feat(auth): add credential storage policies - #105
Merged
Conversation
doistbot
reviewed
Jul 29, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR adds system, plaintext, and fallback credential storage policies to createKeyringTokenStore, with a resolver pattern for lazy policy selection, full backward compatibility via the fallback default, and appropriate test/README coverage. No inline issues were flagged.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (3)
src/auth/keyring/record-write.ts:200:
credentialStoreUnavailableErrorhardcodes'The system credential manager could not store the credential.', but the existingSECURE_STORE_DESCRIPTIONconstant (exported from./secure-store.js) already encapsulates that label and is used for the same purpose intoken-store.ts(e.g.accessReadError,fallbackResult). Import and reuse it for consistency:ts import { type SecureStore, SECURE_STORE_DESCRIPTION, SecureStoreUnavailableError } from './secure-store.js' // ... `${SECURE_STORE_DESCRIPTION} could not store the credential.`src/auth/keyring/record-write.ts:197:
credentialStoreUnavailableError()drops the originalSecureStoreUnavailableError's message andcauseentirely.SecureStoreUnavailableErroris specifically designed to preserve platform diagnostics oncause(per its doc comment in secure-store.ts), and the read path surfaces the underlying reason viaaccessReadError's(${outcome.detail}). In strictsystemmode — where knowing why the keyring was unavailable matters most — the user only sees a generic message. Consider threading the original error's message into theCliError(e.g. viagetErrorMessage(error)) sosystem-mode write failures are diagnosable.src/auth/keyring/token-store.test.ts:155: This is the only rejection test in the file that pins the exact
messagestring; every otherrejects.toMatchObjectasserts only the stablecode. The wording is an implementation detail, so rewording the user-facing message would break this test without a behavioral regression. Consider dropping themessagefield to match the rest of the suite (the unit-level test in record-write.test.ts already checks onlycode).
scottlovegrove
approved these changes
Jul 29, 2026
doist-release-bot Bot
added a commit
that referenced
this pull request
Jul 29, 2026
## [1.1.0](v1.0.1...v1.1.0) (2026-07-29) ### Features * **auth:** add credential storage policies ([#105](#105)) ([68f0f7e](68f0f7e))
Contributor
|
🎉 This PR is included in version 1.1.0 🎉 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.
Summary
CredentialStorepolicies tocreateKeyringTokenStore:system,plaintext, and backward-compatiblefallback.Example
fallbackremains the default to preserve existing consumers. A CLI can expose onlysystemandplaintext, withsystemas its own default.Motivated by Doist/todoist-cli#424.
Verification
npm run buildnpm run type-checknpm test(35 files, 534 tests)npm run check