UNPKG

@clerk/backend

Version:

Clerk Backend SDK - REST Client for Backend API & JWT verification utilities

103 lines (102 loc) 3.96 kB
"use strict"; 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/errors.ts var errors_exports = {}; __export(errors_exports, { MachineTokenVerificationError: () => MachineTokenVerificationError, MachineTokenVerificationErrorCode: () => MachineTokenVerificationErrorCode, SignJWTError: () => SignJWTError, TokenVerificationError: () => TokenVerificationError, TokenVerificationErrorAction: () => TokenVerificationErrorAction, TokenVerificationErrorCode: () => TokenVerificationErrorCode, TokenVerificationErrorReason: () => TokenVerificationErrorReason }); module.exports = __toCommonJS(errors_exports); var TokenVerificationErrorCode = { InvalidSecretKey: "clerk_key_invalid" }; var TokenVerificationErrorReason = { TokenExpired: "token-expired", TokenInvalid: "token-invalid", TokenInvalidAlgorithm: "token-invalid-algorithm", TokenInvalidAuthorizedParties: "token-invalid-authorized-parties", TokenInvalidSignature: "token-invalid-signature", TokenNotActiveYet: "token-not-active-yet", TokenIatInTheFuture: "token-iat-in-the-future", TokenVerificationFailed: "token-verification-failed", InvalidSecretKey: "secret-key-invalid", LocalJWKMissing: "jwk-local-missing", RemoteJWKFailedToLoad: "jwk-remote-failed-to-load", RemoteJWKInvalid: "jwk-remote-invalid", RemoteJWKMissing: "jwk-remote-missing", JWKFailedToResolve: "jwk-failed-to-resolve", JWKKidMismatch: "jwk-kid-mismatch" }; var TokenVerificationErrorAction = { ContactSupport: "Contact support@clerk.com", EnsureClerkJWT: "Make sure that this is a valid Clerk generate JWT.", SetClerkJWTKey: "Set the CLERK_JWT_KEY environment variable.", SetClerkSecretKey: "Set the CLERK_SECRET_KEY environment variable.", EnsureClockSync: "Make sure your system clock is in sync (e.g. turn off and on automatic time synchronization)." }; var TokenVerificationError = class _TokenVerificationError extends Error { constructor({ action, message, reason }) { super(message); Object.setPrototypeOf(this, _TokenVerificationError.prototype); this.reason = reason; this.message = message; this.action = action; } getFullMessage() { return `${[this.message, this.action].filter((m) => m).join(" ")} (reason=${this.reason}, token-carrier=${this.tokenCarrier})`; } }; var SignJWTError = class extends Error { }; var MachineTokenVerificationErrorCode = { TokenInvalid: "token-invalid", InvalidSecretKey: "secret-key-invalid", UnexpectedError: "unexpected-error" }; var MachineTokenVerificationError = class _MachineTokenVerificationError extends Error { constructor({ message, code, status }) { super(message); Object.setPrototypeOf(this, _MachineTokenVerificationError.prototype); this.code = code; this.status = status; } getFullMessage() { return `${this.message} (code=${this.code}, status=${this.status})`; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MachineTokenVerificationError, MachineTokenVerificationErrorCode, SignJWTError, TokenVerificationError, TokenVerificationErrorAction, TokenVerificationErrorCode, TokenVerificationErrorReason }); //# sourceMappingURL=errors.js.map