```
@types/node ^18.16.3 → ^20.1.1 @types/semver ^7.3.13 → ^7.5.0 @typescript-eslint/parser ^5.59.2 → ^5.59.5 eslint ^8.39.0 → ^8.40.0 https-proxy-agent ^5.0.1 → ^6.1.0 webpack ^5.81.0 → ^5.82.0 ```
This commit is contained in:
+323
-377
@@ -10171,238 +10171,175 @@ exports.request = request;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9690:
|
||||
/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
|
||||
/***/ 8348:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
const events_1 = __nccwpck_require__(2361);
|
||||
const debug_1 = __importDefault(__nccwpck_require__(8237));
|
||||
const promisify_1 = __importDefault(__nccwpck_require__(6570));
|
||||
const debug = debug_1.default('agent-base');
|
||||
function isAgent(v) {
|
||||
return Boolean(v) && typeof v.addRequest === 'function';
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.req = exports.json = exports.toBuffer = void 0;
|
||||
const http = __importStar(__nccwpck_require__(3685));
|
||||
const https = __importStar(__nccwpck_require__(5687));
|
||||
async function toBuffer(stream) {
|
||||
let length = 0;
|
||||
const chunks = [];
|
||||
for await (const chunk of stream) {
|
||||
length += chunk.length;
|
||||
chunks.push(chunk);
|
||||
}
|
||||
return Buffer.concat(chunks, length);
|
||||
}
|
||||
exports.toBuffer = toBuffer;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async function json(stream) {
|
||||
const buf = await toBuffer(stream);
|
||||
const str = buf.toString('utf8');
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
}
|
||||
catch (_err) {
|
||||
const err = _err;
|
||||
err.message += ` (input: ${str})`;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
exports.json = json;
|
||||
function req(url, opts = {}) {
|
||||
let req;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const href = typeof url === 'string' ? url : url.href;
|
||||
req = (href.startsWith('https:') ? https : http)
|
||||
.request(url, opts, resolve)
|
||||
.once('error', reject)
|
||||
.end();
|
||||
});
|
||||
req.then = promise.then.bind(promise);
|
||||
return req;
|
||||
}
|
||||
exports.req = req;
|
||||
//# sourceMappingURL=helpers.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 694:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Agent = void 0;
|
||||
const http = __importStar(__nccwpck_require__(3685));
|
||||
__exportStar(__nccwpck_require__(8348), exports);
|
||||
function isSecureEndpoint() {
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string')
|
||||
return false;
|
||||
return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
|
||||
return stack
|
||||
.split('\n')
|
||||
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
||||
l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
function createAgent(callback, opts) {
|
||||
return new createAgent.Agent(callback, opts);
|
||||
}
|
||||
(function (createAgent) {
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
class Agent extends events_1.EventEmitter {
|
||||
constructor(callback, _opts) {
|
||||
super();
|
||||
let opts = _opts;
|
||||
if (typeof callback === 'function') {
|
||||
this.callback = callback;
|
||||
}
|
||||
else if (callback) {
|
||||
opts = callback;
|
||||
}
|
||||
// Timeout for the socket to be returned from the callback
|
||||
this.timeout = null;
|
||||
if (opts && typeof opts.timeout === 'number') {
|
||||
this.timeout = opts.timeout;
|
||||
}
|
||||
// These aren't actually used by `agent-base`, but are required
|
||||
// for the TypeScript definition files in `@types/node` :/
|
||||
this.maxFreeSockets = 1;
|
||||
this.maxSockets = 1;
|
||||
this.maxTotalSockets = Infinity;
|
||||
this.sockets = {};
|
||||
this.freeSockets = {};
|
||||
this.requests = {};
|
||||
this.options = {};
|
||||
}
|
||||
get defaultPort() {
|
||||
if (typeof this.explicitDefaultPort === 'number') {
|
||||
return this.explicitDefaultPort;
|
||||
}
|
||||
return isSecureEndpoint() ? 443 : 80;
|
||||
}
|
||||
set defaultPort(v) {
|
||||
this.explicitDefaultPort = v;
|
||||
}
|
||||
get protocol() {
|
||||
if (typeof this.explicitProtocol === 'string') {
|
||||
return this.explicitProtocol;
|
||||
}
|
||||
return isSecureEndpoint() ? 'https:' : 'http:';
|
||||
}
|
||||
set protocol(v) {
|
||||
this.explicitProtocol = v;
|
||||
}
|
||||
callback(req, opts, fn) {
|
||||
throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
|
||||
}
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
addRequest(req, _opts) {
|
||||
const opts = Object.assign({}, _opts);
|
||||
if (typeof opts.secureEndpoint !== 'boolean') {
|
||||
opts.secureEndpoint = isSecureEndpoint();
|
||||
}
|
||||
if (opts.host == null) {
|
||||
opts.host = 'localhost';
|
||||
}
|
||||
if (opts.port == null) {
|
||||
opts.port = opts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
if (opts.protocol == null) {
|
||||
opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
|
||||
}
|
||||
if (opts.host && opts.path) {
|
||||
// If both a `host` and `path` are specified then it's most
|
||||
// likely the result of a `url.parse()` call... we need to
|
||||
// remove the `path` portion so that `net.connect()` doesn't
|
||||
// attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
// Hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
let timedOut = false;
|
||||
let timeoutId = null;
|
||||
const timeoutMs = opts.timeout || this.timeout;
|
||||
const onerror = (err) => {
|
||||
if (req._hadError)
|
||||
return;
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
};
|
||||
const ontimeout = () => {
|
||||
timeoutId = null;
|
||||
timedOut = true;
|
||||
const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
|
||||
err.code = 'ETIMEOUT';
|
||||
onerror(err);
|
||||
};
|
||||
const callbackError = (err) => {
|
||||
if (timedOut)
|
||||
return;
|
||||
if (timeoutId !== null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
onerror(err);
|
||||
};
|
||||
const onsocket = (socket) => {
|
||||
if (timedOut)
|
||||
return;
|
||||
if (timeoutId != null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
if (isAgent(socket)) {
|
||||
// `socket` is actually an `http.Agent` instance, so
|
||||
// relinquish responsibility for this `req` to the Agent
|
||||
// from here on
|
||||
debug('Callback returned another Agent instance %o', socket.constructor.name);
|
||||
socket.addRequest(req, opts);
|
||||
return;
|
||||
}
|
||||
if (socket) {
|
||||
socket.once('free', () => {
|
||||
this.freeSocket(socket, opts);
|
||||
});
|
||||
req.onSocket(socket);
|
||||
return;
|
||||
}
|
||||
const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
|
||||
onerror(err);
|
||||
};
|
||||
if (typeof this.callback !== 'function') {
|
||||
onerror(new Error('`callback` is not defined'));
|
||||
return;
|
||||
}
|
||||
if (!this.promisifiedCallback) {
|
||||
if (this.callback.length >= 3) {
|
||||
debug('Converting legacy callback function to promise');
|
||||
this.promisifiedCallback = promisify_1.default(this.callback);
|
||||
}
|
||||
else {
|
||||
this.promisifiedCallback = this.callback;
|
||||
}
|
||||
}
|
||||
if (typeof timeoutMs === 'number' && timeoutMs > 0) {
|
||||
timeoutId = setTimeout(ontimeout, timeoutMs);
|
||||
}
|
||||
if ('port' in opts && typeof opts.port !== 'number') {
|
||||
opts.port = Number(opts.port);
|
||||
}
|
||||
try {
|
||||
debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
|
||||
Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
|
||||
}
|
||||
catch (err) {
|
||||
Promise.reject(err).catch(callbackError);
|
||||
}
|
||||
}
|
||||
freeSocket(socket, opts) {
|
||||
debug('Freeing socket %o %o', socket.constructor.name, opts);
|
||||
socket.destroy();
|
||||
}
|
||||
destroy() {
|
||||
debug('Destroying agent %o', this.constructor.name);
|
||||
}
|
||||
class Agent extends http.Agent {
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
this._defaultPort = undefined;
|
||||
this._protocol = undefined;
|
||||
}
|
||||
createSocket(req, options, cb) {
|
||||
const o = {
|
||||
...options,
|
||||
secureEndpoint: options.secureEndpoint ?? isSecureEndpoint(),
|
||||
};
|
||||
Promise.resolve()
|
||||
.then(() => this.connect(req, o))
|
||||
.then((socket) => {
|
||||
if (socket instanceof http.Agent) {
|
||||
// @ts-expect-error `addRequest()` isn't defined in `@types/node`
|
||||
return socket.addRequest(req, o);
|
||||
}
|
||||
this._currentSocket = socket;
|
||||
// @ts-expect-error `createSocket()` isn't defined in `@types/node`
|
||||
super.createSocket(req, options, cb);
|
||||
}, cb);
|
||||
}
|
||||
createConnection() {
|
||||
if (!this._currentSocket) {
|
||||
throw new Error('no socket');
|
||||
}
|
||||
return this._currentSocket;
|
||||
}
|
||||
get defaultPort() {
|
||||
if (typeof this._defaultPort === 'number') {
|
||||
return this._defaultPort;
|
||||
}
|
||||
const port = this.protocol === 'https:' ? 443 : 80;
|
||||
return port;
|
||||
}
|
||||
set defaultPort(v) {
|
||||
this._defaultPort = v;
|
||||
}
|
||||
get protocol() {
|
||||
if (typeof this._protocol === 'string') {
|
||||
return this._protocol;
|
||||
}
|
||||
const p = isSecureEndpoint() ? 'https:' : 'http:';
|
||||
return p;
|
||||
}
|
||||
set protocol(v) {
|
||||
this._protocol = v;
|
||||
}
|
||||
createAgent.Agent = Agent;
|
||||
// So that `instanceof` works correctly
|
||||
createAgent.prototype = createAgent.Agent.prototype;
|
||||
})(createAgent || (createAgent = {}));
|
||||
module.exports = createAgent;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6570:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
function promisify(fn) {
|
||||
return function (req, opts) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn.call(this, req, opts, (err, rtn) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(rtn);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
exports["default"] = promisify;
|
||||
//# sourceMappingURL=promisify.js.map
|
||||
exports.Agent = Agent;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -11471,32 +11408,46 @@ module.exports = (flag, argv = process.argv) => {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3734:
|
||||
/***/ 7219:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const net_1 = __importDefault(__nccwpck_require__(1808));
|
||||
const tls_1 = __importDefault(__nccwpck_require__(4404));
|
||||
const url_1 = __importDefault(__nccwpck_require__(7310));
|
||||
exports.HttpsProxyAgent = void 0;
|
||||
const net = __importStar(__nccwpck_require__(1808));
|
||||
const tls = __importStar(__nccwpck_require__(4404));
|
||||
const assert_1 = __importDefault(__nccwpck_require__(9491));
|
||||
const debug_1 = __importDefault(__nccwpck_require__(8237));
|
||||
const agent_base_1 = __nccwpck_require__(9690);
|
||||
const parse_proxy_response_1 = __importDefault(__nccwpck_require__(595));
|
||||
const debug = debug_1.default('https-proxy-agent:agent');
|
||||
const agent_base_1 = __nccwpck_require__(694);
|
||||
const parse_proxy_response_1 = __nccwpck_require__(595);
|
||||
const debug = (0, debug_1.default)('https-proxy-agent');
|
||||
/**
|
||||
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
|
||||
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
|
||||
@@ -11508,136 +11459,119 @@ const debug = debug_1.default('https-proxy-agent:agent');
|
||||
*
|
||||
* `https:` requests have their socket connection upgraded to TLS once
|
||||
* the connection to the proxy server has been established.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
class HttpsProxyAgent extends agent_base_1.Agent {
|
||||
constructor(_opts) {
|
||||
let opts;
|
||||
if (typeof _opts === 'string') {
|
||||
opts = url_1.default.parse(_opts);
|
||||
}
|
||||
else {
|
||||
opts = _opts;
|
||||
}
|
||||
if (!opts) {
|
||||
throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
|
||||
}
|
||||
debug('creating new HttpsProxyAgent instance: %o', opts);
|
||||
get secureProxy() {
|
||||
return isHTTPS(this.proxy.protocol);
|
||||
}
|
||||
constructor(proxy, opts) {
|
||||
super(opts);
|
||||
const proxy = Object.assign({}, opts);
|
||||
// If `true`, then connect to the proxy server over TLS.
|
||||
// Defaults to `false`.
|
||||
this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
|
||||
// Prefer `hostname` over `host`, and set the `port` if needed.
|
||||
proxy.host = proxy.hostname || proxy.host;
|
||||
if (typeof proxy.port === 'string') {
|
||||
proxy.port = parseInt(proxy.port, 10);
|
||||
}
|
||||
if (!proxy.port && proxy.host) {
|
||||
proxy.port = this.secureProxy ? 443 : 80;
|
||||
}
|
||||
// ALPN is supported by Node.js >= v5.
|
||||
// attempt to negotiate http/1.1 for proxy servers that support http/2
|
||||
if (this.secureProxy && !('ALPNProtocols' in proxy)) {
|
||||
proxy.ALPNProtocols = ['http 1.1'];
|
||||
}
|
||||
if (proxy.host && proxy.path) {
|
||||
// If both a `host` and `path` are specified then it's most likely
|
||||
// the result of a `url.parse()` call... we need to remove the
|
||||
// `path` portion so that `net.connect()` doesn't attempt to open
|
||||
// that as a Unix socket file.
|
||||
delete proxy.path;
|
||||
delete proxy.pathname;
|
||||
}
|
||||
this.proxy = proxy;
|
||||
this.options = { path: undefined };
|
||||
this.proxy = typeof proxy === 'string' ? new URL(proxy) : proxy;
|
||||
this.proxyHeaders = opts?.headers ?? {};
|
||||
debug('Creating new HttpsProxyAgent instance: %o', this.proxy.href);
|
||||
// Trim off the brackets from IPv6 addresses
|
||||
const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, '');
|
||||
const port = this.proxy.port
|
||||
? parseInt(this.proxy.port, 10)
|
||||
: this.secureProxy
|
||||
? 443
|
||||
: 80;
|
||||
this.connectOpts = {
|
||||
// Attempt to negotiate http/1.1 for proxy servers that support http/2
|
||||
ALPNProtocols: ['http/1.1'],
|
||||
...(opts ? omit(opts, 'headers') : null),
|
||||
host,
|
||||
port,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Called when the node-core HTTP client library is creating a
|
||||
* new HTTP request.
|
||||
*
|
||||
* @api protected
|
||||
*/
|
||||
callback(req, opts) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { proxy, secureProxy } = this;
|
||||
// Create a socket connection to the proxy server.
|
||||
let socket;
|
||||
if (secureProxy) {
|
||||
debug('Creating `tls.Socket`: %o', proxy);
|
||||
socket = tls_1.default.connect(proxy);
|
||||
async connect(req, opts) {
|
||||
const { proxy, secureProxy } = this;
|
||||
if (!opts.host) {
|
||||
throw new TypeError('No "host" provided');
|
||||
}
|
||||
// Create a socket connection to the proxy server.
|
||||
let socket;
|
||||
if (secureProxy) {
|
||||
debug('Creating `tls.Socket`: %o', this.connectOpts);
|
||||
socket = tls.connect(this.connectOpts);
|
||||
}
|
||||
else {
|
||||
debug('Creating `net.Socket`: %o', this.connectOpts);
|
||||
socket = net.connect(this.connectOpts);
|
||||
}
|
||||
const headers = { ...this.proxyHeaders };
|
||||
const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
||||
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
|
||||
// Inject the `Proxy-Authorization` header if necessary.
|
||||
if (proxy.username || proxy.password) {
|
||||
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
||||
headers['Proxy-Authorization'] = `Basic ${Buffer.from(auth).toString('base64')}`;
|
||||
}
|
||||
headers.Host = `${host}:${opts.port}`;
|
||||
if (!headers['Proxy-Connection']) {
|
||||
headers['Proxy-Connection'] = this.keepAlive
|
||||
? 'Keep-Alive'
|
||||
: 'close';
|
||||
}
|
||||
for (const name of Object.keys(headers)) {
|
||||
payload += `${name}: ${headers[name]}\r\n`;
|
||||
}
|
||||
const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
|
||||
socket.write(`${payload}\r\n`);
|
||||
const { connect, buffered } = await proxyResponsePromise;
|
||||
req.emit('proxyConnect', connect);
|
||||
this.emit('proxyConnect', connect, req);
|
||||
if (connect.statusCode === 200) {
|
||||
req.once('socket', resume);
|
||||
if (opts.secureEndpoint) {
|
||||
// The proxy is connecting to a TLS server, so upgrade
|
||||
// this socket connection to a TLS connection.
|
||||
debug('Upgrading socket connection to TLS');
|
||||
const servername = opts.servername || opts.host;
|
||||
return tls.connect({
|
||||
...omit(opts, 'host', 'path', 'port'),
|
||||
socket,
|
||||
servername: net.isIP(servername) ? undefined : servername,
|
||||
});
|
||||
}
|
||||
else {
|
||||
debug('Creating `net.Socket`: %o', proxy);
|
||||
socket = net_1.default.connect(proxy);
|
||||
}
|
||||
const headers = Object.assign({}, proxy.headers);
|
||||
const hostname = `${opts.host}:${opts.port}`;
|
||||
let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
|
||||
// Inject the `Proxy-Authorization` header if necessary.
|
||||
if (proxy.auth) {
|
||||
headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
|
||||
}
|
||||
// The `Host` header should only include the port
|
||||
// number when it is not the default port.
|
||||
let { host, port, secureEndpoint } = opts;
|
||||
if (!isDefaultPort(port, secureEndpoint)) {
|
||||
host += `:${port}`;
|
||||
}
|
||||
headers.Host = host;
|
||||
headers.Connection = 'close';
|
||||
for (const name of Object.keys(headers)) {
|
||||
payload += `${name}: ${headers[name]}\r\n`;
|
||||
}
|
||||
const proxyResponsePromise = parse_proxy_response_1.default(socket);
|
||||
socket.write(`${payload}\r\n`);
|
||||
const { statusCode, buffered } = yield proxyResponsePromise;
|
||||
if (statusCode === 200) {
|
||||
req.once('socket', resume);
|
||||
if (opts.secureEndpoint) {
|
||||
// The proxy is connecting to a TLS server, so upgrade
|
||||
// this socket connection to a TLS connection.
|
||||
debug('Upgrading socket connection to TLS');
|
||||
const servername = opts.servername || opts.host;
|
||||
return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
|
||||
servername }));
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
// Some other status code that's not 200... need to re-play the HTTP
|
||||
// header "data" events onto the socket once the HTTP machinery is
|
||||
// attached so that the node core `http` can parse and handle the
|
||||
// error status code.
|
||||
// Close the original socket, and a new "fake" socket is returned
|
||||
// instead, so that the proxy doesn't get the HTTP request
|
||||
// written to it (which may contain `Authorization` headers or other
|
||||
// sensitive data).
|
||||
//
|
||||
// See: https://hackerone.com/reports/541502
|
||||
socket.destroy();
|
||||
const fakeSocket = new net_1.default.Socket({ writable: false });
|
||||
fakeSocket.readable = true;
|
||||
// Need to wait for the "socket" event to re-play the "data" events.
|
||||
req.once('socket', (s) => {
|
||||
debug('replaying proxy buffer for failed request');
|
||||
assert_1.default(s.listenerCount('data') > 0);
|
||||
// Replay the "buffered" Buffer onto the fake `socket`, since at
|
||||
// this point the HTTP module machinery has been hooked up for
|
||||
// the user.
|
||||
s.push(buffered);
|
||||
s.push(null);
|
||||
});
|
||||
return fakeSocket;
|
||||
return socket;
|
||||
}
|
||||
// Some other status code that's not 200... need to re-play the HTTP
|
||||
// header "data" events onto the socket once the HTTP machinery is
|
||||
// attached so that the node core `http` can parse and handle the
|
||||
// error status code.
|
||||
// Close the original socket, and a new "fake" socket is returned
|
||||
// instead, so that the proxy doesn't get the HTTP request
|
||||
// written to it (which may contain `Authorization` headers or other
|
||||
// sensitive data).
|
||||
//
|
||||
// See: https://hackerone.com/reports/541502
|
||||
socket.destroy();
|
||||
const fakeSocket = new net.Socket({ writable: false });
|
||||
fakeSocket.readable = true;
|
||||
// Need to wait for the "socket" event to re-play the "data" events.
|
||||
req.once('socket', (s) => {
|
||||
debug('Replaying proxy buffer for failed request');
|
||||
(0, assert_1.default)(s.listenerCount('data') > 0);
|
||||
// Replay the "buffered" Buffer onto the fake `socket`, since at
|
||||
// this point the HTTP module machinery has been hooked up for
|
||||
// the user.
|
||||
s.push(buffered);
|
||||
s.push(null);
|
||||
});
|
||||
return fakeSocket;
|
||||
}
|
||||
}
|
||||
exports["default"] = HttpsProxyAgent;
|
||||
HttpsProxyAgent.protocols = ['http', 'https'];
|
||||
exports.HttpsProxyAgent = HttpsProxyAgent;
|
||||
function resume(socket) {
|
||||
socket.resume();
|
||||
}
|
||||
function isDefaultPort(port, secure) {
|
||||
return Boolean((!secure && port === 80) || (secure && port === 443));
|
||||
}
|
||||
function isHTTPS(protocol) {
|
||||
return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
|
||||
}
|
||||
@@ -11651,27 +11585,6 @@ function omit(obj, ...keys) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
//# sourceMappingURL=agent.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7219:
|
||||
/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const agent_1 = __importDefault(__nccwpck_require__(3734));
|
||||
function createHttpsProxyAgent(opts) {
|
||||
return new agent_1.default(opts);
|
||||
}
|
||||
(function (createHttpsProxyAgent) {
|
||||
createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
|
||||
createHttpsProxyAgent.prototype = agent_1.default.prototype;
|
||||
})(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
|
||||
module.exports = createHttpsProxyAgent;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
/***/ }),
|
||||
@@ -11685,8 +11598,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseProxyResponse = void 0;
|
||||
const debug_1 = __importDefault(__nccwpck_require__(8237));
|
||||
const debug = debug_1.default('https-proxy-agent:parse-proxy-response');
|
||||
const debug = (0, debug_1.default)('https-proxy-agent:parse-proxy-response');
|
||||
function parseProxyResponse(socket) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// we need to buffer any HTTP traffic that happens with the proxy before we get
|
||||
@@ -11730,12 +11644,44 @@ function parseProxyResponse(socket) {
|
||||
read();
|
||||
return;
|
||||
}
|
||||
const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
|
||||
const statusCode = +firstLine.split(' ')[1];
|
||||
const headerParts = buffered.toString('ascii').split('\r\n');
|
||||
const firstLine = headerParts.shift();
|
||||
if (!firstLine) {
|
||||
throw new Error('No header received');
|
||||
}
|
||||
const firstLineParts = firstLine.split(' ');
|
||||
const statusCode = +firstLineParts[1];
|
||||
const statusText = firstLineParts.slice(2).join(' ');
|
||||
const headers = {};
|
||||
for (const header of headerParts) {
|
||||
if (!header)
|
||||
continue;
|
||||
const firstColon = header.indexOf(':');
|
||||
if (firstColon === -1) {
|
||||
throw new Error(`Invalid header: "${header}"`);
|
||||
}
|
||||
const key = header.slice(0, firstColon).toLowerCase();
|
||||
const value = header.slice(firstColon + 1).trimStart();
|
||||
const current = headers[key];
|
||||
if (typeof current === 'string') {
|
||||
headers[key] = [current, value];
|
||||
}
|
||||
else if (Array.isArray(current)) {
|
||||
current.push(value);
|
||||
}
|
||||
else {
|
||||
headers[key] = value;
|
||||
}
|
||||
}
|
||||
debug('got proxy server response: %o', firstLine);
|
||||
cleanup();
|
||||
resolve({
|
||||
statusCode,
|
||||
buffered
|
||||
connect: {
|
||||
statusCode,
|
||||
statusText,
|
||||
headers,
|
||||
},
|
||||
buffered,
|
||||
});
|
||||
}
|
||||
socket.on('error', onerror);
|
||||
@@ -11744,7 +11690,7 @@ function parseProxyResponse(socket) {
|
||||
read();
|
||||
});
|
||||
}
|
||||
exports["default"] = parseProxyResponse;
|
||||
exports.parseProxyResponse = parseProxyResponse;
|
||||
//# sourceMappingURL=parse-proxy-response.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
Reference in New Issue
Block a user