fix: persist CLI credentials on headless Linux - #6
Merged
Merged
Conversation
Pin the Linux keyring to Secret Service so @napi-rs/keyring cannot silently use the in-memory kernel keyring. When Secret Service is missing, and when keyring get returns null, fall back to the documented 0600 file store. Closes #5 Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
kentcdodds
marked this pull request as ready for review
September 14, 2026 18:03
Owner
Author
|
bugbot review |
|
Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings. |
|
🎉 This PR is included in version 1.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On headless Linux,
kody loginappeared to succeed but a reboot silently logged the user out.@napi-rs/keyringdoes not throw when Secret Service is missing — it uses the in-memory kernel keyring — so nothing was written under$XDG_CONFIG_HOME/kody.loadCredentialsonly fell back to that file when keyringget()threw;getPassword()returnsnullfor a missing entry, so the fallback never ran.Fixes #5
Fix
Product choice A: require a durable OS store; otherwise use the documented
0600file.@napi-rs/keyringto^2.1.0and pin Linux to Secret Service ({ linux: { store: 'secret-service' } }). The constructor throws when that store is missing, so the existing file fallback fires. Kernel keyutils is not used.get()returnsnullor stored data is invalid, load the file. Desktop Secret Service / macOS / Windows stay on the OS keychain.backendKind === 'file'.Risk
Medium. Credential persistence, but it matches the README and does not dual-write tokens to disk when a real keychain exists. Affected users need one more
kody login.Verify
npm run validate(typecheck, tests, build)resolveBackendchose the file store, save/load/delete round-tripped~/.config/kody/credentials-kody.codes.json, and leftover smoke credentials were deletedsetthrow, keyringnull, invalid keyring, leftover-file preference, and dual delete