@navios/core 0.1.10 → 0.1.12

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,3120 +0,0 @@
1
- import {
2
- __commonJS,
3
- __require
4
- } from "./chunk-Z2AVZ4BT.mjs";
5
-
6
- // node_modules/@fastify/busboy/deps/streamsearch/sbmh.js
7
- var require_sbmh = __commonJS({
8
- "node_modules/@fastify/busboy/deps/streamsearch/sbmh.js"(exports, module) {
9
- "use strict";
10
- var { EventEmitter } = __require("node:events");
11
- var { inherits } = __require("node:util");
12
- function SBMH(needle) {
13
- if (typeof needle === "string") {
14
- needle = Buffer.from(needle);
15
- }
16
- if (!Buffer.isBuffer(needle)) {
17
- throw new TypeError("The needle has to be a String or a Buffer.");
18
- }
19
- const needleLength = needle.length;
20
- const needleLastCharIndex = needleLength - 1;
21
- if (needleLength === 0) {
22
- throw new Error("The needle cannot be an empty String/Buffer.");
23
- }
24
- if (needleLength > 256) {
25
- throw new Error("The needle cannot have a length bigger than 256.");
26
- }
27
- this.maxMatches = Infinity;
28
- this.matches = 0;
29
- this._occ = new Uint8Array(256).fill(needleLength);
30
- this._lookbehind_size = 0;
31
- this._needle = needle;
32
- this._bufpos = 0;
33
- this._lookbehind = Buffer.alloc(needleLastCharIndex);
34
- for (var i = 0; i < needleLastCharIndex; ++i) {
35
- this._occ[needle[i]] = needleLastCharIndex - i;
36
- }
37
- }
38
- inherits(SBMH, EventEmitter);
39
- SBMH.prototype.reset = function() {
40
- this._lookbehind_size = 0;
41
- this.matches = 0;
42
- this._bufpos = 0;
43
- };
44
- SBMH.prototype.push = function(chunk, pos) {
45
- if (!Buffer.isBuffer(chunk)) {
46
- chunk = Buffer.from(chunk, "binary");
47
- }
48
- const chlen = chunk.length;
49
- this._bufpos = pos || 0;
50
- let r;
51
- while (r !== chlen && this.matches < this.maxMatches) {
52
- r = this._sbmh_feed(chunk);
53
- }
54
- return r;
55
- };
56
- SBMH.prototype._sbmh_feed = function(data) {
57
- const len = data.length;
58
- const needle = this._needle;
59
- const needleLength = needle.length;
60
- const needleLastCharIndex = needleLength - 1;
61
- const needleLastChar = needle[needleLastCharIndex];
62
- let pos = -this._lookbehind_size;
63
- let ch;
64
- if (pos < 0) {
65
- while (pos < 0 && pos <= len - needleLength) {
66
- ch = data[pos + needleLastCharIndex];
67
- if (ch === needleLastChar && this._sbmh_memcmp(data, pos, needleLastCharIndex)) {
68
- this._lookbehind_size = 0;
69
- ++this.matches;
70
- this.emit("info", true);
71
- return this._bufpos = pos + needleLength;
72
- }
73
- pos += this._occ[ch];
74
- }
75
- while (pos < 0 && !this._sbmh_memcmp(data, pos, len - pos)) {
76
- ++pos;
77
- }
78
- if (pos >= 0) {
79
- this.emit("info", false, this._lookbehind, 0, this._lookbehind_size);
80
- this._lookbehind_size = 0;
81
- } else {
82
- const bytesToCutOff = this._lookbehind_size + pos;
83
- if (bytesToCutOff > 0) {
84
- this.emit("info", false, this._lookbehind, 0, bytesToCutOff);
85
- }
86
- this._lookbehind_size -= bytesToCutOff;
87
- this._lookbehind.copy(this._lookbehind, 0, bytesToCutOff, this._lookbehind_size);
88
- data.copy(this._lookbehind, this._lookbehind_size);
89
- this._lookbehind_size += len;
90
- this._bufpos = len;
91
- return len;
92
- }
93
- }
94
- pos = data.indexOf(needle, pos + this._bufpos);
95
- if (pos !== -1) {
96
- ++this.matches;
97
- if (pos === 0) {
98
- this.emit("info", true);
99
- } else {
100
- this.emit("info", true, data, this._bufpos, pos);
101
- }
102
- return this._bufpos = pos + needleLength;
103
- }
104
- pos = len - needleLastCharIndex;
105
- if (pos < 0) {
106
- pos = 0;
107
- }
108
- while (pos !== len && (data[pos] !== needle[0] || Buffer.compare(
109
- data.subarray(pos + 1, len),
110
- needle.subarray(1, len - pos)
111
- ) !== 0)) {
112
- ++pos;
113
- }
114
- if (pos !== len) {
115
- data.copy(this._lookbehind, 0, pos, len);
116
- this._lookbehind_size = len - pos;
117
- }
118
- if (pos !== 0) {
119
- this.emit("info", false, data, this._bufpos, pos);
120
- }
121
- this._bufpos = len;
122
- return len;
123
- };
124
- SBMH.prototype._sbmh_lookup_char = function(data, pos) {
125
- return pos < 0 ? this._lookbehind[this._lookbehind_size + pos] : data[pos];
126
- };
127
- SBMH.prototype._sbmh_memcmp = function(data, pos, len) {
128
- for (var i = 0; i < len; ++i) {
129
- if (this._sbmh_lookup_char(data, pos + i) !== this._needle[i]) {
130
- return false;
131
- }
132
- }
133
- return true;
134
- };
135
- module.exports = SBMH;
136
- }
137
- });
138
-
139
- // node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js
140
- var require_PartStream = __commonJS({
141
- "node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js"(exports, module) {
142
- "use strict";
143
- var inherits = __require("node:util").inherits;
144
- var ReadableStream = __require("node:stream").Readable;
145
- function PartStream(opts) {
146
- ReadableStream.call(this, opts);
147
- }
148
- inherits(PartStream, ReadableStream);
149
- PartStream.prototype._read = function(n) {
150
- };
151
- module.exports = PartStream;
152
- }
153
- });
154
-
155
- // node_modules/@fastify/busboy/lib/utils/getLimit.js
156
- var require_getLimit = __commonJS({
157
- "node_modules/@fastify/busboy/lib/utils/getLimit.js"(exports, module) {
158
- "use strict";
159
- module.exports = function getLimit(limits, name, defaultLimit) {
160
- if (!limits || limits[name] === void 0 || limits[name] === null) {
161
- return defaultLimit;
162
- }
163
- if (typeof limits[name] !== "number" || isNaN(limits[name])) {
164
- throw new TypeError("Limit " + name + " is not a valid number");
165
- }
166
- return limits[name];
167
- };
168
- }
169
- });
170
-
171
- // node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js
172
- var require_HeaderParser = __commonJS({
173
- "node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js"(exports, module) {
174
- "use strict";
175
- var EventEmitter = __require("node:events").EventEmitter;
176
- var inherits = __require("node:util").inherits;
177
- var getLimit = require_getLimit();
178
- var StreamSearch = require_sbmh();
179
- var B_DCRLF = Buffer.from("\r\n\r\n");
180
- var RE_CRLF = /\r\n/g;
181
- var RE_HDR = /^([^:]+):[ \t]?([\x00-\xFF]+)?$/;
182
- function HeaderParser(cfg) {
183
- EventEmitter.call(this);
184
- cfg = cfg || {};
185
- const self = this;
186
- this.nread = 0;
187
- this.maxed = false;
188
- this.npairs = 0;
189
- this.maxHeaderPairs = getLimit(cfg, "maxHeaderPairs", 2e3);
190
- this.maxHeaderSize = getLimit(cfg, "maxHeaderSize", 80 * 1024);
191
- this.buffer = "";
192
- this.header = {};
193
- this.finished = false;
194
- this.ss = new StreamSearch(B_DCRLF);
195
- this.ss.on("info", function(isMatch, data, start, end) {
196
- if (data && !self.maxed) {
197
- if (self.nread + end - start >= self.maxHeaderSize) {
198
- end = self.maxHeaderSize - self.nread + start;
199
- self.nread = self.maxHeaderSize;
200
- self.maxed = true;
201
- } else {
202
- self.nread += end - start;
203
- }
204
- self.buffer += data.toString("binary", start, end);
205
- }
206
- if (isMatch) {
207
- self._finish();
208
- }
209
- });
210
- }
211
- inherits(HeaderParser, EventEmitter);
212
- HeaderParser.prototype.push = function(data) {
213
- const r = this.ss.push(data);
214
- if (this.finished) {
215
- return r;
216
- }
217
- };
218
- HeaderParser.prototype.reset = function() {
219
- this.finished = false;
220
- this.buffer = "";
221
- this.header = {};
222
- this.ss.reset();
223
- };
224
- HeaderParser.prototype._finish = function() {
225
- if (this.buffer) {
226
- this._parseHeader();
227
- }
228
- this.ss.matches = this.ss.maxMatches;
229
- const header = this.header;
230
- this.header = {};
231
- this.buffer = "";
232
- this.finished = true;
233
- this.nread = this.npairs = 0;
234
- this.maxed = false;
235
- this.emit("header", header);
236
- };
237
- HeaderParser.prototype._parseHeader = function() {
238
- if (this.npairs === this.maxHeaderPairs) {
239
- return;
240
- }
241
- const lines = this.buffer.split(RE_CRLF);
242
- const len = lines.length;
243
- let m, h;
244
- for (var i = 0; i < len; ++i) {
245
- if (lines[i].length === 0) {
246
- continue;
247
- }
248
- if (lines[i][0] === " " || lines[i][0] === " ") {
249
- if (h) {
250
- this.header[h][this.header[h].length - 1] += lines[i];
251
- continue;
252
- }
253
- }
254
- const posColon = lines[i].indexOf(":");
255
- if (posColon === -1 || posColon === 0) {
256
- return;
257
- }
258
- m = RE_HDR.exec(lines[i]);
259
- h = m[1].toLowerCase();
260
- this.header[h] = this.header[h] || [];
261
- this.header[h].push(m[2] || "");
262
- if (++this.npairs === this.maxHeaderPairs) {
263
- break;
264
- }
265
- }
266
- };
267
- module.exports = HeaderParser;
268
- }
269
- });
270
-
271
- // node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js
272
- var require_Dicer = __commonJS({
273
- "node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js"(exports, module) {
274
- "use strict";
275
- var WritableStream = __require("node:stream").Writable;
276
- var inherits = __require("node:util").inherits;
277
- var StreamSearch = require_sbmh();
278
- var PartStream = require_PartStream();
279
- var HeaderParser = require_HeaderParser();
280
- var DASH = 45;
281
- var B_ONEDASH = Buffer.from("-");
282
- var B_CRLF = Buffer.from("\r\n");
283
- var EMPTY_FN = function() {
284
- };
285
- function Dicer(cfg) {
286
- if (!(this instanceof Dicer)) {
287
- return new Dicer(cfg);
288
- }
289
- WritableStream.call(this, cfg);
290
- if (!cfg || !cfg.headerFirst && typeof cfg.boundary !== "string") {
291
- throw new TypeError("Boundary required");
292
- }
293
- if (typeof cfg.boundary === "string") {
294
- this.setBoundary(cfg.boundary);
295
- } else {
296
- this._bparser = void 0;
297
- }
298
- this._headerFirst = cfg.headerFirst;
299
- this._dashes = 0;
300
- this._parts = 0;
301
- this._finished = false;
302
- this._realFinish = false;
303
- this._isPreamble = true;
304
- this._justMatched = false;
305
- this._firstWrite = true;
306
- this._inHeader = true;
307
- this._part = void 0;
308
- this._cb = void 0;
309
- this._ignoreData = false;
310
- this._partOpts = { highWaterMark: cfg.partHwm };
311
- this._pause = false;
312
- const self = this;
313
- this._hparser = new HeaderParser(cfg);
314
- this._hparser.on("header", function(header) {
315
- self._inHeader = false;
316
- self._part.emit("header", header);
317
- });
318
- }
319
- inherits(Dicer, WritableStream);
320
- Dicer.prototype.emit = function(ev) {
321
- if (ev === "finish" && !this._realFinish) {
322
- if (!this._finished) {
323
- const self = this;
324
- process.nextTick(function() {
325
- self.emit("error", new Error("Unexpected end of multipart data"));
326
- if (self._part && !self._ignoreData) {
327
- const type = self._isPreamble ? "Preamble" : "Part";
328
- self._part.emit("error", new Error(type + " terminated early due to unexpected end of multipart data"));
329
- self._part.push(null);
330
- process.nextTick(function() {
331
- self._realFinish = true;
332
- self.emit("finish");
333
- self._realFinish = false;
334
- });
335
- return;
336
- }
337
- self._realFinish = true;
338
- self.emit("finish");
339
- self._realFinish = false;
340
- });
341
- }
342
- } else {
343
- WritableStream.prototype.emit.apply(this, arguments);
344
- }
345
- };
346
- Dicer.prototype._write = function(data, encoding, cb) {
347
- if (!this._hparser && !this._bparser) {
348
- return cb();
349
- }
350
- if (this._headerFirst && this._isPreamble) {
351
- if (!this._part) {
352
- this._part = new PartStream(this._partOpts);
353
- if (this.listenerCount("preamble") !== 0) {
354
- this.emit("preamble", this._part);
355
- } else {
356
- this._ignore();
357
- }
358
- }
359
- const r = this._hparser.push(data);
360
- if (!this._inHeader && r !== void 0 && r < data.length) {
361
- data = data.slice(r);
362
- } else {
363
- return cb();
364
- }
365
- }
366
- if (this._firstWrite) {
367
- this._bparser.push(B_CRLF);
368
- this._firstWrite = false;
369
- }
370
- this._bparser.push(data);
371
- if (this._pause) {
372
- this._cb = cb;
373
- } else {
374
- cb();
375
- }
376
- };
377
- Dicer.prototype.reset = function() {
378
- this._part = void 0;
379
- this._bparser = void 0;
380
- this._hparser = void 0;
381
- };
382
- Dicer.prototype.setBoundary = function(boundary) {
383
- const self = this;
384
- this._bparser = new StreamSearch("\r\n--" + boundary);
385
- this._bparser.on("info", function(isMatch, data, start, end) {
386
- self._oninfo(isMatch, data, start, end);
387
- });
388
- };
389
- Dicer.prototype._ignore = function() {
390
- if (this._part && !this._ignoreData) {
391
- this._ignoreData = true;
392
- this._part.on("error", EMPTY_FN);
393
- this._part.resume();
394
- }
395
- };
396
- Dicer.prototype._oninfo = function(isMatch, data, start, end) {
397
- let buf;
398
- const self = this;
399
- let i = 0;
400
- let r;
401
- let shouldWriteMore = true;
402
- if (!this._part && this._justMatched && data) {
403
- while (this._dashes < 2 && start + i < end) {
404
- if (data[start + i] === DASH) {
405
- ++i;
406
- ++this._dashes;
407
- } else {
408
- if (this._dashes) {
409
- buf = B_ONEDASH;
410
- }
411
- this._dashes = 0;
412
- break;
413
- }
414
- }
415
- if (this._dashes === 2) {
416
- if (start + i < end && this.listenerCount("trailer") !== 0) {
417
- this.emit("trailer", data.slice(start + i, end));
418
- }
419
- this.reset();
420
- this._finished = true;
421
- if (self._parts === 0) {
422
- self._realFinish = true;
423
- self.emit("finish");
424
- self._realFinish = false;
425
- }
426
- }
427
- if (this._dashes) {
428
- return;
429
- }
430
- }
431
- if (this._justMatched) {
432
- this._justMatched = false;
433
- }
434
- if (!this._part) {
435
- this._part = new PartStream(this._partOpts);
436
- this._part._read = function(n) {
437
- self._unpause();
438
- };
439
- if (this._isPreamble && this.listenerCount("preamble") !== 0) {
440
- this.emit("preamble", this._part);
441
- } else if (this._isPreamble !== true && this.listenerCount("part") !== 0) {
442
- this.emit("part", this._part);
443
- } else {
444
- this._ignore();
445
- }
446
- if (!this._isPreamble) {
447
- this._inHeader = true;
448
- }
449
- }
450
- if (data && start < end && !this._ignoreData) {
451
- if (this._isPreamble || !this._inHeader) {
452
- if (buf) {
453
- shouldWriteMore = this._part.push(buf);
454
- }
455
- shouldWriteMore = this._part.push(data.slice(start, end));
456
- if (!shouldWriteMore) {
457
- this._pause = true;
458
- }
459
- } else if (!this._isPreamble && this._inHeader) {
460
- if (buf) {
461
- this._hparser.push(buf);
462
- }
463
- r = this._hparser.push(data.slice(start, end));
464
- if (!this._inHeader && r !== void 0 && r < end) {
465
- this._oninfo(false, data, start + r, end);
466
- }
467
- }
468
- }
469
- if (isMatch) {
470
- this._hparser.reset();
471
- if (this._isPreamble) {
472
- this._isPreamble = false;
473
- } else {
474
- if (start !== end) {
475
- ++this._parts;
476
- this._part.on("end", function() {
477
- if (--self._parts === 0) {
478
- if (self._finished) {
479
- self._realFinish = true;
480
- self.emit("finish");
481
- self._realFinish = false;
482
- } else {
483
- self._unpause();
484
- }
485
- }
486
- });
487
- }
488
- }
489
- this._part.push(null);
490
- this._part = void 0;
491
- this._ignoreData = false;
492
- this._justMatched = true;
493
- this._dashes = 0;
494
- }
495
- };
496
- Dicer.prototype._unpause = function() {
497
- if (!this._pause) {
498
- return;
499
- }
500
- this._pause = false;
501
- if (this._cb) {
502
- const cb = this._cb;
503
- this._cb = void 0;
504
- cb();
505
- }
506
- };
507
- module.exports = Dicer;
508
- }
509
- });
510
-
511
- // node_modules/@fastify/busboy/lib/utils/decodeText.js
512
- var require_decodeText = __commonJS({
513
- "node_modules/@fastify/busboy/lib/utils/decodeText.js"(exports, module) {
514
- "use strict";
515
- var utf8Decoder = new TextDecoder("utf-8");
516
- var textDecoders = /* @__PURE__ */ new Map([
517
- ["utf-8", utf8Decoder],
518
- ["utf8", utf8Decoder]
519
- ]);
520
- function getDecoder(charset) {
521
- let lc;
522
- while (true) {
523
- switch (charset) {
524
- case "utf-8":
525
- case "utf8":
526
- return decoders.utf8;
527
- case "latin1":
528
- case "ascii":
529
- // TODO: Make these a separate, strict decoder?
530
- case "us-ascii":
531
- case "iso-8859-1":
532
- case "iso8859-1":
533
- case "iso88591":
534
- case "iso_8859-1":
535
- case "windows-1252":
536
- case "iso_8859-1:1987":
537
- case "cp1252":
538
- case "x-cp1252":
539
- return decoders.latin1;
540
- case "utf16le":
541
- case "utf-16le":
542
- case "ucs2":
543
- case "ucs-2":
544
- return decoders.utf16le;
545
- case "base64":
546
- return decoders.base64;
547
- default:
548
- if (lc === void 0) {
549
- lc = true;
550
- charset = charset.toLowerCase();
551
- continue;
552
- }
553
- return decoders.other.bind(charset);
554
- }
555
- }
556
- }
557
- var decoders = {
558
- utf8: (data, sourceEncoding) => {
559
- if (data.length === 0) {
560
- return "";
561
- }
562
- if (typeof data === "string") {
563
- data = Buffer.from(data, sourceEncoding);
564
- }
565
- return data.utf8Slice(0, data.length);
566
- },
567
- latin1: (data, sourceEncoding) => {
568
- if (data.length === 0) {
569
- return "";
570
- }
571
- if (typeof data === "string") {
572
- return data;
573
- }
574
- return data.latin1Slice(0, data.length);
575
- },
576
- utf16le: (data, sourceEncoding) => {
577
- if (data.length === 0) {
578
- return "";
579
- }
580
- if (typeof data === "string") {
581
- data = Buffer.from(data, sourceEncoding);
582
- }
583
- return data.ucs2Slice(0, data.length);
584
- },
585
- base64: (data, sourceEncoding) => {
586
- if (data.length === 0) {
587
- return "";
588
- }
589
- if (typeof data === "string") {
590
- data = Buffer.from(data, sourceEncoding);
591
- }
592
- return data.base64Slice(0, data.length);
593
- },
594
- other: (data, sourceEncoding) => {
595
- if (data.length === 0) {
596
- return "";
597
- }
598
- if (typeof data === "string") {
599
- data = Buffer.from(data, sourceEncoding);
600
- }
601
- if (textDecoders.has(exports.toString())) {
602
- try {
603
- return textDecoders.get(exports).decode(data);
604
- } catch {
605
- }
606
- }
607
- return typeof data === "string" ? data : data.toString();
608
- }
609
- };
610
- function decodeText(text, sourceEncoding, destEncoding) {
611
- if (text) {
612
- return getDecoder(destEncoding)(text, sourceEncoding);
613
- }
614
- return text;
615
- }
616
- module.exports = decodeText;
617
- }
618
- });
619
-
620
- // node_modules/@fastify/busboy/lib/utils/parseParams.js
621
- var require_parseParams = __commonJS({
622
- "node_modules/@fastify/busboy/lib/utils/parseParams.js"(exports, module) {
623
- "use strict";
624
- var decodeText = require_decodeText();
625
- var RE_ENCODED = /%[a-fA-F0-9][a-fA-F0-9]/g;
626
- var EncodedLookup = {
627
- "%00": "\0",
628
- "%01": "",
629
- "%02": "",
630
- "%03": "",
631
- "%04": "",
632
- "%05": "",
633
- "%06": "",
634
- "%07": "\x07",
635
- "%08": "\b",
636
- "%09": " ",
637
- "%0a": "\n",
638
- "%0A": "\n",
639
- "%0b": "\v",
640
- "%0B": "\v",
641
- "%0c": "\f",
642
- "%0C": "\f",
643
- "%0d": "\r",
644
- "%0D": "\r",
645
- "%0e": "",
646
- "%0E": "",
647
- "%0f": "",
648
- "%0F": "",
649
- "%10": "",
650
- "%11": "",
651
- "%12": "",
652
- "%13": "",
653
- "%14": "",
654
- "%15": "",
655
- "%16": "",
656
- "%17": "",
657
- "%18": "",
658
- "%19": "",
659
- "%1a": "",
660
- "%1A": "",
661
- "%1b": "\x1B",
662
- "%1B": "\x1B",
663
- "%1c": "",
664
- "%1C": "",
665
- "%1d": "",
666
- "%1D": "",
667
- "%1e": "",
668
- "%1E": "",
669
- "%1f": "",
670
- "%1F": "",
671
- "%20": " ",
672
- "%21": "!",
673
- "%22": '"',
674
- "%23": "#",
675
- "%24": "$",
676
- "%25": "%",
677
- "%26": "&",
678
- "%27": "'",
679
- "%28": "(",
680
- "%29": ")",
681
- "%2a": "*",
682
- "%2A": "*",
683
- "%2b": "+",
684
- "%2B": "+",
685
- "%2c": ",",
686
- "%2C": ",",
687
- "%2d": "-",
688
- "%2D": "-",
689
- "%2e": ".",
690
- "%2E": ".",
691
- "%2f": "/",
692
- "%2F": "/",
693
- "%30": "0",
694
- "%31": "1",
695
- "%32": "2",
696
- "%33": "3",
697
- "%34": "4",
698
- "%35": "5",
699
- "%36": "6",
700
- "%37": "7",
701
- "%38": "8",
702
- "%39": "9",
703
- "%3a": ":",
704
- "%3A": ":",
705
- "%3b": ";",
706
- "%3B": ";",
707
- "%3c": "<",
708
- "%3C": "<",
709
- "%3d": "=",
710
- "%3D": "=",
711
- "%3e": ">",
712
- "%3E": ">",
713
- "%3f": "?",
714
- "%3F": "?",
715
- "%40": "@",
716
- "%41": "A",
717
- "%42": "B",
718
- "%43": "C",
719
- "%44": "D",
720
- "%45": "E",
721
- "%46": "F",
722
- "%47": "G",
723
- "%48": "H",
724
- "%49": "I",
725
- "%4a": "J",
726
- "%4A": "J",
727
- "%4b": "K",
728
- "%4B": "K",
729
- "%4c": "L",
730
- "%4C": "L",
731
- "%4d": "M",
732
- "%4D": "M",
733
- "%4e": "N",
734
- "%4E": "N",
735
- "%4f": "O",
736
- "%4F": "O",
737
- "%50": "P",
738
- "%51": "Q",
739
- "%52": "R",
740
- "%53": "S",
741
- "%54": "T",
742
- "%55": "U",
743
- "%56": "V",
744
- "%57": "W",
745
- "%58": "X",
746
- "%59": "Y",
747
- "%5a": "Z",
748
- "%5A": "Z",
749
- "%5b": "[",
750
- "%5B": "[",
751
- "%5c": "\\",
752
- "%5C": "\\",
753
- "%5d": "]",
754
- "%5D": "]",
755
- "%5e": "^",
756
- "%5E": "^",
757
- "%5f": "_",
758
- "%5F": "_",
759
- "%60": "`",
760
- "%61": "a",
761
- "%62": "b",
762
- "%63": "c",
763
- "%64": "d",
764
- "%65": "e",
765
- "%66": "f",
766
- "%67": "g",
767
- "%68": "h",
768
- "%69": "i",
769
- "%6a": "j",
770
- "%6A": "j",
771
- "%6b": "k",
772
- "%6B": "k",
773
- "%6c": "l",
774
- "%6C": "l",
775
- "%6d": "m",
776
- "%6D": "m",
777
- "%6e": "n",
778
- "%6E": "n",
779
- "%6f": "o",
780
- "%6F": "o",
781
- "%70": "p",
782
- "%71": "q",
783
- "%72": "r",
784
- "%73": "s",
785
- "%74": "t",
786
- "%75": "u",
787
- "%76": "v",
788
- "%77": "w",
789
- "%78": "x",
790
- "%79": "y",
791
- "%7a": "z",
792
- "%7A": "z",
793
- "%7b": "{",
794
- "%7B": "{",
795
- "%7c": "|",
796
- "%7C": "|",
797
- "%7d": "}",
798
- "%7D": "}",
799
- "%7e": "~",
800
- "%7E": "~",
801
- "%7f": "\x7F",
802
- "%7F": "\x7F",
803
- "%80": "\x80",
804
- "%81": "\x81",
805
- "%82": "\x82",
806
- "%83": "\x83",
807
- "%84": "\x84",
808
- "%85": "\x85",
809
- "%86": "\x86",
810
- "%87": "\x87",
811
- "%88": "\x88",
812
- "%89": "\x89",
813
- "%8a": "\x8A",
814
- "%8A": "\x8A",
815
- "%8b": "\x8B",
816
- "%8B": "\x8B",
817
- "%8c": "\x8C",
818
- "%8C": "\x8C",
819
- "%8d": "\x8D",
820
- "%8D": "\x8D",
821
- "%8e": "\x8E",
822
- "%8E": "\x8E",
823
- "%8f": "\x8F",
824
- "%8F": "\x8F",
825
- "%90": "\x90",
826
- "%91": "\x91",
827
- "%92": "\x92",
828
- "%93": "\x93",
829
- "%94": "\x94",
830
- "%95": "\x95",
831
- "%96": "\x96",
832
- "%97": "\x97",
833
- "%98": "\x98",
834
- "%99": "\x99",
835
- "%9a": "\x9A",
836
- "%9A": "\x9A",
837
- "%9b": "\x9B",
838
- "%9B": "\x9B",
839
- "%9c": "\x9C",
840
- "%9C": "\x9C",
841
- "%9d": "\x9D",
842
- "%9D": "\x9D",
843
- "%9e": "\x9E",
844
- "%9E": "\x9E",
845
- "%9f": "\x9F",
846
- "%9F": "\x9F",
847
- "%a0": "\xA0",
848
- "%A0": "\xA0",
849
- "%a1": "\xA1",
850
- "%A1": "\xA1",
851
- "%a2": "\xA2",
852
- "%A2": "\xA2",
853
- "%a3": "\xA3",
854
- "%A3": "\xA3",
855
- "%a4": "\xA4",
856
- "%A4": "\xA4",
857
- "%a5": "\xA5",
858
- "%A5": "\xA5",
859
- "%a6": "\xA6",
860
- "%A6": "\xA6",
861
- "%a7": "\xA7",
862
- "%A7": "\xA7",
863
- "%a8": "\xA8",
864
- "%A8": "\xA8",
865
- "%a9": "\xA9",
866
- "%A9": "\xA9",
867
- "%aa": "\xAA",
868
- "%Aa": "\xAA",
869
- "%aA": "\xAA",
870
- "%AA": "\xAA",
871
- "%ab": "\xAB",
872
- "%Ab": "\xAB",
873
- "%aB": "\xAB",
874
- "%AB": "\xAB",
875
- "%ac": "\xAC",
876
- "%Ac": "\xAC",
877
- "%aC": "\xAC",
878
- "%AC": "\xAC",
879
- "%ad": "\xAD",
880
- "%Ad": "\xAD",
881
- "%aD": "\xAD",
882
- "%AD": "\xAD",
883
- "%ae": "\xAE",
884
- "%Ae": "\xAE",
885
- "%aE": "\xAE",
886
- "%AE": "\xAE",
887
- "%af": "\xAF",
888
- "%Af": "\xAF",
889
- "%aF": "\xAF",
890
- "%AF": "\xAF",
891
- "%b0": "\xB0",
892
- "%B0": "\xB0",
893
- "%b1": "\xB1",
894
- "%B1": "\xB1",
895
- "%b2": "\xB2",
896
- "%B2": "\xB2",
897
- "%b3": "\xB3",
898
- "%B3": "\xB3",
899
- "%b4": "\xB4",
900
- "%B4": "\xB4",
901
- "%b5": "\xB5",
902
- "%B5": "\xB5",
903
- "%b6": "\xB6",
904
- "%B6": "\xB6",
905
- "%b7": "\xB7",
906
- "%B7": "\xB7",
907
- "%b8": "\xB8",
908
- "%B8": "\xB8",
909
- "%b9": "\xB9",
910
- "%B9": "\xB9",
911
- "%ba": "\xBA",
912
- "%Ba": "\xBA",
913
- "%bA": "\xBA",
914
- "%BA": "\xBA",
915
- "%bb": "\xBB",
916
- "%Bb": "\xBB",
917
- "%bB": "\xBB",
918
- "%BB": "\xBB",
919
- "%bc": "\xBC",
920
- "%Bc": "\xBC",
921
- "%bC": "\xBC",
922
- "%BC": "\xBC",
923
- "%bd": "\xBD",
924
- "%Bd": "\xBD",
925
- "%bD": "\xBD",
926
- "%BD": "\xBD",
927
- "%be": "\xBE",
928
- "%Be": "\xBE",
929
- "%bE": "\xBE",
930
- "%BE": "\xBE",
931
- "%bf": "\xBF",
932
- "%Bf": "\xBF",
933
- "%bF": "\xBF",
934
- "%BF": "\xBF",
935
- "%c0": "\xC0",
936
- "%C0": "\xC0",
937
- "%c1": "\xC1",
938
- "%C1": "\xC1",
939
- "%c2": "\xC2",
940
- "%C2": "\xC2",
941
- "%c3": "\xC3",
942
- "%C3": "\xC3",
943
- "%c4": "\xC4",
944
- "%C4": "\xC4",
945
- "%c5": "\xC5",
946
- "%C5": "\xC5",
947
- "%c6": "\xC6",
948
- "%C6": "\xC6",
949
- "%c7": "\xC7",
950
- "%C7": "\xC7",
951
- "%c8": "\xC8",
952
- "%C8": "\xC8",
953
- "%c9": "\xC9",
954
- "%C9": "\xC9",
955
- "%ca": "\xCA",
956
- "%Ca": "\xCA",
957
- "%cA": "\xCA",
958
- "%CA": "\xCA",
959
- "%cb": "\xCB",
960
- "%Cb": "\xCB",
961
- "%cB": "\xCB",
962
- "%CB": "\xCB",
963
- "%cc": "\xCC",
964
- "%Cc": "\xCC",
965
- "%cC": "\xCC",
966
- "%CC": "\xCC",
967
- "%cd": "\xCD",
968
- "%Cd": "\xCD",
969
- "%cD": "\xCD",
970
- "%CD": "\xCD",
971
- "%ce": "\xCE",
972
- "%Ce": "\xCE",
973
- "%cE": "\xCE",
974
- "%CE": "\xCE",
975
- "%cf": "\xCF",
976
- "%Cf": "\xCF",
977
- "%cF": "\xCF",
978
- "%CF": "\xCF",
979
- "%d0": "\xD0",
980
- "%D0": "\xD0",
981
- "%d1": "\xD1",
982
- "%D1": "\xD1",
983
- "%d2": "\xD2",
984
- "%D2": "\xD2",
985
- "%d3": "\xD3",
986
- "%D3": "\xD3",
987
- "%d4": "\xD4",
988
- "%D4": "\xD4",
989
- "%d5": "\xD5",
990
- "%D5": "\xD5",
991
- "%d6": "\xD6",
992
- "%D6": "\xD6",
993
- "%d7": "\xD7",
994
- "%D7": "\xD7",
995
- "%d8": "\xD8",
996
- "%D8": "\xD8",
997
- "%d9": "\xD9",
998
- "%D9": "\xD9",
999
- "%da": "\xDA",
1000
- "%Da": "\xDA",
1001
- "%dA": "\xDA",
1002
- "%DA": "\xDA",
1003
- "%db": "\xDB",
1004
- "%Db": "\xDB",
1005
- "%dB": "\xDB",
1006
- "%DB": "\xDB",
1007
- "%dc": "\xDC",
1008
- "%Dc": "\xDC",
1009
- "%dC": "\xDC",
1010
- "%DC": "\xDC",
1011
- "%dd": "\xDD",
1012
- "%Dd": "\xDD",
1013
- "%dD": "\xDD",
1014
- "%DD": "\xDD",
1015
- "%de": "\xDE",
1016
- "%De": "\xDE",
1017
- "%dE": "\xDE",
1018
- "%DE": "\xDE",
1019
- "%df": "\xDF",
1020
- "%Df": "\xDF",
1021
- "%dF": "\xDF",
1022
- "%DF": "\xDF",
1023
- "%e0": "\xE0",
1024
- "%E0": "\xE0",
1025
- "%e1": "\xE1",
1026
- "%E1": "\xE1",
1027
- "%e2": "\xE2",
1028
- "%E2": "\xE2",
1029
- "%e3": "\xE3",
1030
- "%E3": "\xE3",
1031
- "%e4": "\xE4",
1032
- "%E4": "\xE4",
1033
- "%e5": "\xE5",
1034
- "%E5": "\xE5",
1035
- "%e6": "\xE6",
1036
- "%E6": "\xE6",
1037
- "%e7": "\xE7",
1038
- "%E7": "\xE7",
1039
- "%e8": "\xE8",
1040
- "%E8": "\xE8",
1041
- "%e9": "\xE9",
1042
- "%E9": "\xE9",
1043
- "%ea": "\xEA",
1044
- "%Ea": "\xEA",
1045
- "%eA": "\xEA",
1046
- "%EA": "\xEA",
1047
- "%eb": "\xEB",
1048
- "%Eb": "\xEB",
1049
- "%eB": "\xEB",
1050
- "%EB": "\xEB",
1051
- "%ec": "\xEC",
1052
- "%Ec": "\xEC",
1053
- "%eC": "\xEC",
1054
- "%EC": "\xEC",
1055
- "%ed": "\xED",
1056
- "%Ed": "\xED",
1057
- "%eD": "\xED",
1058
- "%ED": "\xED",
1059
- "%ee": "\xEE",
1060
- "%Ee": "\xEE",
1061
- "%eE": "\xEE",
1062
- "%EE": "\xEE",
1063
- "%ef": "\xEF",
1064
- "%Ef": "\xEF",
1065
- "%eF": "\xEF",
1066
- "%EF": "\xEF",
1067
- "%f0": "\xF0",
1068
- "%F0": "\xF0",
1069
- "%f1": "\xF1",
1070
- "%F1": "\xF1",
1071
- "%f2": "\xF2",
1072
- "%F2": "\xF2",
1073
- "%f3": "\xF3",
1074
- "%F3": "\xF3",
1075
- "%f4": "\xF4",
1076
- "%F4": "\xF4",
1077
- "%f5": "\xF5",
1078
- "%F5": "\xF5",
1079
- "%f6": "\xF6",
1080
- "%F6": "\xF6",
1081
- "%f7": "\xF7",
1082
- "%F7": "\xF7",
1083
- "%f8": "\xF8",
1084
- "%F8": "\xF8",
1085
- "%f9": "\xF9",
1086
- "%F9": "\xF9",
1087
- "%fa": "\xFA",
1088
- "%Fa": "\xFA",
1089
- "%fA": "\xFA",
1090
- "%FA": "\xFA",
1091
- "%fb": "\xFB",
1092
- "%Fb": "\xFB",
1093
- "%fB": "\xFB",
1094
- "%FB": "\xFB",
1095
- "%fc": "\xFC",
1096
- "%Fc": "\xFC",
1097
- "%fC": "\xFC",
1098
- "%FC": "\xFC",
1099
- "%fd": "\xFD",
1100
- "%Fd": "\xFD",
1101
- "%fD": "\xFD",
1102
- "%FD": "\xFD",
1103
- "%fe": "\xFE",
1104
- "%Fe": "\xFE",
1105
- "%fE": "\xFE",
1106
- "%FE": "\xFE",
1107
- "%ff": "\xFF",
1108
- "%Ff": "\xFF",
1109
- "%fF": "\xFF",
1110
- "%FF": "\xFF"
1111
- };
1112
- function encodedReplacer(match) {
1113
- return EncodedLookup[match];
1114
- }
1115
- var STATE_KEY = 0;
1116
- var STATE_VALUE = 1;
1117
- var STATE_CHARSET = 2;
1118
- var STATE_LANG = 3;
1119
- function parseParams(str) {
1120
- const res = [];
1121
- let state = STATE_KEY;
1122
- let charset = "";
1123
- let inquote = false;
1124
- let escaping = false;
1125
- let p = 0;
1126
- let tmp = "";
1127
- const len = str.length;
1128
- for (var i = 0; i < len; ++i) {
1129
- const char = str[i];
1130
- if (char === "\\" && inquote) {
1131
- if (escaping) {
1132
- escaping = false;
1133
- } else {
1134
- escaping = true;
1135
- continue;
1136
- }
1137
- } else if (char === '"') {
1138
- if (!escaping) {
1139
- if (inquote) {
1140
- inquote = false;
1141
- state = STATE_KEY;
1142
- } else {
1143
- inquote = true;
1144
- }
1145
- continue;
1146
- } else {
1147
- escaping = false;
1148
- }
1149
- } else {
1150
- if (escaping && inquote) {
1151
- tmp += "\\";
1152
- }
1153
- escaping = false;
1154
- if ((state === STATE_CHARSET || state === STATE_LANG) && char === "'") {
1155
- if (state === STATE_CHARSET) {
1156
- state = STATE_LANG;
1157
- charset = tmp.substring(1);
1158
- } else {
1159
- state = STATE_VALUE;
1160
- }
1161
- tmp = "";
1162
- continue;
1163
- } else if (state === STATE_KEY && (char === "*" || char === "=") && res.length) {
1164
- state = char === "*" ? STATE_CHARSET : STATE_VALUE;
1165
- res[p] = [tmp, void 0];
1166
- tmp = "";
1167
- continue;
1168
- } else if (!inquote && char === ";") {
1169
- state = STATE_KEY;
1170
- if (charset) {
1171
- if (tmp.length) {
1172
- tmp = decodeText(
1173
- tmp.replace(RE_ENCODED, encodedReplacer),
1174
- "binary",
1175
- charset
1176
- );
1177
- }
1178
- charset = "";
1179
- } else if (tmp.length) {
1180
- tmp = decodeText(tmp, "binary", "utf8");
1181
- }
1182
- if (res[p] === void 0) {
1183
- res[p] = tmp;
1184
- } else {
1185
- res[p][1] = tmp;
1186
- }
1187
- tmp = "";
1188
- ++p;
1189
- continue;
1190
- } else if (!inquote && (char === " " || char === " ")) {
1191
- continue;
1192
- }
1193
- }
1194
- tmp += char;
1195
- }
1196
- if (charset && tmp.length) {
1197
- tmp = decodeText(
1198
- tmp.replace(RE_ENCODED, encodedReplacer),
1199
- "binary",
1200
- charset
1201
- );
1202
- } else if (tmp) {
1203
- tmp = decodeText(tmp, "binary", "utf8");
1204
- }
1205
- if (res[p] === void 0) {
1206
- if (tmp) {
1207
- res[p] = tmp;
1208
- }
1209
- } else {
1210
- res[p][1] = tmp;
1211
- }
1212
- return res;
1213
- }
1214
- module.exports = parseParams;
1215
- }
1216
- });
1217
-
1218
- // node_modules/@fastify/busboy/lib/utils/basename.js
1219
- var require_basename = __commonJS({
1220
- "node_modules/@fastify/busboy/lib/utils/basename.js"(exports, module) {
1221
- "use strict";
1222
- module.exports = function basename(path) {
1223
- if (typeof path !== "string") {
1224
- return "";
1225
- }
1226
- for (var i = path.length - 1; i >= 0; --i) {
1227
- switch (path.charCodeAt(i)) {
1228
- case 47:
1229
- // '/'
1230
- case 92:
1231
- path = path.slice(i + 1);
1232
- return path === ".." || path === "." ? "" : path;
1233
- }
1234
- }
1235
- return path === ".." || path === "." ? "" : path;
1236
- };
1237
- }
1238
- });
1239
-
1240
- // node_modules/@fastify/busboy/lib/types/multipart.js
1241
- var require_multipart = __commonJS({
1242
- "node_modules/@fastify/busboy/lib/types/multipart.js"(exports, module) {
1243
- "use strict";
1244
- var { Readable } = __require("node:stream");
1245
- var { inherits } = __require("node:util");
1246
- var Dicer = require_Dicer();
1247
- var parseParams = require_parseParams();
1248
- var decodeText = require_decodeText();
1249
- var basename = require_basename();
1250
- var getLimit = require_getLimit();
1251
- var RE_BOUNDARY = /^boundary$/i;
1252
- var RE_FIELD = /^form-data$/i;
1253
- var RE_CHARSET = /^charset$/i;
1254
- var RE_FILENAME = /^filename$/i;
1255
- var RE_NAME = /^name$/i;
1256
- Multipart.detect = /^multipart\/form-data/i;
1257
- function Multipart(boy, cfg) {
1258
- let i;
1259
- let len;
1260
- const self = this;
1261
- let boundary;
1262
- const limits = cfg.limits;
1263
- const isPartAFile = cfg.isPartAFile || ((fieldName, contentType, fileName) => contentType === "application/octet-stream" || fileName !== void 0);
1264
- const parsedConType = cfg.parsedConType || [];
1265
- const defCharset = cfg.defCharset || "utf8";
1266
- const preservePath = cfg.preservePath;
1267
- const fileOpts = { highWaterMark: cfg.fileHwm };
1268
- for (i = 0, len = parsedConType.length; i < len; ++i) {
1269
- if (Array.isArray(parsedConType[i]) && RE_BOUNDARY.test(parsedConType[i][0])) {
1270
- boundary = parsedConType[i][1];
1271
- break;
1272
- }
1273
- }
1274
- function checkFinished() {
1275
- if (nends === 0 && finished && !boy._done) {
1276
- finished = false;
1277
- self.end();
1278
- }
1279
- }
1280
- if (typeof boundary !== "string") {
1281
- throw new Error("Multipart: Boundary not found");
1282
- }
1283
- const fieldSizeLimit = getLimit(limits, "fieldSize", 1 * 1024 * 1024);
1284
- const fileSizeLimit = getLimit(limits, "fileSize", Infinity);
1285
- const filesLimit = getLimit(limits, "files", Infinity);
1286
- const fieldsLimit = getLimit(limits, "fields", Infinity);
1287
- const partsLimit = getLimit(limits, "parts", Infinity);
1288
- const headerPairsLimit = getLimit(limits, "headerPairs", 2e3);
1289
- const headerSizeLimit = getLimit(limits, "headerSize", 80 * 1024);
1290
- let nfiles = 0;
1291
- let nfields = 0;
1292
- let nends = 0;
1293
- let curFile;
1294
- let curField;
1295
- let finished = false;
1296
- this._needDrain = false;
1297
- this._pause = false;
1298
- this._cb = void 0;
1299
- this._nparts = 0;
1300
- this._boy = boy;
1301
- const parserCfg = {
1302
- boundary,
1303
- maxHeaderPairs: headerPairsLimit,
1304
- maxHeaderSize: headerSizeLimit,
1305
- partHwm: fileOpts.highWaterMark,
1306
- highWaterMark: cfg.highWaterMark
1307
- };
1308
- this.parser = new Dicer(parserCfg);
1309
- this.parser.on("drain", function() {
1310
- self._needDrain = false;
1311
- if (self._cb && !self._pause) {
1312
- const cb = self._cb;
1313
- self._cb = void 0;
1314
- cb();
1315
- }
1316
- }).on("part", function onPart(part) {
1317
- if (++self._nparts > partsLimit) {
1318
- self.parser.removeListener("part", onPart);
1319
- self.parser.on("part", skipPart);
1320
- boy.hitPartsLimit = true;
1321
- boy.emit("partsLimit");
1322
- return skipPart(part);
1323
- }
1324
- if (curField) {
1325
- const field = curField;
1326
- field.emit("end");
1327
- field.removeAllListeners("end");
1328
- }
1329
- part.on("header", function(header) {
1330
- let contype;
1331
- let fieldname;
1332
- let parsed;
1333
- let charset;
1334
- let encoding;
1335
- let filename;
1336
- let nsize = 0;
1337
- if (header["content-type"]) {
1338
- parsed = parseParams(header["content-type"][0]);
1339
- if (parsed[0]) {
1340
- contype = parsed[0].toLowerCase();
1341
- for (i = 0, len = parsed.length; i < len; ++i) {
1342
- if (RE_CHARSET.test(parsed[i][0])) {
1343
- charset = parsed[i][1].toLowerCase();
1344
- break;
1345
- }
1346
- }
1347
- }
1348
- }
1349
- if (contype === void 0) {
1350
- contype = "text/plain";
1351
- }
1352
- if (charset === void 0) {
1353
- charset = defCharset;
1354
- }
1355
- if (header["content-disposition"]) {
1356
- parsed = parseParams(header["content-disposition"][0]);
1357
- if (!RE_FIELD.test(parsed[0])) {
1358
- return skipPart(part);
1359
- }
1360
- for (i = 0, len = parsed.length; i < len; ++i) {
1361
- if (RE_NAME.test(parsed[i][0])) {
1362
- fieldname = parsed[i][1];
1363
- } else if (RE_FILENAME.test(parsed[i][0])) {
1364
- filename = parsed[i][1];
1365
- if (!preservePath) {
1366
- filename = basename(filename);
1367
- }
1368
- }
1369
- }
1370
- } else {
1371
- return skipPart(part);
1372
- }
1373
- if (header["content-transfer-encoding"]) {
1374
- encoding = header["content-transfer-encoding"][0].toLowerCase();
1375
- } else {
1376
- encoding = "7bit";
1377
- }
1378
- let onData, onEnd;
1379
- if (isPartAFile(fieldname, contype, filename)) {
1380
- if (nfiles === filesLimit) {
1381
- if (!boy.hitFilesLimit) {
1382
- boy.hitFilesLimit = true;
1383
- boy.emit("filesLimit");
1384
- }
1385
- return skipPart(part);
1386
- }
1387
- ++nfiles;
1388
- if (boy.listenerCount("file") === 0) {
1389
- self.parser._ignore();
1390
- return;
1391
- }
1392
- ++nends;
1393
- const file = new FileStream(fileOpts);
1394
- curFile = file;
1395
- file.on("end", function() {
1396
- --nends;
1397
- self._pause = false;
1398
- checkFinished();
1399
- if (self._cb && !self._needDrain) {
1400
- const cb = self._cb;
1401
- self._cb = void 0;
1402
- cb();
1403
- }
1404
- });
1405
- file._read = function(n) {
1406
- if (!self._pause) {
1407
- return;
1408
- }
1409
- self._pause = false;
1410
- if (self._cb && !self._needDrain) {
1411
- const cb = self._cb;
1412
- self._cb = void 0;
1413
- cb();
1414
- }
1415
- };
1416
- boy.emit("file", fieldname, file, filename, encoding, contype);
1417
- onData = function(data) {
1418
- if ((nsize += data.length) > fileSizeLimit) {
1419
- const extralen = fileSizeLimit - nsize + data.length;
1420
- if (extralen > 0) {
1421
- file.push(data.slice(0, extralen));
1422
- }
1423
- file.truncated = true;
1424
- file.bytesRead = fileSizeLimit;
1425
- part.removeAllListeners("data");
1426
- file.emit("limit");
1427
- return;
1428
- } else if (!file.push(data)) {
1429
- self._pause = true;
1430
- }
1431
- file.bytesRead = nsize;
1432
- };
1433
- onEnd = function() {
1434
- curFile = void 0;
1435
- file.push(null);
1436
- };
1437
- } else {
1438
- if (nfields === fieldsLimit) {
1439
- if (!boy.hitFieldsLimit) {
1440
- boy.hitFieldsLimit = true;
1441
- boy.emit("fieldsLimit");
1442
- }
1443
- return skipPart(part);
1444
- }
1445
- ++nfields;
1446
- ++nends;
1447
- let buffer = "";
1448
- let truncated = false;
1449
- curField = part;
1450
- onData = function(data) {
1451
- if ((nsize += data.length) > fieldSizeLimit) {
1452
- const extralen = fieldSizeLimit - (nsize - data.length);
1453
- buffer += data.toString("binary", 0, extralen);
1454
- truncated = true;
1455
- part.removeAllListeners("data");
1456
- } else {
1457
- buffer += data.toString("binary");
1458
- }
1459
- };
1460
- onEnd = function() {
1461
- curField = void 0;
1462
- if (buffer.length) {
1463
- buffer = decodeText(buffer, "binary", charset);
1464
- }
1465
- boy.emit("field", fieldname, buffer, false, truncated, encoding, contype);
1466
- --nends;
1467
- checkFinished();
1468
- };
1469
- }
1470
- part._readableState.sync = false;
1471
- part.on("data", onData);
1472
- part.on("end", onEnd);
1473
- }).on("error", function(err) {
1474
- if (curFile) {
1475
- curFile.emit("error", err);
1476
- }
1477
- });
1478
- }).on("error", function(err) {
1479
- boy.emit("error", err);
1480
- }).on("finish", function() {
1481
- finished = true;
1482
- checkFinished();
1483
- });
1484
- }
1485
- Multipart.prototype.write = function(chunk, cb) {
1486
- const r = this.parser.write(chunk);
1487
- if (r && !this._pause) {
1488
- cb();
1489
- } else {
1490
- this._needDrain = !r;
1491
- this._cb = cb;
1492
- }
1493
- };
1494
- Multipart.prototype.end = function() {
1495
- const self = this;
1496
- if (self.parser.writable) {
1497
- self.parser.end();
1498
- } else if (!self._boy._done) {
1499
- process.nextTick(function() {
1500
- self._boy._done = true;
1501
- self._boy.emit("finish");
1502
- });
1503
- }
1504
- };
1505
- function skipPart(part) {
1506
- part.resume();
1507
- }
1508
- function FileStream(opts) {
1509
- Readable.call(this, opts);
1510
- this.bytesRead = 0;
1511
- this.truncated = false;
1512
- }
1513
- inherits(FileStream, Readable);
1514
- FileStream.prototype._read = function(n) {
1515
- };
1516
- module.exports = Multipart;
1517
- }
1518
- });
1519
-
1520
- // node_modules/@fastify/busboy/lib/utils/Decoder.js
1521
- var require_Decoder = __commonJS({
1522
- "node_modules/@fastify/busboy/lib/utils/Decoder.js"(exports, module) {
1523
- "use strict";
1524
- var RE_PLUS = /\+/g;
1525
- var HEX = [
1526
- 0,
1527
- 0,
1528
- 0,
1529
- 0,
1530
- 0,
1531
- 0,
1532
- 0,
1533
- 0,
1534
- 0,
1535
- 0,
1536
- 0,
1537
- 0,
1538
- 0,
1539
- 0,
1540
- 0,
1541
- 0,
1542
- 0,
1543
- 0,
1544
- 0,
1545
- 0,
1546
- 0,
1547
- 0,
1548
- 0,
1549
- 0,
1550
- 0,
1551
- 0,
1552
- 0,
1553
- 0,
1554
- 0,
1555
- 0,
1556
- 0,
1557
- 0,
1558
- 0,
1559
- 0,
1560
- 0,
1561
- 0,
1562
- 0,
1563
- 0,
1564
- 0,
1565
- 0,
1566
- 0,
1567
- 0,
1568
- 0,
1569
- 0,
1570
- 0,
1571
- 0,
1572
- 0,
1573
- 0,
1574
- 1,
1575
- 1,
1576
- 1,
1577
- 1,
1578
- 1,
1579
- 1,
1580
- 1,
1581
- 1,
1582
- 1,
1583
- 1,
1584
- 0,
1585
- 0,
1586
- 0,
1587
- 0,
1588
- 0,
1589
- 0,
1590
- 0,
1591
- 1,
1592
- 1,
1593
- 1,
1594
- 1,
1595
- 1,
1596
- 1,
1597
- 0,
1598
- 0,
1599
- 0,
1600
- 0,
1601
- 0,
1602
- 0,
1603
- 0,
1604
- 0,
1605
- 0,
1606
- 0,
1607
- 0,
1608
- 0,
1609
- 0,
1610
- 0,
1611
- 0,
1612
- 0,
1613
- 0,
1614
- 0,
1615
- 0,
1616
- 0,
1617
- 0,
1618
- 0,
1619
- 0,
1620
- 0,
1621
- 0,
1622
- 0,
1623
- 1,
1624
- 1,
1625
- 1,
1626
- 1,
1627
- 1,
1628
- 1,
1629
- 0,
1630
- 0,
1631
- 0,
1632
- 0,
1633
- 0,
1634
- 0,
1635
- 0,
1636
- 0,
1637
- 0,
1638
- 0,
1639
- 0,
1640
- 0,
1641
- 0,
1642
- 0,
1643
- 0,
1644
- 0,
1645
- 0,
1646
- 0,
1647
- 0,
1648
- 0,
1649
- 0,
1650
- 0,
1651
- 0,
1652
- 0,
1653
- 0
1654
- ];
1655
- function Decoder() {
1656
- this.buffer = void 0;
1657
- }
1658
- Decoder.prototype.write = function(str) {
1659
- str = str.replace(RE_PLUS, " ");
1660
- let res = "";
1661
- let i = 0;
1662
- let p = 0;
1663
- const len = str.length;
1664
- for (; i < len; ++i) {
1665
- if (this.buffer !== void 0) {
1666
- if (!HEX[str.charCodeAt(i)]) {
1667
- res += "%" + this.buffer;
1668
- this.buffer = void 0;
1669
- --i;
1670
- } else {
1671
- this.buffer += str[i];
1672
- ++p;
1673
- if (this.buffer.length === 2) {
1674
- res += String.fromCharCode(parseInt(this.buffer, 16));
1675
- this.buffer = void 0;
1676
- }
1677
- }
1678
- } else if (str[i] === "%") {
1679
- if (i > p) {
1680
- res += str.substring(p, i);
1681
- p = i;
1682
- }
1683
- this.buffer = "";
1684
- ++p;
1685
- }
1686
- }
1687
- if (p < len && this.buffer === void 0) {
1688
- res += str.substring(p);
1689
- }
1690
- return res;
1691
- };
1692
- Decoder.prototype.reset = function() {
1693
- this.buffer = void 0;
1694
- };
1695
- module.exports = Decoder;
1696
- }
1697
- });
1698
-
1699
- // node_modules/@fastify/busboy/lib/types/urlencoded.js
1700
- var require_urlencoded = __commonJS({
1701
- "node_modules/@fastify/busboy/lib/types/urlencoded.js"(exports, module) {
1702
- "use strict";
1703
- var Decoder = require_Decoder();
1704
- var decodeText = require_decodeText();
1705
- var getLimit = require_getLimit();
1706
- var RE_CHARSET = /^charset$/i;
1707
- UrlEncoded.detect = /^application\/x-www-form-urlencoded/i;
1708
- function UrlEncoded(boy, cfg) {
1709
- const limits = cfg.limits;
1710
- const parsedConType = cfg.parsedConType;
1711
- this.boy = boy;
1712
- this.fieldSizeLimit = getLimit(limits, "fieldSize", 1 * 1024 * 1024);
1713
- this.fieldNameSizeLimit = getLimit(limits, "fieldNameSize", 100);
1714
- this.fieldsLimit = getLimit(limits, "fields", Infinity);
1715
- let charset;
1716
- for (var i = 0, len = parsedConType.length; i < len; ++i) {
1717
- if (Array.isArray(parsedConType[i]) && RE_CHARSET.test(parsedConType[i][0])) {
1718
- charset = parsedConType[i][1].toLowerCase();
1719
- break;
1720
- }
1721
- }
1722
- if (charset === void 0) {
1723
- charset = cfg.defCharset || "utf8";
1724
- }
1725
- this.decoder = new Decoder();
1726
- this.charset = charset;
1727
- this._fields = 0;
1728
- this._state = "key";
1729
- this._checkingBytes = true;
1730
- this._bytesKey = 0;
1731
- this._bytesVal = 0;
1732
- this._key = "";
1733
- this._val = "";
1734
- this._keyTrunc = false;
1735
- this._valTrunc = false;
1736
- this._hitLimit = false;
1737
- }
1738
- UrlEncoded.prototype.write = function(data, cb) {
1739
- if (this._fields === this.fieldsLimit) {
1740
- if (!this.boy.hitFieldsLimit) {
1741
- this.boy.hitFieldsLimit = true;
1742
- this.boy.emit("fieldsLimit");
1743
- }
1744
- return cb();
1745
- }
1746
- let idxeq;
1747
- let idxamp;
1748
- let i;
1749
- let p = 0;
1750
- const len = data.length;
1751
- while (p < len) {
1752
- if (this._state === "key") {
1753
- idxeq = idxamp = void 0;
1754
- for (i = p; i < len; ++i) {
1755
- if (!this._checkingBytes) {
1756
- ++p;
1757
- }
1758
- if (data[i] === 61) {
1759
- idxeq = i;
1760
- break;
1761
- } else if (data[i] === 38) {
1762
- idxamp = i;
1763
- break;
1764
- }
1765
- if (this._checkingBytes && this._bytesKey === this.fieldNameSizeLimit) {
1766
- this._hitLimit = true;
1767
- break;
1768
- } else if (this._checkingBytes) {
1769
- ++this._bytesKey;
1770
- }
1771
- }
1772
- if (idxeq !== void 0) {
1773
- if (idxeq > p) {
1774
- this._key += this.decoder.write(data.toString("binary", p, idxeq));
1775
- }
1776
- this._state = "val";
1777
- this._hitLimit = false;
1778
- this._checkingBytes = true;
1779
- this._val = "";
1780
- this._bytesVal = 0;
1781
- this._valTrunc = false;
1782
- this.decoder.reset();
1783
- p = idxeq + 1;
1784
- } else if (idxamp !== void 0) {
1785
- ++this._fields;
1786
- let key;
1787
- const keyTrunc = this._keyTrunc;
1788
- if (idxamp > p) {
1789
- key = this._key += this.decoder.write(data.toString("binary", p, idxamp));
1790
- } else {
1791
- key = this._key;
1792
- }
1793
- this._hitLimit = false;
1794
- this._checkingBytes = true;
1795
- this._key = "";
1796
- this._bytesKey = 0;
1797
- this._keyTrunc = false;
1798
- this.decoder.reset();
1799
- if (key.length) {
1800
- this.boy.emit(
1801
- "field",
1802
- decodeText(key, "binary", this.charset),
1803
- "",
1804
- keyTrunc,
1805
- false
1806
- );
1807
- }
1808
- p = idxamp + 1;
1809
- if (this._fields === this.fieldsLimit) {
1810
- return cb();
1811
- }
1812
- } else if (this._hitLimit) {
1813
- if (i > p) {
1814
- this._key += this.decoder.write(data.toString("binary", p, i));
1815
- }
1816
- p = i;
1817
- if ((this._bytesKey = this._key.length) === this.fieldNameSizeLimit) {
1818
- this._checkingBytes = false;
1819
- this._keyTrunc = true;
1820
- }
1821
- } else {
1822
- if (p < len) {
1823
- this._key += this.decoder.write(data.toString("binary", p));
1824
- }
1825
- p = len;
1826
- }
1827
- } else {
1828
- idxamp = void 0;
1829
- for (i = p; i < len; ++i) {
1830
- if (!this._checkingBytes) {
1831
- ++p;
1832
- }
1833
- if (data[i] === 38) {
1834
- idxamp = i;
1835
- break;
1836
- }
1837
- if (this._checkingBytes && this._bytesVal === this.fieldSizeLimit) {
1838
- this._hitLimit = true;
1839
- break;
1840
- } else if (this._checkingBytes) {
1841
- ++this._bytesVal;
1842
- }
1843
- }
1844
- if (idxamp !== void 0) {
1845
- ++this._fields;
1846
- if (idxamp > p) {
1847
- this._val += this.decoder.write(data.toString("binary", p, idxamp));
1848
- }
1849
- this.boy.emit(
1850
- "field",
1851
- decodeText(this._key, "binary", this.charset),
1852
- decodeText(this._val, "binary", this.charset),
1853
- this._keyTrunc,
1854
- this._valTrunc
1855
- );
1856
- this._state = "key";
1857
- this._hitLimit = false;
1858
- this._checkingBytes = true;
1859
- this._key = "";
1860
- this._bytesKey = 0;
1861
- this._keyTrunc = false;
1862
- this.decoder.reset();
1863
- p = idxamp + 1;
1864
- if (this._fields === this.fieldsLimit) {
1865
- return cb();
1866
- }
1867
- } else if (this._hitLimit) {
1868
- if (i > p) {
1869
- this._val += this.decoder.write(data.toString("binary", p, i));
1870
- }
1871
- p = i;
1872
- if (this._val === "" && this.fieldSizeLimit === 0 || (this._bytesVal = this._val.length) === this.fieldSizeLimit) {
1873
- this._checkingBytes = false;
1874
- this._valTrunc = true;
1875
- }
1876
- } else {
1877
- if (p < len) {
1878
- this._val += this.decoder.write(data.toString("binary", p));
1879
- }
1880
- p = len;
1881
- }
1882
- }
1883
- }
1884
- cb();
1885
- };
1886
- UrlEncoded.prototype.end = function() {
1887
- if (this.boy._done) {
1888
- return;
1889
- }
1890
- if (this._state === "key" && this._key.length > 0) {
1891
- this.boy.emit(
1892
- "field",
1893
- decodeText(this._key, "binary", this.charset),
1894
- "",
1895
- this._keyTrunc,
1896
- false
1897
- );
1898
- } else if (this._state === "val") {
1899
- this.boy.emit(
1900
- "field",
1901
- decodeText(this._key, "binary", this.charset),
1902
- decodeText(this._val, "binary", this.charset),
1903
- this._keyTrunc,
1904
- this._valTrunc
1905
- );
1906
- }
1907
- this.boy._done = true;
1908
- this.boy.emit("finish");
1909
- };
1910
- module.exports = UrlEncoded;
1911
- }
1912
- });
1913
-
1914
- // node_modules/@fastify/busboy/lib/main.js
1915
- var require_main = __commonJS({
1916
- "node_modules/@fastify/busboy/lib/main.js"(exports, module) {
1917
- "use strict";
1918
- var WritableStream = __require("node:stream").Writable;
1919
- var { inherits } = __require("node:util");
1920
- var Dicer = require_Dicer();
1921
- var MultipartParser = require_multipart();
1922
- var UrlencodedParser = require_urlencoded();
1923
- var parseParams = require_parseParams();
1924
- function Busboy(opts) {
1925
- if (!(this instanceof Busboy)) {
1926
- return new Busboy(opts);
1927
- }
1928
- if (typeof opts !== "object") {
1929
- throw new TypeError("Busboy expected an options-Object.");
1930
- }
1931
- if (typeof opts.headers !== "object") {
1932
- throw new TypeError("Busboy expected an options-Object with headers-attribute.");
1933
- }
1934
- if (typeof opts.headers["content-type"] !== "string") {
1935
- throw new TypeError("Missing Content-Type-header.");
1936
- }
1937
- const {
1938
- headers,
1939
- ...streamOptions
1940
- } = opts;
1941
- this.opts = {
1942
- autoDestroy: false,
1943
- ...streamOptions
1944
- };
1945
- WritableStream.call(this, this.opts);
1946
- this._done = false;
1947
- this._parser = this.getParserByHeaders(headers);
1948
- this._finished = false;
1949
- }
1950
- inherits(Busboy, WritableStream);
1951
- Busboy.prototype.emit = function(ev) {
1952
- var _a;
1953
- if (ev === "finish") {
1954
- if (!this._done) {
1955
- (_a = this._parser) == null ? void 0 : _a.end();
1956
- return;
1957
- } else if (this._finished) {
1958
- return;
1959
- }
1960
- this._finished = true;
1961
- }
1962
- WritableStream.prototype.emit.apply(this, arguments);
1963
- };
1964
- Busboy.prototype.getParserByHeaders = function(headers) {
1965
- const parsed = parseParams(headers["content-type"]);
1966
- const cfg = {
1967
- defCharset: this.opts.defCharset,
1968
- fileHwm: this.opts.fileHwm,
1969
- headers,
1970
- highWaterMark: this.opts.highWaterMark,
1971
- isPartAFile: this.opts.isPartAFile,
1972
- limits: this.opts.limits,
1973
- parsedConType: parsed,
1974
- preservePath: this.opts.preservePath
1975
- };
1976
- if (MultipartParser.detect.test(parsed[0])) {
1977
- return new MultipartParser(this, cfg);
1978
- }
1979
- if (UrlencodedParser.detect.test(parsed[0])) {
1980
- return new UrlencodedParser(this, cfg);
1981
- }
1982
- throw new Error("Unsupported Content-Type.");
1983
- };
1984
- Busboy.prototype._write = function(chunk, encoding, cb) {
1985
- this._parser.write(chunk, cb);
1986
- };
1987
- module.exports = Busboy;
1988
- module.exports.default = Busboy;
1989
- module.exports.Busboy = Busboy;
1990
- module.exports.Dicer = Dicer;
1991
- }
1992
- });
1993
-
1994
- // node_modules/fastify-plugin/lib/getPluginName.js
1995
- var require_getPluginName = __commonJS({
1996
- "node_modules/fastify-plugin/lib/getPluginName.js"(exports, module) {
1997
- "use strict";
1998
- var fpStackTracePattern = /at\s{1}(?:.*\.)?plugin\s{1}.*\n\s*(.*)/;
1999
- var fileNamePattern = /(\w*(\.\w*)*)\..*/;
2000
- module.exports = function getPluginName(fn) {
2001
- if (fn.name.length > 0) return fn.name;
2002
- const stackTraceLimit = Error.stackTraceLimit;
2003
- Error.stackTraceLimit = 10;
2004
- try {
2005
- throw new Error("anonymous function");
2006
- } catch (e) {
2007
- Error.stackTraceLimit = stackTraceLimit;
2008
- return extractPluginName(e.stack);
2009
- }
2010
- };
2011
- function extractPluginName(stack) {
2012
- const m = stack.match(fpStackTracePattern);
2013
- return m ? m[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : "anonymous";
2014
- }
2015
- module.exports.extractPluginName = extractPluginName;
2016
- }
2017
- });
2018
-
2019
- // node_modules/fastify-plugin/lib/toCamelCase.js
2020
- var require_toCamelCase = __commonJS({
2021
- "node_modules/fastify-plugin/lib/toCamelCase.js"(exports, module) {
2022
- "use strict";
2023
- module.exports = function toCamelCase(name) {
2024
- if (name[0] === "@") {
2025
- name = name.slice(1).replace("/", "-");
2026
- }
2027
- return name.replace(/-(.)/g, function(match, g1) {
2028
- return g1.toUpperCase();
2029
- });
2030
- };
2031
- }
2032
- });
2033
-
2034
- // node_modules/fastify-plugin/plugin.js
2035
- var require_plugin = __commonJS({
2036
- "node_modules/fastify-plugin/plugin.js"(exports, module) {
2037
- "use strict";
2038
- var getPluginName = require_getPluginName();
2039
- var toCamelCase = require_toCamelCase();
2040
- var count = 0;
2041
- function plugin(fn, options = {}) {
2042
- let autoName = false;
2043
- if (fn.default !== void 0) {
2044
- fn = fn.default;
2045
- }
2046
- if (typeof fn !== "function") {
2047
- throw new TypeError(
2048
- `fastify-plugin expects a function, instead got a '${typeof fn}'`
2049
- );
2050
- }
2051
- if (typeof options === "string") {
2052
- options = {
2053
- fastify: options
2054
- };
2055
- }
2056
- if (typeof options !== "object" || Array.isArray(options) || options === null) {
2057
- throw new TypeError("The options object should be an object");
2058
- }
2059
- if (options.fastify !== void 0 && typeof options.fastify !== "string") {
2060
- throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof options.fastify}'`);
2061
- }
2062
- if (!options.name) {
2063
- autoName = true;
2064
- options.name = getPluginName(fn) + "-auto-" + count++;
2065
- }
2066
- fn[Symbol.for("skip-override")] = options.encapsulate !== true;
2067
- fn[Symbol.for("fastify.display-name")] = options.name;
2068
- fn[Symbol.for("plugin-meta")] = options;
2069
- if (!fn.default) {
2070
- fn.default = fn;
2071
- }
2072
- const camelCase = toCamelCase(options.name);
2073
- if (!autoName && !fn[camelCase]) {
2074
- fn[camelCase] = fn;
2075
- }
2076
- return fn;
2077
- }
2078
- module.exports = plugin;
2079
- module.exports.default = plugin;
2080
- module.exports.fastifyPlugin = plugin;
2081
- }
2082
- });
2083
-
2084
- // node_modules/@fastify/multipart/lib/generateId.js
2085
- var require_generateId = __commonJS({
2086
- "node_modules/@fastify/multipart/lib/generateId.js"(exports, module) {
2087
- "use strict";
2088
- var HEX = [
2089
- "00",
2090
- "01",
2091
- "02",
2092
- "03",
2093
- "04",
2094
- "05",
2095
- "06",
2096
- "07",
2097
- "08",
2098
- "09",
2099
- "0a",
2100
- "0b",
2101
- "0c",
2102
- "0d",
2103
- "0e",
2104
- "0f",
2105
- "10",
2106
- "11",
2107
- "12",
2108
- "13",
2109
- "14",
2110
- "15",
2111
- "16",
2112
- "17",
2113
- "18",
2114
- "19",
2115
- "1a",
2116
- "1b",
2117
- "1c",
2118
- "1d",
2119
- "1e",
2120
- "1f",
2121
- "20",
2122
- "21",
2123
- "22",
2124
- "23",
2125
- "24",
2126
- "25",
2127
- "26",
2128
- "27",
2129
- "28",
2130
- "29",
2131
- "2a",
2132
- "2b",
2133
- "2c",
2134
- "2d",
2135
- "2e",
2136
- "2f",
2137
- "30",
2138
- "31",
2139
- "32",
2140
- "33",
2141
- "34",
2142
- "35",
2143
- "36",
2144
- "37",
2145
- "38",
2146
- "39",
2147
- "3a",
2148
- "3b",
2149
- "3c",
2150
- "3d",
2151
- "3e",
2152
- "3f",
2153
- "40",
2154
- "41",
2155
- "42",
2156
- "43",
2157
- "44",
2158
- "45",
2159
- "46",
2160
- "47",
2161
- "48",
2162
- "49",
2163
- "4a",
2164
- "4b",
2165
- "4c",
2166
- "4d",
2167
- "4e",
2168
- "4f",
2169
- "50",
2170
- "51",
2171
- "52",
2172
- "53",
2173
- "54",
2174
- "55",
2175
- "56",
2176
- "57",
2177
- "58",
2178
- "59",
2179
- "5a",
2180
- "5b",
2181
- "5c",
2182
- "5d",
2183
- "5e",
2184
- "5f",
2185
- "60",
2186
- "61",
2187
- "62",
2188
- "63",
2189
- "64",
2190
- "65",
2191
- "66",
2192
- "67",
2193
- "68",
2194
- "69",
2195
- "6a",
2196
- "6b",
2197
- "6c",
2198
- "6d",
2199
- "6e",
2200
- "6f",
2201
- "70",
2202
- "71",
2203
- "72",
2204
- "73",
2205
- "74",
2206
- "75",
2207
- "76",
2208
- "77",
2209
- "78",
2210
- "79",
2211
- "7a",
2212
- "7b",
2213
- "7c",
2214
- "7d",
2215
- "7e",
2216
- "7f",
2217
- "80",
2218
- "81",
2219
- "82",
2220
- "83",
2221
- "84",
2222
- "85",
2223
- "86",
2224
- "87",
2225
- "88",
2226
- "89",
2227
- "8a",
2228
- "8b",
2229
- "8c",
2230
- "8d",
2231
- "8e",
2232
- "8f",
2233
- "90",
2234
- "91",
2235
- "92",
2236
- "93",
2237
- "94",
2238
- "95",
2239
- "96",
2240
- "97",
2241
- "98",
2242
- "99",
2243
- "9a",
2244
- "9b",
2245
- "9c",
2246
- "9d",
2247
- "9e",
2248
- "9f",
2249
- "a0",
2250
- "a1",
2251
- "a2",
2252
- "a3",
2253
- "a4",
2254
- "a5",
2255
- "a6",
2256
- "a7",
2257
- "a8",
2258
- "a9",
2259
- "aa",
2260
- "ab",
2261
- "ac",
2262
- "ad",
2263
- "ae",
2264
- "af",
2265
- "b0",
2266
- "b1",
2267
- "b2",
2268
- "b3",
2269
- "b4",
2270
- "b5",
2271
- "b6",
2272
- "b7",
2273
- "b8",
2274
- "b9",
2275
- "ba",
2276
- "bb",
2277
- "bc",
2278
- "bd",
2279
- "be",
2280
- "bf",
2281
- "c0",
2282
- "c1",
2283
- "c2",
2284
- "c3",
2285
- "c4",
2286
- "c5",
2287
- "c6",
2288
- "c7",
2289
- "c8",
2290
- "c9",
2291
- "ca",
2292
- "cb",
2293
- "cc",
2294
- "cd",
2295
- "ce",
2296
- "cf",
2297
- "d0",
2298
- "d1",
2299
- "d2",
2300
- "d3",
2301
- "d4",
2302
- "d5",
2303
- "d6",
2304
- "d7",
2305
- "d8",
2306
- "d9",
2307
- "da",
2308
- "db",
2309
- "dc",
2310
- "dd",
2311
- "de",
2312
- "df",
2313
- "e0",
2314
- "e1",
2315
- "e2",
2316
- "e3",
2317
- "e4",
2318
- "e5",
2319
- "e6",
2320
- "e7",
2321
- "e8",
2322
- "e9",
2323
- "ea",
2324
- "eb",
2325
- "ec",
2326
- "ed",
2327
- "ee",
2328
- "ef",
2329
- "f0",
2330
- "f1",
2331
- "f2",
2332
- "f3",
2333
- "f4",
2334
- "f5",
2335
- "f6",
2336
- "f7",
2337
- "f8",
2338
- "f9",
2339
- "fa",
2340
- "fb",
2341
- "fc",
2342
- "fd",
2343
- "fe",
2344
- "ff"
2345
- ];
2346
- var random = Math.random;
2347
- function seed() {
2348
- return HEX[255 * random() | 0] + HEX[255 * random() | 0] + HEX[255 * random() | 0] + HEX[255 * random() | 0] + HEX[255 * random() | 0] + HEX[255 * random() | 0] + HEX[255 * random() | 0];
2349
- }
2350
- module.exports.generateId = function generateIdFn() {
2351
- let num = 0;
2352
- let str = seed();
2353
- return function generateId() {
2354
- return num === 255 ? (str = seed()) + HEX[num = 0] : str + HEX[++num];
2355
- };
2356
- }();
2357
- }
2358
- });
2359
-
2360
- // node_modules/@fastify/error/index.js
2361
- var require_error = __commonJS({
2362
- "node_modules/@fastify/error/index.js"(exports, module) {
2363
- "use strict";
2364
- var { format } = __require("node:util");
2365
- function toString() {
2366
- return `${this.name} [${this.code}]: ${this.message}`;
2367
- }
2368
- function createError(code, message, statusCode = 500, Base = Error, captureStackTrace = createError.captureStackTrace) {
2369
- if (!code) throw new Error("Fastify error code must not be empty");
2370
- if (!message) throw new Error("Fastify error message must not be empty");
2371
- code = code.toUpperCase();
2372
- !statusCode && (statusCode = void 0);
2373
- function FastifyError(...args) {
2374
- if (!new.target) {
2375
- return new FastifyError(...args);
2376
- }
2377
- this.code = code;
2378
- this.name = "FastifyError";
2379
- this.statusCode = statusCode;
2380
- const lastElement = args.length - 1;
2381
- if (lastElement !== -1 && args[lastElement] && typeof args[lastElement] === "object" && "cause" in args[lastElement]) {
2382
- this.cause = args.pop().cause;
2383
- }
2384
- this.message = format(message, ...args);
2385
- Error.stackTraceLimit && captureStackTrace && Error.captureStackTrace(this, FastifyError);
2386
- }
2387
- FastifyError.prototype = Object.create(Base.prototype, {
2388
- constructor: {
2389
- value: FastifyError,
2390
- enumerable: false,
2391
- writable: true,
2392
- configurable: true
2393
- }
2394
- });
2395
- FastifyError.prototype[Symbol.toStringTag] = "Error";
2396
- FastifyError.prototype.toString = toString;
2397
- return FastifyError;
2398
- }
2399
- createError.captureStackTrace = true;
2400
- module.exports = createError;
2401
- module.exports.default = createError;
2402
- module.exports.createError = createError;
2403
- }
2404
- });
2405
-
2406
- // node_modules/@fastify/multipart/lib/stream-consumer.js
2407
- var require_stream_consumer = __commonJS({
2408
- "node_modules/@fastify/multipart/lib/stream-consumer.js"(exports, module) {
2409
- "use strict";
2410
- module.exports = function streamToNull(stream) {
2411
- return new Promise((resolve, reject) => {
2412
- stream.on("data", () => {
2413
- });
2414
- stream.on("close", () => {
2415
- resolve();
2416
- });
2417
- stream.on("end", () => {
2418
- resolve();
2419
- });
2420
- stream.on("error", (error) => {
2421
- reject(error);
2422
- });
2423
- });
2424
- };
2425
- }
2426
- });
2427
-
2428
- // node_modules/@fastify/deepmerge/index.js
2429
- var require_deepmerge = __commonJS({
2430
- "node_modules/@fastify/deepmerge/index.js"(exports, module) {
2431
- "use strict";
2432
- var JSON_PROTO = Object.getPrototypeOf({});
2433
- function deepmergeConstructor(options) {
2434
- function isNotPrototypeKey(value) {
2435
- return value !== "constructor" && value !== "prototype" && value !== "__proto__";
2436
- }
2437
- function cloneArray(value) {
2438
- let i = 0;
2439
- const il = value.length;
2440
- const result = new Array(il);
2441
- for (i; i < il; ++i) {
2442
- result[i] = clone(value[i]);
2443
- }
2444
- return result;
2445
- }
2446
- function cloneObject(target) {
2447
- const result = {};
2448
- if (cloneProtoObject && Object.getPrototypeOf(target) !== JSON_PROTO) {
2449
- return cloneProtoObject(target);
2450
- }
2451
- const targetKeys = getKeys(target);
2452
- let i, il, key;
2453
- for (i = 0, il = targetKeys.length; i < il; ++i) {
2454
- isNotPrototypeKey(key = targetKeys[i]) && (result[key] = clone(target[key]));
2455
- }
2456
- return result;
2457
- }
2458
- function concatArrays(target, source) {
2459
- const tl = target.length;
2460
- const sl = source.length;
2461
- let i = 0;
2462
- const result = new Array(tl + sl);
2463
- for (i; i < tl; ++i) {
2464
- result[i] = clone(target[i]);
2465
- }
2466
- for (i = 0; i < sl; ++i) {
2467
- result[i + tl] = clone(source[i]);
2468
- }
2469
- return result;
2470
- }
2471
- const propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
2472
- function getSymbolsAndKeys(value) {
2473
- const result = Object.keys(value);
2474
- const keys = Object.getOwnPropertySymbols(value);
2475
- for (let i = 0, il = keys.length; i < il; ++i) {
2476
- propertyIsEnumerable.call(value, keys[i]) && result.push(keys[i]);
2477
- }
2478
- return result;
2479
- }
2480
- const getKeys = (options == null ? void 0 : options.symbols) ? getSymbolsAndKeys : Object.keys;
2481
- const cloneProtoObject = typeof (options == null ? void 0 : options.cloneProtoObject) === "function" ? options.cloneProtoObject : void 0;
2482
- function isMergeableObject(value) {
2483
- return typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Date);
2484
- }
2485
- function isPrimitive(value) {
2486
- return typeof value !== "object" || value === null;
2487
- }
2488
- const isPrimitiveOrBuiltIn = typeof Buffer !== "undefined" ? (value) => typeof value !== "object" || value === null || value instanceof RegExp || value instanceof Date || value instanceof Buffer : (value) => typeof value !== "object" || value === null || value instanceof RegExp || value instanceof Date;
2489
- const mergeArray = options && typeof options.mergeArray === "function" ? options.mergeArray({ clone, deepmerge: _deepmerge, getKeys, isMergeableObject }) : concatArrays;
2490
- function clone(entry) {
2491
- return isMergeableObject(entry) ? Array.isArray(entry) ? cloneArray(entry) : cloneObject(entry) : entry;
2492
- }
2493
- function mergeObject(target, source) {
2494
- const result = {};
2495
- const targetKeys = getKeys(target);
2496
- const sourceKeys = getKeys(source);
2497
- let i, il, key;
2498
- for (i = 0, il = targetKeys.length; i < il; ++i) {
2499
- isNotPrototypeKey(key = targetKeys[i]) && sourceKeys.indexOf(key) === -1 && (result[key] = clone(target[key]));
2500
- }
2501
- for (i = 0, il = sourceKeys.length; i < il; ++i) {
2502
- if (!isNotPrototypeKey(key = sourceKeys[i])) {
2503
- continue;
2504
- }
2505
- if (key in target) {
2506
- if (targetKeys.indexOf(key) !== -1) {
2507
- if (cloneProtoObject && isMergeableObject(source[key]) && Object.getPrototypeOf(source[key]) !== JSON_PROTO) {
2508
- result[key] = cloneProtoObject(source[key]);
2509
- } else {
2510
- result[key] = _deepmerge(target[key], source[key]);
2511
- }
2512
- }
2513
- } else {
2514
- result[key] = clone(source[key]);
2515
- }
2516
- }
2517
- return result;
2518
- }
2519
- function _deepmerge(target, source) {
2520
- const sourceIsArray = Array.isArray(source);
2521
- const targetIsArray = Array.isArray(target);
2522
- if (isPrimitive(source)) {
2523
- return source;
2524
- } else if (isPrimitiveOrBuiltIn(target)) {
2525
- return clone(source);
2526
- } else if (sourceIsArray && targetIsArray) {
2527
- return mergeArray(target, source);
2528
- } else if (sourceIsArray !== targetIsArray) {
2529
- return clone(source);
2530
- } else {
2531
- return mergeObject(target, source);
2532
- }
2533
- }
2534
- function _deepmergeAll() {
2535
- switch (arguments.length) {
2536
- case 0:
2537
- return {};
2538
- case 1:
2539
- return clone(arguments[0]);
2540
- case 2:
2541
- return _deepmerge(arguments[0], arguments[1]);
2542
- }
2543
- let result;
2544
- for (let i = 0, il = arguments.length; i < il; ++i) {
2545
- result = _deepmerge(result, arguments[i]);
2546
- }
2547
- return result;
2548
- }
2549
- return (options == null ? void 0 : options.all) ? _deepmergeAll : _deepmerge;
2550
- }
2551
- module.exports = deepmergeConstructor;
2552
- module.exports.default = deepmergeConstructor;
2553
- module.exports.deepmerge = deepmergeConstructor;
2554
- }
2555
- });
2556
-
2557
- // node_modules/secure-json-parse/index.js
2558
- var require_secure_json_parse = __commonJS({
2559
- "node_modules/secure-json-parse/index.js"(exports, module) {
2560
- "use strict";
2561
- var hasBuffer = typeof Buffer !== "undefined";
2562
- var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
2563
- var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
2564
- function _parse(text, reviver, options) {
2565
- if (options == null) {
2566
- if (reviver !== null && typeof reviver === "object") {
2567
- options = reviver;
2568
- reviver = void 0;
2569
- }
2570
- }
2571
- if (hasBuffer && Buffer.isBuffer(text)) {
2572
- text = text.toString();
2573
- }
2574
- if (text && text.charCodeAt(0) === 65279) {
2575
- text = text.slice(1);
2576
- }
2577
- const obj = JSON.parse(text, reviver);
2578
- if (obj === null || typeof obj !== "object") {
2579
- return obj;
2580
- }
2581
- const protoAction = options && options.protoAction || "error";
2582
- const constructorAction = options && options.constructorAction || "error";
2583
- if (protoAction === "ignore" && constructorAction === "ignore") {
2584
- return obj;
2585
- }
2586
- if (protoAction !== "ignore" && constructorAction !== "ignore") {
2587
- if (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) {
2588
- return obj;
2589
- }
2590
- } else if (protoAction !== "ignore" && constructorAction === "ignore") {
2591
- if (suspectProtoRx.test(text) === false) {
2592
- return obj;
2593
- }
2594
- } else {
2595
- if (suspectConstructorRx.test(text) === false) {
2596
- return obj;
2597
- }
2598
- }
2599
- return filter(obj, { protoAction, constructorAction, safe: options && options.safe });
2600
- }
2601
- function filter(obj, { protoAction = "error", constructorAction = "error", safe } = {}) {
2602
- let next = [obj];
2603
- while (next.length) {
2604
- const nodes = next;
2605
- next = [];
2606
- for (const node of nodes) {
2607
- if (protoAction !== "ignore" && Object.prototype.hasOwnProperty.call(node, "__proto__")) {
2608
- if (safe === true) {
2609
- return null;
2610
- } else if (protoAction === "error") {
2611
- throw new SyntaxError("Object contains forbidden prototype property");
2612
- }
2613
- delete node.__proto__;
2614
- }
2615
- if (constructorAction !== "ignore" && Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
2616
- if (safe === true) {
2617
- return null;
2618
- } else if (constructorAction === "error") {
2619
- throw new SyntaxError("Object contains forbidden prototype property");
2620
- }
2621
- delete node.constructor;
2622
- }
2623
- for (const key in node) {
2624
- const value = node[key];
2625
- if (value && typeof value === "object") {
2626
- next.push(value);
2627
- }
2628
- }
2629
- }
2630
- }
2631
- return obj;
2632
- }
2633
- function parse(text, reviver, options) {
2634
- const { stackTraceLimit } = Error;
2635
- Error.stackTraceLimit = 0;
2636
- try {
2637
- return _parse(text, reviver, options);
2638
- } finally {
2639
- Error.stackTraceLimit = stackTraceLimit;
2640
- }
2641
- }
2642
- function safeParse(text, reviver) {
2643
- const { stackTraceLimit } = Error;
2644
- Error.stackTraceLimit = 0;
2645
- try {
2646
- return _parse(text, reviver, { safe: true });
2647
- } catch (_e) {
2648
- return null;
2649
- } finally {
2650
- Error.stackTraceLimit = stackTraceLimit;
2651
- }
2652
- }
2653
- module.exports = parse;
2654
- module.exports.default = parse;
2655
- module.exports.parse = parse;
2656
- module.exports.safeParse = safeParse;
2657
- module.exports.scan = filter;
2658
- }
2659
- });
2660
-
2661
- // node_modules/@fastify/multipart/index.js
2662
- var require_multipart2 = __commonJS({
2663
- "node_modules/@fastify/multipart/index.js"(exports, module) {
2664
- var Busboy = require_main();
2665
- var os = __require("node:os");
2666
- var fp = require_plugin();
2667
- var { createWriteStream } = __require("node:fs");
2668
- var { unlink } = __require("node:fs/promises");
2669
- var path = __require("node:path");
2670
- var { generateId } = require_generateId();
2671
- var createError = require_error();
2672
- var streamToNull = require_stream_consumer();
2673
- var deepmergeAll = require_deepmerge()({ all: true });
2674
- var { PassThrough, Readable } = __require("node:stream");
2675
- var { pipeline: pump } = __require("node:stream/promises");
2676
- var secureJSON = require_secure_json_parse();
2677
- var kMultipart = Symbol("multipart");
2678
- var kMultipartHandler = Symbol("multipartHandler");
2679
- var PartsLimitError = createError("FST_PARTS_LIMIT", "reach parts limit", 413);
2680
- var FilesLimitError = createError("FST_FILES_LIMIT", "reach files limit", 413);
2681
- var FieldsLimitError = createError("FST_FIELDS_LIMIT", "reach fields limit", 413);
2682
- var RequestFileTooLargeError = createError("FST_REQ_FILE_TOO_LARGE", "request file too large", 413);
2683
- var PrototypeViolationError = createError("FST_PROTO_VIOLATION", "prototype property is not allowed as field name", 400);
2684
- var InvalidMultipartContentTypeError = createError("FST_INVALID_MULTIPART_CONTENT_TYPE", "the request is not multipart", 406);
2685
- var InvalidJSONFieldError = createError("FST_INVALID_JSON_FIELD_ERROR", "a request field is not a valid JSON as declared by its Content-Type", 406);
2686
- var FileBufferNotFoundError = createError("FST_FILE_BUFFER_NOT_FOUND", "the file buffer was not found", 500);
2687
- var NoFormData = createError("FST_NO_FORM_DATA", "FormData is not available", 500);
2688
- function setMultipart(req, _payload, done) {
2689
- req[kMultipart] = true;
2690
- done();
2691
- }
2692
- function busboy(options) {
2693
- try {
2694
- return new Busboy(options);
2695
- } catch (error) {
2696
- const errorEmitter = new PassThrough();
2697
- process.nextTick(function() {
2698
- errorEmitter.emit("error", error);
2699
- });
2700
- return errorEmitter;
2701
- }
2702
- }
2703
- function fastifyMultipart(fastify, options, done) {
2704
- var _a, _b;
2705
- options.limits = {
2706
- ...options.limits,
2707
- parts: ((_a = options.limits) == null ? void 0 : _a.parts) || 1e3,
2708
- fileSize: ((_b = options.limits) == null ? void 0 : _b.fileSize) || fastify.initialConfig.bodyLimit
2709
- };
2710
- const attachFieldsToBody = options.attachFieldsToBody;
2711
- if (attachFieldsToBody === true || attachFieldsToBody === "keyValues") {
2712
- if (typeof options.sharedSchemaId === "string" && attachFieldsToBody === true) {
2713
- fastify.addSchema({
2714
- $id: options.sharedSchemaId,
2715
- type: "object",
2716
- properties: {
2717
- fieldname: { type: "string" },
2718
- encoding: { type: "string" },
2719
- filename: { type: "string" },
2720
- mimetype: { type: "string" }
2721
- }
2722
- });
2723
- }
2724
- fastify.addHook("preValidation", async function(req) {
2725
- if (!req.isMultipart()) {
2726
- return;
2727
- }
2728
- for await (const part of req.parts()) {
2729
- req.body = part.fields;
2730
- if (part.file) {
2731
- if (options.onFile) {
2732
- await options.onFile.call(req, part);
2733
- } else {
2734
- await part.toBuffer();
2735
- }
2736
- }
2737
- }
2738
- if (attachFieldsToBody === "keyValues") {
2739
- const body = {};
2740
- if (req.body) {
2741
- const reqBodyKeys = Object.keys(req.body);
2742
- for (let i = 0; i < reqBodyKeys.length; ++i) {
2743
- const key = reqBodyKeys[i];
2744
- const field = req.body[key];
2745
- if (field.value !== void 0) {
2746
- body[key] = field.value;
2747
- } else if (field._buf) {
2748
- body[key] = field._buf;
2749
- } else if (Array.isArray(field)) {
2750
- const items = [];
2751
- for (let i2 = 0; i2 < field.length; ++i2) {
2752
- const item = field[i2];
2753
- if (item.value !== void 0) {
2754
- items.push(item.value);
2755
- } else if (item._buf) {
2756
- items.push(item._buf);
2757
- }
2758
- }
2759
- if (items.length) {
2760
- body[key] = items;
2761
- }
2762
- }
2763
- }
2764
- }
2765
- req.body = body;
2766
- }
2767
- });
2768
- if (globalThis.FormData && !fastify.hasRequestDecorator("formData")) {
2769
- fastify.decorateRequest("formData", async function() {
2770
- const formData = new FormData();
2771
- for (const key in this.body) {
2772
- const value = this.body[key];
2773
- if (Array.isArray(value)) {
2774
- for (const item of value) {
2775
- await append(key, item);
2776
- }
2777
- } else {
2778
- await append(key, value);
2779
- }
2780
- }
2781
- async function append(key, entry) {
2782
- if (entry.type === "file" || attachFieldsToBody === "keyValues" && Buffer.isBuffer(entry)) {
2783
- formData.append(key, new Blob([await entry.toBuffer()], {
2784
- type: entry.mimetype
2785
- }), entry.filename);
2786
- } else {
2787
- formData.append(key, entry.value);
2788
- }
2789
- }
2790
- return formData;
2791
- });
2792
- }
2793
- }
2794
- if (!fastify.hasRequestDecorator("formData")) {
2795
- fastify.decorateRequest("formData", async function() {
2796
- throw new NoFormData();
2797
- });
2798
- }
2799
- const defaultThrowFileSizeLimit = typeof options.throwFileSizeLimit === "boolean" ? options.throwFileSizeLimit : true;
2800
- fastify.decorate("multipartErrors", {
2801
- PartsLimitError,
2802
- FilesLimitError,
2803
- FieldsLimitError,
2804
- PrototypeViolationError,
2805
- InvalidMultipartContentTypeError,
2806
- RequestFileTooLargeError,
2807
- FileBufferNotFoundError
2808
- });
2809
- fastify.addContentTypeParser("multipart/form-data", setMultipart);
2810
- fastify.decorateRequest(kMultipart, false);
2811
- fastify.decorateRequest(kMultipartHandler, handleMultipart);
2812
- fastify.decorateRequest("parts", getMultipartIterator);
2813
- fastify.decorateRequest("isMultipart", isMultipart);
2814
- fastify.decorateRequest("tmpUploads", null);
2815
- fastify.decorateRequest("savedRequestFiles", null);
2816
- fastify.decorateRequest("file", getMultipartFile);
2817
- fastify.decorateRequest("files", getMultipartFiles);
2818
- fastify.decorateRequest("saveRequestFiles", saveRequestFiles);
2819
- fastify.decorateRequest("cleanRequestFiles", cleanRequestFiles);
2820
- fastify.addHook("onResponse", async (request) => {
2821
- await request.cleanRequestFiles();
2822
- });
2823
- function isMultipart() {
2824
- return this[kMultipart];
2825
- }
2826
- function handleMultipart(opts = {}) {
2827
- if (!this.isMultipart()) {
2828
- throw new InvalidMultipartContentTypeError();
2829
- }
2830
- this.log.debug("starting multipart parsing");
2831
- let values = [];
2832
- let pendingHandler = null;
2833
- const ch = (val) => {
2834
- if (pendingHandler) {
2835
- pendingHandler(val);
2836
- pendingHandler = null;
2837
- } else {
2838
- values.push(val);
2839
- }
2840
- };
2841
- const handle = (handler) => {
2842
- if (values.length > 0) {
2843
- const value = values[0];
2844
- values = values.slice(1);
2845
- handler(value);
2846
- } else {
2847
- pendingHandler = handler;
2848
- }
2849
- };
2850
- const parts = () => {
2851
- return new Promise((resolve, reject) => {
2852
- handle((val) => {
2853
- if (val instanceof Error) {
2854
- if (val.message === "Unexpected end of multipart data") {
2855
- resolve(null);
2856
- } else {
2857
- reject(val);
2858
- }
2859
- } else {
2860
- resolve(val);
2861
- }
2862
- });
2863
- });
2864
- };
2865
- const body = {};
2866
- let lastError = null;
2867
- let currentFile = null;
2868
- const request = this.raw;
2869
- const busboyOptions = deepmergeAll(
2870
- { headers: request.headers },
2871
- options,
2872
- opts
2873
- );
2874
- this.log.trace({ busboyOptions }, "Providing options to busboy");
2875
- const bb = busboy(busboyOptions);
2876
- request.on("close", cleanup);
2877
- request.on("error", cleanup);
2878
- bb.on("field", onField).on("file", onFile).on("end", cleanup).on("finish", cleanup).on("close", cleanup).on("error", cleanup);
2879
- bb.on("partsLimit", function() {
2880
- const err = new PartsLimitError();
2881
- onError(err);
2882
- process.nextTick(() => cleanup(err));
2883
- });
2884
- bb.on("filesLimit", function() {
2885
- const err = new FilesLimitError();
2886
- onError(err);
2887
- process.nextTick(() => cleanup(err));
2888
- });
2889
- bb.on("fieldsLimit", function() {
2890
- const err = new FieldsLimitError();
2891
- onError(err);
2892
- process.nextTick(() => cleanup(err));
2893
- });
2894
- request.pipe(bb);
2895
- function onField(name, fieldValue, fieldnameTruncated, valueTruncated, encoding, contentType) {
2896
- if (name in Object.prototype) {
2897
- onError(new PrototypeViolationError());
2898
- return;
2899
- }
2900
- if (contentType.startsWith("application/json")) {
2901
- if (valueTruncated) {
2902
- onError(new InvalidJSONFieldError());
2903
- return;
2904
- }
2905
- try {
2906
- fieldValue = secureJSON.parse(fieldValue);
2907
- contentType = "application/json";
2908
- } catch {
2909
- onError(new InvalidJSONFieldError());
2910
- return;
2911
- }
2912
- }
2913
- const value = {
2914
- type: "field",
2915
- fieldname: name,
2916
- mimetype: contentType,
2917
- encoding,
2918
- value: fieldValue,
2919
- fieldnameTruncated,
2920
- valueTruncated,
2921
- fields: body
2922
- };
2923
- if (body[name] === void 0) {
2924
- body[name] = value;
2925
- } else if (Array.isArray(body[name])) {
2926
- body[name].push(value);
2927
- } else {
2928
- body[name] = [body[name], value];
2929
- }
2930
- ch(value);
2931
- }
2932
- function onFile(name, file, filename, encoding, mimetype) {
2933
- if (name in Object.prototype) {
2934
- streamToNull(file).catch(() => {
2935
- });
2936
- onError(new PrototypeViolationError());
2937
- return;
2938
- }
2939
- const throwFileSizeLimit = typeof opts.throwFileSizeLimit === "boolean" ? opts.throwFileSizeLimit : defaultThrowFileSizeLimit;
2940
- const value = {
2941
- type: "file",
2942
- fieldname: name,
2943
- filename,
2944
- encoding,
2945
- mimetype,
2946
- file,
2947
- fields: body,
2948
- _buf: null,
2949
- async toBuffer() {
2950
- if (this._buf) {
2951
- return this._buf;
2952
- }
2953
- const fileChunks = [];
2954
- let err;
2955
- for await (const chunk of this.file) {
2956
- fileChunks.push(chunk);
2957
- if (throwFileSizeLimit && this.file.truncated) {
2958
- err = new RequestFileTooLargeError();
2959
- err.part = this;
2960
- onError(err);
2961
- fileChunks.length = 0;
2962
- }
2963
- }
2964
- if (err) {
2965
- throw err;
2966
- }
2967
- this._buf = Buffer.concat(fileChunks);
2968
- return this._buf;
2969
- }
2970
- };
2971
- if (throwFileSizeLimit) {
2972
- file.on("limit", function() {
2973
- const err = new RequestFileTooLargeError();
2974
- err.part = value;
2975
- onError(err);
2976
- });
2977
- }
2978
- if (body[name] === void 0) {
2979
- body[name] = value;
2980
- } else if (Array.isArray(body[name])) {
2981
- body[name].push(value);
2982
- } else {
2983
- body[name] = [body[name], value];
2984
- }
2985
- currentFile = file;
2986
- ch(value);
2987
- }
2988
- function onError(err) {
2989
- lastError = err;
2990
- currentFile = null;
2991
- }
2992
- function cleanup(err) {
2993
- request.unpipe(bb);
2994
- if ((err || request.aborted) && currentFile) {
2995
- currentFile.destroy();
2996
- currentFile = null;
2997
- }
2998
- ch(err || lastError || null);
2999
- }
3000
- return parts;
3001
- }
3002
- async function saveRequestFiles(options2) {
3003
- if (this.savedRequestFiles) {
3004
- return this.savedRequestFiles;
3005
- }
3006
- let files;
3007
- if (attachFieldsToBody === true) {
3008
- if (!this.body) {
3009
- return [];
3010
- }
3011
- files = filesFromFields.call(this, this.body);
3012
- } else {
3013
- files = await this.files(options2);
3014
- }
3015
- this.savedRequestFiles = [];
3016
- const tmpdir = (options2 == null ? void 0 : options2.tmpdir) || os.tmpdir();
3017
- this.tmpUploads = [];
3018
- let i = 0;
3019
- for await (const file of files) {
3020
- const filepath = path.join(tmpdir, generateId() + path.extname(file.filename || "file" + i++));
3021
- const target = createWriteStream(filepath);
3022
- try {
3023
- this.tmpUploads.push(filepath);
3024
- await pump(file.file, target);
3025
- this.savedRequestFiles.push({ ...file, filepath });
3026
- } catch (err) {
3027
- this.log.error({ err }, "save request file");
3028
- throw err;
3029
- }
3030
- }
3031
- return this.savedRequestFiles;
3032
- }
3033
- function* filesFromFields(container) {
3034
- try {
3035
- const fields = Array.isArray(container) ? container : Object.values(container);
3036
- for (let i = 0; i < fields.length; ++i) {
3037
- const field = fields[i];
3038
- if (Array.isArray(field)) {
3039
- for (const subField of filesFromFields.call(this, field)) {
3040
- yield subField;
3041
- }
3042
- }
3043
- if (!field.file) {
3044
- continue;
3045
- }
3046
- if (!field._buf) {
3047
- throw new FileBufferNotFoundError();
3048
- }
3049
- field.file = Readable.from(field._buf);
3050
- yield field;
3051
- }
3052
- } catch (err) {
3053
- this.log.error({ err }, "save request file failed");
3054
- throw err;
3055
- }
3056
- }
3057
- async function cleanRequestFiles() {
3058
- if (!this.tmpUploads) {
3059
- return;
3060
- }
3061
- for (let i = 0; i < this.tmpUploads.length; ++i) {
3062
- const filepath = this.tmpUploads[i];
3063
- try {
3064
- await unlink(filepath);
3065
- } catch (error) {
3066
- this.log.error(error, "Could not delete file");
3067
- }
3068
- }
3069
- }
3070
- async function getMultipartFile(options2) {
3071
- const parts = this[kMultipartHandler](options2);
3072
- let part;
3073
- while ((part = await parts()) != null) {
3074
- if (part.file) {
3075
- return part;
3076
- }
3077
- }
3078
- }
3079
- async function* getMultipartFiles(options2) {
3080
- const parts = this[kMultipartHandler](options2);
3081
- let part;
3082
- while ((part = await parts()) != null) {
3083
- if (part.file) {
3084
- yield part;
3085
- }
3086
- }
3087
- }
3088
- async function* getMultipartIterator(options2) {
3089
- const parts = this[kMultipartHandler](options2);
3090
- let part;
3091
- while ((part = await parts()) != null) {
3092
- yield part;
3093
- }
3094
- }
3095
- done();
3096
- }
3097
- function ajvFilePlugin(ajv) {
3098
- return ajv.addKeyword({
3099
- keyword: "isFile",
3100
- compile: (_schema, parent) => {
3101
- parent.type = "string";
3102
- parent.format = "binary";
3103
- delete parent.isFile;
3104
- return (field) => !!field.file;
3105
- },
3106
- error: {
3107
- message: "should be a file"
3108
- }
3109
- });
3110
- }
3111
- module.exports = fp(fastifyMultipart, {
3112
- fastify: "5.x",
3113
- name: "@fastify/multipart"
3114
- });
3115
- module.exports.default = fastifyMultipart;
3116
- module.exports.fastifyMultipart = fastifyMultipart;
3117
- module.exports.ajvFilePlugin = ajvFilePlugin;
3118
- }
3119
- });
3120
- export default require_multipart2();