This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

168
node_modules/registry-auth-token/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,168 @@
# Change Log
All notable changes will be documented in this file.
## [5.0.2] - 2023-03-05
### Changes
- Prevent crashing on invalid npmrc files (Espen Hovlandsdal)
## [5.0.0] - 2022-06-16
### BREAKING
- Require node version 14 or above (Espen Hovlandsdal)
### Added
- Add typescript definitions (Espen Hovlandsdal)
### Changes
- Replace outdated `rc` dependency with `@pnpm/npm-conf` (Kyler Nelson)
- Fix incorrect usage information in readme (Kyler Nelson)
## [4.2.2] - 2022-06-16
### Changes
- Pin version of `rc` module to `1.2.8` to avoid malware in [compromised versions](https://github.com/advisories/GHSA-g2q5-5433-rhrf) (Espen Hovlandsdal)
## [4.2.1] - 2020-11-10
### Changes
- Exclude tests from published npm files (Garrit Franke)
## [4.2.0] - 2020-07-13
### Changes
- Add support for `NPM_CONFIG_USERCONFIG` environment variable (Ben Sorohan)
## [4.1.0] - 2020-01-17
### Changes
- Add support for legacy auth token on the registry url (Gustav Blomér)
## [4.0.0] - 2019-06-17
### BREAKING
- Minimum node.js version requirement is now v6
### Changes
- Upgraded dependencies (Espen Hovlandsdal)
## [3.4.0] - 2019-03-20
### Changes
- Enabled legacy auth token to be read from environment variable (Martin Flodin)
## [3.3.2] - 2018-01-26
### Changes
- Support password with ENV variable tokens (Nowell Strite)
## [3.3.1] - 2017-05-02
### Fixes
- Auth legacy token is basic auth (Hutson Betts)
## [3.3.0] - 2017-04-24
### Changes
- Support legacy auth token config key (Zoltan Kochan)
- Use safe-buffer module for backwards-compatible base64 encoding/decoding (Espen Hovlandsdal)
- Change to standard.js coding style (Espen Hovlandsdal)
## [3.2.0] - 2017-04-20
### Changes
- Allow passing parsed npmrc from outside (Zoltan Kochan)
## [3.1.2] - 2017-04-07
### Changes
- Avoid infinite loop on invalid URL (Zoltan Kochan)
## [3.1.1] - 2017-04-06
### Changes
- Nerf-dart URLs even if recursive is set to false (Espen Hovlandsdal)
## [3.1.0] - 2016-10-19
### Changes
- Return the password and username for Basic authorization (Zoltan Kochan)
## [3.0.1] - 2016-08-07
### Changes
- Fix recursion bug (Lukas Eipert)
- Implement alternative base64 encoding/decoding implementation for Node 6 (Lukas Eipert)
## [3.0.0] - 2016-08-04
### Added
- Support for Basic Authentication (username/password) (Lukas Eipert)
### Changes
- The result format of the output changed from a simple string to an object which contains the token type
```js
// before: returns 'tokenString'
// after: returns {token: 'tokenString', type: 'Bearer'}
getAuthToken()
```
## [2.1.1] - 2016-07-10
### Changes
- Fix infinite loop when recursively resolving registry URLs on Windows (Espen Hovlandsdal)
## [2.1.0] - 2016-07-07
### Added
- Add feature to find configured registry URL for a scope (Espen Hovlandsdal)
## [2.0.0] - 2016-06-17
### Changes
- Fix tokens defined by reference to environment variables (Dan MacTough)
## [1.1.1] - 2016-04-26
### Changes
- Fix for registries with port number in URL (Ryan Day)
[1.1.1]: https://github.com/rexxars/registry-auth-token/compare/a5b4fe2f5ff982110eb8a813ba1b3b3c5d851af1...v1.1.1
[2.0.0]: https://github.com/rexxars/registry-auth-token/compare/v1.1.1...v2.0.0
[2.1.0]: https://github.com/rexxars/registry-auth-token/compare/v2.0.0...v2.1.0
[2.1.1]: https://github.com/rexxars/registry-auth-token/compare/v2.1.0...v2.1.1
[3.0.0]: https://github.com/rexxars/registry-auth-token/compare/v2.1.1...v3.0.0
[3.0.1]: https://github.com/rexxars/registry-auth-token/compare/v3.0.0...v3.0.1
[3.1.0]: https://github.com/rexxars/registry-auth-token/compare/v3.0.1...v3.1.0
[3.1.1]: https://github.com/rexxars/registry-auth-token/compare/v3.1.0...v3.1.1
[3.1.2]: https://github.com/rexxars/registry-auth-token/compare/v3.1.1...v3.1.2
[3.2.0]: https://github.com/rexxars/registry-auth-token/compare/v3.1.2...v3.2.0
[3.3.0]: https://github.com/rexxars/registry-auth-token/compare/v3.2.0...v3.3.0

21
node_modules/registry-auth-token/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Espen Hovlandsdal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

71
node_modules/registry-auth-token/README.md generated vendored Normal file
View File

@@ -0,0 +1,71 @@
# registry-auth-token
[![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)
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`.
```js
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
```js
// 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](https://espen.codes/)

64
node_modules/registry-auth-token/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,64 @@
declare namespace registryAuthToken {
/**
* The options for passing into `registry-auth-token`
*/
interface AuthOptions {
/**
* Whether or not url's path parts are recursively trimmed from the registry
* url when searching for tokens
*/
recursive?: boolean | undefined;
/**
* An npmrc configuration object used when searching for tokens. If no object is provided,
* the `.npmrc` file at the base of the project is used.
*/
npmrc?: {
/**
* A registry url used for matching
*/
registry?: string | undefined;
/**
* Registry url's with token information
*/
[registryUrls: string]: string | undefined;
} | undefined;
}
/**
* The generated authentication information
*/
interface NpmCredentials {
/**
* The token representing the users credentials
*/
token: string;
/**
* The type of token
*/
type: 'Basic' | 'Bearer';
/**
* The username used in `Basic`
*/
username?: string | undefined;
/**
* The password used in `Basic`
*/
password?: string | undefined;
}
}
/**
* Retrieves the auth token to use for a given registry URL
*
* @param registryUrl - Either the registry url used for matching, or a configuration
* object describing the contents of the .npmrc file
* @param [options] - a configuration object describing the
* contents of the .npmrc file. If an `npmrc` config object was passed in as the
* first parameter, this parameter is ignored.
* @returns The `NpmCredentials` object or undefined if no match found.
*/
declare function registryAuthToken(
registryUrl: string | registryAuthToken.AuthOptions,
options?: registryAuthToken.AuthOptions,
): registryAuthToken.NpmCredentials | undefined;
export = registryAuthToken;

144
node_modules/registry-auth-token/index.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
const url = require('url')
const npmConf = require('@pnpm/npm-conf')
const tokenKey = ':_authToken'
const legacyTokenKey = ':_auth'
const userKey = ':username'
const passwordKey = ':_password'
module.exports = function getRegistryAuthToken () {
let checkUrl
let options
if (arguments.length >= 2) {
checkUrl = arguments[0]
options = Object.assign({}, arguments[1])
} else if (typeof arguments[0] === 'string') {
checkUrl = arguments[0]
} else {
options = Object.assign({}, arguments[0])
}
options = options || {}
const providedNpmrc = options.npmrc
options.npmrc = (options.npmrc ? {
config: {
get: (key) => providedNpmrc[key]
}
} : npmConf()).config
checkUrl = checkUrl || options.npmrc.get('registry') || npmConf.defaults.registry
return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc)
}
function getRegistryAuthInfo (checkUrl, options) {
const parsed = url.parse(checkUrl, false, true)
let pathname
while (pathname !== '/' && parsed.pathname !== pathname) {
pathname = parsed.pathname || '/'
const regUrl = '//' + parsed.host + pathname.replace(/\/$/, '')
const authInfo = getAuthInfoForUrl(regUrl, options.npmrc)
if (authInfo) {
return authInfo
}
// break if not recursive
if (!options.recursive) {
return /\/$/.test(checkUrl)
? undefined
: getRegistryAuthInfo(url.resolve(checkUrl, '.'), options)
}
parsed.pathname = url.resolve(normalizePath(pathname), '..') || '/'
}
return undefined
}
function getLegacyAuthInfo (npmrc) {
if (!npmrc.get('_auth')) {
return undefined
}
const token = replaceEnvironmentVariable(npmrc.get('_auth'))
return { token: token, type: 'Basic' }
}
function normalizePath (path) {
return path[path.length - 1] === '/' ? path : path + '/'
}
function getAuthInfoForUrl (regUrl, npmrc) {
// try to get bearer token
const bearerAuth = getBearerToken(npmrc.get(regUrl + tokenKey) || npmrc.get(regUrl + '/' + tokenKey))
if (bearerAuth) {
return bearerAuth
}
// try to get basic token
const username = npmrc.get(regUrl + userKey) || npmrc.get(regUrl + '/' + userKey)
const password = npmrc.get(regUrl + passwordKey) || npmrc.get(regUrl + '/' + passwordKey)
const basicAuth = getTokenForUsernameAndPassword(username, password)
if (basicAuth) {
return basicAuth
}
const basicAuthWithToken = getLegacyAuthToken(npmrc.get(regUrl + legacyTokenKey) || npmrc.get(regUrl + '/' + legacyTokenKey))
if (basicAuthWithToken) {
return basicAuthWithToken
}
return undefined
}
function replaceEnvironmentVariable (token) {
return token.replace(/^\$\{?([^}]*)\}?$/, function (fullMatch, envVar) {
return process.env[envVar]
})
}
function getBearerToken (tok) {
if (!tok) {
return undefined
}
// check if bearer token is set as environment variable
const token = replaceEnvironmentVariable(tok)
return { token: token, type: 'Bearer' }
}
function getTokenForUsernameAndPassword (username, password) {
if (!username || !password) {
return undefined
}
// passwords are base64 encoded, so we need to decode it
// See https://github.com/npm/npm/blob/v3.10.6/lib/config/set-credentials-by-uri.js#L26
const pass = Buffer.from(replaceEnvironmentVariable(password), 'base64').toString('utf8')
// a basic auth token is base64 encoded 'username:password'
// See https://github.com/npm/npm/blob/v3.10.6/lib/config/get-credentials-by-uri.js#L70
const token = Buffer.from(username + ':' + pass, 'utf8').toString('base64')
// we found a basicToken token so let's exit the loop
return {
token: token,
type: 'Basic',
password: pass,
username: username
}
}
function getLegacyAuthToken (tok) {
if (!tok) {
return undefined
}
// check if legacy auth token is set as environment variable
const token = replaceEnvironmentVariable(tok)
return { token: token, type: 'Basic' }
}

48
node_modules/registry-auth-token/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "registry-auth-token",
"version": "5.0.2",
"description": "Get the auth token set for an npm registry (if any)",
"main": "index.js",
"scripts": {
"test": "mocha --require test/global-hooks.js",
"posttest": "standard",
"coverage": "istanbul cover _mocha"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/rexxars/registry-auth-token.git"
},
"engines": {
"node": ">=14"
},
"keywords": [
"npm",
"conf",
"config",
"npmconf",
"registry",
"auth",
"token",
"authtoken"
],
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/rexxars/registry-auth-token/issues"
},
"homepage": "https://github.com/rexxars/registry-auth-token#readme",
"dependencies": {
"@pnpm/npm-conf": "^2.1.0"
},
"devDependencies": {
"istanbul": "^0.4.2",
"mocha": "^10.0.0",
"require-uncached": "^1.0.2",
"standard": "^12.0.1"
},
"standard": {
"ignore": [
"coverage/**"
]
}
}

12
node_modules/registry-auth-token/registry-url.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { AuthOptions } from './';
/**
* Get the registry URL for a given npm scope
*
* @param scope - npm scope to resolve URL for
* @param [npmrc] - Optional object of npmrc properties to use instead of looking up the users local npmrc file
* @returns The resolved registry URL, falling back to the global npm registry
*/
declare function registryUrl(scope: string, npmrc?: Pick<AuthOptions, 'npmrc'>): string;
export = registryUrl;

7
node_modules/registry-auth-token/registry-url.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
const npmConf = require('@pnpm/npm-conf')
module.exports = function getRegistryUrl (scope, npmrc) {
const rc = npmrc ? { config: { get: (key) => npmrc[key] } } : npmConf()
const url = rc.config.get(scope + ':registry') || rc.config.get('registry') || npmConf.defaults.registry
return url.slice(-1) === '/' ? url : url + '/'
}