{"version":3,"file":"assertSupported.mjs","names":[],"sources":["../../../../src/modules/kms/jwk/assertSupported.ts"],"sourcesContent":["import { KeyManagementAlgorithmNotSupportedError } from '../error/KeyManagementAlgorithmNotSupportedError'\nimport type {\n  KmsDecryptDataDecryption,\n  KmsEncryptDataEncryption,\n  KmsKeyAgreementDecryptOptions,\n  KmsKeyAgreementEncryptOptions,\n} from '../options'\nimport type {\n  KnownJwaContentEncryptionAlgorithm,\n  KnownJwaKeyAgreementAlgorithm,\n  KnownJwaKeyEncryptionAlgorithm,\n} from './jwa'\n\nexport function assertSupportedKeyAgreementAlgorithm<\n  KeyAgreement extends KmsKeyAgreementEncryptOptions | KmsKeyAgreementDecryptOptions,\n  SupportedAlgorithms extends KnownJwaKeyAgreementAlgorithm[],\n>(\n  keyAgreement: KeyAgreement,\n  supportedAlgorithms: SupportedAlgorithms,\n  backend: string\n): asserts keyAgreement is KeyAgreement & { algorithm: SupportedAlgorithms[number] } {\n  if (!supportedAlgorithms.includes(keyAgreement.algorithm as (typeof supportedAlgorithms)[number])) {\n    throw new KeyManagementAlgorithmNotSupportedError(\n      `JWA key agreement algorithm '${keyAgreement.algorithm}'`,\n      backend\n    )\n  }\n}\n\nexport function assertSupportedEncryptionAlgorithm<\n  Encryption extends KmsEncryptDataEncryption | KmsDecryptDataDecryption,\n  SupportedAlgorithms extends Array<KnownJwaContentEncryptionAlgorithm | KnownJwaKeyEncryptionAlgorithm>,\n>(\n  encryption: Encryption,\n  supportedAlgorithms: SupportedAlgorithms,\n  backend: string\n): asserts encryption is Encryption & { algorithm: SupportedAlgorithms[number] } {\n  if (!supportedAlgorithms.includes(encryption.algorithm as (typeof supportedAlgorithms)[number])) {\n    throw new KeyManagementAlgorithmNotSupportedError(`JWA encryption algorithm '${encryption.algorithm}'`, backend)\n  }\n}\n"],"mappings":";;;;;AAaA,SAAgB,qCAId,cACA,qBACA,SACmF;AACnF,KAAI,CAAC,oBAAoB,SAAS,aAAa,UAAkD,CAC/F,OAAM,IAAI,wCACR,gCAAgC,aAAa,UAAU,IACvD,QACD;;AAIL,SAAgB,mCAId,YACA,qBACA,SAC+E;AAC/E,KAAI,CAAC,oBAAoB,SAAS,WAAW,UAAkD,CAC7F,OAAM,IAAI,wCAAwC,6BAA6B,WAAW,UAAU,IAAI,QAAQ"}