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

81 lines (77 loc) • 2.22 kB
import { zKnownJwaSignatureAlgorithm } from "../jwk/jwa.mjs"; import { zKmsJwkPublicEc } from "../jwk/kty/ec/ecJwk.mjs"; import { zKmsJwkPublicOct } from "../jwk/kty/oct/octJwk.mjs"; import { zKmsJwkPublicOkp } from "../jwk/kty/okp/okpJwk.mjs"; import { zKmsJwkPublicRsa } from "../jwk/kty/rsa/rsaJwk.mjs"; import { zKmsKeyId } from "./common.mjs"; import { z } from "zod"; //#region src/modules/kms/options/KmsCreateKeyOptions.ts const zKmsCreateKeyTypeEc = zKmsJwkPublicEc.pick({ kty: true, crv: true }); /** * Octer key pair, commonly used for Ed25519 and X25519 key types */ const zKmsCreateKeyTypeOkp = zKmsJwkPublicOkp.pick({ kty: true, crv: true }); /** * RSA key pair. */ const zKmsCreateKeyTypeRsa = zKmsJwkPublicRsa.pick({ kty: true }).extend({ modulusLength: z.union([ z.literal(2048), z.literal(3072), z.literal(4096) ]) }); /** * Represents an octect sequence for symmetric keys */ const zKmsCreateKeyTypeOct = z.discriminatedUnion("algorithm", [ z.object({ kty: zKmsJwkPublicOct.shape.kty, algorithm: z.literal("aes"), length: z.union([ z.literal(128), z.literal(192), z.literal(256), z.number().int().refine((length) => length % 8 === 0, "aes key length must be multiple of 8") ]) }), z.object({ kty: zKmsJwkPublicOct.shape.kty, algorithm: z.literal("hmac").describe("For usage with HS256, HS384 and HS512"), length: z.union([ z.literal(256), z.literal(384), z.literal(512) ]) }), z.object({ kty: zKmsJwkPublicOct.shape.kty, algorithm: z.literal("C20P").describe("For usage with ChaCha20-Poly1305 and XChaCha20-Poly1305") }) ]); const zKmsCreateKeyTypeAsymmetric = z.union([ zKmsCreateKeyTypeEc, zKmsCreateKeyTypeOkp, zKmsCreateKeyTypeRsa ]); const zKmsCreateKeyType = z.union([ zKmsCreateKeyTypeEc, zKmsCreateKeyTypeOkp, zKmsCreateKeyTypeRsa, zKmsCreateKeyTypeOct ]); const zKmsCreateKeyOptions = z.object({ keyId: z.optional(zKmsKeyId), type: zKmsCreateKeyType }); const zKmsCreateKeyForSignatureAlgorithmOptions = z.object({ keyId: z.optional(zKmsKeyId), algorithm: zKnownJwaSignatureAlgorithm }); //#endregion export { zKmsCreateKeyForSignatureAlgorithmOptions, zKmsCreateKeyOptions }; //# sourceMappingURL=KmsCreateKeyOptions.mjs.map