axios 0.32.0 → 0.34.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.
package/CHANGELOG.md CHANGED
@@ -1,16 +1,168 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## Unreleased — next v0 minor
4
4
 
5
- ### Notable behavior changes
5
+ These changes improve error handling, cancellation context, and request header typing.
6
6
 
7
- - `utils.merge` (used internally by `mergeConfig` and to merge request headers) now returns objects with a `null` prototype to harden against prototype-pollution gadgets. As a result, `error.config`, `error.config.headers`, and any merged header bucket no longer inherit from `Object.prototype`. Two consequences:
8
- - `obj.hasOwnProperty(key)` on a merged config or header object throws `TypeError: obj.hasOwnProperty is not a function`. Use `Object.prototype.hasOwnProperty.call(obj, key)` or `key in obj` instead.
9
- - Implicit string coercion (e.g. `String(obj)`, `'' + obj`, or any path that calls `ToPrimitive`) throws `TypeError: Cannot convert object to primitive value` because there is no inherited `toString`. Coerce explicitly via `JSON.stringify(obj)` or by reading individual properties.
7
+ ### ⚠️ Breaking Changes & Deprecations
10
8
 
11
- Property access (`obj[key]`), enumeration, and `JSON.stringify` are unaffected.
9
+ * **Header types:** TypeScript now rejects header values that are Promises, functions, or objects with custom `toString()` methods. Resolve promises, call functions, or explicitly convert objects before assigning header values. This narrows previously accepted types and must ship in the next v0 minor release under the pre-1.0 compatibility policy. (__#11209__)
12
10
 
13
- ## [0.30.0](https://github.com/axios/axios/compare/v0.29.0...v0.30.0) (2025-03-26)
11
+ ### 🚀 New Features
12
+
13
+ * **Caller diagnostics:** Opt in with `captureCallerStack: true` on a request or instance to append caller frames to asynchronous errors. The default is off so successful requests avoid the additional stack capture and Promise reaction. (__#11209__)
14
+ * **Cancellation context:** `CanceledError.reason` preserves `AbortSignal.reason`, including object and falsy values. Native and structural signals retain their identity and live getters across config merging. (__#11209__)
15
+
16
+ ### 🐛 Bug Fixes
17
+
18
+ * **Error inheritance:** Axios loads alongside read-only `Error.prototype.toJSON` properties while preserving supplied own descriptors and setters. (__#11209__)
19
+ * **Request interceptors:** Synchronous interceptor and dispatch failures reach response interceptors. Rejected recovery promises prevent dispatch; fulfilled recovery values are ignored and the last request config is retained. (__#11209__)
20
+
21
+ [Full Changelog](https://github.com/axios/axios/pull/11209/files)
22
+
23
+ ## v0.32.0 — May 4, 2026
24
+
25
+ This release backports a comprehensive set of security and hardening fixes from the v1.x branch into v0.x, covering prototype-pollution protections, default error redaction, stricter proxy/cookie/socket handling, and one breaking change to merged config and header object prototypes.
26
+
27
+ ## ⚠️ Breaking Changes & Deprecations
28
+
29
+ - Null-prototype merged objects: mergeConfig and header merging now return objects with a null prototype to block prototype-pollution gadgets. Consumers must use Object.prototype.hasOwnProperty.call(obj, key) and avoid implicit string coercion against merged config or header objects. (#10838)
30
+
31
+ ## 🔒 Security Fixes
32
+
33
+ - Default error redaction: AxiosError.toJSON() now redacts sensitive keys by default to prevent credential leaks in logs. The behavior is configurable via config.redact, with defaults exposed on defaults.redact. (#10838)
34
+ - Cookie & XSRF handling: Cookie names are read literally rather than via regex, and only own properties are respected when evaluating withXSRFToken. (#10838)
35
+ - Proxy bypass IPv6 parity: NO_PROXY matching now handles canonical IPv4-mapped IPv6 forms such as ::ffff:127.0.0.1 and ::ffff:7f00:1. (#10838)
36
+ - Node http adapter hardening: Strips Proxy-Authorization when no proxy is in use and gates socketPath behind a new allowedSocketPaths allowlist (string or array, normalized) to reduce accidental Unix socket exposure. (#10838)
37
+ - Browser xhr adapter: Stricter own-property checks when reading config and headers. (#10838)
38
+ - URL parameters: AxiosURLSearchParams keeps %00 encoded and applies consistent encoding throughout. (#10838)
39
+ - Public type surface: Adds formDataHeaderPolicy, redact, and allowedSocketPaths to the TypeScript declarations alongside their runtime defaults. (#10838)
40
+
41
+ ## 🔧 Maintenance & Chores
42
+
43
+ - Repo hygiene: Updates README.md and CHANGELOG.md, adds AGENTS.md, and refreshes the issue and PR templates. (#10838)
44
+
45
+ [**Full Changelog**](https://github.com/axios/axios/compare/v0.31.1...v0.32.0)
46
+
47
+ ## 0.31.1 (2024-12-19)
48
+
49
+ This release backports a broad set of security hardenings from the v1 line — covering prototype-pollution defences, stream size enforcement, XSRF handling, URL null-byte encoding, and bounded FormData recursion — and drops committed `dist/` artefacts along with Bower support.
50
+
51
+ ## ⚠️ Breaking Changes & Deprecations
52
+
53
+ * **Bower & Committed `dist/` Removed:** `dist/` bundles are no longer committed to the repo, and `bower.json` plus the Grunt `package2bower` task have been removed. CI still builds bundles before publish, so npm/yarn/pnpm consumers are unaffected; installs via Bower or directly from the git tree must migrate to npm or a CDN. (__#10747__)
54
+
55
+ ## 🔒 Security Fixes
56
+
57
+ * **Prototype Pollution in Header Merge (GHSA-6chq-wfr3-2hj9):** Tightened `isFormData` to reject plain/null-prototype objects and require `append`, and guarded the Node HTTP adapter so `data.getHeaders()` is only merged when it is not inherited from `Object.prototype`. Blocks injected headers via polluted `getHeaders`. (__#10750__)
58
+ * **Prototype Pollution in Config Merging (GHSA-pf86-5x62-jrwf):** `mergeConfig`, defaults resolution, and the HTTP adapter now uses own-property checks for `transport`, `env`, `Blob`, `formSerializer`, and transforms arrays, and merged configs are returned as null-prototype objects. Prevents hijacking of the request flow through polluted prototypes. (__#10752__)
59
+ * **FormData / Params Recursion DoS:** Added a configurable `maxDepth` (default `100`, `Infinity` disables) to `toFormData` and params serialisation, throwing `AxiosError` with code `ERR_FORM_DATA_DEPTH_EXCEEDED` when exceeded. Circular-reference detection is preserved. (__#10728__)
60
+ * **Null-Byte Injection in Query Strings:** Removed the unsafe `%00` → null-byte substitution from `AxiosURLSearchParams.encode` so `%00` is preserved as-is. Other encoding behaviour (including `%20` → `+`) unchanged. (__#10737__)
61
+ * **Consolidated v1 Security Backport:** Rolls up remaining v1 hardenings into `v0.x`: `maxContentLength` enforcement for `responseType: 'stream'` via a guarded transform with deferred piping, `maxBodyLength` enforcement for streamed uploads on native `http`/`https` with `maxRedirects: 0`, and stricter `withXSRFToken` handling so only own boolean `true` enables cross-origin XSRF headers. (__#10764__)
62
+
63
+ ## 🔧 Maintenance & Chores
64
+
65
+ * **CODEOWNERS:** Added `.github/CODEOWNERS` with `* @jasonsaayman` to set a default reviewer for all paths. (__#10740__)
66
+
67
+ [Full Changelog](https://github.com/axios/axios/compare/v0.31.0...v0.31.1)
68
+
69
+ ## 0.31.0 (2024-12-17)
70
+
71
+ This release backports security fixes from v1.x, hardens the CI/CD supply chain with OIDC publishing and `zizmor` scanning, resolves TypeScript typing issues in `AxiosInstance`, and fixes a performance regression in `isEmptyObject()`.
72
+
73
+ ## 🔒 Security Fixes
74
+
75
+ * **Header Injection & Proxy Bypass:** Backports v1 security hardening — sanitizes outgoing header values to strip invalid bytes, CRLF sequences, and boundary whitespace (including array values); adds proper `NO_PROXY`/`no_proxy` enforcement covering wildcards, explicit ports, loopback aliases (`localhost`, `127.0.0.1`, `::1`), bracketed IPv6, and trailing-dot hostnames. Proxy bypass is now checked before the proxy URL is parsed, and `parsed.host` is used for correct port and IPv6 handling. (__#10688__)
76
+
77
+ * **CI Security:** SHA-pins all actions and disables credential persistence in v0.x CI, introduces `zizmor` security scanning with SARIF upload to code scanning, adds an OIDC Trusted Publishing workflow with npm provenance attestations, and gates all publishes behind a required `npm-publish` GitHub Environment with configurable reviewer protections. (__#10638__, __#10639__, __#10667__)
78
+
79
+ ## 🐛 Bug Fixes
80
+
81
+ * **TypeScript — `AxiosInstance` Return Types:** Fixes return types in `AxiosInstance` methods to correctly resolve to `Promise<R>` (matching `AxiosPromise<T>` semantics), and corrects the generic call signature so TypeScript properly enforces the response data type. TypeScript-only changes; no runtime impact. (__#6253__, __#7328__)
82
+
83
+ * **Performance:** Fixes a performance regression in `isEmptyObject()` that caused excessive computation when the argument was a large string. (__#6484__)
84
+
85
+ ## 🔧 Maintenance & Chores
86
+
87
+ * **Versioning & CI Workflow:** Adds an automated versioning flow for v0.x, renames the CI workflow for consistency with the v1.x naming convention, and corrects the branch name reference in CI config. (__#10690__, __#10691__, __#10692__)
88
+
89
+ ## 🌟 New Contributors
90
+
91
+ We are thrilled to welcome our new contributors. Thank you for helping improve axios:
92
+
93
+ * __@nakataki17__ (__#6253__)
94
+ * __@gmasclet__ (__#6484__)
95
+ * __@shaanmajid__ (__#10638__, __#10639__, __#10667__)
96
+ * __@ivan-churakov__ (__#7328__)
97
+
98
+ [Full Changelog](https://github.com/axios/axios/compare/v0.30.3...v0.31.0)
99
+
100
+ ## 0.30.3 (2024-12-10)
101
+
102
+ This is a critical security maintenance release for the v0.x branch. It addresses a high-priority vulnerability involving prototype pollution that could lead to a Denial of Service (DoS).
103
+
104
+ Recommendation: All users currently on the 0.x release line should upgrade to this version immediately to ensure environment stability.
105
+
106
+ ## 🛡️ Security Fixes
107
+
108
+ - **Backport: Fix DoS via __proto__ key in merge config**
109
+ - Patched a vulnerability where specifically crafted configuration objects using the __proto__ key could cause a Denial of Service during the merge process. - _by @FeBe95 in [PR #7388](https://github.com/axios/axios/pull/7388)_
110
+
111
+ ## ⚙️ Maintenance & CI
112
+
113
+ - **CI Infrastructure Update**
114
+ - Updated Continuous Integration workflows for the v0.x branch to maintain long-term support and build reliability. - _by @jasonsaayman in [PR #7407](https://github.com/axios/axios/pull/7407)_
115
+
116
+ ## ⚠️ Breaking Changes
117
+
118
+ Configuration Merging Behavior:
119
+
120
+ As part of the security fix, Axios now restricts the merging of the __proto__ key within configuration objects. If your codebase relies on unconventional deep-merging patterns that target the object prototype via Axios config, those operations will now be blocked. This is a necessary change to prevent prototype pollution.
121
+
122
+ Full Changelog: [v0.30.2...v0.30.3](https://github.com/axios/axios/compare/v0.30.2...v0.30.3)
123
+
124
+ ## 0.30.2 (2024-11-28)
125
+
126
+ ## What's Changed
127
+ * Backport `maxContentLength` vulnerability fix to v0.x by @FeBe95 in https://github.com/axios/axios/pull/7034
128
+
129
+ ## New Contributors
130
+ * @FeBe95 made their first contribution in https://github.com/axios/axios/pull/7034
131
+
132
+ **Full Changelog**: https://github.com/axios/axios/compare/v0.30.1...v0.30.2
133
+
134
+ ## 0.30.1 (2024-11-27)
135
+
136
+ ## Release notes:
137
+
138
+ ### Bug Fixes
139
+ * chore(deps): bump form-data from 4.0.0 to 4.0.4 for v0.x by @wolandec in https://github.com/axios/axios/pull/6978
140
+
141
+ ### Contributors to this release
142
+ * @wolandec made their first contribution in https://github.com/axios/axios/pull/6978
143
+
144
+ **Full Changelog**: https://github.com/axios/axios/compare/v0.30.0...v0.30.1
145
+
146
+ ## 0.30.0 (2024-11-21)
147
+
148
+ ## Release notes:
149
+
150
+ ### Bug Fixes
151
+ * fix: modify log while request is aborted by @mori5321 in https://github.com/axios/axios/pull/4917
152
+ * fix: update CHANGELOG.md for v0.x by @TehZarathustra in https://github.com/axios/axios/pull/6271
153
+ * fix: modify upgrade guide for 0.28.1's breaking change by @nafeger in https://github.com/axios/axios/pull/6787
154
+ * fix: backport allowAbsoluteUrls vulnerability fix to v0.x by @thatguyinabeanie in https://github.com/axios/axios/pull/6829
155
+ * fix: add allowAbsoluteUrls type by @thatguyinabeanie in https://github.com/axios/axios/pull/6849
156
+
157
+ ### Contributors to this release
158
+ * @mori5321 made their first contribution in https://github.com/axios/axios/pull/4917
159
+ * @TehZarathustra made their first contribution in https://github.com/axios/axios/pull/6271
160
+ * @nafeger made their first contribution in https://github.com/axios/axios/pull/6787
161
+ * @thatguyinabeanie made their first contribution in https://github.com/axios/axios/pull/6829
162
+
163
+ **Full Changelog**: https://github.com/axios/axios/compare/v0.29.0...v0.30.0
164
+
165
+ ## 0.29.0 (2024-11-21)
14
166
 
15
167
  ## Release notes:
16
168
 
@@ -24,6 +176,8 @@
24
176
 
25
177
  ## [0.29.0](https://github.com/axios/axios/compare/v0.28.1...v0.29.0) (2024-11-21)
26
178
 
179
+ ## 0.28.1 (2024-03-24)
180
+
27
181
  ## Release notes:
28
182
 
29
183
  ### Bug Fixes
@@ -35,6 +189,8 @@
35
189
 
36
190
  ## [0.28.1](https://github.com/axios/axios/compare/v0.28.0...v0.28.1) (2024-03-24)
37
191
 
192
+ ## 0.28.0 (2024-02-12)
193
+
38
194
  ## Release notes:
39
195
 
40
196
  ### Bug Fixes
package/README.md CHANGED
@@ -494,7 +494,13 @@ These are the available config options for making requests. Only the `url` is re
494
494
  // supplies credentials.
495
495
  // This will set an `Proxy-Authorization` header, overwriting any existing
496
496
  // `Proxy-Authorization` custom headers you have set using `headers`.
497
- // If the proxy server uses HTTPS, then you must set the protocol to `https`.
497
+ // Set the protocol to `http` for a plaintext proxy or `https` for a TLS proxy.
498
+ // HTTP(S) schemes accept a trailing colon, any case, and surrounding whitespace.
499
+ // If omitted, the proxy connection inherits the target URL's protocol.
500
+ // Empty strings and non-string values also leave the target protocol unchanged.
501
+ // A plaintext proxy for an HTTPS target therefore requires explicit `http`.
502
+ // Unsupported non-empty strings (e.g. `ftp`, `https://`, or whitespace-only)
503
+ // reject with `ERR_BAD_OPTION_VALUE` before connecting, without a fallback.
498
504
  proxy: {
499
505
  protocol: 'https',
500
506
  host: '127.0.0.1',
@@ -513,6 +519,10 @@ These are the available config options for making requests. Only the `url` is re
513
519
  // an alternative way to cancel Axios requests using AbortController
514
520
  signal: new AbortController().signal,
515
521
 
522
+ // Capture the request caller for asynchronous error stacks (default: false).
523
+ // Enable on a request or instance when the extra diagnostics are needed.
524
+ captureCallerStack: false,
525
+
516
526
  // `decompress` indicates whether or not the response body should be decompressed
517
527
  // automatically. If set to `true` will also remove the 'content-encoding' header
518
528
  // from the responses objects of all decompressed responses
@@ -742,8 +752,31 @@ and when the response was fulfilled
742
752
 
743
753
  Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code.
744
754
 
755
+ For synchronous request interceptors, a thrown error is passed to that interceptor's
756
+ rejection handler, when supplied. If the handler is absent, throws, or returns a
757
+ rejected promise, the request is rejected without being sent and response rejection
758
+ interceptors can handle the failure. A promise returned by a recovery handler is
759
+ awaited before dispatch. Recovery return values, including fulfilled promise values,
760
+ do not replace the last request config; that config is used for dispatch.
761
+ Successful synchronous interceptors still dispatch immediately.
762
+
745
763
  ## Handling Errors
746
764
 
765
+ Set `captureCallerStack: true` on a request or instance to append the original caller
766
+ to errors created asynchronously. Stack capture is disabled by default because it
767
+ adds work to every enabled request, including successful requests. When disabled,
768
+ Axios keeps the error's existing stack without capturing additional caller frames.
769
+
770
+ ```js
771
+ const client = axios.create({captureCallerStack: true});
772
+ client.get('/user/12345');
773
+ // An individual request can override the instance setting.
774
+ client.get('/status', {captureCallerStack: false});
775
+ ```
776
+
777
+ The original error and its existing stack are preserved when caller frames are
778
+ appended. Availability and frame counts depend on the runtime's stack support and settings.
779
+
747
780
  ```js
748
781
  axios.get('/user/12345')
749
782
  .catch(function (error) {
@@ -803,6 +836,26 @@ axios.get('/foo/bar', {
803
836
  controller.abort()
804
837
  ```
805
838
 
839
+ On runtimes that expose `AbortSignal.reason`, Axios preserves that value in
840
+ `CanceledError.reason`, including objects and falsy values. Cancellation still uses
841
+ the `canceled` message, `ERR_CANCELED` code, and `axios.isCancel()` detection. Signals
842
+ without a reason continue to work and leave `error.reason` undefined.
843
+ Native signals and plain objects implementing `GenericAbortSignal` are retained by
844
+ reference when configurations are merged, preserving live getters and reason identity.
845
+
846
+ ```js
847
+ const controller = new AbortController();
848
+ const reason = new Error('Replaced by a newer search');
849
+
850
+ axios.get('/search', {signal: controller.signal}).catch(function (error) {
851
+ if (axios.isCancel(error) && error.reason === reason) {
852
+ // This request was superseded.
853
+ }
854
+ });
855
+
856
+ controller.abort(reason);
857
+ ```
858
+
806
859
  ### CancelToken `👎deprecated`
807
860
 
808
861
  You can also cancel a request using a *CancelToken*.
@@ -1181,6 +1234,22 @@ If your environment doesn't support ES6 Promises, you can [polyfill](https://git
1181
1234
 
1182
1235
  ## TypeScript
1183
1236
 
1237
+ Request header values are strings, string arrays, numbers, or booleans. The
1238
+ `common` and method-specific header groups accept maps of these values. Resolve
1239
+ asynchronous values in a request interceptor before assigning them to headers;
1240
+ Promise and function values are rejected by the TypeScript declarations.
1241
+
1242
+ This is a TypeScript compatibility change for the next v0 minor release. Code that
1243
+ previously assigned a Promise, function, or object with a custom `toString()` method
1244
+ must first resolve the Promise, call the function, or explicitly convert the object
1245
+ to a supported header value. For example:
1246
+
1247
+ ```typescript
1248
+ async function requestWithToken(token: Promise<string>) {
1249
+ return axios.get('/user', {headers: {Authorization: 'Bearer ' + await token}});
1250
+ }
1251
+ ```
1252
+
1184
1253
  axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors.
1185
1254
 
1186
1255
  ```typescript