@verdaccio/proxy 6.0.0-6-next.29 → 6.0.0-6-next.31

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @verdaccio/proxy
2
2
 
3
+ ## 6.0.0-6-next.31
4
+
5
+ ### Patch Changes
6
+
7
+ - @verdaccio/core@6.0.0-6-next.53
8
+ - @verdaccio/logger@6.0.0-6-next.21
9
+ - @verdaccio/local-storage@11.0.0-6-next.23
10
+ - @verdaccio/config@6.0.0-6-next.53
11
+ - @verdaccio/utils@6.0.0-6-next.21
12
+
13
+ ## 6.0.0-6-next.30
14
+
15
+ ### Patch Changes
16
+
17
+ - @verdaccio/core@6.0.0-6-next.52
18
+ - @verdaccio/config@6.0.0-6-next.52
19
+ - @verdaccio/logger@6.0.0-6-next.20
20
+ - @verdaccio/local-storage@11.0.0-6-next.22
21
+ - @verdaccio/utils@6.0.0-6-next.20
22
+
3
23
  ## 6.0.0-6-next.29
4
24
 
5
25
  ### Patch Changes
package/build/agent.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  import { Agents } from 'got';
4
4
  import { AgentOptions as HttpAgentOptions } from 'http';
5
5
  import { AgentOptions as HttpsAgentOptions } from 'https';
6
- export declare type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions;
6
+ export type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions;
7
7
  declare class CustomAgents {
8
8
  private url;
9
9
  private proxy;
package/build/agent.js CHANGED
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _hpagent = require("hpagent");
9
-
10
8
  var _http = require("http");
11
-
12
9
  var _https = require("https");
13
-
14
10
  var _url = require("url");
15
-
16
11
  class CustomAgents {
17
12
  constructor(url, proxy, agentOptions) {
18
13
  this.proxy = proxy;
@@ -23,20 +18,17 @@ class CustomAgents {
23
18
  } = this.getParsedUrl();
24
19
  this.agent = this.getAgent(protocol);
25
20
  }
26
-
27
21
  get() {
28
22
  return this.agent;
29
23
  }
30
-
31
24
  getAgent(protocol) {
32
25
  const isHTTPS = protocol === 'https:';
33
-
34
26
  if (this.proxy) {
35
27
  const options = {
36
28
  proxy: this.proxy,
37
29
  ...this.agentOptions
38
- }; // use hpagent
39
-
30
+ };
31
+ // use hpagent
40
32
  return isHTTPS ? {
41
33
  https: new _hpagent.HttpsProxyAgent(options)
42
34
  } : {
@@ -51,13 +43,10 @@ class CustomAgents {
51
43
  };
52
44
  }
53
45
  }
54
-
55
46
  getParsedUrl() {
56
47
  return this.proxy ? new _url.URL(this.proxy) : new _url.URL(this.url);
57
48
  }
58
-
59
49
  }
60
-
61
50
  var _default = CustomAgents;
62
51
  exports.default = _default;
63
52
  //# sourceMappingURL=agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","names":["CustomAgents","constructor","url","proxy","agentOptions","protocol","getParsedUrl","agent","getAgent","get","isHTTPS","options","https","HttpsProxyAgent","http","HttpProxyAgent","HttpsAgent","HttpAgent","URL"],"sources":["../src/agent.ts"],"sourcesContent":["import { Agents } from 'got';\nimport { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';\nimport { Agent as HttpAgent, AgentOptions as HttpAgentOptions } from 'http';\nimport { Agent as HttpsAgent, AgentOptions as HttpsAgentOptions } from 'https';\nimport { URL } from 'url';\n\nexport type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions;\n\nclass CustomAgents {\n private url: string;\n private proxy: string | undefined;\n private agentOptions: HttpAgentOptions | HttpsAgentOptions;\n private agent: Agents;\n public constructor(\n url: string,\n proxy: string | undefined,\n agentOptions: HttpAgentOptions | HttpsAgentOptions\n ) {\n this.proxy = proxy;\n this.url = url;\n this.agentOptions = agentOptions;\n const { protocol } = this.getParsedUrl();\n this.agent = this.getAgent(protocol);\n }\n\n public get() {\n return this.agent;\n }\n\n private getAgent(protocol: string): Agents {\n const isHTTPS = protocol === 'https:';\n if (this.proxy) {\n const options = {\n proxy: this.proxy,\n ...this.agentOptions,\n };\n // use hpagent\n return isHTTPS\n ? { https: new HttpsProxyAgent(options) }\n : { http: new HttpProxyAgent(options) };\n } else {\n // use native http/https agent\n return isHTTPS\n ? { https: new HttpsAgent(this.agentOptions) }\n : { http: new HttpAgent(this.agentOptions) };\n }\n }\n\n private getParsedUrl() {\n return this.proxy ? new URL(this.proxy) : new URL(this.url);\n }\n}\n\nexport default CustomAgents;\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAIA,MAAMA,YAAN,CAAmB;EAKVC,WAAW,CAChBC,GADgB,EAEhBC,KAFgB,EAGhBC,YAHgB,EAIhB;IACA,KAAKD,KAAL,GAAaA,KAAb;IACA,KAAKD,GAAL,GAAWA,GAAX;IACA,KAAKE,YAAL,GAAoBA,YAApB;IACA,MAAM;MAAEC;IAAF,IAAe,KAAKC,YAAL,EAArB;IACA,KAAKC,KAAL,GAAa,KAAKC,QAAL,CAAcH,QAAd,CAAb;EACD;;EAEMI,GAAG,GAAG;IACX,OAAO,KAAKF,KAAZ;EACD;;EAEOC,QAAQ,CAACH,QAAD,EAA2B;IACzC,MAAMK,OAAO,GAAGL,QAAQ,KAAK,QAA7B;;IACA,IAAI,KAAKF,KAAT,EAAgB;MACd,MAAMQ,OAAO,GAAG;QACdR,KAAK,EAAE,KAAKA,KADE;QAEd,GAAG,KAAKC;MAFM,CAAhB,CADc,CAKd;;MACA,OAAOM,OAAO,GACV;QAAEE,KAAK,EAAE,IAAIC,wBAAJ,CAAoBF,OAApB;MAAT,CADU,GAEV;QAAEG,IAAI,EAAE,IAAIC,uBAAJ,CAAmBJ,OAAnB;MAAR,CAFJ;IAGD,CATD,MASO;MACL;MACA,OAAOD,OAAO,GACV;QAAEE,KAAK,EAAE,IAAII,YAAJ,CAAe,KAAKZ,YAApB;MAAT,CADU,GAEV;QAAEU,IAAI,EAAE,IAAIG,WAAJ,CAAc,KAAKb,YAAnB;MAAR,CAFJ;IAGD;EACF;;EAEOE,YAAY,GAAG;IACrB,OAAO,KAAKH,KAAL,GAAa,IAAIe,QAAJ,CAAQ,KAAKf,KAAb,CAAb,GAAmC,IAAIe,QAAJ,CAAQ,KAAKhB,GAAb,CAA1C;EACD;;AA1CgB;;eA6CJF,Y"}
1
+ {"version":3,"file":"agent.js","names":["CustomAgents","constructor","url","proxy","agentOptions","protocol","getParsedUrl","agent","getAgent","get","isHTTPS","options","https","HttpsProxyAgent","http","HttpProxyAgent","HttpsAgent","HttpAgent","URL"],"sources":["../src/agent.ts"],"sourcesContent":["import { Agents } from 'got';\nimport { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';\nimport { Agent as HttpAgent, AgentOptions as HttpAgentOptions } from 'http';\nimport { Agent as HttpsAgent, AgentOptions as HttpsAgentOptions } from 'https';\nimport { URL } from 'url';\n\nexport type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions;\n\nclass CustomAgents {\n private url: string;\n private proxy: string | undefined;\n private agentOptions: HttpAgentOptions | HttpsAgentOptions;\n private agent: Agents;\n public constructor(\n url: string,\n proxy: string | undefined,\n agentOptions: HttpAgentOptions | HttpsAgentOptions\n ) {\n this.proxy = proxy;\n this.url = url;\n this.agentOptions = agentOptions;\n const { protocol } = this.getParsedUrl();\n this.agent = this.getAgent(protocol);\n }\n\n public get() {\n return this.agent;\n }\n\n private getAgent(protocol: string): Agents {\n const isHTTPS = protocol === 'https:';\n if (this.proxy) {\n const options = {\n proxy: this.proxy,\n ...this.agentOptions,\n };\n // use hpagent\n return isHTTPS\n ? { https: new HttpsProxyAgent(options) }\n : { http: new HttpProxyAgent(options) };\n } else {\n // use native http/https agent\n return isHTTPS\n ? { https: new HttpsAgent(this.agentOptions) }\n : { http: new HttpAgent(this.agentOptions) };\n }\n }\n\n private getParsedUrl() {\n return this.proxy ? new URL(this.proxy) : new URL(this.url);\n }\n}\n\nexport default CustomAgents;\n"],"mappings":";;;;;;AACA;AACA;A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6
-
7
6
  var _proxy = require("./proxy");
8
-
9
7
  Object.keys(_proxy).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _proxy[key]) return;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './proxy';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './proxy';\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -15,31 +15,27 @@ const parseIntervalTable = {
15
15
  M: 30 * 86400000,
16
16
  y: 365 * 86400000
17
17
  };
18
+
18
19
  /**
19
20
  * Parse an internal string to number
20
21
  * @param {*} interval
21
22
  * @return {Number}
22
23
  * @deprecated
23
24
  */
24
-
25
25
  function parseInterval(interval) {
26
26
  if (typeof interval === 'number') {
27
27
  return interval * 1000;
28
28
  }
29
-
30
29
  let result = 0;
31
30
  let last_suffix = Infinity;
32
31
  interval.split(/\s+/).forEach(function (x) {
33
32
  if (!x) {
34
33
  return;
35
34
  }
36
-
37
35
  const m = x.match(/^((0|[1-9][0-9]*)(\.[0-9]+)?)(ms|s|m|h|d|w|M|y|)$/);
38
-
39
36
  if (!m || parseIntervalTable[m[4]] >= last_suffix || m[4] === '' && last_suffix !== Infinity) {
40
37
  throw Error('invalid interval: ' + interval);
41
38
  }
42
-
43
39
  last_suffix = parseIntervalTable[m[4]];
44
40
  result += Number(m[1]) * parseIntervalTable[m[4]];
45
41
  });
@@ -1 +1 @@
1
- {"version":3,"file":"proxy-utils.js","names":["parseIntervalTable","ms","s","m","h","d","w","M","y","parseInterval","interval","result","last_suffix","Infinity","split","forEach","x","match","Error","Number"],"sources":["../src/proxy-utils.ts"],"sourcesContent":["const parseIntervalTable = {\n '': 1000,\n ms: 1,\n s: 1000,\n m: 60 * 1000,\n h: 60 * 60 * 1000,\n d: 86400000,\n w: 7 * 86400000,\n M: 30 * 86400000,\n y: 365 * 86400000,\n};\n\n/**\n * Parse an internal string to number\n * @param {*} interval\n * @return {Number}\n * @deprecated\n */\nexport function parseInterval(interval: any): number {\n if (typeof interval === 'number') {\n return interval * 1000;\n }\n let result = 0;\n let last_suffix = Infinity;\n interval.split(/\\s+/).forEach(function (x): void {\n if (!x) {\n return;\n }\n const m = x.match(/^((0|[1-9][0-9]*)(\\.[0-9]+)?)(ms|s|m|h|d|w|M|y|)$/);\n if (\n !m ||\n parseIntervalTable[m[4]] >= last_suffix ||\n (m[4] === '' && last_suffix !== Infinity)\n ) {\n throw Error('invalid interval: ' + interval);\n }\n last_suffix = parseIntervalTable[m[4]];\n result += Number(m[1]) * parseIntervalTable[m[4]];\n });\n return result;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,kBAAkB,GAAG;EACzB,IAAI,IADqB;EAEzBC,EAAE,EAAE,CAFqB;EAGzBC,CAAC,EAAE,IAHsB;EAIzBC,CAAC,EAAE,KAAK,IAJiB;EAKzBC,CAAC,EAAE,KAAK,EAAL,GAAU,IALY;EAMzBC,CAAC,EAAE,QANsB;EAOzBC,CAAC,EAAE,IAAI,QAPkB;EAQzBC,CAAC,EAAE,KAAK,QARiB;EASzBC,CAAC,EAAE,MAAM;AATgB,CAA3B;AAYA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,aAAT,CAAuBC,QAAvB,EAA8C;EACnD,IAAI,OAAOA,QAAP,KAAoB,QAAxB,EAAkC;IAChC,OAAOA,QAAQ,GAAG,IAAlB;EACD;;EACD,IAAIC,MAAM,GAAG,CAAb;EACA,IAAIC,WAAW,GAAGC,QAAlB;EACAH,QAAQ,CAACI,KAAT,CAAe,KAAf,EAAsBC,OAAtB,CAA8B,UAAUC,CAAV,EAAmB;IAC/C,IAAI,CAACA,CAAL,EAAQ;MACN;IACD;;IACD,MAAMb,CAAC,GAAGa,CAAC,CAACC,KAAF,CAAQ,mDAAR,CAAV;;IACA,IACE,CAACd,CAAD,IACAH,kBAAkB,CAACG,CAAC,CAAC,CAAD,CAAF,CAAlB,IAA4BS,WAD5B,IAECT,CAAC,CAAC,CAAD,CAAD,KAAS,EAAT,IAAeS,WAAW,KAAKC,QAHlC,EAIE;MACA,MAAMK,KAAK,CAAC,uBAAuBR,QAAxB,CAAX;IACD;;IACDE,WAAW,GAAGZ,kBAAkB,CAACG,CAAC,CAAC,CAAD,CAAF,CAAhC;IACAQ,MAAM,IAAIQ,MAAM,CAAChB,CAAC,CAAC,CAAD,CAAF,CAAN,GAAeH,kBAAkB,CAACG,CAAC,CAAC,CAAD,CAAF,CAA3C;EACD,CAdD;EAeA,OAAOQ,MAAP;AACD"}
1
+ {"version":3,"file":"proxy-utils.js","names":["parseIntervalTable","ms","s","m","h","d","w","M","y","parseInterval","interval","result","last_suffix","Infinity","split","forEach","x","match","Error","Number"],"sources":["../src/proxy-utils.ts"],"sourcesContent":["const parseIntervalTable = {\n '': 1000,\n ms: 1,\n s: 1000,\n m: 60 * 1000,\n h: 60 * 60 * 1000,\n d: 86400000,\n w: 7 * 86400000,\n M: 30 * 86400000,\n y: 365 * 86400000,\n};\n\n/**\n * Parse an internal string to number\n * @param {*} interval\n * @return {Number}\n * @deprecated\n */\nexport function parseInterval(interval: any): number {\n if (typeof interval === 'number') {\n return interval * 1000;\n }\n let result = 0;\n let last_suffix = Infinity;\n interval.split(/\\s+/).forEach(function (x): void {\n if (!x) {\n return;\n }\n const m = x.match(/^((0|[1-9][0-9]*)(\\.[0-9]+)?)(ms|s|m|h|d|w|M|y|)$/);\n if (\n !m ||\n parseIntervalTable[m[4]] >= last_suffix ||\n (m[4] === '' && last_suffix !== Infinity)\n ) {\n throw Error('invalid interval: ' + interval);\n }\n last_suffix = parseIntervalTable[m[4]];\n result += Number(m[1]) * parseIntervalTable[m[4]];\n });\n return result;\n}\n"],"mappings":";;;;;;AA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accio/core';
9
9
  import { Manifest } from '@verdaccio/types';
10
10
  import { Config, Logger, UpLinkConf } from '@verdaccio/types';
11
11
  import { AgentOptionsConf } from './agent';
12
- export declare type UpLinkConfLocal = UpLinkConf & {
12
+ export type UpLinkConfLocal = UpLinkConf & {
13
13
  no_proxy?: string;
14
14
  };
15
15
  export interface ProxyList {
16
16
  [key: string]: IProxy;
17
17
  }
18
- export declare type ProxySearchParams = {
18
+ export type ProxySearchParams = {
19
19
  headers?: Headers;
20
20
  url: string;
21
21
  query?: searchUtils.SearchQuery;
package/build/proxy.js CHANGED
@@ -4,49 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ProxyStorage = void 0;
7
-
8
7
  var _JSONStream = _interopRequireDefault(require("JSONStream"));
9
-
10
8
  var _debug = _interopRequireDefault(require("debug"));
11
-
12
9
  var _got = _interopRequireDefault(require("got"));
13
-
14
10
  var _lodash = _interopRequireDefault(require("lodash"));
15
-
16
11
  var _stream = require("stream");
17
-
18
12
  var _undici = require("undici");
19
-
20
13
  var _url = require("url");
21
-
22
14
  var _core = require("@verdaccio/core");
23
-
24
15
  var _utils = require("@verdaccio/utils");
25
-
26
16
  var _agent = _interopRequireDefault(require("./agent"));
27
-
28
17
  var _proxyUtils = require("./proxy-utils");
29
-
30
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
19
  const LoggerApi = require('@verdaccio/logger');
33
-
34
20
  const debug = (0, _debug.default)('verdaccio:proxy');
35
-
36
21
  const encode = function (thing) {
37
22
  return encodeURIComponent(thing).replace(/^%40/, '@');
38
23
  };
39
-
40
24
  const jsonContentType = _core.HEADERS.JSON;
41
25
  const contentTypeAccept = `${jsonContentType};`;
26
+
42
27
  /**
43
28
  * Just a helper (`config[key] || default` doesn't work because of zeroes)
44
29
  */
45
-
46
30
  const setConfig = (config, key, def) => {
47
31
  return _lodash.default.isNil(config[key]) === false ? config[key] : def;
48
32
  };
49
-
50
33
  /**
51
34
  * Implements Storage interface
52
35
  * (same for storage.js, local-storage.js, up-storage.js)
@@ -54,7 +37,9 @@ const setConfig = (config, key, def) => {
54
37
  class ProxyStorage {
55
38
  // FIXME: upname is assigned to each instance
56
39
  // @ts-ignore
40
+
57
41
  // @ts-ignore
42
+
58
43
  constructor(config, mainConfig, agent) {
59
44
  this.config = config;
60
45
  this.failed_requests = 0;
@@ -71,19 +56,16 @@ class ProxyStorage {
71
56
  });
72
57
  this.url = new _url.URL(this.config.url);
73
58
  const isHTTPS = this.url.protocol === 'https:';
74
-
75
59
  this._setupProxy(this.url.hostname, config, mainConfig, isHTTPS);
76
-
77
60
  this.agent = agent ?? this.getAgent();
78
61
  this.config.url = this.config.url.replace(/\/$/, '');
79
-
80
62
  if (this.config.timeout && Number(this.config.timeout) >= 1000) {
81
63
  this.logger.warn(['Too big timeout value: ' + this.config.timeout, 'We changed time format to nginx-like one', '(see http://nginx.org/en/docs/syntax.html)', 'so please update your config accordingly'].join('\n'));
82
- } // a bunch of different configurable timers
83
-
84
-
85
- this.maxage = (0, _proxyUtils.parseInterval)(setConfig(this.config, 'maxage', '2m')); // https://github.com/sindresorhus/got/blob/main/documentation/6-timeout.md
64
+ }
86
65
 
66
+ // a bunch of different configurable timers
67
+ this.maxage = (0, _proxyUtils.parseInterval)(setConfig(this.config, 'maxage', '2m'));
68
+ // https://github.com/sindresorhus/got/blob/main/documentation/6-timeout.md
87
69
  this.timeout = (0, _proxyUtils.parseInterval)(setConfig(this.config, 'timeout', '30s'));
88
70
  this.max_fails = Number(setConfig(this.config, 'max_fails', this.config.max_fails ?? 2));
89
71
  this.fail_timeout = (0, _proxyUtils.parseInterval)(setConfig(this.config, 'fail_timeout', '5m'));
@@ -92,7 +74,6 @@ class ProxyStorage {
92
74
  limit: this.max_fails ?? 2
93
75
  };
94
76
  }
95
-
96
77
  getAgent() {
97
78
  if (!this.agent) {
98
79
  // TODO: the config.ca (certificates) is not yet injected here
@@ -102,44 +83,39 @@ class ProxyStorage {
102
83
  return this.agent;
103
84
  }
104
85
  }
105
-
106
86
  getHeadersNext(headers = {}) {
107
87
  const accept = _core.HEADERS.ACCEPT;
108
88
  const acceptEncoding = _core.HEADERS.ACCEPT_ENCODING;
109
89
  const userAgent = _core.HEADERS.USER_AGENT;
110
90
  headers[accept] = headers[accept] || contentTypeAccept;
111
- headers[acceptEncoding] = headers[acceptEncoding] || 'gzip'; // registry.npmjs.org will only return search result if user-agent include string 'npm'
112
-
91
+ headers[acceptEncoding] = headers[acceptEncoding] || 'gzip';
92
+ // registry.npmjs.org will only return search result if user-agent include string 'npm'
113
93
  headers[userAgent] = headers[userAgent] || `npm (${this.userAgent})`;
114
94
  return this.setAuthNext(headers);
115
95
  }
96
+
116
97
  /**
117
98
  * Validate configuration auth and assign Header authorization
118
99
  * @param {Object} headers
119
100
  * @return {Object}
120
101
  * @private
121
102
  */
122
-
123
-
124
103
  setAuthNext(headers) {
125
104
  const {
126
105
  auth
127
106
  } = this.config;
128
-
129
107
  if (typeof auth === 'undefined' || typeof headers[_core.HEADERS.AUTHORIZATION] === 'string') {
130
108
  return headers;
131
109
  }
132
-
133
110
  if (_lodash.default.isObject(auth) === false && _lodash.default.isObject(auth.token) === false) {
134
111
  this._throwErrorAuth('Auth invalid');
135
- } // get NPM_TOKEN http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
112
+ }
113
+
114
+ // get NPM_TOKEN http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
136
115
  // or get other variable export in env
137
116
  // https://github.com/verdaccio/verdaccio/releases/tag/v2.5.0
138
-
139
-
140
117
  let token;
141
118
  const tokenConf = auth;
142
-
143
119
  if (_lodash.default.isNil(tokenConf.token) === false && _lodash.default.isString(tokenConf.token)) {
144
120
  token = tokenConf.token;
145
121
  } else if (_lodash.default.isNil(tokenConf.token_env) === false) {
@@ -149,35 +125,31 @@ class ProxyStorage {
149
125
  token = process.env.NPM_TOKEN;
150
126
  } else {
151
127
  this.logger.error(_core.constants.ERROR_CODE.token_required);
152
-
153
128
  this._throwErrorAuth(_core.constants.ERROR_CODE.token_required);
154
129
  }
155
130
  } else {
156
131
  token = process.env.NPM_TOKEN;
157
132
  }
158
-
159
133
  if (typeof token === 'undefined') {
160
134
  this._throwErrorAuth(_core.constants.ERROR_CODE.token_required);
161
- } // define type Auth allow basic and bearer
162
-
135
+ }
163
136
 
137
+ // define type Auth allow basic and bearer
164
138
  const type = tokenConf.type || _core.TOKEN_BASIC;
165
-
166
139
  this._setHeaderAuthorization(headers, type, token);
167
-
168
140
  return headers;
169
141
  }
142
+
170
143
  /**
171
144
  * @param {string} message
172
145
  * @throws {Error}
173
146
  * @private
174
147
  */
175
-
176
-
177
148
  _throwErrorAuth(message) {
178
149
  this.logger.error(message);
179
150
  throw new Error(message);
180
151
  }
152
+
181
153
  /**
182
154
  * Assign Header authorization with type authentication
183
155
  * @param {Object} headers
@@ -185,18 +157,15 @@ class ProxyStorage {
185
157
  * @param {string} token
186
158
  * @private
187
159
  */
188
-
189
-
190
160
  _setHeaderAuthorization(headers, type, token) {
191
161
  const _type = type.toLowerCase();
192
-
193
162
  if (_type !== _core.TOKEN_BEARER.toLowerCase() && _type !== _core.TOKEN_BASIC.toLowerCase()) {
194
163
  this._throwErrorAuth(`Auth type '${_type}' not allowed`);
195
164
  }
196
-
197
165
  type = _lodash.default.upperFirst(type);
198
166
  headers[_core.HEADERS.AUTHORIZATION] = (0, _utils.buildToken)(type, token);
199
167
  }
168
+
200
169
  /**
201
170
  * It will add or override specified headers from config file.
202
171
  *
@@ -216,61 +185,51 @@ class ProxyStorage {
216
185
  * @private
217
186
  * @deprecated use applyUplinkHeaders
218
187
  */
219
-
220
-
221
188
  _overrideWithUpLinkConfLocaligHeaders(headers) {
222
189
  if (!this.config.headers) {
223
190
  return headers;
224
- } // add/override headers specified in the config
191
+ }
225
192
 
193
+ // add/override headers specified in the config
226
194
  /* eslint guard-for-in: 0 */
227
-
228
-
229
195
  for (const key in this.config.headers) {
230
196
  headers[key] = this.config.headers[key];
231
197
  }
232
198
  }
233
-
234
199
  applyUplinkHeaders(headers) {
235
200
  if (!this.config.headers) {
236
201
  return headers;
237
- } // add/override headers specified in the config
202
+ }
238
203
 
204
+ // add/override headers specified in the config
239
205
  /* eslint guard-for-in: 0 */
240
-
241
-
242
206
  for (const key in this.config.headers) {
243
207
  headers[key] = this.config.headers[key];
244
208
  }
245
-
246
209
  return headers;
247
210
  }
248
-
249
211
  async getRemoteMetadataNext(name, options) {
250
212
  if (this._ifRequestFailure()) {
251
213
  throw _core.errorUtils.getInternalError(_core.API_ERROR.UPLINK_OFFLINE);
252
- } // FUTURE: allow mix headers that comes from the client
253
-
214
+ }
254
215
 
216
+ // FUTURE: allow mix headers that comes from the client
255
217
  debug('get metadata for %s', name);
256
218
  let headers = this.getHeadersNext(options === null || options === void 0 ? void 0 : options.headers);
257
219
  headers = this.addProxyHeaders(headers, options.remoteAddress);
258
- headers = this.applyUplinkHeaders(headers); // the following headers cannot be overwritten
259
-
220
+ headers = this.applyUplinkHeaders(headers);
221
+ // the following headers cannot be overwritten
260
222
  if (_lodash.default.isNil(options.etag) === false) {
261
223
  headers[_core.HEADERS.NONE_MATCH] = options.etag;
262
224
  headers[_core.HEADERS.ACCEPT] = contentTypeAccept;
263
225
  }
264
-
265
226
  const method = options.method || 'GET';
266
227
  const uri = this.config.url + `/${encode(name)}`;
267
228
  debug('request uri for %s retry %s', uri);
268
229
  let response;
269
230
  let responseLength = 0;
270
-
271
231
  try {
272
232
  var _response;
273
-
274
233
  const retry = (options === null || options === void 0 ? void 0 : options.retry) ?? this.retry;
275
234
  debug('retry times %s for %s', retry, uri);
276
235
  response = await (0, _got.default)(uri, {
@@ -287,7 +246,6 @@ class ProxyStorage {
287
246
  afterResponse: [afterResponse => {
288
247
  const code = afterResponse.statusCode;
289
248
  debug('code response %s', code);
290
-
291
249
  if (code >= _core.HTTP_STATUS.OK && code < _core.HTTP_STATUS.MULTIPLE_CHOICES) {
292
250
  if (this.failed_requests >= this.max_fails) {
293
251
  this.failed_requests = 0;
@@ -296,10 +254,10 @@ class ProxyStorage {
296
254
  }, 'host @{host} is now online');
297
255
  }
298
256
  }
299
-
300
257
  return afterResponse;
301
258
  }],
302
- beforeRetry: [// FUTURE: got 12.0.0, the option arg should be removed
259
+ beforeRetry: [
260
+ // FUTURE: got 12.0.0, the option arg should be removed
303
261
  (_options, error, count) => {
304
262
  this.failed_requests = count ?? 0;
305
263
  this.logger.info({
@@ -310,7 +268,6 @@ class ProxyStorage {
310
268
  error: error.message,
311
269
  retryCount: this.failed_requests
312
270
  }, "retry @{retryCount} req: '@{request.method} @{request.url}'");
313
-
314
271
  if (this.failed_requests >= this.max_fails) {
315
272
  this.logger.warn({
316
273
  host: this.url.host
@@ -336,13 +293,13 @@ class ProxyStorage {
336
293
  }
337
294
  });
338
295
  const etag = response.headers.etag;
339
- const data = response.body; // not modified status (304) registry does not return any payload
340
- // it is handled as an error
296
+ const data = response.body;
341
297
 
298
+ // not modified status (304) registry does not return any payload
299
+ // it is handled as an error
342
300
  if (((_response = response) === null || _response === void 0 ? void 0 : _response.statusCode) === _core.HTTP_STATUS.NOT_MODIFIED) {
343
301
  throw _core.errorUtils.getCode(_core.HTTP_STATUS.NOT_MODIFIED, _core.API_ERROR.NOT_MODIFIED_NO_DATA);
344
302
  }
345
-
346
303
  debug('uri %s success', uri);
347
304
  const message = "@{!status}, req: '@{request.method} @{request.url}'";
348
305
  this.logger.http({
@@ -360,46 +317,40 @@ class ProxyStorage {
360
317
  return [data, etag];
361
318
  } catch (err) {
362
319
  debug('uri %s fail', uri);
363
-
364
320
  if (err.code === 'ERR_NON_2XX_3XX_RESPONSE') {
365
321
  const code = err.response.statusCode;
366
-
367
322
  if (code === _core.HTTP_STATUS.NOT_FOUND) {
368
323
  throw _core.errorUtils.getNotFound(_core.errorUtils.API_ERROR.NOT_PACKAGE_UPLINK);
369
324
  }
370
-
371
325
  if (!(code >= _core.HTTP_STATUS.OK && code < _core.HTTP_STATUS.MULTIPLE_CHOICES)) {
372
- const error = _core.errorUtils.getInternalError(`${_core.errorUtils.API_ERROR.BAD_STATUS_CODE}: ${code}`); // we need this code to identify outside which status code triggered the error
373
-
374
-
326
+ const error = _core.errorUtils.getInternalError(`${_core.errorUtils.API_ERROR.BAD_STATUS_CODE}: ${code}`);
327
+ // we need this code to identify outside which status code triggered the error
375
328
  error.remoteStatus = code;
376
329
  throw error;
377
330
  }
378
331
  }
379
-
380
332
  throw err;
381
333
  }
382
- } // FIXME: handle stream and retry
383
-
334
+ }
384
335
 
336
+ // FIXME: handle stream and retry
385
337
  fetchTarballNext(url, overrideOptions) {
386
338
  debug('fetching url for %s', url);
387
- const options = { ...this.config,
339
+ const options = {
340
+ ...this.config,
388
341
  ...overrideOptions
389
342
  };
390
343
  let headers = this.getHeadersNext(options === null || options === void 0 ? void 0 : options.headers);
391
344
  headers = this.addProxyHeaders(headers, options.remoteAddress);
392
- headers = this.applyUplinkHeaders(headers); // the following headers cannot be overwritten
393
-
345
+ headers = this.applyUplinkHeaders(headers);
346
+ // the following headers cannot be overwritten
394
347
  if (_lodash.default.isNil(options.etag) === false) {
395
348
  headers[_core.HEADERS.NONE_MATCH] = options.etag;
396
349
  headers[_core.HEADERS.ACCEPT] = contentTypeAccept;
397
350
  }
398
-
399
- const method = 'GET'; // const uri = this.config.url + `/${encode(name)}`;
400
-
351
+ const method = 'GET';
352
+ // const uri = this.config.url + `/${encode(name)}`;
401
353
  debug('request uri for %s', url);
402
-
403
354
  const readStream = _got.default.stream(url, {
404
355
  headers,
405
356
  method,
@@ -410,26 +361,23 @@ class ProxyStorage {
410
361
  }).on('request', () => {
411
362
  this.last_request_time = Date.now();
412
363
  });
413
-
414
364
  return readStream;
415
365
  }
366
+
416
367
  /**
417
368
  * Perform a stream search.
418
369
  * @param {*} options request options
419
370
  * @return {Stream}
420
371
  */
421
-
422
-
423
372
  async search({
424
373
  url,
425
374
  abort
426
375
  }) {
427
376
  debug('search url %o', url);
428
377
  let response;
429
-
430
378
  try {
431
- const fullURL = new _url.URL(`${this.url}${url}`); // FIXME: a better way to remove duplicate slashes?
432
-
379
+ const fullURL = new _url.URL(`${this.url}${url}`);
380
+ // FIXME: a better way to remove duplicate slashes?
433
381
  const uri = fullURL.href.replace(/([^:]\/)\/+/g, '$1');
434
382
  this.logger.http({
435
383
  uri,
@@ -445,19 +393,15 @@ class ProxyStorage {
445
393
  signal: abort === null || abort === void 0 ? void 0 : abort.signal
446
394
  });
447
395
  debug('response.status %o', response.status);
448
-
449
396
  if (response.status >= _core.HTTP_STATUS.BAD_REQUEST) {
450
397
  throw _core.errorUtils.getInternalError(`bad status code ${response.status} from uplink`);
451
398
  }
452
-
453
399
  const streamSearch = new _stream.PassThrough({
454
400
  objectMode: true
455
401
  });
456
402
  const res = await response.text();
457
-
458
- const streamResponse = _stream.Readable.from(res); // objects is one of the properties on the body, it ignores date and total
459
-
460
-
403
+ const streamResponse = _stream.Readable.from(res);
404
+ // objects is one of the properties on the body, it ignores date and total
461
405
  streamResponse.pipe(_JSONStream.default.parse('objects')).pipe(streamSearch, {
462
406
  end: true
463
407
  });
@@ -470,7 +414,6 @@ class ProxyStorage {
470
414
  throw err;
471
415
  }
472
416
  }
473
-
474
417
  addProxyHeaders(headers, remoteAddress) {
475
418
  // Only submit X-Forwarded-For field if we don't have a proxy selected
476
419
  // in the config file.
@@ -478,23 +421,23 @@ class ProxyStorage {
478
421
  // Otherwise misconfigured proxy could return 407
479
422
  if (!this.proxy) {
480
423
  headers[_core.HEADERS.FORWARDED_FOR] = (headers['x-forwarded-for'] ? headers['x-forwarded-for'] + ', ' : '') + remoteAddress;
481
- } // always attach Via header to avoid loops, even if we're not proxying
482
-
424
+ }
483
425
 
426
+ // always attach Via header to avoid loops, even if we're not proxying
484
427
  headers['via'] = headers['via'] ? headers['via'] + ', ' : '';
485
428
  headers['via'] += '1.1 ' + this.server_id + ' (Verdaccio)';
486
429
  return headers;
487
430
  }
431
+
488
432
  /**
489
433
  * If the request failure.
490
434
  * @return {boolean}
491
435
  * @private
492
436
  */
493
-
494
-
495
437
  _ifRequestFailure() {
496
438
  return this.failed_requests >= this.max_fails && Math.abs(Date.now() - this.last_request_time) < this.fail_timeout;
497
439
  }
440
+
498
441
  /**
499
442
  * Set up a proxy.
500
443
  * @param {*} hostname
@@ -502,41 +445,35 @@ class ProxyStorage {
502
445
  * @param {*} mainconfig
503
446
  * @param {*} isHTTPS
504
447
  */
505
-
506
-
507
448
  _setupProxy(hostname, config, mainconfig, isHTTPS) {
508
449
  let noProxyList;
509
- const proxy_key = isHTTPS ? 'https_proxy' : 'http_proxy'; // get http_proxy and no_proxy configs
450
+ const proxy_key = isHTTPS ? 'https_proxy' : 'http_proxy';
510
451
 
452
+ // get http_proxy and no_proxy configs
511
453
  if (proxy_key in config) {
512
454
  this.proxy = config[proxy_key];
513
455
  } else if (proxy_key in mainconfig) {
514
456
  this.proxy = mainconfig[proxy_key];
515
457
  }
516
-
517
458
  if ('no_proxy' in config) {
518
459
  noProxyList = config.no_proxy;
519
460
  } else if ('no_proxy' in mainconfig) {
520
461
  noProxyList = mainconfig.no_proxy;
521
- } // use wget-like algorithm to determine if proxy shouldn't be used
522
-
462
+ }
523
463
 
464
+ // use wget-like algorithm to determine if proxy shouldn't be used
524
465
  if (hostname[0] !== '.') {
525
466
  hostname = '.' + hostname;
526
467
  }
527
-
528
468
  if (_lodash.default.isString(noProxyList) && noProxyList.length) {
529
469
  noProxyList = noProxyList.split(',');
530
470
  }
531
-
532
471
  if (_lodash.default.isArray(noProxyList)) {
533
472
  for (let i = 0; i < noProxyList.length; i++) {
534
473
  let noProxyItem = noProxyList[i];
535
-
536
474
  if (noProxyItem[0] !== '.') {
537
475
  noProxyItem = '.' + noProxyItem;
538
476
  }
539
-
540
477
  if (hostname.endsWith(noProxyItem)) {
541
478
  if (this.proxy) {
542
479
  this.logger.debug({
@@ -545,12 +482,10 @@ class ProxyStorage {
545
482
  }, 'not using proxy for @{url}, excluded by @{rule} rule');
546
483
  this.proxy = undefined;
547
484
  }
548
-
549
485
  break;
550
486
  }
551
487
  }
552
488
  }
553
-
554
489
  if (typeof this.proxy === 'string') {
555
490
  this.logger.debug({
556
491
  url: this.url.href,
@@ -558,8 +493,6 @@ class ProxyStorage {
558
493
  }, 'using proxy @{proxy} for @{url}');
559
494
  }
560
495
  }
561
-
562
496
  }
563
-
564
497
  exports.ProxyStorage = ProxyStorage;
565
498
  //# sourceMappingURL=proxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","names":["LoggerApi","require","debug","buildDebug","encode","thing","encodeURIComponent","replace","jsonContentType","HEADERS","JSON","contentTypeAccept","setConfig","config","key","def","_","isNil","ProxyStorage","constructor","mainConfig","agent","failed_requests","userAgent","user_agent","ca","logger","child","sub","server_id","agent_options","keepAlive","maxSockets","maxFreeSockets","url","URL","isHTTPS","protocol","_setupProxy","hostname","getAgent","timeout","Number","warn","join","maxage","parseInterval","max_fails","fail_timeout","strict_ssl","Boolean","retry","limit","agentInstance","CustomAgents","proxy","get","getHeadersNext","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","getRemoteMetadataNext","name","options","_ifRequestFailure","errorUtils","getInternalError","API_ERROR","UPLINK_OFFLINE","addProxyHeaders","remoteAddress","etag","NONE_MATCH","method","uri","response","responseLength","got","responseType","request","hooks","afterResponse","code","statusCode","HTTP_STATUS","OK","MULTIPLE_CHOICES","host","beforeRetry","_options","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","fetchTarballNext","overrideOptions","readStream","stream","search","abort","fullURL","href","uplink","upname","undiciFetch","signal","BAD_REQUEST","streamSearch","PassThrough","objectMode","res","text","streamResponse","Readable","from","pipe","JSONStream","parse","end","errorMessage","FORWARDED_FOR","Math","abs","mainconfig","noProxyList","proxy_key","no_proxy","split","isArray","i","noProxyItem","endsWith","rule","undefined"],"sources":["../src/proxy.ts"],"sourcesContent":["import JSONStream from 'JSONStream';\nimport buildDebug from 'debug';\nimport got, { RequiredRetryOptions, Headers as gotHeaders } from 'got';\nimport type { Agents, Options } from 'got';\nimport _ from 'lodash';\nimport Stream, { PassThrough, Readable } from 'stream';\nimport { Headers, fetch as undiciFetch } from 'undici';\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 { Manifest } from '@verdaccio/types';\nimport { Config, Logger, UpLinkConf } from '@verdaccio/types';\nimport { buildToken } from '@verdaccio/utils';\n\nimport CustomAgents, { AgentOptionsConf } from './agent';\nimport { parseInterval } from './proxy-utils';\n\nconst LoggerApi = require('@verdaccio/logger');\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 headers?: Headers;\n url: string;\n query?: searchUtils.SearchQuery;\n abort: AbortController;\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: number;\n max_fails: number;\n fail_timeout: number;\n upname: string;\n search(options: ProxySearchParams): Promise<Stream.Readable>;\n getRemoteMetadataNext(name: string, options: ISyncUplinksOptions): Promise<[Manifest, string]>;\n fetchTarballNext(\n url: string,\n options: 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: number;\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<RequiredRetryOptions> | number;\n\n public constructor(config: UpLinkConfLocal, mainConfig: Config, agent?: Agents) {\n this.config = config;\n this.failed_requests = 0;\n this.userAgent = mainConfig.user_agent;\n this.ca = config.ca;\n this.logger = LoggerApi.logger.child({ sub: 'out' });\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 = parseInterval(setConfig(this.config, 'timeout', '30s'));\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 getHeadersNext(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.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 getRemoteMetadataNext(\n name: string,\n options: 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('get metadata for %s', name);\n let headers = this.getHeadersNext(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('request uri for %s retry %s', uri);\n let response;\n let responseLength = 0;\n try {\n const retry = options?.retry ?? this.retry;\n debug('retry times %s for %s', retry, uri);\n response = await got(uri, {\n headers,\n responseType: 'json',\n method,\n agent: this.agent,\n retry,\n // @ts-ignore\n timeout: { request: options?.timeout ?? this.timeout },\n hooks: {\n afterResponse: [\n (afterResponse) => {\n const code = afterResponse.statusCode;\n debug('code response %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 // FUTURE: got 12.0.0, the option arg should be removed\n (_options, error: any, 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('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('uri %s fail', uri);\n if (err.code === 'ERR_NON_2XX_3XX_RESPONSE') {\n const code = err.response.statusCode;\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 }\n throw err;\n }\n }\n\n // FIXME: handle stream and retry\n public fetchTarballNext(\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.getHeadersNext(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 }: ProxySearchParams): Promise<Stream.Readable> {\n debug('search url %o', url);\n\n let response;\n try {\n const fullURL = new URL(`${this.url}${url}`);\n // FIXME: a better way to remove duplicate slashes?\n const uri = fullURL.href.replace(/([^:]\\/)\\/+/g, '$1');\n this.logger.http({ uri, uplink: this.upname }, 'search request to uplink @{uplink} - @{uri}');\n response = await undiciFetch(uri, {\n method: 'GET',\n // FUTURE: whitelist domains what we are sending not need it headers, security check\n // headers: new Headers({\n // ...headers,\n // connection: 'keep-alive',\n // }),\n signal: abort?.signal,\n });\n debug('response.status %o', response.status);\n\n if (response.status >= HTTP_STATUS.BAD_REQUEST) {\n throw errorUtils.getInternalError(`bad status code ${response.status} from uplink`);\n }\n\n const streamSearch = new PassThrough({ objectMode: true });\n const res = await response.text();\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 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\n // get http_proxy and no_proxy configs\n if (proxy_key in config) {\n this.proxy = config[proxy_key];\n } else if (proxy_key in mainconfig) {\n this.proxy = mainconfig[proxy_key];\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 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 if (typeof this.proxy === 'string') {\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;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAYA;;AAEA;;AACA;;;;AAEA,MAAMA,SAAS,GAAGC,OAAO,CAAC,mBAAD,CAAzB;;AAEA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAW,iBAAX,CAAd;;AAEA,MAAMC,MAAM,GAAG,UAAUC,KAAV,EAAyB;EACtC,OAAOC,kBAAkB,CAACD,KAAD,CAAlB,CAA0BE,OAA1B,CAAkC,MAAlC,EAA0C,GAA1C,CAAP;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAGC,aAAA,CAAQC,IAAhC;AACA,MAAMC,iBAAiB,GAAI,GAAEH,eAAgB,GAA7C;AAEA;AACA;AACA;;AACA,MAAMI,SAAS,GAAG,CAACC,MAAD,EAA0BC,GAA1B,EAAuCC,GAAvC,KAAuD;EACvE,OAAOC,eAAA,CAAEC,KAAF,CAAQJ,MAAM,CAACC,GAAD,CAAd,MAAyB,KAAzB,GAAiCD,MAAM,CAACC,GAAD,CAAvC,GAA+CC,GAAtD;AACD,CAFD;;AAgDA;AACA;AACA;AACA;AACA,MAAMG,YAAN,CAAqC;EAanC;EACA;EAIA;EAKOC,WAAW,CAACN,MAAD,EAA0BO,UAA1B,EAA8CC,KAA9C,EAA8D;IAC9E,KAAKR,MAAL,GAAcA,MAAd;IACA,KAAKS,eAAL,GAAuB,CAAvB;IACA,KAAKC,SAAL,GAAiBH,UAAU,CAACI,UAA5B;IACA,KAAKC,EAAL,GAAUZ,MAAM,CAACY,EAAjB;IACA,KAAKC,MAAL,GAAc1B,SAAS,CAAC0B,MAAV,CAAiBC,KAAjB,CAAuB;MAAEC,GAAG,EAAE;IAAP,CAAvB,CA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AACK,CAAD,CAA7B;;QACA,IAAIC,WAAW,CAAC,CAAD,CAAX,KAAmB,GAAvB,EAA4B;UAC1BA,WAAW,GAAG,MAAMA,WAApB;QACD;;QACD,IAAIpJ,QAAQ,CAACqJ,QAAT,CAAkBD,WAAlB,CAAJ,EAAoC;UAClC,IAAI,KAAKpI,KAAT,EAAgB;YACd,KAAK7B,MAAL,CAAYxB,KAAZ,CACE;cAAEgC,GAAG,EAAE,KAAKA,GAAL,CAAS4H,IAAhB;cAAsB+B,IAAI,EAAEF;YAA5B,CADF,EAEE,sDAFF;YAIA,KAAKpI,KAAL,GAAauI,SAAb;UACD;;UACD;QACD;MACF;IACF;;IAED,IAAI,OAAO,KAAKvI,KAAZ,KAAsB,QAA1B,EAAoC;MAClC,KAAK7B,MAAL,CAAYxB,KAAZ,CACE;QAAEgC,GAAG,EAAE,KAAKA,GAAL,CAAS4H,IAAhB;QAAsBvG,KAAK,EAAE,KAAKA;MAAlC,CADF,EAEE,iCAFF;IAID;EACF;;AA1gBkC"}
1
+ {"version":3,"file":"proxy.js","names":["LoggerApi","require","debug","buildDebug","encode","thing","encodeURIComponent","replace","jsonContentType","HEADERS","JSON","contentTypeAccept","setConfig","config","key","def","_","isNil","ProxyStorage","constructor","mainConfig","agent","failed_requests","userAgent","user_agent","ca","logger","child","sub","server_id","agent_options","keepAlive","maxSockets","maxFreeSockets","url","URL","isHTTPS","protocol","_setupProxy","hostname","getAgent","timeout","Number","warn","join","maxage","parseInterval","max_fails","fail_timeout","strict_ssl","Boolean","retry","limit","agentInstance","CustomAgents","proxy","get","getHeadersNext","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","getRemoteMetadataNext","name","options","_ifRequestFailure","errorUtils","getInternalError","API_ERROR","UPLINK_OFFLINE","addProxyHeaders","remoteAddress","etag","NONE_MATCH","method","uri","response","responseLength","got","responseType","request","hooks","afterResponse","code","statusCode","HTTP_STATUS","OK","MULTIPLE_CHOICES","host","beforeRetry","_options","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","fetchTarballNext","overrideOptions","readStream","stream","search","abort","fullURL","href","uplink","upname","undiciFetch","signal","BAD_REQUEST","streamSearch","PassThrough","objectMode","res","text","streamResponse","Readable","from","pipe","JSONStream","parse","end","errorMessage","FORWARDED_FOR","Math","abs","mainconfig","noProxyList","proxy_key","no_proxy","split","isArray","i","noProxyItem","endsWith","rule","undefined"],"sources":["../src/proxy.ts"],"sourcesContent":["import JSONStream from 'JSONStream';\nimport buildDebug from 'debug';\nimport got, { RequiredRetryOptions, Headers as gotHeaders } from 'got';\nimport type { Agents, Options } from 'got';\nimport _ from 'lodash';\nimport Stream, { PassThrough, Readable } from 'stream';\nimport { Headers, fetch as undiciFetch } from 'undici';\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 { Manifest } from '@verdaccio/types';\nimport { Config, Logger, UpLinkConf } from '@verdaccio/types';\nimport { buildToken } from '@verdaccio/utils';\n\nimport CustomAgents, { AgentOptionsConf } from './agent';\nimport { parseInterval } from './proxy-utils';\n\nconst LoggerApi = require('@verdaccio/logger');\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 headers?: Headers;\n url: string;\n query?: searchUtils.SearchQuery;\n abort: AbortController;\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: number;\n max_fails: number;\n fail_timeout: number;\n upname: string;\n search(options: ProxySearchParams): Promise<Stream.Readable>;\n getRemoteMetadataNext(name: string, options: ISyncUplinksOptions): Promise<[Manifest, string]>;\n fetchTarballNext(\n url: string,\n options: 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: number;\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<RequiredRetryOptions> | number;\n\n public constructor(config: UpLinkConfLocal, mainConfig: Config, agent?: Agents) {\n this.config = config;\n this.failed_requests = 0;\n this.userAgent = mainConfig.user_agent;\n this.ca = config.ca;\n this.logger = LoggerApi.logger.child({ sub: 'out' });\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 = parseInterval(setConfig(this.config, 'timeout', '30s'));\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 getHeadersNext(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.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 getRemoteMetadataNext(\n name: string,\n options: 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('get metadata for %s', name);\n let headers = this.getHeadersNext(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('request uri for %s retry %s', uri);\n let response;\n let responseLength = 0;\n try {\n const retry = options?.retry ?? this.retry;\n debug('retry times %s for %s', retry, uri);\n response = await got(uri, {\n headers,\n responseType: 'json',\n method,\n agent: this.agent,\n retry,\n // @ts-ignore\n timeout: { request: options?.timeout ?? this.timeout },\n hooks: {\n afterResponse: [\n (afterResponse) => {\n const code = afterResponse.statusCode;\n debug('code response %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 // FUTURE: got 12.0.0, the option arg should be removed\n (_options, error: any, 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('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('uri %s fail', uri);\n if (err.code === 'ERR_NON_2XX_3XX_RESPONSE') {\n const code = err.response.statusCode;\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 }\n throw err;\n }\n }\n\n // FIXME: handle stream and retry\n public fetchTarballNext(\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.getHeadersNext(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 }: ProxySearchParams): Promise<Stream.Readable> {\n debug('search url %o', url);\n\n let response;\n try {\n const fullURL = new URL(`${this.url}${url}`);\n // FIXME: a better way to remove duplicate slashes?\n const uri = fullURL.href.replace(/([^:]\\/)\\/+/g, '$1');\n this.logger.http({ uri, uplink: this.upname }, 'search request to uplink @{uplink} - @{uri}');\n response = await undiciFetch(uri, {\n method: 'GET',\n // FUTURE: whitelist domains what we are sending not need it headers, security check\n // headers: new Headers({\n // ...headers,\n // connection: 'keep-alive',\n // }),\n signal: abort?.signal,\n });\n debug('response.status %o', response.status);\n\n if (response.status >= HTTP_STATUS.BAD_REQUEST) {\n throw errorUtils.getInternalError(`bad status code ${response.status} from uplink`);\n }\n\n const streamSearch = new PassThrough({ objectMode: true });\n const res = await response.text();\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 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\n // get http_proxy and no_proxy configs\n if (proxy_key in config) {\n this.proxy = config[proxy_key];\n } else if (proxy_key in mainconfig) {\n this.proxy = mainconfig[proxy_key];\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 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 if (typeof this.proxy === 'string') {\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;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAYA;AAEA;AACA;AAA8C;AAE9C,MAAMA,SAAS,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAE9C,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,iBAAiB,CAAC;AAE3C,MAAMC,MAAM,GAAG,UAAUC,KAAK,EAAU;EACtC,OAAOC,kBAAkB,CAACD,KAAK,CAAC,CAACE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;AACvD,CAAC;AAED,MAAMC,eAAe,GAAGC,aAAO,CAACC,IAAI;AACpC,MAAMC,iBAAiB,GAAI,GAAEH,eAAgB,GAAE;;AAE/C;AACA;AACA;AACA,MAAMI,SAAS,GAAG,CAACC,MAAuB,EAAEC,GAAW,EAAEC,GAAG,KAAa;EACvE,OAAOC,eAAC,CAACC,KAAK,CAACJ,MAAM,CAACC,GAAG,CAAC,CAAC,KAAK,KAAK,GAAGD,MAAM,CAACC,GAAG,CAAC,GAAGC,GAAG;AAC3D,CAAC;AA8CD;AACA;AACA;AACA;AACA,MAAMG,YAAY,CAAmB;EAanC;EACA;;EAIA;;EAKOC,WAAW,CAACN,M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AG,GAAGA,QAAQ;IAC3B;IAEA,IAAIvB,eAAC,CAACuD,QAAQ,CAAC8G,WAAW,CAAC,IAAIA,WAAW,CAACtC,MAAM,EAAE;MACjDsC,WAAW,GAAGA,WAAW,CAACG,KAAK,CAAC,GAAG,CAAC;IACtC;IAEA,IAAIxK,eAAC,CAACyK,OAAO,CAACJ,WAAW,CAAC,EAAE;MAC1B,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,WAAW,CAACtC,MAAM,EAAE2C,CAAC,EAAE,EAAE;QAC3C,IAAIC,WAAW,GAAGN,WAAW,CAACK,CAAC,CAAC;QAChC,IAAIC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;UAC1BA,WAAW,GAAG,GAAG,GAAGA,WAAW;QACjC;QACA,IAAIpJ,QAAQ,CAACqJ,QAAQ,CAACD,WAAW,CAAC,EAAE;UAClC,IAAI,IAAI,CAACpI,KAAK,EAAE;YACd,IAAI,CAAC7B,MAAM,CAACxB,KAAK,CACf;cAAEgC,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC4H,IAAI;cAAE+B,IAAI,EAAEF;YAAY,CAAC,EACzC,sDAAsD,CACvD;YACD,IAAI,CAACpI,KAAK,GAAGuI,SAAS;UACxB;UACA;QACF;MACF;IACF;IAEA,IAAI,OAAO,IAAI,CAACvI,KAAK,KAAK,QAAQ,EAAE;MAClC,IAAI,CAAC7B,MAAM,CAACxB,KAAK,CACf;QAAEgC,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC4H,IAAI;QAAEvG,KAAK,EAAE,IAAI,CAACA;MAAM,CAAC,EACzC,iCAAiC,CAClC;IACH;EACF;AACF;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/proxy",
3
- "version": "6.0.0-6-next.29",
3
+ "version": "6.0.0-6-next.31",
4
4
  "description": "verdaccio proxy fetcher",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -30,25 +30,25 @@
30
30
  "npm": ">=6"
31
31
  },
32
32
  "dependencies": {
33
- "@verdaccio/config": "6.0.0-6-next.51",
34
- "@verdaccio/core": "6.0.0-6-next.51",
35
- "@verdaccio/local-storage": "11.0.0-6-next.21",
36
- "@verdaccio/logger": "6.0.0-6-next.19",
37
- "@verdaccio/utils": "6.0.0-6-next.19",
33
+ "@verdaccio/config": "6.0.0-6-next.53",
34
+ "@verdaccio/core": "6.0.0-6-next.53",
35
+ "@verdaccio/local-storage": "11.0.0-6-next.23",
36
+ "@verdaccio/logger": "6.0.0-6-next.21",
37
+ "@verdaccio/utils": "6.0.0-6-next.21",
38
38
  "JSONStream": "1.3.5",
39
39
  "debug": "4.3.4",
40
40
  "lodash": "4.17.21",
41
- "got": "11.8.5",
42
- "hpagent": "1.1.0",
41
+ "got": "11.8.6",
42
+ "hpagent": "1.2.0",
43
43
  "undici": "4.16.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/node": "16.11.65",
46
+ "@types/node": "16.18.10",
47
47
  "p-cancelable": "2.1.1",
48
- "@verdaccio/types": "11.0.0-6-next.17",
48
+ "@verdaccio/types": "11.0.0-6-next.18",
49
49
  "get-stream": "^6.0.1",
50
50
  "nock": "13.2.9",
51
- "node-mocks-http": "1.11.0",
51
+ "node-mocks-http": "1.12.1",
52
52
  "semver": "7.3.8"
53
53
  },
54
54
  "funding": {