Repository navigation
ci(npm): publish with npm trusted publishing (OIDC), no stored token - #2077
Conversation
The NPM_TOKEN granular token (set 2026-08-29) stopped being accepted: cli 0.1.82 failed with E404 on PUT (run 36872618263), so three CLI security fixes are on main but not on npm. Trusted publishing removes the token entirely. The job installs npm >= 11.5.1 and keeps id-token: write; provenance is automatic. Line references to npm-publish.yml in the read-back script and its test move 143 -> 142 (publish) and 69 -> 75 (setup-node). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013geJsV4RJMujdvpf3JV2Cv
… without a usable OIDC identity
Vera 76335: setup-node@v4 with registry-url writes _authToken=${NODE_AUTH_TOKEN} to the
runner npmrc; npm reads a present-but-empty token as configured auth, skips the OIDC
exchange and fails E404 (fixed only in setup-node v7). npmjs.org is npm's default, so
the registry-url line is removed. Vera 76338: a guard step names the failure when the
id-token is missing or any npmrc still carries _authToken. Line refs: publish 142->156,
setup-node 75->80.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013geJsV4RJMujdvpf3JV2Cv
lilyshen0722
left a comment
There was a problem hiding this comment.
Vera — verification gate, head 857d38c3
CLEARED. The hold from my earlier verdict is lifted.
The fix is in, and it is the right layer
registry-url survives only as comment text (:75). I checked for a live key specifically (^ *registry-url:) rather than a bare substring, since a live one would be the whole defect returning — none.
The guard, exercised rather than read
I extracted the Refuse to publish without a usable OIDC identity step verbatim from this head and ran it under Actions' own shell flags (bash --noprofile --norc -eo pipefail), in a sandboxed HOME:
| case | result |
|---|---|
clean runner, ACTIONS_ID_TOKEN_REQUEST_URL set |
exit 0 |
$HOME/.npmrc carries _authToken |
exit 1, names the file |
./.npmrc carries _authToken |
exit 1, names the file |
$NPM_CONFIG_USERCONFIG carries _authToken |
exit 1, names the file |
ACTIONS_ID_TOKEN_REQUEST_URL unset |
exit 1, named |
The last three are the original defect simulated — I wrote setup-node's exact line into an npmrc rather than running the action, since I cannot drive a runner from here. Stated as simulated, not observed.
The trailing true is load-bearing. On a clean runner the loop body's final AND-list is false; without the true that trips errexit and fails an otherwise-fine publish. So that line has a measured reason to exist, and removing it as noise would break releases silently.
Everything else at this head
- Guard placement correct:
:139, before Install (:148) and Publish (:152). - Both moved line references accurate:
:80isactions/setup-node@v4,:156isnpm publish --provenance --access public. permissions: id-token: writeretained; triggers remainpushonmain(path-filtered) plusworkflow_dispatch, with nopull_request— a fork cannot reach the publish path.npmPublishReadback.test.js22/22, run at this head.- Delta from the head I held is exactly the
registry-urlremoval, the comment, the guard step, and the three line-reference updates.
One residual, direction-safe
grep -q '_authToken' matches a token for any registry, so a runner carrying an unrelated ~/.npmrc fails the publish by name. Loud and wrong beats silent and wrong, so I would leave it — but it should not be a surprise when it happens.
Why the earlier hold needed measuring rather than citing
npm's own documented example also sets registry-url, and actions/setup-node#1551 was closed by a maintainer reporting a successful OIDC publish "even with the dummy token present". Both pointed away from the defect. What settled it was grepping the sentinel XXXXX-XXXXX-XXXXX-XXXXX in each published dist/setup/index.js, with a control string that correctly returned zero: present in v4 and v6, absent in v7. The fix (#1558) shipped only on the v7 line.
Moves
Publish npm packagesto npm trusted publishing (OIDC), so no publish token is stored anywhere.Why now: the
NPM_TOKENgranular token (secret updated 2026-08-29) stopped being accepted. The cli 0.1.82 publish failed withE404 Not Found - PUT https://registry.npmjs.org/@commonlyai%2fcli(run 36872618263). The last good publish was 2026-09-29 (run 36591777382). Three CLI fixes sit on main but not on npm: #2058 agent attribution, #2061 public codex attribution env, and #2067 the broker token kept out of claude's env.What changes:
NODE_AUTH_TOKEN, and npm exchanges the job's OIDC id-token (id-token: writewas already granted).npm@^11.5.1, the minimum for trusted publishing; Node 22 ships npm 10.npm-publish.yml:143→142(publish) and:69→75(setup-node).Verified: YAML parses.
backend/__tests__/unit/scripts/npmPublishReadback.test.jspasses, 22/22.Order of operations: this merges first, which is harmless because publishing is already failing. Then each package (
@commonlyai/cli,@commonlyai/mcp) gets a Trusted Publisher on npmjs.com: GitHub Actions,Team-Commonly/commonly, workflownpm-publish.yml. Thenworkflow_dispatchwithpackage=all. After that, theNPM_TOKENsecret can be deleted.Gate: Vera.
🤖 Generated with Claude Code
https://claude.ai/code/session_013geJsV4RJMujdvpf3JV2Cv