5.1.0 • Published 9 months ago

registry-auth-token v5.1.0

Weekly downloads
9,634,148
License
MIT
Repository
github
Last release
9 months ago

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

package-jsonarchetype-libraryeasy-select-rnreact-native-bluetooth2killi8n-react-native-fast-image@cashremit/cr-streamline-iconsairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationdiscord-music-botsreact-native-covid-sdk@saeon/ol-react@saeon/quick-formmysql-formatreact-native-printer-brothersreact-native-shekhar-bridge-testcogoportutilsdyx-react@oiti/documentoscopy-react-native@mink-opn/build-tokensquoc-testunblock-block-save-variables@infinitebrahmanuniverse/nolb-regi@prodam/prodam-typesluminos-ui-core@everything-registry/sub-chunk-2644jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkg@rabailriaz/hisaab-web-portalreact-native-jawwy_samplegriffin-ui-librarytar-urltest-library-123test-haptik-libwnba-appswombatwait-for-package-replicationwrite-npmrcwifi_configuration_packagewhatsconcstats-npmsui-monoreposportscale-wifi-connectstory-book-test-digital400story-book-test-package-github_digital400_vtest-zeo-collectthanksvision-camera-plugin-face-detectorvision-camera-plugin-scan-facesvision-camera-base64-resizedvantiq-reactvite_vue3_ts_ssssdddddyyyy@praella/localisationist@pradeepgudipati/kovaad-chat-ui-kit-stylesgenerator-bootstrap-boilerplate-templatejrennsoh88-react-native-scroll-indicatorjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libjametkhaled-salem-custom-componentslazy-bee-uihw9hubot-budahong1-utilshexyun.helpersmama-exportermarkdownalint-cli2m2m-chartjs-plugin-crosshair@wanmi/xwidget-cli@winfe/cli-plugin-init@wb310/utils@wecraftapps/react-native-use-keyboard@xbenjii/renovate@tlgeo/react-native-gdal@thinxviewx/core-rn@uniformdev/cli@tonysusi/vapid@vandai-nguyen/module_test@xiwen5566/aqara-automation-switch@yplabs-ltd/react-native-detector@yveskaufmann/semantic-release-lerna@zhbhun/semantic-release-npm@strong-roots-capital/get-npm-auth-token@zotasys/nativeagent-get-agent@zsylvia/renovateangularvezbaawesome-react-starsawesome-module-kdazureopenailive2dchatbot-developaron-semantic-release-npmarchlibrary
5.0.3

11 months ago

5.1.0

9 months ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.2.2

3 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.4.0

7 years ago

3.3.2

8 years ago

3.3.1

8 years ago

3.3.0

9 years ago

3.2.0

9 years ago

3.1.2

9 years ago

3.1.1

9 years ago

3.1.0

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago