5.0.2 • Published 1 year ago

registry-auth-token v5.0.2

Weekly downloads
9,634,148
License
MIT
Repository
github
Last release
1 year 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_sampleweb-yii2zeo-collect@geeky-apo/react-native-advanced-clipboardwnba-appswifi_configuration_packagewombatwait-for-package-replicationwangyaling-1axys_cliyangtao-jsupdate-notifier-cjsuse-safetyvue-v3-yandex-metrikavite_vue3_ts_ssssdddddyyyy@gr2m/semantic-release-npm-161@gr2m/semantic-release-npm-debug@gr2m/semantic-release-plugin-npm-oidc@hemith/react-native-tnkfluent.adflow.reactnativesdk-alphafluent.adflow.reactnativesdkfly-importfmsl@lugia/mega-utils@lugia/npm-utils3.0.0jawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwytest_lib_module_aartingzi-vuepresstohsaka888-use-breakpointthankstest-zeo-collecttwine-libtwine-libraryturbozzums-toolkitupdate-checkupdate-check-es5version-check-2vision-camera-base64-resizedvision-camera-plugin-scan-facesvision-camera-plugin-face-detectorwrite-npmrcwhatsconc@juice-js/semantic-release-npmetanoveretavoner@kalkanisys/vue-select@lark-org/npm@lehuyaa/my-assets@livecycle.io/rrweb-snapshotexpo-renavigatefhir2@idas1/ui-component-lib@glzr/semantic-release-npm@innodata/vue-v3-ya-metrika@npm_fluentco/adflow-react-native-sdkgo88-go88k-world@moezx/meting@moredhel/renovategogency-test-2
5.0.2

1 year ago

5.0.1

2 years ago

5.0.0

2 years ago

4.2.2

2 years ago

4.2.1

3 years ago

4.2.0

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.0

5 years ago

3.4.0

5 years ago

3.3.2

6 years ago

3.3.1

7 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.1.0

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago