perstack 0.0.93 → 0.0.94

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.
@@ -1,1192 +0,0 @@
1
- import { n as __esmMin } from "./chunk-D_gEzPfs.js";
2
- import { a as File, i as init_esm_min, n as FormData, o as Blob, r as formDataToBlob, s as init_fetch_blob, t as init_from } from "./from-CYPG0_GG.js";
3
- import { deprecate, promisify, types } from "node:util";
4
- import Stream, { PassThrough, pipeline } from "node:stream";
5
- import { isIP } from "node:net";
6
- import http from "node:http";
7
- import { Buffer as Buffer$1 } from "node:buffer";
8
- import zlib from "node:zlib";
9
- import https from "node:https";
10
- import { format } from "node:url";
11
-
12
- //#region ../../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js
13
- /**
14
- * Returns a `Buffer` instance from the given data URI `uri`.
15
- *
16
- * @param {String} uri Data URI to turn into a Buffer instance
17
- * @returns {Buffer} Buffer instance from Data URI
18
- * @api public
19
- */
20
- function dataUriToBuffer(uri) {
21
- if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
22
- uri = uri.replace(/\r?\n/g, "");
23
- const firstComma = uri.indexOf(",");
24
- if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
25
- const meta = uri.substring(5, firstComma).split(";");
26
- let charset = "";
27
- let base64 = false;
28
- const type = meta[0] || "text/plain";
29
- let typeFull = type;
30
- for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
31
- else if (meta[i]) {
32
- typeFull += `;${meta[i]}`;
33
- if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
34
- }
35
- if (!meta[0] && !charset.length) {
36
- typeFull += ";charset=US-ASCII";
37
- charset = "US-ASCII";
38
- }
39
- const encoding = base64 ? "base64" : "ascii";
40
- const data = unescape(uri.substring(firstComma + 1));
41
- const buffer = Buffer.from(data, encoding);
42
- buffer.type = type;
43
- buffer.typeFull = typeFull;
44
- buffer.charset = charset;
45
- return buffer;
46
- }
47
- var init_dist = __esmMin((() => {}));
48
-
49
- //#endregion
50
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/base.js
51
- var FetchBaseError;
52
- var init_base = __esmMin((() => {
53
- FetchBaseError = class extends Error {
54
- constructor(message, type) {
55
- super(message);
56
- Error.captureStackTrace(this, this.constructor);
57
- this.type = type;
58
- }
59
- get name() {
60
- return this.constructor.name;
61
- }
62
- get [Symbol.toStringTag]() {
63
- return this.constructor.name;
64
- }
65
- };
66
- }));
67
-
68
- //#endregion
69
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/fetch-error.js
70
- var FetchError;
71
- var init_fetch_error = __esmMin((() => {
72
- init_base();
73
- FetchError = class extends FetchBaseError {
74
- /**
75
- * @param {string} message - Error message for human
76
- * @param {string} [type] - Error type for machine
77
- * @param {SystemError} [systemError] - For Node.js system error
78
- */
79
- constructor(message, type, systemError) {
80
- super(message, type);
81
- if (systemError) {
82
- this.code = this.errno = systemError.code;
83
- this.erroredSysCall = systemError.syscall;
84
- }
85
- }
86
- };
87
- }));
88
-
89
- //#endregion
90
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is.js
91
- var NAME, isURLSearchParameters, isBlob, isAbortSignal, isDomainOrSubdomain, isSameProtocol;
92
- var init_is = __esmMin((() => {
93
- NAME = Symbol.toStringTag;
94
- isURLSearchParameters = (object) => {
95
- return typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && typeof object.sort === "function" && object[NAME] === "URLSearchParams";
96
- };
97
- isBlob = (object) => {
98
- return object && typeof object === "object" && typeof object.arrayBuffer === "function" && typeof object.type === "string" && typeof object.stream === "function" && typeof object.constructor === "function" && /^(Blob|File)$/.test(object[NAME]);
99
- };
100
- isAbortSignal = (object) => {
101
- return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
102
- };
103
- isDomainOrSubdomain = (destination, original) => {
104
- const orig = new URL(original).hostname;
105
- const dest = new URL(destination).hostname;
106
- return orig === dest || orig.endsWith(`.${dest}`);
107
- };
108
- isSameProtocol = (destination, original) => {
109
- return new URL(original).protocol === new URL(destination).protocol;
110
- };
111
- }));
112
-
113
- //#endregion
114
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js
115
- /**
116
- * Body.js
117
- *
118
- * Body interface provides common methods for Request and Response
119
- */
120
- /**
121
- * Consume and convert an entire Body to a Buffer.
122
- *
123
- * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
124
- *
125
- * @return Promise
126
- */
127
- async function consumeBody(data) {
128
- if (data[INTERNALS$2].disturbed) throw new TypeError(`body used already for: ${data.url}`);
129
- data[INTERNALS$2].disturbed = true;
130
- if (data[INTERNALS$2].error) throw data[INTERNALS$2].error;
131
- const { body } = data;
132
- if (body === null) return Buffer$1.alloc(0);
133
- /* c8 ignore next 3 */
134
- if (!(body instanceof Stream)) return Buffer$1.alloc(0);
135
- const accum = [];
136
- let accumBytes = 0;
137
- try {
138
- for await (const chunk of body) {
139
- if (data.size > 0 && accumBytes + chunk.length > data.size) {
140
- const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
141
- body.destroy(error);
142
- throw error;
143
- }
144
- accumBytes += chunk.length;
145
- accum.push(chunk);
146
- }
147
- } catch (error) {
148
- throw error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
149
- }
150
- if (body.readableEnded === true || body._readableState.ended === true) try {
151
- if (accum.every((c) => typeof c === "string")) return Buffer$1.from(accum.join(""));
152
- return Buffer$1.concat(accum, accumBytes);
153
- } catch (error) {
154
- throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
155
- }
156
- else throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
157
- }
158
- var pipeline$1, INTERNALS$2, Body, clone, getNonSpecFormDataBoundary, extractContentType, getTotalBytes, writeToStream;
159
- var init_body = __esmMin((() => {
160
- init_fetch_blob();
161
- init_esm_min();
162
- init_fetch_error();
163
- init_base();
164
- init_is();
165
- pipeline$1 = promisify(Stream.pipeline);
166
- INTERNALS$2 = Symbol("Body internals");
167
- Body = class {
168
- constructor(body, { size = 0 } = {}) {
169
- let boundary = null;
170
- if (body === null) body = null;
171
- else if (isURLSearchParameters(body)) body = Buffer$1.from(body.toString());
172
- else if (isBlob(body)) {} else if (Buffer$1.isBuffer(body)) {} else if (types.isAnyArrayBuffer(body)) body = Buffer$1.from(body);
173
- else if (ArrayBuffer.isView(body)) body = Buffer$1.from(body.buffer, body.byteOffset, body.byteLength);
174
- else if (body instanceof Stream) {} else if (body instanceof FormData) {
175
- body = formDataToBlob(body);
176
- boundary = body.type.split("=")[1];
177
- } else body = Buffer$1.from(String(body));
178
- let stream = body;
179
- if (Buffer$1.isBuffer(body)) stream = Stream.Readable.from(body);
180
- else if (isBlob(body)) stream = Stream.Readable.from(body.stream());
181
- this[INTERNALS$2] = {
182
- body,
183
- stream,
184
- boundary,
185
- disturbed: false,
186
- error: null
187
- };
188
- this.size = size;
189
- if (body instanceof Stream) body.on("error", (error_) => {
190
- const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
191
- this[INTERNALS$2].error = error;
192
- });
193
- }
194
- get body() {
195
- return this[INTERNALS$2].stream;
196
- }
197
- get bodyUsed() {
198
- return this[INTERNALS$2].disturbed;
199
- }
200
- /**
201
- * Decode response as ArrayBuffer
202
- *
203
- * @return Promise
204
- */
205
- async arrayBuffer() {
206
- const { buffer, byteOffset, byteLength } = await consumeBody(this);
207
- return buffer.slice(byteOffset, byteOffset + byteLength);
208
- }
209
- async formData() {
210
- const ct = this.headers.get("content-type");
211
- if (ct.startsWith("application/x-www-form-urlencoded")) {
212
- const formData = new FormData();
213
- const parameters = new URLSearchParams(await this.text());
214
- for (const [name, value] of parameters) formData.append(name, value);
215
- return formData;
216
- }
217
- const { toFormData } = await import("./multipart-parser-B4-GAe3j.js");
218
- return toFormData(this.body, ct);
219
- }
220
- /**
221
- * Return raw response as Blob
222
- *
223
- * @return Promise
224
- */
225
- async blob() {
226
- const ct = this.headers && this.headers.get("content-type") || this[INTERNALS$2].body && this[INTERNALS$2].body.type || "";
227
- return new Blob([await this.arrayBuffer()], { type: ct });
228
- }
229
- /**
230
- * Decode response as json
231
- *
232
- * @return Promise
233
- */
234
- async json() {
235
- const text = await this.text();
236
- return JSON.parse(text);
237
- }
238
- /**
239
- * Decode response as text
240
- *
241
- * @return Promise
242
- */
243
- async text() {
244
- const buffer = await consumeBody(this);
245
- return new TextDecoder().decode(buffer);
246
- }
247
- /**
248
- * Decode response as buffer (non-spec api)
249
- *
250
- * @return Promise
251
- */
252
- buffer() {
253
- return consumeBody(this);
254
- }
255
- };
256
- Body.prototype.buffer = deprecate(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
257
- Object.defineProperties(Body.prototype, {
258
- body: { enumerable: true },
259
- bodyUsed: { enumerable: true },
260
- arrayBuffer: { enumerable: true },
261
- blob: { enumerable: true },
262
- json: { enumerable: true },
263
- text: { enumerable: true },
264
- data: { get: deprecate(() => {}, "data doesn't exist, use json(), text(), arrayBuffer(), or body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (response)") }
265
- });
266
- clone = (instance, highWaterMark) => {
267
- let p1;
268
- let p2;
269
- let { body } = instance[INTERNALS$2];
270
- if (instance.bodyUsed) throw new Error("cannot clone body after it is used");
271
- if (body instanceof Stream && typeof body.getBoundary !== "function") {
272
- p1 = new PassThrough({ highWaterMark });
273
- p2 = new PassThrough({ highWaterMark });
274
- body.pipe(p1);
275
- body.pipe(p2);
276
- instance[INTERNALS$2].stream = p1;
277
- body = p2;
278
- }
279
- return body;
280
- };
281
- getNonSpecFormDataBoundary = deprecate((body) => body.getBoundary(), "form-data doesn't follow the spec and requires special treatment. Use alternative package", "https://github.com/node-fetch/node-fetch/issues/1167");
282
- extractContentType = (body, request) => {
283
- if (body === null) return null;
284
- if (typeof body === "string") return "text/plain;charset=UTF-8";
285
- if (isURLSearchParameters(body)) return "application/x-www-form-urlencoded;charset=UTF-8";
286
- if (isBlob(body)) return body.type || null;
287
- if (Buffer$1.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) return null;
288
- if (body instanceof FormData) return `multipart/form-data; boundary=${request[INTERNALS$2].boundary}`;
289
- if (body && typeof body.getBoundary === "function") return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
290
- if (body instanceof Stream) return null;
291
- return "text/plain;charset=UTF-8";
292
- };
293
- getTotalBytes = (request) => {
294
- const { body } = request[INTERNALS$2];
295
- if (body === null) return 0;
296
- if (isBlob(body)) return body.size;
297
- if (Buffer$1.isBuffer(body)) return body.length;
298
- if (body && typeof body.getLengthSync === "function") return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
299
- return null;
300
- };
301
- writeToStream = async (dest, { body }) => {
302
- if (body === null) dest.end();
303
- else await pipeline$1(body, dest);
304
- };
305
- }));
306
-
307
- //#endregion
308
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
309
- /**
310
- * Headers.js
311
- *
312
- * Headers class offers convenient helpers
313
- */
314
- /**
315
- * Create a Headers object from an http.IncomingMessage.rawHeaders, ignoring those that do
316
- * not conform to HTTP grammar productions.
317
- * @param {import('http').IncomingMessage['rawHeaders']} headers
318
- */
319
- function fromRawHeaders(headers = []) {
320
- return new Headers(headers.reduce((result, value, index, array) => {
321
- if (index % 2 === 0) result.push(array.slice(index, index + 2));
322
- return result;
323
- }, []).filter(([name, value]) => {
324
- try {
325
- validateHeaderName(name);
326
- validateHeaderValue(name, String(value));
327
- return true;
328
- } catch {
329
- return false;
330
- }
331
- }));
332
- }
333
- var validateHeaderName, validateHeaderValue, Headers;
334
- var init_headers = __esmMin((() => {
335
- validateHeaderName = typeof http.validateHeaderName === "function" ? http.validateHeaderName : (name) => {
336
- if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
337
- const error = /* @__PURE__ */ new TypeError(`Header name must be a valid HTTP token [${name}]`);
338
- Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
339
- throw error;
340
- }
341
- };
342
- validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.validateHeaderValue : (name, value) => {
343
- if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
344
- const error = /* @__PURE__ */ new TypeError(`Invalid character in header content ["${name}"]`);
345
- Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
346
- throw error;
347
- }
348
- };
349
- Headers = class Headers extends URLSearchParams {
350
- /**
351
- * Headers class
352
- *
353
- * @constructor
354
- * @param {HeadersInit} [init] - Response headers
355
- */
356
- constructor(init) {
357
- /** @type {string[][]} */
358
- let result = [];
359
- if (init instanceof Headers) {
360
- const raw = init.raw();
361
- for (const [name, values] of Object.entries(raw)) result.push(...values.map((value) => [name, value]));
362
- } else if (init == null) {} else if (typeof init === "object" && !types.isBoxedPrimitive(init)) {
363
- const method = init[Symbol.iterator];
364
- if (method == null) result.push(...Object.entries(init));
365
- else {
366
- if (typeof method !== "function") throw new TypeError("Header pairs must be iterable");
367
- result = [...init].map((pair) => {
368
- if (typeof pair !== "object" || types.isBoxedPrimitive(pair)) throw new TypeError("Each header pair must be an iterable object");
369
- return [...pair];
370
- }).map((pair) => {
371
- if (pair.length !== 2) throw new TypeError("Each header pair must be a name/value tuple");
372
- return [...pair];
373
- });
374
- }
375
- } else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
376
- result = result.length > 0 ? result.map(([name, value]) => {
377
- validateHeaderName(name);
378
- validateHeaderValue(name, String(value));
379
- return [String(name).toLowerCase(), String(value)];
380
- }) : void 0;
381
- super(result);
382
- return new Proxy(this, { get(target, p, receiver) {
383
- switch (p) {
384
- case "append":
385
- case "set": return (name, value) => {
386
- validateHeaderName(name);
387
- validateHeaderValue(name, String(value));
388
- return URLSearchParams.prototype[p].call(target, String(name).toLowerCase(), String(value));
389
- };
390
- case "delete":
391
- case "has":
392
- case "getAll": return (name) => {
393
- validateHeaderName(name);
394
- return URLSearchParams.prototype[p].call(target, String(name).toLowerCase());
395
- };
396
- case "keys": return () => {
397
- target.sort();
398
- return new Set(URLSearchParams.prototype.keys.call(target)).keys();
399
- };
400
- default: return Reflect.get(target, p, receiver);
401
- }
402
- } });
403
- /* c8 ignore next */
404
- }
405
- get [Symbol.toStringTag]() {
406
- return this.constructor.name;
407
- }
408
- toString() {
409
- return Object.prototype.toString.call(this);
410
- }
411
- get(name) {
412
- const values = this.getAll(name);
413
- if (values.length === 0) return null;
414
- let value = values.join(", ");
415
- if (/^content-encoding$/i.test(name)) value = value.toLowerCase();
416
- return value;
417
- }
418
- forEach(callback, thisArg = void 0) {
419
- for (const name of this.keys()) Reflect.apply(callback, thisArg, [
420
- this.get(name),
421
- name,
422
- this
423
- ]);
424
- }
425
- *values() {
426
- for (const name of this.keys()) yield this.get(name);
427
- }
428
- /**
429
- * @type {() => IterableIterator<[string, string]>}
430
- */
431
- *entries() {
432
- for (const name of this.keys()) yield [name, this.get(name)];
433
- }
434
- [Symbol.iterator]() {
435
- return this.entries();
436
- }
437
- /**
438
- * Node-fetch non-spec method
439
- * returning all headers and their values as array
440
- * @returns {Record<string, string[]>}
441
- */
442
- raw() {
443
- return [...this.keys()].reduce((result, key) => {
444
- result[key] = this.getAll(key);
445
- return result;
446
- }, {});
447
- }
448
- /**
449
- * For better console.log(headers) and also to convert Headers into Node.js Request compatible format
450
- */
451
- [Symbol.for("nodejs.util.inspect.custom")]() {
452
- return [...this.keys()].reduce((result, key) => {
453
- const values = this.getAll(key);
454
- if (key === "host") result[key] = values[0];
455
- else result[key] = values.length > 1 ? values : values[0];
456
- return result;
457
- }, {});
458
- }
459
- };
460
- /**
461
- * Re-shaping object for Web IDL tests
462
- * Only need to do it for overridden methods
463
- */
464
- Object.defineProperties(Headers.prototype, [
465
- "get",
466
- "entries",
467
- "forEach",
468
- "values"
469
- ].reduce((result, property) => {
470
- result[property] = { enumerable: true };
471
- return result;
472
- }, {}));
473
- }));
474
-
475
- //#endregion
476
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is-redirect.js
477
- var redirectStatus, isRedirect;
478
- var init_is_redirect = __esmMin((() => {
479
- redirectStatus = new Set([
480
- 301,
481
- 302,
482
- 303,
483
- 307,
484
- 308
485
- ]);
486
- isRedirect = (code) => {
487
- return redirectStatus.has(code);
488
- };
489
- }));
490
-
491
- //#endregion
492
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/response.js
493
- var INTERNALS$1, Response;
494
- var init_response = __esmMin((() => {
495
- init_headers();
496
- init_body();
497
- init_is_redirect();
498
- INTERNALS$1 = Symbol("Response internals");
499
- Response = class Response extends Body {
500
- constructor(body = null, options = {}) {
501
- super(body, options);
502
- const status = options.status != null ? options.status : 200;
503
- const headers = new Headers(options.headers);
504
- if (body !== null && !headers.has("Content-Type")) {
505
- const contentType = extractContentType(body, this);
506
- if (contentType) headers.append("Content-Type", contentType);
507
- }
508
- this[INTERNALS$1] = {
509
- type: "default",
510
- url: options.url,
511
- status,
512
- statusText: options.statusText || "",
513
- headers,
514
- counter: options.counter,
515
- highWaterMark: options.highWaterMark
516
- };
517
- }
518
- get type() {
519
- return this[INTERNALS$1].type;
520
- }
521
- get url() {
522
- return this[INTERNALS$1].url || "";
523
- }
524
- get status() {
525
- return this[INTERNALS$1].status;
526
- }
527
- /**
528
- * Convenience property representing if the request ended normally
529
- */
530
- get ok() {
531
- return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
532
- }
533
- get redirected() {
534
- return this[INTERNALS$1].counter > 0;
535
- }
536
- get statusText() {
537
- return this[INTERNALS$1].statusText;
538
- }
539
- get headers() {
540
- return this[INTERNALS$1].headers;
541
- }
542
- get highWaterMark() {
543
- return this[INTERNALS$1].highWaterMark;
544
- }
545
- /**
546
- * Clone this response
547
- *
548
- * @return Response
549
- */
550
- clone() {
551
- return new Response(clone(this, this.highWaterMark), {
552
- type: this.type,
553
- url: this.url,
554
- status: this.status,
555
- statusText: this.statusText,
556
- headers: this.headers,
557
- ok: this.ok,
558
- redirected: this.redirected,
559
- size: this.size,
560
- highWaterMark: this.highWaterMark
561
- });
562
- }
563
- /**
564
- * @param {string} url The URL that the new response is to originate from.
565
- * @param {number} status An optional status code for the response (e.g., 302.)
566
- * @returns {Response} A Response object.
567
- */
568
- static redirect(url, status = 302) {
569
- if (!isRedirect(status)) throw new RangeError("Failed to execute \"redirect\" on \"response\": Invalid status code");
570
- return new Response(null, {
571
- headers: { location: new URL(url).toString() },
572
- status
573
- });
574
- }
575
- static error() {
576
- const response = new Response(null, {
577
- status: 0,
578
- statusText: ""
579
- });
580
- response[INTERNALS$1].type = "error";
581
- return response;
582
- }
583
- static json(data = void 0, init = {}) {
584
- const body = JSON.stringify(data);
585
- if (body === void 0) throw new TypeError("data is not JSON serializable");
586
- const headers = new Headers(init && init.headers);
587
- if (!headers.has("content-type")) headers.set("content-type", "application/json");
588
- return new Response(body, {
589
- ...init,
590
- headers
591
- });
592
- }
593
- get [Symbol.toStringTag]() {
594
- return "Response";
595
- }
596
- };
597
- Object.defineProperties(Response.prototype, {
598
- type: { enumerable: true },
599
- url: { enumerable: true },
600
- status: { enumerable: true },
601
- ok: { enumerable: true },
602
- redirected: { enumerable: true },
603
- statusText: { enumerable: true },
604
- headers: { enumerable: true },
605
- clone: { enumerable: true }
606
- });
607
- }));
608
-
609
- //#endregion
610
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/get-search.js
611
- var getSearch;
612
- var init_get_search = __esmMin((() => {
613
- getSearch = (parsedURL) => {
614
- if (parsedURL.search) return parsedURL.search;
615
- const lastOffset = parsedURL.href.length - 1;
616
- const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
617
- return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
618
- };
619
- }));
620
-
621
- //#endregion
622
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js
623
- /**
624
- * @external URL
625
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/URL|URL}
626
- */
627
- /**
628
- * @module utils/referrer
629
- * @private
630
- */
631
- /**
632
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#strip-url|Referrer Policy §8.4. Strip url for use as a referrer}
633
- * @param {string} URL
634
- * @param {boolean} [originOnly=false]
635
- */
636
- function stripURLForUseAsAReferrer(url, originOnly = false) {
637
- if (url == null) return "no-referrer";
638
- url = new URL(url);
639
- if (/^(about|blob|data):$/.test(url.protocol)) return "no-referrer";
640
- url.username = "";
641
- url.password = "";
642
- url.hash = "";
643
- if (originOnly) {
644
- url.pathname = "";
645
- url.search = "";
646
- }
647
- return url;
648
- }
649
- /**
650
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#referrer-policies|Referrer Policy §3. Referrer Policies}
651
- * @param {string} referrerPolicy
652
- * @returns {string} referrerPolicy
653
- */
654
- function validateReferrerPolicy(referrerPolicy) {
655
- if (!ReferrerPolicy.has(referrerPolicy)) throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
656
- return referrerPolicy;
657
- }
658
- /**
659
- * @see {@link https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy|Referrer Policy §3.2. Is origin potentially trustworthy?}
660
- * @param {external:URL} url
661
- * @returns `true`: "Potentially Trustworthy", `false`: "Not Trustworthy"
662
- */
663
- function isOriginPotentiallyTrustworthy(url) {
664
- if (/^(http|ws)s:$/.test(url.protocol)) return true;
665
- const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
666
- const hostIPVersion = isIP(hostIp);
667
- if (hostIPVersion === 4 && /^127\./.test(hostIp)) return true;
668
- if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) return true;
669
- if (url.host === "localhost" || url.host.endsWith(".localhost")) return false;
670
- if (url.protocol === "file:") return true;
671
- return false;
672
- }
673
- /**
674
- * @see {@link https://w3c.github.io/webappsec-secure-contexts/#is-url-trustworthy|Referrer Policy §3.3. Is url potentially trustworthy?}
675
- * @param {external:URL} url
676
- * @returns `true`: "Potentially Trustworthy", `false`: "Not Trustworthy"
677
- */
678
- function isUrlPotentiallyTrustworthy(url) {
679
- if (/^about:(blank|srcdoc)$/.test(url)) return true;
680
- if (url.protocol === "data:") return true;
681
- if (/^(blob|filesystem):$/.test(url.protocol)) return true;
682
- return isOriginPotentiallyTrustworthy(url);
683
- }
684
- /**
685
- * Modifies the referrerURL to enforce any extra security policy considerations.
686
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}, step 7
687
- * @callback module:utils/referrer~referrerURLCallback
688
- * @param {external:URL} referrerURL
689
- * @returns {external:URL} modified referrerURL
690
- */
691
- /**
692
- * Modifies the referrerOrigin to enforce any extra security policy considerations.
693
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}, step 7
694
- * @callback module:utils/referrer~referrerOriginCallback
695
- * @param {external:URL} referrerOrigin
696
- * @returns {external:URL} modified referrerOrigin
697
- */
698
- /**
699
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}
700
- * @param {Request} request
701
- * @param {object} o
702
- * @param {module:utils/referrer~referrerURLCallback} o.referrerURLCallback
703
- * @param {module:utils/referrer~referrerOriginCallback} o.referrerOriginCallback
704
- * @returns {external:URL} Request's referrer
705
- */
706
- function determineRequestsReferrer(request, { referrerURLCallback, referrerOriginCallback } = {}) {
707
- if (request.referrer === "no-referrer" || request.referrerPolicy === "") return null;
708
- const policy = request.referrerPolicy;
709
- if (request.referrer === "about:client") return "no-referrer";
710
- const referrerSource = request.referrer;
711
- let referrerURL = stripURLForUseAsAReferrer(referrerSource);
712
- let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
713
- if (referrerURL.toString().length > 4096) referrerURL = referrerOrigin;
714
- if (referrerURLCallback) referrerURL = referrerURLCallback(referrerURL);
715
- if (referrerOriginCallback) referrerOrigin = referrerOriginCallback(referrerOrigin);
716
- const currentURL = new URL(request.url);
717
- switch (policy) {
718
- case "no-referrer": return "no-referrer";
719
- case "origin": return referrerOrigin;
720
- case "unsafe-url": return referrerURL;
721
- case "strict-origin":
722
- if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
723
- return referrerOrigin.toString();
724
- case "strict-origin-when-cross-origin":
725
- if (referrerURL.origin === currentURL.origin) return referrerURL;
726
- if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
727
- return referrerOrigin;
728
- case "same-origin":
729
- if (referrerURL.origin === currentURL.origin) return referrerURL;
730
- return "no-referrer";
731
- case "origin-when-cross-origin":
732
- if (referrerURL.origin === currentURL.origin) return referrerURL;
733
- return referrerOrigin;
734
- case "no-referrer-when-downgrade":
735
- if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
736
- return referrerURL;
737
- default: throw new TypeError(`Invalid referrerPolicy: ${policy}`);
738
- }
739
- }
740
- /**
741
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header|Referrer Policy §8.1. Parse a referrer policy from a Referrer-Policy header}
742
- * @param {Headers} headers Response headers
743
- * @returns {string} policy
744
- */
745
- function parseReferrerPolicyFromHeader(headers) {
746
- const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
747
- let policy = "";
748
- for (const token of policyTokens) if (token && ReferrerPolicy.has(token)) policy = token;
749
- return policy;
750
- }
751
- var ReferrerPolicy, DEFAULT_REFERRER_POLICY;
752
- var init_referrer = __esmMin((() => {
753
- ReferrerPolicy = new Set([
754
- "",
755
- "no-referrer",
756
- "no-referrer-when-downgrade",
757
- "same-origin",
758
- "origin",
759
- "strict-origin",
760
- "origin-when-cross-origin",
761
- "strict-origin-when-cross-origin",
762
- "unsafe-url"
763
- ]);
764
- DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
765
- }));
766
-
767
- //#endregion
768
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/request.js
769
- /**
770
- * Request.js
771
- *
772
- * Request class contains server only options
773
- *
774
- * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
775
- */
776
- var INTERNALS, isRequest, doBadDataWarn, Request, getNodeRequestOptions;
777
- var init_request = __esmMin((() => {
778
- init_headers();
779
- init_body();
780
- init_is();
781
- init_get_search();
782
- init_referrer();
783
- INTERNALS = Symbol("Request internals");
784
- isRequest = (object) => {
785
- return typeof object === "object" && typeof object[INTERNALS] === "object";
786
- };
787
- doBadDataWarn = deprecate(() => {}, ".data is not a valid RequestInit property, use .body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (request)");
788
- Request = class Request extends Body {
789
- constructor(input, init = {}) {
790
- let parsedURL;
791
- if (isRequest(input)) parsedURL = new URL(input.url);
792
- else {
793
- parsedURL = new URL(input);
794
- input = {};
795
- }
796
- if (parsedURL.username !== "" || parsedURL.password !== "") throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
797
- let method = init.method || input.method || "GET";
798
- if (/^(delete|get|head|options|post|put)$/i.test(method)) method = method.toUpperCase();
799
- if (!isRequest(init) && "data" in init) doBadDataWarn();
800
- if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) throw new TypeError("Request with GET/HEAD method cannot have body");
801
- const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
802
- super(inputBody, { size: init.size || input.size || 0 });
803
- const headers = new Headers(init.headers || input.headers || {});
804
- if (inputBody !== null && !headers.has("Content-Type")) {
805
- const contentType = extractContentType(inputBody, this);
806
- if (contentType) headers.set("Content-Type", contentType);
807
- }
808
- let signal = isRequest(input) ? input.signal : null;
809
- if ("signal" in init) signal = init.signal;
810
- if (signal != null && !isAbortSignal(signal)) throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
811
- let referrer = init.referrer == null ? input.referrer : init.referrer;
812
- if (referrer === "") referrer = "no-referrer";
813
- else if (referrer) {
814
- const parsedReferrer = new URL(referrer);
815
- referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
816
- } else referrer = void 0;
817
- this[INTERNALS] = {
818
- method,
819
- redirect: init.redirect || input.redirect || "follow",
820
- headers,
821
- parsedURL,
822
- signal,
823
- referrer
824
- };
825
- this.follow = init.follow === void 0 ? input.follow === void 0 ? 20 : input.follow : init.follow;
826
- this.compress = init.compress === void 0 ? input.compress === void 0 ? true : input.compress : init.compress;
827
- this.counter = init.counter || input.counter || 0;
828
- this.agent = init.agent || input.agent;
829
- this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
830
- this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
831
- this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
832
- }
833
- /** @returns {string} */
834
- get method() {
835
- return this[INTERNALS].method;
836
- }
837
- /** @returns {string} */
838
- get url() {
839
- return format(this[INTERNALS].parsedURL);
840
- }
841
- /** @returns {Headers} */
842
- get headers() {
843
- return this[INTERNALS].headers;
844
- }
845
- get redirect() {
846
- return this[INTERNALS].redirect;
847
- }
848
- /** @returns {AbortSignal} */
849
- get signal() {
850
- return this[INTERNALS].signal;
851
- }
852
- get referrer() {
853
- if (this[INTERNALS].referrer === "no-referrer") return "";
854
- if (this[INTERNALS].referrer === "client") return "about:client";
855
- if (this[INTERNALS].referrer) return this[INTERNALS].referrer.toString();
856
- }
857
- get referrerPolicy() {
858
- return this[INTERNALS].referrerPolicy;
859
- }
860
- set referrerPolicy(referrerPolicy) {
861
- this[INTERNALS].referrerPolicy = validateReferrerPolicy(referrerPolicy);
862
- }
863
- /**
864
- * Clone this request
865
- *
866
- * @return Request
867
- */
868
- clone() {
869
- return new Request(this);
870
- }
871
- get [Symbol.toStringTag]() {
872
- return "Request";
873
- }
874
- };
875
- Object.defineProperties(Request.prototype, {
876
- method: { enumerable: true },
877
- url: { enumerable: true },
878
- headers: { enumerable: true },
879
- redirect: { enumerable: true },
880
- clone: { enumerable: true },
881
- signal: { enumerable: true },
882
- referrer: { enumerable: true },
883
- referrerPolicy: { enumerable: true }
884
- });
885
- getNodeRequestOptions = (request) => {
886
- const { parsedURL } = request[INTERNALS];
887
- const headers = new Headers(request[INTERNALS].headers);
888
- if (!headers.has("Accept")) headers.set("Accept", "*/*");
889
- let contentLengthValue = null;
890
- if (request.body === null && /^(post|put)$/i.test(request.method)) contentLengthValue = "0";
891
- if (request.body !== null) {
892
- const totalBytes = getTotalBytes(request);
893
- if (typeof totalBytes === "number" && !Number.isNaN(totalBytes)) contentLengthValue = String(totalBytes);
894
- }
895
- if (contentLengthValue) headers.set("Content-Length", contentLengthValue);
896
- if (request.referrerPolicy === "") request.referrerPolicy = DEFAULT_REFERRER_POLICY;
897
- if (request.referrer && request.referrer !== "no-referrer") request[INTERNALS].referrer = determineRequestsReferrer(request);
898
- else request[INTERNALS].referrer = "no-referrer";
899
- if (request[INTERNALS].referrer instanceof URL) headers.set("Referer", request.referrer);
900
- if (!headers.has("User-Agent")) headers.set("User-Agent", "node-fetch");
901
- if (request.compress && !headers.has("Accept-Encoding")) headers.set("Accept-Encoding", "gzip, deflate, br");
902
- let { agent } = request;
903
- if (typeof agent === "function") agent = agent(parsedURL);
904
- const search = getSearch(parsedURL);
905
- return {
906
- parsedURL,
907
- options: {
908
- path: parsedURL.pathname + search,
909
- method: request.method,
910
- headers: headers[Symbol.for("nodejs.util.inspect.custom")](),
911
- insecureHTTPParser: request.insecureHTTPParser,
912
- agent
913
- }
914
- };
915
- };
916
- }));
917
-
918
- //#endregion
919
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/abort-error.js
920
- var AbortError;
921
- var init_abort_error = __esmMin((() => {
922
- init_base();
923
- AbortError = class extends FetchBaseError {
924
- constructor(message, type = "aborted") {
925
- super(message, type);
926
- }
927
- };
928
- }));
929
-
930
- //#endregion
931
- //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
932
- /**
933
- * Index.js
934
- *
935
- * a request API compatible with window.fetch
936
- *
937
- * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
938
- */
939
- /**
940
- * Fetch function
941
- *
942
- * @param {string | URL | import('./request').default} url - Absolute url or Request instance
943
- * @param {*} [options_] - Fetch options
944
- * @return {Promise<import('./response').default>}
945
- */
946
- async function fetch(url, options_) {
947
- return new Promise((resolve, reject) => {
948
- const request = new Request(url, options_);
949
- const { parsedURL, options } = getNodeRequestOptions(request);
950
- if (!supportedSchemas.has(parsedURL.protocol)) throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
951
- if (parsedURL.protocol === "data:") {
952
- const data = dataUriToBuffer(request.url);
953
- resolve(new Response(data, { headers: { "Content-Type": data.typeFull } }));
954
- return;
955
- }
956
- const send = (parsedURL.protocol === "https:" ? https : http).request;
957
- const { signal } = request;
958
- let response = null;
959
- const abort = () => {
960
- const error = new AbortError("The operation was aborted.");
961
- reject(error);
962
- if (request.body && request.body instanceof Stream.Readable) request.body.destroy(error);
963
- if (!response || !response.body) return;
964
- response.body.emit("error", error);
965
- };
966
- if (signal && signal.aborted) {
967
- abort();
968
- return;
969
- }
970
- const abortAndFinalize = () => {
971
- abort();
972
- finalize();
973
- };
974
- const request_ = send(parsedURL.toString(), options);
975
- if (signal) signal.addEventListener("abort", abortAndFinalize);
976
- const finalize = () => {
977
- request_.abort();
978
- if (signal) signal.removeEventListener("abort", abortAndFinalize);
979
- };
980
- request_.on("error", (error) => {
981
- reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
982
- finalize();
983
- });
984
- fixResponseChunkedTransferBadEnding(request_, (error) => {
985
- if (response && response.body) response.body.destroy(error);
986
- });
987
- /* c8 ignore next 18 */
988
- if (process.version < "v14") request_.on("socket", (s) => {
989
- let endedWithEventsCount;
990
- s.prependListener("end", () => {
991
- endedWithEventsCount = s._eventsCount;
992
- });
993
- s.prependListener("close", (hadError) => {
994
- if (response && endedWithEventsCount < s._eventsCount && !hadError) {
995
- const error = /* @__PURE__ */ new Error("Premature close");
996
- error.code = "ERR_STREAM_PREMATURE_CLOSE";
997
- response.body.emit("error", error);
998
- }
999
- });
1000
- });
1001
- request_.on("response", (response_) => {
1002
- request_.setTimeout(0);
1003
- const headers = fromRawHeaders(response_.rawHeaders);
1004
- if (isRedirect(response_.statusCode)) {
1005
- const location = headers.get("Location");
1006
- let locationURL = null;
1007
- try {
1008
- locationURL = location === null ? null : new URL(location, request.url);
1009
- } catch {
1010
- if (request.redirect !== "manual") {
1011
- reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
1012
- finalize();
1013
- return;
1014
- }
1015
- }
1016
- switch (request.redirect) {
1017
- case "error":
1018
- reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
1019
- finalize();
1020
- return;
1021
- case "manual": break;
1022
- case "follow": {
1023
- if (locationURL === null) break;
1024
- if (request.counter >= request.follow) {
1025
- reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
1026
- finalize();
1027
- return;
1028
- }
1029
- const requestOptions = {
1030
- headers: new Headers(request.headers),
1031
- follow: request.follow,
1032
- counter: request.counter + 1,
1033
- agent: request.agent,
1034
- compress: request.compress,
1035
- method: request.method,
1036
- body: clone(request),
1037
- signal: request.signal,
1038
- size: request.size,
1039
- referrer: request.referrer,
1040
- referrerPolicy: request.referrerPolicy
1041
- };
1042
- if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) for (const name of [
1043
- "authorization",
1044
- "www-authenticate",
1045
- "cookie",
1046
- "cookie2"
1047
- ]) requestOptions.headers.delete(name);
1048
- if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream.Readable) {
1049
- reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
1050
- finalize();
1051
- return;
1052
- }
1053
- if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request.method === "POST") {
1054
- requestOptions.method = "GET";
1055
- requestOptions.body = void 0;
1056
- requestOptions.headers.delete("content-length");
1057
- }
1058
- const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
1059
- if (responseReferrerPolicy) requestOptions.referrerPolicy = responseReferrerPolicy;
1060
- resolve(fetch(new Request(locationURL, requestOptions)));
1061
- finalize();
1062
- return;
1063
- }
1064
- default: return reject(/* @__PURE__ */ new TypeError(`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`));
1065
- }
1066
- }
1067
- if (signal) response_.once("end", () => {
1068
- signal.removeEventListener("abort", abortAndFinalize);
1069
- });
1070
- let body = pipeline(response_, new PassThrough(), (error) => {
1071
- if (error) reject(error);
1072
- });
1073
- /* c8 ignore next 3 */
1074
- if (process.version < "v12.10") response_.on("aborted", abortAndFinalize);
1075
- const responseOptions = {
1076
- url: request.url,
1077
- status: response_.statusCode,
1078
- statusText: response_.statusMessage,
1079
- headers,
1080
- size: request.size,
1081
- counter: request.counter,
1082
- highWaterMark: request.highWaterMark
1083
- };
1084
- const codings = headers.get("Content-Encoding");
1085
- if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
1086
- response = new Response(body, responseOptions);
1087
- resolve(response);
1088
- return;
1089
- }
1090
- const zlibOptions = {
1091
- flush: zlib.Z_SYNC_FLUSH,
1092
- finishFlush: zlib.Z_SYNC_FLUSH
1093
- };
1094
- if (codings === "gzip" || codings === "x-gzip") {
1095
- body = pipeline(body, zlib.createGunzip(zlibOptions), (error) => {
1096
- if (error) reject(error);
1097
- });
1098
- response = new Response(body, responseOptions);
1099
- resolve(response);
1100
- return;
1101
- }
1102
- if (codings === "deflate" || codings === "x-deflate") {
1103
- const raw = pipeline(response_, new PassThrough(), (error) => {
1104
- if (error) reject(error);
1105
- });
1106
- raw.once("data", (chunk) => {
1107
- if ((chunk[0] & 15) === 8) body = pipeline(body, zlib.createInflate(), (error) => {
1108
- if (error) reject(error);
1109
- });
1110
- else body = pipeline(body, zlib.createInflateRaw(), (error) => {
1111
- if (error) reject(error);
1112
- });
1113
- response = new Response(body, responseOptions);
1114
- resolve(response);
1115
- });
1116
- raw.once("end", () => {
1117
- if (!response) {
1118
- response = new Response(body, responseOptions);
1119
- resolve(response);
1120
- }
1121
- });
1122
- return;
1123
- }
1124
- if (codings === "br") {
1125
- body = pipeline(body, zlib.createBrotliDecompress(), (error) => {
1126
- if (error) reject(error);
1127
- });
1128
- response = new Response(body, responseOptions);
1129
- resolve(response);
1130
- return;
1131
- }
1132
- response = new Response(body, responseOptions);
1133
- resolve(response);
1134
- });
1135
- writeToStream(request_, request).catch(reject);
1136
- });
1137
- }
1138
- function fixResponseChunkedTransferBadEnding(request, errorCallback) {
1139
- const LAST_CHUNK = Buffer$1.from("0\r\n\r\n");
1140
- let isChunkedTransfer = false;
1141
- let properLastChunkReceived = false;
1142
- let previousChunk;
1143
- request.on("response", (response) => {
1144
- const { headers } = response;
1145
- isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
1146
- });
1147
- request.on("socket", (socket) => {
1148
- const onSocketClose = () => {
1149
- if (isChunkedTransfer && !properLastChunkReceived) {
1150
- const error = /* @__PURE__ */ new Error("Premature close");
1151
- error.code = "ERR_STREAM_PREMATURE_CLOSE";
1152
- errorCallback(error);
1153
- }
1154
- };
1155
- const onData = (buf) => {
1156
- properLastChunkReceived = Buffer$1.compare(buf.slice(-5), LAST_CHUNK) === 0;
1157
- if (!properLastChunkReceived && previousChunk) properLastChunkReceived = Buffer$1.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && Buffer$1.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0;
1158
- previousChunk = buf;
1159
- };
1160
- socket.prependListener("close", onSocketClose);
1161
- socket.on("data", onData);
1162
- request.on("close", () => {
1163
- socket.removeListener("close", onSocketClose);
1164
- socket.removeListener("data", onData);
1165
- });
1166
- });
1167
- }
1168
- var supportedSchemas;
1169
- var init_src = __esmMin((() => {
1170
- init_dist();
1171
- init_body();
1172
- init_response();
1173
- init_headers();
1174
- init_request();
1175
- init_fetch_error();
1176
- init_abort_error();
1177
- init_is_redirect();
1178
- init_esm_min();
1179
- init_is();
1180
- init_referrer();
1181
- init_from();
1182
- supportedSchemas = new Set([
1183
- "data:",
1184
- "http:",
1185
- "https:"
1186
- ]);
1187
- }));
1188
-
1189
- //#endregion
1190
- init_src();
1191
- export { fetch as default };
1192
- //# sourceMappingURL=src-gAwrRWVD.js.map