@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
84 lines (83 loc) • 3.04 kB
JavaScript
import { isJwaHpkeAlgorithm, zKnownJwaHpkeAlgorithm } from "../jwk/jwa.mjs";
import { zAnyUint8Array } from "../../../utils/zod.mjs";
import { zKmsJwkPublicEc } from "../jwk/kty/ec/ecJwk.mjs";
import { zKmsJwkPublicOkp } from "../jwk/kty/okp/okpJwk.mjs";
import { zKmsKeyId } from "./common.mjs";
import { z as z$1 } from "zod";
//#region src/modules/kms/options/KmsKeyAgreementEncryptOptions.ts
const zKmsJwkPublicEcdh = z$1.union([zKmsJwkPublicOkp.extend({ crv: zKmsJwkPublicOkp.shape.crv.extract(["X25519"]) }), zKmsJwkPublicEc.extend({ crv: zKmsJwkPublicEc.shape.crv.extract([
"P-256",
"P-384",
"P-521",
"secp256k1"
]) })]);
const zKmsKeyAgreementEcdhEs = z$1.object({
/**
* The key id pointing to the ephemeral public key.
*
* The key type MUST match with the externalPublicJwk
*/
keyId: zKmsKeyId,
algorithm: z$1.literal("ECDH-ES"),
externalPublicJwk: zKmsJwkPublicEcdh,
apu: z$1.optional(zAnyUint8Array),
apv: z$1.optional(zAnyUint8Array)
});
const zKmsKeyAgreementEncryptEcdhEsKw = z$1.object({
/**
* The key id pointing to the ephemeral public key.
*
* The key type MUST match with the externalPublicJwk
*/
keyId: zKmsKeyId,
algorithm: z$1.enum([
"ECDH-ES+A128KW",
"ECDH-ES+A192KW",
"ECDH-ES+A256KW"
]),
externalPublicJwk: zKmsJwkPublicEcdh,
apu: z$1.optional(zAnyUint8Array),
apv: z$1.optional(zAnyUint8Array)
});
const zKmsKeyAgreementEncryptEcdhHsalsa20 = z$1.object({
/**
* The key id to use for encrypting the content encryption key.
* If no key id is provided, anonymous encryption is used.
*/
keyId: zKmsKeyId.optional(),
/**
* Perform key agreement based on the HSALSA20 as used in Libsodium's
* Cryptobox. This is not based on an official JWA algorithm, but is
* used primarily for DIDComm v1 messaging.
*/
algorithm: z$1.literal("ECDH-HSALSA20"),
externalPublicJwk: zKmsJwkPublicOkp.extend({ crv: zKmsJwkPublicOkp.shape.crv.extract(["X25519"]) })
});
const zKmsKeyAgreementEncryptHpke = z$1.object({
/**
* HPKE (RFC 9180) in single-shot base mode. The suite fixes the AEAD, so `encryption` must not be
* provided on the top-level encrypt options.
*/
algorithm: zKnownJwaHpkeAlgorithm,
/**
* The public key of the recipient (`pkR`). HPKE generates its own ephemeral sender key, so no
* `keyId` is used for sealing.
*/
externalPublicJwk: zKmsJwkPublicEcdh,
/**
* Application supplied information, bound into the HPKE key schedule.
*/
info: z$1.optional(zAnyUint8Array)
});
const zKmsKeyAgreementEncryptOptions = z$1.discriminatedUnion("algorithm", [
zKmsKeyAgreementEcdhEs,
zKmsKeyAgreementEncryptEcdhEsKw,
zKmsKeyAgreementEncryptEcdhHsalsa20,
zKmsKeyAgreementEncryptHpke
]).describe("Options for key agreement based on an asymmetric key.");
function isKmsKeyAgreementEncryptHpke(keyAgreement) {
return isJwaHpkeAlgorithm(keyAgreement.algorithm);
}
//#endregion
export { isKmsKeyAgreementEncryptHpke, zKmsJwkPublicEcdh, zKmsKeyAgreementEcdhEs, zKmsKeyAgreementEncryptHpke, zKmsKeyAgreementEncryptOptions };
//# sourceMappingURL=KmsKeyAgreementEncryptOptions.mjs.map