Skip to content

fix(macos): stop repeated keychain prompts after runtime upgrades - #33

Open
pentaoa wants to merge 1 commit into
mainfrom
fix/macos-keychain-acl
Open

pentaoa wants to merge 1 commit into
mainfrom
fix/macos-keychain-acl

Conversation

@pentaoa

@pentaoa pentaoa commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

On macOS the credential item is created by the Node interpreter that runs the CLI. Homebrew upgrades Node through a versioned Cellar path, so the item's ACL no longer matches the current interpreter. Every later command then asks for the login keychain password again; denying or timing out surfaces CREDENTIAL_STORE_ERROR. auth login could not repair this because it read the previous secret before writing, and that read is exactly what the stale ACL blocks.

Fix

  • macOS backend now uses the stable /usr/bin/security helper for get/set/delete instead of @napi-rs/keyring.
  • Items are written with -U -T /usr/bin/security: the ACL trusts the system helper rather than a versioned Node path, so upgrades no longer invalidate it. Passwords are fed on stdin, never argv.
  • saveStoredCredentials tolerates an unreadable previous secret so a fresh auth login can replace a stale item; rollback is skipped when there is no readable baseline.
  • Added a regression test for the stale-ACL login path.

Verification

  • npm test — 496 tests passing.
  • Reproduced locally: after rewriting the item with -U -T /usr/bin/security, repeated sustech bb content / bb attachments calls complete without keychain prompts.
  • Existing items migrate through one normal sustech auth login (or an equivalent security add-generic-password -U -T /usr/bin/security).

Trade-off

The item is still in the user's login keychain and readable only by that user. Trusting /usr/bin/security means any process running as the user can invoke that helper to read it; this matches the previous practical access model while removing the interpreter-path fragility. Happy to switch to a per-binary -T list if maintainers prefer tighter scoping.

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.

1 participant