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(crypto): make Deno runtime try node:crypto if available

Mary 812b68e6 52d020db

+36 -2
+5
.changeset/goofy-humans-know.md
··· 1 + --- 2 + '@atcute/crypto': minor 3 + --- 4 + 5 + make Deno runtime try node:crypto if available
+28
packages/utilities/crypto/lib/keypairs/secp256k1-deno.ts
··· 1 + import { Buffer } from 'node:buffer'; 2 + import { createPrivateKey } from 'node:crypto'; 3 + 4 + import * as node from './secp256k1-node.js'; 5 + import * as noble from './secp256k1-web.js'; 6 + 7 + export { SECP256K1_PRIVATE_PREFIX, SECP256K1_PUBLIC_PREFIX } from './secp256k1-node.ts'; 8 + 9 + const backend = (() => { 10 + try { 11 + const privateKeyBytes = new Uint8Array(32); 12 + privateKeyBytes[31] = 1; 13 + 14 + createPrivateKey({ 15 + key: Buffer.concat([node.PKCS8_PRIVATE_KEY_PREFIX, privateKeyBytes]), 16 + format: 'der', 17 + type: 'pkcs8', 18 + }); 19 + 20 + return node; 21 + } catch { 22 + return noble; 23 + } 24 + })(); 25 + 26 + export const Secp256k1PublicKey = backend.Secp256k1PublicKey; 27 + export const Secp256k1PrivateKey = backend.Secp256k1PrivateKey; 28 + export const Secp256k1PrivateKeyExportable = backend.Secp256k1PrivateKeyExportable;
+2 -1
packages/utilities/crypto/lib/keypairs/secp256k1-node.ts
··· 40 40 ]); 41 41 42 42 // @see p256.ts 43 - const PKCS8_PRIVATE_KEY_PREFIX = Uint8Array.from([ 43 + /** @internal */ 44 + export const PKCS8_PRIVATE_KEY_PREFIX = Uint8Array.from([ 44 45 ...[/* SEQ */ 0x30, /* len */ 0x3e], // PrivateKeyInfo 45 46 /**/ ...[/* INT */ 0x02, /* len */ 0x01, /* 0 */ 0x00], // Version 46 47 /**/ ...ASN1_ALGORITHM_IDENTIFIER, // AlgorithmIdentifier
+1 -1
packages/utilities/crypto/package.json
··· 26 26 "imports": { 27 27 "#keypairs/secp256k1": { 28 28 "bun": "./dist/keypairs/secp256k1-web.js", 29 - "deno": "./dist/keypairs/secp256k1-web.js", 29 + "deno": "./dist/keypairs/secp256k1-deno.js", 30 30 "node": "./dist/keypairs/secp256k1-node.js", 31 31 "default": "./dist/keypairs/secp256k1-web.js" 32 32 }