webpack-dev-server 5.2.0 → 5.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/clients/SockJSClient.js +3 -2
- package/client/clients/WebSocketClient.js +3 -2
- package/client/index.js +8 -7
- package/client/modules/logger/index.js +28 -11
- package/client/modules/sockjs-client/index.js +16 -10
- package/client/overlay.js +8 -2
- package/client/progress.js +4 -3
- package/client/socket.js +5 -1
- package/lib/Server.js +176 -65
- package/package.json +5 -4
- package/types/lib/Server.d.ts +14 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
2
3
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
3
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
7
|
import SockJS from "../modules/sockjs-client/index.js";
|
|
7
8
|
import { log } from "../utils/log.js";
|
|
8
9
|
var SockJSClient = /*#__PURE__*/function () {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
2
3
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
3
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
7
|
import { log } from "../utils/log.js";
|
|
7
8
|
var WebSocketClient = /*#__PURE__*/function () {
|
|
8
9
|
/**
|
package/client/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
2
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
3
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
7
|
/* global __resourceQuery, __webpack_hash__ */
|
|
7
8
|
/// <reference types="webpack/module" />
|
|
8
9
|
import webpackHotLog from "webpack/hot/log.js";
|
|
@@ -42,7 +43,7 @@ import { isProgressSupported, defineProgressElement } from "./progress.js";
|
|
|
42
43
|
* @param {boolean | { warnings?: boolean | string; errors?: boolean | string; runtimeErrors?: boolean | string; }} overlayOptions
|
|
43
44
|
*/
|
|
44
45
|
var decodeOverlayOptions = function decodeOverlayOptions(overlayOptions) {
|
|
45
|
-
if (
|
|
46
|
+
if (_typeof(overlayOptions) === "object") {
|
|
46
47
|
["warnings", "errors", "runtimeErrors"].forEach(function (property) {
|
|
47
48
|
if (typeof overlayOptions[property] === "string") {
|
|
48
49
|
var overlayFilterFunctionString = decodeURIComponent(overlayOptions[property]);
|
|
@@ -155,7 +156,7 @@ if (parsedResourceQuery.overlay) {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
// Fill in default "true" params for partially-specified objects.
|
|
158
|
-
if (
|
|
159
|
+
if (_typeof(options.overlay) === "object") {
|
|
159
160
|
options.overlay = _objectSpread({
|
|
160
161
|
errors: true,
|
|
161
162
|
warnings: true,
|
|
@@ -163,7 +164,7 @@ if (parsedResourceQuery.overlay) {
|
|
|
163
164
|
}, options.overlay);
|
|
164
165
|
decodeOverlayOptions(options.overlay);
|
|
165
166
|
}
|
|
166
|
-
enabledFeatures.Overlay =
|
|
167
|
+
enabledFeatures.Overlay = options.overlay !== false;
|
|
167
168
|
}
|
|
168
169
|
if (parsedResourceQuery.logging) {
|
|
169
170
|
options.logging = parsedResourceQuery.logging;
|
|
@@ -203,7 +204,7 @@ logEnabledFeatures(enabledFeatures);
|
|
|
203
204
|
self.addEventListener("beforeunload", function () {
|
|
204
205
|
status.isUnloading = true;
|
|
205
206
|
});
|
|
206
|
-
var overlay = typeof window !== "undefined" ? createOverlay(
|
|
207
|
+
var overlay = typeof window !== "undefined" ? createOverlay(_typeof(options.overlay) === "object" ? {
|
|
207
208
|
trustedTypesPolicyName: options.overlay.trustedTypesPolicyName,
|
|
208
209
|
catchRuntimeError: options.overlay.runtimeErrors
|
|
209
210
|
} : {
|
|
@@ -282,7 +283,7 @@ var ansiRegex = new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\
|
|
|
282
283
|
*/
|
|
283
284
|
var stripAnsi = function stripAnsi(string) {
|
|
284
285
|
if (typeof string !== "string") {
|
|
285
|
-
throw new TypeError("Expected a `string`, got `".concat(
|
|
286
|
+
throw new TypeError("Expected a `string`, got `".concat(_typeof(string), "`"));
|
|
286
287
|
}
|
|
287
288
|
return string.replace(ansiRegex, "");
|
|
288
289
|
};
|
|
@@ -39,6 +39,15 @@ function SyncBailHook() {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
function _typeof(o) {
|
|
43
|
+
"@babel/helpers - typeof";
|
|
44
|
+
|
|
45
|
+
return _typeof = "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && "symbol" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).iterator ? function (o) {
|
|
46
|
+
return typeof o;
|
|
47
|
+
} : function (o) {
|
|
48
|
+
return o && "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o.constructor === (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o !== (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).prototype ? "symbol" : typeof o;
|
|
49
|
+
}, _typeof(o);
|
|
50
|
+
}
|
|
42
51
|
function _toConsumableArray(r) {
|
|
43
52
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
44
53
|
}
|
|
@@ -79,14 +88,14 @@ function _createClass(e, r, t) {
|
|
|
79
88
|
}
|
|
80
89
|
function _toPropertyKey(t) {
|
|
81
90
|
var i = _toPrimitive(t, "string");
|
|
82
|
-
return "symbol" ==
|
|
91
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
83
92
|
}
|
|
84
93
|
function _toPrimitive(t, r) {
|
|
85
|
-
if ("object" !=
|
|
94
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
86
95
|
var e = t[(typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).toPrimitive];
|
|
87
96
|
if (void 0 !== e) {
|
|
88
97
|
var i = e.call(t, r || "default");
|
|
89
|
-
if ("object" !=
|
|
98
|
+
if ("object" != _typeof(i)) return i;
|
|
90
99
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
91
100
|
}
|
|
92
101
|
return ("string" === r ? String : Number)(t);
|
|
@@ -134,8 +143,8 @@ var TIMERS_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { ret
|
|
|
134
143
|
var TIMERS_AGGREGATES_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })("webpack logger aggregated times");
|
|
135
144
|
var WebpackLogger = /*#__PURE__*/function () {
|
|
136
145
|
/**
|
|
137
|
-
* @param {
|
|
138
|
-
* @param {
|
|
146
|
+
* @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function
|
|
147
|
+
* @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
|
|
139
148
|
*/
|
|
140
149
|
function WebpackLogger(log, getChildLogger) {
|
|
141
150
|
_classCallCheck(this, WebpackLogger);
|
|
@@ -447,6 +456,15 @@ function _arrayLikeToArray(r, a) {
|
|
|
447
456
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
448
457
|
return n;
|
|
449
458
|
}
|
|
459
|
+
function _typeof(o) {
|
|
460
|
+
"@babel/helpers - typeof";
|
|
461
|
+
|
|
462
|
+
return _typeof = "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && "symbol" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).iterator ? function (o) {
|
|
463
|
+
return typeof o;
|
|
464
|
+
} : function (o) {
|
|
465
|
+
return o && "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o.constructor === (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o !== (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).prototype ? "symbol" : typeof o;
|
|
466
|
+
}, _typeof(o);
|
|
467
|
+
}
|
|
450
468
|
var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/logging/Logger.js"),
|
|
451
469
|
LogType = _require.LogType;
|
|
452
470
|
|
|
@@ -454,13 +472,13 @@ var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/l
|
|
|
454
472
|
/** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
|
|
455
473
|
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
|
|
456
474
|
|
|
457
|
-
/** @typedef {
|
|
458
|
-
/** @typedef {
|
|
475
|
+
/** @typedef {(item: string) => boolean} FilterFunction */
|
|
476
|
+
/** @typedef {(value: string, type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} LoggingFunction */
|
|
459
477
|
|
|
460
478
|
/**
|
|
461
479
|
* @typedef {object} LoggerConsole
|
|
462
|
-
* @property {
|
|
463
|
-
* @property {
|
|
480
|
+
* @property {() => void} clear
|
|
481
|
+
* @property {() => void} trace
|
|
464
482
|
* @property {(...args: EXPECTED_ANY[]) => void} info
|
|
465
483
|
* @property {(...args: EXPECTED_ANY[]) => void} log
|
|
466
484
|
* @property {(...args: EXPECTED_ANY[]) => void} warn
|
|
@@ -493,7 +511,7 @@ var filterToFunction = function filterToFunction(item) {
|
|
|
493
511
|
return regExp.test(ident);
|
|
494
512
|
};
|
|
495
513
|
}
|
|
496
|
-
if (item &&
|
|
514
|
+
if (item && _typeof(item) === "object" && typeof item.test === "function") {
|
|
497
515
|
return function (ident) {
|
|
498
516
|
return item.test(ident);
|
|
499
517
|
};
|
|
@@ -537,7 +555,6 @@ module.exports = function (_ref) {
|
|
|
537
555
|
typeof debug === "boolean" ? [function () {
|
|
538
556
|
return debug;
|
|
539
557
|
}] : /** @type {FilterItemTypes[]} */[].concat(debug).map(filterToFunction);
|
|
540
|
-
/** @type {number} */
|
|
541
558
|
var loglevel = LogLevel["".concat(level)] || 0;
|
|
542
559
|
|
|
543
560
|
/**
|
|
@@ -53,6 +53,7 @@ if (typeof Object.create === 'function') {
|
|
|
53
53
|
\**********************************/
|
|
54
54
|
/***/ (function(module) {
|
|
55
55
|
|
|
56
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
56
57
|
/**
|
|
57
58
|
* Helpers.
|
|
58
59
|
*/
|
|
@@ -80,7 +81,7 @@ var y = d * 365.25;
|
|
|
80
81
|
|
|
81
82
|
module.exports = function (val, options) {
|
|
82
83
|
options = options || {};
|
|
83
|
-
var type =
|
|
84
|
+
var type = _typeof(val);
|
|
84
85
|
if (type === 'string' && val.length > 0) {
|
|
85
86
|
return parse(val);
|
|
86
87
|
} else if (type === 'number' && isFinite(val)) {
|
|
@@ -1347,6 +1348,7 @@ module.exports = function (availableTransports) {
|
|
|
1347
1348
|
|
|
1348
1349
|
|
|
1349
1350
|
// pulled specific shims from https://github.com/es-shims/es5-shim
|
|
1351
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1350
1352
|
var ArrayPrototype = Array.prototype;
|
|
1351
1353
|
var ObjectPrototype = Object.prototype;
|
|
1352
1354
|
var FunctionPrototype = Function.prototype;
|
|
@@ -1584,7 +1586,7 @@ var properlyBoxesContext = function properlyBoxed(method) {
|
|
|
1584
1586
|
var properlyBoxesStrict = true;
|
|
1585
1587
|
if (method) {
|
|
1586
1588
|
method.call('foo', function (_, __, context) {
|
|
1587
|
-
if (
|
|
1589
|
+
if (_typeof(context) !== 'object') {
|
|
1588
1590
|
properlyBoxesNonStrict = false;
|
|
1589
1591
|
}
|
|
1590
1592
|
});
|
|
@@ -3618,6 +3620,7 @@ if (!isChromePackagedApp) {
|
|
|
3618
3620
|
"use strict";
|
|
3619
3621
|
|
|
3620
3622
|
|
|
3623
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3621
3624
|
var eventUtils = __webpack_require__(/*! ./event */ "./node_modules/sockjs-client/lib/utils/event.js"),
|
|
3622
3625
|
browser = __webpack_require__(/*! ./browser */ "./node_modules/sockjs-client/lib/utils/browser.js");
|
|
3623
3626
|
var debug = function debug() {};
|
|
@@ -3787,7 +3790,7 @@ module.exports.iframeEnabled = false;
|
|
|
3787
3790
|
if (__webpack_require__.g.document) {
|
|
3788
3791
|
// postMessage misbehaves in konqueror 4.6.5 - the messages are delivered with
|
|
3789
3792
|
// huge delay, or not at all.
|
|
3790
|
-
module.exports.iframeEnabled = (typeof __webpack_require__.g.postMessage === 'function' ||
|
|
3793
|
+
module.exports.iframeEnabled = (typeof __webpack_require__.g.postMessage === 'function' || _typeof(__webpack_require__.g.postMessage) === 'object') && !browser.isKonqueror();
|
|
3791
3794
|
}
|
|
3792
3795
|
|
|
3793
3796
|
/***/ }),
|
|
@@ -3826,9 +3829,10 @@ module.exports = logObject;
|
|
|
3826
3829
|
"use strict";
|
|
3827
3830
|
|
|
3828
3831
|
|
|
3832
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3829
3833
|
module.exports = {
|
|
3830
3834
|
isObject: function isObject(obj) {
|
|
3831
|
-
var type =
|
|
3835
|
+
var type = _typeof(obj);
|
|
3832
3836
|
return type === 'function' || type === 'object' && !!obj;
|
|
3833
3837
|
},
|
|
3834
3838
|
extend: function extend(obj) {
|
|
@@ -4010,14 +4014,15 @@ module.exports = '1.6.1';
|
|
|
4010
4014
|
"use strict";
|
|
4011
4015
|
|
|
4012
4016
|
|
|
4017
|
+
function _typeof2(o) { "@babel/helpers - typeof"; return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof2(o); }
|
|
4013
4018
|
function _typeof(obj) {
|
|
4014
|
-
if (typeof Symbol === "function" &&
|
|
4019
|
+
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
|
|
4015
4020
|
_typeof = function _typeof(obj) {
|
|
4016
|
-
return
|
|
4021
|
+
return _typeof2(obj);
|
|
4017
4022
|
};
|
|
4018
4023
|
} else {
|
|
4019
4024
|
_typeof = function _typeof(obj) {
|
|
4020
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" :
|
|
4025
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
|
|
4021
4026
|
};
|
|
4022
4027
|
}
|
|
4023
4028
|
return _typeof(obj);
|
|
@@ -4424,6 +4429,7 @@ module.exports = setup;
|
|
|
4424
4429
|
"use strict";
|
|
4425
4430
|
|
|
4426
4431
|
|
|
4432
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4427
4433
|
var required = __webpack_require__(/*! requires-port */ "./node_modules/requires-port/index.js"),
|
|
4428
4434
|
qs = __webpack_require__(/*! querystringify */ "./node_modules/querystringify/index.js"),
|
|
4429
4435
|
controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,
|
|
@@ -4506,7 +4512,7 @@ function lolcation(loc) {
|
|
|
4506
4512
|
var location = globalVar.location || {};
|
|
4507
4513
|
loc = loc || location;
|
|
4508
4514
|
var finaldestination = {},
|
|
4509
|
-
type =
|
|
4515
|
+
type = _typeof(loc),
|
|
4510
4516
|
key;
|
|
4511
4517
|
if ('blob:' === loc.protocol) {
|
|
4512
4518
|
finaldestination = new Url(unescape(loc.pathname), {});
|
|
@@ -4658,7 +4664,7 @@ function Url(address, location, parser) {
|
|
|
4658
4664
|
index,
|
|
4659
4665
|
key,
|
|
4660
4666
|
instructions = rules.slice(),
|
|
4661
|
-
type =
|
|
4667
|
+
type = _typeof(location),
|
|
4662
4668
|
url = this,
|
|
4663
4669
|
i = 0;
|
|
4664
4670
|
|
|
@@ -4910,7 +4916,7 @@ function toString(stringify) {
|
|
|
4910
4916
|
host += ':';
|
|
4911
4917
|
}
|
|
4912
4918
|
result += host + url.pathname;
|
|
4913
|
-
query = 'object' ===
|
|
4919
|
+
query = 'object' === _typeof(url.query) ? stringify(url.query) : url.query;
|
|
4914
4920
|
if (query) result += '?' !== query.charAt(0) ? '?' + query : query;
|
|
4915
4921
|
if (url.hash) result += url.hash;
|
|
4916
4922
|
return result;
|
package/client/overlay.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
7
|
// The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
|
|
7
8
|
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
|
|
8
9
|
|
|
@@ -597,6 +598,11 @@ var createOverlay = function createOverlay(options) {
|
|
|
597
598
|
if (!error && !message) {
|
|
598
599
|
return;
|
|
599
600
|
}
|
|
601
|
+
|
|
602
|
+
// if error stack indicates a React error boundary caught the error, do not show overlay.
|
|
603
|
+
if (error && error.stack && error.stack.includes("invokeGuardedCallbackDev")) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
600
606
|
handleError(error, message);
|
|
601
607
|
});
|
|
602
608
|
listenToUnhandledRejection(function (promiseRejectionEvent) {
|
package/client/progress.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
2
3
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
3
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
7
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" ==
|
|
8
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
8
9
|
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
9
10
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
10
11
|
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
package/client/socket.js
CHANGED
|
@@ -17,6 +17,7 @@ var maxRetries = 10;
|
|
|
17
17
|
// It is mutable to enforce singleton
|
|
18
18
|
// eslint-disable-next-line import/no-mutable-exports
|
|
19
19
|
export var client = null;
|
|
20
|
+
var timeout;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @param {string} url
|
|
@@ -27,6 +28,9 @@ var socket = function initSocket(url, handlers, reconnect) {
|
|
|
27
28
|
client = new Client(url);
|
|
28
29
|
client.onOpen(function () {
|
|
29
30
|
retries = 0;
|
|
31
|
+
if (timeout) {
|
|
32
|
+
clearTimeout(timeout);
|
|
33
|
+
}
|
|
30
34
|
if (typeof reconnect !== "undefined") {
|
|
31
35
|
maxRetries = reconnect;
|
|
32
36
|
}
|
|
@@ -47,7 +51,7 @@ var socket = function initSocket(url, handlers, reconnect) {
|
|
|
47
51
|
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
|
|
48
52
|
retries += 1;
|
|
49
53
|
log.info("Trying to reconnect...");
|
|
50
|
-
setTimeout(function () {
|
|
54
|
+
timeout = setTimeout(function () {
|
|
51
55
|
socket(url, handlers, reconnect);
|
|
52
56
|
}, retryInMs);
|
|
53
57
|
}
|
package/lib/Server.js
CHANGED
|
@@ -307,6 +307,8 @@ function useFn(route, fn) {
|
|
|
307
307
|
return /** @type {BasicApplication} */ ({});
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
const DEFAULT_ALLOWED_PROTOCOLS = /^(file|.+-extension):/i;
|
|
311
|
+
|
|
310
312
|
/**
|
|
311
313
|
* @typedef {Object} BasicApplication
|
|
312
314
|
* @property {typeof useFn} use
|
|
@@ -437,8 +439,9 @@ class Server {
|
|
|
437
439
|
return network.address;
|
|
438
440
|
});
|
|
439
441
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
if (networks.length > 0) {
|
|
443
|
+
// Take the first network found
|
|
444
|
+
host = networks[0].address;
|
|
442
445
|
|
|
443
446
|
if (host.includes(":")) {
|
|
444
447
|
host = `[${host}]`;
|
|
@@ -1960,7 +1963,7 @@ class Server {
|
|
|
1960
1963
|
(req.headers);
|
|
1961
1964
|
const headerName = headers[":authority"] ? ":authority" : "host";
|
|
1962
1965
|
|
|
1963
|
-
if (this.
|
|
1966
|
+
if (this.isValidHost(headers, headerName)) {
|
|
1964
1967
|
next();
|
|
1965
1968
|
return;
|
|
1966
1969
|
}
|
|
@@ -1970,6 +1973,39 @@ class Server {
|
|
|
1970
1973
|
},
|
|
1971
1974
|
});
|
|
1972
1975
|
|
|
1976
|
+
// Register setup cross origin request check for security
|
|
1977
|
+
middlewares.push({
|
|
1978
|
+
name: "cross-origin-header-check",
|
|
1979
|
+
/**
|
|
1980
|
+
* @param {Request} req
|
|
1981
|
+
* @param {Response} res
|
|
1982
|
+
* @param {NextFunction} next
|
|
1983
|
+
* @returns {void}
|
|
1984
|
+
*/
|
|
1985
|
+
middleware: (req, res, next) => {
|
|
1986
|
+
const headers =
|
|
1987
|
+
/** @type {{ [key: string]: string | undefined }} */
|
|
1988
|
+
(req.headers);
|
|
1989
|
+
const headerName = headers[":authority"] ? ":authority" : "host";
|
|
1990
|
+
|
|
1991
|
+
if (this.isValidHost(headers, headerName, false)) {
|
|
1992
|
+
next();
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
if (
|
|
1997
|
+
headers["sec-fetch-mode"] === "no-cors" &&
|
|
1998
|
+
headers["sec-fetch-site"] === "cross-site"
|
|
1999
|
+
) {
|
|
2000
|
+
res.statusCode = 403;
|
|
2001
|
+
res.end("Cross-Origin request blocked");
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
next();
|
|
2006
|
+
},
|
|
2007
|
+
});
|
|
2008
|
+
|
|
1973
2009
|
const isHTTP2 =
|
|
1974
2010
|
/** @type {ServerConfiguration<A, S>} */ (this.options.server).type ===
|
|
1975
2011
|
"http2";
|
|
@@ -2641,8 +2677,9 @@ class Server {
|
|
|
2641
2677
|
|
|
2642
2678
|
if (
|
|
2643
2679
|
!headers ||
|
|
2644
|
-
!this.
|
|
2645
|
-
!this.
|
|
2680
|
+
!this.isValidHost(headers, "host") ||
|
|
2681
|
+
!this.isValidHost(headers, "origin") ||
|
|
2682
|
+
!this.isSameOrigin(headers)
|
|
2646
2683
|
) {
|
|
2647
2684
|
this.sendMessage([client], "error", "Invalid Host/Origin header");
|
|
2648
2685
|
|
|
@@ -2676,7 +2713,8 @@ class Server {
|
|
|
2676
2713
|
|
|
2677
2714
|
if (
|
|
2678
2715
|
this.options.client &&
|
|
2679
|
-
/** @type {ClientConfiguration} */
|
|
2716
|
+
/** @type {ClientConfiguration} */
|
|
2717
|
+
(this.options.client).reconnect
|
|
2680
2718
|
) {
|
|
2681
2719
|
this.sendMessage(
|
|
2682
2720
|
[client],
|
|
@@ -2691,9 +2729,9 @@ class Server {
|
|
|
2691
2729
|
/** @type {ClientConfiguration} */
|
|
2692
2730
|
(this.options.client).overlay
|
|
2693
2731
|
) {
|
|
2694
|
-
const overlayConfig =
|
|
2695
|
-
|
|
2696
|
-
|
|
2732
|
+
const overlayConfig =
|
|
2733
|
+
/** @type {ClientConfiguration} */
|
|
2734
|
+
(this.options.client).overlay;
|
|
2697
2735
|
|
|
2698
2736
|
this.sendMessage(
|
|
2699
2737
|
[client],
|
|
@@ -3057,8 +3095,6 @@ class Server {
|
|
|
3057
3095
|
*/
|
|
3058
3096
|
const allHeaders = [];
|
|
3059
3097
|
|
|
3060
|
-
allHeaders.push({ key: "X_TEST", value: "TEST" });
|
|
3061
|
-
|
|
3062
3098
|
if (!Array.isArray(headers)) {
|
|
3063
3099
|
// eslint-disable-next-line guard-for-in
|
|
3064
3100
|
for (const name in headers) {
|
|
@@ -3079,101 +3115,176 @@ class Server {
|
|
|
3079
3115
|
|
|
3080
3116
|
/**
|
|
3081
3117
|
* @private
|
|
3082
|
-
* @param {
|
|
3083
|
-
* @param {string} headerToCheck
|
|
3118
|
+
* @param {string} value
|
|
3084
3119
|
* @returns {boolean}
|
|
3085
3120
|
*/
|
|
3086
|
-
|
|
3121
|
+
isHostAllowed(value) {
|
|
3122
|
+
const { allowedHosts } = this.options;
|
|
3123
|
+
|
|
3087
3124
|
// allow user to opt out of this security check, at their own risk
|
|
3088
3125
|
// by explicitly enabling allowedHosts
|
|
3126
|
+
if (allowedHosts === "all") {
|
|
3127
|
+
return true;
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
// always allow localhost host, for convenience
|
|
3131
|
+
// allow if value is in allowedHosts
|
|
3132
|
+
if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
|
|
3133
|
+
for (const allowedHost of allowedHosts) {
|
|
3134
|
+
if (allowedHost === value) {
|
|
3135
|
+
return true;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
// support "." as a subdomain wildcard
|
|
3139
|
+
// e.g. ".example.com" will allow "example.com", "www.example.com", "subdomain.example.com", etc
|
|
3140
|
+
if (allowedHost.startsWith(".")) {
|
|
3141
|
+
// "example.com" (value === allowedHost.substring(1))
|
|
3142
|
+
// "*.example.com" (value.endsWith(allowedHost))
|
|
3143
|
+
if (
|
|
3144
|
+
value === allowedHost.substring(1) ||
|
|
3145
|
+
/** @type {string} */
|
|
3146
|
+
(value).endsWith(allowedHost)
|
|
3147
|
+
) {
|
|
3148
|
+
return true;
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
// Also allow if `client.webSocketURL.hostname` provided
|
|
3155
|
+
if (
|
|
3156
|
+
this.options.client &&
|
|
3157
|
+
typeof (
|
|
3158
|
+
/** @type {ClientConfiguration} */
|
|
3159
|
+
(this.options.client).webSocketURL
|
|
3160
|
+
) !== "undefined"
|
|
3161
|
+
) {
|
|
3162
|
+
return (
|
|
3163
|
+
/** @type {WebSocketURL} */
|
|
3164
|
+
(/** @type {ClientConfiguration} */ (this.options.client).webSocketURL)
|
|
3165
|
+
.hostname === value
|
|
3166
|
+
);
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
return false;
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* @private
|
|
3174
|
+
* @param {{ [key: string]: string | undefined }} headers
|
|
3175
|
+
* @param {string} headerToCheck
|
|
3176
|
+
* @param {boolean} validateHost
|
|
3177
|
+
* @returns {boolean}
|
|
3178
|
+
*/
|
|
3179
|
+
isValidHost(headers, headerToCheck, validateHost = true) {
|
|
3089
3180
|
if (this.options.allowedHosts === "all") {
|
|
3090
3181
|
return true;
|
|
3091
3182
|
}
|
|
3092
3183
|
|
|
3093
3184
|
// get the Host header and extract hostname
|
|
3094
3185
|
// we don't care about port not matching
|
|
3095
|
-
const
|
|
3186
|
+
const header = headers[headerToCheck];
|
|
3096
3187
|
|
|
3097
|
-
if (!
|
|
3188
|
+
if (!header) {
|
|
3098
3189
|
return false;
|
|
3099
3190
|
}
|
|
3100
3191
|
|
|
3101
|
-
if (
|
|
3192
|
+
if (DEFAULT_ALLOWED_PROTOCOLS.test(header)) {
|
|
3102
3193
|
return true;
|
|
3103
3194
|
}
|
|
3104
3195
|
|
|
3105
3196
|
// use the node url-parser to retrieve the hostname from the host-header.
|
|
3106
3197
|
const hostname = url.parse(
|
|
3107
|
-
// if
|
|
3108
|
-
/^(.+:)?\/\//.test(
|
|
3198
|
+
// if header doesn't have scheme, add // for parsing.
|
|
3199
|
+
/^(.+:)?\/\//.test(header) ? header : `//${header}`,
|
|
3109
3200
|
false,
|
|
3110
3201
|
true,
|
|
3111
3202
|
).hostname;
|
|
3112
3203
|
|
|
3204
|
+
if (hostname === null) {
|
|
3205
|
+
return false;
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
if (this.isHostAllowed(hostname)) {
|
|
3209
|
+
return true;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3113
3212
|
// always allow requests with explicit IPv4 or IPv6-address.
|
|
3114
3213
|
// A note on IPv6 addresses:
|
|
3115
|
-
//
|
|
3214
|
+
// header will always contain the brackets denoting
|
|
3116
3215
|
// an IPv6-address in URLs,
|
|
3117
3216
|
// these are removed from the hostname in url.parse(),
|
|
3118
3217
|
// so we have the pure IPv6-address in hostname.
|
|
3119
3218
|
// For convenience, always allow localhost (hostname === 'localhost')
|
|
3120
3219
|
// and its subdomains (hostname.endsWith(".localhost")).
|
|
3121
3220
|
// allow hostname of listening address (hostname === this.options.host)
|
|
3122
|
-
const isValidHostname =
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3221
|
+
const isValidHostname = validateHost
|
|
3222
|
+
? ipaddr.IPv4.isValid(hostname) ||
|
|
3223
|
+
ipaddr.IPv6.isValid(hostname) ||
|
|
3224
|
+
hostname === "localhost" ||
|
|
3225
|
+
hostname.endsWith(".localhost") ||
|
|
3226
|
+
hostname === this.options.host
|
|
3227
|
+
: false;
|
|
3228
|
+
|
|
3229
|
+
return isValidHostname;
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
/**
|
|
3233
|
+
* @private
|
|
3234
|
+
* @param {{ [key: string]: string | undefined }} headers
|
|
3235
|
+
* @returns {boolean}
|
|
3236
|
+
*/
|
|
3237
|
+
isSameOrigin(headers) {
|
|
3238
|
+
if (this.options.allowedHosts === "all") {
|
|
3130
3239
|
return true;
|
|
3131
3240
|
}
|
|
3132
3241
|
|
|
3133
|
-
const
|
|
3242
|
+
const originHeader = headers.origin;
|
|
3134
3243
|
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
for (let hostIdx = 0; hostIdx < allowedHosts.length; hostIdx++) {
|
|
3139
|
-
/** @type {string} */
|
|
3140
|
-
const allowedHost = allowedHosts[hostIdx];
|
|
3244
|
+
if (!originHeader) {
|
|
3245
|
+
return this.options.allowedHosts === "all";
|
|
3246
|
+
}
|
|
3141
3247
|
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3248
|
+
if (DEFAULT_ALLOWED_PROTOCOLS.test(originHeader)) {
|
|
3249
|
+
return true;
|
|
3250
|
+
}
|
|
3145
3251
|
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
// "*.example.com" (hostname.endsWith(allowedHost))
|
|
3151
|
-
if (
|
|
3152
|
-
hostname === allowedHost.substring(1) ||
|
|
3153
|
-
/** @type {string} */ (hostname).endsWith(allowedHost)
|
|
3154
|
-
) {
|
|
3155
|
-
return true;
|
|
3156
|
-
}
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3252
|
+
const origin = url.parse(originHeader, false, true).hostname;
|
|
3253
|
+
|
|
3254
|
+
if (origin === null) {
|
|
3255
|
+
return false;
|
|
3159
3256
|
}
|
|
3160
3257
|
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
this.options.client &&
|
|
3164
|
-
typeof (
|
|
3165
|
-
/** @type {ClientConfiguration} */ (this.options.client).webSocketURL
|
|
3166
|
-
) !== "undefined"
|
|
3167
|
-
) {
|
|
3168
|
-
return (
|
|
3169
|
-
/** @type {WebSocketURL} */
|
|
3170
|
-
(/** @type {ClientConfiguration} */ (this.options.client).webSocketURL)
|
|
3171
|
-
.hostname === hostname
|
|
3172
|
-
);
|
|
3258
|
+
if (this.isHostAllowed(origin)) {
|
|
3259
|
+
return true;
|
|
3173
3260
|
}
|
|
3174
3261
|
|
|
3175
|
-
|
|
3176
|
-
|
|
3262
|
+
const hostHeader = headers.host;
|
|
3263
|
+
|
|
3264
|
+
if (!hostHeader) {
|
|
3265
|
+
return this.options.allowedHosts === "all";
|
|
3266
|
+
}
|
|
3267
|
+
|
|
3268
|
+
if (DEFAULT_ALLOWED_PROTOCOLS.test(hostHeader)) {
|
|
3269
|
+
return true;
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3272
|
+
const host = url.parse(
|
|
3273
|
+
// if hostHeader doesn't have scheme, add // for parsing.
|
|
3274
|
+
/^(.+:)?\/\//.test(hostHeader) ? hostHeader : `//${hostHeader}`,
|
|
3275
|
+
false,
|
|
3276
|
+
true,
|
|
3277
|
+
).hostname;
|
|
3278
|
+
|
|
3279
|
+
if (host === null) {
|
|
3280
|
+
return false;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
if (this.isHostAllowed(host)) {
|
|
3284
|
+
return true;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
return origin === host;
|
|
3177
3288
|
}
|
|
3178
3289
|
|
|
3179
3290
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "Serves a webpack app. Updates the browser on changes.",
|
|
5
5
|
"bin": "bin/webpack-dev-server.js",
|
|
6
6
|
"main": "lib/Server.js",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@types/bonjour": "^3.5.13",
|
|
50
50
|
"@types/connect-history-api-fallback": "^1.5.4",
|
|
51
51
|
"@types/express": "^4.17.21",
|
|
52
|
+
"@types/express-serve-static-core": "^4.17.21",
|
|
52
53
|
"@types/serve-index": "^1.9.4",
|
|
53
54
|
"@types/serve-static": "^1.15.5",
|
|
54
55
|
"@types/sockjs": "^0.3.36",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"connect-history-api-fallback": "^2.0.0",
|
|
62
63
|
"express": "^4.21.2",
|
|
63
64
|
"graceful-fs": "^4.2.6",
|
|
64
|
-
"http-proxy-middleware": "^2.0.
|
|
65
|
+
"http-proxy-middleware": "^2.0.9",
|
|
65
66
|
"ipaddr.js": "^2.1.0",
|
|
66
67
|
"launch-editor": "^2.6.1",
|
|
67
68
|
"open": "^10.0.3",
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"@types/trusted-types": "^2.0.2",
|
|
93
94
|
"acorn": "^8.14.0",
|
|
94
95
|
"babel-jest": "^29.5.0",
|
|
95
|
-
"babel-loader": "^
|
|
96
|
+
"babel-loader": "^10.0.0",
|
|
96
97
|
"body-parser": "^1.19.2",
|
|
97
98
|
"connect": "^3.7.0",
|
|
98
99
|
"core-js": "^3.38.1",
|
|
@@ -117,7 +118,7 @@
|
|
|
117
118
|
"memfs": "^4.14.0",
|
|
118
119
|
"npm-run-all": "^4.1.5",
|
|
119
120
|
"prettier": "^3.2.4",
|
|
120
|
-
"puppeteer": "^
|
|
121
|
+
"puppeteer": "^24.10.0",
|
|
121
122
|
"readable-stream": "^4.5.2",
|
|
122
123
|
"require-from-string": "^2.0.2",
|
|
123
124
|
"rimraf": "^5.0.5",
|
package/types/lib/Server.d.ts
CHANGED
|
@@ -1347,13 +1347,26 @@ declare class Server<
|
|
|
1347
1347
|
* @param {NextFunction} next
|
|
1348
1348
|
*/
|
|
1349
1349
|
private setHeaders;
|
|
1350
|
+
/**
|
|
1351
|
+
* @private
|
|
1352
|
+
* @param {string} value
|
|
1353
|
+
* @returns {boolean}
|
|
1354
|
+
*/
|
|
1355
|
+
private isHostAllowed;
|
|
1350
1356
|
/**
|
|
1351
1357
|
* @private
|
|
1352
1358
|
* @param {{ [key: string]: string | undefined }} headers
|
|
1353
1359
|
* @param {string} headerToCheck
|
|
1360
|
+
* @param {boolean} validateHost
|
|
1361
|
+
* @returns {boolean}
|
|
1362
|
+
*/
|
|
1363
|
+
private isValidHost;
|
|
1364
|
+
/**
|
|
1365
|
+
* @private
|
|
1366
|
+
* @param {{ [key: string]: string | undefined }} headers
|
|
1354
1367
|
* @returns {boolean}
|
|
1355
1368
|
*/
|
|
1356
|
-
private
|
|
1369
|
+
private isSameOrigin;
|
|
1357
1370
|
/**
|
|
1358
1371
|
* @param {ClientConnection[]} clients
|
|
1359
1372
|
* @param {string} type
|