@passkeyme/react-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/dist/index.esm.js CHANGED
@@ -2422,6 +2422,13 @@ debugMode = false, passkeyOptions = {}, }) => {
2422
2422
  }, children: ["Continue with", " ", provider.charAt(0).toUpperCase() + provider.slice(1)] }) }, provider))) })), (showDebugInfo || debugMode) && (jsxs("div", { style: mergedTheme.debugInfo, children: [jsx("strong", { children: "\uD83D\uDC1B Debug Info:" }), jsx("br", {}), "Passkey Support: ", isPasskeySupported() ? "Yes" : "No", jsx("br", {}), "Authenticated: ", isAuthenticated ? "Yes" : "No", jsx("br", {}), "Auth Loading: ", authLoading ? "Yes" : "No", jsx("br", {}), "Passkey Attempted: ", passkeyAttempted ? "Yes" : "No", jsx("br", {}), "Show OAuth: ", showOAuthOptions ? "Yes" : "No", jsx("br", {}), "Available Providers: ", availableProviders.join(", ") || "None"] }))] }));
2423
2423
  };
2424
2424
 
2425
+ /**
2426
+ * Create a bound version of a function with a specified `this` context
2427
+ *
2428
+ * @param {Function} fn - The function to bind
2429
+ * @param {*} thisArg - The value to be passed as the `this` parameter
2430
+ * @returns {Function} A new function that will call the original function with the specified `this` context
2431
+ */
2425
2432
  function bind(fn, thisArg) {
2426
2433
  return function wrap() {
2427
2434
  return fn.apply(thisArg, arguments);
@@ -2473,7 +2480,7 @@ const isUndefined = typeOfTest('undefined');
2473
2480
  */
2474
2481
  function isBuffer(val) {
2475
2482
  return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
2476
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
2483
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
2477
2484
  }
2478
2485
 
2479
2486
  /**
@@ -2518,7 +2525,7 @@ const isString = typeOfTest('string');
2518
2525
  * @param {*} val The value to test
2519
2526
  * @returns {boolean} True if value is a Function, otherwise false
2520
2527
  */
2521
- const isFunction = typeOfTest('function');
2528
+ const isFunction$1 = typeOfTest('function');
2522
2529
 
2523
2530
  /**
2524
2531
  * Determine if a value is a Number
@@ -2574,7 +2581,7 @@ const isEmptyObject = (val) => {
2574
2581
  if (!isObject(val) || isBuffer(val)) {
2575
2582
  return false;
2576
2583
  }
2577
-
2584
+
2578
2585
  try {
2579
2586
  return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
2580
2587
  } catch (e) {
@@ -2626,7 +2633,7 @@ const isFileList = kindOfTest('FileList');
2626
2633
  *
2627
2634
  * @returns {boolean} True if value is a Stream, otherwise false
2628
2635
  */
2629
- const isStream = (val) => isObject(val) && isFunction(val.pipe);
2636
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
2630
2637
 
2631
2638
  /**
2632
2639
  * Determine if a value is a FormData
@@ -2639,10 +2646,10 @@ const isFormData = (thing) => {
2639
2646
  let kind;
2640
2647
  return thing && (
2641
2648
  (typeof FormData === 'function' && thing instanceof FormData) || (
2642
- isFunction(thing.append) && (
2649
+ isFunction$1(thing.append) && (
2643
2650
  (kind = kindOf(thing)) === 'formdata' ||
2644
2651
  // detect form-data instance
2645
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
2652
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
2646
2653
  )
2647
2654
  )
2648
2655
  )
@@ -2767,7 +2774,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
2767
2774
  * @returns {Object} Result of all merge properties
2768
2775
  */
2769
2776
  function merge(/* obj1, obj2, obj3, ... */) {
2770
- const {caseless} = isContextDefined(this) && this || {};
2777
+ const {caseless, skipUndefined} = isContextDefined(this) && this || {};
2771
2778
  const result = {};
2772
2779
  const assignValue = (val, key) => {
2773
2780
  const targetKey = caseless && findKey(result, key) || key;
@@ -2777,7 +2784,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
2777
2784
  result[targetKey] = merge({}, val);
2778
2785
  } else if (isArray(val)) {
2779
2786
  result[targetKey] = val.slice();
2780
- } else {
2787
+ } else if (!skipUndefined || !isUndefined(val)) {
2781
2788
  result[targetKey] = val;
2782
2789
  }
2783
2790
  };
@@ -2800,7 +2807,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
2800
2807
  */
2801
2808
  const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
2802
2809
  forEach(b, (val, key) => {
2803
- if (thisArg && isFunction(val)) {
2810
+ if (thisArg && isFunction$1(val)) {
2804
2811
  a[key] = bind(val, thisArg);
2805
2812
  } else {
2806
2813
  a[key] = val;
@@ -3016,13 +3023,13 @@ const reduceDescriptors = (obj, reducer) => {
3016
3023
  const freezeMethods = (obj) => {
3017
3024
  reduceDescriptors(obj, (descriptor, name) => {
3018
3025
  // skip restricted props in strict mode
3019
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
3026
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
3020
3027
  return false;
3021
3028
  }
3022
3029
 
3023
3030
  const value = obj[name];
3024
3031
 
3025
- if (!isFunction(value)) return;
3032
+ if (!isFunction$1(value)) return;
3026
3033
 
3027
3034
  descriptor.enumerable = false;
3028
3035
 
@@ -3059,6 +3066,8 @@ const toFiniteNumber = (value, defaultValue) => {
3059
3066
  return value != null && Number.isFinite(value = +value) ? value : defaultValue;
3060
3067
  };
3061
3068
 
3069
+
3070
+
3062
3071
  /**
3063
3072
  * If the thing is a FormData object, return true, otherwise return false.
3064
3073
  *
@@ -3067,7 +3076,7 @@ const toFiniteNumber = (value, defaultValue) => {
3067
3076
  * @returns {boolean}
3068
3077
  */
3069
3078
  function isSpecCompliantForm(thing) {
3070
- return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
3079
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
3071
3080
  }
3072
3081
 
3073
3082
  const toJSONObject = (obj) => {
@@ -3109,7 +3118,7 @@ const toJSONObject = (obj) => {
3109
3118
  const isAsyncFn = kindOfTest('AsyncFunction');
3110
3119
 
3111
3120
  const isThenable = (thing) =>
3112
- thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
3121
+ thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
3113
3122
 
3114
3123
  // original code
3115
3124
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -3133,7 +3142,7 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
3133
3142
  })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
3134
3143
  })(
3135
3144
  typeof setImmediate === 'function',
3136
- isFunction(_global.postMessage)
3145
+ isFunction$1(_global.postMessage)
3137
3146
  );
3138
3147
 
3139
3148
  const asap = typeof queueMicrotask !== 'undefined' ?
@@ -3142,7 +3151,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
3142
3151
  // *********************
3143
3152
 
3144
3153
 
3145
- const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
3154
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
3146
3155
 
3147
3156
 
3148
3157
  var utils$1 = {
@@ -3166,7 +3175,7 @@ var utils$1 = {
3166
3175
  isFile,
3167
3176
  isBlob,
3168
3177
  isRegExp,
3169
- isFunction,
3178
+ isFunction: isFunction$1,
3170
3179
  isStream,
3171
3180
  isURLSearchParams,
3172
3181
  isTypedArray,
@@ -3292,11 +3301,18 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
3292
3301
  return prop !== 'isAxiosError';
3293
3302
  });
3294
3303
 
3295
- AxiosError.call(axiosError, error.message, code, config, request, response);
3304
+ const msg = error && error.message ? error.message : 'Error';
3296
3305
 
3297
- axiosError.cause = error;
3306
+ // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
3307
+ const errCode = code == null && error ? error.code : code;
3308
+ AxiosError.call(axiosError, msg, errCode, config, request, response);
3298
3309
 
3299
- axiosError.name = error.name;
3310
+ // Chain the original error on the standard field; non-enumerable to avoid JSON noise
3311
+ if (error && axiosError.cause == null) {
3312
+ Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
3313
+ }
3314
+
3315
+ axiosError.name = (error && error.name) || 'Error';
3300
3316
 
3301
3317
  customProps && Object.assign(axiosError, customProps);
3302
3318
 
@@ -3587,9 +3603,7 @@ function encode(val) {
3587
3603
  replace(/%3A/gi, ':').
3588
3604
  replace(/%24/g, '$').
3589
3605
  replace(/%2C/gi, ',').
3590
- replace(/%20/g, '+').
3591
- replace(/%5B/gi, '[').
3592
- replace(/%5D/gi, ']');
3606
+ replace(/%20/g, '+');
3593
3607
  }
3594
3608
 
3595
3609
  /**
@@ -3667,7 +3681,7 @@ class InterceptorManager {
3667
3681
  *
3668
3682
  * @param {Number} id The ID that was returned by `use`
3669
3683
  *
3670
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
3684
+ * @returns {void}
3671
3685
  */
3672
3686
  eject(id) {
3673
3687
  if (this.handlers[id]) {
@@ -3994,7 +4008,7 @@ const defaults = {
3994
4008
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
3995
4009
 
3996
4010
  try {
3997
- return JSON.parse(data);
4011
+ return JSON.parse(data, this.parseReviver);
3998
4012
  } catch (e) {
3999
4013
  if (strictJSONParsing) {
4000
4014
  if (e.name === 'SyntaxError') {
@@ -4633,27 +4647,38 @@ var cookies = platform.hasStandardBrowserEnv ?
4633
4647
 
4634
4648
  // Standard browser envs support document.cookie
4635
4649
  {
4636
- write(name, value, expires, path, domain, secure) {
4637
- const cookie = [name + '=' + encodeURIComponent(value)];
4650
+ write(name, value, expires, path, domain, secure, sameSite) {
4651
+ if (typeof document === 'undefined') return;
4638
4652
 
4639
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
4653
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
4640
4654
 
4641
- utils$1.isString(path) && cookie.push('path=' + path);
4642
-
4643
- utils$1.isString(domain) && cookie.push('domain=' + domain);
4644
-
4645
- secure === true && cookie.push('secure');
4655
+ if (utils$1.isNumber(expires)) {
4656
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
4657
+ }
4658
+ if (utils$1.isString(path)) {
4659
+ cookie.push(`path=${path}`);
4660
+ }
4661
+ if (utils$1.isString(domain)) {
4662
+ cookie.push(`domain=${domain}`);
4663
+ }
4664
+ if (secure === true) {
4665
+ cookie.push('secure');
4666
+ }
4667
+ if (utils$1.isString(sameSite)) {
4668
+ cookie.push(`SameSite=${sameSite}`);
4669
+ }
4646
4670
 
4647
4671
  document.cookie = cookie.join('; ');
4648
4672
  },
4649
4673
 
4650
4674
  read(name) {
4651
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
4652
- return (match ? decodeURIComponent(match[3]) : null);
4675
+ if (typeof document === 'undefined') return null;
4676
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
4677
+ return match ? decodeURIComponent(match[1]) : null;
4653
4678
  },
4654
4679
 
4655
4680
  remove(name) {
4656
- this.write(name, '', Date.now() - 86400000);
4681
+ this.write(name, '', Date.now() - 86400000, '/');
4657
4682
  }
4658
4683
  }
4659
4684
 
@@ -4742,11 +4767,11 @@ function mergeConfig(config1, config2) {
4742
4767
  }
4743
4768
 
4744
4769
  // eslint-disable-next-line consistent-return
4745
- function mergeDeepProperties(a, b, prop , caseless) {
4770
+ function mergeDeepProperties(a, b, prop, caseless) {
4746
4771
  if (!utils$1.isUndefined(b)) {
4747
- return getMergedValue(a, b, prop , caseless);
4772
+ return getMergedValue(a, b, prop, caseless);
4748
4773
  } else if (!utils$1.isUndefined(a)) {
4749
- return getMergedValue(undefined, a, prop , caseless);
4774
+ return getMergedValue(undefined, a, prop, caseless);
4750
4775
  }
4751
4776
  }
4752
4777
 
@@ -4804,7 +4829,7 @@ function mergeConfig(config1, config2) {
4804
4829
  socketPath: defaultToConfig2,
4805
4830
  responseEncoding: defaultToConfig2,
4806
4831
  validateStatus: mergeDirectKeys,
4807
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
4832
+ headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
4808
4833
  };
4809
4834
 
4810
4835
  utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
@@ -4819,7 +4844,7 @@ function mergeConfig(config1, config2) {
4819
4844
  var resolveConfig = (config) => {
4820
4845
  const newConfig = mergeConfig({}, config);
4821
4846
 
4822
- let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
4847
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
4823
4848
 
4824
4849
  newConfig.headers = headers = AxiosHeaders$1.from(headers);
4825
4850
 
@@ -4832,17 +4857,21 @@ var resolveConfig = (config) => {
4832
4857
  );
4833
4858
  }
4834
4859
 
4835
- let contentType;
4836
-
4837
4860
  if (utils$1.isFormData(data)) {
4838
4861
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
4839
- headers.setContentType(undefined); // Let the browser set it
4840
- } else if ((contentType = headers.getContentType()) !== false) {
4841
- // fix semicolon duplication issue for ReactNative FormData implementation
4842
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
4843
- headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
4862
+ headers.setContentType(undefined); // browser handles it
4863
+ } else if (utils$1.isFunction(data.getHeaders)) {
4864
+ // Node.js FormData (like form-data package)
4865
+ const formHeaders = data.getHeaders();
4866
+ // Only set safe headers to avoid overwriting security headers
4867
+ const allowedHeaders = ['content-type', 'content-length'];
4868
+ Object.entries(formHeaders).forEach(([key, val]) => {
4869
+ if (allowedHeaders.includes(key.toLowerCase())) {
4870
+ headers.set(key, val);
4871
+ }
4872
+ });
4844
4873
  }
4845
- }
4874
+ }
4846
4875
 
4847
4876
  // Add xsrf header
4848
4877
  // This is only done if running in a standard browser environment.
@@ -4959,15 +4988,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
4959
4988
  };
4960
4989
 
4961
4990
  // Handle low level network errors
4962
- request.onerror = function handleError() {
4963
- // Real errors are hidden from us by the browser
4964
- // onerror should only fire if it's a network error
4965
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
4966
-
4967
- // Clean up request
4968
- request = null;
4991
+ request.onerror = function handleError(event) {
4992
+ // Browsers deliver a ProgressEvent in XHR onerror
4993
+ // (message may be empty; when present, surface it)
4994
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
4995
+ const msg = event && event.message ? event.message : 'Network Error';
4996
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
4997
+ // attach the underlying event for consumers who want details
4998
+ err.event = event || null;
4999
+ reject(err);
5000
+ request = null;
4969
5001
  };
4970
-
5002
+
4971
5003
  // Handle timeout
4972
5004
  request.ontimeout = function handleTimeout() {
4973
5005
  let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
@@ -5183,14 +5215,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
5183
5215
  })
5184
5216
  };
5185
5217
 
5186
- const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
5187
- const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
5218
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
5219
+
5220
+ const {isFunction} = utils$1;
5221
+
5222
+ const globalFetchAPI = (({Request, Response}) => ({
5223
+ Request, Response
5224
+ }))(utils$1.global);
5225
+
5226
+ const {
5227
+ ReadableStream: ReadableStream$1, TextEncoder
5228
+ } = utils$1.global;
5188
5229
 
5189
- // used only inside the fetch adapter
5190
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
5191
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
5192
- async (str) => new Uint8Array(await new Response(str).arrayBuffer())
5193
- );
5194
5230
 
5195
5231
  const test = (fn, ...args) => {
5196
5232
  try {
@@ -5200,278 +5236,380 @@ const test = (fn, ...args) => {
5200
5236
  }
5201
5237
  };
5202
5238
 
5203
- const supportsRequestStream = isReadableStreamSupported && test(() => {
5204
- let duplexAccessed = false;
5239
+ const factory = (env) => {
5240
+ env = utils$1.merge.call({
5241
+ skipUndefined: true
5242
+ }, globalFetchAPI, env);
5205
5243
 
5206
- const hasContentType = new Request(platform.origin, {
5207
- body: new ReadableStream(),
5208
- method: 'POST',
5209
- get duplex() {
5210
- duplexAccessed = true;
5211
- return 'half';
5212
- },
5213
- }).headers.has('Content-Type');
5244
+ const {fetch: envFetch, Request, Response} = env;
5245
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
5246
+ const isRequestSupported = isFunction(Request);
5247
+ const isResponseSupported = isFunction(Response);
5214
5248
 
5215
- return duplexAccessed && !hasContentType;
5216
- });
5249
+ if (!isFetchSupported) {
5250
+ return false;
5251
+ }
5217
5252
 
5218
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
5253
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
5219
5254
 
5220
- const supportsResponseStream = isReadableStreamSupported &&
5221
- test(() => utils$1.isReadableStream(new Response('').body));
5255
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
5256
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
5257
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
5258
+ );
5222
5259
 
5260
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
5261
+ let duplexAccessed = false;
5223
5262
 
5224
- const resolvers = {
5225
- stream: supportsResponseStream && ((res) => res.body)
5226
- };
5263
+ const hasContentType = new Request(platform.origin, {
5264
+ body: new ReadableStream$1(),
5265
+ method: 'POST',
5266
+ get duplex() {
5267
+ duplexAccessed = true;
5268
+ return 'half';
5269
+ },
5270
+ }).headers.has('Content-Type');
5227
5271
 
5228
- isFetchSupported && (((res) => {
5229
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
5230
- !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
5231
- (_, config) => {
5232
- throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
5233
- });
5272
+ return duplexAccessed && !hasContentType;
5234
5273
  });
5235
- })(new Response));
5236
5274
 
5237
- const getBodyLength = async (body) => {
5238
- if (body == null) {
5239
- return 0;
5240
- }
5275
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
5276
+ test(() => utils$1.isReadableStream(new Response('').body));
5241
5277
 
5242
- if(utils$1.isBlob(body)) {
5243
- return body.size;
5244
- }
5278
+ const resolvers = {
5279
+ stream: supportsResponseStream && ((res) => res.body)
5280
+ };
5245
5281
 
5246
- if(utils$1.isSpecCompliantForm(body)) {
5247
- const _request = new Request(platform.origin, {
5248
- method: 'POST',
5249
- body,
5282
+ isFetchSupported && ((() => {
5283
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
5284
+ !resolvers[type] && (resolvers[type] = (res, config) => {
5285
+ let method = res && res[type];
5286
+
5287
+ if (method) {
5288
+ return method.call(res);
5289
+ }
5290
+
5291
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
5292
+ });
5250
5293
  });
5251
- return (await _request.arrayBuffer()).byteLength;
5252
- }
5294
+ })());
5253
5295
 
5254
- if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
5255
- return body.byteLength;
5256
- }
5296
+ const getBodyLength = async (body) => {
5297
+ if (body == null) {
5298
+ return 0;
5299
+ }
5257
5300
 
5258
- if(utils$1.isURLSearchParams(body)) {
5259
- body = body + '';
5260
- }
5301
+ if (utils$1.isBlob(body)) {
5302
+ return body.size;
5303
+ }
5261
5304
 
5262
- if(utils$1.isString(body)) {
5263
- return (await encodeText(body)).byteLength;
5264
- }
5265
- };
5305
+ if (utils$1.isSpecCompliantForm(body)) {
5306
+ const _request = new Request(platform.origin, {
5307
+ method: 'POST',
5308
+ body,
5309
+ });
5310
+ return (await _request.arrayBuffer()).byteLength;
5311
+ }
5266
5312
 
5267
- const resolveBodyLength = async (headers, body) => {
5268
- const length = utils$1.toFiniteNumber(headers.getContentLength());
5313
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
5314
+ return body.byteLength;
5315
+ }
5269
5316
 
5270
- return length == null ? getBodyLength(body) : length;
5271
- };
5317
+ if (utils$1.isURLSearchParams(body)) {
5318
+ body = body + '';
5319
+ }
5320
+
5321
+ if (utils$1.isString(body)) {
5322
+ return (await encodeText(body)).byteLength;
5323
+ }
5324
+ };
5325
+
5326
+ const resolveBodyLength = async (headers, body) => {
5327
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
5328
+
5329
+ return length == null ? getBodyLength(body) : length;
5330
+ };
5331
+
5332
+ return async (config) => {
5333
+ let {
5334
+ url,
5335
+ method,
5336
+ data,
5337
+ signal,
5338
+ cancelToken,
5339
+ timeout,
5340
+ onDownloadProgress,
5341
+ onUploadProgress,
5342
+ responseType,
5343
+ headers,
5344
+ withCredentials = 'same-origin',
5345
+ fetchOptions
5346
+ } = resolveConfig(config);
5347
+
5348
+ let _fetch = envFetch || fetch;
5272
5349
 
5273
- var fetchAdapter = isFetchSupported && (async (config) => {
5274
- let {
5275
- url,
5276
- method,
5277
- data,
5278
- signal,
5279
- cancelToken,
5280
- timeout,
5281
- onDownloadProgress,
5282
- onUploadProgress,
5283
- responseType,
5284
- headers,
5285
- withCredentials = 'same-origin',
5286
- fetchOptions
5287
- } = resolveConfig(config);
5288
-
5289
- responseType = responseType ? (responseType + '').toLowerCase() : 'text';
5290
-
5291
- let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
5292
-
5293
- let request;
5294
-
5295
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
5350
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
5351
+
5352
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
5353
+
5354
+ let request = null;
5355
+
5356
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
5296
5357
  composedSignal.unsubscribe();
5297
- });
5358
+ });
5298
5359
 
5299
- let requestContentLength;
5360
+ let requestContentLength;
5300
5361
 
5301
- try {
5302
- if (
5303
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
5304
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
5305
- ) {
5306
- let _request = new Request(url, {
5307
- method: 'POST',
5308
- body: data,
5309
- duplex: "half"
5310
- });
5362
+ try {
5363
+ if (
5364
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
5365
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
5366
+ ) {
5367
+ let _request = new Request(url, {
5368
+ method: 'POST',
5369
+ body: data,
5370
+ duplex: "half"
5371
+ });
5311
5372
 
5312
- let contentTypeHeader;
5373
+ let contentTypeHeader;
5313
5374
 
5314
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
5315
- headers.setContentType(contentTypeHeader);
5316
- }
5375
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
5376
+ headers.setContentType(contentTypeHeader);
5377
+ }
5317
5378
 
5318
- if (_request.body) {
5319
- const [onProgress, flush] = progressEventDecorator(
5320
- requestContentLength,
5321
- progressEventReducer(asyncDecorator(onUploadProgress))
5322
- );
5379
+ if (_request.body) {
5380
+ const [onProgress, flush] = progressEventDecorator(
5381
+ requestContentLength,
5382
+ progressEventReducer(asyncDecorator(onUploadProgress))
5383
+ );
5323
5384
 
5324
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
5385
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
5386
+ }
5325
5387
  }
5326
- }
5327
5388
 
5328
- if (!utils$1.isString(withCredentials)) {
5329
- withCredentials = withCredentials ? 'include' : 'omit';
5330
- }
5389
+ if (!utils$1.isString(withCredentials)) {
5390
+ withCredentials = withCredentials ? 'include' : 'omit';
5391
+ }
5331
5392
 
5332
- // Cloudflare Workers throws when credentials are defined
5333
- // see https://github.com/cloudflare/workerd/issues/902
5334
- const isCredentialsSupported = "credentials" in Request.prototype;
5335
- request = new Request(url, {
5336
- ...fetchOptions,
5337
- signal: composedSignal,
5338
- method: method.toUpperCase(),
5339
- headers: headers.normalize().toJSON(),
5340
- body: data,
5341
- duplex: "half",
5342
- credentials: isCredentialsSupported ? withCredentials : undefined
5343
- });
5393
+ // Cloudflare Workers throws when credentials are defined
5394
+ // see https://github.com/cloudflare/workerd/issues/902
5395
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
5344
5396
 
5345
- let response = await fetch(request, fetchOptions);
5397
+ const resolvedOptions = {
5398
+ ...fetchOptions,
5399
+ signal: composedSignal,
5400
+ method: method.toUpperCase(),
5401
+ headers: headers.normalize().toJSON(),
5402
+ body: data,
5403
+ duplex: "half",
5404
+ credentials: isCredentialsSupported ? withCredentials : undefined
5405
+ };
5346
5406
 
5347
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
5407
+ request = isRequestSupported && new Request(url, resolvedOptions);
5348
5408
 
5349
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
5350
- const options = {};
5409
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
5351
5410
 
5352
- ['status', 'statusText', 'headers'].forEach(prop => {
5353
- options[prop] = response[prop];
5354
- });
5411
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
5355
5412
 
5356
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
5413
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
5414
+ const options = {};
5357
5415
 
5358
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
5359
- responseContentLength,
5360
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
5361
- ) || [];
5416
+ ['status', 'statusText', 'headers'].forEach(prop => {
5417
+ options[prop] = response[prop];
5418
+ });
5362
5419
 
5363
- response = new Response(
5364
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
5365
- flush && flush();
5366
- unsubscribe && unsubscribe();
5367
- }),
5368
- options
5369
- );
5370
- }
5420
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
5371
5421
 
5372
- responseType = responseType || 'text';
5422
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
5423
+ responseContentLength,
5424
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
5425
+ ) || [];
5373
5426
 
5374
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
5427
+ response = new Response(
5428
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
5429
+ flush && flush();
5430
+ unsubscribe && unsubscribe();
5431
+ }),
5432
+ options
5433
+ );
5434
+ }
5375
5435
 
5376
- !isStreamResponse && unsubscribe && unsubscribe();
5436
+ responseType = responseType || 'text';
5377
5437
 
5378
- return await new Promise((resolve, reject) => {
5379
- settle(resolve, reject, {
5380
- data: responseData,
5381
- headers: AxiosHeaders$1.from(response.headers),
5382
- status: response.status,
5383
- statusText: response.statusText,
5384
- config,
5385
- request
5386
- });
5387
- })
5388
- } catch (err) {
5389
- unsubscribe && unsubscribe();
5438
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
5390
5439
 
5391
- if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
5392
- throw Object.assign(
5393
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
5394
- {
5395
- cause: err.cause || err
5396
- }
5397
- )
5440
+ !isStreamResponse && unsubscribe && unsubscribe();
5441
+
5442
+ return await new Promise((resolve, reject) => {
5443
+ settle(resolve, reject, {
5444
+ data: responseData,
5445
+ headers: AxiosHeaders$1.from(response.headers),
5446
+ status: response.status,
5447
+ statusText: response.statusText,
5448
+ config,
5449
+ request
5450
+ });
5451
+ })
5452
+ } catch (err) {
5453
+ unsubscribe && unsubscribe();
5454
+
5455
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
5456
+ throw Object.assign(
5457
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
5458
+ {
5459
+ cause: err.cause || err
5460
+ }
5461
+ )
5462
+ }
5463
+
5464
+ throw AxiosError.from(err, err && err.code, config, request);
5398
5465
  }
5466
+ }
5467
+ };
5468
+
5469
+ const seedCache = new Map();
5470
+
5471
+ const getFetch = (config) => {
5472
+ let env = (config && config.env) || {};
5473
+ const {fetch, Request, Response} = env;
5474
+ const seeds = [
5475
+ Request, Response, fetch
5476
+ ];
5477
+
5478
+ let len = seeds.length, i = len,
5479
+ seed, target, map = seedCache;
5480
+
5481
+ while (i--) {
5482
+ seed = seeds[i];
5483
+ target = map.get(seed);
5484
+
5485
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
5399
5486
 
5400
- throw AxiosError.from(err, err && err.code, config, request);
5487
+ map = target;
5401
5488
  }
5402
- });
5403
5489
 
5490
+ return target;
5491
+ };
5492
+
5493
+ getFetch();
5494
+
5495
+ /**
5496
+ * Known adapters mapping.
5497
+ * Provides environment-specific adapters for Axios:
5498
+ * - `http` for Node.js
5499
+ * - `xhr` for browsers
5500
+ * - `fetch` for fetch API-based requests
5501
+ *
5502
+ * @type {Object<string, Function|Object>}
5503
+ */
5404
5504
  const knownAdapters = {
5405
5505
  http: httpAdapter,
5406
5506
  xhr: xhrAdapter,
5407
- fetch: fetchAdapter
5507
+ fetch: {
5508
+ get: getFetch,
5509
+ }
5408
5510
  };
5409
5511
 
5512
+ // Assign adapter names for easier debugging and identification
5410
5513
  utils$1.forEach(knownAdapters, (fn, value) => {
5411
5514
  if (fn) {
5412
5515
  try {
5413
- Object.defineProperty(fn, 'name', {value});
5516
+ Object.defineProperty(fn, 'name', { value });
5414
5517
  } catch (e) {
5415
5518
  // eslint-disable-next-line no-empty
5416
5519
  }
5417
- Object.defineProperty(fn, 'adapterName', {value});
5520
+ Object.defineProperty(fn, 'adapterName', { value });
5418
5521
  }
5419
5522
  });
5420
5523
 
5524
+ /**
5525
+ * Render a rejection reason string for unknown or unsupported adapters
5526
+ *
5527
+ * @param {string} reason
5528
+ * @returns {string}
5529
+ */
5421
5530
  const renderReason = (reason) => `- ${reason}`;
5422
5531
 
5532
+ /**
5533
+ * Check if the adapter is resolved (function, null, or false)
5534
+ *
5535
+ * @param {Function|null|false} adapter
5536
+ * @returns {boolean}
5537
+ */
5423
5538
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
5424
5539
 
5425
- var adapters = {
5426
- getAdapter: (adapters) => {
5427
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
5428
-
5429
- const {length} = adapters;
5430
- let nameOrAdapter;
5431
- let adapter;
5540
+ /**
5541
+ * Get the first suitable adapter from the provided list.
5542
+ * Tries each adapter in order until a supported one is found.
5543
+ * Throws an AxiosError if no adapter is suitable.
5544
+ *
5545
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
5546
+ * @param {Object} config - Axios request configuration
5547
+ * @throws {AxiosError} If no suitable adapter is available
5548
+ * @returns {Function} The resolved adapter function
5549
+ */
5550
+ function getAdapter(adapters, config) {
5551
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
5432
5552
 
5433
- const rejectedReasons = {};
5553
+ const { length } = adapters;
5554
+ let nameOrAdapter;
5555
+ let adapter;
5434
5556
 
5435
- for (let i = 0; i < length; i++) {
5436
- nameOrAdapter = adapters[i];
5437
- let id;
5557
+ const rejectedReasons = {};
5438
5558
 
5439
- adapter = nameOrAdapter;
5559
+ for (let i = 0; i < length; i++) {
5560
+ nameOrAdapter = adapters[i];
5561
+ let id;
5440
5562
 
5441
- if (!isResolvedHandle(nameOrAdapter)) {
5442
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
5563
+ adapter = nameOrAdapter;
5443
5564
 
5444
- if (adapter === undefined) {
5445
- throw new AxiosError(`Unknown adapter '${id}'`);
5446
- }
5447
- }
5565
+ if (!isResolvedHandle(nameOrAdapter)) {
5566
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
5448
5567
 
5449
- if (adapter) {
5450
- break;
5568
+ if (adapter === undefined) {
5569
+ throw new AxiosError(`Unknown adapter '${id}'`);
5451
5570
  }
5571
+ }
5452
5572
 
5453
- rejectedReasons[id || '#' + i] = adapter;
5573
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
5574
+ break;
5454
5575
  }
5455
5576
 
5456
- if (!adapter) {
5577
+ rejectedReasons[id || '#' + i] = adapter;
5578
+ }
5457
5579
 
5458
- const reasons = Object.entries(rejectedReasons)
5459
- .map(([id, state]) => `adapter ${id} ` +
5460
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
5461
- );
5580
+ if (!adapter) {
5581
+ const reasons = Object.entries(rejectedReasons)
5582
+ .map(([id, state]) => `adapter ${id} ` +
5583
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
5584
+ );
5462
5585
 
5463
- let s = length ?
5464
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
5465
- 'as no adapter specified';
5586
+ let s = length ?
5587
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
5588
+ 'as no adapter specified';
5466
5589
 
5467
- throw new AxiosError(
5468
- `There is no suitable adapter to dispatch the request ` + s,
5469
- 'ERR_NOT_SUPPORT'
5470
- );
5471
- }
5590
+ throw new AxiosError(
5591
+ `There is no suitable adapter to dispatch the request ` + s,
5592
+ 'ERR_NOT_SUPPORT'
5593
+ );
5594
+ }
5472
5595
 
5473
- return adapter;
5474
- },
5596
+ return adapter;
5597
+ }
5598
+
5599
+ /**
5600
+ * Exports Axios adapters and utility to resolve an adapter
5601
+ */
5602
+ var adapters = {
5603
+ /**
5604
+ * Resolve an adapter from a list of adapter names or functions.
5605
+ * @type {Function}
5606
+ */
5607
+ getAdapter,
5608
+
5609
+ /**
5610
+ * Exposes all known adapters
5611
+ * @type {Object<string, Function|Object>}
5612
+ */
5475
5613
  adapters: knownAdapters
5476
5614
  };
5477
5615
 
@@ -5514,7 +5652,7 @@ function dispatchRequest(config) {
5514
5652
  config.headers.setContentType('application/x-www-form-urlencoded', false);
5515
5653
  }
5516
5654
 
5517
- const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
5655
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
5518
5656
 
5519
5657
  return adapter(config).then(function onAdapterResolution(response) {
5520
5658
  throwIfCancellationRequested(config);
@@ -5548,7 +5686,7 @@ function dispatchRequest(config) {
5548
5686
  });
5549
5687
  }
5550
5688
 
5551
- const VERSION = "1.11.0";
5689
+ const VERSION = "1.13.2";
5552
5690
 
5553
5691
  const validators$1 = {};
5554
5692
 
@@ -5804,8 +5942,6 @@ class Axios {
5804
5942
 
5805
5943
  let newConfig = config;
5806
5944
 
5807
- i = 0;
5808
-
5809
5945
  while (i < len) {
5810
5946
  const onFulfilled = requestInterceptorChain[i++];
5811
5947
  const onRejected = requestInterceptorChain[i++];
@@ -6109,6 +6245,12 @@ const HttpStatusCode = {
6109
6245
  LoopDetected: 508,
6110
6246
  NotExtended: 510,
6111
6247
  NetworkAuthenticationRequired: 511,
6248
+ WebServerIsDown: 521,
6249
+ ConnectionTimedOut: 522,
6250
+ OriginIsUnreachable: 523,
6251
+ TimeoutOccurred: 524,
6252
+ SslHandshakeFailed: 525,
6253
+ InvalidSslCertificate: 526,
6112
6254
  };
6113
6255
 
6114
6256
  Object.entries(HttpStatusCode).forEach(([key, value]) => {