a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

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

refactor(did-plc): optimize did:plc identifier creation

Mary da379ce9 e4c7516e

+22 -5
+5
.changeset/clear-eagles-laugh.md
··· 1 + --- 2 + '@atcute/did-plc': patch 3 + --- 4 + 5 + optimize did:plc identifier creation
+1 -1
.changeset/fine-houses-raise.md
··· 1 1 --- 2 - "@atcute/multibase": patch 2 + '@atcute/multibase': patch 3 3 --- 4 4 5 5 alternative base32 encoding implementation
+1 -1
packages/identity/did-plc/lib/utils.ts
··· 32 32 export const deriveDidFromGenesisOp = async (op: t.CompatibleOperation): Promise<t.DidPlcString> => { 33 33 const opBytes = CBOR.encode(op); 34 34 const hash = await toSha256(opBytes); 35 - return `did:plc:${toBase32(hash).slice(0, 24)}`; 35 + return `did:plc:${toBase32(hash.subarray(0, 15))}`; 36 36 }; 37 37 38 38 export const normalizeOp = (op: t.CompatibleOperation): t.Operation => {
+15 -3
packages/utilities/multibase/lib/bases/base32-encode.ts
··· 29 29 // batching into a single String.fromCharCode call for fewer string concats 30 30 const pairs = (full / 2) | 0; 31 31 for (let g = 0; g < pairs; g++) { 32 - const a0 = bytes[ip], a1 = bytes[ip + 1], a2 = bytes[ip + 2], a3 = bytes[ip + 3], a4 = bytes[ip + 4]; 33 - const b0 = bytes[ip + 5], b1 = bytes[ip + 6], b2 = bytes[ip + 7], b3 = bytes[ip + 8], b4 = bytes[ip + 9]; 32 + const a0 = bytes[ip], 33 + a1 = bytes[ip + 1], 34 + a2 = bytes[ip + 2], 35 + a3 = bytes[ip + 3], 36 + a4 = bytes[ip + 4]; 37 + const b0 = bytes[ip + 5], 38 + b1 = bytes[ip + 6], 39 + b2 = bytes[ip + 7], 40 + b3 = bytes[ip + 8], 41 + b4 = bytes[ip + 9]; 34 42 35 43 str += _fromCharCode( 36 44 cc[a0 >>> 3], ··· 55 63 56 64 // remaining full group if odd count 57 65 if (full & 1) { 58 - const b0 = bytes[ip], b1 = bytes[ip + 1], b2 = bytes[ip + 2], b3 = bytes[ip + 3], b4 = bytes[ip + 4]; 66 + const b0 = bytes[ip], 67 + b1 = bytes[ip + 1], 68 + b2 = bytes[ip + 2], 69 + b3 = bytes[ip + 3], 70 + b4 = bytes[ip + 4]; 59 71 60 72 str += _fromCharCode( 61 73 cc[b0 >>> 3],