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