apify-client 2.23.5-beta.8 → 2.24.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/dist/bundle.js CHANGED
@@ -13019,7 +13019,7 @@ class HttpClient {
13019
13019
  this.axios.defaults.httpsAgent = this.httpsAgent;
13020
13020
  // Works only in Node. Cannot be set in browser
13021
13021
  const isAtHome = !!process.env[_apify_consts__rspack_import_1.APIFY_ENV_VARS.IS_AT_HOME];
13022
- let userAgent = `ApifyClient/${version} (${os.type()}; Node/${process.version}); isAtHome/${isAtHome}`;
13022
+ let userAgent = `ApifyClient/${version} (${os.platform()}; Node/${process.version}); isAtHome/${isAtHome}`;
13023
13023
  if (this.userAgentSuffix) {
13024
13024
  userAgent += `; ${(0,_utils__rspack_import_4.asArray)(this.userAgentSuffix).join('; ')}`;
13025
13025
  }
@@ -13221,13 +13221,13 @@ function ensureHeadersPrototype(config) {
13221
13221
  return typeof value === 'function' ? value.toString() : value;
13222
13222
  });
13223
13223
  }
13224
- async function maybeGzipRequest(config) {
13224
+ async function maybeCompressRequest(config) {
13225
13225
  if (config.headers?.['content-encoding']) return config;
13226
- const maybeZippedData = await (0,_utils__rspack_import_2.maybeGzipValue)(config.data);
13227
- if (maybeZippedData) {
13226
+ const maybeCompressed = await (0,_utils__rspack_import_2.maybeCompressValue)(config.data);
13227
+ if (maybeCompressed) {
13228
13228
  config.headers ??= {};
13229
- config.headers['content-encoding'] = 'gzip';
13230
- config.data = maybeZippedData;
13229
+ config.headers['content-encoding'] = maybeCompressed.encoding;
13230
+ config.data = maybeCompressed.data;
13231
13231
  }
13232
13232
  return config;
13233
13233
  }
@@ -13253,7 +13253,7 @@ function parseResponseData(response) {
13253
13253
  return response;
13254
13254
  }
13255
13255
  const requestInterceptors = [
13256
- maybeGzipRequest,
13256
+ maybeCompressRequest,
13257
13257
  serializeRequest,
13258
13258
  ensureHeadersPrototype
13259
13259
  ];
@@ -13419,9 +13419,6 @@ __webpack_require__.r(__webpack_exports__);
13419
13419
  params: this._params(params),
13420
13420
  // Apify internal property. Tells the request serialization interceptor
13421
13421
  // to stringify functions to JSON, instead of omitting them.
13422
- // TODO: remove this ts-expect-error once we migrate HttpClient to TS and define Apify
13423
- // extension of Axios configs
13424
- // @ts-expect-error Apify extension
13425
13422
  stringifyFunctions: true
13426
13423
  };
13427
13424
  if (options.contentType) {
@@ -13501,6 +13498,62 @@ __webpack_require__.r(__webpack_exports__);
13501
13498
  await streamedLog?.stop();
13502
13499
  });
13503
13500
  }
13501
+ /**
13502
+ * Validates the provided input for the Actor against its input schema.
13503
+ *
13504
+ * Sends the input to the API, which validates it against the Actor's input schema without
13505
+ * starting a run. If the input is valid, the method resolves with `true`. If the input is
13506
+ * invalid, the API responds with an error that is thrown as an `ApifyApiError` describing the
13507
+ * validation problem.
13508
+ *
13509
+ * @param input - Input to validate against the Actor's input schema. Can be any JSON-serializable
13510
+ * value (object, array, string, number). If `contentType` is specified in options,
13511
+ * input should be a string or Buffer.
13512
+ * @param options - Validation options
13513
+ * @param options.build - Tag or number of the build whose input schema the input is validated against
13514
+ * (e.g., `'latest'` or `'1.2.345'`). If not provided, uses the default build.
13515
+ * @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
13516
+ * @returns `true` if the input is valid. Invalid input causes the underlying API call to throw an `ApifyApiError`.
13517
+ * @see https://docs.apify.com/api/v2/act-validate-input-post
13518
+ *
13519
+ * @example
13520
+ * ```javascript
13521
+ * // Validate input against the default build's input schema
13522
+ * const isValid = await client.actor('my-actor').validateInput({ url: 'https://example.com' });
13523
+ *
13524
+ * // Validate against a specific build
13525
+ * const isValid = await client.actor('my-actor').validateInput(
13526
+ * { url: 'https://example.com' },
13527
+ * { build: 'beta' },
13528
+ * );
13529
+ * ```
13530
+ */ async validateInput(input) {
13531
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
13532
+ // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
13533
+ // then it will process input as a buffer.
13534
+ ow__rspack_import_11_default()(options, ow__rspack_import_11_default().object.exactShape({
13535
+ build: (ow__rspack_import_11_default().optional.string),
13536
+ contentType: (ow__rspack_import_11_default().optional.string)
13537
+ }));
13538
+ const request = {
13539
+ url: this._url('validate-input'),
13540
+ method: 'POST',
13541
+ data: input,
13542
+ params: this._params({
13543
+ build: options.build
13544
+ }),
13545
+ // Apify internal property. Tells the request serialization interceptor
13546
+ // to stringify functions to JSON, instead of omitting them.
13547
+ stringifyFunctions: true
13548
+ };
13549
+ if (options.contentType) {
13550
+ request.headers = {
13551
+ 'content-type': options.contentType
13552
+ };
13553
+ }
13554
+ const response = await this.httpClient.call(request);
13555
+ return response.data.valid;
13556
+ }
13504
13557
  /**
13505
13558
  * Builds the Actor.
13506
13559
  *
@@ -13606,7 +13659,7 @@ __webpack_require__.r(__webpack_exports__);
13606
13659
  */ lastRun() {
13607
13660
  let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
13608
13661
  ow__rspack_import_11_default()(options, ow__rspack_import_11_default().object.exactShape({
13609
- status: ow__rspack_import_11_default().optional.string.oneOf(Object.values(_apify_consts__rspack_import_0.ACT_JOB_STATUSES)),
13662
+ status: ow__rspack_import_11_default().optional.string.oneOf(Object.values(_apify_consts__rspack_import_0.ACTOR_JOB_STATUSES)),
13610
13663
  origin: ow__rspack_import_11_default().optional.string.oneOf(Object.values(_apify_consts__rspack_import_0.META_ORIGINS))
13611
13664
  }));
13612
13665
  return new _run__rspack_import_8.RunClient(this._subResourceOptions({
@@ -17908,7 +17961,7 @@ let _computedKey;
17908
17961
  const NOT_FOUND_STATUS_CODE = 404;
17909
17962
  const RECORD_NOT_FOUND_TYPE = 'record-not-found';
17910
17963
  const RECORD_OR_TOKEN_NOT_FOUND_TYPE = 'record-or-token-not-found';
17911
- const MIN_GZIP_BYTES = 1024;
17964
+ const MIN_COMPRESS_BYTES = 1024;
17912
17965
  /**
17913
17966
  * Returns object's 'data' property or throws if parameter is not an object,
17914
17967
  * or an object without a 'data' property.
@@ -17978,23 +18031,61 @@ const MIN_GZIP_BYTES = 1024;
17978
18031
  }
17979
18032
  let gzipPromisified;
17980
18033
  /**
17981
- * Gzip provided value, otherwise returns undefined.
17982
- */ async function maybeGzipValue(value) {
17983
- if (!isNode()) return;
17984
- if (typeof value !== 'string' && !Buffer.isBuffer(value)) return;
17985
- // Request compression is not that important so let's
17986
- // skip it instead of throwing for unsupported types.
17987
- const areDataLargeEnough = Buffer.byteLength(value) >= MIN_GZIP_BYTES;
17988
- if (areDataLargeEnough) {
17989
- if (!gzipPromisified) {
17990
- const { promisify } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 6029, 23));
17991
- const { gzip } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1134, 23));
17992
- gzipPromisified = promisify(gzip);
18034
+ * Gzip-compress the provided value.
18035
+ */ async function gzipValue(value) {
18036
+ if (!gzipPromisified) {
18037
+ const { promisify } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 6029, 23));
18038
+ const { gzip } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1134, 23));
18039
+ gzipPromisified = promisify(gzip);
18040
+ }
18041
+ return gzipPromisified(value);
18042
+ }
18043
+ // null = confirmed unavailable; undefined = not yet checked
18044
+ let brotliCompressPromisified;
18045
+ /**
18046
+ * Brotli-compress the provided value, or return undefined if brotli is unavailable
18047
+ * (Node.js < v10.16.0), this is a strict defensive guard.
18048
+ */ async function maybeBrotliValue(value) {
18049
+ if (brotliCompressPromisified === undefined) {
18050
+ const { promisify } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 6029, 23));
18051
+ const { brotliCompress, constants } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1134, 23));
18052
+ if (typeof brotliCompress === 'function') {
18053
+ const compress = promisify(brotliCompress);
18054
+ brotliCompressPromisified = async (value)=>compress(value, {
18055
+ params: {
18056
+ [constants.BROTLI_PARAM_QUALITY]: 6
18057
+ }
18058
+ });
18059
+ } else {
18060
+ brotliCompressPromisified = null;
17993
18061
  }
17994
- return gzipPromisified(value);
18062
+ }
18063
+ if (brotliCompressPromisified !== null) {
18064
+ return brotliCompressPromisified(value);
17995
18065
  }
17996
18066
  return undefined;
17997
18067
  }
18068
+ /**
18069
+ * Compress the passed value using brotli if available or using gzip as a fallback. Returns undefined
18070
+ * if the data is too small / wrong type.
18071
+ */ async function maybeCompressValue(value) {
18072
+ if (!isNode()) return undefined;
18073
+ // Request compression is not that important so let's
18074
+ // skip it instead of throwing for unsupported types.
18075
+ if (typeof value !== 'string' && !Buffer.isBuffer(value)) return undefined;
18076
+ const areDataLargeEnough = Buffer.byteLength(value) >= MIN_COMPRESS_BYTES;
18077
+ if (!areDataLargeEnough) return undefined;
18078
+ const brotli = await maybeBrotliValue(value);
18079
+ if (brotli) return {
18080
+ data: brotli,
18081
+ encoding: 'br'
18082
+ };
18083
+ const gzipped = await gzipValue(value);
18084
+ return {
18085
+ data: gzipped,
18086
+ encoding: 'gzip'
18087
+ };
18088
+ }
17998
18089
  /**
17999
18090
  * Helper function slice the items from array to fit the max byte length.
18000
18091
  */ function sliceArrayByByteLength(array, maxByteLength, startIndex) {
@@ -18031,7 +18122,7 @@ function isStream(value) {
18031
18122
  function getVersionData() {
18032
18123
  if (true) {
18033
18124
  return {
18034
- version: "2.23.5-beta.8"
18125
+ version: "2.24.0"
18035
18126
  };
18036
18127
  }
18037
18128
  // eslint-disable-next-line
@@ -18126,7 +18217,7 @@ __webpack_require__.d(__webpack_exports__, {
18126
18217
  isBuffer: () => (isBuffer),
18127
18218
  isNode: () => (isNode),
18128
18219
  isStream: () => (isStream),
18129
- maybeGzipValue: () => (maybeGzipValue),
18220
+ maybeCompressValue: () => (maybeCompressValue),
18130
18221
  parseDateFields: () => (parseDateFields),
18131
18222
  pluckData: () => (pluckData),
18132
18223
  sliceArrayByByteLength: () => (sliceArrayByByteLength),
@@ -22007,11 +22098,11 @@ __webpack_require__.r(__webpack_exports__);
22007
22098
  /* import */ var _utils_js__rspack_import_0 = __webpack_require__(7275);
22008
22099
  /* import */ var _core_AxiosError_js__rspack_import_2 = __webpack_require__(4062);
22009
22100
  /* import */ var _helpers_composeSignals_js__rspack_import_4 = __webpack_require__(2723);
22010
- /* import */ var _helpers_trackStream_js__rspack_import_7 = __webpack_require__(1791);
22011
- /* import */ var _core_AxiosHeaders_js__rspack_import_11 = __webpack_require__(7110);
22012
- /* import */ var _helpers_progressEventReducer_js__rspack_import_6 = __webpack_require__(7837);
22101
+ /* import */ var _helpers_trackStream_js__rspack_import_6 = __webpack_require__(1791);
22102
+ /* import */ var _core_AxiosHeaders_js__rspack_import_10 = __webpack_require__(7110);
22103
+ /* import */ var _helpers_progressEventReducer_js__rspack_import_7 = __webpack_require__(7837);
22013
22104
  /* import */ var _helpers_resolveConfig_js__rspack_import_3 = __webpack_require__(8382);
22014
- /* import */ var _core_settle_js__rspack_import_10 = __webpack_require__(3853);
22105
+ /* import */ var _core_settle_js__rspack_import_11 = __webpack_require__(3853);
22015
22106
  /* import */ var _helpers_estimateDataURLDecodedBytes_js__rspack_import_5 = __webpack_require__(1526);
22016
22107
  /* import */ var _env_data_js__rspack_import_8 = __webpack_require__(9888);
22017
22108
  /* import */ var _helpers_sanitizeHeaderValue_js__rspack_import_9 = __webpack_require__(8267);
@@ -22247,14 +22338,28 @@ const factory = (env) => {
22247
22338
 
22248
22339
  let requestContentLength;
22249
22340
 
22341
+ // AxiosError we raise while the request body is being streamed. Captured
22342
+ // by identity so the catch block can surface it directly, regardless of
22343
+ // how the runtime wraps the resulting fetch rejection (undici exposes it
22344
+ // as `err.cause`; some browsers drop the original error entirely).
22345
+ let pendingBodyError = null;
22346
+
22347
+ const maxBodyLengthError = () =>
22348
+ new _core_AxiosError_js__rspack_import_2["default"](
22349
+ 'Request body larger than maxBodyLength limit',
22350
+ _core_AxiosError_js__rspack_import_2["default"].ERR_BAD_REQUEST,
22351
+ config,
22352
+ request
22353
+ );
22354
+
22250
22355
  try {
22251
22356
  // HTTP basic authentication
22252
22357
  let auth = undefined;
22253
22358
  const configAuth = own('auth');
22254
22359
 
22255
22360
  if (configAuth) {
22256
- const username = configAuth.username || '';
22257
- const password = configAuth.password || '';
22361
+ const username = _utils_js__rspack_import_0["default"].getSafeProp(configAuth, 'username') || '';
22362
+ const password = _utils_js__rspack_import_0["default"].getSafeProp(configAuth, 'password') || '';
22258
22363
  auth = {
22259
22364
  username,
22260
22365
  password
@@ -22303,53 +22408,96 @@ const factory = (env) => {
22303
22408
  }
22304
22409
  }
22305
22410
 
22306
- // Enforce maxBodyLength against the outbound request body before dispatch.
22307
- // Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
22308
- // maxBodyLength limit'). Skip when the body length cannot be determined
22309
- // (e.g. a live ReadableStream supplied by the caller).
22411
+ // Enforce maxBodyLength against known-size bodies before dispatch using
22412
+ // the body's *actual* size never a caller-declared Content-Length,
22413
+ // which could under-report to slip an oversized body past the check.
22414
+ // Unknown-size streams return undefined here and are counted per-chunk
22415
+ // below as fetch consumes them.
22310
22416
  if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
22311
- const outboundLength = await resolveBodyLength(headers, data);
22312
- if (
22313
- typeof outboundLength === 'number' &&
22314
- isFinite(outboundLength) &&
22315
- outboundLength > maxBodyLength
22316
- ) {
22317
- throw new _core_AxiosError_js__rspack_import_2["default"](
22318
- 'Request body larger than maxBodyLength limit',
22319
- _core_AxiosError_js__rspack_import_2["default"].ERR_BAD_REQUEST,
22320
- config,
22321
- request
22322
- );
22417
+ const outboundLength = await getBodyLength(data);
22418
+ if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
22419
+ requestContentLength = outboundLength;
22420
+ if (outboundLength > maxBodyLength) {
22421
+ throw maxBodyLengthError();
22422
+ }
22323
22423
  }
22324
22424
  }
22325
22425
 
22426
+ // A streamed body under maxBodyLength must be counted as fetch consumes
22427
+ // it; its size is never trusted from a caller-declared Content-Length.
22428
+ const mustEnforceStreamBody =
22429
+ hasMaxBodyLength && (_utils_js__rspack_import_0["default"].isReadableStream(data) || _utils_js__rspack_import_0["default"].isStream(data));
22430
+
22431
+ const trackRequestStream = (stream, onProgress, flush) =>
22432
+ (0,_helpers_trackStream_js__rspack_import_6.trackStream)(
22433
+ stream,
22434
+ DEFAULT_CHUNK_SIZE,
22435
+ (loadedBytes) => {
22436
+ if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
22437
+ throw (pendingBodyError = maxBodyLengthError());
22438
+ }
22439
+ onProgress && onProgress(loadedBytes);
22440
+ },
22441
+ flush
22442
+ );
22443
+
22326
22444
  if (
22327
- onUploadProgress &&
22328
22445
  supportsRequestStream &&
22329
22446
  method !== 'get' &&
22330
22447
  method !== 'head' &&
22331
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
22448
+ (onUploadProgress || mustEnforceStreamBody)
22332
22449
  ) {
22333
- let _request = new Request(url, {
22334
- method: 'POST',
22335
- body: data,
22336
- duplex: 'half',
22337
- });
22450
+ requestContentLength =
22451
+ requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
22452
+
22453
+ // A declared length of 0 is only trusted to skip the wrap when we are
22454
+ // not enforcing a stream limit (which must not rely on that header).
22455
+ if (requestContentLength !== 0 || mustEnforceStreamBody) {
22456
+ let _request = new Request(url, {
22457
+ method: 'POST',
22458
+ body: data,
22459
+ duplex: 'half',
22460
+ });
22338
22461
 
22339
- let contentTypeHeader;
22462
+ let contentTypeHeader;
22340
22463
 
22341
- if (_utils_js__rspack_import_0["default"].isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
22342
- headers.setContentType(contentTypeHeader);
22343
- }
22464
+ if (_utils_js__rspack_import_0["default"].isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
22465
+ headers.setContentType(contentTypeHeader);
22466
+ }
22344
22467
 
22345
- if (_request.body) {
22346
- const [onProgress, flush] = (0,_helpers_progressEventReducer_js__rspack_import_6.progressEventDecorator)(
22347
- requestContentLength,
22348
- (0,_helpers_progressEventReducer_js__rspack_import_6.progressEventReducer)((0,_helpers_progressEventReducer_js__rspack_import_6.asyncDecorator)(onUploadProgress))
22349
- );
22468
+ if (_request.body) {
22469
+ const [onProgress, flush] =
22470
+ (onUploadProgress &&
22471
+ (0,_helpers_progressEventReducer_js__rspack_import_7.progressEventDecorator)(
22472
+ requestContentLength,
22473
+ (0,_helpers_progressEventReducer_js__rspack_import_7.progressEventReducer)((0,_helpers_progressEventReducer_js__rspack_import_7.asyncDecorator)(onUploadProgress))
22474
+ )) ||
22475
+ [];
22350
22476
 
22351
- data = (0,_helpers_trackStream_js__rspack_import_7.trackStream)(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
22477
+ data = trackRequestStream(_request.body, onProgress, flush);
22478
+ }
22352
22479
  }
22480
+ } else if (
22481
+ mustEnforceStreamBody &&
22482
+ !isRequestSupported &&
22483
+ isReadableStreamSupported &&
22484
+ method !== 'get' &&
22485
+ method !== 'head'
22486
+ ) {
22487
+ data = trackRequestStream(data);
22488
+ } else if (
22489
+ mustEnforceStreamBody &&
22490
+ isRequestSupported &&
22491
+ !supportsRequestStream &&
22492
+ method !== 'get' &&
22493
+ method !== 'head'
22494
+ ) {
22495
+ throw new _core_AxiosError_js__rspack_import_2["default"](
22496
+ 'Stream request bodies are not supported by the current fetch implementation',
22497
+ _core_AxiosError_js__rspack_import_2["default"].ERR_NOT_SUPPORT,
22498
+ config,
22499
+ request
22500
+ );
22353
22501
  }
22354
22502
 
22355
22503
  if (!_utils_js__rspack_import_0["default"].isString(withCredentials)) {
@@ -22392,10 +22540,12 @@ const factory = (env) => {
22392
22540
  ? _fetch(request, fetchOptions)
22393
22541
  : _fetch(url, resolvedOptions));
22394
22542
 
22543
+ const responseHeaders = _core_AxiosHeaders_js__rspack_import_10["default"].from(response.headers);
22544
+
22395
22545
  // Cheap pre-check: if the server honestly declares a content-length that
22396
22546
  // already exceeds the cap, reject before we start streaming.
22397
22547
  if (hasMaxContentLength) {
22398
- const declaredLength = _utils_js__rspack_import_0["default"].toFiniteNumber(response.headers.get('content-length'));
22548
+ const declaredLength = _utils_js__rspack_import_0["default"].toFiniteNumber(responseHeaders.getContentLength());
22399
22549
  if (declaredLength != null && declaredLength > maxContentLength) {
22400
22550
  throw new _core_AxiosError_js__rspack_import_2["default"](
22401
22551
  'maxContentLength size of ' + maxContentLength + ' exceeded',
@@ -22420,13 +22570,13 @@ const factory = (env) => {
22420
22570
  options[prop] = response[prop];
22421
22571
  });
22422
22572
 
22423
- const responseContentLength = _utils_js__rspack_import_0["default"].toFiniteNumber(response.headers.get('content-length'));
22573
+ const responseContentLength = _utils_js__rspack_import_0["default"].toFiniteNumber(responseHeaders.getContentLength());
22424
22574
 
22425
22575
  const [onProgress, flush] =
22426
22576
  (onDownloadProgress &&
22427
- (0,_helpers_progressEventReducer_js__rspack_import_6.progressEventDecorator)(
22577
+ (0,_helpers_progressEventReducer_js__rspack_import_7.progressEventDecorator)(
22428
22578
  responseContentLength,
22429
- (0,_helpers_progressEventReducer_js__rspack_import_6.progressEventReducer)((0,_helpers_progressEventReducer_js__rspack_import_6.asyncDecorator)(onDownloadProgress), true)
22579
+ (0,_helpers_progressEventReducer_js__rspack_import_7.progressEventReducer)((0,_helpers_progressEventReducer_js__rspack_import_7.asyncDecorator)(onDownloadProgress), true)
22430
22580
  )) ||
22431
22581
  [];
22432
22582
 
@@ -22447,7 +22597,7 @@ const factory = (env) => {
22447
22597
  };
22448
22598
 
22449
22599
  response = new Response(
22450
- (0,_helpers_trackStream_js__rspack_import_7.trackStream)(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
22600
+ (0,_helpers_trackStream_js__rspack_import_6.trackStream)(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
22451
22601
  flush && flush();
22452
22602
  unsubscribe && unsubscribe();
22453
22603
  }),
@@ -22492,9 +22642,9 @@ const factory = (env) => {
22492
22642
  !isStreamResponse && unsubscribe && unsubscribe();
22493
22643
 
22494
22644
  return await new Promise((resolve, reject) => {
22495
- (0,_core_settle_js__rspack_import_10["default"])(resolve, reject, {
22645
+ (0,_core_settle_js__rspack_import_11["default"])(resolve, reject, {
22496
22646
  data: responseData,
22497
- headers: _core_AxiosHeaders_js__rspack_import_11["default"].from(response.headers),
22647
+ headers: _core_AxiosHeaders_js__rspack_import_10["default"].from(response.headers),
22498
22648
  status: response.status,
22499
22649
  statusText: response.statusText,
22500
22650
  config,
@@ -22515,6 +22665,23 @@ const factory = (env) => {
22515
22665
  throw canceledError;
22516
22666
  }
22517
22667
 
22668
+ // Surface a maxBodyLength violation we raised while the request body was
22669
+ // being streamed. Matching by identity (rather than reading
22670
+ // `err.cause.isAxiosError`) keeps the error deterministic across runtimes
22671
+ // and avoids both prototype-pollution reads and mis-attributing a foreign
22672
+ // AxiosError that merely happened to land in `err.cause`.
22673
+ if (pendingBodyError) {
22674
+ request && !pendingBodyError.request && (pendingBodyError.request = request);
22675
+ throw pendingBodyError;
22676
+ }
22677
+
22678
+ // Re-throw AxiosErrors we raised synchronously (data: URL / content-length
22679
+ // pre-checks, response size enforcement) without re-wrapping them.
22680
+ if (err instanceof _core_AxiosError_js__rspack_import_2["default"]) {
22681
+ request && !err.request && (err.request = request);
22682
+ throw err;
22683
+ }
22684
+
22518
22685
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
22519
22686
  throw Object.assign(
22520
22687
  new _core_AxiosError_js__rspack_import_2["default"](
@@ -23250,6 +23417,7 @@ class Axios {
23250
23417
  clarifyTimeoutError: validators.transitional(validators.boolean),
23251
23418
  legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
23252
23419
  advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
23420
+ validateStatusUndefinedResolves: validators.transitional(validators.boolean),
23253
23421
  },
23254
23422
  false
23255
23423
  );
@@ -23381,7 +23549,7 @@ class Axios {
23381
23549
 
23382
23550
  getUri(config) {
23383
23551
  config = (0,_mergeConfig_js__rspack_import_2["default"])(this.defaults, config);
23384
- const fullPath = (0,_buildFullPath_js__rspack_import_7["default"])(config.baseURL, config.url, config.allowAbsoluteUrls);
23552
+ const fullPath = (0,_buildFullPath_js__rspack_import_7["default"])(config.baseURL, config.url, config.allowAbsoluteUrls, config);
23385
23553
  return (0,_helpers_buildURL_js__rspack_import_8["default"])(fullPath, config.params, config.paramsSerializer);
23386
23554
  }
23387
23555
  }
@@ -23394,7 +23562,7 @@ _utils_js__rspack_import_3["default"].forEach(['delete', 'get', 'head', 'options
23394
23562
  (0,_mergeConfig_js__rspack_import_2["default"])(config || {}, {
23395
23563
  method,
23396
23564
  url,
23397
- data: (config || {}).data,
23565
+ data: config && _utils_js__rspack_import_3["default"].hasOwnProp(config, 'data') ? config.data : undefined,
23398
23566
  })
23399
23567
  );
23400
23568
  };
@@ -23744,8 +23912,8 @@ class AxiosHeaders {
23744
23912
  setHeaders(header, valueOrRewrite);
23745
23913
  } else if (_utils_js__rspack_import_0["default"].isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
23746
23914
  setHeaders((0,_helpers_parseHeaders_js__rspack_import_2["default"])(header), valueOrRewrite);
23747
- } else if (_utils_js__rspack_import_0["default"].isObject(header) && _utils_js__rspack_import_0["default"].isIterable(header)) {
23748
- let obj = {},
23915
+ } else if (_utils_js__rspack_import_0["default"].isObject(header) && _utils_js__rspack_import_0["default"].isSafeIterable(header)) {
23916
+ let obj = Object.create(null),
23749
23917
  dest,
23750
23918
  key;
23751
23919
  for (const entry of header) {
@@ -23753,11 +23921,14 @@ class AxiosHeaders {
23753
23921
  throw new TypeError('Object iterator must return a key-value pair');
23754
23922
  }
23755
23923
 
23756
- obj[(key = entry[0])] = (dest = obj[key])
23757
- ? _utils_js__rspack_import_0["default"].isArray(dest)
23758
- ? [...dest, entry[1]]
23759
- : [dest, entry[1]]
23760
- : entry[1];
23924
+ key = entry[0];
23925
+
23926
+ if (_utils_js__rspack_import_0["default"].hasOwnProp(obj, key)) {
23927
+ dest = obj[key];
23928
+ obj[key] = _utils_js__rspack_import_0["default"].isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
23929
+ } else {
23930
+ obj[key] = entry[1];
23931
+ }
23761
23932
  }
23762
23933
 
23763
23934
  setHeaders(obj, valueOrRewrite);
@@ -24074,12 +24245,39 @@ __webpack_require__.d(__webpack_exports__, {
24074
24245
  8262(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
24075
24246
  "use strict";
24076
24247
  __webpack_require__.r(__webpack_exports__);
24077
- /* import */ var _helpers_isAbsoluteURL_js__rspack_import_0 = __webpack_require__(9034);
24078
- /* import */ var _helpers_combineURLs_js__rspack_import_1 = __webpack_require__(6787);
24248
+ /* import */ var _AxiosError_js__rspack_import_0 = __webpack_require__(4062);
24249
+ /* import */ var _helpers_isAbsoluteURL_js__rspack_import_1 = __webpack_require__(9034);
24250
+ /* import */ var _helpers_combineURLs_js__rspack_import_2 = __webpack_require__(6787);
24251
+
24252
+
24253
+
24254
+
24079
24255
 
24080
24256
 
24257
+ const malformedHttpProtocol = /^https?:(?!\/\/)/i;
24258
+ const httpProtocolControlCharacters = /[\t\n\r]/g;
24081
24259
 
24260
+ function stripLeadingC0ControlOrSpace(url) {
24261
+ let i = 0;
24262
+ while (i < url.length && url.charCodeAt(i) <= 0x20) {
24263
+ i++;
24264
+ }
24265
+ return url.slice(i);
24266
+ }
24267
+
24268
+ function normalizeURLForProtocolCheck(url) {
24269
+ return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
24270
+ }
24082
24271
 
24272
+ function assertValidHttpProtocolURL(url, config) {
24273
+ if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
24274
+ throw new _AxiosError_js__rspack_import_0["default"](
24275
+ 'Invalid URL: missing "//" after protocol',
24276
+ _AxiosError_js__rspack_import_0["default"].ERR_INVALID_URL,
24277
+ config
24278
+ );
24279
+ }
24280
+ }
24083
24281
 
24084
24282
  /**
24085
24283
  * Creates a new URL by combining the baseURL with the requestedURL,
@@ -24091,10 +24289,12 @@ __webpack_require__.r(__webpack_exports__);
24091
24289
  *
24092
24290
  * @returns {string} The combined full path
24093
24291
  */
24094
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
24095
- let isRelativeUrl = !(0,_helpers_isAbsoluteURL_js__rspack_import_0["default"])(requestedURL);
24292
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
24293
+ assertValidHttpProtocolURL(requestedURL, config);
24294
+ let isRelativeUrl = !(0,_helpers_isAbsoluteURL_js__rspack_import_1["default"])(requestedURL);
24096
24295
  if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
24097
- return (0,_helpers_combineURLs_js__rspack_import_1["default"])(baseURL, requestedURL);
24296
+ assertValidHttpProtocolURL(baseURL, config);
24297
+ return (0,_helpers_combineURLs_js__rspack_import_2["default"])(baseURL, requestedURL);
24098
24298
  }
24099
24299
  return requestedURL;
24100
24300
  }
@@ -24285,6 +24485,28 @@ function mergeConfig(config1, config2) {
24285
24485
  }
24286
24486
  }
24287
24487
 
24488
+ function getMergedTransitionalOption(prop) {
24489
+ const transitional2 = _utils_js__rspack_import_1["default"].hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
24490
+
24491
+ if (!_utils_js__rspack_import_1["default"].isUndefined(transitional2)) {
24492
+ if (_utils_js__rspack_import_1["default"].isPlainObject(transitional2)) {
24493
+ if (_utils_js__rspack_import_1["default"].hasOwnProp(transitional2, prop)) {
24494
+ return transitional2[prop];
24495
+ }
24496
+ } else {
24497
+ return undefined;
24498
+ }
24499
+ }
24500
+
24501
+ const transitional1 = _utils_js__rspack_import_1["default"].hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
24502
+
24503
+ if (_utils_js__rspack_import_1["default"].isPlainObject(transitional1) && _utils_js__rspack_import_1["default"].hasOwnProp(transitional1, prop)) {
24504
+ return transitional1[prop];
24505
+ }
24506
+
24507
+ return undefined;
24508
+ }
24509
+
24288
24510
  // eslint-disable-next-line consistent-return
24289
24511
  function mergeDirectKeys(a, b, prop) {
24290
24512
  if (_utils_js__rspack_import_1["default"].hasOwnProp(config2, prop)) {
@@ -24337,6 +24559,18 @@ function mergeConfig(config1, config2) {
24337
24559
  (_utils_js__rspack_import_1["default"].isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
24338
24560
  });
24339
24561
 
24562
+ if (
24563
+ _utils_js__rspack_import_1["default"].hasOwnProp(config2, 'validateStatus') &&
24564
+ _utils_js__rspack_import_1["default"].isUndefined(config2.validateStatus) &&
24565
+ getMergedTransitionalOption('validateStatusUndefinedResolves') === false
24566
+ ) {
24567
+ if (_utils_js__rspack_import_1["default"].hasOwnProp(config1, 'validateStatus')) {
24568
+ config.validateStatus = getMergedValue(undefined, config1.validateStatus);
24569
+ } else {
24570
+ delete config.validateStatus;
24571
+ }
24572
+ }
24573
+
24340
24574
  return config;
24341
24575
  }
24342
24576
 
@@ -24631,6 +24865,7 @@ __webpack_require__.r(__webpack_exports__);
24631
24865
  clarifyTimeoutError: false,
24632
24866
  legacyInterceptorReqResOrdering: true,
24633
24867
  advertiseZstdAcceptEncoding: false,
24868
+ validateStatusUndefinedResolves: true,
24634
24869
  });
24635
24870
 
24636
24871
  __webpack_require__.d(__webpack_exports__, {
@@ -24643,7 +24878,7 @@ __webpack_require__.d(__webpack_exports__, {
24643
24878
  9888(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
24644
24879
  "use strict";
24645
24880
  __webpack_require__.r(__webpack_exports__);
24646
- const VERSION = "1.17.0";
24881
+ const VERSION = "1.18.0";
24647
24882
  __webpack_require__.d(__webpack_exports__, {
24648
24883
  }, {
24649
24884
  VERSION: VERSION
@@ -24876,15 +25111,17 @@ function buildURL(url, params, options) {
24876
25111
  return url;
24877
25112
  }
24878
25113
 
24879
- const _encode = (options && options.encode) || encode;
24880
-
24881
25114
  const _options = _utils_js__rspack_import_0["default"].isFunction(options)
24882
25115
  ? {
24883
25116
  serialize: options,
24884
25117
  }
24885
25118
  : options;
24886
25119
 
24887
- const serializeFn = _options && _options.serialize;
25120
+ // Read serializer options pollution-safely: own properties and methods on a
25121
+ // class/template prototype are honored, but values injected onto a polluted
25122
+ // Object.prototype are ignored.
25123
+ const _encode = _utils_js__rspack_import_0["default"].getSafeProp(_options, 'encode') || encode;
25124
+ const serializeFn = _utils_js__rspack_import_0["default"].getSafeProp(_options, 'serialize');
24888
25125
 
24889
25126
  let serializedParams;
24890
25127
 
@@ -25087,16 +25324,23 @@ __webpack_require__.d(__webpack_exports__, {
25087
25324
  1526(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
25088
25325
  "use strict";
25089
25326
  __webpack_require__.r(__webpack_exports__);
25090
- /* provided dependency */ var Buffer = __webpack_require__(8287).Buffer;
25091
25327
  /**
25092
25328
  * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
25093
25329
  * - For base64: compute exact decoded size using length and padding;
25094
25330
  * handle %XX at the character-count level (no string allocation).
25095
- * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
25331
+ * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
25096
25332
  *
25097
25333
  * @param {string} url
25098
25334
  * @returns {number}
25099
25335
  */
25336
+ const isHexDigit = (charCode) =>
25337
+ (charCode >= 48 && charCode <= 57) ||
25338
+ (charCode >= 65 && charCode <= 70) ||
25339
+ (charCode >= 97 && charCode <= 102);
25340
+
25341
+ const isPercentEncodedByte = (str, i, len) =>
25342
+ i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
25343
+
25100
25344
  function estimateDataURLDecodedBytes(url) {
25101
25345
  if (!url || typeof url !== 'string') return 0;
25102
25346
  if (!url.startsWith('data:')) return 0;
@@ -25116,9 +25360,7 @@ function estimateDataURLDecodedBytes(url) {
25116
25360
  if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
25117
25361
  const a = body.charCodeAt(i + 1);
25118
25362
  const b = body.charCodeAt(i + 2);
25119
- const isHex =
25120
- ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
25121
- ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
25363
+ const isHex = isHexDigit(a) && isHexDigit(b);
25122
25364
 
25123
25365
  if (isHex) {
25124
25366
  effectiveLen -= 2;
@@ -25159,18 +25401,17 @@ function estimateDataURLDecodedBytes(url) {
25159
25401
  return bytes > 0 ? bytes : 0;
25160
25402
  }
25161
25403
 
25162
- if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
25163
- return Buffer.byteLength(body, 'utf8');
25164
- }
25165
-
25166
25404
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
25167
25405
  // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
25168
- // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
25169
- // but 3 UTF-8 bytes).
25406
+ // Valid %XX triplets count as one decoded byte; this matches the bytes that
25407
+ // decodeURIComponent(body) would produce before Buffer re-encodes the string.
25170
25408
  let bytes = 0;
25171
25409
  for (let i = 0, len = body.length; i < len; i++) {
25172
25410
  const c = body.charCodeAt(i);
25173
- if (c < 0x80) {
25411
+ if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
25412
+ bytes += 1;
25413
+ i += 2;
25414
+ } else if (c < 0x80) {
25174
25415
  bytes += 1;
25175
25416
  } else if (c < 0x800) {
25176
25417
  bytes += 2;
@@ -25198,11 +25439,26 @@ __webpack_require__.d(__webpack_exports__, {
25198
25439
  7887(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
25199
25440
  "use strict";
25200
25441
  __webpack_require__.r(__webpack_exports__);
25201
- /* import */ var _utils_js__rspack_import_0 = __webpack_require__(7275);
25442
+ /* import */ var _utils_js__rspack_import_2 = __webpack_require__(7275);
25443
+ /* import */ var _core_AxiosError_js__rspack_import_1 = __webpack_require__(4062);
25444
+ /* import */ var _toFormData_js__rspack_import_0 = __webpack_require__(665);
25445
+
25446
+
25202
25447
 
25203
25448
 
25204
25449
 
25205
25450
 
25451
+ const MAX_DEPTH = _toFormData_js__rspack_import_0.DEFAULT_FORM_DATA_MAX_DEPTH;
25452
+
25453
+ function throwIfDepthExceeded(index) {
25454
+ if (index > MAX_DEPTH) {
25455
+ throw new _core_AxiosError_js__rspack_import_1["default"](
25456
+ 'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
25457
+ _core_AxiosError_js__rspack_import_1["default"].ERR_FORM_DATA_DEPTH_EXCEEDED
25458
+ );
25459
+ }
25460
+ }
25461
+
25206
25462
  /**
25207
25463
  * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
25208
25464
  *
@@ -25215,9 +25471,16 @@ function parsePropPath(name) {
25215
25471
  // foo.x.y.z
25216
25472
  // foo-x-y-z
25217
25473
  // foo x y z
25218
- return _utils_js__rspack_import_0["default"].matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
25219
- return match[0] === '[]' ? '' : match[1] || match[0];
25220
- });
25474
+ const path = [];
25475
+ const pattern = /\w+|\[(\w*)]/g;
25476
+ let match;
25477
+
25478
+ while ((match = pattern.exec(name)) !== null) {
25479
+ throwIfDepthExceeded(path.length);
25480
+ path.push(match[0] === '[]' ? '' : match[1] || match[0]);
25481
+ }
25482
+
25483
+ return path;
25221
25484
  }
25222
25485
 
25223
25486
  /**
@@ -25249,17 +25512,19 @@ function arrayToObject(arr) {
25249
25512
  */
25250
25513
  function formDataToJSON(formData) {
25251
25514
  function buildPath(path, value, target, index) {
25515
+ throwIfDepthExceeded(index);
25516
+
25252
25517
  let name = path[index++];
25253
25518
 
25254
25519
  if (name === '__proto__') return true;
25255
25520
 
25256
25521
  const isNumericKey = Number.isFinite(+name);
25257
25522
  const isLast = index >= path.length;
25258
- name = !name && _utils_js__rspack_import_0["default"].isArray(target) ? target.length : name;
25523
+ name = !name && _utils_js__rspack_import_2["default"].isArray(target) ? target.length : name;
25259
25524
 
25260
25525
  if (isLast) {
25261
- if (_utils_js__rspack_import_0["default"].hasOwnProp(target, name)) {
25262
- target[name] = _utils_js__rspack_import_0["default"].isArray(target[name])
25526
+ if (_utils_js__rspack_import_2["default"].hasOwnProp(target, name)) {
25527
+ target[name] = _utils_js__rspack_import_2["default"].isArray(target[name])
25263
25528
  ? target[name].concat(value)
25264
25529
  : [target[name], value];
25265
25530
  } else {
@@ -25269,23 +25534,23 @@ function formDataToJSON(formData) {
25269
25534
  return !isNumericKey;
25270
25535
  }
25271
25536
 
25272
- if (!_utils_js__rspack_import_0["default"].hasOwnProp(target, name) || !_utils_js__rspack_import_0["default"].isObject(target[name])) {
25537
+ if (!_utils_js__rspack_import_2["default"].hasOwnProp(target, name) || !_utils_js__rspack_import_2["default"].isObject(target[name])) {
25273
25538
  target[name] = [];
25274
25539
  }
25275
25540
 
25276
25541
  const result = buildPath(path, value, target[name], index);
25277
25542
 
25278
- if (result && _utils_js__rspack_import_0["default"].isArray(target[name])) {
25543
+ if (result && _utils_js__rspack_import_2["default"].isArray(target[name])) {
25279
25544
  target[name] = arrayToObject(target[name]);
25280
25545
  }
25281
25546
 
25282
25547
  return !isNumericKey;
25283
25548
  }
25284
25549
 
25285
- if (_utils_js__rspack_import_0["default"].isFormData(formData) && _utils_js__rspack_import_0["default"].isFunction(formData.entries)) {
25550
+ if (_utils_js__rspack_import_2["default"].isFormData(formData) && _utils_js__rspack_import_2["default"].isFunction(formData.entries)) {
25286
25551
  const obj = {};
25287
25552
 
25288
- _utils_js__rspack_import_0["default"].forEachEntry(formData, (name, value) => {
25553
+ _utils_js__rspack_import_2["default"].forEachEntry(formData, (name, value) => {
25289
25554
  buildPath(parsePropPath(name), value, obj, 0);
25290
25555
  });
25291
25556
 
@@ -25634,17 +25899,19 @@ function resolveConfig(config) {
25634
25899
  newConfig.headers = headers = _core_AxiosHeaders_js__rspack_import_2["default"].from(headers);
25635
25900
 
25636
25901
  newConfig.url = (0,_buildURL_js__rspack_import_3["default"])(
25637
- (0,_core_buildFullPath_js__rspack_import_4["default"])(baseURL, url, allowAbsoluteUrls),
25902
+ (0,_core_buildFullPath_js__rspack_import_4["default"])(baseURL, url, allowAbsoluteUrls, newConfig),
25638
25903
  own('params'),
25639
25904
  own('paramsSerializer')
25640
25905
  );
25641
25906
 
25642
25907
  // HTTP basic authentication
25643
25908
  if (auth) {
25909
+ const username = _utils_js__rspack_import_1["default"].getSafeProp(auth, 'username') || '';
25910
+ const password = _utils_js__rspack_import_1["default"].getSafeProp(auth, 'password') || '';
25911
+
25644
25912
  headers.set(
25645
25913
  'Authorization',
25646
- 'Basic ' +
25647
- btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
25914
+ 'Basic ' + btoa(username + ':' + (password ? encodeUTF8(password) : ''))
25648
25915
  );
25649
25916
  }
25650
25917
 
@@ -25944,6 +26211,10 @@ __webpack_require__.r(__webpack_exports__);
25944
26211
  // temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored
25945
26212
 
25946
26213
 
26214
+ // Default nesting limit shared with the inverse transform (formDataToJSON) so
26215
+ // the FormData <-> JSON round-trip stays symmetric.
26216
+ const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
26217
+
25947
26218
  /**
25948
26219
  * Determines if the given thing is a array or js object.
25949
26220
  *
@@ -26054,8 +26325,9 @@ function toFormData(obj, formData, options) {
26054
26325
  const dots = options.dots;
26055
26326
  const indexes = options.indexes;
26056
26327
  const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
26057
- const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
26328
+ const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
26058
26329
  const useBlob = _Blob && _utils_js__rspack_import_0["default"].isSpecCompliantForm(formData);
26330
+ const stack = [];
26059
26331
 
26060
26332
  if (!_utils_js__rspack_import_0["default"].isFunction(visitor)) {
26061
26333
  throw new TypeError('visitor must be a function');
@@ -26083,6 +26355,38 @@ function toFormData(obj, formData, options) {
26083
26355
  return value;
26084
26356
  }
26085
26357
 
26358
+ function throwIfMaxDepthExceeded(depth) {
26359
+ if (depth > maxDepth) {
26360
+ throw new _core_AxiosError_js__rspack_import_2["default"](
26361
+ 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
26362
+ _core_AxiosError_js__rspack_import_2["default"].ERR_FORM_DATA_DEPTH_EXCEEDED
26363
+ );
26364
+ }
26365
+ }
26366
+
26367
+ function stringifyWithDepthLimit(value, depth) {
26368
+ if (maxDepth === Infinity) {
26369
+ return JSON.stringify(value);
26370
+ }
26371
+
26372
+ const ancestors = [];
26373
+
26374
+ return JSON.stringify(value, function limitDepth(_key, currentValue) {
26375
+ if (!_utils_js__rspack_import_0["default"].isObject(currentValue)) {
26376
+ return currentValue;
26377
+ }
26378
+
26379
+ while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
26380
+ ancestors.pop();
26381
+ }
26382
+
26383
+ ancestors.push(currentValue);
26384
+ throwIfMaxDepthExceeded(depth + ancestors.length - 1);
26385
+
26386
+ return currentValue;
26387
+ });
26388
+ }
26389
+
26086
26390
  /**
26087
26391
  * Default visitor.
26088
26392
  *
@@ -26106,7 +26410,7 @@ function toFormData(obj, formData, options) {
26106
26410
  // eslint-disable-next-line no-param-reassign
26107
26411
  key = metaTokens ? key : key.slice(0, -2);
26108
26412
  // eslint-disable-next-line no-param-reassign
26109
- value = JSON.stringify(value);
26413
+ value = stringifyWithDepthLimit(value, 1);
26110
26414
  } else if (
26111
26415
  (_utils_js__rspack_import_0["default"].isArray(value) && isFlatArray(value)) ||
26112
26416
  ((_utils_js__rspack_import_0["default"].isFileList(value) || _utils_js__rspack_import_0["default"].endsWith(key, '[]')) && (arr = _utils_js__rspack_import_0["default"].toArray(value)))
@@ -26139,8 +26443,6 @@ function toFormData(obj, formData, options) {
26139
26443
  return false;
26140
26444
  }
26141
26445
 
26142
- const stack = [];
26143
-
26144
26446
  const exposedHelpers = Object.assign(predicates, {
26145
26447
  defaultVisitor,
26146
26448
  convertValue,
@@ -26150,12 +26452,7 @@ function toFormData(obj, formData, options) {
26150
26452
  function build(value, path, depth = 0) {
26151
26453
  if (_utils_js__rspack_import_0["default"].isUndefined(value)) return;
26152
26454
 
26153
- if (depth > maxDepth) {
26154
- throw new _core_AxiosError_js__rspack_import_2["default"](
26155
- 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
26156
- _core_AxiosError_js__rspack_import_2["default"].ERR_FORM_DATA_DEPTH_EXCEEDED
26157
- );
26158
- }
26455
+ throwIfMaxDepthExceeded(depth);
26159
26456
 
26160
26457
  if (stack.indexOf(value) !== -1) {
26161
26458
  throw new Error('Circular reference detected in ' + path.join('.'));
@@ -26189,6 +26486,7 @@ function toFormData(obj, formData, options) {
26189
26486
 
26190
26487
  __webpack_require__.d(__webpack_exports__, {
26191
26488
  }, {
26489
+ DEFAULT_FORM_DATA_MAX_DEPTH: DEFAULT_FORM_DATA_MAX_DEPTH,
26192
26490
  "default": __rspack_default_export
26193
26491
  });
26194
26492
 
@@ -26620,6 +26918,57 @@ const { toString } = Object.prototype;
26620
26918
  const { getPrototypeOf } = Object;
26621
26919
  const { iterator, toStringTag } = Symbol;
26622
26920
 
26921
+ /* Creating a function that will check if an object has a property. */
26922
+ const hasOwnProperty = (
26923
+ ({ hasOwnProperty }) =>
26924
+ (obj, prop) =>
26925
+ hasOwnProperty.call(obj, prop)
26926
+ )(Object.prototype);
26927
+
26928
+ /**
26929
+ * Walk the prototype chain (excluding the shared Object.prototype) looking for
26930
+ * an own `prop`. This distinguishes genuine own/inherited members — including
26931
+ * class accessors and template prototypes — from members injected via
26932
+ * Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
26933
+ * live on Object.prototype itself and are therefore never matched.
26934
+ *
26935
+ * @param {*} thing The value whose chain to inspect
26936
+ * @param {string|symbol} prop The property key to look for
26937
+ *
26938
+ * @returns {boolean} True when `prop` is owned below Object.prototype
26939
+ */
26940
+ const hasOwnInPrototypeChain = (thing, prop) => {
26941
+ let obj = thing;
26942
+ const seen = [];
26943
+
26944
+ while (obj != null && obj !== Object.prototype) {
26945
+ if (seen.indexOf(obj) !== -1) {
26946
+ return false;
26947
+ }
26948
+ seen.push(obj);
26949
+
26950
+ if (hasOwnProperty(obj, prop)) {
26951
+ return true;
26952
+ }
26953
+ obj = getPrototypeOf(obj);
26954
+ }
26955
+ return false;
26956
+ };
26957
+
26958
+ /**
26959
+ * Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
26960
+ * properties and members inherited from a non-Object.prototype source (a class
26961
+ * instance or template object) are honored; a value reachable only through a
26962
+ * polluted Object.prototype is ignored and `undefined` is returned.
26963
+ *
26964
+ * @param {*} obj The source object
26965
+ * @param {string|symbol} prop The property key to read
26966
+ *
26967
+ * @returns {*} The resolved value, or undefined when unsafe/absent
26968
+ */
26969
+ const getSafeProp = (obj, prop) =>
26970
+ obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
26971
+
26623
26972
  const kindOf = ((cache) => (thing) => {
26624
26973
  const str = toString.call(thing);
26625
26974
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -26745,7 +27094,7 @@ const isBoolean = (thing) => thing === true || thing === false;
26745
27094
  * @returns {boolean} True if value is a plain Object, otherwise false
26746
27095
  */
26747
27096
  const isPlainObject = (val) => {
26748
- if (kindOf(val) !== 'object') {
27097
+ if (!isObject(val)) {
26749
27098
  return false;
26750
27099
  }
26751
27100
 
@@ -26753,9 +27102,12 @@ const isPlainObject = (val) => {
26753
27102
  return (
26754
27103
  (prototype === null ||
26755
27104
  prototype === Object.prototype ||
26756
- Object.getPrototypeOf(prototype) === null) &&
26757
- !(toStringTag in val) &&
26758
- !(iterator in val)
27105
+ getPrototypeOf(prototype) === null) &&
27106
+ // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
27107
+ // Symbol.iterator as evidence the value is a tagged/iterable type rather
27108
+ // than a plain object, while ignoring keys injected onto Object.prototype.
27109
+ !hasOwnInPrototypeChain(val, toStringTag) &&
27110
+ !hasOwnInPrototypeChain(val, iterator)
26759
27111
  );
26760
27112
  };
26761
27113
 
@@ -27282,13 +27634,6 @@ const toCamelCase = (str) => {
27282
27634
  });
27283
27635
  };
27284
27636
 
27285
- /* Creating a function that will check if an object has a property. */
27286
- const hasOwnProperty = (
27287
- ({ hasOwnProperty }) =>
27288
- (obj, prop) =>
27289
- hasOwnProperty.call(obj, prop)
27290
- )(Object.prototype);
27291
-
27292
27637
  const { propertyIsEnumerable } = Object.prototype;
27293
27638
 
27294
27639
  /**
@@ -27502,6 +27847,20 @@ const asap =
27502
27847
 
27503
27848
  const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
27504
27849
 
27850
+ /**
27851
+ * Determine if a value is iterable via an iterator that is NOT sourced solely
27852
+ * from a polluted Object.prototype. Use this instead of `isIterable` whenever
27853
+ * the iterable comes from untrusted input (e.g. user-supplied header sources),
27854
+ * so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
27855
+ * into an attacker-controlled entries iterator.
27856
+ *
27857
+ * @param {*} thing The value to test
27858
+ *
27859
+ * @returns {boolean} True if value has a non-polluted iterator
27860
+ */
27861
+ const isSafeIterable = (thing) =>
27862
+ thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
27863
+
27505
27864
  /* export default */ const __rspack_default_export = ({
27506
27865
  isArray,
27507
27866
  isArrayBuffer,
@@ -27546,6 +27905,8 @@ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
27546
27905
  isHTMLForm,
27547
27906
  hasOwnProperty,
27548
27907
  hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
27908
+ hasOwnInPrototypeChain,
27909
+ getSafeProp,
27549
27910
  reduceDescriptors,
27550
27911
  freezeMethods,
27551
27912
  toObjectSet,
@@ -27562,6 +27923,7 @@ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
27562
27923
  setImmediate: _setImmediate,
27563
27924
  asap,
27564
27925
  isIterable,
27926
+ isSafeIterable,
27565
27927
  });
27566
27928
 
27567
27929
  __webpack_require__.d(__webpack_exports__, {