UNPKG

@atproto/jwk

Version:

A library for working with JSON Web Keys (JWKs) in TypeScript. This is meant to be extended by environment-specific libraries like @atproto/jwk-jose.

41 lines 1.52 kB
export const ERR_JWKS_NO_MATCHING_KEY = 'ERR_JWKS_NO_MATCHING_KEY'; export const ERR_JWK_INVALID = 'ERR_JWK_INVALID'; export const ERR_JWK_NOT_FOUND = 'ERR_JWK_NOT_FOUND'; export const ERR_JWT_INVALID = 'ERR_JWT_INVALID'; export const ERR_JWT_CREATE = 'ERR_JWT_CREATE'; export const ERR_JWT_VERIFY = 'ERR_JWT_VERIFY'; export class JwkError extends TypeError { constructor(message = 'JWK error', code = ERR_JWK_INVALID, options) { super(message, options); this.code = code; } } export class JwtCreateError extends Error { constructor(message = 'Unable to create JWT', code = ERR_JWT_CREATE, options) { super(message, options); this.code = code; } static from(cause, code, message) { if (cause instanceof JwtCreateError) return cause; if (cause instanceof JwkError) { return new JwtCreateError(message, cause.code, { cause }); } return new JwtCreateError(message, code, { cause }); } } export class JwtVerifyError extends Error { constructor(message = 'Invalid JWT', code = ERR_JWT_VERIFY, options) { super(message, options); this.code = code; } static from(cause, code, message) { if (cause instanceof JwtVerifyError) return cause; if (cause instanceof JwkError) { return new JwtVerifyError(message, cause.code, { cause }); } return new JwtVerifyError(message, code, { cause }); } } //# sourceMappingURL=errors.js.map