@tryghost/content-api 1.11.20 → 1.11.21

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.
@@ -3,7 +3,7 @@
3
3
  var axios = require('axios');
4
4
 
5
5
  var name$1 = "@tryghost/content-api";
6
- var version = "1.11.20";
6
+ var version = "1.11.21";
7
7
  var repository = "https://github.com/TryGhost/SDK/tree/main/packages/content-api";
8
8
  var author = "Ghost Foundation";
9
9
  var license = "MIT";
@@ -32,14 +32,14 @@ var publishConfig = {
32
32
  access: "public"
33
33
  };
34
34
  var devDependencies = {
35
- "@babel/core": "7.23.3",
35
+ "@babel/core": "7.24.4",
36
36
  "@babel/polyfill": "7.12.1",
37
- "@babel/preset-env": "7.23.3",
38
- "@rollup/plugin-json": "6.0.1",
39
- c8: "8.0.1",
40
- "core-js": "3.33.2",
37
+ "@babel/preset-env": "7.24.4",
38
+ "@rollup/plugin-json": "6.1.0",
39
+ c8: "9.1.0",
40
+ "core-js": "3.37.0",
41
41
  "eslint-plugin-ghost": "3.4.0",
42
- mocha: "10.2.0",
42
+ mocha: "10.4.0",
43
43
  rollup: "2.79.1",
44
44
  "rollup-plugin-babel": "4.4.0",
45
45
  "rollup-plugin-commonjs": "10.1.0",
@@ -53,7 +53,7 @@ var devDependencies = {
53
53
  var dependencies = {
54
54
  axios: "^1.0.0"
55
55
  };
56
- var gitHead = "4839d3f97de2120d98fa47677eed7591dfa20e64";
56
+ var gitHead = "048ccde4bd78d2dcd60e778d03eb8dc3227cece5";
57
57
  var packageInfo = {
58
58
  name: name$1,
59
59
  version: version,
package/es/content-api.js CHANGED
@@ -1349,6 +1349,9 @@ function arrayToObject(arr) {
1349
1349
  function formDataToJSON(formData) {
1350
1350
  function buildPath(path, value, target, index) {
1351
1351
  let name = path[index++];
1352
+
1353
+ if (name === '__proto__') return true;
1354
+
1352
1355
  const isNumericKey = Number.isFinite(+name);
1353
1356
  const isLast = index >= path.length;
1354
1357
  name = !name && utils$1.isArray(target) ? target.length : name;
@@ -1432,9 +1435,6 @@ const defaults = {
1432
1435
  const isFormData = utils$1.isFormData(data);
1433
1436
 
1434
1437
  if (isFormData) {
1435
- if (!hasJSONContentType) {
1436
- return data;
1437
- }
1438
1438
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1439
1439
  }
1440
1440
 
@@ -1957,51 +1957,42 @@ function settle(resolve, reject, response) {
1957
1957
 
1958
1958
  var cookies = platform.hasStandardBrowserEnv ?
1959
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));
1960
+ // Standard browser envs support document.cookie
1961
+ {
1962
+ write(name, value, expires, path, domain, secure) {
1963
+ const cookie = [name + '=' + encodeURIComponent(value)];
1966
1964
 
1967
- if (utils$1.isNumber(expires)) {
1968
- cookie.push('expires=' + new Date(expires).toGMTString());
1969
- }
1965
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
1970
1966
 
1971
- if (utils$1.isString(path)) {
1972
- cookie.push('path=' + path);
1973
- }
1967
+ utils$1.isString(path) && cookie.push('path=' + path);
1974
1968
 
1975
- if (utils$1.isString(domain)) {
1976
- cookie.push('domain=' + domain);
1977
- }
1969
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
1978
1970
 
1979
- if (secure === true) {
1980
- cookie.push('secure');
1981
- }
1971
+ secure === true && cookie.push('secure');
1982
1972
 
1983
- document.cookie = cookie.join('; ');
1984
- },
1973
+ document.cookie = cookie.join('; ');
1974
+ },
1985
1975
 
1986
- read: function read(name) {
1987
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1988
- return (match ? decodeURIComponent(match[3]) : null);
1989
- },
1976
+ read(name) {
1977
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1978
+ return (match ? decodeURIComponent(match[3]) : null);
1979
+ },
1990
1980
 
1991
- remove: function remove(name) {
1992
- this.write(name, '', Date.now() - 86400000);
1993
- }
1994
- };
1995
- })() :
1981
+ remove(name) {
1982
+ this.write(name, '', Date.now() - 86400000);
1983
+ }
1984
+ }
1996
1985
 
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
- })();
1986
+ :
1987
+
1988
+ // Non-standard browser env (web workers, react-native) lack needed support.
1989
+ {
1990
+ write() {},
1991
+ read() {
1992
+ return null;
1993
+ },
1994
+ remove() {}
1995
+ };
2005
1996
 
2006
1997
  /**
2007
1998
  * Determines whether the specified URL is absolute
@@ -2027,7 +2018,7 @@ function isAbsoluteURL(url) {
2027
2018
  */
2028
2019
  function combineURLs(baseURL, relativeURL) {
2029
2020
  return relativeURL
2030
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2021
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2031
2022
  : baseURL;
2032
2023
  }
2033
2024
 
@@ -2058,7 +2049,7 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
2058
2049
  let originURL;
2059
2050
 
2060
2051
  /**
2061
- * Parse a URL to discover it's components
2052
+ * Parse a URL to discover its components
2062
2053
  *
2063
2054
  * @param {String} url The URL to be parsed
2064
2055
  * @returns {Object}
@@ -2203,7 +2194,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2203
2194
  return new Promise(function dispatchXhrRequest(resolve, reject) {
2204
2195
  let requestData = config.data;
2205
2196
  const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2206
- const responseType = config.responseType;
2197
+ let {responseType, withXSRFToken} = config;
2207
2198
  let onCanceled;
2208
2199
  function done() {
2209
2200
  if (config.cancelToken) {
@@ -2339,13 +2330,16 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2339
2330
  // Add xsrf header
2340
2331
  // This is only done if running in a standard browser environment.
2341
2332
  // 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);
2333
+ if(platform.hasStandardBrowserEnv) {
2334
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
2335
+
2336
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
2337
+ // Add xsrf header
2338
+ const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2346
2339
 
2347
- if (xsrfValue) {
2348
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2340
+ if (xsrfValue) {
2341
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2342
+ }
2349
2343
  }
2350
2344
  }
2351
2345
 
@@ -2556,7 +2550,7 @@ function dispatchRequest(config) {
2556
2550
  });
2557
2551
  }
2558
2552
 
2559
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
2553
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2560
2554
 
2561
2555
  /**
2562
2556
  * Config-specific merge-function which creates a new config-object
@@ -2628,6 +2622,7 @@ function mergeConfig(config1, config2) {
2628
2622
  timeout: defaultToConfig2,
2629
2623
  timeoutMessage: defaultToConfig2,
2630
2624
  withCredentials: defaultToConfig2,
2625
+ withXSRFToken: defaultToConfig2,
2631
2626
  adapter: defaultToConfig2,
2632
2627
  responseType: defaultToConfig2,
2633
2628
  xsrfCookieName: defaultToConfig2,
@@ -2657,7 +2652,7 @@ function mergeConfig(config1, config2) {
2657
2652
  return config;
2658
2653
  }
2659
2654
 
2660
- const VERSION = "1.6.1";
2655
+ const VERSION = "1.6.8";
2661
2656
 
2662
2657
  const validators$1 = {};
2663
2658
 
@@ -2772,7 +2767,31 @@ class Axios {
2772
2767
  *
2773
2768
  * @returns {Promise} The Promise to be fulfilled
2774
2769
  */
2775
- request(configOrUrl, config) {
2770
+ async request(configOrUrl, config) {
2771
+ try {
2772
+ return await this._request(configOrUrl, config);
2773
+ } catch (err) {
2774
+ if (err instanceof Error) {
2775
+ let dummy;
2776
+
2777
+ Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
2778
+
2779
+ // slice off the Error: ... line
2780
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
2781
+
2782
+ if (!err.stack) {
2783
+ err.stack = stack;
2784
+ // match without the 2 top stack lines
2785
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
2786
+ err.stack += '\n' + stack;
2787
+ }
2788
+ }
2789
+
2790
+ throw err;
2791
+ }
2792
+ }
2793
+
2794
+ _request(configOrUrl, config) {
2776
2795
  /*eslint no-param-reassign:0*/
2777
2796
  // Allow for axios('example/url'[, config]) a la fetch API
2778
2797
  if (typeof configOrUrl === 'string') {
@@ -3236,7 +3255,7 @@ axios.default = axios;
3236
3255
  var axios$1 = axios;
3237
3256
 
3238
3257
  var name$1 = "@tryghost/content-api";
3239
- var version = "1.11.20";
3258
+ var version = "1.11.21";
3240
3259
  var repository = "https://github.com/TryGhost/SDK/tree/main/packages/content-api";
3241
3260
  var author = "Ghost Foundation";
3242
3261
  var license = "MIT";
@@ -3265,14 +3284,14 @@ var publishConfig = {
3265
3284
  access: "public"
3266
3285
  };
3267
3286
  var devDependencies = {
3268
- "@babel/core": "7.23.3",
3287
+ "@babel/core": "7.24.4",
3269
3288
  "@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",
3289
+ "@babel/preset-env": "7.24.4",
3290
+ "@rollup/plugin-json": "6.1.0",
3291
+ c8: "9.1.0",
3292
+ "core-js": "3.37.0",
3274
3293
  "eslint-plugin-ghost": "3.4.0",
3275
- mocha: "10.2.0",
3294
+ mocha: "10.4.0",
3276
3295
  rollup: "2.79.1",
3277
3296
  "rollup-plugin-babel": "4.4.0",
3278
3297
  "rollup-plugin-commonjs": "10.1.0",
@@ -3286,7 +3305,7 @@ var devDependencies = {
3286
3305
  var dependencies = {
3287
3306
  axios: "^1.0.0"
3288
3307
  };
3289
- var gitHead = "4839d3f97de2120d98fa47677eed7591dfa20e64";
3308
+ var gitHead = "048ccde4bd78d2dcd60e778d03eb8dc3227cece5";
3290
3309
  var packageInfo = {
3291
3310
  name: name$1,
3292
3311
  version: version,