axios 0.31.1 → 0.32.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/AGENTS.md ADDED
@@ -0,0 +1,38 @@
1
+ # AGENTS.md
2
+
3
+ ## Setup
4
+ - Use npm here; `package-lock.json` is committed and CI installs with `npm ci --ignore-scripts`.
5
+ - `mise.toml` pins local Node 20, but CI runs Node 12, 14, 16, 18, 20, 22, and 24; keep `lib/` source compatible with old CommonJS-era syntax and runtime assumptions.
6
+ - CI order is `npm ci --ignore-scripts`, `npm run build`, then `npm test`.
7
+
8
+ ## Commands
9
+ - `npm run build`: runs `grunt build`, which cleans `dist/` and uses Rollup from `lib/axios.js` to create `dist/axios*.js` and `dist/esm/axios*.js`.
10
+ - `npm test`: runs JS tests and declaration tests through `bin/ssl_hotfix.js`; use this full command on Node >16 so old tooling gets `NODE_OPTIONS=--openssl-legacy-provider`.
11
+ - `node bin/ssl_hotfix.js ./node_modules/.bin/grunt test`: JS-only verification, running ESLint on `lib/**/*.js`, Mocha on `test/unit/**/*.js`, and Karma on `test/specs/**/*.spec.js`.
12
+ - `./node_modules/.bin/mocha --timeout 30000 test/unit/<path>.js`: run one Node/Mocha unit test file without Karma or dtslint.
13
+ - `node bin/ssl_hotfix.js ./node_modules/.bin/grunt karma:single`: run the browser suite only.
14
+ - `node bin/ssl_hotfix.js ./node_modules/.bin/dtslint --localTs node_modules/typescript/lib`: run the declaration tests in `test/typescript/axios.ts`.
15
+ - `npm run fix`: ESLint autofix for `lib/**/*.js` only.
16
+
17
+ ## Structure
18
+ - Package entry is `index.js` -> `lib/axios.js`; the TypeScript surface is the root `index.d.ts`.
19
+ - `lib/defaults/index.js` chooses the runtime adapter: `lib/adapters/xhr.js` for browsers and `lib/adapters/http.js` for Node.
20
+ - Browser bundlers also rely on `package.json` `browser` mappings from `./lib/adapters/http.js` to `./lib/adapters/xhr.js` and from `./lib/platform/node/index.js` to `./lib/platform/browser/index.js`.
21
+ - `lib/env/data.js` stores the package version and is generated by `grunt version` or `npm run preversion`; do not edit it except as part of a version bump.
22
+ - `grunt build` uses `rollup.config.js`; `webpack.config.js` is not the package build path, while Karma has its own webpack config inside `karma.conf.js`.
23
+
24
+ ## Tests
25
+ - Node tests live in `test/unit/**/*.js` and use Mocha plus Node `assert`.
26
+ - Browser tests live in `test/specs/**/*.spec.js` and use Jasmine/Jasmine-Ajax; globals such as `axios` and `getAjaxRequest` come from `test/specs/__helpers.js`.
27
+ - Karma defaults to `FirefoxHeadless` and `ChromeHeadless` whenever `process.env.GITHUB_ACTIONS !== 'false'`, including when the variable is unset; set `GITHUB_ACTIONS=false` only if you need non-headless local browsers.
28
+ - There is no committed single-browser-spec target; do not leave `fdescribe`, `fit`, or `.only` in tests.
29
+ - Declaration changes should update both `index.d.ts` and `test/typescript/axios.ts`, then run the dtslint command above.
30
+
31
+ ## Source Conventions
32
+ - `lib/` is CommonJS with `'use strict'`, `var`, semicolons, 2-space indentation, and no trailing commas; ESLint only checks `lib/**/*.js`.
33
+ - Public API behavior usually needs README docs, TypeScript declarations, and declaration tests updated together.
34
+ - Adapter or platform changes usually need both Node and browser paths considered, including Mocha coverage for `http.js` behavior and Karma coverage for `xhr.js` behavior.
35
+
36
+ ## Node 12+ Compatibility
37
+ - All shipped code AND test code must run on Node 12 through Node 24. CI runs the full matrix, so a test that only works on Node 16+ will break the build. Avoid `??`, `?.`, top-level `await`, private class fields, `Array.prototype.at`, `structuredClone`, etc. in both `lib/` and `test/`.
38
+ - Be wary of `Object.prototype` pollution tests on Node 12/14: setting `Object.prototype.get` (or `set`) before any code that calls `Object.defineProperty` with a value-only descriptor will throw `TypeError: Getter must be a function`, because the descriptor inherits the polluted property. Construct servers/clients first, pre-load any lazy-required Node internals (e.g. `require('dns')`), then apply the pollution.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ### Notable behavior changes
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.
10
+
11
+ Property access (`obj[key]`), enumeration, and `JSON.stringify` are unaffected.
12
+
3
13
  ## [0.30.0](https://github.com/axios/axios/compare/v0.29.0...v0.30.0) (2025-03-26)
4
14
 
5
15
  ## Release notes:
package/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ @AGENTS.md
package/README.md CHANGED
@@ -331,14 +331,14 @@ These are the available config options for making requests. Only the `url` is re
331
331
  // `params` are the URL parameters to be sent with the request
332
332
  // Must be a plain object or a URLSearchParams object
333
333
  // Null bytes in param values stay percent-encoded as `%00` in the resulting query string
334
- // (GHSA-xhjh-pmcv-23jw) — Axios does not reverse `encodeURIComponent` output for `%00`,
334
+ // Axios does not reverse `encodeURIComponent` output for `%00`,
335
335
  // so null-byte injection cannot be smuggled through the serializer.
336
336
  params: {
337
337
  ID: 12345
338
338
  },
339
339
 
340
340
  // `paramsSerializer` is an optional config in charge of serializing `params`
341
- // Nested objects are walked with a bounded recursion depth (GHSA-62hf-57xw-28j9):
341
+ // Nested objects are walked with a bounded recursion depth:
342
342
  // once `maxDepth` is exceeded the serializer throws `ERR_FORM_DATA_DEPTH_EXCEEDED`
343
343
  // instead of overflowing the call stack. The same cap applies to `toFormData` when
344
344
  // `Content-Type: multipart/form-data` triggers automatic FormData serialization.
@@ -404,7 +404,7 @@ These are the available config options for making requests. Only the `url` is re
404
404
  // `undefined` (default) - set XSRF header only for the same origin requests
405
405
  // Only an explicit `true` (own property on the config) will add the XSRF header for
406
406
  // cross-origin requests. Values inherited from `Object.prototype` are ignored
407
- // (GHSA-xx6v-rp6x-q39c), so a polluted prototype cannot silently enable the token.
407
+ // so a polluted prototype cannot silently enable the token.
408
408
  withXSRFToken: boolean | undefined | ((config: AxiosRequestConfig) => boolean | undefined),
409
409
 
410
410
  // `onUploadProgress` allows handling of progress events for uploads
@@ -421,7 +421,7 @@ These are the available config options for making requests. Only the `url` is re
421
421
 
422
422
  // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
423
423
  // Also enforced on streamed responses (`responseType: 'stream'`): bytes are counted as they
424
- // arrive and the stream is aborted with an error once the cap is exceeded (GHSA-vf2m-468p-8v99).
424
+ // arrive and the stream is aborted with an error once the cap is exceeded.
425
425
  maxContentLength: 2000,
426
426
 
427
427
  // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
@@ -429,6 +429,18 @@ These are the available config options for making requests. Only the `url` is re
429
429
  // once the cap is exceeded, even when the native http transport is used directly.
430
430
  maxBodyLength: 2000,
431
431
 
432
+ // `formDataHeaderPolicy` controls which headers the Node adapter copies from
433
+ // FormData `getHeaders()`.
434
+ // 'legacy' (default) copies all returned headers for v1 compatibility.
435
+ // 'content-only' copies only Content-Type and Content-Length.
436
+ formDataHeaderPolicy: 'legacy',
437
+
438
+ // `redact` masks matching config keys when AxiosError#toJSON() is called.
439
+ // Matching is case-insensitive and recursive. It does not change the request.
440
+ // An empty array is treated as "no override" and falls back to the defaults so
441
+ // an accidental `redact: []` cannot silently disable redaction.
442
+ redact: ['authorization', 'password'],
443
+
432
444
  // `validateStatus` defines whether to resolve or reject the promise for a given
433
445
  // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
434
446
  // or `undefined`), the promise will be resolved; otherwise, the promise will be
@@ -454,10 +466,18 @@ These are the available config options for making requests. Only the `url` is re
454
466
 
455
467
  // `socketPath` defines a UNIX Socket to be used in node.js.
456
468
  // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
469
+ // Avoid passing user-controlled values because socket paths bypass host,
470
+ // port, DNS, and proxy controls.
457
471
  // Only either `socketPath` or `proxy` can be specified.
458
472
  // If both are specified, `socketPath` is used.
459
473
  socketPath: null, // default
460
474
 
475
+ // `allowedSocketPaths` constrains `socketPath` to known-safe Unix sockets.
476
+ // Use this when config can include partially user-controlled input.
477
+ // Set to a string or array of strings. An empty array denies all socket paths.
478
+ // Set to `null` on a request to clear an instance-level allowlist.
479
+ allowedSocketPaths: null, // default
480
+
461
481
  // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
462
482
  // and https requests, respectively, in node.js. This allows options to be added like
463
483
  // `keepAlive` that are not enabled by default.