-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Motivation
npm Trusted Publishing is now generally available, allowing package owners to publish npm packages via CI without manually generating npm tokens. This method greatly reduces the risk of token leaks, which has been a recurring issue in the past. For more details, see:
- https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/
- https://docs.npmjs.com/trusted-publishers/
Current Status
I've added a provenance tab to node-modules-inspector, where you can view the provenance status of all my packages: https://pkg.sxzz.dev/grid/provenance
Some packages have provenance enabled but are not yet using Trusted Publishing, including:
- Vue / Vite, /cc @yyx990803 @edison1105 @patak-dev @sapphi-red
- Nuxt, /cc @danielroe
- Vitest / UnoCSS / Shiki / VueUse / Slidev, /cc @antfu @sheremet-va @zyyv
- Vitest
- UnoCSS
- Shiki ci: use oidc for npm publish & codecov shikijs/shiki#1068
- VueUse
- Slidev
- Rolldown, /cc @hyf0
- Oxc by @Boshen
- tinyexec by @43081j
- tinyglobby by @SuperchupuDev
- publint by @bluwy
- eslint-plugin-import-x / unrs-resolver / synckit by @JounQin
- List of the most popular npm packages: https://github.com/sxzz/npm-top-provenance
Migration
Note
This proposal applies only to packages already published via CI. If your package does not yet use CI for publishing, you will need to set up CI workflows before migrating to Trusted Publishing.
Migrating is straightforward for packages already published via CI:
- Connect your GitHub repository to your existing npm package at
https://www.npmjs.com/package/<your-package>/access - Upgrade npm to the latest version (11.5.1+) if you're using npm or pnpm.
- Safely remove npm tokens
- [optional] Disallow tokens and trusted publishing will still work
For reference, see this example commit:
- name: Publish to NPM
- run: npm publish
+ run: npm i -g npm@latest && npm publish # or pnpm publish
- env:
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- NPM_CONFIG_PROVENANCE: trueI also wrote a reusable workflow: https://github.com/sxzz/workflows/blob/main/examples/release.yml
Automation
Anthony created a tool that lets you open the settings pages for all your monorepo packages at once.
I’ve also developed a userscript that automatically fills in repository information on the trusted publisher form (using the required repository field from package.json) and enables 2FA by default. You can install it using Tampermonkey or Violentmonkey. Thanks to @antfu for the inspiration!
Tip
If you maintain a large monorepo, connecting all packages can be time-consuming, and the user experience is currently lacking. I tried to write a script to automate repository connections, but was blocked by Cloudflare verification. Hopefully, npm will offer this feature via API in the future.
Read more
- https://bsky.app/profile/sxzz.dev/post/3lvne6sp7bs2t
- https://bsky.app/profile/chenjiahan.bsky.social/post/3lvlihvphvk2e