@kimafinance/kima-transaction-widget 1.2.72-beta.1 → 1.2.73-beta.1

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/dist/index.js CHANGED
@@ -7964,7 +7964,7 @@ function output(out, instance) {
7964
7964
  exports.output = output;
7965
7965
  const assert = { number, bool, bytes, hash, exists, output };
7966
7966
  exports.default = assert;
7967
- //# sourceMappingURL=_assert.js.map
7967
+
7968
7968
  });
7969
7969
 
7970
7970
  unwrapExports(_assert);
@@ -7973,7 +7973,7 @@ var crypto = createCommonjsModule(function (module, exports) {
7973
7973
  Object.defineProperty(exports, "__esModule", { value: true });
7974
7974
  exports.crypto = void 0;
7975
7975
  exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
7976
- //# sourceMappingURL=crypto.js.map
7976
+
7977
7977
  });
7978
7978
 
7979
7979
  unwrapExports(crypto);
@@ -8175,7 +8175,7 @@ function randomBytes(bytesLength = 32) {
8175
8175
  throw new Error('crypto.getRandomValues must be defined');
8176
8176
  }
8177
8177
  exports.randomBytes = randomBytes;
8178
- //# sourceMappingURL=utils.js.map
8178
+
8179
8179
  });
8180
8180
 
8181
8181
  unwrapExports(utils);
@@ -8297,7 +8297,7 @@ class SHA2 extends utils.Hash {
8297
8297
  }
8298
8298
  }
8299
8299
  exports.SHA2 = SHA2;
8300
- //# sourceMappingURL=_sha2.js.map
8300
+
8301
8301
  });
8302
8302
 
8303
8303
  unwrapExports(_sha2);
@@ -8430,7 +8430,7 @@ class SHA224 extends SHA256 {
8430
8430
  */
8431
8431
  exports.sha256 = (0, utils.wrapConstructor)(() => new SHA256());
8432
8432
  exports.sha224 = (0, utils.wrapConstructor)(() => new SHA224());
8433
- //# sourceMappingURL=sha256.js.map
8433
+
8434
8434
  });
8435
8435
 
8436
8436
  unwrapExports(sha256);
@@ -8813,6 +8813,8 @@ const isFormData = (thing) => {
8813
8813
  */
8814
8814
  const isURLSearchParams = kindOfTest('URLSearchParams');
8815
8815
 
8816
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
8817
+
8816
8818
  /**
8817
8819
  * Trim excess whitespace off the beginning and end of a string
8818
8820
  *
@@ -9201,8 +9203,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
9201
9203
  const noop = () => {};
9202
9204
 
9203
9205
  const toFiniteNumber = (value, defaultValue) => {
9204
- value = +value;
9205
- return Number.isFinite(value) ? value : defaultValue;
9206
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
9206
9207
  };
9207
9208
 
9208
9209
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
@@ -9272,6 +9273,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
9272
9273
  const isThenable = (thing) =>
9273
9274
  thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
9274
9275
 
9276
+ // original code
9277
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
9278
+
9279
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
9280
+ if (setImmediateSupported) {
9281
+ return setImmediate;
9282
+ }
9283
+
9284
+ return postMessageSupported ? ((token, callbacks) => {
9285
+ _global.addEventListener("message", ({source, data}) => {
9286
+ if (source === _global && data === token) {
9287
+ callbacks.length && callbacks.shift()();
9288
+ }
9289
+ }, false);
9290
+
9291
+ return (cb) => {
9292
+ callbacks.push(cb);
9293
+ _global.postMessage(token, "*");
9294
+ }
9295
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
9296
+ })(
9297
+ typeof setImmediate === 'function',
9298
+ isFunction(_global.postMessage)
9299
+ );
9300
+
9301
+ const asap = typeof queueMicrotask !== 'undefined' ?
9302
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
9303
+
9304
+ // *********************
9305
+
9275
9306
  var utils$1 = {
9276
9307
  isArray,
9277
9308
  isArrayBuffer,
@@ -9283,6 +9314,10 @@ var utils$1 = {
9283
9314
  isBoolean,
9284
9315
  isObject,
9285
9316
  isPlainObject,
9317
+ isReadableStream,
9318
+ isRequest,
9319
+ isResponse,
9320
+ isHeaders,
9286
9321
  isUndefined,
9287
9322
  isDate,
9288
9323
  isFile,
@@ -9323,7 +9358,9 @@ var utils$1 = {
9323
9358
  isSpecCompliantForm,
9324
9359
  toJSONObject,
9325
9360
  isAsyncFn,
9326
- isThenable
9361
+ isThenable,
9362
+ setImmediate: _setImmediate,
9363
+ asap
9327
9364
  };
9328
9365
 
9329
9366
  /**
@@ -9351,7 +9388,10 @@ function AxiosError(message, code, config, request, response) {
9351
9388
  code && (this.code = code);
9352
9389
  config && (this.config = config);
9353
9390
  request && (this.request = request);
9354
- response && (this.response = response);
9391
+ if (response) {
9392
+ this.response = response;
9393
+ this.status = response.status ? response.status : null;
9394
+ }
9355
9395
  }
9356
9396
 
9357
9397
  utils$1.inherits(AxiosError, Error, {
@@ -9371,7 +9411,7 @@ utils$1.inherits(AxiosError, Error, {
9371
9411
  // Axios
9372
9412
  config: utils$1.toJSONObject(this.config),
9373
9413
  code: this.code,
9374
- status: this.response && this.response.status ? this.response.status : null
9414
+ status: this.status
9375
9415
  };
9376
9416
  }
9377
9417
  });
@@ -9837,6 +9877,8 @@ var platform = {
9837
9877
 
9838
9878
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
9839
9879
 
9880
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
9881
+
9840
9882
  /**
9841
9883
  * Determine if we're running in a standard browser environment
9842
9884
  *
@@ -9854,10 +9896,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
9854
9896
  *
9855
9897
  * @returns {boolean}
9856
9898
  */
9857
- const hasStandardBrowserEnv = (
9858
- (product) => {
9859
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
9860
- })(typeof navigator !== 'undefined' && navigator.product);
9899
+ const hasStandardBrowserEnv = hasBrowserEnv &&
9900
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
9861
9901
 
9862
9902
  /**
9863
9903
  * Determine if we're running in a standard browser webWorker environment
@@ -9877,11 +9917,15 @@ const hasStandardBrowserWebWorkerEnv = (() => {
9877
9917
  );
9878
9918
  })();
9879
9919
 
9920
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
9921
+
9880
9922
  var utils$2 = {
9881
9923
  __proto__: null,
9882
9924
  hasBrowserEnv: hasBrowserEnv,
9883
9925
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
9884
- hasStandardBrowserEnv: hasStandardBrowserEnv
9926
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
9927
+ navigator: _navigator,
9928
+ origin: origin
9885
9929
  };
9886
9930
 
9887
9931
  var platform$1 = {
@@ -10021,7 +10065,7 @@ const defaults = {
10021
10065
 
10022
10066
  transitional: transitionalDefaults,
10023
10067
 
10024
- adapter: ['xhr', 'http'],
10068
+ adapter: ['xhr', 'http', 'fetch'],
10025
10069
 
10026
10070
  transformRequest: [function transformRequest(data, headers) {
10027
10071
  const contentType = headers.getContentType() || '';
@@ -10042,7 +10086,8 @@ const defaults = {
10042
10086
  utils$1.isBuffer(data) ||
10043
10087
  utils$1.isStream(data) ||
10044
10088
  utils$1.isFile(data) ||
10045
- utils$1.isBlob(data)
10089
+ utils$1.isBlob(data) ||
10090
+ utils$1.isReadableStream(data)
10046
10091
  ) {
10047
10092
  return data;
10048
10093
  }
@@ -10085,6 +10130,10 @@ const defaults = {
10085
10130
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
10086
10131
  const JSONRequested = this.responseType === 'json';
10087
10132
 
10133
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
10134
+ return data;
10135
+ }
10136
+
10088
10137
  if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
10089
10138
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
10090
10139
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -10286,6 +10335,10 @@ class AxiosHeaders {
10286
10335
  setHeaders(header, valueOrRewrite);
10287
10336
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
10288
10337
  setHeaders(parseHeaders(header), valueOrRewrite);
10338
+ } else if (utils$1.isHeaders(header)) {
10339
+ for (const [key, value] of header.entries()) {
10340
+ setHeader(value, key, rewrite);
10341
+ }
10289
10342
  } else {
10290
10343
  header != null && setHeader(valueOrRewrite, header, rewrite);
10291
10344
  }
@@ -10551,96 +10604,153 @@ function settle(resolve, reject, response) {
10551
10604
  }
10552
10605
  }
10553
10606
 
10554
- var cookies = platform$1.hasStandardBrowserEnv ?
10607
+ function parseProtocol(url) {
10608
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
10609
+ return match && match[1] || '';
10610
+ }
10555
10611
 
10556
- // Standard browser envs support document.cookie
10557
- {
10558
- write(name, value, expires, path, domain, secure) {
10559
- const cookie = [name + '=' + encodeURIComponent(value)];
10612
+ /**
10613
+ * Calculate data maxRate
10614
+ * @param {Number} [samplesCount= 10]
10615
+ * @param {Number} [min= 1000]
10616
+ * @returns {Function}
10617
+ */
10618
+ function speedometer(samplesCount, min) {
10619
+ samplesCount = samplesCount || 10;
10620
+ const bytes = new Array(samplesCount);
10621
+ const timestamps = new Array(samplesCount);
10622
+ let head = 0;
10623
+ let tail = 0;
10624
+ let firstSampleTS;
10560
10625
 
10561
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
10626
+ min = min !== undefined ? min : 1000;
10562
10627
 
10563
- utils$1.isString(path) && cookie.push('path=' + path);
10628
+ return function push(chunkLength) {
10629
+ const now = Date.now();
10564
10630
 
10565
- utils$1.isString(domain) && cookie.push('domain=' + domain);
10631
+ const startedAt = timestamps[tail];
10566
10632
 
10567
- secure === true && cookie.push('secure');
10633
+ if (!firstSampleTS) {
10634
+ firstSampleTS = now;
10635
+ }
10568
10636
 
10569
- document.cookie = cookie.join('; ');
10570
- },
10637
+ bytes[head] = chunkLength;
10638
+ timestamps[head] = now;
10571
10639
 
10572
- read(name) {
10573
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
10574
- return (match ? decodeURIComponent(match[3]) : null);
10575
- },
10640
+ let i = tail;
10641
+ let bytesCount = 0;
10576
10642
 
10577
- remove(name) {
10578
- this.write(name, '', Date.now() - 86400000);
10643
+ while (i !== head) {
10644
+ bytesCount += bytes[i++];
10645
+ i = i % samplesCount;
10579
10646
  }
10580
- }
10581
10647
 
10582
- :
10648
+ head = (head + 1) % samplesCount;
10583
10649
 
10584
- // Non-standard browser env (web workers, react-native) lack needed support.
10585
- {
10586
- write() {},
10587
- read() {
10588
- return null;
10589
- },
10590
- remove() {}
10591
- };
10650
+ if (head === tail) {
10651
+ tail = (tail + 1) % samplesCount;
10652
+ }
10592
10653
 
10593
- /**
10594
- * Determines whether the specified URL is absolute
10595
- *
10596
- * @param {string} url The URL to test
10597
- *
10598
- * @returns {boolean} True if the specified URL is absolute, otherwise false
10599
- */
10600
- function isAbsoluteURL(url) {
10601
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
10602
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
10603
- // by any combination of letters, digits, plus, period, or hyphen.
10604
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
10605
- }
10654
+ if (now - firstSampleTS < min) {
10655
+ return;
10656
+ }
10606
10657
 
10607
- /**
10608
- * Creates a new URL by combining the specified URLs
10609
- *
10610
- * @param {string} baseURL The base URL
10611
- * @param {string} relativeURL The relative URL
10612
- *
10613
- * @returns {string} The combined URL
10614
- */
10615
- function combineURLs(baseURL, relativeURL) {
10616
- return relativeURL
10617
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
10618
- : baseURL;
10658
+ const passed = startedAt && now - startedAt;
10659
+
10660
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
10661
+ };
10619
10662
  }
10620
10663
 
10621
10664
  /**
10622
- * Creates a new URL by combining the baseURL with the requestedURL,
10623
- * only when the requestedURL is not already an absolute URL.
10624
- * If the requestURL is absolute, this function returns the requestedURL untouched.
10625
- *
10626
- * @param {string} baseURL The base URL
10627
- * @param {string} requestedURL Absolute or relative URL to combine
10628
- *
10629
- * @returns {string} The combined full path
10665
+ * Throttle decorator
10666
+ * @param {Function} fn
10667
+ * @param {Number} freq
10668
+ * @return {Function}
10630
10669
  */
10631
- function buildFullPath(baseURL, requestedURL) {
10632
- if (baseURL && !isAbsoluteURL(requestedURL)) {
10633
- return combineURLs(baseURL, requestedURL);
10634
- }
10635
- return requestedURL;
10670
+ function throttle(fn, freq) {
10671
+ let timestamp = 0;
10672
+ let threshold = 1000 / freq;
10673
+ let lastArgs;
10674
+ let timer;
10675
+
10676
+ const invoke = (args, now = Date.now()) => {
10677
+ timestamp = now;
10678
+ lastArgs = null;
10679
+ if (timer) {
10680
+ clearTimeout(timer);
10681
+ timer = null;
10682
+ }
10683
+ fn.apply(null, args);
10684
+ };
10685
+
10686
+ const throttled = (...args) => {
10687
+ const now = Date.now();
10688
+ const passed = now - timestamp;
10689
+ if ( passed >= threshold) {
10690
+ invoke(args, now);
10691
+ } else {
10692
+ lastArgs = args;
10693
+ if (!timer) {
10694
+ timer = setTimeout(() => {
10695
+ timer = null;
10696
+ invoke(lastArgs);
10697
+ }, threshold - passed);
10698
+ }
10699
+ }
10700
+ };
10701
+
10702
+ const flush = () => lastArgs && invoke(lastArgs);
10703
+
10704
+ return [throttled, flush];
10636
10705
  }
10637
10706
 
10707
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
10708
+ let bytesNotified = 0;
10709
+ const _speedometer = speedometer(50, 250);
10710
+
10711
+ return throttle(e => {
10712
+ const loaded = e.loaded;
10713
+ const total = e.lengthComputable ? e.total : undefined;
10714
+ const progressBytes = loaded - bytesNotified;
10715
+ const rate = _speedometer(progressBytes);
10716
+ const inRange = loaded <= total;
10717
+
10718
+ bytesNotified = loaded;
10719
+
10720
+ const data = {
10721
+ loaded,
10722
+ total,
10723
+ progress: total ? (loaded / total) : undefined,
10724
+ bytes: progressBytes,
10725
+ rate: rate ? rate : undefined,
10726
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
10727
+ event: e,
10728
+ lengthComputable: total != null,
10729
+ [isDownloadStream ? 'download' : 'upload']: true
10730
+ };
10731
+
10732
+ listener(data);
10733
+ }, freq);
10734
+ };
10735
+
10736
+ const progressEventDecorator = (total, throttled) => {
10737
+ const lengthComputable = total != null;
10738
+
10739
+ return [(loaded) => throttled[0]({
10740
+ lengthComputable,
10741
+ total,
10742
+ loaded
10743
+ }), throttled[1]];
10744
+ };
10745
+
10746
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
10747
+
10638
10748
  var isURLSameOrigin = platform$1.hasStandardBrowserEnv ?
10639
10749
 
10640
10750
  // Standard browser envs have full support of the APIs needed to test
10641
10751
  // whether the request URL is of the same origin as current location.
10642
10752
  (function standardBrowserEnv() {
10643
- const msie = /(msie|trident)/i.test(navigator.userAgent);
10753
+ const msie = platform$1.navigator && /(msie|trident)/i.test(platform$1.navigator.userAgent);
10644
10754
  const urlParsingNode = document.createElement('a');
10645
10755
  let originURL;
10646
10756
 
@@ -10698,137 +10808,267 @@ var isURLSameOrigin = platform$1.hasStandardBrowserEnv ?
10698
10808
  };
10699
10809
  })();
10700
10810
 
10701
- function parseProtocol(url) {
10702
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
10703
- return match && match[1] || '';
10704
- }
10705
-
10706
- /**
10707
- * Calculate data maxRate
10708
- * @param {Number} [samplesCount= 10]
10709
- * @param {Number} [min= 1000]
10710
- * @returns {Function}
10711
- */
10712
- function speedometer(samplesCount, min) {
10713
- samplesCount = samplesCount || 10;
10714
- const bytes = new Array(samplesCount);
10715
- const timestamps = new Array(samplesCount);
10716
- let head = 0;
10717
- let tail = 0;
10718
- let firstSampleTS;
10719
-
10720
- min = min !== undefined ? min : 1000;
10721
-
10722
- return function push(chunkLength) {
10723
- const now = Date.now();
10811
+ var cookies = platform$1.hasStandardBrowserEnv ?
10724
10812
 
10725
- const startedAt = timestamps[tail];
10813
+ // Standard browser envs support document.cookie
10814
+ {
10815
+ write(name, value, expires, path, domain, secure) {
10816
+ const cookie = [name + '=' + encodeURIComponent(value)];
10726
10817
 
10727
- if (!firstSampleTS) {
10728
- firstSampleTS = now;
10729
- }
10818
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
10730
10819
 
10731
- bytes[head] = chunkLength;
10732
- timestamps[head] = now;
10820
+ utils$1.isString(path) && cookie.push('path=' + path);
10733
10821
 
10734
- let i = tail;
10735
- let bytesCount = 0;
10822
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
10736
10823
 
10737
- while (i !== head) {
10738
- bytesCount += bytes[i++];
10739
- i = i % samplesCount;
10740
- }
10824
+ secure === true && cookie.push('secure');
10741
10825
 
10742
- head = (head + 1) % samplesCount;
10826
+ document.cookie = cookie.join('; ');
10827
+ },
10743
10828
 
10744
- if (head === tail) {
10745
- tail = (tail + 1) % samplesCount;
10746
- }
10829
+ read(name) {
10830
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
10831
+ return (match ? decodeURIComponent(match[3]) : null);
10832
+ },
10747
10833
 
10748
- if (now - firstSampleTS < min) {
10749
- return;
10834
+ remove(name) {
10835
+ this.write(name, '', Date.now() - 86400000);
10750
10836
  }
10837
+ }
10751
10838
 
10752
- const passed = startedAt && now - startedAt;
10839
+ :
10753
10840
 
10754
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
10841
+ // Non-standard browser env (web workers, react-native) lack needed support.
10842
+ {
10843
+ write() {},
10844
+ read() {
10845
+ return null;
10846
+ },
10847
+ remove() {}
10755
10848
  };
10756
- }
10757
10849
 
10758
- function progressEventReducer(listener, isDownloadStream) {
10759
- let bytesNotified = 0;
10760
- const _speedometer = speedometer(50, 250);
10850
+ /**
10851
+ * Determines whether the specified URL is absolute
10852
+ *
10853
+ * @param {string} url The URL to test
10854
+ *
10855
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
10856
+ */
10857
+ function isAbsoluteURL(url) {
10858
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
10859
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
10860
+ // by any combination of letters, digits, plus, period, or hyphen.
10861
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
10862
+ }
10761
10863
 
10762
- return e => {
10763
- const loaded = e.loaded;
10764
- const total = e.lengthComputable ? e.total : undefined;
10765
- const progressBytes = loaded - bytesNotified;
10766
- const rate = _speedometer(progressBytes);
10767
- const inRange = loaded <= total;
10864
+ /**
10865
+ * Creates a new URL by combining the specified URLs
10866
+ *
10867
+ * @param {string} baseURL The base URL
10868
+ * @param {string} relativeURL The relative URL
10869
+ *
10870
+ * @returns {string} The combined URL
10871
+ */
10872
+ function combineURLs(baseURL, relativeURL) {
10873
+ return relativeURL
10874
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
10875
+ : baseURL;
10876
+ }
10768
10877
 
10769
- bytesNotified = loaded;
10878
+ /**
10879
+ * Creates a new URL by combining the baseURL with the requestedURL,
10880
+ * only when the requestedURL is not already an absolute URL.
10881
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
10882
+ *
10883
+ * @param {string} baseURL The base URL
10884
+ * @param {string} requestedURL Absolute or relative URL to combine
10885
+ *
10886
+ * @returns {string} The combined full path
10887
+ */
10888
+ function buildFullPath(baseURL, requestedURL) {
10889
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
10890
+ return combineURLs(baseURL, requestedURL);
10891
+ }
10892
+ return requestedURL;
10893
+ }
10770
10894
 
10771
- const data = {
10772
- loaded,
10773
- total,
10774
- progress: total ? (loaded / total) : undefined,
10775
- bytes: progressBytes,
10776
- rate: rate ? rate : undefined,
10777
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
10778
- event: e
10779
- };
10895
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
10780
10896
 
10781
- data[isDownloadStream ? 'download' : 'upload'] = true;
10897
+ /**
10898
+ * Config-specific merge-function which creates a new config-object
10899
+ * by merging two configuration objects together.
10900
+ *
10901
+ * @param {Object} config1
10902
+ * @param {Object} config2
10903
+ *
10904
+ * @returns {Object} New object resulting from merging config2 to config1
10905
+ */
10906
+ function mergeConfig(config1, config2) {
10907
+ // eslint-disable-next-line no-param-reassign
10908
+ config2 = config2 || {};
10909
+ const config = {};
10782
10910
 
10783
- listener(data);
10911
+ function getMergedValue(target, source, caseless) {
10912
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
10913
+ return utils$1.merge.call({caseless}, target, source);
10914
+ } else if (utils$1.isPlainObject(source)) {
10915
+ return utils$1.merge({}, source);
10916
+ } else if (utils$1.isArray(source)) {
10917
+ return source.slice();
10918
+ }
10919
+ return source;
10920
+ }
10921
+
10922
+ // eslint-disable-next-line consistent-return
10923
+ function mergeDeepProperties(a, b, caseless) {
10924
+ if (!utils$1.isUndefined(b)) {
10925
+ return getMergedValue(a, b, caseless);
10926
+ } else if (!utils$1.isUndefined(a)) {
10927
+ return getMergedValue(undefined, a, caseless);
10928
+ }
10929
+ }
10930
+
10931
+ // eslint-disable-next-line consistent-return
10932
+ function valueFromConfig2(a, b) {
10933
+ if (!utils$1.isUndefined(b)) {
10934
+ return getMergedValue(undefined, b);
10935
+ }
10936
+ }
10937
+
10938
+ // eslint-disable-next-line consistent-return
10939
+ function defaultToConfig2(a, b) {
10940
+ if (!utils$1.isUndefined(b)) {
10941
+ return getMergedValue(undefined, b);
10942
+ } else if (!utils$1.isUndefined(a)) {
10943
+ return getMergedValue(undefined, a);
10944
+ }
10945
+ }
10946
+
10947
+ // eslint-disable-next-line consistent-return
10948
+ function mergeDirectKeys(a, b, prop) {
10949
+ if (prop in config2) {
10950
+ return getMergedValue(a, b);
10951
+ } else if (prop in config1) {
10952
+ return getMergedValue(undefined, a);
10953
+ }
10954
+ }
10955
+
10956
+ const mergeMap = {
10957
+ url: valueFromConfig2,
10958
+ method: valueFromConfig2,
10959
+ data: valueFromConfig2,
10960
+ baseURL: defaultToConfig2,
10961
+ transformRequest: defaultToConfig2,
10962
+ transformResponse: defaultToConfig2,
10963
+ paramsSerializer: defaultToConfig2,
10964
+ timeout: defaultToConfig2,
10965
+ timeoutMessage: defaultToConfig2,
10966
+ withCredentials: defaultToConfig2,
10967
+ withXSRFToken: defaultToConfig2,
10968
+ adapter: defaultToConfig2,
10969
+ responseType: defaultToConfig2,
10970
+ xsrfCookieName: defaultToConfig2,
10971
+ xsrfHeaderName: defaultToConfig2,
10972
+ onUploadProgress: defaultToConfig2,
10973
+ onDownloadProgress: defaultToConfig2,
10974
+ decompress: defaultToConfig2,
10975
+ maxContentLength: defaultToConfig2,
10976
+ maxBodyLength: defaultToConfig2,
10977
+ beforeRedirect: defaultToConfig2,
10978
+ transport: defaultToConfig2,
10979
+ httpAgent: defaultToConfig2,
10980
+ httpsAgent: defaultToConfig2,
10981
+ cancelToken: defaultToConfig2,
10982
+ socketPath: defaultToConfig2,
10983
+ responseEncoding: defaultToConfig2,
10984
+ validateStatus: mergeDirectKeys,
10985
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
10784
10986
  };
10987
+
10988
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
10989
+ const merge = mergeMap[prop] || mergeDeepProperties;
10990
+ const configValue = merge(config1[prop], config2[prop], prop);
10991
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
10992
+ });
10993
+
10994
+ return config;
10785
10995
  }
10786
10996
 
10787
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
10997
+ var resolveConfig = (config) => {
10998
+ const newConfig = mergeConfig({}, config);
10788
10999
 
10789
- var xhrAdapter = isXHRAdapterSupported && function (config) {
10790
- return new Promise(function dispatchXhrRequest(resolve, reject) {
10791
- let requestData = config.data;
10792
- const requestHeaders = AxiosHeaders.from(config.headers).normalize();
10793
- let {responseType, withXSRFToken} = config;
10794
- let onCanceled;
10795
- function done() {
10796
- if (config.cancelToken) {
10797
- config.cancelToken.unsubscribe(onCanceled);
10798
- }
11000
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
10799
11001
 
10800
- if (config.signal) {
10801
- config.signal.removeEventListener('abort', onCanceled);
10802
- }
11002
+ newConfig.headers = headers = AxiosHeaders.from(headers);
11003
+
11004
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
11005
+
11006
+ // HTTP basic authentication
11007
+ if (auth) {
11008
+ headers.set('Authorization', 'Basic ' +
11009
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
11010
+ );
11011
+ }
11012
+
11013
+ let contentType;
11014
+
11015
+ if (utils$1.isFormData(data)) {
11016
+ if (platform$1.hasStandardBrowserEnv || platform$1.hasStandardBrowserWebWorkerEnv) {
11017
+ headers.setContentType(undefined); // Let the browser set it
11018
+ } else if ((contentType = headers.getContentType()) !== false) {
11019
+ // fix semicolon duplication issue for ReactNative FormData implementation
11020
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
11021
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
10803
11022
  }
11023
+ }
11024
+
11025
+ // Add xsrf header
11026
+ // This is only done if running in a standard browser environment.
11027
+ // Specifically not if we're in a web worker, or react-native.
10804
11028
 
10805
- let contentType;
11029
+ if (platform$1.hasStandardBrowserEnv) {
11030
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
10806
11031
 
10807
- if (utils$1.isFormData(requestData)) {
10808
- if (platform$1.hasStandardBrowserEnv || platform$1.hasStandardBrowserWebWorkerEnv) {
10809
- requestHeaders.setContentType(false); // Let the browser set it
10810
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
10811
- // fix semicolon duplication issue for ReactNative FormData implementation
10812
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
10813
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
11032
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
11033
+ // Add xsrf header
11034
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
11035
+
11036
+ if (xsrfValue) {
11037
+ headers.set(xsrfHeaderName, xsrfValue);
10814
11038
  }
10815
11039
  }
11040
+ }
10816
11041
 
10817
- let request = new XMLHttpRequest();
11042
+ return newConfig;
11043
+ };
11044
+
11045
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
11046
+
11047
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
11048
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
11049
+ const _config = resolveConfig(config);
11050
+ let requestData = _config.data;
11051
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
11052
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
11053
+ let onCanceled;
11054
+ let uploadThrottled, downloadThrottled;
11055
+ let flushUpload, flushDownload;
11056
+
11057
+ function done() {
11058
+ flushUpload && flushUpload(); // flush events
11059
+ flushDownload && flushDownload(); // flush events
11060
+
11061
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
10818
11062
 
10819
- // HTTP basic authentication
10820
- if (config.auth) {
10821
- const username = config.auth.username || '';
10822
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
10823
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
11063
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
10824
11064
  }
10825
11065
 
10826
- const fullPath = buildFullPath(config.baseURL, config.url);
11066
+ let request = new XMLHttpRequest();
10827
11067
 
10828
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
11068
+ request.open(_config.method.toUpperCase(), _config.url, true);
10829
11069
 
10830
11070
  // Set the request timeout in MS
10831
- request.timeout = config.timeout;
11071
+ request.timeout = _config.timeout;
10832
11072
 
10833
11073
  function onloadend() {
10834
11074
  if (!request) {
@@ -10908,10 +11148,10 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10908
11148
 
10909
11149
  // Handle timeout
10910
11150
  request.ontimeout = function handleTimeout() {
10911
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
10912
- const transitional = config.transitional || transitionalDefaults;
10913
- if (config.timeoutErrorMessage) {
10914
- timeoutErrorMessage = config.timeoutErrorMessage;
11151
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
11152
+ const transitional = _config.transitional || transitionalDefaults;
11153
+ if (_config.timeoutErrorMessage) {
11154
+ timeoutErrorMessage = _config.timeoutErrorMessage;
10915
11155
  }
10916
11156
  reject(new AxiosError(
10917
11157
  timeoutErrorMessage,
@@ -10923,22 +11163,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10923
11163
  request = null;
10924
11164
  };
10925
11165
 
10926
- // Add xsrf header
10927
- // This is only done if running in a standard browser environment.
10928
- // Specifically not if we're in a web worker, or react-native.
10929
- if(platform$1.hasStandardBrowserEnv) {
10930
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
10931
-
10932
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
10933
- // Add xsrf header
10934
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
10935
-
10936
- if (xsrfValue) {
10937
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
10938
- }
10939
- }
10940
- }
10941
-
10942
11166
  // Remove Content-Type if data is undefined
10943
11167
  requestData === undefined && requestHeaders.setContentType(null);
10944
11168
 
@@ -10950,26 +11174,31 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10950
11174
  }
10951
11175
 
10952
11176
  // Add withCredentials to request if needed
10953
- if (!utils$1.isUndefined(config.withCredentials)) {
10954
- request.withCredentials = !!config.withCredentials;
11177
+ if (!utils$1.isUndefined(_config.withCredentials)) {
11178
+ request.withCredentials = !!_config.withCredentials;
10955
11179
  }
10956
11180
 
10957
11181
  // Add responseType to request if needed
10958
11182
  if (responseType && responseType !== 'json') {
10959
- request.responseType = config.responseType;
11183
+ request.responseType = _config.responseType;
10960
11184
  }
10961
11185
 
10962
11186
  // Handle progress if needed
10963
- if (typeof config.onDownloadProgress === 'function') {
10964
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
11187
+ if (onDownloadProgress) {
11188
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
11189
+ request.addEventListener('progress', downloadThrottled);
10965
11190
  }
10966
11191
 
10967
11192
  // Not all browsers support upload events
10968
- if (typeof config.onUploadProgress === 'function' && request.upload) {
10969
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
11193
+ if (onUploadProgress && request.upload) {
11194
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
11195
+
11196
+ request.upload.addEventListener('progress', uploadThrottled);
11197
+
11198
+ request.upload.addEventListener('loadend', flushUpload);
10970
11199
  }
10971
11200
 
10972
- if (config.cancelToken || config.signal) {
11201
+ if (_config.cancelToken || _config.signal) {
10973
11202
  // Handle cancellation
10974
11203
  // eslint-disable-next-line func-names
10975
11204
  onCanceled = cancel => {
@@ -10981,13 +11210,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10981
11210
  request = null;
10982
11211
  };
10983
11212
 
10984
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
10985
- if (config.signal) {
10986
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
11213
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
11214
+ if (_config.signal) {
11215
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
10987
11216
  }
10988
11217
  }
10989
11218
 
10990
- const protocol = parseProtocol(fullPath);
11219
+ const protocol = parseProtocol(_config.url);
10991
11220
 
10992
11221
  if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
10993
11222
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
@@ -11000,9 +11229,358 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
11000
11229
  });
11001
11230
  };
11002
11231
 
11232
+ const composeSignals = (signals, timeout) => {
11233
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
11234
+
11235
+ if (timeout || length) {
11236
+ let controller = new AbortController();
11237
+
11238
+ let aborted;
11239
+
11240
+ const onabort = function (reason) {
11241
+ if (!aborted) {
11242
+ aborted = true;
11243
+ unsubscribe();
11244
+ const err = reason instanceof Error ? reason : this.reason;
11245
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
11246
+ }
11247
+ };
11248
+
11249
+ let timer = timeout && setTimeout(() => {
11250
+ timer = null;
11251
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
11252
+ }, timeout);
11253
+
11254
+ const unsubscribe = () => {
11255
+ if (signals) {
11256
+ timer && clearTimeout(timer);
11257
+ timer = null;
11258
+ signals.forEach(signal => {
11259
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
11260
+ });
11261
+ signals = null;
11262
+ }
11263
+ };
11264
+
11265
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
11266
+
11267
+ const {signal} = controller;
11268
+
11269
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
11270
+
11271
+ return signal;
11272
+ }
11273
+ };
11274
+
11275
+ const streamChunk = function* (chunk, chunkSize) {
11276
+ let len = chunk.byteLength;
11277
+
11278
+ if (!chunkSize || len < chunkSize) {
11279
+ yield chunk;
11280
+ return;
11281
+ }
11282
+
11283
+ let pos = 0;
11284
+ let end;
11285
+
11286
+ while (pos < len) {
11287
+ end = pos + chunkSize;
11288
+ yield chunk.slice(pos, end);
11289
+ pos = end;
11290
+ }
11291
+ };
11292
+
11293
+ const readBytes = async function* (iterable, chunkSize) {
11294
+ for await (const chunk of readStream(iterable)) {
11295
+ yield* streamChunk(chunk, chunkSize);
11296
+ }
11297
+ };
11298
+
11299
+ const readStream = async function* (stream) {
11300
+ if (stream[Symbol.asyncIterator]) {
11301
+ yield* stream;
11302
+ return;
11303
+ }
11304
+
11305
+ const reader = stream.getReader();
11306
+ try {
11307
+ for (;;) {
11308
+ const {done, value} = await reader.read();
11309
+ if (done) {
11310
+ break;
11311
+ }
11312
+ yield value;
11313
+ }
11314
+ } finally {
11315
+ await reader.cancel();
11316
+ }
11317
+ };
11318
+
11319
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
11320
+ const iterator = readBytes(stream, chunkSize);
11321
+
11322
+ let bytes = 0;
11323
+ let done;
11324
+ let _onFinish = (e) => {
11325
+ if (!done) {
11326
+ done = true;
11327
+ onFinish && onFinish(e);
11328
+ }
11329
+ };
11330
+
11331
+ return new ReadableStream({
11332
+ async pull(controller) {
11333
+ try {
11334
+ const {done, value} = await iterator.next();
11335
+
11336
+ if (done) {
11337
+ _onFinish();
11338
+ controller.close();
11339
+ return;
11340
+ }
11341
+
11342
+ let len = value.byteLength;
11343
+ if (onProgress) {
11344
+ let loadedBytes = bytes += len;
11345
+ onProgress(loadedBytes);
11346
+ }
11347
+ controller.enqueue(new Uint8Array(value));
11348
+ } catch (err) {
11349
+ _onFinish(err);
11350
+ throw err;
11351
+ }
11352
+ },
11353
+ cancel(reason) {
11354
+ _onFinish(reason);
11355
+ return iterator.return();
11356
+ }
11357
+ }, {
11358
+ highWaterMark: 2
11359
+ })
11360
+ };
11361
+
11362
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
11363
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
11364
+
11365
+ // used only inside the fetch adapter
11366
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
11367
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
11368
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
11369
+ );
11370
+
11371
+ const test = (fn, ...args) => {
11372
+ try {
11373
+ return !!fn(...args);
11374
+ } catch (e) {
11375
+ return false
11376
+ }
11377
+ };
11378
+
11379
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
11380
+ let duplexAccessed = false;
11381
+
11382
+ const hasContentType = new Request(platform$1.origin, {
11383
+ body: new ReadableStream(),
11384
+ method: 'POST',
11385
+ get duplex() {
11386
+ duplexAccessed = true;
11387
+ return 'half';
11388
+ },
11389
+ }).headers.has('Content-Type');
11390
+
11391
+ return duplexAccessed && !hasContentType;
11392
+ });
11393
+
11394
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
11395
+
11396
+ const supportsResponseStream = isReadableStreamSupported &&
11397
+ test(() => utils$1.isReadableStream(new Response('').body));
11398
+
11399
+
11400
+ const resolvers = {
11401
+ stream: supportsResponseStream && ((res) => res.body)
11402
+ };
11403
+
11404
+ isFetchSupported && (((res) => {
11405
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
11406
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
11407
+ (_, config) => {
11408
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
11409
+ });
11410
+ });
11411
+ })(new Response));
11412
+
11413
+ const getBodyLength = async (body) => {
11414
+ if (body == null) {
11415
+ return 0;
11416
+ }
11417
+
11418
+ if(utils$1.isBlob(body)) {
11419
+ return body.size;
11420
+ }
11421
+
11422
+ if(utils$1.isSpecCompliantForm(body)) {
11423
+ const _request = new Request(platform$1.origin, {
11424
+ method: 'POST',
11425
+ body,
11426
+ });
11427
+ return (await _request.arrayBuffer()).byteLength;
11428
+ }
11429
+
11430
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
11431
+ return body.byteLength;
11432
+ }
11433
+
11434
+ if(utils$1.isURLSearchParams(body)) {
11435
+ body = body + '';
11436
+ }
11437
+
11438
+ if(utils$1.isString(body)) {
11439
+ return (await encodeText(body)).byteLength;
11440
+ }
11441
+ };
11442
+
11443
+ const resolveBodyLength = async (headers, body) => {
11444
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
11445
+
11446
+ return length == null ? getBodyLength(body) : length;
11447
+ };
11448
+
11449
+ var fetchAdapter = isFetchSupported && (async (config) => {
11450
+ let {
11451
+ url,
11452
+ method,
11453
+ data,
11454
+ signal,
11455
+ cancelToken,
11456
+ timeout,
11457
+ onDownloadProgress,
11458
+ onUploadProgress,
11459
+ responseType,
11460
+ headers,
11461
+ withCredentials = 'same-origin',
11462
+ fetchOptions
11463
+ } = resolveConfig(config);
11464
+
11465
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
11466
+
11467
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
11468
+
11469
+ let request;
11470
+
11471
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
11472
+ composedSignal.unsubscribe();
11473
+ });
11474
+
11475
+ let requestContentLength;
11476
+
11477
+ try {
11478
+ if (
11479
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
11480
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
11481
+ ) {
11482
+ let _request = new Request(url, {
11483
+ method: 'POST',
11484
+ body: data,
11485
+ duplex: "half"
11486
+ });
11487
+
11488
+ let contentTypeHeader;
11489
+
11490
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
11491
+ headers.setContentType(contentTypeHeader);
11492
+ }
11493
+
11494
+ if (_request.body) {
11495
+ const [onProgress, flush] = progressEventDecorator(
11496
+ requestContentLength,
11497
+ progressEventReducer(asyncDecorator(onUploadProgress))
11498
+ );
11499
+
11500
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
11501
+ }
11502
+ }
11503
+
11504
+ if (!utils$1.isString(withCredentials)) {
11505
+ withCredentials = withCredentials ? 'include' : 'omit';
11506
+ }
11507
+
11508
+ // Cloudflare Workers throws when credentials are defined
11509
+ // see https://github.com/cloudflare/workerd/issues/902
11510
+ const isCredentialsSupported = "credentials" in Request.prototype;
11511
+ request = new Request(url, {
11512
+ ...fetchOptions,
11513
+ signal: composedSignal,
11514
+ method: method.toUpperCase(),
11515
+ headers: headers.normalize().toJSON(),
11516
+ body: data,
11517
+ duplex: "half",
11518
+ credentials: isCredentialsSupported ? withCredentials : undefined
11519
+ });
11520
+
11521
+ let response = await fetch(request);
11522
+
11523
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
11524
+
11525
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
11526
+ const options = {};
11527
+
11528
+ ['status', 'statusText', 'headers'].forEach(prop => {
11529
+ options[prop] = response[prop];
11530
+ });
11531
+
11532
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
11533
+
11534
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
11535
+ responseContentLength,
11536
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
11537
+ ) || [];
11538
+
11539
+ response = new Response(
11540
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
11541
+ flush && flush();
11542
+ unsubscribe && unsubscribe();
11543
+ }),
11544
+ options
11545
+ );
11546
+ }
11547
+
11548
+ responseType = responseType || 'text';
11549
+
11550
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
11551
+
11552
+ !isStreamResponse && unsubscribe && unsubscribe();
11553
+
11554
+ return await new Promise((resolve, reject) => {
11555
+ settle(resolve, reject, {
11556
+ data: responseData,
11557
+ headers: AxiosHeaders.from(response.headers),
11558
+ status: response.status,
11559
+ statusText: response.statusText,
11560
+ config,
11561
+ request
11562
+ });
11563
+ })
11564
+ } catch (err) {
11565
+ unsubscribe && unsubscribe();
11566
+
11567
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
11568
+ throw Object.assign(
11569
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
11570
+ {
11571
+ cause: err.cause || err
11572
+ }
11573
+ )
11574
+ }
11575
+
11576
+ throw AxiosError.from(err, err && err.code, config, request);
11577
+ }
11578
+ });
11579
+
11003
11580
  const knownAdapters = {
11004
11581
  http: httpAdapter,
11005
- xhr: xhrAdapter
11582
+ xhr: xhrAdapter,
11583
+ fetch: fetchAdapter
11006
11584
  };
11007
11585
 
11008
11586
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -11146,109 +11724,7 @@ function dispatchRequest(config) {
11146
11724
  });
11147
11725
  }
11148
11726
 
11149
- const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing;
11150
-
11151
- /**
11152
- * Config-specific merge-function which creates a new config-object
11153
- * by merging two configuration objects together.
11154
- *
11155
- * @param {Object} config1
11156
- * @param {Object} config2
11157
- *
11158
- * @returns {Object} New object resulting from merging config2 to config1
11159
- */
11160
- function mergeConfig(config1, config2) {
11161
- // eslint-disable-next-line no-param-reassign
11162
- config2 = config2 || {};
11163
- const config = {};
11164
-
11165
- function getMergedValue(target, source, caseless) {
11166
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
11167
- return utils$1.merge.call({caseless}, target, source);
11168
- } else if (utils$1.isPlainObject(source)) {
11169
- return utils$1.merge({}, source);
11170
- } else if (utils$1.isArray(source)) {
11171
- return source.slice();
11172
- }
11173
- return source;
11174
- }
11175
-
11176
- // eslint-disable-next-line consistent-return
11177
- function mergeDeepProperties(a, b, caseless) {
11178
- if (!utils$1.isUndefined(b)) {
11179
- return getMergedValue(a, b, caseless);
11180
- } else if (!utils$1.isUndefined(a)) {
11181
- return getMergedValue(undefined, a, caseless);
11182
- }
11183
- }
11184
-
11185
- // eslint-disable-next-line consistent-return
11186
- function valueFromConfig2(a, b) {
11187
- if (!utils$1.isUndefined(b)) {
11188
- return getMergedValue(undefined, b);
11189
- }
11190
- }
11191
-
11192
- // eslint-disable-next-line consistent-return
11193
- function defaultToConfig2(a, b) {
11194
- if (!utils$1.isUndefined(b)) {
11195
- return getMergedValue(undefined, b);
11196
- } else if (!utils$1.isUndefined(a)) {
11197
- return getMergedValue(undefined, a);
11198
- }
11199
- }
11200
-
11201
- // eslint-disable-next-line consistent-return
11202
- function mergeDirectKeys(a, b, prop) {
11203
- if (prop in config2) {
11204
- return getMergedValue(a, b);
11205
- } else if (prop in config1) {
11206
- return getMergedValue(undefined, a);
11207
- }
11208
- }
11209
-
11210
- const mergeMap = {
11211
- url: valueFromConfig2,
11212
- method: valueFromConfig2,
11213
- data: valueFromConfig2,
11214
- baseURL: defaultToConfig2,
11215
- transformRequest: defaultToConfig2,
11216
- transformResponse: defaultToConfig2,
11217
- paramsSerializer: defaultToConfig2,
11218
- timeout: defaultToConfig2,
11219
- timeoutMessage: defaultToConfig2,
11220
- withCredentials: defaultToConfig2,
11221
- withXSRFToken: defaultToConfig2,
11222
- adapter: defaultToConfig2,
11223
- responseType: defaultToConfig2,
11224
- xsrfCookieName: defaultToConfig2,
11225
- xsrfHeaderName: defaultToConfig2,
11226
- onUploadProgress: defaultToConfig2,
11227
- onDownloadProgress: defaultToConfig2,
11228
- decompress: defaultToConfig2,
11229
- maxContentLength: defaultToConfig2,
11230
- maxBodyLength: defaultToConfig2,
11231
- beforeRedirect: defaultToConfig2,
11232
- transport: defaultToConfig2,
11233
- httpAgent: defaultToConfig2,
11234
- httpsAgent: defaultToConfig2,
11235
- cancelToken: defaultToConfig2,
11236
- socketPath: defaultToConfig2,
11237
- responseEncoding: defaultToConfig2,
11238
- validateStatus: mergeDirectKeys,
11239
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
11240
- };
11241
-
11242
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
11243
- const merge = mergeMap[prop] || mergeDeepProperties;
11244
- const configValue = merge(config1[prop], config2[prop], prop);
11245
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
11246
- });
11247
-
11248
- return config;
11249
- }
11250
-
11251
- const VERSION = "1.6.7";
11727
+ const VERSION = "1.7.7";
11252
11728
 
11253
11729
  const validators = {};
11254
11730
 
@@ -11374,12 +11850,15 @@ class Axios {
11374
11850
 
11375
11851
  // slice off the Error: ... line
11376
11852
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
11377
-
11378
- if (!err.stack) {
11379
- err.stack = stack;
11380
- // match without the 2 top stack lines
11381
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
11382
- err.stack += '\n' + stack;
11853
+ try {
11854
+ if (!err.stack) {
11855
+ err.stack = stack;
11856
+ // match without the 2 top stack lines
11857
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
11858
+ err.stack += '\n' + stack;
11859
+ }
11860
+ } catch (e) {
11861
+ // ignore the case where "stack" is an un-writable property
11383
11862
  }
11384
11863
  }
11385
11864
 
@@ -11650,6 +12129,20 @@ class CancelToken {
11650
12129
  }
11651
12130
  }
11652
12131
 
12132
+ toAbortSignal() {
12133
+ const controller = new AbortController();
12134
+
12135
+ const abort = (err) => {
12136
+ controller.abort(err);
12137
+ };
12138
+
12139
+ this.subscribe(abort);
12140
+
12141
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
12142
+
12143
+ return controller.signal;
12144
+ }
12145
+
11653
12146
  /**
11654
12147
  * Returns an object that contains a new `CancelToken` and a function that, when called,
11655
12148
  * cancels the `CancelToken`.