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

Configure Feed

Select the types of activity you want to include in your feed.

constant did len of 24 (#31)

authored by

Daniel Holmgren and committed by
GitHub
7263b1c7 ca9d3b60

+4 -9
+4 -9
packages/lib/src/operations.ts
··· 6 6 import * as t from './types' 7 7 import { 8 8 GenesisHashError, 9 - ImproperlyFormattedDidError, 10 9 ImproperOperationError, 11 10 InvalidSignatureError, 12 11 MisorderedOperationError, 13 12 UnsupportedKeyError, 14 13 } from './error' 15 14 16 - export const didForCreateOp = async (op: t.CompatibleOp, truncate = 24) => { 15 + export const didForCreateOp = async (op: t.CompatibleOp) => { 17 16 const hashOfGenesis = await sha256(cbor.encode(op)) 18 17 const hashB32 = uint8arrays.toString(hashOfGenesis, 'base32') 19 - const truncated = hashB32.slice(0, truncate) 18 + const truncated = hashB32.slice(0, 24) 20 19 return `did:plc:${truncated}` 21 20 } 22 21 ··· 273 272 const normalized = normalizeOp(op) 274 273 await assureValidOp(normalized) 275 274 await assureValidSig(normalized.rotationKeys, op) 276 - const expectedDid = await didForCreateOp(op, 64) 277 - // id must be >=24 chars & prefix is 8chars 278 - if (did.length < 32) { 279 - throw new ImproperlyFormattedDidError('too short') 280 - } 281 - if (!expectedDid.startsWith(did)) { 275 + const expectedDid = await didForCreateOp(op) 276 + if (expectedDid !== did) { 282 277 throw new GenesisHashError(expectedDid) 283 278 } 284 279 if (op.prev !== null) {