Skip to content

feat: store auth tokens in OS credential storage#77

Merged
gnapse merged 3 commits intomainfrom
ernesto/secure-token-store
Mar 11, 2026
Merged

feat: store auth tokens in OS credential storage#77
gnapse merged 3 commits intomainfrom
ernesto/secure-token-store

Conversation

@gnapse
Copy link
Collaborator

@gnapse gnapse commented Mar 10, 2026

Summary

  • Store auth tokens in OS-native secure storage via @napi-rs/keyring.
  • Keep TWIST_API_TOKEN as the highest-priority auth source.
  • Automatically migrate legacy plaintext token values from config into secure storage while preserving other config fields.
  • Fall back to plaintext config storage with an explicit warning when the system credential store is unavailable.

User-facing updates

  • Update auth login, auth token, and auth logout messaging to stop claiming tokens are always stored in the config file.
  • Document secure storage, migration, fallback behavior, and env-var precedence in the README and installed skill content.

Test plan

First build the CLI in this branch:

npm run build

Then try the auth commands:

node dist/index.js auth status

# if you're signed in, the above command should've already migrated to secure store
# the config file should either not exist, or have other config but not the token anymore
cat ~/.config/twist-cli/config.json

Optional: try signing out and signing back in:

node dist/index.js auth logout
node dist/index.js auth login

# and run auth status again
node dist/index.js auth status

@doistbot doistbot requested a review from pedroalves0 March 10, 2026 12:25
@gnapse gnapse self-assigned this Mar 10, 2026
Copy link

@doistbot-app doistbot-app bot left a comment

Choose a reason for hiding this comment

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

This PR introduces OS-native secure storage for authentication tokens using @napi-rs/keyring, complete with an automatic migration path from legacy plaintext configurations. This is a great enhancement that significantly improves the security of stored credentials while maintaining a seamless user experience. However, there are a couple of edge cases during transient credential manager failures where fallback operations in saving or clearing the token might leave stale secure credentials active once the system recovers.

Share FeedbackReview Logs

@gnapse gnapse merged commit b67a11b into main Mar 11, 2026
2 checks passed
@gnapse gnapse deleted the ernesto/secure-token-store branch March 11, 2026 11:52
github-actions bot pushed a commit that referenced this pull request Mar 11, 2026
# [2.10.0](v2.9.1...v2.10.0) (2026-03-11)

### Features

* store auth tokens in OS credential storage ([#77](#77)) ([b67a11b](b67a11b))
@github-actions
Copy link

🎉 This PR is included in version 2.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants