@verdaccio/proxy 8.0.0-next-8.12 → 8.0.0-next-8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,19 @@
1
- # @verdaccio/proxy
1
+ # @verdaccio/proxy - Verdaccio Proxy Fetcher
2
2
 
3
- [![backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)
4
- [![stackshare](https://img.shields.io/badge/Follow%20on-StackShare-blue.svg?logo=stackshare&style=flat)](https://stackshare.io/verdaccio)
5
- [![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
6
- [![Crowdin](https://d322cqt584bo4o.cloudfront.net/verdaccio/localized.svg)](https://crowdin.com/project/verdaccio)
7
- [![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/verdaccio/verdaccio)](https://www.tickgit.com/browse?repo=github.com/verdaccio/verdaccio)
3
+ [![Verdaccio Home](https://img.shields.io/badge/Homepage-Verdaccio-405236?style=flat)](https://verdaccio.org)
4
+ [![MIT License](https://img.shields.io/github/license/verdaccio/verdaccio?label=License&color=405236)](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
5
+ [![Verdaccio Latest](https://img.shields.io/npm/v/verdaccio?label=Latest%20Version&color=405236)](https://github.com/verdaccio/verdaccio)
6
+ [![This Package Latest](https://img.shields.io/npm/v/@verdaccio/proxy?label=@verdaccio/proxy&color=405236)](https://npmjs.com/package/@verdaccio/proxy)
8
7
 
9
- [![Github](https://img.shields.io/github/stars/verdaccio/verdaccio.svg?style=social&label=Stars)](https://github.com/verdaccio/verdaccio/stargazers)
8
+ [![Documentation](https://img.shields.io/badge/Help-Verdaccio?style=flat&logo=Verdaccio&label=Verdaccio&color=cd4000)](https://verdaccio.org/docs)
9
+ [![Discord](https://img.shields.io/badge/Chat-Discord?style=flat&logo=Discord&label=Discord&color=cd4000)](https://discord.com/channels/388674437219745793)
10
+ [![Bluesky](https://img.shields.io/badge/Follow-Bluesky?style=flat&logo=Bluesky&label=Bluesky&color=cd4000)](https://bsky.app/profile/verdaccio.org)
11
+ [![Backers](https://img.shields.io/opencollective/backers/verdaccio?style=flat&logo=opencollective&label=Join%20Backers&color=cd4000)](https://opencollective.com/verdaccio/contribute)
12
+ [![Sponsors](https://img.shields.io/opencollective/sponsors/verdaccio?style=flat&logo=opencollective&label=Sponsor%20Us&color=cd4000)](https://opencollective.com/verdaccio/contribute)
13
+
14
+ [![Verdaccio Downloads](https://img.shields.io/npm/dm/verdaccio?style=flat&logo=npm&label=Npm%20Downloads&color=lightgrey)](https://www.npmjs.com/package/verdaccio)
15
+ [![Docker Pulls](https://img.shields.io/docker/pulls/verdaccio/verdaccio?style=flat&logo=docker&label=Docker%20Pulls&color=lightgrey)](https://hub.docker.com/r/verdaccio/verdaccio)
16
+ [![GitHub Stars](https://img.shields.io/github/stars/verdaccio?style=flat&logo=github&label=GitHub%20Stars%20%E2%AD%90&color=lightgrey)](https://github.com/verdaccio/verdaccio/stargazers)
10
17
 
11
18
  ## Donations
12
19
 
@@ -20,7 +27,7 @@ If you want to report a security vulnerability, please follow the steps which we
20
27
 
21
28
  ## Open Collective Sponsors
22
29
 
23
- Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/verdaccio#sponsor)]
30
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/verdaccio/contribute)]
24
31
 
25
32
  [![sponsor](https://opencollective.com/verdaccio/sponsor/0/avatar.svg)](https://opencollective.com/verdaccio/sponsor/0/website)
26
33
  [![sponsor](https://opencollective.com/verdaccio/sponsor/1/avatar.svg)](https://opencollective.com/verdaccio/sponsor/1/website)
@@ -35,40 +42,39 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
35
42
 
36
43
  ## Open Collective Backers
37
44
 
38
- Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/verdaccio#backer)]
45
+ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/verdaccio/contribute)]
39
46
 
40
- [![backers](https://opencollective.com/verdaccio/backers.svg?width=890)](https://opencollective.com/verdaccio#backers)
47
+ [![backers](https://opencollective.com/verdaccio/backers.svg?width=890)](https://opencollective.com/verdaccio/contributes)
41
48
 
42
49
  ## Special Thanks
43
50
 
44
51
  Thanks to the following companies to help us to achieve our goals providing free open source licenses.
45
52
 
46
- [![jetbrain](assets/thanks/jetbrains/logo.png)](https://www.jetbrains.com/)
47
- [![crowdin](assets/thanks/crowdin/logo.png)](https://crowdin.com/)
48
- [![balsamiq](assets/thanks/balsamiq/logo.jpg)](https://balsamiq.com/)
53
+ [![jetbrains](https://github.com/verdaccio/verdaccio/blob/master/assets/thanks/jetbrains/logo.jpg?raw=true)](https://www.jetbrains.com/)
54
+ [![crowdin](https://github.com/verdaccio/verdaccio/blob/master/assets/thanks/crowdin/logo.png?raw=true)](https://crowdin.com/)
49
55
 
50
56
  ## Contributors
51
57
 
52
- This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
58
+ This project exists thanks to all the people who contribute. [[Contribute](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md)].
53
59
 
54
- [![contributors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](../../graphs/contributors)
60
+ [![contributors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](https://github.com/verdaccio/verdaccio/graphs/contributors)
55
61
 
56
- ### FAQ / Contact / Troubleshoot
62
+ ## FAQ / Contact / Troubleshoot
57
63
 
58
- If you have any issue you can try the following options, do no desist to ask or check our issues database, perhaps someone has asked already what you are looking for.
64
+ If you have any issue you can try the following options. Do not hesitate to ask or check our issues database. Perhaps someone has asked already what you are looking for.
59
65
 
60
66
  - [Blog](https://verdaccio.org/blog/)
61
67
  - [Donations](https://opencollective.com/verdaccio)
62
68
  - [Reporting an issue](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md#reporting-a-bug)
63
- - [Running discussions](https://github.com/verdaccio/verdaccio/issues?q=is%3Aissue+is%3Aopen+label%3Adiscuss)
64
- - [Chat](http://chat.verdaccio.org/)
65
- - [Logos](https://verdaccio.org/docs/en/logo)
66
- - [Docker Examples](https://github.com/verdaccio/docker-examples)
69
+ - [Running discussions](https://github.com/orgs/verdaccio/discussions)
70
+ - [Chat](https://discord.com/channels/388674437219745793)
71
+ - [Logos](https://verdaccio.org/docs/logo)
72
+ - [Docker Examples](https://github.com/verdaccio/verdaccio/tree/master/docker-examples)
67
73
  - [FAQ](https://github.com/verdaccio/verdaccio/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20)
68
74
 
69
- ### License
75
+ ## License
70
76
 
71
77
  Verdaccio is [MIT licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
72
78
 
73
- The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch) files within the /assets folder) is
74
- [Creative Commons licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE-docs).
79
+ The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch files within the /assets folder) are
80
+ [Creative Commons licensed](https://creativecommons.org/licenses/by/4.0/).
package/build/proxy.d.ts CHANGED
@@ -19,6 +19,7 @@ export type ProxySearchParams = {
19
19
  retry?: Partial<RetryOptions>;
20
20
  };
21
21
  export interface IProxy {
22
+ uplinkName: string;
22
23
  config: UpLinkConfLocal;
23
24
  failed_requests: number;
24
25
  userAgent: string;
@@ -30,7 +31,6 @@ export interface IProxy {
30
31
  timeout: Delays;
31
32
  max_fails: number;
32
33
  fail_timeout: number;
33
- upname: string;
34
34
  search(options: ProxySearchParams): Promise<Stream.Readable>;
35
35
  getRemoteMetadata(name: string, options: Partial<ISyncUplinksOptions>): Promise<[Manifest, string]>;
36
36
  fetchTarball(url: string, options: Partial<Pick<ISyncUplinksOptions, 'remoteAddress' | 'etag' | 'retry'>>): PassThrough;
@@ -46,6 +46,7 @@ export interface ISyncUplinksOptions extends Options {
46
46
  * (same for storage.js, local-storage.js, up-storage.js)
47
47
  */
48
48
  declare class ProxyStorage implements IProxy {
49
+ uplinkName: string;
49
50
  config: UpLinkConfLocal;
50
51
  failed_requests: number;
51
52
  userAgent: string;
@@ -58,13 +59,12 @@ declare class ProxyStorage implements IProxy {
58
59
  max_fails: number;
59
60
  fail_timeout: number;
60
61
  agent_options: AgentOptionsConf;
61
- upname: string;
62
62
  proxy: string | undefined;
63
63
  private agent;
64
64
  last_request_time: number | null;
65
65
  strict_ssl: boolean;
66
66
  private retry;
67
- constructor(config: UpLinkConfLocal, mainConfig: Config, logger: Logger, agent?: Agents);
67
+ constructor(uplinkName: string, config: UpLinkConfLocal, mainConfig: Config, logger: Logger, agent?: Agents);
68
68
  private getAgent;
69
69
  getHeaders(headers?: {}): gotHeaders;
70
70
  /**
@@ -106,9 +106,7 @@ declare class ProxyStorage implements IProxy {
106
106
 
107
107
  * @param {Object} headers
108
108
  * @private
109
- * @deprecated use applyUplinkHeaders
110
109
  */
111
- private _overrideWithUpLinkConfLocaligHeaders;
112
110
  private applyUplinkHeaders;
113
111
  getRemoteMetadata(name: string, options: Partial<ISyncUplinksOptions>): Promise<[Manifest, string]>;
114
112
  fetchTarball(url: string, overrideOptions: Pick<ISyncUplinksOptions, 'remoteAddress' | 'etag' | 'retry'>): any;
@@ -125,6 +123,12 @@ declare class ProxyStorage implements IProxy {
125
123
  * @private
126
124
  */
127
125
  private _ifRequestFailure;
126
+ /**
127
+ * Check if the request timed out (network or http errors).
128
+ * @param {RequestError} err
129
+ * @return {boolean}
130
+ */
131
+ private _isRequestTimeout;
128
132
  /**
129
133
  * Set up a proxy.
130
134
  * @param {*} hostname
package/build/proxy.js CHANGED
@@ -44,12 +44,10 @@ const setConfig = (config, key, def) => {
44
44
  * (same for storage.js, local-storage.js, up-storage.js)
45
45
  */
46
46
  class ProxyStorage {
47
- // FIXME: upname is assigned to each instance
48
47
  // @ts-ignore
49
48
 
50
- // @ts-ignore
51
-
52
- constructor(config, mainConfig, logger, agent) {
49
+ constructor(uplinkName, config, mainConfig, logger, agent) {
50
+ this.uplinkName = uplinkName;
53
51
  this.config = config;
54
52
  this.failed_requests = 0;
55
53
  this.userAgent = mainConfig.user_agent ?? 'hidden';
@@ -127,17 +125,21 @@ class ProxyStorage {
127
125
  let token;
128
126
  const tokenConf = auth;
129
127
  if (_lodash.default.isNil(tokenConf.token) === false && _lodash.default.isString(tokenConf.token)) {
128
+ debug('use token from config');
130
129
  token = tokenConf.token;
131
130
  } else if (_lodash.default.isNil(tokenConf.token_env) === false) {
132
131
  if (typeof tokenConf.token_env === 'string') {
132
+ debug('use token from env %o', tokenConf.token_env);
133
133
  token = process.env[tokenConf.token_env];
134
134
  } else if (typeof tokenConf.token_env === 'boolean' && tokenConf.token_env) {
135
+ debug('use token from env NPM_TOKEN');
135
136
  token = process.env.NPM_TOKEN;
136
137
  } else {
137
138
  this.logger.error(_core.constants.ERROR_CODE.token_required);
138
139
  this._throwErrorAuth(_core.constants.ERROR_CODE.token_required);
139
140
  }
140
141
  } else {
142
+ debug('use token from env NPM_TOKEN');
141
143
  token = process.env.NPM_TOKEN;
142
144
  }
143
145
  if (typeof token === 'undefined') {
@@ -146,6 +148,7 @@ class ProxyStorage {
146
148
 
147
149
  // define type Auth allow basic and bearer
148
150
  const type = tokenConf.type || _core.TOKEN_BASIC;
151
+ debug('token type %o', type);
149
152
  this._setHeaderAuthorization(headers, type, token);
150
153
  return headers;
151
154
  }
@@ -172,7 +175,6 @@ class ProxyStorage {
172
175
  if (_type !== _core.TOKEN_BEARER.toLowerCase() && _type !== _core.TOKEN_BASIC.toLowerCase()) {
173
176
  this._throwErrorAuth(`Auth type '${_type}' not allowed`);
174
177
  }
175
- type = _lodash.default.upperFirst(type);
176
178
  headers[_core.HEADERS.AUTHORIZATION] = (0, _utils.buildToken)(type, token);
177
179
  }
178
180
 
@@ -193,19 +195,7 @@ class ProxyStorage {
193
195
  authorization: "Basic YourBase64EncodedCredentials=="
194
196
  * @param {Object} headers
195
197
  * @private
196
- * @deprecated use applyUplinkHeaders
197
198
  */
198
- _overrideWithUpLinkConfLocaligHeaders(headers) {
199
- if (!this.config.headers) {
200
- return headers;
201
- }
202
-
203
- // add/override headers specified in the config
204
- /* eslint guard-for-in: 0 */
205
- for (const key in this.config.headers) {
206
- headers[key] = this.config.headers[key];
207
- }
208
- }
209
199
  applyUplinkHeaders(headers) {
210
200
  if (!this.config.headers) {
211
201
  return headers;
@@ -326,21 +316,17 @@ class ProxyStorage {
326
316
  const code = err.response.statusCode;
327
317
  debug('error code %s', code);
328
318
  if (code === _core.HTTP_STATUS.NOT_FOUND) {
329
- throw _core.errorUtils.getNotFound(_core.errorUtils.API_ERROR.NOT_PACKAGE_UPLINK);
319
+ throw _core.errorUtils.getNotFound(_core.API_ERROR.NOT_PACKAGE_UPLINK);
330
320
  }
331
321
  if (!(code >= _core.HTTP_STATUS.OK && code < _core.HTTP_STATUS.MULTIPLE_CHOICES)) {
332
- const error = _core.errorUtils.getInternalError(`${_core.errorUtils.API_ERROR.BAD_STATUS_CODE}: ${code}`);
322
+ const error = _core.errorUtils.getInternalError(`${_core.API_ERROR.BAD_STATUS_CODE}: ${code}`);
333
323
  // we need this code to identify outside which status code triggered the error
334
324
  error.remoteStatus = code;
335
325
  throw error;
336
326
  }
337
- } else if (err.code === 'ETIMEDOUT') {
327
+ } else if (this._isRequestTimeout(err)) {
338
328
  debug('error code timeout');
339
- const code = err.code;
340
- const error = _core.errorUtils.getInternalError(`${_core.errorUtils.API_ERROR.SERVER_TIME_OUT}: ${code}`);
341
- // we need this code to identify outside which status code triggered the error
342
- error.remoteStatus = code;
343
- throw error;
329
+ throw _core.errorUtils.getServiceUnavailable(_core.API_ERROR.SERVER_TIME_OUT);
344
330
  }
345
331
  throw err;
346
332
  }
@@ -392,7 +378,7 @@ class ProxyStorage {
392
378
  const uri = new _url.URL(url, this.url).href;
393
379
  this.logger.http({
394
380
  uri,
395
- uplink: this.upname
381
+ uplink: this.uplinkName
396
382
  }, 'search request to uplink @{uplink} - @{uri}');
397
383
  debug('searching on %o', uri);
398
384
  const response = (0, _gotCjs.default)(uri, {
@@ -420,7 +406,7 @@ class ProxyStorage {
420
406
  }
421
407
  this.logger.error({
422
408
  errorMessage: err?.message,
423
- name: this.upname
409
+ name: this.uplinkName
424
410
  }, 'proxy uplink @{name} search error: @{errorMessage}');
425
411
  throw err;
426
412
  }
@@ -449,6 +435,16 @@ class ProxyStorage {
449
435
  return this.failed_requests >= this.max_fails && Math.abs(Date.now() - this.last_request_time) < this.fail_timeout;
450
436
  }
451
437
 
438
+ /**
439
+ * Check if the request timed out (network or http errors).
440
+ * @param {RequestError} err
441
+ * @return {boolean}
442
+ */
443
+ _isRequestTimeout(err) {
444
+ const code = err?.response?.statusCode;
445
+ return err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT' || err.code === 'ECONNRESET' || code === _core.HTTP_STATUS.REQUEST_TIMEOUT || code === _core.HTTP_STATUS.BAD_GATEWAY || code === _core.HTTP_STATUS.SERVICE_UNAVAILABLE || code === _core.HTTP_STATUS.GATEWAY_TIMEOUT;
446
+ }
447
+
452
448
  /**
453
449
  * Set up a proxy.
454
450
  * @param {*} hostname
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","names":["_JSONStream","_interopRequireDefault","require","_debug","_gotCjs","_interopRequireWildcard","_lodash","_stream","_url","_core","_utils","_agent","_proxyUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","debug","buildDebug","encode","thing","encodeURIComponent","replace","jsonContentType","HEADERS","JSON","contentTypeAccept","setConfig","config","key","def","_","isNil","ProxyStorage","constructor","mainConfig","logger","agent","failed_requests","userAgent","user_agent","ca","server_id","agent_options","keepAlive","maxSockets","maxFreeSockets","url","URL","isHTTPS","protocol","_setupProxy","hostname","getAgent","timeout","Number","warn","join","maxage","parseInterval","request","max_fails","fail_timeout","strict_ssl","Boolean","retry","limit","agentInstance","CustomAgents","proxy","getHeaders","headers","accept","ACCEPT","acceptEncoding","ACCEPT_ENCODING","USER_AGENT","setAuthNext","auth","AUTHORIZATION","isObject","token","_throwErrorAuth","tokenConf","isString","token_env","process","env","NPM_TOKEN","error","constants","ERROR_CODE","token_required","type","TOKEN_BASIC","_setHeaderAuthorization","message","Error","_type","toLowerCase","TOKEN_BEARER","upperFirst","buildToken","_overrideWithUpLinkConfLocaligHeaders","applyUplinkHeaders","getRemoteMetadata","name","options","_ifRequestFailure","errorUtils","getInternalError","API_ERROR","UPLINK_OFFLINE","addProxyHeaders","remoteAddress","etag","NONE_MATCH","method","uri","response","responseLength","got","responseType","hooks","afterResponse","code","statusCode","HTTP_STATUS","OK","MULTIPLE_CHOICES","host","beforeRetry","count","info","retryCount","on","last_request_time","Date","now","eventResponse","http","status","isNull","progress","total","data","body","NOT_MODIFIED","getCode","NOT_MODIFIED_NO_DATA","bytes","in","json","stringify","length","out","err","NOT_FOUND","getNotFound","NOT_PACKAGE_UPLINK","BAD_STATUS_CODE","remoteStatus","SERVER_TIME_OUT","fetchTarball","overrideOptions","readStream","stream","search","abort","href","uplink","upname","signal","res","text","parse","streamSearch","PassThrough","objectMode","streamResponse","Readable","from","pipe","JSONStream","end","errorMessage","FORWARDED_FOR","Math","abs","mainconfig","noProxyList","proxy_key","no_proxy","split","isArray","noProxyItem","endsWith","rule","undefined","proxyUrl","expectedProtocol","exports"],"sources":["../src/proxy.ts"],"sourcesContent":["import JSONStream from 'JSONStream';\nimport buildDebug from 'debug';\nimport got, {\n Agents,\n Delays,\n Options,\n RequestError,\n RetryOptions,\n Headers as gotHeaders,\n} from 'got-cjs';\nimport _ from 'lodash';\nimport Stream, { PassThrough, Readable } from 'stream';\nimport { URL } from 'url';\n\nimport {\n API_ERROR,\n HEADERS,\n HTTP_STATUS,\n TOKEN_BASIC,\n TOKEN_BEARER,\n constants,\n errorUtils,\n searchUtils,\n} from '@verdaccio/core';\nimport { AgentOptionsConf, Config, Logger, Manifest, UpLinkConf } from '@verdaccio/types';\nimport { buildToken } from '@verdaccio/utils';\n\nimport CustomAgents from './agent';\nimport { parseInterval } from './proxy-utils';\n\nconst debug = buildDebug('verdaccio:proxy');\n\nconst encode = function (thing): string {\n return encodeURIComponent(thing).replace(/^%40/, '@');\n};\n\nconst jsonContentType = HEADERS.JSON;\nconst contentTypeAccept = `${jsonContentType};`;\n\n/**\n * Just a helper (`config[key] || default` doesn't work because of zeroes)\n */\nconst setConfig = (config: UpLinkConfLocal, key: string, def): string => {\n return _.isNil(config[key]) === false ? config[key] : def;\n};\n\nexport type UpLinkConfLocal = UpLinkConf & {\n no_proxy?: string;\n};\n\nexport interface ProxyList {\n [key: string]: IProxy;\n}\n\nexport type ProxySearchParams = {\n url: string;\n abort: AbortController;\n query?: searchUtils.SearchQuery;\n headers?: Headers;\n retry?: Partial<RetryOptions>;\n};\nexport interface IProxy {\n config: UpLinkConfLocal;\n failed_requests: number;\n userAgent: string;\n ca?: string | void;\n logger: Logger;\n server_id: string;\n url: URL;\n maxage: number;\n timeout: Delays;\n max_fails: number;\n fail_timeout: number;\n upname: string;\n search(options: ProxySearchParams): Promise<Stream.Readable>;\n getRemoteMetadata(\n name: string,\n options: Partial<ISyncUplinksOptions>\n ): Promise<[Manifest, string]>;\n fetchTarball(\n url: string,\n options: Partial<Pick<ISyncUplinksOptions, 'remoteAddress' | 'etag' | 'retry'>>\n ): PassThrough;\n}\n\n// this type is need it by storage\nexport { Options as FetchOptions };\n\nexport interface ISyncUplinksOptions extends Options {\n uplinksLook?: boolean;\n etag?: string;\n remoteAddress?: string;\n}\n\n/**\n * Implements Storage interface\n * (same for storage.js, local-storage.js, up-storage.js)\n */\nclass ProxyStorage implements IProxy {\n public config: UpLinkConfLocal;\n public failed_requests: number;\n public userAgent: string;\n public ca: string | void;\n public logger: Logger;\n public server_id: string;\n public url: URL;\n public maxage: number;\n public timeout: Delays;\n public max_fails: number;\n public fail_timeout: number;\n public agent_options: AgentOptionsConf;\n // FIXME: upname is assigned to each instance\n // @ts-ignore\n public upname: string;\n public proxy: string | undefined;\n private agent: Agents;\n // @ts-ignore\n public last_request_time: number | null;\n public strict_ssl: boolean;\n private retry: Partial<RetryOptions>;\n\n public constructor(config: UpLinkConfLocal, mainConfig: Config, logger: Logger, agent?: Agents) {\n this.config = config;\n this.failed_requests = 0;\n this.userAgent = mainConfig.user_agent ?? 'hidden';\n this.ca = config.ca;\n this.logger = logger;\n this.server_id = mainConfig.server_id;\n this.agent_options = setConfig(this.config, 'agent_options', {\n keepAlive: true,\n maxSockets: 40,\n maxFreeSockets: 10,\n }) as AgentOptionsConf;\n this.url = new URL(this.config.url);\n const isHTTPS = this.url.protocol === 'https:';\n this._setupProxy(this.url.hostname, config, mainConfig, isHTTPS);\n this.agent = agent ?? this.getAgent();\n this.config.url = this.config.url.replace(/\\/$/, '');\n\n if (this.config.timeout && Number(this.config.timeout) >= 1000) {\n this.logger.warn(\n [\n 'Too big timeout value: ' + this.config.timeout,\n 'We changed time format to nginx-like one',\n '(see http://nginx.org/en/docs/syntax.html)',\n 'so please update your config accordingly',\n ].join('\\n')\n );\n }\n\n // a bunch of different configurable timers\n this.maxage = parseInterval(setConfig(this.config, 'maxage', '2m'));\n // https://github.com/sindresorhus/got/blob/main/documentation/6-timeout.md\n this.timeout = {\n request: parseInterval(setConfig(this.config, 'timeout', '30s')),\n };\n debug('set timeout %s', this.timeout);\n this.max_fails = Number(setConfig(this.config, 'max_fails', this.config.max_fails ?? 2));\n this.fail_timeout = parseInterval(setConfig(this.config, 'fail_timeout', '5m'));\n this.strict_ssl = Boolean(setConfig(this.config, 'strict_ssl', true));\n this.retry = { limit: this.max_fails ?? 2 };\n }\n\n private getAgent() {\n if (!this.agent) {\n // TODO: the config.ca (certificates) is not yet injected here\n const agentInstance = new CustomAgents(this.config.url, this.proxy, this.agent_options);\n return agentInstance.get();\n } else {\n return this.agent;\n }\n }\n\n public getHeaders(headers = {}): gotHeaders {\n const accept = HEADERS.ACCEPT;\n const acceptEncoding = HEADERS.ACCEPT_ENCODING;\n const userAgent = HEADERS.USER_AGENT;\n\n headers[accept] = headers[accept] || contentTypeAccept;\n headers[acceptEncoding] = headers[acceptEncoding] || 'gzip';\n // registry.npmjs.org will only return search result if user-agent include string 'npm'\n headers[userAgent] = headers[userAgent] || `npm (${this.userAgent})`;\n return this.setAuthNext(headers);\n }\n\n /**\n * Validate configuration auth and assign Header authorization\n * @param {Object} headers\n * @return {Object}\n * @private\n */\n private setAuthNext(headers: gotHeaders): gotHeaders {\n const { auth } = this.config;\n if (typeof auth === 'undefined' || typeof headers[HEADERS.AUTHORIZATION] === 'string') {\n return headers;\n }\n\n if (_.isObject(auth) === false && _.isObject((auth as any).token) === false) {\n this._throwErrorAuth('Auth invalid');\n }\n\n // get NPM_TOKEN http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules\n // or get other variable export in env\n // https://github.com/verdaccio/verdaccio/releases/tag/v2.5.0\n let token: any;\n const tokenConf: any = auth;\n if (_.isNil(tokenConf.token) === false && _.isString(tokenConf.token)) {\n token = tokenConf.token;\n } else if (_.isNil(tokenConf.token_env) === false) {\n if (typeof tokenConf.token_env === 'string') {\n token = process.env[tokenConf.token_env];\n } else if (typeof tokenConf.token_env === 'boolean' && tokenConf.token_env) {\n token = process.env.NPM_TOKEN;\n } else {\n this.logger.error(constants.ERROR_CODE.token_required);\n this._throwErrorAuth(constants.ERROR_CODE.token_required);\n }\n } else {\n token = process.env.NPM_TOKEN;\n }\n\n if (typeof token === 'undefined') {\n this._throwErrorAuth(constants.ERROR_CODE.token_required);\n }\n\n // define type Auth allow basic and bearer\n const type = tokenConf.type || TOKEN_BASIC;\n this._setHeaderAuthorization(headers, type, token);\n\n return headers;\n }\n\n /**\n * @param {string} message\n * @throws {Error}\n * @private\n */\n private _throwErrorAuth(message: string): Error {\n this.logger.error(message);\n throw new Error(message);\n }\n\n /**\n * Assign Header authorization with type authentication\n * @param {Object} headers\n * @param {string} type\n * @param {string} token\n * @private\n */\n private _setHeaderAuthorization(headers: any, type: string, token: any): void {\n const _type: string = type.toLowerCase();\n\n if (_type !== TOKEN_BEARER.toLowerCase() && _type !== TOKEN_BASIC.toLowerCase()) {\n this._throwErrorAuth(`Auth type '${_type}' not allowed`);\n }\n\n type = _.upperFirst(type);\n headers[HEADERS.AUTHORIZATION] = buildToken(type, token);\n }\n\n /**\n * It will add or override specified headers from config file.\n *\n * Eg:\n *\n * uplinks:\n npmjs:\n url: https://registry.npmjs.org/\n headers:\n Accept: \"application/vnd.npm.install-v2+json; q=1.0\"\n verdaccio-staging:\n url: https://mycompany.com/npm\n headers:\n Accept: \"application/json\"\n authorization: \"Basic YourBase64EncodedCredentials==\"\n\n * @param {Object} headers\n * @private\n * @deprecated use applyUplinkHeaders\n */\n private _overrideWithUpLinkConfLocaligHeaders(headers: Headers): any {\n if (!this.config.headers) {\n return headers;\n }\n\n // add/override headers specified in the config\n /* eslint guard-for-in: 0 */\n for (const key in this.config.headers) {\n headers[key] = this.config.headers[key];\n }\n }\n\n private applyUplinkHeaders(headers: gotHeaders): gotHeaders {\n if (!this.config.headers) {\n return headers;\n }\n\n // add/override headers specified in the config\n /* eslint guard-for-in: 0 */\n for (const key in this.config.headers) {\n headers[key] = this.config.headers[key];\n }\n return headers;\n }\n\n public async getRemoteMetadata(\n name: string,\n options: Partial<ISyncUplinksOptions>\n ): Promise<[Manifest, string]> {\n if (this._ifRequestFailure()) {\n throw errorUtils.getInternalError(API_ERROR.UPLINK_OFFLINE);\n }\n\n // FUTURE: allow mix headers that comes from the client\n debug('getting metadata for package %s', name);\n let headers = this.getHeaders(options?.headers);\n headers = this.addProxyHeaders(headers, options.remoteAddress);\n headers = this.applyUplinkHeaders(headers);\n // the following headers cannot be overwritten\n if (_.isNil(options.etag) === false) {\n headers[HEADERS.NONE_MATCH] = options.etag;\n headers[HEADERS.ACCEPT] = contentTypeAccept;\n }\n const method = options.method || 'GET';\n const uri = this.config.url + `/${encode(name)}`;\n debug('set retry limit is %s', this.retry.limit);\n let response;\n let responseLength = 0;\n try {\n const retry = options?.retry ?? this.retry;\n debug('retry initial count %s', retry);\n response = await got(uri, {\n headers,\n responseType: 'json',\n method,\n agent: this.agent,\n retry,\n timeout: this.timeout,\n hooks: {\n afterResponse: [\n (afterResponse) => {\n const code = afterResponse.statusCode;\n debug('after response code is %s', code);\n if (code >= HTTP_STATUS.OK && code < HTTP_STATUS.MULTIPLE_CHOICES) {\n if (this.failed_requests >= this.max_fails) {\n this.failed_requests = 0;\n this.logger.warn(\n {\n host: this.url.host,\n },\n 'host @{host} is now online'\n );\n }\n }\n\n return afterResponse;\n },\n ],\n beforeRetry: [\n (error: RequestError, count: number) => {\n debug('retry %s count: %s', uri, count);\n this.failed_requests = count ?? 0;\n this.logger.info(\n {\n request: {\n method: method,\n url: uri,\n },\n error: error.message,\n retryCount: this.failed_requests,\n },\n \"retry @{retryCount} req: '@{request.method} @{request.url}'\"\n );\n if (this.failed_requests >= this.max_fails) {\n this.logger.warn(\n {\n host: this.url.host,\n },\n 'host @{host} is now offline'\n );\n }\n },\n ],\n },\n })\n .on('request', () => {\n this.last_request_time = Date.now();\n })\n .on<any>('response', (eventResponse) => {\n const message = \"@{!status}, req: '@{request.method} @{request.url}' (streaming)\";\n this.logger.http(\n {\n request: {\n method: method,\n url: uri,\n },\n status: _.isNull(eventResponse) === false ? eventResponse.statusCode : 'ERR',\n },\n message\n );\n })\n .on('downloadProgress', (progress) => {\n if (progress.total) {\n debug('responseLength %s', progress.total);\n responseLength = progress.total;\n }\n });\n const etag = response.headers.etag as string;\n const data = response.body;\n\n // not modified status (304) registry does not return any payload\n // it is handled as an error\n if (response?.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n throw errorUtils.getCode(HTTP_STATUS.NOT_MODIFIED, API_ERROR.NOT_MODIFIED_NO_DATA);\n }\n\n debug('uri %s success', uri);\n const message = \"@{!status}, req: '@{request.method} @{request.url}'\";\n this.logger.http(\n {\n // if error is null/false change this to undefined so it wont log\n request: { method: method, url: uri },\n status: response.statusCode,\n bytes: {\n in: options?.json ? JSON.stringify(options?.json).length : 0,\n out: responseLength || 0,\n },\n },\n message\n );\n return [data, etag];\n } catch (err: any) {\n debug('error %s on uri %s', err.code, uri);\n if (err.code === 'ERR_NON_2XX_3XX_RESPONSE') {\n const code = err.response.statusCode;\n debug('error code %s', code);\n if (code === HTTP_STATUS.NOT_FOUND) {\n throw errorUtils.getNotFound(errorUtils.API_ERROR.NOT_PACKAGE_UPLINK);\n }\n\n if (!(code >= HTTP_STATUS.OK && code < HTTP_STATUS.MULTIPLE_CHOICES)) {\n const error = errorUtils.getInternalError(\n `${errorUtils.API_ERROR.BAD_STATUS_CODE}: ${code}`\n );\n // we need this code to identify outside which status code triggered the error\n error.remoteStatus = code;\n throw error;\n }\n } else if (err.code === 'ETIMEDOUT') {\n debug('error code timeout');\n const code = err.code;\n const error = errorUtils.getInternalError(\n `${errorUtils.API_ERROR.SERVER_TIME_OUT}: ${code}`\n );\n // we need this code to identify outside which status code triggered the error\n error.remoteStatus = code;\n throw error;\n }\n throw err;\n }\n }\n\n // FIXME: handle stream and retry\n public fetchTarball(\n url: string,\n overrideOptions: Pick<ISyncUplinksOptions, 'remoteAddress' | 'etag' | 'retry'>\n ): any {\n debug('fetching url for %s', url);\n const options = { ...this.config, ...overrideOptions };\n let headers = this.getHeaders(options?.headers);\n headers = this.addProxyHeaders(headers, options.remoteAddress);\n headers = this.applyUplinkHeaders(headers);\n // the following headers cannot be overwritten\n if (_.isNil(options.etag) === false) {\n headers[HEADERS.NONE_MATCH] = options.etag;\n headers[HEADERS.ACCEPT] = contentTypeAccept;\n }\n const method = 'GET';\n // const uri = this.config.url + `/${encode(name)}`;\n debug('request uri for %s', url);\n\n const readStream = got\n .stream(url, {\n headers,\n method,\n agent: this.agent,\n // FIXME: this should be taken from construtor as priority\n retry: this.retry ?? options?.retry,\n timeout: this.timeout,\n })\n .on('request', () => {\n this.last_request_time = Date.now();\n });\n\n return readStream;\n }\n\n /**\n * Perform a stream search.\n * @param {*} options request options\n * @return {Stream}\n */\n public async search({ url, abort, retry }: ProxySearchParams): Promise<Stream.Readable> {\n try {\n // Incoming URL is relative ie /-/v1/search...\n const uri = new URL(url, this.url).href;\n this.logger.http({ uri, uplink: this.upname }, 'search request to uplink @{uplink} - @{uri}');\n debug('searching on %o', uri);\n const response = got(uri, {\n signal: abort ? abort.signal : {},\n agent: this.agent,\n timeout: this.timeout,\n retry: retry ?? this.retry,\n });\n\n const res = await response.text();\n const total = JSON.parse(res).total;\n debug('number of packages found: %o', total);\n const streamSearch = new PassThrough({ objectMode: true });\n const streamResponse = Readable.from(res);\n // objects is one of the properties on the body, it ignores date and total\n streamResponse.pipe(JSONStream.parse('objects')).pipe(streamSearch, { end: true });\n return streamSearch;\n } catch (err: any) {\n debug('search error %s', err);\n if (err.response.statusCode === 409) {\n throw errorUtils.getInternalError(`bad status code ${err.response.statusCode} from uplink`);\n }\n this.logger.error(\n { errorMessage: err?.message, name: this.upname },\n 'proxy uplink @{name} search error: @{errorMessage}'\n );\n throw err;\n }\n }\n\n private addProxyHeaders(headers: gotHeaders, remoteAddress?: string): gotHeaders {\n // Only submit X-Forwarded-For field if we don't have a proxy selected\n // in the config file.\n //\n // Otherwise misconfigured proxy could return 407\n if (!this.proxy) {\n headers[HEADERS.FORWARDED_FOR] =\n (headers['x-forwarded-for'] ? headers['x-forwarded-for'] + ', ' : '') + remoteAddress;\n }\n\n // always attach Via header to avoid loops, even if we're not proxying\n headers['via'] = headers['via'] ? headers['via'] + ', ' : '';\n headers['via'] += '1.1 ' + this.server_id + ' (Verdaccio)';\n\n return headers;\n }\n\n /**\n * If the request failure.\n * @return {boolean}\n * @private\n */\n private _ifRequestFailure(): boolean {\n return (\n this.failed_requests >= this.max_fails &&\n Math.abs(Date.now() - (this.last_request_time as number)) < this.fail_timeout\n );\n }\n\n /**\n * Set up a proxy.\n * @param {*} hostname\n * @param {*} config\n * @param {*} mainconfig\n * @param {*} isHTTPS\n */\n private _setupProxy(\n hostname: string,\n config: UpLinkConfLocal,\n mainconfig: Config,\n isHTTPS: boolean\n ): void {\n let noProxyList;\n const proxy_key: string = isHTTPS ? 'https_proxy' : 'http_proxy';\n debug('looking for %o', proxy_key);\n\n // get http_proxy and no_proxy configs\n if (proxy_key in config) {\n this.proxy = config[proxy_key];\n debug('found %o in uplink config', this.proxy);\n } else if (proxy_key in mainconfig) {\n this.proxy = mainconfig[proxy_key];\n debug('found %o in main config', this.proxy);\n }\n if ('no_proxy' in config) {\n noProxyList = config.no_proxy;\n } else if ('no_proxy' in mainconfig) {\n noProxyList = mainconfig.no_proxy;\n }\n\n // use wget-like algorithm to determine if proxy shouldn't be used\n if (hostname[0] !== '.') {\n hostname = '.' + hostname;\n }\n\n if (_.isString(noProxyList) && noProxyList.length) {\n noProxyList = noProxyList.split(',');\n }\n\n if (_.isArray(noProxyList)) {\n for (let i = 0; i < noProxyList.length; i++) {\n let noProxyItem = noProxyList[i];\n if (noProxyItem[0] !== '.') {\n noProxyItem = '.' + noProxyItem;\n }\n if (hostname.endsWith(noProxyItem)) {\n if (this.proxy) {\n debug('not using proxy, excluded by @{rule}', noProxyItem);\n this.logger.debug(\n { url: this.url.href, rule: noProxyItem },\n 'not using proxy for @{url}, excluded by @{rule} rule'\n );\n this.proxy = undefined;\n }\n break;\n }\n }\n }\n\n // validate proxy protocol matches the proxy_key type\n if (this.proxy) {\n const proxyUrl = new URL(this.proxy);\n const expectedProtocol = isHTTPS ? 'https:' : 'http:';\n if (proxyUrl.protocol !== expectedProtocol) {\n this.logger.error(\n { proxy: this.proxy, expectedProtocol },\n `invalid protocol for ${proxy_key} - must be ${expectedProtocol}`\n );\n this.proxy = undefined;\n return;\n }\n }\n\n if (typeof this.proxy === 'string') {\n debug('using proxy @{proxy} for @{url}', this.proxy, this.url.href);\n this.logger.debug(\n { url: this.url.href, proxy: this.proxy },\n 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IACF;;IAEA;IACA,IAAI,IAAI,CAACjI,KAAK,EAAE;MACd,MAAMkI,QAAQ,GAAG,IAAIvJ,QAAG,CAAC,IAAI,CAACqB,KAAK,CAAC;MACpC,MAAMmI,gBAAgB,GAAGvJ,OAAO,GAAG,QAAQ,GAAG,OAAO;MACrD,IAAIsJ,QAAQ,CAACrJ,QAAQ,KAAKsJ,gBAAgB,EAAE;QAC1C,IAAI,CAACpK,MAAM,CAACqD,KAAK,CACf;UAAEpB,KAAK,EAAE,IAAI,CAACA,KAAK;UAAEmI;QAAiB,CAAC,EACvC,wBAAwBT,SAAS,cAAcS,gBAAgB,EACjE,CAAC;QACD,IAAI,CAACnI,KAAK,GAAGiI,SAAS;QACtB;MACF;IACF;IAEA,IAAI,OAAO,IAAI,CAACjI,KAAK,KAAK,QAAQ,EAAE;MAClCpD,KAAK,CAAC,iCAAiC,EAAE,IAAI,CAACoD,KAAK,EAAE,IAAI,CAACtB,GAAG,CAAC0H,IAAI,CAAC;MACnE,IAAI,CAACrI,MAAM,CAACnB,KAAK,CACf;QAAE8B,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC0H,IAAI;QAAEpG,KAAK,EAAE,IAAI,CAACA;MAAM,CAAC,EACzC,iCACF,CAAC;IACH;EACF;AACF;AAACoI,OAAA,CAAAxK,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"file":"proxy.js","names":["_JSONStream","_interopRequireDefault","require","_debug","_gotCjs","_interopRequireWildcard","_lodash","_stream","_url","_core","_utils","_agent","_proxyUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","debug","buildDebug","encode","thing","encodeURIComponent","replace","jsonContentType","HEADERS","JSON","contentTypeAccept","setConfig","config","key","def","_","isNil","ProxyStorage","constructor","uplinkName","mainConfig","logger","agent","failed_requests","userAgent","user_agent","ca","server_id","agent_options","keepAlive","maxSockets","maxFreeSockets","url","URL","isHTTPS","protocol","_setupProxy","hostname","getAgent","timeout","Number","warn","join","maxage","parseInterval","request","max_fails","fail_timeout","strict_ssl","Boolean","retry","limit","agentInstance","CustomAgents","proxy","getHeaders","headers","accept","ACCEPT","acceptEncoding","ACCEPT_ENCODING","USER_AGENT","setAuthNext","auth","AUTHORIZATION","isObject","token","_throwErrorAuth","tokenConf","isString","token_env","process","env","NPM_TOKEN","error","constants","ERROR_CODE","token_required","type","TOKEN_BASIC","_setHeaderAuthorization","message","Error","_type","toLowerCase","TOKEN_BEARER","buildToken","applyUplinkHeaders","getRemoteMetadata","name","options","_ifRequestFailure","errorUtils","getInternalError","API_ERROR","UPLINK_OFFLINE","addProxyHeaders","remoteAddress","etag","NONE_MATCH","method","uri","response","responseLength","got","responseType","hooks","afterResponse","code","statusCode","HTTP_STATUS","OK","MULTIPLE_CHOICES","host","beforeRetry","count","info","retryCount","on","last_request_time","Date","now","eventResponse","http","status","isNull","progress","total","data","body","NOT_MODIFIED","getCode","NOT_MODIFIED_NO_DATA","bytes","in","json","stringify","length","out","err","NOT_FOUND","getNotFound","NOT_PACKAGE_UPLINK","BAD_STATUS_CODE","remoteStatus","_isRequestTimeout","getServiceUnavailable","SERVER_TIME_OUT","fetchTarball","overrideOptions","readStream","stream","search","abort","href","uplink","signal","res","text","parse","streamSearch","PassThrough","objectMode","streamResponse","Readable","from","pipe","JSONStream","end","errorMessage","FORWARDED_FOR","Math","abs","REQUEST_TIMEOUT","BAD_GATEWAY","SERVICE_UNAVAILABLE","GATEWAY_TIMEOUT","mainconfig","noProxyList","proxy_key","no_proxy","split","isArray","noProxyItem","endsWith","rule","undefined","proxyUrl","expectedProtocol","exports"],"sources":["../src/proxy.ts"],"sourcesContent":["import JSONStream from 'JSONStream';\nimport buildDebug from 'debug';\nimport got, {\n Agents,\n Delays,\n Options,\n RequestError,\n RetryOptions,\n Headers as gotHeaders,\n} from 'got-cjs';\nimport _ from 'lodash';\nimport Stream, { PassThrough, Readable } from 'stream';\nimport { URL } from 'url';\n\nimport {\n API_ERROR,\n HEADERS,\n HTTP_STATUS,\n TOKEN_BASIC,\n TOKEN_BEARER,\n constants,\n errorUtils,\n searchUtils,\n} from '@verdaccio/core';\nimport { AgentOptionsConf, Config, Logger, Manifest, UpLinkConf } from '@verdaccio/types';\nimport { buildToken } from '@verdaccio/utils';\n\nimport CustomAgents from './agent';\nimport { parseInterval } from './proxy-utils';\n\nconst debug = buildDebug('verdaccio:proxy');\n\nconst encode = function (thing): string {\n return encodeURIComponent(thing).replace(/^%40/, '@');\n};\n\nconst jsonContentType = HEADERS.JSON;\nconst contentTypeAccept = `${jsonContentType};`;\n\n/**\n * Just a helper (`config[key] || default` doesn't work because of zeroes)\n */\nconst setConfig = (config: UpLinkConfLocal, key: string, def): string => {\n return _.isNil(config[key]) === false ? config[key] : def;\n};\n\nexport type UpLinkConfLocal = UpLinkConf & {\n no_proxy?: string;\n};\n\nexport interface ProxyList {\n [key: string]: IProxy;\n}\n\nexport type ProxySearchParams = {\n url: string;\n abort: AbortController;\n query?: searchUtils.SearchQuery;\n headers?: Headers;\n retry?: Partial<RetryOptions>;\n};\nexport interface IProxy {\n uplinkName: string;\n config: UpLinkConfLocal;\n failed_requests: number;\n userAgent: string;\n ca?: string | void;\n logger: Logger;\n server_id: string;\n url: URL;\n maxage: number;\n timeout: Delays;\n max_fails: number;\n fail_timeout: number;\n search(options: ProxySearchParams): Promise<Stream.Readable>;\n getRemoteMetadata(\n name: string,\n options: Partial<ISyncUplinksOptions>\n ): Promise<[Manifest, string]>;\n fetchTarball(\n url: string,\n options: Partial<Pick<ISyncUplinksOptions, 'remoteAddress' | 'etag' | 'retry'>>\n ): PassThrough;\n}\n\n// this type is need it by storage\nexport { Options as FetchOptions };\n\nexport interface ISyncUplinksOptions extends Options {\n uplinksLook?: boolean;\n etag?: string;\n remoteAddress?: string;\n}\n\n/**\n * Implements Storage interface\n * (same for storage.js, local-storage.js, up-storage.js)\n */\nclass ProxyStorage implements IProxy {\n public uplinkName: string;\n public config: UpLinkConfLocal;\n public failed_requests: number;\n public userAgent: string;\n public ca: string | void;\n public logger: Logger;\n public server_id: string;\n public url: URL;\n public maxage: number;\n public timeout: Delays;\n public max_fails: number;\n public fail_timeout: number;\n public agent_options: AgentOptionsConf;\n public proxy: string | undefined;\n private agent: Agents;\n // @ts-ignore\n public last_request_time: number | null;\n public strict_ssl: boolean;\n private retry: Partial<RetryOptions>;\n\n public constructor(\n uplinkName: string,\n config: UpLinkConfLocal,\n mainConfig: Config,\n logger: Logger,\n agent?: Agents\n ) {\n this.uplinkName = uplinkName;\n this.config = config;\n this.failed_requests = 0;\n this.userAgent = mainConfig.user_agent ?? 'hidden';\n this.ca = config.ca;\n this.logger = logger;\n this.server_id = mainConfig.server_id;\n this.agent_options = setConfig(this.config, 'agent_options', {\n keepAlive: true,\n maxSockets: 40,\n maxFreeSockets: 10,\n }) as AgentOptionsConf;\n this.url = new URL(this.config.url);\n const isHTTPS = this.url.protocol === 'https:';\n this._setupProxy(this.url.hostname, config, mainConfig, isHTTPS);\n this.agent = agent ?? this.getAgent();\n this.config.url = this.config.url.replace(/\\/$/, '');\n\n if (this.config.timeout && Number(this.config.timeout) >= 1000) {\n this.logger.warn(\n [\n 'Too big timeout value: ' + this.config.timeout,\n 'We changed time format to nginx-like one',\n '(see http://nginx.org/en/docs/syntax.html)',\n 'so please update your config accordingly',\n ].join('\\n')\n );\n }\n\n // a bunch of different configurable timers\n this.maxage = parseInterval(setConfig(this.config, 'maxage', '2m'));\n // https://github.com/sindresorhus/got/blob/main/documentation/6-timeout.md\n this.timeout = {\n request: parseInterval(setConfig(this.config, 'timeout', '30s')),\n };\n debug('set timeout %s', this.timeout);\n this.max_fails = Number(setConfig(this.config, 'max_fails', this.config.max_fails ?? 2));\n this.fail_timeout = parseInterval(setConfig(this.config, 'fail_timeout', '5m'));\n this.strict_ssl = Boolean(setConfig(this.config, 'strict_ssl', true));\n this.retry = { limit: this.max_fails ?? 2 };\n }\n\n private getAgent() {\n if (!this.agent) {\n // TODO: the config.ca (certificates) is not yet injected here\n const agentInstance = new CustomAgents(this.config.url, this.proxy, this.agent_options);\n return agentInstance.get();\n } else {\n return this.agent;\n }\n }\n\n public getHeaders(headers = {}): gotHeaders {\n const accept = HEADERS.ACCEPT;\n const acceptEncoding = HEADERS.ACCEPT_ENCODING;\n const userAgent = HEADERS.USER_AGENT;\n\n headers[accept] = headers[accept] || contentTypeAccept;\n headers[acceptEncoding] = headers[acceptEncoding] || 'gzip';\n // registry.npmjs.org will only return search result if user-agent include string 'npm'\n headers[userAgent] = headers[userAgent] || `npm (${this.userAgent})`;\n return this.setAuthNext(headers);\n }\n\n /**\n * Validate configuration auth and assign Header authorization\n * @param {Object} headers\n * @return {Object}\n * @private\n */\n private setAuthNext(headers: gotHeaders): gotHeaders {\n const { auth } = this.config;\n if (typeof auth === 'undefined' || typeof headers[HEADERS.AUTHORIZATION] === 'string') {\n return headers;\n }\n\n if (_.isObject(auth) === false && _.isObject((auth as any).token) === false) {\n this._throwErrorAuth('Auth invalid');\n }\n\n // get NPM_TOKEN http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules\n // or get other variable export in env\n // https://github.com/verdaccio/verdaccio/releases/tag/v2.5.0\n let token: any;\n const tokenConf: any = auth;\n if (_.isNil(tokenConf.token) === false && _.isString(tokenConf.token)) {\n debug('use token from config');\n token = tokenConf.token;\n } else if (_.isNil(tokenConf.token_env) === false) {\n if (typeof tokenConf.token_env === 'string') {\n debug('use token from env %o', tokenConf.token_env);\n token = process.env[tokenConf.token_env];\n } else if (typeof tokenConf.token_env === 'boolean' && tokenConf.token_env) {\n debug('use token from env NPM_TOKEN');\n token = process.env.NPM_TOKEN;\n } else {\n this.logger.error(constants.ERROR_CODE.token_required);\n this._throwErrorAuth(constants.ERROR_CODE.token_required);\n }\n } else {\n debug('use token from env NPM_TOKEN');\n token = process.env.NPM_TOKEN;\n }\n\n if (typeof token === 'undefined') {\n this._throwErrorAuth(constants.ERROR_CODE.token_required);\n }\n\n // define type Auth allow basic and bearer\n const type = tokenConf.type || TOKEN_BASIC;\n debug('token type %o', type);\n this._setHeaderAuthorization(headers, type, token);\n\n return headers;\n }\n\n /**\n * @param {string} message\n * @throws {Error}\n * @private\n */\n private _throwErrorAuth(message: string): Error {\n this.logger.error(message);\n throw new Error(message);\n }\n\n /**\n * Assign Header authorization with type authentication\n * @param {Object} headers\n * @param {string} type\n * @param {string} token\n * @private\n */\n private _setHeaderAuthorization(headers: any, type: string, token: any): void {\n const _type: string = type.toLowerCase();\n\n if (_type !== TOKEN_BEARER.toLowerCase() && _type !== TOKEN_BASIC.toLowerCase()) {\n this._throwErrorAuth(`Auth type '${_type}' not allowed`);\n }\n\n headers[HEADERS.AUTHORIZATION] = buildToken(type, token);\n }\n\n /**\n * It will add or override specified headers from config file.\n *\n * Eg:\n *\n * uplinks:\n npmjs:\n url: https://registry.npmjs.org/\n headers:\n Accept: \"application/vnd.npm.install-v2+json; q=1.0\"\n verdaccio-staging:\n url: https://mycompany.com/npm\n headers:\n Accept: \"application/json\"\n authorization: \"Basic YourBase64EncodedCredentials==\"\n\n * @param {Object} headers\n * @private\n */\n private applyUplinkHeaders(headers: gotHeaders): gotHeaders {\n if (!this.config.headers) {\n return headers;\n }\n\n // add/override headers specified in the config\n /* eslint guard-for-in: 0 */\n for (const key in this.config.headers) {\n headers[key] = this.config.headers[key];\n }\n return headers;\n }\n\n public async getRemoteMetadata(\n name: string,\n options: Partial<ISyncUplinksOptions>\n ): Promise<[Manifest, string]> {\n if (this._ifRequestFailure()) {\n throw errorUtils.getInternalError(API_ERROR.UPLINK_OFFLINE);\n }\n\n // FUTURE: allow mix headers that comes from the client\n debug('getting metadata for package %s', name);\n let headers = this.getHeaders(options?.headers);\n headers = this.addProxyHeaders(headers, options.remoteAddress);\n headers = this.applyUplinkHeaders(headers);\n // the following headers cannot be overwritten\n if (_.isNil(options.etag) === false) {\n headers[HEADERS.NONE_MATCH] = options.etag;\n headers[HEADERS.ACCEPT] = contentTypeAccept;\n }\n const method = options.method || 'GET';\n const uri = this.config.url + `/${encode(name)}`;\n debug('set retry limit is %s', this.retry.limit);\n let response;\n let responseLength = 0;\n try {\n const retry = options?.retry ?? this.retry;\n debug('retry initial count %s', retry);\n response = await got(uri, {\n headers,\n responseType: 'json',\n method,\n agent: this.agent,\n retry,\n timeout: this.timeout,\n hooks: {\n afterResponse: [\n (afterResponse) => {\n const code = afterResponse.statusCode;\n debug('after response code is %s', code);\n if (code >= HTTP_STATUS.OK && code < HTTP_STATUS.MULTIPLE_CHOICES) {\n if (this.failed_requests >= this.max_fails) {\n this.failed_requests = 0;\n this.logger.warn(\n {\n host: this.url.host,\n },\n 'host @{host} is now online'\n );\n }\n }\n\n return afterResponse;\n },\n ],\n beforeRetry: [\n (error: RequestError, count: number) => {\n debug('retry %s count: %s', uri, count);\n this.failed_requests = count ?? 0;\n this.logger.info(\n {\n request: {\n method: method,\n url: uri,\n },\n error: error.message,\n retryCount: this.failed_requests,\n },\n \"retry @{retryCount} req: '@{request.method} @{request.url}'\"\n );\n if (this.failed_requests >= this.max_fails) {\n this.logger.warn(\n {\n host: this.url.host,\n },\n 'host @{host} is now offline'\n );\n }\n },\n ],\n },\n })\n .on('request', () => {\n this.last_request_time = Date.now();\n })\n .on<any>('response', (eventResponse) => {\n const message = \"@{!status}, req: '@{request.method} @{request.url}' (streaming)\";\n this.logger.http(\n {\n request: {\n method: method,\n url: uri,\n },\n status: _.isNull(eventResponse) === false ? eventResponse.statusCode : 'ERR',\n },\n message\n );\n })\n .on('downloadProgress', (progress) => {\n if (progress.total) {\n debug('responseLength %s', progress.total);\n responseLength = progress.total;\n }\n });\n const etag = response.headers.etag as string;\n const data = response.body;\n\n // not modified status (304) registry does not return any payload\n // it is handled as an error\n if (response?.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n throw errorUtils.getCode(HTTP_STATUS.NOT_MODIFIED, API_ERROR.NOT_MODIFIED_NO_DATA);\n }\n\n debug('uri %s success', uri);\n const message = \"@{!status}, req: '@{request.method} @{request.url}'\";\n this.logger.http(\n {\n // if error is null/false change this to undefined so it wont log\n request: { method: method, url: uri },\n status: response.statusCode,\n bytes: {\n in: options?.json ? JSON.stringify(options?.json).length : 0,\n out: responseLength || 0,\n },\n },\n message\n );\n return [data, etag];\n } catch (err: any) {\n debug('error %s on uri %s', err.code, uri);\n if (err.code === 'ERR_NON_2XX_3XX_RESPONSE') {\n const code = err.response.statusCode;\n debug('error code %s', code);\n if (code === HTTP_STATUS.NOT_FOUND) {\n throw errorUtils.getNotFound(API_ERROR.NOT_PACKAGE_UPLINK);\n }\n\n if (!(code >= HTTP_STATUS.OK && code < HTTP_STATUS.MULTIPLE_CHOICES)) {\n const error = errorUtils.getInternalError(`${API_ERROR.BAD_STATUS_CODE}: ${code}`);\n // we need this code to identify outside which status code triggered the error\n error.remoteStatus = code;\n throw error;\n }\n } else if (this._isRequestTimeout(err)) {\n debug('error code timeout');\n throw errorUtils.getServiceUnavailable(API_ERROR.SERVER_TIME_OUT);\n }\n throw err;\n }\n }\n\n // FIXME: handle stream and retry\n public fetchTarball(\n url: string,\n overrideOptions: Pick<ISyncUplinksOptions, 'remoteAddress' | 'etag' | 'retry'>\n ): any {\n debug('fetching url for %s', url);\n const options = { ...this.config, ...overrideOptions };\n let headers = this.getHeaders(options?.headers);\n headers = this.addProxyHeaders(headers, options.remoteAddress);\n headers = this.applyUplinkHeaders(headers);\n // the following headers cannot be overwritten\n if (_.isNil(options.etag) === false) {\n headers[HEADERS.NONE_MATCH] = options.etag;\n headers[HEADERS.ACCEPT] = contentTypeAccept;\n }\n const method = 'GET';\n // const uri = this.config.url + `/${encode(name)}`;\n debug('request uri for %s', url);\n\n const readStream = got\n .stream(url, {\n headers,\n method,\n agent: this.agent,\n // FIXME: this should be taken from construtor as priority\n retry: this.retry ?? options?.retry,\n timeout: this.timeout,\n })\n .on('request', () => {\n this.last_request_time = Date.now();\n });\n\n return readStream;\n }\n\n /**\n * Perform a stream search.\n * @param {*} options request options\n * @return {Stream}\n */\n public async search({ url, abort, retry }: ProxySearchParams): Promise<Stream.Readable> {\n try {\n // Incoming URL is relative ie /-/v1/search...\n const uri = new URL(url, this.url).href;\n this.logger.http(\n { uri, uplink: this.uplinkName },\n 'search request to uplink @{uplink} - @{uri}'\n );\n debug('searching on %o', uri);\n const response = got(uri, {\n signal: abort ? abort.signal : {},\n agent: this.agent,\n timeout: this.timeout,\n retry: retry ?? this.retry,\n });\n\n const res = await response.text();\n const total = JSON.parse(res).total;\n debug('number of packages found: %o', total);\n const streamSearch = new PassThrough({ objectMode: true });\n const streamResponse = Readable.from(res);\n // objects is one of the properties on the body, it ignores date and total\n streamResponse.pipe(JSONStream.parse('objects')).pipe(streamSearch, { end: true });\n return streamSearch;\n } catch (err: any) {\n debug('search error %s', err);\n if (err.response.statusCode === 409) {\n throw errorUtils.getInternalError(`bad status code ${err.response.statusCode} from uplink`);\n }\n this.logger.error(\n { errorMessage: err?.message, name: this.uplinkName },\n 'proxy uplink @{name} search error: @{errorMessage}'\n );\n throw err;\n }\n }\n\n private addProxyHeaders(headers: gotHeaders, remoteAddress?: string): gotHeaders {\n // Only submit X-Forwarded-For field if we don't have a proxy selected\n // in the config file.\n //\n // Otherwise misconfigured proxy could return 407\n if (!this.proxy) {\n headers[HEADERS.FORWARDED_FOR] =\n (headers['x-forwarded-for'] ? headers['x-forwarded-for'] + ', ' : '') + remoteAddress;\n }\n\n // always attach Via header to avoid loops, even if we're not proxying\n headers['via'] = headers['via'] ? headers['via'] + ', ' : '';\n headers['via'] += '1.1 ' + this.server_id + ' (Verdaccio)';\n\n return headers;\n }\n\n /**\n * If the request failure.\n * @return {boolean}\n * @private\n */\n private _ifRequestFailure(): boolean {\n return (\n this.failed_requests >= this.max_fails &&\n Math.abs(Date.now() - (this.last_request_time as number)) < this.fail_timeout\n );\n }\n\n /**\n * Check if the request timed out (network or http errors).\n * @param {RequestError} err\n * @return {boolean}\n */\n private _isRequestTimeout(err: RequestError): boolean {\n const code = err?.response?.statusCode;\n return (\n err.code === 'ETIMEDOUT' ||\n err.code === 'ESOCKETTIMEDOUT' ||\n err.code === 'ECONNRESET' ||\n code === HTTP_STATUS.REQUEST_TIMEOUT ||\n code === HTTP_STATUS.BAD_GATEWAY ||\n code === HTTP_STATUS.SERVICE_UNAVAILABLE ||\n code === HTTP_STATUS.GATEWAY_TIMEOUT\n );\n }\n\n /**\n * Set up a proxy.\n * @param {*} hostname\n * @param {*} config\n * @param {*} mainconfig\n * @param {*} isHTTPS\n */\n private _setupProxy(\n hostname: string,\n config: UpLinkConfLocal,\n mainconfig: Config,\n isHTTPS: boolean\n ): void {\n let noProxyList;\n const proxy_key: string = isHTTPS ? 'https_proxy' : 'http_proxy';\n debug('looking for %o', proxy_key);\n\n // get http_proxy and no_proxy configs\n if (proxy_key in config) {\n this.proxy = config[proxy_key];\n debug('found %o in uplink config', this.proxy);\n } else if (proxy_key in mainconfig) {\n this.proxy = mainconfig[proxy_key];\n debug('found %o in main config', this.proxy);\n }\n if ('no_proxy' in config) {\n noProxyList = config.no_proxy;\n } else if ('no_proxy' in mainconfig) {\n noProxyList = mainconfig.no_proxy;\n }\n\n // use wget-like algorithm to determine if proxy shouldn't be used\n if (hostname[0] !== '.') {\n hostname = '.' + hostname;\n }\n\n if (_.isString(noProxyList) && noProxyList.length) {\n noProxyList = noProxyList.split(',');\n }\n\n if (_.isArray(noProxyList)) {\n for (let i = 0; i < noProxyList.length; i++) {\n let noProxyItem = noProxyList[i];\n if (noProxyItem[0] !== '.') {\n noProxyItem = '.' + noProxyItem;\n }\n if (hostname.endsWith(noProxyItem)) {\n if (this.proxy) {\n debug('not using proxy, excluded by @{rule}', noProxyItem);\n this.logger.debug(\n { url: this.url.href, rule: noProxyItem },\n 'not using proxy for @{url}, excluded by @{rule} rule'\n );\n this.proxy = undefined;\n }\n break;\n }\n }\n }\n\n // validate proxy protocol matches the proxy_key type\n if (this.proxy) {\n const proxyUrl = new URL(this.proxy);\n const expectedProtocol = isHTTPS ? 'https:' : 'http:';\n if (proxyUrl.protocol !== expectedProtocol) {\n this.logger.error(\n { proxy: this.proxy, expectedProtocol },\n `invalid protocol for ${proxy_key} - must be ${expectedProtocol}`\n );\n this.proxy = undefined;\n return;\n }\n }\n\n if (typeof this.proxy === 'string') {\n debug('using proxy @{proxy} for @{url}', this.proxy, this.url.href);\n this.logger.debug(\n { url: this.url.href, proxy: this.proxy },\n 'using proxy @{proxy} for @{url}'\n );\n }\n }\n}\n\nexport { ProxyStorage };\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAQA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAEA,IAAAO,KAAA,GAAAP,OAAA;AAWA,IAAAQ,MAAA,GAAAR,OAAA;AAEA,IAAAS,MAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAA8C,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAA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,10 @@ var _index = require("./index");
11
11
  */
12
12
  function setupUpLinks(config, logger) {
13
13
  const uplinks = {};
14
- for (const uplinkName in config.uplinks) {
15
- if (Object.prototype.hasOwnProperty.call(config.uplinks, uplinkName)) {
16
- // instance for each up-link definition
17
- const proxy = new _index.ProxyStorage(config.uplinks[uplinkName], config, logger);
18
- // TODO: review this can be inside ProxyStorage
19
- proxy.upname = uplinkName;
20
- uplinks[uplinkName] = proxy;
21
- }
14
+ for (const uplinkName of Object.keys(config.uplinks)) {
15
+ // instance for each up-link definition
16
+ const proxy = new _index.ProxyStorage(uplinkName, config.uplinks[uplinkName], config, logger);
17
+ uplinks[uplinkName] = proxy;
22
18
  }
23
19
  return uplinks;
24
20
  }
@@ -32,7 +28,7 @@ function updateVersionsHiddenUpLinkNext(manifest, upLink) {
32
28
  }
33
29
  for (const version of versionsList) {
34
30
  // holds a "hidden" value to be used by the package storage.
35
- versions[version][Symbol.for('__verdaccio_uplink')] = upLink.upname;
31
+ versions[version][Symbol.for('__verdaccio_uplink')] = upLink.uplinkName;
36
32
  }
37
33
  return {
38
34
  ...manifest,
@@ -1 +1 @@
1
- {"version":3,"file":"uplink-util.js","names":["_index","require","setupUpLinks","config","logger","uplinks","uplinkName","Object","prototype","hasOwnProperty","call","proxy","ProxyStorage","upname","updateVersionsHiddenUpLinkNext","manifest","upLink","versions","versionsList","keys","length","version","Symbol","for"],"sources":["../src/uplink-util.ts"],"sourcesContent":["import { Config, Logger, Manifest } from '@verdaccio/types';\n\nimport { IProxy, ProxyStorage } from './index';\n\nexport interface ProxyInstanceList {\n [key: string]: IProxy;\n}\n\n/**\n * Set up uplinks for each proxy configuration.\n */\nexport function setupUpLinks(config: Config, logger: Logger): ProxyInstanceList {\n const uplinks: ProxyInstanceList = {};\n\n for (const uplinkName in config.uplinks) {\n if (Object.prototype.hasOwnProperty.call(config.uplinks, uplinkName)) {\n // instance for each up-link definition\n const proxy: IProxy = new ProxyStorage(config.uplinks[uplinkName], config, logger);\n // TODO: review this can be inside ProxyStorage\n proxy.upname = uplinkName;\n\n uplinks[uplinkName] = proxy;\n }\n }\n\n return uplinks;\n}\n\nexport function updateVersionsHiddenUpLinkNext(manifest: Manifest, upLink: IProxy): Manifest {\n const { versions } = manifest;\n const versionsList = Object.keys(versions);\n if (versionsList.length === 0) {\n return manifest;\n }\n\n for (const version of versionsList) {\n // holds a \"hidden\" value to be used by the package storage.\n versions[version][Symbol.for('__verdaccio_uplink')] = upLink.upname;\n }\n\n return { ...manifest, versions };\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACO,SAASC,YAAYA,CAACC,MAAc,EAAEC,MAAc,EAAqB;EAC9E,MAAMC,OAA0B,GAAG,CAAC,CAAC;EAErC,KAAK,MAAMC,UAAU,IAAIH,MAAM,CAACE,OAAO,EAAE;IACvC,IAAIE,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,MAAM,CAACE,OAAO,EAAEC,UAAU,CAAC,EAAE;MACpE;MACA,MAAMK,KAAa,GAAG,IAAIC,mBAAY,CAACT,MAAM,CAACE,OAAO,CAACC,UAAU,CAAC,EAAEH,MAAM,EAAEC,MAAM,CAAC;MAClF;MACAO,KAAK,CAACE,MAAM,GAAGP,UAAU;MAEzBD,OAAO,CAACC,UAAU,CAAC,GAAGK,KAAK;IAC7B;EACF;EAEA,OAAON,OAAO;AAChB;AAEO,SAASS,8BAA8BA,CAACC,QAAkB,EAAEC,MAAc,EAAY;EAC3F,MAAM;IAAEC;EAAS,CAAC,GAAGF,QAAQ;EAC7B,MAAMG,YAAY,GAAGX,MAAM,CAACY,IAAI,CAACF,QAAQ,CAAC;EAC1C,IAAIC,YAAY,CAACE,MAAM,KAAK,CAAC,EAAE;IAC7B,OAAOL,QAAQ;EACjB;EAEA,KAAK,MAAMM,OAAO,IAAIH,YAAY,EAAE;IAClC;IACAD,QAAQ,CAACI,OAAO,CAAC,CAACC,MAAM,CAACC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAGP,MAAM,CAACH,MAAM;EACrE;EAEA,OAAO;IAAE,GAAGE,QAAQ;IAAEE;EAAS,CAAC;AAClC","ignoreList":[]}
1
+ {"version":3,"file":"uplink-util.js","names":["_index","require","setupUpLinks","config","logger","uplinks","uplinkName","Object","keys","proxy","ProxyStorage","updateVersionsHiddenUpLinkNext","manifest","upLink","versions","versionsList","length","version","Symbol","for"],"sources":["../src/uplink-util.ts"],"sourcesContent":["import { Config, Logger, Manifest } from '@verdaccio/types';\n\nimport { IProxy, ProxyStorage } from './index';\n\nexport interface ProxyInstanceList {\n [key: string]: IProxy;\n}\n\n/**\n * Set up uplinks for each proxy configuration.\n */\nexport function setupUpLinks(config: Config, logger: Logger): ProxyInstanceList {\n const uplinks: ProxyInstanceList = {};\n\n for (const uplinkName of Object.keys(config.uplinks)) {\n // instance for each up-link definition\n const proxy: IProxy = new ProxyStorage(uplinkName, config.uplinks[uplinkName], config, logger);\n uplinks[uplinkName] = proxy;\n }\n\n return uplinks;\n}\n\nexport function updateVersionsHiddenUpLinkNext(manifest: Manifest, upLink: IProxy): Manifest {\n const { versions } = manifest;\n const versionsList = Object.keys(versions);\n if (versionsList.length === 0) {\n return manifest;\n }\n\n for (const version of versionsList) {\n // holds a \"hidden\" value to be used by the package storage.\n versions[version][Symbol.for('__verdaccio_uplink')] = upLink.uplinkName;\n }\n\n return { ...manifest, versions };\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACO,SAASC,YAAYA,CAACC,MAAc,EAAEC,MAAc,EAAqB;EAC9E,MAAMC,OAA0B,GAAG,CAAC,CAAC;EAErC,KAAK,MAAMC,UAAU,IAAIC,MAAM,CAACC,IAAI,CAACL,MAAM,CAACE,OAAO,CAAC,EAAE;IACpD;IACA,MAAMI,KAAa,GAAG,IAAIC,mBAAY,CAACJ,UAAU,EAAEH,MAAM,CAACE,OAAO,CAACC,UAAU,CAAC,EAAEH,MAAM,EAAEC,MAAM,CAAC;IAC9FC,OAAO,CAACC,UAAU,CAAC,GAAGG,KAAK;EAC7B;EAEA,OAAOJ,OAAO;AAChB;AAEO,SAASM,8BAA8BA,CAACC,QAAkB,EAAEC,MAAc,EAAY;EAC3F,MAAM;IAAEC;EAAS,CAAC,GAAGF,QAAQ;EAC7B,MAAMG,YAAY,GAAGR,MAAM,CAACC,IAAI,CAACM,QAAQ,CAAC;EAC1C,IAAIC,YAAY,CAACC,MAAM,KAAK,CAAC,EAAE;IAC7B,OAAOJ,QAAQ;EACjB;EAEA,KAAK,MAAMK,OAAO,IAAIF,YAAY,EAAE;IAClC;IACAD,QAAQ,CAACG,OAAO,CAAC,CAACC,MAAM,CAACC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAGN,MAAM,CAACP,UAAU;EACzE;EAEA,OAAO;IAAE,GAAGM,QAAQ;IAAEE;EAAS,CAAC;AAClC","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@verdaccio/proxy",
3
- "version": "8.0.0-next-8.12",
4
- "description": "verdaccio proxy fetcher",
3
+ "version": "8.0.0-next-8.13",
4
+ "description": "Verdaccio Proxy Fetcher",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
7
7
  "author": {
@@ -10,7 +10,11 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "https",
13
- "url": "https://github.com/verdaccio/verdaccio"
13
+ "url": "https://github.com/verdaccio/verdaccio",
14
+ "directory": "packages/proxy"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/verdaccio/verdaccio/issues"
14
18
  },
15
19
  "license": "MIT",
16
20
  "homepage": "https://verdaccio.org",
@@ -29,9 +33,9 @@
29
33
  "node": ">=18"
30
34
  },
31
35
  "dependencies": {
32
- "@verdaccio/config": "8.0.0-next-8.12",
33
- "@verdaccio/core": "8.0.0-next-8.12",
34
- "@verdaccio/utils": "8.1.0-next-8.12",
36
+ "@verdaccio/config": "8.0.0-next-8.13",
37
+ "@verdaccio/core": "8.0.0-next-8.13",
38
+ "@verdaccio/utils": "8.1.0-next-8.13",
35
39
  "JSONStream": "1.3.5",
36
40
  "debug": "4.4.0",
37
41
  "got-cjs": "12.5.4",
@@ -39,8 +43,8 @@
39
43
  "lodash": "4.17.21"
40
44
  },
41
45
  "devDependencies": {
42
- "@verdaccio/logger": "8.0.0-next-8.12",
43
- "@verdaccio/types": "13.0.0-next-8.3",
46
+ "@verdaccio/logger": "8.0.0-next-8.13",
47
+ "@verdaccio/types": "13.0.0-next-8.4",
44
48
  "get-stream": "^6.0.1",
45
49
  "node-mocks-http": "1.14.1",
46
50
  "p-cancelable": "2.1.1",
package/.babelrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../.babelrc"
3
- }