@carbon/ibmdotcom-services 2.53.0 → 2.55.0

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.
@@ -842,6 +842,10 @@
842
842
  };
843
843
  }
844
844
 
845
+ function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
846
+ function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
847
+ function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
848
+
845
849
  // utils is a library of generic helper functions non-specific to axios
846
850
 
847
851
  var toString = Object.prototype.toString;
@@ -1120,6 +1124,7 @@
1120
1124
  * @returns {boolean} True if value is a FileList, otherwise false
1121
1125
  */
1122
1126
  var isFileList = kindOfTest('FileList');
1127
+ var isSet = kindOfTest('Set');
1123
1128
 
1124
1129
  /**
1125
1130
  * Determine if a value is a Stream
@@ -1649,11 +1654,29 @@
1649
1654
  if (!('toJSON' in source)) {
1650
1655
  // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
1651
1656
  visited.add(source);
1652
- var target = isArray(source) ? [] : {};
1653
- forEach(source, function (value, key) {
1654
- var reducedValue = _visit(value);
1655
- !isUndefined(reducedValue) && (target[key] = reducedValue);
1656
- });
1657
+ var target;
1658
+ if (isSet(source)) {
1659
+ target = [];
1660
+ var _iterator2 = _createForOfIteratorHelper$1(source),
1661
+ _step;
1662
+ try {
1663
+ for (_iterator2.s(); !(_step = _iterator2.n()).done;) {
1664
+ var value = _step.value;
1665
+ var reducedValue = _visit(value);
1666
+ !isUndefined(reducedValue) && target.push(reducedValue);
1667
+ }
1668
+ } catch (err) {
1669
+ _iterator2.e(err);
1670
+ } finally {
1671
+ _iterator2.f();
1672
+ }
1673
+ } else {
1674
+ target = isArray(source) ? [] : {};
1675
+ forEach(source, function (value, key) {
1676
+ var reducedValue = _visit(value);
1677
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
1678
+ });
1679
+ }
1657
1680
  visited.delete(source);
1658
1681
  return target;
1659
1682
  }
@@ -2018,17 +2041,18 @@
2018
2041
  i = line.indexOf(':');
2019
2042
  key = line.substring(0, i).trim().toLowerCase();
2020
2043
  val = line.substring(i + 1).trim();
2021
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
2044
+ var hasKey = utils$1.hasOwnProp(parsed, key);
2045
+ if (!key || hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key)) {
2022
2046
  return;
2023
2047
  }
2024
2048
  if (key === 'set-cookie') {
2025
- if (parsed[key]) {
2049
+ if (hasKey) {
2026
2050
  parsed[key].push(val);
2027
2051
  } else {
2028
2052
  parsed[key] = [val];
2029
2053
  }
2030
2054
  } else {
2031
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2055
+ parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
2032
2056
  }
2033
2057
  });
2034
2058
  return parsed;
@@ -2103,6 +2127,90 @@
2103
2127
  }
2104
2128
  return tokens;
2105
2129
  }
2130
+ var parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
2131
+ function trimOWS(value) {
2132
+ var start = 0;
2133
+ var end = value.length;
2134
+ while (start < end) {
2135
+ var code = value.charCodeAt(start);
2136
+ if (code !== 0x09 && code !== 0x20) {
2137
+ break;
2138
+ }
2139
+ start += 1;
2140
+ }
2141
+ while (end > start) {
2142
+ var _code = value.charCodeAt(end - 1);
2143
+ if (_code !== 0x09 && _code !== 0x20) {
2144
+ break;
2145
+ }
2146
+ end -= 1;
2147
+ }
2148
+ return start === 0 && end === value.length ? value : value.slice(start, end);
2149
+ }
2150
+ function decodeQuotedString(value) {
2151
+ var last = value.length - 1;
2152
+ if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
2153
+ return value;
2154
+ }
2155
+ var decoded = '';
2156
+ for (var i = 1; i < last; i++) {
2157
+ var code = value.charCodeAt(i);
2158
+ if (code === 0x22) {
2159
+ return value;
2160
+ }
2161
+ if (code === 0x5c) {
2162
+ i += 1;
2163
+ if (i >= last) {
2164
+ return value;
2165
+ }
2166
+ }
2167
+ decoded += value[i];
2168
+ }
2169
+ return decoded;
2170
+ }
2171
+ function _parseParameters(value) {
2172
+ var parameters = Object.create(null);
2173
+ var str = String(value);
2174
+ var start = 0;
2175
+ var quoted = false;
2176
+ var escaped = false;
2177
+ function parseParameter(end) {
2178
+ var part = trimOWS(str.slice(start, end));
2179
+ var equals = part.indexOf('=');
2180
+ if (equals < 1) {
2181
+ return;
2182
+ }
2183
+ var name = trimOWS(part.slice(0, equals));
2184
+ if (!parameterNameRE.test(name)) {
2185
+ return;
2186
+ }
2187
+ var normalizedName = name.toLowerCase();
2188
+ if (normalizedName === '__proto__' || normalizedName === 'constructor' || normalizedName === 'prototype') {
2189
+ return;
2190
+ }
2191
+ var parameterValue = trimOWS(part.slice(equals + 1));
2192
+ parameters[normalizedName] = decodeQuotedString(parameterValue);
2193
+ }
2194
+ for (var i = 0; i < str.length; i++) {
2195
+ var code = str.charCodeAt(i);
2196
+ if (quoted) {
2197
+ if (escaped) {
2198
+ escaped = false;
2199
+ } else if (code === 0x5c) {
2200
+ escaped = true;
2201
+ } else if (code === 0x22) {
2202
+ quoted = false;
2203
+ }
2204
+ } else if (code === 0x22) {
2205
+ quoted = true;
2206
+ } else if (code === 0x2c || code === 0x3b) {
2207
+ parseParameter(i);
2208
+ start = i + 1;
2209
+ }
2210
+ }
2211
+ parseParameter(str.length);
2212
+ return parameters;
2213
+ }
2106
2214
  var isValidHeaderName = function isValidHeaderName(str) {
2107
2215
  return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2108
2216
  };
@@ -2327,7 +2435,8 @@
2327
2435
  }, {
2328
2436
  key: "getSetCookie",
2329
2437
  value: function getSetCookie() {
2330
- return this.get('set-cookie') || [];
2438
+ var value = this.get('set-cookie');
2439
+ return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
2331
2440
  }
2332
2441
  }, {
2333
2442
  key: Symbol.toStringTag,
@@ -2339,6 +2448,11 @@
2339
2448
  value: function from(thing) {
2340
2449
  return thing instanceof this ? thing : new this(thing);
2341
2450
  }
2451
+ }, {
2452
+ key: "parseParameters",
2453
+ value: function parseParameters(value) {
2454
+ return _parseParameters(value);
2455
+ }
2342
2456
  }, {
2343
2457
  key: "concat",
2344
2458
  value: function concat(first) {
@@ -2452,6 +2566,23 @@
2452
2566
  };
2453
2567
  return _visit(config);
2454
2568
  }
2569
+ function stringifySafely$1(value) {
2570
+ try {
2571
+ return String(value);
2572
+ } catch (err) {
2573
+ return '';
2574
+ }
2575
+ }
2576
+ function aggregateErrorMessage(error) {
2577
+ var message = error.errors.map(function (entry) {
2578
+ try {
2579
+ return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
2580
+ } catch (err) {
2581
+ return '';
2582
+ }
2583
+ }).filter(Boolean).join('; ');
2584
+ return message || error.name || 'AggregateError';
2585
+ }
2455
2586
  var AxiosError = /*#__PURE__*/function (_Error) {
2456
2587
  /**
2457
2588
  * Create an Error with the specified message, config, error code, request and response.
@@ -2524,8 +2655,27 @@
2524
2655
  }], [{
2525
2656
  key: "from",
2526
2657
  value: function from(error, code, config, request, response, customProps) {
2527
- var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
2528
- axiosError.cause = error;
2658
+ // `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
2659
+ // failures) has an empty `message`; its detail lives in `errors[]`. Without
2660
+ // this, the wrapped error surfaces with a blank message (see #6721).
2661
+ var message = error.message;
2662
+ if (!message && utils$1.isArray(error.errors) && error.errors.length) {
2663
+ message = aggregateErrorMessage(error);
2664
+ }
2665
+ var axiosError = new AxiosError(message, code || error.code, config, request, response);
2666
+ // Match native `Error` `cause` semantics: non-enumerable. The wrapped
2667
+ // error often carries circular internals (sockets, requests, agents), so
2668
+ // an enumerable `cause` makes structured loggers (pino/winston) and any
2669
+ // own-property walk throw "Converting circular structure to JSON".
2670
+ // Regression from #6982; see #7205. `__proto__: null` mirrors the
2671
+ // `message` descriptor below (prototype-pollution-safe descriptor).
2672
+ Object.defineProperty(axiosError, 'cause', {
2673
+ __proto__: null,
2674
+ value: error,
2675
+ writable: true,
2676
+ enumerable: false,
2677
+ configurable: true
2678
+ });
2529
2679
  axiosError.name = error.name;
2530
2680
 
2531
2681
  // Preserve status from the original error if not already set from response
@@ -2678,7 +2828,10 @@
2678
2828
  throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
2679
2829
  }
2680
2830
  if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2681
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2831
+ if (useBlob && typeof _Blob === 'function') {
2832
+ return new _Blob([value]);
2833
+ }
2834
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.', AxiosError$1.ERR_NOT_SUPPORT);
2682
2835
  }
2683
2836
  return value;
2684
2837
  }
@@ -2811,8 +2964,9 @@
2811
2964
  this._pairs.push([name, value]);
2812
2965
  };
2813
2966
  prototype.toString = function toString(encoder) {
2967
+ var _this = this;
2814
2968
  var _encode = encoder ? function (value) {
2815
- return encoder.call(this, value, encode$1);
2969
+ return encoder.call(_this, value, encode$1);
2816
2970
  } : encode$1;
2817
2971
  return this._pairs.map(function each(pair) {
2818
2972
  return _encode(pair[0]) + '=' + _encode(pair[1]);
@@ -2844,6 +2998,7 @@
2844
2998
  if (!params) {
2845
2999
  return url;
2846
3000
  }
3001
+ url = url || '';
2847
3002
  var _options = utils$1.isFunction(options) ? {
2848
3003
  serialize: options
2849
3004
  } : options;
@@ -3068,12 +3223,18 @@
3068
3223
  * @returns An array of strings.
3069
3224
  */
3070
3225
  function parsePropPath(name) {
3071
- // foo[x][y][z]
3072
- // foo.x.y.z
3073
- // foo-x-y-z
3074
- // foo x y z
3226
+ // foo[x][y][z] -> ['foo', 'x', 'y', 'z']
3227
+ // foo.x.y.z -> ['foo', 'x', 'y', 'z']
3228
+ // A path is split on `.` and on `[...]` groups. A segment — whether written
3229
+ // in dot notation or captured inside brackets — may contain any character
3230
+ // except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
3231
+ // literal instead of being split (#5402). `.`, `[` and `]` keep their existing
3232
+ // meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
3233
+ // Excluding `[` from the bracket group also makes the match fail fast at the
3234
+ // next `[`, so a malformed name cannot rescan to the end of the string from
3235
+ // every unmatched `[` — parsing stays linear in the length of the name.
3075
3236
  var path = [];
3076
- var pattern = /\w+|\[(\w*)]/g;
3237
+ var pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
3077
3238
  var match;
3078
3239
  while ((match = pattern.exec(name)) !== null) {
3079
3240
  throwIfDepthExceeded(path.length);
@@ -3434,7 +3595,7 @@
3434
3595
  }
3435
3596
  var rawLoaded = e.loaded;
3436
3597
  var total = e.lengthComputable ? e.total : undefined;
3437
- var loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
3598
+ var loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
3438
3599
  var progressBytes = Math.max(0, loaded - bytesNotified);
3439
3600
  var rate = _speedometer(progressBytes);
3440
3601
  bytesNotified = Math.max(bytesNotified, loaded);
@@ -3462,11 +3623,12 @@
3462
3623
  }, throttled[1]];
3463
3624
  };
3464
3625
  var asyncDecorator = function asyncDecorator(fn) {
3626
+ var scheduler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : utils$1.asap;
3465
3627
  return function () {
3466
3628
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3467
3629
  args[_key] = arguments[_key];
3468
3630
  }
3469
- return utils$1.asap(function () {
3631
+ return scheduler(function () {
3470
3632
  return fn.apply(void 0, args);
3471
3633
  });
3472
3634
  };
@@ -3516,7 +3678,11 @@
3516
3678
  var cookie = cookies[i].replace(/^\s+/, '');
3517
3679
  var eq = cookie.indexOf('=');
3518
3680
  if (eq !== -1 && cookie.slice(0, eq) === name) {
3519
- return decodeURIComponent(cookie.slice(eq + 1));
3681
+ try {
3682
+ return decodeURIComponent(cookie.slice(eq + 1));
3683
+ } catch (e) {
3684
+ return cookie.slice(eq + 1);
3685
+ }
3520
3686
  }
3521
3687
  }
3522
3688
  return null;
@@ -3560,7 +3726,14 @@
3560
3726
  * @returns {string} The combined URL
3561
3727
  */
3562
3728
  function combineURLs(baseURL, relativeURL) {
3563
- return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
3729
+ if (!relativeURL) {
3730
+ return baseURL;
3731
+ }
3732
+ var end = baseURL.length;
3733
+ while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
3734
+ end--;
3735
+ }
3736
+ return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
3564
3737
  }
3565
3738
 
3566
3739
  var malformedHttpProtocol = /^https?:(?!\/\/)/i;
@@ -3575,9 +3748,40 @@
3575
3748
  function normalizeURLForProtocolCheck(url) {
3576
3749
  return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
3577
3750
  }
3751
+
3752
+ // Redact the parts of a URL that can carry secrets before it is embedded in an
3753
+ // error message. AxiosError.toJSON() serializes `message` verbatim and errors
3754
+ // are commonly logged, while the opt-in `config.redact` model only cleans
3755
+ // config keys — it cannot reach the message. Redact only the genuinely
3756
+ // sensitive substrings — userinfo (credentials), query parameter values and
3757
+ // fragment contents — with the same REDACTED marker the config redaction uses,
3758
+ // while keeping the scheme, host, path and parameter names so the offending
3759
+ // request stays accurately identifiable.
3760
+ function redactFragment(fragment) {
3761
+ if (!fragment) {
3762
+ return fragment;
3763
+ }
3764
+ return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, function (match, separator) {
3765
+ var parameterName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
3766
+ return "".concat(separator).concat(parameterName).concat(REDACTED);
3767
+ });
3768
+ }
3769
+ function redactSensitiveURLParts(url) {
3770
+ var redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, "$1".concat(REDACTED, "@"));
3771
+ var fragmentIndex = redactedURL.indexOf('#');
3772
+ var urlWithoutFragment = fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
3773
+ var redactedURLWithoutFragment = urlWithoutFragment.replace(/([?&][^=&#]*=)[^&#]*/g, "$1".concat(REDACTED));
3774
+ if (fragmentIndex === -1) {
3775
+ return redactedURLWithoutFragment;
3776
+ }
3777
+ return "".concat(redactedURLWithoutFragment, "#").concat(redactFragment(redactedURL.slice(fragmentIndex + 1)));
3778
+ }
3578
3779
  function assertValidHttpProtocolURL(url, config) {
3579
- if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
3580
- throw new AxiosError$1('Invalid URL: missing "//" after protocol', AxiosError$1.ERR_INVALID_URL, config);
3780
+ if (typeof url === 'string') {
3781
+ var normalizedURL = normalizeURLForProtocolCheck(url);
3782
+ if (malformedHttpProtocol.test(normalizedURL)) {
3783
+ throw new AxiosError$1("Invalid URL ".concat(JSON.stringify(redactSensitiveURLParts(normalizedURL)), ": missing \"//\" after protocol"), AxiosError$1.ERR_INVALID_URL, config);
3784
+ }
3581
3785
  }
3582
3786
  }
3583
3787
 
@@ -3606,6 +3810,14 @@
3606
3810
  var headersToObject = function headersToObject(thing) {
3607
3811
  return thing instanceof AxiosHeaders$1 ? _objectSpread$2({}, thing) : thing;
3608
3812
  };
3813
+ var ownEnumerableKeys = function ownEnumerableKeys(thing) {
3814
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
3815
+ return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(function (symbol) {
3816
+ return Object.getOwnPropertyDescriptor(thing, symbol).enumerable;
3817
+ }));
3818
+ }
3819
+ return Object.keys(thing);
3820
+ };
3609
3821
 
3610
3822
  /**
3611
3823
  * Config-specific merge-function which creates a new config-object
@@ -3618,6 +3830,7 @@
3618
3830
  */
3619
3831
  function mergeConfig(config1, config2) {
3620
3832
  // eslint-disable-next-line no-param-reassign
3833
+ config1 = config1 || {};
3621
3834
  config2 = config2 || {};
3622
3835
 
3623
3836
  // Use a null-prototype object so that downstream reads such as `config.auth`
@@ -3729,7 +3942,7 @@
3729
3942
  return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
3730
3943
  }
3731
3944
  };
3732
- utils$1.forEach(Object.keys(_objectSpread$2(_objectSpread$2({}, config1), config2)), function computeConfigValue(prop) {
3945
+ utils$1.forEach(ownEnumerableKeys(_objectSpread$2(_objectSpread$2({}, config1), config2)), function computeConfigValue(prop) {
3733
3946
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
3734
3947
  var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
3735
3948
  var a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
@@ -3748,12 +3961,24 @@
3748
3961
  }
3749
3962
 
3750
3963
  var FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3964
+
3965
+ /**
3966
+ * Apply the headers generated by a FormData implementation to the request headers,
3967
+ * honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
3968
+ * content-* headers; otherwise merge all of them.
3969
+ *
3970
+ * @param {AxiosHeaders} headers - the request headers to mutate
3971
+ * @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
3972
+ * @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
3973
+ *
3974
+ * @returns {void}
3975
+ */
3751
3976
  function setFormDataHeaders(headers, formHeaders, policy) {
3752
3977
  if (policy !== 'content-only') {
3753
3978
  headers.set(formHeaders);
3754
3979
  return;
3755
3980
  }
3756
- Object.entries(formHeaders).forEach(function (_ref) {
3981
+ Object.entries(formHeaders || {}).forEach(function (_ref) {
3757
3982
  var _ref2 = _slicedToArray(_ref, 2),
3758
3983
  key = _ref2[0],
3759
3984
  val = _ref2[1];
@@ -3800,7 +4025,11 @@
3800
4025
  if (auth) {
3801
4026
  var username = utils$1.getSafeProp(auth, 'username') || '';
3802
4027
  var password = utils$1.getSafeProp(auth, 'password') || '';
3803
- headers.set('Authorization', 'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : '')));
4028
+ try {
4029
+ headers.set('Authorization', 'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : '')));
4030
+ } catch (e) {
4031
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_OPTION_VALUE, config);
4032
+ }
3804
4033
  }
3805
4034
  if (utils$1.isFormData(data)) {
3806
4035
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
@@ -4005,6 +4234,7 @@
4005
4234
  var protocol = parseProtocol(_config.url);
4006
4235
  if (protocol && !platform.protocols.includes(protocol)) {
4007
4236
  reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
4237
+ done();
4008
4238
  return;
4009
4239
  }
4010
4240
 
@@ -4044,7 +4274,16 @@
4044
4274
  signals = null;
4045
4275
  };
4046
4276
  signals.forEach(function (signal) {
4047
- return signal.addEventListener('abort', onabort);
4277
+ if (aborted) {
4278
+ return;
4279
+ }
4280
+ if (signal.aborted) {
4281
+ onabort.call(signal);
4282
+ return;
4283
+ }
4284
+ signal.addEventListener('abort', onabort, {
4285
+ once: true
4286
+ });
4048
4287
  });
4049
4288
  var signal = controller.signal;
4050
4289
  signal.unsubscribe = function () {
@@ -4389,13 +4628,11 @@
4389
4628
  };
4390
4629
 
4391
4630
  /**
4392
- * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
4393
- * - For base64: compute exact decoded size using length and padding;
4394
- * handle %XX at the character-count level (no string allocation).
4395
- * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
4396
- *
4397
- * @param {string} url
4398
- * @returns {number}
4631
+ * Estimate data: URL byte lengths *without* allocating large buffers.
4632
+ * - Fetch percent-decodes a base64 body before decoding it.
4633
+ * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
4634
+ * raw body, including ignored characters and content after padding.
4635
+ * - Non-base64 data is percent-decoded and then encoded as UTF-8.
4399
4636
  */
4400
4637
  var isHexDigit = function isHexDigit(charCode) {
4401
4638
  return charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
@@ -4403,7 +4640,80 @@
4403
4640
  var isPercentEncodedByte = function isPercentEncodedByte(str, i, len) {
4404
4641
  return i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
4405
4642
  };
4406
- function estimateDataURLDecodedBytes(url) {
4643
+ var hexValue = function hexValue(charCode) {
4644
+ return charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55;
4645
+ };
4646
+ var isBase64Char = function isBase64Char(charCode) {
4647
+ return charCode >= 65 && charCode <= 90 ||
4648
+ // A-Z
4649
+ charCode >= 97 && charCode <= 122 ||
4650
+ // a-z
4651
+ charCode >= 48 && charCode <= 57 ||
4652
+ // 0-9
4653
+ charCode === 43 ||
4654
+ // +
4655
+ charCode === 47 ||
4656
+ // /
4657
+ charCode === 45 ||
4658
+ // - (base64url)
4659
+ charCode === 95;
4660
+ }; // _ (base64url)
4661
+
4662
+ var isBase64Whitespace = function isBase64Whitespace(charCode) {
4663
+ return charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
4664
+ };
4665
+ var base64Bytes = function base64Bytes(significant) {
4666
+ var groups = Math.floor(significant / 4);
4667
+ var remainder = significant % 4;
4668
+ return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
4669
+ };
4670
+
4671
+ // Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
4672
+ // upper bound even when Buffer.from later ignores characters or stops at '='.
4673
+ var estimateBase64BufferAllocation = function estimateBase64BufferAllocation(body) {
4674
+ var len = body.length;
4675
+ var padding = 0;
4676
+ if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
4677
+ padding++;
4678
+ if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
4679
+ padding++;
4680
+ }
4681
+ }
4682
+ return Math.floor((len - padding) * 3 / 4);
4683
+ };
4684
+ var estimatePercentDecodedBase64Bytes = function estimatePercentDecodedBase64Bytes(body) {
4685
+ var len = body.length;
4686
+ var significant = 0;
4687
+ var padding = 0;
4688
+ var invalid = false;
4689
+ for (var i = 0; i < len; i++) {
4690
+ var code = body.charCodeAt(i);
4691
+ if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
4692
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
4693
+ i += 2;
4694
+ }
4695
+ if (isBase64Whitespace(code)) {
4696
+ continue;
4697
+ }
4698
+ if (code === 61 /* '=' */) {
4699
+ padding++;
4700
+ continue;
4701
+ }
4702
+ if (!isBase64Char(code) || padding > 0) {
4703
+ invalid = true;
4704
+ continue;
4705
+ }
4706
+ significant++;
4707
+ }
4708
+
4709
+ // Fetch rejects malformed forgiving-base64 input. Returning the raw-size
4710
+ // allocation bound keeps that invalid input from becoming a pre-check bypass.
4711
+ if (invalid || padding > 2 || padding > 0 && (significant + padding) % 4 !== 0 || significant % 4 === 1) {
4712
+ return estimateBase64BufferAllocation(body);
4713
+ }
4714
+ return base64Bytes(significant);
4715
+ };
4716
+ var estimateDataURLBytes = function estimateDataURLBytes(url, estimateBase64) {
4407
4717
  if (!url || typeof url !== 'string') return 0;
4408
4718
  if (!url.startsWith('data:')) return 0;
4409
4719
  var comma = url.indexOf(',');
@@ -4412,49 +4722,7 @@
4412
4722
  var body = url.slice(comma + 1);
4413
4723
  var isBase64 = /;base64/i.test(meta);
4414
4724
  if (isBase64) {
4415
- var effectiveLen = body.length;
4416
- var len = body.length; // cache length
4417
-
4418
- for (var i = 0; i < len; i++) {
4419
- if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
4420
- var a = body.charCodeAt(i + 1);
4421
- var b = body.charCodeAt(i + 2);
4422
- var isHex = isHexDigit(a) && isHexDigit(b);
4423
- if (isHex) {
4424
- effectiveLen -= 2;
4425
- i += 2;
4426
- }
4427
- }
4428
- }
4429
- var pad = 0;
4430
- var idx = len - 1;
4431
- var tailIsPct3D = function tailIsPct3D(j) {
4432
- return j >= 2 && body.charCodeAt(j - 2) === 37 &&
4433
- // '%'
4434
- body.charCodeAt(j - 1) === 51 && (
4435
- // '3'
4436
- body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
4437
- }; // 'D' or 'd'
4438
-
4439
- if (idx >= 0) {
4440
- if (body.charCodeAt(idx) === 61 /* '=' */) {
4441
- pad++;
4442
- idx--;
4443
- } else if (tailIsPct3D(idx)) {
4444
- pad++;
4445
- idx -= 3;
4446
- }
4447
- }
4448
- if (pad === 1 && idx >= 0) {
4449
- if (body.charCodeAt(idx) === 61 /* '=' */) {
4450
- pad++;
4451
- } else if (tailIsPct3D(idx)) {
4452
- pad++;
4453
- }
4454
- }
4455
- var groups = Math.floor(effectiveLen / 4);
4456
- var _bytes = groups * 3 - (pad || 0);
4457
- return _bytes > 0 ? _bytes : 0;
4725
+ return estimateBase64(body);
4458
4726
  }
4459
4727
 
4460
4728
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
@@ -4462,20 +4730,20 @@
4462
4730
  // Valid %XX triplets count as one decoded byte; this matches the bytes that
4463
4731
  // decodeURIComponent(body) would produce before Buffer re-encodes the string.
4464
4732
  var bytes = 0;
4465
- for (var _i = 0, _len = body.length; _i < _len; _i++) {
4466
- var c = body.charCodeAt(_i);
4467
- if (c === 37 /* '%' */ && isPercentEncodedByte(body, _i, _len)) {
4733
+ for (var i = 0, len = body.length; i < len; i++) {
4734
+ var c = body.charCodeAt(i);
4735
+ if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
4468
4736
  bytes += 1;
4469
- _i += 2;
4737
+ i += 2;
4470
4738
  } else if (c < 0x80) {
4471
4739
  bytes += 1;
4472
4740
  } else if (c < 0x800) {
4473
4741
  bytes += 2;
4474
- } else if (c >= 0xd800 && c <= 0xdbff && _i + 1 < _len) {
4475
- var next = body.charCodeAt(_i + 1);
4742
+ } else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
4743
+ var next = body.charCodeAt(i + 1);
4476
4744
  if (next >= 0xdc00 && next <= 0xdfff) {
4477
4745
  bytes += 4;
4478
- _i++;
4746
+ i++;
4479
4747
  } else {
4480
4748
  bytes += 3;
4481
4749
  }
@@ -4484,9 +4752,21 @@
4484
4752
  }
4485
4753
  }
4486
4754
  return bytes;
4755
+ };
4756
+
4757
+ /**
4758
+ * Estimate the percent-decoded payload size used by Fetch data: URLs.
4759
+ *
4760
+ * @param {string} url
4761
+ * @returns {number}
4762
+ */
4763
+ function estimateDataURLDecodedBytes(url) {
4764
+ // Fetch removes URL fragments before processing a data: URL.
4765
+ var fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
4766
+ return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes);
4487
4767
  }
4488
4768
 
4489
- var VERSION = "1.18.0";
4769
+ var VERSION = "1.19.0";
4490
4770
 
4491
4771
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4492
4772
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -4699,7 +4979,7 @@
4699
4979
  }();
4700
4980
  return /*#__PURE__*/function () {
4701
4981
  var _ref4 = _asyncToGenerator(/*#__PURE__*/regenerator.mark(function _callee4(config) {
4702
- var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, hasMaxContentLength, hasMaxBodyLength, own, _fetch, composedSignal, request, unsubscribe, requestContentLength, pendingBodyError, maxBodyLengthError, auth, configAuth, username, password, parsedURL, urlUsername, urlPassword, estimated, outboundLength, mustEnforceStreamBody, trackRequestStream, _request, contentTypeHeader, _ref5, _ref6, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, responseHeaders, declaredLength, isStreamResponse, options, responseContentLength, _ref7, _ref8, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, _t3, _t4;
4982
+ var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, hasMaxContentLength, hasMaxBodyLength, own, _fetch, composedSignal, request, unsubscribe, requestContentLength, pendingBodyError, maxBodyLengthError, auth, configAuth, username, password, parsedURL, urlUsername, urlPassword, estimated, outboundLength, mustEnforceStreamBody, trackRequestStream, _request, contentTypeHeader, _ref5, _ref6, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, responseHeaders, declaredLength, isStreamResponse, options, responseContentLength, _ref7, _ref8, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, networkError, _t3, _t4;
4703
4983
  return regenerator.wrap(function (_context4) {
4704
4984
  while (1) switch (_context4.prev = _context4.next) {
4705
4985
  case 0:
@@ -4971,7 +5251,17 @@
4971
5251
  canceledError = composedSignal.reason;
4972
5252
  canceledError.config = config;
4973
5253
  request && (canceledError.request = request);
4974
- _t4 !== canceledError && (canceledError.cause = _t4);
5254
+ if (_t4 !== canceledError) {
5255
+ // Non-enumerable to match native Error `cause` semantics so loggers
5256
+ // don't recurse into circular fetch internals (see #7205).
5257
+ Object.defineProperty(canceledError, 'cause', {
5258
+ __proto__: null,
5259
+ value: _t4,
5260
+ writable: true,
5261
+ enumerable: false,
5262
+ configurable: true
5263
+ });
5264
+ }
4975
5265
  throw canceledError;
4976
5266
  case 17:
4977
5267
  if (!pendingBodyError) {
@@ -4992,9 +5282,16 @@
4992
5282
  _context4.next = 20;
4993
5283
  break;
4994
5284
  }
4995
- throw Object.assign(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, _t4 && _t4.response), {
4996
- cause: _t4.cause || _t4
5285
+ networkError = new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, _t4 && _t4.response); // Non-enumerable to match native Error `cause` semantics so loggers
5286
+ // don't recurse into circular fetch internals (see #7205).
5287
+ Object.defineProperty(networkError, 'cause', {
5288
+ __proto__: null,
5289
+ value: _t4.cause || _t4,
5290
+ writable: true,
5291
+ enumerable: false,
5292
+ configurable: true
4997
5293
  });
5294
+ throw networkError;
4998
5295
  case 20:
4999
5296
  throw AxiosError$1.from(_t4, _t4 && _t4.code, config, request, _t4 && _t4.response);
5000
5297
  case 21:
@@ -5127,7 +5424,7 @@
5127
5424
  return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
5128
5425
  });
5129
5426
  var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
5130
- throw new AxiosError$1("There is no suitable adapter to dispatch the request " + s, 'ERR_NOT_SUPPORT');
5427
+ throw new AxiosError$1("There is no suitable adapter to dispatch the request " + s, AxiosError$1.ERR_NOT_SUPPORT);
5131
5428
  }
5132
5429
  return adapter;
5133
5430
  }
@@ -5270,7 +5567,7 @@
5270
5567
  */
5271
5568
 
5272
5569
  function assertOptions(options, schema, allowUnknown) {
5273
- if (_typeof$1(options) !== 'object') {
5570
+ if (_typeof$1(options) !== 'object' || options === null) {
5274
5571
  throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
5275
5572
  }
5276
5573
  var keys = Object.keys(options);
@@ -5384,6 +5681,7 @@
5384
5681
  }, {
5385
5682
  key: "_request",
5386
5683
  value: function _request(configOrUrl, config) {
5684
+ var _this = this;
5387
5685
  /*eslint no-param-reassign:0*/
5388
5686
  // Allow for axios('example/url'[, config]) a la fetch API
5389
5687
  if (typeof configOrUrl === 'string') {
@@ -5481,16 +5779,31 @@
5481
5779
  var onFulfilled = requestInterceptorChain[i++];
5482
5780
  var onRejected = requestInterceptorChain[i++];
5483
5781
  try {
5484
- newConfig = onFulfilled(newConfig);
5782
+ newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
5485
5783
  } catch (error) {
5486
- onRejected.call(this, error);
5784
+ if (!onRejected) {
5785
+ promise = Promise.reject(error);
5786
+ break;
5787
+ }
5788
+ try {
5789
+ var rejectedResult = onRejected.call(this, error);
5790
+ if (utils$1.isThenable(rejectedResult)) {
5791
+ promise = Promise.resolve(rejectedResult).then(function () {
5792
+ return dispatchRequest.call(_this, newConfig);
5793
+ });
5794
+ }
5795
+ } catch (rejectedError) {
5796
+ promise = Promise.reject(rejectedError);
5797
+ }
5487
5798
  break;
5488
5799
  }
5489
5800
  }
5490
- try {
5491
- promise = dispatchRequest.call(this, newConfig);
5492
- } catch (error) {
5493
- return Promise.reject(error);
5801
+ if (!promise) {
5802
+ try {
5803
+ promise = dispatchRequest.call(this, newConfig);
5804
+ } catch (error) {
5805
+ promise = Promise.reject(error);
5806
+ }
5494
5807
  }
5495
5808
  i = 0;
5496
5809
  len = responseInterceptorChain.length;
@@ -5772,6 +6085,7 @@
5772
6085
  LoopDetected: 508,
5773
6086
  NotExtended: 510,
5774
6087
  NetworkAuthenticationRequired: 511,
6088
+ WebServerReturnsAnUnknownError: 520,
5775
6089
  WebServerIsDown: 521,
5776
6090
  ConnectionTimedOut: 522,
5777
6091
  OriginIsUnreachable: 523,