@xchainjs/xchain-aggregator 2.0.33 → 2.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.esm.js +462 -329
  2. package/lib/index.js +462 -329
  3. package/package.json +16 -16
package/lib/index.js CHANGED
@@ -317,6 +317,13 @@ class ChainflipProtocol {
317
317
  }
318
318
  }
319
319
 
320
+ /**
321
+ * Create a bound version of a function with a specified `this` context
322
+ *
323
+ * @param {Function} fn - The function to bind
324
+ * @param {*} thisArg - The value to be passed as the `this` parameter
325
+ * @returns {Function} A new function that will call the original function with the specified `this` context
326
+ */
320
327
  function bind(fn, thisArg) {
321
328
  return function wrap() {
322
329
  return fn.apply(thisArg, arguments);
@@ -325,30 +332,30 @@ function bind(fn, thisArg) {
325
332
 
326
333
  // utils is a library of generic helper functions non-specific to axios
327
334
 
328
- const {toString} = Object.prototype;
329
- const {getPrototypeOf} = Object;
330
- const {iterator, toStringTag} = Symbol;
335
+ const { toString } = Object.prototype;
336
+ const { getPrototypeOf } = Object;
337
+ const { iterator, toStringTag } = Symbol;
331
338
 
332
- const kindOf = (cache => thing => {
333
- const str = toString.call(thing);
334
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
339
+ const kindOf = ((cache) => (thing) => {
340
+ const str = toString.call(thing);
341
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
335
342
  })(Object.create(null));
336
343
 
337
344
  const kindOfTest = (type) => {
338
345
  type = type.toLowerCase();
339
- return (thing) => kindOf(thing) === type
346
+ return (thing) => kindOf(thing) === type;
340
347
  };
341
348
 
342
- const typeOfTest = type => thing => typeof thing === type;
349
+ const typeOfTest = (type) => (thing) => typeof thing === type;
343
350
 
344
351
  /**
345
- * Determine if a value is an Array
352
+ * Determine if a value is a non-null object
346
353
  *
347
354
  * @param {Object} val The value to test
348
355
  *
349
356
  * @returns {boolean} True if value is an Array, otherwise false
350
357
  */
351
- const {isArray} = Array;
358
+ const { isArray } = Array;
352
359
 
353
360
  /**
354
361
  * Determine if a value is undefined
@@ -357,7 +364,7 @@ const {isArray} = Array;
357
364
  *
358
365
  * @returns {boolean} True if the value is undefined, otherwise false
359
366
  */
360
- const isUndefined = typeOfTest('undefined');
367
+ const isUndefined = typeOfTest("undefined");
361
368
 
362
369
  /**
363
370
  * Determine if a value is a Buffer
@@ -367,8 +374,14 @@ const isUndefined = typeOfTest('undefined');
367
374
  * @returns {boolean} True if value is a Buffer, otherwise false
368
375
  */
369
376
  function isBuffer(val) {
370
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
371
- && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
377
+ return (
378
+ val !== null &&
379
+ !isUndefined(val) &&
380
+ val.constructor !== null &&
381
+ !isUndefined(val.constructor) &&
382
+ isFunction$1(val.constructor.isBuffer) &&
383
+ val.constructor.isBuffer(val)
384
+ );
372
385
  }
373
386
 
374
387
  /**
@@ -378,8 +391,7 @@ function isBuffer(val) {
378
391
  *
379
392
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
380
393
  */
381
- const isArrayBuffer = kindOfTest('ArrayBuffer');
382
-
394
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
383
395
 
384
396
  /**
385
397
  * Determine if a value is a view on an ArrayBuffer
@@ -390,10 +402,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
390
402
  */
391
403
  function isArrayBufferView(val) {
392
404
  let result;
393
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
405
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
394
406
  result = ArrayBuffer.isView(val);
395
407
  } else {
396
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
408
+ result = val && val.buffer && isArrayBuffer(val.buffer);
397
409
  }
398
410
  return result;
399
411
  }
@@ -405,7 +417,7 @@ function isArrayBufferView(val) {
405
417
  *
406
418
  * @returns {boolean} True if value is a String, otherwise false
407
419
  */
408
- const isString = typeOfTest('string');
420
+ const isString = typeOfTest("string");
409
421
 
410
422
  /**
411
423
  * Determine if a value is a Function
@@ -413,7 +425,7 @@ const isString = typeOfTest('string');
413
425
  * @param {*} val The value to test
414
426
  * @returns {boolean} True if value is a Function, otherwise false
415
427
  */
416
- const isFunction$1 = typeOfTest('function');
428
+ const isFunction$1 = typeOfTest("function");
417
429
 
418
430
  /**
419
431
  * Determine if a value is a Number
@@ -422,7 +434,7 @@ const isFunction$1 = typeOfTest('function');
422
434
  *
423
435
  * @returns {boolean} True if value is a Number, otherwise false
424
436
  */
425
- const isNumber = typeOfTest('number');
437
+ const isNumber = typeOfTest("number");
426
438
 
427
439
  /**
428
440
  * Determine if a value is an Object
@@ -431,7 +443,7 @@ const isNumber = typeOfTest('number');
431
443
  *
432
444
  * @returns {boolean} True if value is an Object, otherwise false
433
445
  */
434
- const isObject = (thing) => thing !== null && typeof thing === 'object';
446
+ const isObject = (thing) => thing !== null && typeof thing === "object";
435
447
 
436
448
  /**
437
449
  * Determine if a value is a Boolean
@@ -439,7 +451,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
439
451
  * @param {*} thing The value to test
440
452
  * @returns {boolean} True if value is a Boolean, otherwise false
441
453
  */
442
- const isBoolean = thing => thing === true || thing === false;
454
+ const isBoolean = (thing) => thing === true || thing === false;
443
455
 
444
456
  /**
445
457
  * Determine if a value is a plain Object
@@ -449,12 +461,18 @@ const isBoolean = thing => thing === true || thing === false;
449
461
  * @returns {boolean} True if value is a plain Object, otherwise false
450
462
  */
451
463
  const isPlainObject = (val) => {
452
- if (kindOf(val) !== 'object') {
464
+ if (kindOf(val) !== "object") {
453
465
  return false;
454
466
  }
455
467
 
456
468
  const prototype = getPrototypeOf(val);
457
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
469
+ return (
470
+ (prototype === null ||
471
+ prototype === Object.prototype ||
472
+ Object.getPrototypeOf(prototype) === null) &&
473
+ !(toStringTag in val) &&
474
+ !(iterator in val)
475
+ );
458
476
  };
459
477
 
460
478
  /**
@@ -471,7 +489,10 @@ const isEmptyObject = (val) => {
471
489
  }
472
490
 
473
491
  try {
474
- return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
492
+ return (
493
+ Object.keys(val).length === 0 &&
494
+ Object.getPrototypeOf(val) === Object.prototype
495
+ );
475
496
  } catch (e) {
476
497
  // Fallback for any other objects that might cause RangeError with Object.keys()
477
498
  return false;
@@ -485,7 +506,7 @@ const isEmptyObject = (val) => {
485
506
  *
486
507
  * @returns {boolean} True if value is a Date, otherwise false
487
508
  */
488
- const isDate = kindOfTest('Date');
509
+ const isDate = kindOfTest("Date");
489
510
 
490
511
  /**
491
512
  * Determine if a value is a File
@@ -494,7 +515,7 @@ const isDate = kindOfTest('Date');
494
515
  *
495
516
  * @returns {boolean} True if value is a File, otherwise false
496
517
  */
497
- const isFile = kindOfTest('File');
518
+ const isFile = kindOfTest("File");
498
519
 
499
520
  /**
500
521
  * Determine if a value is a Blob
@@ -503,7 +524,7 @@ const isFile = kindOfTest('File');
503
524
  *
504
525
  * @returns {boolean} True if value is a Blob, otherwise false
505
526
  */
506
- const isBlob = kindOfTest('Blob');
527
+ const isBlob = kindOfTest("Blob");
507
528
 
508
529
  /**
509
530
  * Determine if a value is a FileList
@@ -512,7 +533,7 @@ const isBlob = kindOfTest('Blob');
512
533
  *
513
534
  * @returns {boolean} True if value is a File, otherwise false
514
535
  */
515
- const isFileList = kindOfTest('FileList');
536
+ const isFileList = kindOfTest("FileList");
516
537
 
517
538
  /**
518
539
  * Determine if a value is a Stream
@@ -532,15 +553,16 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
532
553
  */
533
554
  const isFormData = (thing) => {
534
555
  let kind;
535
- return thing && (
536
- (typeof FormData === 'function' && thing instanceof FormData) || (
537
- isFunction$1(thing.append) && (
538
- (kind = kindOf(thing)) === 'formdata' ||
539
- // detect form-data instance
540
- (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
541
- )
542
- )
543
- )
556
+ return (
557
+ thing &&
558
+ ((typeof FormData === "function" && thing instanceof FormData) ||
559
+ (isFunction$1(thing.append) &&
560
+ ((kind = kindOf(thing)) === "formdata" ||
561
+ // detect form-data instance
562
+ (kind === "object" &&
563
+ isFunction$1(thing.toString) &&
564
+ thing.toString() === "[object FormData]"))))
565
+ );
544
566
  };
545
567
 
546
568
  /**
@@ -550,9 +572,14 @@ const isFormData = (thing) => {
550
572
  *
551
573
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
552
574
  */
553
- const isURLSearchParams = kindOfTest('URLSearchParams');
575
+ const isURLSearchParams = kindOfTest("URLSearchParams");
554
576
 
555
- const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
577
+ const [isReadableStream, isRequest, isResponse, isHeaders] = [
578
+ "ReadableStream",
579
+ "Request",
580
+ "Response",
581
+ "Headers",
582
+ ].map(kindOfTest);
556
583
 
557
584
  /**
558
585
  * Trim excess whitespace off the beginning and end of a string
@@ -561,8 +588,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
561
588
  *
562
589
  * @returns {String} The String freed of excess whitespace
563
590
  */
564
- const trim = (str) => str.trim ?
565
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
591
+ const trim = (str) =>
592
+ str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
566
593
 
567
594
  /**
568
595
  * Iterate over an Array or an Object invoking a function for each item.
@@ -573,15 +600,16 @@ const trim = (str) => str.trim ?
573
600
  * If 'obj' is an Object callback will be called passing
574
601
  * the value, key, and complete object for each property.
575
602
  *
576
- * @param {Object|Array} obj The object to iterate
603
+ * @param {Object|Array<unknown>} obj The object to iterate
577
604
  * @param {Function} fn The callback to invoke for each item
578
605
  *
579
- * @param {Boolean} [allOwnKeys = false]
606
+ * @param {Object} [options]
607
+ * @param {Boolean} [options.allOwnKeys = false]
580
608
  * @returns {any}
581
609
  */
582
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
610
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
583
611
  // Don't bother if no value provided
584
- if (obj === null || typeof obj === 'undefined') {
612
+ if (obj === null || typeof obj === "undefined") {
585
613
  return;
586
614
  }
587
615
 
@@ -589,7 +617,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
589
617
  let l;
590
618
 
591
619
  // Force an array if not already something iterable
592
- if (typeof obj !== 'object') {
620
+ if (typeof obj !== "object") {
593
621
  /*eslint no-param-reassign:0*/
594
622
  obj = [obj];
595
623
  }
@@ -606,7 +634,9 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
606
634
  }
607
635
 
608
636
  // Iterate over object keys
609
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
637
+ const keys = allOwnKeys
638
+ ? Object.getOwnPropertyNames(obj)
639
+ : Object.keys(obj);
610
640
  const len = keys.length;
611
641
  let key;
612
642
 
@@ -618,7 +648,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
618
648
  }
619
649
 
620
650
  function findKey(obj, key) {
621
- if (isBuffer(obj)){
651
+ if (isBuffer(obj)) {
622
652
  return null;
623
653
  }
624
654
 
@@ -638,10 +668,15 @@ function findKey(obj, key) {
638
668
  const _global = (() => {
639
669
  /*eslint no-undef:0*/
640
670
  if (typeof globalThis !== "undefined") return globalThis;
641
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
671
+ return typeof self !== "undefined"
672
+ ? self
673
+ : typeof window !== "undefined"
674
+ ? window
675
+ : global;
642
676
  })();
643
677
 
644
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
678
+ const isContextDefined = (context) =>
679
+ !isUndefined(context) && context !== _global;
645
680
 
646
681
  /**
647
682
  * Accepts varargs expecting each argument to be an object, then
@@ -653,7 +688,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
653
688
  * Example:
654
689
  *
655
690
  * ```js
656
- * var result = merge({foo: 123}, {foo: 456});
691
+ * const result = merge({foo: 123}, {foo: 456});
657
692
  * console.log(result.foo); // outputs 456
658
693
  * ```
659
694
  *
@@ -662,20 +697,23 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
662
697
  * @returns {Object} Result of all merge properties
663
698
  */
664
699
  function merge(/* obj1, obj2, obj3, ... */) {
665
- const {caseless, skipUndefined} = isContextDefined(this) && this || {};
700
+ const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
666
701
  const result = {};
667
702
  const assignValue = (val, key) => {
668
- const targetKey = caseless && findKey(result, key) || key;
703
+ // Skip dangerous property names to prevent prototype pollution
704
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
705
+ return;
706
+ }
707
+
708
+ const targetKey = (caseless && findKey(result, key)) || key;
669
709
  if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
670
710
  result[targetKey] = merge(result[targetKey], val);
671
711
  } else if (isPlainObject(val)) {
672
712
  result[targetKey] = merge({}, val);
673
713
  } else if (isArray(val)) {
674
714
  result[targetKey] = val.slice();
675
- } else {
676
- if (!skipUndefined || !isUndefined(val)) {
677
- result[targetKey] = val;
678
- }
715
+ } else if (!skipUndefined || !isUndefined(val)) {
716
+ result[targetKey] = val;
679
717
  }
680
718
  };
681
719
 
@@ -692,17 +730,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
692
730
  * @param {Object} b The object to copy properties from
693
731
  * @param {Object} thisArg The object to bind function to
694
732
  *
695
- * @param {Boolean} [allOwnKeys]
733
+ * @param {Object} [options]
734
+ * @param {Boolean} [options.allOwnKeys]
696
735
  * @returns {Object} The resulting value of object a
697
736
  */
698
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
699
- forEach(b, (val, key) => {
700
- if (thisArg && isFunction$1(val)) {
701
- a[key] = bind(val, thisArg);
702
- } else {
703
- a[key] = val;
704
- }
705
- }, {allOwnKeys});
737
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
738
+ forEach(
739
+ b,
740
+ (val, key) => {
741
+ if (thisArg && isFunction$1(val)) {
742
+ Object.defineProperty(a, key, {
743
+ value: bind(val, thisArg),
744
+ writable: true,
745
+ enumerable: true,
746
+ configurable: true,
747
+ });
748
+ } else {
749
+ Object.defineProperty(a, key, {
750
+ value: val,
751
+ writable: true,
752
+ enumerable: true,
753
+ configurable: true,
754
+ });
755
+ }
756
+ },
757
+ { allOwnKeys },
758
+ );
706
759
  return a;
707
760
  };
708
761
 
@@ -714,7 +767,7 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
714
767
  * @returns {string} content value without BOM
715
768
  */
716
769
  const stripBOM = (content) => {
717
- if (content.charCodeAt(0) === 0xFEFF) {
770
+ if (content.charCodeAt(0) === 0xfeff) {
718
771
  content = content.slice(1);
719
772
  }
720
773
  return content;
@@ -730,10 +783,18 @@ const stripBOM = (content) => {
730
783
  * @returns {void}
731
784
  */
732
785
  const inherits = (constructor, superConstructor, props, descriptors) => {
733
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
734
- constructor.prototype.constructor = constructor;
735
- Object.defineProperty(constructor, 'super', {
736
- value: superConstructor.prototype
786
+ constructor.prototype = Object.create(
787
+ superConstructor.prototype,
788
+ descriptors,
789
+ );
790
+ Object.defineProperty(constructor.prototype, "constructor", {
791
+ value: constructor,
792
+ writable: true,
793
+ enumerable: false,
794
+ configurable: true,
795
+ });
796
+ Object.defineProperty(constructor, "super", {
797
+ value: superConstructor.prototype,
737
798
  });
738
799
  props && Object.assign(constructor.prototype, props);
739
800
  };
@@ -762,13 +823,20 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
762
823
  i = props.length;
763
824
  while (i-- > 0) {
764
825
  prop = props[i];
765
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
826
+ if (
827
+ (!propFilter || propFilter(prop, sourceObj, destObj)) &&
828
+ !merged[prop]
829
+ ) {
766
830
  destObj[prop] = sourceObj[prop];
767
831
  merged[prop] = true;
768
832
  }
769
833
  }
770
834
  sourceObj = filter !== false && getPrototypeOf(sourceObj);
771
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
835
+ } while (
836
+ sourceObj &&
837
+ (!filter || filter(sourceObj, destObj)) &&
838
+ sourceObj !== Object.prototype
839
+ );
772
840
 
773
841
  return destObj;
774
842
  };
@@ -792,7 +860,6 @@ const endsWith = (str, searchString, position) => {
792
860
  return lastIndex !== -1 && lastIndex === position;
793
861
  };
794
862
 
795
-
796
863
  /**
797
864
  * Returns new array from array like object or null if failed
798
865
  *
@@ -821,12 +888,12 @@ const toArray = (thing) => {
821
888
  * @returns {Array}
822
889
  */
823
890
  // eslint-disable-next-line func-names
824
- const isTypedArray = (TypedArray => {
891
+ const isTypedArray = ((TypedArray) => {
825
892
  // eslint-disable-next-line func-names
826
- return thing => {
893
+ return (thing) => {
827
894
  return TypedArray && thing instanceof TypedArray;
828
895
  };
829
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
896
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
830
897
 
831
898
  /**
832
899
  * For each entry in the object, call the function with the key and value.
@@ -869,18 +936,22 @@ const matchAll = (regExp, str) => {
869
936
  };
870
937
 
871
938
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
872
- const isHTMLForm = kindOfTest('HTMLFormElement');
939
+ const isHTMLForm = kindOfTest("HTMLFormElement");
873
940
 
874
- const toCamelCase = str => {
875
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
876
- function replacer(m, p1, p2) {
941
+ const toCamelCase = (str) => {
942
+ return str
943
+ .toLowerCase()
944
+ .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
877
945
  return p1.toUpperCase() + p2;
878
- }
879
- );
946
+ });
880
947
  };
881
948
 
882
949
  /* Creating a function that will check if an object has a property. */
883
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
950
+ const hasOwnProperty = (
951
+ ({ hasOwnProperty }) =>
952
+ (obj, prop) =>
953
+ hasOwnProperty.call(obj, prop)
954
+ )(Object.prototype);
884
955
 
885
956
  /**
886
957
  * Determine if a value is a RegExp object
@@ -889,7 +960,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
889
960
  *
890
961
  * @returns {boolean} True if value is a RegExp object, otherwise false
891
962
  */
892
- const isRegExp = kindOfTest('RegExp');
963
+ const isRegExp = kindOfTest("RegExp");
893
964
 
894
965
  const reduceDescriptors = (obj, reducer) => {
895
966
  const descriptors = Object.getOwnPropertyDescriptors(obj);
@@ -913,7 +984,10 @@ const reduceDescriptors = (obj, reducer) => {
913
984
  const freezeMethods = (obj) => {
914
985
  reduceDescriptors(obj, (descriptor, name) => {
915
986
  // skip restricted props in strict mode
916
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
987
+ if (
988
+ isFunction$1(obj) &&
989
+ ["arguments", "caller", "callee"].indexOf(name) !== -1
990
+ ) {
917
991
  return false;
918
992
  }
919
993
 
@@ -923,14 +997,14 @@ const freezeMethods = (obj) => {
923
997
 
924
998
  descriptor.enumerable = false;
925
999
 
926
- if ('writable' in descriptor) {
1000
+ if ("writable" in descriptor) {
927
1001
  descriptor.writable = false;
928
1002
  return;
929
1003
  }
930
1004
 
931
1005
  if (!descriptor.set) {
932
1006
  descriptor.set = () => {
933
- throw Error('Can not rewrite read-only method \'' + name + '\'');
1007
+ throw Error("Can not rewrite read-only method '" + name + "'");
934
1008
  };
935
1009
  }
936
1010
  });
@@ -940,12 +1014,14 @@ const toObjectSet = (arrayOrString, delimiter) => {
940
1014
  const obj = {};
941
1015
 
942
1016
  const define = (arr) => {
943
- arr.forEach(value => {
1017
+ arr.forEach((value) => {
944
1018
  obj[value] = true;
945
1019
  });
946
1020
  };
947
1021
 
948
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
1022
+ isArray(arrayOrString)
1023
+ ? define(arrayOrString)
1024
+ : define(String(arrayOrString).split(delimiter));
949
1025
 
950
1026
  return obj;
951
1027
  };
@@ -953,11 +1029,11 @@ const toObjectSet = (arrayOrString, delimiter) => {
953
1029
  const noop = () => {};
954
1030
 
955
1031
  const toFiniteNumber = (value, defaultValue) => {
956
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
1032
+ return value != null && Number.isFinite((value = +value))
1033
+ ? value
1034
+ : defaultValue;
957
1035
  };
958
1036
 
959
-
960
-
961
1037
  /**
962
1038
  * If the thing is a FormData object, return true, otherwise return false.
963
1039
  *
@@ -966,14 +1042,18 @@ const toFiniteNumber = (value, defaultValue) => {
966
1042
  * @returns {boolean}
967
1043
  */
968
1044
  function isSpecCompliantForm(thing) {
969
- return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
1045
+ return !!(
1046
+ thing &&
1047
+ isFunction$1(thing.append) &&
1048
+ thing[toStringTag] === "FormData" &&
1049
+ thing[iterator]
1050
+ );
970
1051
  }
971
1052
 
972
1053
  const toJSONObject = (obj) => {
973
1054
  const stack = new Array(10);
974
1055
 
975
1056
  const visit = (source, i) => {
976
-
977
1057
  if (isObject(source)) {
978
1058
  if (stack.indexOf(source) >= 0) {
979
1059
  return;
@@ -984,7 +1064,7 @@ const toJSONObject = (obj) => {
984
1064
  return source;
985
1065
  }
986
1066
 
987
- if(!('toJSON' in source)) {
1067
+ if (!("toJSON" in source)) {
988
1068
  stack[i] = source;
989
1069
  const target = isArray(source) ? [] : {};
990
1070
 
@@ -1005,10 +1085,13 @@ const toJSONObject = (obj) => {
1005
1085
  return visit(obj, 0);
1006
1086
  };
1007
1087
 
1008
- const isAsyncFn = kindOfTest('AsyncFunction');
1088
+ const isAsyncFn = kindOfTest("AsyncFunction");
1009
1089
 
1010
1090
  const isThenable = (thing) =>
1011
- thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
1091
+ thing &&
1092
+ (isObject(thing) || isFunction$1(thing)) &&
1093
+ isFunction$1(thing.then) &&
1094
+ isFunction$1(thing.catch);
1012
1095
 
1013
1096
  // original code
1014
1097
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -1018,32 +1101,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1018
1101
  return setImmediate;
1019
1102
  }
1020
1103
 
1021
- return postMessageSupported ? ((token, callbacks) => {
1022
- _global.addEventListener("message", ({source, data}) => {
1023
- if (source === _global && data === token) {
1024
- callbacks.length && callbacks.shift()();
1025
- }
1026
- }, false);
1104
+ return postMessageSupported
1105
+ ? ((token, callbacks) => {
1106
+ _global.addEventListener(
1107
+ "message",
1108
+ ({ source, data }) => {
1109
+ if (source === _global && data === token) {
1110
+ callbacks.length && callbacks.shift()();
1111
+ }
1112
+ },
1113
+ false,
1114
+ );
1027
1115
 
1028
- return (cb) => {
1029
- callbacks.push(cb);
1030
- _global.postMessage(token, "*");
1031
- }
1032
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
1033
- })(
1034
- typeof setImmediate === 'function',
1035
- isFunction$1(_global.postMessage)
1036
- );
1116
+ return (cb) => {
1117
+ callbacks.push(cb);
1118
+ _global.postMessage(token, "*");
1119
+ };
1120
+ })(`axios@${Math.random()}`, [])
1121
+ : (cb) => setTimeout(cb);
1122
+ })(typeof setImmediate === "function", isFunction$1(_global.postMessage));
1037
1123
 
1038
- const asap = typeof queueMicrotask !== 'undefined' ?
1039
- queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
1124
+ const asap =
1125
+ typeof queueMicrotask !== "undefined"
1126
+ ? queueMicrotask.bind(_global)
1127
+ : (typeof process !== "undefined" && process.nextTick) || _setImmediate;
1040
1128
 
1041
1129
  // *********************
1042
1130
 
1043
-
1044
1131
  const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
1045
1132
 
1046
-
1047
1133
  var utils$1 = {
1048
1134
  isArray,
1049
1135
  isArrayBuffer,
@@ -1101,113 +1187,76 @@ var utils$1 = {
1101
1187
  isThenable,
1102
1188
  setImmediate: _setImmediate,
1103
1189
  asap,
1104
- isIterable
1190
+ isIterable,
1105
1191
  };
1106
1192
 
1107
- /**
1108
- * Create an Error with the specified message, config, error code, request and response.
1109
- *
1110
- * @param {string} message The error message.
1111
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
1112
- * @param {Object} [config] The config.
1113
- * @param {Object} [request] The request.
1114
- * @param {Object} [response] The response.
1115
- *
1116
- * @returns {Error} The created error.
1117
- */
1118
- function AxiosError(message, code, config, request, response) {
1119
- Error.call(this);
1193
+ class AxiosError extends Error {
1194
+ static from(error, code, config, request, response, customProps) {
1195
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1196
+ axiosError.cause = error;
1197
+ axiosError.name = error.name;
1198
+ customProps && Object.assign(axiosError, customProps);
1199
+ return axiosError;
1200
+ }
1120
1201
 
1121
- if (Error.captureStackTrace) {
1122
- Error.captureStackTrace(this, this.constructor);
1123
- } else {
1124
- this.stack = (new Error()).stack;
1125
- }
1202
+ /**
1203
+ * Create an Error with the specified message, config, error code, request and response.
1204
+ *
1205
+ * @param {string} message The error message.
1206
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1207
+ * @param {Object} [config] The config.
1208
+ * @param {Object} [request] The request.
1209
+ * @param {Object} [response] The response.
1210
+ *
1211
+ * @returns {Error} The created error.
1212
+ */
1213
+ constructor(message, code, config, request, response) {
1214
+ super(message);
1215
+ this.name = 'AxiosError';
1216
+ this.isAxiosError = true;
1217
+ code && (this.code = code);
1218
+ config && (this.config = config);
1219
+ request && (this.request = request);
1220
+ if (response) {
1221
+ this.response = response;
1222
+ this.status = response.status;
1223
+ }
1224
+ }
1126
1225
 
1127
- this.message = message;
1128
- this.name = 'AxiosError';
1129
- code && (this.code = code);
1130
- config && (this.config = config);
1131
- request && (this.request = request);
1132
- if (response) {
1133
- this.response = response;
1134
- this.status = response.status ? response.status : null;
1135
- }
1226
+ toJSON() {
1227
+ return {
1228
+ // Standard
1229
+ message: this.message,
1230
+ name: this.name,
1231
+ // Microsoft
1232
+ description: this.description,
1233
+ number: this.number,
1234
+ // Mozilla
1235
+ fileName: this.fileName,
1236
+ lineNumber: this.lineNumber,
1237
+ columnNumber: this.columnNumber,
1238
+ stack: this.stack,
1239
+ // Axios
1240
+ config: utils$1.toJSONObject(this.config),
1241
+ code: this.code,
1242
+ status: this.status,
1243
+ };
1244
+ }
1136
1245
  }
1137
1246
 
1138
- utils$1.inherits(AxiosError, Error, {
1139
- toJSON: function toJSON() {
1140
- return {
1141
- // Standard
1142
- message: this.message,
1143
- name: this.name,
1144
- // Microsoft
1145
- description: this.description,
1146
- number: this.number,
1147
- // Mozilla
1148
- fileName: this.fileName,
1149
- lineNumber: this.lineNumber,
1150
- columnNumber: this.columnNumber,
1151
- stack: this.stack,
1152
- // Axios
1153
- config: utils$1.toJSONObject(this.config),
1154
- code: this.code,
1155
- status: this.status
1156
- };
1157
- }
1158
- });
1159
-
1160
- const prototype$1 = AxiosError.prototype;
1161
- const descriptors = {};
1162
-
1163
- [
1164
- 'ERR_BAD_OPTION_VALUE',
1165
- 'ERR_BAD_OPTION',
1166
- 'ECONNABORTED',
1167
- 'ETIMEDOUT',
1168
- 'ERR_NETWORK',
1169
- 'ERR_FR_TOO_MANY_REDIRECTS',
1170
- 'ERR_DEPRECATED',
1171
- 'ERR_BAD_RESPONSE',
1172
- 'ERR_BAD_REQUEST',
1173
- 'ERR_CANCELED',
1174
- 'ERR_NOT_SUPPORT',
1175
- 'ERR_INVALID_URL'
1176
- // eslint-disable-next-line func-names
1177
- ].forEach(code => {
1178
- descriptors[code] = {value: code};
1179
- });
1180
-
1181
- Object.defineProperties(AxiosError, descriptors);
1182
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
1183
-
1184
- // eslint-disable-next-line func-names
1185
- AxiosError.from = (error, code, config, request, response, customProps) => {
1186
- const axiosError = Object.create(prototype$1);
1187
-
1188
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
1189
- return obj !== Error.prototype;
1190
- }, prop => {
1191
- return prop !== 'isAxiosError';
1192
- });
1193
-
1194
- const msg = error && error.message ? error.message : 'Error';
1195
-
1196
- // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
1197
- const errCode = code == null && error ? error.code : code;
1198
- AxiosError.call(axiosError, msg, errCode, config, request, response);
1199
-
1200
- // Chain the original error on the standard field; non-enumerable to avoid JSON noise
1201
- if (error && axiosError.cause == null) {
1202
- Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
1203
- }
1204
-
1205
- axiosError.name = (error && error.name) || 'Error';
1206
-
1207
- customProps && Object.assign(axiosError, customProps);
1208
-
1209
- return axiosError;
1210
- };
1247
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1248
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1249
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1250
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
1251
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1252
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1253
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1254
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1255
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1256
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1257
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1258
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1259
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
1211
1260
 
1212
1261
  // eslint-disable-next-line strict
1213
1262
  var httpAdapter = null;
@@ -1506,29 +1555,26 @@ function encode(val) {
1506
1555
  * @returns {string} The formatted url
1507
1556
  */
1508
1557
  function buildURL(url, params, options) {
1509
- /*eslint no-param-reassign:0*/
1510
1558
  if (!params) {
1511
1559
  return url;
1512
1560
  }
1513
-
1561
+
1514
1562
  const _encode = options && options.encode || encode;
1515
1563
 
1516
- if (utils$1.isFunction(options)) {
1517
- options = {
1518
- serialize: options
1519
- };
1520
- }
1564
+ const _options = utils$1.isFunction(options) ? {
1565
+ serialize: options
1566
+ } : options;
1521
1567
 
1522
- const serializeFn = options && options.serialize;
1568
+ const serializeFn = _options && _options.serialize;
1523
1569
 
1524
1570
  let serializedParams;
1525
1571
 
1526
1572
  if (serializeFn) {
1527
- serializedParams = serializeFn(params, options);
1573
+ serializedParams = serializeFn(params, _options);
1528
1574
  } else {
1529
1575
  serializedParams = utils$1.isURLSearchParams(params) ?
1530
1576
  params.toString() :
1531
- new AxiosURLSearchParams(params, options).toString(_encode);
1577
+ new AxiosURLSearchParams(params, _options).toString(_encode);
1532
1578
  }
1533
1579
 
1534
1580
  if (serializedParams) {
@@ -1553,6 +1599,7 @@ class InterceptorManager {
1553
1599
  *
1554
1600
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
1555
1601
  * @param {Function} rejected The function to handle `reject` for a `Promise`
1602
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
1556
1603
  *
1557
1604
  * @return {Number} An ID used to remove interceptor later
1558
1605
  */
@@ -1571,7 +1618,7 @@ class InterceptorManager {
1571
1618
  *
1572
1619
  * @param {Number} id The ID that was returned by `use`
1573
1620
  *
1574
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1621
+ * @returns {void}
1575
1622
  */
1576
1623
  eject(id) {
1577
1624
  if (this.handlers[id]) {
@@ -1612,7 +1659,8 @@ class InterceptorManager {
1612
1659
  var transitionalDefaults = {
1613
1660
  silentJSONParsing: true,
1614
1661
  forcedJSONParsing: true,
1615
- clarifyTimeoutError: false
1662
+ clarifyTimeoutError: false,
1663
+ legacyInterceptorReqResOrdering: true
1616
1664
  };
1617
1665
 
1618
1666
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -2330,25 +2378,23 @@ function isCancel(value) {
2330
2378
  return !!(value && value.__CANCEL__);
2331
2379
  }
2332
2380
 
2333
- /**
2334
- * A `CanceledError` is an object that is thrown when an operation is canceled.
2335
- *
2336
- * @param {string=} message The message.
2337
- * @param {Object=} config The config.
2338
- * @param {Object=} request The request.
2339
- *
2340
- * @returns {CanceledError} The created error.
2341
- */
2342
- function CanceledError(message, config, request) {
2343
- // eslint-disable-next-line no-eq-null,eqeqeq
2344
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2345
- this.name = 'CanceledError';
2381
+ class CanceledError extends AxiosError {
2382
+ /**
2383
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2384
+ *
2385
+ * @param {string=} message The message.
2386
+ * @param {Object=} config The config.
2387
+ * @param {Object=} request The request.
2388
+ *
2389
+ * @returns {CanceledError} The created error.
2390
+ */
2391
+ constructor(message, config, request) {
2392
+ super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2393
+ this.name = 'CanceledError';
2394
+ this.__CANCEL__ = true;
2395
+ }
2346
2396
  }
2347
2397
 
2348
- utils$1.inherits(CanceledError, AxiosError, {
2349
- __CANCEL__: true
2350
- });
2351
-
2352
2398
  /**
2353
2399
  * Resolve or reject a Promise based on response status.
2354
2400
  *
@@ -2531,27 +2577,38 @@ var cookies = platform.hasStandardBrowserEnv ?
2531
2577
 
2532
2578
  // Standard browser envs support document.cookie
2533
2579
  {
2534
- write(name, value, expires, path, domain, secure) {
2535
- const cookie = [name + '=' + encodeURIComponent(value)];
2536
-
2537
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2538
-
2539
- utils$1.isString(path) && cookie.push('path=' + path);
2580
+ write(name, value, expires, path, domain, secure, sameSite) {
2581
+ if (typeof document === 'undefined') return;
2540
2582
 
2541
- utils$1.isString(domain) && cookie.push('domain=' + domain);
2583
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2542
2584
 
2543
- secure === true && cookie.push('secure');
2585
+ if (utils$1.isNumber(expires)) {
2586
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
2587
+ }
2588
+ if (utils$1.isString(path)) {
2589
+ cookie.push(`path=${path}`);
2590
+ }
2591
+ if (utils$1.isString(domain)) {
2592
+ cookie.push(`domain=${domain}`);
2593
+ }
2594
+ if (secure === true) {
2595
+ cookie.push('secure');
2596
+ }
2597
+ if (utils$1.isString(sameSite)) {
2598
+ cookie.push(`SameSite=${sameSite}`);
2599
+ }
2544
2600
 
2545
2601
  document.cookie = cookie.join('; ');
2546
2602
  },
2547
2603
 
2548
2604
  read(name) {
2549
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2550
- return (match ? decodeURIComponent(match[3]) : null);
2605
+ if (typeof document === 'undefined') return null;
2606
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2607
+ return match ? decodeURIComponent(match[1]) : null;
2551
2608
  },
2552
2609
 
2553
2610
  remove(name) {
2554
- this.write(name, '', Date.now() - 86400000);
2611
+ this.write(name, '', Date.now() - 86400000, '/');
2555
2612
  }
2556
2613
  }
2557
2614
 
@@ -2577,6 +2634,10 @@ function isAbsoluteURL(url) {
2577
2634
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2578
2635
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2579
2636
  // by any combination of letters, digits, plus, period, or hyphen.
2637
+ if (typeof url !== 'string') {
2638
+ return false;
2639
+ }
2640
+
2580
2641
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2581
2642
  }
2582
2643
 
@@ -2612,7 +2673,8 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2612
2673
  return requestedURL;
2613
2674
  }
2614
2675
 
2615
- const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
2676
+ const headersToObject = (thing) =>
2677
+ thing instanceof AxiosHeaders ? { ...thing } : thing;
2616
2678
 
2617
2679
  /**
2618
2680
  * Config-specific merge-function which creates a new config-object
@@ -2630,7 +2692,7 @@ function mergeConfig(config1, config2) {
2630
2692
 
2631
2693
  function getMergedValue(target, source, prop, caseless) {
2632
2694
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2633
- return utils$1.merge.call({caseless}, target, source);
2695
+ return utils$1.merge.call({ caseless }, target, source);
2634
2696
  } else if (utils$1.isPlainObject(source)) {
2635
2697
  return utils$1.merge({}, source);
2636
2698
  } else if (utils$1.isArray(source)) {
@@ -2639,12 +2701,11 @@ function mergeConfig(config1, config2) {
2639
2701
  return source;
2640
2702
  }
2641
2703
 
2642
- // eslint-disable-next-line consistent-return
2643
- function mergeDeepProperties(a, b, prop , caseless) {
2704
+ function mergeDeepProperties(a, b, prop, caseless) {
2644
2705
  if (!utils$1.isUndefined(b)) {
2645
- return getMergedValue(a, b, prop , caseless);
2706
+ return getMergedValue(a, b, prop, caseless);
2646
2707
  } else if (!utils$1.isUndefined(a)) {
2647
- return getMergedValue(undefined, a, prop , caseless);
2708
+ return getMergedValue(undefined, a, prop, caseless);
2648
2709
  }
2649
2710
  }
2650
2711
 
@@ -2702,14 +2763,27 @@ function mergeConfig(config1, config2) {
2702
2763
  socketPath: defaultToConfig2,
2703
2764
  responseEncoding: defaultToConfig2,
2704
2765
  validateStatus: mergeDirectKeys,
2705
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2766
+ headers: (a, b, prop) =>
2767
+ mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
2706
2768
  };
2707
2769
 
2708
- utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
2709
- const merge = mergeMap[prop] || mergeDeepProperties;
2710
- const configValue = merge(config1[prop], config2[prop], prop);
2711
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2712
- });
2770
+ utils$1.forEach(
2771
+ Object.keys({ ...config1, ...config2 }),
2772
+ function computeConfigValue(prop) {
2773
+ if (
2774
+ prop === "__proto__" ||
2775
+ prop === "constructor" ||
2776
+ prop === "prototype"
2777
+ )
2778
+ return;
2779
+ const merge = utils$1.hasOwnProp(mergeMap, prop)
2780
+ ? mergeMap[prop]
2781
+ : mergeDeepProperties;
2782
+ const configValue = merge(config1[prop], config2[prop], prop);
2783
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
2784
+ (config[prop] = configValue);
2785
+ },
2786
+ );
2713
2787
 
2714
2788
  return config;
2715
2789
  }
@@ -2975,7 +3049,7 @@ const composeSignals = (signals, timeout) => {
2975
3049
 
2976
3050
  let timer = timeout && setTimeout(() => {
2977
3051
  timer = null;
2978
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3052
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
2979
3053
  }, timeout);
2980
3054
 
2981
3055
  const unsubscribe = () => {
@@ -3090,9 +3164,9 @@ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3090
3164
 
3091
3165
  const {isFunction} = utils$1;
3092
3166
 
3093
- const globalFetchAPI = (({fetch, Request, Response}) => ({
3094
- fetch, Request, Response
3095
- }))(utils$1.global);
3167
+ const globalFetchAPI = (({Request, Response}) => ({
3168
+ Request, Response
3169
+ }))(utils$1.global);
3096
3170
 
3097
3171
  const {
3098
3172
  ReadableStream: ReadableStream$1, TextEncoder
@@ -3108,8 +3182,12 @@ const test = (fn, ...args) => {
3108
3182
  };
3109
3183
 
3110
3184
  const factory = (env) => {
3111
- const {fetch, Request, Response} = Object.assign({}, globalFetchAPI, env);
3112
- const isFetchSupported = isFunction(fetch);
3185
+ env = utils$1.merge.call({
3186
+ skipUndefined: true
3187
+ }, globalFetchAPI, env);
3188
+
3189
+ const {fetch: envFetch, Request, Response} = env;
3190
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
3113
3191
  const isRequestSupported = isFunction(Request);
3114
3192
  const isResponseSupported = isFunction(Response);
3115
3193
 
@@ -3212,6 +3290,8 @@ const factory = (env) => {
3212
3290
  fetchOptions
3213
3291
  } = resolveConfig(config);
3214
3292
 
3293
+ let _fetch = envFetch || fetch;
3294
+
3215
3295
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3216
3296
 
3217
3297
  let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
@@ -3271,7 +3351,7 @@ const factory = (env) => {
3271
3351
 
3272
3352
  request = isRequestSupported && new Request(url, resolvedOptions);
3273
3353
 
3274
- let response = await (isRequestSupported ? fetch(request, fetchOptions) : fetch(url, resolvedOptions));
3354
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
3275
3355
 
3276
3356
  const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3277
3357
 
@@ -3319,14 +3399,14 @@ const factory = (env) => {
3319
3399
 
3320
3400
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3321
3401
  throw Object.assign(
3322
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3402
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
3323
3403
  {
3324
3404
  cause: err.cause || err
3325
3405
  }
3326
3406
  )
3327
3407
  }
3328
3408
 
3329
- throw AxiosError.from(err, err && err.code, config, request);
3409
+ throw AxiosError.from(err, err && err.code, config, request, err && err.response);
3330
3410
  }
3331
3411
  }
3332
3412
  };
@@ -3334,12 +3414,8 @@ const factory = (env) => {
3334
3414
  const seedCache = new Map();
3335
3415
 
3336
3416
  const getFetch = (config) => {
3337
- let env = utils$1.merge.call({
3338
- skipUndefined: true
3339
- }, globalFetchAPI, config ? config.env : null);
3340
-
3417
+ let env = (config && config.env) || {};
3341
3418
  const {fetch, Request, Response} = env;
3342
-
3343
3419
  const seeds = [
3344
3420
  Request, Response, fetch
3345
3421
  ];
@@ -3361,6 +3437,15 @@ const getFetch = (config) => {
3361
3437
 
3362
3438
  getFetch();
3363
3439
 
3440
+ /**
3441
+ * Known adapters mapping.
3442
+ * Provides environment-specific adapters for Axios:
3443
+ * - `http` for Node.js
3444
+ * - `xhr` for browsers
3445
+ * - `fetch` for fetch API-based requests
3446
+ *
3447
+ * @type {Object<string, Function|Object>}
3448
+ */
3364
3449
  const knownAdapters = {
3365
3450
  http: httpAdapter,
3366
3451
  xhr: xhrAdapter,
@@ -3369,71 +3454,107 @@ const knownAdapters = {
3369
3454
  }
3370
3455
  };
3371
3456
 
3457
+ // Assign adapter names for easier debugging and identification
3372
3458
  utils$1.forEach(knownAdapters, (fn, value) => {
3373
3459
  if (fn) {
3374
3460
  try {
3375
- Object.defineProperty(fn, 'name', {value});
3461
+ Object.defineProperty(fn, 'name', { value });
3376
3462
  } catch (e) {
3377
3463
  // eslint-disable-next-line no-empty
3378
3464
  }
3379
- Object.defineProperty(fn, 'adapterName', {value});
3465
+ Object.defineProperty(fn, 'adapterName', { value });
3380
3466
  }
3381
3467
  });
3382
3468
 
3469
+ /**
3470
+ * Render a rejection reason string for unknown or unsupported adapters
3471
+ *
3472
+ * @param {string} reason
3473
+ * @returns {string}
3474
+ */
3383
3475
  const renderReason = (reason) => `- ${reason}`;
3384
3476
 
3477
+ /**
3478
+ * Check if the adapter is resolved (function, null, or false)
3479
+ *
3480
+ * @param {Function|null|false} adapter
3481
+ * @returns {boolean}
3482
+ */
3385
3483
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3386
3484
 
3387
- var adapters = {
3388
- getAdapter: (adapters, config) => {
3389
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3390
-
3391
- const {length} = adapters;
3392
- let nameOrAdapter;
3393
- let adapter;
3485
+ /**
3486
+ * Get the first suitable adapter from the provided list.
3487
+ * Tries each adapter in order until a supported one is found.
3488
+ * Throws an AxiosError if no adapter is suitable.
3489
+ *
3490
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
3491
+ * @param {Object} config - Axios request configuration
3492
+ * @throws {AxiosError} If no suitable adapter is available
3493
+ * @returns {Function} The resolved adapter function
3494
+ */
3495
+ function getAdapter(adapters, config) {
3496
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3394
3497
 
3395
- const rejectedReasons = {};
3498
+ const { length } = adapters;
3499
+ let nameOrAdapter;
3500
+ let adapter;
3396
3501
 
3397
- for (let i = 0; i < length; i++) {
3398
- nameOrAdapter = adapters[i];
3399
- let id;
3502
+ const rejectedReasons = {};
3400
3503
 
3401
- adapter = nameOrAdapter;
3504
+ for (let i = 0; i < length; i++) {
3505
+ nameOrAdapter = adapters[i];
3506
+ let id;
3402
3507
 
3403
- if (!isResolvedHandle(nameOrAdapter)) {
3404
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3508
+ adapter = nameOrAdapter;
3405
3509
 
3406
- if (adapter === undefined) {
3407
- throw new AxiosError(`Unknown adapter '${id}'`);
3408
- }
3409
- }
3510
+ if (!isResolvedHandle(nameOrAdapter)) {
3511
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3410
3512
 
3411
- if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3412
- break;
3513
+ if (adapter === undefined) {
3514
+ throw new AxiosError(`Unknown adapter '${id}'`);
3413
3515
  }
3516
+ }
3414
3517
 
3415
- rejectedReasons[id || '#' + i] = adapter;
3518
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3519
+ break;
3416
3520
  }
3417
3521
 
3418
- if (!adapter) {
3522
+ rejectedReasons[id || '#' + i] = adapter;
3523
+ }
3419
3524
 
3420
- const reasons = Object.entries(rejectedReasons)
3421
- .map(([id, state]) => `adapter ${id} ` +
3422
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
3423
- );
3525
+ if (!adapter) {
3526
+ const reasons = Object.entries(rejectedReasons)
3527
+ .map(([id, state]) => `adapter ${id} ` +
3528
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3529
+ );
3424
3530
 
3425
- let s = length ?
3426
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3427
- 'as no adapter specified';
3531
+ let s = length ?
3532
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3533
+ 'as no adapter specified';
3428
3534
 
3429
- throw new AxiosError(
3430
- `There is no suitable adapter to dispatch the request ` + s,
3431
- 'ERR_NOT_SUPPORT'
3432
- );
3433
- }
3535
+ throw new AxiosError(
3536
+ `There is no suitable adapter to dispatch the request ` + s,
3537
+ 'ERR_NOT_SUPPORT'
3538
+ );
3539
+ }
3434
3540
 
3435
- return adapter;
3436
- },
3541
+ return adapter;
3542
+ }
3543
+
3544
+ /**
3545
+ * Exports Axios adapters and utility to resolve an adapter
3546
+ */
3547
+ var adapters = {
3548
+ /**
3549
+ * Resolve an adapter from a list of adapter names or functions.
3550
+ * @type {Function}
3551
+ */
3552
+ getAdapter,
3553
+
3554
+ /**
3555
+ * Exposes all known adapters
3556
+ * @type {Object<string, Function|Object>}
3557
+ */
3437
3558
  adapters: knownAdapters
3438
3559
  };
3439
3560
 
@@ -3510,7 +3631,7 @@ function dispatchRequest(config) {
3510
3631
  });
3511
3632
  }
3512
3633
 
3513
- const VERSION = "1.12.1";
3634
+ const VERSION = "1.13.5";
3514
3635
 
3515
3636
  const validators$1 = {};
3516
3637
 
@@ -3678,7 +3799,8 @@ class Axios {
3678
3799
  validator.assertOptions(transitional, {
3679
3800
  silentJSONParsing: validators.transitional(validators.boolean),
3680
3801
  forcedJSONParsing: validators.transitional(validators.boolean),
3681
- clarifyTimeoutError: validators.transitional(validators.boolean)
3802
+ clarifyTimeoutError: validators.transitional(validators.boolean),
3803
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
3682
3804
  }, false);
3683
3805
  }
3684
3806
 
@@ -3735,7 +3857,14 @@ class Axios {
3735
3857
 
3736
3858
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3737
3859
 
3738
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3860
+ const transitional = config.transitional || transitionalDefaults;
3861
+ const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
3862
+
3863
+ if (legacyInterceptorReqResOrdering) {
3864
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3865
+ } else {
3866
+ requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3867
+ }
3739
3868
  });
3740
3869
 
3741
3870
  const responseInterceptorChain = [];
@@ -3766,8 +3895,6 @@ class Axios {
3766
3895
 
3767
3896
  let newConfig = config;
3768
3897
 
3769
- i = 0;
3770
-
3771
3898
  while (i < len) {
3772
3899
  const onFulfilled = requestInterceptorChain[i++];
3773
3900
  const onRejected = requestInterceptorChain[i++];
@@ -3972,7 +4099,7 @@ class CancelToken {
3972
4099
  *
3973
4100
  * ```js
3974
4101
  * function f(x, y, z) {}
3975
- * var args = [1, 2, 3];
4102
+ * const args = [1, 2, 3];
3976
4103
  * f.apply(null, args);
3977
4104
  * ```
3978
4105
  *
@@ -4067,6 +4194,12 @@ const HttpStatusCode = {
4067
4194
  LoopDetected: 508,
4068
4195
  NotExtended: 510,
4069
4196
  NetworkAuthenticationRequired: 511,
4197
+ WebServerIsDown: 521,
4198
+ ConnectionTimedOut: 522,
4199
+ OriginIsUnreachable: 523,
4200
+ TimeoutOccurred: 524,
4201
+ SslHandshakeFailed: 525,
4202
+ InvalidSslCertificate: 526,
4070
4203
  };
4071
4204
 
4072
4205
  Object.entries(HttpStatusCode).forEach(([key, value]) => {