axios 0.21.4 → 0.30.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +318 -54
  2. package/README.md +378 -64
  3. package/SECURITY.md +3 -3
  4. package/UPGRADE_GUIDE.md +41 -13
  5. package/bin/check-build-version.js +19 -0
  6. package/bin/ssl_hotfix.js +22 -0
  7. package/dist/axios.js +2072 -1878
  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 +2379 -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/index.d.ts +219 -46
  16. package/lib/adapters/http.js +262 -130
  17. package/lib/adapters/xhr.js +59 -22
  18. package/lib/axios.js +19 -7
  19. package/lib/cancel/CancelToken.js +65 -4
  20. package/lib/cancel/CanceledError.js +24 -0
  21. package/lib/core/Axios.js +45 -17
  22. package/lib/core/AxiosError.js +97 -0
  23. package/lib/core/InterceptorManager.js +9 -0
  24. package/lib/core/buildFullPath.js +5 -2
  25. package/lib/core/dispatchRequest.js +13 -1
  26. package/lib/core/mergeConfig.js +54 -38
  27. package/lib/core/settle.js +3 -3
  28. package/lib/core/transformData.js +4 -3
  29. package/lib/{defaults.js → defaults/index.js} +64 -23
  30. package/lib/defaults/transitional.js +7 -0
  31. package/lib/env/README.md +3 -0
  32. package/lib/env/classes/FormData.js +2 -0
  33. package/lib/env/data.js +3 -0
  34. package/lib/helpers/AxiosURLSearchParams.js +42 -0
  35. package/lib/helpers/bind.js +1 -5
  36. package/lib/helpers/buildURL.js +18 -33
  37. package/lib/helpers/combineURLs.js +1 -1
  38. package/lib/helpers/formDataToJSON.js +74 -0
  39. package/lib/helpers/fromDataURI.js +51 -0
  40. package/lib/helpers/isAbsoluteURL.js +1 -1
  41. package/lib/helpers/isAxiosError.js +3 -1
  42. package/lib/helpers/isURLSameOrigin.js +12 -12
  43. package/lib/helpers/null.js +2 -0
  44. package/lib/helpers/parseHeaders.js +2 -2
  45. package/lib/helpers/parseProtocol.js +6 -0
  46. package/lib/helpers/toFormData.js +179 -0
  47. package/lib/helpers/toURLEncodedForm.js +18 -0
  48. package/lib/helpers/validator.js +14 -33
  49. package/lib/platform/browser/classes/FormData.js +3 -0
  50. package/lib/platform/browser/classes/URLSearchParams.js +5 -0
  51. package/lib/platform/browser/index.js +11 -0
  52. package/lib/platform/index.js +3 -0
  53. package/lib/platform/node/classes/FormData.js +3 -0
  54. package/lib/platform/node/classes/URLSearchParams.js +5 -0
  55. package/lib/platform/node/index.js +11 -0
  56. package/lib/utils.js +210 -37
  57. package/package.json +42 -26
  58. package/rollup.config.js +60 -0
  59. package/tsconfig.json +14 -0
  60. package/tslint.json +6 -0
  61. package/dist/axios.map +0 -1
  62. package/dist/axios.min.map +0 -1
  63. package/lib/cancel/Cancel.js +0 -19
  64. package/lib/core/createError.js +0 -18
  65. package/lib/core/enhanceError.js +0 -42
package/SECURITY.md CHANGED
@@ -1,5 +1,5 @@
1
- # Security Policy
1
+ # Reporting a Vulnerability
2
2
 
3
- ## Reporting a Vulnerability
3
+ If you discover a security vulnerability within axios, please submit a report via [huntr.dev](https://huntr.dev/bounties/?target=https%3A%2F%2Fgithub.com%2Faxios%2Faxios). Bounties and CVEs are automatically managed and allocated via the platform.
4
4
 
5
- Please report security issues to jasonsaayman@gmail.com
5
+ All security vulnerabilities will be promptly addressed.
package/UPGRADE_GUIDE.md CHANGED
@@ -1,14 +1,20 @@
1
1
  # Upgrade Guide
2
2
 
3
- ### 0.15.x -> 0.16.0
3
+ ## 0.18.x -> 0.19.0
4
4
 
5
- #### `Promise` Type Declarations
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
6
12
 
7
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.
8
14
 
9
- ### 0.13.x -> 0.14.0
15
+ ## 0.13.x -> 0.14.0
10
16
 
11
- #### TypeScript Definitions
17
+ ### TypeScript Definitions
12
18
 
13
19
  The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax.
14
20
 
@@ -22,7 +28,7 @@ axios.get('/foo')
22
28
  .catch(error => console.log(error));
23
29
  ```
24
30
 
25
- #### `agent` Config Option
31
+ ### `agent` Config Option
26
32
 
27
33
  The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead.
28
34
 
@@ -35,7 +41,7 @@ The `agent` config option has been replaced with two new options: `httpAgent` an
35
41
  }
36
42
  ```
37
43
 
38
- #### `progress` Config Option
44
+ ### `progress` Config Option
39
45
 
40
46
  The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options.
41
47
 
@@ -53,11 +59,11 @@ The `progress` config option has been replaced with the `onUploadProgress` and `
53
59
  }
54
60
  ```
55
61
 
56
- ### 0.12.x -> 0.13.0
62
+ ## 0.12.x -> 0.13.0
57
63
 
58
64
  The `0.13.0` release contains several changes to custom adapters and error handling.
59
65
 
60
- #### Error Handling
66
+ ### Error Handling
61
67
 
62
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.
63
69
 
@@ -71,7 +77,7 @@ axios.get('/user/12345')
71
77
  });
72
78
  ```
73
79
 
74
- #### Request Adapters
80
+ ### Request Adapters
75
81
 
76
82
  This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter.
77
83
 
@@ -115,14 +121,15 @@ function myAdapter(config) {
115
121
  ```
116
122
 
117
123
  See the related commits for more details:
124
+
118
125
  - [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
119
126
  - [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
120
127
 
121
- ### 0.5.x -> 0.6.0
128
+ ## 0.5.x -> 0.6.0
122
129
 
123
130
  The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading.
124
131
 
125
- #### ES6 Promise Polyfill
132
+ ### ES6 Promise Polyfill
126
133
 
127
134
  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.
128
135
 
@@ -133,7 +140,7 @@ var axios = require('axios');
133
140
 
134
141
  This will polyfill the global environment, and only needs to be done once.
135
142
 
136
- #### `axios.success`/`axios.error`
143
+ ### `axios.success`/`axios.error`
137
144
 
138
145
  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
146
 
@@ -147,7 +154,7 @@ axios.get('some/url')
147
154
  });
148
155
  ```
149
156
 
150
- #### UMD
157
+ ### UMD
151
158
 
152
159
  Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build.
153
160
 
@@ -160,3 +167,24 @@ require(['bower_components/axios/dist/axios'], function (axios) {
160
167
  // CommonJS
161
168
  var axios = require('axios/dist/axios');
162
169
  ```
170
+
171
+ ## 0.28.x -> 0.28.1
172
+
173
+ The way to pass in a custom parameter serializer has changed
174
+
175
+ 0.28.0
176
+ ```js
177
+ axios.create({
178
+ paramsSerializer: (params) => {
179
+ return qs.stringify(params, { arrayFormat: 'repeat', skipNulls: true })
180
+ }, ...config);
181
+ ```
182
+ now the serializer needs to be in under a new key:
183
+
184
+ 0.28.1
185
+ ```js
186
+ axios.create({
187
+ paramsSerializer: {
188
+ serialize: (params) => qs.stringify(params, { arrayFormat: 'repeat', skipNulls: true }),
189
+ }, ...config);
190
+ ```
@@ -0,0 +1,19 @@
1
+ const fs = require('fs');
2
+ const assert = require('assert');
3
+ const axios = require('../index.js');
4
+
5
+ const {version} = JSON.parse(fs.readFileSync('./package.json'));
6
+
7
+ console.log('Checking versions...\n----------------------------')
8
+
9
+ console.log(`Package version: v${version}`);
10
+ console.log(`Axios version: v${axios.VERSION}`);
11
+ console.log(`----------------------------`);
12
+
13
+ assert.strictEqual(
14
+ version,
15
+ axios.VERSION,
16
+ `Version mismatch between package and Axios ${version} != ${axios.VERSION}`
17
+ );
18
+
19
+ console.log('✔️ PASSED\n');
@@ -0,0 +1,22 @@
1
+ const {spawn} = require('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
+ })