@andersbakken/fisk 4.0.64 → 4.0.65

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.
@@ -139,7 +139,12 @@ class Database {
139
139
  resolve(JSON.parse(data));
140
140
  }
141
141
  catch (error) {
142
- fs__default["default"].renameSync(this.path, this.path + ".error");
142
+ try {
143
+ fs__default["default"].renameSync(this.path, this.path + ".error");
144
+ }
145
+ catch (renameErr) {
146
+ console.error("Failed to quarantine corrupt DB file", this.path, renameErr);
147
+ }
143
148
  reject(new Error(`Failed to parse JSON from file: ${this.path} ${error.message}`));
144
149
  }
145
150
  }
@@ -3659,7 +3664,8 @@ class Environments {
3659
3664
  if (st.isDirectory()) {
3660
3665
  // we're good
3661
3666
  this._path = p;
3662
- fs$4.readdir(p).then((files) => {
3667
+ fs$4.readdir(p)
3668
+ .then((files) => {
3663
3669
  const promises = [];
3664
3670
  files.forEach((e) => {
3665
3671
  if (e.length === 47 && e.indexOf(".tar.gz", 40) === 40) {
@@ -3678,13 +3684,12 @@ class Environments {
3678
3684
  }));
3679
3685
  }
3680
3686
  });
3681
- Promise.all(promises).then(() => {
3687
+ return Promise.all(promises).then(() => {
3682
3688
  resolve();
3683
3689
  });
3684
- // setTimeout(() => {
3685
- // // console.log(JSON.stringify(environments._links, null, 4));
3686
- // this.link("28CD22DF1176120F63EC463E095F13D4330194D7", "177EF462A7AEC31C26502F5833A92B51C177C01B", [], []);
3687
- // }, 1000);
3690
+ })
3691
+ .catch((err) => {
3692
+ reject(`Failed to read environments directory ${p}: ${err}`);
3688
3693
  });
3689
3694
  }
3690
3695
  else {
@@ -3720,15 +3725,12 @@ class Environments {
3720
3725
  return new File(path__default["default"].join(this._path, `${environment.hash}.tar.gz`), environment.hash);
3721
3726
  }
3722
3727
  complete(file) {
3723
- return new Promise((resolve) => {
3724
- untarFile(file.path, "etc/compiler_info").then((data) => {
3725
- const idx = data.indexOf("\n");
3726
- const info = JSON.parse(data.substr(0, idx));
3727
- const env = new Environment(file.path, file.hash, info.system, info.originalPath);
3728
- env.info = data.substr(idx + 1);
3729
- this._data[file.hash] = env;
3730
- resolve();
3731
- });
3728
+ return untarFile(file.path, "etc/compiler_info").then((data) => {
3729
+ const idx = data.indexOf("\n");
3730
+ const info = JSON.parse(data.substr(0, idx));
3731
+ const env = new Environment(file.path, file.hash, info.system, info.originalPath);
3732
+ env.info = data.substr(idx + 1);
3733
+ this._data[file.hash] = env;
3732
3734
  });
3733
3735
  }
3734
3736
  hasEnvironment(hash) {
@@ -3807,21 +3809,24 @@ class Environments {
3807
3809
  return this._db.set("links", this.linksInfo());
3808
3810
  }
3809
3811
  remove(hash) {
3810
- // ### this should be promisified
3811
3812
  const env = this._data[hash];
3812
3813
  if (!env) {
3813
3814
  return;
3814
3815
  }
3815
3816
  try {
3816
3817
  fs$4.removeSync(env.path);
3817
- delete this._data[hash];
3818
- this.unlink(hash);
3819
- this.unlink(undefined, hash);
3820
- this.syncLinks();
3821
3818
  }
3822
3819
  catch (err) {
3823
3820
  console.error("Failed to remove environment", env.path, err);
3821
+ return;
3824
3822
  }
3823
+ delete this._data[hash];
3824
+ this.unlink(hash)
3825
+ .then(() => this.unlink(undefined, hash))
3826
+ .then(() => this.syncLinks())
3827
+ .catch((err) => {
3828
+ console.error("Failed to unlink environment metadata", env.path, err);
3829
+ });
3825
3830
  }
3826
3831
  }
3827
3832
  Environments.instance = new Environments();
@@ -7703,7 +7708,7 @@ function push(dest, name, elem) {
7703
7708
  * @return {Object} The parsed object
7704
7709
  * @public
7705
7710
  */
7706
- function parse$b(header) {
7711
+ function parse$a(header) {
7707
7712
  const offers = Object.create(null);
7708
7713
 
7709
7714
  if (header === undefined || header === '') return offers;
@@ -7854,7 +7859,7 @@ function parse$b(header) {
7854
7859
  * @return {String} A string representing the given object
7855
7860
  * @public
7856
7861
  */
7857
- function format$4(extensions) {
7862
+ function format$3(extensions) {
7858
7863
  return Object.keys(extensions)
7859
7864
  .map((extension) => {
7860
7865
  let configurations = extensions[extension];
@@ -7878,7 +7883,7 @@ function format$4(extensions) {
7878
7883
  .join(', ');
7879
7884
  }
7880
7885
 
7881
- var extension = { format: format$4, parse: parse$b };
7886
+ var extension = { format: format$3, parse: parse$a };
7882
7887
 
7883
7888
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
7884
7889
 
@@ -7902,7 +7907,7 @@ const {
7902
7907
  NOOP
7903
7908
  } = constants;
7904
7909
  const { addEventListener, removeEventListener } = eventTarget;
7905
- const { format: format$3, parse: parse$a } = extension;
7910
+ const { format: format$2, parse: parse$9 } = extension;
7906
7911
  const { toBuffer } = bufferUtilExports;
7907
7912
 
7908
7913
  const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
@@ -8536,7 +8541,7 @@ function initAsClient(websocket, address, protocols, options) {
8536
8541
  false,
8537
8542
  opts.maxPayload
8538
8543
  );
8539
- opts.headers['Sec-WebSocket-Extensions'] = format$3({
8544
+ opts.headers['Sec-WebSocket-Extensions'] = format$2({
8540
8545
  [PerMessageDeflate$1.extensionName]: perMessageDeflate.offer()
8541
8546
  });
8542
8547
  }
@@ -8727,7 +8732,7 @@ function initAsClient(websocket, address, protocols, options) {
8727
8732
  let extensions;
8728
8733
 
8729
8734
  try {
8730
- extensions = parse$a(secWebSocketExtensions);
8735
+ extensions = parse$9(secWebSocketExtensions);
8731
8736
  } catch (err) {
8732
8737
  const message = 'Invalid Sec-WebSocket-Extensions header';
8733
8738
  abortHandshake$1(websocket, socket, message);
@@ -9262,7 +9267,7 @@ const { createHash } = crypto__default["default"];
9262
9267
 
9263
9268
  const PerMessageDeflate = permessageDeflate;
9264
9269
  const WebSocket$1 = websocket;
9265
- const { format: format$2, parse: parse$9 } = extension;
9270
+ const { format: format$1, parse: parse$8 } = extension;
9266
9271
  const { GUID, kWebSocket } = constants;
9267
9272
 
9268
9273
  const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
@@ -9485,7 +9490,7 @@ class WebSocketServer extends EventEmitter {
9485
9490
  );
9486
9491
 
9487
9492
  try {
9488
- const offers = parse$9(req.headers['sec-websocket-extensions']);
9493
+ const offers = parse$8(req.headers['sec-websocket-extensions']);
9489
9494
 
9490
9495
  if (offers[PerMessageDeflate.extensionName]) {
9491
9496
  perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
@@ -9586,7 +9591,7 @@ class WebSocketServer extends EventEmitter {
9586
9591
 
9587
9592
  if (extensions[PerMessageDeflate.extensionName]) {
9588
9593
  const params = extensions[PerMessageDeflate.extensionName].params;
9589
- const value = format$2({
9594
+ const value = format$1({
9590
9595
  [PerMessageDeflate.extensionName]: [params]
9591
9596
  });
9592
9597
  headers.push(`Sec-WebSocket-Extensions: ${value}`);
@@ -10253,10 +10258,10 @@ function DeprecationError (namespace, message, stack) {
10253
10258
  return error
10254
10259
  }
10255
10260
 
10256
- var bytesExports = {};
10261
+ var bytesExports$1 = {};
10257
10262
  var bytes$1 = {
10258
- get exports(){ return bytesExports; },
10259
- set exports(v){ bytesExports = v; },
10263
+ get exports(){ return bytesExports$1; },
10264
+ set exports(v){ bytesExports$1 = v; },
10260
10265
  };
10261
10266
 
10262
10267
  /*!
@@ -10266,166 +10271,174 @@ var bytes$1 = {
10266
10271
  * MIT Licensed
10267
10272
  */
10268
10273
 
10269
- /**
10270
- * Module exports.
10271
- * @public
10272
- */
10274
+ var hasRequiredBytes;
10273
10275
 
10274
- bytes$1.exports = bytes;
10275
- bytesExports.format = format$1;
10276
- bytesExports.parse = parse$8;
10276
+ function requireBytes () {
10277
+ if (hasRequiredBytes) return bytesExports$1;
10278
+ hasRequiredBytes = 1;
10277
10279
 
10278
- /**
10279
- * Module variables.
10280
- * @private
10281
- */
10280
+ /**
10281
+ * Module exports.
10282
+ * @public
10283
+ */
10282
10284
 
10283
- var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
10285
+ bytes$1.exports = bytes;
10286
+ bytesExports$1.format = format;
10287
+ bytesExports$1.parse = parse;
10284
10288
 
10285
- var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
10289
+ /**
10290
+ * Module variables.
10291
+ * @private
10292
+ */
10286
10293
 
10287
- var map = {
10288
- b: 1,
10289
- kb: 1 << 10,
10290
- mb: 1 << 20,
10291
- gb: 1 << 30,
10292
- tb: Math.pow(1024, 4),
10293
- pb: Math.pow(1024, 5),
10294
- };
10294
+ var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
10295
10295
 
10296
- var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
10296
+ var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
10297
10297
 
10298
- /**
10299
- * Convert the given value in bytes into a string or parse to string to an integer in bytes.
10300
- *
10301
- * @param {string|number} value
10302
- * @param {{
10303
- * case: [string],
10304
- * decimalPlaces: [number]
10305
- * fixedDecimals: [boolean]
10306
- * thousandsSeparator: [string]
10307
- * unitSeparator: [string]
10308
- * }} [options] bytes options.
10309
- *
10310
- * @returns {string|number|null}
10311
- */
10298
+ var map = {
10299
+ b: 1,
10300
+ kb: 1 << 10,
10301
+ mb: 1 << 20,
10302
+ gb: 1 << 30,
10303
+ tb: Math.pow(1024, 4),
10304
+ pb: Math.pow(1024, 5),
10305
+ };
10312
10306
 
10313
- function bytes(value, options) {
10314
- if (typeof value === 'string') {
10315
- return parse$8(value);
10316
- }
10307
+ var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
10317
10308
 
10318
- if (typeof value === 'number') {
10319
- return format$1(value, options);
10320
- }
10309
+ /**
10310
+ * Convert the given value in bytes into a string or parse to string to an integer in bytes.
10311
+ *
10312
+ * @param {string|number} value
10313
+ * @param {{
10314
+ * case: [string],
10315
+ * decimalPlaces: [number]
10316
+ * fixedDecimals: [boolean]
10317
+ * thousandsSeparator: [string]
10318
+ * unitSeparator: [string]
10319
+ * }} [options] bytes options.
10320
+ *
10321
+ * @returns {string|number|null}
10322
+ */
10321
10323
 
10322
- return null;
10323
- }
10324
+ function bytes(value, options) {
10325
+ if (typeof value === 'string') {
10326
+ return parse(value);
10327
+ }
10324
10328
 
10325
- /**
10326
- * Format the given value in bytes into a string.
10327
- *
10328
- * If the value is negative, it is kept as such. If it is a float,
10329
- * it is rounded.
10330
- *
10331
- * @param {number} value
10332
- * @param {object} [options]
10333
- * @param {number} [options.decimalPlaces=2]
10334
- * @param {number} [options.fixedDecimals=false]
10335
- * @param {string} [options.thousandsSeparator=]
10336
- * @param {string} [options.unit=]
10337
- * @param {string} [options.unitSeparator=]
10338
- *
10339
- * @returns {string|null}
10340
- * @public
10341
- */
10329
+ if (typeof value === 'number') {
10330
+ return format(value, options);
10331
+ }
10342
10332
 
10343
- function format$1(value, options) {
10344
- if (!Number.isFinite(value)) {
10345
- return null;
10346
- }
10333
+ return null;
10334
+ }
10347
10335
 
10348
- var mag = Math.abs(value);
10349
- var thousandsSeparator = (options && options.thousandsSeparator) || '';
10350
- var unitSeparator = (options && options.unitSeparator) || '';
10351
- var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
10352
- var fixedDecimals = Boolean(options && options.fixedDecimals);
10353
- var unit = (options && options.unit) || '';
10354
-
10355
- if (!unit || !map[unit.toLowerCase()]) {
10356
- if (mag >= map.pb) {
10357
- unit = 'PB';
10358
- } else if (mag >= map.tb) {
10359
- unit = 'TB';
10360
- } else if (mag >= map.gb) {
10361
- unit = 'GB';
10362
- } else if (mag >= map.mb) {
10363
- unit = 'MB';
10364
- } else if (mag >= map.kb) {
10365
- unit = 'KB';
10366
- } else {
10367
- unit = 'B';
10368
- }
10369
- }
10336
+ /**
10337
+ * Format the given value in bytes into a string.
10338
+ *
10339
+ * If the value is negative, it is kept as such. If it is a float,
10340
+ * it is rounded.
10341
+ *
10342
+ * @param {number} value
10343
+ * @param {object} [options]
10344
+ * @param {number} [options.decimalPlaces=2]
10345
+ * @param {number} [options.fixedDecimals=false]
10346
+ * @param {string} [options.thousandsSeparator=]
10347
+ * @param {string} [options.unit=]
10348
+ * @param {string} [options.unitSeparator=]
10349
+ *
10350
+ * @returns {string|null}
10351
+ * @public
10352
+ */
10370
10353
 
10371
- var val = value / map[unit.toLowerCase()];
10372
- var str = val.toFixed(decimalPlaces);
10354
+ function format(value, options) {
10355
+ if (!Number.isFinite(value)) {
10356
+ return null;
10357
+ }
10373
10358
 
10374
- if (!fixedDecimals) {
10375
- str = str.replace(formatDecimalsRegExp, '$1');
10376
- }
10359
+ var mag = Math.abs(value);
10360
+ var thousandsSeparator = (options && options.thousandsSeparator) || '';
10361
+ var unitSeparator = (options && options.unitSeparator) || '';
10362
+ var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
10363
+ var fixedDecimals = Boolean(options && options.fixedDecimals);
10364
+ var unit = (options && options.unit) || '';
10365
+
10366
+ if (!unit || !map[unit.toLowerCase()]) {
10367
+ if (mag >= map.pb) {
10368
+ unit = 'PB';
10369
+ } else if (mag >= map.tb) {
10370
+ unit = 'TB';
10371
+ } else if (mag >= map.gb) {
10372
+ unit = 'GB';
10373
+ } else if (mag >= map.mb) {
10374
+ unit = 'MB';
10375
+ } else if (mag >= map.kb) {
10376
+ unit = 'KB';
10377
+ } else {
10378
+ unit = 'B';
10379
+ }
10380
+ }
10377
10381
 
10378
- if (thousandsSeparator) {
10379
- str = str.split('.').map(function (s, i) {
10380
- return i === 0
10381
- ? s.replace(formatThousandsRegExp, thousandsSeparator)
10382
- : s
10383
- }).join('.');
10384
- }
10382
+ var val = value / map[unit.toLowerCase()];
10383
+ var str = val.toFixed(decimalPlaces);
10385
10384
 
10386
- return str + unitSeparator + unit;
10387
- }
10385
+ if (!fixedDecimals) {
10386
+ str = str.replace(formatDecimalsRegExp, '$1');
10387
+ }
10388
10388
 
10389
- /**
10390
- * Parse the string value into an integer in bytes.
10391
- *
10392
- * If no unit is given, it is assumed the value is in bytes.
10393
- *
10394
- * @param {number|string} val
10395
- *
10396
- * @returns {number|null}
10397
- * @public
10398
- */
10389
+ if (thousandsSeparator) {
10390
+ str = str.split('.').map(function (s, i) {
10391
+ return i === 0
10392
+ ? s.replace(formatThousandsRegExp, thousandsSeparator)
10393
+ : s
10394
+ }).join('.');
10395
+ }
10399
10396
 
10400
- function parse$8(val) {
10401
- if (typeof val === 'number' && !isNaN(val)) {
10402
- return val;
10403
- }
10397
+ return str + unitSeparator + unit;
10398
+ }
10404
10399
 
10405
- if (typeof val !== 'string') {
10406
- return null;
10407
- }
10400
+ /**
10401
+ * Parse the string value into an integer in bytes.
10402
+ *
10403
+ * If no unit is given, it is assumed the value is in bytes.
10404
+ *
10405
+ * @param {number|string} val
10406
+ *
10407
+ * @returns {number|null}
10408
+ * @public
10409
+ */
10408
10410
 
10409
- // Test if the string passed is valid
10410
- var results = parseRegExp.exec(val);
10411
- var floatValue;
10412
- var unit = 'b';
10411
+ function parse(val) {
10412
+ if (typeof val === 'number' && !isNaN(val)) {
10413
+ return val;
10414
+ }
10413
10415
 
10414
- if (!results) {
10415
- // Nothing could be extracted from the given string
10416
- floatValue = parseInt(val, 10);
10417
- unit = 'b';
10418
- } else {
10419
- // Retrieve the value and the unit
10420
- floatValue = parseFloat(results[1]);
10421
- unit = results[4].toLowerCase();
10422
- }
10416
+ if (typeof val !== 'string') {
10417
+ return null;
10418
+ }
10423
10419
 
10424
- if (isNaN(floatValue)) {
10425
- return null;
10426
- }
10420
+ // Test if the string passed is valid
10421
+ var results = parseRegExp.exec(val);
10422
+ var floatValue;
10423
+ var unit = 'b';
10424
+
10425
+ if (!results) {
10426
+ // Nothing could be extracted from the given string
10427
+ floatValue = parseInt(val, 10);
10428
+ unit = 'b';
10429
+ } else {
10430
+ // Retrieve the value and the unit
10431
+ floatValue = parseFloat(results[1]);
10432
+ unit = results[4].toLowerCase();
10433
+ }
10427
10434
 
10428
- return Math.floor(map[unit] * floatValue);
10435
+ if (isNaN(floatValue)) {
10436
+ return null;
10437
+ }
10438
+
10439
+ return Math.floor(map[unit] * floatValue);
10440
+ }
10441
+ return bytesExports$1;
10429
10442
  }
10430
10443
 
10431
10444
  var contentType = {};
@@ -23595,7 +23608,7 @@ function requireRawBody () {
23595
23608
  */
23596
23609
 
23597
23610
  var asyncHooks = tryRequireAsyncHooks();
23598
- var bytes = bytesExports;
23611
+ var bytes = requireBytes();
23599
23612
  var createError = requireHttpErrors();
23600
23613
  var iconv = requireLib$1();
23601
23614
  var unpipe = requireUnpipe();
@@ -35973,7 +35986,7 @@ function requireJson () {
35973
35986
  * @private
35974
35987
  */
35975
35988
 
35976
- var bytes = bytesExports;
35989
+ var bytes = requireBytes();
35977
35990
  var contentType = requireContentType();
35978
35991
  var createError = requireHttpErrors();
35979
35992
  var debug = requireSrc()('body-parser:json');
@@ -36119,11 +36132,7 @@ function requireJson () {
36119
36132
  var partial = '';
36120
36133
 
36121
36134
  if (index !== -1) {
36122
- partial = str.substring(0, index) + JSON_SYNTAX_CHAR;
36123
-
36124
- for (var i = index + 1; i < str.length; i++) {
36125
- partial += JSON_SYNTAX_CHAR;
36126
- }
36135
+ partial = str.substring(0, index) + new Array(str.length - index + 1).join(JSON_SYNTAX_CHAR);
36127
36136
  }
36128
36137
 
36129
36138
  try {
@@ -36226,7 +36235,7 @@ function requireRaw () {
36226
36235
  * Module dependencies.
36227
36236
  */
36228
36237
 
36229
- var bytes = bytesExports;
36238
+ var bytes = requireBytes();
36230
36239
  var debug = requireSrc()('body-parser:raw');
36231
36240
  var read = requireRead();
36232
36241
  var typeis = requireTypeIs();
@@ -36335,7 +36344,7 @@ function requireText () {
36335
36344
  * Module dependencies.
36336
36345
  */
36337
36346
 
36338
- var bytes = bytesExports;
36347
+ var bytes = requireBytes();
36339
36348
  var contentType = requireContentType();
36340
36349
  var debug = requireSrc()('body-parser:text');
36341
36350
  var read = requireRead();
@@ -38461,7 +38470,7 @@ function requireUtils () {
38461
38470
  var hexTable = (function () {
38462
38471
  var array = [];
38463
38472
  for (var i = 0; i < 256; ++i) {
38464
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
38473
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
38465
38474
  }
38466
38475
 
38467
38476
  return array;
@@ -38477,7 +38486,7 @@ function requireUtils () {
38477
38486
 
38478
38487
  for (var j = 0; j < obj.length; ++j) {
38479
38488
  if (typeof obj[j] !== 'undefined') {
38480
- compacted.push(obj[j]);
38489
+ compacted[compacted.length] = obj[j];
38481
38490
  }
38482
38491
  }
38483
38492
 
@@ -38505,13 +38514,19 @@ function requireUtils () {
38505
38514
 
38506
38515
  if (typeof source !== 'object' && typeof source !== 'function') {
38507
38516
  if (isArray(target)) {
38508
- target.push(source);
38517
+ var nextIndex = target.length;
38518
+ if (options && typeof options.arrayLimit === 'number' && nextIndex > options.arrayLimit) {
38519
+ return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
38520
+ }
38521
+ target[nextIndex] = source;
38509
38522
  } else if (target && typeof target === 'object') {
38510
38523
  if (isOverflow(target)) {
38511
38524
  // Add at next numeric index for overflow objects
38512
38525
  var newIndex = getMaxIndex(target) + 1;
38513
38526
  target[newIndex] = source;
38514
38527
  setMaxIndex(target, newIndex);
38528
+ } else if (options && options.strictMerge) {
38529
+ return [target, source];
38515
38530
  } else if (
38516
38531
  (options && (options.plainObjects || options.allowPrototypes))
38517
38532
  || !has.call(Object.prototype, source)
@@ -38538,7 +38553,11 @@ function requireUtils () {
38538
38553
  }
38539
38554
  return markOverflow(result, getMaxIndex(source) + 1);
38540
38555
  }
38541
- return [target].concat(source);
38556
+ var combined = [target].concat(source);
38557
+ if (options && typeof options.arrayLimit === 'number' && combined.length > options.arrayLimit) {
38558
+ return markOverflow(arrayToObject(combined, options), combined.length - 1);
38559
+ }
38560
+ return combined;
38542
38561
  }
38543
38562
 
38544
38563
  var mergeTarget = target;
@@ -38553,7 +38572,7 @@ function requireUtils () {
38553
38572
  if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
38554
38573
  target[i] = merge(targetItem, item, options);
38555
38574
  } else {
38556
- target.push(item);
38575
+ target[target.length] = item;
38557
38576
  }
38558
38577
  } else {
38559
38578
  target[i] = item;
@@ -38570,6 +38589,17 @@ function requireUtils () {
38570
38589
  } else {
38571
38590
  acc[key] = value;
38572
38591
  }
38592
+
38593
+ if (isOverflow(source) && !isOverflow(acc)) {
38594
+ markOverflow(acc, getMaxIndex(source));
38595
+ }
38596
+ if (isOverflow(acc)) {
38597
+ var keyNum = parseInt(key, 10);
38598
+ if (String(keyNum) === key && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
38599
+ setMaxIndex(acc, keyNum);
38600
+ }
38601
+ }
38602
+
38573
38603
  return acc;
38574
38604
  }, mergeTarget);
38575
38605
  };
@@ -38686,8 +38716,8 @@ function requireUtils () {
38686
38716
  var key = keys[j];
38687
38717
  var val = obj[key];
38688
38718
  if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
38689
- queue.push({ obj: obj, prop: key });
38690
- refs.push(val);
38719
+ queue[queue.length] = { obj: obj, prop: key };
38720
+ refs[refs.length] = val;
38691
38721
  }
38692
38722
  }
38693
38723
  }
@@ -38729,7 +38759,7 @@ function requireUtils () {
38729
38759
  if (isArray(val)) {
38730
38760
  var mapped = [];
38731
38761
  for (var i = 0; i < val.length; i += 1) {
38732
- mapped.push(fn(val[i]));
38762
+ mapped[mapped.length] = fn(val[i]);
38733
38763
  }
38734
38764
  return mapped;
38735
38765
  }
@@ -38746,6 +38776,7 @@ function requireUtils () {
38746
38776
  isBuffer: isBuffer,
38747
38777
  isOverflow: isOverflow,
38748
38778
  isRegExp: isRegExp,
38779
+ markOverflow: markOverflow,
38749
38780
  maybeMap: maybeMap,
38750
38781
  merge: merge
38751
38782
  };
@@ -38877,7 +38908,7 @@ function requireStringify () {
38877
38908
 
38878
38909
  if (obj === null) {
38879
38910
  if (strictNullHandling) {
38880
- return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
38911
+ return formatter(encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix);
38881
38912
  }
38882
38913
 
38883
38914
  obj = '';
@@ -38901,7 +38932,9 @@ function requireStringify () {
38901
38932
  if (generateArrayPrefix === 'comma' && isArray(obj)) {
38902
38933
  // we need to join elements in
38903
38934
  if (encodeValuesOnly && encoder) {
38904
- obj = utils.maybeMap(obj, encoder);
38935
+ obj = utils.maybeMap(obj, function (v) {
38936
+ return v == null ? v : encoder(v);
38937
+ });
38905
38938
  }
38906
38939
  objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
38907
38940
  } else if (isArray(filter)) {
@@ -39071,6 +39104,11 @@ function requireStringify () {
39071
39104
  var sideChannel = getSideChannel();
39072
39105
  for (var i = 0; i < objKeys.length; ++i) {
39073
39106
  var key = objKeys[i];
39107
+
39108
+ if (typeof key === 'undefined' || key === null) {
39109
+ continue;
39110
+ }
39111
+
39074
39112
  var value = obj[key];
39075
39113
 
39076
39114
  if (options.skipNulls && value === null) {
@@ -39104,10 +39142,10 @@ function requireStringify () {
39104
39142
  if (options.charsetSentinel) {
39105
39143
  if (options.charset === 'iso-8859-1') {
39106
39144
  // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
39107
- prefix += 'utf8=%26%2310003%3B&';
39145
+ prefix += 'utf8=%26%2310003%3B' + options.delimiter;
39108
39146
  } else {
39109
39147
  // encodeURIComponent('✓')
39110
- prefix += 'utf8=%E2%9C%93&';
39148
+ prefix += 'utf8=%E2%9C%93' + options.delimiter;
39111
39149
  }
39112
39150
  }
39113
39151
 
@@ -39148,6 +39186,7 @@ function requireParse () {
39148
39186
  parseArrays: true,
39149
39187
  plainObjects: false,
39150
39188
  strictDepth: false,
39189
+ strictMerge: true,
39151
39190
  strictNullHandling: false,
39152
39191
  throwOnLimitExceeded: false
39153
39192
  };
@@ -39186,13 +39225,13 @@ function requireParse () {
39186
39225
  var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
39187
39226
  cleanStr = cleanStr.replace(/%5B/gi, '[').replace(/%5D/gi, ']');
39188
39227
 
39189
- var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
39228
+ var limit = options.parameterLimit === Infinity ? void undefined : options.parameterLimit;
39190
39229
  var parts = cleanStr.split(
39191
39230
  options.delimiter,
39192
- options.throwOnLimitExceeded ? limit + 1 : limit
39231
+ options.throwOnLimitExceeded && typeof limit !== 'undefined' ? limit + 1 : limit
39193
39232
  );
39194
39233
 
39195
- if (options.throwOnLimitExceeded && parts.length > limit) {
39234
+ if (options.throwOnLimitExceeded && typeof limit !== 'undefined' && parts.length > limit) {
39196
39235
  throw new RangeError('Parameter limit exceeded. Only ' + limit + ' parameter' + (limit === 1 ? '' : 's') + ' allowed.');
39197
39236
  }
39198
39237
 
@@ -39253,9 +39292,16 @@ function requireParse () {
39253
39292
  val = isArray(val) ? [val] : val;
39254
39293
  }
39255
39294
 
39295
+ if (options.comma && isArray(val) && val.length > options.arrayLimit) {
39296
+ if (options.throwOnLimitExceeded) {
39297
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
39298
+ }
39299
+ val = utils.combine([], val, options.arrayLimit, options.plainObjects);
39300
+ }
39301
+
39256
39302
  if (key !== null) {
39257
39303
  var existing = has.call(obj, key);
39258
- if (existing && options.duplicates === 'combine') {
39304
+ if (existing && (options.duplicates === 'combine' || part.indexOf('[]=') > -1)) {
39259
39305
  obj[key] = utils.combine(
39260
39306
  obj[key],
39261
39307
  val,
@@ -39303,17 +39349,21 @@ function requireParse () {
39303
39349
  var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
39304
39350
  var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, '.') : cleanRoot;
39305
39351
  var index = parseInt(decodedRoot, 10);
39306
- if (!options.parseArrays && decodedRoot === '') {
39307
- obj = { 0: leaf };
39308
- } else if (
39309
- !isNaN(index)
39352
+ var isValidArrayIndex = !isNaN(index)
39310
39353
  && root !== decodedRoot
39311
39354
  && String(index) === decodedRoot
39312
39355
  && index >= 0
39313
- && (options.parseArrays && index <= options.arrayLimit)
39314
- ) {
39356
+ && options.parseArrays;
39357
+ if (!options.parseArrays && decodedRoot === '') {
39358
+ obj = { 0: leaf };
39359
+ } else if (isValidArrayIndex && index < options.arrayLimit) {
39315
39360
  obj = [];
39316
39361
  obj[index] = leaf;
39362
+ } else if (isValidArrayIndex && options.throwOnLimitExceeded) {
39363
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
39364
+ } else if (isValidArrayIndex) {
39365
+ obj[index] = leaf;
39366
+ utils.markOverflow(obj, index);
39317
39367
  } else if (decodedRoot !== '__proto__') {
39318
39368
  obj[decodedRoot] = leaf;
39319
39369
  }
@@ -39325,9 +39375,12 @@ function requireParse () {
39325
39375
  return leaf;
39326
39376
  };
39327
39377
 
39328
- var splitKeyIntoSegments = function splitKeyIntoSegments(givenKey, options) {
39329
- var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
39378
+ // Split a key like "a[b][c[]]" into ['a', '[b]', '[c[]]'] while preserving
39379
+ // qs parse semantics for depth/prototype guards.
39380
+ var splitKeyIntoSegments = function splitKeyIntoSegments(originalKey, options) {
39381
+ var key = options.allowDots ? originalKey.replace(/\.([^.[]+)/g, '[$1]') : originalKey;
39330
39382
 
39383
+ // depth <= 0 keeps the whole key as one segment
39331
39384
  if (options.depth <= 0) {
39332
39385
  if (!options.plainObjects && has.call(Object.prototype, key)) {
39333
39386
  if (!options.allowPrototypes) {
@@ -39338,14 +39391,11 @@ function requireParse () {
39338
39391
  return [key];
39339
39392
  }
39340
39393
 
39341
- var brackets = /(\[[^[\]]*])/;
39342
- var child = /(\[[^[\]]*])/g;
39343
-
39344
- var segment = brackets.exec(key);
39345
- var parent = segment ? key.slice(0, segment.index) : key;
39346
-
39347
- var keys = [];
39394
+ var segments = [];
39348
39395
 
39396
+ // parent before the first '[' (may be empty if key starts with '[')
39397
+ var first = key.indexOf('[');
39398
+ var parent = first >= 0 ? key.slice(0, first) : key;
39349
39399
  if (parent) {
39350
39400
  if (!options.plainObjects && has.call(Object.prototype, parent)) {
39351
39401
  if (!options.allowPrototypes) {
@@ -39353,32 +39403,62 @@ function requireParse () {
39353
39403
  }
39354
39404
  }
39355
39405
 
39356
- keys.push(parent);
39406
+ segments[segments.length] = parent;
39357
39407
  }
39358
39408
 
39359
- var i = 0;
39360
- while ((segment = child.exec(key)) !== null && i < options.depth) {
39361
- i += 1;
39409
+ var n = key.length;
39410
+ var open = first;
39411
+ var collected = 0;
39362
39412
 
39363
- var segmentContent = segment[1].slice(1, -1);
39364
- if (!options.plainObjects && has.call(Object.prototype, segmentContent)) {
39365
- if (!options.allowPrototypes) {
39366
- return;
39413
+ while (open >= 0 && collected < options.depth) {
39414
+ var level = 1;
39415
+ var i = open + 1;
39416
+ var close = -1;
39417
+
39418
+ // balance nested '[' and ']' inside this bracket group using a nesting level counter
39419
+ while (i < n && close < 0) {
39420
+ var cu = key.charCodeAt(i);
39421
+ if (cu === 0x5B) { // '['
39422
+ level += 1;
39423
+ } else if (cu === 0x5D) { // ']'
39424
+ level -= 1;
39425
+ if (level === 0) {
39426
+ close = i; // found matching close; loop will exit by condition
39427
+ }
39367
39428
  }
39429
+ i += 1;
39430
+ }
39431
+
39432
+ if (close < 0) {
39433
+ // Unterminated group: wrap the raw remainder in one bracket pair so it stays
39434
+ // a single literal segment (e.g. "[[]b" -> "[[]b]"); we do not infer missing ']'.
39435
+ segments[segments.length] = '[' + key.slice(open) + ']';
39436
+ return segments;
39437
+ }
39438
+
39439
+ var seg = key.slice(open, close + 1);
39440
+ // prototype guard for the content of this group
39441
+ var content = seg.slice(1, -1);
39442
+ if (!options.plainObjects && has.call(Object.prototype, content) && !options.allowPrototypes) {
39443
+ return;
39368
39444
  }
39369
39445
 
39370
- keys.push(segment[1]);
39446
+ segments[segments.length] = seg;
39447
+ collected += 1;
39448
+
39449
+ // find the next '[' after this balanced group
39450
+ open = key.indexOf('[', close + 1);
39371
39451
  }
39372
39452
 
39373
- if (segment) {
39453
+ if (open >= 0) {
39374
39454
  if (options.strictDepth === true) {
39375
39455
  throw new RangeError('Input depth exceeded depth option of ' + options.depth + ' and strictDepth is true');
39376
39456
  }
39377
39457
 
39378
- keys.push('[' + key.slice(segment.index) + ']');
39458
+ segments[segments.length] = '[' + key.slice(open) + ']';
39379
39459
  }
39380
39460
 
39381
- return keys;
39461
+ return segments;
39382
39462
  };
39383
39463
 
39384
39464
  var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
@@ -39451,6 +39531,7 @@ function requireParse () {
39451
39531
  parseArrays: opts.parseArrays !== false,
39452
39532
  plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
39453
39533
  strictDepth: typeof opts.strictDepth === 'boolean' ? !!opts.strictDepth : defaults.strictDepth,
39534
+ strictMerge: typeof opts.strictMerge === 'boolean' ? !!opts.strictMerge : defaults.strictMerge,
39454
39535
  strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling,
39455
39536
  throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === 'boolean' ? opts.throwOnLimitExceeded : false
39456
39537
  };
@@ -39522,7 +39603,7 @@ function requireUrlencoded () {
39522
39603
  * @private
39523
39604
  */
39524
39605
 
39525
- var bytes = bytesExports;
39606
+ var bytes = requireBytes();
39526
39607
  var contentType = requireContentType();
39527
39608
  var createError = requireHttpErrors();
39528
39609
  var debug = requireSrc()('body-parser:urlencoded');
@@ -39716,16 +39797,15 @@ function requireUrlencoded () {
39716
39797
 
39717
39798
  function parameterCount (body, limit) {
39718
39799
  var count = 0;
39719
- var index = 0;
39800
+ var index = -1;
39720
39801
 
39721
- while ((index = body.indexOf('&', index)) !== -1) {
39802
+ do {
39722
39803
  count++;
39723
- index++;
39724
-
39725
- if (count === limit) {
39804
+ if (count > limit) {
39726
39805
  return undefined
39727
39806
  }
39728
- }
39807
+ index = body.indexOf('&', index + 1);
39808
+ } while (index !== -1)
39729
39809
 
39730
39810
  return count
39731
39811
  }
@@ -42574,6 +42654,7 @@ function pathToRegexp(path, keys, options) {
42574
42654
  pos = offset + match.length;
42575
42655
 
42576
42656
  if (match === '*') {
42657
+ backtrack = '';
42577
42658
  extraOffset += 3;
42578
42659
  return '(.*)';
42579
42660
  }
@@ -42603,6 +42684,7 @@ function pathToRegexp(path, keys, options) {
42603
42684
  + ')'
42604
42685
  + optional;
42605
42686
 
42687
+ backtrack = '';
42606
42688
  extraOffset += result.length - match.length;
42607
42689
 
42608
42690
  return result;
@@ -51486,7 +51568,8 @@ function trustSingle (subnet) {
51486
51568
 
51487
51569
  function parseExtendedQueryString(str) {
51488
51570
  return qs.parse(str, {
51489
- allowPrototypes: true
51571
+ allowPrototypes: true,
51572
+ arrayLimit: 1000
51490
51573
  });
51491
51574
  }
51492
51575
 
@@ -56399,6 +56482,9 @@ function common$1(option) {
56399
56482
  };
56400
56483
  }
56401
56484
 
56485
+ var bytesExports = requireBytes();
56486
+ var bytes = /*@__PURE__*/getDefaultExportFromCjs(bytesExports);
56487
+
56402
56488
  var compareVersionsExports = {};
56403
56489
  var compareVersions$1 = {
56404
56490
  get exports(){ return compareVersionsExports; },
@@ -58175,7 +58261,7 @@ function purgeEnvironmentsToMaxSize() {
58175
58261
  return new Promise((resolve) => {
58176
58262
  let max = option("max-environment-size");
58177
58263
  if (typeof max === "string") {
58178
- max = bytesExports.parse(max);
58264
+ max = bytes.parse(max);
58179
58265
  }
58180
58266
  else if (typeof max !== "number") {
58181
58267
  max = 0;
@@ -58281,7 +58367,7 @@ function environmentsInfo() {
58281
58367
  const ret = Object.assign({}, Environments.instance.environments);
58282
58368
  ret.maxSize = option("max-environment-size") || 0;
58283
58369
  const max = option("max-environment-size");
58284
- ret.maxSizeBytes = max ? bytesExports.parse(String(max)) || 0 : 0;
58370
+ ret.maxSizeBytes = max ? bytes.parse(String(max)) || 0 : 0;
58285
58371
  let usedSizeBytes = 0;
58286
58372
  for (const hsh in Environments.instance.environments) {
58287
58373
  const env = Environments.instance.environments[hsh];
@@ -58289,7 +58375,7 @@ function environmentsInfo() {
58289
58375
  usedSizeBytes += env.size;
58290
58376
  }
58291
58377
  }
58292
- ret.usedSize = bytesExports.format(usedSizeBytes);
58378
+ ret.usedSize = bytes.format(usedSizeBytes);
58293
58379
  ret.links = Environments.instance.linksInfo();
58294
58380
  ret.usedSizeBytes = usedSizeBytes;
58295
58381
  return ret;
@@ -58415,6 +58501,12 @@ server.on("listen", (app) => {
58415
58501
  rstream.on("error", (err) => {
58416
58502
  console.error("Got read stream error for", env.path, err);
58417
58503
  rstream.close();
58504
+ if (!res.headersSent) {
58505
+ res.sendStatus(500);
58506
+ }
58507
+ else {
58508
+ res.destroy(err);
58509
+ }
58418
58510
  });
58419
58511
  rstream.pipe(res);
58420
58512
  });