groove-dev 0.27.143 → 0.27.145
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/CLAUDE.md +0 -7
- package/node_modules/@groove-dev/cli/package.json +1 -1
- package/node_modules/@groove-dev/daemon/package.json +1 -1
- package/node_modules/@groove-dev/daemon/src/api.js +1086 -6532
- package/node_modules/@groove-dev/daemon/src/conversations.js +18 -48
- package/node_modules/@groove-dev/daemon/src/gateways/manager.js +35 -1
- package/node_modules/@groove-dev/daemon/src/index.js +3 -0
- package/node_modules/@groove-dev/daemon/src/journalist.js +23 -13
- package/node_modules/@groove-dev/daemon/src/mlx-server.js +365 -0
- package/node_modules/@groove-dev/daemon/src/model-lab.js +308 -12
- package/node_modules/@groove-dev/daemon/src/pm.js +1 -1
- package/node_modules/@groove-dev/daemon/src/process.js +2 -2
- package/node_modules/@groove-dev/daemon/src/providers/local.js +36 -8
- package/node_modules/@groove-dev/daemon/src/registry.js +21 -5
- package/node_modules/@groove-dev/daemon/src/routes/agents.js +812 -0
- package/node_modules/@groove-dev/daemon/src/routes/coordination.js +318 -0
- package/node_modules/@groove-dev/daemon/src/routes/files.js +751 -0
- package/node_modules/@groove-dev/daemon/src/routes/integrations.js +485 -0
- package/node_modules/@groove-dev/daemon/src/routes/network.js +1784 -0
- package/node_modules/@groove-dev/daemon/src/routes/providers.js +755 -0
- package/node_modules/@groove-dev/daemon/src/routes/schedules.js +110 -0
- package/node_modules/@groove-dev/daemon/src/routes/teams.js +650 -0
- package/node_modules/@groove-dev/daemon/src/scheduler.js +456 -24
- package/node_modules/@groove-dev/daemon/src/teams.js +1 -1
- package/node_modules/@groove-dev/daemon/src/validate.js +38 -1
- package/node_modules/@groove-dev/daemon/templates/mlx-setup.json +12 -0
- package/node_modules/@groove-dev/daemon/templates/tgi-setup.json +1 -1
- package/node_modules/@groove-dev/daemon/templates/vllm-setup.json +1 -1
- package/node_modules/@groove-dev/daemon/test/introducer.test.js +3 -3
- package/node_modules/@groove-dev/daemon/test/journalist.test.js +7 -10
- package/node_modules/@groove-dev/daemon/test/registry.test.js +38 -0
- package/node_modules/@groove-dev/gui/dist/assets/index-Bxc0gU06.js +1006 -0
- package/node_modules/@groove-dev/gui/dist/assets/index-C0pztKBn.css +1 -0
- package/node_modules/@groove-dev/gui/dist/index.html +2 -2
- package/node_modules/@groove-dev/gui/package.json +1 -1
- package/node_modules/@groove-dev/gui/src/{app.jsx → App.jsx} +0 -2
- package/node_modules/@groove-dev/gui/src/app.css +35 -0
- package/node_modules/@groove-dev/gui/src/components/agents/agent-config.jsx +1 -128
- package/node_modules/@groove-dev/gui/src/components/agents/agent-feed.jsx +210 -112
- package/node_modules/@groove-dev/gui/src/components/agents/agent-node.jsx +8 -13
- package/node_modules/@groove-dev/gui/src/components/agents/agent-panel.jsx +2 -70
- package/node_modules/@groove-dev/gui/src/components/agents/code-review.jsx +159 -122
- package/node_modules/@groove-dev/gui/src/components/agents/diff-viewer.jsx +23 -23
- package/node_modules/@groove-dev/gui/src/components/agents/journalist-panel.jsx +1 -1
- package/node_modules/@groove-dev/gui/src/components/agents/spawn-wizard.jsx +2 -135
- package/node_modules/@groove-dev/gui/src/components/automations/automation-card.jsx +274 -0
- package/node_modules/@groove-dev/gui/src/components/automations/automation-wizard.jsx +1136 -0
- package/node_modules/@groove-dev/gui/src/components/chat/chat-header.jsx +2 -0
- package/node_modules/@groove-dev/gui/src/components/chat/chat-input.jsx +68 -66
- package/node_modules/@groove-dev/gui/src/components/chat/chat-view.jsx +4 -8
- package/node_modules/@groove-dev/gui/src/components/dashboard/activity-feed.jsx +3 -3
- package/node_modules/@groove-dev/gui/src/components/dashboard/cache-ring.jsx +5 -5
- package/node_modules/@groove-dev/gui/src/components/dashboard/context-gauges.jsx +6 -8
- package/node_modules/@groove-dev/gui/src/components/dashboard/fleet-panel.jsx +8 -14
- package/node_modules/@groove-dev/gui/src/components/dashboard/intel-panel.jsx +238 -656
- package/node_modules/@groove-dev/gui/src/components/dashboard/kpi-card.jsx +3 -3
- package/node_modules/@groove-dev/gui/src/components/dashboard/routing-chart.jsx +3 -3
- package/node_modules/@groove-dev/gui/src/components/dashboard/team-burn-panel.jsx +1 -1
- package/node_modules/@groove-dev/gui/src/components/dashboard/token-chart.jsx +4 -4
- package/node_modules/@groove-dev/gui/src/components/lab/chat-playground.jsx +39 -31
- package/node_modules/@groove-dev/gui/src/components/lab/lab-assistant.jsx +316 -82
- package/node_modules/@groove-dev/gui/src/components/lab/metrics-panel.jsx +187 -32
- package/node_modules/@groove-dev/gui/src/components/lab/parameter-panel.jsx +200 -18
- package/node_modules/@groove-dev/gui/src/components/lab/preset-manager.jsx +17 -14
- package/node_modules/@groove-dev/gui/src/components/lab/runtime-config.jsx +335 -152
- package/node_modules/@groove-dev/gui/src/components/lab/system-prompt-editor.jsx +10 -8
- package/node_modules/@groove-dev/gui/src/components/layout/activity-bar.jsx +2 -4
- package/node_modules/@groove-dev/gui/src/components/layout/terminal-panel.jsx +4 -2
- package/node_modules/@groove-dev/gui/src/components/layout/welcome-splash.jsx +137 -108
- package/node_modules/@groove-dev/gui/src/components/network/network-health.jsx +2 -2
- package/node_modules/@groove-dev/gui/src/components/network/performance-dashboard.jsx +4 -4
- package/node_modules/@groove-dev/gui/src/components/settings/ssh-wizard.jsx +81 -99
- package/node_modules/@groove-dev/gui/src/components/ui/sheet.jsx +5 -2
- package/node_modules/@groove-dev/gui/src/components/ui/slider.jsx +8 -8
- package/node_modules/@groove-dev/gui/src/lib/cron.js +64 -0
- package/node_modules/@groove-dev/gui/src/lib/status.js +25 -24
- package/node_modules/@groove-dev/gui/src/lib/theme-hex.js +1 -0
- package/node_modules/@groove-dev/gui/src/stores/groove.js +51 -3144
- package/node_modules/@groove-dev/gui/src/stores/helpers.js +10 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/agents-slice.js +459 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/automations-slice.js +96 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/chat-slice.js +226 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/editor-slice.js +285 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/marketplace-slice.js +461 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/network-slice.js +361 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/preview-slice.js +109 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/providers-slice.js +897 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/teams-slice.js +413 -0
- package/node_modules/@groove-dev/gui/src/stores/slices/ui-slice.js +98 -0
- package/node_modules/@groove-dev/gui/src/views/agents.jsx +5 -5
- package/node_modules/@groove-dev/gui/src/views/dashboard.jsx +12 -13
- package/node_modules/@groove-dev/gui/src/views/marketplace.jsx +191 -3
- package/node_modules/@groove-dev/gui/src/views/model-lab.jsx +54 -12
- package/node_modules/@groove-dev/gui/src/views/models.jsx +419 -496
- package/node_modules/@groove-dev/gui/src/views/network.jsx +3 -3
- package/node_modules/@groove-dev/gui/src/views/settings.jsx +81 -94
- package/node_modules/@groove-dev/gui/src/views/teams.jsx +40 -483
- package/node_modules/axios/CHANGELOG.md +260 -0
- package/node_modules/axios/README.md +595 -223
- package/node_modules/axios/dist/axios.js +1460 -1090
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +1560 -1132
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +1557 -1128
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +1594 -1057
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +40 -41
- package/node_modules/axios/index.d.ts +151 -227
- package/node_modules/axios/index.js +2 -0
- package/node_modules/axios/lib/adapters/adapters.js +4 -2
- package/node_modules/axios/lib/adapters/fetch.js +147 -16
- package/node_modules/axios/lib/adapters/http.js +306 -58
- package/node_modules/axios/lib/adapters/xhr.js +6 -2
- package/node_modules/axios/lib/core/Axios.js +7 -3
- package/node_modules/axios/lib/core/AxiosError.js +120 -34
- package/node_modules/axios/lib/core/AxiosHeaders.js +27 -25
- package/node_modules/axios/lib/core/buildFullPath.js +1 -1
- package/node_modules/axios/lib/core/dispatchRequest.js +19 -7
- package/node_modules/axios/lib/core/mergeConfig.js +21 -4
- package/node_modules/axios/lib/core/settle.js +7 -11
- package/node_modules/axios/lib/defaults/index.js +14 -9
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +1 -2
- package/node_modules/axios/lib/helpers/buildURL.js +1 -1
- package/node_modules/axios/lib/helpers/cookies.js +14 -2
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +28 -1
- package/node_modules/axios/lib/helpers/formDataToJSON.js +3 -1
- package/node_modules/axios/lib/helpers/formDataToStream.js +3 -2
- package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
- package/node_modules/axios/lib/helpers/progressEventReducer.js +5 -5
- package/node_modules/axios/lib/helpers/resolveConfig.js +54 -18
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +74 -2
- package/node_modules/axios/lib/helpers/toFormData.js +10 -2
- package/node_modules/axios/lib/helpers/validator.js +3 -1
- package/node_modules/axios/lib/utils.js +33 -21
- package/node_modules/axios/package.json +17 -24
- package/node_modules/follow-redirects/README.md +7 -5
- package/node_modules/follow-redirects/index.js +24 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/daemon/package.json +1 -1
- package/packages/daemon/src/api.js +1086 -6532
- package/packages/daemon/src/conversations.js +18 -48
- package/packages/daemon/src/gateways/manager.js +35 -1
- package/packages/daemon/src/index.js +3 -0
- package/packages/daemon/src/journalist.js +23 -13
- package/packages/daemon/src/mlx-server.js +365 -0
- package/packages/daemon/src/model-lab.js +308 -12
- package/packages/daemon/src/pm.js +1 -1
- package/packages/daemon/src/process.js +2 -2
- package/packages/daemon/src/providers/local.js +36 -8
- package/packages/daemon/src/registry.js +21 -5
- package/packages/daemon/src/routes/agents.js +812 -0
- package/packages/daemon/src/routes/coordination.js +318 -0
- package/packages/daemon/src/routes/files.js +751 -0
- package/packages/daemon/src/routes/integrations.js +485 -0
- package/packages/daemon/src/routes/network.js +1784 -0
- package/packages/daemon/src/routes/providers.js +755 -0
- package/packages/daemon/src/routes/schedules.js +110 -0
- package/packages/daemon/src/routes/teams.js +650 -0
- package/packages/daemon/src/scheduler.js +456 -24
- package/packages/daemon/src/teams.js +1 -1
- package/packages/daemon/src/validate.js +38 -1
- package/packages/daemon/templates/mlx-setup.json +12 -0
- package/packages/daemon/templates/tgi-setup.json +1 -1
- package/packages/daemon/templates/vllm-setup.json +1 -1
- package/packages/gui/dist/assets/index-Bxc0gU06.js +1006 -0
- package/packages/gui/dist/assets/index-C0pztKBn.css +1 -0
- package/packages/gui/dist/index.html +2 -2
- package/packages/gui/package.json +1 -1
- package/packages/gui/src/{app.jsx → App.jsx} +0 -2
- package/packages/gui/src/app.css +35 -0
- package/packages/gui/src/components/agents/agent-config.jsx +1 -128
- package/packages/gui/src/components/agents/agent-feed.jsx +210 -112
- package/packages/gui/src/components/agents/agent-node.jsx +8 -13
- package/packages/gui/src/components/agents/agent-panel.jsx +2 -70
- package/packages/gui/src/components/agents/code-review.jsx +159 -122
- package/packages/gui/src/components/agents/diff-viewer.jsx +23 -23
- package/packages/gui/src/components/agents/journalist-panel.jsx +1 -1
- package/packages/gui/src/components/agents/spawn-wizard.jsx +2 -135
- package/packages/gui/src/components/automations/automation-card.jsx +274 -0
- package/packages/gui/src/components/automations/automation-wizard.jsx +1136 -0
- package/packages/gui/src/components/chat/chat-header.jsx +2 -0
- package/packages/gui/src/components/chat/chat-input.jsx +68 -66
- package/packages/gui/src/components/chat/chat-view.jsx +4 -8
- package/packages/gui/src/components/dashboard/activity-feed.jsx +3 -3
- package/packages/gui/src/components/dashboard/cache-ring.jsx +5 -5
- package/packages/gui/src/components/dashboard/context-gauges.jsx +6 -8
- package/packages/gui/src/components/dashboard/fleet-panel.jsx +8 -14
- package/packages/gui/src/components/dashboard/intel-panel.jsx +238 -656
- package/packages/gui/src/components/dashboard/kpi-card.jsx +3 -3
- package/packages/gui/src/components/dashboard/routing-chart.jsx +3 -3
- package/packages/gui/src/components/dashboard/team-burn-panel.jsx +1 -1
- package/packages/gui/src/components/dashboard/token-chart.jsx +4 -4
- package/packages/gui/src/components/lab/chat-playground.jsx +39 -31
- package/packages/gui/src/components/lab/lab-assistant.jsx +316 -82
- package/packages/gui/src/components/lab/metrics-panel.jsx +187 -32
- package/packages/gui/src/components/lab/parameter-panel.jsx +200 -18
- package/packages/gui/src/components/lab/preset-manager.jsx +17 -14
- package/packages/gui/src/components/lab/runtime-config.jsx +335 -152
- package/packages/gui/src/components/lab/system-prompt-editor.jsx +10 -8
- package/packages/gui/src/components/layout/activity-bar.jsx +2 -4
- package/packages/gui/src/components/layout/terminal-panel.jsx +4 -2
- package/packages/gui/src/components/layout/welcome-splash.jsx +137 -108
- package/packages/gui/src/components/network/network-health.jsx +2 -2
- package/packages/gui/src/components/network/performance-dashboard.jsx +4 -4
- package/packages/gui/src/components/settings/ssh-wizard.jsx +81 -99
- package/packages/gui/src/components/ui/sheet.jsx +5 -2
- package/packages/gui/src/components/ui/slider.jsx +8 -8
- package/packages/gui/src/lib/cron.js +64 -0
- package/packages/gui/src/lib/status.js +25 -24
- package/packages/gui/src/lib/theme-hex.js +1 -0
- package/packages/gui/src/stores/groove.js +51 -3144
- package/packages/gui/src/stores/helpers.js +10 -0
- package/packages/gui/src/stores/slices/agents-slice.js +459 -0
- package/packages/gui/src/stores/slices/automations-slice.js +96 -0
- package/packages/gui/src/stores/slices/chat-slice.js +226 -0
- package/packages/gui/src/stores/slices/editor-slice.js +285 -0
- package/packages/gui/src/stores/slices/marketplace-slice.js +461 -0
- package/packages/gui/src/stores/slices/network-slice.js +361 -0
- package/packages/gui/src/stores/slices/preview-slice.js +109 -0
- package/packages/gui/src/stores/slices/providers-slice.js +897 -0
- package/packages/gui/src/stores/slices/teams-slice.js +413 -0
- package/packages/gui/src/stores/slices/ui-slice.js +98 -0
- package/packages/gui/src/views/agents.jsx +5 -5
- package/packages/gui/src/views/dashboard.jsx +12 -13
- package/packages/gui/src/views/marketplace.jsx +191 -3
- package/packages/gui/src/views/model-lab.jsx +54 -12
- package/packages/gui/src/views/models.jsx +419 -496
- package/packages/gui/src/views/network.jsx +3 -3
- package/packages/gui/src/views/settings.jsx +81 -94
- package/packages/gui/src/views/teams.jsx +40 -483
- package/SECURITY_SWEEP.md +0 -228
- package/TRAINING_DATA_v4.md +0 -6
- package/node_modules/@groove-dev/gui/dist/assets/index-CCVvAoQn.css +0 -1
- package/node_modules/@groove-dev/gui/dist/assets/index-DGIv_TRm.js +0 -984
- package/node_modules/@groove-dev/gui/src/components/agents/agent-chat.jsx +0 -379
- package/node_modules/@groove-dev/gui/src/views/preview.jsx +0 -6
- package/node_modules/@groove-dev/gui/src/views/subscription-panel.jsx +0 -327
- package/packages/gui/dist/assets/index-CCVvAoQn.css +0 -1
- package/packages/gui/dist/assets/index-DGIv_TRm.js +0 -984
- package/packages/gui/src/components/agents/agent-chat.jsx +0 -379
- package/packages/gui/src/views/preview.jsx +0 -6
- package/packages/gui/src/views/subscription-panel.jsx +0 -327
- package/test.py +0 -571
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.16.0 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var FormData$1 = require('form-data');
|
|
@@ -8,6 +8,7 @@ var http = require('http');
|
|
|
8
8
|
var https = require('https');
|
|
9
9
|
var http2 = require('http2');
|
|
10
10
|
var util = require('util');
|
|
11
|
+
var path = require('path');
|
|
11
12
|
var followRedirects = require('follow-redirects');
|
|
12
13
|
var zlib = require('zlib');
|
|
13
14
|
var stream = require('stream');
|
|
@@ -207,9 +208,9 @@ const isFile = kindOfTest('File');
|
|
|
207
208
|
* also have a `name` and `type` attribute to specify filename and content type
|
|
208
209
|
*
|
|
209
210
|
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
210
|
-
*
|
|
211
|
+
*
|
|
211
212
|
* @param {*} value The value to test
|
|
212
|
-
*
|
|
213
|
+
*
|
|
213
214
|
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
214
215
|
*/
|
|
215
216
|
const isReactNativeBlob = value => {
|
|
@@ -219,9 +220,9 @@ const isReactNativeBlob = value => {
|
|
|
219
220
|
/**
|
|
220
221
|
* Determine if environment is React Native
|
|
221
222
|
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
222
|
-
*
|
|
223
|
+
*
|
|
223
224
|
* @param {*} formData The formData to test
|
|
224
|
-
*
|
|
225
|
+
*
|
|
225
226
|
* @returns {boolean} True if environment is React Native, otherwise false
|
|
226
227
|
*/
|
|
227
228
|
const isReactNative = formData => formData && typeof formData.getParts !== 'undefined';
|
|
@@ -240,7 +241,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
240
241
|
*
|
|
241
242
|
* @param {*} val The value to test
|
|
242
243
|
*
|
|
243
|
-
* @returns {boolean} True if value is a
|
|
244
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
244
245
|
*/
|
|
245
246
|
const isFileList = kindOfTest('FileList');
|
|
246
247
|
|
|
@@ -270,10 +271,16 @@ function getGlobal() {
|
|
|
270
271
|
const G = getGlobal();
|
|
271
272
|
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
272
273
|
const isFormData = thing => {
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
if (!thing) return false;
|
|
275
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
276
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
277
|
+
const proto = getPrototypeOf(thing);
|
|
278
|
+
if (!proto || proto === Object.prototype) return false;
|
|
279
|
+
if (!isFunction$1(thing.append)) return false;
|
|
280
|
+
const kind = kindOf(thing);
|
|
281
|
+
return kind === 'formdata' ||
|
|
275
282
|
// detect form-data instance
|
|
276
|
-
kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'
|
|
283
|
+
kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]';
|
|
277
284
|
};
|
|
278
285
|
|
|
279
286
|
/**
|
|
@@ -398,8 +405,7 @@ const isContextDefined = context => !isUndefined(context) && context !== _global
|
|
|
398
405
|
*
|
|
399
406
|
* @returns {Object} Result of all merge properties
|
|
400
407
|
*/
|
|
401
|
-
function merge(
|
|
402
|
-
) {
|
|
408
|
+
function merge(...objs) {
|
|
403
409
|
const {
|
|
404
410
|
caseless,
|
|
405
411
|
skipUndefined
|
|
@@ -411,8 +417,12 @@ function merge(/* obj1, obj2, obj3, ... */
|
|
|
411
417
|
return;
|
|
412
418
|
}
|
|
413
419
|
const targetKey = caseless && findKey(result, key) || key;
|
|
414
|
-
|
|
415
|
-
|
|
420
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
421
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
422
|
+
// copied into the merged result.
|
|
423
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
424
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
425
|
+
result[targetKey] = merge(existing, val);
|
|
416
426
|
} else if (isPlainObject(val)) {
|
|
417
427
|
result[targetKey] = merge({}, val);
|
|
418
428
|
} else if (isArray(val)) {
|
|
@@ -421,8 +431,8 @@ function merge(/* obj1, obj2, obj3, ... */
|
|
|
421
431
|
result[targetKey] = val;
|
|
422
432
|
}
|
|
423
433
|
};
|
|
424
|
-
for (let i = 0, l =
|
|
425
|
-
|
|
434
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
435
|
+
objs[i] && forEach(objs[i], assignValue);
|
|
426
436
|
}
|
|
427
437
|
return result;
|
|
428
438
|
}
|
|
@@ -444,6 +454,9 @@ const extend = (a, b, thisArg, {
|
|
|
444
454
|
forEach(b, (val, key) => {
|
|
445
455
|
if (thisArg && isFunction$1(val)) {
|
|
446
456
|
Object.defineProperty(a, key, {
|
|
457
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
458
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
459
|
+
__proto__: null,
|
|
447
460
|
value: bind(val, thisArg),
|
|
448
461
|
writable: true,
|
|
449
462
|
enumerable: true,
|
|
@@ -451,6 +464,7 @@ const extend = (a, b, thisArg, {
|
|
|
451
464
|
});
|
|
452
465
|
} else {
|
|
453
466
|
Object.defineProperty(a, key, {
|
|
467
|
+
__proto__: null,
|
|
454
468
|
value: val,
|
|
455
469
|
writable: true,
|
|
456
470
|
enumerable: true,
|
|
@@ -489,12 +503,14 @@ const stripBOM = content => {
|
|
|
489
503
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
490
504
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
491
505
|
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
506
|
+
__proto__: null,
|
|
492
507
|
value: constructor,
|
|
493
508
|
writable: true,
|
|
494
509
|
enumerable: false,
|
|
495
510
|
configurable: true
|
|
496
511
|
});
|
|
497
512
|
Object.defineProperty(constructor, 'super', {
|
|
513
|
+
__proto__: null,
|
|
498
514
|
value: superConstructor.prototype
|
|
499
515
|
});
|
|
500
516
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -662,7 +678,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
662
678
|
const freezeMethods = obj => {
|
|
663
679
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
664
680
|
// skip restricted props in strict mode
|
|
665
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].
|
|
681
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
666
682
|
return false;
|
|
667
683
|
}
|
|
668
684
|
const value = obj[name];
|
|
@@ -869,1034 +885,1111 @@ var utils$1 = {
|
|
|
869
885
|
isIterable
|
|
870
886
|
};
|
|
871
887
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
axiosError.cause = error;
|
|
876
|
-
axiosError.name = error.name;
|
|
888
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
889
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
890
|
+
const ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
|
|
877
891
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
892
|
+
/**
|
|
893
|
+
* Parse headers into an object
|
|
894
|
+
*
|
|
895
|
+
* ```
|
|
896
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
897
|
+
* Content-Type: application/json
|
|
898
|
+
* Connection: keep-alive
|
|
899
|
+
* Transfer-Encoding: chunked
|
|
900
|
+
* ```
|
|
901
|
+
*
|
|
902
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
903
|
+
*
|
|
904
|
+
* @returns {Object} Headers parsed into an object
|
|
905
|
+
*/
|
|
906
|
+
var parseHeaders = rawHeaders => {
|
|
907
|
+
const parsed = {};
|
|
908
|
+
let key;
|
|
909
|
+
let val;
|
|
910
|
+
let i;
|
|
911
|
+
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
|
912
|
+
i = line.indexOf(':');
|
|
913
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
914
|
+
val = line.substring(i + 1).trim();
|
|
915
|
+
if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
|
916
|
+
return;
|
|
881
917
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
*
|
|
895
|
-
* @returns {Error} The created error.
|
|
896
|
-
*/
|
|
897
|
-
constructor(message, code, config, request, response) {
|
|
898
|
-
super(message);
|
|
918
|
+
if (key === 'set-cookie') {
|
|
919
|
+
if (parsed[key]) {
|
|
920
|
+
parsed[key].push(val);
|
|
921
|
+
} else {
|
|
922
|
+
parsed[key] = [val];
|
|
923
|
+
}
|
|
924
|
+
} else {
|
|
925
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
return parsed;
|
|
929
|
+
};
|
|
899
930
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
this.name = 'AxiosError';
|
|
910
|
-
this.isAxiosError = true;
|
|
911
|
-
code && (this.code = code);
|
|
912
|
-
config && (this.config = config);
|
|
913
|
-
request && (this.request = request);
|
|
914
|
-
if (response) {
|
|
915
|
-
this.response = response;
|
|
916
|
-
this.status = response.status;
|
|
931
|
+
const $internals = Symbol('internals');
|
|
932
|
+
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
933
|
+
function trimSPorHTAB(str) {
|
|
934
|
+
let start = 0;
|
|
935
|
+
let end = str.length;
|
|
936
|
+
while (start < end) {
|
|
937
|
+
const code = str.charCodeAt(start);
|
|
938
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
939
|
+
break;
|
|
917
940
|
}
|
|
941
|
+
start += 1;
|
|
918
942
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
description: this.description,
|
|
926
|
-
number: this.number,
|
|
927
|
-
// Mozilla
|
|
928
|
-
fileName: this.fileName,
|
|
929
|
-
lineNumber: this.lineNumber,
|
|
930
|
-
columnNumber: this.columnNumber,
|
|
931
|
-
stack: this.stack,
|
|
932
|
-
// Axios
|
|
933
|
-
config: utils$1.toJSONObject(this.config),
|
|
934
|
-
code: this.code,
|
|
935
|
-
status: this.status
|
|
936
|
-
};
|
|
943
|
+
while (end > start) {
|
|
944
|
+
const code = str.charCodeAt(end - 1);
|
|
945
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
end -= 1;
|
|
937
949
|
}
|
|
950
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
938
951
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
942
|
-
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
943
|
-
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
944
|
-
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
945
|
-
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
946
|
-
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
947
|
-
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
948
|
-
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
949
|
-
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
950
|
-
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
951
|
-
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
952
|
-
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
953
|
-
|
|
954
|
-
/**
|
|
955
|
-
* Determines if the given thing is a array or js object.
|
|
956
|
-
*
|
|
957
|
-
* @param {string} thing - The object or array to be visited.
|
|
958
|
-
*
|
|
959
|
-
* @returns {boolean}
|
|
960
|
-
*/
|
|
961
|
-
function isVisitable(thing) {
|
|
962
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
952
|
+
function normalizeHeader(header) {
|
|
953
|
+
return header && String(header).trim().toLowerCase();
|
|
963
954
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
* It removes the brackets from the end of a string
|
|
967
|
-
*
|
|
968
|
-
* @param {string} key - The key of the parameter.
|
|
969
|
-
*
|
|
970
|
-
* @returns {string} the key without the brackets.
|
|
971
|
-
*/
|
|
972
|
-
function removeBrackets(key) {
|
|
973
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
955
|
+
function sanitizeHeaderValue(str) {
|
|
956
|
+
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
974
957
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
* @param {string} key - The key of the current object being iterated over.
|
|
981
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
982
|
-
*
|
|
983
|
-
* @returns {string} The path to the current key.
|
|
984
|
-
*/
|
|
985
|
-
function renderKey(path, key, dots) {
|
|
986
|
-
if (!path) return key;
|
|
987
|
-
return path.concat(key).map(function each(token, i) {
|
|
988
|
-
// eslint-disable-next-line no-param-reassign
|
|
989
|
-
token = removeBrackets(token);
|
|
990
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
991
|
-
}).join(dots ? '.' : '');
|
|
958
|
+
function normalizeValue(value) {
|
|
959
|
+
if (value === false || value == null) {
|
|
960
|
+
return value;
|
|
961
|
+
}
|
|
962
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
992
963
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
function isFlatArray(arr) {
|
|
1002
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
964
|
+
function parseTokens(str) {
|
|
965
|
+
const tokens = Object.create(null);
|
|
966
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
967
|
+
let match;
|
|
968
|
+
while (match = tokensRE.exec(str)) {
|
|
969
|
+
tokens[match[1]] = match[2];
|
|
970
|
+
}
|
|
971
|
+
return tokens;
|
|
1003
972
|
}
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Convert a data object to FormData
|
|
1010
|
-
*
|
|
1011
|
-
* @param {Object} obj
|
|
1012
|
-
* @param {?Object} [formData]
|
|
1013
|
-
* @param {?Object} [options]
|
|
1014
|
-
* @param {Function} [options.visitor]
|
|
1015
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
1016
|
-
* @param {Boolean} [options.dots = false]
|
|
1017
|
-
* @param {?Boolean} [options.indexes = false]
|
|
1018
|
-
*
|
|
1019
|
-
* @returns {Object}
|
|
1020
|
-
**/
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
* It converts an object into a FormData object
|
|
1024
|
-
*
|
|
1025
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1026
|
-
* @param {string} formData - The FormData object to append to.
|
|
1027
|
-
* @param {Object<string, any>} options
|
|
1028
|
-
*
|
|
1029
|
-
* @returns
|
|
1030
|
-
*/
|
|
1031
|
-
function toFormData(obj, formData, options) {
|
|
1032
|
-
if (!utils$1.isObject(obj)) {
|
|
1033
|
-
throw new TypeError('target must be an object');
|
|
973
|
+
const isValidHeaderName = str => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
974
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
975
|
+
if (utils$1.isFunction(filter)) {
|
|
976
|
+
return filter.call(this, value, header);
|
|
1034
977
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
formData = formData || new (FormData$1 || FormData)();
|
|
1038
|
-
|
|
1039
|
-
// eslint-disable-next-line no-param-reassign
|
|
1040
|
-
options = utils$1.toFlatObject(options, {
|
|
1041
|
-
metaTokens: true,
|
|
1042
|
-
dots: false,
|
|
1043
|
-
indexes: false
|
|
1044
|
-
}, false, function defined(option, source) {
|
|
1045
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1046
|
-
return !utils$1.isUndefined(source[option]);
|
|
1047
|
-
});
|
|
1048
|
-
const metaTokens = options.metaTokens;
|
|
1049
|
-
// eslint-disable-next-line no-use-before-define
|
|
1050
|
-
const visitor = options.visitor || defaultVisitor;
|
|
1051
|
-
const dots = options.dots;
|
|
1052
|
-
const indexes = options.indexes;
|
|
1053
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1054
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1055
|
-
if (!utils$1.isFunction(visitor)) {
|
|
1056
|
-
throw new TypeError('visitor must be a function');
|
|
978
|
+
if (isHeaderNameFilter) {
|
|
979
|
+
value = header;
|
|
1057
980
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
return value.toISOString();
|
|
1062
|
-
}
|
|
1063
|
-
if (utils$1.isBoolean(value)) {
|
|
1064
|
-
return value.toString();
|
|
1065
|
-
}
|
|
1066
|
-
if (!useBlob && utils$1.isBlob(value)) {
|
|
1067
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1068
|
-
}
|
|
1069
|
-
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
1070
|
-
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1071
|
-
}
|
|
1072
|
-
return value;
|
|
981
|
+
if (!utils$1.isString(value)) return;
|
|
982
|
+
if (utils$1.isString(filter)) {
|
|
983
|
+
return value.indexOf(filter) !== -1;
|
|
1073
984
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
985
|
+
if (utils$1.isRegExp(filter)) {
|
|
986
|
+
return filter.test(value);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
function formatHeader(header) {
|
|
990
|
+
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
991
|
+
return char.toUpperCase() + str;
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function buildAccessors(obj, header) {
|
|
995
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
996
|
+
['get', 'set', 'has'].forEach(methodName => {
|
|
997
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
998
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
999
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1000
|
+
__proto__: null,
|
|
1001
|
+
value: function (arg1, arg2, arg3) {
|
|
1002
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1003
|
+
},
|
|
1004
|
+
configurable: true
|
|
1005
|
+
});
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
class AxiosHeaders {
|
|
1009
|
+
constructor(headers) {
|
|
1010
|
+
headers && this.set(headers);
|
|
1011
|
+
}
|
|
1012
|
+
set(header, valueOrRewrite, rewrite) {
|
|
1013
|
+
const self = this;
|
|
1014
|
+
function setHeader(_value, _header, _rewrite) {
|
|
1015
|
+
const lHeader = normalizeHeader(_header);
|
|
1016
|
+
if (!lHeader) {
|
|
1017
|
+
throw new Error('header name must be a non-empty string');
|
|
1018
|
+
}
|
|
1019
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1020
|
+
if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
|
|
1021
|
+
self[key || _header] = normalizeValue(_value);
|
|
1022
|
+
}
|
|
1090
1023
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
key
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
return false;
|
|
1024
|
+
const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1025
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1026
|
+
setHeaders(header, valueOrRewrite);
|
|
1027
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1028
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1029
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1030
|
+
let obj = {},
|
|
1031
|
+
dest,
|
|
1032
|
+
key;
|
|
1033
|
+
for (const entry of header) {
|
|
1034
|
+
if (!utils$1.isArray(entry)) {
|
|
1035
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
1036
|
+
}
|
|
1037
|
+
obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
|
|
1106
1038
|
}
|
|
1039
|
+
setHeaders(obj, valueOrRewrite);
|
|
1040
|
+
} else {
|
|
1041
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1107
1042
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1043
|
+
return this;
|
|
1044
|
+
}
|
|
1045
|
+
get(header, parser) {
|
|
1046
|
+
header = normalizeHeader(header);
|
|
1047
|
+
if (header) {
|
|
1048
|
+
const key = utils$1.findKey(this, header);
|
|
1049
|
+
if (key) {
|
|
1050
|
+
const value = this[key];
|
|
1051
|
+
if (!parser) {
|
|
1052
|
+
return value;
|
|
1053
|
+
}
|
|
1054
|
+
if (parser === true) {
|
|
1055
|
+
return parseTokens(value);
|
|
1056
|
+
}
|
|
1057
|
+
if (utils$1.isFunction(parser)) {
|
|
1058
|
+
return parser.call(this, value, key);
|
|
1059
|
+
}
|
|
1060
|
+
if (utils$1.isRegExp(parser)) {
|
|
1061
|
+
return parser.exec(value);
|
|
1062
|
+
}
|
|
1063
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
has(header, matcher) {
|
|
1068
|
+
header = normalizeHeader(header);
|
|
1069
|
+
if (header) {
|
|
1070
|
+
const key = utils$1.findKey(this, header);
|
|
1071
|
+
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1110
1072
|
}
|
|
1111
|
-
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1112
1073
|
return false;
|
|
1113
1074
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1075
|
+
delete(header, matcher) {
|
|
1076
|
+
const self = this;
|
|
1077
|
+
let deleted = false;
|
|
1078
|
+
function deleteHeader(_header) {
|
|
1079
|
+
_header = normalizeHeader(_header);
|
|
1080
|
+
if (_header) {
|
|
1081
|
+
const key = utils$1.findKey(self, _header);
|
|
1082
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1083
|
+
delete self[key];
|
|
1084
|
+
deleted = true;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1124
1087
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1088
|
+
if (utils$1.isArray(header)) {
|
|
1089
|
+
header.forEach(deleteHeader);
|
|
1090
|
+
} else {
|
|
1091
|
+
deleteHeader(header);
|
|
1092
|
+
}
|
|
1093
|
+
return deleted;
|
|
1094
|
+
}
|
|
1095
|
+
clear(matcher) {
|
|
1096
|
+
const keys = Object.keys(this);
|
|
1097
|
+
let i = keys.length;
|
|
1098
|
+
let deleted = false;
|
|
1099
|
+
while (i--) {
|
|
1100
|
+
const key = keys[i];
|
|
1101
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1102
|
+
delete this[key];
|
|
1103
|
+
deleted = true;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return deleted;
|
|
1107
|
+
}
|
|
1108
|
+
normalize(format) {
|
|
1109
|
+
const self = this;
|
|
1110
|
+
const headers = {};
|
|
1111
|
+
utils$1.forEach(this, (value, header) => {
|
|
1112
|
+
const key = utils$1.findKey(headers, header);
|
|
1113
|
+
if (key) {
|
|
1114
|
+
self[key] = normalizeValue(value);
|
|
1115
|
+
delete self[header];
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1119
|
+
if (normalized !== header) {
|
|
1120
|
+
delete self[header];
|
|
1130
1121
|
}
|
|
1122
|
+
self[normalized] = normalizeValue(value);
|
|
1123
|
+
headers[normalized] = true;
|
|
1131
1124
|
});
|
|
1132
|
-
|
|
1125
|
+
return this;
|
|
1133
1126
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1127
|
+
concat(...targets) {
|
|
1128
|
+
return this.constructor.concat(this, ...targets);
|
|
1129
|
+
}
|
|
1130
|
+
toJSON(asStrings) {
|
|
1131
|
+
const obj = Object.create(null);
|
|
1132
|
+
utils$1.forEach(this, (value, header) => {
|
|
1133
|
+
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1134
|
+
});
|
|
1135
|
+
return obj;
|
|
1136
|
+
}
|
|
1137
|
+
[Symbol.iterator]() {
|
|
1138
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1139
|
+
}
|
|
1140
|
+
toString() {
|
|
1141
|
+
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
|
1142
|
+
}
|
|
1143
|
+
getSetCookie() {
|
|
1144
|
+
return this.get('set-cookie') || [];
|
|
1145
|
+
}
|
|
1146
|
+
get [Symbol.toStringTag]() {
|
|
1147
|
+
return 'AxiosHeaders';
|
|
1148
|
+
}
|
|
1149
|
+
static from(thing) {
|
|
1150
|
+
return thing instanceof this ? thing : new this(thing);
|
|
1151
|
+
}
|
|
1152
|
+
static concat(first, ...targets) {
|
|
1153
|
+
const computed = new this(first);
|
|
1154
|
+
targets.forEach(target => computed.set(target));
|
|
1155
|
+
return computed;
|
|
1156
|
+
}
|
|
1157
|
+
static accessor(header) {
|
|
1158
|
+
const internals = this[$internals] = this[$internals] = {
|
|
1159
|
+
accessors: {}
|
|
1160
|
+
};
|
|
1161
|
+
const accessors = internals.accessors;
|
|
1162
|
+
const prototype = this.prototype;
|
|
1163
|
+
function defineAccessor(_header) {
|
|
1164
|
+
const lHeader = normalizeHeader(_header);
|
|
1165
|
+
if (!accessors[lHeader]) {
|
|
1166
|
+
buildAccessors(prototype, _header);
|
|
1167
|
+
accessors[lHeader] = true;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1171
|
+
return this;
|
|
1136
1172
|
}
|
|
1137
|
-
build(obj);
|
|
1138
|
-
return formData;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
1143
|
-
* their percent-encoded equivalents
|
|
1144
|
-
*
|
|
1145
|
-
* @param {string} str - The string to encode.
|
|
1146
|
-
*
|
|
1147
|
-
* @returns {string} The encoded string.
|
|
1148
|
-
*/
|
|
1149
|
-
function encode$1(str) {
|
|
1150
|
-
const charMap = {
|
|
1151
|
-
'!': '%21',
|
|
1152
|
-
"'": '%27',
|
|
1153
|
-
'(': '%28',
|
|
1154
|
-
')': '%29',
|
|
1155
|
-
'~': '%7E',
|
|
1156
|
-
'%20': '+',
|
|
1157
|
-
'%00': '\x00'
|
|
1158
|
-
};
|
|
1159
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
1160
|
-
return charMap[match];
|
|
1161
|
-
});
|
|
1162
1173
|
}
|
|
1174
|
+
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
1163
1175
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
prototype.append = function append(name, value) {
|
|
1178
|
-
this._pairs.push([name, value]);
|
|
1179
|
-
};
|
|
1180
|
-
prototype.toString = function toString(encoder) {
|
|
1181
|
-
const _encode = encoder ? function (value) {
|
|
1182
|
-
return encoder.call(this, value, encode$1);
|
|
1183
|
-
} : encode$1;
|
|
1184
|
-
return this._pairs.map(function each(pair) {
|
|
1185
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1186
|
-
}, '').join('&');
|
|
1187
|
-
};
|
|
1188
|
-
|
|
1189
|
-
/**
|
|
1190
|
-
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1191
|
-
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1192
|
-
*
|
|
1193
|
-
* @param {string} val The value to be encoded.
|
|
1194
|
-
*
|
|
1195
|
-
* @returns {string} The encoded value.
|
|
1196
|
-
*/
|
|
1197
|
-
function encode(val) {
|
|
1198
|
-
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
|
|
1199
|
-
}
|
|
1176
|
+
// reserved names hotfix
|
|
1177
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({
|
|
1178
|
+
value
|
|
1179
|
+
}, key) => {
|
|
1180
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
1181
|
+
return {
|
|
1182
|
+
get: () => value,
|
|
1183
|
+
set(headerValue) {
|
|
1184
|
+
this[mapped] = headerValue;
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
});
|
|
1188
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
1200
1189
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
* @param {object} [params] The params to be appended
|
|
1206
|
-
* @param {?(object|Function)} options
|
|
1207
|
-
*
|
|
1208
|
-
* @returns {string} The formatted url
|
|
1209
|
-
*/
|
|
1210
|
-
function buildURL(url, params, options) {
|
|
1211
|
-
if (!params) {
|
|
1212
|
-
return url;
|
|
1213
|
-
}
|
|
1214
|
-
const _encode = options && options.encode || encode;
|
|
1215
|
-
const _options = utils$1.isFunction(options) ? {
|
|
1216
|
-
serialize: options
|
|
1217
|
-
} : options;
|
|
1218
|
-
const serializeFn = _options && _options.serialize;
|
|
1219
|
-
let serializedParams;
|
|
1220
|
-
if (serializeFn) {
|
|
1221
|
-
serializedParams = serializeFn(params, _options);
|
|
1222
|
-
} else {
|
|
1223
|
-
serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1190
|
+
const REDACTED = '[REDACTED ****]';
|
|
1191
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
1192
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
1193
|
+
return true;
|
|
1224
1194
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
if (
|
|
1228
|
-
|
|
1195
|
+
let prototype = Object.getPrototypeOf(source);
|
|
1196
|
+
while (prototype && prototype !== Object.prototype) {
|
|
1197
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
1198
|
+
return true;
|
|
1229
1199
|
}
|
|
1230
|
-
|
|
1200
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
1231
1201
|
}
|
|
1232
|
-
return
|
|
1202
|
+
return false;
|
|
1233
1203
|
}
|
|
1234
1204
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1205
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
1206
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
1207
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
1208
|
+
function redactConfig(config, redactKeys) {
|
|
1209
|
+
const lowerKeys = new Set(redactKeys.map(k => String(k).toLowerCase()));
|
|
1210
|
+
const seen = [];
|
|
1211
|
+
const visit = source => {
|
|
1212
|
+
if (source === null || typeof source !== 'object') return source;
|
|
1213
|
+
if (utils$1.isBuffer(source)) return source;
|
|
1214
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
1215
|
+
if (source instanceof AxiosHeaders) {
|
|
1216
|
+
source = source.toJSON();
|
|
1217
|
+
}
|
|
1218
|
+
seen.push(source);
|
|
1219
|
+
let result;
|
|
1220
|
+
if (utils$1.isArray(source)) {
|
|
1221
|
+
result = [];
|
|
1222
|
+
source.forEach((v, i) => {
|
|
1223
|
+
const reducedValue = visit(v);
|
|
1224
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1225
|
+
result[i] = reducedValue;
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
} else {
|
|
1229
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
1230
|
+
seen.pop();
|
|
1231
|
+
return source;
|
|
1232
|
+
}
|
|
1233
|
+
result = Object.create(null);
|
|
1234
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1235
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
1236
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1237
|
+
result[key] = reducedValue;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1269
1240
|
}
|
|
1270
|
-
|
|
1241
|
+
seen.pop();
|
|
1242
|
+
return result;
|
|
1243
|
+
};
|
|
1244
|
+
return visit(config);
|
|
1245
|
+
}
|
|
1246
|
+
class AxiosError extends Error {
|
|
1247
|
+
static from(error, code, config, request, response, customProps) {
|
|
1248
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1249
|
+
axiosError.cause = error;
|
|
1250
|
+
axiosError.name = error.name;
|
|
1271
1251
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
* @returns {void}
|
|
1276
|
-
*/
|
|
1277
|
-
clear() {
|
|
1278
|
-
if (this.handlers) {
|
|
1279
|
-
this.handlers = [];
|
|
1252
|
+
// Preserve status from the original error if not already set from response
|
|
1253
|
+
if (error.status != null && axiosError.status == null) {
|
|
1254
|
+
axiosError.status = error.status;
|
|
1280
1255
|
}
|
|
1256
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1257
|
+
return axiosError;
|
|
1281
1258
|
}
|
|
1282
1259
|
|
|
1283
1260
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
* This method is particularly useful for skipping over any
|
|
1287
|
-
* interceptors that may have become `null` calling `eject`.
|
|
1261
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1288
1262
|
*
|
|
1289
|
-
* @param {
|
|
1263
|
+
* @param {string} message The error message.
|
|
1264
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1265
|
+
* @param {Object} [config] The config.
|
|
1266
|
+
* @param {Object} [request] The request.
|
|
1267
|
+
* @param {Object} [response] The response.
|
|
1290
1268
|
*
|
|
1291
|
-
* @returns {
|
|
1269
|
+
* @returns {Error} The created error.
|
|
1292
1270
|
*/
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1271
|
+
constructor(message, code, config, request, response) {
|
|
1272
|
+
super(message);
|
|
1273
|
+
|
|
1274
|
+
// Make message enumerable to maintain backward compatibility
|
|
1275
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1276
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1277
|
+
Object.defineProperty(this, 'message', {
|
|
1278
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1279
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1280
|
+
__proto__: null,
|
|
1281
|
+
value: message,
|
|
1282
|
+
enumerable: true,
|
|
1283
|
+
writable: true,
|
|
1284
|
+
configurable: true
|
|
1298
1285
|
});
|
|
1286
|
+
this.name = 'AxiosError';
|
|
1287
|
+
this.isAxiosError = true;
|
|
1288
|
+
code && (this.code = code);
|
|
1289
|
+
config && (this.config = config);
|
|
1290
|
+
request && (this.request = request);
|
|
1291
|
+
if (response) {
|
|
1292
|
+
this.response = response;
|
|
1293
|
+
this.status = response.status;
|
|
1294
|
+
}
|
|
1299
1295
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
for (let i = 0; i < size; i++) {
|
|
1326
|
-
str += alphabet[randomValues[i] % length];
|
|
1296
|
+
toJSON() {
|
|
1297
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
1298
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
1299
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
1300
|
+
// existing serialization behavior unchanged.
|
|
1301
|
+
const config = this.config;
|
|
1302
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
1303
|
+
const serializedConfig = utils$1.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils$1.toJSONObject(config);
|
|
1304
|
+
return {
|
|
1305
|
+
// Standard
|
|
1306
|
+
message: this.message,
|
|
1307
|
+
name: this.name,
|
|
1308
|
+
// Microsoft
|
|
1309
|
+
description: this.description,
|
|
1310
|
+
number: this.number,
|
|
1311
|
+
// Mozilla
|
|
1312
|
+
fileName: this.fileName,
|
|
1313
|
+
lineNumber: this.lineNumber,
|
|
1314
|
+
columnNumber: this.columnNumber,
|
|
1315
|
+
stack: this.stack,
|
|
1316
|
+
// Axios
|
|
1317
|
+
config: serializedConfig,
|
|
1318
|
+
code: this.code,
|
|
1319
|
+
status: this.status
|
|
1320
|
+
};
|
|
1327
1321
|
}
|
|
1328
|
-
|
|
1329
|
-
};
|
|
1330
|
-
var platform$1 = {
|
|
1331
|
-
isNode: true,
|
|
1332
|
-
classes: {
|
|
1333
|
-
URLSearchParams,
|
|
1334
|
-
FormData: FormData$1,
|
|
1335
|
-
Blob: typeof Blob !== 'undefined' && Blob || null
|
|
1336
|
-
},
|
|
1337
|
-
ALPHABET,
|
|
1338
|
-
generateString,
|
|
1339
|
-
protocols: ['http', 'https', 'file', 'data']
|
|
1340
|
-
};
|
|
1322
|
+
}
|
|
1341
1323
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1324
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1325
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1326
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1327
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
1328
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
1329
|
+
AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|
1330
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1331
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1332
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1333
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1334
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1335
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1336
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1337
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1338
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1344
1339
|
|
|
1345
1340
|
/**
|
|
1346
|
-
*
|
|
1341
|
+
* Determines if the given thing is a array or js object.
|
|
1347
1342
|
*
|
|
1348
|
-
*
|
|
1349
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1350
|
-
*
|
|
1351
|
-
* web workers:
|
|
1352
|
-
* typeof window -> undefined
|
|
1353
|
-
* typeof document -> undefined
|
|
1354
|
-
*
|
|
1355
|
-
* react-native:
|
|
1356
|
-
* navigator.product -> 'ReactNative'
|
|
1357
|
-
* nativescript
|
|
1358
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
1343
|
+
* @param {string} thing - The object or array to be visited.
|
|
1359
1344
|
*
|
|
1360
1345
|
* @returns {boolean}
|
|
1361
1346
|
*/
|
|
1362
|
-
|
|
1347
|
+
function isVisitable(thing) {
|
|
1348
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1349
|
+
}
|
|
1363
1350
|
|
|
1364
1351
|
/**
|
|
1365
|
-
*
|
|
1352
|
+
* It removes the brackets from the end of a string
|
|
1366
1353
|
*
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1371
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
1354
|
+
* @param {string} key - The key of the parameter.
|
|
1355
|
+
*
|
|
1356
|
+
* @returns {string} the key without the brackets.
|
|
1372
1357
|
*/
|
|
1373
|
-
|
|
1374
|
-
return
|
|
1375
|
-
// eslint-disable-next-line no-undef
|
|
1376
|
-
self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
|
|
1377
|
-
})();
|
|
1378
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1379
|
-
|
|
1380
|
-
var utils = /*#__PURE__*/Object.freeze({
|
|
1381
|
-
__proto__: null,
|
|
1382
|
-
hasBrowserEnv: hasBrowserEnv,
|
|
1383
|
-
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1384
|
-
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1385
|
-
navigator: _navigator,
|
|
1386
|
-
origin: origin
|
|
1387
|
-
});
|
|
1388
|
-
|
|
1389
|
-
var platform = {
|
|
1390
|
-
...utils,
|
|
1391
|
-
...platform$1
|
|
1392
|
-
};
|
|
1393
|
-
|
|
1394
|
-
function toURLEncodedForm(data, options) {
|
|
1395
|
-
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
1396
|
-
visitor: function (value, key, path, helpers) {
|
|
1397
|
-
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1398
|
-
this.append(key, value.toString('base64'));
|
|
1399
|
-
return false;
|
|
1400
|
-
}
|
|
1401
|
-
return helpers.defaultVisitor.apply(this, arguments);
|
|
1402
|
-
},
|
|
1403
|
-
...options
|
|
1404
|
-
});
|
|
1358
|
+
function removeBrackets(key) {
|
|
1359
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1405
1360
|
}
|
|
1406
1361
|
|
|
1407
1362
|
/**
|
|
1408
|
-
* It takes a
|
|
1363
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
1409
1364
|
*
|
|
1410
|
-
* @param {string}
|
|
1365
|
+
* @param {string} path - The path to the current key.
|
|
1366
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
1367
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
1411
1368
|
*
|
|
1412
|
-
* @returns
|
|
1369
|
+
* @returns {string} The path to the current key.
|
|
1413
1370
|
*/
|
|
1414
|
-
function
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
});
|
|
1371
|
+
function renderKey(path, key, dots) {
|
|
1372
|
+
if (!path) return key;
|
|
1373
|
+
return path.concat(key).map(function each(token, i) {
|
|
1374
|
+
// eslint-disable-next-line no-param-reassign
|
|
1375
|
+
token = removeBrackets(token);
|
|
1376
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1377
|
+
}).join(dots ? '.' : '');
|
|
1422
1378
|
}
|
|
1423
1379
|
|
|
1424
1380
|
/**
|
|
1425
|
-
*
|
|
1381
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
1426
1382
|
*
|
|
1427
|
-
* @param {Array<any>} arr - The array to
|
|
1383
|
+
* @param {Array<any>} arr - The array to check
|
|
1428
1384
|
*
|
|
1429
|
-
* @returns
|
|
1385
|
+
* @returns {boolean}
|
|
1430
1386
|
*/
|
|
1431
|
-
function
|
|
1432
|
-
|
|
1433
|
-
const keys = Object.keys(arr);
|
|
1434
|
-
let i;
|
|
1435
|
-
const len = keys.length;
|
|
1436
|
-
let key;
|
|
1437
|
-
for (i = 0; i < len; i++) {
|
|
1438
|
-
key = keys[i];
|
|
1439
|
-
obj[key] = arr[key];
|
|
1440
|
-
}
|
|
1441
|
-
return obj;
|
|
1387
|
+
function isFlatArray(arr) {
|
|
1388
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1442
1389
|
}
|
|
1390
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
1391
|
+
return /^is[A-Z]/.test(prop);
|
|
1392
|
+
});
|
|
1443
1393
|
|
|
1444
1394
|
/**
|
|
1445
|
-
*
|
|
1395
|
+
* Convert a data object to FormData
|
|
1446
1396
|
*
|
|
1447
|
-
* @param {
|
|
1397
|
+
* @param {Object} obj
|
|
1398
|
+
* @param {?Object} [formData]
|
|
1399
|
+
* @param {?Object} [options]
|
|
1400
|
+
* @param {Function} [options.visitor]
|
|
1401
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
1402
|
+
* @param {Boolean} [options.dots = false]
|
|
1403
|
+
* @param {?Boolean} [options.indexes = false]
|
|
1448
1404
|
*
|
|
1449
|
-
* @returns {Object
|
|
1405
|
+
* @returns {Object}
|
|
1406
|
+
**/
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* It converts an object into a FormData object
|
|
1410
|
+
*
|
|
1411
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1412
|
+
* @param {string} formData - The FormData object to append to.
|
|
1413
|
+
* @param {Object<string, any>} options
|
|
1414
|
+
*
|
|
1415
|
+
* @returns
|
|
1450
1416
|
*/
|
|
1451
|
-
function
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1417
|
+
function toFormData(obj, formData, options) {
|
|
1418
|
+
if (!utils$1.isObject(obj)) {
|
|
1419
|
+
throw new TypeError('target must be an object');
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// eslint-disable-next-line no-param-reassign
|
|
1423
|
+
formData = formData || new (FormData$1 || FormData)();
|
|
1424
|
+
|
|
1425
|
+
// eslint-disable-next-line no-param-reassign
|
|
1426
|
+
options = utils$1.toFlatObject(options, {
|
|
1427
|
+
metaTokens: true,
|
|
1428
|
+
dots: false,
|
|
1429
|
+
indexes: false
|
|
1430
|
+
}, false, function defined(option, source) {
|
|
1431
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1432
|
+
return !utils$1.isUndefined(source[option]);
|
|
1433
|
+
});
|
|
1434
|
+
const metaTokens = options.metaTokens;
|
|
1435
|
+
// eslint-disable-next-line no-use-before-define
|
|
1436
|
+
const visitor = options.visitor || defaultVisitor;
|
|
1437
|
+
const dots = options.dots;
|
|
1438
|
+
const indexes = options.indexes;
|
|
1439
|
+
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1440
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1441
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1442
|
+
if (!utils$1.isFunction(visitor)) {
|
|
1443
|
+
throw new TypeError('visitor must be a function');
|
|
1444
|
+
}
|
|
1445
|
+
function convertValue(value) {
|
|
1446
|
+
if (value === null) return '';
|
|
1447
|
+
if (utils$1.isDate(value)) {
|
|
1448
|
+
return value.toISOString();
|
|
1465
1449
|
}
|
|
1466
|
-
if (
|
|
1467
|
-
|
|
1450
|
+
if (utils$1.isBoolean(value)) {
|
|
1451
|
+
return value.toString();
|
|
1468
1452
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
target[name] = arrayToObject(target[name]);
|
|
1453
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
1454
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1472
1455
|
}
|
|
1473
|
-
|
|
1456
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
1457
|
+
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1458
|
+
}
|
|
1459
|
+
return value;
|
|
1474
1460
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Default visitor.
|
|
1464
|
+
*
|
|
1465
|
+
* @param {*} value
|
|
1466
|
+
* @param {String|Number} key
|
|
1467
|
+
* @param {Array<String|Number>} path
|
|
1468
|
+
* @this {FormData}
|
|
1469
|
+
*
|
|
1470
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1471
|
+
*/
|
|
1472
|
+
function defaultVisitor(value, key, path) {
|
|
1473
|
+
let arr = value;
|
|
1474
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1475
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1476
|
+
return false;
|
|
1477
|
+
}
|
|
1478
|
+
if (value && !path && typeof value === 'object') {
|
|
1479
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
1480
|
+
// eslint-disable-next-line no-param-reassign
|
|
1481
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
1482
|
+
// eslint-disable-next-line no-param-reassign
|
|
1483
|
+
value = JSON.stringify(value);
|
|
1484
|
+
} else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
|
|
1485
|
+
// eslint-disable-next-line no-param-reassign
|
|
1486
|
+
key = removeBrackets(key);
|
|
1487
|
+
arr.forEach(function each(el, index) {
|
|
1488
|
+
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
1489
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1490
|
+
indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
|
|
1491
|
+
});
|
|
1492
|
+
return false;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
if (isVisitable(value)) {
|
|
1496
|
+
return true;
|
|
1497
|
+
}
|
|
1498
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1499
|
+
return false;
|
|
1500
|
+
}
|
|
1501
|
+
const stack = [];
|
|
1502
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
1503
|
+
defaultVisitor,
|
|
1504
|
+
convertValue,
|
|
1505
|
+
isVisitable
|
|
1506
|
+
});
|
|
1507
|
+
function build(value, path, depth = 0) {
|
|
1508
|
+
if (utils$1.isUndefined(value)) return;
|
|
1509
|
+
if (depth > maxDepth) {
|
|
1510
|
+
throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
|
|
1511
|
+
}
|
|
1512
|
+
if (stack.indexOf(value) !== -1) {
|
|
1513
|
+
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1514
|
+
}
|
|
1515
|
+
stack.push(value);
|
|
1516
|
+
utils$1.forEach(value, function each(el, key) {
|
|
1517
|
+
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1518
|
+
if (result === true) {
|
|
1519
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1520
|
+
}
|
|
1479
1521
|
});
|
|
1480
|
-
|
|
1522
|
+
stack.pop();
|
|
1481
1523
|
}
|
|
1482
|
-
|
|
1524
|
+
if (!utils$1.isObject(obj)) {
|
|
1525
|
+
throw new TypeError('data must be an object');
|
|
1526
|
+
}
|
|
1527
|
+
build(obj);
|
|
1528
|
+
return formData;
|
|
1483
1529
|
}
|
|
1484
1530
|
|
|
1485
1531
|
/**
|
|
1486
|
-
* It
|
|
1487
|
-
*
|
|
1532
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
1533
|
+
* their percent-encoded equivalents
|
|
1488
1534
|
*
|
|
1489
|
-
* @param {
|
|
1490
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
1491
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
1535
|
+
* @param {string} str - The string to encode.
|
|
1492
1536
|
*
|
|
1493
|
-
* @returns {string}
|
|
1537
|
+
* @returns {string} The encoded string.
|
|
1494
1538
|
*/
|
|
1495
|
-
function
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1539
|
+
function encode$1(str) {
|
|
1540
|
+
const charMap = {
|
|
1541
|
+
'!': '%21',
|
|
1542
|
+
"'": '%27',
|
|
1543
|
+
'(': '%28',
|
|
1544
|
+
')': '%29',
|
|
1545
|
+
'~': '%7E',
|
|
1546
|
+
'%20': '+'
|
|
1547
|
+
};
|
|
1548
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1549
|
+
return charMap[match];
|
|
1550
|
+
});
|
|
1507
1551
|
}
|
|
1508
|
-
const defaults = {
|
|
1509
|
-
transitional: transitionalDefaults,
|
|
1510
|
-
adapter: ['xhr', 'http', 'fetch'],
|
|
1511
|
-
transformRequest: [function transformRequest(data, headers) {
|
|
1512
|
-
const contentType = headers.getContentType() || '';
|
|
1513
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1514
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
1515
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1516
|
-
data = new FormData(data);
|
|
1517
|
-
}
|
|
1518
|
-
const isFormData = utils$1.isFormData(data);
|
|
1519
|
-
if (isFormData) {
|
|
1520
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1521
|
-
}
|
|
1522
|
-
if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
|
|
1523
|
-
return data;
|
|
1524
|
-
}
|
|
1525
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1526
|
-
return data.buffer;
|
|
1527
|
-
}
|
|
1528
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1529
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1530
|
-
return data.toString();
|
|
1531
|
-
}
|
|
1532
|
-
let isFileList;
|
|
1533
|
-
if (isObjectPayload) {
|
|
1534
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1535
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1536
|
-
}
|
|
1537
|
-
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1538
|
-
const _FormData = this.env && this.env.FormData;
|
|
1539
|
-
return toFormData(isFileList ? {
|
|
1540
|
-
'files[]': data
|
|
1541
|
-
} : data, _FormData && new _FormData(), this.formSerializer);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
if (isObjectPayload || hasJSONContentType) {
|
|
1545
|
-
headers.setContentType('application/json', false);
|
|
1546
|
-
return stringifySafely(data);
|
|
1547
|
-
}
|
|
1548
|
-
return data;
|
|
1549
|
-
}],
|
|
1550
|
-
transformResponse: [function transformResponse(data) {
|
|
1551
|
-
const transitional = this.transitional || defaults.transitional;
|
|
1552
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1553
|
-
const JSONRequested = this.responseType === 'json';
|
|
1554
|
-
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1555
|
-
return data;
|
|
1556
|
-
}
|
|
1557
|
-
if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
|
1558
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1559
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1560
|
-
try {
|
|
1561
|
-
return JSON.parse(data, this.parseReviver);
|
|
1562
|
-
} catch (e) {
|
|
1563
|
-
if (strictJSONParsing) {
|
|
1564
|
-
if (e.name === 'SyntaxError') {
|
|
1565
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1566
|
-
}
|
|
1567
|
-
throw e;
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
return data;
|
|
1572
|
-
}],
|
|
1573
|
-
/**
|
|
1574
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
1575
|
-
* timeout is not created.
|
|
1576
|
-
*/
|
|
1577
|
-
timeout: 0,
|
|
1578
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
|
1579
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
1580
|
-
maxContentLength: -1,
|
|
1581
|
-
maxBodyLength: -1,
|
|
1582
|
-
env: {
|
|
1583
|
-
FormData: platform.classes.FormData,
|
|
1584
|
-
Blob: platform.classes.Blob
|
|
1585
|
-
},
|
|
1586
|
-
validateStatus: function validateStatus(status) {
|
|
1587
|
-
return status >= 200 && status < 300;
|
|
1588
|
-
},
|
|
1589
|
-
headers: {
|
|
1590
|
-
common: {
|
|
1591
|
-
Accept: 'application/json, text/plain, */*',
|
|
1592
|
-
'Content-Type': undefined
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], method => {
|
|
1597
|
-
defaults.headers[method] = {};
|
|
1598
|
-
});
|
|
1599
|
-
|
|
1600
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1601
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1602
|
-
const ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
|
|
1603
1552
|
|
|
1604
1553
|
/**
|
|
1605
|
-
*
|
|
1606
|
-
*
|
|
1607
|
-
* ```
|
|
1608
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1609
|
-
* Content-Type: application/json
|
|
1610
|
-
* Connection: keep-alive
|
|
1611
|
-
* Transfer-Encoding: chunked
|
|
1612
|
-
* ```
|
|
1554
|
+
* It takes a params object and converts it to a FormData object
|
|
1613
1555
|
*
|
|
1614
|
-
* @param {
|
|
1556
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1557
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1615
1558
|
*
|
|
1616
|
-
* @returns {
|
|
1559
|
+
* @returns {void}
|
|
1617
1560
|
*/
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
} else {
|
|
1634
|
-
parsed[key] = [val];
|
|
1635
|
-
}
|
|
1636
|
-
} else {
|
|
1637
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1638
|
-
}
|
|
1639
|
-
});
|
|
1640
|
-
return parsed;
|
|
1561
|
+
function AxiosURLSearchParams(params, options) {
|
|
1562
|
+
this._pairs = [];
|
|
1563
|
+
params && toFormData(params, this, options);
|
|
1564
|
+
}
|
|
1565
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
1566
|
+
prototype.append = function append(name, value) {
|
|
1567
|
+
this._pairs.push([name, value]);
|
|
1568
|
+
};
|
|
1569
|
+
prototype.toString = function toString(encoder) {
|
|
1570
|
+
const _encode = encoder ? function (value) {
|
|
1571
|
+
return encoder.call(this, value, encode$1);
|
|
1572
|
+
} : encode$1;
|
|
1573
|
+
return this._pairs.map(function each(pair) {
|
|
1574
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1575
|
+
}, '').join('&');
|
|
1641
1576
|
};
|
|
1642
1577
|
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
if (!isValidHeaderValue(String(value))) {
|
|
1654
|
-
throw new Error(`Invalid character in header content ["${header}"]`);
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
function normalizeHeader(header) {
|
|
1658
|
-
return header && String(header).trim().toLowerCase();
|
|
1578
|
+
/**
|
|
1579
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1580
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1581
|
+
*
|
|
1582
|
+
* @param {string} val The value to be encoded.
|
|
1583
|
+
*
|
|
1584
|
+
* @returns {string} The encoded value.
|
|
1585
|
+
*/
|
|
1586
|
+
function encode(val) {
|
|
1587
|
+
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
|
|
1659
1588
|
}
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Build a URL by appending params to the end
|
|
1592
|
+
*
|
|
1593
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
1594
|
+
* @param {object} [params] The params to be appended
|
|
1595
|
+
* @param {?(object|Function)} options
|
|
1596
|
+
*
|
|
1597
|
+
* @returns {string} The formatted url
|
|
1598
|
+
*/
|
|
1599
|
+
function buildURL(url, params, options) {
|
|
1600
|
+
if (!params) {
|
|
1601
|
+
return url;
|
|
1668
1602
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1603
|
+
const _encode = options && options.encode || encode;
|
|
1604
|
+
const _options = utils$1.isFunction(options) ? {
|
|
1605
|
+
serialize: options
|
|
1606
|
+
} : options;
|
|
1607
|
+
const serializeFn = _options && _options.serialize;
|
|
1608
|
+
let serializedParams;
|
|
1609
|
+
if (serializeFn) {
|
|
1610
|
+
serializedParams = serializeFn(params, _options);
|
|
1611
|
+
} else {
|
|
1612
|
+
serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1674
1613
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
while (match = tokensRE.exec(str)) {
|
|
1682
|
-
tokens[match[1]] = match[2];
|
|
1614
|
+
if (serializedParams) {
|
|
1615
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1616
|
+
if (hashmarkIndex !== -1) {
|
|
1617
|
+
url = url.slice(0, hashmarkIndex);
|
|
1618
|
+
}
|
|
1619
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
1683
1620
|
}
|
|
1684
|
-
return
|
|
1621
|
+
return url;
|
|
1685
1622
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1623
|
+
|
|
1624
|
+
class InterceptorManager {
|
|
1625
|
+
constructor() {
|
|
1626
|
+
this.handlers = [];
|
|
1690
1627
|
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1628
|
+
|
|
1629
|
+
/**
|
|
1630
|
+
* Add a new interceptor to the stack
|
|
1631
|
+
*
|
|
1632
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1633
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1634
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1635
|
+
*
|
|
1636
|
+
* @return {Number} An ID used to remove interceptor later
|
|
1637
|
+
*/
|
|
1638
|
+
use(fulfilled, rejected, options) {
|
|
1639
|
+
this.handlers.push({
|
|
1640
|
+
fulfilled,
|
|
1641
|
+
rejected,
|
|
1642
|
+
synchronous: options ? options.synchronous : false,
|
|
1643
|
+
runWhen: options ? options.runWhen : null
|
|
1644
|
+
});
|
|
1645
|
+
return this.handlers.length - 1;
|
|
1693
1646
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Remove an interceptor from the stack
|
|
1650
|
+
*
|
|
1651
|
+
* @param {Number} id The ID that was returned by `use`
|
|
1652
|
+
*
|
|
1653
|
+
* @returns {void}
|
|
1654
|
+
*/
|
|
1655
|
+
eject(id) {
|
|
1656
|
+
if (this.handlers[id]) {
|
|
1657
|
+
this.handlers[id] = null;
|
|
1658
|
+
}
|
|
1697
1659
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* Clear all interceptors from the stack
|
|
1663
|
+
*
|
|
1664
|
+
* @returns {void}
|
|
1665
|
+
*/
|
|
1666
|
+
clear() {
|
|
1667
|
+
if (this.handlers) {
|
|
1668
|
+
this.handlers = [];
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Iterate over all the registered interceptors
|
|
1674
|
+
*
|
|
1675
|
+
* This method is particularly useful for skipping over any
|
|
1676
|
+
* interceptors that may have become `null` calling `eject`.
|
|
1677
|
+
*
|
|
1678
|
+
* @param {Function} fn The function to call for each interceptor
|
|
1679
|
+
*
|
|
1680
|
+
* @returns {void}
|
|
1681
|
+
*/
|
|
1682
|
+
forEach(fn) {
|
|
1683
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1684
|
+
if (h !== null) {
|
|
1685
|
+
fn(h);
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1700
1688
|
}
|
|
1701
1689
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1690
|
+
|
|
1691
|
+
var transitionalDefaults = {
|
|
1692
|
+
silentJSONParsing: true,
|
|
1693
|
+
forcedJSONParsing: true,
|
|
1694
|
+
clarifyTimeoutError: false,
|
|
1695
|
+
legacyInterceptorReqResOrdering: true
|
|
1696
|
+
};
|
|
1697
|
+
|
|
1698
|
+
var URLSearchParams = url.URLSearchParams;
|
|
1699
|
+
|
|
1700
|
+
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
1701
|
+
const DIGIT = '0123456789';
|
|
1702
|
+
const ALPHABET = {
|
|
1703
|
+
DIGIT,
|
|
1704
|
+
ALPHA,
|
|
1705
|
+
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
1706
|
+
};
|
|
1707
|
+
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
1708
|
+
let str = '';
|
|
1709
|
+
const {
|
|
1710
|
+
length
|
|
1711
|
+
} = alphabet;
|
|
1712
|
+
const randomValues = new Uint32Array(size);
|
|
1713
|
+
crypto.randomFillSync(randomValues);
|
|
1714
|
+
for (let i = 0; i < size; i++) {
|
|
1715
|
+
str += alphabet[randomValues[i] % length];
|
|
1716
|
+
}
|
|
1717
|
+
return str;
|
|
1718
|
+
};
|
|
1719
|
+
var platform$1 = {
|
|
1720
|
+
isNode: true,
|
|
1721
|
+
classes: {
|
|
1722
|
+
URLSearchParams,
|
|
1723
|
+
FormData: FormData$1,
|
|
1724
|
+
Blob: typeof Blob !== 'undefined' && Blob || null
|
|
1725
|
+
},
|
|
1726
|
+
ALPHABET,
|
|
1727
|
+
generateString,
|
|
1728
|
+
protocols: ['http', 'https', 'file', 'data']
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1732
|
+
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
1733
|
+
|
|
1734
|
+
/**
|
|
1735
|
+
* Determine if we're running in a standard browser environment
|
|
1736
|
+
*
|
|
1737
|
+
* This allows axios to run in a web worker, and react-native.
|
|
1738
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1739
|
+
*
|
|
1740
|
+
* web workers:
|
|
1741
|
+
* typeof window -> undefined
|
|
1742
|
+
* typeof document -> undefined
|
|
1743
|
+
*
|
|
1744
|
+
* react-native:
|
|
1745
|
+
* navigator.product -> 'ReactNative'
|
|
1746
|
+
* nativescript
|
|
1747
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
1748
|
+
*
|
|
1749
|
+
* @returns {boolean}
|
|
1750
|
+
*/
|
|
1751
|
+
const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1752
|
+
|
|
1753
|
+
/**
|
|
1754
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
1755
|
+
*
|
|
1756
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
1757
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
1758
|
+
* filtered out due to its judgment standard
|
|
1759
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1760
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
1761
|
+
*/
|
|
1762
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
1763
|
+
return typeof WorkerGlobalScope !== 'undefined' &&
|
|
1764
|
+
// eslint-disable-next-line no-undef
|
|
1765
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
|
|
1766
|
+
})();
|
|
1767
|
+
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1768
|
+
|
|
1769
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
1770
|
+
__proto__: null,
|
|
1771
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
1772
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1773
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1774
|
+
navigator: _navigator,
|
|
1775
|
+
origin: origin
|
|
1776
|
+
});
|
|
1777
|
+
|
|
1778
|
+
var platform = {
|
|
1779
|
+
...utils,
|
|
1780
|
+
...platform$1
|
|
1781
|
+
};
|
|
1782
|
+
|
|
1783
|
+
function toURLEncodedForm(data, options) {
|
|
1784
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
1785
|
+
visitor: function (value, key, path, helpers) {
|
|
1786
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1787
|
+
this.append(key, value.toString('base64'));
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
1791
|
+
},
|
|
1792
|
+
...options
|
|
1705
1793
|
});
|
|
1706
1794
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
1798
|
+
*
|
|
1799
|
+
* @param {string} name - The name of the property to get.
|
|
1800
|
+
*
|
|
1801
|
+
* @returns An array of strings.
|
|
1802
|
+
*/
|
|
1803
|
+
function parsePropPath(name) {
|
|
1804
|
+
// foo[x][y][z]
|
|
1805
|
+
// foo.x.y.z
|
|
1806
|
+
// foo-x-y-z
|
|
1807
|
+
// foo x y z
|
|
1808
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1809
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1716
1810
|
});
|
|
1717
1811
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1736
|
-
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1737
|
-
setHeaders(header, valueOrRewrite);
|
|
1738
|
-
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1739
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1740
|
-
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1741
|
-
let obj = {},
|
|
1742
|
-
dest,
|
|
1743
|
-
key;
|
|
1744
|
-
for (const entry of header) {
|
|
1745
|
-
if (!utils$1.isArray(entry)) {
|
|
1746
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
1747
|
-
}
|
|
1748
|
-
obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
|
|
1749
|
-
}
|
|
1750
|
-
setHeaders(obj, valueOrRewrite);
|
|
1751
|
-
} else {
|
|
1752
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1753
|
-
}
|
|
1754
|
-
return this;
|
|
1755
|
-
}
|
|
1756
|
-
get(header, parser) {
|
|
1757
|
-
header = normalizeHeader(header);
|
|
1758
|
-
if (header) {
|
|
1759
|
-
const key = utils$1.findKey(this, header);
|
|
1760
|
-
if (key) {
|
|
1761
|
-
const value = this[key];
|
|
1762
|
-
if (!parser) {
|
|
1763
|
-
return value;
|
|
1764
|
-
}
|
|
1765
|
-
if (parser === true) {
|
|
1766
|
-
return parseTokens(value);
|
|
1767
|
-
}
|
|
1768
|
-
if (utils$1.isFunction(parser)) {
|
|
1769
|
-
return parser.call(this, value, key);
|
|
1770
|
-
}
|
|
1771
|
-
if (utils$1.isRegExp(parser)) {
|
|
1772
|
-
return parser.exec(value);
|
|
1773
|
-
}
|
|
1774
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
has(header, matcher) {
|
|
1779
|
-
header = normalizeHeader(header);
|
|
1780
|
-
if (header) {
|
|
1781
|
-
const key = utils$1.findKey(this, header);
|
|
1782
|
-
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1783
|
-
}
|
|
1784
|
-
return false;
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* Convert an array to an object.
|
|
1815
|
+
*
|
|
1816
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
1817
|
+
*
|
|
1818
|
+
* @returns An object with the same keys and values as the array.
|
|
1819
|
+
*/
|
|
1820
|
+
function arrayToObject(arr) {
|
|
1821
|
+
const obj = {};
|
|
1822
|
+
const keys = Object.keys(arr);
|
|
1823
|
+
let i;
|
|
1824
|
+
const len = keys.length;
|
|
1825
|
+
let key;
|
|
1826
|
+
for (i = 0; i < len; i++) {
|
|
1827
|
+
key = keys[i];
|
|
1828
|
+
obj[key] = arr[key];
|
|
1785
1829
|
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1830
|
+
return obj;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* It takes a FormData object and returns a JavaScript object
|
|
1835
|
+
*
|
|
1836
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
1837
|
+
*
|
|
1838
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
1839
|
+
*/
|
|
1840
|
+
function formDataToJSON(formData) {
|
|
1841
|
+
function buildPath(path, value, target, index) {
|
|
1842
|
+
let name = path[index++];
|
|
1843
|
+
if (name === '__proto__') return true;
|
|
1844
|
+
const isNumericKey = Number.isFinite(+name);
|
|
1845
|
+
const isLast = index >= path.length;
|
|
1846
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
1847
|
+
if (isLast) {
|
|
1848
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
1849
|
+
target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
|
|
1850
|
+
} else {
|
|
1851
|
+
target[name] = value;
|
|
1797
1852
|
}
|
|
1853
|
+
return !isNumericKey;
|
|
1798
1854
|
}
|
|
1799
|
-
if (utils$1.
|
|
1800
|
-
|
|
1801
|
-
} else {
|
|
1802
|
-
deleteHeader(header);
|
|
1855
|
+
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
1856
|
+
target[name] = [];
|
|
1803
1857
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
const keys = Object.keys(this);
|
|
1808
|
-
let i = keys.length;
|
|
1809
|
-
let deleted = false;
|
|
1810
|
-
while (i--) {
|
|
1811
|
-
const key = keys[i];
|
|
1812
|
-
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1813
|
-
delete this[key];
|
|
1814
|
-
deleted = true;
|
|
1815
|
-
}
|
|
1858
|
+
const result = buildPath(path, value, target[name], index);
|
|
1859
|
+
if (result && utils$1.isArray(target[name])) {
|
|
1860
|
+
target[name] = arrayToObject(target[name]);
|
|
1816
1861
|
}
|
|
1817
|
-
return
|
|
1818
|
-
}
|
|
1819
|
-
normalize(format) {
|
|
1820
|
-
const self = this;
|
|
1821
|
-
const headers = {};
|
|
1822
|
-
utils$1.forEach(this, (value, header) => {
|
|
1823
|
-
const key = utils$1.findKey(headers, header);
|
|
1824
|
-
if (key) {
|
|
1825
|
-
self[key] = normalizeValue(value);
|
|
1826
|
-
delete self[header];
|
|
1827
|
-
return;
|
|
1828
|
-
}
|
|
1829
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1830
|
-
if (normalized !== header) {
|
|
1831
|
-
delete self[header];
|
|
1832
|
-
}
|
|
1833
|
-
self[normalized] = normalizeValue(value);
|
|
1834
|
-
headers[normalized] = true;
|
|
1835
|
-
});
|
|
1836
|
-
return this;
|
|
1837
|
-
}
|
|
1838
|
-
concat(...targets) {
|
|
1839
|
-
return this.constructor.concat(this, ...targets);
|
|
1862
|
+
return !isNumericKey;
|
|
1840
1863
|
}
|
|
1841
|
-
|
|
1842
|
-
const obj =
|
|
1843
|
-
utils$1.
|
|
1844
|
-
|
|
1864
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
1865
|
+
const obj = {};
|
|
1866
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
1867
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
1845
1868
|
});
|
|
1846
|
-
return obj;
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
};
|
|
1872
|
-
const accessors = internals.accessors;
|
|
1873
|
-
const prototype = this.prototype;
|
|
1874
|
-
function defineAccessor(_header) {
|
|
1875
|
-
const lHeader = normalizeHeader(_header);
|
|
1876
|
-
if (!accessors[lHeader]) {
|
|
1877
|
-
buildAccessors(prototype, _header);
|
|
1878
|
-
accessors[lHeader] = true;
|
|
1869
|
+
return obj;
|
|
1870
|
+
}
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
const own = (obj, key) => obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
|
|
1875
|
+
|
|
1876
|
+
/**
|
|
1877
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1878
|
+
* of the input
|
|
1879
|
+
*
|
|
1880
|
+
* @param {any} rawValue - The value to be stringified.
|
|
1881
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
1882
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
1883
|
+
*
|
|
1884
|
+
* @returns {string} A stringified version of the rawValue.
|
|
1885
|
+
*/
|
|
1886
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
1887
|
+
if (utils$1.isString(rawValue)) {
|
|
1888
|
+
try {
|
|
1889
|
+
(parser || JSON.parse)(rawValue);
|
|
1890
|
+
return utils$1.trim(rawValue);
|
|
1891
|
+
} catch (e) {
|
|
1892
|
+
if (e.name !== 'SyntaxError') {
|
|
1893
|
+
throw e;
|
|
1879
1894
|
}
|
|
1880
1895
|
}
|
|
1881
|
-
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1882
|
-
return this;
|
|
1883
1896
|
}
|
|
1897
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
1884
1898
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
set(headerValue) {
|
|
1895
|
-
this[mapped] = headerValue;
|
|
1899
|
+
const defaults = {
|
|
1900
|
+
transitional: transitionalDefaults,
|
|
1901
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
1902
|
+
transformRequest: [function transformRequest(data, headers) {
|
|
1903
|
+
const contentType = headers.getContentType() || '';
|
|
1904
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1905
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1906
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1907
|
+
data = new FormData(data);
|
|
1896
1908
|
}
|
|
1897
|
-
|
|
1909
|
+
const isFormData = utils$1.isFormData(data);
|
|
1910
|
+
if (isFormData) {
|
|
1911
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1912
|
+
}
|
|
1913
|
+
if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
|
|
1914
|
+
return data;
|
|
1915
|
+
}
|
|
1916
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1917
|
+
return data.buffer;
|
|
1918
|
+
}
|
|
1919
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1920
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1921
|
+
return data.toString();
|
|
1922
|
+
}
|
|
1923
|
+
let isFileList;
|
|
1924
|
+
if (isObjectPayload) {
|
|
1925
|
+
const formSerializer = own(this, 'formSerializer');
|
|
1926
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1927
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
1928
|
+
}
|
|
1929
|
+
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1930
|
+
const env = own(this, 'env');
|
|
1931
|
+
const _FormData = env && env.FormData;
|
|
1932
|
+
return toFormData(isFileList ? {
|
|
1933
|
+
'files[]': data
|
|
1934
|
+
} : data, _FormData && new _FormData(), formSerializer);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
1938
|
+
headers.setContentType('application/json', false);
|
|
1939
|
+
return stringifySafely(data);
|
|
1940
|
+
}
|
|
1941
|
+
return data;
|
|
1942
|
+
}],
|
|
1943
|
+
transformResponse: [function transformResponse(data) {
|
|
1944
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
1945
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1946
|
+
const responseType = own(this, 'responseType');
|
|
1947
|
+
const JSONRequested = responseType === 'json';
|
|
1948
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1949
|
+
return data;
|
|
1950
|
+
}
|
|
1951
|
+
if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
|
|
1952
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1953
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1954
|
+
try {
|
|
1955
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
1956
|
+
} catch (e) {
|
|
1957
|
+
if (strictJSONParsing) {
|
|
1958
|
+
if (e.name === 'SyntaxError') {
|
|
1959
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
1960
|
+
}
|
|
1961
|
+
throw e;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
return data;
|
|
1966
|
+
}],
|
|
1967
|
+
/**
|
|
1968
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
1969
|
+
* timeout is not created.
|
|
1970
|
+
*/
|
|
1971
|
+
timeout: 0,
|
|
1972
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
1973
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
1974
|
+
maxContentLength: -1,
|
|
1975
|
+
maxBodyLength: -1,
|
|
1976
|
+
env: {
|
|
1977
|
+
FormData: platform.classes.FormData,
|
|
1978
|
+
Blob: platform.classes.Blob
|
|
1979
|
+
},
|
|
1980
|
+
validateStatus: function validateStatus(status) {
|
|
1981
|
+
return status >= 200 && status < 300;
|
|
1982
|
+
},
|
|
1983
|
+
headers: {
|
|
1984
|
+
common: {
|
|
1985
|
+
Accept: 'application/json, text/plain, */*',
|
|
1986
|
+
'Content-Type': undefined
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], method => {
|
|
1991
|
+
defaults.headers[method] = {};
|
|
1898
1992
|
});
|
|
1899
|
-
utils$1.freezeMethods(AxiosHeaders);
|
|
1900
1993
|
|
|
1901
1994
|
/**
|
|
1902
1995
|
* Transform the data for a request or a response
|
|
@@ -1953,7 +2046,7 @@ function settle(resolve, reject, response) {
|
|
|
1953
2046
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
1954
2047
|
resolve(response);
|
|
1955
2048
|
} else {
|
|
1956
|
-
reject(new AxiosError('Request failed with status code ' + response.status,
|
|
2049
|
+
reject(new AxiosError('Request failed with status code ' + response.status, response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE, response.config, response.request, response));
|
|
1957
2050
|
}
|
|
1958
2051
|
}
|
|
1959
2052
|
|
|
@@ -1998,7 +2091,7 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
1998
2091
|
*/
|
|
1999
2092
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2000
2093
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2001
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
2094
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2002
2095
|
return combineURLs(baseURL, requestedURL);
|
|
2003
2096
|
}
|
|
2004
2097
|
return requestedURL;
|
|
@@ -2100,10 +2193,10 @@ function getEnv(key) {
|
|
|
2100
2193
|
return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
|
|
2101
2194
|
}
|
|
2102
2195
|
|
|
2103
|
-
const VERSION = "1.
|
|
2196
|
+
const VERSION = "1.16.0";
|
|
2104
2197
|
|
|
2105
2198
|
function parseProtocol(url) {
|
|
2106
|
-
const match = /^([-+\w]{1,25})(
|
|
2199
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
2107
2200
|
return match && match[1] || '';
|
|
2108
2201
|
}
|
|
2109
2202
|
|
|
@@ -2291,7 +2384,8 @@ class FormDataPart {
|
|
|
2291
2384
|
if (isStringValue) {
|
|
2292
2385
|
value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
|
|
2293
2386
|
} else {
|
|
2294
|
-
|
|
2387
|
+
const safeType = String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
2388
|
+
headers += `Content-Type: ${safeType}${CRLF}`;
|
|
2295
2389
|
}
|
|
2296
2390
|
this.headers = textEncoder.encode(headers + CRLF);
|
|
2297
2391
|
this.contentLength = isStringValue ? value.byteLength : value.size;
|
|
@@ -2329,7 +2423,7 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
|
2329
2423
|
throw TypeError('FormData instance required');
|
|
2330
2424
|
}
|
|
2331
2425
|
if (boundary.length < 1 || boundary.length > 70) {
|
|
2332
|
-
throw Error('boundary must be
|
|
2426
|
+
throw Error('boundary must be 1-70 characters long');
|
|
2333
2427
|
}
|
|
2334
2428
|
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
|
2335
2429
|
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
|
|
@@ -2392,6 +2486,47 @@ const callbackify = (fn, reducer) => {
|
|
|
2392
2486
|
} : fn;
|
|
2393
2487
|
};
|
|
2394
2488
|
|
|
2489
|
+
const LOOPBACK_HOSTNAMES = new Set(['localhost']);
|
|
2490
|
+
const isIPv4Loopback = host => {
|
|
2491
|
+
const parts = host.split('.');
|
|
2492
|
+
if (parts.length !== 4) return false;
|
|
2493
|
+
if (parts[0] !== '127') return false;
|
|
2494
|
+
return parts.every(p => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
2495
|
+
};
|
|
2496
|
+
const isIPv6Loopback = host => {
|
|
2497
|
+
// Collapse all-zero groups: any form of ::1 / 0:0:...:0:1
|
|
2498
|
+
// First, strip any leading "::" by normalising with Set lookup of common forms,
|
|
2499
|
+
// then fall back to structural check.
|
|
2500
|
+
if (host === '::1') return true;
|
|
2501
|
+
|
|
2502
|
+
// Check IPv4-mapped IPv6 loopback: ::ffff:<v4-loopback> or ::ffff:<hex-v4-loopback>
|
|
2503
|
+
// Node's URL parser normalises ::ffff:127.0.0.1 → ::ffff:7f00:1
|
|
2504
|
+
const v4MappedDotted = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
|
|
2505
|
+
if (v4MappedDotted) return isIPv4Loopback(v4MappedDotted[1]);
|
|
2506
|
+
const v4MappedHex = host.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);
|
|
2507
|
+
if (v4MappedHex) {
|
|
2508
|
+
const high = parseInt(v4MappedHex[1], 16);
|
|
2509
|
+
// High 16 bits must start with 127 (0x7f) — i.e. 0x7f00..0x7fff
|
|
2510
|
+
return high >= 0x7f00 && high <= 0x7fff;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
// Full-form ::1 variants: any number of zero groups followed by trailing 1
|
|
2514
|
+
// e.g. 0:0:0:0:0:0:0:1, 0000:...:0001
|
|
2515
|
+
const groups = host.split(':');
|
|
2516
|
+
if (groups.length === 8) {
|
|
2517
|
+
for (let i = 0; i < 7; i++) {
|
|
2518
|
+
if (!/^0+$/.test(groups[i])) return false;
|
|
2519
|
+
}
|
|
2520
|
+
return /^0*1$/.test(groups[7]);
|
|
2521
|
+
}
|
|
2522
|
+
return false;
|
|
2523
|
+
};
|
|
2524
|
+
const isLoopback = host => {
|
|
2525
|
+
if (!host) return false;
|
|
2526
|
+
if (LOOPBACK_HOSTNAMES.has(host)) return true;
|
|
2527
|
+
if (isIPv4Loopback(host)) return true;
|
|
2528
|
+
return isIPv6Loopback(host);
|
|
2529
|
+
};
|
|
2395
2530
|
const DEFAULT_PORTS = {
|
|
2396
2531
|
http: 80,
|
|
2397
2532
|
https: 443,
|
|
@@ -2421,6 +2556,27 @@ const parseNoProxyEntry = entry => {
|
|
|
2421
2556
|
}
|
|
2422
2557
|
return [entryHost, entryPort];
|
|
2423
2558
|
};
|
|
2559
|
+
|
|
2560
|
+
// Convert IPv4-mapped IPv6 (::ffff:0:0/96 prefix) to IPv4 dotted form so both
|
|
2561
|
+
// sides of a NO_PROXY comparison see the same canonical address. Without this,
|
|
2562
|
+
// `NO_PROXY=192.168.1.5` would not match a request to `http://[::ffff:192.168.1.5]/`
|
|
2563
|
+
// (Node's URL parser normalises that to `[::ffff:c0a8:105]`), and vice-versa,
|
|
2564
|
+
// allowing the proxy-bypass policy to be circumvented by using the alternate
|
|
2565
|
+
// representation. Returns the input unchanged when not IPv4-mapped.
|
|
2566
|
+
const IPV4_MAPPED_DOTTED_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i;
|
|
2567
|
+
const IPV4_MAPPED_HEX_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i;
|
|
2568
|
+
const unmapIPv4MappedIPv6 = host => {
|
|
2569
|
+
if (typeof host !== 'string' || host.indexOf(':') === -1) return host;
|
|
2570
|
+
const dotted = host.match(IPV4_MAPPED_DOTTED_RE);
|
|
2571
|
+
if (dotted) return dotted[1];
|
|
2572
|
+
const hex = host.match(IPV4_MAPPED_HEX_RE);
|
|
2573
|
+
if (hex) {
|
|
2574
|
+
const high = parseInt(hex[1], 16);
|
|
2575
|
+
const low = parseInt(hex[2], 16);
|
|
2576
|
+
return `${high >> 8}.${high & 0xff}.${low >> 8}.${low & 0xff}`;
|
|
2577
|
+
}
|
|
2578
|
+
return host;
|
|
2579
|
+
};
|
|
2424
2580
|
const normalizeNoProxyHost = hostname => {
|
|
2425
2581
|
if (!hostname) {
|
|
2426
2582
|
return hostname;
|
|
@@ -2428,7 +2584,7 @@ const normalizeNoProxyHost = hostname => {
|
|
|
2428
2584
|
if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') {
|
|
2429
2585
|
hostname = hostname.slice(1, -1);
|
|
2430
2586
|
}
|
|
2431
|
-
return hostname.replace(/\.+$/, '');
|
|
2587
|
+
return unmapIPv4MappedIPv6(hostname.replace(/\.+$/, ''));
|
|
2432
2588
|
};
|
|
2433
2589
|
function shouldBypassProxy(location) {
|
|
2434
2590
|
let parsed;
|
|
@@ -2464,7 +2620,7 @@ function shouldBypassProxy(location) {
|
|
|
2464
2620
|
if (entryHost.charAt(0) === '.') {
|
|
2465
2621
|
return hostname.endsWith(entryHost);
|
|
2466
2622
|
}
|
|
2467
|
-
return hostname === entryHost;
|
|
2623
|
+
return hostname === entryHost || isLoopback(hostname) && isLoopback(entryHost);
|
|
2468
2624
|
});
|
|
2469
2625
|
}
|
|
2470
2626
|
|
|
@@ -2551,19 +2707,19 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2551
2707
|
let bytesNotified = 0;
|
|
2552
2708
|
const _speedometer = speedometer(50, 250);
|
|
2553
2709
|
return throttle(e => {
|
|
2554
|
-
const
|
|
2710
|
+
const rawLoaded = e.loaded;
|
|
2555
2711
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2556
|
-
const
|
|
2712
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2713
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2557
2714
|
const rate = _speedometer(progressBytes);
|
|
2558
|
-
|
|
2559
|
-
bytesNotified = loaded;
|
|
2715
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2560
2716
|
const data = {
|
|
2561
2717
|
loaded,
|
|
2562
2718
|
total,
|
|
2563
2719
|
progress: total ? loaded / total : undefined,
|
|
2564
2720
|
bytes: progressBytes,
|
|
2565
2721
|
rate: rate ? rate : undefined,
|
|
2566
|
-
estimated: rate && total
|
|
2722
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2567
2723
|
event: e,
|
|
2568
2724
|
lengthComputable: total != null,
|
|
2569
2725
|
[isDownloadStream ? 'download' : 'upload']: true
|
|
@@ -2641,7 +2797,34 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
2641
2797
|
const bytes = groups * 3 - (pad || 0);
|
|
2642
2798
|
return bytes > 0 ? bytes : 0;
|
|
2643
2799
|
}
|
|
2644
|
-
|
|
2800
|
+
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
2801
|
+
return Buffer.byteLength(body, 'utf8');
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
2805
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
2806
|
+
// Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
|
|
2807
|
+
// but 3 UTF-8 bytes).
|
|
2808
|
+
let bytes = 0;
|
|
2809
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
2810
|
+
const c = body.charCodeAt(i);
|
|
2811
|
+
if (c < 0x80) {
|
|
2812
|
+
bytes += 1;
|
|
2813
|
+
} else if (c < 0x800) {
|
|
2814
|
+
bytes += 2;
|
|
2815
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
2816
|
+
const next = body.charCodeAt(i + 1);
|
|
2817
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
2818
|
+
bytes += 4;
|
|
2819
|
+
i++;
|
|
2820
|
+
} else {
|
|
2821
|
+
bytes += 3;
|
|
2822
|
+
}
|
|
2823
|
+
} else {
|
|
2824
|
+
bytes += 3;
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
return bytes;
|
|
2645
2828
|
}
|
|
2646
2829
|
|
|
2647
2830
|
const zlibOptions = {
|
|
@@ -2658,9 +2841,41 @@ const {
|
|
|
2658
2841
|
https: httpsFollow
|
|
2659
2842
|
} = followRedirects;
|
|
2660
2843
|
const isHttps = /https:?/;
|
|
2844
|
+
const FORM_DATA_CONTENT_HEADERS$1 = ['content-type', 'content-length'];
|
|
2845
|
+
function setFormDataHeaders$1(headers, formHeaders, policy) {
|
|
2846
|
+
if (policy !== 'content-only') {
|
|
2847
|
+
headers.set(formHeaders);
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2851
|
+
if (FORM_DATA_CONTENT_HEADERS$1.includes(key.toLowerCase())) {
|
|
2852
|
+
headers.set(key, val);
|
|
2853
|
+
}
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
// Symbols used to bind a single 'error' listener to a pooled socket and track
|
|
2858
|
+
// the request currently owning that socket across keep-alive reuse (issue #10780).
|
|
2859
|
+
const kAxiosSocketListener = Symbol('axios.http.socketListener');
|
|
2860
|
+
const kAxiosCurrentReq = Symbol('axios.http.currentReq');
|
|
2661
2861
|
const supportedProtocols = platform.protocols.map(protocol => {
|
|
2662
2862
|
return protocol + ':';
|
|
2663
2863
|
});
|
|
2864
|
+
|
|
2865
|
+
// Node's WHATWG URL parser returns `username` and `password` percent-encoded.
|
|
2866
|
+
// Decode before composing the `auth` option so credentials such as
|
|
2867
|
+
// `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
|
|
2868
|
+
// original value for malformed input so a bad encoding never throws.
|
|
2869
|
+
const decodeURIComponentSafe = value => {
|
|
2870
|
+
if (!utils$1.isString(value)) {
|
|
2871
|
+
return value;
|
|
2872
|
+
}
|
|
2873
|
+
try {
|
|
2874
|
+
return decodeURIComponent(value);
|
|
2875
|
+
} catch (error) {
|
|
2876
|
+
return value;
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2664
2879
|
const flushOnFinish = (stream, [throttled, flush]) => {
|
|
2665
2880
|
stream.on('end', flush).on('error', flush);
|
|
2666
2881
|
return throttled;
|
|
@@ -2748,12 +2963,12 @@ const http2Sessions = new Http2Sessions();
|
|
|
2748
2963
|
*
|
|
2749
2964
|
* @returns {Object<string, any>}
|
|
2750
2965
|
*/
|
|
2751
|
-
function dispatchBeforeRedirect(options, responseDetails) {
|
|
2966
|
+
function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
|
|
2752
2967
|
if (options.beforeRedirects.proxy) {
|
|
2753
2968
|
options.beforeRedirects.proxy(options);
|
|
2754
2969
|
}
|
|
2755
2970
|
if (options.beforeRedirects.config) {
|
|
2756
|
-
options.beforeRedirects.config(options, responseDetails);
|
|
2971
|
+
options.beforeRedirects.config(options, responseDetails, requestDetails);
|
|
2757
2972
|
}
|
|
2758
2973
|
}
|
|
2759
2974
|
|
|
@@ -2766,7 +2981,7 @@ function dispatchBeforeRedirect(options, responseDetails) {
|
|
|
2766
2981
|
*
|
|
2767
2982
|
* @returns {http.ClientRequestArgs}
|
|
2768
2983
|
*/
|
|
2769
|
-
function setProxy(options, configProxy, location) {
|
|
2984
|
+
function setProxy(options, configProxy, location, isRedirect) {
|
|
2770
2985
|
let proxy = configProxy;
|
|
2771
2986
|
if (!proxy && proxy !== false) {
|
|
2772
2987
|
const proxyUrl = getProxyForUrl(location);
|
|
@@ -2776,39 +2991,80 @@ function setProxy(options, configProxy, location) {
|
|
|
2776
2991
|
}
|
|
2777
2992
|
}
|
|
2778
2993
|
}
|
|
2994
|
+
// On redirect re-invocation, strip any stale Proxy-Authorization header carried
|
|
2995
|
+
// over from the prior request (e.g. new target no longer uses a proxy, or uses
|
|
2996
|
+
// a different proxy). Skip on the initial request so user-supplied headers are
|
|
2997
|
+
// preserved. Header names are case-insensitive, so remove every case variant.
|
|
2998
|
+
if (isRedirect && options.headers) {
|
|
2999
|
+
for (const name of Object.keys(options.headers)) {
|
|
3000
|
+
if (name.toLowerCase() === 'proxy-authorization') {
|
|
3001
|
+
delete options.headers[name];
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
2779
3005
|
if (proxy) {
|
|
3006
|
+
// Read proxy fields without traversing the prototype chain. URL instances expose
|
|
3007
|
+
// username/password/hostname/host/port/protocol via getters on URL.prototype (so
|
|
3008
|
+
// direct reads are shielded), but plain object proxies — and the `auth` field
|
|
3009
|
+
// (which URL does not expose) — must be guarded so a polluted Object.prototype
|
|
3010
|
+
// (e.g. Object.prototype.auth = { username, password }) cannot inject
|
|
3011
|
+
// attacker-controlled credentials into the Proxy-Authorization header or
|
|
3012
|
+
// redirect proxying to an attacker-controlled host.
|
|
3013
|
+
const isProxyURL = proxy instanceof URL;
|
|
3014
|
+
const readProxyField = key => isProxyURL || utils$1.hasOwnProp(proxy, key) ? proxy[key] : undefined;
|
|
3015
|
+
const proxyUsername = readProxyField('username');
|
|
3016
|
+
const proxyPassword = readProxyField('password');
|
|
3017
|
+
let proxyAuth = utils$1.hasOwnProp(proxy, 'auth') ? proxy.auth : undefined;
|
|
3018
|
+
|
|
2780
3019
|
// Basic proxy authorization
|
|
2781
|
-
if (
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2784
|
-
if (
|
|
2785
|
-
// Support proxy auth object form
|
|
2786
|
-
|
|
3020
|
+
if (proxyUsername) {
|
|
3021
|
+
proxyAuth = (proxyUsername || '') + ':' + (proxyPassword || '');
|
|
3022
|
+
}
|
|
3023
|
+
if (proxyAuth) {
|
|
3024
|
+
// Support proxy auth object form. Read sub-fields via own-prop checks so a
|
|
3025
|
+
// plain object inheriting from polluted Object.prototype cannot leak creds.
|
|
3026
|
+
const authIsObject = typeof proxyAuth === 'object';
|
|
3027
|
+
const authUsername = authIsObject && utils$1.hasOwnProp(proxyAuth, 'username') ? proxyAuth.username : undefined;
|
|
3028
|
+
const authPassword = authIsObject && utils$1.hasOwnProp(proxyAuth, 'password') ? proxyAuth.password : undefined;
|
|
3029
|
+
const validProxyAuth = Boolean(authUsername || authPassword);
|
|
2787
3030
|
if (validProxyAuth) {
|
|
2788
|
-
|
|
2789
|
-
} else if (
|
|
3031
|
+
proxyAuth = (authUsername || '') + ':' + (authPassword || '');
|
|
3032
|
+
} else if (authIsObject) {
|
|
2790
3033
|
throw new AxiosError('Invalid proxy authorization', AxiosError.ERR_BAD_OPTION, {
|
|
2791
3034
|
proxy
|
|
2792
3035
|
});
|
|
2793
3036
|
}
|
|
2794
|
-
const base64 = Buffer.from(
|
|
3037
|
+
const base64 = Buffer.from(proxyAuth, 'utf8').toString('base64');
|
|
2795
3038
|
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
|
2796
3039
|
}
|
|
2797
|
-
|
|
2798
|
-
|
|
3040
|
+
|
|
3041
|
+
// Preserve a user-supplied Host header (case-insensitive) so callers can override
|
|
3042
|
+
// the value forwarded to the proxy; otherwise default to the request URL's host.
|
|
3043
|
+
let hasUserHostHeader = false;
|
|
3044
|
+
for (const name of Object.keys(options.headers)) {
|
|
3045
|
+
if (name.toLowerCase() === 'host') {
|
|
3046
|
+
hasUserHostHeader = true;
|
|
3047
|
+
break;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
if (!hasUserHostHeader) {
|
|
3051
|
+
options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
|
|
3052
|
+
}
|
|
3053
|
+
const proxyHost = readProxyField('hostname') || readProxyField('host');
|
|
2799
3054
|
options.hostname = proxyHost;
|
|
2800
3055
|
// Replace 'host' since options is not a URL object
|
|
2801
3056
|
options.host = proxyHost;
|
|
2802
|
-
options.port =
|
|
3057
|
+
options.port = readProxyField('port');
|
|
2803
3058
|
options.path = location;
|
|
2804
|
-
|
|
2805
|
-
|
|
3059
|
+
const proxyProtocol = readProxyField('protocol');
|
|
3060
|
+
if (proxyProtocol) {
|
|
3061
|
+
options.protocol = proxyProtocol.includes(':') ? proxyProtocol : `${proxyProtocol}:`;
|
|
2806
3062
|
}
|
|
2807
3063
|
}
|
|
2808
3064
|
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
|
|
2809
3065
|
// Configure proxy for redirected request, passing the original config proxy to apply
|
|
2810
3066
|
// the exact same logic as if the redirected request was performed by axios directly.
|
|
2811
|
-
setProxy(redirectOptions, configProxy, redirectOptions.href);
|
|
3067
|
+
setProxy(redirectOptions, configProxy, redirectOptions.href, true);
|
|
2812
3068
|
};
|
|
2813
3069
|
}
|
|
2814
3070
|
const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(process) === 'process';
|
|
@@ -2891,21 +3147,20 @@ const http2Transport = {
|
|
|
2891
3147
|
/*eslint consistent-return:0*/
|
|
2892
3148
|
var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2893
3149
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
const
|
|
2902
|
-
|
|
2903
|
-
responseEncoding
|
|
2904
|
-
} = config;
|
|
3150
|
+
const own = key => utils$1.hasOwnProp(config, key) ? config[key] : undefined;
|
|
3151
|
+
let data = own('data');
|
|
3152
|
+
let lookup = own('lookup');
|
|
3153
|
+
let family = own('family');
|
|
3154
|
+
let httpVersion = own('httpVersion');
|
|
3155
|
+
if (httpVersion === undefined) httpVersion = 1;
|
|
3156
|
+
let http2Options = own('http2Options');
|
|
3157
|
+
const responseType = own('responseType');
|
|
3158
|
+
const responseEncoding = own('responseEncoding');
|
|
2905
3159
|
const method = config.method.toUpperCase();
|
|
2906
3160
|
let isDone;
|
|
2907
3161
|
let rejected = false;
|
|
2908
3162
|
let req;
|
|
3163
|
+
let connectPhaseTimer;
|
|
2909
3164
|
httpVersion = +httpVersion;
|
|
2910
3165
|
if (Number.isNaN(httpVersion)) {
|
|
2911
3166
|
throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
|
|
@@ -2935,8 +3190,23 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
2935
3190
|
console.warn('emit error', err);
|
|
2936
3191
|
}
|
|
2937
3192
|
}
|
|
3193
|
+
function clearConnectPhaseTimer() {
|
|
3194
|
+
if (connectPhaseTimer) {
|
|
3195
|
+
clearTimeout(connectPhaseTimer);
|
|
3196
|
+
connectPhaseTimer = null;
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
function createTimeoutError() {
|
|
3200
|
+
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
3201
|
+
const transitional = config.transitional || transitionalDefaults;
|
|
3202
|
+
if (config.timeoutErrorMessage) {
|
|
3203
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
3204
|
+
}
|
|
3205
|
+
return new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, req);
|
|
3206
|
+
}
|
|
2938
3207
|
abortEmitter.once('abort', reject);
|
|
2939
3208
|
const onFinished = () => {
|
|
3209
|
+
clearConnectPhaseTimer();
|
|
2940
3210
|
if (config.cancelToken) {
|
|
2941
3211
|
config.cancelToken.unsubscribe(abort);
|
|
2942
3212
|
}
|
|
@@ -2953,6 +3223,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
2953
3223
|
}
|
|
2954
3224
|
onDone((response, isRejected) => {
|
|
2955
3225
|
isDone = true;
|
|
3226
|
+
clearConnectPhaseTimer();
|
|
2956
3227
|
if (isRejected) {
|
|
2957
3228
|
rejected = true;
|
|
2958
3229
|
onFinished();
|
|
@@ -3045,8 +3316,8 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3045
3316
|
boundary: userBoundary && userBoundary[1] || undefined
|
|
3046
3317
|
});
|
|
3047
3318
|
// support for https://www.npmjs.com/package/form-data api
|
|
3048
|
-
} else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
|
|
3049
|
-
headers
|
|
3319
|
+
} else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders) && data.getHeaders !== Object.prototype.getHeaders) {
|
|
3320
|
+
setFormDataHeaders$1(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
3050
3321
|
if (!headers.hasContentLength()) {
|
|
3051
3322
|
try {
|
|
3052
3323
|
const knownLength = await util.promisify(data.getLength).call(data);
|
|
@@ -3094,20 +3365,21 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3094
3365
|
|
|
3095
3366
|
// HTTP basic authentication
|
|
3096
3367
|
let auth = undefined;
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
const
|
|
3368
|
+
const configAuth = own('auth');
|
|
3369
|
+
if (configAuth) {
|
|
3370
|
+
const username = configAuth.username || '';
|
|
3371
|
+
const password = configAuth.password || '';
|
|
3100
3372
|
auth = username + ':' + password;
|
|
3101
3373
|
}
|
|
3102
3374
|
if (!auth && parsed.username) {
|
|
3103
|
-
const urlUsername = parsed.username;
|
|
3104
|
-
const urlPassword = parsed.password;
|
|
3375
|
+
const urlUsername = decodeURIComponentSafe(parsed.username);
|
|
3376
|
+
const urlPassword = decodeURIComponentSafe(parsed.password);
|
|
3105
3377
|
auth = urlUsername + ':' + urlPassword;
|
|
3106
3378
|
}
|
|
3107
3379
|
auth && headers.delete('authorization');
|
|
3108
|
-
let path;
|
|
3380
|
+
let path$1;
|
|
3109
3381
|
try {
|
|
3110
|
-
path = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, '');
|
|
3382
|
+
path$1 = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, '');
|
|
3111
3383
|
} catch (err) {
|
|
3112
3384
|
const customErr = new Error(err.message);
|
|
3113
3385
|
customErr.config = config;
|
|
@@ -3116,8 +3388,11 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3116
3388
|
return reject(customErr);
|
|
3117
3389
|
}
|
|
3118
3390
|
headers.set('Accept-Encoding', 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false);
|
|
3119
|
-
|
|
3120
|
-
|
|
3391
|
+
|
|
3392
|
+
// Null-prototype to block prototype pollution gadgets on properties read
|
|
3393
|
+
// directly by Node's http.request (e.g. insecureHTTPParser, lookup).
|
|
3394
|
+
const options = Object.assign(Object.create(null), {
|
|
3395
|
+
path: path$1,
|
|
3121
3396
|
method: method,
|
|
3122
3397
|
headers: headers.toJSON(),
|
|
3123
3398
|
agents: {
|
|
@@ -3128,13 +3403,24 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3128
3403
|
protocol,
|
|
3129
3404
|
family,
|
|
3130
3405
|
beforeRedirect: dispatchBeforeRedirect,
|
|
3131
|
-
beforeRedirects:
|
|
3406
|
+
beforeRedirects: Object.create(null),
|
|
3132
3407
|
http2Options
|
|
3133
|
-
};
|
|
3408
|
+
});
|
|
3134
3409
|
|
|
3135
3410
|
// cacheable-lookup integration hotfix
|
|
3136
3411
|
!utils$1.isUndefined(lookup) && (options.lookup = lookup);
|
|
3137
3412
|
if (config.socketPath) {
|
|
3413
|
+
if (typeof config.socketPath !== 'string') {
|
|
3414
|
+
return reject(new AxiosError('socketPath must be a string', AxiosError.ERR_BAD_OPTION_VALUE, config));
|
|
3415
|
+
}
|
|
3416
|
+
if (config.allowedSocketPaths != null) {
|
|
3417
|
+
const allowed = Array.isArray(config.allowedSocketPaths) ? config.allowedSocketPaths : [config.allowedSocketPaths];
|
|
3418
|
+
const resolvedSocket = path.resolve(config.socketPath);
|
|
3419
|
+
const isAllowed = allowed.some(entry => typeof entry === 'string' && path.resolve(entry) === resolvedSocket);
|
|
3420
|
+
if (!isAllowed) {
|
|
3421
|
+
return reject(new AxiosError(`socketPath "${config.socketPath}" is not permitted by allowedSocketPaths`, AxiosError.ERR_BAD_OPTION_VALUE, config));
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3138
3424
|
options.socketPath = config.socketPath;
|
|
3139
3425
|
} else {
|
|
3140
3426
|
options.hostname = parsed.hostname.startsWith('[') ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
@@ -3142,21 +3428,25 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3142
3428
|
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
|
3143
3429
|
}
|
|
3144
3430
|
let transport;
|
|
3431
|
+
let isNativeTransport = false;
|
|
3145
3432
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
3146
3433
|
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
3147
3434
|
if (isHttp2) {
|
|
3148
3435
|
transport = http2Transport;
|
|
3149
3436
|
} else {
|
|
3150
|
-
|
|
3151
|
-
|
|
3437
|
+
const configTransport = own('transport');
|
|
3438
|
+
if (configTransport) {
|
|
3439
|
+
transport = configTransport;
|
|
3152
3440
|
} else if (config.maxRedirects === 0) {
|
|
3153
3441
|
transport = isHttpsRequest ? https : http;
|
|
3442
|
+
isNativeTransport = true;
|
|
3154
3443
|
} else {
|
|
3155
3444
|
if (config.maxRedirects) {
|
|
3156
3445
|
options.maxRedirects = config.maxRedirects;
|
|
3157
3446
|
}
|
|
3158
|
-
|
|
3159
|
-
|
|
3447
|
+
const configBeforeRedirect = own('beforeRedirect');
|
|
3448
|
+
if (configBeforeRedirect) {
|
|
3449
|
+
options.beforeRedirects.config = configBeforeRedirect;
|
|
3160
3450
|
}
|
|
3161
3451
|
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
|
3162
3452
|
}
|
|
@@ -3167,12 +3457,15 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3167
3457
|
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
|
|
3168
3458
|
options.maxBodyLength = Infinity;
|
|
3169
3459
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3460
|
+
|
|
3461
|
+
// Always set an explicit own value so a polluted
|
|
3462
|
+
// Object.prototype.insecureHTTPParser cannot enable the lenient parser
|
|
3463
|
+
// through Node's internal options copy
|
|
3464
|
+
options.insecureHTTPParser = Boolean(own('insecureHTTPParser'));
|
|
3173
3465
|
|
|
3174
3466
|
// Create the request
|
|
3175
3467
|
req = transport.request(options, function handleResponse(res) {
|
|
3468
|
+
clearConnectPhaseTimer();
|
|
3176
3469
|
if (req.destroyed) return;
|
|
3177
3470
|
const streams = [res];
|
|
3178
3471
|
const responseLength = utils$1.toFiniteNumber(res.headers['content-length']);
|
|
@@ -3234,6 +3527,25 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3234
3527
|
request: lastRequest
|
|
3235
3528
|
};
|
|
3236
3529
|
if (responseType === 'stream') {
|
|
3530
|
+
// Enforce maxContentLength on streamed responses; previously this
|
|
3531
|
+
// was applied only to buffered responses.
|
|
3532
|
+
if (config.maxContentLength > -1) {
|
|
3533
|
+
const limit = config.maxContentLength;
|
|
3534
|
+
const source = responseStream;
|
|
3535
|
+
async function* enforceMaxContentLength() {
|
|
3536
|
+
let totalResponseBytes = 0;
|
|
3537
|
+
for await (const chunk of source) {
|
|
3538
|
+
totalResponseBytes += chunk.length;
|
|
3539
|
+
if (totalResponseBytes > limit) {
|
|
3540
|
+
throw new AxiosError('maxContentLength size of ' + limit + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, lastRequest);
|
|
3541
|
+
}
|
|
3542
|
+
yield chunk;
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
responseStream = stream.Readable.from(enforceMaxContentLength(), {
|
|
3546
|
+
objectMode: false
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3237
3549
|
response.data = responseStream;
|
|
3238
3550
|
settle(resolve, reject, response);
|
|
3239
3551
|
} else {
|
|
@@ -3255,13 +3567,13 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3255
3567
|
if (rejected) {
|
|
3256
3568
|
return;
|
|
3257
3569
|
}
|
|
3258
|
-
const err = new AxiosError('stream has been aborted', AxiosError.ERR_BAD_RESPONSE, config, lastRequest);
|
|
3570
|
+
const err = new AxiosError('stream has been aborted', AxiosError.ERR_BAD_RESPONSE, config, lastRequest, response);
|
|
3259
3571
|
responseStream.destroy(err);
|
|
3260
3572
|
reject(err);
|
|
3261
3573
|
});
|
|
3262
3574
|
responseStream.on('error', function handleStreamError(err) {
|
|
3263
|
-
if (
|
|
3264
|
-
reject(AxiosError.from(err, null, config, lastRequest));
|
|
3575
|
+
if (rejected) return;
|
|
3576
|
+
reject(AxiosError.from(err, null, config, lastRequest, response));
|
|
3265
3577
|
});
|
|
3266
3578
|
responseStream.on('end', function handleStreamEnd() {
|
|
3267
3579
|
try {
|
|
@@ -3300,9 +3612,44 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3300
3612
|
});
|
|
3301
3613
|
|
|
3302
3614
|
// set tcp keep alive to prevent drop connection by peer
|
|
3615
|
+
// Track every socket bound to this outer RedirectableRequest so a single
|
|
3616
|
+
// 'close' listener can release ownership on all of them. follow-redirects
|
|
3617
|
+
// re-emits the 'socket' event for each hop's native request onto the same
|
|
3618
|
+
// outer request, so attaching per-request listeners inside this handler
|
|
3619
|
+
// would accumulate across hops and trigger MaxListenersExceededWarning at
|
|
3620
|
+
// >= 11 redirects. Clearing only the last-bound socket would leave stale
|
|
3621
|
+
// kAxiosCurrentReq refs on earlier hop sockets returned to the keep-alive
|
|
3622
|
+
// pool, causing an idle-pool 'error' to be attributed to a closed req.
|
|
3623
|
+
const boundSockets = new Set();
|
|
3303
3624
|
req.on('socket', function handleRequestSocket(socket) {
|
|
3304
3625
|
// default interval of sending ack packet is 1 minute
|
|
3305
3626
|
socket.setKeepAlive(true, 1000 * 60);
|
|
3627
|
+
|
|
3628
|
+
// Install a single 'error' listener per socket (not per request) to avoid
|
|
3629
|
+
// accumulating listeners on pooled keep-alive sockets that get reassigned
|
|
3630
|
+
// to new requests before the previous request's 'close' fires (issue #10780).
|
|
3631
|
+
// The listener is bound to the socket's currently-active request via a
|
|
3632
|
+
// symbol, which is swapped as the socket is reassigned.
|
|
3633
|
+
if (!socket[kAxiosSocketListener]) {
|
|
3634
|
+
socket.on('error', function handleSocketError(err) {
|
|
3635
|
+
const current = socket[kAxiosCurrentReq];
|
|
3636
|
+
if (current && !current.destroyed) {
|
|
3637
|
+
current.destroy(err);
|
|
3638
|
+
}
|
|
3639
|
+
});
|
|
3640
|
+
socket[kAxiosSocketListener] = true;
|
|
3641
|
+
}
|
|
3642
|
+
socket[kAxiosCurrentReq] = req;
|
|
3643
|
+
boundSockets.add(socket);
|
|
3644
|
+
});
|
|
3645
|
+
req.once('close', function clearCurrentReq() {
|
|
3646
|
+
clearConnectPhaseTimer();
|
|
3647
|
+
for (const socket of boundSockets) {
|
|
3648
|
+
if (socket[kAxiosCurrentReq] === req) {
|
|
3649
|
+
socket[kAxiosCurrentReq] = null;
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3652
|
+
boundSockets.clear();
|
|
3306
3653
|
});
|
|
3307
3654
|
|
|
3308
3655
|
// Handle request timeout
|
|
@@ -3313,21 +3660,23 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3313
3660
|
abort(new AxiosError('error trying to parse `config.timeout` to int', AxiosError.ERR_BAD_OPTION_VALUE, config, req));
|
|
3314
3661
|
return;
|
|
3315
3662
|
}
|
|
3663
|
+
const handleTimeout = function handleTimeout() {
|
|
3664
|
+
if (isDone) return;
|
|
3665
|
+
abort(createTimeoutError());
|
|
3666
|
+
};
|
|
3667
|
+
if (isNativeTransport && timeout > 0) {
|
|
3668
|
+
// Native ClientRequest#setTimeout starts from the socket lifecycle and
|
|
3669
|
+
// may not fire while TCP connect is still pending. Mirror the
|
|
3670
|
+
// follow-redirects wall-clock timer for the maxRedirects === 0 path.
|
|
3671
|
+
connectPhaseTimer = setTimeout(handleTimeout, timeout);
|
|
3672
|
+
}
|
|
3316
3673
|
|
|
3317
3674
|
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
|
|
3318
3675
|
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
|
|
3319
3676
|
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
|
|
3320
3677
|
// And then these socket which be hang up will devouring CPU little by little.
|
|
3321
3678
|
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
|
3322
|
-
req.setTimeout(timeout,
|
|
3323
|
-
if (isDone) return;
|
|
3324
|
-
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
3325
|
-
const transitional = config.transitional || transitionalDefaults;
|
|
3326
|
-
if (config.timeoutErrorMessage) {
|
|
3327
|
-
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
3328
|
-
}
|
|
3329
|
-
abort(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, req));
|
|
3330
|
-
});
|
|
3679
|
+
req.setTimeout(timeout, handleTimeout);
|
|
3331
3680
|
} else {
|
|
3332
3681
|
// explicitly reset the socket timeout value for a possible `keep-alive` request
|
|
3333
3682
|
req.setTimeout(0);
|
|
@@ -3349,7 +3698,28 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3349
3698
|
abort(new CanceledError('Request stream has been aborted', config, req));
|
|
3350
3699
|
}
|
|
3351
3700
|
});
|
|
3352
|
-
|
|
3701
|
+
|
|
3702
|
+
// Enforce maxBodyLength for streamed uploads on the native http/https
|
|
3703
|
+
// transport (maxRedirects === 0); follow-redirects enforces it on the
|
|
3704
|
+
// other path.
|
|
3705
|
+
let uploadStream = data;
|
|
3706
|
+
if (config.maxBodyLength > -1 && config.maxRedirects === 0) {
|
|
3707
|
+
const limit = config.maxBodyLength;
|
|
3708
|
+
let bytesSent = 0;
|
|
3709
|
+
uploadStream = stream.pipeline([data, new stream.Transform({
|
|
3710
|
+
transform(chunk, _enc, cb) {
|
|
3711
|
+
bytesSent += chunk.length;
|
|
3712
|
+
if (bytesSent > limit) {
|
|
3713
|
+
return cb(new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, req));
|
|
3714
|
+
}
|
|
3715
|
+
cb(null, chunk);
|
|
3716
|
+
}
|
|
3717
|
+
})], utils$1.noop);
|
|
3718
|
+
uploadStream.on('error', err => {
|
|
3719
|
+
if (!req.destroyed) req.destroy(err);
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3722
|
+
uploadStream.pipe(req);
|
|
3353
3723
|
} else {
|
|
3354
3724
|
data && req.write(data);
|
|
3355
3725
|
req.end();
|
|
@@ -3387,8 +3757,20 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
3387
3757
|
},
|
|
3388
3758
|
read(name) {
|
|
3389
3759
|
if (typeof document === 'undefined') return null;
|
|
3390
|
-
|
|
3391
|
-
|
|
3760
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
3761
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
3762
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
3763
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
3764
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
3765
|
+
const cookies = document.cookie.split(';');
|
|
3766
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
3767
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
3768
|
+
const eq = cookie.indexOf('=');
|
|
3769
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
3770
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
return null;
|
|
3392
3774
|
},
|
|
3393
3775
|
remove(name) {
|
|
3394
3776
|
this.write(name, '', Date.now() - 86400000, '/');
|
|
@@ -3419,7 +3801,21 @@ const headersToObject = thing => thing instanceof AxiosHeaders ? {
|
|
|
3419
3801
|
function mergeConfig(config1, config2) {
|
|
3420
3802
|
// eslint-disable-next-line no-param-reassign
|
|
3421
3803
|
config2 = config2 || {};
|
|
3422
|
-
|
|
3804
|
+
|
|
3805
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
3806
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
3807
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
3808
|
+
// ergonomics for user code that relies on it.
|
|
3809
|
+
const config = Object.create(null);
|
|
3810
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
3811
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
3812
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
3813
|
+
__proto__: null,
|
|
3814
|
+
value: Object.prototype.hasOwnProperty,
|
|
3815
|
+
enumerable: false,
|
|
3816
|
+
writable: true,
|
|
3817
|
+
configurable: true
|
|
3818
|
+
});
|
|
3423
3819
|
function getMergedValue(target, source, prop, caseless) {
|
|
3424
3820
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
3425
3821
|
return utils$1.merge.call({
|
|
@@ -3458,9 +3854,9 @@ function mergeConfig(config1, config2) {
|
|
|
3458
3854
|
|
|
3459
3855
|
// eslint-disable-next-line consistent-return
|
|
3460
3856
|
function mergeDirectKeys(a, b, prop) {
|
|
3461
|
-
if (prop
|
|
3857
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
3462
3858
|
return getMergedValue(a, b);
|
|
3463
|
-
} else if (prop
|
|
3859
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
3464
3860
|
return getMergedValue(undefined, a);
|
|
3465
3861
|
}
|
|
3466
3862
|
}
|
|
@@ -3491,6 +3887,7 @@ function mergeConfig(config1, config2) {
|
|
|
3491
3887
|
httpsAgent: defaultToConfig2,
|
|
3492
3888
|
cancelToken: defaultToConfig2,
|
|
3493
3889
|
socketPath: defaultToConfig2,
|
|
3890
|
+
allowedSocketPaths: defaultToConfig2,
|
|
3494
3891
|
responseEncoding: defaultToConfig2,
|
|
3495
3892
|
validateStatus: mergeDirectKeys,
|
|
3496
3893
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
@@ -3501,42 +3898,64 @@ function mergeConfig(config1, config2) {
|
|
|
3501
3898
|
}), function computeConfigValue(prop) {
|
|
3502
3899
|
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
3503
3900
|
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
3504
|
-
const
|
|
3901
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
3902
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
3903
|
+
const configValue = merge(a, b, prop);
|
|
3505
3904
|
utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
|
|
3506
3905
|
});
|
|
3507
3906
|
return config;
|
|
3508
3907
|
}
|
|
3509
3908
|
|
|
3909
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
3910
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
3911
|
+
if (policy !== 'content-only') {
|
|
3912
|
+
headers.set(formHeaders);
|
|
3913
|
+
return;
|
|
3914
|
+
}
|
|
3915
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3916
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
3917
|
+
headers.set(key, val);
|
|
3918
|
+
}
|
|
3919
|
+
});
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
/**
|
|
3923
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
3924
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
3925
|
+
*
|
|
3926
|
+
* @param {string} str The string to encode
|
|
3927
|
+
*
|
|
3928
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3929
|
+
*/
|
|
3930
|
+
const encodeUTF8 = str => encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
3510
3931
|
var resolveConfig = config => {
|
|
3511
3932
|
const newConfig = mergeConfig({}, config);
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3933
|
+
|
|
3934
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
3935
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
3936
|
+
const own = key => utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
|
|
3937
|
+
const data = own('data');
|
|
3938
|
+
let withXSRFToken = own('withXSRFToken');
|
|
3939
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
3940
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
3941
|
+
let headers = own('headers');
|
|
3942
|
+
const auth = own('auth');
|
|
3943
|
+
const baseURL = own('baseURL');
|
|
3944
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
3945
|
+
const url = own('url');
|
|
3520
3946
|
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
3521
|
-
newConfig.url = buildURL(buildFullPath(
|
|
3947
|
+
newConfig.url = buildURL(buildFullPath(baseURL, url, allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
3522
3948
|
|
|
3523
3949
|
// HTTP basic authentication
|
|
3524
3950
|
if (auth) {
|
|
3525
|
-
headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ?
|
|
3951
|
+
headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : '')));
|
|
3526
3952
|
}
|
|
3527
3953
|
if (utils$1.isFormData(data)) {
|
|
3528
3954
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
3529
3955
|
headers.setContentType(undefined); // browser handles it
|
|
3530
3956
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3531
3957
|
// Node.js FormData (like form-data package)
|
|
3532
|
-
|
|
3533
|
-
// Only set safe headers to avoid overwriting security headers
|
|
3534
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
3535
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3536
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
3537
|
-
headers.set(key, val);
|
|
3538
|
-
}
|
|
3539
|
-
});
|
|
3958
|
+
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
3540
3959
|
}
|
|
3541
3960
|
}
|
|
3542
3961
|
|
|
@@ -3545,9 +3964,15 @@ var resolveConfig = config => {
|
|
|
3545
3964
|
// Specifically not if we're in a web worker, or react-native.
|
|
3546
3965
|
|
|
3547
3966
|
if (platform.hasStandardBrowserEnv) {
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3967
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
3968
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
3969
|
+
}
|
|
3970
|
+
|
|
3971
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
3972
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
3973
|
+
// the XSRF token cross-origin.
|
|
3974
|
+
const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
|
|
3975
|
+
if (shouldSendXSRF) {
|
|
3551
3976
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
3552
3977
|
if (xsrfValue) {
|
|
3553
3978
|
headers.set(xsrfHeaderName, xsrfValue);
|
|
@@ -3623,7 +4048,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3623
4048
|
// handled by onerror instead
|
|
3624
4049
|
// With one exception: request that using file: protocol, most browsers
|
|
3625
4050
|
// will return status as 0 even though it's a successful request
|
|
3626
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.
|
|
4051
|
+
if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith('file:'))) {
|
|
3627
4052
|
return;
|
|
3628
4053
|
}
|
|
3629
4054
|
// readystate handler is calling before onerror or ontimeout handlers,
|
|
@@ -3638,6 +4063,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3638
4063
|
return;
|
|
3639
4064
|
}
|
|
3640
4065
|
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
4066
|
+
done();
|
|
3641
4067
|
|
|
3642
4068
|
// Clean up request
|
|
3643
4069
|
request = null;
|
|
@@ -3653,6 +4079,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3653
4079
|
// attach the underlying event for consumers who want details
|
|
3654
4080
|
err.event = event || null;
|
|
3655
4081
|
reject(err);
|
|
4082
|
+
done();
|
|
3656
4083
|
request = null;
|
|
3657
4084
|
};
|
|
3658
4085
|
|
|
@@ -3664,6 +4091,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3664
4091
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3665
4092
|
}
|
|
3666
4093
|
reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
|
|
4094
|
+
done();
|
|
3667
4095
|
|
|
3668
4096
|
// Clean up request
|
|
3669
4097
|
request = null;
|
|
@@ -3710,6 +4138,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3710
4138
|
}
|
|
3711
4139
|
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
3712
4140
|
request.abort();
|
|
4141
|
+
done();
|
|
3713
4142
|
request = null;
|
|
3714
4143
|
};
|
|
3715
4144
|
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
@@ -3718,7 +4147,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3718
4147
|
}
|
|
3719
4148
|
}
|
|
3720
4149
|
const protocol = parseProtocol(_config.url);
|
|
3721
|
-
if (protocol && platform.protocols.
|
|
4150
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
3722
4151
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
3723
4152
|
return;
|
|
3724
4153
|
}
|
|
@@ -3852,17 +4281,6 @@ const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
|
3852
4281
|
const {
|
|
3853
4282
|
isFunction
|
|
3854
4283
|
} = utils$1;
|
|
3855
|
-
const globalFetchAPI = (({
|
|
3856
|
-
Request,
|
|
3857
|
-
Response
|
|
3858
|
-
}) => ({
|
|
3859
|
-
Request,
|
|
3860
|
-
Response
|
|
3861
|
-
}))(utils$1.global);
|
|
3862
|
-
const {
|
|
3863
|
-
ReadableStream: ReadableStream$1,
|
|
3864
|
-
TextEncoder: TextEncoder$1
|
|
3865
|
-
} = utils$1.global;
|
|
3866
4284
|
const test = (fn, ...args) => {
|
|
3867
4285
|
try {
|
|
3868
4286
|
return !!fn(...args);
|
|
@@ -3871,9 +4289,18 @@ const test = (fn, ...args) => {
|
|
|
3871
4289
|
}
|
|
3872
4290
|
};
|
|
3873
4291
|
const factory = env => {
|
|
4292
|
+
var _utils$global;
|
|
4293
|
+
const globalObject = (_utils$global = utils$1.global) !== null && _utils$global !== void 0 ? _utils$global : globalThis;
|
|
4294
|
+
const {
|
|
4295
|
+
ReadableStream,
|
|
4296
|
+
TextEncoder
|
|
4297
|
+
} = globalObject;
|
|
3874
4298
|
env = utils$1.merge.call({
|
|
3875
4299
|
skipUndefined: true
|
|
3876
|
-
},
|
|
4300
|
+
}, {
|
|
4301
|
+
Request: globalObject.Request,
|
|
4302
|
+
Response: globalObject.Response
|
|
4303
|
+
}, env);
|
|
3877
4304
|
const {
|
|
3878
4305
|
fetch: envFetch,
|
|
3879
4306
|
Request,
|
|
@@ -3885,20 +4312,22 @@ const factory = env => {
|
|
|
3885
4312
|
if (!isFetchSupported) {
|
|
3886
4313
|
return false;
|
|
3887
4314
|
}
|
|
3888
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
3889
|
-
const encodeText = isFetchSupported && (typeof TextEncoder
|
|
4315
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
4316
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? (encoder => str => encoder.encode(str))(new TextEncoder()) : async str => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
3890
4317
|
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
3891
4318
|
let duplexAccessed = false;
|
|
3892
|
-
const
|
|
3893
|
-
|
|
3894
|
-
body,
|
|
4319
|
+
const request = new Request(platform.origin, {
|
|
4320
|
+
body: new ReadableStream(),
|
|
3895
4321
|
method: 'POST',
|
|
3896
4322
|
get duplex() {
|
|
3897
4323
|
duplexAccessed = true;
|
|
3898
4324
|
return 'half';
|
|
3899
4325
|
}
|
|
3900
|
-
})
|
|
3901
|
-
|
|
4326
|
+
});
|
|
4327
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
4328
|
+
if (request.body != null) {
|
|
4329
|
+
request.body.cancel();
|
|
4330
|
+
}
|
|
3902
4331
|
return duplexAccessed && !hasContentType;
|
|
3903
4332
|
});
|
|
3904
4333
|
const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response('').body));
|
|
@@ -3957,8 +4386,12 @@ const factory = env => {
|
|
|
3957
4386
|
responseType,
|
|
3958
4387
|
headers,
|
|
3959
4388
|
withCredentials = 'same-origin',
|
|
3960
|
-
fetchOptions
|
|
4389
|
+
fetchOptions,
|
|
4390
|
+
maxContentLength,
|
|
4391
|
+
maxBodyLength
|
|
3961
4392
|
} = resolveConfig(config);
|
|
4393
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
4394
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
3962
4395
|
let _fetch = envFetch || fetch;
|
|
3963
4396
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3964
4397
|
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
@@ -3968,6 +4401,26 @@ const factory = env => {
|
|
|
3968
4401
|
});
|
|
3969
4402
|
let requestContentLength;
|
|
3970
4403
|
try {
|
|
4404
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
4405
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
4406
|
+
// "if (protocol === 'data:')" branch).
|
|
4407
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
4408
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
4409
|
+
if (estimated > maxContentLength) {
|
|
4410
|
+
throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
|
|
4414
|
+
// Enforce maxBodyLength against the outbound request body before dispatch.
|
|
4415
|
+
// Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
|
|
4416
|
+
// maxBodyLength limit'). Skip when the body length cannot be determined
|
|
4417
|
+
// (e.g. a live ReadableStream supplied by the caller).
|
|
4418
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
4419
|
+
const outboundLength = await resolveBodyLength(headers, data);
|
|
4420
|
+
if (typeof outboundLength === 'number' && isFinite(outboundLength) && outboundLength > maxBodyLength) {
|
|
4421
|
+
throw new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
|
|
4422
|
+
}
|
|
4423
|
+
}
|
|
3971
4424
|
if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
3972
4425
|
let _request = new Request(url, {
|
|
3973
4426
|
method: 'POST',
|
|
@@ -3990,6 +4443,18 @@ const factory = env => {
|
|
|
3990
4443
|
// Cloudflare Workers throws when credentials are defined
|
|
3991
4444
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3992
4445
|
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
4446
|
+
|
|
4447
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
4448
|
+
// delete it so fetch can set it correctly with the boundary
|
|
4449
|
+
if (utils$1.isFormData(data)) {
|
|
4450
|
+
const contentType = headers.getContentType();
|
|
4451
|
+
if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
|
|
4452
|
+
headers.delete('content-type');
|
|
4453
|
+
}
|
|
4454
|
+
}
|
|
4455
|
+
|
|
4456
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
4457
|
+
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
3993
4458
|
const resolvedOptions = {
|
|
3994
4459
|
...fetchOptions,
|
|
3995
4460
|
signal: composedSignal,
|
|
@@ -4001,21 +4466,59 @@ const factory = env => {
|
|
|
4001
4466
|
};
|
|
4002
4467
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
4003
4468
|
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
4469
|
+
|
|
4470
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
4471
|
+
// already exceeds the cap, reject before we start streaming.
|
|
4472
|
+
if (hasMaxContentLength) {
|
|
4473
|
+
const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4474
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
4475
|
+
throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4004
4478
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4005
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
4479
|
+
if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
|
|
4006
4480
|
const options = {};
|
|
4007
4481
|
['status', 'statusText', 'headers'].forEach(prop => {
|
|
4008
4482
|
options[prop] = response[prop];
|
|
4009
4483
|
});
|
|
4010
4484
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4011
4485
|
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [];
|
|
4012
|
-
|
|
4486
|
+
let bytesRead = 0;
|
|
4487
|
+
const onChunkProgress = loadedBytes => {
|
|
4488
|
+
if (hasMaxContentLength) {
|
|
4489
|
+
bytesRead = loadedBytes;
|
|
4490
|
+
if (bytesRead > maxContentLength) {
|
|
4491
|
+
throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
onProgress && onProgress(loadedBytes);
|
|
4495
|
+
};
|
|
4496
|
+
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
4013
4497
|
flush && flush();
|
|
4014
4498
|
unsubscribe && unsubscribe();
|
|
4015
4499
|
}), options);
|
|
4016
4500
|
}
|
|
4017
4501
|
responseType = responseType || 'text';
|
|
4018
4502
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
4503
|
+
|
|
4504
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
4505
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
4506
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
4507
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
4508
|
+
let materializedSize;
|
|
4509
|
+
if (responseData != null) {
|
|
4510
|
+
if (typeof responseData.byteLength === 'number') {
|
|
4511
|
+
materializedSize = responseData.byteLength;
|
|
4512
|
+
} else if (typeof responseData.size === 'number') {
|
|
4513
|
+
materializedSize = responseData.size;
|
|
4514
|
+
} else if (typeof responseData === 'string') {
|
|
4515
|
+
materializedSize = typeof TextEncoder === 'function' ? new TextEncoder().encode(responseData).byteLength : responseData.length;
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
4519
|
+
throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4019
4522
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4020
4523
|
return await new Promise((resolve, reject) => {
|
|
4021
4524
|
settle(resolve, reject, {
|
|
@@ -4029,6 +4532,17 @@ const factory = env => {
|
|
|
4029
4532
|
});
|
|
4030
4533
|
} catch (err) {
|
|
4031
4534
|
unsubscribe && unsubscribe();
|
|
4535
|
+
|
|
4536
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
4537
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
4538
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
4539
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError) {
|
|
4540
|
+
const canceledError = composedSignal.reason;
|
|
4541
|
+
canceledError.config = config;
|
|
4542
|
+
request && (canceledError.request = request);
|
|
4543
|
+
err !== canceledError && (canceledError.cause = err);
|
|
4544
|
+
throw canceledError;
|
|
4545
|
+
}
|
|
4032
4546
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4033
4547
|
throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response), {
|
|
4034
4548
|
cause: err.cause || err
|
|
@@ -4083,13 +4597,17 @@ const knownAdapters = {
|
|
|
4083
4597
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
4084
4598
|
if (fn) {
|
|
4085
4599
|
try {
|
|
4600
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
4601
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
4086
4602
|
Object.defineProperty(fn, 'name', {
|
|
4603
|
+
__proto__: null,
|
|
4087
4604
|
value
|
|
4088
4605
|
});
|
|
4089
4606
|
} catch (e) {
|
|
4090
4607
|
// eslint-disable-next-line no-empty
|
|
4091
4608
|
}
|
|
4092
4609
|
Object.defineProperty(fn, 'adapterName', {
|
|
4610
|
+
__proto__: null,
|
|
4093
4611
|
value
|
|
4094
4612
|
});
|
|
4095
4613
|
}
|
|
@@ -4204,8 +4722,15 @@ function dispatchRequest(config) {
|
|
|
4204
4722
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
4205
4723
|
throwIfCancellationRequested(config);
|
|
4206
4724
|
|
|
4207
|
-
//
|
|
4208
|
-
|
|
4725
|
+
// Expose the current response on config so that transformResponse can
|
|
4726
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
4727
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
4728
|
+
config.response = response;
|
|
4729
|
+
try {
|
|
4730
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
4731
|
+
} finally {
|
|
4732
|
+
delete config.response;
|
|
4733
|
+
}
|
|
4209
4734
|
response.headers = AxiosHeaders.from(response.headers);
|
|
4210
4735
|
return response;
|
|
4211
4736
|
}, function onAdapterRejection(reason) {
|
|
@@ -4214,7 +4739,12 @@ function dispatchRequest(config) {
|
|
|
4214
4739
|
|
|
4215
4740
|
// Transform response data
|
|
4216
4741
|
if (reason && reason.response) {
|
|
4217
|
-
|
|
4742
|
+
config.response = reason.response;
|
|
4743
|
+
try {
|
|
4744
|
+
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
|
4745
|
+
} finally {
|
|
4746
|
+
delete config.response;
|
|
4747
|
+
}
|
|
4218
4748
|
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
4219
4749
|
}
|
|
4220
4750
|
}
|
|
@@ -4285,7 +4815,9 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
4285
4815
|
let i = keys.length;
|
|
4286
4816
|
while (i-- > 0) {
|
|
4287
4817
|
const opt = keys[i];
|
|
4288
|
-
|
|
4818
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
4819
|
+
// a non-function validator and cause a TypeError.
|
|
4820
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
4289
4821
|
if (validator) {
|
|
4290
4822
|
const value = options[opt];
|
|
4291
4823
|
const result = value === undefined || validator(value, opt, options);
|
|
@@ -4417,7 +4949,7 @@ class Axios {
|
|
|
4417
4949
|
|
|
4418
4950
|
// Flatten headers
|
|
4419
4951
|
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
4420
|
-
headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], method => {
|
|
4952
|
+
headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], method => {
|
|
4421
4953
|
delete headers[method];
|
|
4422
4954
|
});
|
|
4423
4955
|
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
@@ -4498,7 +5030,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
4498
5030
|
}));
|
|
4499
5031
|
};
|
|
4500
5032
|
});
|
|
4501
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
5033
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
4502
5034
|
function generateHTTPMethod(isForm) {
|
|
4503
5035
|
return function httpMethod(url, data, config) {
|
|
4504
5036
|
return this.request(mergeConfig(config || {}, {
|
|
@@ -4512,7 +5044,12 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
4512
5044
|
};
|
|
4513
5045
|
}
|
|
4514
5046
|
Axios.prototype[method] = generateHTTPMethod();
|
|
4515
|
-
|
|
5047
|
+
|
|
5048
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
5049
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
5050
|
+
if (method !== 'query') {
|
|
5051
|
+
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
5052
|
+
}
|
|
4516
5053
|
});
|
|
4517
5054
|
|
|
4518
5055
|
/**
|