axios 1.7.4 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +30 -0
- package/README.md +7 -57
- package/dist/axios.js +94 -68
- 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 +76 -57
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +76 -57
- 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 +77 -58
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +18 -18
- package/lib/adapters/http.js +1 -1
- package/lib/cancel/CancelToken.js +14 -0
- package/lib/core/AxiosError.js +5 -2
- package/lib/env/data.js +1 -1
- package/lib/helpers/composeSignals.js +31 -29
- package/lib/helpers/isURLSameOrigin.js +1 -1
- package/lib/platform/common/utils.js +5 -4
- package/package.json +1 -1
package/dist/browser/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.6 Copyright (c) 2024 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
function bind(fn, thisArg) {
|
@@ -789,7 +789,10 @@ function AxiosError(message, code, config, request, response) {
|
|
789
789
|
code && (this.code = code);
|
790
790
|
config && (this.config = config);
|
791
791
|
request && (this.request = request);
|
792
|
-
|
792
|
+
if (response) {
|
793
|
+
this.response = response;
|
794
|
+
this.status = response.status ? response.status : null;
|
795
|
+
}
|
793
796
|
}
|
794
797
|
|
795
798
|
utils$1.inherits(AxiosError, Error, {
|
@@ -809,7 +812,7 @@ utils$1.inherits(AxiosError, Error, {
|
|
809
812
|
// Axios
|
810
813
|
config: utils$1.toJSONObject(this.config),
|
811
814
|
code: this.code,
|
812
|
-
status: this.
|
815
|
+
status: this.status
|
813
816
|
};
|
814
817
|
}
|
815
818
|
});
|
@@ -1277,6 +1280,8 @@ var platform$1 = {
|
|
1277
1280
|
|
1278
1281
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
1279
1282
|
|
1283
|
+
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
1284
|
+
|
1280
1285
|
/**
|
1281
1286
|
* Determine if we're running in a standard browser environment
|
1282
1287
|
*
|
@@ -1294,10 +1299,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
|
|
1294
1299
|
*
|
1295
1300
|
* @returns {boolean}
|
1296
1301
|
*/
|
1297
|
-
const hasStandardBrowserEnv =
|
1298
|
-
(product)
|
1299
|
-
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
1300
|
-
})(typeof navigator !== 'undefined' && navigator.product);
|
1302
|
+
const hasStandardBrowserEnv = hasBrowserEnv &&
|
1303
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
1301
1304
|
|
1302
1305
|
/**
|
1303
1306
|
* Determine if we're running in a standard browser webWorker environment
|
@@ -1324,6 +1327,7 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
1324
1327
|
hasBrowserEnv: hasBrowserEnv,
|
1325
1328
|
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
1326
1329
|
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
1330
|
+
navigator: _navigator,
|
1327
1331
|
origin: origin
|
1328
1332
|
});
|
1329
1333
|
|
@@ -2153,7 +2157,7 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
2153
2157
|
// Standard browser envs have full support of the APIs needed to test
|
2154
2158
|
// whether the request URL is of the same origin as current location.
|
2155
2159
|
(function standardBrowserEnv() {
|
2156
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
2160
|
+
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
2157
2161
|
const urlParsingNode = document.createElement('a');
|
2158
2162
|
let originURL;
|
2159
2163
|
|
@@ -2633,45 +2637,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2633
2637
|
};
|
2634
2638
|
|
2635
2639
|
const composeSignals = (signals, timeout) => {
|
2636
|
-
|
2640
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
2637
2641
|
|
2638
|
-
|
2642
|
+
if (timeout || length) {
|
2643
|
+
let controller = new AbortController();
|
2639
2644
|
|
2640
|
-
|
2641
|
-
if (!aborted) {
|
2642
|
-
aborted = true;
|
2643
|
-
unsubscribe();
|
2644
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
2645
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
2646
|
-
}
|
2647
|
-
};
|
2645
|
+
let aborted;
|
2648
2646
|
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2647
|
+
const onabort = function (reason) {
|
2648
|
+
if (!aborted) {
|
2649
|
+
aborted = true;
|
2650
|
+
unsubscribe();
|
2651
|
+
const err = reason instanceof Error ? reason : this.reason;
|
2652
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
2653
|
+
}
|
2654
|
+
};
|
2652
2655
|
|
2653
|
-
|
2654
|
-
if (signals) {
|
2655
|
-
timer && clearTimeout(timer);
|
2656
|
+
let timer = timeout && setTimeout(() => {
|
2656
2657
|
timer = null;
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
signals
|
2662
|
-
|
2663
|
-
|
2658
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
2659
|
+
}, timeout);
|
2660
|
+
|
2661
|
+
const unsubscribe = () => {
|
2662
|
+
if (signals) {
|
2663
|
+
timer && clearTimeout(timer);
|
2664
|
+
timer = null;
|
2665
|
+
signals.forEach(signal => {
|
2666
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
2667
|
+
});
|
2668
|
+
signals = null;
|
2669
|
+
}
|
2670
|
+
};
|
2664
2671
|
|
2665
|
-
|
2672
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
2666
2673
|
|
2667
|
-
|
2674
|
+
const {signal} = controller;
|
2668
2675
|
|
2669
|
-
|
2676
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
2670
2677
|
|
2671
|
-
|
2672
|
-
|
2673
|
-
timer = null;
|
2674
|
-
}];
|
2678
|
+
return signal;
|
2679
|
+
}
|
2675
2680
|
};
|
2676
2681
|
|
2677
2682
|
var composeSignals$1 = composeSignals;
|
@@ -2804,7 +2809,11 @@ const getBodyLength = async (body) => {
|
|
2804
2809
|
}
|
2805
2810
|
|
2806
2811
|
if(utils$1.isSpecCompliantForm(body)) {
|
2807
|
-
|
2812
|
+
const _request = new Request(platform.origin, {
|
2813
|
+
method: 'POST',
|
2814
|
+
body,
|
2815
|
+
});
|
2816
|
+
return (await _request.arrayBuffer()).byteLength;
|
2808
2817
|
}
|
2809
2818
|
|
2810
2819
|
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
@@ -2844,18 +2853,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2844
2853
|
|
2845
2854
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
2846
2855
|
|
2847
|
-
let
|
2848
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
2849
|
-
|
2850
|
-
let finished, request;
|
2856
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
2851
2857
|
|
2852
|
-
|
2853
|
-
!finished && setTimeout(() => {
|
2854
|
-
composedSignal && composedSignal.unsubscribe();
|
2855
|
-
});
|
2858
|
+
let request;
|
2856
2859
|
|
2857
|
-
|
2858
|
-
|
2860
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
2861
|
+
composedSignal.unsubscribe();
|
2862
|
+
});
|
2859
2863
|
|
2860
2864
|
let requestContentLength;
|
2861
2865
|
|
@@ -2890,6 +2894,9 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2890
2894
|
withCredentials = withCredentials ? 'include' : 'omit';
|
2891
2895
|
}
|
2892
2896
|
|
2897
|
+
// Cloudflare Workers throws when credentials are defined
|
2898
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
2899
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
2893
2900
|
request = new Request(url, {
|
2894
2901
|
...fetchOptions,
|
2895
2902
|
signal: composedSignal,
|
@@ -2897,14 +2904,14 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2897
2904
|
headers: headers.normalize().toJSON(),
|
2898
2905
|
body: data,
|
2899
2906
|
duplex: "half",
|
2900
|
-
credentials: withCredentials
|
2907
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
2901
2908
|
});
|
2902
2909
|
|
2903
2910
|
let response = await fetch(request);
|
2904
2911
|
|
2905
2912
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
2906
2913
|
|
2907
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
2914
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
2908
2915
|
const options = {};
|
2909
2916
|
|
2910
2917
|
['status', 'statusText', 'headers'].forEach(prop => {
|
@@ -2921,7 +2928,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2921
2928
|
response = new Response(
|
2922
2929
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
2923
2930
|
flush && flush();
|
2924
|
-
|
2931
|
+
unsubscribe && unsubscribe();
|
2925
2932
|
}, encodeText),
|
2926
2933
|
options
|
2927
2934
|
);
|
@@ -2931,9 +2938,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2931
2938
|
|
2932
2939
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
2933
2940
|
|
2934
|
-
!isStreamResponse &&
|
2935
|
-
|
2936
|
-
stopTimeout && stopTimeout();
|
2941
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
2937
2942
|
|
2938
2943
|
return await new Promise((resolve, reject) => {
|
2939
2944
|
settle(resolve, reject, {
|
@@ -2946,7 +2951,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
2946
2951
|
});
|
2947
2952
|
})
|
2948
2953
|
} catch (err) {
|
2949
|
-
|
2954
|
+
unsubscribe && unsubscribe();
|
2950
2955
|
|
2951
2956
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
2952
2957
|
throw Object.assign(
|
@@ -3108,7 +3113,7 @@ function dispatchRequest(config) {
|
|
3108
3113
|
});
|
3109
3114
|
}
|
3110
3115
|
|
3111
|
-
const VERSION = "1.7.
|
3116
|
+
const VERSION = "1.7.6";
|
3112
3117
|
|
3113
3118
|
const validators$1 = {};
|
3114
3119
|
|
@@ -3515,6 +3520,20 @@ class CancelToken {
|
|
3515
3520
|
}
|
3516
3521
|
}
|
3517
3522
|
|
3523
|
+
toAbortSignal() {
|
3524
|
+
const controller = new AbortController();
|
3525
|
+
|
3526
|
+
const abort = (err) => {
|
3527
|
+
controller.abort(err);
|
3528
|
+
};
|
3529
|
+
|
3530
|
+
this.subscribe(abort);
|
3531
|
+
|
3532
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
3533
|
+
|
3534
|
+
return controller.signal;
|
3535
|
+
}
|
3536
|
+
|
3518
3537
|
/**
|
3519
3538
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
3520
3539
|
* cancels the `CancelToken`.
|