@rsbuild/core 2.0.0-rc.0 → 2.0.0-rc.2
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/compiled/connect-next/package.json +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +180 -386
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/at-rule.d.ts +0 -1
- package/compiled/postcss/lib/comment.d.ts +0 -1
- package/compiled/postcss/lib/container.d.ts +1 -6
- package/compiled/postcss/lib/css-syntax-error.d.ts +0 -1
- package/compiled/postcss/lib/declaration.d.ts +0 -1
- package/compiled/postcss/lib/document.d.ts +0 -1
- package/compiled/postcss/lib/fromJSON.d.ts +1 -1
- package/compiled/postcss/lib/input.d.ts +0 -1
- package/compiled/postcss/lib/lazy-result.d.ts +3 -4
- package/compiled/postcss/lib/list.d.ts +1 -1
- package/compiled/postcss/lib/no-work-result.d.ts +0 -1
- package/compiled/postcss/lib/node.d.ts +0 -1
- package/compiled/postcss/lib/parse.d.ts +1 -1
- package/compiled/postcss/lib/postcss.d.ts +1 -3
- package/compiled/postcss/lib/previous-map.d.ts +0 -1
- package/compiled/postcss/lib/processor.d.ts +0 -1
- package/compiled/postcss/lib/result.d.ts +0 -1
- package/compiled/postcss/lib/root.d.ts +0 -1
- package/compiled/postcss/lib/rule.d.ts +12 -12
- package/compiled/postcss/lib/stringifier.d.ts +0 -1
- package/compiled/postcss/lib/stringify.d.ts +1 -1
- package/compiled/postcss/lib/warning.d.ts +0 -1
- package/compiled/postcss/license +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +38 -115
- package/dist/1~rslib-runtime.js +1 -1
- package/dist/{552.js → 753.js} +143 -196
- package/dist/client/hmr.js +23 -10
- package/dist/connect-next.js +636 -26
- package/dist/connect-next.js.LICENSE.txt +14 -1
- package/dist/http-proxy-middleware.js +1169 -1226
- package/dist/http-proxy-middleware.js.LICENSE.txt +0 -35
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +6 -6
- package/dist/manifest-plugin.js +8 -8
- package/dist/memfs.js +16 -56
- package/dist/tinyglobby.js +279 -127
- package/dist/ws.js +2 -2
- package/dist-types/client/hmr.d.ts +1 -1
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/url.d.ts +1 -1
- package/dist-types/pluginHelper.d.ts +1 -8
- package/dist-types/server/devServer.d.ts +9 -7
- package/dist-types/server/socketServer.d.ts +16 -4
- package/dist-types/types/config.d.ts +9 -3
- package/dist-types/types/rspack.d.ts +1 -1
- package/package.json +11 -11
- package/dist/debug.js +0 -503
- package/dist-types/plugins/esm.d.ts +0 -2
- /package/dist/{552.js.LICENSE.txt → 753.js.LICENSE.txt} +0 -0
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
/*! LICENSE: http-proxy-middleware.js.LICENSE.txt */
|
|
2
|
+
import node_http from "node:http";
|
|
3
|
+
import node_https from "node:https";
|
|
4
|
+
import node_http2 from "node:http2";
|
|
5
|
+
import { EventEmitter } from "node:events";
|
|
6
|
+
import "node:net";
|
|
7
|
+
import "node:stream";
|
|
8
|
+
import { URL as external_node_url_URL } from "node:url";
|
|
9
|
+
import "node:zlib";
|
|
10
|
+
import "node:querystring";
|
|
2
11
|
import { __webpack_require__ } from "./1~rslib-runtime.js";
|
|
3
|
-
import "./
|
|
4
|
-
import "
|
|
12
|
+
import "./753.js";
|
|
13
|
+
import * as __rspack_external_node_os_74b4b876 from "node:os";
|
|
14
|
+
import * as __rspack_external_node_process_786449bf from "node:process";
|
|
15
|
+
import * as __rspack_external_node_tty_c64aab7e from "node:tty";
|
|
5
16
|
__webpack_require__.add({
|
|
6
17
|
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
7
18
|
let stringify = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js"), compile = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/compile.js"), expand = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/expand.js"), parse = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/parse.js"), braces = (input, options = {})=>{
|
|
@@ -374,103 +385,332 @@ __webpack_require__.add({
|
|
|
374
385
|
return flat(args), result;
|
|
375
386
|
};
|
|
376
387
|
},
|
|
377
|
-
"../../node_modules/.pnpm/
|
|
378
|
-
|
|
379
|
-
function
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
function
|
|
384
|
-
if ('
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/browser.js" (module, exports, __webpack_require__) {
|
|
389
|
+
let warned;
|
|
390
|
+
function useColors() {
|
|
391
|
+
let m;
|
|
392
|
+
return "u" > typeof window && !!window.process && ('renderer' === window.process.type || !!window.process.__nwjs) || !("u" > typeof navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) && ("u" > typeof document && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || "u" > typeof window && window.console && (window.console.firebug || window.console.exception && window.console.table) || "u" > typeof navigator && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || "u" > typeof navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
393
|
+
}
|
|
394
|
+
function formatArgs(args) {
|
|
395
|
+
if (args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff), !this.useColors) return;
|
|
396
|
+
let c = 'color: ' + this.color;
|
|
397
|
+
args.splice(1, 0, c, 'color: inherit');
|
|
398
|
+
let index = 0, lastC = 0;
|
|
399
|
+
args[0].replace(/%[a-zA-Z%]/g, (match)=>{
|
|
400
|
+
'%%' !== match && (index++, '%c' === match && (lastC = index));
|
|
401
|
+
}), args.splice(lastC, 0, c);
|
|
402
|
+
}
|
|
403
|
+
function save(namespaces) {
|
|
404
|
+
try {
|
|
405
|
+
namespaces ? exports.storage.setItem('debug', namespaces) : exports.storage.removeItem('debug');
|
|
406
|
+
} catch (error) {}
|
|
393
407
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
408
|
+
function load() {
|
|
409
|
+
let r;
|
|
410
|
+
try {
|
|
411
|
+
r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG');
|
|
412
|
+
} catch (error) {}
|
|
413
|
+
return !r && "u" > typeof process && 'env' in process && (r = process.env.DEBUG), r;
|
|
396
414
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
415
|
+
function localstorage() {
|
|
416
|
+
try {
|
|
417
|
+
return localStorage;
|
|
418
|
+
} catch (error) {}
|
|
419
|
+
}
|
|
420
|
+
exports.formatArgs = formatArgs, exports.save = save, exports.load = load, exports.useColors = useColors, exports.storage = localstorage(), warned = !1, exports.destroy = ()=>{
|
|
421
|
+
warned || (warned = !0, console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'));
|
|
422
|
+
}, exports.colors = [
|
|
423
|
+
'#0000CC',
|
|
424
|
+
'#0000FF',
|
|
425
|
+
'#0033CC',
|
|
426
|
+
'#0033FF',
|
|
427
|
+
'#0066CC',
|
|
428
|
+
'#0066FF',
|
|
429
|
+
'#0099CC',
|
|
430
|
+
'#0099FF',
|
|
431
|
+
'#00CC00',
|
|
432
|
+
'#00CC33',
|
|
433
|
+
'#00CC66',
|
|
434
|
+
'#00CC99',
|
|
435
|
+
'#00CCCC',
|
|
436
|
+
'#00CCFF',
|
|
437
|
+
'#3300CC',
|
|
438
|
+
'#3300FF',
|
|
439
|
+
'#3333CC',
|
|
440
|
+
'#3333FF',
|
|
441
|
+
'#3366CC',
|
|
442
|
+
'#3366FF',
|
|
443
|
+
'#3399CC',
|
|
444
|
+
'#3399FF',
|
|
445
|
+
'#33CC00',
|
|
446
|
+
'#33CC33',
|
|
447
|
+
'#33CC66',
|
|
448
|
+
'#33CC99',
|
|
449
|
+
'#33CCCC',
|
|
450
|
+
'#33CCFF',
|
|
451
|
+
'#6600CC',
|
|
452
|
+
'#6600FF',
|
|
453
|
+
'#6633CC',
|
|
454
|
+
'#6633FF',
|
|
455
|
+
'#66CC00',
|
|
456
|
+
'#66CC33',
|
|
457
|
+
'#9900CC',
|
|
458
|
+
'#9900FF',
|
|
459
|
+
'#9933CC',
|
|
460
|
+
'#9933FF',
|
|
461
|
+
'#99CC00',
|
|
462
|
+
'#99CC33',
|
|
463
|
+
'#CC0000',
|
|
464
|
+
'#CC0033',
|
|
465
|
+
'#CC0066',
|
|
466
|
+
'#CC0099',
|
|
467
|
+
'#CC00CC',
|
|
468
|
+
'#CC00FF',
|
|
469
|
+
'#CC3300',
|
|
470
|
+
'#CC3333',
|
|
471
|
+
'#CC3366',
|
|
472
|
+
'#CC3399',
|
|
473
|
+
'#CC33CC',
|
|
474
|
+
'#CC33FF',
|
|
475
|
+
'#CC6600',
|
|
476
|
+
'#CC6633',
|
|
477
|
+
'#CC9900',
|
|
478
|
+
'#CC9933',
|
|
479
|
+
'#CCCC00',
|
|
480
|
+
'#CCCC33',
|
|
481
|
+
'#FF0000',
|
|
482
|
+
'#FF0033',
|
|
483
|
+
'#FF0066',
|
|
484
|
+
'#FF0099',
|
|
485
|
+
'#FF00CC',
|
|
486
|
+
'#FF00FF',
|
|
487
|
+
'#FF3300',
|
|
488
|
+
'#FF3333',
|
|
489
|
+
'#FF3366',
|
|
490
|
+
'#FF3399',
|
|
491
|
+
'#FF33CC',
|
|
492
|
+
'#FF33FF',
|
|
493
|
+
'#FF6600',
|
|
494
|
+
'#FF6633',
|
|
495
|
+
'#FF9900',
|
|
496
|
+
'#FF9933',
|
|
497
|
+
'#FFCC00',
|
|
498
|
+
'#FFCC33'
|
|
499
|
+
], exports.log = console.debug || console.log || (()=>{}), module.exports = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/common.js")(exports);
|
|
500
|
+
let { formatters } = module.exports;
|
|
501
|
+
formatters.j = function(v) {
|
|
502
|
+
try {
|
|
503
|
+
return JSON.stringify(v);
|
|
504
|
+
} catch (error) {
|
|
505
|
+
return '[UnexpectedJSONParseError]: ' + error.message;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
},
|
|
509
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/common.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
510
|
+
module.exports = function setup(env) {
|
|
511
|
+
function selectColor(namespace) {
|
|
512
|
+
let hash = 0;
|
|
513
|
+
for(let i = 0; i < namespace.length; i++)hash = (hash << 5) - hash + namespace.charCodeAt(i) | 0;
|
|
514
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
515
|
+
}
|
|
516
|
+
function createDebug(namespace) {
|
|
517
|
+
let prevTime, namespacesCache, enabledCache, enableOverride = null;
|
|
518
|
+
function debug(...args) {
|
|
519
|
+
if (!debug.enabled) return;
|
|
520
|
+
let self = debug, curr = Number(new Date());
|
|
521
|
+
self.diff = curr - (prevTime || curr), self.prev = prevTime, self.curr = curr, prevTime = curr, args[0] = createDebug.coerce(args[0]), 'string' != typeof args[0] && args.unshift('%O');
|
|
522
|
+
let index = 0;
|
|
523
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format)=>{
|
|
524
|
+
if ('%%' === match) return '%';
|
|
525
|
+
index++;
|
|
526
|
+
let formatter = createDebug.formatters[format];
|
|
527
|
+
if ('function' == typeof formatter) {
|
|
528
|
+
let val = args[index];
|
|
529
|
+
match = formatter.call(self, val), args.splice(index, 1), index--;
|
|
530
|
+
}
|
|
531
|
+
return match;
|
|
532
|
+
}), createDebug.formatArgs.call(self, args), (self.log || createDebug.log).apply(self, args);
|
|
533
|
+
}
|
|
534
|
+
return debug.namespace = namespace, debug.useColors = createDebug.useColors(), debug.color = createDebug.selectColor(namespace), debug.extend = extend, debug.destroy = createDebug.destroy, Object.defineProperty(debug, 'enabled', {
|
|
535
|
+
enumerable: !0,
|
|
536
|
+
configurable: !1,
|
|
537
|
+
get: ()=>null !== enableOverride ? enableOverride : (namespacesCache !== createDebug.namespaces && (namespacesCache = createDebug.namespaces, enabledCache = createDebug.enabled(namespace)), enabledCache),
|
|
538
|
+
set: (v)=>{
|
|
539
|
+
enableOverride = v;
|
|
540
|
+
}
|
|
541
|
+
}), 'function' == typeof createDebug.init && createDebug.init(debug), debug;
|
|
542
|
+
}
|
|
543
|
+
function extend(namespace, delimiter) {
|
|
544
|
+
let newDebug = createDebug(this.namespace + (void 0 === delimiter ? ':' : delimiter) + namespace);
|
|
545
|
+
return newDebug.log = this.log, newDebug;
|
|
546
|
+
}
|
|
547
|
+
function enable(namespaces) {
|
|
548
|
+
for (let ns of (createDebug.save(namespaces), createDebug.namespaces = namespaces, createDebug.names = [], createDebug.skips = [], ('string' == typeof namespaces ? namespaces : '').trim().replace(/\s+/g, ',').split(',').filter(Boolean)))'-' === ns[0] ? createDebug.skips.push(ns.slice(1)) : createDebug.names.push(ns);
|
|
549
|
+
}
|
|
550
|
+
function matchesTemplate(search, template) {
|
|
551
|
+
let searchIndex = 0, templateIndex = 0, starIndex = -1, matchIndex = 0;
|
|
552
|
+
for(; searchIndex < search.length;)if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || '*' === template[templateIndex])) '*' === template[templateIndex] ? (starIndex = templateIndex, matchIndex = searchIndex) : searchIndex++, templateIndex++;
|
|
553
|
+
else {
|
|
554
|
+
if (-1 === starIndex) return !1;
|
|
555
|
+
templateIndex = starIndex + 1, searchIndex = ++matchIndex;
|
|
452
556
|
}
|
|
557
|
+
for(; templateIndex < template.length && '*' === template[templateIndex];)templateIndex++;
|
|
558
|
+
return templateIndex === template.length;
|
|
453
559
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
var evt = prefix ? prefix + event : event;
|
|
461
|
-
if (!this._events[evt]) return this;
|
|
462
|
-
if (!fn) return clearEvent(this, evt), this;
|
|
463
|
-
var listeners = this._events[evt];
|
|
464
|
-
if (listeners.fn) listeners.fn !== fn || once && !listeners.once || context && listeners.context !== context || clearEvent(this, evt);
|
|
465
|
-
else {
|
|
466
|
-
for(var i = 0, events = [], length = listeners.length; i < length; i++)(listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) && events.push(listeners[i]);
|
|
467
|
-
events.length ? this._events[evt] = 1 === events.length ? events[0] : events : clearEvent(this, evt);
|
|
560
|
+
function disable() {
|
|
561
|
+
let namespaces = [
|
|
562
|
+
...createDebug.names,
|
|
563
|
+
...createDebug.skips.map((namespace)=>'-' + namespace)
|
|
564
|
+
].join(',');
|
|
565
|
+
return createDebug.enable(''), namespaces;
|
|
468
566
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
567
|
+
function enabled(name) {
|
|
568
|
+
for (let skip of createDebug.skips)if (matchesTemplate(name, skip)) return !1;
|
|
569
|
+
for (let ns of createDebug.names)if (matchesTemplate(name, ns)) return !0;
|
|
570
|
+
return !1;
|
|
571
|
+
}
|
|
572
|
+
function coerce(val) {
|
|
573
|
+
return val instanceof Error ? val.stack || val.message : val;
|
|
574
|
+
}
|
|
575
|
+
function destroy() {
|
|
576
|
+
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
577
|
+
}
|
|
578
|
+
return createDebug.debug = createDebug, createDebug.default = createDebug, createDebug.coerce = coerce, createDebug.disable = disable, createDebug.enable = enable, createDebug.enabled = enabled, createDebug.humanize = __webpack_require__("../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"), createDebug.destroy = destroy, Object.keys(env).forEach((key)=>{
|
|
579
|
+
createDebug[key] = env[key];
|
|
580
|
+
}), createDebug.names = [], createDebug.skips = [], createDebug.formatters = {}, createDebug.selectColor = selectColor, createDebug.enable(createDebug.load()), createDebug;
|
|
581
|
+
};
|
|
582
|
+
},
|
|
583
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
584
|
+
"u" < typeof process || 'renderer' === process.type || !0 === process.browser || process.__nwjs ? module.exports = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/browser.js") : module.exports = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/node.js");
|
|
585
|
+
},
|
|
586
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/node.js" (module, exports, __webpack_require__) {
|
|
587
|
+
let tty = __webpack_require__("tty"), util = __webpack_require__("util");
|
|
588
|
+
exports.init = init, exports.log = log, exports.formatArgs = formatArgs, exports.save = save, exports.load = load, exports.useColors = useColors, exports.destroy = util.deprecate(()=>{}, 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'), exports.colors = [
|
|
589
|
+
6,
|
|
590
|
+
2,
|
|
591
|
+
3,
|
|
592
|
+
4,
|
|
593
|
+
5,
|
|
594
|
+
1
|
|
595
|
+
];
|
|
596
|
+
try {
|
|
597
|
+
let supportsColor = __webpack_require__("../../node_modules/.pnpm/supports-color@10.2.2/node_modules/supports-color/index.js");
|
|
598
|
+
supportsColor && (supportsColor.stderr || supportsColor).level >= 2 && (exports.colors = [
|
|
599
|
+
20,
|
|
600
|
+
21,
|
|
601
|
+
26,
|
|
602
|
+
27,
|
|
603
|
+
32,
|
|
604
|
+
33,
|
|
605
|
+
38,
|
|
606
|
+
39,
|
|
607
|
+
40,
|
|
608
|
+
41,
|
|
609
|
+
42,
|
|
610
|
+
43,
|
|
611
|
+
44,
|
|
612
|
+
45,
|
|
613
|
+
56,
|
|
614
|
+
57,
|
|
615
|
+
62,
|
|
616
|
+
63,
|
|
617
|
+
68,
|
|
618
|
+
69,
|
|
619
|
+
74,
|
|
620
|
+
75,
|
|
621
|
+
76,
|
|
622
|
+
77,
|
|
623
|
+
78,
|
|
624
|
+
79,
|
|
625
|
+
80,
|
|
626
|
+
81,
|
|
627
|
+
92,
|
|
628
|
+
93,
|
|
629
|
+
98,
|
|
630
|
+
99,
|
|
631
|
+
112,
|
|
632
|
+
113,
|
|
633
|
+
128,
|
|
634
|
+
129,
|
|
635
|
+
134,
|
|
636
|
+
135,
|
|
637
|
+
148,
|
|
638
|
+
149,
|
|
639
|
+
160,
|
|
640
|
+
161,
|
|
641
|
+
162,
|
|
642
|
+
163,
|
|
643
|
+
164,
|
|
644
|
+
165,
|
|
645
|
+
166,
|
|
646
|
+
167,
|
|
647
|
+
168,
|
|
648
|
+
169,
|
|
649
|
+
170,
|
|
650
|
+
171,
|
|
651
|
+
172,
|
|
652
|
+
173,
|
|
653
|
+
178,
|
|
654
|
+
179,
|
|
655
|
+
184,
|
|
656
|
+
185,
|
|
657
|
+
196,
|
|
658
|
+
197,
|
|
659
|
+
198,
|
|
660
|
+
199,
|
|
661
|
+
200,
|
|
662
|
+
201,
|
|
663
|
+
202,
|
|
664
|
+
203,
|
|
665
|
+
204,
|
|
666
|
+
205,
|
|
667
|
+
206,
|
|
668
|
+
207,
|
|
669
|
+
208,
|
|
670
|
+
209,
|
|
671
|
+
214,
|
|
672
|
+
215,
|
|
673
|
+
220,
|
|
674
|
+
221
|
|
675
|
+
]);
|
|
676
|
+
} catch (error) {}
|
|
677
|
+
function useColors() {
|
|
678
|
+
return 'colors' in exports.inspectOpts ? !!exports.inspectOpts.colors : tty.isatty(process.stderr.fd);
|
|
679
|
+
}
|
|
680
|
+
function formatArgs(args) {
|
|
681
|
+
let { namespace: name, useColors } = this;
|
|
682
|
+
if (useColors) {
|
|
683
|
+
let c = this.color, colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c), prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
684
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix), args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
|
685
|
+
} else args[0] = getDate() + name + ' ' + args[0];
|
|
686
|
+
}
|
|
687
|
+
function getDate() {
|
|
688
|
+
return exports.inspectOpts.hideDate ? '' : new Date().toISOString() + ' ';
|
|
689
|
+
}
|
|
690
|
+
function log(...args) {
|
|
691
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
692
|
+
}
|
|
693
|
+
function save(namespaces) {
|
|
694
|
+
namespaces ? process.env.DEBUG = namespaces : delete process.env.DEBUG;
|
|
695
|
+
}
|
|
696
|
+
function load() {
|
|
697
|
+
return process.env.DEBUG;
|
|
698
|
+
}
|
|
699
|
+
function init(debug) {
|
|
700
|
+
debug.inspectOpts = {};
|
|
701
|
+
let keys = Object.keys(exports.inspectOpts);
|
|
702
|
+
for(let i = 0; i < keys.length; i++)debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
703
|
+
}
|
|
704
|
+
exports.inspectOpts = Object.keys(process.env).filter((key)=>/^debug_/i.test(key)).reduce((obj, key)=>{
|
|
705
|
+
let prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k)=>k.toUpperCase()), val = process.env[key];
|
|
706
|
+
return val = !!/^(yes|on|true|enabled)$/i.test(val) || !/^(no|off|false|disabled)$/i.test(val) && ('null' === val ? null : Number(val)), obj[prop] = val, obj;
|
|
707
|
+
}, {}), module.exports = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/common.js")(exports);
|
|
708
|
+
let { formatters } = module.exports;
|
|
709
|
+
formatters.o = function(v) {
|
|
710
|
+
return this.inspectOpts.colors = this.useColors, util.inspect(v, this.inspectOpts).split('\n').map((str)=>str.trim()).join(' ');
|
|
711
|
+
}, formatters.O = function(v) {
|
|
712
|
+
return this.inspectOpts.colors = this.useColors, util.inspect(v, this.inspectOpts);
|
|
713
|
+
};
|
|
474
714
|
},
|
|
475
715
|
"../../node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
476
716
|
let util = __webpack_require__("util"), toRegexRange = __webpack_require__("../../node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js"), isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val), isValidValue = (value)=>'number' == typeof value || 'string' == typeof value && '' !== value, zeros = (input)=>{
|
|
@@ -570,553 +810,6 @@ __webpack_require__.add({
|
|
|
570
810
|
};
|
|
571
811
|
module.exports = fill;
|
|
572
812
|
},
|
|
573
|
-
"../../node_modules/.pnpm/follow-redirects@1.15.11_debug@4.4.3_supports-color@10.2.2_/node_modules/follow-redirects/debug.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
574
|
-
var debug;
|
|
575
|
-
module.exports = function() {
|
|
576
|
-
if (!debug) {
|
|
577
|
-
try {
|
|
578
|
-
debug = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/index.js")("follow-redirects");
|
|
579
|
-
} catch (error) {}
|
|
580
|
-
"function" != typeof debug && (debug = function() {});
|
|
581
|
-
}
|
|
582
|
-
debug.apply(null, arguments);
|
|
583
|
-
};
|
|
584
|
-
},
|
|
585
|
-
"../../node_modules/.pnpm/follow-redirects@1.15.11_debug@4.4.3_supports-color@10.2.2_/node_modules/follow-redirects/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
586
|
-
var looksLikeNode, looksLikeBrowser, looksLikeV8, url = __webpack_require__("url?5f07"), URL = url.URL, http = __webpack_require__("http"), https = __webpack_require__("https"), Writable = __webpack_require__("stream").Writable, assert = __webpack_require__("assert"), debug = __webpack_require__("../../node_modules/.pnpm/follow-redirects@1.15.11_debug@4.4.3_supports-color@10.2.2_/node_modules/follow-redirects/debug.js");
|
|
587
|
-
looksLikeNode = "u" > typeof process, looksLikeBrowser = "u" > typeof window && "u" > typeof document, looksLikeV8 = isFunction(Error.captureStackTrace), looksLikeNode || !looksLikeBrowser && looksLikeV8 || console.warn("The follow-redirects package should be excluded from browser builds.");
|
|
588
|
-
var useNativeURL = !1;
|
|
589
|
-
try {
|
|
590
|
-
assert(new URL(""));
|
|
591
|
-
} catch (error) {
|
|
592
|
-
useNativeURL = "ERR_INVALID_URL" === error.code;
|
|
593
|
-
}
|
|
594
|
-
var preservedUrlFields = [
|
|
595
|
-
"auth",
|
|
596
|
-
"host",
|
|
597
|
-
"hostname",
|
|
598
|
-
"href",
|
|
599
|
-
"path",
|
|
600
|
-
"pathname",
|
|
601
|
-
"port",
|
|
602
|
-
"protocol",
|
|
603
|
-
"query",
|
|
604
|
-
"search",
|
|
605
|
-
"hash"
|
|
606
|
-
], events = [
|
|
607
|
-
"abort",
|
|
608
|
-
"aborted",
|
|
609
|
-
"connect",
|
|
610
|
-
"error",
|
|
611
|
-
"socket",
|
|
612
|
-
"timeout"
|
|
613
|
-
], eventHandlers = Object.create(null);
|
|
614
|
-
events.forEach(function(event) {
|
|
615
|
-
eventHandlers[event] = function(arg1, arg2, arg3) {
|
|
616
|
-
this._redirectable.emit(event, arg1, arg2, arg3);
|
|
617
|
-
};
|
|
618
|
-
});
|
|
619
|
-
var InvalidUrlError = createErrorType("ERR_INVALID_URL", "Invalid URL", TypeError), RedirectionError = createErrorType("ERR_FR_REDIRECTION_FAILURE", "Redirected request failed"), TooManyRedirectsError = createErrorType("ERR_FR_TOO_MANY_REDIRECTS", "Maximum number of redirects exceeded", RedirectionError), MaxBodyLengthExceededError = createErrorType("ERR_FR_MAX_BODY_LENGTH_EXCEEDED", "Request body larger than maxBodyLength limit"), WriteAfterEndError = createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end"), destroy = Writable.prototype.destroy || noop;
|
|
620
|
-
function RedirectableRequest(options, responseCallback) {
|
|
621
|
-
Writable.call(this), this._sanitizeOptions(options), this._options = options, this._ended = !1, this._ending = !1, this._redirectCount = 0, this._redirects = [], this._requestBodyLength = 0, this._requestBodyBuffers = [], responseCallback && this.on("response", responseCallback);
|
|
622
|
-
var self = this;
|
|
623
|
-
this._onNativeResponse = function(response) {
|
|
624
|
-
try {
|
|
625
|
-
self._processResponse(response);
|
|
626
|
-
} catch (cause) {
|
|
627
|
-
self.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({
|
|
628
|
-
cause: cause
|
|
629
|
-
}));
|
|
630
|
-
}
|
|
631
|
-
}, this._performRequest();
|
|
632
|
-
}
|
|
633
|
-
function wrap(protocols) {
|
|
634
|
-
var exports = {
|
|
635
|
-
maxRedirects: 21,
|
|
636
|
-
maxBodyLength: 10485760
|
|
637
|
-
}, nativeProtocols = {};
|
|
638
|
-
return Object.keys(protocols).forEach(function(scheme) {
|
|
639
|
-
var protocol = scheme + ":", nativeProtocol = nativeProtocols[protocol] = protocols[scheme], wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
|
|
640
|
-
function get(input, options, callback) {
|
|
641
|
-
var wrappedRequest = wrappedProtocol.request(input, options, callback);
|
|
642
|
-
return wrappedRequest.end(), wrappedRequest;
|
|
643
|
-
}
|
|
644
|
-
Object.defineProperties(wrappedProtocol, {
|
|
645
|
-
request: {
|
|
646
|
-
value: function request(input, options, callback) {
|
|
647
|
-
return isURL(input) ? input = spreadUrlObject(input) : isString(input) ? input = spreadUrlObject(parseUrl(input)) : (callback = options, options = validateUrl(input), input = {
|
|
648
|
-
protocol: protocol
|
|
649
|
-
}), isFunction(options) && (callback = options, options = null), (options = Object.assign({
|
|
650
|
-
maxRedirects: exports.maxRedirects,
|
|
651
|
-
maxBodyLength: exports.maxBodyLength
|
|
652
|
-
}, input, options)).nativeProtocols = nativeProtocols, isString(options.host) || isString(options.hostname) || (options.hostname = "::1"), assert.equal(options.protocol, protocol, "protocol mismatch"), debug("options", options), new RedirectableRequest(options, callback);
|
|
653
|
-
},
|
|
654
|
-
configurable: !0,
|
|
655
|
-
enumerable: !0,
|
|
656
|
-
writable: !0
|
|
657
|
-
},
|
|
658
|
-
get: {
|
|
659
|
-
value: get,
|
|
660
|
-
configurable: !0,
|
|
661
|
-
enumerable: !0,
|
|
662
|
-
writable: !0
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
}), exports;
|
|
666
|
-
}
|
|
667
|
-
function noop() {}
|
|
668
|
-
function parseUrl(input) {
|
|
669
|
-
var parsed;
|
|
670
|
-
if (useNativeURL) parsed = new URL(input);
|
|
671
|
-
else if (!isString((parsed = validateUrl(url.parse(input))).protocol)) throw new InvalidUrlError({
|
|
672
|
-
input
|
|
673
|
-
});
|
|
674
|
-
return parsed;
|
|
675
|
-
}
|
|
676
|
-
function resolveUrl(relative, base) {
|
|
677
|
-
return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
|
|
678
|
-
}
|
|
679
|
-
function validateUrl(input) {
|
|
680
|
-
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname) || /^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) throw new InvalidUrlError({
|
|
681
|
-
input: input.href || input
|
|
682
|
-
});
|
|
683
|
-
return input;
|
|
684
|
-
}
|
|
685
|
-
function spreadUrlObject(urlObject, target) {
|
|
686
|
-
var spread = target || {};
|
|
687
|
-
for (var key of preservedUrlFields)spread[key] = urlObject[key];
|
|
688
|
-
return spread.hostname.startsWith("[") && (spread.hostname = spread.hostname.slice(1, -1)), "" !== spread.port && (spread.port = Number(spread.port)), spread.path = spread.search ? spread.pathname + spread.search : spread.pathname, spread;
|
|
689
|
-
}
|
|
690
|
-
function removeMatchingHeaders(regex, headers) {
|
|
691
|
-
var lastValue;
|
|
692
|
-
for(var header in headers)regex.test(header) && (lastValue = headers[header], delete headers[header]);
|
|
693
|
-
return null == lastValue ? void 0 : String(lastValue).trim();
|
|
694
|
-
}
|
|
695
|
-
function createErrorType(code, message, baseClass) {
|
|
696
|
-
function CustomError(properties) {
|
|
697
|
-
isFunction(Error.captureStackTrace) && Error.captureStackTrace(this, this.constructor), Object.assign(this, properties || {}), this.code = code, this.message = this.cause ? message + ": " + this.cause.message : message;
|
|
698
|
-
}
|
|
699
|
-
return CustomError.prototype = new (baseClass || Error)(), Object.defineProperties(CustomError.prototype, {
|
|
700
|
-
constructor: {
|
|
701
|
-
value: CustomError,
|
|
702
|
-
enumerable: !1
|
|
703
|
-
},
|
|
704
|
-
name: {
|
|
705
|
-
value: "Error [" + code + "]",
|
|
706
|
-
enumerable: !1
|
|
707
|
-
}
|
|
708
|
-
}), CustomError;
|
|
709
|
-
}
|
|
710
|
-
function destroyRequest(request, error) {
|
|
711
|
-
for (var event of events)request.removeListener(event, eventHandlers[event]);
|
|
712
|
-
request.on("error", noop), request.destroy(error);
|
|
713
|
-
}
|
|
714
|
-
function isSubdomain(subdomain, domain) {
|
|
715
|
-
assert(isString(subdomain) && isString(domain));
|
|
716
|
-
var dot = subdomain.length - domain.length - 1;
|
|
717
|
-
return dot > 0 && "." === subdomain[dot] && subdomain.endsWith(domain);
|
|
718
|
-
}
|
|
719
|
-
function isString(value) {
|
|
720
|
-
return "string" == typeof value || value instanceof String;
|
|
721
|
-
}
|
|
722
|
-
function isFunction(value) {
|
|
723
|
-
return "function" == typeof value;
|
|
724
|
-
}
|
|
725
|
-
function isBuffer(value) {
|
|
726
|
-
return "object" == typeof value && "length" in value;
|
|
727
|
-
}
|
|
728
|
-
function isURL(value) {
|
|
729
|
-
return URL && value instanceof URL;
|
|
730
|
-
}
|
|
731
|
-
RedirectableRequest.prototype = Object.create(Writable.prototype), RedirectableRequest.prototype.abort = function() {
|
|
732
|
-
destroyRequest(this._currentRequest), this._currentRequest.abort(), this.emit("abort");
|
|
733
|
-
}, RedirectableRequest.prototype.destroy = function(error) {
|
|
734
|
-
return destroyRequest(this._currentRequest, error), destroy.call(this, error), this;
|
|
735
|
-
}, RedirectableRequest.prototype.write = function(data, encoding, callback) {
|
|
736
|
-
if (this._ending) throw new WriteAfterEndError();
|
|
737
|
-
if (!isString(data) && !isBuffer(data)) throw TypeError("data should be a string, Buffer or Uint8Array");
|
|
738
|
-
if (isFunction(encoding) && (callback = encoding, encoding = null), 0 === data.length) {
|
|
739
|
-
callback && callback();
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
this._requestBodyLength + data.length <= this._options.maxBodyLength ? (this._requestBodyLength += data.length, this._requestBodyBuffers.push({
|
|
743
|
-
data: data,
|
|
744
|
-
encoding: encoding
|
|
745
|
-
}), this._currentRequest.write(data, encoding, callback)) : (this.emit("error", new MaxBodyLengthExceededError()), this.abort());
|
|
746
|
-
}, RedirectableRequest.prototype.end = function(data, encoding, callback) {
|
|
747
|
-
if (isFunction(data) ? (callback = data, data = encoding = null) : isFunction(encoding) && (callback = encoding, encoding = null), data) {
|
|
748
|
-
var self = this, currentRequest = this._currentRequest;
|
|
749
|
-
this.write(data, encoding, function() {
|
|
750
|
-
self._ended = !0, currentRequest.end(null, null, callback);
|
|
751
|
-
}), this._ending = !0;
|
|
752
|
-
} else this._ended = this._ending = !0, this._currentRequest.end(null, null, callback);
|
|
753
|
-
}, RedirectableRequest.prototype.setHeader = function(name, value) {
|
|
754
|
-
this._options.headers[name] = value, this._currentRequest.setHeader(name, value);
|
|
755
|
-
}, RedirectableRequest.prototype.removeHeader = function(name) {
|
|
756
|
-
delete this._options.headers[name], this._currentRequest.removeHeader(name);
|
|
757
|
-
}, RedirectableRequest.prototype.setTimeout = function(msecs, callback) {
|
|
758
|
-
var self = this;
|
|
759
|
-
function destroyOnTimeout(socket) {
|
|
760
|
-
socket.setTimeout(msecs), socket.removeListener("timeout", socket.destroy), socket.addListener("timeout", socket.destroy);
|
|
761
|
-
}
|
|
762
|
-
function startTimer(socket) {
|
|
763
|
-
self._timeout && clearTimeout(self._timeout), self._timeout = setTimeout(function() {
|
|
764
|
-
self.emit("timeout"), clearTimer();
|
|
765
|
-
}, msecs), destroyOnTimeout(socket);
|
|
766
|
-
}
|
|
767
|
-
function clearTimer() {
|
|
768
|
-
self._timeout && (clearTimeout(self._timeout), self._timeout = null), self.removeListener("abort", clearTimer), self.removeListener("error", clearTimer), self.removeListener("response", clearTimer), self.removeListener("close", clearTimer), callback && self.removeListener("timeout", callback), self.socket || self._currentRequest.removeListener("socket", startTimer);
|
|
769
|
-
}
|
|
770
|
-
return callback && this.on("timeout", callback), this.socket ? startTimer(this.socket) : this._currentRequest.once("socket", startTimer), this.on("socket", destroyOnTimeout), this.on("abort", clearTimer), this.on("error", clearTimer), this.on("response", clearTimer), this.on("close", clearTimer), this;
|
|
771
|
-
}, [
|
|
772
|
-
"flushHeaders",
|
|
773
|
-
"getHeader",
|
|
774
|
-
"setNoDelay",
|
|
775
|
-
"setSocketKeepAlive"
|
|
776
|
-
].forEach(function(method) {
|
|
777
|
-
RedirectableRequest.prototype[method] = function(a, b) {
|
|
778
|
-
return this._currentRequest[method](a, b);
|
|
779
|
-
};
|
|
780
|
-
}), [
|
|
781
|
-
"aborted",
|
|
782
|
-
"connection",
|
|
783
|
-
"socket"
|
|
784
|
-
].forEach(function(property) {
|
|
785
|
-
Object.defineProperty(RedirectableRequest.prototype, property, {
|
|
786
|
-
get: function() {
|
|
787
|
-
return this._currentRequest[property];
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
}), RedirectableRequest.prototype._sanitizeOptions = function(options) {
|
|
791
|
-
if (options.headers || (options.headers = {}), options.host && (options.hostname || (options.hostname = options.host), delete options.host), !options.pathname && options.path) {
|
|
792
|
-
var searchPos = options.path.indexOf("?");
|
|
793
|
-
searchPos < 0 ? options.pathname = options.path : (options.pathname = options.path.substring(0, searchPos), options.search = options.path.substring(searchPos));
|
|
794
|
-
}
|
|
795
|
-
}, RedirectableRequest.prototype._performRequest = function() {
|
|
796
|
-
var protocol = this._options.protocol, nativeProtocol = this._options.nativeProtocols[protocol];
|
|
797
|
-
if (!nativeProtocol) throw TypeError("Unsupported protocol " + protocol);
|
|
798
|
-
if (this._options.agents) {
|
|
799
|
-
var scheme = protocol.slice(0, -1);
|
|
800
|
-
this._options.agent = this._options.agents[scheme];
|
|
801
|
-
}
|
|
802
|
-
var request = this._currentRequest = nativeProtocol.request(this._options, this._onNativeResponse);
|
|
803
|
-
for (var event of (request._redirectable = this, events))request.on(event, eventHandlers[event]);
|
|
804
|
-
if (this._currentUrl = /^\//.test(this._options.path) ? url.format(this._options) : this._options.path, this._isRedirect) {
|
|
805
|
-
var i = 0, self = this, buffers = this._requestBodyBuffers;
|
|
806
|
-
!function writeNext(error) {
|
|
807
|
-
if (request === self._currentRequest) if (error) self.emit("error", error);
|
|
808
|
-
else if (i < buffers.length) {
|
|
809
|
-
var buffer = buffers[i++];
|
|
810
|
-
request.finished || request.write(buffer.data, buffer.encoding, writeNext);
|
|
811
|
-
} else self._ended && request.end();
|
|
812
|
-
}();
|
|
813
|
-
}
|
|
814
|
-
}, RedirectableRequest.prototype._processResponse = function(response) {
|
|
815
|
-
var requestHeaders, statusCode = response.statusCode;
|
|
816
|
-
this._options.trackRedirects && this._redirects.push({
|
|
817
|
-
url: this._currentUrl,
|
|
818
|
-
headers: response.headers,
|
|
819
|
-
statusCode: statusCode
|
|
820
|
-
});
|
|
821
|
-
var location = response.headers.location;
|
|
822
|
-
if (!location || !1 === this._options.followRedirects || statusCode < 300 || statusCode >= 400) {
|
|
823
|
-
response.responseUrl = this._currentUrl, response.redirects = this._redirects, this.emit("response", response), this._requestBodyBuffers = [];
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
if (destroyRequest(this._currentRequest), response.destroy(), ++this._redirectCount > this._options.maxRedirects) throw new TooManyRedirectsError();
|
|
827
|
-
var beforeRedirect = this._options.beforeRedirect;
|
|
828
|
-
beforeRedirect && (requestHeaders = Object.assign({
|
|
829
|
-
Host: response.req.getHeader("host")
|
|
830
|
-
}, this._options.headers));
|
|
831
|
-
var method = this._options.method;
|
|
832
|
-
(301 !== statusCode && 302 !== statusCode || "POST" !== this._options.method) && (303 !== statusCode || /^(?:GET|HEAD)$/.test(this._options.method)) || (this._options.method = "GET", this._requestBodyBuffers = [], removeMatchingHeaders(/^content-/i, this._options.headers));
|
|
833
|
-
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers), currentUrlParts = parseUrl(this._currentUrl), currentHost = currentHostHeader || currentUrlParts.host, currentUrl = /^\w+:/.test(location) ? this._currentUrl : url.format(Object.assign(currentUrlParts, {
|
|
834
|
-
host: currentHost
|
|
835
|
-
})), redirectUrl = resolveUrl(location, currentUrl);
|
|
836
|
-
if (debug("redirecting to", redirectUrl.href), this._isRedirect = !0, spreadUrlObject(redirectUrl, this._options), (redirectUrl.protocol === currentUrlParts.protocol || "https:" === redirectUrl.protocol) && (redirectUrl.host === currentHost || isSubdomain(redirectUrl.host, currentHost)) || removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers), isFunction(beforeRedirect)) {
|
|
837
|
-
var responseDetails = {
|
|
838
|
-
headers: response.headers,
|
|
839
|
-
statusCode: statusCode
|
|
840
|
-
}, requestDetails = {
|
|
841
|
-
url: currentUrl,
|
|
842
|
-
method: method,
|
|
843
|
-
headers: requestHeaders
|
|
844
|
-
};
|
|
845
|
-
beforeRedirect(this._options, responseDetails, requestDetails), this._sanitizeOptions(this._options);
|
|
846
|
-
}
|
|
847
|
-
this._performRequest();
|
|
848
|
-
}, module.exports = wrap({
|
|
849
|
-
http: http,
|
|
850
|
-
https: https
|
|
851
|
-
}), module.exports.wrap = wrap;
|
|
852
|
-
},
|
|
853
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
854
|
-
module.exports = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy.js");
|
|
855
|
-
},
|
|
856
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
857
|
-
var ProxyServer = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/index.js").Server;
|
|
858
|
-
function createProxyServer(options) {
|
|
859
|
-
return new ProxyServer(options);
|
|
860
|
-
}
|
|
861
|
-
ProxyServer.createProxyServer = createProxyServer, ProxyServer.createServer = createProxyServer, ProxyServer.createProxy = createProxyServer, module.exports = ProxyServer;
|
|
862
|
-
},
|
|
863
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/common.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
864
|
-
var url = __webpack_require__("url?5f07"), required = __webpack_require__("../../node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js"), upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i, isSSL = /^https|wss/;
|
|
865
|
-
function hasPort(host) {
|
|
866
|
-
return !!~host.indexOf(':');
|
|
867
|
-
}
|
|
868
|
-
exports.isSSL = isSSL, exports.setupOutgoing = function(outgoing, options, req, forward) {
|
|
869
|
-
outgoing.port = options[forward || 'target'].port || (isSSL.test(options[forward || 'target'].protocol) ? 443 : 80), [
|
|
870
|
-
'host',
|
|
871
|
-
'hostname',
|
|
872
|
-
'socketPath',
|
|
873
|
-
'pfx',
|
|
874
|
-
'key',
|
|
875
|
-
'passphrase',
|
|
876
|
-
'cert',
|
|
877
|
-
'ca',
|
|
878
|
-
'ciphers',
|
|
879
|
-
'secureProtocol'
|
|
880
|
-
].forEach(function(e) {
|
|
881
|
-
outgoing[e] = options[forward || 'target'][e];
|
|
882
|
-
}), outgoing.method = options.method || req.method, outgoing.headers = Object.assign({}, req.headers), options.headers && Object.assign(outgoing.headers, options.headers), options.auth && (outgoing.auth = options.auth), options.ca && (outgoing.ca = options.ca), isSSL.test(options[forward || 'target'].protocol) && (outgoing.rejectUnauthorized = void 0 === options.secure || options.secure), outgoing.agent = options.agent || !1, outgoing.localAddress = options.localAddress, !outgoing.agent && (outgoing.headers = outgoing.headers || {}, 'string' == typeof outgoing.headers.connection && upgradeHeader.test(outgoing.headers.connection) || (outgoing.headers.connection = 'close'));
|
|
883
|
-
var target = options[forward || 'target'], targetPath = target && !1 !== options.prependPath && target.path || '', outgoingPath = options.toProxy ? req.url : url.parse(req.url).path || '';
|
|
884
|
-
return outgoingPath = options.ignorePath ? '' : outgoingPath, outgoing.path = exports.urlJoin(targetPath, outgoingPath), options.changeOrigin && (outgoing.headers.host = required(outgoing.port, options[forward || 'target'].protocol) && !hasPort(outgoing.host) ? outgoing.host + ':' + outgoing.port : outgoing.host), outgoing;
|
|
885
|
-
}, exports.setupSocket = function(socket) {
|
|
886
|
-
return socket.setTimeout(0), socket.setNoDelay(!0), socket.setKeepAlive(!0, 0), socket;
|
|
887
|
-
}, exports.getPort = function(req) {
|
|
888
|
-
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : '';
|
|
889
|
-
return res ? res[1] : exports.hasEncryptedConnection(req) ? '443' : '80';
|
|
890
|
-
}, exports.hasEncryptedConnection = function(req) {
|
|
891
|
-
return !!(req.connection.encrypted || req.connection.pair);
|
|
892
|
-
}, exports.urlJoin = function() {
|
|
893
|
-
var retSegs, args = Array.prototype.slice.call(arguments), lastIndex = args.length - 1, lastSegs = args[lastIndex].split('?');
|
|
894
|
-
return args[lastIndex] = lastSegs.shift(), (retSegs = [
|
|
895
|
-
args.filter(Boolean).join('/').replace(/\/+/g, '/').replace('http:/', 'http://').replace('https:/', 'https://')
|
|
896
|
-
]).push.apply(retSegs, lastSegs), retSegs.join('?');
|
|
897
|
-
}, exports.rewriteCookieProperty = function rewriteCookieProperty(header, config, property) {
|
|
898
|
-
return Array.isArray(header) ? header.map(function(headerElement) {
|
|
899
|
-
return rewriteCookieProperty(headerElement, config, property);
|
|
900
|
-
}) : header.replace(RegExp("(;\\s*" + property + "=)([^;]+)", 'i'), function(match, prefix, previousValue) {
|
|
901
|
-
var newValue;
|
|
902
|
-
if (previousValue in config) newValue = config[previousValue];
|
|
903
|
-
else {
|
|
904
|
-
if (!('*' in config)) return match;
|
|
905
|
-
newValue = config['*'];
|
|
906
|
-
}
|
|
907
|
-
return newValue ? prefix + newValue : '';
|
|
908
|
-
});
|
|
909
|
-
};
|
|
910
|
-
},
|
|
911
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
912
|
-
var httpProxy = module.exports, parse_url = __webpack_require__("url?5f07").parse, EE3 = __webpack_require__("../../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"), http = __webpack_require__("http"), https = __webpack_require__("https"), web = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js"), ws = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js");
|
|
913
|
-
function createRightProxy(type) {
|
|
914
|
-
return function(options) {
|
|
915
|
-
return function(req, res) {
|
|
916
|
-
var head, cbl, passes = 'ws' === type ? this.wsPasses : this.webPasses, args = [].slice.call(arguments), cntr = args.length - 1;
|
|
917
|
-
'function' == typeof args[cntr] && (cbl = args[cntr], cntr--);
|
|
918
|
-
var requestOptions = options;
|
|
919
|
-
if (!(args[cntr] instanceof Buffer) && args[cntr] !== res && (Object.assign(requestOptions = Object.assign({}, options), args[cntr]), cntr--), args[cntr] instanceof Buffer && (head = args[cntr]), [
|
|
920
|
-
'target',
|
|
921
|
-
'forward'
|
|
922
|
-
].forEach(function(e) {
|
|
923
|
-
'string' == typeof requestOptions[e] && (requestOptions[e] = parse_url(requestOptions[e]));
|
|
924
|
-
}), !requestOptions.target && !requestOptions.forward) return this.emit('error', Error('Must provide a proper URL as target'));
|
|
925
|
-
for(var i = 0; i < passes.length && !passes[i](req, res, requestOptions, head, this, cbl); i++);
|
|
926
|
-
};
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
function ProxyServer(options) {
|
|
930
|
-
EE3.call(this), (options = options || {}).prependPath = !1 !== options.prependPath, this.web = this.proxyRequest = createRightProxy('web')(options), this.ws = this.proxyWebsocketRequest = createRightProxy('ws')(options), this.options = options, this.webPasses = Object.keys(web).map(function(pass) {
|
|
931
|
-
return web[pass];
|
|
932
|
-
}), this.wsPasses = Object.keys(ws).map(function(pass) {
|
|
933
|
-
return ws[pass];
|
|
934
|
-
}), this.on('error', this.onError, this);
|
|
935
|
-
}
|
|
936
|
-
httpProxy.Server = ProxyServer, httpProxy.createRightProxy = createRightProxy, __webpack_require__("util").inherits(ProxyServer, EE3), ProxyServer.prototype.onError = function(err) {
|
|
937
|
-
if (1 === this.listeners('error').length) throw err;
|
|
938
|
-
}, ProxyServer.prototype.listen = function(port, hostname) {
|
|
939
|
-
var self = this, closure = function(req, res) {
|
|
940
|
-
self.web(req, res);
|
|
941
|
-
};
|
|
942
|
-
return this._server = this.options.ssl ? https.createServer(this.options.ssl, closure) : http.createServer(closure), this.options.ws && this._server.on('upgrade', function(req, socket, head) {
|
|
943
|
-
self.ws(req, socket, head);
|
|
944
|
-
}), this._server.listen(port, hostname), this;
|
|
945
|
-
}, ProxyServer.prototype.close = function(callback) {
|
|
946
|
-
var self = this;
|
|
947
|
-
function done() {
|
|
948
|
-
self._server = null, callback && callback.apply(null, arguments);
|
|
949
|
-
}
|
|
950
|
-
this._server && this._server.close(done);
|
|
951
|
-
}, ProxyServer.prototype.before = function(type, passName, callback) {
|
|
952
|
-
if ('ws' !== type && 'web' !== type) throw Error('type must be `web` or `ws`');
|
|
953
|
-
var passes = 'ws' === type ? this.wsPasses : this.webPasses, i = !1;
|
|
954
|
-
if (passes.forEach(function(v, idx) {
|
|
955
|
-
v.name === passName && (i = idx);
|
|
956
|
-
}), !1 === i) throw Error('No such pass');
|
|
957
|
-
passes.splice(i, 0, callback);
|
|
958
|
-
}, ProxyServer.prototype.after = function(type, passName, callback) {
|
|
959
|
-
if ('ws' !== type && 'web' !== type) throw Error('type must be `web` or `ws`');
|
|
960
|
-
var passes = 'ws' === type ? this.wsPasses : this.webPasses, i = !1;
|
|
961
|
-
if (passes.forEach(function(v, idx) {
|
|
962
|
-
v.name === passName && (i = idx);
|
|
963
|
-
}), !1 === i) throw Error('No such pass');
|
|
964
|
-
passes.splice(i++, 0, callback);
|
|
965
|
-
};
|
|
966
|
-
},
|
|
967
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
968
|
-
var httpNative = __webpack_require__("http"), httpsNative = __webpack_require__("https"), web_o = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js"), common = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/common.js"), followRedirects = __webpack_require__("../../node_modules/.pnpm/follow-redirects@1.15.11_debug@4.4.3_supports-color@10.2.2_/node_modules/follow-redirects/index.js");
|
|
969
|
-
web_o = Object.keys(web_o).map(function(pass) {
|
|
970
|
-
return web_o[pass];
|
|
971
|
-
});
|
|
972
|
-
var nativeAgents = {
|
|
973
|
-
http: httpNative,
|
|
974
|
-
https: httpsNative
|
|
975
|
-
};
|
|
976
|
-
module.exports = {
|
|
977
|
-
deleteLength: function deleteLength(req, res, options) {
|
|
978
|
-
'DELETE' !== req.method && 'OPTIONS' !== req.method || req.headers['content-length'] || (req.headers['content-length'] = '0', delete req.headers['transfer-encoding']);
|
|
979
|
-
},
|
|
980
|
-
timeout: function timeout(req, res, options) {
|
|
981
|
-
options.timeout && req.socket.setTimeout(options.timeout);
|
|
982
|
-
},
|
|
983
|
-
XHeaders: function XHeaders(req, res, options) {
|
|
984
|
-
if (options.xfwd) {
|
|
985
|
-
var encrypted = req.isSpdy || common.hasEncryptedConnection(req), values = {
|
|
986
|
-
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
987
|
-
port: common.getPort(req),
|
|
988
|
-
proto: encrypted ? 'https' : 'http'
|
|
989
|
-
};
|
|
990
|
-
[
|
|
991
|
-
'for',
|
|
992
|
-
'port',
|
|
993
|
-
'proto'
|
|
994
|
-
].forEach(function(header) {
|
|
995
|
-
req.headers['x-forwarded-' + header] = (req.headers['x-forwarded-' + header] || '') + (req.headers['x-forwarded-' + header] ? ',' : '') + values[header];
|
|
996
|
-
}), req.headers['x-forwarded-host'] = req.headers['x-forwarded-host'] || req.headers.host || '';
|
|
997
|
-
}
|
|
998
|
-
},
|
|
999
|
-
stream: function stream(req, res, options, _, server, clb) {
|
|
1000
|
-
server.emit('start', req, res, options.target || options.forward);
|
|
1001
|
-
var agents = options.followRedirects ? followRedirects : nativeAgents, http = agents.http, https = agents.https;
|
|
1002
|
-
if (options.forward) {
|
|
1003
|
-
var forwardReq = ('https:' === options.forward.protocol ? https : http).request(common.setupOutgoing(options.ssl || {}, options, req, 'forward')), forwardError = createErrorHandler(forwardReq, options.forward);
|
|
1004
|
-
if (req.on('error', forwardError), forwardReq.on('error', forwardError), (options.buffer || req).pipe(forwardReq), !options.target) return res.end();
|
|
1005
|
-
}
|
|
1006
|
-
var proxyReq = ('https:' === options.target.protocol ? https : http).request(common.setupOutgoing(options.ssl || {}, options, req));
|
|
1007
|
-
proxyReq.on('socket', function(socket) {
|
|
1008
|
-
server && !proxyReq.getHeader('expect') && server.emit('proxyReq', proxyReq, req, res, options);
|
|
1009
|
-
}), options.proxyTimeout && proxyReq.setTimeout(options.proxyTimeout, function() {
|
|
1010
|
-
proxyReq.abort();
|
|
1011
|
-
}), req.on('aborted', function() {
|
|
1012
|
-
proxyReq.abort();
|
|
1013
|
-
});
|
|
1014
|
-
var proxyError = createErrorHandler(proxyReq, options.target);
|
|
1015
|
-
function createErrorHandler(proxyReq, url) {
|
|
1016
|
-
return function proxyError(err) {
|
|
1017
|
-
if (req.socket.destroyed && 'ECONNRESET' === err.code) return server.emit('econnreset', err, req, res, url), proxyReq.abort();
|
|
1018
|
-
clb ? clb(err, req, res, url) : server.emit('error', err, req, res, url);
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
req.on('error', proxyError), proxyReq.on('error', proxyError), (options.buffer || req).pipe(proxyReq), proxyReq.on('response', function(proxyRes) {
|
|
1022
|
-
if (server && server.emit('proxyRes', proxyRes, req, res), !res.headersSent && !options.selfHandleResponse) for(var i = 0; i < web_o.length && !web_o[i](req, res, proxyRes, options); i++);
|
|
1023
|
-
res.finished ? server && server.emit('end', req, res, proxyRes) : (proxyRes.on('end', function() {
|
|
1024
|
-
server && server.emit('end', req, res, proxyRes);
|
|
1025
|
-
}), options.selfHandleResponse || proxyRes.pipe(res));
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
},
|
|
1030
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1031
|
-
var url = __webpack_require__("url?5f07"), common = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/common.js"), redirectRegex = /^201|30(1|2|7|8)$/;
|
|
1032
|
-
module.exports = {
|
|
1033
|
-
removeChunked: function removeChunked(req, res, proxyRes) {
|
|
1034
|
-
'1.0' === req.httpVersion && delete proxyRes.headers['transfer-encoding'];
|
|
1035
|
-
},
|
|
1036
|
-
setConnection: function setConnection(req, res, proxyRes) {
|
|
1037
|
-
'1.0' === req.httpVersion ? proxyRes.headers.connection = req.headers.connection || 'close' : '2.0' === req.httpVersion || proxyRes.headers.connection || (proxyRes.headers.connection = req.headers.connection || 'keep-alive');
|
|
1038
|
-
},
|
|
1039
|
-
setRedirectHostRewrite: function setRedirectHostRewrite(req, res, proxyRes, options) {
|
|
1040
|
-
if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers.location && redirectRegex.test(proxyRes.statusCode)) {
|
|
1041
|
-
var target = url.parse(options.target), u = url.parse(proxyRes.headers.location);
|
|
1042
|
-
target.host == u.host && (options.hostRewrite ? u.host = options.hostRewrite : options.autoRewrite && (u.host = req.headers.host), options.protocolRewrite && (u.protocol = options.protocolRewrite), proxyRes.headers.location = u.format());
|
|
1043
|
-
}
|
|
1044
|
-
},
|
|
1045
|
-
writeHeaders: function writeHeaders(req, res, proxyRes, options) {
|
|
1046
|
-
var rawHeaderKeyMap, rewriteCookieDomainConfig = options.cookieDomainRewrite, rewriteCookiePathConfig = options.cookiePathRewrite, preserveHeaderKeyCase = options.preserveHeaderKeyCase, setHeader = function(key, header) {
|
|
1047
|
-
void 0 != header && (rewriteCookieDomainConfig && 'set-cookie' === key.toLowerCase() && (header = common.rewriteCookieProperty(header, rewriteCookieDomainConfig, 'domain')), rewriteCookiePathConfig && 'set-cookie' === key.toLowerCase() && (header = common.rewriteCookieProperty(header, rewriteCookiePathConfig, 'path')), res.setHeader(String(key).trim(), header));
|
|
1048
|
-
};
|
|
1049
|
-
if ('string' == typeof rewriteCookieDomainConfig && (rewriteCookieDomainConfig = {
|
|
1050
|
-
'*': rewriteCookieDomainConfig
|
|
1051
|
-
}), 'string' == typeof rewriteCookiePathConfig && (rewriteCookiePathConfig = {
|
|
1052
|
-
'*': rewriteCookiePathConfig
|
|
1053
|
-
}), preserveHeaderKeyCase && void 0 != proxyRes.rawHeaders) {
|
|
1054
|
-
rawHeaderKeyMap = {};
|
|
1055
|
-
for(var i = 0; i < proxyRes.rawHeaders.length; i += 2){
|
|
1056
|
-
var key = proxyRes.rawHeaders[i];
|
|
1057
|
-
rawHeaderKeyMap[key.toLowerCase()] = key;
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
Object.keys(proxyRes.headers).forEach(function(key) {
|
|
1061
|
-
var header = proxyRes.headers[key];
|
|
1062
|
-
preserveHeaderKeyCase && rawHeaderKeyMap && (key = rawHeaderKeyMap[key] || key), setHeader(key, header);
|
|
1063
|
-
});
|
|
1064
|
-
},
|
|
1065
|
-
writeStatusCode: function writeStatusCode(req, res, proxyRes) {
|
|
1066
|
-
proxyRes.statusMessage ? (res.statusCode = proxyRes.statusCode, res.statusMessage = proxyRes.statusMessage) : res.statusCode = proxyRes.statusCode;
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
},
|
|
1070
|
-
"../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1071
|
-
var http = __webpack_require__("http"), https = __webpack_require__("https"), common = __webpack_require__("../../node_modules/.pnpm/http-proxy@1.18.1_patch_hash=424b689da454f1f336d635615733f30568882789c1173f861c30f95ba8_7c4b684cae90eb7d05b3dfae37f0ceb4/node_modules/http-proxy/lib/http-proxy/common.js");
|
|
1072
|
-
module.exports = {
|
|
1073
|
-
checkMethodAndHeader: function checkMethodAndHeader(req, socket) {
|
|
1074
|
-
if ('GET' !== req.method || !req.headers.upgrade || 'websocket' !== req.headers.upgrade.toLowerCase()) return socket.destroy(), !0;
|
|
1075
|
-
},
|
|
1076
|
-
XHeaders: function XHeaders(req, socket, options) {
|
|
1077
|
-
if (options.xfwd) {
|
|
1078
|
-
var values = {
|
|
1079
|
-
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
1080
|
-
port: common.getPort(req),
|
|
1081
|
-
proto: common.hasEncryptedConnection(req) ? 'wss' : 'ws'
|
|
1082
|
-
};
|
|
1083
|
-
[
|
|
1084
|
-
'for',
|
|
1085
|
-
'port',
|
|
1086
|
-
'proto'
|
|
1087
|
-
].forEach(function(header) {
|
|
1088
|
-
req.headers['x-forwarded-' + header] = (req.headers['x-forwarded-' + header] || '') + (req.headers['x-forwarded-' + header] ? ',' : '') + values[header];
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
},
|
|
1092
|
-
stream: function stream(req, socket, options, head, server, clb) {
|
|
1093
|
-
var createHttpHeader = function(line, headers) {
|
|
1094
|
-
return Object.keys(headers).reduce(function(head, key) {
|
|
1095
|
-
var value = headers[key];
|
|
1096
|
-
if (!Array.isArray(value)) return head.push(key + ': ' + value), head;
|
|
1097
|
-
for(var i = 0; i < value.length; i++)head.push(key + ': ' + value[i]);
|
|
1098
|
-
return head;
|
|
1099
|
-
}, [
|
|
1100
|
-
line
|
|
1101
|
-
]).join('\r\n') + '\r\n\r\n';
|
|
1102
|
-
};
|
|
1103
|
-
common.setupSocket(socket), head && head.length && socket.unshift(head);
|
|
1104
|
-
var proxyReq = (common.isSSL.test(options.target.protocol) ? https : http).request(common.setupOutgoing(options.ssl || {}, options, req));
|
|
1105
|
-
return server && server.emit('proxyReqWs', proxyReq, req, socket, options, head), proxyReq.on('error', onOutgoingError), proxyReq.on('response', function(res) {
|
|
1106
|
-
res.upgrade || (socket.write(createHttpHeader('HTTP/' + res.httpVersion + ' ' + res.statusCode + ' ' + res.statusMessage, res.headers)), res.pipe(socket));
|
|
1107
|
-
}), proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
|
|
1108
|
-
proxySocket.on('error', onOutgoingError), proxySocket.on('end', function() {
|
|
1109
|
-
server.emit('close', proxyRes, proxySocket, proxyHead);
|
|
1110
|
-
}), socket.on('error', function() {
|
|
1111
|
-
proxySocket.end();
|
|
1112
|
-
}), common.setupSocket(proxySocket), proxyHead && proxyHead.length && proxySocket.unshift(proxyHead), socket.write(createHttpHeader('HTTP/1.1 101 Switching Protocols', proxyRes.headers)), proxySocket.pipe(socket).pipe(proxySocket), server.emit('open', proxySocket), server.emit('proxySocket', proxySocket);
|
|
1113
|
-
}), proxyReq.end();
|
|
1114
|
-
function onOutgoingError(err) {
|
|
1115
|
-
clb ? clb(err, req, socket) : server.emit('error', err, req, socket), socket.end();
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
};
|
|
1119
|
-
},
|
|
1120
813
|
"../../node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js" (module) {
|
|
1121
814
|
module.exports = function isExtglob(str) {
|
|
1122
815
|
var match;
|
|
@@ -1178,15 +871,6 @@ __webpack_require__.add({
|
|
|
1178
871
|
return 'number' == typeof num ? num - num == 0 : 'string' == typeof num && '' !== num.trim() && (Number.isFinite ? Number.isFinite(+num) : isFinite(+num));
|
|
1179
872
|
};
|
|
1180
873
|
},
|
|
1181
|
-
"../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.js" (__unused_rspack_module, exports) {
|
|
1182
|
-
function isObject(o) {
|
|
1183
|
-
return '[object Object]' === Object.prototype.toString.call(o);
|
|
1184
|
-
}
|
|
1185
|
-
exports.isPlainObject = function isPlainObject(o) {
|
|
1186
|
-
var ctor, prot;
|
|
1187
|
-
return !1 !== isObject(o) && (void 0 === (ctor = o.constructor) || !1 !== isObject(prot = ctor.prototype) && !1 !== prot.hasOwnProperty('isPrototypeOf'));
|
|
1188
|
-
};
|
|
1189
|
-
},
|
|
1190
874
|
"../../node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1191
875
|
let util = __webpack_require__("util"), braces = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js"), picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/index.js"), utils = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"), isEmptyString = (v)=>'' === v || './' === v, hasBraces = (v)=>{
|
|
1192
876
|
let index = v.indexOf('{');
|
|
@@ -1285,11 +969,81 @@ __webpack_require__.add({
|
|
|
1285
969
|
});
|
|
1286
970
|
}, micromatch.hasBraces = hasBraces, module.exports = micromatch;
|
|
1287
971
|
},
|
|
972
|
+
"../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js" (module) {
|
|
973
|
+
function parse(str) {
|
|
974
|
+
if (!((str = String(str)).length > 100)) {
|
|
975
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
976
|
+
if (match) {
|
|
977
|
+
var n = parseFloat(match[1]);
|
|
978
|
+
switch((match[2] || 'ms').toLowerCase()){
|
|
979
|
+
case 'years':
|
|
980
|
+
case 'year':
|
|
981
|
+
case 'yrs':
|
|
982
|
+
case 'yr':
|
|
983
|
+
case 'y':
|
|
984
|
+
return 31557600000 * n;
|
|
985
|
+
case 'weeks':
|
|
986
|
+
case 'week':
|
|
987
|
+
case 'w':
|
|
988
|
+
return 604800000 * n;
|
|
989
|
+
case 'days':
|
|
990
|
+
case 'day':
|
|
991
|
+
case 'd':
|
|
992
|
+
return 86400000 * n;
|
|
993
|
+
case 'hours':
|
|
994
|
+
case 'hour':
|
|
995
|
+
case 'hrs':
|
|
996
|
+
case 'hr':
|
|
997
|
+
case 'h':
|
|
998
|
+
return 3600000 * n;
|
|
999
|
+
case 'minutes':
|
|
1000
|
+
case 'minute':
|
|
1001
|
+
case 'mins':
|
|
1002
|
+
case 'min':
|
|
1003
|
+
case 'm':
|
|
1004
|
+
return 60000 * n;
|
|
1005
|
+
case 'seconds':
|
|
1006
|
+
case 'second':
|
|
1007
|
+
case 'secs':
|
|
1008
|
+
case 'sec':
|
|
1009
|
+
case 's':
|
|
1010
|
+
return 1000 * n;
|
|
1011
|
+
case 'milliseconds':
|
|
1012
|
+
case 'millisecond':
|
|
1013
|
+
case 'msecs':
|
|
1014
|
+
case 'msec':
|
|
1015
|
+
case 'ms':
|
|
1016
|
+
return n;
|
|
1017
|
+
default:
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function fmtShort(ms) {
|
|
1024
|
+
var msAbs = Math.abs(ms);
|
|
1025
|
+
return msAbs >= 86400000 ? Math.round(ms / 86400000) + 'd' : msAbs >= 3600000 ? Math.round(ms / 3600000) + 'h' : msAbs >= 60000 ? Math.round(ms / 60000) + 'm' : msAbs >= 1000 ? Math.round(ms / 1000) + 's' : ms + 'ms';
|
|
1026
|
+
}
|
|
1027
|
+
function fmtLong(ms) {
|
|
1028
|
+
var msAbs = Math.abs(ms);
|
|
1029
|
+
return msAbs >= 86400000 ? plural(ms, msAbs, 86400000, 'day') : msAbs >= 3600000 ? plural(ms, msAbs, 3600000, 'hour') : msAbs >= 60000 ? plural(ms, msAbs, 60000, 'minute') : msAbs >= 1000 ? plural(ms, msAbs, 1000, 'second') : ms + ' ms';
|
|
1030
|
+
}
|
|
1031
|
+
function plural(ms, msAbs, n, name) {
|
|
1032
|
+
return Math.round(ms / n) + ' ' + name + (msAbs >= 1.5 * n ? 's' : '');
|
|
1033
|
+
}
|
|
1034
|
+
module.exports = function(val, options) {
|
|
1035
|
+
options = options || {};
|
|
1036
|
+
var type = typeof val;
|
|
1037
|
+
if ('string' === type && val.length > 0) return parse(val);
|
|
1038
|
+
if ('number' === type && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
|
|
1039
|
+
throw Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
|
1040
|
+
};
|
|
1041
|
+
},
|
|
1288
1042
|
"../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1289
1043
|
module.exports = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js");
|
|
1290
1044
|
},
|
|
1291
1045
|
"../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1292
|
-
let path = __webpack_require__("path?
|
|
1046
|
+
let path = __webpack_require__("path?aeb1"), WIN_NO_SLASH = "[^\\\\/]", QMARK = '[^/]', END_ANCHOR = "(?:\\/|$)", START_ANCHOR = "(?:^|\\/)", DOTS_SLASH = `\\.{1,2}${END_ANCHOR}`, NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`, NO_DOT_SLASH = `(?!\\.{0,1}${END_ANCHOR})`, NO_DOTS_SLASH = `(?!${DOTS_SLASH})`, STAR = `${QMARK}*?`, POSIX_CHARS = {
|
|
1293
1047
|
DOT_LITERAL: '\\.',
|
|
1294
1048
|
PLUS_LITERAL: '\\+',
|
|
1295
1049
|
QMARK_LITERAL: '\\?',
|
|
@@ -1967,7 +1721,7 @@ __webpack_require__.add({
|
|
|
1967
1721
|
}, module.exports = parse;
|
|
1968
1722
|
},
|
|
1969
1723
|
"../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1970
|
-
let path = __webpack_require__("path?
|
|
1724
|
+
let path = __webpack_require__("path?aeb1"), scan = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/scan.js"), parse = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/parse.js"), utils = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"), constants = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"), picomatch = (glob, options, returnState = !1)=>{
|
|
1971
1725
|
if (Array.isArray(glob)) {
|
|
1972
1726
|
let fns = glob.map((input)=>picomatch(input, options, returnState));
|
|
1973
1727
|
return (str)=>{
|
|
@@ -2195,7 +1949,7 @@ __webpack_require__.add({
|
|
|
2195
1949
|
};
|
|
2196
1950
|
},
|
|
2197
1951
|
"../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2198
|
-
let path = __webpack_require__("path?
|
|
1952
|
+
let path = __webpack_require__("path?aeb1"), win32 = 'win32' === process.platform, { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js");
|
|
2199
1953
|
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val), exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str), exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str), exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'), exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/'), exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match), exports.supportsLookbehinds = ()=>{
|
|
2200
1954
|
let segs = process.version.slice(1).split('.').map(Number);
|
|
2201
1955
|
return 3 === segs.length && !!(segs[0] >= 9) || 8 === segs[0] && !!(segs[1] >= 10);
|
|
@@ -2210,26 +1964,6 @@ __webpack_require__.add({
|
|
|
2210
1964
|
return !0 === state.negated && (output = `(?:^(?!${output}).*$)`), output;
|
|
2211
1965
|
};
|
|
2212
1966
|
},
|
|
2213
|
-
"../../node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js" (module) {
|
|
2214
|
-
module.exports = function required(port, protocol) {
|
|
2215
|
-
if (protocol = protocol.split(':')[0], !(port *= 1)) return !1;
|
|
2216
|
-
switch(protocol){
|
|
2217
|
-
case 'http':
|
|
2218
|
-
case 'ws':
|
|
2219
|
-
return 80 !== port;
|
|
2220
|
-
case 'https':
|
|
2221
|
-
case 'wss':
|
|
2222
|
-
return 443 !== port;
|
|
2223
|
-
case 'ftp':
|
|
2224
|
-
return 21 !== port;
|
|
2225
|
-
case 'gopher':
|
|
2226
|
-
return 70 !== port;
|
|
2227
|
-
case 'file':
|
|
2228
|
-
return !1;
|
|
2229
|
-
}
|
|
2230
|
-
return 0 !== port;
|
|
2231
|
-
};
|
|
2232
|
-
},
|
|
2233
1967
|
"../../node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2234
1968
|
let isNumber = __webpack_require__("../../node_modules/.pnpm/is-number@7.0.0/node_modules/is-number/index.js"), toRegexRange = (min, max, options)=>{
|
|
2235
1969
|
if (!1 === isNumber(min)) throw TypeError('toRegexRange: expected the first argument to be a number');
|
|
@@ -2354,594 +2088,803 @@ __webpack_require__.add({
|
|
|
2354
2088
|
}
|
|
2355
2089
|
toRegexRange.cache = {}, toRegexRange.clearCache = ()=>toRegexRange.cache = {}, module.exports = toRegexRange;
|
|
2356
2090
|
},
|
|
2357
|
-
"
|
|
2358
|
-
exports
|
|
2359
|
-
let errors_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/errors.js");
|
|
2360
|
-
function verifyConfig(options) {
|
|
2361
|
-
if (!options.target && !options.router) throw Error(errors_1.ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING);
|
|
2362
|
-
}
|
|
2363
|
-
},
|
|
2364
|
-
"../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/debug.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2365
|
-
exports.Debug = void 0, exports.Debug = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/index.js")('http-proxy-middleware');
|
|
2091
|
+
"node:os?3b8c" (module) {
|
|
2092
|
+
module.exports = __rspack_external_node_os_74b4b876;
|
|
2366
2093
|
},
|
|
2367
|
-
"
|
|
2368
|
-
|
|
2369
|
-
exports.ERRORS = void 0, (ERRORS1 = ERRORS || (exports.ERRORS = ERRORS = {})).ERR_CONFIG_FACTORY_TARGET_MISSING = "[HPM] Missing \"target\" option. Example: {target: \"http://www.example.org\"}", ERRORS1.ERR_CONTEXT_MATCHER_GENERIC = "[HPM] Invalid pathFilter. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]", ERRORS1.ERR_CONTEXT_MATCHER_INVALID_ARRAY = "[HPM] Invalid pathFilter. Plain paths (e.g. \"/api\") can not be mixed with globs (e.g. \"/api/**\"). Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"].", ERRORS1.ERR_PATH_REWRITER_CONFIG = "[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function";
|
|
2094
|
+
"node:process?aa5c" (module) {
|
|
2095
|
+
module.exports = __rspack_external_node_process_786449bf;
|
|
2370
2096
|
},
|
|
2371
|
-
"
|
|
2372
|
-
|
|
2373
|
-
value: !0
|
|
2374
|
-
}), exports.createProxyMiddleware = createProxyMiddleware;
|
|
2375
|
-
let http_proxy_middleware_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/http-proxy-middleware.js");
|
|
2376
|
-
function createProxyMiddleware(options) {
|
|
2377
|
-
let { middleware } = new http_proxy_middleware_1.HttpProxyMiddleware(options);
|
|
2378
|
-
return middleware;
|
|
2379
|
-
}
|
|
2097
|
+
"node:tty?4724" (module) {
|
|
2098
|
+
module.exports = __rspack_external_node_tty_c64aab7e;
|
|
2380
2099
|
},
|
|
2381
|
-
"../../node_modules/.pnpm/
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2100
|
+
"../../node_modules/.pnpm/supports-color@10.2.2/node_modules/supports-color/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2101
|
+
let flagForceColor;
|
|
2102
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
2103
|
+
createSupportsColor: ()=>createSupportsColor,
|
|
2104
|
+
default: ()=>__rspack_default_export
|
|
2105
|
+
});
|
|
2106
|
+
var node_process__rspack_import_0 = __webpack_require__("node:process?aa5c"), node_os__rspack_import_1 = __webpack_require__("node:os?3b8c"), node_tty__rspack_import_2 = __webpack_require__("node:tty?4724");
|
|
2107
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process__rspack_import_0.default.argv) {
|
|
2108
|
+
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
2109
|
+
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
2110
|
+
}
|
|
2111
|
+
let { env } = node_process__rspack_import_0.default;
|
|
2112
|
+
function envForceColor() {
|
|
2113
|
+
if (!('FORCE_COLOR' in env)) return;
|
|
2114
|
+
if ('true' === env.FORCE_COLOR) return 1;
|
|
2115
|
+
if ('false' === env.FORCE_COLOR) return 0;
|
|
2116
|
+
if (0 === env.FORCE_COLOR.length) return 1;
|
|
2117
|
+
let level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
2118
|
+
if ([
|
|
2119
|
+
0,
|
|
2120
|
+
1,
|
|
2121
|
+
2,
|
|
2122
|
+
3
|
|
2123
|
+
].includes(level)) return level;
|
|
2124
|
+
}
|
|
2125
|
+
function translateLevel(level) {
|
|
2126
|
+
return 0 !== level && {
|
|
2127
|
+
level,
|
|
2128
|
+
hasBasic: !0,
|
|
2129
|
+
has256: level >= 2,
|
|
2130
|
+
has16m: level >= 3
|
|
2412
2131
|
};
|
|
2413
|
-
contentType.includes('application/json') || contentType.includes('+json') ? writeBody(JSON.stringify(requestBody)) : contentType.includes('application/x-www-form-urlencoded') ? writeBody(querystring.stringify(requestBody)) : contentType.includes('multipart/form-data') && writeBody(handlerFormDataBodyData(contentType, requestBody));
|
|
2414
|
-
}
|
|
2415
|
-
function handlerFormDataBodyData(contentType, data) {
|
|
2416
|
-
let boundary = contentType.replace(/^.*boundary=(.*)$/, '$1'), str = '';
|
|
2417
|
-
for (let [key, value] of Object.entries(data))str += `--${boundary}\r\nContent-Disposition: form-data; name="${key}"\r\n\r\n${value}\r\n`;
|
|
2418
|
-
return str;
|
|
2419
2132
|
}
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
return m[k];
|
|
2429
|
-
}
|
|
2430
|
-
}), Object.defineProperty(o, k2, desc);
|
|
2431
|
-
} : function(o, m, k, k2) {
|
|
2432
|
-
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
2433
|
-
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
2434
|
-
for(var p in m)"default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
2435
|
-
};
|
|
2436
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2437
|
-
value: !0
|
|
2438
|
-
}), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/handlers/public.js"), exports);
|
|
2439
|
-
},
|
|
2440
|
-
"../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/handlers/public.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2441
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2442
|
-
value: !0
|
|
2443
|
-
}), exports.fixRequestBody = exports.responseInterceptor = void 0;
|
|
2444
|
-
var response_interceptor_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/handlers/response-interceptor.js");
|
|
2445
|
-
Object.defineProperty(exports, "responseInterceptor", {
|
|
2446
|
-
enumerable: !0,
|
|
2447
|
-
get: function() {
|
|
2448
|
-
return response_interceptor_1.responseInterceptor;
|
|
2133
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = !0 } = {}) {
|
|
2134
|
+
let noFlagForceColor = envForceColor();
|
|
2135
|
+
void 0 !== noFlagForceColor && (flagForceColor = noFlagForceColor);
|
|
2136
|
+
let forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
2137
|
+
if (0 === forceColor) return 0;
|
|
2138
|
+
if (sniffFlags) {
|
|
2139
|
+
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
|
|
2140
|
+
if (hasFlag('color=256')) return 2;
|
|
2449
2141
|
}
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2142
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) return 1;
|
|
2143
|
+
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
2144
|
+
let min = forceColor || 0;
|
|
2145
|
+
if ('dumb' === env.TERM) return min;
|
|
2146
|
+
if ('win32' === node_process__rspack_import_0.default.platform) {
|
|
2147
|
+
let osRelease = node_os__rspack_import_1.default.release().split('.');
|
|
2148
|
+
return Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
|
|
2456
2149
|
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
}
|
|
2478
|
-
};
|
|
2479
|
-
}
|
|
2480
|
-
function decompress(proxyRes, contentEncoding) {
|
|
2481
|
-
let decompress, _proxyRes = proxyRes;
|
|
2482
|
-
switch(contentEncoding){
|
|
2483
|
-
case 'gzip':
|
|
2484
|
-
decompress = zlib.createGunzip();
|
|
2485
|
-
break;
|
|
2486
|
-
case 'br':
|
|
2487
|
-
decompress = zlib.createBrotliDecompress();
|
|
2488
|
-
break;
|
|
2489
|
-
case 'deflate':
|
|
2490
|
-
decompress = zlib.createInflate();
|
|
2150
|
+
if ('CI' in env) return [
|
|
2151
|
+
'GITHUB_ACTIONS',
|
|
2152
|
+
'GITEA_ACTIONS',
|
|
2153
|
+
'CIRCLECI'
|
|
2154
|
+
].some((key)=>key in env) ? 3 : [
|
|
2155
|
+
'TRAVIS',
|
|
2156
|
+
'APPVEYOR',
|
|
2157
|
+
'GITLAB_CI',
|
|
2158
|
+
'BUILDKITE',
|
|
2159
|
+
'DRONE'
|
|
2160
|
+
].some((sign)=>sign in env) || 'codeship' === env.CI_NAME ? 1 : min;
|
|
2161
|
+
if ('TEAMCITY_VERSION' in env) return +!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION);
|
|
2162
|
+
if ('truecolor' === env.COLORTERM || 'xterm-kitty' === env.TERM || 'xterm-ghostty' === env.TERM || 'wezterm' === env.TERM) return 3;
|
|
2163
|
+
if ('TERM_PROGRAM' in env) {
|
|
2164
|
+
let version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2165
|
+
switch(env.TERM_PROGRAM){
|
|
2166
|
+
case 'iTerm.app':
|
|
2167
|
+
return version >= 3 ? 3 : 2;
|
|
2168
|
+
case 'Apple_Terminal':
|
|
2169
|
+
return 2;
|
|
2170
|
+
}
|
|
2491
2171
|
}
|
|
2492
|
-
return
|
|
2172
|
+
return /-256(color)?$/i.test(env.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM) || 'COLORTERM' in env ? 1 : min;
|
|
2493
2173
|
}
|
|
2494
|
-
function
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
'transfer-encoding'
|
|
2500
|
-
].includes(key))).forEach((key)=>{
|
|
2501
|
-
let value = originalResponse.headers[key];
|
|
2502
|
-
'set-cookie' === key && (value = (value = Array.isArray(value) ? value : [
|
|
2503
|
-
value
|
|
2504
|
-
]).map((x)=>x.replace(/Domain=[^;]+?/i, ''))), response.setHeader(key, value);
|
|
2505
|
-
});
|
|
2506
|
-
} else response.headers = originalResponse.headers;
|
|
2174
|
+
function createSupportsColor(stream, options = {}) {
|
|
2175
|
+
return translateLevel(_supportsColor(stream, {
|
|
2176
|
+
streamIsTTY: stream && stream.isTTY,
|
|
2177
|
+
...options
|
|
2178
|
+
}));
|
|
2507
2179
|
}
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
let activeProxyOptions = await this.prepareProxyRequest(req);
|
|
2517
|
-
(0, debug_1.Debug)("proxy request to target: %O", activeProxyOptions.target), this.proxy.web(req, res, activeProxyOptions);
|
|
2518
|
-
} catch (err) {
|
|
2519
|
-
next?.(err);
|
|
2520
|
-
}
|
|
2521
|
-
else next?.();
|
|
2522
|
-
let server = (req.socket ?? req.connection)?.server;
|
|
2523
|
-
server && !this.serverOnCloseSubscribed && (server.on('close', ()=>{
|
|
2524
|
-
(0, debug_1.Debug)('server close signal received: closing proxy server'), this.proxy.close();
|
|
2525
|
-
}), this.serverOnCloseSubscribed = !0), !0 === this.proxyOptions.ws && this.catchUpgradeRequest(server);
|
|
2526
|
-
}, this.catchUpgradeRequest = (server)=>{
|
|
2527
|
-
this.wsInternalSubscribed || ((0, debug_1.Debug)('subscribing to server upgrade event'), server.on('upgrade', this.handleUpgrade), this.wsInternalSubscribed = !0);
|
|
2528
|
-
}, this.handleUpgrade = async (req, socket, head)=>{
|
|
2529
|
-
try {
|
|
2530
|
-
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
2531
|
-
let activeProxyOptions = await this.prepareProxyRequest(req);
|
|
2532
|
-
this.proxy.ws(req, socket, head, activeProxyOptions), (0, debug_1.Debug)('server upgrade event received. Proxying WebSocket');
|
|
2533
|
-
}
|
|
2534
|
-
} catch (err) {
|
|
2535
|
-
this.proxy.emit('error', err, req, socket);
|
|
2536
|
-
}
|
|
2537
|
-
}, this.shouldProxy = (pathFilter, req)=>{
|
|
2538
|
-
try {
|
|
2539
|
-
return (0, path_filter_1.matchPathFilter)(pathFilter, req.url, req);
|
|
2540
|
-
} catch (err) {
|
|
2541
|
-
return (0, debug_1.Debug)('Error: matchPathFilter() called with request url: ', `"${req.url}"`), this.logger.error(err), !1;
|
|
2542
|
-
}
|
|
2543
|
-
}, this.prepareProxyRequest = async (req)=>{
|
|
2544
|
-
this.middleware.__LEGACY_HTTP_PROXY_MIDDLEWARE__ && (req.url = req.originalUrl || req.url);
|
|
2545
|
-
let newProxyOptions = Object.assign({}, this.proxyOptions);
|
|
2546
|
-
return await this.applyRouter(req, newProxyOptions), await this.applyPathRewrite(req, this.pathRewriter), newProxyOptions;
|
|
2547
|
-
}, this.applyRouter = async (req, options)=>{
|
|
2548
|
-
let newTarget;
|
|
2549
|
-
options.router && (newTarget = await Router.getTarget(req, options)) && ((0, debug_1.Debug)('router new target: "%s"', newTarget), options.target = newTarget);
|
|
2550
|
-
}, this.applyPathRewrite = async (req, pathRewriter)=>{
|
|
2551
|
-
if (pathRewriter) {
|
|
2552
|
-
let path = await pathRewriter(req.url, req);
|
|
2553
|
-
'string' == typeof path ? ((0, debug_1.Debug)('pathRewrite new path: %s', req.url), req.url = path) : (0, debug_1.Debug)('pathRewrite: no rewritten path found: %s', req.url);
|
|
2554
|
-
}
|
|
2555
|
-
}, (0, configuration_1.verifyConfig)(options), this.proxyOptions = options, this.logger = (0, logger_1.getLogger)(options), (0, debug_1.Debug)("create proxy server"), this.proxy = httpProxy.createProxyServer({}), this.registerPlugins(this.proxy, this.proxyOptions), this.pathRewriter = PathRewriter.createPathRewriter(this.proxyOptions.pathRewrite), this.middleware.upgrade = (req, socket, head)=>{
|
|
2556
|
-
this.wsInternalSubscribed || this.handleUpgrade(req, socket, head);
|
|
2557
|
-
};
|
|
2558
|
-
}
|
|
2559
|
-
registerPlugins(proxy, options) {
|
|
2560
|
-
(0, get_plugins_1.getPlugins)(options).forEach((plugin)=>{
|
|
2561
|
-
(0, debug_1.Debug)(`register plugin: "${(0, function_1.getFunctionName)(plugin)}"`), plugin(proxy, options);
|
|
2562
|
-
});
|
|
2563
|
-
}
|
|
2180
|
+
hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never') ? flagForceColor = 0 : (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) && (flagForceColor = 1);
|
|
2181
|
+
let __rspack_default_export = {
|
|
2182
|
+
stdout: createSupportsColor({
|
|
2183
|
+
isTTY: node_tty__rspack_import_2.default.isatty(1)
|
|
2184
|
+
}),
|
|
2185
|
+
stderr: createSupportsColor({
|
|
2186
|
+
isTTY: node_tty__rspack_import_2.default.isatty(2)
|
|
2187
|
+
})
|
|
2564
2188
|
};
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
let upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i, defaultAgents = {
|
|
2192
|
+
http: new node_http.Agent({
|
|
2193
|
+
keepAlive: !0,
|
|
2194
|
+
maxSockets: 256,
|
|
2195
|
+
maxFreeSockets: 64
|
|
2196
|
+
}),
|
|
2197
|
+
https: new node_https.Agent({
|
|
2198
|
+
keepAlive: !0,
|
|
2199
|
+
maxSockets: 256,
|
|
2200
|
+
maxFreeSockets: 64
|
|
2201
|
+
})
|
|
2202
|
+
}, isSSL = /^https|wss/, HTTP2_HEADER_BLACKLIST = [
|
|
2203
|
+
":method",
|
|
2204
|
+
":path",
|
|
2205
|
+
":scheme",
|
|
2206
|
+
":authority"
|
|
2207
|
+
];
|
|
2208
|
+
function setupOutgoing(outgoing, options, req, forward) {
|
|
2209
|
+
for (let e of (outgoing.port = options[forward || "target"].port || (isSSL.test(options[forward || "target"].protocol ?? "http") ? 443 : 80), [
|
|
2210
|
+
"host",
|
|
2211
|
+
"hostname",
|
|
2212
|
+
"socketPath",
|
|
2213
|
+
"pfx",
|
|
2214
|
+
"key",
|
|
2215
|
+
"passphrase",
|
|
2216
|
+
"cert",
|
|
2217
|
+
"ca",
|
|
2218
|
+
"ciphers",
|
|
2219
|
+
"secureProtocol"
|
|
2220
|
+
])){
|
|
2221
|
+
let value = options[forward || "target"][e];
|
|
2222
|
+
void 0 !== value && (outgoing[e] = value);
|
|
2223
|
+
}
|
|
2224
|
+
if (outgoing.method = options.method || req.method, outgoing.headers = {
|
|
2225
|
+
...req.headers
|
|
2226
|
+
}, req.headers?.[":authority"] && (outgoing.headers.host = req.headers[":authority"]), options.headers) for (let key of Object.keys(options.headers))outgoing.headers[key] = options.headers[key];
|
|
2227
|
+
if (req.httpVersionMajor > 1) for (let header of HTTP2_HEADER_BLACKLIST)delete outgoing.headers[header];
|
|
2228
|
+
if (options.auth && (outgoing.auth = options.auth), options.ca && (outgoing.ca = options.ca), isSSL.test(options[forward || "target"].protocol ?? "http") && (outgoing.rejectUnauthorized = void 0 === options.secure || options.secure), void 0 !== options.agent) outgoing.agent = options.agent || !1;
|
|
2229
|
+
else if (req.httpVersionMajor > 1) outgoing.agent = !1;
|
|
2230
|
+
else {
|
|
2231
|
+
let targetProto = options[forward || "target"].protocol ?? "http";
|
|
2232
|
+
outgoing.agent = isSSL.test(targetProto) ? defaultAgents.https : defaultAgents.http;
|
|
2233
|
+
}
|
|
2234
|
+
outgoing.localAddress = options.localAddress, !outgoing.agent && (outgoing.headers = outgoing.headers || {}, "string" == typeof outgoing.headers.connection && upgradeHeader.test(outgoing.headers.connection) || (outgoing.headers.connection = "close"));
|
|
2235
|
+
let target = options[forward || "target"], targetPath = target && !1 !== options.prependPath && target.pathname || "", targetSearch = target instanceof URL && !1 !== options.prependPath && target.search || "", reqUrl = req.url || "", qIdx = reqUrl.indexOf("?"), reqPath = -1 === qIdx ? reqUrl : reqUrl.slice(0, qIdx), reqSearch = -1 === qIdx ? "" : reqUrl.slice(qIdx), normalizedPath = reqPath ? "/" === reqPath[0] ? reqPath : "/" + reqPath : "/", outgoingPath = options.toProxy ? "/" + reqUrl : normalizedPath + reqSearch, fullPath = joinURL(targetPath, outgoingPath = options.ignorePath ? "" : outgoingPath);
|
|
2236
|
+
return targetSearch && (fullPath = fullPath.includes("?") ? fullPath.replace("?", targetSearch + "&") : fullPath + targetSearch), outgoing.path = fullPath, options.changeOrigin && (outgoing.headers.host = requiresPort(outgoing.port, options[forward || "target"].protocol) && !hasPort(outgoing.host) ? outgoing.host + ":" + outgoing.port : outgoing.host ?? void 0), outgoing;
|
|
2237
|
+
}
|
|
2238
|
+
function joinURL(base, path) {
|
|
2239
|
+
if (!base || "/" === base) return path || "/";
|
|
2240
|
+
if (!path || "/" === path) return base || "/";
|
|
2241
|
+
let baseHasTrailing = "/" === base[base.length - 1], pathHasLeading = "/" === path[0];
|
|
2242
|
+
return baseHasTrailing && pathHasLeading ? base + path.slice(1) : baseHasTrailing || pathHasLeading ? base + path : base + "/" + path;
|
|
2243
|
+
}
|
|
2244
|
+
function setupSocket(socket) {
|
|
2245
|
+
return socket.setTimeout(0), socket.setNoDelay(!0), socket.setKeepAlive(!0, 0), socket;
|
|
2246
|
+
}
|
|
2247
|
+
function getPort(req) {
|
|
2248
|
+
let hostHeader = req.headers[":authority"] || req.headers.host, res = hostHeader ? hostHeader.match(/:(\d+)/) : "";
|
|
2249
|
+
return res ? res[1] : hasEncryptedConnection(req) ? "443" : "80";
|
|
2250
|
+
}
|
|
2251
|
+
function hasEncryptedConnection(req) {
|
|
2252
|
+
let socket = req.socket;
|
|
2253
|
+
return !!socket && "encrypted" in socket && socket.encrypted;
|
|
2254
|
+
}
|
|
2255
|
+
function rewriteCookieProperty(header, config, property) {
|
|
2256
|
+
return Array.isArray(header) ? header.map(function(headerElement) {
|
|
2257
|
+
return rewriteCookieProperty(headerElement, config, property);
|
|
2258
|
+
}) : header.replace(RegExp(String.raw`(;\s*` + property + "=)([^;]+)", "i"), function(match, prefix, previousValue) {
|
|
2259
|
+
let newValue;
|
|
2260
|
+
if (previousValue in config) newValue = config[previousValue];
|
|
2261
|
+
else {
|
|
2262
|
+
if (!("*" in config)) return match;
|
|
2263
|
+
newValue = config["*"];
|
|
2264
|
+
}
|
|
2265
|
+
return newValue ? prefix + newValue : "";
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
function hasPort(host) {
|
|
2269
|
+
return !!host && !!~host.indexOf(":");
|
|
2270
|
+
}
|
|
2271
|
+
function requiresPort(_port, _protocol) {
|
|
2272
|
+
let protocol = _protocol?.split(":")[0], port = +_port;
|
|
2273
|
+
if (!port) return !1;
|
|
2274
|
+
switch(protocol){
|
|
2275
|
+
case "http":
|
|
2276
|
+
case "ws":
|
|
2277
|
+
return 80 !== port;
|
|
2278
|
+
case "https":
|
|
2279
|
+
case "wss":
|
|
2280
|
+
return 443 !== port;
|
|
2281
|
+
case "ftp":
|
|
2282
|
+
return 21 !== port;
|
|
2283
|
+
case "gopher":
|
|
2284
|
+
return 70 !== port;
|
|
2285
|
+
case "file":
|
|
2286
|
+
return !1;
|
|
2287
|
+
}
|
|
2288
|
+
return 0 !== port;
|
|
2289
|
+
}
|
|
2290
|
+
let redirectRegex = /^201|30([12378])$/, webOutgoingMiddleware = [
|
|
2291
|
+
(req, res, proxyRes)=>{
|
|
2292
|
+
("1.0" === req.httpVersion || req.httpVersionMajor >= 2 || 204 === proxyRes.statusCode || 304 === proxyRes.statusCode) && delete proxyRes.headers["transfer-encoding"];
|
|
2565
2293
|
},
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
void 0 === k2 && (k2 = k);
|
|
2569
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2570
|
-
(!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) && (desc = {
|
|
2571
|
-
enumerable: !0,
|
|
2572
|
-
get: function() {
|
|
2573
|
-
return m[k];
|
|
2574
|
-
}
|
|
2575
|
-
}), Object.defineProperty(o, k2, desc);
|
|
2576
|
-
} : function(o, m, k, k2) {
|
|
2577
|
-
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
2578
|
-
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
2579
|
-
for(var p in m)"default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
2580
|
-
};
|
|
2581
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2582
|
-
value: !0
|
|
2583
|
-
}), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/factory.js"), exports), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/handlers/index.js"), exports), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/plugins/default/index.js"), exports), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/legacy/index.js"), exports);
|
|
2294
|
+
(req, res, proxyRes)=>{
|
|
2295
|
+
"1.0" === req.httpVersion ? proxyRes.headers.connection = req.headers.connection || "close" : req.httpVersionMajor < 2 && !proxyRes.headers.connection ? proxyRes.headers.connection = req.headers.connection || "keep-alive" : req.httpVersionMajor >= 2 && delete proxyRes.headers.connection;
|
|
2584
2296
|
},
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
let factory_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/factory.js"), debug_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/debug.js"), options_adapter_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/legacy/options-adapter.js"), debug = debug_1.Debug.extend('legacy-create-proxy-middleware');
|
|
2590
|
-
function legacyCreateProxyMiddleware(legacyContext, legacyOptions) {
|
|
2591
|
-
debug('init');
|
|
2592
|
-
let options = (0, options_adapter_1.legacyOptionsAdapter)(legacyContext, legacyOptions), proxyMiddleware = (0, factory_1.createProxyMiddleware)(options);
|
|
2593
|
-
return debug('add marker for patching req.url (old behavior)'), proxyMiddleware.__LEGACY_HTTP_PROXY_MIDDLEWARE__ = !0, proxyMiddleware;
|
|
2297
|
+
(req, res, proxyRes, options)=>{
|
|
2298
|
+
if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers.location && redirectRegex.test(String(proxyRes.statusCode))) {
|
|
2299
|
+
let target = _toURL(options.target), u = new URL(proxyRes.headers.location, target);
|
|
2300
|
+
target.host === u.host && (options.hostRewrite ? u.host = options.hostRewrite : options.autoRewrite && (req.headers[":authority"] ? u.host = req.headers[":authority"] : req.headers.host && (u.host = req.headers.host)), options.protocolRewrite && (u.protocol = options.protocolRewrite), proxyRes.headers.location = u.toString());
|
|
2594
2301
|
}
|
|
2595
2302
|
},
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
2609
|
-
for(var p in m)"default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
2610
|
-
};
|
|
2611
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2612
|
-
value: !0
|
|
2613
|
-
}), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/legacy/public.js"), exports);
|
|
2614
|
-
},
|
|
2615
|
-
"../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/legacy/options-adapter.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2616
|
-
exports.legacyOptionsAdapter = legacyOptionsAdapter;
|
|
2617
|
-
let url = __webpack_require__("url?5f07"), debug_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/debug.js"), logger_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/logger.js"), debug = debug_1.Debug.extend('legacy-options-adapter'), proxyEventMap = {
|
|
2618
|
-
onError: 'error',
|
|
2619
|
-
onProxyReq: 'proxyReq',
|
|
2620
|
-
onProxyRes: 'proxyRes',
|
|
2621
|
-
onProxyReqWs: 'proxyReqWs',
|
|
2622
|
-
onOpen: 'open',
|
|
2623
|
-
onClose: 'close'
|
|
2624
|
-
};
|
|
2625
|
-
function legacyOptionsAdapter(legacyContext, legacyOptions) {
|
|
2626
|
-
let logger, options = {};
|
|
2627
|
-
if ('string' == typeof legacyContext && url.parse(legacyContext).host) throw Error(`Shorthand syntax is removed from legacyCreateProxyMiddleware().
|
|
2628
|
-
Please use "legacyCreateProxyMiddleware({ target: 'http://www.example.org' })" instead.
|
|
2629
|
-
|
|
2630
|
-
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-shorthand-usage
|
|
2631
|
-
`);
|
|
2632
|
-
legacyContext && legacyOptions ? (debug('map legacy context/filter to options.pathFilter'), (logger = getLegacyLogger(options = {
|
|
2633
|
-
...legacyOptions,
|
|
2634
|
-
pathFilter: legacyContext
|
|
2635
|
-
})).warn(`[http-proxy-middleware] Legacy "context" argument is deprecated. Migrate your "context" to "options.pathFilter":
|
|
2636
|
-
|
|
2637
|
-
const options = {
|
|
2638
|
-
pathFilter: '${legacyContext}',
|
|
2639
|
-
}
|
|
2640
|
-
|
|
2641
|
-
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-context-argument
|
|
2642
|
-
`)) : logger = legacyContext && !legacyOptions ? getLegacyLogger(options = {
|
|
2643
|
-
...legacyContext
|
|
2644
|
-
}) : getLegacyLogger({}), Object.entries(proxyEventMap).forEach(([legacyEventName, proxyEventName])=>{
|
|
2645
|
-
options[legacyEventName] && (options.on = {
|
|
2646
|
-
...options.on
|
|
2647
|
-
}, options.on[proxyEventName] = options[legacyEventName], debug('map legacy event "%s" to "on.%s"', legacyEventName, proxyEventName), logger.warn(`[http-proxy-middleware] Legacy "${legacyEventName}" is deprecated. Migrate to "options.on.${proxyEventName}":
|
|
2648
|
-
|
|
2649
|
-
const options = {
|
|
2650
|
-
on: {
|
|
2651
|
-
${proxyEventName}: () => {},
|
|
2652
|
-
},
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2655
|
-
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#refactored-proxy-events
|
|
2656
|
-
`));
|
|
2657
|
-
});
|
|
2658
|
-
let logProvider = options.logProvider && options.logProvider(), logLevel = options.logLevel;
|
|
2659
|
-
return debug('legacy logLevel', logLevel), debug('legacy logProvider: %O', logProvider), 'string' == typeof logLevel && 'silent' !== logLevel && (debug('map "logProvider" to "logger"'), logger.warn(`[http-proxy-middleware] Legacy "logLevel" and "logProvider" are deprecated. Migrate to "options.logger":
|
|
2660
|
-
|
|
2661
|
-
const options = {
|
|
2662
|
-
logger: console,
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-logprovider-and-loglevel-options
|
|
2666
|
-
`)), options;
|
|
2303
|
+
(req, res, proxyRes, options)=>{
|
|
2304
|
+
let rawHeaderKeyMap, rewriteCookieDomainConfig = "string" == typeof options.cookieDomainRewrite ? {
|
|
2305
|
+
"*": options.cookieDomainRewrite
|
|
2306
|
+
} : options.cookieDomainRewrite, rewriteCookiePathConfig = "string" == typeof options.cookiePathRewrite ? {
|
|
2307
|
+
"*": options.cookiePathRewrite
|
|
2308
|
+
} : options.cookiePathRewrite, preserveHeaderKeyCase = options.preserveHeaderKeyCase;
|
|
2309
|
+
if (preserveHeaderKeyCase && void 0 !== proxyRes.rawHeaders) {
|
|
2310
|
+
rawHeaderKeyMap = {};
|
|
2311
|
+
for(let i = 0; i < proxyRes.rawHeaders.length; i += 2){
|
|
2312
|
+
let key = proxyRes.rawHeaders[i];
|
|
2313
|
+
rawHeaderKeyMap[key.toLowerCase()] = key;
|
|
2314
|
+
}
|
|
2667
2315
|
}
|
|
2668
|
-
|
|
2669
|
-
let
|
|
2670
|
-
|
|
2316
|
+
for (let key1 of Object.keys(proxyRes.headers)){
|
|
2317
|
+
let header1 = proxyRes.headers[key1];
|
|
2318
|
+
preserveHeaderKeyCase && rawHeaderKeyMap && (key1 = rawHeaderKeyMap[key1] || key1);
|
|
2319
|
+
var key = key1, header = header1;
|
|
2320
|
+
if (void 0 !== header && String(key).trim()) {
|
|
2321
|
+
rewriteCookieDomainConfig && "set-cookie" === key.toLowerCase() && (header = rewriteCookieProperty(header, rewriteCookieDomainConfig, "domain")), rewriteCookiePathConfig && "set-cookie" === key.toLowerCase() && (header = rewriteCookieProperty(header, rewriteCookiePathConfig, "path"));
|
|
2322
|
+
try {
|
|
2323
|
+
res.setHeader(String(key).trim(), header);
|
|
2324
|
+
} catch {}
|
|
2325
|
+
}
|
|
2671
2326
|
}
|
|
2672
2327
|
},
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2328
|
+
(req, res, proxyRes)=>{
|
|
2329
|
+
res.statusCode = proxyRes.statusCode, proxyRes.statusMessage && req.httpVersionMajor < 2 && (res.statusMessage = proxyRes.statusMessage);
|
|
2330
|
+
}
|
|
2331
|
+
];
|
|
2332
|
+
function _toURL(target) {
|
|
2333
|
+
if (target instanceof URL) return target;
|
|
2334
|
+
if ("string" == typeof target) return new URL(target);
|
|
2335
|
+
let protocol = target.protocol || "http:", host = target.host || target.hostname || "localhost", port = target.port;
|
|
2336
|
+
return new URL(`${protocol}//${host}${port ? ":" + port : ""}`);
|
|
2337
|
+
}
|
|
2338
|
+
let redirectStatuses = new Set([
|
|
2339
|
+
301,
|
|
2340
|
+
302,
|
|
2341
|
+
303,
|
|
2342
|
+
307,
|
|
2343
|
+
308
|
|
2344
|
+
]), webIncomingMiddleware = [
|
|
2345
|
+
(req)=>{
|
|
2346
|
+
"DELETE" !== req.method && "OPTIONS" !== req.method || req.headers["content-length"] || (req.headers["content-length"] = "0", delete req.headers["transfer-encoding"]);
|
|
2347
|
+
},
|
|
2348
|
+
(req, res, options)=>{
|
|
2349
|
+
options.timeout && req.socket.setTimeout(options.timeout, ()=>{
|
|
2350
|
+
req.socket.destroy();
|
|
2683
2351
|
});
|
|
2684
2352
|
},
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
let
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2353
|
+
(req, res, options)=>{
|
|
2354
|
+
if (!options.xfwd) return;
|
|
2355
|
+
let encrypted = req.isSpdy || hasEncryptedConnection(req), values = {
|
|
2356
|
+
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
2357
|
+
port: getPort(req),
|
|
2358
|
+
proto: encrypted ? "https" : "http"
|
|
2691
2359
|
};
|
|
2692
|
-
|
|
2693
|
-
|
|
2360
|
+
for (let header of [
|
|
2361
|
+
"for",
|
|
2362
|
+
"port",
|
|
2363
|
+
"proto"
|
|
2364
|
+
]){
|
|
2365
|
+
let key = "x-forwarded-" + header;
|
|
2366
|
+
req.headers[key] || (req.headers[key] = values[header]);
|
|
2694
2367
|
}
|
|
2368
|
+
req.headers["x-forwarded-host"] = req.headers["x-forwarded-host"] || req.headers[":authority"] || req.headers.host || "";
|
|
2695
2369
|
},
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
if (
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
return matches && matches.length > 0;
|
|
2719
|
-
}
|
|
2720
|
-
function matchMultiGlobPath(patternList, uri) {
|
|
2721
|
-
return matchSingleGlobPath(patternList, uri);
|
|
2370
|
+
(req, res, options, server, head, callback)=>{
|
|
2371
|
+
let bodyBuffer;
|
|
2372
|
+
server.emit("start", req, res, options.target || options.forward);
|
|
2373
|
+
let maxRedirects = "number" == typeof options.followRedirects ? options.followRedirects : 5 * !!options.followRedirects;
|
|
2374
|
+
if (options.forward) {
|
|
2375
|
+
let forwardReq = (isSSL.test(options.forward.protocol || "http") ? node_https : node_http).request(setupOutgoing(options.ssl || {}, options, req, "forward")), forwardError = createErrorHandler(forwardReq, options.forward);
|
|
2376
|
+
if (req.on("error", forwardError), forwardReq.on("error", forwardError), (options.buffer || req).pipe(forwardReq), !options.target) return void res.end();
|
|
2377
|
+
}
|
|
2378
|
+
let proxyReq = (isSSL.test(options.target.protocol || "http") ? node_https : node_http).request(setupOutgoing(options.ssl || {}, options, req));
|
|
2379
|
+
proxyReq.on("socket", (_socket)=>{
|
|
2380
|
+
server && !proxyReq.getHeader("expect") && server.emit("proxyReq", proxyReq, req, res, options);
|
|
2381
|
+
}), options.proxyTimeout && proxyReq.setTimeout(options.proxyTimeout, function() {
|
|
2382
|
+
proxyReq.destroy();
|
|
2383
|
+
}), res.on("close", function() {
|
|
2384
|
+
res.writableFinished || proxyReq.destroy();
|
|
2385
|
+
});
|
|
2386
|
+
let proxyError = createErrorHandler(proxyReq, options.target);
|
|
2387
|
+
function createErrorHandler(proxyReq, url) {
|
|
2388
|
+
return function proxyError(err) {
|
|
2389
|
+
if (!req.socket?.writable && "ECONNRESET" === err.code) return server.emit("econnreset", err, req, res, url), proxyReq.destroy();
|
|
2390
|
+
callback ? callback(err, req, res, url) : server.emit("error", err, req, res, url);
|
|
2391
|
+
};
|
|
2722
2392
|
}
|
|
2723
|
-
|
|
2724
|
-
let
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2393
|
+
if (req.on("error", proxyError), proxyReq.on("error", proxyError), maxRedirects > 0) {
|
|
2394
|
+
let chunks = [], source = options.buffer || req;
|
|
2395
|
+
source.on("data", (chunk)=>{
|
|
2396
|
+
chunks.push("string" == typeof chunk ? Buffer.from(chunk) : chunk), proxyReq.write(chunk);
|
|
2397
|
+
}), source.on("end", ()=>{
|
|
2398
|
+
bodyBuffer = Buffer.concat(chunks), proxyReq.end();
|
|
2399
|
+
}), source.on("error", (err)=>{
|
|
2400
|
+
proxyReq.destroy(err);
|
|
2401
|
+
});
|
|
2402
|
+
} else proxyReq.on("socket", (socket)=>{
|
|
2403
|
+
socket.pending ? socket.on("connect", ()=>(options.buffer || req).pipe(proxyReq)) : (options.buffer || req).pipe(proxyReq);
|
|
2404
|
+
});
|
|
2405
|
+
function handleResponse(proxyRes, redirectCount, currentUrl) {
|
|
2406
|
+
let statusCode = proxyRes.statusCode;
|
|
2407
|
+
if (maxRedirects > 0 && redirectStatuses.has(statusCode) && redirectCount < maxRedirects && proxyRes.headers.location) {
|
|
2408
|
+
proxyRes.resume();
|
|
2409
|
+
let location = new URL(proxyRes.headers.location, currentUrl), preserveMethod = 307 === statusCode || 308 === statusCode, redirectMethod = preserveMethod && req.method || "GET", isHTTPS = isSSL.test(location.protocol), agent = isHTTPS ? node_https : node_http, redirectHeaders = {
|
|
2410
|
+
...req.headers
|
|
2411
|
+
};
|
|
2412
|
+
options.headers && Object.assign(redirectHeaders, options.headers), redirectHeaders.host = location.host, location.host !== currentUrl.host && (delete redirectHeaders.authorization, delete redirectHeaders.cookie), preserveMethod || (delete redirectHeaders["content-length"], delete redirectHeaders["content-type"], delete redirectHeaders["transfer-encoding"]);
|
|
2413
|
+
let redirectOpts = {
|
|
2414
|
+
hostname: location.hostname,
|
|
2415
|
+
port: location.port || (isHTTPS ? 443 : 80),
|
|
2416
|
+
path: location.pathname + location.search,
|
|
2417
|
+
method: redirectMethod,
|
|
2418
|
+
headers: redirectHeaders,
|
|
2419
|
+
agent: options.agent || !1
|
|
2420
|
+
};
|
|
2421
|
+
isHTTPS && (redirectOpts.rejectUnauthorized = void 0 === options.secure || options.secure);
|
|
2422
|
+
let redirectReq = agent.request(redirectOpts);
|
|
2423
|
+
server && !redirectReq.getHeader("expect") && server.emit("proxyReq", redirectReq, req, res, options), options.proxyTimeout && redirectReq.setTimeout(options.proxyTimeout, ()=>{
|
|
2424
|
+
redirectReq.destroy();
|
|
2425
|
+
});
|
|
2426
|
+
let redirectError = createErrorHandler(redirectReq, location);
|
|
2427
|
+
redirectReq.on("error", redirectError), redirectReq.on("response", (nextRes)=>{
|
|
2428
|
+
handleResponse(nextRes, redirectCount + 1, location);
|
|
2429
|
+
}), preserveMethod && bodyBuffer && bodyBuffer.length > 0 ? redirectReq.end(bodyBuffer) : redirectReq.end();
|
|
2430
|
+
return;
|
|
2728
2431
|
}
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
function getUrlPathName(uri) {
|
|
2732
|
-
return uri && url.parse(uri).pathname;
|
|
2733
|
-
}
|
|
2734
|
-
function isStringPath(pathFilter) {
|
|
2735
|
-
return 'string' == typeof pathFilter && !isGlob(pathFilter);
|
|
2736
|
-
}
|
|
2737
|
-
function isGlobPath(pathFilter) {
|
|
2738
|
-
return isGlob(pathFilter);
|
|
2739
|
-
}
|
|
2740
|
-
},
|
|
2741
|
-
"../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/path-rewriter.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2742
|
-
exports.createPathRewriter = createPathRewriter;
|
|
2743
|
-
let is_plain_object_1 = __webpack_require__("../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.js"), errors_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/errors.js"), debug = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/debug.js").Debug.extend('path-rewriter');
|
|
2744
|
-
function createPathRewriter(rewriteConfig) {
|
|
2745
|
-
let rulesCache;
|
|
2746
|
-
if (isValidRewriteConfig(rewriteConfig)) if ('function' == typeof rewriteConfig) return rewriteConfig;
|
|
2747
|
-
else return rulesCache = parsePathRewriteRules(rewriteConfig), rewritePath;
|
|
2748
|
-
function rewritePath(path) {
|
|
2749
|
-
let result = path;
|
|
2750
|
-
for (let rule of rulesCache)if (rule.regex.test(path)) {
|
|
2751
|
-
debug('rewriting path from "%s" to "%s"', path, result = result.replace(rule.regex, rule.value));
|
|
2752
|
-
break;
|
|
2753
|
-
}
|
|
2754
|
-
return result;
|
|
2432
|
+
if (server && server.emit("proxyRes", proxyRes, req, res), !res.headersSent && !options.selfHandleResponse) {
|
|
2433
|
+
for (let pass of webOutgoingMiddleware)if (pass(req, res, proxyRes, options)) break;
|
|
2755
2434
|
}
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2435
|
+
res.finished ? server && server.emit("end", req, res, proxyRes) : (res.on("close", function() {
|
|
2436
|
+
proxyRes.destroy();
|
|
2437
|
+
}), proxyRes.on("close", function() {
|
|
2438
|
+
proxyRes.complete || res.destroyed || res.destroy();
|
|
2439
|
+
}), proxyRes.on("error", function(err) {
|
|
2440
|
+
res.destroyed || res.destroy(err), server.listenerCount("error") > 0 && server.emit("error", err, req, res, currentUrl);
|
|
2441
|
+
}), proxyRes.on("end", function() {
|
|
2442
|
+
server && server.emit("end", req, res, proxyRes);
|
|
2443
|
+
}), options.selfHandleResponse || proxyRes.pipe(res));
|
|
2444
|
+
}
|
|
2445
|
+
proxyReq.on("response", function(proxyRes) {
|
|
2446
|
+
handleResponse(proxyRes, 0, options.target);
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
], websocketIncomingMiddleware = [
|
|
2450
|
+
(req, socket)=>{
|
|
2451
|
+
if ("GET" !== req.method || !req.headers.upgrade || "websocket" !== req.headers.upgrade.toLowerCase()) return socket.destroy(), !0;
|
|
2771
2452
|
},
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
proxyServer.on('error', (error, req, res, target)=>{
|
|
2779
|
-
debug(`http-proxy error event: \n%O`, error);
|
|
2780
|
-
}), proxyServer.on('proxyReq', (proxyReq, req, socket)=>{
|
|
2781
|
-
socket.on('error', (error)=>{
|
|
2782
|
-
debug('Socket error in proxyReq event: \n%O', error);
|
|
2783
|
-
});
|
|
2784
|
-
}), proxyServer.on('proxyRes', (proxyRes, req, res)=>{
|
|
2785
|
-
res.on('close', ()=>{
|
|
2786
|
-
res.writableEnded || (debug('Destroying proxyRes in proxyRes close event'), proxyRes.destroy());
|
|
2787
|
-
});
|
|
2788
|
-
}), proxyServer.on('proxyReqWs', (proxyReq, req, socket)=>{
|
|
2789
|
-
socket.on('error', (error)=>{
|
|
2790
|
-
debug('Socket error in proxyReqWs event: \n%O', error);
|
|
2791
|
-
});
|
|
2792
|
-
}), proxyServer.on('open', (proxySocket)=>{
|
|
2793
|
-
proxySocket.on('error', (error)=>{
|
|
2794
|
-
debug('Socket error in open event: \n%O', error);
|
|
2795
|
-
});
|
|
2796
|
-
}), proxyServer.on('close', (req, socket, head)=>{
|
|
2797
|
-
socket.on('error', (error)=>{
|
|
2798
|
-
debug('Socket error in close event: \n%O', error);
|
|
2799
|
-
});
|
|
2800
|
-
}), proxyServer.on('econnreset', (error, req, res, target)=>{
|
|
2801
|
-
debug(`http-proxy econnreset event: \n%O`, error);
|
|
2802
|
-
});
|
|
2453
|
+
(req, socket, options)=>{
|
|
2454
|
+
if (!options.xfwd) return;
|
|
2455
|
+
let values = {
|
|
2456
|
+
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
2457
|
+
port: getPort(req),
|
|
2458
|
+
proto: hasEncryptedConnection(req) ? "wss" : "ws"
|
|
2803
2459
|
};
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
return obj && 'function' == typeof obj.writeHead;
|
|
2812
|
-
}
|
|
2813
|
-
function isSocketLike(obj) {
|
|
2814
|
-
return obj && 'function' == typeof obj.write && !('writeHead' in obj);
|
|
2460
|
+
for (let header of [
|
|
2461
|
+
"for",
|
|
2462
|
+
"port",
|
|
2463
|
+
"proto"
|
|
2464
|
+
]){
|
|
2465
|
+
let key = "x-forwarded-" + header;
|
|
2466
|
+
req.headers[key] || (req.headers[key] = values[header]);
|
|
2815
2467
|
}
|
|
2816
|
-
exports.errorResponsePlugin = (proxyServer, options)=>{
|
|
2817
|
-
proxyServer.on('error', (err, req, res, target)=>{
|
|
2818
|
-
if (!req && !res) throw err;
|
|
2819
|
-
if (isResponseLike(res)) {
|
|
2820
|
-
if (!res.headersSent) {
|
|
2821
|
-
let statusCode = (0, status_code_1.getStatusCode)(err.code);
|
|
2822
|
-
res.writeHead(statusCode);
|
|
2823
|
-
}
|
|
2824
|
-
let host = req.headers && req.headers.host;
|
|
2825
|
-
res.end(`Error occurred while trying to proxy: ${host}${req.url}`);
|
|
2826
|
-
} else isSocketLike(res) && res.destroy();
|
|
2827
|
-
});
|
|
2828
|
-
};
|
|
2829
2468
|
},
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
} : function(o, m, k, k2) {
|
|
2841
|
-
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
2842
|
-
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
2843
|
-
for(var p in m)"default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
2844
|
-
};
|
|
2845
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2846
|
-
value: !0
|
|
2847
|
-
}), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/plugins/default/debug-proxy-errors-plugin.js"), exports), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/plugins/default/error-response-plugin.js"), exports), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/plugins/default/logger-plugin.js"), exports), __exportStar(__webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/plugins/default/proxy-events.js"), exports);
|
|
2848
|
-
},
|
|
2849
|
-
"../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/plugins/default/logger-plugin.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2850
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2851
|
-
value: !0
|
|
2852
|
-
}), exports.loggerPlugin = void 0;
|
|
2853
|
-
let url_1 = __webpack_require__("url?5f07"), logger_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/logger.js"), logger_plugin_1 = __webpack_require__("../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/utils/logger-plugin.js");
|
|
2854
|
-
exports.loggerPlugin = (proxyServer, options)=>{
|
|
2855
|
-
let logger = (0, logger_1.getLogger)(options);
|
|
2856
|
-
proxyServer.on('error', (err, req, res, target)=>{
|
|
2857
|
-
let hostname = req?.headers?.host, requestHref = `${hostname}${req?.url}`, targetHref = `${target?.href}`;
|
|
2858
|
-
logger.error('[HPM] Error occurred while proxying request %s to %s [%s] (%s)', requestHref, targetHref, err.code || err, 'https://nodejs.org/api/errors.html#errors_common_system_errors');
|
|
2859
|
-
}), proxyServer.on('proxyRes', (proxyRes, req, res)=>{
|
|
2860
|
-
let target, originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
|
|
2861
|
-
try {
|
|
2862
|
-
let port = (0, logger_plugin_1.getPort)(proxyRes.req?.agent?.sockets), obj = {
|
|
2863
|
-
protocol: proxyRes.req.protocol,
|
|
2864
|
-
host: proxyRes.req.host,
|
|
2865
|
-
pathname: proxyRes.req.path
|
|
2866
|
-
};
|
|
2867
|
-
target = new url_1.URL(`${obj.protocol}//${obj.host}${obj.pathname}`), port && (target.port = port);
|
|
2868
|
-
} catch (err) {
|
|
2869
|
-
(target = new url_1.URL(options.target)).pathname = proxyRes.req.path;
|
|
2870
|
-
}
|
|
2871
|
-
let targetUrl = target.toString(), exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
|
|
2872
|
-
logger.info(exchange);
|
|
2873
|
-
}), proxyServer.on('open', (socket)=>{
|
|
2874
|
-
logger.info('[HPM] Client connected: %o', socket.address());
|
|
2875
|
-
}), proxyServer.on('close', (req, proxySocket, proxyHead)=>{
|
|
2876
|
-
logger.info('[HPM] Client disconnected: %o', proxySocket.address());
|
|
2877
|
-
});
|
|
2469
|
+
(req, socket, options, server, head, callback)=>{
|
|
2470
|
+
let createHttpHeader = function(line, headers) {
|
|
2471
|
+
return Object.keys(headers).reduce(function(head, key) {
|
|
2472
|
+
let value = headers[key];
|
|
2473
|
+
if (!Array.isArray(value)) return head.push(key + ": " + value), head;
|
|
2474
|
+
for (let element of value)head.push(key + ": " + element);
|
|
2475
|
+
return head;
|
|
2476
|
+
}, [
|
|
2477
|
+
line
|
|
2478
|
+
]).join("\r\n") + "\r\n\r\n";
|
|
2878
2479
|
};
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
}
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2480
|
+
setupSocket(socket), head && head.length > 0 && socket.unshift(head), socket.on("error", onSocketError);
|
|
2481
|
+
let proxyReq = (isSSL.test(options.target.protocol || "http") ? node_https : node_http).request(setupOutgoing(options.ssl || {}, options, req));
|
|
2482
|
+
function onSocketError(err) {
|
|
2483
|
+
callback ? callback(err, req, socket) : server.emit("error", err, req, socket), proxyReq.destroy();
|
|
2484
|
+
}
|
|
2485
|
+
function onOutgoingError(err) {
|
|
2486
|
+
callback ? callback(err, req, socket) : server.emit("error", err, req, socket), socket.end();
|
|
2487
|
+
}
|
|
2488
|
+
server && server.emit("proxyReqWs", proxyReq, req, socket, options, head), proxyReq.on("error", onOutgoingError), proxyReq.on("response", function(res) {
|
|
2489
|
+
res.upgrade || (!socket.destroyed && socket.writable ? (socket.write(createHttpHeader("HTTP/" + res.httpVersion + " " + res.statusCode + " " + res.statusMessage, res.headers)), res.on("error", onOutgoingError), res.pipe(socket)) : res.resume());
|
|
2490
|
+
}), proxyReq.on("upgrade", function(proxyRes, proxySocket, proxyHead) {
|
|
2491
|
+
proxySocket.on("error", onOutgoingError), proxySocket.on("end", function() {
|
|
2492
|
+
server.emit("close", proxyRes, proxySocket, proxyHead);
|
|
2493
|
+
}), socket.removeListener("error", onSocketError), socket.on("error", function() {
|
|
2494
|
+
proxySocket.end();
|
|
2495
|
+
}), setupSocket(proxySocket), proxyHead && proxyHead.length > 0 && proxySocket.unshift(proxyHead), socket.write(createHttpHeader("HTTP/1.1 101 Switching Protocols", proxyRes.headers)), proxySocket.pipe(socket).pipe(proxySocket), server.emit("open", proxySocket), server.emit("proxySocket", proxySocket);
|
|
2496
|
+
}), proxyReq.end();
|
|
2497
|
+
}
|
|
2498
|
+
];
|
|
2499
|
+
var ERRORS, errors_ERRORS, ProxyServer = class extends EventEmitter {
|
|
2500
|
+
_server;
|
|
2501
|
+
_webPasses = [
|
|
2502
|
+
...webIncomingMiddleware
|
|
2503
|
+
];
|
|
2504
|
+
_wsPasses = [
|
|
2505
|
+
...websocketIncomingMiddleware
|
|
2506
|
+
];
|
|
2507
|
+
options;
|
|
2508
|
+
web;
|
|
2509
|
+
ws;
|
|
2510
|
+
constructor(options = {}){
|
|
2511
|
+
super(), this.options = options || {}, this.options.prependPath = !1 !== options.prependPath, this.web = _createProxyFn("web", this), this.ws = _createProxyFn("ws", this);
|
|
2512
|
+
}
|
|
2513
|
+
listen(port, hostname) {
|
|
2514
|
+
let closure = (req, res)=>this.web(req, res);
|
|
2515
|
+
if (this.options.http2) {
|
|
2516
|
+
if (!this.options.ssl) throw Error("HTTP/2 requires ssl option");
|
|
2517
|
+
this._server = node_http2.createSecureServer({
|
|
2518
|
+
...this.options.ssl,
|
|
2519
|
+
allowHTTP1: !0
|
|
2520
|
+
}, closure);
|
|
2521
|
+
} else this.options.ssl ? this._server = node_https.createServer(this.options.ssl, closure) : this._server = node_http.createServer(closure);
|
|
2522
|
+
return this.options.ws && this._server.on("upgrade", (req, socket, head)=>{
|
|
2523
|
+
this.ws(req, socket, this.options, head).catch(()=>{});
|
|
2524
|
+
}), this._server.listen(port, hostname), this;
|
|
2525
|
+
}
|
|
2526
|
+
close(callback) {
|
|
2527
|
+
this._server && this._server.close((...args)=>{
|
|
2528
|
+
this._server = void 0, callback && Reflect.apply(callback, void 0, args);
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
before(type, passName, pass) {
|
|
2532
|
+
if ("ws" !== type && "web" !== type) throw Error("type must be `web` or `ws`");
|
|
2533
|
+
let passes = this._getPasses(type), i = !1;
|
|
2534
|
+
for (let [idx, v] of passes.entries())v.name === passName && (i = idx);
|
|
2535
|
+
if (!1 === i) throw Error("No such pass");
|
|
2536
|
+
passes.splice(i, 0, pass);
|
|
2537
|
+
}
|
|
2538
|
+
after(type, passName, pass) {
|
|
2539
|
+
if ("ws" !== type && "web" !== type) throw Error("type must be `web` or `ws`");
|
|
2540
|
+
let passes = this._getPasses(type), i = !1;
|
|
2541
|
+
for (let [idx, v] of passes.entries())v.name === passName && (i = idx);
|
|
2542
|
+
if (!1 === i) throw Error("No such pass");
|
|
2543
|
+
passes.splice(i++, 0, pass);
|
|
2544
|
+
}
|
|
2545
|
+
_getPasses(type) {
|
|
2546
|
+
return "ws" === type ? this._wsPasses : this._webPasses;
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
function createProxyServer(options = {}) {
|
|
2550
|
+
return new ProxyServer(options);
|
|
2551
|
+
}
|
|
2552
|
+
function _createProxyFn(type, server) {
|
|
2553
|
+
return function(req, res, opts, head) {
|
|
2554
|
+
let _resolve, _reject, requestOptions = {
|
|
2555
|
+
...opts,
|
|
2556
|
+
...server.options
|
|
2889
2557
|
};
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
}
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2558
|
+
for (let key of [
|
|
2559
|
+
"target",
|
|
2560
|
+
"forward"
|
|
2561
|
+
])"string" == typeof requestOptions[key] && (requestOptions[key] = new URL(requestOptions[key]));
|
|
2562
|
+
if (!requestOptions.target && !requestOptions.forward) return this.emit("error", Error("Must provide a proper URL as target")), Promise.resolve();
|
|
2563
|
+
let callbackPromise = new Promise((resolve, reject)=>{
|
|
2564
|
+
_resolve = resolve, _reject = reject;
|
|
2565
|
+
});
|
|
2566
|
+
for (let pass of (res.on("close", ()=>{
|
|
2567
|
+
_resolve();
|
|
2568
|
+
}), res.on("error", (error)=>{
|
|
2569
|
+
_reject(error);
|
|
2570
|
+
}), server._getPasses(type))){
|
|
2571
|
+
let stop;
|
|
2572
|
+
try {
|
|
2573
|
+
stop = pass(req, res, requestOptions, server, head, (error)=>{
|
|
2574
|
+
server.listenerCount("error") > 0 ? (server.emit("error", error, req, res), _resolve()) : _reject(error);
|
|
2575
|
+
});
|
|
2576
|
+
} catch (error) {
|
|
2577
|
+
server.listenerCount("error") > 0 ? (server.emit("error", error, req, res), _resolve()) : _reject(error);
|
|
2907
2578
|
break;
|
|
2908
2579
|
}
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
return v.indexOf('/') > -1;
|
|
2913
|
-
}
|
|
2914
|
-
},
|
|
2915
|
-
"../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/status-code.js" (__unused_rspack_module, exports) {
|
|
2916
|
-
exports.getStatusCode = getStatusCode;
|
|
2917
|
-
function getStatusCode(errorCode) {
|
|
2918
|
-
let statusCode;
|
|
2919
|
-
if (/HPE_INVALID/.test(errorCode)) statusCode = 502;
|
|
2920
|
-
else switch(errorCode){
|
|
2921
|
-
case 'ECONNRESET':
|
|
2922
|
-
case 'ENOTFOUND':
|
|
2923
|
-
case 'ECONNREFUSED':
|
|
2924
|
-
case 'ETIMEDOUT':
|
|
2925
|
-
statusCode = 504;
|
|
2926
|
-
break;
|
|
2927
|
-
default:
|
|
2928
|
-
statusCode = 500;
|
|
2580
|
+
if (stop) {
|
|
2581
|
+
_resolve();
|
|
2582
|
+
break;
|
|
2929
2583
|
}
|
|
2930
|
-
return statusCode;
|
|
2931
2584
|
}
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2585
|
+
return callbackPromise;
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
function verifyConfig(options) {
|
|
2589
|
+
if (!options.target && !options.router) throw Error(errors_ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING);
|
|
2590
|
+
}
|
|
2591
|
+
(ERRORS = errors_ERRORS || (errors_ERRORS = {})).ERR_CONFIG_FACTORY_TARGET_MISSING = "[HPM] Missing \"target\" option. Example: {target: \"http://www.example.org\"}", ERRORS.ERR_CONTEXT_MATCHER_GENERIC = "[HPM] Invalid pathFilter. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]", ERRORS.ERR_CONTEXT_MATCHER_INVALID_ARRAY = "[HPM] Invalid pathFilter. Plain paths (e.g. \"/api\") can not be mixed with globs (e.g. \"/api/**\"). Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"].", ERRORS.ERR_PATH_REWRITER_CONFIG = "[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function";
|
|
2592
|
+
let Debug = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/index.js")('http-proxy-middleware'), debug = Debug.extend('debug-proxy-errors-plugin'), debugProxyErrorsPlugin = (proxyServer)=>{
|
|
2593
|
+
proxyServer.on('error', (error, req, res, target)=>{
|
|
2594
|
+
debug(`http-proxy error event: \n%O`, error);
|
|
2595
|
+
}), proxyServer.on('proxyReq', (proxyReq, req, socket)=>{
|
|
2596
|
+
socket.on('error', (error)=>{
|
|
2597
|
+
debug('Socket error in proxyReq event: \n%O', error);
|
|
2598
|
+
});
|
|
2599
|
+
}), proxyServer.on('proxyRes', (proxyRes, req, res)=>{
|
|
2600
|
+
res.on('close', ()=>{
|
|
2601
|
+
res.writableEnded || (debug('Destroying proxyRes in proxyRes close event'), proxyRes.destroy());
|
|
2602
|
+
});
|
|
2603
|
+
}), proxyServer.on('proxyReqWs', (proxyReq, req, socket)=>{
|
|
2604
|
+
socket.on('error', (error)=>{
|
|
2605
|
+
debug('Socket error in proxyReqWs event: \n%O', error);
|
|
2606
|
+
});
|
|
2607
|
+
}), proxyServer.on('open', (proxySocket)=>{
|
|
2608
|
+
proxySocket.on('error', (error)=>{
|
|
2609
|
+
debug('Socket error in open event: \n%O', error);
|
|
2610
|
+
});
|
|
2611
|
+
}), proxyServer.on('close', (req, socket, head)=>{
|
|
2612
|
+
socket.on('error', (error)=>{
|
|
2613
|
+
debug('Socket error in close event: \n%O', error);
|
|
2614
|
+
});
|
|
2615
|
+
}), proxyServer.on('econnreset', (error, req, res, target)=>{
|
|
2616
|
+
debug(`http-proxy econnreset event: \n%O`, error);
|
|
2617
|
+
});
|
|
2618
|
+
};
|
|
2619
|
+
function getStatusCode(errorCode) {
|
|
2620
|
+
let statusCode;
|
|
2621
|
+
if (/HPE_INVALID/.test(errorCode)) statusCode = 502;
|
|
2622
|
+
else switch(errorCode){
|
|
2623
|
+
case 'ECONNRESET':
|
|
2624
|
+
case 'ENOTFOUND':
|
|
2625
|
+
case 'ECONNREFUSED':
|
|
2626
|
+
case 'ETIMEDOUT':
|
|
2627
|
+
statusCode = 504;
|
|
2628
|
+
break;
|
|
2629
|
+
default:
|
|
2630
|
+
statusCode = 500;
|
|
2631
|
+
}
|
|
2632
|
+
return statusCode;
|
|
2633
|
+
}
|
|
2634
|
+
function sanitize(input) {
|
|
2635
|
+
return input?.replace(/[<>]/g, (i)=>encodeURIComponent(i)) ?? '';
|
|
2636
|
+
}
|
|
2637
|
+
function isResponseLike(obj) {
|
|
2638
|
+
return obj && 'function' == typeof obj.writeHead;
|
|
2639
|
+
}
|
|
2640
|
+
function isSocketLike(obj) {
|
|
2641
|
+
return obj && 'function' == typeof obj.write && !('writeHead' in obj);
|
|
2642
|
+
}
|
|
2643
|
+
let errorResponsePlugin = (proxyServer, options)=>{
|
|
2644
|
+
proxyServer.on('error', (err, req, res, target)=>{
|
|
2645
|
+
if (!req || !res) throw err;
|
|
2646
|
+
if (isResponseLike(res)) {
|
|
2647
|
+
if (!res.headersSent) {
|
|
2648
|
+
let statusCode = getStatusCode(err.code);
|
|
2649
|
+
res.writeHead(statusCode);
|
|
2650
|
+
}
|
|
2651
|
+
let host = req.headers && req.headers.host;
|
|
2652
|
+
res.end(`Error occurred while trying to proxy: ${sanitize(host)}${sanitize(req.url)}`);
|
|
2653
|
+
} else isSocketLike(res) && res.destroy();
|
|
2654
|
+
});
|
|
2655
|
+
}, noopLogger = {
|
|
2656
|
+
info: ()=>{},
|
|
2657
|
+
warn: ()=>{},
|
|
2658
|
+
error: ()=>{}
|
|
2659
|
+
};
|
|
2660
|
+
function logger_plugin_getPort(sockets) {
|
|
2661
|
+
return Object.keys(sockets || {})?.[0]?.split(':')[1];
|
|
2662
|
+
}
|
|
2663
|
+
let loggerPlugin = (proxyServer, options)=>{
|
|
2664
|
+
let logger = options.logger || noopLogger;
|
|
2665
|
+
proxyServer.on('error', (err, req, res, target)=>{
|
|
2666
|
+
let hostname = req?.headers?.host, requestHref = `${hostname}${req?.url}`, targetHref = `${target?.href}`;
|
|
2667
|
+
logger.error('[HPM] Error occurred while proxying request %s to %s [%s] (%s)', requestHref, targetHref, err.code || err, 'https://nodejs.org/api/errors.html#errors_common_system_errors');
|
|
2668
|
+
}), proxyServer.on('proxyRes', (proxyRes, req, res)=>{
|
|
2669
|
+
let target, originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
|
|
2670
|
+
try {
|
|
2671
|
+
let port = logger_plugin_getPort(proxyRes.req?.agent?.sockets), obj = {
|
|
2672
|
+
protocol: proxyRes.req.protocol,
|
|
2673
|
+
host: proxyRes.req.host,
|
|
2674
|
+
pathname: proxyRes.req.path
|
|
2675
|
+
};
|
|
2676
|
+
target = new external_node_url_URL(`${obj.protocol}//${obj.host}${obj.pathname}`), port && (target.port = port);
|
|
2677
|
+
} catch (err) {
|
|
2678
|
+
(target = new external_node_url_URL(options.target)).pathname = proxyRes.req.path;
|
|
2679
|
+
}
|
|
2680
|
+
let targetUrl = target.toString(), exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
|
|
2681
|
+
logger.info(exchange);
|
|
2682
|
+
}), proxyServer.on('open', (socket)=>{
|
|
2683
|
+
logger.info('[HPM] Client connected: %o', socket.address());
|
|
2684
|
+
}), proxyServer.on('close', (req, proxySocket, proxyHead)=>{
|
|
2685
|
+
logger.info('[HPM] Client disconnected: %o', proxySocket.address());
|
|
2686
|
+
});
|
|
2687
|
+
};
|
|
2688
|
+
function function_getFunctionName(fn) {
|
|
2689
|
+
return fn.name || '[anonymous Function]';
|
|
2690
|
+
}
|
|
2691
|
+
let proxy_events_debug = Debug.extend('proxy-events-plugin'), proxyEventsPlugin = (proxyServer, options)=>{
|
|
2692
|
+
let eventName;
|
|
2693
|
+
if (options.on) {
|
|
2694
|
+
for(eventName in options.on)if (Object.prototype.hasOwnProperty.call(options.on, eventName)) {
|
|
2695
|
+
let handler = options.on[eventName];
|
|
2696
|
+
if (!handler) continue;
|
|
2697
|
+
proxy_events_debug(`register event handler: "${eventName}" -> "${function_getFunctionName(handler)}"`), proxyServer.on(eventName, handler);
|
|
2943
2698
|
}
|
|
2944
2699
|
}
|
|
2945
|
-
}
|
|
2946
|
-
|
|
2947
|
-
|
|
2700
|
+
};
|
|
2701
|
+
function getPlugins(options) {
|
|
2702
|
+
let maybeErrorResponsePlugin = options.on?.error ? [] : [
|
|
2703
|
+
errorResponsePlugin
|
|
2704
|
+
];
|
|
2705
|
+
return [
|
|
2706
|
+
...options.ejectPlugins ? [] : [
|
|
2707
|
+
debugProxyErrorsPlugin,
|
|
2708
|
+
proxyEventsPlugin,
|
|
2709
|
+
loggerPlugin,
|
|
2710
|
+
...maybeErrorResponsePlugin
|
|
2711
|
+
],
|
|
2712
|
+
...options.plugins ?? []
|
|
2713
|
+
];
|
|
2714
|
+
}
|
|
2715
|
+
let is_glob = __webpack_require__("../../node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js"), micromatch = __webpack_require__("../../node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js");
|
|
2716
|
+
function matchPathFilter(pathFilter = '/', uri, req) {
|
|
2717
|
+
if (isStringPath(pathFilter)) return matchSingleStringPath(pathFilter, uri);
|
|
2718
|
+
if (isGlobPath(pathFilter)) return matchSingleGlobPath(pathFilter, uri);
|
|
2719
|
+
if (Array.isArray(pathFilter)) {
|
|
2720
|
+
if (pathFilter.every(isStringPath)) return matchMultiPath(pathFilter, uri);
|
|
2721
|
+
if (pathFilter.every(isGlobPath)) return matchMultiGlobPath(pathFilter, uri);
|
|
2722
|
+
throw Error(errors_ERRORS.ERR_CONTEXT_MATCHER_INVALID_ARRAY);
|
|
2723
|
+
}
|
|
2724
|
+
if ('function' == typeof pathFilter) return pathFilter(getUrlPathName(uri), req);
|
|
2725
|
+
throw Error(errors_ERRORS.ERR_CONTEXT_MATCHER_GENERIC);
|
|
2726
|
+
}
|
|
2727
|
+
function matchSingleStringPath(pathFilter, uri) {
|
|
2728
|
+
let pathname = getUrlPathName(uri);
|
|
2729
|
+
return pathname?.indexOf(pathFilter) === 0;
|
|
2730
|
+
}
|
|
2731
|
+
function matchSingleGlobPath(pattern, uri) {
|
|
2732
|
+
let matches = micromatch([
|
|
2733
|
+
getUrlPathName(uri)
|
|
2734
|
+
], pattern);
|
|
2735
|
+
return matches && matches.length > 0;
|
|
2736
|
+
}
|
|
2737
|
+
function matchMultiGlobPath(patternList, uri) {
|
|
2738
|
+
return matchSingleGlobPath(patternList, uri);
|
|
2739
|
+
}
|
|
2740
|
+
function matchMultiPath(pathFilterList, uri) {
|
|
2741
|
+
let isMultiPath = !1;
|
|
2742
|
+
for (let context of pathFilterList)if (matchSingleStringPath(context, uri)) {
|
|
2743
|
+
isMultiPath = !0;
|
|
2744
|
+
break;
|
|
2745
|
+
}
|
|
2746
|
+
return isMultiPath;
|
|
2747
|
+
}
|
|
2748
|
+
function getUrlPathName(uri) {
|
|
2749
|
+
return uri && new URL(uri, 'http://0.0.0.0').pathname;
|
|
2750
|
+
}
|
|
2751
|
+
function isStringPath(pathFilter) {
|
|
2752
|
+
return 'string' == typeof pathFilter && !is_glob(pathFilter);
|
|
2753
|
+
}
|
|
2754
|
+
function isGlobPath(pathFilter) {
|
|
2755
|
+
return is_glob(pathFilter);
|
|
2756
|
+
}
|
|
2757
|
+
function isPlainObject(value) {
|
|
2758
|
+
if ('object' != typeof value || null === value) return !1;
|
|
2759
|
+
let prototype = Object.getPrototypeOf(value);
|
|
2760
|
+
return (null === prototype || prototype === Object.prototype || null === Object.getPrototypeOf(prototype)) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
2761
|
+
}
|
|
2762
|
+
let path_rewriter_debug = Debug.extend('path-rewriter');
|
|
2763
|
+
function createPathRewriter(rewriteConfig) {
|
|
2764
|
+
let rulesCache;
|
|
2765
|
+
if (isValidRewriteConfig(rewriteConfig)) if ('function' == typeof rewriteConfig) return rewriteConfig;
|
|
2766
|
+
else return rulesCache = parsePathRewriteRules(rewriteConfig), rewritePath;
|
|
2767
|
+
function rewritePath(path) {
|
|
2768
|
+
let result = path;
|
|
2769
|
+
for (let rule of rulesCache)if (rule.regex.test(path)) {
|
|
2770
|
+
path_rewriter_debug('rewriting path from "%s" to "%s"', path, result = result.replace(rule.regex, rule.value));
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
return result;
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
function isValidRewriteConfig(rewriteConfig) {
|
|
2777
|
+
if ('function' == typeof rewriteConfig) return !0;
|
|
2778
|
+
if (isPlainObject(rewriteConfig)) return 0 !== Object.keys(rewriteConfig).length;
|
|
2779
|
+
if (null == rewriteConfig) return !1;
|
|
2780
|
+
throw Error(errors_ERRORS.ERR_PATH_REWRITER_CONFIG);
|
|
2781
|
+
}
|
|
2782
|
+
function parsePathRewriteRules(rewriteConfig) {
|
|
2783
|
+
let rules = [];
|
|
2784
|
+
if (isPlainObject(rewriteConfig)) for (let [key, value] of Object.entries(rewriteConfig))rules.push({
|
|
2785
|
+
regex: new RegExp(key),
|
|
2786
|
+
value: value
|
|
2787
|
+
}), path_rewriter_debug('rewrite rule created: "%s" ~> "%s"', key, value);
|
|
2788
|
+
return rules;
|
|
2789
|
+
}
|
|
2790
|
+
let router_debug = Debug.extend('router');
|
|
2791
|
+
async function getTarget(req, config) {
|
|
2792
|
+
let newTarget, router = config.router;
|
|
2793
|
+
return isPlainObject(router) ? newTarget = getTargetFromProxyTable(req, router) : 'function' == typeof router && (newTarget = await router(req)), newTarget;
|
|
2794
|
+
}
|
|
2795
|
+
function getTargetFromProxyTable(req, table) {
|
|
2796
|
+
let result, host = req.headers.host, hostAndPath = host + req.url;
|
|
2797
|
+
for (let [key, value] of Object.entries(table))if (containsPath(key)) {
|
|
2798
|
+
if (hostAndPath.indexOf(key) > -1) {
|
|
2799
|
+
router_debug('match: "%s" -> "%s"', key, result = value);
|
|
2800
|
+
break;
|
|
2801
|
+
}
|
|
2802
|
+
} else if (key === host) {
|
|
2803
|
+
router_debug('match: "%s" -> "%s"', host, result = value);
|
|
2804
|
+
break;
|
|
2805
|
+
}
|
|
2806
|
+
return result;
|
|
2807
|
+
}
|
|
2808
|
+
function containsPath(v) {
|
|
2809
|
+
return v.indexOf('/') > -1;
|
|
2810
|
+
}
|
|
2811
|
+
class HttpProxyMiddleware {
|
|
2812
|
+
wsInternalSubscribed = !1;
|
|
2813
|
+
serverOnCloseSubscribed = !1;
|
|
2814
|
+
proxyOptions;
|
|
2815
|
+
proxy;
|
|
2816
|
+
pathRewriter;
|
|
2817
|
+
logger;
|
|
2818
|
+
constructor(options){
|
|
2819
|
+
verifyConfig(options), this.proxyOptions = options, this.logger = options.logger || noopLogger, Debug("create proxy server"), this.proxy = createProxyServer({}), this.registerPlugins(this.proxy, this.proxyOptions), this.pathRewriter = createPathRewriter(this.proxyOptions.pathRewrite), this.middleware.upgrade = (req, socket, head)=>{
|
|
2820
|
+
this.wsInternalSubscribed || this.handleUpgrade(req, socket, head);
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
2823
|
+
middleware = async (req, res, next)=>{
|
|
2824
|
+
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
2825
|
+
let activeProxyOptions;
|
|
2826
|
+
try {
|
|
2827
|
+
if (!(activeProxyOptions = await this.prepareProxyRequest(req)).target && !activeProxyOptions.forward) throw Error('Must provide a proper URL as target');
|
|
2828
|
+
} catch (err) {
|
|
2829
|
+
next?.(err);
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
try {
|
|
2833
|
+
Debug("proxy request to target: %O", activeProxyOptions.target), await this.proxy.web(req, res, activeProxyOptions);
|
|
2834
|
+
} catch (err) {
|
|
2835
|
+
this.proxy.emit('error', err, req, res, activeProxyOptions.target), next?.(err);
|
|
2836
|
+
}
|
|
2837
|
+
} else next?.();
|
|
2838
|
+
let server = req.socket?.server;
|
|
2839
|
+
server && !this.serverOnCloseSubscribed && (server.on('close', ()=>{
|
|
2840
|
+
Debug('server close signal received: closing proxy server'), this.proxy.close(()=>{
|
|
2841
|
+
Debug('proxy server closed');
|
|
2842
|
+
});
|
|
2843
|
+
}), this.serverOnCloseSubscribed = !0), !0 === this.proxyOptions.ws && server && this.catchUpgradeRequest(server);
|
|
2844
|
+
};
|
|
2845
|
+
registerPlugins(proxy, options) {
|
|
2846
|
+
getPlugins(options).forEach((plugin)=>{
|
|
2847
|
+
Debug(`register plugin: "${function_getFunctionName(plugin)}"`), plugin(proxy, options);
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
catchUpgradeRequest = (server)=>{
|
|
2851
|
+
this.wsInternalSubscribed || (Debug('subscribing to server upgrade event'), server.on('upgrade', this.handleUpgrade), this.wsInternalSubscribed = !0);
|
|
2852
|
+
};
|
|
2853
|
+
handleUpgrade = async (req, socket, head)=>{
|
|
2854
|
+
try {
|
|
2855
|
+
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
2856
|
+
let activeProxyOptions = await this.prepareProxyRequest(req);
|
|
2857
|
+
await this.proxy.ws(req, socket, activeProxyOptions, head), Debug('server upgrade event received. Proxying WebSocket');
|
|
2858
|
+
}
|
|
2859
|
+
} catch (err) {
|
|
2860
|
+
this.proxy.emit('error', err, req, socket);
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
shouldProxy = (pathFilter, req)=>{
|
|
2864
|
+
try {
|
|
2865
|
+
return matchPathFilter(pathFilter, req.url, req);
|
|
2866
|
+
} catch (err) {
|
|
2867
|
+
return Debug('Error: matchPathFilter() called with request url: ', `"${req.url}"`), this.logger.error(err), !1;
|
|
2868
|
+
}
|
|
2869
|
+
};
|
|
2870
|
+
prepareProxyRequest = async (req)=>{
|
|
2871
|
+
let newProxyOptions = Object.assign({}, this.proxyOptions);
|
|
2872
|
+
return await this.applyRouter(req, newProxyOptions), await this.applyPathRewrite(req, this.pathRewriter), newProxyOptions;
|
|
2873
|
+
};
|
|
2874
|
+
applyRouter = async (req, options)=>{
|
|
2875
|
+
let newTarget;
|
|
2876
|
+
options.router && (newTarget = await getTarget(req, options)) && (Debug('router new target: "%s"', newTarget), options.target = newTarget);
|
|
2877
|
+
};
|
|
2878
|
+
applyPathRewrite = async (req, pathRewriter)=>{
|
|
2879
|
+
if (pathRewriter) {
|
|
2880
|
+
let path = await pathRewriter(req.url, req);
|
|
2881
|
+
'string' == typeof path ? (Debug('pathRewrite new path: %s', path), req.url = path) : Debug('pathRewrite: no rewritten path found: %s', req.url);
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
}
|
|
2885
|
+
function factory_createProxyMiddleware(options) {
|
|
2886
|
+
let { middleware } = new HttpProxyMiddleware(options);
|
|
2887
|
+
return middleware;
|
|
2888
|
+
}
|
|
2889
|
+
Debug.extend('response-interceptor');
|
|
2890
|
+
export { factory_createProxyMiddleware as createProxyMiddleware };
|