{"version":3,"file":"jwa.mjs","names":[],"sources":["../../../../src/modules/kms/jwk/jwa.ts"],"sourcesContent":["import { z } from 'zod'\n\nfunction recordToUnion<T>(record: Record<string, T>) {\n  return Object.values(record) as [\n    (typeof record)[keyof typeof record],\n    (typeof record)[keyof typeof record],\n    ...(typeof record)[keyof typeof record][],\n  ]\n}\n\nexport const KnownJwaSignatureAlgorithms = {\n  HS256: 'HS256',\n  HS384: 'HS384',\n  HS512: 'HS512',\n  RS256: 'RS256',\n  RS384: 'RS384',\n  RS512: 'RS512',\n  ES256: 'ES256',\n  ES384: 'ES384',\n  ES512: 'ES512',\n  PS256: 'PS256',\n  PS384: 'PS384',\n  PS512: 'PS512',\n  EdDSA: 'EdDSA',\n  Ed25519: 'Ed25519',\n  ES256K: 'ES256K',\n} as const\n\nexport const zKnownJwaSignatureAlgorithm = z.enum(recordToUnion(KnownJwaSignatureAlgorithms))\nexport type KnownJwaSignatureAlgorithm = z.output<typeof zKnownJwaSignatureAlgorithm>\n\nexport function isKnownJwaSignatureAlgorithm(alg: string): alg is KnownJwaSignatureAlgorithm {\n  return Object.values(KnownJwaSignatureAlgorithms).includes(alg as keyof typeof KnownJwaSignatureAlgorithms)\n}\n\n// Content encryption algorithms (\"enc\" parameter)\nexport const KnownJwaContentEncryptionAlgorithms = {\n  // AES-GCM Content Encryption\n  A128GCM: 'A128GCM',\n  A192GCM: 'A192GCM',\n  A256GCM: 'A256GCM',\n\n  // AES-CBC Content Encryption\n  A128CBC: 'A128CBC',\n  A256CBC: 'A256CBC',\n\n  // (X)ChaCha20-Poly1305\n  C20P: 'C20P',\n  XC20P: 'XC20P',\n\n  /**\n   * As is used in DIDComm v1\n   */\n  'XSALSA20-POLY1305': 'XSALSA20-POLY1305',\n\n  A128CBC_HS256: 'A128CBC-HS256',\n  A192CBC_HS384: 'A192CBC-HS384',\n  A256CBC_HS512: 'A256CBC-HS512',\n} as const\nexport const zKnownJwaContentEncryptionAlgorithm = z.enum(recordToUnion(KnownJwaContentEncryptionAlgorithms))\nexport type KnownJwaContentEncryptionAlgorithm = z.output<typeof zKnownJwaContentEncryptionAlgorithm>\n\nexport const KnownJwaKeyEncryptionAlgorithms = {\n  // AES Key Wrapping\n  A128KW: 'A128KW',\n  A192KW: 'A192KW',\n  A256KW: 'A256KW',\n} as const\nconst zKnownJwaKeyEncryptionAlgorithm = z.enum(recordToUnion(KnownJwaKeyEncryptionAlgorithms))\nexport type KnownJwaKeyEncryptionAlgorithm = z.output<typeof zKnownJwaKeyEncryptionAlgorithm>\n\n// Key derivation / wrapping algorithms (\"alg\" parameter)\nexport const KnownJwaKeyAgreementAlgorithms = {\n  // ECDH-ES with P-256/P-384/P-521\n  ECDH_ES: 'ECDH-ES',\n  ECDH_ES_A128KW: 'ECDH-ES+A128KW',\n  ECDH_ES_A192KW: 'ECDH-ES+A192KW',\n  ECDH_ES_A256KW: 'ECDH-ES+A256KW',\n\n  ECDH_HSALSA20: 'ECDH-HSALSA20',\n} as const\nconst zKnownJwaKeyAgreementAlgorithm = z.enum(recordToUnion(KnownJwaKeyAgreementAlgorithms))\nexport type KnownJwaKeyAgreementAlgorithm = z.output<typeof zKnownJwaKeyAgreementAlgorithm>\n"],"mappings":";;;;;AAEA,SAAS,cAAiB,QAA2B;AACnD,QAAO,OAAO,OAAO,OAAO;;AAO9B,MAAa,8BAA8B;CACzC,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,SAAS;CACT,QAAQ;CACT;AAED,MAAa,8BAA8B,EAAE,KAAK,cAAc,4BAA4B,CAAC;AAG7F,SAAgB,6BAA6B,KAAgD;AAC3F,QAAO,OAAO,OAAO,4BAA4B,CAAC,SAAS,IAAgD;;AAI7G,MAAa,sCAAsC;CAEjD,SAAS;CACT,SAAS;CACT,SAAS;CAGT,SAAS;CACT,SAAS;CAGT,MAAM;CACN,OAAO;CAKP,qBAAqB;CAErB,eAAe;CACf,eAAe;CACf,eAAe;CAChB;AACD,MAAa,sCAAsC,EAAE,KAAK,cAAc,oCAAoC,CAAC;AAG7G,MAAa,kCAAkC;CAE7C,QAAQ;CACR,QAAQ;CACR,QAAQ;CACT;AACuC,EAAE,KAAK,cAAc,gCAAgC,CAAC;AAI9F,MAAa,iCAAiC;CAE5C,SAAS;CACT,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAEhB,eAAe;CAChB;AACsC,EAAE,KAAK,cAAc,+BAA+B,CAAC"}