You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
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.
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:
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:
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:
https://www.npmjs.com/package/<your-package>/accessFor reference, see this example commit:
I 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
repositoryfield frompackage.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