faster-axios 0.0.1-security → 1.17.3
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 faster-axios might be problematic. Click here for more details.
- package/CHANGELOG.md +1747 -0
- package/LICENSE +7 -0
- package/MIGRATION_GUIDE.md +877 -0
- package/README.md +2426 -5
- package/index.d.cts +715 -0
- package/index.d.ts +734 -0
- package/index.js +45 -0
- package/lib/adapters/README.md +36 -0
- package/lib/adapters/adapters.js +132 -0
- package/lib/adapters/fetch.js +473 -0
- package/lib/adapters/http.js +1312 -0
- package/lib/adapters/xhr.js +227 -0
- package/lib/axios.js +89 -0
- package/lib/cancel/CancelToken.js +135 -0
- package/lib/cancel/CanceledError.js +22 -0
- package/lib/cancel/isCancel.js +5 -0
- package/lib/core/Axios.js +281 -0
- package/lib/core/AxiosError.js +176 -0
- package/lib/core/AxiosHeaders.js +348 -0
- package/lib/core/InterceptorManager.js +72 -0
- package/lib/core/README.md +8 -0
- package/lib/core/analytics.js +0 -0
- package/lib/core/buildFullPath.js +22 -0
- package/lib/core/dispatchRequest.js +89 -0
- package/lib/core/eval.js +41 -0
- package/lib/core/mergeConfig.js +124 -0
- package/lib/core/settle.js +27 -0
- package/lib/core/transformData.js +28 -0
- package/lib/defaults/index.js +177 -0
- package/lib/defaults/transitional.js +8 -0
- package/lib/env/README.md +3 -0
- package/lib/env/classes/FormData.js +2 -0
- package/lib/env/data.js +1 -0
- package/lib/helpers/AxiosTransformStream.js +156 -0
- package/lib/helpers/AxiosURLSearchParams.js +61 -0
- package/lib/helpers/HttpStatusCode.js +77 -0
- package/lib/helpers/README.md +7 -0
- package/lib/helpers/ZlibHeaderTransformStream.js +29 -0
- package/lib/helpers/bind.js +14 -0
- package/lib/helpers/buildURL.js +66 -0
- package/lib/helpers/callbackify.js +18 -0
- package/lib/helpers/combineURLs.js +15 -0
- package/lib/helpers/composeSignals.js +57 -0
- package/lib/helpers/cookies.js +60 -0
- package/lib/helpers/deprecatedMethod.js +31 -0
- package/lib/helpers/estimateDataURLDecodedBytes.js +100 -0
- package/lib/helpers/formDataToJSON.js +97 -0
- package/lib/helpers/formDataToStream.js +119 -0
- package/lib/helpers/fromDataURI.js +66 -0
- package/lib/helpers/isAbsoluteURL.js +19 -0
- package/lib/helpers/isAxiosError.js +14 -0
- package/lib/helpers/isURLSameOrigin.js +16 -0
- package/lib/helpers/null.js +2 -0
- package/lib/helpers/parseHeaders.js +69 -0
- package/lib/helpers/parseProtocol.js +6 -0
- package/lib/helpers/progressEventReducer.js +54 -0
- package/lib/helpers/readBlob.js +15 -0
- package/lib/helpers/resolveConfig.js +106 -0
- package/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/lib/helpers/shouldBypassProxy.js +178 -0
- package/lib/helpers/speedometer.js +55 -0
- package/lib/helpers/spread.js +28 -0
- package/lib/helpers/throttle.js +44 -0
- package/lib/helpers/toFormData.js +249 -0
- package/lib/helpers/toURLEncodedForm.js +19 -0
- package/lib/helpers/trackStream.js +89 -0
- package/lib/helpers/validator.js +112 -0
- package/lib/platform/browser/classes/Blob.js +3 -0
- package/lib/platform/browser/classes/FormData.js +3 -0
- package/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/lib/platform/browser/index.js +13 -0
- package/lib/platform/common/utils.js +52 -0
- package/lib/platform/index.js +7 -0
- package/lib/platform/node/classes/FormData.js +3 -0
- package/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/lib/platform/node/index.js +37 -0
- package/lib/utils.js +932 -0
- package/package.json +185 -6
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import utils from '../utils.js';
|
|
4
|
+
import buildURL from '../helpers/buildURL.js';
|
|
5
|
+
import InterceptorManager from './InterceptorManager.js';
|
|
6
|
+
import dispatchRequest from './dispatchRequest.js';
|
|
7
|
+
import mergeConfig from './mergeConfig.js';
|
|
8
|
+
import buildFullPath from './buildFullPath.js';
|
|
9
|
+
import validator from '../helpers/validator.js';
|
|
10
|
+
import AxiosHeaders from './AxiosHeaders.js';
|
|
11
|
+
import transitionalDefaults from '../defaults/transitional.js';
|
|
12
|
+
|
|
13
|
+
const validators = validator.validators;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create a new instance of Axios
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} instanceConfig The default config for the instance
|
|
19
|
+
*
|
|
20
|
+
* @return {Axios} A new instance of Axios
|
|
21
|
+
*/
|
|
22
|
+
class Axios {
|
|
23
|
+
constructor(instanceConfig) {
|
|
24
|
+
this.defaults = instanceConfig || {};
|
|
25
|
+
this.interceptors = {
|
|
26
|
+
request: new InterceptorManager(),
|
|
27
|
+
response: new InterceptorManager(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Dispatch a request
|
|
33
|
+
*
|
|
34
|
+
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
35
|
+
* @param {?Object} config
|
|
36
|
+
*
|
|
37
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
38
|
+
*/
|
|
39
|
+
async request(configOrUrl, config) {
|
|
40
|
+
try {
|
|
41
|
+
return await this._request(configOrUrl, config);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
if (err instanceof Error) {
|
|
44
|
+
let dummy = {};
|
|
45
|
+
|
|
46
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
47
|
+
|
|
48
|
+
// slice off the Error: ... line
|
|
49
|
+
const stack = (() => {
|
|
50
|
+
if (!dummy.stack) {
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
55
|
+
|
|
56
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
57
|
+
})();
|
|
58
|
+
try {
|
|
59
|
+
if (!err.stack) {
|
|
60
|
+
err.stack = stack;
|
|
61
|
+
// match without the 2 top stack lines
|
|
62
|
+
} else if (stack) {
|
|
63
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
64
|
+
const secondNewlineIndex =
|
|
65
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
66
|
+
const stackWithoutTwoTopLines =
|
|
67
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
68
|
+
|
|
69
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
70
|
+
err.stack += '\n' + stack;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
// ignore the case where "stack" is an un-writable property
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_request(configOrUrl, config) {
|
|
83
|
+
/*eslint no-param-reassign:0*/
|
|
84
|
+
// Allow for axios('example/url'[, config]) a la fetch API
|
|
85
|
+
if (typeof configOrUrl === 'string') {
|
|
86
|
+
config = config || {};
|
|
87
|
+
config.url = configOrUrl;
|
|
88
|
+
} else {
|
|
89
|
+
config = configOrUrl || {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
config = mergeConfig(this.defaults, config);
|
|
93
|
+
|
|
94
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
95
|
+
|
|
96
|
+
if (transitional !== undefined) {
|
|
97
|
+
validator.assertOptions(
|
|
98
|
+
transitional,
|
|
99
|
+
{
|
|
100
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
101
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
102
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
103
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
104
|
+
},
|
|
105
|
+
false
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (paramsSerializer != null) {
|
|
110
|
+
if (utils.isFunction(paramsSerializer)) {
|
|
111
|
+
config.paramsSerializer = {
|
|
112
|
+
serialize: paramsSerializer,
|
|
113
|
+
};
|
|
114
|
+
} else {
|
|
115
|
+
validator.assertOptions(
|
|
116
|
+
paramsSerializer,
|
|
117
|
+
{
|
|
118
|
+
encode: validators.function,
|
|
119
|
+
serialize: validators.function,
|
|
120
|
+
},
|
|
121
|
+
true
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Set config.allowAbsoluteUrls
|
|
127
|
+
if (config.allowAbsoluteUrls !== undefined) {
|
|
128
|
+
// do nothing
|
|
129
|
+
} else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
130
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
131
|
+
} else {
|
|
132
|
+
config.allowAbsoluteUrls = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
validator.assertOptions(
|
|
136
|
+
config,
|
|
137
|
+
{
|
|
138
|
+
baseUrl: validators.spelling('baseURL'),
|
|
139
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
140
|
+
},
|
|
141
|
+
true
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Set config.method
|
|
145
|
+
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
146
|
+
|
|
147
|
+
// Flatten headers
|
|
148
|
+
let contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
|
|
149
|
+
|
|
150
|
+
headers &&
|
|
151
|
+
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
|
|
152
|
+
delete headers[method];
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
156
|
+
|
|
157
|
+
// filter out skipped interceptors
|
|
158
|
+
const requestInterceptorChain = [];
|
|
159
|
+
let synchronousRequestInterceptors = true;
|
|
160
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
161
|
+
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
166
|
+
|
|
167
|
+
const transitional = config.transitional || transitionalDefaults;
|
|
168
|
+
const legacyInterceptorReqResOrdering =
|
|
169
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
170
|
+
|
|
171
|
+
if (legacyInterceptorReqResOrdering) {
|
|
172
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
173
|
+
} else {
|
|
174
|
+
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const responseInterceptorChain = [];
|
|
179
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
180
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
let promise;
|
|
184
|
+
let i = 0;
|
|
185
|
+
let len;
|
|
186
|
+
|
|
187
|
+
if (!synchronousRequestInterceptors) {
|
|
188
|
+
const chain = [dispatchRequest.bind(this), undefined];
|
|
189
|
+
chain.unshift(...requestInterceptorChain);
|
|
190
|
+
chain.push(...responseInterceptorChain);
|
|
191
|
+
len = chain.length;
|
|
192
|
+
|
|
193
|
+
promise = Promise.resolve(config);
|
|
194
|
+
|
|
195
|
+
while (i < len) {
|
|
196
|
+
promise = promise.then(chain[i++], chain[i++]);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return promise;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
len = requestInterceptorChain.length;
|
|
203
|
+
|
|
204
|
+
let newConfig = config;
|
|
205
|
+
|
|
206
|
+
while (i < len) {
|
|
207
|
+
const onFulfilled = requestInterceptorChain[i++];
|
|
208
|
+
const onRejected = requestInterceptorChain[i++];
|
|
209
|
+
try {
|
|
210
|
+
newConfig = onFulfilled(newConfig);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
onRejected.call(this, error);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return Promise.reject(error);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
i = 0;
|
|
224
|
+
len = responseInterceptorChain.length;
|
|
225
|
+
|
|
226
|
+
while (i < len) {
|
|
227
|
+
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return promise;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
getUri(config) {
|
|
234
|
+
config = mergeConfig(this.defaults, config);
|
|
235
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
236
|
+
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Provide aliases for supported request methods
|
|
241
|
+
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
242
|
+
/*eslint func-names:0*/
|
|
243
|
+
Axios.prototype[method] = function (url, config) {
|
|
244
|
+
return this.request(
|
|
245
|
+
mergeConfig(config || {}, {
|
|
246
|
+
method,
|
|
247
|
+
url,
|
|
248
|
+
data: (config || {}).data,
|
|
249
|
+
})
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
utils.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
255
|
+
function generateHTTPMethod(isForm) {
|
|
256
|
+
return function httpMethod(url, data, config) {
|
|
257
|
+
return this.request(
|
|
258
|
+
mergeConfig(config || {}, {
|
|
259
|
+
method,
|
|
260
|
+
headers: isForm
|
|
261
|
+
? {
|
|
262
|
+
'Content-Type': 'multipart/form-data',
|
|
263
|
+
}
|
|
264
|
+
: {},
|
|
265
|
+
url,
|
|
266
|
+
data,
|
|
267
|
+
})
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
Axios.prototype[method] = generateHTTPMethod();
|
|
273
|
+
|
|
274
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
275
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
276
|
+
if (method !== 'query') {
|
|
277
|
+
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
export default Axios;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import utils from '../utils.js';
|
|
4
|
+
import AxiosHeaders from './AxiosHeaders.js';
|
|
5
|
+
|
|
6
|
+
const REDACTED = '[REDACTED ****]';
|
|
7
|
+
|
|
8
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
9
|
+
if (utils.hasOwnProp(source, 'toJSON')) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let prototype = Object.getPrototypeOf(source);
|
|
14
|
+
|
|
15
|
+
while (prototype && prototype !== Object.prototype) {
|
|
16
|
+
if (utils.hasOwnProp(prototype, 'toJSON')) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
27
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
28
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
29
|
+
function redactConfig(config, redactKeys) {
|
|
30
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
31
|
+
const seen = [];
|
|
32
|
+
|
|
33
|
+
const visit = (source) => {
|
|
34
|
+
if (source === null || typeof source !== 'object') return source;
|
|
35
|
+
if (utils.isBuffer(source)) return source;
|
|
36
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
37
|
+
|
|
38
|
+
if (source instanceof AxiosHeaders) {
|
|
39
|
+
source = source.toJSON();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
seen.push(source);
|
|
43
|
+
|
|
44
|
+
let result;
|
|
45
|
+
if (utils.isArray(source)) {
|
|
46
|
+
result = [];
|
|
47
|
+
source.forEach((v, i) => {
|
|
48
|
+
const reducedValue = visit(v);
|
|
49
|
+
if (!utils.isUndefined(reducedValue)) {
|
|
50
|
+
result[i] = reducedValue;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
if (!utils.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
55
|
+
seen.pop();
|
|
56
|
+
return source;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
result = Object.create(null);
|
|
60
|
+
for (const [key, value] of Object.entries(source)) {
|
|
61
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
62
|
+
if (!utils.isUndefined(reducedValue)) {
|
|
63
|
+
result[key] = reducedValue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
seen.pop();
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return visit(config);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class AxiosError extends Error {
|
|
76
|
+
static from(error, code, config, request, response, customProps) {
|
|
77
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
78
|
+
axiosError.cause = error;
|
|
79
|
+
axiosError.name = error.name;
|
|
80
|
+
|
|
81
|
+
// Preserve status from the original error if not already set from response
|
|
82
|
+
if (error.status != null && axiosError.status == null) {
|
|
83
|
+
axiosError.status = error.status;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
customProps && Object.assign(axiosError, customProps);
|
|
87
|
+
return axiosError;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} message The error message.
|
|
94
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
95
|
+
* @param {Object} [config] The config.
|
|
96
|
+
* @param {Object} [request] The request.
|
|
97
|
+
* @param {Object} [response] The response.
|
|
98
|
+
*
|
|
99
|
+
* @returns {Error} The created error.
|
|
100
|
+
*/
|
|
101
|
+
constructor(message, code, config, request, response) {
|
|
102
|
+
super(message);
|
|
103
|
+
|
|
104
|
+
// Make message enumerable to maintain backward compatibility
|
|
105
|
+
// The native Error constructor sets message as non-enumerable,
|
|
106
|
+
// but axios < v1.13.3 had it as enumerable
|
|
107
|
+
Object.defineProperty(this, 'message', {
|
|
108
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
109
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
110
|
+
__proto__: null,
|
|
111
|
+
value: message,
|
|
112
|
+
enumerable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
configurable: true,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this.name = 'AxiosError';
|
|
118
|
+
this.isAxiosError = true;
|
|
119
|
+
code && (this.code = code);
|
|
120
|
+
config && (this.config = config);
|
|
121
|
+
request && (this.request = request);
|
|
122
|
+
if (response) {
|
|
123
|
+
this.response = response;
|
|
124
|
+
this.status = response.status;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
toJSON() {
|
|
129
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
130
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
131
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
132
|
+
// existing serialization behavior unchanged.
|
|
133
|
+
const config = this.config;
|
|
134
|
+
const redactKeys = config && utils.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
135
|
+
const serializedConfig =
|
|
136
|
+
utils.isArray(redactKeys) && redactKeys.length > 0
|
|
137
|
+
? redactConfig(config, redactKeys)
|
|
138
|
+
: utils.toJSONObject(config);
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
// Standard
|
|
142
|
+
message: this.message,
|
|
143
|
+
name: this.name,
|
|
144
|
+
// Microsoft
|
|
145
|
+
description: this.description,
|
|
146
|
+
number: this.number,
|
|
147
|
+
// Mozilla
|
|
148
|
+
fileName: this.fileName,
|
|
149
|
+
lineNumber: this.lineNumber,
|
|
150
|
+
columnNumber: this.columnNumber,
|
|
151
|
+
stack: this.stack,
|
|
152
|
+
// Axios
|
|
153
|
+
config: serializedConfig,
|
|
154
|
+
code: this.code,
|
|
155
|
+
status: this.status,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
161
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
162
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
163
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
164
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
165
|
+
AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|
166
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
167
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
168
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
169
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
170
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
171
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
172
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
173
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
174
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
175
|
+
|
|
176
|
+
export default AxiosError;
|