5.1.0 • Published 4 months ago

registry-auth-token v5.1.0

Weekly downloads
9,634,148
License
MIT
Repository
github
Last release
4 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@cs6/react-native-test-native-view-library@con-test/react-native-concent-common@damruravihara/react-native-testing-package@cus/semantic-release-npm@continous-auth/semantic-release-npm@continuous-auth/semantic-release-npm@corelmax/react-native-my2c2p-sdk@cythral/renovate@rstacruz/pnpm@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-uigomantic_release3.0.0jawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwytest_lib_module_aarquickcapture_react_nativern-agora-ios-mweb-yii2react-native-omental-frameworkreact-native-sixdee_test_libspigot-ui-inventorytingzi-vuepressums-toolkittohsaka888-use-breakpointtools_may_24twine-libtwine-libraryturbozz@amiruldev/wajs@amirdiafi/react-native-ios-haptics
5.0.3

7 months ago

5.1.0

4 months ago

5.0.2

2 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

5 years ago

4.1.0

5 years ago

4.0.0

6 years ago

3.4.0

6 years ago

3.3.2

7 years ago

3.3.1

8 years ago

3.3.0

8 years ago

3.2.0

8 years ago

3.1.2

8 years ago

3.1.1

8 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

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago