Skip to content

Decode hex-encoded Claude Code Keychain credentials - #2931

Open
Guitaraholic wants to merge 1 commit into
get-bb:mainfrom
Guitaraholic:fix/claude-keychain-hex-json
Open

Decode hex-encoded Claude Code Keychain credentials#2931
Guitaraholic wants to merge 1 commit into
get-bb:mainfrom
Guitaraholic:fix/claude-keychain-hex-json

Conversation

@Guitaraholic

Copy link
Copy Markdown

Human comments

What was wrong

Claude Code 2.1.x stores the macOS Keychain item Claude Code-credentials as hex-encoded JSON (7b… = {). provider-maintenance parsed that blob with JSON.parse as UTF-8, failed, and never fell through to ~/.claude/.credentials.json because the Keychain read had already succeeded. Settings → Usage limits then reported Claude as unauthenticated while the CLI was logged in.

What changed

  • Decode the Keychain secret as JSON first, then as hex JSON.
  • If the Keychain blob still does not parse, read ~/.claude/.credentials.json.
  • Unit test covers hex, UTF-8 JSON, and garbage input.
  • No HOST_DAEMON_PROTOCOL_VERSION bump: this is local credential parsing, not a wire change.

How you verified

  • pnpm exec vitest run --config vitest.config.ts src/bridge/provider-maintenance.test.ts in plugins/provider-claude-code (3 passed, including the new hex fixture).
  • Live: after this decode, GET /api/v1/system/usage-limits returns Claude session/weekly windows instead of unauthenticated.

Fixes #2928

AGENT GENERATED

Claude Code 2.1.x stores the Keychain item as hex JSON. Parsing it as
UTF-8 JSON failed and skipped ~/.claude/.credentials.json, so usage
limits reported unauthenticated while the CLI was logged in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code usage limits report unauthenticated: macOS Keychain blob is hex JSON

1 participant