source: imaps-frontend/node_modules/axios/dist/node/axios.cjs@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 125.2 KB
Line 
1// Axios v1.7.8 Copyright (c) 2024 Matt Zabriskie and contributors
2'use strict';
3
4const FormData$1 = require('form-data');
5const url = require('url');
6const proxyFromEnv = require('proxy-from-env');
7const http = require('http');
8const https = require('https');
9const util = require('util');
10const followRedirects = require('follow-redirects');
11const zlib = require('zlib');
12const stream = require('stream');
13const events = require('events');
14
15function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
17const FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
18const url__default = /*#__PURE__*/_interopDefaultLegacy(url);
19const proxyFromEnv__default = /*#__PURE__*/_interopDefaultLegacy(proxyFromEnv);
20const http__default = /*#__PURE__*/_interopDefaultLegacy(http);
21const https__default = /*#__PURE__*/_interopDefaultLegacy(https);
22const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
23const followRedirects__default = /*#__PURE__*/_interopDefaultLegacy(followRedirects);
24const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
25const stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
26
27function bind(fn, thisArg) {
28 return function wrap() {
29 return fn.apply(thisArg, arguments);
30 };
31}
32
33// utils is a library of generic helper functions non-specific to axios
34
35const {toString} = Object.prototype;
36const {getPrototypeOf} = Object;
37
38const kindOf = (cache => thing => {
39 const str = toString.call(thing);
40 return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
41})(Object.create(null));
42
43const kindOfTest = (type) => {
44 type = type.toLowerCase();
45 return (thing) => kindOf(thing) === type
46};
47
48const typeOfTest = type => thing => typeof thing === type;
49
50/**
51 * Determine if a value is an Array
52 *
53 * @param {Object} val The value to test
54 *
55 * @returns {boolean} True if value is an Array, otherwise false
56 */
57const {isArray} = Array;
58
59/**
60 * Determine if a value is undefined
61 *
62 * @param {*} val The value to test
63 *
64 * @returns {boolean} True if the value is undefined, otherwise false
65 */
66const isUndefined = typeOfTest('undefined');
67
68/**
69 * Determine if a value is a Buffer
70 *
71 * @param {*} val The value to test
72 *
73 * @returns {boolean} True if value is a Buffer, otherwise false
74 */
75function isBuffer(val) {
76 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
77 && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
78}
79
80/**
81 * Determine if a value is an ArrayBuffer
82 *
83 * @param {*} val The value to test
84 *
85 * @returns {boolean} True if value is an ArrayBuffer, otherwise false
86 */
87const isArrayBuffer = kindOfTest('ArrayBuffer');
88
89
90/**
91 * Determine if a value is a view on an ArrayBuffer
92 *
93 * @param {*} val The value to test
94 *
95 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
96 */
97function isArrayBufferView(val) {
98 let result;
99 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
100 result = ArrayBuffer.isView(val);
101 } else {
102 result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
103 }
104 return result;
105}
106
107/**
108 * Determine if a value is a String
109 *
110 * @param {*} val The value to test
111 *
112 * @returns {boolean} True if value is a String, otherwise false
113 */
114const isString = typeOfTest('string');
115
116/**
117 * Determine if a value is a Function
118 *
119 * @param {*} val The value to test
120 * @returns {boolean} True if value is a Function, otherwise false
121 */
122const isFunction = typeOfTest('function');
123
124/**
125 * Determine if a value is a Number
126 *
127 * @param {*} val The value to test
128 *
129 * @returns {boolean} True if value is a Number, otherwise false
130 */
131const isNumber = typeOfTest('number');
132
133/**
134 * Determine if a value is an Object
135 *
136 * @param {*} thing The value to test
137 *
138 * @returns {boolean} True if value is an Object, otherwise false
139 */
140const isObject = (thing) => thing !== null && typeof thing === 'object';
141
142/**
143 * Determine if a value is a Boolean
144 *
145 * @param {*} thing The value to test
146 * @returns {boolean} True if value is a Boolean, otherwise false
147 */
148const isBoolean = thing => thing === true || thing === false;
149
150/**
151 * Determine if a value is a plain Object
152 *
153 * @param {*} val The value to test
154 *
155 * @returns {boolean} True if value is a plain Object, otherwise false
156 */
157const isPlainObject = (val) => {
158 if (kindOf(val) !== 'object') {
159 return false;
160 }
161
162 const prototype = getPrototypeOf(val);
163 return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
164};
165
166/**
167 * Determine if a value is a Date
168 *
169 * @param {*} val The value to test
170 *
171 * @returns {boolean} True if value is a Date, otherwise false
172 */
173const isDate = kindOfTest('Date');
174
175/**
176 * Determine if a value is a File
177 *
178 * @param {*} val The value to test
179 *
180 * @returns {boolean} True if value is a File, otherwise false
181 */
182const isFile = kindOfTest('File');
183
184/**
185 * Determine if a value is a Blob
186 *
187 * @param {*} val The value to test
188 *
189 * @returns {boolean} True if value is a Blob, otherwise false
190 */
191const isBlob = kindOfTest('Blob');
192
193/**
194 * Determine if a value is a FileList
195 *
196 * @param {*} val The value to test
197 *
198 * @returns {boolean} True if value is a File, otherwise false
199 */
200const isFileList = kindOfTest('FileList');
201
202/**
203 * Determine if a value is a Stream
204 *
205 * @param {*} val The value to test
206 *
207 * @returns {boolean} True if value is a Stream, otherwise false
208 */
209const isStream = (val) => isObject(val) && isFunction(val.pipe);
210
211/**
212 * Determine if a value is a FormData
213 *
214 * @param {*} thing The value to test
215 *
216 * @returns {boolean} True if value is an FormData, otherwise false
217 */
218const isFormData = (thing) => {
219 let kind;
220 return thing && (
221 (typeof FormData === 'function' && thing instanceof FormData) || (
222 isFunction(thing.append) && (
223 (kind = kindOf(thing)) === 'formdata' ||
224 // detect form-data instance
225 (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
226 )
227 )
228 )
229};
230
231/**
232 * Determine if a value is a URLSearchParams object
233 *
234 * @param {*} val The value to test
235 *
236 * @returns {boolean} True if value is a URLSearchParams object, otherwise false
237 */
238const isURLSearchParams = kindOfTest('URLSearchParams');
239
240const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
241
242/**
243 * Trim excess whitespace off the beginning and end of a string
244 *
245 * @param {String} str The String to trim
246 *
247 * @returns {String} The String freed of excess whitespace
248 */
249const trim = (str) => str.trim ?
250 str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
251
252/**
253 * Iterate over an Array or an Object invoking a function for each item.
254 *
255 * If `obj` is an Array callback will be called passing
256 * the value, index, and complete array for each item.
257 *
258 * If 'obj' is an Object callback will be called passing
259 * the value, key, and complete object for each property.
260 *
261 * @param {Object|Array} obj The object to iterate
262 * @param {Function} fn The callback to invoke for each item
263 *
264 * @param {Boolean} [allOwnKeys = false]
265 * @returns {any}
266 */
267function forEach(obj, fn, {allOwnKeys = false} = {}) {
268 // Don't bother if no value provided
269 if (obj === null || typeof obj === 'undefined') {
270 return;
271 }
272
273 let i;
274 let l;
275
276 // Force an array if not already something iterable
277 if (typeof obj !== 'object') {
278 /*eslint no-param-reassign:0*/
279 obj = [obj];
280 }
281
282 if (isArray(obj)) {
283 // Iterate over array values
284 for (i = 0, l = obj.length; i < l; i++) {
285 fn.call(null, obj[i], i, obj);
286 }
287 } else {
288 // Iterate over object keys
289 const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
290 const len = keys.length;
291 let key;
292
293 for (i = 0; i < len; i++) {
294 key = keys[i];
295 fn.call(null, obj[key], key, obj);
296 }
297 }
298}
299
300function findKey(obj, key) {
301 key = key.toLowerCase();
302 const keys = Object.keys(obj);
303 let i = keys.length;
304 let _key;
305 while (i-- > 0) {
306 _key = keys[i];
307 if (key === _key.toLowerCase()) {
308 return _key;
309 }
310 }
311 return null;
312}
313
314const _global = (() => {
315 /*eslint no-undef:0*/
316 if (typeof globalThis !== "undefined") return globalThis;
317 return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
318})();
319
320const isContextDefined = (context) => !isUndefined(context) && context !== _global;
321
322/**
323 * Accepts varargs expecting each argument to be an object, then
324 * immutably merges the properties of each object and returns result.
325 *
326 * When multiple objects contain the same key the later object in
327 * the arguments list will take precedence.
328 *
329 * Example:
330 *
331 * ```js
332 * var result = merge({foo: 123}, {foo: 456});
333 * console.log(result.foo); // outputs 456
334 * ```
335 *
336 * @param {Object} obj1 Object to merge
337 *
338 * @returns {Object} Result of all merge properties
339 */
340function merge(/* obj1, obj2, obj3, ... */) {
341 const {caseless} = isContextDefined(this) && this || {};
342 const result = {};
343 const assignValue = (val, key) => {
344 const targetKey = caseless && findKey(result, key) || key;
345 if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
346 result[targetKey] = merge(result[targetKey], val);
347 } else if (isPlainObject(val)) {
348 result[targetKey] = merge({}, val);
349 } else if (isArray(val)) {
350 result[targetKey] = val.slice();
351 } else {
352 result[targetKey] = val;
353 }
354 };
355
356 for (let i = 0, l = arguments.length; i < l; i++) {
357 arguments[i] && forEach(arguments[i], assignValue);
358 }
359 return result;
360}
361
362/**
363 * Extends object a by mutably adding to it the properties of object b.
364 *
365 * @param {Object} a The object to be extended
366 * @param {Object} b The object to copy properties from
367 * @param {Object} thisArg The object to bind function to
368 *
369 * @param {Boolean} [allOwnKeys]
370 * @returns {Object} The resulting value of object a
371 */
372const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
373 forEach(b, (val, key) => {
374 if (thisArg && isFunction(val)) {
375 a[key] = bind(val, thisArg);
376 } else {
377 a[key] = val;
378 }
379 }, {allOwnKeys});
380 return a;
381};
382
383/**
384 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
385 *
386 * @param {string} content with BOM
387 *
388 * @returns {string} content value without BOM
389 */
390const stripBOM = (content) => {
391 if (content.charCodeAt(0) === 0xFEFF) {
392 content = content.slice(1);
393 }
394 return content;
395};
396
397/**
398 * Inherit the prototype methods from one constructor into another
399 * @param {function} constructor
400 * @param {function} superConstructor
401 * @param {object} [props]
402 * @param {object} [descriptors]
403 *
404 * @returns {void}
405 */
406const inherits = (constructor, superConstructor, props, descriptors) => {
407 constructor.prototype = Object.create(superConstructor.prototype, descriptors);
408 constructor.prototype.constructor = constructor;
409 Object.defineProperty(constructor, 'super', {
410 value: superConstructor.prototype
411 });
412 props && Object.assign(constructor.prototype, props);
413};
414
415/**
416 * Resolve object with deep prototype chain to a flat object
417 * @param {Object} sourceObj source object
418 * @param {Object} [destObj]
419 * @param {Function|Boolean} [filter]
420 * @param {Function} [propFilter]
421 *
422 * @returns {Object}
423 */
424const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
425 let props;
426 let i;
427 let prop;
428 const merged = {};
429
430 destObj = destObj || {};
431 // eslint-disable-next-line no-eq-null,eqeqeq
432 if (sourceObj == null) return destObj;
433
434 do {
435 props = Object.getOwnPropertyNames(sourceObj);
436 i = props.length;
437 while (i-- > 0) {
438 prop = props[i];
439 if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
440 destObj[prop] = sourceObj[prop];
441 merged[prop] = true;
442 }
443 }
444 sourceObj = filter !== false && getPrototypeOf(sourceObj);
445 } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
446
447 return destObj;
448};
449
450/**
451 * Determines whether a string ends with the characters of a specified string
452 *
453 * @param {String} str
454 * @param {String} searchString
455 * @param {Number} [position= 0]
456 *
457 * @returns {boolean}
458 */
459const endsWith = (str, searchString, position) => {
460 str = String(str);
461 if (position === undefined || position > str.length) {
462 position = str.length;
463 }
464 position -= searchString.length;
465 const lastIndex = str.indexOf(searchString, position);
466 return lastIndex !== -1 && lastIndex === position;
467};
468
469
470/**
471 * Returns new array from array like object or null if failed
472 *
473 * @param {*} [thing]
474 *
475 * @returns {?Array}
476 */
477const toArray = (thing) => {
478 if (!thing) return null;
479 if (isArray(thing)) return thing;
480 let i = thing.length;
481 if (!isNumber(i)) return null;
482 const arr = new Array(i);
483 while (i-- > 0) {
484 arr[i] = thing[i];
485 }
486 return arr;
487};
488
489/**
490 * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
491 * thing passed in is an instance of Uint8Array
492 *
493 * @param {TypedArray}
494 *
495 * @returns {Array}
496 */
497// eslint-disable-next-line func-names
498const isTypedArray = (TypedArray => {
499 // eslint-disable-next-line func-names
500 return thing => {
501 return TypedArray && thing instanceof TypedArray;
502 };
503})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
504
505/**
506 * For each entry in the object, call the function with the key and value.
507 *
508 * @param {Object<any, any>} obj - The object to iterate over.
509 * @param {Function} fn - The function to call for each entry.
510 *
511 * @returns {void}
512 */
513const forEachEntry = (obj, fn) => {
514 const generator = obj && obj[Symbol.iterator];
515
516 const iterator = generator.call(obj);
517
518 let result;
519
520 while ((result = iterator.next()) && !result.done) {
521 const pair = result.value;
522 fn.call(obj, pair[0], pair[1]);
523 }
524};
525
526/**
527 * It takes a regular expression and a string, and returns an array of all the matches
528 *
529 * @param {string} regExp - The regular expression to match against.
530 * @param {string} str - The string to search.
531 *
532 * @returns {Array<boolean>}
533 */
534const matchAll = (regExp, str) => {
535 let matches;
536 const arr = [];
537
538 while ((matches = regExp.exec(str)) !== null) {
539 arr.push(matches);
540 }
541
542 return arr;
543};
544
545/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
546const isHTMLForm = kindOfTest('HTMLFormElement');
547
548const toCamelCase = str => {
549 return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
550 function replacer(m, p1, p2) {
551 return p1.toUpperCase() + p2;
552 }
553 );
554};
555
556/* Creating a function that will check if an object has a property. */
557const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
558
559/**
560 * Determine if a value is a RegExp object
561 *
562 * @param {*} val The value to test
563 *
564 * @returns {boolean} True if value is a RegExp object, otherwise false
565 */
566const isRegExp = kindOfTest('RegExp');
567
568const reduceDescriptors = (obj, reducer) => {
569 const descriptors = Object.getOwnPropertyDescriptors(obj);
570 const reducedDescriptors = {};
571
572 forEach(descriptors, (descriptor, name) => {
573 let ret;
574 if ((ret = reducer(descriptor, name, obj)) !== false) {
575 reducedDescriptors[name] = ret || descriptor;
576 }
577 });
578
579 Object.defineProperties(obj, reducedDescriptors);
580};
581
582/**
583 * Makes all methods read-only
584 * @param {Object} obj
585 */
586
587const freezeMethods = (obj) => {
588 reduceDescriptors(obj, (descriptor, name) => {
589 // skip restricted props in strict mode
590 if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
591 return false;
592 }
593
594 const value = obj[name];
595
596 if (!isFunction(value)) return;
597
598 descriptor.enumerable = false;
599
600 if ('writable' in descriptor) {
601 descriptor.writable = false;
602 return;
603 }
604
605 if (!descriptor.set) {
606 descriptor.set = () => {
607 throw Error('Can not rewrite read-only method \'' + name + '\'');
608 };
609 }
610 });
611};
612
613const toObjectSet = (arrayOrString, delimiter) => {
614 const obj = {};
615
616 const define = (arr) => {
617 arr.forEach(value => {
618 obj[value] = true;
619 });
620 };
621
622 isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
623
624 return obj;
625};
626
627const noop = () => {};
628
629const toFiniteNumber = (value, defaultValue) => {
630 return value != null && Number.isFinite(value = +value) ? value : defaultValue;
631};
632
633const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
634
635const DIGIT = '0123456789';
636
637const ALPHABET = {
638 DIGIT,
639 ALPHA,
640 ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
641};
642
643const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
644 let str = '';
645 const {length} = alphabet;
646 while (size--) {
647 str += alphabet[Math.random() * length|0];
648 }
649
650 return str;
651};
652
653/**
654 * If the thing is a FormData object, return true, otherwise return false.
655 *
656 * @param {unknown} thing - The thing to check.
657 *
658 * @returns {boolean}
659 */
660function isSpecCompliantForm(thing) {
661 return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
662}
663
664const toJSONObject = (obj) => {
665 const stack = new Array(10);
666
667 const visit = (source, i) => {
668
669 if (isObject(source)) {
670 if (stack.indexOf(source) >= 0) {
671 return;
672 }
673
674 if(!('toJSON' in source)) {
675 stack[i] = source;
676 const target = isArray(source) ? [] : {};
677
678 forEach(source, (value, key) => {
679 const reducedValue = visit(value, i + 1);
680 !isUndefined(reducedValue) && (target[key] = reducedValue);
681 });
682
683 stack[i] = undefined;
684
685 return target;
686 }
687 }
688
689 return source;
690 };
691
692 return visit(obj, 0);
693};
694
695const isAsyncFn = kindOfTest('AsyncFunction');
696
697const isThenable = (thing) =>
698 thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
699
700// original code
701// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
702
703const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
704 if (setImmediateSupported) {
705 return setImmediate;
706 }
707
708 return postMessageSupported ? ((token, callbacks) => {
709 _global.addEventListener("message", ({source, data}) => {
710 if (source === _global && data === token) {
711 callbacks.length && callbacks.shift()();
712 }
713 }, false);
714
715 return (cb) => {
716 callbacks.push(cb);
717 _global.postMessage(token, "*");
718 }
719 })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
720})(
721 typeof setImmediate === 'function',
722 isFunction(_global.postMessage)
723);
724
725const asap = typeof queueMicrotask !== 'undefined' ?
726 queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
727
728// *********************
729
730const utils$1 = {
731 isArray,
732 isArrayBuffer,
733 isBuffer,
734 isFormData,
735 isArrayBufferView,
736 isString,
737 isNumber,
738 isBoolean,
739 isObject,
740 isPlainObject,
741 isReadableStream,
742 isRequest,
743 isResponse,
744 isHeaders,
745 isUndefined,
746 isDate,
747 isFile,
748 isBlob,
749 isRegExp,
750 isFunction,
751 isStream,
752 isURLSearchParams,
753 isTypedArray,
754 isFileList,
755 forEach,
756 merge,
757 extend,
758 trim,
759 stripBOM,
760 inherits,
761 toFlatObject,
762 kindOf,
763 kindOfTest,
764 endsWith,
765 toArray,
766 forEachEntry,
767 matchAll,
768 isHTMLForm,
769 hasOwnProperty,
770 hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
771 reduceDescriptors,
772 freezeMethods,
773 toObjectSet,
774 toCamelCase,
775 noop,
776 toFiniteNumber,
777 findKey,
778 global: _global,
779 isContextDefined,
780 ALPHABET,
781 generateString,
782 isSpecCompliantForm,
783 toJSONObject,
784 isAsyncFn,
785 isThenable,
786 setImmediate: _setImmediate,
787 asap
788};
789
790/**
791 * Create an Error with the specified message, config, error code, request and response.
792 *
793 * @param {string} message The error message.
794 * @param {string} [code] The error code (for example, 'ECONNABORTED').
795 * @param {Object} [config] The config.
796 * @param {Object} [request] The request.
797 * @param {Object} [response] The response.
798 *
799 * @returns {Error} The created error.
800 */
801function AxiosError(message, code, config, request, response) {
802 Error.call(this);
803
804 if (Error.captureStackTrace) {
805 Error.captureStackTrace(this, this.constructor);
806 } else {
807 this.stack = (new Error()).stack;
808 }
809
810 this.message = message;
811 this.name = 'AxiosError';
812 code && (this.code = code);
813 config && (this.config = config);
814 request && (this.request = request);
815 if (response) {
816 this.response = response;
817 this.status = response.status ? response.status : null;
818 }
819}
820
821utils$1.inherits(AxiosError, Error, {
822 toJSON: function toJSON() {
823 return {
824 // Standard
825 message: this.message,
826 name: this.name,
827 // Microsoft
828 description: this.description,
829 number: this.number,
830 // Mozilla
831 fileName: this.fileName,
832 lineNumber: this.lineNumber,
833 columnNumber: this.columnNumber,
834 stack: this.stack,
835 // Axios
836 config: utils$1.toJSONObject(this.config),
837 code: this.code,
838 status: this.status
839 };
840 }
841});
842
843const prototype$1 = AxiosError.prototype;
844const descriptors = {};
845
846[
847 'ERR_BAD_OPTION_VALUE',
848 'ERR_BAD_OPTION',
849 'ECONNABORTED',
850 'ETIMEDOUT',
851 'ERR_NETWORK',
852 'ERR_FR_TOO_MANY_REDIRECTS',
853 'ERR_DEPRECATED',
854 'ERR_BAD_RESPONSE',
855 'ERR_BAD_REQUEST',
856 'ERR_CANCELED',
857 'ERR_NOT_SUPPORT',
858 'ERR_INVALID_URL'
859// eslint-disable-next-line func-names
860].forEach(code => {
861 descriptors[code] = {value: code};
862});
863
864Object.defineProperties(AxiosError, descriptors);
865Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
866
867// eslint-disable-next-line func-names
868AxiosError.from = (error, code, config, request, response, customProps) => {
869 const axiosError = Object.create(prototype$1);
870
871 utils$1.toFlatObject(error, axiosError, function filter(obj) {
872 return obj !== Error.prototype;
873 }, prop => {
874 return prop !== 'isAxiosError';
875 });
876
877 AxiosError.call(axiosError, error.message, code, config, request, response);
878
879 axiosError.cause = error;
880
881 axiosError.name = error.name;
882
883 customProps && Object.assign(axiosError, customProps);
884
885 return axiosError;
886};
887
888/**
889 * Determines if the given thing is a array or js object.
890 *
891 * @param {string} thing - The object or array to be visited.
892 *
893 * @returns {boolean}
894 */
895function isVisitable(thing) {
896 return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
897}
898
899/**
900 * It removes the brackets from the end of a string
901 *
902 * @param {string} key - The key of the parameter.
903 *
904 * @returns {string} the key without the brackets.
905 */
906function removeBrackets(key) {
907 return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
908}
909
910/**
911 * It takes a path, a key, and a boolean, and returns a string
912 *
913 * @param {string} path - The path to the current key.
914 * @param {string} key - The key of the current object being iterated over.
915 * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
916 *
917 * @returns {string} The path to the current key.
918 */
919function renderKey(path, key, dots) {
920 if (!path) return key;
921 return path.concat(key).map(function each(token, i) {
922 // eslint-disable-next-line no-param-reassign
923 token = removeBrackets(token);
924 return !dots && i ? '[' + token + ']' : token;
925 }).join(dots ? '.' : '');
926}
927
928/**
929 * If the array is an array and none of its elements are visitable, then it's a flat array.
930 *
931 * @param {Array<any>} arr - The array to check
932 *
933 * @returns {boolean}
934 */
935function isFlatArray(arr) {
936 return utils$1.isArray(arr) && !arr.some(isVisitable);
937}
938
939const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
940 return /^is[A-Z]/.test(prop);
941});
942
943/**
944 * Convert a data object to FormData
945 *
946 * @param {Object} obj
947 * @param {?Object} [formData]
948 * @param {?Object} [options]
949 * @param {Function} [options.visitor]
950 * @param {Boolean} [options.metaTokens = true]
951 * @param {Boolean} [options.dots = false]
952 * @param {?Boolean} [options.indexes = false]
953 *
954 * @returns {Object}
955 **/
956
957/**
958 * It converts an object into a FormData object
959 *
960 * @param {Object<any, any>} obj - The object to convert to form data.
961 * @param {string} formData - The FormData object to append to.
962 * @param {Object<string, any>} options
963 *
964 * @returns
965 */
966function toFormData(obj, formData, options) {
967 if (!utils$1.isObject(obj)) {
968 throw new TypeError('target must be an object');
969 }
970
971 // eslint-disable-next-line no-param-reassign
972 formData = formData || new (FormData__default["default"] || FormData)();
973
974 // eslint-disable-next-line no-param-reassign
975 options = utils$1.toFlatObject(options, {
976 metaTokens: true,
977 dots: false,
978 indexes: false
979 }, false, function defined(option, source) {
980 // eslint-disable-next-line no-eq-null,eqeqeq
981 return !utils$1.isUndefined(source[option]);
982 });
983
984 const metaTokens = options.metaTokens;
985 // eslint-disable-next-line no-use-before-define
986 const visitor = options.visitor || defaultVisitor;
987 const dots = options.dots;
988 const indexes = options.indexes;
989 const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
990 const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
991
992 if (!utils$1.isFunction(visitor)) {
993 throw new TypeError('visitor must be a function');
994 }
995
996 function convertValue(value) {
997 if (value === null) return '';
998
999 if (utils$1.isDate(value)) {
1000 return value.toISOString();
1001 }
1002
1003 if (!useBlob && utils$1.isBlob(value)) {
1004 throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1005 }
1006
1007 if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1008 return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1009 }
1010
1011 return value;
1012 }
1013
1014 /**
1015 * Default visitor.
1016 *
1017 * @param {*} value
1018 * @param {String|Number} key
1019 * @param {Array<String|Number>} path
1020 * @this {FormData}
1021 *
1022 * @returns {boolean} return true to visit the each prop of the value recursively
1023 */
1024 function defaultVisitor(value, key, path) {
1025 let arr = value;
1026
1027 if (value && !path && typeof value === 'object') {
1028 if (utils$1.endsWith(key, '{}')) {
1029 // eslint-disable-next-line no-param-reassign
1030 key = metaTokens ? key : key.slice(0, -2);
1031 // eslint-disable-next-line no-param-reassign
1032 value = JSON.stringify(value);
1033 } else if (
1034 (utils$1.isArray(value) && isFlatArray(value)) ||
1035 ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1036 )) {
1037 // eslint-disable-next-line no-param-reassign
1038 key = removeBrackets(key);
1039
1040 arr.forEach(function each(el, index) {
1041 !(utils$1.isUndefined(el) || el === null) && formData.append(
1042 // eslint-disable-next-line no-nested-ternary
1043 indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1044 convertValue(el)
1045 );
1046 });
1047 return false;
1048 }
1049 }
1050
1051 if (isVisitable(value)) {
1052 return true;
1053 }
1054
1055 formData.append(renderKey(path, key, dots), convertValue(value));
1056
1057 return false;
1058 }
1059
1060 const stack = [];
1061
1062 const exposedHelpers = Object.assign(predicates, {
1063 defaultVisitor,
1064 convertValue,
1065 isVisitable
1066 });
1067
1068 function build(value, path) {
1069 if (utils$1.isUndefined(value)) return;
1070
1071 if (stack.indexOf(value) !== -1) {
1072 throw Error('Circular reference detected in ' + path.join('.'));
1073 }
1074
1075 stack.push(value);
1076
1077 utils$1.forEach(value, function each(el, key) {
1078 const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1079 formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1080 );
1081
1082 if (result === true) {
1083 build(el, path ? path.concat(key) : [key]);
1084 }
1085 });
1086
1087 stack.pop();
1088 }
1089
1090 if (!utils$1.isObject(obj)) {
1091 throw new TypeError('data must be an object');
1092 }
1093
1094 build(obj);
1095
1096 return formData;
1097}
1098
1099/**
1100 * It encodes a string by replacing all characters that are not in the unreserved set with
1101 * their percent-encoded equivalents
1102 *
1103 * @param {string} str - The string to encode.
1104 *
1105 * @returns {string} The encoded string.
1106 */
1107function encode$1(str) {
1108 const charMap = {
1109 '!': '%21',
1110 "'": '%27',
1111 '(': '%28',
1112 ')': '%29',
1113 '~': '%7E',
1114 '%20': '+',
1115 '%00': '\x00'
1116 };
1117 return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1118 return charMap[match];
1119 });
1120}
1121
1122/**
1123 * It takes a params object and converts it to a FormData object
1124 *
1125 * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1126 * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1127 *
1128 * @returns {void}
1129 */
1130function AxiosURLSearchParams(params, options) {
1131 this._pairs = [];
1132
1133 params && toFormData(params, this, options);
1134}
1135
1136const prototype = AxiosURLSearchParams.prototype;
1137
1138prototype.append = function append(name, value) {
1139 this._pairs.push([name, value]);
1140};
1141
1142prototype.toString = function toString(encoder) {
1143 const _encode = encoder ? function(value) {
1144 return encoder.call(this, value, encode$1);
1145 } : encode$1;
1146
1147 return this._pairs.map(function each(pair) {
1148 return _encode(pair[0]) + '=' + _encode(pair[1]);
1149 }, '').join('&');
1150};
1151
1152/**
1153 * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1154 * URI encoded counterparts
1155 *
1156 * @param {string} val The value to be encoded.
1157 *
1158 * @returns {string} The encoded value.
1159 */
1160function encode(val) {
1161 return encodeURIComponent(val).
1162 replace(/%3A/gi, ':').
1163 replace(/%24/g, '$').
1164 replace(/%2C/gi, ',').
1165 replace(/%20/g, '+').
1166 replace(/%5B/gi, '[').
1167 replace(/%5D/gi, ']');
1168}
1169
1170/**
1171 * Build a URL by appending params to the end
1172 *
1173 * @param {string} url The base of the url (e.g., http://www.google.com)
1174 * @param {object} [params] The params to be appended
1175 * @param {?(object|Function)} options
1176 *
1177 * @returns {string} The formatted url
1178 */
1179function buildURL(url, params, options) {
1180 /*eslint no-param-reassign:0*/
1181 if (!params) {
1182 return url;
1183 }
1184
1185 const _encode = options && options.encode || encode;
1186
1187 if (utils$1.isFunction(options)) {
1188 options = {
1189 serialize: options
1190 };
1191 }
1192
1193 const serializeFn = options && options.serialize;
1194
1195 let serializedParams;
1196
1197 if (serializeFn) {
1198 serializedParams = serializeFn(params, options);
1199 } else {
1200 serializedParams = utils$1.isURLSearchParams(params) ?
1201 params.toString() :
1202 new AxiosURLSearchParams(params, options).toString(_encode);
1203 }
1204
1205 if (serializedParams) {
1206 const hashmarkIndex = url.indexOf("#");
1207
1208 if (hashmarkIndex !== -1) {
1209 url = url.slice(0, hashmarkIndex);
1210 }
1211 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1212 }
1213
1214 return url;
1215}
1216
1217class InterceptorManager {
1218 constructor() {
1219 this.handlers = [];
1220 }
1221
1222 /**
1223 * Add a new interceptor to the stack
1224 *
1225 * @param {Function} fulfilled The function to handle `then` for a `Promise`
1226 * @param {Function} rejected The function to handle `reject` for a `Promise`
1227 *
1228 * @return {Number} An ID used to remove interceptor later
1229 */
1230 use(fulfilled, rejected, options) {
1231 this.handlers.push({
1232 fulfilled,
1233 rejected,
1234 synchronous: options ? options.synchronous : false,
1235 runWhen: options ? options.runWhen : null
1236 });
1237 return this.handlers.length - 1;
1238 }
1239
1240 /**
1241 * Remove an interceptor from the stack
1242 *
1243 * @param {Number} id The ID that was returned by `use`
1244 *
1245 * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1246 */
1247 eject(id) {
1248 if (this.handlers[id]) {
1249 this.handlers[id] = null;
1250 }
1251 }
1252
1253 /**
1254 * Clear all interceptors from the stack
1255 *
1256 * @returns {void}
1257 */
1258 clear() {
1259 if (this.handlers) {
1260 this.handlers = [];
1261 }
1262 }
1263
1264 /**
1265 * Iterate over all the registered interceptors
1266 *
1267 * This method is particularly useful for skipping over any
1268 * interceptors that may have become `null` calling `eject`.
1269 *
1270 * @param {Function} fn The function to call for each interceptor
1271 *
1272 * @returns {void}
1273 */
1274 forEach(fn) {
1275 utils$1.forEach(this.handlers, function forEachHandler(h) {
1276 if (h !== null) {
1277 fn(h);
1278 }
1279 });
1280 }
1281}
1282
1283const InterceptorManager$1 = InterceptorManager;
1284
1285const transitionalDefaults = {
1286 silentJSONParsing: true,
1287 forcedJSONParsing: true,
1288 clarifyTimeoutError: false
1289};
1290
1291const URLSearchParams = url__default["default"].URLSearchParams;
1292
1293const platform$1 = {
1294 isNode: true,
1295 classes: {
1296 URLSearchParams,
1297 FormData: FormData__default["default"],
1298 Blob: typeof Blob !== 'undefined' && Blob || null
1299 },
1300 protocols: [ 'http', 'https', 'file', 'data' ]
1301};
1302
1303const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1304
1305const _navigator = typeof navigator === 'object' && navigator || undefined;
1306
1307/**
1308 * Determine if we're running in a standard browser environment
1309 *
1310 * This allows axios to run in a web worker, and react-native.
1311 * Both environments support XMLHttpRequest, but not fully standard globals.
1312 *
1313 * web workers:
1314 * typeof window -> undefined
1315 * typeof document -> undefined
1316 *
1317 * react-native:
1318 * navigator.product -> 'ReactNative'
1319 * nativescript
1320 * navigator.product -> 'NativeScript' or 'NS'
1321 *
1322 * @returns {boolean}
1323 */
1324const hasStandardBrowserEnv = hasBrowserEnv &&
1325 (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1326
1327/**
1328 * Determine if we're running in a standard browser webWorker environment
1329 *
1330 * Although the `isStandardBrowserEnv` method indicates that
1331 * `allows axios to run in a web worker`, the WebWorker will still be
1332 * filtered out due to its judgment standard
1333 * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1334 * This leads to a problem when axios post `FormData` in webWorker
1335 */
1336const hasStandardBrowserWebWorkerEnv = (() => {
1337 return (
1338 typeof WorkerGlobalScope !== 'undefined' &&
1339 // eslint-disable-next-line no-undef
1340 self instanceof WorkerGlobalScope &&
1341 typeof self.importScripts === 'function'
1342 );
1343})();
1344
1345const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1346
1347const utils = /*#__PURE__*/Object.freeze({
1348 __proto__: null,
1349 hasBrowserEnv: hasBrowserEnv,
1350 hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1351 hasStandardBrowserEnv: hasStandardBrowserEnv,
1352 navigator: _navigator,
1353 origin: origin
1354});
1355
1356const platform = {
1357 ...utils,
1358 ...platform$1
1359};
1360
1361function toURLEncodedForm(data, options) {
1362 return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1363 visitor: function(value, key, path, helpers) {
1364 if (platform.isNode && utils$1.isBuffer(value)) {
1365 this.append(key, value.toString('base64'));
1366 return false;
1367 }
1368
1369 return helpers.defaultVisitor.apply(this, arguments);
1370 }
1371 }, options));
1372}
1373
1374/**
1375 * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1376 *
1377 * @param {string} name - The name of the property to get.
1378 *
1379 * @returns An array of strings.
1380 */
1381function parsePropPath(name) {
1382 // foo[x][y][z]
1383 // foo.x.y.z
1384 // foo-x-y-z
1385 // foo x y z
1386 return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1387 return match[0] === '[]' ? '' : match[1] || match[0];
1388 });
1389}
1390
1391/**
1392 * Convert an array to an object.
1393 *
1394 * @param {Array<any>} arr - The array to convert to an object.
1395 *
1396 * @returns An object with the same keys and values as the array.
1397 */
1398function arrayToObject(arr) {
1399 const obj = {};
1400 const keys = Object.keys(arr);
1401 let i;
1402 const len = keys.length;
1403 let key;
1404 for (i = 0; i < len; i++) {
1405 key = keys[i];
1406 obj[key] = arr[key];
1407 }
1408 return obj;
1409}
1410
1411/**
1412 * It takes a FormData object and returns a JavaScript object
1413 *
1414 * @param {string} formData The FormData object to convert to JSON.
1415 *
1416 * @returns {Object<string, any> | null} The converted object.
1417 */
1418function formDataToJSON(formData) {
1419 function buildPath(path, value, target, index) {
1420 let name = path[index++];
1421
1422 if (name === '__proto__') return true;
1423
1424 const isNumericKey = Number.isFinite(+name);
1425 const isLast = index >= path.length;
1426 name = !name && utils$1.isArray(target) ? target.length : name;
1427
1428 if (isLast) {
1429 if (utils$1.hasOwnProp(target, name)) {
1430 target[name] = [target[name], value];
1431 } else {
1432 target[name] = value;
1433 }
1434
1435 return !isNumericKey;
1436 }
1437
1438 if (!target[name] || !utils$1.isObject(target[name])) {
1439 target[name] = [];
1440 }
1441
1442 const result = buildPath(path, value, target[name], index);
1443
1444 if (result && utils$1.isArray(target[name])) {
1445 target[name] = arrayToObject(target[name]);
1446 }
1447
1448 return !isNumericKey;
1449 }
1450
1451 if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1452 const obj = {};
1453
1454 utils$1.forEachEntry(formData, (name, value) => {
1455 buildPath(parsePropPath(name), value, obj, 0);
1456 });
1457
1458 return obj;
1459 }
1460
1461 return null;
1462}
1463
1464/**
1465 * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1466 * of the input
1467 *
1468 * @param {any} rawValue - The value to be stringified.
1469 * @param {Function} parser - A function that parses a string into a JavaScript object.
1470 * @param {Function} encoder - A function that takes a value and returns a string.
1471 *
1472 * @returns {string} A stringified version of the rawValue.
1473 */
1474function stringifySafely(rawValue, parser, encoder) {
1475 if (utils$1.isString(rawValue)) {
1476 try {
1477 (parser || JSON.parse)(rawValue);
1478 return utils$1.trim(rawValue);
1479 } catch (e) {
1480 if (e.name !== 'SyntaxError') {
1481 throw e;
1482 }
1483 }
1484 }
1485
1486 return (encoder || JSON.stringify)(rawValue);
1487}
1488
1489const defaults = {
1490
1491 transitional: transitionalDefaults,
1492
1493 adapter: ['xhr', 'http', 'fetch'],
1494
1495 transformRequest: [function transformRequest(data, headers) {
1496 const contentType = headers.getContentType() || '';
1497 const hasJSONContentType = contentType.indexOf('application/json') > -1;
1498 const isObjectPayload = utils$1.isObject(data);
1499
1500 if (isObjectPayload && utils$1.isHTMLForm(data)) {
1501 data = new FormData(data);
1502 }
1503
1504 const isFormData = utils$1.isFormData(data);
1505
1506 if (isFormData) {
1507 return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1508 }
1509
1510 if (utils$1.isArrayBuffer(data) ||
1511 utils$1.isBuffer(data) ||
1512 utils$1.isStream(data) ||
1513 utils$1.isFile(data) ||
1514 utils$1.isBlob(data) ||
1515 utils$1.isReadableStream(data)
1516 ) {
1517 return data;
1518 }
1519 if (utils$1.isArrayBufferView(data)) {
1520 return data.buffer;
1521 }
1522 if (utils$1.isURLSearchParams(data)) {
1523 headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1524 return data.toString();
1525 }
1526
1527 let isFileList;
1528
1529 if (isObjectPayload) {
1530 if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1531 return toURLEncodedForm(data, this.formSerializer).toString();
1532 }
1533
1534 if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1535 const _FormData = this.env && this.env.FormData;
1536
1537 return toFormData(
1538 isFileList ? {'files[]': data} : data,
1539 _FormData && new _FormData(),
1540 this.formSerializer
1541 );
1542 }
1543 }
1544
1545 if (isObjectPayload || hasJSONContentType ) {
1546 headers.setContentType('application/json', false);
1547 return stringifySafely(data);
1548 }
1549
1550 return data;
1551 }],
1552
1553 transformResponse: [function transformResponse(data) {
1554 const transitional = this.transitional || defaults.transitional;
1555 const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1556 const JSONRequested = this.responseType === 'json';
1557
1558 if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1559 return data;
1560 }
1561
1562 if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1563 const silentJSONParsing = transitional && transitional.silentJSONParsing;
1564 const strictJSONParsing = !silentJSONParsing && JSONRequested;
1565
1566 try {
1567 return JSON.parse(data);
1568 } catch (e) {
1569 if (strictJSONParsing) {
1570 if (e.name === 'SyntaxError') {
1571 throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1572 }
1573 throw e;
1574 }
1575 }
1576 }
1577
1578 return data;
1579 }],
1580
1581 /**
1582 * A timeout in milliseconds to abort a request. If set to 0 (default) a
1583 * timeout is not created.
1584 */
1585 timeout: 0,
1586
1587 xsrfCookieName: 'XSRF-TOKEN',
1588 xsrfHeaderName: 'X-XSRF-TOKEN',
1589
1590 maxContentLength: -1,
1591 maxBodyLength: -1,
1592
1593 env: {
1594 FormData: platform.classes.FormData,
1595 Blob: platform.classes.Blob
1596 },
1597
1598 validateStatus: function validateStatus(status) {
1599 return status >= 200 && status < 300;
1600 },
1601
1602 headers: {
1603 common: {
1604 'Accept': 'application/json, text/plain, */*',
1605 'Content-Type': undefined
1606 }
1607 }
1608};
1609
1610utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1611 defaults.headers[method] = {};
1612});
1613
1614const defaults$1 = defaults;
1615
1616// RawAxiosHeaders whose duplicates are ignored by node
1617// c.f. https://nodejs.org/api/http.html#http_message_headers
1618const ignoreDuplicateOf = utils$1.toObjectSet([
1619 'age', 'authorization', 'content-length', 'content-type', 'etag',
1620 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1621 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1622 'referer', 'retry-after', 'user-agent'
1623]);
1624
1625/**
1626 * Parse headers into an object
1627 *
1628 * ```
1629 * Date: Wed, 27 Aug 2014 08:58:49 GMT
1630 * Content-Type: application/json
1631 * Connection: keep-alive
1632 * Transfer-Encoding: chunked
1633 * ```
1634 *
1635 * @param {String} rawHeaders Headers needing to be parsed
1636 *
1637 * @returns {Object} Headers parsed into an object
1638 */
1639const parseHeaders = rawHeaders => {
1640 const parsed = {};
1641 let key;
1642 let val;
1643 let i;
1644
1645 rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1646 i = line.indexOf(':');
1647 key = line.substring(0, i).trim().toLowerCase();
1648 val = line.substring(i + 1).trim();
1649
1650 if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1651 return;
1652 }
1653
1654 if (key === 'set-cookie') {
1655 if (parsed[key]) {
1656 parsed[key].push(val);
1657 } else {
1658 parsed[key] = [val];
1659 }
1660 } else {
1661 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1662 }
1663 });
1664
1665 return parsed;
1666};
1667
1668const $internals = Symbol('internals');
1669
1670function normalizeHeader(header) {
1671 return header && String(header).trim().toLowerCase();
1672}
1673
1674function normalizeValue(value) {
1675 if (value === false || value == null) {
1676 return value;
1677 }
1678
1679 return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1680}
1681
1682function parseTokens(str) {
1683 const tokens = Object.create(null);
1684 const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1685 let match;
1686
1687 while ((match = tokensRE.exec(str))) {
1688 tokens[match[1]] = match[2];
1689 }
1690
1691 return tokens;
1692}
1693
1694const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1695
1696function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1697 if (utils$1.isFunction(filter)) {
1698 return filter.call(this, value, header);
1699 }
1700
1701 if (isHeaderNameFilter) {
1702 value = header;
1703 }
1704
1705 if (!utils$1.isString(value)) return;
1706
1707 if (utils$1.isString(filter)) {
1708 return value.indexOf(filter) !== -1;
1709 }
1710
1711 if (utils$1.isRegExp(filter)) {
1712 return filter.test(value);
1713 }
1714}
1715
1716function formatHeader(header) {
1717 return header.trim()
1718 .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1719 return char.toUpperCase() + str;
1720 });
1721}
1722
1723function buildAccessors(obj, header) {
1724 const accessorName = utils$1.toCamelCase(' ' + header);
1725
1726 ['get', 'set', 'has'].forEach(methodName => {
1727 Object.defineProperty(obj, methodName + accessorName, {
1728 value: function(arg1, arg2, arg3) {
1729 return this[methodName].call(this, header, arg1, arg2, arg3);
1730 },
1731 configurable: true
1732 });
1733 });
1734}
1735
1736class AxiosHeaders {
1737 constructor(headers) {
1738 headers && this.set(headers);
1739 }
1740
1741 set(header, valueOrRewrite, rewrite) {
1742 const self = this;
1743
1744 function setHeader(_value, _header, _rewrite) {
1745 const lHeader = normalizeHeader(_header);
1746
1747 if (!lHeader) {
1748 throw new Error('header name must be a non-empty string');
1749 }
1750
1751 const key = utils$1.findKey(self, lHeader);
1752
1753 if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1754 self[key || _header] = normalizeValue(_value);
1755 }
1756 }
1757
1758 const setHeaders = (headers, _rewrite) =>
1759 utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1760
1761 if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1762 setHeaders(header, valueOrRewrite);
1763 } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1764 setHeaders(parseHeaders(header), valueOrRewrite);
1765 } else if (utils$1.isHeaders(header)) {
1766 for (const [key, value] of header.entries()) {
1767 setHeader(value, key, rewrite);
1768 }
1769 } else {
1770 header != null && setHeader(valueOrRewrite, header, rewrite);
1771 }
1772
1773 return this;
1774 }
1775
1776 get(header, parser) {
1777 header = normalizeHeader(header);
1778
1779 if (header) {
1780 const key = utils$1.findKey(this, header);
1781
1782 if (key) {
1783 const value = this[key];
1784
1785 if (!parser) {
1786 return value;
1787 }
1788
1789 if (parser === true) {
1790 return parseTokens(value);
1791 }
1792
1793 if (utils$1.isFunction(parser)) {
1794 return parser.call(this, value, key);
1795 }
1796
1797 if (utils$1.isRegExp(parser)) {
1798 return parser.exec(value);
1799 }
1800
1801 throw new TypeError('parser must be boolean|regexp|function');
1802 }
1803 }
1804 }
1805
1806 has(header, matcher) {
1807 header = normalizeHeader(header);
1808
1809 if (header) {
1810 const key = utils$1.findKey(this, header);
1811
1812 return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1813 }
1814
1815 return false;
1816 }
1817
1818 delete(header, matcher) {
1819 const self = this;
1820 let deleted = false;
1821
1822 function deleteHeader(_header) {
1823 _header = normalizeHeader(_header);
1824
1825 if (_header) {
1826 const key = utils$1.findKey(self, _header);
1827
1828 if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1829 delete self[key];
1830
1831 deleted = true;
1832 }
1833 }
1834 }
1835
1836 if (utils$1.isArray(header)) {
1837 header.forEach(deleteHeader);
1838 } else {
1839 deleteHeader(header);
1840 }
1841
1842 return deleted;
1843 }
1844
1845 clear(matcher) {
1846 const keys = Object.keys(this);
1847 let i = keys.length;
1848 let deleted = false;
1849
1850 while (i--) {
1851 const key = keys[i];
1852 if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1853 delete this[key];
1854 deleted = true;
1855 }
1856 }
1857
1858 return deleted;
1859 }
1860
1861 normalize(format) {
1862 const self = this;
1863 const headers = {};
1864
1865 utils$1.forEach(this, (value, header) => {
1866 const key = utils$1.findKey(headers, header);
1867
1868 if (key) {
1869 self[key] = normalizeValue(value);
1870 delete self[header];
1871 return;
1872 }
1873
1874 const normalized = format ? formatHeader(header) : String(header).trim();
1875
1876 if (normalized !== header) {
1877 delete self[header];
1878 }
1879
1880 self[normalized] = normalizeValue(value);
1881
1882 headers[normalized] = true;
1883 });
1884
1885 return this;
1886 }
1887
1888 concat(...targets) {
1889 return this.constructor.concat(this, ...targets);
1890 }
1891
1892 toJSON(asStrings) {
1893 const obj = Object.create(null);
1894
1895 utils$1.forEach(this, (value, header) => {
1896 value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1897 });
1898
1899 return obj;
1900 }
1901
1902 [Symbol.iterator]() {
1903 return Object.entries(this.toJSON())[Symbol.iterator]();
1904 }
1905
1906 toString() {
1907 return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1908 }
1909
1910 get [Symbol.toStringTag]() {
1911 return 'AxiosHeaders';
1912 }
1913
1914 static from(thing) {
1915 return thing instanceof this ? thing : new this(thing);
1916 }
1917
1918 static concat(first, ...targets) {
1919 const computed = new this(first);
1920
1921 targets.forEach((target) => computed.set(target));
1922
1923 return computed;
1924 }
1925
1926 static accessor(header) {
1927 const internals = this[$internals] = (this[$internals] = {
1928 accessors: {}
1929 });
1930
1931 const accessors = internals.accessors;
1932 const prototype = this.prototype;
1933
1934 function defineAccessor(_header) {
1935 const lHeader = normalizeHeader(_header);
1936
1937 if (!accessors[lHeader]) {
1938 buildAccessors(prototype, _header);
1939 accessors[lHeader] = true;
1940 }
1941 }
1942
1943 utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1944
1945 return this;
1946 }
1947}
1948
1949AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1950
1951// reserved names hotfix
1952utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
1953 let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1954 return {
1955 get: () => value,
1956 set(headerValue) {
1957 this[mapped] = headerValue;
1958 }
1959 }
1960});
1961
1962utils$1.freezeMethods(AxiosHeaders);
1963
1964const AxiosHeaders$1 = AxiosHeaders;
1965
1966/**
1967 * Transform the data for a request or a response
1968 *
1969 * @param {Array|Function} fns A single function or Array of functions
1970 * @param {?Object} response The response object
1971 *
1972 * @returns {*} The resulting transformed data
1973 */
1974function transformData(fns, response) {
1975 const config = this || defaults$1;
1976 const context = response || config;
1977 const headers = AxiosHeaders$1.from(context.headers);
1978 let data = context.data;
1979
1980 utils$1.forEach(fns, function transform(fn) {
1981 data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1982 });
1983
1984 headers.normalize();
1985
1986 return data;
1987}
1988
1989function isCancel(value) {
1990 return !!(value && value.__CANCEL__);
1991}
1992
1993/**
1994 * A `CanceledError` is an object that is thrown when an operation is canceled.
1995 *
1996 * @param {string=} message The message.
1997 * @param {Object=} config The config.
1998 * @param {Object=} request The request.
1999 *
2000 * @returns {CanceledError} The created error.
2001 */
2002function CanceledError(message, config, request) {
2003 // eslint-disable-next-line no-eq-null,eqeqeq
2004 AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2005 this.name = 'CanceledError';
2006}
2007
2008utils$1.inherits(CanceledError, AxiosError, {
2009 __CANCEL__: true
2010});
2011
2012/**
2013 * Resolve or reject a Promise based on response status.
2014 *
2015 * @param {Function} resolve A function that resolves the promise.
2016 * @param {Function} reject A function that rejects the promise.
2017 * @param {object} response The response.
2018 *
2019 * @returns {object} The response.
2020 */
2021function settle(resolve, reject, response) {
2022 const validateStatus = response.config.validateStatus;
2023 if (!response.status || !validateStatus || validateStatus(response.status)) {
2024 resolve(response);
2025 } else {
2026 reject(new AxiosError(
2027 'Request failed with status code ' + response.status,
2028 [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2029 response.config,
2030 response.request,
2031 response
2032 ));
2033 }
2034}
2035
2036/**
2037 * Determines whether the specified URL is absolute
2038 *
2039 * @param {string} url The URL to test
2040 *
2041 * @returns {boolean} True if the specified URL is absolute, otherwise false
2042 */
2043function isAbsoluteURL(url) {
2044 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2045 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2046 // by any combination of letters, digits, plus, period, or hyphen.
2047 return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2048}
2049
2050/**
2051 * Creates a new URL by combining the specified URLs
2052 *
2053 * @param {string} baseURL The base URL
2054 * @param {string} relativeURL The relative URL
2055 *
2056 * @returns {string} The combined URL
2057 */
2058function combineURLs(baseURL, relativeURL) {
2059 return relativeURL
2060 ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2061 : baseURL;
2062}
2063
2064/**
2065 * Creates a new URL by combining the baseURL with the requestedURL,
2066 * only when the requestedURL is not already an absolute URL.
2067 * If the requestURL is absolute, this function returns the requestedURL untouched.
2068 *
2069 * @param {string} baseURL The base URL
2070 * @param {string} requestedURL Absolute or relative URL to combine
2071 *
2072 * @returns {string} The combined full path
2073 */
2074function buildFullPath(baseURL, requestedURL) {
2075 if (baseURL && !isAbsoluteURL(requestedURL)) {
2076 return combineURLs(baseURL, requestedURL);
2077 }
2078 return requestedURL;
2079}
2080
2081const VERSION = "1.7.8";
2082
2083function parseProtocol(url) {
2084 const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2085 return match && match[1] || '';
2086}
2087
2088const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
2089
2090/**
2091 * Parse data uri to a Buffer or Blob
2092 *
2093 * @param {String} uri
2094 * @param {?Boolean} asBlob
2095 * @param {?Object} options
2096 * @param {?Function} options.Blob
2097 *
2098 * @returns {Buffer|Blob}
2099 */
2100function fromDataURI(uri, asBlob, options) {
2101 const _Blob = options && options.Blob || platform.classes.Blob;
2102 const protocol = parseProtocol(uri);
2103
2104 if (asBlob === undefined && _Blob) {
2105 asBlob = true;
2106 }
2107
2108 if (protocol === 'data') {
2109 uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
2110
2111 const match = DATA_URL_PATTERN.exec(uri);
2112
2113 if (!match) {
2114 throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
2115 }
2116
2117 const mime = match[1];
2118 const isBase64 = match[2];
2119 const body = match[3];
2120 const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
2121
2122 if (asBlob) {
2123 if (!_Blob) {
2124 throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
2125 }
2126
2127 return new _Blob([buffer], {type: mime});
2128 }
2129
2130 return buffer;
2131 }
2132
2133 throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
2134}
2135
2136const kInternals = Symbol('internals');
2137
2138class AxiosTransformStream extends stream__default["default"].Transform{
2139 constructor(options) {
2140 options = utils$1.toFlatObject(options, {
2141 maxRate: 0,
2142 chunkSize: 64 * 1024,
2143 minChunkSize: 100,
2144 timeWindow: 500,
2145 ticksRate: 2,
2146 samplesCount: 15
2147 }, null, (prop, source) => {
2148 return !utils$1.isUndefined(source[prop]);
2149 });
2150
2151 super({
2152 readableHighWaterMark: options.chunkSize
2153 });
2154
2155 const internals = this[kInternals] = {
2156 timeWindow: options.timeWindow,
2157 chunkSize: options.chunkSize,
2158 maxRate: options.maxRate,
2159 minChunkSize: options.minChunkSize,
2160 bytesSeen: 0,
2161 isCaptured: false,
2162 notifiedBytesLoaded: 0,
2163 ts: Date.now(),
2164 bytes: 0,
2165 onReadCallback: null
2166 };
2167
2168 this.on('newListener', event => {
2169 if (event === 'progress') {
2170 if (!internals.isCaptured) {
2171 internals.isCaptured = true;
2172 }
2173 }
2174 });
2175 }
2176
2177 _read(size) {
2178 const internals = this[kInternals];
2179
2180 if (internals.onReadCallback) {
2181 internals.onReadCallback();
2182 }
2183
2184 return super._read(size);
2185 }
2186
2187 _transform(chunk, encoding, callback) {
2188 const internals = this[kInternals];
2189 const maxRate = internals.maxRate;
2190
2191 const readableHighWaterMark = this.readableHighWaterMark;
2192
2193 const timeWindow = internals.timeWindow;
2194
2195 const divider = 1000 / timeWindow;
2196 const bytesThreshold = (maxRate / divider);
2197 const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
2198
2199 const pushChunk = (_chunk, _callback) => {
2200 const bytes = Buffer.byteLength(_chunk);
2201 internals.bytesSeen += bytes;
2202 internals.bytes += bytes;
2203
2204 internals.isCaptured && this.emit('progress', internals.bytesSeen);
2205
2206 if (this.push(_chunk)) {
2207 process.nextTick(_callback);
2208 } else {
2209 internals.onReadCallback = () => {
2210 internals.onReadCallback = null;
2211 process.nextTick(_callback);
2212 };
2213 }
2214 };
2215
2216 const transformChunk = (_chunk, _callback) => {
2217 const chunkSize = Buffer.byteLength(_chunk);
2218 let chunkRemainder = null;
2219 let maxChunkSize = readableHighWaterMark;
2220 let bytesLeft;
2221 let passed = 0;
2222
2223 if (maxRate) {
2224 const now = Date.now();
2225
2226 if (!internals.ts || (passed = (now - internals.ts)) >= timeWindow) {
2227 internals.ts = now;
2228 bytesLeft = bytesThreshold - internals.bytes;
2229 internals.bytes = bytesLeft < 0 ? -bytesLeft : 0;
2230 passed = 0;
2231 }
2232
2233 bytesLeft = bytesThreshold - internals.bytes;
2234 }
2235
2236 if (maxRate) {
2237 if (bytesLeft <= 0) {
2238 // next time window
2239 return setTimeout(() => {
2240 _callback(null, _chunk);
2241 }, timeWindow - passed);
2242 }
2243
2244 if (bytesLeft < maxChunkSize) {
2245 maxChunkSize = bytesLeft;
2246 }
2247 }
2248
2249 if (maxChunkSize && chunkSize > maxChunkSize && (chunkSize - maxChunkSize) > minChunkSize) {
2250 chunkRemainder = _chunk.subarray(maxChunkSize);
2251 _chunk = _chunk.subarray(0, maxChunkSize);
2252 }
2253
2254 pushChunk(_chunk, chunkRemainder ? () => {
2255 process.nextTick(_callback, null, chunkRemainder);
2256 } : _callback);
2257 };
2258
2259 transformChunk(chunk, function transformNextChunk(err, _chunk) {
2260 if (err) {
2261 return callback(err);
2262 }
2263
2264 if (_chunk) {
2265 transformChunk(_chunk, transformNextChunk);
2266 } else {
2267 callback(null);
2268 }
2269 });
2270 }
2271}
2272
2273const AxiosTransformStream$1 = AxiosTransformStream;
2274
2275const {asyncIterator} = Symbol;
2276
2277const readBlob = async function* (blob) {
2278 if (blob.stream) {
2279 yield* blob.stream();
2280 } else if (blob.arrayBuffer) {
2281 yield await blob.arrayBuffer();
2282 } else if (blob[asyncIterator]) {
2283 yield* blob[asyncIterator]();
2284 } else {
2285 yield blob;
2286 }
2287};
2288
2289const readBlob$1 = readBlob;
2290
2291const BOUNDARY_ALPHABET = utils$1.ALPHABET.ALPHA_DIGIT + '-_';
2292
2293const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util__default["default"].TextEncoder();
2294
2295const CRLF = '\r\n';
2296const CRLF_BYTES = textEncoder.encode(CRLF);
2297const CRLF_BYTES_COUNT = 2;
2298
2299class FormDataPart {
2300 constructor(name, value) {
2301 const {escapeName} = this.constructor;
2302 const isStringValue = utils$1.isString(value);
2303
2304 let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
2305 !isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''
2306 }${CRLF}`;
2307
2308 if (isStringValue) {
2309 value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
2310 } else {
2311 headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`;
2312 }
2313
2314 this.headers = textEncoder.encode(headers + CRLF);
2315
2316 this.contentLength = isStringValue ? value.byteLength : value.size;
2317
2318 this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
2319
2320 this.name = name;
2321 this.value = value;
2322 }
2323
2324 async *encode(){
2325 yield this.headers;
2326
2327 const {value} = this;
2328
2329 if(utils$1.isTypedArray(value)) {
2330 yield value;
2331 } else {
2332 yield* readBlob$1(value);
2333 }
2334
2335 yield CRLF_BYTES;
2336 }
2337
2338 static escapeName(name) {
2339 return String(name).replace(/[\r\n"]/g, (match) => ({
2340 '\r' : '%0D',
2341 '\n' : '%0A',
2342 '"' : '%22',
2343 }[match]));
2344 }
2345}
2346
2347const formDataToStream = (form, headersHandler, options) => {
2348 const {
2349 tag = 'form-data-boundary',
2350 size = 25,
2351 boundary = tag + '-' + utils$1.generateString(size, BOUNDARY_ALPHABET)
2352 } = options || {};
2353
2354 if(!utils$1.isFormData(form)) {
2355 throw TypeError('FormData instance required');
2356 }
2357
2358 if (boundary.length < 1 || boundary.length > 70) {
2359 throw Error('boundary must be 10-70 characters long')
2360 }
2361
2362 const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
2363 const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
2364 let contentLength = footerBytes.byteLength;
2365
2366 const parts = Array.from(form.entries()).map(([name, value]) => {
2367 const part = new FormDataPart(name, value);
2368 contentLength += part.size;
2369 return part;
2370 });
2371
2372 contentLength += boundaryBytes.byteLength * parts.length;
2373
2374 contentLength = utils$1.toFiniteNumber(contentLength);
2375
2376 const computedHeaders = {
2377 'Content-Type': `multipart/form-data; boundary=${boundary}`
2378 };
2379
2380 if (Number.isFinite(contentLength)) {
2381 computedHeaders['Content-Length'] = contentLength;
2382 }
2383
2384 headersHandler && headersHandler(computedHeaders);
2385
2386 return stream.Readable.from((async function *() {
2387 for(const part of parts) {
2388 yield boundaryBytes;
2389 yield* part.encode();
2390 }
2391
2392 yield footerBytes;
2393 })());
2394};
2395
2396const formDataToStream$1 = formDataToStream;
2397
2398class ZlibHeaderTransformStream extends stream__default["default"].Transform {
2399 __transform(chunk, encoding, callback) {
2400 this.push(chunk);
2401 callback();
2402 }
2403
2404 _transform(chunk, encoding, callback) {
2405 if (chunk.length !== 0) {
2406 this._transform = this.__transform;
2407
2408 // Add Default Compression headers if no zlib headers are present
2409 if (chunk[0] !== 120) { // Hex: 78
2410 const header = Buffer.alloc(2);
2411 header[0] = 120; // Hex: 78
2412 header[1] = 156; // Hex: 9C
2413 this.push(header, encoding);
2414 }
2415 }
2416
2417 this.__transform(chunk, encoding, callback);
2418 }
2419}
2420
2421const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
2422
2423const callbackify = (fn, reducer) => {
2424 return utils$1.isAsyncFn(fn) ? function (...args) {
2425 const cb = args.pop();
2426 fn.apply(this, args).then((value) => {
2427 try {
2428 reducer ? cb(null, ...reducer(value)) : cb(null, value);
2429 } catch (err) {
2430 cb(err);
2431 }
2432 }, cb);
2433 } : fn;
2434};
2435
2436const callbackify$1 = callbackify;
2437
2438/**
2439 * Calculate data maxRate
2440 * @param {Number} [samplesCount= 10]
2441 * @param {Number} [min= 1000]
2442 * @returns {Function}
2443 */
2444function speedometer(samplesCount, min) {
2445 samplesCount = samplesCount || 10;
2446 const bytes = new Array(samplesCount);
2447 const timestamps = new Array(samplesCount);
2448 let head = 0;
2449 let tail = 0;
2450 let firstSampleTS;
2451
2452 min = min !== undefined ? min : 1000;
2453
2454 return function push(chunkLength) {
2455 const now = Date.now();
2456
2457 const startedAt = timestamps[tail];
2458
2459 if (!firstSampleTS) {
2460 firstSampleTS = now;
2461 }
2462
2463 bytes[head] = chunkLength;
2464 timestamps[head] = now;
2465
2466 let i = tail;
2467 let bytesCount = 0;
2468
2469 while (i !== head) {
2470 bytesCount += bytes[i++];
2471 i = i % samplesCount;
2472 }
2473
2474 head = (head + 1) % samplesCount;
2475
2476 if (head === tail) {
2477 tail = (tail + 1) % samplesCount;
2478 }
2479
2480 if (now - firstSampleTS < min) {
2481 return;
2482 }
2483
2484 const passed = startedAt && now - startedAt;
2485
2486 return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2487 };
2488}
2489
2490/**
2491 * Throttle decorator
2492 * @param {Function} fn
2493 * @param {Number} freq
2494 * @return {Function}
2495 */
2496function throttle(fn, freq) {
2497 let timestamp = 0;
2498 let threshold = 1000 / freq;
2499 let lastArgs;
2500 let timer;
2501
2502 const invoke = (args, now = Date.now()) => {
2503 timestamp = now;
2504 lastArgs = null;
2505 if (timer) {
2506 clearTimeout(timer);
2507 timer = null;
2508 }
2509 fn.apply(null, args);
2510 };
2511
2512 const throttled = (...args) => {
2513 const now = Date.now();
2514 const passed = now - timestamp;
2515 if ( passed >= threshold) {
2516 invoke(args, now);
2517 } else {
2518 lastArgs = args;
2519 if (!timer) {
2520 timer = setTimeout(() => {
2521 timer = null;
2522 invoke(lastArgs);
2523 }, threshold - passed);
2524 }
2525 }
2526 };
2527
2528 const flush = () => lastArgs && invoke(lastArgs);
2529
2530 return [throttled, flush];
2531}
2532
2533const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2534 let bytesNotified = 0;
2535 const _speedometer = speedometer(50, 250);
2536
2537 return throttle(e => {
2538 const loaded = e.loaded;
2539 const total = e.lengthComputable ? e.total : undefined;
2540 const progressBytes = loaded - bytesNotified;
2541 const rate = _speedometer(progressBytes);
2542 const inRange = loaded <= total;
2543
2544 bytesNotified = loaded;
2545
2546 const data = {
2547 loaded,
2548 total,
2549 progress: total ? (loaded / total) : undefined,
2550 bytes: progressBytes,
2551 rate: rate ? rate : undefined,
2552 estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2553 event: e,
2554 lengthComputable: total != null,
2555 [isDownloadStream ? 'download' : 'upload']: true
2556 };
2557
2558 listener(data);
2559 }, freq);
2560};
2561
2562const progressEventDecorator = (total, throttled) => {
2563 const lengthComputable = total != null;
2564
2565 return [(loaded) => throttled[0]({
2566 lengthComputable,
2567 total,
2568 loaded
2569 }), throttled[1]];
2570};
2571
2572const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2573
2574const zlibOptions = {
2575 flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
2576 finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
2577};
2578
2579const brotliOptions = {
2580 flush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH,
2581 finishFlush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH
2582};
2583
2584const isBrotliSupported = utils$1.isFunction(zlib__default["default"].createBrotliDecompress);
2585
2586const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"];
2587
2588const isHttps = /https:?/;
2589
2590const supportedProtocols = platform.protocols.map(protocol => {
2591 return protocol + ':';
2592});
2593
2594const flushOnFinish = (stream, [throttled, flush]) => {
2595 stream
2596 .on('end', flush)
2597 .on('error', flush);
2598
2599 return throttled;
2600};
2601
2602/**
2603 * If the proxy or config beforeRedirects functions are defined, call them with the options
2604 * object.
2605 *
2606 * @param {Object<string, any>} options - The options object that was passed to the request.
2607 *
2608 * @returns {Object<string, any>}
2609 */
2610function dispatchBeforeRedirect(options, responseDetails) {
2611 if (options.beforeRedirects.proxy) {
2612 options.beforeRedirects.proxy(options);
2613 }
2614 if (options.beforeRedirects.config) {
2615 options.beforeRedirects.config(options, responseDetails);
2616 }
2617}
2618
2619/**
2620 * If the proxy or config afterRedirects functions are defined, call them with the options
2621 *
2622 * @param {http.ClientRequestArgs} options
2623 * @param {AxiosProxyConfig} configProxy configuration from Axios options object
2624 * @param {string} location
2625 *
2626 * @returns {http.ClientRequestArgs}
2627 */
2628function setProxy(options, configProxy, location) {
2629 let proxy = configProxy;
2630 if (!proxy && proxy !== false) {
2631 const proxyUrl = proxyFromEnv__default["default"].getProxyForUrl(location);
2632 if (proxyUrl) {
2633 proxy = new URL(proxyUrl);
2634 }
2635 }
2636 if (proxy) {
2637 // Basic proxy authorization
2638 if (proxy.username) {
2639 proxy.auth = (proxy.username || '') + ':' + (proxy.password || '');
2640 }
2641
2642 if (proxy.auth) {
2643 // Support proxy auth object form
2644 if (proxy.auth.username || proxy.auth.password) {
2645 proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
2646 }
2647 const base64 = Buffer
2648 .from(proxy.auth, 'utf8')
2649 .toString('base64');
2650 options.headers['Proxy-Authorization'] = 'Basic ' + base64;
2651 }
2652
2653 options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
2654 const proxyHost = proxy.hostname || proxy.host;
2655 options.hostname = proxyHost;
2656 // Replace 'host' since options is not a URL object
2657 options.host = proxyHost;
2658 options.port = proxy.port;
2659 options.path = location;
2660 if (proxy.protocol) {
2661 options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
2662 }
2663 }
2664
2665 options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
2666 // Configure proxy for redirected request, passing the original config proxy to apply
2667 // the exact same logic as if the redirected request was performed by axios directly.
2668 setProxy(redirectOptions, configProxy, redirectOptions.href);
2669 };
2670}
2671
2672const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(process) === 'process';
2673
2674// temporary hotfix
2675
2676const wrapAsync = (asyncExecutor) => {
2677 return new Promise((resolve, reject) => {
2678 let onDone;
2679 let isDone;
2680
2681 const done = (value, isRejected) => {
2682 if (isDone) return;
2683 isDone = true;
2684 onDone && onDone(value, isRejected);
2685 };
2686
2687 const _resolve = (value) => {
2688 done(value);
2689 resolve(value);
2690 };
2691
2692 const _reject = (reason) => {
2693 done(reason, true);
2694 reject(reason);
2695 };
2696
2697 asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
2698 })
2699};
2700
2701const resolveFamily = ({address, family}) => {
2702 if (!utils$1.isString(address)) {
2703 throw TypeError('address must be a string');
2704 }
2705 return ({
2706 address,
2707 family: family || (address.indexOf('.') < 0 ? 6 : 4)
2708 });
2709};
2710
2711const buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(address) ? address : {address, family});
2712
2713/*eslint consistent-return:0*/
2714const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2715 return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
2716 let {data, lookup, family} = config;
2717 const {responseType, responseEncoding} = config;
2718 const method = config.method.toUpperCase();
2719 let isDone;
2720 let rejected = false;
2721 let req;
2722
2723 if (lookup) {
2724 const _lookup = callbackify$1(lookup, (value) => utils$1.isArray(value) ? value : [value]);
2725 // hotfix to support opt.all option which is required for node 20.x
2726 lookup = (hostname, opt, cb) => {
2727 _lookup(hostname, opt, (err, arg0, arg1) => {
2728 if (err) {
2729 return cb(err);
2730 }
2731
2732 const addresses = utils$1.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
2733
2734 opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
2735 });
2736 };
2737 }
2738
2739 // temporary internal emitter until the AxiosRequest class will be implemented
2740 const emitter = new events.EventEmitter();
2741
2742 const onFinished = () => {
2743 if (config.cancelToken) {
2744 config.cancelToken.unsubscribe(abort);
2745 }
2746
2747 if (config.signal) {
2748 config.signal.removeEventListener('abort', abort);
2749 }
2750
2751 emitter.removeAllListeners();
2752 };
2753
2754 onDone((value, isRejected) => {
2755 isDone = true;
2756 if (isRejected) {
2757 rejected = true;
2758 onFinished();
2759 }
2760 });
2761
2762 function abort(reason) {
2763 emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
2764 }
2765
2766 emitter.once('abort', reject);
2767
2768 if (config.cancelToken || config.signal) {
2769 config.cancelToken && config.cancelToken.subscribe(abort);
2770 if (config.signal) {
2771 config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort);
2772 }
2773 }
2774
2775 // Parse url
2776 const fullPath = buildFullPath(config.baseURL, config.url);
2777 const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
2778 const protocol = parsed.protocol || supportedProtocols[0];
2779
2780 if (protocol === 'data:') {
2781 let convertedData;
2782
2783 if (method !== 'GET') {
2784 return settle(resolve, reject, {
2785 status: 405,
2786 statusText: 'method not allowed',
2787 headers: {},
2788 config
2789 });
2790 }
2791
2792 try {
2793 convertedData = fromDataURI(config.url, responseType === 'blob', {
2794 Blob: config.env && config.env.Blob
2795 });
2796 } catch (err) {
2797 throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
2798 }
2799
2800 if (responseType === 'text') {
2801 convertedData = convertedData.toString(responseEncoding);
2802
2803 if (!responseEncoding || responseEncoding === 'utf8') {
2804 convertedData = utils$1.stripBOM(convertedData);
2805 }
2806 } else if (responseType === 'stream') {
2807 convertedData = stream__default["default"].Readable.from(convertedData);
2808 }
2809
2810 return settle(resolve, reject, {
2811 data: convertedData,
2812 status: 200,
2813 statusText: 'OK',
2814 headers: new AxiosHeaders$1(),
2815 config
2816 });
2817 }
2818
2819 if (supportedProtocols.indexOf(protocol) === -1) {
2820 return reject(new AxiosError(
2821 'Unsupported protocol ' + protocol,
2822 AxiosError.ERR_BAD_REQUEST,
2823 config
2824 ));
2825 }
2826
2827 const headers = AxiosHeaders$1.from(config.headers).normalize();
2828
2829 // Set User-Agent (required by some servers)
2830 // See https://github.com/axios/axios/issues/69
2831 // User-Agent is specified; handle case where no UA header is desired
2832 // Only set header if it hasn't been set in config
2833 headers.set('User-Agent', 'axios/' + VERSION, false);
2834
2835 const {onUploadProgress, onDownloadProgress} = config;
2836 const maxRate = config.maxRate;
2837 let maxUploadRate = undefined;
2838 let maxDownloadRate = undefined;
2839
2840 // support for spec compliant FormData objects
2841 if (utils$1.isSpecCompliantForm(data)) {
2842 const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
2843
2844 data = formDataToStream$1(data, (formHeaders) => {
2845 headers.set(formHeaders);
2846 }, {
2847 tag: `axios-${VERSION}-boundary`,
2848 boundary: userBoundary && userBoundary[1] || undefined
2849 });
2850 // support for https://www.npmjs.com/package/form-data api
2851 } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
2852 headers.set(data.getHeaders());
2853
2854 if (!headers.hasContentLength()) {
2855 try {
2856 const knownLength = await util__default["default"].promisify(data.getLength).call(data);
2857 Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
2858 /*eslint no-empty:0*/
2859 } catch (e) {
2860 }
2861 }
2862 } else if (utils$1.isBlob(data) || utils$1.isFile(data)) {
2863 data.size && headers.setContentType(data.type || 'application/octet-stream');
2864 headers.setContentLength(data.size || 0);
2865 data = stream__default["default"].Readable.from(readBlob$1(data));
2866 } else if (data && !utils$1.isStream(data)) {
2867 if (Buffer.isBuffer(data)) ; else if (utils$1.isArrayBuffer(data)) {
2868 data = Buffer.from(new Uint8Array(data));
2869 } else if (utils$1.isString(data)) {
2870 data = Buffer.from(data, 'utf-8');
2871 } else {
2872 return reject(new AxiosError(
2873 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
2874 AxiosError.ERR_BAD_REQUEST,
2875 config
2876 ));
2877 }
2878
2879 // Add Content-Length header if data exists
2880 headers.setContentLength(data.length, false);
2881
2882 if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
2883 return reject(new AxiosError(
2884 'Request body larger than maxBodyLength limit',
2885 AxiosError.ERR_BAD_REQUEST,
2886 config
2887 ));
2888 }
2889 }
2890
2891 const contentLength = utils$1.toFiniteNumber(headers.getContentLength());
2892
2893 if (utils$1.isArray(maxRate)) {
2894 maxUploadRate = maxRate[0];
2895 maxDownloadRate = maxRate[1];
2896 } else {
2897 maxUploadRate = maxDownloadRate = maxRate;
2898 }
2899
2900 if (data && (onUploadProgress || maxUploadRate)) {
2901 if (!utils$1.isStream(data)) {
2902 data = stream__default["default"].Readable.from(data, {objectMode: false});
2903 }
2904
2905 data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
2906 maxRate: utils$1.toFiniteNumber(maxUploadRate)
2907 })], utils$1.noop);
2908
2909 onUploadProgress && data.on('progress', flushOnFinish(
2910 data,
2911 progressEventDecorator(
2912 contentLength,
2913 progressEventReducer(asyncDecorator(onUploadProgress), false, 3)
2914 )
2915 ));
2916 }
2917
2918 // HTTP basic authentication
2919 let auth = undefined;
2920 if (config.auth) {
2921 const username = config.auth.username || '';
2922 const password = config.auth.password || '';
2923 auth = username + ':' + password;
2924 }
2925
2926 if (!auth && parsed.username) {
2927 const urlUsername = parsed.username;
2928 const urlPassword = parsed.password;
2929 auth = urlUsername + ':' + urlPassword;
2930 }
2931
2932 auth && headers.delete('authorization');
2933
2934 let path;
2935
2936 try {
2937 path = buildURL(
2938 parsed.pathname + parsed.search,
2939 config.params,
2940 config.paramsSerializer
2941 ).replace(/^\?/, '');
2942 } catch (err) {
2943 const customErr = new Error(err.message);
2944 customErr.config = config;
2945 customErr.url = config.url;
2946 customErr.exists = true;
2947 return reject(customErr);
2948 }
2949
2950 headers.set(
2951 'Accept-Encoding',
2952 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
2953 );
2954
2955 const options = {
2956 path,
2957 method: method,
2958 headers: headers.toJSON(),
2959 agents: { http: config.httpAgent, https: config.httpsAgent },
2960 auth,
2961 protocol,
2962 family,
2963 beforeRedirect: dispatchBeforeRedirect,
2964 beforeRedirects: {}
2965 };
2966
2967 // cacheable-lookup integration hotfix
2968 !utils$1.isUndefined(lookup) && (options.lookup = lookup);
2969
2970 if (config.socketPath) {
2971 options.socketPath = config.socketPath;
2972 } else {
2973 options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
2974 options.port = parsed.port;
2975 setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
2976 }
2977
2978 let transport;
2979 const isHttpsRequest = isHttps.test(options.protocol);
2980 options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
2981 if (config.transport) {
2982 transport = config.transport;
2983 } else if (config.maxRedirects === 0) {
2984 transport = isHttpsRequest ? https__default["default"] : http__default["default"];
2985 } else {
2986 if (config.maxRedirects) {
2987 options.maxRedirects = config.maxRedirects;
2988 }
2989 if (config.beforeRedirect) {
2990 options.beforeRedirects.config = config.beforeRedirect;
2991 }
2992 transport = isHttpsRequest ? httpsFollow : httpFollow;
2993 }
2994
2995 if (config.maxBodyLength > -1) {
2996 options.maxBodyLength = config.maxBodyLength;
2997 } else {
2998 // follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
2999 options.maxBodyLength = Infinity;
3000 }
3001
3002 if (config.insecureHTTPParser) {
3003 options.insecureHTTPParser = config.insecureHTTPParser;
3004 }
3005
3006 // Create the request
3007 req = transport.request(options, function handleResponse(res) {
3008 if (req.destroyed) return;
3009
3010 const streams = [res];
3011
3012 const responseLength = +res.headers['content-length'];
3013
3014 if (onDownloadProgress || maxDownloadRate) {
3015 const transformStream = new AxiosTransformStream$1({
3016 maxRate: utils$1.toFiniteNumber(maxDownloadRate)
3017 });
3018
3019 onDownloadProgress && transformStream.on('progress', flushOnFinish(
3020 transformStream,
3021 progressEventDecorator(
3022 responseLength,
3023 progressEventReducer(asyncDecorator(onDownloadProgress), true, 3)
3024 )
3025 ));
3026
3027 streams.push(transformStream);
3028 }
3029
3030 // decompress the response body transparently if required
3031 let responseStream = res;
3032
3033 // return the last request in case of redirects
3034 const lastRequest = res.req || req;
3035
3036 // if decompress disabled we should not decompress
3037 if (config.decompress !== false && res.headers['content-encoding']) {
3038 // if no content, but headers still say that it is encoded,
3039 // remove the header not confuse downstream operations
3040 if (method === 'HEAD' || res.statusCode === 204) {
3041 delete res.headers['content-encoding'];
3042 }
3043
3044 switch ((res.headers['content-encoding'] || '').toLowerCase()) {
3045 /*eslint default-case:0*/
3046 case 'gzip':
3047 case 'x-gzip':
3048 case 'compress':
3049 case 'x-compress':
3050 // add the unzipper to the body stream processing pipeline
3051 streams.push(zlib__default["default"].createUnzip(zlibOptions));
3052
3053 // remove the content-encoding in order to not confuse downstream operations
3054 delete res.headers['content-encoding'];
3055 break;
3056 case 'deflate':
3057 streams.push(new ZlibHeaderTransformStream$1());
3058
3059 // add the unzipper to the body stream processing pipeline
3060 streams.push(zlib__default["default"].createUnzip(zlibOptions));
3061
3062 // remove the content-encoding in order to not confuse downstream operations
3063 delete res.headers['content-encoding'];
3064 break;
3065 case 'br':
3066 if (isBrotliSupported) {
3067 streams.push(zlib__default["default"].createBrotliDecompress(brotliOptions));
3068 delete res.headers['content-encoding'];
3069 }
3070 }
3071 }
3072
3073 responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils$1.noop) : streams[0];
3074
3075 const offListeners = stream__default["default"].finished(responseStream, () => {
3076 offListeners();
3077 onFinished();
3078 });
3079
3080 const response = {
3081 status: res.statusCode,
3082 statusText: res.statusMessage,
3083 headers: new AxiosHeaders$1(res.headers),
3084 config,
3085 request: lastRequest
3086 };
3087
3088 if (responseType === 'stream') {
3089 response.data = responseStream;
3090 settle(resolve, reject, response);
3091 } else {
3092 const responseBuffer = [];
3093 let totalResponseBytes = 0;
3094
3095 responseStream.on('data', function handleStreamData(chunk) {
3096 responseBuffer.push(chunk);
3097 totalResponseBytes += chunk.length;
3098
3099 // make sure the content length is not over the maxContentLength if specified
3100 if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
3101 // stream.destroy() emit aborted event before calling reject() on Node.js v16
3102 rejected = true;
3103 responseStream.destroy();
3104 reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
3105 AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
3106 }
3107 });
3108
3109 responseStream.on('aborted', function handlerStreamAborted() {
3110 if (rejected) {
3111 return;
3112 }
3113
3114 const err = new AxiosError(
3115 'stream has been aborted',
3116 AxiosError.ERR_BAD_RESPONSE,
3117 config,
3118 lastRequest
3119 );
3120 responseStream.destroy(err);
3121 reject(err);
3122 });
3123
3124 responseStream.on('error', function handleStreamError(err) {
3125 if (req.destroyed) return;
3126 reject(AxiosError.from(err, null, config, lastRequest));
3127 });
3128
3129 responseStream.on('end', function handleStreamEnd() {
3130 try {
3131 let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
3132 if (responseType !== 'arraybuffer') {
3133 responseData = responseData.toString(responseEncoding);
3134 if (!responseEncoding || responseEncoding === 'utf8') {
3135 responseData = utils$1.stripBOM(responseData);
3136 }
3137 }
3138 response.data = responseData;
3139 } catch (err) {
3140 return reject(AxiosError.from(err, null, config, response.request, response));
3141 }
3142 settle(resolve, reject, response);
3143 });
3144 }
3145
3146 emitter.once('abort', err => {
3147 if (!responseStream.destroyed) {
3148 responseStream.emit('error', err);
3149 responseStream.destroy();
3150 }
3151 });
3152 });
3153
3154 emitter.once('abort', err => {
3155 reject(err);
3156 req.destroy(err);
3157 });
3158
3159 // Handle errors
3160 req.on('error', function handleRequestError(err) {
3161 // @todo remove
3162 // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
3163 reject(AxiosError.from(err, null, config, req));
3164 });
3165
3166 // set tcp keep alive to prevent drop connection by peer
3167 req.on('socket', function handleRequestSocket(socket) {
3168 // default interval of sending ack packet is 1 minute
3169 socket.setKeepAlive(true, 1000 * 60);
3170 });
3171
3172 // Handle request timeout
3173 if (config.timeout) {
3174 // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
3175 const timeout = parseInt(config.timeout, 10);
3176
3177 if (Number.isNaN(timeout)) {
3178 reject(new AxiosError(
3179 'error trying to parse `config.timeout` to int',
3180 AxiosError.ERR_BAD_OPTION_VALUE,
3181 config,
3182 req
3183 ));
3184
3185 return;
3186 }
3187
3188 // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
3189 // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
3190 // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
3191 // And then these socket which be hang up will devouring CPU little by little.
3192 // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
3193 req.setTimeout(timeout, function handleRequestTimeout() {
3194 if (isDone) return;
3195 let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
3196 const transitional = config.transitional || transitionalDefaults;
3197 if (config.timeoutErrorMessage) {
3198 timeoutErrorMessage = config.timeoutErrorMessage;
3199 }
3200 reject(new AxiosError(
3201 timeoutErrorMessage,
3202 transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
3203 config,
3204 req
3205 ));
3206 abort();
3207 });
3208 }
3209
3210
3211 // Send the request
3212 if (utils$1.isStream(data)) {
3213 let ended = false;
3214 let errored = false;
3215
3216 data.on('end', () => {
3217 ended = true;
3218 });
3219
3220 data.once('error', err => {
3221 errored = true;
3222 req.destroy(err);
3223 });
3224
3225 data.on('close', () => {
3226 if (!ended && !errored) {
3227 abort(new CanceledError('Request stream has been aborted', config, req));
3228 }
3229 });
3230
3231 data.pipe(req);
3232 } else {
3233 req.end(data);
3234 }
3235 });
3236};
3237
3238const isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
3239 url = new URL(url, platform.origin);
3240
3241 return (
3242 origin.protocol === url.protocol &&
3243 origin.host === url.host &&
3244 (isMSIE || origin.port === url.port)
3245 );
3246})(
3247 new URL(platform.origin),
3248 platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
3249) : () => true;
3250
3251const cookies = platform.hasStandardBrowserEnv ?
3252
3253 // Standard browser envs support document.cookie
3254 {
3255 write(name, value, expires, path, domain, secure) {
3256 const cookie = [name + '=' + encodeURIComponent(value)];
3257
3258 utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
3259
3260 utils$1.isString(path) && cookie.push('path=' + path);
3261
3262 utils$1.isString(domain) && cookie.push('domain=' + domain);
3263
3264 secure === true && cookie.push('secure');
3265
3266 document.cookie = cookie.join('; ');
3267 },
3268
3269 read(name) {
3270 const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
3271 return (match ? decodeURIComponent(match[3]) : null);
3272 },
3273
3274 remove(name) {
3275 this.write(name, '', Date.now() - 86400000);
3276 }
3277 }
3278
3279 :
3280
3281 // Non-standard browser env (web workers, react-native) lack needed support.
3282 {
3283 write() {},
3284 read() {
3285 return null;
3286 },
3287 remove() {}
3288 };
3289
3290const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3291
3292/**
3293 * Config-specific merge-function which creates a new config-object
3294 * by merging two configuration objects together.
3295 *
3296 * @param {Object} config1
3297 * @param {Object} config2
3298 *
3299 * @returns {Object} New object resulting from merging config2 to config1
3300 */
3301function mergeConfig(config1, config2) {
3302 // eslint-disable-next-line no-param-reassign
3303 config2 = config2 || {};
3304 const config = {};
3305
3306 function getMergedValue(target, source, prop, caseless) {
3307 if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3308 return utils$1.merge.call({caseless}, target, source);
3309 } else if (utils$1.isPlainObject(source)) {
3310 return utils$1.merge({}, source);
3311 } else if (utils$1.isArray(source)) {
3312 return source.slice();
3313 }
3314 return source;
3315 }
3316
3317 // eslint-disable-next-line consistent-return
3318 function mergeDeepProperties(a, b, prop , caseless) {
3319 if (!utils$1.isUndefined(b)) {
3320 return getMergedValue(a, b, prop , caseless);
3321 } else if (!utils$1.isUndefined(a)) {
3322 return getMergedValue(undefined, a, prop , caseless);
3323 }
3324 }
3325
3326 // eslint-disable-next-line consistent-return
3327 function valueFromConfig2(a, b) {
3328 if (!utils$1.isUndefined(b)) {
3329 return getMergedValue(undefined, b);
3330 }
3331 }
3332
3333 // eslint-disable-next-line consistent-return
3334 function defaultToConfig2(a, b) {
3335 if (!utils$1.isUndefined(b)) {
3336 return getMergedValue(undefined, b);
3337 } else if (!utils$1.isUndefined(a)) {
3338 return getMergedValue(undefined, a);
3339 }
3340 }
3341
3342 // eslint-disable-next-line consistent-return
3343 function mergeDirectKeys(a, b, prop) {
3344 if (prop in config2) {
3345 return getMergedValue(a, b);
3346 } else if (prop in config1) {
3347 return getMergedValue(undefined, a);
3348 }
3349 }
3350
3351 const mergeMap = {
3352 url: valueFromConfig2,
3353 method: valueFromConfig2,
3354 data: valueFromConfig2,
3355 baseURL: defaultToConfig2,
3356 transformRequest: defaultToConfig2,
3357 transformResponse: defaultToConfig2,
3358 paramsSerializer: defaultToConfig2,
3359 timeout: defaultToConfig2,
3360 timeoutMessage: defaultToConfig2,
3361 withCredentials: defaultToConfig2,
3362 withXSRFToken: defaultToConfig2,
3363 adapter: defaultToConfig2,
3364 responseType: defaultToConfig2,
3365 xsrfCookieName: defaultToConfig2,
3366 xsrfHeaderName: defaultToConfig2,
3367 onUploadProgress: defaultToConfig2,
3368 onDownloadProgress: defaultToConfig2,
3369 decompress: defaultToConfig2,
3370 maxContentLength: defaultToConfig2,
3371 maxBodyLength: defaultToConfig2,
3372 beforeRedirect: defaultToConfig2,
3373 transport: defaultToConfig2,
3374 httpAgent: defaultToConfig2,
3375 httpsAgent: defaultToConfig2,
3376 cancelToken: defaultToConfig2,
3377 socketPath: defaultToConfig2,
3378 responseEncoding: defaultToConfig2,
3379 validateStatus: mergeDirectKeys,
3380 headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
3381 };
3382
3383 utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
3384 const merge = mergeMap[prop] || mergeDeepProperties;
3385 const configValue = merge(config1[prop], config2[prop], prop);
3386 (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3387 });
3388
3389 return config;
3390}
3391
3392const resolveConfig = (config) => {
3393 const newConfig = mergeConfig({}, config);
3394
3395 let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
3396
3397 newConfig.headers = headers = AxiosHeaders$1.from(headers);
3398
3399 newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
3400
3401 // HTTP basic authentication
3402 if (auth) {
3403 headers.set('Authorization', 'Basic ' +
3404 btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
3405 );
3406 }
3407
3408 let contentType;
3409
3410 if (utils$1.isFormData(data)) {
3411 if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
3412 headers.setContentType(undefined); // Let the browser set it
3413 } else if ((contentType = headers.getContentType()) !== false) {
3414 // fix semicolon duplication issue for ReactNative FormData implementation
3415 const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
3416 headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
3417 }
3418 }
3419
3420 // Add xsrf header
3421 // This is only done if running in a standard browser environment.
3422 // Specifically not if we're in a web worker, or react-native.
3423
3424 if (platform.hasStandardBrowserEnv) {
3425 withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3426
3427 if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
3428 // Add xsrf header
3429 const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3430
3431 if (xsrfValue) {
3432 headers.set(xsrfHeaderName, xsrfValue);
3433 }
3434 }
3435 }
3436
3437 return newConfig;
3438};
3439
3440const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3441
3442const xhrAdapter = isXHRAdapterSupported && function (config) {
3443 return new Promise(function dispatchXhrRequest(resolve, reject) {
3444 const _config = resolveConfig(config);
3445 let requestData = _config.data;
3446 const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3447 let {responseType, onUploadProgress, onDownloadProgress} = _config;
3448 let onCanceled;
3449 let uploadThrottled, downloadThrottled;
3450 let flushUpload, flushDownload;
3451
3452 function done() {
3453 flushUpload && flushUpload(); // flush events
3454 flushDownload && flushDownload(); // flush events
3455
3456 _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
3457
3458 _config.signal && _config.signal.removeEventListener('abort', onCanceled);
3459 }
3460
3461 let request = new XMLHttpRequest();
3462
3463 request.open(_config.method.toUpperCase(), _config.url, true);
3464
3465 // Set the request timeout in MS
3466 request.timeout = _config.timeout;
3467
3468 function onloadend() {
3469 if (!request) {
3470 return;
3471 }
3472 // Prepare the response
3473 const responseHeaders = AxiosHeaders$1.from(
3474 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
3475 );
3476 const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
3477 request.responseText : request.response;
3478 const response = {
3479 data: responseData,
3480 status: request.status,
3481 statusText: request.statusText,
3482 headers: responseHeaders,
3483 config,
3484 request
3485 };
3486
3487 settle(function _resolve(value) {
3488 resolve(value);
3489 done();
3490 }, function _reject(err) {
3491 reject(err);
3492 done();
3493 }, response);
3494
3495 // Clean up request
3496 request = null;
3497 }
3498
3499 if ('onloadend' in request) {
3500 // Use onloadend if available
3501 request.onloadend = onloadend;
3502 } else {
3503 // Listen for ready state to emulate onloadend
3504 request.onreadystatechange = function handleLoad() {
3505 if (!request || request.readyState !== 4) {
3506 return;
3507 }
3508
3509 // The request errored out and we didn't get a response, this will be
3510 // handled by onerror instead
3511 // With one exception: request that using file: protocol, most browsers
3512 // will return status as 0 even though it's a successful request
3513 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
3514 return;
3515 }
3516 // readystate handler is calling before onerror or ontimeout handlers,
3517 // so we should call onloadend on the next 'tick'
3518 setTimeout(onloadend);
3519 };
3520 }
3521
3522 // Handle browser request cancellation (as opposed to a manual cancellation)
3523 request.onabort = function handleAbort() {
3524 if (!request) {
3525 return;
3526 }
3527
3528 reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
3529
3530 // Clean up request
3531 request = null;
3532 };
3533
3534 // Handle low level network errors
3535 request.onerror = function handleError() {
3536 // Real errors are hidden from us by the browser
3537 // onerror should only fire if it's a network error
3538 reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
3539
3540 // Clean up request
3541 request = null;
3542 };
3543
3544 // Handle timeout
3545 request.ontimeout = function handleTimeout() {
3546 let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
3547 const transitional = _config.transitional || transitionalDefaults;
3548 if (_config.timeoutErrorMessage) {
3549 timeoutErrorMessage = _config.timeoutErrorMessage;
3550 }
3551 reject(new AxiosError(
3552 timeoutErrorMessage,
3553 transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
3554 config,
3555 request));
3556
3557 // Clean up request
3558 request = null;
3559 };
3560
3561 // Remove Content-Type if data is undefined
3562 requestData === undefined && requestHeaders.setContentType(null);
3563
3564 // Add headers to the request
3565 if ('setRequestHeader' in request) {
3566 utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3567 request.setRequestHeader(key, val);
3568 });
3569 }
3570
3571 // Add withCredentials to request if needed
3572 if (!utils$1.isUndefined(_config.withCredentials)) {
3573 request.withCredentials = !!_config.withCredentials;
3574 }
3575
3576 // Add responseType to request if needed
3577 if (responseType && responseType !== 'json') {
3578 request.responseType = _config.responseType;
3579 }
3580
3581 // Handle progress if needed
3582 if (onDownloadProgress) {
3583 ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
3584 request.addEventListener('progress', downloadThrottled);
3585 }
3586
3587 // Not all browsers support upload events
3588 if (onUploadProgress && request.upload) {
3589 ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
3590
3591 request.upload.addEventListener('progress', uploadThrottled);
3592
3593 request.upload.addEventListener('loadend', flushUpload);
3594 }
3595
3596 if (_config.cancelToken || _config.signal) {
3597 // Handle cancellation
3598 // eslint-disable-next-line func-names
3599 onCanceled = cancel => {
3600 if (!request) {
3601 return;
3602 }
3603 reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
3604 request.abort();
3605 request = null;
3606 };
3607
3608 _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3609 if (_config.signal) {
3610 _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
3611 }
3612 }
3613
3614 const protocol = parseProtocol(_config.url);
3615
3616 if (protocol && platform.protocols.indexOf(protocol) === -1) {
3617 reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
3618 return;
3619 }
3620
3621
3622 // Send the request
3623 request.send(requestData || null);
3624 });
3625};
3626
3627const composeSignals = (signals, timeout) => {
3628 const {length} = (signals = signals ? signals.filter(Boolean) : []);
3629
3630 if (timeout || length) {
3631 let controller = new AbortController();
3632
3633 let aborted;
3634
3635 const onabort = function (reason) {
3636 if (!aborted) {
3637 aborted = true;
3638 unsubscribe();
3639 const err = reason instanceof Error ? reason : this.reason;
3640 controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3641 }
3642 };
3643
3644 let timer = timeout && setTimeout(() => {
3645 timer = null;
3646 onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3647 }, timeout);
3648
3649 const unsubscribe = () => {
3650 if (signals) {
3651 timer && clearTimeout(timer);
3652 timer = null;
3653 signals.forEach(signal => {
3654 signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3655 });
3656 signals = null;
3657 }
3658 };
3659
3660 signals.forEach((signal) => signal.addEventListener('abort', onabort));
3661
3662 const {signal} = controller;
3663
3664 signal.unsubscribe = () => utils$1.asap(unsubscribe);
3665
3666 return signal;
3667 }
3668};
3669
3670const composeSignals$1 = composeSignals;
3671
3672const streamChunk = function* (chunk, chunkSize) {
3673 let len = chunk.byteLength;
3674
3675 if (!chunkSize || len < chunkSize) {
3676 yield chunk;
3677 return;
3678 }
3679
3680 let pos = 0;
3681 let end;
3682
3683 while (pos < len) {
3684 end = pos + chunkSize;
3685 yield chunk.slice(pos, end);
3686 pos = end;
3687 }
3688};
3689
3690const readBytes = async function* (iterable, chunkSize) {
3691 for await (const chunk of readStream(iterable)) {
3692 yield* streamChunk(chunk, chunkSize);
3693 }
3694};
3695
3696const readStream = async function* (stream) {
3697 if (stream[Symbol.asyncIterator]) {
3698 yield* stream;
3699 return;
3700 }
3701
3702 const reader = stream.getReader();
3703 try {
3704 for (;;) {
3705 const {done, value} = await reader.read();
3706 if (done) {
3707 break;
3708 }
3709 yield value;
3710 }
3711 } finally {
3712 await reader.cancel();
3713 }
3714};
3715
3716const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3717 const iterator = readBytes(stream, chunkSize);
3718
3719 let bytes = 0;
3720 let done;
3721 let _onFinish = (e) => {
3722 if (!done) {
3723 done = true;
3724 onFinish && onFinish(e);
3725 }
3726 };
3727
3728 return new ReadableStream({
3729 async pull(controller) {
3730 try {
3731 const {done, value} = await iterator.next();
3732
3733 if (done) {
3734 _onFinish();
3735 controller.close();
3736 return;
3737 }
3738
3739 let len = value.byteLength;
3740 if (onProgress) {
3741 let loadedBytes = bytes += len;
3742 onProgress(loadedBytes);
3743 }
3744 controller.enqueue(new Uint8Array(value));
3745 } catch (err) {
3746 _onFinish(err);
3747 throw err;
3748 }
3749 },
3750 cancel(reason) {
3751 _onFinish(reason);
3752 return iterator.return();
3753 }
3754 }, {
3755 highWaterMark: 2
3756 })
3757};
3758
3759const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
3760const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
3761
3762// used only inside the fetch adapter
3763const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3764 ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3765 async (str) => new Uint8Array(await new Response(str).arrayBuffer())
3766);
3767
3768const test = (fn, ...args) => {
3769 try {
3770 return !!fn(...args);
3771 } catch (e) {
3772 return false
3773 }
3774};
3775
3776const supportsRequestStream = isReadableStreamSupported && test(() => {
3777 let duplexAccessed = false;
3778
3779 const hasContentType = new Request(platform.origin, {
3780 body: new ReadableStream(),
3781 method: 'POST',
3782 get duplex() {
3783 duplexAccessed = true;
3784 return 'half';
3785 },
3786 }).headers.has('Content-Type');
3787
3788 return duplexAccessed && !hasContentType;
3789});
3790
3791const DEFAULT_CHUNK_SIZE = 64 * 1024;
3792
3793const supportsResponseStream = isReadableStreamSupported &&
3794 test(() => utils$1.isReadableStream(new Response('').body));
3795
3796
3797const resolvers = {
3798 stream: supportsResponseStream && ((res) => res.body)
3799};
3800
3801isFetchSupported && (((res) => {
3802 ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3803 !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
3804 (_, config) => {
3805 throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
3806 });
3807 });
3808})(new Response));
3809
3810const getBodyLength = async (body) => {
3811 if (body == null) {
3812 return 0;
3813 }
3814
3815 if(utils$1.isBlob(body)) {
3816 return body.size;
3817 }
3818
3819 if(utils$1.isSpecCompliantForm(body)) {
3820 const _request = new Request(platform.origin, {
3821 method: 'POST',
3822 body,
3823 });
3824 return (await _request.arrayBuffer()).byteLength;
3825 }
3826
3827 if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3828 return body.byteLength;
3829 }
3830
3831 if(utils$1.isURLSearchParams(body)) {
3832 body = body + '';
3833 }
3834
3835 if(utils$1.isString(body)) {
3836 return (await encodeText(body)).byteLength;
3837 }
3838};
3839
3840const resolveBodyLength = async (headers, body) => {
3841 const length = utils$1.toFiniteNumber(headers.getContentLength());
3842
3843 return length == null ? getBodyLength(body) : length;
3844};
3845
3846const fetchAdapter = isFetchSupported && (async (config) => {
3847 let {
3848 url,
3849 method,
3850 data,
3851 signal,
3852 cancelToken,
3853 timeout,
3854 onDownloadProgress,
3855 onUploadProgress,
3856 responseType,
3857 headers,
3858 withCredentials = 'same-origin',
3859 fetchOptions
3860 } = resolveConfig(config);
3861
3862 responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3863
3864 let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3865
3866 let request;
3867
3868 const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3869 composedSignal.unsubscribe();
3870 });
3871
3872 let requestContentLength;
3873
3874 try {
3875 if (
3876 onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3877 (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3878 ) {
3879 let _request = new Request(url, {
3880 method: 'POST',
3881 body: data,
3882 duplex: "half"
3883 });
3884
3885 let contentTypeHeader;
3886
3887 if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3888 headers.setContentType(contentTypeHeader);
3889 }
3890
3891 if (_request.body) {
3892 const [onProgress, flush] = progressEventDecorator(
3893 requestContentLength,
3894 progressEventReducer(asyncDecorator(onUploadProgress))
3895 );
3896
3897 data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3898 }
3899 }
3900
3901 if (!utils$1.isString(withCredentials)) {
3902 withCredentials = withCredentials ? 'include' : 'omit';
3903 }
3904
3905 // Cloudflare Workers throws when credentials are defined
3906 // see https://github.com/cloudflare/workerd/issues/902
3907 const isCredentialsSupported = "credentials" in Request.prototype;
3908 request = new Request(url, {
3909 ...fetchOptions,
3910 signal: composedSignal,
3911 method: method.toUpperCase(),
3912 headers: headers.normalize().toJSON(),
3913 body: data,
3914 duplex: "half",
3915 credentials: isCredentialsSupported ? withCredentials : undefined
3916 });
3917
3918 let response = await fetch(request);
3919
3920 const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3921
3922 if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3923 const options = {};
3924
3925 ['status', 'statusText', 'headers'].forEach(prop => {
3926 options[prop] = response[prop];
3927 });
3928
3929 const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3930
3931 const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3932 responseContentLength,
3933 progressEventReducer(asyncDecorator(onDownloadProgress), true)
3934 ) || [];
3935
3936 response = new Response(
3937 trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3938 flush && flush();
3939 unsubscribe && unsubscribe();
3940 }),
3941 options
3942 );
3943 }
3944
3945 responseType = responseType || 'text';
3946
3947 let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3948
3949 !isStreamResponse && unsubscribe && unsubscribe();
3950
3951 return await new Promise((resolve, reject) => {
3952 settle(resolve, reject, {
3953 data: responseData,
3954 headers: AxiosHeaders$1.from(response.headers),
3955 status: response.status,
3956 statusText: response.statusText,
3957 config,
3958 request
3959 });
3960 })
3961 } catch (err) {
3962 unsubscribe && unsubscribe();
3963
3964 if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3965 throw Object.assign(
3966 new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3967 {
3968 cause: err.cause || err
3969 }
3970 )
3971 }
3972
3973 throw AxiosError.from(err, err && err.code, config, request);
3974 }
3975});
3976
3977const knownAdapters = {
3978 http: httpAdapter,
3979 xhr: xhrAdapter,
3980 fetch: fetchAdapter
3981};
3982
3983utils$1.forEach(knownAdapters, (fn, value) => {
3984 if (fn) {
3985 try {
3986 Object.defineProperty(fn, 'name', {value});
3987 } catch (e) {
3988 // eslint-disable-next-line no-empty
3989 }
3990 Object.defineProperty(fn, 'adapterName', {value});
3991 }
3992});
3993
3994const renderReason = (reason) => `- ${reason}`;
3995
3996const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3997
3998const adapters = {
3999 getAdapter: (adapters) => {
4000 adapters = utils$1.isArray(adapters) ? adapters : [adapters];
4001
4002 const {length} = adapters;
4003 let nameOrAdapter;
4004 let adapter;
4005
4006 const rejectedReasons = {};
4007
4008 for (let i = 0; i < length; i++) {
4009 nameOrAdapter = adapters[i];
4010 let id;
4011
4012 adapter = nameOrAdapter;
4013
4014 if (!isResolvedHandle(nameOrAdapter)) {
4015 adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
4016
4017 if (adapter === undefined) {
4018 throw new AxiosError(`Unknown adapter '${id}'`);
4019 }
4020 }
4021
4022 if (adapter) {
4023 break;
4024 }
4025
4026 rejectedReasons[id || '#' + i] = adapter;
4027 }
4028
4029 if (!adapter) {
4030
4031 const reasons = Object.entries(rejectedReasons)
4032 .map(([id, state]) => `adapter ${id} ` +
4033 (state === false ? 'is not supported by the environment' : 'is not available in the build')
4034 );
4035
4036 let s = length ?
4037 (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
4038 'as no adapter specified';
4039
4040 throw new AxiosError(
4041 `There is no suitable adapter to dispatch the request ` + s,
4042 'ERR_NOT_SUPPORT'
4043 );
4044 }
4045
4046 return adapter;
4047 },
4048 adapters: knownAdapters
4049};
4050
4051/**
4052 * Throws a `CanceledError` if cancellation has been requested.
4053 *
4054 * @param {Object} config The config that is to be used for the request
4055 *
4056 * @returns {void}
4057 */
4058function throwIfCancellationRequested(config) {
4059 if (config.cancelToken) {
4060 config.cancelToken.throwIfRequested();
4061 }
4062
4063 if (config.signal && config.signal.aborted) {
4064 throw new CanceledError(null, config);
4065 }
4066}
4067
4068/**
4069 * Dispatch a request to the server using the configured adapter.
4070 *
4071 * @param {object} config The config that is to be used for the request
4072 *
4073 * @returns {Promise} The Promise to be fulfilled
4074 */
4075function dispatchRequest(config) {
4076 throwIfCancellationRequested(config);
4077
4078 config.headers = AxiosHeaders$1.from(config.headers);
4079
4080 // Transform request data
4081 config.data = transformData.call(
4082 config,
4083 config.transformRequest
4084 );
4085
4086 if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
4087 config.headers.setContentType('application/x-www-form-urlencoded', false);
4088 }
4089
4090 const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
4091
4092 return adapter(config).then(function onAdapterResolution(response) {
4093 throwIfCancellationRequested(config);
4094
4095 // Transform response data
4096 response.data = transformData.call(
4097 config,
4098 config.transformResponse,
4099 response
4100 );
4101
4102 response.headers = AxiosHeaders$1.from(response.headers);
4103
4104 return response;
4105 }, function onAdapterRejection(reason) {
4106 if (!isCancel(reason)) {
4107 throwIfCancellationRequested(config);
4108
4109 // Transform response data
4110 if (reason && reason.response) {
4111 reason.response.data = transformData.call(
4112 config,
4113 config.transformResponse,
4114 reason.response
4115 );
4116 reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
4117 }
4118 }
4119
4120 return Promise.reject(reason);
4121 });
4122}
4123
4124const validators$1 = {};
4125
4126// eslint-disable-next-line func-names
4127['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
4128 validators$1[type] = function validator(thing) {
4129 return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
4130 };
4131});
4132
4133const deprecatedWarnings = {};
4134
4135/**
4136 * Transitional option validator
4137 *
4138 * @param {function|boolean?} validator - set to false if the transitional option has been removed
4139 * @param {string?} version - deprecated version / removed since version
4140 * @param {string?} message - some message with additional info
4141 *
4142 * @returns {function}
4143 */
4144validators$1.transitional = function transitional(validator, version, message) {
4145 function formatMessage(opt, desc) {
4146 return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
4147 }
4148
4149 // eslint-disable-next-line func-names
4150 return (value, opt, opts) => {
4151 if (validator === false) {
4152 throw new AxiosError(
4153 formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
4154 AxiosError.ERR_DEPRECATED
4155 );
4156 }
4157
4158 if (version && !deprecatedWarnings[opt]) {
4159 deprecatedWarnings[opt] = true;
4160 // eslint-disable-next-line no-console
4161 console.warn(
4162 formatMessage(
4163 opt,
4164 ' has been deprecated since v' + version + ' and will be removed in the near future'
4165 )
4166 );
4167 }
4168
4169 return validator ? validator(value, opt, opts) : true;
4170 };
4171};
4172
4173validators$1.spelling = function spelling(correctSpelling) {
4174 return (value, opt) => {
4175 // eslint-disable-next-line no-console
4176 console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
4177 return true;
4178 }
4179};
4180
4181/**
4182 * Assert object's properties type
4183 *
4184 * @param {object} options
4185 * @param {object} schema
4186 * @param {boolean?} allowUnknown
4187 *
4188 * @returns {object}
4189 */
4190
4191function assertOptions(options, schema, allowUnknown) {
4192 if (typeof options !== 'object') {
4193 throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
4194 }
4195 const keys = Object.keys(options);
4196 let i = keys.length;
4197 while (i-- > 0) {
4198 const opt = keys[i];
4199 const validator = schema[opt];
4200 if (validator) {
4201 const value = options[opt];
4202 const result = value === undefined || validator(value, opt, options);
4203 if (result !== true) {
4204 throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
4205 }
4206 continue;
4207 }
4208 if (allowUnknown !== true) {
4209 throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
4210 }
4211 }
4212}
4213
4214const validator = {
4215 assertOptions,
4216 validators: validators$1
4217};
4218
4219const validators = validator.validators;
4220
4221/**
4222 * Create a new instance of Axios
4223 *
4224 * @param {Object} instanceConfig The default config for the instance
4225 *
4226 * @return {Axios} A new instance of Axios
4227 */
4228class Axios {
4229 constructor(instanceConfig) {
4230 this.defaults = instanceConfig;
4231 this.interceptors = {
4232 request: new InterceptorManager$1(),
4233 response: new InterceptorManager$1()
4234 };
4235 }
4236
4237 /**
4238 * Dispatch a request
4239 *
4240 * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
4241 * @param {?Object} config
4242 *
4243 * @returns {Promise} The Promise to be fulfilled
4244 */
4245 async request(configOrUrl, config) {
4246 try {
4247 return await this._request(configOrUrl, config);
4248 } catch (err) {
4249 if (err instanceof Error) {
4250 let dummy = {};
4251
4252 Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
4253
4254 // slice off the Error: ... line
4255 const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
4256 try {
4257 if (!err.stack) {
4258 err.stack = stack;
4259 // match without the 2 top stack lines
4260 } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
4261 err.stack += '\n' + stack;
4262 }
4263 } catch (e) {
4264 // ignore the case where "stack" is an un-writable property
4265 }
4266 }
4267
4268 throw err;
4269 }
4270 }
4271
4272 _request(configOrUrl, config) {
4273 /*eslint no-param-reassign:0*/
4274 // Allow for axios('example/url'[, config]) a la fetch API
4275 if (typeof configOrUrl === 'string') {
4276 config = config || {};
4277 config.url = configOrUrl;
4278 } else {
4279 config = configOrUrl || {};
4280 }
4281
4282 config = mergeConfig(this.defaults, config);
4283
4284 const {transitional, paramsSerializer, headers} = config;
4285
4286 if (transitional !== undefined) {
4287 validator.assertOptions(transitional, {
4288 silentJSONParsing: validators.transitional(validators.boolean),
4289 forcedJSONParsing: validators.transitional(validators.boolean),
4290 clarifyTimeoutError: validators.transitional(validators.boolean)
4291 }, false);
4292 }
4293
4294 if (paramsSerializer != null) {
4295 if (utils$1.isFunction(paramsSerializer)) {
4296 config.paramsSerializer = {
4297 serialize: paramsSerializer
4298 };
4299 } else {
4300 validator.assertOptions(paramsSerializer, {
4301 encode: validators.function,
4302 serialize: validators.function
4303 }, true);
4304 }
4305 }
4306
4307 validator.assertOptions(config, {
4308 baseUrl: validators.spelling('baseURL'),
4309 withXsrfToken: validators.spelling('withXSRFToken')
4310 }, true);
4311
4312 // Set config.method
4313 config.method = (config.method || this.defaults.method || 'get').toLowerCase();
4314
4315 // Flatten headers
4316 let contextHeaders = headers && utils$1.merge(
4317 headers.common,
4318 headers[config.method]
4319 );
4320
4321 headers && utils$1.forEach(
4322 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
4323 (method) => {
4324 delete headers[method];
4325 }
4326 );
4327
4328 config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
4329
4330 // filter out skipped interceptors
4331 const requestInterceptorChain = [];
4332 let synchronousRequestInterceptors = true;
4333 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
4334 if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
4335 return;
4336 }
4337
4338 synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
4339
4340 requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
4341 });
4342
4343 const responseInterceptorChain = [];
4344 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
4345 responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
4346 });
4347
4348 let promise;
4349 let i = 0;
4350 let len;
4351
4352 if (!synchronousRequestInterceptors) {
4353 const chain = [dispatchRequest.bind(this), undefined];
4354 chain.unshift.apply(chain, requestInterceptorChain);
4355 chain.push.apply(chain, responseInterceptorChain);
4356 len = chain.length;
4357
4358 promise = Promise.resolve(config);
4359
4360 while (i < len) {
4361 promise = promise.then(chain[i++], chain[i++]);
4362 }
4363
4364 return promise;
4365 }
4366
4367 len = requestInterceptorChain.length;
4368
4369 let newConfig = config;
4370
4371 i = 0;
4372
4373 while (i < len) {
4374 const onFulfilled = requestInterceptorChain[i++];
4375 const onRejected = requestInterceptorChain[i++];
4376 try {
4377 newConfig = onFulfilled(newConfig);
4378 } catch (error) {
4379 onRejected.call(this, error);
4380 break;
4381 }
4382 }
4383
4384 try {
4385 promise = dispatchRequest.call(this, newConfig);
4386 } catch (error) {
4387 return Promise.reject(error);
4388 }
4389
4390 i = 0;
4391 len = responseInterceptorChain.length;
4392
4393 while (i < len) {
4394 promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
4395 }
4396
4397 return promise;
4398 }
4399
4400 getUri(config) {
4401 config = mergeConfig(this.defaults, config);
4402 const fullPath = buildFullPath(config.baseURL, config.url);
4403 return buildURL(fullPath, config.params, config.paramsSerializer);
4404 }
4405}
4406
4407// Provide aliases for supported request methods
4408utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
4409 /*eslint func-names:0*/
4410 Axios.prototype[method] = function(url, config) {
4411 return this.request(mergeConfig(config || {}, {
4412 method,
4413 url,
4414 data: (config || {}).data
4415 }));
4416 };
4417});
4418
4419utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4420 /*eslint func-names:0*/
4421
4422 function generateHTTPMethod(isForm) {
4423 return function httpMethod(url, data, config) {
4424 return this.request(mergeConfig(config || {}, {
4425 method,
4426 headers: isForm ? {
4427 'Content-Type': 'multipart/form-data'
4428 } : {},
4429 url,
4430 data
4431 }));
4432 };
4433 }
4434
4435 Axios.prototype[method] = generateHTTPMethod();
4436
4437 Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
4438});
4439
4440const Axios$1 = Axios;
4441
4442/**
4443 * A `CancelToken` is an object that can be used to request cancellation of an operation.
4444 *
4445 * @param {Function} executor The executor function.
4446 *
4447 * @returns {CancelToken}
4448 */
4449class CancelToken {
4450 constructor(executor) {
4451 if (typeof executor !== 'function') {
4452 throw new TypeError('executor must be a function.');
4453 }
4454
4455 let resolvePromise;
4456
4457 this.promise = new Promise(function promiseExecutor(resolve) {
4458 resolvePromise = resolve;
4459 });
4460
4461 const token = this;
4462
4463 // eslint-disable-next-line func-names
4464 this.promise.then(cancel => {
4465 if (!token._listeners) return;
4466
4467 let i = token._listeners.length;
4468
4469 while (i-- > 0) {
4470 token._listeners[i](cancel);
4471 }
4472 token._listeners = null;
4473 });
4474
4475 // eslint-disable-next-line func-names
4476 this.promise.then = onfulfilled => {
4477 let _resolve;
4478 // eslint-disable-next-line func-names
4479 const promise = new Promise(resolve => {
4480 token.subscribe(resolve);
4481 _resolve = resolve;
4482 }).then(onfulfilled);
4483
4484 promise.cancel = function reject() {
4485 token.unsubscribe(_resolve);
4486 };
4487
4488 return promise;
4489 };
4490
4491 executor(function cancel(message, config, request) {
4492 if (token.reason) {
4493 // Cancellation has already been requested
4494 return;
4495 }
4496
4497 token.reason = new CanceledError(message, config, request);
4498 resolvePromise(token.reason);
4499 });
4500 }
4501
4502 /**
4503 * Throws a `CanceledError` if cancellation has been requested.
4504 */
4505 throwIfRequested() {
4506 if (this.reason) {
4507 throw this.reason;
4508 }
4509 }
4510
4511 /**
4512 * Subscribe to the cancel signal
4513 */
4514
4515 subscribe(listener) {
4516 if (this.reason) {
4517 listener(this.reason);
4518 return;
4519 }
4520
4521 if (this._listeners) {
4522 this._listeners.push(listener);
4523 } else {
4524 this._listeners = [listener];
4525 }
4526 }
4527
4528 /**
4529 * Unsubscribe from the cancel signal
4530 */
4531
4532 unsubscribe(listener) {
4533 if (!this._listeners) {
4534 return;
4535 }
4536 const index = this._listeners.indexOf(listener);
4537 if (index !== -1) {
4538 this._listeners.splice(index, 1);
4539 }
4540 }
4541
4542 toAbortSignal() {
4543 const controller = new AbortController();
4544
4545 const abort = (err) => {
4546 controller.abort(err);
4547 };
4548
4549 this.subscribe(abort);
4550
4551 controller.signal.unsubscribe = () => this.unsubscribe(abort);
4552
4553 return controller.signal;
4554 }
4555
4556 /**
4557 * Returns an object that contains a new `CancelToken` and a function that, when called,
4558 * cancels the `CancelToken`.
4559 */
4560 static source() {
4561 let cancel;
4562 const token = new CancelToken(function executor(c) {
4563 cancel = c;
4564 });
4565 return {
4566 token,
4567 cancel
4568 };
4569 }
4570}
4571
4572const CancelToken$1 = CancelToken;
4573
4574/**
4575 * Syntactic sugar for invoking a function and expanding an array for arguments.
4576 *
4577 * Common use case would be to use `Function.prototype.apply`.
4578 *
4579 * ```js
4580 * function f(x, y, z) {}
4581 * var args = [1, 2, 3];
4582 * f.apply(null, args);
4583 * ```
4584 *
4585 * With `spread` this example can be re-written.
4586 *
4587 * ```js
4588 * spread(function(x, y, z) {})([1, 2, 3]);
4589 * ```
4590 *
4591 * @param {Function} callback
4592 *
4593 * @returns {Function}
4594 */
4595function spread(callback) {
4596 return function wrap(arr) {
4597 return callback.apply(null, arr);
4598 };
4599}
4600
4601/**
4602 * Determines whether the payload is an error thrown by Axios
4603 *
4604 * @param {*} payload The value to test
4605 *
4606 * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4607 */
4608function isAxiosError(payload) {
4609 return utils$1.isObject(payload) && (payload.isAxiosError === true);
4610}
4611
4612const HttpStatusCode = {
4613 Continue: 100,
4614 SwitchingProtocols: 101,
4615 Processing: 102,
4616 EarlyHints: 103,
4617 Ok: 200,
4618 Created: 201,
4619 Accepted: 202,
4620 NonAuthoritativeInformation: 203,
4621 NoContent: 204,
4622 ResetContent: 205,
4623 PartialContent: 206,
4624 MultiStatus: 207,
4625 AlreadyReported: 208,
4626 ImUsed: 226,
4627 MultipleChoices: 300,
4628 MovedPermanently: 301,
4629 Found: 302,
4630 SeeOther: 303,
4631 NotModified: 304,
4632 UseProxy: 305,
4633 Unused: 306,
4634 TemporaryRedirect: 307,
4635 PermanentRedirect: 308,
4636 BadRequest: 400,
4637 Unauthorized: 401,
4638 PaymentRequired: 402,
4639 Forbidden: 403,
4640 NotFound: 404,
4641 MethodNotAllowed: 405,
4642 NotAcceptable: 406,
4643 ProxyAuthenticationRequired: 407,
4644 RequestTimeout: 408,
4645 Conflict: 409,
4646 Gone: 410,
4647 LengthRequired: 411,
4648 PreconditionFailed: 412,
4649 PayloadTooLarge: 413,
4650 UriTooLong: 414,
4651 UnsupportedMediaType: 415,
4652 RangeNotSatisfiable: 416,
4653 ExpectationFailed: 417,
4654 ImATeapot: 418,
4655 MisdirectedRequest: 421,
4656 UnprocessableEntity: 422,
4657 Locked: 423,
4658 FailedDependency: 424,
4659 TooEarly: 425,
4660 UpgradeRequired: 426,
4661 PreconditionRequired: 428,
4662 TooManyRequests: 429,
4663 RequestHeaderFieldsTooLarge: 431,
4664 UnavailableForLegalReasons: 451,
4665 InternalServerError: 500,
4666 NotImplemented: 501,
4667 BadGateway: 502,
4668 ServiceUnavailable: 503,
4669 GatewayTimeout: 504,
4670 HttpVersionNotSupported: 505,
4671 VariantAlsoNegotiates: 506,
4672 InsufficientStorage: 507,
4673 LoopDetected: 508,
4674 NotExtended: 510,
4675 NetworkAuthenticationRequired: 511,
4676};
4677
4678Object.entries(HttpStatusCode).forEach(([key, value]) => {
4679 HttpStatusCode[value] = key;
4680});
4681
4682const HttpStatusCode$1 = HttpStatusCode;
4683
4684/**
4685 * Create an instance of Axios
4686 *
4687 * @param {Object} defaultConfig The default config for the instance
4688 *
4689 * @returns {Axios} A new instance of Axios
4690 */
4691function createInstance(defaultConfig) {
4692 const context = new Axios$1(defaultConfig);
4693 const instance = bind(Axios$1.prototype.request, context);
4694
4695 // Copy axios.prototype to instance
4696 utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
4697
4698 // Copy context to instance
4699 utils$1.extend(instance, context, null, {allOwnKeys: true});
4700
4701 // Factory for creating new instances
4702 instance.create = function create(instanceConfig) {
4703 return createInstance(mergeConfig(defaultConfig, instanceConfig));
4704 };
4705
4706 return instance;
4707}
4708
4709// Create the default instance to be exported
4710const axios = createInstance(defaults$1);
4711
4712// Expose Axios class to allow class inheritance
4713axios.Axios = Axios$1;
4714
4715// Expose Cancel & CancelToken
4716axios.CanceledError = CanceledError;
4717axios.CancelToken = CancelToken$1;
4718axios.isCancel = isCancel;
4719axios.VERSION = VERSION;
4720axios.toFormData = toFormData;
4721
4722// Expose AxiosError class
4723axios.AxiosError = AxiosError;
4724
4725// alias for CanceledError for backward compatibility
4726axios.Cancel = axios.CanceledError;
4727
4728// Expose all/spread
4729axios.all = function all(promises) {
4730 return Promise.all(promises);
4731};
4732
4733axios.spread = spread;
4734
4735// Expose isAxiosError
4736axios.isAxiosError = isAxiosError;
4737
4738// Expose mergeConfig
4739axios.mergeConfig = mergeConfig;
4740
4741axios.AxiosHeaders = AxiosHeaders$1;
4742
4743axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4744
4745axios.getAdapter = adapters.getAdapter;
4746
4747axios.HttpStatusCode = HttpStatusCode$1;
4748
4749axios.default = axios;
4750
4751module.exports = axios;
4752//# sourceMappingURL=axios.cjs.map
Note: See TracBrowser for help on using the repository browser.