fix(keychain): load secure keychain export#2867
Merged
Merged
Conversation
## Purpose and Context The credential store should prefer the secure keychain backend when it is available and only fall back to configstore otherwise. The dynamic require path was reading the secure backend with the wrong module shape, which made the CLI use the insecure fallback even when the secure backend could be loaded. ## Key Changes - Read the default export from the secure keychain module when requiring it dynamically. - Remove the unused constructor type import. ## Impact and Considerations Login credentials are stored in the secure keychain when that backend is available. The existing configstore fallback remains available for environments without secure keychain support. If the secure keychain is available, the users will have to re-login to have their credentials migrated from the configstore to the
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes secure keychain backend selection by correcting the dynamic require() shape handling so the CLI actually instantiates the secure backend when it’s available, instead of unintentionally falling back to the insecure configstore-based backend.
Changes:
- Load the secure keychain backend via its default export when requiring it dynamically.
- Remove the now-unused
KeychainConstructortype import fromsrc/lib/keychain.ts.
rebeccahum
approved these changes
Jun 3, 2026
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.



Description
Purpose and Context
The credential store should prefer the secure keychain backend when available and fall back to configstore otherwise. The dynamic require path was reading the secure backend with the wrong module shape, causing the CLI to use the insecure fallback even when the secure backend could be loaded.
Key Changes
Impact and Considerations
Login credentials are stored in the secure keychain when that backend is available. The existing configstore fallback remains available for environments without secure keychain support.
If the secure keychain is available, the users will have to re-login to have their credentials migrated from the configstore to the
Changelog Description
Fixed
Pull request checklist
New release checklist
Steps to Test
DEBUG=@automattic/vip:keychain vipmust not show "Cannot use Secure keychain; falling back to Insecure keychain (Details: TypeError: Secure is not a constructor"