You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9741b64
Browse filesBrowse the repository at this point in the historyBrowse files
feat(dist-tag): support OIDC authentication (#10038)
## Summary
- Add OIDC authentication to dist-tag add, remove, and list operations,
including scoped registries and workspace listing.
- Keep exchanged tokens in the non-persistable CLI config layer and
clear the previous token before each subsequent OIDC attempt, preventing
failed exchanges from reusing another package's token.
- Keep automatic provenance configuration specific to publishing, and
invalidate cached flat options when deleting configuration values.
- Add coverage for provider exchanges, fallback credentials, workspace
token isolation, provenance exclusion, and config cache invalidation.
## Notable bug fix: workspace OIDC token reuse
During a single `npm publish --workspaces` invocation, a successful OIDC
exchange for workspace A could leave its package-specific token in
shared configuration. If workspace B's exchange failed, npm could
incorrectly fall back to A's token instead of the original credentials
or reporting `ENEEDAUTH` when no credentials were available. This PR
clears the previous exchanged token before every subsequent OIDC
attempt, including attempts that fail or are skipped.
Exchanged tokens now use the `cli` config namespace instead of `user`.
The `cli` layer is non-persistable, so temporary tokens do not overwrite
user credentials (in memory) and cannot be included when saving user
configuration. Token deletion also invalidates cached flat options so a
stale copy cannot remain available to subsequent operations.
## Validation
All 1,439 assertions passed: 422 across the affected OIDC and command
tests, plus 1,017 in the config workspace.
```sh
node node_modules/tap/bin/run.js --no-coverage --reporter=classic test/lib/utils/oidc.js test/lib/commands/dist-tag.js test/lib/commands/publish.js test/lib/commands/stage/index.js
(cd workspaces/config && node ../../node_modules/tap/bin/run.js --no-coverage --reporter=classic test)
```
The workspace token-reuse and config cache regression tests were also
verified to fail against the existing implementation with the fixes
stashed.
---------
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 15207d1d-40b3-4973-9371-b7aba1e286fb
Copilot-Session: 18971883-024d-4f5a-b531-4eeaa0af80b3
0 commit comments