diff --git a/packages/jwk-webcrypto/package.json b/packages/jwk-webcrypto/package.json index b91abd7046d..99160716113 100644 --- a/packages/jwk-webcrypto/package.json +++ b/packages/jwk-webcrypto/package.json @@ -21,7 +21,6 @@ "build": "tsc --build tsconfig.build.json" }, "dependencies": { - "@atproto/indexed-db": "workspace:*", "@atproto/jwk": "workspace:*", "@atproto/jwk-jose": "workspace:*" }, diff --git a/packages/jwk-webcrypto/src/db.ts b/packages/jwk-webcrypto/src/db.ts deleted file mode 100644 index 4a59e6315b7..00000000000 --- a/packages/jwk-webcrypto/src/db.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { DB } from '@atproto/indexed-db' -import { fromSubtleAlgorithm, generateKeypair } from './util.js' - -const INDEXED_DB_NAME = '@@jwk-webcrypto' - -export async function loadCryptoKeyPair( - kid: string, - algs: string[], - extractable = false, -): Promise { - type Schema = { - 'oauth-keypair': CryptoKeyPair - } - - const migrations = [ - (db: IDBDatabase) => { - db.createObjectStore('oauth-keypair') - }, - ] - - // eslint-disable-next-line - await using db = await DB.open(INDEXED_DB_NAME, migrations) - - const current = await db.transaction(['oauth-keypair'], 'readonly', (tx) => - tx.objectStore('oauth-keypair').get(kid), - ) - - try { - const alg = fromSubtleAlgorithm(current.privateKey.algorithm) - if (algs.includes(alg) && current.privateKey.extractable === extractable) { - return current - } else if (current) { - throw new Error('Store contained invalid keypair') - } - } catch { - await db.transaction(['oauth-keypair'], 'readwrite', (tx) => - tx.objectStore('oauth-keypair').delete(kid), - ) - } - - return generateKeypair(algs, extractable) -} diff --git a/packages/jwk-webcrypto/src/webcrypto-key.ts b/packages/jwk-webcrypto/src/webcrypto-key.ts index 9731050737e..0b701d24cf2 100644 --- a/packages/jwk-webcrypto/src/webcrypto-key.ts +++ b/packages/jwk-webcrypto/src/webcrypto-key.ts @@ -1,7 +1,6 @@ import { Jwk, jwkSchema } from '@atproto/jwk' import { JoseKey } from '@atproto/jwk-jose' -// XXX TODO: remove "./db.ts" file -// import { loadCryptoKeyPair } from './db.js' + import { generateKeypair, fromSubtleAlgorithm, @@ -9,14 +8,9 @@ import { } from './util.js' export class WebcryptoKey extends JoseKey { - // static async fromIndexedDB(kid: string, allowedAlgos: string[] = ['ES384']) { - // const cryptoKeyPair = await loadCryptoKeyPair(kid, allowedAlgos) - // return this.fromKeypair(kid, cryptoKeyPair) - // } - static async generate( kid: string = crypto.randomUUID(), - allowedAlgos: string[] = ['ES384'], + allowedAlgos: string[] = ['ES256'], exportable = false, ) { const cryptoKeyPair = await generateKeypair(allowedAlgos, exportable) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa9c8db3682..a060f085ebb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -761,9 +761,6 @@ importers: packages/jwk-webcrypto: dependencies: - '@atproto/indexed-db': - specifier: workspace:* - version: link:../indexed-db '@atproto/jwk': specifier: workspace:* version: link:../jwk