@verdaccio/proxy 8.0.0-next-8.12 → 8.0.0-next-8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -24
- package/build/proxy.d.ts +9 -5
- package/build/proxy.js +23 -27
- package/build/proxy.js.map +1 -1
- package/build/uplink-util.js +5 -9
- package/build/uplink-util.js.map +1 -1
- package/package.json +12 -8
- package/.babelrc +0 -3
- package/CHANGELOG.md +0 -1390
- package/src/agent.ts +0 -50
- package/src/index.ts +0 -2
- package/src/proxy-utils.ts +0 -41
- package/src/proxy.ts +0 -650
- package/src/uplink-util.ts +0 -42
- package/test/conf/proxy1.yaml +0 -31
- package/test/headers.auth.spec.ts +0 -165
- package/test/noProxy.spec.ts +0 -239
- package/test/partials/jquery-0.0.1.tgz +0 -0
- package/test/partials/search-v1.json +0 -157
- package/test/partials/ssl-cert-snakeoil.key +0 -15
- package/test/partials/ssl-cert-snakeoil.pem +0 -12
- package/test/proxy-utils.spec.ts +0 -36
- package/test/proxy.error.___.ts +0 -126
- package/test/proxy.metadata.spec.ts +0 -451
- package/test/proxy.protocol.spec.ts +0 -87
- package/test/proxy.search.spec.ts +0 -110
- package/test/proxy.tarball.spec.ts +0 -183
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -23
- package/types/patch.d.ts +0 -10
package/src/agent.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Agents } from 'got-cjs';
|
|
2
|
-
import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
|
|
3
|
-
import { Agent as HttpAgent } from 'http';
|
|
4
|
-
import { Agent as HttpsAgent } from 'https';
|
|
5
|
-
import { URL } from 'url';
|
|
6
|
-
|
|
7
|
-
import { AgentOptionsConf } from '@verdaccio/types';
|
|
8
|
-
|
|
9
|
-
class CustomAgents {
|
|
10
|
-
private url: string;
|
|
11
|
-
private proxy: string | undefined;
|
|
12
|
-
private agentOptions: AgentOptionsConf;
|
|
13
|
-
private agent: Agents;
|
|
14
|
-
public constructor(url: string, proxy: string | undefined, agentOptions: AgentOptionsConf) {
|
|
15
|
-
this.proxy = proxy;
|
|
16
|
-
this.url = url;
|
|
17
|
-
this.agentOptions = agentOptions;
|
|
18
|
-
const { protocol } = this.getParsedUrl();
|
|
19
|
-
this.agent = this.getAgent(protocol);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public get() {
|
|
23
|
-
return this.agent;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private getAgent(protocol: string): Agents {
|
|
27
|
-
const isHTTPS = protocol === 'https:';
|
|
28
|
-
if (this.proxy) {
|
|
29
|
-
const options = {
|
|
30
|
-
proxy: this.proxy,
|
|
31
|
-
...this.agentOptions,
|
|
32
|
-
};
|
|
33
|
-
// use hpagent
|
|
34
|
-
return isHTTPS
|
|
35
|
-
? { https: new HttpsProxyAgent(options) }
|
|
36
|
-
: { http: new HttpProxyAgent(options) };
|
|
37
|
-
} else {
|
|
38
|
-
// use native http/https agent
|
|
39
|
-
return isHTTPS
|
|
40
|
-
? { https: new HttpsAgent(this.agentOptions) }
|
|
41
|
-
: { http: new HttpAgent(this.agentOptions) };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private getParsedUrl() {
|
|
46
|
-
return this.proxy ? new URL(this.proxy) : new URL(this.url);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default CustomAgents;
|
package/src/index.ts
DELETED
package/src/proxy-utils.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const parseIntervalTable = {
|
|
2
|
-
'': 1000,
|
|
3
|
-
ms: 1,
|
|
4
|
-
s: 1000,
|
|
5
|
-
m: 60 * 1000,
|
|
6
|
-
h: 60 * 60 * 1000,
|
|
7
|
-
d: 86400000,
|
|
8
|
-
w: 7 * 86400000,
|
|
9
|
-
M: 30 * 86400000,
|
|
10
|
-
y: 365 * 86400000,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Parse an internal string to number
|
|
15
|
-
* @param {*} interval
|
|
16
|
-
* @return {Number}
|
|
17
|
-
* @deprecated
|
|
18
|
-
*/
|
|
19
|
-
export function parseInterval(interval: any): number {
|
|
20
|
-
if (typeof interval === 'number') {
|
|
21
|
-
return interval * 1000;
|
|
22
|
-
}
|
|
23
|
-
let result = 0;
|
|
24
|
-
let last_suffix = Infinity;
|
|
25
|
-
interval.split(/\s+/).forEach(function (x): void {
|
|
26
|
-
if (!x) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const m = x.match(/^((0|[1-9][0-9]*)(\.[0-9]+)?)(ms|s|m|h|d|w|M|y|)$/);
|
|
30
|
-
if (
|
|
31
|
-
!m ||
|
|
32
|
-
parseIntervalTable[m[4]] >= last_suffix ||
|
|
33
|
-
(m[4] === '' && last_suffix !== Infinity)
|
|
34
|
-
) {
|
|
35
|
-
throw Error('invalid interval: ' + interval);
|
|
36
|
-
}
|
|
37
|
-
last_suffix = parseIntervalTable[m[4]];
|
|
38
|
-
result += Number(m[1]) * parseIntervalTable[m[4]];
|
|
39
|
-
});
|
|
40
|
-
return result;
|
|
41
|
-
}
|