GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: npm stage by reggi · Pull Request #9201 · npm/cli

Conversation

@reggi

@reggi reggi commented Apr 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Introducing npm stage 🎉

A new command for staged publishing — allowing package maintainers to decouple the act of publishing from proof-of-presence (2FA), making automated workflows more secure.

🔗 Docs

Why Staged Publishing?

With npm stage publish, an automated workflow can stage a package version without a 2FA prompt. The maintainer can then review and approve the staged package at their convenience, providing 2FA only at the approval step. This keeps proof-of-presence in the loop while keeping CI/CD fully automated.

Subcommands

Command Description Requires 2FA
npm stage publish [<package-spec>] Stage a package for publishing No
npm stage list [<package-spec>] List all staged package versions No
npm stage view <stage-id> View details of a specific staged package No
npm stage approve <stage-id> Approve and publish a staged package Yes
npm stage reject <stage-id> Reject and remove a staged package Yes
npm stage download <stage-id> Download the staged tarball for inspection No

How It Works

  1. Stage — CI runs npm stage publish using any token type (no 2FA needed). The package version is held in a pending state, not publicly available.
  2. Review — Maintainer runs npm stage list to see pending staged packages, and npm stage view <id> or npm stage download <id> to inspect them.
  3. Approve or Reject — Maintainer runs npm stage approve <id> (with 2FA) to publish, or npm stage reject <id> to discard.

Key Behaviors

  • Staged packages share the same semver uniqueness constraint as published packages — you can't publish a version that's already staged.
  • Normal npm publish continues to work alongside staged publishing.
  • Multiple versions of the same package can be staged concurrently.
  • npm stage publish has full parity with npm publish (respects "private": true, workspace support, etc).
  • Tags are immutable once staged — reject and re-stage to change a tag.

Future Work

  • Trust relationship permissions — A follow-up PR will add granular command permissions to npm trust, with --allow-publish and --allow-stage-publish flags to control whether a trust relationship can be used for npm publish, npm stage publish, or both.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

franky47, joaopedrodcf, wrslatz, jonchurch, naugtur, hansott, and azu reacted with hooray emoji naugtur reacted with heart emoji franky47 and joaopedrodcf reacted with eyes emoji
All reactions
  • 🎉 7 reactions
  • ❤️ 1 reaction
  • 👀 2 reactions
@reggi
reggi requested a review from a team as a code owner April 7, 2026 19:52
@ljharb

ljharb commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Why would download not require 2fa but view require it? Either both should, or neither, I’d expect.

riderx reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@reggi

reggi commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Why would download not require 2fa but view require it? Either both should, or neither, I’d expect.

@ljharb that was a mistake, fixed!

ljharb reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ljharb

ljharb commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

(i'm assuming that all the "no"s still require one factor)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar

wraithgar commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

(i'm assuming that all the "no"s still require one factor)

All staged content routes will require authentication with access to that package.

ljharb reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@reggi reggi mentioned this pull request Apr 16, 2026
feat: add permissions support to trust commands #9248
Merged
@reggi
reggi force-pushed the reggi/stage branch from 44e23bb to 95be212 Compare April 21, 2026 16:41
@shmam shmam mentioned this pull request May 6, 2026
feat: adding npm stage endpoints for managing staged package versions npm/api-documentation#54
Merged
reggi and others added 3 commits May 8, 2026 14:23
@reggi
feat: npm stage
af8d3e9
Adds staged publishing support with subcommands: publish, list, view, approve, reject, and download.

Co-authored-by: Copilot <[email protected]>
@reggi
fix: list and view dont require 2fa
76e5f1d
@reggi
fix: access JSON output under package name key in stage tests
f887436
The logTar utility wraps JSON output under the package name key,
so tests need to access out[pkg] instead of out directly.

Co-authored-by: Copilot <[email protected]>
@reggi
reggi force-pushed the reggi/stage branch from 95be212 to f887436 Compare May 8, 2026 18:30
@reggi
reggi requested a review from a team as a code owner May 8, 2026 18:30
@reggi
fix: regenerate smoke test snapshots
10f4200
Update smoke-tests/tap-snapshots/test/index.js.test.cjs to match
current CLI output after rebasing on latest.

Co-authored-by: Copilot <[email protected]>
nishantms
nishantms reviewed May 15, 2026
View reviewed changes
Comment thread lib/utils/display.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/utils/key-values.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/commands/stage/download.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

nishantms
nishantms reviewed May 15, 2026
View reviewed changes
Comment thread lib/commands/stage/index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/commands/stage/reject.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/lib/commands/stage/approve.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

nishantms
nishantms reviewed May 15, 2026
View reviewed changes
Comment thread workspaces/libnpmpublish/lib/publish.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread workspaces/libnpmpublish/lib/publish.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/commands/publish.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

shmam added a commit to npm/api-documentation that referenced this pull request May 15, 2026
@shmam
feat: adding npm stage endpoints for managing staged package versio…
b7730e6
…ns (#54)

## Summary 
This PR introduces six new public endpoints for supporting managing
staged package versions. These endpoint support viewing, filtering,
approving, rejecting and inspecting staged package versions on the npm
registry.

#### E1. GET https://registry.npmjs.org/-/stage
Gets the list of all staged package versions that the user has access to

#### E2. POST https://registry.npmjs.org/-/stage/package/{package-name}
Creates a staged package version

#### E3. GET https://registry.npmjs.org/-/stage/{stage-id}
Gets a specific staged package version

#### E4. DELETE https://registry.npmjs.org/-/stage/{stage-id}
Reject a staged staged package version

#### E5. POST https://registry.npmjs.org/-/stage/{stage-id}/approve
Approve a staged package version to published

#### E6. GET https://registry.npmjs.org/-/stage/{stage-id}/tarball
Gets a staged package version tarball 

## References
- for more info on npm stage: npm/cli#9201
@reggi
fix: remove global redact:false override for JSON output
89a97de
JSON output no longer disables credential redaction globally.
Previously, all --json commands would skip redactLog(), which
could leak embedded credentials from registry URLs.

Co-authored-by: Copilot <[email protected]>
@owlstronaut owlstronaut added the backport:v11 label May 18, 2026
owlstronaut
owlstronaut suggested changes May 18, 2026
View reviewed changes
Comment thread tap-snapshots/TAP.test.cjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tap-snapshots/smoke-tests/test/index.js.test.cjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@reggi

reggi commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Regarding the redact: false change in display.js:

The JSON output buffer now redacts each item individually by default. Callsites can opt out of redaction by passing { redact: false } in the buffer meta. This was needed because @npmcli/redact redacts all UUIDs (including stageId), and there is no way to selectively redact parts of a merged JSON object after the fact.

We could not simply add stageId as a separate buffer entry because getArrayOrObject uses Object.assign to merge items — a second { [pkgName]: { stageId } } would overwrite the first { [pkgName]: { ...tarball } }. So the approach is: put stageId on the tarball contents and mark that entire buffer item as redact: false via logTar. The tarball metadata (name, version, shasum, etc.) does not contain sensitive data, so skipping redaction there is safe.

Note: publish --json already outputs multiple JSON objects in the webauthn flow, so a separate JSON output for stageId was also considered as an alternative simpler approach, but per-item buffer redaction is more correct long-term.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

reggi and others added 8 commits May 18, 2026 13:26
@reggi
fix: per-item redaction for JSON output buffer
40f95aa
The JSON output buffer now redacts each buffered item individually
based on its meta. Callsites opt out with { redact: false }.
This allows stage publish to include stageId (a UUID) unredacted
while other buffer items remain redacted by default.

Also guards against actorType: null rendering as "(null)" in
stage view output.

Co-authored-by: Copilot <[email protected]>
@reggi
fix: guard against null actorType in stage view
5aa1b0d
Co-authored-by: Copilot <[email protected]>
@reggi
fix: add static tab completion to Stage command
9db72d6
Mirrors the pattern used by dist-tag, access, and owner commands
to provide subcommand suggestions (publish, list, view, approve,
reject, download) when pressing TAB after `npm stage`.

Co-authored-by: Copilot <[email protected]>
@reggi
test(stage): add error path tests for invalid UUID, 404, and 403
dd92f19
Cover the common failure modes users will hit:
- Invalid UUID format (validateUUID throws)
- 404 (stage-id not found or already approved/rejected)
- 403 (not an owner)

Co-authored-by: Copilot <[email protected]>
@reggi
lint fixes
0d1990f
@reggi
test: cover logStageItem branch without actorType
ad47e35
Adds a test case for the falsy actorType path on line 36 of
lib/utils/key-values.js, bringing branch coverage to 100%.

Co-authored-by: Copilot <[email protected]>
@reggi
test: add completion coverage for stage index.js
f4ea071
Co-authored-by: Copilot <[email protected]>
@reggi
fix: preserve Response object in libnpmpublish stage return
d9d1f6e
Mutate stageId directly onto res instead of spreading, matching
the existing transparencyLogUrl pattern. Spreading dropped
non-enumerable Response getters (headers, status, url).

Co-authored-by: Copilot <[email protected]>
@reggi
reggi dismissed owlstronaut’s stale review via c0af6bb May 20, 2026 16:26
nishantms
nishantms approved these changes May 20, 2026
View reviewed changes
@reggi
reggi merged commit 254809e into latest May 20, 2026
74 of 77 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@reggi
reggi deleted the reggi/stage branch May 20, 2026 16:59
@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

⚠️ Backport to release/v11 failed.

This usually means the cherry-pick had conflicts. Please create a manual backport:

git fetch origin release/v11
git checkout -b backport/v11/9201 origin/release/v11
git cherry-pick -x 254809e318ee0046092d07d68a99154c3f672147
# resolve any conflicts, then:
git push origin backport/v11/9201
Error details
Command failed: git cherry-pick -x 254809e318ee0046092d07d68a99154c3f672147
error: could not apply 254809e31... feat: npm stage (#9201)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request May 20, 2026
chore: release 12.0.0-pre.0.0 #9229
Merged
@reggi reggi mentioned this pull request May 20, 2026
feat: npm stage (#9201) #9379
Merged
reggi added a commit that referenced this pull request May 20, 2026
@reggi
feat: npm stage
0d5d899
Backports #9201 to `release/v11`.

Original commit: 254809e

## Conflict resolutions

- **docs/lib/content/nav.yml** and **lib/utils/cmd-list.js**: kept
`shrinkwrap`, `star`, and `stars` (still present on `release/v11`) and
added `stage` in alphabetical order. On `latest`, those three commands
were dropped in separate commits not part of this backport.
- **lib/utils/tar.js**: combined both sides — kept the `key == null ?
tarball : { [key]: tarball }` form from `release/v11` and added the new
`redact` / `META` handling from the stage commit.
- **Snapshots** (`test/lib/docs.js.test.cjs`,
`test/lib/npm.js.test.cjs`, `smoke-tests/test/index.js.test.cjs`,
`tap-snapshots/test/lib/commands/publish.js.test.cjs`): regenerated
locally via `npm test` and `npm run snap -w smoke-tests`.

Co-authored-by: Copilot <[email protected]>
@reggi reggi mentioned this pull request May 20, 2026
fix: key stage download --json output by package name #9380
Merged
reggi added a commit that referenced this pull request May 20, 2026
@reggi
fix: key stage download --json output by package name (#9380)
2a13550
`npm stage download <id> --json` currently emits the package contents
under a literal `"undefined"` key because `logTar` is called without a
`key` option.

### Before

```json
{
  "undefined": {
    "name": "polo-meow-meow-meow",
    "version": "1.0.3",
    ...
  }
}
```

### After

```json
{
  "polo-meow-meow-meow": {
    "name": "polo-meow-meow-meow",
    "version": "1.0.3",
    ...
  }
}
```

This matches the JSON shape of `npm publish --json` and `npm pack
--json`.

### Background

The `key == null` fallback in `lib/utils/tar.js` (that would have
rendered a bare object when no key was passed) was removed from `latest`
in #9247 ("fix: sync json output of pack and publish") as a `BREAKING
CHANGE`. Per that PR:

> BREAKING CHANGE: the --json output of `npm pack` and `npm publish`
have changed. They are now always consistent, and in the same format.
>
> Previously, `npm pack` would output an array of entries and `npm
publish` an object. The `npm publish` object also changed forms
depending on if workspaces were being published.
>
> Now, the output is always an object with the package name as the top
level index.

When #9201 (npm stage) landed, it added a new `logTar` caller in
`lib/commands/stage/download.js` that did not pass a `key`, silently
violating the v12 contract established in #9247 and producing the
`"undefined"` wrapper. This PR brings the new caller into compliance.

### Repro

```
npm stage download <stage-id> --json
```

A follow-up backports this to `release/v11` for consistent output across
branches: #9381.

Co-authored-by: Copilot <[email protected]>
@hyunbinseo hyunbinseo mentioned this pull request May 21, 2026
Support pnpm stage publish pnpm/pnpm#11796
Closed
1 task
@franky47 franky47 mentioned this pull request May 21, 2026
[feat] Add support for staged publishing semantic-release/npm#1160
Open
@dubzzz dubzzz mentioned this pull request May 21, 2026
👷 Switch release jobs to npm stage publish dubzzz/fast-check#7013
Merged
5 tasks done
dubzzz added a commit to dubzzz/fast-check that referenced this pull request May 21, 2026
@dubzzz @claude
👷 Switch release jobs to npm stage publish (#7013)
a7a73f1
## Description

> AI-agent disclosure: this PR was authored by an automated agent
(Claude Code) and has not been line-by-line reviewed by a human before
submission.

Switches every `publish_package_*` job in
`.github/workflows/build-status.yml` from `pnpm publish` to [`npm stage
publish`](npm/cli#9201). With staged publishing,
CI uploads the tarball into a holding area on the registry instead of
releasing it immediately — a maintainer then has to approve the staged
version (with 2FA) before it becomes installable. End users still
receive the same artifacts on npm, but the release step is no longer
fully automated: there is now an explicit approval gate between a tag
being pushed and the package going live. This is a follow-up to #7011
(which already removed the OTP prompt from the publish call); together
they move the workflow toward npm's recommended staged-release flow.

Each publish job now:

- installs `npm@latest` so the runner-provided npm is upgraded before
publishing — the `stage` subcommand landed in npm 11.15.0 and is not yet
bundled with Node 24's default npm;
- runs both `npm install -g` and `npm stage publish` from the parent
directory (`cd ..`), because the repo's `package.json` pins pnpm via
`devEngines` and would otherwise block npm from executing inside the
workspace;
- no longer needs the `pnpm/action-setup` step or the pnpm-specific
`--no-git-checks` flag, both of which were dropped from the seven
affected jobs.

Non-publish jobs were intentionally left alone and still install pnpm —
only the release plumbing changes. Because the diff only touches the
workflow file, there are no source, dependency, or published-artifact
changes, no semver impact to flag, and no changeset to add; the new code
path is exercised the next time a `v*` tag is pushed.

## Checklist

— _Don't delete this checklist and make sure you do the following before
opening the PR_

- [x] I have a full understanding of every line in this PR — whether the
code was hand-written, AI-generated, copied from external sources or
produced by any other tool
- [x] I flagged the impact of my change (minor / patch / major) either
by running `pnpm run bump` or by following the instructions from the
changeset bot
- [x] I kept this PR focused on a single concern and did not bundle
unrelated changes
- [x] I followed the [gitmoji](https://gitmoji.dev/) specification for
the name of the PR, including the package scope (e.g. `🐛(vitest)
Something...`) when the change targets a package other than `fast-check`
- [x] I added relevant tests and they would have failed without my PR
(when applicable)

Co-authored-by: Claude <[email protected]>
@43081j 43081j mentioned this pull request May 23, 2026
feat(libnpmpublish): add support for stageId DefinitelyTyped/DefinitelyTyped#75043
Merged
8 tasks done
@github-actions github-actions Bot mentioned this pull request May 27, 2026
chore: release 12.0.0-pre.1 #9387
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jun 2, 2026
feat(npm): add support for staged publishing with pnpm luxass/shared-workflows#44
Merged
@npm-cli-bot npm-cli-bot mentioned this pull request Jun 23, 2026
deps: upgrade npm to 12.0.0-pre.1 nodejs/node#64096
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 24, 2026
chore: simplify release workflow using changesets publish gating mynameistito/create-cf-token#141
Merged
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jul 10, 2026
feat: initial tsgo2tsc migration CLI mynameistito/tsgo2tsc#1
Merged
3 tasks done
This was referenced Aug 3, 2026
ci: publish to npm via trusted publishing (OIDC) leapter/n8n-nodes-leapter#39
Merged
Harden the repository and npm releases against Shai-Hulud natanelia/comlink-worker-pool#16
Open
ci: skip staging when the version is already on npm akin-oz/ai-engineering#1
Merged
v1.1.1 shriyanss/cli-print-img#3
Merged
This was referenced Aug 18, 2026
docs(cli): document npm install and release operations apache/maka#3197
Merged
ci: stage PR beta publishes for 2FA Cap-go/capacitor-wifi#20
Merged
ci: use npm stage publish for 2FA Cap-go/capacitor-firebase#15
Merged
fix(ci): stage CLI releases through npm approval Cap-go/capgo.app#3149
Closed
fix(ci): publish CLI via npm stage like plugins Cap-go/capgo.app#3152
Merged
docs: plan OpenCode v2 migration mynameistito/oc-usage-limits-plugin#65
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nishantms nishantms nishantms approved these changes
+1 more reviewer
@owlstronaut owlstronaut owlstronaut left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backport:v11

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@reggi @ljharb @wraithgar @owlstronaut @nishantms
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.