@wix/dev-machine-monitor 1.0.5 → 1.0.6
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 +4 -1
- package/build/integration.d.ts +5 -0
- package/build/integration.js +259 -0
- package/build/run.cjs +834 -665
- package/build/run.cjs.map +1 -1
- package/package.json +9 -4
package/build/run.cjs
CHANGED
|
@@ -3459,342 +3459,6 @@ var require_commander = __commonJS({
|
|
|
3459
3459
|
}
|
|
3460
3460
|
});
|
|
3461
3461
|
|
|
3462
|
-
// node_modules/http-proxy-3/dist/lib/http-proxy/common.js
|
|
3463
|
-
var require_common = __commonJS({
|
|
3464
|
-
"node_modules/http-proxy-3/dist/lib/http-proxy/common.js"(exports2) {
|
|
3465
|
-
"use strict";
|
|
3466
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3467
|
-
exports2.isSSL = void 0;
|
|
3468
|
-
exports2.setupOutgoing = setupOutgoing;
|
|
3469
|
-
exports2.setupSocket = setupSocket;
|
|
3470
|
-
exports2.getPort = getPort;
|
|
3471
|
-
exports2.hasEncryptedConnection = hasEncryptedConnection;
|
|
3472
|
-
exports2.urlJoin = urlJoin;
|
|
3473
|
-
exports2.rewriteCookieProperty = rewriteCookieProperty;
|
|
3474
|
-
exports2.toURL = toURL;
|
|
3475
|
-
var node_tls_1 = require("node:tls");
|
|
3476
|
-
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
|
|
3477
|
-
exports2.isSSL = /^https|wss/;
|
|
3478
|
-
var HEADER_BLACKLIST = "trailer";
|
|
3479
|
-
var HTTP2_HEADER_BLACKLIST = [
|
|
3480
|
-
":method",
|
|
3481
|
-
":path",
|
|
3482
|
-
":scheme",
|
|
3483
|
-
":authority"
|
|
3484
|
-
];
|
|
3485
|
-
function setupOutgoing(outgoing, options, req, forward) {
|
|
3486
|
-
const target = options[forward || "target"];
|
|
3487
|
-
outgoing.port = +(target.port ?? (target.protocol !== void 0 && exports2.isSSL.test(target.protocol) ? 443 : 80));
|
|
3488
|
-
for (const e of [
|
|
3489
|
-
"host",
|
|
3490
|
-
"hostname",
|
|
3491
|
-
"socketPath",
|
|
3492
|
-
"pfx",
|
|
3493
|
-
"key",
|
|
3494
|
-
"passphrase",
|
|
3495
|
-
"cert",
|
|
3496
|
-
"ca",
|
|
3497
|
-
"ciphers",
|
|
3498
|
-
"secureProtocol"
|
|
3499
|
-
]) {
|
|
3500
|
-
outgoing[e] = target[e];
|
|
3501
|
-
}
|
|
3502
|
-
outgoing.method = options.method || req.method;
|
|
3503
|
-
outgoing.headers = { ...req.headers };
|
|
3504
|
-
if (options.headers) {
|
|
3505
|
-
outgoing.headers = { ...outgoing.headers, ...options.headers };
|
|
3506
|
-
}
|
|
3507
|
-
for (const header in outgoing.headers) {
|
|
3508
|
-
if (HEADER_BLACKLIST == header.toLowerCase()) {
|
|
3509
|
-
delete outgoing.headers[header];
|
|
3510
|
-
break;
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
if (req.httpVersionMajor > 1) {
|
|
3514
|
-
for (const header of HTTP2_HEADER_BLACKLIST) {
|
|
3515
|
-
delete outgoing.headers[header];
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
if (options.auth) {
|
|
3519
|
-
delete outgoing.headers.authorization;
|
|
3520
|
-
outgoing.auth = options.auth;
|
|
3521
|
-
}
|
|
3522
|
-
if (options.ca) {
|
|
3523
|
-
outgoing.ca = options.ca;
|
|
3524
|
-
}
|
|
3525
|
-
if (target.protocol !== void 0 && exports2.isSSL.test(target.protocol)) {
|
|
3526
|
-
outgoing.rejectUnauthorized = typeof options.secure === "undefined" ? true : options.secure;
|
|
3527
|
-
}
|
|
3528
|
-
outgoing.agent = options.agent || false;
|
|
3529
|
-
outgoing.localAddress = options.localAddress;
|
|
3530
|
-
if (!outgoing.agent) {
|
|
3531
|
-
outgoing.headers = outgoing.headers || {};
|
|
3532
|
-
if (typeof outgoing.headers.connection !== "string" || !upgradeHeader.test(outgoing.headers.connection)) {
|
|
3533
|
-
outgoing.headers.connection = "close";
|
|
3534
|
-
}
|
|
3535
|
-
}
|
|
3536
|
-
const targetPath = target && options.prependPath !== false && "pathname" in target ? getPath(`${target.pathname}${target.search ?? ""}`) : "/";
|
|
3537
|
-
let outgoingPath = options.toProxy ? req.url : getPath(req.url);
|
|
3538
|
-
outgoingPath = !options.ignorePath ? outgoingPath : "";
|
|
3539
|
-
outgoing.path = urlJoin(targetPath, outgoingPath ?? "");
|
|
3540
|
-
if (options.changeOrigin) {
|
|
3541
|
-
outgoing.headers.host = target.protocol !== void 0 && required(outgoing.port, target.protocol) && !hasPort(outgoing.host) ? outgoing.host + ":" + outgoing.port : outgoing.host;
|
|
3542
|
-
}
|
|
3543
|
-
return outgoing;
|
|
3544
|
-
}
|
|
3545
|
-
function setupSocket(socket) {
|
|
3546
|
-
socket.setTimeout(0);
|
|
3547
|
-
socket.setNoDelay(true);
|
|
3548
|
-
socket.setKeepAlive(true, 0);
|
|
3549
|
-
return socket;
|
|
3550
|
-
}
|
|
3551
|
-
function getPort(req) {
|
|
3552
|
-
const res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
|
|
3553
|
-
return res ? res[1] : hasEncryptedConnection(req) ? "443" : "80";
|
|
3554
|
-
}
|
|
3555
|
-
function hasEncryptedConnection(req) {
|
|
3556
|
-
const conn = req.connection;
|
|
3557
|
-
return conn instanceof node_tls_1.TLSSocket && conn.encrypted || Boolean(conn.pair);
|
|
3558
|
-
}
|
|
3559
|
-
function urlJoin(...args) {
|
|
3560
|
-
const queryParams = [];
|
|
3561
|
-
let queryParamRaw = "";
|
|
3562
|
-
args.forEach((url, index) => {
|
|
3563
|
-
const qpStart = url.indexOf("?");
|
|
3564
|
-
if (qpStart !== -1) {
|
|
3565
|
-
queryParams.push(url.substring(qpStart + 1));
|
|
3566
|
-
args[index] = url.substring(0, qpStart);
|
|
3567
|
-
}
|
|
3568
|
-
});
|
|
3569
|
-
queryParamRaw = queryParams.filter(Boolean).join("&");
|
|
3570
|
-
let retSegs = "";
|
|
3571
|
-
for (const seg of args) {
|
|
3572
|
-
if (!seg) {
|
|
3573
|
-
continue;
|
|
3574
|
-
}
|
|
3575
|
-
if (retSegs.endsWith("/")) {
|
|
3576
|
-
if (seg.startsWith("/")) {
|
|
3577
|
-
retSegs += seg.slice(1);
|
|
3578
|
-
} else {
|
|
3579
|
-
retSegs += seg;
|
|
3580
|
-
}
|
|
3581
|
-
} else {
|
|
3582
|
-
if (seg.startsWith("/")) {
|
|
3583
|
-
retSegs += seg;
|
|
3584
|
-
} else {
|
|
3585
|
-
retSegs += "/" + seg;
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
}
|
|
3589
|
-
return queryParamRaw ? retSegs + "?" + queryParamRaw : retSegs;
|
|
3590
|
-
}
|
|
3591
|
-
function rewriteCookieProperty(header, config, property) {
|
|
3592
|
-
if (Array.isArray(header)) {
|
|
3593
|
-
return header.map((headerElement) => {
|
|
3594
|
-
return rewriteCookieProperty(headerElement, config, property);
|
|
3595
|
-
});
|
|
3596
|
-
}
|
|
3597
|
-
return header.replace(new RegExp("(;\\s*" + property + "=)([^;]+)", "i"), (match, prefix, previousValue) => {
|
|
3598
|
-
let newValue;
|
|
3599
|
-
if (previousValue in config) {
|
|
3600
|
-
newValue = config[previousValue];
|
|
3601
|
-
} else if ("*" in config) {
|
|
3602
|
-
newValue = config["*"];
|
|
3603
|
-
} else {
|
|
3604
|
-
return match;
|
|
3605
|
-
}
|
|
3606
|
-
if (newValue) {
|
|
3607
|
-
return prefix + newValue;
|
|
3608
|
-
} else {
|
|
3609
|
-
return "";
|
|
3610
|
-
}
|
|
3611
|
-
});
|
|
3612
|
-
}
|
|
3613
|
-
function hasPort(host) {
|
|
3614
|
-
return !!~host.indexOf(":");
|
|
3615
|
-
}
|
|
3616
|
-
function getPath(url) {
|
|
3617
|
-
if (url === "" || url?.startsWith("?")) {
|
|
3618
|
-
return url;
|
|
3619
|
-
}
|
|
3620
|
-
const u2 = toURL(url);
|
|
3621
|
-
return `${u2.pathname ?? ""}${u2.search ?? ""}`;
|
|
3622
|
-
}
|
|
3623
|
-
function toURL(url) {
|
|
3624
|
-
if (url instanceof URL) {
|
|
3625
|
-
return url;
|
|
3626
|
-
} else if (typeof url === "object" && "href" in url && typeof url.href === "string") {
|
|
3627
|
-
url = url.href;
|
|
3628
|
-
}
|
|
3629
|
-
if (!url) {
|
|
3630
|
-
url = "";
|
|
3631
|
-
}
|
|
3632
|
-
if (typeof url != "string") {
|
|
3633
|
-
url = `${url}`;
|
|
3634
|
-
}
|
|
3635
|
-
if (url.startsWith("//")) {
|
|
3636
|
-
url = `http://base.invalid${url}`;
|
|
3637
|
-
}
|
|
3638
|
-
return new URL(url, "http://base.invalid");
|
|
3639
|
-
}
|
|
3640
|
-
function required(port, protocol) {
|
|
3641
|
-
protocol = protocol.split(":")[0];
|
|
3642
|
-
port = +port;
|
|
3643
|
-
if (!port)
|
|
3644
|
-
return false;
|
|
3645
|
-
switch (protocol) {
|
|
3646
|
-
case "http":
|
|
3647
|
-
case "ws":
|
|
3648
|
-
return port !== 80;
|
|
3649
|
-
case "https":
|
|
3650
|
-
case "wss":
|
|
3651
|
-
return port !== 443;
|
|
3652
|
-
}
|
|
3653
|
-
return port !== 0;
|
|
3654
|
-
}
|
|
3655
|
-
}
|
|
3656
|
-
});
|
|
3657
|
-
|
|
3658
|
-
// node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-outgoing.js
|
|
3659
|
-
var require_web_outgoing = __commonJS({
|
|
3660
|
-
"node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-outgoing.js"(exports2) {
|
|
3661
|
-
"use strict";
|
|
3662
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o2, m, k, k2) {
|
|
3663
|
-
if (k2 === void 0) k2 = k;
|
|
3664
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3665
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3666
|
-
desc = { enumerable: true, get: function() {
|
|
3667
|
-
return m[k];
|
|
3668
|
-
} };
|
|
3669
|
-
}
|
|
3670
|
-
Object.defineProperty(o2, k2, desc);
|
|
3671
|
-
}) : (function(o2, m, k, k2) {
|
|
3672
|
-
if (k2 === void 0) k2 = k;
|
|
3673
|
-
o2[k2] = m[k];
|
|
3674
|
-
}));
|
|
3675
|
-
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o2, v) {
|
|
3676
|
-
Object.defineProperty(o2, "default", { enumerable: true, value: v });
|
|
3677
|
-
}) : function(o2, v) {
|
|
3678
|
-
o2["default"] = v;
|
|
3679
|
-
});
|
|
3680
|
-
var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
|
|
3681
|
-
var ownKeys = function(o2) {
|
|
3682
|
-
ownKeys = Object.getOwnPropertyNames || function(o3) {
|
|
3683
|
-
var ar = [];
|
|
3684
|
-
for (var k in o3) if (Object.prototype.hasOwnProperty.call(o3, k)) ar[ar.length] = k;
|
|
3685
|
-
return ar;
|
|
3686
|
-
};
|
|
3687
|
-
return ownKeys(o2);
|
|
3688
|
-
};
|
|
3689
|
-
return function(mod) {
|
|
3690
|
-
if (mod && mod.__esModule) return mod;
|
|
3691
|
-
var result = {};
|
|
3692
|
-
if (mod != null) {
|
|
3693
|
-
for (var k = ownKeys(mod), i2 = 0; i2 < k.length; i2++) if (k[i2] !== "default") __createBinding(result, mod, k[i2]);
|
|
3694
|
-
}
|
|
3695
|
-
__setModuleDefault(result, mod);
|
|
3696
|
-
return result;
|
|
3697
|
-
};
|
|
3698
|
-
})();
|
|
3699
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3700
|
-
exports2.OUTGOING_PASSES = void 0;
|
|
3701
|
-
exports2.removeChunked = removeChunked;
|
|
3702
|
-
exports2.setConnection = setConnection;
|
|
3703
|
-
exports2.setRedirectHostRewrite = setRedirectHostRewrite;
|
|
3704
|
-
exports2.writeHeaders = writeHeaders;
|
|
3705
|
-
exports2.writeStatusCode = writeStatusCode;
|
|
3706
|
-
var common2 = __importStar(require_common());
|
|
3707
|
-
var redirectRegex = /^201|30(1|2|7|8)$/;
|
|
3708
|
-
function removeChunked(_req, _res, proxyRes) {
|
|
3709
|
-
delete proxyRes.headers["transfer-encoding"];
|
|
3710
|
-
}
|
|
3711
|
-
function setConnection(req, _res, proxyRes) {
|
|
3712
|
-
if (req.httpVersion === "1.0") {
|
|
3713
|
-
proxyRes.headers["connection"] = req.headers["connection"] || "close";
|
|
3714
|
-
} else if (req.httpVersion !== "2.0" && !proxyRes.headers["connection"]) {
|
|
3715
|
-
proxyRes.headers["connection"] = req.headers["connection"] || "keep-alive";
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
function setRedirectHostRewrite(req, _res, proxyRes, options) {
|
|
3719
|
-
if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers["location"] && redirectRegex.test(`${proxyRes.statusCode}`)) {
|
|
3720
|
-
const target = common2.toURL(options.target);
|
|
3721
|
-
const location = proxyRes.headers["location"];
|
|
3722
|
-
if (typeof location != "string") {
|
|
3723
|
-
return;
|
|
3724
|
-
}
|
|
3725
|
-
const u2 = common2.toURL(location);
|
|
3726
|
-
if (target.host != u2.host) {
|
|
3727
|
-
return;
|
|
3728
|
-
}
|
|
3729
|
-
if (options.hostRewrite) {
|
|
3730
|
-
u2.host = options.hostRewrite;
|
|
3731
|
-
} else if (options.autoRewrite) {
|
|
3732
|
-
u2.host = req.headers["host"] ?? "";
|
|
3733
|
-
}
|
|
3734
|
-
if (options.protocolRewrite) {
|
|
3735
|
-
u2.protocol = options.protocolRewrite;
|
|
3736
|
-
}
|
|
3737
|
-
proxyRes.headers["location"] = u2.toString();
|
|
3738
|
-
}
|
|
3739
|
-
}
|
|
3740
|
-
function writeHeaders(_req, res, proxyRes, options) {
|
|
3741
|
-
const rewriteCookieDomainConfig = typeof options.cookieDomainRewrite === "string" ? (
|
|
3742
|
-
// also test for ''
|
|
3743
|
-
{ "*": options.cookieDomainRewrite }
|
|
3744
|
-
) : options.cookieDomainRewrite;
|
|
3745
|
-
const rewriteCookiePathConfig = typeof options.cookiePathRewrite === "string" ? (
|
|
3746
|
-
// also test for ''
|
|
3747
|
-
{ "*": options.cookiePathRewrite }
|
|
3748
|
-
) : options.cookiePathRewrite;
|
|
3749
|
-
const preserveHeaderKeyCase = options.preserveHeaderKeyCase;
|
|
3750
|
-
const setHeader = (key, header) => {
|
|
3751
|
-
if (header == void 0) {
|
|
3752
|
-
return;
|
|
3753
|
-
}
|
|
3754
|
-
if (rewriteCookieDomainConfig && key.toLowerCase() === "set-cookie") {
|
|
3755
|
-
header = common2.rewriteCookieProperty(header, rewriteCookieDomainConfig, "domain");
|
|
3756
|
-
}
|
|
3757
|
-
if (rewriteCookiePathConfig && key.toLowerCase() === "set-cookie") {
|
|
3758
|
-
header = common2.rewriteCookieProperty(header, rewriteCookiePathConfig, "path");
|
|
3759
|
-
}
|
|
3760
|
-
res.setHeader(String(key).trim(), header);
|
|
3761
|
-
};
|
|
3762
|
-
let rawHeaderKeyMap;
|
|
3763
|
-
if (preserveHeaderKeyCase && proxyRes.rawHeaders != void 0) {
|
|
3764
|
-
rawHeaderKeyMap = {};
|
|
3765
|
-
for (let i2 = 0; i2 < proxyRes.rawHeaders.length; i2 += 2) {
|
|
3766
|
-
const key = proxyRes.rawHeaders[i2];
|
|
3767
|
-
rawHeaderKeyMap[key.toLowerCase()] = key;
|
|
3768
|
-
}
|
|
3769
|
-
}
|
|
3770
|
-
for (const key0 in proxyRes.headers) {
|
|
3771
|
-
let key = key0;
|
|
3772
|
-
if (_req.httpVersionMajor > 1 && key === "connection") {
|
|
3773
|
-
continue;
|
|
3774
|
-
}
|
|
3775
|
-
const header = proxyRes.headers[key];
|
|
3776
|
-
if (preserveHeaderKeyCase && rawHeaderKeyMap) {
|
|
3777
|
-
key = rawHeaderKeyMap[key] ?? key;
|
|
3778
|
-
}
|
|
3779
|
-
setHeader(key, header);
|
|
3780
|
-
}
|
|
3781
|
-
}
|
|
3782
|
-
function writeStatusCode(_req, res, proxyRes) {
|
|
3783
|
-
res.statusCode = proxyRes.statusCode;
|
|
3784
|
-
if (proxyRes.statusMessage && _req.httpVersionMajor === 1) {
|
|
3785
|
-
res.statusMessage = proxyRes.statusMessage;
|
|
3786
|
-
}
|
|
3787
|
-
}
|
|
3788
|
-
exports2.OUTGOING_PASSES = {
|
|
3789
|
-
removeChunked,
|
|
3790
|
-
setConnection,
|
|
3791
|
-
setRedirectHostRewrite,
|
|
3792
|
-
writeHeaders,
|
|
3793
|
-
writeStatusCode
|
|
3794
|
-
};
|
|
3795
|
-
}
|
|
3796
|
-
});
|
|
3797
|
-
|
|
3798
3462
|
// node_modules/ms/index.js
|
|
3799
3463
|
var require_ms = __commonJS({
|
|
3800
3464
|
"node_modules/ms/index.js"(exports2, module2) {
|
|
@@ -3913,7 +3577,7 @@ var require_ms = __commonJS({
|
|
|
3913
3577
|
});
|
|
3914
3578
|
|
|
3915
3579
|
// node_modules/debug/src/common.js
|
|
3916
|
-
var
|
|
3580
|
+
var require_common = __commonJS({
|
|
3917
3581
|
"node_modules/debug/src/common.js"(exports2, module2) {
|
|
3918
3582
|
"use strict";
|
|
3919
3583
|
function setup(env2) {
|
|
@@ -4249,7 +3913,7 @@ var require_browser = __commonJS({
|
|
|
4249
3913
|
} catch (error) {
|
|
4250
3914
|
}
|
|
4251
3915
|
}
|
|
4252
|
-
module2.exports =
|
|
3916
|
+
module2.exports = require_common()(exports2);
|
|
4253
3917
|
var { formatters } = module2.exports;
|
|
4254
3918
|
formatters.j = function(v) {
|
|
4255
3919
|
try {
|
|
@@ -4423,7 +4087,7 @@ var require_node = __commonJS({
|
|
|
4423
4087
|
debug.inspectOpts[keys[i2]] = exports2.inspectOpts[keys[i2]];
|
|
4424
4088
|
}
|
|
4425
4089
|
}
|
|
4426
|
-
module2.exports =
|
|
4090
|
+
module2.exports = require_common()(exports2);
|
|
4427
4091
|
var { formatters } = module2.exports;
|
|
4428
4092
|
formatters.o = function(v) {
|
|
4429
4093
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -4615,354 +4279,698 @@ var require_follow_redirects = __commonJS({
|
|
|
4615
4279
|
self._ended = true;
|
|
4616
4280
|
currentRequest.end(null, null, callback);
|
|
4617
4281
|
});
|
|
4618
|
-
this._ending = true;
|
|
4282
|
+
this._ending = true;
|
|
4283
|
+
}
|
|
4284
|
+
};
|
|
4285
|
+
RedirectableRequest.prototype.setHeader = function(name, value) {
|
|
4286
|
+
this._options.headers[name] = value;
|
|
4287
|
+
this._currentRequest.setHeader(name, value);
|
|
4288
|
+
};
|
|
4289
|
+
RedirectableRequest.prototype.removeHeader = function(name) {
|
|
4290
|
+
delete this._options.headers[name];
|
|
4291
|
+
this._currentRequest.removeHeader(name);
|
|
4292
|
+
};
|
|
4293
|
+
RedirectableRequest.prototype.setTimeout = function(msecs, callback) {
|
|
4294
|
+
var self = this;
|
|
4295
|
+
function destroyOnTimeout(socket) {
|
|
4296
|
+
socket.setTimeout(msecs);
|
|
4297
|
+
socket.removeListener("timeout", socket.destroy);
|
|
4298
|
+
socket.addListener("timeout", socket.destroy);
|
|
4299
|
+
}
|
|
4300
|
+
function startTimer(socket) {
|
|
4301
|
+
if (self._timeout) {
|
|
4302
|
+
clearTimeout(self._timeout);
|
|
4303
|
+
}
|
|
4304
|
+
self._timeout = setTimeout(function() {
|
|
4305
|
+
self.emit("timeout");
|
|
4306
|
+
clearTimer();
|
|
4307
|
+
}, msecs);
|
|
4308
|
+
destroyOnTimeout(socket);
|
|
4309
|
+
}
|
|
4310
|
+
function clearTimer() {
|
|
4311
|
+
if (self._timeout) {
|
|
4312
|
+
clearTimeout(self._timeout);
|
|
4313
|
+
self._timeout = null;
|
|
4314
|
+
}
|
|
4315
|
+
self.removeListener("abort", clearTimer);
|
|
4316
|
+
self.removeListener("error", clearTimer);
|
|
4317
|
+
self.removeListener("response", clearTimer);
|
|
4318
|
+
self.removeListener("close", clearTimer);
|
|
4319
|
+
if (callback) {
|
|
4320
|
+
self.removeListener("timeout", callback);
|
|
4321
|
+
}
|
|
4322
|
+
if (!self.socket) {
|
|
4323
|
+
self._currentRequest.removeListener("socket", startTimer);
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
if (callback) {
|
|
4327
|
+
this.on("timeout", callback);
|
|
4328
|
+
}
|
|
4329
|
+
if (this.socket) {
|
|
4330
|
+
startTimer(this.socket);
|
|
4331
|
+
} else {
|
|
4332
|
+
this._currentRequest.once("socket", startTimer);
|
|
4333
|
+
}
|
|
4334
|
+
this.on("socket", destroyOnTimeout);
|
|
4335
|
+
this.on("abort", clearTimer);
|
|
4336
|
+
this.on("error", clearTimer);
|
|
4337
|
+
this.on("response", clearTimer);
|
|
4338
|
+
this.on("close", clearTimer);
|
|
4339
|
+
return this;
|
|
4340
|
+
};
|
|
4341
|
+
[
|
|
4342
|
+
"flushHeaders",
|
|
4343
|
+
"getHeader",
|
|
4344
|
+
"setNoDelay",
|
|
4345
|
+
"setSocketKeepAlive"
|
|
4346
|
+
].forEach(function(method) {
|
|
4347
|
+
RedirectableRequest.prototype[method] = function(a2, b) {
|
|
4348
|
+
return this._currentRequest[method](a2, b);
|
|
4349
|
+
};
|
|
4350
|
+
});
|
|
4351
|
+
["aborted", "connection", "socket"].forEach(function(property) {
|
|
4352
|
+
Object.defineProperty(RedirectableRequest.prototype, property, {
|
|
4353
|
+
get: function() {
|
|
4354
|
+
return this._currentRequest[property];
|
|
4355
|
+
}
|
|
4356
|
+
});
|
|
4357
|
+
});
|
|
4358
|
+
RedirectableRequest.prototype._sanitizeOptions = function(options) {
|
|
4359
|
+
if (!options.headers) {
|
|
4360
|
+
options.headers = {};
|
|
4361
|
+
}
|
|
4362
|
+
if (options.host) {
|
|
4363
|
+
if (!options.hostname) {
|
|
4364
|
+
options.hostname = options.host;
|
|
4365
|
+
}
|
|
4366
|
+
delete options.host;
|
|
4367
|
+
}
|
|
4368
|
+
if (!options.pathname && options.path) {
|
|
4369
|
+
var searchPos = options.path.indexOf("?");
|
|
4370
|
+
if (searchPos < 0) {
|
|
4371
|
+
options.pathname = options.path;
|
|
4372
|
+
} else {
|
|
4373
|
+
options.pathname = options.path.substring(0, searchPos);
|
|
4374
|
+
options.search = options.path.substring(searchPos);
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
};
|
|
4378
|
+
RedirectableRequest.prototype._performRequest = function() {
|
|
4379
|
+
var protocol = this._options.protocol;
|
|
4380
|
+
var nativeProtocol = this._options.nativeProtocols[protocol];
|
|
4381
|
+
if (!nativeProtocol) {
|
|
4382
|
+
throw new TypeError("Unsupported protocol " + protocol);
|
|
4383
|
+
}
|
|
4384
|
+
if (this._options.agents) {
|
|
4385
|
+
var scheme = protocol.slice(0, -1);
|
|
4386
|
+
this._options.agent = this._options.agents[scheme];
|
|
4387
|
+
}
|
|
4388
|
+
var request = this._currentRequest = nativeProtocol.request(this._options, this._onNativeResponse);
|
|
4389
|
+
request._redirectable = this;
|
|
4390
|
+
for (var event of events) {
|
|
4391
|
+
request.on(event, eventHandlers[event]);
|
|
4392
|
+
}
|
|
4393
|
+
this._currentUrl = /^\//.test(this._options.path) ? url.format(this._options) : (
|
|
4394
|
+
// When making a request to a proxy, […]
|
|
4395
|
+
// a client MUST send the target URI in absolute-form […].
|
|
4396
|
+
this._options.path
|
|
4397
|
+
);
|
|
4398
|
+
if (this._isRedirect) {
|
|
4399
|
+
var i2 = 0;
|
|
4400
|
+
var self = this;
|
|
4401
|
+
var buffers = this._requestBodyBuffers;
|
|
4402
|
+
(function writeNext(error) {
|
|
4403
|
+
if (request === self._currentRequest) {
|
|
4404
|
+
if (error) {
|
|
4405
|
+
self.emit("error", error);
|
|
4406
|
+
} else if (i2 < buffers.length) {
|
|
4407
|
+
var buffer = buffers[i2++];
|
|
4408
|
+
if (!request.finished) {
|
|
4409
|
+
request.write(buffer.data, buffer.encoding, writeNext);
|
|
4410
|
+
}
|
|
4411
|
+
} else if (self._ended) {
|
|
4412
|
+
request.end();
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
})();
|
|
4416
|
+
}
|
|
4417
|
+
};
|
|
4418
|
+
RedirectableRequest.prototype._processResponse = function(response) {
|
|
4419
|
+
var statusCode = response.statusCode;
|
|
4420
|
+
if (this._options.trackRedirects) {
|
|
4421
|
+
this._redirects.push({
|
|
4422
|
+
url: this._currentUrl,
|
|
4423
|
+
headers: response.headers,
|
|
4424
|
+
statusCode
|
|
4425
|
+
});
|
|
4426
|
+
}
|
|
4427
|
+
var location = response.headers.location;
|
|
4428
|
+
if (!location || this._options.followRedirects === false || statusCode < 300 || statusCode >= 400) {
|
|
4429
|
+
response.responseUrl = this._currentUrl;
|
|
4430
|
+
response.redirects = this._redirects;
|
|
4431
|
+
this.emit("response", response);
|
|
4432
|
+
this._requestBodyBuffers = [];
|
|
4433
|
+
return;
|
|
4434
|
+
}
|
|
4435
|
+
destroyRequest(this._currentRequest);
|
|
4436
|
+
response.destroy();
|
|
4437
|
+
if (++this._redirectCount > this._options.maxRedirects) {
|
|
4438
|
+
throw new TooManyRedirectsError();
|
|
4439
|
+
}
|
|
4440
|
+
var requestHeaders;
|
|
4441
|
+
var beforeRedirect = this._options.beforeRedirect;
|
|
4442
|
+
if (beforeRedirect) {
|
|
4443
|
+
requestHeaders = Object.assign({
|
|
4444
|
+
// The Host header was set by nativeProtocol.request
|
|
4445
|
+
Host: response.req.getHeader("host")
|
|
4446
|
+
}, this._options.headers);
|
|
4447
|
+
}
|
|
4448
|
+
var method = this._options.method;
|
|
4449
|
+
if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || // RFC7231§6.4.4: The 303 (See Other) status code indicates that
|
|
4450
|
+
// the server is redirecting the user agent to a different resource […]
|
|
4451
|
+
// A user agent can perform a retrieval request targeting that URI
|
|
4452
|
+
// (a GET or HEAD request if using HTTP) […]
|
|
4453
|
+
statusCode === 303 && !/^(?:GET|HEAD)$/.test(this._options.method)) {
|
|
4454
|
+
this._options.method = "GET";
|
|
4455
|
+
this._requestBodyBuffers = [];
|
|
4456
|
+
removeMatchingHeaders(/^content-/i, this._options.headers);
|
|
4457
|
+
}
|
|
4458
|
+
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
|
4459
|
+
var currentUrlParts = parseUrl(this._currentUrl);
|
|
4460
|
+
var currentHost = currentHostHeader || currentUrlParts.host;
|
|
4461
|
+
var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
|
4462
|
+
var redirectUrl = resolveUrl(location, currentUrl);
|
|
4463
|
+
debug("redirecting to", redirectUrl.href);
|
|
4464
|
+
this._isRedirect = true;
|
|
4465
|
+
spreadUrlObject(redirectUrl, this._options);
|
|
4466
|
+
if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
|
|
4467
|
+
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
|
|
4468
|
+
}
|
|
4469
|
+
if (isFunction(beforeRedirect)) {
|
|
4470
|
+
var responseDetails = {
|
|
4471
|
+
headers: response.headers,
|
|
4472
|
+
statusCode
|
|
4473
|
+
};
|
|
4474
|
+
var requestDetails = {
|
|
4475
|
+
url: currentUrl,
|
|
4476
|
+
method,
|
|
4477
|
+
headers: requestHeaders
|
|
4478
|
+
};
|
|
4479
|
+
beforeRedirect(this._options, responseDetails, requestDetails);
|
|
4480
|
+
this._sanitizeOptions(this._options);
|
|
4481
|
+
}
|
|
4482
|
+
this._performRequest();
|
|
4483
|
+
};
|
|
4484
|
+
function wrap(protocols) {
|
|
4485
|
+
var exports3 = {
|
|
4486
|
+
maxRedirects: 21,
|
|
4487
|
+
maxBodyLength: 10 * 1024 * 1024
|
|
4488
|
+
};
|
|
4489
|
+
var nativeProtocols = {};
|
|
4490
|
+
Object.keys(protocols).forEach(function(scheme) {
|
|
4491
|
+
var protocol = scheme + ":";
|
|
4492
|
+
var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
|
|
4493
|
+
var wrappedProtocol = exports3[scheme] = Object.create(nativeProtocol);
|
|
4494
|
+
function request(input, options, callback) {
|
|
4495
|
+
if (isURL(input)) {
|
|
4496
|
+
input = spreadUrlObject(input);
|
|
4497
|
+
} else if (isString(input)) {
|
|
4498
|
+
input = spreadUrlObject(parseUrl(input));
|
|
4499
|
+
} else {
|
|
4500
|
+
callback = options;
|
|
4501
|
+
options = validateUrl(input);
|
|
4502
|
+
input = { protocol };
|
|
4503
|
+
}
|
|
4504
|
+
if (isFunction(options)) {
|
|
4505
|
+
callback = options;
|
|
4506
|
+
options = null;
|
|
4507
|
+
}
|
|
4508
|
+
options = Object.assign({
|
|
4509
|
+
maxRedirects: exports3.maxRedirects,
|
|
4510
|
+
maxBodyLength: exports3.maxBodyLength
|
|
4511
|
+
}, input, options);
|
|
4512
|
+
options.nativeProtocols = nativeProtocols;
|
|
4513
|
+
if (!isString(options.host) && !isString(options.hostname)) {
|
|
4514
|
+
options.hostname = "::1";
|
|
4515
|
+
}
|
|
4516
|
+
assert.equal(options.protocol, protocol, "protocol mismatch");
|
|
4517
|
+
debug("options", options);
|
|
4518
|
+
return new RedirectableRequest(options, callback);
|
|
4519
|
+
}
|
|
4520
|
+
function get(input, options, callback) {
|
|
4521
|
+
var wrappedRequest = wrappedProtocol.request(input, options, callback);
|
|
4522
|
+
wrappedRequest.end();
|
|
4523
|
+
return wrappedRequest;
|
|
4524
|
+
}
|
|
4525
|
+
Object.defineProperties(wrappedProtocol, {
|
|
4526
|
+
request: { value: request, configurable: true, enumerable: true, writable: true },
|
|
4527
|
+
get: { value: get, configurable: true, enumerable: true, writable: true }
|
|
4528
|
+
});
|
|
4529
|
+
});
|
|
4530
|
+
return exports3;
|
|
4531
|
+
}
|
|
4532
|
+
function noop3() {
|
|
4533
|
+
}
|
|
4534
|
+
function parseUrl(input) {
|
|
4535
|
+
var parsed;
|
|
4536
|
+
if (useNativeURL) {
|
|
4537
|
+
parsed = new URL2(input);
|
|
4538
|
+
} else {
|
|
4539
|
+
parsed = validateUrl(url.parse(input));
|
|
4540
|
+
if (!isString(parsed.protocol)) {
|
|
4541
|
+
throw new InvalidUrlError({ input });
|
|
4542
|
+
}
|
|
4619
4543
|
}
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
}
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
};
|
|
4629
|
-
RedirectableRequest.prototype.setTimeout = function(msecs, callback) {
|
|
4630
|
-
var self = this;
|
|
4631
|
-
function destroyOnTimeout(socket) {
|
|
4632
|
-
socket.setTimeout(msecs);
|
|
4633
|
-
socket.removeListener("timeout", socket.destroy);
|
|
4634
|
-
socket.addListener("timeout", socket.destroy);
|
|
4544
|
+
return parsed;
|
|
4545
|
+
}
|
|
4546
|
+
function resolveUrl(relative, base) {
|
|
4547
|
+
return useNativeURL ? new URL2(relative, base) : parseUrl(url.resolve(base, relative));
|
|
4548
|
+
}
|
|
4549
|
+
function validateUrl(input) {
|
|
4550
|
+
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
|
4551
|
+
throw new InvalidUrlError({ input: input.href || input });
|
|
4635
4552
|
}
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
clearTimeout(self._timeout);
|
|
4639
|
-
}
|
|
4640
|
-
self._timeout = setTimeout(function() {
|
|
4641
|
-
self.emit("timeout");
|
|
4642
|
-
clearTimer();
|
|
4643
|
-
}, msecs);
|
|
4644
|
-
destroyOnTimeout(socket);
|
|
4553
|
+
if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
|
|
4554
|
+
throw new InvalidUrlError({ input: input.href || input });
|
|
4645
4555
|
}
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
self.removeListener("error", clearTimer);
|
|
4653
|
-
self.removeListener("response", clearTimer);
|
|
4654
|
-
self.removeListener("close", clearTimer);
|
|
4655
|
-
if (callback) {
|
|
4656
|
-
self.removeListener("timeout", callback);
|
|
4657
|
-
}
|
|
4658
|
-
if (!self.socket) {
|
|
4659
|
-
self._currentRequest.removeListener("socket", startTimer);
|
|
4660
|
-
}
|
|
4556
|
+
return input;
|
|
4557
|
+
}
|
|
4558
|
+
function spreadUrlObject(urlObject, target) {
|
|
4559
|
+
var spread = target || {};
|
|
4560
|
+
for (var key of preservedUrlFields) {
|
|
4561
|
+
spread[key] = urlObject[key];
|
|
4661
4562
|
}
|
|
4662
|
-
if (
|
|
4663
|
-
|
|
4563
|
+
if (spread.hostname.startsWith("[")) {
|
|
4564
|
+
spread.hostname = spread.hostname.slice(1, -1);
|
|
4664
4565
|
}
|
|
4665
|
-
if (
|
|
4666
|
-
|
|
4667
|
-
} else {
|
|
4668
|
-
this._currentRequest.once("socket", startTimer);
|
|
4566
|
+
if (spread.port !== "") {
|
|
4567
|
+
spread.port = Number(spread.port);
|
|
4669
4568
|
}
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
"getHeader",
|
|
4680
|
-
"setNoDelay",
|
|
4681
|
-
"setSocketKeepAlive"
|
|
4682
|
-
].forEach(function(method) {
|
|
4683
|
-
RedirectableRequest.prototype[method] = function(a2, b) {
|
|
4684
|
-
return this._currentRequest[method](a2, b);
|
|
4685
|
-
};
|
|
4686
|
-
});
|
|
4687
|
-
["aborted", "connection", "socket"].forEach(function(property) {
|
|
4688
|
-
Object.defineProperty(RedirectableRequest.prototype, property, {
|
|
4689
|
-
get: function() {
|
|
4690
|
-
return this._currentRequest[property];
|
|
4569
|
+
spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
|
|
4570
|
+
return spread;
|
|
4571
|
+
}
|
|
4572
|
+
function removeMatchingHeaders(regex, headers) {
|
|
4573
|
+
var lastValue;
|
|
4574
|
+
for (var header in headers) {
|
|
4575
|
+
if (regex.test(header)) {
|
|
4576
|
+
lastValue = headers[header];
|
|
4577
|
+
delete headers[header];
|
|
4691
4578
|
}
|
|
4692
|
-
});
|
|
4693
|
-
});
|
|
4694
|
-
RedirectableRequest.prototype._sanitizeOptions = function(options) {
|
|
4695
|
-
if (!options.headers) {
|
|
4696
|
-
options.headers = {};
|
|
4697
4579
|
}
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4580
|
+
return lastValue === null || typeof lastValue === "undefined" ? void 0 : String(lastValue).trim();
|
|
4581
|
+
}
|
|
4582
|
+
function createErrorType(code, message, baseClass) {
|
|
4583
|
+
function CustomError(properties) {
|
|
4584
|
+
if (isFunction(Error.captureStackTrace)) {
|
|
4585
|
+
Error.captureStackTrace(this, this.constructor);
|
|
4701
4586
|
}
|
|
4702
|
-
|
|
4587
|
+
Object.assign(this, properties || {});
|
|
4588
|
+
this.code = code;
|
|
4589
|
+
this.message = this.cause ? message + ": " + this.cause.message : message;
|
|
4703
4590
|
}
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4591
|
+
CustomError.prototype = new (baseClass || Error)();
|
|
4592
|
+
Object.defineProperties(CustomError.prototype, {
|
|
4593
|
+
constructor: {
|
|
4594
|
+
value: CustomError,
|
|
4595
|
+
enumerable: false
|
|
4596
|
+
},
|
|
4597
|
+
name: {
|
|
4598
|
+
value: "Error [" + code + "]",
|
|
4599
|
+
enumerable: false
|
|
4711
4600
|
}
|
|
4601
|
+
});
|
|
4602
|
+
return CustomError;
|
|
4603
|
+
}
|
|
4604
|
+
function destroyRequest(request, error) {
|
|
4605
|
+
for (var event of events) {
|
|
4606
|
+
request.removeListener(event, eventHandlers[event]);
|
|
4712
4607
|
}
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4608
|
+
request.on("error", noop3);
|
|
4609
|
+
request.destroy(error);
|
|
4610
|
+
}
|
|
4611
|
+
function isSubdomain(subdomain, domain) {
|
|
4612
|
+
assert(isString(subdomain) && isString(domain));
|
|
4613
|
+
var dot = subdomain.length - domain.length - 1;
|
|
4614
|
+
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
4615
|
+
}
|
|
4616
|
+
function isString(value) {
|
|
4617
|
+
return typeof value === "string" || value instanceof String;
|
|
4618
|
+
}
|
|
4619
|
+
function isFunction(value) {
|
|
4620
|
+
return typeof value === "function";
|
|
4621
|
+
}
|
|
4622
|
+
function isBuffer(value) {
|
|
4623
|
+
return typeof value === "object" && "length" in value;
|
|
4624
|
+
}
|
|
4625
|
+
function isURL(value) {
|
|
4626
|
+
return URL2 && value instanceof URL2;
|
|
4627
|
+
}
|
|
4628
|
+
module2.exports = wrap({ http: http2, https });
|
|
4629
|
+
module2.exports.wrap = wrap;
|
|
4630
|
+
}
|
|
4631
|
+
});
|
|
4632
|
+
|
|
4633
|
+
// node_modules/http-proxy-3/dist/lib/http-proxy/common.js
|
|
4634
|
+
var require_common2 = __commonJS({
|
|
4635
|
+
"node_modules/http-proxy-3/dist/lib/http-proxy/common.js"(exports2) {
|
|
4636
|
+
"use strict";
|
|
4637
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4638
|
+
exports2.isSSL = void 0;
|
|
4639
|
+
exports2.setupOutgoing = setupOutgoing;
|
|
4640
|
+
exports2.setupSocket = setupSocket;
|
|
4641
|
+
exports2.getPort = getPort;
|
|
4642
|
+
exports2.hasEncryptedConnection = hasEncryptedConnection;
|
|
4643
|
+
exports2.urlJoin = urlJoin;
|
|
4644
|
+
exports2.rewriteCookieProperty = rewriteCookieProperty;
|
|
4645
|
+
exports2.toURL = toURL;
|
|
4646
|
+
var node_tls_1 = require("node:tls");
|
|
4647
|
+
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
|
|
4648
|
+
exports2.isSSL = /^https|wss/;
|
|
4649
|
+
var HEADER_BLACKLIST = "trailer";
|
|
4650
|
+
var HTTP2_HEADER_BLACKLIST = [
|
|
4651
|
+
":method",
|
|
4652
|
+
":path",
|
|
4653
|
+
":scheme",
|
|
4654
|
+
":authority",
|
|
4655
|
+
"connection",
|
|
4656
|
+
"keep-alive"
|
|
4657
|
+
];
|
|
4658
|
+
function setupOutgoing(outgoing, options, req, forward) {
|
|
4659
|
+
const target = options[forward || "target"];
|
|
4660
|
+
outgoing.port = +(target.port ?? (target.protocol !== void 0 && exports2.isSSL.test(target.protocol) ? 443 : 80));
|
|
4661
|
+
for (const e of [
|
|
4662
|
+
"host",
|
|
4663
|
+
"hostname",
|
|
4664
|
+
"socketPath",
|
|
4665
|
+
"pfx",
|
|
4666
|
+
"key",
|
|
4667
|
+
"passphrase",
|
|
4668
|
+
"cert",
|
|
4669
|
+
"ca",
|
|
4670
|
+
"ciphers",
|
|
4671
|
+
"secureProtocol"
|
|
4672
|
+
]) {
|
|
4673
|
+
outgoing[e] = target[e];
|
|
4723
4674
|
}
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4675
|
+
outgoing.method = options.method || req.method;
|
|
4676
|
+
outgoing.headers = { ...req.headers };
|
|
4677
|
+
if (options.headers) {
|
|
4678
|
+
outgoing.headers = { ...outgoing.headers, ...options.headers };
|
|
4728
4679
|
}
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
if (this._isRedirect) {
|
|
4735
|
-
var i2 = 0;
|
|
4736
|
-
var self = this;
|
|
4737
|
-
var buffers = this._requestBodyBuffers;
|
|
4738
|
-
(function writeNext(error) {
|
|
4739
|
-
if (request === self._currentRequest) {
|
|
4740
|
-
if (error) {
|
|
4741
|
-
self.emit("error", error);
|
|
4742
|
-
} else if (i2 < buffers.length) {
|
|
4743
|
-
var buffer = buffers[i2++];
|
|
4744
|
-
if (!request.finished) {
|
|
4745
|
-
request.write(buffer.data, buffer.encoding, writeNext);
|
|
4746
|
-
}
|
|
4747
|
-
} else if (self._ended) {
|
|
4748
|
-
request.end();
|
|
4749
|
-
}
|
|
4750
|
-
}
|
|
4751
|
-
})();
|
|
4680
|
+
for (const header in outgoing.headers) {
|
|
4681
|
+
if (HEADER_BLACKLIST == header.toLowerCase()) {
|
|
4682
|
+
delete outgoing.headers[header];
|
|
4683
|
+
break;
|
|
4684
|
+
}
|
|
4752
4685
|
}
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
this._redirects.push({
|
|
4758
|
-
url: this._currentUrl,
|
|
4759
|
-
headers: response.headers,
|
|
4760
|
-
statusCode
|
|
4761
|
-
});
|
|
4686
|
+
if (req.httpVersionMajor > 1) {
|
|
4687
|
+
for (const header of HTTP2_HEADER_BLACKLIST) {
|
|
4688
|
+
delete outgoing.headers[header];
|
|
4689
|
+
}
|
|
4762
4690
|
}
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
response.redirects = this._redirects;
|
|
4767
|
-
this.emit("response", response);
|
|
4768
|
-
this._requestBodyBuffers = [];
|
|
4769
|
-
return;
|
|
4691
|
+
if (options.auth) {
|
|
4692
|
+
delete outgoing.headers.authorization;
|
|
4693
|
+
outgoing.auth = options.auth;
|
|
4770
4694
|
}
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
if (++this._redirectCount > this._options.maxRedirects) {
|
|
4774
|
-
throw new TooManyRedirectsError();
|
|
4695
|
+
if (options.ca) {
|
|
4696
|
+
outgoing.ca = options.ca;
|
|
4775
4697
|
}
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
if (beforeRedirect) {
|
|
4779
|
-
requestHeaders = Object.assign({
|
|
4780
|
-
// The Host header was set by nativeProtocol.request
|
|
4781
|
-
Host: response.req.getHeader("host")
|
|
4782
|
-
}, this._options.headers);
|
|
4698
|
+
if (target.protocol !== void 0 && exports2.isSSL.test(target.protocol)) {
|
|
4699
|
+
outgoing.rejectUnauthorized = typeof options.secure === "undefined" ? true : options.secure;
|
|
4783
4700
|
}
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
this._requestBodyBuffers = [];
|
|
4792
|
-
removeMatchingHeaders(/^content-/i, this._options.headers);
|
|
4701
|
+
outgoing.agent = options.agent || false;
|
|
4702
|
+
outgoing.localAddress = options.localAddress;
|
|
4703
|
+
if (!outgoing.agent) {
|
|
4704
|
+
outgoing.headers = outgoing.headers || {};
|
|
4705
|
+
if (typeof outgoing.headers.connection !== "string" || !upgradeHeader.test(outgoing.headers.connection)) {
|
|
4706
|
+
outgoing.headers.connection = "close";
|
|
4707
|
+
}
|
|
4793
4708
|
}
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
this._isRedirect = true;
|
|
4801
|
-
spreadUrlObject(redirectUrl, this._options);
|
|
4802
|
-
if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
|
|
4803
|
-
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
|
|
4709
|
+
const targetPath = target && options.prependPath !== false && "pathname" in target ? getPath(`${target.pathname}${target.search ?? ""}`) : "/";
|
|
4710
|
+
let outgoingPath = options.toProxy ? req.url : getPath(req.url);
|
|
4711
|
+
outgoingPath = !options.ignorePath ? outgoingPath : "";
|
|
4712
|
+
outgoing.path = urlJoin(targetPath, outgoingPath ?? "");
|
|
4713
|
+
if (options.changeOrigin) {
|
|
4714
|
+
outgoing.headers.host = target.protocol !== void 0 && required(outgoing.port, target.protocol) && !hasPort(outgoing.host) ? outgoing.host + ":" + outgoing.port : outgoing.host;
|
|
4804
4715
|
}
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
}
|
|
4810
|
-
var requestDetails = {
|
|
4811
|
-
url: currentUrl,
|
|
4812
|
-
method,
|
|
4813
|
-
headers: requestHeaders
|
|
4814
|
-
};
|
|
4815
|
-
beforeRedirect(this._options, responseDetails, requestDetails);
|
|
4816
|
-
this._sanitizeOptions(this._options);
|
|
4716
|
+
outgoing.url = "href" in target && target.href || (target.protocol === "https" ? "https" : "http") + "://" + outgoing.host + (outgoing.port ? ":" + outgoing.port : "");
|
|
4717
|
+
if (req.httpVersionMajor > 1) {
|
|
4718
|
+
for (const header of HTTP2_HEADER_BLACKLIST) {
|
|
4719
|
+
delete outgoing.headers[header];
|
|
4720
|
+
}
|
|
4817
4721
|
}
|
|
4818
|
-
|
|
4819
|
-
}
|
|
4820
|
-
function
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4722
|
+
return outgoing;
|
|
4723
|
+
}
|
|
4724
|
+
function setupSocket(socket) {
|
|
4725
|
+
socket.setTimeout(0);
|
|
4726
|
+
socket.setNoDelay(true);
|
|
4727
|
+
socket.setKeepAlive(true, 0);
|
|
4728
|
+
return socket;
|
|
4729
|
+
}
|
|
4730
|
+
function getPort(req) {
|
|
4731
|
+
const res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
|
|
4732
|
+
return res ? res[1] : hasEncryptedConnection(req) ? "443" : "80";
|
|
4733
|
+
}
|
|
4734
|
+
function hasEncryptedConnection(req) {
|
|
4735
|
+
const conn = req.connection;
|
|
4736
|
+
return conn instanceof node_tls_1.TLSSocket && conn.encrypted || Boolean(conn.pair);
|
|
4737
|
+
}
|
|
4738
|
+
function urlJoin(...args) {
|
|
4739
|
+
const queryParams = [];
|
|
4740
|
+
let queryParamRaw = "";
|
|
4741
|
+
args.forEach((url, index) => {
|
|
4742
|
+
const qpStart = url.indexOf("?");
|
|
4743
|
+
if (qpStart !== -1) {
|
|
4744
|
+
queryParams.push(url.substring(qpStart + 1));
|
|
4745
|
+
args[index] = url.substring(0, qpStart);
|
|
4746
|
+
}
|
|
4747
|
+
});
|
|
4748
|
+
queryParamRaw = queryParams.filter(Boolean).join("&");
|
|
4749
|
+
let retSegs = "";
|
|
4750
|
+
for (const seg of args) {
|
|
4751
|
+
if (!seg) {
|
|
4752
|
+
continue;
|
|
4753
|
+
}
|
|
4754
|
+
if (retSegs.endsWith("/")) {
|
|
4755
|
+
if (seg.startsWith("/")) {
|
|
4756
|
+
retSegs += seg.slice(1);
|
|
4835
4757
|
} else {
|
|
4836
|
-
|
|
4837
|
-
options = validateUrl(input);
|
|
4838
|
-
input = { protocol };
|
|
4839
|
-
}
|
|
4840
|
-
if (isFunction(options)) {
|
|
4841
|
-
callback = options;
|
|
4842
|
-
options = null;
|
|
4758
|
+
retSegs += seg;
|
|
4843
4759
|
}
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
}
|
|
4848
|
-
|
|
4849
|
-
if (!isString(options.host) && !isString(options.hostname)) {
|
|
4850
|
-
options.hostname = "::1";
|
|
4760
|
+
} else {
|
|
4761
|
+
if (seg.startsWith("/")) {
|
|
4762
|
+
retSegs += seg;
|
|
4763
|
+
} else {
|
|
4764
|
+
retSegs += "/" + seg;
|
|
4851
4765
|
}
|
|
4852
|
-
assert.equal(options.protocol, protocol, "protocol mismatch");
|
|
4853
|
-
debug("options", options);
|
|
4854
|
-
return new RedirectableRequest(options, callback);
|
|
4855
|
-
}
|
|
4856
|
-
function get(input, options, callback) {
|
|
4857
|
-
var wrappedRequest = wrappedProtocol.request(input, options, callback);
|
|
4858
|
-
wrappedRequest.end();
|
|
4859
|
-
return wrappedRequest;
|
|
4860
4766
|
}
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4767
|
+
}
|
|
4768
|
+
return queryParamRaw ? retSegs + "?" + queryParamRaw : retSegs;
|
|
4769
|
+
}
|
|
4770
|
+
function rewriteCookieProperty(header, config, property) {
|
|
4771
|
+
if (Array.isArray(header)) {
|
|
4772
|
+
return header.map((headerElement) => {
|
|
4773
|
+
return rewriteCookieProperty(headerElement, config, property);
|
|
4864
4774
|
});
|
|
4775
|
+
}
|
|
4776
|
+
return header.replace(new RegExp("(;\\s*" + property + "=)([^;]+)", "i"), (match, prefix, previousValue) => {
|
|
4777
|
+
let newValue;
|
|
4778
|
+
if (previousValue in config) {
|
|
4779
|
+
newValue = config[previousValue];
|
|
4780
|
+
} else if ("*" in config) {
|
|
4781
|
+
newValue = config["*"];
|
|
4782
|
+
} else {
|
|
4783
|
+
return match;
|
|
4784
|
+
}
|
|
4785
|
+
if (newValue) {
|
|
4786
|
+
return prefix + newValue;
|
|
4787
|
+
} else {
|
|
4788
|
+
return "";
|
|
4789
|
+
}
|
|
4865
4790
|
});
|
|
4866
|
-
return exports3;
|
|
4867
4791
|
}
|
|
4868
|
-
function
|
|
4792
|
+
function hasPort(host) {
|
|
4793
|
+
return !!~host.indexOf(":");
|
|
4869
4794
|
}
|
|
4870
|
-
function
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
parsed = new URL2(input);
|
|
4874
|
-
} else {
|
|
4875
|
-
parsed = validateUrl(url.parse(input));
|
|
4876
|
-
if (!isString(parsed.protocol)) {
|
|
4877
|
-
throw new InvalidUrlError({ input });
|
|
4878
|
-
}
|
|
4795
|
+
function getPath(url) {
|
|
4796
|
+
if (url === "" || url?.startsWith("?")) {
|
|
4797
|
+
return url;
|
|
4879
4798
|
}
|
|
4880
|
-
|
|
4799
|
+
const u2 = toURL(url);
|
|
4800
|
+
return `${u2.pathname ?? ""}${u2.search ?? ""}`;
|
|
4881
4801
|
}
|
|
4882
|
-
function
|
|
4883
|
-
|
|
4802
|
+
function toURL(url) {
|
|
4803
|
+
if (url instanceof URL) {
|
|
4804
|
+
return url;
|
|
4805
|
+
} else if (typeof url === "object" && "href" in url && typeof url.href === "string") {
|
|
4806
|
+
url = url.href;
|
|
4807
|
+
}
|
|
4808
|
+
if (!url) {
|
|
4809
|
+
url = "";
|
|
4810
|
+
}
|
|
4811
|
+
if (typeof url != "string") {
|
|
4812
|
+
url = `${url}`;
|
|
4813
|
+
}
|
|
4814
|
+
if (url.startsWith("//")) {
|
|
4815
|
+
url = `http://base.invalid${url}`;
|
|
4816
|
+
}
|
|
4817
|
+
return new URL(url, "http://base.invalid");
|
|
4884
4818
|
}
|
|
4885
|
-
function
|
|
4886
|
-
|
|
4887
|
-
|
|
4819
|
+
function required(port, protocol) {
|
|
4820
|
+
protocol = protocol.split(":")[0];
|
|
4821
|
+
port = +port;
|
|
4822
|
+
if (!port)
|
|
4823
|
+
return false;
|
|
4824
|
+
switch (protocol) {
|
|
4825
|
+
case "http":
|
|
4826
|
+
case "ws":
|
|
4827
|
+
return port !== 80;
|
|
4828
|
+
case "https":
|
|
4829
|
+
case "wss":
|
|
4830
|
+
return port !== 443;
|
|
4888
4831
|
}
|
|
4889
|
-
|
|
4890
|
-
|
|
4832
|
+
return port !== 0;
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
});
|
|
4836
|
+
|
|
4837
|
+
// node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-outgoing.js
|
|
4838
|
+
var require_web_outgoing = __commonJS({
|
|
4839
|
+
"node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-outgoing.js"(exports2) {
|
|
4840
|
+
"use strict";
|
|
4841
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o2, m, k, k2) {
|
|
4842
|
+
if (k2 === void 0) k2 = k;
|
|
4843
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4844
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4845
|
+
desc = { enumerable: true, get: function() {
|
|
4846
|
+
return m[k];
|
|
4847
|
+
} };
|
|
4891
4848
|
}
|
|
4892
|
-
|
|
4849
|
+
Object.defineProperty(o2, k2, desc);
|
|
4850
|
+
}) : (function(o2, m, k, k2) {
|
|
4851
|
+
if (k2 === void 0) k2 = k;
|
|
4852
|
+
o2[k2] = m[k];
|
|
4853
|
+
}));
|
|
4854
|
+
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o2, v) {
|
|
4855
|
+
Object.defineProperty(o2, "default", { enumerable: true, value: v });
|
|
4856
|
+
}) : function(o2, v) {
|
|
4857
|
+
o2["default"] = v;
|
|
4858
|
+
});
|
|
4859
|
+
var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
|
|
4860
|
+
var ownKeys = function(o2) {
|
|
4861
|
+
ownKeys = Object.getOwnPropertyNames || function(o3) {
|
|
4862
|
+
var ar = [];
|
|
4863
|
+
for (var k in o3) if (Object.prototype.hasOwnProperty.call(o3, k)) ar[ar.length] = k;
|
|
4864
|
+
return ar;
|
|
4865
|
+
};
|
|
4866
|
+
return ownKeys(o2);
|
|
4867
|
+
};
|
|
4868
|
+
return function(mod) {
|
|
4869
|
+
if (mod && mod.__esModule) return mod;
|
|
4870
|
+
var result = {};
|
|
4871
|
+
if (mod != null) {
|
|
4872
|
+
for (var k = ownKeys(mod), i2 = 0; i2 < k.length; i2++) if (k[i2] !== "default") __createBinding(result, mod, k[i2]);
|
|
4873
|
+
}
|
|
4874
|
+
__setModuleDefault(result, mod);
|
|
4875
|
+
return result;
|
|
4876
|
+
};
|
|
4877
|
+
})();
|
|
4878
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4879
|
+
exports2.OUTGOING_PASSES = void 0;
|
|
4880
|
+
exports2.removeChunked = removeChunked;
|
|
4881
|
+
exports2.setConnection = setConnection;
|
|
4882
|
+
exports2.setRedirectHostRewrite = setRedirectHostRewrite;
|
|
4883
|
+
exports2.writeHeaders = writeHeaders;
|
|
4884
|
+
exports2.writeStatusCode = writeStatusCode;
|
|
4885
|
+
var common2 = __importStar(require_common2());
|
|
4886
|
+
var redirectRegex = /^201|30(1|2|7|8)$/;
|
|
4887
|
+
function removeChunked(_req, _res, proxyRes) {
|
|
4888
|
+
delete proxyRes.headers["transfer-encoding"];
|
|
4893
4889
|
}
|
|
4894
|
-
function
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
if (spread.hostname.startsWith("[")) {
|
|
4900
|
-
spread.hostname = spread.hostname.slice(1, -1);
|
|
4901
|
-
}
|
|
4902
|
-
if (spread.port !== "") {
|
|
4903
|
-
spread.port = Number(spread.port);
|
|
4890
|
+
function setConnection(req, _res, proxyRes) {
|
|
4891
|
+
if (req.httpVersion === "1.0") {
|
|
4892
|
+
proxyRes.headers["connection"] = req.headers["connection"] || "close";
|
|
4893
|
+
} else if (req.httpVersion !== "2.0" && !proxyRes.headers["connection"]) {
|
|
4894
|
+
proxyRes.headers["connection"] = req.headers["connection"] || "keep-alive";
|
|
4904
4895
|
}
|
|
4905
|
-
spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
|
|
4906
|
-
return spread;
|
|
4907
4896
|
}
|
|
4908
|
-
function
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4897
|
+
function setRedirectHostRewrite(req, _res, proxyRes, options) {
|
|
4898
|
+
if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers["location"] && redirectRegex.test(`${proxyRes.statusCode}`)) {
|
|
4899
|
+
const target = common2.toURL(options.target);
|
|
4900
|
+
const location = proxyRes.headers["location"];
|
|
4901
|
+
if (typeof location != "string") {
|
|
4902
|
+
return;
|
|
4903
|
+
}
|
|
4904
|
+
const u2 = common2.toURL(location);
|
|
4905
|
+
if (target.host != u2.host) {
|
|
4906
|
+
return;
|
|
4907
|
+
}
|
|
4908
|
+
if (options.hostRewrite) {
|
|
4909
|
+
u2.host = options.hostRewrite;
|
|
4910
|
+
} else if (options.autoRewrite) {
|
|
4911
|
+
u2.host = req.headers["host"] ?? "";
|
|
4912
|
+
}
|
|
4913
|
+
if (options.protocolRewrite) {
|
|
4914
|
+
u2.protocol = options.protocolRewrite;
|
|
4914
4915
|
}
|
|
4916
|
+
proxyRes.headers["location"] = u2.toString();
|
|
4915
4917
|
}
|
|
4916
|
-
return lastValue === null || typeof lastValue === "undefined" ? void 0 : String(lastValue).trim();
|
|
4917
4918
|
}
|
|
4918
|
-
function
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4919
|
+
function writeHeaders(_req, res, proxyRes, options) {
|
|
4920
|
+
const rewriteCookieDomainConfig = typeof options.cookieDomainRewrite === "string" ? (
|
|
4921
|
+
// also test for ''
|
|
4922
|
+
{ "*": options.cookieDomainRewrite }
|
|
4923
|
+
) : options.cookieDomainRewrite;
|
|
4924
|
+
const rewriteCookiePathConfig = typeof options.cookiePathRewrite === "string" ? (
|
|
4925
|
+
// also test for ''
|
|
4926
|
+
{ "*": options.cookiePathRewrite }
|
|
4927
|
+
) : options.cookiePathRewrite;
|
|
4928
|
+
const preserveHeaderKeyCase = options.preserveHeaderKeyCase;
|
|
4929
|
+
const setHeader = (key, header) => {
|
|
4930
|
+
if (header == void 0) {
|
|
4931
|
+
return;
|
|
4932
|
+
}
|
|
4933
|
+
if (rewriteCookieDomainConfig && key.toLowerCase() === "set-cookie") {
|
|
4934
|
+
header = common2.rewriteCookieProperty(header, rewriteCookieDomainConfig, "domain");
|
|
4935
|
+
}
|
|
4936
|
+
if (rewriteCookiePathConfig && key.toLowerCase() === "set-cookie") {
|
|
4937
|
+
header = common2.rewriteCookieProperty(header, rewriteCookiePathConfig, "path");
|
|
4938
|
+
}
|
|
4939
|
+
res.setHeader(String(key).trim(), header);
|
|
4940
|
+
};
|
|
4941
|
+
let rawHeaderKeyMap;
|
|
4942
|
+
if (preserveHeaderKeyCase && proxyRes.rawHeaders != void 0) {
|
|
4943
|
+
rawHeaderKeyMap = {};
|
|
4944
|
+
for (let i2 = 0; i2 < proxyRes.rawHeaders.length; i2 += 2) {
|
|
4945
|
+
const key = proxyRes.rawHeaders[i2];
|
|
4946
|
+
rawHeaderKeyMap[key.toLowerCase()] = key;
|
|
4922
4947
|
}
|
|
4923
|
-
Object.assign(this, properties || {});
|
|
4924
|
-
this.code = code;
|
|
4925
|
-
this.message = this.cause ? message + ": " + this.cause.message : message;
|
|
4926
4948
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
enumerable: false
|
|
4932
|
-
},
|
|
4933
|
-
name: {
|
|
4934
|
-
value: "Error [" + code + "]",
|
|
4935
|
-
enumerable: false
|
|
4949
|
+
for (const key0 in proxyRes.headers) {
|
|
4950
|
+
let key = key0;
|
|
4951
|
+
if (_req.httpVersionMajor > 1 && (key === "connection" || key === "keep-alive")) {
|
|
4952
|
+
continue;
|
|
4936
4953
|
}
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
request.removeListener(event, eventHandlers[event]);
|
|
4954
|
+
const header = proxyRes.headers[key];
|
|
4955
|
+
if (preserveHeaderKeyCase && rawHeaderKeyMap) {
|
|
4956
|
+
key = rawHeaderKeyMap[key] ?? key;
|
|
4957
|
+
}
|
|
4958
|
+
setHeader(key, header);
|
|
4943
4959
|
}
|
|
4944
|
-
request.on("error", noop3);
|
|
4945
|
-
request.destroy(error);
|
|
4946
|
-
}
|
|
4947
|
-
function isSubdomain(subdomain, domain) {
|
|
4948
|
-
assert(isString(subdomain) && isString(domain));
|
|
4949
|
-
var dot = subdomain.length - domain.length - 1;
|
|
4950
|
-
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
4951
|
-
}
|
|
4952
|
-
function isString(value) {
|
|
4953
|
-
return typeof value === "string" || value instanceof String;
|
|
4954
|
-
}
|
|
4955
|
-
function isFunction(value) {
|
|
4956
|
-
return typeof value === "function";
|
|
4957
|
-
}
|
|
4958
|
-
function isBuffer(value) {
|
|
4959
|
-
return typeof value === "object" && "length" in value;
|
|
4960
4960
|
}
|
|
4961
|
-
function
|
|
4962
|
-
|
|
4961
|
+
function writeStatusCode(_req, res, proxyRes) {
|
|
4962
|
+
res.statusCode = proxyRes.statusCode;
|
|
4963
|
+
if (proxyRes.statusMessage && _req.httpVersionMajor === 1) {
|
|
4964
|
+
res.statusMessage = proxyRes.statusMessage;
|
|
4965
|
+
}
|
|
4963
4966
|
}
|
|
4964
|
-
|
|
4965
|
-
|
|
4967
|
+
exports2.OUTGOING_PASSES = {
|
|
4968
|
+
removeChunked,
|
|
4969
|
+
setConnection,
|
|
4970
|
+
setRedirectHostRewrite,
|
|
4971
|
+
writeHeaders,
|
|
4972
|
+
writeStatusCode
|
|
4973
|
+
};
|
|
4966
4974
|
}
|
|
4967
4975
|
});
|
|
4968
4976
|
|
|
@@ -5015,9 +5023,10 @@ var require_web_incoming = __commonJS({
|
|
|
5015
5023
|
exports2.stream = stream;
|
|
5016
5024
|
var http2 = __importStar(require("node:http"));
|
|
5017
5025
|
var https = __importStar(require("node:https"));
|
|
5018
|
-
var web_outgoing_1 = require_web_outgoing();
|
|
5019
|
-
var common2 = __importStar(require_common());
|
|
5020
5026
|
var followRedirects = __importStar(require_follow_redirects());
|
|
5027
|
+
var common2 = __importStar(require_common2());
|
|
5028
|
+
var web_outgoing_1 = require_web_outgoing();
|
|
5029
|
+
var node_stream_1 = require("node:stream");
|
|
5021
5030
|
var web_o = Object.values(web_outgoing_1.OUTGOING_PASSES);
|
|
5022
5031
|
var nativeAgents = { http: http2, https };
|
|
5023
5032
|
function deleteLength(req) {
|
|
@@ -5048,6 +5057,9 @@ var require_web_incoming = __commonJS({
|
|
|
5048
5057
|
}
|
|
5049
5058
|
function stream(req, res, options, _, server, cb) {
|
|
5050
5059
|
server.emit("start", req, res, options.target || options.forward);
|
|
5060
|
+
if (options.fetch || process.env.FORCE_FETCH_PATH === "true") {
|
|
5061
|
+
return stream2(req, res, options, _, server, cb);
|
|
5062
|
+
}
|
|
5051
5063
|
const agents = options.followRedirects ? followRedirects : nativeAgents;
|
|
5052
5064
|
const http3 = agents.http;
|
|
5053
5065
|
const https2 = agents.https;
|
|
@@ -5119,6 +5131,149 @@ var require_web_incoming = __commonJS({
|
|
|
5119
5131
|
}
|
|
5120
5132
|
});
|
|
5121
5133
|
}
|
|
5134
|
+
async function stream2(req, res, options, _, server, cb) {
|
|
5135
|
+
const handleError = (err, target) => {
|
|
5136
|
+
if (cb) {
|
|
5137
|
+
cb(err, req, res, target);
|
|
5138
|
+
} else {
|
|
5139
|
+
server.emit("error", err, req, res, target);
|
|
5140
|
+
}
|
|
5141
|
+
};
|
|
5142
|
+
req.on("error", (err) => {
|
|
5143
|
+
if (req.socket.destroyed && err.code === "ECONNRESET") {
|
|
5144
|
+
const target = options.target || options.forward;
|
|
5145
|
+
if (target) {
|
|
5146
|
+
server.emit("econnreset", err, req, res, target);
|
|
5147
|
+
}
|
|
5148
|
+
return;
|
|
5149
|
+
}
|
|
5150
|
+
handleError(err);
|
|
5151
|
+
});
|
|
5152
|
+
const fetchOptions = options.fetch === true ? {} : options.fetch;
|
|
5153
|
+
if (!fetchOptions) {
|
|
5154
|
+
throw new Error("stream2 called without fetch options");
|
|
5155
|
+
}
|
|
5156
|
+
if (options.forward) {
|
|
5157
|
+
const outgoingOptions2 = common2.setupOutgoing(options.ssl || {}, options, req, "forward");
|
|
5158
|
+
const requestOptions2 = {
|
|
5159
|
+
method: outgoingOptions2.method
|
|
5160
|
+
};
|
|
5161
|
+
if (fetchOptions.dispatcher) {
|
|
5162
|
+
requestOptions2.dispatcher = fetchOptions.dispatcher;
|
|
5163
|
+
}
|
|
5164
|
+
if (options.buffer) {
|
|
5165
|
+
requestOptions2.body = options.buffer;
|
|
5166
|
+
} else if (req.method !== "GET" && req.method !== "HEAD") {
|
|
5167
|
+
requestOptions2.body = req;
|
|
5168
|
+
requestOptions2.duplex = "half";
|
|
5169
|
+
}
|
|
5170
|
+
if (fetchOptions.onBeforeRequest) {
|
|
5171
|
+
try {
|
|
5172
|
+
await fetchOptions.onBeforeRequest(requestOptions2, req, res, options);
|
|
5173
|
+
} catch (err) {
|
|
5174
|
+
handleError(err, options.forward);
|
|
5175
|
+
return;
|
|
5176
|
+
}
|
|
5177
|
+
}
|
|
5178
|
+
try {
|
|
5179
|
+
const result = await fetch(new URL(outgoingOptions2.url).origin + outgoingOptions2.path, requestOptions2);
|
|
5180
|
+
if (fetchOptions.onAfterResponse) {
|
|
5181
|
+
try {
|
|
5182
|
+
await fetchOptions.onAfterResponse(result, req, res, options);
|
|
5183
|
+
} catch (err) {
|
|
5184
|
+
handleError(err, options.forward);
|
|
5185
|
+
return;
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
} catch (err) {
|
|
5189
|
+
handleError(err, options.forward);
|
|
5190
|
+
}
|
|
5191
|
+
if (!options.target) {
|
|
5192
|
+
return res.end();
|
|
5193
|
+
}
|
|
5194
|
+
}
|
|
5195
|
+
const outgoingOptions = common2.setupOutgoing(options.ssl || {}, options, req);
|
|
5196
|
+
const requestOptions = {
|
|
5197
|
+
method: outgoingOptions.method,
|
|
5198
|
+
headers: Object.fromEntries(Object.entries(outgoingOptions.headers || {}).filter(([key, _value]) => {
|
|
5199
|
+
return typeof key === "string";
|
|
5200
|
+
})),
|
|
5201
|
+
...fetchOptions.requestOptions
|
|
5202
|
+
};
|
|
5203
|
+
if (fetchOptions.dispatcher) {
|
|
5204
|
+
requestOptions.dispatcher = fetchOptions.dispatcher;
|
|
5205
|
+
}
|
|
5206
|
+
if (options.auth) {
|
|
5207
|
+
requestOptions.headers = {
|
|
5208
|
+
...requestOptions.headers,
|
|
5209
|
+
authorization: `Basic ${Buffer.from(options.auth).toString("base64")}`
|
|
5210
|
+
};
|
|
5211
|
+
}
|
|
5212
|
+
if (options.buffer) {
|
|
5213
|
+
requestOptions.body = options.buffer;
|
|
5214
|
+
} else if (req.method !== "GET" && req.method !== "HEAD") {
|
|
5215
|
+
requestOptions.body = req;
|
|
5216
|
+
requestOptions.duplex = "half";
|
|
5217
|
+
}
|
|
5218
|
+
if (fetchOptions.onBeforeRequest) {
|
|
5219
|
+
try {
|
|
5220
|
+
await fetchOptions.onBeforeRequest(requestOptions, req, res, options);
|
|
5221
|
+
} catch (err) {
|
|
5222
|
+
handleError(err, options.target);
|
|
5223
|
+
return;
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
try {
|
|
5227
|
+
const response = await fetch(new URL(outgoingOptions.url).origin + outgoingOptions.path, requestOptions);
|
|
5228
|
+
if (fetchOptions.onAfterResponse) {
|
|
5229
|
+
try {
|
|
5230
|
+
await fetchOptions.onAfterResponse(response, req, res, options);
|
|
5231
|
+
} catch (err) {
|
|
5232
|
+
handleError(err, options.target);
|
|
5233
|
+
return;
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
const fakeProxyRes = {
|
|
5237
|
+
statusCode: response.status,
|
|
5238
|
+
statusMessage: response.statusText,
|
|
5239
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
5240
|
+
rawHeaders: Object.entries(response.headers).flatMap(([key, value]) => {
|
|
5241
|
+
if (Array.isArray(value)) {
|
|
5242
|
+
return value.flatMap((v) => v != null ? [key, v] : []);
|
|
5243
|
+
}
|
|
5244
|
+
return value != null ? [key, value] : [];
|
|
5245
|
+
})
|
|
5246
|
+
};
|
|
5247
|
+
server?.emit("proxyRes", fakeProxyRes, req, res);
|
|
5248
|
+
if (!res.headersSent && !options.selfHandleResponse) {
|
|
5249
|
+
for (const pass of web_o) {
|
|
5250
|
+
pass(req, res, fakeProxyRes, options);
|
|
5251
|
+
}
|
|
5252
|
+
}
|
|
5253
|
+
if (!res.writableEnded) {
|
|
5254
|
+
const nodeStream = response.body ? node_stream_1.Readable.from(response.body) : null;
|
|
5255
|
+
if (nodeStream) {
|
|
5256
|
+
nodeStream.on("error", (err) => {
|
|
5257
|
+
handleError(err, options.target);
|
|
5258
|
+
});
|
|
5259
|
+
nodeStream.on("end", () => {
|
|
5260
|
+
server?.emit("end", req, res, fakeProxyRes);
|
|
5261
|
+
});
|
|
5262
|
+
if (!options.selfHandleResponse) {
|
|
5263
|
+
nodeStream.pipe(res, { end: true });
|
|
5264
|
+
} else {
|
|
5265
|
+
nodeStream.resume();
|
|
5266
|
+
}
|
|
5267
|
+
} else {
|
|
5268
|
+
server?.emit("end", req, res, fakeProxyRes);
|
|
5269
|
+
}
|
|
5270
|
+
} else {
|
|
5271
|
+
server?.emit("end", req, res, fakeProxyRes);
|
|
5272
|
+
}
|
|
5273
|
+
} catch (err) {
|
|
5274
|
+
handleError(err, options.target);
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5122
5277
|
exports2.WEB_PASSES = { deleteLength, timeout, XHeaders, stream };
|
|
5123
5278
|
}
|
|
5124
5279
|
});
|
|
@@ -5175,7 +5330,7 @@ var require_ws_incoming = __commonJS({
|
|
|
5175
5330
|
exports2.stream = stream;
|
|
5176
5331
|
var http2 = __importStar(require("node:http"));
|
|
5177
5332
|
var https = __importStar(require("node:https"));
|
|
5178
|
-
var common2 = __importStar(
|
|
5333
|
+
var common2 = __importStar(require_common2());
|
|
5179
5334
|
var web_outgoing_1 = require_web_outgoing();
|
|
5180
5335
|
var debug_1 = __importDefault(require_src());
|
|
5181
5336
|
var log = (0, debug_1.default)("http-proxy-3:ws-incoming");
|
|
@@ -5404,7 +5559,7 @@ var require_http_proxy = __commonJS({
|
|
|
5404
5559
|
var ws_incoming_1 = require_ws_incoming();
|
|
5405
5560
|
var node_events_1 = require("node:events");
|
|
5406
5561
|
var debug_1 = __importDefault(require_src());
|
|
5407
|
-
var common_1 =
|
|
5562
|
+
var common_1 = require_common2();
|
|
5408
5563
|
var log = (0, debug_1.default)("http-proxy-3");
|
|
5409
5564
|
var ProxyServer = class _ProxyServer extends node_events_1.EventEmitter {
|
|
5410
5565
|
/**
|
|
@@ -5525,7 +5680,7 @@ var require_http_proxy = __commonJS({
|
|
|
5525
5680
|
passes.splice(i2++, 0, cb);
|
|
5526
5681
|
};
|
|
5527
5682
|
log("creating a ProxyServer", options);
|
|
5528
|
-
options.prependPath = options.prependPath
|
|
5683
|
+
options.prependPath = options.prependPath !== false;
|
|
5529
5684
|
this.options = options;
|
|
5530
5685
|
this.web = this.createRightProxy("web")(options);
|
|
5531
5686
|
this.ws = this.createRightProxy("ws")(options);
|
|
@@ -6618,7 +6773,7 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6618
6773
|
const httpServer = http.createServer((req, res) => {
|
|
6619
6774
|
if (req.url?.startsWith(RESTART_URL) && req.method === "POST") {
|
|
6620
6775
|
onRestart();
|
|
6621
|
-
res.writeHead(
|
|
6776
|
+
res.writeHead(500, {
|
|
6622
6777
|
"Content-Type": "text/html"
|
|
6623
6778
|
}).end(`
|
|
6624
6779
|
<!doctype html>
|
|
@@ -6714,8 +6869,29 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6714
6869
|
<section>
|
|
6715
6870
|
<span class="code" id="err-code">Restarting the services...</span>
|
|
6716
6871
|
<h1 id="err-title">Please wait...</h1>
|
|
6717
|
-
<
|
|
6718
|
-
|
|
6872
|
+
<script>
|
|
6873
|
+
function checkIfSiteIsAlive(counter = 0) {
|
|
6874
|
+
if (counter === 10) {
|
|
6875
|
+
window.location.href = "/";
|
|
6876
|
+
return;
|
|
6877
|
+
}
|
|
6878
|
+
|
|
6879
|
+
fetch('/')
|
|
6880
|
+
.then((response) => {
|
|
6881
|
+
if (response.ok) {
|
|
6882
|
+
window.location.href = "/";
|
|
6883
|
+
return;
|
|
6884
|
+
}
|
|
6885
|
+
return Promise.reject();
|
|
6886
|
+
})
|
|
6887
|
+
.catch((error) => {
|
|
6888
|
+
console.error('monitor:error', 'server is not yet reachable', error);
|
|
6889
|
+
setTimeout(() => checkIfSiteIsAlive(counter + 1), 2_000);
|
|
6890
|
+
});
|
|
6891
|
+
}
|
|
6892
|
+
checkIfSiteIsAlive();
|
|
6893
|
+
</script>
|
|
6894
|
+
<p class="lead">Waiting for server to restart</p>
|
|
6719
6895
|
</section>
|
|
6720
6896
|
</main>
|
|
6721
6897
|
</body>
|
|
@@ -6736,7 +6912,7 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6736
6912
|
proxy.on("error", (_err, _req, res) => {
|
|
6737
6913
|
if ("req" in res) {
|
|
6738
6914
|
if (!res.headersSent && !res.writableEnded) {
|
|
6739
|
-
res.writeHead(
|
|
6915
|
+
res.writeHead(500, {
|
|
6740
6916
|
"Content-Type": "text/html"
|
|
6741
6917
|
}).end(`
|
|
6742
6918
|
<!doctype html>
|
|
@@ -6744,8 +6920,7 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6744
6920
|
<head>
|
|
6745
6921
|
<meta charset="utf-8" />
|
|
6746
6922
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6747
|
-
<title>
|
|
6748
|
-
<meta name="description" content="Friendly error page with suggestions and retry button." />
|
|
6923
|
+
<title>Development Server Crashed</title>
|
|
6749
6924
|
<style>
|
|
6750
6925
|
:root{
|
|
6751
6926
|
--bg:#0f1724; /* deep navy */
|
|
@@ -6815,11 +6990,10 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6815
6990
|
</style>
|
|
6816
6991
|
</head>
|
|
6817
6992
|
<body>
|
|
6818
|
-
<main class="card"
|
|
6993
|
+
<main class="card">
|
|
6819
6994
|
<div class="illustration">
|
|
6820
|
-
<div class="badge"
|
|
6821
|
-
|
|
6822
|
-
<svg width="160" height="160" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg" class="wobble" role="img" aria-hidden="true">
|
|
6995
|
+
<div class="badge">
|
|
6996
|
+
<svg width="160" height="160" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg" class="wobble">
|
|
6823
6997
|
<rect x="6" y="10" width="52" height="36" rx="6" fill="rgba(125,211,252,0.06)" stroke="rgba(125,211,252,0.12)"/>
|
|
6824
6998
|
<circle cx="20" cy="28" r="4" fill="rgba(125,211,252,0.18)"/>
|
|
6825
6999
|
<rect x="32" y="24" width="16" height="6" rx="2" fill="rgba(125,211,252,0.22)"/>
|
|
@@ -6830,13 +7004,14 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6830
7004
|
</div>
|
|
6831
7005
|
|
|
6832
7006
|
<section>
|
|
6833
|
-
<span class="code" id="err-code">
|
|
6834
|
-
<h1 id="err-title">
|
|
7007
|
+
<span class="code" id="err-code">Development Server Down</span>
|
|
7008
|
+
<h1 id="err-title">For unknown reasons development server has crashed and is not reachable.</h1>
|
|
6835
7009
|
<p class="lead">We hit an unexpected error while trying to load the page. This usually clears up quickly \u2014 here are a few options.</p>
|
|
6836
7010
|
|
|
6837
|
-
<div class="actions"
|
|
7011
|
+
<div class="actions">
|
|
6838
7012
|
<form action=${RESTART_URL} method="POST">
|
|
6839
7013
|
<button class="btn primary" id="retryBtn" type="submit">Retry</button>
|
|
7014
|
+
<a class="btn" id="homeBtn" onClick="fixWithAI()">Fix with AI</a>
|
|
6840
7015
|
</form>
|
|
6841
7016
|
<script type="text/javascript">
|
|
6842
7017
|
function fixWithAI() {
|
|
@@ -6850,15 +7025,9 @@ async function runProxy(proxyFrom, proxyTo, stdio) {
|
|
|
6850
7025
|
}, '*');
|
|
6851
7026
|
}
|
|
6852
7027
|
</script>
|
|
6853
|
-
<a class="btn" id="homeBtn" onClick="fixWithAI()">Fix with AI</a>
|
|
6854
|
-
</div>
|
|
6855
|
-
|
|
6856
|
-
<div class="details" id="details" hidden>
|
|
6857
|
-
<strong>Technical details</strong>
|
|
6858
|
-
<div id="debugText" style="margin-top:8px;color:var(--muted);">No additional information available.</div>
|
|
6859
7028
|
</div>
|
|
6860
7029
|
|
|
6861
|
-
<div class="suggestions"
|
|
7030
|
+
<div class="suggestions">
|
|
6862
7031
|
<div class="suggestion"><span class="dot"></span><div>Try refreshing the page or press <kbd>Ctrl</kbd> + <kbd>R</kbd>.</div></div>
|
|
6863
7032
|
<div class="suggestion"><span class="dot"></span><div>Check your connection or try again in a few minutes.</div></div>
|
|
6864
7033
|
<div class="suggestion"><span class="dot"></span><div>If the problem persists, open an issue or contact support.</div></div>
|