@verdaccio/proxy 7.0.0-next.6 → 8.0.0-next-8.1
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 +177 -0
- package/build/agent.d.ts +2 -0
- package/build/agent.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +11 -0
- package/build/index.js.map +1 -1
- package/build/proxy-utils.js.map +1 -1
- package/build/proxy.js +2 -2
- package/build/proxy.js.map +1 -1
- package/build/uplink-util.d.ts +10 -0
- package/build/uplink-util.js +42 -0
- package/build/uplink-util.js.map +1 -0
- package/package.json +11 -11
- package/src/index.ts +1 -0
- package/src/proxy.ts +1 -1
- package/src/uplink-util.ts +42 -0
- package/test/headers.auth.spec.ts +7 -5
- package/test/noProxy.spec.ts +2 -0
- package/test/proxy-utils.spec.ts +1 -0
- package/test/proxy.metadata.spec.ts +10 -23
- package/test/proxy.search.spec.ts +6 -5
- package/test/proxy.tarball.spec.ts +41 -37
- package/jest.config.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,182 @@
|
|
|
1
1
|
# @verdaccio/proxy
|
|
2
2
|
|
|
3
|
+
## 8.0.0-next-8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@8.0.0-next-8.1
|
|
8
|
+
- @verdaccio/config@8.0.0-next-8.1
|
|
9
|
+
- @verdaccio/utils@7.0.1-next-8.1
|
|
10
|
+
|
|
11
|
+
## 8.0.0-next-8.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- chore: move v7 next to v8 next
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @verdaccio/core@8.0.0-next-8.0
|
|
21
|
+
- @verdaccio/config@8.0.0-next-8.0
|
|
22
|
+
- @verdaccio/utils@7.0.1-next-8.0
|
|
23
|
+
|
|
24
|
+
## 7.0.0
|
|
25
|
+
|
|
26
|
+
### Major Changes
|
|
27
|
+
|
|
28
|
+
- 47f61c6: feat!: bump to v7
|
|
29
|
+
- e7ebccb: update major dependencies, remove old nodejs support
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [47f61c6]
|
|
34
|
+
- Updated dependencies [10dd81f]
|
|
35
|
+
- Updated dependencies [6e764e3]
|
|
36
|
+
- Updated dependencies [8c10a3e]
|
|
37
|
+
- Updated dependencies [daceb6d]
|
|
38
|
+
- Updated dependencies [e7ebccb]
|
|
39
|
+
- Updated dependencies [c9962fe]
|
|
40
|
+
- Updated dependencies [f047cc8]
|
|
41
|
+
- Updated dependencies [a99a4bb]
|
|
42
|
+
- Updated dependencies [a05a7d8]
|
|
43
|
+
- Updated dependencies [7c9f3cf]
|
|
44
|
+
- Updated dependencies [c31aec8]
|
|
45
|
+
- Updated dependencies [bd8703e]
|
|
46
|
+
- Updated dependencies [4d96324]
|
|
47
|
+
- @verdaccio/config@7.0.0
|
|
48
|
+
- @verdaccio/core@7.0.0
|
|
49
|
+
- @verdaccio/utils@7.0.0
|
|
50
|
+
|
|
51
|
+
## 7.0.0-next-8.21
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [8c10a3e]
|
|
56
|
+
- Updated dependencies [a05a7d8]
|
|
57
|
+
- Updated dependencies [7c9f3cf]
|
|
58
|
+
- @verdaccio/config@7.0.0-next-8.21
|
|
59
|
+
- @verdaccio/core@7.0.0-next-8.21
|
|
60
|
+
- @verdaccio/utils@7.0.0-next-8.21
|
|
61
|
+
|
|
62
|
+
## 7.0.0-next-7.20
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- @verdaccio/core@7.0.0-next-7.20
|
|
67
|
+
- @verdaccio/config@7.0.0-next-7.20
|
|
68
|
+
- @verdaccio/utils@7.0.0-next-7.20
|
|
69
|
+
|
|
70
|
+
## 7.0.0-next-7.19
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [c31aec8]
|
|
75
|
+
- @verdaccio/config@7.0.0-next-7.19
|
|
76
|
+
- @verdaccio/core@7.0.0-next-7.19
|
|
77
|
+
- @verdaccio/utils@7.0.0-next-7.19
|
|
78
|
+
|
|
79
|
+
## 7.0.0-next-7.18
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [10dd81f]
|
|
84
|
+
- @verdaccio/config@7.0.0-next-7.18
|
|
85
|
+
- @verdaccio/core@7.0.0-next-7.18
|
|
86
|
+
- @verdaccio/utils@7.0.0-next-7.18
|
|
87
|
+
|
|
88
|
+
## 7.0.0-next-7.17
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- Updated dependencies [6e764e3]
|
|
93
|
+
- @verdaccio/config@7.0.0-next-7.17
|
|
94
|
+
- @verdaccio/core@7.0.0-next-7.17
|
|
95
|
+
- @verdaccio/utils@7.0.0-next-7.17
|
|
96
|
+
|
|
97
|
+
## 7.0.0-next-7.16
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- @verdaccio/core@7.0.0-next-7.16
|
|
102
|
+
- @verdaccio/config@7.0.0-next-7.16
|
|
103
|
+
- @verdaccio/utils@7.0.0-next-7.16
|
|
104
|
+
|
|
105
|
+
## 7.0.0-next-7.15
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [bd8703e]
|
|
110
|
+
- @verdaccio/core@7.0.0-next-7.15
|
|
111
|
+
- @verdaccio/config@7.0.0-next-7.15
|
|
112
|
+
- @verdaccio/utils@7.0.0-next-7.15
|
|
113
|
+
|
|
114
|
+
## 7.0.0-next-7.14
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- @verdaccio/core@7.0.0-next-7.14
|
|
119
|
+
- @verdaccio/config@7.0.0-next-7.14
|
|
120
|
+
- @verdaccio/utils@7.0.0-next-7.14
|
|
121
|
+
|
|
122
|
+
## 7.0.0-next-7.13
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- Updated dependencies [a99a4bb]
|
|
127
|
+
- @verdaccio/config@7.0.0-next-7.13
|
|
128
|
+
- @verdaccio/core@7.0.0-next-7.13
|
|
129
|
+
- @verdaccio/utils@7.0.0-next-7.13
|
|
130
|
+
|
|
131
|
+
## 7.0.0-next-7.12
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- @verdaccio/core@7.0.0-next-7.12
|
|
136
|
+
- @verdaccio/config@7.0.0-next-7.12
|
|
137
|
+
- @verdaccio/utils@7.0.0-next-7.12
|
|
138
|
+
|
|
139
|
+
## 7.0.0-next-7.11
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- Updated dependencies [c9962fe]
|
|
144
|
+
- @verdaccio/config@7.0.0-next-7.11
|
|
145
|
+
- @verdaccio/core@7.0.0-next-7.11
|
|
146
|
+
- @verdaccio/utils@7.0.0-next-7.11
|
|
147
|
+
|
|
148
|
+
## 7.0.0-next-7.10
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- @verdaccio/core@7.0.0-next-7.10
|
|
153
|
+
- @verdaccio/config@7.0.0-next-7.10
|
|
154
|
+
- @verdaccio/utils@7.0.0-next-7.10
|
|
155
|
+
|
|
156
|
+
## 7.0.0-next-7.9
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- @verdaccio/core@7.0.0-next-7.9
|
|
161
|
+
- @verdaccio/config@7.0.0-next-7.9
|
|
162
|
+
- @verdaccio/utils@7.0.0-next-7.9
|
|
163
|
+
|
|
164
|
+
## 7.0.0-next-7.8
|
|
165
|
+
|
|
166
|
+
### Patch Changes
|
|
167
|
+
|
|
168
|
+
- @verdaccio/core@7.0.0-next-7.8
|
|
169
|
+
- @verdaccio/config@7.0.0-next-7.8
|
|
170
|
+
- @verdaccio/utils@7.0.0-next-7.8
|
|
171
|
+
|
|
172
|
+
## 7.0.0-next-7.7
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- @verdaccio/core@7.0.0-next-7.7
|
|
177
|
+
- @verdaccio/config@7.0.0-next-7.7
|
|
178
|
+
- @verdaccio/utils@7.0.0-next-7.7
|
|
179
|
+
|
|
3
180
|
## 7.0.0-next.6
|
|
4
181
|
|
|
5
182
|
### Patch Changes
|
package/build/agent.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node/http" />
|
|
4
|
+
/// <reference types="got-cjs/dist/source/core/timed-out" />
|
|
3
5
|
import { Agents } from 'got-cjs';
|
|
4
6
|
import { AgentOptions as HttpAgentOptions } from 'http';
|
|
5
7
|
import { AgentOptions as HttpsAgentOptions } from 'https';
|
package/build/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["_hpagent","require","_http","_https","_url","CustomAgents","constructor","url","proxy","agentOptions","protocol","getParsedUrl","agent","getAgent","get","isHTTPS","options","https","HttpsProxyAgent","http","HttpProxyAgent","HttpsAgent","HttpAgent","URL","_default","exports","default"],"sources":["../src/agent.ts"],"sourcesContent":["import { Agents } from 'got-cjs';\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAIA,MAAMI,YAAY,CAAC;EAKVC,WAAWA,CAChBC,GAAW,EACXC,KAAyB,EACzBC,YAAkD,EAClD;IACA,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACD,GAAG,GAAGA,GAAG;IACd,IAAI,CAACE,YAAY,GAAGA,YAAY;IAChC,MAAM;MAAEC;IAAS,CAAC,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;IACxC,IAAI,CAACC,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACH,QAAQ,CAAC;EACtC;EAEOI,GAAGA,CAAA,EAAG;IACX,OAAO,IAAI,CAACF,KAAK;EACnB;EAEQC,QAAQA,CAACH,QAAgB,EAAU;IACzC,MAAMK,OAAO,GAAGL,QAAQ,KAAK,QAAQ;IACrC,IAAI,IAAI,CAACF,KAAK,EAAE;MACd,MAAMQ,OAAO,GAAG;QACdR,KAAK,EAAE,IAAI,CAACA,KAAK;QACjB,GAAG,IAAI,CAACC;MACV,CAAC;MACD;MACA,OAAOM,OAAO,GACV;QAAEE,KAAK,EAAE,IAAIC,wBAAe,CAACF,OAAO;MAAE,CAAC,GACvC;QAAEG,IAAI,EAAE,IAAIC,uBAAc,CAACJ,OAAO;MAAE,CAAC;IAC3C,CAAC,MAAM;MACL;MACA,OAAOD,OAAO,GACV;QAAEE,KAAK,EAAE,IAAII,YAAU,CAAC,IAAI,CAACZ,YAAY;MAAE,CAAC,GAC5C;QAAEU,IAAI,EAAE,IAAIG,WAAS,CAAC,IAAI,CAACb,YAAY;MAAE,CAAC;IAChD;EACF;EAEQE,YAAYA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACH,KAAK,GAAG,IAAIe,QAAG,CAAC,IAAI,CAACf,KAAK,CAAC,GAAG,IAAIe,QAAG,CAAC,IAAI,CAAChB,GAAG,CAAC;EAC7D;AACF;AAAC,IAAAiB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcrB,YAAY"}
|
|
1
|
+
{"version":3,"file":"agent.js","names":["_hpagent","require","_http","_https","_url","CustomAgents","constructor","url","proxy","agentOptions","protocol","getParsedUrl","agent","getAgent","get","isHTTPS","options","https","HttpsProxyAgent","http","HttpProxyAgent","HttpsAgent","HttpAgent","URL","_default","exports","default"],"sources":["../src/agent.ts"],"sourcesContent":["import { Agents } from 'got-cjs';\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAIA,MAAMI,YAAY,CAAC;EAKVC,WAAWA,CAChBC,GAAW,EACXC,KAAyB,EACzBC,YAAkD,EAClD;IACA,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACD,GAAG,GAAGA,GAAG;IACd,IAAI,CAACE,YAAY,GAAGA,YAAY;IAChC,MAAM;MAAEC;IAAS,CAAC,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;IACxC,IAAI,CAACC,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACH,QAAQ,CAAC;EACtC;EAEOI,GAAGA,CAAA,EAAG;IACX,OAAO,IAAI,CAACF,KAAK;EACnB;EAEQC,QAAQA,CAACH,QAAgB,EAAU;IACzC,MAAMK,OAAO,GAAGL,QAAQ,KAAK,QAAQ;IACrC,IAAI,IAAI,CAACF,KAAK,EAAE;MACd,MAAMQ,OAAO,GAAG;QACdR,KAAK,EAAE,IAAI,CAACA,KAAK;QACjB,GAAG,IAAI,CAACC;MACV,CAAC;MACD;MACA,OAAOM,OAAO,GACV;QAAEE,KAAK,EAAE,IAAIC,wBAAe,CAACF,OAAO;MAAE,CAAC,GACvC;QAAEG,IAAI,EAAE,IAAIC,uBAAc,CAACJ,OAAO;MAAE,CAAC;IAC3C,CAAC,MAAM;MACL;MACA,OAAOD,OAAO,GACV;QAAEE,KAAK,EAAE,IAAII,YAAU,CAAC,IAAI,CAACZ,YAAY;MAAE,CAAC,GAC5C;QAAEU,IAAI,EAAE,IAAIG,WAAS,CAAC,IAAI,CAACb,YAAY;MAAE,CAAC;IAChD;EACF;EAEQE,YAAYA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACH,KAAK,GAAG,IAAIe,QAAG,CAAC,IAAI,CAACf,KAAK,CAAC,GAAG,IAAIe,QAAG,CAAC,IAAI,CAAChB,GAAG,CAAC;EAC7D;AACF;AAAC,IAAAiB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcrB,YAAY","ignoreList":[]}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -14,4 +14,15 @@ Object.keys(_proxy).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
+
var _uplinkUtil = require("./uplink-util");
|
|
18
|
+
Object.keys(_uplinkUtil).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _uplinkUtil[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _uplinkUtil[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
17
28
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_proxy","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../src/index.ts"],"sourcesContent":["export * from './proxy';\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_proxy","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_uplinkUtil"],"sources":["../src/index.ts"],"sourcesContent":["export * from './proxy';\nexport * from './uplink-util';\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/build/proxy-utils.js.map
CHANGED
|
@@ -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,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,CAAC;EACLC,CAAC,EAAE,IAAI;EACPC,CAAC,EAAE,EAAE,GAAG,IAAI;EACZC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;EACjBC,CAAC,EAAE,QAAQ;EACXC,CAAC,EAAE,CAAC,GAAG,QAAQ;EACfC,CAAC,EAAE,EAAE,GAAG,QAAQ;EAChBC,CAAC,EAAE,GAAG,GAAG;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACC,QAAa,EAAU;EACnD,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;IAChC,OAAOA,QAAQ,GAAG,IAAI;EACxB;EACA,IAAIC,MAAM,GAAG,CAAC;EACd,IAAIC,WAAW,GAAGC,QAAQ;EAC1BH,QAAQ,CAACI,KAAK,CAAC,KAAK,CAAC,CAACC,OAAO,CAAC,UAAUC,CAAC,EAAQ;IAC/C,IAAI,CAACA,CAAC,EAAE;MACN;IACF;IACA,MAAMb,CAAC,GAAGa,CAAC,CAACC,KAAK,CAAC,mDAAmD,CAAC;IACtE,IACE,CAACd,CAAC,IACFH,kBAAkB,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAIS,WAAW,IACtCT,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,IAAIS,WAAW,KAAKC,QAAS,EACzC;MACA,MAAMK,KAAK,CAAC,oBAAoB,GAAGR,QAAQ,CAAC;IAC9C;IACAE,WAAW,GAAGZ,kBAAkB,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtCQ,MAAM,IAAIQ,MAAM,CAAChB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAGH,kBAAkB,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC;EACnD,CAAC,CAAC;EACF,OAAOQ,MAAM;AACf"}
|
|
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,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,CAAC;EACLC,CAAC,EAAE,IAAI;EACPC,CAAC,EAAE,EAAE,GAAG,IAAI;EACZC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;EACjBC,CAAC,EAAE,QAAQ;EACXC,CAAC,EAAE,CAAC,GAAG,QAAQ;EACfC,CAAC,EAAE,EAAE,GAAG,QAAQ;EAChBC,CAAC,EAAE,GAAG,GAAG;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACC,QAAa,EAAU;EACnD,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;IAChC,OAAOA,QAAQ,GAAG,IAAI;EACxB;EACA,IAAIC,MAAM,GAAG,CAAC;EACd,IAAIC,WAAW,GAAGC,QAAQ;EAC1BH,QAAQ,CAACI,KAAK,CAAC,KAAK,CAAC,CAACC,OAAO,CAAC,UAAUC,CAAC,EAAQ;IAC/C,IAAI,CAACA,CAAC,EAAE;MACN;IACF;IACA,MAAMb,CAAC,GAAGa,CAAC,CAACC,KAAK,CAAC,mDAAmD,CAAC;IACtE,IACE,CAACd,CAAC,IACFH,kBAAkB,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAIS,WAAW,IACtCT,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,IAAIS,WAAW,KAAKC,QAAS,EACzC;MACA,MAAMK,KAAK,CAAC,oBAAoB,GAAGR,QAAQ,CAAC;IAC9C;IACAE,WAAW,GAAGZ,kBAAkB,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtCQ,MAAM,IAAIQ,MAAM,CAAChB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAGH,kBAAkB,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC;EACnD,CAAC,CAAC;EACF,OAAOQ,MAAM;AACf","ignoreList":[]}
|
package/build/proxy.js
CHANGED
|
@@ -21,8 +21,8 @@ var _utils = require("@verdaccio/utils");
|
|
|
21
21
|
var _agent = _interopRequireDefault(require("./agent"));
|
|
22
22
|
var _proxyUtils = require("./proxy-utils");
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
25
|
-
function _interopRequireDefault(
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
26
|
const debug = (0, _debug.default)('verdaccio:proxy');
|
|
27
27
|
const encode = function (thing) {
|
|
28
28
|
return encodeURIComponent(thing).replace(/^%40/, '@');
|
package/build/proxy.js.map
CHANGED
|
@@ -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","prototype","hasOwnProperty","call","i","set","obj","debug","buildDebug","encode","thing","encodeURIComponent","replace","jsonContentType","HEADERS","JSON","contentTypeAccept","setConfig","config","key","def","_","isNil","ProxyStorage","constructor","mainConfig","logger","agent","_mainConfig$user_agen","_this$config$max_fail","_this$max_fails","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","_options$retry","_response","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","_this$retry","readStream","stream","search","abort","fullURL","href","uplink","upname","signal","res","text","streamSearch","PassThrough","objectMode","streamResponse","Readable","from","pipe","JSONStream","parse","end","errorMessage","FORWARDED_FOR","Math","abs","mainconfig","noProxyList","proxy_key","no_proxy","split","isArray","noProxyItem","endsWith","rule","undefined","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 { 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 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.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 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 debug('searching on %s', 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 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\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,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;AAYA,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,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAA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E;MAC1B,KAAK,IAAIvL,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGuL,WAAW,CAACtC,MAAM,EAAEjJ,CAAC,EAAE,EAAE;QAC3C,IAAI4L,WAAW,GAAGL,WAAW,CAACvL,CAAC,CAAC;QAChC,IAAI4L,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;UAC1BA,WAAW,GAAG,GAAG,GAAGA,WAAW;QACjC;QACA,IAAInJ,QAAQ,CAACoJ,QAAQ,CAACD,WAAW,CAAC,EAAE;UAClC,IAAI,IAAI,CAAClI,KAAK,EAAE;YACd,IAAI,CAACpC,MAAM,CAACnB,KAAK,CACf;cAAEiC,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC8H,IAAI;cAAE4B,IAAI,EAAEF;YAAY,CAAC,EACzC,sDACF,CAAC;YACD,IAAI,CAAClI,KAAK,GAAGqI,SAAS;UACxB;UACA;QACF;MACF;IACF;IAEA,IAAI,OAAO,IAAI,CAACrI,KAAK,KAAK,QAAQ,EAAE;MAClC,IAAI,CAACpC,MAAM,CAACnB,KAAK,CACf;QAAEiC,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC8H,IAAI;QAAExG,KAAK,EAAE,IAAI,CAACA;MAAM,CAAC,EACzC,iCACF,CAAC;IACH;EACF;AACF;AAACsI,OAAA,CAAA7K,YAAA,GAAAA,YAAA"}
|
|
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","_mainConfig$user_agen","_this$config$max_fail","_this$max_fails","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","_options$retry","_response","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","_this$retry","readStream","stream","search","abort","fullURL","href","uplink","upname","signal","res","text","streamSearch","PassThrough","objectMode","streamResponse","Readable","from","pipe","JSONStream","parse","end","errorMessage","FORWARDED_FOR","Math","abs","mainconfig","noProxyList","proxy_key","no_proxy","split","isArray","noProxyItem","endsWith","rule","undefined","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 { 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 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 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 debug('searching on %s', 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 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\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,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,CAAA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GAAG,CAAC8H,IAAI;cAAE4B,IAAI,EAAEF;YAAY,CAAC,EACzC,sDACF,CAAC;YACD,IAAI,CAAClI,KAAK,GAAGqI,SAAS;UACxB;UACA;QACF;MACF;IACF;IAEA,IAAI,OAAO,IAAI,CAACrI,KAAK,KAAK,QAAQ,EAAE;MAClC,IAAI,CAACpC,MAAM,CAACnB,KAAK,CACf;QAAEiC,GAAG,EAAE,IAAI,CAACA,GAAG,CAAC8H,IAAI;QAAExG,KAAK,EAAE,IAAI,CAACA;MAAM,CAAC,EACzC,iCACF,CAAC;IACH;EACF;AACF;AAACsI,OAAA,CAAA7K,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config, Logger, Manifest } from '@verdaccio/types';
|
|
2
|
+
import { IProxy } from './index';
|
|
3
|
+
export interface ProxyInstanceList {
|
|
4
|
+
[key: string]: IProxy;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Set up uplinks for each proxy configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setupUpLinks(config: Config, logger: Logger): ProxyInstanceList;
|
|
10
|
+
export declare function updateVersionsHiddenUpLinkNext(manifest: Manifest, upLink: IProxy): Manifest;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setupUpLinks = setupUpLinks;
|
|
7
|
+
exports.updateVersionsHiddenUpLinkNext = updateVersionsHiddenUpLinkNext;
|
|
8
|
+
var _index = require("./index");
|
|
9
|
+
/**
|
|
10
|
+
* Set up uplinks for each proxy configuration.
|
|
11
|
+
*/
|
|
12
|
+
function setupUpLinks(config, logger) {
|
|
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
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return uplinks;
|
|
24
|
+
}
|
|
25
|
+
function updateVersionsHiddenUpLinkNext(manifest, upLink) {
|
|
26
|
+
const {
|
|
27
|
+
versions
|
|
28
|
+
} = manifest;
|
|
29
|
+
const versionsList = Object.keys(versions);
|
|
30
|
+
if (versionsList.length === 0) {
|
|
31
|
+
return manifest;
|
|
32
|
+
}
|
|
33
|
+
for (const version of versionsList) {
|
|
34
|
+
// holds a "hidden" value to be used by the package storage.
|
|
35
|
+
versions[version][Symbol.for('__verdaccio_uplink')] = upLink.upname;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...manifest,
|
|
39
|
+
versions
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=uplink-util.js.map
|
|
@@ -0,0 +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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/proxy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-next-8.1",
|
|
4
4
|
"description": "verdaccio proxy fetcher",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,26 +26,26 @@
|
|
|
26
26
|
"verdaccio"
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=14"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/config": "
|
|
33
|
-
"@verdaccio/core": "
|
|
34
|
-
"@verdaccio/utils": "7.0.
|
|
32
|
+
"@verdaccio/config": "8.0.0-next-8.1",
|
|
33
|
+
"@verdaccio/core": "8.0.0-next-8.1",
|
|
34
|
+
"@verdaccio/utils": "7.0.1-next-8.1",
|
|
35
35
|
"JSONStream": "1.3.5",
|
|
36
|
-
"debug": "4.3.
|
|
36
|
+
"debug": "4.3.7",
|
|
37
37
|
"got-cjs": "12.5.4",
|
|
38
38
|
"hpagent": "1.2.0",
|
|
39
39
|
"lodash": "4.17.21"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@verdaccio/logger": "
|
|
43
|
-
"@verdaccio/types": "
|
|
42
|
+
"@verdaccio/logger": "8.0.0-next-8.1",
|
|
43
|
+
"@verdaccio/types": "13.0.0-next-8.0",
|
|
44
44
|
"get-stream": "^6.0.1",
|
|
45
|
-
"nock": "13.
|
|
45
|
+
"nock": "13.5.1",
|
|
46
46
|
"node-mocks-http": "1.14.1",
|
|
47
47
|
"p-cancelable": "2.1.1",
|
|
48
|
-
"semver": "7.
|
|
48
|
+
"semver": "7.6.3"
|
|
49
49
|
},
|
|
50
50
|
"funding": {
|
|
51
51
|
"type": "opencollective",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"clean": "rimraf ./build",
|
|
56
|
-
"test": "
|
|
56
|
+
"test": "vitest run",
|
|
57
57
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
58
58
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
59
59
|
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
|
package/src/index.ts
CHANGED
package/src/proxy.ts
CHANGED
|
@@ -196,7 +196,7 @@ class ProxyStorage implements IProxy {
|
|
|
196
196
|
return headers;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
if (_.isObject(auth) === false && _.isObject(auth.token) === false) {
|
|
199
|
+
if (_.isObject(auth) === false && _.isObject((auth as any).token) === false) {
|
|
200
200
|
this._throwErrorAuth('Auth invalid');
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Config, Logger, Manifest } from '@verdaccio/types';
|
|
2
|
+
|
|
3
|
+
import { IProxy, ProxyStorage } from './index';
|
|
4
|
+
|
|
5
|
+
export interface ProxyInstanceList {
|
|
6
|
+
[key: string]: IProxy;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Set up uplinks for each proxy configuration.
|
|
11
|
+
*/
|
|
12
|
+
export function setupUpLinks(config: Config, logger: Logger): ProxyInstanceList {
|
|
13
|
+
const uplinks: ProxyInstanceList = {};
|
|
14
|
+
|
|
15
|
+
for (const uplinkName in config.uplinks) {
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(config.uplinks, uplinkName)) {
|
|
17
|
+
// instance for each up-link definition
|
|
18
|
+
const proxy: IProxy = new ProxyStorage(config.uplinks[uplinkName], config, logger);
|
|
19
|
+
// TODO: review this can be inside ProxyStorage
|
|
20
|
+
proxy.upname = uplinkName;
|
|
21
|
+
|
|
22
|
+
uplinks[uplinkName] = proxy;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return uplinks;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function updateVersionsHiddenUpLinkNext(manifest: Manifest, upLink: IProxy): Manifest {
|
|
30
|
+
const { versions } = manifest;
|
|
31
|
+
const versionsList = Object.keys(versions);
|
|
32
|
+
if (versionsList.length === 0) {
|
|
33
|
+
return manifest;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const version of versionsList) {
|
|
37
|
+
// holds a "hidden" value to be used by the package storage.
|
|
38
|
+
versions[version][Symbol.for('__verdaccio_uplink')] = upLink.upname;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { ...manifest, versions };
|
|
42
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
+
|
|
1
3
|
import { DEFAULT_REGISTRY } from '@verdaccio/config';
|
|
2
4
|
import { HEADERS, TOKEN_BASIC, TOKEN_BEARER, constants } from '@verdaccio/core';
|
|
3
5
|
import { Logger } from '@verdaccio/types';
|
|
@@ -5,11 +7,11 @@ import { buildToken } from '@verdaccio/utils';
|
|
|
5
7
|
|
|
6
8
|
import { ProxyStorage } from '../src';
|
|
7
9
|
|
|
8
|
-
const mockDebug =
|
|
9
|
-
const mockInfo =
|
|
10
|
-
const mockHttp =
|
|
11
|
-
const mockError =
|
|
12
|
-
const mockWarn =
|
|
10
|
+
const mockDebug = vi.fn();
|
|
11
|
+
const mockInfo = vi.fn();
|
|
12
|
+
const mockHttp = vi.fn();
|
|
13
|
+
const mockError = vi.fn();
|
|
14
|
+
const mockWarn = vi.fn();
|
|
13
15
|
|
|
14
16
|
const logger = {
|
|
15
17
|
debug: mockDebug,
|
package/test/noProxy.spec.ts
CHANGED
package/test/proxy-utils.spec.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { setTimeout } from 'timers/promises';
|
|
4
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
5
|
|
|
5
6
|
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
6
7
|
import { API_ERROR, errorUtils } from '@verdaccio/core';
|
|
@@ -10,11 +11,11 @@ import { ProxyStorage } from '../src';
|
|
|
10
11
|
|
|
11
12
|
const getConf = (name) => path.join(__dirname, '/conf', name);
|
|
12
13
|
|
|
13
|
-
const mockDebug =
|
|
14
|
-
const mockInfo =
|
|
15
|
-
const mockHttp =
|
|
16
|
-
const mockError =
|
|
17
|
-
const mockWarn =
|
|
14
|
+
const mockDebug = vi.fn();
|
|
15
|
+
const mockInfo = vi.fn();
|
|
16
|
+
const mockHttp = vi.fn();
|
|
17
|
+
const mockError = vi.fn();
|
|
18
|
+
const mockWarn = vi.fn();
|
|
18
19
|
|
|
19
20
|
const logger = {
|
|
20
21
|
debug: mockDebug,
|
|
@@ -24,39 +25,25 @@ const logger = {
|
|
|
24
25
|
warn: mockWarn,
|
|
25
26
|
} as unknown as Logger;
|
|
26
27
|
|
|
27
|
-
// mock to get the headers fixed value
|
|
28
|
-
jest.mock('crypto', () => {
|
|
29
|
-
return {
|
|
30
|
-
randomBytes: (): { toString: () => string } => {
|
|
31
|
-
return {
|
|
32
|
-
toString: (): string => 'foo-random-bytes',
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
pseudoRandomBytes: (): { toString: () => string } => {
|
|
36
|
-
return {
|
|
37
|
-
toString: (): string => 'foo-phseudo-bytes',
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
|
|
43
28
|
const domain = 'https://registry.npmjs.org';
|
|
44
29
|
|
|
45
30
|
describe('proxy', () => {
|
|
46
31
|
beforeEach(() => {
|
|
47
32
|
nock.cleanAll();
|
|
48
33
|
});
|
|
34
|
+
|
|
49
35
|
const defaultRequestOptions = {
|
|
50
|
-
url:
|
|
36
|
+
url: domain,
|
|
51
37
|
};
|
|
52
38
|
const proxyPath = getConf('proxy1.yaml');
|
|
53
39
|
const conf = new Config(parseConfigFile(proxyPath));
|
|
40
|
+
conf.server_id = 'foo-phseudo-bytes';
|
|
54
41
|
|
|
55
42
|
describe('getRemoteMetadata', () => {
|
|
56
43
|
beforeEach(() => {
|
|
57
44
|
nock.cleanAll();
|
|
58
45
|
nock.abortPendingRequests();
|
|
59
|
-
|
|
46
|
+
vi.clearAllMocks();
|
|
60
47
|
});
|
|
61
48
|
describe('basic requests', () => {
|
|
62
49
|
test('success call to remote', async () => {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import getStream from 'get-stream';
|
|
5
5
|
import nock from 'nock';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
7
8
|
|
|
8
9
|
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
9
10
|
import { streamUtils } from '@verdaccio/core';
|
|
@@ -13,11 +14,11 @@ import { ProxyStorage } from '../src';
|
|
|
13
14
|
|
|
14
15
|
const getConf = (name) => path.join(__dirname, '/conf', name);
|
|
15
16
|
|
|
16
|
-
const mockDebug =
|
|
17
|
-
const mockInfo =
|
|
18
|
-
const mockHttp =
|
|
19
|
-
const mockError =
|
|
20
|
-
const mockWarn =
|
|
17
|
+
const mockDebug = vi.fn();
|
|
18
|
+
const mockInfo = vi.fn();
|
|
19
|
+
const mockHttp = vi.fn();
|
|
20
|
+
const mockError = vi.fn();
|
|
21
|
+
const mockWarn = vi.fn();
|
|
21
22
|
|
|
22
23
|
const logger = {
|
|
23
24
|
debug: mockDebug,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { beforeEach, describe, test, vi } from 'vitest';
|
|
3
4
|
|
|
4
5
|
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
5
6
|
import { logger, setup } from '@verdaccio/logger';
|
|
6
7
|
|
|
7
8
|
import { ProxyStorage } from '../src';
|
|
8
9
|
|
|
9
|
-
setup();
|
|
10
|
+
setup({});
|
|
10
11
|
|
|
11
12
|
const getConf = (name) => path.join(__dirname, '/conf', name);
|
|
12
13
|
|
|
13
14
|
// // mock to get the headers fixed value
|
|
14
|
-
|
|
15
|
+
vi.mock('crypto', () => {
|
|
15
16
|
return {
|
|
16
17
|
randomBytes: (): { toString: () => string } => {
|
|
17
18
|
return {
|
|
@@ -30,7 +31,7 @@ describe('tarball proxy', () => {
|
|
|
30
31
|
beforeEach(() => {
|
|
31
32
|
nock.cleanAll();
|
|
32
33
|
nock.abortPendingRequests();
|
|
33
|
-
|
|
34
|
+
vi.clearAllMocks();
|
|
34
35
|
});
|
|
35
36
|
const defaultRequestOptions = {
|
|
36
37
|
url: 'https://registry.verdaccio.org',
|
|
@@ -40,41 +41,44 @@ describe('tarball proxy', () => {
|
|
|
40
41
|
const conf = new Config(parseConfigFile(proxyPath));
|
|
41
42
|
|
|
42
43
|
describe('fetchTarball', () => {
|
|
43
|
-
test('get file tarball fetch', (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
test('get file tarball fetch', () =>
|
|
45
|
+
new Promise((done) => {
|
|
46
|
+
nock('https://registry.verdaccio.org')
|
|
47
|
+
.get('/jquery/-/jquery-0.0.1.tgz')
|
|
48
|
+
.replyWithFile(201, path.join(__dirname, 'partials/jquery-0.0.1.tgz'));
|
|
49
|
+
const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
|
|
50
|
+
const stream = prox1.fetchTarball(
|
|
51
|
+
'https://registry.verdaccio.org/jquery/-/jquery-0.0.1.tgz',
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
{}
|
|
54
|
+
);
|
|
55
|
+
stream.on('response', () => {
|
|
56
|
+
done(true);
|
|
57
|
+
});
|
|
58
|
+
stream.on('error', (err) => {
|
|
59
|
+
done(err);
|
|
60
|
+
});
|
|
61
|
+
}));
|
|
59
62
|
|
|
60
|
-
test.skip('get file tarball handle retries', (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
test.skip('get file tarball handle retries', () =>
|
|
64
|
+
new Promise((done) => {
|
|
65
|
+
nock('https://registry.verdaccio.org')
|
|
66
|
+
.get('/jquery/-/jquery-0.0.1.tgz')
|
|
67
|
+
.twice()
|
|
68
|
+
.reply(500, 'some-text')
|
|
69
|
+
.get('/jquery/-/jquery-0.0.1.tgz')
|
|
70
|
+
.once()
|
|
71
|
+
.replyWithFile(201, path.join(__dirname, 'partials/jquery-0.0.1.tgz'));
|
|
72
|
+
const prox1 = new ProxyStorage(defaultRequestOptions, conf);
|
|
73
|
+
const stream = prox1.fetchTarball(
|
|
74
|
+
'https://registry.verdaccio.org/jquery/-/jquery-0.0.1.tgz',
|
|
75
|
+
{ retry: { limit: 2 } }
|
|
76
|
+
);
|
|
77
|
+
stream.on('error', () => {
|
|
78
|
+
// FIXME: stream should have handle 2 retry
|
|
79
|
+
done();
|
|
80
|
+
});
|
|
81
|
+
}));
|
|
78
82
|
});
|
|
79
83
|
});
|
|
80
84
|
// test('get file tarball correct content-length', (done) => {
|