UNPKG

@gaonengwww/jose

Version:

JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes

37 lines (35 loc) 961 B
// src/util/errors.ts var JOSEError = class extends Error { /** * A unique error code for the particular error subclass. * * @ignore */ static code = "ERR_JOSE_GENERIC"; /** A unique error code for {@link JOSEError}. */ code = "ERR_JOSE_GENERIC"; /** @ignore */ constructor(message, options) { super(message, options); this.name = this.constructor.name; Error.captureStackTrace?.(this, this.constructor); } }; var JWEInvalid = class extends JOSEError { /** @ignore */ static code = "ERR_JWE_INVALID"; /** A unique error code for {@link JWEInvalid}. */ code = "ERR_JWE_INVALID"; }; // src/lib/check_cek_length.ts var check_cek_length_default = (cek, expected) => { const actual = cek.byteLength << 3; if (actual !== expected) { throw new JWEInvalid( `Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits` ); } }; export { check_cek_length_default as default };