axios 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +175 -0
- package/README.md +256 -1
- package/dist/axios.js +191 -131
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +143 -141
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +143 -141
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +225 -159
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +18 -7
- package/index.d.ts +19 -8
- package/lib/adapters/http.js +23 -10
- package/lib/adapters/xhr.js +7 -8
- package/lib/env/data.js +1 -1
- package/lib/helpers/cookies.js +1 -1
- package/lib/helpers/isURLSameOrigin.js +1 -1
- package/lib/platform/browser/index.js +0 -51
- package/lib/platform/common/utils.js +47 -0
- package/lib/platform/index.js +5 -1
- package/package.json +2 -1
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.6.1 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const FormData$1 = require('form-data');
|
@@ -696,7 +696,7 @@ const isAsyncFn = kindOfTest('AsyncFunction');
|
|
696
696
|
const isThenable = (thing) =>
|
697
697
|
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
698
698
|
|
699
|
-
const utils = {
|
699
|
+
const utils$1 = {
|
700
700
|
isArray,
|
701
701
|
isArrayBuffer,
|
702
702
|
isBuffer,
|
@@ -778,7 +778,7 @@ function AxiosError(message, code, config, request, response) {
|
|
778
778
|
response && (this.response = response);
|
779
779
|
}
|
780
780
|
|
781
|
-
utils.inherits(AxiosError, Error, {
|
781
|
+
utils$1.inherits(AxiosError, Error, {
|
782
782
|
toJSON: function toJSON() {
|
783
783
|
return {
|
784
784
|
// Standard
|
@@ -793,7 +793,7 @@ utils.inherits(AxiosError, Error, {
|
|
793
793
|
columnNumber: this.columnNumber,
|
794
794
|
stack: this.stack,
|
795
795
|
// Axios
|
796
|
-
config: utils.toJSONObject(this.config),
|
796
|
+
config: utils$1.toJSONObject(this.config),
|
797
797
|
code: this.code,
|
798
798
|
status: this.response && this.response.status ? this.response.status : null
|
799
799
|
};
|
@@ -828,7 +828,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
828
828
|
AxiosError.from = (error, code, config, request, response, customProps) => {
|
829
829
|
const axiosError = Object.create(prototype$1);
|
830
830
|
|
831
|
-
utils.toFlatObject(error, axiosError, function filter(obj) {
|
831
|
+
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
832
832
|
return obj !== Error.prototype;
|
833
833
|
}, prop => {
|
834
834
|
return prop !== 'isAxiosError';
|
@@ -853,7 +853,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
853
853
|
* @returns {boolean}
|
854
854
|
*/
|
855
855
|
function isVisitable(thing) {
|
856
|
-
return utils.isPlainObject(thing) || utils.isArray(thing);
|
856
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
857
857
|
}
|
858
858
|
|
859
859
|
/**
|
@@ -864,7 +864,7 @@ function isVisitable(thing) {
|
|
864
864
|
* @returns {string} the key without the brackets.
|
865
865
|
*/
|
866
866
|
function removeBrackets(key) {
|
867
|
-
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
867
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
868
868
|
}
|
869
869
|
|
870
870
|
/**
|
@@ -893,10 +893,10 @@ function renderKey(path, key, dots) {
|
|
893
893
|
* @returns {boolean}
|
894
894
|
*/
|
895
895
|
function isFlatArray(arr) {
|
896
|
-
return utils.isArray(arr) && !arr.some(isVisitable);
|
896
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
897
897
|
}
|
898
898
|
|
899
|
-
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
899
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
900
900
|
return /^is[A-Z]/.test(prop);
|
901
901
|
});
|
902
902
|
|
@@ -924,7 +924,7 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
924
924
|
* @returns
|
925
925
|
*/
|
926
926
|
function toFormData(obj, formData, options) {
|
927
|
-
if (!utils.isObject(obj)) {
|
927
|
+
if (!utils$1.isObject(obj)) {
|
928
928
|
throw new TypeError('target must be an object');
|
929
929
|
}
|
930
930
|
|
@@ -932,13 +932,13 @@ function toFormData(obj, formData, options) {
|
|
932
932
|
formData = formData || new (FormData__default["default"] || FormData)();
|
933
933
|
|
934
934
|
// eslint-disable-next-line no-param-reassign
|
935
|
-
options = utils.toFlatObject(options, {
|
935
|
+
options = utils$1.toFlatObject(options, {
|
936
936
|
metaTokens: true,
|
937
937
|
dots: false,
|
938
938
|
indexes: false
|
939
939
|
}, false, function defined(option, source) {
|
940
940
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
941
|
-
return !utils.isUndefined(source[option]);
|
941
|
+
return !utils$1.isUndefined(source[option]);
|
942
942
|
});
|
943
943
|
|
944
944
|
const metaTokens = options.metaTokens;
|
@@ -947,24 +947,24 @@ function toFormData(obj, formData, options) {
|
|
947
947
|
const dots = options.dots;
|
948
948
|
const indexes = options.indexes;
|
949
949
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
950
|
-
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
950
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
951
951
|
|
952
|
-
if (!utils.isFunction(visitor)) {
|
952
|
+
if (!utils$1.isFunction(visitor)) {
|
953
953
|
throw new TypeError('visitor must be a function');
|
954
954
|
}
|
955
955
|
|
956
956
|
function convertValue(value) {
|
957
957
|
if (value === null) return '';
|
958
958
|
|
959
|
-
if (utils.isDate(value)) {
|
959
|
+
if (utils$1.isDate(value)) {
|
960
960
|
return value.toISOString();
|
961
961
|
}
|
962
962
|
|
963
|
-
if (!useBlob && utils.isBlob(value)) {
|
963
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
964
964
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
965
965
|
}
|
966
966
|
|
967
|
-
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
967
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
968
968
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
969
969
|
}
|
970
970
|
|
@@ -985,20 +985,20 @@ function toFormData(obj, formData, options) {
|
|
985
985
|
let arr = value;
|
986
986
|
|
987
987
|
if (value && !path && typeof value === 'object') {
|
988
|
-
if (utils.endsWith(key, '{}')) {
|
988
|
+
if (utils$1.endsWith(key, '{}')) {
|
989
989
|
// eslint-disable-next-line no-param-reassign
|
990
990
|
key = metaTokens ? key : key.slice(0, -2);
|
991
991
|
// eslint-disable-next-line no-param-reassign
|
992
992
|
value = JSON.stringify(value);
|
993
993
|
} else if (
|
994
|
-
(utils.isArray(value) && isFlatArray(value)) ||
|
995
|
-
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
994
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
995
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
996
996
|
)) {
|
997
997
|
// eslint-disable-next-line no-param-reassign
|
998
998
|
key = removeBrackets(key);
|
999
999
|
|
1000
1000
|
arr.forEach(function each(el, index) {
|
1001
|
-
!(utils.isUndefined(el) || el === null) && formData.append(
|
1001
|
+
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
1002
1002
|
// eslint-disable-next-line no-nested-ternary
|
1003
1003
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
1004
1004
|
convertValue(el)
|
@@ -1026,7 +1026,7 @@ function toFormData(obj, formData, options) {
|
|
1026
1026
|
});
|
1027
1027
|
|
1028
1028
|
function build(value, path) {
|
1029
|
-
if (utils.isUndefined(value)) return;
|
1029
|
+
if (utils$1.isUndefined(value)) return;
|
1030
1030
|
|
1031
1031
|
if (stack.indexOf(value) !== -1) {
|
1032
1032
|
throw Error('Circular reference detected in ' + path.join('.'));
|
@@ -1034,9 +1034,9 @@ function toFormData(obj, formData, options) {
|
|
1034
1034
|
|
1035
1035
|
stack.push(value);
|
1036
1036
|
|
1037
|
-
utils.forEach(value, function each(el, key) {
|
1038
|
-
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
1039
|
-
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
1037
|
+
utils$1.forEach(value, function each(el, key) {
|
1038
|
+
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
1039
|
+
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
1040
1040
|
);
|
1041
1041
|
|
1042
1042
|
if (result === true) {
|
@@ -1047,7 +1047,7 @@ function toFormData(obj, formData, options) {
|
|
1047
1047
|
stack.pop();
|
1048
1048
|
}
|
1049
1049
|
|
1050
|
-
if (!utils.isObject(obj)) {
|
1050
|
+
if (!utils$1.isObject(obj)) {
|
1051
1051
|
throw new TypeError('data must be an object');
|
1052
1052
|
}
|
1053
1053
|
|
@@ -1151,7 +1151,7 @@ function buildURL(url, params, options) {
|
|
1151
1151
|
if (serializeFn) {
|
1152
1152
|
serializedParams = serializeFn(params, options);
|
1153
1153
|
} else {
|
1154
|
-
serializedParams = utils.isURLSearchParams(params) ?
|
1154
|
+
serializedParams = utils$1.isURLSearchParams(params) ?
|
1155
1155
|
params.toString() :
|
1156
1156
|
new AxiosURLSearchParams(params, options).toString(_encode);
|
1157
1157
|
}
|
@@ -1226,7 +1226,7 @@ class InterceptorManager {
|
|
1226
1226
|
* @returns {void}
|
1227
1227
|
*/
|
1228
1228
|
forEach(fn) {
|
1229
|
-
utils.forEach(this.handlers, function forEachHandler(h) {
|
1229
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
1230
1230
|
if (h !== null) {
|
1231
1231
|
fn(h);
|
1232
1232
|
}
|
@@ -1244,7 +1244,7 @@ const transitionalDefaults = {
|
|
1244
1244
|
|
1245
1245
|
const URLSearchParams = url__default["default"].URLSearchParams;
|
1246
1246
|
|
1247
|
-
const platform = {
|
1247
|
+
const platform$1 = {
|
1248
1248
|
isNode: true,
|
1249
1249
|
classes: {
|
1250
1250
|
URLSearchParams,
|
@@ -1254,10 +1254,64 @@ const platform = {
|
|
1254
1254
|
protocols: [ 'http', 'https', 'file', 'data' ]
|
1255
1255
|
};
|
1256
1256
|
|
1257
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
1258
|
+
|
1259
|
+
/**
|
1260
|
+
* Determine if we're running in a standard browser environment
|
1261
|
+
*
|
1262
|
+
* This allows axios to run in a web worker, and react-native.
|
1263
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
1264
|
+
*
|
1265
|
+
* web workers:
|
1266
|
+
* typeof window -> undefined
|
1267
|
+
* typeof document -> undefined
|
1268
|
+
*
|
1269
|
+
* react-native:
|
1270
|
+
* navigator.product -> 'ReactNative'
|
1271
|
+
* nativescript
|
1272
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
1273
|
+
*
|
1274
|
+
* @returns {boolean}
|
1275
|
+
*/
|
1276
|
+
const hasStandardBrowserEnv = (
|
1277
|
+
(product) => {
|
1278
|
+
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
1279
|
+
})(typeof navigator !== 'undefined' && navigator.product);
|
1280
|
+
|
1281
|
+
/**
|
1282
|
+
* Determine if we're running in a standard browser webWorker environment
|
1283
|
+
*
|
1284
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
1285
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
1286
|
+
* filtered out due to its judgment standard
|
1287
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
1288
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
1289
|
+
*/
|
1290
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
1291
|
+
return (
|
1292
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
1293
|
+
// eslint-disable-next-line no-undef
|
1294
|
+
self instanceof WorkerGlobalScope &&
|
1295
|
+
typeof self.importScripts === 'function'
|
1296
|
+
);
|
1297
|
+
})();
|
1298
|
+
|
1299
|
+
const utils = /*#__PURE__*/Object.freeze({
|
1300
|
+
__proto__: null,
|
1301
|
+
hasBrowserEnv: hasBrowserEnv,
|
1302
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
1303
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv
|
1304
|
+
});
|
1305
|
+
|
1306
|
+
const platform = {
|
1307
|
+
...utils,
|
1308
|
+
...platform$1
|
1309
|
+
};
|
1310
|
+
|
1257
1311
|
function toURLEncodedForm(data, options) {
|
1258
1312
|
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
1259
1313
|
visitor: function(value, key, path, helpers) {
|
1260
|
-
if (utils.isBuffer(value)) {
|
1314
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
1261
1315
|
this.append(key, value.toString('base64'));
|
1262
1316
|
return false;
|
1263
1317
|
}
|
@@ -1279,7 +1333,7 @@ function parsePropPath(name) {
|
|
1279
1333
|
// foo.x.y.z
|
1280
1334
|
// foo-x-y-z
|
1281
1335
|
// foo x y z
|
1282
|
-
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
1336
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
1283
1337
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
1284
1338
|
});
|
1285
1339
|
}
|
@@ -1316,10 +1370,10 @@ function formDataToJSON(formData) {
|
|
1316
1370
|
let name = path[index++];
|
1317
1371
|
const isNumericKey = Number.isFinite(+name);
|
1318
1372
|
const isLast = index >= path.length;
|
1319
|
-
name = !name && utils.isArray(target) ? target.length : name;
|
1373
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
1320
1374
|
|
1321
1375
|
if (isLast) {
|
1322
|
-
if (utils.hasOwnProp(target, name)) {
|
1376
|
+
if (utils$1.hasOwnProp(target, name)) {
|
1323
1377
|
target[name] = [target[name], value];
|
1324
1378
|
} else {
|
1325
1379
|
target[name] = value;
|
@@ -1328,23 +1382,23 @@ function formDataToJSON(formData) {
|
|
1328
1382
|
return !isNumericKey;
|
1329
1383
|
}
|
1330
1384
|
|
1331
|
-
if (!target[name] || !utils.isObject(target[name])) {
|
1385
|
+
if (!target[name] || !utils$1.isObject(target[name])) {
|
1332
1386
|
target[name] = [];
|
1333
1387
|
}
|
1334
1388
|
|
1335
1389
|
const result = buildPath(path, value, target[name], index);
|
1336
1390
|
|
1337
|
-
if (result && utils.isArray(target[name])) {
|
1391
|
+
if (result && utils$1.isArray(target[name])) {
|
1338
1392
|
target[name] = arrayToObject(target[name]);
|
1339
1393
|
}
|
1340
1394
|
|
1341
1395
|
return !isNumericKey;
|
1342
1396
|
}
|
1343
1397
|
|
1344
|
-
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
1398
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
1345
1399
|
const obj = {};
|
1346
1400
|
|
1347
|
-
utils.forEachEntry(formData, (name, value) => {
|
1401
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
1348
1402
|
buildPath(parsePropPath(name), value, obj, 0);
|
1349
1403
|
});
|
1350
1404
|
|
@@ -1365,10 +1419,10 @@ function formDataToJSON(formData) {
|
|
1365
1419
|
* @returns {string} A stringified version of the rawValue.
|
1366
1420
|
*/
|
1367
1421
|
function stringifySafely(rawValue, parser, encoder) {
|
1368
|
-
if (utils.isString(rawValue)) {
|
1422
|
+
if (utils$1.isString(rawValue)) {
|
1369
1423
|
try {
|
1370
1424
|
(parser || JSON.parse)(rawValue);
|
1371
|
-
return utils.trim(rawValue);
|
1425
|
+
return utils$1.trim(rawValue);
|
1372
1426
|
} catch (e) {
|
1373
1427
|
if (e.name !== 'SyntaxError') {
|
1374
1428
|
throw e;
|
@@ -1388,13 +1442,13 @@ const defaults = {
|
|
1388
1442
|
transformRequest: [function transformRequest(data, headers) {
|
1389
1443
|
const contentType = headers.getContentType() || '';
|
1390
1444
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1391
|
-
const isObjectPayload = utils.isObject(data);
|
1445
|
+
const isObjectPayload = utils$1.isObject(data);
|
1392
1446
|
|
1393
|
-
if (isObjectPayload && utils.isHTMLForm(data)) {
|
1447
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
1394
1448
|
data = new FormData(data);
|
1395
1449
|
}
|
1396
1450
|
|
1397
|
-
const isFormData = utils.isFormData(data);
|
1451
|
+
const isFormData = utils$1.isFormData(data);
|
1398
1452
|
|
1399
1453
|
if (isFormData) {
|
1400
1454
|
if (!hasJSONContentType) {
|
@@ -1403,18 +1457,18 @@ const defaults = {
|
|
1403
1457
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1404
1458
|
}
|
1405
1459
|
|
1406
|
-
if (utils.isArrayBuffer(data) ||
|
1407
|
-
utils.isBuffer(data) ||
|
1408
|
-
utils.isStream(data) ||
|
1409
|
-
utils.isFile(data) ||
|
1410
|
-
utils.isBlob(data)
|
1460
|
+
if (utils$1.isArrayBuffer(data) ||
|
1461
|
+
utils$1.isBuffer(data) ||
|
1462
|
+
utils$1.isStream(data) ||
|
1463
|
+
utils$1.isFile(data) ||
|
1464
|
+
utils$1.isBlob(data)
|
1411
1465
|
) {
|
1412
1466
|
return data;
|
1413
1467
|
}
|
1414
|
-
if (utils.isArrayBufferView(data)) {
|
1468
|
+
if (utils$1.isArrayBufferView(data)) {
|
1415
1469
|
return data.buffer;
|
1416
1470
|
}
|
1417
|
-
if (utils.isURLSearchParams(data)) {
|
1471
|
+
if (utils$1.isURLSearchParams(data)) {
|
1418
1472
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1419
1473
|
return data.toString();
|
1420
1474
|
}
|
@@ -1426,7 +1480,7 @@ const defaults = {
|
|
1426
1480
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
1427
1481
|
}
|
1428
1482
|
|
1429
|
-
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1483
|
+
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1430
1484
|
const _FormData = this.env && this.env.FormData;
|
1431
1485
|
|
1432
1486
|
return toFormData(
|
@@ -1450,7 +1504,7 @@ const defaults = {
|
|
1450
1504
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1451
1505
|
const JSONRequested = this.responseType === 'json';
|
1452
1506
|
|
1453
|
-
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
1507
|
+
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
1454
1508
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1455
1509
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1456
1510
|
|
@@ -1498,7 +1552,7 @@ const defaults = {
|
|
1498
1552
|
}
|
1499
1553
|
};
|
1500
1554
|
|
1501
|
-
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
1555
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
1502
1556
|
defaults.headers[method] = {};
|
1503
1557
|
});
|
1504
1558
|
|
@@ -1506,7 +1560,7 @@ const defaults$1 = defaults;
|
|
1506
1560
|
|
1507
1561
|
// RawAxiosHeaders whose duplicates are ignored by node
|
1508
1562
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
1509
|
-
const ignoreDuplicateOf = utils.toObjectSet([
|
1563
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
1510
1564
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
1511
1565
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
1512
1566
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
@@ -1567,7 +1621,7 @@ function normalizeValue(value) {
|
|
1567
1621
|
return value;
|
1568
1622
|
}
|
1569
1623
|
|
1570
|
-
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
1624
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
1571
1625
|
}
|
1572
1626
|
|
1573
1627
|
function parseTokens(str) {
|
@@ -1585,7 +1639,7 @@ function parseTokens(str) {
|
|
1585
1639
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
1586
1640
|
|
1587
1641
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
1588
|
-
if (utils.isFunction(filter)) {
|
1642
|
+
if (utils$1.isFunction(filter)) {
|
1589
1643
|
return filter.call(this, value, header);
|
1590
1644
|
}
|
1591
1645
|
|
@@ -1593,13 +1647,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1593
1647
|
value = header;
|
1594
1648
|
}
|
1595
1649
|
|
1596
|
-
if (!utils.isString(value)) return;
|
1650
|
+
if (!utils$1.isString(value)) return;
|
1597
1651
|
|
1598
|
-
if (utils.isString(filter)) {
|
1652
|
+
if (utils$1.isString(filter)) {
|
1599
1653
|
return value.indexOf(filter) !== -1;
|
1600
1654
|
}
|
1601
1655
|
|
1602
|
-
if (utils.isRegExp(filter)) {
|
1656
|
+
if (utils$1.isRegExp(filter)) {
|
1603
1657
|
return filter.test(value);
|
1604
1658
|
}
|
1605
1659
|
}
|
@@ -1612,7 +1666,7 @@ function formatHeader(header) {
|
|
1612
1666
|
}
|
1613
1667
|
|
1614
1668
|
function buildAccessors(obj, header) {
|
1615
|
-
const accessorName = utils.toCamelCase(' ' + header);
|
1669
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
1616
1670
|
|
1617
1671
|
['get', 'set', 'has'].forEach(methodName => {
|
1618
1672
|
Object.defineProperty(obj, methodName + accessorName, {
|
@@ -1639,7 +1693,7 @@ class AxiosHeaders {
|
|
1639
1693
|
throw new Error('header name must be a non-empty string');
|
1640
1694
|
}
|
1641
1695
|
|
1642
|
-
const key = utils.findKey(self, lHeader);
|
1696
|
+
const key = utils$1.findKey(self, lHeader);
|
1643
1697
|
|
1644
1698
|
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
1645
1699
|
self[key || _header] = normalizeValue(_value);
|
@@ -1647,11 +1701,11 @@ class AxiosHeaders {
|
|
1647
1701
|
}
|
1648
1702
|
|
1649
1703
|
const setHeaders = (headers, _rewrite) =>
|
1650
|
-
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
1704
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
1651
1705
|
|
1652
|
-
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
1706
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
1653
1707
|
setHeaders(header, valueOrRewrite);
|
1654
|
-
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1708
|
+
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1655
1709
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
1656
1710
|
} else {
|
1657
1711
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
@@ -1664,7 +1718,7 @@ class AxiosHeaders {
|
|
1664
1718
|
header = normalizeHeader(header);
|
1665
1719
|
|
1666
1720
|
if (header) {
|
1667
|
-
const key = utils.findKey(this, header);
|
1721
|
+
const key = utils$1.findKey(this, header);
|
1668
1722
|
|
1669
1723
|
if (key) {
|
1670
1724
|
const value = this[key];
|
@@ -1677,11 +1731,11 @@ class AxiosHeaders {
|
|
1677
1731
|
return parseTokens(value);
|
1678
1732
|
}
|
1679
1733
|
|
1680
|
-
if (utils.isFunction(parser)) {
|
1734
|
+
if (utils$1.isFunction(parser)) {
|
1681
1735
|
return parser.call(this, value, key);
|
1682
1736
|
}
|
1683
1737
|
|
1684
|
-
if (utils.isRegExp(parser)) {
|
1738
|
+
if (utils$1.isRegExp(parser)) {
|
1685
1739
|
return parser.exec(value);
|
1686
1740
|
}
|
1687
1741
|
|
@@ -1694,7 +1748,7 @@ class AxiosHeaders {
|
|
1694
1748
|
header = normalizeHeader(header);
|
1695
1749
|
|
1696
1750
|
if (header) {
|
1697
|
-
const key = utils.findKey(this, header);
|
1751
|
+
const key = utils$1.findKey(this, header);
|
1698
1752
|
|
1699
1753
|
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1700
1754
|
}
|
@@ -1710,7 +1764,7 @@ class AxiosHeaders {
|
|
1710
1764
|
_header = normalizeHeader(_header);
|
1711
1765
|
|
1712
1766
|
if (_header) {
|
1713
|
-
const key = utils.findKey(self, _header);
|
1767
|
+
const key = utils$1.findKey(self, _header);
|
1714
1768
|
|
1715
1769
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1716
1770
|
delete self[key];
|
@@ -1720,7 +1774,7 @@ class AxiosHeaders {
|
|
1720
1774
|
}
|
1721
1775
|
}
|
1722
1776
|
|
1723
|
-
if (utils.isArray(header)) {
|
1777
|
+
if (utils$1.isArray(header)) {
|
1724
1778
|
header.forEach(deleteHeader);
|
1725
1779
|
} else {
|
1726
1780
|
deleteHeader(header);
|
@@ -1749,8 +1803,8 @@ class AxiosHeaders {
|
|
1749
1803
|
const self = this;
|
1750
1804
|
const headers = {};
|
1751
1805
|
|
1752
|
-
utils.forEach(this, (value, header) => {
|
1753
|
-
const key = utils.findKey(headers, header);
|
1806
|
+
utils$1.forEach(this, (value, header) => {
|
1807
|
+
const key = utils$1.findKey(headers, header);
|
1754
1808
|
|
1755
1809
|
if (key) {
|
1756
1810
|
self[key] = normalizeValue(value);
|
@@ -1779,8 +1833,8 @@ class AxiosHeaders {
|
|
1779
1833
|
toJSON(asStrings) {
|
1780
1834
|
const obj = Object.create(null);
|
1781
1835
|
|
1782
|
-
utils.forEach(this, (value, header) => {
|
1783
|
-
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
1836
|
+
utils$1.forEach(this, (value, header) => {
|
1837
|
+
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
1784
1838
|
});
|
1785
1839
|
|
1786
1840
|
return obj;
|
@@ -1827,7 +1881,7 @@ class AxiosHeaders {
|
|
1827
1881
|
}
|
1828
1882
|
}
|
1829
1883
|
|
1830
|
-
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1884
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1831
1885
|
|
1832
1886
|
return this;
|
1833
1887
|
}
|
@@ -1836,7 +1890,7 @@ class AxiosHeaders {
|
|
1836
1890
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1837
1891
|
|
1838
1892
|
// reserved names hotfix
|
1839
|
-
utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
1893
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
1840
1894
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
1841
1895
|
return {
|
1842
1896
|
get: () => value,
|
@@ -1846,7 +1900,7 @@ utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
1846
1900
|
}
|
1847
1901
|
});
|
1848
1902
|
|
1849
|
-
utils.freezeMethods(AxiosHeaders);
|
1903
|
+
utils$1.freezeMethods(AxiosHeaders);
|
1850
1904
|
|
1851
1905
|
const AxiosHeaders$1 = AxiosHeaders;
|
1852
1906
|
|
@@ -1864,7 +1918,7 @@ function transformData(fns, response) {
|
|
1864
1918
|
const headers = AxiosHeaders$1.from(context.headers);
|
1865
1919
|
let data = context.data;
|
1866
1920
|
|
1867
|
-
utils.forEach(fns, function transform(fn) {
|
1921
|
+
utils$1.forEach(fns, function transform(fn) {
|
1868
1922
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1869
1923
|
});
|
1870
1924
|
|
@@ -1892,7 +1946,7 @@ function CanceledError(message, config, request) {
|
|
1892
1946
|
this.name = 'CanceledError';
|
1893
1947
|
}
|
1894
1948
|
|
1895
|
-
utils.inherits(CanceledError, AxiosError, {
|
1949
|
+
utils$1.inherits(CanceledError, AxiosError, {
|
1896
1950
|
__CANCEL__: true
|
1897
1951
|
});
|
1898
1952
|
|
@@ -1965,7 +2019,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
1965
2019
|
return requestedURL;
|
1966
2020
|
}
|
1967
2021
|
|
1968
|
-
const VERSION = "1.
|
2022
|
+
const VERSION = "1.6.1";
|
1969
2023
|
|
1970
2024
|
function parseProtocol(url) {
|
1971
2025
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
@@ -2106,7 +2160,7 @@ const kInternals = Symbol('internals');
|
|
2106
2160
|
|
2107
2161
|
class AxiosTransformStream extends stream__default["default"].Transform{
|
2108
2162
|
constructor(options) {
|
2109
|
-
options = utils.toFlatObject(options, {
|
2163
|
+
options = utils$1.toFlatObject(options, {
|
2110
2164
|
maxRate: 0,
|
2111
2165
|
chunkSize: 64 * 1024,
|
2112
2166
|
minChunkSize: 100,
|
@@ -2114,7 +2168,7 @@ class AxiosTransformStream extends stream__default["default"].Transform{
|
|
2114
2168
|
ticksRate: 2,
|
2115
2169
|
samplesCount: 15
|
2116
2170
|
}, null, (prop, source) => {
|
2117
|
-
return !utils.isUndefined(source[prop]);
|
2171
|
+
return !utils$1.isUndefined(source[prop]);
|
2118
2172
|
});
|
2119
2173
|
|
2120
2174
|
super({
|
@@ -2303,7 +2357,7 @@ const readBlob = async function* (blob) {
|
|
2303
2357
|
|
2304
2358
|
const readBlob$1 = readBlob;
|
2305
2359
|
|
2306
|
-
const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_';
|
2360
|
+
const BOUNDARY_ALPHABET = utils$1.ALPHABET.ALPHA_DIGIT + '-_';
|
2307
2361
|
|
2308
2362
|
const textEncoder = new util.TextEncoder();
|
2309
2363
|
|
@@ -2314,7 +2368,7 @@ const CRLF_BYTES_COUNT = 2;
|
|
2314
2368
|
class FormDataPart {
|
2315
2369
|
constructor(name, value) {
|
2316
2370
|
const {escapeName} = this.constructor;
|
2317
|
-
const isStringValue = utils.isString(value);
|
2371
|
+
const isStringValue = utils$1.isString(value);
|
2318
2372
|
|
2319
2373
|
let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
|
2320
2374
|
!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''
|
@@ -2341,7 +2395,7 @@ class FormDataPart {
|
|
2341
2395
|
|
2342
2396
|
const {value} = this;
|
2343
2397
|
|
2344
|
-
if(utils.isTypedArray(value)) {
|
2398
|
+
if(utils$1.isTypedArray(value)) {
|
2345
2399
|
yield value;
|
2346
2400
|
} else {
|
2347
2401
|
yield* readBlob$1(value);
|
@@ -2363,10 +2417,10 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
2363
2417
|
const {
|
2364
2418
|
tag = 'form-data-boundary',
|
2365
2419
|
size = 25,
|
2366
|
-
boundary = tag + '-' + utils.generateString(size, BOUNDARY_ALPHABET)
|
2420
|
+
boundary = tag + '-' + utils$1.generateString(size, BOUNDARY_ALPHABET)
|
2367
2421
|
} = options || {};
|
2368
2422
|
|
2369
|
-
if(!utils.isFormData(form)) {
|
2423
|
+
if(!utils$1.isFormData(form)) {
|
2370
2424
|
throw TypeError('FormData instance required');
|
2371
2425
|
}
|
2372
2426
|
|
@@ -2386,7 +2440,7 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
2386
2440
|
|
2387
2441
|
contentLength += boundaryBytes.byteLength * parts.length;
|
2388
2442
|
|
2389
|
-
contentLength = utils.toFiniteNumber(contentLength);
|
2443
|
+
contentLength = utils$1.toFiniteNumber(contentLength);
|
2390
2444
|
|
2391
2445
|
const computedHeaders = {
|
2392
2446
|
'Content-Type': `multipart/form-data; boundary=${boundary}`
|
@@ -2436,7 +2490,7 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
|
|
2436
2490
|
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
|
2437
2491
|
|
2438
2492
|
const callbackify = (fn, reducer) => {
|
2439
|
-
return utils.isAsyncFn(fn) ? function (...args) {
|
2493
|
+
return utils$1.isAsyncFn(fn) ? function (...args) {
|
2440
2494
|
const cb = args.pop();
|
2441
2495
|
fn.apply(this, args).then((value) => {
|
2442
2496
|
try {
|
@@ -2460,7 +2514,7 @@ const brotliOptions = {
|
|
2460
2514
|
finishFlush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH
|
2461
2515
|
};
|
2462
2516
|
|
2463
|
-
const isBrotliSupported = utils.isFunction(zlib__default["default"].createBrotliDecompress);
|
2517
|
+
const isBrotliSupported = utils$1.isFunction(zlib__default["default"].createBrotliDecompress);
|
2464
2518
|
|
2465
2519
|
const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"];
|
2466
2520
|
|
@@ -2540,7 +2594,7 @@ function setProxy(options, configProxy, location) {
|
|
2540
2594
|
};
|
2541
2595
|
}
|
2542
2596
|
|
2543
|
-
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
|
2597
|
+
const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(process) === 'process';
|
2544
2598
|
|
2545
2599
|
// temporary hotfix
|
2546
2600
|
|
@@ -2569,6 +2623,18 @@ const wrapAsync = (asyncExecutor) => {
|
|
2569
2623
|
})
|
2570
2624
|
};
|
2571
2625
|
|
2626
|
+
const resolveFamily = ({address, family}) => {
|
2627
|
+
if (!utils$1.isString(address)) {
|
2628
|
+
throw TypeError('address must be a string');
|
2629
|
+
}
|
2630
|
+
return ({
|
2631
|
+
address,
|
2632
|
+
family: family || (address.indexOf('.') < 0 ? 6 : 4)
|
2633
|
+
});
|
2634
|
+
};
|
2635
|
+
|
2636
|
+
const buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(address) ? address : {address, family});
|
2637
|
+
|
2572
2638
|
/*eslint consistent-return:0*/
|
2573
2639
|
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
2574
2640
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
@@ -2579,15 +2645,16 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2579
2645
|
let rejected = false;
|
2580
2646
|
let req;
|
2581
2647
|
|
2582
|
-
if (lookup
|
2583
|
-
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2648
|
+
if (lookup) {
|
2649
|
+
const _lookup = callbackify$1(lookup, (value) => utils$1.isArray(value) ? value : [value]);
|
2650
|
+
// hotfix to support opt.all option which is required for node 20.x
|
2651
|
+
lookup = (hostname, opt, cb) => {
|
2652
|
+
_lookup(hostname, opt, (err, arg0, arg1) => {
|
2653
|
+
const addresses = utils$1.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
2654
|
+
|
2655
|
+
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
2656
|
+
});
|
2657
|
+
};
|
2591
2658
|
}
|
2592
2659
|
|
2593
2660
|
// temporary internal emitter until the AxiosRequest class will be implemented
|
@@ -2655,7 +2722,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2655
2722
|
convertedData = convertedData.toString(responseEncoding);
|
2656
2723
|
|
2657
2724
|
if (!responseEncoding || responseEncoding === 'utf8') {
|
2658
|
-
convertedData = utils.stripBOM(convertedData);
|
2725
|
+
convertedData = utils$1.stripBOM(convertedData);
|
2659
2726
|
}
|
2660
2727
|
} else if (responseType === 'stream') {
|
2661
2728
|
convertedData = stream__default["default"].Readable.from(convertedData);
|
@@ -2693,7 +2760,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2693
2760
|
let maxDownloadRate = undefined;
|
2694
2761
|
|
2695
2762
|
// support for spec compliant FormData objects
|
2696
|
-
if (utils.isSpecCompliantForm(data)) {
|
2763
|
+
if (utils$1.isSpecCompliantForm(data)) {
|
2697
2764
|
const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
|
2698
2765
|
|
2699
2766
|
data = formDataToStream$1(data, (formHeaders) => {
|
@@ -2703,7 +2770,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2703
2770
|
boundary: userBoundary && userBoundary[1] || undefined
|
2704
2771
|
});
|
2705
2772
|
// support for https://www.npmjs.com/package/form-data api
|
2706
|
-
} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
2773
|
+
} else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
|
2707
2774
|
headers.set(data.getHeaders());
|
2708
2775
|
|
2709
2776
|
if (!headers.hasContentLength()) {
|
@@ -2714,14 +2781,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2714
2781
|
} catch (e) {
|
2715
2782
|
}
|
2716
2783
|
}
|
2717
|
-
} else if (utils.isBlob(data)) {
|
2784
|
+
} else if (utils$1.isBlob(data)) {
|
2718
2785
|
data.size && headers.setContentType(data.type || 'application/octet-stream');
|
2719
2786
|
headers.setContentLength(data.size || 0);
|
2720
2787
|
data = stream__default["default"].Readable.from(readBlob$1(data));
|
2721
|
-
} else if (data && !utils.isStream(data)) {
|
2722
|
-
if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
|
2788
|
+
} else if (data && !utils$1.isStream(data)) {
|
2789
|
+
if (Buffer.isBuffer(data)) ; else if (utils$1.isArrayBuffer(data)) {
|
2723
2790
|
data = Buffer.from(new Uint8Array(data));
|
2724
|
-
} else if (utils.isString(data)) {
|
2791
|
+
} else if (utils$1.isString(data)) {
|
2725
2792
|
data = Buffer.from(data, 'utf-8');
|
2726
2793
|
} else {
|
2727
2794
|
return reject(new AxiosError(
|
@@ -2743,9 +2810,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2743
2810
|
}
|
2744
2811
|
}
|
2745
2812
|
|
2746
|
-
const contentLength = utils.toFiniteNumber(headers.getContentLength());
|
2813
|
+
const contentLength = utils$1.toFiniteNumber(headers.getContentLength());
|
2747
2814
|
|
2748
|
-
if (utils.isArray(maxRate)) {
|
2815
|
+
if (utils$1.isArray(maxRate)) {
|
2749
2816
|
maxUploadRate = maxRate[0];
|
2750
2817
|
maxDownloadRate = maxRate[1];
|
2751
2818
|
} else {
|
@@ -2753,14 +2820,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2753
2820
|
}
|
2754
2821
|
|
2755
2822
|
if (data && (onUploadProgress || maxUploadRate)) {
|
2756
|
-
if (!utils.isStream(data)) {
|
2823
|
+
if (!utils$1.isStream(data)) {
|
2757
2824
|
data = stream__default["default"].Readable.from(data, {objectMode: false});
|
2758
2825
|
}
|
2759
2826
|
|
2760
2827
|
data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
|
2761
2828
|
length: contentLength,
|
2762
|
-
maxRate: utils.toFiniteNumber(maxUploadRate)
|
2763
|
-
})], utils.noop);
|
2829
|
+
maxRate: utils$1.toFiniteNumber(maxUploadRate)
|
2830
|
+
})], utils$1.noop);
|
2764
2831
|
|
2765
2832
|
onUploadProgress && data.on('progress', progress => {
|
2766
2833
|
onUploadProgress(Object.assign(progress, {
|
@@ -2819,7 +2886,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2819
2886
|
};
|
2820
2887
|
|
2821
2888
|
// cacheable-lookup integration hotfix
|
2822
|
-
!utils.isUndefined(lookup) && (options.lookup = lookup);
|
2889
|
+
!utils$1.isUndefined(lookup) && (options.lookup = lookup);
|
2823
2890
|
|
2824
2891
|
if (config.socketPath) {
|
2825
2892
|
options.socketPath = config.socketPath;
|
@@ -2867,8 +2934,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2867
2934
|
|
2868
2935
|
if (onDownloadProgress) {
|
2869
2936
|
const transformStream = new AxiosTransformStream$1({
|
2870
|
-
length: utils.toFiniteNumber(responseLength),
|
2871
|
-
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
2937
|
+
length: utils$1.toFiniteNumber(responseLength),
|
2938
|
+
maxRate: utils$1.toFiniteNumber(maxDownloadRate)
|
2872
2939
|
});
|
2873
2940
|
|
2874
2941
|
onDownloadProgress && transformStream.on('progress', progress => {
|
@@ -2923,7 +2990,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2923
2990
|
}
|
2924
2991
|
}
|
2925
2992
|
|
2926
|
-
responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils.noop) : streams[0];
|
2993
|
+
responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils$1.noop) : streams[0];
|
2927
2994
|
|
2928
2995
|
const offListeners = stream__default["default"].finished(responseStream, () => {
|
2929
2996
|
offListeners();
|
@@ -2985,12 +3052,12 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2985
3052
|
if (responseType !== 'arraybuffer') {
|
2986
3053
|
responseData = responseData.toString(responseEncoding);
|
2987
3054
|
if (!responseEncoding || responseEncoding === 'utf8') {
|
2988
|
-
responseData = utils.stripBOM(responseData);
|
3055
|
+
responseData = utils$1.stripBOM(responseData);
|
2989
3056
|
}
|
2990
3057
|
}
|
2991
3058
|
response.data = responseData;
|
2992
3059
|
} catch (err) {
|
2993
|
-
reject(AxiosError.from(err, null, config, response.request, response));
|
3060
|
+
return reject(AxiosError.from(err, null, config, response.request, response));
|
2994
3061
|
}
|
2995
3062
|
settle(resolve, reject, response);
|
2996
3063
|
});
|
@@ -3062,7 +3129,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
3062
3129
|
|
3063
3130
|
|
3064
3131
|
// Send the request
|
3065
|
-
if (utils.isStream(data)) {
|
3132
|
+
if (utils$1.isStream(data)) {
|
3066
3133
|
let ended = false;
|
3067
3134
|
let errored = false;
|
3068
3135
|
|
@@ -3088,7 +3155,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
3088
3155
|
});
|
3089
3156
|
};
|
3090
3157
|
|
3091
|
-
const cookies = platform.
|
3158
|
+
const cookies = platform.hasStandardBrowserEnv ?
|
3092
3159
|
|
3093
3160
|
// Standard browser envs support document.cookie
|
3094
3161
|
(function standardBrowserEnv() {
|
@@ -3097,15 +3164,15 @@ const cookies = platform.isStandardBrowserEnv ?
|
|
3097
3164
|
const cookie = [];
|
3098
3165
|
cookie.push(name + '=' + encodeURIComponent(value));
|
3099
3166
|
|
3100
|
-
if (utils.isNumber(expires)) {
|
3167
|
+
if (utils$1.isNumber(expires)) {
|
3101
3168
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
3102
3169
|
}
|
3103
3170
|
|
3104
|
-
if (utils.isString(path)) {
|
3171
|
+
if (utils$1.isString(path)) {
|
3105
3172
|
cookie.push('path=' + path);
|
3106
3173
|
}
|
3107
3174
|
|
3108
|
-
if (utils.isString(domain)) {
|
3175
|
+
if (utils$1.isString(domain)) {
|
3109
3176
|
cookie.push('domain=' + domain);
|
3110
3177
|
}
|
3111
3178
|
|
@@ -3136,7 +3203,7 @@ const cookies = platform.isStandardBrowserEnv ?
|
|
3136
3203
|
};
|
3137
3204
|
})();
|
3138
3205
|
|
3139
|
-
const isURLSameOrigin = platform.
|
3206
|
+
const isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
3140
3207
|
|
3141
3208
|
// Standard browser envs have full support of the APIs needed to test
|
3142
3209
|
// whether the request URL is of the same origin as current location.
|
@@ -3186,7 +3253,7 @@ const isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
3186
3253
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
3187
3254
|
*/
|
3188
3255
|
return function isURLSameOrigin(requestURL) {
|
3189
|
-
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
3256
|
+
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
3190
3257
|
return (parsed.protocol === originURL.protocol &&
|
3191
3258
|
parsed.host === originURL.host);
|
3192
3259
|
};
|
@@ -3248,14 +3315,13 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3248
3315
|
|
3249
3316
|
let contentType;
|
3250
3317
|
|
3251
|
-
if (utils.isFormData(requestData)) {
|
3252
|
-
if (platform.
|
3318
|
+
if (utils$1.isFormData(requestData)) {
|
3319
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
3253
3320
|
requestHeaders.setContentType(false); // Let the browser set it
|
3254
|
-
} else if(
|
3255
|
-
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
3256
|
-
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
3321
|
+
} else if ((contentType = requestHeaders.getContentType()) !== false) {
|
3257
3322
|
// fix semicolon duplication issue for ReactNative FormData implementation
|
3258
|
-
|
3323
|
+
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
3324
|
+
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
3259
3325
|
}
|
3260
3326
|
}
|
3261
3327
|
|
@@ -3371,10 +3437,10 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3371
3437
|
// Add xsrf header
|
3372
3438
|
// This is only done if running in a standard browser environment.
|
3373
3439
|
// Specifically not if we're in a web worker, or react-native.
|
3374
|
-
if (platform.
|
3440
|
+
if (platform.hasStandardBrowserEnv) {
|
3375
3441
|
// Add xsrf header
|
3376
|
-
|
3377
|
-
|
3442
|
+
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
|
3443
|
+
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
3378
3444
|
|
3379
3445
|
if (xsrfValue) {
|
3380
3446
|
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
@@ -3386,13 +3452,13 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3386
3452
|
|
3387
3453
|
// Add headers to the request
|
3388
3454
|
if ('setRequestHeader' in request) {
|
3389
|
-
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
3455
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
3390
3456
|
request.setRequestHeader(key, val);
|
3391
3457
|
});
|
3392
3458
|
}
|
3393
3459
|
|
3394
3460
|
// Add withCredentials to request if needed
|
3395
|
-
if (!utils.isUndefined(config.withCredentials)) {
|
3461
|
+
if (!utils$1.isUndefined(config.withCredentials)) {
|
3396
3462
|
request.withCredentials = !!config.withCredentials;
|
3397
3463
|
}
|
3398
3464
|
|
@@ -3447,7 +3513,7 @@ const knownAdapters = {
|
|
3447
3513
|
xhr: xhrAdapter
|
3448
3514
|
};
|
3449
3515
|
|
3450
|
-
utils.forEach(knownAdapters, (fn, value) => {
|
3516
|
+
utils$1.forEach(knownAdapters, (fn, value) => {
|
3451
3517
|
if (fn) {
|
3452
3518
|
try {
|
3453
3519
|
Object.defineProperty(fn, 'name', {value});
|
@@ -3460,11 +3526,11 @@ utils.forEach(knownAdapters, (fn, value) => {
|
|
3460
3526
|
|
3461
3527
|
const renderReason = (reason) => `- ${reason}`;
|
3462
3528
|
|
3463
|
-
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
3529
|
+
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
3464
3530
|
|
3465
3531
|
const adapters = {
|
3466
3532
|
getAdapter: (adapters) => {
|
3467
|
-
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
3533
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
3468
3534
|
|
3469
3535
|
const {length} = adapters;
|
3470
3536
|
let nameOrAdapter;
|
@@ -3605,11 +3671,11 @@ function mergeConfig(config1, config2) {
|
|
3605
3671
|
const config = {};
|
3606
3672
|
|
3607
3673
|
function getMergedValue(target, source, caseless) {
|
3608
|
-
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
3609
|
-
return utils.merge.call({caseless}, target, source);
|
3610
|
-
} else if (utils.isPlainObject(source)) {
|
3611
|
-
return utils.merge({}, source);
|
3612
|
-
} else if (utils.isArray(source)) {
|
3674
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
3675
|
+
return utils$1.merge.call({caseless}, target, source);
|
3676
|
+
} else if (utils$1.isPlainObject(source)) {
|
3677
|
+
return utils$1.merge({}, source);
|
3678
|
+
} else if (utils$1.isArray(source)) {
|
3613
3679
|
return source.slice();
|
3614
3680
|
}
|
3615
3681
|
return source;
|
@@ -3617,25 +3683,25 @@ function mergeConfig(config1, config2) {
|
|
3617
3683
|
|
3618
3684
|
// eslint-disable-next-line consistent-return
|
3619
3685
|
function mergeDeepProperties(a, b, caseless) {
|
3620
|
-
if (!utils.isUndefined(b)) {
|
3686
|
+
if (!utils$1.isUndefined(b)) {
|
3621
3687
|
return getMergedValue(a, b, caseless);
|
3622
|
-
} else if (!utils.isUndefined(a)) {
|
3688
|
+
} else if (!utils$1.isUndefined(a)) {
|
3623
3689
|
return getMergedValue(undefined, a, caseless);
|
3624
3690
|
}
|
3625
3691
|
}
|
3626
3692
|
|
3627
3693
|
// eslint-disable-next-line consistent-return
|
3628
3694
|
function valueFromConfig2(a, b) {
|
3629
|
-
if (!utils.isUndefined(b)) {
|
3695
|
+
if (!utils$1.isUndefined(b)) {
|
3630
3696
|
return getMergedValue(undefined, b);
|
3631
3697
|
}
|
3632
3698
|
}
|
3633
3699
|
|
3634
3700
|
// eslint-disable-next-line consistent-return
|
3635
3701
|
function defaultToConfig2(a, b) {
|
3636
|
-
if (!utils.isUndefined(b)) {
|
3702
|
+
if (!utils$1.isUndefined(b)) {
|
3637
3703
|
return getMergedValue(undefined, b);
|
3638
|
-
} else if (!utils.isUndefined(a)) {
|
3704
|
+
} else if (!utils$1.isUndefined(a)) {
|
3639
3705
|
return getMergedValue(undefined, a);
|
3640
3706
|
}
|
3641
3707
|
}
|
@@ -3680,10 +3746,10 @@ function mergeConfig(config1, config2) {
|
|
3680
3746
|
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
3681
3747
|
};
|
3682
3748
|
|
3683
|
-
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
3749
|
+
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
3684
3750
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
3685
3751
|
const configValue = merge(config1[prop], config2[prop], prop);
|
3686
|
-
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
3752
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
3687
3753
|
});
|
3688
3754
|
|
3689
3755
|
return config;
|
@@ -3825,7 +3891,7 @@ class Axios {
|
|
3825
3891
|
}
|
3826
3892
|
|
3827
3893
|
if (paramsSerializer != null) {
|
3828
|
-
if (utils.isFunction(paramsSerializer)) {
|
3894
|
+
if (utils$1.isFunction(paramsSerializer)) {
|
3829
3895
|
config.paramsSerializer = {
|
3830
3896
|
serialize: paramsSerializer
|
3831
3897
|
};
|
@@ -3841,12 +3907,12 @@ class Axios {
|
|
3841
3907
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
3842
3908
|
|
3843
3909
|
// Flatten headers
|
3844
|
-
let contextHeaders = headers && utils.merge(
|
3910
|
+
let contextHeaders = headers && utils$1.merge(
|
3845
3911
|
headers.common,
|
3846
3912
|
headers[config.method]
|
3847
3913
|
);
|
3848
3914
|
|
3849
|
-
headers && utils.forEach(
|
3915
|
+
headers && utils$1.forEach(
|
3850
3916
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
3851
3917
|
(method) => {
|
3852
3918
|
delete headers[method];
|
@@ -3933,7 +3999,7 @@ class Axios {
|
|
3933
3999
|
}
|
3934
4000
|
|
3935
4001
|
// Provide aliases for supported request methods
|
3936
|
-
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
4002
|
+
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
3937
4003
|
/*eslint func-names:0*/
|
3938
4004
|
Axios.prototype[method] = function(url, config) {
|
3939
4005
|
return this.request(mergeConfig(config || {}, {
|
@@ -3944,7 +4010,7 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
|
|
3944
4010
|
};
|
3945
4011
|
});
|
3946
4012
|
|
3947
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
4013
|
+
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
3948
4014
|
/*eslint func-names:0*/
|
3949
4015
|
|
3950
4016
|
function generateHTTPMethod(isForm) {
|
@@ -4120,7 +4186,7 @@ function spread(callback) {
|
|
4120
4186
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
4121
4187
|
*/
|
4122
4188
|
function isAxiosError(payload) {
|
4123
|
-
return utils.isObject(payload) && (payload.isAxiosError === true);
|
4189
|
+
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
4124
4190
|
}
|
4125
4191
|
|
4126
4192
|
const HttpStatusCode = {
|
@@ -4207,10 +4273,10 @@ function createInstance(defaultConfig) {
|
|
4207
4273
|
const instance = bind(Axios$1.prototype.request, context);
|
4208
4274
|
|
4209
4275
|
// Copy axios.prototype to instance
|
4210
|
-
utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
4276
|
+
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
4211
4277
|
|
4212
4278
|
// Copy context to instance
|
4213
|
-
utils.extend(instance, context, null, {allOwnKeys: true});
|
4279
|
+
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
4214
4280
|
|
4215
4281
|
// Factory for creating new instances
|
4216
4282
|
instance.create = function create(instanceConfig) {
|
@@ -4254,7 +4320,7 @@ axios.mergeConfig = mergeConfig;
|
|
4254
4320
|
|
4255
4321
|
axios.AxiosHeaders = AxiosHeaders$1;
|
4256
4322
|
|
4257
|
-
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
4323
|
+
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
4258
4324
|
|
4259
4325
|
axios.getAdapter = adapters.getAdapter;
|
4260
4326
|
|