@xchainjs/xchain-aggregator 2.3.1 → 2.3.3

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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Network } from '@xchainjs/xchain-client';
2
- import { CachedValue, isSynthAsset, isTradeAsset, CryptoAmount, baseAmount, isSecuredAsset, assetToString, eqAsset, assetFromStringEx, assetFromString, isTokenAsset } from '@xchainjs/xchain-util';
2
+ import { CachedValue, isSynthAsset, isTradeAsset, CryptoAmount, baseAmount, isSecuredAsset, assetToString, eqAsset, assetFromStringEx, isTokenAsset, assetFromString } from '@xchainjs/xchain-util';
3
3
  import { SwapSDK } from '@chainflip/sdk/swap';
4
4
  import { assetUSDC, ThorchainCache, Thornode, ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
5
5
  import { AssetCacao, MAYAChain } from '@xchainjs/xchain-mayachain';
@@ -40,7 +40,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
40
40
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
41
41
  };
42
42
 
43
- const SupportedProtocols = ['Thorchain', 'Mayachain', 'Chainflip'];
43
+ const SupportedProtocols = ['Thorchain', 'Mayachain', 'Chainflip', 'OneClick'];
44
44
  const DEFAULT_CONFIG = {
45
45
  protocols: SupportedProtocols,
46
46
  network: Network.Mainnet,
@@ -350,7 +350,7 @@ const { isArray } = Array;
350
350
  *
351
351
  * @returns {boolean} True if the value is undefined, otherwise false
352
352
  */
353
- const isUndefined = typeOfTest("undefined");
353
+ const isUndefined = typeOfTest('undefined');
354
354
 
355
355
  /**
356
356
  * Determine if a value is a Buffer
@@ -377,7 +377,7 @@ function isBuffer(val) {
377
377
  *
378
378
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
379
379
  */
380
- const isArrayBuffer = kindOfTest("ArrayBuffer");
380
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
381
381
 
382
382
  /**
383
383
  * Determine if a value is a view on an ArrayBuffer
@@ -388,7 +388,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
388
388
  */
389
389
  function isArrayBufferView(val) {
390
390
  let result;
391
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
391
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
392
392
  result = ArrayBuffer.isView(val);
393
393
  } else {
394
394
  result = val && val.buffer && isArrayBuffer(val.buffer);
@@ -403,7 +403,7 @@ function isArrayBufferView(val) {
403
403
  *
404
404
  * @returns {boolean} True if value is a String, otherwise false
405
405
  */
406
- const isString = typeOfTest("string");
406
+ const isString = typeOfTest('string');
407
407
 
408
408
  /**
409
409
  * Determine if a value is a Function
@@ -411,7 +411,7 @@ const isString = typeOfTest("string");
411
411
  * @param {*} val The value to test
412
412
  * @returns {boolean} True if value is a Function, otherwise false
413
413
  */
414
- const isFunction$1 = typeOfTest("function");
414
+ const isFunction$1 = typeOfTest('function');
415
415
 
416
416
  /**
417
417
  * Determine if a value is a Number
@@ -420,7 +420,7 @@ const isFunction$1 = typeOfTest("function");
420
420
  *
421
421
  * @returns {boolean} True if value is a Number, otherwise false
422
422
  */
423
- const isNumber = typeOfTest("number");
423
+ const isNumber = typeOfTest('number');
424
424
 
425
425
  /**
426
426
  * Determine if a value is an Object
@@ -429,7 +429,7 @@ const isNumber = typeOfTest("number");
429
429
  *
430
430
  * @returns {boolean} True if value is an Object, otherwise false
431
431
  */
432
- const isObject = (thing) => thing !== null && typeof thing === "object";
432
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
433
433
 
434
434
  /**
435
435
  * Determine if a value is a Boolean
@@ -447,7 +447,7 @@ const isBoolean = (thing) => thing === true || thing === false;
447
447
  * @returns {boolean} True if value is a plain Object, otherwise false
448
448
  */
449
449
  const isPlainObject = (val) => {
450
- if (kindOf(val) !== "object") {
450
+ if (kindOf(val) !== 'object') {
451
451
  return false;
452
452
  }
453
453
 
@@ -475,10 +475,7 @@ const isEmptyObject = (val) => {
475
475
  }
476
476
 
477
477
  try {
478
- return (
479
- Object.keys(val).length === 0 &&
480
- Object.getPrototypeOf(val) === Object.prototype
481
- );
478
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
482
479
  } catch (e) {
483
480
  // Fallback for any other objects that might cause RangeError with Object.keys()
484
481
  return false;
@@ -492,7 +489,7 @@ const isEmptyObject = (val) => {
492
489
  *
493
490
  * @returns {boolean} True if value is a Date, otherwise false
494
491
  */
495
- const isDate = kindOfTest("Date");
492
+ const isDate = kindOfTest('Date');
496
493
 
497
494
  /**
498
495
  * Determine if a value is a File
@@ -501,7 +498,32 @@ const isDate = kindOfTest("Date");
501
498
  *
502
499
  * @returns {boolean} True if value is a File, otherwise false
503
500
  */
504
- const isFile = kindOfTest("File");
501
+ const isFile = kindOfTest('File');
502
+
503
+ /**
504
+ * Determine if a value is a React Native Blob
505
+ * React Native "blob": an object with a `uri` attribute. Optionally, it can
506
+ * also have a `name` and `type` attribute to specify filename and content type
507
+ *
508
+ * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
509
+ *
510
+ * @param {*} value The value to test
511
+ *
512
+ * @returns {boolean} True if value is a React Native Blob, otherwise false
513
+ */
514
+ const isReactNativeBlob = (value) => {
515
+ return !!(value && typeof value.uri !== 'undefined');
516
+ };
517
+
518
+ /**
519
+ * Determine if environment is React Native
520
+ * ReactNative `FormData` has a non-standard `getParts()` method
521
+ *
522
+ * @param {*} formData The formData to test
523
+ *
524
+ * @returns {boolean} True if environment is React Native, otherwise false
525
+ */
526
+ const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
505
527
 
506
528
  /**
507
529
  * Determine if a value is a Blob
@@ -510,7 +532,7 @@ const isFile = kindOfTest("File");
510
532
  *
511
533
  * @returns {boolean} True if value is a Blob, otherwise false
512
534
  */
513
- const isBlob = kindOfTest("Blob");
535
+ const isBlob = kindOfTest('Blob');
514
536
 
515
537
  /**
516
538
  * Determine if a value is a FileList
@@ -519,7 +541,7 @@ const isBlob = kindOfTest("Blob");
519
541
  *
520
542
  * @returns {boolean} True if value is a File, otherwise false
521
543
  */
522
- const isFileList = kindOfTest("FileList");
544
+ const isFileList = kindOfTest('FileList');
523
545
 
524
546
  /**
525
547
  * Determine if a value is a Stream
@@ -537,18 +559,28 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
537
559
  *
538
560
  * @returns {boolean} True if value is an FormData, otherwise false
539
561
  */
562
+ function getGlobal() {
563
+ if (typeof globalThis !== 'undefined') return globalThis;
564
+ if (typeof self !== 'undefined') return self;
565
+ if (typeof window !== 'undefined') return window;
566
+ if (typeof global !== 'undefined') return global;
567
+ return {};
568
+ }
569
+
570
+ const G = getGlobal();
571
+ const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
572
+
540
573
  const isFormData = (thing) => {
541
- let kind;
542
- return (
543
- thing &&
544
- ((typeof FormData === "function" && thing instanceof FormData) ||
545
- (isFunction$1(thing.append) &&
546
- ((kind = kindOf(thing)) === "formdata" ||
547
- // detect form-data instance
548
- (kind === "object" &&
549
- isFunction$1(thing.toString) &&
550
- thing.toString() === "[object FormData]"))))
551
- );
574
+ if (!thing) return false;
575
+ if (FormDataCtor && thing instanceof FormDataCtor) return true;
576
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
577
+ const proto = getPrototypeOf(thing);
578
+ if (!proto || proto === Object.prototype) return false;
579
+ if (!isFunction$1(thing.append)) return false;
580
+ const kind = kindOf(thing);
581
+ return kind === 'formdata' ||
582
+ // detect form-data instance
583
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]');
552
584
  };
553
585
 
554
586
  /**
@@ -558,13 +590,13 @@ const isFormData = (thing) => {
558
590
  *
559
591
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
560
592
  */
561
- const isURLSearchParams = kindOfTest("URLSearchParams");
593
+ const isURLSearchParams = kindOfTest('URLSearchParams');
562
594
 
563
595
  const [isReadableStream, isRequest, isResponse, isHeaders] = [
564
- "ReadableStream",
565
- "Request",
566
- "Response",
567
- "Headers",
596
+ 'ReadableStream',
597
+ 'Request',
598
+ 'Response',
599
+ 'Headers',
568
600
  ].map(kindOfTest);
569
601
 
570
602
  /**
@@ -574,9 +606,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
574
606
  *
575
607
  * @returns {String} The String freed of excess whitespace
576
608
  */
577
- const trim = (str) =>
578
- str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
579
-
609
+ const trim = (str) => {
610
+ return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
611
+ };
580
612
  /**
581
613
  * Iterate over an Array or an Object invoking a function for each item.
582
614
  *
@@ -595,7 +627,7 @@ const trim = (str) =>
595
627
  */
596
628
  function forEach(obj, fn, { allOwnKeys = false } = {}) {
597
629
  // Don't bother if no value provided
598
- if (obj === null || typeof obj === "undefined") {
630
+ if (obj === null || typeof obj === 'undefined') {
599
631
  return;
600
632
  }
601
633
 
@@ -603,7 +635,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
603
635
  let l;
604
636
 
605
637
  // Force an array if not already something iterable
606
- if (typeof obj !== "object") {
638
+ if (typeof obj !== 'object') {
607
639
  /*eslint no-param-reassign:0*/
608
640
  obj = [obj];
609
641
  }
@@ -620,9 +652,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
620
652
  }
621
653
 
622
654
  // Iterate over object keys
623
- const keys = allOwnKeys
624
- ? Object.getOwnPropertyNames(obj)
625
- : Object.keys(obj);
655
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
626
656
  const len = keys.length;
627
657
  let key;
628
658
 
@@ -633,6 +663,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
633
663
  }
634
664
  }
635
665
 
666
+ /**
667
+ * Finds a key in an object, case-insensitive, returning the actual key name.
668
+ * Returns null if the object is a Buffer or if no match is found.
669
+ *
670
+ * @param {Object} obj - The object to search.
671
+ * @param {string} key - The key to find (case-insensitive).
672
+ * @returns {?string} The actual key name if found, otherwise null.
673
+ */
636
674
  function findKey(obj, key) {
637
675
  if (isBuffer(obj)) {
638
676
  return null;
@@ -653,16 +691,11 @@ function findKey(obj, key) {
653
691
 
654
692
  const _global = (() => {
655
693
  /*eslint no-undef:0*/
656
- if (typeof globalThis !== "undefined") return globalThis;
657
- return typeof self !== "undefined"
658
- ? self
659
- : typeof window !== "undefined"
660
- ? window
661
- : global;
694
+ if (typeof globalThis !== 'undefined') return globalThis;
695
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
662
696
  })();
663
697
 
664
- const isContextDefined = (context) =>
665
- !isUndefined(context) && context !== _global;
698
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
666
699
 
667
700
  /**
668
701
  * Accepts varargs expecting each argument to be an object, then
@@ -687,7 +720,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
687
720
  const result = {};
688
721
  const assignValue = (val, key) => {
689
722
  // Skip dangerous property names to prevent prototype pollution
690
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
723
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
691
724
  return;
692
725
  }
693
726
 
@@ -740,7 +773,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
740
773
  });
741
774
  }
742
775
  },
743
- { allOwnKeys },
776
+ { allOwnKeys }
744
777
  );
745
778
  return a;
746
779
  };
@@ -769,17 +802,14 @@ const stripBOM = (content) => {
769
802
  * @returns {void}
770
803
  */
771
804
  const inherits = (constructor, superConstructor, props, descriptors) => {
772
- constructor.prototype = Object.create(
773
- superConstructor.prototype,
774
- descriptors,
775
- );
776
- Object.defineProperty(constructor.prototype, "constructor", {
805
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
806
+ Object.defineProperty(constructor.prototype, 'constructor', {
777
807
  value: constructor,
778
808
  writable: true,
779
809
  enumerable: false,
780
810
  configurable: true,
781
811
  });
782
- Object.defineProperty(constructor, "super", {
812
+ Object.defineProperty(constructor, 'super', {
783
813
  value: superConstructor.prototype,
784
814
  });
785
815
  props && Object.assign(constructor.prototype, props);
@@ -809,20 +839,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
809
839
  i = props.length;
810
840
  while (i-- > 0) {
811
841
  prop = props[i];
812
- if (
813
- (!propFilter || propFilter(prop, sourceObj, destObj)) &&
814
- !merged[prop]
815
- ) {
842
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
816
843
  destObj[prop] = sourceObj[prop];
817
844
  merged[prop] = true;
818
845
  }
819
846
  }
820
847
  sourceObj = filter !== false && getPrototypeOf(sourceObj);
821
- } while (
822
- sourceObj &&
823
- (!filter || filter(sourceObj, destObj)) &&
824
- sourceObj !== Object.prototype
825
- );
848
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
826
849
 
827
850
  return destObj;
828
851
  };
@@ -879,7 +902,7 @@ const isTypedArray = ((TypedArray) => {
879
902
  return (thing) => {
880
903
  return TypedArray && thing instanceof TypedArray;
881
904
  };
882
- })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
905
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
883
906
 
884
907
  /**
885
908
  * For each entry in the object, call the function with the key and value.
@@ -922,14 +945,12 @@ const matchAll = (regExp, str) => {
922
945
  };
923
946
 
924
947
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
925
- const isHTMLForm = kindOfTest("HTMLFormElement");
948
+ const isHTMLForm = kindOfTest('HTMLFormElement');
926
949
 
927
950
  const toCamelCase = (str) => {
928
- return str
929
- .toLowerCase()
930
- .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
931
- return p1.toUpperCase() + p2;
932
- });
951
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
952
+ return p1.toUpperCase() + p2;
953
+ });
933
954
  };
934
955
 
935
956
  /* Creating a function that will check if an object has a property. */
@@ -946,7 +967,7 @@ const hasOwnProperty = (
946
967
  *
947
968
  * @returns {boolean} True if value is a RegExp object, otherwise false
948
969
  */
949
- const isRegExp = kindOfTest("RegExp");
970
+ const isRegExp = kindOfTest('RegExp');
950
971
 
951
972
  const reduceDescriptors = (obj, reducer) => {
952
973
  const descriptors = Object.getOwnPropertyDescriptors(obj);
@@ -970,10 +991,7 @@ const reduceDescriptors = (obj, reducer) => {
970
991
  const freezeMethods = (obj) => {
971
992
  reduceDescriptors(obj, (descriptor, name) => {
972
993
  // skip restricted props in strict mode
973
- if (
974
- isFunction$1(obj) &&
975
- ["arguments", "caller", "callee"].indexOf(name) !== -1
976
- ) {
994
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
977
995
  return false;
978
996
  }
979
997
 
@@ -983,7 +1001,7 @@ const freezeMethods = (obj) => {
983
1001
 
984
1002
  descriptor.enumerable = false;
985
1003
 
986
- if ("writable" in descriptor) {
1004
+ if ('writable' in descriptor) {
987
1005
  descriptor.writable = false;
988
1006
  return;
989
1007
  }
@@ -996,6 +1014,14 @@ const freezeMethods = (obj) => {
996
1014
  });
997
1015
  };
998
1016
 
1017
+ /**
1018
+ * Converts an array or a delimited string into an object set with values as keys and true as values.
1019
+ * Useful for fast membership checks.
1020
+ *
1021
+ * @param {Array|string} arrayOrString - The array or string to convert.
1022
+ * @param {string} delimiter - The delimiter to use if input is a string.
1023
+ * @returns {Object} An object with keys from the array or string, values set to true.
1024
+ */
999
1025
  const toObjectSet = (arrayOrString, delimiter) => {
1000
1026
  const obj = {};
1001
1027
 
@@ -1005,9 +1031,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
1005
1031
  });
1006
1032
  };
1007
1033
 
1008
- isArray(arrayOrString)
1009
- ? define(arrayOrString)
1010
- : define(String(arrayOrString).split(delimiter));
1034
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
1011
1035
 
1012
1036
  return obj;
1013
1037
  };
@@ -1015,9 +1039,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
1015
1039
  const noop = () => {};
1016
1040
 
1017
1041
  const toFiniteNumber = (value, defaultValue) => {
1018
- return value != null && Number.isFinite((value = +value))
1019
- ? value
1020
- : defaultValue;
1042
+ return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
1021
1043
  };
1022
1044
 
1023
1045
  /**
@@ -1031,11 +1053,17 @@ function isSpecCompliantForm(thing) {
1031
1053
  return !!(
1032
1054
  thing &&
1033
1055
  isFunction$1(thing.append) &&
1034
- thing[toStringTag] === "FormData" &&
1056
+ thing[toStringTag] === 'FormData' &&
1035
1057
  thing[iterator]
1036
1058
  );
1037
1059
  }
1038
1060
 
1061
+ /**
1062
+ * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
1063
+ *
1064
+ * @param {Object} obj - The object to convert.
1065
+ * @returns {Object} The JSON-compatible object.
1066
+ */
1039
1067
  const toJSONObject = (obj) => {
1040
1068
  const stack = new Array(10);
1041
1069
 
@@ -1050,7 +1078,7 @@ const toJSONObject = (obj) => {
1050
1078
  return source;
1051
1079
  }
1052
1080
 
1053
- if (!("toJSON" in source)) {
1081
+ if (!('toJSON' in source)) {
1054
1082
  stack[i] = source;
1055
1083
  const target = isArray(source) ? [] : {};
1056
1084
 
@@ -1071,8 +1099,20 @@ const toJSONObject = (obj) => {
1071
1099
  return visit(obj, 0);
1072
1100
  };
1073
1101
 
1074
- const isAsyncFn = kindOfTest("AsyncFunction");
1102
+ /**
1103
+ * Determines if a value is an async function.
1104
+ *
1105
+ * @param {*} thing - The value to test.
1106
+ * @returns {boolean} True if value is an async function, otherwise false.
1107
+ */
1108
+ const isAsyncFn = kindOfTest('AsyncFunction');
1075
1109
 
1110
+ /**
1111
+ * Determines if a value is thenable (has then and catch methods).
1112
+ *
1113
+ * @param {*} thing - The value to test.
1114
+ * @returns {boolean} True if value is thenable, otherwise false.
1115
+ */
1076
1116
  const isThenable = (thing) =>
1077
1117
  thing &&
1078
1118
  (isObject(thing) || isFunction$1(thing)) &&
@@ -1082,6 +1122,14 @@ const isThenable = (thing) =>
1082
1122
  // original code
1083
1123
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
1084
1124
 
1125
+ /**
1126
+ * Provides a cross-platform setImmediate implementation.
1127
+ * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
1128
+ *
1129
+ * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
1130
+ * @param {boolean} postMessageSupported - Whether postMessage is supported.
1131
+ * @returns {Function} A function to schedule a callback asynchronously.
1132
+ */
1085
1133
  const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1086
1134
  if (setImmediateSupported) {
1087
1135
  return setImmediate;
@@ -1090,27 +1138,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1090
1138
  return postMessageSupported
1091
1139
  ? ((token, callbacks) => {
1092
1140
  _global.addEventListener(
1093
- "message",
1141
+ 'message',
1094
1142
  ({ source, data }) => {
1095
1143
  if (source === _global && data === token) {
1096
1144
  callbacks.length && callbacks.shift()();
1097
1145
  }
1098
1146
  },
1099
- false,
1147
+ false
1100
1148
  );
1101
1149
 
1102
1150
  return (cb) => {
1103
1151
  callbacks.push(cb);
1104
- _global.postMessage(token, "*");
1152
+ _global.postMessage(token, '*');
1105
1153
  };
1106
1154
  })(`axios@${Math.random()}`, [])
1107
1155
  : (cb) => setTimeout(cb);
1108
- })(typeof setImmediate === "function", isFunction$1(_global.postMessage));
1156
+ })(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
1109
1157
 
1158
+ /**
1159
+ * Schedules a microtask or asynchronous callback as soon as possible.
1160
+ * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
1161
+ *
1162
+ * @type {Function}
1163
+ */
1110
1164
  const asap =
1111
- typeof queueMicrotask !== "undefined"
1165
+ typeof queueMicrotask !== 'undefined'
1112
1166
  ? queueMicrotask.bind(_global)
1113
- : (typeof process !== "undefined" && process.nextTick) || _setImmediate;
1167
+ : (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
1114
1168
 
1115
1169
  // *********************
1116
1170
 
@@ -1135,6 +1189,8 @@ var utils$1 = {
1135
1189
  isUndefined,
1136
1190
  isDate,
1137
1191
  isFile,
1192
+ isReactNativeBlob,
1193
+ isReactNative,
1138
1194
  isBlob,
1139
1195
  isRegExp,
1140
1196
  isFunction: isFunction$1,
@@ -1177,57 +1233,74 @@ var utils$1 = {
1177
1233
  };
1178
1234
 
1179
1235
  let AxiosError$1 = class AxiosError extends Error {
1180
- static from(error, code, config, request, response, customProps) {
1181
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1182
- axiosError.cause = error;
1183
- axiosError.name = error.name;
1184
- customProps && Object.assign(axiosError, customProps);
1185
- return axiosError;
1186
- }
1236
+ static from(error, code, config, request, response, customProps) {
1237
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1238
+ axiosError.cause = error;
1239
+ axiosError.name = error.name;
1187
1240
 
1188
- /**
1189
- * Create an Error with the specified message, config, error code, request and response.
1190
- *
1191
- * @param {string} message The error message.
1192
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
1193
- * @param {Object} [config] The config.
1194
- * @param {Object} [request] The request.
1195
- * @param {Object} [response] The response.
1196
- *
1197
- * @returns {Error} The created error.
1198
- */
1199
- constructor(message, code, config, request, response) {
1200
- super(message);
1201
- this.name = 'AxiosError';
1202
- this.isAxiosError = true;
1203
- code && (this.code = code);
1204
- config && (this.config = config);
1205
- request && (this.request = request);
1206
- if (response) {
1207
- this.response = response;
1208
- this.status = response.status;
1209
- }
1241
+ // Preserve status from the original error if not already set from response
1242
+ if (error.status != null && axiosError.status == null) {
1243
+ axiosError.status = error.status;
1210
1244
  }
1211
1245
 
1212
- toJSON() {
1213
- return {
1214
- // Standard
1215
- message: this.message,
1216
- name: this.name,
1217
- // Microsoft
1218
- description: this.description,
1219
- number: this.number,
1220
- // Mozilla
1221
- fileName: this.fileName,
1222
- lineNumber: this.lineNumber,
1223
- columnNumber: this.columnNumber,
1224
- stack: this.stack,
1225
- // Axios
1226
- config: utils$1.toJSONObject(this.config),
1227
- code: this.code,
1228
- status: this.status,
1229
- };
1246
+ customProps && Object.assign(axiosError, customProps);
1247
+ return axiosError;
1248
+ }
1249
+
1250
+ /**
1251
+ * Create an Error with the specified message, config, error code, request and response.
1252
+ *
1253
+ * @param {string} message The error message.
1254
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1255
+ * @param {Object} [config] The config.
1256
+ * @param {Object} [request] The request.
1257
+ * @param {Object} [response] The response.
1258
+ *
1259
+ * @returns {Error} The created error.
1260
+ */
1261
+ constructor(message, code, config, request, response) {
1262
+ super(message);
1263
+
1264
+ // Make message enumerable to maintain backward compatibility
1265
+ // The native Error constructor sets message as non-enumerable,
1266
+ // but axios < v1.13.3 had it as enumerable
1267
+ Object.defineProperty(this, 'message', {
1268
+ value: message,
1269
+ enumerable: true,
1270
+ writable: true,
1271
+ configurable: true,
1272
+ });
1273
+
1274
+ this.name = 'AxiosError';
1275
+ this.isAxiosError = true;
1276
+ code && (this.code = code);
1277
+ config && (this.config = config);
1278
+ request && (this.request = request);
1279
+ if (response) {
1280
+ this.response = response;
1281
+ this.status = response.status;
1230
1282
  }
1283
+ }
1284
+
1285
+ toJSON() {
1286
+ return {
1287
+ // Standard
1288
+ message: this.message,
1289
+ name: this.name,
1290
+ // Microsoft
1291
+ description: this.description,
1292
+ number: this.number,
1293
+ // Mozilla
1294
+ fileName: this.fileName,
1295
+ lineNumber: this.lineNumber,
1296
+ columnNumber: this.columnNumber,
1297
+ stack: this.stack,
1298
+ // Axios
1299
+ config: utils$1.toJSONObject(this.config),
1300
+ code: this.code,
1301
+ status: this.status,
1302
+ };
1303
+ }
1231
1304
  };
1232
1305
 
1233
1306
  // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
@@ -1243,6 +1316,7 @@ AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1243
1316
  AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
1244
1317
  AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1245
1318
  AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
1319
+ AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
1246
1320
 
1247
1321
  // eslint-disable-next-line strict
1248
1322
  var httpAdapter = null;
@@ -1280,11 +1354,14 @@ function removeBrackets(key) {
1280
1354
  */
1281
1355
  function renderKey(path, key, dots) {
1282
1356
  if (!path) return key;
1283
- return path.concat(key).map(function each(token, i) {
1284
- // eslint-disable-next-line no-param-reassign
1285
- token = removeBrackets(token);
1286
- return !dots && i ? '[' + token + ']' : token;
1287
- }).join(dots ? '.' : '');
1357
+ return path
1358
+ .concat(key)
1359
+ .map(function each(token, i) {
1360
+ // eslint-disable-next-line no-param-reassign
1361
+ token = removeBrackets(token);
1362
+ return !dots && i ? '[' + token + ']' : token;
1363
+ })
1364
+ .join(dots ? '.' : '');
1288
1365
  }
1289
1366
 
1290
1367
  /**
@@ -1334,21 +1411,27 @@ function toFormData$1(obj, formData, options) {
1334
1411
  formData = formData || new (FormData)();
1335
1412
 
1336
1413
  // eslint-disable-next-line no-param-reassign
1337
- options = utils$1.toFlatObject(options, {
1338
- metaTokens: true,
1339
- dots: false,
1340
- indexes: false
1341
- }, false, function defined(option, source) {
1342
- // eslint-disable-next-line no-eq-null,eqeqeq
1343
- return !utils$1.isUndefined(source[option]);
1344
- });
1414
+ options = utils$1.toFlatObject(
1415
+ options,
1416
+ {
1417
+ metaTokens: true,
1418
+ dots: false,
1419
+ indexes: false,
1420
+ },
1421
+ false,
1422
+ function defined(option, source) {
1423
+ // eslint-disable-next-line no-eq-null,eqeqeq
1424
+ return !utils$1.isUndefined(source[option]);
1425
+ }
1426
+ );
1345
1427
 
1346
1428
  const metaTokens = options.metaTokens;
1347
1429
  // eslint-disable-next-line no-use-before-define
1348
1430
  const visitor = options.visitor || defaultVisitor;
1349
1431
  const dots = options.dots;
1350
1432
  const indexes = options.indexes;
1351
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1433
+ const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
1434
+ const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
1352
1435
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1353
1436
 
1354
1437
  if (!utils$1.isFunction(visitor)) {
@@ -1390,6 +1473,11 @@ function toFormData$1(obj, formData, options) {
1390
1473
  function defaultVisitor(value, key, path) {
1391
1474
  let arr = value;
1392
1475
 
1476
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
1477
+ formData.append(renderKey(path, key, dots), convertValue(value));
1478
+ return false;
1479
+ }
1480
+
1393
1481
  if (value && !path && typeof value === 'object') {
1394
1482
  if (utils$1.endsWith(key, '{}')) {
1395
1483
  // eslint-disable-next-line no-param-reassign
@@ -1398,17 +1486,22 @@ function toFormData$1(obj, formData, options) {
1398
1486
  value = JSON.stringify(value);
1399
1487
  } else if (
1400
1488
  (utils$1.isArray(value) && isFlatArray(value)) ||
1401
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1402
- )) {
1489
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
1490
+ ) {
1403
1491
  // eslint-disable-next-line no-param-reassign
1404
1492
  key = removeBrackets(key);
1405
1493
 
1406
1494
  arr.forEach(function each(el, index) {
1407
- !(utils$1.isUndefined(el) || el === null) && formData.append(
1408
- // eslint-disable-next-line no-nested-ternary
1409
- indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1410
- convertValue(el)
1411
- );
1495
+ !(utils$1.isUndefined(el) || el === null) &&
1496
+ formData.append(
1497
+ // eslint-disable-next-line no-nested-ternary
1498
+ indexes === true
1499
+ ? renderKey([key], index, dots)
1500
+ : indexes === null
1501
+ ? key
1502
+ : key + '[]',
1503
+ convertValue(el)
1504
+ );
1412
1505
  });
1413
1506
  return false;
1414
1507
  }
@@ -1428,12 +1521,19 @@ function toFormData$1(obj, formData, options) {
1428
1521
  const exposedHelpers = Object.assign(predicates, {
1429
1522
  defaultVisitor,
1430
1523
  convertValue,
1431
- isVisitable
1524
+ isVisitable,
1432
1525
  });
1433
1526
 
1434
- function build(value, path) {
1527
+ function build(value, path, depth = 0) {
1435
1528
  if (utils$1.isUndefined(value)) return;
1436
1529
 
1530
+ if (depth > maxDepth) {
1531
+ throw new AxiosError$1(
1532
+ 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
1533
+ AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
1534
+ );
1535
+ }
1536
+
1437
1537
  if (stack.indexOf(value) !== -1) {
1438
1538
  throw Error('Circular reference detected in ' + path.join('.'));
1439
1539
  }
@@ -1441,12 +1541,12 @@ function toFormData$1(obj, formData, options) {
1441
1541
  stack.push(value);
1442
1542
 
1443
1543
  utils$1.forEach(value, function each(el, key) {
1444
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1445
- formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1446
- );
1544
+ const result =
1545
+ !(utils$1.isUndefined(el) || el === null) &&
1546
+ visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
1447
1547
 
1448
1548
  if (result === true) {
1449
- build(el, path ? path.concat(key) : [key]);
1549
+ build(el, path ? path.concat(key) : [key], depth + 1);
1450
1550
  }
1451
1551
  });
1452
1552
 
@@ -1478,9 +1578,8 @@ function encode$1(str) {
1478
1578
  ')': '%29',
1479
1579
  '~': '%7E',
1480
1580
  '%20': '+',
1481
- '%00': '\x00'
1482
1581
  };
1483
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1582
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
1484
1583
  return charMap[match];
1485
1584
  });
1486
1585
  }
@@ -1506,29 +1605,33 @@ prototype.append = function append(name, value) {
1506
1605
  };
1507
1606
 
1508
1607
  prototype.toString = function toString(encoder) {
1509
- const _encode = encoder ? function(value) {
1510
- return encoder.call(this, value, encode$1);
1511
- } : encode$1;
1608
+ const _encode = encoder
1609
+ ? function (value) {
1610
+ return encoder.call(this, value, encode$1);
1611
+ }
1612
+ : encode$1;
1512
1613
 
1513
- return this._pairs.map(function each(pair) {
1514
- return _encode(pair[0]) + '=' + _encode(pair[1]);
1515
- }, '').join('&');
1614
+ return this._pairs
1615
+ .map(function each(pair) {
1616
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1617
+ }, '')
1618
+ .join('&');
1516
1619
  };
1517
1620
 
1518
1621
  /**
1519
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1520
- * URI encoded counterparts
1622
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
1623
+ * their plain counterparts (`:`, `$`, `,`, `+`).
1521
1624
  *
1522
1625
  * @param {string} val The value to be encoded.
1523
1626
  *
1524
1627
  * @returns {string} The encoded value.
1525
1628
  */
1526
1629
  function encode(val) {
1527
- return encodeURIComponent(val).
1528
- replace(/%3A/gi, ':').
1529
- replace(/%24/g, '$').
1530
- replace(/%2C/gi, ',').
1531
- replace(/%20/g, '+');
1630
+ return encodeURIComponent(val)
1631
+ .replace(/%3A/gi, ':')
1632
+ .replace(/%24/g, '$')
1633
+ .replace(/%2C/gi, ',')
1634
+ .replace(/%20/g, '+');
1532
1635
  }
1533
1636
 
1534
1637
  /**
@@ -1545,11 +1648,13 @@ function buildURL(url, params, options) {
1545
1648
  return url;
1546
1649
  }
1547
1650
 
1548
- const _encode = options && options.encode || encode;
1651
+ const _encode = (options && options.encode) || encode;
1549
1652
 
1550
- const _options = utils$1.isFunction(options) ? {
1551
- serialize: options
1552
- } : options;
1653
+ const _options = utils$1.isFunction(options)
1654
+ ? {
1655
+ serialize: options,
1656
+ }
1657
+ : options;
1553
1658
 
1554
1659
  const serializeFn = _options && _options.serialize;
1555
1660
 
@@ -1558,13 +1663,13 @@ function buildURL(url, params, options) {
1558
1663
  if (serializeFn) {
1559
1664
  serializedParams = serializeFn(params, _options);
1560
1665
  } else {
1561
- serializedParams = utils$1.isURLSearchParams(params) ?
1562
- params.toString() :
1563
- new AxiosURLSearchParams(params, _options).toString(_encode);
1666
+ serializedParams = utils$1.isURLSearchParams(params)
1667
+ ? params.toString()
1668
+ : new AxiosURLSearchParams(params, _options).toString(_encode);
1564
1669
  }
1565
1670
 
1566
1671
  if (serializedParams) {
1567
- const hashmarkIndex = url.indexOf("#");
1672
+ const hashmarkIndex = url.indexOf('#');
1568
1673
 
1569
1674
  if (hashmarkIndex !== -1) {
1570
1675
  url = url.slice(0, hashmarkIndex);
@@ -1594,7 +1699,7 @@ class InterceptorManager {
1594
1699
  fulfilled,
1595
1700
  rejected,
1596
1701
  synchronous: options ? options.synchronous : false,
1597
- runWhen: options ? options.runWhen : null
1702
+ runWhen: options ? options.runWhen : null,
1598
1703
  });
1599
1704
  return this.handlers.length - 1;
1600
1705
  }
@@ -1646,7 +1751,7 @@ var transitionalDefaults = {
1646
1751
  silentJSONParsing: true,
1647
1752
  forcedJSONParsing: true,
1648
1753
  clarifyTimeoutError: false,
1649
- legacyInterceptorReqResOrdering: true
1754
+ legacyInterceptorReqResOrdering: true,
1650
1755
  };
1651
1756
 
1652
1757
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -1660,14 +1765,14 @@ var platform$1 = {
1660
1765
  classes: {
1661
1766
  URLSearchParams: URLSearchParams$1,
1662
1767
  FormData: FormData$1,
1663
- Blob: Blob$1
1768
+ Blob: Blob$1,
1664
1769
  },
1665
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1770
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
1666
1771
  };
1667
1772
 
1668
1773
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1669
1774
 
1670
- const _navigator = typeof navigator === 'object' && navigator || undefined;
1775
+ const _navigator = (typeof navigator === 'object' && navigator) || undefined;
1671
1776
 
1672
1777
  /**
1673
1778
  * Determine if we're running in a standard browser environment
@@ -1686,7 +1791,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
1686
1791
  *
1687
1792
  * @returns {boolean}
1688
1793
  */
1689
- const hasStandardBrowserEnv = hasBrowserEnv &&
1794
+ const hasStandardBrowserEnv =
1795
+ hasBrowserEnv &&
1690
1796
  (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1691
1797
 
1692
1798
  /**
@@ -1707,7 +1813,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
1707
1813
  );
1708
1814
  })();
1709
1815
 
1710
- const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1816
+ const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
1711
1817
 
1712
1818
  var utils = /*#__PURE__*/Object.freeze({
1713
1819
  __proto__: null,
@@ -1720,12 +1826,12 @@ var utils = /*#__PURE__*/Object.freeze({
1720
1826
 
1721
1827
  var platform = {
1722
1828
  ...utils,
1723
- ...platform$1
1829
+ ...platform$1,
1724
1830
  };
1725
1831
 
1726
1832
  function toURLEncodedForm(data, options) {
1727
1833
  return toFormData$1(data, new platform.classes.URLSearchParams(), {
1728
- visitor: function(value, key, path, helpers) {
1834
+ visitor: function (value, key, path, helpers) {
1729
1835
  if (platform.isNode && utils$1.isBuffer(value)) {
1730
1836
  this.append(key, value.toString('base64'));
1731
1837
  return false;
@@ -1733,7 +1839,7 @@ function toURLEncodedForm(data, options) {
1733
1839
 
1734
1840
  return helpers.defaultVisitor.apply(this, arguments);
1735
1841
  },
1736
- ...options
1842
+ ...options,
1737
1843
  });
1738
1844
  }
1739
1845
 
@@ -1749,7 +1855,7 @@ function parsePropPath(name) {
1749
1855
  // foo.x.y.z
1750
1856
  // foo-x-y-z
1751
1857
  // foo x y z
1752
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1858
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
1753
1859
  return match[0] === '[]' ? '' : match[1] || match[0];
1754
1860
  });
1755
1861
  }
@@ -1793,7 +1899,9 @@ function formDataToJSON(formData) {
1793
1899
 
1794
1900
  if (isLast) {
1795
1901
  if (utils$1.hasOwnProp(target, name)) {
1796
- target[name] = [target[name], value];
1902
+ target[name] = utils$1.isArray(target[name])
1903
+ ? target[name].concat(value)
1904
+ : [target[name], value];
1797
1905
  } else {
1798
1906
  target[name] = value;
1799
1907
  }
@@ -1827,6 +1935,8 @@ function formDataToJSON(formData) {
1827
1935
  return null;
1828
1936
  }
1829
1937
 
1938
+ const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
1939
+
1830
1940
  /**
1831
1941
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1832
1942
  * of the input
@@ -1853,96 +1963,110 @@ function stringifySafely(rawValue, parser, encoder) {
1853
1963
  }
1854
1964
 
1855
1965
  const defaults = {
1856
-
1857
1966
  transitional: transitionalDefaults,
1858
1967
 
1859
1968
  adapter: ['xhr', 'http', 'fetch'],
1860
1969
 
1861
- transformRequest: [function transformRequest(data, headers) {
1862
- const contentType = headers.getContentType() || '';
1863
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
1864
- const isObjectPayload = utils$1.isObject(data);
1865
-
1866
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1867
- data = new FormData(data);
1868
- }
1970
+ transformRequest: [
1971
+ function transformRequest(data, headers) {
1972
+ const contentType = headers.getContentType() || '';
1973
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1974
+ const isObjectPayload = utils$1.isObject(data);
1869
1975
 
1870
- const isFormData = utils$1.isFormData(data);
1871
-
1872
- if (isFormData) {
1873
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1874
- }
1976
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1977
+ data = new FormData(data);
1978
+ }
1875
1979
 
1876
- if (utils$1.isArrayBuffer(data) ||
1877
- utils$1.isBuffer(data) ||
1878
- utils$1.isStream(data) ||
1879
- utils$1.isFile(data) ||
1880
- utils$1.isBlob(data) ||
1881
- utils$1.isReadableStream(data)
1882
- ) {
1883
- return data;
1884
- }
1885
- if (utils$1.isArrayBufferView(data)) {
1886
- return data.buffer;
1887
- }
1888
- if (utils$1.isURLSearchParams(data)) {
1889
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1890
- return data.toString();
1891
- }
1980
+ const isFormData = utils$1.isFormData(data);
1892
1981
 
1893
- let isFileList;
1982
+ if (isFormData) {
1983
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1984
+ }
1894
1985
 
1895
- if (isObjectPayload) {
1896
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1897
- return toURLEncodedForm(data, this.formSerializer).toString();
1986
+ if (
1987
+ utils$1.isArrayBuffer(data) ||
1988
+ utils$1.isBuffer(data) ||
1989
+ utils$1.isStream(data) ||
1990
+ utils$1.isFile(data) ||
1991
+ utils$1.isBlob(data) ||
1992
+ utils$1.isReadableStream(data)
1993
+ ) {
1994
+ return data;
1995
+ }
1996
+ if (utils$1.isArrayBufferView(data)) {
1997
+ return data.buffer;
1998
+ }
1999
+ if (utils$1.isURLSearchParams(data)) {
2000
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2001
+ return data.toString();
1898
2002
  }
1899
2003
 
1900
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1901
- const _FormData = this.env && this.env.FormData;
2004
+ let isFileList;
1902
2005
 
1903
- return toFormData$1(
1904
- isFileList ? {'files[]': data} : data,
1905
- _FormData && new _FormData(),
1906
- this.formSerializer
1907
- );
2006
+ if (isObjectPayload) {
2007
+ const formSerializer = own(this, 'formSerializer');
2008
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2009
+ return toURLEncodedForm(data, formSerializer).toString();
2010
+ }
2011
+
2012
+ if (
2013
+ (isFileList = utils$1.isFileList(data)) ||
2014
+ contentType.indexOf('multipart/form-data') > -1
2015
+ ) {
2016
+ const env = own(this, 'env');
2017
+ const _FormData = env && env.FormData;
2018
+
2019
+ return toFormData$1(
2020
+ isFileList ? { 'files[]': data } : data,
2021
+ _FormData && new _FormData(),
2022
+ formSerializer
2023
+ );
2024
+ }
1908
2025
  }
1909
- }
1910
2026
 
1911
- if (isObjectPayload || hasJSONContentType ) {
1912
- headers.setContentType('application/json', false);
1913
- return stringifySafely(data);
1914
- }
2027
+ if (isObjectPayload || hasJSONContentType) {
2028
+ headers.setContentType('application/json', false);
2029
+ return stringifySafely(data);
2030
+ }
1915
2031
 
1916
- return data;
1917
- }],
2032
+ return data;
2033
+ },
2034
+ ],
1918
2035
 
1919
- transformResponse: [function transformResponse(data) {
1920
- const transitional = this.transitional || defaults.transitional;
1921
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1922
- const JSONRequested = this.responseType === 'json';
2036
+ transformResponse: [
2037
+ function transformResponse(data) {
2038
+ const transitional = own(this, 'transitional') || defaults.transitional;
2039
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2040
+ const responseType = own(this, 'responseType');
2041
+ const JSONRequested = responseType === 'json';
1923
2042
 
1924
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1925
- return data;
1926
- }
2043
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2044
+ return data;
2045
+ }
1927
2046
 
1928
- if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1929
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
1930
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
2047
+ if (
2048
+ data &&
2049
+ utils$1.isString(data) &&
2050
+ ((forcedJSONParsing && !responseType) || JSONRequested)
2051
+ ) {
2052
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
2053
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1931
2054
 
1932
- try {
1933
- return JSON.parse(data, this.parseReviver);
1934
- } catch (e) {
1935
- if (strictJSONParsing) {
1936
- if (e.name === 'SyntaxError') {
1937
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
2055
+ try {
2056
+ return JSON.parse(data, own(this, 'parseReviver'));
2057
+ } catch (e) {
2058
+ if (strictJSONParsing) {
2059
+ if (e.name === 'SyntaxError') {
2060
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
2061
+ }
2062
+ throw e;
1938
2063
  }
1939
- throw e;
1940
2064
  }
1941
2065
  }
1942
- }
1943
2066
 
1944
- return data;
1945
- }],
2067
+ return data;
2068
+ },
2069
+ ],
1946
2070
 
1947
2071
  /**
1948
2072
  * A timeout in milliseconds to abort a request. If set to 0 (default) a
@@ -1958,7 +2082,7 @@ const defaults = {
1958
2082
 
1959
2083
  env: {
1960
2084
  FormData: platform.classes.FormData,
1961
- Blob: platform.classes.Blob
2085
+ Blob: platform.classes.Blob,
1962
2086
  },
1963
2087
 
1964
2088
  validateStatus: function validateStatus(status) {
@@ -1967,10 +2091,10 @@ const defaults = {
1967
2091
 
1968
2092
  headers: {
1969
2093
  common: {
1970
- 'Accept': 'application/json, text/plain, */*',
1971
- 'Content-Type': undefined
1972
- }
1973
- }
2094
+ Accept: 'application/json, text/plain, */*',
2095
+ 'Content-Type': undefined,
2096
+ },
2097
+ },
1974
2098
  };
1975
2099
 
1976
2100
  utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
@@ -1980,10 +2104,23 @@ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1980
2104
  // RawAxiosHeaders whose duplicates are ignored by node
1981
2105
  // c.f. https://nodejs.org/api/http.html#http_message_headers
1982
2106
  const ignoreDuplicateOf = utils$1.toObjectSet([
1983
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
1984
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1985
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1986
- 'referer', 'retry-after', 'user-agent'
2107
+ 'age',
2108
+ 'authorization',
2109
+ 'content-length',
2110
+ 'content-type',
2111
+ 'etag',
2112
+ 'expires',
2113
+ 'from',
2114
+ 'host',
2115
+ 'if-modified-since',
2116
+ 'if-unmodified-since',
2117
+ 'last-modified',
2118
+ 'location',
2119
+ 'max-forwards',
2120
+ 'proxy-authorization',
2121
+ 'referer',
2122
+ 'retry-after',
2123
+ 'user-agent',
1987
2124
  ]);
1988
2125
 
1989
2126
  /**
@@ -2000,47 +2137,81 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
2000
2137
  *
2001
2138
  * @returns {Object} Headers parsed into an object
2002
2139
  */
2003
- var parseHeaders = rawHeaders => {
2140
+ var parseHeaders = (rawHeaders) => {
2004
2141
  const parsed = {};
2005
2142
  let key;
2006
2143
  let val;
2007
2144
  let i;
2008
2145
 
2009
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
2010
- i = line.indexOf(':');
2011
- key = line.substring(0, i).trim().toLowerCase();
2012
- val = line.substring(i + 1).trim();
2146
+ rawHeaders &&
2147
+ rawHeaders.split('\n').forEach(function parser(line) {
2148
+ i = line.indexOf(':');
2149
+ key = line.substring(0, i).trim().toLowerCase();
2150
+ val = line.substring(i + 1).trim();
2013
2151
 
2014
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
2015
- return;
2016
- }
2152
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
2153
+ return;
2154
+ }
2017
2155
 
2018
- if (key === 'set-cookie') {
2019
- if (parsed[key]) {
2020
- parsed[key].push(val);
2156
+ if (key === 'set-cookie') {
2157
+ if (parsed[key]) {
2158
+ parsed[key].push(val);
2159
+ } else {
2160
+ parsed[key] = [val];
2161
+ }
2021
2162
  } else {
2022
- parsed[key] = [val];
2163
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2023
2164
  }
2024
- } else {
2025
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2026
- }
2027
- });
2165
+ });
2028
2166
 
2029
2167
  return parsed;
2030
2168
  };
2031
2169
 
2032
2170
  const $internals = Symbol('internals');
2033
2171
 
2172
+ const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
2173
+
2174
+ function trimSPorHTAB(str) {
2175
+ let start = 0;
2176
+ let end = str.length;
2177
+
2178
+ while (start < end) {
2179
+ const code = str.charCodeAt(start);
2180
+
2181
+ if (code !== 0x09 && code !== 0x20) {
2182
+ break;
2183
+ }
2184
+
2185
+ start += 1;
2186
+ }
2187
+
2188
+ while (end > start) {
2189
+ const code = str.charCodeAt(end - 1);
2190
+
2191
+ if (code !== 0x09 && code !== 0x20) {
2192
+ break;
2193
+ }
2194
+
2195
+ end -= 1;
2196
+ }
2197
+
2198
+ return start === 0 && end === str.length ? str : str.slice(start, end);
2199
+ }
2200
+
2034
2201
  function normalizeHeader(header) {
2035
2202
  return header && String(header).trim().toLowerCase();
2036
2203
  }
2037
2204
 
2205
+ function sanitizeHeaderValue(str) {
2206
+ return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
2207
+ }
2208
+
2038
2209
  function normalizeValue(value) {
2039
2210
  if (value === false || value == null) {
2040
2211
  return value;
2041
2212
  }
2042
2213
 
2043
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
2214
+ return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
2044
2215
  }
2045
2216
 
2046
2217
  function parseTokens(str) {
@@ -2078,8 +2249,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
2078
2249
  }
2079
2250
 
2080
2251
  function formatHeader(header) {
2081
- return header.trim()
2082
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2252
+ return header
2253
+ .trim()
2254
+ .toLowerCase()
2255
+ .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2083
2256
  return char.toUpperCase() + str;
2084
2257
  });
2085
2258
  }
@@ -2087,12 +2260,12 @@ function formatHeader(header) {
2087
2260
  function buildAccessors(obj, header) {
2088
2261
  const accessorName = utils$1.toCamelCase(' ' + header);
2089
2262
 
2090
- ['get', 'set', 'has'].forEach(methodName => {
2263
+ ['get', 'set', 'has'].forEach((methodName) => {
2091
2264
  Object.defineProperty(obj, methodName + accessorName, {
2092
- value: function(arg1, arg2, arg3) {
2265
+ value: function (arg1, arg2, arg3) {
2093
2266
  return this[methodName].call(this, header, arg1, arg2, arg3);
2094
2267
  },
2095
- configurable: true
2268
+ configurable: true,
2096
2269
  });
2097
2270
  });
2098
2271
  }
@@ -2114,7 +2287,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
2114
2287
 
2115
2288
  const key = utils$1.findKey(self, lHeader);
2116
2289
 
2117
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
2290
+ if (
2291
+ !key ||
2292
+ self[key] === undefined ||
2293
+ _rewrite === true ||
2294
+ (_rewrite === undefined && self[key] !== false)
2295
+ ) {
2118
2296
  self[key || _header] = normalizeValue(_value);
2119
2297
  }
2120
2298
  }
@@ -2124,17 +2302,22 @@ let AxiosHeaders$1 = class AxiosHeaders {
2124
2302
 
2125
2303
  if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2126
2304
  setHeaders(header, valueOrRewrite);
2127
- } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2305
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2128
2306
  setHeaders(parseHeaders(header), valueOrRewrite);
2129
2307
  } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2130
- let obj = {}, dest, key;
2308
+ let obj = {},
2309
+ dest,
2310
+ key;
2131
2311
  for (const entry of header) {
2132
2312
  if (!utils$1.isArray(entry)) {
2133
2313
  throw TypeError('Object iterator must return a key-value pair');
2134
2314
  }
2135
2315
 
2136
- obj[key = entry[0]] = (dest = obj[key]) ?
2137
- (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
2316
+ obj[(key = entry[0])] = (dest = obj[key])
2317
+ ? utils$1.isArray(dest)
2318
+ ? [...dest, entry[1]]
2319
+ : [dest, entry[1]]
2320
+ : entry[1];
2138
2321
  }
2139
2322
 
2140
2323
  setHeaders(obj, valueOrRewrite);
@@ -2181,7 +2364,11 @@ let AxiosHeaders$1 = class AxiosHeaders {
2181
2364
  if (header) {
2182
2365
  const key = utils$1.findKey(this, header);
2183
2366
 
2184
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2367
+ return !!(
2368
+ key &&
2369
+ this[key] !== undefined &&
2370
+ (!matcher || matchHeaderValue(this, this[key], key, matcher))
2371
+ );
2185
2372
  }
2186
2373
 
2187
2374
  return false;
@@ -2221,7 +2408,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
2221
2408
 
2222
2409
  while (i--) {
2223
2410
  const key = keys[i];
2224
- if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2411
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2225
2412
  delete this[key];
2226
2413
  deleted = true;
2227
2414
  }
@@ -2265,7 +2452,9 @@ let AxiosHeaders$1 = class AxiosHeaders {
2265
2452
  const obj = Object.create(null);
2266
2453
 
2267
2454
  utils$1.forEach(this, (value, header) => {
2268
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2455
+ value != null &&
2456
+ value !== false &&
2457
+ (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2269
2458
  });
2270
2459
 
2271
2460
  return obj;
@@ -2276,11 +2465,13 @@ let AxiosHeaders$1 = class AxiosHeaders {
2276
2465
  }
2277
2466
 
2278
2467
  toString() {
2279
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
2468
+ return Object.entries(this.toJSON())
2469
+ .map(([header, value]) => header + ': ' + value)
2470
+ .join('\n');
2280
2471
  }
2281
2472
 
2282
2473
  getSetCookie() {
2283
- return this.get("set-cookie") || [];
2474
+ return this.get('set-cookie') || [];
2284
2475
  }
2285
2476
 
2286
2477
  get [Symbol.toStringTag]() {
@@ -2300,9 +2491,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
2300
2491
  }
2301
2492
 
2302
2493
  static accessor(header) {
2303
- const internals = this[$internals] = (this[$internals] = {
2304
- accessors: {}
2305
- });
2494
+ const internals =
2495
+ (this[$internals] =
2496
+ this[$internals] =
2497
+ {
2498
+ accessors: {},
2499
+ });
2306
2500
 
2307
2501
  const accessors = internals.accessors;
2308
2502
  const prototype = this.prototype;
@@ -2322,17 +2516,24 @@ let AxiosHeaders$1 = class AxiosHeaders {
2322
2516
  }
2323
2517
  };
2324
2518
 
2325
- AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2519
+ AxiosHeaders$1.accessor([
2520
+ 'Content-Type',
2521
+ 'Content-Length',
2522
+ 'Accept',
2523
+ 'Accept-Encoding',
2524
+ 'User-Agent',
2525
+ 'Authorization',
2526
+ ]);
2326
2527
 
2327
2528
  // reserved names hotfix
2328
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
2529
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
2329
2530
  let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2330
2531
  return {
2331
2532
  get: () => value,
2332
2533
  set(headerValue) {
2333
2534
  this[mapped] = headerValue;
2334
- }
2335
- }
2535
+ },
2536
+ };
2336
2537
  });
2337
2538
 
2338
2539
  utils$1.freezeMethods(AxiosHeaders$1);
@@ -2395,19 +2596,23 @@ function settle(resolve, reject, response) {
2395
2596
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2396
2597
  resolve(response);
2397
2598
  } else {
2398
- reject(new AxiosError$1(
2399
- 'Request failed with status code ' + response.status,
2400
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2401
- response.config,
2402
- response.request,
2403
- response
2404
- ));
2599
+ reject(
2600
+ new AxiosError$1(
2601
+ 'Request failed with status code ' + response.status,
2602
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
2603
+ Math.floor(response.status / 100) - 4
2604
+ ],
2605
+ response.config,
2606
+ response.request,
2607
+ response
2608
+ )
2609
+ );
2405
2610
  }
2406
2611
  }
2407
2612
 
2408
2613
  function parseProtocol(url) {
2409
2614
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2410
- return match && match[1] || '';
2615
+ return (match && match[1]) || '';
2411
2616
  }
2412
2617
 
2413
2618
  /**
@@ -2458,7 +2663,7 @@ function speedometer(samplesCount, min) {
2458
2663
 
2459
2664
  const passed = startedAt && now - startedAt;
2460
2665
 
2461
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2666
+ return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
2462
2667
  };
2463
2668
  }
2464
2669
 
@@ -2487,7 +2692,7 @@ function throttle(fn, freq) {
2487
2692
  const throttled = (...args) => {
2488
2693
  const now = Date.now();
2489
2694
  const passed = now - timestamp;
2490
- if ( passed >= threshold) {
2695
+ if (passed >= threshold) {
2491
2696
  invoke(args, now);
2492
2697
  } else {
2493
2698
  lastArgs = args;
@@ -2509,25 +2714,25 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2509
2714
  let bytesNotified = 0;
2510
2715
  const _speedometer = speedometer(50, 250);
2511
2716
 
2512
- return throttle(e => {
2513
- const loaded = e.loaded;
2717
+ return throttle((e) => {
2718
+ const rawLoaded = e.loaded;
2514
2719
  const total = e.lengthComputable ? e.total : undefined;
2515
- const progressBytes = loaded - bytesNotified;
2720
+ const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
2721
+ const progressBytes = Math.max(0, loaded - bytesNotified);
2516
2722
  const rate = _speedometer(progressBytes);
2517
- const inRange = loaded <= total;
2518
2723
 
2519
- bytesNotified = loaded;
2724
+ bytesNotified = Math.max(bytesNotified, loaded);
2520
2725
 
2521
2726
  const data = {
2522
2727
  loaded,
2523
2728
  total,
2524
- progress: total ? (loaded / total) : undefined,
2729
+ progress: total ? loaded / total : undefined,
2525
2730
  bytes: progressBytes,
2526
2731
  rate: rate ? rate : undefined,
2527
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2732
+ estimated: rate && total ? (total - loaded) / rate : undefined,
2528
2733
  event: e,
2529
2734
  lengthComputable: total != null,
2530
- [isDownloadStream ? 'download' : 'upload']: true
2735
+ [isDownloadStream ? 'download' : 'upload']: true,
2531
2736
  };
2532
2737
 
2533
2738
  listener(data);
@@ -2537,77 +2742,82 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2537
2742
  const progressEventDecorator = (total, throttled) => {
2538
2743
  const lengthComputable = total != null;
2539
2744
 
2540
- return [(loaded) => throttled[0]({
2541
- lengthComputable,
2542
- total,
2543
- loaded
2544
- }), throttled[1]];
2745
+ return [
2746
+ (loaded) =>
2747
+ throttled[0]({
2748
+ lengthComputable,
2749
+ total,
2750
+ loaded,
2751
+ }),
2752
+ throttled[1],
2753
+ ];
2545
2754
  };
2546
2755
 
2547
- const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2756
+ const asyncDecorator =
2757
+ (fn) =>
2758
+ (...args) =>
2759
+ utils$1.asap(() => fn(...args));
2548
2760
 
2549
- var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2550
- url = new URL(url, platform.origin);
2761
+ var isURLSameOrigin = platform.hasStandardBrowserEnv
2762
+ ? ((origin, isMSIE) => (url) => {
2763
+ url = new URL(url, platform.origin);
2551
2764
 
2552
- return (
2553
- origin.protocol === url.protocol &&
2554
- origin.host === url.host &&
2555
- (isMSIE || origin.port === url.port)
2556
- );
2557
- })(
2558
- new URL(platform.origin),
2559
- platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2560
- ) : () => true;
2561
-
2562
- var cookies = platform.hasStandardBrowserEnv ?
2563
-
2564
- // Standard browser envs support document.cookie
2565
- {
2566
- write(name, value, expires, path, domain, secure, sameSite) {
2567
- if (typeof document === 'undefined') return;
2568
-
2569
- const cookie = [`${name}=${encodeURIComponent(value)}`];
2570
-
2571
- if (utils$1.isNumber(expires)) {
2572
- cookie.push(`expires=${new Date(expires).toUTCString()}`);
2573
- }
2574
- if (utils$1.isString(path)) {
2575
- cookie.push(`path=${path}`);
2576
- }
2577
- if (utils$1.isString(domain)) {
2578
- cookie.push(`domain=${domain}`);
2579
- }
2580
- if (secure === true) {
2581
- cookie.push('secure');
2582
- }
2583
- if (utils$1.isString(sameSite)) {
2584
- cookie.push(`SameSite=${sameSite}`);
2585
- }
2765
+ return (
2766
+ origin.protocol === url.protocol &&
2767
+ origin.host === url.host &&
2768
+ (isMSIE || origin.port === url.port)
2769
+ );
2770
+ })(
2771
+ new URL(platform.origin),
2772
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2773
+ )
2774
+ : () => true;
2775
+
2776
+ var cookies = platform.hasStandardBrowserEnv
2777
+ ? // Standard browser envs support document.cookie
2778
+ {
2779
+ write(name, value, expires, path, domain, secure, sameSite) {
2780
+ if (typeof document === 'undefined') return;
2781
+
2782
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2783
+
2784
+ if (utils$1.isNumber(expires)) {
2785
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
2786
+ }
2787
+ if (utils$1.isString(path)) {
2788
+ cookie.push(`path=${path}`);
2789
+ }
2790
+ if (utils$1.isString(domain)) {
2791
+ cookie.push(`domain=${domain}`);
2792
+ }
2793
+ if (secure === true) {
2794
+ cookie.push('secure');
2795
+ }
2796
+ if (utils$1.isString(sameSite)) {
2797
+ cookie.push(`SameSite=${sameSite}`);
2798
+ }
2586
2799
 
2587
- document.cookie = cookie.join('; ');
2588
- },
2800
+ document.cookie = cookie.join('; ');
2801
+ },
2589
2802
 
2590
- read(name) {
2591
- if (typeof document === 'undefined') return null;
2592
- const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2593
- return match ? decodeURIComponent(match[1]) : null;
2594
- },
2803
+ read(name) {
2804
+ if (typeof document === 'undefined') return null;
2805
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2806
+ return match ? decodeURIComponent(match[1]) : null;
2807
+ },
2595
2808
 
2596
- remove(name) {
2597
- this.write(name, '', Date.now() - 86400000, '/');
2809
+ remove(name) {
2810
+ this.write(name, '', Date.now() - 86400000, '/');
2811
+ },
2598
2812
  }
2599
- }
2600
-
2601
- :
2602
-
2603
- // Non-standard browser env (web workers, react-native) lack needed support.
2604
- {
2605
- write() {},
2606
- read() {
2607
- return null;
2608
- },
2609
- remove() {}
2610
- };
2813
+ : // Non-standard browser env (web workers, react-native) lack needed support.
2814
+ {
2815
+ write() {},
2816
+ read() {
2817
+ return null;
2818
+ },
2819
+ remove() {},
2820
+ };
2611
2821
 
2612
2822
  /**
2613
2823
  * Determines whether the specified URL is absolute
@@ -2653,14 +2863,13 @@ function combineURLs(baseURL, relativeURL) {
2653
2863
  */
2654
2864
  function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2655
2865
  let isRelativeUrl = !isAbsoluteURL(requestedURL);
2656
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2866
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
2657
2867
  return combineURLs(baseURL, requestedURL);
2658
2868
  }
2659
2869
  return requestedURL;
2660
2870
  }
2661
2871
 
2662
- const headersToObject = (thing) =>
2663
- thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2872
+ const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
2664
2873
 
2665
2874
  /**
2666
2875
  * Config-specific merge-function which creates a new config-object
@@ -2674,7 +2883,18 @@ const headersToObject = (thing) =>
2674
2883
  function mergeConfig$1(config1, config2) {
2675
2884
  // eslint-disable-next-line no-param-reassign
2676
2885
  config2 = config2 || {};
2677
- const config = {};
2886
+
2887
+ // Use a null-prototype object so that downstream reads such as `config.auth`
2888
+ // or `config.baseURL` cannot inherit polluted values from Object.prototype
2889
+ // (see GHSA-q8qp-cvcw-x6jj). `hasOwnProperty` is restored as a non-enumerable
2890
+ // own slot to preserve ergonomics for user code that relies on it.
2891
+ const config = Object.create(null);
2892
+ Object.defineProperty(config, 'hasOwnProperty', {
2893
+ value: Object.prototype.hasOwnProperty,
2894
+ enumerable: false,
2895
+ writable: true,
2896
+ configurable: true,
2897
+ });
2678
2898
 
2679
2899
  function getMergedValue(target, source, prop, caseless) {
2680
2900
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
@@ -2713,9 +2933,9 @@ function mergeConfig$1(config1, config2) {
2713
2933
 
2714
2934
  // eslint-disable-next-line consistent-return
2715
2935
  function mergeDirectKeys(a, b, prop) {
2716
- if (prop in config2) {
2936
+ if (utils$1.hasOwnProp(config2, prop)) {
2717
2937
  return getMergedValue(a, b);
2718
- } else if (prop in config1) {
2938
+ } else if (utils$1.hasOwnProp(config1, prop)) {
2719
2939
  return getMergedValue(undefined, a);
2720
2940
  }
2721
2941
  }
@@ -2747,29 +2967,21 @@ function mergeConfig$1(config1, config2) {
2747
2967
  httpsAgent: defaultToConfig2,
2748
2968
  cancelToken: defaultToConfig2,
2749
2969
  socketPath: defaultToConfig2,
2970
+ allowedSocketPaths: defaultToConfig2,
2750
2971
  responseEncoding: defaultToConfig2,
2751
2972
  validateStatus: mergeDirectKeys,
2752
2973
  headers: (a, b, prop) =>
2753
2974
  mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
2754
2975
  };
2755
2976
 
2756
- utils$1.forEach(
2757
- Object.keys({ ...config1, ...config2 }),
2758
- function computeConfigValue(prop) {
2759
- if (
2760
- prop === "__proto__" ||
2761
- prop === "constructor" ||
2762
- prop === "prototype"
2763
- )
2764
- return;
2765
- const merge = utils$1.hasOwnProp(mergeMap, prop)
2766
- ? mergeMap[prop]
2767
- : mergeDeepProperties;
2768
- const configValue = merge(config1[prop], config2[prop], prop);
2769
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
2770
- (config[prop] = configValue);
2771
- },
2772
- );
2977
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
2978
+ if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
2979
+ const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
2980
+ const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
2981
+ const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
2982
+ const configValue = merge(a, b, prop);
2983
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2984
+ });
2773
2985
 
2774
2986
  return config;
2775
2987
  }
@@ -2777,16 +2989,38 @@ function mergeConfig$1(config1, config2) {
2777
2989
  var resolveConfig = (config) => {
2778
2990
  const newConfig = mergeConfig$1({}, config);
2779
2991
 
2780
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2992
+ // Read only own properties to prevent prototype pollution gadgets
2993
+ // (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
2994
+ const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
2995
+
2996
+ const data = own('data');
2997
+ let withXSRFToken = own('withXSRFToken');
2998
+ const xsrfHeaderName = own('xsrfHeaderName');
2999
+ const xsrfCookieName = own('xsrfCookieName');
3000
+ let headers = own('headers');
3001
+ const auth = own('auth');
3002
+ const baseURL = own('baseURL');
3003
+ const allowAbsoluteUrls = own('allowAbsoluteUrls');
3004
+ const url = own('url');
2781
3005
 
2782
3006
  newConfig.headers = headers = AxiosHeaders$1.from(headers);
2783
3007
 
2784
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
3008
+ newConfig.url = buildURL(
3009
+ buildFullPath(baseURL, url, allowAbsoluteUrls),
3010
+ config.params,
3011
+ config.paramsSerializer
3012
+ );
2785
3013
 
2786
3014
  // HTTP basic authentication
2787
3015
  if (auth) {
2788
- headers.set('Authorization', 'Basic ' +
2789
- btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
3016
+ headers.set(
3017
+ 'Authorization',
3018
+ 'Basic ' +
3019
+ btoa(
3020
+ (auth.username || '') +
3021
+ ':' +
3022
+ (auth.password ? unescape(encodeURIComponent(auth.password)) : '')
3023
+ )
2790
3024
  );
2791
3025
  }
2792
3026
 
@@ -2804,17 +3038,25 @@ var resolveConfig = (config) => {
2804
3038
  }
2805
3039
  });
2806
3040
  }
2807
- }
3041
+ }
2808
3042
 
2809
3043
  // Add xsrf header
2810
3044
  // This is only done if running in a standard browser environment.
2811
3045
  // Specifically not if we're in a web worker, or react-native.
2812
3046
 
2813
3047
  if (platform.hasStandardBrowserEnv) {
2814
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3048
+ if (utils$1.isFunction(withXSRFToken)) {
3049
+ withXSRFToken = withXSRFToken(newConfig);
3050
+ }
2815
3051
 
2816
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2817
- // Add xsrf header
3052
+ // Strict boolean check prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
3053
+ // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
3054
+ // the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
3055
+ const shouldSendXSRF =
3056
+ withXSRFToken === true ||
3057
+ (withXSRFToken == null && isURLSameOrigin(newConfig.url));
3058
+
3059
+ if (shouldSendXSRF) {
2818
3060
  const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2819
3061
 
2820
3062
  if (xsrfValue) {
@@ -2828,196 +3070,218 @@ var resolveConfig = (config) => {
2828
3070
 
2829
3071
  const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2830
3072
 
2831
- var xhrAdapter = isXHRAdapterSupported && function (config) {
2832
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2833
- const _config = resolveConfig(config);
2834
- let requestData = _config.data;
2835
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2836
- let {responseType, onUploadProgress, onDownloadProgress} = _config;
2837
- let onCanceled;
2838
- let uploadThrottled, downloadThrottled;
2839
- let flushUpload, flushDownload;
3073
+ var xhrAdapter = isXHRAdapterSupported &&
3074
+ function (config) {
3075
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
3076
+ const _config = resolveConfig(config);
3077
+ let requestData = _config.data;
3078
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3079
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
3080
+ let onCanceled;
3081
+ let uploadThrottled, downloadThrottled;
3082
+ let flushUpload, flushDownload;
2840
3083
 
2841
- function done() {
2842
- flushUpload && flushUpload(); // flush events
2843
- flushDownload && flushDownload(); // flush events
3084
+ function done() {
3085
+ flushUpload && flushUpload(); // flush events
3086
+ flushDownload && flushDownload(); // flush events
2844
3087
 
2845
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
3088
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2846
3089
 
2847
- _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2848
- }
3090
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
3091
+ }
2849
3092
 
2850
- let request = new XMLHttpRequest();
3093
+ let request = new XMLHttpRequest();
2851
3094
 
2852
- request.open(_config.method.toUpperCase(), _config.url, true);
3095
+ request.open(_config.method.toUpperCase(), _config.url, true);
2853
3096
 
2854
- // Set the request timeout in MS
2855
- request.timeout = _config.timeout;
3097
+ // Set the request timeout in MS
3098
+ request.timeout = _config.timeout;
2856
3099
 
2857
- function onloadend() {
2858
- if (!request) {
2859
- return;
3100
+ function onloadend() {
3101
+ if (!request) {
3102
+ return;
3103
+ }
3104
+ // Prepare the response
3105
+ const responseHeaders = AxiosHeaders$1.from(
3106
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
3107
+ );
3108
+ const responseData =
3109
+ !responseType || responseType === 'text' || responseType === 'json'
3110
+ ? request.responseText
3111
+ : request.response;
3112
+ const response = {
3113
+ data: responseData,
3114
+ status: request.status,
3115
+ statusText: request.statusText,
3116
+ headers: responseHeaders,
3117
+ config,
3118
+ request,
3119
+ };
3120
+
3121
+ settle(
3122
+ function _resolve(value) {
3123
+ resolve(value);
3124
+ done();
3125
+ },
3126
+ function _reject(err) {
3127
+ reject(err);
3128
+ done();
3129
+ },
3130
+ response
3131
+ );
3132
+
3133
+ // Clean up request
3134
+ request = null;
2860
3135
  }
2861
- // Prepare the response
2862
- const responseHeaders = AxiosHeaders$1.from(
2863
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2864
- );
2865
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2866
- request.responseText : request.response;
2867
- const response = {
2868
- data: responseData,
2869
- status: request.status,
2870
- statusText: request.statusText,
2871
- headers: responseHeaders,
2872
- config,
2873
- request
2874
- };
2875
3136
 
2876
- settle(function _resolve(value) {
2877
- resolve(value);
2878
- done();
2879
- }, function _reject(err) {
2880
- reject(err);
2881
- done();
2882
- }, response);
3137
+ if ('onloadend' in request) {
3138
+ // Use onloadend if available
3139
+ request.onloadend = onloadend;
3140
+ } else {
3141
+ // Listen for ready state to emulate onloadend
3142
+ request.onreadystatechange = function handleLoad() {
3143
+ if (!request || request.readyState !== 4) {
3144
+ return;
3145
+ }
2883
3146
 
2884
- // Clean up request
2885
- request = null;
2886
- }
3147
+ // The request errored out and we didn't get a response, this will be
3148
+ // handled by onerror instead
3149
+ // With one exception: request that using file: protocol, most browsers
3150
+ // will return status as 0 even though it's a successful request
3151
+ if (
3152
+ request.status === 0 &&
3153
+ !(request.responseURL && request.responseURL.indexOf('file:') === 0)
3154
+ ) {
3155
+ return;
3156
+ }
3157
+ // readystate handler is calling before onerror or ontimeout handlers,
3158
+ // so we should call onloadend on the next 'tick'
3159
+ setTimeout(onloadend);
3160
+ };
3161
+ }
2887
3162
 
2888
- if ('onloadend' in request) {
2889
- // Use onloadend if available
2890
- request.onloadend = onloadend;
2891
- } else {
2892
- // Listen for ready state to emulate onloadend
2893
- request.onreadystatechange = function handleLoad() {
2894
- if (!request || request.readyState !== 4) {
3163
+ // Handle browser request cancellation (as opposed to a manual cancellation)
3164
+ request.onabort = function handleAbort() {
3165
+ if (!request) {
2895
3166
  return;
2896
3167
  }
2897
3168
 
2898
- // The request errored out and we didn't get a response, this will be
2899
- // handled by onerror instead
2900
- // With one exception: request that using file: protocol, most browsers
2901
- // will return status as 0 even though it's a successful request
2902
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2903
- return;
2904
- }
2905
- // readystate handler is calling before onerror or ontimeout handlers,
2906
- // so we should call onloadend on the next 'tick'
2907
- setTimeout(onloadend);
3169
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
3170
+
3171
+ // Clean up request
3172
+ request = null;
2908
3173
  };
2909
- }
2910
3174
 
2911
- // Handle browser request cancellation (as opposed to a manual cancellation)
2912
- request.onabort = function handleAbort() {
2913
- if (!request) {
2914
- return;
2915
- }
3175
+ // Handle low level network errors
3176
+ request.onerror = function handleError(event) {
3177
+ // Browsers deliver a ProgressEvent in XHR onerror
3178
+ // (message may be empty; when present, surface it)
3179
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
3180
+ const msg = event && event.message ? event.message : 'Network Error';
3181
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
3182
+ // attach the underlying event for consumers who want details
3183
+ err.event = event || null;
3184
+ reject(err);
3185
+ request = null;
3186
+ };
2916
3187
 
2917
- reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
3188
+ // Handle timeout
3189
+ request.ontimeout = function handleTimeout() {
3190
+ let timeoutErrorMessage = _config.timeout
3191
+ ? 'timeout of ' + _config.timeout + 'ms exceeded'
3192
+ : 'timeout exceeded';
3193
+ const transitional = _config.transitional || transitionalDefaults;
3194
+ if (_config.timeoutErrorMessage) {
3195
+ timeoutErrorMessage = _config.timeoutErrorMessage;
3196
+ }
3197
+ reject(
3198
+ new AxiosError$1(
3199
+ timeoutErrorMessage,
3200
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
3201
+ config,
3202
+ request
3203
+ )
3204
+ );
2918
3205
 
2919
- // Clean up request
2920
- request = null;
2921
- };
3206
+ // Clean up request
3207
+ request = null;
3208
+ };
2922
3209
 
2923
- // Handle low level network errors
2924
- request.onerror = function handleError(event) {
2925
- // Browsers deliver a ProgressEvent in XHR onerror
2926
- // (message may be empty; when present, surface it)
2927
- // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2928
- const msg = event && event.message ? event.message : 'Network Error';
2929
- const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
2930
- // attach the underlying event for consumers who want details
2931
- err.event = event || null;
2932
- reject(err);
2933
- request = null;
2934
- };
2935
-
2936
- // Handle timeout
2937
- request.ontimeout = function handleTimeout() {
2938
- let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2939
- const transitional = _config.transitional || transitionalDefaults;
2940
- if (_config.timeoutErrorMessage) {
2941
- timeoutErrorMessage = _config.timeoutErrorMessage;
2942
- }
2943
- reject(new AxiosError$1(
2944
- timeoutErrorMessage,
2945
- transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2946
- config,
2947
- request));
2948
-
2949
- // Clean up request
2950
- request = null;
2951
- };
3210
+ // Remove Content-Type if data is undefined
3211
+ requestData === undefined && requestHeaders.setContentType(null);
2952
3212
 
2953
- // Remove Content-Type if data is undefined
2954
- requestData === undefined && requestHeaders.setContentType(null);
3213
+ // Add headers to the request
3214
+ if ('setRequestHeader' in request) {
3215
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3216
+ request.setRequestHeader(key, val);
3217
+ });
3218
+ }
2955
3219
 
2956
- // Add headers to the request
2957
- if ('setRequestHeader' in request) {
2958
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2959
- request.setRequestHeader(key, val);
2960
- });
2961
- }
3220
+ // Add withCredentials to request if needed
3221
+ if (!utils$1.isUndefined(_config.withCredentials)) {
3222
+ request.withCredentials = !!_config.withCredentials;
3223
+ }
2962
3224
 
2963
- // Add withCredentials to request if needed
2964
- if (!utils$1.isUndefined(_config.withCredentials)) {
2965
- request.withCredentials = !!_config.withCredentials;
2966
- }
3225
+ // Add responseType to request if needed
3226
+ if (responseType && responseType !== 'json') {
3227
+ request.responseType = _config.responseType;
3228
+ }
2967
3229
 
2968
- // Add responseType to request if needed
2969
- if (responseType && responseType !== 'json') {
2970
- request.responseType = _config.responseType;
2971
- }
3230
+ // Handle progress if needed
3231
+ if (onDownloadProgress) {
3232
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
3233
+ request.addEventListener('progress', downloadThrottled);
3234
+ }
2972
3235
 
2973
- // Handle progress if needed
2974
- if (onDownloadProgress) {
2975
- ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2976
- request.addEventListener('progress', downloadThrottled);
2977
- }
3236
+ // Not all browsers support upload events
3237
+ if (onUploadProgress && request.upload) {
3238
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
2978
3239
 
2979
- // Not all browsers support upload events
2980
- if (onUploadProgress && request.upload) {
2981
- ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
3240
+ request.upload.addEventListener('progress', uploadThrottled);
2982
3241
 
2983
- request.upload.addEventListener('progress', uploadThrottled);
3242
+ request.upload.addEventListener('loadend', flushUpload);
3243
+ }
2984
3244
 
2985
- request.upload.addEventListener('loadend', flushUpload);
2986
- }
3245
+ if (_config.cancelToken || _config.signal) {
3246
+ // Handle cancellation
3247
+ // eslint-disable-next-line func-names
3248
+ onCanceled = (cancel) => {
3249
+ if (!request) {
3250
+ return;
3251
+ }
3252
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
3253
+ request.abort();
3254
+ request = null;
3255
+ };
2987
3256
 
2988
- if (_config.cancelToken || _config.signal) {
2989
- // Handle cancellation
2990
- // eslint-disable-next-line func-names
2991
- onCanceled = cancel => {
2992
- if (!request) {
2993
- return;
3257
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3258
+ if (_config.signal) {
3259
+ _config.signal.aborted
3260
+ ? onCanceled()
3261
+ : _config.signal.addEventListener('abort', onCanceled);
2994
3262
  }
2995
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2996
- request.abort();
2997
- request = null;
2998
- };
2999
-
3000
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3001
- if (_config.signal) {
3002
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
3003
3263
  }
3004
- }
3005
-
3006
- const protocol = parseProtocol(_config.url);
3007
3264
 
3008
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
3009
- reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
3010
- return;
3011
- }
3265
+ const protocol = parseProtocol(_config.url);
3012
3266
 
3267
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
3268
+ reject(
3269
+ new AxiosError$1(
3270
+ 'Unsupported protocol ' + protocol + ':',
3271
+ AxiosError$1.ERR_BAD_REQUEST,
3272
+ config
3273
+ )
3274
+ );
3275
+ return;
3276
+ }
3013
3277
 
3014
- // Send the request
3015
- request.send(requestData || null);
3016
- });
3017
- };
3278
+ // Send the request
3279
+ request.send(requestData || null);
3280
+ });
3281
+ };
3018
3282
 
3019
3283
  const composeSignals = (signals, timeout) => {
3020
- const {length} = (signals = signals ? signals.filter(Boolean) : []);
3284
+ const { length } = (signals = signals ? signals.filter(Boolean) : []);
3021
3285
 
3022
3286
  if (timeout || length) {
3023
3287
  let controller = new AbortController();
@@ -3029,21 +3293,29 @@ const composeSignals = (signals, timeout) => {
3029
3293
  aborted = true;
3030
3294
  unsubscribe();
3031
3295
  const err = reason instanceof Error ? reason : this.reason;
3032
- controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
3296
+ controller.abort(
3297
+ err instanceof AxiosError$1
3298
+ ? err
3299
+ : new CanceledError$1(err instanceof Error ? err.message : err)
3300
+ );
3033
3301
  }
3034
3302
  };
3035
3303
 
3036
- let timer = timeout && setTimeout(() => {
3037
- timer = null;
3038
- onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
3039
- }, timeout);
3304
+ let timer =
3305
+ timeout &&
3306
+ setTimeout(() => {
3307
+ timer = null;
3308
+ onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
3309
+ }, timeout);
3040
3310
 
3041
3311
  const unsubscribe = () => {
3042
3312
  if (signals) {
3043
3313
  timer && clearTimeout(timer);
3044
3314
  timer = null;
3045
- signals.forEach(signal => {
3046
- signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3315
+ signals.forEach((signal) => {
3316
+ signal.unsubscribe
3317
+ ? signal.unsubscribe(onabort)
3318
+ : signal.removeEventListener('abort', onabort);
3047
3319
  });
3048
3320
  signals = null;
3049
3321
  }
@@ -3051,7 +3323,7 @@ const composeSignals = (signals, timeout) => {
3051
3323
 
3052
3324
  signals.forEach((signal) => signal.addEventListener('abort', onabort));
3053
3325
 
3054
- const {signal} = controller;
3326
+ const { signal } = controller;
3055
3327
 
3056
3328
  signal.unsubscribe = () => utils$1.asap(unsubscribe);
3057
3329
 
@@ -3092,7 +3364,7 @@ const readStream = async function* (stream) {
3092
3364
  const reader = stream.getReader();
3093
3365
  try {
3094
3366
  for (;;) {
3095
- const {done, value} = await reader.read();
3367
+ const { done, value } = await reader.read();
3096
3368
  if (done) {
3097
3369
  break;
3098
3370
  }
@@ -3115,64 +3387,69 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3115
3387
  }
3116
3388
  };
3117
3389
 
3118
- return new ReadableStream({
3119
- async pull(controller) {
3120
- try {
3121
- const {done, value} = await iterator.next();
3390
+ return new ReadableStream(
3391
+ {
3392
+ async pull(controller) {
3393
+ try {
3394
+ const { done, value } = await iterator.next();
3122
3395
 
3123
- if (done) {
3124
- _onFinish();
3125
- controller.close();
3126
- return;
3127
- }
3396
+ if (done) {
3397
+ _onFinish();
3398
+ controller.close();
3399
+ return;
3400
+ }
3128
3401
 
3129
- let len = value.byteLength;
3130
- if (onProgress) {
3131
- let loadedBytes = bytes += len;
3132
- onProgress(loadedBytes);
3402
+ let len = value.byteLength;
3403
+ if (onProgress) {
3404
+ let loadedBytes = (bytes += len);
3405
+ onProgress(loadedBytes);
3406
+ }
3407
+ controller.enqueue(new Uint8Array(value));
3408
+ } catch (err) {
3409
+ _onFinish(err);
3410
+ throw err;
3133
3411
  }
3134
- controller.enqueue(new Uint8Array(value));
3135
- } catch (err) {
3136
- _onFinish(err);
3137
- throw err;
3138
- }
3412
+ },
3413
+ cancel(reason) {
3414
+ _onFinish(reason);
3415
+ return iterator.return();
3416
+ },
3139
3417
  },
3140
- cancel(reason) {
3141
- _onFinish(reason);
3142
- return iterator.return();
3418
+ {
3419
+ highWaterMark: 2,
3143
3420
  }
3144
- }, {
3145
- highWaterMark: 2
3146
- })
3421
+ );
3147
3422
  };
3148
3423
 
3149
3424
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
3150
3425
 
3151
- const {isFunction} = utils$1;
3426
+ const { isFunction } = utils$1;
3152
3427
 
3153
- const globalFetchAPI = (({Request, Response}) => ({
3154
- Request, Response
3428
+ const globalFetchAPI = (({ Request, Response }) => ({
3429
+ Request,
3430
+ Response,
3155
3431
  }))(utils$1.global);
3156
3432
 
3157
- const {
3158
- ReadableStream: ReadableStream$1, TextEncoder
3159
- } = utils$1.global;
3160
-
3433
+ const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
3161
3434
 
3162
3435
  const test = (fn, ...args) => {
3163
3436
  try {
3164
3437
  return !!fn(...args);
3165
3438
  } catch (e) {
3166
- return false
3439
+ return false;
3167
3440
  }
3168
3441
  };
3169
3442
 
3170
3443
  const factory = (env) => {
3171
- env = utils$1.merge.call({
3172
- skipUndefined: true
3173
- }, globalFetchAPI, env);
3444
+ env = utils$1.merge.call(
3445
+ {
3446
+ skipUndefined: true,
3447
+ },
3448
+ globalFetchAPI,
3449
+ env
3450
+ );
3174
3451
 
3175
- const {fetch: envFetch, Request, Response} = env;
3452
+ const { fetch: envFetch, Request, Response } = env;
3176
3453
  const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
3177
3454
  const isRequestSupported = isFunction(Request);
3178
3455
  const isResponseSupported = isFunction(Response);
@@ -3183,46 +3460,67 @@ const factory = (env) => {
3183
3460
 
3184
3461
  const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3185
3462
 
3186
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3187
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3188
- async (str) => new Uint8Array(await new Request(str).arrayBuffer())
3189
- );
3463
+ const encodeText =
3464
+ isFetchSupported &&
3465
+ (typeof TextEncoder === 'function'
3466
+ ? (
3467
+ (encoder) => (str) =>
3468
+ encoder.encode(str)
3469
+ )(new TextEncoder())
3470
+ : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
3471
+
3472
+ const supportsRequestStream =
3473
+ isRequestSupported &&
3474
+ isReadableStreamSupported &&
3475
+ test(() => {
3476
+ let duplexAccessed = false;
3477
+
3478
+ const request = new Request(platform.origin, {
3479
+ body: new ReadableStream$1(),
3480
+ method: 'POST',
3481
+ get duplex() {
3482
+ duplexAccessed = true;
3483
+ return 'half';
3484
+ },
3485
+ });
3190
3486
 
3191
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3192
- let duplexAccessed = false;
3487
+ const hasContentType = request.headers.has('Content-Type');
3193
3488
 
3194
- const hasContentType = new Request(platform.origin, {
3195
- body: new ReadableStream$1(),
3196
- method: 'POST',
3197
- get duplex() {
3198
- duplexAccessed = true;
3199
- return 'half';
3200
- },
3201
- }).headers.has('Content-Type');
3489
+ if (request.body != null) {
3490
+ request.body.cancel();
3491
+ }
3202
3492
 
3203
- return duplexAccessed && !hasContentType;
3204
- });
3493
+ return duplexAccessed && !hasContentType;
3494
+ });
3205
3495
 
3206
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
3496
+ const supportsResponseStream =
3497
+ isResponseSupported &&
3498
+ isReadableStreamSupported &&
3207
3499
  test(() => utils$1.isReadableStream(new Response('').body));
3208
3500
 
3209
3501
  const resolvers = {
3210
- stream: supportsResponseStream && ((res) => res.body)
3502
+ stream: supportsResponseStream && ((res) => res.body),
3211
3503
  };
3212
3504
 
3213
- isFetchSupported && ((() => {
3214
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3215
- !resolvers[type] && (resolvers[type] = (res, config) => {
3216
- let method = res && res[type];
3505
+ isFetchSupported &&
3506
+ (() => {
3507
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
3508
+ !resolvers[type] &&
3509
+ (resolvers[type] = (res, config) => {
3510
+ let method = res && res[type];
3217
3511
 
3218
- if (method) {
3219
- return method.call(res);
3220
- }
3512
+ if (method) {
3513
+ return method.call(res);
3514
+ }
3221
3515
 
3222
- throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
3516
+ throw new AxiosError$1(
3517
+ `Response type '${type}' is not supported`,
3518
+ AxiosError$1.ERR_NOT_SUPPORT,
3519
+ config
3520
+ );
3521
+ });
3223
3522
  });
3224
- });
3225
- })());
3523
+ })();
3226
3524
 
3227
3525
  const getBodyLength = async (body) => {
3228
3526
  if (body == null) {
@@ -3273,32 +3571,41 @@ const factory = (env) => {
3273
3571
  responseType,
3274
3572
  headers,
3275
3573
  withCredentials = 'same-origin',
3276
- fetchOptions
3574
+ fetchOptions,
3277
3575
  } = resolveConfig(config);
3278
3576
 
3279
3577
  let _fetch = envFetch || fetch;
3280
3578
 
3281
3579
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3282
3580
 
3283
- let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3581
+ let composedSignal = composeSignals(
3582
+ [signal, cancelToken && cancelToken.toAbortSignal()],
3583
+ timeout
3584
+ );
3284
3585
 
3285
3586
  let request = null;
3286
3587
 
3287
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3288
- composedSignal.unsubscribe();
3289
- });
3588
+ const unsubscribe =
3589
+ composedSignal &&
3590
+ composedSignal.unsubscribe &&
3591
+ (() => {
3592
+ composedSignal.unsubscribe();
3593
+ });
3290
3594
 
3291
3595
  let requestContentLength;
3292
3596
 
3293
3597
  try {
3294
3598
  if (
3295
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3599
+ onUploadProgress &&
3600
+ supportsRequestStream &&
3601
+ method !== 'get' &&
3602
+ method !== 'head' &&
3296
3603
  (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3297
3604
  ) {
3298
3605
  let _request = new Request(url, {
3299
3606
  method: 'POST',
3300
3607
  body: data,
3301
- duplex: "half"
3608
+ duplex: 'half',
3302
3609
  });
3303
3610
 
3304
3611
  let contentTypeHeader;
@@ -3323,7 +3630,20 @@ const factory = (env) => {
3323
3630
 
3324
3631
  // Cloudflare Workers throws when credentials are defined
3325
3632
  // see https://github.com/cloudflare/workerd/issues/902
3326
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3633
+ const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
3634
+
3635
+ // If data is FormData and Content-Type is multipart/form-data without boundary,
3636
+ // delete it so fetch can set it correctly with the boundary
3637
+ if (utils$1.isFormData(data)) {
3638
+ const contentType = headers.getContentType();
3639
+ if (
3640
+ contentType &&
3641
+ /^multipart\/form-data/i.test(contentType) &&
3642
+ !/boundary=/i.test(contentType)
3643
+ ) {
3644
+ headers.delete('content-type');
3645
+ }
3646
+ }
3327
3647
 
3328
3648
  const resolvedOptions = {
3329
3649
  ...fetchOptions,
@@ -3331,29 +3651,35 @@ const factory = (env) => {
3331
3651
  method: method.toUpperCase(),
3332
3652
  headers: headers.normalize().toJSON(),
3333
3653
  body: data,
3334
- duplex: "half",
3335
- credentials: isCredentialsSupported ? withCredentials : undefined
3654
+ duplex: 'half',
3655
+ credentials: isCredentialsSupported ? withCredentials : undefined,
3336
3656
  };
3337
3657
 
3338
3658
  request = isRequestSupported && new Request(url, resolvedOptions);
3339
3659
 
3340
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
3660
+ let response = await (isRequestSupported
3661
+ ? _fetch(request, fetchOptions)
3662
+ : _fetch(url, resolvedOptions));
3341
3663
 
3342
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3664
+ const isStreamResponse =
3665
+ supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3343
3666
 
3344
3667
  if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3345
3668
  const options = {};
3346
3669
 
3347
- ['status', 'statusText', 'headers'].forEach(prop => {
3670
+ ['status', 'statusText', 'headers'].forEach((prop) => {
3348
3671
  options[prop] = response[prop];
3349
3672
  });
3350
3673
 
3351
3674
  const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3352
3675
 
3353
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3354
- responseContentLength,
3355
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
3356
- ) || [];
3676
+ const [onProgress, flush] =
3677
+ (onDownloadProgress &&
3678
+ progressEventDecorator(
3679
+ responseContentLength,
3680
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3681
+ )) ||
3682
+ [];
3357
3683
 
3358
3684
  response = new Response(
3359
3685
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
@@ -3366,7 +3692,10 @@ const factory = (env) => {
3366
3692
 
3367
3693
  responseType = responseType || 'text';
3368
3694
 
3369
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3695
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
3696
+ response,
3697
+ config
3698
+ );
3370
3699
 
3371
3700
  !isStreamResponse && unsubscribe && unsubscribe();
3372
3701
 
@@ -3377,43 +3706,50 @@ const factory = (env) => {
3377
3706
  status: response.status,
3378
3707
  statusText: response.statusText,
3379
3708
  config,
3380
- request
3709
+ request,
3381
3710
  });
3382
- })
3711
+ });
3383
3712
  } catch (err) {
3384
3713
  unsubscribe && unsubscribe();
3385
3714
 
3386
3715
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3387
3716
  throw Object.assign(
3388
- new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, err && err.response),
3717
+ new AxiosError$1(
3718
+ 'Network Error',
3719
+ AxiosError$1.ERR_NETWORK,
3720
+ config,
3721
+ request,
3722
+ err && err.response
3723
+ ),
3389
3724
  {
3390
- cause: err.cause || err
3725
+ cause: err.cause || err,
3391
3726
  }
3392
- )
3727
+ );
3393
3728
  }
3394
3729
 
3395
3730
  throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
3396
3731
  }
3397
- }
3732
+ };
3398
3733
  };
3399
3734
 
3400
3735
  const seedCache = new Map();
3401
3736
 
3402
3737
  const getFetch = (config) => {
3403
3738
  let env = (config && config.env) || {};
3404
- const {fetch, Request, Response} = env;
3405
- const seeds = [
3406
- Request, Response, fetch
3407
- ];
3739
+ const { fetch, Request, Response } = env;
3740
+ const seeds = [Request, Response, fetch];
3408
3741
 
3409
- let len = seeds.length, i = len,
3410
- seed, target, map = seedCache;
3742
+ let len = seeds.length,
3743
+ i = len,
3744
+ seed,
3745
+ target,
3746
+ map = seedCache;
3411
3747
 
3412
3748
  while (i--) {
3413
3749
  seed = seeds[i];
3414
3750
  target = map.get(seed);
3415
3751
 
3416
- target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3752
+ target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
3417
3753
 
3418
3754
  map = target;
3419
3755
  }
@@ -3429,7 +3765,7 @@ getFetch();
3429
3765
  * - `http` for Node.js
3430
3766
  * - `xhr` for browsers
3431
3767
  * - `fetch` for fetch API-based requests
3432
- *
3768
+ *
3433
3769
  * @type {Object<string, Function|Object>}
3434
3770
  */
3435
3771
  const knownAdapters = {
@@ -3437,7 +3773,7 @@ const knownAdapters = {
3437
3773
  xhr: xhrAdapter,
3438
3774
  fetch: {
3439
3775
  get: getFetch,
3440
- }
3776
+ },
3441
3777
  };
3442
3778
 
3443
3779
  // Assign adapter names for easier debugging and identification
@@ -3454,7 +3790,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
3454
3790
 
3455
3791
  /**
3456
3792
  * Render a rejection reason string for unknown or unsupported adapters
3457
- *
3793
+ *
3458
3794
  * @param {string} reason
3459
3795
  * @returns {string}
3460
3796
  */
@@ -3462,17 +3798,18 @@ const renderReason = (reason) => `- ${reason}`;
3462
3798
 
3463
3799
  /**
3464
3800
  * Check if the adapter is resolved (function, null, or false)
3465
- *
3801
+ *
3466
3802
  * @param {Function|null|false} adapter
3467
3803
  * @returns {boolean}
3468
3804
  */
3469
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3805
+ const isResolvedHandle = (adapter) =>
3806
+ utils$1.isFunction(adapter) || adapter === null || adapter === false;
3470
3807
 
3471
3808
  /**
3472
3809
  * Get the first suitable adapter from the provided list.
3473
3810
  * Tries each adapter in order until a supported one is found.
3474
3811
  * Throws an AxiosError if no adapter is suitable.
3475
- *
3812
+ *
3476
3813
  * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
3477
3814
  * @param {Object} config - Axios request configuration
3478
3815
  * @throws {AxiosError} If no suitable adapter is available
@@ -3509,14 +3846,17 @@ function getAdapter$1(adapters, config) {
3509
3846
  }
3510
3847
 
3511
3848
  if (!adapter) {
3512
- const reasons = Object.entries(rejectedReasons)
3513
- .map(([id, state]) => `adapter ${id} ` +
3849
+ const reasons = Object.entries(rejectedReasons).map(
3850
+ ([id, state]) =>
3851
+ `adapter ${id} ` +
3514
3852
  (state === false ? 'is not supported by the environment' : 'is not available in the build')
3515
- );
3853
+ );
3516
3854
 
3517
- let s = length ?
3518
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3519
- 'as no adapter specified';
3855
+ let s = length
3856
+ ? reasons.length > 1
3857
+ ? 'since :\n' + reasons.map(renderReason).join('\n')
3858
+ : ' ' + renderReason(reasons[0])
3859
+ : 'as no adapter specified';
3520
3860
 
3521
3861
  throw new AxiosError$1(
3522
3862
  `There is no suitable adapter to dispatch the request ` + s,
@@ -3541,7 +3881,7 @@ var adapters = {
3541
3881
  * Exposes all known adapters
3542
3882
  * @type {Object<string, Function|Object>}
3543
3883
  */
3544
- adapters: knownAdapters
3884
+ adapters: knownAdapters,
3545
3885
  };
3546
3886
 
3547
3887
  /**
@@ -3574,10 +3914,7 @@ function dispatchRequest(config) {
3574
3914
  config.headers = AxiosHeaders$1.from(config.headers);
3575
3915
 
3576
3916
  // Transform request data
3577
- config.data = transformData.call(
3578
- config,
3579
- config.transformRequest
3580
- );
3917
+ config.data = transformData.call(config, config.transformRequest);
3581
3918
 
3582
3919
  if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3583
3920
  config.headers.setContentType('application/x-www-form-urlencoded', false);
@@ -3585,39 +3922,38 @@ function dispatchRequest(config) {
3585
3922
 
3586
3923
  const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
3587
3924
 
3588
- return adapter(config).then(function onAdapterResolution(response) {
3589
- throwIfCancellationRequested(config);
3590
-
3591
- // Transform response data
3592
- response.data = transformData.call(
3593
- config,
3594
- config.transformResponse,
3595
- response
3596
- );
3597
-
3598
- response.headers = AxiosHeaders$1.from(response.headers);
3599
-
3600
- return response;
3601
- }, function onAdapterRejection(reason) {
3602
- if (!isCancel$1(reason)) {
3925
+ return adapter(config).then(
3926
+ function onAdapterResolution(response) {
3603
3927
  throwIfCancellationRequested(config);
3604
3928
 
3605
3929
  // Transform response data
3606
- if (reason && reason.response) {
3607
- reason.response.data = transformData.call(
3608
- config,
3609
- config.transformResponse,
3610
- reason.response
3611
- );
3612
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3930
+ response.data = transformData.call(config, config.transformResponse, response);
3931
+
3932
+ response.headers = AxiosHeaders$1.from(response.headers);
3933
+
3934
+ return response;
3935
+ },
3936
+ function onAdapterRejection(reason) {
3937
+ if (!isCancel$1(reason)) {
3938
+ throwIfCancellationRequested(config);
3939
+
3940
+ // Transform response data
3941
+ if (reason && reason.response) {
3942
+ reason.response.data = transformData.call(
3943
+ config,
3944
+ config.transformResponse,
3945
+ reason.response
3946
+ );
3947
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3948
+ }
3613
3949
  }
3614
- }
3615
3950
 
3616
- return Promise.reject(reason);
3617
- });
3951
+ return Promise.reject(reason);
3952
+ }
3953
+ );
3618
3954
  }
3619
3955
 
3620
- const VERSION$1 = "1.13.5";
3956
+ const VERSION$1 = "1.15.2";
3621
3957
 
3622
3958
  const validators$1 = {};
3623
3959
 
@@ -3641,7 +3977,15 @@ const deprecatedWarnings = {};
3641
3977
  */
3642
3978
  validators$1.transitional = function transitional(validator, version, message) {
3643
3979
  function formatMessage(opt, desc) {
3644
- return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3980
+ return (
3981
+ '[Axios v' +
3982
+ VERSION$1 +
3983
+ "] Transitional option '" +
3984
+ opt +
3985
+ "'" +
3986
+ desc +
3987
+ (message ? '. ' + message : '')
3988
+ );
3645
3989
  }
3646
3990
 
3647
3991
  // eslint-disable-next-line func-names
@@ -3673,7 +4017,7 @@ validators$1.spelling = function spelling(correctSpelling) {
3673
4017
  // eslint-disable-next-line no-console
3674
4018
  console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3675
4019
  return true;
3676
- }
4020
+ };
3677
4021
  };
3678
4022
 
3679
4023
  /**
@@ -3694,12 +4038,17 @@ function assertOptions(options, schema, allowUnknown) {
3694
4038
  let i = keys.length;
3695
4039
  while (i-- > 0) {
3696
4040
  const opt = keys[i];
3697
- const validator = schema[opt];
4041
+ // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
4042
+ // a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
4043
+ const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
3698
4044
  if (validator) {
3699
4045
  const value = options[opt];
3700
4046
  const result = value === undefined || validator(value, opt, options);
3701
4047
  if (result !== true) {
3702
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
4048
+ throw new AxiosError$1(
4049
+ 'option ' + opt + ' must be ' + result,
4050
+ AxiosError$1.ERR_BAD_OPTION_VALUE
4051
+ );
3703
4052
  }
3704
4053
  continue;
3705
4054
  }
@@ -3711,7 +4060,7 @@ function assertOptions(options, schema, allowUnknown) {
3711
4060
 
3712
4061
  var validator = {
3713
4062
  assertOptions,
3714
- validators: validators$1
4063
+ validators: validators$1,
3715
4064
  };
3716
4065
 
3717
4066
  const validators = validator.validators;
@@ -3728,7 +4077,7 @@ let Axios$1 = class Axios {
3728
4077
  this.defaults = instanceConfig || {};
3729
4078
  this.interceptors = {
3730
4079
  request: new InterceptorManager(),
3731
- response: new InterceptorManager()
4080
+ response: new InterceptorManager(),
3732
4081
  };
3733
4082
  }
3734
4083
 
@@ -3750,13 +4099,29 @@ let Axios$1 = class Axios {
3750
4099
  Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3751
4100
 
3752
4101
  // slice off the Error: ... line
3753
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
4102
+ const stack = (() => {
4103
+ if (!dummy.stack) {
4104
+ return '';
4105
+ }
4106
+
4107
+ const firstNewlineIndex = dummy.stack.indexOf('\n');
4108
+
4109
+ return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
4110
+ })();
3754
4111
  try {
3755
4112
  if (!err.stack) {
3756
4113
  err.stack = stack;
3757
4114
  // match without the 2 top stack lines
3758
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3759
- err.stack += '\n' + stack;
4115
+ } else if (stack) {
4116
+ const firstNewlineIndex = stack.indexOf('\n');
4117
+ const secondNewlineIndex =
4118
+ firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
4119
+ const stackWithoutTwoTopLines =
4120
+ secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
4121
+
4122
+ if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
4123
+ err.stack += '\n' + stack;
4124
+ }
3760
4125
  }
3761
4126
  } catch (e) {
3762
4127
  // ignore the case where "stack" is an un-writable property
@@ -3779,27 +4144,35 @@ let Axios$1 = class Axios {
3779
4144
 
3780
4145
  config = mergeConfig$1(this.defaults, config);
3781
4146
 
3782
- const {transitional, paramsSerializer, headers} = config;
4147
+ const { transitional, paramsSerializer, headers } = config;
3783
4148
 
3784
4149
  if (transitional !== undefined) {
3785
- validator.assertOptions(transitional, {
3786
- silentJSONParsing: validators.transitional(validators.boolean),
3787
- forcedJSONParsing: validators.transitional(validators.boolean),
3788
- clarifyTimeoutError: validators.transitional(validators.boolean),
3789
- legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
3790
- }, false);
4150
+ validator.assertOptions(
4151
+ transitional,
4152
+ {
4153
+ silentJSONParsing: validators.transitional(validators.boolean),
4154
+ forcedJSONParsing: validators.transitional(validators.boolean),
4155
+ clarifyTimeoutError: validators.transitional(validators.boolean),
4156
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
4157
+ },
4158
+ false
4159
+ );
3791
4160
  }
3792
4161
 
3793
4162
  if (paramsSerializer != null) {
3794
4163
  if (utils$1.isFunction(paramsSerializer)) {
3795
4164
  config.paramsSerializer = {
3796
- serialize: paramsSerializer
4165
+ serialize: paramsSerializer,
3797
4166
  };
3798
4167
  } else {
3799
- validator.assertOptions(paramsSerializer, {
3800
- encode: validators.function,
3801
- serialize: validators.function
3802
- }, true);
4168
+ validator.assertOptions(
4169
+ paramsSerializer,
4170
+ {
4171
+ encode: validators.function,
4172
+ serialize: validators.function,
4173
+ },
4174
+ true
4175
+ );
3803
4176
  }
3804
4177
  }
3805
4178
 
@@ -3810,26 +4183,25 @@ let Axios$1 = class Axios {
3810
4183
  config.allowAbsoluteUrls = true;
3811
4184
  }
3812
4185
 
3813
- validator.assertOptions(config, {
3814
- baseUrl: validators.spelling('baseURL'),
3815
- withXsrfToken: validators.spelling('withXSRFToken')
3816
- }, true);
4186
+ validator.assertOptions(
4187
+ config,
4188
+ {
4189
+ baseUrl: validators.spelling('baseURL'),
4190
+ withXsrfToken: validators.spelling('withXSRFToken'),
4191
+ },
4192
+ true
4193
+ );
3817
4194
 
3818
4195
  // Set config.method
3819
4196
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3820
4197
 
3821
4198
  // Flatten headers
3822
- let contextHeaders = headers && utils$1.merge(
3823
- headers.common,
3824
- headers[config.method]
3825
- );
4199
+ let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
3826
4200
 
3827
- headers && utils$1.forEach(
3828
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3829
- (method) => {
4201
+ headers &&
4202
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
3830
4203
  delete headers[method];
3831
- }
3832
- );
4204
+ });
3833
4205
 
3834
4206
  config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3835
4207
 
@@ -3844,7 +4216,8 @@ let Axios$1 = class Axios {
3844
4216
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3845
4217
 
3846
4218
  const transitional = config.transitional || transitionalDefaults;
3847
- const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
4219
+ const legacyInterceptorReqResOrdering =
4220
+ transitional && transitional.legacyInterceptorReqResOrdering;
3848
4221
 
3849
4222
  if (legacyInterceptorReqResOrdering) {
3850
4223
  requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
@@ -3918,28 +4291,32 @@ let Axios$1 = class Axios {
3918
4291
  // Provide aliases for supported request methods
3919
4292
  utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3920
4293
  /*eslint func-names:0*/
3921
- Axios$1.prototype[method] = function(url, config) {
3922
- return this.request(mergeConfig$1(config || {}, {
3923
- method,
3924
- url,
3925
- data: (config || {}).data
3926
- }));
4294
+ Axios$1.prototype[method] = function (url, config) {
4295
+ return this.request(
4296
+ mergeConfig$1(config || {}, {
4297
+ method,
4298
+ url,
4299
+ data: (config || {}).data,
4300
+ })
4301
+ );
3927
4302
  };
3928
4303
  });
3929
4304
 
3930
4305
  utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3931
- /*eslint func-names:0*/
3932
-
3933
4306
  function generateHTTPMethod(isForm) {
3934
4307
  return function httpMethod(url, data, config) {
3935
- return this.request(mergeConfig$1(config || {}, {
3936
- method,
3937
- headers: isForm ? {
3938
- 'Content-Type': 'multipart/form-data'
3939
- } : {},
3940
- url,
3941
- data
3942
- }));
4308
+ return this.request(
4309
+ mergeConfig$1(config || {}, {
4310
+ method,
4311
+ headers: isForm
4312
+ ? {
4313
+ 'Content-Type': 'multipart/form-data',
4314
+ }
4315
+ : {},
4316
+ url,
4317
+ data,
4318
+ })
4319
+ );
3943
4320
  };
3944
4321
  }
3945
4322
 
@@ -3970,7 +4347,7 @@ let CancelToken$1 = class CancelToken {
3970
4347
  const token = this;
3971
4348
 
3972
4349
  // eslint-disable-next-line func-names
3973
- this.promise.then(cancel => {
4350
+ this.promise.then((cancel) => {
3974
4351
  if (!token._listeners) return;
3975
4352
 
3976
4353
  let i = token._listeners.length;
@@ -3982,10 +4359,10 @@ let CancelToken$1 = class CancelToken {
3982
4359
  });
3983
4360
 
3984
4361
  // eslint-disable-next-line func-names
3985
- this.promise.then = onfulfilled => {
4362
+ this.promise.then = (onfulfilled) => {
3986
4363
  let _resolve;
3987
4364
  // eslint-disable-next-line func-names
3988
- const promise = new Promise(resolve => {
4365
+ const promise = new Promise((resolve) => {
3989
4366
  token.subscribe(resolve);
3990
4367
  _resolve = resolve;
3991
4368
  }).then(onfulfilled);
@@ -4073,7 +4450,7 @@ let CancelToken$1 = class CancelToken {
4073
4450
  });
4074
4451
  return {
4075
4452
  token,
4076
- cancel
4453
+ cancel,
4077
4454
  };
4078
4455
  }
4079
4456
  };
@@ -4113,7 +4490,7 @@ function spread$1(callback) {
4113
4490
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4114
4491
  */
4115
4492
  function isAxiosError$1(payload) {
4116
- return utils$1.isObject(payload) && (payload.isAxiosError === true);
4493
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
4117
4494
  }
4118
4495
 
4119
4496
  const HttpStatusCode$1 = {
@@ -4204,10 +4581,10 @@ function createInstance(defaultConfig) {
4204
4581
  const instance = bind(Axios$1.prototype.request, context);
4205
4582
 
4206
4583
  // Copy axios.prototype to instance
4207
- utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
4584
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
4208
4585
 
4209
4586
  // Copy context to instance
4210
- utils$1.extend(instance, context, null, {allOwnKeys: true});
4587
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
4211
4588
 
4212
4589
  // Factory for creating new instances
4213
4590
  instance.create = function create(instanceConfig) {
@@ -4251,7 +4628,7 @@ axios.mergeConfig = mergeConfig$1;
4251
4628
 
4252
4629
  axios.AxiosHeaders = AxiosHeaders$1;
4253
4630
 
4254
- axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4631
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4255
4632
 
4256
4633
  axios.getAdapter = adapters.getAdapter;
4257
4634
 
@@ -4278,7 +4655,7 @@ const {
4278
4655
  HttpStatusCode,
4279
4656
  formToJSON,
4280
4657
  getAdapter,
4281
- mergeConfig
4658
+ mergeConfig,
4282
4659
  } = axios;
4283
4660
 
4284
4661
  /******************************************************************************
@@ -7366,10 +7743,255 @@ class MayachainProtocol {
7366
7743
  }
7367
7744
  }
7368
7745
 
7746
+ const BASE_URL = 'https://1click.chaindefuser.com';
7747
+ class OneClickApi {
7748
+ constructor(apiKey) {
7749
+ this.headers = { 'Content-Type': 'application/json' };
7750
+ if (apiKey) {
7751
+ this.headers['Authorization'] = `Bearer ${apiKey}`;
7752
+ }
7753
+ }
7754
+ getTokens() {
7755
+ return __awaiter$4(this, void 0, void 0, function* () {
7756
+ const resp = yield fetch(`${BASE_URL}/v0/tokens`, { headers: this.headers });
7757
+ if (!resp.ok)
7758
+ throw new Error(`1Click getTokens failed: ${resp.status}`);
7759
+ return resp.json();
7760
+ });
7761
+ }
7762
+ getQuote(params) {
7763
+ return __awaiter$4(this, void 0, void 0, function* () {
7764
+ const resp = yield fetch(`${BASE_URL}/v0/quote`, {
7765
+ method: 'POST',
7766
+ headers: this.headers,
7767
+ body: JSON.stringify(params),
7768
+ });
7769
+ if (!resp.ok)
7770
+ throw new Error(`1Click getQuote failed: ${resp.status}`);
7771
+ return resp.json();
7772
+ });
7773
+ }
7774
+ submitDeposit(txHash, depositAddress) {
7775
+ return __awaiter$4(this, void 0, void 0, function* () {
7776
+ yield fetch(`${BASE_URL}/v0/deposit/submit`, {
7777
+ method: 'POST',
7778
+ headers: this.headers,
7779
+ body: JSON.stringify({ txHash, depositAddress }),
7780
+ }).catch(() => {
7781
+ // Fire-and-forget
7782
+ });
7783
+ });
7784
+ }
7785
+ }
7786
+
7787
+ const X_TO_ONECLICK = {
7788
+ BTC: 'btc',
7789
+ ETH: 'eth',
7790
+ ARB: 'arb',
7791
+ AVAX: 'avax',
7792
+ BSC: 'bsc',
7793
+ SOL: 'sol',
7794
+ DOGE: 'doge',
7795
+ DASH: 'dash',
7796
+ LTC: 'ltc',
7797
+ BCH: 'bch',
7798
+ XRP: 'xrp',
7799
+ ADA: 'cardano',
7800
+ SUI: 'sui',
7801
+ };
7802
+ const ONECLICK_TO_X = Object.fromEntries(Object.entries(X_TO_ONECLICK).map(([k, v]) => [v, k]));
7803
+ const xChainToOneClickBlockchain = (chain) => {
7804
+ var _a;
7805
+ return (_a = X_TO_ONECLICK[chain]) !== null && _a !== void 0 ? _a : null;
7806
+ };
7807
+ const oneClickBlockchainToXChain = (blockchain) => {
7808
+ var _a;
7809
+ return (_a = ONECLICK_TO_X[blockchain]) !== null && _a !== void 0 ? _a : null;
7810
+ };
7811
+ const findOneClickToken = (asset, tokens) => {
7812
+ if (isSynthAsset(asset) || isTradeAsset(asset) || isSecuredAsset(asset))
7813
+ return undefined;
7814
+ const blockchain = xChainToOneClickBlockchain(asset.chain);
7815
+ if (!blockchain)
7816
+ return undefined;
7817
+ return tokens.find((token) => {
7818
+ if (token.blockchain !== blockchain)
7819
+ return false;
7820
+ if (isTokenAsset(asset)) {
7821
+ // Match by contract address (case-insensitive)
7822
+ const assetContract = asset.symbol.includes('-') ? asset.symbol.split('-')[1] : undefined;
7823
+ return assetContract && token.contractAddress
7824
+ ? token.contractAddress.toLowerCase() === assetContract.toLowerCase()
7825
+ : false;
7826
+ }
7827
+ // Native asset: match by symbol, ensure no contract address on token
7828
+ return token.symbol.toUpperCase() === asset.symbol.toUpperCase() && !token.contractAddress;
7829
+ });
7830
+ };
7831
+
7832
+ class OneClickProtocol {
7833
+ constructor(configuration) {
7834
+ this.name = 'OneClick';
7835
+ this.api = new OneClickApi(configuration === null || configuration === void 0 ? void 0 : configuration.oneClickApiKey);
7836
+ this.wallet = configuration === null || configuration === void 0 ? void 0 : configuration.wallet;
7837
+ this.affiliateAddress = configuration === null || configuration === void 0 ? void 0 : configuration.affiliateAddress;
7838
+ this.affiliateBps = configuration === null || configuration === void 0 ? void 0 : configuration.affiliateBps;
7839
+ this.tokensCache = new CachedValue(() => this.api.getTokens(), 24 * 60 * 60 * 1000);
7840
+ }
7841
+ approveRouterToSpend(_params) {
7842
+ return __awaiter$4(this, void 0, void 0, function* () {
7843
+ throw new Error('Not implemented');
7844
+ });
7845
+ }
7846
+ shouldBeApproved(_params) {
7847
+ return __awaiter$4(this, void 0, void 0, function* () {
7848
+ return false;
7849
+ });
7850
+ }
7851
+ isAssetSupported(asset) {
7852
+ return __awaiter$4(this, void 0, void 0, function* () {
7853
+ if (isSynthAsset(asset) || isTradeAsset(asset) || isSecuredAsset(asset))
7854
+ return false;
7855
+ const tokens = yield this.tokensCache.getValue();
7856
+ return findOneClickToken(asset, tokens) !== undefined;
7857
+ });
7858
+ }
7859
+ getSupportedChains() {
7860
+ return __awaiter$4(this, void 0, void 0, function* () {
7861
+ const tokens = yield this.tokensCache.getValue();
7862
+ const chains = new Set();
7863
+ for (const token of tokens) {
7864
+ const chain = oneClickBlockchainToXChain(token.blockchain);
7865
+ if (chain)
7866
+ chains.add(chain);
7867
+ }
7868
+ return Array.from(chains);
7869
+ });
7870
+ }
7871
+ estimateSwap(params) {
7872
+ return __awaiter$4(this, void 0, void 0, function* () {
7873
+ var _a, _b, _c;
7874
+ const tokens = yield this.tokensCache.getValue();
7875
+ const srcToken = findOneClickToken(params.fromAsset, tokens);
7876
+ const destToken = findOneClickToken(params.destinationAsset, tokens);
7877
+ if (!srcToken || !destToken) {
7878
+ return this.errorQuote(params, srcToken ? 'Destination asset not supported' : 'Source asset not supported');
7879
+ }
7880
+ try {
7881
+ const isDry = !(params.fromAddress && params.destinationAddress);
7882
+ const deadline = new Date(Date.now() + 10 * 60 * 1000).toISOString();
7883
+ const appFees = this.affiliateAddress && this.affiliateBps
7884
+ ? [{ recipient: this.affiliateAddress, fee: this.affiliateBps }]
7885
+ : undefined;
7886
+ const resp = yield this.api.getQuote({
7887
+ dry: isDry,
7888
+ swapType: 'EXACT_INPUT',
7889
+ depositType: 'ORIGIN_CHAIN',
7890
+ recipientType: 'DESTINATION_CHAIN',
7891
+ refundType: 'ORIGIN_CHAIN',
7892
+ originAsset: srcToken.assetId,
7893
+ destinationAsset: destToken.assetId,
7894
+ amount: params.amount.baseAmount.amount().toString(),
7895
+ refundTo: params.fromAddress || '',
7896
+ recipient: params.destinationAddress || '',
7897
+ slippageTolerance: (_a = params.toleranceBps) !== null && _a !== void 0 ? _a : 100,
7898
+ deadline,
7899
+ appFees,
7900
+ });
7901
+ if (resp.error || resp.message) {
7902
+ return this.errorQuote(params, resp.error || resp.message || 'Unknown error');
7903
+ }
7904
+ const quote = resp.quote;
7905
+ const toAddress = (_b = quote.depositAddress) !== null && _b !== void 0 ? _b : '';
7906
+ return {
7907
+ protocol: this.name,
7908
+ toAddress,
7909
+ memo: '',
7910
+ expectedAmount: new CryptoAmount(baseAmount(quote.amountOut, destToken.decimals), params.destinationAsset),
7911
+ dustThreshold: new CryptoAmount(baseAmount(0), params.fromAsset),
7912
+ totalSwapSeconds: (_c = quote.timeEstimate) !== null && _c !== void 0 ? _c : 0,
7913
+ maxStreamingQuantity: undefined,
7914
+ canSwap: toAddress !== '',
7915
+ warning: '',
7916
+ errors: [],
7917
+ slipBasisPoints: 0,
7918
+ fees: {
7919
+ asset: params.fromAsset,
7920
+ affiliateFee: new CryptoAmount(baseAmount(0), params.fromAsset),
7921
+ outboundFee: new CryptoAmount(baseAmount(0), params.destinationAsset),
7922
+ },
7923
+ };
7924
+ }
7925
+ catch (e) {
7926
+ return this.errorQuote(params, e instanceof Error ? e.message : 'Unknown error');
7927
+ }
7928
+ });
7929
+ }
7930
+ doSwap(params) {
7931
+ return __awaiter$4(this, void 0, void 0, function* () {
7932
+ const quoteSwap = yield this.estimateSwap(params);
7933
+ if (!quoteSwap.canSwap) {
7934
+ throw new Error(`Can not make swap. ${quoteSwap.errors.join('\n')}`);
7935
+ }
7936
+ if (!this.wallet)
7937
+ throw new Error('Wallet not configured. Can not do swap');
7938
+ const hash = yield this.wallet.transfer({
7939
+ recipient: quoteSwap.toAddress,
7940
+ amount: params.amount.baseAmount,
7941
+ asset: params.fromAsset,
7942
+ memo: quoteSwap.memo,
7943
+ });
7944
+ // Funds are already on the wire. Awaiting submitDeposit lets callers distinguish
7945
+ // "deposit registered, swap will settle" from "registration silently failed, swap will
7946
+ // never settle" — surface the failure with the broadcast hash so it can be retried.
7947
+ try {
7948
+ yield this.api.submitDeposit(hash, quoteSwap.toAddress);
7949
+ }
7950
+ catch (e) {
7951
+ throw new Error(`1Click deposit tx ${hash} was broadcast, but submitDeposit failed: ${e instanceof Error ? e.message : 'unknown error'}`);
7952
+ }
7953
+ // Explorer URL is best-effort; the hash is what callers actually need for tracking.
7954
+ let url = '';
7955
+ try {
7956
+ url = yield this.wallet.getExplorerTxUrl(params.fromAsset.chain, hash);
7957
+ }
7958
+ catch (_a) {
7959
+ // swallow: explorer URL lookup must not reject a successful swap
7960
+ }
7961
+ return { hash, url };
7962
+ });
7963
+ }
7964
+ getSwapHistory(_params) {
7965
+ return __awaiter$4(this, void 0, void 0, function* () {
7966
+ return { count: 0, swaps: [] };
7967
+ });
7968
+ }
7969
+ errorQuote(params, error) {
7970
+ return {
7971
+ protocol: this.name,
7972
+ toAddress: '',
7973
+ memo: '',
7974
+ expectedAmount: new CryptoAmount(baseAmount(0), params.destinationAsset),
7975
+ dustThreshold: new CryptoAmount(baseAmount(0), params.fromAsset),
7976
+ totalSwapSeconds: 0,
7977
+ maxStreamingQuantity: undefined,
7978
+ canSwap: false,
7979
+ warning: '',
7980
+ errors: [error],
7981
+ slipBasisPoints: 0,
7982
+ fees: {
7983
+ asset: params.fromAsset,
7984
+ affiliateFee: new CryptoAmount(baseAmount(0), params.fromAsset),
7985
+ outboundFee: new CryptoAmount(baseAmount(0), params.destinationAsset),
7986
+ },
7987
+ };
7988
+ }
7989
+ }
7990
+
7369
7991
  /**
7370
- * The base URL for the Midgard API provided by Nine Realms.
7992
+ * The base URL for the Midgard API endpoint.
7371
7993
  */
7372
- const MIDGARD_API_9R_URL = 'https://midgard.ninerealms.com/';
7994
+ const MIDGARD_API_URL = 'https://midgard.thorchain.network/';
7373
7995
 
7374
7996
  /******************************************************************************
7375
7997
  Copyright (c) Microsoft Corporation.
@@ -9844,7 +10466,7 @@ class Configuration {
9844
10466
  /**
9845
10467
  * The base URL for the Midgard API.
9846
10468
  */
9847
- const baseUrl = MIDGARD_API_9R_URL;
10469
+ const baseUrl = MIDGARD_API_URL;
9848
10470
  /**
9849
10471
  * Default configuration for the Midgard API client.
9850
10472
  */
@@ -10198,15 +10820,15 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
10198
10820
  const defaultMidgardConfig = {
10199
10821
  mainnet: {
10200
10822
  apiRetries: 3,
10201
- midgardBaseUrls: ['https://midgard.ninerealms.com'],
10823
+ midgardBaseUrls: ['https://midgard.thorchain.network', 'https://gateway.liquify.com/chain/thorchain_midgard'],
10202
10824
  },
10203
10825
  stagenet: {
10204
10826
  apiRetries: 3,
10205
- midgardBaseUrls: ['https://stagenet-midgard.ninerealms.com'],
10827
+ midgardBaseUrls: [],
10206
10828
  },
10207
10829
  testnet: {
10208
10830
  apiRetries: 3,
10209
- midgardBaseUrls: ['https://testnet.midgard.thorchain.info'],
10831
+ midgardBaseUrls: ['deprecated'],
10210
10832
  },
10211
10833
  };
10212
10834
  class Midgard {
@@ -10432,7 +11054,7 @@ class MidgardQuery {
10432
11054
  getFallbackDecimals(asset) {
10433
11055
  const assetString = assetToString(asset);
10434
11056
  // Map of assets to their actual decimal places from THORChain pools
10435
- // Data sourced from https://thornode-v2.ninerealms.com/thorchain/pools
11057
+ // Data sourced from https://gateway.liquify.com/chain/thorchain_api/thorchain/pools
10436
11058
  const fallbackDecimalMap = {
10437
11059
  // Bitcoin and forks
10438
11060
  'BTC.BTC': 8,
@@ -10751,6 +11373,7 @@ const getProtocolConfig = (name, configuration) => {
10751
11373
  network: configuration.network,
10752
11374
  affiliateBrokers: configuration.affiliateBrokers,
10753
11375
  brokerUrl: configuration.brokerUrl,
11376
+ oneClickApiKey: configuration.oneClickApiKey,
10754
11377
  };
10755
11378
  };
10756
11379
  class ProtocolFactory {
@@ -10763,6 +11386,8 @@ class ProtocolFactory {
10763
11386
  return new MayachainProtocol(protocolConfig);
10764
11387
  case 'Chainflip':
10765
11388
  return new ChainflipProtocol(protocolConfig);
11389
+ case 'OneClick':
11390
+ return new OneClickProtocol(protocolConfig);
10766
11391
  }
10767
11392
  }
10768
11393
  }