diegosouzapw/OmniRoute · error
decodeCredentialBlob: invalid payload — not base64url
Error message
decodeCredentialBlob: invalid payload — not base64url
What it means
decodeCredentialBlob(): the payload after the prefix failed the base64url charset check (contains characters outside A-Za-z0-9_-), so it cannot be decoded to JSON.
Solutions
- Copy the blob without line wraps or extra characters
- Re-export; hand-edited blobs break the alphabet
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/lib/oauth/credentialBlob.ts:77 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/aac7dcdb0f19d262.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/oauth/credentialBlob.ts:77
const json = JSON.stringify(payload);
const b64 = Buffer.from(json, "utf8").toString("base64url");
return `${CREDENTIAL_BLOB_PREFIX}${b64}`;
}
/**
* Decode a credential blob produced by {@link encodeCredentialBlob}.
* Validates the prefix, version, JSON shape, and the presence of an access_token.
* Throws a descriptive error on any malformed/tampered/unsupported input.
*/
export function decodeCredentialBlob(blob: string): CredentialBlob {
if (typeof blob !== "string" || !blob.startsWith(CREDENTIAL_BLOB_PREFIX)) {
throw new Error(
`decodeCredentialBlob: invalid format — must start with "${CREDENTIAL_BLOB_PREFIX}"`
);
}
const b64 = blob.slice(CREDENTIAL_BLOB_PREFIX.length).trim();
if (!/^[A-Za-z0-9_-]+$/.test(b64)) {
throw new Error("decodeCredentialBlob: invalid payload — not base64url");
}
let parsed: { v?: unknown; provider?: unknown; tokens?: unknown };
try {
const json = Buffer.from(b64, "base64url").toString("utf8");
parsed = JSON.parse(json);
} catch {
throw new Error("decodeCredentialBlob: invalid payload — could not parse JSON");
}
if (parsed.v !== CREDENTIAL_BLOB_VERSION) {
throw new Error(
`decodeCredentialBlob: unsupported blob version ${String(parsed.v)} (expected ${CREDENTIAL_BLOB_VERSION})`
);
}
if (typeof parsed.provider !== "string" || !parsed.provider.trim()) {
throw new Error("decodeCredentialBlob: invalid payload — missing provider");
}View on GitHub (pinned to a179ffed5b)