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

31 lines (30 loc) • 1.87 kB
import { KeyManagementError } from "../error/KeyManagementError.mjs"; import { getJwkHumanDescription } from "../jwk/humanDescription.mjs"; import "../jwk/index.mjs"; //#region src/modules/kms/options/KmsOperation.ts function getKmsOperationHumanDescription(operation) { if (operation.operation === "deleteKey") return "'deleteKey' operation"; if (operation.operation === "createKey") { let base = `'createKey' operation with kty '${operation.type.kty}'`; if (operation.type.kty === "EC" || operation.type.kty === "OKP") base += ` and crv '${operation.type.crv}'`; else if (operation.type.kty === "RSA") base += ` and bit length '${operation.type.modulusLength}'`; else if (operation.type.kty === "oct") { base += ` and algorithm '${operation.type.algorithm}'`; if (operation.type.algorithm === "aes" || operation.type.algorithm === "hmac") base += ` with key length '${operation.type.length}'`; } return base; } if (operation.operation === "importKey") return `'importKey' operation with ${getJwkHumanDescription(operation.privateJwk)}`; if (operation.operation === "sign" || operation.operation === "verify") return `'${operation.operation}' operation with algorithm '${operation.algorithm}'`; if (operation.operation === "encrypt" || operation.operation === "decrypt") { const encryption = operation.operation === "encrypt" ? operation.encryption : operation.decryption; let message = `'${operation.operation}' operation with encryption algorithm '${encryption.algorithm}'`; if (operation.keyAgreement) message += ` and key agreement algorithm '${operation.keyAgreement.algorithm}'`; return message; } if (operation.operation === "randomBytes") return `'randomBytes' operation`; throw new KeyManagementError("Unsupported operation"); } //#endregion export { getKmsOperationHumanDescription }; //# sourceMappingURL=KmsOperation.mjs.map