@clerk/backend
Version:
Clerk Backend SDK - REST Client for Backend API & JWT verification utilities
80 lines (79 loc) • 2.67 kB
JavaScript
// src/errors.ts
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-generated 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",
TokenVerificationFailed: "token-verification-failed"
};
var MachineTokenVerificationError = class _MachineTokenVerificationError extends Error {
constructor({
message,
code,
status,
action
}) {
super(message);
Object.setPrototypeOf(this, _MachineTokenVerificationError.prototype);
this.code = code;
this.status = status;
this.action = action;
}
getFullMessage() {
return `${this.message} (code=${this.code}, status=${this.status || "n/a"})`;
}
};
export {
TokenVerificationErrorCode,
TokenVerificationErrorReason,
TokenVerificationErrorAction,
TokenVerificationError,
SignJWTError,
MachineTokenVerificationErrorCode,
MachineTokenVerificationError
};
//# sourceMappingURL=chunk-TCIXZLLW.mjs.map