@jjrawlins/cdk-iam-policy-builder-helper 0.0.23 → 0.0.24

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.
Files changed (57) hide show
  1. package/.jsii +3 -3
  2. package/cdk-iam-policy-builder-helper/go.mod +1 -1
  3. package/cdk-iam-policy-builder-helper/jsii/jsii.go +2 -2
  4. package/cdk-iam-policy-builder-helper/version +1 -1
  5. package/methods_list.txt +6 -0
  6. package/node_modules/@aws-sdk/client-iam/package.json +38 -38
  7. package/node_modules/@aws-sdk/client-sso/package.json +36 -36
  8. package/node_modules/@aws-sdk/core/package.json +12 -12
  9. package/node_modules/@aws-sdk/credential-provider-env/package.json +4 -4
  10. package/node_modules/@aws-sdk/credential-provider-http/package.json +9 -9
  11. package/node_modules/@aws-sdk/credential-provider-ini/package.json +10 -10
  12. package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
  13. package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
  14. package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
  15. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +5 -5
  16. package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
  17. package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
  18. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
  19. package/node_modules/@aws-sdk/middleware-user-agent/package.json +7 -7
  20. package/node_modules/@aws-sdk/nested-clients/package.json +36 -36
  21. package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
  22. package/node_modules/@aws-sdk/token-providers/package.json +5 -5
  23. package/node_modules/@aws-sdk/types/package.json +2 -2
  24. package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
  25. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
  26. package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
  27. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  28. package/node_modules/axios/CHANGELOG.md +35 -0
  29. package/node_modules/axios/README.md +13 -10
  30. package/node_modules/axios/dist/axios.js +358 -289
  31. package/node_modules/axios/dist/axios.js.map +1 -1
  32. package/node_modules/axios/dist/axios.min.js +2 -2
  33. package/node_modules/axios/dist/axios.min.js.map +1 -1
  34. package/node_modules/axios/dist/browser/axios.cjs +286 -211
  35. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  36. package/node_modules/axios/dist/esm/axios.js +286 -211
  37. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  38. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  39. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  40. package/node_modules/axios/dist/node/axios.cjs +377 -211
  41. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  42. package/node_modules/axios/index.d.cts +9 -5
  43. package/node_modules/axios/index.d.ts +10 -4
  44. package/node_modules/axios/lib/adapters/adapters.js +6 -4
  45. package/node_modules/axios/lib/adapters/fetch.js +220 -163
  46. package/node_modules/axios/lib/adapters/http.js +18 -0
  47. package/node_modules/axios/lib/adapters/xhr.js +11 -8
  48. package/node_modules/axios/lib/core/AxiosError.js +10 -3
  49. package/node_modules/axios/lib/core/dispatchRequest.js +1 -1
  50. package/node_modules/axios/lib/defaults/index.js +1 -1
  51. package/node_modules/axios/lib/env/data.js +1 -1
  52. package/node_modules/axios/lib/helpers/buildURL.js +1 -3
  53. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +73 -0
  54. package/node_modules/axios/lib/helpers/resolveConfig.js +13 -9
  55. package/node_modules/axios/lib/utils.js +7 -3
  56. package/node_modules/axios/package.json +12 -9
  57. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- /*! Axios v1.11.0 Copyright (c) 2025 Matt Zabriskie and contributors */
1
+ /*! Axios v1.12.0 Copyright (c) 2025 Matt Zabriskie and contributors */
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -77,7 +77,7 @@ const isUndefined = typeOfTest('undefined');
77
77
  */
78
78
  function isBuffer(val) {
79
79
  return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
80
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
80
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
81
81
  }
82
82
 
83
83
  /**
@@ -122,7 +122,7 @@ const isString = typeOfTest('string');
122
122
  * @param {*} val The value to test
123
123
  * @returns {boolean} True if value is a Function, otherwise false
124
124
  */
125
- const isFunction = typeOfTest('function');
125
+ const isFunction$1 = typeOfTest('function');
126
126
 
127
127
  /**
128
128
  * Determine if a value is a Number
@@ -178,7 +178,7 @@ const isEmptyObject = (val) => {
178
178
  if (!isObject(val) || isBuffer(val)) {
179
179
  return false;
180
180
  }
181
-
181
+
182
182
  try {
183
183
  return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
184
184
  } catch (e) {
@@ -230,7 +230,7 @@ const isFileList = kindOfTest('FileList');
230
230
  *
231
231
  * @returns {boolean} True if value is a Stream, otherwise false
232
232
  */
233
- const isStream = (val) => isObject(val) && isFunction(val.pipe);
233
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
234
234
 
235
235
  /**
236
236
  * Determine if a value is a FormData
@@ -243,10 +243,10 @@ const isFormData = (thing) => {
243
243
  let kind;
244
244
  return thing && (
245
245
  (typeof FormData === 'function' && thing instanceof FormData) || (
246
- isFunction(thing.append) && (
246
+ isFunction$1(thing.append) && (
247
247
  (kind = kindOf(thing)) === 'formdata' ||
248
248
  // detect form-data instance
249
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
249
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
250
250
  )
251
251
  )
252
252
  )
@@ -371,7 +371,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
371
371
  * @returns {Object} Result of all merge properties
372
372
  */
373
373
  function merge(/* obj1, obj2, obj3, ... */) {
374
- const {caseless} = isContextDefined(this) && this || {};
374
+ const {caseless, skipUndefined} = isContextDefined(this) && this || {};
375
375
  const result = {};
376
376
  const assignValue = (val, key) => {
377
377
  const targetKey = caseless && findKey(result, key) || key;
@@ -382,7 +382,9 @@ function merge(/* obj1, obj2, obj3, ... */) {
382
382
  } else if (isArray(val)) {
383
383
  result[targetKey] = val.slice();
384
384
  } else {
385
- result[targetKey] = val;
385
+ if (!skipUndefined || !isUndefined(val)) {
386
+ result[targetKey] = val;
387
+ }
386
388
  }
387
389
  };
388
390
 
@@ -404,7 +406,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
404
406
  */
405
407
  const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
406
408
  forEach(b, (val, key) => {
407
- if (thisArg && isFunction(val)) {
409
+ if (thisArg && isFunction$1(val)) {
408
410
  a[key] = bind(val, thisArg);
409
411
  } else {
410
412
  a[key] = val;
@@ -620,13 +622,13 @@ const reduceDescriptors = (obj, reducer) => {
620
622
  const freezeMethods = (obj) => {
621
623
  reduceDescriptors(obj, (descriptor, name) => {
622
624
  // skip restricted props in strict mode
623
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
625
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
624
626
  return false;
625
627
  }
626
628
 
627
629
  const value = obj[name];
628
630
 
629
- if (!isFunction(value)) return;
631
+ if (!isFunction$1(value)) return;
630
632
 
631
633
  descriptor.enumerable = false;
632
634
 
@@ -663,6 +665,8 @@ const toFiniteNumber = (value, defaultValue) => {
663
665
  return value != null && Number.isFinite(value = +value) ? value : defaultValue;
664
666
  };
665
667
 
668
+
669
+
666
670
  /**
667
671
  * If the thing is a FormData object, return true, otherwise return false.
668
672
  *
@@ -671,7 +675,7 @@ const toFiniteNumber = (value, defaultValue) => {
671
675
  * @returns {boolean}
672
676
  */
673
677
  function isSpecCompliantForm(thing) {
674
- return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
678
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
675
679
  }
676
680
 
677
681
  const toJSONObject = (obj) => {
@@ -713,7 +717,7 @@ const toJSONObject = (obj) => {
713
717
  const isAsyncFn = kindOfTest('AsyncFunction');
714
718
 
715
719
  const isThenable = (thing) =>
716
- thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
720
+ thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
717
721
 
718
722
  // original code
719
723
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -737,7 +741,7 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
737
741
  })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
738
742
  })(
739
743
  typeof setImmediate === 'function',
740
- isFunction(_global.postMessage)
744
+ isFunction$1(_global.postMessage)
741
745
  );
742
746
 
743
747
  const asap = typeof queueMicrotask !== 'undefined' ?
@@ -746,7 +750,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
746
750
  // *********************
747
751
 
748
752
 
749
- const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
753
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
750
754
 
751
755
 
752
756
  const utils$1 = {
@@ -770,7 +774,7 @@ const utils$1 = {
770
774
  isFile,
771
775
  isBlob,
772
776
  isRegExp,
773
- isFunction,
777
+ isFunction: isFunction$1,
774
778
  isStream,
775
779
  isURLSearchParams,
776
780
  isTypedArray,
@@ -896,11 +900,18 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
896
900
  return prop !== 'isAxiosError';
897
901
  });
898
902
 
899
- AxiosError.call(axiosError, error.message, code, config, request, response);
903
+ const msg = error && error.message ? error.message : 'Error';
900
904
 
901
- axiosError.cause = error;
905
+ // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
906
+ const errCode = code == null && error ? error.code : code;
907
+ AxiosError.call(axiosError, msg, errCode, config, request, response);
902
908
 
903
- axiosError.name = error.name;
909
+ // Chain the original error on the standard field; non-enumerable to avoid JSON noise
910
+ if (error && axiosError.cause == null) {
911
+ Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
912
+ }
913
+
914
+ axiosError.name = (error && error.name) || 'Error';
904
915
 
905
916
  customProps && Object.assign(axiosError, customProps);
906
917
 
@@ -1188,9 +1199,7 @@ function encode(val) {
1188
1199
  replace(/%3A/gi, ':').
1189
1200
  replace(/%24/g, '$').
1190
1201
  replace(/%2C/gi, ',').
1191
- replace(/%20/g, '+').
1192
- replace(/%5B/gi, '[').
1193
- replace(/%5D/gi, ']');
1202
+ replace(/%20/g, '+');
1194
1203
  }
1195
1204
 
1196
1205
  /**
@@ -1616,7 +1625,7 @@ const defaults = {
1616
1625
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
1617
1626
 
1618
1627
  try {
1619
- return JSON.parse(data);
1628
+ return JSON.parse(data, this.parseReviver);
1620
1629
  } catch (e) {
1621
1630
  if (strictJSONParsing) {
1622
1631
  if (e.name === 'SyntaxError') {
@@ -2143,7 +2152,7 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2143
2152
  return requestedURL;
2144
2153
  }
2145
2154
 
2146
- const VERSION = "1.11.0";
2155
+ const VERSION = "1.12.0";
2147
2156
 
2148
2157
  function parseProtocol(url) {
2149
2158
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2636,6 +2645,80 @@ const progressEventDecorator = (total, throttled) => {
2636
2645
 
2637
2646
  const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2638
2647
 
2648
+ /**
2649
+ * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
2650
+ * - For base64: compute exact decoded size using length and padding;
2651
+ * handle %XX at the character-count level (no string allocation).
2652
+ * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
2653
+ *
2654
+ * @param {string} url
2655
+ * @returns {number}
2656
+ */
2657
+ function estimateDataURLDecodedBytes(url) {
2658
+ if (!url || typeof url !== 'string') return 0;
2659
+ if (!url.startsWith('data:')) return 0;
2660
+
2661
+ const comma = url.indexOf(',');
2662
+ if (comma < 0) return 0;
2663
+
2664
+ const meta = url.slice(5, comma);
2665
+ const body = url.slice(comma + 1);
2666
+ const isBase64 = /;base64/i.test(meta);
2667
+
2668
+ if (isBase64) {
2669
+ let effectiveLen = body.length;
2670
+ const len = body.length; // cache length
2671
+
2672
+ for (let i = 0; i < len; i++) {
2673
+ if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
2674
+ const a = body.charCodeAt(i + 1);
2675
+ const b = body.charCodeAt(i + 2);
2676
+ const isHex =
2677
+ ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
2678
+ ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
2679
+
2680
+ if (isHex) {
2681
+ effectiveLen -= 2;
2682
+ i += 2;
2683
+ }
2684
+ }
2685
+ }
2686
+
2687
+ let pad = 0;
2688
+ let idx = len - 1;
2689
+
2690
+ const tailIsPct3D = (j) =>
2691
+ j >= 2 &&
2692
+ body.charCodeAt(j - 2) === 37 && // '%'
2693
+ body.charCodeAt(j - 1) === 51 && // '3'
2694
+ (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
2695
+
2696
+ if (idx >= 0) {
2697
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
2698
+ pad++;
2699
+ idx--;
2700
+ } else if (tailIsPct3D(idx)) {
2701
+ pad++;
2702
+ idx -= 3;
2703
+ }
2704
+ }
2705
+
2706
+ if (pad === 1 && idx >= 0) {
2707
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
2708
+ pad++;
2709
+ } else if (tailIsPct3D(idx)) {
2710
+ pad++;
2711
+ }
2712
+ }
2713
+
2714
+ const groups = Math.floor(effectiveLen / 4);
2715
+ const bytes = groups * 3 - (pad || 0);
2716
+ return bytes > 0 ? bytes : 0;
2717
+ }
2718
+
2719
+ return Buffer.byteLength(body, 'utf8');
2720
+ }
2721
+
2639
2722
  const zlibOptions = {
2640
2723
  flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
2641
2724
  finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
@@ -2656,6 +2739,7 @@ const supportedProtocols = platform.protocols.map(protocol => {
2656
2739
  return protocol + ':';
2657
2740
  });
2658
2741
 
2742
+
2659
2743
  const flushOnFinish = (stream, [throttled, flush]) => {
2660
2744
  stream
2661
2745
  .on('end', flush)
@@ -2664,6 +2748,7 @@ const flushOnFinish = (stream, [throttled, flush]) => {
2664
2748
  return throttled;
2665
2749
  };
2666
2750
 
2751
+
2667
2752
  /**
2668
2753
  * If the proxy or config beforeRedirects functions are defined, call them with the options
2669
2754
  * object.
@@ -2843,6 +2928,21 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2843
2928
  const protocol = parsed.protocol || supportedProtocols[0];
2844
2929
 
2845
2930
  if (protocol === 'data:') {
2931
+ // Apply the same semantics as HTTP: only enforce if a finite, non-negative cap is set.
2932
+ if (config.maxContentLength > -1) {
2933
+ // Use the exact string passed to fromDataURI (config.url); fall back to fullPath if needed.
2934
+ const dataUrl = String(config.url || fullPath || '');
2935
+ const estimated = estimateDataURLDecodedBytes(dataUrl);
2936
+
2937
+ if (estimated > config.maxContentLength) {
2938
+ return reject(new AxiosError(
2939
+ 'maxContentLength size of ' + config.maxContentLength + ' exceeded',
2940
+ AxiosError.ERR_BAD_RESPONSE,
2941
+ config
2942
+ ));
2943
+ }
2944
+ }
2945
+
2846
2946
  let convertedData;
2847
2947
 
2848
2948
  if (method !== 'GET') {
@@ -3457,7 +3557,7 @@ function mergeConfig(config1, config2) {
3457
3557
  const resolveConfig = (config) => {
3458
3558
  const newConfig = mergeConfig({}, config);
3459
3559
 
3460
- let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
3560
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3461
3561
 
3462
3562
  newConfig.headers = headers = AxiosHeaders$1.from(headers);
3463
3563
 
@@ -3470,17 +3570,21 @@ const resolveConfig = (config) => {
3470
3570
  );
3471
3571
  }
3472
3572
 
3473
- let contentType;
3474
-
3475
3573
  if (utils$1.isFormData(data)) {
3476
3574
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
3477
- headers.setContentType(undefined); // Let the browser set it
3478
- } else if ((contentType = headers.getContentType()) !== false) {
3479
- // fix semicolon duplication issue for ReactNative FormData implementation
3480
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
3481
- headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
3575
+ headers.setContentType(undefined); // browser handles it
3576
+ } else if (utils$1.isFunction(data.getHeaders)) {
3577
+ // Node.js FormData (like form-data package)
3578
+ const formHeaders = data.getHeaders();
3579
+ // Only set safe headers to avoid overwriting security headers
3580
+ const allowedHeaders = ['content-type', 'content-length'];
3581
+ Object.entries(formHeaders).forEach(([key, val]) => {
3582
+ if (allowedHeaders.includes(key.toLowerCase())) {
3583
+ headers.set(key, val);
3584
+ }
3585
+ });
3482
3586
  }
3483
- }
3587
+ }
3484
3588
 
3485
3589
  // Add xsrf header
3486
3590
  // This is only done if running in a standard browser environment.
@@ -3597,15 +3701,18 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3597
3701
  };
3598
3702
 
3599
3703
  // Handle low level network errors
3600
- request.onerror = function handleError() {
3601
- // Real errors are hidden from us by the browser
3602
- // onerror should only fire if it's a network error
3603
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
3604
-
3605
- // Clean up request
3606
- request = null;
3704
+ request.onerror = function handleError(event) {
3705
+ // Browsers deliver a ProgressEvent in XHR onerror
3706
+ // (message may be empty; when present, surface it)
3707
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
3708
+ const msg = event && event.message ? event.message : 'Network Error';
3709
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
3710
+ // attach the underlying event for consumers who want details
3711
+ err.event = event || null;
3712
+ reject(err);
3713
+ request = null;
3607
3714
  };
3608
-
3715
+
3609
3716
  // Handle timeout
3610
3717
  request.ontimeout = function handleTimeout() {
3611
3718
  let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
@@ -3821,14 +3928,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3821
3928
  })
3822
3929
  };
3823
3930
 
3824
- const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
3825
- const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
3931
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3932
+
3933
+ const {isFunction} = utils$1;
3934
+
3935
+ const globalFetchAPI = (({fetch, Request, Response}) => ({
3936
+ fetch, Request, Response
3937
+ }))(utils$1.global);
3938
+
3939
+ const {
3940
+ ReadableStream: ReadableStream$1, TextEncoder: TextEncoder$1
3941
+ } = utils$1.global;
3826
3942
 
3827
- // used only inside the fetch adapter
3828
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3829
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3830
- async (str) => new Uint8Array(await new Response(str).arrayBuffer())
3831
- );
3832
3943
 
3833
3944
  const test = (fn, ...args) => {
3834
3945
  try {
@@ -3838,211 +3949,266 @@ const test = (fn, ...args) => {
3838
3949
  }
3839
3950
  };
3840
3951
 
3841
- const supportsRequestStream = isReadableStreamSupported && test(() => {
3842
- let duplexAccessed = false;
3952
+ const factory = (env) => {
3953
+ const {fetch, Request, Response} = Object.assign({}, globalFetchAPI, env);
3954
+ const isFetchSupported = isFunction(fetch);
3955
+ const isRequestSupported = isFunction(Request);
3956
+ const isResponseSupported = isFunction(Response);
3843
3957
 
3844
- const hasContentType = new Request(platform.origin, {
3845
- body: new ReadableStream(),
3846
- method: 'POST',
3847
- get duplex() {
3848
- duplexAccessed = true;
3849
- return 'half';
3850
- },
3851
- }).headers.has('Content-Type');
3958
+ if (!isFetchSupported) {
3959
+ return false;
3960
+ }
3852
3961
 
3853
- return duplexAccessed && !hasContentType;
3854
- });
3962
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3855
3963
 
3856
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
3964
+ const encodeText = isFetchSupported && (typeof TextEncoder$1 === 'function' ?
3965
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder$1()) :
3966
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
3967
+ );
3857
3968
 
3858
- const supportsResponseStream = isReadableStreamSupported &&
3859
- test(() => utils$1.isReadableStream(new Response('').body));
3969
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3970
+ let duplexAccessed = false;
3860
3971
 
3972
+ const hasContentType = new Request(platform.origin, {
3973
+ body: new ReadableStream$1(),
3974
+ method: 'POST',
3975
+ get duplex() {
3976
+ duplexAccessed = true;
3977
+ return 'half';
3978
+ },
3979
+ }).headers.has('Content-Type');
3861
3980
 
3862
- const resolvers = {
3863
- stream: supportsResponseStream && ((res) => res.body)
3864
- };
3981
+ return duplexAccessed && !hasContentType;
3982
+ });
3983
+
3984
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
3985
+ test(() => utils$1.isReadableStream(new Response('').body));
3986
+
3987
+ const resolvers = {
3988
+ stream: supportsResponseStream && ((res) => res.body)
3989
+ };
3990
+
3991
+ isFetchSupported && ((() => {
3992
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3993
+ !resolvers[type] && (resolvers[type] = (res, config) => {
3994
+ let method = res && res[type];
3995
+
3996
+ if (method) {
3997
+ return method.call(res);
3998
+ }
3865
3999
 
3866
- isFetchSupported && (((res) => {
3867
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3868
- !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
3869
- (_, config) => {
3870
4000
  throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
3871
4001
  });
3872
- });
3873
- })(new Response));
4002
+ });
4003
+ })());
3874
4004
 
3875
- const getBodyLength = async (body) => {
3876
- if (body == null) {
3877
- return 0;
3878
- }
4005
+ const getBodyLength = async (body) => {
4006
+ if (body == null) {
4007
+ return 0;
4008
+ }
3879
4009
 
3880
- if(utils$1.isBlob(body)) {
3881
- return body.size;
3882
- }
4010
+ if (utils$1.isBlob(body)) {
4011
+ return body.size;
4012
+ }
3883
4013
 
3884
- if(utils$1.isSpecCompliantForm(body)) {
3885
- const _request = new Request(platform.origin, {
3886
- method: 'POST',
3887
- body,
3888
- });
3889
- return (await _request.arrayBuffer()).byteLength;
3890
- }
4014
+ if (utils$1.isSpecCompliantForm(body)) {
4015
+ const _request = new Request(platform.origin, {
4016
+ method: 'POST',
4017
+ body,
4018
+ });
4019
+ return (await _request.arrayBuffer()).byteLength;
4020
+ }
3891
4021
 
3892
- if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3893
- return body.byteLength;
3894
- }
4022
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
4023
+ return body.byteLength;
4024
+ }
3895
4025
 
3896
- if(utils$1.isURLSearchParams(body)) {
3897
- body = body + '';
3898
- }
4026
+ if (utils$1.isURLSearchParams(body)) {
4027
+ body = body + '';
4028
+ }
3899
4029
 
3900
- if(utils$1.isString(body)) {
3901
- return (await encodeText(body)).byteLength;
3902
- }
3903
- };
4030
+ if (utils$1.isString(body)) {
4031
+ return (await encodeText(body)).byteLength;
4032
+ }
4033
+ };
3904
4034
 
3905
- const resolveBodyLength = async (headers, body) => {
3906
- const length = utils$1.toFiniteNumber(headers.getContentLength());
4035
+ const resolveBodyLength = async (headers, body) => {
4036
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3907
4037
 
3908
- return length == null ? getBodyLength(body) : length;
3909
- };
4038
+ return length == null ? getBodyLength(body) : length;
4039
+ };
4040
+
4041
+ return async (config) => {
4042
+ let {
4043
+ url,
4044
+ method,
4045
+ data,
4046
+ signal,
4047
+ cancelToken,
4048
+ timeout,
4049
+ onDownloadProgress,
4050
+ onUploadProgress,
4051
+ responseType,
4052
+ headers,
4053
+ withCredentials = 'same-origin',
4054
+ fetchOptions
4055
+ } = resolveConfig(config);
4056
+
4057
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3910
4058
 
3911
- const fetchAdapter = isFetchSupported && (async (config) => {
3912
- let {
3913
- url,
3914
- method,
3915
- data,
3916
- signal,
3917
- cancelToken,
3918
- timeout,
3919
- onDownloadProgress,
3920
- onUploadProgress,
3921
- responseType,
3922
- headers,
3923
- withCredentials = 'same-origin',
3924
- fetchOptions
3925
- } = resolveConfig(config);
3926
-
3927
- responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3928
-
3929
- let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3930
-
3931
- let request;
3932
-
3933
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
4059
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
4060
+
4061
+ let request = null;
4062
+
4063
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3934
4064
  composedSignal.unsubscribe();
3935
- });
4065
+ });
3936
4066
 
3937
- let requestContentLength;
4067
+ let requestContentLength;
3938
4068
 
3939
- try {
3940
- if (
3941
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3942
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3943
- ) {
3944
- let _request = new Request(url, {
3945
- method: 'POST',
3946
- body: data,
3947
- duplex: "half"
3948
- });
4069
+ try {
4070
+ if (
4071
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
4072
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
4073
+ ) {
4074
+ let _request = new Request(url, {
4075
+ method: 'POST',
4076
+ body: data,
4077
+ duplex: "half"
4078
+ });
3949
4079
 
3950
- let contentTypeHeader;
4080
+ let contentTypeHeader;
3951
4081
 
3952
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3953
- headers.setContentType(contentTypeHeader);
3954
- }
4082
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
4083
+ headers.setContentType(contentTypeHeader);
4084
+ }
3955
4085
 
3956
- if (_request.body) {
3957
- const [onProgress, flush] = progressEventDecorator(
3958
- requestContentLength,
3959
- progressEventReducer(asyncDecorator(onUploadProgress))
3960
- );
4086
+ if (_request.body) {
4087
+ const [onProgress, flush] = progressEventDecorator(
4088
+ requestContentLength,
4089
+ progressEventReducer(asyncDecorator(onUploadProgress))
4090
+ );
3961
4091
 
3962
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
4092
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
4093
+ }
3963
4094
  }
3964
- }
3965
4095
 
3966
- if (!utils$1.isString(withCredentials)) {
3967
- withCredentials = withCredentials ? 'include' : 'omit';
3968
- }
4096
+ if (!utils$1.isString(withCredentials)) {
4097
+ withCredentials = withCredentials ? 'include' : 'omit';
4098
+ }
3969
4099
 
3970
- // Cloudflare Workers throws when credentials are defined
3971
- // see https://github.com/cloudflare/workerd/issues/902
3972
- const isCredentialsSupported = "credentials" in Request.prototype;
3973
- request = new Request(url, {
3974
- ...fetchOptions,
3975
- signal: composedSignal,
3976
- method: method.toUpperCase(),
3977
- headers: headers.normalize().toJSON(),
3978
- body: data,
3979
- duplex: "half",
3980
- credentials: isCredentialsSupported ? withCredentials : undefined
3981
- });
4100
+ // Cloudflare Workers throws when credentials are defined
4101
+ // see https://github.com/cloudflare/workerd/issues/902
4102
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3982
4103
 
3983
- let response = await fetch(request, fetchOptions);
4104
+ const resolvedOptions = {
4105
+ ...fetchOptions,
4106
+ signal: composedSignal,
4107
+ method: method.toUpperCase(),
4108
+ headers: headers.normalize().toJSON(),
4109
+ body: data,
4110
+ duplex: "half",
4111
+ credentials: isCredentialsSupported ? withCredentials : undefined
4112
+ };
3984
4113
 
3985
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
4114
+ request = isRequestSupported && new Request(url, resolvedOptions);
3986
4115
 
3987
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3988
- const options = {};
4116
+ let response = await (isRequestSupported ? fetch(request, fetchOptions) : fetch(url, resolvedOptions));
3989
4117
 
3990
- ['status', 'statusText', 'headers'].forEach(prop => {
3991
- options[prop] = response[prop];
3992
- });
4118
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3993
4119
 
3994
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
4120
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
4121
+ const options = {};
3995
4122
 
3996
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3997
- responseContentLength,
3998
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
3999
- ) || [];
4123
+ ['status', 'statusText', 'headers'].forEach(prop => {
4124
+ options[prop] = response[prop];
4125
+ });
4000
4126
 
4001
- response = new Response(
4002
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
4003
- flush && flush();
4004
- unsubscribe && unsubscribe();
4005
- }),
4006
- options
4007
- );
4008
- }
4127
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
4009
4128
 
4010
- responseType = responseType || 'text';
4129
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
4130
+ responseContentLength,
4131
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
4132
+ ) || [];
4011
4133
 
4012
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
4134
+ response = new Response(
4135
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
4136
+ flush && flush();
4137
+ unsubscribe && unsubscribe();
4138
+ }),
4139
+ options
4140
+ );
4141
+ }
4013
4142
 
4014
- !isStreamResponse && unsubscribe && unsubscribe();
4143
+ responseType = responseType || 'text';
4015
4144
 
4016
- return await new Promise((resolve, reject) => {
4017
- settle(resolve, reject, {
4018
- data: responseData,
4019
- headers: AxiosHeaders$1.from(response.headers),
4020
- status: response.status,
4021
- statusText: response.statusText,
4022
- config,
4023
- request
4024
- });
4025
- })
4026
- } catch (err) {
4027
- unsubscribe && unsubscribe();
4028
-
4029
- if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
4030
- throw Object.assign(
4031
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
4032
- {
4033
- cause: err.cause || err
4034
- }
4035
- )
4145
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
4146
+
4147
+ !isStreamResponse && unsubscribe && unsubscribe();
4148
+
4149
+ return await new Promise((resolve, reject) => {
4150
+ settle(resolve, reject, {
4151
+ data: responseData,
4152
+ headers: AxiosHeaders$1.from(response.headers),
4153
+ status: response.status,
4154
+ statusText: response.statusText,
4155
+ config,
4156
+ request
4157
+ });
4158
+ })
4159
+ } catch (err) {
4160
+ unsubscribe && unsubscribe();
4161
+
4162
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
4163
+ throw Object.assign(
4164
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
4165
+ {
4166
+ cause: err.cause || err
4167
+ }
4168
+ )
4169
+ }
4170
+
4171
+ throw AxiosError.from(err, err && err.code, config, request);
4036
4172
  }
4173
+ }
4174
+ };
4175
+
4176
+ const seedCache = new Map();
4177
+
4178
+ const getFetch = (config) => {
4179
+ let env = utils$1.merge.call({
4180
+ skipUndefined: true
4181
+ }, globalFetchAPI, config ? config.env : null);
4182
+
4183
+ const {fetch, Request, Response} = env;
4037
4184
 
4038
- throw AxiosError.from(err, err && err.code, config, request);
4185
+ const seeds = [
4186
+ Request, Response, fetch
4187
+ ];
4188
+
4189
+ let len = seeds.length, i = len,
4190
+ seed, target, map = seedCache;
4191
+
4192
+ while (i--) {
4193
+ seed = seeds[i];
4194
+ target = map.get(seed);
4195
+
4196
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
4197
+
4198
+ map = target;
4039
4199
  }
4040
- });
4200
+
4201
+ return target;
4202
+ };
4203
+
4204
+ getFetch();
4041
4205
 
4042
4206
  const knownAdapters = {
4043
4207
  http: httpAdapter,
4044
4208
  xhr: xhrAdapter,
4045
- fetch: fetchAdapter
4209
+ fetch: {
4210
+ get: getFetch,
4211
+ }
4046
4212
  };
4047
4213
 
4048
4214
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -4061,7 +4227,7 @@ const renderReason = (reason) => `- ${reason}`;
4061
4227
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
4062
4228
 
4063
4229
  const adapters = {
4064
- getAdapter: (adapters) => {
4230
+ getAdapter: (adapters, config) => {
4065
4231
  adapters = utils$1.isArray(adapters) ? adapters : [adapters];
4066
4232
 
4067
4233
  const {length} = adapters;
@@ -4084,7 +4250,7 @@ const adapters = {
4084
4250
  }
4085
4251
  }
4086
4252
 
4087
- if (adapter) {
4253
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
4088
4254
  break;
4089
4255
  }
4090
4256
 
@@ -4152,7 +4318,7 @@ function dispatchRequest(config) {
4152
4318
  config.headers.setContentType('application/x-www-form-urlencoded', false);
4153
4319
  }
4154
4320
 
4155
- const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
4321
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
4156
4322
 
4157
4323
  return adapter(config).then(function onAdapterResolution(response) {
4158
4324
  throwIfCancellationRequested(config);