basant307/AI_Governance_Project
045
1# registry-auth-token2 3[](https://www.npmjs.com/package/registry-auth-token)[](https://www.npmjs.com/package/registry-auth-token)4 5Get the auth token set for an npm registry from `.npmrc`. Also allows fetching the configured registry URL for a given npm scope.6 7## Installing8 9```10npm install --save registry-auth-token11```12 13## Usage14 15Returns an object containing `token` and `type`, or `undefined` if no token can be found. `type` can be either `Bearer` or `Basic`.16 17```js18const getAuthToken = require('registry-auth-token')19const getRegistryUrl = require('registry-auth-token/registry-url')20 21// Get auth token and type for default `registry` set in `.npmrc`22console.log(getAuthToken()) // {token: 'someToken', type: 'Bearer'}23 24// Get auth token for a specific registry URL25console.log(getAuthToken('//registry.foo.bar'))26 27// Find the registry auth token for a given URL (with deep path):28// If registry is at `//some.host/registry`29// URL passed is `//some.host/registry/deep/path`30// Will find token the closest matching path; `//some.host/registry`31console.log(getAuthToken('//some.host/registry/deep/path', {recursive: true}))32 33// Use the npm config that is passed in34console.log(getAuthToken('//registry.foo.bar', {35 npmrc: {36 'registry': 'http://registry.foo.bar',37 '//registry.foo.bar/:_authToken': 'qar'38 }39}))40 41// Find the configured registry url for scope `@foobar`.42// Falls back to the global registry if not defined.43console.log(getRegistryUrl('@foobar'))44 45// Use the npm config that is passed in46console.log(getRegistryUrl('http://registry.foobar.eu/', {47 'registry': 'http://registry.foobar.eu/',48 '//registry.foobar.eu/:_authToken': 'qar'49}))50```51 52## Return value53 54```js55// If auth info can be found:56{token: 'someToken', type: 'Bearer'}57 58// Or:59{token: 'someOtherToken', type: 'Basic'}60 61// Or, if nothing is found:62undefined63```64 65## Security66 67Please be careful when using this. Leaking your auth token is dangerous.68 69## License70 71MIT © [Espen Hovlandsdal](https://espen.codes/)72 