Skip to content

feat(token): support read-write-stage-only granular access tokens - #9948

Open
Tayvon wants to merge 2 commits into
latestfrom
tayvon-stage-only-gat-parity
Open

feat(token): support read-write-stage-only granular access tokens#9948
Tayvon wants to merge 2 commits into
latestfrom
tayvon-stage-only-gat-parity

Conversation

@Tayvon

@Tayvon Tayvon commented Sep 3, 2026

Copy link
Copy Markdown

Summary

Adds a read-write-stage-only value to the packages-and-scopes-permission option for npm token create, letting the CLI create granular access tokens with a stage-only publish policy (parity with the web UI). Also adds a deprecation warning when creating a direct-publish-capable token, steering users toward the stage-only value.

Changes

  • Add read-write-stage-only to the packages-and-scopes-permission config enum and update its description. orgs-permission is intentionally left unchanged (the registry only accepts read-write-stage-only for packages/scopes).
  • token create already forwards packages_and_scopes_permission verbatim in the POST body, so the value flows straight to the registry create-token route, which normalizes it to publish_policy: stage_only — identical to the web UI.
  • Add a log.warn when creating a token with read-write package/scope permission (direct-publish-capable), pointing users to --packages-and-scopes-permission=read-write-stage-only. Stage-only, read-only, and no-access tokens do not warn; --bypass-2fa is orthogonal and does not by itself trigger the warning.
  • Tests: creating a stage-only token asserts the POST body carries the value and emits no warning; read-write (with and without --bypass-2fa) emits the warning; --bypass-2fa alone does not.
  • Regenerate affected tap snapshots (docs.js, workspaces/config type-description.js).

Tayvon and others added 2 commits September 3, 2026 15:32
Adds the granular-token stage-only publish policy value to the
packages-and-scopes-permission option. The value is forwarded as-is to
the registry create-token route, where it normalizes to a stage_only
publish policy (identical to the web UI).

Ref: github/npm#15609
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0f2e357f-6da8-4978-a637-f14539820093
Emits a log.warn when creating a granular access token that can publish
directly to the registry (a read-write packages-and-scopes permission),
steering users toward read-write-stage-only tokens. bypass-2fa is
orthogonal and does not trigger the warning on its own.

Ref: github/npm#15609
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0f2e357f-6da8-4978-a637-f14539820093
@Tayvon
Tayvon requested review from a team as code owners September 3, 2026 20:17
@Tayvon
Tayvon requested a balanced review from Copilot September 3, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the stated behavior and includes focused coverage for each permission scenario.

Review tier: Balanced
Findings: None

What changed in this PR

Adds stage-only granular token support and warns users creating direct-publish-capable tokens.

Changes:

  • Adds and documents the read-write-stage-only permission.
  • Warns when creating read-write tokens.
  • Adds coverage and updates generated snapshots.
File Description
workspaces/​config/​lib/​definitions/​definitions.js Defines and documents the new permission.
lib/​commands/​token.js Adds the direct-publish warning.
test/​lib/​commands/​token.js Tests forwarding and warning behavior.
workspaces/​config/​tap-snapshots/​test/​type-description.js.test.cjs Updates configuration snapshots.
tap-snapshots/​test/​lib/​docs.js.test.cjs Updates generated documentation snapshots.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants