[Feature] tokenHelper support on .npmrc
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
To fetch private npm packages, we need to write credentials in the .npmrc or specify them via environment variables. However, currently, it is recommended to use short-lived tokens as a countermeasure against credential leakage and not to leave credentials written in static files.This is a security feature supported not only by npm but also by Docker through a mechanism called credential helper.
By supporting this in npm, credentials will not be retained at the endpoint, significantly reducing the damage from leaks.
This feature is also supported by pnpm, a wrapper tool for npm, and it is recommended to apply it upstream in a compatible manner.
https://pnpm.io/npmrc#urltokenhelper
A token helper is an executable which outputs an auth token. This can be used in situations where the authToken is not a constant value but is something that refreshes regularly, where a script or other tool can use an existing refresh token to obtain a new access token.The configuration for the path to the helper must be an absolute path, with no arguments. In order to be secure, it is only permitted to set this value in the user .npmrc. Otherwise a project could place a value in a project's local .npmrc and run arbitrary executables.
Setting a token helper for the default registry:tokenHelper=/home/ivan/token-generatorSetting a token helper for the specified registry:
//registry.corp.com:tokenHelper=/home/ivan/token-generator
If you have any insights or recommendations regarding this feature request, please comment.
Thank you!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading npm's existing .npmrc configuration handling and the linked pnpm tokenHelper documentation. Identify how user-level configuration, absolute helper paths, registry-specific settings, and command execution are handled. Done should include compatible tokenHelper behavior with security restrictions and coverage for the supported configuration forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100