axios 0.20.0-0 → 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,5 +1,131 @@
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
+
72
+ ### 0.21.1 (December 21, 2020)
73
+
74
+ Fixes and Functionality:
75
+
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))
80
+
81
+ Internal and Tests:
82
+
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))
85
+
86
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
87
+
88
+ - Daniel Lopretto <timemachine3030@users.noreply.github.com>
89
+ - Jason Kwok <JasonHK@users.noreply.github.com>
90
+ - Jay <jasonsaayman@gmail.com>
91
+ - Jonathan Foster <jonathan@jonathanfoster.io>
92
+ - Remco Haszing <remcohaszing@gmail.com>
93
+ - Xianming Zhong <chinesedfan@qq.com>
94
+
95
+ ### 0.21.0 (October 23, 2020)
96
+
97
+ Fixes and Functionality:
98
+
99
+ - Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287))
100
+ - Fixing node types ([#3237](https://github.com/axios/axios/pull/3237))
101
+ - Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282))
102
+ - Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289))
103
+ - Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled ([#3200](https://github.com/axios/axios/pull/3200))
104
+
105
+ Internal and Tests:
106
+
107
+ - Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361))
108
+
109
+ Documentation:
110
+
111
+ - Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252))
112
+ - Fixing typos ([#3309](https://github.com/axios/axios/pull/3309))
113
+
114
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
115
+
116
+ - Allan Cruz <57270969+Allanbcruz@users.noreply.github.com>
117
+ - George Cheng <Gerhut@GMail.com>
118
+ - Jay <jasonsaayman@gmail.com>
119
+ - Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
120
+ - Remco Haszing <remcohaszing@gmail.com>
121
+ - Taemin Shin <cprayer13@gmail.com>
122
+ - Tim Gates <tim.gates@iress.com>
123
+ - Xianming Zhong <chinesedfan@qq.com>
124
+
125
+ ### 0.20.0 (August 20, 2020)
126
+
127
+ Release of 0.20.0-pre as a full release with no other changes.
128
+
3
129
  ### 0.20.0-pre (July 15, 2020)
4
130
 
5
131
  Fixes and Functionality:
@@ -36,7 +162,7 @@ Fixes and Functionality:
36
162
  - Adding test to check if password with non-Latin1 characters pass
37
163
  - Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
38
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.
39
- - 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))
40
166
  - Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
41
167
  - Fix 'progressEvent' type
42
168
  - Update axios.ts
@@ -54,7 +180,7 @@ Fixes and Functionality:
54
180
  - Fixing test\unit\adapters\http.js lint errors
55
181
  - Adding test for disabling auto decompression
56
182
  - Removing changes that fixed lint errors in tests
57
- - Removing formating change to unit test
183
+ - Removing formatting change to unit test
58
184
  - Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781))
59
185
  - Add independent option to set the maximum size of the request body
60
186
  - Remove maxBodyLength check
@@ -100,14 +226,14 @@ Internal and Tests:
100
226
  - Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210))
101
227
  - Adding console log on sandbox server startup
102
228
  - Update server.js
103
- Add server error handeling
229
+ Add server error handling
104
230
  - Update server.js
105
231
  Better error message, remove retry.
106
232
  - Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996))
107
233
  Update tests.
108
234
  - Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695))
109
235
  - Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601))
110
- - Fixing issue for HEAD method and gziped repsonse ([#2666](https://github.com/axios/axios/pull/2666))
236
+ - Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666))
111
237
  - Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748))
112
238
  - chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443))
113
239
 
@@ -145,7 +271,7 @@ Documentation:
145
271
  - Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878))
146
272
  This badge will show the version on CDNJS!
147
273
  - Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928))
148
- - Made a adjustment to the documenation to clear up any ambiguity around the use of "fs". This should help clear up that the code examples with "fs" cannot be used on the client side.
274
+ - Made an adjustment to the documentation to clear up any ambiguity around the use of "fs". This should help clear up that the code examples with "fs" cannot be used on the client side.
149
275
  - Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912))
150
276
  Rewrote the comment from "Reject only if the status code is greater than or equal to 500" to "Resolve only if the status code is less than 500"
151
277
  - Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805))
@@ -248,7 +374,6 @@ Fixes and Functionality:
248
374
  - Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383))
249
375
  - Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290))
250
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))
251
- - Add typescript HTTP method definition for LINK and UNLINK ([#2444](https://github.com/axios/axios/pull/2444))
252
377
 
253
378
  Internal:
254
379
 
@@ -272,7 +397,7 @@ Documentation:
272
397
  - Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399))
273
398
  - Update README.md ([#2504](https://github.com/axios/axios/pull/2504))
274
399
  - Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432))
275
- - upadating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
400
+ - updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
276
401
  - Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271))
277
402
  - Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198))
278
403
 
@@ -325,7 +450,7 @@ New Functionality:
325
450
 
326
451
  - Add getUri method ([#1712](https://github.com/axios/axios/issues/1712))
327
452
  - Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693))
328
- - Add toJSON to decorated Axios errors to faciliate serialization ([#1625](https://github.com/axios/axios/issues/1625))
453
+ - Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625))
329
454
  - Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623))
330
455
  - Typings: allow custom return types
331
456
  - Add option to specify character set in responses (with http adapter)
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)
@@ -422,7 +426,7 @@ These are the available config options for making requests. Only the `url` is re
422
426
  httpAgent: new http.Agent({ keepAlive: true }),
423
427
  httpsAgent: new https.Agent({ keepAlive: true }),
424
428
 
425
- // `proxy` defines the hostname and port of the proxy server.
429
+ // `proxy` defines the hostname, port, and protocol of the proxy server.
426
430
  // You can also define your proxy using the conventional `http_proxy` and
427
431
  // `https_proxy` environment variables. If you are using environment variables
428
432
  // for your proxy configuration, you can also define a `no_proxy` environment
@@ -432,7 +436,9 @@ These are the available config options for making requests. Only the `url` is re
432
436
  // supplies credentials.
433
437
  // This will set an `Proxy-Authorization` header, overwriting any existing
434
438
  // `Proxy-Authorization` custom headers you have set using `headers`.
439
+ // If the proxy server uses HTTPS, then you must set the protocol to `https`.
435
440
  proxy: {
441
+ protocol: 'https',
436
442
  host: '127.0.0.1',
437
443
  port: 9000,
438
444
  auth: {
@@ -450,8 +456,21 @@ These are the available config options for making requests. Only the `url` is re
450
456
  // automatically. If set to `true` will also remove the 'content-encoding' header
451
457
  // from the responses objects of all decompressed responses
452
458
  // - Node only (XHR cannot turn off decompression)
453
- decompress: true // default
454
-
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
+ }
455
474
  }
456
475
  ```
457
476
 
@@ -508,7 +527,11 @@ You can specify config defaults that will be applied to every request.
508
527
 
509
528
  ```js
510
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.
511
533
  axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
534
+
512
535
  axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
513
536
  ```
514
537
 
@@ -583,6 +606,34 @@ const instance = axios.create();
583
606
  instance.interceptors.request.use(function () {/*...*/});
584
607
  ```
585
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
+
586
637
  ## Handling Errors
587
638
 
588
639
  ```js
@@ -676,6 +727,7 @@ cancel();
676
727
  ```
677
728
 
678
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.
679
731
 
680
732
  ## Using application/x-www-form-urlencoded format
681
733
 
@@ -775,12 +827,30 @@ axios depends on a native ES6 Promise implementation to be [supported](http://ca
775
827
  If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
776
828
 
777
829
  ## TypeScript
778
- axios includes [TypeScript](http://typescriptlang.org) definitions.
830
+
831
+ axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors.
832
+
779
833
  ```typescript
780
- import axios from 'axios';
781
- 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
+ }
782
845
  ```
783
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
+
784
854
  ## Resources
785
855
 
786
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
package/UPGRADE_GUIDE.md CHANGED
@@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once.
135
135
 
136
136
  #### `axios.success`/`axios.error`
137
137
 
138
- The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
138
+ The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
139
139
 
140
140
  ```js
141
141
  axios.get('some/url')