@passkeyme/auth 2.0.10 → 2.0.11
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 -2
- package/dist/index.esm.js +413 -267
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +413 -267
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +413 -267
- package/dist/index.umd.js.map +1 -1
- package/dist/src/passkeyme-auth.d.ts.map +1 -1
- package/dist/src/types.d.ts +5 -5
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -826,7 +826,7 @@ class PasskeymeAuth {
|
|
|
826
826
|
const defaultRedirectUri = typeof window !== "undefined" && window.location && window.location.origin
|
|
827
827
|
? `${window.location.origin}/auth/callback`
|
|
828
828
|
: "http://localhost:3000/auth/callback";
|
|
829
|
-
//
|
|
829
|
+
// Base URL for hosted auth UI pages - defaults to auth.passkeyme.com
|
|
830
830
|
const serverUrl = config.baseUrl || "https://auth.passkeyme.com";
|
|
831
831
|
console.log("[DEBUG] serverUrl determined as:", serverUrl);
|
|
832
832
|
this.config = {
|
|
@@ -1017,11 +1017,15 @@ class PasskeymeAuth {
|
|
|
1017
1017
|
*/
|
|
1018
1018
|
redirectToOAuth(provider, redirectUri) {
|
|
1019
1019
|
const finalRedirectUri = redirectUri || this.config.redirectUri;
|
|
1020
|
-
// Build direct OAuth initiation URL
|
|
1020
|
+
// Build direct OAuth initiation URL - use apiUrl for backend API endpoints
|
|
1021
|
+
const apiBaseUrl = this.config.apiUrl ||
|
|
1022
|
+
(typeof window !== "undefined" && window.location.hostname !== "localhost"
|
|
1023
|
+
? "https://api.passkeyme.com"
|
|
1024
|
+
: "http://localhost:8000");
|
|
1021
1025
|
const params = new URLSearchParams({
|
|
1022
1026
|
redirect_uri: finalRedirectUri,
|
|
1023
1027
|
});
|
|
1024
|
-
const oauthUrl = `${
|
|
1028
|
+
const oauthUrl = `${apiBaseUrl}/auth/${this.config.appId}/oauth/${provider}/start?${params.toString()}`;
|
|
1025
1029
|
logger.debug("Redirecting directly to OAuth provider:", provider, oauthUrl);
|
|
1026
1030
|
this.performRedirect(oauthUrl, finalRedirectUri);
|
|
1027
1031
|
}
|
|
@@ -1831,6 +1835,13 @@ function createAuth(config) {
|
|
|
1831
1835
|
return new PasskeymeAuth(config);
|
|
1832
1836
|
}
|
|
1833
1837
|
|
|
1838
|
+
/**
|
|
1839
|
+
* Create a bound version of a function with a specified `this` context
|
|
1840
|
+
*
|
|
1841
|
+
* @param {Function} fn - The function to bind
|
|
1842
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
1843
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
1844
|
+
*/
|
|
1834
1845
|
function bind(fn, thisArg) {
|
|
1835
1846
|
return function wrap() {
|
|
1836
1847
|
return fn.apply(thisArg, arguments);
|
|
@@ -1882,7 +1893,7 @@ const isUndefined = typeOfTest('undefined');
|
|
|
1882
1893
|
*/
|
|
1883
1894
|
function isBuffer(val) {
|
|
1884
1895
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
1885
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
1896
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
1886
1897
|
}
|
|
1887
1898
|
|
|
1888
1899
|
/**
|
|
@@ -1927,7 +1938,7 @@ const isString = typeOfTest('string');
|
|
|
1927
1938
|
* @param {*} val The value to test
|
|
1928
1939
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
1929
1940
|
*/
|
|
1930
|
-
const isFunction = typeOfTest('function');
|
|
1941
|
+
const isFunction$1 = typeOfTest('function');
|
|
1931
1942
|
|
|
1932
1943
|
/**
|
|
1933
1944
|
* Determine if a value is a Number
|
|
@@ -1983,7 +1994,7 @@ const isEmptyObject = (val) => {
|
|
|
1983
1994
|
if (!isObject(val) || isBuffer(val)) {
|
|
1984
1995
|
return false;
|
|
1985
1996
|
}
|
|
1986
|
-
|
|
1997
|
+
|
|
1987
1998
|
try {
|
|
1988
1999
|
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
1989
2000
|
} catch (e) {
|
|
@@ -2035,7 +2046,7 @@ const isFileList = kindOfTest('FileList');
|
|
|
2035
2046
|
*
|
|
2036
2047
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
2037
2048
|
*/
|
|
2038
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
2049
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
2039
2050
|
|
|
2040
2051
|
/**
|
|
2041
2052
|
* Determine if a value is a FormData
|
|
@@ -2048,10 +2059,10 @@ const isFormData = (thing) => {
|
|
|
2048
2059
|
let kind;
|
|
2049
2060
|
return thing && (
|
|
2050
2061
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
2051
|
-
isFunction(thing.append) && (
|
|
2062
|
+
isFunction$1(thing.append) && (
|
|
2052
2063
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
2053
2064
|
// detect form-data instance
|
|
2054
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
2065
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
2055
2066
|
)
|
|
2056
2067
|
)
|
|
2057
2068
|
)
|
|
@@ -2176,7 +2187,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
2176
2187
|
* @returns {Object} Result of all merge properties
|
|
2177
2188
|
*/
|
|
2178
2189
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
2179
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
2190
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
2180
2191
|
const result = {};
|
|
2181
2192
|
const assignValue = (val, key) => {
|
|
2182
2193
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -2186,7 +2197,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
2186
2197
|
result[targetKey] = merge({}, val);
|
|
2187
2198
|
} else if (isArray(val)) {
|
|
2188
2199
|
result[targetKey] = val.slice();
|
|
2189
|
-
} else {
|
|
2200
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
2190
2201
|
result[targetKey] = val;
|
|
2191
2202
|
}
|
|
2192
2203
|
};
|
|
@@ -2209,7 +2220,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
2209
2220
|
*/
|
|
2210
2221
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
2211
2222
|
forEach(b, (val, key) => {
|
|
2212
|
-
if (thisArg && isFunction(val)) {
|
|
2223
|
+
if (thisArg && isFunction$1(val)) {
|
|
2213
2224
|
a[key] = bind(val, thisArg);
|
|
2214
2225
|
} else {
|
|
2215
2226
|
a[key] = val;
|
|
@@ -2425,13 +2436,13 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
2425
2436
|
const freezeMethods = (obj) => {
|
|
2426
2437
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
2427
2438
|
// skip restricted props in strict mode
|
|
2428
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
2439
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
2429
2440
|
return false;
|
|
2430
2441
|
}
|
|
2431
2442
|
|
|
2432
2443
|
const value = obj[name];
|
|
2433
2444
|
|
|
2434
|
-
if (!isFunction(value)) return;
|
|
2445
|
+
if (!isFunction$1(value)) return;
|
|
2435
2446
|
|
|
2436
2447
|
descriptor.enumerable = false;
|
|
2437
2448
|
|
|
@@ -2468,6 +2479,8 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
2468
2479
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
2469
2480
|
};
|
|
2470
2481
|
|
|
2482
|
+
|
|
2483
|
+
|
|
2471
2484
|
/**
|
|
2472
2485
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
2473
2486
|
*
|
|
@@ -2476,7 +2489,7 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
2476
2489
|
* @returns {boolean}
|
|
2477
2490
|
*/
|
|
2478
2491
|
function isSpecCompliantForm(thing) {
|
|
2479
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
2492
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
2480
2493
|
}
|
|
2481
2494
|
|
|
2482
2495
|
const toJSONObject = (obj) => {
|
|
@@ -2518,7 +2531,7 @@ const toJSONObject = (obj) => {
|
|
|
2518
2531
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
2519
2532
|
|
|
2520
2533
|
const isThenable = (thing) =>
|
|
2521
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
2534
|
+
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
2522
2535
|
|
|
2523
2536
|
// original code
|
|
2524
2537
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -2542,7 +2555,7 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
2542
2555
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
2543
2556
|
})(
|
|
2544
2557
|
typeof setImmediate === 'function',
|
|
2545
|
-
isFunction(_global.postMessage)
|
|
2558
|
+
isFunction$1(_global.postMessage)
|
|
2546
2559
|
);
|
|
2547
2560
|
|
|
2548
2561
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -2551,7 +2564,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
2551
2564
|
// *********************
|
|
2552
2565
|
|
|
2553
2566
|
|
|
2554
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
2567
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
2555
2568
|
|
|
2556
2569
|
|
|
2557
2570
|
var utils$1 = {
|
|
@@ -2575,7 +2588,7 @@ var utils$1 = {
|
|
|
2575
2588
|
isFile,
|
|
2576
2589
|
isBlob,
|
|
2577
2590
|
isRegExp,
|
|
2578
|
-
isFunction,
|
|
2591
|
+
isFunction: isFunction$1,
|
|
2579
2592
|
isStream,
|
|
2580
2593
|
isURLSearchParams,
|
|
2581
2594
|
isTypedArray,
|
|
@@ -2701,11 +2714,18 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
|
2701
2714
|
return prop !== 'isAxiosError';
|
|
2702
2715
|
});
|
|
2703
2716
|
|
|
2704
|
-
|
|
2717
|
+
const msg = error && error.message ? error.message : 'Error';
|
|
2705
2718
|
|
|
2706
|
-
|
|
2719
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
2720
|
+
const errCode = code == null && error ? error.code : code;
|
|
2721
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
2707
2722
|
|
|
2708
|
-
|
|
2723
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
2724
|
+
if (error && axiosError.cause == null) {
|
|
2725
|
+
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
axiosError.name = (error && error.name) || 'Error';
|
|
2709
2729
|
|
|
2710
2730
|
customProps && Object.assign(axiosError, customProps);
|
|
2711
2731
|
|
|
@@ -2996,9 +3016,7 @@ function encode(val) {
|
|
|
2996
3016
|
replace(/%3A/gi, ':').
|
|
2997
3017
|
replace(/%24/g, '$').
|
|
2998
3018
|
replace(/%2C/gi, ',').
|
|
2999
|
-
replace(/%20/g, '+')
|
|
3000
|
-
replace(/%5B/gi, '[').
|
|
3001
|
-
replace(/%5D/gi, ']');
|
|
3019
|
+
replace(/%20/g, '+');
|
|
3002
3020
|
}
|
|
3003
3021
|
|
|
3004
3022
|
/**
|
|
@@ -3076,7 +3094,7 @@ class InterceptorManager {
|
|
|
3076
3094
|
*
|
|
3077
3095
|
* @param {Number} id The ID that was returned by `use`
|
|
3078
3096
|
*
|
|
3079
|
-
* @returns {
|
|
3097
|
+
* @returns {void}
|
|
3080
3098
|
*/
|
|
3081
3099
|
eject(id) {
|
|
3082
3100
|
if (this.handlers[id]) {
|
|
@@ -3403,7 +3421,7 @@ const defaults = {
|
|
|
3403
3421
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
3404
3422
|
|
|
3405
3423
|
try {
|
|
3406
|
-
return JSON.parse(data);
|
|
3424
|
+
return JSON.parse(data, this.parseReviver);
|
|
3407
3425
|
} catch (e) {
|
|
3408
3426
|
if (strictJSONParsing) {
|
|
3409
3427
|
if (e.name === 'SyntaxError') {
|
|
@@ -4042,27 +4060,38 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
4042
4060
|
|
|
4043
4061
|
// Standard browser envs support document.cookie
|
|
4044
4062
|
{
|
|
4045
|
-
write(name, value, expires, path, domain, secure) {
|
|
4046
|
-
|
|
4063
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
4064
|
+
if (typeof document === 'undefined') return;
|
|
4047
4065
|
|
|
4048
|
-
|
|
4066
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
4049
4067
|
|
|
4050
|
-
utils$1.
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4068
|
+
if (utils$1.isNumber(expires)) {
|
|
4069
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
4070
|
+
}
|
|
4071
|
+
if (utils$1.isString(path)) {
|
|
4072
|
+
cookie.push(`path=${path}`);
|
|
4073
|
+
}
|
|
4074
|
+
if (utils$1.isString(domain)) {
|
|
4075
|
+
cookie.push(`domain=${domain}`);
|
|
4076
|
+
}
|
|
4077
|
+
if (secure === true) {
|
|
4078
|
+
cookie.push('secure');
|
|
4079
|
+
}
|
|
4080
|
+
if (utils$1.isString(sameSite)) {
|
|
4081
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
4082
|
+
}
|
|
4055
4083
|
|
|
4056
4084
|
document.cookie = cookie.join('; ');
|
|
4057
4085
|
},
|
|
4058
4086
|
|
|
4059
4087
|
read(name) {
|
|
4060
|
-
|
|
4061
|
-
|
|
4088
|
+
if (typeof document === 'undefined') return null;
|
|
4089
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
4090
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
4062
4091
|
},
|
|
4063
4092
|
|
|
4064
4093
|
remove(name) {
|
|
4065
|
-
this.write(name, '', Date.now() - 86400000);
|
|
4094
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
4066
4095
|
}
|
|
4067
4096
|
}
|
|
4068
4097
|
|
|
@@ -4151,11 +4180,11 @@ function mergeConfig(config1, config2) {
|
|
|
4151
4180
|
}
|
|
4152
4181
|
|
|
4153
4182
|
// eslint-disable-next-line consistent-return
|
|
4154
|
-
function mergeDeepProperties(a, b, prop
|
|
4183
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
4155
4184
|
if (!utils$1.isUndefined(b)) {
|
|
4156
|
-
return getMergedValue(a, b, prop
|
|
4185
|
+
return getMergedValue(a, b, prop, caseless);
|
|
4157
4186
|
} else if (!utils$1.isUndefined(a)) {
|
|
4158
|
-
return getMergedValue(undefined, a, prop
|
|
4187
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
4159
4188
|
}
|
|
4160
4189
|
}
|
|
4161
4190
|
|
|
@@ -4213,7 +4242,7 @@ function mergeConfig(config1, config2) {
|
|
|
4213
4242
|
socketPath: defaultToConfig2,
|
|
4214
4243
|
responseEncoding: defaultToConfig2,
|
|
4215
4244
|
validateStatus: mergeDirectKeys,
|
|
4216
|
-
headers: (a, b
|
|
4245
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
4217
4246
|
};
|
|
4218
4247
|
|
|
4219
4248
|
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
@@ -4228,7 +4257,7 @@ function mergeConfig(config1, config2) {
|
|
|
4228
4257
|
var resolveConfig = (config) => {
|
|
4229
4258
|
const newConfig = mergeConfig({}, config);
|
|
4230
4259
|
|
|
4231
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
4260
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
4232
4261
|
|
|
4233
4262
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
4234
4263
|
|
|
@@ -4241,17 +4270,21 @@ var resolveConfig = (config) => {
|
|
|
4241
4270
|
);
|
|
4242
4271
|
}
|
|
4243
4272
|
|
|
4244
|
-
let contentType;
|
|
4245
|
-
|
|
4246
4273
|
if (utils$1.isFormData(data)) {
|
|
4247
4274
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
4248
|
-
headers.setContentType(undefined); //
|
|
4249
|
-
} else if ((
|
|
4250
|
-
//
|
|
4251
|
-
const
|
|
4252
|
-
headers
|
|
4275
|
+
headers.setContentType(undefined); // browser handles it
|
|
4276
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
4277
|
+
// Node.js FormData (like form-data package)
|
|
4278
|
+
const formHeaders = data.getHeaders();
|
|
4279
|
+
// Only set safe headers to avoid overwriting security headers
|
|
4280
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
4281
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
4282
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
4283
|
+
headers.set(key, val);
|
|
4284
|
+
}
|
|
4285
|
+
});
|
|
4253
4286
|
}
|
|
4254
|
-
}
|
|
4287
|
+
}
|
|
4255
4288
|
|
|
4256
4289
|
// Add xsrf header
|
|
4257
4290
|
// This is only done if running in a standard browser environment.
|
|
@@ -4368,15 +4401,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4368
4401
|
};
|
|
4369
4402
|
|
|
4370
4403
|
// Handle low level network errors
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4404
|
+
request.onerror = function handleError(event) {
|
|
4405
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
4406
|
+
// (message may be empty; when present, surface it)
|
|
4407
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
4408
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
4409
|
+
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
4410
|
+
// attach the underlying event for consumers who want details
|
|
4411
|
+
err.event = event || null;
|
|
4412
|
+
reject(err);
|
|
4413
|
+
request = null;
|
|
4378
4414
|
};
|
|
4379
|
-
|
|
4415
|
+
|
|
4380
4416
|
// Handle timeout
|
|
4381
4417
|
request.ontimeout = function handleTimeout() {
|
|
4382
4418
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -4592,14 +4628,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
4592
4628
|
})
|
|
4593
4629
|
};
|
|
4594
4630
|
|
|
4595
|
-
const
|
|
4596
|
-
|
|
4631
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4632
|
+
|
|
4633
|
+
const {isFunction} = utils$1;
|
|
4634
|
+
|
|
4635
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
4636
|
+
Request, Response
|
|
4637
|
+
}))(utils$1.global);
|
|
4638
|
+
|
|
4639
|
+
const {
|
|
4640
|
+
ReadableStream: ReadableStream$1, TextEncoder
|
|
4641
|
+
} = utils$1.global;
|
|
4597
4642
|
|
|
4598
|
-
// used only inside the fetch adapter
|
|
4599
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
4600
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
4601
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
4602
|
-
);
|
|
4603
4643
|
|
|
4604
4644
|
const test = (fn, ...args) => {
|
|
4605
4645
|
try {
|
|
@@ -4609,278 +4649,380 @@ const test = (fn, ...args) => {
|
|
|
4609
4649
|
}
|
|
4610
4650
|
};
|
|
4611
4651
|
|
|
4612
|
-
const
|
|
4613
|
-
|
|
4652
|
+
const factory = (env) => {
|
|
4653
|
+
env = utils$1.merge.call({
|
|
4654
|
+
skipUndefined: true
|
|
4655
|
+
}, globalFetchAPI, env);
|
|
4614
4656
|
|
|
4615
|
-
const
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
duplexAccessed = true;
|
|
4620
|
-
return 'half';
|
|
4621
|
-
},
|
|
4622
|
-
}).headers.has('Content-Type');
|
|
4657
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
4658
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
4659
|
+
const isRequestSupported = isFunction(Request);
|
|
4660
|
+
const isResponseSupported = isFunction(Response);
|
|
4623
4661
|
|
|
4624
|
-
|
|
4625
|
-
|
|
4662
|
+
if (!isFetchSupported) {
|
|
4663
|
+
return false;
|
|
4664
|
+
}
|
|
4626
4665
|
|
|
4627
|
-
const
|
|
4666
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
4628
4667
|
|
|
4629
|
-
const
|
|
4630
|
-
|
|
4668
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
4669
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
4670
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
4671
|
+
);
|
|
4631
4672
|
|
|
4673
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
4674
|
+
let duplexAccessed = false;
|
|
4632
4675
|
|
|
4633
|
-
const
|
|
4634
|
-
|
|
4635
|
-
|
|
4676
|
+
const hasContentType = new Request(platform.origin, {
|
|
4677
|
+
body: new ReadableStream$1(),
|
|
4678
|
+
method: 'POST',
|
|
4679
|
+
get duplex() {
|
|
4680
|
+
duplexAccessed = true;
|
|
4681
|
+
return 'half';
|
|
4682
|
+
},
|
|
4683
|
+
}).headers.has('Content-Type');
|
|
4636
4684
|
|
|
4637
|
-
|
|
4638
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
4639
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
4640
|
-
(_, config) => {
|
|
4641
|
-
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
4642
|
-
});
|
|
4685
|
+
return duplexAccessed && !hasContentType;
|
|
4643
4686
|
});
|
|
4644
|
-
})(new Response));
|
|
4645
4687
|
|
|
4646
|
-
const
|
|
4647
|
-
|
|
4648
|
-
return 0;
|
|
4649
|
-
}
|
|
4688
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
4689
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
4650
4690
|
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
}
|
|
4691
|
+
const resolvers = {
|
|
4692
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
4693
|
+
};
|
|
4654
4694
|
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4695
|
+
isFetchSupported && ((() => {
|
|
4696
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
4697
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
4698
|
+
let method = res && res[type];
|
|
4699
|
+
|
|
4700
|
+
if (method) {
|
|
4701
|
+
return method.call(res);
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4704
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
4705
|
+
});
|
|
4659
4706
|
});
|
|
4660
|
-
|
|
4661
|
-
}
|
|
4707
|
+
})());
|
|
4662
4708
|
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4709
|
+
const getBodyLength = async (body) => {
|
|
4710
|
+
if (body == null) {
|
|
4711
|
+
return 0;
|
|
4712
|
+
}
|
|
4666
4713
|
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4714
|
+
if (utils$1.isBlob(body)) {
|
|
4715
|
+
return body.size;
|
|
4716
|
+
}
|
|
4670
4717
|
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4718
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
4719
|
+
const _request = new Request(platform.origin, {
|
|
4720
|
+
method: 'POST',
|
|
4721
|
+
body,
|
|
4722
|
+
});
|
|
4723
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
4724
|
+
}
|
|
4675
4725
|
|
|
4676
|
-
|
|
4677
|
-
|
|
4726
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
4727
|
+
return body.byteLength;
|
|
4728
|
+
}
|
|
4678
4729
|
|
|
4679
|
-
|
|
4680
|
-
|
|
4730
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
4731
|
+
body = body + '';
|
|
4732
|
+
}
|
|
4733
|
+
|
|
4734
|
+
if (utils$1.isString(body)) {
|
|
4735
|
+
return (await encodeText(body)).byteLength;
|
|
4736
|
+
}
|
|
4737
|
+
};
|
|
4738
|
+
|
|
4739
|
+
const resolveBodyLength = async (headers, body) => {
|
|
4740
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
4741
|
+
|
|
4742
|
+
return length == null ? getBodyLength(body) : length;
|
|
4743
|
+
};
|
|
4744
|
+
|
|
4745
|
+
return async (config) => {
|
|
4746
|
+
let {
|
|
4747
|
+
url,
|
|
4748
|
+
method,
|
|
4749
|
+
data,
|
|
4750
|
+
signal,
|
|
4751
|
+
cancelToken,
|
|
4752
|
+
timeout,
|
|
4753
|
+
onDownloadProgress,
|
|
4754
|
+
onUploadProgress,
|
|
4755
|
+
responseType,
|
|
4756
|
+
headers,
|
|
4757
|
+
withCredentials = 'same-origin',
|
|
4758
|
+
fetchOptions
|
|
4759
|
+
} = resolveConfig(config);
|
|
4760
|
+
|
|
4761
|
+
let _fetch = envFetch || fetch;
|
|
4681
4762
|
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
timeout,
|
|
4690
|
-
onDownloadProgress,
|
|
4691
|
-
onUploadProgress,
|
|
4692
|
-
responseType,
|
|
4693
|
-
headers,
|
|
4694
|
-
withCredentials = 'same-origin',
|
|
4695
|
-
fetchOptions
|
|
4696
|
-
} = resolveConfig(config);
|
|
4697
|
-
|
|
4698
|
-
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4699
|
-
|
|
4700
|
-
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
4701
|
-
|
|
4702
|
-
let request;
|
|
4703
|
-
|
|
4704
|
-
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
4763
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4764
|
+
|
|
4765
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
4766
|
+
|
|
4767
|
+
let request = null;
|
|
4768
|
+
|
|
4769
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
4705
4770
|
composedSignal.unsubscribe();
|
|
4706
|
-
|
|
4771
|
+
});
|
|
4707
4772
|
|
|
4708
|
-
|
|
4773
|
+
let requestContentLength;
|
|
4709
4774
|
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4775
|
+
try {
|
|
4776
|
+
if (
|
|
4777
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
4778
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
4779
|
+
) {
|
|
4780
|
+
let _request = new Request(url, {
|
|
4781
|
+
method: 'POST',
|
|
4782
|
+
body: data,
|
|
4783
|
+
duplex: "half"
|
|
4784
|
+
});
|
|
4720
4785
|
|
|
4721
|
-
|
|
4786
|
+
let contentTypeHeader;
|
|
4722
4787
|
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4788
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4789
|
+
headers.setContentType(contentTypeHeader);
|
|
4790
|
+
}
|
|
4726
4791
|
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4792
|
+
if (_request.body) {
|
|
4793
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
4794
|
+
requestContentLength,
|
|
4795
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4796
|
+
);
|
|
4732
4797
|
|
|
4733
|
-
|
|
4798
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
4799
|
+
}
|
|
4734
4800
|
}
|
|
4735
|
-
}
|
|
4736
4801
|
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4802
|
+
if (!utils$1.isString(withCredentials)) {
|
|
4803
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
4804
|
+
}
|
|
4740
4805
|
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
request = new Request(url, {
|
|
4745
|
-
...fetchOptions,
|
|
4746
|
-
signal: composedSignal,
|
|
4747
|
-
method: method.toUpperCase(),
|
|
4748
|
-
headers: headers.normalize().toJSON(),
|
|
4749
|
-
body: data,
|
|
4750
|
-
duplex: "half",
|
|
4751
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4752
|
-
});
|
|
4806
|
+
// Cloudflare Workers throws when credentials are defined
|
|
4807
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
4808
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
4753
4809
|
|
|
4754
|
-
|
|
4810
|
+
const resolvedOptions = {
|
|
4811
|
+
...fetchOptions,
|
|
4812
|
+
signal: composedSignal,
|
|
4813
|
+
method: method.toUpperCase(),
|
|
4814
|
+
headers: headers.normalize().toJSON(),
|
|
4815
|
+
body: data,
|
|
4816
|
+
duplex: "half",
|
|
4817
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4818
|
+
};
|
|
4755
4819
|
|
|
4756
|
-
|
|
4820
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
4757
4821
|
|
|
4758
|
-
|
|
4759
|
-
const options = {};
|
|
4822
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
4760
4823
|
|
|
4761
|
-
|
|
4762
|
-
options[prop] = response[prop];
|
|
4763
|
-
});
|
|
4824
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4764
4825
|
|
|
4765
|
-
|
|
4826
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
4827
|
+
const options = {};
|
|
4766
4828
|
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
) || [];
|
|
4829
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
4830
|
+
options[prop] = response[prop];
|
|
4831
|
+
});
|
|
4771
4832
|
|
|
4772
|
-
|
|
4773
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4774
|
-
flush && flush();
|
|
4775
|
-
unsubscribe && unsubscribe();
|
|
4776
|
-
}),
|
|
4777
|
-
options
|
|
4778
|
-
);
|
|
4779
|
-
}
|
|
4833
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4780
4834
|
|
|
4781
|
-
|
|
4835
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
4836
|
+
responseContentLength,
|
|
4837
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
4838
|
+
) || [];
|
|
4782
4839
|
|
|
4783
|
-
|
|
4840
|
+
response = new Response(
|
|
4841
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4842
|
+
flush && flush();
|
|
4843
|
+
unsubscribe && unsubscribe();
|
|
4844
|
+
}),
|
|
4845
|
+
options
|
|
4846
|
+
);
|
|
4847
|
+
}
|
|
4784
4848
|
|
|
4785
|
-
|
|
4849
|
+
responseType = responseType || 'text';
|
|
4786
4850
|
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4851
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
4852
|
+
|
|
4853
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4854
|
+
|
|
4855
|
+
return await new Promise((resolve, reject) => {
|
|
4856
|
+
settle(resolve, reject, {
|
|
4857
|
+
data: responseData,
|
|
4858
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
4859
|
+
status: response.status,
|
|
4860
|
+
statusText: response.statusText,
|
|
4861
|
+
config,
|
|
4862
|
+
request
|
|
4863
|
+
});
|
|
4864
|
+
})
|
|
4865
|
+
} catch (err) {
|
|
4866
|
+
unsubscribe && unsubscribe();
|
|
4867
|
+
|
|
4868
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4869
|
+
throw Object.assign(
|
|
4870
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
4871
|
+
{
|
|
4872
|
+
cause: err.cause || err
|
|
4873
|
+
}
|
|
4874
|
+
)
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4877
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
4807
4878
|
}
|
|
4879
|
+
}
|
|
4880
|
+
};
|
|
4881
|
+
|
|
4882
|
+
const seedCache = new Map();
|
|
4883
|
+
|
|
4884
|
+
const getFetch = (config) => {
|
|
4885
|
+
let env = (config && config.env) || {};
|
|
4886
|
+
const {fetch, Request, Response} = env;
|
|
4887
|
+
const seeds = [
|
|
4888
|
+
Request, Response, fetch
|
|
4889
|
+
];
|
|
4890
|
+
|
|
4891
|
+
let len = seeds.length, i = len,
|
|
4892
|
+
seed, target, map = seedCache;
|
|
4893
|
+
|
|
4894
|
+
while (i--) {
|
|
4895
|
+
seed = seeds[i];
|
|
4896
|
+
target = map.get(seed);
|
|
4897
|
+
|
|
4898
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
4808
4899
|
|
|
4809
|
-
|
|
4900
|
+
map = target;
|
|
4810
4901
|
}
|
|
4811
|
-
});
|
|
4812
4902
|
|
|
4903
|
+
return target;
|
|
4904
|
+
};
|
|
4905
|
+
|
|
4906
|
+
getFetch();
|
|
4907
|
+
|
|
4908
|
+
/**
|
|
4909
|
+
* Known adapters mapping.
|
|
4910
|
+
* Provides environment-specific adapters for Axios:
|
|
4911
|
+
* - `http` for Node.js
|
|
4912
|
+
* - `xhr` for browsers
|
|
4913
|
+
* - `fetch` for fetch API-based requests
|
|
4914
|
+
*
|
|
4915
|
+
* @type {Object<string, Function|Object>}
|
|
4916
|
+
*/
|
|
4813
4917
|
const knownAdapters = {
|
|
4814
4918
|
http: httpAdapter,
|
|
4815
4919
|
xhr: xhrAdapter,
|
|
4816
|
-
fetch:
|
|
4920
|
+
fetch: {
|
|
4921
|
+
get: getFetch,
|
|
4922
|
+
}
|
|
4817
4923
|
};
|
|
4818
4924
|
|
|
4925
|
+
// Assign adapter names for easier debugging and identification
|
|
4819
4926
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
4820
4927
|
if (fn) {
|
|
4821
4928
|
try {
|
|
4822
|
-
Object.defineProperty(fn, 'name', {value});
|
|
4929
|
+
Object.defineProperty(fn, 'name', { value });
|
|
4823
4930
|
} catch (e) {
|
|
4824
4931
|
// eslint-disable-next-line no-empty
|
|
4825
4932
|
}
|
|
4826
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
4933
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
4827
4934
|
}
|
|
4828
4935
|
});
|
|
4829
4936
|
|
|
4937
|
+
/**
|
|
4938
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
4939
|
+
*
|
|
4940
|
+
* @param {string} reason
|
|
4941
|
+
* @returns {string}
|
|
4942
|
+
*/
|
|
4830
4943
|
const renderReason = (reason) => `- ${reason}`;
|
|
4831
4944
|
|
|
4945
|
+
/**
|
|
4946
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
4947
|
+
*
|
|
4948
|
+
* @param {Function|null|false} adapter
|
|
4949
|
+
* @returns {boolean}
|
|
4950
|
+
*/
|
|
4832
4951
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
4833
4952
|
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4953
|
+
/**
|
|
4954
|
+
* Get the first suitable adapter from the provided list.
|
|
4955
|
+
* Tries each adapter in order until a supported one is found.
|
|
4956
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
4957
|
+
*
|
|
4958
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
4959
|
+
* @param {Object} config - Axios request configuration
|
|
4960
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
4961
|
+
* @returns {Function} The resolved adapter function
|
|
4962
|
+
*/
|
|
4963
|
+
function getAdapter(adapters, config) {
|
|
4964
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
4841
4965
|
|
|
4842
|
-
|
|
4966
|
+
const { length } = adapters;
|
|
4967
|
+
let nameOrAdapter;
|
|
4968
|
+
let adapter;
|
|
4843
4969
|
|
|
4844
|
-
|
|
4845
|
-
nameOrAdapter = adapters[i];
|
|
4846
|
-
let id;
|
|
4970
|
+
const rejectedReasons = {};
|
|
4847
4971
|
|
|
4848
|
-
|
|
4972
|
+
for (let i = 0; i < length; i++) {
|
|
4973
|
+
nameOrAdapter = adapters[i];
|
|
4974
|
+
let id;
|
|
4849
4975
|
|
|
4850
|
-
|
|
4851
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
4976
|
+
adapter = nameOrAdapter;
|
|
4852
4977
|
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
}
|
|
4856
|
-
}
|
|
4978
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
4979
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
4857
4980
|
|
|
4858
|
-
if (adapter) {
|
|
4859
|
-
|
|
4981
|
+
if (adapter === undefined) {
|
|
4982
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
4860
4983
|
}
|
|
4984
|
+
}
|
|
4861
4985
|
|
|
4862
|
-
|
|
4986
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
4987
|
+
break;
|
|
4863
4988
|
}
|
|
4864
4989
|
|
|
4865
|
-
|
|
4990
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
4991
|
+
}
|
|
4866
4992
|
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
)
|
|
4993
|
+
if (!adapter) {
|
|
4994
|
+
const reasons = Object.entries(rejectedReasons)
|
|
4995
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
4996
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
4997
|
+
);
|
|
4871
4998
|
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4999
|
+
let s = length ?
|
|
5000
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
5001
|
+
'as no adapter specified';
|
|
4875
5002
|
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
5003
|
+
throw new AxiosError(
|
|
5004
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
5005
|
+
'ERR_NOT_SUPPORT'
|
|
5006
|
+
);
|
|
5007
|
+
}
|
|
4881
5008
|
|
|
4882
|
-
|
|
4883
|
-
|
|
5009
|
+
return adapter;
|
|
5010
|
+
}
|
|
5011
|
+
|
|
5012
|
+
/**
|
|
5013
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
5014
|
+
*/
|
|
5015
|
+
var adapters = {
|
|
5016
|
+
/**
|
|
5017
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
5018
|
+
* @type {Function}
|
|
5019
|
+
*/
|
|
5020
|
+
getAdapter,
|
|
5021
|
+
|
|
5022
|
+
/**
|
|
5023
|
+
* Exposes all known adapters
|
|
5024
|
+
* @type {Object<string, Function|Object>}
|
|
5025
|
+
*/
|
|
4884
5026
|
adapters: knownAdapters
|
|
4885
5027
|
};
|
|
4886
5028
|
|
|
@@ -4923,7 +5065,7 @@ function dispatchRequest(config) {
|
|
|
4923
5065
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
4924
5066
|
}
|
|
4925
5067
|
|
|
4926
|
-
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
|
5068
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
4927
5069
|
|
|
4928
5070
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
4929
5071
|
throwIfCancellationRequested(config);
|
|
@@ -4957,7 +5099,7 @@ function dispatchRequest(config) {
|
|
|
4957
5099
|
});
|
|
4958
5100
|
}
|
|
4959
5101
|
|
|
4960
|
-
const VERSION = "1.
|
|
5102
|
+
const VERSION = "1.13.2";
|
|
4961
5103
|
|
|
4962
5104
|
const validators$1 = {};
|
|
4963
5105
|
|
|
@@ -5213,8 +5355,6 @@ class Axios {
|
|
|
5213
5355
|
|
|
5214
5356
|
let newConfig = config;
|
|
5215
5357
|
|
|
5216
|
-
i = 0;
|
|
5217
|
-
|
|
5218
5358
|
while (i < len) {
|
|
5219
5359
|
const onFulfilled = requestInterceptorChain[i++];
|
|
5220
5360
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -5518,6 +5658,12 @@ const HttpStatusCode = {
|
|
|
5518
5658
|
LoopDetected: 508,
|
|
5519
5659
|
NotExtended: 510,
|
|
5520
5660
|
NetworkAuthenticationRequired: 511,
|
|
5661
|
+
WebServerIsDown: 521,
|
|
5662
|
+
ConnectionTimedOut: 522,
|
|
5663
|
+
OriginIsUnreachable: 523,
|
|
5664
|
+
TimeoutOccurred: 524,
|
|
5665
|
+
SslHandshakeFailed: 525,
|
|
5666
|
+
InvalidSslCertificate: 526,
|
|
5521
5667
|
};
|
|
5522
5668
|
|
|
5523
5669
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|