jose/dist/node/esm/util/errors.js
2021-09-10 11:21:11 +02:00

108 lines
3.2 KiB
JavaScript

export class JOSEError extends Error {
constructor(message) {
super(message);
this.code = JOSEError.code;
this.name = this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
}
JOSEError.code = 'ERR_JOSE_GENERIC';
export class JWTClaimValidationFailed extends JOSEError {
constructor(message, claim = 'unspecified', reason = 'unspecified') {
super(message);
this.code = JWTClaimValidationFailed.code;
this.claim = claim;
this.reason = reason;
}
}
JWTClaimValidationFailed.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
export class JOSEAlgNotAllowed extends JOSEError {
constructor() {
super(...arguments);
this.code = JOSEAlgNotAllowed.code;
}
}
JOSEAlgNotAllowed.code = 'ERR_JOSE_ALG_NOT_ALLOWED';
export class JOSENotSupported extends JOSEError {
constructor() {
super(...arguments);
this.code = JOSENotSupported.code;
}
}
JOSENotSupported.code = 'ERR_JOSE_NOT_SUPPORTED';
export class JWEDecryptionFailed extends JOSEError {
constructor() {
super(...arguments);
this.code = JWEDecryptionFailed.code;
this.message = 'decryption operation failed';
}
}
JWEDecryptionFailed.code = 'ERR_JWE_DECRYPTION_FAILED';
export class JWEInvalid extends JOSEError {
constructor() {
super(...arguments);
this.code = JWEInvalid.code;
}
}
JWEInvalid.code = 'ERR_JWE_INVALID';
export class JWSInvalid extends JOSEError {
constructor() {
super(...arguments);
this.code = JWSInvalid.code;
}
}
JWSInvalid.code = 'ERR_JWS_INVALID';
export class JWTInvalid extends JOSEError {
constructor() {
super(...arguments);
this.code = JWTInvalid.code;
}
}
JWTInvalid.code = 'ERR_JWT_INVALID';
export class JWKInvalid extends JOSEError {
constructor() {
super(...arguments);
this.code = JWKInvalid.code;
}
}
JWKInvalid.code = 'ERR_JWK_INVALID';
export class JWKSInvalid extends JOSEError {
constructor() {
super(...arguments);
this.code = JWKSInvalid.code;
}
}
JWKSInvalid.code = 'ERR_JWKS_INVALID';
export class JWKSNoMatchingKey extends JOSEError {
constructor() {
super(...arguments);
this.code = JWKSNoMatchingKey.code;
this.message = 'no applicable key found in the JSON Web Key Set';
}
}
JWKSNoMatchingKey.code = 'ERR_JWKS_NO_MATCHING_KEY';
export class JWKSMultipleMatchingKeys extends JOSEError {
constructor() {
super(...arguments);
this.code = JWKSMultipleMatchingKeys.code;
this.message = 'multiple matching keys found in the JSON Web Key Set';
}
}
JWKSMultipleMatchingKeys.code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
export class JWSSignatureVerificationFailed extends JOSEError {
constructor() {
super(...arguments);
this.code = JWSSignatureVerificationFailed.code;
this.message = 'signature verification failed';
}
}
JWSSignatureVerificationFailed.code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
export class JWTExpired extends JWTClaimValidationFailed {
constructor() {
super(...arguments);
this.code = JWTExpired.code;
}
}
JWTExpired.code = 'ERR_JWT_EXPIRED';