@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
73 lines (72 loc) • 2.57 kB
JavaScript
import { isJwaHpkeAlgorithm, zKnownJwaHpkeAlgorithm } from "../jwk/jwa.mjs";
import { zAnyUint8Array } from "../../../utils/zod.mjs";
import { zKmsJwkPublicOkp } from "../jwk/kty/okp/okpJwk.mjs";
import { zKmsKeyId } from "./common.mjs";
import { zKmsJwkPublicEcdh, zKmsKeyAgreementEcdhEs } from "./KmsKeyAgreementEncryptOptions.mjs";
import { zKmsEncryptedKey } from "./KmsEncryptOptions.mjs";
import { z as z$1 } from "zod";
//#region src/modules/kms/options/KmsKeyAgreementDecryptOptions.ts
const zKmsKeyAgreementDecryptEcdhEsKw = 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,
/**
* The encrypted content encryption key (cek)
*/
encryptedKey: zKmsEncryptedKey,
apu: z$1.optional(zAnyUint8Array),
apv: z$1.optional(zAnyUint8Array)
});
const zKmsKeyAgreementDecryptEcdhHsalsa20 = z$1.object({
/**
* The key id to use for decrypting the content encryption key.
*/
keyId: zKmsKeyId,
/**
* 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"),
/**
* Can be undefined for anonymous encryption
*/
externalPublicJwk: zKmsJwkPublicOkp.extend({ crv: zKmsJwkPublicOkp.shape.crv.extract(["X25519"]) }).optional()
});
const zKmsKeyAgreementDecryptHpke = z$1.object({
/**
* The key id pointing to the recipient private key (`skR`).
*/
keyId: zKmsKeyId,
algorithm: zKnownJwaHpkeAlgorithm,
/**
* The raw serialized encapsulated key (`enc`) generated by the sender. For the DHKEM(P-256)
* suites this is the 65-byte uncompressed SEC1 point.
*/
encapsulatedKey: zAnyUint8Array,
/**
* Application supplied information, bound into the HPKE key schedule.
*/
info: z$1.optional(zAnyUint8Array)
});
const zKmsKeyAgreementDecryptOptions = z$1.discriminatedUnion("algorithm", [
zKmsKeyAgreementEcdhEs,
zKmsKeyAgreementDecryptEcdhEsKw,
zKmsKeyAgreementDecryptEcdhHsalsa20,
zKmsKeyAgreementDecryptHpke
]).describe("Options for key agreement based on an asymmetric key.");
function isKmsKeyAgreementDecryptHpke(keyAgreement) {
return isJwaHpkeAlgorithm(keyAgreement.algorithm);
}
//#endregion
export { isKmsKeyAgreementDecryptHpke, zKmsKeyAgreementDecryptHpke, zKmsKeyAgreementDecryptOptions };
//# sourceMappingURL=KmsKeyAgreementDecryptOptions.mjs.map