@tryghost/content-api 1.11.20 → 1.11.22

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/es/content-api.js CHANGED
@@ -211,6 +211,8 @@ const isFormData = (thing) => {
211
211
  */
212
212
  const isURLSearchParams = kindOfTest('URLSearchParams');
213
213
 
214
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
215
+
214
216
  /**
215
217
  * Trim excess whitespace off the beginning and end of a string
216
218
  *
@@ -599,28 +601,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
599
601
  const noop = () => {};
600
602
 
601
603
  const toFiniteNumber = (value, defaultValue) => {
602
- value = +value;
603
- return Number.isFinite(value) ? value : defaultValue;
604
- };
605
-
606
- const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
607
-
608
- const DIGIT = '0123456789';
609
-
610
- const ALPHABET = {
611
- DIGIT,
612
- ALPHA,
613
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
614
- };
615
-
616
- const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
617
- let str = '';
618
- const {length} = alphabet;
619
- while (size--) {
620
- str += alphabet[Math.random() * length|0];
621
- }
622
-
623
- return str;
604
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
624
605
  };
625
606
 
626
607
  /**
@@ -670,6 +651,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
670
651
  const isThenable = (thing) =>
671
652
  thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
672
653
 
654
+ // original code
655
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
656
+
657
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
658
+ if (setImmediateSupported) {
659
+ return setImmediate;
660
+ }
661
+
662
+ return postMessageSupported ? ((token, callbacks) => {
663
+ _global.addEventListener("message", ({source, data}) => {
664
+ if (source === _global && data === token) {
665
+ callbacks.length && callbacks.shift()();
666
+ }
667
+ }, false);
668
+
669
+ return (cb) => {
670
+ callbacks.push(cb);
671
+ _global.postMessage(token, "*");
672
+ }
673
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
674
+ })(
675
+ typeof setImmediate === 'function',
676
+ isFunction(_global.postMessage)
677
+ );
678
+
679
+ const asap = typeof queueMicrotask !== 'undefined' ?
680
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
681
+
682
+ // *********************
683
+
673
684
  var utils$1 = {
674
685
  isArray,
675
686
  isArrayBuffer,
@@ -681,6 +692,10 @@ var utils$1 = {
681
692
  isBoolean,
682
693
  isObject,
683
694
  isPlainObject,
695
+ isReadableStream,
696
+ isRequest,
697
+ isResponse,
698
+ isHeaders,
684
699
  isUndefined,
685
700
  isDate,
686
701
  isFile,
@@ -716,12 +731,12 @@ var utils$1 = {
716
731
  findKey,
717
732
  global: _global,
718
733
  isContextDefined,
719
- ALPHABET,
720
- generateString,
721
734
  isSpecCompliantForm,
722
735
  toJSONObject,
723
736
  isAsyncFn,
724
- isThenable
737
+ isThenable,
738
+ setImmediate: _setImmediate,
739
+ asap
725
740
  };
726
741
 
727
742
  /**
@@ -749,7 +764,10 @@ function AxiosError(message, code, config, request, response) {
749
764
  code && (this.code = code);
750
765
  config && (this.config = config);
751
766
  request && (this.request = request);
752
- response && (this.response = response);
767
+ if (response) {
768
+ this.response = response;
769
+ this.status = response.status ? response.status : null;
770
+ }
753
771
  }
754
772
 
755
773
  utils$1.inherits(AxiosError, Error, {
@@ -769,7 +787,7 @@ utils$1.inherits(AxiosError, Error, {
769
787
  // Axios
770
788
  config: utils$1.toJSONObject(this.config),
771
789
  code: this.code,
772
- status: this.response && this.response.status ? this.response.status : null
790
+ status: this.status
773
791
  };
774
792
  }
775
793
  });
@@ -1109,7 +1127,7 @@ function encode(val) {
1109
1127
  *
1110
1128
  * @param {string} url The base of the url (e.g., http://www.google.com)
1111
1129
  * @param {object} [params] The params to be appended
1112
- * @param {?object} options
1130
+ * @param {?(object|Function)} options
1113
1131
  *
1114
1132
  * @returns {string} The formatted url
1115
1133
  */
@@ -1121,6 +1139,12 @@ function buildURL(url, params, options) {
1121
1139
 
1122
1140
  const _encode = options && options.encode || encode;
1123
1141
 
1142
+ if (utils$1.isFunction(options)) {
1143
+ options = {
1144
+ serialize: options
1145
+ };
1146
+ }
1147
+
1124
1148
  const serializeFn = options && options.serialize;
1125
1149
 
1126
1150
  let serializedParams;
@@ -1237,6 +1261,8 @@ var platform$1 = {
1237
1261
 
1238
1262
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1239
1263
 
1264
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1265
+
1240
1266
  /**
1241
1267
  * Determine if we're running in a standard browser environment
1242
1268
  *
@@ -1254,10 +1280,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
1254
1280
  *
1255
1281
  * @returns {boolean}
1256
1282
  */
1257
- const hasStandardBrowserEnv = (
1258
- (product) => {
1259
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
1260
- })(typeof navigator !== 'undefined' && navigator.product);
1283
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1284
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1261
1285
 
1262
1286
  /**
1263
1287
  * Determine if we're running in a standard browser webWorker environment
@@ -1277,11 +1301,15 @@ const hasStandardBrowserWebWorkerEnv = (() => {
1277
1301
  );
1278
1302
  })();
1279
1303
 
1304
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1305
+
1280
1306
  var utils = /*#__PURE__*/Object.freeze({
1281
1307
  __proto__: null,
1282
1308
  hasBrowserEnv: hasBrowserEnv,
1283
1309
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1284
- hasStandardBrowserEnv: hasStandardBrowserEnv
1310
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1311
+ navigator: _navigator,
1312
+ origin: origin
1285
1313
  });
1286
1314
 
1287
1315
  var platform = {
@@ -1349,6 +1377,9 @@ function arrayToObject(arr) {
1349
1377
  function formDataToJSON(formData) {
1350
1378
  function buildPath(path, value, target, index) {
1351
1379
  let name = path[index++];
1380
+
1381
+ if (name === '__proto__') return true;
1382
+
1352
1383
  const isNumericKey = Number.isFinite(+name);
1353
1384
  const isLast = index >= path.length;
1354
1385
  name = !name && utils$1.isArray(target) ? target.length : name;
@@ -1418,7 +1449,7 @@ const defaults = {
1418
1449
 
1419
1450
  transitional: transitionalDefaults,
1420
1451
 
1421
- adapter: ['xhr', 'http'],
1452
+ adapter: ['xhr', 'http', 'fetch'],
1422
1453
 
1423
1454
  transformRequest: [function transformRequest(data, headers) {
1424
1455
  const contentType = headers.getContentType() || '';
@@ -1432,9 +1463,6 @@ const defaults = {
1432
1463
  const isFormData = utils$1.isFormData(data);
1433
1464
 
1434
1465
  if (isFormData) {
1435
- if (!hasJSONContentType) {
1436
- return data;
1437
- }
1438
1466
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1439
1467
  }
1440
1468
 
@@ -1442,7 +1470,8 @@ const defaults = {
1442
1470
  utils$1.isBuffer(data) ||
1443
1471
  utils$1.isStream(data) ||
1444
1472
  utils$1.isFile(data) ||
1445
- utils$1.isBlob(data)
1473
+ utils$1.isBlob(data) ||
1474
+ utils$1.isReadableStream(data)
1446
1475
  ) {
1447
1476
  return data;
1448
1477
  }
@@ -1485,6 +1514,10 @@ const defaults = {
1485
1514
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1486
1515
  const JSONRequested = this.responseType === 'json';
1487
1516
 
1517
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1518
+ return data;
1519
+ }
1520
+
1488
1521
  if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1489
1522
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
1490
1523
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -1688,6 +1721,10 @@ class AxiosHeaders {
1688
1721
  setHeaders(header, valueOrRewrite);
1689
1722
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1690
1723
  setHeaders(parseHeaders(header), valueOrRewrite);
1724
+ } else if (utils$1.isHeaders(header)) {
1725
+ for (const [key, value] of header.entries()) {
1726
+ setHeader(value, key, rewrite);
1727
+ }
1691
1728
  } else {
1692
1729
  header != null && setHeader(valueOrRewrite, header, rewrite);
1693
1730
  }
@@ -1955,162 +1992,6 @@ function settle(resolve, reject, response) {
1955
1992
  }
1956
1993
  }
1957
1994
 
1958
- var cookies = platform.hasStandardBrowserEnv ?
1959
-
1960
- // Standard browser envs support document.cookie
1961
- (function standardBrowserEnv() {
1962
- return {
1963
- write: function write(name, value, expires, path, domain, secure) {
1964
- const cookie = [];
1965
- cookie.push(name + '=' + encodeURIComponent(value));
1966
-
1967
- if (utils$1.isNumber(expires)) {
1968
- cookie.push('expires=' + new Date(expires).toGMTString());
1969
- }
1970
-
1971
- if (utils$1.isString(path)) {
1972
- cookie.push('path=' + path);
1973
- }
1974
-
1975
- if (utils$1.isString(domain)) {
1976
- cookie.push('domain=' + domain);
1977
- }
1978
-
1979
- if (secure === true) {
1980
- cookie.push('secure');
1981
- }
1982
-
1983
- document.cookie = cookie.join('; ');
1984
- },
1985
-
1986
- read: function read(name) {
1987
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1988
- return (match ? decodeURIComponent(match[3]) : null);
1989
- },
1990
-
1991
- remove: function remove(name) {
1992
- this.write(name, '', Date.now() - 86400000);
1993
- }
1994
- };
1995
- })() :
1996
-
1997
- // Non standard browser env (web workers, react-native) lack needed support.
1998
- (function nonStandardBrowserEnv() {
1999
- return {
2000
- write: function write() {},
2001
- read: function read() { return null; },
2002
- remove: function remove() {}
2003
- };
2004
- })();
2005
-
2006
- /**
2007
- * Determines whether the specified URL is absolute
2008
- *
2009
- * @param {string} url The URL to test
2010
- *
2011
- * @returns {boolean} True if the specified URL is absolute, otherwise false
2012
- */
2013
- function isAbsoluteURL(url) {
2014
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2015
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2016
- // by any combination of letters, digits, plus, period, or hyphen.
2017
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2018
- }
2019
-
2020
- /**
2021
- * Creates a new URL by combining the specified URLs
2022
- *
2023
- * @param {string} baseURL The base URL
2024
- * @param {string} relativeURL The relative URL
2025
- *
2026
- * @returns {string} The combined URL
2027
- */
2028
- function combineURLs(baseURL, relativeURL) {
2029
- return relativeURL
2030
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2031
- : baseURL;
2032
- }
2033
-
2034
- /**
2035
- * Creates a new URL by combining the baseURL with the requestedURL,
2036
- * only when the requestedURL is not already an absolute URL.
2037
- * If the requestURL is absolute, this function returns the requestedURL untouched.
2038
- *
2039
- * @param {string} baseURL The base URL
2040
- * @param {string} requestedURL Absolute or relative URL to combine
2041
- *
2042
- * @returns {string} The combined full path
2043
- */
2044
- function buildFullPath(baseURL, requestedURL) {
2045
- if (baseURL && !isAbsoluteURL(requestedURL)) {
2046
- return combineURLs(baseURL, requestedURL);
2047
- }
2048
- return requestedURL;
2049
- }
2050
-
2051
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
2052
-
2053
- // Standard browser envs have full support of the APIs needed to test
2054
- // whether the request URL is of the same origin as current location.
2055
- (function standardBrowserEnv() {
2056
- const msie = /(msie|trident)/i.test(navigator.userAgent);
2057
- const urlParsingNode = document.createElement('a');
2058
- let originURL;
2059
-
2060
- /**
2061
- * Parse a URL to discover it's components
2062
- *
2063
- * @param {String} url The URL to be parsed
2064
- * @returns {Object}
2065
- */
2066
- function resolveURL(url) {
2067
- let href = url;
2068
-
2069
- if (msie) {
2070
- // IE needs attribute set twice to normalize properties
2071
- urlParsingNode.setAttribute('href', href);
2072
- href = urlParsingNode.href;
2073
- }
2074
-
2075
- urlParsingNode.setAttribute('href', href);
2076
-
2077
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2078
- return {
2079
- href: urlParsingNode.href,
2080
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2081
- host: urlParsingNode.host,
2082
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2083
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2084
- hostname: urlParsingNode.hostname,
2085
- port: urlParsingNode.port,
2086
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2087
- urlParsingNode.pathname :
2088
- '/' + urlParsingNode.pathname
2089
- };
2090
- }
2091
-
2092
- originURL = resolveURL(window.location.href);
2093
-
2094
- /**
2095
- * Determine if a URL shares the same origin as the current location
2096
- *
2097
- * @param {String} requestURL The URL to test
2098
- * @returns {boolean} True if URL shares the same origin, otherwise false
2099
- */
2100
- return function isURLSameOrigin(requestURL) {
2101
- const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2102
- return (parsed.protocol === originURL.protocol &&
2103
- parsed.host === originURL.host);
2104
- };
2105
- })() :
2106
-
2107
- // Non standard browser envs (web workers, react-native) lack needed support.
2108
- (function nonStandardBrowserEnv() {
2109
- return function isURLSameOrigin() {
2110
- return true;
2111
- };
2112
- })();
2113
-
2114
1995
  function parseProtocol(url) {
2115
1996
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2116
1997
  return match && match[1] || '';
@@ -2168,11 +2049,54 @@ function speedometer(samplesCount, min) {
2168
2049
  };
2169
2050
  }
2170
2051
 
2171
- function progressEventReducer(listener, isDownloadStream) {
2052
+ /**
2053
+ * Throttle decorator
2054
+ * @param {Function} fn
2055
+ * @param {Number} freq
2056
+ * @return {Function}
2057
+ */
2058
+ function throttle(fn, freq) {
2059
+ let timestamp = 0;
2060
+ let threshold = 1000 / freq;
2061
+ let lastArgs;
2062
+ let timer;
2063
+
2064
+ const invoke = (args, now = Date.now()) => {
2065
+ timestamp = now;
2066
+ lastArgs = null;
2067
+ if (timer) {
2068
+ clearTimeout(timer);
2069
+ timer = null;
2070
+ }
2071
+ fn.apply(null, args);
2072
+ };
2073
+
2074
+ const throttled = (...args) => {
2075
+ const now = Date.now();
2076
+ const passed = now - timestamp;
2077
+ if ( passed >= threshold) {
2078
+ invoke(args, now);
2079
+ } else {
2080
+ lastArgs = args;
2081
+ if (!timer) {
2082
+ timer = setTimeout(() => {
2083
+ timer = null;
2084
+ invoke(lastArgs);
2085
+ }, threshold - passed);
2086
+ }
2087
+ }
2088
+ };
2089
+
2090
+ const flush = () => lastArgs && invoke(lastArgs);
2091
+
2092
+ return [throttled, flush];
2093
+ }
2094
+
2095
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2172
2096
  let bytesNotified = 0;
2173
2097
  const _speedometer = speedometer(50, 250);
2174
2098
 
2175
- return e => {
2099
+ return throttle(e => {
2176
2100
  const loaded = e.loaded;
2177
2101
  const total = e.lengthComputable ? e.total : undefined;
2178
2102
  const progressBytes = loaded - bytesNotified;
@@ -2188,166 +2112,395 @@ function progressEventReducer(listener, isDownloadStream) {
2188
2112
  bytes: progressBytes,
2189
2113
  rate: rate ? rate : undefined,
2190
2114
  estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2191
- event: e
2115
+ event: e,
2116
+ lengthComputable: total != null,
2117
+ [isDownloadStream ? 'download' : 'upload']: true
2192
2118
  };
2193
2119
 
2194
- data[isDownloadStream ? 'download' : 'upload'] = true;
2195
-
2196
2120
  listener(data);
2197
- };
2198
- }
2199
-
2200
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2121
+ }, freq);
2122
+ };
2201
2123
 
2202
- var xhrAdapter = isXHRAdapterSupported && function (config) {
2203
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2204
- let requestData = config.data;
2205
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2206
- const responseType = config.responseType;
2207
- let onCanceled;
2208
- function done() {
2209
- if (config.cancelToken) {
2210
- config.cancelToken.unsubscribe(onCanceled);
2211
- }
2124
+ const progressEventDecorator = (total, throttled) => {
2125
+ const lengthComputable = total != null;
2212
2126
 
2213
- if (config.signal) {
2214
- config.signal.removeEventListener('abort', onCanceled);
2215
- }
2216
- }
2127
+ return [(loaded) => throttled[0]({
2128
+ lengthComputable,
2129
+ total,
2130
+ loaded
2131
+ }), throttled[1]];
2132
+ };
2217
2133
 
2218
- let contentType;
2134
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2219
2135
 
2220
- if (utils$1.isFormData(requestData)) {
2221
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2222
- requestHeaders.setContentType(false); // Let the browser set it
2223
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
2224
- // fix semicolon duplication issue for ReactNative FormData implementation
2225
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2226
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2227
- }
2228
- }
2136
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2137
+ url = new URL(url, platform.origin);
2229
2138
 
2230
- let request = new XMLHttpRequest();
2139
+ return (
2140
+ origin.protocol === url.protocol &&
2141
+ origin.host === url.host &&
2142
+ (isMSIE || origin.port === url.port)
2143
+ );
2144
+ })(
2145
+ new URL(platform.origin),
2146
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2147
+ ) : () => true;
2231
2148
 
2232
- // HTTP basic authentication
2233
- if (config.auth) {
2234
- const username = config.auth.username || '';
2235
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2236
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2237
- }
2149
+ var cookies = platform.hasStandardBrowserEnv ?
2238
2150
 
2239
- const fullPath = buildFullPath(config.baseURL, config.url);
2151
+ // Standard browser envs support document.cookie
2152
+ {
2153
+ write(name, value, expires, path, domain, secure) {
2154
+ const cookie = [name + '=' + encodeURIComponent(value)];
2240
2155
 
2241
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
2156
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2242
2157
 
2243
- // Set the request timeout in MS
2244
- request.timeout = config.timeout;
2158
+ utils$1.isString(path) && cookie.push('path=' + path);
2245
2159
 
2246
- function onloadend() {
2247
- if (!request) {
2248
- return;
2249
- }
2250
- // Prepare the response
2251
- const responseHeaders = AxiosHeaders$1.from(
2252
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2253
- );
2254
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2255
- request.responseText : request.response;
2256
- const response = {
2257
- data: responseData,
2258
- status: request.status,
2259
- statusText: request.statusText,
2260
- headers: responseHeaders,
2261
- config,
2262
- request
2263
- };
2160
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2264
2161
 
2265
- settle(function _resolve(value) {
2266
- resolve(value);
2267
- done();
2268
- }, function _reject(err) {
2269
- reject(err);
2270
- done();
2271
- }, response);
2162
+ secure === true && cookie.push('secure');
2272
2163
 
2273
- // Clean up request
2274
- request = null;
2275
- }
2164
+ document.cookie = cookie.join('; ');
2165
+ },
2276
2166
 
2277
- if ('onloadend' in request) {
2278
- // Use onloadend if available
2279
- request.onloadend = onloadend;
2280
- } else {
2281
- // Listen for ready state to emulate onloadend
2282
- request.onreadystatechange = function handleLoad() {
2283
- if (!request || request.readyState !== 4) {
2284
- return;
2285
- }
2167
+ read(name) {
2168
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2169
+ return (match ? decodeURIComponent(match[3]) : null);
2170
+ },
2286
2171
 
2287
- // The request errored out and we didn't get a response, this will be
2288
- // handled by onerror instead
2289
- // With one exception: request that using file: protocol, most browsers
2290
- // will return status as 0 even though it's a successful request
2291
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2292
- return;
2293
- }
2294
- // readystate handler is calling before onerror or ontimeout handlers,
2295
- // so we should call onloadend on the next 'tick'
2296
- setTimeout(onloadend);
2297
- };
2172
+ remove(name) {
2173
+ this.write(name, '', Date.now() - 86400000);
2298
2174
  }
2175
+ }
2299
2176
 
2300
- // Handle browser request cancellation (as opposed to a manual cancellation)
2301
- request.onabort = function handleAbort() {
2302
- if (!request) {
2303
- return;
2304
- }
2177
+ :
2305
2178
 
2306
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2179
+ // Non-standard browser env (web workers, react-native) lack needed support.
2180
+ {
2181
+ write() {},
2182
+ read() {
2183
+ return null;
2184
+ },
2185
+ remove() {}
2186
+ };
2307
2187
 
2308
- // Clean up request
2309
- request = null;
2310
- };
2188
+ /**
2189
+ * Determines whether the specified URL is absolute
2190
+ *
2191
+ * @param {string} url The URL to test
2192
+ *
2193
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2194
+ */
2195
+ function isAbsoluteURL(url) {
2196
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2197
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2198
+ // by any combination of letters, digits, plus, period, or hyphen.
2199
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2200
+ }
2311
2201
 
2312
- // Handle low level network errors
2313
- request.onerror = function handleError() {
2314
- // Real errors are hidden from us by the browser
2315
- // onerror should only fire if it's a network error
2316
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2202
+ /**
2203
+ * Creates a new URL by combining the specified URLs
2204
+ *
2205
+ * @param {string} baseURL The base URL
2206
+ * @param {string} relativeURL The relative URL
2207
+ *
2208
+ * @returns {string} The combined URL
2209
+ */
2210
+ function combineURLs(baseURL, relativeURL) {
2211
+ return relativeURL
2212
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2213
+ : baseURL;
2214
+ }
2317
2215
 
2318
- // Clean up request
2319
- request = null;
2320
- };
2216
+ /**
2217
+ * Creates a new URL by combining the baseURL with the requestedURL,
2218
+ * only when the requestedURL is not already an absolute URL.
2219
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2220
+ *
2221
+ * @param {string} baseURL The base URL
2222
+ * @param {string} requestedURL Absolute or relative URL to combine
2223
+ *
2224
+ * @returns {string} The combined full path
2225
+ */
2226
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2227
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2228
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2229
+ return combineURLs(baseURL, requestedURL);
2230
+ }
2231
+ return requestedURL;
2232
+ }
2321
2233
 
2322
- // Handle timeout
2323
- request.ontimeout = function handleTimeout() {
2324
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2325
- const transitional = config.transitional || transitionalDefaults;
2326
- if (config.timeoutErrorMessage) {
2327
- timeoutErrorMessage = config.timeoutErrorMessage;
2328
- }
2329
- reject(new AxiosError(
2330
- timeoutErrorMessage,
2331
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2234
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2235
+
2236
+ /**
2237
+ * Config-specific merge-function which creates a new config-object
2238
+ * by merging two configuration objects together.
2239
+ *
2240
+ * @param {Object} config1
2241
+ * @param {Object} config2
2242
+ *
2243
+ * @returns {Object} New object resulting from merging config2 to config1
2244
+ */
2245
+ function mergeConfig(config1, config2) {
2246
+ // eslint-disable-next-line no-param-reassign
2247
+ config2 = config2 || {};
2248
+ const config = {};
2249
+
2250
+ function getMergedValue(target, source, prop, caseless) {
2251
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2252
+ return utils$1.merge.call({caseless}, target, source);
2253
+ } else if (utils$1.isPlainObject(source)) {
2254
+ return utils$1.merge({}, source);
2255
+ } else if (utils$1.isArray(source)) {
2256
+ return source.slice();
2257
+ }
2258
+ return source;
2259
+ }
2260
+
2261
+ // eslint-disable-next-line consistent-return
2262
+ function mergeDeepProperties(a, b, prop , caseless) {
2263
+ if (!utils$1.isUndefined(b)) {
2264
+ return getMergedValue(a, b, prop , caseless);
2265
+ } else if (!utils$1.isUndefined(a)) {
2266
+ return getMergedValue(undefined, a, prop , caseless);
2267
+ }
2268
+ }
2269
+
2270
+ // eslint-disable-next-line consistent-return
2271
+ function valueFromConfig2(a, b) {
2272
+ if (!utils$1.isUndefined(b)) {
2273
+ return getMergedValue(undefined, b);
2274
+ }
2275
+ }
2276
+
2277
+ // eslint-disable-next-line consistent-return
2278
+ function defaultToConfig2(a, b) {
2279
+ if (!utils$1.isUndefined(b)) {
2280
+ return getMergedValue(undefined, b);
2281
+ } else if (!utils$1.isUndefined(a)) {
2282
+ return getMergedValue(undefined, a);
2283
+ }
2284
+ }
2285
+
2286
+ // eslint-disable-next-line consistent-return
2287
+ function mergeDirectKeys(a, b, prop) {
2288
+ if (prop in config2) {
2289
+ return getMergedValue(a, b);
2290
+ } else if (prop in config1) {
2291
+ return getMergedValue(undefined, a);
2292
+ }
2293
+ }
2294
+
2295
+ const mergeMap = {
2296
+ url: valueFromConfig2,
2297
+ method: valueFromConfig2,
2298
+ data: valueFromConfig2,
2299
+ baseURL: defaultToConfig2,
2300
+ transformRequest: defaultToConfig2,
2301
+ transformResponse: defaultToConfig2,
2302
+ paramsSerializer: defaultToConfig2,
2303
+ timeout: defaultToConfig2,
2304
+ timeoutMessage: defaultToConfig2,
2305
+ withCredentials: defaultToConfig2,
2306
+ withXSRFToken: defaultToConfig2,
2307
+ adapter: defaultToConfig2,
2308
+ responseType: defaultToConfig2,
2309
+ xsrfCookieName: defaultToConfig2,
2310
+ xsrfHeaderName: defaultToConfig2,
2311
+ onUploadProgress: defaultToConfig2,
2312
+ onDownloadProgress: defaultToConfig2,
2313
+ decompress: defaultToConfig2,
2314
+ maxContentLength: defaultToConfig2,
2315
+ maxBodyLength: defaultToConfig2,
2316
+ beforeRedirect: defaultToConfig2,
2317
+ transport: defaultToConfig2,
2318
+ httpAgent: defaultToConfig2,
2319
+ httpsAgent: defaultToConfig2,
2320
+ cancelToken: defaultToConfig2,
2321
+ socketPath: defaultToConfig2,
2322
+ responseEncoding: defaultToConfig2,
2323
+ validateStatus: mergeDirectKeys,
2324
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2325
+ };
2326
+
2327
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2328
+ const merge = mergeMap[prop] || mergeDeepProperties;
2329
+ const configValue = merge(config1[prop], config2[prop], prop);
2330
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2331
+ });
2332
+
2333
+ return config;
2334
+ }
2335
+
2336
+ var resolveConfig = (config) => {
2337
+ const newConfig = mergeConfig({}, config);
2338
+
2339
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
2340
+
2341
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
2342
+
2343
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2344
+
2345
+ // HTTP basic authentication
2346
+ if (auth) {
2347
+ headers.set('Authorization', 'Basic ' +
2348
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2349
+ );
2350
+ }
2351
+
2352
+ let contentType;
2353
+
2354
+ if (utils$1.isFormData(data)) {
2355
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2356
+ headers.setContentType(undefined); // Let the browser set it
2357
+ } else if ((contentType = headers.getContentType()) !== false) {
2358
+ // fix semicolon duplication issue for ReactNative FormData implementation
2359
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2360
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2361
+ }
2362
+ }
2363
+
2364
+ // Add xsrf header
2365
+ // This is only done if running in a standard browser environment.
2366
+ // Specifically not if we're in a web worker, or react-native.
2367
+
2368
+ if (platform.hasStandardBrowserEnv) {
2369
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2370
+
2371
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2372
+ // Add xsrf header
2373
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2374
+
2375
+ if (xsrfValue) {
2376
+ headers.set(xsrfHeaderName, xsrfValue);
2377
+ }
2378
+ }
2379
+ }
2380
+
2381
+ return newConfig;
2382
+ };
2383
+
2384
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2385
+
2386
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
2387
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2388
+ const _config = resolveConfig(config);
2389
+ let requestData = _config.data;
2390
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2391
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
2392
+ let onCanceled;
2393
+ let uploadThrottled, downloadThrottled;
2394
+ let flushUpload, flushDownload;
2395
+
2396
+ function done() {
2397
+ flushUpload && flushUpload(); // flush events
2398
+ flushDownload && flushDownload(); // flush events
2399
+
2400
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2401
+
2402
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2403
+ }
2404
+
2405
+ let request = new XMLHttpRequest();
2406
+
2407
+ request.open(_config.method.toUpperCase(), _config.url, true);
2408
+
2409
+ // Set the request timeout in MS
2410
+ request.timeout = _config.timeout;
2411
+
2412
+ function onloadend() {
2413
+ if (!request) {
2414
+ return;
2415
+ }
2416
+ // Prepare the response
2417
+ const responseHeaders = AxiosHeaders$1.from(
2418
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2419
+ );
2420
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2421
+ request.responseText : request.response;
2422
+ const response = {
2423
+ data: responseData,
2424
+ status: request.status,
2425
+ statusText: request.statusText,
2426
+ headers: responseHeaders,
2332
2427
  config,
2333
- request));
2428
+ request
2429
+ };
2430
+
2431
+ settle(function _resolve(value) {
2432
+ resolve(value);
2433
+ done();
2434
+ }, function _reject(err) {
2435
+ reject(err);
2436
+ done();
2437
+ }, response);
2438
+
2439
+ // Clean up request
2440
+ request = null;
2441
+ }
2442
+
2443
+ if ('onloadend' in request) {
2444
+ // Use onloadend if available
2445
+ request.onloadend = onloadend;
2446
+ } else {
2447
+ // Listen for ready state to emulate onloadend
2448
+ request.onreadystatechange = function handleLoad() {
2449
+ if (!request || request.readyState !== 4) {
2450
+ return;
2451
+ }
2452
+
2453
+ // The request errored out and we didn't get a response, this will be
2454
+ // handled by onerror instead
2455
+ // With one exception: request that using file: protocol, most browsers
2456
+ // will return status as 0 even though it's a successful request
2457
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2458
+ return;
2459
+ }
2460
+ // readystate handler is calling before onerror or ontimeout handlers,
2461
+ // so we should call onloadend on the next 'tick'
2462
+ setTimeout(onloadend);
2463
+ };
2464
+ }
2465
+
2466
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2467
+ request.onabort = function handleAbort() {
2468
+ if (!request) {
2469
+ return;
2470
+ }
2471
+
2472
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2334
2473
 
2335
2474
  // Clean up request
2336
2475
  request = null;
2337
2476
  };
2338
2477
 
2339
- // Add xsrf header
2340
- // This is only done if running in a standard browser environment.
2341
- // Specifically not if we're in a web worker, or react-native.
2342
- if (platform.hasStandardBrowserEnv) {
2343
- // Add xsrf header
2344
- // regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
2345
- const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2478
+ // Handle low level network errors
2479
+ request.onerror = function handleError() {
2480
+ // Real errors are hidden from us by the browser
2481
+ // onerror should only fire if it's a network error
2482
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2346
2483
 
2347
- if (xsrfValue) {
2348
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2484
+ // Clean up request
2485
+ request = null;
2486
+ };
2487
+
2488
+ // Handle timeout
2489
+ request.ontimeout = function handleTimeout() {
2490
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2491
+ const transitional = _config.transitional || transitionalDefaults;
2492
+ if (_config.timeoutErrorMessage) {
2493
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2349
2494
  }
2350
- }
2495
+ reject(new AxiosError(
2496
+ timeoutErrorMessage,
2497
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2498
+ config,
2499
+ request));
2500
+
2501
+ // Clean up request
2502
+ request = null;
2503
+ };
2351
2504
 
2352
2505
  // Remove Content-Type if data is undefined
2353
2506
  requestData === undefined && requestHeaders.setContentType(null);
@@ -2360,26 +2513,31 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2360
2513
  }
2361
2514
 
2362
2515
  // Add withCredentials to request if needed
2363
- if (!utils$1.isUndefined(config.withCredentials)) {
2364
- request.withCredentials = !!config.withCredentials;
2516
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2517
+ request.withCredentials = !!_config.withCredentials;
2365
2518
  }
2366
2519
 
2367
2520
  // Add responseType to request if needed
2368
2521
  if (responseType && responseType !== 'json') {
2369
- request.responseType = config.responseType;
2522
+ request.responseType = _config.responseType;
2370
2523
  }
2371
2524
 
2372
2525
  // Handle progress if needed
2373
- if (typeof config.onDownloadProgress === 'function') {
2374
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
2526
+ if (onDownloadProgress) {
2527
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2528
+ request.addEventListener('progress', downloadThrottled);
2375
2529
  }
2376
2530
 
2377
2531
  // Not all browsers support upload events
2378
- if (typeof config.onUploadProgress === 'function' && request.upload) {
2379
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
2532
+ if (onUploadProgress && request.upload) {
2533
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
2534
+
2535
+ request.upload.addEventListener('progress', uploadThrottled);
2536
+
2537
+ request.upload.addEventListener('loadend', flushUpload);
2380
2538
  }
2381
2539
 
2382
- if (config.cancelToken || config.signal) {
2540
+ if (_config.cancelToken || _config.signal) {
2383
2541
  // Handle cancellation
2384
2542
  // eslint-disable-next-line func-names
2385
2543
  onCanceled = cancel => {
@@ -2391,13 +2549,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2391
2549
  request = null;
2392
2550
  };
2393
2551
 
2394
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
2395
- if (config.signal) {
2396
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2552
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2553
+ if (_config.signal) {
2554
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
2397
2555
  }
2398
2556
  }
2399
2557
 
2400
- const protocol = parseProtocol(fullPath);
2558
+ const protocol = parseProtocol(_config.url);
2401
2559
 
2402
2560
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
2403
2561
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
@@ -2410,9 +2568,360 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2410
2568
  });
2411
2569
  };
2412
2570
 
2571
+ const composeSignals = (signals, timeout) => {
2572
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
2573
+
2574
+ if (timeout || length) {
2575
+ let controller = new AbortController();
2576
+
2577
+ let aborted;
2578
+
2579
+ const onabort = function (reason) {
2580
+ if (!aborted) {
2581
+ aborted = true;
2582
+ unsubscribe();
2583
+ const err = reason instanceof Error ? reason : this.reason;
2584
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
2585
+ }
2586
+ };
2587
+
2588
+ let timer = timeout && setTimeout(() => {
2589
+ timer = null;
2590
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2591
+ }, timeout);
2592
+
2593
+ const unsubscribe = () => {
2594
+ if (signals) {
2595
+ timer && clearTimeout(timer);
2596
+ timer = null;
2597
+ signals.forEach(signal => {
2598
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
2599
+ });
2600
+ signals = null;
2601
+ }
2602
+ };
2603
+
2604
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
2605
+
2606
+ const {signal} = controller;
2607
+
2608
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
2609
+
2610
+ return signal;
2611
+ }
2612
+ };
2613
+
2614
+ var composeSignals$1 = composeSignals;
2615
+
2616
+ const streamChunk = function* (chunk, chunkSize) {
2617
+ let len = chunk.byteLength;
2618
+
2619
+ if (!chunkSize || len < chunkSize) {
2620
+ yield chunk;
2621
+ return;
2622
+ }
2623
+
2624
+ let pos = 0;
2625
+ let end;
2626
+
2627
+ while (pos < len) {
2628
+ end = pos + chunkSize;
2629
+ yield chunk.slice(pos, end);
2630
+ pos = end;
2631
+ }
2632
+ };
2633
+
2634
+ const readBytes = async function* (iterable, chunkSize) {
2635
+ for await (const chunk of readStream(iterable)) {
2636
+ yield* streamChunk(chunk, chunkSize);
2637
+ }
2638
+ };
2639
+
2640
+ const readStream = async function* (stream) {
2641
+ if (stream[Symbol.asyncIterator]) {
2642
+ yield* stream;
2643
+ return;
2644
+ }
2645
+
2646
+ const reader = stream.getReader();
2647
+ try {
2648
+ for (;;) {
2649
+ const {done, value} = await reader.read();
2650
+ if (done) {
2651
+ break;
2652
+ }
2653
+ yield value;
2654
+ }
2655
+ } finally {
2656
+ await reader.cancel();
2657
+ }
2658
+ };
2659
+
2660
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2661
+ const iterator = readBytes(stream, chunkSize);
2662
+
2663
+ let bytes = 0;
2664
+ let done;
2665
+ let _onFinish = (e) => {
2666
+ if (!done) {
2667
+ done = true;
2668
+ onFinish && onFinish(e);
2669
+ }
2670
+ };
2671
+
2672
+ return new ReadableStream({
2673
+ async pull(controller) {
2674
+ try {
2675
+ const {done, value} = await iterator.next();
2676
+
2677
+ if (done) {
2678
+ _onFinish();
2679
+ controller.close();
2680
+ return;
2681
+ }
2682
+
2683
+ let len = value.byteLength;
2684
+ if (onProgress) {
2685
+ let loadedBytes = bytes += len;
2686
+ onProgress(loadedBytes);
2687
+ }
2688
+ controller.enqueue(new Uint8Array(value));
2689
+ } catch (err) {
2690
+ _onFinish(err);
2691
+ throw err;
2692
+ }
2693
+ },
2694
+ cancel(reason) {
2695
+ _onFinish(reason);
2696
+ return iterator.return();
2697
+ }
2698
+ }, {
2699
+ highWaterMark: 2
2700
+ })
2701
+ };
2702
+
2703
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
2704
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
2705
+
2706
+ // used only inside the fetch adapter
2707
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2708
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2709
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2710
+ );
2711
+
2712
+ const test = (fn, ...args) => {
2713
+ try {
2714
+ return !!fn(...args);
2715
+ } catch (e) {
2716
+ return false
2717
+ }
2718
+ };
2719
+
2720
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
2721
+ let duplexAccessed = false;
2722
+
2723
+ const hasContentType = new Request(platform.origin, {
2724
+ body: new ReadableStream(),
2725
+ method: 'POST',
2726
+ get duplex() {
2727
+ duplexAccessed = true;
2728
+ return 'half';
2729
+ },
2730
+ }).headers.has('Content-Type');
2731
+
2732
+ return duplexAccessed && !hasContentType;
2733
+ });
2734
+
2735
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2736
+
2737
+ const supportsResponseStream = isReadableStreamSupported &&
2738
+ test(() => utils$1.isReadableStream(new Response('').body));
2739
+
2740
+
2741
+ const resolvers = {
2742
+ stream: supportsResponseStream && ((res) => res.body)
2743
+ };
2744
+
2745
+ isFetchSupported && (((res) => {
2746
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2747
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
2748
+ (_, config) => {
2749
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2750
+ });
2751
+ });
2752
+ })(new Response));
2753
+
2754
+ const getBodyLength = async (body) => {
2755
+ if (body == null) {
2756
+ return 0;
2757
+ }
2758
+
2759
+ if(utils$1.isBlob(body)) {
2760
+ return body.size;
2761
+ }
2762
+
2763
+ if(utils$1.isSpecCompliantForm(body)) {
2764
+ const _request = new Request(platform.origin, {
2765
+ method: 'POST',
2766
+ body,
2767
+ });
2768
+ return (await _request.arrayBuffer()).byteLength;
2769
+ }
2770
+
2771
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2772
+ return body.byteLength;
2773
+ }
2774
+
2775
+ if(utils$1.isURLSearchParams(body)) {
2776
+ body = body + '';
2777
+ }
2778
+
2779
+ if(utils$1.isString(body)) {
2780
+ return (await encodeText(body)).byteLength;
2781
+ }
2782
+ };
2783
+
2784
+ const resolveBodyLength = async (headers, body) => {
2785
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
2786
+
2787
+ return length == null ? getBodyLength(body) : length;
2788
+ };
2789
+
2790
+ var fetchAdapter = isFetchSupported && (async (config) => {
2791
+ let {
2792
+ url,
2793
+ method,
2794
+ data,
2795
+ signal,
2796
+ cancelToken,
2797
+ timeout,
2798
+ onDownloadProgress,
2799
+ onUploadProgress,
2800
+ responseType,
2801
+ headers,
2802
+ withCredentials = 'same-origin',
2803
+ fetchOptions
2804
+ } = resolveConfig(config);
2805
+
2806
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2807
+
2808
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2809
+
2810
+ let request;
2811
+
2812
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2813
+ composedSignal.unsubscribe();
2814
+ });
2815
+
2816
+ let requestContentLength;
2817
+
2818
+ try {
2819
+ if (
2820
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2821
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2822
+ ) {
2823
+ let _request = new Request(url, {
2824
+ method: 'POST',
2825
+ body: data,
2826
+ duplex: "half"
2827
+ });
2828
+
2829
+ let contentTypeHeader;
2830
+
2831
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2832
+ headers.setContentType(contentTypeHeader);
2833
+ }
2834
+
2835
+ if (_request.body) {
2836
+ const [onProgress, flush] = progressEventDecorator(
2837
+ requestContentLength,
2838
+ progressEventReducer(asyncDecorator(onUploadProgress))
2839
+ );
2840
+
2841
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2842
+ }
2843
+ }
2844
+
2845
+ if (!utils$1.isString(withCredentials)) {
2846
+ withCredentials = withCredentials ? 'include' : 'omit';
2847
+ }
2848
+
2849
+ // Cloudflare Workers throws when credentials are defined
2850
+ // see https://github.com/cloudflare/workerd/issues/902
2851
+ const isCredentialsSupported = "credentials" in Request.prototype;
2852
+ request = new Request(url, {
2853
+ ...fetchOptions,
2854
+ signal: composedSignal,
2855
+ method: method.toUpperCase(),
2856
+ headers: headers.normalize().toJSON(),
2857
+ body: data,
2858
+ duplex: "half",
2859
+ credentials: isCredentialsSupported ? withCredentials : undefined
2860
+ });
2861
+
2862
+ let response = await fetch(request);
2863
+
2864
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
2865
+
2866
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
2867
+ const options = {};
2868
+
2869
+ ['status', 'statusText', 'headers'].forEach(prop => {
2870
+ options[prop] = response[prop];
2871
+ });
2872
+
2873
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
2874
+
2875
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2876
+ responseContentLength,
2877
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
2878
+ ) || [];
2879
+
2880
+ response = new Response(
2881
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2882
+ flush && flush();
2883
+ unsubscribe && unsubscribe();
2884
+ }),
2885
+ options
2886
+ );
2887
+ }
2888
+
2889
+ responseType = responseType || 'text';
2890
+
2891
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
2892
+
2893
+ !isStreamResponse && unsubscribe && unsubscribe();
2894
+
2895
+ return await new Promise((resolve, reject) => {
2896
+ settle(resolve, reject, {
2897
+ data: responseData,
2898
+ headers: AxiosHeaders$1.from(response.headers),
2899
+ status: response.status,
2900
+ statusText: response.statusText,
2901
+ config,
2902
+ request
2903
+ });
2904
+ })
2905
+ } catch (err) {
2906
+ unsubscribe && unsubscribe();
2907
+
2908
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
2909
+ throw Object.assign(
2910
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
2911
+ {
2912
+ cause: err.cause || err
2913
+ }
2914
+ )
2915
+ }
2916
+
2917
+ throw AxiosError.from(err, err && err.code, config, request);
2918
+ }
2919
+ });
2920
+
2413
2921
  const knownAdapters = {
2414
2922
  http: httpAdapter,
2415
- xhr: xhrAdapter
2923
+ xhr: xhrAdapter,
2924
+ fetch: fetchAdapter
2416
2925
  };
2417
2926
 
2418
2927
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -2556,108 +3065,7 @@ function dispatchRequest(config) {
2556
3065
  });
2557
3066
  }
2558
3067
 
2559
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
2560
-
2561
- /**
2562
- * Config-specific merge-function which creates a new config-object
2563
- * by merging two configuration objects together.
2564
- *
2565
- * @param {Object} config1
2566
- * @param {Object} config2
2567
- *
2568
- * @returns {Object} New object resulting from merging config2 to config1
2569
- */
2570
- function mergeConfig(config1, config2) {
2571
- // eslint-disable-next-line no-param-reassign
2572
- config2 = config2 || {};
2573
- const config = {};
2574
-
2575
- function getMergedValue(target, source, caseless) {
2576
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2577
- return utils$1.merge.call({caseless}, target, source);
2578
- } else if (utils$1.isPlainObject(source)) {
2579
- return utils$1.merge({}, source);
2580
- } else if (utils$1.isArray(source)) {
2581
- return source.slice();
2582
- }
2583
- return source;
2584
- }
2585
-
2586
- // eslint-disable-next-line consistent-return
2587
- function mergeDeepProperties(a, b, caseless) {
2588
- if (!utils$1.isUndefined(b)) {
2589
- return getMergedValue(a, b, caseless);
2590
- } else if (!utils$1.isUndefined(a)) {
2591
- return getMergedValue(undefined, a, caseless);
2592
- }
2593
- }
2594
-
2595
- // eslint-disable-next-line consistent-return
2596
- function valueFromConfig2(a, b) {
2597
- if (!utils$1.isUndefined(b)) {
2598
- return getMergedValue(undefined, b);
2599
- }
2600
- }
2601
-
2602
- // eslint-disable-next-line consistent-return
2603
- function defaultToConfig2(a, b) {
2604
- if (!utils$1.isUndefined(b)) {
2605
- return getMergedValue(undefined, b);
2606
- } else if (!utils$1.isUndefined(a)) {
2607
- return getMergedValue(undefined, a);
2608
- }
2609
- }
2610
-
2611
- // eslint-disable-next-line consistent-return
2612
- function mergeDirectKeys(a, b, prop) {
2613
- if (prop in config2) {
2614
- return getMergedValue(a, b);
2615
- } else if (prop in config1) {
2616
- return getMergedValue(undefined, a);
2617
- }
2618
- }
2619
-
2620
- const mergeMap = {
2621
- url: valueFromConfig2,
2622
- method: valueFromConfig2,
2623
- data: valueFromConfig2,
2624
- baseURL: defaultToConfig2,
2625
- transformRequest: defaultToConfig2,
2626
- transformResponse: defaultToConfig2,
2627
- paramsSerializer: defaultToConfig2,
2628
- timeout: defaultToConfig2,
2629
- timeoutMessage: defaultToConfig2,
2630
- withCredentials: defaultToConfig2,
2631
- adapter: defaultToConfig2,
2632
- responseType: defaultToConfig2,
2633
- xsrfCookieName: defaultToConfig2,
2634
- xsrfHeaderName: defaultToConfig2,
2635
- onUploadProgress: defaultToConfig2,
2636
- onDownloadProgress: defaultToConfig2,
2637
- decompress: defaultToConfig2,
2638
- maxContentLength: defaultToConfig2,
2639
- maxBodyLength: defaultToConfig2,
2640
- beforeRedirect: defaultToConfig2,
2641
- transport: defaultToConfig2,
2642
- httpAgent: defaultToConfig2,
2643
- httpsAgent: defaultToConfig2,
2644
- cancelToken: defaultToConfig2,
2645
- socketPath: defaultToConfig2,
2646
- responseEncoding: defaultToConfig2,
2647
- validateStatus: mergeDirectKeys,
2648
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2649
- };
2650
-
2651
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2652
- const merge = mergeMap[prop] || mergeDeepProperties;
2653
- const configValue = merge(config1[prop], config2[prop], prop);
2654
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2655
- });
2656
-
2657
- return config;
2658
- }
2659
-
2660
- const VERSION = "1.6.1";
3068
+ const VERSION = "1.8.4";
2661
3069
 
2662
3070
  const validators$1 = {};
2663
3071
 
@@ -2708,6 +3116,14 @@ validators$1.transitional = function transitional(validator, version, message) {
2708
3116
  };
2709
3117
  };
2710
3118
 
3119
+ validators$1.spelling = function spelling(correctSpelling) {
3120
+ return (value, opt) => {
3121
+ // eslint-disable-next-line no-console
3122
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3123
+ return true;
3124
+ }
3125
+ };
3126
+
2711
3127
  /**
2712
3128
  * Assert object's properties type
2713
3129
  *
@@ -2772,7 +3188,34 @@ class Axios {
2772
3188
  *
2773
3189
  * @returns {Promise} The Promise to be fulfilled
2774
3190
  */
2775
- request(configOrUrl, config) {
3191
+ async request(configOrUrl, config) {
3192
+ try {
3193
+ return await this._request(configOrUrl, config);
3194
+ } catch (err) {
3195
+ if (err instanceof Error) {
3196
+ let dummy = {};
3197
+
3198
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3199
+
3200
+ // slice off the Error: ... line
3201
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3202
+ try {
3203
+ if (!err.stack) {
3204
+ err.stack = stack;
3205
+ // match without the 2 top stack lines
3206
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3207
+ err.stack += '\n' + stack;
3208
+ }
3209
+ } catch (e) {
3210
+ // ignore the case where "stack" is an un-writable property
3211
+ }
3212
+ }
3213
+
3214
+ throw err;
3215
+ }
3216
+ }
3217
+
3218
+ _request(configOrUrl, config) {
2776
3219
  /*eslint no-param-reassign:0*/
2777
3220
  // Allow for axios('example/url'[, config]) a la fetch API
2778
3221
  if (typeof configOrUrl === 'string') {
@@ -2807,6 +3250,18 @@ class Axios {
2807
3250
  }
2808
3251
  }
2809
3252
 
3253
+ // Set config.allowAbsoluteUrls
3254
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
3255
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3256
+ } else {
3257
+ config.allowAbsoluteUrls = true;
3258
+ }
3259
+
3260
+ validator.assertOptions(config, {
3261
+ baseUrl: validators.spelling('baseURL'),
3262
+ withXsrfToken: validators.spelling('withXSRFToken')
3263
+ }, true);
3264
+
2810
3265
  // Set config.method
2811
3266
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2812
3267
 
@@ -2897,7 +3352,7 @@ class Axios {
2897
3352
 
2898
3353
  getUri(config) {
2899
3354
  config = mergeConfig(this.defaults, config);
2900
- const fullPath = buildFullPath(config.baseURL, config.url);
3355
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
2901
3356
  return buildURL(fullPath, config.params, config.paramsSerializer);
2902
3357
  }
2903
3358
  }
@@ -3037,6 +3492,20 @@ class CancelToken {
3037
3492
  }
3038
3493
  }
3039
3494
 
3495
+ toAbortSignal() {
3496
+ const controller = new AbortController();
3497
+
3498
+ const abort = (err) => {
3499
+ controller.abort(err);
3500
+ };
3501
+
3502
+ this.subscribe(abort);
3503
+
3504
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3505
+
3506
+ return controller.signal;
3507
+ }
3508
+
3040
3509
  /**
3041
3510
  * Returns an object that contains a new `CancelToken` and a function that, when called,
3042
3511
  * cancels the `CancelToken`.
@@ -3236,7 +3705,7 @@ axios.default = axios;
3236
3705
  var axios$1 = axios;
3237
3706
 
3238
3707
  var name$1 = "@tryghost/content-api";
3239
- var version = "1.11.20";
3708
+ var version = "1.11.22";
3240
3709
  var repository = "https://github.com/TryGhost/SDK/tree/main/packages/content-api";
3241
3710
  var author = "Ghost Foundation";
3242
3711
  var license = "MIT";
@@ -3265,15 +3734,15 @@ var publishConfig = {
3265
3734
  access: "public"
3266
3735
  };
3267
3736
  var devDependencies = {
3268
- "@babel/core": "7.23.3",
3737
+ "@babel/core": "7.26.10",
3269
3738
  "@babel/polyfill": "7.12.1",
3270
- "@babel/preset-env": "7.23.3",
3271
- "@rollup/plugin-json": "6.0.1",
3272
- c8: "8.0.1",
3273
- "core-js": "3.33.2",
3739
+ "@babel/preset-env": "7.26.9",
3740
+ "@rollup/plugin-json": "6.1.0",
3741
+ c8: "10.1.3",
3742
+ "core-js": "3.41.0",
3274
3743
  "eslint-plugin-ghost": "3.4.0",
3275
- mocha: "10.2.0",
3276
- rollup: "2.79.1",
3744
+ mocha: "11.1.0",
3745
+ rollup: "2.79.2",
3277
3746
  "rollup-plugin-babel": "4.4.0",
3278
3747
  "rollup-plugin-commonjs": "10.1.0",
3279
3748
  "rollup-plugin-node-resolve": "5.2.0",
@@ -3281,12 +3750,12 @@ var devDependencies = {
3281
3750
  "rollup-plugin-replace": "2.2.0",
3282
3751
  "rollup-plugin-terser": "7.0.2",
3283
3752
  should: "13.2.3",
3284
- sinon: "17.0.1"
3753
+ sinon: "20.0.0"
3285
3754
  };
3286
3755
  var dependencies = {
3287
3756
  axios: "^1.0.0"
3288
3757
  };
3289
- var gitHead = "4839d3f97de2120d98fa47677eed7591dfa20e64";
3758
+ var gitHead = "19592ba6684cd896674e6bd1da92e3eb06e665f2";
3290
3759
  var packageInfo = {
3291
3760
  name: name$1,
3292
3761
  version: version,