@xchainjs/xchain-dash 2.0.8 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -6,7 +6,7 @@ var xchainUtxoProviders = require('@xchainjs/xchain-utxo-providers');
6
6
  var dashcore = require('@dashevo/dashcore-lib');
7
7
  var xchainUtxo = require('@xchainjs/xchain-utxo');
8
8
  var Dash = require('bitcoinjs-lib');
9
- var accumulative = require('coinselect/accumulative');
9
+ var accumulative = require('coinselect/accumulative.js');
10
10
  var ecc = require('@bitcoin-js/tiny-secp256k1-asmjs');
11
11
  var xchainCrypto = require('@xchainjs/xchain-crypto');
12
12
  var bip32 = require('@scure/bip32');
@@ -33,7 +33,7 @@ function _interopNamespace(e) {
33
33
  return Object.freeze(n);
34
34
  }
35
35
 
36
- var dashcore__namespace = /*#__PURE__*/_interopNamespace(dashcore);
36
+ var dashcore__default = /*#__PURE__*/_interopDefault(dashcore);
37
37
  var Dash__namespace = /*#__PURE__*/_interopNamespace(Dash);
38
38
  var accumulative__default = /*#__PURE__*/_interopDefault(accumulative);
39
39
  var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);
@@ -150,6 +150,13 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
150
150
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
151
151
  };
152
152
 
153
+ /**
154
+ * Create a bound version of a function with a specified `this` context
155
+ *
156
+ * @param {Function} fn - The function to bind
157
+ * @param {*} thisArg - The value to be passed as the `this` parameter
158
+ * @returns {Function} A new function that will call the original function with the specified `this` context
159
+ */
153
160
  function bind(fn, thisArg) {
154
161
  return function wrap() {
155
162
  return fn.apply(thisArg, arguments);
@@ -158,29 +165,30 @@ function bind(fn, thisArg) {
158
165
 
159
166
  // utils is a library of generic helper functions non-specific to axios
160
167
 
161
- const {toString} = Object.prototype;
162
- const {getPrototypeOf} = Object;
168
+ const { toString } = Object.prototype;
169
+ const { getPrototypeOf } = Object;
170
+ const { iterator, toStringTag } = Symbol;
163
171
 
164
- const kindOf = (cache => thing => {
165
- const str = toString.call(thing);
166
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
172
+ const kindOf = ((cache) => (thing) => {
173
+ const str = toString.call(thing);
174
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
167
175
  })(Object.create(null));
168
176
 
169
177
  const kindOfTest = (type) => {
170
178
  type = type.toLowerCase();
171
- return (thing) => kindOf(thing) === type
179
+ return (thing) => kindOf(thing) === type;
172
180
  };
173
181
 
174
- const typeOfTest = type => thing => typeof thing === type;
182
+ const typeOfTest = (type) => (thing) => typeof thing === type;
175
183
 
176
184
  /**
177
- * Determine if a value is an Array
185
+ * Determine if a value is a non-null object
178
186
  *
179
187
  * @param {Object} val The value to test
180
188
  *
181
189
  * @returns {boolean} True if value is an Array, otherwise false
182
190
  */
183
- const {isArray} = Array;
191
+ const { isArray } = Array;
184
192
 
185
193
  /**
186
194
  * Determine if a value is undefined
@@ -189,7 +197,7 @@ const {isArray} = Array;
189
197
  *
190
198
  * @returns {boolean} True if the value is undefined, otherwise false
191
199
  */
192
- const isUndefined = typeOfTest('undefined');
200
+ const isUndefined = typeOfTest("undefined");
193
201
 
194
202
  /**
195
203
  * Determine if a value is a Buffer
@@ -199,8 +207,14 @@ const isUndefined = typeOfTest('undefined');
199
207
  * @returns {boolean} True if value is a Buffer, otherwise false
200
208
  */
201
209
  function isBuffer(val) {
202
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
203
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
210
+ return (
211
+ val !== null &&
212
+ !isUndefined(val) &&
213
+ val.constructor !== null &&
214
+ !isUndefined(val.constructor) &&
215
+ isFunction$1(val.constructor.isBuffer) &&
216
+ val.constructor.isBuffer(val)
217
+ );
204
218
  }
205
219
 
206
220
  /**
@@ -210,8 +224,7 @@ function isBuffer(val) {
210
224
  *
211
225
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
212
226
  */
213
- const isArrayBuffer = kindOfTest('ArrayBuffer');
214
-
227
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
215
228
 
216
229
  /**
217
230
  * Determine if a value is a view on an ArrayBuffer
@@ -222,10 +235,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
222
235
  */
223
236
  function isArrayBufferView(val) {
224
237
  let result;
225
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
238
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
226
239
  result = ArrayBuffer.isView(val);
227
240
  } else {
228
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
241
+ result = val && val.buffer && isArrayBuffer(val.buffer);
229
242
  }
230
243
  return result;
231
244
  }
@@ -237,7 +250,7 @@ function isArrayBufferView(val) {
237
250
  *
238
251
  * @returns {boolean} True if value is a String, otherwise false
239
252
  */
240
- const isString = typeOfTest('string');
253
+ const isString = typeOfTest("string");
241
254
 
242
255
  /**
243
256
  * Determine if a value is a Function
@@ -245,7 +258,7 @@ const isString = typeOfTest('string');
245
258
  * @param {*} val The value to test
246
259
  * @returns {boolean} True if value is a Function, otherwise false
247
260
  */
248
- const isFunction = typeOfTest('function');
261
+ const isFunction$1 = typeOfTest("function");
249
262
 
250
263
  /**
251
264
  * Determine if a value is a Number
@@ -254,7 +267,7 @@ const isFunction = typeOfTest('function');
254
267
  *
255
268
  * @returns {boolean} True if value is a Number, otherwise false
256
269
  */
257
- const isNumber = typeOfTest('number');
270
+ const isNumber = typeOfTest("number");
258
271
 
259
272
  /**
260
273
  * Determine if a value is an Object
@@ -263,7 +276,7 @@ const isNumber = typeOfTest('number');
263
276
  *
264
277
  * @returns {boolean} True if value is an Object, otherwise false
265
278
  */
266
- const isObject = (thing) => thing !== null && typeof thing === 'object';
279
+ const isObject = (thing) => thing !== null && typeof thing === "object";
267
280
 
268
281
  /**
269
282
  * Determine if a value is a Boolean
@@ -271,7 +284,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
271
284
  * @param {*} thing The value to test
272
285
  * @returns {boolean} True if value is a Boolean, otherwise false
273
286
  */
274
- const isBoolean = thing => thing === true || thing === false;
287
+ const isBoolean = (thing) => thing === true || thing === false;
275
288
 
276
289
  /**
277
290
  * Determine if a value is a plain Object
@@ -281,12 +294,42 @@ const isBoolean = thing => thing === true || thing === false;
281
294
  * @returns {boolean} True if value is a plain Object, otherwise false
282
295
  */
283
296
  const isPlainObject = (val) => {
284
- if (kindOf(val) !== 'object') {
297
+ if (kindOf(val) !== "object") {
285
298
  return false;
286
299
  }
287
300
 
288
301
  const prototype = getPrototypeOf(val);
289
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
302
+ return (
303
+ (prototype === null ||
304
+ prototype === Object.prototype ||
305
+ Object.getPrototypeOf(prototype) === null) &&
306
+ !(toStringTag in val) &&
307
+ !(iterator in val)
308
+ );
309
+ };
310
+
311
+ /**
312
+ * Determine if a value is an empty object (safely handles Buffers)
313
+ *
314
+ * @param {*} val The value to test
315
+ *
316
+ * @returns {boolean} True if value is an empty object, otherwise false
317
+ */
318
+ const isEmptyObject = (val) => {
319
+ // Early return for non-objects or Buffers to prevent RangeError
320
+ if (!isObject(val) || isBuffer(val)) {
321
+ return false;
322
+ }
323
+
324
+ try {
325
+ return (
326
+ Object.keys(val).length === 0 &&
327
+ Object.getPrototypeOf(val) === Object.prototype
328
+ );
329
+ } catch (e) {
330
+ // Fallback for any other objects that might cause RangeError with Object.keys()
331
+ return false;
332
+ }
290
333
  };
291
334
 
292
335
  /**
@@ -296,7 +339,7 @@ const isPlainObject = (val) => {
296
339
  *
297
340
  * @returns {boolean} True if value is a Date, otherwise false
298
341
  */
299
- const isDate = kindOfTest('Date');
342
+ const isDate = kindOfTest("Date");
300
343
 
301
344
  /**
302
345
  * Determine if a value is a File
@@ -305,7 +348,7 @@ const isDate = kindOfTest('Date');
305
348
  *
306
349
  * @returns {boolean} True if value is a File, otherwise false
307
350
  */
308
- const isFile = kindOfTest('File');
351
+ const isFile = kindOfTest("File");
309
352
 
310
353
  /**
311
354
  * Determine if a value is a Blob
@@ -314,7 +357,7 @@ const isFile = kindOfTest('File');
314
357
  *
315
358
  * @returns {boolean} True if value is a Blob, otherwise false
316
359
  */
317
- const isBlob = kindOfTest('Blob');
360
+ const isBlob = kindOfTest("Blob");
318
361
 
319
362
  /**
320
363
  * Determine if a value is a FileList
@@ -323,7 +366,7 @@ const isBlob = kindOfTest('Blob');
323
366
  *
324
367
  * @returns {boolean} True if value is a File, otherwise false
325
368
  */
326
- const isFileList = kindOfTest('FileList');
369
+ const isFileList = kindOfTest("FileList");
327
370
 
328
371
  /**
329
372
  * Determine if a value is a Stream
@@ -332,7 +375,7 @@ const isFileList = kindOfTest('FileList');
332
375
  *
333
376
  * @returns {boolean} True if value is a Stream, otherwise false
334
377
  */
335
- const isStream = (val) => isObject(val) && isFunction(val.pipe);
378
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
336
379
 
337
380
  /**
338
381
  * Determine if a value is a FormData
@@ -343,15 +386,16 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
343
386
  */
344
387
  const isFormData = (thing) => {
345
388
  let kind;
346
- return thing && (
347
- (typeof FormData === 'function' && thing instanceof FormData) || (
348
- isFunction(thing.append) && (
349
- (kind = kindOf(thing)) === 'formdata' ||
350
- // detect form-data instance
351
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
352
- )
353
- )
354
- )
389
+ return (
390
+ thing &&
391
+ ((typeof FormData === "function" && thing instanceof FormData) ||
392
+ (isFunction$1(thing.append) &&
393
+ ((kind = kindOf(thing)) === "formdata" ||
394
+ // detect form-data instance
395
+ (kind === "object" &&
396
+ isFunction$1(thing.toString) &&
397
+ thing.toString() === "[object FormData]"))))
398
+ );
355
399
  };
356
400
 
357
401
  /**
@@ -361,9 +405,14 @@ const isFormData = (thing) => {
361
405
  *
362
406
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
363
407
  */
364
- const isURLSearchParams = kindOfTest('URLSearchParams');
408
+ const isURLSearchParams = kindOfTest("URLSearchParams");
365
409
 
366
- const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
410
+ const [isReadableStream, isRequest, isResponse, isHeaders] = [
411
+ "ReadableStream",
412
+ "Request",
413
+ "Response",
414
+ "Headers",
415
+ ].map(kindOfTest);
367
416
 
368
417
  /**
369
418
  * Trim excess whitespace off the beginning and end of a string
@@ -372,8 +421,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
372
421
  *
373
422
  * @returns {String} The String freed of excess whitespace
374
423
  */
375
- const trim = (str) => str.trim ?
376
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
424
+ const trim = (str) =>
425
+ str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
377
426
 
378
427
  /**
379
428
  * Iterate over an Array or an Object invoking a function for each item.
@@ -384,15 +433,16 @@ const trim = (str) => str.trim ?
384
433
  * If 'obj' is an Object callback will be called passing
385
434
  * the value, key, and complete object for each property.
386
435
  *
387
- * @param {Object|Array} obj The object to iterate
436
+ * @param {Object|Array<unknown>} obj The object to iterate
388
437
  * @param {Function} fn The callback to invoke for each item
389
438
  *
390
- * @param {Boolean} [allOwnKeys = false]
439
+ * @param {Object} [options]
440
+ * @param {Boolean} [options.allOwnKeys = false]
391
441
  * @returns {any}
392
442
  */
393
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
443
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
394
444
  // Don't bother if no value provided
395
- if (obj === null || typeof obj === 'undefined') {
445
+ if (obj === null || typeof obj === "undefined") {
396
446
  return;
397
447
  }
398
448
 
@@ -400,7 +450,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
400
450
  let l;
401
451
 
402
452
  // Force an array if not already something iterable
403
- if (typeof obj !== 'object') {
453
+ if (typeof obj !== "object") {
404
454
  /*eslint no-param-reassign:0*/
405
455
  obj = [obj];
406
456
  }
@@ -411,8 +461,15 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
411
461
  fn.call(null, obj[i], i, obj);
412
462
  }
413
463
  } else {
464
+ // Buffer check
465
+ if (isBuffer(obj)) {
466
+ return;
467
+ }
468
+
414
469
  // Iterate over object keys
415
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
470
+ const keys = allOwnKeys
471
+ ? Object.getOwnPropertyNames(obj)
472
+ : Object.keys(obj);
416
473
  const len = keys.length;
417
474
  let key;
418
475
 
@@ -424,6 +481,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
424
481
  }
425
482
 
426
483
  function findKey(obj, key) {
484
+ if (isBuffer(obj)) {
485
+ return null;
486
+ }
487
+
427
488
  key = key.toLowerCase();
428
489
  const keys = Object.keys(obj);
429
490
  let i = keys.length;
@@ -440,10 +501,15 @@ function findKey(obj, key) {
440
501
  const _global = (() => {
441
502
  /*eslint no-undef:0*/
442
503
  if (typeof globalThis !== "undefined") return globalThis;
443
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
504
+ return typeof self !== "undefined"
505
+ ? self
506
+ : typeof window !== "undefined"
507
+ ? window
508
+ : global;
444
509
  })();
445
510
 
446
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
511
+ const isContextDefined = (context) =>
512
+ !isUndefined(context) && context !== _global;
447
513
 
448
514
  /**
449
515
  * Accepts varargs expecting each argument to be an object, then
@@ -455,7 +521,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
455
521
  * Example:
456
522
  *
457
523
  * ```js
458
- * var result = merge({foo: 123}, {foo: 456});
524
+ * const result = merge({foo: 123}, {foo: 456});
459
525
  * console.log(result.foo); // outputs 456
460
526
  * ```
461
527
  *
@@ -464,17 +530,22 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
464
530
  * @returns {Object} Result of all merge properties
465
531
  */
466
532
  function merge(/* obj1, obj2, obj3, ... */) {
467
- const {caseless} = isContextDefined(this) && this || {};
533
+ const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
468
534
  const result = {};
469
535
  const assignValue = (val, key) => {
470
- const targetKey = caseless && findKey(result, key) || key;
536
+ // Skip dangerous property names to prevent prototype pollution
537
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
538
+ return;
539
+ }
540
+
541
+ const targetKey = (caseless && findKey(result, key)) || key;
471
542
  if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
472
543
  result[targetKey] = merge(result[targetKey], val);
473
544
  } else if (isPlainObject(val)) {
474
545
  result[targetKey] = merge({}, val);
475
546
  } else if (isArray(val)) {
476
547
  result[targetKey] = val.slice();
477
- } else {
548
+ } else if (!skipUndefined || !isUndefined(val)) {
478
549
  result[targetKey] = val;
479
550
  }
480
551
  };
@@ -492,17 +563,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
492
563
  * @param {Object} b The object to copy properties from
493
564
  * @param {Object} thisArg The object to bind function to
494
565
  *
495
- * @param {Boolean} [allOwnKeys]
566
+ * @param {Object} [options]
567
+ * @param {Boolean} [options.allOwnKeys]
496
568
  * @returns {Object} The resulting value of object a
497
569
  */
498
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
499
- forEach(b, (val, key) => {
500
- if (thisArg && isFunction(val)) {
501
- a[key] = bind(val, thisArg);
502
- } else {
503
- a[key] = val;
504
- }
505
- }, {allOwnKeys});
570
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
571
+ forEach(
572
+ b,
573
+ (val, key) => {
574
+ if (thisArg && isFunction$1(val)) {
575
+ Object.defineProperty(a, key, {
576
+ value: bind(val, thisArg),
577
+ writable: true,
578
+ enumerable: true,
579
+ configurable: true,
580
+ });
581
+ } else {
582
+ Object.defineProperty(a, key, {
583
+ value: val,
584
+ writable: true,
585
+ enumerable: true,
586
+ configurable: true,
587
+ });
588
+ }
589
+ },
590
+ { allOwnKeys },
591
+ );
506
592
  return a;
507
593
  };
508
594
 
@@ -514,7 +600,7 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
514
600
  * @returns {string} content value without BOM
515
601
  */
516
602
  const stripBOM = (content) => {
517
- if (content.charCodeAt(0) === 0xFEFF) {
603
+ if (content.charCodeAt(0) === 0xfeff) {
518
604
  content = content.slice(1);
519
605
  }
520
606
  return content;
@@ -530,10 +616,18 @@ const stripBOM = (content) => {
530
616
  * @returns {void}
531
617
  */
532
618
  const inherits = (constructor, superConstructor, props, descriptors) => {
533
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
534
- constructor.prototype.constructor = constructor;
535
- Object.defineProperty(constructor, 'super', {
536
- value: superConstructor.prototype
619
+ constructor.prototype = Object.create(
620
+ superConstructor.prototype,
621
+ descriptors,
622
+ );
623
+ Object.defineProperty(constructor.prototype, "constructor", {
624
+ value: constructor,
625
+ writable: true,
626
+ enumerable: false,
627
+ configurable: true,
628
+ });
629
+ Object.defineProperty(constructor, "super", {
630
+ value: superConstructor.prototype,
537
631
  });
538
632
  props && Object.assign(constructor.prototype, props);
539
633
  };
@@ -562,13 +656,20 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
562
656
  i = props.length;
563
657
  while (i-- > 0) {
564
658
  prop = props[i];
565
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
659
+ if (
660
+ (!propFilter || propFilter(prop, sourceObj, destObj)) &&
661
+ !merged[prop]
662
+ ) {
566
663
  destObj[prop] = sourceObj[prop];
567
664
  merged[prop] = true;
568
665
  }
569
666
  }
570
667
  sourceObj = filter !== false && getPrototypeOf(sourceObj);
571
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
668
+ } while (
669
+ sourceObj &&
670
+ (!filter || filter(sourceObj, destObj)) &&
671
+ sourceObj !== Object.prototype
672
+ );
572
673
 
573
674
  return destObj;
574
675
  };
@@ -592,7 +693,6 @@ const endsWith = (str, searchString, position) => {
592
693
  return lastIndex !== -1 && lastIndex === position;
593
694
  };
594
695
 
595
-
596
696
  /**
597
697
  * Returns new array from array like object or null if failed
598
698
  *
@@ -621,12 +721,12 @@ const toArray = (thing) => {
621
721
  * @returns {Array}
622
722
  */
623
723
  // eslint-disable-next-line func-names
624
- const isTypedArray = (TypedArray => {
724
+ const isTypedArray = ((TypedArray) => {
625
725
  // eslint-disable-next-line func-names
626
- return thing => {
726
+ return (thing) => {
627
727
  return TypedArray && thing instanceof TypedArray;
628
728
  };
629
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
729
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
630
730
 
631
731
  /**
632
732
  * For each entry in the object, call the function with the key and value.
@@ -637,13 +737,13 @@ const isTypedArray = (TypedArray => {
637
737
  * @returns {void}
638
738
  */
639
739
  const forEachEntry = (obj, fn) => {
640
- const generator = obj && obj[Symbol.iterator];
740
+ const generator = obj && obj[iterator];
641
741
 
642
- const iterator = generator.call(obj);
742
+ const _iterator = generator.call(obj);
643
743
 
644
744
  let result;
645
745
 
646
- while ((result = iterator.next()) && !result.done) {
746
+ while ((result = _iterator.next()) && !result.done) {
647
747
  const pair = result.value;
648
748
  fn.call(obj, pair[0], pair[1]);
649
749
  }
@@ -669,18 +769,22 @@ const matchAll = (regExp, str) => {
669
769
  };
670
770
 
671
771
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
672
- const isHTMLForm = kindOfTest('HTMLFormElement');
772
+ const isHTMLForm = kindOfTest("HTMLFormElement");
673
773
 
674
- const toCamelCase = str => {
675
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
676
- function replacer(m, p1, p2) {
774
+ const toCamelCase = (str) => {
775
+ return str
776
+ .toLowerCase()
777
+ .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
677
778
  return p1.toUpperCase() + p2;
678
- }
679
- );
779
+ });
680
780
  };
681
781
 
682
782
  /* Creating a function that will check if an object has a property. */
683
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
783
+ const hasOwnProperty = (
784
+ ({ hasOwnProperty }) =>
785
+ (obj, prop) =>
786
+ hasOwnProperty.call(obj, prop)
787
+ )(Object.prototype);
684
788
 
685
789
  /**
686
790
  * Determine if a value is a RegExp object
@@ -689,7 +793,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
689
793
  *
690
794
  * @returns {boolean} True if value is a RegExp object, otherwise false
691
795
  */
692
- const isRegExp = kindOfTest('RegExp');
796
+ const isRegExp = kindOfTest("RegExp");
693
797
 
694
798
  const reduceDescriptors = (obj, reducer) => {
695
799
  const descriptors = Object.getOwnPropertyDescriptors(obj);
@@ -713,24 +817,27 @@ const reduceDescriptors = (obj, reducer) => {
713
817
  const freezeMethods = (obj) => {
714
818
  reduceDescriptors(obj, (descriptor, name) => {
715
819
  // skip restricted props in strict mode
716
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
820
+ if (
821
+ isFunction$1(obj) &&
822
+ ["arguments", "caller", "callee"].indexOf(name) !== -1
823
+ ) {
717
824
  return false;
718
825
  }
719
826
 
720
827
  const value = obj[name];
721
828
 
722
- if (!isFunction(value)) return;
829
+ if (!isFunction$1(value)) return;
723
830
 
724
831
  descriptor.enumerable = false;
725
832
 
726
- if ('writable' in descriptor) {
833
+ if ("writable" in descriptor) {
727
834
  descriptor.writable = false;
728
835
  return;
729
836
  }
730
837
 
731
838
  if (!descriptor.set) {
732
839
  descriptor.set = () => {
733
- throw Error('Can not rewrite read-only method \'' + name + '\'');
840
+ throw Error("Can not rewrite read-only method '" + name + "'");
734
841
  };
735
842
  }
736
843
  });
@@ -740,12 +847,14 @@ const toObjectSet = (arrayOrString, delimiter) => {
740
847
  const obj = {};
741
848
 
742
849
  const define = (arr) => {
743
- arr.forEach(value => {
850
+ arr.forEach((value) => {
744
851
  obj[value] = true;
745
852
  });
746
853
  };
747
854
 
748
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
855
+ isArray(arrayOrString)
856
+ ? define(arrayOrString)
857
+ : define(String(arrayOrString).split(delimiter));
749
858
 
750
859
  return obj;
751
860
  };
@@ -753,7 +862,9 @@ const toObjectSet = (arrayOrString, delimiter) => {
753
862
  const noop = () => {};
754
863
 
755
864
  const toFiniteNumber = (value, defaultValue) => {
756
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
865
+ return value != null && Number.isFinite((value = +value))
866
+ ? value
867
+ : defaultValue;
757
868
  };
758
869
 
759
870
  /**
@@ -764,20 +875,29 @@ const toFiniteNumber = (value, defaultValue) => {
764
875
  * @returns {boolean}
765
876
  */
766
877
  function isSpecCompliantForm(thing) {
767
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
878
+ return !!(
879
+ thing &&
880
+ isFunction$1(thing.append) &&
881
+ thing[toStringTag] === "FormData" &&
882
+ thing[iterator]
883
+ );
768
884
  }
769
885
 
770
886
  const toJSONObject = (obj) => {
771
887
  const stack = new Array(10);
772
888
 
773
889
  const visit = (source, i) => {
774
-
775
890
  if (isObject(source)) {
776
891
  if (stack.indexOf(source) >= 0) {
777
892
  return;
778
893
  }
779
894
 
780
- if(!('toJSON' in source)) {
895
+ //Buffer check
896
+ if (isBuffer(source)) {
897
+ return source;
898
+ }
899
+
900
+ if (!("toJSON" in source)) {
781
901
  stack[i] = source;
782
902
  const target = isArray(source) ? [] : {};
783
903
 
@@ -798,10 +918,13 @@ const toJSONObject = (obj) => {
798
918
  return visit(obj, 0);
799
919
  };
800
920
 
801
- const isAsyncFn = kindOfTest('AsyncFunction');
921
+ const isAsyncFn = kindOfTest("AsyncFunction");
802
922
 
803
923
  const isThenable = (thing) =>
804
- thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
924
+ thing &&
925
+ (isObject(thing) || isFunction$1(thing)) &&
926
+ isFunction$1(thing.then) &&
927
+ isFunction$1(thing.catch);
805
928
 
806
929
  // original code
807
930
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -811,28 +934,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
811
934
  return setImmediate;
812
935
  }
813
936
 
814
- return postMessageSupported ? ((token, callbacks) => {
815
- _global.addEventListener("message", ({source, data}) => {
816
- if (source === _global && data === token) {
817
- callbacks.length && callbacks.shift()();
818
- }
819
- }, false);
937
+ return postMessageSupported
938
+ ? ((token, callbacks) => {
939
+ _global.addEventListener(
940
+ "message",
941
+ ({ source, data }) => {
942
+ if (source === _global && data === token) {
943
+ callbacks.length && callbacks.shift()();
944
+ }
945
+ },
946
+ false,
947
+ );
820
948
 
821
- return (cb) => {
822
- callbacks.push(cb);
823
- _global.postMessage(token, "*");
824
- }
825
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
826
- })(
827
- typeof setImmediate === 'function',
828
- isFunction(_global.postMessage)
829
- );
949
+ return (cb) => {
950
+ callbacks.push(cb);
951
+ _global.postMessage(token, "*");
952
+ };
953
+ })(`axios@${Math.random()}`, [])
954
+ : (cb) => setTimeout(cb);
955
+ })(typeof setImmediate === "function", isFunction$1(_global.postMessage));
830
956
 
831
- const asap = typeof queueMicrotask !== 'undefined' ?
832
- queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
957
+ const asap =
958
+ typeof queueMicrotask !== "undefined"
959
+ ? queueMicrotask.bind(_global)
960
+ : (typeof process !== "undefined" && process.nextTick) || _setImmediate;
833
961
 
834
962
  // *********************
835
963
 
964
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
965
+
836
966
  var utils$1 = {
837
967
  isArray,
838
968
  isArrayBuffer,
@@ -844,6 +974,7 @@ var utils$1 = {
844
974
  isBoolean,
845
975
  isObject,
846
976
  isPlainObject,
977
+ isEmptyObject,
847
978
  isReadableStream,
848
979
  isRequest,
849
980
  isResponse,
@@ -853,7 +984,7 @@ var utils$1 = {
853
984
  isFile,
854
985
  isBlob,
855
986
  isRegExp,
856
- isFunction,
987
+ isFunction: isFunction$1,
857
988
  isStream,
858
989
  isURLSearchParams,
859
990
  isTypedArray,
@@ -888,106 +1019,77 @@ var utils$1 = {
888
1019
  isAsyncFn,
889
1020
  isThenable,
890
1021
  setImmediate: _setImmediate,
891
- asap
1022
+ asap,
1023
+ isIterable,
892
1024
  };
893
1025
 
894
- /**
895
- * Create an Error with the specified message, config, error code, request and response.
896
- *
897
- * @param {string} message The error message.
898
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
899
- * @param {Object} [config] The config.
900
- * @param {Object} [request] The request.
901
- * @param {Object} [response] The response.
902
- *
903
- * @returns {Error} The created error.
904
- */
905
- function AxiosError(message, code, config, request, response) {
906
- Error.call(this);
1026
+ class AxiosError extends Error {
1027
+ static from(error, code, config, request, response, customProps) {
1028
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1029
+ axiosError.cause = error;
1030
+ axiosError.name = error.name;
1031
+ customProps && Object.assign(axiosError, customProps);
1032
+ return axiosError;
1033
+ }
907
1034
 
908
- if (Error.captureStackTrace) {
909
- Error.captureStackTrace(this, this.constructor);
910
- } else {
911
- this.stack = (new Error()).stack;
912
- }
1035
+ /**
1036
+ * Create an Error with the specified message, config, error code, request and response.
1037
+ *
1038
+ * @param {string} message The error message.
1039
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1040
+ * @param {Object} [config] The config.
1041
+ * @param {Object} [request] The request.
1042
+ * @param {Object} [response] The response.
1043
+ *
1044
+ * @returns {Error} The created error.
1045
+ */
1046
+ constructor(message, code, config, request, response) {
1047
+ super(message);
1048
+ this.name = 'AxiosError';
1049
+ this.isAxiosError = true;
1050
+ code && (this.code = code);
1051
+ config && (this.config = config);
1052
+ request && (this.request = request);
1053
+ if (response) {
1054
+ this.response = response;
1055
+ this.status = response.status;
1056
+ }
1057
+ }
913
1058
 
914
- this.message = message;
915
- this.name = 'AxiosError';
916
- code && (this.code = code);
917
- config && (this.config = config);
918
- request && (this.request = request);
919
- if (response) {
920
- this.response = response;
921
- this.status = response.status ? response.status : null;
922
- }
1059
+ toJSON() {
1060
+ return {
1061
+ // Standard
1062
+ message: this.message,
1063
+ name: this.name,
1064
+ // Microsoft
1065
+ description: this.description,
1066
+ number: this.number,
1067
+ // Mozilla
1068
+ fileName: this.fileName,
1069
+ lineNumber: this.lineNumber,
1070
+ columnNumber: this.columnNumber,
1071
+ stack: this.stack,
1072
+ // Axios
1073
+ config: utils$1.toJSONObject(this.config),
1074
+ code: this.code,
1075
+ status: this.status,
1076
+ };
1077
+ }
923
1078
  }
924
1079
 
925
- utils$1.inherits(AxiosError, Error, {
926
- toJSON: function toJSON() {
927
- return {
928
- // Standard
929
- message: this.message,
930
- name: this.name,
931
- // Microsoft
932
- description: this.description,
933
- number: this.number,
934
- // Mozilla
935
- fileName: this.fileName,
936
- lineNumber: this.lineNumber,
937
- columnNumber: this.columnNumber,
938
- stack: this.stack,
939
- // Axios
940
- config: utils$1.toJSONObject(this.config),
941
- code: this.code,
942
- status: this.status
943
- };
944
- }
945
- });
946
-
947
- const prototype$1 = AxiosError.prototype;
948
- const descriptors = {};
949
-
950
- [
951
- 'ERR_BAD_OPTION_VALUE',
952
- 'ERR_BAD_OPTION',
953
- 'ECONNABORTED',
954
- 'ETIMEDOUT',
955
- 'ERR_NETWORK',
956
- 'ERR_FR_TOO_MANY_REDIRECTS',
957
- 'ERR_DEPRECATED',
958
- 'ERR_BAD_RESPONSE',
959
- 'ERR_BAD_REQUEST',
960
- 'ERR_CANCELED',
961
- 'ERR_NOT_SUPPORT',
962
- 'ERR_INVALID_URL'
963
- // eslint-disable-next-line func-names
964
- ].forEach(code => {
965
- descriptors[code] = {value: code};
966
- });
967
-
968
- Object.defineProperties(AxiosError, descriptors);
969
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
970
-
971
- // eslint-disable-next-line func-names
972
- AxiosError.from = (error, code, config, request, response, customProps) => {
973
- const axiosError = Object.create(prototype$1);
974
-
975
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
976
- return obj !== Error.prototype;
977
- }, prop => {
978
- return prop !== 'isAxiosError';
979
- });
980
-
981
- AxiosError.call(axiosError, error.message, code, config, request, response);
982
-
983
- axiosError.cause = error;
984
-
985
- axiosError.name = error.name;
986
-
987
- customProps && Object.assign(axiosError, customProps);
988
-
989
- return axiosError;
990
- };
1080
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1081
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1082
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1083
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
1084
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1085
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1086
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1087
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1088
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1089
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1090
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1091
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1092
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
991
1093
 
992
1094
  // eslint-disable-next-line strict
993
1095
  var httpAdapter = null;
@@ -1107,6 +1209,10 @@ function toFormData(obj, formData, options) {
1107
1209
  return value.toISOString();
1108
1210
  }
1109
1211
 
1212
+ if (utils$1.isBoolean(value)) {
1213
+ return value.toString();
1214
+ }
1215
+
1110
1216
  if (!useBlob && utils$1.isBlob(value)) {
1111
1217
  throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1112
1218
  }
@@ -1269,9 +1375,7 @@ function encode(val) {
1269
1375
  replace(/%3A/gi, ':').
1270
1376
  replace(/%24/g, '$').
1271
1377
  replace(/%2C/gi, ',').
1272
- replace(/%20/g, '+').
1273
- replace(/%5B/gi, '[').
1274
- replace(/%5D/gi, ']');
1378
+ replace(/%20/g, '+');
1275
1379
  }
1276
1380
 
1277
1381
  /**
@@ -1284,29 +1388,26 @@ function encode(val) {
1284
1388
  * @returns {string} The formatted url
1285
1389
  */
1286
1390
  function buildURL(url, params, options) {
1287
- /*eslint no-param-reassign:0*/
1288
1391
  if (!params) {
1289
1392
  return url;
1290
1393
  }
1291
-
1394
+
1292
1395
  const _encode = options && options.encode || encode;
1293
1396
 
1294
- if (utils$1.isFunction(options)) {
1295
- options = {
1296
- serialize: options
1297
- };
1298
- }
1397
+ const _options = utils$1.isFunction(options) ? {
1398
+ serialize: options
1399
+ } : options;
1299
1400
 
1300
- const serializeFn = options && options.serialize;
1401
+ const serializeFn = _options && _options.serialize;
1301
1402
 
1302
1403
  let serializedParams;
1303
1404
 
1304
1405
  if (serializeFn) {
1305
- serializedParams = serializeFn(params, options);
1406
+ serializedParams = serializeFn(params, _options);
1306
1407
  } else {
1307
1408
  serializedParams = utils$1.isURLSearchParams(params) ?
1308
1409
  params.toString() :
1309
- new AxiosURLSearchParams(params, options).toString(_encode);
1410
+ new AxiosURLSearchParams(params, _options).toString(_encode);
1310
1411
  }
1311
1412
 
1312
1413
  if (serializedParams) {
@@ -1331,6 +1432,7 @@ class InterceptorManager {
1331
1432
  *
1332
1433
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
1333
1434
  * @param {Function} rejected The function to handle `reject` for a `Promise`
1435
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
1334
1436
  *
1335
1437
  * @return {Number} An ID used to remove interceptor later
1336
1438
  */
@@ -1349,7 +1451,7 @@ class InterceptorManager {
1349
1451
  *
1350
1452
  * @param {Number} id The ID that was returned by `use`
1351
1453
  *
1352
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1454
+ * @returns {void}
1353
1455
  */
1354
1456
  eject(id) {
1355
1457
  if (this.handlers[id]) {
@@ -1390,7 +1492,8 @@ class InterceptorManager {
1390
1492
  var transitionalDefaults = {
1391
1493
  silentJSONParsing: true,
1392
1494
  forcedJSONParsing: true,
1393
- clarifyTimeoutError: false
1495
+ clarifyTimeoutError: false,
1496
+ legacyInterceptorReqResOrdering: true
1394
1497
  };
1395
1498
 
1396
1499
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -1468,7 +1571,7 @@ var platform = {
1468
1571
  };
1469
1572
 
1470
1573
  function toURLEncodedForm(data, options) {
1471
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1574
+ return toFormData(data, new platform.classes.URLSearchParams(), {
1472
1575
  visitor: function(value, key, path, helpers) {
1473
1576
  if (platform.isNode && utils$1.isBuffer(value)) {
1474
1577
  this.append(key, value.toString('base64'));
@@ -1476,8 +1579,9 @@ function toURLEncodedForm(data, options) {
1476
1579
  }
1477
1580
 
1478
1581
  return helpers.defaultVisitor.apply(this, arguments);
1479
- }
1480
- }, options));
1582
+ },
1583
+ ...options
1584
+ });
1481
1585
  }
1482
1586
 
1483
1587
  /**
@@ -1673,7 +1777,7 @@ const defaults = {
1673
1777
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
1674
1778
 
1675
1779
  try {
1676
- return JSON.parse(data);
1780
+ return JSON.parse(data, this.parseReviver);
1677
1781
  } catch (e) {
1678
1782
  if (strictJSONParsing) {
1679
1783
  if (e.name === 'SyntaxError') {
@@ -1869,10 +1973,18 @@ class AxiosHeaders {
1869
1973
  setHeaders(header, valueOrRewrite);
1870
1974
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1871
1975
  setHeaders(parseHeaders(header), valueOrRewrite);
1872
- } else if (utils$1.isHeaders(header)) {
1873
- for (const [key, value] of header.entries()) {
1874
- setHeader(value, key, rewrite);
1976
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1977
+ let obj = {}, dest, key;
1978
+ for (const entry of header) {
1979
+ if (!utils$1.isArray(entry)) {
1980
+ throw TypeError('Object iterator must return a key-value pair');
1981
+ }
1982
+
1983
+ obj[key = entry[0]] = (dest = obj[key]) ?
1984
+ (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
1875
1985
  }
1986
+
1987
+ setHeaders(obj, valueOrRewrite);
1876
1988
  } else {
1877
1989
  header != null && setHeader(valueOrRewrite, header, rewrite);
1878
1990
  }
@@ -2014,6 +2126,10 @@ class AxiosHeaders {
2014
2126
  return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
2015
2127
  }
2016
2128
 
2129
+ getSetCookie() {
2130
+ return this.get("set-cookie") || [];
2131
+ }
2132
+
2017
2133
  get [Symbol.toStringTag]() {
2018
2134
  return 'AxiosHeaders';
2019
2135
  }
@@ -2095,25 +2211,23 @@ function isCancel(value) {
2095
2211
  return !!(value && value.__CANCEL__);
2096
2212
  }
2097
2213
 
2098
- /**
2099
- * A `CanceledError` is an object that is thrown when an operation is canceled.
2100
- *
2101
- * @param {string=} message The message.
2102
- * @param {Object=} config The config.
2103
- * @param {Object=} request The request.
2104
- *
2105
- * @returns {CanceledError} The created error.
2106
- */
2107
- function CanceledError(message, config, request) {
2108
- // eslint-disable-next-line no-eq-null,eqeqeq
2109
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2110
- this.name = 'CanceledError';
2214
+ class CanceledError extends AxiosError {
2215
+ /**
2216
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2217
+ *
2218
+ * @param {string=} message The message.
2219
+ * @param {Object=} config The config.
2220
+ * @param {Object=} request The request.
2221
+ *
2222
+ * @returns {CanceledError} The created error.
2223
+ */
2224
+ constructor(message, config, request) {
2225
+ super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2226
+ this.name = 'CanceledError';
2227
+ this.__CANCEL__ = true;
2228
+ }
2111
2229
  }
2112
2230
 
2113
- utils$1.inherits(CanceledError, AxiosError, {
2114
- __CANCEL__: true
2115
- });
2116
-
2117
2231
  /**
2118
2232
  * Resolve or reject a Promise based on response status.
2119
2233
  *
@@ -2214,7 +2328,7 @@ function throttle(fn, freq) {
2214
2328
  clearTimeout(timer);
2215
2329
  timer = null;
2216
2330
  }
2217
- fn.apply(null, args);
2331
+ fn(...args);
2218
2332
  };
2219
2333
 
2220
2334
  const throttled = (...args) => {
@@ -2296,27 +2410,38 @@ var cookies = platform.hasStandardBrowserEnv ?
2296
2410
 
2297
2411
  // Standard browser envs support document.cookie
2298
2412
  {
2299
- write(name, value, expires, path, domain, secure) {
2300
- const cookie = [name + '=' + encodeURIComponent(value)];
2301
-
2302
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2303
-
2304
- utils$1.isString(path) && cookie.push('path=' + path);
2413
+ write(name, value, expires, path, domain, secure, sameSite) {
2414
+ if (typeof document === 'undefined') return;
2305
2415
 
2306
- utils$1.isString(domain) && cookie.push('domain=' + domain);
2416
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2307
2417
 
2308
- secure === true && cookie.push('secure');
2418
+ if (utils$1.isNumber(expires)) {
2419
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
2420
+ }
2421
+ if (utils$1.isString(path)) {
2422
+ cookie.push(`path=${path}`);
2423
+ }
2424
+ if (utils$1.isString(domain)) {
2425
+ cookie.push(`domain=${domain}`);
2426
+ }
2427
+ if (secure === true) {
2428
+ cookie.push('secure');
2429
+ }
2430
+ if (utils$1.isString(sameSite)) {
2431
+ cookie.push(`SameSite=${sameSite}`);
2432
+ }
2309
2433
 
2310
2434
  document.cookie = cookie.join('; ');
2311
2435
  },
2312
2436
 
2313
2437
  read(name) {
2314
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2315
- return (match ? decodeURIComponent(match[3]) : null);
2438
+ if (typeof document === 'undefined') return null;
2439
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2440
+ return match ? decodeURIComponent(match[1]) : null;
2316
2441
  },
2317
2442
 
2318
2443
  remove(name) {
2319
- this.write(name, '', Date.now() - 86400000);
2444
+ this.write(name, '', Date.now() - 86400000, '/');
2320
2445
  }
2321
2446
  }
2322
2447
 
@@ -2342,6 +2467,10 @@ function isAbsoluteURL(url) {
2342
2467
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2343
2468
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2344
2469
  // by any combination of letters, digits, plus, period, or hyphen.
2470
+ if (typeof url !== 'string') {
2471
+ return false;
2472
+ }
2473
+
2345
2474
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2346
2475
  }
2347
2476
 
@@ -2377,7 +2506,8 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2377
2506
  return requestedURL;
2378
2507
  }
2379
2508
 
2380
- const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
2509
+ const headersToObject = (thing) =>
2510
+ thing instanceof AxiosHeaders ? { ...thing } : thing;
2381
2511
 
2382
2512
  /**
2383
2513
  * Config-specific merge-function which creates a new config-object
@@ -2395,7 +2525,7 @@ function mergeConfig(config1, config2) {
2395
2525
 
2396
2526
  function getMergedValue(target, source, prop, caseless) {
2397
2527
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2398
- return utils$1.merge.call({caseless}, target, source);
2528
+ return utils$1.merge.call({ caseless }, target, source);
2399
2529
  } else if (utils$1.isPlainObject(source)) {
2400
2530
  return utils$1.merge({}, source);
2401
2531
  } else if (utils$1.isArray(source)) {
@@ -2404,12 +2534,11 @@ function mergeConfig(config1, config2) {
2404
2534
  return source;
2405
2535
  }
2406
2536
 
2407
- // eslint-disable-next-line consistent-return
2408
- function mergeDeepProperties(a, b, prop , caseless) {
2537
+ function mergeDeepProperties(a, b, prop, caseless) {
2409
2538
  if (!utils$1.isUndefined(b)) {
2410
- return getMergedValue(a, b, prop , caseless);
2539
+ return getMergedValue(a, b, prop, caseless);
2411
2540
  } else if (!utils$1.isUndefined(a)) {
2412
- return getMergedValue(undefined, a, prop , caseless);
2541
+ return getMergedValue(undefined, a, prop, caseless);
2413
2542
  }
2414
2543
  }
2415
2544
 
@@ -2467,14 +2596,27 @@ function mergeConfig(config1, config2) {
2467
2596
  socketPath: defaultToConfig2,
2468
2597
  responseEncoding: defaultToConfig2,
2469
2598
  validateStatus: mergeDirectKeys,
2470
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2599
+ headers: (a, b, prop) =>
2600
+ mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
2471
2601
  };
2472
2602
 
2473
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2474
- const merge = mergeMap[prop] || mergeDeepProperties;
2475
- const configValue = merge(config1[prop], config2[prop], prop);
2476
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2477
- });
2603
+ utils$1.forEach(
2604
+ Object.keys({ ...config1, ...config2 }),
2605
+ function computeConfigValue(prop) {
2606
+ if (
2607
+ prop === "__proto__" ||
2608
+ prop === "constructor" ||
2609
+ prop === "prototype"
2610
+ )
2611
+ return;
2612
+ const merge = utils$1.hasOwnProp(mergeMap, prop)
2613
+ ? mergeMap[prop]
2614
+ : mergeDeepProperties;
2615
+ const configValue = merge(config1[prop], config2[prop], prop);
2616
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
2617
+ (config[prop] = configValue);
2618
+ },
2619
+ );
2478
2620
 
2479
2621
  return config;
2480
2622
  }
@@ -2482,7 +2624,7 @@ function mergeConfig(config1, config2) {
2482
2624
  var resolveConfig = (config) => {
2483
2625
  const newConfig = mergeConfig({}, config);
2484
2626
 
2485
- let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
2627
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2486
2628
 
2487
2629
  newConfig.headers = headers = AxiosHeaders.from(headers);
2488
2630
 
@@ -2495,17 +2637,21 @@ var resolveConfig = (config) => {
2495
2637
  );
2496
2638
  }
2497
2639
 
2498
- let contentType;
2499
-
2500
2640
  if (utils$1.isFormData(data)) {
2501
2641
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2502
- headers.setContentType(undefined); // Let the browser set it
2503
- } else if ((contentType = headers.getContentType()) !== false) {
2504
- // fix semicolon duplication issue for ReactNative FormData implementation
2505
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2506
- headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2642
+ headers.setContentType(undefined); // browser handles it
2643
+ } else if (utils$1.isFunction(data.getHeaders)) {
2644
+ // Node.js FormData (like form-data package)
2645
+ const formHeaders = data.getHeaders();
2646
+ // Only set safe headers to avoid overwriting security headers
2647
+ const allowedHeaders = ['content-type', 'content-length'];
2648
+ Object.entries(formHeaders).forEach(([key, val]) => {
2649
+ if (allowedHeaders.includes(key.toLowerCase())) {
2650
+ headers.set(key, val);
2651
+ }
2652
+ });
2507
2653
  }
2508
- }
2654
+ }
2509
2655
 
2510
2656
  // Add xsrf header
2511
2657
  // This is only done if running in a standard browser environment.
@@ -2622,15 +2768,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2622
2768
  };
2623
2769
 
2624
2770
  // Handle low level network errors
2625
- request.onerror = function handleError() {
2626
- // Real errors are hidden from us by the browser
2627
- // onerror should only fire if it's a network error
2628
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2629
-
2630
- // Clean up request
2631
- request = null;
2771
+ request.onerror = function handleError(event) {
2772
+ // Browsers deliver a ProgressEvent in XHR onerror
2773
+ // (message may be empty; when present, surface it)
2774
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2775
+ const msg = event && event.message ? event.message : 'Network Error';
2776
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
2777
+ // attach the underlying event for consumers who want details
2778
+ err.event = event || null;
2779
+ reject(err);
2780
+ request = null;
2632
2781
  };
2633
-
2782
+
2634
2783
  // Handle timeout
2635
2784
  request.ontimeout = function handleTimeout() {
2636
2785
  let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
@@ -2733,7 +2882,7 @@ const composeSignals = (signals, timeout) => {
2733
2882
 
2734
2883
  let timer = timeout && setTimeout(() => {
2735
2884
  timer = null;
2736
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2885
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
2737
2886
  }, timeout);
2738
2887
 
2739
2888
  const unsubscribe = () => {
@@ -2844,14 +2993,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2844
2993
  })
2845
2994
  };
2846
2995
 
2847
- const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
2848
- const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
2996
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2997
+
2998
+ const {isFunction} = utils$1;
2999
+
3000
+ const globalFetchAPI = (({Request, Response}) => ({
3001
+ Request, Response
3002
+ }))(utils$1.global);
3003
+
3004
+ const {
3005
+ ReadableStream: ReadableStream$1, TextEncoder
3006
+ } = utils$1.global;
2849
3007
 
2850
- // used only inside the fetch adapter
2851
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2852
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2853
- async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2854
- );
2855
3008
 
2856
3009
  const test = (fn, ...args) => {
2857
3010
  try {
@@ -2861,278 +3014,380 @@ const test = (fn, ...args) => {
2861
3014
  }
2862
3015
  };
2863
3016
 
2864
- const supportsRequestStream = isReadableStreamSupported && test(() => {
2865
- let duplexAccessed = false;
3017
+ const factory = (env) => {
3018
+ env = utils$1.merge.call({
3019
+ skipUndefined: true
3020
+ }, globalFetchAPI, env);
2866
3021
 
2867
- const hasContentType = new Request(platform.origin, {
2868
- body: new ReadableStream(),
2869
- method: 'POST',
2870
- get duplex() {
2871
- duplexAccessed = true;
2872
- return 'half';
2873
- },
2874
- }).headers.has('Content-Type');
3022
+ const {fetch: envFetch, Request, Response} = env;
3023
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
3024
+ const isRequestSupported = isFunction(Request);
3025
+ const isResponseSupported = isFunction(Response);
2875
3026
 
2876
- return duplexAccessed && !hasContentType;
2877
- });
3027
+ if (!isFetchSupported) {
3028
+ return false;
3029
+ }
2878
3030
 
2879
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
3031
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
2880
3032
 
2881
- const supportsResponseStream = isReadableStreamSupported &&
2882
- test(() => utils$1.isReadableStream(new Response('').body));
3033
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3034
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3035
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
3036
+ );
2883
3037
 
3038
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3039
+ let duplexAccessed = false;
2884
3040
 
2885
- const resolvers = {
2886
- stream: supportsResponseStream && ((res) => res.body)
2887
- };
3041
+ const hasContentType = new Request(platform.origin, {
3042
+ body: new ReadableStream$1(),
3043
+ method: 'POST',
3044
+ get duplex() {
3045
+ duplexAccessed = true;
3046
+ return 'half';
3047
+ },
3048
+ }).headers.has('Content-Type');
2888
3049
 
2889
- isFetchSupported && (((res) => {
2890
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2891
- !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
2892
- (_, config) => {
2893
- throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2894
- });
3050
+ return duplexAccessed && !hasContentType;
2895
3051
  });
2896
- })(new Response));
2897
3052
 
2898
- const getBodyLength = async (body) => {
2899
- if (body == null) {
2900
- return 0;
2901
- }
3053
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
3054
+ test(() => utils$1.isReadableStream(new Response('').body));
2902
3055
 
2903
- if(utils$1.isBlob(body)) {
2904
- return body.size;
2905
- }
3056
+ const resolvers = {
3057
+ stream: supportsResponseStream && ((res) => res.body)
3058
+ };
2906
3059
 
2907
- if(utils$1.isSpecCompliantForm(body)) {
2908
- const _request = new Request(platform.origin, {
2909
- method: 'POST',
2910
- body,
3060
+ isFetchSupported && ((() => {
3061
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3062
+ !resolvers[type] && (resolvers[type] = (res, config) => {
3063
+ let method = res && res[type];
3064
+
3065
+ if (method) {
3066
+ return method.call(res);
3067
+ }
3068
+
3069
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
3070
+ });
2911
3071
  });
2912
- return (await _request.arrayBuffer()).byteLength;
2913
- }
3072
+ })());
2914
3073
 
2915
- if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2916
- return body.byteLength;
2917
- }
3074
+ const getBodyLength = async (body) => {
3075
+ if (body == null) {
3076
+ return 0;
3077
+ }
2918
3078
 
2919
- if(utils$1.isURLSearchParams(body)) {
2920
- body = body + '';
2921
- }
3079
+ if (utils$1.isBlob(body)) {
3080
+ return body.size;
3081
+ }
2922
3082
 
2923
- if(utils$1.isString(body)) {
2924
- return (await encodeText(body)).byteLength;
2925
- }
2926
- };
3083
+ if (utils$1.isSpecCompliantForm(body)) {
3084
+ const _request = new Request(platform.origin, {
3085
+ method: 'POST',
3086
+ body,
3087
+ });
3088
+ return (await _request.arrayBuffer()).byteLength;
3089
+ }
2927
3090
 
2928
- const resolveBodyLength = async (headers, body) => {
2929
- const length = utils$1.toFiniteNumber(headers.getContentLength());
3091
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3092
+ return body.byteLength;
3093
+ }
2930
3094
 
2931
- return length == null ? getBodyLength(body) : length;
2932
- };
3095
+ if (utils$1.isURLSearchParams(body)) {
3096
+ body = body + '';
3097
+ }
3098
+
3099
+ if (utils$1.isString(body)) {
3100
+ return (await encodeText(body)).byteLength;
3101
+ }
3102
+ };
3103
+
3104
+ const resolveBodyLength = async (headers, body) => {
3105
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3106
+
3107
+ return length == null ? getBodyLength(body) : length;
3108
+ };
3109
+
3110
+ return async (config) => {
3111
+ let {
3112
+ url,
3113
+ method,
3114
+ data,
3115
+ signal,
3116
+ cancelToken,
3117
+ timeout,
3118
+ onDownloadProgress,
3119
+ onUploadProgress,
3120
+ responseType,
3121
+ headers,
3122
+ withCredentials = 'same-origin',
3123
+ fetchOptions
3124
+ } = resolveConfig(config);
3125
+
3126
+ let _fetch = envFetch || fetch;
3127
+
3128
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3129
+
3130
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3131
+
3132
+ let request = null;
2933
3133
 
2934
- var fetchAdapter = isFetchSupported && (async (config) => {
2935
- let {
2936
- url,
2937
- method,
2938
- data,
2939
- signal,
2940
- cancelToken,
2941
- timeout,
2942
- onDownloadProgress,
2943
- onUploadProgress,
2944
- responseType,
2945
- headers,
2946
- withCredentials = 'same-origin',
2947
- fetchOptions
2948
- } = resolveConfig(config);
2949
-
2950
- responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2951
-
2952
- let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2953
-
2954
- let request;
2955
-
2956
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3134
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2957
3135
  composedSignal.unsubscribe();
2958
- });
3136
+ });
2959
3137
 
2960
- let requestContentLength;
3138
+ let requestContentLength;
2961
3139
 
2962
- try {
2963
- if (
2964
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2965
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2966
- ) {
2967
- let _request = new Request(url, {
2968
- method: 'POST',
2969
- body: data,
2970
- duplex: "half"
2971
- });
3140
+ try {
3141
+ if (
3142
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3143
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3144
+ ) {
3145
+ let _request = new Request(url, {
3146
+ method: 'POST',
3147
+ body: data,
3148
+ duplex: "half"
3149
+ });
2972
3150
 
2973
- let contentTypeHeader;
3151
+ let contentTypeHeader;
2974
3152
 
2975
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2976
- headers.setContentType(contentTypeHeader);
2977
- }
3153
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3154
+ headers.setContentType(contentTypeHeader);
3155
+ }
2978
3156
 
2979
- if (_request.body) {
2980
- const [onProgress, flush] = progressEventDecorator(
2981
- requestContentLength,
2982
- progressEventReducer(asyncDecorator(onUploadProgress))
2983
- );
3157
+ if (_request.body) {
3158
+ const [onProgress, flush] = progressEventDecorator(
3159
+ requestContentLength,
3160
+ progressEventReducer(asyncDecorator(onUploadProgress))
3161
+ );
2984
3162
 
2985
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3163
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3164
+ }
2986
3165
  }
2987
- }
2988
3166
 
2989
- if (!utils$1.isString(withCredentials)) {
2990
- withCredentials = withCredentials ? 'include' : 'omit';
2991
- }
3167
+ if (!utils$1.isString(withCredentials)) {
3168
+ withCredentials = withCredentials ? 'include' : 'omit';
3169
+ }
2992
3170
 
2993
- // Cloudflare Workers throws when credentials are defined
2994
- // see https://github.com/cloudflare/workerd/issues/902
2995
- const isCredentialsSupported = "credentials" in Request.prototype;
2996
- request = new Request(url, {
2997
- ...fetchOptions,
2998
- signal: composedSignal,
2999
- method: method.toUpperCase(),
3000
- headers: headers.normalize().toJSON(),
3001
- body: data,
3002
- duplex: "half",
3003
- credentials: isCredentialsSupported ? withCredentials : undefined
3004
- });
3171
+ // Cloudflare Workers throws when credentials are defined
3172
+ // see https://github.com/cloudflare/workerd/issues/902
3173
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3005
3174
 
3006
- let response = await fetch(request);
3175
+ const resolvedOptions = {
3176
+ ...fetchOptions,
3177
+ signal: composedSignal,
3178
+ method: method.toUpperCase(),
3179
+ headers: headers.normalize().toJSON(),
3180
+ body: data,
3181
+ duplex: "half",
3182
+ credentials: isCredentialsSupported ? withCredentials : undefined
3183
+ };
3007
3184
 
3008
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3185
+ request = isRequestSupported && new Request(url, resolvedOptions);
3009
3186
 
3010
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3011
- const options = {};
3187
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
3012
3188
 
3013
- ['status', 'statusText', 'headers'].forEach(prop => {
3014
- options[prop] = response[prop];
3015
- });
3189
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3016
3190
 
3017
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3191
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3192
+ const options = {};
3018
3193
 
3019
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3020
- responseContentLength,
3021
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
3022
- ) || [];
3194
+ ['status', 'statusText', 'headers'].forEach(prop => {
3195
+ options[prop] = response[prop];
3196
+ });
3023
3197
 
3024
- response = new Response(
3025
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3026
- flush && flush();
3027
- unsubscribe && unsubscribe();
3028
- }),
3029
- options
3030
- );
3031
- }
3198
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3032
3199
 
3033
- responseType = responseType || 'text';
3200
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3201
+ responseContentLength,
3202
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3203
+ ) || [];
3034
3204
 
3035
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3205
+ response = new Response(
3206
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3207
+ flush && flush();
3208
+ unsubscribe && unsubscribe();
3209
+ }),
3210
+ options
3211
+ );
3212
+ }
3036
3213
 
3037
- !isStreamResponse && unsubscribe && unsubscribe();
3214
+ responseType = responseType || 'text';
3038
3215
 
3039
- return await new Promise((resolve, reject) => {
3040
- settle(resolve, reject, {
3041
- data: responseData,
3042
- headers: AxiosHeaders.from(response.headers),
3043
- status: response.status,
3044
- statusText: response.statusText,
3045
- config,
3046
- request
3047
- });
3048
- })
3049
- } catch (err) {
3050
- unsubscribe && unsubscribe();
3216
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3051
3217
 
3052
- if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3053
- throw Object.assign(
3054
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3055
- {
3056
- cause: err.cause || err
3057
- }
3058
- )
3218
+ !isStreamResponse && unsubscribe && unsubscribe();
3219
+
3220
+ return await new Promise((resolve, reject) => {
3221
+ settle(resolve, reject, {
3222
+ data: responseData,
3223
+ headers: AxiosHeaders.from(response.headers),
3224
+ status: response.status,
3225
+ statusText: response.statusText,
3226
+ config,
3227
+ request
3228
+ });
3229
+ })
3230
+ } catch (err) {
3231
+ unsubscribe && unsubscribe();
3232
+
3233
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3234
+ throw Object.assign(
3235
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
3236
+ {
3237
+ cause: err.cause || err
3238
+ }
3239
+ )
3240
+ }
3241
+
3242
+ throw AxiosError.from(err, err && err.code, config, request, err && err.response);
3059
3243
  }
3244
+ }
3245
+ };
3246
+
3247
+ const seedCache = new Map();
3248
+
3249
+ const getFetch = (config) => {
3250
+ let env = (config && config.env) || {};
3251
+ const {fetch, Request, Response} = env;
3252
+ const seeds = [
3253
+ Request, Response, fetch
3254
+ ];
3255
+
3256
+ let len = seeds.length, i = len,
3257
+ seed, target, map = seedCache;
3258
+
3259
+ while (i--) {
3260
+ seed = seeds[i];
3261
+ target = map.get(seed);
3060
3262
 
3061
- throw AxiosError.from(err, err && err.code, config, request);
3263
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3264
+
3265
+ map = target;
3062
3266
  }
3063
- });
3064
3267
 
3268
+ return target;
3269
+ };
3270
+
3271
+ getFetch();
3272
+
3273
+ /**
3274
+ * Known adapters mapping.
3275
+ * Provides environment-specific adapters for Axios:
3276
+ * - `http` for Node.js
3277
+ * - `xhr` for browsers
3278
+ * - `fetch` for fetch API-based requests
3279
+ *
3280
+ * @type {Object<string, Function|Object>}
3281
+ */
3065
3282
  const knownAdapters = {
3066
3283
  http: httpAdapter,
3067
3284
  xhr: xhrAdapter,
3068
- fetch: fetchAdapter
3285
+ fetch: {
3286
+ get: getFetch,
3287
+ }
3069
3288
  };
3070
3289
 
3290
+ // Assign adapter names for easier debugging and identification
3071
3291
  utils$1.forEach(knownAdapters, (fn, value) => {
3072
3292
  if (fn) {
3073
3293
  try {
3074
- Object.defineProperty(fn, 'name', {value});
3294
+ Object.defineProperty(fn, 'name', { value });
3075
3295
  } catch (e) {
3076
3296
  // eslint-disable-next-line no-empty
3077
3297
  }
3078
- Object.defineProperty(fn, 'adapterName', {value});
3298
+ Object.defineProperty(fn, 'adapterName', { value });
3079
3299
  }
3080
3300
  });
3081
3301
 
3302
+ /**
3303
+ * Render a rejection reason string for unknown or unsupported adapters
3304
+ *
3305
+ * @param {string} reason
3306
+ * @returns {string}
3307
+ */
3082
3308
  const renderReason = (reason) => `- ${reason}`;
3083
3309
 
3310
+ /**
3311
+ * Check if the adapter is resolved (function, null, or false)
3312
+ *
3313
+ * @param {Function|null|false} adapter
3314
+ * @returns {boolean}
3315
+ */
3084
3316
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3085
3317
 
3086
- var adapters = {
3087
- getAdapter: (adapters) => {
3088
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3089
-
3090
- const {length} = adapters;
3091
- let nameOrAdapter;
3092
- let adapter;
3318
+ /**
3319
+ * Get the first suitable adapter from the provided list.
3320
+ * Tries each adapter in order until a supported one is found.
3321
+ * Throws an AxiosError if no adapter is suitable.
3322
+ *
3323
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
3324
+ * @param {Object} config - Axios request configuration
3325
+ * @throws {AxiosError} If no suitable adapter is available
3326
+ * @returns {Function} The resolved adapter function
3327
+ */
3328
+ function getAdapter(adapters, config) {
3329
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3093
3330
 
3094
- const rejectedReasons = {};
3331
+ const { length } = adapters;
3332
+ let nameOrAdapter;
3333
+ let adapter;
3095
3334
 
3096
- for (let i = 0; i < length; i++) {
3097
- nameOrAdapter = adapters[i];
3098
- let id;
3335
+ const rejectedReasons = {};
3099
3336
 
3100
- adapter = nameOrAdapter;
3337
+ for (let i = 0; i < length; i++) {
3338
+ nameOrAdapter = adapters[i];
3339
+ let id;
3101
3340
 
3102
- if (!isResolvedHandle(nameOrAdapter)) {
3103
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3341
+ adapter = nameOrAdapter;
3104
3342
 
3105
- if (adapter === undefined) {
3106
- throw new AxiosError(`Unknown adapter '${id}'`);
3107
- }
3108
- }
3343
+ if (!isResolvedHandle(nameOrAdapter)) {
3344
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3109
3345
 
3110
- if (adapter) {
3111
- break;
3346
+ if (adapter === undefined) {
3347
+ throw new AxiosError(`Unknown adapter '${id}'`);
3112
3348
  }
3349
+ }
3113
3350
 
3114
- rejectedReasons[id || '#' + i] = adapter;
3351
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3352
+ break;
3115
3353
  }
3116
3354
 
3117
- if (!adapter) {
3355
+ rejectedReasons[id || '#' + i] = adapter;
3356
+ }
3118
3357
 
3119
- const reasons = Object.entries(rejectedReasons)
3120
- .map(([id, state]) => `adapter ${id} ` +
3121
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
3122
- );
3358
+ if (!adapter) {
3359
+ const reasons = Object.entries(rejectedReasons)
3360
+ .map(([id, state]) => `adapter ${id} ` +
3361
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3362
+ );
3123
3363
 
3124
- let s = length ?
3125
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3126
- 'as no adapter specified';
3364
+ let s = length ?
3365
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3366
+ 'as no adapter specified';
3127
3367
 
3128
- throw new AxiosError(
3129
- `There is no suitable adapter to dispatch the request ` + s,
3130
- 'ERR_NOT_SUPPORT'
3131
- );
3132
- }
3368
+ throw new AxiosError(
3369
+ `There is no suitable adapter to dispatch the request ` + s,
3370
+ 'ERR_NOT_SUPPORT'
3371
+ );
3372
+ }
3133
3373
 
3134
- return adapter;
3135
- },
3374
+ return adapter;
3375
+ }
3376
+
3377
+ /**
3378
+ * Exports Axios adapters and utility to resolve an adapter
3379
+ */
3380
+ var adapters = {
3381
+ /**
3382
+ * Resolve an adapter from a list of adapter names or functions.
3383
+ * @type {Function}
3384
+ */
3385
+ getAdapter,
3386
+
3387
+ /**
3388
+ * Exposes all known adapters
3389
+ * @type {Object<string, Function|Object>}
3390
+ */
3136
3391
  adapters: knownAdapters
3137
3392
  };
3138
3393
 
@@ -3175,7 +3430,7 @@ function dispatchRequest(config) {
3175
3430
  config.headers.setContentType('application/x-www-form-urlencoded', false);
3176
3431
  }
3177
3432
 
3178
- const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
3433
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
3179
3434
 
3180
3435
  return adapter(config).then(function onAdapterResolution(response) {
3181
3436
  throwIfCancellationRequested(config);
@@ -3209,7 +3464,7 @@ function dispatchRequest(config) {
3209
3464
  });
3210
3465
  }
3211
3466
 
3212
- const VERSION = "1.8.4";
3467
+ const VERSION = "1.13.5";
3213
3468
 
3214
3469
  const validators$1 = {};
3215
3470
 
@@ -3317,7 +3572,7 @@ const validators = validator.validators;
3317
3572
  */
3318
3573
  class Axios {
3319
3574
  constructor(instanceConfig) {
3320
- this.defaults = instanceConfig;
3575
+ this.defaults = instanceConfig || {};
3321
3576
  this.interceptors = {
3322
3577
  request: new InterceptorManager(),
3323
3578
  response: new InterceptorManager()
@@ -3377,7 +3632,8 @@ class Axios {
3377
3632
  validator.assertOptions(transitional, {
3378
3633
  silentJSONParsing: validators.transitional(validators.boolean),
3379
3634
  forcedJSONParsing: validators.transitional(validators.boolean),
3380
- clarifyTimeoutError: validators.transitional(validators.boolean)
3635
+ clarifyTimeoutError: validators.transitional(validators.boolean),
3636
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
3381
3637
  }, false);
3382
3638
  }
3383
3639
 
@@ -3434,7 +3690,14 @@ class Axios {
3434
3690
 
3435
3691
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3436
3692
 
3437
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3693
+ const transitional = config.transitional || transitionalDefaults;
3694
+ const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
3695
+
3696
+ if (legacyInterceptorReqResOrdering) {
3697
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3698
+ } else {
3699
+ requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3700
+ }
3438
3701
  });
3439
3702
 
3440
3703
  const responseInterceptorChain = [];
@@ -3448,8 +3711,8 @@ class Axios {
3448
3711
 
3449
3712
  if (!synchronousRequestInterceptors) {
3450
3713
  const chain = [dispatchRequest.bind(this), undefined];
3451
- chain.unshift.apply(chain, requestInterceptorChain);
3452
- chain.push.apply(chain, responseInterceptorChain);
3714
+ chain.unshift(...requestInterceptorChain);
3715
+ chain.push(...responseInterceptorChain);
3453
3716
  len = chain.length;
3454
3717
 
3455
3718
  promise = Promise.resolve(config);
@@ -3465,8 +3728,6 @@ class Axios {
3465
3728
 
3466
3729
  let newConfig = config;
3467
3730
 
3468
- i = 0;
3469
-
3470
3731
  while (i < len) {
3471
3732
  const onFulfilled = requestInterceptorChain[i++];
3472
3733
  const onRejected = requestInterceptorChain[i++];
@@ -3671,7 +3932,7 @@ class CancelToken {
3671
3932
  *
3672
3933
  * ```js
3673
3934
  * function f(x, y, z) {}
3674
- * var args = [1, 2, 3];
3935
+ * const args = [1, 2, 3];
3675
3936
  * f.apply(null, args);
3676
3937
  * ```
3677
3938
  *
@@ -3766,6 +4027,12 @@ const HttpStatusCode = {
3766
4027
  LoopDetected: 508,
3767
4028
  NotExtended: 510,
3768
4029
  NetworkAuthenticationRequired: 511,
4030
+ WebServerIsDown: 521,
4031
+ ConnectionTimedOut: 522,
4032
+ OriginIsUnreachable: 523,
4033
+ TimeoutOccurred: 524,
4034
+ SslHandshakeFailed: 525,
4035
+ InvalidSslCertificate: 526,
3769
4036
  };
3770
4037
 
3771
4038
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
@@ -3928,7 +4195,7 @@ const TX_MIN_FEE = 1000;
3928
4195
  /**
3929
4196
  * Threshold value for dust amount in Dash transactions.
3930
4197
  */
3931
- dashcore__namespace.default.Transaction.DUST_AMOUNT;
4198
+ dashcore__default.default.Transaction.DUST_AMOUNT;
3932
4199
  /**
3933
4200
  * Function to determine the Dash network based on the provided network type.
3934
4201
  * @param {Network} network The network type (Mainnet, Testnet, or Stagenet).
@@ -3954,7 +4221,7 @@ const validateAddress = (address, network) => {
3954
4221
  Dash__namespace.address.toOutputScript(address, dashNetwork(network)); // Convert address to output script
3955
4222
  return true; // Address is valid
3956
4223
  }
3957
- catch (error) {
4224
+ catch (_error) {
3958
4225
  return false; // Address is invalid
3959
4226
  }
3960
4227
  };
@@ -3992,7 +4259,7 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ amount, rec
3992
4259
  if (!inputs || !outputs)
3993
4260
  throw new Error('Insufficient balance for transaction');
3994
4261
  // Initialize new Dash transaction
3995
- const tx = new dashcore__namespace.default.Transaction().to(recipient, amount.amount().toNumber());
4262
+ const tx = new dashcore__default.default.Transaction().to(recipient, amount.amount().toNumber());
3996
4263
  // Add inputs to the transaction
3997
4264
  inputs.forEach((utxo) => {
3998
4265
  const insightUtxo = insightUtxos.find((x) => x.txid === utxo.hash && x.vout == utxo.index);
@@ -4000,12 +4267,12 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ amount, rec
4000
4267
  throw new Error('Unable to match accumulative inputs with insight UTXOs');
4001
4268
  }
4002
4269
  const scriptBuffer = Buffer.from(insightUtxo.scriptPubKey, 'hex');
4003
- const script = new dashcore__namespace.default.Script(scriptBuffer);
4004
- const input = new dashcore__namespace.default.Transaction.Input.PublicKeyHash({
4270
+ const script = new dashcore__default.default.Script(scriptBuffer);
4271
+ const input = new dashcore__default.default.Transaction.Input.PublicKeyHash({
4005
4272
  prevTxId: Buffer.from(insightUtxo.txid, 'hex'),
4006
4273
  outputIndex: insightUtxo.vout,
4007
4274
  script: '',
4008
- output: new dashcore__namespace.default.Transaction.Output({
4275
+ output: new dashcore__default.default.Transaction.Output({
4009
4276
  satoshis: utxo.value,
4010
4277
  script,
4011
4278
  }),
@@ -4013,7 +4280,7 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ amount, rec
4013
4280
  tx.uncheckedAddInput(input);
4014
4281
  });
4015
4282
  // Define sender address
4016
- const senderAddress = dashcore__namespace.default.Address.fromString(sender, network);
4283
+ const senderAddress = dashcore__default.default.Address.fromString(sender, network);
4017
4284
  tx.change(senderAddress);
4018
4285
  // Add memo to the transaction if provided
4019
4286
  if (memo) {
@@ -4225,6 +4492,9 @@ class Client extends xchainUtxo.Client {
4225
4492
  network: this.network,
4226
4493
  });
4227
4494
  // Return the raw unsigned transaction and UTXOs
4495
+ // ESLint disabled: Dash transaction has proper toString() method that returns hex string
4496
+ // Left as-is during ESLint 8 upgrade as this core crypto functionality is tested and working
4497
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
4228
4498
  return { rawUnsignedTx: tx.toString(), utxos, inputs };
4229
4499
  });
4230
4500
  }
@@ -4234,7 +4504,7 @@ class Client extends xchainUtxo.Client {
4234
4504
  * @returns {Buffer} The compiled memo as a buffer.
4235
4505
  */
4236
4506
  compileMemo(memo) {
4237
- return dashcore__namespace.Script.buildDataOut(memo);
4507
+ return dashcore__default.default.Script.buildDataOut(memo);
4238
4508
  }
4239
4509
  /**
4240
4510
  * Calculates the transaction fee based on the provided UTXOs, fee rate, and optional compiled memo.
@@ -4302,7 +4572,7 @@ const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
4302
4572
  }
4303
4573
  catch (ex) {
4304
4574
  // If an exception occurs during the request, reject the promise with the caught error message.
4305
- return Promise.reject(Error(`failed to broadcast a transaction caught: ${ex}`));
4575
+ return Promise.reject(Error(`failed to broadcast a transaction caught: ${String(ex)}`));
4306
4576
  }
4307
4577
  });
4308
4578
 
@@ -4373,7 +4643,7 @@ class ClientKeystore extends Client {
4373
4643
  xchainClient.checkFeeBounds(this.feeBounds, feeRate);
4374
4644
  const fromAddressIndex = params.walletIndex || 0;
4375
4645
  const { rawUnsignedTx, utxos } = yield this.prepareTx(Object.assign(Object.assign({}, params), { feeRate, sender: yield this.getAddressAsync(fromAddressIndex) }));
4376
- const tx = new dashcore__namespace.Transaction(rawUnsignedTx);
4646
+ const tx = new dashcore__default.default.Transaction(rawUnsignedTx);
4377
4647
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4378
4648
  tx.inputs.forEach((input, index) => {
4379
4649
  const insightUtxo = utxos.find((utxo) => {
@@ -4383,12 +4653,12 @@ class ClientKeystore extends Client {
4383
4653
  throw new Error('Unable to match accumulative inputs with insight utxos');
4384
4654
  }
4385
4655
  const scriptBuffer = Buffer.from(insightUtxo.scriptPubKey || '', 'hex');
4386
- const script = new dashcore__namespace.Script(scriptBuffer);
4387
- tx.inputs[index] = new dashcore__namespace.Transaction.Input.PublicKeyHash({
4656
+ const script = new dashcore__default.default.Script(scriptBuffer);
4657
+ tx.inputs[index] = new dashcore__default.default.Transaction.Input.PublicKeyHash({
4388
4658
  prevTxId: Buffer.from(insightUtxo.hash, 'hex'),
4389
4659
  outputIndex: insightUtxo.index,
4390
4660
  script: '',
4391
- output: new dashcore__namespace.Transaction.Output({
4661
+ output: new dashcore__default.default.Transaction.Output({
4392
4662
  satoshis: insightUtxo.value,
4393
4663
  script,
4394
4664
  }),
@@ -4453,7 +4723,7 @@ class ClientLedger extends Client {
4453
4723
  const sender = yield this.getAddressAsync(fromAddressIndex);
4454
4724
  // Prepare transaction
4455
4725
  const { rawUnsignedTx, inputs } = yield this.prepareTx(Object.assign(Object.assign({}, params), { sender, feeRate }));
4456
- const tx = new dashcore__namespace.Transaction(rawUnsignedTx);
4726
+ const tx = new dashcore__default.default.Transaction(rawUnsignedTx);
4457
4727
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4458
4728
  const ledgerInputs = [];
4459
4729
  for (const input of tx.inputs) {
@@ -4465,7 +4735,7 @@ class ClientLedger extends Client {
4465
4735
  throw new Error('Unable to match accumulative inputs with insight utxos');
4466
4736
  }
4467
4737
  const txHex = yield getRawTx({ txid: insightUtxo.hash, network: this.network });
4468
- const utxoTx = new dashcore__namespace.Transaction(txHex);
4738
+ const utxoTx = new dashcore__default.default.Transaction(txHex);
4469
4739
  const splittedTx = app.splitTransaction(utxoTx.toString());
4470
4740
  ledgerInputs.push([splittedTx, input.outputIndex, null, null]);
4471
4741
  }