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.

feat(cid): expose encode and digest methods

Mary d07a423a 731849de

+3 -3
+3 -3
packages/utilities/cid/lib/index.ts
··· 141 141 */ 142 142 export const create = async (code: number, input: Uint8Array): Promise<CID> => { 143 143 const digest = createDigest(0x12, new Uint8Array(await crypto.subtle.digest('sha-256', input))); 144 - const bytes = encodeCID(1, code, digest.bytes); 144 + const bytes = encode(1, code, digest.bytes); 145 145 146 146 return { 147 147 version: 1, ··· 158 158 return 'b' + base32.encode(cid.bytes); 159 159 }; 160 160 161 - const createDigest = (code: number, digest: Uint8Array): Digest => { 161 + export const createDigest = (code: number, digest: Uint8Array): Digest => { 162 162 const size = digest.byteLength; 163 163 const sizeOffset = varint.encodingLength(code); 164 164 const digestOffset = sizeOffset + varint.encodingLength(size); ··· 176 176 }; 177 177 }; 178 178 179 - const encodeCID = (version: number, code: number, multihash: Uint8Array): Uint8Array => { 179 + export const encode = (version: number, code: number, multihash: Uint8Array): Uint8Array => { 180 180 const codeOffset = varint.encodingLength(version); 181 181 const hashOffset = codeOffset + varint.encodingLength(code); 182 182