Skip to content

ci: publish to npm via Trusted Publishing (OIDC) instead of NPM_TOKEN - #193

Merged
silverbucket merged 1 commit into
masterfrom
ci/npm-trusted-publishing
Oct 8, 2026
Merged

silverbucket merged 1 commit into
masterfrom
ci/npm-trusted-publishing

Conversation

@silverbucket

Copy link
Copy Markdown
Owner

Closes #188 once v3.1.0 is published.

Why

The v3.1.0 publish (run 37653554926) fails with EOTP: the npm account requires 2FA and the granular token can't bypass it. npm is deprecating 2FA-bypass tokens for direct publishing (January 2027), so fixing the token would only buy a few months. Trusted Publishing (OIDC) needs no stored secret and already produces the provenance attestation the workflow asks for.

Changes

  • publish-on-merge.yml
    • Remove NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} from the publish step.
    • Bump actions/setup-node v4 → v7, which no longer writes a placeholder _authToken to .npmrc that would override OIDC.
    • Add a step upgrading npm to latest (Trusted Publishing needs ≥ 11.5.1).
    • Point the failure summary and auto-filed issue at the Trusted Publisher config instead of NPM_TOKEN.
  • docs/RELEASE.md: setup and troubleshooting now describe Trusted Publishing; note that the workflow must be on master for the publisher to match.

One-time setup required before this works

  1. On npmjs.com: webfinger.js → Settings → Trusted Publisher → GitHub Actions. Owner silverbucket, repository webfinger.js, workflow filename publish-on-merge.yml, environment blank.
  2. Merge this PR (the publisher matches the workflow on the default branch).
  3. Delete the NPM_TOKEN and NODE_AUTH_TOKEN repository secrets.

Publishing v3.1.0

Re-running the old failed run uses the old workflow file, so it won't pick this up. Either publish 3.1.0 once by hand (npm login then npm publish from the v3.1.0 tag; prepublishOnly rebuilds dist/), or re-open and re-merge a release/v3.1.0 PR after this lands so the new workflow runs. The workflow's "already published" check keeps the tag/release steps idempotent either way.

npm is deprecating 2FA-bypass granular access tokens for direct
publishing (January 2027), and the v3.1.0 publish already fails with
EOTP because the account requires 2FA. Switch the publish workflow to
Trusted Publishing: drop NODE_AUTH_TOKEN from the publish step, bump
actions/setup-node to v7 so no placeholder token is written to .npmrc,
upgrade npm to >= 11.5.1 on the runner, and point recovery messages and
docs/RELEASE.md at the Trusted Publisher configuration.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c8cccac-0a7c-4ebd-9a36-ea0b32fa595f
📥 Commits

Reviewing files that changed from the base of the PR and between c4b25fd and 16bc80b.

📒 Files selected for processing (2)
  • .github/workflows/publish-on-merge.yml
  • docs/RELEASE.md
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security review: no medium, high, or critical issues in this diff.

Publishing now uses the job’s GitHub OIDC identity instead of a stored NPM_TOKEN. The new steps (actions/setup-node@v7 and npm install -g npm@latest) do not pass attacker-controlled input into a sink, and the job still runs only after a merged release/* pull request. I did not find an auth bypass, token leak, injection, or other exploitable path in the changed lines.

Open in Web View Automation 

Sent by Cursor Automation: PR review - Find vulnerabilities

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security review: one medium supply-chain finding in the new publish path. Removing the long-lived NPM_TOKEN and publishing with OIDC is sound. No high or critical issues, and there were no earlier automation review threads to re-open.

The remaining issue is the unpinned npm install -g npm@latest step inside the job that has id-token: write. Current Node LTS already ships npm 11.19.0, which meets the Trusted Publishing minimum, so this upgrade is not required.

Open in Web View Automation 

Sent by Cursor Automation: Find vulnerabilities


- name: Ensure npm supports Trusted Publishing (>= 11.5.1)
run: |
npm install -g npm@latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Medium — unpinned npm@latest executes with npm publish OIDC

This step installs whatever the registry currently tags latest (npm 12.2.0 today, including its bundled dependency tree). The same step then runs that binary (npm --version), and the later npm publish --provenance step runs it again. The job has id-token: write, so that process can request a GitHub OIDC token for publish-on-merge.yml. Once this workflow is a Trusted Publisher, npm will exchange that token for a credential that can publish webfinger.js.

node-version: 'lts/*' is Node 24.21.0, which already includes npm 11.19.0 (above the 11.5.1 Trusted Publishing minimum). Nothing in this job needs a floating upgrade. A compromised npm release is fetched and executed on the next merged release/* PR and can upload a tampered package under a valid provenance attestation.

Pin an exact npm version, or drop this step and publish with the npm that ships with Node 24.

@silverbucket
silverbucket merged commit 54f3162 into master Oct 8, 2026
10 checks passed
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.

NPM Publish Failed for v3.1.0

1 participant