{"record":{"id":"0ce59ee7b4353507","repo":"diegosouzapw/OmniRoute","slug":"encodecredentialblob-a-non-empty-provider-is-requ","errorCode":null,"errorMessage":"encodeCredentialBlob: a non-empty provider is required","messagePattern":"encodeCredentialBlob: a non-empty provider is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/credentialBlob.ts","lineNumber":49,"sourceCode":"  refresh_token?: string;\n  id_token?: string;\n  expires_in?: number;\n  scope?: string;\n  [key: string]: unknown;\n}\n\nexport interface CredentialBlob {\n  provider: string;\n  tokens: CredentialBlobTokens;\n}\n\n/**\n * Encode a provider + raw OAuth token response into a single-line blob.\n * Throws if `provider` is missing — a blob with no provider cannot be routed.\n */\nexport function encodeCredentialBlob(input: CredentialBlob): string {\n  if (!input || typeof input.provider !== \"string\" || !input.provider.trim()) {\n    throw new Error(\"encodeCredentialBlob: a non-empty provider is required\");\n  }\n  if (!input.tokens || typeof input.tokens !== \"object\") {\n    throw new Error(\"encodeCredentialBlob: tokens object is required\");\n  }\n  const payload = {\n    v: CREDENTIAL_BLOB_VERSION,\n    provider: input.provider.trim(),\n    tokens: input.tokens,\n  };\n  const json = JSON.stringify(payload);\n  const b64 = Buffer.from(json, \"utf8\").toString(\"base64url\");\n  return `${CREDENTIAL_BLOB_PREFIX}${b64}`;\n}\n\n/**\n * Decode a credential blob produced by {@link encodeCredentialBlob}.\n * Validates the prefix, version, JSON shape, and the presence of an access_token.\n * Throws a descriptive error on any malformed/tampered/unsupported input.","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/credentialBlob.ts#L31-L67","documentation":"Error \"encodeCredentialBlob: a non-empty provider is required\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/oauth/credentialBlob.ts:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}