typesense-instantsearch-adapter 3.0.3-2 → 3.0.4
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/README.md +2 -0
- package/dist/typesense-instantsearch-adapter.js +1912 -477
- package/dist/typesense-instantsearch-adapter.js.map +1 -1
- package/dist/typesense-instantsearch-adapter.min.js +1 -1
- package/dist/typesense-instantsearch-adapter.min.js.LICENSE.txt +1 -1
- package/dist/typesense-instantsearch-adapter.min.js.map +1 -1
- package/index.d.ts +5 -0
- package/lib/Configuration.js +3 -1
- package/lib/Configuration.js.map +1 -1
- package/lib/SearchRequestAdapter.js +13 -2
- package/lib/SearchRequestAdapter.js.map +1 -1
- package/package.json +2 -2
- package/src/Configuration.js +2 -0
- package/src/SearchRequestAdapter.js +14 -2
|
@@ -1008,7 +1008,7 @@ var ApiCall = /** @class */ (function () {
|
|
|
1008
1008
|
var transformedData = data;
|
|
1009
1009
|
if (headers !== undefined &&
|
|
1010
1010
|
typeof data === "string" &&
|
|
1011
|
-
headers["content-type"] &&
|
|
1011
|
+
typeof headers["content-type"] === "string" &&
|
|
1012
1012
|
headers["content-type"].startsWith("application/json")) {
|
|
1013
1013
|
transformedData = JSON.parse(data);
|
|
1014
1014
|
}
|
|
@@ -1975,25 +1975,28 @@ var Configuration = /** @class */ (function () {
|
|
|
1975
1975
|
var _this = this;
|
|
1976
1976
|
this.nodes = options.nodes || [];
|
|
1977
1977
|
this.nodes = this.nodes
|
|
1978
|
+
.map(function (node) { return (tslib_1.__assign({}, node)); }) // Copy the caller's node objects before mutating them
|
|
1978
1979
|
.map(function (node) { return _this.setDefaultPathInNode(node); })
|
|
1979
|
-
.map(function (node) { return _this.setDefaultPortInNode(node); })
|
|
1980
|
-
.map(function (node) { return (tslib_1.__assign({}, node)); }); // Make a deep copy
|
|
1980
|
+
.map(function (node) { return _this.setDefaultPortInNode(node); });
|
|
1981
1981
|
if (options.randomizeNodes == null) {
|
|
1982
1982
|
options.randomizeNodes = true;
|
|
1983
1983
|
}
|
|
1984
1984
|
if (options.randomizeNodes === true) {
|
|
1985
1985
|
this.shuffleArray(this.nodes);
|
|
1986
1986
|
}
|
|
1987
|
-
this.nearestNode =
|
|
1987
|
+
this.nearestNode =
|
|
1988
|
+
options.nearestNode == null
|
|
1989
|
+
? options.nearestNode
|
|
1990
|
+
: tslib_1.__assign({}, options.nearestNode);
|
|
1988
1991
|
this.nearestNode = this.setDefaultPathInNode(this.nearestNode);
|
|
1989
1992
|
this.nearestNode = this.setDefaultPortInNode(this.nearestNode);
|
|
1990
1993
|
this.connectionTimeoutSeconds =
|
|
1991
1994
|
options.connectionTimeoutSeconds || options.timeoutSeconds || 5;
|
|
1992
1995
|
this.healthcheckIntervalSeconds = options.healthcheckIntervalSeconds || 60;
|
|
1993
1996
|
this.numRetries =
|
|
1994
|
-
|
|
1997
|
+
options.numRetries !== undefined && options.numRetries >= 0
|
|
1995
1998
|
? options.numRetries
|
|
1996
|
-
: this.nodes.length + (this.nearestNode == null ? 0 : 1)
|
|
1999
|
+
: this.nodes.length + (this.nearestNode == null ? 0 : 1) || 3;
|
|
1997
2000
|
this.retryIntervalSeconds = options.retryIntervalSeconds || 0.1;
|
|
1998
2001
|
this.apiKey = options.apiKey;
|
|
1999
2002
|
this.sendApiKeyAsQueryParam = options.sendApiKeyAsQueryParam; // We will set a default for this in Client and SearchClient
|
|
@@ -2488,16 +2491,19 @@ exports.Document = void 0;
|
|
|
2488
2491
|
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/typesense/node_modules/tslib/tslib.es6.mjs");
|
|
2489
2492
|
var Collections_1 = tslib_1.__importDefault(__webpack_require__(/*! ./Collections */ "./node_modules/typesense/lib/Typesense/Collections.js"));
|
|
2490
2493
|
var Documents_1 = tslib_1.__importDefault(__webpack_require__(/*! ./Documents */ "./node_modules/typesense/lib/Typesense/Documents.js"));
|
|
2494
|
+
var Utils_1 = __webpack_require__(/*! ./Utils */ "./node_modules/typesense/lib/Typesense/Utils.js");
|
|
2491
2495
|
var Document = /** @class */ (function () {
|
|
2492
2496
|
function Document(collectionName, documentId, apiCall) {
|
|
2493
2497
|
this.collectionName = collectionName;
|
|
2494
2498
|
this.documentId = documentId;
|
|
2495
2499
|
this.apiCall = apiCall;
|
|
2496
2500
|
}
|
|
2497
|
-
Document.prototype.retrieve = function () {
|
|
2501
|
+
Document.prototype.retrieve = function (options) {
|
|
2498
2502
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2503
|
+
var queryParams;
|
|
2499
2504
|
return tslib_1.__generator(this, function (_a) {
|
|
2500
|
-
|
|
2505
|
+
queryParams = (0, Utils_1.normalizeArrayableParams)(options !== null && options !== void 0 ? options : {});
|
|
2506
|
+
return [2 /*return*/, this.apiCall.get(this.endpointPath(), queryParams)];
|
|
2501
2507
|
});
|
|
2502
2508
|
});
|
|
2503
2509
|
};
|
|
@@ -2582,6 +2588,22 @@ var Documents = /** @class */ (function (_super) {
|
|
|
2582
2588
|
});
|
|
2583
2589
|
});
|
|
2584
2590
|
};
|
|
2591
|
+
Documents.prototype.emplace = function (document_1) {
|
|
2592
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (document, options) {
|
|
2593
|
+
if (options === void 0) { options = {}; }
|
|
2594
|
+
return tslib_1.__generator(this, function (_a) {
|
|
2595
|
+
if (!document)
|
|
2596
|
+
throw new Error("No document provided");
|
|
2597
|
+
if (options["filter_by"] != null) {
|
|
2598
|
+
return [2 /*return*/, this.apiCall.patch(this.endpointPath(), document, Object.assign({}, options))];
|
|
2599
|
+
}
|
|
2600
|
+
else {
|
|
2601
|
+
return [2 /*return*/, this.apiCall.post(this.endpointPath(), document, Object.assign({}, options, { action: "emplace" }))];
|
|
2602
|
+
}
|
|
2603
|
+
return [2 /*return*/];
|
|
2604
|
+
});
|
|
2605
|
+
});
|
|
2606
|
+
};
|
|
2585
2607
|
Documents.prototype.delete = function () {
|
|
2586
2608
|
return tslib_1.__awaiter(this, arguments, void 0, function (query) {
|
|
2587
2609
|
if (query === void 0) { query = {}; }
|
|
@@ -2600,11 +2622,12 @@ var Documents = /** @class */ (function (_super) {
|
|
|
2600
2622
|
});
|
|
2601
2623
|
};
|
|
2602
2624
|
Documents.prototype.import = function (documents_1) {
|
|
2603
|
-
return tslib_1.__awaiter(this, arguments, void 0, function (documents, options) {
|
|
2625
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (documents, options, _a) {
|
|
2604
2626
|
var finalOptions, documentsInJSONLFormat, resultsInJSONLFormat, resultsInJSONFormat, failedItems;
|
|
2605
2627
|
if (options === void 0) { options = {}; }
|
|
2606
|
-
|
|
2607
|
-
|
|
2628
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.abortSignal, abortSignal = _c === void 0 ? null : _c;
|
|
2629
|
+
return tslib_1.__generator(this, function (_d) {
|
|
2630
|
+
switch (_d.label) {
|
|
2608
2631
|
case 0:
|
|
2609
2632
|
finalOptions = tslib_1.__assign({ throwOnFail: true }, options);
|
|
2610
2633
|
if (Array.isArray(documents)) {
|
|
@@ -2636,11 +2659,12 @@ var Documents = /** @class */ (function (_super) {
|
|
|
2636
2659
|
queryParameters: finalOptions,
|
|
2637
2660
|
bodyParameters: documentsInJSONLFormat,
|
|
2638
2661
|
additionalHeaders: { "Content-Type": "text/plain" },
|
|
2662
|
+
abortSignal: abortSignal,
|
|
2639
2663
|
skipConnectionTimeout: true, // We never want to client-side-timeout on an import and retry, since imports are syncronous and we want to let them take as long as it takes to complete fully
|
|
2640
2664
|
enableKeepAlive: isNodeJSEnvironment ? true : false, // This is to prevent ECONNRESET socket hang up errors. Reference: https://github.com/axios/axios/issues/2936#issuecomment-779439991
|
|
2641
2665
|
})];
|
|
2642
2666
|
case 1:
|
|
2643
|
-
resultsInJSONLFormat =
|
|
2667
|
+
resultsInJSONLFormat = _d.sent();
|
|
2644
2668
|
if (Array.isArray(documents)) {
|
|
2645
2669
|
resultsInJSONFormat = resultsInJSONLFormat
|
|
2646
2670
|
.split("\n")
|
|
@@ -2670,22 +2694,24 @@ var Documents = /** @class */ (function (_super) {
|
|
|
2670
2694
|
* Imports documents from a NodeJS readable stream of JSONL.
|
|
2671
2695
|
*/
|
|
2672
2696
|
Documents.prototype.importStream = function (readableStream_1) {
|
|
2673
|
-
return tslib_1.__awaiter(this, arguments, void 0, function (readableStream, options) {
|
|
2697
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (readableStream, options, _a) {
|
|
2674
2698
|
var finalOptions, resultsInJSONLFormat, resultsInJSONFormat, failedItems;
|
|
2675
2699
|
if (options === void 0) { options = {}; }
|
|
2676
|
-
|
|
2677
|
-
|
|
2700
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.abortSignal, abortSignal = _c === void 0 ? null : _c;
|
|
2701
|
+
return tslib_1.__generator(this, function (_d) {
|
|
2702
|
+
switch (_d.label) {
|
|
2678
2703
|
case 0:
|
|
2679
2704
|
finalOptions = tslib_1.__assign({ throwOnFail: true }, options);
|
|
2680
2705
|
return [4 /*yield*/, this.apiCall.performRequest("post", this.endpointPath("import"), {
|
|
2681
2706
|
queryParameters: finalOptions,
|
|
2682
2707
|
bodyParameters: readableStream,
|
|
2683
2708
|
additionalHeaders: { "Content-Type": "text/plain" },
|
|
2709
|
+
abortSignal: abortSignal,
|
|
2684
2710
|
skipConnectionTimeout: true, // We never want to client-side-timeout on an import and retry, since imports are syncronous and we want to let them take as long as it takes to complete fully
|
|
2685
2711
|
enableKeepAlive: isNodeJSEnvironment ? true : false, // This is to prevent ECONNRESET socket hang up errors. Reference: https://github.com/axios/axios/issues/2936#issuecomment-779439991
|
|
2686
2712
|
})];
|
|
2687
2713
|
case 1:
|
|
2688
|
-
resultsInJSONLFormat =
|
|
2714
|
+
resultsInJSONLFormat = _d.sent();
|
|
2689
2715
|
resultsInJSONFormat = resultsInJSONLFormat
|
|
2690
2716
|
.split("\n")
|
|
2691
2717
|
.map(function (r) { return JSON.parse(r); });
|
|
@@ -3208,6 +3234,9 @@ var MultiSearch = /** @class */ (function () {
|
|
|
3208
3234
|
}
|
|
3209
3235
|
normalizedSearchRequests = {
|
|
3210
3236
|
union: searchRequests.union,
|
|
3237
|
+
remove_duplicates: "remove_duplicates" in searchRequests
|
|
3238
|
+
? searchRequests.remove_duplicates
|
|
3239
|
+
: undefined,
|
|
3211
3240
|
searches: searchRequests.searches.map((Utils_1.normalizeArrayableParams)),
|
|
3212
3241
|
};
|
|
3213
3242
|
streamConfig = params.streamConfig, paramsWithoutStream = tslib_1.__rest(params, ["streamConfig"]);
|
|
@@ -3229,7 +3258,7 @@ var MultiSearch = /** @class */ (function () {
|
|
|
3229
3258
|
});
|
|
3230
3259
|
};
|
|
3231
3260
|
MultiSearch.prototype.isStreamingRequest = function (commonParams) {
|
|
3232
|
-
return commonParams.
|
|
3261
|
+
return commonParams.conversation_stream === true;
|
|
3233
3262
|
};
|
|
3234
3263
|
MultiSearch.prototype.hasAnySearchObjectPagination = function (searchRequests) {
|
|
3235
3264
|
return searchRequests.searches.some(function (search) { return search.page !== undefined || search.per_page !== undefined || search.offset !== undefined || search.limit !== undefined || search.limit_hits !== undefined; });
|
|
@@ -3583,9 +3612,10 @@ var RequestWithCache = /** @class */ (function () {
|
|
|
3583
3612
|
};
|
|
3584
3613
|
RequestWithCache.prototype.perform = function (requestContext, methodName, requestParams, cacheOptions) {
|
|
3585
3614
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3586
|
-
var _a, _b, cacheResponseForSeconds, _c, maxSize, isCacheDisabled, path, queryParams, body, headers, streamConfig, abortSignal, responseType, isStreamingRequest, requestParamsJSON, cacheEntry, now, isEntryValid, cachePromiseEntry, isEntryValid, responsePromise, response, isCacheOverMaxSize, oldestEntry, isResponsePromiseCacheOverMaxSize, oldestEntry;
|
|
3587
|
-
|
|
3588
|
-
|
|
3615
|
+
var _a, _b, cacheResponseForSeconds, _c, maxSize, isCacheDisabled, path, queryParams, body, headers, streamConfig, abortSignal, responseType, isStreamingRequest, requestParamsJSON, cacheEntry, now, isEntryValid, cachePromiseEntry, isEntryValid, responsePromise, response, error_1, isCacheOverMaxSize, oldestEntry, isResponsePromiseCacheOverMaxSize, oldestEntry;
|
|
3616
|
+
var _d;
|
|
3617
|
+
return tslib_1.__generator(this, function (_e) {
|
|
3618
|
+
switch (_e.label) {
|
|
3589
3619
|
case 0:
|
|
3590
3620
|
_a = cacheOptions || {}, _b = _a.cacheResponseForSeconds, cacheResponseForSeconds = _b === void 0 ? defaultCacheResponseForSeconds : _b, _c = _a.maxSize, maxSize = _c === void 0 ? defaultMaxSize : _c;
|
|
3591
3621
|
isCacheDisabled = cacheOptions === undefined ||
|
|
@@ -3627,9 +3657,21 @@ var RequestWithCache = /** @class */ (function () {
|
|
|
3627
3657
|
requestTimestamp: now,
|
|
3628
3658
|
responsePromise: responsePromise,
|
|
3629
3659
|
});
|
|
3630
|
-
|
|
3660
|
+
_e.label = 1;
|
|
3631
3661
|
case 1:
|
|
3632
|
-
|
|
3662
|
+
_e.trys.push([1, 3, , 4]);
|
|
3663
|
+
return [4 /*yield*/, responsePromise];
|
|
3664
|
+
case 2:
|
|
3665
|
+
response = _e.sent();
|
|
3666
|
+
return [3 /*break*/, 4];
|
|
3667
|
+
case 3:
|
|
3668
|
+
error_1 = _e.sent();
|
|
3669
|
+
if (((_d = this.responsePromiseCache.get(requestParamsJSON)) === null || _d === void 0 ? void 0 : _d.responsePromise) ===
|
|
3670
|
+
responsePromise) {
|
|
3671
|
+
this.responsePromiseCache.delete(requestParamsJSON);
|
|
3672
|
+
}
|
|
3673
|
+
throw error_1;
|
|
3674
|
+
case 4:
|
|
3633
3675
|
this.responseCache.set(requestParamsJSON, {
|
|
3634
3676
|
requestTimestamp: now,
|
|
3635
3677
|
response: response,
|
|
@@ -4871,7 +4913,7 @@ try {
|
|
|
4871
4913
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4872
4914
|
|
|
4873
4915
|
"use strict";
|
|
4874
|
-
/*! Axios v1.
|
|
4916
|
+
/*! Axios v1.21.1 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
4875
4917
|
|
|
4876
4918
|
|
|
4877
4919
|
/**
|
|
@@ -4900,12 +4942,65 @@ const hasOwnProperty = (
|
|
|
4900
4942
|
hasOwnProperty.call(obj, prop)
|
|
4901
4943
|
)(Object.prototype);
|
|
4902
4944
|
|
|
4945
|
+
const isUnsafeObjectKey = (prop) =>
|
|
4946
|
+
typeof prop === 'string' &&
|
|
4947
|
+
(prop === '__proto__' || prop === 'constructor' || prop === 'prototype');
|
|
4948
|
+
|
|
4949
|
+
/**
|
|
4950
|
+
* Determine whether an inherited object must be treated as a shared-prototype
|
|
4951
|
+
* boundary. Cross-realm Object.prototype objects cannot be distinguished
|
|
4952
|
+
* reliably from application-created null-prototype objects because their
|
|
4953
|
+
* properties are mutable, so all inherited terminal prototypes are excluded
|
|
4954
|
+
* as a fail-closed boundary. A null-prototype source still keeps its own
|
|
4955
|
+
* properties, as produced by mergeConfig and other safe materialization paths.
|
|
4956
|
+
*
|
|
4957
|
+
* @param {*} obj The object to inspect
|
|
4958
|
+
* @param {*} prototype The object's prototype
|
|
4959
|
+
* @param {boolean} source Whether obj is the original traversal source
|
|
4960
|
+
*
|
|
4961
|
+
* @returns {boolean} True when obj is a safe prototype traversal boundary
|
|
4962
|
+
*/
|
|
4963
|
+
const isPrototypeBoundary = (obj, prototype, source) =>
|
|
4964
|
+
obj === Object.prototype || (!source && prototype === null);
|
|
4965
|
+
|
|
4966
|
+
/**
|
|
4967
|
+
* Determine whether an object can retain its identity through code paths that
|
|
4968
|
+
* add, replace, and remove config properties without bypassing unsafe-key
|
|
4969
|
+
* filtering. Immutable objects, unsafe-key-bearing objects, and objects with
|
|
4970
|
+
* accessor or restricted data properties must be materialized instead.
|
|
4971
|
+
*
|
|
4972
|
+
* @param {*} obj The object to inspect
|
|
4973
|
+
*
|
|
4974
|
+
* @returns {boolean} True when every own property is safe and fully mutable
|
|
4975
|
+
*/
|
|
4976
|
+
const isSafeAndFullyMutable = (obj) => {
|
|
4977
|
+
if (!Object.isExtensible(obj)) {
|
|
4978
|
+
return false;
|
|
4979
|
+
}
|
|
4980
|
+
|
|
4981
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
4982
|
+
|
|
4983
|
+
if (Object.getOwnPropertySymbols) {
|
|
4984
|
+
props.push(...Object.getOwnPropertySymbols(obj));
|
|
4985
|
+
}
|
|
4986
|
+
|
|
4987
|
+
return props.every((prop) => {
|
|
4988
|
+
if (isUnsafeObjectKey(prop)) {
|
|
4989
|
+
return false;
|
|
4990
|
+
}
|
|
4991
|
+
|
|
4992
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
4993
|
+
|
|
4994
|
+
return !!descriptor && descriptor.configurable && descriptor.writable === true;
|
|
4995
|
+
});
|
|
4996
|
+
};
|
|
4997
|
+
|
|
4903
4998
|
/**
|
|
4904
|
-
* Walk the prototype chain (excluding the
|
|
4905
|
-
* an own `prop`. This distinguishes genuine own/inherited members
|
|
4906
|
-
* class accessors and template prototypes — from members injected
|
|
4907
|
-
* Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
|
|
4908
|
-
* live on Object.prototype itself and are therefore never matched.
|
|
4999
|
+
* Walk the prototype chain (excluding the source realm's Object.prototype)
|
|
5000
|
+
* looking for an own `prop`. This distinguishes genuine own/inherited members
|
|
5001
|
+
* — including class accessors and template prototypes — from members injected
|
|
5002
|
+
* via Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
|
|
5003
|
+
* which live on Object.prototype itself and are therefore never matched.
|
|
4909
5004
|
*
|
|
4910
5005
|
* @param {*} thing The value whose chain to inspect
|
|
4911
5006
|
* @param {string|symbol} prop The property key to look for
|
|
@@ -4916,16 +5011,22 @@ const hasOwnInPrototypeChain = (thing, prop) => {
|
|
|
4916
5011
|
let obj = thing;
|
|
4917
5012
|
const seen = [];
|
|
4918
5013
|
|
|
4919
|
-
while (obj != null
|
|
5014
|
+
while (obj != null) {
|
|
4920
5015
|
if (seen.indexOf(obj) !== -1) {
|
|
4921
5016
|
return false;
|
|
4922
5017
|
}
|
|
4923
5018
|
seen.push(obj);
|
|
4924
5019
|
|
|
5020
|
+
const prototype = getPrototypeOf(obj);
|
|
5021
|
+
|
|
5022
|
+
if (isPrototypeBoundary(obj, prototype, obj === thing)) {
|
|
5023
|
+
return false;
|
|
5024
|
+
}
|
|
5025
|
+
|
|
4925
5026
|
if (hasOwnProperty(obj, prop)) {
|
|
4926
5027
|
return true;
|
|
4927
5028
|
}
|
|
4928
|
-
obj =
|
|
5029
|
+
obj = prototype;
|
|
4929
5030
|
}
|
|
4930
5031
|
return false;
|
|
4931
5032
|
};
|
|
@@ -4944,6 +5045,69 @@ const hasOwnInPrototypeChain = (thing, prop) => {
|
|
|
4944
5045
|
const getSafeProp = (obj, prop) =>
|
|
4945
5046
|
obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
4946
5047
|
|
|
5048
|
+
/**
|
|
5049
|
+
* Flatten an object and its application-defined prototype chain into a
|
|
5050
|
+
* null-prototype object. Members inherited only from the source realm's
|
|
5051
|
+
* Object.prototype are deliberately excluded, while class/template members
|
|
5052
|
+
* below that boundary are preserved.
|
|
5053
|
+
*
|
|
5054
|
+
* @param {*} thing The value to flatten
|
|
5055
|
+
*
|
|
5056
|
+
* @returns {*} A null-prototype copy, or the original value when it is already
|
|
5057
|
+
* structurally safe or is not an object
|
|
5058
|
+
*/
|
|
5059
|
+
const toSafeFlatObject = (thing) => {
|
|
5060
|
+
if (thing == null || (typeof thing !== 'object' && typeof thing !== 'function')) {
|
|
5061
|
+
return thing;
|
|
5062
|
+
}
|
|
5063
|
+
|
|
5064
|
+
const sourcePrototype = getPrototypeOf(thing);
|
|
5065
|
+
|
|
5066
|
+
if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
|
|
5067
|
+
return thing;
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5070
|
+
const result = Object.create(null);
|
|
5071
|
+
const merged = Object.create(null);
|
|
5072
|
+
const seen = [];
|
|
5073
|
+
let current = thing;
|
|
5074
|
+
|
|
5075
|
+
while (current != null) {
|
|
5076
|
+
if (seen.indexOf(current) !== -1) {
|
|
5077
|
+
break;
|
|
5078
|
+
}
|
|
5079
|
+
|
|
5080
|
+
seen.push(current);
|
|
5081
|
+
|
|
5082
|
+
const prototype = current === thing ? sourcePrototype : getPrototypeOf(current);
|
|
5083
|
+
|
|
5084
|
+
if (isPrototypeBoundary(current, prototype, current === thing)) {
|
|
5085
|
+
break;
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
const props = Object.getOwnPropertyNames(current);
|
|
5089
|
+
|
|
5090
|
+
if (Object.getOwnPropertySymbols) {
|
|
5091
|
+
props.push(...Object.getOwnPropertySymbols(current));
|
|
5092
|
+
}
|
|
5093
|
+
|
|
5094
|
+
for (const prop of props) {
|
|
5095
|
+
if (isUnsafeObjectKey(prop)) {
|
|
5096
|
+
continue;
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
if (!hasOwnProperty(merged, prop)) {
|
|
5100
|
+
result[prop] = thing[prop];
|
|
5101
|
+
merged[prop] = true;
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
|
|
5105
|
+
current = prototype;
|
|
5106
|
+
}
|
|
5107
|
+
|
|
5108
|
+
return result;
|
|
5109
|
+
};
|
|
5110
|
+
|
|
4947
5111
|
const kindOf = ((cache) => (thing) => {
|
|
4948
5112
|
const str = toString.call(thing);
|
|
4949
5113
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -5075,14 +5239,18 @@ const isPlainObject = (val) => {
|
|
|
5075
5239
|
|
|
5076
5240
|
const prototype = getPrototypeOf(val);
|
|
5077
5241
|
return (
|
|
5078
|
-
(prototype === null ||
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
//
|
|
5082
|
-
//
|
|
5083
|
-
//
|
|
5084
|
-
|
|
5085
|
-
|
|
5242
|
+
(prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
|
|
5243
|
+
// Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
|
|
5244
|
+
// value is tagged/iterable, ignoring members reachable only through shared
|
|
5245
|
+
// or terminal prototype boundaries. This is exactly what
|
|
5246
|
+
// hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
|
|
5247
|
+
// above (null, Object.prototype, or a terminal null-prototype template) is
|
|
5248
|
+
// a boundary, so the walk never inspects anything but `val`'s own members,
|
|
5249
|
+
// and stops before even those when `val` is itself the boundary
|
|
5250
|
+
// Object.prototype. Checking that inline avoids allocating the walker's
|
|
5251
|
+
// `seen` list twice per call on the mergeConfig / merge hot path.
|
|
5252
|
+
(isPrototypeBoundary(val, prototype, true) ||
|
|
5253
|
+
(!hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator)))
|
|
5086
5254
|
);
|
|
5087
5255
|
};
|
|
5088
5256
|
|
|
@@ -5167,6 +5335,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
5167
5335
|
* @returns {boolean} True if value is a FileList, otherwise false
|
|
5168
5336
|
*/
|
|
5169
5337
|
const isFileList = kindOfTest('FileList');
|
|
5338
|
+
const isSet = kindOfTest('Set');
|
|
5170
5339
|
|
|
5171
5340
|
/**
|
|
5172
5341
|
* Determine if a value is a Stream
|
|
@@ -5345,15 +5514,30 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
5345
5514
|
function merge(...objs) {
|
|
5346
5515
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
5347
5516
|
const result = {};
|
|
5517
|
+
// Caseless lookup only applies to string keys — symbol keys are
|
|
5518
|
+
// identity-matched. Every string key that reaches `result` passes through
|
|
5519
|
+
// this index first, so it can never hold two case variants of one key and a
|
|
5520
|
+
// lowercase -> key map is exactly what findKey(result, key) would rescan
|
|
5521
|
+
// Object.keys(result) for on each assignment.
|
|
5522
|
+
const lowerCaseKeys = caseless ? Object.create(null) : null;
|
|
5348
5523
|
const assignValue = (val, key) => {
|
|
5349
5524
|
// Skip dangerous property names to prevent prototype pollution
|
|
5350
5525
|
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
5351
5526
|
return;
|
|
5352
5527
|
}
|
|
5353
5528
|
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5529
|
+
let targetKey = key;
|
|
5530
|
+
if (lowerCaseKeys && typeof key === 'string') {
|
|
5531
|
+
const lowerKey = key.toLowerCase();
|
|
5532
|
+
const knownKey = lowerCaseKeys[lowerKey];
|
|
5533
|
+
// A key recorded but absent from `result` was skipped by skipUndefined;
|
|
5534
|
+
// the later spelling wins then, as it does for findKey.
|
|
5535
|
+
if (knownKey !== undefined && hasOwnProperty(result, knownKey)) {
|
|
5536
|
+
targetKey = knownKey;
|
|
5537
|
+
} else {
|
|
5538
|
+
lowerCaseKeys[lowerKey] = key;
|
|
5539
|
+
}
|
|
5540
|
+
}
|
|
5357
5541
|
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
5358
5542
|
// chain, so a polluted Object.prototype value could surface here and get
|
|
5359
5543
|
// copied into the merged result.
|
|
@@ -5377,7 +5561,7 @@ function merge(...objs) {
|
|
|
5377
5561
|
|
|
5378
5562
|
forEach(source, assignValue);
|
|
5379
5563
|
|
|
5380
|
-
if (typeof source !== 'object' || isArray(source)) {
|
|
5564
|
+
if (typeof source !== 'object' || isArray(source) || !Object.getOwnPropertySymbols) {
|
|
5381
5565
|
continue;
|
|
5382
5566
|
}
|
|
5383
5567
|
|
|
@@ -5536,7 +5720,37 @@ const toArray = (thing) => {
|
|
|
5536
5720
|
if (!thing) return null;
|
|
5537
5721
|
if (isArray(thing)) return thing;
|
|
5538
5722
|
let i = thing.length;
|
|
5539
|
-
if (!
|
|
5723
|
+
if (!Number.isSafeInteger(i) || i < 0 || i > 0xffffffff) return null;
|
|
5724
|
+
|
|
5725
|
+
// Bound the copy by actual indexed properties, including hidden and inherited
|
|
5726
|
+
// members of array-like collections, rather than by the declared length alone.
|
|
5727
|
+
const indexes = new Set();
|
|
5728
|
+
const seen = new Set();
|
|
5729
|
+
let source = thing;
|
|
5730
|
+
|
|
5731
|
+
while (source != null && indexes.size < i) {
|
|
5732
|
+
if (seen.has(source)) return null;
|
|
5733
|
+
seen.add(source);
|
|
5734
|
+
|
|
5735
|
+
const prototype = getPrototypeOf(source);
|
|
5736
|
+
if (isPrototypeBoundary(source, prototype, source === thing)) break;
|
|
5737
|
+
|
|
5738
|
+
Object.getOwnPropertyNames(source).forEach((key) => {
|
|
5739
|
+
const index = +key;
|
|
5740
|
+
if (
|
|
5741
|
+
Number.isInteger(index) &&
|
|
5742
|
+
index >= 0 &&
|
|
5743
|
+
index < i &&
|
|
5744
|
+
String(index) === key &&
|
|
5745
|
+
hasOwnProperty(source, key)
|
|
5746
|
+
) {
|
|
5747
|
+
indexes.add(index);
|
|
5748
|
+
}
|
|
5749
|
+
});
|
|
5750
|
+
source = prototype;
|
|
5751
|
+
}
|
|
5752
|
+
|
|
5753
|
+
if (indexes.size !== i) return null;
|
|
5540
5754
|
const arr = new Array(i);
|
|
5541
5755
|
while (i-- > 0) {
|
|
5542
5756
|
arr[i] = thing[i];
|
|
@@ -5732,12 +5946,23 @@ const toJSONObject = (obj) => {
|
|
|
5732
5946
|
if (!('toJSON' in source)) {
|
|
5733
5947
|
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
5734
5948
|
visited.add(source);
|
|
5735
|
-
const target = isArray(source) ? [] : {};
|
|
5736
5949
|
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5950
|
+
let target;
|
|
5951
|
+
|
|
5952
|
+
if (isSet(source)) {
|
|
5953
|
+
target = [];
|
|
5954
|
+
for (const value of source) {
|
|
5955
|
+
const reducedValue = visit(value);
|
|
5956
|
+
!isUndefined(reducedValue) && target.push(reducedValue);
|
|
5957
|
+
}
|
|
5958
|
+
} else {
|
|
5959
|
+
target = isArray(source) ? [] : {};
|
|
5960
|
+
|
|
5961
|
+
forEach(source, (value, key) => {
|
|
5962
|
+
const reducedValue = visit(value);
|
|
5963
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
5964
|
+
});
|
|
5965
|
+
}
|
|
5741
5966
|
|
|
5742
5967
|
visited.delete(source);
|
|
5743
5968
|
|
|
@@ -5882,6 +6107,7 @@ var utils$1 = {
|
|
|
5882
6107
|
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
5883
6108
|
hasOwnInPrototypeChain,
|
|
5884
6109
|
getSafeProp,
|
|
6110
|
+
toSafeFlatObject,
|
|
5885
6111
|
reduceDescriptors,
|
|
5886
6112
|
freezeMethods,
|
|
5887
6113
|
toObjectSet,
|
|
@@ -5938,7 +6164,8 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
|
5938
6164
|
* @returns {Object} Headers parsed into an object
|
|
5939
6165
|
*/
|
|
5940
6166
|
var parseHeaders = (rawHeaders) => {
|
|
5941
|
-
|
|
6167
|
+
// Header names are data, including __proto__; avoid inherited setters.
|
|
6168
|
+
const parsed = Object.create(null);
|
|
5942
6169
|
let key;
|
|
5943
6170
|
let val;
|
|
5944
6171
|
let i;
|
|
@@ -5949,18 +6176,20 @@ var parseHeaders = (rawHeaders) => {
|
|
|
5949
6176
|
key = line.substring(0, i).trim().toLowerCase();
|
|
5950
6177
|
val = line.substring(i + 1).trim();
|
|
5951
6178
|
|
|
5952
|
-
|
|
6179
|
+
const hasKey = utils$1.hasOwnProp(parsed, key);
|
|
6180
|
+
|
|
6181
|
+
if (!key || (hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key))) {
|
|
5953
6182
|
return;
|
|
5954
6183
|
}
|
|
5955
6184
|
|
|
5956
6185
|
if (key === 'set-cookie') {
|
|
5957
|
-
if (
|
|
6186
|
+
if (hasKey) {
|
|
5958
6187
|
parsed[key].push(val);
|
|
5959
6188
|
} else {
|
|
5960
6189
|
parsed[key] = [val];
|
|
5961
6190
|
}
|
|
5962
6191
|
} else {
|
|
5963
|
-
parsed[key] =
|
|
6192
|
+
parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
|
|
5964
6193
|
}
|
|
5965
6194
|
});
|
|
5966
6195
|
|
|
@@ -6024,7 +6253,7 @@ function toByteStringHeaderObject(headers) {
|
|
|
6024
6253
|
return byteStringHeaders;
|
|
6025
6254
|
}
|
|
6026
6255
|
|
|
6027
|
-
const $internals = Symbol('internals');
|
|
6256
|
+
const $internals$1 = Symbol('internals');
|
|
6028
6257
|
|
|
6029
6258
|
function normalizeHeader(header) {
|
|
6030
6259
|
return header && String(header).trim().toLowerCase();
|
|
@@ -6050,11 +6279,142 @@ function parseTokens(str) {
|
|
|
6050
6279
|
return tokens;
|
|
6051
6280
|
}
|
|
6052
6281
|
|
|
6282
|
+
const parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
6283
|
+
|
|
6284
|
+
function trimOWS(value) {
|
|
6285
|
+
let start = 0;
|
|
6286
|
+
let end = value.length;
|
|
6287
|
+
|
|
6288
|
+
while (start < end) {
|
|
6289
|
+
const code = value.charCodeAt(start);
|
|
6290
|
+
|
|
6291
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
6292
|
+
break;
|
|
6293
|
+
}
|
|
6294
|
+
|
|
6295
|
+
start += 1;
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
while (end > start) {
|
|
6299
|
+
const code = value.charCodeAt(end - 1);
|
|
6300
|
+
|
|
6301
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
6302
|
+
break;
|
|
6303
|
+
}
|
|
6304
|
+
|
|
6305
|
+
end -= 1;
|
|
6306
|
+
}
|
|
6307
|
+
|
|
6308
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
6309
|
+
}
|
|
6310
|
+
|
|
6311
|
+
function decodeQuotedString(value) {
|
|
6312
|
+
const last = value.length - 1;
|
|
6313
|
+
|
|
6314
|
+
if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
|
|
6315
|
+
return value;
|
|
6316
|
+
}
|
|
6317
|
+
|
|
6318
|
+
let decoded = '';
|
|
6319
|
+
|
|
6320
|
+
for (let i = 1; i < last; i++) {
|
|
6321
|
+
const code = value.charCodeAt(i);
|
|
6322
|
+
|
|
6323
|
+
if (code === 0x22) {
|
|
6324
|
+
return value;
|
|
6325
|
+
}
|
|
6326
|
+
|
|
6327
|
+
if (code === 0x5c) {
|
|
6328
|
+
i += 1;
|
|
6329
|
+
|
|
6330
|
+
if (i >= last) {
|
|
6331
|
+
return value;
|
|
6332
|
+
}
|
|
6333
|
+
}
|
|
6334
|
+
|
|
6335
|
+
decoded += value[i];
|
|
6336
|
+
}
|
|
6337
|
+
|
|
6338
|
+
return decoded;
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
function parseParameters(value) {
|
|
6342
|
+
const parameters = Object.create(null);
|
|
6343
|
+
const str = String(value);
|
|
6344
|
+
let start = 0;
|
|
6345
|
+
let quoted = false;
|
|
6346
|
+
let escaped = false;
|
|
6347
|
+
|
|
6348
|
+
function parseParameter(end) {
|
|
6349
|
+
const part = trimOWS(str.slice(start, end));
|
|
6350
|
+
const equals = part.indexOf('=');
|
|
6351
|
+
|
|
6352
|
+
if (equals < 1) {
|
|
6353
|
+
return;
|
|
6354
|
+
}
|
|
6355
|
+
|
|
6356
|
+
const name = trimOWS(part.slice(0, equals));
|
|
6357
|
+
|
|
6358
|
+
if (!parameterNameRE.test(name)) {
|
|
6359
|
+
return;
|
|
6360
|
+
}
|
|
6361
|
+
|
|
6362
|
+
const normalizedName = name.toLowerCase();
|
|
6363
|
+
|
|
6364
|
+
if (
|
|
6365
|
+
normalizedName === '__proto__' ||
|
|
6366
|
+
normalizedName === 'constructor' ||
|
|
6367
|
+
normalizedName === 'prototype'
|
|
6368
|
+
) {
|
|
6369
|
+
return;
|
|
6370
|
+
}
|
|
6371
|
+
|
|
6372
|
+
const parameterValue = trimOWS(part.slice(equals + 1));
|
|
6373
|
+
parameters[normalizedName] = decodeQuotedString(parameterValue);
|
|
6374
|
+
}
|
|
6375
|
+
|
|
6376
|
+
for (let i = 0; i < str.length; i++) {
|
|
6377
|
+
const code = str.charCodeAt(i);
|
|
6378
|
+
|
|
6379
|
+
if (quoted) {
|
|
6380
|
+
if (escaped) {
|
|
6381
|
+
escaped = false;
|
|
6382
|
+
} else if (code === 0x5c) {
|
|
6383
|
+
escaped = true;
|
|
6384
|
+
} else if (code === 0x22) {
|
|
6385
|
+
quoted = false;
|
|
6386
|
+
}
|
|
6387
|
+
} else if (code === 0x22) {
|
|
6388
|
+
quoted = true;
|
|
6389
|
+
} else if (code === 0x2c || code === 0x3b) {
|
|
6390
|
+
parseParameter(i);
|
|
6391
|
+
start = i + 1;
|
|
6392
|
+
}
|
|
6393
|
+
}
|
|
6394
|
+
|
|
6395
|
+
parseParameter(str.length);
|
|
6396
|
+
|
|
6397
|
+
return parameters;
|
|
6398
|
+
}
|
|
6399
|
+
|
|
6053
6400
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
6054
6401
|
|
|
6402
|
+
// `__proto__` is a valid field name, and the one name the uppercase mapping at
|
|
6403
|
+
// the bottom of this file cannot reach: it is inherited from Object.prototype
|
|
6404
|
+
// instead of being declared on AxiosHeaders.prototype, so `self.__proto__ = v`
|
|
6405
|
+
// runs the inherited setter. That silently discards the header, and an array
|
|
6406
|
+
// value replaces the instance prototype, taking every method with it.
|
|
6407
|
+
// Store it under the same kind of case variant that mapping uses for `set` and
|
|
6408
|
+
// `constructor`. Header lookup is caseless, so it reads back under either
|
|
6409
|
+
// spelling, and no own `__proto__` slot is ever created for a later
|
|
6410
|
+
// `Object.assign` to copy onto a plain object through the same setter.
|
|
6411
|
+
const PROTO_HEADER_SLOT = '__Proto__';
|
|
6412
|
+
|
|
6413
|
+
const headerSlot = (name) => (name === '__proto__' ? PROTO_HEADER_SLOT : name);
|
|
6414
|
+
|
|
6055
6415
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
6056
6416
|
if (utils$1.isFunction(filter)) {
|
|
6057
|
-
return filter.call(
|
|
6417
|
+
return filter.call(context, value, header);
|
|
6058
6418
|
}
|
|
6059
6419
|
|
|
6060
6420
|
if (isHeaderNameFilter) {
|
|
@@ -6120,7 +6480,7 @@ class AxiosHeaders {
|
|
|
6120
6480
|
_rewrite === true ||
|
|
6121
6481
|
(_rewrite === undefined && self[key] !== false)
|
|
6122
6482
|
) {
|
|
6123
|
-
self[key || _header] = normalizeValue(_value);
|
|
6483
|
+
self[headerSlot(key || _header)] = normalizeValue(_value);
|
|
6124
6484
|
}
|
|
6125
6485
|
}
|
|
6126
6486
|
|
|
@@ -6249,7 +6609,7 @@ class AxiosHeaders {
|
|
|
6249
6609
|
|
|
6250
6610
|
normalize(format) {
|
|
6251
6611
|
const self = this;
|
|
6252
|
-
const headers =
|
|
6612
|
+
const headers = Object.create(null);
|
|
6253
6613
|
|
|
6254
6614
|
utils$1.forEach(this, (value, header) => {
|
|
6255
6615
|
const key = utils$1.findKey(headers, header);
|
|
@@ -6260,7 +6620,7 @@ class AxiosHeaders {
|
|
|
6260
6620
|
return;
|
|
6261
6621
|
}
|
|
6262
6622
|
|
|
6263
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
6623
|
+
const normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
|
|
6264
6624
|
|
|
6265
6625
|
if (normalized !== header) {
|
|
6266
6626
|
delete self[header];
|
|
@@ -6301,7 +6661,8 @@ class AxiosHeaders {
|
|
|
6301
6661
|
}
|
|
6302
6662
|
|
|
6303
6663
|
getSetCookie() {
|
|
6304
|
-
|
|
6664
|
+
const value = this.get('set-cookie');
|
|
6665
|
+
return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
|
|
6305
6666
|
}
|
|
6306
6667
|
|
|
6307
6668
|
get [Symbol.toStringTag]() {
|
|
@@ -6312,6 +6673,10 @@ class AxiosHeaders {
|
|
|
6312
6673
|
return thing instanceof this ? thing : new this(thing);
|
|
6313
6674
|
}
|
|
6314
6675
|
|
|
6676
|
+
static parseParameters(value) {
|
|
6677
|
+
return parseParameters(value);
|
|
6678
|
+
}
|
|
6679
|
+
|
|
6315
6680
|
static concat(first, ...targets) {
|
|
6316
6681
|
const computed = new this(first);
|
|
6317
6682
|
|
|
@@ -6322,8 +6687,8 @@ class AxiosHeaders {
|
|
|
6322
6687
|
|
|
6323
6688
|
static accessor(header) {
|
|
6324
6689
|
const internals =
|
|
6325
|
-
(this[$internals] =
|
|
6326
|
-
this[$internals] =
|
|
6690
|
+
(this[$internals$1] =
|
|
6691
|
+
this[$internals$1] =
|
|
6327
6692
|
{
|
|
6328
6693
|
accessors: {},
|
|
6329
6694
|
});
|
|
@@ -6437,9 +6802,95 @@ function redactConfig(config, redactKeys) {
|
|
|
6437
6802
|
return visit(config);
|
|
6438
6803
|
}
|
|
6439
6804
|
|
|
6805
|
+
function stringifySafely$1(value) {
|
|
6806
|
+
try {
|
|
6807
|
+
return String(value);
|
|
6808
|
+
} catch (err) {
|
|
6809
|
+
return '';
|
|
6810
|
+
}
|
|
6811
|
+
}
|
|
6812
|
+
|
|
6813
|
+
function aggregateErrorMessage(error) {
|
|
6814
|
+
const message = error.errors
|
|
6815
|
+
.map((entry) => {
|
|
6816
|
+
try {
|
|
6817
|
+
return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
|
|
6818
|
+
} catch (err) {
|
|
6819
|
+
return '';
|
|
6820
|
+
}
|
|
6821
|
+
})
|
|
6822
|
+
.filter(Boolean)
|
|
6823
|
+
.join('; ');
|
|
6824
|
+
|
|
6825
|
+
return message || error.name || 'AggregateError';
|
|
6826
|
+
}
|
|
6827
|
+
|
|
6828
|
+
// Shared with `Axios.prototype.request`, which splices the reconstructed
|
|
6829
|
+
// caller frames in ahead of this marker.
|
|
6830
|
+
const CAUSED_BY_SEPARATOR = '\nCaused by: ';
|
|
6831
|
+
const $causeStack = Symbol('causeStack');
|
|
6832
|
+
|
|
6833
|
+
// Match the section we appended, not marker-like text in an error message or
|
|
6834
|
+
// a replacement stack supplied by the caller. Do not re-read the cause's stack.
|
|
6835
|
+
function getCauseStackIndex(error, stack) {
|
|
6836
|
+
const causeStack = utils$1.hasOwnProp(error, $causeStack) && error[$causeStack];
|
|
6837
|
+
|
|
6838
|
+
return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
|
|
6839
|
+
}
|
|
6840
|
+
|
|
6841
|
+
/**
|
|
6842
|
+
* Append the stack of a wrapped error to `target.stack`.
|
|
6843
|
+
*
|
|
6844
|
+
* `cause` already exposes the original error for tooling that walks the standard
|
|
6845
|
+
* cause chain, but many error reporters read `stack` and nothing else. Inlining
|
|
6846
|
+
* the wrapped stack there means those reporters surface the underlying failure
|
|
6847
|
+
* instead of the axios frames that normalized it (see #6670).
|
|
6848
|
+
*
|
|
6849
|
+
* Every read is defensive: a custom `Error.prepareStackTrace` hook, a runtime
|
|
6850
|
+
* without stack support, or a replaced `stack` property can leave the value
|
|
6851
|
+
* missing, non-string, or read-only, and normalizing an error must not throw
|
|
6852
|
+
* because of that.
|
|
6853
|
+
*
|
|
6854
|
+
* @param {Error} target The AxiosError being built.
|
|
6855
|
+
* @param {Error} source The error being wrapped.
|
|
6856
|
+
*
|
|
6857
|
+
* @returns {void}
|
|
6858
|
+
*/
|
|
6859
|
+
function appendCauseStack(target, source) {
|
|
6860
|
+
try {
|
|
6861
|
+
const sourceStack = source && source.stack;
|
|
6862
|
+
|
|
6863
|
+
if (typeof sourceStack !== 'string' || !sourceStack) {
|
|
6864
|
+
return;
|
|
6865
|
+
}
|
|
6866
|
+
|
|
6867
|
+
const targetStack = target.stack;
|
|
6868
|
+
|
|
6869
|
+
if (typeof targetStack !== 'string' || !targetStack) {
|
|
6870
|
+
return;
|
|
6871
|
+
}
|
|
6872
|
+
|
|
6873
|
+
// Each call to `from()` creates a fresh target. Re-wrapping includes the
|
|
6874
|
+
// previous stack verbatim, adding one cause section per wrap.
|
|
6875
|
+
const causeStack = CAUSED_BY_SEPARATOR + sourceStack;
|
|
6876
|
+
target.stack = targetStack + causeStack;
|
|
6877
|
+
Object.defineProperty(target, $causeStack, { __proto__: null, value: causeStack });
|
|
6878
|
+
} catch (e) {
|
|
6879
|
+
// Ignore failures from custom stack hooks or un-writable stack properties.
|
|
6880
|
+
}
|
|
6881
|
+
}
|
|
6882
|
+
|
|
6440
6883
|
class AxiosError extends Error {
|
|
6441
6884
|
static from(error, code, config, request, response, customProps) {
|
|
6442
|
-
|
|
6885
|
+
// `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
|
|
6886
|
+
// failures) has an empty `message`; its detail lives in `errors[]`. Without
|
|
6887
|
+
// this, the wrapped error surfaces with a blank message (see #6721).
|
|
6888
|
+
let message = error.message;
|
|
6889
|
+
if (!message && utils$1.isArray(error.errors) && error.errors.length) {
|
|
6890
|
+
message = aggregateErrorMessage(error);
|
|
6891
|
+
}
|
|
6892
|
+
|
|
6893
|
+
const axiosError = new AxiosError(message, code || error.code, config, request, response);
|
|
6443
6894
|
// Match native `Error` `cause` semantics: non-enumerable. The wrapped
|
|
6444
6895
|
// error often carries circular internals (sockets, requests, agents), so
|
|
6445
6896
|
// an enumerable `cause` makes structured loggers (pino/winston) and any
|
|
@@ -6455,6 +6906,10 @@ class AxiosError extends Error {
|
|
|
6455
6906
|
});
|
|
6456
6907
|
axiosError.name = error.name;
|
|
6457
6908
|
|
|
6909
|
+
// Inline the wrapped stack for reporters that read only `stack`; the `cause`
|
|
6910
|
+
// property above already covers cause-aware tooling.
|
|
6911
|
+
appendCauseStack(axiosError, error);
|
|
6912
|
+
|
|
6458
6913
|
// Preserve status from the original error if not already set from response
|
|
6459
6914
|
if (error.status != null && axiosError.status == null) {
|
|
6460
6915
|
axiosError.status = error.status;
|
|
@@ -6646,28 +7101,18 @@ function toFormData(obj, formData, options) {
|
|
|
6646
7101
|
// eslint-disable-next-line no-param-reassign
|
|
6647
7102
|
formData = formData || new (FormData)();
|
|
6648
7103
|
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
metaTokens: true,
|
|
6654
|
-
dots: false,
|
|
6655
|
-
indexes: false,
|
|
6656
|
-
},
|
|
6657
|
-
false,
|
|
6658
|
-
function defined(option, source) {
|
|
6659
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
6660
|
-
return !utils$1.isUndefined(source[option]);
|
|
6661
|
-
}
|
|
6662
|
-
);
|
|
7104
|
+
const option = (name, fallback) => {
|
|
7105
|
+
const value = utils$1.getSafeProp(options, name);
|
|
7106
|
+
return utils$1.isUndefined(value) ? fallback : value;
|
|
7107
|
+
};
|
|
6663
7108
|
|
|
6664
|
-
const metaTokens =
|
|
7109
|
+
const metaTokens = option('metaTokens', true);
|
|
6665
7110
|
// eslint-disable-next-line no-use-before-define
|
|
6666
|
-
const visitor =
|
|
6667
|
-
const dots =
|
|
6668
|
-
const indexes =
|
|
6669
|
-
const _Blob =
|
|
6670
|
-
const maxDepth =
|
|
7111
|
+
const visitor = option('visitor') || defaultVisitor;
|
|
7112
|
+
const dots = option('dots', false);
|
|
7113
|
+
const indexes = option('indexes', false);
|
|
7114
|
+
const _Blob = option('Blob') || (typeof Blob !== 'undefined' && Blob);
|
|
7115
|
+
const maxDepth = option('maxDepth', DEFAULT_FORM_DATA_MAX_DEPTH);
|
|
6671
7116
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
6672
7117
|
const stack = [];
|
|
6673
7118
|
|
|
@@ -6694,10 +7139,10 @@ function toFormData(obj, formData, options) {
|
|
|
6694
7139
|
if (useBlob && typeof _Blob === 'function') {
|
|
6695
7140
|
return new _Blob([value]);
|
|
6696
7141
|
}
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
7142
|
+
throw new AxiosError(
|
|
7143
|
+
'Blob is not supported. Use a Buffer instead.',
|
|
7144
|
+
AxiosError.ERR_NOT_SUPPORT
|
|
7145
|
+
);
|
|
6701
7146
|
}
|
|
6702
7147
|
|
|
6703
7148
|
return value;
|
|
@@ -6949,28 +7394,103 @@ function buildURL(url, params, options) {
|
|
|
6949
7394
|
return url;
|
|
6950
7395
|
}
|
|
6951
7396
|
|
|
6952
|
-
|
|
6953
|
-
constructor() {
|
|
6954
|
-
this.handlers = [];
|
|
6955
|
-
}
|
|
7397
|
+
const $internals = Symbol('internals');
|
|
6956
7398
|
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
7399
|
+
// `handlers` is public and may be replaced with a nullish value by user code;
|
|
7400
|
+
// `clear()` has always tolerated that. Treat it as an empty stack rather than
|
|
7401
|
+
// dereferencing it.
|
|
7402
|
+
function countHandlers(handlers) {
|
|
7403
|
+
return handlers ? handlers.length : 0;
|
|
7404
|
+
}
|
|
7405
|
+
|
|
7406
|
+
function trimHandlers(handlers) {
|
|
7407
|
+
if (!handlers) {
|
|
7408
|
+
return;
|
|
7409
|
+
}
|
|
7410
|
+
|
|
7411
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
7412
|
+
handlers.pop();
|
|
7413
|
+
}
|
|
7414
|
+
}
|
|
7415
|
+
|
|
7416
|
+
// Preserve the array-key coercion used before IDs were stored in a Map, without
|
|
7417
|
+
// treating null, empty strings, or noncanonical numeric strings as ID zero.
|
|
7418
|
+
function normalizeHandlerId(id) {
|
|
7419
|
+
if (typeof id === 'string' && id !== '' && String(Number(id)) === id) {
|
|
7420
|
+
return Number(id);
|
|
7421
|
+
}
|
|
7422
|
+
|
|
7423
|
+
return id;
|
|
7424
|
+
}
|
|
7425
|
+
|
|
7426
|
+
function syncHandlerEntries(manager, internals) {
|
|
7427
|
+
const handlers = manager.handlers;
|
|
7428
|
+
const length = countHandlers(handlers);
|
|
7429
|
+
|
|
7430
|
+
if (handlers !== internals.handlersRef) {
|
|
7431
|
+
internals.handlersRef = handlers;
|
|
7432
|
+
internals.handlerEntries.clear();
|
|
7433
|
+
} else if (length !== internals.handlersLength) {
|
|
7434
|
+
if (!length) {
|
|
7435
|
+
internals.handlerEntries.clear();
|
|
7436
|
+
} else {
|
|
7437
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
7438
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
7439
|
+
internals.handlerEntries.delete(id);
|
|
7440
|
+
}
|
|
7441
|
+
});
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7444
|
+
|
|
7445
|
+
internals.handlersLength = length;
|
|
7446
|
+
}
|
|
7447
|
+
|
|
7448
|
+
class InterceptorManager {
|
|
7449
|
+
constructor() {
|
|
7450
|
+
this.handlers = [];
|
|
7451
|
+
this[$internals] = {
|
|
7452
|
+
handlersRef: this.handlers,
|
|
7453
|
+
handlersLength: this.handlers.length,
|
|
7454
|
+
handlerEntries: new Map(),
|
|
7455
|
+
iterationDepth: 0,
|
|
7456
|
+
nextId: 0,
|
|
7457
|
+
};
|
|
7458
|
+
}
|
|
7459
|
+
|
|
7460
|
+
/**
|
|
7461
|
+
* Add a new interceptor to the stack
|
|
7462
|
+
*
|
|
7463
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
7464
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
7465
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
7466
|
+
*
|
|
7467
|
+
* @return {Number} An ID used to remove interceptor later
|
|
7468
|
+
*/
|
|
7469
|
+
use(fulfilled, rejected, options) {
|
|
7470
|
+
const handler = {
|
|
7471
|
+
fulfilled,
|
|
7472
|
+
rejected,
|
|
7473
|
+
synchronous: options ? options.synchronous : false,
|
|
7474
|
+
runWhen: options ? options.runWhen : null,
|
|
7475
|
+
};
|
|
7476
|
+
const internals = this[$internals];
|
|
7477
|
+
|
|
7478
|
+
if (this.handlers == null) {
|
|
7479
|
+
this.handlers = [];
|
|
7480
|
+
}
|
|
7481
|
+
|
|
7482
|
+
syncHandlerEntries(this, internals);
|
|
7483
|
+
|
|
7484
|
+
const id = internals.nextId++;
|
|
7485
|
+
|
|
7486
|
+
this.handlers.push(handler);
|
|
7487
|
+
internals.handlerEntries.set(id, {
|
|
7488
|
+
handler,
|
|
7489
|
+
index: this.handlers.length - 1,
|
|
7490
|
+
});
|
|
7491
|
+
internals.handlersLength = this.handlers.length;
|
|
7492
|
+
|
|
7493
|
+
return id;
|
|
6974
7494
|
}
|
|
6975
7495
|
|
|
6976
7496
|
/**
|
|
@@ -6981,8 +7501,28 @@ class InterceptorManager {
|
|
|
6981
7501
|
* @returns {void}
|
|
6982
7502
|
*/
|
|
6983
7503
|
eject(id) {
|
|
6984
|
-
|
|
6985
|
-
|
|
7504
|
+
const internals = this[$internals];
|
|
7505
|
+
|
|
7506
|
+
syncHandlerEntries(this, internals);
|
|
7507
|
+
|
|
7508
|
+
const handlerId = normalizeHandlerId(id);
|
|
7509
|
+
const entry = internals.handlerEntries.get(handlerId);
|
|
7510
|
+
|
|
7511
|
+
if (entry) {
|
|
7512
|
+
internals.handlerEntries.delete(handlerId);
|
|
7513
|
+
|
|
7514
|
+
// Ignore IDs invalidated by clear or direct replacement of handlers.
|
|
7515
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
7516
|
+
return;
|
|
7517
|
+
}
|
|
7518
|
+
|
|
7519
|
+
this.handlers[entry.index] = null;
|
|
7520
|
+
|
|
7521
|
+
// Do not reuse an index while forEach is walking its length snapshot.
|
|
7522
|
+
if (!internals.iterationDepth) {
|
|
7523
|
+
trimHandlers(this.handlers);
|
|
7524
|
+
internals.handlersLength = this.handlers.length;
|
|
7525
|
+
}
|
|
6986
7526
|
}
|
|
6987
7527
|
}
|
|
6988
7528
|
|
|
@@ -6994,6 +7534,7 @@ class InterceptorManager {
|
|
|
6994
7534
|
clear() {
|
|
6995
7535
|
if (this.handlers) {
|
|
6996
7536
|
this.handlers = [];
|
|
7537
|
+
syncHandlerEntries(this, this[$internals]);
|
|
6997
7538
|
}
|
|
6998
7539
|
}
|
|
6999
7540
|
|
|
@@ -7008,11 +7549,25 @@ class InterceptorManager {
|
|
|
7008
7549
|
* @returns {void}
|
|
7009
7550
|
*/
|
|
7010
7551
|
forEach(fn) {
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7552
|
+
const internals = this[$internals];
|
|
7553
|
+
|
|
7554
|
+
syncHandlerEntries(this, internals);
|
|
7555
|
+
|
|
7556
|
+
internals.iterationDepth++;
|
|
7557
|
+
|
|
7558
|
+
try {
|
|
7559
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
7560
|
+
if (h !== null) {
|
|
7561
|
+
fn(h);
|
|
7562
|
+
}
|
|
7563
|
+
});
|
|
7564
|
+
} finally {
|
|
7565
|
+
if (!--internals.iterationDepth) {
|
|
7566
|
+
syncHandlerEntries(this, internals);
|
|
7567
|
+
trimHandlers(this.handlers);
|
|
7568
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
7014
7569
|
}
|
|
7015
|
-
}
|
|
7570
|
+
}
|
|
7016
7571
|
}
|
|
7017
7572
|
}
|
|
7018
7573
|
|
|
@@ -7023,6 +7578,7 @@ var transitionalDefaults = {
|
|
|
7023
7578
|
legacyInterceptorReqResOrdering: true,
|
|
7024
7579
|
advertiseZstdAcceptEncoding: false,
|
|
7025
7580
|
validateStatusUndefinedResolves: true,
|
|
7581
|
+
encodeBasicAuthUsername: false,
|
|
7026
7582
|
};
|
|
7027
7583
|
|
|
7028
7584
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -7133,12 +7689,18 @@ function throwIfDepthExceeded(index) {
|
|
|
7133
7689
|
* @returns An array of strings.
|
|
7134
7690
|
*/
|
|
7135
7691
|
function parsePropPath(name) {
|
|
7136
|
-
// foo[x][y][z]
|
|
7137
|
-
// foo.x.y.z
|
|
7138
|
-
//
|
|
7139
|
-
//
|
|
7692
|
+
// foo[x][y][z] -> ['foo', 'x', 'y', 'z']
|
|
7693
|
+
// foo.x.y.z -> ['foo', 'x', 'y', 'z']
|
|
7694
|
+
// A path is split on `.` and on `[...]` groups. A segment — whether written
|
|
7695
|
+
// in dot notation or captured inside brackets — may contain any character
|
|
7696
|
+
// except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
|
|
7697
|
+
// literal instead of being split (#5402). `.`, `[` and `]` keep their existing
|
|
7698
|
+
// meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
|
|
7699
|
+
// Excluding `[` from the bracket group also makes the match fail fast at the
|
|
7700
|
+
// next `[`, so a malformed name cannot rescan to the end of the string from
|
|
7701
|
+
// every unmatched `[` — parsing stays linear in the length of the name.
|
|
7140
7702
|
const path = [];
|
|
7141
|
-
const pattern =
|
|
7703
|
+
const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
|
|
7142
7704
|
let match;
|
|
7143
7705
|
|
|
7144
7706
|
while ((match = pattern.exec(name)) !== null) {
|
|
@@ -7169,6 +7731,29 @@ function arrayToObject(arr) {
|
|
|
7169
7731
|
return obj;
|
|
7170
7732
|
}
|
|
7171
7733
|
|
|
7734
|
+
function normalizeArray(value) {
|
|
7735
|
+
if (!utils$1.isArray(value)) return value;
|
|
7736
|
+
|
|
7737
|
+
const keys = Object.keys(value);
|
|
7738
|
+
return keys.length !== value.length || keys.some((key, index) => key !== String(index))
|
|
7739
|
+
? arrayToObject(value)
|
|
7740
|
+
: value;
|
|
7741
|
+
}
|
|
7742
|
+
|
|
7743
|
+
function normalizeArrays(obj) {
|
|
7744
|
+
const pending = [obj];
|
|
7745
|
+
while (pending.length) {
|
|
7746
|
+
const target = pending.pop();
|
|
7747
|
+
Object.keys(target).forEach((key) => {
|
|
7748
|
+
const value = (target[key] = normalizeArray(target[key]));
|
|
7749
|
+
if (utils$1.isArray(value) || utils$1.isPlainObject(value)) {
|
|
7750
|
+
pending.push(value);
|
|
7751
|
+
}
|
|
7752
|
+
});
|
|
7753
|
+
}
|
|
7754
|
+
return obj;
|
|
7755
|
+
}
|
|
7756
|
+
|
|
7172
7757
|
/**
|
|
7173
7758
|
* It takes a FormData object and returns a JavaScript object
|
|
7174
7759
|
*
|
|
@@ -7190,6 +7775,7 @@ function formDataToJSON(formData) {
|
|
|
7190
7775
|
|
|
7191
7776
|
if (isLast) {
|
|
7192
7777
|
if (utils$1.hasOwnProp(target, name)) {
|
|
7778
|
+
target[name] = normalizeArray(target[name]);
|
|
7193
7779
|
target[name] = utils$1.isArray(target[name])
|
|
7194
7780
|
? target[name].concat(value)
|
|
7195
7781
|
: [target[name], value];
|
|
@@ -7220,12 +7806,26 @@ function formDataToJSON(formData) {
|
|
|
7220
7806
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
7221
7807
|
});
|
|
7222
7808
|
|
|
7223
|
-
return obj;
|
|
7809
|
+
return normalizeArrays(obj);
|
|
7224
7810
|
}
|
|
7225
7811
|
|
|
7226
7812
|
return null;
|
|
7227
7813
|
}
|
|
7228
7814
|
|
|
7815
|
+
const methodList = Object.freeze([
|
|
7816
|
+
'get',
|
|
7817
|
+
'delete',
|
|
7818
|
+
'head',
|
|
7819
|
+
'options',
|
|
7820
|
+
'post',
|
|
7821
|
+
'put',
|
|
7822
|
+
'patch',
|
|
7823
|
+
'purge',
|
|
7824
|
+
'link',
|
|
7825
|
+
'unlink',
|
|
7826
|
+
'query',
|
|
7827
|
+
]);
|
|
7828
|
+
|
|
7229
7829
|
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
7230
7830
|
|
|
7231
7831
|
/**
|
|
@@ -7388,7 +7988,7 @@ const defaults = {
|
|
|
7388
7988
|
},
|
|
7389
7989
|
};
|
|
7390
7990
|
|
|
7391
|
-
utils$1.forEach(
|
|
7991
|
+
utils$1.forEach(methodList, (method) => {
|
|
7392
7992
|
defaults.headers[method] = {};
|
|
7393
7993
|
});
|
|
7394
7994
|
|
|
@@ -7460,11 +8060,120 @@ function settle(resolve, reject, response) {
|
|
|
7460
8060
|
}
|
|
7461
8061
|
}
|
|
7462
8062
|
|
|
8063
|
+
const urlParserControlCharacters = /[\t\n\r]/g;
|
|
8064
|
+
|
|
8065
|
+
/**
|
|
8066
|
+
* Match WHATWG URL preprocessing before checking a URL's protocol.
|
|
8067
|
+
*
|
|
8068
|
+
* @param {string} url
|
|
8069
|
+
*
|
|
8070
|
+
* @returns {string}
|
|
8071
|
+
*/
|
|
8072
|
+
function normalizeURLForProtocolCheck(url) {
|
|
8073
|
+
if (typeof url !== 'string') {
|
|
8074
|
+
return url;
|
|
8075
|
+
}
|
|
8076
|
+
|
|
8077
|
+
let start = 0;
|
|
8078
|
+
|
|
8079
|
+
while (start < url.length && url.charCodeAt(start) <= 0x20) {
|
|
8080
|
+
start++;
|
|
8081
|
+
}
|
|
8082
|
+
|
|
8083
|
+
return url.slice(start).replace(urlParserControlCharacters, '');
|
|
8084
|
+
}
|
|
8085
|
+
|
|
7463
8086
|
function parseProtocol(url) {
|
|
7464
8087
|
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
7465
|
-
return (match && match[1]) || '';
|
|
8088
|
+
return (match && match[1].toLowerCase()) || '';
|
|
7466
8089
|
}
|
|
7467
8090
|
|
|
8091
|
+
const decodeCookieValue = (value) => {
|
|
8092
|
+
try {
|
|
8093
|
+
return decodeURIComponent(value);
|
|
8094
|
+
} catch (e) {
|
|
8095
|
+
return value;
|
|
8096
|
+
}
|
|
8097
|
+
};
|
|
8098
|
+
|
|
8099
|
+
var cookies = platform.hasStandardBrowserEnv
|
|
8100
|
+
? // Standard browser envs support document.cookie
|
|
8101
|
+
{
|
|
8102
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
8103
|
+
if (typeof document === 'undefined') return;
|
|
8104
|
+
|
|
8105
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
8106
|
+
|
|
8107
|
+
if (utils$1.isNumber(expires)) {
|
|
8108
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
8109
|
+
}
|
|
8110
|
+
if (utils$1.isString(path)) {
|
|
8111
|
+
cookie.push(`path=${path}`);
|
|
8112
|
+
}
|
|
8113
|
+
if (utils$1.isString(domain)) {
|
|
8114
|
+
cookie.push(`domain=${domain}`);
|
|
8115
|
+
}
|
|
8116
|
+
if (secure === true) {
|
|
8117
|
+
cookie.push('secure');
|
|
8118
|
+
}
|
|
8119
|
+
if (utils$1.isString(sameSite)) {
|
|
8120
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
8121
|
+
}
|
|
8122
|
+
|
|
8123
|
+
document.cookie = cookie.join('; ');
|
|
8124
|
+
},
|
|
8125
|
+
|
|
8126
|
+
read(name) {
|
|
8127
|
+
if (typeof document === 'undefined') return null;
|
|
8128
|
+
const cookieString = document.cookie;
|
|
8129
|
+
if (!cookieString) return null;
|
|
8130
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
8131
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
8132
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
8133
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
8134
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
8135
|
+
const cookies = cookieString.split(';');
|
|
8136
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
8137
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
8138
|
+
const eq = cookie.indexOf('=');
|
|
8139
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
8140
|
+
return decodeCookieValue(cookie.slice(eq + 1));
|
|
8141
|
+
}
|
|
8142
|
+
}
|
|
8143
|
+
return null;
|
|
8144
|
+
},
|
|
8145
|
+
|
|
8146
|
+
async readAsync(name) {
|
|
8147
|
+
try {
|
|
8148
|
+
const store = typeof window !== 'undefined' && window.cookieStore;
|
|
8149
|
+
if (store && utils$1.isFunction(store.get)) {
|
|
8150
|
+
const cookie = await store.get(name);
|
|
8151
|
+
// Both APIs expose stored bytes; preserve Axios's existing URI decoding.
|
|
8152
|
+
return cookie ? decodeCookieValue(cookie.value) : null;
|
|
8153
|
+
}
|
|
8154
|
+
} catch (e) {
|
|
8155
|
+
// Restricted or unavailable storage retains the synchronous fallback.
|
|
8156
|
+
}
|
|
8157
|
+
|
|
8158
|
+
return this.read(name);
|
|
8159
|
+
},
|
|
8160
|
+
|
|
8161
|
+
remove(name) {
|
|
8162
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
8163
|
+
},
|
|
8164
|
+
}
|
|
8165
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
8166
|
+
{
|
|
8167
|
+
write() {},
|
|
8168
|
+
read() {
|
|
8169
|
+
return null;
|
|
8170
|
+
},
|
|
8171
|
+
async readAsync() {
|
|
8172
|
+
return null;
|
|
8173
|
+
},
|
|
8174
|
+
remove() {},
|
|
8175
|
+
};
|
|
8176
|
+
|
|
7468
8177
|
/**
|
|
7469
8178
|
* Calculate data maxRate
|
|
7470
8179
|
* @param {Number} [samplesCount= 10]
|
|
@@ -7521,7 +8230,7 @@ function speedometer(samplesCount, min) {
|
|
|
7521
8230
|
* Throttle decorator
|
|
7522
8231
|
* @param {Function} fn
|
|
7523
8232
|
* @param {Number} freq
|
|
7524
|
-
* @return {Function}
|
|
8233
|
+
* @return {Array<Function>}
|
|
7525
8234
|
*/
|
|
7526
8235
|
function throttle(fn, freq) {
|
|
7527
8236
|
let timestamp = 0;
|
|
@@ -7556,8 +8265,9 @@ function throttle(fn, freq) {
|
|
|
7556
8265
|
};
|
|
7557
8266
|
|
|
7558
8267
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
8268
|
+
const flushWith = (...args) => invoke(args);
|
|
7559
8269
|
|
|
7560
|
-
return [throttled, flush];
|
|
8270
|
+
return [throttled, flush, flushWith];
|
|
7561
8271
|
}
|
|
7562
8272
|
|
|
7563
8273
|
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
@@ -7565,12 +8275,12 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
7565
8275
|
const _speedometer = speedometer(50, 250);
|
|
7566
8276
|
|
|
7567
8277
|
return throttle((e) => {
|
|
7568
|
-
if (!e ||
|
|
8278
|
+
if (!e || !utils$1.isNumber(e.loaded)) {
|
|
7569
8279
|
return;
|
|
7570
8280
|
}
|
|
7571
8281
|
const rawLoaded = e.loaded;
|
|
7572
8282
|
const total = e.lengthComputable ? e.total : undefined;
|
|
7573
|
-
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
8283
|
+
const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
|
|
7574
8284
|
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
7575
8285
|
const rate = _speedometer(progressBytes);
|
|
7576
8286
|
|
|
@@ -7607,87 +8317,20 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
7607
8317
|
};
|
|
7608
8318
|
|
|
7609
8319
|
const asyncDecorator =
|
|
7610
|
-
(fn) =>
|
|
8320
|
+
(fn, scheduler = utils$1.asap) =>
|
|
7611
8321
|
(...args) =>
|
|
7612
|
-
|
|
8322
|
+
scheduler(() => fn(...args));
|
|
7613
8323
|
|
|
7614
8324
|
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
7615
|
-
? ((origin
|
|
7616
|
-
url = new URL(url, platform.origin);
|
|
8325
|
+
? ((origin) => (url) => {
|
|
8326
|
+
url = new URL(url, document.baseURI || platform.origin);
|
|
7617
8327
|
|
|
7618
8328
|
return (
|
|
7619
|
-
origin.protocol === url.protocol &&
|
|
7620
|
-
origin.host === url.host &&
|
|
7621
|
-
(isMSIE || origin.port === url.port)
|
|
8329
|
+
origin.protocol === url.protocol && origin.host === url.host && origin.port === url.port
|
|
7622
8330
|
);
|
|
7623
|
-
})(
|
|
7624
|
-
new URL(platform.origin),
|
|
7625
|
-
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
7626
|
-
)
|
|
8331
|
+
})(new URL(platform.origin))
|
|
7627
8332
|
: () => true;
|
|
7628
8333
|
|
|
7629
|
-
var cookies = platform.hasStandardBrowserEnv
|
|
7630
|
-
? // Standard browser envs support document.cookie
|
|
7631
|
-
{
|
|
7632
|
-
write(name, value, expires, path, domain, secure, sameSite) {
|
|
7633
|
-
if (typeof document === 'undefined') return;
|
|
7634
|
-
|
|
7635
|
-
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
7636
|
-
|
|
7637
|
-
if (utils$1.isNumber(expires)) {
|
|
7638
|
-
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
7639
|
-
}
|
|
7640
|
-
if (utils$1.isString(path)) {
|
|
7641
|
-
cookie.push(`path=${path}`);
|
|
7642
|
-
}
|
|
7643
|
-
if (utils$1.isString(domain)) {
|
|
7644
|
-
cookie.push(`domain=${domain}`);
|
|
7645
|
-
}
|
|
7646
|
-
if (secure === true) {
|
|
7647
|
-
cookie.push('secure');
|
|
7648
|
-
}
|
|
7649
|
-
if (utils$1.isString(sameSite)) {
|
|
7650
|
-
cookie.push(`SameSite=${sameSite}`);
|
|
7651
|
-
}
|
|
7652
|
-
|
|
7653
|
-
document.cookie = cookie.join('; ');
|
|
7654
|
-
},
|
|
7655
|
-
|
|
7656
|
-
read(name) {
|
|
7657
|
-
if (typeof document === 'undefined') return null;
|
|
7658
|
-
// Match name=value by splitting on the semicolon separator instead of building a
|
|
7659
|
-
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
7660
|
-
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
7661
|
-
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
7662
|
-
// "; ", so ignore optional whitespace before each cookie name.
|
|
7663
|
-
const cookies = document.cookie.split(';');
|
|
7664
|
-
for (let i = 0; i < cookies.length; i++) {
|
|
7665
|
-
const cookie = cookies[i].replace(/^\s+/, '');
|
|
7666
|
-
const eq = cookie.indexOf('=');
|
|
7667
|
-
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
7668
|
-
try {
|
|
7669
|
-
return decodeURIComponent(cookie.slice(eq + 1));
|
|
7670
|
-
} catch (e) {
|
|
7671
|
-
return cookie.slice(eq + 1);
|
|
7672
|
-
}
|
|
7673
|
-
}
|
|
7674
|
-
}
|
|
7675
|
-
return null;
|
|
7676
|
-
},
|
|
7677
|
-
|
|
7678
|
-
remove(name) {
|
|
7679
|
-
this.write(name, '', Date.now() - 86400000, '/');
|
|
7680
|
-
},
|
|
7681
|
-
}
|
|
7682
|
-
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
7683
|
-
{
|
|
7684
|
-
write() {},
|
|
7685
|
-
read() {
|
|
7686
|
-
return null;
|
|
7687
|
-
},
|
|
7688
|
-
remove() {},
|
|
7689
|
-
};
|
|
7690
|
-
|
|
7691
8334
|
/**
|
|
7692
8335
|
* Determines whether the specified URL is absolute
|
|
7693
8336
|
*
|
|
@@ -7715,33 +8358,66 @@ function isAbsoluteURL(url) {
|
|
|
7715
8358
|
* @returns {string} The combined URL
|
|
7716
8359
|
*/
|
|
7717
8360
|
function combineURLs(baseURL, relativeURL) {
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
8361
|
+
if (!relativeURL) {
|
|
8362
|
+
return baseURL;
|
|
8363
|
+
}
|
|
8364
|
+
|
|
8365
|
+
let end = baseURL.length;
|
|
8366
|
+
|
|
8367
|
+
while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
|
|
8368
|
+
end--;
|
|
8369
|
+
}
|
|
8370
|
+
|
|
8371
|
+
return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
|
|
7721
8372
|
}
|
|
7722
8373
|
|
|
7723
8374
|
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
7724
|
-
const httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
7725
8375
|
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
8376
|
+
// Redact the parts of a URL that can carry secrets before it is embedded in an
|
|
8377
|
+
// error message. AxiosError.toJSON() serializes `message` verbatim and errors
|
|
8378
|
+
// are commonly logged, while the opt-in `config.redact` model only cleans
|
|
8379
|
+
// config keys — it cannot reach the message. Redact only the genuinely
|
|
8380
|
+
// sensitive substrings — userinfo (credentials), query parameter values and
|
|
8381
|
+
// fragment contents — with the same REDACTED marker the config redaction uses,
|
|
8382
|
+
// while keeping the scheme, host, path and parameter names so the offending
|
|
8383
|
+
// request stays accurately identifiable.
|
|
8384
|
+
function redactFragment(fragment) {
|
|
8385
|
+
if (!fragment) {
|
|
8386
|
+
return fragment;
|
|
8387
|
+
}
|
|
8388
|
+
|
|
8389
|
+
return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = '') => {
|
|
8390
|
+
return `${separator}${parameterName}${REDACTED}`;
|
|
8391
|
+
});
|
|
7732
8392
|
}
|
|
7733
8393
|
|
|
7734
|
-
function
|
|
7735
|
-
|
|
8394
|
+
function redactSensitiveURLParts(url) {
|
|
8395
|
+
const redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
|
|
8396
|
+
const fragmentIndex = redactedURL.indexOf('#');
|
|
8397
|
+
const urlWithoutFragment =
|
|
8398
|
+
fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
|
|
8399
|
+
const redactedURLWithoutFragment = urlWithoutFragment.replace(
|
|
8400
|
+
/([?&][^=&#]*=)[^&#]*/g,
|
|
8401
|
+
`$1${REDACTED}`
|
|
8402
|
+
);
|
|
8403
|
+
|
|
8404
|
+
if (fragmentIndex === -1) {
|
|
8405
|
+
return redactedURLWithoutFragment;
|
|
8406
|
+
}
|
|
8407
|
+
|
|
8408
|
+
return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
|
|
7736
8409
|
}
|
|
7737
8410
|
|
|
7738
8411
|
function assertValidHttpProtocolURL(url, config) {
|
|
7739
|
-
if (typeof url === 'string'
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
AxiosError
|
|
7743
|
-
|
|
7744
|
-
|
|
8412
|
+
if (typeof url === 'string') {
|
|
8413
|
+
const normalizedURL = normalizeURLForProtocolCheck(url);
|
|
8414
|
+
if (malformedHttpProtocol.test(normalizedURL)) {
|
|
8415
|
+
throw new AxiosError(
|
|
8416
|
+
`Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
|
|
8417
|
+
AxiosError.ERR_INVALID_URL,
|
|
8418
|
+
config
|
|
8419
|
+
);
|
|
8420
|
+
}
|
|
7745
8421
|
}
|
|
7746
8422
|
}
|
|
7747
8423
|
|
|
@@ -7765,8 +8441,234 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
|
7765
8441
|
return requestedURL;
|
|
7766
8442
|
}
|
|
7767
8443
|
|
|
8444
|
+
function assertParamsAcyclic(params) {
|
|
8445
|
+
const pending = [{ value: params }];
|
|
8446
|
+
const active = new WeakSet();
|
|
8447
|
+
const visited = new WeakSet();
|
|
8448
|
+
|
|
8449
|
+
while (pending.length) {
|
|
8450
|
+
const { value, done } = pending.pop();
|
|
8451
|
+
if (!utils$1.isPlainObject(value) && !utils$1.isArray(value)) continue;
|
|
8452
|
+
if (done) {
|
|
8453
|
+
active.delete(value);
|
|
8454
|
+
continue;
|
|
8455
|
+
}
|
|
8456
|
+
if (active.has(value)) {
|
|
8457
|
+
throw new AxiosError(
|
|
8458
|
+
'Circular reference detected in params',
|
|
8459
|
+
AxiosError.ERR_BAD_OPTION_VALUE
|
|
8460
|
+
);
|
|
8461
|
+
}
|
|
8462
|
+
if (visited.has(value)) continue;
|
|
8463
|
+
visited.add(value);
|
|
8464
|
+
active.add(value);
|
|
8465
|
+
pending.push({ value, done: true });
|
|
8466
|
+
|
|
8467
|
+
const keys = Object.keys(value);
|
|
8468
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
8469
|
+
Object.getOwnPropertySymbols(value).forEach((key) => {
|
|
8470
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
8471
|
+
if (descriptor && descriptor.enumerable) keys.push(key);
|
|
8472
|
+
});
|
|
8473
|
+
}
|
|
8474
|
+
// Shallow array elements retain fields filtered during plain-object merges.
|
|
8475
|
+
// Inspect reserved data properties without evaluating their accessors.
|
|
8476
|
+
keys.forEach((key) => {
|
|
8477
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
8478
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
8479
|
+
if (descriptor && utils$1.hasOwnProp(descriptor, 'value')) {
|
|
8480
|
+
pending.push({ value: descriptor.value });
|
|
8481
|
+
}
|
|
8482
|
+
} else {
|
|
8483
|
+
pending.push({ value: value[key] });
|
|
8484
|
+
}
|
|
8485
|
+
});
|
|
8486
|
+
}
|
|
8487
|
+
}
|
|
8488
|
+
|
|
7768
8489
|
const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
|
|
7769
8490
|
|
|
8491
|
+
const ownEnumerableKeys = (thing) => {
|
|
8492
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
8493
|
+
return Object.keys(thing).concat(
|
|
8494
|
+
Object.getOwnPropertySymbols(thing).filter((symbol) => {
|
|
8495
|
+
const descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
|
|
8496
|
+
return descriptor && descriptor.enumerable;
|
|
8497
|
+
})
|
|
8498
|
+
);
|
|
8499
|
+
}
|
|
8500
|
+
return Object.keys(thing);
|
|
8501
|
+
};
|
|
8502
|
+
|
|
8503
|
+
// Copy params without recursive merges so the serializer remains responsible
|
|
8504
|
+
// for its depth policy. Only visit defaults that contribute to the result.
|
|
8505
|
+
function mergeParams(a, b) {
|
|
8506
|
+
const pending = [];
|
|
8507
|
+
const copies = new WeakMap();
|
|
8508
|
+
const empty = {};
|
|
8509
|
+
|
|
8510
|
+
function copy(target, source) {
|
|
8511
|
+
if (!utils$1.isPlainObject(source)) {
|
|
8512
|
+
return utils$1.isArray(source) ? source.slice() : source;
|
|
8513
|
+
}
|
|
8514
|
+
|
|
8515
|
+
const base = utils$1.isPlainObject(target) ? target : empty;
|
|
8516
|
+
let bases = copies.get(source);
|
|
8517
|
+
if (!bases) {
|
|
8518
|
+
bases = new WeakMap();
|
|
8519
|
+
copies.set(source, bases);
|
|
8520
|
+
}
|
|
8521
|
+
if (bases.has(base)) return bases.get(base);
|
|
8522
|
+
|
|
8523
|
+
const result = {};
|
|
8524
|
+
bases.set(base, result);
|
|
8525
|
+
pending.push({ base, source, result });
|
|
8526
|
+
return result;
|
|
8527
|
+
}
|
|
8528
|
+
|
|
8529
|
+
const result = utils$1.isUndefined(b) ? copy(undefined, a) : copy(a, b);
|
|
8530
|
+
while (pending.length) {
|
|
8531
|
+
const { base, source, result: target } = pending.pop();
|
|
8532
|
+
const baseKeys = new Set(ownEnumerableKeys(base));
|
|
8533
|
+
const sourceKeys = new Set(ownEnumerableKeys(source));
|
|
8534
|
+
const keys = new Set([...baseKeys, ...sourceKeys]);
|
|
8535
|
+
|
|
8536
|
+
keys.forEach((key) => {
|
|
8537
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') return;
|
|
8538
|
+
const hasSource = sourceKeys.has(key);
|
|
8539
|
+
const value = hasSource ? source[key] : undefined;
|
|
8540
|
+
const previous =
|
|
8541
|
+
(!hasSource || utils$1.isPlainObject(value)) && baseKeys.has(key) ? base[key] : undefined;
|
|
8542
|
+
target[key] = hasSource ? copy(previous, value) : copy(undefined, previous);
|
|
8543
|
+
});
|
|
8544
|
+
}
|
|
8545
|
+
|
|
8546
|
+
assertParamsAcyclic(result);
|
|
8547
|
+
return result;
|
|
8548
|
+
}
|
|
8549
|
+
|
|
8550
|
+
function getMergedValue(target, source, prop, caseless) {
|
|
8551
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
8552
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
8553
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
8554
|
+
return utils$1.merge({}, source);
|
|
8555
|
+
} else if (utils$1.isArray(source)) {
|
|
8556
|
+
return source.slice();
|
|
8557
|
+
}
|
|
8558
|
+
return source;
|
|
8559
|
+
}
|
|
8560
|
+
|
|
8561
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
8562
|
+
if (!utils$1.isUndefined(b)) {
|
|
8563
|
+
return getMergedValue(a, b, prop, caseless);
|
|
8564
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
8565
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
8566
|
+
}
|
|
8567
|
+
}
|
|
8568
|
+
|
|
8569
|
+
// eslint-disable-next-line consistent-return
|
|
8570
|
+
function valueFromConfig2(a, b) {
|
|
8571
|
+
if (!utils$1.isUndefined(b)) {
|
|
8572
|
+
return getMergedValue(undefined, b);
|
|
8573
|
+
}
|
|
8574
|
+
}
|
|
8575
|
+
|
|
8576
|
+
// eslint-disable-next-line consistent-return
|
|
8577
|
+
function defaultToConfig2(a, b) {
|
|
8578
|
+
if (!utils$1.isUndefined(b)) {
|
|
8579
|
+
return getMergedValue(undefined, b);
|
|
8580
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
8581
|
+
return getMergedValue(undefined, a);
|
|
8582
|
+
}
|
|
8583
|
+
}
|
|
8584
|
+
|
|
8585
|
+
function getMergedTransitionalOption(config1, config2, prop) {
|
|
8586
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
|
|
8587
|
+
? config2.transitional
|
|
8588
|
+
: undefined;
|
|
8589
|
+
|
|
8590
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
8591
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
8592
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
8593
|
+
return transitional2[prop];
|
|
8594
|
+
}
|
|
8595
|
+
} else {
|
|
8596
|
+
return undefined;
|
|
8597
|
+
}
|
|
8598
|
+
}
|
|
8599
|
+
|
|
8600
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
|
|
8601
|
+
? config1.transitional
|
|
8602
|
+
: undefined;
|
|
8603
|
+
|
|
8604
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
8605
|
+
return transitional1[prop];
|
|
8606
|
+
}
|
|
8607
|
+
|
|
8608
|
+
return undefined;
|
|
8609
|
+
}
|
|
8610
|
+
|
|
8611
|
+
// eslint-disable-next-line consistent-return
|
|
8612
|
+
function mergeDirectKeys(a, b, prop, config1, config2) {
|
|
8613
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
8614
|
+
return getMergedValue(a, b);
|
|
8615
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
8616
|
+
return getMergedValue(undefined, a);
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
|
|
8620
|
+
function mergeHeaders(a, b, prop) {
|
|
8621
|
+
return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
|
|
8622
|
+
}
|
|
8623
|
+
|
|
8624
|
+
// Null-proto, frozen descriptor so a polluted Object.prototype.get cannot turn
|
|
8625
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
8626
|
+
// defineProperty only reads it, so one shared instance serves every call.
|
|
8627
|
+
const hasOwnPropertyDescriptor = Object.freeze({
|
|
8628
|
+
__proto__: null,
|
|
8629
|
+
value: Object.prototype.hasOwnProperty,
|
|
8630
|
+
enumerable: false,
|
|
8631
|
+
writable: true,
|
|
8632
|
+
configurable: true,
|
|
8633
|
+
});
|
|
8634
|
+
|
|
8635
|
+
// The strategy table and the strategies above are stateless, so they are
|
|
8636
|
+
// built once at module load instead of on every call: mergeConfig runs at
|
|
8637
|
+
// most twice per request (once from a method alias, once from `_request`).
|
|
8638
|
+
const mergeMap = {
|
|
8639
|
+
url: valueFromConfig2,
|
|
8640
|
+
method: valueFromConfig2,
|
|
8641
|
+
data: valueFromConfig2,
|
|
8642
|
+
baseURL: defaultToConfig2,
|
|
8643
|
+
transformRequest: defaultToConfig2,
|
|
8644
|
+
transformResponse: defaultToConfig2,
|
|
8645
|
+
params: mergeParams,
|
|
8646
|
+
paramsSerializer: defaultToConfig2,
|
|
8647
|
+
timeout: defaultToConfig2,
|
|
8648
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
8649
|
+
withCredentials: defaultToConfig2,
|
|
8650
|
+
withXSRFToken: defaultToConfig2,
|
|
8651
|
+
adapter: defaultToConfig2,
|
|
8652
|
+
responseType: defaultToConfig2,
|
|
8653
|
+
xsrfCookieName: defaultToConfig2,
|
|
8654
|
+
xsrfHeaderName: defaultToConfig2,
|
|
8655
|
+
onUploadProgress: defaultToConfig2,
|
|
8656
|
+
onDownloadProgress: defaultToConfig2,
|
|
8657
|
+
decompress: defaultToConfig2,
|
|
8658
|
+
maxContentLength: defaultToConfig2,
|
|
8659
|
+
maxBodyLength: defaultToConfig2,
|
|
8660
|
+
beforeRedirect: defaultToConfig2,
|
|
8661
|
+
transport: defaultToConfig2,
|
|
8662
|
+
httpAgent: defaultToConfig2,
|
|
8663
|
+
httpsAgent: defaultToConfig2,
|
|
8664
|
+
cancelToken: defaultToConfig2,
|
|
8665
|
+
socketPath: defaultToConfig2,
|
|
8666
|
+
allowedSocketPaths: defaultToConfig2,
|
|
8667
|
+
responseEncoding: defaultToConfig2,
|
|
8668
|
+
validateStatus: mergeDirectKeys,
|
|
8669
|
+
headers: mergeHeaders,
|
|
8670
|
+
};
|
|
8671
|
+
|
|
7770
8672
|
/**
|
|
7771
8673
|
* Config-specific merge-function which creates a new config-object
|
|
7772
8674
|
* by merging two configuration objects together.
|
|
@@ -7786,129 +8688,25 @@ function mergeConfig(config1, config2) {
|
|
|
7786
8688
|
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
7787
8689
|
// ergonomics for user code that relies on it.
|
|
7788
8690
|
const config = Object.create(null);
|
|
7789
|
-
Object.defineProperty(config, 'hasOwnProperty',
|
|
7790
|
-
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
7791
|
-
// this data descriptor into an accessor descriptor on the way in.
|
|
7792
|
-
__proto__: null,
|
|
7793
|
-
value: Object.prototype.hasOwnProperty,
|
|
7794
|
-
enumerable: false,
|
|
7795
|
-
writable: true,
|
|
7796
|
-
configurable: true,
|
|
7797
|
-
});
|
|
7798
|
-
|
|
7799
|
-
function getMergedValue(target, source, prop, caseless) {
|
|
7800
|
-
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
7801
|
-
return utils$1.merge.call({ caseless }, target, source);
|
|
7802
|
-
} else if (utils$1.isPlainObject(source)) {
|
|
7803
|
-
return utils$1.merge({}, source);
|
|
7804
|
-
} else if (utils$1.isArray(source)) {
|
|
7805
|
-
return source.slice();
|
|
7806
|
-
}
|
|
7807
|
-
return source;
|
|
7808
|
-
}
|
|
7809
|
-
|
|
7810
|
-
function mergeDeepProperties(a, b, prop, caseless) {
|
|
7811
|
-
if (!utils$1.isUndefined(b)) {
|
|
7812
|
-
return getMergedValue(a, b, prop, caseless);
|
|
7813
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
7814
|
-
return getMergedValue(undefined, a, prop, caseless);
|
|
7815
|
-
}
|
|
7816
|
-
}
|
|
7817
|
-
|
|
7818
|
-
// eslint-disable-next-line consistent-return
|
|
7819
|
-
function valueFromConfig2(a, b) {
|
|
7820
|
-
if (!utils$1.isUndefined(b)) {
|
|
7821
|
-
return getMergedValue(undefined, b);
|
|
7822
|
-
}
|
|
7823
|
-
}
|
|
7824
|
-
|
|
7825
|
-
// eslint-disable-next-line consistent-return
|
|
7826
|
-
function defaultToConfig2(a, b) {
|
|
7827
|
-
if (!utils$1.isUndefined(b)) {
|
|
7828
|
-
return getMergedValue(undefined, b);
|
|
7829
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
7830
|
-
return getMergedValue(undefined, a);
|
|
7831
|
-
}
|
|
7832
|
-
}
|
|
8691
|
+
Object.defineProperty(config, 'hasOwnProperty', hasOwnPropertyDescriptor);
|
|
7833
8692
|
|
|
7834
|
-
|
|
7835
|
-
const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
|
|
8693
|
+
const keys = ownEnumerableKeys({ ...config1, ...config2 });
|
|
7836
8694
|
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
return transitional2[prop];
|
|
7841
|
-
}
|
|
7842
|
-
} else {
|
|
7843
|
-
return undefined;
|
|
7844
|
-
}
|
|
7845
|
-
}
|
|
7846
|
-
|
|
7847
|
-
const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
|
|
7848
|
-
|
|
7849
|
-
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
7850
|
-
return transitional1[prop];
|
|
7851
|
-
}
|
|
7852
|
-
|
|
7853
|
-
return undefined;
|
|
7854
|
-
}
|
|
7855
|
-
|
|
7856
|
-
// eslint-disable-next-line consistent-return
|
|
7857
|
-
function mergeDirectKeys(a, b, prop) {
|
|
7858
|
-
if (utils$1.hasOwnProp(config2, prop)) {
|
|
7859
|
-
return getMergedValue(a, b);
|
|
7860
|
-
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
7861
|
-
return getMergedValue(undefined, a);
|
|
7862
|
-
}
|
|
7863
|
-
}
|
|
7864
|
-
|
|
7865
|
-
const mergeMap = {
|
|
7866
|
-
url: valueFromConfig2,
|
|
7867
|
-
method: valueFromConfig2,
|
|
7868
|
-
data: valueFromConfig2,
|
|
7869
|
-
baseURL: defaultToConfig2,
|
|
7870
|
-
transformRequest: defaultToConfig2,
|
|
7871
|
-
transformResponse: defaultToConfig2,
|
|
7872
|
-
paramsSerializer: defaultToConfig2,
|
|
7873
|
-
timeout: defaultToConfig2,
|
|
7874
|
-
timeoutMessage: defaultToConfig2,
|
|
7875
|
-
withCredentials: defaultToConfig2,
|
|
7876
|
-
withXSRFToken: defaultToConfig2,
|
|
7877
|
-
adapter: defaultToConfig2,
|
|
7878
|
-
responseType: defaultToConfig2,
|
|
7879
|
-
xsrfCookieName: defaultToConfig2,
|
|
7880
|
-
xsrfHeaderName: defaultToConfig2,
|
|
7881
|
-
onUploadProgress: defaultToConfig2,
|
|
7882
|
-
onDownloadProgress: defaultToConfig2,
|
|
7883
|
-
decompress: defaultToConfig2,
|
|
7884
|
-
maxContentLength: defaultToConfig2,
|
|
7885
|
-
maxBodyLength: defaultToConfig2,
|
|
7886
|
-
beforeRedirect: defaultToConfig2,
|
|
7887
|
-
transport: defaultToConfig2,
|
|
7888
|
-
httpAgent: defaultToConfig2,
|
|
7889
|
-
httpsAgent: defaultToConfig2,
|
|
7890
|
-
cancelToken: defaultToConfig2,
|
|
7891
|
-
socketPath: defaultToConfig2,
|
|
7892
|
-
allowedSocketPaths: defaultToConfig2,
|
|
7893
|
-
responseEncoding: defaultToConfig2,
|
|
7894
|
-
validateStatus: mergeDirectKeys,
|
|
7895
|
-
headers: (a, b, prop) =>
|
|
7896
|
-
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
7897
|
-
};
|
|
7898
|
-
|
|
7899
|
-
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
7900
|
-
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
8695
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
8696
|
+
const prop = keys[i];
|
|
8697
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') continue;
|
|
7901
8698
|
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
7902
8699
|
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
7903
8700
|
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
7904
|
-
const configValue =
|
|
8701
|
+
const configValue =
|
|
8702
|
+
merge === mergeDirectKeys ? merge(a, b, prop, config1, config2) : merge(a, b, prop);
|
|
7905
8703
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
7906
|
-
}
|
|
8704
|
+
}
|
|
7907
8705
|
|
|
7908
8706
|
if (
|
|
7909
8707
|
utils$1.hasOwnProp(config2, 'validateStatus') &&
|
|
7910
8708
|
utils$1.isUndefined(config2.validateStatus) &&
|
|
7911
|
-
getMergedTransitionalOption('validateStatusUndefinedResolves') === false
|
|
8709
|
+
getMergedTransitionalOption(config1, config2, 'validateStatusUndefinedResolves') === false
|
|
7912
8710
|
) {
|
|
7913
8711
|
if (utils$1.hasOwnProp(config1, 'validateStatus')) {
|
|
7914
8712
|
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|
|
@@ -7922,6 +8720,17 @@ function mergeConfig(config1, config2) {
|
|
|
7922
8720
|
|
|
7923
8721
|
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
7924
8722
|
|
|
8723
|
+
/**
|
|
8724
|
+
* Apply the headers generated by a FormData implementation to the request headers,
|
|
8725
|
+
* honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
|
|
8726
|
+
* content-* headers; otherwise merge all of them.
|
|
8727
|
+
*
|
|
8728
|
+
* @param {AxiosHeaders} headers - the request headers to mutate
|
|
8729
|
+
* @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
|
|
8730
|
+
* @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
|
|
8731
|
+
*
|
|
8732
|
+
* @returns {void}
|
|
8733
|
+
*/
|
|
7925
8734
|
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
7926
8735
|
if (policy !== 'content-only') {
|
|
7927
8736
|
headers.set(formHeaders);
|
|
@@ -7948,7 +8757,9 @@ const encodeUTF8$1 = (str) =>
|
|
|
7948
8757
|
String.fromCharCode(parseInt(hex, 16))
|
|
7949
8758
|
);
|
|
7950
8759
|
|
|
7951
|
-
|
|
8760
|
+
const readCookie = (name) => cookies.read(name);
|
|
8761
|
+
|
|
8762
|
+
function resolveConfig(config, readXsrfCookie = readCookie) {
|
|
7952
8763
|
const newConfig = mergeConfig({}, config);
|
|
7953
8764
|
|
|
7954
8765
|
// Read only own properties to prevent prototype pollution gadgets
|
|
@@ -7977,11 +8788,22 @@ function resolveConfig(config) {
|
|
|
7977
8788
|
if (auth) {
|
|
7978
8789
|
const username = utils$1.getSafeProp(auth, 'username') || '';
|
|
7979
8790
|
const password = utils$1.getSafeProp(auth, 'password') || '';
|
|
8791
|
+
const transitional = own('transitional');
|
|
8792
|
+
const encodeUsername =
|
|
8793
|
+
transitional &&
|
|
8794
|
+
utils$1.hasOwnProp(transitional, 'encodeBasicAuthUsername') &&
|
|
8795
|
+
transitional.encodeBasicAuthUsername === true;
|
|
7980
8796
|
|
|
7981
8797
|
try {
|
|
7982
8798
|
headers.set(
|
|
7983
8799
|
'Authorization',
|
|
7984
|
-
|
|
8800
|
+
// Preserve legacy username bytes unless the caller opts in to UTF-8.
|
|
8801
|
+
'Basic ' +
|
|
8802
|
+
btoa(
|
|
8803
|
+
(encodeUsername ? encodeUTF8$1(username) : username) +
|
|
8804
|
+
':' +
|
|
8805
|
+
(password ? encodeUTF8$1(password) : '')
|
|
8806
|
+
)
|
|
7985
8807
|
);
|
|
7986
8808
|
} catch (e) {
|
|
7987
8809
|
throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
@@ -7989,15 +8811,17 @@ function resolveConfig(config) {
|
|
|
7989
8811
|
}
|
|
7990
8812
|
|
|
7991
8813
|
if (utils$1.isFormData(data)) {
|
|
8814
|
+
const getHeaders = utils$1.getSafeProp(data, 'getHeaders');
|
|
8815
|
+
|
|
7992
8816
|
if (
|
|
7993
8817
|
platform.hasStandardBrowserEnv ||
|
|
7994
8818
|
platform.hasStandardBrowserWebWorkerEnv ||
|
|
7995
8819
|
utils$1.isReactNative(data)
|
|
7996
8820
|
) {
|
|
7997
8821
|
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
7998
|
-
} else if (utils$1.isFunction(
|
|
8822
|
+
} else if (utils$1.isFunction(getHeaders)) {
|
|
7999
8823
|
// Node.js FormData (like form-data package)
|
|
8000
|
-
setFormDataHeaders(headers,
|
|
8824
|
+
setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
|
|
8001
8825
|
}
|
|
8002
8826
|
}
|
|
8003
8827
|
|
|
@@ -8017,7 +8841,7 @@ function resolveConfig(config) {
|
|
|
8017
8841
|
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
8018
8842
|
|
|
8019
8843
|
if (shouldSendXSRF) {
|
|
8020
|
-
const xsrfValue = xsrfHeaderName && xsrfCookieName &&
|
|
8844
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
|
|
8021
8845
|
|
|
8022
8846
|
if (xsrfValue) {
|
|
8023
8847
|
headers.set(xsrfHeaderName, xsrfValue);
|
|
@@ -8033,17 +8857,60 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
|
8033
8857
|
var xhrAdapter = isXHRAdapterSupported &&
|
|
8034
8858
|
function (config) {
|
|
8035
8859
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
8036
|
-
|
|
8860
|
+
let useAsyncXsrf;
|
|
8861
|
+
try {
|
|
8862
|
+
const store =
|
|
8863
|
+
platform.hasStandardBrowserEnv && typeof window !== 'undefined' && window.cookieStore;
|
|
8864
|
+
useAsyncXsrf = store && utils$1.isFunction(store.get);
|
|
8865
|
+
} catch (e) {
|
|
8866
|
+
// A restricted Cookie Store getter must retain the synchronous fallback.
|
|
8867
|
+
}
|
|
8868
|
+
let xsrfCookieName;
|
|
8869
|
+
const _config = resolveConfig(
|
|
8870
|
+
config,
|
|
8871
|
+
useAsyncXsrf
|
|
8872
|
+
? (name) => {
|
|
8873
|
+
xsrfCookieName = name;
|
|
8874
|
+
return null;
|
|
8875
|
+
}
|
|
8876
|
+
: undefined
|
|
8877
|
+
);
|
|
8037
8878
|
let requestData = _config.data;
|
|
8038
8879
|
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|
8039
8880
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
8040
8881
|
let onCanceled;
|
|
8882
|
+
let timeoutId;
|
|
8041
8883
|
let uploadThrottled, downloadThrottled;
|
|
8042
|
-
let flushUpload, flushDownload;
|
|
8884
|
+
let flushUpload, flushDownload, flushDownloadWithEvent;
|
|
8885
|
+
|
|
8886
|
+
function done() {
|
|
8887
|
+
clearTimeout(timeoutId);
|
|
8888
|
+
// A final progress callback must not prevent the remaining cleanup.
|
|
8889
|
+
// Report errors asynchronously, as onloadend and the throttle timer do.
|
|
8890
|
+
try {
|
|
8891
|
+
flushUpload && flushUpload(); // flush events
|
|
8892
|
+
} catch (err) {
|
|
8893
|
+
setTimeout(() => {
|
|
8894
|
+
throw err;
|
|
8895
|
+
});
|
|
8896
|
+
}
|
|
8897
|
+
try {
|
|
8898
|
+
flushDownload && flushDownload(); // flush events
|
|
8899
|
+
} catch (err) {
|
|
8900
|
+
setTimeout(() => {
|
|
8901
|
+
throw err;
|
|
8902
|
+
});
|
|
8903
|
+
}
|
|
8043
8904
|
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8905
|
+
// A flush can synchronously cancel the request and reenter done().
|
|
8906
|
+
// In that case the inner call has already detached these listeners.
|
|
8907
|
+
if (request) {
|
|
8908
|
+
downloadThrottled && request.removeEventListener('progress', downloadThrottled);
|
|
8909
|
+
if (request.upload) {
|
|
8910
|
+
uploadThrottled && request.upload.removeEventListener('progress', uploadThrottled);
|
|
8911
|
+
flushUpload && request.upload.removeEventListener('loadend', flushUpload);
|
|
8912
|
+
}
|
|
8913
|
+
}
|
|
8047
8914
|
|
|
8048
8915
|
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
8049
8916
|
|
|
@@ -8057,10 +8924,55 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8057
8924
|
// Set the request timeout in MS
|
|
8058
8925
|
request.timeout = _config.timeout;
|
|
8059
8926
|
|
|
8060
|
-
function onloadend() {
|
|
8927
|
+
function onloadend(event) {
|
|
8928
|
+
if (!request) {
|
|
8929
|
+
return;
|
|
8930
|
+
}
|
|
8931
|
+
|
|
8932
|
+
// Status 0 means no response was received, which onerror and onabort normally
|
|
8933
|
+
// reject before this runs. Firefox 152 fires only readystatechange and loadend for
|
|
8934
|
+
// navigation-canceled requests (https://bugzilla.mozilla.org/show_bug.cgi?id=1505389),
|
|
8935
|
+
// leaving settle() to resolve them as an empty success. ECONNABORTED is the error
|
|
8936
|
+
// onabort raised on Firefox 151. Reads over file:, which some environments report as
|
|
8937
|
+
// status 0 on success, are excluded by the request URL's scheme after browser-style
|
|
8938
|
+
// preprocessing, by the page origin's scheme for relative URLs (which inherit it), or
|
|
8939
|
+
// by responseURL where implemented.
|
|
8940
|
+
if (
|
|
8941
|
+
request.status === 0 &&
|
|
8942
|
+
(parseProtocol(normalizeURLForProtocolCheck(_config.url)) ||
|
|
8943
|
+
parseProtocol(platform.origin)) !== 'file' &&
|
|
8944
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
8945
|
+
) {
|
|
8946
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
8947
|
+
done();
|
|
8948
|
+
|
|
8949
|
+
// Clean up request
|
|
8950
|
+
request = null;
|
|
8951
|
+
return;
|
|
8952
|
+
}
|
|
8953
|
+
|
|
8954
|
+
// When loadend is still dispatching, flushing with it gives progress
|
|
8955
|
+
// listeners a final delivery whose event has a live target. The legacy
|
|
8956
|
+
// ready-state fallback has no event, so replay its pending progress.
|
|
8957
|
+
// A throwing listener must not block settlement; rethrow asynchronously,
|
|
8958
|
+
// matching how listener errors surface on the throttle timer path.
|
|
8959
|
+
try {
|
|
8960
|
+
if (event) {
|
|
8961
|
+
flushDownloadWithEvent && flushDownloadWithEvent(event);
|
|
8962
|
+
} else {
|
|
8963
|
+
flushDownload && flushDownload();
|
|
8964
|
+
}
|
|
8965
|
+
} catch (err) {
|
|
8966
|
+
setTimeout(() => {
|
|
8967
|
+
throw err;
|
|
8968
|
+
});
|
|
8969
|
+
}
|
|
8970
|
+
|
|
8971
|
+
// A final progress callback can cancel the request synchronously.
|
|
8061
8972
|
if (!request) {
|
|
8062
8973
|
return;
|
|
8063
8974
|
}
|
|
8975
|
+
|
|
8064
8976
|
// Prepare the response
|
|
8065
8977
|
const responseHeaders = AxiosHeaders.from(
|
|
8066
8978
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
@@ -8149,6 +9061,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8149
9061
|
|
|
8150
9062
|
// Handle timeout
|
|
8151
9063
|
request.ontimeout = function handleTimeout() {
|
|
9064
|
+
if (!request) return;
|
|
8152
9065
|
let timeoutErrorMessage = _config.timeout
|
|
8153
9066
|
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
8154
9067
|
: 'timeout exceeded';
|
|
@@ -8173,13 +9086,6 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8173
9086
|
// Remove Content-Type if data is undefined
|
|
8174
9087
|
requestData === undefined && requestHeaders.setContentType(null);
|
|
8175
9088
|
|
|
8176
|
-
// Add headers to the request
|
|
8177
|
-
if ('setRequestHeader' in request) {
|
|
8178
|
-
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
8179
|
-
request.setRequestHeader(key, val);
|
|
8180
|
-
});
|
|
8181
|
-
}
|
|
8182
|
-
|
|
8183
9089
|
// Add withCredentials to request if needed
|
|
8184
9090
|
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
8185
9091
|
request.withCredentials = !!_config.withCredentials;
|
|
@@ -8192,7 +9098,10 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8192
9098
|
|
|
8193
9099
|
// Handle progress if needed
|
|
8194
9100
|
if (onDownloadProgress) {
|
|
8195
|
-
[downloadThrottled, flushDownload] = progressEventReducer(
|
|
9101
|
+
[downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
|
|
9102
|
+
onDownloadProgress,
|
|
9103
|
+
true
|
|
9104
|
+
);
|
|
8196
9105
|
request.addEventListener('progress', downloadThrottled);
|
|
8197
9106
|
}
|
|
8198
9107
|
|
|
@@ -8213,12 +9122,14 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8213
9122
|
return;
|
|
8214
9123
|
}
|
|
8215
9124
|
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
8216
|
-
request
|
|
9125
|
+
const xhr = request;
|
|
8217
9126
|
done();
|
|
8218
9127
|
request = null;
|
|
9128
|
+
xhr.abort();
|
|
8219
9129
|
};
|
|
8220
9130
|
|
|
8221
9131
|
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
9132
|
+
if (!request) return;
|
|
8222
9133
|
if (_config.signal) {
|
|
8223
9134
|
_config.signal.aborted
|
|
8224
9135
|
? onCanceled()
|
|
@@ -8226,6 +9137,8 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8226
9137
|
}
|
|
8227
9138
|
}
|
|
8228
9139
|
|
|
9140
|
+
if (!request) return;
|
|
9141
|
+
|
|
8229
9142
|
const protocol = parseProtocol(_config.url);
|
|
8230
9143
|
|
|
8231
9144
|
if (protocol && !platform.protocols.includes(protocol)) {
|
|
@@ -8240,8 +9153,73 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
8240
9153
|
return;
|
|
8241
9154
|
}
|
|
8242
9155
|
|
|
8243
|
-
|
|
8244
|
-
|
|
9156
|
+
const sendRequest = () => {
|
|
9157
|
+
if (!request) return;
|
|
9158
|
+
// Apply headers after an asynchronous XSRF read so existing headers are
|
|
9159
|
+
// replaced through AxiosHeaders rather than appended by the native XHR.
|
|
9160
|
+
if ('setRequestHeader' in request) {
|
|
9161
|
+
utils$1.forEach(
|
|
9162
|
+
toByteStringHeaderObject(requestHeaders),
|
|
9163
|
+
function setRequestHeader(val, key) {
|
|
9164
|
+
request.setRequestHeader(key, val);
|
|
9165
|
+
}
|
|
9166
|
+
);
|
|
9167
|
+
}
|
|
9168
|
+
request.send(requestData || null);
|
|
9169
|
+
};
|
|
9170
|
+
|
|
9171
|
+
if (xsrfCookieName) {
|
|
9172
|
+
// Native XHR timeout starts at send(). Cover cookie preparation and the
|
|
9173
|
+
// subsequent request with the same budget and existing timeout handler.
|
|
9174
|
+
const now =
|
|
9175
|
+
typeof performance !== 'undefined' && utils$1.isFunction(performance.now)
|
|
9176
|
+
? () => performance.now()
|
|
9177
|
+
: Date.now;
|
|
9178
|
+
const deadline = request.timeout > 0 ? now() + Number(request.timeout) : undefined;
|
|
9179
|
+
const abortOnTimeout = () => {
|
|
9180
|
+
if (!request) return;
|
|
9181
|
+
const xhr = request;
|
|
9182
|
+
xhr.ontimeout();
|
|
9183
|
+
xhr.abort();
|
|
9184
|
+
};
|
|
9185
|
+
if (deadline !== undefined) {
|
|
9186
|
+
const scheduleTimeout = () => {
|
|
9187
|
+
const remaining = deadline - now();
|
|
9188
|
+
if (remaining > 0) {
|
|
9189
|
+
// Browser timers overflow above the signed 32-bit delay limit.
|
|
9190
|
+
timeoutId = setTimeout(scheduleTimeout, Math.min(remaining, 0x7fffffff));
|
|
9191
|
+
} else {
|
|
9192
|
+
abortOnTimeout();
|
|
9193
|
+
}
|
|
9194
|
+
};
|
|
9195
|
+
scheduleTimeout();
|
|
9196
|
+
}
|
|
9197
|
+
|
|
9198
|
+
cookies
|
|
9199
|
+
.readAsync(xsrfCookieName)
|
|
9200
|
+
.then((value) => {
|
|
9201
|
+
if (!request) return;
|
|
9202
|
+
// Promise callbacks may run before an overdue timer after a busy task.
|
|
9203
|
+
if (deadline !== undefined && now() >= deadline) {
|
|
9204
|
+
abortOnTimeout();
|
|
9205
|
+
return;
|
|
9206
|
+
}
|
|
9207
|
+
if (value) {
|
|
9208
|
+
const headerName =
|
|
9209
|
+
utils$1.hasOwnProp(_config, 'xsrfHeaderName') && _config.xsrfHeaderName;
|
|
9210
|
+
requestHeaders.set(headerName, value);
|
|
9211
|
+
}
|
|
9212
|
+
sendRequest();
|
|
9213
|
+
})
|
|
9214
|
+
.catch((error) => {
|
|
9215
|
+
if (!request) return;
|
|
9216
|
+
reject(AxiosError.from(error, null, config, request));
|
|
9217
|
+
done();
|
|
9218
|
+
request = null;
|
|
9219
|
+
});
|
|
9220
|
+
} else {
|
|
9221
|
+
sendRequest();
|
|
9222
|
+
}
|
|
8245
9223
|
});
|
|
8246
9224
|
};
|
|
8247
9225
|
|
|
@@ -8277,18 +9255,32 @@ const composeSignals = (signals, timeout) => {
|
|
|
8277
9255
|
}, timeout);
|
|
8278
9256
|
|
|
8279
9257
|
const unsubscribe = () => {
|
|
8280
|
-
if (!signals) {
|
|
9258
|
+
if (!signals) {
|
|
9259
|
+
return;
|
|
9260
|
+
}
|
|
8281
9261
|
timer && clearTimeout(timer);
|
|
8282
9262
|
timer = null;
|
|
8283
9263
|
signals.forEach((signal) => {
|
|
8284
|
-
signal
|
|
8285
|
-
|
|
9264
|
+
const unsubscribeSignal = utils$1.getSafeProp(signal, 'unsubscribe');
|
|
9265
|
+
utils$1.isFunction(unsubscribeSignal)
|
|
9266
|
+
? unsubscribeSignal.call(signal, onabort)
|
|
8286
9267
|
: signal.removeEventListener('abort', onabort);
|
|
8287
9268
|
});
|
|
8288
9269
|
signals = null;
|
|
8289
9270
|
};
|
|
8290
9271
|
|
|
8291
|
-
signals.forEach((signal) =>
|
|
9272
|
+
signals.forEach((signal) => {
|
|
9273
|
+
if (aborted) {
|
|
9274
|
+
return;
|
|
9275
|
+
}
|
|
9276
|
+
|
|
9277
|
+
if (signal.aborted) {
|
|
9278
|
+
onabort.call(signal);
|
|
9279
|
+
return;
|
|
9280
|
+
}
|
|
9281
|
+
|
|
9282
|
+
signal.addEventListener('abort', onabort, { once: true });
|
|
9283
|
+
});
|
|
8292
9284
|
|
|
8293
9285
|
const { signal } = controller;
|
|
8294
9286
|
|
|
@@ -8387,14 +9379,157 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
8387
9379
|
);
|
|
8388
9380
|
};
|
|
8389
9381
|
|
|
9382
|
+
const CRLF = '\r\n';
|
|
9383
|
+
const normalizeLines = (value) => String(value).replace(/\r\n|\r|\n/g, CRLF);
|
|
9384
|
+
const escapeName = (value) =>
|
|
9385
|
+
String(value).replace(/[\r\n"]/g, (char) =>
|
|
9386
|
+
char === '\r' ? '%0D' : char === '\n' ? '%0A' : '%22'
|
|
9387
|
+
);
|
|
9388
|
+
|
|
9389
|
+
// Count UTF-8 bytes without allocating an encoded copy of a field. FormData
|
|
9390
|
+
// string values normalize line endings; Blob/File contents remain unchanged.
|
|
9391
|
+
const stringBytes = (value, normalize) => {
|
|
9392
|
+
let length = 0;
|
|
9393
|
+
for (let i = 0; i < value.length; i++) {
|
|
9394
|
+
const code = value.charCodeAt(i);
|
|
9395
|
+
if (normalize && (code === 13 || code === 10)) {
|
|
9396
|
+
if (code === 13 && value.charCodeAt(i + 1) === 10) i++;
|
|
9397
|
+
length += 2;
|
|
9398
|
+
} else if (code < 0x80) {
|
|
9399
|
+
length++;
|
|
9400
|
+
} else if (code < 0x800) {
|
|
9401
|
+
length += 2;
|
|
9402
|
+
} else if (
|
|
9403
|
+
code >= 0xd800 &&
|
|
9404
|
+
code <= 0xdbff &&
|
|
9405
|
+
value.charCodeAt(i + 1) >= 0xdc00 &&
|
|
9406
|
+
value.charCodeAt(i + 1) <= 0xdfff
|
|
9407
|
+
) {
|
|
9408
|
+
length += 4;
|
|
9409
|
+
i++;
|
|
9410
|
+
} else {
|
|
9411
|
+
length += 3;
|
|
9412
|
+
}
|
|
9413
|
+
}
|
|
9414
|
+
return length;
|
|
9415
|
+
};
|
|
9416
|
+
|
|
9417
|
+
// Describe serialization failures independently of any request library.
|
|
9418
|
+
class FormDataError extends TypeError {
|
|
9419
|
+
constructor(message, reason) {
|
|
9420
|
+
super(message);
|
|
9421
|
+
this.name = 'FormDataError';
|
|
9422
|
+
this.reason = reason;
|
|
9423
|
+
}
|
|
9424
|
+
}
|
|
9425
|
+
|
|
9426
|
+
// The caller supplies the boundary, Blob implementation, and limit error.
|
|
9427
|
+
function formDataToBlob(form, Blob, limit, limitError, boundary) {
|
|
9428
|
+
if (!utils$1.isFunction(Blob)) {
|
|
9429
|
+
throw new FormDataError('Blob is not supported', 'blob');
|
|
9430
|
+
}
|
|
9431
|
+
|
|
9432
|
+
if (
|
|
9433
|
+
!utils$1.isString(boundary) ||
|
|
9434
|
+
!/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) ||
|
|
9435
|
+
/ $/.test(boundary)
|
|
9436
|
+
) {
|
|
9437
|
+
throw new FormDataError('Invalid multipart boundary', 'boundary');
|
|
9438
|
+
}
|
|
9439
|
+
const footer = '--' + boundary + '--' + CRLF;
|
|
9440
|
+
let length = footer.length;
|
|
9441
|
+
const parts = [];
|
|
9442
|
+
const checkLength = (extra) => {
|
|
9443
|
+
if (length + extra > limit) throw limitError();
|
|
9444
|
+
};
|
|
9445
|
+
checkLength(0);
|
|
9446
|
+
|
|
9447
|
+
for (const [name, value] of form) {
|
|
9448
|
+
const isString = utils$1.isString(value);
|
|
9449
|
+
const valueLength = isString ? stringBytes(value, true) : value.size;
|
|
9450
|
+
if (!Number.isFinite(valueLength) || valueLength < 0) {
|
|
9451
|
+
throw new FormDataError('Unsupported FormData part size', 'part');
|
|
9452
|
+
}
|
|
9453
|
+
// Reject large values and names before building normalized header strings.
|
|
9454
|
+
checkLength(
|
|
9455
|
+
valueLength +
|
|
9456
|
+
stringBytes(name, true) +
|
|
9457
|
+
(!isString && value.name ? stringBytes(value.name, false) : 0) +
|
|
9458
|
+
(!isString && value.type ? stringBytes(value.type, false) : 0)
|
|
9459
|
+
);
|
|
9460
|
+
|
|
9461
|
+
let header =
|
|
9462
|
+
'--' +
|
|
9463
|
+
boundary +
|
|
9464
|
+
CRLF +
|
|
9465
|
+
'Content-Disposition: form-data; name="' +
|
|
9466
|
+
escapeName(normalizeLines(name)) +
|
|
9467
|
+
'"';
|
|
9468
|
+
if (!isString) {
|
|
9469
|
+
header +=
|
|
9470
|
+
'; filename="' +
|
|
9471
|
+
escapeName(utils$1.isString(value.name) ? value.name : 'blob') +
|
|
9472
|
+
'"' +
|
|
9473
|
+
CRLF +
|
|
9474
|
+
'Content-Type: ' +
|
|
9475
|
+
String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
9476
|
+
}
|
|
9477
|
+
header += CRLF + CRLF;
|
|
9478
|
+
const partLength = stringBytes(header, false) + valueLength + CRLF.length;
|
|
9479
|
+
checkLength(partLength);
|
|
9480
|
+
length += partLength;
|
|
9481
|
+
parts.push({ header, value, isString });
|
|
9482
|
+
}
|
|
9483
|
+
|
|
9484
|
+
// Native Blob composition retains existing Blob/File data. No file is read
|
|
9485
|
+
// and no complete multipart ArrayBuffer is created to determine its length.
|
|
9486
|
+
const blobParts = [];
|
|
9487
|
+
for (const part of parts) {
|
|
9488
|
+
blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF);
|
|
9489
|
+
}
|
|
9490
|
+
blobParts.push(footer);
|
|
9491
|
+
return new Blob(blobParts, { type: 'multipart/form-data; boundary=' + boundary });
|
|
9492
|
+
}
|
|
9493
|
+
|
|
9494
|
+
function createMultipartBody(form, Blob, limit, limitError, boundary) {
|
|
9495
|
+
// Report missing Blob support before trying to select a random source.
|
|
9496
|
+
if (!utils$1.isFunction(Blob)) {
|
|
9497
|
+
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
9498
|
+
}
|
|
9499
|
+
|
|
9500
|
+
if (boundary === undefined) {
|
|
9501
|
+
if (utils$1.isFunction(platform.generateString)) {
|
|
9502
|
+
boundary = 'axios-' + platform.generateString(36, '0123456789abcdef');
|
|
9503
|
+
} else {
|
|
9504
|
+
const crypto = utils$1.global.crypto;
|
|
9505
|
+
if (!crypto || !utils$1.isFunction(crypto.getRandomValues)) {
|
|
9506
|
+
throw new AxiosError('Random byte generation is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
9507
|
+
}
|
|
9508
|
+
const random = new Uint8Array(18);
|
|
9509
|
+
crypto.getRandomValues(random);
|
|
9510
|
+
boundary =
|
|
9511
|
+
'axios-' + Array.from(random, (value) => ('0' + value.toString(16)).slice(-2)).join('');
|
|
9512
|
+
}
|
|
9513
|
+
}
|
|
9514
|
+
|
|
9515
|
+
try {
|
|
9516
|
+
return formDataToBlob(form, Blob, limit, limitError, boundary);
|
|
9517
|
+
} catch (error) {
|
|
9518
|
+
if (error instanceof FormDataError) {
|
|
9519
|
+
const code =
|
|
9520
|
+
error.reason === 'boundary' ? AxiosError.ERR_BAD_OPTION_VALUE : AxiosError.ERR_BAD_REQUEST;
|
|
9521
|
+
throw new AxiosError(error.message, code);
|
|
9522
|
+
}
|
|
9523
|
+
throw error;
|
|
9524
|
+
}
|
|
9525
|
+
}
|
|
9526
|
+
|
|
8390
9527
|
/**
|
|
8391
|
-
* Estimate
|
|
8392
|
-
* -
|
|
8393
|
-
*
|
|
8394
|
-
*
|
|
8395
|
-
*
|
|
8396
|
-
* @param {string} url
|
|
8397
|
-
* @returns {number}
|
|
9528
|
+
* Estimate data: URL byte lengths *without* allocating large buffers.
|
|
9529
|
+
* - Fetch percent-decodes a base64 body before decoding it.
|
|
9530
|
+
* - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
|
|
9531
|
+
* percent-decoded body, including ignored characters and content after padding.
|
|
9532
|
+
* - Non-base64 data is percent-decoded and then encoded as UTF-8.
|
|
8398
9533
|
*/
|
|
8399
9534
|
const isHexDigit = (charCode) =>
|
|
8400
9535
|
(charCode >= 48 && charCode <= 57) ||
|
|
@@ -8404,64 +9539,101 @@ const isHexDigit = (charCode) =>
|
|
|
8404
9539
|
const isPercentEncodedByte = (str, i, len) =>
|
|
8405
9540
|
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
8406
9541
|
|
|
8407
|
-
|
|
8408
|
-
if (!url || typeof url !== 'string') return 0;
|
|
8409
|
-
if (!url.startsWith('data:')) return 0;
|
|
9542
|
+
const hexValue = (charCode) => (charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55);
|
|
8410
9543
|
|
|
8411
|
-
|
|
8412
|
-
|
|
9544
|
+
const isBase64Char = (charCode) =>
|
|
9545
|
+
(charCode >= 65 && charCode <= 90) || // A-Z
|
|
9546
|
+
(charCode >= 97 && charCode <= 122) || // a-z
|
|
9547
|
+
(charCode >= 48 && charCode <= 57) || // 0-9
|
|
9548
|
+
charCode === 43 || // +
|
|
9549
|
+
charCode === 47 || // /
|
|
9550
|
+
charCode === 45 || // - (base64url)
|
|
9551
|
+
charCode === 95; // _ (base64url)
|
|
8413
9552
|
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
const isBase64 = /;base64/i.test(meta);
|
|
9553
|
+
const isBase64Whitespace = (charCode) =>
|
|
9554
|
+
charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
|
|
8417
9555
|
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
9556
|
+
const base64Bytes = (significant) => {
|
|
9557
|
+
const groups = Math.floor(significant / 4);
|
|
9558
|
+
const remainder = significant % 4;
|
|
9559
|
+
return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
9560
|
+
};
|
|
8421
9561
|
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
9562
|
+
// Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
|
|
9563
|
+
// upper bound even when Buffer.from later ignores characters or stops at '='.
|
|
9564
|
+
const estimateBase64BufferAllocation = (body) => {
|
|
9565
|
+
const len = body.length;
|
|
9566
|
+
let padding = 0;
|
|
8427
9567
|
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
9568
|
+
if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
|
|
9569
|
+
padding++;
|
|
9570
|
+
|
|
9571
|
+
if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
|
|
9572
|
+
padding++;
|
|
8433
9573
|
}
|
|
9574
|
+
}
|
|
8434
9575
|
|
|
8435
|
-
|
|
8436
|
-
|
|
9576
|
+
return Math.floor(((len - padding) * 3) / 4);
|
|
9577
|
+
};
|
|
8437
9578
|
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
9579
|
+
const estimatePercentDecodedBase64Bytes = (body) => {
|
|
9580
|
+
const len = body.length;
|
|
9581
|
+
let significant = 0;
|
|
9582
|
+
let padding = 0;
|
|
9583
|
+
let invalid = false;
|
|
8443
9584
|
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
idx -= 3;
|
|
8451
|
-
}
|
|
9585
|
+
for (let i = 0; i < len; i++) {
|
|
9586
|
+
let code = body.charCodeAt(i);
|
|
9587
|
+
|
|
9588
|
+
if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
9589
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
9590
|
+
i += 2;
|
|
8452
9591
|
}
|
|
8453
9592
|
|
|
8454
|
-
if (
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
9593
|
+
if (isBase64Whitespace(code)) {
|
|
9594
|
+
continue;
|
|
9595
|
+
}
|
|
9596
|
+
|
|
9597
|
+
if (code === 61 /* '=' */) {
|
|
9598
|
+
padding++;
|
|
9599
|
+
continue;
|
|
9600
|
+
}
|
|
9601
|
+
|
|
9602
|
+
if (!isBase64Char(code) || padding > 0) {
|
|
9603
|
+
invalid = true;
|
|
9604
|
+
continue;
|
|
8460
9605
|
}
|
|
8461
9606
|
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
9607
|
+
significant++;
|
|
9608
|
+
}
|
|
9609
|
+
|
|
9610
|
+
// Fetch rejects malformed forgiving-base64 input. Returning the raw-size
|
|
9611
|
+
// allocation bound keeps that invalid input from becoming a pre-check bypass.
|
|
9612
|
+
if (
|
|
9613
|
+
invalid ||
|
|
9614
|
+
padding > 2 ||
|
|
9615
|
+
(padding > 0 && (significant + padding) % 4 !== 0) ||
|
|
9616
|
+
significant % 4 === 1
|
|
9617
|
+
) {
|
|
9618
|
+
return estimateBase64BufferAllocation(body);
|
|
9619
|
+
}
|
|
9620
|
+
|
|
9621
|
+
return base64Bytes(significant);
|
|
9622
|
+
};
|
|
9623
|
+
|
|
9624
|
+
const estimateDataURLBytes = (url, estimateBase64, base64Pattern) => {
|
|
9625
|
+
if (!url || typeof url !== 'string') return 0;
|
|
9626
|
+
if (!/^data:/i.test(url)) return 0;
|
|
9627
|
+
|
|
9628
|
+
const comma = url.indexOf(',');
|
|
9629
|
+
if (comma < 0) return 0;
|
|
9630
|
+
|
|
9631
|
+
const meta = url.slice(5, comma);
|
|
9632
|
+
const body = url.slice(comma + 1);
|
|
9633
|
+
const isBase64 = base64Pattern.test(meta);
|
|
9634
|
+
|
|
9635
|
+
if (isBase64) {
|
|
9636
|
+
return estimateBase64(body);
|
|
8465
9637
|
}
|
|
8466
9638
|
|
|
8467
9639
|
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
@@ -8491,12 +9663,41 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
8491
9663
|
}
|
|
8492
9664
|
}
|
|
8493
9665
|
return bytes;
|
|
9666
|
+
};
|
|
9667
|
+
|
|
9668
|
+
/**
|
|
9669
|
+
* Estimate the percent-decoded payload size used by Fetch data: URLs.
|
|
9670
|
+
*
|
|
9671
|
+
* @param {string} url
|
|
9672
|
+
* @returns {number}
|
|
9673
|
+
*/
|
|
9674
|
+
function estimateDataURLDecodedBytes(url) {
|
|
9675
|
+
// Fetch removes URL fragments before processing a data: URL.
|
|
9676
|
+
const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
|
|
9677
|
+
|
|
9678
|
+
return estimateDataURLBytes(
|
|
9679
|
+
fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
|
|
9680
|
+
estimatePercentDecodedBase64Bytes,
|
|
9681
|
+
/; *base64[\t\n\f\r ]*$/i
|
|
9682
|
+
);
|
|
8494
9683
|
}
|
|
8495
9684
|
|
|
8496
|
-
const VERSION = "1.
|
|
9685
|
+
const VERSION = "1.21.1";
|
|
8497
9686
|
|
|
8498
9687
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
8499
9688
|
|
|
9689
|
+
const DEFAULT_REQUEST_OPTIONS = {
|
|
9690
|
+
cache: 'default',
|
|
9691
|
+
redirect: 'follow',
|
|
9692
|
+
referrer: 'about:client',
|
|
9693
|
+
referrerPolicy: '',
|
|
9694
|
+
mode: 'cors',
|
|
9695
|
+
integrity: '',
|
|
9696
|
+
keepalive: false,
|
|
9697
|
+
priority: 'auto',
|
|
9698
|
+
window: null,
|
|
9699
|
+
};
|
|
9700
|
+
|
|
8500
9701
|
const { isFunction } = utils$1;
|
|
8501
9702
|
|
|
8502
9703
|
/**
|
|
@@ -8547,9 +9748,7 @@ const maybeWithAuthCredentials = (url) => {
|
|
|
8547
9748
|
|
|
8548
9749
|
const factory = (env) => {
|
|
8549
9750
|
const globalObject =
|
|
8550
|
-
utils$1.global !== undefined && utils$1.global !== null
|
|
8551
|
-
? utils$1.global
|
|
8552
|
-
: globalThis;
|
|
9751
|
+
utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
|
|
8553
9752
|
const { ReadableStream, TextEncoder } = globalObject;
|
|
8554
9753
|
|
|
8555
9754
|
env = utils$1.merge.call(
|
|
@@ -8559,11 +9758,13 @@ const factory = (env) => {
|
|
|
8559
9758
|
{
|
|
8560
9759
|
Request: globalObject.Request,
|
|
8561
9760
|
Response: globalObject.Response,
|
|
9761
|
+
Blob: globalObject.Blob,
|
|
8562
9762
|
},
|
|
8563
9763
|
env
|
|
8564
9764
|
);
|
|
8565
9765
|
|
|
8566
|
-
const
|
|
9766
|
+
const envFetch = utils$1.hasOwnProp(env, 'fetch') ? env.fetch : undefined;
|
|
9767
|
+
const { Request, Response, Blob } = env;
|
|
8567
9768
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
8568
9769
|
const isRequestSupported = isFunction(Request);
|
|
8569
9770
|
const isResponseSupported = isFunction(Response);
|
|
@@ -8612,6 +9813,20 @@ const factory = (env) => {
|
|
|
8612
9813
|
isReadableStreamSupported &&
|
|
8613
9814
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
8614
9815
|
|
|
9816
|
+
// Some runtimes reject every explicit cache mode. Use own defaults for both
|
|
9817
|
+
// probes so unrelated polluted options cannot affect cache-mode detection.
|
|
9818
|
+
const requestDefaults = Object.assign(Object.create(null), DEFAULT_REQUEST_OPTIONS);
|
|
9819
|
+
|
|
9820
|
+
if (isRequestSupported && !test(() => new Request(platform.origin, requestDefaults))) {
|
|
9821
|
+
delete requestDefaults.cache;
|
|
9822
|
+
|
|
9823
|
+
// Only omit cache when that makes Request construction succeed. Otherwise
|
|
9824
|
+
// retain the explicit default that protects supporting runtimes from pollution.
|
|
9825
|
+
if (!test(() => new Request(platform.origin, requestDefaults))) {
|
|
9826
|
+
requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
|
|
9827
|
+
}
|
|
9828
|
+
}
|
|
9829
|
+
|
|
8615
9830
|
const resolvers = {
|
|
8616
9831
|
stream: supportsResponseStream && ((res) => res.body),
|
|
8617
9832
|
};
|
|
@@ -8645,14 +9860,6 @@ const factory = (env) => {
|
|
|
8645
9860
|
return body.size;
|
|
8646
9861
|
}
|
|
8647
9862
|
|
|
8648
|
-
if (utils$1.isSpecCompliantForm(body)) {
|
|
8649
|
-
const _request = new Request(platform.origin, {
|
|
8650
|
-
method: 'POST',
|
|
8651
|
-
body,
|
|
8652
|
-
});
|
|
8653
|
-
return (await _request.arrayBuffer()).byteLength;
|
|
8654
|
-
}
|
|
8655
|
-
|
|
8656
9863
|
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
8657
9864
|
return body.byteLength;
|
|
8658
9865
|
}
|
|
@@ -8688,6 +9895,7 @@ const factory = (env) => {
|
|
|
8688
9895
|
fetchOptions,
|
|
8689
9896
|
maxContentLength,
|
|
8690
9897
|
maxBodyLength,
|
|
9898
|
+
maxRedirects,
|
|
8691
9899
|
} = resolveConfig(config);
|
|
8692
9900
|
|
|
8693
9901
|
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
@@ -8714,11 +9922,12 @@ const factory = (env) => {
|
|
|
8714
9922
|
|
|
8715
9923
|
let requestContentLength;
|
|
8716
9924
|
|
|
8717
|
-
//
|
|
9925
|
+
// AxiosErrors we raise while request or response bodies are being streamed. Captured
|
|
8718
9926
|
// by identity so the catch block can surface it directly, regardless of
|
|
8719
9927
|
// how the runtime wraps the resulting fetch rejection (undici exposes it
|
|
8720
9928
|
// as `err.cause`; some browsers drop the original error entirely).
|
|
8721
9929
|
let pendingBodyError = null;
|
|
9930
|
+
let pendingResponseError = null;
|
|
8722
9931
|
|
|
8723
9932
|
const maxBodyLengthError = () =>
|
|
8724
9933
|
new AxiosError(
|
|
@@ -8738,19 +9947,20 @@ const factory = (env) => {
|
|
|
8738
9947
|
const password = utils$1.getSafeProp(configAuth, 'password') || '';
|
|
8739
9948
|
auth = {
|
|
8740
9949
|
username,
|
|
8741
|
-
password
|
|
9950
|
+
password,
|
|
8742
9951
|
};
|
|
8743
9952
|
}
|
|
8744
9953
|
|
|
9954
|
+
let parsedURL;
|
|
8745
9955
|
if (maybeWithAuthCredentials(url)) {
|
|
8746
|
-
|
|
9956
|
+
parsedURL = new URL(url, platform.origin);
|
|
8747
9957
|
|
|
8748
9958
|
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
8749
9959
|
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
8750
9960
|
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
8751
9961
|
auth = {
|
|
8752
9962
|
username: urlUsername,
|
|
8753
|
-
password: urlPassword
|
|
9963
|
+
password: urlPassword,
|
|
8754
9964
|
};
|
|
8755
9965
|
}
|
|
8756
9966
|
|
|
@@ -8772,8 +9982,8 @@ const factory = (env) => {
|
|
|
8772
9982
|
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
8773
9983
|
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
8774
9984
|
// "if (protocol === 'data:')" branch).
|
|
8775
|
-
if (hasMaxContentLength &&
|
|
8776
|
-
const estimated = estimateDataURLDecodedBytes(
|
|
9985
|
+
if (hasMaxContentLength && parsedURL && parsedURL.protocol === 'data:') {
|
|
9986
|
+
const estimated = estimateDataURLDecodedBytes(parsedURL.href);
|
|
8777
9987
|
if (estimated > maxContentLength) {
|
|
8778
9988
|
throw new AxiosError(
|
|
8779
9989
|
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
@@ -8784,6 +9994,38 @@ const factory = (env) => {
|
|
|
8784
9994
|
}
|
|
8785
9995
|
}
|
|
8786
9996
|
|
|
9997
|
+
const formContentType =
|
|
9998
|
+
utils$1.isSpecCompliantForm(data) && AxiosHeaders.from(own('headers')).getContentType();
|
|
9999
|
+
let formBoundary;
|
|
10000
|
+
if (
|
|
10001
|
+
utils$1.isString(formContentType) &&
|
|
10002
|
+
/^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())
|
|
10003
|
+
) {
|
|
10004
|
+
const parameters = AxiosHeaders.parseParameters(formContentType);
|
|
10005
|
+
if (utils$1.hasOwnProp(parameters, 'boundary')) formBoundary = parameters.boundary;
|
|
10006
|
+
}
|
|
10007
|
+
|
|
10008
|
+
if (
|
|
10009
|
+
utils$1.isSpecCompliantForm(data) &&
|
|
10010
|
+
method !== 'get' &&
|
|
10011
|
+
method !== 'head' &&
|
|
10012
|
+
(hasMaxBodyLength ||
|
|
10013
|
+
(onUploadProgress && supportsRequestStream) ||
|
|
10014
|
+
formBoundary !== undefined)
|
|
10015
|
+
) {
|
|
10016
|
+
data = createMultipartBody(
|
|
10017
|
+
data,
|
|
10018
|
+
Blob,
|
|
10019
|
+
hasMaxBodyLength ? maxBodyLength : Infinity,
|
|
10020
|
+
maxBodyLengthError,
|
|
10021
|
+
formBoundary
|
|
10022
|
+
);
|
|
10023
|
+
// Blob.type lowercases its value, including a case-sensitive boundary.
|
|
10024
|
+
// Retain the caller's header when an explicit boundary was serialized.
|
|
10025
|
+
headers.setContentType(formBoundary === undefined ? data.type : formContentType);
|
|
10026
|
+
requestContentLength = data.size;
|
|
10027
|
+
}
|
|
10028
|
+
|
|
8787
10029
|
// Enforce maxBodyLength against known-size bodies before dispatch using
|
|
8788
10030
|
// the body's *actual* size — never a caller-declared Content-Length,
|
|
8789
10031
|
// which could under-report to slip an oversized body past the check.
|
|
@@ -8824,7 +10066,9 @@ const factory = (env) => {
|
|
|
8824
10066
|
(onUploadProgress || mustEnforceStreamBody)
|
|
8825
10067
|
) {
|
|
8826
10068
|
requestContentLength =
|
|
8827
|
-
requestContentLength == null
|
|
10069
|
+
requestContentLength == null
|
|
10070
|
+
? await resolveBodyLength(headers, data)
|
|
10071
|
+
: requestContentLength;
|
|
8828
10072
|
|
|
8829
10073
|
// A declared length of 0 is only trusted to skip the wrap when we are
|
|
8830
10074
|
// not enforcing a stream limit (which must not rely on that header).
|
|
@@ -8837,7 +10081,10 @@ const factory = (env) => {
|
|
|
8837
10081
|
|
|
8838
10082
|
let contentTypeHeader;
|
|
8839
10083
|
|
|
8840
|
-
if (
|
|
10084
|
+
if (
|
|
10085
|
+
utils$1.isFormData(data) &&
|
|
10086
|
+
(contentTypeHeader = _request.headers.get('content-type'))
|
|
10087
|
+
) {
|
|
8841
10088
|
headers.setContentType(contentTypeHeader);
|
|
8842
10089
|
}
|
|
8843
10090
|
|
|
@@ -8900,20 +10147,57 @@ const factory = (env) => {
|
|
|
8900
10147
|
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
8901
10148
|
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
8902
10149
|
|
|
8903
|
-
const
|
|
8904
|
-
|
|
10150
|
+
const safeFetchOptions =
|
|
10151
|
+
fetchOptions == null ? fetchOptions : Object.assign(Object.create(null), fetchOptions);
|
|
10152
|
+
|
|
10153
|
+
if (safeFetchOptions) {
|
|
10154
|
+
// These options are owned by Axios and are already reflected in the
|
|
10155
|
+
// resolved Request passed to fetch.
|
|
10156
|
+
delete safeFetchOptions.body;
|
|
10157
|
+
delete safeFetchOptions.headers;
|
|
10158
|
+
delete safeFetchOptions.method;
|
|
10159
|
+
delete safeFetchOptions.signal;
|
|
10160
|
+
delete safeFetchOptions.duplex;
|
|
10161
|
+
delete safeFetchOptions.credentials;
|
|
10162
|
+
}
|
|
10163
|
+
|
|
10164
|
+
const resolvedOptions = Object.assign(Object.create(null), safeFetchOptions, {
|
|
8905
10165
|
signal: composedSignal,
|
|
8906
10166
|
method: method.toUpperCase(),
|
|
8907
10167
|
headers: toByteStringHeaderObject(headers.normalize()),
|
|
8908
10168
|
body: data,
|
|
8909
10169
|
duplex: 'half',
|
|
8910
10170
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
8911
|
-
};
|
|
10171
|
+
});
|
|
10172
|
+
|
|
10173
|
+
if (isRequestSupported) {
|
|
10174
|
+
utils$1.forEach(requestDefaults, (value, key) => {
|
|
10175
|
+
if (resolvedOptions[key] === undefined) {
|
|
10176
|
+
resolvedOptions[key] = value;
|
|
10177
|
+
}
|
|
10178
|
+
});
|
|
10179
|
+
|
|
10180
|
+
if (resolvedOptions.signal === undefined) {
|
|
10181
|
+
resolvedOptions.signal = null;
|
|
10182
|
+
}
|
|
10183
|
+
|
|
10184
|
+
if (resolvedOptions.body === undefined) {
|
|
10185
|
+
resolvedOptions.body = null;
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
|
|
10189
|
+
if (maxRedirects === 0) {
|
|
10190
|
+
resolvedOptions.redirect = 'manual';
|
|
10191
|
+
|
|
10192
|
+
if (safeFetchOptions) {
|
|
10193
|
+
safeFetchOptions.redirect = 'manual';
|
|
10194
|
+
}
|
|
10195
|
+
}
|
|
8912
10196
|
|
|
8913
10197
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
8914
10198
|
|
|
8915
10199
|
let response = await (isRequestSupported
|
|
8916
|
-
? _fetch(request,
|
|
10200
|
+
? _fetch(request, safeFetchOptions)
|
|
8917
10201
|
: _fetch(url, resolvedOptions));
|
|
8918
10202
|
|
|
8919
10203
|
const responseHeaders = AxiosHeaders.from(response.headers);
|
|
@@ -8961,12 +10245,12 @@ const factory = (env) => {
|
|
|
8961
10245
|
if (hasMaxContentLength) {
|
|
8962
10246
|
bytesRead = loadedBytes;
|
|
8963
10247
|
if (bytesRead > maxContentLength) {
|
|
8964
|
-
throw new AxiosError(
|
|
10248
|
+
throw (pendingResponseError = new AxiosError(
|
|
8965
10249
|
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
8966
10250
|
AxiosError.ERR_BAD_RESPONSE,
|
|
8967
10251
|
config,
|
|
8968
10252
|
request
|
|
8969
|
-
);
|
|
10253
|
+
));
|
|
8970
10254
|
}
|
|
8971
10255
|
}
|
|
8972
10256
|
onProgress && onProgress(loadedBytes);
|
|
@@ -9052,7 +10336,7 @@ const factory = (env) => {
|
|
|
9052
10336
|
}
|
|
9053
10337
|
|
|
9054
10338
|
// Surface a maxBodyLength violation we raised while the request body was
|
|
9055
|
-
// being streamed.
|
|
10339
|
+
// being streamed. Keeping the original error (rather than reading
|
|
9056
10340
|
// `err.cause.isAxiosError`) keeps the error deterministic across runtimes
|
|
9057
10341
|
// and avoids both prototype-pollution reads and mis-attributing a foreign
|
|
9058
10342
|
// AxiosError that merely happened to land in `err.cause`.
|
|
@@ -9061,6 +10345,10 @@ const factory = (env) => {
|
|
|
9061
10345
|
throw pendingBodyError;
|
|
9062
10346
|
}
|
|
9063
10347
|
|
|
10348
|
+
if (pendingResponseError) {
|
|
10349
|
+
throw pendingResponseError;
|
|
10350
|
+
}
|
|
10351
|
+
|
|
9064
10352
|
// Re-throw AxiosErrors we raised synchronously (data: URL / content-length
|
|
9065
10353
|
// pre-checks, response size enforcement) without re-wrapping them.
|
|
9066
10354
|
if (err instanceof AxiosError) {
|
|
@@ -9096,9 +10384,15 @@ const factory = (env) => {
|
|
|
9096
10384
|
const seedCache = new Map();
|
|
9097
10385
|
|
|
9098
10386
|
const getFetch = (config) => {
|
|
9099
|
-
|
|
9100
|
-
const
|
|
9101
|
-
|
|
10387
|
+
const env = Object.create(null);
|
|
10388
|
+
const configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
|
|
10389
|
+
['fetch', 'Request', 'Response', 'Blob'].forEach((key) => {
|
|
10390
|
+
if (configuredEnv && utils$1.hasOwnProp(configuredEnv, key)) {
|
|
10391
|
+
env[key] = configuredEnv[key];
|
|
10392
|
+
}
|
|
10393
|
+
});
|
|
10394
|
+
const { fetch, Request, Response, Blob } = env;
|
|
10395
|
+
const seeds = [Request, Response, fetch, Blob];
|
|
9102
10396
|
|
|
9103
10397
|
let len = seeds.length,
|
|
9104
10398
|
i = len,
|
|
@@ -9264,6 +10558,37 @@ function throwIfCancellationRequested(config) {
|
|
|
9264
10558
|
}
|
|
9265
10559
|
}
|
|
9266
10560
|
|
|
10561
|
+
/**
|
|
10562
|
+
* Resolve the clock used to time adapter execution.
|
|
10563
|
+
*
|
|
10564
|
+
* Prefers the monotonic `performance.now()` so wall-clock adjustments do not
|
|
10565
|
+
* skew the measurement, and so frameworks that forbid reading the current
|
|
10566
|
+
* time during prerendering (e.g. Next.js Cache Components) accept it. Falls
|
|
10567
|
+
* back to `Date.now()` in runtimes without the High Resolution Time API.
|
|
10568
|
+
*
|
|
10569
|
+
* @returns {() => number} Millisecond clock
|
|
10570
|
+
*/
|
|
10571
|
+
function resolveClock() {
|
|
10572
|
+
return typeof performance !== 'undefined' && utils$1.isFunction(performance.now)
|
|
10573
|
+
? () => performance.now()
|
|
10574
|
+
: Date.now;
|
|
10575
|
+
}
|
|
10576
|
+
|
|
10577
|
+
/**
|
|
10578
|
+
* Whole milliseconds elapsed since `start`, floored at zero.
|
|
10579
|
+
*
|
|
10580
|
+
* Rounded so the value stays an integer as with `Date.now()`. The fallback
|
|
10581
|
+
* wall clock can move backwards mid-request, so the result is clamped.
|
|
10582
|
+
*
|
|
10583
|
+
* @param {() => number} now Clock returned by `resolveClock()`
|
|
10584
|
+
* @param {number} start Timestamp read from `now`
|
|
10585
|
+
*
|
|
10586
|
+
* @returns {number} Non-negative elapsed milliseconds
|
|
10587
|
+
*/
|
|
10588
|
+
function elapsedSince(now, start) {
|
|
10589
|
+
return Math.max(0, Math.round(now() - start));
|
|
10590
|
+
}
|
|
10591
|
+
|
|
9267
10592
|
/**
|
|
9268
10593
|
* Dispatch a request to the server using the configured adapter.
|
|
9269
10594
|
*
|
|
@@ -9271,10 +10596,15 @@ function throwIfCancellationRequested(config) {
|
|
|
9271
10596
|
*
|
|
9272
10597
|
* @returns {Promise} The Promise to be fulfilled
|
|
9273
10598
|
*/
|
|
9274
|
-
function dispatchRequest(
|
|
10599
|
+
function dispatchRequest(_config) {
|
|
10600
|
+
// Interceptors may replace the merged config with an ordinary object. Flatten
|
|
10601
|
+
// it at the dispatch boundary so shared prototype members cannot become
|
|
10602
|
+
// request behavior, while preserving intentional template/class members.
|
|
10603
|
+
const config = utils$1.toSafeFlatObject(_config);
|
|
10604
|
+
|
|
9275
10605
|
throwIfCancellationRequested(config);
|
|
9276
10606
|
|
|
9277
|
-
config.headers = AxiosHeaders.from(config
|
|
10607
|
+
config.headers = AxiosHeaders.from(utils$1.getSafeProp(config, 'headers'));
|
|
9278
10608
|
|
|
9279
10609
|
// Transform request data
|
|
9280
10610
|
config.data = transformData.call(config, config.transformRequest);
|
|
@@ -9285,10 +10615,15 @@ function dispatchRequest(config) {
|
|
|
9285
10615
|
|
|
9286
10616
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
9287
10617
|
|
|
10618
|
+
const now = resolveClock();
|
|
10619
|
+
const start = now();
|
|
10620
|
+
|
|
9288
10621
|
return adapter(config).then(
|
|
9289
10622
|
function onAdapterResolution(response) {
|
|
9290
10623
|
throwIfCancellationRequested(config);
|
|
9291
10624
|
|
|
10625
|
+
response.duration = elapsedSince(now, start);
|
|
10626
|
+
|
|
9292
10627
|
// Expose the current response on config so that transformResponse can
|
|
9293
10628
|
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
9294
10629
|
// We clean it up afterwards to avoid polluting the config object.
|
|
@@ -9309,6 +10644,7 @@ function dispatchRequest(config) {
|
|
|
9309
10644
|
|
|
9310
10645
|
// Transform response data
|
|
9311
10646
|
if (reason && reason.response) {
|
|
10647
|
+
reason.response.duration = elapsedSince(now, start);
|
|
9312
10648
|
config.response = reason.response;
|
|
9313
10649
|
try {
|
|
9314
10650
|
reason.response.data = transformData.call(
|
|
@@ -9438,6 +10774,37 @@ var validator = {
|
|
|
9438
10774
|
|
|
9439
10775
|
const validators = validator.validators;
|
|
9440
10776
|
|
|
10777
|
+
// Recognize header maps without consuming objects intended as literal values.
|
|
10778
|
+
// AxiosHeaders from other builds share a brand and header-container interface,
|
|
10779
|
+
// but not constructor identity. A tag and toJSON alone can describe a literal.
|
|
10780
|
+
const isHeadersBucket = (value) => {
|
|
10781
|
+
if (value == null || utils$1.isPlainObject(value) || value instanceof AxiosHeaders) {
|
|
10782
|
+
return true;
|
|
10783
|
+
}
|
|
10784
|
+
|
|
10785
|
+
try {
|
|
10786
|
+
return (
|
|
10787
|
+
utils$1.isObject(value) &&
|
|
10788
|
+
utils$1.getSafeProp(value, Symbol.toStringTag) === 'AxiosHeaders' &&
|
|
10789
|
+
[
|
|
10790
|
+
'toJSON',
|
|
10791
|
+
'set',
|
|
10792
|
+
'get',
|
|
10793
|
+
'has',
|
|
10794
|
+
'delete',
|
|
10795
|
+
'clear',
|
|
10796
|
+
'normalize',
|
|
10797
|
+
'concat',
|
|
10798
|
+
'toString',
|
|
10799
|
+
Symbol.iterator,
|
|
10800
|
+
].every((method) => utils$1.isFunction(utils$1.getSafeProp(value, method)))
|
|
10801
|
+
);
|
|
10802
|
+
} catch (e) {
|
|
10803
|
+
// A failed optional brand probe must not prevent literal header serialization.
|
|
10804
|
+
return false;
|
|
10805
|
+
}
|
|
10806
|
+
};
|
|
10807
|
+
|
|
9441
10808
|
/**
|
|
9442
10809
|
* Create a new instance of Axios
|
|
9443
10810
|
*
|
|
@@ -9467,37 +10834,47 @@ class Axios {
|
|
|
9467
10834
|
return await this._request(configOrUrl, config);
|
|
9468
10835
|
} catch (err) {
|
|
9469
10836
|
if (err instanceof Error) {
|
|
9470
|
-
|
|
10837
|
+
try {
|
|
10838
|
+
let dummy = {};
|
|
9471
10839
|
|
|
9472
|
-
|
|
10840
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
9473
10841
|
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
if (!dummy.stack) {
|
|
9477
|
-
return '';
|
|
9478
|
-
}
|
|
10842
|
+
const dummyStack = dummy.stack;
|
|
10843
|
+
let stack = '';
|
|
9479
10844
|
|
|
9480
|
-
|
|
10845
|
+
// slice off the Error: ... line
|
|
10846
|
+
if (typeof dummyStack === 'string') {
|
|
10847
|
+
const firstNewlineIndex = dummyStack.indexOf('\n');
|
|
10848
|
+
|
|
10849
|
+
stack = firstNewlineIndex === -1 ? '' : dummyStack.slice(firstNewlineIndex + 1);
|
|
10850
|
+
}
|
|
9481
10851
|
|
|
9482
|
-
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
9483
|
-
})();
|
|
9484
|
-
try {
|
|
9485
10852
|
if (!err.stack) {
|
|
9486
10853
|
err.stack = stack;
|
|
9487
|
-
// match without the 2 top stack lines
|
|
9488
10854
|
} else if (stack) {
|
|
10855
|
+
// Match a common suffix after the 2 top frames when available,
|
|
10856
|
+
// otherwise compare the full reconstructed stack.
|
|
9489
10857
|
const firstNewlineIndex = stack.indexOf('\n');
|
|
9490
10858
|
const secondNewlineIndex =
|
|
9491
10859
|
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
9492
|
-
const
|
|
9493
|
-
secondNewlineIndex === -1 ?
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
10860
|
+
const duplicateCheckSuffix =
|
|
10861
|
+
secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1);
|
|
10862
|
+
|
|
10863
|
+
// `AxiosError.from()` may have already inlined the wrapped error's
|
|
10864
|
+
// stack under a `Caused by:` marker. Keep the reconstructed caller
|
|
10865
|
+
// frames ahead of that marker so stack-only reporters do not read
|
|
10866
|
+
// them as part of the low-level cause.
|
|
10867
|
+
const currentStack = String(err.stack);
|
|
10868
|
+
const causeIndex = getCauseStackIndex(err, currentStack);
|
|
10869
|
+
const stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
|
|
10870
|
+
const causeSection = causeIndex === -1 ? '' : currentStack.slice(causeIndex);
|
|
10871
|
+
|
|
10872
|
+
if (!stackHead.endsWith(duplicateCheckSuffix)) {
|
|
10873
|
+
err.stack = stackHead + '\n' + stack + causeSection;
|
|
9497
10874
|
}
|
|
9498
10875
|
}
|
|
9499
10876
|
} catch (e) {
|
|
9500
|
-
//
|
|
10877
|
+
// Ignore failures from custom stack hooks or un-writable stack properties.
|
|
9501
10878
|
}
|
|
9502
10879
|
}
|
|
9503
10880
|
|
|
@@ -9529,6 +10906,7 @@ class Axios {
|
|
|
9529
10906
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
9530
10907
|
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
9531
10908
|
validateStatusUndefinedResolves: validators.transitional(validators.boolean),
|
|
10909
|
+
encodeBasicAuthUsername: validators.transitional(validators.boolean),
|
|
9532
10910
|
},
|
|
9533
10911
|
false
|
|
9534
10912
|
);
|
|
@@ -9552,7 +10930,10 @@ class Axios {
|
|
|
9552
10930
|
}
|
|
9553
10931
|
|
|
9554
10932
|
// Set config.allowAbsoluteUrls
|
|
9555
|
-
if (config.allowAbsoluteUrls !== undefined) ; else if (
|
|
10933
|
+
if (config.allowAbsoluteUrls !== undefined) ; else if (
|
|
10934
|
+
utils$1.hasOwnProp(this.defaults, 'allowAbsoluteUrls') &&
|
|
10935
|
+
this.defaults.allowAbsoluteUrls !== undefined
|
|
10936
|
+
) {
|
|
9556
10937
|
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
9557
10938
|
} else {
|
|
9558
10939
|
config.allowAbsoluteUrls = true;
|
|
@@ -9568,14 +10949,27 @@ class Axios {
|
|
|
9568
10949
|
);
|
|
9569
10950
|
|
|
9570
10951
|
// Set config.method
|
|
9571
|
-
config.method = (
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
10952
|
+
config.method = (
|
|
10953
|
+
utils$1.getSafeProp(config, 'method') ||
|
|
10954
|
+
utils$1.getSafeProp(this.defaults, 'method') ||
|
|
10955
|
+
'get'
|
|
10956
|
+
).toLowerCase();
|
|
10957
|
+
|
|
10958
|
+
// Flatten header defaults without consuming literal method-named headers.
|
|
10959
|
+
const commonHeaders = utils$1.getSafeProp(headers, 'common');
|
|
10960
|
+
const methodHeaders = utils$1.getSafeProp(headers, config.method);
|
|
10961
|
+
const contextHeaders =
|
|
10962
|
+
headers &&
|
|
10963
|
+
utils$1.merge(
|
|
10964
|
+
isHeadersBucket(commonHeaders) ? commonHeaders : undefined,
|
|
10965
|
+
isHeadersBucket(methodHeaders) ? methodHeaders : undefined
|
|
10966
|
+
);
|
|
9575
10967
|
|
|
9576
10968
|
headers &&
|
|
9577
|
-
utils$1.forEach(
|
|
9578
|
-
|
|
10969
|
+
utils$1.forEach(methodList.concat('common'), (method) => {
|
|
10970
|
+
if (isHeadersBucket(utils$1.getSafeProp(headers, method))) {
|
|
10971
|
+
delete headers[method];
|
|
10972
|
+
}
|
|
9579
10973
|
});
|
|
9580
10974
|
|
|
9581
10975
|
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
@@ -9633,17 +11027,35 @@ class Axios {
|
|
|
9633
11027
|
const onFulfilled = requestInterceptorChain[i++];
|
|
9634
11028
|
const onRejected = requestInterceptorChain[i++];
|
|
9635
11029
|
try {
|
|
9636
|
-
newConfig = onFulfilled(newConfig);
|
|
11030
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
9637
11031
|
} catch (error) {
|
|
9638
|
-
onRejected
|
|
11032
|
+
if (!onRejected) {
|
|
11033
|
+
promise = Promise.reject(error);
|
|
11034
|
+
break;
|
|
11035
|
+
}
|
|
11036
|
+
|
|
11037
|
+
try {
|
|
11038
|
+
const rejectedResult = onRejected.call(this, error);
|
|
11039
|
+
|
|
11040
|
+
if (utils$1.isThenable(rejectedResult)) {
|
|
11041
|
+
promise = Promise.resolve(rejectedResult).then(() =>
|
|
11042
|
+
dispatchRequest.call(this, newConfig)
|
|
11043
|
+
);
|
|
11044
|
+
}
|
|
11045
|
+
} catch (rejectedError) {
|
|
11046
|
+
promise = Promise.reject(rejectedError);
|
|
11047
|
+
}
|
|
11048
|
+
|
|
9639
11049
|
break;
|
|
9640
11050
|
}
|
|
9641
11051
|
}
|
|
9642
11052
|
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
11053
|
+
if (!promise) {
|
|
11054
|
+
try {
|
|
11055
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
11056
|
+
} catch (error) {
|
|
11057
|
+
promise = Promise.reject(error);
|
|
11058
|
+
}
|
|
9647
11059
|
}
|
|
9648
11060
|
|
|
9649
11061
|
i = 0;
|
|
@@ -9666,7 +11078,7 @@ class Axios {
|
|
|
9666
11078
|
// Provide aliases for supported request methods
|
|
9667
11079
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
9668
11080
|
/*eslint func-names:0*/
|
|
9669
|
-
Axios.prototype[method] = function (url, config) {
|
|
11081
|
+
Axios.prototype[method] = async function (url, config) {
|
|
9670
11082
|
return this.request(
|
|
9671
11083
|
mergeConfig(config || {}, {
|
|
9672
11084
|
method,
|
|
@@ -9679,7 +11091,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
9679
11091
|
|
|
9680
11092
|
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
9681
11093
|
function generateHTTPMethod(isForm) {
|
|
9682
|
-
return function httpMethod(url, data, config) {
|
|
11094
|
+
return async function httpMethod(url, data, config) {
|
|
9683
11095
|
return this.request(
|
|
9684
11096
|
mergeConfig(config || {}, {
|
|
9685
11097
|
method,
|
|
@@ -9909,14 +11321,22 @@ const HttpStatusCode = {
|
|
|
9909
11321
|
Gone: 410,
|
|
9910
11322
|
LengthRequired: 411,
|
|
9911
11323
|
PreconditionFailed: 412,
|
|
11324
|
+
/**
|
|
11325
|
+
* @deprecated Use `ContentTooLarge` instead.
|
|
11326
|
+
*/
|
|
9912
11327
|
PayloadTooLarge: 413,
|
|
11328
|
+
ContentTooLarge: 413,
|
|
9913
11329
|
UriTooLong: 414,
|
|
9914
11330
|
UnsupportedMediaType: 415,
|
|
9915
11331
|
RangeNotSatisfiable: 416,
|
|
9916
11332
|
ExpectationFailed: 417,
|
|
9917
11333
|
ImATeapot: 418,
|
|
9918
11334
|
MisdirectedRequest: 421,
|
|
11335
|
+
/**
|
|
11336
|
+
* @deprecated Use `UnprocessableContent` instead.
|
|
11337
|
+
*/
|
|
9919
11338
|
UnprocessableEntity: 422,
|
|
11339
|
+
UnprocessableContent: 422,
|
|
9920
11340
|
Locked: 423,
|
|
9921
11341
|
FailedDependency: 424,
|
|
9922
11342
|
TooEarly: 425,
|
|
@@ -9936,6 +11356,7 @@ const HttpStatusCode = {
|
|
|
9936
11356
|
LoopDetected: 508,
|
|
9937
11357
|
NotExtended: 510,
|
|
9938
11358
|
NetworkAuthenticationRequired: 511,
|
|
11359
|
+
WebServerReturnsAnUnknownError: 520,
|
|
9939
11360
|
WebServerIsDown: 521,
|
|
9940
11361
|
ConnectionTimedOut: 522,
|
|
9941
11362
|
OriginIsUnreachable: 523,
|
|
@@ -9945,7 +11366,9 @@ const HttpStatusCode = {
|
|
|
9945
11366
|
};
|
|
9946
11367
|
|
|
9947
11368
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
9948
|
-
HttpStatusCode[value]
|
|
11369
|
+
if (HttpStatusCode[value] === undefined) {
|
|
11370
|
+
HttpStatusCode[value] = key;
|
|
11371
|
+
}
|
|
9949
11372
|
});
|
|
9950
11373
|
|
|
9951
11374
|
/**
|
|
@@ -10016,7 +11439,6 @@ axios.HttpStatusCode = HttpStatusCode;
|
|
|
10016
11439
|
axios.default = axios;
|
|
10017
11440
|
|
|
10018
11441
|
module.exports = axios;
|
|
10019
|
-
//# sourceMappingURL=axios.cjs.map
|
|
10020
11442
|
|
|
10021
11443
|
|
|
10022
11444
|
/***/ }),
|
|
@@ -10530,7 +11952,8 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
10530
11952
|
_options$collectionSp4,
|
|
10531
11953
|
_options$union,
|
|
10532
11954
|
_options$useOverrideT,
|
|
10533
|
-
_options$flipNegative
|
|
11955
|
+
_options$flipNegative,
|
|
11956
|
+
_options$interpretNeg;
|
|
10534
11957
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10535
11958
|
(0,_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__["default"])(this, Configuration);
|
|
10536
11959
|
this.server = options.server || {
|
|
@@ -10577,6 +12000,7 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
10577
12000
|
// flips negative refinement encoding between AND/OR groups
|
|
10578
12001
|
// AND groups become field:![a,b], OR groups become field:!a || field:!b
|
|
10579
12002
|
this.flipNegativeRefinementOperator = (_options$flipNegative = options.flipNegativeRefinementOperator) !== null && _options$flipNegative !== void 0 ? _options$flipNegative : false;
|
|
12003
|
+
this.interpretNegativeNumericFacetFiltersAsExclusions = (_options$interpretNeg = options.interpretNegativeNumericFacetFiltersAsExclusions) !== null && _options$interpretNeg !== void 0 ? _options$interpretNeg : false;
|
|
10580
12004
|
}
|
|
10581
12005
|
return (0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(Configuration, [{
|
|
10582
12006
|
key: "validate",
|
|
@@ -10771,7 +12195,7 @@ var SearchRequestAdapter = /*#__PURE__*/function () {
|
|
|
10771
12195
|
|
|
10772
12196
|
// Partition values into included and excluded values
|
|
10773
12197
|
var _fieldValues$reduce = fieldValues.reduce(function (result, fieldValue) {
|
|
10774
|
-
if (
|
|
12198
|
+
if (_this._isExcludedFacetValue(fieldValue)) {
|
|
10775
12199
|
result[0].push(fieldValue.substring(1));
|
|
10776
12200
|
} else {
|
|
10777
12201
|
result[1].push(fieldValue);
|
|
@@ -10814,7 +12238,7 @@ var SearchRequestAdapter = /*#__PURE__*/function () {
|
|
|
10814
12238
|
_fieldName = _this$_parseFacetFilt2.fieldName,
|
|
10815
12239
|
fieldValue = _this$_parseFacetFilt2.fieldValue;
|
|
10816
12240
|
var _typesenseFilterString;
|
|
10817
|
-
if (
|
|
12241
|
+
if (_this._isExcludedFacetValue(fieldValue)) {
|
|
10818
12242
|
var _operator2 = _this._shouldUseExactMatchForField(_fieldName, collectionName) ? ":!=" : ":!";
|
|
10819
12243
|
_typesenseFilterString = "".concat(_fieldName).concat(_operator2, "[").concat(_this._escapeFacetValue(fieldValue.substring(1)), "]");
|
|
10820
12244
|
} else {
|
|
@@ -10874,9 +12298,20 @@ var SearchRequestAdapter = /*#__PURE__*/function () {
|
|
|
10874
12298
|
fieldValue: fieldValue
|
|
10875
12299
|
};
|
|
10876
12300
|
}
|
|
12301
|
+
|
|
12302
|
+
// Algolia reads "-5" as "not 5", but sites that hand-write "-5" in URLs or initialUiState mean the number -5.
|
|
12303
|
+
}, {
|
|
12304
|
+
key: "_isExcludedFacetValue",
|
|
12305
|
+
value: function _isExcludedFacetValue(fieldValue) {
|
|
12306
|
+
return fieldValue.startsWith("-") && (this.configuration.interpretNegativeNumericFacetFiltersAsExclusions || !this._isNumber(fieldValue));
|
|
12307
|
+
}
|
|
10877
12308
|
}, {
|
|
10878
12309
|
key: "_escapeFacetValue",
|
|
10879
12310
|
value: function _escapeFacetValue(value) {
|
|
12311
|
+
// "\-" is InstantSearch's escape for a value that really starts with "-"
|
|
12312
|
+
if (typeof value === "string" && value.startsWith("\\-")) {
|
|
12313
|
+
value = value.substring(1);
|
|
12314
|
+
}
|
|
10880
12315
|
// Don't escape booleans, integers or floats
|
|
10881
12316
|
if (typeof value === "boolean" || value === "true" || value === "false" || this._isNumber(value)) {
|
|
10882
12317
|
return value;
|