{"version":3,"file":"legacy.mjs","names":[],"sources":["../../../src/modules/kms/legacy.ts"],"sourcesContent":["import { TypedArrayEncoder } from '../../utils'\nimport { KeyManagementError } from './error/KeyManagementError'\nimport type { PublicJwk } from './jwk/PublicJwk'\n\n/**\n * Returns the legacy key id based on the public key encoded as base58\n *\n * This is what was has been used by askar\n */\nexport function legacyKeyIdFromPublicJwk(publicJwk: PublicJwk) {\n  // Compressed public keys were used for legacy key ids\n  const compressedPublicKey = publicJwk.compressedPublicKey\n  if (compressedPublicKey) {\n    return TypedArrayEncoder.toBase58(compressedPublicKey.publicKey)\n  }\n\n  const publicKey = publicJwk.publicKey\n  if (publicKey.kty === 'RSA') {\n    throw new KeyManagementError(\n      'Unable to derive legacy key id from RSA key. Support for RSA keys was only added after explicit key ids were added.'\n    )\n  }\n\n  return TypedArrayEncoder.toBase58(publicKey.publicKey)\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,yBAAyB,WAAsB;CAE7D,MAAM,sBAAsB,UAAU;CACtC,IAAI,qBACF,OAAO,kBAAkB,SAAS,oBAAoB,SAAS;CAGjE,MAAM,YAAY,UAAU;CAC5B,IAAI,UAAU,QAAQ,OACpB,MAAM,IAAI,mBACR,qHACF;CAGF,OAAO,kBAAkB,SAAS,UAAU,SAAS;AACvD"}