@rsbuild/core 2.0.0-alpha.4 → 2.0.0-beta.1
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/css-loader/index.js +2 -2
- package/compiled/css-loader/package.json +1 -1
- package/compiled/html-rspack-plugin/index.d.ts +102 -1
- package/compiled/html-rspack-plugin/index.js +848 -5
- package/compiled/http-proxy-middleware/index.d.ts +268 -43
- package/compiled/http-proxy-middleware/index.js +2601 -1753
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/dist/131.js +242 -200
- package/dist/manifest-plugin.js +526 -4
- package/dist-types/helpers/index.d.ts +1 -0
- package/dist-types/helpers/vendors.d.ts +1 -0
- package/dist-types/index.d.ts +2 -2
- package/dist-types/pluginHelper.d.ts +1 -1
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +1 -1
- package/dist-types/server/assets-middleware/index.d.ts +1 -1
- package/dist-types/types/config.d.ts +34 -15
- package/package.json +4 -5
- package/dist-types/rspack.d.ts +0 -2
|
@@ -622,6 +622,513 @@
|
|
|
622
622
|
return result;
|
|
623
623
|
};
|
|
624
624
|
},
|
|
625
|
+
471: (module, exports, __nccwpck_require__) => {
|
|
626
|
+
exports.formatArgs = formatArgs;
|
|
627
|
+
exports.save = save;
|
|
628
|
+
exports.load = load;
|
|
629
|
+
exports.useColors = useColors;
|
|
630
|
+
exports.storage = localstorage();
|
|
631
|
+
exports.destroy = (() => {
|
|
632
|
+
let warned = false;
|
|
633
|
+
return () => {
|
|
634
|
+
if (!warned) {
|
|
635
|
+
warned = true;
|
|
636
|
+
console.warn(
|
|
637
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.",
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
})();
|
|
642
|
+
exports.colors = [
|
|
643
|
+
"#0000CC",
|
|
644
|
+
"#0000FF",
|
|
645
|
+
"#0033CC",
|
|
646
|
+
"#0033FF",
|
|
647
|
+
"#0066CC",
|
|
648
|
+
"#0066FF",
|
|
649
|
+
"#0099CC",
|
|
650
|
+
"#0099FF",
|
|
651
|
+
"#00CC00",
|
|
652
|
+
"#00CC33",
|
|
653
|
+
"#00CC66",
|
|
654
|
+
"#00CC99",
|
|
655
|
+
"#00CCCC",
|
|
656
|
+
"#00CCFF",
|
|
657
|
+
"#3300CC",
|
|
658
|
+
"#3300FF",
|
|
659
|
+
"#3333CC",
|
|
660
|
+
"#3333FF",
|
|
661
|
+
"#3366CC",
|
|
662
|
+
"#3366FF",
|
|
663
|
+
"#3399CC",
|
|
664
|
+
"#3399FF",
|
|
665
|
+
"#33CC00",
|
|
666
|
+
"#33CC33",
|
|
667
|
+
"#33CC66",
|
|
668
|
+
"#33CC99",
|
|
669
|
+
"#33CCCC",
|
|
670
|
+
"#33CCFF",
|
|
671
|
+
"#6600CC",
|
|
672
|
+
"#6600FF",
|
|
673
|
+
"#6633CC",
|
|
674
|
+
"#6633FF",
|
|
675
|
+
"#66CC00",
|
|
676
|
+
"#66CC33",
|
|
677
|
+
"#9900CC",
|
|
678
|
+
"#9900FF",
|
|
679
|
+
"#9933CC",
|
|
680
|
+
"#9933FF",
|
|
681
|
+
"#99CC00",
|
|
682
|
+
"#99CC33",
|
|
683
|
+
"#CC0000",
|
|
684
|
+
"#CC0033",
|
|
685
|
+
"#CC0066",
|
|
686
|
+
"#CC0099",
|
|
687
|
+
"#CC00CC",
|
|
688
|
+
"#CC00FF",
|
|
689
|
+
"#CC3300",
|
|
690
|
+
"#CC3333",
|
|
691
|
+
"#CC3366",
|
|
692
|
+
"#CC3399",
|
|
693
|
+
"#CC33CC",
|
|
694
|
+
"#CC33FF",
|
|
695
|
+
"#CC6600",
|
|
696
|
+
"#CC6633",
|
|
697
|
+
"#CC9900",
|
|
698
|
+
"#CC9933",
|
|
699
|
+
"#CCCC00",
|
|
700
|
+
"#CCCC33",
|
|
701
|
+
"#FF0000",
|
|
702
|
+
"#FF0033",
|
|
703
|
+
"#FF0066",
|
|
704
|
+
"#FF0099",
|
|
705
|
+
"#FF00CC",
|
|
706
|
+
"#FF00FF",
|
|
707
|
+
"#FF3300",
|
|
708
|
+
"#FF3333",
|
|
709
|
+
"#FF3366",
|
|
710
|
+
"#FF3399",
|
|
711
|
+
"#FF33CC",
|
|
712
|
+
"#FF33FF",
|
|
713
|
+
"#FF6600",
|
|
714
|
+
"#FF6633",
|
|
715
|
+
"#FF9900",
|
|
716
|
+
"#FF9933",
|
|
717
|
+
"#FFCC00",
|
|
718
|
+
"#FFCC33",
|
|
719
|
+
];
|
|
720
|
+
function useColors() {
|
|
721
|
+
if (
|
|
722
|
+
typeof window !== "undefined" &&
|
|
723
|
+
window.process &&
|
|
724
|
+
(window.process.type === "renderer" || window.process.__nwjs)
|
|
725
|
+
) {
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
if (
|
|
729
|
+
typeof navigator !== "undefined" &&
|
|
730
|
+
navigator.userAgent &&
|
|
731
|
+
navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)
|
|
732
|
+
) {
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
let m;
|
|
736
|
+
return (
|
|
737
|
+
(typeof document !== "undefined" &&
|
|
738
|
+
document.documentElement &&
|
|
739
|
+
document.documentElement.style &&
|
|
740
|
+
document.documentElement.style.WebkitAppearance) ||
|
|
741
|
+
(typeof window !== "undefined" &&
|
|
742
|
+
window.console &&
|
|
743
|
+
(window.console.firebug ||
|
|
744
|
+
(window.console.exception && window.console.table))) ||
|
|
745
|
+
(typeof navigator !== "undefined" &&
|
|
746
|
+
navigator.userAgent &&
|
|
747
|
+
(m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) &&
|
|
748
|
+
parseInt(m[1], 10) >= 31) ||
|
|
749
|
+
(typeof navigator !== "undefined" &&
|
|
750
|
+
navigator.userAgent &&
|
|
751
|
+
navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
function formatArgs(args) {
|
|
755
|
+
args[0] =
|
|
756
|
+
(this.useColors ? "%c" : "") +
|
|
757
|
+
this.namespace +
|
|
758
|
+
(this.useColors ? " %c" : " ") +
|
|
759
|
+
args[0] +
|
|
760
|
+
(this.useColors ? "%c " : " ") +
|
|
761
|
+
"+" +
|
|
762
|
+
module.exports.humanize(this.diff);
|
|
763
|
+
if (!this.useColors) {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
const c = "color: " + this.color;
|
|
767
|
+
args.splice(1, 0, c, "color: inherit");
|
|
768
|
+
let index = 0;
|
|
769
|
+
let lastC = 0;
|
|
770
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
771
|
+
if (match === "%%") {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
index++;
|
|
775
|
+
if (match === "%c") {
|
|
776
|
+
lastC = index;
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
args.splice(lastC, 0, c);
|
|
780
|
+
}
|
|
781
|
+
exports.log = console.debug || console.log || (() => {});
|
|
782
|
+
function save(namespaces) {
|
|
783
|
+
try {
|
|
784
|
+
if (namespaces) {
|
|
785
|
+
exports.storage.setItem("debug", namespaces);
|
|
786
|
+
} else {
|
|
787
|
+
exports.storage.removeItem("debug");
|
|
788
|
+
}
|
|
789
|
+
} catch (error) {}
|
|
790
|
+
}
|
|
791
|
+
function load() {
|
|
792
|
+
let r;
|
|
793
|
+
try {
|
|
794
|
+
r =
|
|
795
|
+
exports.storage.getItem("debug") ||
|
|
796
|
+
exports.storage.getItem("DEBUG");
|
|
797
|
+
} catch (error) {}
|
|
798
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
799
|
+
r = process.env.DEBUG;
|
|
800
|
+
}
|
|
801
|
+
return r;
|
|
802
|
+
}
|
|
803
|
+
function localstorage() {
|
|
804
|
+
try {
|
|
805
|
+
return localStorage;
|
|
806
|
+
} catch (error) {}
|
|
807
|
+
}
|
|
808
|
+
module.exports = __nccwpck_require__(1210)(exports);
|
|
809
|
+
const { formatters } = module.exports;
|
|
810
|
+
formatters.j = function (v) {
|
|
811
|
+
try {
|
|
812
|
+
return JSON.stringify(v);
|
|
813
|
+
} catch (error) {
|
|
814
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
},
|
|
818
|
+
1210: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
819
|
+
function setup(env) {
|
|
820
|
+
createDebug.debug = createDebug;
|
|
821
|
+
createDebug.default = createDebug;
|
|
822
|
+
createDebug.coerce = coerce;
|
|
823
|
+
createDebug.disable = disable;
|
|
824
|
+
createDebug.enable = enable;
|
|
825
|
+
createDebug.enabled = enabled;
|
|
826
|
+
createDebug.humanize = __nccwpck_require__(6987);
|
|
827
|
+
createDebug.destroy = destroy;
|
|
828
|
+
Object.keys(env).forEach((key) => {
|
|
829
|
+
createDebug[key] = env[key];
|
|
830
|
+
});
|
|
831
|
+
createDebug.names = [];
|
|
832
|
+
createDebug.skips = [];
|
|
833
|
+
createDebug.formatters = {};
|
|
834
|
+
function selectColor(namespace) {
|
|
835
|
+
let hash = 0;
|
|
836
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
837
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
838
|
+
hash |= 0;
|
|
839
|
+
}
|
|
840
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
841
|
+
}
|
|
842
|
+
createDebug.selectColor = selectColor;
|
|
843
|
+
function createDebug(namespace) {
|
|
844
|
+
let prevTime;
|
|
845
|
+
let enableOverride = null;
|
|
846
|
+
let namespacesCache;
|
|
847
|
+
let enabledCache;
|
|
848
|
+
function debug(...args) {
|
|
849
|
+
if (!debug.enabled) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
const self = debug;
|
|
853
|
+
const curr = Number(new Date());
|
|
854
|
+
const ms = curr - (prevTime || curr);
|
|
855
|
+
self.diff = ms;
|
|
856
|
+
self.prev = prevTime;
|
|
857
|
+
self.curr = curr;
|
|
858
|
+
prevTime = curr;
|
|
859
|
+
args[0] = createDebug.coerce(args[0]);
|
|
860
|
+
if (typeof args[0] !== "string") {
|
|
861
|
+
args.unshift("%O");
|
|
862
|
+
}
|
|
863
|
+
let index = 0;
|
|
864
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
865
|
+
if (match === "%%") {
|
|
866
|
+
return "%";
|
|
867
|
+
}
|
|
868
|
+
index++;
|
|
869
|
+
const formatter = createDebug.formatters[format];
|
|
870
|
+
if (typeof formatter === "function") {
|
|
871
|
+
const val = args[index];
|
|
872
|
+
match = formatter.call(self, val);
|
|
873
|
+
args.splice(index, 1);
|
|
874
|
+
index--;
|
|
875
|
+
}
|
|
876
|
+
return match;
|
|
877
|
+
});
|
|
878
|
+
createDebug.formatArgs.call(self, args);
|
|
879
|
+
const logFn = self.log || createDebug.log;
|
|
880
|
+
logFn.apply(self, args);
|
|
881
|
+
}
|
|
882
|
+
debug.namespace = namespace;
|
|
883
|
+
debug.useColors = createDebug.useColors();
|
|
884
|
+
debug.color = createDebug.selectColor(namespace);
|
|
885
|
+
debug.extend = extend;
|
|
886
|
+
debug.destroy = createDebug.destroy;
|
|
887
|
+
Object.defineProperty(debug, "enabled", {
|
|
888
|
+
enumerable: true,
|
|
889
|
+
configurable: false,
|
|
890
|
+
get: () => {
|
|
891
|
+
if (enableOverride !== null) {
|
|
892
|
+
return enableOverride;
|
|
893
|
+
}
|
|
894
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
895
|
+
namespacesCache = createDebug.namespaces;
|
|
896
|
+
enabledCache = createDebug.enabled(namespace);
|
|
897
|
+
}
|
|
898
|
+
return enabledCache;
|
|
899
|
+
},
|
|
900
|
+
set: (v) => {
|
|
901
|
+
enableOverride = v;
|
|
902
|
+
},
|
|
903
|
+
});
|
|
904
|
+
if (typeof createDebug.init === "function") {
|
|
905
|
+
createDebug.init(debug);
|
|
906
|
+
}
|
|
907
|
+
return debug;
|
|
908
|
+
}
|
|
909
|
+
function extend(namespace, delimiter) {
|
|
910
|
+
const newDebug = createDebug(
|
|
911
|
+
this.namespace +
|
|
912
|
+
(typeof delimiter === "undefined" ? ":" : delimiter) +
|
|
913
|
+
namespace,
|
|
914
|
+
);
|
|
915
|
+
newDebug.log = this.log;
|
|
916
|
+
return newDebug;
|
|
917
|
+
}
|
|
918
|
+
function enable(namespaces) {
|
|
919
|
+
createDebug.save(namespaces);
|
|
920
|
+
createDebug.namespaces = namespaces;
|
|
921
|
+
createDebug.names = [];
|
|
922
|
+
createDebug.skips = [];
|
|
923
|
+
const split = (typeof namespaces === "string" ? namespaces : "")
|
|
924
|
+
.trim()
|
|
925
|
+
.replace(/\s+/g, ",")
|
|
926
|
+
.split(",")
|
|
927
|
+
.filter(Boolean);
|
|
928
|
+
for (const ns of split) {
|
|
929
|
+
if (ns[0] === "-") {
|
|
930
|
+
createDebug.skips.push(ns.slice(1));
|
|
931
|
+
} else {
|
|
932
|
+
createDebug.names.push(ns);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
function matchesTemplate(search, template) {
|
|
937
|
+
let searchIndex = 0;
|
|
938
|
+
let templateIndex = 0;
|
|
939
|
+
let starIndex = -1;
|
|
940
|
+
let matchIndex = 0;
|
|
941
|
+
while (searchIndex < search.length) {
|
|
942
|
+
if (
|
|
943
|
+
templateIndex < template.length &&
|
|
944
|
+
(template[templateIndex] === search[searchIndex] ||
|
|
945
|
+
template[templateIndex] === "*")
|
|
946
|
+
) {
|
|
947
|
+
if (template[templateIndex] === "*") {
|
|
948
|
+
starIndex = templateIndex;
|
|
949
|
+
matchIndex = searchIndex;
|
|
950
|
+
templateIndex++;
|
|
951
|
+
} else {
|
|
952
|
+
searchIndex++;
|
|
953
|
+
templateIndex++;
|
|
954
|
+
}
|
|
955
|
+
} else if (starIndex !== -1) {
|
|
956
|
+
templateIndex = starIndex + 1;
|
|
957
|
+
matchIndex++;
|
|
958
|
+
searchIndex = matchIndex;
|
|
959
|
+
} else {
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
while (
|
|
964
|
+
templateIndex < template.length &&
|
|
965
|
+
template[templateIndex] === "*"
|
|
966
|
+
) {
|
|
967
|
+
templateIndex++;
|
|
968
|
+
}
|
|
969
|
+
return templateIndex === template.length;
|
|
970
|
+
}
|
|
971
|
+
function disable() {
|
|
972
|
+
const namespaces = [
|
|
973
|
+
...createDebug.names,
|
|
974
|
+
...createDebug.skips.map((namespace) => "-" + namespace),
|
|
975
|
+
].join(",");
|
|
976
|
+
createDebug.enable("");
|
|
977
|
+
return namespaces;
|
|
978
|
+
}
|
|
979
|
+
function enabled(name) {
|
|
980
|
+
for (const skip of createDebug.skips) {
|
|
981
|
+
if (matchesTemplate(name, skip)) {
|
|
982
|
+
return false;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
for (const ns of createDebug.names) {
|
|
986
|
+
if (matchesTemplate(name, ns)) {
|
|
987
|
+
return true;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
return false;
|
|
991
|
+
}
|
|
992
|
+
function coerce(val) {
|
|
993
|
+
if (val instanceof Error) {
|
|
994
|
+
return val.stack || val.message;
|
|
995
|
+
}
|
|
996
|
+
return val;
|
|
997
|
+
}
|
|
998
|
+
function destroy() {
|
|
999
|
+
console.warn(
|
|
1000
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.",
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
createDebug.enable(createDebug.load());
|
|
1004
|
+
return createDebug;
|
|
1005
|
+
}
|
|
1006
|
+
module.exports = setup;
|
|
1007
|
+
},
|
|
1008
|
+
6675: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1009
|
+
if (
|
|
1010
|
+
typeof process === "undefined" ||
|
|
1011
|
+
process.type === "renderer" ||
|
|
1012
|
+
process.browser === true ||
|
|
1013
|
+
process.__nwjs
|
|
1014
|
+
) {
|
|
1015
|
+
module.exports = __nccwpck_require__(471);
|
|
1016
|
+
} else {
|
|
1017
|
+
module.exports = __nccwpck_require__(7443);
|
|
1018
|
+
}
|
|
1019
|
+
},
|
|
1020
|
+
7443: (module, exports, __nccwpck_require__) => {
|
|
1021
|
+
const tty = __nccwpck_require__(2018);
|
|
1022
|
+
const util = __nccwpck_require__(9023);
|
|
1023
|
+
exports.init = init;
|
|
1024
|
+
exports.log = log;
|
|
1025
|
+
exports.formatArgs = formatArgs;
|
|
1026
|
+
exports.save = save;
|
|
1027
|
+
exports.load = load;
|
|
1028
|
+
exports.useColors = useColors;
|
|
1029
|
+
exports.destroy = util.deprecate(
|
|
1030
|
+
() => {},
|
|
1031
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.",
|
|
1032
|
+
);
|
|
1033
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
1034
|
+
try {
|
|
1035
|
+
const supportsColor = __nccwpck_require__(115);
|
|
1036
|
+
if (
|
|
1037
|
+
supportsColor &&
|
|
1038
|
+
(supportsColor.stderr || supportsColor).level >= 2
|
|
1039
|
+
) {
|
|
1040
|
+
exports.colors = [
|
|
1041
|
+
20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62,
|
|
1042
|
+
63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112,
|
|
1043
|
+
113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165,
|
|
1044
|
+
166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196,
|
|
1045
|
+
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
|
|
1046
|
+
214, 215, 220, 221,
|
|
1047
|
+
];
|
|
1048
|
+
}
|
|
1049
|
+
} catch (error) {}
|
|
1050
|
+
exports.inspectOpts = Object.keys(process.env)
|
|
1051
|
+
.filter((key) => /^debug_/i.test(key))
|
|
1052
|
+
.reduce((obj, key) => {
|
|
1053
|
+
const prop = key
|
|
1054
|
+
.substring(6)
|
|
1055
|
+
.toLowerCase()
|
|
1056
|
+
.replace(/_([a-z])/g, (_, k) => k.toUpperCase());
|
|
1057
|
+
let val = process.env[key];
|
|
1058
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
1059
|
+
val = true;
|
|
1060
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
1061
|
+
val = false;
|
|
1062
|
+
} else if (val === "null") {
|
|
1063
|
+
val = null;
|
|
1064
|
+
} else {
|
|
1065
|
+
val = Number(val);
|
|
1066
|
+
}
|
|
1067
|
+
obj[prop] = val;
|
|
1068
|
+
return obj;
|
|
1069
|
+
}, {});
|
|
1070
|
+
function useColors() {
|
|
1071
|
+
return "colors" in exports.inspectOpts
|
|
1072
|
+
? Boolean(exports.inspectOpts.colors)
|
|
1073
|
+
: tty.isatty(process.stderr.fd);
|
|
1074
|
+
}
|
|
1075
|
+
function formatArgs(args) {
|
|
1076
|
+
const { namespace: name, useColors } = this;
|
|
1077
|
+
if (useColors) {
|
|
1078
|
+
const c = this.color;
|
|
1079
|
+
const colorCode = "[3" + (c < 8 ? c : "8;5;" + c);
|
|
1080
|
+
const prefix = ` ${colorCode};1m${name} [0m`;
|
|
1081
|
+
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
1082
|
+
args.push(
|
|
1083
|
+
colorCode + "m+" + module.exports.humanize(this.diff) + "[0m",
|
|
1084
|
+
);
|
|
1085
|
+
} else {
|
|
1086
|
+
args[0] = getDate() + name + " " + args[0];
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
function getDate() {
|
|
1090
|
+
if (exports.inspectOpts.hideDate) {
|
|
1091
|
+
return "";
|
|
1092
|
+
}
|
|
1093
|
+
return new Date().toISOString() + " ";
|
|
1094
|
+
}
|
|
1095
|
+
function log(...args) {
|
|
1096
|
+
return process.stderr.write(
|
|
1097
|
+
util.formatWithOptions(exports.inspectOpts, ...args) + "\n",
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
function save(namespaces) {
|
|
1101
|
+
if (namespaces) {
|
|
1102
|
+
process.env.DEBUG = namespaces;
|
|
1103
|
+
} else {
|
|
1104
|
+
delete process.env.DEBUG;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function load() {
|
|
1108
|
+
return process.env.DEBUG;
|
|
1109
|
+
}
|
|
1110
|
+
function init(debug) {
|
|
1111
|
+
debug.inspectOpts = {};
|
|
1112
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
1113
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1114
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
module.exports = __nccwpck_require__(1210)(exports);
|
|
1118
|
+
const { formatters } = module.exports;
|
|
1119
|
+
formatters.o = function (v) {
|
|
1120
|
+
this.inspectOpts.colors = this.useColors;
|
|
1121
|
+
return util
|
|
1122
|
+
.inspect(v, this.inspectOpts)
|
|
1123
|
+
.split("\n")
|
|
1124
|
+
.map((str) => str.trim())
|
|
1125
|
+
.join(" ");
|
|
1126
|
+
};
|
|
1127
|
+
formatters.O = function (v) {
|
|
1128
|
+
this.inspectOpts.colors = this.useColors;
|
|
1129
|
+
return util.inspect(v, this.inspectOpts);
|
|
1130
|
+
};
|
|
1131
|
+
},
|
|
625
1132
|
6234: (module) => {
|
|
626
1133
|
"use strict";
|
|
627
1134
|
var has = Object.prototype.hasOwnProperty,
|
|
@@ -1029,12 +1536,12 @@
|
|
|
1029
1536
|
};
|
|
1030
1537
|
module.exports = fill;
|
|
1031
1538
|
},
|
|
1032
|
-
|
|
1539
|
+
4382: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1033
1540
|
var debug;
|
|
1034
1541
|
module.exports = function () {
|
|
1035
1542
|
if (!debug) {
|
|
1036
1543
|
try {
|
|
1037
|
-
debug = __nccwpck_require__(
|
|
1544
|
+
debug = __nccwpck_require__(6675)("follow-redirects");
|
|
1038
1545
|
} catch (error) {}
|
|
1039
1546
|
if (typeof debug !== "function") {
|
|
1040
1547
|
debug = function () {};
|
|
@@ -1043,14 +1550,14 @@
|
|
|
1043
1550
|
debug.apply(null, arguments);
|
|
1044
1551
|
};
|
|
1045
1552
|
},
|
|
1046
|
-
|
|
1553
|
+
8977: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1047
1554
|
var url = __nccwpck_require__(7016);
|
|
1048
1555
|
var URL = url.URL;
|
|
1049
1556
|
var http = __nccwpck_require__(8611);
|
|
1050
1557
|
var https = __nccwpck_require__(5692);
|
|
1051
1558
|
var Writable = __nccwpck_require__(2203).Writable;
|
|
1052
1559
|
var assert = __nccwpck_require__(2613);
|
|
1053
|
-
var debug = __nccwpck_require__(
|
|
1560
|
+
var debug = __nccwpck_require__(4382);
|
|
1054
1561
|
(function detectUnsupportedEnvironment() {
|
|
1055
1562
|
var looksLikeNode = typeof process !== "undefined";
|
|
1056
1563
|
var looksLikeBrowser =
|
|
@@ -1593,1333 +2100,543 @@
|
|
|
1593
2100
|
module.exports = wrap({ http, https });
|
|
1594
2101
|
module.exports.wrap = wrap;
|
|
1595
2102
|
},
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
});
|
|
1610
|
-
proxy.on("proxyReqWs", (proxyReq, req, socket, options, head) => {
|
|
1611
|
-
socket.on("error", (error) => {
|
|
1612
|
-
logger.error(`[HPM] WebSocket error: %O`, error);
|
|
1613
|
-
});
|
|
1614
|
-
});
|
|
1615
|
-
logger.debug(
|
|
1616
|
-
"[HPM] Subscribed to http-proxy events:",
|
|
1617
|
-
Object.keys(handlers),
|
|
1618
|
-
);
|
|
1619
|
-
}
|
|
1620
|
-
exports.init = init;
|
|
1621
|
-
function getHandlers(options) {
|
|
1622
|
-
const proxyEventsMap = {
|
|
1623
|
-
error: "onError",
|
|
1624
|
-
proxyReq: "onProxyReq",
|
|
1625
|
-
proxyReqWs: "onProxyReqWs",
|
|
1626
|
-
proxyRes: "onProxyRes",
|
|
1627
|
-
open: "onOpen",
|
|
1628
|
-
close: "onClose",
|
|
1629
|
-
};
|
|
1630
|
-
const handlers = {};
|
|
1631
|
-
for (const [eventName, onEventName] of Object.entries(proxyEventsMap)) {
|
|
1632
|
-
const fnHandler = options ? options[onEventName] : null;
|
|
1633
|
-
if (typeof fnHandler === "function") {
|
|
1634
|
-
handlers[eventName] = fnHandler;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
if (typeof handlers.error !== "function") {
|
|
1638
|
-
handlers.error = defaultErrorHandler;
|
|
1639
|
-
}
|
|
1640
|
-
if (typeof handlers.close !== "function") {
|
|
1641
|
-
handlers.close = logClose;
|
|
1642
|
-
}
|
|
1643
|
-
return handlers;
|
|
1644
|
-
}
|
|
1645
|
-
exports.getHandlers = getHandlers;
|
|
1646
|
-
function defaultErrorHandler(err, req, res) {
|
|
1647
|
-
if (!req && !res) {
|
|
1648
|
-
throw err;
|
|
1649
|
-
}
|
|
1650
|
-
const host = req.headers && req.headers.host;
|
|
1651
|
-
const code = err.code;
|
|
1652
|
-
if (res.writeHead && !res.headersSent) {
|
|
1653
|
-
if (/HPE_INVALID/.test(code)) {
|
|
1654
|
-
res.writeHead(502);
|
|
1655
|
-
} else {
|
|
1656
|
-
switch (code) {
|
|
1657
|
-
case "ECONNRESET":
|
|
1658
|
-
case "ENOTFOUND":
|
|
1659
|
-
case "ECONNREFUSED":
|
|
1660
|
-
case "ETIMEDOUT":
|
|
1661
|
-
res.writeHead(504);
|
|
1662
|
-
break;
|
|
1663
|
-
default:
|
|
1664
|
-
res.writeHead(500);
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
res.end(`Error occurred while trying to proxy: ${host}${req.url}`);
|
|
1669
|
-
}
|
|
1670
|
-
function logClose(req, socket, head) {
|
|
1671
|
-
logger.info("[HPM] Client disconnected");
|
|
1672
|
-
}
|
|
2103
|
+
1929: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2104
|
+
/*!
|
|
2105
|
+
* Caron dimonio, con occhi di bragia
|
|
2106
|
+
* loro accennando, tutte le raccoglie;
|
|
2107
|
+
* batte col remo qualunque s’adagia
|
|
2108
|
+
*
|
|
2109
|
+
* Charon the demon, with the eyes of glede,
|
|
2110
|
+
* Beckoning to them, collects them all together,
|
|
2111
|
+
* Beats with his oar whoever lags behind
|
|
2112
|
+
*
|
|
2113
|
+
* Dante - The Divine Comedy (Canto III)
|
|
2114
|
+
*/
|
|
2115
|
+
module.exports = __nccwpck_require__(8944);
|
|
1673
2116
|
},
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
const isPlainObj = __nccwpck_require__(3458);
|
|
1679
|
-
const url = __nccwpck_require__(7016);
|
|
1680
|
-
const errors_1 = __nccwpck_require__(4618);
|
|
1681
|
-
const logger_1 = __nccwpck_require__(8045);
|
|
1682
|
-
const logger = (0, logger_1.getInstance)();
|
|
1683
|
-
function createConfig(context, opts) {
|
|
1684
|
-
const config = { context: undefined, options: {} };
|
|
1685
|
-
if (isContextless(context, opts)) {
|
|
1686
|
-
config.context = "/";
|
|
1687
|
-
config.options = Object.assign(config.options, context);
|
|
1688
|
-
} else if (isStringShortHand(context)) {
|
|
1689
|
-
const oUrl = url.parse(context);
|
|
1690
|
-
const target = [oUrl.protocol, "//", oUrl.host].join("");
|
|
1691
|
-
config.context = oUrl.pathname || "/";
|
|
1692
|
-
config.options = Object.assign(config.options, { target }, opts);
|
|
1693
|
-
if (oUrl.protocol === "ws:" || oUrl.protocol === "wss:") {
|
|
1694
|
-
config.options.ws = true;
|
|
1695
|
-
}
|
|
1696
|
-
} else {
|
|
1697
|
-
config.context = context;
|
|
1698
|
-
config.options = Object.assign(config.options, opts);
|
|
1699
|
-
}
|
|
1700
|
-
configureLogger(config.options);
|
|
1701
|
-
if (!config.options.target && !config.options.router) {
|
|
1702
|
-
throw new Error(errors_1.ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING);
|
|
1703
|
-
}
|
|
1704
|
-
return config;
|
|
1705
|
-
}
|
|
1706
|
-
exports.createConfig = createConfig;
|
|
1707
|
-
function isStringShortHand(context) {
|
|
1708
|
-
if (typeof context === "string") {
|
|
1709
|
-
return !!url.parse(context).host;
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
function isContextless(context, opts) {
|
|
1713
|
-
return (
|
|
1714
|
-
isPlainObj(context) &&
|
|
1715
|
-
(opts == null || Object.keys(opts).length === 0)
|
|
1716
|
-
);
|
|
1717
|
-
}
|
|
1718
|
-
function configureLogger(options) {
|
|
1719
|
-
if (options.logLevel) {
|
|
1720
|
-
logger.setLevel(options.logLevel);
|
|
1721
|
-
}
|
|
1722
|
-
if (options.logProvider) {
|
|
1723
|
-
logger.setProvider(options.logProvider);
|
|
1724
|
-
}
|
|
2117
|
+
8944: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2118
|
+
var ProxyServer = __nccwpck_require__(9815).Server;
|
|
2119
|
+
function createProxyServer(options) {
|
|
2120
|
+
return new ProxyServer(options);
|
|
1725
2121
|
}
|
|
2122
|
+
ProxyServer.createProxyServer = createProxyServer;
|
|
2123
|
+
ProxyServer.createServer = createProxyServer;
|
|
2124
|
+
ProxyServer.createProxy = createProxyServer;
|
|
2125
|
+
module.exports = ProxyServer;
|
|
1726
2126
|
},
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
2127
|
+
6758: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2128
|
+
var common = exports,
|
|
2129
|
+
url = __nccwpck_require__(7016),
|
|
2130
|
+
required = __nccwpck_require__(7866);
|
|
2131
|
+
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
|
|
2132
|
+
isSSL = /^https|wss/;
|
|
2133
|
+
common.isSSL = isSSL;
|
|
2134
|
+
common.setupOutgoing = function (outgoing, options, req, forward) {
|
|
2135
|
+
outgoing.port =
|
|
2136
|
+
options[forward || "target"].port ||
|
|
2137
|
+
(isSSL.test(options[forward || "target"].protocol) ? 443 : 80);
|
|
2138
|
+
[
|
|
2139
|
+
"host",
|
|
2140
|
+
"hostname",
|
|
2141
|
+
"socketPath",
|
|
2142
|
+
"pfx",
|
|
2143
|
+
"key",
|
|
2144
|
+
"passphrase",
|
|
2145
|
+
"cert",
|
|
2146
|
+
"ca",
|
|
2147
|
+
"ciphers",
|
|
2148
|
+
"secureProtocol",
|
|
2149
|
+
].forEach(function (e) {
|
|
2150
|
+
outgoing[e] = options[forward || "target"][e];
|
|
2151
|
+
});
|
|
2152
|
+
outgoing.method = options.method || req.method;
|
|
2153
|
+
outgoing.headers = Object.assign({}, req.headers);
|
|
2154
|
+
if (options.headers) {
|
|
2155
|
+
Object.assign(outgoing.headers, options.headers);
|
|
1738
2156
|
}
|
|
1739
|
-
if (
|
|
1740
|
-
|
|
2157
|
+
if (options.auth) {
|
|
2158
|
+
outgoing.auth = options.auth;
|
|
1741
2159
|
}
|
|
1742
|
-
if (
|
|
1743
|
-
|
|
1744
|
-
return matchMultiPath(context, uri);
|
|
1745
|
-
}
|
|
1746
|
-
if (context.every(isGlobPath)) {
|
|
1747
|
-
return matchMultiGlobPath(context, uri);
|
|
1748
|
-
}
|
|
1749
|
-
throw new Error(errors_1.ERRORS.ERR_CONTEXT_MATCHER_INVALID_ARRAY);
|
|
2160
|
+
if (options.ca) {
|
|
2161
|
+
outgoing.ca = options.ca;
|
|
1750
2162
|
}
|
|
1751
|
-
if (
|
|
1752
|
-
|
|
1753
|
-
|
|
2163
|
+
if (isSSL.test(options[forward || "target"].protocol)) {
|
|
2164
|
+
outgoing.rejectUnauthorized =
|
|
2165
|
+
typeof options.secure === "undefined" ? true : options.secure;
|
|
1754
2166
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
const matches = micromatch([pathname], pattern);
|
|
1765
|
-
return matches && matches.length > 0;
|
|
1766
|
-
}
|
|
1767
|
-
function matchMultiGlobPath(patternList, uri) {
|
|
1768
|
-
return matchSingleGlobPath(patternList, uri);
|
|
1769
|
-
}
|
|
1770
|
-
function matchMultiPath(contextList, uri) {
|
|
1771
|
-
let isMultiPath = false;
|
|
1772
|
-
for (const context of contextList) {
|
|
1773
|
-
if (matchSingleStringPath(context, uri)) {
|
|
1774
|
-
isMultiPath = true;
|
|
1775
|
-
break;
|
|
2167
|
+
outgoing.agent = options.agent || false;
|
|
2168
|
+
outgoing.localAddress = options.localAddress;
|
|
2169
|
+
if (!outgoing.agent) {
|
|
2170
|
+
outgoing.headers = outgoing.headers || {};
|
|
2171
|
+
if (
|
|
2172
|
+
typeof outgoing.headers.connection !== "string" ||
|
|
2173
|
+
!upgradeHeader.test(outgoing.headers.connection)
|
|
2174
|
+
) {
|
|
2175
|
+
outgoing.headers.connection = "close";
|
|
1776
2176
|
}
|
|
1777
2177
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1793
|
-
exports.ERRORS = void 0;
|
|
1794
|
-
var ERRORS;
|
|
1795
|
-
(function (ERRORS) {
|
|
1796
|
-
ERRORS["ERR_CONFIG_FACTORY_TARGET_MISSING"] =
|
|
1797
|
-
'[HPM] Missing "target" option. Example: {target: "http://www.example.org"}';
|
|
1798
|
-
ERRORS["ERR_CONTEXT_MATCHER_GENERIC"] =
|
|
1799
|
-
'[HPM] Invalid context. Expecting something like: "/api" or ["/api", "/ajax"]';
|
|
1800
|
-
ERRORS["ERR_CONTEXT_MATCHER_INVALID_ARRAY"] =
|
|
1801
|
-
'[HPM] Invalid context. Expecting something like: ["/api", "/ajax"] or ["/api/**", "!**.html"]';
|
|
1802
|
-
ERRORS["ERR_PATH_REWRITER_CONFIG"] =
|
|
1803
|
-
"[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function";
|
|
1804
|
-
})((ERRORS = exports.ERRORS || (exports.ERRORS = {})));
|
|
1805
|
-
},
|
|
1806
|
-
6861: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1807
|
-
"use strict";
|
|
1808
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1809
|
-
exports.fixRequestBody = void 0;
|
|
1810
|
-
const querystring = __nccwpck_require__(3480);
|
|
1811
|
-
function fixRequestBody(proxyReq, req) {
|
|
1812
|
-
if (req.readableLength !== 0) {
|
|
1813
|
-
return;
|
|
1814
|
-
}
|
|
1815
|
-
const requestBody = req.body;
|
|
1816
|
-
if (!requestBody) {
|
|
1817
|
-
return;
|
|
1818
|
-
}
|
|
1819
|
-
const contentType = proxyReq.getHeader("Content-Type");
|
|
1820
|
-
if (!contentType) {
|
|
1821
|
-
return;
|
|
2178
|
+
var target = options[forward || "target"];
|
|
2179
|
+
var targetPath =
|
|
2180
|
+
target && options.prependPath !== false ? target.path || "" : "";
|
|
2181
|
+
var outgoingPath = !options.toProxy
|
|
2182
|
+
? url.parse(req.url).path || ""
|
|
2183
|
+
: req.url;
|
|
2184
|
+
outgoingPath = !options.ignorePath ? outgoingPath : "";
|
|
2185
|
+
outgoing.path = common.urlJoin(targetPath, outgoingPath);
|
|
2186
|
+
if (options.changeOrigin) {
|
|
2187
|
+
outgoing.headers.host =
|
|
2188
|
+
required(outgoing.port, options[forward || "target"].protocol) &&
|
|
2189
|
+
!hasPort(outgoing.host)
|
|
2190
|
+
? outgoing.host + ":" + outgoing.port
|
|
2191
|
+
: outgoing.host;
|
|
1822
2192
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
2193
|
+
return outgoing;
|
|
2194
|
+
};
|
|
2195
|
+
common.setupSocket = function (socket) {
|
|
2196
|
+
socket.setTimeout(0);
|
|
2197
|
+
socket.setNoDelay(true);
|
|
2198
|
+
socket.setKeepAlive(true, 0);
|
|
2199
|
+
return socket;
|
|
2200
|
+
};
|
|
2201
|
+
common.getPort = function (req) {
|
|
2202
|
+
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
|
|
2203
|
+
return res ? res[1] : common.hasEncryptedConnection(req) ? "443" : "80";
|
|
2204
|
+
};
|
|
2205
|
+
common.hasEncryptedConnection = function (req) {
|
|
2206
|
+
return Boolean(req.connection.encrypted || req.connection.pair);
|
|
2207
|
+
};
|
|
2208
|
+
common.urlJoin = function () {
|
|
2209
|
+
var args = Array.prototype.slice.call(arguments),
|
|
2210
|
+
lastIndex = args.length - 1,
|
|
2211
|
+
last = args[lastIndex],
|
|
2212
|
+
lastSegs = last.split("?"),
|
|
2213
|
+
retSegs;
|
|
2214
|
+
args[lastIndex] = lastSegs.shift();
|
|
2215
|
+
retSegs = [
|
|
2216
|
+
args
|
|
2217
|
+
.filter(Boolean)
|
|
2218
|
+
.join("/")
|
|
2219
|
+
.replace(/\/+/g, "/")
|
|
2220
|
+
.replace("http:/", "http://")
|
|
2221
|
+
.replace("https:/", "https://"),
|
|
2222
|
+
];
|
|
2223
|
+
retSegs.push.apply(retSegs, lastSegs);
|
|
2224
|
+
return retSegs.join("?");
|
|
2225
|
+
};
|
|
2226
|
+
common.rewriteCookieProperty = function rewriteCookieProperty(
|
|
2227
|
+
header,
|
|
2228
|
+
config,
|
|
2229
|
+
property,
|
|
2230
|
+
) {
|
|
2231
|
+
if (Array.isArray(header)) {
|
|
2232
|
+
return header.map(function (headerElement) {
|
|
2233
|
+
return rewriteCookieProperty(headerElement, config, property);
|
|
2234
|
+
});
|
|
1831
2235
|
}
|
|
2236
|
+
return header.replace(
|
|
2237
|
+
new RegExp("(;\\s*" + property + "=)([^;]+)", "i"),
|
|
2238
|
+
function (match, prefix, previousValue) {
|
|
2239
|
+
var newValue;
|
|
2240
|
+
if (previousValue in config) {
|
|
2241
|
+
newValue = config[previousValue];
|
|
2242
|
+
} else if ("*" in config) {
|
|
2243
|
+
newValue = config["*"];
|
|
2244
|
+
} else {
|
|
2245
|
+
return match;
|
|
2246
|
+
}
|
|
2247
|
+
if (newValue) {
|
|
2248
|
+
return prefix + newValue;
|
|
2249
|
+
} else {
|
|
2250
|
+
return "";
|
|
2251
|
+
}
|
|
2252
|
+
},
|
|
2253
|
+
);
|
|
2254
|
+
};
|
|
2255
|
+
function hasPort(host) {
|
|
2256
|
+
return !!~host.indexOf(":");
|
|
1832
2257
|
}
|
|
1833
|
-
exports.fixRequestBody = fixRequestBody;
|
|
1834
2258
|
},
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
(
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
2259
|
+
9815: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2260
|
+
var httpProxy = module.exports,
|
|
2261
|
+
parse_url = __nccwpck_require__(7016).parse,
|
|
2262
|
+
EE3 = __nccwpck_require__(6234),
|
|
2263
|
+
http = __nccwpck_require__(8611),
|
|
2264
|
+
https = __nccwpck_require__(5692),
|
|
2265
|
+
web = __nccwpck_require__(7640),
|
|
2266
|
+
ws = __nccwpck_require__(2264);
|
|
2267
|
+
httpProxy.Server = ProxyServer;
|
|
2268
|
+
function createRightProxy(type) {
|
|
2269
|
+
return function (options) {
|
|
2270
|
+
return function (req, res) {
|
|
2271
|
+
var passes = type === "ws" ? this.wsPasses : this.webPasses,
|
|
2272
|
+
args = [].slice.call(arguments),
|
|
2273
|
+
cntr = args.length - 1,
|
|
2274
|
+
head,
|
|
2275
|
+
cbl;
|
|
2276
|
+
if (typeof args[cntr] === "function") {
|
|
2277
|
+
cbl = args[cntr];
|
|
2278
|
+
cntr--;
|
|
1848
2279
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
2280
|
+
var requestOptions = options;
|
|
2281
|
+
if (!(args[cntr] instanceof Buffer) && args[cntr] !== res) {
|
|
2282
|
+
requestOptions = Object.assign({}, options);
|
|
2283
|
+
Object.assign(requestOptions, args[cntr]);
|
|
2284
|
+
cntr--;
|
|
2285
|
+
}
|
|
2286
|
+
if (args[cntr] instanceof Buffer) {
|
|
2287
|
+
head = args[cntr];
|
|
2288
|
+
}
|
|
2289
|
+
["target", "forward"].forEach(function (e) {
|
|
2290
|
+
if (typeof requestOptions[e] === "string")
|
|
2291
|
+
requestOptions[e] = parse_url(requestOptions[e]);
|
|
1852
2292
|
});
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
},
|
|
1866
|
-
9602: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1867
|
-
"use strict";
|
|
1868
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1869
|
-
exports.fixRequestBody = exports.responseInterceptor = void 0;
|
|
1870
|
-
var response_interceptor_1 = __nccwpck_require__(5938);
|
|
1871
|
-
Object.defineProperty(exports, "responseInterceptor", {
|
|
1872
|
-
enumerable: true,
|
|
1873
|
-
get: function () {
|
|
1874
|
-
return response_interceptor_1.responseInterceptor;
|
|
1875
|
-
},
|
|
1876
|
-
});
|
|
1877
|
-
var fix_request_body_1 = __nccwpck_require__(6861);
|
|
1878
|
-
Object.defineProperty(exports, "fixRequestBody", {
|
|
1879
|
-
enumerable: true,
|
|
1880
|
-
get: function () {
|
|
1881
|
-
return fix_request_body_1.fixRequestBody;
|
|
1882
|
-
},
|
|
1883
|
-
});
|
|
1884
|
-
},
|
|
1885
|
-
5938: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1886
|
-
"use strict";
|
|
1887
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1888
|
-
exports.responseInterceptor = void 0;
|
|
1889
|
-
const zlib = __nccwpck_require__(3106);
|
|
1890
|
-
function responseInterceptor(interceptor) {
|
|
1891
|
-
return async function proxyRes(proxyRes, req, res) {
|
|
1892
|
-
const originalProxyRes = proxyRes;
|
|
1893
|
-
let buffer = Buffer.from("", "utf8");
|
|
1894
|
-
const _proxyRes = decompress(
|
|
1895
|
-
proxyRes,
|
|
1896
|
-
proxyRes.headers["content-encoding"],
|
|
1897
|
-
);
|
|
1898
|
-
_proxyRes.on(
|
|
1899
|
-
"data",
|
|
1900
|
-
(chunk) => (buffer = Buffer.concat([buffer, chunk])),
|
|
1901
|
-
);
|
|
1902
|
-
_proxyRes.on("end", async () => {
|
|
1903
|
-
copyHeaders(proxyRes, res);
|
|
1904
|
-
const interceptedBuffer = Buffer.from(
|
|
1905
|
-
await interceptor(buffer, originalProxyRes, req, res),
|
|
1906
|
-
);
|
|
1907
|
-
res.setHeader(
|
|
1908
|
-
"content-length",
|
|
1909
|
-
Buffer.byteLength(interceptedBuffer, "utf8"),
|
|
1910
|
-
);
|
|
1911
|
-
res.write(interceptedBuffer);
|
|
1912
|
-
res.end();
|
|
1913
|
-
});
|
|
1914
|
-
_proxyRes.on("error", (error) => {
|
|
1915
|
-
res.end(`Error fetching proxied request: ${error.message}`);
|
|
1916
|
-
});
|
|
2293
|
+
if (!requestOptions.target && !requestOptions.forward) {
|
|
2294
|
+
return this.emit(
|
|
2295
|
+
"error",
|
|
2296
|
+
new Error("Must provide a proper URL as target"),
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2299
|
+
for (var i = 0; i < passes.length; i++) {
|
|
2300
|
+
if (passes[i](req, res, requestOptions, head, this, cbl)) {
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
1917
2305
|
};
|
|
1918
2306
|
}
|
|
1919
|
-
|
|
1920
|
-
function
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
break;
|
|
1935
|
-
}
|
|
1936
|
-
if (decompress) {
|
|
1937
|
-
_proxyRes.pipe(decompress);
|
|
1938
|
-
_proxyRes = decompress;
|
|
1939
|
-
}
|
|
1940
|
-
return _proxyRes;
|
|
2307
|
+
httpProxy.createRightProxy = createRightProxy;
|
|
2308
|
+
function ProxyServer(options) {
|
|
2309
|
+
EE3.call(this);
|
|
2310
|
+
options = options || {};
|
|
2311
|
+
options.prependPath = options.prependPath === false ? false : true;
|
|
2312
|
+
this.web = this.proxyRequest = createRightProxy("web")(options);
|
|
2313
|
+
this.ws = this.proxyWebsocketRequest = createRightProxy("ws")(options);
|
|
2314
|
+
this.options = options;
|
|
2315
|
+
this.webPasses = Object.keys(web).map(function (pass) {
|
|
2316
|
+
return web[pass];
|
|
2317
|
+
});
|
|
2318
|
+
this.wsPasses = Object.keys(ws).map(function (pass) {
|
|
2319
|
+
return ws[pass];
|
|
2320
|
+
});
|
|
2321
|
+
this.on("error", this.onError, this);
|
|
1941
2322
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
let keys = Object.keys(originalResponse.headers);
|
|
1947
|
-
keys = keys.filter(
|
|
1948
|
-
(key) => !["content-encoding", "transfer-encoding"].includes(key),
|
|
1949
|
-
);
|
|
1950
|
-
keys.forEach((key) => {
|
|
1951
|
-
let value = originalResponse.headers[key];
|
|
1952
|
-
if (key === "set-cookie") {
|
|
1953
|
-
value = Array.isArray(value) ? value : [value];
|
|
1954
|
-
value = value.map((x) => x.replace(/Domain=[^;]+?/i, ""));
|
|
1955
|
-
}
|
|
1956
|
-
response.setHeader(key, value);
|
|
1957
|
-
});
|
|
1958
|
-
} else {
|
|
1959
|
-
response.headers = originalResponse.headers;
|
|
2323
|
+
__nccwpck_require__(9023).inherits(ProxyServer, EE3);
|
|
2324
|
+
ProxyServer.prototype.onError = function (err) {
|
|
2325
|
+
if (this.listeners("error").length === 1) {
|
|
2326
|
+
throw err;
|
|
1960
2327
|
}
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
exports.HttpProxyMiddleware = void 0;
|
|
1967
|
-
const httpProxy = __nccwpck_require__(4484);
|
|
1968
|
-
const config_factory_1 = __nccwpck_require__(2304);
|
|
1969
|
-
const contextMatcher = __nccwpck_require__(1345);
|
|
1970
|
-
const handlers = __nccwpck_require__(501);
|
|
1971
|
-
const logger_1 = __nccwpck_require__(8045);
|
|
1972
|
-
const PathRewriter = __nccwpck_require__(6241);
|
|
1973
|
-
const Router = __nccwpck_require__(604);
|
|
1974
|
-
class HttpProxyMiddleware {
|
|
1975
|
-
constructor(context, opts) {
|
|
1976
|
-
this.logger = (0, logger_1.getInstance)();
|
|
1977
|
-
this.wsInternalSubscribed = false;
|
|
1978
|
-
this.serverOnCloseSubscribed = false;
|
|
1979
|
-
this.middleware = async (req, res, next) => {
|
|
1980
|
-
var _a, _b;
|
|
1981
|
-
if (this.shouldProxy(this.config.context, req)) {
|
|
1982
|
-
try {
|
|
1983
|
-
const activeProxyOptions = await this.prepareProxyRequest(req);
|
|
1984
|
-
this.proxy.web(req, res, activeProxyOptions);
|
|
1985
|
-
} catch (err) {
|
|
1986
|
-
next(err);
|
|
1987
|
-
}
|
|
1988
|
-
} else {
|
|
1989
|
-
next();
|
|
1990
|
-
}
|
|
1991
|
-
const server =
|
|
1992
|
-
(_b =
|
|
1993
|
-
(_a = req.socket) !== null && _a !== void 0
|
|
1994
|
-
? _a
|
|
1995
|
-
: req.connection) === null || _b === void 0
|
|
1996
|
-
? void 0
|
|
1997
|
-
: _b.server;
|
|
1998
|
-
if (server && !this.serverOnCloseSubscribed) {
|
|
1999
|
-
server.on("close", () => {
|
|
2000
|
-
this.logger.info(
|
|
2001
|
-
"[HPM] server close signal received: closing proxy server",
|
|
2002
|
-
);
|
|
2003
|
-
this.proxy.close();
|
|
2004
|
-
});
|
|
2005
|
-
this.serverOnCloseSubscribed = true;
|
|
2006
|
-
}
|
|
2007
|
-
if (this.proxyOptions.ws === true) {
|
|
2008
|
-
this.catchUpgradeRequest(server);
|
|
2009
|
-
}
|
|
2010
|
-
};
|
|
2011
|
-
this.catchUpgradeRequest = (server) => {
|
|
2012
|
-
if (!this.wsInternalSubscribed) {
|
|
2013
|
-
server.on("upgrade", this.handleUpgrade);
|
|
2014
|
-
this.wsInternalSubscribed = true;
|
|
2015
|
-
}
|
|
2016
|
-
};
|
|
2017
|
-
this.handleUpgrade = async (req, socket, head) => {
|
|
2018
|
-
if (this.shouldProxy(this.config.context, req)) {
|
|
2019
|
-
const activeProxyOptions = await this.prepareProxyRequest(req);
|
|
2020
|
-
this.proxy.ws(req, socket, head, activeProxyOptions);
|
|
2021
|
-
this.logger.info("[HPM] Upgrading to WebSocket");
|
|
2022
|
-
}
|
|
2023
|
-
};
|
|
2024
|
-
this.shouldProxy = (context, req) => {
|
|
2025
|
-
try {
|
|
2026
|
-
const path = req.originalUrl || req.url;
|
|
2027
|
-
return contextMatcher.match(context, path, req);
|
|
2028
|
-
} catch (error) {
|
|
2029
|
-
this.logger.error(error);
|
|
2030
|
-
return false;
|
|
2031
|
-
}
|
|
2032
|
-
};
|
|
2033
|
-
this.prepareProxyRequest = async (req) => {
|
|
2034
|
-
req.url = req.originalUrl || req.url;
|
|
2035
|
-
const originalPath = req.url;
|
|
2036
|
-
const newProxyOptions = Object.assign({}, this.proxyOptions);
|
|
2037
|
-
await this.applyRouter(req, newProxyOptions);
|
|
2038
|
-
await this.applyPathRewrite(req, this.pathRewriter);
|
|
2039
|
-
if (this.proxyOptions.logLevel === "debug") {
|
|
2040
|
-
const arrow = (0, logger_1.getArrow)(
|
|
2041
|
-
originalPath,
|
|
2042
|
-
req.url,
|
|
2043
|
-
this.proxyOptions.target,
|
|
2044
|
-
newProxyOptions.target,
|
|
2045
|
-
);
|
|
2046
|
-
this.logger.debug(
|
|
2047
|
-
"[HPM] %s %s %s %s",
|
|
2048
|
-
req.method,
|
|
2049
|
-
originalPath,
|
|
2050
|
-
arrow,
|
|
2051
|
-
newProxyOptions.target,
|
|
2052
|
-
);
|
|
2053
|
-
}
|
|
2054
|
-
return newProxyOptions;
|
|
2055
|
-
};
|
|
2056
|
-
this.applyRouter = async (req, options) => {
|
|
2057
|
-
let newTarget;
|
|
2058
|
-
if (options.router) {
|
|
2059
|
-
newTarget = await Router.getTarget(req, options);
|
|
2060
|
-
if (newTarget) {
|
|
2061
|
-
this.logger.debug(
|
|
2062
|
-
'[HPM] Router new target: %s -> "%s"',
|
|
2063
|
-
options.target,
|
|
2064
|
-
newTarget,
|
|
2065
|
-
);
|
|
2066
|
-
options.target = newTarget;
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
this.applyPathRewrite = async (req, pathRewriter) => {
|
|
2071
|
-
if (pathRewriter) {
|
|
2072
|
-
const path = await pathRewriter(req.url, req);
|
|
2073
|
-
if (typeof path === "string") {
|
|
2074
|
-
req.url = path;
|
|
2075
|
-
} else {
|
|
2076
|
-
this.logger.info(
|
|
2077
|
-
"[HPM] pathRewrite: No rewritten path found. (%s)",
|
|
2078
|
-
req.url,
|
|
2079
|
-
);
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
};
|
|
2083
|
-
this.logError = (err, req, res, target) => {
|
|
2084
|
-
var _a;
|
|
2085
|
-
const hostname =
|
|
2086
|
-
((_a = req.headers) === null || _a === void 0
|
|
2087
|
-
? void 0
|
|
2088
|
-
: _a.host) ||
|
|
2089
|
-
req.hostname ||
|
|
2090
|
-
req.host;
|
|
2091
|
-
const requestHref = `${hostname}${req.url}`;
|
|
2092
|
-
const targetHref = `${target === null || target === void 0 ? void 0 : target.href}`;
|
|
2093
|
-
const errorMessage =
|
|
2094
|
-
"[HPM] Error occurred while proxying request %s to %s [%s] (%s)";
|
|
2095
|
-
const errReference =
|
|
2096
|
-
"https://nodejs.org/api/errors.html#errors_common_system_errors";
|
|
2097
|
-
this.logger.error(
|
|
2098
|
-
errorMessage,
|
|
2099
|
-
requestHref,
|
|
2100
|
-
targetHref,
|
|
2101
|
-
err.code || err,
|
|
2102
|
-
errReference,
|
|
2103
|
-
);
|
|
2104
|
-
};
|
|
2105
|
-
this.config = (0, config_factory_1.createConfig)(context, opts);
|
|
2106
|
-
this.proxyOptions = this.config.options;
|
|
2107
|
-
this.proxy = httpProxy.createProxyServer({});
|
|
2108
|
-
this.logger.info(
|
|
2109
|
-
`[HPM] Proxy created: ${this.config.context} -> ${this.proxyOptions.target}`,
|
|
2110
|
-
);
|
|
2111
|
-
this.pathRewriter = PathRewriter.createPathRewriter(
|
|
2112
|
-
this.proxyOptions.pathRewrite,
|
|
2113
|
-
);
|
|
2114
|
-
handlers.init(this.proxy, this.proxyOptions);
|
|
2115
|
-
this.proxy.on("error", this.logError);
|
|
2116
|
-
this.middleware.upgrade = (req, socket, head) => {
|
|
2117
|
-
if (!this.wsInternalSubscribed) {
|
|
2118
|
-
this.handleUpgrade(req, socket, head);
|
|
2119
|
-
}
|
|
2328
|
+
};
|
|
2329
|
+
ProxyServer.prototype.listen = function (port, hostname) {
|
|
2330
|
+
var self = this,
|
|
2331
|
+
closure = function (req, res) {
|
|
2332
|
+
self.web(req, res);
|
|
2120
2333
|
};
|
|
2334
|
+
this._server = this.options.ssl
|
|
2335
|
+
? https.createServer(this.options.ssl, closure)
|
|
2336
|
+
: http.createServer(closure);
|
|
2337
|
+
if (this.options.ws) {
|
|
2338
|
+
this._server.on("upgrade", function (req, socket, head) {
|
|
2339
|
+
self.ws(req, socket, head);
|
|
2340
|
+
});
|
|
2121
2341
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
},
|
|
2125
|
-
7861: function (__unused_webpack_module, exports, __nccwpck_require__) {
|
|
2126
|
-
"use strict";
|
|
2127
|
-
var __createBinding =
|
|
2128
|
-
(this && this.__createBinding) ||
|
|
2129
|
-
(Object.create
|
|
2130
|
-
? function (o, m, k, k2) {
|
|
2131
|
-
if (k2 === undefined) k2 = k;
|
|
2132
|
-
Object.defineProperty(o, k2, {
|
|
2133
|
-
enumerable: true,
|
|
2134
|
-
get: function () {
|
|
2135
|
-
return m[k];
|
|
2136
|
-
},
|
|
2137
|
-
});
|
|
2138
|
-
}
|
|
2139
|
-
: function (o, m, k, k2) {
|
|
2140
|
-
if (k2 === undefined) k2 = k;
|
|
2141
|
-
o[k2] = m[k];
|
|
2142
|
-
});
|
|
2143
|
-
var __exportStar =
|
|
2144
|
-
(this && this.__exportStar) ||
|
|
2145
|
-
function (m, exports) {
|
|
2146
|
-
for (var p in m)
|
|
2147
|
-
if (
|
|
2148
|
-
p !== "default" &&
|
|
2149
|
-
!Object.prototype.hasOwnProperty.call(exports, p)
|
|
2150
|
-
)
|
|
2151
|
-
__createBinding(exports, m, p);
|
|
2152
|
-
};
|
|
2153
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2154
|
-
exports.createProxyMiddleware = void 0;
|
|
2155
|
-
const http_proxy_middleware_1 = __nccwpck_require__(6953);
|
|
2156
|
-
function createProxyMiddleware(context, options) {
|
|
2157
|
-
const { middleware } = new http_proxy_middleware_1.HttpProxyMiddleware(
|
|
2158
|
-
context,
|
|
2159
|
-
options,
|
|
2160
|
-
);
|
|
2161
|
-
return middleware;
|
|
2162
|
-
}
|
|
2163
|
-
exports.createProxyMiddleware = createProxyMiddleware;
|
|
2164
|
-
__exportStar(__nccwpck_require__(5611), exports);
|
|
2165
|
-
},
|
|
2166
|
-
8045: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2167
|
-
"use strict";
|
|
2168
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2169
|
-
exports.getArrow = exports.getInstance = void 0;
|
|
2170
|
-
const util = __nccwpck_require__(9023);
|
|
2171
|
-
let loggerInstance;
|
|
2172
|
-
const defaultProvider = {
|
|
2173
|
-
log: console.log,
|
|
2174
|
-
debug: console.log,
|
|
2175
|
-
info: console.info,
|
|
2176
|
-
warn: console.warn,
|
|
2177
|
-
error: console.error,
|
|
2342
|
+
this._server.listen(port, hostname);
|
|
2343
|
+
return this;
|
|
2178
2344
|
};
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
LEVELS[(LEVELS["warn"] = 30)] = "warn";
|
|
2184
|
-
LEVELS[(LEVELS["error"] = 50)] = "error";
|
|
2185
|
-
LEVELS[(LEVELS["silent"] = 80)] = "silent";
|
|
2186
|
-
})(LEVELS || (LEVELS = {}));
|
|
2187
|
-
function getInstance() {
|
|
2188
|
-
if (!loggerInstance) {
|
|
2189
|
-
loggerInstance = new Logger();
|
|
2190
|
-
}
|
|
2191
|
-
return loggerInstance;
|
|
2192
|
-
}
|
|
2193
|
-
exports.getInstance = getInstance;
|
|
2194
|
-
class Logger {
|
|
2195
|
-
constructor() {
|
|
2196
|
-
this.setLevel("info");
|
|
2197
|
-
this.setProvider(() => defaultProvider);
|
|
2198
|
-
}
|
|
2199
|
-
log() {
|
|
2200
|
-
this.provider.log(this._interpolate.apply(null, arguments));
|
|
2201
|
-
}
|
|
2202
|
-
debug() {
|
|
2203
|
-
if (this._showLevel("debug")) {
|
|
2204
|
-
this.provider.debug(this._interpolate.apply(null, arguments));
|
|
2205
|
-
}
|
|
2345
|
+
ProxyServer.prototype.close = function (callback) {
|
|
2346
|
+
var self = this;
|
|
2347
|
+
if (this._server) {
|
|
2348
|
+
this._server.close(done);
|
|
2206
2349
|
}
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2350
|
+
function done() {
|
|
2351
|
+
self._server = null;
|
|
2352
|
+
if (callback) {
|
|
2353
|
+
callback.apply(null, arguments);
|
|
2210
2354
|
}
|
|
2211
2355
|
}
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2356
|
+
};
|
|
2357
|
+
ProxyServer.prototype.before = function (type, passName, callback) {
|
|
2358
|
+
if (type !== "ws" && type !== "web") {
|
|
2359
|
+
throw new Error("type must be `web` or `ws`");
|
|
2216
2360
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2361
|
+
var passes = type === "ws" ? this.wsPasses : this.webPasses,
|
|
2362
|
+
i = false;
|
|
2363
|
+
passes.forEach(function (v, idx) {
|
|
2364
|
+
if (v.name === passName) i = idx;
|
|
2365
|
+
});
|
|
2366
|
+
if (i === false) throw new Error("No such pass");
|
|
2367
|
+
passes.splice(i, 0, callback);
|
|
2368
|
+
};
|
|
2369
|
+
ProxyServer.prototype.after = function (type, passName, callback) {
|
|
2370
|
+
if (type !== "ws" && type !== "web") {
|
|
2371
|
+
throw new Error("type must be `web` or `ws`");
|
|
2221
2372
|
}
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2373
|
+
var passes = type === "ws" ? this.wsPasses : this.webPasses,
|
|
2374
|
+
i = false;
|
|
2375
|
+
passes.forEach(function (v, idx) {
|
|
2376
|
+
if (v.name === passName) i = idx;
|
|
2377
|
+
});
|
|
2378
|
+
if (i === false) throw new Error("No such pass");
|
|
2379
|
+
passes.splice(i++, 0, callback);
|
|
2380
|
+
};
|
|
2381
|
+
},
|
|
2382
|
+
7640: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2383
|
+
var httpNative = __nccwpck_require__(8611),
|
|
2384
|
+
httpsNative = __nccwpck_require__(5692),
|
|
2385
|
+
web_o = __nccwpck_require__(382),
|
|
2386
|
+
common = __nccwpck_require__(6758),
|
|
2387
|
+
followRedirects = __nccwpck_require__(8977);
|
|
2388
|
+
web_o = Object.keys(web_o).map(function (pass) {
|
|
2389
|
+
return web_o[pass];
|
|
2390
|
+
});
|
|
2391
|
+
var nativeAgents = { http: httpNative, https: httpsNative };
|
|
2392
|
+
/*!
|
|
2393
|
+
* Array of passes.
|
|
2394
|
+
*
|
|
2395
|
+
* A `pass` is just a function that is executed on `req, res, options`
|
|
2396
|
+
* so that you can easily add new checks while still keeping the base
|
|
2397
|
+
* flexible.
|
|
2398
|
+
*/ module.exports = {
|
|
2399
|
+
deleteLength: function deleteLength(req, res, options) {
|
|
2400
|
+
if (
|
|
2401
|
+
(req.method === "DELETE" || req.method === "OPTIONS") &&
|
|
2402
|
+
!req.headers["content-length"]
|
|
2403
|
+
) {
|
|
2404
|
+
req.headers["content-length"] = "0";
|
|
2405
|
+
delete req.headers["transfer-encoding"];
|
|
2225
2406
|
}
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
if (
|
|
2229
|
-
|
|
2407
|
+
},
|
|
2408
|
+
timeout: function timeout(req, res, options) {
|
|
2409
|
+
if (options.timeout) {
|
|
2410
|
+
req.socket.setTimeout(options.timeout);
|
|
2230
2411
|
}
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2412
|
+
},
|
|
2413
|
+
XHeaders: function XHeaders(req, res, options) {
|
|
2414
|
+
if (!options.xfwd) return;
|
|
2415
|
+
var encrypted = req.isSpdy || common.hasEncryptedConnection(req);
|
|
2416
|
+
var values = {
|
|
2417
|
+
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
2418
|
+
port: common.getPort(req),
|
|
2419
|
+
proto: encrypted ? "https" : "http",
|
|
2420
|
+
};
|
|
2421
|
+
["for", "port", "proto"].forEach(function (header) {
|
|
2422
|
+
req.headers["x-forwarded-" + header] =
|
|
2423
|
+
(req.headers["x-forwarded-" + header] || "") +
|
|
2424
|
+
(req.headers["x-forwarded-" + header] ? "," : "") +
|
|
2425
|
+
values[header];
|
|
2426
|
+
});
|
|
2427
|
+
req.headers["x-forwarded-host"] =
|
|
2428
|
+
req.headers["x-forwarded-host"] || req.headers["host"] || "";
|
|
2429
|
+
},
|
|
2430
|
+
stream: function stream(req, res, options, _, server, clb) {
|
|
2431
|
+
server.emit("start", req, res, options.target || options.forward);
|
|
2432
|
+
var agents = options.followRedirects ? followRedirects : nativeAgents;
|
|
2433
|
+
var http = agents.http;
|
|
2434
|
+
var https = agents.https;
|
|
2435
|
+
if (options.forward) {
|
|
2436
|
+
var forwardReq = (
|
|
2437
|
+
options.forward.protocol === "https:" ? https : http
|
|
2438
|
+
).request(
|
|
2439
|
+
common.setupOutgoing(options.ssl || {}, options, req, "forward"),
|
|
2237
2440
|
);
|
|
2441
|
+
var forwardError = createErrorHandler(forwardReq, options.forward);
|
|
2442
|
+
req.on("error", forwardError);
|
|
2443
|
+
forwardReq.on("error", forwardError);
|
|
2444
|
+
(options.buffer || req).pipe(forwardReq);
|
|
2445
|
+
if (!options.target) {
|
|
2446
|
+
return res.end();
|
|
2447
|
+
}
|
|
2238
2448
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
throw new Error("[HPM] Log level error. Invalid logLevel.");
|
|
2246
|
-
}
|
|
2247
|
-
return isValid;
|
|
2248
|
-
}
|
|
2249
|
-
_showLevel(showLevel) {
|
|
2250
|
-
let result = false;
|
|
2251
|
-
const currentLogLevel = LEVELS[this.logLevel];
|
|
2252
|
-
if (currentLogLevel && currentLogLevel <= LEVELS[showLevel]) {
|
|
2253
|
-
result = true;
|
|
2254
|
-
}
|
|
2255
|
-
return result;
|
|
2256
|
-
}
|
|
2257
|
-
_interpolate(format, ...args) {
|
|
2258
|
-
const result = util.format(format, ...args);
|
|
2259
|
-
return result;
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
function getArrow(originalPath, newPath, originalTarget, newTarget) {
|
|
2263
|
-
const arrow = [">"];
|
|
2264
|
-
const isNewTarget = originalTarget !== newTarget;
|
|
2265
|
-
const isNewPath = originalPath !== newPath;
|
|
2266
|
-
if (isNewPath && !isNewTarget) {
|
|
2267
|
-
arrow.unshift("~");
|
|
2268
|
-
} else if (!isNewPath && isNewTarget) {
|
|
2269
|
-
arrow.unshift("=");
|
|
2270
|
-
} else if (isNewPath && isNewTarget) {
|
|
2271
|
-
arrow.unshift("≈");
|
|
2272
|
-
} else {
|
|
2273
|
-
arrow.unshift("-");
|
|
2274
|
-
}
|
|
2275
|
-
return arrow.join("");
|
|
2276
|
-
}
|
|
2277
|
-
exports.getArrow = getArrow;
|
|
2278
|
-
},
|
|
2279
|
-
6241: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2280
|
-
"use strict";
|
|
2281
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2282
|
-
exports.createPathRewriter = void 0;
|
|
2283
|
-
const isPlainObj = __nccwpck_require__(3458);
|
|
2284
|
-
const errors_1 = __nccwpck_require__(4618);
|
|
2285
|
-
const logger_1 = __nccwpck_require__(8045);
|
|
2286
|
-
const logger = (0, logger_1.getInstance)();
|
|
2287
|
-
function createPathRewriter(rewriteConfig) {
|
|
2288
|
-
let rulesCache;
|
|
2289
|
-
if (!isValidRewriteConfig(rewriteConfig)) {
|
|
2290
|
-
return;
|
|
2291
|
-
}
|
|
2292
|
-
if (typeof rewriteConfig === "function") {
|
|
2293
|
-
const customRewriteFn = rewriteConfig;
|
|
2294
|
-
return customRewriteFn;
|
|
2295
|
-
} else {
|
|
2296
|
-
rulesCache = parsePathRewriteRules(rewriteConfig);
|
|
2297
|
-
return rewritePath;
|
|
2298
|
-
}
|
|
2299
|
-
function rewritePath(path) {
|
|
2300
|
-
let result = path;
|
|
2301
|
-
for (const rule of rulesCache) {
|
|
2302
|
-
if (rule.regex.test(path)) {
|
|
2303
|
-
result = result.replace(rule.regex, rule.value);
|
|
2304
|
-
logger.debug(
|
|
2305
|
-
'[HPM] Rewriting path from "%s" to "%s"',
|
|
2306
|
-
path,
|
|
2307
|
-
result,
|
|
2308
|
-
);
|
|
2309
|
-
break;
|
|
2449
|
+
var proxyReq = (
|
|
2450
|
+
options.target.protocol === "https:" ? https : http
|
|
2451
|
+
).request(common.setupOutgoing(options.ssl || {}, options, req));
|
|
2452
|
+
proxyReq.on("socket", function (socket) {
|
|
2453
|
+
if (server && !proxyReq.getHeader("expect")) {
|
|
2454
|
+
server.emit("proxyReq", proxyReq, req, res, options);
|
|
2310
2455
|
}
|
|
2456
|
+
});
|
|
2457
|
+
if (options.proxyTimeout) {
|
|
2458
|
+
proxyReq.setTimeout(options.proxyTimeout, function () {
|
|
2459
|
+
proxyReq.abort();
|
|
2460
|
+
});
|
|
2311
2461
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
for (const [key] of Object.entries(rewriteConfig)) {
|
|
2331
|
-
rules.push({ regex: new RegExp(key), value: rewriteConfig[key] });
|
|
2332
|
-
logger.info(
|
|
2333
|
-
'[HPM] Proxy rewrite rule created: "%s" ~> "%s"',
|
|
2334
|
-
key,
|
|
2335
|
-
rewriteConfig[key],
|
|
2336
|
-
);
|
|
2462
|
+
req.on("aborted", function () {
|
|
2463
|
+
proxyReq.abort();
|
|
2464
|
+
});
|
|
2465
|
+
var proxyError = createErrorHandler(proxyReq, options.target);
|
|
2466
|
+
req.on("error", proxyError);
|
|
2467
|
+
proxyReq.on("error", proxyError);
|
|
2468
|
+
function createErrorHandler(proxyReq, url) {
|
|
2469
|
+
return function proxyError(err) {
|
|
2470
|
+
if (req.socket.destroyed && err.code === "ECONNRESET") {
|
|
2471
|
+
server.emit("econnreset", err, req, res, url);
|
|
2472
|
+
return proxyReq.abort();
|
|
2473
|
+
}
|
|
2474
|
+
if (clb) {
|
|
2475
|
+
clb(err, req, res, url);
|
|
2476
|
+
} else {
|
|
2477
|
+
server.emit("error", err, req, res, url);
|
|
2478
|
+
}
|
|
2479
|
+
};
|
|
2337
2480
|
}
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
604: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2343
|
-
"use strict";
|
|
2344
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2345
|
-
exports.getTarget = void 0;
|
|
2346
|
-
const isPlainObj = __nccwpck_require__(3458);
|
|
2347
|
-
const logger_1 = __nccwpck_require__(8045);
|
|
2348
|
-
const logger = (0, logger_1.getInstance)();
|
|
2349
|
-
async function getTarget(req, config) {
|
|
2350
|
-
let newTarget;
|
|
2351
|
-
const router = config.router;
|
|
2352
|
-
if (isPlainObj(router)) {
|
|
2353
|
-
newTarget = getTargetFromProxyTable(req, router);
|
|
2354
|
-
} else if (typeof router === "function") {
|
|
2355
|
-
newTarget = await router(req);
|
|
2356
|
-
}
|
|
2357
|
-
return newTarget;
|
|
2358
|
-
}
|
|
2359
|
-
exports.getTarget = getTarget;
|
|
2360
|
-
function getTargetFromProxyTable(req, table) {
|
|
2361
|
-
let result;
|
|
2362
|
-
const host = req.headers.host;
|
|
2363
|
-
const path = req.url;
|
|
2364
|
-
const hostAndPath = host + path;
|
|
2365
|
-
for (const [key] of Object.entries(table)) {
|
|
2366
|
-
if (containsPath(key)) {
|
|
2367
|
-
if (hostAndPath.indexOf(key) > -1) {
|
|
2368
|
-
result = table[key];
|
|
2369
|
-
logger.debug('[HPM] Router table match: "%s"', key);
|
|
2370
|
-
break;
|
|
2481
|
+
(options.buffer || req).pipe(proxyReq);
|
|
2482
|
+
proxyReq.on("response", function (proxyRes) {
|
|
2483
|
+
if (server) {
|
|
2484
|
+
server.emit("proxyRes", proxyRes, req, res);
|
|
2371
2485
|
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2486
|
+
if (!res.headersSent && !options.selfHandleResponse) {
|
|
2487
|
+
for (var i = 0; i < web_o.length; i++) {
|
|
2488
|
+
if (web_o[i](req, res, proxyRes, options)) {
|
|
2489
|
+
break;
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2377
2492
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2493
|
+
if (!res.finished) {
|
|
2494
|
+
proxyRes.on("end", function () {
|
|
2495
|
+
if (server) server.emit("end", req, res, proxyRes);
|
|
2496
|
+
});
|
|
2497
|
+
if (!options.selfHandleResponse) proxyRes.pipe(res);
|
|
2498
|
+
} else {
|
|
2499
|
+
if (server) server.emit("end", req, res, proxyRes);
|
|
2500
|
+
}
|
|
2501
|
+
});
|
|
2502
|
+
},
|
|
2503
|
+
};
|
|
2385
2504
|
},
|
|
2386
|
-
|
|
2505
|
+
382: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2506
|
+
var url = __nccwpck_require__(7016),
|
|
2507
|
+
common = __nccwpck_require__(6758);
|
|
2508
|
+
var redirectRegex = /^201|30(1|2|7|8)$/;
|
|
2387
2509
|
/*!
|
|
2388
|
-
*
|
|
2389
|
-
* loro accennando, tutte le raccoglie;
|
|
2390
|
-
* batte col remo qualunque s’adagia
|
|
2391
|
-
*
|
|
2392
|
-
* Charon the demon, with the eyes of glede,
|
|
2393
|
-
* Beckoning to them, collects them all together,
|
|
2394
|
-
* Beats with his oar whoever lags behind
|
|
2510
|
+
* Array of passes.
|
|
2395
2511
|
*
|
|
2396
|
-
*
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
"host",
|
|
2423
|
-
"hostname",
|
|
2424
|
-
"socketPath",
|
|
2425
|
-
"pfx",
|
|
2426
|
-
"key",
|
|
2427
|
-
"passphrase",
|
|
2428
|
-
"cert",
|
|
2429
|
-
"ca",
|
|
2430
|
-
"ciphers",
|
|
2431
|
-
"secureProtocol",
|
|
2432
|
-
].forEach(function (e) {
|
|
2433
|
-
outgoing[e] = options[forward || "target"][e];
|
|
2434
|
-
});
|
|
2435
|
-
outgoing.method = options.method || req.method;
|
|
2436
|
-
outgoing.headers = Object.assign({}, req.headers);
|
|
2437
|
-
if (options.headers) {
|
|
2438
|
-
Object.assign(outgoing.headers, options.headers);
|
|
2439
|
-
}
|
|
2440
|
-
if (options.auth) {
|
|
2441
|
-
outgoing.auth = options.auth;
|
|
2442
|
-
}
|
|
2443
|
-
if (options.ca) {
|
|
2444
|
-
outgoing.ca = options.ca;
|
|
2445
|
-
}
|
|
2446
|
-
if (isSSL.test(options[forward || "target"].protocol)) {
|
|
2447
|
-
outgoing.rejectUnauthorized =
|
|
2448
|
-
typeof options.secure === "undefined" ? true : options.secure;
|
|
2449
|
-
}
|
|
2450
|
-
outgoing.agent = options.agent || false;
|
|
2451
|
-
outgoing.localAddress = options.localAddress;
|
|
2452
|
-
if (!outgoing.agent) {
|
|
2453
|
-
outgoing.headers = outgoing.headers || {};
|
|
2512
|
+
* A `pass` is just a function that is executed on `req, res, options`
|
|
2513
|
+
* so that you can easily add new checks while still keeping the base
|
|
2514
|
+
* flexible.
|
|
2515
|
+
*/ module.exports = {
|
|
2516
|
+
removeChunked: function removeChunked(req, res, proxyRes) {
|
|
2517
|
+
if (req.httpVersion === "1.0") {
|
|
2518
|
+
delete proxyRes.headers["transfer-encoding"];
|
|
2519
|
+
}
|
|
2520
|
+
},
|
|
2521
|
+
setConnection: function setConnection(req, res, proxyRes) {
|
|
2522
|
+
if (req.httpVersion === "1.0") {
|
|
2523
|
+
proxyRes.headers.connection = req.headers.connection || "close";
|
|
2524
|
+
} else if (
|
|
2525
|
+
req.httpVersion !== "2.0" &&
|
|
2526
|
+
!proxyRes.headers.connection
|
|
2527
|
+
) {
|
|
2528
|
+
proxyRes.headers.connection =
|
|
2529
|
+
req.headers.connection || "keep-alive";
|
|
2530
|
+
}
|
|
2531
|
+
},
|
|
2532
|
+
setRedirectHostRewrite: function setRedirectHostRewrite(
|
|
2533
|
+
req,
|
|
2534
|
+
res,
|
|
2535
|
+
proxyRes,
|
|
2536
|
+
options,
|
|
2537
|
+
) {
|
|
2454
2538
|
if (
|
|
2455
|
-
|
|
2456
|
-
|
|
2539
|
+
(options.hostRewrite ||
|
|
2540
|
+
options.autoRewrite ||
|
|
2541
|
+
options.protocolRewrite) &&
|
|
2542
|
+
proxyRes.headers["location"] &&
|
|
2543
|
+
redirectRegex.test(proxyRes.statusCode)
|
|
2457
2544
|
) {
|
|
2458
|
-
|
|
2545
|
+
var target = url.parse(options.target);
|
|
2546
|
+
var u = url.parse(proxyRes.headers["location"]);
|
|
2547
|
+
if (target.host != u.host) {
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
if (options.hostRewrite) {
|
|
2551
|
+
u.host = options.hostRewrite;
|
|
2552
|
+
} else if (options.autoRewrite) {
|
|
2553
|
+
u.host = req.headers["host"];
|
|
2554
|
+
}
|
|
2555
|
+
if (options.protocolRewrite) {
|
|
2556
|
+
u.protocol = options.protocolRewrite;
|
|
2557
|
+
}
|
|
2558
|
+
proxyRes.headers["location"] = u.format();
|
|
2459
2559
|
}
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
};
|
|
2488
|
-
common.hasEncryptedConnection = function (req) {
|
|
2489
|
-
return Boolean(req.connection.encrypted || req.connection.pair);
|
|
2490
|
-
};
|
|
2491
|
-
common.urlJoin = function () {
|
|
2492
|
-
var args = Array.prototype.slice.call(arguments),
|
|
2493
|
-
lastIndex = args.length - 1,
|
|
2494
|
-
last = args[lastIndex],
|
|
2495
|
-
lastSegs = last.split("?"),
|
|
2496
|
-
retSegs;
|
|
2497
|
-
args[lastIndex] = lastSegs.shift();
|
|
2498
|
-
retSegs = [
|
|
2499
|
-
args
|
|
2500
|
-
.filter(Boolean)
|
|
2501
|
-
.join("/")
|
|
2502
|
-
.replace(/\/+/g, "/")
|
|
2503
|
-
.replace("http:/", "http://")
|
|
2504
|
-
.replace("https:/", "https://"),
|
|
2505
|
-
];
|
|
2506
|
-
retSegs.push.apply(retSegs, lastSegs);
|
|
2507
|
-
return retSegs.join("?");
|
|
2508
|
-
};
|
|
2509
|
-
common.rewriteCookieProperty = function rewriteCookieProperty(
|
|
2510
|
-
header,
|
|
2511
|
-
config,
|
|
2512
|
-
property,
|
|
2513
|
-
) {
|
|
2514
|
-
if (Array.isArray(header)) {
|
|
2515
|
-
return header.map(function (headerElement) {
|
|
2516
|
-
return rewriteCookieProperty(headerElement, config, property);
|
|
2517
|
-
});
|
|
2518
|
-
}
|
|
2519
|
-
return header.replace(
|
|
2520
|
-
new RegExp("(;\\s*" + property + "=)([^;]+)", "i"),
|
|
2521
|
-
function (match, prefix, previousValue) {
|
|
2522
|
-
var newValue;
|
|
2523
|
-
if (previousValue in config) {
|
|
2524
|
-
newValue = config[previousValue];
|
|
2525
|
-
} else if ("*" in config) {
|
|
2526
|
-
newValue = config["*"];
|
|
2527
|
-
} else {
|
|
2528
|
-
return match;
|
|
2529
|
-
}
|
|
2530
|
-
if (newValue) {
|
|
2531
|
-
return prefix + newValue;
|
|
2532
|
-
} else {
|
|
2533
|
-
return "";
|
|
2534
|
-
}
|
|
2535
|
-
},
|
|
2536
|
-
);
|
|
2537
|
-
};
|
|
2538
|
-
function hasPort(host) {
|
|
2539
|
-
return !!~host.indexOf(":");
|
|
2540
|
-
}
|
|
2541
|
-
},
|
|
2542
|
-
1152: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2543
|
-
var httpProxy = module.exports,
|
|
2544
|
-
parse_url = __nccwpck_require__(7016).parse,
|
|
2545
|
-
EE3 = __nccwpck_require__(6234),
|
|
2546
|
-
http = __nccwpck_require__(8611),
|
|
2547
|
-
https = __nccwpck_require__(5692),
|
|
2548
|
-
web = __nccwpck_require__(9043),
|
|
2549
|
-
ws = __nccwpck_require__(2725);
|
|
2550
|
-
httpProxy.Server = ProxyServer;
|
|
2551
|
-
function createRightProxy(type) {
|
|
2552
|
-
return function (options) {
|
|
2553
|
-
return function (req, res) {
|
|
2554
|
-
var passes = type === "ws" ? this.wsPasses : this.webPasses,
|
|
2555
|
-
args = [].slice.call(arguments),
|
|
2556
|
-
cntr = args.length - 1,
|
|
2557
|
-
head,
|
|
2558
|
-
cbl;
|
|
2559
|
-
if (typeof args[cntr] === "function") {
|
|
2560
|
-
cbl = args[cntr];
|
|
2561
|
-
cntr--;
|
|
2562
|
-
}
|
|
2563
|
-
var requestOptions = options;
|
|
2564
|
-
if (!(args[cntr] instanceof Buffer) && args[cntr] !== res) {
|
|
2565
|
-
requestOptions = Object.assign({}, options);
|
|
2566
|
-
Object.assign(requestOptions, args[cntr]);
|
|
2567
|
-
cntr--;
|
|
2568
|
-
}
|
|
2569
|
-
if (args[cntr] instanceof Buffer) {
|
|
2570
|
-
head = args[cntr];
|
|
2571
|
-
}
|
|
2572
|
-
["target", "forward"].forEach(function (e) {
|
|
2573
|
-
if (typeof requestOptions[e] === "string")
|
|
2574
|
-
requestOptions[e] = parse_url(requestOptions[e]);
|
|
2575
|
-
});
|
|
2576
|
-
if (!requestOptions.target && !requestOptions.forward) {
|
|
2577
|
-
return this.emit(
|
|
2578
|
-
"error",
|
|
2579
|
-
new Error("Must provide a proper URL as target"),
|
|
2580
|
-
);
|
|
2581
|
-
}
|
|
2582
|
-
for (var i = 0; i < passes.length; i++) {
|
|
2583
|
-
if (passes[i](req, res, requestOptions, head, this, cbl)) {
|
|
2584
|
-
break;
|
|
2560
|
+
},
|
|
2561
|
+
writeHeaders: function writeHeaders(req, res, proxyRes, options) {
|
|
2562
|
+
var rewriteCookieDomainConfig = options.cookieDomainRewrite,
|
|
2563
|
+
rewriteCookiePathConfig = options.cookiePathRewrite,
|
|
2564
|
+
preserveHeaderKeyCase = options.preserveHeaderKeyCase,
|
|
2565
|
+
rawHeaderKeyMap,
|
|
2566
|
+
setHeader = function (key, header) {
|
|
2567
|
+
if (header == undefined) return;
|
|
2568
|
+
if (
|
|
2569
|
+
rewriteCookieDomainConfig &&
|
|
2570
|
+
key.toLowerCase() === "set-cookie"
|
|
2571
|
+
) {
|
|
2572
|
+
header = common.rewriteCookieProperty(
|
|
2573
|
+
header,
|
|
2574
|
+
rewriteCookieDomainConfig,
|
|
2575
|
+
"domain",
|
|
2576
|
+
);
|
|
2577
|
+
}
|
|
2578
|
+
if (
|
|
2579
|
+
rewriteCookiePathConfig &&
|
|
2580
|
+
key.toLowerCase() === "set-cookie"
|
|
2581
|
+
) {
|
|
2582
|
+
header = common.rewriteCookieProperty(
|
|
2583
|
+
header,
|
|
2584
|
+
rewriteCookiePathConfig,
|
|
2585
|
+
"path",
|
|
2586
|
+
);
|
|
2585
2587
|
}
|
|
2588
|
+
res.setHeader(String(key).trim(), header);
|
|
2589
|
+
};
|
|
2590
|
+
if (typeof rewriteCookieDomainConfig === "string") {
|
|
2591
|
+
rewriteCookieDomainConfig = { "*": rewriteCookieDomainConfig };
|
|
2592
|
+
}
|
|
2593
|
+
if (typeof rewriteCookiePathConfig === "string") {
|
|
2594
|
+
rewriteCookiePathConfig = { "*": rewriteCookiePathConfig };
|
|
2595
|
+
}
|
|
2596
|
+
if (preserveHeaderKeyCase && proxyRes.rawHeaders != undefined) {
|
|
2597
|
+
rawHeaderKeyMap = {};
|
|
2598
|
+
for (var i = 0; i < proxyRes.rawHeaders.length; i += 2) {
|
|
2599
|
+
var key = proxyRes.rawHeaders[i];
|
|
2600
|
+
rawHeaderKeyMap[key.toLowerCase()] = key;
|
|
2586
2601
|
}
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
options.prependPath = options.prependPath === false ? false : true;
|
|
2595
|
-
this.web = this.proxyRequest = createRightProxy("web")(options);
|
|
2596
|
-
this.ws = this.proxyWebsocketRequest = createRightProxy("ws")(options);
|
|
2597
|
-
this.options = options;
|
|
2598
|
-
this.webPasses = Object.keys(web).map(function (pass) {
|
|
2599
|
-
return web[pass];
|
|
2600
|
-
});
|
|
2601
|
-
this.wsPasses = Object.keys(ws).map(function (pass) {
|
|
2602
|
-
return ws[pass];
|
|
2603
|
-
});
|
|
2604
|
-
this.on("error", this.onError, this);
|
|
2605
|
-
}
|
|
2606
|
-
__nccwpck_require__(9023).inherits(ProxyServer, EE3);
|
|
2607
|
-
ProxyServer.prototype.onError = function (err) {
|
|
2608
|
-
if (this.listeners("error").length === 1) {
|
|
2609
|
-
throw err;
|
|
2610
|
-
}
|
|
2611
|
-
};
|
|
2612
|
-
ProxyServer.prototype.listen = function (port, hostname) {
|
|
2613
|
-
var self = this,
|
|
2614
|
-
closure = function (req, res) {
|
|
2615
|
-
self.web(req, res);
|
|
2616
|
-
};
|
|
2617
|
-
this._server = this.options.ssl
|
|
2618
|
-
? https.createServer(this.options.ssl, closure)
|
|
2619
|
-
: http.createServer(closure);
|
|
2620
|
-
if (this.options.ws) {
|
|
2621
|
-
this._server.on("upgrade", function (req, socket, head) {
|
|
2622
|
-
self.ws(req, socket, head);
|
|
2602
|
+
}
|
|
2603
|
+
Object.keys(proxyRes.headers).forEach(function (key) {
|
|
2604
|
+
var header = proxyRes.headers[key];
|
|
2605
|
+
if (preserveHeaderKeyCase && rawHeaderKeyMap) {
|
|
2606
|
+
key = rawHeaderKeyMap[key] || key;
|
|
2607
|
+
}
|
|
2608
|
+
setHeader(key, header);
|
|
2623
2609
|
});
|
|
2624
|
-
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
this._server.close(done);
|
|
2632
|
-
}
|
|
2633
|
-
function done() {
|
|
2634
|
-
self._server = null;
|
|
2635
|
-
if (callback) {
|
|
2636
|
-
callback.apply(null, arguments);
|
|
2610
|
+
},
|
|
2611
|
+
writeStatusCode: function writeStatusCode(req, res, proxyRes) {
|
|
2612
|
+
if (proxyRes.statusMessage) {
|
|
2613
|
+
res.statusCode = proxyRes.statusCode;
|
|
2614
|
+
res.statusMessage = proxyRes.statusMessage;
|
|
2615
|
+
} else {
|
|
2616
|
+
res.statusCode = proxyRes.statusCode;
|
|
2637
2617
|
}
|
|
2638
|
-
}
|
|
2639
|
-
};
|
|
2640
|
-
ProxyServer.prototype.before = function (type, passName, callback) {
|
|
2641
|
-
if (type !== "ws" && type !== "web") {
|
|
2642
|
-
throw new Error("type must be `web` or `ws`");
|
|
2643
|
-
}
|
|
2644
|
-
var passes = type === "ws" ? this.wsPasses : this.webPasses,
|
|
2645
|
-
i = false;
|
|
2646
|
-
passes.forEach(function (v, idx) {
|
|
2647
|
-
if (v.name === passName) i = idx;
|
|
2648
|
-
});
|
|
2649
|
-
if (i === false) throw new Error("No such pass");
|
|
2650
|
-
passes.splice(i, 0, callback);
|
|
2651
|
-
};
|
|
2652
|
-
ProxyServer.prototype.after = function (type, passName, callback) {
|
|
2653
|
-
if (type !== "ws" && type !== "web") {
|
|
2654
|
-
throw new Error("type must be `web` or `ws`");
|
|
2655
|
-
}
|
|
2656
|
-
var passes = type === "ws" ? this.wsPasses : this.webPasses,
|
|
2657
|
-
i = false;
|
|
2658
|
-
passes.forEach(function (v, idx) {
|
|
2659
|
-
if (v.name === passName) i = idx;
|
|
2660
|
-
});
|
|
2661
|
-
if (i === false) throw new Error("No such pass");
|
|
2662
|
-
passes.splice(i++, 0, callback);
|
|
2618
|
+
},
|
|
2663
2619
|
};
|
|
2664
2620
|
},
|
|
2665
|
-
|
|
2666
|
-
var
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
common = __nccwpck_require__(2915),
|
|
2670
|
-
followRedirects = __nccwpck_require__(1584);
|
|
2671
|
-
web_o = Object.keys(web_o).map(function (pass) {
|
|
2672
|
-
return web_o[pass];
|
|
2673
|
-
});
|
|
2674
|
-
var nativeAgents = { http: httpNative, https: httpsNative };
|
|
2621
|
+
2264: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2622
|
+
var http = __nccwpck_require__(8611),
|
|
2623
|
+
https = __nccwpck_require__(5692),
|
|
2624
|
+
common = __nccwpck_require__(6758);
|
|
2675
2625
|
/*!
|
|
2676
2626
|
* Array of passes.
|
|
2677
2627
|
*
|
|
2678
|
-
* A `pass` is just a function that is executed on `req,
|
|
2628
|
+
* A `pass` is just a function that is executed on `req, socket, options`
|
|
2679
2629
|
* so that you can easily add new checks while still keeping the base
|
|
2680
2630
|
* flexible.
|
|
2681
2631
|
*/ module.exports = {
|
|
2682
|
-
|
|
2683
|
-
if (
|
|
2684
|
-
(
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
},
|
|
2691
|
-
timeout: function timeout(req, res, options) {
|
|
2692
|
-
if (options.timeout) {
|
|
2693
|
-
req.socket.setTimeout(options.timeout);
|
|
2694
|
-
}
|
|
2695
|
-
},
|
|
2696
|
-
XHeaders: function XHeaders(req, res, options) {
|
|
2697
|
-
if (!options.xfwd) return;
|
|
2698
|
-
var encrypted = req.isSpdy || common.hasEncryptedConnection(req);
|
|
2699
|
-
var values = {
|
|
2700
|
-
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
2701
|
-
port: common.getPort(req),
|
|
2702
|
-
proto: encrypted ? "https" : "http",
|
|
2703
|
-
};
|
|
2704
|
-
["for", "port", "proto"].forEach(function (header) {
|
|
2705
|
-
req.headers["x-forwarded-" + header] =
|
|
2706
|
-
(req.headers["x-forwarded-" + header] || "") +
|
|
2707
|
-
(req.headers["x-forwarded-" + header] ? "," : "") +
|
|
2708
|
-
values[header];
|
|
2709
|
-
});
|
|
2710
|
-
req.headers["x-forwarded-host"] =
|
|
2711
|
-
req.headers["x-forwarded-host"] || req.headers["host"] || "";
|
|
2712
|
-
},
|
|
2713
|
-
stream: function stream(req, res, options, _, server, clb) {
|
|
2714
|
-
server.emit("start", req, res, options.target || options.forward);
|
|
2715
|
-
var agents = options.followRedirects ? followRedirects : nativeAgents;
|
|
2716
|
-
var http = agents.http;
|
|
2717
|
-
var https = agents.https;
|
|
2718
|
-
if (options.forward) {
|
|
2719
|
-
var forwardReq = (
|
|
2720
|
-
options.forward.protocol === "https:" ? https : http
|
|
2721
|
-
).request(
|
|
2722
|
-
common.setupOutgoing(options.ssl || {}, options, req, "forward"),
|
|
2723
|
-
);
|
|
2724
|
-
var forwardError = createErrorHandler(forwardReq, options.forward);
|
|
2725
|
-
req.on("error", forwardError);
|
|
2726
|
-
forwardReq.on("error", forwardError);
|
|
2727
|
-
(options.buffer || req).pipe(forwardReq);
|
|
2728
|
-
if (!options.target) {
|
|
2729
|
-
return res.end();
|
|
2730
|
-
}
|
|
2731
|
-
}
|
|
2732
|
-
var proxyReq = (
|
|
2733
|
-
options.target.protocol === "https:" ? https : http
|
|
2734
|
-
).request(common.setupOutgoing(options.ssl || {}, options, req));
|
|
2735
|
-
proxyReq.on("socket", function (socket) {
|
|
2736
|
-
if (server && !proxyReq.getHeader("expect")) {
|
|
2737
|
-
server.emit("proxyReq", proxyReq, req, res, options);
|
|
2738
|
-
}
|
|
2739
|
-
});
|
|
2740
|
-
if (options.proxyTimeout) {
|
|
2741
|
-
proxyReq.setTimeout(options.proxyTimeout, function () {
|
|
2742
|
-
proxyReq.abort();
|
|
2743
|
-
});
|
|
2744
|
-
}
|
|
2745
|
-
req.on("aborted", function () {
|
|
2746
|
-
proxyReq.abort();
|
|
2747
|
-
});
|
|
2748
|
-
var proxyError = createErrorHandler(proxyReq, options.target);
|
|
2749
|
-
req.on("error", proxyError);
|
|
2750
|
-
proxyReq.on("error", proxyError);
|
|
2751
|
-
function createErrorHandler(proxyReq, url) {
|
|
2752
|
-
return function proxyError(err) {
|
|
2753
|
-
if (req.socket.destroyed && err.code === "ECONNRESET") {
|
|
2754
|
-
server.emit("econnreset", err, req, res, url);
|
|
2755
|
-
return proxyReq.abort();
|
|
2756
|
-
}
|
|
2757
|
-
if (clb) {
|
|
2758
|
-
clb(err, req, res, url);
|
|
2759
|
-
} else {
|
|
2760
|
-
server.emit("error", err, req, res, url);
|
|
2761
|
-
}
|
|
2762
|
-
};
|
|
2763
|
-
}
|
|
2764
|
-
(options.buffer || req).pipe(proxyReq);
|
|
2765
|
-
proxyReq.on("response", function (proxyRes) {
|
|
2766
|
-
if (server) {
|
|
2767
|
-
server.emit("proxyRes", proxyRes, req, res);
|
|
2768
|
-
}
|
|
2769
|
-
if (!res.headersSent && !options.selfHandleResponse) {
|
|
2770
|
-
for (var i = 0; i < web_o.length; i++) {
|
|
2771
|
-
if (web_o[i](req, res, proxyRes, options)) {
|
|
2772
|
-
break;
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
if (!res.finished) {
|
|
2777
|
-
proxyRes.on("end", function () {
|
|
2778
|
-
if (server) server.emit("end", req, res, proxyRes);
|
|
2779
|
-
});
|
|
2780
|
-
if (!options.selfHandleResponse) proxyRes.pipe(res);
|
|
2781
|
-
} else {
|
|
2782
|
-
if (server) server.emit("end", req, res, proxyRes);
|
|
2783
|
-
}
|
|
2784
|
-
});
|
|
2785
|
-
},
|
|
2786
|
-
};
|
|
2787
|
-
},
|
|
2788
|
-
9905: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2789
|
-
var url = __nccwpck_require__(7016),
|
|
2790
|
-
common = __nccwpck_require__(2915);
|
|
2791
|
-
var redirectRegex = /^201|30(1|2|7|8)$/;
|
|
2792
|
-
/*!
|
|
2793
|
-
* Array of passes.
|
|
2794
|
-
*
|
|
2795
|
-
* A `pass` is just a function that is executed on `req, res, options`
|
|
2796
|
-
* so that you can easily add new checks while still keeping the base
|
|
2797
|
-
* flexible.
|
|
2798
|
-
*/ module.exports = {
|
|
2799
|
-
removeChunked: function removeChunked(req, res, proxyRes) {
|
|
2800
|
-
if (req.httpVersion === "1.0") {
|
|
2801
|
-
delete proxyRes.headers["transfer-encoding"];
|
|
2802
|
-
}
|
|
2803
|
-
},
|
|
2804
|
-
setConnection: function setConnection(req, res, proxyRes) {
|
|
2805
|
-
if (req.httpVersion === "1.0") {
|
|
2806
|
-
proxyRes.headers.connection = req.headers.connection || "close";
|
|
2807
|
-
} else if (
|
|
2808
|
-
req.httpVersion !== "2.0" &&
|
|
2809
|
-
!proxyRes.headers.connection
|
|
2810
|
-
) {
|
|
2811
|
-
proxyRes.headers.connection =
|
|
2812
|
-
req.headers.connection || "keep-alive";
|
|
2813
|
-
}
|
|
2814
|
-
},
|
|
2815
|
-
setRedirectHostRewrite: function setRedirectHostRewrite(
|
|
2816
|
-
req,
|
|
2817
|
-
res,
|
|
2818
|
-
proxyRes,
|
|
2819
|
-
options,
|
|
2820
|
-
) {
|
|
2821
|
-
if (
|
|
2822
|
-
(options.hostRewrite ||
|
|
2823
|
-
options.autoRewrite ||
|
|
2824
|
-
options.protocolRewrite) &&
|
|
2825
|
-
proxyRes.headers["location"] &&
|
|
2826
|
-
redirectRegex.test(proxyRes.statusCode)
|
|
2827
|
-
) {
|
|
2828
|
-
var target = url.parse(options.target);
|
|
2829
|
-
var u = url.parse(proxyRes.headers["location"]);
|
|
2830
|
-
if (target.host != u.host) {
|
|
2831
|
-
return;
|
|
2832
|
-
}
|
|
2833
|
-
if (options.hostRewrite) {
|
|
2834
|
-
u.host = options.hostRewrite;
|
|
2835
|
-
} else if (options.autoRewrite) {
|
|
2836
|
-
u.host = req.headers["host"];
|
|
2837
|
-
}
|
|
2838
|
-
if (options.protocolRewrite) {
|
|
2839
|
-
u.protocol = options.protocolRewrite;
|
|
2840
|
-
}
|
|
2841
|
-
proxyRes.headers["location"] = u.format();
|
|
2842
|
-
}
|
|
2843
|
-
},
|
|
2844
|
-
writeHeaders: function writeHeaders(req, res, proxyRes, options) {
|
|
2845
|
-
var rewriteCookieDomainConfig = options.cookieDomainRewrite,
|
|
2846
|
-
rewriteCookiePathConfig = options.cookiePathRewrite,
|
|
2847
|
-
preserveHeaderKeyCase = options.preserveHeaderKeyCase,
|
|
2848
|
-
rawHeaderKeyMap,
|
|
2849
|
-
setHeader = function (key, header) {
|
|
2850
|
-
if (header == undefined) return;
|
|
2851
|
-
if (
|
|
2852
|
-
rewriteCookieDomainConfig &&
|
|
2853
|
-
key.toLowerCase() === "set-cookie"
|
|
2854
|
-
) {
|
|
2855
|
-
header = common.rewriteCookieProperty(
|
|
2856
|
-
header,
|
|
2857
|
-
rewriteCookieDomainConfig,
|
|
2858
|
-
"domain",
|
|
2859
|
-
);
|
|
2860
|
-
}
|
|
2861
|
-
if (
|
|
2862
|
-
rewriteCookiePathConfig &&
|
|
2863
|
-
key.toLowerCase() === "set-cookie"
|
|
2864
|
-
) {
|
|
2865
|
-
header = common.rewriteCookieProperty(
|
|
2866
|
-
header,
|
|
2867
|
-
rewriteCookiePathConfig,
|
|
2868
|
-
"path",
|
|
2869
|
-
);
|
|
2870
|
-
}
|
|
2871
|
-
res.setHeader(String(key).trim(), header);
|
|
2872
|
-
};
|
|
2873
|
-
if (typeof rewriteCookieDomainConfig === "string") {
|
|
2874
|
-
rewriteCookieDomainConfig = { "*": rewriteCookieDomainConfig };
|
|
2875
|
-
}
|
|
2876
|
-
if (typeof rewriteCookiePathConfig === "string") {
|
|
2877
|
-
rewriteCookiePathConfig = { "*": rewriteCookiePathConfig };
|
|
2878
|
-
}
|
|
2879
|
-
if (preserveHeaderKeyCase && proxyRes.rawHeaders != undefined) {
|
|
2880
|
-
rawHeaderKeyMap = {};
|
|
2881
|
-
for (var i = 0; i < proxyRes.rawHeaders.length; i += 2) {
|
|
2882
|
-
var key = proxyRes.rawHeaders[i];
|
|
2883
|
-
rawHeaderKeyMap[key.toLowerCase()] = key;
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
Object.keys(proxyRes.headers).forEach(function (key) {
|
|
2887
|
-
var header = proxyRes.headers[key];
|
|
2888
|
-
if (preserveHeaderKeyCase && rawHeaderKeyMap) {
|
|
2889
|
-
key = rawHeaderKeyMap[key] || key;
|
|
2890
|
-
}
|
|
2891
|
-
setHeader(key, header);
|
|
2892
|
-
});
|
|
2893
|
-
},
|
|
2894
|
-
writeStatusCode: function writeStatusCode(req, res, proxyRes) {
|
|
2895
|
-
if (proxyRes.statusMessage) {
|
|
2896
|
-
res.statusCode = proxyRes.statusCode;
|
|
2897
|
-
res.statusMessage = proxyRes.statusMessage;
|
|
2898
|
-
} else {
|
|
2899
|
-
res.statusCode = proxyRes.statusCode;
|
|
2900
|
-
}
|
|
2901
|
-
},
|
|
2902
|
-
};
|
|
2903
|
-
},
|
|
2904
|
-
2725: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2905
|
-
var http = __nccwpck_require__(8611),
|
|
2906
|
-
https = __nccwpck_require__(5692),
|
|
2907
|
-
common = __nccwpck_require__(2915);
|
|
2908
|
-
/*!
|
|
2909
|
-
* Array of passes.
|
|
2910
|
-
*
|
|
2911
|
-
* A `pass` is just a function that is executed on `req, socket, options`
|
|
2912
|
-
* so that you can easily add new checks while still keeping the base
|
|
2913
|
-
* flexible.
|
|
2914
|
-
*/ module.exports = {
|
|
2915
|
-
checkMethodAndHeader: function checkMethodAndHeader(req, socket) {
|
|
2916
|
-
if (req.method !== "GET" || !req.headers.upgrade) {
|
|
2917
|
-
socket.destroy();
|
|
2918
|
-
return true;
|
|
2919
|
-
}
|
|
2920
|
-
if (req.headers.upgrade.toLowerCase() !== "websocket") {
|
|
2921
|
-
socket.destroy();
|
|
2922
|
-
return true;
|
|
2632
|
+
checkMethodAndHeader: function checkMethodAndHeader(req, socket) {
|
|
2633
|
+
if (req.method !== "GET" || !req.headers.upgrade) {
|
|
2634
|
+
socket.destroy();
|
|
2635
|
+
return true;
|
|
2636
|
+
}
|
|
2637
|
+
if (req.headers.upgrade.toLowerCase() !== "websocket") {
|
|
2638
|
+
socket.destroy();
|
|
2639
|
+
return true;
|
|
2923
2640
|
}
|
|
2924
2641
|
},
|
|
2925
2642
|
XHeaders: function XHeaders(req, socket, options) {
|
|
@@ -3201,15 +2918,30 @@
|
|
|
3201
2918
|
return false;
|
|
3202
2919
|
};
|
|
3203
2920
|
},
|
|
3204
|
-
|
|
2921
|
+
634: (__unused_webpack_module, exports) => {
|
|
3205
2922
|
"use strict";
|
|
3206
|
-
|
|
3207
|
-
|
|
2923
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2924
|
+
/*!
|
|
2925
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
2926
|
+
*
|
|
2927
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
2928
|
+
* Released under the MIT License.
|
|
2929
|
+
*/ function isObject(o) {
|
|
2930
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
2931
|
+
}
|
|
2932
|
+
function isPlainObject(o) {
|
|
2933
|
+
var ctor, prot;
|
|
2934
|
+
if (isObject(o) === false) return false;
|
|
2935
|
+
ctor = o.constructor;
|
|
2936
|
+
if (ctor === undefined) return true;
|
|
2937
|
+
prot = ctor.prototype;
|
|
2938
|
+
if (isObject(prot) === false) return false;
|
|
2939
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
3208
2940
|
return false;
|
|
3209
2941
|
}
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
2942
|
+
return true;
|
|
2943
|
+
}
|
|
2944
|
+
exports.isPlainObject = isPlainObject;
|
|
3213
2945
|
},
|
|
3214
2946
|
9555: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3215
2947
|
"use strict";
|
|
@@ -3385,24 +3117,138 @@
|
|
|
3385
3117
|
micromatch.hasBraces = hasBraces;
|
|
3386
3118
|
module.exports = micromatch;
|
|
3387
3119
|
},
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3120
|
+
6987: (module) => {
|
|
3121
|
+
var s = 1e3;
|
|
3122
|
+
var m = s * 60;
|
|
3123
|
+
var h = m * 60;
|
|
3124
|
+
var d = h * 24;
|
|
3125
|
+
var w = d * 7;
|
|
3126
|
+
var y = d * 365.25;
|
|
3127
|
+
module.exports = function (val, options) {
|
|
3128
|
+
options = options || {};
|
|
3129
|
+
var type = typeof val;
|
|
3130
|
+
if (type === "string" && val.length > 0) {
|
|
3131
|
+
return parse(val);
|
|
3132
|
+
} else if (type === "number" && isFinite(val)) {
|
|
3133
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
3134
|
+
}
|
|
3135
|
+
throw new Error(
|
|
3136
|
+
"val is not a non-empty string or a valid number. val=" +
|
|
3137
|
+
JSON.stringify(val),
|
|
3138
|
+
);
|
|
3139
|
+
};
|
|
3140
|
+
function parse(str) {
|
|
3141
|
+
str = String(str);
|
|
3142
|
+
if (str.length > 100) {
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
var match =
|
|
3146
|
+
/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
3147
|
+
str,
|
|
3148
|
+
);
|
|
3149
|
+
if (!match) {
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3152
|
+
var n = parseFloat(match[1]);
|
|
3153
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
3154
|
+
switch (type) {
|
|
3155
|
+
case "years":
|
|
3156
|
+
case "year":
|
|
3157
|
+
case "yrs":
|
|
3158
|
+
case "yr":
|
|
3159
|
+
case "y":
|
|
3160
|
+
return n * y;
|
|
3161
|
+
case "weeks":
|
|
3162
|
+
case "week":
|
|
3163
|
+
case "w":
|
|
3164
|
+
return n * w;
|
|
3165
|
+
case "days":
|
|
3166
|
+
case "day":
|
|
3167
|
+
case "d":
|
|
3168
|
+
return n * d;
|
|
3169
|
+
case "hours":
|
|
3170
|
+
case "hour":
|
|
3171
|
+
case "hrs":
|
|
3172
|
+
case "hr":
|
|
3173
|
+
case "h":
|
|
3174
|
+
return n * h;
|
|
3175
|
+
case "minutes":
|
|
3176
|
+
case "minute":
|
|
3177
|
+
case "mins":
|
|
3178
|
+
case "min":
|
|
3179
|
+
case "m":
|
|
3180
|
+
return n * m;
|
|
3181
|
+
case "seconds":
|
|
3182
|
+
case "second":
|
|
3183
|
+
case "secs":
|
|
3184
|
+
case "sec":
|
|
3185
|
+
case "s":
|
|
3186
|
+
return n * s;
|
|
3187
|
+
case "milliseconds":
|
|
3188
|
+
case "millisecond":
|
|
3189
|
+
case "msecs":
|
|
3190
|
+
case "msec":
|
|
3191
|
+
case "ms":
|
|
3192
|
+
return n;
|
|
3193
|
+
default:
|
|
3194
|
+
return undefined;
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
function fmtShort(ms) {
|
|
3198
|
+
var msAbs = Math.abs(ms);
|
|
3199
|
+
if (msAbs >= d) {
|
|
3200
|
+
return Math.round(ms / d) + "d";
|
|
3201
|
+
}
|
|
3202
|
+
if (msAbs >= h) {
|
|
3203
|
+
return Math.round(ms / h) + "h";
|
|
3204
|
+
}
|
|
3205
|
+
if (msAbs >= m) {
|
|
3206
|
+
return Math.round(ms / m) + "m";
|
|
3207
|
+
}
|
|
3208
|
+
if (msAbs >= s) {
|
|
3209
|
+
return Math.round(ms / s) + "s";
|
|
3210
|
+
}
|
|
3211
|
+
return ms + "ms";
|
|
3212
|
+
}
|
|
3213
|
+
function fmtLong(ms) {
|
|
3214
|
+
var msAbs = Math.abs(ms);
|
|
3215
|
+
if (msAbs >= d) {
|
|
3216
|
+
return plural(ms, msAbs, d, "day");
|
|
3217
|
+
}
|
|
3218
|
+
if (msAbs >= h) {
|
|
3219
|
+
return plural(ms, msAbs, h, "hour");
|
|
3220
|
+
}
|
|
3221
|
+
if (msAbs >= m) {
|
|
3222
|
+
return plural(ms, msAbs, m, "minute");
|
|
3223
|
+
}
|
|
3224
|
+
if (msAbs >= s) {
|
|
3225
|
+
return plural(ms, msAbs, s, "second");
|
|
3226
|
+
}
|
|
3227
|
+
return ms + " ms";
|
|
3228
|
+
}
|
|
3229
|
+
function plural(ms, msAbs, n, name) {
|
|
3230
|
+
var isPlural = msAbs >= n * 1.5;
|
|
3231
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
3232
|
+
}
|
|
3233
|
+
},
|
|
3234
|
+
5675: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3235
|
+
"use strict";
|
|
3236
|
+
module.exports = __nccwpck_require__(3193);
|
|
3237
|
+
},
|
|
3238
|
+
7054: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3239
|
+
"use strict";
|
|
3240
|
+
const path = __nccwpck_require__(6928);
|
|
3241
|
+
const WIN_SLASH = "\\\\/";
|
|
3242
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
3243
|
+
const DOT_LITERAL = "\\.";
|
|
3244
|
+
const PLUS_LITERAL = "\\+";
|
|
3245
|
+
const QMARK_LITERAL = "\\?";
|
|
3246
|
+
const SLASH_LITERAL = "\\/";
|
|
3247
|
+
const ONE_CHAR = "(?=.)";
|
|
3248
|
+
const QMARK = "[^/]";
|
|
3249
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
3250
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
3251
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
3406
3252
|
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
3407
3253
|
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
3408
3254
|
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
@@ -4746,514 +4592,1516 @@
|
|
|
4746
4592
|
}
|
|
4747
4593
|
continue;
|
|
4748
4594
|
}
|
|
4749
|
-
break;
|
|
4595
|
+
break;
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
if (code === CHAR_ASTERISK) {
|
|
4599
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
4600
|
+
isGlob = token.isGlob = true;
|
|
4601
|
+
finished = true;
|
|
4602
|
+
if (scanToEnd === true) {
|
|
4603
|
+
continue;
|
|
4604
|
+
}
|
|
4605
|
+
break;
|
|
4606
|
+
}
|
|
4607
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
4608
|
+
isGlob = token.isGlob = true;
|
|
4609
|
+
finished = true;
|
|
4610
|
+
if (scanToEnd === true) {
|
|
4611
|
+
continue;
|
|
4612
|
+
}
|
|
4613
|
+
break;
|
|
4614
|
+
}
|
|
4615
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
4616
|
+
while (eos() !== true && (next = advance())) {
|
|
4617
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
4618
|
+
backslashes = token.backslashes = true;
|
|
4619
|
+
advance();
|
|
4620
|
+
continue;
|
|
4621
|
+
}
|
|
4622
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
4623
|
+
isBracket = token.isBracket = true;
|
|
4624
|
+
isGlob = token.isGlob = true;
|
|
4625
|
+
finished = true;
|
|
4626
|
+
break;
|
|
4627
|
+
}
|
|
4628
|
+
}
|
|
4629
|
+
if (scanToEnd === true) {
|
|
4630
|
+
continue;
|
|
4631
|
+
}
|
|
4632
|
+
break;
|
|
4633
|
+
}
|
|
4634
|
+
if (
|
|
4635
|
+
opts.nonegate !== true &&
|
|
4636
|
+
code === CHAR_EXCLAMATION_MARK &&
|
|
4637
|
+
index === start
|
|
4638
|
+
) {
|
|
4639
|
+
negated = token.negated = true;
|
|
4640
|
+
start++;
|
|
4641
|
+
continue;
|
|
4642
|
+
}
|
|
4643
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
4644
|
+
isGlob = token.isGlob = true;
|
|
4645
|
+
if (scanToEnd === true) {
|
|
4646
|
+
while (eos() !== true && (code = advance())) {
|
|
4647
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
4648
|
+
backslashes = token.backslashes = true;
|
|
4649
|
+
code = advance();
|
|
4650
|
+
continue;
|
|
4651
|
+
}
|
|
4652
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
4653
|
+
finished = true;
|
|
4654
|
+
break;
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
continue;
|
|
4658
|
+
}
|
|
4659
|
+
break;
|
|
4660
|
+
}
|
|
4661
|
+
if (isGlob === true) {
|
|
4662
|
+
finished = true;
|
|
4663
|
+
if (scanToEnd === true) {
|
|
4664
|
+
continue;
|
|
4665
|
+
}
|
|
4666
|
+
break;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
if (opts.noext === true) {
|
|
4670
|
+
isExtglob = false;
|
|
4671
|
+
isGlob = false;
|
|
4672
|
+
}
|
|
4673
|
+
let base = str;
|
|
4674
|
+
let prefix = "";
|
|
4675
|
+
let glob = "";
|
|
4676
|
+
if (start > 0) {
|
|
4677
|
+
prefix = str.slice(0, start);
|
|
4678
|
+
str = str.slice(start);
|
|
4679
|
+
lastIndex -= start;
|
|
4680
|
+
}
|
|
4681
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
4682
|
+
base = str.slice(0, lastIndex);
|
|
4683
|
+
glob = str.slice(lastIndex);
|
|
4684
|
+
} else if (isGlob === true) {
|
|
4685
|
+
base = "";
|
|
4686
|
+
glob = str;
|
|
4687
|
+
} else {
|
|
4688
|
+
base = str;
|
|
4689
|
+
}
|
|
4690
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
4691
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
4692
|
+
base = base.slice(0, -1);
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
if (opts.unescape === true) {
|
|
4696
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
4697
|
+
if (base && backslashes === true) {
|
|
4698
|
+
base = utils.removeBackslashes(base);
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
const state = {
|
|
4702
|
+
prefix,
|
|
4703
|
+
input,
|
|
4704
|
+
start,
|
|
4705
|
+
base,
|
|
4706
|
+
glob,
|
|
4707
|
+
isBrace,
|
|
4708
|
+
isBracket,
|
|
4709
|
+
isGlob,
|
|
4710
|
+
isExtglob,
|
|
4711
|
+
isGlobstar,
|
|
4712
|
+
negated,
|
|
4713
|
+
negatedExtglob,
|
|
4714
|
+
};
|
|
4715
|
+
if (opts.tokens === true) {
|
|
4716
|
+
state.maxDepth = 0;
|
|
4717
|
+
if (!isPathSeparator(code)) {
|
|
4718
|
+
tokens.push(token);
|
|
4719
|
+
}
|
|
4720
|
+
state.tokens = tokens;
|
|
4721
|
+
}
|
|
4722
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
4723
|
+
let prevIndex;
|
|
4724
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
4725
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
4726
|
+
const i = slashes[idx];
|
|
4727
|
+
const value = input.slice(n, i);
|
|
4728
|
+
if (opts.tokens) {
|
|
4729
|
+
if (idx === 0 && start !== 0) {
|
|
4730
|
+
tokens[idx].isPrefix = true;
|
|
4731
|
+
tokens[idx].value = prefix;
|
|
4732
|
+
} else {
|
|
4733
|
+
tokens[idx].value = value;
|
|
4734
|
+
}
|
|
4735
|
+
depth(tokens[idx]);
|
|
4736
|
+
state.maxDepth += tokens[idx].depth;
|
|
4737
|
+
}
|
|
4738
|
+
if (idx !== 0 || value !== "") {
|
|
4739
|
+
parts.push(value);
|
|
4740
|
+
}
|
|
4741
|
+
prevIndex = i;
|
|
4742
|
+
}
|
|
4743
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
4744
|
+
const value = input.slice(prevIndex + 1);
|
|
4745
|
+
parts.push(value);
|
|
4746
|
+
if (opts.tokens) {
|
|
4747
|
+
tokens[tokens.length - 1].value = value;
|
|
4748
|
+
depth(tokens[tokens.length - 1]);
|
|
4749
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
state.slashes = slashes;
|
|
4753
|
+
state.parts = parts;
|
|
4754
|
+
}
|
|
4755
|
+
return state;
|
|
4756
|
+
};
|
|
4757
|
+
module.exports = scan;
|
|
4758
|
+
},
|
|
4759
|
+
7910: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4760
|
+
"use strict";
|
|
4761
|
+
const path = __nccwpck_require__(6928);
|
|
4762
|
+
const win32 = process.platform === "win32";
|
|
4763
|
+
const {
|
|
4764
|
+
REGEX_BACKSLASH,
|
|
4765
|
+
REGEX_REMOVE_BACKSLASH,
|
|
4766
|
+
REGEX_SPECIAL_CHARS,
|
|
4767
|
+
REGEX_SPECIAL_CHARS_GLOBAL,
|
|
4768
|
+
} = __nccwpck_require__(7054);
|
|
4769
|
+
exports.isObject = (val) =>
|
|
4770
|
+
val !== null && typeof val === "object" && !Array.isArray(val);
|
|
4771
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
4772
|
+
exports.isRegexChar = (str) =>
|
|
4773
|
+
str.length === 1 && exports.hasRegexChars(str);
|
|
4774
|
+
exports.escapeRegex = (str) =>
|
|
4775
|
+
str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
4776
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
4777
|
+
exports.removeBackslashes = (str) =>
|
|
4778
|
+
str.replace(REGEX_REMOVE_BACKSLASH, (match) =>
|
|
4779
|
+
match === "\\" ? "" : match,
|
|
4780
|
+
);
|
|
4781
|
+
exports.supportsLookbehinds = () => {
|
|
4782
|
+
const segs = process.version.slice(1).split(".").map(Number);
|
|
4783
|
+
if (
|
|
4784
|
+
(segs.length === 3 && segs[0] >= 9) ||
|
|
4785
|
+
(segs[0] === 8 && segs[1] >= 10)
|
|
4786
|
+
) {
|
|
4787
|
+
return true;
|
|
4788
|
+
}
|
|
4789
|
+
return false;
|
|
4790
|
+
};
|
|
4791
|
+
exports.isWindows = (options) => {
|
|
4792
|
+
if (options && typeof options.windows === "boolean") {
|
|
4793
|
+
return options.windows;
|
|
4794
|
+
}
|
|
4795
|
+
return win32 === true || path.sep === "\\";
|
|
4796
|
+
};
|
|
4797
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
4798
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
4799
|
+
if (idx === -1) return input;
|
|
4800
|
+
if (input[idx - 1] === "\\")
|
|
4801
|
+
return exports.escapeLast(input, char, idx - 1);
|
|
4802
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
4803
|
+
};
|
|
4804
|
+
exports.removePrefix = (input, state = {}) => {
|
|
4805
|
+
let output = input;
|
|
4806
|
+
if (output.startsWith("./")) {
|
|
4807
|
+
output = output.slice(2);
|
|
4808
|
+
state.prefix = "./";
|
|
4809
|
+
}
|
|
4810
|
+
return output;
|
|
4811
|
+
};
|
|
4812
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
4813
|
+
const prepend = options.contains ? "" : "^";
|
|
4814
|
+
const append = options.contains ? "" : "$";
|
|
4815
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
4816
|
+
if (state.negated === true) {
|
|
4817
|
+
output = `(?:^(?!${output}).*$)`;
|
|
4818
|
+
}
|
|
4819
|
+
return output;
|
|
4820
|
+
};
|
|
4821
|
+
},
|
|
4822
|
+
7866: (module) => {
|
|
4823
|
+
"use strict";
|
|
4824
|
+
module.exports = function required(port, protocol) {
|
|
4825
|
+
protocol = protocol.split(":")[0];
|
|
4826
|
+
port = +port;
|
|
4827
|
+
if (!port) return false;
|
|
4828
|
+
switch (protocol) {
|
|
4829
|
+
case "http":
|
|
4830
|
+
case "ws":
|
|
4831
|
+
return port !== 80;
|
|
4832
|
+
case "https":
|
|
4833
|
+
case "wss":
|
|
4834
|
+
return port !== 443;
|
|
4835
|
+
case "ftp":
|
|
4836
|
+
return port !== 21;
|
|
4837
|
+
case "gopher":
|
|
4838
|
+
return port !== 70;
|
|
4839
|
+
case "file":
|
|
4840
|
+
return false;
|
|
4841
|
+
}
|
|
4842
|
+
return port !== 0;
|
|
4843
|
+
};
|
|
4844
|
+
},
|
|
4845
|
+
743: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4846
|
+
"use strict";
|
|
4847
|
+
/*!
|
|
4848
|
+
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
4849
|
+
*
|
|
4850
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
4851
|
+
* Released under the MIT License.
|
|
4852
|
+
*/ const isNumber = __nccwpck_require__(952);
|
|
4853
|
+
const toRegexRange = (min, max, options) => {
|
|
4854
|
+
if (isNumber(min) === false) {
|
|
4855
|
+
throw new TypeError(
|
|
4856
|
+
"toRegexRange: expected the first argument to be a number",
|
|
4857
|
+
);
|
|
4858
|
+
}
|
|
4859
|
+
if (max === void 0 || min === max) {
|
|
4860
|
+
return String(min);
|
|
4861
|
+
}
|
|
4862
|
+
if (isNumber(max) === false) {
|
|
4863
|
+
throw new TypeError(
|
|
4864
|
+
"toRegexRange: expected the second argument to be a number.",
|
|
4865
|
+
);
|
|
4866
|
+
}
|
|
4867
|
+
let opts = { relaxZeros: true, ...options };
|
|
4868
|
+
if (typeof opts.strictZeros === "boolean") {
|
|
4869
|
+
opts.relaxZeros = opts.strictZeros === false;
|
|
4870
|
+
}
|
|
4871
|
+
let relax = String(opts.relaxZeros);
|
|
4872
|
+
let shorthand = String(opts.shorthand);
|
|
4873
|
+
let capture = String(opts.capture);
|
|
4874
|
+
let wrap = String(opts.wrap);
|
|
4875
|
+
let cacheKey =
|
|
4876
|
+
min + ":" + max + "=" + relax + shorthand + capture + wrap;
|
|
4877
|
+
if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
|
|
4878
|
+
return toRegexRange.cache[cacheKey].result;
|
|
4879
|
+
}
|
|
4880
|
+
let a = Math.min(min, max);
|
|
4881
|
+
let b = Math.max(min, max);
|
|
4882
|
+
if (Math.abs(a - b) === 1) {
|
|
4883
|
+
let result = min + "|" + max;
|
|
4884
|
+
if (opts.capture) {
|
|
4885
|
+
return `(${result})`;
|
|
4886
|
+
}
|
|
4887
|
+
if (opts.wrap === false) {
|
|
4888
|
+
return result;
|
|
4889
|
+
}
|
|
4890
|
+
return `(?:${result})`;
|
|
4891
|
+
}
|
|
4892
|
+
let isPadded = hasPadding(min) || hasPadding(max);
|
|
4893
|
+
let state = { min, max, a, b };
|
|
4894
|
+
let positives = [];
|
|
4895
|
+
let negatives = [];
|
|
4896
|
+
if (isPadded) {
|
|
4897
|
+
state.isPadded = isPadded;
|
|
4898
|
+
state.maxLen = String(state.max).length;
|
|
4899
|
+
}
|
|
4900
|
+
if (a < 0) {
|
|
4901
|
+
let newMin = b < 0 ? Math.abs(b) : 1;
|
|
4902
|
+
negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
|
|
4903
|
+
a = state.a = 0;
|
|
4904
|
+
}
|
|
4905
|
+
if (b >= 0) {
|
|
4906
|
+
positives = splitToPatterns(a, b, state, opts);
|
|
4907
|
+
}
|
|
4908
|
+
state.negatives = negatives;
|
|
4909
|
+
state.positives = positives;
|
|
4910
|
+
state.result = collatePatterns(negatives, positives, opts);
|
|
4911
|
+
if (opts.capture === true) {
|
|
4912
|
+
state.result = `(${state.result})`;
|
|
4913
|
+
} else if (
|
|
4914
|
+
opts.wrap !== false &&
|
|
4915
|
+
positives.length + negatives.length > 1
|
|
4916
|
+
) {
|
|
4917
|
+
state.result = `(?:${state.result})`;
|
|
4918
|
+
}
|
|
4919
|
+
toRegexRange.cache[cacheKey] = state;
|
|
4920
|
+
return state.result;
|
|
4921
|
+
};
|
|
4922
|
+
function collatePatterns(neg, pos, options) {
|
|
4923
|
+
let onlyNegative = filterPatterns(neg, pos, "-", false, options) || [];
|
|
4924
|
+
let onlyPositive = filterPatterns(pos, neg, "", false, options) || [];
|
|
4925
|
+
let intersected = filterPatterns(neg, pos, "-?", true, options) || [];
|
|
4926
|
+
let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
|
|
4927
|
+
return subpatterns.join("|");
|
|
4928
|
+
}
|
|
4929
|
+
function splitToRanges(min, max) {
|
|
4930
|
+
let nines = 1;
|
|
4931
|
+
let zeros = 1;
|
|
4932
|
+
let stop = countNines(min, nines);
|
|
4933
|
+
let stops = new Set([max]);
|
|
4934
|
+
while (min <= stop && stop <= max) {
|
|
4935
|
+
stops.add(stop);
|
|
4936
|
+
nines += 1;
|
|
4937
|
+
stop = countNines(min, nines);
|
|
4938
|
+
}
|
|
4939
|
+
stop = countZeros(max + 1, zeros) - 1;
|
|
4940
|
+
while (min < stop && stop <= max) {
|
|
4941
|
+
stops.add(stop);
|
|
4942
|
+
zeros += 1;
|
|
4943
|
+
stop = countZeros(max + 1, zeros) - 1;
|
|
4944
|
+
}
|
|
4945
|
+
stops = [...stops];
|
|
4946
|
+
stops.sort(compare);
|
|
4947
|
+
return stops;
|
|
4948
|
+
}
|
|
4949
|
+
function rangeToPattern(start, stop, options) {
|
|
4950
|
+
if (start === stop) {
|
|
4951
|
+
return { pattern: start, count: [], digits: 0 };
|
|
4952
|
+
}
|
|
4953
|
+
let zipped = zip(start, stop);
|
|
4954
|
+
let digits = zipped.length;
|
|
4955
|
+
let pattern = "";
|
|
4956
|
+
let count = 0;
|
|
4957
|
+
for (let i = 0; i < digits; i++) {
|
|
4958
|
+
let [startDigit, stopDigit] = zipped[i];
|
|
4959
|
+
if (startDigit === stopDigit) {
|
|
4960
|
+
pattern += startDigit;
|
|
4961
|
+
} else if (startDigit !== "0" || stopDigit !== "9") {
|
|
4962
|
+
pattern += toCharacterClass(startDigit, stopDigit, options);
|
|
4963
|
+
} else {
|
|
4964
|
+
count++;
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
if (count) {
|
|
4968
|
+
pattern += options.shorthand === true ? "\\d" : "[0-9]";
|
|
4969
|
+
}
|
|
4970
|
+
return { pattern, count: [count], digits };
|
|
4971
|
+
}
|
|
4972
|
+
function splitToPatterns(min, max, tok, options) {
|
|
4973
|
+
let ranges = splitToRanges(min, max);
|
|
4974
|
+
let tokens = [];
|
|
4975
|
+
let start = min;
|
|
4976
|
+
let prev;
|
|
4977
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
4978
|
+
let max = ranges[i];
|
|
4979
|
+
let obj = rangeToPattern(String(start), String(max), options);
|
|
4980
|
+
let zeros = "";
|
|
4981
|
+
if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
|
|
4982
|
+
if (prev.count.length > 1) {
|
|
4983
|
+
prev.count.pop();
|
|
4984
|
+
}
|
|
4985
|
+
prev.count.push(obj.count[0]);
|
|
4986
|
+
prev.string = prev.pattern + toQuantifier(prev.count);
|
|
4987
|
+
start = max + 1;
|
|
4988
|
+
continue;
|
|
4989
|
+
}
|
|
4990
|
+
if (tok.isPadded) {
|
|
4991
|
+
zeros = padZeros(max, tok, options);
|
|
4992
|
+
}
|
|
4993
|
+
obj.string = zeros + obj.pattern + toQuantifier(obj.count);
|
|
4994
|
+
tokens.push(obj);
|
|
4995
|
+
start = max + 1;
|
|
4996
|
+
prev = obj;
|
|
4997
|
+
}
|
|
4998
|
+
return tokens;
|
|
4999
|
+
}
|
|
5000
|
+
function filterPatterns(arr, comparison, prefix, intersection, options) {
|
|
5001
|
+
let result = [];
|
|
5002
|
+
for (let ele of arr) {
|
|
5003
|
+
let { string } = ele;
|
|
5004
|
+
if (!intersection && !contains(comparison, "string", string)) {
|
|
5005
|
+
result.push(prefix + string);
|
|
5006
|
+
}
|
|
5007
|
+
if (intersection && contains(comparison, "string", string)) {
|
|
5008
|
+
result.push(prefix + string);
|
|
5009
|
+
}
|
|
5010
|
+
}
|
|
5011
|
+
return result;
|
|
5012
|
+
}
|
|
5013
|
+
function zip(a, b) {
|
|
5014
|
+
let arr = [];
|
|
5015
|
+
for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
|
|
5016
|
+
return arr;
|
|
5017
|
+
}
|
|
5018
|
+
function compare(a, b) {
|
|
5019
|
+
return a > b ? 1 : b > a ? -1 : 0;
|
|
5020
|
+
}
|
|
5021
|
+
function contains(arr, key, val) {
|
|
5022
|
+
return arr.some((ele) => ele[key] === val);
|
|
5023
|
+
}
|
|
5024
|
+
function countNines(min, len) {
|
|
5025
|
+
return Number(String(min).slice(0, -len) + "9".repeat(len));
|
|
5026
|
+
}
|
|
5027
|
+
function countZeros(integer, zeros) {
|
|
5028
|
+
return integer - (integer % Math.pow(10, zeros));
|
|
5029
|
+
}
|
|
5030
|
+
function toQuantifier(digits) {
|
|
5031
|
+
let [start = 0, stop = ""] = digits;
|
|
5032
|
+
if (stop || start > 1) {
|
|
5033
|
+
return `{${start + (stop ? "," + stop : "")}}`;
|
|
5034
|
+
}
|
|
5035
|
+
return "";
|
|
5036
|
+
}
|
|
5037
|
+
function toCharacterClass(a, b, options) {
|
|
5038
|
+
return `[${a}${b - a === 1 ? "" : "-"}${b}]`;
|
|
5039
|
+
}
|
|
5040
|
+
function hasPadding(str) {
|
|
5041
|
+
return /^-?(0+)\d/.test(str);
|
|
5042
|
+
}
|
|
5043
|
+
function padZeros(value, tok, options) {
|
|
5044
|
+
if (!tok.isPadded) {
|
|
5045
|
+
return value;
|
|
5046
|
+
}
|
|
5047
|
+
let diff = Math.abs(tok.maxLen - String(value).length);
|
|
5048
|
+
let relax = options.relaxZeros !== false;
|
|
5049
|
+
switch (diff) {
|
|
5050
|
+
case 0:
|
|
5051
|
+
return "";
|
|
5052
|
+
case 1:
|
|
5053
|
+
return relax ? "0?" : "0";
|
|
5054
|
+
case 2:
|
|
5055
|
+
return relax ? "0{0,2}" : "00";
|
|
5056
|
+
default: {
|
|
5057
|
+
return relax ? `0{0,${diff}}` : `0{${diff}}`;
|
|
5058
|
+
}
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
toRegexRange.cache = {};
|
|
5062
|
+
toRegexRange.clearCache = () => (toRegexRange.cache = {});
|
|
5063
|
+
module.exports = toRegexRange;
|
|
5064
|
+
},
|
|
5065
|
+
115: (module) => {
|
|
5066
|
+
module.exports = eval("require")("supports-color");
|
|
5067
|
+
},
|
|
5068
|
+
2613: (module) => {
|
|
5069
|
+
"use strict";
|
|
5070
|
+
module.exports = require("assert");
|
|
5071
|
+
},
|
|
5072
|
+
8611: (module) => {
|
|
5073
|
+
"use strict";
|
|
5074
|
+
module.exports = require("http");
|
|
5075
|
+
},
|
|
5076
|
+
5692: (module) => {
|
|
5077
|
+
"use strict";
|
|
5078
|
+
module.exports = require("https");
|
|
5079
|
+
},
|
|
5080
|
+
6928: (module) => {
|
|
5081
|
+
"use strict";
|
|
5082
|
+
module.exports = require("path");
|
|
5083
|
+
},
|
|
5084
|
+
3480: (module) => {
|
|
5085
|
+
"use strict";
|
|
5086
|
+
module.exports = require("querystring");
|
|
5087
|
+
},
|
|
5088
|
+
2203: (module) => {
|
|
5089
|
+
"use strict";
|
|
5090
|
+
module.exports = require("stream");
|
|
5091
|
+
},
|
|
5092
|
+
2018: (module) => {
|
|
5093
|
+
"use strict";
|
|
5094
|
+
module.exports = require("tty");
|
|
5095
|
+
},
|
|
5096
|
+
7016: (module) => {
|
|
5097
|
+
"use strict";
|
|
5098
|
+
module.exports = require("url");
|
|
5099
|
+
},
|
|
5100
|
+
9023: (module) => {
|
|
5101
|
+
"use strict";
|
|
5102
|
+
module.exports = require("util");
|
|
5103
|
+
},
|
|
5104
|
+
3106: (module) => {
|
|
5105
|
+
"use strict";
|
|
5106
|
+
module.exports = require("zlib");
|
|
5107
|
+
},
|
|
5108
|
+
1783: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5109
|
+
"use strict";
|
|
5110
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5111
|
+
exports.verifyConfig = verifyConfig;
|
|
5112
|
+
const errors_1 = __nccwpck_require__(4006);
|
|
5113
|
+
function verifyConfig(options) {
|
|
5114
|
+
if (!options.target && !options.router) {
|
|
5115
|
+
throw new Error(errors_1.ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING);
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
},
|
|
5119
|
+
5342: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5120
|
+
"use strict";
|
|
5121
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5122
|
+
exports.Debug = void 0;
|
|
5123
|
+
const createDebug = __nccwpck_require__(6675);
|
|
5124
|
+
exports.Debug = createDebug("http-proxy-middleware");
|
|
5125
|
+
},
|
|
5126
|
+
4006: (__unused_webpack_module, exports) => {
|
|
5127
|
+
"use strict";
|
|
5128
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5129
|
+
exports.ERRORS = void 0;
|
|
5130
|
+
var ERRORS;
|
|
5131
|
+
(function (ERRORS) {
|
|
5132
|
+
ERRORS["ERR_CONFIG_FACTORY_TARGET_MISSING"] =
|
|
5133
|
+
'[HPM] Missing "target" option. Example: {target: "http://www.example.org"}';
|
|
5134
|
+
ERRORS["ERR_CONTEXT_MATCHER_GENERIC"] =
|
|
5135
|
+
'[HPM] Invalid pathFilter. Expecting something like: "/api" or ["/api", "/ajax"]';
|
|
5136
|
+
ERRORS["ERR_CONTEXT_MATCHER_INVALID_ARRAY"] =
|
|
5137
|
+
'[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"].';
|
|
5138
|
+
ERRORS["ERR_PATH_REWRITER_CONFIG"] =
|
|
5139
|
+
"[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function";
|
|
5140
|
+
})(ERRORS || (exports.ERRORS = ERRORS = {}));
|
|
5141
|
+
},
|
|
5142
|
+
1179: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5143
|
+
"use strict";
|
|
5144
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5145
|
+
exports.createProxyMiddleware = createProxyMiddleware;
|
|
5146
|
+
const http_proxy_middleware_1 = __nccwpck_require__(3501);
|
|
5147
|
+
function createProxyMiddleware(options) {
|
|
5148
|
+
const { middleware } = new http_proxy_middleware_1.HttpProxyMiddleware(
|
|
5149
|
+
options,
|
|
5150
|
+
);
|
|
5151
|
+
return middleware;
|
|
5152
|
+
}
|
|
5153
|
+
},
|
|
5154
|
+
4828: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5155
|
+
"use strict";
|
|
5156
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5157
|
+
exports.getPlugins = getPlugins;
|
|
5158
|
+
const default_1 = __nccwpck_require__(3024);
|
|
5159
|
+
function getPlugins(options) {
|
|
5160
|
+
const maybeErrorResponsePlugin = options.on?.error
|
|
5161
|
+
? []
|
|
5162
|
+
: [default_1.errorResponsePlugin];
|
|
5163
|
+
const defaultPlugins = options.ejectPlugins
|
|
5164
|
+
? []
|
|
5165
|
+
: [
|
|
5166
|
+
default_1.debugProxyErrorsPlugin,
|
|
5167
|
+
default_1.proxyEventsPlugin,
|
|
5168
|
+
default_1.loggerPlugin,
|
|
5169
|
+
...maybeErrorResponsePlugin,
|
|
5170
|
+
];
|
|
5171
|
+
const userPlugins = options.plugins ?? [];
|
|
5172
|
+
return [...defaultPlugins, ...userPlugins];
|
|
5173
|
+
}
|
|
5174
|
+
},
|
|
5175
|
+
2609: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5176
|
+
"use strict";
|
|
5177
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5178
|
+
exports.fixRequestBody = fixRequestBody;
|
|
5179
|
+
const querystring = __nccwpck_require__(3480);
|
|
5180
|
+
function fixRequestBody(proxyReq, req) {
|
|
5181
|
+
if (req.readableLength !== 0) {
|
|
5182
|
+
return;
|
|
5183
|
+
}
|
|
5184
|
+
const requestBody = req.body;
|
|
5185
|
+
if (!requestBody) {
|
|
5186
|
+
return;
|
|
5187
|
+
}
|
|
5188
|
+
const contentType = proxyReq.getHeader("Content-Type");
|
|
5189
|
+
if (!contentType) {
|
|
5190
|
+
return;
|
|
5191
|
+
}
|
|
5192
|
+
const writeBody = (bodyData) => {
|
|
5193
|
+
proxyReq.setHeader("Content-Length", Buffer.byteLength(bodyData));
|
|
5194
|
+
proxyReq.write(bodyData);
|
|
5195
|
+
};
|
|
5196
|
+
if (
|
|
5197
|
+
contentType.includes("application/json") ||
|
|
5198
|
+
contentType.includes("+json")
|
|
5199
|
+
) {
|
|
5200
|
+
writeBody(JSON.stringify(requestBody));
|
|
5201
|
+
} else if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
5202
|
+
writeBody(querystring.stringify(requestBody));
|
|
5203
|
+
} else if (contentType.includes("multipart/form-data")) {
|
|
5204
|
+
writeBody(handlerFormDataBodyData(contentType, requestBody));
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
function handlerFormDataBodyData(contentType, data) {
|
|
5208
|
+
const boundary = contentType.replace(/^.*boundary=(.*)$/, "$1");
|
|
5209
|
+
let str = "";
|
|
5210
|
+
for (const [key, value] of Object.entries(data)) {
|
|
5211
|
+
str += `--${boundary}\r\nContent-Disposition: form-data; name="${key}"\r\n\r\n${value}\r\n`;
|
|
5212
|
+
}
|
|
5213
|
+
return str;
|
|
5214
|
+
}
|
|
5215
|
+
},
|
|
5216
|
+
3623: function (__unused_webpack_module, exports, __nccwpck_require__) {
|
|
5217
|
+
"use strict";
|
|
5218
|
+
var __createBinding =
|
|
5219
|
+
(this && this.__createBinding) ||
|
|
5220
|
+
(Object.create
|
|
5221
|
+
? function (o, m, k, k2) {
|
|
5222
|
+
if (k2 === undefined) k2 = k;
|
|
5223
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5224
|
+
if (
|
|
5225
|
+
!desc ||
|
|
5226
|
+
("get" in desc
|
|
5227
|
+
? !m.__esModule
|
|
5228
|
+
: desc.writable || desc.configurable)
|
|
5229
|
+
) {
|
|
5230
|
+
desc = {
|
|
5231
|
+
enumerable: true,
|
|
5232
|
+
get: function () {
|
|
5233
|
+
return m[k];
|
|
5234
|
+
},
|
|
5235
|
+
};
|
|
5236
|
+
}
|
|
5237
|
+
Object.defineProperty(o, k2, desc);
|
|
5238
|
+
}
|
|
5239
|
+
: function (o, m, k, k2) {
|
|
5240
|
+
if (k2 === undefined) k2 = k;
|
|
5241
|
+
o[k2] = m[k];
|
|
5242
|
+
});
|
|
5243
|
+
var __exportStar =
|
|
5244
|
+
(this && this.__exportStar) ||
|
|
5245
|
+
function (m, exports) {
|
|
5246
|
+
for (var p in m)
|
|
5247
|
+
if (
|
|
5248
|
+
p !== "default" &&
|
|
5249
|
+
!Object.prototype.hasOwnProperty.call(exports, p)
|
|
5250
|
+
)
|
|
5251
|
+
__createBinding(exports, m, p);
|
|
5252
|
+
};
|
|
5253
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5254
|
+
__exportStar(__nccwpck_require__(1310), exports);
|
|
5255
|
+
},
|
|
5256
|
+
1310: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5257
|
+
"use strict";
|
|
5258
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5259
|
+
exports.fixRequestBody = exports.responseInterceptor = void 0;
|
|
5260
|
+
var response_interceptor_1 = __nccwpck_require__(4566);
|
|
5261
|
+
Object.defineProperty(exports, "responseInterceptor", {
|
|
5262
|
+
enumerable: true,
|
|
5263
|
+
get: function () {
|
|
5264
|
+
return response_interceptor_1.responseInterceptor;
|
|
5265
|
+
},
|
|
5266
|
+
});
|
|
5267
|
+
var fix_request_body_1 = __nccwpck_require__(2609);
|
|
5268
|
+
Object.defineProperty(exports, "fixRequestBody", {
|
|
5269
|
+
enumerable: true,
|
|
5270
|
+
get: function () {
|
|
5271
|
+
return fix_request_body_1.fixRequestBody;
|
|
5272
|
+
},
|
|
5273
|
+
});
|
|
5274
|
+
},
|
|
5275
|
+
4566: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5276
|
+
"use strict";
|
|
5277
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5278
|
+
exports.responseInterceptor = responseInterceptor;
|
|
5279
|
+
const zlib = __nccwpck_require__(3106);
|
|
5280
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
5281
|
+
const function_1 = __nccwpck_require__(7);
|
|
5282
|
+
const debug = debug_1.Debug.extend("response-interceptor");
|
|
5283
|
+
function responseInterceptor(interceptor) {
|
|
5284
|
+
return async function proxyResResponseInterceptor(proxyRes, req, res) {
|
|
5285
|
+
debug("intercept proxy response");
|
|
5286
|
+
const originalProxyRes = proxyRes;
|
|
5287
|
+
let buffer = Buffer.from("", "utf8");
|
|
5288
|
+
const _proxyRes = decompress(
|
|
5289
|
+
proxyRes,
|
|
5290
|
+
proxyRes.headers["content-encoding"],
|
|
5291
|
+
);
|
|
5292
|
+
_proxyRes.on(
|
|
5293
|
+
"data",
|
|
5294
|
+
(chunk) => (buffer = Buffer.concat([buffer, chunk])),
|
|
5295
|
+
);
|
|
5296
|
+
_proxyRes.on("end", async () => {
|
|
5297
|
+
copyHeaders(proxyRes, res);
|
|
5298
|
+
debug(
|
|
5299
|
+
"call interceptor function: %s",
|
|
5300
|
+
(0, function_1.getFunctionName)(interceptor),
|
|
5301
|
+
);
|
|
5302
|
+
const interceptedBuffer = Buffer.from(
|
|
5303
|
+
await interceptor(buffer, originalProxyRes, req, res),
|
|
5304
|
+
);
|
|
5305
|
+
debug(
|
|
5306
|
+
"set content-length: %s",
|
|
5307
|
+
Buffer.byteLength(interceptedBuffer, "utf8"),
|
|
5308
|
+
);
|
|
5309
|
+
res.setHeader(
|
|
5310
|
+
"content-length",
|
|
5311
|
+
Buffer.byteLength(interceptedBuffer, "utf8"),
|
|
5312
|
+
);
|
|
5313
|
+
debug("write intercepted response");
|
|
5314
|
+
res.write(interceptedBuffer);
|
|
5315
|
+
res.end();
|
|
5316
|
+
});
|
|
5317
|
+
_proxyRes.on("error", (error) => {
|
|
5318
|
+
res.end(`Error fetching proxied request: ${error.message}`);
|
|
5319
|
+
});
|
|
5320
|
+
};
|
|
5321
|
+
}
|
|
5322
|
+
function decompress(proxyRes, contentEncoding) {
|
|
5323
|
+
let _proxyRes = proxyRes;
|
|
5324
|
+
let decompress;
|
|
5325
|
+
switch (contentEncoding) {
|
|
5326
|
+
case "gzip":
|
|
5327
|
+
decompress = zlib.createGunzip();
|
|
5328
|
+
break;
|
|
5329
|
+
case "br":
|
|
5330
|
+
decompress = zlib.createBrotliDecompress();
|
|
5331
|
+
break;
|
|
5332
|
+
case "deflate":
|
|
5333
|
+
decompress = zlib.createInflate();
|
|
5334
|
+
break;
|
|
5335
|
+
default:
|
|
5336
|
+
break;
|
|
5337
|
+
}
|
|
5338
|
+
if (decompress) {
|
|
5339
|
+
debug(
|
|
5340
|
+
`decompress proxy response with 'content-encoding': %s`,
|
|
5341
|
+
contentEncoding,
|
|
5342
|
+
);
|
|
5343
|
+
_proxyRes.pipe(decompress);
|
|
5344
|
+
_proxyRes = decompress;
|
|
5345
|
+
}
|
|
5346
|
+
return _proxyRes;
|
|
5347
|
+
}
|
|
5348
|
+
function copyHeaders(originalResponse, response) {
|
|
5349
|
+
debug("copy original response headers");
|
|
5350
|
+
response.statusCode = originalResponse.statusCode;
|
|
5351
|
+
response.statusMessage = originalResponse.statusMessage;
|
|
5352
|
+
if (response.setHeader) {
|
|
5353
|
+
let keys = Object.keys(originalResponse.headers);
|
|
5354
|
+
keys = keys.filter(
|
|
5355
|
+
(key) => !["content-encoding", "transfer-encoding"].includes(key),
|
|
5356
|
+
);
|
|
5357
|
+
keys.forEach((key) => {
|
|
5358
|
+
let value = originalResponse.headers[key];
|
|
5359
|
+
if (key === "set-cookie") {
|
|
5360
|
+
value = Array.isArray(value) ? value : [value];
|
|
5361
|
+
value = value.map((x) => x.replace(/Domain=[^;]+?/i, ""));
|
|
5362
|
+
}
|
|
5363
|
+
response.setHeader(key, value);
|
|
5364
|
+
});
|
|
5365
|
+
} else {
|
|
5366
|
+
response.headers = originalResponse.headers;
|
|
5367
|
+
}
|
|
5368
|
+
}
|
|
5369
|
+
},
|
|
5370
|
+
3501: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5371
|
+
"use strict";
|
|
5372
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5373
|
+
exports.HttpProxyMiddleware = void 0;
|
|
5374
|
+
const httpProxy = __nccwpck_require__(1929);
|
|
5375
|
+
const configuration_1 = __nccwpck_require__(1783);
|
|
5376
|
+
const get_plugins_1 = __nccwpck_require__(4828);
|
|
5377
|
+
const path_filter_1 = __nccwpck_require__(3833);
|
|
5378
|
+
const PathRewriter = __nccwpck_require__(3461);
|
|
5379
|
+
const Router = __nccwpck_require__(1976);
|
|
5380
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
5381
|
+
const function_1 = __nccwpck_require__(7);
|
|
5382
|
+
const logger_1 = __nccwpck_require__(2001);
|
|
5383
|
+
class HttpProxyMiddleware {
|
|
5384
|
+
constructor(options) {
|
|
5385
|
+
this.wsInternalSubscribed = false;
|
|
5386
|
+
this.serverOnCloseSubscribed = false;
|
|
5387
|
+
this.middleware = async (req, res, next) => {
|
|
5388
|
+
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
5389
|
+
try {
|
|
5390
|
+
const activeProxyOptions = await this.prepareProxyRequest(req);
|
|
5391
|
+
(0, debug_1.Debug)(
|
|
5392
|
+
`proxy request to target: %O`,
|
|
5393
|
+
activeProxyOptions.target,
|
|
5394
|
+
);
|
|
5395
|
+
this.proxy.web(req, res, activeProxyOptions);
|
|
5396
|
+
} catch (err) {
|
|
5397
|
+
next?.(err);
|
|
5398
|
+
}
|
|
5399
|
+
} else {
|
|
5400
|
+
next?.();
|
|
4750
5401
|
}
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
5402
|
+
const server = (req.socket ?? req.connection)?.server;
|
|
5403
|
+
if (server && !this.serverOnCloseSubscribed) {
|
|
5404
|
+
server.on("close", () => {
|
|
5405
|
+
(0, debug_1.Debug)(
|
|
5406
|
+
"server close signal received: closing proxy server",
|
|
5407
|
+
);
|
|
5408
|
+
this.proxy.close();
|
|
5409
|
+
});
|
|
5410
|
+
this.serverOnCloseSubscribed = true;
|
|
4758
5411
|
}
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
4762
|
-
isGlob = token.isGlob = true;
|
|
4763
|
-
finished = true;
|
|
4764
|
-
if (scanToEnd === true) {
|
|
4765
|
-
continue;
|
|
5412
|
+
if (this.proxyOptions.ws === true) {
|
|
5413
|
+
this.catchUpgradeRequest(server);
|
|
4766
5414
|
}
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
5415
|
+
};
|
|
5416
|
+
this.catchUpgradeRequest = (server) => {
|
|
5417
|
+
if (!this.wsInternalSubscribed) {
|
|
5418
|
+
(0, debug_1.Debug)("subscribing to server upgrade event");
|
|
5419
|
+
server.on("upgrade", this.handleUpgrade);
|
|
5420
|
+
this.wsInternalSubscribed = true;
|
|
5421
|
+
}
|
|
5422
|
+
};
|
|
5423
|
+
this.handleUpgrade = async (req, socket, head) => {
|
|
5424
|
+
try {
|
|
5425
|
+
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
5426
|
+
const activeProxyOptions = await this.prepareProxyRequest(req);
|
|
5427
|
+
this.proxy.ws(req, socket, head, activeProxyOptions);
|
|
5428
|
+
(0, debug_1.Debug)(
|
|
5429
|
+
"server upgrade event received. Proxying WebSocket",
|
|
5430
|
+
);
|
|
4781
5431
|
}
|
|
5432
|
+
} catch (err) {
|
|
5433
|
+
this.proxy.emit("error", err, req, socket);
|
|
4782
5434
|
}
|
|
4783
|
-
|
|
4784
|
-
|
|
5435
|
+
};
|
|
5436
|
+
this.shouldProxy = (pathFilter, req) => {
|
|
5437
|
+
try {
|
|
5438
|
+
return (0, path_filter_1.matchPathFilter)(
|
|
5439
|
+
pathFilter,
|
|
5440
|
+
req.url,
|
|
5441
|
+
req,
|
|
5442
|
+
);
|
|
5443
|
+
} catch (err) {
|
|
5444
|
+
(0, debug_1.Debug)(
|
|
5445
|
+
"Error: matchPathFilter() called with request url: ",
|
|
5446
|
+
`"${req.url}"`,
|
|
5447
|
+
);
|
|
5448
|
+
this.logger.error(err);
|
|
5449
|
+
return false;
|
|
4785
5450
|
}
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
code === CHAR_EXCLAMATION_MARK &&
|
|
4791
|
-
index === start
|
|
4792
|
-
) {
|
|
4793
|
-
negated = token.negated = true;
|
|
4794
|
-
start++;
|
|
4795
|
-
continue;
|
|
4796
|
-
}
|
|
4797
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
4798
|
-
isGlob = token.isGlob = true;
|
|
4799
|
-
if (scanToEnd === true) {
|
|
4800
|
-
while (eos() !== true && (code = advance())) {
|
|
4801
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
4802
|
-
backslashes = token.backslashes = true;
|
|
4803
|
-
code = advance();
|
|
4804
|
-
continue;
|
|
4805
|
-
}
|
|
4806
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
4807
|
-
finished = true;
|
|
4808
|
-
break;
|
|
4809
|
-
}
|
|
4810
|
-
}
|
|
4811
|
-
continue;
|
|
5451
|
+
};
|
|
5452
|
+
this.prepareProxyRequest = async (req) => {
|
|
5453
|
+
if (this.middleware.__LEGACY_HTTP_PROXY_MIDDLEWARE__) {
|
|
5454
|
+
req.url = req.originalUrl || req.url;
|
|
4812
5455
|
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
5456
|
+
const newProxyOptions = Object.assign({}, this.proxyOptions);
|
|
5457
|
+
await this.applyRouter(req, newProxyOptions);
|
|
5458
|
+
await this.applyPathRewrite(req, this.pathRewriter);
|
|
5459
|
+
return newProxyOptions;
|
|
5460
|
+
};
|
|
5461
|
+
this.applyRouter = async (req, options) => {
|
|
5462
|
+
let newTarget;
|
|
5463
|
+
if (options.router) {
|
|
5464
|
+
newTarget = await Router.getTarget(req, options);
|
|
5465
|
+
if (newTarget) {
|
|
5466
|
+
(0, debug_1.Debug)('router new target: "%s"', newTarget);
|
|
5467
|
+
options.target = newTarget;
|
|
5468
|
+
}
|
|
4819
5469
|
}
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
let base = str;
|
|
4828
|
-
let prefix = "";
|
|
4829
|
-
let glob = "";
|
|
4830
|
-
if (start > 0) {
|
|
4831
|
-
prefix = str.slice(0, start);
|
|
4832
|
-
str = str.slice(start);
|
|
4833
|
-
lastIndex -= start;
|
|
4834
|
-
}
|
|
4835
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
4836
|
-
base = str.slice(0, lastIndex);
|
|
4837
|
-
glob = str.slice(lastIndex);
|
|
4838
|
-
} else if (isGlob === true) {
|
|
4839
|
-
base = "";
|
|
4840
|
-
glob = str;
|
|
4841
|
-
} else {
|
|
4842
|
-
base = str;
|
|
4843
|
-
}
|
|
4844
|
-
if (base && base !== "" && base !== "/" && base !== str) {
|
|
4845
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
4846
|
-
base = base.slice(0, -1);
|
|
4847
|
-
}
|
|
4848
|
-
}
|
|
4849
|
-
if (opts.unescape === true) {
|
|
4850
|
-
if (glob) glob = utils.removeBackslashes(glob);
|
|
4851
|
-
if (base && backslashes === true) {
|
|
4852
|
-
base = utils.removeBackslashes(base);
|
|
4853
|
-
}
|
|
4854
|
-
}
|
|
4855
|
-
const state = {
|
|
4856
|
-
prefix,
|
|
4857
|
-
input,
|
|
4858
|
-
start,
|
|
4859
|
-
base,
|
|
4860
|
-
glob,
|
|
4861
|
-
isBrace,
|
|
4862
|
-
isBracket,
|
|
4863
|
-
isGlob,
|
|
4864
|
-
isExtglob,
|
|
4865
|
-
isGlobstar,
|
|
4866
|
-
negated,
|
|
4867
|
-
negatedExtglob,
|
|
4868
|
-
};
|
|
4869
|
-
if (opts.tokens === true) {
|
|
4870
|
-
state.maxDepth = 0;
|
|
4871
|
-
if (!isPathSeparator(code)) {
|
|
4872
|
-
tokens.push(token);
|
|
4873
|
-
}
|
|
4874
|
-
state.tokens = tokens;
|
|
4875
|
-
}
|
|
4876
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
4877
|
-
let prevIndex;
|
|
4878
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
4879
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
4880
|
-
const i = slashes[idx];
|
|
4881
|
-
const value = input.slice(n, i);
|
|
4882
|
-
if (opts.tokens) {
|
|
4883
|
-
if (idx === 0 && start !== 0) {
|
|
4884
|
-
tokens[idx].isPrefix = true;
|
|
4885
|
-
tokens[idx].value = prefix;
|
|
5470
|
+
};
|
|
5471
|
+
this.applyPathRewrite = async (req, pathRewriter) => {
|
|
5472
|
+
if (pathRewriter) {
|
|
5473
|
+
const path = await pathRewriter(req.url, req);
|
|
5474
|
+
if (typeof path === "string") {
|
|
5475
|
+
(0, debug_1.Debug)("pathRewrite new path: %s", req.url);
|
|
5476
|
+
req.url = path;
|
|
4886
5477
|
} else {
|
|
4887
|
-
|
|
5478
|
+
(0, debug_1.Debug)(
|
|
5479
|
+
"pathRewrite: no rewritten path found: %s",
|
|
5480
|
+
req.url,
|
|
5481
|
+
);
|
|
4888
5482
|
}
|
|
4889
|
-
depth(tokens[idx]);
|
|
4890
|
-
state.maxDepth += tokens[idx].depth;
|
|
4891
|
-
}
|
|
4892
|
-
if (idx !== 0 || value !== "") {
|
|
4893
|
-
parts.push(value);
|
|
4894
|
-
}
|
|
4895
|
-
prevIndex = i;
|
|
4896
|
-
}
|
|
4897
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
4898
|
-
const value = input.slice(prevIndex + 1);
|
|
4899
|
-
parts.push(value);
|
|
4900
|
-
if (opts.tokens) {
|
|
4901
|
-
tokens[tokens.length - 1].value = value;
|
|
4902
|
-
depth(tokens[tokens.length - 1]);
|
|
4903
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
4904
5483
|
}
|
|
4905
|
-
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
REGEX_SPECIAL_CHARS,
|
|
4921
|
-
REGEX_SPECIAL_CHARS_GLOBAL,
|
|
4922
|
-
} = __nccwpck_require__(7054);
|
|
4923
|
-
exports.isObject = (val) =>
|
|
4924
|
-
val !== null && typeof val === "object" && !Array.isArray(val);
|
|
4925
|
-
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
4926
|
-
exports.isRegexChar = (str) =>
|
|
4927
|
-
str.length === 1 && exports.hasRegexChars(str);
|
|
4928
|
-
exports.escapeRegex = (str) =>
|
|
4929
|
-
str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
4930
|
-
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
4931
|
-
exports.removeBackslashes = (str) =>
|
|
4932
|
-
str.replace(REGEX_REMOVE_BACKSLASH, (match) =>
|
|
4933
|
-
match === "\\" ? "" : match,
|
|
4934
|
-
);
|
|
4935
|
-
exports.supportsLookbehinds = () => {
|
|
4936
|
-
const segs = process.version.slice(1).split(".").map(Number);
|
|
4937
|
-
if (
|
|
4938
|
-
(segs.length === 3 && segs[0] >= 9) ||
|
|
4939
|
-
(segs[0] === 8 && segs[1] >= 10)
|
|
4940
|
-
) {
|
|
4941
|
-
return true;
|
|
4942
|
-
}
|
|
4943
|
-
return false;
|
|
4944
|
-
};
|
|
4945
|
-
exports.isWindows = (options) => {
|
|
4946
|
-
if (options && typeof options.windows === "boolean") {
|
|
4947
|
-
return options.windows;
|
|
4948
|
-
}
|
|
4949
|
-
return win32 === true || path.sep === "\\";
|
|
4950
|
-
};
|
|
4951
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
4952
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
4953
|
-
if (idx === -1) return input;
|
|
4954
|
-
if (input[idx - 1] === "\\")
|
|
4955
|
-
return exports.escapeLast(input, char, idx - 1);
|
|
4956
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
4957
|
-
};
|
|
4958
|
-
exports.removePrefix = (input, state = {}) => {
|
|
4959
|
-
let output = input;
|
|
4960
|
-
if (output.startsWith("./")) {
|
|
4961
|
-
output = output.slice(2);
|
|
4962
|
-
state.prefix = "./";
|
|
5484
|
+
};
|
|
5485
|
+
(0, configuration_1.verifyConfig)(options);
|
|
5486
|
+
this.proxyOptions = options;
|
|
5487
|
+
this.logger = (0, logger_1.getLogger)(options);
|
|
5488
|
+
(0, debug_1.Debug)(`create proxy server`);
|
|
5489
|
+
this.proxy = httpProxy.createProxyServer({});
|
|
5490
|
+
this.registerPlugins(this.proxy, this.proxyOptions);
|
|
5491
|
+
this.pathRewriter = PathRewriter.createPathRewriter(
|
|
5492
|
+
this.proxyOptions.pathRewrite,
|
|
5493
|
+
);
|
|
5494
|
+
this.middleware.upgrade = (req, socket, head) => {
|
|
5495
|
+
if (!this.wsInternalSubscribed) {
|
|
5496
|
+
this.handleUpgrade(req, socket, head);
|
|
5497
|
+
}
|
|
5498
|
+
};
|
|
4963
5499
|
}
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
5500
|
+
registerPlugins(proxy, options) {
|
|
5501
|
+
const plugins = (0, get_plugins_1.getPlugins)(options);
|
|
5502
|
+
plugins.forEach((plugin) => {
|
|
5503
|
+
(0, debug_1.Debug)(
|
|
5504
|
+
`register plugin: "${(0, function_1.getFunctionName)(plugin)}"`,
|
|
5505
|
+
);
|
|
5506
|
+
plugin(proxy, options);
|
|
5507
|
+
});
|
|
4972
5508
|
}
|
|
4973
|
-
|
|
4974
|
-
|
|
5509
|
+
}
|
|
5510
|
+
exports.HttpProxyMiddleware = HttpProxyMiddleware;
|
|
4975
5511
|
},
|
|
4976
|
-
|
|
5512
|
+
6289: function (__unused_webpack_module, exports, __nccwpck_require__) {
|
|
4977
5513
|
"use strict";
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
5514
|
+
var __createBinding =
|
|
5515
|
+
(this && this.__createBinding) ||
|
|
5516
|
+
(Object.create
|
|
5517
|
+
? function (o, m, k, k2) {
|
|
5518
|
+
if (k2 === undefined) k2 = k;
|
|
5519
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5520
|
+
if (
|
|
5521
|
+
!desc ||
|
|
5522
|
+
("get" in desc
|
|
5523
|
+
? !m.__esModule
|
|
5524
|
+
: desc.writable || desc.configurable)
|
|
5525
|
+
) {
|
|
5526
|
+
desc = {
|
|
5527
|
+
enumerable: true,
|
|
5528
|
+
get: function () {
|
|
5529
|
+
return m[k];
|
|
5530
|
+
},
|
|
5531
|
+
};
|
|
5532
|
+
}
|
|
5533
|
+
Object.defineProperty(o, k2, desc);
|
|
5534
|
+
}
|
|
5535
|
+
: function (o, m, k, k2) {
|
|
5536
|
+
if (k2 === undefined) k2 = k;
|
|
5537
|
+
o[k2] = m[k];
|
|
5538
|
+
});
|
|
5539
|
+
var __exportStar =
|
|
5540
|
+
(this && this.__exportStar) ||
|
|
5541
|
+
function (m, exports) {
|
|
5542
|
+
for (var p in m)
|
|
5543
|
+
if (
|
|
5544
|
+
p !== "default" &&
|
|
5545
|
+
!Object.prototype.hasOwnProperty.call(exports, p)
|
|
5546
|
+
)
|
|
5547
|
+
__createBinding(exports, m, p);
|
|
5548
|
+
};
|
|
5549
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5550
|
+
__exportStar(__nccwpck_require__(1179), exports);
|
|
5551
|
+
__exportStar(__nccwpck_require__(3623), exports);
|
|
5552
|
+
__exportStar(__nccwpck_require__(3024), exports);
|
|
5553
|
+
__exportStar(__nccwpck_require__(4233), exports);
|
|
4998
5554
|
},
|
|
4999
|
-
|
|
5555
|
+
4041: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5000
5556
|
"use strict";
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5557
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5558
|
+
exports.legacyCreateProxyMiddleware = legacyCreateProxyMiddleware;
|
|
5559
|
+
const factory_1 = __nccwpck_require__(1179);
|
|
5560
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
5561
|
+
const options_adapter_1 = __nccwpck_require__(3357);
|
|
5562
|
+
const debug = debug_1.Debug.extend("legacy-create-proxy-middleware");
|
|
5563
|
+
function legacyCreateProxyMiddleware(legacyContext, legacyOptions) {
|
|
5564
|
+
debug("init");
|
|
5565
|
+
const options = (0, options_adapter_1.legacyOptionsAdapter)(
|
|
5566
|
+
legacyContext,
|
|
5567
|
+
legacyOptions,
|
|
5568
|
+
);
|
|
5569
|
+
const proxyMiddleware = (0, factory_1.createProxyMiddleware)(options);
|
|
5570
|
+
debug("add marker for patching req.url (old behavior)");
|
|
5571
|
+
proxyMiddleware.__LEGACY_HTTP_PROXY_MIDDLEWARE__ = true;
|
|
5572
|
+
return proxyMiddleware;
|
|
5573
|
+
}
|
|
5574
|
+
},
|
|
5575
|
+
4233: function (__unused_webpack_module, exports, __nccwpck_require__) {
|
|
5576
|
+
"use strict";
|
|
5577
|
+
var __createBinding =
|
|
5578
|
+
(this && this.__createBinding) ||
|
|
5579
|
+
(Object.create
|
|
5580
|
+
? function (o, m, k, k2) {
|
|
5581
|
+
if (k2 === undefined) k2 = k;
|
|
5582
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5583
|
+
if (
|
|
5584
|
+
!desc ||
|
|
5585
|
+
("get" in desc
|
|
5586
|
+
? !m.__esModule
|
|
5587
|
+
: desc.writable || desc.configurable)
|
|
5588
|
+
) {
|
|
5589
|
+
desc = {
|
|
5590
|
+
enumerable: true,
|
|
5591
|
+
get: function () {
|
|
5592
|
+
return m[k];
|
|
5593
|
+
},
|
|
5594
|
+
};
|
|
5595
|
+
}
|
|
5596
|
+
Object.defineProperty(o, k2, desc);
|
|
5597
|
+
}
|
|
5598
|
+
: function (o, m, k, k2) {
|
|
5599
|
+
if (k2 === undefined) k2 = k;
|
|
5600
|
+
o[k2] = m[k];
|
|
5601
|
+
});
|
|
5602
|
+
var __exportStar =
|
|
5603
|
+
(this && this.__exportStar) ||
|
|
5604
|
+
function (m, exports) {
|
|
5605
|
+
for (var p in m)
|
|
5606
|
+
if (
|
|
5607
|
+
p !== "default" &&
|
|
5608
|
+
!Object.prototype.hasOwnProperty.call(exports, p)
|
|
5609
|
+
)
|
|
5610
|
+
__createBinding(exports, m, p);
|
|
5611
|
+
};
|
|
5612
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5613
|
+
__exportStar(__nccwpck_require__(2328), exports);
|
|
5614
|
+
},
|
|
5615
|
+
3357: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5616
|
+
"use strict";
|
|
5617
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5618
|
+
exports.legacyOptionsAdapter = legacyOptionsAdapter;
|
|
5619
|
+
const url = __nccwpck_require__(7016);
|
|
5620
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
5621
|
+
const logger_1 = __nccwpck_require__(2001);
|
|
5622
|
+
const debug = debug_1.Debug.extend("legacy-options-adapter");
|
|
5623
|
+
const proxyEventMap = {
|
|
5624
|
+
onError: "error",
|
|
5625
|
+
onProxyReq: "proxyReq",
|
|
5626
|
+
onProxyRes: "proxyRes",
|
|
5627
|
+
onProxyReqWs: "proxyReqWs",
|
|
5628
|
+
onOpen: "open",
|
|
5629
|
+
onClose: "close",
|
|
5630
|
+
};
|
|
5631
|
+
function legacyOptionsAdapter(legacyContext, legacyOptions) {
|
|
5632
|
+
let options = {};
|
|
5633
|
+
let logger;
|
|
5634
|
+
if (
|
|
5635
|
+
typeof legacyContext === "string" &&
|
|
5636
|
+
!!url.parse(legacyContext).host
|
|
5637
|
+
) {
|
|
5638
|
+
throw new Error(
|
|
5639
|
+
`Shorthand syntax is removed from legacyCreateProxyMiddleware().\n Please use "legacyCreateProxyMiddleware({ target: 'http://www.example.org' })" instead.\n\n More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-shorthand-usage\n `,
|
|
5011
5640
|
);
|
|
5012
5641
|
}
|
|
5013
|
-
if (
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
"
|
|
5642
|
+
if (legacyContext && legacyOptions) {
|
|
5643
|
+
debug("map legacy context/filter to options.pathFilter");
|
|
5644
|
+
options = { ...legacyOptions, pathFilter: legacyContext };
|
|
5645
|
+
logger = getLegacyLogger(options);
|
|
5646
|
+
logger.warn(
|
|
5647
|
+
`[http-proxy-middleware] Legacy "context" argument is deprecated. Migrate your "context" to "options.pathFilter":\n\n const options = {\n pathFilter: '${legacyContext}',\n }\n\n More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-context-argument\n `,
|
|
5019
5648
|
);
|
|
5020
|
-
}
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
return `(${result})`;
|
|
5040
|
-
}
|
|
5041
|
-
if (opts.wrap === false) {
|
|
5042
|
-
return result;
|
|
5043
|
-
}
|
|
5044
|
-
return `(?:${result})`;
|
|
5045
|
-
}
|
|
5046
|
-
let isPadded = hasPadding(min) || hasPadding(max);
|
|
5047
|
-
let state = { min, max, a, b };
|
|
5048
|
-
let positives = [];
|
|
5049
|
-
let negatives = [];
|
|
5050
|
-
if (isPadded) {
|
|
5051
|
-
state.isPadded = isPadded;
|
|
5052
|
-
state.maxLen = String(state.max).length;
|
|
5053
|
-
}
|
|
5054
|
-
if (a < 0) {
|
|
5055
|
-
let newMin = b < 0 ? Math.abs(b) : 1;
|
|
5056
|
-
negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
|
|
5057
|
-
a = state.a = 0;
|
|
5058
|
-
}
|
|
5059
|
-
if (b >= 0) {
|
|
5060
|
-
positives = splitToPatterns(a, b, state, opts);
|
|
5061
|
-
}
|
|
5062
|
-
state.negatives = negatives;
|
|
5063
|
-
state.positives = positives;
|
|
5064
|
-
state.result = collatePatterns(negatives, positives, opts);
|
|
5065
|
-
if (opts.capture === true) {
|
|
5066
|
-
state.result = `(${state.result})`;
|
|
5067
|
-
} else if (
|
|
5068
|
-
opts.wrap !== false &&
|
|
5069
|
-
positives.length + negatives.length > 1
|
|
5070
|
-
) {
|
|
5071
|
-
state.result = `(?:${state.result})`;
|
|
5072
|
-
}
|
|
5073
|
-
toRegexRange.cache[cacheKey] = state;
|
|
5074
|
-
return state.result;
|
|
5075
|
-
};
|
|
5076
|
-
function collatePatterns(neg, pos, options) {
|
|
5077
|
-
let onlyNegative = filterPatterns(neg, pos, "-", false, options) || [];
|
|
5078
|
-
let onlyPositive = filterPatterns(pos, neg, "", false, options) || [];
|
|
5079
|
-
let intersected = filterPatterns(neg, pos, "-?", true, options) || [];
|
|
5080
|
-
let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
|
|
5081
|
-
return subpatterns.join("|");
|
|
5082
|
-
}
|
|
5083
|
-
function splitToRanges(min, max) {
|
|
5084
|
-
let nines = 1;
|
|
5085
|
-
let zeros = 1;
|
|
5086
|
-
let stop = countNines(min, nines);
|
|
5087
|
-
let stops = new Set([max]);
|
|
5088
|
-
while (min <= stop && stop <= max) {
|
|
5089
|
-
stops.add(stop);
|
|
5090
|
-
nines += 1;
|
|
5091
|
-
stop = countNines(min, nines);
|
|
5092
|
-
}
|
|
5093
|
-
stop = countZeros(max + 1, zeros) - 1;
|
|
5094
|
-
while (min < stop && stop <= max) {
|
|
5095
|
-
stops.add(stop);
|
|
5096
|
-
zeros += 1;
|
|
5097
|
-
stop = countZeros(max + 1, zeros) - 1;
|
|
5098
|
-
}
|
|
5099
|
-
stops = [...stops];
|
|
5100
|
-
stops.sort(compare);
|
|
5101
|
-
return stops;
|
|
5102
|
-
}
|
|
5103
|
-
function rangeToPattern(start, stop, options) {
|
|
5104
|
-
if (start === stop) {
|
|
5105
|
-
return { pattern: start, count: [], digits: 0 };
|
|
5106
|
-
}
|
|
5107
|
-
let zipped = zip(start, stop);
|
|
5108
|
-
let digits = zipped.length;
|
|
5109
|
-
let pattern = "";
|
|
5110
|
-
let count = 0;
|
|
5111
|
-
for (let i = 0; i < digits; i++) {
|
|
5112
|
-
let [startDigit, stopDigit] = zipped[i];
|
|
5113
|
-
if (startDigit === stopDigit) {
|
|
5114
|
-
pattern += startDigit;
|
|
5115
|
-
} else if (startDigit !== "0" || stopDigit !== "9") {
|
|
5116
|
-
pattern += toCharacterClass(startDigit, stopDigit, options);
|
|
5117
|
-
} else {
|
|
5118
|
-
count++;
|
|
5119
|
-
}
|
|
5120
|
-
}
|
|
5121
|
-
if (count) {
|
|
5122
|
-
pattern += options.shorthand === true ? "\\d" : "[0-9]";
|
|
5123
|
-
}
|
|
5124
|
-
return { pattern, count: [count], digits };
|
|
5125
|
-
}
|
|
5126
|
-
function splitToPatterns(min, max, tok, options) {
|
|
5127
|
-
let ranges = splitToRanges(min, max);
|
|
5128
|
-
let tokens = [];
|
|
5129
|
-
let start = min;
|
|
5130
|
-
let prev;
|
|
5131
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
5132
|
-
let max = ranges[i];
|
|
5133
|
-
let obj = rangeToPattern(String(start), String(max), options);
|
|
5134
|
-
let zeros = "";
|
|
5135
|
-
if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
|
|
5136
|
-
if (prev.count.length > 1) {
|
|
5137
|
-
prev.count.pop();
|
|
5649
|
+
} else if (legacyContext && !legacyOptions) {
|
|
5650
|
+
options = { ...legacyContext };
|
|
5651
|
+
logger = getLegacyLogger(options);
|
|
5652
|
+
} else {
|
|
5653
|
+
logger = getLegacyLogger({});
|
|
5654
|
+
}
|
|
5655
|
+
Object.entries(proxyEventMap).forEach(
|
|
5656
|
+
([legacyEventName, proxyEventName]) => {
|
|
5657
|
+
if (options[legacyEventName]) {
|
|
5658
|
+
options.on = { ...options.on };
|
|
5659
|
+
options.on[proxyEventName] = options[legacyEventName];
|
|
5660
|
+
debug(
|
|
5661
|
+
'map legacy event "%s" to "on.%s"',
|
|
5662
|
+
legacyEventName,
|
|
5663
|
+
proxyEventName,
|
|
5664
|
+
);
|
|
5665
|
+
logger.warn(
|
|
5666
|
+
`[http-proxy-middleware] Legacy "${legacyEventName}" is deprecated. Migrate to "options.on.${proxyEventName}":\n\n const options = {\n on: {\n ${proxyEventName}: () => {},\n },\n }\n\n More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#refactored-proxy-events\n `,
|
|
5667
|
+
);
|
|
5138
5668
|
}
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5669
|
+
},
|
|
5670
|
+
);
|
|
5671
|
+
const logProvider = options.logProvider && options.logProvider();
|
|
5672
|
+
const logLevel = options.logLevel;
|
|
5673
|
+
debug("legacy logLevel", logLevel);
|
|
5674
|
+
debug("legacy logProvider: %O", logProvider);
|
|
5675
|
+
if (typeof logLevel === "string" && logLevel !== "silent") {
|
|
5676
|
+
debug('map "logProvider" to "logger"');
|
|
5677
|
+
logger.warn(
|
|
5678
|
+
`[http-proxy-middleware] Legacy "logLevel" and "logProvider" are deprecated. Migrate to "options.logger":\n\n const options = {\n logger: console,\n }\n\n More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-logprovider-and-loglevel-options\n `,
|
|
5679
|
+
);
|
|
5680
|
+
}
|
|
5681
|
+
return options;
|
|
5682
|
+
}
|
|
5683
|
+
function getLegacyLogger(options) {
|
|
5684
|
+
const legacyLogger = options.logProvider && options.logProvider();
|
|
5685
|
+
if (legacyLogger) {
|
|
5686
|
+
options.logger = legacyLogger;
|
|
5151
5687
|
}
|
|
5152
|
-
return
|
|
5688
|
+
return (0, logger_1.getLogger)(options);
|
|
5153
5689
|
}
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5690
|
+
},
|
|
5691
|
+
2328: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5692
|
+
"use strict";
|
|
5693
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5694
|
+
exports.legacyCreateProxyMiddleware = void 0;
|
|
5695
|
+
var create_proxy_middleware_1 = __nccwpck_require__(4041);
|
|
5696
|
+
Object.defineProperty(exports, "legacyCreateProxyMiddleware", {
|
|
5697
|
+
enumerable: true,
|
|
5698
|
+
get: function () {
|
|
5699
|
+
return create_proxy_middleware_1.legacyCreateProxyMiddleware;
|
|
5700
|
+
},
|
|
5701
|
+
});
|
|
5702
|
+
},
|
|
5703
|
+
2001: (__unused_webpack_module, exports) => {
|
|
5704
|
+
"use strict";
|
|
5705
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5706
|
+
exports.getLogger = getLogger;
|
|
5707
|
+
const noopLogger = { info: () => {}, warn: () => {}, error: () => {} };
|
|
5708
|
+
function getLogger(options) {
|
|
5709
|
+
return options.logger || noopLogger;
|
|
5710
|
+
}
|
|
5711
|
+
},
|
|
5712
|
+
3833: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5713
|
+
"use strict";
|
|
5714
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5715
|
+
exports.matchPathFilter = matchPathFilter;
|
|
5716
|
+
const isGlob = __nccwpck_require__(686);
|
|
5717
|
+
const micromatch = __nccwpck_require__(9555);
|
|
5718
|
+
const url = __nccwpck_require__(7016);
|
|
5719
|
+
const errors_1 = __nccwpck_require__(4006);
|
|
5720
|
+
function matchPathFilter(pathFilter = "/", uri, req) {
|
|
5721
|
+
if (isStringPath(pathFilter)) {
|
|
5722
|
+
return matchSingleStringPath(pathFilter, uri);
|
|
5723
|
+
}
|
|
5724
|
+
if (isGlobPath(pathFilter)) {
|
|
5725
|
+
return matchSingleGlobPath(pathFilter, uri);
|
|
5726
|
+
}
|
|
5727
|
+
if (Array.isArray(pathFilter)) {
|
|
5728
|
+
if (pathFilter.every(isStringPath)) {
|
|
5729
|
+
return matchMultiPath(pathFilter, uri);
|
|
5160
5730
|
}
|
|
5161
|
-
if (
|
|
5162
|
-
|
|
5731
|
+
if (pathFilter.every(isGlobPath)) {
|
|
5732
|
+
return matchMultiGlobPath(pathFilter, uri);
|
|
5163
5733
|
}
|
|
5734
|
+
throw new Error(errors_1.ERRORS.ERR_CONTEXT_MATCHER_INVALID_ARRAY);
|
|
5164
5735
|
}
|
|
5165
|
-
|
|
5736
|
+
if (typeof pathFilter === "function") {
|
|
5737
|
+
const pathname = getUrlPathName(uri);
|
|
5738
|
+
return pathFilter(pathname, req);
|
|
5739
|
+
}
|
|
5740
|
+
throw new Error(errors_1.ERRORS.ERR_CONTEXT_MATCHER_GENERIC);
|
|
5166
5741
|
}
|
|
5167
|
-
function
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
return arr;
|
|
5742
|
+
function matchSingleStringPath(pathFilter, uri) {
|
|
5743
|
+
const pathname = getUrlPathName(uri);
|
|
5744
|
+
return pathname?.indexOf(pathFilter) === 0;
|
|
5171
5745
|
}
|
|
5172
|
-
function
|
|
5173
|
-
|
|
5746
|
+
function matchSingleGlobPath(pattern, uri) {
|
|
5747
|
+
const pathname = getUrlPathName(uri);
|
|
5748
|
+
const matches = micromatch([pathname], pattern);
|
|
5749
|
+
return matches && matches.length > 0;
|
|
5174
5750
|
}
|
|
5175
|
-
function
|
|
5176
|
-
return
|
|
5751
|
+
function matchMultiGlobPath(patternList, uri) {
|
|
5752
|
+
return matchSingleGlobPath(patternList, uri);
|
|
5177
5753
|
}
|
|
5178
|
-
function
|
|
5179
|
-
|
|
5754
|
+
function matchMultiPath(pathFilterList, uri) {
|
|
5755
|
+
let isMultiPath = false;
|
|
5756
|
+
for (const context of pathFilterList) {
|
|
5757
|
+
if (matchSingleStringPath(context, uri)) {
|
|
5758
|
+
isMultiPath = true;
|
|
5759
|
+
break;
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
return isMultiPath;
|
|
5180
5763
|
}
|
|
5181
|
-
function
|
|
5182
|
-
return
|
|
5764
|
+
function getUrlPathName(uri) {
|
|
5765
|
+
return uri && url.parse(uri).pathname;
|
|
5183
5766
|
}
|
|
5184
|
-
function
|
|
5185
|
-
|
|
5186
|
-
if (stop || start > 1) {
|
|
5187
|
-
return `{${start + (stop ? "," + stop : "")}}`;
|
|
5188
|
-
}
|
|
5189
|
-
return "";
|
|
5767
|
+
function isStringPath(pathFilter) {
|
|
5768
|
+
return typeof pathFilter === "string" && !isGlob(pathFilter);
|
|
5190
5769
|
}
|
|
5191
|
-
function
|
|
5192
|
-
return
|
|
5770
|
+
function isGlobPath(pathFilter) {
|
|
5771
|
+
return isGlob(pathFilter);
|
|
5193
5772
|
}
|
|
5194
|
-
|
|
5195
|
-
|
|
5773
|
+
},
|
|
5774
|
+
3461: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5775
|
+
"use strict";
|
|
5776
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5777
|
+
exports.createPathRewriter = createPathRewriter;
|
|
5778
|
+
const is_plain_object_1 = __nccwpck_require__(634);
|
|
5779
|
+
const errors_1 = __nccwpck_require__(4006);
|
|
5780
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
5781
|
+
const debug = debug_1.Debug.extend("path-rewriter");
|
|
5782
|
+
function createPathRewriter(rewriteConfig) {
|
|
5783
|
+
let rulesCache;
|
|
5784
|
+
if (!isValidRewriteConfig(rewriteConfig)) {
|
|
5785
|
+
return;
|
|
5786
|
+
}
|
|
5787
|
+
if (typeof rewriteConfig === "function") {
|
|
5788
|
+
const customRewriteFn = rewriteConfig;
|
|
5789
|
+
return customRewriteFn;
|
|
5790
|
+
} else {
|
|
5791
|
+
rulesCache = parsePathRewriteRules(rewriteConfig);
|
|
5792
|
+
return rewritePath;
|
|
5793
|
+
}
|
|
5794
|
+
function rewritePath(path) {
|
|
5795
|
+
let result = path;
|
|
5796
|
+
for (const rule of rulesCache) {
|
|
5797
|
+
if (rule.regex.test(path)) {
|
|
5798
|
+
result = result.replace(rule.regex, rule.value);
|
|
5799
|
+
debug('rewriting path from "%s" to "%s"', path, result);
|
|
5800
|
+
break;
|
|
5801
|
+
}
|
|
5802
|
+
}
|
|
5803
|
+
return result;
|
|
5804
|
+
}
|
|
5196
5805
|
}
|
|
5197
|
-
function
|
|
5198
|
-
if (
|
|
5199
|
-
return
|
|
5806
|
+
function isValidRewriteConfig(rewriteConfig) {
|
|
5807
|
+
if (typeof rewriteConfig === "function") {
|
|
5808
|
+
return true;
|
|
5809
|
+
} else if ((0, is_plain_object_1.isPlainObject)(rewriteConfig)) {
|
|
5810
|
+
return Object.keys(rewriteConfig).length !== 0;
|
|
5811
|
+
} else if (rewriteConfig === undefined || rewriteConfig === null) {
|
|
5812
|
+
return false;
|
|
5813
|
+
} else {
|
|
5814
|
+
throw new Error(errors_1.ERRORS.ERR_PATH_REWRITER_CONFIG);
|
|
5200
5815
|
}
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
case 2:
|
|
5209
|
-
return relax ? "0{0,2}" : "00";
|
|
5210
|
-
default: {
|
|
5211
|
-
return relax ? `0{0,${diff}}` : `0{${diff}}`;
|
|
5816
|
+
}
|
|
5817
|
+
function parsePathRewriteRules(rewriteConfig) {
|
|
5818
|
+
const rules = [];
|
|
5819
|
+
if ((0, is_plain_object_1.isPlainObject)(rewriteConfig)) {
|
|
5820
|
+
for (const [key, value] of Object.entries(rewriteConfig)) {
|
|
5821
|
+
rules.push({ regex: new RegExp(key), value });
|
|
5822
|
+
debug('rewrite rule created: "%s" ~> "%s"', key, value);
|
|
5212
5823
|
}
|
|
5213
5824
|
}
|
|
5825
|
+
return rules;
|
|
5214
5826
|
}
|
|
5215
|
-
toRegexRange.cache = {};
|
|
5216
|
-
toRegexRange.clearCache = () => (toRegexRange.cache = {});
|
|
5217
|
-
module.exports = toRegexRange;
|
|
5218
|
-
},
|
|
5219
|
-
2814: (module) => {
|
|
5220
|
-
module.exports = eval("require")("debug");
|
|
5221
5827
|
},
|
|
5222
|
-
|
|
5828
|
+
8150: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5223
5829
|
"use strict";
|
|
5224
|
-
|
|
5830
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5831
|
+
exports.debugProxyErrorsPlugin = void 0;
|
|
5832
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
5833
|
+
const debug = debug_1.Debug.extend("debug-proxy-errors-plugin");
|
|
5834
|
+
const debugProxyErrorsPlugin = (proxyServer) => {
|
|
5835
|
+
proxyServer.on("error", (error, req, res, target) => {
|
|
5836
|
+
debug(`http-proxy error event: \n%O`, error);
|
|
5837
|
+
});
|
|
5838
|
+
proxyServer.on("proxyReq", (proxyReq, req, socket) => {
|
|
5839
|
+
socket.on("error", (error) => {
|
|
5840
|
+
debug("Socket error in proxyReq event: \n%O", error);
|
|
5841
|
+
});
|
|
5842
|
+
});
|
|
5843
|
+
proxyServer.on("proxyRes", (proxyRes, req, res) => {
|
|
5844
|
+
res.on("close", () => {
|
|
5845
|
+
if (!res.writableEnded) {
|
|
5846
|
+
debug("Destroying proxyRes in proxyRes close event");
|
|
5847
|
+
proxyRes.destroy();
|
|
5848
|
+
}
|
|
5849
|
+
});
|
|
5850
|
+
});
|
|
5851
|
+
proxyServer.on("proxyReqWs", (proxyReq, req, socket) => {
|
|
5852
|
+
socket.on("error", (error) => {
|
|
5853
|
+
debug("Socket error in proxyReqWs event: \n%O", error);
|
|
5854
|
+
});
|
|
5855
|
+
});
|
|
5856
|
+
proxyServer.on("open", (proxySocket) => {
|
|
5857
|
+
proxySocket.on("error", (error) => {
|
|
5858
|
+
debug("Socket error in open event: \n%O", error);
|
|
5859
|
+
});
|
|
5860
|
+
});
|
|
5861
|
+
proxyServer.on("close", (req, socket, head) => {
|
|
5862
|
+
socket.on("error", (error) => {
|
|
5863
|
+
debug("Socket error in close event: \n%O", error);
|
|
5864
|
+
});
|
|
5865
|
+
});
|
|
5866
|
+
proxyServer.on("econnreset", (error, req, res, target) => {
|
|
5867
|
+
debug(`http-proxy econnreset event: \n%O`, error);
|
|
5868
|
+
});
|
|
5869
|
+
};
|
|
5870
|
+
exports.debugProxyErrorsPlugin = debugProxyErrorsPlugin;
|
|
5225
5871
|
},
|
|
5226
|
-
|
|
5872
|
+
766: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5227
5873
|
"use strict";
|
|
5228
|
-
|
|
5874
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5875
|
+
exports.errorResponsePlugin = void 0;
|
|
5876
|
+
const status_code_1 = __nccwpck_require__(4173);
|
|
5877
|
+
function isResponseLike(obj) {
|
|
5878
|
+
return obj && typeof obj.writeHead === "function";
|
|
5879
|
+
}
|
|
5880
|
+
function isSocketLike(obj) {
|
|
5881
|
+
return obj && typeof obj.write === "function" && !("writeHead" in obj);
|
|
5882
|
+
}
|
|
5883
|
+
const errorResponsePlugin = (proxyServer, options) => {
|
|
5884
|
+
proxyServer.on("error", (err, req, res, target) => {
|
|
5885
|
+
if (!req && !res) {
|
|
5886
|
+
throw err;
|
|
5887
|
+
}
|
|
5888
|
+
if (isResponseLike(res)) {
|
|
5889
|
+
if (!res.headersSent) {
|
|
5890
|
+
const statusCode = (0, status_code_1.getStatusCode)(err.code);
|
|
5891
|
+
res.writeHead(statusCode);
|
|
5892
|
+
}
|
|
5893
|
+
const host = req.headers && req.headers.host;
|
|
5894
|
+
res.end(`Error occurred while trying to proxy: ${host}${req.url}`);
|
|
5895
|
+
} else if (isSocketLike(res)) {
|
|
5896
|
+
res.destroy();
|
|
5897
|
+
}
|
|
5898
|
+
});
|
|
5899
|
+
};
|
|
5900
|
+
exports.errorResponsePlugin = errorResponsePlugin;
|
|
5229
5901
|
},
|
|
5230
|
-
|
|
5902
|
+
3024: function (__unused_webpack_module, exports, __nccwpck_require__) {
|
|
5231
5903
|
"use strict";
|
|
5232
|
-
|
|
5904
|
+
var __createBinding =
|
|
5905
|
+
(this && this.__createBinding) ||
|
|
5906
|
+
(Object.create
|
|
5907
|
+
? function (o, m, k, k2) {
|
|
5908
|
+
if (k2 === undefined) k2 = k;
|
|
5909
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5910
|
+
if (
|
|
5911
|
+
!desc ||
|
|
5912
|
+
("get" in desc
|
|
5913
|
+
? !m.__esModule
|
|
5914
|
+
: desc.writable || desc.configurable)
|
|
5915
|
+
) {
|
|
5916
|
+
desc = {
|
|
5917
|
+
enumerable: true,
|
|
5918
|
+
get: function () {
|
|
5919
|
+
return m[k];
|
|
5920
|
+
},
|
|
5921
|
+
};
|
|
5922
|
+
}
|
|
5923
|
+
Object.defineProperty(o, k2, desc);
|
|
5924
|
+
}
|
|
5925
|
+
: function (o, m, k, k2) {
|
|
5926
|
+
if (k2 === undefined) k2 = k;
|
|
5927
|
+
o[k2] = m[k];
|
|
5928
|
+
});
|
|
5929
|
+
var __exportStar =
|
|
5930
|
+
(this && this.__exportStar) ||
|
|
5931
|
+
function (m, exports) {
|
|
5932
|
+
for (var p in m)
|
|
5933
|
+
if (
|
|
5934
|
+
p !== "default" &&
|
|
5935
|
+
!Object.prototype.hasOwnProperty.call(exports, p)
|
|
5936
|
+
)
|
|
5937
|
+
__createBinding(exports, m, p);
|
|
5938
|
+
};
|
|
5939
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5940
|
+
__exportStar(__nccwpck_require__(8150), exports);
|
|
5941
|
+
__exportStar(__nccwpck_require__(766), exports);
|
|
5942
|
+
__exportStar(__nccwpck_require__(232), exports);
|
|
5943
|
+
__exportStar(__nccwpck_require__(5644), exports);
|
|
5233
5944
|
},
|
|
5234
|
-
|
|
5945
|
+
232: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5235
5946
|
"use strict";
|
|
5236
|
-
|
|
5947
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5948
|
+
exports.loggerPlugin = void 0;
|
|
5949
|
+
const url_1 = __nccwpck_require__(7016);
|
|
5950
|
+
const logger_1 = __nccwpck_require__(2001);
|
|
5951
|
+
const logger_plugin_1 = __nccwpck_require__(9223);
|
|
5952
|
+
const loggerPlugin = (proxyServer, options) => {
|
|
5953
|
+
const logger = (0, logger_1.getLogger)(options);
|
|
5954
|
+
proxyServer.on("error", (err, req, res, target) => {
|
|
5955
|
+
const hostname = req?.headers?.host;
|
|
5956
|
+
const requestHref = `${hostname}${req?.url}`;
|
|
5957
|
+
const targetHref = `${target?.href}`;
|
|
5958
|
+
const errorMessage =
|
|
5959
|
+
"[HPM] Error occurred while proxying request %s to %s [%s] (%s)";
|
|
5960
|
+
const errReference =
|
|
5961
|
+
"https://nodejs.org/api/errors.html#errors_common_system_errors";
|
|
5962
|
+
logger.error(
|
|
5963
|
+
errorMessage,
|
|
5964
|
+
requestHref,
|
|
5965
|
+
targetHref,
|
|
5966
|
+
err.code || err,
|
|
5967
|
+
errReference,
|
|
5968
|
+
);
|
|
5969
|
+
});
|
|
5970
|
+
proxyServer.on("proxyRes", (proxyRes, req, res) => {
|
|
5971
|
+
const originalUrl =
|
|
5972
|
+
req.originalUrl ?? `${req.baseUrl || ""}${req.url}`;
|
|
5973
|
+
let target;
|
|
5974
|
+
try {
|
|
5975
|
+
const port = (0, logger_plugin_1.getPort)(
|
|
5976
|
+
proxyRes.req?.agent?.sockets,
|
|
5977
|
+
);
|
|
5978
|
+
const obj = {
|
|
5979
|
+
protocol: proxyRes.req.protocol,
|
|
5980
|
+
host: proxyRes.req.host,
|
|
5981
|
+
pathname: proxyRes.req.path,
|
|
5982
|
+
};
|
|
5983
|
+
target = new url_1.URL(
|
|
5984
|
+
`${obj.protocol}//${obj.host}${obj.pathname}`,
|
|
5985
|
+
);
|
|
5986
|
+
if (port) {
|
|
5987
|
+
target.port = port;
|
|
5988
|
+
}
|
|
5989
|
+
} catch (err) {
|
|
5990
|
+
target = new url_1.URL(options.target);
|
|
5991
|
+
target.pathname = proxyRes.req.path;
|
|
5992
|
+
}
|
|
5993
|
+
const targetUrl = target.toString();
|
|
5994
|
+
const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
|
|
5995
|
+
logger.info(exchange);
|
|
5996
|
+
});
|
|
5997
|
+
proxyServer.on("open", (socket) => {
|
|
5998
|
+
logger.info("[HPM] Client connected: %o", socket.address());
|
|
5999
|
+
});
|
|
6000
|
+
proxyServer.on("close", (req, proxySocket, proxyHead) => {
|
|
6001
|
+
logger.info("[HPM] Client disconnected: %o", proxySocket.address());
|
|
6002
|
+
});
|
|
6003
|
+
};
|
|
6004
|
+
exports.loggerPlugin = loggerPlugin;
|
|
5237
6005
|
},
|
|
5238
|
-
|
|
6006
|
+
5644: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5239
6007
|
"use strict";
|
|
5240
|
-
|
|
6008
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6009
|
+
exports.proxyEventsPlugin = void 0;
|
|
6010
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
6011
|
+
const function_1 = __nccwpck_require__(7);
|
|
6012
|
+
const debug = debug_1.Debug.extend("proxy-events-plugin");
|
|
6013
|
+
const proxyEventsPlugin = (proxyServer, options) => {
|
|
6014
|
+
Object.entries(options.on || {}).forEach(([eventName, handler]) => {
|
|
6015
|
+
debug(
|
|
6016
|
+
`register event handler: "${eventName}" -> "${(0, function_1.getFunctionName)(handler)}"`,
|
|
6017
|
+
);
|
|
6018
|
+
proxyServer.on(eventName, handler);
|
|
6019
|
+
});
|
|
6020
|
+
};
|
|
6021
|
+
exports.proxyEventsPlugin = proxyEventsPlugin;
|
|
5241
6022
|
},
|
|
5242
|
-
|
|
6023
|
+
1976: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5243
6024
|
"use strict";
|
|
5244
|
-
|
|
6025
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6026
|
+
exports.getTarget = getTarget;
|
|
6027
|
+
const is_plain_object_1 = __nccwpck_require__(634);
|
|
6028
|
+
const debug_1 = __nccwpck_require__(5342);
|
|
6029
|
+
const debug = debug_1.Debug.extend("router");
|
|
6030
|
+
async function getTarget(req, config) {
|
|
6031
|
+
let newTarget;
|
|
6032
|
+
const router = config.router;
|
|
6033
|
+
if ((0, is_plain_object_1.isPlainObject)(router)) {
|
|
6034
|
+
newTarget = getTargetFromProxyTable(req, router);
|
|
6035
|
+
} else if (typeof router === "function") {
|
|
6036
|
+
newTarget = await router(req);
|
|
6037
|
+
}
|
|
6038
|
+
return newTarget;
|
|
6039
|
+
}
|
|
6040
|
+
function getTargetFromProxyTable(req, table) {
|
|
6041
|
+
let result;
|
|
6042
|
+
const host = req.headers.host;
|
|
6043
|
+
const path = req.url;
|
|
6044
|
+
const hostAndPath = host + path;
|
|
6045
|
+
for (const [key, value] of Object.entries(table)) {
|
|
6046
|
+
if (containsPath(key)) {
|
|
6047
|
+
if (hostAndPath.indexOf(key) > -1) {
|
|
6048
|
+
result = value;
|
|
6049
|
+
debug('match: "%s" -> "%s"', key, result);
|
|
6050
|
+
break;
|
|
6051
|
+
}
|
|
6052
|
+
} else {
|
|
6053
|
+
if (key === host) {
|
|
6054
|
+
result = value;
|
|
6055
|
+
debug('match: "%s" -> "%s"', host, result);
|
|
6056
|
+
break;
|
|
6057
|
+
}
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
return result;
|
|
6061
|
+
}
|
|
6062
|
+
function containsPath(v) {
|
|
6063
|
+
return v.indexOf("/") > -1;
|
|
6064
|
+
}
|
|
5245
6065
|
},
|
|
5246
|
-
|
|
6066
|
+
4173: (__unused_webpack_module, exports) => {
|
|
5247
6067
|
"use strict";
|
|
5248
|
-
|
|
6068
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6069
|
+
exports.getStatusCode = getStatusCode;
|
|
6070
|
+
function getStatusCode(errorCode) {
|
|
6071
|
+
let statusCode;
|
|
6072
|
+
if (/HPE_INVALID/.test(errorCode)) {
|
|
6073
|
+
statusCode = 502;
|
|
6074
|
+
} else {
|
|
6075
|
+
switch (errorCode) {
|
|
6076
|
+
case "ECONNRESET":
|
|
6077
|
+
case "ENOTFOUND":
|
|
6078
|
+
case "ECONNREFUSED":
|
|
6079
|
+
case "ETIMEDOUT":
|
|
6080
|
+
statusCode = 504;
|
|
6081
|
+
break;
|
|
6082
|
+
default:
|
|
6083
|
+
statusCode = 500;
|
|
6084
|
+
break;
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
return statusCode;
|
|
6088
|
+
}
|
|
5249
6089
|
},
|
|
5250
|
-
|
|
6090
|
+
7: (__unused_webpack_module, exports) => {
|
|
5251
6091
|
"use strict";
|
|
5252
|
-
|
|
6092
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6093
|
+
exports.getFunctionName = getFunctionName;
|
|
6094
|
+
function getFunctionName(fn) {
|
|
6095
|
+
return fn.name || "[anonymous Function]";
|
|
6096
|
+
}
|
|
5253
6097
|
},
|
|
5254
|
-
|
|
6098
|
+
9223: (__unused_webpack_module, exports) => {
|
|
5255
6099
|
"use strict";
|
|
5256
|
-
|
|
6100
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6101
|
+
exports.getPort = getPort;
|
|
6102
|
+
function getPort(sockets) {
|
|
6103
|
+
return Object.keys(sockets || {})?.[0]?.split(":")[1];
|
|
6104
|
+
}
|
|
5257
6105
|
},
|
|
5258
6106
|
};
|
|
5259
6107
|
var __webpack_module_cache__ = {};
|
|
@@ -5279,6 +6127,6 @@
|
|
|
5279
6127
|
}
|
|
5280
6128
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
5281
6129
|
__nccwpck_require__.ab = __dirname + "/";
|
|
5282
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
6130
|
+
var __webpack_exports__ = __nccwpck_require__(6289);
|
|
5283
6131
|
module.exports = __webpack_exports__;
|
|
5284
6132
|
})();
|