axios 1.8.4 → 1.9.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/index.d.cts CHANGED
@@ -359,7 +359,7 @@ declare namespace axios {
359
359
 
360
360
  type Milliseconds = number;
361
361
 
362
- type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
362
+ type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
363
363
 
364
364
  type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
365
365
 
@@ -508,6 +508,7 @@ declare namespace axios {
508
508
  <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
509
509
  <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
510
510
 
511
+ create(config?: CreateAxiosDefaults): AxiosInstance;
511
512
  defaults: Omit<AxiosDefaults, 'headers'> & {
512
513
  headers: HeadersDefaults & {
513
514
  [key: string]: AxiosHeaderValue
@@ -526,7 +527,6 @@ declare namespace axios {
526
527
  }
527
528
 
528
529
  interface AxiosStatic extends AxiosInstance {
529
- create(config?: CreateAxiosDefaults): AxiosInstance;
530
530
  Cancel: CancelStatic;
531
531
  CancelToken: CancelTokenStatic;
532
532
  Axios: typeof Axios;
package/index.d.ts CHANGED
@@ -74,6 +74,8 @@ export class AxiosHeaders {
74
74
  getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
75
75
  hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
76
76
 
77
+ getSetCookie(): string[];
78
+
77
79
  [Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
78
80
  }
79
81
 
@@ -300,7 +302,7 @@ export interface AxiosProgressEvent {
300
302
 
301
303
  type Milliseconds = number;
302
304
 
303
- type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
305
+ type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
304
306
 
305
307
  type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
306
308
 
@@ -512,6 +514,7 @@ export interface AxiosInstance extends Axios {
512
514
  <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
513
515
  <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
514
516
 
517
+ create(config?: CreateAxiosDefaults): AxiosInstance;
515
518
  defaults: Omit<AxiosDefaults, 'headers'> & {
516
519
  headers: HeadersDefaults & {
517
520
  [key: string]: AxiosHeaderValue
@@ -546,7 +549,6 @@ export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
546
549
  export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
547
550
 
548
551
  export interface AxiosStatic extends AxiosInstance {
549
- create(config?: CreateAxiosDefaults): AxiosInstance;
550
552
  Cancel: CancelStatic;
551
553
  CancelToken: CancelTokenStatic;
552
554
  Axios: typeof Axios;
@@ -213,7 +213,7 @@ export default isFetchSupported && (async (config) => {
213
213
  } catch (err) {
214
214
  unsubscribe && unsubscribe();
215
215
 
216
- if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
216
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
217
217
  throw Object.assign(
218
218
  new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
219
219
  {
package/lib/core/Axios.js CHANGED
@@ -20,7 +20,7 @@ const validators = validator.validators;
20
20
  */
21
21
  class Axios {
22
22
  constructor(instanceConfig) {
23
- this.defaults = instanceConfig;
23
+ this.defaults = instanceConfig || {};
24
24
  this.interceptors = {
25
25
  request: new InterceptorManager(),
26
26
  response: new InterceptorManager()
@@ -100,10 +100,18 @@ class AxiosHeaders {
100
100
  setHeaders(header, valueOrRewrite)
101
101
  } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
102
102
  setHeaders(parseHeaders(header), valueOrRewrite);
103
- } else if (utils.isHeaders(header)) {
104
- for (const [key, value] of header.entries()) {
105
- setHeader(value, key, rewrite);
103
+ } else if (utils.isObject(header) && utils.isIterable(header)) {
104
+ let obj = {}, dest, key;
105
+ for (const entry of header) {
106
+ if (!utils.isArray(entry)) {
107
+ throw TypeError('Object iterator must return a key-value pair');
108
+ }
109
+
110
+ obj[key = entry[0]] = (dest = obj[key]) ?
111
+ (utils.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
106
112
  }
113
+
114
+ setHeaders(obj, valueOrRewrite)
107
115
  } else {
108
116
  header != null && setHeader(valueOrRewrite, header, rewrite);
109
117
  }
@@ -245,6 +253,10 @@ class AxiosHeaders {
245
253
  return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
246
254
  }
247
255
 
256
+ getSetCookie() {
257
+ return this.get("set-cookie") || [];
258
+ }
259
+
248
260
  get [Symbol.toStringTag]() {
249
261
  return 'AxiosHeaders';
250
262
  }
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.8.4";
1
+ export const VERSION = "1.9.0";
@@ -76,7 +76,7 @@ const formDataToStream = (form, headersHandler, options) => {
76
76
  }
77
77
 
78
78
  const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
79
- const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
79
+ const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
80
80
  let contentLength = footerBytes.byteLength;
81
81
 
82
82
  const parts = Array.from(form.entries()).map(([name, value]) => {
package/lib/utils.js CHANGED
@@ -6,6 +6,7 @@ import bind from './helpers/bind.js';
6
6
 
7
7
  const {toString} = Object.prototype;
8
8
  const {getPrototypeOf} = Object;
9
+ const {iterator, toStringTag} = Symbol;
9
10
 
10
11
  const kindOf = (cache => thing => {
11
12
  const str = toString.call(thing);
@@ -132,7 +133,7 @@ const isPlainObject = (val) => {
132
133
  }
133
134
 
134
135
  const prototype = getPrototypeOf(val);
135
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
136
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
136
137
  }
137
138
 
138
139
  /**
@@ -483,13 +484,13 @@ const isTypedArray = (TypedArray => {
483
484
  * @returns {void}
484
485
  */
485
486
  const forEachEntry = (obj, fn) => {
486
- const generator = obj && obj[Symbol.iterator];
487
+ const generator = obj && obj[iterator];
487
488
 
488
- const iterator = generator.call(obj);
489
+ const _iterator = generator.call(obj);
489
490
 
490
491
  let result;
491
492
 
492
- while ((result = iterator.next()) && !result.done) {
493
+ while ((result = _iterator.next()) && !result.done) {
493
494
  const pair = result.value;
494
495
  fn.call(obj, pair[0], pair[1]);
495
496
  }
@@ -610,7 +611,7 @@ const toFiniteNumber = (value, defaultValue) => {
610
611
  * @returns {boolean}
611
612
  */
612
613
  function isSpecCompliantForm(thing) {
613
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
614
+ return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
614
615
  }
615
616
 
616
617
  const toJSONObject = (obj) => {
@@ -679,6 +680,10 @@ const asap = typeof queueMicrotask !== 'undefined' ?
679
680
 
680
681
  // *********************
681
682
 
683
+
684
+ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
685
+
686
+
682
687
  export default {
683
688
  isArray,
684
689
  isArrayBuffer,
@@ -734,5 +739,6 @@ export default {
734
739
  isAsyncFn,
735
740
  isThenable,
736
741
  setImmediate: _setImmediate,
737
- asap
742
+ asap,
743
+ isIterable
738
744
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.8.4",
3
+ "version": "1.9.0",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -167,10 +167,10 @@
167
167
  "Justin Beckwith (https://github.com/JustinBeckwith)",
168
168
  "Martti Laine (https://github.com/codeclown)",
169
169
  "Xianming Zhong (https://github.com/chinesedfan)",
170
- "Remco Haszing (https://github.com/remcohaszing)",
171
170
  "Rikki Gibson (https://github.com/RikkiGibson)",
172
- "Ben Carp (https://github.com/carpben)",
173
- "Yasu Flores (https://github.com/yasuf)"
171
+ "Remco Haszing (https://github.com/remcohaszing)",
172
+ "Yasu Flores (https://github.com/yasuf)",
173
+ "Ben Carp (https://github.com/carpben)"
174
174
  ],
175
175
  "sideEffects": false,
176
176
  "release-it": {