@builderbot/bot 1.3.15-alpha.149 → 1.3.15-alpha.151

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.
Files changed (2) hide show
  1. package/dist/index.cjs +2010 -1922
  2. package/package.json +7 -7
package/dist/index.cjs CHANGED
@@ -655,11 +655,15 @@ function getDefaultExportFromCjs (x) {
655
655
  }
656
656
 
657
657
  function getAugmentedNamespace(n) {
658
- if (n.__esModule) return n;
658
+ if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
659
659
  var f = n.default;
660
660
  if (typeof f == "function") {
661
661
  var a = function a () {
662
- if (this instanceof a) {
662
+ var isInstance = false;
663
+ try {
664
+ isInstance = this instanceof a;
665
+ } catch {}
666
+ if (isInstance) {
663
667
  return Reflect.construct(f, arguments, this.constructor);
664
668
  }
665
669
  return f.apply(this, arguments);
@@ -681,83 +685,90 @@ function getAugmentedNamespace(n) {
681
685
 
682
686
  var picocolors = {exports: {}};
683
687
 
684
- let p = process || {}, argv = p.argv || [], env = p.env || {};
685
- let isColorSupported =
686
- !(!!env.NO_COLOR || argv.includes("--no-color")) &&
687
- (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
688
+ var hasRequiredPicocolors;
688
689
 
689
- let formatter = (open, close, replace = open) =>
690
- input => {
691
- let string = "" + input, index = string.indexOf(close, open.length);
692
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
693
- };
690
+ function requirePicocolors () {
691
+ if (hasRequiredPicocolors) return picocolors.exports;
692
+ hasRequiredPicocolors = 1;
693
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
694
+ let isColorSupported =
695
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
696
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
694
697
 
695
- let replaceClose = (string, close, replace, index) => {
696
- let result = "", cursor = 0;
697
- do {
698
- result += string.substring(cursor, index) + replace;
699
- cursor = index + close.length;
700
- index = string.indexOf(close, cursor);
701
- } while (~index)
702
- return result + string.substring(cursor)
703
- };
698
+ let formatter = (open, close, replace = open) =>
699
+ input => {
700
+ let string = "" + input, index = string.indexOf(close, open.length);
701
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
702
+ };
704
703
 
705
- let createColors = (enabled = isColorSupported) => {
706
- let f = enabled ? formatter : () => String;
707
- return {
708
- isColorSupported: enabled,
709
- reset: f("\x1b[0m", "\x1b[0m"),
710
- bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
711
- dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
712
- italic: f("\x1b[3m", "\x1b[23m"),
713
- underline: f("\x1b[4m", "\x1b[24m"),
714
- inverse: f("\x1b[7m", "\x1b[27m"),
715
- hidden: f("\x1b[8m", "\x1b[28m"),
716
- strikethrough: f("\x1b[9m", "\x1b[29m"),
717
-
718
- black: f("\x1b[30m", "\x1b[39m"),
719
- red: f("\x1b[31m", "\x1b[39m"),
720
- green: f("\x1b[32m", "\x1b[39m"),
721
- yellow: f("\x1b[33m", "\x1b[39m"),
722
- blue: f("\x1b[34m", "\x1b[39m"),
723
- magenta: f("\x1b[35m", "\x1b[39m"),
724
- cyan: f("\x1b[36m", "\x1b[39m"),
725
- white: f("\x1b[37m", "\x1b[39m"),
726
- gray: f("\x1b[90m", "\x1b[39m"),
727
-
728
- bgBlack: f("\x1b[40m", "\x1b[49m"),
729
- bgRed: f("\x1b[41m", "\x1b[49m"),
730
- bgGreen: f("\x1b[42m", "\x1b[49m"),
731
- bgYellow: f("\x1b[43m", "\x1b[49m"),
732
- bgBlue: f("\x1b[44m", "\x1b[49m"),
733
- bgMagenta: f("\x1b[45m", "\x1b[49m"),
734
- bgCyan: f("\x1b[46m", "\x1b[49m"),
735
- bgWhite: f("\x1b[47m", "\x1b[49m"),
736
-
737
- blackBright: f("\x1b[90m", "\x1b[39m"),
738
- redBright: f("\x1b[91m", "\x1b[39m"),
739
- greenBright: f("\x1b[92m", "\x1b[39m"),
740
- yellowBright: f("\x1b[93m", "\x1b[39m"),
741
- blueBright: f("\x1b[94m", "\x1b[39m"),
742
- magentaBright: f("\x1b[95m", "\x1b[39m"),
743
- cyanBright: f("\x1b[96m", "\x1b[39m"),
744
- whiteBright: f("\x1b[97m", "\x1b[39m"),
745
-
746
- bgBlackBright: f("\x1b[100m", "\x1b[49m"),
747
- bgRedBright: f("\x1b[101m", "\x1b[49m"),
748
- bgGreenBright: f("\x1b[102m", "\x1b[49m"),
749
- bgYellowBright: f("\x1b[103m", "\x1b[49m"),
750
- bgBlueBright: f("\x1b[104m", "\x1b[49m"),
751
- bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
752
- bgCyanBright: f("\x1b[106m", "\x1b[49m"),
753
- bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
754
- }
755
- };
704
+ let replaceClose = (string, close, replace, index) => {
705
+ let result = "", cursor = 0;
706
+ do {
707
+ result += string.substring(cursor, index) + replace;
708
+ cursor = index + close.length;
709
+ index = string.indexOf(close, cursor);
710
+ } while (~index)
711
+ return result + string.substring(cursor)
712
+ };
756
713
 
757
- picocolors.exports = createColors();
758
- picocolors.exports.createColors = createColors;
714
+ let createColors = (enabled = isColorSupported) => {
715
+ let f = enabled ? formatter : () => String;
716
+ return {
717
+ isColorSupported: enabled,
718
+ reset: f("\x1b[0m", "\x1b[0m"),
719
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
720
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
721
+ italic: f("\x1b[3m", "\x1b[23m"),
722
+ underline: f("\x1b[4m", "\x1b[24m"),
723
+ inverse: f("\x1b[7m", "\x1b[27m"),
724
+ hidden: f("\x1b[8m", "\x1b[28m"),
725
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
726
+
727
+ black: f("\x1b[30m", "\x1b[39m"),
728
+ red: f("\x1b[31m", "\x1b[39m"),
729
+ green: f("\x1b[32m", "\x1b[39m"),
730
+ yellow: f("\x1b[33m", "\x1b[39m"),
731
+ blue: f("\x1b[34m", "\x1b[39m"),
732
+ magenta: f("\x1b[35m", "\x1b[39m"),
733
+ cyan: f("\x1b[36m", "\x1b[39m"),
734
+ white: f("\x1b[37m", "\x1b[39m"),
735
+ gray: f("\x1b[90m", "\x1b[39m"),
736
+
737
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
738
+ bgRed: f("\x1b[41m", "\x1b[49m"),
739
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
740
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
741
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
742
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
743
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
744
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
745
+
746
+ blackBright: f("\x1b[90m", "\x1b[39m"),
747
+ redBright: f("\x1b[91m", "\x1b[39m"),
748
+ greenBright: f("\x1b[92m", "\x1b[39m"),
749
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
750
+ blueBright: f("\x1b[94m", "\x1b[39m"),
751
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
752
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
753
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
754
+
755
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
756
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
757
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
758
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
759
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
760
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
761
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
762
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
763
+ }
764
+ };
765
+
766
+ picocolors.exports = createColors();
767
+ picocolors.exports.createColors = createColors;
768
+ return picocolors.exports;
769
+ }
759
770
 
760
- var picocolorsExports = picocolors.exports;
771
+ var picocolorsExports = /*@__PURE__*/ requirePicocolors();
761
772
  var color = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
762
773
 
763
774
  const NODE_ENV = process.env.NODE_ENV || 'dev';
@@ -2148,710 +2159,725 @@ function requireSrc$1 () {
2148
2159
  return src$1.exports;
2149
2160
  }
2150
2161
 
2151
- var debug$2;
2162
+ var debug_1;
2163
+ var hasRequiredDebug$1;
2152
2164
 
2153
- var debug_1 = function () {
2154
- if (!debug$2) {
2155
- try {
2156
- /* eslint global-require: off */
2157
- debug$2 = requireSrc$1()("follow-redirects");
2158
- }
2159
- catch (error) { /* */ }
2160
- if (typeof debug$2 !== "function") {
2161
- debug$2 = function () { /* */ };
2162
- }
2163
- }
2164
- debug$2.apply(null, arguments);
2165
- };
2165
+ function requireDebug$1 () {
2166
+ if (hasRequiredDebug$1) return debug_1;
2167
+ hasRequiredDebug$1 = 1;
2168
+ var debug;
2166
2169
 
2167
- var url$1 = require$$0$6;
2168
- var URL$1 = url$1.URL;
2169
- var http$1 = require$$1$3;
2170
- var https = require$$2$1;
2171
- var Writable = require$$1$2.Writable;
2172
- var assert = require$$4$1;
2173
- var debug$1 = debug_1;
2174
-
2175
- // Preventive platform detection
2176
- // istanbul ignore next
2177
- (function detectUnsupportedEnvironment() {
2178
- var looksLikeNode = typeof process !== "undefined";
2179
- var looksLikeBrowser = typeof window !== "undefined" && typeof document !== "undefined";
2180
- var looksLikeV8 = isFunction(Error.captureStackTrace);
2181
- if (!looksLikeNode && (looksLikeBrowser || !looksLikeV8)) {
2182
- console.warn("The follow-redirects package should be excluded from browser builds.");
2183
- }
2184
- }());
2185
-
2186
- // Whether to use the native URL object or the legacy url module
2187
- var useNativeURL = false;
2188
- try {
2189
- assert(new URL$1(""));
2190
- }
2191
- catch (error) {
2192
- useNativeURL = error.code === "ERR_INVALID_URL";
2170
+ debug_1 = function () {
2171
+ if (!debug) {
2172
+ try {
2173
+ /* eslint global-require: off */
2174
+ debug = requireSrc$1()("follow-redirects");
2175
+ }
2176
+ catch (error) { /* */ }
2177
+ if (typeof debug !== "function") {
2178
+ debug = function () { /* */ };
2179
+ }
2180
+ }
2181
+ debug.apply(null, arguments);
2182
+ };
2183
+ return debug_1;
2193
2184
  }
2194
2185
 
2195
- // URL fields to preserve in copy operations
2196
- var preservedUrlFields = [
2197
- "auth",
2198
- "host",
2199
- "hostname",
2200
- "href",
2201
- "path",
2202
- "pathname",
2203
- "port",
2204
- "protocol",
2205
- "query",
2206
- "search",
2207
- "hash",
2208
- ];
2186
+ var hasRequiredFollowRedirects;
2187
+
2188
+ function requireFollowRedirects () {
2189
+ if (hasRequiredFollowRedirects) return followRedirects.exports;
2190
+ hasRequiredFollowRedirects = 1;
2191
+ var url = require$$0$6;
2192
+ var URL = url.URL;
2193
+ var http = require$$1$3;
2194
+ var https = require$$2$1;
2195
+ var Writable = require$$1$2.Writable;
2196
+ var assert = require$$4$1;
2197
+ var debug = requireDebug$1();
2198
+
2199
+ // Preventive platform detection
2200
+ // istanbul ignore next
2201
+ (function detectUnsupportedEnvironment() {
2202
+ var looksLikeNode = typeof process !== "undefined";
2203
+ var looksLikeBrowser = typeof window !== "undefined" && typeof document !== "undefined";
2204
+ var looksLikeV8 = isFunction(Error.captureStackTrace);
2205
+ if (!looksLikeNode && (looksLikeBrowser || !looksLikeV8)) {
2206
+ console.warn("The follow-redirects package should be excluded from browser builds.");
2207
+ }
2208
+ }());
2209
2209
 
2210
- // Create handlers that pass events from native requests
2211
- var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
2212
- var eventHandlers = Object.create(null);
2213
- events.forEach(function (event) {
2214
- eventHandlers[event] = function (arg1, arg2, arg3) {
2215
- this._redirectable.emit(event, arg1, arg2, arg3);
2216
- };
2217
- });
2210
+ // Whether to use the native URL object or the legacy url module
2211
+ var useNativeURL = false;
2212
+ try {
2213
+ assert(new URL(""));
2214
+ }
2215
+ catch (error) {
2216
+ useNativeURL = error.code === "ERR_INVALID_URL";
2217
+ }
2218
2218
 
2219
- // Error types with codes
2220
- var InvalidUrlError = createErrorType(
2221
- "ERR_INVALID_URL",
2222
- "Invalid URL",
2223
- TypeError
2224
- );
2225
- var RedirectionError = createErrorType(
2226
- "ERR_FR_REDIRECTION_FAILURE",
2227
- "Redirected request failed"
2228
- );
2229
- var TooManyRedirectsError = createErrorType(
2230
- "ERR_FR_TOO_MANY_REDIRECTS",
2231
- "Maximum number of redirects exceeded",
2232
- RedirectionError
2233
- );
2234
- var MaxBodyLengthExceededError = createErrorType(
2235
- "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
2236
- "Request body larger than maxBodyLength limit"
2237
- );
2238
- var WriteAfterEndError = createErrorType(
2239
- "ERR_STREAM_WRITE_AFTER_END",
2240
- "write after end"
2241
- );
2242
-
2243
- // istanbul ignore next
2244
- var destroy = Writable.prototype.destroy || noop;
2245
-
2246
- // An HTTP(S) request that can be redirected
2247
- function RedirectableRequest(options, responseCallback) {
2248
- // Initialize the request
2249
- Writable.call(this);
2250
- this._sanitizeOptions(options);
2251
- this._options = options;
2252
- this._ended = false;
2253
- this._ending = false;
2254
- this._redirectCount = 0;
2255
- this._redirects = [];
2256
- this._requestBodyLength = 0;
2257
- this._requestBodyBuffers = [];
2258
-
2259
- // Attach a callback if passed
2260
- if (responseCallback) {
2261
- this.on("response", responseCallback);
2262
- }
2263
-
2264
- // React to responses of native requests
2265
- var self = this;
2266
- this._onNativeResponse = function (response) {
2267
- try {
2268
- self._processResponse(response);
2269
- }
2270
- catch (cause) {
2271
- self.emit("error", cause instanceof RedirectionError ?
2272
- cause : new RedirectionError({ cause: cause }));
2273
- }
2274
- };
2219
+ // URL fields to preserve in copy operations
2220
+ var preservedUrlFields = [
2221
+ "auth",
2222
+ "host",
2223
+ "hostname",
2224
+ "href",
2225
+ "path",
2226
+ "pathname",
2227
+ "port",
2228
+ "protocol",
2229
+ "query",
2230
+ "search",
2231
+ "hash",
2232
+ ];
2233
+
2234
+ // Create handlers that pass events from native requests
2235
+ var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
2236
+ var eventHandlers = Object.create(null);
2237
+ events.forEach(function (event) {
2238
+ eventHandlers[event] = function (arg1, arg2, arg3) {
2239
+ this._redirectable.emit(event, arg1, arg2, arg3);
2240
+ };
2241
+ });
2275
2242
 
2276
- // Perform the first request
2277
- this._performRequest();
2278
- }
2279
- RedirectableRequest.prototype = Object.create(Writable.prototype);
2243
+ // Error types with codes
2244
+ var InvalidUrlError = createErrorType(
2245
+ "ERR_INVALID_URL",
2246
+ "Invalid URL",
2247
+ TypeError
2248
+ );
2249
+ var RedirectionError = createErrorType(
2250
+ "ERR_FR_REDIRECTION_FAILURE",
2251
+ "Redirected request failed"
2252
+ );
2253
+ var TooManyRedirectsError = createErrorType(
2254
+ "ERR_FR_TOO_MANY_REDIRECTS",
2255
+ "Maximum number of redirects exceeded",
2256
+ RedirectionError
2257
+ );
2258
+ var MaxBodyLengthExceededError = createErrorType(
2259
+ "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
2260
+ "Request body larger than maxBodyLength limit"
2261
+ );
2262
+ var WriteAfterEndError = createErrorType(
2263
+ "ERR_STREAM_WRITE_AFTER_END",
2264
+ "write after end"
2265
+ );
2280
2266
 
2281
- RedirectableRequest.prototype.abort = function () {
2282
- destroyRequest(this._currentRequest);
2283
- this._currentRequest.abort();
2284
- this.emit("abort");
2285
- };
2267
+ // istanbul ignore next
2268
+ var destroy = Writable.prototype.destroy || noop;
2269
+
2270
+ // An HTTP(S) request that can be redirected
2271
+ function RedirectableRequest(options, responseCallback) {
2272
+ // Initialize the request
2273
+ Writable.call(this);
2274
+ this._sanitizeOptions(options);
2275
+ this._options = options;
2276
+ this._ended = false;
2277
+ this._ending = false;
2278
+ this._redirectCount = 0;
2279
+ this._redirects = [];
2280
+ this._requestBodyLength = 0;
2281
+ this._requestBodyBuffers = [];
2282
+
2283
+ // Attach a callback if passed
2284
+ if (responseCallback) {
2285
+ this.on("response", responseCallback);
2286
+ }
2286
2287
 
2287
- RedirectableRequest.prototype.destroy = function (error) {
2288
- destroyRequest(this._currentRequest, error);
2289
- destroy.call(this, error);
2290
- return this;
2291
- };
2288
+ // React to responses of native requests
2289
+ var self = this;
2290
+ this._onNativeResponse = function (response) {
2291
+ try {
2292
+ self._processResponse(response);
2293
+ }
2294
+ catch (cause) {
2295
+ self.emit("error", cause instanceof RedirectionError ?
2296
+ cause : new RedirectionError({ cause: cause }));
2297
+ }
2298
+ };
2292
2299
 
2293
- // Writes buffered data to the current native request
2294
- RedirectableRequest.prototype.write = function (data, encoding, callback) {
2295
- // Writing is not allowed if end has been called
2296
- if (this._ending) {
2297
- throw new WriteAfterEndError();
2298
- }
2299
-
2300
- // Validate input and shift parameters if necessary
2301
- if (!isString(data) && !isBuffer(data)) {
2302
- throw new TypeError("data should be a string, Buffer or Uint8Array");
2303
- }
2304
- if (isFunction(encoding)) {
2305
- callback = encoding;
2306
- encoding = null;
2307
- }
2308
-
2309
- // Ignore empty buffers, since writing them doesn't invoke the callback
2310
- // https://github.com/nodejs/node/issues/22066
2311
- if (data.length === 0) {
2312
- if (callback) {
2313
- callback();
2314
- }
2315
- return;
2316
- }
2317
- // Only write when we don't exceed the maximum body length
2318
- if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
2319
- this._requestBodyLength += data.length;
2320
- this._requestBodyBuffers.push({ data: data, encoding: encoding });
2321
- this._currentRequest.write(data, encoding, callback);
2322
- }
2323
- // Error when we exceed the maximum body length
2324
- else {
2325
- this.emit("error", new MaxBodyLengthExceededError());
2326
- this.abort();
2327
- }
2328
- };
2300
+ // Perform the first request
2301
+ this._performRequest();
2302
+ }
2303
+ RedirectableRequest.prototype = Object.create(Writable.prototype);
2329
2304
 
2330
- // Ends the current native request
2331
- RedirectableRequest.prototype.end = function (data, encoding, callback) {
2332
- // Shift parameters if necessary
2333
- if (isFunction(data)) {
2334
- callback = data;
2335
- data = encoding = null;
2336
- }
2337
- else if (isFunction(encoding)) {
2338
- callback = encoding;
2339
- encoding = null;
2340
- }
2341
-
2342
- // Write data if needed and end
2343
- if (!data) {
2344
- this._ended = this._ending = true;
2345
- this._currentRequest.end(null, null, callback);
2346
- }
2347
- else {
2348
- var self = this;
2349
- var currentRequest = this._currentRequest;
2350
- this.write(data, encoding, function () {
2351
- self._ended = true;
2352
- currentRequest.end(null, null, callback);
2353
- });
2354
- this._ending = true;
2355
- }
2356
- };
2305
+ RedirectableRequest.prototype.abort = function () {
2306
+ destroyRequest(this._currentRequest);
2307
+ this._currentRequest.abort();
2308
+ this.emit("abort");
2309
+ };
2357
2310
 
2358
- // Sets a header value on the current native request
2359
- RedirectableRequest.prototype.setHeader = function (name, value) {
2360
- this._options.headers[name] = value;
2361
- this._currentRequest.setHeader(name, value);
2362
- };
2311
+ RedirectableRequest.prototype.destroy = function (error) {
2312
+ destroyRequest(this._currentRequest, error);
2313
+ destroy.call(this, error);
2314
+ return this;
2315
+ };
2363
2316
 
2364
- // Clears a header value on the current native request
2365
- RedirectableRequest.prototype.removeHeader = function (name) {
2366
- delete this._options.headers[name];
2367
- this._currentRequest.removeHeader(name);
2368
- };
2317
+ // Writes buffered data to the current native request
2318
+ RedirectableRequest.prototype.write = function (data, encoding, callback) {
2319
+ // Writing is not allowed if end has been called
2320
+ if (this._ending) {
2321
+ throw new WriteAfterEndError();
2322
+ }
2369
2323
 
2370
- // Global timeout for all underlying requests
2371
- RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
2372
- var self = this;
2373
-
2374
- // Destroys the socket on timeout
2375
- function destroyOnTimeout(socket) {
2376
- socket.setTimeout(msecs);
2377
- socket.removeListener("timeout", socket.destroy);
2378
- socket.addListener("timeout", socket.destroy);
2379
- }
2380
-
2381
- // Sets up a timer to trigger a timeout event
2382
- function startTimer(socket) {
2383
- if (self._timeout) {
2384
- clearTimeout(self._timeout);
2385
- }
2386
- self._timeout = setTimeout(function () {
2387
- self.emit("timeout");
2388
- clearTimer();
2389
- }, msecs);
2390
- destroyOnTimeout(socket);
2391
- }
2392
-
2393
- // Stops a timeout from triggering
2394
- function clearTimer() {
2395
- // Clear the timeout
2396
- if (self._timeout) {
2397
- clearTimeout(self._timeout);
2398
- self._timeout = null;
2399
- }
2324
+ // Validate input and shift parameters if necessary
2325
+ if (!isString(data) && !isBuffer(data)) {
2326
+ throw new TypeError("data should be a string, Buffer or Uint8Array");
2327
+ }
2328
+ if (isFunction(encoding)) {
2329
+ callback = encoding;
2330
+ encoding = null;
2331
+ }
2400
2332
 
2401
- // Clean up all attached listeners
2402
- self.removeListener("abort", clearTimer);
2403
- self.removeListener("error", clearTimer);
2404
- self.removeListener("response", clearTimer);
2405
- self.removeListener("close", clearTimer);
2406
- if (callback) {
2407
- self.removeListener("timeout", callback);
2408
- }
2409
- if (!self.socket) {
2410
- self._currentRequest.removeListener("socket", startTimer);
2411
- }
2412
- }
2413
-
2414
- // Attach callback if passed
2415
- if (callback) {
2416
- this.on("timeout", callback);
2417
- }
2418
-
2419
- // Start the timer if or when the socket is opened
2420
- if (this.socket) {
2421
- startTimer(this.socket);
2422
- }
2423
- else {
2424
- this._currentRequest.once("socket", startTimer);
2425
- }
2426
-
2427
- // Clean up on events
2428
- this.on("socket", destroyOnTimeout);
2429
- this.on("abort", clearTimer);
2430
- this.on("error", clearTimer);
2431
- this.on("response", clearTimer);
2432
- this.on("close", clearTimer);
2433
-
2434
- return this;
2435
- };
2333
+ // Ignore empty buffers, since writing them doesn't invoke the callback
2334
+ // https://github.com/nodejs/node/issues/22066
2335
+ if (data.length === 0) {
2336
+ if (callback) {
2337
+ callback();
2338
+ }
2339
+ return;
2340
+ }
2341
+ // Only write when we don't exceed the maximum body length
2342
+ if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
2343
+ this._requestBodyLength += data.length;
2344
+ this._requestBodyBuffers.push({ data: data, encoding: encoding });
2345
+ this._currentRequest.write(data, encoding, callback);
2346
+ }
2347
+ // Error when we exceed the maximum body length
2348
+ else {
2349
+ this.emit("error", new MaxBodyLengthExceededError());
2350
+ this.abort();
2351
+ }
2352
+ };
2436
2353
 
2437
- // Proxy all other public ClientRequest methods
2438
- [
2439
- "flushHeaders", "getHeader",
2440
- "setNoDelay", "setSocketKeepAlive",
2441
- ].forEach(function (method) {
2442
- RedirectableRequest.prototype[method] = function (a, b) {
2443
- return this._currentRequest[method](a, b);
2444
- };
2445
- });
2354
+ // Ends the current native request
2355
+ RedirectableRequest.prototype.end = function (data, encoding, callback) {
2356
+ // Shift parameters if necessary
2357
+ if (isFunction(data)) {
2358
+ callback = data;
2359
+ data = encoding = null;
2360
+ }
2361
+ else if (isFunction(encoding)) {
2362
+ callback = encoding;
2363
+ encoding = null;
2364
+ }
2446
2365
 
2447
- // Proxy all public ClientRequest properties
2448
- ["aborted", "connection", "socket"].forEach(function (property) {
2449
- Object.defineProperty(RedirectableRequest.prototype, property, {
2450
- get: function () { return this._currentRequest[property]; },
2451
- });
2452
- });
2366
+ // Write data if needed and end
2367
+ if (!data) {
2368
+ this._ended = this._ending = true;
2369
+ this._currentRequest.end(null, null, callback);
2370
+ }
2371
+ else {
2372
+ var self = this;
2373
+ var currentRequest = this._currentRequest;
2374
+ this.write(data, encoding, function () {
2375
+ self._ended = true;
2376
+ currentRequest.end(null, null, callback);
2377
+ });
2378
+ this._ending = true;
2379
+ }
2380
+ };
2453
2381
 
2454
- RedirectableRequest.prototype._sanitizeOptions = function (options) {
2455
- // Ensure headers are always present
2456
- if (!options.headers) {
2457
- options.headers = {};
2458
- }
2459
-
2460
- // Since http.request treats host as an alias of hostname,
2461
- // but the url module interprets host as hostname plus port,
2462
- // eliminate the host property to avoid confusion.
2463
- if (options.host) {
2464
- // Use hostname if set, because it has precedence
2465
- if (!options.hostname) {
2466
- options.hostname = options.host;
2467
- }
2468
- delete options.host;
2469
- }
2470
-
2471
- // Complete the URL object when necessary
2472
- if (!options.pathname && options.path) {
2473
- var searchPos = options.path.indexOf("?");
2474
- if (searchPos < 0) {
2475
- options.pathname = options.path;
2476
- }
2477
- else {
2478
- options.pathname = options.path.substring(0, searchPos);
2479
- options.search = options.path.substring(searchPos);
2480
- }
2481
- }
2482
- };
2382
+ // Sets a header value on the current native request
2383
+ RedirectableRequest.prototype.setHeader = function (name, value) {
2384
+ this._options.headers[name] = value;
2385
+ this._currentRequest.setHeader(name, value);
2386
+ };
2483
2387
 
2388
+ // Clears a header value on the current native request
2389
+ RedirectableRequest.prototype.removeHeader = function (name) {
2390
+ delete this._options.headers[name];
2391
+ this._currentRequest.removeHeader(name);
2392
+ };
2484
2393
 
2485
- // Executes the next native request (initial or redirect)
2486
- RedirectableRequest.prototype._performRequest = function () {
2487
- // Load the native protocol
2488
- var protocol = this._options.protocol;
2489
- var nativeProtocol = this._options.nativeProtocols[protocol];
2490
- if (!nativeProtocol) {
2491
- throw new TypeError("Unsupported protocol " + protocol);
2492
- }
2493
-
2494
- // If specified, use the agent corresponding to the protocol
2495
- // (HTTP and HTTPS use different types of agents)
2496
- if (this._options.agents) {
2497
- var scheme = protocol.slice(0, -1);
2498
- this._options.agent = this._options.agents[scheme];
2499
- }
2500
-
2501
- // Create the native request and set up its event handlers
2502
- var request = this._currentRequest =
2503
- nativeProtocol.request(this._options, this._onNativeResponse);
2504
- request._redirectable = this;
2505
- for (var event of events) {
2506
- request.on(event, eventHandlers[event]);
2507
- }
2508
-
2509
- // RFC7230§5.3.1: When making a request directly to an origin server, […]
2510
- // a client MUST send only the absolute path […] as the request-target.
2511
- this._currentUrl = /^\//.test(this._options.path) ?
2512
- url$1.format(this._options) :
2513
- // When making a request to a proxy, […]
2514
- // a client MUST send the target URI in absolute-form […].
2515
- this._options.path;
2516
-
2517
- // End a redirected request
2518
- // (The first request must be ended explicitly with RedirectableRequest#end)
2519
- if (this._isRedirect) {
2520
- // Write the request entity and end
2521
- var i = 0;
2522
- var self = this;
2523
- var buffers = this._requestBodyBuffers;
2524
- (function writeNext(error) {
2525
- // Only write if this request has not been redirected yet
2526
- // istanbul ignore else
2527
- if (request === self._currentRequest) {
2528
- // Report any write errors
2529
- // istanbul ignore if
2530
- if (error) {
2531
- self.emit("error", error);
2532
- }
2533
- // Write the next buffer if there are still left
2534
- else if (i < buffers.length) {
2535
- var buffer = buffers[i++];
2536
- // istanbul ignore else
2537
- if (!request.finished) {
2538
- request.write(buffer.data, buffer.encoding, writeNext);
2539
- }
2540
- }
2541
- // End the request if `end` has been called on us
2542
- else if (self._ended) {
2543
- request.end();
2544
- }
2545
- }
2546
- }());
2547
- }
2548
- };
2394
+ // Global timeout for all underlying requests
2395
+ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
2396
+ var self = this;
2549
2397
 
2550
- // Processes a response from the current native request
2551
- RedirectableRequest.prototype._processResponse = function (response) {
2552
- // Store the redirected response
2553
- var statusCode = response.statusCode;
2554
- if (this._options.trackRedirects) {
2555
- this._redirects.push({
2556
- url: this._currentUrl,
2557
- headers: response.headers,
2558
- statusCode: statusCode,
2559
- });
2560
- }
2561
-
2562
- // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
2563
- // that further action needs to be taken by the user agent in order to
2564
- // fulfill the request. If a Location header field is provided,
2565
- // the user agent MAY automatically redirect its request to the URI
2566
- // referenced by the Location field value,
2567
- // even if the specific status code is not understood.
2568
-
2569
- // If the response is not a redirect; return it as-is
2570
- var location = response.headers.location;
2571
- if (!location || this._options.followRedirects === false ||
2572
- statusCode < 300 || statusCode >= 400) {
2573
- response.responseUrl = this._currentUrl;
2574
- response.redirects = this._redirects;
2575
- this.emit("response", response);
2576
-
2577
- // Clean up
2578
- this._requestBodyBuffers = [];
2579
- return;
2580
- }
2581
-
2582
- // The response is a redirect, so abort the current request
2583
- destroyRequest(this._currentRequest);
2584
- // Discard the remainder of the response to avoid waiting for data
2585
- response.destroy();
2586
-
2587
- // RFC7231§6.4: A client SHOULD detect and intervene
2588
- // in cyclical redirections (i.e., "infinite" redirection loops).
2589
- if (++this._redirectCount > this._options.maxRedirects) {
2590
- throw new TooManyRedirectsError();
2591
- }
2592
-
2593
- // Store the request headers if applicable
2594
- var requestHeaders;
2595
- var beforeRedirect = this._options.beforeRedirect;
2596
- if (beforeRedirect) {
2597
- requestHeaders = Object.assign({
2598
- // The Host header was set by nativeProtocol.request
2599
- Host: response.req.getHeader("host"),
2600
- }, this._options.headers);
2601
- }
2602
-
2603
- // RFC7231§6.4: Automatic redirection needs to done with
2604
- // care for methods not known to be safe, […]
2605
- // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
2606
- // the request method from POST to GET for the subsequent request.
2607
- var method = this._options.method;
2608
- if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
2609
- // RFC7231§6.4.4: The 303 (See Other) status code indicates that
2610
- // the server is redirecting the user agent to a different resource […]
2611
- // A user agent can perform a retrieval request targeting that URI
2612
- // (a GET or HEAD request if using HTTP) […]
2613
- (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2614
- this._options.method = "GET";
2615
- // Drop a possible entity and headers related to it
2616
- this._requestBodyBuffers = [];
2617
- removeMatchingHeaders(/^content-/i, this._options.headers);
2618
- }
2619
-
2620
- // Drop the Host header, as the redirect might lead to a different host
2621
- var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
2622
-
2623
- // If the redirect is relative, carry over the host of the last request
2624
- var currentUrlParts = parseUrl(this._currentUrl);
2625
- var currentHost = currentHostHeader || currentUrlParts.host;
2626
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
2627
- url$1.format(Object.assign(currentUrlParts, { host: currentHost }));
2628
-
2629
- // Create the redirected request
2630
- var redirectUrl = resolveUrl(location, currentUrl);
2631
- debug$1("redirecting to", redirectUrl.href);
2632
- this._isRedirect = true;
2633
- spreadUrlObject(redirectUrl, this._options);
2634
-
2635
- // Drop confidential headers when redirecting to a less secure protocol
2636
- // or to a different domain that is not a superdomain
2637
- if (redirectUrl.protocol !== currentUrlParts.protocol &&
2638
- redirectUrl.protocol !== "https:" ||
2639
- redirectUrl.host !== currentHost &&
2640
- !isSubdomain(redirectUrl.host, currentHost)) {
2641
- removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
2642
- }
2643
-
2644
- // Evaluate the beforeRedirect callback
2645
- if (isFunction(beforeRedirect)) {
2646
- var responseDetails = {
2647
- headers: response.headers,
2648
- statusCode: statusCode,
2649
- };
2650
- var requestDetails = {
2651
- url: currentUrl,
2652
- method: method,
2653
- headers: requestHeaders,
2654
- };
2655
- beforeRedirect(this._options, responseDetails, requestDetails);
2656
- this._sanitizeOptions(this._options);
2657
- }
2398
+ // Destroys the socket on timeout
2399
+ function destroyOnTimeout(socket) {
2400
+ socket.setTimeout(msecs);
2401
+ socket.removeListener("timeout", socket.destroy);
2402
+ socket.addListener("timeout", socket.destroy);
2403
+ }
2658
2404
 
2659
- // Perform the redirected request
2660
- this._performRequest();
2661
- };
2405
+ // Sets up a timer to trigger a timeout event
2406
+ function startTimer(socket) {
2407
+ if (self._timeout) {
2408
+ clearTimeout(self._timeout);
2409
+ }
2410
+ self._timeout = setTimeout(function () {
2411
+ self.emit("timeout");
2412
+ clearTimer();
2413
+ }, msecs);
2414
+ destroyOnTimeout(socket);
2415
+ }
2662
2416
 
2663
- // Wraps the key/value object of protocols with redirect functionality
2664
- function wrap(protocols) {
2665
- // Default settings
2666
- var exports$1 = {
2667
- maxRedirects: 21,
2668
- maxBodyLength: 10 * 1024 * 1024,
2669
- };
2670
-
2671
- // Wrap each protocol
2672
- var nativeProtocols = {};
2673
- Object.keys(protocols).forEach(function (scheme) {
2674
- var protocol = scheme + ":";
2675
- var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
2676
- var wrappedProtocol = exports$1[scheme] = Object.create(nativeProtocol);
2677
-
2678
- // Executes a request, following redirects
2679
- function request(input, options, callback) {
2680
- // Parse parameters, ensuring that input is an object
2681
- if (isURL(input)) {
2682
- input = spreadUrlObject(input);
2683
- }
2684
- else if (isString(input)) {
2685
- input = spreadUrlObject(parseUrl(input));
2686
- }
2687
- else {
2688
- callback = options;
2689
- options = validateUrl(input);
2690
- input = { protocol: protocol };
2691
- }
2692
- if (isFunction(options)) {
2693
- callback = options;
2694
- options = null;
2695
- }
2696
-
2697
- // Set defaults
2698
- options = Object.assign({
2699
- maxRedirects: exports$1.maxRedirects,
2700
- maxBodyLength: exports$1.maxBodyLength,
2701
- }, input, options);
2702
- options.nativeProtocols = nativeProtocols;
2703
- if (!isString(options.host) && !isString(options.hostname)) {
2704
- options.hostname = "::1";
2705
- }
2706
-
2707
- assert.equal(options.protocol, protocol, "protocol mismatch");
2708
- debug$1("options", options);
2709
- return new RedirectableRequest(options, callback);
2710
- }
2417
+ // Stops a timeout from triggering
2418
+ function clearTimer() {
2419
+ // Clear the timeout
2420
+ if (self._timeout) {
2421
+ clearTimeout(self._timeout);
2422
+ self._timeout = null;
2423
+ }
2711
2424
 
2712
- // Executes a GET request, following redirects
2713
- function get(input, options, callback) {
2714
- var wrappedRequest = wrappedProtocol.request(input, options, callback);
2715
- wrappedRequest.end();
2716
- return wrappedRequest;
2717
- }
2425
+ // Clean up all attached listeners
2426
+ self.removeListener("abort", clearTimer);
2427
+ self.removeListener("error", clearTimer);
2428
+ self.removeListener("response", clearTimer);
2429
+ self.removeListener("close", clearTimer);
2430
+ if (callback) {
2431
+ self.removeListener("timeout", callback);
2432
+ }
2433
+ if (!self.socket) {
2434
+ self._currentRequest.removeListener("socket", startTimer);
2435
+ }
2436
+ }
2718
2437
 
2719
- // Expose the properties on the wrapped protocol
2720
- Object.defineProperties(wrappedProtocol, {
2721
- request: { value: request, configurable: true, enumerable: true, writable: true },
2722
- get: { value: get, configurable: true, enumerable: true, writable: true },
2723
- });
2724
- });
2725
- return exports$1;
2726
- }
2438
+ // Attach callback if passed
2439
+ if (callback) {
2440
+ this.on("timeout", callback);
2441
+ }
2727
2442
 
2728
- function noop() { /* empty */ }
2729
-
2730
- function parseUrl(input) {
2731
- var parsed;
2732
- // istanbul ignore else
2733
- if (useNativeURL) {
2734
- parsed = new URL$1(input);
2735
- }
2736
- else {
2737
- // Ensure the URL is valid and absolute
2738
- parsed = validateUrl(url$1.parse(input));
2739
- if (!isString(parsed.protocol)) {
2740
- throw new InvalidUrlError({ input });
2741
- }
2742
- }
2743
- return parsed;
2744
- }
2443
+ // Start the timer if or when the socket is opened
2444
+ if (this.socket) {
2445
+ startTimer(this.socket);
2446
+ }
2447
+ else {
2448
+ this._currentRequest.once("socket", startTimer);
2449
+ }
2745
2450
 
2746
- function resolveUrl(relative, base) {
2747
- // istanbul ignore next
2748
- return useNativeURL ? new URL$1(relative, base) : parseUrl(url$1.resolve(base, relative));
2749
- }
2451
+ // Clean up on events
2452
+ this.on("socket", destroyOnTimeout);
2453
+ this.on("abort", clearTimer);
2454
+ this.on("error", clearTimer);
2455
+ this.on("response", clearTimer);
2456
+ this.on("close", clearTimer);
2750
2457
 
2751
- function validateUrl(input) {
2752
- if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
2753
- throw new InvalidUrlError({ input: input.href || input });
2754
- }
2755
- if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
2756
- throw new InvalidUrlError({ input: input.href || input });
2757
- }
2758
- return input;
2759
- }
2458
+ return this;
2459
+ };
2760
2460
 
2761
- function spreadUrlObject(urlObject, target) {
2762
- var spread = target || {};
2763
- for (var key of preservedUrlFields) {
2764
- spread[key] = urlObject[key];
2765
- }
2766
-
2767
- // Fix IPv6 hostname
2768
- if (spread.hostname.startsWith("[")) {
2769
- spread.hostname = spread.hostname.slice(1, -1);
2770
- }
2771
- // Ensure port is a number
2772
- if (spread.port !== "") {
2773
- spread.port = Number(spread.port);
2774
- }
2775
- // Concatenate path
2776
- spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
2777
-
2778
- return spread;
2779
- }
2461
+ // Proxy all other public ClientRequest methods
2462
+ [
2463
+ "flushHeaders", "getHeader",
2464
+ "setNoDelay", "setSocketKeepAlive",
2465
+ ].forEach(function (method) {
2466
+ RedirectableRequest.prototype[method] = function (a, b) {
2467
+ return this._currentRequest[method](a, b);
2468
+ };
2469
+ });
2780
2470
 
2781
- function removeMatchingHeaders(regex, headers) {
2782
- var lastValue;
2783
- for (var header in headers) {
2784
- if (regex.test(header)) {
2785
- lastValue = headers[header];
2786
- delete headers[header];
2787
- }
2788
- }
2789
- return (lastValue === null || typeof lastValue === "undefined") ?
2790
- undefined : String(lastValue).trim();
2791
- }
2471
+ // Proxy all public ClientRequest properties
2472
+ ["aborted", "connection", "socket"].forEach(function (property) {
2473
+ Object.defineProperty(RedirectableRequest.prototype, property, {
2474
+ get: function () { return this._currentRequest[property]; },
2475
+ });
2476
+ });
2792
2477
 
2793
- function createErrorType(code, message, baseClass) {
2794
- // Create constructor
2795
- function CustomError(properties) {
2796
- // istanbul ignore else
2797
- if (isFunction(Error.captureStackTrace)) {
2798
- Error.captureStackTrace(this, this.constructor);
2799
- }
2800
- Object.assign(this, properties || {});
2801
- this.code = code;
2802
- this.message = this.cause ? message + ": " + this.cause.message : message;
2803
- }
2804
-
2805
- // Attach constructor and set default properties
2806
- CustomError.prototype = new (baseClass || Error)();
2807
- Object.defineProperties(CustomError.prototype, {
2808
- constructor: {
2809
- value: CustomError,
2810
- enumerable: false,
2811
- },
2812
- name: {
2813
- value: "Error [" + code + "]",
2814
- enumerable: false,
2815
- },
2816
- });
2817
- return CustomError;
2818
- }
2478
+ RedirectableRequest.prototype._sanitizeOptions = function (options) {
2479
+ // Ensure headers are always present
2480
+ if (!options.headers) {
2481
+ options.headers = {};
2482
+ }
2819
2483
 
2820
- function destroyRequest(request, error) {
2821
- for (var event of events) {
2822
- request.removeListener(event, eventHandlers[event]);
2823
- }
2824
- request.on("error", noop);
2825
- request.destroy(error);
2826
- }
2484
+ // Since http.request treats host as an alias of hostname,
2485
+ // but the url module interprets host as hostname plus port,
2486
+ // eliminate the host property to avoid confusion.
2487
+ if (options.host) {
2488
+ // Use hostname if set, because it has precedence
2489
+ if (!options.hostname) {
2490
+ options.hostname = options.host;
2491
+ }
2492
+ delete options.host;
2493
+ }
2827
2494
 
2828
- function isSubdomain(subdomain, domain) {
2829
- assert(isString(subdomain) && isString(domain));
2830
- var dot = subdomain.length - domain.length - 1;
2831
- return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
2832
- }
2495
+ // Complete the URL object when necessary
2496
+ if (!options.pathname && options.path) {
2497
+ var searchPos = options.path.indexOf("?");
2498
+ if (searchPos < 0) {
2499
+ options.pathname = options.path;
2500
+ }
2501
+ else {
2502
+ options.pathname = options.path.substring(0, searchPos);
2503
+ options.search = options.path.substring(searchPos);
2504
+ }
2505
+ }
2506
+ };
2833
2507
 
2834
- function isString(value) {
2835
- return typeof value === "string" || value instanceof String;
2836
- }
2837
2508
 
2838
- function isFunction(value) {
2839
- return typeof value === "function";
2840
- }
2509
+ // Executes the next native request (initial or redirect)
2510
+ RedirectableRequest.prototype._performRequest = function () {
2511
+ // Load the native protocol
2512
+ var protocol = this._options.protocol;
2513
+ var nativeProtocol = this._options.nativeProtocols[protocol];
2514
+ if (!nativeProtocol) {
2515
+ throw new TypeError("Unsupported protocol " + protocol);
2516
+ }
2841
2517
 
2842
- function isBuffer(value) {
2843
- return typeof value === "object" && ("length" in value);
2844
- }
2518
+ // If specified, use the agent corresponding to the protocol
2519
+ // (HTTP and HTTPS use different types of agents)
2520
+ if (this._options.agents) {
2521
+ var scheme = protocol.slice(0, -1);
2522
+ this._options.agent = this._options.agents[scheme];
2523
+ }
2845
2524
 
2846
- function isURL(value) {
2847
- return URL$1 && value instanceof URL$1;
2848
- }
2525
+ // Create the native request and set up its event handlers
2526
+ var request = this._currentRequest =
2527
+ nativeProtocol.request(this._options, this._onNativeResponse);
2528
+ request._redirectable = this;
2529
+ for (var event of events) {
2530
+ request.on(event, eventHandlers[event]);
2531
+ }
2532
+
2533
+ // RFC7230§5.3.1: When making a request directly to an origin server, […]
2534
+ // a client MUST send only the absolute path […] as the request-target.
2535
+ this._currentUrl = /^\//.test(this._options.path) ?
2536
+ url.format(this._options) :
2537
+ // When making a request to a proxy, […]
2538
+ // a client MUST send the target URI in absolute-form […].
2539
+ this._options.path;
2540
+
2541
+ // End a redirected request
2542
+ // (The first request must be ended explicitly with RedirectableRequest#end)
2543
+ if (this._isRedirect) {
2544
+ // Write the request entity and end
2545
+ var i = 0;
2546
+ var self = this;
2547
+ var buffers = this._requestBodyBuffers;
2548
+ (function writeNext(error) {
2549
+ // Only write if this request has not been redirected yet
2550
+ // istanbul ignore else
2551
+ if (request === self._currentRequest) {
2552
+ // Report any write errors
2553
+ // istanbul ignore if
2554
+ if (error) {
2555
+ self.emit("error", error);
2556
+ }
2557
+ // Write the next buffer if there are still left
2558
+ else if (i < buffers.length) {
2559
+ var buffer = buffers[i++];
2560
+ // istanbul ignore else
2561
+ if (!request.finished) {
2562
+ request.write(buffer.data, buffer.encoding, writeNext);
2563
+ }
2564
+ }
2565
+ // End the request if `end` has been called on us
2566
+ else if (self._ended) {
2567
+ request.end();
2568
+ }
2569
+ }
2570
+ }());
2571
+ }
2572
+ };
2573
+
2574
+ // Processes a response from the current native request
2575
+ RedirectableRequest.prototype._processResponse = function (response) {
2576
+ // Store the redirected response
2577
+ var statusCode = response.statusCode;
2578
+ if (this._options.trackRedirects) {
2579
+ this._redirects.push({
2580
+ url: this._currentUrl,
2581
+ headers: response.headers,
2582
+ statusCode: statusCode,
2583
+ });
2584
+ }
2585
+
2586
+ // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
2587
+ // that further action needs to be taken by the user agent in order to
2588
+ // fulfill the request. If a Location header field is provided,
2589
+ // the user agent MAY automatically redirect its request to the URI
2590
+ // referenced by the Location field value,
2591
+ // even if the specific status code is not understood.
2592
+
2593
+ // If the response is not a redirect; return it as-is
2594
+ var location = response.headers.location;
2595
+ if (!location || this._options.followRedirects === false ||
2596
+ statusCode < 300 || statusCode >= 400) {
2597
+ response.responseUrl = this._currentUrl;
2598
+ response.redirects = this._redirects;
2599
+ this.emit("response", response);
2600
+
2601
+ // Clean up
2602
+ this._requestBodyBuffers = [];
2603
+ return;
2604
+ }
2605
+
2606
+ // The response is a redirect, so abort the current request
2607
+ destroyRequest(this._currentRequest);
2608
+ // Discard the remainder of the response to avoid waiting for data
2609
+ response.destroy();
2610
+
2611
+ // RFC7231§6.4: A client SHOULD detect and intervene
2612
+ // in cyclical redirections (i.e., "infinite" redirection loops).
2613
+ if (++this._redirectCount > this._options.maxRedirects) {
2614
+ throw new TooManyRedirectsError();
2615
+ }
2616
+
2617
+ // Store the request headers if applicable
2618
+ var requestHeaders;
2619
+ var beforeRedirect = this._options.beforeRedirect;
2620
+ if (beforeRedirect) {
2621
+ requestHeaders = Object.assign({
2622
+ // The Host header was set by nativeProtocol.request
2623
+ Host: response.req.getHeader("host"),
2624
+ }, this._options.headers);
2625
+ }
2626
+
2627
+ // RFC7231§6.4: Automatic redirection needs to done with
2628
+ // care for methods not known to be safe, […]
2629
+ // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
2630
+ // the request method from POST to GET for the subsequent request.
2631
+ var method = this._options.method;
2632
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
2633
+ // RFC7231§6.4.4: The 303 (See Other) status code indicates that
2634
+ // the server is redirecting the user agent to a different resource […]
2635
+ // A user agent can perform a retrieval request targeting that URI
2636
+ // (a GET or HEAD request if using HTTP) […]
2637
+ (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2638
+ this._options.method = "GET";
2639
+ // Drop a possible entity and headers related to it
2640
+ this._requestBodyBuffers = [];
2641
+ removeMatchingHeaders(/^content-/i, this._options.headers);
2642
+ }
2643
+
2644
+ // Drop the Host header, as the redirect might lead to a different host
2645
+ var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
2646
+
2647
+ // If the redirect is relative, carry over the host of the last request
2648
+ var currentUrlParts = parseUrl(this._currentUrl);
2649
+ var currentHost = currentHostHeader || currentUrlParts.host;
2650
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
2651
+ url.format(Object.assign(currentUrlParts, { host: currentHost }));
2652
+
2653
+ // Create the redirected request
2654
+ var redirectUrl = resolveUrl(location, currentUrl);
2655
+ debug("redirecting to", redirectUrl.href);
2656
+ this._isRedirect = true;
2657
+ spreadUrlObject(redirectUrl, this._options);
2658
+
2659
+ // Drop confidential headers when redirecting to a less secure protocol
2660
+ // or to a different domain that is not a superdomain
2661
+ if (redirectUrl.protocol !== currentUrlParts.protocol &&
2662
+ redirectUrl.protocol !== "https:" ||
2663
+ redirectUrl.host !== currentHost &&
2664
+ !isSubdomain(redirectUrl.host, currentHost)) {
2665
+ removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
2666
+ }
2667
+
2668
+ // Evaluate the beforeRedirect callback
2669
+ if (isFunction(beforeRedirect)) {
2670
+ var responseDetails = {
2671
+ headers: response.headers,
2672
+ statusCode: statusCode,
2673
+ };
2674
+ var requestDetails = {
2675
+ url: currentUrl,
2676
+ method: method,
2677
+ headers: requestHeaders,
2678
+ };
2679
+ beforeRedirect(this._options, responseDetails, requestDetails);
2680
+ this._sanitizeOptions(this._options);
2681
+ }
2682
+
2683
+ // Perform the redirected request
2684
+ this._performRequest();
2685
+ };
2686
+
2687
+ // Wraps the key/value object of protocols with redirect functionality
2688
+ function wrap(protocols) {
2689
+ // Default settings
2690
+ var exports$1 = {
2691
+ maxRedirects: 21,
2692
+ maxBodyLength: 10 * 1024 * 1024,
2693
+ };
2694
+
2695
+ // Wrap each protocol
2696
+ var nativeProtocols = {};
2697
+ Object.keys(protocols).forEach(function (scheme) {
2698
+ var protocol = scheme + ":";
2699
+ var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
2700
+ var wrappedProtocol = exports$1[scheme] = Object.create(nativeProtocol);
2701
+
2702
+ // Executes a request, following redirects
2703
+ function request(input, options, callback) {
2704
+ // Parse parameters, ensuring that input is an object
2705
+ if (isURL(input)) {
2706
+ input = spreadUrlObject(input);
2707
+ }
2708
+ else if (isString(input)) {
2709
+ input = spreadUrlObject(parseUrl(input));
2710
+ }
2711
+ else {
2712
+ callback = options;
2713
+ options = validateUrl(input);
2714
+ input = { protocol: protocol };
2715
+ }
2716
+ if (isFunction(options)) {
2717
+ callback = options;
2718
+ options = null;
2719
+ }
2720
+
2721
+ // Set defaults
2722
+ options = Object.assign({
2723
+ maxRedirects: exports$1.maxRedirects,
2724
+ maxBodyLength: exports$1.maxBodyLength,
2725
+ }, input, options);
2726
+ options.nativeProtocols = nativeProtocols;
2727
+ if (!isString(options.host) && !isString(options.hostname)) {
2728
+ options.hostname = "::1";
2729
+ }
2730
+
2731
+ assert.equal(options.protocol, protocol, "protocol mismatch");
2732
+ debug("options", options);
2733
+ return new RedirectableRequest(options, callback);
2734
+ }
2735
+
2736
+ // Executes a GET request, following redirects
2737
+ function get(input, options, callback) {
2738
+ var wrappedRequest = wrappedProtocol.request(input, options, callback);
2739
+ wrappedRequest.end();
2740
+ return wrappedRequest;
2741
+ }
2742
+
2743
+ // Expose the properties on the wrapped protocol
2744
+ Object.defineProperties(wrappedProtocol, {
2745
+ request: { value: request, configurable: true, enumerable: true, writable: true },
2746
+ get: { value: get, configurable: true, enumerable: true, writable: true },
2747
+ });
2748
+ });
2749
+ return exports$1;
2750
+ }
2751
+
2752
+ function noop() { /* empty */ }
2753
+
2754
+ function parseUrl(input) {
2755
+ var parsed;
2756
+ // istanbul ignore else
2757
+ if (useNativeURL) {
2758
+ parsed = new URL(input);
2759
+ }
2760
+ else {
2761
+ // Ensure the URL is valid and absolute
2762
+ parsed = validateUrl(url.parse(input));
2763
+ if (!isString(parsed.protocol)) {
2764
+ throw new InvalidUrlError({ input });
2765
+ }
2766
+ }
2767
+ return parsed;
2768
+ }
2769
+
2770
+ function resolveUrl(relative, base) {
2771
+ // istanbul ignore next
2772
+ return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
2773
+ }
2774
+
2775
+ function validateUrl(input) {
2776
+ if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
2777
+ throw new InvalidUrlError({ input: input.href || input });
2778
+ }
2779
+ if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
2780
+ throw new InvalidUrlError({ input: input.href || input });
2781
+ }
2782
+ return input;
2783
+ }
2784
+
2785
+ function spreadUrlObject(urlObject, target) {
2786
+ var spread = target || {};
2787
+ for (var key of preservedUrlFields) {
2788
+ spread[key] = urlObject[key];
2789
+ }
2790
+
2791
+ // Fix IPv6 hostname
2792
+ if (spread.hostname.startsWith("[")) {
2793
+ spread.hostname = spread.hostname.slice(1, -1);
2794
+ }
2795
+ // Ensure port is a number
2796
+ if (spread.port !== "") {
2797
+ spread.port = Number(spread.port);
2798
+ }
2799
+ // Concatenate path
2800
+ spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
2801
+
2802
+ return spread;
2803
+ }
2804
+
2805
+ function removeMatchingHeaders(regex, headers) {
2806
+ var lastValue;
2807
+ for (var header in headers) {
2808
+ if (regex.test(header)) {
2809
+ lastValue = headers[header];
2810
+ delete headers[header];
2811
+ }
2812
+ }
2813
+ return (lastValue === null || typeof lastValue === "undefined") ?
2814
+ undefined : String(lastValue).trim();
2815
+ }
2816
+
2817
+ function createErrorType(code, message, baseClass) {
2818
+ // Create constructor
2819
+ function CustomError(properties) {
2820
+ // istanbul ignore else
2821
+ if (isFunction(Error.captureStackTrace)) {
2822
+ Error.captureStackTrace(this, this.constructor);
2823
+ }
2824
+ Object.assign(this, properties || {});
2825
+ this.code = code;
2826
+ this.message = this.cause ? message + ": " + this.cause.message : message;
2827
+ }
2828
+
2829
+ // Attach constructor and set default properties
2830
+ CustomError.prototype = new (baseClass || Error)();
2831
+ Object.defineProperties(CustomError.prototype, {
2832
+ constructor: {
2833
+ value: CustomError,
2834
+ enumerable: false,
2835
+ },
2836
+ name: {
2837
+ value: "Error [" + code + "]",
2838
+ enumerable: false,
2839
+ },
2840
+ });
2841
+ return CustomError;
2842
+ }
2843
+
2844
+ function destroyRequest(request, error) {
2845
+ for (var event of events) {
2846
+ request.removeListener(event, eventHandlers[event]);
2847
+ }
2848
+ request.on("error", noop);
2849
+ request.destroy(error);
2850
+ }
2851
+
2852
+ function isSubdomain(subdomain, domain) {
2853
+ assert(isString(subdomain) && isString(domain));
2854
+ var dot = subdomain.length - domain.length - 1;
2855
+ return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
2856
+ }
2857
+
2858
+ function isString(value) {
2859
+ return typeof value === "string" || value instanceof String;
2860
+ }
2861
+
2862
+ function isFunction(value) {
2863
+ return typeof value === "function";
2864
+ }
2865
+
2866
+ function isBuffer(value) {
2867
+ return typeof value === "object" && ("length" in value);
2868
+ }
2869
+
2870
+ function isURL(value) {
2871
+ return URL && value instanceof URL;
2872
+ }
2849
2873
 
2850
- // Exports
2851
- followRedirects.exports = wrap({ http: http$1, https: https });
2852
- followRedirects.exports.wrap = wrap;
2874
+ // Exports
2875
+ followRedirects.exports = wrap({ http: http, https: https });
2876
+ followRedirects.exports.wrap = wrap;
2877
+ return followRedirects.exports;
2878
+ }
2853
2879
 
2854
- var followRedirectsExports = followRedirects.exports;
2880
+ var followRedirectsExports = requireFollowRedirects();
2855
2881
 
2856
2882
  var mimeTypes$1 = {};
2857
2883
 
@@ -14861,537 +14887,545 @@ var bodyParser = {exports: {}};
14861
14887
  * MIT Licensed
14862
14888
  */
14863
14889
 
14864
- /**
14865
- * Module dependencies.
14866
- */
14890
+ var depd_1;
14891
+ var hasRequiredDepd;
14867
14892
 
14868
- var relative = path.relative;
14893
+ function requireDepd () {
14894
+ if (hasRequiredDepd) return depd_1;
14895
+ hasRequiredDepd = 1;
14896
+ /**
14897
+ * Module dependencies.
14898
+ */
14869
14899
 
14870
- /**
14871
- * Module exports.
14872
- */
14900
+ var relative = path.relative;
14873
14901
 
14874
- var depd_1 = depd;
14902
+ /**
14903
+ * Module exports.
14904
+ */
14875
14905
 
14876
- /**
14877
- * Get the path to base files on.
14878
- */
14906
+ depd_1 = depd;
14879
14907
 
14880
- var basePath = process.cwd();
14908
+ /**
14909
+ * Get the path to base files on.
14910
+ */
14881
14911
 
14882
- /**
14883
- * Determine if namespace is contained in the string.
14884
- */
14912
+ var basePath = process.cwd();
14885
14913
 
14886
- function containsNamespace (str, namespace) {
14887
- var vals = str.split(/[ ,]+/);
14888
- var ns = String(namespace).toLowerCase();
14914
+ /**
14915
+ * Determine if namespace is contained in the string.
14916
+ */
14889
14917
 
14890
- for (var i = 0; i < vals.length; i++) {
14891
- var val = vals[i];
14918
+ function containsNamespace (str, namespace) {
14919
+ var vals = str.split(/[ ,]+/);
14920
+ var ns = String(namespace).toLowerCase();
14892
14921
 
14893
- // namespace contained
14894
- if (val && (val === '*' || val.toLowerCase() === ns)) {
14895
- return true
14896
- }
14897
- }
14922
+ for (var i = 0; i < vals.length; i++) {
14923
+ var val = vals[i];
14898
14924
 
14899
- return false
14900
- }
14925
+ // namespace contained
14926
+ if (val && (val === '*' || val.toLowerCase() === ns)) {
14927
+ return true
14928
+ }
14929
+ }
14901
14930
 
14902
- /**
14903
- * Convert a data descriptor to accessor descriptor.
14904
- */
14931
+ return false
14932
+ }
14905
14933
 
14906
- function convertDataDescriptorToAccessor (obj, prop, message) {
14907
- var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
14908
- var value = descriptor.value;
14934
+ /**
14935
+ * Convert a data descriptor to accessor descriptor.
14936
+ */
14909
14937
 
14910
- descriptor.get = function getter () { return value };
14938
+ function convertDataDescriptorToAccessor (obj, prop, message) {
14939
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
14940
+ var value = descriptor.value;
14911
14941
 
14912
- if (descriptor.writable) {
14913
- descriptor.set = function setter (val) { return (value = val) };
14914
- }
14942
+ descriptor.get = function getter () { return value };
14915
14943
 
14916
- delete descriptor.value;
14917
- delete descriptor.writable;
14944
+ if (descriptor.writable) {
14945
+ descriptor.set = function setter (val) { return (value = val) };
14946
+ }
14918
14947
 
14919
- Object.defineProperty(obj, prop, descriptor);
14948
+ delete descriptor.value;
14949
+ delete descriptor.writable;
14920
14950
 
14921
- return descriptor
14922
- }
14951
+ Object.defineProperty(obj, prop, descriptor);
14923
14952
 
14924
- /**
14925
- * Create arguments string to keep arity.
14926
- */
14953
+ return descriptor
14954
+ }
14927
14955
 
14928
- function createArgumentsString (arity) {
14929
- var str = '';
14956
+ /**
14957
+ * Create arguments string to keep arity.
14958
+ */
14930
14959
 
14931
- for (var i = 0; i < arity; i++) {
14932
- str += ', arg' + i;
14933
- }
14960
+ function createArgumentsString (arity) {
14961
+ var str = '';
14934
14962
 
14935
- return str.substr(2)
14936
- }
14963
+ for (var i = 0; i < arity; i++) {
14964
+ str += ', arg' + i;
14965
+ }
14937
14966
 
14938
- /**
14939
- * Create stack string from stack.
14940
- */
14967
+ return str.substr(2)
14968
+ }
14941
14969
 
14942
- function createStackString (stack) {
14943
- var str = this.name + ': ' + this.namespace;
14970
+ /**
14971
+ * Create stack string from stack.
14972
+ */
14944
14973
 
14945
- if (this.message) {
14946
- str += ' deprecated ' + this.message;
14947
- }
14974
+ function createStackString (stack) {
14975
+ var str = this.name + ': ' + this.namespace;
14948
14976
 
14949
- for (var i = 0; i < stack.length; i++) {
14950
- str += '\n at ' + stack[i].toString();
14951
- }
14977
+ if (this.message) {
14978
+ str += ' deprecated ' + this.message;
14979
+ }
14952
14980
 
14953
- return str
14954
- }
14981
+ for (var i = 0; i < stack.length; i++) {
14982
+ str += '\n at ' + stack[i].toString();
14983
+ }
14955
14984
 
14956
- /**
14957
- * Create deprecate for namespace in caller.
14958
- */
14985
+ return str
14986
+ }
14959
14987
 
14960
- function depd (namespace) {
14961
- if (!namespace) {
14962
- throw new TypeError('argument namespace is required')
14963
- }
14988
+ /**
14989
+ * Create deprecate for namespace in caller.
14990
+ */
14964
14991
 
14965
- var stack = getStack();
14966
- var site = callSiteLocation(stack[1]);
14967
- var file = site[0];
14992
+ function depd (namespace) {
14993
+ if (!namespace) {
14994
+ throw new TypeError('argument namespace is required')
14995
+ }
14968
14996
 
14969
- function deprecate (message) {
14970
- // call to self as log
14971
- log.call(deprecate, message);
14972
- }
14997
+ var stack = getStack();
14998
+ var site = callSiteLocation(stack[1]);
14999
+ var file = site[0];
14973
15000
 
14974
- deprecate._file = file;
14975
- deprecate._ignored = isignored(namespace);
14976
- deprecate._namespace = namespace;
14977
- deprecate._traced = istraced(namespace);
14978
- deprecate._warned = Object.create(null);
15001
+ function deprecate (message) {
15002
+ // call to self as log
15003
+ log.call(deprecate, message);
15004
+ }
14979
15005
 
14980
- deprecate.function = wrapfunction;
14981
- deprecate.property = wrapproperty;
15006
+ deprecate._file = file;
15007
+ deprecate._ignored = isignored(namespace);
15008
+ deprecate._namespace = namespace;
15009
+ deprecate._traced = istraced(namespace);
15010
+ deprecate._warned = Object.create(null);
14982
15011
 
14983
- return deprecate
14984
- }
15012
+ deprecate.function = wrapfunction;
15013
+ deprecate.property = wrapproperty;
14985
15014
 
14986
- /**
14987
- * Determine if event emitter has listeners of a given type.
14988
- *
14989
- * The way to do this check is done three different ways in Node.js >= 0.8
14990
- * so this consolidates them into a minimal set using instance methods.
14991
- *
14992
- * @param {EventEmitter} emitter
14993
- * @param {string} type
14994
- * @returns {boolean}
14995
- * @private
14996
- */
15015
+ return deprecate
15016
+ }
15017
+
15018
+ /**
15019
+ * Determine if event emitter has listeners of a given type.
15020
+ *
15021
+ * The way to do this check is done three different ways in Node.js >= 0.8
15022
+ * so this consolidates them into a minimal set using instance methods.
15023
+ *
15024
+ * @param {EventEmitter} emitter
15025
+ * @param {string} type
15026
+ * @returns {boolean}
15027
+ * @private
15028
+ */
14997
15029
 
14998
- function eehaslisteners (emitter, type) {
14999
- var count = typeof emitter.listenerCount !== 'function'
15000
- ? emitter.listeners(type).length
15001
- : emitter.listenerCount(type);
15030
+ function eehaslisteners (emitter, type) {
15031
+ var count = typeof emitter.listenerCount !== 'function'
15032
+ ? emitter.listeners(type).length
15033
+ : emitter.listenerCount(type);
15002
15034
 
15003
- return count > 0
15004
- }
15035
+ return count > 0
15036
+ }
15005
15037
 
15006
- /**
15007
- * Determine if namespace is ignored.
15008
- */
15038
+ /**
15039
+ * Determine if namespace is ignored.
15040
+ */
15009
15041
 
15010
- function isignored (namespace) {
15011
- if (process.noDeprecation) {
15012
- // --no-deprecation support
15013
- return true
15014
- }
15042
+ function isignored (namespace) {
15043
+ if (process.noDeprecation) {
15044
+ // --no-deprecation support
15045
+ return true
15046
+ }
15015
15047
 
15016
- var str = process.env.NO_DEPRECATION || '';
15048
+ var str = process.env.NO_DEPRECATION || '';
15017
15049
 
15018
- // namespace ignored
15019
- return containsNamespace(str, namespace)
15020
- }
15050
+ // namespace ignored
15051
+ return containsNamespace(str, namespace)
15052
+ }
15021
15053
 
15022
- /**
15023
- * Determine if namespace is traced.
15024
- */
15054
+ /**
15055
+ * Determine if namespace is traced.
15056
+ */
15025
15057
 
15026
- function istraced (namespace) {
15027
- if (process.traceDeprecation) {
15028
- // --trace-deprecation support
15029
- return true
15030
- }
15058
+ function istraced (namespace) {
15059
+ if (process.traceDeprecation) {
15060
+ // --trace-deprecation support
15061
+ return true
15062
+ }
15031
15063
 
15032
- var str = process.env.TRACE_DEPRECATION || '';
15064
+ var str = process.env.TRACE_DEPRECATION || '';
15033
15065
 
15034
- // namespace traced
15035
- return containsNamespace(str, namespace)
15036
- }
15066
+ // namespace traced
15067
+ return containsNamespace(str, namespace)
15068
+ }
15037
15069
 
15038
- /**
15039
- * Display deprecation message.
15040
- */
15070
+ /**
15071
+ * Display deprecation message.
15072
+ */
15041
15073
 
15042
- function log (message, site) {
15043
- var haslisteners = eehaslisteners(process, 'deprecation');
15044
-
15045
- // abort early if no destination
15046
- if (!haslisteners && this._ignored) {
15047
- return
15048
- }
15049
-
15050
- var caller;
15051
- var callFile;
15052
- var callSite;
15053
- var depSite;
15054
- var i = 0;
15055
- var seen = false;
15056
- var stack = getStack();
15057
- var file = this._file;
15058
-
15059
- if (site) {
15060
- // provided site
15061
- depSite = site;
15062
- callSite = callSiteLocation(stack[1]);
15063
- callSite.name = depSite.name;
15064
- file = callSite[0];
15065
- } else {
15066
- // get call site
15067
- i = 2;
15068
- depSite = callSiteLocation(stack[i]);
15069
- callSite = depSite;
15070
- }
15071
-
15072
- // get caller of deprecated thing in relation to file
15073
- for (; i < stack.length; i++) {
15074
- caller = callSiteLocation(stack[i]);
15075
- callFile = caller[0];
15076
-
15077
- if (callFile === file) {
15078
- seen = true;
15079
- } else if (callFile === this._file) {
15080
- file = this._file;
15081
- } else if (seen) {
15082
- break
15083
- }
15084
- }
15085
-
15086
- var key = caller
15087
- ? depSite.join(':') + '__' + caller.join(':')
15088
- : undefined;
15089
-
15090
- if (key !== undefined && key in this._warned) {
15091
- // already warned
15092
- return
15093
- }
15094
-
15095
- this._warned[key] = true;
15096
-
15097
- // generate automatic message from call site
15098
- var msg = message;
15099
- if (!msg) {
15100
- msg = callSite === depSite || !callSite.name
15101
- ? defaultMessage(depSite)
15102
- : defaultMessage(callSite);
15103
- }
15104
-
15105
- // emit deprecation if listeners exist
15106
- if (haslisteners) {
15107
- var err = DeprecationError(this._namespace, msg, stack.slice(i));
15108
- process.emit('deprecation', err);
15109
- return
15110
- }
15111
-
15112
- // format and write message
15113
- var format = process.stderr.isTTY
15114
- ? formatColor
15115
- : formatPlain;
15116
- var output = format.call(this, msg, caller, stack.slice(i));
15117
- process.stderr.write(output + '\n', 'utf8');
15118
- }
15074
+ function log (message, site) {
15075
+ var haslisteners = eehaslisteners(process, 'deprecation');
15119
15076
 
15120
- /**
15121
- * Get call site location as array.
15122
- */
15077
+ // abort early if no destination
15078
+ if (!haslisteners && this._ignored) {
15079
+ return
15080
+ }
15123
15081
 
15124
- function callSiteLocation (callSite) {
15125
- var file = callSite.getFileName() || '<anonymous>';
15126
- var line = callSite.getLineNumber();
15127
- var colm = callSite.getColumnNumber();
15082
+ var caller;
15083
+ var callFile;
15084
+ var callSite;
15085
+ var depSite;
15086
+ var i = 0;
15087
+ var seen = false;
15088
+ var stack = getStack();
15089
+ var file = this._file;
15090
+
15091
+ if (site) {
15092
+ // provided site
15093
+ depSite = site;
15094
+ callSite = callSiteLocation(stack[1]);
15095
+ callSite.name = depSite.name;
15096
+ file = callSite[0];
15097
+ } else {
15098
+ // get call site
15099
+ i = 2;
15100
+ depSite = callSiteLocation(stack[i]);
15101
+ callSite = depSite;
15102
+ }
15128
15103
 
15129
- if (callSite.isEval()) {
15130
- file = callSite.getEvalOrigin() + ', ' + file;
15131
- }
15104
+ // get caller of deprecated thing in relation to file
15105
+ for (; i < stack.length; i++) {
15106
+ caller = callSiteLocation(stack[i]);
15107
+ callFile = caller[0];
15132
15108
 
15133
- var site = [file, line, colm];
15109
+ if (callFile === file) {
15110
+ seen = true;
15111
+ } else if (callFile === this._file) {
15112
+ file = this._file;
15113
+ } else if (seen) {
15114
+ break
15115
+ }
15116
+ }
15134
15117
 
15135
- site.callSite = callSite;
15136
- site.name = callSite.getFunctionName();
15118
+ var key = caller
15119
+ ? depSite.join(':') + '__' + caller.join(':')
15120
+ : undefined;
15137
15121
 
15138
- return site
15139
- }
15122
+ if (key !== undefined && key in this._warned) {
15123
+ // already warned
15124
+ return
15125
+ }
15140
15126
 
15141
- /**
15142
- * Generate a default message from the site.
15143
- */
15127
+ this._warned[key] = true;
15128
+
15129
+ // generate automatic message from call site
15130
+ var msg = message;
15131
+ if (!msg) {
15132
+ msg = callSite === depSite || !callSite.name
15133
+ ? defaultMessage(depSite)
15134
+ : defaultMessage(callSite);
15135
+ }
15136
+
15137
+ // emit deprecation if listeners exist
15138
+ if (haslisteners) {
15139
+ var err = DeprecationError(this._namespace, msg, stack.slice(i));
15140
+ process.emit('deprecation', err);
15141
+ return
15142
+ }
15144
15143
 
15145
- function defaultMessage (site) {
15146
- var callSite = site.callSite;
15147
- var funcName = site.name;
15144
+ // format and write message
15145
+ var format = process.stderr.isTTY
15146
+ ? formatColor
15147
+ : formatPlain;
15148
+ var output = format.call(this, msg, caller, stack.slice(i));
15149
+ process.stderr.write(output + '\n', 'utf8');
15150
+ }
15148
15151
 
15149
- // make useful anonymous name
15150
- if (!funcName) {
15151
- funcName = '<anonymous@' + formatLocation(site) + '>';
15152
- }
15152
+ /**
15153
+ * Get call site location as array.
15154
+ */
15153
15155
 
15154
- var context = callSite.getThis();
15155
- var typeName = context && callSite.getTypeName();
15156
+ function callSiteLocation (callSite) {
15157
+ var file = callSite.getFileName() || '<anonymous>';
15158
+ var line = callSite.getLineNumber();
15159
+ var colm = callSite.getColumnNumber();
15156
15160
 
15157
- // ignore useless type name
15158
- if (typeName === 'Object') {
15159
- typeName = undefined;
15160
- }
15161
+ if (callSite.isEval()) {
15162
+ file = callSite.getEvalOrigin() + ', ' + file;
15163
+ }
15161
15164
 
15162
- // make useful type name
15163
- if (typeName === 'Function') {
15164
- typeName = context.name || typeName;
15165
- }
15165
+ var site = [file, line, colm];
15166
15166
 
15167
- return typeName && callSite.getMethodName()
15168
- ? typeName + '.' + funcName
15169
- : funcName
15170
- }
15167
+ site.callSite = callSite;
15168
+ site.name = callSite.getFunctionName();
15171
15169
 
15172
- /**
15173
- * Format deprecation message without color.
15174
- */
15170
+ return site
15171
+ }
15175
15172
 
15176
- function formatPlain (msg, caller, stack) {
15177
- var timestamp = new Date().toUTCString();
15173
+ /**
15174
+ * Generate a default message from the site.
15175
+ */
15178
15176
 
15179
- var formatted = timestamp +
15180
- ' ' + this._namespace +
15181
- ' deprecated ' + msg;
15177
+ function defaultMessage (site) {
15178
+ var callSite = site.callSite;
15179
+ var funcName = site.name;
15182
15180
 
15183
- // add stack trace
15184
- if (this._traced) {
15185
- for (var i = 0; i < stack.length; i++) {
15186
- formatted += '\n at ' + stack[i].toString();
15187
- }
15181
+ // make useful anonymous name
15182
+ if (!funcName) {
15183
+ funcName = '<anonymous@' + formatLocation(site) + '>';
15184
+ }
15188
15185
 
15189
- return formatted
15190
- }
15186
+ var context = callSite.getThis();
15187
+ var typeName = context && callSite.getTypeName();
15191
15188
 
15192
- if (caller) {
15193
- formatted += ' at ' + formatLocation(caller);
15194
- }
15189
+ // ignore useless type name
15190
+ if (typeName === 'Object') {
15191
+ typeName = undefined;
15192
+ }
15195
15193
 
15196
- return formatted
15197
- }
15194
+ // make useful type name
15195
+ if (typeName === 'Function') {
15196
+ typeName = context.name || typeName;
15197
+ }
15198
15198
 
15199
- /**
15200
- * Format deprecation message with color.
15201
- */
15199
+ return typeName && callSite.getMethodName()
15200
+ ? typeName + '.' + funcName
15201
+ : funcName
15202
+ }
15202
15203
 
15203
- function formatColor (msg, caller, stack) {
15204
- var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' + // bold cyan
15205
- ' \x1b[33;1mdeprecated\x1b[22;39m' + // bold yellow
15206
- ' \x1b[0m' + msg + '\x1b[39m'; // reset
15204
+ /**
15205
+ * Format deprecation message without color.
15206
+ */
15207
15207
 
15208
- // add stack trace
15209
- if (this._traced) {
15210
- for (var i = 0; i < stack.length; i++) {
15211
- formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m'; // cyan
15212
- }
15208
+ function formatPlain (msg, caller, stack) {
15209
+ var timestamp = new Date().toUTCString();
15213
15210
 
15214
- return formatted
15215
- }
15211
+ var formatted = timestamp +
15212
+ ' ' + this._namespace +
15213
+ ' deprecated ' + msg;
15216
15214
 
15217
- if (caller) {
15218
- formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m'; // cyan
15219
- }
15215
+ // add stack trace
15216
+ if (this._traced) {
15217
+ for (var i = 0; i < stack.length; i++) {
15218
+ formatted += '\n at ' + stack[i].toString();
15219
+ }
15220
15220
 
15221
- return formatted
15222
- }
15221
+ return formatted
15222
+ }
15223
15223
 
15224
- /**
15225
- * Format call site location.
15226
- */
15224
+ if (caller) {
15225
+ formatted += ' at ' + formatLocation(caller);
15226
+ }
15227
15227
 
15228
- function formatLocation (callSite) {
15229
- return relative(basePath, callSite[0]) +
15230
- ':' + callSite[1] +
15231
- ':' + callSite[2]
15232
- }
15228
+ return formatted
15229
+ }
15233
15230
 
15234
- /**
15235
- * Get the stack as array of call sites.
15236
- */
15231
+ /**
15232
+ * Format deprecation message with color.
15233
+ */
15237
15234
 
15238
- function getStack () {
15239
- var limit = Error.stackTraceLimit;
15240
- var obj = {};
15241
- var prep = Error.prepareStackTrace;
15235
+ function formatColor (msg, caller, stack) {
15236
+ var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' + // bold cyan
15237
+ ' \x1b[33;1mdeprecated\x1b[22;39m' + // bold yellow
15238
+ ' \x1b[0m' + msg + '\x1b[39m'; // reset
15242
15239
 
15243
- Error.prepareStackTrace = prepareObjectStackTrace;
15244
- Error.stackTraceLimit = Math.max(10, limit);
15240
+ // add stack trace
15241
+ if (this._traced) {
15242
+ for (var i = 0; i < stack.length; i++) {
15243
+ formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m'; // cyan
15244
+ }
15245
15245
 
15246
- // capture the stack
15247
- Error.captureStackTrace(obj);
15246
+ return formatted
15247
+ }
15248
15248
 
15249
- // slice this function off the top
15250
- var stack = obj.stack.slice(1);
15249
+ if (caller) {
15250
+ formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m'; // cyan
15251
+ }
15251
15252
 
15252
- Error.prepareStackTrace = prep;
15253
- Error.stackTraceLimit = limit;
15253
+ return formatted
15254
+ }
15254
15255
 
15255
- return stack
15256
- }
15256
+ /**
15257
+ * Format call site location.
15258
+ */
15257
15259
 
15258
- /**
15259
- * Capture call site stack from v8.
15260
- */
15260
+ function formatLocation (callSite) {
15261
+ return relative(basePath, callSite[0]) +
15262
+ ':' + callSite[1] +
15263
+ ':' + callSite[2]
15264
+ }
15261
15265
 
15262
- function prepareObjectStackTrace (obj, stack) {
15263
- return stack
15264
- }
15266
+ /**
15267
+ * Get the stack as array of call sites.
15268
+ */
15265
15269
 
15266
- /**
15267
- * Return a wrapped function in a deprecation message.
15268
- */
15270
+ function getStack () {
15271
+ var limit = Error.stackTraceLimit;
15272
+ var obj = {};
15273
+ var prep = Error.prepareStackTrace;
15269
15274
 
15270
- function wrapfunction (fn, message) {
15271
- if (typeof fn !== 'function') {
15272
- throw new TypeError('argument fn must be a function')
15273
- }
15275
+ Error.prepareStackTrace = prepareObjectStackTrace;
15276
+ Error.stackTraceLimit = Math.max(10, limit);
15274
15277
 
15275
- var args = createArgumentsString(fn.length);
15276
- var stack = getStack();
15277
- var site = callSiteLocation(stack[1]);
15278
+ // capture the stack
15279
+ Error.captureStackTrace(obj);
15278
15280
 
15279
- site.name = fn.name;
15281
+ // slice this function off the top
15282
+ var stack = obj.stack.slice(1);
15280
15283
 
15281
- // eslint-disable-next-line no-new-func
15282
- var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
15283
- '"use strict"\n' +
15284
- 'return function (' + args + ') {' +
15285
- 'log.call(deprecate, message, site)\n' +
15286
- 'return fn.apply(this, arguments)\n' +
15287
- '}')(fn, log, this, message, site);
15284
+ Error.prepareStackTrace = prep;
15285
+ Error.stackTraceLimit = limit;
15288
15286
 
15289
- return deprecatedfn
15290
- }
15287
+ return stack
15288
+ }
15291
15289
 
15292
- /**
15293
- * Wrap property in a deprecation message.
15294
- */
15290
+ /**
15291
+ * Capture call site stack from v8.
15292
+ */
15295
15293
 
15296
- function wrapproperty (obj, prop, message) {
15297
- if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
15298
- throw new TypeError('argument obj must be object')
15299
- }
15294
+ function prepareObjectStackTrace (obj, stack) {
15295
+ return stack
15296
+ }
15300
15297
 
15301
- var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
15298
+ /**
15299
+ * Return a wrapped function in a deprecation message.
15300
+ */
15302
15301
 
15303
- if (!descriptor) {
15304
- throw new TypeError('must call property on owner object')
15305
- }
15302
+ function wrapfunction (fn, message) {
15303
+ if (typeof fn !== 'function') {
15304
+ throw new TypeError('argument fn must be a function')
15305
+ }
15306
15306
 
15307
- if (!descriptor.configurable) {
15308
- throw new TypeError('property must be configurable')
15309
- }
15307
+ var args = createArgumentsString(fn.length);
15308
+ var stack = getStack();
15309
+ var site = callSiteLocation(stack[1]);
15310
15310
 
15311
- var deprecate = this;
15312
- var stack = getStack();
15313
- var site = callSiteLocation(stack[1]);
15311
+ site.name = fn.name;
15314
15312
 
15315
- // set site name
15316
- site.name = prop;
15313
+ // eslint-disable-next-line no-new-func
15314
+ var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
15315
+ '"use strict"\n' +
15316
+ 'return function (' + args + ') {' +
15317
+ 'log.call(deprecate, message, site)\n' +
15318
+ 'return fn.apply(this, arguments)\n' +
15319
+ '}')(fn, log, this, message, site);
15317
15320
 
15318
- // convert data descriptor
15319
- if ('value' in descriptor) {
15320
- descriptor = convertDataDescriptorToAccessor(obj, prop);
15321
- }
15321
+ return deprecatedfn
15322
+ }
15322
15323
 
15323
- var get = descriptor.get;
15324
- var set = descriptor.set;
15324
+ /**
15325
+ * Wrap property in a deprecation message.
15326
+ */
15325
15327
 
15326
- // wrap getter
15327
- if (typeof get === 'function') {
15328
- descriptor.get = function getter () {
15329
- log.call(deprecate, message, site);
15330
- return get.apply(this, arguments)
15331
- };
15332
- }
15328
+ function wrapproperty (obj, prop, message) {
15329
+ if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
15330
+ throw new TypeError('argument obj must be object')
15331
+ }
15333
15332
 
15334
- // wrap setter
15335
- if (typeof set === 'function') {
15336
- descriptor.set = function setter () {
15337
- log.call(deprecate, message, site);
15338
- return set.apply(this, arguments)
15339
- };
15340
- }
15333
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
15341
15334
 
15342
- Object.defineProperty(obj, prop, descriptor);
15343
- }
15335
+ if (!descriptor) {
15336
+ throw new TypeError('must call property on owner object')
15337
+ }
15344
15338
 
15345
- /**
15346
- * Create DeprecationError for deprecation
15347
- */
15339
+ if (!descriptor.configurable) {
15340
+ throw new TypeError('property must be configurable')
15341
+ }
15348
15342
 
15349
- function DeprecationError (namespace, message, stack) {
15350
- var error = new Error();
15351
- var stackString;
15352
-
15353
- Object.defineProperty(error, 'constructor', {
15354
- value: DeprecationError
15355
- });
15356
-
15357
- Object.defineProperty(error, 'message', {
15358
- configurable: true,
15359
- enumerable: false,
15360
- value: message,
15361
- writable: true
15362
- });
15363
-
15364
- Object.defineProperty(error, 'name', {
15365
- enumerable: false,
15366
- configurable: true,
15367
- value: 'DeprecationError',
15368
- writable: true
15369
- });
15370
-
15371
- Object.defineProperty(error, 'namespace', {
15372
- configurable: true,
15373
- enumerable: false,
15374
- value: namespace,
15375
- writable: true
15376
- });
15377
-
15378
- Object.defineProperty(error, 'stack', {
15379
- configurable: true,
15380
- enumerable: false,
15381
- get: function () {
15382
- if (stackString !== undefined) {
15383
- return stackString
15384
- }
15385
-
15386
- // prepare stack trace
15387
- return (stackString = createStackString.call(this, stack))
15388
- },
15389
- set: function setter (val) {
15390
- stackString = val;
15391
- }
15392
- });
15343
+ var deprecate = this;
15344
+ var stack = getStack();
15345
+ var site = callSiteLocation(stack[1]);
15346
+
15347
+ // set site name
15348
+ site.name = prop;
15349
+
15350
+ // convert data descriptor
15351
+ if ('value' in descriptor) {
15352
+ descriptor = convertDataDescriptorToAccessor(obj, prop);
15353
+ }
15354
+
15355
+ var get = descriptor.get;
15356
+ var set = descriptor.set;
15357
+
15358
+ // wrap getter
15359
+ if (typeof get === 'function') {
15360
+ descriptor.get = function getter () {
15361
+ log.call(deprecate, message, site);
15362
+ return get.apply(this, arguments)
15363
+ };
15364
+ }
15365
+
15366
+ // wrap setter
15367
+ if (typeof set === 'function') {
15368
+ descriptor.set = function setter () {
15369
+ log.call(deprecate, message, site);
15370
+ return set.apply(this, arguments)
15371
+ };
15372
+ }
15373
+
15374
+ Object.defineProperty(obj, prop, descriptor);
15375
+ }
15376
+
15377
+ /**
15378
+ * Create DeprecationError for deprecation
15379
+ */
15380
+
15381
+ function DeprecationError (namespace, message, stack) {
15382
+ var error = new Error();
15383
+ var stackString;
15384
+
15385
+ Object.defineProperty(error, 'constructor', {
15386
+ value: DeprecationError
15387
+ });
15388
+
15389
+ Object.defineProperty(error, 'message', {
15390
+ configurable: true,
15391
+ enumerable: false,
15392
+ value: message,
15393
+ writable: true
15394
+ });
15395
+
15396
+ Object.defineProperty(error, 'name', {
15397
+ enumerable: false,
15398
+ configurable: true,
15399
+ value: 'DeprecationError',
15400
+ writable: true
15401
+ });
15402
+
15403
+ Object.defineProperty(error, 'namespace', {
15404
+ configurable: true,
15405
+ enumerable: false,
15406
+ value: namespace,
15407
+ writable: true
15408
+ });
15409
+
15410
+ Object.defineProperty(error, 'stack', {
15411
+ configurable: true,
15412
+ enumerable: false,
15413
+ get: function () {
15414
+ if (stackString !== undefined) {
15415
+ return stackString
15416
+ }
15417
+
15418
+ // prepare stack trace
15419
+ return (stackString = createStackString.call(this, stack))
15420
+ },
15421
+ set: function setter (val) {
15422
+ stackString = val;
15423
+ }
15424
+ });
15393
15425
 
15394
- return error
15426
+ return error
15427
+ }
15428
+ return depd_1;
15395
15429
  }
15396
15430
 
15397
15431
  var bytes = {exports: {}};
@@ -16169,7 +16203,7 @@ function requireHttpErrors () {
16169
16203
  * @private
16170
16204
  */
16171
16205
 
16172
- var deprecate = depd_1('http-errors');
16206
+ var deprecate = requireDepd()('http-errors');
16173
16207
  var setPrototypeOf = requireSetprototypeof();
16174
16208
  var statuses = requireStatuses();
16175
16209
  var inherits = requireInherits();
@@ -28466,11 +28500,11 @@ function requireExtendNode () {
28466
28500
  return extendNode;
28467
28501
  }
28468
28502
 
28469
- var hasRequiredLib$1;
28503
+ var hasRequiredLib$2;
28470
28504
 
28471
- function requireLib$1 () {
28472
- if (hasRequiredLib$1) return lib$2.exports;
28473
- hasRequiredLib$1 = 1;
28505
+ function requireLib$2 () {
28506
+ if (hasRequiredLib$2) return lib$2.exports;
28507
+ hasRequiredLib$2 = 1;
28474
28508
  (function (module) {
28475
28509
 
28476
28510
  // Some environments don't have global Buffer (e.g. React Native).
@@ -28723,7 +28757,7 @@ function requireRawBody () {
28723
28757
  var asyncHooks = tryRequireAsyncHooks();
28724
28758
  var bytes = requireBytes();
28725
28759
  var createError = requireHttpErrors();
28726
- var iconv = requireLib$1();
28760
+ var iconv = requireLib$2();
28727
28761
  var unpipe = requireUnpipe();
28728
28762
 
28729
28763
  /**
@@ -29412,7 +29446,7 @@ function requireRead () {
29412
29446
  var createError = requireHttpErrors();
29413
29447
  var destroy = requireDestroy();
29414
29448
  var getBody = requireRawBody();
29415
- var iconv = requireLib$1();
29449
+ var iconv = requireLib$2();
29416
29450
  var onFinished = requireOnFinished();
29417
29451
  var unpipe = requireUnpipe();
29418
29452
  var zlib = require$$3$2;
@@ -30747,7 +30781,7 @@ function requireObjectInspect () {
30747
30781
  return $replace.call(str, sepRegex, '$&_');
30748
30782
  }
30749
30783
 
30750
- var utilInspect = requireUtil_inspect();
30784
+ var utilInspect = /*@__PURE__*/ requireUtil_inspect();
30751
30785
  var inspectCustom = utilInspect.custom;
30752
30786
  var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
30753
30787
 
@@ -31234,9 +31268,9 @@ function requireSideChannelList () {
31234
31268
  if (hasRequiredSideChannelList) return sideChannelList;
31235
31269
  hasRequiredSideChannelList = 1;
31236
31270
 
31237
- var inspect = requireObjectInspect();
31271
+ var inspect = /*@__PURE__*/ requireObjectInspect();
31238
31272
 
31239
- var $TypeError = requireType();
31273
+ var $TypeError = /*@__PURE__*/ requireType();
31240
31274
 
31241
31275
  /*
31242
31276
  * This function traverses the list returning the node corresponding to the given key.
@@ -31525,7 +31559,7 @@ function requireSign () {
31525
31559
  if (hasRequiredSign) return sign;
31526
31560
  hasRequiredSign = 1;
31527
31561
 
31528
- var $isNaN = require_isNaN();
31562
+ var $isNaN = /*@__PURE__*/ require_isNaN();
31529
31563
 
31530
31564
  /** @type {import('./sign')} */
31531
31565
  sign = function sign(number) {
@@ -31557,7 +31591,7 @@ function requireGopd () {
31557
31591
  hasRequiredGopd = 1;
31558
31592
 
31559
31593
  /** @type {import('.')} */
31560
- var $gOPD = requireGOPD();
31594
+ var $gOPD = /*@__PURE__*/ requireGOPD();
31561
31595
 
31562
31596
  if ($gOPD) {
31563
31597
  try {
@@ -31688,7 +31722,7 @@ function requireObject_getPrototypeOf () {
31688
31722
  if (hasRequiredObject_getPrototypeOf) return Object_getPrototypeOf;
31689
31723
  hasRequiredObject_getPrototypeOf = 1;
31690
31724
 
31691
- var $Object = requireEsObjectAtoms();
31725
+ var $Object = /*@__PURE__*/ requireEsObjectAtoms();
31692
31726
 
31693
31727
  /** @type {import('./Object.getPrototypeOf')} */
31694
31728
  Object_getPrototypeOf = $Object.getPrototypeOf || null;
@@ -31862,7 +31896,7 @@ function requireCallBindApplyHelpers () {
31862
31896
  hasRequiredCallBindApplyHelpers = 1;
31863
31897
 
31864
31898
  var bind = requireFunctionBind();
31865
- var $TypeError = requireType();
31899
+ var $TypeError = /*@__PURE__*/ requireType();
31866
31900
 
31867
31901
  var $call = requireFunctionCall();
31868
31902
  var $actualApply = requireActualApply();
@@ -31885,7 +31919,7 @@ function requireGet () {
31885
31919
  hasRequiredGet = 1;
31886
31920
 
31887
31921
  var callBind = requireCallBindApplyHelpers();
31888
- var gOPD = requireGopd();
31922
+ var gOPD = /*@__PURE__*/ requireGopd();
31889
31923
 
31890
31924
  var hasProtoAccessor;
31891
31925
  try {
@@ -31925,7 +31959,7 @@ function requireGetProto () {
31925
31959
  var reflectGetProto = requireReflect_getPrototypeOf();
31926
31960
  var originalGetProto = requireObject_getPrototypeOf();
31927
31961
 
31928
- var getDunderProto = requireGet();
31962
+ var getDunderProto = /*@__PURE__*/ requireGet();
31929
31963
 
31930
31964
  /** @type {import('.')} */
31931
31965
  getProto = reflectGetProto
@@ -31975,23 +32009,23 @@ function requireGetIntrinsic () {
31975
32009
 
31976
32010
  var undefined$1;
31977
32011
 
31978
- var $Object = requireEsObjectAtoms();
32012
+ var $Object = /*@__PURE__*/ requireEsObjectAtoms();
31979
32013
 
31980
- var $Error = requireEsErrors();
31981
- var $EvalError = require_eval();
31982
- var $RangeError = requireRange();
31983
- var $ReferenceError = requireRef();
31984
- var $SyntaxError = requireSyntax();
31985
- var $TypeError = requireType();
31986
- var $URIError = requireUri();
32014
+ var $Error = /*@__PURE__*/ requireEsErrors();
32015
+ var $EvalError = /*@__PURE__*/ require_eval();
32016
+ var $RangeError = /*@__PURE__*/ requireRange();
32017
+ var $ReferenceError = /*@__PURE__*/ requireRef();
32018
+ var $SyntaxError = /*@__PURE__*/ requireSyntax();
32019
+ var $TypeError = /*@__PURE__*/ requireType();
32020
+ var $URIError = /*@__PURE__*/ requireUri();
31987
32021
 
31988
- var abs = requireAbs();
31989
- var floor = requireFloor();
31990
- var max = requireMax();
31991
- var min = requireMin();
31992
- var pow = requirePow();
31993
- var round = requireRound();
31994
- var sign = requireSign();
32022
+ var abs = /*@__PURE__*/ requireAbs();
32023
+ var floor = /*@__PURE__*/ requireFloor();
32024
+ var max = /*@__PURE__*/ requireMax();
32025
+ var min = /*@__PURE__*/ requireMin();
32026
+ var pow = /*@__PURE__*/ requirePow();
32027
+ var round = /*@__PURE__*/ requireRound();
32028
+ var sign = /*@__PURE__*/ requireSign();
31995
32029
 
31996
32030
  var $Function = Function;
31997
32031
 
@@ -32002,8 +32036,8 @@ function requireGetIntrinsic () {
32002
32036
  } catch (e) {}
32003
32037
  };
32004
32038
 
32005
- var $gOPD = requireGopd();
32006
- var $defineProperty = requireEsDefineProperty();
32039
+ var $gOPD = /*@__PURE__*/ requireGopd();
32040
+ var $defineProperty = /*@__PURE__*/ requireEsDefineProperty();
32007
32041
 
32008
32042
  var throwTypeError = function () {
32009
32043
  throw new $TypeError();
@@ -32214,7 +32248,7 @@ function requireGetIntrinsic () {
32214
32248
  };
32215
32249
 
32216
32250
  var bind = requireFunctionBind();
32217
- var hasOwn = requireHasown();
32251
+ var hasOwn = /*@__PURE__*/ requireHasown();
32218
32252
  var $concat = bind.call($call, Array.prototype.concat);
32219
32253
  var $spliceApply = bind.call($apply, Array.prototype.splice);
32220
32254
  var $replace = bind.call($call, String.prototype.replace);
@@ -32359,7 +32393,7 @@ function requireCallBound () {
32359
32393
  if (hasRequiredCallBound) return callBound;
32360
32394
  hasRequiredCallBound = 1;
32361
32395
 
32362
- var GetIntrinsic = requireGetIntrinsic();
32396
+ var GetIntrinsic = /*@__PURE__*/ requireGetIntrinsic();
32363
32397
 
32364
32398
  var callBindBasic = requireCallBindApplyHelpers();
32365
32399
 
@@ -32386,11 +32420,11 @@ function requireSideChannelMap () {
32386
32420
  if (hasRequiredSideChannelMap) return sideChannelMap;
32387
32421
  hasRequiredSideChannelMap = 1;
32388
32422
 
32389
- var GetIntrinsic = requireGetIntrinsic();
32390
- var callBound = requireCallBound();
32391
- var inspect = requireObjectInspect();
32423
+ var GetIntrinsic = /*@__PURE__*/ requireGetIntrinsic();
32424
+ var callBound = /*@__PURE__*/ requireCallBound();
32425
+ var inspect = /*@__PURE__*/ requireObjectInspect();
32392
32426
 
32393
- var $TypeError = requireType();
32427
+ var $TypeError = /*@__PURE__*/ requireType();
32394
32428
  var $Map = GetIntrinsic('%Map%', true);
32395
32429
 
32396
32430
  /** @type {<K, V>(thisArg: Map<K, V>, key: K) => V} */
@@ -32462,12 +32496,12 @@ function requireSideChannelWeakmap () {
32462
32496
  if (hasRequiredSideChannelWeakmap) return sideChannelWeakmap;
32463
32497
  hasRequiredSideChannelWeakmap = 1;
32464
32498
 
32465
- var GetIntrinsic = requireGetIntrinsic();
32466
- var callBound = requireCallBound();
32467
- var inspect = requireObjectInspect();
32499
+ var GetIntrinsic = /*@__PURE__*/ requireGetIntrinsic();
32500
+ var callBound = /*@__PURE__*/ requireCallBound();
32501
+ var inspect = /*@__PURE__*/ requireObjectInspect();
32468
32502
  var getSideChannelMap = requireSideChannelMap();
32469
32503
 
32470
- var $TypeError = requireType();
32504
+ var $TypeError = /*@__PURE__*/ requireType();
32471
32505
  var $WeakMap = GetIntrinsic('%WeakMap%', true);
32472
32506
 
32473
32507
  /** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => V} */
@@ -32554,8 +32588,8 @@ function requireSideChannel () {
32554
32588
  if (hasRequiredSideChannel) return sideChannel;
32555
32589
  hasRequiredSideChannel = 1;
32556
32590
 
32557
- var $TypeError = requireType();
32558
- var inspect = requireObjectInspect();
32591
+ var $TypeError = /*@__PURE__*/ requireType();
32592
+ var inspect = /*@__PURE__*/ requireObjectInspect();
32559
32593
  var getSideChannelList = requireSideChannelList();
32560
32594
  var getSideChannelMap = requireSideChannelMap();
32561
32595
  var getSideChannelWeakMap = requireSideChannelWeakmap();
@@ -32636,7 +32670,7 @@ function requireUtils () {
32636
32670
  if (hasRequiredUtils) return utils;
32637
32671
  hasRequiredUtils = 1;
32638
32672
 
32639
- var formats = requireFormats();
32673
+ var formats = /*@__PURE__*/ requireFormats();
32640
32674
 
32641
32675
  var has = Object.prototype.hasOwnProperty;
32642
32676
  var isArray = Array.isArray;
@@ -32913,8 +32947,8 @@ function requireStringify () {
32913
32947
  hasRequiredStringify = 1;
32914
32948
 
32915
32949
  var getSideChannel = requireSideChannel();
32916
- var utils = requireUtils();
32917
- var formats = requireFormats();
32950
+ var utils = /*@__PURE__*/ requireUtils();
32951
+ var formats = /*@__PURE__*/ requireFormats();
32918
32952
  var has = Object.prototype.hasOwnProperty;
32919
32953
 
32920
32954
  var arrayPrefixGenerators = {
@@ -33269,14 +33303,14 @@ function requireStringify () {
33269
33303
  return stringify_1;
33270
33304
  }
33271
33305
 
33272
- var parse$4;
33306
+ var parse$1;
33273
33307
  var hasRequiredParse;
33274
33308
 
33275
33309
  function requireParse () {
33276
- if (hasRequiredParse) return parse$4;
33310
+ if (hasRequiredParse) return parse$1;
33277
33311
  hasRequiredParse = 1;
33278
33312
 
33279
- var utils = requireUtils();
33313
+ var utils = /*@__PURE__*/ requireUtils();
33280
33314
 
33281
33315
  var has = Object.prototype.hasOwnProperty;
33282
33316
  var isArray = Array.isArray;
@@ -33577,7 +33611,7 @@ function requireParse () {
33577
33611
  };
33578
33612
  };
33579
33613
 
33580
- parse$4 = function (str, opts) {
33614
+ parse$1 = function (str, opts) {
33581
33615
  var options = normalizeParseOptions(opts);
33582
33616
 
33583
33617
  if (str === '' || str === null || typeof str === 'undefined') {
@@ -33602,19 +33636,19 @@ function requireParse () {
33602
33636
 
33603
33637
  return utils.compact(obj);
33604
33638
  };
33605
- return parse$4;
33639
+ return parse$1;
33606
33640
  }
33607
33641
 
33608
33642
  var lib$1;
33609
- var hasRequiredLib;
33643
+ var hasRequiredLib$1;
33610
33644
 
33611
- function requireLib () {
33612
- if (hasRequiredLib) return lib$1;
33613
- hasRequiredLib = 1;
33645
+ function requireLib$1 () {
33646
+ if (hasRequiredLib$1) return lib$1;
33647
+ hasRequiredLib$1 = 1;
33614
33648
 
33615
- var stringify = requireStringify();
33616
- var parse = requireParse();
33617
- var formats = requireFormats();
33649
+ var stringify = /*@__PURE__*/ requireStringify();
33650
+ var parse = /*@__PURE__*/ requireParse();
33651
+ var formats = /*@__PURE__*/ requireFormats();
33618
33652
 
33619
33653
  lib$1 = {
33620
33654
  formats: formats,
@@ -33647,7 +33681,7 @@ function requireUrlencoded () {
33647
33681
  var contentType = requireContentType();
33648
33682
  var createError = requireHttpErrors();
33649
33683
  var debug = requireSrc()('body-parser:urlencoded');
33650
- var deprecate = depd_1('body-parser');
33684
+ var deprecate = requireDepd()('body-parser');
33651
33685
  var read = requireRead();
33652
33686
  var typeis = requireTypeIs();
33653
33687
 
@@ -33869,7 +33903,7 @@ function requireUrlencoded () {
33869
33903
  // this uses a switch for static require analysis
33870
33904
  switch (name) {
33871
33905
  case 'qs':
33872
- mod = requireLib();
33906
+ mod = /*@__PURE__*/ requireLib$1();
33873
33907
  break
33874
33908
  case 'querystring':
33875
33909
  mod = require$$8;
@@ -33938,159 +33972,166 @@ function requireUrlencoded () {
33938
33972
  * MIT Licensed
33939
33973
  */
33940
33974
 
33941
- (function (module, exports$1) {
33975
+ var hasRequiredBodyParser;
33942
33976
 
33943
- /**
33944
- * Module dependencies.
33945
- * @private
33946
- */
33977
+ function requireBodyParser () {
33978
+ if (hasRequiredBodyParser) return bodyParser.exports;
33979
+ hasRequiredBodyParser = 1;
33980
+ (function (module, exports$1) {
33947
33981
 
33948
- var deprecate = depd_1('body-parser');
33982
+ /**
33983
+ * Module dependencies.
33984
+ * @private
33985
+ */
33949
33986
 
33950
- /**
33951
- * Cache of loaded parsers.
33952
- * @private
33953
- */
33987
+ var deprecate = requireDepd()('body-parser');
33954
33988
 
33955
- var parsers = Object.create(null);
33989
+ /**
33990
+ * Cache of loaded parsers.
33991
+ * @private
33992
+ */
33956
33993
 
33957
- /**
33958
- * @typedef Parsers
33959
- * @type {function}
33960
- * @property {function} json
33961
- * @property {function} raw
33962
- * @property {function} text
33963
- * @property {function} urlencoded
33964
- */
33994
+ var parsers = Object.create(null);
33965
33995
 
33966
- /**
33967
- * Module exports.
33968
- * @type {Parsers}
33969
- */
33996
+ /**
33997
+ * @typedef Parsers
33998
+ * @type {function}
33999
+ * @property {function} json
34000
+ * @property {function} raw
34001
+ * @property {function} text
34002
+ * @property {function} urlencoded
34003
+ */
33970
34004
 
33971
- exports$1 = module.exports = deprecate.function(bodyParser,
33972
- 'bodyParser: use individual json/urlencoded middlewares');
34005
+ /**
34006
+ * Module exports.
34007
+ * @type {Parsers}
34008
+ */
33973
34009
 
33974
- /**
33975
- * JSON parser.
33976
- * @public
33977
- */
34010
+ exports$1 = module.exports = deprecate.function(bodyParser,
34011
+ 'bodyParser: use individual json/urlencoded middlewares');
33978
34012
 
33979
- Object.defineProperty(exports$1, 'json', {
33980
- configurable: true,
33981
- enumerable: true,
33982
- get: createParserGetter('json')
33983
- });
34013
+ /**
34014
+ * JSON parser.
34015
+ * @public
34016
+ */
33984
34017
 
33985
- /**
33986
- * Raw parser.
33987
- * @public
33988
- */
34018
+ Object.defineProperty(exports$1, 'json', {
34019
+ configurable: true,
34020
+ enumerable: true,
34021
+ get: createParserGetter('json')
34022
+ });
33989
34023
 
33990
- Object.defineProperty(exports$1, 'raw', {
33991
- configurable: true,
33992
- enumerable: true,
33993
- get: createParserGetter('raw')
33994
- });
34024
+ /**
34025
+ * Raw parser.
34026
+ * @public
34027
+ */
33995
34028
 
33996
- /**
33997
- * Text parser.
33998
- * @public
33999
- */
34029
+ Object.defineProperty(exports$1, 'raw', {
34030
+ configurable: true,
34031
+ enumerable: true,
34032
+ get: createParserGetter('raw')
34033
+ });
34000
34034
 
34001
- Object.defineProperty(exports$1, 'text', {
34002
- configurable: true,
34003
- enumerable: true,
34004
- get: createParserGetter('text')
34005
- });
34035
+ /**
34036
+ * Text parser.
34037
+ * @public
34038
+ */
34006
34039
 
34007
- /**
34008
- * URL-encoded parser.
34009
- * @public
34010
- */
34040
+ Object.defineProperty(exports$1, 'text', {
34041
+ configurable: true,
34042
+ enumerable: true,
34043
+ get: createParserGetter('text')
34044
+ });
34011
34045
 
34012
- Object.defineProperty(exports$1, 'urlencoded', {
34013
- configurable: true,
34014
- enumerable: true,
34015
- get: createParserGetter('urlencoded')
34016
- });
34046
+ /**
34047
+ * URL-encoded parser.
34048
+ * @public
34049
+ */
34017
34050
 
34018
- /**
34019
- * Create a middleware to parse json and urlencoded bodies.
34020
- *
34021
- * @param {object} [options]
34022
- * @return {function}
34023
- * @deprecated
34024
- * @public
34025
- */
34051
+ Object.defineProperty(exports$1, 'urlencoded', {
34052
+ configurable: true,
34053
+ enumerable: true,
34054
+ get: createParserGetter('urlencoded')
34055
+ });
34026
34056
 
34027
- function bodyParser (options) {
34028
- // use default type for parsers
34029
- var opts = Object.create(options || null, {
34030
- type: {
34031
- configurable: true,
34032
- enumerable: true,
34033
- value: undefined,
34034
- writable: true
34035
- }
34036
- });
34057
+ /**
34058
+ * Create a middleware to parse json and urlencoded bodies.
34059
+ *
34060
+ * @param {object} [options]
34061
+ * @return {function}
34062
+ * @deprecated
34063
+ * @public
34064
+ */
34037
34065
 
34038
- var _urlencoded = exports$1.urlencoded(opts);
34039
- var _json = exports$1.json(opts);
34066
+ function bodyParser (options) {
34067
+ // use default type for parsers
34068
+ var opts = Object.create(options || null, {
34069
+ type: {
34070
+ configurable: true,
34071
+ enumerable: true,
34072
+ value: undefined,
34073
+ writable: true
34074
+ }
34075
+ });
34040
34076
 
34041
- return function bodyParser (req, res, next) {
34042
- _json(req, res, function (err) {
34043
- if (err) return next(err)
34044
- _urlencoded(req, res, next);
34045
- });
34046
- }
34047
- }
34077
+ var _urlencoded = exports$1.urlencoded(opts);
34078
+ var _json = exports$1.json(opts);
34048
34079
 
34049
- /**
34050
- * Create a getter for loading a parser.
34051
- * @private
34052
- */
34080
+ return function bodyParser (req, res, next) {
34081
+ _json(req, res, function (err) {
34082
+ if (err) return next(err)
34083
+ _urlencoded(req, res, next);
34084
+ });
34085
+ }
34086
+ }
34053
34087
 
34054
- function createParserGetter (name) {
34055
- return function get () {
34056
- return loadParser(name)
34057
- }
34058
- }
34088
+ /**
34089
+ * Create a getter for loading a parser.
34090
+ * @private
34091
+ */
34059
34092
 
34060
- /**
34061
- * Load a parser module.
34062
- * @private
34063
- */
34093
+ function createParserGetter (name) {
34094
+ return function get () {
34095
+ return loadParser(name)
34096
+ }
34097
+ }
34064
34098
 
34065
- function loadParser (parserName) {
34066
- var parser = parsers[parserName];
34099
+ /**
34100
+ * Load a parser module.
34101
+ * @private
34102
+ */
34067
34103
 
34068
- if (parser !== undefined) {
34069
- return parser
34070
- }
34104
+ function loadParser (parserName) {
34105
+ var parser = parsers[parserName];
34071
34106
 
34072
- // this uses a switch for static require analysis
34073
- switch (parserName) {
34074
- case 'json':
34075
- parser = requireJson();
34076
- break
34077
- case 'raw':
34078
- parser = requireRaw();
34079
- break
34080
- case 'text':
34081
- parser = requireText();
34082
- break
34083
- case 'urlencoded':
34084
- parser = requireUrlencoded();
34085
- break
34086
- }
34107
+ if (parser !== undefined) {
34108
+ return parser
34109
+ }
34087
34110
 
34088
- // store to prevent invoking require()
34089
- return (parsers[parserName] = parser)
34090
- }
34091
- } (bodyParser, bodyParser.exports));
34111
+ // this uses a switch for static require analysis
34112
+ switch (parserName) {
34113
+ case 'json':
34114
+ parser = requireJson();
34115
+ break
34116
+ case 'raw':
34117
+ parser = requireRaw();
34118
+ break
34119
+ case 'text':
34120
+ parser = requireText();
34121
+ break
34122
+ case 'urlencoded':
34123
+ parser = requireUrlencoded();
34124
+ break
34125
+ }
34092
34126
 
34093
- var bodyParserExports = bodyParser.exports;
34127
+ // store to prevent invoking require()
34128
+ return (parsers[parserName] = parser)
34129
+ }
34130
+ } (bodyParser, bodyParser.exports));
34131
+ return bodyParser.exports;
34132
+ }
34133
+
34134
+ var bodyParserExports = requireBodyParser();
34094
34135
 
34095
34136
  var lib = {exports: {}};
34096
34137
 
@@ -34099,91 +34140,100 @@ object-assign
34099
34140
  (c) Sindre Sorhus
34100
34141
  @license MIT
34101
34142
  */
34102
- /* eslint-disable no-unused-vars */
34103
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
34104
- var hasOwnProperty = Object.prototype.hasOwnProperty;
34105
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
34106
-
34107
- function toObject(val) {
34108
- if (val === null || val === undefined) {
34109
- throw new TypeError('Object.assign cannot be called with null or undefined');
34110
- }
34111
34143
 
34112
- return Object(val);
34113
- }
34144
+ var objectAssign;
34145
+ var hasRequiredObjectAssign;
34114
34146
 
34115
- function shouldUseNative() {
34116
- try {
34117
- if (!Object.assign) {
34118
- return false;
34147
+ function requireObjectAssign () {
34148
+ if (hasRequiredObjectAssign) return objectAssign;
34149
+ hasRequiredObjectAssign = 1;
34150
+ /* eslint-disable no-unused-vars */
34151
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
34152
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
34153
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
34154
+
34155
+ function toObject(val) {
34156
+ if (val === null || val === undefined) {
34157
+ throw new TypeError('Object.assign cannot be called with null or undefined');
34119
34158
  }
34120
34159
 
34121
- // Detect buggy property enumeration order in older V8 versions.
34160
+ return Object(val);
34161
+ }
34122
34162
 
34123
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
34124
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
34125
- test1[5] = 'de';
34126
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
34127
- return false;
34128
- }
34163
+ function shouldUseNative() {
34164
+ try {
34165
+ if (!Object.assign) {
34166
+ return false;
34167
+ }
34129
34168
 
34130
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
34131
- var test2 = {};
34132
- for (var i = 0; i < 10; i++) {
34133
- test2['_' + String.fromCharCode(i)] = i;
34134
- }
34135
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
34136
- return test2[n];
34137
- });
34138
- if (order2.join('') !== '0123456789') {
34139
- return false;
34140
- }
34169
+ // Detect buggy property enumeration order in older V8 versions.
34141
34170
 
34142
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
34143
- var test3 = {};
34144
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
34145
- test3[letter] = letter;
34146
- });
34147
- if (Object.keys(Object.assign({}, test3)).join('') !==
34148
- 'abcdefghijklmnopqrst') {
34171
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
34172
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
34173
+ test1[5] = 'de';
34174
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
34175
+ return false;
34176
+ }
34177
+
34178
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
34179
+ var test2 = {};
34180
+ for (var i = 0; i < 10; i++) {
34181
+ test2['_' + String.fromCharCode(i)] = i;
34182
+ }
34183
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
34184
+ return test2[n];
34185
+ });
34186
+ if (order2.join('') !== '0123456789') {
34187
+ return false;
34188
+ }
34189
+
34190
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
34191
+ var test3 = {};
34192
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
34193
+ test3[letter] = letter;
34194
+ });
34195
+ if (Object.keys(Object.assign({}, test3)).join('') !==
34196
+ 'abcdefghijklmnopqrst') {
34197
+ return false;
34198
+ }
34199
+
34200
+ return true;
34201
+ } catch (err) {
34202
+ // We don't expect any of the above to throw, but better to be safe.
34149
34203
  return false;
34150
34204
  }
34151
-
34152
- return true;
34153
- } catch (err) {
34154
- // We don't expect any of the above to throw, but better to be safe.
34155
- return false;
34156
34205
  }
34157
- }
34158
34206
 
34159
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
34160
- var from;
34161
- var to = toObject(target);
34162
- var symbols;
34207
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
34208
+ var from;
34209
+ var to = toObject(target);
34210
+ var symbols;
34163
34211
 
34164
- for (var s = 1; s < arguments.length; s++) {
34165
- from = Object(arguments[s]);
34212
+ for (var s = 1; s < arguments.length; s++) {
34213
+ from = Object(arguments[s]);
34166
34214
 
34167
- for (var key in from) {
34168
- if (hasOwnProperty.call(from, key)) {
34169
- to[key] = from[key];
34215
+ for (var key in from) {
34216
+ if (hasOwnProperty.call(from, key)) {
34217
+ to[key] = from[key];
34218
+ }
34170
34219
  }
34171
- }
34172
34220
 
34173
- if (getOwnPropertySymbols) {
34174
- symbols = getOwnPropertySymbols(from);
34175
- for (var i = 0; i < symbols.length; i++) {
34176
- if (propIsEnumerable.call(from, symbols[i])) {
34177
- to[symbols[i]] = from[symbols[i]];
34221
+ if (getOwnPropertySymbols) {
34222
+ symbols = getOwnPropertySymbols(from);
34223
+ for (var i = 0; i < symbols.length; i++) {
34224
+ if (propIsEnumerable.call(from, symbols[i])) {
34225
+ to[symbols[i]] = from[symbols[i]];
34226
+ }
34178
34227
  }
34179
34228
  }
34180
34229
  }
34181
- }
34182
34230
 
34183
- return to;
34184
- };
34231
+ return to;
34232
+ };
34233
+ return objectAssign;
34234
+ }
34185
34235
 
34186
- var vary$1 = {exports: {}};
34236
+ var vary = {exports: {}};
34187
34237
 
34188
34238
  /*!
34189
34239
  * vary
@@ -34191,388 +34241,401 @@ var vary$1 = {exports: {}};
34191
34241
  * MIT Licensed
34192
34242
  */
34193
34243
 
34194
- /**
34195
- * Module exports.
34196
- */
34244
+ var hasRequiredVary;
34197
34245
 
34198
- vary$1.exports = vary;
34199
- vary$1.exports.append = append;
34246
+ function requireVary () {
34247
+ if (hasRequiredVary) return vary.exports;
34248
+ hasRequiredVary = 1;
34200
34249
 
34201
- /**
34202
- * RegExp to match field-name in RFC 7230 sec 3.2
34203
- *
34204
- * field-name = token
34205
- * token = 1*tchar
34206
- * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
34207
- * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
34208
- * / DIGIT / ALPHA
34209
- * ; any VCHAR, except delimiters
34210
- */
34250
+ /**
34251
+ * Module exports.
34252
+ */
34211
34253
 
34212
- var FIELD_NAME_REGEXP = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
34254
+ vary.exports = vary$1;
34255
+ vary.exports.append = append;
34213
34256
 
34214
- /**
34215
- * Append a field to a vary header.
34216
- *
34217
- * @param {String} header
34218
- * @param {String|Array} field
34219
- * @return {String}
34220
- * @public
34221
- */
34257
+ /**
34258
+ * RegExp to match field-name in RFC 7230 sec 3.2
34259
+ *
34260
+ * field-name = token
34261
+ * token = 1*tchar
34262
+ * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
34263
+ * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
34264
+ * / DIGIT / ALPHA
34265
+ * ; any VCHAR, except delimiters
34266
+ */
34222
34267
 
34223
- function append (header, field) {
34224
- if (typeof header !== 'string') {
34225
- throw new TypeError('header argument is required')
34226
- }
34268
+ var FIELD_NAME_REGEXP = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
34227
34269
 
34228
- if (!field) {
34229
- throw new TypeError('field argument is required')
34230
- }
34270
+ /**
34271
+ * Append a field to a vary header.
34272
+ *
34273
+ * @param {String} header
34274
+ * @param {String|Array} field
34275
+ * @return {String}
34276
+ * @public
34277
+ */
34231
34278
 
34232
- // get fields array
34233
- var fields = !Array.isArray(field)
34234
- ? parse$3(String(field))
34235
- : field;
34279
+ function append (header, field) {
34280
+ if (typeof header !== 'string') {
34281
+ throw new TypeError('header argument is required')
34282
+ }
34236
34283
 
34237
- // assert on invalid field names
34238
- for (var j = 0; j < fields.length; j++) {
34239
- if (!FIELD_NAME_REGEXP.test(fields[j])) {
34240
- throw new TypeError('field argument contains an invalid header name')
34241
- }
34242
- }
34243
-
34244
- // existing, unspecified vary
34245
- if (header === '*') {
34246
- return header
34247
- }
34248
-
34249
- // enumerate current values
34250
- var val = header;
34251
- var vals = parse$3(header.toLowerCase());
34252
-
34253
- // unspecified vary
34254
- if (fields.indexOf('*') !== -1 || vals.indexOf('*') !== -1) {
34255
- return '*'
34256
- }
34257
-
34258
- for (var i = 0; i < fields.length; i++) {
34259
- var fld = fields[i].toLowerCase();
34260
-
34261
- // append value (case-preserving)
34262
- if (vals.indexOf(fld) === -1) {
34263
- vals.push(fld);
34264
- val = val
34265
- ? val + ', ' + fields[i]
34266
- : fields[i];
34267
- }
34268
- }
34284
+ if (!field) {
34285
+ throw new TypeError('field argument is required')
34286
+ }
34269
34287
 
34270
- return val
34271
- }
34288
+ // get fields array
34289
+ var fields = !Array.isArray(field)
34290
+ ? parse(String(field))
34291
+ : field;
34272
34292
 
34273
- /**
34274
- * Parse a vary header into an array.
34275
- *
34276
- * @param {String} header
34277
- * @return {Array}
34278
- * @private
34279
- */
34293
+ // assert on invalid field names
34294
+ for (var j = 0; j < fields.length; j++) {
34295
+ if (!FIELD_NAME_REGEXP.test(fields[j])) {
34296
+ throw new TypeError('field argument contains an invalid header name')
34297
+ }
34298
+ }
34280
34299
 
34281
- function parse$3 (header) {
34282
- var end = 0;
34283
- var list = [];
34284
- var start = 0;
34285
-
34286
- // gather tokens
34287
- for (var i = 0, len = header.length; i < len; i++) {
34288
- switch (header.charCodeAt(i)) {
34289
- case 0x20: /* */
34290
- if (start === end) {
34291
- start = end = i + 1;
34292
- }
34293
- break
34294
- case 0x2c: /* , */
34295
- list.push(header.substring(start, end));
34296
- start = end = i + 1;
34297
- break
34298
- default:
34299
- end = i + 1;
34300
- break
34301
- }
34302
- }
34300
+ // existing, unspecified vary
34301
+ if (header === '*') {
34302
+ return header
34303
+ }
34303
34304
 
34304
- // final token
34305
- list.push(header.substring(start, end));
34305
+ // enumerate current values
34306
+ var val = header;
34307
+ var vals = parse(header.toLowerCase());
34306
34308
 
34307
- return list
34308
- }
34309
+ // unspecified vary
34310
+ if (fields.indexOf('*') !== -1 || vals.indexOf('*') !== -1) {
34311
+ return '*'
34312
+ }
34309
34313
 
34310
- /**
34311
- * Mark that a request is varied on a header field.
34312
- *
34313
- * @param {Object} res
34314
- * @param {String|Array} field
34315
- * @public
34316
- */
34314
+ for (var i = 0; i < fields.length; i++) {
34315
+ var fld = fields[i].toLowerCase();
34316
+
34317
+ // append value (case-preserving)
34318
+ if (vals.indexOf(fld) === -1) {
34319
+ vals.push(fld);
34320
+ val = val
34321
+ ? val + ', ' + fields[i]
34322
+ : fields[i];
34323
+ }
34324
+ }
34317
34325
 
34318
- function vary (res, field) {
34319
- if (!res || !res.getHeader || !res.setHeader) {
34320
- // quack quack
34321
- throw new TypeError('res argument is required')
34322
- }
34323
-
34324
- // get existing header
34325
- var val = res.getHeader('Vary') || '';
34326
- var header = Array.isArray(val)
34327
- ? val.join(', ')
34328
- : String(val);
34329
-
34330
- // set new header
34331
- if ((val = append(header, field))) {
34332
- res.setHeader('Vary', val);
34333
- }
34326
+ return val
34327
+ }
34328
+
34329
+ /**
34330
+ * Parse a vary header into an array.
34331
+ *
34332
+ * @param {String} header
34333
+ * @return {Array}
34334
+ * @private
34335
+ */
34336
+
34337
+ function parse (header) {
34338
+ var end = 0;
34339
+ var list = [];
34340
+ var start = 0;
34341
+
34342
+ // gather tokens
34343
+ for (var i = 0, len = header.length; i < len; i++) {
34344
+ switch (header.charCodeAt(i)) {
34345
+ case 0x20: /* */
34346
+ if (start === end) {
34347
+ start = end = i + 1;
34348
+ }
34349
+ break
34350
+ case 0x2c: /* , */
34351
+ list.push(header.substring(start, end));
34352
+ start = end = i + 1;
34353
+ break
34354
+ default:
34355
+ end = i + 1;
34356
+ break
34357
+ }
34358
+ }
34359
+
34360
+ // final token
34361
+ list.push(header.substring(start, end));
34362
+
34363
+ return list
34364
+ }
34365
+
34366
+ /**
34367
+ * Mark that a request is varied on a header field.
34368
+ *
34369
+ * @param {Object} res
34370
+ * @param {String|Array} field
34371
+ * @public
34372
+ */
34373
+
34374
+ function vary$1 (res, field) {
34375
+ if (!res || !res.getHeader || !res.setHeader) {
34376
+ // quack quack
34377
+ throw new TypeError('res argument is required')
34378
+ }
34379
+
34380
+ // get existing header
34381
+ var val = res.getHeader('Vary') || '';
34382
+ var header = Array.isArray(val)
34383
+ ? val.join(', ')
34384
+ : String(val);
34385
+
34386
+ // set new header
34387
+ if ((val = append(header, field))) {
34388
+ res.setHeader('Vary', val);
34389
+ }
34390
+ }
34391
+ return vary.exports;
34334
34392
  }
34335
34393
 
34336
- var varyExports = vary$1.exports;
34394
+ var hasRequiredLib;
34337
34395
 
34338
- (function () {
34396
+ function requireLib () {
34397
+ if (hasRequiredLib) return lib.exports;
34398
+ hasRequiredLib = 1;
34399
+ (function () {
34339
34400
 
34340
- var assign = objectAssign;
34341
- var vary = varyExports;
34401
+ var assign = requireObjectAssign();
34402
+ var vary = requireVary();
34342
34403
 
34343
- var defaults = {
34344
- origin: '*',
34345
- methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
34346
- preflightContinue: false,
34347
- optionsSuccessStatus: 204
34348
- };
34404
+ var defaults = {
34405
+ origin: '*',
34406
+ methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
34407
+ preflightContinue: false,
34408
+ optionsSuccessStatus: 204
34409
+ };
34349
34410
 
34350
- function isString(s) {
34351
- return typeof s === 'string' || s instanceof String;
34352
- }
34411
+ function isString(s) {
34412
+ return typeof s === 'string' || s instanceof String;
34413
+ }
34353
34414
 
34354
- function isOriginAllowed(origin, allowedOrigin) {
34355
- if (Array.isArray(allowedOrigin)) {
34356
- for (var i = 0; i < allowedOrigin.length; ++i) {
34357
- if (isOriginAllowed(origin, allowedOrigin[i])) {
34358
- return true;
34359
- }
34360
- }
34361
- return false;
34362
- } else if (isString(allowedOrigin)) {
34363
- return origin === allowedOrigin;
34364
- } else if (allowedOrigin instanceof RegExp) {
34365
- return allowedOrigin.test(origin);
34366
- } else {
34367
- return !!allowedOrigin;
34368
- }
34369
- }
34370
-
34371
- function configureOrigin(options, req) {
34372
- var requestOrigin = req.headers.origin,
34373
- headers = [],
34374
- isAllowed;
34375
-
34376
- if (!options.origin || options.origin === '*') {
34377
- // allow any origin
34378
- headers.push([{
34379
- key: 'Access-Control-Allow-Origin',
34380
- value: '*'
34381
- }]);
34382
- } else if (isString(options.origin)) {
34383
- // fixed origin
34384
- headers.push([{
34385
- key: 'Access-Control-Allow-Origin',
34386
- value: options.origin
34387
- }]);
34388
- headers.push([{
34389
- key: 'Vary',
34390
- value: 'Origin'
34391
- }]);
34392
- } else {
34393
- isAllowed = isOriginAllowed(requestOrigin, options.origin);
34394
- // reflect origin
34395
- headers.push([{
34396
- key: 'Access-Control-Allow-Origin',
34397
- value: isAllowed ? requestOrigin : false
34398
- }]);
34399
- headers.push([{
34400
- key: 'Vary',
34401
- value: 'Origin'
34402
- }]);
34403
- }
34415
+ function isOriginAllowed(origin, allowedOrigin) {
34416
+ if (Array.isArray(allowedOrigin)) {
34417
+ for (var i = 0; i < allowedOrigin.length; ++i) {
34418
+ if (isOriginAllowed(origin, allowedOrigin[i])) {
34419
+ return true;
34420
+ }
34421
+ }
34422
+ return false;
34423
+ } else if (isString(allowedOrigin)) {
34424
+ return origin === allowedOrigin;
34425
+ } else if (allowedOrigin instanceof RegExp) {
34426
+ return allowedOrigin.test(origin);
34427
+ } else {
34428
+ return !!allowedOrigin;
34429
+ }
34430
+ }
34404
34431
 
34405
- return headers;
34406
- }
34432
+ function configureOrigin(options, req) {
34433
+ var requestOrigin = req.headers.origin,
34434
+ headers = [],
34435
+ isAllowed;
34436
+
34437
+ if (!options.origin || options.origin === '*') {
34438
+ // allow any origin
34439
+ headers.push([{
34440
+ key: 'Access-Control-Allow-Origin',
34441
+ value: '*'
34442
+ }]);
34443
+ } else if (isString(options.origin)) {
34444
+ // fixed origin
34445
+ headers.push([{
34446
+ key: 'Access-Control-Allow-Origin',
34447
+ value: options.origin
34448
+ }]);
34449
+ headers.push([{
34450
+ key: 'Vary',
34451
+ value: 'Origin'
34452
+ }]);
34453
+ } else {
34454
+ isAllowed = isOriginAllowed(requestOrigin, options.origin);
34455
+ // reflect origin
34456
+ headers.push([{
34457
+ key: 'Access-Control-Allow-Origin',
34458
+ value: isAllowed ? requestOrigin : false
34459
+ }]);
34460
+ headers.push([{
34461
+ key: 'Vary',
34462
+ value: 'Origin'
34463
+ }]);
34464
+ }
34407
34465
 
34408
- function configureMethods(options) {
34409
- var methods = options.methods;
34410
- if (methods.join) {
34411
- methods = options.methods.join(','); // .methods is an array, so turn it into a string
34412
- }
34413
- return {
34414
- key: 'Access-Control-Allow-Methods',
34415
- value: methods
34416
- };
34417
- }
34418
-
34419
- function configureCredentials(options) {
34420
- if (options.credentials === true) {
34421
- return {
34422
- key: 'Access-Control-Allow-Credentials',
34423
- value: 'true'
34424
- };
34425
- }
34426
- return null;
34427
- }
34428
-
34429
- function configureAllowedHeaders(options, req) {
34430
- var allowedHeaders = options.allowedHeaders || options.headers;
34431
- var headers = [];
34432
-
34433
- if (!allowedHeaders) {
34434
- allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers
34435
- headers.push([{
34436
- key: 'Vary',
34437
- value: 'Access-Control-Request-Headers'
34438
- }]);
34439
- } else if (allowedHeaders.join) {
34440
- allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string
34441
- }
34442
- if (allowedHeaders && allowedHeaders.length) {
34443
- headers.push([{
34444
- key: 'Access-Control-Allow-Headers',
34445
- value: allowedHeaders
34446
- }]);
34447
- }
34466
+ return headers;
34467
+ }
34448
34468
 
34449
- return headers;
34450
- }
34469
+ function configureMethods(options) {
34470
+ var methods = options.methods;
34471
+ if (methods.join) {
34472
+ methods = options.methods.join(','); // .methods is an array, so turn it into a string
34473
+ }
34474
+ return {
34475
+ key: 'Access-Control-Allow-Methods',
34476
+ value: methods
34477
+ };
34478
+ }
34451
34479
 
34452
- function configureExposedHeaders(options) {
34453
- var headers = options.exposedHeaders;
34454
- if (!headers) {
34455
- return null;
34456
- } else if (headers.join) {
34457
- headers = headers.join(','); // .headers is an array, so turn it into a string
34458
- }
34459
- if (headers && headers.length) {
34460
- return {
34461
- key: 'Access-Control-Expose-Headers',
34462
- value: headers
34463
- };
34464
- }
34465
- return null;
34466
- }
34467
-
34468
- function configureMaxAge(options) {
34469
- var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString();
34470
- if (maxAge && maxAge.length) {
34471
- return {
34472
- key: 'Access-Control-Max-Age',
34473
- value: maxAge
34474
- };
34475
- }
34476
- return null;
34477
- }
34478
-
34479
- function applyHeaders(headers, res) {
34480
- for (var i = 0, n = headers.length; i < n; i++) {
34481
- var header = headers[i];
34482
- if (header) {
34483
- if (Array.isArray(header)) {
34484
- applyHeaders(header, res);
34485
- } else if (header.key === 'Vary' && header.value) {
34486
- vary(res, header.value);
34487
- } else if (header.value) {
34488
- res.setHeader(header.key, header.value);
34489
- }
34490
- }
34491
- }
34492
- }
34493
-
34494
- function cors(options, req, res, next) {
34495
- var headers = [],
34496
- method = req.method && req.method.toUpperCase && req.method.toUpperCase();
34497
-
34498
- if (method === 'OPTIONS') {
34499
- // preflight
34500
- headers.push(configureOrigin(options, req));
34501
- headers.push(configureCredentials(options));
34502
- headers.push(configureMethods(options));
34503
- headers.push(configureAllowedHeaders(options, req));
34504
- headers.push(configureMaxAge(options));
34505
- headers.push(configureExposedHeaders(options));
34506
- applyHeaders(headers, res);
34507
-
34508
- if (options.preflightContinue) {
34509
- next();
34510
- } else {
34511
- // Safari (and potentially other browsers) need content-length 0,
34512
- // for 204 or they just hang waiting for a body
34513
- res.statusCode = options.optionsSuccessStatus;
34514
- res.setHeader('Content-Length', '0');
34515
- res.end();
34516
- }
34517
- } else {
34518
- // actual response
34519
- headers.push(configureOrigin(options, req));
34520
- headers.push(configureCredentials(options));
34521
- headers.push(configureExposedHeaders(options));
34522
- applyHeaders(headers, res);
34523
- next();
34524
- }
34525
- }
34526
-
34527
- function middlewareWrapper(o) {
34528
- // if options are static (either via defaults or custom options passed in), wrap in a function
34529
- var optionsCallback = null;
34530
- if (typeof o === 'function') {
34531
- optionsCallback = o;
34532
- } else {
34533
- optionsCallback = function (req, cb) {
34534
- cb(null, o);
34535
- };
34536
- }
34480
+ function configureCredentials(options) {
34481
+ if (options.credentials === true) {
34482
+ return {
34483
+ key: 'Access-Control-Allow-Credentials',
34484
+ value: 'true'
34485
+ };
34486
+ }
34487
+ return null;
34488
+ }
34537
34489
 
34538
- return function corsMiddleware(req, res, next) {
34539
- optionsCallback(req, function (err, options) {
34540
- if (err) {
34541
- next(err);
34542
- } else {
34543
- var corsOptions = assign({}, defaults, options);
34544
- var originCallback = null;
34545
- if (corsOptions.origin && typeof corsOptions.origin === 'function') {
34546
- originCallback = corsOptions.origin;
34547
- } else if (corsOptions.origin) {
34548
- originCallback = function (origin, cb) {
34549
- cb(null, corsOptions.origin);
34550
- };
34551
- }
34552
-
34553
- if (originCallback) {
34554
- originCallback(req.headers.origin, function (err2, origin) {
34555
- if (err2 || !origin) {
34556
- next(err2);
34557
- } else {
34558
- corsOptions.origin = origin;
34559
- cors(corsOptions, req, res, next);
34560
- }
34561
- });
34562
- } else {
34563
- next();
34564
- }
34565
- }
34566
- });
34567
- };
34568
- }
34490
+ function configureAllowedHeaders(options, req) {
34491
+ var allowedHeaders = options.allowedHeaders || options.headers;
34492
+ var headers = [];
34493
+
34494
+ if (!allowedHeaders) {
34495
+ allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers
34496
+ headers.push([{
34497
+ key: 'Vary',
34498
+ value: 'Access-Control-Request-Headers'
34499
+ }]);
34500
+ } else if (allowedHeaders.join) {
34501
+ allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string
34502
+ }
34503
+ if (allowedHeaders && allowedHeaders.length) {
34504
+ headers.push([{
34505
+ key: 'Access-Control-Allow-Headers',
34506
+ value: allowedHeaders
34507
+ }]);
34508
+ }
34509
+
34510
+ return headers;
34511
+ }
34512
+
34513
+ function configureExposedHeaders(options) {
34514
+ var headers = options.exposedHeaders;
34515
+ if (!headers) {
34516
+ return null;
34517
+ } else if (headers.join) {
34518
+ headers = headers.join(','); // .headers is an array, so turn it into a string
34519
+ }
34520
+ if (headers && headers.length) {
34521
+ return {
34522
+ key: 'Access-Control-Expose-Headers',
34523
+ value: headers
34524
+ };
34525
+ }
34526
+ return null;
34527
+ }
34569
34528
 
34570
- // can pass either an options hash, an options delegate, or nothing
34571
- lib.exports = middlewareWrapper;
34529
+ function configureMaxAge(options) {
34530
+ var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString();
34531
+ if (maxAge && maxAge.length) {
34532
+ return {
34533
+ key: 'Access-Control-Max-Age',
34534
+ value: maxAge
34535
+ };
34536
+ }
34537
+ return null;
34538
+ }
34572
34539
 
34573
- }());
34540
+ function applyHeaders(headers, res) {
34541
+ for (var i = 0, n = headers.length; i < n; i++) {
34542
+ var header = headers[i];
34543
+ if (header) {
34544
+ if (Array.isArray(header)) {
34545
+ applyHeaders(header, res);
34546
+ } else if (header.key === 'Vary' && header.value) {
34547
+ vary(res, header.value);
34548
+ } else if (header.value) {
34549
+ res.setHeader(header.key, header.value);
34550
+ }
34551
+ }
34552
+ }
34553
+ }
34574
34554
 
34575
- var libExports = lib.exports;
34555
+ function cors(options, req, res, next) {
34556
+ var headers = [],
34557
+ method = req.method && req.method.toUpperCase && req.method.toUpperCase();
34558
+
34559
+ if (method === 'OPTIONS') {
34560
+ // preflight
34561
+ headers.push(configureOrigin(options, req));
34562
+ headers.push(configureCredentials(options));
34563
+ headers.push(configureMethods(options));
34564
+ headers.push(configureAllowedHeaders(options, req));
34565
+ headers.push(configureMaxAge(options));
34566
+ headers.push(configureExposedHeaders(options));
34567
+ applyHeaders(headers, res);
34568
+
34569
+ if (options.preflightContinue) {
34570
+ next();
34571
+ } else {
34572
+ // Safari (and potentially other browsers) need content-length 0,
34573
+ // for 204 or they just hang waiting for a body
34574
+ res.statusCode = options.optionsSuccessStatus;
34575
+ res.setHeader('Content-Length', '0');
34576
+ res.end();
34577
+ }
34578
+ } else {
34579
+ // actual response
34580
+ headers.push(configureOrigin(options, req));
34581
+ headers.push(configureCredentials(options));
34582
+ headers.push(configureExposedHeaders(options));
34583
+ applyHeaders(headers, res);
34584
+ next();
34585
+ }
34586
+ }
34587
+
34588
+ function middlewareWrapper(o) {
34589
+ // if options are static (either via defaults or custom options passed in), wrap in a function
34590
+ var optionsCallback = null;
34591
+ if (typeof o === 'function') {
34592
+ optionsCallback = o;
34593
+ } else {
34594
+ optionsCallback = function (req, cb) {
34595
+ cb(null, o);
34596
+ };
34597
+ }
34598
+
34599
+ return function corsMiddleware(req, res, next) {
34600
+ optionsCallback(req, function (err, options) {
34601
+ if (err) {
34602
+ next(err);
34603
+ } else {
34604
+ var corsOptions = assign({}, defaults, options);
34605
+ var originCallback = null;
34606
+ if (corsOptions.origin && typeof corsOptions.origin === 'function') {
34607
+ originCallback = corsOptions.origin;
34608
+ } else if (corsOptions.origin) {
34609
+ originCallback = function (origin, cb) {
34610
+ cb(null, corsOptions.origin);
34611
+ };
34612
+ }
34613
+
34614
+ if (originCallback) {
34615
+ originCallback(req.headers.origin, function (err2, origin) {
34616
+ if (err2 || !origin) {
34617
+ next(err2);
34618
+ } else {
34619
+ corsOptions.origin = origin;
34620
+ cors(corsOptions, req, res, next);
34621
+ }
34622
+ });
34623
+ } else {
34624
+ next();
34625
+ }
34626
+ }
34627
+ });
34628
+ };
34629
+ }
34630
+
34631
+ // can pass either an options hash, an options delegate, or nothing
34632
+ lib.exports = middlewareWrapper;
34633
+
34634
+ }());
34635
+ return lib.exports;
34636
+ }
34637
+
34638
+ var libExports = requireLib();
34576
34639
  var cors = /*@__PURE__*/getDefaultExportFromCjs(libExports);
34577
34640
 
34578
34641
  function every (arr, cb) {
@@ -34609,7 +34672,7 @@ function isMatch(arr, obj, idx) {
34609
34672
  return (obj.val === idx && obj.type === STYPE) || (idx === SEP ? obj.type > PTYPE : obj.type !== STYPE && (idx || '').endsWith(obj.end));
34610
34673
  }
34611
34674
 
34612
- function match$1(str, all) {
34675
+ function match(str, all) {
34613
34676
  var i=0, tmp, segs=split(str), len=segs.length, l;
34614
34677
  var fn = isMatch.bind(isMatch, segs);
34615
34678
 
@@ -34623,7 +34686,7 @@ function match$1(str, all) {
34623
34686
  return [];
34624
34687
  }
34625
34688
 
34626
- function parse$2(str) {
34689
+ function parse(str) {
34627
34690
  if (str === SEP) {
34628
34691
  return [{ old:str, type:STYPE, val:str, end:'' }];
34629
34692
  }
@@ -34687,7 +34750,7 @@ function parse$2(str) {
34687
34750
  return out;
34688
34751
  }
34689
34752
 
34690
- function exec$1(str, arr) {
34753
+ function exec(str, arr) {
34691
34754
  var i=0, x, y, segs=split(str), out={};
34692
34755
  for (; i < arr.length; i++) {
34693
34756
  x=segs[i]; y=arr[i];
@@ -34701,186 +34764,211 @@ function exec$1(str, arr) {
34701
34764
 
34702
34765
  var matchit = /*#__PURE__*/Object.freeze({
34703
34766
  __proto__: null,
34704
- exec: exec$1,
34705
- match: match$1,
34706
- parse: parse$2
34767
+ exec: exec,
34768
+ match: match,
34769
+ parse: parse
34707
34770
  });
34708
34771
 
34709
34772
  var require$$0 = /*@__PURE__*/getAugmentedNamespace(matchit);
34710
34773
 
34711
- const { exec, match, parse: parse$1 } = require$$0;
34712
-
34713
- class Trouter {
34714
- constructor(opts) {
34715
- this.opts = opts || {};
34716
- this.routes = {};
34717
- this.handlers = {};
34718
-
34719
- this.all = this.add.bind(this, '*');
34720
- this.get = this.add.bind(this, 'GET');
34721
- this.head = this.add.bind(this, 'HEAD');
34722
- this.patch = this.add.bind(this, 'PATCH');
34723
- this.options = this.add.bind(this, 'OPTIONS');
34724
- this.connect = this.add.bind(this, 'CONNECT');
34725
- this.delete = this.add.bind(this, 'DELETE');
34726
- this.trace = this.add.bind(this, 'TRACE');
34727
- this.post = this.add.bind(this, 'POST');
34728
- this.put = this.add.bind(this, 'PUT');
34729
- }
34774
+ var trouter;
34775
+ var hasRequiredTrouter;
34776
+
34777
+ function requireTrouter () {
34778
+ if (hasRequiredTrouter) return trouter;
34779
+ hasRequiredTrouter = 1;
34780
+ const { exec, match, parse } = require$$0;
34781
+
34782
+ class Trouter {
34783
+ constructor(opts) {
34784
+ this.opts = opts || {};
34785
+ this.routes = {};
34786
+ this.handlers = {};
34787
+
34788
+ this.all = this.add.bind(this, '*');
34789
+ this.get = this.add.bind(this, 'GET');
34790
+ this.head = this.add.bind(this, 'HEAD');
34791
+ this.patch = this.add.bind(this, 'PATCH');
34792
+ this.options = this.add.bind(this, 'OPTIONS');
34793
+ this.connect = this.add.bind(this, 'CONNECT');
34794
+ this.delete = this.add.bind(this, 'DELETE');
34795
+ this.trace = this.add.bind(this, 'TRACE');
34796
+ this.post = this.add.bind(this, 'POST');
34797
+ this.put = this.add.bind(this, 'PUT');
34798
+ }
34730
34799
 
34731
- add(method, pattern, ...fns) {
34732
- // Save decoded pattern info
34733
- if (this.routes[method] === void 0) this.routes[method]=[];
34734
- this.routes[method].push(parse$1(pattern));
34735
- // Save route handler(s)
34736
- if (this.handlers[method] === void 0) this.handlers[method]={};
34737
- this.handlers[method][pattern] = fns;
34738
- // Allow chainable
34739
- return this;
34740
- }
34800
+ add(method, pattern, ...fns) {
34801
+ // Save decoded pattern info
34802
+ if (this.routes[method] === void 0) this.routes[method]=[];
34803
+ this.routes[method].push(parse(pattern));
34804
+ // Save route handler(s)
34805
+ if (this.handlers[method] === void 0) this.handlers[method]={};
34806
+ this.handlers[method][pattern] = fns;
34807
+ // Allow chainable
34808
+ return this;
34809
+ }
34741
34810
 
34742
- find(method, url) {
34743
- let arr = match(url, this.routes[method] || []);
34744
- if (arr.length === 0) {
34745
- arr = match(url, this.routes[method='*'] || []);
34746
- if (!arr.length) return false;
34811
+ find(method, url) {
34812
+ let arr = match(url, this.routes[method] || []);
34813
+ if (arr.length === 0) {
34814
+ arr = match(url, this.routes[method='*'] || []);
34815
+ if (!arr.length) return false;
34816
+ }
34817
+ return {
34818
+ params: exec(url, arr),
34819
+ handlers: this.handlers[method][arr[0].old]
34820
+ };
34747
34821
  }
34748
- return {
34749
- params: exec(url, arr),
34750
- handlers: this.handlers[method][arr[0].old]
34751
- };
34752
34822
  }
34753
- }
34754
34823
 
34755
- var trouter = Trouter;
34756
-
34757
- var url = function (req) {
34758
- let url = req.url;
34759
- if (url === void 0) return url;
34824
+ trouter = Trouter;
34825
+ return trouter;
34826
+ }
34760
34827
 
34761
- let obj = req._parsedUrl;
34762
- if (obj && obj._raw === url) return obj;
34828
+ var url;
34829
+ var hasRequiredUrl;
34763
34830
 
34764
- obj = {};
34765
- obj.query = obj.search = null;
34766
- obj.href = obj.path = obj.pathname = url;
34831
+ function requireUrl () {
34832
+ if (hasRequiredUrl) return url;
34833
+ hasRequiredUrl = 1;
34834
+ url = function (req) {
34835
+ let url = req.url;
34836
+ if (url === void 0) return url;
34767
34837
 
34768
- let idx = url.indexOf('?', 1);
34769
- if (idx !== -1) {
34770
- obj.search = url.substring(idx);
34771
- obj.query = obj.search.substring(1);
34772
- obj.pathname = url.substring(0, idx);
34773
- }
34838
+ let obj = req._parsedUrl;
34839
+ if (obj && obj._raw === url) return obj;
34774
34840
 
34775
- obj._raw = url;
34776
-
34777
- return (req._parsedUrl = obj);
34778
- };
34841
+ obj = {};
34842
+ obj.query = obj.search = null;
34843
+ obj.href = obj.path = obj.pathname = url;
34779
34844
 
34780
- const http = require$$1$3;
34781
- const Router = trouter;
34782
- const { parse } = require$$8;
34783
- const parser = url;
34845
+ let idx = url.indexOf('?', 1);
34846
+ if (idx !== -1) {
34847
+ obj.search = url.substring(idx);
34848
+ obj.query = obj.search.substring(1);
34849
+ obj.pathname = url.substring(0, idx);
34850
+ }
34784
34851
 
34785
- function lead(x) {
34786
- return x.charCodeAt(0) === 47 ? x : ('/' + x);
34787
- }
34852
+ obj._raw = url;
34788
34853
 
34789
- function value(x) {
34790
- let y = x.indexOf('/', 1);
34791
- return y > 1 ? x.substring(0, y) : x;
34854
+ return (req._parsedUrl = obj);
34855
+ };
34856
+ return url;
34792
34857
  }
34793
34858
 
34794
- function mutate(str, req) {
34795
- req.url = req.url.substring(str.length) || '/';
34796
- req.path = req.path.substring(str.length) || '/';
34797
- }
34859
+ var polka$1;
34860
+ var hasRequiredPolka;
34798
34861
 
34799
- function onError(err, req, res, next) {
34800
- let code = (res.statusCode = err.code || err.status || 500);
34801
- res.end(err.length && err || err.message || http.STATUS_CODES[code]);
34802
- }
34862
+ function requirePolka () {
34863
+ if (hasRequiredPolka) return polka$1;
34864
+ hasRequiredPolka = 1;
34865
+ const http = require$$1$3;
34866
+ const Router = requireTrouter();
34867
+ const { parse } = require$$8;
34868
+ const parser = requireUrl();
34803
34869
 
34804
- class Polka extends Router {
34805
- constructor(opts={}) {
34806
- super(opts);
34807
- this.apps = {};
34808
- this.wares = [];
34809
- this.bwares = {};
34810
- this.parse = parser;
34811
- this.server = opts.server;
34812
- this.handler = this.handler.bind(this);
34813
- this.onError = opts.onError || onError; // catch-all handler
34814
- this.onNoMatch = opts.onNoMatch || this.onError.bind(null, { code:404 });
34870
+ function lead(x) {
34871
+ return x.charCodeAt(0) === 47 ? x : ('/' + x);
34815
34872
  }
34816
34873
 
34817
- add(method, pattern, ...fns) {
34818
- let base = lead(value(pattern));
34819
- if (this.apps[base] !== void 0) throw new Error(`Cannot mount ".${method.toLowerCase()}('${lead(pattern)}')" because a Polka application at ".use('${base}')" already exists! You should move this handler into your Polka application instead.`);
34820
- return super.add(method, pattern, ...fns);
34874
+ function value(x) {
34875
+ let y = x.indexOf('/', 1);
34876
+ return y > 1 ? x.substring(0, y) : x;
34821
34877
  }
34822
34878
 
34823
- use(base, ...fns) {
34824
- if (typeof base === 'function') {
34825
- this.wares = this.wares.concat(base, fns);
34826
- } else if (base === '/') {
34827
- this.wares = this.wares.concat(fns);
34828
- } else {
34829
- base = lead(base);
34830
- fns.forEach(fn => {
34831
- if (fn instanceof Polka) {
34832
- this.apps[base] = fn;
34833
- } else {
34834
- let arr = this.bwares[base] || [];
34835
- arr.length > 0 || arr.push((r, _, nxt) => (mutate(base, r),nxt()));
34836
- this.bwares[base] = arr.concat(fn);
34837
- }
34838
- });
34839
- }
34840
- return this; // chainable
34879
+ function mutate(str, req) {
34880
+ req.url = req.url.substring(str.length) || '/';
34881
+ req.path = req.path.substring(str.length) || '/';
34841
34882
  }
34842
34883
 
34843
- listen() {
34844
- (this.server = this.server || http.createServer()).on('request', this.handler);
34845
- this.server.listen.apply(this.server, arguments);
34846
- return this;
34884
+ function onError(err, req, res, next) {
34885
+ let code = (res.statusCode = err.code || err.status || 500);
34886
+ res.end(err.length && err || err.message || http.STATUS_CODES[code]);
34847
34887
  }
34848
34888
 
34849
- handler(req, res, info) {
34850
- info = info || this.parse(req);
34851
- let fns=[], arr=this.wares, obj=this.find(req.method, info.pathname);
34852
- req.originalUrl = req.originalUrl || req.url;
34853
- let base = value(req.path = info.pathname);
34854
- if (this.bwares[base] !== void 0) {
34855
- arr = arr.concat(this.bwares[base]);
34889
+ class Polka extends Router {
34890
+ constructor(opts={}) {
34891
+ super(opts);
34892
+ this.apps = {};
34893
+ this.wares = [];
34894
+ this.bwares = {};
34895
+ this.parse = parser;
34896
+ this.server = opts.server;
34897
+ this.handler = this.handler.bind(this);
34898
+ this.onError = opts.onError || onError; // catch-all handler
34899
+ this.onNoMatch = opts.onNoMatch || this.onError.bind(null, { code:404 });
34856
34900
  }
34857
- if (obj) {
34858
- fns = obj.handlers;
34859
- req.params = obj.params;
34860
- } else if (this.apps[base] !== void 0) {
34861
- mutate(base, req); info.pathname=req.path; //=> updates
34862
- fns.push(this.apps[base].handler.bind(null, req, res, info));
34863
- } else if (fns.length === 0) {
34864
- fns.push(this.onNoMatch);
34901
+
34902
+ add(method, pattern, ...fns) {
34903
+ let base = lead(value(pattern));
34904
+ if (this.apps[base] !== void 0) throw new Error(`Cannot mount ".${method.toLowerCase()}('${lead(pattern)}')" because a Polka application at ".use('${base}')" already exists! You should move this handler into your Polka application instead.`);
34905
+ return super.add(method, pattern, ...fns);
34906
+ }
34907
+
34908
+ use(base, ...fns) {
34909
+ if (typeof base === 'function') {
34910
+ this.wares = this.wares.concat(base, fns);
34911
+ } else if (base === '/') {
34912
+ this.wares = this.wares.concat(fns);
34913
+ } else {
34914
+ base = lead(base);
34915
+ fns.forEach(fn => {
34916
+ if (fn instanceof Polka) {
34917
+ this.apps[base] = fn;
34918
+ } else {
34919
+ let arr = this.bwares[base] || [];
34920
+ arr.length > 0 || arr.push((r, _, nxt) => (mutate(base, r),nxt()));
34921
+ this.bwares[base] = arr.concat(fn);
34922
+ }
34923
+ });
34924
+ }
34925
+ return this; // chainable
34926
+ }
34927
+
34928
+ listen() {
34929
+ (this.server = this.server || http.createServer()).on('request', this.handler);
34930
+ this.server.listen.apply(this.server, arguments);
34931
+ return this;
34932
+ }
34933
+
34934
+ handler(req, res, info) {
34935
+ info = info || this.parse(req);
34936
+ let fns=[], arr=this.wares, obj=this.find(req.method, info.pathname);
34937
+ req.originalUrl = req.originalUrl || req.url;
34938
+ let base = value(req.path = info.pathname);
34939
+ if (this.bwares[base] !== void 0) {
34940
+ arr = arr.concat(this.bwares[base]);
34941
+ }
34942
+ if (obj) {
34943
+ fns = obj.handlers;
34944
+ req.params = obj.params;
34945
+ } else if (this.apps[base] !== void 0) {
34946
+ mutate(base, req); info.pathname=req.path; //=> updates
34947
+ fns.push(this.apps[base].handler.bind(null, req, res, info));
34948
+ } else if (fns.length === 0) {
34949
+ fns.push(this.onNoMatch);
34950
+ }
34951
+ // Grab addl values from `info`
34952
+ req.search = info.search;
34953
+ req.query = parse(info.query);
34954
+ // Exit if only a single function
34955
+ let i=0, len=arr.length, num=fns.length;
34956
+ if (len === i && num === 1) return fns[0](req, res);
34957
+ // Otherwise loop thru all middlware
34958
+ let next = err => err ? this.onError(err, req, res, next) : loop();
34959
+ let loop = _ => res.finished || (i < len) && arr[i++](req, res, next);
34960
+ arr = arr.concat(fns);
34961
+ len += num;
34962
+ loop(); // init
34865
34963
  }
34866
- // Grab addl values from `info`
34867
- req.search = info.search;
34868
- req.query = parse(info.query);
34869
- // Exit if only a single function
34870
- let i=0, len=arr.length, num=fns.length;
34871
- if (len === i && num === 1) return fns[0](req, res);
34872
- // Otherwise loop thru all middlware
34873
- let next = err => err ? this.onError(err, req, res, next) : loop();
34874
- let loop = _ => res.finished || (i < len) && arr[i++](req, res, next);
34875
- arr = arr.concat(fns);
34876
- len += num;
34877
- loop(); // init
34878
34964
  }
34879
- }
34880
34965
 
34881
- var polka = opts => new Polka(opts);
34966
+ polka$1 = opts => new Polka(opts);
34967
+ return polka$1;
34968
+ }
34882
34969
 
34883
- var polka$1 = /*@__PURE__*/getDefaultExportFromCjs(polka);
34970
+ var polkaExports = requirePolka();
34971
+ var polka = /*@__PURE__*/getDefaultExportFromCjs(polkaExports);
34884
34972
 
34885
34973
  /**
34886
34974
  * Abstract class representing a ProviderClass.
@@ -35066,7 +35154,7 @@ class ProviderClass extends EventEmitterClass {
35066
35154
  * @returns {Polka} Polka instance.
35067
35155
  */
35068
35156
  buildHTTPServer() {
35069
- return polka$1()
35157
+ return polka()
35070
35158
  .use(cors())
35071
35159
  .use(bodyParserExports.urlencoded({ extended: true }))
35072
35160
  .use(bodyParserExports.json());