@postman-cs/onboarding-repo-sync 2.9.3 → 2.10.1

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/cli.cjs CHANGED
@@ -332,6 +332,7 @@ var require_symbols = __commonJS({
332
332
  kCounter: /* @__PURE__ */ Symbol("socket request counter"),
333
333
  kMaxResponseSize: /* @__PURE__ */ Symbol("max response size"),
334
334
  kHTTP2Session: /* @__PURE__ */ Symbol("http2Session"),
335
+ kHTTP2Options: /* @__PURE__ */ Symbol("http2 options"),
335
336
  kHTTP2SessionState: /* @__PURE__ */ Symbol("http2Session state"),
336
337
  kRetryHandlerDefaultRetry: /* @__PURE__ */ Symbol("retry agent default retry"),
337
338
  kConstruct: /* @__PURE__ */ Symbol("constructable"),
@@ -1378,14 +1379,14 @@ var require_util = __commonJS({
1378
1379
  }
1379
1380
  const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
1380
1381
  let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
1381
- let path5 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
1382
+ let path6 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
1382
1383
  if (origin[origin.length - 1] === "/") {
1383
1384
  origin = origin.slice(0, origin.length - 1);
1384
1385
  }
1385
- if (path5 && path5[0] !== "/") {
1386
- path5 = `/${path5}`;
1386
+ if (path6 && path6[0] !== "/") {
1387
+ path6 = `/${path6}`;
1387
1388
  }
1388
- return new URL(`${origin}${path5}`);
1389
+ return new URL(`${origin}${path6}`);
1389
1390
  }
1390
1391
  if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
1391
1392
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -2256,9 +2257,9 @@ var require_diagnostics = __commonJS({
2256
2257
  "undici:client:sendHeaders",
2257
2258
  (evt) => {
2258
2259
  const {
2259
- request: { method, path: path5, origin }
2260
+ request: { method, path: path6, origin }
2260
2261
  } = evt;
2261
- debugLog("sending request to %s %s%s", method, origin, path5);
2262
+ debugLog("sending request to %s %s%s", method, origin, path6);
2262
2263
  }
2263
2264
  );
2264
2265
  }
@@ -2276,14 +2277,14 @@ var require_diagnostics = __commonJS({
2276
2277
  "undici:request:headers",
2277
2278
  (evt) => {
2278
2279
  const {
2279
- request: { method, path: path5, origin },
2280
+ request: { method, path: path6, origin },
2280
2281
  response: { statusCode }
2281
2282
  } = evt;
2282
2283
  debugLog(
2283
2284
  "received response to %s %s%s - HTTP %d",
2284
2285
  method,
2285
2286
  origin,
2286
- path5,
2287
+ path6,
2287
2288
  statusCode
2288
2289
  );
2289
2290
  }
@@ -2292,23 +2293,23 @@ var require_diagnostics = __commonJS({
2292
2293
  "undici:request:trailers",
2293
2294
  (evt) => {
2294
2295
  const {
2295
- request: { method, path: path5, origin }
2296
+ request: { method, path: path6, origin }
2296
2297
  } = evt;
2297
- debugLog("trailers received from %s %s%s", method, origin, path5);
2298
+ debugLog("trailers received from %s %s%s", method, origin, path6);
2298
2299
  }
2299
2300
  );
2300
2301
  diagnosticsChannel.subscribe(
2301
2302
  "undici:request:error",
2302
2303
  (evt) => {
2303
2304
  const {
2304
- request: { method, path: path5, origin },
2305
+ request: { method, path: path6, origin },
2305
2306
  error
2306
2307
  } = evt;
2307
2308
  debugLog(
2308
2309
  "request to %s %s%s errored - %s",
2309
2310
  method,
2310
2311
  origin,
2311
- path5,
2312
+ path6,
2312
2313
  error.message
2313
2314
  );
2314
2315
  }
@@ -2461,9 +2462,9 @@ var require_request = __commonJS({
2461
2462
  return this.#paused;
2462
2463
  }
2463
2464
  };
2464
- var Request = class {
2465
+ var Request2 = class {
2465
2466
  constructor(origin, {
2466
- path: path5,
2467
+ path: path6,
2467
2468
  method,
2468
2469
  body,
2469
2470
  headers,
@@ -2480,11 +2481,11 @@ var require_request = __commonJS({
2480
2481
  maxRedirections,
2481
2482
  typeOfService
2482
2483
  }, handler) {
2483
- if (typeof path5 !== "string") {
2484
+ if (typeof path6 !== "string") {
2484
2485
  throw new InvalidArgumentError("path must be a string");
2485
- } else if (path5[0] !== "/" && !(path5.startsWith("http://") || path5.startsWith("https://")) && method !== "CONNECT") {
2486
+ } else if (path6[0] !== "/" && !(path6.startsWith("http://") || path6.startsWith("https://")) && method !== "CONNECT") {
2486
2487
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
2487
- } else if (invalidPathRegex.test(path5)) {
2488
+ } else if (invalidPathRegex.test(path6)) {
2488
2489
  throw new InvalidArgumentError("invalid request path");
2489
2490
  }
2490
2491
  if (typeof method !== "string") {
@@ -2559,7 +2560,7 @@ var require_request = __commonJS({
2559
2560
  this.completed = false;
2560
2561
  this.aborted = false;
2561
2562
  this.upgrade = upgrade || null;
2562
- this.path = query ? serializePathWithQuery(path5, query) : path5;
2563
+ this.path = query ? serializePathWithQuery(path6, query) : path6;
2563
2564
  this.origin = origin;
2564
2565
  this.protocol = getProtocolFromUrlString(origin);
2565
2566
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" || method === "QUERY" : idempotent;
@@ -2756,7 +2757,11 @@ var require_request = __commonJS({
2756
2757
  } else if (typeof val[i] === "object") {
2757
2758
  throw new InvalidArgumentError(`invalid ${key} header`);
2758
2759
  } else {
2759
- arr.push(`${val[i]}`);
2760
+ const str = `${val[i]}`;
2761
+ if (!isValidHeaderValue(str)) {
2762
+ throw new InvalidArgumentError(`invalid ${key} header`);
2763
+ }
2764
+ arr.push(str);
2760
2765
  }
2761
2766
  }
2762
2767
  val = arr;
@@ -2768,6 +2773,9 @@ var require_request = __commonJS({
2768
2773
  val = "";
2769
2774
  } else {
2770
2775
  val = `${val}`;
2776
+ if (!isValidHeaderValue(val)) {
2777
+ throw new InvalidArgumentError(`invalid ${key} header`);
2778
+ }
2771
2779
  }
2772
2780
  if (headerName === "host") {
2773
2781
  if (request.host !== null) {
@@ -2810,7 +2818,7 @@ var require_request = __commonJS({
2810
2818
  request.headers.push(key, val);
2811
2819
  }
2812
2820
  }
2813
- module2.exports = Request;
2821
+ module2.exports = Request2;
2814
2822
  }
2815
2823
  });
2816
2824
 
@@ -3093,14 +3101,26 @@ var require_connect = __commonJS({
3093
3101
  } else {
3094
3102
  assert(!httpSocket, "httpSocket can only be sent on TLS update");
3095
3103
  port = port || 80;
3096
- socket = net.connect({
3104
+ const connectOptions = {
3097
3105
  highWaterMark: 64 * 1024,
3098
3106
  // Same as nodejs fs streams.
3099
3107
  ...options,
3100
3108
  localAddress,
3101
3109
  port,
3102
3110
  host: hostname
3103
- });
3111
+ };
3112
+ const family = net.isIP(hostname);
3113
+ if (family !== 0 && servername && servername !== hostname) {
3114
+ connectOptions.host = servername;
3115
+ connectOptions.lookup = (_hostname, lookupOptions, cb) => {
3116
+ if (lookupOptions.all) {
3117
+ cb(null, [{ address: hostname, family }]);
3118
+ } else {
3119
+ cb(null, hostname, family);
3120
+ }
3121
+ };
3122
+ }
3123
+ socket = net.connect(connectOptions);
3104
3124
  if (useH2c === true) {
3105
3125
  socket.alpnProtocol = "h2";
3106
3126
  }
@@ -6753,6 +6773,7 @@ var require_client_h1 = __commonJS({
6753
6773
  RequestContentLengthMismatchError,
6754
6774
  ResponseContentLengthMismatchError,
6755
6775
  RequestAbortedError,
6776
+ InvalidArgumentError,
6756
6777
  HeadersTimeoutError,
6757
6778
  HeadersOverflowError,
6758
6779
  SocketError,
@@ -7539,20 +7560,20 @@ var require_client_h1 = __commonJS({
7539
7560
  }
7540
7561
  function clearIdleSocketValidation(socket) {
7541
7562
  if (socket[kIdleSocketValidationTimeout]) {
7542
- clearImmediate(socket[kIdleSocketValidationTimeout]);
7563
+ clearTimeout(socket[kIdleSocketValidationTimeout]);
7543
7564
  socket[kIdleSocketValidationTimeout] = null;
7544
7565
  }
7545
7566
  socket[kIdleSocketValidation] = 0;
7546
7567
  }
7547
7568
  function scheduleIdleSocketValidation(client, socket) {
7548
7569
  socket[kIdleSocketValidation] = 1;
7549
- socket[kIdleSocketValidationTimeout] = setImmediate(() => {
7570
+ socket[kIdleSocketValidationTimeout] = setTimeout(() => {
7550
7571
  socket[kIdleSocketValidationTimeout] = null;
7551
7572
  socket[kIdleSocketValidation] = 2;
7552
7573
  if (client[kSocket] === socket && !socket.destroyed) {
7553
7574
  client[kResume]();
7554
7575
  }
7555
- });
7576
+ }, 0);
7556
7577
  socket[kIdleSocketValidationTimeout].unref?.();
7557
7578
  }
7558
7579
  function resumeH1(client) {
@@ -7625,7 +7646,7 @@ var require_client_h1 = __commonJS({
7625
7646
  }
7626
7647
  }
7627
7648
  function writeH1(client, request) {
7628
- const { method, path: path5, host, upgrade, blocking, reset } = request;
7649
+ const { method, path: path6, host, upgrade, blocking, reset } = request;
7629
7650
  let { body, headers, contentLength } = request;
7630
7651
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
7631
7652
  if (util.isFormDataLike(body)) {
@@ -7638,8 +7659,16 @@ var require_client_h1 = __commonJS({
7638
7659
  }
7639
7660
  body = bodyStream.stream;
7640
7661
  contentLength = bodyStream.length;
7641
- } else if (util.isBlobLike(body) && request.contentType == null && body.type) {
7642
- headers.push("content-type", body.type);
7662
+ } else if (util.isBlobLike(body) && request.contentType == null) {
7663
+ const contentType = body.type;
7664
+ if (contentType) {
7665
+ const contentTypeValue = `${contentType}`;
7666
+ if (!util.isValidHeaderValue(contentTypeValue)) {
7667
+ util.errorRequest(client, request, new InvalidArgumentError("invalid content-type header"));
7668
+ return false;
7669
+ }
7670
+ headers.push("content-type", contentTypeValue);
7671
+ }
7643
7672
  }
7644
7673
  if (body && typeof body.read === "function") {
7645
7674
  body.read(0);
@@ -7693,7 +7722,7 @@ var require_client_h1 = __commonJS({
7693
7722
  socket[kBlocking] = true;
7694
7723
  }
7695
7724
  setTypeOfService(socket, request);
7696
- let header = `${method} ${path5} HTTP/1.1\r
7725
+ let header = `${method} ${path6} HTTP/1.1\r
7697
7726
  `;
7698
7727
  if (typeof host === "string") {
7699
7728
  header += `host: ${host}\r
@@ -8068,10 +8097,7 @@ var require_client_h2 = __commonJS({
8068
8097
  kStrictContentLength,
8069
8098
  kOnError,
8070
8099
  kMaxConcurrentStreams,
8071
- kPingInterval,
8072
8100
  kHTTP2Session,
8073
- kHTTP2InitialWindowSize,
8074
- kHTTP2ConnectionWindowSize,
8075
8101
  kHostAuthority,
8076
8102
  kResume,
8077
8103
  kSize,
@@ -8083,7 +8109,8 @@ var require_client_h2 = __commonJS({
8083
8109
  kEnableConnectProtocol,
8084
8110
  kRemoteSettings,
8085
8111
  kHTTP2Stream,
8086
- kHTTP2SessionState
8112
+ kHTTP2SessionState,
8113
+ kHTTP2Options
8087
8114
  } = require_symbols();
8088
8115
  var { channels } = require_diagnostics();
8089
8116
  var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
@@ -8092,6 +8119,9 @@ var require_client_h2 = __commonJS({
8092
8119
  var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
8093
8120
  var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
8094
8121
  var kReceivedGoAway = /* @__PURE__ */ Symbol("received goaway");
8122
+ var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
8123
+ var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
8124
+ var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
8095
8125
  var extractBody;
8096
8126
  var http2;
8097
8127
  try {
@@ -8189,10 +8219,15 @@ var require_client_h2 = __commonJS({
8189
8219
  client[kPendingIdx] = client[kRunningIdx];
8190
8220
  }
8191
8221
  }
8192
- function canRetryRequestAfterGoAway(request) {
8222
+ function canReplayRequest(request) {
8193
8223
  const { body } = request;
8194
8224
  return body == null || util.isBuffer(body) || util.isBlobLike(body);
8195
8225
  }
8226
+ function registerGoAwayRefusal(request) {
8227
+ const attempts = (request[kGoAwayReplayAttempts] ?? 0) + 1;
8228
+ request[kGoAwayReplayAttempts] = attempts;
8229
+ return attempts <= MAX_GOAWAY_REPLAY_ATTEMPTS;
8230
+ }
8196
8231
  function closeStream(stream, code = NGHTTP2_REFUSED_STREAM) {
8197
8232
  if (stream != null && !stream.destroyed && !stream.closed) {
8198
8233
  try {
@@ -8204,15 +8239,30 @@ var require_client_h2 = __commonJS({
8204
8239
  function detachRequestStreamForClose(request) {
8205
8240
  const stream = request[kRequestStream];
8206
8241
  clearRequestStream(request);
8242
+ severRequestStream(stream);
8207
8243
  return stream;
8208
8244
  }
8245
+ function severRequestStream(stream) {
8246
+ if (stream == null || stream[kRequestStreamState] == null) {
8247
+ return;
8248
+ }
8249
+ stream[kRequestStreamState] = null;
8250
+ stream.off("close", completeRequestStream);
8251
+ stream.off("close", onUpgradeStreamClose);
8252
+ if (stream[kHTTP2Session] != null) {
8253
+ closeStreamSession(stream);
8254
+ }
8255
+ if (!stream.destroyed && !stream.closed) {
8256
+ stream.once("error", noop);
8257
+ }
8258
+ }
8209
8259
  function connectH2(client, socket) {
8210
8260
  client[kSocket] = socket;
8211
- const http2InitialWindowSize = client[kHTTP2InitialWindowSize];
8212
- const http2ConnectionWindowSize = client[kHTTP2ConnectionWindowSize];
8261
+ const http2InitialWindowSize = client[kHTTP2Options].sessionOptions?.initialWindowSize;
8262
+ const http2ConnectionWindowSize = client[kHTTP2Options].connectionWindowSize;
8213
8263
  const session = http2.connect(client[kUrl], {
8214
8264
  createConnection: () => socket,
8215
- peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
8265
+ peerMaxConcurrentStreams: client[kHTTP2Options].maxConcurrentStreams,
8216
8266
  settings: {
8217
8267
  // TODO(metcoder95): add support for PUSH
8218
8268
  enablePush: false,
@@ -8225,13 +8275,16 @@ var require_client_h2 = __commonJS({
8225
8275
  session[kSocket] = socket;
8226
8276
  session[kHTTP2SessionState] = {
8227
8277
  idleTimeout: null,
8278
+ // Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
8279
+ // work that cannot start. See setNoStreamsTimeout.
8280
+ noStreamsTimeout: null,
8228
8281
  // Sockets start out ref'd. Session ref/unref proxies to the socket, so a
8229
8282
  // single cached flag lets us skip redundant uv ref/unref calls, provided
8230
8283
  // every ref/unref of the session or its socket goes through
8231
8284
  // refH2Session/unrefH2Session.
8232
8285
  refed: true,
8233
8286
  ping: {
8234
- interval: client[kPingInterval] === 0 ? null : setInterval(onHttp2SendPing, client[kPingInterval], session).unref()
8287
+ interval: client[kHTTP2Options].pingInterval === 0 ? null : setInterval(onHttp2SendPing, client[kHTTP2Options].pingInterval, session).unref()
8235
8288
  }
8236
8289
  };
8237
8290
  session[kReceivedGoAway] = false;
@@ -8336,8 +8389,48 @@ var require_client_h2 = __commonJS({
8336
8389
  } else {
8337
8390
  clearHttp2IdleTimeout(session);
8338
8391
  }
8392
+ if (client[kMaxConcurrentStreams] === 0 && client[kRunning] === 0 && client[kPending] > 0) {
8393
+ setNoStreamsTimeout(session);
8394
+ } else {
8395
+ clearNoStreamsTimeout(session);
8396
+ }
8397
+ }
8398
+ }
8399
+ function clearNoStreamsTimeout(session) {
8400
+ const state = session[kHTTP2SessionState];
8401
+ if (state?.noStreamsTimeout != null) {
8402
+ clearTimeout(state.noStreamsTimeout);
8403
+ state.noStreamsTimeout = null;
8339
8404
  }
8340
8405
  }
8406
+ function setNoStreamsTimeout(session) {
8407
+ const client = session[kClient];
8408
+ const state = session[kHTTP2SessionState];
8409
+ const timeout = client[kHeadersTimeout];
8410
+ if (!timeout || state.noStreamsTimeout != null) {
8411
+ return;
8412
+ }
8413
+ state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
8414
+ }
8415
+ function onNoStreamsTimeout(session) {
8416
+ const client = session[kClient];
8417
+ const state = session[kHTTP2SessionState];
8418
+ state.noStreamsTimeout = null;
8419
+ if (client[kHTTP2Session] !== session || client[kMaxConcurrentStreams] !== 0 || client[kRunning] !== 0 || client[kPending] === 0) {
8420
+ return;
8421
+ }
8422
+ const err = new HeadersTimeoutError(
8423
+ `HTTP/2: server did not accept a new stream within ${client[kHeadersTimeout]}`
8424
+ );
8425
+ const requests = client[kQueue].splice(client[kPendingIdx]);
8426
+ for (let i = 0; i < requests.length; i++) {
8427
+ if (requests[i] != null) {
8428
+ util.errorRequest(client, requests[i], err);
8429
+ }
8430
+ }
8431
+ session[kError] = err;
8432
+ resetHttp2Session(session, err);
8433
+ }
8341
8434
  function clearHttp2IdleTimeout(session) {
8342
8435
  const state = session[kHTTP2SessionState];
8343
8436
  if (state?.idleTimeout != null) {
@@ -8444,7 +8537,7 @@ var require_client_h2 = __commonJS({
8444
8537
  const request = client[kQueue][i];
8445
8538
  if (request != null) {
8446
8539
  streamsToClose.push(detachRequestStreamForClose(request));
8447
- if (canRetryRequestAfterGoAway(request)) {
8540
+ if (canReplayRequest(request) && registerGoAwayRefusal(request)) {
8448
8541
  retriableRequests.push(request);
8449
8542
  } else {
8450
8543
  util.errorRequest(client, request, err);
@@ -8465,6 +8558,7 @@ var require_client_h2 = __commonJS({
8465
8558
  client[kHTTP2Session] = null;
8466
8559
  }
8467
8560
  clearHttp2IdleTimeout(this);
8561
+ clearNoStreamsTimeout(this);
8468
8562
  if (!this.closed && !this.destroyed) {
8469
8563
  this.close();
8470
8564
  }
@@ -8481,6 +8575,7 @@ var require_client_h2 = __commonJS({
8481
8575
  client[kHTTP2Session] = null;
8482
8576
  }
8483
8577
  clearHttp2IdleTimeout(this);
8578
+ clearNoStreamsTimeout(this);
8484
8579
  if (state.ping.interval != null) {
8485
8580
  clearInterval(state.ping.interval);
8486
8581
  state.ping.interval = null;
@@ -8556,6 +8651,12 @@ var require_client_h2 = __commonJS({
8556
8651
  releaseRequestStream(this);
8557
8652
  if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
8558
8653
  state.request.onResponseEnd(state.trailers || {});
8654
+ } else if (!state.request.aborted && !state.request.completed) {
8655
+ util.errorRequest(
8656
+ state.client,
8657
+ state.request,
8658
+ new InformationalError("HTTP/2: stream closed before the response was complete")
8659
+ );
8559
8660
  }
8560
8661
  finalizeRequest(state);
8561
8662
  closeStreamSession(this);
@@ -8702,7 +8803,7 @@ var require_client_h2 = __commonJS({
8702
8803
  const headersTimeout = request.headersTimeout ?? client[kHeadersTimeout];
8703
8804
  const bodyTimeout = request.bodyTimeout ?? client[kBodyTimeout];
8704
8805
  const session = client[kHTTP2Session];
8705
- const { method, path: path5, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request;
8806
+ const { method, path: path6, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request;
8706
8807
  if (upgrade != null && upgrade !== "websocket") {
8707
8808
  util.errorRequest(client, request, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
8708
8809
  return false;
@@ -8765,7 +8866,7 @@ var require_client_h2 = __commonJS({
8765
8866
  }
8766
8867
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
8767
8868
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
8768
- headers[HTTP2_HEADER_PATH] = path5;
8869
+ headers[HTTP2_HEADER_PATH] = path6;
8769
8870
  if (protocol === "ws:" || protocol === "wss:") {
8770
8871
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
8771
8872
  } else {
@@ -8787,7 +8888,7 @@ var require_client_h2 = __commonJS({
8787
8888
  setupUpgradeStream(stream, state);
8788
8889
  return true;
8789
8890
  }
8790
- headers[HTTP2_HEADER_PATH] = path5;
8891
+ headers[HTTP2_HEADER_PATH] = path6;
8791
8892
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8792
8893
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
8793
8894
  let body = state.body;
@@ -8955,6 +9056,20 @@ var require_client_h2 = __commonJS({
8955
9056
  state.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
8956
9057
  }
8957
9058
  }
9059
+ function retryRefusedStream(stream, state) {
9060
+ const { client, request } = state;
9061
+ if (state.responseReceived || request.aborted || request.completed || request[kRefusedStreamRetry] || !canReplayRequest(request)) {
9062
+ return false;
9063
+ }
9064
+ request[kRefusedStreamRetry] = true;
9065
+ detachRequestStreamForClose(request);
9066
+ state.stream = null;
9067
+ state.requestFinalized = true;
9068
+ completeRequest(client, request);
9069
+ client[kQueue].splice(client[kPendingIdx], 0, request);
9070
+ client[kResume]();
9071
+ return true;
9072
+ }
8958
9073
  function onError(err) {
8959
9074
  const stream = this;
8960
9075
  const state = stream[kRequestStreamState];
@@ -8962,6 +9077,12 @@ var require_client_h2 = __commonJS({
8962
9077
  return;
8963
9078
  }
8964
9079
  stream.off("error", onError);
9080
+ if (typeof stream.rstCode === "number" && stream.rstCode !== NGHTTP2_NO_ERROR) {
9081
+ err.http2ErrorCode = stream.rstCode;
9082
+ }
9083
+ if (stream.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream, state)) {
9084
+ return;
9085
+ }
8965
9086
  state.abort(err);
8966
9087
  }
8967
9088
  function onFrameError(type, code) {
@@ -9196,7 +9317,7 @@ var require_client = __commonJS({
9196
9317
  var util = require_util();
9197
9318
  var { ClientStats } = require_stats();
9198
9319
  var { channels } = require_diagnostics();
9199
- var Request = require_request();
9320
+ var Request2 = require_request();
9200
9321
  var DispatcherBase = require_dispatcher_base();
9201
9322
  var {
9202
9323
  InvalidArgumentError,
@@ -9243,10 +9364,8 @@ var require_client = __commonJS({
9243
9364
  kHTTPContext,
9244
9365
  kMaxConcurrentStreams,
9245
9366
  kHostAuthority,
9246
- kHTTP2InitialWindowSize,
9247
- kHTTP2ConnectionWindowSize,
9248
9367
  kResume,
9249
- kPingInterval
9368
+ kHTTP2Options
9250
9369
  } = require_symbols();
9251
9370
  var connectH1 = require_client_h1();
9252
9371
  var connectH2 = require_client_h2();
@@ -9259,6 +9378,14 @@ var require_client = __commonJS({
9259
9378
  function getPipelining(client) {
9260
9379
  return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1;
9261
9380
  }
9381
+ var h2NamespaceOptsWarning = false;
9382
+ function emitH2OptionsNamespaceWarning(optName) {
9383
+ if (h2NamespaceOptsWarning === true) return;
9384
+ process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {
9385
+ code: "UNDICI-H2-OPTIONS"
9386
+ });
9387
+ h2NamespaceOptsWarning = true;
9388
+ }
9262
9389
  function getMaxConcurrent(client) {
9263
9390
  if (client[kHTTPContext]?.version === "h2") {
9264
9391
  return client[kMaxConcurrentStreams];
@@ -9302,7 +9429,8 @@ var require_client = __commonJS({
9302
9429
  initialWindowSize,
9303
9430
  connectionWindowSize,
9304
9431
  pingInterval,
9305
- webSocket
9432
+ webSocket,
9433
+ h2Options
9306
9434
  } = {}) {
9307
9435
  if (keepAlive !== void 0) {
9308
9436
  throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
@@ -9365,20 +9493,45 @@ var require_client = __commonJS({
9365
9493
  if (allowH2 != null && typeof allowH2 !== "boolean") {
9366
9494
  throw new InvalidArgumentError("allowH2 must be a valid boolean value");
9367
9495
  }
9368
- if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
9369
- throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
9370
- }
9371
- if (useH2c != null && typeof useH2c !== "boolean") {
9372
- throw new InvalidArgumentError("useH2c must be a valid boolean value");
9373
- }
9374
- if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
9375
- throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
9376
- }
9377
- if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
9378
- throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
9379
- }
9380
- if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
9381
- throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
9496
+ if (allowH2 !== false) {
9497
+ if (h2Options != null) {
9498
+ if (h2Options.useH2c != null && typeof h2Options.useH2c !== "boolean") {
9499
+ throw new InvalidArgumentError("h2Options.useH2c must be a valid boolean value");
9500
+ }
9501
+ if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
9502
+ throw new InvalidArgumentError("h2Options.settings.initialWindowSize must be a positive integer, greater than 0");
9503
+ }
9504
+ if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
9505
+ throw new InvalidArgumentError("h2Options.maxConcurrentStreams must be a positive integer, greater than 0");
9506
+ }
9507
+ if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
9508
+ throw new InvalidArgumentError("h2Options.connectionWindowSize must be a positive integer, greater than 0");
9509
+ }
9510
+ if (h2Options.pingInterval != null && (typeof h2Options.pingInterval !== "number" || !Number.isInteger(h2Options.pingInterval) || h2Options.pingInterval < 0)) {
9511
+ throw new InvalidArgumentError("h2Options.pingInterval must be a positive integer, greater or equal to 0");
9512
+ }
9513
+ } else {
9514
+ if (useH2c != null && typeof useH2c !== "boolean") {
9515
+ emitH2OptionsNamespaceWarning("useH2c");
9516
+ throw new InvalidArgumentError("useH2c must be a valid boolean value");
9517
+ }
9518
+ if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
9519
+ emitH2OptionsNamespaceWarning("maxConcurrentStreams");
9520
+ throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
9521
+ }
9522
+ if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
9523
+ emitH2OptionsNamespaceWarning("initialWindowSize");
9524
+ throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
9525
+ }
9526
+ if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
9527
+ emitH2OptionsNamespaceWarning("connectionWindowSize");
9528
+ throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
9529
+ }
9530
+ if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
9531
+ emitH2OptionsNamespaceWarning("pingInterval");
9532
+ throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
9533
+ }
9534
+ }
9382
9535
  }
9383
9536
  super({ webSocket });
9384
9537
  if (typeof connect2 !== "function") {
@@ -9386,8 +9539,8 @@ var require_client = __commonJS({
9386
9539
  ...tls,
9387
9540
  maxCachedSessions,
9388
9541
  allowH2,
9389
- useH2c,
9390
9542
  socketPath,
9543
+ useH2c: h2Options?.useH2c ?? useH2c,
9391
9544
  timeout: connectTimeout,
9392
9545
  ...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
9393
9546
  ...connect2
@@ -9422,10 +9575,21 @@ var require_client = __commonJS({
9422
9575
  this[kClosedResolve] = null;
9423
9576
  this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
9424
9577
  this[kHTTPContext] = null;
9425
- this[kMaxConcurrentStreams] = maxConcurrentStreams != null ? maxConcurrentStreams : 100;
9426
- this[kHTTP2InitialWindowSize] = initialWindowSize != null ? initialWindowSize : 262144;
9427
- this[kHTTP2ConnectionWindowSize] = connectionWindowSize != null ? connectionWindowSize : 524288;
9428
- this[kPingInterval] = pingInterval != null ? pingInterval : 6e4;
9578
+ this[kHTTP2Options] = {
9579
+ pingInterval: h2Options?.pingInterval ?? pingInterval ?? 6e4,
9580
+ connectionWindowSize: h2Options?.connectionWindowSize ?? connectionWindowSize ?? 524288,
9581
+ maxConcurrentStreams: h2Options?.maxConcurrentStreams ?? maxConcurrentStreams ?? 100,
9582
+ // Max peerConcurrentStreams for a Node h2 server
9583
+ sessionOptions: {
9584
+ // HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
9585
+ // - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
9586
+ // Allows more data to be sent before requiring acknowledgment, improving throughput
9587
+ // especially on high-latency networks. This matches common production HTTP/2 servers.
9588
+ // - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
9589
+ // Provides better flow control for the entire connection across multiple streams.
9590
+ initialWindowSize: h2Options?.initialWindowSize ?? initialWindowSize ?? 262144
9591
+ }
9592
+ };
9429
9593
  this[kQueue] = [];
9430
9594
  this[kRunningIdx] = 0;
9431
9595
  this[kPendingIdx] = 0;
@@ -9465,7 +9629,7 @@ var require_client = __commonJS({
9465
9629
  this.once("connect", cb);
9466
9630
  }
9467
9631
  [kDispatch](opts, handler) {
9468
- const request = new Request(this[kUrl].origin, opts, handler);
9632
+ const request = new Request2(this[kUrl].origin, opts, handler);
9469
9633
  this[kQueue].push(request);
9470
9634
  if (this[kResuming]) {
9471
9635
  } else if (util.bodyLength(request.body) == null && util.isIterable(request.body)) {
@@ -9710,6 +9874,7 @@ var require_client = __commonJS({
9710
9874
  return;
9711
9875
  }
9712
9876
  if (!client[kHTTPContext]) {
9877
+ client[kServerName] = request.servername;
9713
9878
  connect(client);
9714
9879
  return;
9715
9880
  }
@@ -11120,7 +11285,7 @@ var require_socks5_proxy_agent = __commonJS({
11120
11285
  var DispatcherBase = require_dispatcher_base();
11121
11286
  var { InvalidArgumentError } = require_errors();
11122
11287
  var { Socks5Client, STATES } = require_socks5_client();
11123
- var { kDispatch, kClose, kDestroy } = require_symbols();
11288
+ var { kBusy, kConnected, kDispatch, kClose, kDestroy } = require_symbols();
11124
11289
  var Pool = require_pool();
11125
11290
  var buildConnector = require_connect();
11126
11291
  var { debuglog } = require("node:util");
@@ -11278,6 +11443,17 @@ var require_socks5_proxy_agent = __commonJS({
11278
11443
  }
11279
11444
  });
11280
11445
  this[kPools].set(originKey, pool);
11446
+ const closePoolIfUnused = () => {
11447
+ if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
11448
+ return;
11449
+ }
11450
+ this[kPools].delete(originKey);
11451
+ if (!pool.destroyed) {
11452
+ pool.close();
11453
+ }
11454
+ };
11455
+ pool.on("disconnect", closePoolIfUnused);
11456
+ pool.on("connectionError", closePoolIfUnused);
11281
11457
  }
11282
11458
  return pool[kDispatch](opts, handler);
11283
11459
  } catch (err) {
@@ -11382,10 +11558,10 @@ var require_proxy_agent = __commonJS({
11382
11558
  };
11383
11559
  const {
11384
11560
  origin,
11385
- path: path5 = "/",
11561
+ path: path6 = "/",
11386
11562
  headers = {}
11387
11563
  } = opts;
11388
- opts.path = origin + path5;
11564
+ opts.path = origin + path6;
11389
11565
  if (!("host" in headers) && !("Host" in headers)) {
11390
11566
  const { host } = new URL(origin);
11391
11567
  headers.host = host;
@@ -11662,7 +11838,7 @@ var require_env_http_proxy_agent = __commonJS({
11662
11838
  }
11663
11839
  #getProxyAgentForUrl(url) {
11664
11840
  let { protocol, host: hostname, port } = url;
11665
- hostname = hostname.replace(/:\d*$/, "").toLowerCase();
11841
+ hostname = hostname.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
11666
11842
  port = Number.parseInt(port, 10) || DEFAULT_PORTS[protocol] || 0;
11667
11843
  if (!this.#shouldProxy(hostname, port)) {
11668
11844
  return this[kNoProxyAgent];
@@ -11705,11 +11881,22 @@ var require_env_http_proxy_agent = __commonJS({
11705
11881
  if (!entry) {
11706
11882
  continue;
11707
11883
  }
11708
- const parsed = entry.match(/^(.+):(\d+)$/);
11884
+ let hostname, port;
11885
+ const ipv6WithPort = entry.match(/^\[(.+)\]:(\d+)$/);
11886
+ if (ipv6WithPort) {
11887
+ hostname = ipv6WithPort[1];
11888
+ port = Number.parseInt(ipv6WithPort[2], 10);
11889
+ } else {
11890
+ const unbracketed = entry.replace(/^\[(.+)\]$/, "$1");
11891
+ const colonCount = (unbracketed.match(/:/g) || []).length;
11892
+ const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/);
11893
+ hostname = parsed ? parsed[1] : unbracketed;
11894
+ port = parsed ? Number.parseInt(parsed[2], 10) : 0;
11895
+ }
11709
11896
  noProxyEntries.push({
11710
11897
  // strip leading dot or asterisk with dot
11711
- hostname: (parsed ? parsed[1] : entry).replace(/^\*?\./, "").toLowerCase(),
11712
- port: parsed ? Number.parseInt(parsed[2], 10) : 0
11898
+ hostname: hostname.replace(/^\*?\./, "").toLowerCase(),
11899
+ port
11713
11900
  });
11714
11901
  }
11715
11902
  this.#noProxyValue = noProxyValue;
@@ -11745,6 +11932,23 @@ var require_retry_handler = __commonJS({
11745
11932
  const retryTime = new Date(retryAfter).getTime();
11746
11933
  return isNaN(retryTime) ? null : retryTime - Date.now();
11747
11934
  }
11935
+ function validatePartialResponseContentLength(headers, range, statusCode, retryCount) {
11936
+ const contentLength = headers["content-length"];
11937
+ if (contentLength == null) {
11938
+ return;
11939
+ }
11940
+ if (!Number.isFinite(range.start) || !Number.isFinite(range.end)) {
11941
+ return;
11942
+ }
11943
+ const length = Number(contentLength);
11944
+ const expectedLength = range.end - range.start + 1;
11945
+ if (!Number.isFinite(length) || length !== expectedLength) {
11946
+ throw new RequestRetryError("Content-Length mismatch", statusCode, {
11947
+ headers,
11948
+ data: { count: retryCount }
11949
+ });
11950
+ }
11951
+ }
11748
11952
  var RetryController = class {
11749
11953
  constructor() {
11750
11954
  this.target = null;
@@ -11914,6 +12118,10 @@ var require_retry_handler = __commonJS({
11914
12118
  setTimeout(() => cb(null), retryTimeout);
11915
12119
  }
11916
12120
  onResponseStart(controller, statusCode, headers, statusMessage) {
12121
+ if (statusCode < 200) {
12122
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
12123
+ return;
12124
+ }
11917
12125
  this.error = null;
11918
12126
  this.retryCount += 1;
11919
12127
  this.statusCode = statusCode;
@@ -11948,6 +12156,7 @@ var require_retry_handler = __commonJS({
11948
12156
  data: { count: this.retryCount }
11949
12157
  });
11950
12158
  }
12159
+ validatePartialResponseContentLength(headers, contentRange, statusCode, this.retryCount);
11951
12160
  const { start, size, end = size ? size - 1 : null } = contentRange;
11952
12161
  assert(this.start === start, "content-range mismatch");
11953
12162
  assert(this.end == null || this.end === end, "content-range mismatch");
@@ -11956,7 +12165,7 @@ var require_retry_handler = __commonJS({
11956
12165
  if (this.end == null) {
11957
12166
  if (statusCode === 206) {
11958
12167
  const range = parseRangeHeader(headers["content-range"]);
11959
- if (range == null) {
12168
+ if (range == null || range.end == null) {
11960
12169
  this.headersSent = true;
11961
12170
  this.handler.onResponseStart?.(
11962
12171
  this.controllerProxy,
@@ -11966,6 +12175,7 @@ var require_retry_handler = __commonJS({
11966
12175
  );
11967
12176
  return;
11968
12177
  }
12178
+ validatePartialResponseContentLength(headers, range, statusCode, this.retryCount);
11969
12179
  const { start, size, end = size ? size - 1 : null } = range;
11970
12180
  assert(
11971
12181
  start != null && Number.isFinite(start),
@@ -11975,7 +12185,7 @@ var require_retry_handler = __commonJS({
11975
12185
  this.start = start;
11976
12186
  this.end = end;
11977
12187
  }
11978
- if (this.end == null) {
12188
+ if (this.end == null && this.opts.method !== "HEAD") {
11979
12189
  const contentLength = headers["content-length"];
11980
12190
  this.end = contentLength != null ? Number(contentLength) - 1 : null;
11981
12191
  }
@@ -12176,7 +12386,6 @@ var require_readable = __commonJS({
12176
12386
  var kContentLength = /* @__PURE__ */ Symbol("kContentLength");
12177
12387
  var kUsed = /* @__PURE__ */ Symbol("kUsed");
12178
12388
  var kBytesRead = /* @__PURE__ */ Symbol("kBytesRead");
12179
- var kPreservedBuffer = /* @__PURE__ */ Symbol("kPreservedBuffer");
12180
12389
  var noop = () => {
12181
12390
  };
12182
12391
  var BodyReadable = class extends Readable {
@@ -12415,21 +12624,6 @@ var require_readable = __commonJS({
12415
12624
  */
12416
12625
  setEncoding(encoding) {
12417
12626
  if (Buffer.isEncoding(encoding)) {
12418
- const state = this._readableState;
12419
- const buffer = state.buffer;
12420
- if (buffer && state.length > 0) {
12421
- const bufferIndex = state.bufferIndex ?? 0;
12422
- const preserved = [];
12423
- const source = typeof buffer.slice === "function" ? buffer.slice(bufferIndex) : buffer;
12424
- for (const data of source) {
12425
- if (Buffer.isBuffer(data)) {
12426
- preserved.push(data);
12427
- }
12428
- }
12429
- if (preserved.length > 0) {
12430
- this[kPreservedBuffer] = (this[kPreservedBuffer] || []).concat(preserved);
12431
- }
12432
- }
12433
12627
  super.setEncoding(encoding);
12434
12628
  }
12435
12629
  return this;
@@ -12480,13 +12674,7 @@ var require_readable = __commonJS({
12480
12674
  return;
12481
12675
  }
12482
12676
  const { _readableState: state } = consume2.stream;
12483
- const preserved = consume2.stream[kPreservedBuffer];
12484
- if (preserved && preserved.length > 0) {
12485
- for (const chunk of preserved) {
12486
- consumePush(consume2, chunk);
12487
- }
12488
- consume2.stream[kPreservedBuffer] = null;
12489
- } else if (state.bufferIndex) {
12677
+ if (state.bufferIndex) {
12490
12678
  const start = state.bufferIndex;
12491
12679
  const end = state.buffer.length;
12492
12680
  for (let n = start; n < end; n++) {
@@ -12497,13 +12685,17 @@ var require_readable = __commonJS({
12497
12685
  consumePush(consume2, chunk);
12498
12686
  }
12499
12687
  }
12688
+ const decoder = state.decoder;
12689
+ if (decoder != null && decoder.lastNeed > 0) {
12690
+ consumePush(consume2, Buffer.from(decoder.lastChar.subarray(0, decoder.lastTotal - decoder.lastNeed)));
12691
+ }
12500
12692
  if (state.endEmitted) {
12501
- consumeEnd(this[kConsume], this._readableState.encoding);
12502
- } else {
12503
- consume2.stream.on("end", function() {
12504
- consumeEnd(this[kConsume], this._readableState.encoding);
12505
- });
12693
+ consumeEnd(consume2, state.encoding);
12694
+ return;
12506
12695
  }
12696
+ consume2.stream.on("end", function() {
12697
+ consumeEnd(this[kConsume], this._readableState.encoding);
12698
+ });
12507
12699
  consume2.stream.resume();
12508
12700
  while (consume2.stream.read() != null) {
12509
12701
  }
@@ -12560,6 +12752,9 @@ var require_readable = __commonJS({
12560
12752
  if (consume2.body === null) {
12561
12753
  return;
12562
12754
  }
12755
+ if (typeof chunk === "string") {
12756
+ chunk = Buffer.from(chunk, consume2.stream._readableState.encoding);
12757
+ }
12563
12758
  consume2.length += chunk.length;
12564
12759
  consume2.body.push(chunk);
12565
12760
  }
@@ -13544,6 +13739,7 @@ var require_mock_utils = __commonJS({
13544
13739
  }
13545
13740
  } = require("node:util");
13546
13741
  var { InvalidArgumentError } = require_errors();
13742
+ var requestAborted = /* @__PURE__ */ Symbol("request aborted");
13547
13743
  function matchValue(match, value) {
13548
13744
  if (typeof match === "string") {
13549
13745
  return match === value;
@@ -13630,20 +13826,20 @@ var require_mock_utils = __commonJS({
13630
13826
  }
13631
13827
  return normalizedQp;
13632
13828
  }
13633
- function safeUrl(path5) {
13634
- if (typeof path5 !== "string") {
13635
- return path5;
13829
+ function safeUrl(path6) {
13830
+ if (typeof path6 !== "string") {
13831
+ return path6;
13636
13832
  }
13637
- const pathSegments = path5.split("?", 3);
13833
+ const pathSegments = path6.split("?", 3);
13638
13834
  if (pathSegments.length !== 2) {
13639
- return path5;
13835
+ return path6;
13640
13836
  }
13641
13837
  const qp = new URLSearchParams(pathSegments.pop());
13642
13838
  qp.sort();
13643
13839
  return [...pathSegments, qp.toString()].join("?");
13644
13840
  }
13645
- function matchKey(mockDispatch2, { path: path5, method, body, headers }) {
13646
- const pathMatch = matchValue(mockDispatch2.path, path5);
13841
+ function matchKey(mockDispatch2, { path: path6, method, body, headers }) {
13842
+ const pathMatch = matchValue(mockDispatch2.path, path6);
13647
13843
  const methodMatch = matchValue(mockDispatch2.method, method);
13648
13844
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
13649
13845
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -13656,6 +13852,8 @@ var require_mock_utils = __commonJS({
13656
13852
  return data;
13657
13853
  } else if (data instanceof ArrayBuffer) {
13658
13854
  return data;
13855
+ } else if (ArrayBuffer.isView(data)) {
13856
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
13659
13857
  } else if (typeof data === "object") {
13660
13858
  return JSON.stringify(data);
13661
13859
  } else if (data) {
@@ -13668,8 +13866,8 @@ var require_mock_utils = __commonJS({
13668
13866
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
13669
13867
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
13670
13868
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
13671
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path5, ignoreTrailingSlash }) => {
13672
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path5)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path5), resolvedPath);
13869
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path6, ignoreTrailingSlash }) => {
13870
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path6)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path6), resolvedPath);
13673
13871
  });
13674
13872
  if (matchedMockDispatches.length === 0) {
13675
13873
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -13708,19 +13906,22 @@ var require_mock_utils = __commonJS({
13708
13906
  mockDispatches.splice(index, 1);
13709
13907
  }
13710
13908
  }
13711
- function removeTrailingSlash(path5) {
13712
- while (path5.endsWith("/")) {
13713
- path5 = path5.slice(0, -1);
13909
+ function removeTrailingSlash(path6) {
13910
+ if (typeof path6 !== "string") {
13911
+ return path6;
13714
13912
  }
13715
- if (path5.length === 0) {
13716
- path5 = "/";
13913
+ while (path6.endsWith("/")) {
13914
+ path6 = path6.slice(0, -1);
13717
13915
  }
13718
- return path5;
13916
+ if (path6.length === 0) {
13917
+ path6 = "/";
13918
+ }
13919
+ return path6;
13719
13920
  }
13720
13921
  function buildKey(opts) {
13721
- const { path: path5, method, body, headers, query } = opts;
13922
+ const { path: path6, method, body, headers, query } = opts;
13722
13923
  return {
13723
- path: path5,
13924
+ path: path6,
13724
13925
  method,
13725
13926
  body,
13726
13927
  headers,
@@ -13762,30 +13963,38 @@ var require_mock_utils = __commonJS({
13762
13963
  const { timesInvoked, times } = mockDispatch2;
13763
13964
  mockDispatch2.consumed = !mockDispatch2.persist && timesInvoked >= times;
13764
13965
  mockDispatch2.pending = timesInvoked < times;
13765
- if (mockDispatch2.data.callback) {
13766
- const callbackResult = mockDispatch2.data.callback(opts);
13966
+ const hasBodyHooks = typeof handler.onBodySent === "function" || typeof handler.onRequestSent === "function";
13967
+ if (mockDispatch2.data.callback && (!hasBodyHooks || opts.body == null)) {
13968
+ const { callback, ...responseDefaults } = mockDispatch2.data;
13969
+ const callbackResult = callback(opts);
13767
13970
  if (isPromise(callbackResult)) {
13768
13971
  callbackResult.then(
13769
13972
  (resolvedData) => {
13770
- mockDispatch2.data = { ...mockDispatch2.data, ...resolvedData };
13973
+ if (resolvedData == null || typeof resolvedData !== "object") {
13974
+ handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
13975
+ return;
13976
+ }
13977
+ mockDispatch2.data = { ...responseDefaults, ...resolvedData };
13771
13978
  dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler);
13772
13979
  },
13773
13980
  (error) => {
13774
- deleteMockDispatch(mockDispatches, key);
13775
13981
  handler.onResponseError(null, error);
13776
13982
  }
13777
13983
  );
13778
13984
  return true;
13779
13985
  }
13780
- mockDispatch2.data = { ...mockDispatch2.data, ...callbackResult };
13986
+ if (callbackResult == null || typeof callbackResult !== "object") {
13987
+ throw new InvalidArgumentError("reply options callback must return an object");
13988
+ }
13989
+ mockDispatch2.data = { ...responseDefaults, ...callbackResult };
13781
13990
  }
13782
13991
  return dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler);
13783
13992
  }
13784
13993
  function dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler) {
13785
- const { data: { statusCode, data, headers, trailers, error }, delay } = mockDispatch2;
13786
- if (error !== null) {
13994
+ const { data: response, delay } = mockDispatch2;
13995
+ if (response.error !== null) {
13787
13996
  deleteMockDispatch(mockDispatches, key);
13788
- handler.onResponseError(null, error);
13997
+ handler.onResponseError(null, response.error);
13789
13998
  return true;
13790
13999
  }
13791
14000
  let aborted = false;
@@ -13812,30 +14021,91 @@ var require_mock_utils = __commonJS({
13812
14021
  handler.onResponseError?.(controller, reason);
13813
14022
  }
13814
14023
  };
14024
+ let replyOpts = opts;
14025
+ const dispatches = mockDispatches;
13815
14026
  handler.onRequestStart?.(controller, null);
13816
- if (typeof delay === "number" && delay > 0) {
13817
- timer = setTimeout(() => {
13818
- timer = null;
13819
- handleReply(mockDispatches);
13820
- }, delay);
13821
- } else {
13822
- handleReply(mockDispatches);
14027
+ if (aborted) {
14028
+ return true;
14029
+ }
14030
+ const requestBody = dispatchRequestBody(opts.body, handler, controller, () => aborted);
14031
+ if (isPromise(requestBody)) {
14032
+ requestBody.then((body) => {
14033
+ if (body === requestAborted) {
14034
+ return;
14035
+ }
14036
+ if (body !== opts.body) {
14037
+ replyOpts = { ...opts, body };
14038
+ }
14039
+ sendReply();
14040
+ }, (error) => controller.abort(error));
14041
+ return true;
14042
+ }
14043
+ if (requestBody === requestAborted) {
14044
+ return true;
14045
+ }
14046
+ if (requestBody !== opts.body) {
14047
+ replyOpts = { ...opts, body: requestBody };
14048
+ }
14049
+ sendReply();
14050
+ function sendReply() {
14051
+ if (response.callback) {
14052
+ const { callback, ...responseDefaults } = response;
14053
+ let callbackResult;
14054
+ try {
14055
+ callbackResult = callback(replyOpts);
14056
+ } catch (err) {
14057
+ deleteMockDispatch(mockDispatches, key);
14058
+ handler.onResponseError(null, err);
14059
+ return;
14060
+ }
14061
+ if (isPromise(callbackResult)) {
14062
+ callbackResult.then(
14063
+ (resolvedData) => {
14064
+ if (resolvedData == null || typeof resolvedData !== "object") {
14065
+ handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
14066
+ return;
14067
+ }
14068
+ mockDispatch2.data = { ...responseDefaults, ...resolvedData };
14069
+ handleReply(dispatches, mockDispatch2.data);
14070
+ },
14071
+ (err) => {
14072
+ handler.onResponseError(null, err);
14073
+ }
14074
+ );
14075
+ return;
14076
+ }
14077
+ if (callbackResult == null || typeof callbackResult !== "object") {
14078
+ throw new InvalidArgumentError("reply options callback must return an object");
14079
+ }
14080
+ mockDispatch2.data = { ...responseDefaults, ...callbackResult };
14081
+ handleReply(dispatches, mockDispatch2.data);
14082
+ return;
14083
+ }
14084
+ if (typeof delay === "number" && delay > 0) {
14085
+ timer = setTimeout(() => {
14086
+ timer = null;
14087
+ handleReply(dispatches);
14088
+ }, delay);
14089
+ } else {
14090
+ handleReply(dispatches);
14091
+ }
13823
14092
  }
13824
- function handleReply(mockDispatches2, _data = data) {
14093
+ function handleReply(mockDispatches2, _response = response) {
13825
14094
  if (aborted) {
13826
14095
  return;
13827
14096
  }
14097
+ const { statusCode, data, headers, trailers } = _response;
13828
14098
  const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
13829
- const body = typeof _data === "function" ? _data({ ...opts, headers: optsHeaders }) : _data;
14099
+ const body = typeof data === "function" ? data({ ...replyOpts, headers: optsHeaders }) : data;
13830
14100
  if (isPromise(body)) {
13831
- return body.then((newData) => handleReply(mockDispatches2, newData));
14101
+ return body.then((newData) => handleReply(mockDispatches2, { ..._response, data: newData }));
13832
14102
  }
13833
14103
  if (aborted) {
13834
14104
  return;
13835
14105
  }
13836
14106
  const responseData = getResponseData(body);
13837
- const responseHeaders = generateKeyValues(headers);
13838
- const responseTrailers = generateKeyValues(trailers);
14107
+ const responseHeaders = generateKeyValues(headers ?? {});
14108
+ const responseTrailers = generateKeyValues(trailers ?? {});
13839
14109
  controller.rawHeaders = responseHeaders;
13840
14110
  controller.rawTrailers = responseTrailers;
13841
14111
  handler.onResponseStart?.(controller, statusCode, parseHeaders(responseHeaders), getStatusText(statusCode));
@@ -13845,6 +14115,78 @@ var require_mock_utils = __commonJS({
13845
14115
  }
13846
14116
  return true;
13847
14117
  }
14118
+ function dispatchRequestBody(body, handler, controller, isAborted) {
14119
+ if (typeof handler.onBodySent !== "function" && typeof handler.onRequestSent !== "function") {
14120
+ return body;
14121
+ }
14122
+ if (body == null) {
14123
+ return callOnRequestSent(handler, controller, isAborted) ? body : requestAborted;
14124
+ }
14125
+ if (body && typeof body[Symbol.asyncIterator] === "function") {
14126
+ return dispatchAsyncIterableBody(body, handler, controller, isAborted);
14127
+ }
14128
+ if (isIterableBody(body)) {
14129
+ const chunks = [];
14130
+ for (const chunk of body) {
14131
+ if (isAborted()) {
14132
+ return requestAborted;
14133
+ }
14134
+ chunks.push(chunk);
14135
+ if (!callOnBodySent(handler, controller, chunk) || isAborted()) {
14136
+ return requestAborted;
14137
+ }
14138
+ }
14139
+ return callOnRequestSent(handler, controller, isAborted) ? chunks : requestAborted;
14140
+ }
14141
+ if (isAborted()) {
14142
+ return requestAborted;
14143
+ }
14144
+ if (!callOnBodySent(handler, controller, body)) {
14145
+ return requestAborted;
14146
+ }
14147
+ return callOnRequestSent(handler, controller, isAborted) ? body : requestAborted;
14148
+ }
14149
+ async function dispatchAsyncIterableBody(body, handler, controller, isAborted) {
14150
+ const chunks = [];
14151
+ for await (const chunk of body) {
14152
+ if (isAborted()) {
14153
+ return requestAborted;
14154
+ }
14155
+ chunks.push(chunk);
14156
+ if (!callOnBodySent(handler, controller, chunk) || isAborted()) {
14157
+ return requestAborted;
14158
+ }
14159
+ }
14160
+ if (!callOnRequestSent(handler, controller, isAborted)) {
14161
+ return requestAborted;
14162
+ }
14163
+ return {
14164
+ async *[Symbol.asyncIterator]() {
14165
+ yield* chunks;
14166
+ }
14167
+ };
14168
+ }
14169
+ function callOnBodySent(handler, controller, chunk) {
14170
+ try {
14171
+ handler.onBodySent?.(chunk);
14172
+ return true;
14173
+ } catch (error) {
14174
+ controller.abort(error);
14175
+ return false;
14176
+ }
14177
+ }
14178
+ function callOnRequestSent(handler, controller, isAborted) {
14179
+ try {
14180
+ handler.onRequestSent?.();
14181
+ return !isAborted();
14182
+ } catch (error) {
14183
+ controller.abort(error);
14184
+ return false;
14185
+ }
14186
+ }
14187
+ function isIterableBody(body) {
14188
+ return typeof body !== "string" && !Buffer.isBuffer(body) && !ArrayBuffer.isView(body) && typeof body[Symbol.iterator] === "function";
14189
+ }
13848
14190
  function buildMockDispatch() {
13849
14191
  const agent = this[kMockAgent];
13850
14192
  const origin = this[kOrigin];
@@ -14450,10 +14792,10 @@ var require_pending_interceptors_formatter = __commonJS({
14450
14792
  }
14451
14793
  format(pendingInterceptors) {
14452
14794
  const withPrettyHeaders = pendingInterceptors.map(
14453
- ({ method, path: path5, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
14795
+ ({ method, path: path6, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
14454
14796
  Method: method,
14455
14797
  Origin: origin,
14456
- Path: path5,
14798
+ Path: path6,
14457
14799
  "Status code": statusCode,
14458
14800
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
14459
14801
  Invocations: timesInvoked,
@@ -14535,9 +14877,9 @@ var require_mock_agent = __commonJS({
14535
14877
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
14536
14878
  const dispatchOpts = { ...opts };
14537
14879
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
14538
- const [path5, searchParams] = dispatchOpts.path.split("?");
14880
+ const [path6, searchParams] = dispatchOpts.path.split("?");
14539
14881
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
14540
- dispatchOpts.path = `${path5}?${normalizedSearchParams}`;
14882
+ dispatchOpts.path = `${path6}?${normalizedSearchParams}`;
14541
14883
  }
14542
14884
  return this[kAgent].dispatch(dispatchOpts, handler);
14543
14885
  }
@@ -14953,12 +15295,12 @@ var require_snapshot_recorder = __commonJS({
14953
15295
  * @return {Promise<void>} - Resolves when snapshots are loaded
14954
15296
  */
14955
15297
  async loadSnapshots(filePath) {
14956
- const path5 = filePath || this.#snapshotPath;
14957
- if (!path5) {
15298
+ const path6 = filePath || this.#snapshotPath;
15299
+ if (!path6) {
14958
15300
  throw new InvalidArgumentError("Snapshot path is required");
14959
15301
  }
14960
15302
  try {
14961
- const data = await readFile(resolve2(path5), "utf8");
15303
+ const data = await readFile(resolve2(path6), "utf8");
14962
15304
  const parsed = JSON.parse(data);
14963
15305
  if (Array.isArray(parsed)) {
14964
15306
  this.#snapshots.clear();
@@ -14972,7 +15314,7 @@ var require_snapshot_recorder = __commonJS({
14972
15314
  if (error.code === "ENOENT") {
14973
15315
  this.#snapshots.clear();
14974
15316
  } else {
14975
- throw new UndiciError(`Failed to load snapshots from ${path5}`, { cause: error });
15317
+ throw new UndiciError(`Failed to load snapshots from ${path6}`, { cause: error });
14976
15318
  }
14977
15319
  }
14978
15320
  }
@@ -14983,11 +15325,11 @@ var require_snapshot_recorder = __commonJS({
14983
15325
  * @returns {Promise<void>} - Resolves when snapshots are saved
14984
15326
  */
14985
15327
  async saveSnapshots(filePath) {
14986
- const path5 = filePath || this.#snapshotPath;
14987
- if (!path5) {
15328
+ const path6 = filePath || this.#snapshotPath;
15329
+ if (!path6) {
14988
15330
  throw new InvalidArgumentError("Snapshot path is required");
14989
15331
  }
14990
- const resolvedPath = resolve2(path5);
15332
+ const resolvedPath = resolve2(path6);
14991
15333
  await mkdir4(dirname3(resolvedPath), { recursive: true });
14992
15334
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
14993
15335
  hash,
@@ -15436,6 +15778,7 @@ var require_global2 = __commonJS({
15436
15778
  var { InvalidArgumentError } = require_errors();
15437
15779
  var Agent = require_agent();
15438
15780
  var Dispatcher1Wrapper = require_dispatcher1_wrapper();
15781
+ var fallbackDispatcher;
15439
15782
  if (getGlobalDispatcher() === void 0) {
15440
15783
  setGlobalDispatcher(new Agent());
15441
15784
  }
@@ -15443,22 +15786,36 @@ var require_global2 = __commonJS({
15443
15786
  if (!agent || typeof agent.dispatch !== "function") {
15444
15787
  throw new InvalidArgumentError("Argument agent must implement Agent");
15445
15788
  }
15446
- Object.defineProperty(globalThis, globalDispatcher, {
15447
- value: agent,
15448
- writable: true,
15449
- enumerable: false,
15450
- configurable: false
15451
- });
15452
- const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent);
15453
- Object.defineProperty(globalThis, legacyGlobalDispatcher, {
15454
- value: legacyAgent,
15455
- writable: true,
15456
- enumerable: false,
15457
- configurable: false
15458
- });
15789
+ try {
15790
+ Object.defineProperty(globalThis, globalDispatcher, {
15791
+ value: agent,
15792
+ writable: true,
15793
+ enumerable: false,
15794
+ configurable: false
15795
+ });
15796
+ } catch (err) {
15797
+ if (err instanceof TypeError) {
15798
+ fallbackDispatcher = agent;
15799
+ return;
15800
+ }
15801
+ throw err;
15802
+ }
15803
+ try {
15804
+ const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent);
15805
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
15806
+ value: legacyAgent,
15807
+ writable: true,
15808
+ enumerable: false,
15809
+ configurable: false
15810
+ });
15811
+ } catch (err) {
15812
+ if (!(err instanceof TypeError)) {
15813
+ throw err;
15814
+ }
15815
+ }
15459
15816
  }
15460
15817
  function getGlobalDispatcher() {
15461
- return globalThis[globalDispatcher];
15818
+ return globalThis[globalDispatcher] ?? fallbackDispatcher;
15462
15819
  }
15463
15820
  var installedExports = (
15464
15821
  /** @type {const} */
@@ -15609,15 +15966,15 @@ var require_redirect_handler = __commonJS({
15609
15966
  return;
15610
15967
  }
15611
15968
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
15612
- const path5 = search ? `${pathname}${search}` : pathname;
15613
- const redirectUrlString = `${origin}${path5}`;
15969
+ const path6 = search ? `${pathname}${search}` : pathname;
15970
+ const redirectUrlString = `${origin}${path6}`;
15614
15971
  for (const historyUrl of this.history) {
15615
15972
  if (historyUrl.toString() === redirectUrlString) {
15616
15973
  throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
15617
15974
  }
15618
15975
  }
15619
15976
  this.opts.headers = cleanRequestHeaders(this.opts.headers, removeContentHeaders, this.opts.origin !== origin, this.stripHeadersOnRedirect, this.stripHeadersOnCrossOriginRedirect);
15620
- this.opts.path = path5;
15977
+ this.opts.path = path6;
15621
15978
  this.opts.origin = origin;
15622
15979
  this.opts.query = null;
15623
15980
  }
@@ -16357,24 +16714,146 @@ var require_cache = __commonJS({
16357
16714
  var {
16358
16715
  safeHTTPMethods,
16359
16716
  pathHasQueryOrFragment,
16360
- hasSafeIterator
16717
+ hasSafeIterator,
16718
+ isValidHTTPToken
16361
16719
  } = require_util();
16362
16720
  var { serializePathWithQuery } = require_util();
16363
- function makeCacheKey(opts) {
16364
- if (!opts.origin) {
16365
- throw new Error("opts.origin is undefined");
16721
+ var MAX_DELTA_SECONDS = 2147483647;
16722
+ var RESTRICTIVE_DIRECTIVE_NAMES = ["no-store", "private", "no-cache"];
16723
+ var kInvalidCacheControlDirectives = /* @__PURE__ */ Symbol("invalid cache-control directives");
16724
+ function trimOWS(value) {
16725
+ return value.replace(/^[\t ]+|[\t ]+$/g, "");
16726
+ }
16727
+ function arrayIncludes(array, value) {
16728
+ for (let i = 0; i < array.length; i++) {
16729
+ if (array[i] === value) {
16730
+ return true;
16731
+ }
16732
+ }
16733
+ return false;
16734
+ }
16735
+ function trimOWSStart(value) {
16736
+ return value.replace(/^[\t ]+/, "");
16737
+ }
16738
+ function trimOWSEnd(value) {
16739
+ return value.replace(/[\t ]+$/, "");
16740
+ }
16741
+ function findUnescapedQuote(value, start) {
16742
+ let escaped = false;
16743
+ for (let i = start; i < value.length; i++) {
16744
+ if (escaped) {
16745
+ escaped = false;
16746
+ } else if (value[i] === "\\") {
16747
+ escaped = true;
16748
+ } else if (value[i] === '"') {
16749
+ return i;
16750
+ }
16366
16751
  }
16752
+ return -1;
16753
+ }
16754
+ function splitCacheControlHeaderValue(value) {
16755
+ const directives = [];
16756
+ let start = 0;
16757
+ let quoteStart = -1;
16758
+ let inQuote = false;
16759
+ let escaped = false;
16760
+ for (let i = 0; i < value.length; i++) {
16761
+ if (inQuote) {
16762
+ if (escaped) {
16763
+ escaped = false;
16764
+ } else if (value[i] === "\\") {
16765
+ escaped = true;
16766
+ } else if (value[i] === '"') {
16767
+ inQuote = false;
16768
+ quoteStart = -1;
16769
+ }
16770
+ } else if (value[i] === '"') {
16771
+ inQuote = true;
16772
+ quoteStart = i;
16773
+ } else if (value[i] === ",") {
16774
+ directives.push({ value: value.substring(start, i), fromMalformedQuote: false });
16775
+ start = i + 1;
16776
+ }
16777
+ }
16778
+ if (!inQuote) {
16779
+ directives.push({ value: value.substring(start), fromMalformedQuote: false });
16780
+ return directives;
16781
+ }
16782
+ const tail = value.substring(start);
16783
+ const quoteOffset = quoteStart - start;
16784
+ let tailStart = 0;
16785
+ for (let i = 0; i < tail.length; i++) {
16786
+ if (tail[i] === ",") {
16787
+ directives.push({
16788
+ value: tail.substring(tailStart, i),
16789
+ fromMalformedQuote: tailStart > quoteOffset
16790
+ });
16791
+ tailStart = i + 1;
16792
+ }
16793
+ }
16794
+ directives.push({
16795
+ value: tail.substring(tailStart),
16796
+ fromMalformedQuote: tailStart > quoteOffset
16797
+ });
16798
+ return directives;
16799
+ }
16800
+ function markInvalidCacheControlDirective(directives, key) {
16801
+ let invalidDirectives = directives[kInvalidCacheControlDirectives];
16802
+ if (invalidDirectives === void 0) {
16803
+ invalidDirectives = /* @__PURE__ */ new Set();
16804
+ Object.defineProperty(directives, kInvalidCacheControlDirectives, {
16805
+ value: invalidDirectives
16806
+ });
16807
+ }
16808
+ invalidDirectives.add(key);
16809
+ }
16810
+ function hasInvalidCacheControlDirective(directives, key) {
16811
+ return directives[kInvalidCacheControlDirectives]?.has(key) === true;
16812
+ }
16813
+ function getMalformedRestrictiveDirectiveName(key) {
16814
+ for (const directiveName of RESTRICTIVE_DIRECTIVE_NAMES) {
16815
+ if (key.startsWith(directiveName) && key.length > directiveName.length && !isValidHTTPToken(key[directiveName.length])) {
16816
+ return directiveName;
16817
+ }
16818
+ }
16819
+ let tokenOnlyKey = "";
16820
+ let hasInvalidTokenChar = false;
16821
+ for (let i = 0; i < key.length; i++) {
16822
+ if (isValidHTTPToken(key[i])) {
16823
+ tokenOnlyKey += key[i];
16824
+ } else {
16825
+ hasInvalidTokenChar = true;
16826
+ }
16827
+ }
16828
+ if (hasInvalidTokenChar && arrayIncludes(RESTRICTIVE_DIRECTIVE_NAMES, tokenOnlyKey)) {
16829
+ return tokenOnlyKey;
16830
+ }
16831
+ }
16832
+ function makeCacheKey(opts) {
16833
+ const origin = opts.origin ? opts.origin.toString() : "";
16367
16834
  let fullPath = opts.path || "/";
16368
16835
  if (opts.query && !pathHasQueryOrFragment(fullPath)) {
16369
16836
  fullPath = serializePathWithQuery(fullPath, opts.query);
16370
16837
  }
16371
16838
  return {
16372
- origin: opts.origin.toString(),
16839
+ origin,
16373
16840
  method: opts.method,
16374
16841
  path: fullPath,
16375
16842
  headers: opts.headers
16376
16843
  };
16377
16844
  }
16845
+ function appendHeader(headers, key, val) {
16846
+ const headerName = key.toLowerCase();
16847
+ const current = headers[headerName];
16848
+ const values = Array.isArray(val) ? val : [val];
16849
+ if (current === void 0) {
16850
+ headers[headerName] = Array.isArray(val) ? val.slice() : val;
16851
+ } else if (Array.isArray(current)) {
16852
+ current.push(...values);
16853
+ } else {
16854
+ headers[headerName] = [current, ...values];
16855
+ }
16856
+ }
16378
16857
  function normalizeHeaders(opts) {
16379
16858
  let headers;
16380
16859
  if (opts.headers == null) {
@@ -16393,7 +16872,7 @@ var require_cache = __commonJS({
16393
16872
  if (typeof key !== "string" || typeof val !== "string") {
16394
16873
  throw new Error("opts.headers is not a valid header map");
16395
16874
  }
16396
- headers[key.toLowerCase()] = val;
16875
+ appendHeader(headers, key, val);
16397
16876
  }
16398
16877
  } else {
16399
16878
  const len = opts.headers.length;
@@ -16407,14 +16886,14 @@ var require_cache = __commonJS({
16407
16886
  throw new Error("opts.headers is not a valid header map");
16408
16887
  }
16409
16888
  if (typeof val === "string") {
16410
- headers[key.toLowerCase()] = val;
16889
+ appendHeader(headers, key, val);
16411
16890
  } else {
16412
16891
  const mapped = [];
16413
16892
  for (let j = 0; j < val.length; j++) {
16414
16893
  const v = val[j];
16415
16894
  mapped.push(typeof v === "string" ? v : v.toString("latin1"));
16416
16895
  }
16417
- headers[key.toLowerCase()] = mapped;
16896
+ appendHeader(headers, key, mapped);
16418
16897
  }
16419
16898
  }
16420
16899
  }
@@ -16427,12 +16906,12 @@ var require_cache = __commonJS({
16427
16906
  if (typeof key !== "string" || typeof val !== "string") {
16428
16907
  throw new Error("opts.headers is not a valid header map");
16429
16908
  }
16430
- headers[key.toLowerCase()] = val;
16909
+ appendHeader(headers, key, val);
16431
16910
  }
16432
16911
  }
16433
16912
  } else {
16434
16913
  for (const key of Object.keys(opts.headers)) {
16435
- headers[key.toLowerCase()] = opts.headers[key];
16914
+ appendHeader(headers, key, opts.headers[key]);
16436
16915
  }
16437
16916
  }
16438
16917
  } else {
@@ -16477,25 +16956,32 @@ var require_cache = __commonJS({
16477
16956
  }
16478
16957
  function parseCacheControlHeader(header) {
16479
16958
  const output = {};
16480
- let directives;
16481
- if (Array.isArray(header)) {
16482
- directives = [];
16483
- for (const directive of header) {
16484
- directives.push(...directive.split(","));
16485
- }
16486
- } else {
16487
- directives = header.split(",");
16488
- }
16959
+ const invalidNumericDirectives = /* @__PURE__ */ new Set();
16960
+ const invalidNoArgumentDirectives = /* @__PURE__ */ new Set();
16961
+ const directives = splitCacheControlHeaderValue(Array.isArray(header) ? header.join(",") : header);
16489
16962
  for (let i = 0; i < directives.length; i++) {
16490
- const directive = directives[i].toLowerCase();
16963
+ const directiveRecord = directives[i];
16964
+ const directive = directiveRecord.value.toLowerCase();
16965
+ const fromMalformedQuote = directiveRecord.fromMalformedQuote;
16491
16966
  const keyValueDelimiter = directive.indexOf("=");
16492
16967
  let key;
16493
16968
  let value;
16969
+ let keyHasTrailingWhitespace = false;
16970
+ let valueHasLeadingWhitespace = false;
16494
16971
  if (keyValueDelimiter !== -1) {
16495
- key = directive.substring(0, keyValueDelimiter).trimStart();
16496
- value = directive.substring(keyValueDelimiter + 1);
16972
+ const rawKey = directive.substring(0, keyValueDelimiter);
16973
+ const rawValue = directive.substring(keyValueDelimiter + 1);
16974
+ keyHasTrailingWhitespace = trimOWSEnd(rawKey) !== rawKey;
16975
+ valueHasLeadingWhitespace = trimOWSStart(rawValue) !== rawValue;
16976
+ key = trimOWS(rawKey);
16977
+ value = trimOWSStart(rawValue);
16497
16978
  } else {
16498
- key = directive.trim();
16979
+ key = trimOWS(directive);
16980
+ }
16981
+ const malformedRestrictiveDirectiveName = getMalformedRestrictiveDirectiveName(key);
16982
+ if (malformedRestrictiveDirectiveName !== void 0) {
16983
+ output[malformedRestrictiveDirectiveName] = true;
16984
+ continue;
16499
16985
  }
16500
16986
  switch (key) {
16501
16987
  case "min-fresh":
@@ -16504,48 +16990,85 @@ var require_cache = __commonJS({
16504
16990
  case "s-maxage":
16505
16991
  case "stale-while-revalidate":
16506
16992
  case "stale-if-error": {
16507
- if (value === void 0 || value[0] === " ") {
16993
+ if (fromMalformedQuote || invalidNumericDirectives.has(key)) {
16994
+ continue;
16995
+ }
16996
+ if (value === void 0 || keyHasTrailingWhitespace || valueHasLeadingWhitespace) {
16997
+ delete output[key];
16998
+ invalidNumericDirectives.add(key);
16999
+ markInvalidCacheControlDirective(output, key);
16508
17000
  continue;
16509
17001
  }
16510
17002
  if (value.length >= 2 && value[0] === '"' && value[value.length - 1] === '"') {
16511
17003
  value = value.substring(1, value.length - 1);
16512
17004
  }
16513
- const parsedValue = parseInt(value, 10);
16514
- if (parsedValue !== parsedValue) {
17005
+ if (!/^[0-9]+$/.test(value)) {
17006
+ delete output[key];
17007
+ invalidNumericDirectives.add(key);
17008
+ markInvalidCacheControlDirective(output, key);
16515
17009
  continue;
16516
17010
  }
16517
- if (key === "max-age" && key in output && output[key] >= parsedValue) {
16518
- continue;
17011
+ const parsedValue = Math.min(parseInt(value, 10), MAX_DELTA_SECONDS);
17012
+ if (key === "min-fresh") {
17013
+ if (!(key in output) || output[key] < parsedValue) {
17014
+ output[key] = parsedValue;
17015
+ }
17016
+ } else if (!(key in output) || output[key] > parsedValue) {
17017
+ output[key] = parsedValue;
16519
17018
  }
16520
- output[key] = parsedValue;
16521
17019
  break;
16522
17020
  }
16523
17021
  case "private":
16524
17022
  case "no-cache": {
17023
+ if (fromMalformedQuote) {
17024
+ output[key] = true;
17025
+ break;
17026
+ }
17027
+ if (value !== void 0 && value.length === 0) {
17028
+ output[key] = true;
17029
+ break;
17030
+ }
16525
17031
  if (value) {
16526
17032
  if (value[0] === '"') {
16527
- const headers = [value.substring(1)];
16528
- let foundEndingQuote = value[value.length - 1] === '"';
16529
- if (!foundEndingQuote) {
17033
+ value = trimOWSEnd(value);
17034
+ let fieldList = "";
17035
+ let lastQuotedPart = i;
17036
+ let foundEndingQuote = false;
17037
+ const closingQuote = findUnescapedQuote(value, 1);
17038
+ if (closingQuote !== -1) {
17039
+ fieldList = value.substring(1, closingQuote);
17040
+ foundEndingQuote = true;
17041
+ } else {
17042
+ const fieldListParts = [value.substring(1)];
16530
17043
  for (let j = i + 1; j < directives.length; j++) {
16531
- const nextPart = directives[j];
16532
- const nextPartLength = nextPart.length;
16533
- headers.push(nextPart.trim());
16534
- if (nextPartLength !== 0 && nextPart[nextPartLength - 1] === '"') {
17044
+ const nextPart = trimOWS(directives[j].value);
17045
+ const closingQuote2 = findUnescapedQuote(nextPart, 0);
17046
+ lastQuotedPart = j;
17047
+ if (closingQuote2 !== -1) {
17048
+ fieldListParts.push(nextPart.substring(0, closingQuote2));
16535
17049
  foundEndingQuote = true;
16536
17050
  break;
16537
17051
  }
17052
+ fieldListParts.push(nextPart);
16538
17053
  }
17054
+ fieldList = fieldListParts.join(",");
16539
17055
  }
16540
- if (foundEndingQuote) {
16541
- let lastHeader = headers[headers.length - 1];
16542
- if (lastHeader[lastHeader.length - 1] === '"') {
16543
- lastHeader = lastHeader.substring(0, lastHeader.length - 1);
16544
- headers[headers.length - 1] = lastHeader;
16545
- }
16546
- for (let j = 0; j < headers.length; j++) {
16547
- headers[j] = headers[j].trim();
17056
+ if (!foundEndingQuote) {
17057
+ output[key] = true;
17058
+ break;
17059
+ }
17060
+ i = lastQuotedPart;
17061
+ const headers = fieldList.split(",");
17062
+ let validFieldNames = true;
17063
+ for (let j = 0; j < headers.length; j++) {
17064
+ headers[j] = trimOWS(headers[j]);
17065
+ if (!isValidHTTPToken(headers[j])) {
17066
+ validFieldNames = false;
16548
17067
  }
17068
+ }
17069
+ if (!validFieldNames) {
17070
+ output[key] = true;
17071
+ } else if (output[key] !== true) {
16549
17072
  if (key in output) {
16550
17073
  output[key] = output[key].concat(headers);
16551
17074
  } else {
@@ -16553,11 +17076,15 @@ var require_cache = __commonJS({
16553
17076
  }
16554
17077
  }
16555
17078
  } else {
16556
- const fieldName = value.trim();
16557
- if (key in output) {
16558
- output[key] = output[key].concat(fieldName);
16559
- } else {
16560
- output[key] = [fieldName];
17079
+ const fieldName = trimOWS(value);
17080
+ if (!isValidHTTPToken(fieldName)) {
17081
+ output[key] = true;
17082
+ } else if (output[key] !== true) {
17083
+ if (key in output) {
17084
+ output[key] = output[key].concat(fieldName);
17085
+ } else {
17086
+ output[key] = [fieldName];
17087
+ }
16561
17088
  }
16562
17089
  }
16563
17090
  break;
@@ -16565,39 +17092,76 @@ var require_cache = __commonJS({
16565
17092
  }
16566
17093
  // eslint-disable-next-line no-fallthrough
16567
17094
  case "public":
16568
- case "no-store":
16569
17095
  case "must-revalidate":
16570
17096
  case "proxy-revalidate":
16571
17097
  case "immutable":
16572
17098
  case "no-transform":
16573
17099
  case "must-understand":
16574
17100
  case "only-if-cached":
16575
- if (value) {
17101
+ if (fromMalformedQuote || invalidNoArgumentDirectives.has(key)) {
17102
+ continue;
17103
+ }
17104
+ if (value !== void 0) {
17105
+ delete output[key];
17106
+ invalidNoArgumentDirectives.add(key);
16576
17107
  continue;
16577
17108
  }
16578
17109
  output[key] = true;
16579
17110
  break;
17111
+ case "no-store":
17112
+ output[key] = true;
17113
+ break;
16580
17114
  default:
16581
17115
  continue;
16582
17116
  }
16583
17117
  }
16584
17118
  return output;
16585
17119
  }
17120
+ function splitVaryHeader(varyHeader) {
17121
+ const values = Array.isArray(varyHeader) ? varyHeader : [varyHeader];
17122
+ const output = [];
17123
+ for (let i = 0; i < values.length; i++) {
17124
+ const parts = values[i].split(",");
17125
+ for (let j = 0; j < parts.length; j++) {
17126
+ output.push(parts[j]);
17127
+ }
17128
+ }
17129
+ return output;
17130
+ }
17131
+ function hasVaryStar(varyHeader) {
17132
+ const values = splitVaryHeader(varyHeader);
17133
+ for (let i = 0; i < values.length; i++) {
17134
+ if (trimOWS(values[i]).indexOf("*") !== -1) {
17135
+ return true;
17136
+ }
17137
+ }
17138
+ return false;
17139
+ }
16586
17140
  function parseVaryHeader(varyHeader, headers) {
16587
- if (typeof varyHeader === "string" && varyHeader.includes("*")) {
17141
+ if (hasVaryStar(varyHeader)) {
16588
17142
  return headers;
16589
17143
  }
16590
17144
  const output = (
16591
17145
  /** @type {Record<string, string | string[] | null>} */
16592
17146
  {}
16593
17147
  );
16594
- const varyingHeaders = typeof varyHeader === "string" ? varyHeader.split(",") : varyHeader;
17148
+ const varyingHeaders = splitVaryHeader(varyHeader);
16595
17149
  for (const header of varyingHeaders) {
16596
- const trimmedHeader = header.trim().toLowerCase();
16597
- output[trimmedHeader] = headers[trimmedHeader] ?? null;
17150
+ const trimmedHeader = trimOWS(header).toLowerCase();
17151
+ if (trimmedHeader.length === 0) {
17152
+ continue;
17153
+ }
17154
+ if (!isValidHTTPToken(trimmedHeader)) {
17155
+ return void 0;
17156
+ }
17157
+ const headerValue = headers[trimmedHeader];
17158
+ output[trimmedHeader] = Array.isArray(headerValue) ? headerValue.slice() : headerValue ?? null;
16598
17159
  }
16599
17160
  return output;
16600
17161
  }
17162
+ function isInvalidOrWildcardVaryHeader(varyHeader) {
17163
+ return hasVaryStar(varyHeader) || parseVaryHeader(varyHeader, {}) === void 0;
17164
+ }
16601
17165
  function isEtagUsable(etag) {
16602
17166
  if (etag.length <= 2) {
16603
17167
  return false;
@@ -16628,7 +17192,7 @@ var require_cache = __commonJS({
16628
17192
  throw new TypeError(`${name} needs to have at least one method`);
16629
17193
  }
16630
17194
  for (const method of methods) {
16631
- if (!safeHTTPMethods.includes(method)) {
17195
+ if (!arrayIncludes(safeHTTPMethods, method)) {
16632
17196
  throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(", ")}, got ${method}`);
16633
17197
  }
16634
17198
  }
@@ -16652,7 +17216,10 @@ var require_cache = __commonJS({
16652
17216
  assertCacheKey,
16653
17217
  assertCacheValue,
16654
17218
  parseCacheControlHeader,
17219
+ hasInvalidCacheControlDirective,
16655
17220
  parseVaryHeader,
17221
+ hasVaryStar,
17222
+ isInvalidOrWildcardVaryHeader,
16656
17223
  isEtagUsable,
16657
17224
  assertCacheMethods,
16658
17225
  assertCacheStore,
@@ -16675,6 +17242,13 @@ var require_date = __commonJS({
16675
17242
  return parseRfc850Date(date);
16676
17243
  }
16677
17244
  }
17245
+ function makeDate(year, monthIdx, day, hour, minute, second, weekday) {
17246
+ const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
17247
+ if (year >= 0 && year <= 99) {
17248
+ result.setUTCFullYear(year);
17249
+ }
17250
+ return result.getUTCFullYear() === year && result.getUTCMonth() === monthIdx && result.getUTCDate() === day && result.getUTCHours() === hour && result.getUTCMinutes() === minute && result.getUTCSeconds() === second && result.getUTCDay() === weekday ? result : void 0;
17251
+ }
16678
17252
  function parseImfDate(date) {
16679
17253
  if (date.length !== 29 || date[4] !== " " || date[7] !== " " || date[11] !== " " || date[16] !== " " || date[19] !== ":" || date[22] !== ":" || date[25] !== " " || date[26] !== "G" || date[27] !== "M" || date[28] !== "T") {
16680
17254
  return void 0;
@@ -16835,8 +17409,7 @@ var require_date = __commonJS({
16835
17409
  }
16836
17410
  second = (code1 - 48) * 10 + (code2 - 48);
16837
17411
  }
16838
- const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
16839
- return result.getUTCDay() === weekday ? result : void 0;
17412
+ return makeDate(year, monthIdx, day, hour, minute, second, weekday);
16840
17413
  }
16841
17414
  function parseAscTimeDate(date) {
16842
17415
  if (date.length !== 24 || date[7] !== " " || date[10] !== " " || date[19] !== " ") {
@@ -16998,8 +17571,7 @@ var require_date = __commonJS({
16998
17571
  return void 0;
16999
17572
  }
17000
17573
  const year = (yearDigit1 - 48) * 1e3 + (yearDigit2 - 48) * 100 + (yearDigit3 - 48) * 10 + (yearDigit4 - 48);
17001
- const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
17002
- return result.getUTCDay() === weekday ? result : void 0;
17574
+ return makeDate(year, monthIdx, day, hour, minute, second, weekday);
17003
17575
  }
17004
17576
  function parseRfc850Date(date) {
17005
17577
  let commaIndex = -1;
@@ -17148,8 +17720,7 @@ var require_date = __commonJS({
17148
17720
  }
17149
17721
  second = (code1 - 48) * 10 + (code2 - 48);
17150
17722
  }
17151
- const result = new Date(Date.UTC(year, monthIdx, day, hour, minute, second));
17152
- return result.getUTCDay() === weekday ? result : void 0;
17723
+ return makeDate(year, monthIdx, day, hour, minute, second, weekday);
17153
17724
  }
17154
17725
  module2.exports = {
17155
17726
  parseHttpDate
@@ -17164,7 +17735,10 @@ var require_cache_handler = __commonJS({
17164
17735
  var util = require_util();
17165
17736
  var {
17166
17737
  parseCacheControlHeader,
17738
+ hasInvalidCacheControlDirective,
17167
17739
  parseVaryHeader,
17740
+ hasVaryStar,
17741
+ isInvalidOrWildcardVaryHeader,
17168
17742
  isEtagUsable
17169
17743
  } = require_cache();
17170
17744
  var { parseHttpDate } = require_date();
@@ -17189,6 +17763,78 @@ var require_cache_handler = __commonJS({
17189
17763
  ];
17190
17764
  var MAX_RESPONSE_AGE = 2147483647e3;
17191
17765
  var REVALIDATION_ONLY_RETENTION = 864e5;
17766
+ function trimOWS(value) {
17767
+ return value.replace(/^[\t ]+|[\t ]+$/g, "");
17768
+ }
17769
+ function arrayIncludes(array, value) {
17770
+ for (let i = 0; i < array.length; i++) {
17771
+ if (array[i] === value) {
17772
+ return true;
17773
+ }
17774
+ }
17775
+ return false;
17776
+ }
17777
+ function appendConnectionHeaderTokens(headersToRemove, connectionHeader) {
17778
+ const values = Array.isArray(connectionHeader) ? connectionHeader : [connectionHeader];
17779
+ for (let i = 0; i < values.length; i++) {
17780
+ const tokens = values[i].split(",");
17781
+ for (let j = 0; j < tokens.length; j++) {
17782
+ headersToRemove.push(trimOWS(tokens[j]).toLowerCase());
17783
+ }
17784
+ }
17785
+ }
17786
+ function getSameOriginPath(cacheKey, location) {
17787
+ if (typeof location !== "string") {
17788
+ return void 0;
17789
+ }
17790
+ let originUrl;
17791
+ let requestUrl;
17792
+ let locationUrl;
17793
+ try {
17794
+ originUrl = new URL(cacheKey.origin);
17795
+ requestUrl = new URL(cacheKey.path, originUrl);
17796
+ locationUrl = new URL(location, requestUrl);
17797
+ } catch {
17798
+ return void 0;
17799
+ }
17800
+ if (locationUrl.origin !== originUrl.origin) {
17801
+ return void 0;
17802
+ }
17803
+ return locationUrl.pathname + locationUrl.search;
17804
+ }
17805
+ function deleteCachedUri(store, cacheKey, path6) {
17806
+ deleteCachedValue(store, {
17807
+ ...cacheKey,
17808
+ path: path6
17809
+ });
17810
+ for (let i = 0; i < util.safeHTTPMethods.length; i++) {
17811
+ const method = util.safeHTTPMethods[i];
17812
+ if (method !== cacheKey.method) {
17813
+ deleteCachedValue(store, {
17814
+ ...cacheKey,
17815
+ method,
17816
+ path: path6
17817
+ });
17818
+ }
17819
+ }
17820
+ }
17821
+ function deleteLocationTargets(store, cacheKey, headerValue) {
17822
+ if (headerValue === void 0) {
17823
+ return;
17824
+ }
17825
+ const values = Array.isArray(headerValue) ? headerValue : [headerValue];
17826
+ for (let i = 0; i < values.length; i++) {
17827
+ const path6 = getSameOriginPath(cacheKey, values[i]);
17828
+ if (path6 !== void 0) {
17829
+ deleteCachedUri(store, cacheKey, path6);
17830
+ }
17831
+ }
17832
+ }
17833
+ function invalidateUnsafeRequest(store, cacheKey, resHeaders) {
17834
+ deleteCachedUri(store, cacheKey, cacheKey.path);
17835
+ deleteLocationTargets(store, cacheKey, resHeaders.location);
17836
+ deleteLocationTargets(store, cacheKey, resHeaders["content-location"]);
17837
+ }
17192
17838
  var CacheHandler = class {
17193
17839
  /**
17194
17840
  * @type {import('../../types/cache-interceptor.d.ts').default.CacheKey}
@@ -17248,38 +17894,51 @@ var require_cache_handler = __commonJS({
17248
17894
  statusMessage
17249
17895
  );
17250
17896
  const handler = this;
17251
- if (!util.safeHTTPMethods.includes(this.#cacheKey.method) && statusCode >= 200 && statusCode <= 399) {
17252
- try {
17253
- this.#store.delete(this.#cacheKey)?.catch?.(noop);
17254
- } catch {
17255
- }
17256
- this.#deleteLocationHeaderEntries(resHeaders);
17897
+ if (!arrayIncludes(util.safeHTTPMethods, this.#cacheKey.method) && statusCode >= 200 && statusCode <= 399) {
17898
+ invalidateUnsafeRequest(this.#store, this.#cacheKey, resHeaders);
17257
17899
  return downstreamOnHeaders();
17258
17900
  }
17259
17901
  const cacheControlHeader = resHeaders["cache-control"];
17260
- const heuristicallyCacheable = resHeaders["last-modified"] && HEURISTICALLY_CACHEABLE_STATUS_CODES.includes(statusCode);
17902
+ const heuristicallyCacheable = resHeaders["last-modified"] && arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, statusCode);
17261
17903
  if (!cacheControlHeader && !resHeaders["expires"] && !heuristicallyCacheable && !this.#cacheByDefault) {
17904
+ if (statusCode === 304 && resHeaders.vary && isInvalidOrWildcardVaryHeader(resHeaders.vary)) {
17905
+ deleteCachedValue(this.#store, this.#cacheKey);
17906
+ }
17262
17907
  return downstreamOnHeaders();
17263
17908
  }
17264
17909
  const cacheControlDirectives = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
17265
17910
  if (!canCacheResponse(this.#cacheType, statusCode, resHeaders, cacheControlDirectives, this.#cacheKey.headers)) {
17911
+ if (statusCode === 304 && (cacheControlHeader || revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives))) {
17912
+ deleteCachedValue(this.#store, this.#cacheKey);
17913
+ }
17266
17914
  return downstreamOnHeaders();
17267
17915
  }
17268
17916
  const now = Date.now();
17269
- const resAge = resHeaders.age ? getAge(resHeaders.age) : void 0;
17270
- if (resAge && resAge >= MAX_RESPONSE_AGE) {
17917
+ const resAge = Object.hasOwn(resHeaders, "age") ? getAge(resHeaders.age) : void 0;
17918
+ if (resAge !== void 0 && resAge >= MAX_RESPONSE_AGE) {
17919
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
17920
+ return downstreamOnHeaders();
17921
+ }
17922
+ const resDate = Object.hasOwn(resHeaders, "date") ? getDate(resHeaders.date) : void 0;
17923
+ if (resDate === null) {
17924
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
17271
17925
  return downstreamOnHeaders();
17272
17926
  }
17273
- const resDate = typeof resHeaders.date === "string" ? parseHttpDate(resHeaders.date) : void 0;
17927
+ const apparentAge = resDate ? Math.max(0, now - resDate.getTime()) : 0;
17928
+ const currentAge = Math.max(apparentAge, resAge ?? 0);
17274
17929
  const hasValidator = typeof resHeaders.etag === "string" && isEtagUsable(resHeaders.etag) || typeof resHeaders["last-modified"] === "string";
17275
17930
  const staleAt = determineStaleAt(this.#cacheType, now, resAge, resHeaders, resDate, cacheControlDirectives, hasValidator) ?? this.#cacheByDefault;
17276
- if (staleAt === void 0 || resAge && resAge > staleAt) {
17931
+ const revalidationOnly = staleAt === 0 && hasValidator;
17932
+ if (staleAt === void 0 || currentAge >= staleAt && !revalidationOnly) {
17933
+ if (cacheControlHeader || staleAt !== void 0) {
17934
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
17935
+ }
17277
17936
  return downstreamOnHeaders();
17278
17937
  }
17279
- const baseTime = resDate ? resDate.getTime() : now;
17938
+ const baseTime = now - currentAge;
17280
17939
  const absoluteStaleAt = staleAt + baseTime;
17281
- const revalidationOnly = staleAt === 0 && hasValidator;
17282
17940
  if (now >= absoluteStaleAt && !revalidationOnly) {
17941
+ deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
17283
17942
  return downstreamOnHeaders();
17284
17943
  }
17285
17944
  let varyDirectives;
@@ -17289,8 +17948,8 @@ var require_cache_handler = __commonJS({
17289
17948
  return downstreamOnHeaders();
17290
17949
  }
17291
17950
  }
17292
- const cachedAt = resAge ? now - resAge : now;
17293
- const deleteAt = determineDeleteAt(baseTime, cachedAt, cacheControlDirectives, absoluteStaleAt);
17951
+ const cachedAt = baseTime;
17952
+ const deleteAt = determineDeleteAt(baseTime, now, cacheControlDirectives, absoluteStaleAt);
17294
17953
  const strippedHeaders = stripNecessaryHeaders(resHeaders, cacheControlDirectives);
17295
17954
  const value = {
17296
17955
  statusCode,
@@ -17310,6 +17969,7 @@ var require_cache_handler = __commonJS({
17310
17969
  value.statusCode = cachedValue.statusCode;
17311
17970
  value.statusMessage = cachedValue.statusMessage;
17312
17971
  value.etag = cachedValue.etag;
17972
+ value.vary = varyDirectives ?? cachedValue.vary;
17313
17973
  value.headers = { ...cachedValue.headers, ...strippedHeaders };
17314
17974
  downstreamOnHeaders();
17315
17975
  this.#writeStream = this.#store.createWriteStream(this.#cacheKey, value);
@@ -17384,47 +18044,6 @@ var require_cache_handler = __commonJS({
17384
18044
  downstreamOnHeaders();
17385
18045
  }
17386
18046
  }
17387
- /**
17388
- * Deletes the cache entries for the URIs in the response's Location and
17389
- * Content-Location headers when they share the request URI's origin
17390
- * https://www.rfc-editor.org/rfc/rfc9111.html#section-4.4
17391
- *
17392
- * @param {import('../../types/header.d.ts').IncomingHttpHeaders} resHeaders
17393
- */
17394
- #deleteLocationHeaderEntries(resHeaders) {
17395
- let requestUrl;
17396
- try {
17397
- requestUrl = new URL(this.#cacheKey.path, this.#cacheKey.origin);
17398
- } catch {
17399
- return;
17400
- }
17401
- const invalidatedPaths = /* @__PURE__ */ new Set([this.#cacheKey.path]);
17402
- for (const headerName of ["location", "content-location"]) {
17403
- const header = resHeaders[headerName];
17404
- const value = Array.isArray(header) ? header[0] : header;
17405
- if (typeof value !== "string" || value === "") {
17406
- continue;
17407
- }
17408
- let url;
17409
- try {
17410
- url = new URL(value, requestUrl);
17411
- } catch {
17412
- continue;
17413
- }
17414
- if (url.origin !== requestUrl.origin) {
17415
- continue;
17416
- }
17417
- const path5 = `${url.pathname}${url.search}`;
17418
- if (invalidatedPaths.has(path5)) {
17419
- continue;
17420
- }
17421
- invalidatedPaths.add(path5);
17422
- try {
17423
- this.#store.delete({ ...this.#cacheKey, path: path5 })?.catch?.(noop);
17424
- } catch {
17425
- }
17426
- }
17427
- }
17428
18047
  onResponseData(controller, chunk) {
17429
18048
  if (this.#writeStream?.write(chunk) === false) {
17430
18049
  controller.pause();
@@ -17441,11 +18060,25 @@ var require_cache_handler = __commonJS({
17441
18060
  this.#handler.onResponseError?.(controller, err);
17442
18061
  }
17443
18062
  };
18063
+ function deleteCachedValue(store, cacheKey) {
18064
+ try {
18065
+ store.delete(cacheKey)?.catch?.(noop);
18066
+ } catch {
18067
+ }
18068
+ }
18069
+ function deleteCachedValueIfNotModified(statusCode, store, cacheKey) {
18070
+ if (statusCode === 304) {
18071
+ deleteCachedValue(store, cacheKey);
18072
+ }
18073
+ }
18074
+ function revalidationResponseDisallowsCachedReuse(cacheType, resHeaders, cacheControlDirectives) {
18075
+ return cacheControlDirectives["no-store"] === true || cacheType === "shared" && cacheControlDirectives.private === true || (resHeaders.vary ? isInvalidOrWildcardVaryHeader(resHeaders.vary) : false);
18076
+ }
17444
18077
  function canCacheResponse(cacheType, statusCode, resHeaders, cacheControlDirectives, reqHeaders) {
17445
- if (statusCode < 200 || NOT_UNDERSTOOD_STATUS_CODES.includes(statusCode)) {
18078
+ if (statusCode < 200 || arrayIncludes(NOT_UNDERSTOOD_STATUS_CODES, statusCode)) {
17446
18079
  return false;
17447
18080
  }
17448
- if (!HEURISTICALLY_CACHEABLE_STATUS_CODES.includes(statusCode) && !resHeaders["expires"] && !cacheControlDirectives.public && cacheControlDirectives["max-age"] === void 0 && // RFC 9111: a private response directive, if the cache is not shared
18081
+ if (!arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, statusCode) && !resHeaders["expires"] && !cacheControlDirectives.public && cacheControlDirectives["max-age"] === void 0 && // RFC 9111: a private response directive, if the cache is not shared
17449
18082
  !(cacheControlDirectives.private && cacheType === "private") && !(cacheControlDirectives["s-maxage"] !== void 0 && cacheType === "shared")) {
17450
18083
  return false;
17451
18084
  }
@@ -17455,66 +18088,104 @@ var require_cache_handler = __commonJS({
17455
18088
  if (cacheType === "shared" && cacheControlDirectives.private === true) {
17456
18089
  return false;
17457
18090
  }
17458
- if (resHeaders.vary?.includes("*")) {
18091
+ if (resHeaders.vary && hasVaryStar(resHeaders.vary)) {
17459
18092
  return false;
17460
18093
  }
17461
- if (reqHeaders?.authorization) {
18094
+ if (reqHeaders != null && Object.hasOwn(reqHeaders, "authorization")) {
17462
18095
  if (!cacheControlDirectives.public && !cacheControlDirectives["s-maxage"] && !cacheControlDirectives["must-revalidate"]) {
17463
18096
  return false;
17464
18097
  }
17465
18098
  if (typeof reqHeaders.authorization !== "string") {
17466
18099
  return false;
17467
18100
  }
17468
- if (Array.isArray(cacheControlDirectives["no-cache"]) && cacheControlDirectives["no-cache"].includes("authorization")) {
18101
+ if (Array.isArray(cacheControlDirectives["no-cache"]) && arrayIncludes(cacheControlDirectives["no-cache"], "authorization")) {
17469
18102
  return false;
17470
18103
  }
17471
- if (Array.isArray(cacheControlDirectives["private"]) && cacheControlDirectives["private"].includes("authorization")) {
18104
+ if (Array.isArray(cacheControlDirectives["private"]) && arrayIncludes(cacheControlDirectives["private"], "authorization")) {
17472
18105
  return false;
17473
18106
  }
17474
18107
  }
17475
18108
  return true;
17476
18109
  }
18110
+ function getDate(dateHeader) {
18111
+ let dateValue = dateHeader;
18112
+ if (Array.isArray(dateValue)) {
18113
+ if (dateValue.length !== 1) {
18114
+ return null;
18115
+ }
18116
+ dateValue = dateValue[0];
18117
+ }
18118
+ if (typeof dateValue !== "string") {
18119
+ return null;
18120
+ }
18121
+ return parseHttpDate(dateValue);
18122
+ }
17477
18123
  function getAge(ageHeader) {
17478
- const age = parseInt(Array.isArray(ageHeader) ? ageHeader[0] : ageHeader);
17479
- return isNaN(age) ? void 0 : age * 1e3;
18124
+ let ageValue = ageHeader;
18125
+ if (Array.isArray(ageValue)) {
18126
+ if (ageValue.length !== 1) {
18127
+ return MAX_RESPONSE_AGE;
18128
+ }
18129
+ ageValue = ageValue[0];
18130
+ }
18131
+ if (typeof ageValue !== "string" || !/^[\t ]*[0-9]+[\t ]*$/.test(ageValue)) {
18132
+ return MAX_RESPONSE_AGE;
18133
+ }
18134
+ const age = BigInt(ageValue.replace(/^[\t ]+|[\t ]+$/g, ""));
18135
+ if (age >= BigInt(MAX_RESPONSE_AGE / 1e3)) {
18136
+ return MAX_RESPONSE_AGE;
18137
+ }
18138
+ return Number(age) * 1e3;
17480
18139
  }
17481
18140
  function determineStaleAt(cacheType, now, age, resHeaders, responseDate, cacheControlDirectives, hasValidator) {
17482
18141
  if (cacheType === "shared") {
18142
+ if (hasInvalidCacheControlDirective(cacheControlDirectives, "s-maxage")) {
18143
+ return 0;
18144
+ }
17483
18145
  const sMaxAge = cacheControlDirectives["s-maxage"];
17484
18146
  if (sMaxAge !== void 0) {
17485
18147
  if (sMaxAge > 0) {
17486
18148
  return sMaxAge * 1e3;
17487
18149
  }
17488
- return sMaxAge === 0 && hasValidator ? 0 : void 0;
18150
+ return 0;
17489
18151
  }
17490
18152
  }
18153
+ if (hasInvalidCacheControlDirective(cacheControlDirectives, "max-age")) {
18154
+ return 0;
18155
+ }
17491
18156
  const maxAge = cacheControlDirectives["max-age"];
17492
18157
  if (maxAge !== void 0) {
17493
18158
  if (maxAge > 0) {
17494
18159
  return maxAge * 1e3;
17495
18160
  }
17496
- return maxAge === 0 && hasValidator ? 0 : void 0;
18161
+ return 0;
17497
18162
  }
17498
- if (typeof resHeaders.expires === "string") {
18163
+ if (Object.hasOwn(resHeaders, "expires")) {
18164
+ if (typeof resHeaders.expires !== "string") {
18165
+ return 0;
18166
+ }
17499
18167
  const expiresDate = parseHttpDate(resHeaders.expires);
17500
- if (expiresDate) {
17501
- if (now >= expiresDate.getTime()) {
17502
- return void 0;
18168
+ if (!expiresDate) {
18169
+ return 0;
18170
+ }
18171
+ if (now >= expiresDate.getTime()) {
18172
+ return 0;
18173
+ }
18174
+ if (responseDate) {
18175
+ if (responseDate >= expiresDate) {
18176
+ return 0;
17503
18177
  }
17504
- if (responseDate) {
17505
- if (responseDate >= expiresDate) {
17506
- return void 0;
17507
- }
17508
- if (age !== void 0 && age > expiresDate - responseDate) {
17509
- return void 0;
17510
- }
18178
+ const freshnessLifetime = expiresDate.getTime() - responseDate.getTime();
18179
+ if (age !== void 0 && age >= freshnessLifetime) {
18180
+ return 0;
17511
18181
  }
17512
- return expiresDate.getTime() - now;
18182
+ return freshnessLifetime;
17513
18183
  }
18184
+ return expiresDate.getTime() - now;
17514
18185
  }
17515
18186
  if (typeof resHeaders["last-modified"] === "string") {
17516
- const lastModified = new Date(resHeaders["last-modified"]);
17517
- if (isValidDate(lastModified)) {
18187
+ const lastModified = parseHttpDate(resHeaders["last-modified"]);
18188
+ if (lastModified) {
17518
18189
  if (lastModified.getTime() >= now) {
17519
18190
  return void 0;
17520
18191
  }
@@ -17567,11 +18238,7 @@ var require_cache_handler = __commonJS({
17567
18238
  "age"
17568
18239
  ];
17569
18240
  if (resHeaders["connection"]) {
17570
- if (Array.isArray(resHeaders["connection"])) {
17571
- headersToRemove.push(...resHeaders["connection"].map((header) => header.trim()));
17572
- } else {
17573
- headersToRemove.push(...resHeaders["connection"].split(",").map((header) => header.trim()));
17574
- }
18241
+ appendConnectionHeaderTokens(headersToRemove, resHeaders["connection"]);
17575
18242
  }
17576
18243
  if (Array.isArray(cacheControlDirectives["no-cache"])) {
17577
18244
  headersToRemove.push(...cacheControlDirectives["no-cache"]);
@@ -17581,16 +18248,13 @@ var require_cache_handler = __commonJS({
17581
18248
  }
17582
18249
  let strippedHeaders;
17583
18250
  for (const headerName of headersToRemove) {
17584
- if (resHeaders[headerName]) {
18251
+ if (Object.hasOwn(resHeaders, headerName)) {
17585
18252
  strippedHeaders ??= { ...resHeaders };
17586
18253
  delete strippedHeaders[headerName];
17587
18254
  }
17588
18255
  }
17589
18256
  return strippedHeaders ?? resHeaders;
17590
18257
  }
17591
- function isValidDate(date) {
17592
- return date instanceof Date && Number.isFinite(date.valueOf());
17593
- }
17594
18258
  module2.exports = CacheHandler;
17595
18259
  }
17596
18260
  });
@@ -17761,12 +18425,43 @@ var require_memory_cache_store = __commonJS({
17761
18425
  }
17762
18426
  };
17763
18427
  function findEntry(key, entries, now) {
17764
- return entries.find((entry) => entry.deleteAt > now && entry.method === key.method && (entry.vary == null || Object.keys(entry.vary).every((headerName) => {
17765
- if (entry.vary[headerName] === null) {
17766
- return key.headers[headerName] === void 0;
18428
+ for (let i = 0; i < entries.length; i++) {
18429
+ const entry = entries[i];
18430
+ if (entry.deleteAt > now && entry.method === key.method && varyMatches(key, entry)) {
18431
+ return entry;
17767
18432
  }
17768
- return entry.vary[headerName] === key.headers[headerName];
17769
- })));
18433
+ }
18434
+ }
18435
+ function varyMatches(key, entry) {
18436
+ if (entry.vary == null) {
18437
+ return true;
18438
+ }
18439
+ for (const headerName in entry.vary) {
18440
+ if (Object.hasOwn(entry.vary, headerName) && !headerValueEquals(key.headers?.[headerName], entry.vary[headerName])) {
18441
+ return false;
18442
+ }
18443
+ }
18444
+ return true;
18445
+ }
18446
+ function headerValueEquals(lhs, rhs) {
18447
+ if (lhs == null && rhs == null) {
18448
+ return true;
18449
+ }
18450
+ if (lhs == null && rhs != null || lhs != null && rhs == null) {
18451
+ return false;
18452
+ }
18453
+ if (Array.isArray(lhs) && Array.isArray(rhs)) {
18454
+ if (lhs.length !== rhs.length) {
18455
+ return false;
18456
+ }
18457
+ for (let i = 0; i < lhs.length; i++) {
18458
+ if (lhs[i] !== rhs[i]) {
18459
+ return false;
18460
+ }
18461
+ }
18462
+ return true;
18463
+ }
18464
+ return lhs === rhs;
17770
18465
  }
17771
18466
  module2.exports = MemoryCacheStore;
17772
18467
  }
@@ -17780,7 +18475,7 @@ var require_cache_revalidation_handler = __commonJS({
17780
18475
  var CacheRevalidationHandler = class {
17781
18476
  #successful = false;
17782
18477
  /**
17783
- * @type {((boolean, any) => void) | null}
18478
+ * @type {((success: boolean, context?: any, statusCode?: number, headers?: import('../../types/header.d.ts').IncomingHttpHeaders) => void) | null}
17784
18479
  */
17785
18480
  #callback;
17786
18481
  /**
@@ -17793,7 +18488,7 @@ var require_cache_revalidation_handler = __commonJS({
17793
18488
  */
17794
18489
  #allowErrorStatusCodes;
17795
18490
  /**
17796
- * @param {(boolean) => void} callback Function to call if the cached value is valid
18491
+ * @param {(success: boolean, context?: any, statusCode?: number, headers?: import('../../types/header.d.ts').IncomingHttpHeaders) => void} callback Function to call if the cached value is valid
17797
18492
  * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler
17798
18493
  * @param {boolean} allowErrorStatusCodes
17799
18494
  */
@@ -17815,7 +18510,7 @@ var require_cache_revalidation_handler = __commonJS({
17815
18510
  onResponseStart(controller, statusCode, headers, statusMessage) {
17816
18511
  assert(this.#callback != null);
17817
18512
  this.#successful = statusCode === 304 || this.#allowErrorStatusCodes && statusCode >= 500 && statusCode <= 504;
17818
- this.#callback(this.#successful, this.#context);
18513
+ this.#callback(this.#successful, this.#context, statusCode, headers);
17819
18514
  this.#callback = null;
17820
18515
  if (this.#successful) {
17821
18516
  return true;
@@ -17875,8 +18570,9 @@ var require_cache2 = __commonJS({
17875
18570
  var CacheHandler = require_cache_handler();
17876
18571
  var MemoryCacheStore = require_memory_cache_store();
17877
18572
  var CacheRevalidationHandler = require_cache_revalidation_handler();
17878
- var { assertCacheStore, assertCacheMethods, makeCacheKey, normalizeHeaders, parseCacheControlHeader } = require_cache();
18573
+ var { assertCacheStore, assertCacheMethods, makeCacheKey, normalizeHeaders, parseCacheControlHeader, isInvalidOrWildcardVaryHeader } = require_cache();
17879
18574
  var { AbortError } = require_errors();
18575
+ var { parseHttpDate } = require_date();
17880
18576
  function assertCacheOrigins(origins, name) {
17881
18577
  if (origins === void 0) return;
17882
18578
  if (!Array.isArray(origins)) {
@@ -17891,6 +18587,37 @@ var require_cache2 = __commonJS({
17891
18587
  }
17892
18588
  var nop = () => {
17893
18589
  };
18590
+ function trimOWS(value) {
18591
+ return value.replace(/^[\t ]+|[\t ]+$/g, "");
18592
+ }
18593
+ function arrayIncludes(array, value) {
18594
+ for (let i = 0; i < array.length; i++) {
18595
+ if (array[i] === value) {
18596
+ return true;
18597
+ }
18598
+ }
18599
+ return false;
18600
+ }
18601
+ function hasPragmaNoCache(headers) {
18602
+ const pragma = headers?.pragma;
18603
+ if (!pragma) {
18604
+ return false;
18605
+ }
18606
+ const values = Array.isArray(pragma) ? pragma : [pragma];
18607
+ for (let i = 0; i < values.length; i++) {
18608
+ const value = values[i];
18609
+ if (typeof value !== "string") {
18610
+ continue;
18611
+ }
18612
+ const directives = value.split(",");
18613
+ for (let j = 0; j < directives.length; j++) {
18614
+ if (trimOWS(directives[j]).toLowerCase() === "no-cache") {
18615
+ return true;
18616
+ }
18617
+ }
18618
+ }
18619
+ return false;
18620
+ }
17894
18621
  function needsRevalidation(result, cacheControlDirectives, { headers = {} }) {
17895
18622
  if (cacheControlDirectives?.["no-cache"]) {
17896
18623
  return true;
@@ -17903,15 +18630,58 @@ var require_cache2 = __commonJS({
17903
18630
  }
17904
18631
  return false;
17905
18632
  }
17906
- function forbidsServingStale(result, cacheType) {
17907
- return Boolean(
17908
- result.cacheControlDirectives?.["must-revalidate"] || cacheType === "shared" && result.cacheControlDirectives?.["proxy-revalidate"]
17909
- );
18633
+ function staleResponseRequiresRevalidation(result, cacheType) {
18634
+ return result.cacheControlDirectives?.["must-revalidate"] === true || cacheType === "shared" && (result.cacheControlDirectives?.["proxy-revalidate"] === true || // https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.2.10
18635
+ // s-maxage implies proxy-revalidate for shared caches.
18636
+ result.cacheControlDirectives?.["s-maxage"] !== void 0);
18637
+ }
18638
+ function revalidationResponseDisallowsCachedReuse(cacheType, headers) {
18639
+ if (headers.vary && isInvalidOrWildcardVaryHeader(headers.vary)) {
18640
+ return true;
18641
+ }
18642
+ const cacheControl = headers["cache-control"];
18643
+ if (!cacheControl) {
18644
+ return false;
18645
+ }
18646
+ const cacheControlDirectives = parseCacheControlHeader(cacheControl);
18647
+ return cacheControlDirectives["no-store"] === true || cacheType === "shared" && cacheControlDirectives.private === true;
18648
+ }
18649
+ function revalidationResponseUpdatesCacheControl(headers) {
18650
+ return headers["cache-control"] !== void 0;
18651
+ }
18652
+ function deleteCachedValue(store, cacheKey) {
18653
+ try {
18654
+ store.delete(cacheKey)?.catch?.(nop);
18655
+ } catch {
18656
+ }
18657
+ }
18658
+ function getUsableLastModified(headers) {
18659
+ const lastModified = headers?.["last-modified"];
18660
+ if (typeof lastModified === "string" && parseHttpDate(lastModified)) {
18661
+ return lastModified;
18662
+ }
18663
+ }
18664
+ function makeRevalidationHeaders(opts, result) {
18665
+ const headers = {
18666
+ ...opts.headers,
18667
+ "if-modified-since": getUsableLastModified(result.headers) ?? new Date(result.cachedAt).toUTCString()
18668
+ };
18669
+ if (result.etag) {
18670
+ headers["if-none-match"] = result.etag;
18671
+ }
18672
+ if (result.vary) {
18673
+ for (const key in result.vary) {
18674
+ if (result.vary[key] != null) {
18675
+ headers[key] = result.vary[key];
18676
+ }
18677
+ }
18678
+ }
18679
+ return headers;
17910
18680
  }
17911
18681
  function isStale(result, cacheControlDirectives, cacheType) {
17912
18682
  const now = Date.now();
17913
18683
  if (now > result.staleAt) {
17914
- if (cacheControlDirectives?.["max-stale"] && !forbidsServingStale(result, cacheType)) {
18684
+ if (!staleResponseRequiresRevalidation(result, cacheType) && cacheControlDirectives?.["max-stale"]) {
17915
18685
  const gracePeriod = result.staleAt + cacheControlDirectives["max-stale"] * 1e3;
17916
18686
  return now > gracePeriod;
17917
18687
  }
@@ -17924,9 +18694,9 @@ var require_cache2 = __commonJS({
17924
18694
  }
17925
18695
  return false;
17926
18696
  }
17927
- function withinStaleWhileRevalidateWindow(result) {
18697
+ function withinStaleWhileRevalidateWindow(result, cacheType) {
17928
18698
  const staleWhileRevalidate = result.cacheControlDirectives?.["stale-while-revalidate"];
17929
- if (!staleWhileRevalidate) {
18699
+ if (!staleWhileRevalidate || staleResponseRequiresRevalidation(result, cacheType)) {
17930
18700
  return false;
17931
18701
  }
17932
18702
  const now = Date.now();
@@ -18036,32 +18806,17 @@ var require_cache2 = __commonJS({
18036
18806
  return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
18037
18807
  }
18038
18808
  const age = Math.round((now - result.cachedAt) / 1e3);
18039
- if (reqCacheControl?.["max-age"] && age >= reqCacheControl["max-age"]) {
18040
- return dispatch(opts, handler);
18041
- }
18042
- const stale = isStale(result, reqCacheControl, globalOpts.type);
18043
- const revalidate = needsRevalidation(result, reqCacheControl, opts);
18809
+ const requestMaxAgeExpired = reqCacheControl?.["max-age"] !== void 0 && age >= reqCacheControl["max-age"];
18810
+ const stale = requestMaxAgeExpired || isStale(result, reqCacheControl, globalOpts.type);
18811
+ const revalidate = requestMaxAgeExpired || needsRevalidation(result, reqCacheControl, opts);
18044
18812
  if (stale || revalidate) {
18045
18813
  if (util.isStream(opts.body) && util.bodyLength(opts.body) !== 0) {
18046
18814
  return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
18047
18815
  }
18048
- if (!revalidate && withinStaleWhileRevalidateWindow(result)) {
18816
+ if (!revalidate && withinStaleWhileRevalidateWindow(result, globalOpts.type)) {
18049
18817
  sendCachedValue(handler, opts, result, age, null, true);
18050
18818
  queueMicrotask(() => {
18051
- const headers2 = {
18052
- ...opts.headers,
18053
- "if-modified-since": new Date(result.cachedAt).toUTCString()
18054
- };
18055
- if (result.etag) {
18056
- headers2["if-none-match"] = result.etag;
18057
- }
18058
- if (result.vary) {
18059
- for (const key in result.vary) {
18060
- if (result.vary[key] != null) {
18061
- headers2[key] = result.vary[key];
18062
- }
18063
- }
18064
- }
18819
+ const headers2 = makeRevalidationHeaders(opts, result);
18065
18820
  dispatch(
18066
18821
  {
18067
18822
  ...opts,
@@ -18087,32 +18842,33 @@ var require_cache2 = __commonJS({
18087
18842
  return true;
18088
18843
  }
18089
18844
  let withinStaleIfErrorThreshold = false;
18090
- const staleIfErrorExpiry = result.cacheControlDirectives["stale-if-error"] ?? reqCacheControl?.["stale-if-error"];
18091
- if (staleIfErrorExpiry && !forbidsServingStale(result, globalOpts.type)) {
18092
- withinStaleIfErrorThreshold = now < result.staleAt + staleIfErrorExpiry * 1e3;
18093
- }
18094
- const headers = {
18095
- ...opts.headers,
18096
- "if-modified-since": new Date(result.cachedAt).toUTCString()
18097
- };
18098
- if (result.etag) {
18099
- headers["if-none-match"] = result.etag;
18100
- }
18101
- if (result.vary) {
18102
- for (const key in result.vary) {
18103
- if (result.vary[key] != null) {
18104
- headers[key] = result.vary[key];
18105
- }
18845
+ if (!staleResponseRequiresRevalidation(result, globalOpts.type)) {
18846
+ const staleIfErrorExpiry = result.cacheControlDirectives["stale-if-error"] ?? reqCacheControl?.["stale-if-error"];
18847
+ if (staleIfErrorExpiry) {
18848
+ withinStaleIfErrorThreshold = now < result.staleAt + staleIfErrorExpiry * 1e3;
18106
18849
  }
18107
18850
  }
18851
+ const headers = makeRevalidationHeaders(opts, result);
18108
18852
  return dispatch(
18109
18853
  {
18110
18854
  ...opts,
18111
18855
  headers
18112
18856
  },
18113
18857
  new CacheRevalidationHandler(
18114
- (success, context) => {
18858
+ (success, context, statusCode, headers2) => {
18115
18859
  if (success) {
18860
+ if (statusCode === 304) {
18861
+ if (revalidationResponseDisallowsCachedReuse(globalOpts.type, headers2)) {
18862
+ if (util.isStream(result.body)) {
18863
+ result.body.on("error", nop).destroy();
18864
+ }
18865
+ deleteCachedValue(globalOpts.store, cacheKey);
18866
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
18867
+ }
18868
+ if (revalidationResponseUpdatesCacheControl(headers2)) {
18869
+ deleteCachedValue(globalOpts.store, cacheKey);
18870
+ }
18871
+ }
18116
18872
  sendCachedValue(handler, opts, result, age, context, stale);
18117
18873
  } else if (util.isStream(result.body)) {
18118
18874
  result.body.on("error", nop).destroy();
@@ -18154,13 +18910,22 @@ var require_cache2 = __commonJS({
18154
18910
  cacheByDefault,
18155
18911
  type
18156
18912
  };
18157
- const safeMethodsToNotCache = util.safeHTTPMethods.filter((method) => methods.includes(method) === false);
18913
+ const safeMethodsToNotCache = [];
18914
+ for (let i = 0; i < util.safeHTTPMethods.length; i++) {
18915
+ const method = util.safeHTTPMethods[i];
18916
+ if (!arrayIncludes(methods, method)) {
18917
+ safeMethodsToNotCache.push(method);
18918
+ }
18919
+ }
18158
18920
  return (dispatch) => {
18159
18921
  return (opts2, handler) => {
18160
- if (!opts2.origin || safeMethodsToNotCache.includes(opts2.method)) {
18922
+ if (arrayIncludes(safeMethodsToNotCache, opts2.method)) {
18161
18923
  return dispatch(opts2, handler);
18162
18924
  }
18163
18925
  if (origins !== void 0) {
18926
+ if (!opts2.origin) {
18927
+ return dispatch(opts2, handler);
18928
+ }
18164
18929
  const requestOrigin = opts2.origin.toString().toLowerCase();
18165
18930
  let isAllowed = false;
18166
18931
  for (let i = 0; i < origins.length; i++) {
@@ -18183,7 +18948,7 @@ var require_cache2 = __commonJS({
18183
18948
  ...opts2,
18184
18949
  headers: normalizeHeaders(opts2)
18185
18950
  };
18186
- const reqCacheControl = opts2.headers?.["cache-control"] ? parseCacheControlHeader(opts2.headers["cache-control"]) : void 0;
18951
+ const reqCacheControl = opts2.headers?.["cache-control"] ? parseCacheControlHeader(opts2.headers["cache-control"]) : hasPragmaNoCache(opts2.headers) ? { "no-cache": true } : void 0;
18187
18952
  if (reqCacheControl?.["no-store"]) {
18188
18953
  return dispatch(opts2, handler);
18189
18954
  }
@@ -18243,6 +19008,8 @@ var require_decompress = __commonJS({
18243
19008
  var DecompressHandler = class extends DecoratorHandler {
18244
19009
  /** @type {Transform[]} */
18245
19010
  #decompressors = [];
19011
+ /** @type {Record<string, string | string[]> | undefined} */
19012
+ #trailers;
18246
19013
  /** @type {Readonly<number[]>} */
18247
19014
  #skipStatusCodes;
18248
19015
  /** @type {boolean} */
@@ -18318,7 +19085,7 @@ var require_decompress = __commonJS({
18318
19085
  const decompressor = this.#decompressors[0];
18319
19086
  this.#setupDecompressorEvents(decompressor, controller);
18320
19087
  decompressor.on("end", () => {
18321
- super.onResponseEnd(controller, {});
19088
+ super.onResponseEnd(controller, this.#trailers);
18322
19089
  });
18323
19090
  }
18324
19091
  /**
@@ -18334,7 +19101,7 @@ var require_decompress = __commonJS({
18334
19101
  super.onResponseError(controller, err);
18335
19102
  return;
18336
19103
  }
18337
- super.onResponseEnd(controller, {});
19104
+ super.onResponseEnd(controller, this.#trailers);
18338
19105
  });
18339
19106
  }
18340
19107
  /**
@@ -18412,6 +19179,7 @@ var require_decompress = __commonJS({
18412
19179
  */
18413
19180
  onResponseEnd(controller, trailers) {
18414
19181
  if (this.#decompressors.length > 0) {
19182
+ this.#trailers = trailers;
18415
19183
  this.#decompressors[0].end();
18416
19184
  this.#cleanupDecompressors();
18417
19185
  return;
@@ -18855,7 +19623,7 @@ var require_deduplicate = __commonJS({
18855
19623
  const pendingRequests = /* @__PURE__ */ new Map();
18856
19624
  return (dispatch) => {
18857
19625
  return (opts2, handler) => {
18858
- if (!opts2.origin || methods.includes(opts2.method) === false) {
19626
+ if (opts2.upgrade || methods.includes(opts2.method) === false) {
18859
19627
  return dispatch(opts2, handler);
18860
19628
  }
18861
19629
  opts2 = {
@@ -19253,7 +20021,12 @@ var require_sqlite_cache_store = __commonJS({
19253
20021
  if (lhs.length !== rhs.length) {
19254
20022
  return false;
19255
20023
  }
19256
- return lhs.every((x, i) => x === rhs[i]);
20024
+ for (let i = 0; i < lhs.length; i++) {
20025
+ if (lhs[i] !== rhs[i]) {
20026
+ return false;
20027
+ }
20028
+ }
20029
+ return true;
19257
20030
  }
19258
20031
  return lhs === rhs;
19259
20032
  }
@@ -20206,7 +20979,7 @@ var require_request2 = __commonJS({
20206
20979
  }
20207
20980
  }
20208
20981
  var patchMethodWarning = false;
20209
- var Request = class _Request {
20982
+ var Request2 = class _Request {
20210
20983
  /** @type {AbortSignal} */
20211
20984
  #signal;
20212
20985
  /** @type {import('../../dispatcher/dispatcher')} */
@@ -20711,15 +21484,15 @@ var require_request2 = __commonJS({
20711
21484
  request.#abortCleanup?.();
20712
21485
  }
20713
21486
  };
20714
- var { setRequestSignal, getRequestDispatcher, setRequestDispatcher, setRequestHeaders, getRequestState, setRequestState, removeRequestAbortListener } = Request;
20715
- Reflect.deleteProperty(Request, "setRequestSignal");
20716
- Reflect.deleteProperty(Request, "getRequestDispatcher");
20717
- Reflect.deleteProperty(Request, "setRequestDispatcher");
20718
- Reflect.deleteProperty(Request, "setRequestHeaders");
20719
- Reflect.deleteProperty(Request, "getRequestState");
20720
- Reflect.deleteProperty(Request, "setRequestState");
20721
- Reflect.deleteProperty(Request, "removeRequestAbortListener");
20722
- mixinBody(Request, getRequestState);
21487
+ var { setRequestSignal, getRequestDispatcher, setRequestDispatcher, setRequestHeaders, getRequestState, setRequestState, removeRequestAbortListener } = Request2;
21488
+ Reflect.deleteProperty(Request2, "setRequestSignal");
21489
+ Reflect.deleteProperty(Request2, "getRequestDispatcher");
21490
+ Reflect.deleteProperty(Request2, "setRequestDispatcher");
21491
+ Reflect.deleteProperty(Request2, "setRequestHeaders");
21492
+ Reflect.deleteProperty(Request2, "getRequestState");
21493
+ Reflect.deleteProperty(Request2, "setRequestState");
21494
+ Reflect.deleteProperty(Request2, "removeRequestAbortListener");
21495
+ mixinBody(Request2, getRequestState);
20723
21496
  function makeRequest(init) {
20724
21497
  return {
20725
21498
  method: init.method ?? "GET",
@@ -20773,7 +21546,7 @@ var require_request2 = __commonJS({
20773
21546
  return newRequest;
20774
21547
  }
20775
21548
  function fromInnerRequest(innerRequest, dispatcher, signal, guard) {
20776
- const request = new Request(kConstruct);
21549
+ const request = new Request2(kConstruct);
20777
21550
  setRequestState(request, innerRequest);
20778
21551
  setRequestDispatcher(request, dispatcher);
20779
21552
  setRequestSignal(request, signal);
@@ -20783,7 +21556,7 @@ var require_request2 = __commonJS({
20783
21556
  setHeadersGuard(headers, guard);
20784
21557
  return request;
20785
21558
  }
20786
- Object.defineProperties(Request.prototype, {
21559
+ Object.defineProperties(Request2.prototype, {
20787
21560
  method: kEnumerableProperty,
20788
21561
  url: kEnumerableProperty,
20789
21562
  headers: kEnumerableProperty,
@@ -20809,7 +21582,7 @@ var require_request2 = __commonJS({
20809
21582
  configurable: true
20810
21583
  }
20811
21584
  });
20812
- webidl.is.Request = webidl.util.MakeTypeAssertion(Request);
21585
+ webidl.is.Request = webidl.util.MakeTypeAssertion(Request2);
20813
21586
  webidl.converters.RequestInfo = function(V) {
20814
21587
  if (typeof V === "string") {
20815
21588
  return webidl.converters.USVString(V);
@@ -20908,7 +21681,7 @@ var require_request2 = __commonJS({
20908
21681
  }
20909
21682
  ]);
20910
21683
  module2.exports = {
20911
- Request,
21684
+ Request: Request2,
20912
21685
  makeRequest,
20913
21686
  fromInnerRequest,
20914
21687
  cloneRequest,
@@ -21071,7 +21844,7 @@ var require_fetch = __commonJS({
21071
21844
  getResponseState
21072
21845
  } = require_response();
21073
21846
  var { HeadersList } = require_headers();
21074
- var { Request, cloneRequest, getRequestDispatcher, getRequestState, removeRequestAbortListener } = require_request2();
21847
+ var { Request: Request2, cloneRequest, getRequestDispatcher, getRequestState, removeRequestAbortListener } = require_request2();
21075
21848
  var zlib = require("node:zlib");
21076
21849
  var {
21077
21850
  makePolicyContainer,
@@ -21191,7 +21964,7 @@ var require_fetch = __commonJS({
21191
21964
  let p = Promise.withResolvers();
21192
21965
  let requestObject;
21193
21966
  try {
21194
- requestObject = new Request(input, init);
21967
+ requestObject = new Request2(input, init);
21195
21968
  } catch (e) {
21196
21969
  p.reject(e);
21197
21970
  return p.promise;
@@ -22050,13 +22823,13 @@ var require_fetch = __commonJS({
22050
22823
  function dispatch({ body }) {
22051
22824
  const url = requestCurrentURL(request);
22052
22825
  const agent = fetchParams.controller.dispatcher;
22053
- const path5 = url.pathname + url.search;
22826
+ const path6 = url.pathname + url.search;
22054
22827
  const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
22055
22828
  return dispatchWithProtocolPreference(body);
22056
22829
  function dispatchWithProtocolPreference(body2, allowH2) {
22057
22830
  return new Promise((resolve2, reject) => agent.dispatch(
22058
22831
  {
22059
- path: hasTrailingQuestionMark ? `${path5}?` : path5,
22832
+ path: hasTrailingQuestionMark ? `${path6}?` : path6,
22060
22833
  origin: url.origin,
22061
22834
  method: request.method,
22062
22835
  body: agent.isMockActive ? request.body && (request.body.source || request.body.stream) : body2,
@@ -22246,7 +23019,7 @@ var require_cache3 = __commonJS({
22246
23019
  var { kEnumerableProperty, isDisturbed } = require_util();
22247
23020
  var { webidl } = require_webidl();
22248
23021
  var { cloneResponse, fromInnerResponse, getResponseState } = require_response();
22249
- var { Request, fromInnerRequest, getRequestState } = require_request2();
23022
+ var { Request: Request2, fromInnerRequest, getRequestState } = require_request2();
22250
23023
  var { fetching } = require_fetch();
22251
23024
  var { urlIsHttpHttpsScheme, readAllBytes } = require_util2();
22252
23025
  var Cache = class _Cache {
@@ -22318,7 +23091,7 @@ var require_cache3 = __commonJS({
22318
23091
  }
22319
23092
  const fetchControllers = [];
22320
23093
  for (const request of requests) {
22321
- const r = getRequestState(new Request(request));
23094
+ const r = getRequestState(new Request2(request));
22322
23095
  if (!urlIsHttpHttpsScheme(r.url)) {
22323
23096
  throw webidl.errors.exception({
22324
23097
  header: prefix,
@@ -22405,7 +23178,7 @@ var require_cache3 = __commonJS({
22405
23178
  if (webidl.is.Request(request)) {
22406
23179
  innerRequest = getRequestState(request);
22407
23180
  } else {
22408
- innerRequest = getRequestState(new Request(request));
23181
+ innerRequest = getRequestState(new Request2(request));
22409
23182
  }
22410
23183
  if (!urlIsHttpHttpsScheme(innerRequest.url) || innerRequest.method !== "GET") {
22411
23184
  throw webidl.errors.exception({
@@ -22490,7 +23263,7 @@ var require_cache3 = __commonJS({
22490
23263
  }
22491
23264
  } else {
22492
23265
  assert(typeof request === "string");
22493
- r = getRequestState(new Request(request));
23266
+ r = getRequestState(new Request2(request));
22494
23267
  }
22495
23268
  const operations = [];
22496
23269
  const operation = {
@@ -22535,7 +23308,7 @@ var require_cache3 = __commonJS({
22535
23308
  return [];
22536
23309
  }
22537
23310
  } else if (typeof request === "string") {
22538
- r = getRequestState(new Request(request));
23311
+ r = getRequestState(new Request2(request));
22539
23312
  }
22540
23313
  }
22541
23314
  const promise = Promise.withResolvers();
@@ -22708,7 +23481,7 @@ var require_cache3 = __commonJS({
22708
23481
  return [];
22709
23482
  }
22710
23483
  } else if (typeof request === "string") {
22711
- r = getRequestState(new Request(request));
23484
+ r = getRequestState(new Request2(request));
22712
23485
  }
22713
23486
  }
22714
23487
  const responses = [];
@@ -22968,9 +23741,9 @@ var require_util4 = __commonJS({
22968
23741
  }
22969
23742
  }
22970
23743
  }
22971
- function validateCookiePath(path5) {
22972
- for (let i = 0; i < path5.length; ++i) {
22973
- const code = path5.charCodeAt(i);
23744
+ function validateCookiePath(path6) {
23745
+ for (let i = 0; i < path6.length; ++i) {
23746
+ const code = path6.charCodeAt(i);
22974
23747
  if (code < 32 || // exclude CTLs (0-31)
22975
23748
  code > 126 || // exclude non-ascii and DEL
22976
23749
  code === 59) {
@@ -22978,8 +23751,42 @@ var require_util4 = __commonJS({
22978
23751
  }
22979
23752
  }
22980
23753
  }
23754
+ function isLetterOrDigit(code) {
23755
+ return code >= 48 && code <= 57 || // 0-9
23756
+ code >= 65 && code <= 90 || // A-Z
23757
+ code >= 97 && code <= 122;
23758
+ }
22981
23759
  function validateCookieDomain(domain) {
22982
- if (domain.startsWith("-") || domain.endsWith(".") || domain.endsWith("-")) {
23760
+ if (domain === " ") {
23761
+ return;
23762
+ }
23763
+ if (domain.length > 255) {
23764
+ throw new Error("Invalid cookie domain");
23765
+ }
23766
+ let labelLength = 0;
23767
+ for (let i = 0; i < domain.length; ++i) {
23768
+ const code = domain.charCodeAt(i);
23769
+ if (code === 46) {
23770
+ if (labelLength === 0) {
23771
+ throw new Error("Invalid cookie domain");
23772
+ }
23773
+ if (domain.charCodeAt(i - 1) === 45) {
23774
+ throw new Error("Invalid cookie domain");
23775
+ }
23776
+ labelLength = 0;
23777
+ continue;
23778
+ }
23779
+ if (labelLength === 0 && !isLetterOrDigit(code)) {
23780
+ throw new Error("Invalid cookie domain");
23781
+ }
23782
+ if (!isLetterOrDigit(code) && code !== 45) {
23783
+ throw new Error("Invalid cookie domain");
23784
+ }
23785
+ if (++labelLength > 63) {
23786
+ throw new Error("Invalid cookie domain");
23787
+ }
23788
+ }
23789
+ if (labelLength === 0 || domain.charCodeAt(domain.length - 1) === 45) {
22983
23790
  throw new Error("Invalid cookie domain");
22984
23791
  }
22985
23792
  }
@@ -23062,7 +23869,11 @@ var require_util4 = __commonJS({
23062
23869
  throw new Error("Invalid unparsed");
23063
23870
  }
23064
23871
  const [key, ...value] = part.split("=");
23065
- out.push(`${key.trim()}=${value.join("=")}`);
23872
+ const trimmedKey = key.trim();
23873
+ const joinedValue = value.join("=");
23874
+ validateCookieName(trimmedKey);
23875
+ validateCookieValue(joinedValue);
23876
+ out.push(`${trimmedKey}=${joinedValue}`);
23066
23877
  }
23067
23878
  return out.join("; ");
23068
23879
  }
@@ -24662,6 +25473,8 @@ var require_websocket = __commonJS({
24662
25473
  var { SendQueue } = require_sender();
24663
25474
  var { WebsocketFrameSend } = require_frame();
24664
25475
  var { channels } = require_diagnostics();
25476
+ var kRef = /* @__PURE__ */ Symbol.for("nodejs.ref");
25477
+ var kUnref = /* @__PURE__ */ Symbol.for("nodejs.unref");
24665
25478
  function getSocketAddress(socket) {
24666
25479
  if (typeof socket?.address === "function") {
24667
25480
  return socket.address();
@@ -24681,6 +25494,7 @@ var require_websocket = __commonJS({
24681
25494
  #bufferedAmount = 0;
24682
25495
  #protocol = "";
24683
25496
  #extensions = "";
25497
+ #refed = true;
24684
25498
  /** @type {SendQueue} */
24685
25499
  #sendQueue;
24686
25500
  /** @type {Handler} */
@@ -24763,6 +25577,16 @@ var require_websocket = __commonJS({
24763
25577
  this.#handler.readyState = _WebSocket.CONNECTING;
24764
25578
  this.#binaryType = "blob";
24765
25579
  }
25580
+ [kRef]() {
25581
+ webidl.brandCheck(this, _WebSocket);
25582
+ this.#refed = true;
25583
+ this.#handler.socket?.ref?.();
25584
+ }
25585
+ [kUnref]() {
25586
+ webidl.brandCheck(this, _WebSocket);
25587
+ this.#refed = false;
25588
+ this.#handler.socket?.unref?.();
25589
+ }
24766
25590
  /**
24767
25591
  * @see https://websockets.spec.whatwg.org/#dom-websocket-close
24768
25592
  * @param {number|undefined} code
@@ -24924,6 +25748,9 @@ var require_websocket = __commonJS({
24924
25748
  */
24925
25749
  #onConnectionEstablished(response, parsedExtensions) {
24926
25750
  this.#handler.socket = response.socket;
25751
+ if (!this.#refed) {
25752
+ this.#handler.socket.unref?.();
25753
+ }
24927
25754
  const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
24928
25755
  const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
24929
25756
  const parser = new ByteParser(this.#handler, parsedExtensions, {
@@ -26288,11 +27115,11 @@ var require_undici = __commonJS({
26288
27115
  if (typeof opts.path !== "string") {
26289
27116
  throw new InvalidArgumentError("invalid opts.path");
26290
27117
  }
26291
- let path5 = opts.path;
27118
+ let path6 = opts.path;
26292
27119
  if (!opts.path.startsWith("/")) {
26293
- path5 = `/${path5}`;
27120
+ path6 = `/${path6}`;
26294
27121
  }
26295
- url = new URL(util.parseOrigin(url).origin + path5);
27122
+ url = new URL(util.parseOrigin(url).origin + path6);
26296
27123
  } else {
26297
27124
  if (!opts) {
26298
27125
  opts = typeof url === "object" ? url : {};
@@ -34170,10 +34997,10 @@ var require_util7 = __commonJS({
34170
34997
  function cloneDef(schema) {
34171
34998
  return mergeDefs(schema._zod.def);
34172
34999
  }
34173
- function getElementAtPath(obj, path5) {
34174
- if (!path5)
35000
+ function getElementAtPath(obj, path6) {
35001
+ if (!path6)
34175
35002
  return obj;
34176
- return path5.reduce((acc, key) => acc?.[key], obj);
35003
+ return path6.reduce((acc, key) => acc?.[key], obj);
34177
35004
  }
34178
35005
  function promiseAllObject(promisesObj) {
34179
35006
  const keys = Object.keys(promisesObj);
@@ -34583,11 +35410,11 @@ var require_util7 = __commonJS({
34583
35410
  }
34584
35411
  return false;
34585
35412
  }
34586
- function prefixIssues(path5, issues) {
35413
+ function prefixIssues(path6, issues) {
34587
35414
  return issues.map((iss) => {
34588
35415
  var _a;
34589
35416
  (_a = iss).path ?? (_a.path = []);
34590
- iss.path.unshift(path5);
35417
+ iss.path.unshift(path6);
34591
35418
  return iss;
34592
35419
  });
34593
35420
  }
@@ -34776,16 +35603,16 @@ var require_errors2 = __commonJS({
34776
35603
  }
34777
35604
  function formatError2(error, mapper = (issue2) => issue2.message) {
34778
35605
  const fieldErrors = { _errors: [] };
34779
- const processError = (error2, path5 = []) => {
35606
+ const processError = (error2, path6 = []) => {
34780
35607
  for (const issue2 of error2.issues) {
34781
35608
  if (issue2.code === "invalid_union" && issue2.errors.length) {
34782
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
35609
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
34783
35610
  } else if (issue2.code === "invalid_key") {
34784
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
35611
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
34785
35612
  } else if (issue2.code === "invalid_element") {
34786
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
35613
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
34787
35614
  } else {
34788
- const fullpath = [...path5, ...issue2.path];
35615
+ const fullpath = [...path6, ...issue2.path];
34789
35616
  if (fullpath.length === 0) {
34790
35617
  fieldErrors._errors.push(mapper(issue2));
34791
35618
  } else {
@@ -34812,17 +35639,17 @@ var require_errors2 = __commonJS({
34812
35639
  }
34813
35640
  function treeifyError(error, mapper = (issue2) => issue2.message) {
34814
35641
  const result = { errors: [] };
34815
- const processError = (error2, path5 = []) => {
35642
+ const processError = (error2, path6 = []) => {
34816
35643
  var _a, _b;
34817
35644
  for (const issue2 of error2.issues) {
34818
35645
  if (issue2.code === "invalid_union" && issue2.errors.length) {
34819
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
35646
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
34820
35647
  } else if (issue2.code === "invalid_key") {
34821
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
35648
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
34822
35649
  } else if (issue2.code === "invalid_element") {
34823
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
35650
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
34824
35651
  } else {
34825
- const fullpath = [...path5, ...issue2.path];
35652
+ const fullpath = [...path6, ...issue2.path];
34826
35653
  if (fullpath.length === 0) {
34827
35654
  result.errors.push(mapper(issue2));
34828
35655
  continue;
@@ -34854,8 +35681,8 @@ var require_errors2 = __commonJS({
34854
35681
  }
34855
35682
  function toDotPath(_path) {
34856
35683
  const segs = [];
34857
- const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
34858
- for (const seg of path5) {
35684
+ const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
35685
+ for (const seg of path6) {
34859
35686
  if (typeof seg === "number")
34860
35687
  segs.push(`[${seg}]`);
34861
35688
  else if (typeof seg === "symbol")
@@ -62006,11 +62833,11 @@ var require_lodash = __commonJS({
62006
62833
  return isFunction(object[key]);
62007
62834
  });
62008
62835
  }
62009
- function baseGet(object, path5) {
62010
- path5 = castPath(path5, object);
62011
- var index = 0, length = path5.length;
62836
+ function baseGet(object, path6) {
62837
+ path6 = castPath(path6, object);
62838
+ var index = 0, length = path6.length;
62012
62839
  while (object != null && index < length) {
62013
- object = object[toKey(path5[index++])];
62840
+ object = object[toKey(path6[index++])];
62014
62841
  }
62015
62842
  return index && index == length ? object : undefined2;
62016
62843
  }
@@ -62074,10 +62901,10 @@ var require_lodash = __commonJS({
62074
62901
  });
62075
62902
  return accumulator;
62076
62903
  }
62077
- function baseInvoke(object, path5, args) {
62078
- path5 = castPath(path5, object);
62079
- object = parent(object, path5);
62080
- var func = object == null ? object : object[toKey(last(path5))];
62904
+ function baseInvoke(object, path6, args) {
62905
+ path6 = castPath(path6, object);
62906
+ object = parent(object, path6);
62907
+ var func = object == null ? object : object[toKey(last(path6))];
62081
62908
  return func == null ? undefined2 : apply(func, object, args);
62082
62909
  }
62083
62910
  function baseIsArguments(value) {
@@ -62233,13 +63060,13 @@ var require_lodash = __commonJS({
62233
63060
  return object === source || baseIsMatch(object, source, matchData);
62234
63061
  };
62235
63062
  }
62236
- function baseMatchesProperty(path5, srcValue) {
62237
- if (isKey(path5) && isStrictComparable(srcValue)) {
62238
- return matchesStrictComparable(toKey(path5), srcValue);
63063
+ function baseMatchesProperty(path6, srcValue) {
63064
+ if (isKey(path6) && isStrictComparable(srcValue)) {
63065
+ return matchesStrictComparable(toKey(path6), srcValue);
62239
63066
  }
62240
63067
  return function(object) {
62241
- var objValue = get(object, path5);
62242
- return objValue === undefined2 && objValue === srcValue ? hasIn(object, path5) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
63068
+ var objValue = get(object, path6);
63069
+ return objValue === undefined2 && objValue === srcValue ? hasIn(object, path6) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
62243
63070
  };
62244
63071
  }
62245
63072
  function baseMerge(object, source, srcIndex, customizer, stack) {
@@ -62336,23 +63163,23 @@ var require_lodash = __commonJS({
62336
63163
  });
62337
63164
  }
62338
63165
  function basePick(object, paths) {
62339
- return basePickBy(object, paths, function(value, path5) {
62340
- return hasIn(object, path5);
63166
+ return basePickBy(object, paths, function(value, path6) {
63167
+ return hasIn(object, path6);
62341
63168
  });
62342
63169
  }
62343
63170
  function basePickBy(object, paths, predicate) {
62344
63171
  var index = -1, length = paths.length, result2 = {};
62345
63172
  while (++index < length) {
62346
- var path5 = paths[index], value = baseGet(object, path5);
62347
- if (predicate(value, path5)) {
62348
- baseSet(result2, castPath(path5, object), value);
63173
+ var path6 = paths[index], value = baseGet(object, path6);
63174
+ if (predicate(value, path6)) {
63175
+ baseSet(result2, castPath(path6, object), value);
62349
63176
  }
62350
63177
  }
62351
63178
  return result2;
62352
63179
  }
62353
- function basePropertyDeep(path5) {
63180
+ function basePropertyDeep(path6) {
62354
63181
  return function(object) {
62355
- return baseGet(object, path5);
63182
+ return baseGet(object, path6);
62356
63183
  };
62357
63184
  }
62358
63185
  function basePullAll(array, values2, iteratee2, comparator) {
@@ -62426,14 +63253,14 @@ var require_lodash = __commonJS({
62426
63253
  var array = values(collection);
62427
63254
  return shuffleSelf(array, baseClamp(n, 0, array.length));
62428
63255
  }
62429
- function baseSet(object, path5, value, customizer) {
63256
+ function baseSet(object, path6, value, customizer) {
62430
63257
  if (!isObject(object)) {
62431
63258
  return object;
62432
63259
  }
62433
- path5 = castPath(path5, object);
62434
- var index = -1, length = path5.length, lastIndex = length - 1, nested = object;
63260
+ path6 = castPath(path6, object);
63261
+ var index = -1, length = path6.length, lastIndex = length - 1, nested = object;
62435
63262
  while (nested != null && ++index < length) {
62436
- var key = toKey(path5[index]), newValue = value;
63263
+ var key = toKey(path6[index]), newValue = value;
62437
63264
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
62438
63265
  return object;
62439
63266
  }
@@ -62441,7 +63268,7 @@ var require_lodash = __commonJS({
62441
63268
  var objValue = nested[key];
62442
63269
  newValue = customizer ? customizer(objValue, key, nested) : undefined2;
62443
63270
  if (newValue === undefined2) {
62444
- newValue = isObject(objValue) ? objValue : isIndex(path5[index + 1]) ? [] : {};
63271
+ newValue = isObject(objValue) ? objValue : isIndex(path6[index + 1]) ? [] : {};
62445
63272
  }
62446
63273
  }
62447
63274
  assignValue(nested, key, newValue);
@@ -62607,14 +63434,14 @@ var require_lodash = __commonJS({
62607
63434
  }
62608
63435
  return result2;
62609
63436
  }
62610
- function baseUnset(object, path5) {
62611
- path5 = castPath(path5, object);
62612
- var index = -1, length = path5.length;
63437
+ function baseUnset(object, path6) {
63438
+ path6 = castPath(path6, object);
63439
+ var index = -1, length = path6.length;
62613
63440
  if (!length) {
62614
63441
  return true;
62615
63442
  }
62616
63443
  while (++index < length) {
62617
- var key = toKey(path5[index]);
63444
+ var key = toKey(path6[index]);
62618
63445
  if (key === "__proto__" && !hasOwnProperty.call(object, "__proto__")) {
62619
63446
  return false;
62620
63447
  }
@@ -62622,11 +63449,11 @@ var require_lodash = __commonJS({
62622
63449
  return false;
62623
63450
  }
62624
63451
  }
62625
- var obj = parent(object, path5);
62626
- return obj == null || delete obj[toKey(last(path5))];
63452
+ var obj = parent(object, path6);
63453
+ return obj == null || delete obj[toKey(last(path6))];
62627
63454
  }
62628
- function baseUpdate(object, path5, updater, customizer) {
62629
- return baseSet(object, path5, updater(baseGet(object, path5)), customizer);
63455
+ function baseUpdate(object, path6, updater, customizer) {
63456
+ return baseSet(object, path6, updater(baseGet(object, path6)), customizer);
62630
63457
  }
62631
63458
  function baseWhile(array, predicate, isDrop, fromRight) {
62632
63459
  var length = array.length, index = fromRight ? length : -1;
@@ -63509,11 +64336,11 @@ var require_lodash = __commonJS({
63509
64336
  var match = source.match(reWrapDetails);
63510
64337
  return match ? match[1].split(reSplitDetails) : [];
63511
64338
  }
63512
- function hasPath(object, path5, hasFunc) {
63513
- path5 = castPath(path5, object);
63514
- var index = -1, length = path5.length, result2 = false;
64339
+ function hasPath(object, path6, hasFunc) {
64340
+ path6 = castPath(path6, object);
64341
+ var index = -1, length = path6.length, result2 = false;
63515
64342
  while (++index < length) {
63516
- var key = toKey(path5[index]);
64343
+ var key = toKey(path6[index]);
63517
64344
  if (!(result2 = object != null && hasFunc(object, key))) {
63518
64345
  break;
63519
64346
  }
@@ -63715,8 +64542,8 @@ var require_lodash = __commonJS({
63715
64542
  return apply(func, this, otherArgs);
63716
64543
  };
63717
64544
  }
63718
- function parent(object, path5) {
63719
- return path5.length < 2 ? object : baseGet(object, baseSlice(path5, 0, -1));
64545
+ function parent(object, path6) {
64546
+ return path6.length < 2 ? object : baseGet(object, baseSlice(path6, 0, -1));
63720
64547
  }
63721
64548
  function reorder(array, indexes) {
63722
64549
  var arrLength = array.length, length = nativeMin(indexes.length, arrLength), oldArray = copyArray(array);
@@ -64351,10 +65178,10 @@ var require_lodash = __commonJS({
64351
65178
  }
64352
65179
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
64353
65180
  }
64354
- var invokeMap = baseRest(function(collection, path5, args) {
64355
- var index = -1, isFunc = typeof path5 == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
65181
+ var invokeMap = baseRest(function(collection, path6, args) {
65182
+ var index = -1, isFunc = typeof path6 == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
64356
65183
  baseEach(collection, function(value) {
64357
- result2[++index] = isFunc ? apply(path5, value, args) : baseInvoke(value, path5, args);
65184
+ result2[++index] = isFunc ? apply(path6, value, args) : baseInvoke(value, path6, args);
64358
65185
  });
64359
65186
  return result2;
64360
65187
  });
@@ -65006,15 +65833,15 @@ var require_lodash = __commonJS({
65006
65833
  function functionsIn(object) {
65007
65834
  return object == null ? [] : baseFunctions(object, keysIn(object));
65008
65835
  }
65009
- function get(object, path5, defaultValue) {
65010
- var result2 = object == null ? undefined2 : baseGet(object, path5);
65836
+ function get(object, path6, defaultValue) {
65837
+ var result2 = object == null ? undefined2 : baseGet(object, path6);
65011
65838
  return result2 === undefined2 ? defaultValue : result2;
65012
65839
  }
65013
- function has(object, path5) {
65014
- return object != null && hasPath(object, path5, baseHas);
65840
+ function has(object, path6) {
65841
+ return object != null && hasPath(object, path6, baseHas);
65015
65842
  }
65016
- function hasIn(object, path5) {
65017
- return object != null && hasPath(object, path5, baseHasIn);
65843
+ function hasIn(object, path6) {
65844
+ return object != null && hasPath(object, path6, baseHasIn);
65018
65845
  }
65019
65846
  var invert = createInverter(function(result2, value, key) {
65020
65847
  if (value != null && typeof value.toString != "function") {
@@ -65067,10 +65894,10 @@ var require_lodash = __commonJS({
65067
65894
  return result2;
65068
65895
  }
65069
65896
  var isDeep = false;
65070
- paths = arrayMap(paths, function(path5) {
65071
- path5 = castPath(path5, object);
65072
- isDeep || (isDeep = path5.length > 1);
65073
- return path5;
65897
+ paths = arrayMap(paths, function(path6) {
65898
+ path6 = castPath(path6, object);
65899
+ isDeep || (isDeep = path6.length > 1);
65900
+ return path6;
65074
65901
  });
65075
65902
  copyObject(object, getAllKeysIn(object), result2);
65076
65903
  if (isDeep) {
@@ -65096,19 +65923,19 @@ var require_lodash = __commonJS({
65096
65923
  return [prop];
65097
65924
  });
65098
65925
  predicate = getIteratee(predicate);
65099
- return basePickBy(object, props, function(value, path5) {
65100
- return predicate(value, path5[0]);
65926
+ return basePickBy(object, props, function(value, path6) {
65927
+ return predicate(value, path6[0]);
65101
65928
  });
65102
65929
  }
65103
- function result(object, path5, defaultValue) {
65104
- path5 = castPath(path5, object);
65105
- var index = -1, length = path5.length;
65930
+ function result(object, path6, defaultValue) {
65931
+ path6 = castPath(path6, object);
65932
+ var index = -1, length = path6.length;
65106
65933
  if (!length) {
65107
65934
  length = 1;
65108
65935
  object = undefined2;
65109
65936
  }
65110
65937
  while (++index < length) {
65111
- var value = object == null ? undefined2 : object[toKey(path5[index])];
65938
+ var value = object == null ? undefined2 : object[toKey(path6[index])];
65112
65939
  if (value === undefined2) {
65113
65940
  index = length;
65114
65941
  value = defaultValue;
@@ -65117,12 +65944,12 @@ var require_lodash = __commonJS({
65117
65944
  }
65118
65945
  return object;
65119
65946
  }
65120
- function set(object, path5, value) {
65121
- return object == null ? object : baseSet(object, path5, value);
65947
+ function set(object, path6, value) {
65948
+ return object == null ? object : baseSet(object, path6, value);
65122
65949
  }
65123
- function setWith(object, path5, value, customizer) {
65950
+ function setWith(object, path6, value, customizer) {
65124
65951
  customizer = typeof customizer == "function" ? customizer : undefined2;
65125
- return object == null ? object : baseSet(object, path5, value, customizer);
65952
+ return object == null ? object : baseSet(object, path6, value, customizer);
65126
65953
  }
65127
65954
  var toPairs = createToPairs(keys);
65128
65955
  var toPairsIn = createToPairs(keysIn);
@@ -65144,15 +65971,15 @@ var require_lodash = __commonJS({
65144
65971
  });
65145
65972
  return accumulator;
65146
65973
  }
65147
- function unset(object, path5) {
65148
- return object == null ? true : baseUnset(object, path5);
65974
+ function unset(object, path6) {
65975
+ return object == null ? true : baseUnset(object, path6);
65149
65976
  }
65150
- function update(object, path5, updater) {
65151
- return object == null ? object : baseUpdate(object, path5, castFunction(updater));
65977
+ function update(object, path6, updater) {
65978
+ return object == null ? object : baseUpdate(object, path6, castFunction(updater));
65152
65979
  }
65153
- function updateWith(object, path5, updater, customizer) {
65980
+ function updateWith(object, path6, updater, customizer) {
65154
65981
  customizer = typeof customizer == "function" ? customizer : undefined2;
65155
- return object == null ? object : baseUpdate(object, path5, castFunction(updater), customizer);
65982
+ return object == null ? object : baseUpdate(object, path6, castFunction(updater), customizer);
65156
65983
  }
65157
65984
  function values(object) {
65158
65985
  return object == null ? [] : baseValues(object, keys(object));
@@ -65538,17 +66365,17 @@ var require_lodash = __commonJS({
65538
66365
  function matches(source) {
65539
66366
  return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
65540
66367
  }
65541
- function matchesProperty(path5, srcValue) {
65542
- return baseMatchesProperty(path5, baseClone(srcValue, CLONE_DEEP_FLAG));
66368
+ function matchesProperty(path6, srcValue) {
66369
+ return baseMatchesProperty(path6, baseClone(srcValue, CLONE_DEEP_FLAG));
65543
66370
  }
65544
- var method = baseRest(function(path5, args) {
66371
+ var method = baseRest(function(path6, args) {
65545
66372
  return function(object) {
65546
- return baseInvoke(object, path5, args);
66373
+ return baseInvoke(object, path6, args);
65547
66374
  };
65548
66375
  });
65549
66376
  var methodOf = baseRest(function(object, args) {
65550
- return function(path5) {
65551
- return baseInvoke(object, path5, args);
66377
+ return function(path6) {
66378
+ return baseInvoke(object, path6, args);
65552
66379
  };
65553
66380
  });
65554
66381
  function mixin(object, source, options) {
@@ -65595,12 +66422,12 @@ var require_lodash = __commonJS({
65595
66422
  var over = createOver(arrayMap);
65596
66423
  var overEvery = createOver(arrayEvery);
65597
66424
  var overSome = createOver(arraySome);
65598
- function property(path5) {
65599
- return isKey(path5) ? baseProperty(toKey(path5)) : basePropertyDeep(path5);
66425
+ function property(path6) {
66426
+ return isKey(path6) ? baseProperty(toKey(path6)) : basePropertyDeep(path6);
65600
66427
  }
65601
66428
  function propertyOf(object) {
65602
- return function(path5) {
65603
- return object == null ? undefined2 : baseGet(object, path5);
66429
+ return function(path6) {
66430
+ return object == null ? undefined2 : baseGet(object, path6);
65604
66431
  };
65605
66432
  }
65606
66433
  var range = createRange();
@@ -66053,12 +66880,12 @@ var require_lodash = __commonJS({
66053
66880
  LazyWrapper.prototype.findLast = function(predicate) {
66054
66881
  return this.reverse().find(predicate);
66055
66882
  };
66056
- LazyWrapper.prototype.invokeMap = baseRest(function(path5, args) {
66057
- if (typeof path5 == "function") {
66883
+ LazyWrapper.prototype.invokeMap = baseRest(function(path6, args) {
66884
+ if (typeof path6 == "function") {
66058
66885
  return new LazyWrapper(this);
66059
66886
  }
66060
66887
  return this.map(function(value) {
66061
- return baseInvoke(value, path5, args);
66888
+ return baseInvoke(value, path6, args);
66062
66889
  });
66063
66890
  });
66064
66891
  LazyWrapper.prototype.reject = function(predicate) {
@@ -72342,7 +73169,7 @@ var require_url2 = __commonJS({
72342
73169
  */
72343
73170
  update(url) {
72344
73171
  !url && (url = E);
72345
- var parsedUrl = _.isString(url) ? Url.parse(url) : url, auth = parsedUrl.auth, protocol = parsedUrl.protocol, port = parsedUrl.port, path5 = parsedUrl.path, hash = parsedUrl.hash, host = parsedUrl.host, query = parsedUrl.query, variable = parsedUrl.variable;
73172
+ var parsedUrl = _.isString(url) ? Url.parse(url) : url, auth = parsedUrl.auth, protocol = parsedUrl.protocol, port = parsedUrl.port, path6 = parsedUrl.path, hash = parsedUrl.hash, host = parsedUrl.host, query = parsedUrl.query, variable = parsedUrl.variable;
72346
73173
  if (query) {
72347
73174
  if (_.isString(query)) {
72348
73175
  query = QueryParam.parse(query);
@@ -72362,9 +73189,9 @@ var require_url2 = __commonJS({
72362
73189
  return v;
72363
73190
  });
72364
73191
  }
72365
- if (_.isString(path5)) {
72366
- path5 && (path5 = path5.replace(regexes.trimPath, MATCH_1));
72367
- path5 = path5 ? path5 === PATH_SEPARATOR ? [E] : path5.split(PATH_SEPARATOR) : void 0;
73192
+ if (_.isString(path6)) {
73193
+ path6 && (path6 = path6.replace(regexes.trimPath, MATCH_1));
73194
+ path6 = path6 ? path6 === PATH_SEPARATOR ? [E] : path6.split(PATH_SEPARATOR) : void 0;
72368
73195
  }
72369
73196
  _.isString(host) && (host = host.split(regexes.splitDomain));
72370
73197
  _.assign(
@@ -72386,7 +73213,7 @@ var require_url2 = __commonJS({
72386
73213
  /**
72387
73214
  * @type {Array<String>}
72388
73215
  */
72389
- path: path5,
73216
+ path: path6,
72390
73217
  /**
72391
73218
  * @type {String}
72392
73219
  */
@@ -72528,11 +73355,11 @@ var require_url2 = __commonJS({
72528
73355
  * @example /something/postman?hi=notbye
72529
73356
  */
72530
73357
  getPathWithQuery() {
72531
- var path5 = this.getPath(), queryString = this.getQueryString();
73358
+ var path6 = this.getPath(), queryString = this.getQueryString();
72532
73359
  if (queryString) {
72533
- path5 += QUERY_SEPARATOR + queryString;
73360
+ path6 += QUERY_SEPARATOR + queryString;
72534
73361
  }
72535
- return path5;
73362
+ return path6;
72536
73363
  },
72537
73364
  /**
72538
73365
  * Returns the host part of the URL
@@ -72572,9 +73399,9 @@ var require_url2 = __commonJS({
72572
73399
  * @note not discontinue yet because it's used in Twitter APIs public collections
72573
73400
  */
72574
73401
  getOAuth1BaseUrl() {
72575
- var protocol = this.protocol || PROTOCOL_HTTP, port = this.port ? this.port.toString() : void 0, host = (port === HTTP_PORT || port === HTTPS_PORT || port === void 0) && this.host.join(DOMAIN_SEPARATOR) || this.host.join(DOMAIN_SEPARATOR) + PORT_SEPARATOR + port, path5 = this.getPath();
73402
+ var protocol = this.protocol || PROTOCOL_HTTP, port = this.port ? this.port.toString() : void 0, host = (port === HTTP_PORT || port === HTTPS_PORT || port === void 0) && this.host.join(DOMAIN_SEPARATOR) || this.host.join(DOMAIN_SEPARATOR) + PORT_SEPARATOR + port, path6 = this.getPath();
72576
73403
  protocol = _.endsWith(protocol, PROTOCOL_SEPARATOR) ? protocol : protocol + PROTOCOL_SEPARATOR;
72577
- return protocol.toLowerCase() + host.toLowerCase() + path5;
73404
+ return protocol.toLowerCase() + host.toLowerCase() + path6;
72578
73405
  }
72579
73406
  }
72580
73407
  );
@@ -72829,9 +73656,9 @@ var require_url_match_pattern = __commonJS({
72829
73656
  * @param {String=} path The path to be checked if the pattern allows.
72830
73657
  * @returns {Boolean=}
72831
73658
  */
72832
- testPath(path5) {
73659
+ testPath(path6) {
72833
73660
  var matchRegexObject = this._matchPatternObject;
72834
- return !_.isEmpty(path5.match(matchRegexObject.path));
73661
+ return !_.isEmpty(path6.match(matchRegexObject.path));
72835
73662
  },
72836
73663
  /**
72837
73664
  * Tests the url string with the match pattern provided.
@@ -74580,7 +75407,7 @@ var require_request13 = __commonJS({
74580
75407
  var HeaderList = require_header_list().HeaderList;
74581
75408
  var RequestBody = require_request_body2().RequestBody;
74582
75409
  var RequestAuth = require_request_auth().RequestAuth;
74583
- var Request;
75410
+ var Request2;
74584
75411
  var DEFAULT_REQ_METHOD = "GET";
74585
75412
  var CONTENT_LENGTH = "Content-Length";
74586
75413
  var SP = " ";
@@ -74599,8 +75426,8 @@ var require_request13 = __commonJS({
74599
75426
  * @extends {Property}
74600
75427
  * @param {Request.definition} options -
74601
75428
  */
74602
- Request = function PostmanRequest(options) {
74603
- Request.super_.apply(this, arguments);
75429
+ Request2 = function PostmanRequest(options) {
75430
+ Request2.super_.apply(this, arguments);
74604
75431
  typeof options === "string" && (options = {
74605
75432
  url: options
74606
75433
  });
@@ -74630,7 +75457,7 @@ var require_request13 = __commonJS({
74630
75457
  Property
74631
75458
  );
74632
75459
  _.assign(
74633
- Request.prototype,
75460
+ Request2.prototype,
74634
75461
  /** @lends Request.prototype */
74635
75462
  {
74636
75463
  /**
@@ -74832,12 +75659,12 @@ var require_request13 = __commonJS({
74832
75659
  * @returns {Request}
74833
75660
  */
74834
75661
  clone: function() {
74835
- return new Request(this.toJSON());
75662
+ return new Request2(this.toJSON());
74836
75663
  }
74837
75664
  }
74838
75665
  );
74839
75666
  _.assign(
74840
- Request,
75667
+ Request2,
74841
75668
  /** @lends Request */
74842
75669
  {
74843
75670
  /**
@@ -74855,12 +75682,12 @@ var require_request13 = __commonJS({
74855
75682
  * @returns {Boolean}
74856
75683
  */
74857
75684
  isRequest: function(obj) {
74858
- return Boolean(obj) && (obj instanceof Request || _.inSuperChain(obj.constructor, "_postman_propertyName", Request._postman_propertyName));
75685
+ return Boolean(obj) && (obj instanceof Request2 || _.inSuperChain(obj.constructor, "_postman_propertyName", Request2._postman_propertyName));
74859
75686
  }
74860
75687
  }
74861
75688
  );
74862
75689
  module2.exports = {
74863
- Request
75690
+ Request: Request2
74864
75691
  };
74865
75692
  }
74866
75693
  });
@@ -76605,11 +77432,11 @@ var require_Mime = __commonJS({
76605
77432
  }
76606
77433
  }
76607
77434
  };
76608
- Mime.prototype.getType = function(path5) {
76609
- path5 = String(path5);
76610
- let last = path5.replace(/^.*[/\\]/, "").toLowerCase();
77435
+ Mime.prototype.getType = function(path6) {
77436
+ path6 = String(path6);
77437
+ let last = path6.replace(/^.*[/\\]/, "").toLowerCase();
76611
77438
  let ext = last.replace(/^.*\./, "").toLowerCase();
76612
- let hasPath = last.length < path5.length;
77439
+ let hasPath = last.length < path6.length;
76613
77440
  let hasDot = ext.length < last.length - 1;
76614
77441
  return (hasDot || !hasPath) && this._types[ext] || null;
76615
77442
  };
@@ -78840,7 +79667,7 @@ var require_response2 = __commonJS({
78840
79667
  var LJSON = require_liquid_json();
78841
79668
  var Property = require_property().Property;
78842
79669
  var PropertyBase = require_property_base().PropertyBase;
78843
- var Request = require_request13().Request;
79670
+ var Request2 = require_request13().Request;
78844
79671
  var CookieList = require_cookie_list().CookieList;
78845
79672
  var HeaderList = require_header_list().HeaderList;
78846
79673
  var contentInfo = require_content_info().contentInfo;
@@ -78911,7 +79738,7 @@ var require_response2 = __commonJS({
78911
79738
  /**
78912
79739
  * @type {Request}
78913
79740
  */
78914
- originalRequest: options.originalRequest ? new Request(options.originalRequest) : void 0,
79741
+ originalRequest: options.originalRequest ? new Request2(options.originalRequest) : void 0,
78915
79742
  /**
78916
79743
  * @type {String}
78917
79744
  */
@@ -79258,7 +80085,7 @@ var require_item = __commonJS({
79258
80085
  var Property = require_property().Property;
79259
80086
  var PropertyList = require_property_list().PropertyList;
79260
80087
  var EventList = require_event_list().EventList;
79261
- var Request = require_request13().Request;
80088
+ var Request2 = require_request13().Request;
79262
80089
  var RequestAuth = require_request_auth().RequestAuth;
79263
80090
  var Response2 = require_response2().Response;
79264
80091
  var Item;
@@ -79319,7 +80146,7 @@ var require_item = __commonJS({
79319
80146
  *
79320
80147
  * @type {Request}
79321
80148
  */
79322
- request: definition && new Request(definition.request),
80149
+ request: definition && new Request2(definition.request),
79323
80150
  /**
79324
80151
  * An Item also contains a list of sample responses that is expected when the request defined in the item is
79325
80152
  * executed. The sample responses are useful in elaborating API usage and is also useful for other
@@ -79506,7 +80333,7 @@ var require_item = __commonJS({
79506
80333
  */
79507
80334
  authorizeRequestUsing: function(type, options) {
79508
80335
  if (!this.request) {
79509
- this.request = new Request();
80336
+ this.request = new Request2();
79510
80337
  }
79511
80338
  return this.request.authorizeUsing(type, options);
79512
80339
  },
@@ -79516,12 +80343,12 @@ var require_item = __commonJS({
79516
80343
  * @returns {Array<string>}
79517
80344
  */
79518
80345
  getPath: function() {
79519
- const path5 = [], pushItem = (item) => {
79520
- path5.push(item.name);
80346
+ const path6 = [], pushItem = (item) => {
80347
+ path6.push(item.name);
79521
80348
  };
79522
80349
  pushItem(this);
79523
80350
  this.forEachParent({ withRoot: true }, pushItem);
79524
- return path5.reverse();
80351
+ return path6.reverse();
79525
80352
  }
79526
80353
  }
79527
80354
  );
@@ -79562,7 +80389,7 @@ var require_item_group = __commonJS({
79562
80389
  var PropertyList = require_property_list().PropertyList;
79563
80390
  var EventList = require_event_list().EventList;
79564
80391
  var Item = require_item().Item;
79565
- var Request = require_request13().Request;
80392
+ var Request2 = require_request13().Request;
79566
80393
  var RequestAuth = require_request_auth().RequestAuth;
79567
80394
  var ItemGroup;
79568
80395
  var OBJECT = "object";
@@ -79802,7 +80629,7 @@ var require_item_group = __commonJS({
79802
80629
  * @note This function was previously (in v2 of SDK) used to clone request and populate headers. Now it is used to
79803
80630
  * only set auth information to request
79804
80631
  */
79805
- authorizeRequestsUsing: Request.prototype.authorizeUsing
80632
+ authorizeRequestsUsing: Request2.prototype.authorizeUsing
79806
80633
  }
79807
80634
  );
79808
80635
  _.assign(
@@ -85241,8 +86068,8 @@ var require_Trie = __commonJS({
85241
86068
  throw new Error("Trie.insert: key cannot be null or undefined");
85242
86069
  }
85243
86070
  let node = this.root;
85244
- const path5 = this.getPath(key);
85245
- for (const segment of path5) {
86071
+ const path6 = this.getPath(key);
86072
+ for (const segment of path6) {
85246
86073
  if (!node.children.has(segment)) {
85247
86074
  node.children.set(segment, new TrieNode());
85248
86075
  }
@@ -85259,8 +86086,8 @@ var require_Trie = __commonJS({
85259
86086
  return [];
85260
86087
  }
85261
86088
  let node = this.root;
85262
- const path5 = this.getPath(prefix);
85263
- for (const segment of path5) {
86089
+ const path6 = this.getPath(prefix);
86090
+ for (const segment of path6) {
85264
86091
  const child = node.children.get(segment);
85265
86092
  if (!child) {
85266
86093
  return [];
@@ -85276,8 +86103,8 @@ var require_Trie = __commonJS({
85276
86103
  return [];
85277
86104
  }
85278
86105
  let node = this.root;
85279
- const path5 = this.getPath(prefix);
85280
- for (const segment of path5) {
86106
+ const path6 = this.getPath(prefix);
86107
+ for (const segment of path6) {
85281
86108
  const child = node.children.get(segment);
85282
86109
  if (!child) {
85283
86110
  return [];
@@ -85285,7 +86112,7 @@ var require_Trie = __commonJS({
85285
86112
  node = child;
85286
86113
  }
85287
86114
  const results = [];
85288
- this._collectEntries(node, path5, results);
86115
+ this._collectEntries(node, path6, results);
85289
86116
  return results;
85290
86117
  }
85291
86118
  get(key) {
@@ -85293,8 +86120,8 @@ var require_Trie = __commonJS({
85293
86120
  return void 0;
85294
86121
  }
85295
86122
  let node = this.root;
85296
- const path5 = this.getPath(key);
85297
- for (const segment of path5) {
86123
+ const path6 = this.getPath(key);
86124
+ for (const segment of path6) {
85298
86125
  const child = node.children.get(segment);
85299
86126
  if (!child) {
85300
86127
  return void 0;
@@ -85308,8 +86135,8 @@ var require_Trie = __commonJS({
85308
86135
  return false;
85309
86136
  }
85310
86137
  let node = this.root;
85311
- const path5 = this.getPath(key);
85312
- for (const segment of path5) {
86138
+ const path6 = this.getPath(key);
86139
+ for (const segment of path6) {
85313
86140
  const child = node.children.get(segment);
85314
86141
  if (!child) {
85315
86142
  return false;
@@ -88618,17 +89445,17 @@ var require_visit = __commonJS({
88618
89445
  visit2.BREAK = BREAK;
88619
89446
  visit2.SKIP = SKIP;
88620
89447
  visit2.REMOVE = REMOVE;
88621
- function visit_(key, node, visitor, path5) {
88622
- const ctrl = callVisitor(key, node, visitor, path5);
89448
+ function visit_(key, node, visitor, path6) {
89449
+ const ctrl = callVisitor(key, node, visitor, path6);
88623
89450
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
88624
- replaceNode(key, path5, ctrl);
88625
- return visit_(key, ctrl, visitor, path5);
89451
+ replaceNode(key, path6, ctrl);
89452
+ return visit_(key, ctrl, visitor, path6);
88626
89453
  }
88627
89454
  if (typeof ctrl !== "symbol") {
88628
89455
  if (identity.isCollection(node)) {
88629
- path5 = Object.freeze(path5.concat(node));
89456
+ path6 = Object.freeze(path6.concat(node));
88630
89457
  for (let i = 0; i < node.items.length; ++i) {
88631
- const ci = visit_(i, node.items[i], visitor, path5);
89458
+ const ci = visit_(i, node.items[i], visitor, path6);
88632
89459
  if (typeof ci === "number")
88633
89460
  i = ci - 1;
88634
89461
  else if (ci === BREAK)
@@ -88639,13 +89466,13 @@ var require_visit = __commonJS({
88639
89466
  }
88640
89467
  }
88641
89468
  } else if (identity.isPair(node)) {
88642
- path5 = Object.freeze(path5.concat(node));
88643
- const ck = visit_("key", node.key, visitor, path5);
89469
+ path6 = Object.freeze(path6.concat(node));
89470
+ const ck = visit_("key", node.key, visitor, path6);
88644
89471
  if (ck === BREAK)
88645
89472
  return BREAK;
88646
89473
  else if (ck === REMOVE)
88647
89474
  node.key = null;
88648
- const cv = visit_("value", node.value, visitor, path5);
89475
+ const cv = visit_("value", node.value, visitor, path6);
88649
89476
  if (cv === BREAK)
88650
89477
  return BREAK;
88651
89478
  else if (cv === REMOVE)
@@ -88666,17 +89493,17 @@ var require_visit = __commonJS({
88666
89493
  visitAsync.BREAK = BREAK;
88667
89494
  visitAsync.SKIP = SKIP;
88668
89495
  visitAsync.REMOVE = REMOVE;
88669
- async function visitAsync_(key, node, visitor, path5) {
88670
- const ctrl = await callVisitor(key, node, visitor, path5);
89496
+ async function visitAsync_(key, node, visitor, path6) {
89497
+ const ctrl = await callVisitor(key, node, visitor, path6);
88671
89498
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
88672
- replaceNode(key, path5, ctrl);
88673
- return visitAsync_(key, ctrl, visitor, path5);
89499
+ replaceNode(key, path6, ctrl);
89500
+ return visitAsync_(key, ctrl, visitor, path6);
88674
89501
  }
88675
89502
  if (typeof ctrl !== "symbol") {
88676
89503
  if (identity.isCollection(node)) {
88677
- path5 = Object.freeze(path5.concat(node));
89504
+ path6 = Object.freeze(path6.concat(node));
88678
89505
  for (let i = 0; i < node.items.length; ++i) {
88679
- const ci = await visitAsync_(i, node.items[i], visitor, path5);
89506
+ const ci = await visitAsync_(i, node.items[i], visitor, path6);
88680
89507
  if (typeof ci === "number")
88681
89508
  i = ci - 1;
88682
89509
  else if (ci === BREAK)
@@ -88687,13 +89514,13 @@ var require_visit = __commonJS({
88687
89514
  }
88688
89515
  }
88689
89516
  } else if (identity.isPair(node)) {
88690
- path5 = Object.freeze(path5.concat(node));
88691
- const ck = await visitAsync_("key", node.key, visitor, path5);
89517
+ path6 = Object.freeze(path6.concat(node));
89518
+ const ck = await visitAsync_("key", node.key, visitor, path6);
88692
89519
  if (ck === BREAK)
88693
89520
  return BREAK;
88694
89521
  else if (ck === REMOVE)
88695
89522
  node.key = null;
88696
- const cv = await visitAsync_("value", node.value, visitor, path5);
89523
+ const cv = await visitAsync_("value", node.value, visitor, path6);
88697
89524
  if (cv === BREAK)
88698
89525
  return BREAK;
88699
89526
  else if (cv === REMOVE)
@@ -88720,23 +89547,23 @@ var require_visit = __commonJS({
88720
89547
  }
88721
89548
  return visitor;
88722
89549
  }
88723
- function callVisitor(key, node, visitor, path5) {
89550
+ function callVisitor(key, node, visitor, path6) {
88724
89551
  if (typeof visitor === "function")
88725
- return visitor(key, node, path5);
89552
+ return visitor(key, node, path6);
88726
89553
  if (identity.isMap(node))
88727
- return visitor.Map?.(key, node, path5);
89554
+ return visitor.Map?.(key, node, path6);
88728
89555
  if (identity.isSeq(node))
88729
- return visitor.Seq?.(key, node, path5);
89556
+ return visitor.Seq?.(key, node, path6);
88730
89557
  if (identity.isPair(node))
88731
- return visitor.Pair?.(key, node, path5);
89558
+ return visitor.Pair?.(key, node, path6);
88732
89559
  if (identity.isScalar(node))
88733
- return visitor.Scalar?.(key, node, path5);
89560
+ return visitor.Scalar?.(key, node, path6);
88734
89561
  if (identity.isAlias(node))
88735
- return visitor.Alias?.(key, node, path5);
89562
+ return visitor.Alias?.(key, node, path6);
88736
89563
  return void 0;
88737
89564
  }
88738
- function replaceNode(key, path5, node) {
88739
- const parent = path5[path5.length - 1];
89565
+ function replaceNode(key, path6, node) {
89566
+ const parent = path6[path6.length - 1];
88740
89567
  if (identity.isCollection(parent)) {
88741
89568
  parent.items[key] = node;
88742
89569
  } else if (identity.isPair(parent)) {
@@ -89346,10 +90173,10 @@ var require_Collection = __commonJS({
89346
90173
  var createNode = require_createNode();
89347
90174
  var identity = require_identity();
89348
90175
  var Node = require_Node();
89349
- function collectionFromPath(schema, path5, value) {
90176
+ function collectionFromPath(schema, path6, value) {
89350
90177
  let v = value;
89351
- for (let i = path5.length - 1; i >= 0; --i) {
89352
- const k = path5[i];
90178
+ for (let i = path6.length - 1; i >= 0; --i) {
90179
+ const k = path6[i];
89353
90180
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
89354
90181
  const a = [];
89355
90182
  a[k] = v;
@@ -89368,7 +90195,7 @@ var require_Collection = __commonJS({
89368
90195
  sourceObjects: /* @__PURE__ */ new Map()
89369
90196
  });
89370
90197
  }
89371
- var isEmptyPath = (path5) => path5 == null || typeof path5 === "object" && !!path5[Symbol.iterator]().next().done;
90198
+ var isEmptyPath = (path6) => path6 == null || typeof path6 === "object" && !!path6[Symbol.iterator]().next().done;
89372
90199
  var Collection2 = class extends Node.NodeBase {
89373
90200
  constructor(type, schema) {
89374
90201
  super(type);
@@ -89398,11 +90225,11 @@ var require_Collection = __commonJS({
89398
90225
  * be a Pair instance or a `{ key, value }` object, which may not have a key
89399
90226
  * that already exists in the map.
89400
90227
  */
89401
- addIn(path5, value) {
89402
- if (isEmptyPath(path5))
90228
+ addIn(path6, value) {
90229
+ if (isEmptyPath(path6))
89403
90230
  this.add(value);
89404
90231
  else {
89405
- const [key, ...rest] = path5;
90232
+ const [key, ...rest] = path6;
89406
90233
  const node = this.get(key, true);
89407
90234
  if (identity.isCollection(node))
89408
90235
  node.addIn(rest, value);
@@ -89416,8 +90243,8 @@ var require_Collection = __commonJS({
89416
90243
  * Removes a value from the collection.
89417
90244
  * @returns `true` if the item was found and removed.
89418
90245
  */
89419
- deleteIn(path5) {
89420
- const [key, ...rest] = path5;
90246
+ deleteIn(path6) {
90247
+ const [key, ...rest] = path6;
89421
90248
  if (rest.length === 0)
89422
90249
  return this.delete(key);
89423
90250
  const node = this.get(key, true);
@@ -89431,8 +90258,8 @@ var require_Collection = __commonJS({
89431
90258
  * scalar values from their surrounding node; to disable set `keepScalar` to
89432
90259
  * `true` (collections are always returned intact).
89433
90260
  */
89434
- getIn(path5, keepScalar) {
89435
- const [key, ...rest] = path5;
90261
+ getIn(path6, keepScalar) {
90262
+ const [key, ...rest] = path6;
89436
90263
  const node = this.get(key, true);
89437
90264
  if (rest.length === 0)
89438
90265
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -89450,8 +90277,8 @@ var require_Collection = __commonJS({
89450
90277
  /**
89451
90278
  * Checks if the collection includes a value with the key `key`.
89452
90279
  */
89453
- hasIn(path5) {
89454
- const [key, ...rest] = path5;
90280
+ hasIn(path6) {
90281
+ const [key, ...rest] = path6;
89455
90282
  if (rest.length === 0)
89456
90283
  return this.has(key);
89457
90284
  const node = this.get(key, true);
@@ -89461,8 +90288,8 @@ var require_Collection = __commonJS({
89461
90288
  * Sets a value in this collection. For `!!set`, `value` needs to be a
89462
90289
  * boolean to add/remove the item from the set.
89463
90290
  */
89464
- setIn(path5, value) {
89465
- const [key, ...rest] = path5;
90291
+ setIn(path6, value) {
90292
+ const [key, ...rest] = path6;
89466
90293
  if (rest.length === 0) {
89467
90294
  this.set(key, value);
89468
90295
  } else {
@@ -91977,9 +92804,9 @@ var require_Document = __commonJS({
91977
92804
  this.contents.add(value);
91978
92805
  }
91979
92806
  /** Adds a value to the document. */
91980
- addIn(path5, value) {
92807
+ addIn(path6, value) {
91981
92808
  if (assertCollection(this.contents))
91982
- this.contents.addIn(path5, value);
92809
+ this.contents.addIn(path6, value);
91983
92810
  }
91984
92811
  /**
91985
92812
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -92054,14 +92881,14 @@ var require_Document = __commonJS({
92054
92881
  * Removes a value from the document.
92055
92882
  * @returns `true` if the item was found and removed.
92056
92883
  */
92057
- deleteIn(path5) {
92058
- if (Collection2.isEmptyPath(path5)) {
92884
+ deleteIn(path6) {
92885
+ if (Collection2.isEmptyPath(path6)) {
92059
92886
  if (this.contents == null)
92060
92887
  return false;
92061
92888
  this.contents = null;
92062
92889
  return true;
92063
92890
  }
92064
- return assertCollection(this.contents) ? this.contents.deleteIn(path5) : false;
92891
+ return assertCollection(this.contents) ? this.contents.deleteIn(path6) : false;
92065
92892
  }
92066
92893
  /**
92067
92894
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -92076,10 +92903,10 @@ var require_Document = __commonJS({
92076
92903
  * scalar values from their surrounding node; to disable set `keepScalar` to
92077
92904
  * `true` (collections are always returned intact).
92078
92905
  */
92079
- getIn(path5, keepScalar) {
92080
- if (Collection2.isEmptyPath(path5))
92906
+ getIn(path6, keepScalar) {
92907
+ if (Collection2.isEmptyPath(path6))
92081
92908
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
92082
- return identity.isCollection(this.contents) ? this.contents.getIn(path5, keepScalar) : void 0;
92909
+ return identity.isCollection(this.contents) ? this.contents.getIn(path6, keepScalar) : void 0;
92083
92910
  }
92084
92911
  /**
92085
92912
  * Checks if the document includes a value with the key `key`.
@@ -92090,10 +92917,10 @@ var require_Document = __commonJS({
92090
92917
  /**
92091
92918
  * Checks if the document includes a value at `path`.
92092
92919
  */
92093
- hasIn(path5) {
92094
- if (Collection2.isEmptyPath(path5))
92920
+ hasIn(path6) {
92921
+ if (Collection2.isEmptyPath(path6))
92095
92922
  return this.contents !== void 0;
92096
- return identity.isCollection(this.contents) ? this.contents.hasIn(path5) : false;
92923
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path6) : false;
92097
92924
  }
92098
92925
  /**
92099
92926
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -92110,13 +92937,13 @@ var require_Document = __commonJS({
92110
92937
  * Sets a value in this document. For `!!set`, `value` needs to be a
92111
92938
  * boolean to add/remove the item from the set.
92112
92939
  */
92113
- setIn(path5, value) {
92114
- if (Collection2.isEmptyPath(path5)) {
92940
+ setIn(path6, value) {
92941
+ if (Collection2.isEmptyPath(path6)) {
92115
92942
  this.contents = value;
92116
92943
  } else if (this.contents == null) {
92117
- this.contents = Collection2.collectionFromPath(this.schema, Array.from(path5), value);
92944
+ this.contents = Collection2.collectionFromPath(this.schema, Array.from(path6), value);
92118
92945
  } else if (assertCollection(this.contents)) {
92119
- this.contents.setIn(path5, value);
92946
+ this.contents.setIn(path6, value);
92120
92947
  }
92121
92948
  }
92122
92949
  /**
@@ -94076,9 +94903,9 @@ var require_cst_visit = __commonJS({
94076
94903
  visit2.BREAK = BREAK;
94077
94904
  visit2.SKIP = SKIP;
94078
94905
  visit2.REMOVE = REMOVE;
94079
- visit2.itemAtPath = (cst, path5) => {
94906
+ visit2.itemAtPath = (cst, path6) => {
94080
94907
  let item = cst;
94081
- for (const [field, index] of path5) {
94908
+ for (const [field, index] of path6) {
94082
94909
  const tok = item?.[field];
94083
94910
  if (tok && "items" in tok) {
94084
94911
  item = tok.items[index];
@@ -94087,23 +94914,23 @@ var require_cst_visit = __commonJS({
94087
94914
  }
94088
94915
  return item;
94089
94916
  };
94090
- visit2.parentCollection = (cst, path5) => {
94091
- const parent = visit2.itemAtPath(cst, path5.slice(0, -1));
94092
- const field = path5[path5.length - 1][0];
94917
+ visit2.parentCollection = (cst, path6) => {
94918
+ const parent = visit2.itemAtPath(cst, path6.slice(0, -1));
94919
+ const field = path6[path6.length - 1][0];
94093
94920
  const coll = parent?.[field];
94094
94921
  if (coll && "items" in coll)
94095
94922
  return coll;
94096
94923
  throw new Error("Parent collection not found");
94097
94924
  };
94098
- function _visit(path5, item, visitor) {
94099
- let ctrl = visitor(item, path5);
94925
+ function _visit(path6, item, visitor) {
94926
+ let ctrl = visitor(item, path6);
94100
94927
  if (typeof ctrl === "symbol")
94101
94928
  return ctrl;
94102
94929
  for (const field of ["key", "value"]) {
94103
94930
  const token = item[field];
94104
94931
  if (token && "items" in token) {
94105
94932
  for (let i = 0; i < token.items.length; ++i) {
94106
- const ci = _visit(Object.freeze(path5.concat([[field, i]])), token.items[i], visitor);
94933
+ const ci = _visit(Object.freeze(path6.concat([[field, i]])), token.items[i], visitor);
94107
94934
  if (typeof ci === "number")
94108
94935
  i = ci - 1;
94109
94936
  else if (ci === BREAK)
@@ -94114,10 +94941,10 @@ var require_cst_visit = __commonJS({
94114
94941
  }
94115
94942
  }
94116
94943
  if (typeof ctrl === "function" && field === "key")
94117
- ctrl = ctrl(item, path5);
94944
+ ctrl = ctrl(item, path6);
94118
94945
  }
94119
94946
  }
94120
- return typeof ctrl === "function" ? ctrl(item, path5) : ctrl;
94947
+ return typeof ctrl === "function" ? ctrl(item, path6) : ctrl;
94121
94948
  }
94122
94949
  exports2.visit = visit2;
94123
94950
  }
@@ -98448,7 +99275,7 @@ var require_split_collection = __commonJS({
98448
99275
  if (items && items.length > 0) {
98449
99276
  processItems(trie, rootPath, rootResourcesPath, items, serializeOpts, idMap, collection.id);
98450
99277
  }
98451
- const files = trie.entries().map(([path5, content]) => ({ path: path5, content }));
99278
+ const files = trie.entries().map(([path6, content]) => ({ path: path6, content }));
98452
99279
  return idMap ? { files, rootPath, idMap } : { files, rootPath };
98453
99280
  }
98454
99281
  }
@@ -101322,8 +102149,8 @@ var require_utils5 = __commonJS({
101322
102149
  var result = transform2[inputType][outputType](input);
101323
102150
  return result;
101324
102151
  };
101325
- exports2.resolve = function(path5) {
101326
- var parts = path5.split("/");
102152
+ exports2.resolve = function(path6) {
102153
+ var parts = path6.split("/");
101327
102154
  var result = [];
101328
102155
  for (var index = 0; index < parts.length; index++) {
101329
102156
  var part = parts[index];
@@ -107176,18 +108003,18 @@ var require_object = __commonJS({
107176
108003
  var object = new ZipObject(name, zipObjectContent, o);
107177
108004
  this.files[name] = object;
107178
108005
  };
107179
- var parentFolder = function(path5) {
107180
- if (path5.slice(-1) === "/") {
107181
- path5 = path5.substring(0, path5.length - 1);
108006
+ var parentFolder = function(path6) {
108007
+ if (path6.slice(-1) === "/") {
108008
+ path6 = path6.substring(0, path6.length - 1);
107182
108009
  }
107183
- var lastSlash = path5.lastIndexOf("/");
107184
- return lastSlash > 0 ? path5.substring(0, lastSlash) : "";
108010
+ var lastSlash = path6.lastIndexOf("/");
108011
+ return lastSlash > 0 ? path6.substring(0, lastSlash) : "";
107185
108012
  };
107186
- var forceTrailingSlash = function(path5) {
107187
- if (path5.slice(-1) !== "/") {
107188
- path5 += "/";
108013
+ var forceTrailingSlash = function(path6) {
108014
+ if (path6.slice(-1) !== "/") {
108015
+ path6 += "/";
107189
108016
  }
107190
- return path5;
108017
+ return path6;
107191
108018
  };
107192
108019
  var folderAdd = function(name, createFolders) {
107193
108020
  createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
@@ -108254,9 +109081,9 @@ __export(cli_exports, {
108254
109081
  });
108255
109082
  module.exports = __toCommonJS(cli_exports);
108256
109083
  var import_node_child_process = require("node:child_process");
108257
- var import_node_fs6 = require("node:fs");
109084
+ var import_node_fs7 = require("node:fs");
108258
109085
  var import_promises = require("node:fs/promises");
108259
- var import_node_path3 = __toESM(require("node:path"), 1);
109086
+ var import_node_path4 = __toESM(require("node:path"), 1);
108260
109087
  var import_node_util = require("node:util");
108261
109088
 
108262
109089
  // node_modules/@actions/http-client/lib/index.js
@@ -108623,8 +109450,8 @@ var ExitCode;
108623
109450
 
108624
109451
  // src/index.ts
108625
109452
  var import_node_crypto3 = require("node:crypto");
108626
- var import_node_fs5 = require("node:fs");
108627
- var path3 = __toESM(require("node:path"), 1);
109453
+ var import_node_fs6 = require("node:fs");
109454
+ var path4 = __toESM(require("node:path"), 1);
108628
109455
 
108629
109456
  // node_modules/js-yaml/dist/js-yaml.mjs
108630
109457
  var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
@@ -109048,6 +109875,11 @@ var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
109048
109875
  });
109049
109876
  var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
109050
109877
  var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
109878
+ function makeUtcDate(year, month, day, hour = 0, minute = 0, second = 0, fraction = 0) {
109879
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
109880
+ date.setUTCFullYear(year, month, day);
109881
+ return date;
109882
+ }
109051
109883
  function resolveYamlTimestamp(source) {
109052
109884
  let match = YAML_DATE_REGEXP.exec(source);
109053
109885
  if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
@@ -109056,7 +109888,7 @@ function resolveYamlTimestamp(source) {
109056
109888
  const month = +match[2] - 1;
109057
109889
  const day = +match[3];
109058
109890
  if (!match[4]) {
109059
- const date2 = new Date(Date.UTC(year, month, day));
109891
+ const date2 = makeUtcDate(year, month, day);
109060
109892
  if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month || date2.getUTCDate() !== day) return NOT_RESOLVED;
109061
109893
  return date2;
109062
109894
  }
@@ -109070,7 +109902,7 @@ function resolveYamlTimestamp(source) {
109070
109902
  while (value.length < 3) value += "0";
109071
109903
  fraction = +value;
109072
109904
  }
109073
- const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
109905
+ const date = makeUtcDate(year, month, day, hour, minute, second, fraction);
109074
109906
  if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
109075
109907
  if (match[9]) {
109076
109908
  const offsetHour = +match[10];
@@ -109168,7 +110000,11 @@ var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
109168
110000
  return Object.prototype.hasOwnProperty.call(container, String(key));
109169
110001
  },
109170
110002
  keys: (container) => Object.keys(container),
109171
- get: (container, key) => container[String(key)]
110003
+ get: (container, key) => {
110004
+ const normalizedKey = String(key);
110005
+ if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
110006
+ return container[normalizedKey];
110007
+ }
109172
110008
  });
109173
110009
  var setTag = defineMappingTag("tag:yaml.org,2002:set", {
109174
110010
  create: () => /* @__PURE__ */ new Set(),
@@ -109189,9 +110025,9 @@ var setTag = defineMappingTag("tag:yaml.org,2002:set", {
109189
110025
  });
109190
110026
  function createTagDefinitionMap() {
109191
110027
  return {
109192
- scalar: {},
109193
- sequence: {},
109194
- mapping: {}
110028
+ scalar: /* @__PURE__ */ Object.create(null),
110029
+ sequence: /* @__PURE__ */ Object.create(null),
110030
+ mapping: /* @__PURE__ */ Object.create(null)
109195
110031
  };
109196
110032
  }
109197
110033
  function createTagDefinitionListMap() {
@@ -109361,7 +110197,11 @@ var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
109361
110197
  return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
109362
110198
  },
109363
110199
  keys: (container) => Object.keys(container),
109364
- get: (container, key) => container[String(key)]
110200
+ get: (container, key) => {
110201
+ const normalizedKey = String(key);
110202
+ if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
110203
+ return container[normalizedKey];
110204
+ }
109365
110205
  });
109366
110206
  var DEFAULT_SNIPPET_OPTIONS = {
109367
110207
  maxLength: 79,
@@ -109697,10 +110537,10 @@ function getScalarValue(input, scalar) {
109697
110537
  return getPlainValue(input, valueStart, valueEnd);
109698
110538
  }
109699
110539
  }
109700
- var DEFAULT_TAG_HANDLERS = {
110540
+ var DEFAULT_TAG_HANDLERS = Object.assign(/* @__PURE__ */ Object.create(null), {
109701
110541
  "!": "!",
109702
110542
  "!!": "tag:yaml.org,2002:"
109703
- };
110543
+ });
109704
110544
  function tagPercentEncode(source) {
109705
110545
  return encodeURI(source).replace(/!/g, "%21");
109706
110546
  }
@@ -109953,6 +110793,10 @@ function constructFromEvents(events, options) {
109953
110793
  }
109954
110794
  case 6: {
109955
110795
  const frame = state.frames.pop();
110796
+ if (frame.kind === "mapping" && frame.hasKey) {
110797
+ state.position = frame.keyPosition;
110798
+ throwError$1(state, "incomplete mapping pair in event stream");
110799
+ }
109956
110800
  if (frame.kind === "document") state.documents.push(frame.value);
109957
110801
  else {
109958
110802
  const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
@@ -110623,10 +111467,6 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
110623
111467
  else if (state.lineIndent === parentIndent) indentStatus = 0;
110624
111468
  else indentStatus = -1;
110625
111469
  }
110626
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
110627
- state.depth--;
110628
- return false;
110629
- }
110630
111470
  if (indentStatus === 1) while (true) {
110631
111471
  const ch = state.input.charCodeAt(state.position);
110632
111472
  const propertyState = snapshotState(state);
@@ -111175,14 +112015,14 @@ function chooseScalarStyle(state, string, layout, singleLineOnly, forceQuote, in
111175
112015
  if (char === CHAR_LINE_FEED) {
111176
112016
  hasLineBreak = true;
111177
112017
  if (shouldTrackWidth) {
111178
- hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
112018
+ hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && !isMoreIndented(string[previousLineBreak + 1]);
111179
112019
  previousLineBreak = i;
111180
112020
  }
111181
112021
  } else if (!isPrintable(char)) return STYLE_DOUBLE;
111182
112022
  plain = plain && isPlainSafe(char, prevChar, inblock);
111183
112023
  prevChar = char;
111184
112024
  }
111185
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
112025
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && !isMoreIndented(string[previousLineBreak + 1]);
111186
112026
  }
111187
112027
  if (!hasLineBreak && !hasFoldableLine) {
111188
112028
  if (plain && !forceQuote) return STYLE_PLAIN;
@@ -111247,27 +112087,30 @@ function encodeFlowBreaks(string, indent) {
111247
112087
  function dropEndingNewline(string) {
111248
112088
  return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
111249
112089
  }
112090
+ function isMoreIndented(char) {
112091
+ return char === " " || char === " ";
112092
+ }
111250
112093
  function foldBlockScalar(string, width) {
111251
112094
  const lineRe = /(\n+)([^\n]*)/g;
111252
112095
  let nextLF = string.indexOf("\n");
111253
112096
  if (nextLF === -1) nextLF = string.length;
111254
112097
  lineRe.lastIndex = nextLF;
111255
112098
  let result = foldLine(string.slice(0, nextLF), width);
111256
- let prevMoreIndented = string[0] === "\n" || string[0] === " ";
112099
+ let prevMoreIndented = string[0] === "\n" || isMoreIndented(string[0]);
111257
112100
  let moreIndented;
111258
112101
  let match;
111259
112102
  while (match = lineRe.exec(string)) {
111260
112103
  const prefix = match[1];
111261
112104
  const line = match[2];
111262
- moreIndented = line[0] === " ";
112105
+ moreIndented = line !== "" && isMoreIndented(line[0]);
111263
112106
  result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
111264
112107
  prevMoreIndented = moreIndented;
111265
112108
  }
111266
112109
  return result;
111267
112110
  }
111268
112111
  function foldLine(line, width) {
111269
- if (line === "" || line[0] === " ") return line;
111270
- const breakRe = / [^ ]/g;
112112
+ if (line === "" || isMoreIndented(line[0])) return line;
112113
+ const breakRe = / [^ \t]/g;
111271
112114
  let match;
111272
112115
  let start = 0;
111273
112116
  let end;
@@ -112669,12 +113512,23 @@ var RepoMutationService = class {
112669
113512
  resolvedCurrentRef
112670
113513
  };
112671
113514
  }
112672
- await this.execute("git", [
113515
+ const commit = await this.execute("git", [
112673
113516
  "commit",
112674
113517
  "-m",
112675
113518
  "chore: sync Postman artifacts and metadata"
112676
113519
  ]);
112677
- let commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
113520
+ if (commit.exitCode !== 0) {
113521
+ throw new Error(
113522
+ secretMasker(commit.stderr || commit.stdout || "Failed to commit generated changes")
113523
+ );
113524
+ }
113525
+ const revision = await this.execute("git", ["rev-parse", "HEAD"]);
113526
+ let commitSha = revision.stdout.trim();
113527
+ if (revision.exitCode !== 0 || !commitSha) {
113528
+ throw new Error(
113529
+ secretMasker(revision.stderr || revision.stdout || "Failed to resolve generated commit")
113530
+ );
113531
+ }
112678
113532
  if (options.repoWriteMode !== "commit-and-push") {
112679
113533
  return {
112680
113534
  commitSha,
@@ -112796,11 +113650,11 @@ function normalizeRepoUrl(url) {
112796
113650
  const sshMatch = raw.match(/^git@([^:]+):(.+?)(?:\.git)?$/);
112797
113651
  if (sshMatch) {
112798
113652
  const host = sshMatch[1];
112799
- const path5 = sshMatch[2];
113653
+ const path6 = sshMatch[2];
112800
113654
  if (host === "ssh.dev.azure.com") {
112801
- return normalizeAzureReposSshPath2(path5);
113655
+ return normalizeAzureReposSshPath2(path6);
112802
113656
  }
112803
- return `https://${host}/${path5}`;
113657
+ return `https://${host}/${path6}`;
112804
113658
  }
112805
113659
  try {
112806
113660
  const parsed = new URL(raw);
@@ -113035,8 +113889,8 @@ function normalizeRepoUrl2(url) {
113035
113889
  const sshMatch = raw.match(/^git@([^:]+):(.+?)(?:\.git)?$/);
113036
113890
  if (sshMatch) {
113037
113891
  const host = sshMatch[1];
113038
- const path5 = sshMatch[2];
113039
- return `https://${host}/${path5}`;
113892
+ const path6 = sshMatch[2];
113893
+ return `https://${host}/${path6}`;
113040
113894
  }
113041
113895
  return raw.replace(/\.git$/, "");
113042
113896
  }
@@ -114784,8 +115638,8 @@ var BifrostInternalIntegrationAdapter = class {
114784
115638
  * - 403 + error.meta.workspaceId -> linked-invisible
114785
115639
  * - 200 + error.meta.workspaceId -> linked-invisible (proxy envelope)
114786
115640
  */
114787
- async findWorkspaceForRepo(repoUrl, path5 = "/") {
114788
- const fsPath = path5 && path5.trim() ? path5.trim() : "/";
115641
+ async findWorkspaceForRepo(repoUrl, path6 = "/") {
115642
+ const fsPath = path6 && path6.trim() ? path6.trim() : "/";
114789
115643
  const url = `${this.bifrostBaseUrl}/ws/proxy`;
114790
115644
  const payload = {
114791
115645
  service: "workspaces",
@@ -115025,10 +115879,14 @@ var postmanRepoSyncActionContract = {
115025
115879
  committerEmail: "support@postman.com"
115026
115880
  },
115027
115881
  inputs: {
115028
- "generate-ci-workflow": {
115029
- description: "Whether to generate the CI workflow file",
115882
+ "working-directory": {
115883
+ description: "Repository-root-relative directory used for all local inputs and generated artifacts.",
115030
115884
  required: false,
115031
- default: "true"
115885
+ default: ""
115886
+ },
115887
+ "generate-ci-workflow": {
115888
+ description: "Whether to generate the CI workflow file. Defaults to true at the repository root and false when working-directory is set.",
115889
+ required: false
115032
115890
  },
115033
115891
  "ci-workflow-path": {
115034
115892
  description: "Path to write the generated CI workflow file",
@@ -115374,8 +116232,8 @@ var PostmanAssetsClient = class {
115374
116232
  this.fetchImpl = options.fetchImpl ?? fetch;
115375
116233
  void (options.secretMasker ?? createSecretMasker([this.apiKey]));
115376
116234
  }
115377
- async request(path5, init = {}) {
115378
- const url = path5.startsWith("http") ? path5 : `${this.baseUrl}${path5}`;
116235
+ async request(path6, init = {}) {
116236
+ const url = path6.startsWith("http") ? path6 : `${this.baseUrl}${path6}`;
115379
116237
  const response = await this.fetchImpl(url, {
115380
116238
  ...init,
115381
116239
  headers: {
@@ -115920,9 +116778,9 @@ var PostmanGatewayAssetsClient = class {
115920
116778
  const row = this.asRecord(value);
115921
116779
  if (!row || row.type === "FOLDER") continue;
115922
116780
  if (row.type !== "FILE" || typeof row.id !== "string" || !row.id.trim() || typeof row.path !== "string" || !row.path.trim() || typeof row.content !== "string" || typeof row.fileType !== "string" || !row.fileType.trim()) return void 0;
115923
- const path5 = row.path.replace(/\\/g, "/").normalize("NFC");
115924
- if (path5.startsWith("/") || path5.split("/").some((part) => part === ".." || !part)) throw new Error("CONTRACT_DEFINITION_PATH_INVALID");
115925
- rows.push({ ...row, path: path5 });
116781
+ const path6 = row.path.replace(/\\/g, "/").normalize("NFC");
116782
+ if (path6.startsWith("/") || path6.split("/").some((part) => part === ".." || !part)) throw new Error("CONTRACT_DEFINITION_PATH_INVALID");
116783
+ rows.push({ ...row, path: path6 });
115926
116784
  }
115927
116785
  const meta = this.asRecord(response?.meta);
115928
116786
  const cursorValue = this.asRecord(meta?.cursor)?.next;
@@ -115935,9 +116793,9 @@ var PostmanGatewayAssetsClient = class {
115935
116793
  }
115936
116794
  const paths = /* @__PURE__ */ new Set();
115937
116795
  for (const row of rows) {
115938
- const path5 = String(row.path).toLocaleLowerCase();
115939
- if (paths.has(path5)) throw new Error("CONTRACT_DEFINITION_DUPLICATE_PATH");
115940
- paths.add(path5);
116796
+ const path6 = String(row.path).toLocaleLowerCase();
116797
+ if (paths.has(path6)) throw new Error("CONTRACT_DEFINITION_DUPLICATE_PATH");
116798
+ paths.add(path6);
115941
116799
  }
115942
116800
  const roots = rows.filter((row) => row.fileType === "ROOT");
115943
116801
  if (roots.length !== 1) throw new Error("CONTRACT_DEFINITION_INVENTORY_INVALID");
@@ -117067,10 +117925,10 @@ function detectProvider(env) {
117067
117925
  return "unknown";
117068
117926
  }
117069
117927
  function readGithubEvent(env) {
117070
- const path5 = clean(env.GITHUB_EVENT_PATH);
117071
- if (!path5) return void 0;
117928
+ const path6 = clean(env.GITHUB_EVENT_PATH);
117929
+ if (!path6) return void 0;
117072
117930
  try {
117073
- return JSON.parse((0, import_node_fs4.readFileSync)(path5, "utf8"));
117931
+ return JSON.parse((0, import_node_fs4.readFileSync)(path6, "utf8"));
117074
117932
  } catch {
117075
117933
  return void 0;
117076
117934
  }
@@ -117390,6 +118248,47 @@ function parseAssetMarker(description) {
117390
118248
  return void 0;
117391
118249
  }
117392
118250
 
118251
+ // src/lib/working-directory.ts
118252
+ var import_node_fs5 = require("node:fs");
118253
+ var import_node_path3 = __toESM(require("node:path"), 1);
118254
+ function invalidWorkingDirectory(message) {
118255
+ throw new Error(`Invalid working-directory: ${message}`);
118256
+ }
118257
+ function isOutside(root, candidate) {
118258
+ const relative3 = import_node_path3.default.relative(root, candidate);
118259
+ return relative3 === ".." || relative3.startsWith(`..${import_node_path3.default.sep}`) || import_node_path3.default.isAbsolute(relative3);
118260
+ }
118261
+ function activateWorkingDirectory(input, baseRoot) {
118262
+ const originalRoot = import_node_path3.default.resolve(baseRoot);
118263
+ const requested = input?.trim() ?? "";
118264
+ if (!requested) {
118265
+ return { changed: false, originalRoot, effectiveRoot: originalRoot };
118266
+ }
118267
+ if (import_node_path3.default.isAbsolute(requested)) {
118268
+ invalidWorkingDirectory("expected a repository-root-relative directory");
118269
+ }
118270
+ if (requested.split(/[\\/]/u).includes("..")) {
118271
+ invalidWorkingDirectory("path traversal is not allowed");
118272
+ }
118273
+ let originalRealPath;
118274
+ let effectiveRoot;
118275
+ try {
118276
+ originalRealPath = (0, import_node_fs5.realpathSync)(originalRoot);
118277
+ effectiveRoot = (0, import_node_fs5.realpathSync)(import_node_path3.default.resolve(originalRealPath, requested));
118278
+ } catch {
118279
+ invalidWorkingDirectory(`directory does not exist: ${requested}`);
118280
+ }
118281
+ if (isOutside(originalRealPath, effectiveRoot)) {
118282
+ invalidWorkingDirectory("resolved path must stay inside the repository root");
118283
+ }
118284
+ if (!(0, import_node_fs5.statSync)(effectiveRoot).isDirectory()) {
118285
+ invalidWorkingDirectory(`path is not a directory: ${requested}`);
118286
+ }
118287
+ process.chdir(effectiveRoot);
118288
+ process.env.GITHUB_WORKSPACE = effectiveRoot;
118289
+ return { changed: true, originalRoot: originalRealPath, effectiveRoot };
118290
+ }
118291
+
117393
118292
  // src/index.ts
117394
118293
  var identitySecretMasker = (input) => input;
117395
118294
  function resolveRepoSyncMasker(dependencies) {
@@ -117634,7 +118533,22 @@ function resolveInputs(env = process.env) {
117634
118533
  const postmanRegion = parsePostmanRegion(getInput("postman-region", env));
117635
118534
  const postmanStack = parsePostmanStack(getInput("postman-stack", env));
117636
118535
  const endpointProfile = resolvePostmanEndpointProfile(postmanStack, postmanRegion, env);
118536
+ const workingDirectory = getInput("working-directory", env);
118537
+ const generateCiWorkflowInput = getInput("generate-ci-workflow", env);
118538
+ let generateCiWorkflow = parseBooleanInput(generateCiWorkflowInput, true);
118539
+ let generateCiWorkflowDefaulted = false;
118540
+ if (workingDirectory) {
118541
+ if (!generateCiWorkflowInput) {
118542
+ generateCiWorkflow = false;
118543
+ generateCiWorkflowDefaulted = true;
118544
+ } else if (generateCiWorkflow) {
118545
+ throw new Error(
118546
+ "generate-ci-workflow=true is not supported with working-directory because GitHub ignores nested workflow files. Set generate-ci-workflow=false and use the monorepo dispatcher guide."
118547
+ );
118548
+ }
118549
+ }
117637
118550
  return {
118551
+ workingDirectory,
117638
118552
  projectName: getInput("project-name", env),
117639
118553
  workspaceId: getInput("workspace-id", env),
117640
118554
  baselineCollectionId: getInput("baseline-collection-id", env),
@@ -117676,7 +118590,8 @@ function resolveInputs(env = process.env) {
117676
118590
  ghFallbackToken: getInput("gh-fallback-token", env),
117677
118591
  provider: repoContext.provider,
117678
118592
  ciWorkflowBase64: getInput("ci-workflow-base64", env),
117679
- generateCiWorkflow: parseBooleanInput(getInput("generate-ci-workflow", env), true),
118593
+ generateCiWorkflow,
118594
+ generateCiWorkflowDefaulted,
117680
118595
  ciRunnerOs: parseCiRunnerOs(getInput("ci-runner-os", env)),
117681
118596
  monitorType: getInput("monitor-type", env) || "cloud",
117682
118597
  ciWorkflowPath: getInput("ci-workflow-path", env) || (repoContext.provider === "azure-devops" ? "azure-pipelines.yml" : ".github/workflows/ci.yml"),
@@ -117779,7 +118694,7 @@ var StateUnreadableError = class extends Error {
117779
118694
  function readResourcesState() {
117780
118695
  let raw;
117781
118696
  try {
117782
- raw = (0, import_node_fs5.readFileSync)(".postman/resources.yaml", "utf8");
118697
+ raw = (0, import_node_fs6.readFileSync)(".postman/resources.yaml", "utf8");
117783
118698
  } catch {
117784
118699
  return null;
117785
118700
  }
@@ -117836,7 +118751,7 @@ function getEnvironmentUidsFromResources(resourcesState) {
117836
118751
  );
117837
118752
  }
117838
118753
  function normalizeToPosix(filePath) {
117839
- return filePath.split(path3.sep).join("/").replace(/\\/g, "/");
118754
+ return filePath.split(path4.sep).join("/").replace(/\\/g, "/");
117840
118755
  }
117841
118756
  function canonicalizeRelativePath(value) {
117842
118757
  return normalizeToPosix(String(value ?? "").trim()).replace(/^\.\/+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/g, "");
@@ -117884,7 +118799,7 @@ function isSpecCandidateExtension(filePath) {
117884
118799
  }
117885
118800
  function readOpenApiSpecFile(fullPath) {
117886
118801
  try {
117887
- const raw = (0, import_node_fs5.readFileSync)(fullPath, "utf8");
118802
+ const raw = (0, import_node_fs6.readFileSync)(fullPath, "utf8");
117888
118803
  const parsed = fullPath.endsWith(".json") ? JSON.parse(raw) : load(raw);
117889
118804
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
117890
118805
  return false;
@@ -117905,7 +118820,7 @@ function shouldIgnoreSpecDiscoveryEntry(entryName, currentDir, baseDir, ignoredP
117905
118820
  if (LOCAL_SPEC_DISCOVERY_IGNORED_DIRS.has(entryName)) {
117906
118821
  return true;
117907
118822
  }
117908
- const relative3 = normalizeToPosix(path3.relative(baseDir, path3.join(currentDir, entryName)));
118823
+ const relative3 = normalizeToPosix(path4.relative(baseDir, path4.join(currentDir, entryName)));
117909
118824
  return ignoredPrefixes.some(
117910
118825
  (prefix) => relative3 === prefix || relative3.startsWith(`${prefix}/`)
117911
118826
  );
@@ -117921,7 +118836,7 @@ function scanLocalSpecReferences(baseDir = ".", options = {}) {
117921
118836
  const { dir: currentDir, depth: currentDepth } = pendingDirs.shift();
117922
118837
  let entries;
117923
118838
  try {
117924
- entries = (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true }).sort(
118839
+ entries = (0, import_node_fs6.readdirSync)(currentDir, { withFileTypes: true }).sort(
117925
118840
  (left, right) => left.name.localeCompare(right.name)
117926
118841
  );
117927
118842
  } catch {
@@ -117937,7 +118852,7 @@ function scanLocalSpecReferences(baseDir = ".", options = {}) {
117937
118852
  if (shouldIgnoreSpecDiscoveryEntry(entry.name, currentDir, baseDir, ignoredPrefixes)) {
117938
118853
  continue;
117939
118854
  }
117940
- const fullPath = path3.join(currentDir, entry.name);
118855
+ const fullPath = path4.join(currentDir, entry.name);
117941
118856
  if (entry.isDirectory()) {
117942
118857
  const nextDepth = currentDepth + 1;
117943
118858
  if (nextDepth > LOCAL_SPEC_DISCOVERY_MAX_DEPTH) {
@@ -117959,12 +118874,12 @@ function scanLocalSpecReferences(baseDir = ".", options = {}) {
117959
118874
  }
117960
118875
  let sizeBytes;
117961
118876
  try {
117962
- sizeBytes = (0, import_node_fs5.statSync)(fullPath).size;
118877
+ sizeBytes = (0, import_node_fs6.statSync)(fullPath).size;
117963
118878
  } catch {
117964
118879
  continue;
117965
118880
  }
117966
118881
  if (sizeBytes > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES) {
117967
- const repoRelativePath2 = normalizeToPosix(path3.relative(baseDir, fullPath));
118882
+ const repoRelativePath2 = normalizeToPosix(path4.relative(baseDir, fullPath));
117968
118883
  failLocalSpecDiscoveryLimit(
117969
118884
  `local spec discovery candidate ${repoRelativePath2} exceeds ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES} bytes.`
117970
118885
  );
@@ -117972,14 +118887,14 @@ function scanLocalSpecReferences(baseDir = ".", options = {}) {
117972
118887
  if (!readOpenApiSpecFile(fullPath)) {
117973
118888
  continue;
117974
118889
  }
117975
- const repoRelativePath = normalizeToPosix(path3.relative(baseDir, fullPath));
118890
+ const repoRelativePath = normalizeToPosix(path4.relative(baseDir, fullPath));
117976
118891
  if (found.has(repoRelativePath)) {
117977
118892
  continue;
117978
118893
  }
117979
118894
  found.add(repoRelativePath);
117980
118895
  refs.push({
117981
118896
  repoRelativePath,
117982
- configRelativePath: normalizeToPosix(path3.join("..", repoRelativePath))
118897
+ configRelativePath: normalizeToPosix(path4.join("..", repoRelativePath))
117983
118898
  });
117984
118899
  }
117985
118900
  }
@@ -117990,11 +118905,11 @@ function tryResolveExplicitSpecReference(explicitSpecPath) {
117990
118905
  if (!normalizedExplicitPath) {
117991
118906
  return void 0;
117992
118907
  }
117993
- const explicitFullPath = path3.resolve(normalizedExplicitPath);
117994
- if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
118908
+ const explicitFullPath = path4.resolve(normalizedExplicitPath);
118909
+ if ((0, import_node_fs6.existsSync)(explicitFullPath) && (0, import_node_fs6.statSync)(explicitFullPath).isFile()) {
117995
118910
  return {
117996
118911
  repoRelativePath: normalizedExplicitPath,
117997
- configRelativePath: normalizeToPosix(path3.join("..", normalizedExplicitPath))
118912
+ configRelativePath: normalizeToPosix(path4.join("..", normalizedExplicitPath))
117998
118913
  };
117999
118914
  }
118000
118915
  return void 0;
@@ -118243,8 +119158,8 @@ async function upsertMockEnvironment(inputs, dependencies, assetProjectName, moc
118243
119158
  return "";
118244
119159
  }
118245
119160
  }
118246
- function ensureDir(path5) {
118247
- (0, import_node_fs5.mkdirSync)(path5, { recursive: true });
119161
+ function ensureDir(path6) {
119162
+ (0, import_node_fs6.mkdirSync)(path6, { recursive: true });
118248
119163
  }
118249
119164
  function getCollectionDirectoryName(kind, projectName) {
118250
119165
  if (kind === "Baseline") {
@@ -118279,9 +119194,9 @@ function stripVolatileFields(obj) {
118279
119194
  }
118280
119195
  return obj;
118281
119196
  }
118282
- function writeJsonFile(path5, content, normalize4 = false) {
119197
+ function writeJsonFile(path6, content, normalize4 = false) {
118283
119198
  const data = normalize4 ? stripVolatileFields(content) : content;
118284
- (0, import_node_fs5.writeFileSync)(path5, JSON.stringify(data, null, 2));
119199
+ (0, import_node_fs6.writeFileSync)(path6, JSON.stringify(data, null, 2));
118285
119200
  }
118286
119201
  function sanitizeMockEnvironmentArtifact(content) {
118287
119202
  if (Array.isArray(content)) {
@@ -118534,32 +119449,32 @@ function parsePrebuiltCollectionsJson(raw) {
118534
119449
  function assertPathWithinArtifactRoot(targetPath, artifactDir, fieldName) {
118535
119450
  assertPathWithinCwd(targetPath, fieldName);
118536
119451
  assertPathWithinCwd(artifactDir, "artifact-dir");
118537
- const cwd = (0, import_node_fs5.realpathSync)(process.cwd());
118538
- const artifactRoot = path3.resolve(cwd, artifactDir.trim());
118539
- const resolved = path3.resolve(cwd, targetPath.trim());
118540
- const relativeToArtifact = path3.relative(artifactRoot, resolved);
118541
- if (!relativeToArtifact || relativeToArtifact.startsWith("..") || path3.isAbsolute(relativeToArtifact)) {
119452
+ const cwd = (0, import_node_fs6.realpathSync)(process.cwd());
119453
+ const artifactRoot = path4.resolve(cwd, artifactDir.trim());
119454
+ const resolved = path4.resolve(cwd, targetPath.trim());
119455
+ const relativeToArtifact = path4.relative(artifactRoot, resolved);
119456
+ if (!relativeToArtifact || relativeToArtifact.startsWith("..") || path4.isAbsolute(relativeToArtifact)) {
118542
119457
  failPrebuiltCollections(
118543
119458
  `${fieldName} must stay under artifact-dir (${artifactDir}); received ${targetPath}`
118544
119459
  );
118545
119460
  }
118546
119461
  let existingPath = resolved;
118547
- while (!(0, import_node_fs5.existsSync)(existingPath)) {
118548
- const parent = path3.dirname(existingPath);
119462
+ while (!(0, import_node_fs6.existsSync)(existingPath)) {
119463
+ const parent = path4.dirname(existingPath);
118549
119464
  if (parent === existingPath) {
118550
119465
  break;
118551
119466
  }
118552
119467
  existingPath = parent;
118553
119468
  }
118554
- const realExisting = (0, import_node_fs5.realpathSync)(existingPath);
118555
- const realArtifactRoot = (0, import_node_fs5.existsSync)(artifactRoot) ? (0, import_node_fs5.realpathSync)(artifactRoot) : void 0;
118556
- const realRelative = realArtifactRoot ? path3.relative(realArtifactRoot, realExisting) : "";
118557
- if (realArtifactRoot && (realRelative.startsWith("..") || path3.isAbsolute(realRelative))) {
119469
+ const realExisting = (0, import_node_fs6.realpathSync)(existingPath);
119470
+ const realArtifactRoot = (0, import_node_fs6.existsSync)(artifactRoot) ? (0, import_node_fs6.realpathSync)(artifactRoot) : void 0;
119471
+ const realRelative = realArtifactRoot ? path4.relative(realArtifactRoot, realExisting) : "";
119472
+ if (realArtifactRoot && (realRelative.startsWith("..") || path4.isAbsolute(realRelative))) {
118558
119473
  failPrebuiltCollections(
118559
119474
  `${fieldName} resolves outside artifact-dir via symlink; received ${targetPath}`
118560
119475
  );
118561
119476
  }
118562
- return normalizeToPosix(path3.relative(cwd, resolved));
119477
+ return normalizeToPosix(path4.relative(cwd, resolved));
118563
119478
  }
118564
119479
  function prebuiltDirectoryTraversalIdentity(absolutePath, stats, options = {}) {
118565
119480
  const platform2 = options.platform ?? process.platform;
@@ -118567,7 +119482,7 @@ function prebuiltDirectoryTraversalIdentity(absolutePath, stats, options = {}) {
118567
119482
  if (platform2 !== "win32" && !inodeIsZero) {
118568
119483
  return `${stats.dev}:${stats.ino}`;
118569
119484
  }
118570
- const resolveCanonicalPath = options.resolveCanonicalPath ?? ((candidate) => import_node_fs5.realpathSync.native(candidate));
119485
+ const resolveCanonicalPath = options.resolveCanonicalPath ?? ((candidate) => import_node_fs6.realpathSync.native(candidate));
118571
119486
  const canonical = resolveCanonicalPath(absolutePath);
118572
119487
  return platform2 === "win32" ? canonical.toLowerCase() : canonical;
118573
119488
  }
@@ -118577,13 +119492,13 @@ function listPrebuiltCollectionTreeFiles(collectionPath, artifactDir) {
118577
119492
  artifactDir,
118578
119493
  "prebuilt collection path"
118579
119494
  );
118580
- const absRoot = path3.resolve(process.cwd(), confined);
118581
- if (!(0, import_node_fs5.existsSync)(absRoot)) {
119495
+ const absRoot = path4.resolve(process.cwd(), confined);
119496
+ if (!(0, import_node_fs6.existsSync)(absRoot)) {
118582
119497
  return [];
118583
119498
  }
118584
119499
  let rootStat;
118585
119500
  try {
118586
- rootStat = (0, import_node_fs5.lstatSync)(absRoot);
119501
+ rootStat = (0, import_node_fs6.lstatSync)(absRoot);
118587
119502
  } catch {
118588
119503
  return [];
118589
119504
  }
@@ -118606,20 +119521,20 @@ function listPrebuiltCollectionTreeFiles(collectionPath, artifactDir) {
118606
119521
  break;
118607
119522
  }
118608
119523
  const { absolute: currentAbsolute, depth: currentDepth } = current;
118609
- const currentStat = (0, import_node_fs5.lstatSync)(currentAbsolute);
119524
+ const currentStat = (0, import_node_fs6.lstatSync)(currentAbsolute);
118610
119525
  if (currentStat.isSymbolicLink() || !currentStat.isDirectory()) {
118611
119526
  failPrebuiltCollections(
118612
- `prebuilt collection tree directory changed or became unsupported at ${normalizeToPosix(path3.relative(absRoot, currentAbsolute)) || "."}`
119527
+ `prebuilt collection tree directory changed or became unsupported at ${normalizeToPosix(path4.relative(absRoot, currentAbsolute)) || "."}`
118613
119528
  );
118614
119529
  }
118615
119530
  const currentKey = prebuiltDirectoryTraversalIdentity(currentAbsolute, currentStat);
118616
119531
  if (seenDirectories.has(currentKey)) {
118617
119532
  failPrebuiltCollections(
118618
- `prebuilt collection tree directory cycle detected at ${normalizeToPosix(path3.relative(absRoot, currentAbsolute)) || "."}`
119533
+ `prebuilt collection tree directory cycle detected at ${normalizeToPosix(path4.relative(absRoot, currentAbsolute)) || "."}`
118619
119534
  );
118620
119535
  }
118621
119536
  seenDirectories.add(currentKey);
118622
- const entries = (0, import_node_fs5.readdirSync)(currentAbsolute, { withFileTypes: true }).sort(
119537
+ const entries = (0, import_node_fs6.readdirSync)(currentAbsolute, { withFileTypes: true }).sort(
118623
119538
  (left, right) => left.name.localeCompare(right.name)
118624
119539
  );
118625
119540
  for (const entry of entries) {
@@ -118629,10 +119544,10 @@ function listPrebuiltCollectionTreeFiles(collectionPath, artifactDir) {
118629
119544
  `prebuilt collection tree exceeded the ${PREBUILT_COLLECTION_MAX_TRAVERSAL_ENTRIES} traversal-entry budget`
118630
119545
  );
118631
119546
  }
118632
- const abs = path3.join(currentAbsolute, entry.name);
119547
+ const abs = path4.join(currentAbsolute, entry.name);
118633
119548
  if (entry.isSymbolicLink()) {
118634
119549
  failPrebuiltCollections(
118635
- `prebuilt collection tree must not contain symlinks; received ${normalizeToPosix(path3.relative(absRoot, abs))}`
119550
+ `prebuilt collection tree must not contain symlinks; received ${normalizeToPosix(path4.relative(absRoot, abs))}`
118636
119551
  );
118637
119552
  }
118638
119553
  if (entry.isDirectory()) {
@@ -118647,18 +119562,18 @@ function listPrebuiltCollectionTreeFiles(collectionPath, artifactDir) {
118647
119562
  }
118648
119563
  if (!entry.isFile()) {
118649
119564
  failPrebuiltCollections(
118650
- `prebuilt collection tree contains unsupported entry type at ${normalizeToPosix(path3.relative(absRoot, abs))}`
119565
+ `prebuilt collection tree contains unsupported entry type at ${normalizeToPosix(path4.relative(absRoot, abs))}`
118651
119566
  );
118652
119567
  }
118653
- const fileLstat = (0, import_node_fs5.lstatSync)(abs);
119568
+ const fileLstat = (0, import_node_fs6.lstatSync)(abs);
118654
119569
  if (fileLstat.isSymbolicLink() || !fileLstat.isFile()) {
118655
119570
  failPrebuiltCollections(
118656
- `prebuilt collection tree file changed or became unsupported at ${normalizeToPosix(path3.relative(absRoot, abs))}`
119571
+ `prebuilt collection tree file changed or became unsupported at ${normalizeToPosix(path4.relative(absRoot, abs))}`
118657
119572
  );
118658
119573
  }
118659
119574
  if (fileLstat.size > PREBUILT_COLLECTION_MAX_FILE_BYTES) {
118660
119575
  failPrebuiltCollections(
118661
- `prebuilt collection tree file ${normalizeToPosix(path3.relative(absRoot, abs))} exceeds the ${PREBUILT_COLLECTION_MAX_FILE_BYTES / (1024 * 1024)} MiB individual-file budget`
119576
+ `prebuilt collection tree file ${normalizeToPosix(path4.relative(absRoot, abs))} exceeds the ${PREBUILT_COLLECTION_MAX_FILE_BYTES / (1024 * 1024)} MiB individual-file budget`
118662
119577
  );
118663
119578
  }
118664
119579
  totalBytes += fileLstat.size;
@@ -118669,7 +119584,7 @@ function listPrebuiltCollectionTreeFiles(collectionPath, artifactDir) {
118669
119584
  }
118670
119585
  files.push({
118671
119586
  absolute: abs,
118672
- relative: normalizeToPosix(path3.relative(absRoot, abs)),
119587
+ relative: normalizeToPosix(path4.relative(absRoot, abs)),
118673
119588
  dev: fileLstat.dev,
118674
119589
  ino: fileLstat.ino,
118675
119590
  size: fileLstat.size
@@ -118753,8 +119668,8 @@ async function preparePrebuiltCollections(inputs) {
118753
119668
  inputs.artifactDir,
118754
119669
  `prebuilt ${entry.role} collection path`
118755
119670
  );
118756
- const absolute = path3.resolve(process.cwd(), confinedPath);
118757
- if (!(0, import_node_fs5.existsSync)(absolute)) {
119671
+ const absolute = path4.resolve(process.cwd(), confinedPath);
119672
+ if (!(0, import_node_fs6.existsSync)(absolute)) {
118758
119673
  prepared.set(entry.role, { entry, confinedPath });
118759
119674
  continue;
118760
119675
  }
@@ -118783,8 +119698,8 @@ function tryReusePrebuiltCollection(options) {
118783
119698
  if (confined !== expectedNormalized) {
118784
119699
  return false;
118785
119700
  }
118786
- const expectedName = path3.posix.basename(expectedNormalized);
118787
- if (path3.posix.basename(confined) !== expectedName) {
119701
+ const expectedName = path4.posix.basename(expectedNormalized);
119702
+ if (path4.posix.basename(confined) !== expectedName) {
118788
119703
  return false;
118789
119704
  }
118790
119705
  return prepared.artifactDigest === entry.artifactDigest;
@@ -118879,26 +119794,26 @@ function assertPathWithinCwd(targetPath, fieldName) {
118879
119794
  const originalPath = String(targetPath || "");
118880
119795
  const rawPath = originalPath.trim();
118881
119796
  const segments = rawPath.split(/[\\/]+/).filter(Boolean);
118882
- if (!rawPath || hasControlCharacter2(originalPath) || path3.isAbsolute(rawPath) || path3.win32.isAbsolute(rawPath) || segments.includes("..") || rawPath.startsWith(":") || hasControlCharacter2(rawPath)) {
119797
+ if (!rawPath || hasControlCharacter2(originalPath) || path4.isAbsolute(rawPath) || path4.win32.isAbsolute(rawPath) || segments.includes("..") || rawPath.startsWith(":") || hasControlCharacter2(rawPath)) {
118883
119798
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
118884
119799
  }
118885
- const base = (0, import_node_fs5.realpathSync)(process.cwd());
118886
- const resolved = path3.resolve(base, rawPath);
118887
- const relative3 = path3.relative(base, resolved);
118888
- if (relative3.startsWith("..") || path3.isAbsolute(relative3)) {
119800
+ const base = (0, import_node_fs6.realpathSync)(process.cwd());
119801
+ const resolved = path4.resolve(base, rawPath);
119802
+ const relative3 = path4.relative(base, resolved);
119803
+ if (relative3.startsWith("..") || path4.isAbsolute(relative3)) {
118889
119804
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
118890
119805
  }
118891
119806
  let existingPath = resolved;
118892
- while (!(0, import_node_fs5.existsSync)(existingPath)) {
118893
- const parent = path3.dirname(existingPath);
119807
+ while (!(0, import_node_fs6.existsSync)(existingPath)) {
119808
+ const parent = path4.dirname(existingPath);
118894
119809
  if (parent === existingPath) {
118895
119810
  break;
118896
119811
  }
118897
119812
  existingPath = parent;
118898
119813
  }
118899
- const realExistingPath = (0, import_node_fs5.realpathSync)(existingPath);
118900
- const realRelative = path3.relative(base, realExistingPath);
118901
- if (realRelative.startsWith("..") || path3.isAbsolute(realRelative)) {
119814
+ const realExistingPath = (0, import_node_fs6.realpathSync)(existingPath);
119815
+ const realRelative = path4.relative(base, realExistingPath);
119816
+ if (realRelative.startsWith("..") || path4.isAbsolute(realRelative)) {
118902
119817
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
118903
119818
  }
118904
119819
  }
@@ -118947,7 +119862,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
118947
119862
  }
118948
119863
  ensureDir(".postman");
118949
119864
  assertPathWithinCwd(".postman/resources.yaml", "resources state target");
118950
- (0, import_node_fs5.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
119865
+ (0, import_node_fs6.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
118951
119866
  durableWorkspaceId,
118952
119867
  {},
118953
119868
  {},
@@ -119014,8 +119929,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
119014
119929
  ensureDir(specsDir);
119015
119930
  ensureDir(".postman");
119016
119931
  const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
119017
- if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
119018
- (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
119932
+ if (!(0, import_node_fs6.existsSync)(globalsFilePath)) {
119933
+ (0, import_node_fs6.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
119019
119934
  }
119020
119935
  if (inputs.generateCiWorkflow) {
119021
119936
  const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
@@ -119061,7 +119976,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
119061
119976
  );
119062
119977
  }
119063
119978
  assertPathWithinCwd(".postman/resources.yaml", "resources state target");
119064
- (0, import_node_fs5.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
119979
+ (0, import_node_fs6.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
119065
119980
  durableWorkspaceId,
119066
119981
  manifestCollections,
119067
119982
  envUids,
@@ -119075,12 +119990,12 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
119075
119990
  if (mappedSpec && Object.keys(manifestCollections).length > 0) {
119076
119991
  let existingWorkflows;
119077
119992
  try {
119078
- existingWorkflows = (0, import_node_fs5.readFileSync)(".postman/workflows.yaml", "utf8");
119993
+ existingWorkflows = (0, import_node_fs6.readFileSync)(".postman/workflows.yaml", "utf8");
119079
119994
  } catch {
119080
119995
  existingWorkflows = void 0;
119081
119996
  }
119082
119997
  assertPathWithinCwd(".postman/workflows.yaml", "workflows state target");
119083
- (0, import_node_fs5.writeFileSync)(
119998
+ (0, import_node_fs6.writeFileSync)(
119084
119999
  ".postman/workflows.yaml",
119085
120000
  buildSpecCollectionWorkflowManifest(
119086
120001
  mappedSpec.configRelativePath,
@@ -119136,13 +120051,13 @@ async function commitAndPushGeneratedFiles(inputs, dependencies, privateMockAuth
119136
120051
  const dir = parts.slice(0, -1).join("/");
119137
120052
  ensureDir(dir);
119138
120053
  }
119139
- (0, import_node_fs5.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
120054
+ (0, import_node_fs6.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
119140
120055
  if (inputs.provider === "github" || inputs.provider === "unknown") {
119141
120056
  const gcPath = ".github/workflows/postman-preview-gc.yml";
119142
120057
  if (inputs.ciWorkflowPath.endsWith(".github/workflows/ci.yml") || inputs.ciWorkflowPath === ".github/workflows/ci.yml") {
119143
120058
  assertPathWithinCwd(gcPath, "preview GC workflow path");
119144
120059
  ensureDir(".github/workflows");
119145
- (0, import_node_fs5.writeFileSync)(gcPath, renderGcWorkflowTemplate());
120060
+ (0, import_node_fs6.writeFileSync)(gcPath, renderGcWorkflowTemplate());
119146
120061
  }
119147
120062
  }
119148
120063
  }
@@ -119150,16 +120065,16 @@ async function commitAndPushGeneratedFiles(inputs, dependencies, privateMockAuth
119150
120065
  return { commitSha: "", resolvedCurrentRef: "", pushed: false };
119151
120066
  }
119152
120067
  const provisionPath = ".github/workflows/provision.yml";
119153
- const provisionExists = inputs.provider === "github" && (0, import_node_fs5.existsSync)(provisionPath);
120068
+ const provisionExists = inputs.provider === "github" && (0, import_node_fs6.existsSync)(provisionPath);
119154
120069
  const gcWorkflowPath = ".github/workflows/postman-preview-gc.yml";
119155
- const gcExists = inputs.generateCiWorkflow && (0, import_node_fs5.existsSync)(gcWorkflowPath);
120070
+ const gcExists = inputs.generateCiWorkflow && (0, import_node_fs6.existsSync)(gcWorkflowPath);
119156
120071
  const stagePaths = (inputs.onboardingScope === "spec-only" ? [".postman/resources.yaml"] : [
119157
120072
  inputs.artifactDir,
119158
120073
  ".postman",
119159
120074
  inputs.generateCiWorkflow ? inputs.ciWorkflowPath : null,
119160
120075
  gcExists ? gcWorkflowPath : null,
119161
120076
  provisionExists ? provisionPath : null
119162
- ]).filter((entry) => typeof entry === "string" && ((0, import_node_fs5.existsSync)(entry) || entry === provisionPath));
120077
+ ]).filter((entry) => typeof entry === "string" && ((0, import_node_fs6.existsSync)(entry) || entry === provisionPath));
119163
120078
  if (stagePaths.length === 0) {
119164
120079
  dependencies.core.info("No generated repository paths were found; skipping repo mutation.");
119165
120080
  return {
@@ -120104,6 +121019,7 @@ function createRepoSyncDependencies(inputs, resolved, factories, options = {}) {
120104
121019
  listSpecVersionTags: gatewayAssets.listSpecVersionTags.bind(gatewayAssets)
120105
121020
  };
120106
121021
  const repoMutation = repository && (inputs.repoWriteMode === "commit-only" || inputs.repoWriteMode === "commit-and-push") ? new RepoMutationService({
121022
+ cwd: process.cwd(),
120107
121023
  provider: inputs.provider,
120108
121024
  repository,
120109
121025
  repoUrl: inputs.repoUrl || void 0,
@@ -120539,6 +121455,7 @@ async function runGc(options) {
120539
121455
  // src/cli.ts
120540
121456
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
120541
121457
  var CLI_INPUT_NAMES = [
121458
+ "working-directory",
120542
121459
  "project-name",
120543
121460
  "workspace-id",
120544
121461
  "baseline-collection-id",
@@ -120723,12 +121640,12 @@ function resolvePackageVersion() {
120723
121640
  }
120724
121641
  const candidates = [];
120725
121642
  if (typeof __filename === "string" && __filename) {
120726
- candidates.push(import_node_path3.default.join(import_node_path3.default.dirname(__filename), "..", "package.json"));
121643
+ candidates.push(import_node_path4.default.join(import_node_path4.default.dirname(__filename), "..", "package.json"));
120727
121644
  }
120728
- candidates.push(import_node_path3.default.join(process.cwd(), "package.json"));
121645
+ candidates.push(import_node_path4.default.join(process.cwd(), "package.json"));
120729
121646
  for (const packageJsonPath of candidates) {
120730
121647
  try {
120731
- const packageJson = JSON.parse((0, import_node_fs6.readFileSync)(packageJsonPath, "utf8"));
121648
+ const packageJson = JSON.parse((0, import_node_fs7.readFileSync)(packageJsonPath, "utf8"));
120732
121649
  if (packageJson.name === "@postman-cs/onboarding-repo-sync" && packageJson.version) {
120733
121650
  return String(packageJson.version).trim();
120734
121651
  }
@@ -120840,56 +121757,56 @@ function toDotenv(outputs) {
120840
121757
  ]).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join("\n");
120841
121758
  }
120842
121759
  function assertOutputFileAllowed(filePath) {
120843
- const workspaceRoot = (0, import_node_fs6.realpathSync)(import_node_path3.default.resolve(process.cwd()));
120844
- const resolved = import_node_path3.default.resolve(workspaceRoot, filePath);
120845
- const relative3 = import_node_path3.default.relative(workspaceRoot, resolved);
120846
- if (relative3.startsWith("..") || import_node_path3.default.isAbsolute(relative3)) {
121760
+ const workspaceRoot = (0, import_node_fs7.realpathSync)(import_node_path4.default.resolve(process.cwd()));
121761
+ const resolved = import_node_path4.default.resolve(workspaceRoot, filePath);
121762
+ const relative3 = import_node_path4.default.relative(workspaceRoot, resolved);
121763
+ if (relative3.startsWith("..") || import_node_path4.default.isAbsolute(relative3)) {
120847
121764
  throw new Error(`Output path must stay within workspace: ${filePath}`);
120848
121765
  }
120849
- let existingParent = import_node_path3.default.dirname(resolved);
120850
- while (!(0, import_node_fs6.existsSync)(existingParent)) {
120851
- const parent = import_node_path3.default.dirname(existingParent);
121766
+ let existingParent = import_node_path4.default.dirname(resolved);
121767
+ while (!(0, import_node_fs7.existsSync)(existingParent)) {
121768
+ const parent = import_node_path4.default.dirname(existingParent);
120852
121769
  if (parent === existingParent) break;
120853
121770
  existingParent = parent;
120854
121771
  }
120855
- const parentReal = (0, import_node_fs6.realpathSync)(existingParent);
120856
- const parentRelative = import_node_path3.default.relative(workspaceRoot, parentReal);
120857
- if (parentRelative.startsWith("..") || import_node_path3.default.isAbsolute(parentRelative)) {
121772
+ const parentReal = (0, import_node_fs7.realpathSync)(existingParent);
121773
+ const parentRelative = import_node_path4.default.relative(workspaceRoot, parentReal);
121774
+ if (parentRelative.startsWith("..") || import_node_path4.default.isAbsolute(parentRelative)) {
120858
121775
  throw new Error(`Output path must stay within workspace: ${filePath}`);
120859
121776
  }
120860
- if ((0, import_node_fs6.existsSync)(resolved) || (() => {
121777
+ if ((0, import_node_fs7.existsSync)(resolved) || (() => {
120861
121778
  try {
120862
- (0, import_node_fs6.lstatSync)(resolved);
121779
+ (0, import_node_fs7.lstatSync)(resolved);
120863
121780
  return true;
120864
121781
  } catch {
120865
121782
  return false;
120866
121783
  }
120867
121784
  })()) {
120868
- const targetReal = (0, import_node_fs6.realpathSync)(resolved);
120869
- const targetRelative = import_node_path3.default.relative(workspaceRoot, targetReal);
120870
- if (targetRelative.startsWith("..") || import_node_path3.default.isAbsolute(targetRelative)) {
121785
+ const targetReal = (0, import_node_fs7.realpathSync)(resolved);
121786
+ const targetRelative = import_node_path4.default.relative(workspaceRoot, targetReal);
121787
+ if (targetRelative.startsWith("..") || import_node_path4.default.isAbsolute(targetRelative)) {
120871
121788
  throw new Error(`Output path must stay within workspace: ${filePath}`);
120872
121789
  }
120873
121790
  }
120874
- return { resolved, directory: import_node_path3.default.dirname(resolved) };
121791
+ return { resolved, directory: import_node_path4.default.dirname(resolved) };
120875
121792
  }
120876
121793
  function resolveSymlinkAwarePath(filePath) {
120877
- const workspaceRoot = (0, import_node_fs6.realpathSync)(import_node_path3.default.resolve(process.cwd()));
120878
- const resolved = import_node_path3.default.resolve(workspaceRoot, filePath);
121794
+ const workspaceRoot = (0, import_node_fs7.realpathSync)(import_node_path4.default.resolve(process.cwd()));
121795
+ const resolved = import_node_path4.default.resolve(workspaceRoot, filePath);
120879
121796
  let existing = resolved;
120880
- while (!(0, import_node_fs6.existsSync)(existing)) {
120881
- const parent = import_node_path3.default.dirname(existing);
121797
+ while (!(0, import_node_fs7.existsSync)(existing)) {
121798
+ const parent = import_node_path4.default.dirname(existing);
120882
121799
  if (parent === existing) break;
120883
121800
  existing = parent;
120884
121801
  }
120885
- return import_node_path3.default.resolve((0, import_node_fs6.realpathSync)(existing), import_node_path3.default.relative(existing, resolved));
121802
+ return import_node_path4.default.resolve((0, import_node_fs7.realpathSync)(existing), import_node_path4.default.relative(existing, resolved));
120886
121803
  }
120887
121804
  function assertResultPathOutsideGeneratedPaths(resultJsonPath, inputs) {
120888
121805
  const result = assertOutputFileAllowed(resultJsonPath).resolved;
120889
121806
  const resultReal = resolveSymlinkAwarePath(result);
120890
121807
  for (const root of [inputs.artifactDir, ".postman"].map(resolveSymlinkAwarePath)) {
120891
- const relative3 = import_node_path3.default.relative(root, resultReal);
120892
- if (!relative3 || !relative3.startsWith("..") && !import_node_path3.default.isAbsolute(relative3)) {
121808
+ const relative3 = import_node_path4.default.relative(root, resultReal);
121809
+ if (!relative3 || !relative3.startsWith("..") && !import_node_path4.default.isAbsolute(relative3)) {
120893
121810
  throw new Error(
120894
121811
  `--result-json must not overlap a generated or staged repository path: ${resultJsonPath}`
120895
121812
  );
@@ -120902,7 +121819,7 @@ function assertResultPathOutsideGeneratedPaths(resultJsonPath, inputs) {
120902
121819
  generatedFiles.push(".github/workflows/postman-preview-gc.yml");
120903
121820
  }
120904
121821
  }
120905
- if (inputs.provider === "github" && (0, import_node_fs6.existsSync)(".github/workflows/provision.yml")) {
121822
+ if (inputs.provider === "github" && (0, import_node_fs7.existsSync)(".github/workflows/provision.yml")) {
120906
121823
  generatedFiles.push(".github/workflows/provision.yml");
120907
121824
  }
120908
121825
  for (const generatedFile of generatedFiles) {
@@ -120926,17 +121843,17 @@ async function writeOptionalFile(filePath, content) {
120926
121843
  function writeOptionalFileAtomic(filePath, content) {
120927
121844
  if (!filePath) return;
120928
121845
  const { resolved, directory } = assertOutputFileAllowed(filePath);
120929
- (0, import_node_fs6.mkdirSync)(directory, { recursive: true });
121846
+ (0, import_node_fs7.mkdirSync)(directory, { recursive: true });
120930
121847
  const validated = assertOutputFileAllowed(filePath);
120931
- const temporaryDirectory = (0, import_node_fs6.mkdtempSync)(
120932
- import_node_path3.default.join((0, import_node_fs6.realpathSync)(validated.directory), `.${import_node_path3.default.basename(resolved)}.`)
121848
+ const temporaryDirectory = (0, import_node_fs7.mkdtempSync)(
121849
+ import_node_path4.default.join((0, import_node_fs7.realpathSync)(validated.directory), `.${import_node_path4.default.basename(resolved)}.`)
120933
121850
  );
120934
- const temporary = import_node_path3.default.join(temporaryDirectory, import_node_path3.default.basename(resolved));
121851
+ const temporary = import_node_path4.default.join(temporaryDirectory, import_node_path4.default.basename(resolved));
120935
121852
  try {
120936
- (0, import_node_fs6.writeFileSync)(temporary, content, "utf8");
120937
- (0, import_node_fs6.renameSync)(temporary, resolved);
121853
+ (0, import_node_fs7.writeFileSync)(temporary, content, "utf8");
121854
+ (0, import_node_fs7.renameSync)(temporary, resolved);
120938
121855
  } finally {
120939
- (0, import_node_fs6.rmSync)(temporaryDirectory, { recursive: true, force: true });
121856
+ (0, import_node_fs7.rmSync)(temporaryDirectory, { recursive: true, force: true });
120940
121857
  }
120941
121858
  }
120942
121859
  function createCliDependencies(inputs, resolved, reporter = new ConsoleReporter()) {
@@ -120985,6 +121902,7 @@ async function runCli(argv = process.argv.slice(2), runtime = {}) {
120985
121902
  return;
120986
121903
  }
120987
121904
  const config = parseCliArgs(argv, env);
121905
+ activateWorkingDirectory(config.inputEnv.INPUT_WORKING_DIRECTORY, process.cwd());
120988
121906
  const inputs = resolveInputs(config.inputEnv);
120989
121907
  const branchDecision = decideBranchTier(inputs, config.inputEnv);
120990
121908
  if (branchDecision.tier !== "gated") {
@@ -120995,6 +121913,11 @@ async function runCli(argv = process.argv.slice(2), runtime = {}) {
120995
121913
  partialOutputs[name] = String(value ?? "");
120996
121914
  writeOptionalFileAtomic(config.resultJsonPath, JSON.stringify(partialOutputs, null, 2));
120997
121915
  });
121916
+ if (inputs.generateCiWorkflowDefaulted) {
121917
+ reporter.info(
121918
+ "working-directory is set; generate-ci-workflow defaulted to false. Use the root monorepo dispatcher workflow."
121919
+ );
121920
+ }
120998
121921
  if (branchDecision.tier === "gated") {
120999
121922
  const result2 = runGatedSkip(inputs, branchDecision, reporter);
121000
121923
  writeOptionalFileAtomic(config.resultJsonPath, JSON.stringify(result2, null, 2));
@@ -121139,9 +122062,9 @@ function isEntrypoint(currentPath, entrypointPath) {
121139
122062
  return false;
121140
122063
  }
121141
122064
  try {
121142
- return (0, import_node_fs6.realpathSync)(currentPath) === (0, import_node_fs6.realpathSync)(entrypointPath);
122065
+ return (0, import_node_fs7.realpathSync)(currentPath) === (0, import_node_fs7.realpathSync)(entrypointPath);
121143
122066
  } catch {
121144
- return import_node_path3.default.resolve(currentPath) === import_node_path3.default.resolve(entrypointPath);
122067
+ return import_node_path4.default.resolve(currentPath) === import_node_path4.default.resolve(entrypointPath);
121145
122068
  }
121146
122069
  }
121147
122070
  if (isEntrypoint(currentModulePath, entrypoint)) {
@@ -121199,5 +122122,5 @@ postman-collection/index.js:
121199
122122
  *)
121200
122123
 
121201
122124
  js-yaml/dist/js-yaml.mjs:
121202
- (*! js-yaml 5.2.2 https://github.com/nodeca/js-yaml @license MIT *)
122125
+ (*! js-yaml 5.2.3 https://github.com/nodeca/js-yaml @license MIT *)
121203
122126
  */