Reference
Error handling
Every verification failure throws DecaneAuthError — always that type, so callers can instanceof-narrow. It carries a machine-readable reason and, when the failure originated in jose, the underlying error as cause.
ts
import { DecaneAuthError } from "decane-node";
try {
const claims = await decane.verifyAccessToken(token);
} catch (err) {
if (err instanceof DecaneAuthError) {
err.reason; // "invalid_token" | "missing_uid" | "project_mismatch"
err.cause; // underlying jose error, when present
}
}| Reason | When |
|---|---|
invalid_token | Signature, format, or expiry rejected — including expired tokens. |
missing_uid | The signature verified but the token has no uid claim. |
project_mismatch | The token’s project_id differs from the configured appId. |
If you never want to catch, use safeVerifyAccessToken and branch on null. Sign-in and other backend API calls throw a different class, DecaneApiError — verification failures are always DecaneAuthError, API failures always DecaneApiError.