@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/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
@@ -1,2 +0,0 @@
1
- export * from './proxy';
2
- export * from './uplink-util';
@@ -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
- }