Skip to content

feat(keychain): storage for openrouter api key - #129

Open
bharatsachya wants to merge 8 commits into
pre-releasefrom
feat/keychain
Open

bharatsachya wants to merge 8 commits into
pre-releasefrom
feat/keychain

Conversation

@bharatsachya

@bharatsachya bharatsachya commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Added @napi-rs/keyring dependency to the @bb/config package to support synchronous access to the OS credential store (macOS Keychain, Linux Secret Service, Windows Credential Manager).
  • Created a new keychain utility (packages/config/src/keychain.ts) defining SECRET_KEYS (openrouter_api_key, neo4j_password) and exposing helper functions: getSecret, setSecret, deleteSecret, isKeychainAvailable, isSecretKey, and isKeychainAvailable (availability probe).
  • Added storeSecret helper (packages/config/src/secrets.ts) that orchestrates storing secrets in the keychain while clearing any plaintext equivalents from config.json.
  • Modified the config loader (packages/config/src/loader.ts) to automatically overlay config schema values with values retrieved from the OS keychain if the local plaintext values are empty.
  • Updated packages/server/src/index.ts to log a startup warning if any secret key is found stored in plaintext inside config.json.
  • Updated the CLI set command (packages/cli/src/SetCommand.ts), the setup form (packages/cli/src/SetupForm.tsx), and the configuration boot default applicator (packages/cli/src/bootConfig.ts) to route secrets through the new keychain-aware setter mapping.
  • Documented secret storage architecture, fallback mechanisms, and public API surface in both CLAUDE.md and packages/config/README.md.

Why

Storing API keys and database passwords in plaintext in a configuration file (config.json) represents a significant security risk. Moving these secrets to the OS-provided secure credential store (Keychain on macOS, Secret Service on Linux, and Credential Manager on Windows) ensures they are encrypted at rest.

Using a transparent fallback to plaintext config.json ensures the application continues to run seamlessly on environments or containers where no secure OS keychain backend is available.

How to test

  1. Ensure dependencies are up-to-date by running:
    bun install
    bytebell set/setup

@bharatsachya

Copy link
Copy Markdown
Contributor Author

Against #100

@Dead-Bytes Dead-Bytes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of supporting legacy i think a clean migration is more viable option to go for

@Dead-Bytes
Dead-Bytes changed the base branch from main to pre-release June 8, 2026 07:14
@Dead-Bytes Dead-Bytes added Done Done and ready to be included in the next release Ready For Merge enhancement New feature or request labels Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Done Done and ready to be included in the next release enhancement New feature or request Ready For Merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants