@passkeyme/auth 2.0.10 → 2.0.12
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 +429 -268
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +429 -268
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +429 -268
- 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.umd.js
CHANGED
|
@@ -828,7 +828,7 @@
|
|
|
828
828
|
const defaultRedirectUri = typeof window !== "undefined" && window.location && window.location.origin
|
|
829
829
|
? `${window.location.origin}/auth/callback`
|
|
830
830
|
: "http://localhost:3000/auth/callback";
|
|
831
|
-
//
|
|
831
|
+
// Base URL for hosted auth UI pages - defaults to auth.passkeyme.com
|
|
832
832
|
const serverUrl = config.baseUrl || "https://auth.passkeyme.com";
|
|
833
833
|
console.log("[DEBUG] serverUrl determined as:", serverUrl);
|
|
834
834
|
this.config = {
|
|
@@ -1019,11 +1019,15 @@
|
|
|
1019
1019
|
*/
|
|
1020
1020
|
redirectToOAuth(provider, redirectUri) {
|
|
1021
1021
|
const finalRedirectUri = redirectUri || this.config.redirectUri;
|
|
1022
|
-
// Build direct OAuth initiation URL
|
|
1022
|
+
// Build direct OAuth initiation URL - use apiUrl for backend API endpoints
|
|
1023
|
+
const apiBaseUrl = this.config.apiUrl ||
|
|
1024
|
+
(typeof window !== "undefined" && window.location.hostname !== "localhost"
|
|
1025
|
+
? "https://api.passkeyme.com"
|
|
1026
|
+
: "http://localhost:8000");
|
|
1023
1027
|
const params = new URLSearchParams({
|
|
1024
1028
|
redirect_uri: finalRedirectUri,
|
|
1025
1029
|
});
|
|
1026
|
-
const oauthUrl = `${
|
|
1030
|
+
const oauthUrl = `${apiBaseUrl}/auth/${this.config.appId}/oauth/${provider}/start?${params.toString()}`;
|
|
1027
1031
|
logger.debug("Redirecting directly to OAuth provider:", provider, oauthUrl);
|
|
1028
1032
|
this.performRedirect(oauthUrl, finalRedirectUri);
|
|
1029
1033
|
}
|
|
@@ -1431,6 +1435,19 @@
|
|
|
1431
1435
|
}
|
|
1432
1436
|
// Extract token and user info from response
|
|
1433
1437
|
const { token, user_uuid, success, message } = completeResponse.data;
|
|
1438
|
+
// Decode JWT to extract email and other user info
|
|
1439
|
+
let tokenEmail;
|
|
1440
|
+
try {
|
|
1441
|
+
const tokenParts = token.split(".");
|
|
1442
|
+
if (tokenParts.length === 3) {
|
|
1443
|
+
const payload = JSON.parse(atob(tokenParts[1]));
|
|
1444
|
+
tokenEmail = payload.email;
|
|
1445
|
+
logger.debug("Extracted email from JWT:", tokenEmail);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
catch (decodeError) {
|
|
1449
|
+
logger.debug("Failed to decode JWT token:", decodeError);
|
|
1450
|
+
}
|
|
1434
1451
|
// Store tokens - use the JWT token as access token
|
|
1435
1452
|
const tokens = {
|
|
1436
1453
|
accessToken: token,
|
|
@@ -1439,11 +1456,13 @@
|
|
|
1439
1456
|
};
|
|
1440
1457
|
await this.tokenStorage.setTokens(tokens);
|
|
1441
1458
|
// Create user object with available information
|
|
1459
|
+
// Prefer email from JWT token, fallback to username
|
|
1460
|
+
const userEmail = tokenEmail || username;
|
|
1442
1461
|
const user = {
|
|
1443
1462
|
id: user_uuid,
|
|
1444
1463
|
uuid: user_uuid,
|
|
1445
1464
|
username: username,
|
|
1446
|
-
email:
|
|
1465
|
+
email: userEmail,
|
|
1447
1466
|
authenticated: true,
|
|
1448
1467
|
};
|
|
1449
1468
|
// Update state
|
|
@@ -1833,6 +1852,13 @@
|
|
|
1833
1852
|
return new PasskeymeAuth(config);
|
|
1834
1853
|
}
|
|
1835
1854
|
|
|
1855
|
+
/**
|
|
1856
|
+
* Create a bound version of a function with a specified `this` context
|
|
1857
|
+
*
|
|
1858
|
+
* @param {Function} fn - The function to bind
|
|
1859
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
1860
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
1861
|
+
*/
|
|
1836
1862
|
function bind(fn, thisArg) {
|
|
1837
1863
|
return function wrap() {
|
|
1838
1864
|
return fn.apply(thisArg, arguments);
|
|
@@ -1884,7 +1910,7 @@
|
|
|
1884
1910
|
*/
|
|
1885
1911
|
function isBuffer(val) {
|
|
1886
1912
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
1887
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
1913
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
1888
1914
|
}
|
|
1889
1915
|
|
|
1890
1916
|
/**
|
|
@@ -1929,7 +1955,7 @@
|
|
|
1929
1955
|
* @param {*} val The value to test
|
|
1930
1956
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
1931
1957
|
*/
|
|
1932
|
-
const isFunction = typeOfTest('function');
|
|
1958
|
+
const isFunction$1 = typeOfTest('function');
|
|
1933
1959
|
|
|
1934
1960
|
/**
|
|
1935
1961
|
* Determine if a value is a Number
|
|
@@ -1985,7 +2011,7 @@
|
|
|
1985
2011
|
if (!isObject(val) || isBuffer(val)) {
|
|
1986
2012
|
return false;
|
|
1987
2013
|
}
|
|
1988
|
-
|
|
2014
|
+
|
|
1989
2015
|
try {
|
|
1990
2016
|
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
1991
2017
|
} catch (e) {
|
|
@@ -2037,7 +2063,7 @@
|
|
|
2037
2063
|
*
|
|
2038
2064
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
2039
2065
|
*/
|
|
2040
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
2066
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
2041
2067
|
|
|
2042
2068
|
/**
|
|
2043
2069
|
* Determine if a value is a FormData
|
|
@@ -2050,10 +2076,10 @@
|
|
|
2050
2076
|
let kind;
|
|
2051
2077
|
return thing && (
|
|
2052
2078
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
2053
|
-
isFunction(thing.append) && (
|
|
2079
|
+
isFunction$1(thing.append) && (
|
|
2054
2080
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
2055
2081
|
// detect form-data instance
|
|
2056
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
2082
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
2057
2083
|
)
|
|
2058
2084
|
)
|
|
2059
2085
|
)
|
|
@@ -2178,7 +2204,7 @@
|
|
|
2178
2204
|
* @returns {Object} Result of all merge properties
|
|
2179
2205
|
*/
|
|
2180
2206
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
2181
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
2207
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
2182
2208
|
const result = {};
|
|
2183
2209
|
const assignValue = (val, key) => {
|
|
2184
2210
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -2188,7 +2214,7 @@
|
|
|
2188
2214
|
result[targetKey] = merge({}, val);
|
|
2189
2215
|
} else if (isArray(val)) {
|
|
2190
2216
|
result[targetKey] = val.slice();
|
|
2191
|
-
} else {
|
|
2217
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
2192
2218
|
result[targetKey] = val;
|
|
2193
2219
|
}
|
|
2194
2220
|
};
|
|
@@ -2211,7 +2237,7 @@
|
|
|
2211
2237
|
*/
|
|
2212
2238
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
2213
2239
|
forEach(b, (val, key) => {
|
|
2214
|
-
if (thisArg && isFunction(val)) {
|
|
2240
|
+
if (thisArg && isFunction$1(val)) {
|
|
2215
2241
|
a[key] = bind(val, thisArg);
|
|
2216
2242
|
} else {
|
|
2217
2243
|
a[key] = val;
|
|
@@ -2427,13 +2453,13 @@
|
|
|
2427
2453
|
const freezeMethods = (obj) => {
|
|
2428
2454
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
2429
2455
|
// skip restricted props in strict mode
|
|
2430
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
2456
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
2431
2457
|
return false;
|
|
2432
2458
|
}
|
|
2433
2459
|
|
|
2434
2460
|
const value = obj[name];
|
|
2435
2461
|
|
|
2436
|
-
if (!isFunction(value)) return;
|
|
2462
|
+
if (!isFunction$1(value)) return;
|
|
2437
2463
|
|
|
2438
2464
|
descriptor.enumerable = false;
|
|
2439
2465
|
|
|
@@ -2470,6 +2496,8 @@
|
|
|
2470
2496
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
2471
2497
|
};
|
|
2472
2498
|
|
|
2499
|
+
|
|
2500
|
+
|
|
2473
2501
|
/**
|
|
2474
2502
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
2475
2503
|
*
|
|
@@ -2478,7 +2506,7 @@
|
|
|
2478
2506
|
* @returns {boolean}
|
|
2479
2507
|
*/
|
|
2480
2508
|
function isSpecCompliantForm(thing) {
|
|
2481
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
2509
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
2482
2510
|
}
|
|
2483
2511
|
|
|
2484
2512
|
const toJSONObject = (obj) => {
|
|
@@ -2520,7 +2548,7 @@
|
|
|
2520
2548
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
2521
2549
|
|
|
2522
2550
|
const isThenable = (thing) =>
|
|
2523
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
2551
|
+
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
2524
2552
|
|
|
2525
2553
|
// original code
|
|
2526
2554
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -2544,7 +2572,7 @@
|
|
|
2544
2572
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
2545
2573
|
})(
|
|
2546
2574
|
typeof setImmediate === 'function',
|
|
2547
|
-
isFunction(_global.postMessage)
|
|
2575
|
+
isFunction$1(_global.postMessage)
|
|
2548
2576
|
);
|
|
2549
2577
|
|
|
2550
2578
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -2553,7 +2581,7 @@
|
|
|
2553
2581
|
// *********************
|
|
2554
2582
|
|
|
2555
2583
|
|
|
2556
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
2584
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
2557
2585
|
|
|
2558
2586
|
|
|
2559
2587
|
var utils$1 = {
|
|
@@ -2577,7 +2605,7 @@
|
|
|
2577
2605
|
isFile,
|
|
2578
2606
|
isBlob,
|
|
2579
2607
|
isRegExp,
|
|
2580
|
-
isFunction,
|
|
2608
|
+
isFunction: isFunction$1,
|
|
2581
2609
|
isStream,
|
|
2582
2610
|
isURLSearchParams,
|
|
2583
2611
|
isTypedArray,
|
|
@@ -2703,11 +2731,18 @@
|
|
|
2703
2731
|
return prop !== 'isAxiosError';
|
|
2704
2732
|
});
|
|
2705
2733
|
|
|
2706
|
-
|
|
2734
|
+
const msg = error && error.message ? error.message : 'Error';
|
|
2735
|
+
|
|
2736
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
2737
|
+
const errCode = code == null && error ? error.code : code;
|
|
2738
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
2707
2739
|
|
|
2708
|
-
|
|
2740
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
2741
|
+
if (error && axiosError.cause == null) {
|
|
2742
|
+
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
2743
|
+
}
|
|
2709
2744
|
|
|
2710
|
-
axiosError.name = error.name;
|
|
2745
|
+
axiosError.name = (error && error.name) || 'Error';
|
|
2711
2746
|
|
|
2712
2747
|
customProps && Object.assign(axiosError, customProps);
|
|
2713
2748
|
|
|
@@ -2998,9 +3033,7 @@
|
|
|
2998
3033
|
replace(/%3A/gi, ':').
|
|
2999
3034
|
replace(/%24/g, '$').
|
|
3000
3035
|
replace(/%2C/gi, ',').
|
|
3001
|
-
replace(/%20/g, '+')
|
|
3002
|
-
replace(/%5B/gi, '[').
|
|
3003
|
-
replace(/%5D/gi, ']');
|
|
3036
|
+
replace(/%20/g, '+');
|
|
3004
3037
|
}
|
|
3005
3038
|
|
|
3006
3039
|
/**
|
|
@@ -3078,7 +3111,7 @@
|
|
|
3078
3111
|
*
|
|
3079
3112
|
* @param {Number} id The ID that was returned by `use`
|
|
3080
3113
|
*
|
|
3081
|
-
* @returns {
|
|
3114
|
+
* @returns {void}
|
|
3082
3115
|
*/
|
|
3083
3116
|
eject(id) {
|
|
3084
3117
|
if (this.handlers[id]) {
|
|
@@ -3405,7 +3438,7 @@
|
|
|
3405
3438
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
3406
3439
|
|
|
3407
3440
|
try {
|
|
3408
|
-
return JSON.parse(data);
|
|
3441
|
+
return JSON.parse(data, this.parseReviver);
|
|
3409
3442
|
} catch (e) {
|
|
3410
3443
|
if (strictJSONParsing) {
|
|
3411
3444
|
if (e.name === 'SyntaxError') {
|
|
@@ -4044,27 +4077,38 @@
|
|
|
4044
4077
|
|
|
4045
4078
|
// Standard browser envs support document.cookie
|
|
4046
4079
|
{
|
|
4047
|
-
write(name, value, expires, path, domain, secure) {
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
4051
|
-
|
|
4052
|
-
utils$1.isString(path) && cookie.push('path=' + path);
|
|
4080
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
4081
|
+
if (typeof document === 'undefined') return;
|
|
4053
4082
|
|
|
4054
|
-
|
|
4083
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
4055
4084
|
|
|
4056
|
-
|
|
4085
|
+
if (utils$1.isNumber(expires)) {
|
|
4086
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
4087
|
+
}
|
|
4088
|
+
if (utils$1.isString(path)) {
|
|
4089
|
+
cookie.push(`path=${path}`);
|
|
4090
|
+
}
|
|
4091
|
+
if (utils$1.isString(domain)) {
|
|
4092
|
+
cookie.push(`domain=${domain}`);
|
|
4093
|
+
}
|
|
4094
|
+
if (secure === true) {
|
|
4095
|
+
cookie.push('secure');
|
|
4096
|
+
}
|
|
4097
|
+
if (utils$1.isString(sameSite)) {
|
|
4098
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
4099
|
+
}
|
|
4057
4100
|
|
|
4058
4101
|
document.cookie = cookie.join('; ');
|
|
4059
4102
|
},
|
|
4060
4103
|
|
|
4061
4104
|
read(name) {
|
|
4062
|
-
|
|
4063
|
-
|
|
4105
|
+
if (typeof document === 'undefined') return null;
|
|
4106
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
4107
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
4064
4108
|
},
|
|
4065
4109
|
|
|
4066
4110
|
remove(name) {
|
|
4067
|
-
this.write(name, '', Date.now() - 86400000);
|
|
4111
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
4068
4112
|
}
|
|
4069
4113
|
}
|
|
4070
4114
|
|
|
@@ -4153,11 +4197,11 @@
|
|
|
4153
4197
|
}
|
|
4154
4198
|
|
|
4155
4199
|
// eslint-disable-next-line consistent-return
|
|
4156
|
-
function mergeDeepProperties(a, b, prop
|
|
4200
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
4157
4201
|
if (!utils$1.isUndefined(b)) {
|
|
4158
|
-
return getMergedValue(a, b, prop
|
|
4202
|
+
return getMergedValue(a, b, prop, caseless);
|
|
4159
4203
|
} else if (!utils$1.isUndefined(a)) {
|
|
4160
|
-
return getMergedValue(undefined, a, prop
|
|
4204
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
4161
4205
|
}
|
|
4162
4206
|
}
|
|
4163
4207
|
|
|
@@ -4215,7 +4259,7 @@
|
|
|
4215
4259
|
socketPath: defaultToConfig2,
|
|
4216
4260
|
responseEncoding: defaultToConfig2,
|
|
4217
4261
|
validateStatus: mergeDirectKeys,
|
|
4218
|
-
headers: (a, b
|
|
4262
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
4219
4263
|
};
|
|
4220
4264
|
|
|
4221
4265
|
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
@@ -4230,7 +4274,7 @@
|
|
|
4230
4274
|
var resolveConfig = (config) => {
|
|
4231
4275
|
const newConfig = mergeConfig({}, config);
|
|
4232
4276
|
|
|
4233
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
4277
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
4234
4278
|
|
|
4235
4279
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
4236
4280
|
|
|
@@ -4243,17 +4287,21 @@
|
|
|
4243
4287
|
);
|
|
4244
4288
|
}
|
|
4245
4289
|
|
|
4246
|
-
let contentType;
|
|
4247
|
-
|
|
4248
4290
|
if (utils$1.isFormData(data)) {
|
|
4249
4291
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
4250
|
-
headers.setContentType(undefined); //
|
|
4251
|
-
} else if ((
|
|
4252
|
-
//
|
|
4253
|
-
const
|
|
4254
|
-
headers
|
|
4292
|
+
headers.setContentType(undefined); // browser handles it
|
|
4293
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
4294
|
+
// Node.js FormData (like form-data package)
|
|
4295
|
+
const formHeaders = data.getHeaders();
|
|
4296
|
+
// Only set safe headers to avoid overwriting security headers
|
|
4297
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
4298
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
4299
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
4300
|
+
headers.set(key, val);
|
|
4301
|
+
}
|
|
4302
|
+
});
|
|
4255
4303
|
}
|
|
4256
|
-
}
|
|
4304
|
+
}
|
|
4257
4305
|
|
|
4258
4306
|
// Add xsrf header
|
|
4259
4307
|
// This is only done if running in a standard browser environment.
|
|
@@ -4370,15 +4418,18 @@
|
|
|
4370
4418
|
};
|
|
4371
4419
|
|
|
4372
4420
|
// Handle low level network errors
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4421
|
+
request.onerror = function handleError(event) {
|
|
4422
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
4423
|
+
// (message may be empty; when present, surface it)
|
|
4424
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
4425
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
4426
|
+
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
4427
|
+
// attach the underlying event for consumers who want details
|
|
4428
|
+
err.event = event || null;
|
|
4429
|
+
reject(err);
|
|
4430
|
+
request = null;
|
|
4380
4431
|
};
|
|
4381
|
-
|
|
4432
|
+
|
|
4382
4433
|
// Handle timeout
|
|
4383
4434
|
request.ontimeout = function handleTimeout() {
|
|
4384
4435
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -4594,14 +4645,18 @@
|
|
|
4594
4645
|
})
|
|
4595
4646
|
};
|
|
4596
4647
|
|
|
4597
|
-
const
|
|
4598
|
-
|
|
4648
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4649
|
+
|
|
4650
|
+
const {isFunction} = utils$1;
|
|
4651
|
+
|
|
4652
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
4653
|
+
Request, Response
|
|
4654
|
+
}))(utils$1.global);
|
|
4655
|
+
|
|
4656
|
+
const {
|
|
4657
|
+
ReadableStream: ReadableStream$1, TextEncoder
|
|
4658
|
+
} = utils$1.global;
|
|
4599
4659
|
|
|
4600
|
-
// used only inside the fetch adapter
|
|
4601
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
4602
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
4603
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
4604
|
-
);
|
|
4605
4660
|
|
|
4606
4661
|
const test = (fn, ...args) => {
|
|
4607
4662
|
try {
|
|
@@ -4611,278 +4666,380 @@
|
|
|
4611
4666
|
}
|
|
4612
4667
|
};
|
|
4613
4668
|
|
|
4614
|
-
const
|
|
4615
|
-
|
|
4669
|
+
const factory = (env) => {
|
|
4670
|
+
env = utils$1.merge.call({
|
|
4671
|
+
skipUndefined: true
|
|
4672
|
+
}, globalFetchAPI, env);
|
|
4616
4673
|
|
|
4617
|
-
const
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
duplexAccessed = true;
|
|
4622
|
-
return 'half';
|
|
4623
|
-
},
|
|
4624
|
-
}).headers.has('Content-Type');
|
|
4674
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
4675
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
4676
|
+
const isRequestSupported = isFunction(Request);
|
|
4677
|
+
const isResponseSupported = isFunction(Response);
|
|
4625
4678
|
|
|
4626
|
-
|
|
4627
|
-
|
|
4679
|
+
if (!isFetchSupported) {
|
|
4680
|
+
return false;
|
|
4681
|
+
}
|
|
4628
4682
|
|
|
4629
|
-
|
|
4683
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
4630
4684
|
|
|
4631
|
-
|
|
4632
|
-
|
|
4685
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
4686
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
4687
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
4688
|
+
);
|
|
4633
4689
|
|
|
4690
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
4691
|
+
let duplexAccessed = false;
|
|
4634
4692
|
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4693
|
+
const hasContentType = new Request(platform.origin, {
|
|
4694
|
+
body: new ReadableStream$1(),
|
|
4695
|
+
method: 'POST',
|
|
4696
|
+
get duplex() {
|
|
4697
|
+
duplexAccessed = true;
|
|
4698
|
+
return 'half';
|
|
4699
|
+
},
|
|
4700
|
+
}).headers.has('Content-Type');
|
|
4638
4701
|
|
|
4639
|
-
|
|
4640
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
4641
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
4642
|
-
(_, config) => {
|
|
4643
|
-
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
4644
|
-
});
|
|
4702
|
+
return duplexAccessed && !hasContentType;
|
|
4645
4703
|
});
|
|
4646
|
-
})(new Response));
|
|
4647
4704
|
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
return 0;
|
|
4651
|
-
}
|
|
4705
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
4706
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
4652
4707
|
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
}
|
|
4708
|
+
const resolvers = {
|
|
4709
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
4710
|
+
};
|
|
4656
4711
|
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4712
|
+
isFetchSupported && ((() => {
|
|
4713
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
4714
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
4715
|
+
let method = res && res[type];
|
|
4716
|
+
|
|
4717
|
+
if (method) {
|
|
4718
|
+
return method.call(res);
|
|
4719
|
+
}
|
|
4720
|
+
|
|
4721
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
4722
|
+
});
|
|
4661
4723
|
});
|
|
4662
|
-
|
|
4663
|
-
}
|
|
4724
|
+
})());
|
|
4664
4725
|
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4726
|
+
const getBodyLength = async (body) => {
|
|
4727
|
+
if (body == null) {
|
|
4728
|
+
return 0;
|
|
4729
|
+
}
|
|
4668
4730
|
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4731
|
+
if (utils$1.isBlob(body)) {
|
|
4732
|
+
return body.size;
|
|
4733
|
+
}
|
|
4672
4734
|
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4735
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
4736
|
+
const _request = new Request(platform.origin, {
|
|
4737
|
+
method: 'POST',
|
|
4738
|
+
body,
|
|
4739
|
+
});
|
|
4740
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
4741
|
+
}
|
|
4677
4742
|
|
|
4678
|
-
|
|
4679
|
-
|
|
4743
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
4744
|
+
return body.byteLength;
|
|
4745
|
+
}
|
|
4680
4746
|
|
|
4681
|
-
|
|
4682
|
-
|
|
4747
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
4748
|
+
body = body + '';
|
|
4749
|
+
}
|
|
4750
|
+
|
|
4751
|
+
if (utils$1.isString(body)) {
|
|
4752
|
+
return (await encodeText(body)).byteLength;
|
|
4753
|
+
}
|
|
4754
|
+
};
|
|
4683
4755
|
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4756
|
+
const resolveBodyLength = async (headers, body) => {
|
|
4757
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
4758
|
+
|
|
4759
|
+
return length == null ? getBodyLength(body) : length;
|
|
4760
|
+
};
|
|
4761
|
+
|
|
4762
|
+
return async (config) => {
|
|
4763
|
+
let {
|
|
4764
|
+
url,
|
|
4765
|
+
method,
|
|
4766
|
+
data,
|
|
4767
|
+
signal,
|
|
4768
|
+
cancelToken,
|
|
4769
|
+
timeout,
|
|
4770
|
+
onDownloadProgress,
|
|
4771
|
+
onUploadProgress,
|
|
4772
|
+
responseType,
|
|
4773
|
+
headers,
|
|
4774
|
+
withCredentials = 'same-origin',
|
|
4775
|
+
fetchOptions
|
|
4776
|
+
} = resolveConfig(config);
|
|
4777
|
+
|
|
4778
|
+
let _fetch = envFetch || fetch;
|
|
4779
|
+
|
|
4780
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4781
|
+
|
|
4782
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
4783
|
+
|
|
4784
|
+
let request = null;
|
|
4785
|
+
|
|
4786
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
4707
4787
|
composedSignal.unsubscribe();
|
|
4708
|
-
|
|
4788
|
+
});
|
|
4709
4789
|
|
|
4710
|
-
|
|
4790
|
+
let requestContentLength;
|
|
4711
4791
|
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4792
|
+
try {
|
|
4793
|
+
if (
|
|
4794
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
4795
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
4796
|
+
) {
|
|
4797
|
+
let _request = new Request(url, {
|
|
4798
|
+
method: 'POST',
|
|
4799
|
+
body: data,
|
|
4800
|
+
duplex: "half"
|
|
4801
|
+
});
|
|
4722
4802
|
|
|
4723
|
-
|
|
4803
|
+
let contentTypeHeader;
|
|
4724
4804
|
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4805
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4806
|
+
headers.setContentType(contentTypeHeader);
|
|
4807
|
+
}
|
|
4728
4808
|
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4809
|
+
if (_request.body) {
|
|
4810
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
4811
|
+
requestContentLength,
|
|
4812
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4813
|
+
);
|
|
4734
4814
|
|
|
4735
|
-
|
|
4815
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
4816
|
+
}
|
|
4736
4817
|
}
|
|
4737
|
-
}
|
|
4738
4818
|
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4819
|
+
if (!utils$1.isString(withCredentials)) {
|
|
4820
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
4821
|
+
}
|
|
4742
4822
|
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
request = new Request(url, {
|
|
4747
|
-
...fetchOptions,
|
|
4748
|
-
signal: composedSignal,
|
|
4749
|
-
method: method.toUpperCase(),
|
|
4750
|
-
headers: headers.normalize().toJSON(),
|
|
4751
|
-
body: data,
|
|
4752
|
-
duplex: "half",
|
|
4753
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4754
|
-
});
|
|
4823
|
+
// Cloudflare Workers throws when credentials are defined
|
|
4824
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
4825
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
4755
4826
|
|
|
4756
|
-
|
|
4827
|
+
const resolvedOptions = {
|
|
4828
|
+
...fetchOptions,
|
|
4829
|
+
signal: composedSignal,
|
|
4830
|
+
method: method.toUpperCase(),
|
|
4831
|
+
headers: headers.normalize().toJSON(),
|
|
4832
|
+
body: data,
|
|
4833
|
+
duplex: "half",
|
|
4834
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4835
|
+
};
|
|
4757
4836
|
|
|
4758
|
-
|
|
4837
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
4759
4838
|
|
|
4760
|
-
|
|
4761
|
-
const options = {};
|
|
4839
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
4762
4840
|
|
|
4763
|
-
|
|
4764
|
-
options[prop] = response[prop];
|
|
4765
|
-
});
|
|
4841
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4766
4842
|
|
|
4767
|
-
|
|
4843
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
4844
|
+
const options = {};
|
|
4768
4845
|
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
) || [];
|
|
4846
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
4847
|
+
options[prop] = response[prop];
|
|
4848
|
+
});
|
|
4773
4849
|
|
|
4774
|
-
|
|
4775
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4776
|
-
flush && flush();
|
|
4777
|
-
unsubscribe && unsubscribe();
|
|
4778
|
-
}),
|
|
4779
|
-
options
|
|
4780
|
-
);
|
|
4781
|
-
}
|
|
4850
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4782
4851
|
|
|
4783
|
-
|
|
4852
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
4853
|
+
responseContentLength,
|
|
4854
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
4855
|
+
) || [];
|
|
4784
4856
|
|
|
4785
|
-
|
|
4857
|
+
response = new Response(
|
|
4858
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4859
|
+
flush && flush();
|
|
4860
|
+
unsubscribe && unsubscribe();
|
|
4861
|
+
}),
|
|
4862
|
+
options
|
|
4863
|
+
);
|
|
4864
|
+
}
|
|
4786
4865
|
|
|
4787
|
-
|
|
4866
|
+
responseType = responseType || 'text';
|
|
4788
4867
|
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4868
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
4869
|
+
|
|
4870
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4871
|
+
|
|
4872
|
+
return await new Promise((resolve, reject) => {
|
|
4873
|
+
settle(resolve, reject, {
|
|
4874
|
+
data: responseData,
|
|
4875
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
4876
|
+
status: response.status,
|
|
4877
|
+
statusText: response.statusText,
|
|
4878
|
+
config,
|
|
4879
|
+
request
|
|
4880
|
+
});
|
|
4881
|
+
})
|
|
4882
|
+
} catch (err) {
|
|
4883
|
+
unsubscribe && unsubscribe();
|
|
4884
|
+
|
|
4885
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4886
|
+
throw Object.assign(
|
|
4887
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
4888
|
+
{
|
|
4889
|
+
cause: err.cause || err
|
|
4890
|
+
}
|
|
4891
|
+
)
|
|
4892
|
+
}
|
|
4893
|
+
|
|
4894
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
4809
4895
|
}
|
|
4896
|
+
}
|
|
4897
|
+
};
|
|
4898
|
+
|
|
4899
|
+
const seedCache = new Map();
|
|
4900
|
+
|
|
4901
|
+
const getFetch = (config) => {
|
|
4902
|
+
let env = (config && config.env) || {};
|
|
4903
|
+
const {fetch, Request, Response} = env;
|
|
4904
|
+
const seeds = [
|
|
4905
|
+
Request, Response, fetch
|
|
4906
|
+
];
|
|
4907
|
+
|
|
4908
|
+
let len = seeds.length, i = len,
|
|
4909
|
+
seed, target, map = seedCache;
|
|
4910
|
+
|
|
4911
|
+
while (i--) {
|
|
4912
|
+
seed = seeds[i];
|
|
4913
|
+
target = map.get(seed);
|
|
4810
4914
|
|
|
4811
|
-
|
|
4915
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
4916
|
+
|
|
4917
|
+
map = target;
|
|
4812
4918
|
}
|
|
4813
|
-
});
|
|
4814
4919
|
|
|
4920
|
+
return target;
|
|
4921
|
+
};
|
|
4922
|
+
|
|
4923
|
+
getFetch();
|
|
4924
|
+
|
|
4925
|
+
/**
|
|
4926
|
+
* Known adapters mapping.
|
|
4927
|
+
* Provides environment-specific adapters for Axios:
|
|
4928
|
+
* - `http` for Node.js
|
|
4929
|
+
* - `xhr` for browsers
|
|
4930
|
+
* - `fetch` for fetch API-based requests
|
|
4931
|
+
*
|
|
4932
|
+
* @type {Object<string, Function|Object>}
|
|
4933
|
+
*/
|
|
4815
4934
|
const knownAdapters = {
|
|
4816
4935
|
http: httpAdapter,
|
|
4817
4936
|
xhr: xhrAdapter,
|
|
4818
|
-
fetch:
|
|
4937
|
+
fetch: {
|
|
4938
|
+
get: getFetch,
|
|
4939
|
+
}
|
|
4819
4940
|
};
|
|
4820
4941
|
|
|
4942
|
+
// Assign adapter names for easier debugging and identification
|
|
4821
4943
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
4822
4944
|
if (fn) {
|
|
4823
4945
|
try {
|
|
4824
|
-
Object.defineProperty(fn, 'name', {value});
|
|
4946
|
+
Object.defineProperty(fn, 'name', { value });
|
|
4825
4947
|
} catch (e) {
|
|
4826
4948
|
// eslint-disable-next-line no-empty
|
|
4827
4949
|
}
|
|
4828
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
4950
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
4829
4951
|
}
|
|
4830
4952
|
});
|
|
4831
4953
|
|
|
4954
|
+
/**
|
|
4955
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
4956
|
+
*
|
|
4957
|
+
* @param {string} reason
|
|
4958
|
+
* @returns {string}
|
|
4959
|
+
*/
|
|
4832
4960
|
const renderReason = (reason) => `- ${reason}`;
|
|
4833
4961
|
|
|
4962
|
+
/**
|
|
4963
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
4964
|
+
*
|
|
4965
|
+
* @param {Function|null|false} adapter
|
|
4966
|
+
* @returns {boolean}
|
|
4967
|
+
*/
|
|
4834
4968
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
4835
4969
|
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4970
|
+
/**
|
|
4971
|
+
* Get the first suitable adapter from the provided list.
|
|
4972
|
+
* Tries each adapter in order until a supported one is found.
|
|
4973
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
4974
|
+
*
|
|
4975
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
4976
|
+
* @param {Object} config - Axios request configuration
|
|
4977
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
4978
|
+
* @returns {Function} The resolved adapter function
|
|
4979
|
+
*/
|
|
4980
|
+
function getAdapter(adapters, config) {
|
|
4981
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
4843
4982
|
|
|
4844
|
-
|
|
4983
|
+
const { length } = adapters;
|
|
4984
|
+
let nameOrAdapter;
|
|
4985
|
+
let adapter;
|
|
4845
4986
|
|
|
4846
|
-
|
|
4847
|
-
nameOrAdapter = adapters[i];
|
|
4848
|
-
let id;
|
|
4987
|
+
const rejectedReasons = {};
|
|
4849
4988
|
|
|
4850
|
-
|
|
4989
|
+
for (let i = 0; i < length; i++) {
|
|
4990
|
+
nameOrAdapter = adapters[i];
|
|
4991
|
+
let id;
|
|
4851
4992
|
|
|
4852
|
-
|
|
4853
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
4993
|
+
adapter = nameOrAdapter;
|
|
4854
4994
|
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4995
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
4996
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
4859
4997
|
|
|
4860
|
-
if (adapter) {
|
|
4861
|
-
|
|
4998
|
+
if (adapter === undefined) {
|
|
4999
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
4862
5000
|
}
|
|
5001
|
+
}
|
|
4863
5002
|
|
|
4864
|
-
|
|
5003
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
5004
|
+
break;
|
|
4865
5005
|
}
|
|
4866
5006
|
|
|
4867
|
-
|
|
5007
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
5008
|
+
}
|
|
4868
5009
|
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
)
|
|
5010
|
+
if (!adapter) {
|
|
5011
|
+
const reasons = Object.entries(rejectedReasons)
|
|
5012
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
5013
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
5014
|
+
);
|
|
4873
5015
|
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
5016
|
+
let s = length ?
|
|
5017
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
5018
|
+
'as no adapter specified';
|
|
4877
5019
|
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
5020
|
+
throw new AxiosError(
|
|
5021
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
5022
|
+
'ERR_NOT_SUPPORT'
|
|
5023
|
+
);
|
|
5024
|
+
}
|
|
4883
5025
|
|
|
4884
|
-
|
|
4885
|
-
|
|
5026
|
+
return adapter;
|
|
5027
|
+
}
|
|
5028
|
+
|
|
5029
|
+
/**
|
|
5030
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
5031
|
+
*/
|
|
5032
|
+
var adapters = {
|
|
5033
|
+
/**
|
|
5034
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
5035
|
+
* @type {Function}
|
|
5036
|
+
*/
|
|
5037
|
+
getAdapter,
|
|
5038
|
+
|
|
5039
|
+
/**
|
|
5040
|
+
* Exposes all known adapters
|
|
5041
|
+
* @type {Object<string, Function|Object>}
|
|
5042
|
+
*/
|
|
4886
5043
|
adapters: knownAdapters
|
|
4887
5044
|
};
|
|
4888
5045
|
|
|
@@ -4925,7 +5082,7 @@
|
|
|
4925
5082
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
4926
5083
|
}
|
|
4927
5084
|
|
|
4928
|
-
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
|
5085
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
4929
5086
|
|
|
4930
5087
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
4931
5088
|
throwIfCancellationRequested(config);
|
|
@@ -4959,7 +5116,7 @@
|
|
|
4959
5116
|
});
|
|
4960
5117
|
}
|
|
4961
5118
|
|
|
4962
|
-
const VERSION = "1.
|
|
5119
|
+
const VERSION = "1.13.2";
|
|
4963
5120
|
|
|
4964
5121
|
const validators$1 = {};
|
|
4965
5122
|
|
|
@@ -5215,8 +5372,6 @@
|
|
|
5215
5372
|
|
|
5216
5373
|
let newConfig = config;
|
|
5217
5374
|
|
|
5218
|
-
i = 0;
|
|
5219
|
-
|
|
5220
5375
|
while (i < len) {
|
|
5221
5376
|
const onFulfilled = requestInterceptorChain[i++];
|
|
5222
5377
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -5520,6 +5675,12 @@
|
|
|
5520
5675
|
LoopDetected: 508,
|
|
5521
5676
|
NotExtended: 510,
|
|
5522
5677
|
NetworkAuthenticationRequired: 511,
|
|
5678
|
+
WebServerIsDown: 521,
|
|
5679
|
+
ConnectionTimedOut: 522,
|
|
5680
|
+
OriginIsUnreachable: 523,
|
|
5681
|
+
TimeoutOccurred: 524,
|
|
5682
|
+
SslHandshakeFailed: 525,
|
|
5683
|
+
InvalidSslCertificate: 526,
|
|
5523
5684
|
};
|
|
5524
5685
|
|
|
5525
5686
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|