axios 1.6.1 → 1.6.2

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.6.2](https://github.com/axios/axios/compare/v1.6.1...v1.6.2) (2023-11-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * **withXSRFToken:** added withXSRFToken option as a workaround to achieve the old `withCredentials` behavior; ([#6046](https://github.com/axios/axios/issues/6046)) ([cff9967](https://github.com/axios/axios/commit/cff996779b272a5e94c2b52f5503ccf668bc42dc))
9
+
10
+ ### PRs
11
+ - feat(withXSRFToken): added withXSRFToken option as a workaround to achieve the old `withCredentials` behavior; ( [#6046](https://api.github.com/repos/axios/axios/pulls/6046) )
12
+ ```
13
+
14
+ 📢 This PR added 'withXSRFToken' option as a replacement for old withCredentials behaviour.
15
+ You should now use withXSRFToken along with withCredential to get the old behavior.
16
+ This functionality is considered as a fix.
17
+ ```
18
+
19
+ ### Contributors to this release
20
+
21
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+271/-146 (#6081 #6080 #6079 #6078 #6046 #6064 #6063 )")
22
+ - <img src="https://avatars.githubusercontent.com/u/79681367?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Ng Choon Khon (CK)](https://github.com/ckng0221 "+4/-4 (#6073 )")
23
+ - <img src="https://avatars.githubusercontent.com/u/9162827?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Muhammad Noman](https://github.com/mnomanmemon "+2/-2 (#6048 )")
24
+
3
25
  ## [1.6.1](https://github.com/axios/axios/compare/v1.6.0...v1.6.1) (2023-11-08)
4
26
 
5
27
 
@@ -13,6 +35,15 @@
13
35
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+432/-65 (#6059 #6056 #6055 )")
14
36
  - <img src="https://avatars.githubusercontent.com/u/3982806?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Fabian Meyer](https://github.com/meyfa "+5/-2 (#5835 )")
15
37
 
38
+ ### PRs
39
+ - feat(withXSRFToken): added withXSRFToken option as a workaround to achieve the old &#x60;withCredentials&#x60; behavior; ( [#6046](https://api.github.com/repos/axios/axios/pulls/6046) )
40
+ ```
41
+
42
+ 📢 This PR added &#x27;withXSRFToken&#x27; option as a replacement for old withCredentials behaviour.
43
+ You should now use withXSRFToken along with withCredential to get the old behavior.
44
+ This functionality is considered as a fix.
45
+ ```
46
+
16
47
  # [1.6.0](https://github.com/axios/axios/compare/v1.5.1...v1.6.0) (2023-10-26)
17
48
 
18
49
 
package/README.md CHANGED
@@ -452,6 +452,9 @@ These are the available config options for making requests. Only the `url` is re
452
452
 
453
453
  // `xsrfHeaderName` is the name of the http header that carries the xsrf token value
454
454
  xsrfHeaderName: 'X-XSRF-TOKEN', // default
455
+
456
+ // `undefined` (default) - set XSRF header only for the same origin requests
457
+ withXSRFToken: boolean | undefined | ((config: InternalAxiosRequestConfig) => boolean | undefined),
455
458
 
456
459
  // `onUploadProgress` allows handling of progress events for uploads
457
460
  // browser & node.js
@@ -543,7 +546,7 @@ These are the available config options for making requests. Only the `url` is re
543
546
  // automatically. If set to `true` will also remove the 'content-encoding' header
544
547
  // from the responses objects of all decompressed responses
545
548
  // - Node only (XHR cannot turn off decompression)
546
- decompress: true // default
549
+ decompress: true, // default
547
550
 
548
551
  // `insecureHTTPParser` boolean.
549
552
  // Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers.
@@ -551,7 +554,7 @@ These are the available config options for making requests. Only the `url` is re
551
554
  // Using the insecure parser should be avoided.
552
555
  // see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback
553
556
  // see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none
554
- insecureHTTPParser: undefined // default
557
+ insecureHTTPParser: undefined, // default
555
558
 
556
559
  // transitional options for backward compatibility that may be removed in the newer versions
557
560
  transitional: {
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.6.1 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.6.2 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -1910,44 +1910,31 @@
1910
1910
 
1911
1911
  var cookies = platform.hasStandardBrowserEnv ?
1912
1912
  // Standard browser envs support document.cookie
1913
- function standardBrowserEnv() {
1914
- return {
1915
- write: function write(name, value, expires, path, domain, secure) {
1916
- var cookie = [];
1917
- cookie.push(name + '=' + encodeURIComponent(value));
1918
- if (utils$1.isNumber(expires)) {
1919
- cookie.push('expires=' + new Date(expires).toGMTString());
1920
- }
1921
- if (utils$1.isString(path)) {
1922
- cookie.push('path=' + path);
1923
- }
1924
- if (utils$1.isString(domain)) {
1925
- cookie.push('domain=' + domain);
1926
- }
1927
- if (secure === true) {
1928
- cookie.push('secure');
1929
- }
1930
- document.cookie = cookie.join('; ');
1931
- },
1932
- read: function read(name) {
1933
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1934
- return match ? decodeURIComponent(match[3]) : null;
1935
- },
1936
- remove: function remove(name) {
1937
- this.write(name, '', Date.now() - 86400000);
1938
- }
1939
- };
1940
- }() :
1941
- // Non standard browser env (web workers, react-native) lack needed support.
1942
- function nonStandardBrowserEnv() {
1943
- return {
1944
- write: function write() {},
1945
- read: function read() {
1946
- return null;
1947
- },
1948
- remove: function remove() {}
1949
- };
1950
- }();
1913
+ {
1914
+ write: function write(name, value, expires, path, domain, secure) {
1915
+ var cookie = [name + '=' + encodeURIComponent(value)];
1916
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
1917
+ utils$1.isString(path) && cookie.push('path=' + path);
1918
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
1919
+ secure === true && cookie.push('secure');
1920
+ document.cookie = cookie.join('; ');
1921
+ },
1922
+ read: function read(name) {
1923
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1924
+ return match ? decodeURIComponent(match[3]) : null;
1925
+ },
1926
+ remove: function remove(name) {
1927
+ this.write(name, '', Date.now() - 86400000);
1928
+ }
1929
+ } :
1930
+ // Non-standard browser env (web workers, react-native) lack needed support.
1931
+ {
1932
+ write: function write() {},
1933
+ read: function read() {
1934
+ return null;
1935
+ },
1936
+ remove: function remove() {}
1937
+ };
1951
1938
 
1952
1939
  /**
1953
1940
  * Determines whether the specified URL is absolute
@@ -2001,7 +1988,7 @@
2001
1988
  var originURL;
2002
1989
 
2003
1990
  /**
2004
- * Parse a URL to discover it's components
1991
+ * Parse a URL to discover its components
2005
1992
  *
2006
1993
  * @param {String} url The URL to be parsed
2007
1994
  * @returns {Object}
@@ -2120,7 +2107,8 @@
2120
2107
  return new Promise(function dispatchXhrRequest(resolve, reject) {
2121
2108
  var requestData = config.data;
2122
2109
  var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2123
- var responseType = config.responseType;
2110
+ var responseType = config.responseType,
2111
+ withXSRFToken = config.withXSRFToken;
2124
2112
  var onCanceled;
2125
2113
  function done() {
2126
2114
  if (config.cancelToken) {
@@ -2245,11 +2233,13 @@
2245
2233
  // This is only done if running in a standard browser environment.
2246
2234
  // Specifically not if we're in a web worker, or react-native.
2247
2235
  if (platform.hasStandardBrowserEnv) {
2248
- // Add xsrf header
2249
- // regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
2250
- var xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2251
- if (xsrfValue) {
2252
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2236
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
2237
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(fullPath)) {
2238
+ // Add xsrf header
2239
+ var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2240
+ if (xsrfValue) {
2241
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2242
+ }
2253
2243
  }
2254
2244
  }
2255
2245
 
@@ -2499,6 +2489,7 @@
2499
2489
  timeout: defaultToConfig2,
2500
2490
  timeoutMessage: defaultToConfig2,
2501
2491
  withCredentials: defaultToConfig2,
2492
+ withXSRFToken: defaultToConfig2,
2502
2493
  adapter: defaultToConfig2,
2503
2494
  responseType: defaultToConfig2,
2504
2495
  xsrfCookieName: defaultToConfig2,
@@ -2528,7 +2519,7 @@
2528
2519
  return config;
2529
2520
  }
2530
2521
 
2531
- var VERSION = "1.6.1";
2522
+ var VERSION = "1.6.2";
2532
2523
 
2533
2524
  var validators$1 = {};
2534
2525