axios 0.27.2 → 1.1.3

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.

Files changed (75) hide show
  1. package/CHANGELOG.md +232 -920
  2. package/LICENSE +4 -16
  3. package/README.md +386 -103
  4. package/SECURITY.md +4 -3
  5. package/UPGRADE_GUIDE.md +1 -166
  6. package/bin/ssl_hotfix.js +22 -0
  7. package/dist/axios.js +2430 -2367
  8. package/dist/axios.js.map +1 -0
  9. package/dist/axios.min.js +2 -3
  10. package/dist/axios.min.js.map +1 -0
  11. package/dist/esm/axios.js +2950 -0
  12. package/dist/esm/axios.js.map +1 -0
  13. package/dist/esm/axios.min.js +2 -0
  14. package/dist/esm/axios.min.js.map +1 -0
  15. package/dist/node/axios.cjs +3764 -0
  16. package/dist/node/axios.cjs.map +1 -0
  17. package/gulpfile.js +88 -0
  18. package/index.d.ts +299 -70
  19. package/index.js +32 -1
  20. package/karma.conf.cjs +250 -0
  21. package/lib/adapters/http.js +378 -211
  22. package/lib/adapters/index.js +33 -0
  23. package/lib/adapters/xhr.js +81 -57
  24. package/lib/axios.js +34 -22
  25. package/lib/cancel/CancelToken.js +91 -89
  26. package/lib/cancel/CanceledError.js +9 -6
  27. package/lib/cancel/isCancel.js +2 -2
  28. package/lib/core/Axios.js +133 -98
  29. package/lib/core/AxiosError.js +22 -8
  30. package/lib/core/AxiosHeaders.js +268 -0
  31. package/lib/core/InterceptorManager.js +62 -45
  32. package/lib/core/buildFullPath.js +5 -4
  33. package/lib/core/dispatchRequest.js +21 -32
  34. package/lib/core/mergeConfig.js +8 -7
  35. package/lib/core/settle.js +6 -4
  36. package/lib/core/transformData.js +15 -9
  37. package/lib/defaults/index.js +77 -38
  38. package/lib/defaults/transitional.js +1 -1
  39. package/lib/env/classes/FormData.js +2 -0
  40. package/lib/env/data.js +1 -3
  41. package/lib/helpers/AxiosTransformStream.js +191 -0
  42. package/lib/helpers/AxiosURLSearchParams.js +58 -0
  43. package/lib/helpers/bind.js +3 -7
  44. package/lib/helpers/buildURL.js +26 -33
  45. package/lib/helpers/combineURLs.js +3 -2
  46. package/lib/helpers/cookies.js +43 -44
  47. package/lib/helpers/deprecatedMethod.js +4 -2
  48. package/lib/helpers/formDataToJSON.js +92 -0
  49. package/lib/helpers/fromDataURI.js +53 -0
  50. package/lib/helpers/isAbsoluteURL.js +3 -2
  51. package/lib/helpers/isAxiosError.js +4 -3
  52. package/lib/helpers/isURLSameOrigin.js +44 -45
  53. package/lib/helpers/null.js +1 -1
  54. package/lib/helpers/parseHeaders.js +24 -22
  55. package/lib/helpers/parseProtocol.js +3 -3
  56. package/lib/helpers/speedometer.js +55 -0
  57. package/lib/helpers/spread.js +3 -2
  58. package/lib/helpers/throttle.js +33 -0
  59. package/lib/helpers/toFormData.js +193 -36
  60. package/lib/helpers/toURLEncodedForm.js +18 -0
  61. package/lib/helpers/validator.js +20 -15
  62. package/lib/platform/browser/classes/FormData.js +3 -0
  63. package/lib/platform/browser/classes/URLSearchParams.js +4 -0
  64. package/lib/platform/browser/index.js +43 -0
  65. package/lib/platform/index.js +3 -0
  66. package/lib/platform/node/classes/FormData.js +3 -0
  67. package/lib/platform/node/classes/URLSearchParams.js +4 -0
  68. package/lib/platform/node/index.js +12 -0
  69. package/lib/utils.js +321 -178
  70. package/package.json +70 -23
  71. package/rollup.config.js +90 -0
  72. package/dist/axios.map +0 -1
  73. package/dist/axios.min.map +0 -1
  74. package/lib/defaults/env/FormData.js +0 -2
  75. package/lib/helpers/normalizeHeaderName.js +0 -12
package/SECURITY.md CHANGED
@@ -1,5 +1,6 @@
1
- # Security Policy
1
+ # Reporting a Vulnerability
2
2
 
3
- ## Reporting a Vulnerability
3
+ If you discover a security vulnerability in axios please disclose it via [our huntr page](https://huntr.dev/repos/axios/axios/). Bounty eligibility, CVE assignment, response times and past reports are all there.
4
4
 
5
- Please report security issues to jasonsaayman@gmail.com
5
+
6
+ Thank you for improving the security of axios.
package/UPGRADE_GUIDE.md CHANGED
@@ -1,168 +1,3 @@
1
1
  # Upgrade Guide
2
2
 
3
- ### 0.18.x -> 0.19.0
4
-
5
- #### HTTPS Proxies
6
-
7
- Routing through an https proxy now requires setting the `protocol` attribute of the proxy configuration to `https`
8
-
9
- ### 0.15.x -> 0.16.0
10
-
11
- #### `Promise` Type Declarations
12
-
13
- The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details.
14
-
15
- ### 0.13.x -> 0.14.0
16
-
17
- #### TypeScript Definitions
18
-
19
- The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax.
20
-
21
- Please use the following `import` statement to import axios in TypeScript:
22
-
23
- ```typescript
24
- import axios from 'axios';
25
-
26
- axios.get('/foo')
27
- .then(response => console.log(response))
28
- .catch(error => console.log(error));
29
- ```
30
-
31
- #### `agent` Config Option
32
-
33
- The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead.
34
-
35
- ```js
36
- {
37
- // Define a custom agent for HTTP
38
- httpAgent: new http.Agent({ keepAlive: true }),
39
- // Define a custom agent for HTTPS
40
- httpsAgent: new https.Agent({ keepAlive: true })
41
- }
42
- ```
43
-
44
- #### `progress` Config Option
45
-
46
- The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options.
47
-
48
- ```js
49
- {
50
- // Define a handler for upload progress events
51
- onUploadProgress: function (progressEvent) {
52
- // ...
53
- },
54
-
55
- // Define a handler for download progress events
56
- onDownloadProgress: function (progressEvent) {
57
- // ...
58
- }
59
- }
60
- ```
61
-
62
- ### 0.12.x -> 0.13.0
63
-
64
- The `0.13.0` release contains several changes to custom adapters and error handling.
65
-
66
- #### Error Handling
67
-
68
- Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response.
69
-
70
- ```js
71
- axios.get('/user/12345')
72
- .catch((error) => {
73
- console.log(error.message);
74
- console.log(error.code); // Not always specified
75
- console.log(error.config); // The config that was used to make the request
76
- console.log(error.response); // Only available if response was received from the server
77
- });
78
- ```
79
-
80
- #### Request Adapters
81
-
82
- This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter.
83
-
84
- 1. Response transformer is now called outside of adapter.
85
- 2. Request adapter returns a `Promise`.
86
-
87
- This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter.
88
-
89
- Previous code:
90
-
91
- ```js
92
- function myAdapter(resolve, reject, config) {
93
- var response = {
94
- data: transformData(
95
- responseData,
96
- responseHeaders,
97
- config.transformResponse
98
- ),
99
- status: request.status,
100
- statusText: request.statusText,
101
- headers: responseHeaders
102
- };
103
- settle(resolve, reject, response);
104
- }
105
- ```
106
-
107
- New code:
108
-
109
- ```js
110
- function myAdapter(config) {
111
- return new Promise(function (resolve, reject) {
112
- var response = {
113
- data: responseData,
114
- status: request.status,
115
- statusText: request.statusText,
116
- headers: responseHeaders
117
- };
118
- settle(resolve, reject, response);
119
- });
120
- }
121
- ```
122
-
123
- See the related commits for more details:
124
- - [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
125
- - [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
126
-
127
- ### 0.5.x -> 0.6.0
128
-
129
- The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading.
130
-
131
- #### ES6 Promise Polyfill
132
-
133
- Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it.
134
-
135
- ```js
136
- require('es6-promise').polyfill();
137
- var axios = require('axios');
138
- ```
139
-
140
- This will polyfill the global environment, and only needs to be done once.
141
-
142
- #### `axios.success`/`axios.error`
143
-
144
- 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.
145
-
146
- ```js
147
- axios.get('some/url')
148
- .then(function (res) {
149
- /* ... */
150
- })
151
- .catch(function (err) {
152
- /* ... */
153
- });
154
- ```
155
-
156
- #### UMD
157
-
158
- Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build.
159
-
160
- ```js
161
- // AMD
162
- require(['bower_components/axios/dist/axios'], function (axios) {
163
- /* ... */
164
- });
165
-
166
- // CommonJS
167
- var axios = require('axios/dist/axios');
168
- ```
3
+ ## 0.x.x -> 1.1.0
@@ -0,0 +1,22 @@
1
+ import {spawn} from 'child_process';
2
+
3
+ const args = process.argv.slice(2);
4
+
5
+ console.log(`Running ${args.join(' ')} on ${process.version}\n`);
6
+
7
+ const match = /v(\d+)/.exec(process.version);
8
+
9
+ const isHotfixNeeded = match && match[1] > 16;
10
+
11
+ isHotfixNeeded && console.warn('Setting --openssl-legacy-provider as ssl hotfix');
12
+
13
+ const test = spawn('cross-env',
14
+ isHotfixNeeded ? ['NODE_OPTIONS=--openssl-legacy-provider', ...args] : args, {
15
+ shell: true,
16
+ stdio: 'inherit'
17
+ }
18
+ );
19
+
20
+ test.on('exit', function (code) {
21
+ process.exit(code)
22
+ })