@gaonengwww/jose
Version:
JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes
177 lines (176 loc) • 5.66 kB
JavaScript
// 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 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);
}
};
export {
JOSEAlgNotAllowed,
JOSEError,
JOSENotSupported,
JWEDecryptionFailed,
JWEInvalid,
JWKInvalid,
JWKSInvalid,
JWKSMultipleMatchingKeys,
JWKSNoMatchingKey,
JWKSTimeout,
JWSInvalid,
JWSSignatureVerificationFailed,
JWTClaimValidationFailed,
JWTExpired,
JWTInvalid
};