@tryghost/content-api 1.12.4 → 1.12.6

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/es/content-api.js CHANGED
@@ -45,7 +45,7 @@ const { isArray } = Array;
45
45
  *
46
46
  * @returns {boolean} True if the value is undefined, otherwise false
47
47
  */
48
- const isUndefined = typeOfTest("undefined");
48
+ const isUndefined = typeOfTest('undefined');
49
49
 
50
50
  /**
51
51
  * Determine if a value is a Buffer
@@ -72,7 +72,7 @@ function isBuffer(val) {
72
72
  *
73
73
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
74
74
  */
75
- const isArrayBuffer = kindOfTest("ArrayBuffer");
75
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
76
76
 
77
77
  /**
78
78
  * Determine if a value is a view on an ArrayBuffer
@@ -83,7 +83,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
83
83
  */
84
84
  function isArrayBufferView(val) {
85
85
  let result;
86
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
86
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
87
87
  result = ArrayBuffer.isView(val);
88
88
  } else {
89
89
  result = val && val.buffer && isArrayBuffer(val.buffer);
@@ -98,7 +98,7 @@ function isArrayBufferView(val) {
98
98
  *
99
99
  * @returns {boolean} True if value is a String, otherwise false
100
100
  */
101
- const isString = typeOfTest("string");
101
+ const isString = typeOfTest('string');
102
102
 
103
103
  /**
104
104
  * Determine if a value is a Function
@@ -106,7 +106,7 @@ const isString = typeOfTest("string");
106
106
  * @param {*} val The value to test
107
107
  * @returns {boolean} True if value is a Function, otherwise false
108
108
  */
109
- const isFunction$1 = typeOfTest("function");
109
+ const isFunction$1 = typeOfTest('function');
110
110
 
111
111
  /**
112
112
  * Determine if a value is a Number
@@ -115,7 +115,7 @@ const isFunction$1 = typeOfTest("function");
115
115
  *
116
116
  * @returns {boolean} True if value is a Number, otherwise false
117
117
  */
118
- const isNumber = typeOfTest("number");
118
+ const isNumber = typeOfTest('number');
119
119
 
120
120
  /**
121
121
  * Determine if a value is an Object
@@ -124,7 +124,7 @@ const isNumber = typeOfTest("number");
124
124
  *
125
125
  * @returns {boolean} True if value is an Object, otherwise false
126
126
  */
127
- const isObject = (thing) => thing !== null && typeof thing === "object";
127
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
128
128
 
129
129
  /**
130
130
  * Determine if a value is a Boolean
@@ -142,7 +142,7 @@ const isBoolean = (thing) => thing === true || thing === false;
142
142
  * @returns {boolean} True if value is a plain Object, otherwise false
143
143
  */
144
144
  const isPlainObject = (val) => {
145
- if (kindOf(val) !== "object") {
145
+ if (kindOf(val) !== 'object') {
146
146
  return false;
147
147
  }
148
148
 
@@ -170,10 +170,7 @@ const isEmptyObject = (val) => {
170
170
  }
171
171
 
172
172
  try {
173
- return (
174
- Object.keys(val).length === 0 &&
175
- Object.getPrototypeOf(val) === Object.prototype
176
- );
173
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
177
174
  } catch (e) {
178
175
  // Fallback for any other objects that might cause RangeError with Object.keys()
179
176
  return false;
@@ -187,7 +184,7 @@ const isEmptyObject = (val) => {
187
184
  *
188
185
  * @returns {boolean} True if value is a Date, otherwise false
189
186
  */
190
- const isDate = kindOfTest("Date");
187
+ const isDate = kindOfTest('Date');
191
188
 
192
189
  /**
193
190
  * Determine if a value is a File
@@ -196,7 +193,32 @@ const isDate = kindOfTest("Date");
196
193
  *
197
194
  * @returns {boolean} True if value is a File, otherwise false
198
195
  */
199
- const isFile = kindOfTest("File");
196
+ const isFile = kindOfTest('File');
197
+
198
+ /**
199
+ * Determine if a value is a React Native Blob
200
+ * React Native "blob": an object with a `uri` attribute. Optionally, it can
201
+ * also have a `name` and `type` attribute to specify filename and content type
202
+ *
203
+ * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
204
+ *
205
+ * @param {*} value The value to test
206
+ *
207
+ * @returns {boolean} True if value is a React Native Blob, otherwise false
208
+ */
209
+ const isReactNativeBlob = (value) => {
210
+ return !!(value && typeof value.uri !== 'undefined');
211
+ };
212
+
213
+ /**
214
+ * Determine if environment is React Native
215
+ * ReactNative `FormData` has a non-standard `getParts()` method
216
+ *
217
+ * @param {*} formData The formData to test
218
+ *
219
+ * @returns {boolean} True if environment is React Native, otherwise false
220
+ */
221
+ const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
200
222
 
201
223
  /**
202
224
  * Determine if a value is a Blob
@@ -205,7 +227,7 @@ const isFile = kindOfTest("File");
205
227
  *
206
228
  * @returns {boolean} True if value is a Blob, otherwise false
207
229
  */
208
- const isBlob = kindOfTest("Blob");
230
+ const isBlob = kindOfTest('Blob');
209
231
 
210
232
  /**
211
233
  * Determine if a value is a FileList
@@ -214,7 +236,7 @@ const isBlob = kindOfTest("Blob");
214
236
  *
215
237
  * @returns {boolean} True if value is a File, otherwise false
216
238
  */
217
- const isFileList = kindOfTest("FileList");
239
+ const isFileList = kindOfTest('FileList');
218
240
 
219
241
  /**
220
242
  * Determine if a value is a Stream
@@ -232,17 +254,27 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
232
254
  *
233
255
  * @returns {boolean} True if value is an FormData, otherwise false
234
256
  */
257
+ function getGlobal() {
258
+ if (typeof globalThis !== 'undefined') return globalThis;
259
+ if (typeof self !== 'undefined') return self;
260
+ if (typeof window !== 'undefined') return window;
261
+ if (typeof global !== 'undefined') return global;
262
+ return {};
263
+ }
264
+
265
+ const G = getGlobal();
266
+ const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
267
+
235
268
  const isFormData = (thing) => {
236
269
  let kind;
237
- return (
238
- thing &&
239
- ((typeof FormData === "function" && thing instanceof FormData) ||
240
- (isFunction$1(thing.append) &&
241
- ((kind = kindOf(thing)) === "formdata" ||
242
- // detect form-data instance
243
- (kind === "object" &&
244
- isFunction$1(thing.toString) &&
245
- thing.toString() === "[object FormData]"))))
270
+ return thing && (
271
+ (FormDataCtor && thing instanceof FormDataCtor) || (
272
+ isFunction$1(thing.append) && (
273
+ (kind = kindOf(thing)) === 'formdata' ||
274
+ // detect form-data instance
275
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
276
+ )
277
+ )
246
278
  );
247
279
  };
248
280
 
@@ -253,13 +285,13 @@ const isFormData = (thing) => {
253
285
  *
254
286
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
255
287
  */
256
- const isURLSearchParams = kindOfTest("URLSearchParams");
288
+ const isURLSearchParams = kindOfTest('URLSearchParams');
257
289
 
258
290
  const [isReadableStream, isRequest, isResponse, isHeaders] = [
259
- "ReadableStream",
260
- "Request",
261
- "Response",
262
- "Headers",
291
+ 'ReadableStream',
292
+ 'Request',
293
+ 'Response',
294
+ 'Headers',
263
295
  ].map(kindOfTest);
264
296
 
265
297
  /**
@@ -269,9 +301,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
269
301
  *
270
302
  * @returns {String} The String freed of excess whitespace
271
303
  */
272
- const trim = (str) =>
273
- str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
274
-
304
+ const trim = (str) => {
305
+ return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
306
+ };
275
307
  /**
276
308
  * Iterate over an Array or an Object invoking a function for each item.
277
309
  *
@@ -290,7 +322,7 @@ const trim = (str) =>
290
322
  */
291
323
  function forEach(obj, fn, { allOwnKeys = false } = {}) {
292
324
  // Don't bother if no value provided
293
- if (obj === null || typeof obj === "undefined") {
325
+ if (obj === null || typeof obj === 'undefined') {
294
326
  return;
295
327
  }
296
328
 
@@ -298,7 +330,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
298
330
  let l;
299
331
 
300
332
  // Force an array if not already something iterable
301
- if (typeof obj !== "object") {
333
+ if (typeof obj !== 'object') {
302
334
  /*eslint no-param-reassign:0*/
303
335
  obj = [obj];
304
336
  }
@@ -315,9 +347,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
315
347
  }
316
348
 
317
349
  // Iterate over object keys
318
- const keys = allOwnKeys
319
- ? Object.getOwnPropertyNames(obj)
320
- : Object.keys(obj);
350
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
321
351
  const len = keys.length;
322
352
  let key;
323
353
 
@@ -328,6 +358,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
328
358
  }
329
359
  }
330
360
 
361
+ /**
362
+ * Finds a key in an object, case-insensitive, returning the actual key name.
363
+ * Returns null if the object is a Buffer or if no match is found.
364
+ *
365
+ * @param {Object} obj - The object to search.
366
+ * @param {string} key - The key to find (case-insensitive).
367
+ * @returns {?string} The actual key name if found, otherwise null.
368
+ */
331
369
  function findKey(obj, key) {
332
370
  if (isBuffer(obj)) {
333
371
  return null;
@@ -348,16 +386,11 @@ function findKey(obj, key) {
348
386
 
349
387
  const _global = (() => {
350
388
  /*eslint no-undef:0*/
351
- if (typeof globalThis !== "undefined") return globalThis;
352
- return typeof self !== "undefined"
353
- ? self
354
- : typeof window !== "undefined"
355
- ? window
356
- : global;
389
+ if (typeof globalThis !== 'undefined') return globalThis;
390
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
357
391
  })();
358
392
 
359
- const isContextDefined = (context) =>
360
- !isUndefined(context) && context !== _global;
393
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
361
394
 
362
395
  /**
363
396
  * Accepts varargs expecting each argument to be an object, then
@@ -382,7 +415,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
382
415
  const result = {};
383
416
  const assignValue = (val, key) => {
384
417
  // Skip dangerous property names to prevent prototype pollution
385
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
418
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
386
419
  return;
387
420
  }
388
421
 
@@ -435,7 +468,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
435
468
  });
436
469
  }
437
470
  },
438
- { allOwnKeys },
471
+ { allOwnKeys }
439
472
  );
440
473
  return a;
441
474
  };
@@ -464,17 +497,14 @@ const stripBOM = (content) => {
464
497
  * @returns {void}
465
498
  */
466
499
  const inherits = (constructor, superConstructor, props, descriptors) => {
467
- constructor.prototype = Object.create(
468
- superConstructor.prototype,
469
- descriptors,
470
- );
471
- Object.defineProperty(constructor.prototype, "constructor", {
500
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
501
+ Object.defineProperty(constructor.prototype, 'constructor', {
472
502
  value: constructor,
473
503
  writable: true,
474
504
  enumerable: false,
475
505
  configurable: true,
476
506
  });
477
- Object.defineProperty(constructor, "super", {
507
+ Object.defineProperty(constructor, 'super', {
478
508
  value: superConstructor.prototype,
479
509
  });
480
510
  props && Object.assign(constructor.prototype, props);
@@ -504,20 +534,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
504
534
  i = props.length;
505
535
  while (i-- > 0) {
506
536
  prop = props[i];
507
- if (
508
- (!propFilter || propFilter(prop, sourceObj, destObj)) &&
509
- !merged[prop]
510
- ) {
537
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
511
538
  destObj[prop] = sourceObj[prop];
512
539
  merged[prop] = true;
513
540
  }
514
541
  }
515
542
  sourceObj = filter !== false && getPrototypeOf(sourceObj);
516
- } while (
517
- sourceObj &&
518
- (!filter || filter(sourceObj, destObj)) &&
519
- sourceObj !== Object.prototype
520
- );
543
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
521
544
 
522
545
  return destObj;
523
546
  };
@@ -574,7 +597,7 @@ const isTypedArray = ((TypedArray) => {
574
597
  return (thing) => {
575
598
  return TypedArray && thing instanceof TypedArray;
576
599
  };
577
- })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
600
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
578
601
 
579
602
  /**
580
603
  * For each entry in the object, call the function with the key and value.
@@ -617,14 +640,12 @@ const matchAll = (regExp, str) => {
617
640
  };
618
641
 
619
642
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
620
- const isHTMLForm = kindOfTest("HTMLFormElement");
643
+ const isHTMLForm = kindOfTest('HTMLFormElement');
621
644
 
622
645
  const toCamelCase = (str) => {
623
- return str
624
- .toLowerCase()
625
- .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
626
- return p1.toUpperCase() + p2;
627
- });
646
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
647
+ return p1.toUpperCase() + p2;
648
+ });
628
649
  };
629
650
 
630
651
  /* Creating a function that will check if an object has a property. */
@@ -641,7 +662,7 @@ const hasOwnProperty = (
641
662
  *
642
663
  * @returns {boolean} True if value is a RegExp object, otherwise false
643
664
  */
644
- const isRegExp = kindOfTest("RegExp");
665
+ const isRegExp = kindOfTest('RegExp');
645
666
 
646
667
  const reduceDescriptors = (obj, reducer) => {
647
668
  const descriptors = Object.getOwnPropertyDescriptors(obj);
@@ -665,10 +686,7 @@ const reduceDescriptors = (obj, reducer) => {
665
686
  const freezeMethods = (obj) => {
666
687
  reduceDescriptors(obj, (descriptor, name) => {
667
688
  // skip restricted props in strict mode
668
- if (
669
- isFunction$1(obj) &&
670
- ["arguments", "caller", "callee"].indexOf(name) !== -1
671
- ) {
689
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
672
690
  return false;
673
691
  }
674
692
 
@@ -678,7 +696,7 @@ const freezeMethods = (obj) => {
678
696
 
679
697
  descriptor.enumerable = false;
680
698
 
681
- if ("writable" in descriptor) {
699
+ if ('writable' in descriptor) {
682
700
  descriptor.writable = false;
683
701
  return;
684
702
  }
@@ -691,6 +709,14 @@ const freezeMethods = (obj) => {
691
709
  });
692
710
  };
693
711
 
712
+ /**
713
+ * Converts an array or a delimited string into an object set with values as keys and true as values.
714
+ * Useful for fast membership checks.
715
+ *
716
+ * @param {Array|string} arrayOrString - The array or string to convert.
717
+ * @param {string} delimiter - The delimiter to use if input is a string.
718
+ * @returns {Object} An object with keys from the array or string, values set to true.
719
+ */
694
720
  const toObjectSet = (arrayOrString, delimiter) => {
695
721
  const obj = {};
696
722
 
@@ -700,9 +726,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
700
726
  });
701
727
  };
702
728
 
703
- isArray(arrayOrString)
704
- ? define(arrayOrString)
705
- : define(String(arrayOrString).split(delimiter));
729
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
706
730
 
707
731
  return obj;
708
732
  };
@@ -710,9 +734,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
710
734
  const noop = () => {};
711
735
 
712
736
  const toFiniteNumber = (value, defaultValue) => {
713
- return value != null && Number.isFinite((value = +value))
714
- ? value
715
- : defaultValue;
737
+ return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
716
738
  };
717
739
 
718
740
  /**
@@ -726,11 +748,17 @@ function isSpecCompliantForm(thing) {
726
748
  return !!(
727
749
  thing &&
728
750
  isFunction$1(thing.append) &&
729
- thing[toStringTag] === "FormData" &&
751
+ thing[toStringTag] === 'FormData' &&
730
752
  thing[iterator]
731
753
  );
732
754
  }
733
755
 
756
+ /**
757
+ * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
758
+ *
759
+ * @param {Object} obj - The object to convert.
760
+ * @returns {Object} The JSON-compatible object.
761
+ */
734
762
  const toJSONObject = (obj) => {
735
763
  const stack = new Array(10);
736
764
 
@@ -745,7 +773,7 @@ const toJSONObject = (obj) => {
745
773
  return source;
746
774
  }
747
775
 
748
- if (!("toJSON" in source)) {
776
+ if (!('toJSON' in source)) {
749
777
  stack[i] = source;
750
778
  const target = isArray(source) ? [] : {};
751
779
 
@@ -766,8 +794,20 @@ const toJSONObject = (obj) => {
766
794
  return visit(obj, 0);
767
795
  };
768
796
 
769
- const isAsyncFn = kindOfTest("AsyncFunction");
797
+ /**
798
+ * Determines if a value is an async function.
799
+ *
800
+ * @param {*} thing - The value to test.
801
+ * @returns {boolean} True if value is an async function, otherwise false.
802
+ */
803
+ const isAsyncFn = kindOfTest('AsyncFunction');
770
804
 
805
+ /**
806
+ * Determines if a value is thenable (has then and catch methods).
807
+ *
808
+ * @param {*} thing - The value to test.
809
+ * @returns {boolean} True if value is thenable, otherwise false.
810
+ */
771
811
  const isThenable = (thing) =>
772
812
  thing &&
773
813
  (isObject(thing) || isFunction$1(thing)) &&
@@ -777,6 +817,14 @@ const isThenable = (thing) =>
777
817
  // original code
778
818
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
779
819
 
820
+ /**
821
+ * Provides a cross-platform setImmediate implementation.
822
+ * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
823
+ *
824
+ * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
825
+ * @param {boolean} postMessageSupported - Whether postMessage is supported.
826
+ * @returns {Function} A function to schedule a callback asynchronously.
827
+ */
780
828
  const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
781
829
  if (setImmediateSupported) {
782
830
  return setImmediate;
@@ -785,27 +833,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
785
833
  return postMessageSupported
786
834
  ? ((token, callbacks) => {
787
835
  _global.addEventListener(
788
- "message",
836
+ 'message',
789
837
  ({ source, data }) => {
790
838
  if (source === _global && data === token) {
791
839
  callbacks.length && callbacks.shift()();
792
840
  }
793
841
  },
794
- false,
842
+ false
795
843
  );
796
844
 
797
845
  return (cb) => {
798
846
  callbacks.push(cb);
799
- _global.postMessage(token, "*");
847
+ _global.postMessage(token, '*');
800
848
  };
801
849
  })(`axios@${Math.random()}`, [])
802
850
  : (cb) => setTimeout(cb);
803
- })(typeof setImmediate === "function", isFunction$1(_global.postMessage));
851
+ })(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
804
852
 
853
+ /**
854
+ * Schedules a microtask or asynchronous callback as soon as possible.
855
+ * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
856
+ *
857
+ * @type {Function}
858
+ */
805
859
  const asap =
806
- typeof queueMicrotask !== "undefined"
860
+ typeof queueMicrotask !== 'undefined'
807
861
  ? queueMicrotask.bind(_global)
808
- : (typeof process !== "undefined" && process.nextTick) || _setImmediate;
862
+ : (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
809
863
 
810
864
  // *********************
811
865
 
@@ -830,6 +884,8 @@ var utils$1 = {
830
884
  isUndefined,
831
885
  isDate,
832
886
  isFile,
887
+ isReactNativeBlob,
888
+ isReactNative,
833
889
  isBlob,
834
890
  isRegExp,
835
891
  isFunction: isFunction$1,
@@ -872,14 +928,20 @@ var utils$1 = {
872
928
  };
873
929
 
874
930
  class AxiosError extends Error {
875
- static from(error, code, config, request, response, customProps) {
876
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
877
- axiosError.cause = error;
878
- axiosError.name = error.name;
879
- customProps && Object.assign(axiosError, customProps);
880
- return axiosError;
931
+ static from(error, code, config, request, response, customProps) {
932
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
933
+ axiosError.cause = error;
934
+ axiosError.name = error.name;
935
+
936
+ // Preserve status from the original error if not already set from response
937
+ if (error.status != null && axiosError.status == null) {
938
+ axiosError.status = error.status;
881
939
  }
882
940
 
941
+ customProps && Object.assign(axiosError, customProps);
942
+ return axiosError;
943
+ }
944
+
883
945
  /**
884
946
  * Create an Error with the specified message, config, error code, request and response.
885
947
  *
@@ -892,37 +954,48 @@ class AxiosError extends Error {
892
954
  * @returns {Error} The created error.
893
955
  */
894
956
  constructor(message, code, config, request, response) {
895
- super(message);
896
- this.name = 'AxiosError';
897
- this.isAxiosError = true;
898
- code && (this.code = code);
899
- config && (this.config = config);
900
- request && (this.request = request);
901
- if (response) {
902
- this.response = response;
903
- this.status = response.status;
904
- }
957
+ super(message);
958
+
959
+ // Make message enumerable to maintain backward compatibility
960
+ // The native Error constructor sets message as non-enumerable,
961
+ // but axios < v1.13.3 had it as enumerable
962
+ Object.defineProperty(this, 'message', {
963
+ value: message,
964
+ enumerable: true,
965
+ writable: true,
966
+ configurable: true
967
+ });
968
+
969
+ this.name = 'AxiosError';
970
+ this.isAxiosError = true;
971
+ code && (this.code = code);
972
+ config && (this.config = config);
973
+ request && (this.request = request);
974
+ if (response) {
975
+ this.response = response;
976
+ this.status = response.status;
977
+ }
905
978
  }
906
979
 
907
- toJSON() {
908
- return {
909
- // Standard
910
- message: this.message,
911
- name: this.name,
912
- // Microsoft
913
- description: this.description,
914
- number: this.number,
915
- // Mozilla
916
- fileName: this.fileName,
917
- lineNumber: this.lineNumber,
918
- columnNumber: this.columnNumber,
919
- stack: this.stack,
920
- // Axios
921
- config: utils$1.toJSONObject(this.config),
922
- code: this.code,
923
- status: this.status,
924
- };
925
- }
980
+ toJSON() {
981
+ return {
982
+ // Standard
983
+ message: this.message,
984
+ name: this.name,
985
+ // Microsoft
986
+ description: this.description,
987
+ number: this.number,
988
+ // Mozilla
989
+ fileName: this.fileName,
990
+ lineNumber: this.lineNumber,
991
+ columnNumber: this.columnNumber,
992
+ stack: this.stack,
993
+ // Axios
994
+ config: utils$1.toJSONObject(this.config),
995
+ code: this.code,
996
+ status: this.status,
997
+ };
998
+ }
926
999
  }
927
1000
 
928
1001
  // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
@@ -977,11 +1050,14 @@ function removeBrackets(key) {
977
1050
  */
978
1051
  function renderKey(path, key, dots) {
979
1052
  if (!path) return key;
980
- return path.concat(key).map(function each(token, i) {
981
- // eslint-disable-next-line no-param-reassign
982
- token = removeBrackets(token);
983
- return !dots && i ? '[' + token + ']' : token;
984
- }).join(dots ? '.' : '');
1053
+ return path
1054
+ .concat(key)
1055
+ .map(function each(token, i) {
1056
+ // eslint-disable-next-line no-param-reassign
1057
+ token = removeBrackets(token);
1058
+ return !dots && i ? '[' + token + ']' : token;
1059
+ })
1060
+ .join(dots ? '.' : '');
985
1061
  }
986
1062
 
987
1063
  /**
@@ -1031,21 +1107,26 @@ function toFormData(obj, formData, options) {
1031
1107
  formData = formData || new (FormData)();
1032
1108
 
1033
1109
  // eslint-disable-next-line no-param-reassign
1034
- options = utils$1.toFlatObject(options, {
1035
- metaTokens: true,
1036
- dots: false,
1037
- indexes: false
1038
- }, false, function defined(option, source) {
1039
- // eslint-disable-next-line no-eq-null,eqeqeq
1040
- return !utils$1.isUndefined(source[option]);
1041
- });
1110
+ options = utils$1.toFlatObject(
1111
+ options,
1112
+ {
1113
+ metaTokens: true,
1114
+ dots: false,
1115
+ indexes: false,
1116
+ },
1117
+ false,
1118
+ function defined(option, source) {
1119
+ // eslint-disable-next-line no-eq-null,eqeqeq
1120
+ return !utils$1.isUndefined(source[option]);
1121
+ }
1122
+ );
1042
1123
 
1043
1124
  const metaTokens = options.metaTokens;
1044
1125
  // eslint-disable-next-line no-use-before-define
1045
1126
  const visitor = options.visitor || defaultVisitor;
1046
1127
  const dots = options.dots;
1047
1128
  const indexes = options.indexes;
1048
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1129
+ const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
1049
1130
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1050
1131
 
1051
1132
  if (!utils$1.isFunction(visitor)) {
@@ -1087,6 +1168,11 @@ function toFormData(obj, formData, options) {
1087
1168
  function defaultVisitor(value, key, path) {
1088
1169
  let arr = value;
1089
1170
 
1171
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
1172
+ formData.append(renderKey(path, key, dots), convertValue(value));
1173
+ return false;
1174
+ }
1175
+
1090
1176
  if (value && !path && typeof value === 'object') {
1091
1177
  if (utils$1.endsWith(key, '{}')) {
1092
1178
  // eslint-disable-next-line no-param-reassign
@@ -1095,17 +1181,22 @@ function toFormData(obj, formData, options) {
1095
1181
  value = JSON.stringify(value);
1096
1182
  } else if (
1097
1183
  (utils$1.isArray(value) && isFlatArray(value)) ||
1098
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1099
- )) {
1184
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
1185
+ ) {
1100
1186
  // eslint-disable-next-line no-param-reassign
1101
1187
  key = removeBrackets(key);
1102
1188
 
1103
1189
  arr.forEach(function each(el, index) {
1104
- !(utils$1.isUndefined(el) || el === null) && formData.append(
1105
- // eslint-disable-next-line no-nested-ternary
1106
- indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1107
- convertValue(el)
1108
- );
1190
+ !(utils$1.isUndefined(el) || el === null) &&
1191
+ formData.append(
1192
+ // eslint-disable-next-line no-nested-ternary
1193
+ indexes === true
1194
+ ? renderKey([key], index, dots)
1195
+ : indexes === null
1196
+ ? key
1197
+ : key + '[]',
1198
+ convertValue(el)
1199
+ );
1109
1200
  });
1110
1201
  return false;
1111
1202
  }
@@ -1125,7 +1216,7 @@ function toFormData(obj, formData, options) {
1125
1216
  const exposedHelpers = Object.assign(predicates, {
1126
1217
  defaultVisitor,
1127
1218
  convertValue,
1128
- isVisitable
1219
+ isVisitable,
1129
1220
  });
1130
1221
 
1131
1222
  function build(value, path) {
@@ -1138,9 +1229,9 @@ function toFormData(obj, formData, options) {
1138
1229
  stack.push(value);
1139
1230
 
1140
1231
  utils$1.forEach(value, function each(el, key) {
1141
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1142
- formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1143
- );
1232
+ const result =
1233
+ !(utils$1.isUndefined(el) || el === null) &&
1234
+ visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
1144
1235
 
1145
1236
  if (result === true) {
1146
1237
  build(el, path ? path.concat(key) : [key]);
@@ -1175,7 +1266,7 @@ function encode$1(str) {
1175
1266
  ')': '%29',
1176
1267
  '~': '%7E',
1177
1268
  '%20': '+',
1178
- '%00': '\x00'
1269
+ '%00': '\x00',
1179
1270
  };
1180
1271
  return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1181
1272
  return charMap[match];
@@ -1203,13 +1294,17 @@ prototype.append = function append(name, value) {
1203
1294
  };
1204
1295
 
1205
1296
  prototype.toString = function toString(encoder) {
1206
- const _encode = encoder ? function(value) {
1207
- return encoder.call(this, value, encode$1);
1208
- } : encode$1;
1297
+ const _encode = encoder
1298
+ ? function (value) {
1299
+ return encoder.call(this, value, encode$1);
1300
+ }
1301
+ : encode$1;
1209
1302
 
1210
- return this._pairs.map(function each(pair) {
1211
- return _encode(pair[0]) + '=' + _encode(pair[1]);
1212
- }, '').join('&');
1303
+ return this._pairs
1304
+ .map(function each(pair) {
1305
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1306
+ }, '')
1307
+ .join('&');
1213
1308
  };
1214
1309
 
1215
1310
  /**
@@ -1221,11 +1316,11 @@ prototype.toString = function toString(encoder) {
1221
1316
  * @returns {string} The encoded value.
1222
1317
  */
1223
1318
  function encode(val) {
1224
- return encodeURIComponent(val).
1225
- replace(/%3A/gi, ':').
1226
- replace(/%24/g, '$').
1227
- replace(/%2C/gi, ',').
1228
- replace(/%20/g, '+');
1319
+ return encodeURIComponent(val)
1320
+ .replace(/%3A/gi, ':')
1321
+ .replace(/%24/g, '$')
1322
+ .replace(/%2C/gi, ',')
1323
+ .replace(/%20/g, '+');
1229
1324
  }
1230
1325
 
1231
1326
  /**
@@ -1242,11 +1337,13 @@ function buildURL(url, params, options) {
1242
1337
  return url;
1243
1338
  }
1244
1339
 
1245
- const _encode = options && options.encode || encode;
1340
+ const _encode = (options && options.encode) || encode;
1246
1341
 
1247
- const _options = utils$1.isFunction(options) ? {
1248
- serialize: options
1249
- } : options;
1342
+ const _options = utils$1.isFunction(options)
1343
+ ? {
1344
+ serialize: options,
1345
+ }
1346
+ : options;
1250
1347
 
1251
1348
  const serializeFn = _options && _options.serialize;
1252
1349
 
@@ -1255,13 +1352,13 @@ function buildURL(url, params, options) {
1255
1352
  if (serializeFn) {
1256
1353
  serializedParams = serializeFn(params, _options);
1257
1354
  } else {
1258
- serializedParams = utils$1.isURLSearchParams(params) ?
1259
- params.toString() :
1260
- new AxiosURLSearchParams(params, _options).toString(_encode);
1355
+ serializedParams = utils$1.isURLSearchParams(params)
1356
+ ? params.toString()
1357
+ : new AxiosURLSearchParams(params, _options).toString(_encode);
1261
1358
  }
1262
1359
 
1263
1360
  if (serializedParams) {
1264
- const hashmarkIndex = url.indexOf("#");
1361
+ const hashmarkIndex = url.indexOf('#');
1265
1362
 
1266
1363
  if (hashmarkIndex !== -1) {
1267
1364
  url = url.slice(0, hashmarkIndex);
@@ -1291,7 +1388,7 @@ class InterceptorManager {
1291
1388
  fulfilled,
1292
1389
  rejected,
1293
1390
  synchronous: options ? options.synchronous : false,
1294
- runWhen: options ? options.runWhen : null
1391
+ runWhen: options ? options.runWhen : null,
1295
1392
  });
1296
1393
  return this.handlers.length - 1;
1297
1394
  }
@@ -1345,7 +1442,7 @@ var transitionalDefaults = {
1345
1442
  silentJSONParsing: true,
1346
1443
  forcedJSONParsing: true,
1347
1444
  clarifyTimeoutError: false,
1348
- legacyInterceptorReqResOrdering: true
1445
+ legacyInterceptorReqResOrdering: true,
1349
1446
  };
1350
1447
 
1351
1448
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -1359,14 +1456,14 @@ var platform$1 = {
1359
1456
  classes: {
1360
1457
  URLSearchParams: URLSearchParams$1,
1361
1458
  FormData: FormData$1,
1362
- Blob: Blob$1
1459
+ Blob: Blob$1,
1363
1460
  },
1364
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1461
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
1365
1462
  };
1366
1463
 
1367
1464
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1368
1465
 
1369
- const _navigator = typeof navigator === 'object' && navigator || undefined;
1466
+ const _navigator = (typeof navigator === 'object' && navigator) || undefined;
1370
1467
 
1371
1468
  /**
1372
1469
  * Determine if we're running in a standard browser environment
@@ -1385,7 +1482,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
1385
1482
  *
1386
1483
  * @returns {boolean}
1387
1484
  */
1388
- const hasStandardBrowserEnv = hasBrowserEnv &&
1485
+ const hasStandardBrowserEnv =
1486
+ hasBrowserEnv &&
1389
1487
  (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1390
1488
 
1391
1489
  /**
@@ -1406,7 +1504,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
1406
1504
  );
1407
1505
  })();
1408
1506
 
1409
- const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1507
+ const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
1410
1508
 
1411
1509
  var utils = /*#__PURE__*/Object.freeze({
1412
1510
  __proto__: null,
@@ -1419,12 +1517,12 @@ var utils = /*#__PURE__*/Object.freeze({
1419
1517
 
1420
1518
  var platform = {
1421
1519
  ...utils,
1422
- ...platform$1
1520
+ ...platform$1,
1423
1521
  };
1424
1522
 
1425
1523
  function toURLEncodedForm(data, options) {
1426
1524
  return toFormData(data, new platform.classes.URLSearchParams(), {
1427
- visitor: function(value, key, path, helpers) {
1525
+ visitor: function (value, key, path, helpers) {
1428
1526
  if (platform.isNode && utils$1.isBuffer(value)) {
1429
1527
  this.append(key, value.toString('base64'));
1430
1528
  return false;
@@ -1432,7 +1530,7 @@ function toURLEncodedForm(data, options) {
1432
1530
 
1433
1531
  return helpers.defaultVisitor.apply(this, arguments);
1434
1532
  },
1435
- ...options
1533
+ ...options,
1436
1534
  });
1437
1535
  }
1438
1536
 
@@ -1448,7 +1546,7 @@ function parsePropPath(name) {
1448
1546
  // foo.x.y.z
1449
1547
  // foo-x-y-z
1450
1548
  // foo x y z
1451
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1549
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
1452
1550
  return match[0] === '[]' ? '' : match[1] || match[0];
1453
1551
  });
1454
1552
  }
@@ -1552,96 +1650,107 @@ function stringifySafely(rawValue, parser, encoder) {
1552
1650
  }
1553
1651
 
1554
1652
  const defaults = {
1555
-
1556
1653
  transitional: transitionalDefaults,
1557
1654
 
1558
1655
  adapter: ['xhr', 'http', 'fetch'],
1559
1656
 
1560
- transformRequest: [function transformRequest(data, headers) {
1561
- const contentType = headers.getContentType() || '';
1562
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
1563
- const isObjectPayload = utils$1.isObject(data);
1657
+ transformRequest: [
1658
+ function transformRequest(data, headers) {
1659
+ const contentType = headers.getContentType() || '';
1660
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1661
+ const isObjectPayload = utils$1.isObject(data);
1564
1662
 
1565
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1566
- data = new FormData(data);
1567
- }
1663
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1664
+ data = new FormData(data);
1665
+ }
1568
1666
 
1569
- const isFormData = utils$1.isFormData(data);
1667
+ const isFormData = utils$1.isFormData(data);
1570
1668
 
1571
- if (isFormData) {
1572
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1573
- }
1669
+ if (isFormData) {
1670
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1671
+ }
1574
1672
 
1575
- if (utils$1.isArrayBuffer(data) ||
1576
- utils$1.isBuffer(data) ||
1577
- utils$1.isStream(data) ||
1578
- utils$1.isFile(data) ||
1579
- utils$1.isBlob(data) ||
1580
- utils$1.isReadableStream(data)
1581
- ) {
1582
- return data;
1583
- }
1584
- if (utils$1.isArrayBufferView(data)) {
1585
- return data.buffer;
1586
- }
1587
- if (utils$1.isURLSearchParams(data)) {
1588
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1589
- return data.toString();
1590
- }
1673
+ if (
1674
+ utils$1.isArrayBuffer(data) ||
1675
+ utils$1.isBuffer(data) ||
1676
+ utils$1.isStream(data) ||
1677
+ utils$1.isFile(data) ||
1678
+ utils$1.isBlob(data) ||
1679
+ utils$1.isReadableStream(data)
1680
+ ) {
1681
+ return data;
1682
+ }
1683
+ if (utils$1.isArrayBufferView(data)) {
1684
+ return data.buffer;
1685
+ }
1686
+ if (utils$1.isURLSearchParams(data)) {
1687
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1688
+ return data.toString();
1689
+ }
1591
1690
 
1592
- let isFileList;
1691
+ let isFileList;
1593
1692
 
1594
- if (isObjectPayload) {
1595
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1596
- return toURLEncodedForm(data, this.formSerializer).toString();
1597
- }
1693
+ if (isObjectPayload) {
1694
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1695
+ return toURLEncodedForm(data, this.formSerializer).toString();
1696
+ }
1598
1697
 
1599
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1600
- const _FormData = this.env && this.env.FormData;
1698
+ if (
1699
+ (isFileList = utils$1.isFileList(data)) ||
1700
+ contentType.indexOf('multipart/form-data') > -1
1701
+ ) {
1702
+ const _FormData = this.env && this.env.FormData;
1601
1703
 
1602
- return toFormData(
1603
- isFileList ? {'files[]': data} : data,
1604
- _FormData && new _FormData(),
1605
- this.formSerializer
1606
- );
1704
+ return toFormData(
1705
+ isFileList ? { 'files[]': data } : data,
1706
+ _FormData && new _FormData(),
1707
+ this.formSerializer
1708
+ );
1709
+ }
1607
1710
  }
1608
- }
1609
1711
 
1610
- if (isObjectPayload || hasJSONContentType ) {
1611
- headers.setContentType('application/json', false);
1612
- return stringifySafely(data);
1613
- }
1712
+ if (isObjectPayload || hasJSONContentType) {
1713
+ headers.setContentType('application/json', false);
1714
+ return stringifySafely(data);
1715
+ }
1614
1716
 
1615
- return data;
1616
- }],
1717
+ return data;
1718
+ },
1719
+ ],
1617
1720
 
1618
- transformResponse: [function transformResponse(data) {
1619
- const transitional = this.transitional || defaults.transitional;
1620
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1621
- const JSONRequested = this.responseType === 'json';
1721
+ transformResponse: [
1722
+ function transformResponse(data) {
1723
+ const transitional = this.transitional || defaults.transitional;
1724
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1725
+ const JSONRequested = this.responseType === 'json';
1622
1726
 
1623
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1624
- return data;
1625
- }
1727
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1728
+ return data;
1729
+ }
1626
1730
 
1627
- if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1628
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
1629
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
1731
+ if (
1732
+ data &&
1733
+ utils$1.isString(data) &&
1734
+ ((forcedJSONParsing && !this.responseType) || JSONRequested)
1735
+ ) {
1736
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1737
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1630
1738
 
1631
- try {
1632
- return JSON.parse(data, this.parseReviver);
1633
- } catch (e) {
1634
- if (strictJSONParsing) {
1635
- if (e.name === 'SyntaxError') {
1636
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1739
+ try {
1740
+ return JSON.parse(data, this.parseReviver);
1741
+ } catch (e) {
1742
+ if (strictJSONParsing) {
1743
+ if (e.name === 'SyntaxError') {
1744
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1745
+ }
1746
+ throw e;
1637
1747
  }
1638
- throw e;
1639
1748
  }
1640
1749
  }
1641
- }
1642
1750
 
1643
- return data;
1644
- }],
1751
+ return data;
1752
+ },
1753
+ ],
1645
1754
 
1646
1755
  /**
1647
1756
  * A timeout in milliseconds to abort a request. If set to 0 (default) a
@@ -1657,7 +1766,7 @@ const defaults = {
1657
1766
 
1658
1767
  env: {
1659
1768
  FormData: platform.classes.FormData,
1660
- Blob: platform.classes.Blob
1769
+ Blob: platform.classes.Blob,
1661
1770
  },
1662
1771
 
1663
1772
  validateStatus: function validateStatus(status) {
@@ -1666,10 +1775,10 @@ const defaults = {
1666
1775
 
1667
1776
  headers: {
1668
1777
  common: {
1669
- 'Accept': 'application/json, text/plain, */*',
1670
- 'Content-Type': undefined
1671
- }
1672
- }
1778
+ Accept: 'application/json, text/plain, */*',
1779
+ 'Content-Type': undefined,
1780
+ },
1781
+ },
1673
1782
  };
1674
1783
 
1675
1784
  utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
@@ -1681,10 +1790,23 @@ var defaults$1 = defaults;
1681
1790
  // RawAxiosHeaders whose duplicates are ignored by node
1682
1791
  // c.f. https://nodejs.org/api/http.html#http_message_headers
1683
1792
  const ignoreDuplicateOf = utils$1.toObjectSet([
1684
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
1685
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1686
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1687
- 'referer', 'retry-after', 'user-agent'
1793
+ 'age',
1794
+ 'authorization',
1795
+ 'content-length',
1796
+ 'content-type',
1797
+ 'etag',
1798
+ 'expires',
1799
+ 'from',
1800
+ 'host',
1801
+ 'if-modified-since',
1802
+ 'if-unmodified-since',
1803
+ 'last-modified',
1804
+ 'location',
1805
+ 'max-forwards',
1806
+ 'proxy-authorization',
1807
+ 'referer',
1808
+ 'retry-after',
1809
+ 'user-agent',
1688
1810
  ]);
1689
1811
 
1690
1812
  /**
@@ -1701,31 +1823,32 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
1701
1823
  *
1702
1824
  * @returns {Object} Headers parsed into an object
1703
1825
  */
1704
- var parseHeaders = rawHeaders => {
1826
+ var parseHeaders = (rawHeaders) => {
1705
1827
  const parsed = {};
1706
1828
  let key;
1707
1829
  let val;
1708
1830
  let i;
1709
1831
 
1710
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1711
- i = line.indexOf(':');
1712
- key = line.substring(0, i).trim().toLowerCase();
1713
- val = line.substring(i + 1).trim();
1832
+ rawHeaders &&
1833
+ rawHeaders.split('\n').forEach(function parser(line) {
1834
+ i = line.indexOf(':');
1835
+ key = line.substring(0, i).trim().toLowerCase();
1836
+ val = line.substring(i + 1).trim();
1714
1837
 
1715
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1716
- return;
1717
- }
1838
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1839
+ return;
1840
+ }
1718
1841
 
1719
- if (key === 'set-cookie') {
1720
- if (parsed[key]) {
1721
- parsed[key].push(val);
1842
+ if (key === 'set-cookie') {
1843
+ if (parsed[key]) {
1844
+ parsed[key].push(val);
1845
+ } else {
1846
+ parsed[key] = [val];
1847
+ }
1722
1848
  } else {
1723
- parsed[key] = [val];
1849
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1724
1850
  }
1725
- } else {
1726
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1727
- }
1728
- });
1851
+ });
1729
1852
 
1730
1853
  return parsed;
1731
1854
  };
@@ -1779,8 +1902,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1779
1902
  }
1780
1903
 
1781
1904
  function formatHeader(header) {
1782
- return header.trim()
1783
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1905
+ return header
1906
+ .trim()
1907
+ .toLowerCase()
1908
+ .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1784
1909
  return char.toUpperCase() + str;
1785
1910
  });
1786
1911
  }
@@ -1788,12 +1913,12 @@ function formatHeader(header) {
1788
1913
  function buildAccessors(obj, header) {
1789
1914
  const accessorName = utils$1.toCamelCase(' ' + header);
1790
1915
 
1791
- ['get', 'set', 'has'].forEach(methodName => {
1916
+ ['get', 'set', 'has'].forEach((methodName) => {
1792
1917
  Object.defineProperty(obj, methodName + accessorName, {
1793
- value: function(arg1, arg2, arg3) {
1918
+ value: function (arg1, arg2, arg3) {
1794
1919
  return this[methodName].call(this, header, arg1, arg2, arg3);
1795
1920
  },
1796
- configurable: true
1921
+ configurable: true,
1797
1922
  });
1798
1923
  });
1799
1924
  }
@@ -1815,7 +1940,12 @@ class AxiosHeaders {
1815
1940
 
1816
1941
  const key = utils$1.findKey(self, lHeader);
1817
1942
 
1818
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1943
+ if (
1944
+ !key ||
1945
+ self[key] === undefined ||
1946
+ _rewrite === true ||
1947
+ (_rewrite === undefined && self[key] !== false)
1948
+ ) {
1819
1949
  self[key || _header] = normalizeValue(_value);
1820
1950
  }
1821
1951
  }
@@ -1825,17 +1955,22 @@ class AxiosHeaders {
1825
1955
 
1826
1956
  if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1827
1957
  setHeaders(header, valueOrRewrite);
1828
- } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1958
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1829
1959
  setHeaders(parseHeaders(header), valueOrRewrite);
1830
1960
  } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1831
- let obj = {}, dest, key;
1961
+ let obj = {},
1962
+ dest,
1963
+ key;
1832
1964
  for (const entry of header) {
1833
1965
  if (!utils$1.isArray(entry)) {
1834
1966
  throw TypeError('Object iterator must return a key-value pair');
1835
1967
  }
1836
1968
 
1837
- obj[key = entry[0]] = (dest = obj[key]) ?
1838
- (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
1969
+ obj[(key = entry[0])] = (dest = obj[key])
1970
+ ? utils$1.isArray(dest)
1971
+ ? [...dest, entry[1]]
1972
+ : [dest, entry[1]]
1973
+ : entry[1];
1839
1974
  }
1840
1975
 
1841
1976
  setHeaders(obj, valueOrRewrite);
@@ -1882,7 +2017,11 @@ class AxiosHeaders {
1882
2017
  if (header) {
1883
2018
  const key = utils$1.findKey(this, header);
1884
2019
 
1885
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2020
+ return !!(
2021
+ key &&
2022
+ this[key] !== undefined &&
2023
+ (!matcher || matchHeaderValue(this, this[key], key, matcher))
2024
+ );
1886
2025
  }
1887
2026
 
1888
2027
  return false;
@@ -1922,7 +2061,7 @@ class AxiosHeaders {
1922
2061
 
1923
2062
  while (i--) {
1924
2063
  const key = keys[i];
1925
- if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2064
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1926
2065
  delete this[key];
1927
2066
  deleted = true;
1928
2067
  }
@@ -1966,7 +2105,9 @@ class AxiosHeaders {
1966
2105
  const obj = Object.create(null);
1967
2106
 
1968
2107
  utils$1.forEach(this, (value, header) => {
1969
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2108
+ value != null &&
2109
+ value !== false &&
2110
+ (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1970
2111
  });
1971
2112
 
1972
2113
  return obj;
@@ -1977,11 +2118,13 @@ class AxiosHeaders {
1977
2118
  }
1978
2119
 
1979
2120
  toString() {
1980
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
2121
+ return Object.entries(this.toJSON())
2122
+ .map(([header, value]) => header + ': ' + value)
2123
+ .join('\n');
1981
2124
  }
1982
2125
 
1983
2126
  getSetCookie() {
1984
- return this.get("set-cookie") || [];
2127
+ return this.get('set-cookie') || [];
1985
2128
  }
1986
2129
 
1987
2130
  get [Symbol.toStringTag]() {
@@ -2001,9 +2144,12 @@ class AxiosHeaders {
2001
2144
  }
2002
2145
 
2003
2146
  static accessor(header) {
2004
- const internals = this[$internals] = (this[$internals] = {
2005
- accessors: {}
2006
- });
2147
+ const internals =
2148
+ (this[$internals] =
2149
+ this[$internals] =
2150
+ {
2151
+ accessors: {},
2152
+ });
2007
2153
 
2008
2154
  const accessors = internals.accessors;
2009
2155
  const prototype = this.prototype;
@@ -2023,17 +2169,24 @@ class AxiosHeaders {
2023
2169
  }
2024
2170
  }
2025
2171
 
2026
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2172
+ AxiosHeaders.accessor([
2173
+ 'Content-Type',
2174
+ 'Content-Length',
2175
+ 'Accept',
2176
+ 'Accept-Encoding',
2177
+ 'User-Agent',
2178
+ 'Authorization',
2179
+ ]);
2027
2180
 
2028
2181
  // reserved names hotfix
2029
- utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
2182
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
2030
2183
  let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2031
2184
  return {
2032
2185
  get: () => value,
2033
2186
  set(headerValue) {
2034
2187
  this[mapped] = headerValue;
2035
- }
2036
- }
2188
+ },
2189
+ };
2037
2190
  });
2038
2191
 
2039
2192
  utils$1.freezeMethods(AxiosHeaders);
@@ -2100,19 +2253,23 @@ function settle(resolve, reject, response) {
2100
2253
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2101
2254
  resolve(response);
2102
2255
  } else {
2103
- reject(new AxiosError$1(
2104
- 'Request failed with status code ' + response.status,
2105
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2106
- response.config,
2107
- response.request,
2108
- response
2109
- ));
2256
+ reject(
2257
+ new AxiosError$1(
2258
+ 'Request failed with status code ' + response.status,
2259
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
2260
+ Math.floor(response.status / 100) - 4
2261
+ ],
2262
+ response.config,
2263
+ response.request,
2264
+ response
2265
+ )
2266
+ );
2110
2267
  }
2111
2268
  }
2112
2269
 
2113
2270
  function parseProtocol(url) {
2114
2271
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2115
- return match && match[1] || '';
2272
+ return (match && match[1]) || '';
2116
2273
  }
2117
2274
 
2118
2275
  /**
@@ -2163,7 +2320,7 @@ function speedometer(samplesCount, min) {
2163
2320
 
2164
2321
  const passed = startedAt && now - startedAt;
2165
2322
 
2166
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2323
+ return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
2167
2324
  };
2168
2325
  }
2169
2326
 
@@ -2192,7 +2349,7 @@ function throttle(fn, freq) {
2192
2349
  const throttled = (...args) => {
2193
2350
  const now = Date.now();
2194
2351
  const passed = now - timestamp;
2195
- if ( passed >= threshold) {
2352
+ if (passed >= threshold) {
2196
2353
  invoke(args, now);
2197
2354
  } else {
2198
2355
  lastArgs = args;
@@ -2214,7 +2371,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2214
2371
  let bytesNotified = 0;
2215
2372
  const _speedometer = speedometer(50, 250);
2216
2373
 
2217
- return throttle(e => {
2374
+ return throttle((e) => {
2218
2375
  const loaded = e.loaded;
2219
2376
  const total = e.lengthComputable ? e.total : undefined;
2220
2377
  const progressBytes = loaded - bytesNotified;
@@ -2226,13 +2383,13 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2226
2383
  const data = {
2227
2384
  loaded,
2228
2385
  total,
2229
- progress: total ? (loaded / total) : undefined,
2386
+ progress: total ? loaded / total : undefined,
2230
2387
  bytes: progressBytes,
2231
2388
  rate: rate ? rate : undefined,
2232
2389
  estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2233
2390
  event: e,
2234
2391
  lengthComputable: total != null,
2235
- [isDownloadStream ? 'download' : 'upload']: true
2392
+ [isDownloadStream ? 'download' : 'upload']: true,
2236
2393
  };
2237
2394
 
2238
2395
  listener(data);
@@ -2242,77 +2399,82 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2242
2399
  const progressEventDecorator = (total, throttled) => {
2243
2400
  const lengthComputable = total != null;
2244
2401
 
2245
- return [(loaded) => throttled[0]({
2246
- lengthComputable,
2247
- total,
2248
- loaded
2249
- }), throttled[1]];
2402
+ return [
2403
+ (loaded) =>
2404
+ throttled[0]({
2405
+ lengthComputable,
2406
+ total,
2407
+ loaded,
2408
+ }),
2409
+ throttled[1],
2410
+ ];
2250
2411
  };
2251
2412
 
2252
- const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2253
-
2254
- var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2255
- url = new URL(url, platform.origin);
2256
-
2257
- return (
2258
- origin.protocol === url.protocol &&
2259
- origin.host === url.host &&
2260
- (isMSIE || origin.port === url.port)
2261
- );
2262
- })(
2263
- new URL(platform.origin),
2264
- platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2265
- ) : () => true;
2266
-
2267
- var cookies = platform.hasStandardBrowserEnv ?
2268
-
2269
- // Standard browser envs support document.cookie
2270
- {
2271
- write(name, value, expires, path, domain, secure, sameSite) {
2272
- if (typeof document === 'undefined') return;
2413
+ const asyncDecorator =
2414
+ (fn) =>
2415
+ (...args) =>
2416
+ utils$1.asap(() => fn(...args));
2273
2417
 
2274
- const cookie = [`${name}=${encodeURIComponent(value)}`];
2418
+ var isURLSameOrigin = platform.hasStandardBrowserEnv
2419
+ ? ((origin, isMSIE) => (url) => {
2420
+ url = new URL(url, platform.origin);
2275
2421
 
2276
- if (utils$1.isNumber(expires)) {
2277
- cookie.push(`expires=${new Date(expires).toUTCString()}`);
2278
- }
2279
- if (utils$1.isString(path)) {
2280
- cookie.push(`path=${path}`);
2281
- }
2282
- if (utils$1.isString(domain)) {
2283
- cookie.push(`domain=${domain}`);
2284
- }
2285
- if (secure === true) {
2286
- cookie.push('secure');
2287
- }
2288
- if (utils$1.isString(sameSite)) {
2289
- cookie.push(`SameSite=${sameSite}`);
2290
- }
2422
+ return (
2423
+ origin.protocol === url.protocol &&
2424
+ origin.host === url.host &&
2425
+ (isMSIE || origin.port === url.port)
2426
+ );
2427
+ })(
2428
+ new URL(platform.origin),
2429
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2430
+ )
2431
+ : () => true;
2432
+
2433
+ var cookies = platform.hasStandardBrowserEnv
2434
+ ? // Standard browser envs support document.cookie
2435
+ {
2436
+ write(name, value, expires, path, domain, secure, sameSite) {
2437
+ if (typeof document === 'undefined') return;
2438
+
2439
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2440
+
2441
+ if (utils$1.isNumber(expires)) {
2442
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
2443
+ }
2444
+ if (utils$1.isString(path)) {
2445
+ cookie.push(`path=${path}`);
2446
+ }
2447
+ if (utils$1.isString(domain)) {
2448
+ cookie.push(`domain=${domain}`);
2449
+ }
2450
+ if (secure === true) {
2451
+ cookie.push('secure');
2452
+ }
2453
+ if (utils$1.isString(sameSite)) {
2454
+ cookie.push(`SameSite=${sameSite}`);
2455
+ }
2291
2456
 
2292
- document.cookie = cookie.join('; ');
2293
- },
2457
+ document.cookie = cookie.join('; ');
2458
+ },
2294
2459
 
2295
- read(name) {
2296
- if (typeof document === 'undefined') return null;
2297
- const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2298
- return match ? decodeURIComponent(match[1]) : null;
2299
- },
2460
+ read(name) {
2461
+ if (typeof document === 'undefined') return null;
2462
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2463
+ return match ? decodeURIComponent(match[1]) : null;
2464
+ },
2300
2465
 
2301
- remove(name) {
2302
- this.write(name, '', Date.now() - 86400000, '/');
2466
+ remove(name) {
2467
+ this.write(name, '', Date.now() - 86400000, '/');
2468
+ },
2303
2469
  }
2304
- }
2305
-
2306
- :
2307
-
2308
- // Non-standard browser env (web workers, react-native) lack needed support.
2309
- {
2310
- write() {},
2311
- read() {
2312
- return null;
2313
- },
2314
- remove() {}
2315
- };
2470
+ : // Non-standard browser env (web workers, react-native) lack needed support.
2471
+ {
2472
+ write() {},
2473
+ read() {
2474
+ return null;
2475
+ },
2476
+ remove() {},
2477
+ };
2316
2478
 
2317
2479
  /**
2318
2480
  * Determines whether the specified URL is absolute
@@ -2364,8 +2526,7 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2364
2526
  return requestedURL;
2365
2527
  }
2366
2528
 
2367
- const headersToObject = (thing) =>
2368
- thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2529
+ const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
2369
2530
 
2370
2531
  /**
2371
2532
  * Config-specific merge-function which creates a new config-object
@@ -2458,23 +2619,12 @@ function mergeConfig(config1, config2) {
2458
2619
  mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
2459
2620
  };
2460
2621
 
2461
- utils$1.forEach(
2462
- Object.keys({ ...config1, ...config2 }),
2463
- function computeConfigValue(prop) {
2464
- if (
2465
- prop === "__proto__" ||
2466
- prop === "constructor" ||
2467
- prop === "prototype"
2468
- )
2469
- return;
2470
- const merge = utils$1.hasOwnProp(mergeMap, prop)
2471
- ? mergeMap[prop]
2472
- : mergeDeepProperties;
2473
- const configValue = merge(config1[prop], config2[prop], prop);
2474
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
2475
- (config[prop] = configValue);
2476
- },
2477
- );
2622
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
2623
+ if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
2624
+ const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
2625
+ const configValue = merge(config1[prop], config2[prop], prop);
2626
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2627
+ });
2478
2628
 
2479
2629
  return config;
2480
2630
  }
@@ -2486,12 +2636,22 @@ var resolveConfig = (config) => {
2486
2636
 
2487
2637
  newConfig.headers = headers = AxiosHeaders$1.from(headers);
2488
2638
 
2489
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2639
+ newConfig.url = buildURL(
2640
+ buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
2641
+ config.params,
2642
+ config.paramsSerializer
2643
+ );
2490
2644
 
2491
2645
  // HTTP basic authentication
2492
2646
  if (auth) {
2493
- headers.set('Authorization', 'Basic ' +
2494
- btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2647
+ headers.set(
2648
+ 'Authorization',
2649
+ 'Basic ' +
2650
+ btoa(
2651
+ (auth.username || '') +
2652
+ ':' +
2653
+ (auth.password ? unescape(encodeURIComponent(auth.password)) : '')
2654
+ )
2495
2655
  );
2496
2656
  }
2497
2657
 
@@ -2509,7 +2669,7 @@ var resolveConfig = (config) => {
2509
2669
  }
2510
2670
  });
2511
2671
  }
2512
- }
2672
+ }
2513
2673
 
2514
2674
  // Add xsrf header
2515
2675
  // This is only done if running in a standard browser environment.
@@ -2533,196 +2693,218 @@ var resolveConfig = (config) => {
2533
2693
 
2534
2694
  const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2535
2695
 
2536
- var xhrAdapter = isXHRAdapterSupported && function (config) {
2537
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2538
- const _config = resolveConfig(config);
2539
- let requestData = _config.data;
2540
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2541
- let {responseType, onUploadProgress, onDownloadProgress} = _config;
2542
- let onCanceled;
2543
- let uploadThrottled, downloadThrottled;
2544
- let flushUpload, flushDownload;
2696
+ var xhrAdapter = isXHRAdapterSupported &&
2697
+ function (config) {
2698
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2699
+ const _config = resolveConfig(config);
2700
+ let requestData = _config.data;
2701
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2702
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
2703
+ let onCanceled;
2704
+ let uploadThrottled, downloadThrottled;
2705
+ let flushUpload, flushDownload;
2545
2706
 
2546
- function done() {
2547
- flushUpload && flushUpload(); // flush events
2548
- flushDownload && flushDownload(); // flush events
2707
+ function done() {
2708
+ flushUpload && flushUpload(); // flush events
2709
+ flushDownload && flushDownload(); // flush events
2549
2710
 
2550
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2711
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2551
2712
 
2552
- _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2553
- }
2713
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2714
+ }
2554
2715
 
2555
- let request = new XMLHttpRequest();
2716
+ let request = new XMLHttpRequest();
2556
2717
 
2557
- request.open(_config.method.toUpperCase(), _config.url, true);
2718
+ request.open(_config.method.toUpperCase(), _config.url, true);
2558
2719
 
2559
- // Set the request timeout in MS
2560
- request.timeout = _config.timeout;
2720
+ // Set the request timeout in MS
2721
+ request.timeout = _config.timeout;
2561
2722
 
2562
- function onloadend() {
2563
- if (!request) {
2564
- return;
2723
+ function onloadend() {
2724
+ if (!request) {
2725
+ return;
2726
+ }
2727
+ // Prepare the response
2728
+ const responseHeaders = AxiosHeaders$1.from(
2729
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2730
+ );
2731
+ const responseData =
2732
+ !responseType || responseType === 'text' || responseType === 'json'
2733
+ ? request.responseText
2734
+ : request.response;
2735
+ const response = {
2736
+ data: responseData,
2737
+ status: request.status,
2738
+ statusText: request.statusText,
2739
+ headers: responseHeaders,
2740
+ config,
2741
+ request,
2742
+ };
2743
+
2744
+ settle(
2745
+ function _resolve(value) {
2746
+ resolve(value);
2747
+ done();
2748
+ },
2749
+ function _reject(err) {
2750
+ reject(err);
2751
+ done();
2752
+ },
2753
+ response
2754
+ );
2755
+
2756
+ // Clean up request
2757
+ request = null;
2565
2758
  }
2566
- // Prepare the response
2567
- const responseHeaders = AxiosHeaders$1.from(
2568
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2569
- );
2570
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2571
- request.responseText : request.response;
2572
- const response = {
2573
- data: responseData,
2574
- status: request.status,
2575
- statusText: request.statusText,
2576
- headers: responseHeaders,
2577
- config,
2578
- request
2579
- };
2580
2759
 
2581
- settle(function _resolve(value) {
2582
- resolve(value);
2583
- done();
2584
- }, function _reject(err) {
2585
- reject(err);
2586
- done();
2587
- }, response);
2760
+ if ('onloadend' in request) {
2761
+ // Use onloadend if available
2762
+ request.onloadend = onloadend;
2763
+ } else {
2764
+ // Listen for ready state to emulate onloadend
2765
+ request.onreadystatechange = function handleLoad() {
2766
+ if (!request || request.readyState !== 4) {
2767
+ return;
2768
+ }
2588
2769
 
2589
- // Clean up request
2590
- request = null;
2591
- }
2770
+ // The request errored out and we didn't get a response, this will be
2771
+ // handled by onerror instead
2772
+ // With one exception: request that using file: protocol, most browsers
2773
+ // will return status as 0 even though it's a successful request
2774
+ if (
2775
+ request.status === 0 &&
2776
+ !(request.responseURL && request.responseURL.indexOf('file:') === 0)
2777
+ ) {
2778
+ return;
2779
+ }
2780
+ // readystate handler is calling before onerror or ontimeout handlers,
2781
+ // so we should call onloadend on the next 'tick'
2782
+ setTimeout(onloadend);
2783
+ };
2784
+ }
2592
2785
 
2593
- if ('onloadend' in request) {
2594
- // Use onloadend if available
2595
- request.onloadend = onloadend;
2596
- } else {
2597
- // Listen for ready state to emulate onloadend
2598
- request.onreadystatechange = function handleLoad() {
2599
- if (!request || request.readyState !== 4) {
2786
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2787
+ request.onabort = function handleAbort() {
2788
+ if (!request) {
2600
2789
  return;
2601
2790
  }
2602
2791
 
2603
- // The request errored out and we didn't get a response, this will be
2604
- // handled by onerror instead
2605
- // With one exception: request that using file: protocol, most browsers
2606
- // will return status as 0 even though it's a successful request
2607
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2608
- return;
2609
- }
2610
- // readystate handler is calling before onerror or ontimeout handlers,
2611
- // so we should call onloadend on the next 'tick'
2612
- setTimeout(onloadend);
2792
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
2793
+
2794
+ // Clean up request
2795
+ request = null;
2613
2796
  };
2614
- }
2615
2797
 
2616
- // Handle browser request cancellation (as opposed to a manual cancellation)
2617
- request.onabort = function handleAbort() {
2618
- if (!request) {
2619
- return;
2620
- }
2798
+ // Handle low level network errors
2799
+ request.onerror = function handleError(event) {
2800
+ // Browsers deliver a ProgressEvent in XHR onerror
2801
+ // (message may be empty; when present, surface it)
2802
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2803
+ const msg = event && event.message ? event.message : 'Network Error';
2804
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
2805
+ // attach the underlying event for consumers who want details
2806
+ err.event = event || null;
2807
+ reject(err);
2808
+ request = null;
2809
+ };
2621
2810
 
2622
- reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
2811
+ // Handle timeout
2812
+ request.ontimeout = function handleTimeout() {
2813
+ let timeoutErrorMessage = _config.timeout
2814
+ ? 'timeout of ' + _config.timeout + 'ms exceeded'
2815
+ : 'timeout exceeded';
2816
+ const transitional = _config.transitional || transitionalDefaults;
2817
+ if (_config.timeoutErrorMessage) {
2818
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2819
+ }
2820
+ reject(
2821
+ new AxiosError$1(
2822
+ timeoutErrorMessage,
2823
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2824
+ config,
2825
+ request
2826
+ )
2827
+ );
2623
2828
 
2624
- // Clean up request
2625
- request = null;
2626
- };
2829
+ // Clean up request
2830
+ request = null;
2831
+ };
2627
2832
 
2628
- // Handle low level network errors
2629
- request.onerror = function handleError(event) {
2630
- // Browsers deliver a ProgressEvent in XHR onerror
2631
- // (message may be empty; when present, surface it)
2632
- // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2633
- const msg = event && event.message ? event.message : 'Network Error';
2634
- const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
2635
- // attach the underlying event for consumers who want details
2636
- err.event = event || null;
2637
- reject(err);
2638
- request = null;
2639
- };
2640
-
2641
- // Handle timeout
2642
- request.ontimeout = function handleTimeout() {
2643
- let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2644
- const transitional = _config.transitional || transitionalDefaults;
2645
- if (_config.timeoutErrorMessage) {
2646
- timeoutErrorMessage = _config.timeoutErrorMessage;
2647
- }
2648
- reject(new AxiosError$1(
2649
- timeoutErrorMessage,
2650
- transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2651
- config,
2652
- request));
2653
-
2654
- // Clean up request
2655
- request = null;
2656
- };
2833
+ // Remove Content-Type if data is undefined
2834
+ requestData === undefined && requestHeaders.setContentType(null);
2657
2835
 
2658
- // Remove Content-Type if data is undefined
2659
- requestData === undefined && requestHeaders.setContentType(null);
2836
+ // Add headers to the request
2837
+ if ('setRequestHeader' in request) {
2838
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2839
+ request.setRequestHeader(key, val);
2840
+ });
2841
+ }
2660
2842
 
2661
- // Add headers to the request
2662
- if ('setRequestHeader' in request) {
2663
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2664
- request.setRequestHeader(key, val);
2665
- });
2666
- }
2843
+ // Add withCredentials to request if needed
2844
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2845
+ request.withCredentials = !!_config.withCredentials;
2846
+ }
2667
2847
 
2668
- // Add withCredentials to request if needed
2669
- if (!utils$1.isUndefined(_config.withCredentials)) {
2670
- request.withCredentials = !!_config.withCredentials;
2671
- }
2848
+ // Add responseType to request if needed
2849
+ if (responseType && responseType !== 'json') {
2850
+ request.responseType = _config.responseType;
2851
+ }
2672
2852
 
2673
- // Add responseType to request if needed
2674
- if (responseType && responseType !== 'json') {
2675
- request.responseType = _config.responseType;
2676
- }
2853
+ // Handle progress if needed
2854
+ if (onDownloadProgress) {
2855
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
2856
+ request.addEventListener('progress', downloadThrottled);
2857
+ }
2677
2858
 
2678
- // Handle progress if needed
2679
- if (onDownloadProgress) {
2680
- ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2681
- request.addEventListener('progress', downloadThrottled);
2682
- }
2859
+ // Not all browsers support upload events
2860
+ if (onUploadProgress && request.upload) {
2861
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
2683
2862
 
2684
- // Not all browsers support upload events
2685
- if (onUploadProgress && request.upload) {
2686
- ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
2863
+ request.upload.addEventListener('progress', uploadThrottled);
2687
2864
 
2688
- request.upload.addEventListener('progress', uploadThrottled);
2865
+ request.upload.addEventListener('loadend', flushUpload);
2866
+ }
2689
2867
 
2690
- request.upload.addEventListener('loadend', flushUpload);
2691
- }
2868
+ if (_config.cancelToken || _config.signal) {
2869
+ // Handle cancellation
2870
+ // eslint-disable-next-line func-names
2871
+ onCanceled = (cancel) => {
2872
+ if (!request) {
2873
+ return;
2874
+ }
2875
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2876
+ request.abort();
2877
+ request = null;
2878
+ };
2692
2879
 
2693
- if (_config.cancelToken || _config.signal) {
2694
- // Handle cancellation
2695
- // eslint-disable-next-line func-names
2696
- onCanceled = cancel => {
2697
- if (!request) {
2698
- return;
2880
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2881
+ if (_config.signal) {
2882
+ _config.signal.aborted
2883
+ ? onCanceled()
2884
+ : _config.signal.addEventListener('abort', onCanceled);
2699
2885
  }
2700
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2701
- request.abort();
2702
- request = null;
2703
- };
2704
-
2705
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2706
- if (_config.signal) {
2707
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
2708
2886
  }
2709
- }
2710
2887
 
2711
- const protocol = parseProtocol(_config.url);
2712
-
2713
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
2714
- reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2715
- return;
2716
- }
2888
+ const protocol = parseProtocol(_config.url);
2717
2889
 
2890
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2891
+ reject(
2892
+ new AxiosError$1(
2893
+ 'Unsupported protocol ' + protocol + ':',
2894
+ AxiosError$1.ERR_BAD_REQUEST,
2895
+ config
2896
+ )
2897
+ );
2898
+ return;
2899
+ }
2718
2900
 
2719
- // Send the request
2720
- request.send(requestData || null);
2721
- });
2722
- };
2901
+ // Send the request
2902
+ request.send(requestData || null);
2903
+ });
2904
+ };
2723
2905
 
2724
2906
  const composeSignals = (signals, timeout) => {
2725
- const {length} = (signals = signals ? signals.filter(Boolean) : []);
2907
+ const { length } = (signals = signals ? signals.filter(Boolean) : []);
2726
2908
 
2727
2909
  if (timeout || length) {
2728
2910
  let controller = new AbortController();
@@ -2734,21 +2916,29 @@ const composeSignals = (signals, timeout) => {
2734
2916
  aborted = true;
2735
2917
  unsubscribe();
2736
2918
  const err = reason instanceof Error ? reason : this.reason;
2737
- controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
2919
+ controller.abort(
2920
+ err instanceof AxiosError$1
2921
+ ? err
2922
+ : new CanceledError$1(err instanceof Error ? err.message : err)
2923
+ );
2738
2924
  }
2739
2925
  };
2740
2926
 
2741
- let timer = timeout && setTimeout(() => {
2742
- timer = null;
2743
- onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
2744
- }, timeout);
2927
+ let timer =
2928
+ timeout &&
2929
+ setTimeout(() => {
2930
+ timer = null;
2931
+ onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
2932
+ }, timeout);
2745
2933
 
2746
2934
  const unsubscribe = () => {
2747
2935
  if (signals) {
2748
2936
  timer && clearTimeout(timer);
2749
2937
  timer = null;
2750
- signals.forEach(signal => {
2751
- signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
2938
+ signals.forEach((signal) => {
2939
+ signal.unsubscribe
2940
+ ? signal.unsubscribe(onabort)
2941
+ : signal.removeEventListener('abort', onabort);
2752
2942
  });
2753
2943
  signals = null;
2754
2944
  }
@@ -2756,7 +2946,7 @@ const composeSignals = (signals, timeout) => {
2756
2946
 
2757
2947
  signals.forEach((signal) => signal.addEventListener('abort', onabort));
2758
2948
 
2759
- const {signal} = controller;
2949
+ const { signal } = controller;
2760
2950
 
2761
2951
  signal.unsubscribe = () => utils$1.asap(unsubscribe);
2762
2952
 
@@ -2799,7 +2989,7 @@ const readStream = async function* (stream) {
2799
2989
  const reader = stream.getReader();
2800
2990
  try {
2801
2991
  for (;;) {
2802
- const {done, value} = await reader.read();
2992
+ const { done, value } = await reader.read();
2803
2993
  if (done) {
2804
2994
  break;
2805
2995
  }
@@ -2822,64 +3012,69 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2822
3012
  }
2823
3013
  };
2824
3014
 
2825
- return new ReadableStream({
2826
- async pull(controller) {
2827
- try {
2828
- const {done, value} = await iterator.next();
3015
+ return new ReadableStream(
3016
+ {
3017
+ async pull(controller) {
3018
+ try {
3019
+ const { done, value } = await iterator.next();
2829
3020
 
2830
- if (done) {
2831
- _onFinish();
2832
- controller.close();
2833
- return;
2834
- }
3021
+ if (done) {
3022
+ _onFinish();
3023
+ controller.close();
3024
+ return;
3025
+ }
2835
3026
 
2836
- let len = value.byteLength;
2837
- if (onProgress) {
2838
- let loadedBytes = bytes += len;
2839
- onProgress(loadedBytes);
3027
+ let len = value.byteLength;
3028
+ if (onProgress) {
3029
+ let loadedBytes = (bytes += len);
3030
+ onProgress(loadedBytes);
3031
+ }
3032
+ controller.enqueue(new Uint8Array(value));
3033
+ } catch (err) {
3034
+ _onFinish(err);
3035
+ throw err;
2840
3036
  }
2841
- controller.enqueue(new Uint8Array(value));
2842
- } catch (err) {
2843
- _onFinish(err);
2844
- throw err;
2845
- }
3037
+ },
3038
+ cancel(reason) {
3039
+ _onFinish(reason);
3040
+ return iterator.return();
3041
+ },
2846
3042
  },
2847
- cancel(reason) {
2848
- _onFinish(reason);
2849
- return iterator.return();
3043
+ {
3044
+ highWaterMark: 2,
2850
3045
  }
2851
- }, {
2852
- highWaterMark: 2
2853
- })
3046
+ );
2854
3047
  };
2855
3048
 
2856
3049
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
2857
3050
 
2858
- const {isFunction} = utils$1;
3051
+ const { isFunction } = utils$1;
2859
3052
 
2860
- const globalFetchAPI = (({Request, Response}) => ({
2861
- Request, Response
3053
+ const globalFetchAPI = (({ Request, Response }) => ({
3054
+ Request,
3055
+ Response,
2862
3056
  }))(utils$1.global);
2863
3057
 
2864
- const {
2865
- ReadableStream: ReadableStream$1, TextEncoder
2866
- } = utils$1.global;
2867
-
3058
+ const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
2868
3059
 
2869
3060
  const test = (fn, ...args) => {
2870
3061
  try {
2871
3062
  return !!fn(...args);
2872
3063
  } catch (e) {
2873
- return false
3064
+ return false;
2874
3065
  }
2875
3066
  };
2876
3067
 
2877
3068
  const factory = (env) => {
2878
- env = utils$1.merge.call({
2879
- skipUndefined: true
2880
- }, globalFetchAPI, env);
3069
+ env = utils$1.merge.call(
3070
+ {
3071
+ skipUndefined: true,
3072
+ },
3073
+ globalFetchAPI,
3074
+ env
3075
+ );
2881
3076
 
2882
- const {fetch: envFetch, Request, Response} = env;
3077
+ const { fetch: envFetch, Request, Response } = env;
2883
3078
  const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
2884
3079
  const isRequestSupported = isFunction(Request);
2885
3080
  const isResponseSupported = isFunction(Response);
@@ -2890,46 +3085,61 @@ const factory = (env) => {
2890
3085
 
2891
3086
  const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
2892
3087
 
2893
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2894
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2895
- async (str) => new Uint8Array(await new Request(str).arrayBuffer())
2896
- );
2897
-
2898
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
2899
- let duplexAccessed = false;
2900
-
2901
- const hasContentType = new Request(platform.origin, {
2902
- body: new ReadableStream$1(),
2903
- method: 'POST',
2904
- get duplex() {
2905
- duplexAccessed = true;
2906
- return 'half';
2907
- },
2908
- }).headers.has('Content-Type');
3088
+ const encodeText =
3089
+ isFetchSupported &&
3090
+ (typeof TextEncoder === 'function'
3091
+ ? (
3092
+ (encoder) => (str) =>
3093
+ encoder.encode(str)
3094
+ )(new TextEncoder())
3095
+ : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
3096
+
3097
+ const supportsRequestStream =
3098
+ isRequestSupported &&
3099
+ isReadableStreamSupported &&
3100
+ test(() => {
3101
+ let duplexAccessed = false;
3102
+
3103
+ const hasContentType = new Request(platform.origin, {
3104
+ body: new ReadableStream$1(),
3105
+ method: 'POST',
3106
+ get duplex() {
3107
+ duplexAccessed = true;
3108
+ return 'half';
3109
+ },
3110
+ }).headers.has('Content-Type');
2909
3111
 
2910
- return duplexAccessed && !hasContentType;
2911
- });
3112
+ return duplexAccessed && !hasContentType;
3113
+ });
2912
3114
 
2913
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
3115
+ const supportsResponseStream =
3116
+ isResponseSupported &&
3117
+ isReadableStreamSupported &&
2914
3118
  test(() => utils$1.isReadableStream(new Response('').body));
2915
3119
 
2916
3120
  const resolvers = {
2917
- stream: supportsResponseStream && ((res) => res.body)
3121
+ stream: supportsResponseStream && ((res) => res.body),
2918
3122
  };
2919
3123
 
2920
- isFetchSupported && ((() => {
2921
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2922
- !resolvers[type] && (resolvers[type] = (res, config) => {
2923
- let method = res && res[type];
3124
+ isFetchSupported &&
3125
+ (() => {
3126
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
3127
+ !resolvers[type] &&
3128
+ (resolvers[type] = (res, config) => {
3129
+ let method = res && res[type];
2924
3130
 
2925
- if (method) {
2926
- return method.call(res);
2927
- }
3131
+ if (method) {
3132
+ return method.call(res);
3133
+ }
2928
3134
 
2929
- throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
3135
+ throw new AxiosError$1(
3136
+ `Response type '${type}' is not supported`,
3137
+ AxiosError$1.ERR_NOT_SUPPORT,
3138
+ config
3139
+ );
3140
+ });
2930
3141
  });
2931
- });
2932
- })());
3142
+ })();
2933
3143
 
2934
3144
  const getBodyLength = async (body) => {
2935
3145
  if (body == null) {
@@ -2980,32 +3190,41 @@ const factory = (env) => {
2980
3190
  responseType,
2981
3191
  headers,
2982
3192
  withCredentials = 'same-origin',
2983
- fetchOptions
3193
+ fetchOptions,
2984
3194
  } = resolveConfig(config);
2985
3195
 
2986
3196
  let _fetch = envFetch || fetch;
2987
3197
 
2988
3198
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2989
3199
 
2990
- let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3200
+ let composedSignal = composeSignals$1(
3201
+ [signal, cancelToken && cancelToken.toAbortSignal()],
3202
+ timeout
3203
+ );
2991
3204
 
2992
3205
  let request = null;
2993
3206
 
2994
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2995
- composedSignal.unsubscribe();
2996
- });
3207
+ const unsubscribe =
3208
+ composedSignal &&
3209
+ composedSignal.unsubscribe &&
3210
+ (() => {
3211
+ composedSignal.unsubscribe();
3212
+ });
2997
3213
 
2998
3214
  let requestContentLength;
2999
3215
 
3000
3216
  try {
3001
3217
  if (
3002
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3218
+ onUploadProgress &&
3219
+ supportsRequestStream &&
3220
+ method !== 'get' &&
3221
+ method !== 'head' &&
3003
3222
  (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3004
3223
  ) {
3005
3224
  let _request = new Request(url, {
3006
3225
  method: 'POST',
3007
3226
  body: data,
3008
- duplex: "half"
3227
+ duplex: 'half',
3009
3228
  });
3010
3229
 
3011
3230
  let contentTypeHeader;
@@ -3030,7 +3249,7 @@ const factory = (env) => {
3030
3249
 
3031
3250
  // Cloudflare Workers throws when credentials are defined
3032
3251
  // see https://github.com/cloudflare/workerd/issues/902
3033
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3252
+ const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
3034
3253
 
3035
3254
  const resolvedOptions = {
3036
3255
  ...fetchOptions,
@@ -3038,29 +3257,35 @@ const factory = (env) => {
3038
3257
  method: method.toUpperCase(),
3039
3258
  headers: headers.normalize().toJSON(),
3040
3259
  body: data,
3041
- duplex: "half",
3042
- credentials: isCredentialsSupported ? withCredentials : undefined
3260
+ duplex: 'half',
3261
+ credentials: isCredentialsSupported ? withCredentials : undefined,
3043
3262
  };
3044
3263
 
3045
3264
  request = isRequestSupported && new Request(url, resolvedOptions);
3046
3265
 
3047
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
3266
+ let response = await (isRequestSupported
3267
+ ? _fetch(request, fetchOptions)
3268
+ : _fetch(url, resolvedOptions));
3048
3269
 
3049
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3270
+ const isStreamResponse =
3271
+ supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3050
3272
 
3051
3273
  if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3052
3274
  const options = {};
3053
3275
 
3054
- ['status', 'statusText', 'headers'].forEach(prop => {
3276
+ ['status', 'statusText', 'headers'].forEach((prop) => {
3055
3277
  options[prop] = response[prop];
3056
3278
  });
3057
3279
 
3058
3280
  const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3059
3281
 
3060
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3061
- responseContentLength,
3062
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
3063
- ) || [];
3282
+ const [onProgress, flush] =
3283
+ (onDownloadProgress &&
3284
+ progressEventDecorator(
3285
+ responseContentLength,
3286
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3287
+ )) ||
3288
+ [];
3064
3289
 
3065
3290
  response = new Response(
3066
3291
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
@@ -3073,7 +3298,10 @@ const factory = (env) => {
3073
3298
 
3074
3299
  responseType = responseType || 'text';
3075
3300
 
3076
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3301
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
3302
+ response,
3303
+ config
3304
+ );
3077
3305
 
3078
3306
  !isStreamResponse && unsubscribe && unsubscribe();
3079
3307
 
@@ -3084,43 +3312,50 @@ const factory = (env) => {
3084
3312
  status: response.status,
3085
3313
  statusText: response.statusText,
3086
3314
  config,
3087
- request
3315
+ request,
3088
3316
  });
3089
- })
3317
+ });
3090
3318
  } catch (err) {
3091
3319
  unsubscribe && unsubscribe();
3092
3320
 
3093
3321
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3094
3322
  throw Object.assign(
3095
- new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, err && err.response),
3323
+ new AxiosError$1(
3324
+ 'Network Error',
3325
+ AxiosError$1.ERR_NETWORK,
3326
+ config,
3327
+ request,
3328
+ err && err.response
3329
+ ),
3096
3330
  {
3097
- cause: err.cause || err
3331
+ cause: err.cause || err,
3098
3332
  }
3099
- )
3333
+ );
3100
3334
  }
3101
3335
 
3102
3336
  throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
3103
3337
  }
3104
- }
3338
+ };
3105
3339
  };
3106
3340
 
3107
3341
  const seedCache = new Map();
3108
3342
 
3109
3343
  const getFetch = (config) => {
3110
3344
  let env = (config && config.env) || {};
3111
- const {fetch, Request, Response} = env;
3112
- const seeds = [
3113
- Request, Response, fetch
3114
- ];
3345
+ const { fetch, Request, Response } = env;
3346
+ const seeds = [Request, Response, fetch];
3115
3347
 
3116
- let len = seeds.length, i = len,
3117
- seed, target, map = seedCache;
3348
+ let len = seeds.length,
3349
+ i = len,
3350
+ seed,
3351
+ target,
3352
+ map = seedCache;
3118
3353
 
3119
3354
  while (i--) {
3120
3355
  seed = seeds[i];
3121
3356
  target = map.get(seed);
3122
3357
 
3123
- target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3358
+ target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
3124
3359
 
3125
3360
  map = target;
3126
3361
  }
@@ -3136,7 +3371,7 @@ getFetch();
3136
3371
  * - `http` for Node.js
3137
3372
  * - `xhr` for browsers
3138
3373
  * - `fetch` for fetch API-based requests
3139
- *
3374
+ *
3140
3375
  * @type {Object<string, Function|Object>}
3141
3376
  */
3142
3377
  const knownAdapters = {
@@ -3144,7 +3379,7 @@ const knownAdapters = {
3144
3379
  xhr: xhrAdapter,
3145
3380
  fetch: {
3146
3381
  get: getFetch,
3147
- }
3382
+ },
3148
3383
  };
3149
3384
 
3150
3385
  // Assign adapter names for easier debugging and identification
@@ -3161,7 +3396,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
3161
3396
 
3162
3397
  /**
3163
3398
  * Render a rejection reason string for unknown or unsupported adapters
3164
- *
3399
+ *
3165
3400
  * @param {string} reason
3166
3401
  * @returns {string}
3167
3402
  */
@@ -3169,17 +3404,18 @@ const renderReason = (reason) => `- ${reason}`;
3169
3404
 
3170
3405
  /**
3171
3406
  * Check if the adapter is resolved (function, null, or false)
3172
- *
3407
+ *
3173
3408
  * @param {Function|null|false} adapter
3174
3409
  * @returns {boolean}
3175
3410
  */
3176
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3411
+ const isResolvedHandle = (adapter) =>
3412
+ utils$1.isFunction(adapter) || adapter === null || adapter === false;
3177
3413
 
3178
3414
  /**
3179
3415
  * Get the first suitable adapter from the provided list.
3180
3416
  * Tries each adapter in order until a supported one is found.
3181
3417
  * Throws an AxiosError if no adapter is suitable.
3182
- *
3418
+ *
3183
3419
  * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
3184
3420
  * @param {Object} config - Axios request configuration
3185
3421
  * @throws {AxiosError} If no suitable adapter is available
@@ -3216,14 +3452,17 @@ function getAdapter(adapters, config) {
3216
3452
  }
3217
3453
 
3218
3454
  if (!adapter) {
3219
- const reasons = Object.entries(rejectedReasons)
3220
- .map(([id, state]) => `adapter ${id} ` +
3455
+ const reasons = Object.entries(rejectedReasons).map(
3456
+ ([id, state]) =>
3457
+ `adapter ${id} ` +
3221
3458
  (state === false ? 'is not supported by the environment' : 'is not available in the build')
3222
- );
3459
+ );
3223
3460
 
3224
- let s = length ?
3225
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3226
- 'as no adapter specified';
3461
+ let s = length
3462
+ ? reasons.length > 1
3463
+ ? 'since :\n' + reasons.map(renderReason).join('\n')
3464
+ : ' ' + renderReason(reasons[0])
3465
+ : 'as no adapter specified';
3227
3466
 
3228
3467
  throw new AxiosError$1(
3229
3468
  `There is no suitable adapter to dispatch the request ` + s,
@@ -3248,7 +3487,7 @@ var adapters = {
3248
3487
  * Exposes all known adapters
3249
3488
  * @type {Object<string, Function|Object>}
3250
3489
  */
3251
- adapters: knownAdapters
3490
+ adapters: knownAdapters,
3252
3491
  };
3253
3492
 
3254
3493
  /**
@@ -3281,10 +3520,7 @@ function dispatchRequest(config) {
3281
3520
  config.headers = AxiosHeaders$1.from(config.headers);
3282
3521
 
3283
3522
  // Transform request data
3284
- config.data = transformData.call(
3285
- config,
3286
- config.transformRequest
3287
- );
3523
+ config.data = transformData.call(config, config.transformRequest);
3288
3524
 
3289
3525
  if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3290
3526
  config.headers.setContentType('application/x-www-form-urlencoded', false);
@@ -3292,39 +3528,38 @@ function dispatchRequest(config) {
3292
3528
 
3293
3529
  const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
3294
3530
 
3295
- return adapter(config).then(function onAdapterResolution(response) {
3296
- throwIfCancellationRequested(config);
3297
-
3298
- // Transform response data
3299
- response.data = transformData.call(
3300
- config,
3301
- config.transformResponse,
3302
- response
3303
- );
3304
-
3305
- response.headers = AxiosHeaders$1.from(response.headers);
3306
-
3307
- return response;
3308
- }, function onAdapterRejection(reason) {
3309
- if (!isCancel(reason)) {
3531
+ return adapter(config).then(
3532
+ function onAdapterResolution(response) {
3310
3533
  throwIfCancellationRequested(config);
3311
3534
 
3312
3535
  // Transform response data
3313
- if (reason && reason.response) {
3314
- reason.response.data = transformData.call(
3315
- config,
3316
- config.transformResponse,
3317
- reason.response
3318
- );
3319
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3536
+ response.data = transformData.call(config, config.transformResponse, response);
3537
+
3538
+ response.headers = AxiosHeaders$1.from(response.headers);
3539
+
3540
+ return response;
3541
+ },
3542
+ function onAdapterRejection(reason) {
3543
+ if (!isCancel(reason)) {
3544
+ throwIfCancellationRequested(config);
3545
+
3546
+ // Transform response data
3547
+ if (reason && reason.response) {
3548
+ reason.response.data = transformData.call(
3549
+ config,
3550
+ config.transformResponse,
3551
+ reason.response
3552
+ );
3553
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3554
+ }
3320
3555
  }
3321
- }
3322
3556
 
3323
- return Promise.reject(reason);
3324
- });
3557
+ return Promise.reject(reason);
3558
+ }
3559
+ );
3325
3560
  }
3326
3561
 
3327
- const VERSION = "1.13.5";
3562
+ const VERSION = "1.13.6";
3328
3563
 
3329
3564
  const validators$1 = {};
3330
3565
 
@@ -3348,7 +3583,15 @@ const deprecatedWarnings = {};
3348
3583
  */
3349
3584
  validators$1.transitional = function transitional(validator, version, message) {
3350
3585
  function formatMessage(opt, desc) {
3351
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3586
+ return (
3587
+ '[Axios v' +
3588
+ VERSION +
3589
+ "] Transitional option '" +
3590
+ opt +
3591
+ "'" +
3592
+ desc +
3593
+ (message ? '. ' + message : '')
3594
+ );
3352
3595
  }
3353
3596
 
3354
3597
  // eslint-disable-next-line func-names
@@ -3380,7 +3623,7 @@ validators$1.spelling = function spelling(correctSpelling) {
3380
3623
  // eslint-disable-next-line no-console
3381
3624
  console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3382
3625
  return true;
3383
- }
3626
+ };
3384
3627
  };
3385
3628
 
3386
3629
  /**
@@ -3406,7 +3649,10 @@ function assertOptions(options, schema, allowUnknown) {
3406
3649
  const value = options[opt];
3407
3650
  const result = value === undefined || validator(value, opt, options);
3408
3651
  if (result !== true) {
3409
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
3652
+ throw new AxiosError$1(
3653
+ 'option ' + opt + ' must be ' + result,
3654
+ AxiosError$1.ERR_BAD_OPTION_VALUE
3655
+ );
3410
3656
  }
3411
3657
  continue;
3412
3658
  }
@@ -3418,7 +3664,7 @@ function assertOptions(options, schema, allowUnknown) {
3418
3664
 
3419
3665
  var validator = {
3420
3666
  assertOptions,
3421
- validators: validators$1
3667
+ validators: validators$1,
3422
3668
  };
3423
3669
 
3424
3670
  const validators = validator.validators;
@@ -3435,7 +3681,7 @@ class Axios {
3435
3681
  this.defaults = instanceConfig || {};
3436
3682
  this.interceptors = {
3437
3683
  request: new InterceptorManager$1(),
3438
- response: new InterceptorManager$1()
3684
+ response: new InterceptorManager$1(),
3439
3685
  };
3440
3686
  }
3441
3687
 
@@ -3486,27 +3732,35 @@ class Axios {
3486
3732
 
3487
3733
  config = mergeConfig(this.defaults, config);
3488
3734
 
3489
- const {transitional, paramsSerializer, headers} = config;
3735
+ const { transitional, paramsSerializer, headers } = config;
3490
3736
 
3491
3737
  if (transitional !== undefined) {
3492
- validator.assertOptions(transitional, {
3493
- silentJSONParsing: validators.transitional(validators.boolean),
3494
- forcedJSONParsing: validators.transitional(validators.boolean),
3495
- clarifyTimeoutError: validators.transitional(validators.boolean),
3496
- legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
3497
- }, false);
3738
+ validator.assertOptions(
3739
+ transitional,
3740
+ {
3741
+ silentJSONParsing: validators.transitional(validators.boolean),
3742
+ forcedJSONParsing: validators.transitional(validators.boolean),
3743
+ clarifyTimeoutError: validators.transitional(validators.boolean),
3744
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
3745
+ },
3746
+ false
3747
+ );
3498
3748
  }
3499
3749
 
3500
3750
  if (paramsSerializer != null) {
3501
3751
  if (utils$1.isFunction(paramsSerializer)) {
3502
3752
  config.paramsSerializer = {
3503
- serialize: paramsSerializer
3753
+ serialize: paramsSerializer,
3504
3754
  };
3505
3755
  } else {
3506
- validator.assertOptions(paramsSerializer, {
3507
- encode: validators.function,
3508
- serialize: validators.function
3509
- }, true);
3756
+ validator.assertOptions(
3757
+ paramsSerializer,
3758
+ {
3759
+ encode: validators.function,
3760
+ serialize: validators.function,
3761
+ },
3762
+ true
3763
+ );
3510
3764
  }
3511
3765
  }
3512
3766
 
@@ -3517,26 +3771,25 @@ class Axios {
3517
3771
  config.allowAbsoluteUrls = true;
3518
3772
  }
3519
3773
 
3520
- validator.assertOptions(config, {
3521
- baseUrl: validators.spelling('baseURL'),
3522
- withXsrfToken: validators.spelling('withXSRFToken')
3523
- }, true);
3774
+ validator.assertOptions(
3775
+ config,
3776
+ {
3777
+ baseUrl: validators.spelling('baseURL'),
3778
+ withXsrfToken: validators.spelling('withXSRFToken'),
3779
+ },
3780
+ true
3781
+ );
3524
3782
 
3525
3783
  // Set config.method
3526
3784
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3527
3785
 
3528
3786
  // Flatten headers
3529
- let contextHeaders = headers && utils$1.merge(
3530
- headers.common,
3531
- headers[config.method]
3532
- );
3787
+ let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
3533
3788
 
3534
- headers && utils$1.forEach(
3535
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3536
- (method) => {
3789
+ headers &&
3790
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
3537
3791
  delete headers[method];
3538
- }
3539
- );
3792
+ });
3540
3793
 
3541
3794
  config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3542
3795
 
@@ -3551,7 +3804,8 @@ class Axios {
3551
3804
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3552
3805
 
3553
3806
  const transitional = config.transitional || transitionalDefaults;
3554
- const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
3807
+ const legacyInterceptorReqResOrdering =
3808
+ transitional && transitional.legacyInterceptorReqResOrdering;
3555
3809
 
3556
3810
  if (legacyInterceptorReqResOrdering) {
3557
3811
  requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
@@ -3625,12 +3879,14 @@ class Axios {
3625
3879
  // Provide aliases for supported request methods
3626
3880
  utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3627
3881
  /*eslint func-names:0*/
3628
- Axios.prototype[method] = function(url, config) {
3629
- return this.request(mergeConfig(config || {}, {
3630
- method,
3631
- url,
3632
- data: (config || {}).data
3633
- }));
3882
+ Axios.prototype[method] = function (url, config) {
3883
+ return this.request(
3884
+ mergeConfig(config || {}, {
3885
+ method,
3886
+ url,
3887
+ data: (config || {}).data,
3888
+ })
3889
+ );
3634
3890
  };
3635
3891
  });
3636
3892
 
@@ -3639,14 +3895,18 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
3639
3895
 
3640
3896
  function generateHTTPMethod(isForm) {
3641
3897
  return function httpMethod(url, data, config) {
3642
- return this.request(mergeConfig(config || {}, {
3643
- method,
3644
- headers: isForm ? {
3645
- 'Content-Type': 'multipart/form-data'
3646
- } : {},
3647
- url,
3648
- data
3649
- }));
3898
+ return this.request(
3899
+ mergeConfig(config || {}, {
3900
+ method,
3901
+ headers: isForm
3902
+ ? {
3903
+ 'Content-Type': 'multipart/form-data',
3904
+ }
3905
+ : {},
3906
+ url,
3907
+ data,
3908
+ })
3909
+ );
3650
3910
  };
3651
3911
  }
3652
3912
 
@@ -3679,7 +3939,7 @@ class CancelToken {
3679
3939
  const token = this;
3680
3940
 
3681
3941
  // eslint-disable-next-line func-names
3682
- this.promise.then(cancel => {
3942
+ this.promise.then((cancel) => {
3683
3943
  if (!token._listeners) return;
3684
3944
 
3685
3945
  let i = token._listeners.length;
@@ -3691,10 +3951,10 @@ class CancelToken {
3691
3951
  });
3692
3952
 
3693
3953
  // eslint-disable-next-line func-names
3694
- this.promise.then = onfulfilled => {
3954
+ this.promise.then = (onfulfilled) => {
3695
3955
  let _resolve;
3696
3956
  // eslint-disable-next-line func-names
3697
- const promise = new Promise(resolve => {
3957
+ const promise = new Promise((resolve) => {
3698
3958
  token.subscribe(resolve);
3699
3959
  _resolve = resolve;
3700
3960
  }).then(onfulfilled);
@@ -3782,7 +4042,7 @@ class CancelToken {
3782
4042
  });
3783
4043
  return {
3784
4044
  token,
3785
- cancel
4045
+ cancel,
3786
4046
  };
3787
4047
  }
3788
4048
  }
@@ -3824,7 +4084,7 @@ function spread(callback) {
3824
4084
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3825
4085
  */
3826
4086
  function isAxiosError(payload) {
3827
- return utils$1.isObject(payload) && (payload.isAxiosError === true);
4087
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
3828
4088
  }
3829
4089
 
3830
4090
  const HttpStatusCode = {
@@ -3917,10 +4177,10 @@ function createInstance(defaultConfig) {
3917
4177
  const instance = bind(Axios$1.prototype.request, context);
3918
4178
 
3919
4179
  // Copy axios.prototype to instance
3920
- utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
4180
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
3921
4181
 
3922
4182
  // Copy context to instance
3923
- utils$1.extend(instance, context, null, {allOwnKeys: true});
4183
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
3924
4184
 
3925
4185
  // Factory for creating new instances
3926
4186
  instance.create = function create(instanceConfig) {
@@ -3964,7 +4224,7 @@ axios.mergeConfig = mergeConfig;
3964
4224
 
3965
4225
  axios.AxiosHeaders = AxiosHeaders$1;
3966
4226
 
3967
- axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4227
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3968
4228
 
3969
4229
  axios.getAdapter = adapters.getAdapter;
3970
4230
 
@@ -3976,7 +4236,7 @@ axios.default = axios;
3976
4236
  var axios$1 = axios;
3977
4237
 
3978
4238
  var name$1 = "@tryghost/content-api";
3979
- var version = "1.12.4";
4239
+ var version = "1.12.6";
3980
4240
  var repository = {
3981
4241
  type: "git",
3982
4242
  url: "git+https://github.com/TryGhost/SDK.git",
@@ -4018,19 +4278,19 @@ var devDependencies = {
4018
4278
  "@rollup/plugin-terser": "0.4.4",
4019
4279
  c8: "11.0.0",
4020
4280
  "core-js": "3.48.0",
4021
- "eslint-plugin-ghost": "3.4.4",
4281
+ "eslint-plugin-ghost": "3.5.0",
4022
4282
  mocha: "11.7.5",
4023
4283
  rollup: "2.80.0",
4024
4284
  "rollup-plugin-commonjs": "10.1.0",
4025
4285
  "rollup-plugin-polyfill-node": "0.13.0",
4026
4286
  "rollup-plugin-replace": "2.2.0",
4027
4287
  should: "13.2.3",
4028
- sinon: "21.0.1"
4288
+ sinon: "21.0.2"
4029
4289
  };
4030
4290
  var dependencies = {
4031
- axios: "1.13.5"
4291
+ axios: "1.13.6"
4032
4292
  };
4033
- var gitHead = "2c937c80e98d9bad4458e1c2e9d6f6b138bd308e";
4293
+ var gitHead = "9cc8428821b292029029019e1af6fb24a75709ad";
4034
4294
  var packageInfo = {
4035
4295
  name: name$1,
4036
4296
  version: version,