@openclaw/feishu 2026.6.11 → 2026.6.34

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 (109) hide show
  1. package/dist/api.js +1 -1
  2. package/dist/{channel-C1MthXp0.js → channel-CJZM55mB.js} +3 -3
  3. package/dist/channel-plugin-api.js +1 -1
  4. package/dist/{channel.runtime-CiQqumBC.js → channel.runtime-DC21Vx4J.js} +1 -1
  5. package/dist/{monitor-CxUQtU--.js → monitor-BZS7ekeI.js} +1 -1
  6. package/dist/{monitor.account-C3SH96dD.js → monitor.account-D5SNO1bC.js} +1 -1
  7. package/dist/{secret-contract-ChjJKAJ9.js → secret-contract-DLaBl9m4.js} +26 -8
  8. package/dist/secret-contract-api.js +1 -1
  9. package/dist/setup-api.js +1 -1
  10. package/node_modules/agent-base/README.md +145 -0
  11. package/node_modules/agent-base/dist/src/index.d.ts +78 -0
  12. package/node_modules/agent-base/dist/src/index.js +203 -0
  13. package/node_modules/agent-base/dist/src/index.js.map +1 -0
  14. package/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
  15. package/node_modules/agent-base/dist/src/promisify.js +18 -0
  16. package/node_modules/agent-base/dist/src/promisify.js.map +1 -0
  17. package/node_modules/agent-base/package.json +64 -0
  18. package/node_modules/agent-base/src/index.ts +345 -0
  19. package/node_modules/agent-base/src/promisify.ts +33 -0
  20. package/node_modules/axios/CHANGELOG.md +165 -1
  21. package/node_modules/axios/README.md +310 -247
  22. package/node_modules/axios/dist/axios.js +533 -197
  23. package/node_modules/axios/dist/axios.min.js +3 -3
  24. package/node_modules/axios/dist/axios.min.js.map +1 -1
  25. package/node_modules/axios/dist/browser/axios.cjs +564 -161
  26. package/node_modules/axios/dist/esm/axios.js +564 -161
  27. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  28. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  29. package/node_modules/axios/dist/node/axios.cjs +839 -281
  30. package/node_modules/axios/index.d.cts +11 -4
  31. package/node_modules/axios/index.d.ts +7 -2
  32. package/node_modules/axios/lib/adapters/fetch.js +196 -37
  33. package/node_modules/axios/lib/adapters/http.js +328 -185
  34. package/node_modules/axios/lib/adapters/xhr.js +2 -1
  35. package/node_modules/axios/lib/core/Axios.js +4 -2
  36. package/node_modules/axios/lib/core/AxiosHeaders.js +13 -42
  37. package/node_modules/axios/lib/core/buildFullPath.js +29 -1
  38. package/node_modules/axios/lib/core/mergeConfig.js +34 -0
  39. package/node_modules/axios/lib/defaults/transitional.js +2 -0
  40. package/node_modules/axios/lib/env/data.js +1 -1
  41. package/node_modules/axios/lib/helpers/Http2Sessions.js +119 -0
  42. package/node_modules/axios/lib/helpers/buildURL.js +6 -4
  43. package/node_modules/axios/lib/helpers/composeSignals.js +48 -47
  44. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +16 -11
  45. package/node_modules/axios/lib/helpers/formDataToJSON.js +26 -4
  46. package/node_modules/axios/lib/helpers/formDataToStream.js +2 -2
  47. package/node_modules/axios/lib/helpers/fromDataURI.js +18 -5
  48. package/node_modules/axios/lib/helpers/progressEventReducer.js +3 -0
  49. package/node_modules/axios/lib/helpers/resolveConfig.js +17 -9
  50. package/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
  51. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +33 -1
  52. package/node_modules/axios/lib/helpers/toFormData.js +41 -11
  53. package/node_modules/axios/lib/utils.js +105 -19
  54. package/node_modules/axios/package.json +31 -13
  55. package/node_modules/debug/LICENSE +20 -0
  56. package/node_modules/debug/README.md +481 -0
  57. package/node_modules/debug/package.json +64 -0
  58. package/node_modules/debug/src/browser.js +272 -0
  59. package/node_modules/debug/src/common.js +292 -0
  60. package/node_modules/debug/src/index.js +10 -0
  61. package/node_modules/debug/src/node.js +263 -0
  62. package/node_modules/https-proxy-agent/README.md +137 -0
  63. package/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
  64. package/node_modules/https-proxy-agent/dist/agent.js +177 -0
  65. package/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
  66. package/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
  67. package/node_modules/https-proxy-agent/dist/index.js +14 -0
  68. package/node_modules/https-proxy-agent/dist/index.js.map +1 -0
  69. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
  70. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
  71. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
  72. package/node_modules/https-proxy-agent/package.json +56 -0
  73. package/node_modules/ms/index.js +162 -0
  74. package/node_modules/ms/license.md +21 -0
  75. package/node_modules/ms/package.json +38 -0
  76. package/node_modules/ms/readme.md +59 -0
  77. package/node_modules/protobufjs/dist/light/protobuf.js +145 -188
  78. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  79. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  80. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  81. package/node_modules/protobufjs/dist/minimal/protobuf.js +33 -76
  82. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  83. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  84. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  85. package/node_modules/protobufjs/dist/protobuf.js +168 -208
  86. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  87. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  88. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  89. package/node_modules/protobufjs/index.d.ts +0 -8
  90. package/node_modules/protobufjs/package.json +2 -3
  91. package/node_modules/protobufjs/src/parse.js +3 -0
  92. package/node_modules/protobufjs/src/util/minimal.js +0 -3
  93. package/npm-shrinkwrap.json +58 -16
  94. package/package.json +4 -4
  95. package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
  96. package/node_modules/@protobufjs/inquire/LICENSE +0 -26
  97. package/node_modules/@protobufjs/inquire/README.md +0 -13
  98. package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
  99. package/node_modules/@protobufjs/inquire/index.js +0 -38
  100. package/node_modules/@protobufjs/inquire/package.json +0 -21
  101. package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
  102. package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
  103. package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
  104. package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
  105. package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
  106. package/node_modules/axios/dist/axios.js.map +0 -1
  107. package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
  108. package/node_modules/axios/dist/esm/axios.js.map +0 -1
  109. package/node_modules/axios/dist/node/axios.cjs.map +0 -1
@@ -66,7 +66,9 @@ declare class AxiosHeaders {
66
66
  ...targets: Array<AxiosHeaders | axios.RawAxiosHeaders | string | undefined | null>
67
67
  ): AxiosHeaders;
68
68
 
69
- toJSON(asStrings?: boolean): axios.RawAxiosHeaders;
69
+ toJSON(asStrings: true): Record<string, string>;
70
+ toJSON(asStrings?: false): Record<string, string | string[]>;
71
+ toJSON(asStrings?: boolean): Record<string, string | string[]>;
70
72
 
71
73
  static from(thing?: AxiosHeaders | axios.RawAxiosHeaders | string): AxiosHeaders;
72
74
 
@@ -162,7 +164,9 @@ declare class AxiosError<T = unknown, D = any> extends Error {
162
164
  static readonly ETIMEDOUT = 'ETIMEDOUT';
163
165
  }
164
166
 
165
- declare class CanceledError<T> extends AxiosError<T> {}
167
+ declare class CanceledError<T> extends AxiosError<T> {
168
+ readonly name: 'CanceledError';
169
+ }
166
170
 
167
171
  declare class Axios {
168
172
  constructor(config?: axios.AxiosRequestConfig);
@@ -392,6 +396,8 @@ declare namespace axios {
392
396
  forcedJSONParsing?: boolean;
393
397
  clarifyTimeoutError?: boolean;
394
398
  legacyInterceptorReqResOrdering?: boolean;
399
+ advertiseZstdAcceptEncoding?: boolean;
400
+ validateStatusUndefinedResolves?: boolean;
395
401
  }
396
402
 
397
403
  interface GenericAbortSignal {
@@ -544,7 +550,7 @@ declare namespace axios {
544
550
  | LookupAddress
545
551
  >);
546
552
  withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
547
- parseReviver?: (this: any, key: string, value: any, context?: { source: string }) => any;
553
+ parseReviver?: (this: any, key: string, value: any, context?: { source?: string }) => any;
548
554
  fetchOptions?:
549
555
  | Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'>
550
556
  | Record<string, any>;
@@ -554,6 +560,7 @@ declare namespace axios {
554
560
  };
555
561
  formDataHeaderPolicy?: 'legacy' | 'content-only';
556
562
  redact?: string[];
563
+ sensitiveHeaders?: string[];
557
564
  }
558
565
 
559
566
  // Alias
@@ -691,7 +698,7 @@ declare namespace axios {
691
698
  CanceledError: typeof CanceledError;
692
699
  HttpStatusCode: typeof HttpStatusCode;
693
700
  readonly VERSION: string;
694
- isCancel(value: any): value is Cancel;
701
+ isCancel<T = any>(value: any): value is CanceledError<T>;
695
702
  all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
696
703
  spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
697
704
  isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
@@ -47,7 +47,9 @@ export class AxiosHeaders {
47
47
  ...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
48
48
  ): AxiosHeaders;
49
49
 
50
- toJSON(asStrings?: boolean): RawAxiosHeaders;
50
+ toJSON(asStrings: true): Record<string, string>;
51
+ toJSON(asStrings?: false): Record<string, string | string[]>;
52
+ toJSON(asStrings?: boolean): Record<string, string | string[]>;
51
53
 
52
54
  static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
53
55
 
@@ -281,6 +283,8 @@ export interface TransitionalOptions {
281
283
  forcedJSONParsing?: boolean;
282
284
  clarifyTimeoutError?: boolean;
283
285
  legacyInterceptorReqResOrdering?: boolean;
286
+ advertiseZstdAcceptEncoding?: boolean;
287
+ validateStatusUndefinedResolves?: boolean;
284
288
  }
285
289
 
286
290
  export interface GenericAbortSignal {
@@ -441,7 +445,7 @@ export interface AxiosRequestConfig<D = any> {
441
445
  [address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress
442
446
  >);
443
447
  withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
444
- parseReviver?: (this: any, key: string, value: any, context?: { source: string }) => any;
448
+ parseReviver?: (this: any, key: string, value: any, context?: { source?: string }) => any;
445
449
  fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
446
450
  httpVersion?: 1 | 2;
447
451
  http2Options?: Record<string, any> & {
@@ -449,6 +453,7 @@ export interface AxiosRequestConfig<D = any> {
449
453
  };
450
454
  formDataHeaderPolicy?: 'legacy' | 'content-only';
451
455
  redact?: string[];
456
+ sensitiveHeaders?: string[];
452
457
  }
453
458
 
454
459
  // Alias
@@ -13,11 +13,41 @@ import resolveConfig from '../helpers/resolveConfig.js';
13
13
  import settle from '../core/settle.js';
14
14
  import estimateDataURLDecodedBytes from '../helpers/estimateDataURLDecodedBytes.js';
15
15
  import { VERSION } from '../env/data.js';
16
+ import { toByteStringHeaderObject } from '../helpers/sanitizeHeaderValue.js';
16
17
 
17
18
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
18
19
 
19
20
  const { isFunction } = utils;
20
21
 
22
+ /**
23
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
24
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
25
+ *
26
+ * @param {string} str The string to encode
27
+ *
28
+ * @returns {string} UTF-8 bytes as a Latin-1 string
29
+ */
30
+ const encodeUTF8 = (str) =>
31
+ encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
32
+ String.fromCharCode(parseInt(hex, 16))
33
+ );
34
+
35
+ // Node's WHATWG URL parser returns `username` and `password` percent-encoded.
36
+ // Decode before composing the `auth` option so credentials such as
37
+ // `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
38
+ // original value for malformed input so a bad encoding never throws.
39
+ const decodeURIComponentSafe = (value) => {
40
+ if (!utils.isString(value)) {
41
+ return value;
42
+ }
43
+
44
+ try {
45
+ return decodeURIComponent(value);
46
+ } catch (error) {
47
+ return value;
48
+ }
49
+ };
50
+
21
51
  const test = (fn, ...args) => {
22
52
  try {
23
53
  return !!fn(...args);
@@ -26,8 +56,20 @@ const test = (fn, ...args) => {
26
56
  }
27
57
  };
28
58
 
59
+ const maybeWithAuthCredentials = (url) => {
60
+ const protocolIndex = url.indexOf('://');
61
+ let urlToCheck = url;
62
+ if (protocolIndex !== -1) {
63
+ urlToCheck = urlToCheck.slice(protocolIndex + 3);
64
+ }
65
+ return urlToCheck.includes('@') || urlToCheck.includes(':');
66
+ };
67
+
29
68
  const factory = (env) => {
30
- const globalObject = utils.global ?? globalThis;
69
+ const globalObject =
70
+ utils.global !== undefined && utils.global !== null
71
+ ? utils.global
72
+ : globalThis;
31
73
  const { ReadableStream, TextEncoder } = globalObject;
32
74
 
33
75
  env = utils.merge.call(
@@ -170,6 +212,7 @@ const factory = (env) => {
170
212
 
171
213
  const hasMaxContentLength = utils.isNumber(maxContentLength) && maxContentLength > -1;
172
214
  const hasMaxBodyLength = utils.isNumber(maxBodyLength) && maxBodyLength > -1;
215
+ const own = (key) => (utils.hasOwnProp(config, key) ? config[key] : undefined);
173
216
 
174
217
  let _fetch = envFetch || fetch;
175
218
 
@@ -191,7 +234,61 @@ const factory = (env) => {
191
234
 
192
235
  let requestContentLength;
193
236
 
237
+ // AxiosError we raise while the request body is being streamed. Captured
238
+ // by identity so the catch block can surface it directly, regardless of
239
+ // how the runtime wraps the resulting fetch rejection (undici exposes it
240
+ // as `err.cause`; some browsers drop the original error entirely).
241
+ let pendingBodyError = null;
242
+
243
+ const maxBodyLengthError = () =>
244
+ new AxiosError(
245
+ 'Request body larger than maxBodyLength limit',
246
+ AxiosError.ERR_BAD_REQUEST,
247
+ config,
248
+ request
249
+ );
250
+
194
251
  try {
252
+ // HTTP basic authentication
253
+ let auth = undefined;
254
+ const configAuth = own('auth');
255
+
256
+ if (configAuth) {
257
+ const username = utils.getSafeProp(configAuth, 'username') || '';
258
+ const password = utils.getSafeProp(configAuth, 'password') || '';
259
+ auth = {
260
+ username,
261
+ password
262
+ };
263
+ }
264
+
265
+ if (maybeWithAuthCredentials(url)) {
266
+ const parsedURL = new URL(url, platform.origin);
267
+
268
+ if (!auth && (parsedURL.username || parsedURL.password)) {
269
+ const urlUsername = decodeURIComponentSafe(parsedURL.username);
270
+ const urlPassword = decodeURIComponentSafe(parsedURL.password);
271
+ auth = {
272
+ username: urlUsername,
273
+ password: urlPassword
274
+ };
275
+ }
276
+
277
+ if (parsedURL.username || parsedURL.password) {
278
+ parsedURL.username = '';
279
+ parsedURL.password = '';
280
+ url = parsedURL.href;
281
+ }
282
+ }
283
+
284
+ if (auth) {
285
+ headers.delete('authorization');
286
+ headers.set(
287
+ 'Authorization',
288
+ 'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || '')))
289
+ );
290
+ }
291
+
195
292
  // Enforce maxContentLength for data: URLs up-front so we never materialize
196
293
  // an oversized payload. The HTTP adapter applies the same check (see http.js
197
294
  // "if (protocol === 'data:')" branch).
@@ -207,53 +304,96 @@ const factory = (env) => {
207
304
  }
208
305
  }
209
306
 
210
- // Enforce maxBodyLength against the outbound request body before dispatch.
211
- // Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
212
- // maxBodyLength limit'). Skip when the body length cannot be determined
213
- // (e.g. a live ReadableStream supplied by the caller).
307
+ // Enforce maxBodyLength against known-size bodies before dispatch using
308
+ // the body's *actual* size never a caller-declared Content-Length,
309
+ // which could under-report to slip an oversized body past the check.
310
+ // Unknown-size streams return undefined here and are counted per-chunk
311
+ // below as fetch consumes them.
214
312
  if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
215
- const outboundLength = await resolveBodyLength(headers, data);
216
- if (
217
- typeof outboundLength === 'number' &&
218
- isFinite(outboundLength) &&
219
- outboundLength > maxBodyLength
220
- ) {
221
- throw new AxiosError(
222
- 'Request body larger than maxBodyLength limit',
223
- AxiosError.ERR_BAD_REQUEST,
224
- config,
225
- request
226
- );
313
+ const outboundLength = await getBodyLength(data);
314
+ if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
315
+ requestContentLength = outboundLength;
316
+ if (outboundLength > maxBodyLength) {
317
+ throw maxBodyLengthError();
318
+ }
227
319
  }
228
320
  }
229
321
 
322
+ // A streamed body under maxBodyLength must be counted as fetch consumes
323
+ // it; its size is never trusted from a caller-declared Content-Length.
324
+ const mustEnforceStreamBody =
325
+ hasMaxBodyLength && (utils.isReadableStream(data) || utils.isStream(data));
326
+
327
+ const trackRequestStream = (stream, onProgress, flush) =>
328
+ trackStream(
329
+ stream,
330
+ DEFAULT_CHUNK_SIZE,
331
+ (loadedBytes) => {
332
+ if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
333
+ throw (pendingBodyError = maxBodyLengthError());
334
+ }
335
+ onProgress && onProgress(loadedBytes);
336
+ },
337
+ flush
338
+ );
339
+
230
340
  if (
231
- onUploadProgress &&
232
341
  supportsRequestStream &&
233
342
  method !== 'get' &&
234
343
  method !== 'head' &&
235
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
344
+ (onUploadProgress || mustEnforceStreamBody)
236
345
  ) {
237
- let _request = new Request(url, {
238
- method: 'POST',
239
- body: data,
240
- duplex: 'half',
241
- });
346
+ requestContentLength =
347
+ requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
348
+
349
+ // A declared length of 0 is only trusted to skip the wrap when we are
350
+ // not enforcing a stream limit (which must not rely on that header).
351
+ if (requestContentLength !== 0 || mustEnforceStreamBody) {
352
+ let _request = new Request(url, {
353
+ method: 'POST',
354
+ body: data,
355
+ duplex: 'half',
356
+ });
242
357
 
243
- let contentTypeHeader;
358
+ let contentTypeHeader;
244
359
 
245
- if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
246
- headers.setContentType(contentTypeHeader);
247
- }
360
+ if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
361
+ headers.setContentType(contentTypeHeader);
362
+ }
248
363
 
249
- if (_request.body) {
250
- const [onProgress, flush] = progressEventDecorator(
251
- requestContentLength,
252
- progressEventReducer(asyncDecorator(onUploadProgress))
253
- );
364
+ if (_request.body) {
365
+ const [onProgress, flush] =
366
+ (onUploadProgress &&
367
+ progressEventDecorator(
368
+ requestContentLength,
369
+ progressEventReducer(asyncDecorator(onUploadProgress))
370
+ )) ||
371
+ [];
254
372
 
255
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
373
+ data = trackRequestStream(_request.body, onProgress, flush);
374
+ }
256
375
  }
376
+ } else if (
377
+ mustEnforceStreamBody &&
378
+ !isRequestSupported &&
379
+ isReadableStreamSupported &&
380
+ method !== 'get' &&
381
+ method !== 'head'
382
+ ) {
383
+ data = trackRequestStream(data);
384
+ } else if (
385
+ mustEnforceStreamBody &&
386
+ isRequestSupported &&
387
+ !supportsRequestStream &&
388
+ method !== 'get' &&
389
+ method !== 'head'
390
+ ) {
391
+ throw new AxiosError(
392
+ 'Stream request bodies are not supported by the current fetch implementation',
393
+ AxiosError.ERR_NOT_SUPPORT,
394
+ config,
395
+ request
396
+ );
257
397
  }
258
398
 
259
399
  if (!utils.isString(withCredentials)) {
@@ -284,7 +424,7 @@ const factory = (env) => {
284
424
  ...fetchOptions,
285
425
  signal: composedSignal,
286
426
  method: method.toUpperCase(),
287
- headers: headers.normalize().toJSON(),
427
+ headers: toByteStringHeaderObject(headers.normalize()),
288
428
  body: data,
289
429
  duplex: 'half',
290
430
  credentials: isCredentialsSupported ? withCredentials : undefined,
@@ -296,10 +436,12 @@ const factory = (env) => {
296
436
  ? _fetch(request, fetchOptions)
297
437
  : _fetch(url, resolvedOptions));
298
438
 
439
+ const responseHeaders = AxiosHeaders.from(response.headers);
440
+
299
441
  // Cheap pre-check: if the server honestly declares a content-length that
300
442
  // already exceeds the cap, reject before we start streaming.
301
443
  if (hasMaxContentLength) {
302
- const declaredLength = utils.toFiniteNumber(response.headers.get('content-length'));
444
+ const declaredLength = utils.toFiniteNumber(responseHeaders.getContentLength());
303
445
  if (declaredLength != null && declaredLength > maxContentLength) {
304
446
  throw new AxiosError(
305
447
  'maxContentLength size of ' + maxContentLength + ' exceeded',
@@ -324,7 +466,7 @@ const factory = (env) => {
324
466
  options[prop] = response[prop];
325
467
  });
326
468
 
327
- const responseContentLength = utils.toFiniteNumber(response.headers.get('content-length'));
469
+ const responseContentLength = utils.toFiniteNumber(responseHeaders.getContentLength());
328
470
 
329
471
  const [onProgress, flush] =
330
472
  (onDownloadProgress &&
@@ -419,6 +561,23 @@ const factory = (env) => {
419
561
  throw canceledError;
420
562
  }
421
563
 
564
+ // Surface a maxBodyLength violation we raised while the request body was
565
+ // being streamed. Matching by identity (rather than reading
566
+ // `err.cause.isAxiosError`) keeps the error deterministic across runtimes
567
+ // and avoids both prototype-pollution reads and mis-attributing a foreign
568
+ // AxiosError that merely happened to land in `err.cause`.
569
+ if (pendingBodyError) {
570
+ request && !pendingBodyError.request && (pendingBodyError.request = request);
571
+ throw pendingBodyError;
572
+ }
573
+
574
+ // Re-throw AxiosErrors we raised synchronously (data: URL / content-length
575
+ // pre-checks, response size enforcement) without re-wrapping them.
576
+ if (err instanceof AxiosError) {
577
+ request && !err.request && (err.request = request);
578
+ throw err;
579
+ }
580
+
422
581
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
423
582
  throw Object.assign(
424
583
  new AxiosError(