axios 0.21.1 → 0.21.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.
package/CHANGELOG.md CHANGED
@@ -1,18 +1,87 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.21.2 (September 4, 2021)
4
+
5
+ Fixes and Functionality:
6
+
7
+ - Updating axios requests to be delayed by pre-emptive promise creation ([#2702](https://github.com/axios/axios/pull/2702))
8
+ - Adding "synchronous" and "runWhen" options to interceptors api ([#2702](https://github.com/axios/axios/pull/2702))
9
+ - Updating of transformResponse ([#3377](https://github.com/axios/axios/pull/3377))
10
+ - Adding ability to omit User-Agent header ([#3703](https://github.com/axios/axios/pull/3703))
11
+ - Adding multiple JSON improvements ([#3688](https://github.com/axios/axios/pull/3688), [#3763](https://github.com/axios/axios/pull/3763))
12
+ - Fixing quadratic runtime and extra memory usage when setting a maxContentLength ([#3738](https://github.com/axios/axios/pull/3738))
13
+ - Adding parseInt to config.timeout ([#3781](https://github.com/axios/axios/pull/3781))
14
+ - Adding custom return type support to interceptor ([#3783](https://github.com/axios/axios/pull/3783))
15
+ - Adding security fix for ReDoS vulnerability ([#3980](https://github.com/axios/axios/pull/3980))
16
+
17
+ Internal and Tests:
18
+
19
+ - Updating build dev dependancies ([#3401](https://github.com/axios/axios/pull/3401))
20
+ - Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538))
21
+ - Updating follow rediect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771))
22
+ - Updating karma sauce launcher to fix failing sauce tests ([#3712](https://github.com/axios/axios/pull/3712), [#3717](https://github.com/axios/axios/pull/3717))
23
+ - Updating content-type header for application/json to not contain charset field, according do RFC 8259 ([#2154](https://github.com/axios/axios/pull/2154))
24
+ - Fixing tests by bumping karma-sauce-launcher version ([#3813](https://github.com/axios/axios/pull/3813))
25
+ - Changing testing process from Travis CI to GitHub Actions ([#3938](https://github.com/axios/axios/pull/3938))
26
+
27
+ Documentation:
28
+
29
+ - Updating documentation around the use of `AUTH_TOKEN` with multiple domain endpoints ([#3539](https://github.com/axios/axios/pull/3539))
30
+ - Remove duplication of item in changelog ([#3523](https://github.com/axios/axios/pull/3523))
31
+ - Fixing gramatical errors ([#2642](https://github.com/axios/axios/pull/2642))
32
+ - Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567))
33
+ - Moving gitpod metion ([#2637](https://github.com/axios/axios/pull/2637))
34
+ - Adding new axios documentation website link ([#3681](https://github.com/axios/axios/pull/3681), [#3707](https://github.com/axios/axios/pull/3707))
35
+ - Updating documentation around dispatching requests ([#3772](https://github.com/axios/axios/pull/3772))
36
+ - Adding documentation for the type guard isAxiosError ([#3767](https://github.com/axios/axios/pull/3767))
37
+ - Adding explanation of cancel token ([#3803](https://github.com/axios/axios/pull/3803))
38
+ - Updating CI status badge ([#3953](https://github.com/axios/axios/pull/3953))
39
+ - Fixing errors with JSON documentation ([#3936](https://github.com/axios/axios/pull/3936))
40
+ - Fixing README typo under Request Config ([#3825](https://github.com/axios/axios/pull/3825))
41
+ - Adding axios-multi-api to the ecosystem file ([#3817](https://github.com/axios/axios/pull/3817))
42
+ - Adding SECURITY.md to properly disclose security vulnerabilities ([#3981](https://github.com/axios/axios/pull/3981))
43
+
44
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
45
+
46
+ - [Jay](mailto:jasonsaayman@gmail.com)
47
+ - [Sasha Korotkov](https://github.com/SashaKoro)
48
+ - [Daniel Lopretto](https://github.com/timemachine3030)
49
+ - [Mike Bishop](https://github.com/MikeBishop)
50
+ - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
51
+ - [Mark](https://github.com/bimbiltu)
52
+ - [Philipe Gouveia Paixão](https://github.com/piiih)
53
+ - [hippo](https://github.com/hippo2cat)
54
+ - [ready-research](https://github.com/ready-research)
55
+ - [Xianming Zhong](https://github.com/chinesedfan)
56
+ - [Christopher Chrapka](https://github.com/OJezu)
57
+ - [Brian Anglin](https://github.com/anglinb)
58
+ - [Kohta Ito](https://github.com/koh110)
59
+ - [Ali Clark](https://github.com/aliclark)
60
+ - [caikan](https://github.com/caikan)
61
+ - [Elina Gorshkova](https://github.com/elinagorshkova)
62
+ - [Ryota Ikezawa](https://github.com/paveg)
63
+ - [Nisar Hassan Naqvi](https://github.com/nisarhassan12)
64
+ - [Jake](https://github.com/codemaster138)
65
+ - [TagawaHirotaka](https://github.com/wafuwafu13)
66
+ - [Johannes Jarbratt](https://github.com/johachi)
67
+ - [Mo Sattler](https://github.com/MoSattler)
68
+ - [Sam Carlton](https://github.com/ThatGuySam)
69
+ - [Matt Czapliński](https://github.com/MattCCC)
70
+ - [Ziding Zhang](https://github.com/zidingz)
71
+
3
72
  ### 0.21.1 (December 21, 2020)
4
73
 
5
74
  Fixes and Functionality:
6
75
 
7
- - Hotfix: Prevent SSRF (#3410)
8
- - Protocol not parsed when setting proxy config from env vars (#3070)
9
- - Updating axios in types to be lower case (#2797)
10
- - Adding a type guard for `AxiosError` (#2949)
76
+ - Hotfix: Prevent SSRF ([#3410](https://github.com/axios/axios/pull/3410))
77
+ - Protocol not parsed when setting proxy config from env vars ([#3070](https://github.com/axios/axios/pull/3070))
78
+ - Updating axios in types to be lower case ([#2797](https://github.com/axios/axios/pull/2797))
79
+ - Adding a type guard for `AxiosError` ([#2949](https://github.com/axios/axios/pull/2949))
11
80
 
12
81
  Internal and Tests:
13
82
 
14
- - Remove the skipping of the `socket` http test (#3364)
15
- - Use different socket for Win32 test (#3375)
83
+ - Remove the skipping of the `socket` http test ([#3364](https://github.com/axios/axios/pull/3364))
84
+ - Use different socket for Win32 test ([#3375](https://github.com/axios/axios/pull/3375))
16
85
 
17
86
  Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
18
87
 
@@ -93,7 +162,7 @@ Fixes and Functionality:
93
162
  - Adding test to check if password with non-Latin1 characters pass
94
163
  - Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
95
164
  There is a bug in react native Android platform when using get method. It will trigger a 'Network Error' when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug.
96
- - Fixing Cookie Helper with Asyc Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
165
+ - Fixing Cookie Helper with Async Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
97
166
  - Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
98
167
  - Fix 'progressEvent' type
99
168
  - Update axios.ts
@@ -305,7 +374,6 @@ Fixes and Functionality:
305
374
  - Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383))
306
375
  - Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290))
307
376
  - Do not modify config.url when using a relative baseURL (resolves [#1628](https://github.com/axios/axios/issues/1098)) ([#2391](https://github.com/axios/axios/pull/2391))
308
- - Add typescript HTTP method definition for LINK and UNLINK ([#2444](https://github.com/axios/axios/pull/2444))
309
377
 
310
378
  Internal:
311
379
 
package/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
4
4
  [![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
5
- [![build status](https://img.shields.io/travis/axios/axios/master.svg?style=flat-square)](https://travis-ci.org/axios/axios)
5
+ ![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg)
6
+ [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios)
6
7
  [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
7
8
  [![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
8
9
  [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
@@ -10,6 +11,9 @@
10
11
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
11
12
 
12
13
  Promise based HTTP client for the browser and node.js
14
+
15
+ > New axios docs website: [click here](https://axios-http.com/)
16
+
13
17
  ## Table of Contents
14
18
 
15
19
  - [Features](#features)
@@ -452,8 +456,21 @@ These are the available config options for making requests. Only the `url` is re
452
456
  // automatically. If set to `true` will also remove the 'content-encoding' header
453
457
  // from the responses objects of all decompressed responses
454
458
  // - Node only (XHR cannot turn off decompression)
455
- decompress: true // default
456
-
459
+ decompress: true, // default
460
+
461
+ // transitional options for backward compatibility that may be removed in the newer versions
462
+ transitional: {
463
+ // silent JSON parsing mode
464
+ // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
465
+ // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
466
+ silentJSONParsing: true, // default value for the current Axios version
467
+
468
+ // try to parse the response string as JSON even if `responseType` is not 'json'
469
+ forcedJSONParsing: true;
470
+
471
+ // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
472
+ clarifyTimeoutError: false,
473
+ }
457
474
  }
458
475
  ```
459
476
 
@@ -510,7 +527,11 @@ You can specify config defaults that will be applied to every request.
510
527
 
511
528
  ```js
512
529
  axios.defaults.baseURL = 'https://api.example.com';
530
+
531
+ // Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them.
532
+ // See below for an example using Custom instance defaults instead.
513
533
  axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
534
+
514
535
  axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
515
536
  ```
516
537
 
@@ -585,6 +606,34 @@ const instance = axios.create();
585
606
  instance.interceptors.request.use(function () {/*...*/});
586
607
  ```
587
608
 
609
+ When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay
610
+ in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
611
+ the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag
612
+ to the options object that will tell axios to run the code synchronously and avoid any delays in request execution.
613
+
614
+ ```js
615
+ axios.interceptors.request.use(function (config) {
616
+ config.headers.test = 'I am only a header!';
617
+ return config;
618
+ }, null, { synchronous: true });
619
+ ```
620
+
621
+ If you want to execute a particular interceptor based on a runtime check,
622
+ you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return
623
+ of `runWhen` is `false`. The function will be called with the config
624
+ object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
625
+ asynchronous request interceptor that only needs to run at certain times.
626
+
627
+ ```js
628
+ function onGetCall(config) {
629
+ return config.method === 'get';
630
+ }
631
+ axios.interceptors.request.use(function (config) {
632
+ config.headers.test = 'special get headers';
633
+ return config;
634
+ }, null, { runWhen: onGetCall });
635
+ ```
636
+
588
637
  ## Handling Errors
589
638
 
590
639
  ```js
@@ -678,6 +727,7 @@ cancel();
678
727
  ```
679
728
 
680
729
  > Note: you can cancel several requests with the same cancel token.
730
+ > If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make real request.
681
731
 
682
732
  ## Using application/x-www-form-urlencoded format
683
733
 
@@ -777,12 +827,30 @@ axios depends on a native ES6 Promise implementation to be [supported](http://ca
777
827
  If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
778
828
 
779
829
  ## TypeScript
780
- axios includes [TypeScript](http://typescriptlang.org) definitions.
830
+
831
+ axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors.
832
+
781
833
  ```typescript
782
- import axios from 'axios';
783
- axios.get('/user?ID=12345');
834
+ let user: User = null;
835
+ try {
836
+ const { data } = await axios.get('/user?ID=12345');
837
+ user = data.userDetails;
838
+ } catch (error) {
839
+ if (axios.isAxiosError(error)) {
840
+ handleAxiosError(error);
841
+ } else {
842
+ handleUnexpectedError(error);
843
+ }
844
+ }
784
845
  ```
785
846
 
847
+ ## Online one-click setup
848
+
849
+ You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online.
850
+
851
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js)
852
+
853
+
786
854
  ## Resources
787
855
 
788
856
  * [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please report security issues to jasonsaayman@gmail.com