axios 1.7.9 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +200 -0
- package/README.md +62 -37
- package/dist/axios.js +438 -327
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +369 -249
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +369 -249
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +491 -253
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +26 -10
- package/index.d.ts +16 -7
- package/lib/adapters/adapters.js +6 -4
- package/lib/adapters/fetch.js +220 -163
- package/lib/adapters/http.js +19 -1
- package/lib/adapters/xhr.js +11 -8
- package/lib/core/Axios.js +13 -4
- package/lib/core/AxiosError.js +10 -3
- package/lib/core/AxiosHeaders.js +15 -3
- package/lib/core/buildFullPath.js +3 -2
- package/lib/core/dispatchRequest.js +1 -1
- package/lib/core/mergeConfig.js +1 -1
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +1 -3
- package/lib/helpers/estimateDataURLDecodedBytes.js +73 -0
- package/lib/helpers/formDataToStream.js +4 -3
- package/lib/helpers/resolveConfig.js +14 -10
- package/lib/helpers/throttle.js +1 -1
- package/lib/helpers/toFormData.js +4 -0
- package/lib/helpers/toURLEncodedForm.js +4 -3
- package/lib/platform/node/index.js +26 -0
- package/lib/utils.js +52 -28
- package/package.json +24 -12
- package/SECURITY.md +0 -6
package/dist/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/*! Axios v1.12.0 Copyright (c) 2025 Matt Zabriskie and contributors */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -585,9 +585,6 @@
|
|
|
585
585
|
function _slicedToArray(arr, i) {
|
|
586
586
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
587
587
|
}
|
|
588
|
-
function _toArray(arr) {
|
|
589
|
-
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
590
|
-
}
|
|
591
588
|
function _toConsumableArray(arr) {
|
|
592
589
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
593
590
|
}
|
|
@@ -681,6 +678,8 @@
|
|
|
681
678
|
|
|
682
679
|
var toString = Object.prototype.toString;
|
|
683
680
|
var getPrototypeOf = Object.getPrototypeOf;
|
|
681
|
+
var iterator = Symbol.iterator,
|
|
682
|
+
toStringTag = Symbol.toStringTag;
|
|
684
683
|
var kindOf = function (cache) {
|
|
685
684
|
return function (thing) {
|
|
686
685
|
var str = toString.call(thing);
|
|
@@ -725,7 +724,7 @@
|
|
|
725
724
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
726
725
|
*/
|
|
727
726
|
function isBuffer(val) {
|
|
728
|
-
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
727
|
+
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
729
728
|
}
|
|
730
729
|
|
|
731
730
|
/**
|
|
@@ -769,7 +768,7 @@
|
|
|
769
768
|
* @param {*} val The value to test
|
|
770
769
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
771
770
|
*/
|
|
772
|
-
var isFunction = typeOfTest('function');
|
|
771
|
+
var isFunction$1 = typeOfTest('function');
|
|
773
772
|
|
|
774
773
|
/**
|
|
775
774
|
* Determine if a value is a Number
|
|
@@ -813,7 +812,27 @@
|
|
|
813
812
|
return false;
|
|
814
813
|
}
|
|
815
814
|
var prototype = getPrototypeOf(val);
|
|
816
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(
|
|
815
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
820
|
+
*
|
|
821
|
+
* @param {*} val The value to test
|
|
822
|
+
*
|
|
823
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
824
|
+
*/
|
|
825
|
+
var isEmptyObject = function isEmptyObject(val) {
|
|
826
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
827
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
try {
|
|
831
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
832
|
+
} catch (e) {
|
|
833
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
817
836
|
};
|
|
818
837
|
|
|
819
838
|
/**
|
|
@@ -860,7 +879,7 @@
|
|
|
860
879
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
861
880
|
*/
|
|
862
881
|
var isStream = function isStream(val) {
|
|
863
|
-
return isObject(val) && isFunction(val.pipe);
|
|
882
|
+
return isObject(val) && isFunction$1(val.pipe);
|
|
864
883
|
};
|
|
865
884
|
|
|
866
885
|
/**
|
|
@@ -872,9 +891,9 @@
|
|
|
872
891
|
*/
|
|
873
892
|
var isFormData = function isFormData(thing) {
|
|
874
893
|
var kind;
|
|
875
|
-
return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
|
|
894
|
+
return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
|
|
876
895
|
// detect form-data instance
|
|
877
|
-
kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]'));
|
|
896
|
+
kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'));
|
|
878
897
|
};
|
|
879
898
|
|
|
880
899
|
/**
|
|
@@ -940,6 +959,11 @@
|
|
|
940
959
|
fn.call(null, obj[i], i, obj);
|
|
941
960
|
}
|
|
942
961
|
} else {
|
|
962
|
+
// Buffer check
|
|
963
|
+
if (isBuffer(obj)) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
|
|
943
967
|
// Iterate over object keys
|
|
944
968
|
var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
945
969
|
var len = keys.length;
|
|
@@ -951,6 +975,9 @@
|
|
|
951
975
|
}
|
|
952
976
|
}
|
|
953
977
|
function findKey(obj, key) {
|
|
978
|
+
if (isBuffer(obj)) {
|
|
979
|
+
return null;
|
|
980
|
+
}
|
|
954
981
|
key = key.toLowerCase();
|
|
955
982
|
var keys = Object.keys(obj);
|
|
956
983
|
var i = keys.length;
|
|
@@ -993,7 +1020,8 @@
|
|
|
993
1020
|
function merge( /* obj1, obj2, obj3, ... */
|
|
994
1021
|
) {
|
|
995
1022
|
var _ref2 = isContextDefined(this) && this || {},
|
|
996
|
-
caseless = _ref2.caseless
|
|
1023
|
+
caseless = _ref2.caseless,
|
|
1024
|
+
skipUndefined = _ref2.skipUndefined;
|
|
997
1025
|
var result = {};
|
|
998
1026
|
var assignValue = function assignValue(val, key) {
|
|
999
1027
|
var targetKey = caseless && findKey(result, key) || key;
|
|
@@ -1004,7 +1032,9 @@
|
|
|
1004
1032
|
} else if (isArray(val)) {
|
|
1005
1033
|
result[targetKey] = val.slice();
|
|
1006
1034
|
} else {
|
|
1007
|
-
|
|
1035
|
+
if (!skipUndefined || !isUndefined(val)) {
|
|
1036
|
+
result[targetKey] = val;
|
|
1037
|
+
}
|
|
1008
1038
|
}
|
|
1009
1039
|
};
|
|
1010
1040
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
@@ -1027,7 +1057,7 @@
|
|
|
1027
1057
|
var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
1028
1058
|
allOwnKeys = _ref3.allOwnKeys;
|
|
1029
1059
|
forEach(b, function (val, key) {
|
|
1030
|
-
if (thisArg && isFunction(val)) {
|
|
1060
|
+
if (thisArg && isFunction$1(val)) {
|
|
1031
1061
|
a[key] = bind(val, thisArg);
|
|
1032
1062
|
} else {
|
|
1033
1063
|
a[key] = val;
|
|
@@ -1165,10 +1195,10 @@
|
|
|
1165
1195
|
* @returns {void}
|
|
1166
1196
|
*/
|
|
1167
1197
|
var forEachEntry = function forEachEntry(obj, fn) {
|
|
1168
|
-
var generator = obj && obj[
|
|
1169
|
-
var
|
|
1198
|
+
var generator = obj && obj[iterator];
|
|
1199
|
+
var _iterator = generator.call(obj);
|
|
1170
1200
|
var result;
|
|
1171
|
-
while ((result =
|
|
1201
|
+
while ((result = _iterator.next()) && !result.done) {
|
|
1172
1202
|
var pair = result.value;
|
|
1173
1203
|
fn.call(obj, pair[0], pair[1]);
|
|
1174
1204
|
}
|
|
@@ -1235,11 +1265,11 @@
|
|
|
1235
1265
|
var freezeMethods = function freezeMethods(obj) {
|
|
1236
1266
|
reduceDescriptors(obj, function (descriptor, name) {
|
|
1237
1267
|
// skip restricted props in strict mode
|
|
1238
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
1268
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
1239
1269
|
return false;
|
|
1240
1270
|
}
|
|
1241
1271
|
var value = obj[name];
|
|
1242
|
-
if (!isFunction(value)) return;
|
|
1272
|
+
if (!isFunction$1(value)) return;
|
|
1243
1273
|
descriptor.enumerable = false;
|
|
1244
1274
|
if ('writable' in descriptor) {
|
|
1245
1275
|
descriptor.writable = false;
|
|
@@ -1266,23 +1296,6 @@
|
|
|
1266
1296
|
var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
|
|
1267
1297
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
1268
1298
|
};
|
|
1269
|
-
var ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
1270
|
-
var DIGIT = '0123456789';
|
|
1271
|
-
var ALPHABET = {
|
|
1272
|
-
DIGIT: DIGIT,
|
|
1273
|
-
ALPHA: ALPHA,
|
|
1274
|
-
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
1275
|
-
};
|
|
1276
|
-
var generateString = function generateString() {
|
|
1277
|
-
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
1278
|
-
var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
|
|
1279
|
-
var str = '';
|
|
1280
|
-
var length = alphabet.length;
|
|
1281
|
-
while (size--) {
|
|
1282
|
-
str += alphabet[Math.random() * length | 0];
|
|
1283
|
-
}
|
|
1284
|
-
return str;
|
|
1285
|
-
};
|
|
1286
1299
|
|
|
1287
1300
|
/**
|
|
1288
1301
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
@@ -1292,7 +1305,7 @@
|
|
|
1292
1305
|
* @returns {boolean}
|
|
1293
1306
|
*/
|
|
1294
1307
|
function isSpecCompliantForm(thing) {
|
|
1295
|
-
return !!(thing && isFunction(thing.append) && thing[
|
|
1308
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
1296
1309
|
}
|
|
1297
1310
|
var toJSONObject = function toJSONObject(obj) {
|
|
1298
1311
|
var stack = new Array(10);
|
|
@@ -1301,6 +1314,11 @@
|
|
|
1301
1314
|
if (stack.indexOf(source) >= 0) {
|
|
1302
1315
|
return;
|
|
1303
1316
|
}
|
|
1317
|
+
|
|
1318
|
+
//Buffer check
|
|
1319
|
+
if (isBuffer(source)) {
|
|
1320
|
+
return source;
|
|
1321
|
+
}
|
|
1304
1322
|
if (!('toJSON' in source)) {
|
|
1305
1323
|
stack[i] = source;
|
|
1306
1324
|
var target = isArray(source) ? [] : {};
|
|
@@ -1318,7 +1336,7 @@
|
|
|
1318
1336
|
};
|
|
1319
1337
|
var isAsyncFn = kindOfTest('AsyncFunction');
|
|
1320
1338
|
var isThenable = function isThenable(thing) {
|
|
1321
|
-
return thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing["catch"]);
|
|
1339
|
+
return thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing["catch"]);
|
|
1322
1340
|
};
|
|
1323
1341
|
|
|
1324
1342
|
// original code
|
|
@@ -1343,11 +1361,14 @@
|
|
|
1343
1361
|
}("axios@".concat(Math.random()), []) : function (cb) {
|
|
1344
1362
|
return setTimeout(cb);
|
|
1345
1363
|
};
|
|
1346
|
-
}(typeof setImmediate === 'function', isFunction(_global.postMessage));
|
|
1364
|
+
}(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
1347
1365
|
var asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
|
|
1348
1366
|
|
|
1349
1367
|
// *********************
|
|
1350
1368
|
|
|
1369
|
+
var isIterable = function isIterable(thing) {
|
|
1370
|
+
return thing != null && isFunction$1(thing[iterator]);
|
|
1371
|
+
};
|
|
1351
1372
|
var utils$1 = {
|
|
1352
1373
|
isArray: isArray,
|
|
1353
1374
|
isArrayBuffer: isArrayBuffer,
|
|
@@ -1359,6 +1380,7 @@
|
|
|
1359
1380
|
isBoolean: isBoolean,
|
|
1360
1381
|
isObject: isObject,
|
|
1361
1382
|
isPlainObject: isPlainObject,
|
|
1383
|
+
isEmptyObject: isEmptyObject,
|
|
1362
1384
|
isReadableStream: isReadableStream,
|
|
1363
1385
|
isRequest: isRequest,
|
|
1364
1386
|
isResponse: isResponse,
|
|
@@ -1368,7 +1390,7 @@
|
|
|
1368
1390
|
isFile: isFile,
|
|
1369
1391
|
isBlob: isBlob,
|
|
1370
1392
|
isRegExp: isRegExp,
|
|
1371
|
-
isFunction: isFunction,
|
|
1393
|
+
isFunction: isFunction$1,
|
|
1372
1394
|
isStream: isStream,
|
|
1373
1395
|
isURLSearchParams: isURLSearchParams,
|
|
1374
1396
|
isTypedArray: isTypedArray,
|
|
@@ -1399,14 +1421,13 @@
|
|
|
1399
1421
|
findKey: findKey,
|
|
1400
1422
|
global: _global,
|
|
1401
1423
|
isContextDefined: isContextDefined,
|
|
1402
|
-
ALPHABET: ALPHABET,
|
|
1403
|
-
generateString: generateString,
|
|
1404
1424
|
isSpecCompliantForm: isSpecCompliantForm,
|
|
1405
1425
|
toJSONObject: toJSONObject,
|
|
1406
1426
|
isAsyncFn: isAsyncFn,
|
|
1407
1427
|
isThenable: isThenable,
|
|
1408
1428
|
setImmediate: _setImmediate,
|
|
1409
|
-
asap: asap
|
|
1429
|
+
asap: asap,
|
|
1430
|
+
isIterable: isIterable
|
|
1410
1431
|
};
|
|
1411
1432
|
|
|
1412
1433
|
/**
|
|
@@ -1480,9 +1501,20 @@
|
|
|
1480
1501
|
}, function (prop) {
|
|
1481
1502
|
return prop !== 'isAxiosError';
|
|
1482
1503
|
});
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1504
|
+
var msg = error && error.message ? error.message : 'Error';
|
|
1505
|
+
|
|
1506
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
1507
|
+
var errCode = code == null && error ? error.code : code;
|
|
1508
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
1509
|
+
|
|
1510
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
1511
|
+
if (error && axiosError.cause == null) {
|
|
1512
|
+
Object.defineProperty(axiosError, 'cause', {
|
|
1513
|
+
value: error,
|
|
1514
|
+
configurable: true
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
axiosError.name = error && error.name || 'Error';
|
|
1486
1518
|
customProps && Object.assign(axiosError, customProps);
|
|
1487
1519
|
return axiosError;
|
|
1488
1520
|
};
|
|
@@ -1599,6 +1631,9 @@
|
|
|
1599
1631
|
if (utils$1.isDate(value)) {
|
|
1600
1632
|
return value.toISOString();
|
|
1601
1633
|
}
|
|
1634
|
+
if (utils$1.isBoolean(value)) {
|
|
1635
|
+
return value.toString();
|
|
1636
|
+
}
|
|
1602
1637
|
if (!useBlob && utils$1.isBlob(value)) {
|
|
1603
1638
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1604
1639
|
}
|
|
@@ -1727,7 +1762,7 @@
|
|
|
1727
1762
|
* @returns {string} The encoded value.
|
|
1728
1763
|
*/
|
|
1729
1764
|
function encode(val) {
|
|
1730
|
-
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+')
|
|
1765
|
+
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
|
|
1731
1766
|
}
|
|
1732
1767
|
|
|
1733
1768
|
/**
|
|
@@ -1917,7 +1952,7 @@
|
|
|
1917
1952
|
var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
|
|
1918
1953
|
|
|
1919
1954
|
function toURLEncodedForm(data, options) {
|
|
1920
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
1955
|
+
return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
|
|
1921
1956
|
visitor: function visitor(value, key, path, helpers) {
|
|
1922
1957
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1923
1958
|
this.append(key, value.toString('base64'));
|
|
@@ -2082,7 +2117,7 @@
|
|
|
2082
2117
|
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2083
2118
|
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2084
2119
|
try {
|
|
2085
|
-
return JSON.parse(data);
|
|
2120
|
+
return JSON.parse(data, this.parseReviver);
|
|
2086
2121
|
} catch (e) {
|
|
2087
2122
|
if (strictJSONParsing) {
|
|
2088
2123
|
if (e.name === 'SyntaxError') {
|
|
@@ -2246,21 +2281,26 @@
|
|
|
2246
2281
|
setHeaders(header, valueOrRewrite);
|
|
2247
2282
|
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2248
2283
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2249
|
-
} else if (utils$1.
|
|
2250
|
-
var
|
|
2284
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
2285
|
+
var obj = {},
|
|
2286
|
+
dest,
|
|
2287
|
+
key;
|
|
2288
|
+
var _iterator = _createForOfIteratorHelper(header),
|
|
2251
2289
|
_step;
|
|
2252
2290
|
try {
|
|
2253
2291
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2254
|
-
var
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2292
|
+
var entry = _step.value;
|
|
2293
|
+
if (!utils$1.isArray(entry)) {
|
|
2294
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
2295
|
+
}
|
|
2296
|
+
obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
|
|
2258
2297
|
}
|
|
2259
2298
|
} catch (err) {
|
|
2260
2299
|
_iterator.e(err);
|
|
2261
2300
|
} finally {
|
|
2262
2301
|
_iterator.f();
|
|
2263
2302
|
}
|
|
2303
|
+
setHeaders(obj, valueOrRewrite);
|
|
2264
2304
|
} else {
|
|
2265
2305
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
2266
2306
|
}
|
|
@@ -2391,6 +2431,11 @@
|
|
|
2391
2431
|
return header + ': ' + value;
|
|
2392
2432
|
}).join('\n');
|
|
2393
2433
|
}
|
|
2434
|
+
}, {
|
|
2435
|
+
key: "getSetCookie",
|
|
2436
|
+
value: function getSetCookie() {
|
|
2437
|
+
return this.get("set-cookie") || [];
|
|
2438
|
+
}
|
|
2394
2439
|
}, {
|
|
2395
2440
|
key: _Symbol$toStringTag,
|
|
2396
2441
|
get: function get() {
|
|
@@ -2576,7 +2621,7 @@
|
|
|
2576
2621
|
clearTimeout(timer);
|
|
2577
2622
|
timer = null;
|
|
2578
2623
|
}
|
|
2579
|
-
fn.apply(
|
|
2624
|
+
fn.apply(void 0, _toConsumableArray(args));
|
|
2580
2625
|
};
|
|
2581
2626
|
var throttled = function throttled() {
|
|
2582
2627
|
var now = Date.now();
|
|
@@ -2720,8 +2765,9 @@
|
|
|
2720
2765
|
*
|
|
2721
2766
|
* @returns {string} The combined full path
|
|
2722
2767
|
*/
|
|
2723
|
-
function buildFullPath(baseURL, requestedURL) {
|
|
2724
|
-
|
|
2768
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2769
|
+
var isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2770
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
2725
2771
|
return combineURLs(baseURL, requestedURL);
|
|
2726
2772
|
}
|
|
2727
2773
|
return requestedURL;
|
|
@@ -2823,7 +2869,7 @@
|
|
|
2823
2869
|
return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
|
|
2824
2870
|
}
|
|
2825
2871
|
};
|
|
2826
|
-
utils$1.forEach(Object.keys(
|
|
2872
|
+
utils$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
|
|
2827
2873
|
var merge = mergeMap[prop] || mergeDeepProperties;
|
|
2828
2874
|
var configValue = merge(config1[prop], config2[prop], prop);
|
|
2829
2875
|
utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
|
|
@@ -2840,25 +2886,28 @@
|
|
|
2840
2886
|
headers = newConfig.headers,
|
|
2841
2887
|
auth = newConfig.auth;
|
|
2842
2888
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2843
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
2889
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
2844
2890
|
|
|
2845
2891
|
// HTTP basic authentication
|
|
2846
2892
|
if (auth) {
|
|
2847
2893
|
headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
|
|
2848
2894
|
}
|
|
2849
|
-
var contentType;
|
|
2850
2895
|
if (utils$1.isFormData(data)) {
|
|
2851
2896
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2852
|
-
headers.setContentType(undefined); //
|
|
2853
|
-
} else if ((
|
|
2854
|
-
//
|
|
2855
|
-
var
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2897
|
+
headers.setContentType(undefined); // browser handles it
|
|
2898
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
2899
|
+
// Node.js FormData (like form-data package)
|
|
2900
|
+
var formHeaders = data.getHeaders();
|
|
2901
|
+
// Only set safe headers to avoid overwriting security headers
|
|
2902
|
+
var allowedHeaders = ['content-type', 'content-length'];
|
|
2903
|
+
Object.entries(formHeaders).forEach(function (_ref) {
|
|
2904
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
2905
|
+
key = _ref2[0],
|
|
2906
|
+
val = _ref2[1];
|
|
2907
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
2908
|
+
headers.set(key, val);
|
|
2909
|
+
}
|
|
2910
|
+
});
|
|
2862
2911
|
}
|
|
2863
2912
|
}
|
|
2864
2913
|
|
|
@@ -2964,12 +3013,15 @@
|
|
|
2964
3013
|
};
|
|
2965
3014
|
|
|
2966
3015
|
// Handle low level network errors
|
|
2967
|
-
request.onerror = function handleError() {
|
|
2968
|
-
//
|
|
2969
|
-
//
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
3016
|
+
request.onerror = function handleError(event) {
|
|
3017
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3018
|
+
// (message may be empty; when present, surface it)
|
|
3019
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3020
|
+
var msg = event && event.message ? event.message : 'Network Error';
|
|
3021
|
+
var err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
3022
|
+
// attach the underlying event for consumers who want details
|
|
3023
|
+
err.event = event || null;
|
|
3024
|
+
reject(err);
|
|
2973
3025
|
request = null;
|
|
2974
3026
|
};
|
|
2975
3027
|
|
|
@@ -3298,35 +3350,21 @@
|
|
|
3298
3350
|
});
|
|
3299
3351
|
};
|
|
3300
3352
|
|
|
3301
|
-
var
|
|
3302
|
-
var
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3312
|
-
while (1) switch (_context.prev = _context.next) {
|
|
3313
|
-
case 0:
|
|
3314
|
-
_context.t0 = Uint8Array;
|
|
3315
|
-
_context.next = 3;
|
|
3316
|
-
return new Response(str).arrayBuffer();
|
|
3317
|
-
case 3:
|
|
3318
|
-
_context.t1 = _context.sent;
|
|
3319
|
-
return _context.abrupt("return", new _context.t0(_context.t1));
|
|
3320
|
-
case 5:
|
|
3321
|
-
case "end":
|
|
3322
|
-
return _context.stop();
|
|
3323
|
-
}
|
|
3324
|
-
}, _callee);
|
|
3325
|
-
}));
|
|
3326
|
-
return function (_x) {
|
|
3327
|
-
return _ref.apply(this, arguments);
|
|
3353
|
+
var DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3354
|
+
var isFunction = utils$1.isFunction;
|
|
3355
|
+
var globalFetchAPI = function (_ref) {
|
|
3356
|
+
var fetch = _ref.fetch,
|
|
3357
|
+
Request = _ref.Request,
|
|
3358
|
+
Response = _ref.Response;
|
|
3359
|
+
return {
|
|
3360
|
+
fetch: fetch,
|
|
3361
|
+
Request: Request,
|
|
3362
|
+
Response: Response
|
|
3328
3363
|
};
|
|
3329
|
-
}()
|
|
3364
|
+
}(utils$1.global);
|
|
3365
|
+
var _utils$global = utils$1.global,
|
|
3366
|
+
ReadableStream$1 = _utils$global.ReadableStream,
|
|
3367
|
+
TextEncoder = _utils$global.TextEncoder;
|
|
3330
3368
|
var test = function test(fn) {
|
|
3331
3369
|
try {
|
|
3332
3370
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -3337,232 +3375,298 @@
|
|
|
3337
3375
|
return false;
|
|
3338
3376
|
}
|
|
3339
3377
|
};
|
|
3340
|
-
var
|
|
3341
|
-
var
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
return duplexAccessed && !hasContentType;
|
|
3351
|
-
});
|
|
3352
|
-
var DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3353
|
-
var supportsResponseStream = isReadableStreamSupported && test(function () {
|
|
3354
|
-
return utils$1.isReadableStream(new Response('').body);
|
|
3355
|
-
});
|
|
3356
|
-
var resolvers = {
|
|
3357
|
-
stream: supportsResponseStream && function (res) {
|
|
3358
|
-
return res.body;
|
|
3378
|
+
var factory = function factory(env) {
|
|
3379
|
+
var _Object$assign = Object.assign({}, globalFetchAPI, env),
|
|
3380
|
+
fetch = _Object$assign.fetch,
|
|
3381
|
+
Request = _Object$assign.Request,
|
|
3382
|
+
Response = _Object$assign.Response;
|
|
3383
|
+
var isFetchSupported = isFunction(fetch);
|
|
3384
|
+
var isRequestSupported = isFunction(Request);
|
|
3385
|
+
var isResponseSupported = isFunction(Response);
|
|
3386
|
+
if (!isFetchSupported) {
|
|
3387
|
+
return false;
|
|
3359
3388
|
}
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
body: body
|
|
3395
|
-
});
|
|
3396
|
-
_context2.next = 8;
|
|
3397
|
-
return _request.arrayBuffer();
|
|
3398
|
-
case 8:
|
|
3399
|
-
return _context2.abrupt("return", _context2.sent.byteLength);
|
|
3400
|
-
case 9:
|
|
3401
|
-
if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
|
|
3402
|
-
_context2.next = 11;
|
|
3403
|
-
break;
|
|
3404
|
-
}
|
|
3405
|
-
return _context2.abrupt("return", body.byteLength);
|
|
3406
|
-
case 11:
|
|
3407
|
-
if (utils$1.isURLSearchParams(body)) {
|
|
3408
|
-
body = body + '';
|
|
3409
|
-
}
|
|
3410
|
-
if (!utils$1.isString(body)) {
|
|
3411
|
-
_context2.next = 16;
|
|
3412
|
-
break;
|
|
3413
|
-
}
|
|
3414
|
-
_context2.next = 15;
|
|
3415
|
-
return encodeText(body);
|
|
3416
|
-
case 15:
|
|
3417
|
-
return _context2.abrupt("return", _context2.sent.byteLength);
|
|
3418
|
-
case 16:
|
|
3419
|
-
case "end":
|
|
3420
|
-
return _context2.stop();
|
|
3421
|
-
}
|
|
3422
|
-
}, _callee2);
|
|
3423
|
-
}));
|
|
3424
|
-
return function getBodyLength(_x2) {
|
|
3425
|
-
return _ref2.apply(this, arguments);
|
|
3426
|
-
};
|
|
3427
|
-
}();
|
|
3428
|
-
var resolveBodyLength = /*#__PURE__*/function () {
|
|
3429
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(headers, body) {
|
|
3430
|
-
var length;
|
|
3431
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3432
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
3433
|
-
case 0:
|
|
3434
|
-
length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
3435
|
-
return _context3.abrupt("return", length == null ? getBodyLength(body) : length);
|
|
3436
|
-
case 2:
|
|
3437
|
-
case "end":
|
|
3438
|
-
return _context3.stop();
|
|
3389
|
+
var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3390
|
+
var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
|
|
3391
|
+
return function (str) {
|
|
3392
|
+
return encoder.encode(str);
|
|
3393
|
+
};
|
|
3394
|
+
}(new TextEncoder()) : ( /*#__PURE__*/function () {
|
|
3395
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(str) {
|
|
3396
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3397
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3398
|
+
case 0:
|
|
3399
|
+
_context.t0 = Uint8Array;
|
|
3400
|
+
_context.next = 3;
|
|
3401
|
+
return new Request(str).arrayBuffer();
|
|
3402
|
+
case 3:
|
|
3403
|
+
_context.t1 = _context.sent;
|
|
3404
|
+
return _context.abrupt("return", new _context.t0(_context.t1));
|
|
3405
|
+
case 5:
|
|
3406
|
+
case "end":
|
|
3407
|
+
return _context.stop();
|
|
3408
|
+
}
|
|
3409
|
+
}, _callee);
|
|
3410
|
+
}));
|
|
3411
|
+
return function (_x) {
|
|
3412
|
+
return _ref2.apply(this, arguments);
|
|
3413
|
+
};
|
|
3414
|
+
}()));
|
|
3415
|
+
var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
|
|
3416
|
+
var duplexAccessed = false;
|
|
3417
|
+
var hasContentType = new Request(platform.origin, {
|
|
3418
|
+
body: new ReadableStream$1(),
|
|
3419
|
+
method: 'POST',
|
|
3420
|
+
get duplex() {
|
|
3421
|
+
duplexAccessed = true;
|
|
3422
|
+
return 'half';
|
|
3439
3423
|
}
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3424
|
+
}).headers.has('Content-Type');
|
|
3425
|
+
return duplexAccessed && !hasContentType;
|
|
3426
|
+
});
|
|
3427
|
+
var supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(function () {
|
|
3428
|
+
return utils$1.isReadableStream(new Response('').body);
|
|
3429
|
+
});
|
|
3430
|
+
var resolvers = {
|
|
3431
|
+
stream: supportsResponseStream && function (res) {
|
|
3432
|
+
return res.body;
|
|
3433
|
+
}
|
|
3444
3434
|
};
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
}
|
|
3482
|
-
if (_request.body) {
|
|
3483
|
-
_progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
|
|
3484
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
3485
|
-
}
|
|
3486
|
-
case 15:
|
|
3487
|
-
if (!utils$1.isString(withCredentials)) {
|
|
3488
|
-
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3489
|
-
}
|
|
3490
|
-
|
|
3491
|
-
// Cloudflare Workers throws when credentials are defined
|
|
3492
|
-
// see https://github.com/cloudflare/workerd/issues/902
|
|
3493
|
-
isCredentialsSupported = "credentials" in Request.prototype;
|
|
3494
|
-
request = new Request(url, _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
|
|
3495
|
-
signal: composedSignal,
|
|
3496
|
-
method: method.toUpperCase(),
|
|
3497
|
-
headers: headers.normalize().toJSON(),
|
|
3498
|
-
body: data,
|
|
3499
|
-
duplex: "half",
|
|
3500
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3501
|
-
}));
|
|
3502
|
-
_context4.next = 20;
|
|
3503
|
-
return fetch(request);
|
|
3504
|
-
case 20:
|
|
3505
|
-
response = _context4.sent;
|
|
3506
|
-
isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3507
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
3508
|
-
options = {};
|
|
3509
|
-
['status', 'statusText', 'headers'].forEach(function (prop) {
|
|
3510
|
-
options[prop] = response[prop];
|
|
3435
|
+
isFetchSupported && function () {
|
|
3436
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
|
|
3437
|
+
!resolvers[type] && (resolvers[type] = function (res, config) {
|
|
3438
|
+
var method = res && res[type];
|
|
3439
|
+
if (method) {
|
|
3440
|
+
return method.call(res);
|
|
3441
|
+
}
|
|
3442
|
+
throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
|
|
3443
|
+
});
|
|
3444
|
+
});
|
|
3445
|
+
}();
|
|
3446
|
+
var getBodyLength = /*#__PURE__*/function () {
|
|
3447
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body) {
|
|
3448
|
+
var _request;
|
|
3449
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3450
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3451
|
+
case 0:
|
|
3452
|
+
if (!(body == null)) {
|
|
3453
|
+
_context2.next = 2;
|
|
3454
|
+
break;
|
|
3455
|
+
}
|
|
3456
|
+
return _context2.abrupt("return", 0);
|
|
3457
|
+
case 2:
|
|
3458
|
+
if (!utils$1.isBlob(body)) {
|
|
3459
|
+
_context2.next = 4;
|
|
3460
|
+
break;
|
|
3461
|
+
}
|
|
3462
|
+
return _context2.abrupt("return", body.size);
|
|
3463
|
+
case 4:
|
|
3464
|
+
if (!utils$1.isSpecCompliantForm(body)) {
|
|
3465
|
+
_context2.next = 9;
|
|
3466
|
+
break;
|
|
3467
|
+
}
|
|
3468
|
+
_request = new Request(platform.origin, {
|
|
3469
|
+
method: 'POST',
|
|
3470
|
+
body: body
|
|
3511
3471
|
});
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3472
|
+
_context2.next = 8;
|
|
3473
|
+
return _request.arrayBuffer();
|
|
3474
|
+
case 8:
|
|
3475
|
+
return _context2.abrupt("return", _context2.sent.byteLength);
|
|
3476
|
+
case 9:
|
|
3477
|
+
if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
|
|
3478
|
+
_context2.next = 11;
|
|
3479
|
+
break;
|
|
3480
|
+
}
|
|
3481
|
+
return _context2.abrupt("return", body.byteLength);
|
|
3482
|
+
case 11:
|
|
3483
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
3484
|
+
body = body + '';
|
|
3485
|
+
}
|
|
3486
|
+
if (!utils$1.isString(body)) {
|
|
3487
|
+
_context2.next = 16;
|
|
3488
|
+
break;
|
|
3489
|
+
}
|
|
3490
|
+
_context2.next = 15;
|
|
3491
|
+
return encodeText(body);
|
|
3492
|
+
case 15:
|
|
3493
|
+
return _context2.abrupt("return", _context2.sent.byteLength);
|
|
3494
|
+
case 16:
|
|
3495
|
+
case "end":
|
|
3496
|
+
return _context2.stop();
|
|
3497
|
+
}
|
|
3498
|
+
}, _callee2);
|
|
3499
|
+
}));
|
|
3500
|
+
return function getBodyLength(_x2) {
|
|
3501
|
+
return _ref3.apply(this, arguments);
|
|
3502
|
+
};
|
|
3503
|
+
}();
|
|
3504
|
+
var resolveBodyLength = /*#__PURE__*/function () {
|
|
3505
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(headers, body) {
|
|
3506
|
+
var length;
|
|
3507
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3508
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3509
|
+
case 0:
|
|
3510
|
+
length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
3511
|
+
return _context3.abrupt("return", length == null ? getBodyLength(body) : length);
|
|
3512
|
+
case 2:
|
|
3513
|
+
case "end":
|
|
3514
|
+
return _context3.stop();
|
|
3515
|
+
}
|
|
3516
|
+
}, _callee3);
|
|
3517
|
+
}));
|
|
3518
|
+
return function resolveBodyLength(_x3, _x4) {
|
|
3519
|
+
return _ref4.apply(this, arguments);
|
|
3520
|
+
};
|
|
3521
|
+
}();
|
|
3522
|
+
return /*#__PURE__*/function () {
|
|
3523
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(config) {
|
|
3524
|
+
var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, composedSignal, request, unsubscribe, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, resolvedOptions, response, isStreamResponse, options, responseContentLength, _ref6, _ref7, _onProgress, _flush, responseData;
|
|
3525
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
3526
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
3527
|
+
case 0:
|
|
3528
|
+
_resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
|
|
3529
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3530
|
+
composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3531
|
+
request = null;
|
|
3532
|
+
unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
|
|
3533
|
+
composedSignal.unsubscribe();
|
|
3534
|
+
};
|
|
3535
|
+
_context4.prev = 5;
|
|
3536
|
+
_context4.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
|
|
3537
|
+
if (!_context4.t0) {
|
|
3538
|
+
_context4.next = 12;
|
|
3539
|
+
break;
|
|
3540
|
+
}
|
|
3541
|
+
_context4.next = 10;
|
|
3542
|
+
return resolveBodyLength(headers, data);
|
|
3543
|
+
case 10:
|
|
3544
|
+
_context4.t1 = requestContentLength = _context4.sent;
|
|
3545
|
+
_context4.t0 = _context4.t1 !== 0;
|
|
3546
|
+
case 12:
|
|
3547
|
+
if (!_context4.t0) {
|
|
3548
|
+
_context4.next = 16;
|
|
3549
|
+
break;
|
|
3550
|
+
}
|
|
3551
|
+
_request = new Request(url, {
|
|
3552
|
+
method: 'POST',
|
|
3553
|
+
body: data,
|
|
3554
|
+
duplex: "half"
|
|
3534
3555
|
});
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3556
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
3557
|
+
headers.setContentType(contentTypeHeader);
|
|
3558
|
+
}
|
|
3559
|
+
if (_request.body) {
|
|
3560
|
+
_progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
|
|
3561
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
3562
|
+
}
|
|
3563
|
+
case 16:
|
|
3564
|
+
if (!utils$1.isString(withCredentials)) {
|
|
3565
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
// Cloudflare Workers throws when credentials are defined
|
|
3569
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
3570
|
+
isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
3571
|
+
resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
|
|
3572
|
+
signal: composedSignal,
|
|
3573
|
+
method: method.toUpperCase(),
|
|
3574
|
+
headers: headers.normalize().toJSON(),
|
|
3575
|
+
body: data,
|
|
3576
|
+
duplex: "half",
|
|
3577
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3578
|
+
});
|
|
3579
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3580
|
+
_context4.next = 22;
|
|
3581
|
+
return isRequestSupported ? fetch(request, fetchOptions) : fetch(url, resolvedOptions);
|
|
3582
|
+
case 22:
|
|
3583
|
+
response = _context4.sent;
|
|
3584
|
+
isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3585
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
3586
|
+
options = {};
|
|
3587
|
+
['status', 'statusText', 'headers'].forEach(function (prop) {
|
|
3588
|
+
options[prop] = response[prop];
|
|
3589
|
+
});
|
|
3590
|
+
responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3591
|
+
_ref6 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref7 = _slicedToArray(_ref6, 2), _onProgress = _ref7[0], _flush = _ref7[1];
|
|
3592
|
+
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
|
|
3593
|
+
_flush && _flush();
|
|
3594
|
+
unsubscribe && unsubscribe();
|
|
3595
|
+
}), options);
|
|
3596
|
+
}
|
|
3597
|
+
responseType = responseType || 'text';
|
|
3598
|
+
_context4.next = 28;
|
|
3599
|
+
return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3600
|
+
case 28:
|
|
3601
|
+
responseData = _context4.sent;
|
|
3602
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3603
|
+
_context4.next = 32;
|
|
3604
|
+
return new Promise(function (resolve, reject) {
|
|
3605
|
+
settle(resolve, reject, {
|
|
3606
|
+
data: responseData,
|
|
3607
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
3608
|
+
status: response.status,
|
|
3609
|
+
statusText: response.statusText,
|
|
3610
|
+
config: config,
|
|
3611
|
+
request: request
|
|
3612
|
+
});
|
|
3613
|
+
});
|
|
3614
|
+
case 32:
|
|
3615
|
+
return _context4.abrupt("return", _context4.sent);
|
|
3616
|
+
case 35:
|
|
3617
|
+
_context4.prev = 35;
|
|
3618
|
+
_context4.t2 = _context4["catch"](5);
|
|
3619
|
+
unsubscribe && unsubscribe();
|
|
3620
|
+
if (!(_context4.t2 && _context4.t2.name === 'TypeError' && /Load failed|fetch/i.test(_context4.t2.message))) {
|
|
3621
|
+
_context4.next = 40;
|
|
3622
|
+
break;
|
|
3623
|
+
}
|
|
3624
|
+
throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
|
|
3625
|
+
cause: _context4.t2.cause || _context4.t2
|
|
3626
|
+
});
|
|
3627
|
+
case 40:
|
|
3628
|
+
throw AxiosError.from(_context4.t2, _context4.t2 && _context4.t2.code, config, request);
|
|
3629
|
+
case 41:
|
|
3630
|
+
case "end":
|
|
3631
|
+
return _context4.stop();
|
|
3632
|
+
}
|
|
3633
|
+
}, _callee4, null, [[5, 35]]);
|
|
3634
|
+
}));
|
|
3635
|
+
return function (_x5) {
|
|
3636
|
+
return _ref5.apply(this, arguments);
|
|
3637
|
+
};
|
|
3638
|
+
}();
|
|
3639
|
+
};
|
|
3640
|
+
var seedCache = new Map();
|
|
3641
|
+
var getFetch = function getFetch(config) {
|
|
3642
|
+
var env = utils$1.merge.call({
|
|
3643
|
+
skipUndefined: true
|
|
3644
|
+
}, globalFetchAPI, config ? config.env : null);
|
|
3645
|
+
var fetch = env.fetch,
|
|
3646
|
+
Request = env.Request,
|
|
3647
|
+
Response = env.Response;
|
|
3648
|
+
var seeds = [Request, Response, fetch];
|
|
3649
|
+
var len = seeds.length,
|
|
3650
|
+
i = len,
|
|
3651
|
+
seed,
|
|
3652
|
+
target,
|
|
3653
|
+
map = seedCache;
|
|
3654
|
+
while (i--) {
|
|
3655
|
+
seed = seeds[i];
|
|
3656
|
+
target = map.get(seed);
|
|
3657
|
+
target === undefined && map.set(seed, target = i ? new Map() : factory(env));
|
|
3658
|
+
map = target;
|
|
3659
|
+
}
|
|
3660
|
+
return target;
|
|
3661
|
+
};
|
|
3662
|
+
getFetch();
|
|
3561
3663
|
|
|
3562
3664
|
var knownAdapters = {
|
|
3563
3665
|
http: httpAdapter,
|
|
3564
3666
|
xhr: xhrAdapter,
|
|
3565
|
-
fetch:
|
|
3667
|
+
fetch: {
|
|
3668
|
+
get: getFetch
|
|
3669
|
+
}
|
|
3566
3670
|
};
|
|
3567
3671
|
utils$1.forEach(knownAdapters, function (fn, value) {
|
|
3568
3672
|
if (fn) {
|
|
@@ -3585,7 +3689,7 @@
|
|
|
3585
3689
|
return utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3586
3690
|
};
|
|
3587
3691
|
var adapters = {
|
|
3588
|
-
getAdapter: function getAdapter(adapters) {
|
|
3692
|
+
getAdapter: function getAdapter(adapters, config) {
|
|
3589
3693
|
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3590
3694
|
var _adapters = adapters,
|
|
3591
3695
|
length = _adapters.length;
|
|
@@ -3602,7 +3706,7 @@
|
|
|
3602
3706
|
throw new AxiosError("Unknown adapter '".concat(id, "'"));
|
|
3603
3707
|
}
|
|
3604
3708
|
}
|
|
3605
|
-
if (adapter) {
|
|
3709
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
3606
3710
|
break;
|
|
3607
3711
|
}
|
|
3608
3712
|
rejectedReasons[id || '#' + i] = adapter;
|
|
@@ -3654,7 +3758,7 @@
|
|
|
3654
3758
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3655
3759
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
3656
3760
|
}
|
|
3657
|
-
var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
|
3761
|
+
var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
3658
3762
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
3659
3763
|
throwIfCancellationRequested(config);
|
|
3660
3764
|
|
|
@@ -3676,7 +3780,7 @@
|
|
|
3676
3780
|
});
|
|
3677
3781
|
}
|
|
3678
3782
|
|
|
3679
|
-
var VERSION = "1.
|
|
3783
|
+
var VERSION = "1.12.0";
|
|
3680
3784
|
|
|
3681
3785
|
var validators$1 = {};
|
|
3682
3786
|
|
|
@@ -3772,7 +3876,7 @@
|
|
|
3772
3876
|
var Axios = /*#__PURE__*/function () {
|
|
3773
3877
|
function Axios(instanceConfig) {
|
|
3774
3878
|
_classCallCheck(this, Axios);
|
|
3775
|
-
this.defaults = instanceConfig;
|
|
3879
|
+
this.defaults = instanceConfig || {};
|
|
3776
3880
|
this.interceptors = {
|
|
3777
3881
|
request: new InterceptorManager$1(),
|
|
3778
3882
|
response: new InterceptorManager$1()
|
|
@@ -3867,6 +3971,13 @@
|
|
|
3867
3971
|
}, true);
|
|
3868
3972
|
}
|
|
3869
3973
|
}
|
|
3974
|
+
|
|
3975
|
+
// Set config.allowAbsoluteUrls
|
|
3976
|
+
if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
3977
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
3978
|
+
} else {
|
|
3979
|
+
config.allowAbsoluteUrls = true;
|
|
3980
|
+
}
|
|
3870
3981
|
validator.assertOptions(config, {
|
|
3871
3982
|
baseUrl: validators.spelling('baseURL'),
|
|
3872
3983
|
withXsrfToken: validators.spelling('withXSRFToken')
|
|
@@ -3939,7 +4050,7 @@
|
|
|
3939
4050
|
key: "getUri",
|
|
3940
4051
|
value: function getUri(config) {
|
|
3941
4052
|
config = mergeConfig(this.defaults, config);
|
|
3942
|
-
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
4053
|
+
var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
3943
4054
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
3944
4055
|
}
|
|
3945
4056
|
}]);
|