UNPKG

@credo-ts/core

Version:

<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1

76 lines (72 loc) • 2.83 kB
import { KnownJwaContentEncryptionAlgorithms } from "../jwk/jwa.mjs"; import { zAnyUint8Array } from "../../../utils/zod.mjs"; import { zKmsJwkPrivateOct } from "../jwk/kty/oct/octJwk.mjs"; import { zKmsKeyId } from "./common.mjs"; import { zKmsKeyAgreementDecryptOptions } from "./KmsKeyAgreementDecryptOptions.mjs"; import { z } from "zod"; //#region src/modules/kms/options/KmsDecryptOptions.ts const zKmsDecryptDataDecryptionAesGcm = z.object({ algorithm: z.enum([ KnownJwaContentEncryptionAlgorithms.A128GCM, KnownJwaContentEncryptionAlgorithms.A192GCM, KnownJwaContentEncryptionAlgorithms.A256GCM ]), iv: zAnyUint8Array.refine((iv) => iv.length === 12, "iv must be 12 bytes for AES GCM"), aad: z.optional(zAnyUint8Array), tag: zAnyUint8Array }); const zKmsDecryptDataDecryptionAesCbc = z.object({ algorithm: z.enum([KnownJwaContentEncryptionAlgorithms.A128CBC, KnownJwaContentEncryptionAlgorithms.A256CBC]), iv: zAnyUint8Array.refine((iv) => iv.length === 16, "iv must be 16 bytes for AES CBC") }); const zKmsDecryptDataDecryptionAesCbcHmac = z.object({ algorithm: z.enum([ KnownJwaContentEncryptionAlgorithms.A128CBC_HS256, KnownJwaContentEncryptionAlgorithms.A192CBC_HS384, KnownJwaContentEncryptionAlgorithms.A256CBC_HS512 ]), iv: zAnyUint8Array.refine((iv) => iv.length === 16, "iv must be 16 bytes for AES CBC with HMAC"), aad: z.optional(zAnyUint8Array), tag: zAnyUint8Array }); const zKmsDecryptDataDecryptionSalsa = z.object({ algorithm: z.enum([KnownJwaContentEncryptionAlgorithms["XSALSA20-POLY1305"]]), iv: zAnyUint8Array.optional() }); const zKmsDecryptDataDecryptionC20p = z.object({ algorithm: z.enum([KnownJwaContentEncryptionAlgorithms.C20P, KnownJwaContentEncryptionAlgorithms.XC20P]), iv: zAnyUint8Array, aad: z.optional(zAnyUint8Array), tag: zAnyUint8Array }); const zKmsDecryptDataDecryption = z.discriminatedUnion("algorithm", [ zKmsDecryptDataDecryptionAesCbc, zKmsDecryptDataDecryptionAesCbcHmac, zKmsDecryptDataDecryptionAesGcm, zKmsDecryptDataDecryptionC20p, zKmsDecryptDataDecryptionSalsa ]); const zKmsDecryptOptions = z.object({ key: z.union([ z.object({ keyId: zKmsKeyId, privateJwk: z.never().optional(), keyAgreement: z.never().optional() }), z.object({ privateJwk: zKmsJwkPrivateOct.describe("A private oct (symmetric) jwk"), keyId: z.never().optional(), keyAgreement: z.never().optional() }), z.object({ keyAgreement: zKmsKeyAgreementDecryptOptions, keyId: z.never().optional(), privateJwk: z.never().optional() }) ]), decryption: zKmsDecryptDataDecryption.describe("Options related to the decryption algorithm to use for decrypting the data"), encrypted: zAnyUint8Array.describe("The encrypted data to decrypt") }); //#endregion export { zKmsDecryptOptions }; //# sourceMappingURL=KmsDecryptOptions.mjs.map