Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inDemoInstall

registry-auth-token

Package Overview
Dependencies
1
Maintainers
3
Versions
24
Issues
File Explorer

Advanced tools

registry-auth-token

Get the auth token set for an npm registry (if any)

    5.0.1latest
    Github

Version published
Maintainers
3
Weekly downloads
11,822,118
increased by4.14%

Weekly downloads

Readme

Source

registry-auth-token

npm versionnpm

Get the auth token set for an npm registry from .npmrc. Also allows fetching the configured registry URL for a given npm scope.

Installing

npm install --save registry-auth-token

Usage

Returns an object containing token and type, or undefined if no token can be found. type can be either Bearer or Basic.

const getAuthToken = require('registry-auth-token') const getRegistryUrl = require('registry-auth-token/registry-url') // Get auth token and type for default `registry` set in `.npmrc` console.log(getAuthToken()) // {token: 'someToken', type: 'Bearer'} // Get auth token for a specific registry URL console.log(getAuthToken('//registry.foo.bar')) // Find the registry auth token for a given URL (with deep path): // If registry is at `//some.host/registry` // URL passed is `//some.host/registry/deep/path` // Will find token the closest matching path; `//some.host/registry` console.log(getAuthToken('//some.host/registry/deep/path', {recursive: true})) // Use the npm config that is passed in console.log(getAuthToken('//registry.foo.bar', { npmrc: { 'registry': 'http://registry.foo.bar', '//registry.foo.bar/:_authToken': 'qar' } })) // Find the configured registry url for scope `@foobar`. // Falls back to the global registry if not defined. console.log(getRegistryUrl('@foobar')) // Use the npm config that is passed in console.log(getRegistryUrl('http://registry.foobar.eu/', { 'registry': 'http://registry.foobar.eu/', '//registry.foobar.eu/:_authToken': 'qar' }))

Return value

// If auth info can be found: {token: 'someToken', type: 'Bearer'} // Or: {token: 'someOtherToken', type: 'Basic'} // Or, if nothing is found: undefined

Security

Please be careful when using this. Leaking your auth token is dangerous.

License

MIT © Espen Hovlandsdal

Keywords

FAQs

What is registry-auth-token?

Get the auth token set for an npm registry (if any)

Is registry-auth-token popular?

The npm package registry-auth-token receives a total of 9,588,136 weekly downloads. As such, registry-auth-token popularity was classified as popular.

Is registry-auth-token well maintained?

We found that registry-auth-token demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 3 open source maintainers collaborating on the project.

Last updated on 19 Jun 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket[email protected]

Product

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc