@gaonengwww/jose
Version:
JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes
216 lines (214 loc) • 7.28 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/util/errors.ts
var errors_exports = {};
__export(errors_exports, {
JOSEAlgNotAllowed: () => JOSEAlgNotAllowed,
JOSEError: () => JOSEError,
JOSENotSupported: () => JOSENotSupported,
JWEDecryptionFailed: () => JWEDecryptionFailed,
JWEInvalid: () => JWEInvalid,
JWKInvalid: () => JWKInvalid,
JWKSInvalid: () => JWKSInvalid,
JWKSMultipleMatchingKeys: () => JWKSMultipleMatchingKeys,
JWKSNoMatchingKey: () => JWKSNoMatchingKey,
JWKSTimeout: () => JWKSTimeout,
JWSInvalid: () => JWSInvalid,
JWSSignatureVerificationFailed: () => JWSSignatureVerificationFailed,
JWTClaimValidationFailed: () => JWTClaimValidationFailed,
JWTExpired: () => JWTExpired,
JWTInvalid: () => JWTInvalid
});
module.exports = __toCommonJS(errors_exports);
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 JWTClaimValidationFailed = class extends JOSEError {
/** @ignore */
static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
/** A unique error code for {@link JWTClaimValidationFailed}. */
code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
/** The Claim for which the validation failed. */
claim;
/** Reason code for the validation failure. */
reason;
/**
* The parsed JWT Claims Set (aka payload). Other JWT claims may or may not have been verified at
* this point. The JSON Web Signature (JWS) or a JSON Web Encryption (JWE) structures' integrity
* has however been verified. Claims Set verification happens after the JWS Signature or JWE
* Decryption processes.
*/
payload;
/** @ignore */
constructor(message, payload, claim = "unspecified", reason = "unspecified") {
super(message, { cause: { claim, reason, payload } });
this.claim = claim;
this.reason = reason;
this.payload = payload;
}
};
var JWTExpired = class extends JOSEError {
/** @ignore */
static code = "ERR_JWT_EXPIRED";
/** A unique error code for {@link JWTExpired}. */
code = "ERR_JWT_EXPIRED";
/** The Claim for which the validation failed. */
claim;
/** Reason code for the validation failure. */
reason;
/**
* The parsed JWT Claims Set (aka payload). Other JWT claims may or may not have been verified at
* this point. The JSON Web Signature (JWS) or a JSON Web Encryption (JWE) structures' integrity
* has however been verified. Claims Set verification happens after the JWS Signature or JWE
* Decryption processes.
*/
payload;
/** @ignore */
constructor(message, payload, claim = "unspecified", reason = "unspecified") {
super(message, { cause: { claim, reason, payload } });
this.claim = claim;
this.reason = reason;
this.payload = payload;
}
};
var JOSEAlgNotAllowed = class extends JOSEError {
/** @ignore */
static code = "ERR_JOSE_ALG_NOT_ALLOWED";
/** A unique error code for {@link JOSEAlgNotAllowed}. */
code = "ERR_JOSE_ALG_NOT_ALLOWED";
};
var JOSENotSupported = class extends JOSEError {
/** @ignore */
static code = "ERR_JOSE_NOT_SUPPORTED";
/** A unique error code for {@link JOSENotSupported}. */
code = "ERR_JOSE_NOT_SUPPORTED";
};
var JWEDecryptionFailed = class extends JOSEError {
/** @ignore */
static code = "ERR_JWE_DECRYPTION_FAILED";
/** A unique error code for {@link JWEDecryptionFailed}. */
code = "ERR_JWE_DECRYPTION_FAILED";
/** @ignore */
constructor(message = "decryption operation failed", options) {
super(message, options);
}
};
var JWEInvalid = class extends JOSEError {
/** @ignore */
static code = "ERR_JWE_INVALID";
/** A unique error code for {@link JWEInvalid}. */
code = "ERR_JWE_INVALID";
};
var JWSInvalid = class extends JOSEError {
/** @ignore */
static code = "ERR_JWS_INVALID";
/** A unique error code for {@link JWSInvalid}. */
code = "ERR_JWS_INVALID";
};
var JWTInvalid = class extends JOSEError {
/** @ignore */
static code = "ERR_JWT_INVALID";
/** A unique error code for {@link JWTInvalid}. */
code = "ERR_JWT_INVALID";
};
var JWKInvalid = class extends JOSEError {
/** @ignore */
static code = "ERR_JWK_INVALID";
/** A unique error code for {@link JWKInvalid}. */
code = "ERR_JWK_INVALID";
};
var JWKSInvalid = class extends JOSEError {
/** @ignore */
static code = "ERR_JWKS_INVALID";
/** A unique error code for {@link JWKSInvalid}. */
code = "ERR_JWKS_INVALID";
};
var JWKSNoMatchingKey = class extends JOSEError {
/** @ignore */
static code = "ERR_JWKS_NO_MATCHING_KEY";
/** A unique error code for {@link JWKSNoMatchingKey}. */
code = "ERR_JWKS_NO_MATCHING_KEY";
/** @ignore */
constructor(message = "no applicable key found in the JSON Web Key Set", options) {
super(message, options);
}
};
var JWKSMultipleMatchingKeys = class extends JOSEError {
/** @ignore */
[Symbol.asyncIterator];
/** @ignore */
static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
/** A unique error code for {@link JWKSMultipleMatchingKeys}. */
code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
/** @ignore */
constructor(message = "multiple matching keys found in the JSON Web Key Set", options) {
super(message, options);
}
};
var JWKSTimeout = class extends JOSEError {
/** @ignore */
static code = "ERR_JWKS_TIMEOUT";
/** A unique error code for {@link JWKSTimeout}. */
code = "ERR_JWKS_TIMEOUT";
/** @ignore */
constructor(message = "request timed out", options) {
super(message, options);
}
};
var JWSSignatureVerificationFailed = class extends JOSEError {
/** @ignore */
static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
/** A unique error code for {@link JWSSignatureVerificationFailed}. */
code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
/** @ignore */
constructor(message = "signature verification failed", options) {
super(message, options);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
JOSEAlgNotAllowed,
JOSEError,
JOSENotSupported,
JWEDecryptionFailed,
JWEInvalid,
JWKInvalid,
JWKSInvalid,
JWKSMultipleMatchingKeys,
JWKSNoMatchingKey,
JWKSTimeout,
JWSInvalid,
JWSSignatureVerificationFailed,
JWTClaimValidationFailed,
JWTExpired,
JWTInvalid
});