Fork of github.com/did-method-plc/did-method-plc

refactor did:key check to reuse extractMultikey util logic

Changed files
+6 -3
packages
server
+6 -3
packages/server/src/constraints.ts
···
import { DAY, HOUR, cborEncode } from '@atproto/common'
import * as plc from '@did-plc/lib'
import { ServerError } from './error'
-
import { parseDidKey } from '@atproto/crypto'
const MAX_OP_BYTES = 4000
const MAX_AKA_ENTRIES = 10
···
`Verification Method id too long (max ${MAX_ID_LENGTH}): ${id}`,
)
}
-
// perform only minimal did:key syntax checking
-
if (!key.startsWith('did:key:')) {
throw new ServerError(400, `Invalid verificationMethod key: ${key}`)
}
}
···
import { DAY, HOUR, cborEncode } from '@atproto/common'
import * as plc from '@did-plc/lib'
import { ServerError } from './error'
+
import { extractMultikey, parseDidKey } from '@atproto/crypto'
const MAX_OP_BYTES = 4000
const MAX_AKA_ENTRIES = 10
···
`Verification Method id too long (max ${MAX_ID_LENGTH}): ${id}`,
)
}
+
try {
+
// perform only minimal did:key syntax checking, with no restrictions on
+
// key types
+
extractMultikey(key)
+
} catch (err) {
throw new ServerError(400, `Invalid verificationMethod key: ${key}`)
}
}