{"id":16184949,"url":"https://github.com/rexxars/registry-auth-token","last_synced_at":"2025-05-15T19:08:11.384Z","repository":{"id":6154950,"uuid":"54893312","full_name":"rexxars/registry-auth-token","owner":"rexxars","description":"Get the auth token set for an npm registry","archived":false,"fork":false,"pushed_at":"2025-02-08T01:45:52.000Z","size":484,"stargazers_count":35,"open_issues_count":1,"forks_count":17,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T03:12:06.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rexxars.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-28T13:16:05.000Z","updated_at":"2025-02-08T01:45:54.000Z","dependencies_parsed_at":"2024-06-18T13:32:26.493Z","dependency_job_id":"961f61c4-7c91-41c3-adcf-644ec2e936fc","html_url":"https://github.com/rexxars/registry-auth-token","commit_stats":{"total_commits":105,"total_committers":16,"mean_commits":6.5625,"dds":0.3142857142857143,"last_synced_commit":"ce45782c768f8a5f6c4e2b3967af228409fcf0c2"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexxars%2Fregistry-auth-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexxars%2Fregistry-auth-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexxars%2Fregistry-auth-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexxars%2Fregistry-auth-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rexxars","download_url":"https://codeload.github.com/rexxars/registry-auth-token/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254313869,"owners_count":22050121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:12:53.513Z","updated_at":"2025-05-15T19:08:11.364Z","avatar_url":"https://github.com/rexxars.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# registry-auth-token\n\n[![npm version](http://img.shields.io/npm/v/registry-auth-token.svg?style=flat-square)](https://www.npmjs.com/package/registry-auth-token)[![npm](https://img.shields.io/npm/dm/registry-auth-token?style=flat-square)](https://www.npmjs.com/package/registry-auth-token)\n\nGet the auth token set for an npm registry from `.npmrc`. Also allows fetching the configured registry URL for a given npm scope.\n\n## Installing\n\n```\nnpm install --save registry-auth-token\n```\n\n## Usage\n\nReturns an object containing `token` and `type`, or `undefined` if no token can be found. `type` can be either `Bearer` or `Basic`.\n\n```js\nconst getAuthToken = require('registry-auth-token')\nconst getRegistryUrl = require('registry-auth-token/registry-url')\n\n// Get auth token and type for default `registry` set in `.npmrc`\nconsole.log(getAuthToken()) // {token: 'someToken', type: 'Bearer'}\n\n// Get auth token for a specific registry URL\nconsole.log(getAuthToken('//registry.foo.bar'))\n\n// Find the registry auth token for a given URL (with deep path):\n// If registry is at `//some.host/registry`\n// URL passed is `//some.host/registry/deep/path`\n// Will find token the closest matching path; `//some.host/registry`\nconsole.log(getAuthToken('//some.host/registry/deep/path', {recursive: true}))\n\n// Use the npm config that is passed in\nconsole.log(getAuthToken('//registry.foo.bar', {\n  npmrc: {\n    'registry': 'http://registry.foo.bar',\n    '//registry.foo.bar/:_authToken': 'qar'\n  }\n}))\n\n// Find the configured registry url for scope `@foobar`.\n// Falls back to the global registry if not defined.\nconsole.log(getRegistryUrl('@foobar'))\n\n// Use the npm config that is passed in\nconsole.log(getRegistryUrl('http://registry.foobar.eu/', {\n  'registry': 'http://registry.foobar.eu/',\n  '//registry.foobar.eu/:_authToken': 'qar'\n}))\n```\n\n## Return value\n\n```js\n// If auth info can be found:\n{token: 'someToken', type: 'Bearer'}\n\n// Or:\n{token: 'someOtherToken', type: 'Basic'}\n\n// Or, if nothing is found:\nundefined\n```\n\n## Security\n\nPlease be careful when using this. Leaking your auth token is dangerous.\n\n## License\n\nMIT © [Espen Hovlandsdal](https://espen.codes/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frexxars%2Fregistry-auth-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frexxars%2Fregistry-auth-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frexxars%2Fregistry-auth-token/lists"}