@wopee-io/wopee.pw 4.24.1 → 4.25.0
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/.github/workflows/ci_cd.yaml +30 -12
- package/README.md +13 -0
- package/build/core/ports/configPort/configPort.js +2 -0
- package/build/core/ports/configPort/configPort.js.map +1 -1
- package/build/core/ports/configPort/configValidation.d.ts +2 -0
- package/build/core/ports/configPort/configValidation.js +49 -0
- package/build/core/ports/configPort/configValidation.js.map +1 -0
- package/build/shared/metadata/versionMetadata.js +15 -6
- package/build/shared/metadata/versionMetadata.js.map +1 -1
- package/build/tools/wopee-reporter/wopeeReporter.d.ts +3 -0
- package/build/tools/wopee-reporter/wopeeReporter.js +30 -3
- package/build/tools/wopee-reporter/wopeeReporter.js.map +1 -1
- package/docs/configuration.md +39 -15
- package/docs/troubleshooting.md +59 -0
- package/node_modules/@autonomous-testing/sdk/.github/workflows/ci_cd.yaml +47 -20
- package/node_modules/@autonomous-testing/sdk/README.md +129 -36
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +4 -8
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.d.ts +12 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.js +5 -4
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.d.ts +20 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.js +178 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.js +13 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloAdapterService.js +6 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/error.interface.d.ts +13 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/error.interface.js +8 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/README.md +145 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.d.ts +78 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.js +203 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.js +18 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/package.json +64 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/src/index.ts +345 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/src/promisify.ts +33 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/README.md +137 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.js +177 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.js +14 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/package.json +56 -0
- package/node_modules/@autonomous-testing/sdk/package.json +18 -6
- package/node_modules/agent-base/LICENSE +22 -0
- package/node_modules/agent-base/README.md +69 -0
- package/node_modules/agent-base/dist/helpers.d.ts +15 -0
- package/node_modules/agent-base/dist/helpers.d.ts.map +1 -0
- package/node_modules/agent-base/dist/helpers.js +66 -0
- package/node_modules/agent-base/dist/helpers.js.map +1 -0
- package/node_modules/agent-base/dist/index.d.ts +41 -0
- package/node_modules/agent-base/dist/index.d.ts.map +1 -0
- package/node_modules/agent-base/dist/index.js +178 -0
- package/node_modules/agent-base/dist/index.js.map +1 -0
- package/node_modules/agent-base/package.json +46 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/http-proxy-agent/LICENSE +22 -0
- package/node_modules/http-proxy-agent/README.md +44 -0
- package/node_modules/http-proxy-agent/dist/index.d.ts +44 -0
- package/node_modules/http-proxy-agent/dist/index.d.ts.map +1 -0
- package/node_modules/http-proxy-agent/dist/index.js +148 -0
- package/node_modules/http-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/http-proxy-agent/package.json +47 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/package.json +14 -3
- package/.github/actions/npm_clean_install/action.yaml +0 -35
- package/node_modules/@autonomous-testing/sdk/.github/actions/npm_clean_install/action.yaml +0 -35
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const net_1 = __importDefault(require("net"));
|
|
16
|
+
const tls_1 = __importDefault(require("tls"));
|
|
17
|
+
const url_1 = __importDefault(require("url"));
|
|
18
|
+
const assert_1 = __importDefault(require("assert"));
|
|
19
|
+
const debug_1 = __importDefault(require("debug"));
|
|
20
|
+
const agent_base_1 = require("agent-base");
|
|
21
|
+
const parse_proxy_response_1 = __importDefault(require("./parse-proxy-response"));
|
|
22
|
+
const debug = debug_1.default('https-proxy-agent:agent');
|
|
23
|
+
/**
|
|
24
|
+
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
|
|
25
|
+
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
|
|
26
|
+
*
|
|
27
|
+
* Outgoing HTTP requests are first tunneled through the proxy server using the
|
|
28
|
+
* `CONNECT` HTTP request method to establish a connection to the proxy server,
|
|
29
|
+
* and then the proxy server connects to the destination target and issues the
|
|
30
|
+
* HTTP request from the proxy server.
|
|
31
|
+
*
|
|
32
|
+
* `https:` requests have their socket connection upgraded to TLS once
|
|
33
|
+
* the connection to the proxy server has been established.
|
|
34
|
+
*
|
|
35
|
+
* @api public
|
|
36
|
+
*/
|
|
37
|
+
class HttpsProxyAgent extends agent_base_1.Agent {
|
|
38
|
+
constructor(_opts) {
|
|
39
|
+
let opts;
|
|
40
|
+
if (typeof _opts === 'string') {
|
|
41
|
+
opts = url_1.default.parse(_opts);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
opts = _opts;
|
|
45
|
+
}
|
|
46
|
+
if (!opts) {
|
|
47
|
+
throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
|
|
48
|
+
}
|
|
49
|
+
debug('creating new HttpsProxyAgent instance: %o', opts);
|
|
50
|
+
super(opts);
|
|
51
|
+
const proxy = Object.assign({}, opts);
|
|
52
|
+
// If `true`, then connect to the proxy server over TLS.
|
|
53
|
+
// Defaults to `false`.
|
|
54
|
+
this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
|
|
55
|
+
// Prefer `hostname` over `host`, and set the `port` if needed.
|
|
56
|
+
proxy.host = proxy.hostname || proxy.host;
|
|
57
|
+
if (typeof proxy.port === 'string') {
|
|
58
|
+
proxy.port = parseInt(proxy.port, 10);
|
|
59
|
+
}
|
|
60
|
+
if (!proxy.port && proxy.host) {
|
|
61
|
+
proxy.port = this.secureProxy ? 443 : 80;
|
|
62
|
+
}
|
|
63
|
+
// ALPN is supported by Node.js >= v5.
|
|
64
|
+
// attempt to negotiate http/1.1 for proxy servers that support http/2
|
|
65
|
+
if (this.secureProxy && !('ALPNProtocols' in proxy)) {
|
|
66
|
+
proxy.ALPNProtocols = ['http 1.1'];
|
|
67
|
+
}
|
|
68
|
+
if (proxy.host && proxy.path) {
|
|
69
|
+
// If both a `host` and `path` are specified then it's most likely
|
|
70
|
+
// the result of a `url.parse()` call... we need to remove the
|
|
71
|
+
// `path` portion so that `net.connect()` doesn't attempt to open
|
|
72
|
+
// that as a Unix socket file.
|
|
73
|
+
delete proxy.path;
|
|
74
|
+
delete proxy.pathname;
|
|
75
|
+
}
|
|
76
|
+
this.proxy = proxy;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Called when the node-core HTTP client library is creating a
|
|
80
|
+
* new HTTP request.
|
|
81
|
+
*
|
|
82
|
+
* @api protected
|
|
83
|
+
*/
|
|
84
|
+
callback(req, opts) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const { proxy, secureProxy } = this;
|
|
87
|
+
// Create a socket connection to the proxy server.
|
|
88
|
+
let socket;
|
|
89
|
+
if (secureProxy) {
|
|
90
|
+
debug('Creating `tls.Socket`: %o', proxy);
|
|
91
|
+
socket = tls_1.default.connect(proxy);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
debug('Creating `net.Socket`: %o', proxy);
|
|
95
|
+
socket = net_1.default.connect(proxy);
|
|
96
|
+
}
|
|
97
|
+
const headers = Object.assign({}, proxy.headers);
|
|
98
|
+
const hostname = `${opts.host}:${opts.port}`;
|
|
99
|
+
let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
|
|
100
|
+
// Inject the `Proxy-Authorization` header if necessary.
|
|
101
|
+
if (proxy.auth) {
|
|
102
|
+
headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
|
|
103
|
+
}
|
|
104
|
+
// The `Host` header should only include the port
|
|
105
|
+
// number when it is not the default port.
|
|
106
|
+
let { host, port, secureEndpoint } = opts;
|
|
107
|
+
if (!isDefaultPort(port, secureEndpoint)) {
|
|
108
|
+
host += `:${port}`;
|
|
109
|
+
}
|
|
110
|
+
headers.Host = host;
|
|
111
|
+
headers.Connection = 'close';
|
|
112
|
+
for (const name of Object.keys(headers)) {
|
|
113
|
+
payload += `${name}: ${headers[name]}\r\n`;
|
|
114
|
+
}
|
|
115
|
+
const proxyResponsePromise = parse_proxy_response_1.default(socket);
|
|
116
|
+
socket.write(`${payload}\r\n`);
|
|
117
|
+
const { statusCode, buffered } = yield proxyResponsePromise;
|
|
118
|
+
if (statusCode === 200) {
|
|
119
|
+
req.once('socket', resume);
|
|
120
|
+
if (opts.secureEndpoint) {
|
|
121
|
+
// The proxy is connecting to a TLS server, so upgrade
|
|
122
|
+
// this socket connection to a TLS connection.
|
|
123
|
+
debug('Upgrading socket connection to TLS');
|
|
124
|
+
const servername = opts.servername || opts.host;
|
|
125
|
+
return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
|
|
126
|
+
servername }));
|
|
127
|
+
}
|
|
128
|
+
return socket;
|
|
129
|
+
}
|
|
130
|
+
// Some other status code that's not 200... need to re-play the HTTP
|
|
131
|
+
// header "data" events onto the socket once the HTTP machinery is
|
|
132
|
+
// attached so that the node core `http` can parse and handle the
|
|
133
|
+
// error status code.
|
|
134
|
+
// Close the original socket, and a new "fake" socket is returned
|
|
135
|
+
// instead, so that the proxy doesn't get the HTTP request
|
|
136
|
+
// written to it (which may contain `Authorization` headers or other
|
|
137
|
+
// sensitive data).
|
|
138
|
+
//
|
|
139
|
+
// See: https://hackerone.com/reports/541502
|
|
140
|
+
socket.destroy();
|
|
141
|
+
const fakeSocket = new net_1.default.Socket({ writable: false });
|
|
142
|
+
fakeSocket.readable = true;
|
|
143
|
+
// Need to wait for the "socket" event to re-play the "data" events.
|
|
144
|
+
req.once('socket', (s) => {
|
|
145
|
+
debug('replaying proxy buffer for failed request');
|
|
146
|
+
assert_1.default(s.listenerCount('data') > 0);
|
|
147
|
+
// Replay the "buffered" Buffer onto the fake `socket`, since at
|
|
148
|
+
// this point the HTTP module machinery has been hooked up for
|
|
149
|
+
// the user.
|
|
150
|
+
s.push(buffered);
|
|
151
|
+
s.push(null);
|
|
152
|
+
});
|
|
153
|
+
return fakeSocket;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.default = HttpsProxyAgent;
|
|
158
|
+
function resume(socket) {
|
|
159
|
+
socket.resume();
|
|
160
|
+
}
|
|
161
|
+
function isDefaultPort(port, secure) {
|
|
162
|
+
return Boolean((!secure && port === 80) || (secure && port === 443));
|
|
163
|
+
}
|
|
164
|
+
function isHTTPS(protocol) {
|
|
165
|
+
return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
|
|
166
|
+
}
|
|
167
|
+
function omit(obj, ...keys) {
|
|
168
|
+
const ret = {};
|
|
169
|
+
let key;
|
|
170
|
+
for (key in obj) {
|
|
171
|
+
if (!keys.includes(key)) {
|
|
172
|
+
ret[key] = obj[key];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return ret;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,8CAAsB;AACtB,8CAAsB;AACtB,oDAA4B;AAC5B,kDAAgC;AAEhC,2CAAkE;AAElE,kFAAwD;AAExD,MAAM,KAAK,GAAG,eAAW,CAAC,yBAAyB,CAAC,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAqB,eAAgB,SAAQ,kBAAK;IAIjD,YAAY,KAAsC;QACjD,IAAI,IAA4B,CAAC;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC9B,IAAI,GAAG,aAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACxB;aAAM;YACN,IAAI,GAAG,KAAK,CAAC;SACb;QACD,IAAI,CAAC,IAAI,EAAE;YACV,MAAM,IAAI,KAAK,CACd,8DAA8D,CAC9D,CAAC;SACF;QACD,KAAK,CAAC,2CAA2C,EAAE,IAAI,CAAC,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,MAAM,KAAK,qBAAgC,IAAI,CAAE,CAAC;QAElD,wDAAwD;QACxD,uBAAuB;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/D,+DAA+D;QAC/D,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC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CAAC;AACtE,CAAC;AAED,SAAS,OAAO,CAAC,QAAwB;IACxC,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3E,CAAC;AAED,SAAS,IAAI,CACZ,GAAM,EACN,GAAG,IAAO;IAIV,MAAM,GAAG,GAAG,EAEX,CAAC;IACF,IAAI,GAAqB,CAAC;IAC1B,KAAK,GAAG,IAAI,GAAG,EAAE;QAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;SACpB;KACD;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import net from 'net';
|
|
3
|
+
import tls from 'tls';
|
|
4
|
+
import { Url } from 'url';
|
|
5
|
+
import { AgentOptions } from 'agent-base';
|
|
6
|
+
import { OutgoingHttpHeaders } from 'http';
|
|
7
|
+
import _HttpsProxyAgent from './agent';
|
|
8
|
+
declare function createHttpsProxyAgent(opts: string | createHttpsProxyAgent.HttpsProxyAgentOptions): _HttpsProxyAgent;
|
|
9
|
+
declare namespace createHttpsProxyAgent {
|
|
10
|
+
interface BaseHttpsProxyAgentOptions {
|
|
11
|
+
headers?: OutgoingHttpHeaders;
|
|
12
|
+
secureProxy?: boolean;
|
|
13
|
+
host?: string | null;
|
|
14
|
+
path?: string | null;
|
|
15
|
+
port?: string | number | null;
|
|
16
|
+
}
|
|
17
|
+
export interface HttpsProxyAgentOptions extends AgentOptions, BaseHttpsProxyAgentOptions, Partial<Omit<Url & net.NetConnectOpts & tls.ConnectionOptions, keyof BaseHttpsProxyAgentOptions>> {
|
|
18
|
+
}
|
|
19
|
+
export type HttpsProxyAgent = _HttpsProxyAgent;
|
|
20
|
+
export const HttpsProxyAgent: typeof _HttpsProxyAgent;
|
|
21
|
+
export {};
|
|
22
|
+
}
|
|
23
|
+
export = createHttpsProxyAgent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const agent_1 = __importDefault(require("./agent"));
|
|
6
|
+
function createHttpsProxyAgent(opts) {
|
|
7
|
+
return new agent_1.default(opts);
|
|
8
|
+
}
|
|
9
|
+
(function (createHttpsProxyAgent) {
|
|
10
|
+
createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
|
|
11
|
+
createHttpsProxyAgent.prototype = agent_1.default.prototype;
|
|
12
|
+
})(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
|
|
13
|
+
module.exports = createHttpsProxyAgent;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAKA,oDAAuC;AAEvC,SAAS,qBAAqB,CAC7B,IAA2D;IAE3D,OAAO,IAAI,eAAgB,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,WAAU,qBAAqB;IAoBjB,qCAAe,GAAG,eAAgB,CAAC;IAEhD,qBAAqB,CAAC,SAAS,GAAG,eAAgB,CAAC,SAAS,CAAC;AAC9D,CAAC,EAvBS,qBAAqB,KAArB,qBAAqB,QAuB9B;AAED,iBAAS,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const debug_1 = __importDefault(require("debug"));
|
|
7
|
+
const debug = debug_1.default('https-proxy-agent:parse-proxy-response');
|
|
8
|
+
function parseProxyResponse(socket) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
// we need to buffer any HTTP traffic that happens with the proxy before we get
|
|
11
|
+
// the CONNECT response, so that if the response is anything other than an "200"
|
|
12
|
+
// response code, then we can re-play the "data" events on the socket once the
|
|
13
|
+
// HTTP parser is hooked up...
|
|
14
|
+
let buffersLength = 0;
|
|
15
|
+
const buffers = [];
|
|
16
|
+
function read() {
|
|
17
|
+
const b = socket.read();
|
|
18
|
+
if (b)
|
|
19
|
+
ondata(b);
|
|
20
|
+
else
|
|
21
|
+
socket.once('readable', read);
|
|
22
|
+
}
|
|
23
|
+
function cleanup() {
|
|
24
|
+
socket.removeListener('end', onend);
|
|
25
|
+
socket.removeListener('error', onerror);
|
|
26
|
+
socket.removeListener('close', onclose);
|
|
27
|
+
socket.removeListener('readable', read);
|
|
28
|
+
}
|
|
29
|
+
function onclose(err) {
|
|
30
|
+
debug('onclose had error %o', err);
|
|
31
|
+
}
|
|
32
|
+
function onend() {
|
|
33
|
+
debug('onend');
|
|
34
|
+
}
|
|
35
|
+
function onerror(err) {
|
|
36
|
+
cleanup();
|
|
37
|
+
debug('onerror %o', err);
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
function ondata(b) {
|
|
41
|
+
buffers.push(b);
|
|
42
|
+
buffersLength += b.length;
|
|
43
|
+
const buffered = Buffer.concat(buffers, buffersLength);
|
|
44
|
+
const endOfHeaders = buffered.indexOf('\r\n\r\n');
|
|
45
|
+
if (endOfHeaders === -1) {
|
|
46
|
+
// keep buffering
|
|
47
|
+
debug('have not received end of HTTP headers yet...');
|
|
48
|
+
read();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
|
|
52
|
+
const statusCode = +firstLine.split(' ')[1];
|
|
53
|
+
debug('got proxy server response: %o', firstLine);
|
|
54
|
+
resolve({
|
|
55
|
+
statusCode,
|
|
56
|
+
buffered
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
socket.on('error', onerror);
|
|
60
|
+
socket.on('close', onclose);
|
|
61
|
+
socket.on('end', onend);
|
|
62
|
+
read();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.default = parseProxyResponse;
|
|
66
|
+
//# sourceMappingURL=parse-proxy-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-proxy-response.js","sourceRoot":"","sources":["../src/parse-proxy-response.ts"],"names":[],"mappings":";;;;;AAAA,kDAAgC;AAGhC,MAAM,KAAK,GAAG,eAAW,CAAC,wCAAwC,CAAC,CAAC;AAOpE,SAAwB,kBAAkB,CACzC,MAAgB;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,+EAA+E;QAC/E,gFAAgF;QAChF,8EAA8E;QAC9E,8BAA8B;QAC9B,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,MAAM,OAAO,GAAa,EAAE,CAAC;QAE7B,SAAS,IAAI;YACZ,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC;gBAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;gBACZ,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACpC,CAAC;QAED,SAAS,OAAO;YACf,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QAED,SAAS,OAAO,CAAC,GAAW;YAC3B,KAAK,CAAC,sBAAsB,EAAE,GAAG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}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "https-proxy-agent",
|
|
3
|
+
"version": "5.0.1",
|
|
4
|
+
"description": "An HTTP(s) proxy `http.Agent` implementation for HTTPS",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prebuild": "rimraf dist",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "mocha --reporter spec",
|
|
14
|
+
"test-lint": "eslint src --ext .js,.ts",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git://github.com/TooTallNate/node-https-proxy-agent.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"https",
|
|
23
|
+
"proxy",
|
|
24
|
+
"endpoint",
|
|
25
|
+
"agent"
|
|
26
|
+
],
|
|
27
|
+
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/TooTallNate/node-https-proxy-agent/issues"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"agent-base": "6",
|
|
34
|
+
"debug": "4"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/debug": "4",
|
|
38
|
+
"@types/node": "^12.12.11",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "1.6.0",
|
|
40
|
+
"@typescript-eslint/parser": "1.1.0",
|
|
41
|
+
"eslint": "5.16.0",
|
|
42
|
+
"eslint-config-airbnb": "17.1.0",
|
|
43
|
+
"eslint-config-prettier": "4.1.0",
|
|
44
|
+
"eslint-import-resolver-typescript": "1.1.1",
|
|
45
|
+
"eslint-plugin-import": "2.16.0",
|
|
46
|
+
"eslint-plugin-jsx-a11y": "6.2.1",
|
|
47
|
+
"eslint-plugin-react": "7.12.4",
|
|
48
|
+
"mocha": "^6.2.2",
|
|
49
|
+
"proxy": "1",
|
|
50
|
+
"rimraf": "^3.0.0",
|
|
51
|
+
"typescript": "^3.5.3"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">= 6"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomous-testing/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:win": "rm -rf ./build/ && npx tsc && node utils/addVersionToBuild.mjs"
|
|
6
6
|
},
|
|
7
|
+
"description": "JavaScript/TypeScript SDK for Wopee.io autonomous testing platform — integrate visual and functional testing into your apps",
|
|
7
8
|
"author": "Ondrej Winter <me@ondrejwinter.com>",
|
|
8
9
|
"license": "PROPRIETARY",
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
10
|
+
"homepage": "https://docs.wopee.io/",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"wopee",
|
|
13
|
+
"wopee.io",
|
|
14
|
+
"testing sdk",
|
|
15
|
+
"visual testing",
|
|
16
|
+
"autonomous testing",
|
|
17
|
+
"test automation",
|
|
18
|
+
"ai testing",
|
|
19
|
+
"javascript",
|
|
20
|
+
"typescript",
|
|
21
|
+
"sdk"
|
|
22
|
+
],
|
|
13
23
|
"publishConfig": {
|
|
14
24
|
"registry": "https://npm.pkg.github.com",
|
|
15
25
|
"tag": "dev"
|
|
@@ -19,6 +29,8 @@
|
|
|
19
29
|
"type": "commonjs",
|
|
20
30
|
"dependencies": {
|
|
21
31
|
"axios": "0.30.0",
|
|
32
|
+
"http-proxy-agent": "^7.0.2",
|
|
33
|
+
"https-proxy-agent": "^5.0.1",
|
|
22
34
|
"process": "^0.11.10",
|
|
23
35
|
"proxy-from-env": "^1.1.0",
|
|
24
36
|
"zod": "^3.23.0"
|
|
@@ -37,7 +49,7 @@
|
|
|
37
49
|
"@types/node": "^20.12.7",
|
|
38
50
|
"@types/proxy-from-env": "^1.0.4",
|
|
39
51
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
40
|
-
"canvas": "^2.
|
|
52
|
+
"canvas": "^3.2.0",
|
|
41
53
|
"copyfiles": "^2.4.1",
|
|
42
54
|
"crypto": "^1.0.1",
|
|
43
55
|
"dotenv": "^16.4.5",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
agent-base
|
|
2
|
+
==========
|
|
3
|
+
### Turn a function into an [`http.Agent`][http.Agent] instance
|
|
4
|
+
|
|
5
|
+
This module is a thin wrapper around the base `http.Agent` class.
|
|
6
|
+
|
|
7
|
+
It provides an abstract class that must define a `connect()` function,
|
|
8
|
+
which is responsible for creating the underlying socket that the HTTP
|
|
9
|
+
client requests will use.
|
|
10
|
+
|
|
11
|
+
The `connect()` function may return an arbitrary `Duplex` stream, or
|
|
12
|
+
another `http.Agent` instance to delegate the request to, and may be
|
|
13
|
+
asynchronous (by defining an `async` function).
|
|
14
|
+
|
|
15
|
+
Instances of this agent can be used with the `http` and `https`
|
|
16
|
+
modules. To differentiate, the options parameter in the `connect()`
|
|
17
|
+
function includes a `secureEndpoint` property, which can be checked
|
|
18
|
+
to determine what type of socket should be returned.
|
|
19
|
+
|
|
20
|
+
#### Some subclasses:
|
|
21
|
+
|
|
22
|
+
Here are some more interesting uses of `agent-base`.
|
|
23
|
+
Send a pull request to list yours!
|
|
24
|
+
|
|
25
|
+
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
|
26
|
+
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
|
27
|
+
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
|
28
|
+
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
|
29
|
+
|
|
30
|
+
Example
|
|
31
|
+
-------
|
|
32
|
+
|
|
33
|
+
Here's a minimal example that creates a new `net.Socket` or `tls.Socket`
|
|
34
|
+
based on the `secureEndpoint` property. This agent can be used with both
|
|
35
|
+
the `http` and `https` modules.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import * as net from 'net';
|
|
39
|
+
import * as tls from 'tls';
|
|
40
|
+
import * as http from 'http';
|
|
41
|
+
import { Agent } from 'agent-base';
|
|
42
|
+
|
|
43
|
+
class MyAgent extends Agent {
|
|
44
|
+
connect(req, opts) {
|
|
45
|
+
// `secureEndpoint` is true when using the "https" module
|
|
46
|
+
if (opts.secureEndpoint) {
|
|
47
|
+
return tls.connect(opts);
|
|
48
|
+
} else {
|
|
49
|
+
return net.connect(opts);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Keep alive enabled means that `connect()` will only be
|
|
55
|
+
// invoked when a new connection needs to be created
|
|
56
|
+
const agent = new MyAgent({ keepAlive: true });
|
|
57
|
+
|
|
58
|
+
// Pass the `agent` option when creating the HTTP request
|
|
59
|
+
http.get('http://nodejs.org/api/', { agent }, (res) => {
|
|
60
|
+
console.log('"response" event!', res.headers);
|
|
61
|
+
res.pipe(process.stdout);
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
[http-proxy-agent]: ../http-proxy-agent
|
|
66
|
+
[https-proxy-agent]: ../https-proxy-agent
|
|
67
|
+
[pac-proxy-agent]: ../pac-proxy-agent
|
|
68
|
+
[socks-proxy-agent]: ../socks-proxy-agent
|
|
69
|
+
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
import * as http from 'http';
|
|
7
|
+
import * as https from 'https';
|
|
8
|
+
import type { Readable } from 'stream';
|
|
9
|
+
export type ThenableRequest = http.ClientRequest & {
|
|
10
|
+
then: Promise<http.IncomingMessage>['then'];
|
|
11
|
+
};
|
|
12
|
+
export declare function toBuffer(stream: Readable): Promise<Buffer>;
|
|
13
|
+
export declare function json(stream: Readable): Promise<any>;
|
|
14
|
+
export declare function req(url: string | URL, opts?: https.RequestOptions): ThenableRequest;
|
|
15
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,GAAG;IAClD,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhE;AAGD,wBAAsB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAUzD;AAED,wBAAgB,GAAG,CAClB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,GAAE,KAAK,CAAC,cAAmB,GAC7B,eAAe,CAcjB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.req = exports.json = exports.toBuffer = void 0;
|
|
27
|
+
const http = __importStar(require("http"));
|
|
28
|
+
const https = __importStar(require("https"));
|
|
29
|
+
async function toBuffer(stream) {
|
|
30
|
+
let length = 0;
|
|
31
|
+
const chunks = [];
|
|
32
|
+
for await (const chunk of stream) {
|
|
33
|
+
length += chunk.length;
|
|
34
|
+
chunks.push(chunk);
|
|
35
|
+
}
|
|
36
|
+
return Buffer.concat(chunks, length);
|
|
37
|
+
}
|
|
38
|
+
exports.toBuffer = toBuffer;
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
async function json(stream) {
|
|
41
|
+
const buf = await toBuffer(stream);
|
|
42
|
+
const str = buf.toString('utf8');
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(str);
|
|
45
|
+
}
|
|
46
|
+
catch (_err) {
|
|
47
|
+
const err = _err;
|
|
48
|
+
err.message += ` (input: ${str})`;
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.json = json;
|
|
53
|
+
function req(url, opts = {}) {
|
|
54
|
+
const href = typeof url === 'string' ? url : url.href;
|
|
55
|
+
const req = (href.startsWith('https:') ? https : http).request(url, opts);
|
|
56
|
+
const promise = new Promise((resolve, reject) => {
|
|
57
|
+
req
|
|
58
|
+
.once('response', resolve)
|
|
59
|
+
.once('error', reject)
|
|
60
|
+
.end();
|
|
61
|
+
});
|
|
62
|
+
req.then = promise.then.bind(promise);
|
|
63
|
+
return req;
|
|
64
|
+
}
|
|
65
|
+
exports.req = req;
|
|
66
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,6CAA+B;AAOxB,KAAK,UAAU,QAAQ,CAAC,MAAgB;IAC9C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACnB;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AARD,4BAQC;AAED,8DAA8D;AACvD,KAAK,UAAU,IAAI,CAAC,MAAgB;IAC1C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACvB;IAAC,OAAO,IAAa,EAAE;QACvB,MAAM,GAAG,GAAG,IAAa,CAAC;QAC1B,GAAG,CAAC,OAAO,IAAI,YAAY,GAAG,GAAG,CAAC;QAClC,MAAM,GAAG,CAAC;KACV;AACF,CAAC;AAVD,oBAUC;AAED,SAAgB,GAAG,CAClB,GAAiB,EACjB,OAA6B,EAAE;IAE/B,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACtD,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAC7D,GAAG,EACH,IAAI,CACe,CAAC;IACrB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrE,GAAG;aACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC;aACzB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aACrB,GAAG,EAAqB,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACZ,CAAC;AAjBD,kBAiBC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import * as net from 'net';
|
|
6
|
+
import * as tls from 'tls';
|
|
7
|
+
import * as http from 'http';
|
|
8
|
+
import type { Duplex } from 'stream';
|
|
9
|
+
export * from './helpers';
|
|
10
|
+
interface HttpConnectOpts extends net.TcpNetConnectOpts {
|
|
11
|
+
secureEndpoint: false;
|
|
12
|
+
protocol?: string;
|
|
13
|
+
}
|
|
14
|
+
interface HttpsConnectOpts extends tls.ConnectionOptions {
|
|
15
|
+
secureEndpoint: true;
|
|
16
|
+
protocol?: string;
|
|
17
|
+
port: number;
|
|
18
|
+
}
|
|
19
|
+
export type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
|
|
20
|
+
declare const INTERNAL: unique symbol;
|
|
21
|
+
export declare abstract class Agent extends http.Agent {
|
|
22
|
+
private [INTERNAL];
|
|
23
|
+
options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
|
|
24
|
+
keepAlive: boolean;
|
|
25
|
+
constructor(opts?: http.AgentOptions);
|
|
26
|
+
abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
|
|
27
|
+
/**
|
|
28
|
+
* Determine whether this is an `http` or `https` request.
|
|
29
|
+
*/
|
|
30
|
+
isSecureEndpoint(options?: AgentConnectOpts): boolean;
|
|
31
|
+
private incrementSockets;
|
|
32
|
+
private decrementSockets;
|
|
33
|
+
getName(options?: AgentConnectOpts): string;
|
|
34
|
+
createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
|
|
35
|
+
createConnection(): Duplex;
|
|
36
|
+
get defaultPort(): number;
|
|
37
|
+
set defaultPort(v: number);
|
|
38
|
+
get protocol(): string;
|
|
39
|
+
set protocol(v: string);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,cAAc,WAAW,CAAC;AAE1B,UAAU,eAAgB,SAAQ,GAAG,CAAC,iBAAiB;IACtD,cAAc,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IACvD,cAAc,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb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