@kanbodev/mcp 1.1.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +323 -323
- package/dist/index.js +1795 -1012
- package/docs/GIT_CONVENTIONS.md +139 -139
- package/docs/SETUP.md +254 -254
- package/docs/VSCODE.md +211 -211
- package/package.json +47 -47
package/dist/index.js
CHANGED
|
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
8
13
|
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
9
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
22
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
23
|
for (let key of __getOwnPropNames(mod))
|
|
12
24
|
if (!__hasOwnProp.call(to, key))
|
|
13
25
|
__defProp(to, key, {
|
|
14
|
-
get: (
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
15
27
|
enumerable: true
|
|
16
28
|
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
17
31
|
return to;
|
|
18
32
|
};
|
|
19
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __returnValue = (v) => v;
|
|
35
|
+
function __exportSetter(name, newValue) {
|
|
36
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
37
|
+
}
|
|
20
38
|
var __export = (target, all) => {
|
|
21
39
|
for (var name in all)
|
|
22
40
|
__defProp(target, name, {
|
|
23
41
|
get: all[name],
|
|
24
42
|
enumerable: true,
|
|
25
43
|
configurable: true,
|
|
26
|
-
set: (
|
|
44
|
+
set: __exportSetter.bind(all, name)
|
|
27
45
|
});
|
|
28
46
|
};
|
|
29
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -227,7 +245,7 @@ var init_constants = __esm(() => {
|
|
|
227
245
|
};
|
|
228
246
|
SERVER_INFO = {
|
|
229
247
|
name: "kanbo-mcp",
|
|
230
|
-
version: "1.
|
|
248
|
+
version: "1.2.0",
|
|
231
249
|
description: "MCP server for Kanbo project management"
|
|
232
250
|
};
|
|
233
251
|
PAT_CONFIG = {
|
|
@@ -4812,6 +4830,7 @@ var require_limitLength = __commonJS((exports) => {
|
|
|
4812
4830
|
var require_pattern = __commonJS((exports) => {
|
|
4813
4831
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4814
4832
|
var code_1 = require_code2();
|
|
4833
|
+
var util_1 = require_util();
|
|
4815
4834
|
var codegen_1 = require_codegen();
|
|
4816
4835
|
var error2 = {
|
|
4817
4836
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4824,10 +4843,18 @@ var require_pattern = __commonJS((exports) => {
|
|
|
4824
4843
|
$data: true,
|
|
4825
4844
|
error: error2,
|
|
4826
4845
|
code(cxt) {
|
|
4827
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4846
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4828
4847
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4829
|
-
|
|
4830
|
-
|
|
4848
|
+
if ($data) {
|
|
4849
|
+
const { regExp } = it.opts.code;
|
|
4850
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4851
|
+
const valid = gen.let("valid");
|
|
4852
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4853
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4854
|
+
} else {
|
|
4855
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4856
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4857
|
+
}
|
|
4831
4858
|
}
|
|
4832
4859
|
};
|
|
4833
4860
|
exports.default = def;
|
|
@@ -6520,7 +6547,7 @@ var require_formats = __commonJS((exports) => {
|
|
|
6520
6547
|
}
|
|
6521
6548
|
var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
6522
6549
|
function getTime(strictTimeZone) {
|
|
6523
|
-
return function
|
|
6550
|
+
return function time3(str) {
|
|
6524
6551
|
const matches = TIME.exec(str);
|
|
6525
6552
|
if (!matches)
|
|
6526
6553
|
return false;
|
|
@@ -7999,8 +8026,18 @@ var require_sonic_boom = __commonJS((exports, module) => {
|
|
|
7999
8026
|
this.flush = flush;
|
|
8000
8027
|
this.flushSync = flushSync;
|
|
8001
8028
|
this._actualWrite = actualWrite;
|
|
8002
|
-
fsWriteSync = () =>
|
|
8003
|
-
|
|
8029
|
+
fsWriteSync = () => {
|
|
8030
|
+
if (Buffer.isBuffer(this._writingBuf)) {
|
|
8031
|
+
return fs2.writeSync(this.fd, this._writingBuf);
|
|
8032
|
+
}
|
|
8033
|
+
return fs2.writeSync(this.fd, this._writingBuf, "utf8");
|
|
8034
|
+
};
|
|
8035
|
+
fsWrite = () => {
|
|
8036
|
+
if (Buffer.isBuffer(this._writingBuf)) {
|
|
8037
|
+
return fs2.write(this.fd, this._writingBuf, this.release);
|
|
8038
|
+
}
|
|
8039
|
+
return fs2.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
8040
|
+
};
|
|
8004
8041
|
} else {
|
|
8005
8042
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
8006
8043
|
}
|
|
@@ -8095,11 +8132,11 @@ var require_sonic_boom = __commonJS((exports, module) => {
|
|
|
8095
8132
|
}
|
|
8096
8133
|
}
|
|
8097
8134
|
function releaseWritingBuf(writingBuf, len, n) {
|
|
8098
|
-
if (typeof writingBuf === "string"
|
|
8099
|
-
|
|
8135
|
+
if (typeof writingBuf === "string") {
|
|
8136
|
+
writingBuf = Buffer.from(writingBuf);
|
|
8100
8137
|
}
|
|
8101
8138
|
len = Math.max(len - n, 0);
|
|
8102
|
-
writingBuf = writingBuf.
|
|
8139
|
+
writingBuf = writingBuf.subarray(n);
|
|
8103
8140
|
return { writingBuf, len };
|
|
8104
8141
|
}
|
|
8105
8142
|
function emitDrain(sonic) {
|
|
@@ -8123,14 +8160,16 @@ var require_sonic_boom = __commonJS((exports, module) => {
|
|
|
8123
8160
|
if (this.destroyed) {
|
|
8124
8161
|
throw new Error("SonicBoom destroyed");
|
|
8125
8162
|
}
|
|
8126
|
-
|
|
8163
|
+
data = "" + data;
|
|
8164
|
+
const dataLen = Buffer.byteLength(data);
|
|
8165
|
+
const len = this._len + dataLen;
|
|
8127
8166
|
const bufs = this._bufs;
|
|
8128
8167
|
if (this.maxLength && len > this.maxLength) {
|
|
8129
8168
|
this.emit("drop", data);
|
|
8130
8169
|
return this._len < this._hwm;
|
|
8131
8170
|
}
|
|
8132
|
-
if (bufs.length === 0 || bufs[bufs.length - 1]
|
|
8133
|
-
bufs.push(
|
|
8171
|
+
if (bufs.length === 0 || Buffer.byteLength(bufs[bufs.length - 1]) + dataLen > this.maxWrite) {
|
|
8172
|
+
bufs.push(data);
|
|
8134
8173
|
} else {
|
|
8135
8174
|
bufs[bufs.length - 1] += data;
|
|
8136
8175
|
}
|
|
@@ -8315,12 +8354,12 @@ var require_sonic_boom = __commonJS((exports, module) => {
|
|
|
8315
8354
|
this._writingBuf = "";
|
|
8316
8355
|
}
|
|
8317
8356
|
let buf = "";
|
|
8318
|
-
while (this._bufs.length || buf) {
|
|
8357
|
+
while (this._bufs.length || buf.length) {
|
|
8319
8358
|
if (buf.length <= 0) {
|
|
8320
8359
|
buf = this._bufs[0];
|
|
8321
8360
|
}
|
|
8322
8361
|
try {
|
|
8323
|
-
const n = fs2.writeSync(this.fd, buf, "utf8");
|
|
8362
|
+
const n = Buffer.isBuffer(buf) ? fs2.writeSync(this.fd, buf) : fs2.writeSync(this.fd, buf, "utf8");
|
|
8324
8363
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
8325
8364
|
buf = releasedBufObj.writingBuf;
|
|
8326
8365
|
this._len = releasedBufObj.len;
|
|
@@ -8381,16 +8420,16 @@ var require_sonic_boom = __commonJS((exports, module) => {
|
|
|
8381
8420
|
function actualWrite() {
|
|
8382
8421
|
const release = this.release;
|
|
8383
8422
|
this._writing = true;
|
|
8384
|
-
this._writingBuf = this._writingBuf
|
|
8423
|
+
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
8385
8424
|
if (this.sync) {
|
|
8386
8425
|
try {
|
|
8387
|
-
const written = fs2.writeSync(this.fd, this._writingBuf, "utf8");
|
|
8426
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs2.writeSync(this.fd, this._writingBuf) : fs2.writeSync(this.fd, this._writingBuf, "utf8");
|
|
8388
8427
|
release(null, written);
|
|
8389
8428
|
} catch (err) {
|
|
8390
8429
|
release(err);
|
|
8391
8430
|
}
|
|
8392
8431
|
} else {
|
|
8393
|
-
fs2.write(this.fd, this._writingBuf,
|
|
8432
|
+
fs2.write(this.fd, this._writingBuf, release);
|
|
8394
8433
|
}
|
|
8395
8434
|
}
|
|
8396
8435
|
function actualWriteBuffer() {
|
|
@@ -8658,7 +8697,7 @@ var require_indexes = __commonJS((exports, module) => {
|
|
|
8658
8697
|
|
|
8659
8698
|
// node_modules/thread-stream/index.js
|
|
8660
8699
|
var require_thread_stream = __commonJS((exports, module) => {
|
|
8661
|
-
var __dirname = "
|
|
8700
|
+
var __dirname = "C:\\Users\\cloudpg07\\0dev\\kanbo-mcp\\node_modules\\thread-stream";
|
|
8662
8701
|
var { version: version2 } = require_package();
|
|
8663
8702
|
var { EventEmitter } = __require("events");
|
|
8664
8703
|
var { Worker } = __require("worker_threads");
|
|
@@ -9083,10 +9122,12 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
9083
9122
|
|
|
9084
9123
|
// node_modules/pino/lib/transport.js
|
|
9085
9124
|
var require_transport = __commonJS((exports, module) => {
|
|
9086
|
-
var __dirname = "
|
|
9125
|
+
var __dirname = "C:\\Users\\cloudpg07\\0dev\\kanbo-mcp\\node_modules\\pino\\lib";
|
|
9087
9126
|
var { createRequire: createRequire2 } = __require("module");
|
|
9127
|
+
var { existsSync: existsSync2 } = __require("node:fs");
|
|
9088
9128
|
var getCallers = require_caller();
|
|
9089
9129
|
var { join: join2, isAbsolute, sep } = __require("node:path");
|
|
9130
|
+
var { fileURLToPath } = __require("node:url");
|
|
9090
9131
|
var sleep = require_atomic_sleep();
|
|
9091
9132
|
var onExit = require_on_exit_leak_free();
|
|
9092
9133
|
var ThreadStream = require_thread_stream();
|
|
@@ -9110,6 +9151,63 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
9110
9151
|
}
|
|
9111
9152
|
return false;
|
|
9112
9153
|
}
|
|
9154
|
+
function sanitizeNodeOptions(nodeOptions) {
|
|
9155
|
+
const tokens = nodeOptions.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);
|
|
9156
|
+
if (!tokens) {
|
|
9157
|
+
return nodeOptions;
|
|
9158
|
+
}
|
|
9159
|
+
const sanitized = [];
|
|
9160
|
+
let changed = false;
|
|
9161
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
9162
|
+
const token = tokens[i];
|
|
9163
|
+
if (token === "--require" || token === "-r" || token === "--import") {
|
|
9164
|
+
const next = tokens[i + 1];
|
|
9165
|
+
if (next && shouldDropPreload(next)) {
|
|
9166
|
+
changed = true;
|
|
9167
|
+
i++;
|
|
9168
|
+
continue;
|
|
9169
|
+
}
|
|
9170
|
+
sanitized.push(token);
|
|
9171
|
+
if (next) {
|
|
9172
|
+
sanitized.push(next);
|
|
9173
|
+
i++;
|
|
9174
|
+
}
|
|
9175
|
+
continue;
|
|
9176
|
+
}
|
|
9177
|
+
if (token.startsWith("--require=") || token.startsWith("-r=") || token.startsWith("--import=")) {
|
|
9178
|
+
const value = token.slice(token.indexOf("=") + 1);
|
|
9179
|
+
if (shouldDropPreload(value)) {
|
|
9180
|
+
changed = true;
|
|
9181
|
+
continue;
|
|
9182
|
+
}
|
|
9183
|
+
}
|
|
9184
|
+
sanitized.push(token);
|
|
9185
|
+
}
|
|
9186
|
+
return changed ? sanitized.join(" ") : nodeOptions;
|
|
9187
|
+
}
|
|
9188
|
+
function shouldDropPreload(value) {
|
|
9189
|
+
const unquoted = stripQuotes(value);
|
|
9190
|
+
if (!unquoted) {
|
|
9191
|
+
return false;
|
|
9192
|
+
}
|
|
9193
|
+
let path2 = unquoted;
|
|
9194
|
+
if (path2.startsWith("file://")) {
|
|
9195
|
+
try {
|
|
9196
|
+
path2 = fileURLToPath(path2);
|
|
9197
|
+
} catch {
|
|
9198
|
+
return false;
|
|
9199
|
+
}
|
|
9200
|
+
}
|
|
9201
|
+
return isAbsolute(path2) && !existsSync2(path2);
|
|
9202
|
+
}
|
|
9203
|
+
function stripQuotes(value) {
|
|
9204
|
+
const first = value[0];
|
|
9205
|
+
const last = value[value.length - 1];
|
|
9206
|
+
if (first === '"' && last === '"' || first === "'" && last === "'") {
|
|
9207
|
+
return value.slice(1, -1);
|
|
9208
|
+
}
|
|
9209
|
+
return value;
|
|
9210
|
+
}
|
|
9113
9211
|
function buildStream(filename, workerData, workerOpts, sync, name) {
|
|
9114
9212
|
if (!workerOpts.execArgv && hasPreloadFlags() && __require.main === undefined) {
|
|
9115
9213
|
workerOpts = {
|
|
@@ -9117,6 +9215,18 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
9117
9215
|
execArgv: []
|
|
9118
9216
|
};
|
|
9119
9217
|
}
|
|
9218
|
+
if (!workerOpts.env && process.env.NODE_OPTIONS) {
|
|
9219
|
+
const nodeOptions = sanitizeNodeOptions(process.env.NODE_OPTIONS);
|
|
9220
|
+
if (nodeOptions !== process.env.NODE_OPTIONS) {
|
|
9221
|
+
workerOpts = {
|
|
9222
|
+
...workerOpts,
|
|
9223
|
+
env: {
|
|
9224
|
+
...process.env,
|
|
9225
|
+
NODE_OPTIONS: nodeOptions
|
|
9226
|
+
}
|
|
9227
|
+
};
|
|
9228
|
+
}
|
|
9229
|
+
}
|
|
9120
9230
|
workerOpts = { ...workerOpts, name };
|
|
9121
9231
|
const stream = new ThreadStream({
|
|
9122
9232
|
filename,
|
|
@@ -9750,7 +9860,7 @@ var require_levels = __commonJS((exports, module) => {
|
|
|
9750
9860
|
|
|
9751
9861
|
// node_modules/pino/lib/meta.js
|
|
9752
9862
|
var require_meta = __commonJS((exports, module) => {
|
|
9753
|
-
module.exports = { version: "10.3.
|
|
9863
|
+
module.exports = { version: "10.3.1" };
|
|
9754
9864
|
});
|
|
9755
9865
|
|
|
9756
9866
|
// node_modules/pino/lib/proto.js
|
|
@@ -12041,52 +12151,135 @@ function textDecode(bytes, encoding = "utf-8") {
|
|
|
12041
12151
|
throw new RangeError(`Encoding '${encoding}' not supported`);
|
|
12042
12152
|
}
|
|
12043
12153
|
}
|
|
12154
|
+
function flushChunk(parts, chunk) {
|
|
12155
|
+
if (chunk.length === 0)
|
|
12156
|
+
return;
|
|
12157
|
+
parts.push(String.fromCharCode.apply(null, chunk));
|
|
12158
|
+
chunk.length = 0;
|
|
12159
|
+
}
|
|
12160
|
+
function pushCodeUnit(parts, chunk, codeUnit) {
|
|
12161
|
+
chunk.push(codeUnit);
|
|
12162
|
+
if (chunk.length >= CHUNK)
|
|
12163
|
+
flushChunk(parts, chunk);
|
|
12164
|
+
}
|
|
12165
|
+
function pushCodePoint(parts, chunk, cp) {
|
|
12166
|
+
if (cp <= 65535) {
|
|
12167
|
+
pushCodeUnit(parts, chunk, cp);
|
|
12168
|
+
return;
|
|
12169
|
+
}
|
|
12170
|
+
cp -= 65536;
|
|
12171
|
+
pushCodeUnit(parts, chunk, 55296 + (cp >> 10));
|
|
12172
|
+
pushCodeUnit(parts, chunk, 56320 + (cp & 1023));
|
|
12173
|
+
}
|
|
12044
12174
|
function decodeUTF8(bytes) {
|
|
12045
12175
|
const parts = [];
|
|
12046
|
-
|
|
12176
|
+
const chunk = [];
|
|
12047
12177
|
let i = 0;
|
|
12178
|
+
if (bytes.length >= 3 && bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) {
|
|
12179
|
+
i = 3;
|
|
12180
|
+
}
|
|
12048
12181
|
while (i < bytes.length) {
|
|
12049
|
-
const b1 = bytes[i
|
|
12050
|
-
if (b1
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
out += String.fromCharCode((b1 & 31) << 6 | b2);
|
|
12055
|
-
} else if (b1 < 240) {
|
|
12056
|
-
const b2 = bytes[i++] & 63;
|
|
12057
|
-
const b3 = bytes[i++] & 63;
|
|
12058
|
-
out += String.fromCharCode((b1 & 15) << 12 | b2 << 6 | b3);
|
|
12059
|
-
} else {
|
|
12060
|
-
const b2 = bytes[i++] & 63;
|
|
12061
|
-
const b3 = bytes[i++] & 63;
|
|
12062
|
-
const b4 = bytes[i++] & 63;
|
|
12063
|
-
let cp = (b1 & 7) << 18 | b2 << 12 | b3 << 6 | b4;
|
|
12064
|
-
cp -= 65536;
|
|
12065
|
-
out += String.fromCharCode(55296 + (cp >> 10 & 1023), 56320 + (cp & 1023));
|
|
12182
|
+
const b1 = bytes[i];
|
|
12183
|
+
if (b1 <= 127) {
|
|
12184
|
+
pushCodeUnit(parts, chunk, b1);
|
|
12185
|
+
i++;
|
|
12186
|
+
continue;
|
|
12066
12187
|
}
|
|
12067
|
-
if (
|
|
12068
|
-
parts
|
|
12069
|
-
|
|
12188
|
+
if (b1 < 194 || b1 > 244) {
|
|
12189
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12190
|
+
i++;
|
|
12191
|
+
continue;
|
|
12192
|
+
}
|
|
12193
|
+
if (b1 <= 223) {
|
|
12194
|
+
if (i + 1 >= bytes.length) {
|
|
12195
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12196
|
+
i++;
|
|
12197
|
+
continue;
|
|
12198
|
+
}
|
|
12199
|
+
const b22 = bytes[i + 1];
|
|
12200
|
+
if ((b22 & 192) !== 128) {
|
|
12201
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12202
|
+
i++;
|
|
12203
|
+
continue;
|
|
12204
|
+
}
|
|
12205
|
+
const cp2 = (b1 & 31) << 6 | b22 & 63;
|
|
12206
|
+
pushCodeUnit(parts, chunk, cp2);
|
|
12207
|
+
i += 2;
|
|
12208
|
+
continue;
|
|
12209
|
+
}
|
|
12210
|
+
if (b1 <= 239) {
|
|
12211
|
+
if (i + 2 >= bytes.length) {
|
|
12212
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12213
|
+
i++;
|
|
12214
|
+
continue;
|
|
12215
|
+
}
|
|
12216
|
+
const b22 = bytes[i + 1];
|
|
12217
|
+
const b32 = bytes[i + 2];
|
|
12218
|
+
const valid2 = (b22 & 192) === 128 && (b32 & 192) === 128 && !(b1 === 224 && b22 < 160) && !(b1 === 237 && b22 >= 160);
|
|
12219
|
+
if (!valid2) {
|
|
12220
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12221
|
+
i++;
|
|
12222
|
+
continue;
|
|
12223
|
+
}
|
|
12224
|
+
const cp2 = (b1 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
|
|
12225
|
+
pushCodeUnit(parts, chunk, cp2);
|
|
12226
|
+
i += 3;
|
|
12227
|
+
continue;
|
|
12228
|
+
}
|
|
12229
|
+
if (i + 3 >= bytes.length) {
|
|
12230
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12231
|
+
i++;
|
|
12232
|
+
continue;
|
|
12233
|
+
}
|
|
12234
|
+
const b2 = bytes[i + 1];
|
|
12235
|
+
const b3 = bytes[i + 2];
|
|
12236
|
+
const b4 = bytes[i + 3];
|
|
12237
|
+
const valid = (b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128 && !(b1 === 240 && b2 < 144) && !(b1 === 244 && b2 > 143);
|
|
12238
|
+
if (!valid) {
|
|
12239
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12240
|
+
i++;
|
|
12241
|
+
continue;
|
|
12070
12242
|
}
|
|
12243
|
+
const cp = (b1 & 7) << 18 | (b2 & 63) << 12 | (b3 & 63) << 6 | b4 & 63;
|
|
12244
|
+
pushCodePoint(parts, chunk, cp);
|
|
12245
|
+
i += 4;
|
|
12071
12246
|
}
|
|
12072
|
-
|
|
12073
|
-
parts.push(out);
|
|
12247
|
+
flushChunk(parts, chunk);
|
|
12074
12248
|
return parts.join("");
|
|
12075
12249
|
}
|
|
12076
12250
|
function decodeUTF16LE(bytes) {
|
|
12077
|
-
const len = bytes.length & ~1;
|
|
12078
|
-
if (len === 0)
|
|
12079
|
-
return "";
|
|
12080
12251
|
const parts = [];
|
|
12081
|
-
const
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12252
|
+
const chunk = [];
|
|
12253
|
+
const len = bytes.length;
|
|
12254
|
+
let i = 0;
|
|
12255
|
+
while (i + 1 < len) {
|
|
12256
|
+
const u1 = bytes[i] | bytes[i + 1] << 8;
|
|
12257
|
+
i += 2;
|
|
12258
|
+
if (u1 >= 55296 && u1 <= 56319) {
|
|
12259
|
+
if (i + 1 < len) {
|
|
12260
|
+
const u2 = bytes[i] | bytes[i + 1] << 8;
|
|
12261
|
+
if (u2 >= 56320 && u2 <= 57343) {
|
|
12262
|
+
pushCodeUnit(parts, chunk, u1);
|
|
12263
|
+
pushCodeUnit(parts, chunk, u2);
|
|
12264
|
+
i += 2;
|
|
12265
|
+
} else {
|
|
12266
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12267
|
+
}
|
|
12268
|
+
} else {
|
|
12269
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12270
|
+
}
|
|
12271
|
+
continue;
|
|
12272
|
+
}
|
|
12273
|
+
if (u1 >= 56320 && u1 <= 57343) {
|
|
12274
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12275
|
+
continue;
|
|
12087
12276
|
}
|
|
12088
|
-
parts
|
|
12277
|
+
pushCodeUnit(parts, chunk, u1);
|
|
12278
|
+
}
|
|
12279
|
+
if (i < len) {
|
|
12280
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
12089
12281
|
}
|
|
12282
|
+
flushChunk(parts, chunk);
|
|
12090
12283
|
return parts.join("");
|
|
12091
12284
|
}
|
|
12092
12285
|
function decodeASCII(bytes) {
|
|
@@ -12129,7 +12322,7 @@ function decodeWindows1252(bytes) {
|
|
|
12129
12322
|
parts.push(out);
|
|
12130
12323
|
return parts.join("");
|
|
12131
12324
|
}
|
|
12132
|
-
var WINDOWS_1252_EXTRA, WINDOWS_1252_REVERSE, _utf8Decoder, CHUNK;
|
|
12325
|
+
var WINDOWS_1252_EXTRA, WINDOWS_1252_REVERSE, _utf8Decoder, CHUNK, REPLACEMENT = 65533;
|
|
12133
12326
|
var init_lib2 = __esm(() => {
|
|
12134
12327
|
WINDOWS_1252_EXTRA = {
|
|
12135
12328
|
128: "€",
|
|
@@ -13637,6 +13830,100 @@ var init_supported = __esm(() => {
|
|
|
13637
13830
|
});
|
|
13638
13831
|
|
|
13639
13832
|
// node_modules/file-type/core.js
|
|
13833
|
+
function getSafeBound(value, maximum, reason) {
|
|
13834
|
+
if (!Number.isFinite(value) || value < 0 || value > maximum) {
|
|
13835
|
+
throw new ParserHardLimitError(`${reason} has invalid size ${value} (maximum ${maximum} bytes)`);
|
|
13836
|
+
}
|
|
13837
|
+
return value;
|
|
13838
|
+
}
|
|
13839
|
+
async function safeIgnore(tokenizer, length, { maximumLength = maximumUntrustedSkipSizeInBytes, reason = "skip" } = {}) {
|
|
13840
|
+
const safeLength = getSafeBound(length, maximumLength, reason);
|
|
13841
|
+
await tokenizer.ignore(safeLength);
|
|
13842
|
+
}
|
|
13843
|
+
async function safeReadBuffer(tokenizer, buffer, options, { maximumLength = buffer.length, reason = "read" } = {}) {
|
|
13844
|
+
const length = options?.length ?? buffer.length;
|
|
13845
|
+
const safeLength = getSafeBound(length, maximumLength, reason);
|
|
13846
|
+
return tokenizer.readBuffer(buffer, {
|
|
13847
|
+
...options,
|
|
13848
|
+
length: safeLength
|
|
13849
|
+
});
|
|
13850
|
+
}
|
|
13851
|
+
async function decompressDeflateRawWithLimit(data, { maximumLength = maximumZipEntrySizeInBytes } = {}) {
|
|
13852
|
+
const input = new ReadableStream({
|
|
13853
|
+
start(controller) {
|
|
13854
|
+
controller.enqueue(data);
|
|
13855
|
+
controller.close();
|
|
13856
|
+
}
|
|
13857
|
+
});
|
|
13858
|
+
const output = input.pipeThrough(new DecompressionStream("deflate-raw"));
|
|
13859
|
+
const reader = output.getReader();
|
|
13860
|
+
const chunks = [];
|
|
13861
|
+
let totalLength = 0;
|
|
13862
|
+
try {
|
|
13863
|
+
for (;; ) {
|
|
13864
|
+
const { done, value } = await reader.read();
|
|
13865
|
+
if (done) {
|
|
13866
|
+
break;
|
|
13867
|
+
}
|
|
13868
|
+
totalLength += value.length;
|
|
13869
|
+
if (totalLength > maximumLength) {
|
|
13870
|
+
await reader.cancel();
|
|
13871
|
+
throw new Error(`ZIP entry decompressed data exceeds ${maximumLength} bytes`);
|
|
13872
|
+
}
|
|
13873
|
+
chunks.push(value);
|
|
13874
|
+
}
|
|
13875
|
+
} finally {
|
|
13876
|
+
reader.releaseLock();
|
|
13877
|
+
}
|
|
13878
|
+
const uncompressedData = new Uint8Array(totalLength);
|
|
13879
|
+
let offset = 0;
|
|
13880
|
+
for (const chunk of chunks) {
|
|
13881
|
+
uncompressedData.set(chunk, offset);
|
|
13882
|
+
offset += chunk.length;
|
|
13883
|
+
}
|
|
13884
|
+
return uncompressedData;
|
|
13885
|
+
}
|
|
13886
|
+
function createByteLimitedReadableStream(stream, maximumBytes) {
|
|
13887
|
+
const reader = stream.getReader();
|
|
13888
|
+
let emittedBytes = 0;
|
|
13889
|
+
let sourceDone = false;
|
|
13890
|
+
let sourceCanceled = false;
|
|
13891
|
+
const cancelSource = async (reason) => {
|
|
13892
|
+
if (sourceDone || sourceCanceled) {
|
|
13893
|
+
return;
|
|
13894
|
+
}
|
|
13895
|
+
sourceCanceled = true;
|
|
13896
|
+
await reader.cancel(reason);
|
|
13897
|
+
};
|
|
13898
|
+
return new ReadableStream({
|
|
13899
|
+
async pull(controller) {
|
|
13900
|
+
if (emittedBytes >= maximumBytes) {
|
|
13901
|
+
controller.close();
|
|
13902
|
+
await cancelSource();
|
|
13903
|
+
return;
|
|
13904
|
+
}
|
|
13905
|
+
const { done, value } = await reader.read();
|
|
13906
|
+
if (done || !value) {
|
|
13907
|
+
sourceDone = true;
|
|
13908
|
+
controller.close();
|
|
13909
|
+
return;
|
|
13910
|
+
}
|
|
13911
|
+
const remainingBytes = maximumBytes - emittedBytes;
|
|
13912
|
+
if (value.length > remainingBytes) {
|
|
13913
|
+
controller.enqueue(value.subarray(0, remainingBytes));
|
|
13914
|
+
emittedBytes += remainingBytes;
|
|
13915
|
+
controller.close();
|
|
13916
|
+
await cancelSource();
|
|
13917
|
+
return;
|
|
13918
|
+
}
|
|
13919
|
+
controller.enqueue(value);
|
|
13920
|
+
emittedBytes += value.length;
|
|
13921
|
+
},
|
|
13922
|
+
async cancel(reason) {
|
|
13923
|
+
await cancelSource(reason);
|
|
13924
|
+
}
|
|
13925
|
+
});
|
|
13926
|
+
}
|
|
13640
13927
|
async function fileTypeFromBuffer(input, options) {
|
|
13641
13928
|
return new FileTypeParser(options).fromBuffer(input);
|
|
13642
13929
|
}
|
|
@@ -13790,29 +14077,166 @@ function _check2(buffer, headers, options) {
|
|
|
13790
14077
|
}
|
|
13791
14078
|
return true;
|
|
13792
14079
|
}
|
|
14080
|
+
function normalizeSampleSize(sampleSize) {
|
|
14081
|
+
if (!Number.isFinite(sampleSize)) {
|
|
14082
|
+
return reasonableDetectionSizeInBytes;
|
|
14083
|
+
}
|
|
14084
|
+
return Math.max(1, Math.trunc(sampleSize));
|
|
14085
|
+
}
|
|
14086
|
+
function normalizeMpegOffsetTolerance(mpegOffsetTolerance) {
|
|
14087
|
+
if (!Number.isFinite(mpegOffsetTolerance)) {
|
|
14088
|
+
return 0;
|
|
14089
|
+
}
|
|
14090
|
+
return Math.max(0, Math.min(maximumMpegOffsetTolerance, Math.trunc(mpegOffsetTolerance)));
|
|
14091
|
+
}
|
|
14092
|
+
function getKnownFileSizeOrMaximum(fileSize) {
|
|
14093
|
+
if (!Number.isFinite(fileSize)) {
|
|
14094
|
+
return Number.MAX_SAFE_INTEGER;
|
|
14095
|
+
}
|
|
14096
|
+
return Math.max(0, fileSize);
|
|
14097
|
+
}
|
|
14098
|
+
function hasUnknownFileSize(tokenizer) {
|
|
14099
|
+
const fileSize = tokenizer.fileInfo.size;
|
|
14100
|
+
return !Number.isFinite(fileSize) || fileSize === Number.MAX_SAFE_INTEGER;
|
|
14101
|
+
}
|
|
14102
|
+
function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes) {
|
|
14103
|
+
return hasUnknownFileSize(tokenizer) && tokenizer.position - startOffset > maximumBytes;
|
|
14104
|
+
}
|
|
14105
|
+
function isRecoverableZipError(error2) {
|
|
14106
|
+
if (error2 instanceof EndOfStreamError) {
|
|
14107
|
+
return true;
|
|
14108
|
+
}
|
|
14109
|
+
if (error2 instanceof ParserHardLimitError) {
|
|
14110
|
+
return true;
|
|
14111
|
+
}
|
|
14112
|
+
if (!(error2 instanceof Error)) {
|
|
14113
|
+
return false;
|
|
14114
|
+
}
|
|
14115
|
+
if (recoverableZipErrorMessages.has(error2.message)) {
|
|
14116
|
+
return true;
|
|
14117
|
+
}
|
|
14118
|
+
if (error2 instanceof TypeError && recoverableZipErrorCodes.has(error2.code)) {
|
|
14119
|
+
return true;
|
|
14120
|
+
}
|
|
14121
|
+
for (const prefix of recoverableZipErrorMessagePrefixes) {
|
|
14122
|
+
if (error2.message.startsWith(prefix)) {
|
|
14123
|
+
return true;
|
|
14124
|
+
}
|
|
14125
|
+
}
|
|
14126
|
+
return false;
|
|
14127
|
+
}
|
|
14128
|
+
function canReadZipEntryForDetection(zipHeader, maximumSize = maximumZipEntrySizeInBytes) {
|
|
14129
|
+
const sizes = [zipHeader.compressedSize, zipHeader.uncompressedSize];
|
|
14130
|
+
for (const size of sizes) {
|
|
14131
|
+
if (!Number.isFinite(size) || size < 0 || size > maximumSize) {
|
|
14132
|
+
return false;
|
|
14133
|
+
}
|
|
14134
|
+
}
|
|
14135
|
+
return true;
|
|
14136
|
+
}
|
|
14137
|
+
function createOpenXmlZipDetectionState() {
|
|
14138
|
+
return {
|
|
14139
|
+
hasContentTypesEntry: false,
|
|
14140
|
+
hasParsedContentTypesEntry: false,
|
|
14141
|
+
isParsingContentTypes: false,
|
|
14142
|
+
hasUnparseableContentTypes: false,
|
|
14143
|
+
hasWordDirectory: false,
|
|
14144
|
+
hasPresentationDirectory: false,
|
|
14145
|
+
hasSpreadsheetDirectory: false,
|
|
14146
|
+
hasThreeDimensionalModelEntry: false
|
|
14147
|
+
};
|
|
14148
|
+
}
|
|
14149
|
+
function updateOpenXmlZipDetectionStateFromFilename(openXmlState, filename) {
|
|
14150
|
+
if (filename.startsWith("word/")) {
|
|
14151
|
+
openXmlState.hasWordDirectory = true;
|
|
14152
|
+
}
|
|
14153
|
+
if (filename.startsWith("ppt/")) {
|
|
14154
|
+
openXmlState.hasPresentationDirectory = true;
|
|
14155
|
+
}
|
|
14156
|
+
if (filename.startsWith("xl/")) {
|
|
14157
|
+
openXmlState.hasSpreadsheetDirectory = true;
|
|
14158
|
+
}
|
|
14159
|
+
if (filename.startsWith("3D/") && filename.endsWith(".model")) {
|
|
14160
|
+
openXmlState.hasThreeDimensionalModelEntry = true;
|
|
14161
|
+
}
|
|
14162
|
+
}
|
|
14163
|
+
function getOpenXmlFileTypeFromZipEntries(openXmlState) {
|
|
14164
|
+
if (!openXmlState.hasContentTypesEntry || openXmlState.hasUnparseableContentTypes || openXmlState.isParsingContentTypes || openXmlState.hasParsedContentTypesEntry) {
|
|
14165
|
+
return;
|
|
14166
|
+
}
|
|
14167
|
+
if (openXmlState.hasWordDirectory) {
|
|
14168
|
+
return {
|
|
14169
|
+
ext: "docx",
|
|
14170
|
+
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
14171
|
+
};
|
|
14172
|
+
}
|
|
14173
|
+
if (openXmlState.hasPresentationDirectory) {
|
|
14174
|
+
return {
|
|
14175
|
+
ext: "pptx",
|
|
14176
|
+
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
14177
|
+
};
|
|
14178
|
+
}
|
|
14179
|
+
if (openXmlState.hasSpreadsheetDirectory) {
|
|
14180
|
+
return {
|
|
14181
|
+
ext: "xlsx",
|
|
14182
|
+
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
14183
|
+
};
|
|
14184
|
+
}
|
|
14185
|
+
if (openXmlState.hasThreeDimensionalModelEntry) {
|
|
14186
|
+
return {
|
|
14187
|
+
ext: "3mf",
|
|
14188
|
+
mime: "model/3mf"
|
|
14189
|
+
};
|
|
14190
|
+
}
|
|
14191
|
+
}
|
|
14192
|
+
function getOpenXmlMimeTypeFromContentTypesXml(xmlContent) {
|
|
14193
|
+
const endPosition = xmlContent.indexOf('.main+xml"');
|
|
14194
|
+
if (endPosition === -1) {
|
|
14195
|
+
const mimeType = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
|
|
14196
|
+
if (xmlContent.includes(`ContentType="${mimeType}"`)) {
|
|
14197
|
+
return mimeType;
|
|
14198
|
+
}
|
|
14199
|
+
return;
|
|
14200
|
+
}
|
|
14201
|
+
const truncatedContent = xmlContent.slice(0, endPosition);
|
|
14202
|
+
const firstQuotePosition = truncatedContent.lastIndexOf('"');
|
|
14203
|
+
return truncatedContent.slice(firstQuotePosition + 1);
|
|
14204
|
+
}
|
|
13793
14205
|
async function fileTypeFromTokenizer(tokenizer, options) {
|
|
13794
14206
|
return new FileTypeParser(options).fromTokenizer(tokenizer);
|
|
13795
14207
|
}
|
|
13796
14208
|
|
|
13797
14209
|
class FileTypeParser {
|
|
13798
14210
|
constructor(options) {
|
|
14211
|
+
const normalizedMpegOffsetTolerance = normalizeMpegOffsetTolerance(options?.mpegOffsetTolerance);
|
|
13799
14212
|
this.options = {
|
|
13800
|
-
|
|
13801
|
-
|
|
14213
|
+
...options,
|
|
14214
|
+
mpegOffsetTolerance: normalizedMpegOffsetTolerance
|
|
13802
14215
|
};
|
|
13803
14216
|
this.detectors = [
|
|
13804
|
-
...options
|
|
14217
|
+
...this.options.customDetectors ?? [],
|
|
13805
14218
|
{ id: "core", detect: this.detectConfident },
|
|
13806
14219
|
{ id: "core.imprecise", detect: this.detectImprecise }
|
|
13807
14220
|
];
|
|
13808
14221
|
this.tokenizerOptions = {
|
|
13809
|
-
abortSignal: options
|
|
14222
|
+
abortSignal: this.options.signal
|
|
13810
14223
|
};
|
|
13811
14224
|
}
|
|
13812
14225
|
async fromTokenizer(tokenizer) {
|
|
13813
14226
|
const initialPosition = tokenizer.position;
|
|
13814
14227
|
for (const detector of this.detectors) {
|
|
13815
|
-
|
|
14228
|
+
let fileType;
|
|
14229
|
+
try {
|
|
14230
|
+
fileType = await detector.detect(tokenizer);
|
|
14231
|
+
} catch (error2) {
|
|
14232
|
+
if (error2 instanceof EndOfStreamError) {
|
|
14233
|
+
return;
|
|
14234
|
+
}
|
|
14235
|
+
if (error2 instanceof ParserHardLimitError) {
|
|
14236
|
+
return;
|
|
14237
|
+
}
|
|
14238
|
+
throw error2;
|
|
14239
|
+
}
|
|
13816
14240
|
if (fileType) {
|
|
13817
14241
|
return fileType;
|
|
13818
14242
|
}
|
|
@@ -13848,7 +14272,7 @@ class FileTypeParser {
|
|
|
13848
14272
|
}
|
|
13849
14273
|
}
|
|
13850
14274
|
async toDetectionStream(stream, options) {
|
|
13851
|
-
const
|
|
14275
|
+
const sampleSize = normalizeSampleSize(options?.sampleSize ?? reasonableDetectionSizeInBytes);
|
|
13852
14276
|
let detectedFileType;
|
|
13853
14277
|
let firstChunk;
|
|
13854
14278
|
const reader = stream.getReader({ mode: "byob" });
|
|
@@ -13950,7 +14374,7 @@ class FileTypeParser {
|
|
|
13950
14374
|
};
|
|
13951
14375
|
}
|
|
13952
14376
|
if (this.check([239, 187, 191])) {
|
|
13953
|
-
this.tokenizer.ignore(3);
|
|
14377
|
+
await this.tokenizer.ignore(3);
|
|
13954
14378
|
return this.detectConfident(tokenizer);
|
|
13955
14379
|
}
|
|
13956
14380
|
if (this.check([71, 73, 70])) {
|
|
@@ -13967,26 +14391,21 @@ class FileTypeParser {
|
|
|
13967
14391
|
}
|
|
13968
14392
|
if (this.check([31, 139, 8])) {
|
|
13969
14393
|
const gzipHandler = new GzipHandler(tokenizer);
|
|
13970
|
-
const
|
|
13971
|
-
let
|
|
14394
|
+
const limitedInflatedStream = createByteLimitedReadableStream(gzipHandler.inflate(), maximumNestedGzipDetectionSizeInBytes);
|
|
14395
|
+
let compressedFileType;
|
|
13972
14396
|
try {
|
|
13973
|
-
|
|
13974
|
-
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
shouldCancelStream = false;
|
|
13978
|
-
}
|
|
13979
|
-
if (compressedFileType && compressedFileType.ext === "tar") {
|
|
13980
|
-
return {
|
|
13981
|
-
ext: "tar.gz",
|
|
13982
|
-
mime: "application/gzip"
|
|
13983
|
-
};
|
|
13984
|
-
}
|
|
13985
|
-
} finally {
|
|
13986
|
-
if (shouldCancelStream) {
|
|
13987
|
-
await stream.cancel();
|
|
14397
|
+
compressedFileType = await this.fromStream(limitedInflatedStream);
|
|
14398
|
+
} catch (error2) {
|
|
14399
|
+
if (error2?.name === "AbortError") {
|
|
14400
|
+
throw error2;
|
|
13988
14401
|
}
|
|
13989
14402
|
}
|
|
14403
|
+
if (compressedFileType?.ext === "tar") {
|
|
14404
|
+
return {
|
|
14405
|
+
ext: "tar.gz",
|
|
14406
|
+
mime: "application/gzip"
|
|
14407
|
+
};
|
|
14408
|
+
}
|
|
13990
14409
|
return {
|
|
13991
14410
|
ext: "gz",
|
|
13992
14411
|
mime: "application/gzip"
|
|
@@ -13999,15 +14418,35 @@ class FileTypeParser {
|
|
|
13999
14418
|
};
|
|
14000
14419
|
}
|
|
14001
14420
|
if (this.checkString("ID3")) {
|
|
14002
|
-
await tokenizer
|
|
14421
|
+
await safeIgnore(tokenizer, 6, {
|
|
14422
|
+
maximumLength: 6,
|
|
14423
|
+
reason: "ID3 header prefix"
|
|
14424
|
+
});
|
|
14003
14425
|
const id3HeaderLength = await tokenizer.readToken(uint32SyncSafeToken);
|
|
14426
|
+
const isUnknownFileSize = hasUnknownFileSize(tokenizer);
|
|
14427
|
+
if (!Number.isFinite(id3HeaderLength) || id3HeaderLength < 0 || isUnknownFileSize && id3HeaderLength > maximumId3HeaderSizeInBytes) {
|
|
14428
|
+
return;
|
|
14429
|
+
}
|
|
14004
14430
|
if (tokenizer.position + id3HeaderLength > tokenizer.fileInfo.size) {
|
|
14431
|
+
if (isUnknownFileSize) {
|
|
14432
|
+
return;
|
|
14433
|
+
}
|
|
14005
14434
|
return {
|
|
14006
14435
|
ext: "mp3",
|
|
14007
14436
|
mime: "audio/mpeg"
|
|
14008
14437
|
};
|
|
14009
14438
|
}
|
|
14010
|
-
|
|
14439
|
+
try {
|
|
14440
|
+
await safeIgnore(tokenizer, id3HeaderLength, {
|
|
14441
|
+
maximumLength: isUnknownFileSize ? maximumId3HeaderSizeInBytes : tokenizer.fileInfo.size,
|
|
14442
|
+
reason: "ID3 payload"
|
|
14443
|
+
});
|
|
14444
|
+
} catch (error2) {
|
|
14445
|
+
if (error2 instanceof EndOfStreamError) {
|
|
14446
|
+
return;
|
|
14447
|
+
}
|
|
14448
|
+
throw error2;
|
|
14449
|
+
}
|
|
14011
14450
|
return this.fromTokenizer(tokenizer);
|
|
14012
14451
|
}
|
|
14013
14452
|
if (this.checkString("MP+")) {
|
|
@@ -14072,67 +14511,88 @@ class FileTypeParser {
|
|
|
14072
14511
|
}
|
|
14073
14512
|
if (this.check([80, 75, 3, 4])) {
|
|
14074
14513
|
let fileType;
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
stop: true
|
|
14084
|
-
};
|
|
14085
|
-
case "META-INF/MANIFEST.MF":
|
|
14086
|
-
fileType = {
|
|
14087
|
-
ext: "jar",
|
|
14088
|
-
mime: "application/java-archive"
|
|
14089
|
-
};
|
|
14090
|
-
return {
|
|
14091
|
-
stop: true
|
|
14092
|
-
};
|
|
14093
|
-
case "mimetype":
|
|
14514
|
+
const openXmlState = createOpenXmlZipDetectionState();
|
|
14515
|
+
try {
|
|
14516
|
+
await new ZipHandler(tokenizer).unzip((zipHeader) => {
|
|
14517
|
+
updateOpenXmlZipDetectionStateFromFilename(openXmlState, zipHeader.filename);
|
|
14518
|
+
const isOpenXmlContentTypesEntry = zipHeader.filename === "[Content_Types].xml";
|
|
14519
|
+
const openXmlFileTypeFromEntries = getOpenXmlFileTypeFromZipEntries(openXmlState);
|
|
14520
|
+
if (!isOpenXmlContentTypesEntry && openXmlFileTypeFromEntries) {
|
|
14521
|
+
fileType = openXmlFileTypeFromEntries;
|
|
14094
14522
|
return {
|
|
14095
|
-
async handler(fileData) {
|
|
14096
|
-
const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
|
|
14097
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
14098
|
-
},
|
|
14099
14523
|
stop: true
|
|
14100
14524
|
};
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14525
|
+
}
|
|
14526
|
+
switch (zipHeader.filename) {
|
|
14527
|
+
case "META-INF/mozilla.rsa":
|
|
14528
|
+
fileType = {
|
|
14529
|
+
ext: "xpi",
|
|
14530
|
+
mime: "application/x-xpinstall"
|
|
14531
|
+
};
|
|
14532
|
+
return {
|
|
14533
|
+
stop: true
|
|
14534
|
+
};
|
|
14535
|
+
case "META-INF/MANIFEST.MF":
|
|
14536
|
+
fileType = {
|
|
14537
|
+
ext: "jar",
|
|
14538
|
+
mime: "application/java-archive"
|
|
14539
|
+
};
|
|
14540
|
+
return {
|
|
14541
|
+
stop: true
|
|
14542
|
+
};
|
|
14543
|
+
case "mimetype":
|
|
14544
|
+
if (!canReadZipEntryForDetection(zipHeader)) {
|
|
14545
|
+
return {};
|
|
14546
|
+
}
|
|
14547
|
+
return {
|
|
14548
|
+
async handler(fileData) {
|
|
14549
|
+
const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
|
|
14550
|
+
fileType = getFileTypeFromMimeType(mimeType);
|
|
14551
|
+
},
|
|
14552
|
+
stop: true
|
|
14553
|
+
};
|
|
14554
|
+
case "[Content_Types].xml": {
|
|
14555
|
+
openXmlState.hasContentTypesEntry = true;
|
|
14556
|
+
const maximumContentTypesEntrySize = hasUnknownFileSize(tokenizer) ? maximumZipEntrySizeInBytes : Number.MAX_SAFE_INTEGER;
|
|
14557
|
+
if (!canReadZipEntryForDetection(zipHeader, maximumContentTypesEntrySize)) {
|
|
14558
|
+
openXmlState.hasUnparseableContentTypes = true;
|
|
14559
|
+
return {};
|
|
14560
|
+
}
|
|
14561
|
+
openXmlState.isParsingContentTypes = true;
|
|
14562
|
+
return {
|
|
14563
|
+
async handler(fileData) {
|
|
14564
|
+
const xmlContent = new TextDecoder("utf-8").decode(fileData);
|
|
14565
|
+
const mimeType = getOpenXmlMimeTypeFromContentTypesXml(xmlContent);
|
|
14566
|
+
if (mimeType) {
|
|
14109
14567
|
fileType = getFileTypeFromMimeType(mimeType);
|
|
14110
14568
|
}
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
14116
|
-
}
|
|
14117
|
-
},
|
|
14118
|
-
stop: true
|
|
14119
|
-
};
|
|
14120
|
-
default:
|
|
14121
|
-
if (/classes\d*\.dex/.test(zipHeader.filename)) {
|
|
14122
|
-
fileType = {
|
|
14123
|
-
ext: "apk",
|
|
14124
|
-
mime: "application/vnd.android.package-archive"
|
|
14569
|
+
openXmlState.hasParsedContentTypesEntry = true;
|
|
14570
|
+
openXmlState.isParsingContentTypes = false;
|
|
14571
|
+
},
|
|
14572
|
+
stop: true
|
|
14125
14573
|
};
|
|
14126
|
-
return { stop: true };
|
|
14127
14574
|
}
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14575
|
+
default:
|
|
14576
|
+
if (/classes\d*\.dex/.test(zipHeader.filename)) {
|
|
14577
|
+
fileType = {
|
|
14578
|
+
ext: "apk",
|
|
14579
|
+
mime: "application/vnd.android.package-archive"
|
|
14580
|
+
};
|
|
14581
|
+
return { stop: true };
|
|
14582
|
+
}
|
|
14583
|
+
return {};
|
|
14584
|
+
}
|
|
14585
|
+
});
|
|
14586
|
+
} catch (error2) {
|
|
14587
|
+
if (!isRecoverableZipError(error2)) {
|
|
14132
14588
|
throw error2;
|
|
14133
14589
|
}
|
|
14134
|
-
|
|
14135
|
-
|
|
14590
|
+
if (openXmlState.isParsingContentTypes) {
|
|
14591
|
+
openXmlState.isParsingContentTypes = false;
|
|
14592
|
+
openXmlState.hasUnparseableContentTypes = true;
|
|
14593
|
+
}
|
|
14594
|
+
}
|
|
14595
|
+
return fileType ?? getOpenXmlFileTypeFromZipEntries(openXmlState) ?? {
|
|
14136
14596
|
ext: "zip",
|
|
14137
14597
|
mime: "application/zip"
|
|
14138
14598
|
};
|
|
@@ -14282,7 +14742,10 @@ class FileTypeParser {
|
|
|
14282
14742
|
mask >>= 1;
|
|
14283
14743
|
}
|
|
14284
14744
|
const id = new Uint8Array(ic + 1);
|
|
14285
|
-
await tokenizer
|
|
14745
|
+
await safeReadBuffer(tokenizer, id, undefined, {
|
|
14746
|
+
maximumLength: id.length,
|
|
14747
|
+
reason: "EBML field"
|
|
14748
|
+
});
|
|
14286
14749
|
return id;
|
|
14287
14750
|
}
|
|
14288
14751
|
async function readElement() {
|
|
@@ -14298,18 +14761,33 @@ class FileTypeParser {
|
|
|
14298
14761
|
};
|
|
14299
14762
|
}
|
|
14300
14763
|
async function readChildren(children) {
|
|
14764
|
+
let ebmlElementCount = 0;
|
|
14301
14765
|
while (children > 0) {
|
|
14766
|
+
ebmlElementCount++;
|
|
14767
|
+
if (ebmlElementCount > maximumEbmlElementCount) {
|
|
14768
|
+
return;
|
|
14769
|
+
}
|
|
14302
14770
|
const element = await readElement();
|
|
14303
14771
|
if (element.id === 17026) {
|
|
14304
|
-
|
|
14772
|
+
if (element.len > maximumEbmlDocumentTypeSizeInBytes) {
|
|
14773
|
+
return;
|
|
14774
|
+
}
|
|
14775
|
+
const documentTypeLength = getSafeBound(element.len, maximumEbmlDocumentTypeSizeInBytes, "EBML DocType");
|
|
14776
|
+
const rawValue = await tokenizer.readToken(new StringType2(documentTypeLength));
|
|
14305
14777
|
return rawValue.replaceAll(/\00.*$/g, "");
|
|
14306
14778
|
}
|
|
14307
|
-
|
|
14779
|
+
if (hasUnknownFileSize(tokenizer) && (!Number.isFinite(element.len) || element.len < 0 || element.len > maximumEbmlElementPayloadSizeInBytes)) {
|
|
14780
|
+
return;
|
|
14781
|
+
}
|
|
14782
|
+
await safeIgnore(tokenizer, element.len, {
|
|
14783
|
+
maximumLength: hasUnknownFileSize(tokenizer) ? maximumEbmlElementPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
14784
|
+
reason: "EBML payload"
|
|
14785
|
+
});
|
|
14308
14786
|
--children;
|
|
14309
14787
|
}
|
|
14310
14788
|
}
|
|
14311
|
-
const
|
|
14312
|
-
const documentType = await readChildren(
|
|
14789
|
+
const rootElement = await readElement();
|
|
14790
|
+
const documentType = await readChildren(rootElement.len);
|
|
14313
14791
|
switch (documentType) {
|
|
14314
14792
|
case "webm":
|
|
14315
14793
|
return {
|
|
@@ -14572,6 +15050,14 @@ class FileTypeParser {
|
|
|
14572
15050
|
};
|
|
14573
15051
|
}
|
|
14574
15052
|
if (this.check([137, 80, 78, 71, 13, 10, 26, 10])) {
|
|
15053
|
+
const pngFileType = {
|
|
15054
|
+
ext: "png",
|
|
15055
|
+
mime: "image/png"
|
|
15056
|
+
};
|
|
15057
|
+
const apngFileType = {
|
|
15058
|
+
ext: "apng",
|
|
15059
|
+
mime: "image/apng"
|
|
15060
|
+
};
|
|
14575
15061
|
await tokenizer.ignore(8);
|
|
14576
15062
|
async function readChunkHeader() {
|
|
14577
15063
|
return {
|
|
@@ -14579,30 +15065,39 @@ class FileTypeParser {
|
|
|
14579
15065
|
type: await tokenizer.readToken(new StringType2(4, "latin1"))
|
|
14580
15066
|
};
|
|
14581
15067
|
}
|
|
15068
|
+
const isUnknownPngStream = hasUnknownFileSize(tokenizer);
|
|
15069
|
+
const pngScanStart = tokenizer.position;
|
|
14582
15070
|
do {
|
|
15071
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, pngScanStart, maximumPngChunkSizeInBytes)) {
|
|
15072
|
+
break;
|
|
15073
|
+
}
|
|
14583
15074
|
const chunk = await readChunkHeader();
|
|
14584
15075
|
if (chunk.length < 0) {
|
|
14585
15076
|
return;
|
|
14586
15077
|
}
|
|
14587
15078
|
switch (chunk.type) {
|
|
14588
15079
|
case "IDAT":
|
|
14589
|
-
return
|
|
14590
|
-
ext: "png",
|
|
14591
|
-
mime: "image/png"
|
|
14592
|
-
};
|
|
15080
|
+
return pngFileType;
|
|
14593
15081
|
case "acTL":
|
|
14594
|
-
return
|
|
14595
|
-
ext: "apng",
|
|
14596
|
-
mime: "image/apng"
|
|
14597
|
-
};
|
|
15082
|
+
return apngFileType;
|
|
14598
15083
|
default:
|
|
14599
|
-
|
|
15084
|
+
if (isUnknownPngStream && chunk.length > maximumPngChunkSizeInBytes) {
|
|
15085
|
+
return;
|
|
15086
|
+
}
|
|
15087
|
+
try {
|
|
15088
|
+
await safeIgnore(tokenizer, chunk.length + 4, {
|
|
15089
|
+
maximumLength: isUnknownPngStream ? maximumPngChunkSizeInBytes + 4 : tokenizer.fileInfo.size,
|
|
15090
|
+
reason: "PNG chunk payload"
|
|
15091
|
+
});
|
|
15092
|
+
} catch (error2) {
|
|
15093
|
+
if (!isUnknownPngStream && (error2 instanceof ParserHardLimitError || error2 instanceof EndOfStreamError)) {
|
|
15094
|
+
return pngFileType;
|
|
15095
|
+
}
|
|
15096
|
+
throw error2;
|
|
15097
|
+
}
|
|
14600
15098
|
}
|
|
14601
15099
|
} while (tokenizer.position + 8 < tokenizer.fileInfo.size);
|
|
14602
|
-
return
|
|
14603
|
-
ext: "png",
|
|
14604
|
-
mime: "image/png"
|
|
14605
|
-
};
|
|
15100
|
+
return pngFileType;
|
|
14606
15101
|
}
|
|
14607
15102
|
if (this.check([65, 82, 82, 79, 87, 49, 0, 0])) {
|
|
14608
15103
|
return {
|
|
@@ -14722,36 +15217,76 @@ class FileTypeParser {
|
|
|
14722
15217
|
};
|
|
14723
15218
|
}
|
|
14724
15219
|
if (this.check([48, 38, 178, 117, 142, 102, 207, 17, 166, 217])) {
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
15220
|
+
let isMalformedAsf = false;
|
|
15221
|
+
try {
|
|
15222
|
+
async function readHeader() {
|
|
15223
|
+
const guid2 = new Uint8Array(16);
|
|
15224
|
+
await safeReadBuffer(tokenizer, guid2, undefined, {
|
|
15225
|
+
maximumLength: guid2.length,
|
|
15226
|
+
reason: "ASF header GUID"
|
|
15227
|
+
});
|
|
15228
|
+
return {
|
|
15229
|
+
id: guid2,
|
|
15230
|
+
size: Number(await tokenizer.readToken(UINT64_LE))
|
|
15231
|
+
};
|
|
15232
|
+
}
|
|
15233
|
+
await safeIgnore(tokenizer, 30, {
|
|
15234
|
+
maximumLength: 30,
|
|
15235
|
+
reason: "ASF header prelude"
|
|
15236
|
+
});
|
|
15237
|
+
const isUnknownFileSize = hasUnknownFileSize(tokenizer);
|
|
15238
|
+
const asfHeaderScanStart = tokenizer.position;
|
|
15239
|
+
while (tokenizer.position + 24 < tokenizer.fileInfo.size) {
|
|
15240
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, asfHeaderScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
15241
|
+
break;
|
|
14745
15242
|
}
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
15243
|
+
const previousPosition = tokenizer.position;
|
|
15244
|
+
const header = await readHeader();
|
|
15245
|
+
let payload = header.size - 24;
|
|
15246
|
+
if (!Number.isFinite(payload) || payload < 0) {
|
|
15247
|
+
isMalformedAsf = true;
|
|
15248
|
+
break;
|
|
14751
15249
|
}
|
|
14752
|
-
|
|
15250
|
+
if (_check2(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
|
|
15251
|
+
const typeId = new Uint8Array(16);
|
|
15252
|
+
payload -= await safeReadBuffer(tokenizer, typeId, undefined, {
|
|
15253
|
+
maximumLength: typeId.length,
|
|
15254
|
+
reason: "ASF stream type GUID"
|
|
15255
|
+
});
|
|
15256
|
+
if (_check2(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
15257
|
+
return {
|
|
15258
|
+
ext: "asf",
|
|
15259
|
+
mime: "audio/x-ms-asf"
|
|
15260
|
+
};
|
|
15261
|
+
}
|
|
15262
|
+
if (_check2(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
15263
|
+
return {
|
|
15264
|
+
ext: "asf",
|
|
15265
|
+
mime: "video/x-ms-asf"
|
|
15266
|
+
};
|
|
15267
|
+
}
|
|
15268
|
+
break;
|
|
15269
|
+
}
|
|
15270
|
+
await safeIgnore(tokenizer, payload, {
|
|
15271
|
+
maximumLength: isUnknownFileSize ? maximumUntrustedSkipSizeInBytes : tokenizer.fileInfo.size,
|
|
15272
|
+
reason: "ASF header payload"
|
|
15273
|
+
});
|
|
15274
|
+
if (tokenizer.position <= previousPosition) {
|
|
15275
|
+
isMalformedAsf = true;
|
|
15276
|
+
break;
|
|
15277
|
+
}
|
|
15278
|
+
}
|
|
15279
|
+
} catch (error2) {
|
|
15280
|
+
if (error2 instanceof EndOfStreamError || error2 instanceof ParserHardLimitError) {
|
|
15281
|
+
if (hasUnknownFileSize(tokenizer)) {
|
|
15282
|
+
isMalformedAsf = true;
|
|
15283
|
+
}
|
|
15284
|
+
} else {
|
|
15285
|
+
throw error2;
|
|
14753
15286
|
}
|
|
14754
|
-
|
|
15287
|
+
}
|
|
15288
|
+
if (isMalformedAsf) {
|
|
15289
|
+
return;
|
|
14755
15290
|
}
|
|
14756
15291
|
return {
|
|
14757
15292
|
ext: "asf",
|
|
@@ -15002,7 +15537,8 @@ class FileTypeParser {
|
|
|
15002
15537
|
};
|
|
15003
15538
|
detectImprecise = async (tokenizer) => {
|
|
15004
15539
|
this.buffer = new Uint8Array(reasonableDetectionSizeInBytes);
|
|
15005
|
-
|
|
15540
|
+
const fileSize = getKnownFileSizeOrMaximum(tokenizer.fileInfo.size);
|
|
15541
|
+
await tokenizer.peekBuffer(this.buffer, { length: Math.min(8, fileSize), mayBeLess: true });
|
|
15006
15542
|
if (this.check([0, 0, 1, 186]) || this.check([0, 0, 1, 179])) {
|
|
15007
15543
|
return {
|
|
15008
15544
|
ext: "mpg",
|
|
@@ -15027,7 +15563,7 @@ class FileTypeParser {
|
|
|
15027
15563
|
mime: "image/x-icon"
|
|
15028
15564
|
};
|
|
15029
15565
|
}
|
|
15030
|
-
await tokenizer.peekBuffer(this.buffer, { length: Math.min(2 + this.options.mpegOffsetTolerance,
|
|
15566
|
+
await tokenizer.peekBuffer(this.buffer, { length: Math.min(2 + this.options.mpegOffsetTolerance, fileSize), mayBeLess: true });
|
|
15031
15567
|
if (this.buffer.length >= 2 + this.options.mpegOffsetTolerance) {
|
|
15032
15568
|
for (let depth = 0;depth <= this.options.mpegOffsetTolerance; ++depth) {
|
|
15033
15569
|
const type = this.scanMpeg(depth);
|
|
@@ -15039,7 +15575,7 @@ class FileTypeParser {
|
|
|
15039
15575
|
};
|
|
15040
15576
|
async readTiffTag(bigEndian) {
|
|
15041
15577
|
const tagId = await this.tokenizer.readToken(bigEndian ? UINT16_BE : UINT16_LE);
|
|
15042
|
-
this.tokenizer.ignore(10);
|
|
15578
|
+
await this.tokenizer.ignore(10);
|
|
15043
15579
|
switch (tagId) {
|
|
15044
15580
|
case 50341:
|
|
15045
15581
|
return {
|
|
@@ -15056,6 +15592,9 @@ class FileTypeParser {
|
|
|
15056
15592
|
}
|
|
15057
15593
|
async readTiffIFD(bigEndian) {
|
|
15058
15594
|
const numberOfTags = await this.tokenizer.readToken(bigEndian ? UINT16_BE : UINT16_LE);
|
|
15595
|
+
if (hasUnknownFileSize(this.tokenizer) && 2 + numberOfTags * 12 > maximumTiffIfdOffsetInBytes) {
|
|
15596
|
+
return;
|
|
15597
|
+
}
|
|
15059
15598
|
for (let n = 0;n < numberOfTags; ++n) {
|
|
15060
15599
|
const fileType = await this.readTiffTag(bigEndian);
|
|
15061
15600
|
if (fileType) {
|
|
@@ -15064,6 +15603,10 @@ class FileTypeParser {
|
|
|
15064
15603
|
}
|
|
15065
15604
|
}
|
|
15066
15605
|
async readTiffHeader(bigEndian) {
|
|
15606
|
+
const tiffFileType = {
|
|
15607
|
+
ext: "tif",
|
|
15608
|
+
mime: "image/tiff"
|
|
15609
|
+
};
|
|
15067
15610
|
const version2 = (bigEndian ? UINT16_BE : UINT16_LE).get(this.buffer, 2);
|
|
15068
15611
|
const ifdOffset = (bigEndian ? UINT32_BE : UINT32_LE).get(this.buffer, 4);
|
|
15069
15612
|
if (version2 === 42) {
|
|
@@ -15085,18 +15628,31 @@ class FileTypeParser {
|
|
|
15085
15628
|
}
|
|
15086
15629
|
}
|
|
15087
15630
|
}
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15631
|
+
const maximumTiffOffset = hasUnknownFileSize(this.tokenizer) ? maximumTiffIfdOffsetInBytes : this.tokenizer.fileInfo.size;
|
|
15632
|
+
try {
|
|
15633
|
+
await safeIgnore(this.tokenizer, ifdOffset, {
|
|
15634
|
+
maximumLength: maximumTiffOffset,
|
|
15635
|
+
reason: "TIFF IFD offset"
|
|
15636
|
+
});
|
|
15637
|
+
} catch (error2) {
|
|
15638
|
+
if (error2 instanceof EndOfStreamError) {
|
|
15639
|
+
return;
|
|
15640
|
+
}
|
|
15641
|
+
throw error2;
|
|
15642
|
+
}
|
|
15643
|
+
let fileType;
|
|
15644
|
+
try {
|
|
15645
|
+
fileType = await this.readTiffIFD(bigEndian);
|
|
15646
|
+
} catch (error2) {
|
|
15647
|
+
if (error2 instanceof EndOfStreamError) {
|
|
15648
|
+
return;
|
|
15649
|
+
}
|
|
15650
|
+
throw error2;
|
|
15651
|
+
}
|
|
15652
|
+
return fileType ?? tiffFileType;
|
|
15094
15653
|
}
|
|
15095
15654
|
if (version2 === 43) {
|
|
15096
|
-
return
|
|
15097
|
-
ext: "tif",
|
|
15098
|
-
mime: "image/tiff"
|
|
15099
|
-
};
|
|
15655
|
+
return tiffFileType;
|
|
15100
15656
|
}
|
|
15101
15657
|
}
|
|
15102
15658
|
scanMpeg(offset) {
|
|
@@ -15134,7 +15690,7 @@ class FileTypeParser {
|
|
|
15134
15690
|
}
|
|
15135
15691
|
}
|
|
15136
15692
|
}
|
|
15137
|
-
var reasonableDetectionSizeInBytes = 4100, supportedExtensions, supportedMimeTypes;
|
|
15693
|
+
var reasonableDetectionSizeInBytes = 4100, maximumMpegOffsetTolerance, maximumZipEntrySizeInBytes, maximumUntrustedSkipSizeInBytes, maximumNestedGzipDetectionSizeInBytes, maximumId3HeaderSizeInBytes, maximumEbmlDocumentTypeSizeInBytes = 64, maximumEbmlElementPayloadSizeInBytes, maximumEbmlElementCount = 256, maximumPngChunkSizeInBytes, maximumTiffIfdOffsetInBytes, recoverableZipErrorMessages, recoverableZipErrorMessagePrefixes, recoverableZipErrorCodes, ParserHardLimitError, supportedExtensions, supportedMimeTypes;
|
|
15138
15694
|
var init_core2 = __esm(() => {
|
|
15139
15695
|
init_lib3();
|
|
15140
15696
|
init_core();
|
|
@@ -15142,6 +15698,41 @@ var init_core2 = __esm(() => {
|
|
|
15142
15698
|
init_uint8array_extras();
|
|
15143
15699
|
init_util();
|
|
15144
15700
|
init_supported();
|
|
15701
|
+
maximumMpegOffsetTolerance = reasonableDetectionSizeInBytes - 2;
|
|
15702
|
+
maximumZipEntrySizeInBytes = 1024 * 1024;
|
|
15703
|
+
maximumUntrustedSkipSizeInBytes = 16 * 1024 * 1024;
|
|
15704
|
+
maximumNestedGzipDetectionSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
15705
|
+
maximumId3HeaderSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
15706
|
+
maximumEbmlElementPayloadSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
15707
|
+
maximumPngChunkSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
15708
|
+
maximumTiffIfdOffsetInBytes = maximumUntrustedSkipSizeInBytes;
|
|
15709
|
+
recoverableZipErrorMessages = new Set([
|
|
15710
|
+
"Unexpected signature",
|
|
15711
|
+
"Encrypted ZIP",
|
|
15712
|
+
"Expected Central-File-Header signature"
|
|
15713
|
+
]);
|
|
15714
|
+
recoverableZipErrorMessagePrefixes = [
|
|
15715
|
+
"Unsupported ZIP compression method:",
|
|
15716
|
+
"ZIP entry decompressed data exceeds "
|
|
15717
|
+
];
|
|
15718
|
+
recoverableZipErrorCodes = new Set([
|
|
15719
|
+
"Z_BUF_ERROR",
|
|
15720
|
+
"Z_DATA_ERROR",
|
|
15721
|
+
"ERR_INVALID_STATE"
|
|
15722
|
+
]);
|
|
15723
|
+
ParserHardLimitError = class ParserHardLimitError extends Error {
|
|
15724
|
+
};
|
|
15725
|
+
ZipHandler.prototype.inflate = async function(zipHeader, fileData, callback) {
|
|
15726
|
+
if (zipHeader.compressedMethod === 0) {
|
|
15727
|
+
return callback(fileData);
|
|
15728
|
+
}
|
|
15729
|
+
if (zipHeader.compressedMethod !== 8) {
|
|
15730
|
+
throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
|
|
15731
|
+
}
|
|
15732
|
+
const maximumLength = hasUnknownFileSize(this.tokenizer) ? maximumZipEntrySizeInBytes : Number.MAX_SAFE_INTEGER;
|
|
15733
|
+
const uncompressedData = await decompressDeflateRawWithLimit(fileData, { maximumLength });
|
|
15734
|
+
return callback(uncompressedData);
|
|
15735
|
+
};
|
|
15145
15736
|
supportedExtensions = new Set(extensions);
|
|
15146
15737
|
supportedMimeTypes = new Set(mimeTypes);
|
|
15147
15738
|
});
|
|
@@ -15161,6 +15752,12 @@ __export(exports_file_type, {
|
|
|
15161
15752
|
});
|
|
15162
15753
|
import { ReadableStream as WebReadableStream } from "node:stream/web";
|
|
15163
15754
|
import { pipeline as pipeline2, PassThrough, Readable } from "node:stream";
|
|
15755
|
+
function isTokenizerStreamBoundsError(error2) {
|
|
15756
|
+
if (!(error2 instanceof RangeError) || error2.message !== "offset is out of bounds" || typeof error2.stack !== "string") {
|
|
15757
|
+
return false;
|
|
15758
|
+
}
|
|
15759
|
+
return /strtok3[/\\]lib[/\\]stream[/\\]/.test(error2.stack);
|
|
15760
|
+
}
|
|
15164
15761
|
async function fileTypeFromFile(path2, options) {
|
|
15165
15762
|
return new FileTypeParser2(options).fromFile(path2, options);
|
|
15166
15763
|
}
|
|
@@ -15180,6 +15777,11 @@ var init_file_type = __esm(() => {
|
|
|
15180
15777
|
const tokenizer = await (stream instanceof WebReadableStream ? fromWebStream(stream, this.tokenizerOptions) : fromStream2(stream, this.tokenizerOptions));
|
|
15181
15778
|
try {
|
|
15182
15779
|
return await super.fromTokenizer(tokenizer);
|
|
15780
|
+
} catch (error2) {
|
|
15781
|
+
if (isTokenizerStreamBoundsError(error2)) {
|
|
15782
|
+
return;
|
|
15783
|
+
}
|
|
15784
|
+
throw error2;
|
|
15183
15785
|
} finally {
|
|
15184
15786
|
await tokenizer.close();
|
|
15185
15787
|
}
|
|
@@ -15196,7 +15798,7 @@ var init_file_type = __esm(() => {
|
|
|
15196
15798
|
if (!(readableStream instanceof Readable)) {
|
|
15197
15799
|
return super.toDetectionStream(readableStream, options);
|
|
15198
15800
|
}
|
|
15199
|
-
const
|
|
15801
|
+
const sampleSize = normalizeSampleSize(options.sampleSize ?? reasonableDetectionSizeInBytes);
|
|
15200
15802
|
return new Promise((resolve, reject) => {
|
|
15201
15803
|
readableStream.on("error", reject);
|
|
15202
15804
|
readableStream.once("readable", () => {
|
|
@@ -16131,10 +16733,14 @@ var isWsl = () => {
|
|
|
16131
16733
|
return true;
|
|
16132
16734
|
}
|
|
16133
16735
|
try {
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16736
|
+
if (fs6.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
16737
|
+
return !isInsideContainer();
|
|
16738
|
+
}
|
|
16739
|
+
} catch {}
|
|
16740
|
+
if (fs6.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs6.existsSync("/run/WSL")) {
|
|
16741
|
+
return !isInsideContainer();
|
|
16137
16742
|
}
|
|
16743
|
+
return false;
|
|
16138
16744
|
}, is_wsl_default;
|
|
16139
16745
|
var init_is_wsl = __esm(() => {
|
|
16140
16746
|
init_is_inside_container();
|
|
@@ -16340,11 +16946,11 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
|
16340
16946
|
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
16341
16947
|
}
|
|
16342
16948
|
const { id } = match.groups;
|
|
16343
|
-
const
|
|
16344
|
-
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
return
|
|
16949
|
+
const dotIndex = id.lastIndexOf(".");
|
|
16950
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
16951
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
16952
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
16953
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
16348
16954
|
}
|
|
16349
16955
|
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
16350
16956
|
var init_windows = __esm(() => {
|
|
@@ -24081,11 +24687,12 @@ init_constants();
|
|
|
24081
24687
|
// src/lib/client/index.ts
|
|
24082
24688
|
init_constants();
|
|
24083
24689
|
init_errors();
|
|
24084
|
-
import { AsyncLocalStorage as
|
|
24690
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
24085
24691
|
|
|
24086
24692
|
// src/lib/client/core.ts
|
|
24087
24693
|
init_errors();
|
|
24088
24694
|
init_constants();
|
|
24695
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
24089
24696
|
|
|
24090
24697
|
// src/config/endpoints.ts
|
|
24091
24698
|
var EP = {
|
|
@@ -24330,6 +24937,10 @@ function createLogger(bindings = {}) {
|
|
|
24330
24937
|
}
|
|
24331
24938
|
var logger = createLogger();
|
|
24332
24939
|
// src/lib/client/core.ts
|
|
24940
|
+
var orgContextStorage = new AsyncLocalStorage2;
|
|
24941
|
+
function runWithOrgContext(client, fn) {
|
|
24942
|
+
return orgContextStorage.run({ orgId: client.getDefaultOrgId() }, fn);
|
|
24943
|
+
}
|
|
24333
24944
|
var apiLogger = logger.withCategory(LogCategory.API);
|
|
24334
24945
|
var oidcTokenCache = new Map;
|
|
24335
24946
|
var OIDC_EXPIRY_BUFFER_MS = 5 * 60 * 1000;
|
|
@@ -24525,8 +25136,16 @@ class KanboClient {
|
|
|
24525
25136
|
}
|
|
24526
25137
|
setOrganization(orgId) {
|
|
24527
25138
|
this.orgId = orgId;
|
|
25139
|
+
const ctx = orgContextStorage.getStore();
|
|
25140
|
+
if (ctx) {
|
|
25141
|
+
ctx.orgId = orgId;
|
|
25142
|
+
}
|
|
24528
25143
|
}
|
|
24529
25144
|
getOrganizationId() {
|
|
25145
|
+
const ctx = orgContextStorage.getStore();
|
|
25146
|
+
return ctx ? ctx.orgId : this.orgId;
|
|
25147
|
+
}
|
|
25148
|
+
getDefaultOrgId() {
|
|
24530
25149
|
return this.orgId;
|
|
24531
25150
|
}
|
|
24532
25151
|
async validateAndGetContext() {
|
|
@@ -25025,7 +25644,7 @@ KanboClient.prototype.batchMoveTickets = async function(projectId, ticketIds, st
|
|
|
25025
25644
|
};
|
|
25026
25645
|
|
|
25027
25646
|
// src/lib/client/index.ts
|
|
25028
|
-
var requestClientStorage = new
|
|
25647
|
+
var requestClientStorage = new AsyncLocalStorage3;
|
|
25029
25648
|
function runWithClient(client, fn) {
|
|
25030
25649
|
return requestClientStorage.run(client, fn);
|
|
25031
25650
|
}
|
|
@@ -29893,42 +30512,46 @@ function createMCPServer() {
|
|
|
29893
30512
|
isError: true
|
|
29894
30513
|
};
|
|
29895
30514
|
}
|
|
29896
|
-
|
|
29897
|
-
|
|
29898
|
-
|
|
29899
|
-
|
|
29900
|
-
|
|
29901
|
-
|
|
29902
|
-
|
|
29903
|
-
|
|
29904
|
-
|
|
29905
|
-
|
|
29906
|
-
|
|
29907
|
-
|
|
29908
|
-
|
|
29909
|
-
|
|
29910
|
-
|
|
29911
|
-
|
|
29912
|
-
|
|
29913
|
-
|
|
29914
|
-
|
|
29915
|
-
|
|
29916
|
-
|
|
29917
|
-
|
|
29918
|
-
|
|
30515
|
+
const client = getKanboClient();
|
|
30516
|
+
return runWithOrgContext(client, async () => {
|
|
30517
|
+
try {
|
|
30518
|
+
const result = await handler(args || {});
|
|
30519
|
+
return {
|
|
30520
|
+
content: [
|
|
30521
|
+
{
|
|
30522
|
+
type: "text",
|
|
30523
|
+
text: formatToolResult(result)
|
|
30524
|
+
}
|
|
30525
|
+
],
|
|
30526
|
+
isError: !result.success
|
|
30527
|
+
};
|
|
30528
|
+
} catch (error2) {
|
|
30529
|
+
serverLogger.error({ err: error2, toolName: name }, "Tool execution failed");
|
|
30530
|
+
return {
|
|
30531
|
+
content: [
|
|
30532
|
+
{
|
|
30533
|
+
type: "text",
|
|
30534
|
+
text: formatToolResult(errorResultFromError(error2))
|
|
30535
|
+
}
|
|
30536
|
+
],
|
|
30537
|
+
isError: true
|
|
30538
|
+
};
|
|
30539
|
+
}
|
|
30540
|
+
});
|
|
29919
30541
|
});
|
|
29920
30542
|
return server;
|
|
29921
30543
|
}
|
|
30544
|
+
var STARTUP_AUTH_TIMEOUT_MS = 15000;
|
|
29922
30545
|
async function startStdioServer() {
|
|
29923
|
-
logToolRegistration();
|
|
29924
|
-
serverLogger.info("Starting in stdio mode");
|
|
29925
30546
|
if (!CONFIG.KANBO_API_KEY) {
|
|
29926
|
-
|
|
29927
|
-
process.exit(1);
|
|
30547
|
+
throw new Error('KANBO_API_KEY is required. Run "kanbo-mcp login" to authenticate, ' + "or set the KANBO_API_KEY environment variable.");
|
|
29928
30548
|
}
|
|
29929
30549
|
try {
|
|
29930
30550
|
const client = getKanboClient();
|
|
29931
|
-
const authContext = await
|
|
30551
|
+
const authContext = await Promise.race([
|
|
30552
|
+
client.validateAndGetContext(),
|
|
30553
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Authentication timed out after ${STARTUP_AUTH_TIMEOUT_MS / 1000}s. ` + "Check your network connection and API URL.")), STARTUP_AUTH_TIMEOUT_MS))
|
|
30554
|
+
]);
|
|
29932
30555
|
serverLogger.info({ email: authContext.email }, "Authenticated");
|
|
29933
30556
|
serverLogger.info({ organizations: authContext.organizations.map((o) => o.name) }, "Available organizations");
|
|
29934
30557
|
if (client.getOrganizationId()) {
|
|
@@ -29937,11 +30560,19 @@ async function startStdioServer() {
|
|
|
29937
30560
|
}
|
|
29938
30561
|
} catch (error2) {
|
|
29939
30562
|
serverLogger.fatal({ err: error2 }, "Authentication failed");
|
|
29940
|
-
|
|
30563
|
+
throw error2;
|
|
29941
30564
|
}
|
|
29942
30565
|
const server = createMCPServer();
|
|
29943
30566
|
const transport = new StdioServerTransport;
|
|
30567
|
+
const shutdown = async () => {
|
|
30568
|
+
serverLogger.info("Shutting down...");
|
|
30569
|
+
await server.close();
|
|
30570
|
+
process.exit(0);
|
|
30571
|
+
};
|
|
30572
|
+
process.on("SIGINT", shutdown);
|
|
30573
|
+
process.on("SIGTERM", shutdown);
|
|
29944
30574
|
await server.connect(transport);
|
|
30575
|
+
logToolRegistration();
|
|
29945
30576
|
serverLogger.info("Server running on stdio");
|
|
29946
30577
|
}
|
|
29947
30578
|
|
|
@@ -32916,7 +33547,6 @@ var Type = exports_type3;
|
|
|
32916
33547
|
|
|
32917
33548
|
// node_modules/elysia/dist/index.mjs
|
|
32918
33549
|
var import_fast_decode_uri_component4 = __toESM(require_fast_decode_uri_component(), 1);
|
|
32919
|
-
|
|
32920
33550
|
// node_modules/@sinclair/typebox/build/esm/errors/function.mjs
|
|
32921
33551
|
function DefaultErrorFunction(error2) {
|
|
32922
33552
|
switch (error2.errorType) {
|
|
@@ -34194,6 +34824,7 @@ function Errors(...args) {
|
|
|
34194
34824
|
const iterator = args.length === 3 ? Visit6(args[0], args[1], "", args[2]) : Visit6(args[0], [], "", args[1]);
|
|
34195
34825
|
return new ValueErrorIterator(iterator);
|
|
34196
34826
|
}
|
|
34827
|
+
|
|
34197
34828
|
// node_modules/@sinclair/typebox/build/esm/value/assert/assert.mjs
|
|
34198
34829
|
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
34199
34830
|
if (kind === "m")
|
|
@@ -36810,6 +37441,15 @@ var TypeCompiler;
|
|
|
36810
37441
|
|
|
36811
37442
|
// node_modules/elysia/dist/universal/utils.mjs
|
|
36812
37443
|
var isBun = typeof Bun < "u";
|
|
37444
|
+
function isCloudflareWorker() {
|
|
37445
|
+
try {
|
|
37446
|
+
if (typeof caches < "u" && typeof caches.default < "u" || typeof WebSocketPair < "u")
|
|
37447
|
+
return true;
|
|
37448
|
+
} catch {
|
|
37449
|
+
return false;
|
|
37450
|
+
}
|
|
37451
|
+
return false;
|
|
37452
|
+
}
|
|
36813
37453
|
|
|
36814
37454
|
// node_modules/elysia/dist/universal/file.mjs
|
|
36815
37455
|
var mime = {
|
|
@@ -36939,7 +37579,6 @@ class ElysiaFile {
|
|
|
36939
37579
|
}
|
|
36940
37580
|
|
|
36941
37581
|
// node_modules/elysia/dist/utils.mjs
|
|
36942
|
-
var hasHeaderShorthand = "toJSON" in new Headers;
|
|
36943
37582
|
var replaceUrlPath = (url, pathname) => {
|
|
36944
37583
|
const pathStartIndex = url.indexOf("/", 11), queryIndex = url.indexOf("?", pathStartIndex);
|
|
36945
37584
|
return queryIndex === -1 ? `${url.slice(0, pathStartIndex)}${pathname.charCodeAt(0) === 47 ? "" : "/"}${pathname}` : `${url.slice(0, pathStartIndex)}${pathname.charCodeAt(0) === 47 ? "" : "/"}${pathname}${url.slice(queryIndex)}`;
|
|
@@ -37071,8 +37710,7 @@ var lifeCycleToArray = (a) => {
|
|
|
37071
37710
|
let beforeHandle = [];
|
|
37072
37711
|
return a.resolve && (beforeHandle = fnToContainer(Array.isArray(a.resolve) ? a.resolve : [a.resolve], "resolve"), delete a.resolve), a.beforeHandle && (beforeHandle.length ? beforeHandle = beforeHandle.concat(Array.isArray(a.beforeHandle) ? a.beforeHandle : [a.beforeHandle]) : beforeHandle = Array.isArray(a.beforeHandle) ? a.beforeHandle : [a.beforeHandle]), beforeHandle.length && (a.beforeHandle = beforeHandle), a;
|
|
37073
37712
|
};
|
|
37074
|
-
var
|
|
37075
|
-
var hasBunHash = isBun2 && typeof Bun.hash == "function";
|
|
37713
|
+
var hasHeaderShorthand = isBun ? "toJSON" in new Headers : false;
|
|
37076
37714
|
var hasSetImmediate = typeof setImmediate == "function";
|
|
37077
37715
|
var checksum = (s) => {
|
|
37078
37716
|
let h = 9;
|
|
@@ -37222,8 +37860,8 @@ function removeTrailingEquals(digest) {
|
|
|
37222
37860
|
}
|
|
37223
37861
|
var encoder = new TextEncoder;
|
|
37224
37862
|
var signCookie = async (val, secret) => {
|
|
37225
|
-
if (typeof val == "object" ? val = JSON.stringify(val) : typeof val != "string" && (val = val + ""), secret
|
|
37226
|
-
throw new TypeError("Secret key must be provided
|
|
37863
|
+
if (typeof val == "object" ? val = JSON.stringify(val) : typeof val != "string" && (val = val + ""), secret == null)
|
|
37864
|
+
throw new TypeError("Secret key must be provided");
|
|
37227
37865
|
const secretKey = await crypto.subtle.importKey("raw", encoder.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]), hmacBuffer = await crypto.subtle.sign("HMAC", secretKey, encoder.encode(val));
|
|
37228
37866
|
return val + "." + removeTrailingEquals(Buffer.from(hmacBuffer).toString("base64"));
|
|
37229
37867
|
};
|
|
@@ -37234,11 +37872,9 @@ var constantTimeEqual = typeof crypto?.timingSafeEqual == "function" ? (a, b) =>
|
|
|
37234
37872
|
var unsignCookie = async (input, secret) => {
|
|
37235
37873
|
if (typeof input != "string")
|
|
37236
37874
|
throw new TypeError("Signed cookie string must be provided.");
|
|
37237
|
-
if (secret === null)
|
|
37238
|
-
throw new TypeError("Secret key must be provided.");
|
|
37239
37875
|
const dot = input.lastIndexOf(".");
|
|
37240
|
-
if (dot
|
|
37241
|
-
return false;
|
|
37876
|
+
if (dot === -1)
|
|
37877
|
+
return secret === null ? input : false;
|
|
37242
37878
|
const tentativeValue = input.slice(0, dot), expectedInput = await signCookie(tentativeValue, secret);
|
|
37243
37879
|
return constantTimeEqual(expectedInput, input) ? tentativeValue : false;
|
|
37244
37880
|
};
|
|
@@ -37350,11 +37986,11 @@ var form = (items) => {
|
|
|
37350
37986
|
}
|
|
37351
37987
|
return formData;
|
|
37352
37988
|
};
|
|
37353
|
-
var randomId = typeof crypto > "u" ? () => {
|
|
37989
|
+
var randomId = typeof crypto > "u" || isCloudflareWorker() ? () => {
|
|
37354
37990
|
let result = "";
|
|
37355
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
37991
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
37356
37992
|
for (let i = 0;i < 16; i++)
|
|
37357
|
-
result += characters.charAt(Math.floor(Math.random() *
|
|
37993
|
+
result += characters.charAt(Math.floor(Math.random() * 62));
|
|
37358
37994
|
return result;
|
|
37359
37995
|
} : () => {
|
|
37360
37996
|
const uuid2 = crypto.randomUUID();
|
|
@@ -37580,7 +38216,7 @@ class ValidationError2 extends Error {
|
|
|
37580
38216
|
value,
|
|
37581
38217
|
property: accessor,
|
|
37582
38218
|
message: error2?.message,
|
|
37583
|
-
summary: mapValueError(error2)
|
|
38219
|
+
summary: mapValueError(error2)?.summary,
|
|
37584
38220
|
found: value,
|
|
37585
38221
|
expected,
|
|
37586
38222
|
errors: "Errors" in validator ? [
|
|
@@ -37597,7 +38233,7 @@ class ValidationError2 extends Error {
|
|
|
37597
38233
|
on: type,
|
|
37598
38234
|
property: accessor,
|
|
37599
38235
|
message: error2?.message,
|
|
37600
|
-
summary: mapValueError(error2)
|
|
38236
|
+
summary: mapValueError(error2)?.summary,
|
|
37601
38237
|
expected,
|
|
37602
38238
|
found: value,
|
|
37603
38239
|
errors: "Errors" in validator ? [...validator.Errors(value)].map(mapValueError) : [...exports_value2.Errors(validator, value)].map(mapValueError)
|
|
@@ -37621,7 +38257,7 @@ class ValidationError2 extends Error {
|
|
|
37621
38257
|
path: issue2.path?.join(".") || "root",
|
|
37622
38258
|
message: issue2.message,
|
|
37623
38259
|
value: this.value
|
|
37624
|
-
})) || [] : ("Errors" in this.validator) ? [...this.validator.Errors(this.value)].map(mapValueError) : [...exports_value2.Errors(this.validator, this.value)].map(mapValueError);
|
|
38260
|
+
})) || [] : ("Errors" in this.validator) ? [...this.validator.Errors(this.value)].filter((x) => x).map((x) => mapValueError(x)) : [...exports_value2.Errors(this.validator, this.value)].map(mapValueError);
|
|
37625
38261
|
}
|
|
37626
38262
|
static simplifyModel(validator) {
|
|
37627
38263
|
const model = "schema" in validator ? validator.schema : validator;
|
|
@@ -37657,7 +38293,7 @@ class ValidationError2 extends Error {
|
|
|
37657
38293
|
on: this.type,
|
|
37658
38294
|
property: this.valueError?.path || "root",
|
|
37659
38295
|
message,
|
|
37660
|
-
summary:
|
|
38296
|
+
summary: mapValueError(this.valueError)?.summary,
|
|
37661
38297
|
found: value,
|
|
37662
38298
|
expected,
|
|
37663
38299
|
errors: errors3
|
|
@@ -37758,7 +38394,7 @@ var fullFormats = {
|
|
|
37758
38394
|
uri,
|
|
37759
38395
|
"uri-reference": /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,
|
|
37760
38396
|
"uri-template": /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,
|
|
37761
|
-
url: /^(?:https?|ftp):\/\/(
|
|
38397
|
+
url: /^(?:https?|ftp):\/\/(?:[^\s:@]+(?::[^\s@]*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,
|
|
37762
38398
|
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
|
37763
38399
|
hostname: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,
|
|
37764
38400
|
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,
|
|
@@ -38209,6 +38845,270 @@ t.BooleanString = ElysiaType.BooleanString, t.ObjectString = ElysiaType.ObjectSt
|
|
|
38209
38845
|
}
|
|
38210
38846
|
})), t.Nullable = ElysiaType.Nullable, t.MaybeEmpty = ElysiaType.MaybeEmpty, t.Cookie = ElysiaType.Cookie, t.Date = ElysiaType.Date, t.UnionEnum = ElysiaType.UnionEnum, t.NoValidate = ElysiaType.NoValidate, t.Form = ElysiaType.Form, t.ArrayBuffer = ElysiaType.ArrayBuffer, t.Uint8Array = ElysiaType.Uint8Array;
|
|
38211
38847
|
|
|
38848
|
+
// node_modules/elysia/dist/sucrose.mjs
|
|
38849
|
+
var separateFunction = (code) => {
|
|
38850
|
+
code.startsWith("async") && (code = code.slice(5)), code = code.trimStart();
|
|
38851
|
+
let index = -1;
|
|
38852
|
+
if (code.charCodeAt(0) === 40 && (index = code.indexOf("=>", code.indexOf(")")), index !== -1)) {
|
|
38853
|
+
let bracketEndIndex = index;
|
|
38854
|
+
for (;bracketEndIndex > 0 && code.charCodeAt(--bracketEndIndex) !== 41; )
|
|
38855
|
+
;
|
|
38856
|
+
let body = code.slice(index + 2);
|
|
38857
|
+
return body.charCodeAt(0) === 32 && (body = body.trimStart()), [
|
|
38858
|
+
code.slice(1, bracketEndIndex),
|
|
38859
|
+
body,
|
|
38860
|
+
{
|
|
38861
|
+
isArrowReturn: body.charCodeAt(0) !== 123
|
|
38862
|
+
}
|
|
38863
|
+
];
|
|
38864
|
+
}
|
|
38865
|
+
if (/^(\w+)=>/g.test(code) && (index = code.indexOf("=>"), index !== -1)) {
|
|
38866
|
+
let body = code.slice(index + 2);
|
|
38867
|
+
return body.charCodeAt(0) === 32 && (body = body.trimStart()), [
|
|
38868
|
+
code.slice(0, index),
|
|
38869
|
+
body,
|
|
38870
|
+
{
|
|
38871
|
+
isArrowReturn: body.charCodeAt(0) !== 123
|
|
38872
|
+
}
|
|
38873
|
+
];
|
|
38874
|
+
}
|
|
38875
|
+
if (code.startsWith("function")) {
|
|
38876
|
+
index = code.indexOf("(");
|
|
38877
|
+
const end = code.indexOf(")");
|
|
38878
|
+
return [
|
|
38879
|
+
code.slice(index + 1, end),
|
|
38880
|
+
code.slice(end + 2),
|
|
38881
|
+
{
|
|
38882
|
+
isArrowReturn: false
|
|
38883
|
+
}
|
|
38884
|
+
];
|
|
38885
|
+
}
|
|
38886
|
+
const start = code.indexOf("(");
|
|
38887
|
+
if (start !== -1) {
|
|
38888
|
+
const sep = code.indexOf(`
|
|
38889
|
+
`, 2), parameter = code.slice(0, sep), end = parameter.lastIndexOf(")") + 1, body = code.slice(sep + 1);
|
|
38890
|
+
return [
|
|
38891
|
+
parameter.slice(start, end),
|
|
38892
|
+
"{" + body,
|
|
38893
|
+
{
|
|
38894
|
+
isArrowReturn: false
|
|
38895
|
+
}
|
|
38896
|
+
];
|
|
38897
|
+
}
|
|
38898
|
+
const x = code.split(`
|
|
38899
|
+
`, 2);
|
|
38900
|
+
return [x[0], x[1], { isArrowReturn: false }];
|
|
38901
|
+
};
|
|
38902
|
+
var bracketPairRange = (parameter) => {
|
|
38903
|
+
const start = parameter.indexOf("{");
|
|
38904
|
+
if (start === -1)
|
|
38905
|
+
return [-1, 0];
|
|
38906
|
+
let end = start + 1, deep = 1;
|
|
38907
|
+
for (;end < parameter.length; end++) {
|
|
38908
|
+
const char = parameter.charCodeAt(end);
|
|
38909
|
+
if (char === 123 ? deep++ : char === 125 && deep--, deep === 0)
|
|
38910
|
+
break;
|
|
38911
|
+
}
|
|
38912
|
+
return deep !== 0 ? [0, parameter.length] : [start, end + 1];
|
|
38913
|
+
};
|
|
38914
|
+
var bracketPairRangeReverse = (parameter) => {
|
|
38915
|
+
const end = parameter.lastIndexOf("}");
|
|
38916
|
+
if (end === -1)
|
|
38917
|
+
return [-1, 0];
|
|
38918
|
+
let start = end - 1, deep = 1;
|
|
38919
|
+
for (;start >= 0; start--) {
|
|
38920
|
+
const char = parameter.charCodeAt(start);
|
|
38921
|
+
if (char === 125 ? deep++ : char === 123 && deep--, deep === 0)
|
|
38922
|
+
break;
|
|
38923
|
+
}
|
|
38924
|
+
return deep !== 0 ? [-1, 0] : [start, end + 1];
|
|
38925
|
+
};
|
|
38926
|
+
var removeColonAlias = (parameter) => {
|
|
38927
|
+
for (;; ) {
|
|
38928
|
+
const start = parameter.indexOf(":");
|
|
38929
|
+
if (start === -1)
|
|
38930
|
+
break;
|
|
38931
|
+
let end = parameter.indexOf(",", start);
|
|
38932
|
+
end === -1 && (end = parameter.indexOf("}", start) - 1), end === -2 && (end = parameter.length), parameter = parameter.slice(0, start) + parameter.slice(end);
|
|
38933
|
+
}
|
|
38934
|
+
return parameter;
|
|
38935
|
+
};
|
|
38936
|
+
var retrieveRootparameters = (parameter) => {
|
|
38937
|
+
let hasParenthesis = false;
|
|
38938
|
+
parameter.charCodeAt(0) === 40 && (parameter = parameter.slice(1, -1)), parameter.charCodeAt(0) === 123 && (hasParenthesis = true, parameter = parameter.slice(1, -1)), parameter = parameter.replace(/( |\t|\n)/g, "").trim();
|
|
38939
|
+
let parameters = [];
|
|
38940
|
+
for (;; ) {
|
|
38941
|
+
let [start, end] = bracketPairRange(parameter);
|
|
38942
|
+
if (start === -1)
|
|
38943
|
+
break;
|
|
38944
|
+
parameters.push(parameter.slice(0, start - 1)), parameter.charCodeAt(end) === 44 && end++, parameter = parameter.slice(end);
|
|
38945
|
+
}
|
|
38946
|
+
parameter = removeColonAlias(parameter), parameter && (parameters = parameters.concat(parameter.split(",")));
|
|
38947
|
+
const parameterMap = /* @__PURE__ */ Object.create(null);
|
|
38948
|
+
for (const p of parameters) {
|
|
38949
|
+
if (p.indexOf(",") === -1) {
|
|
38950
|
+
parameterMap[p] = true;
|
|
38951
|
+
continue;
|
|
38952
|
+
}
|
|
38953
|
+
for (const q of p.split(","))
|
|
38954
|
+
parameterMap[q.trim()] = true;
|
|
38955
|
+
}
|
|
38956
|
+
return {
|
|
38957
|
+
hasParenthesis,
|
|
38958
|
+
parameters: parameterMap
|
|
38959
|
+
};
|
|
38960
|
+
};
|
|
38961
|
+
var findParameterReference = (parameter, inference) => {
|
|
38962
|
+
const { parameters, hasParenthesis } = retrieveRootparameters(parameter);
|
|
38963
|
+
return parameters.query && (inference.query = true), parameters.headers && (inference.headers = true), parameters.body && (inference.body = true), parameters.cookie && (inference.cookie = true), parameters.set && (inference.set = true), parameters.server && (inference.server = true), parameters.route && (inference.route = true), parameters.url && (inference.url = true), parameters.path && (inference.path = true), hasParenthesis ? `{ ${Object.keys(parameters).join(", ")} }` : Object.keys(parameters).join(", ");
|
|
38964
|
+
};
|
|
38965
|
+
var findEndIndex = (type, content, index) => {
|
|
38966
|
+
const regex2 = new RegExp(`${type.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\n\\t,; ]`);
|
|
38967
|
+
index !== undefined && (regex2.lastIndex = index);
|
|
38968
|
+
const match = regex2.exec(content);
|
|
38969
|
+
return match ? match.index : -1;
|
|
38970
|
+
};
|
|
38971
|
+
var findAlias = (type, body, depth = 0) => {
|
|
38972
|
+
if (depth > 5)
|
|
38973
|
+
return [];
|
|
38974
|
+
const aliases = [];
|
|
38975
|
+
let content = body;
|
|
38976
|
+
for (;; ) {
|
|
38977
|
+
let index = findEndIndex(" = " + type, content);
|
|
38978
|
+
if (index === -1 && (index = findEndIndex("=" + type, content)), index === -1) {
|
|
38979
|
+
let lastIndex = content.indexOf(" = " + type);
|
|
38980
|
+
if (lastIndex === -1 && (lastIndex = content.indexOf("=" + type)), lastIndex + 3 + type.length !== content.length)
|
|
38981
|
+
break;
|
|
38982
|
+
index = lastIndex;
|
|
38983
|
+
}
|
|
38984
|
+
const part = content.slice(0, index), lastPart = part.lastIndexOf(" ");
|
|
38985
|
+
let variable = part.slice(lastPart !== -1 ? lastPart + 1 : -1);
|
|
38986
|
+
if (variable === "}") {
|
|
38987
|
+
const [start, end] = bracketPairRangeReverse(part);
|
|
38988
|
+
aliases.push(removeColonAlias(content.slice(start, end))), content = content.slice(index + 3 + type.length);
|
|
38989
|
+
continue;
|
|
38990
|
+
}
|
|
38991
|
+
for (;variable.charCodeAt(0) === 44; )
|
|
38992
|
+
variable = variable.slice(1);
|
|
38993
|
+
for (;variable.charCodeAt(0) === 9; )
|
|
38994
|
+
variable = variable.slice(1);
|
|
38995
|
+
variable.includes("(") || aliases.push(variable), content = content.slice(index + 3 + type.length);
|
|
38996
|
+
}
|
|
38997
|
+
for (const alias of aliases) {
|
|
38998
|
+
if (alias.charCodeAt(0) === 123)
|
|
38999
|
+
continue;
|
|
39000
|
+
const deepAlias = findAlias(alias, body);
|
|
39001
|
+
deepAlias.length > 0 && aliases.push(...deepAlias);
|
|
39002
|
+
}
|
|
39003
|
+
return aliases;
|
|
39004
|
+
};
|
|
39005
|
+
var extractMainParameter = (parameter) => {
|
|
39006
|
+
if (!parameter)
|
|
39007
|
+
return;
|
|
39008
|
+
if (parameter.charCodeAt(0) !== 123)
|
|
39009
|
+
return parameter;
|
|
39010
|
+
if (parameter = parameter.slice(2, -2), !parameter.includes(","))
|
|
39011
|
+
return parameter.indexOf("...") !== -1 ? parameter.slice(parameter.indexOf("...") + 3) : undefined;
|
|
39012
|
+
const spreadIndex = parameter.indexOf("...");
|
|
39013
|
+
if (spreadIndex !== -1)
|
|
39014
|
+
return parameter.slice(spreadIndex + 3).trimEnd();
|
|
39015
|
+
};
|
|
39016
|
+
var inferBodyReference = (code, aliases, inference) => {
|
|
39017
|
+
const access = (type, alias) => new RegExp(`${alias}\\.(${type})|${alias}\\["${type}"\\]|${alias}\\['${type}'\\]`).test(code);
|
|
39018
|
+
for (const alias of aliases)
|
|
39019
|
+
if (alias) {
|
|
39020
|
+
if (alias.charCodeAt(0) === 123) {
|
|
39021
|
+
const parameters = retrieveRootparameters(alias).parameters;
|
|
39022
|
+
parameters.query && (inference.query = true), parameters.headers && (inference.headers = true), parameters.body && (inference.body = true), parameters.cookie && (inference.cookie = true), parameters.set && (inference.set = true), parameters.server && (inference.server = true), parameters.url && (inference.url = true), parameters.route && (inference.route = true), parameters.path && (inference.path = true);
|
|
39023
|
+
continue;
|
|
39024
|
+
}
|
|
39025
|
+
if (!inference.query && (access("query", alias) || code.includes("return " + alias) || code.includes("return " + alias + ".query")) && (inference.query = true), !inference.headers && access("headers", alias) && (inference.headers = true), !inference.body && access("body", alias) && (inference.body = true), !inference.cookie && access("cookie", alias) && (inference.cookie = true), !inference.set && access("set", alias) && (inference.set = true), !inference.server && access("server", alias) && (inference.server = true), !inference.route && access("route", alias) && (inference.route = true), !inference.url && access("url", alias) && (inference.url = true), !inference.path && access("path", alias) && (inference.path = true), inference.query && inference.headers && inference.body && inference.cookie && inference.set && inference.server && inference.route && inference.url && inference.path)
|
|
39026
|
+
break;
|
|
39027
|
+
}
|
|
39028
|
+
return aliases;
|
|
39029
|
+
};
|
|
39030
|
+
var isContextPassToFunction = (context, body, inference) => {
|
|
39031
|
+
try {
|
|
39032
|
+
const captureFunction = new RegExp(`\\w\\((?:.*?)?${context}(?:.*?)?\\)`, "gs"), exactParameter = new RegExp(`${context}(,|\\))`, "gs"), length = body.length;
|
|
39033
|
+
let fn;
|
|
39034
|
+
for (fn = captureFunction.exec(body) + "";captureFunction.lastIndex !== 0 && captureFunction.lastIndex < length + (fn ? fn.length : 0); ) {
|
|
39035
|
+
if (fn && exactParameter.test(fn))
|
|
39036
|
+
return inference.query = true, inference.headers = true, inference.body = true, inference.cookie = true, inference.set = true, inference.server = true, inference.url = true, inference.route = true, inference.path = true, true;
|
|
39037
|
+
fn = captureFunction.exec(body) + "";
|
|
39038
|
+
}
|
|
39039
|
+
const nextChar = body.charCodeAt(captureFunction.lastIndex);
|
|
39040
|
+
return nextChar === 41 || nextChar === 44 ? (inference.query = true, inference.headers = true, inference.body = true, inference.cookie = true, inference.set = true, inference.server = true, inference.url = true, inference.route = true, inference.path = true, true) : false;
|
|
39041
|
+
} catch {
|
|
39042
|
+
return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"), console.log("--- body ---"), console.log(body), console.log("--- context ---"), console.log(context), true;
|
|
39043
|
+
}
|
|
39044
|
+
};
|
|
39045
|
+
var pendingGC;
|
|
39046
|
+
var caches2 = {};
|
|
39047
|
+
var clearSucroseCache = (delay) => {
|
|
39048
|
+
delay === null || isCloudflareWorker() || (delay === undefined && (delay = 4 * 60 * 1000 + 55 * 1000), pendingGC && clearTimeout(pendingGC), pendingGC = setTimeout(() => {
|
|
39049
|
+
caches2 = {}, pendingGC = undefined, isBun && Bun.gc(false);
|
|
39050
|
+
}, delay), pendingGC.unref?.());
|
|
39051
|
+
};
|
|
39052
|
+
var mergeInference = (a, b) => ({
|
|
39053
|
+
body: a.body || b.body,
|
|
39054
|
+
cookie: a.cookie || b.cookie,
|
|
39055
|
+
headers: a.headers || b.headers,
|
|
39056
|
+
query: a.query || b.query,
|
|
39057
|
+
set: a.set || b.set,
|
|
39058
|
+
server: a.server || b.server,
|
|
39059
|
+
url: a.url || b.url,
|
|
39060
|
+
route: a.route || b.route,
|
|
39061
|
+
path: a.path || b.path
|
|
39062
|
+
});
|
|
39063
|
+
var sucrose = (lifeCycle, inference = {
|
|
39064
|
+
query: false,
|
|
39065
|
+
headers: false,
|
|
39066
|
+
body: false,
|
|
39067
|
+
cookie: false,
|
|
39068
|
+
set: false,
|
|
39069
|
+
server: false,
|
|
39070
|
+
url: false,
|
|
39071
|
+
route: false,
|
|
39072
|
+
path: false
|
|
39073
|
+
}, settings = {}) => {
|
|
39074
|
+
const events = [];
|
|
39075
|
+
lifeCycle.request?.length && events.push(...lifeCycle.request), lifeCycle.beforeHandle?.length && events.push(...lifeCycle.beforeHandle), lifeCycle.parse?.length && events.push(...lifeCycle.parse), lifeCycle.error?.length && events.push(...lifeCycle.error), lifeCycle.transform?.length && events.push(...lifeCycle.transform), lifeCycle.afterHandle?.length && events.push(...lifeCycle.afterHandle), lifeCycle.mapResponse?.length && events.push(...lifeCycle.mapResponse), lifeCycle.afterResponse?.length && events.push(...lifeCycle.afterResponse), lifeCycle.handler && typeof lifeCycle.handler == "function" && events.push(lifeCycle.handler);
|
|
39076
|
+
for (let i = 0;i < events.length; i++) {
|
|
39077
|
+
const e = events[i];
|
|
39078
|
+
if (!e)
|
|
39079
|
+
continue;
|
|
39080
|
+
const event = typeof e == "object" ? e.fn : e;
|
|
39081
|
+
if (typeof event != "function")
|
|
39082
|
+
continue;
|
|
39083
|
+
const content = event.toString(), key = checksum(content), cachedInference = caches2[key];
|
|
39084
|
+
if (cachedInference) {
|
|
39085
|
+
inference = mergeInference(inference, cachedInference);
|
|
39086
|
+
continue;
|
|
39087
|
+
}
|
|
39088
|
+
clearSucroseCache(settings.gcTime);
|
|
39089
|
+
const fnInference = {
|
|
39090
|
+
query: false,
|
|
39091
|
+
headers: false,
|
|
39092
|
+
body: false,
|
|
39093
|
+
cookie: false,
|
|
39094
|
+
set: false,
|
|
39095
|
+
server: false,
|
|
39096
|
+
url: false,
|
|
39097
|
+
route: false,
|
|
39098
|
+
path: false
|
|
39099
|
+
}, [parameter, body] = separateFunction(content), rootParameters = findParameterReference(parameter, fnInference), mainParameter = extractMainParameter(rootParameters);
|
|
39100
|
+
if (mainParameter) {
|
|
39101
|
+
const aliases = findAlias(mainParameter, body.slice(1, -1));
|
|
39102
|
+
aliases.splice(0, -1, mainParameter);
|
|
39103
|
+
let code = body;
|
|
39104
|
+
code.charCodeAt(0) === 123 && code.charCodeAt(body.length - 1) === 125 && (code = code.slice(1, -1).trim()), isContextPassToFunction(mainParameter, code, fnInference) || inferBodyReference(code, aliases, fnInference), !fnInference.query && code.includes("return " + mainParameter + ".query") && (fnInference.query = true);
|
|
39105
|
+
}
|
|
39106
|
+
if (caches2[key] || (caches2[key] = fnInference), inference = mergeInference(inference, fnInference), inference.query && inference.headers && inference.body && inference.cookie && inference.set && inference.server && inference.url && inference.route && inference.path)
|
|
39107
|
+
break;
|
|
39108
|
+
}
|
|
39109
|
+
return inference;
|
|
39110
|
+
};
|
|
39111
|
+
|
|
38212
39112
|
// node_modules/elysia/dist/cookies.mjs
|
|
38213
39113
|
var import_cookie = __toESM(require_dist2(), 1);
|
|
38214
39114
|
var import_fast_decode_uri_component = __toESM(require_fast_decode_uri_component(), 1);
|
|
@@ -38221,7 +39121,7 @@ var hashString = (str) => {
|
|
|
38221
39121
|
};
|
|
38222
39122
|
|
|
38223
39123
|
class Cookie {
|
|
38224
|
-
constructor(name, jar, initial =
|
|
39124
|
+
constructor(name, jar, initial = /* @__PURE__ */ Object.create(null)) {
|
|
38225
39125
|
this.name = name;
|
|
38226
39126
|
this.jar = jar;
|
|
38227
39127
|
this.initial = initial;
|
|
@@ -38341,7 +39241,7 @@ class Cookie {
|
|
|
38341
39241
|
return typeof this.value == "object" ? JSON.stringify(this.value) : this.value?.toString() ?? "";
|
|
38342
39242
|
}
|
|
38343
39243
|
}
|
|
38344
|
-
var createCookieJar = (set2, store, initial) => (set2.cookie || (set2.cookie =
|
|
39244
|
+
var createCookieJar = (set2, store, initial) => (set2.cookie || (set2.cookie = /* @__PURE__ */ Object.create(null)), new Proxy(store, {
|
|
38345
39245
|
get(_, key) {
|
|
38346
39246
|
return key in store ? new Cookie(key, set2.cookie, Object.assign({}, initial ?? {}, store[key])) : new Cookie(key, set2.cookie, Object.assign({}, initial));
|
|
38347
39247
|
}
|
|
@@ -38350,23 +39250,16 @@ var parseCookie = async (set2, cookieString, {
|
|
|
38350
39250
|
secrets,
|
|
38351
39251
|
sign,
|
|
38352
39252
|
...initial
|
|
38353
|
-
} =
|
|
39253
|
+
} = /* @__PURE__ */ Object.create(null)) => {
|
|
38354
39254
|
if (!cookieString)
|
|
38355
|
-
return createCookieJar(set2,
|
|
39255
|
+
return createCookieJar(set2, /* @__PURE__ */ Object.create(null), initial);
|
|
38356
39256
|
const isStringKey = typeof secrets == "string";
|
|
38357
39257
|
sign && sign !== true && !Array.isArray(sign) && (sign = [sign]);
|
|
38358
|
-
const jar =
|
|
39258
|
+
const jar = /* @__PURE__ */ Object.create(null), cookies = import_cookie.parse(cookieString);
|
|
38359
39259
|
for (const [name, v] of Object.entries(cookies)) {
|
|
38360
|
-
if (v === undefined)
|
|
39260
|
+
if (v === undefined || name === "__proto__" || name === "constructor" || name === "prototype")
|
|
38361
39261
|
continue;
|
|
38362
39262
|
let value = import_fast_decode_uri_component.default(v);
|
|
38363
|
-
if (value) {
|
|
38364
|
-
const starts = value.charCodeAt(0), ends = value.charCodeAt(value.length - 1);
|
|
38365
|
-
if (starts === 123 && ends === 125 || starts === 91 && ends === 93)
|
|
38366
|
-
try {
|
|
38367
|
-
value = JSON.parse(value);
|
|
38368
|
-
} catch {}
|
|
38369
|
-
}
|
|
38370
39263
|
if (sign === true || sign?.includes(name)) {
|
|
38371
39264
|
if (!secrets)
|
|
38372
39265
|
throw new Error("No secret is provided to cookie plugin");
|
|
@@ -38392,9 +39285,14 @@ var parseCookie = async (set2, cookieString, {
|
|
|
38392
39285
|
throw new InvalidCookieSignature(name);
|
|
38393
39286
|
}
|
|
38394
39287
|
}
|
|
38395
|
-
|
|
38396
|
-
value
|
|
38397
|
-
|
|
39288
|
+
if (value) {
|
|
39289
|
+
const starts = value.charCodeAt(0), ends = value.charCodeAt(value.length - 1);
|
|
39290
|
+
if (starts === 123 && ends === 125 || starts === 91 && ends === 93)
|
|
39291
|
+
try {
|
|
39292
|
+
value = JSON.parse(value);
|
|
39293
|
+
} catch {}
|
|
39294
|
+
}
|
|
39295
|
+
jar[name] = /* @__PURE__ */ Object.create(null), jar[name].value = value;
|
|
38398
39296
|
}
|
|
38399
39297
|
return createCookieJar(set2, jar, initial);
|
|
38400
39298
|
};
|
|
@@ -38572,32 +39470,33 @@ var handleSet = (set2) => {
|
|
|
38572
39470
|
}
|
|
38573
39471
|
set2.headers["set-cookie"] && Array.isArray(set2.headers["set-cookie"]) && (set2.headers = parseSetCookies(new Headers(set2.headers), set2.headers["set-cookie"]));
|
|
38574
39472
|
};
|
|
39473
|
+
function mergeHeaders(responseHeaders, setHeaders) {
|
|
39474
|
+
const headers = new Headers(responseHeaders);
|
|
39475
|
+
if (setHeaders instanceof Headers)
|
|
39476
|
+
for (const key of setHeaders.keys())
|
|
39477
|
+
if (key === "set-cookie") {
|
|
39478
|
+
if (headers.has("set-cookie"))
|
|
39479
|
+
continue;
|
|
39480
|
+
for (const cookie of setHeaders.getSetCookie())
|
|
39481
|
+
headers.append("set-cookie", cookie);
|
|
39482
|
+
} else
|
|
39483
|
+
responseHeaders.has(key) || headers.set(key, setHeaders?.get(key) ?? "");
|
|
39484
|
+
else
|
|
39485
|
+
for (const key in setHeaders)
|
|
39486
|
+
key === "set-cookie" ? headers.append(key, setHeaders[key]) : responseHeaders.has(key) || headers.set(key, setHeaders[key]);
|
|
39487
|
+
return headers;
|
|
39488
|
+
}
|
|
39489
|
+
function mergeStatus(responseStatus, setStatus) {
|
|
39490
|
+
return typeof setStatus == "string" && (setStatus = StatusMap[setStatus]), responseStatus === 200 ? setStatus : responseStatus;
|
|
39491
|
+
}
|
|
38575
39492
|
var createResponseHandler = (handler) => {
|
|
38576
39493
|
const handleStream = createStreamHandler(handler);
|
|
38577
39494
|
return (response, set2, request) => {
|
|
38578
|
-
|
|
38579
|
-
|
|
38580
|
-
|
|
38581
|
-
|
|
38582
|
-
|
|
38583
|
-
continue;
|
|
38584
|
-
isCookieSet = true;
|
|
38585
|
-
for (const cookie of set2.headers.getSetCookie())
|
|
38586
|
-
response.headers.append("set-cookie", cookie);
|
|
38587
|
-
} else
|
|
38588
|
-
response.headers.has(key) || response.headers.set(key, set2.headers?.get(key) ?? "");
|
|
38589
|
-
else
|
|
38590
|
-
for (const key in set2.headers)
|
|
38591
|
-
key === "set-cookie" ? response.headers.append(key, set2.headers[key]) : response.headers.has(key) || response.headers.set(key, set2.headers[key]);
|
|
38592
|
-
const status2 = set2.status ?? 200;
|
|
38593
|
-
if (response.status !== status2 && status2 !== 200 && (response.status <= 300 || response.status > 400)) {
|
|
38594
|
-
const newResponse = new Response(response.body, {
|
|
38595
|
-
headers: response.headers,
|
|
38596
|
-
status: set2.status
|
|
38597
|
-
});
|
|
38598
|
-
return !newResponse.headers.has("content-length") && newResponse.headers.get("transfer-encoding") === "chunked" ? handleStream(streamResponse(newResponse), responseToSetHeaders(newResponse, set2), request, true) : newResponse;
|
|
38599
|
-
}
|
|
38600
|
-
return !response.headers.has("content-length") && response.headers.get("transfer-encoding") === "chunked" ? handleStream(streamResponse(response), responseToSetHeaders(response, set2), request, true) : response;
|
|
39495
|
+
const newResponse = new Response(response.body, {
|
|
39496
|
+
headers: mergeHeaders(response.headers, set2.headers),
|
|
39497
|
+
status: mergeStatus(response.status, set2.status)
|
|
39498
|
+
});
|
|
39499
|
+
return !newResponse.headers.has("content-length") && newResponse.headers.get("transfer-encoding") === "chunked" ? handleStream(streamResponse(newResponse), responseToSetHeaders(newResponse, set2), request, true) : newResponse;
|
|
38601
39500
|
};
|
|
38602
39501
|
};
|
|
38603
39502
|
async function tee(source, branches = 2) {
|
|
@@ -38678,6 +39577,12 @@ var mapResponse = (response, set2, request) => {
|
|
|
38678
39577
|
return handleStream(response, set2, request);
|
|
38679
39578
|
if (typeof response?.then == "function")
|
|
38680
39579
|
return response.then((x) => mapResponse(x, set2));
|
|
39580
|
+
if (Array.isArray(response))
|
|
39581
|
+
return new Response(JSON.stringify(response), {
|
|
39582
|
+
headers: {
|
|
39583
|
+
"Content-Type": "application/json"
|
|
39584
|
+
}
|
|
39585
|
+
});
|
|
38681
39586
|
if (typeof response?.toResponse == "function")
|
|
38682
39587
|
return mapResponse(response.toResponse(), set2);
|
|
38683
39588
|
if ("charCodeAt" in response) {
|
|
@@ -38738,6 +39643,12 @@ var mapEarlyResponse = (response, set2, request) => {
|
|
|
38738
39643
|
return response.then((x) => mapEarlyResponse(x, set2));
|
|
38739
39644
|
if (typeof response?.toResponse == "function")
|
|
38740
39645
|
return mapEarlyResponse(response.toResponse(), set2);
|
|
39646
|
+
if (Array.isArray(response))
|
|
39647
|
+
return new Response(JSON.stringify(response), {
|
|
39648
|
+
headers: {
|
|
39649
|
+
"Content-Type": "application/json"
|
|
39650
|
+
}
|
|
39651
|
+
});
|
|
38741
39652
|
if ("charCodeAt" in response) {
|
|
38742
39653
|
const code = response.charCodeAt(0);
|
|
38743
39654
|
if (code === 123 || code === 91)
|
|
@@ -38800,6 +39711,12 @@ var mapEarlyResponse = (response, set2, request) => {
|
|
|
38800
39711
|
return response.then((x) => mapEarlyResponse(x, set2));
|
|
38801
39712
|
if (typeof response?.toResponse == "function")
|
|
38802
39713
|
return mapEarlyResponse(response.toResponse(), set2);
|
|
39714
|
+
if (Array.isArray(response))
|
|
39715
|
+
return new Response(JSON.stringify(response), {
|
|
39716
|
+
headers: {
|
|
39717
|
+
"Content-Type": "application/json"
|
|
39718
|
+
}
|
|
39719
|
+
});
|
|
38803
39720
|
if ("charCodeAt" in response) {
|
|
38804
39721
|
const code = response.charCodeAt(0);
|
|
38805
39722
|
if (code === 123 || code === 91)
|
|
@@ -38871,6 +39788,12 @@ var mapCompactResponse = (response, request) => {
|
|
|
38871
39788
|
return response.then((x) => mapCompactResponse(x, request));
|
|
38872
39789
|
if (typeof response?.toResponse == "function")
|
|
38873
39790
|
return mapCompactResponse(response.toResponse());
|
|
39791
|
+
if (Array.isArray(response))
|
|
39792
|
+
return new Response(JSON.stringify(response), {
|
|
39793
|
+
headers: {
|
|
39794
|
+
"Content-Type": "application/json"
|
|
39795
|
+
}
|
|
39796
|
+
});
|
|
38874
39797
|
if ("charCodeAt" in response) {
|
|
38875
39798
|
const code = response.charCodeAt(0);
|
|
38876
39799
|
if (code === 123 || code === 91)
|
|
@@ -38954,10 +39877,57 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
38954
39877
|
c.body={}
|
|
38955
39878
|
`;
|
|
38956
39879
|
return isOptional ? fnLiteral += "let form;try{form=await c.request.formData()}catch{}" : fnLiteral += `const form=await c.request.formData()
|
|
38957
|
-
`, fnLiteral + `
|
|
39880
|
+
`, fnLiteral + `const dangerousKeys=new Set(['__proto__','constructor','prototype'])
|
|
39881
|
+
const isDangerousKey=(k)=>{if(dangerousKeys.has(k))return true;const m=k.match(/^(.+)\\[(\\d+)\\]$/);return m?dangerousKeys.has(m[1]):false}
|
|
39882
|
+
const parseArrayKey=(k)=>{const m=k.match(/^(.+)\\[(\\d+)\\]$/);return m?{name:m[1],index:parseInt(m[2],10)}:null}
|
|
39883
|
+
for(const key of form.keys()){if(c.body[key])continue
|
|
38958
39884
|
const value=form.getAll(key)
|
|
38959
|
-
|
|
38960
|
-
|
|
39885
|
+
let finalValue
|
|
39886
|
+
if(value.length===1){
|
|
39887
|
+
const sv=value[0]
|
|
39888
|
+
if(typeof sv==='string'&&(sv.charCodeAt(0)===123||sv.charCodeAt(0)===91)){
|
|
39889
|
+
try{
|
|
39890
|
+
const p=JSON.parse(sv)
|
|
39891
|
+
if(p&&typeof p==='object')finalValue=p
|
|
39892
|
+
}catch{}
|
|
39893
|
+
}
|
|
39894
|
+
if(finalValue===undefined)finalValue=sv
|
|
39895
|
+
}else finalValue=value
|
|
39896
|
+
if(Array.isArray(finalValue)){
|
|
39897
|
+
const stringValue=finalValue.find((entry)=>typeof entry==='string')
|
|
39898
|
+
const files=typeof File==='undefined'?[]:finalValue.filter((entry)=>entry instanceof File)
|
|
39899
|
+
if(stringValue&&files.length&&stringValue.charCodeAt(0)===123){
|
|
39900
|
+
try{
|
|
39901
|
+
const parsed=JSON.parse(stringValue)
|
|
39902
|
+
if(parsed&&typeof parsed==='object'&&!Array.isArray(parsed)){
|
|
39903
|
+
if(!('file' in parsed)&&files.length===1)parsed.file=files[0]
|
|
39904
|
+
else if(!('files' in parsed)&&files.length>1)parsed.files=files
|
|
39905
|
+
finalValue=parsed
|
|
39906
|
+
}
|
|
39907
|
+
}catch{}
|
|
39908
|
+
}
|
|
39909
|
+
}
|
|
39910
|
+
if(key.includes('.')||key.includes('[')){const keys=key.split('.')
|
|
39911
|
+
const lastKey=keys.pop()
|
|
39912
|
+
if(isDangerousKey(lastKey)||keys.some(isDangerousKey))continue
|
|
39913
|
+
let current=c.body
|
|
39914
|
+
for(const k of keys){const arrayInfo=parseArrayKey(k)
|
|
39915
|
+
if(arrayInfo){if(!Array.isArray(current[arrayInfo.name]))current[arrayInfo.name]=[]
|
|
39916
|
+
const existing=current[arrayInfo.name][arrayInfo.index]
|
|
39917
|
+
const isFile=typeof File!=='undefined'&&existing instanceof File
|
|
39918
|
+
if(!existing||typeof existing!=='object'||Array.isArray(existing)||isFile){
|
|
39919
|
+
let parsed
|
|
39920
|
+
if(typeof existing==='string'&&existing.charCodeAt(0)===123){
|
|
39921
|
+
try{parsed=JSON.parse(existing)
|
|
39922
|
+
if(!parsed||typeof parsed!=='object'||Array.isArray(parsed))parsed=undefined}catch{}
|
|
39923
|
+
}
|
|
39924
|
+
current[arrayInfo.name][arrayInfo.index]=parsed||{}
|
|
39925
|
+
}
|
|
39926
|
+
current=current[arrayInfo.name][arrayInfo.index]}else{if(!current[k]||typeof current[k]!=='object')current[k]={}
|
|
39927
|
+
current=current[k]}}
|
|
39928
|
+
const arrayInfo=parseArrayKey(lastKey)
|
|
39929
|
+
if(arrayInfo){if(!Array.isArray(current[arrayInfo.name]))current[arrayInfo.name]=[]
|
|
39930
|
+
current[arrayInfo.name][arrayInfo.index]=finalValue}else{current[lastKey]=finalValue}}else c.body[key]=finalValue}`;
|
|
38961
39931
|
}
|
|
38962
39932
|
}
|
|
38963
39933
|
},
|
|
@@ -39004,6 +39974,278 @@ const error404=new Response(error404Message,{status:404})
|
|
|
39004
39974
|
}
|
|
39005
39975
|
};
|
|
39006
39976
|
|
|
39977
|
+
// node_modules/elysia/dist/adapter/bun/handler.mjs
|
|
39978
|
+
var mapResponse2 = (response, set2, request) => {
|
|
39979
|
+
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.cookie)
|
|
39980
|
+
switch (handleSet(set2), response?.constructor?.name) {
|
|
39981
|
+
case "String":
|
|
39982
|
+
return new Response(response, set2);
|
|
39983
|
+
case "Array":
|
|
39984
|
+
case "Object":
|
|
39985
|
+
return Response.json(response, set2);
|
|
39986
|
+
case "ElysiaFile":
|
|
39987
|
+
return handleFile(response.value, set2);
|
|
39988
|
+
case "File":
|
|
39989
|
+
return handleFile(response, set2);
|
|
39990
|
+
case "Blob":
|
|
39991
|
+
return handleFile(response, set2);
|
|
39992
|
+
case "ElysiaCustomStatusResponse":
|
|
39993
|
+
return set2.status = response.code, mapResponse2(response.response, set2, request);
|
|
39994
|
+
case undefined:
|
|
39995
|
+
return response ? Response.json(response, set2) : new Response("", set2);
|
|
39996
|
+
case "Response":
|
|
39997
|
+
return handleResponse2(response, set2, request);
|
|
39998
|
+
case "Error":
|
|
39999
|
+
return errorToResponse2(response, set2);
|
|
40000
|
+
case "Promise":
|
|
40001
|
+
return response.then((x) => mapResponse2(x, set2, request));
|
|
40002
|
+
case "Function":
|
|
40003
|
+
return mapResponse2(response(), set2, request);
|
|
40004
|
+
case "Number":
|
|
40005
|
+
case "Boolean":
|
|
40006
|
+
return new Response(response.toString(), set2);
|
|
40007
|
+
case "Cookie":
|
|
40008
|
+
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
40009
|
+
case "FormData":
|
|
40010
|
+
return new Response(response, set2);
|
|
40011
|
+
default:
|
|
40012
|
+
if (response instanceof Response)
|
|
40013
|
+
return handleResponse2(response, set2, request);
|
|
40014
|
+
if (response instanceof Promise)
|
|
40015
|
+
return response.then((x) => mapResponse2(x, set2));
|
|
40016
|
+
if (response instanceof Error)
|
|
40017
|
+
return errorToResponse2(response, set2);
|
|
40018
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40019
|
+
return set2.status = response.code, mapResponse2(response.response, set2, request);
|
|
40020
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40021
|
+
return handleStream2(response, set2, request);
|
|
40022
|
+
if (typeof response?.then == "function")
|
|
40023
|
+
return response.then((x) => mapResponse2(x, set2));
|
|
40024
|
+
if (Array.isArray(response))
|
|
40025
|
+
return Response.json(response);
|
|
40026
|
+
if (typeof response?.toResponse == "function")
|
|
40027
|
+
return mapResponse2(response.toResponse(), set2);
|
|
40028
|
+
if ("charCodeAt" in response) {
|
|
40029
|
+
const code = response.charCodeAt(0);
|
|
40030
|
+
if (code === 123 || code === 91)
|
|
40031
|
+
return Response.json(response, set2);
|
|
40032
|
+
}
|
|
40033
|
+
return new Response(response, set2);
|
|
40034
|
+
}
|
|
40035
|
+
return typeof response?.next == "function" || response instanceof ReadableStream ? handleStream2(response, set2, request) : mapCompactResponse2(response, request);
|
|
40036
|
+
};
|
|
40037
|
+
var mapEarlyResponse2 = (response, set2, request) => {
|
|
40038
|
+
if (response != null)
|
|
40039
|
+
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.cookie)
|
|
40040
|
+
switch (handleSet(set2), response?.constructor?.name) {
|
|
40041
|
+
case "String":
|
|
40042
|
+
return new Response(response, set2);
|
|
40043
|
+
case "Array":
|
|
40044
|
+
case "Object":
|
|
40045
|
+
return Response.json(response, set2);
|
|
40046
|
+
case "ElysiaFile":
|
|
40047
|
+
return handleFile(response.value, set2);
|
|
40048
|
+
case "File":
|
|
40049
|
+
return handleFile(response, set2);
|
|
40050
|
+
case "Blob":
|
|
40051
|
+
return handleFile(response, set2);
|
|
40052
|
+
case "ElysiaCustomStatusResponse":
|
|
40053
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40054
|
+
case undefined:
|
|
40055
|
+
return response ? Response.json(response, set2) : undefined;
|
|
40056
|
+
case "Response":
|
|
40057
|
+
return handleResponse2(response, set2, request);
|
|
40058
|
+
case "Promise":
|
|
40059
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40060
|
+
case "Error":
|
|
40061
|
+
return errorToResponse2(response, set2);
|
|
40062
|
+
case "Function":
|
|
40063
|
+
return mapEarlyResponse2(response(), set2);
|
|
40064
|
+
case "Number":
|
|
40065
|
+
case "Boolean":
|
|
40066
|
+
return new Response(response.toString(), set2);
|
|
40067
|
+
case "FormData":
|
|
40068
|
+
return new Response(response);
|
|
40069
|
+
case "Cookie":
|
|
40070
|
+
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
40071
|
+
default:
|
|
40072
|
+
if (response instanceof Response)
|
|
40073
|
+
return handleResponse2(response, set2, request);
|
|
40074
|
+
if (response instanceof Promise)
|
|
40075
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40076
|
+
if (response instanceof Error)
|
|
40077
|
+
return errorToResponse2(response, set2);
|
|
40078
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40079
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40080
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40081
|
+
return handleStream2(response, set2, request);
|
|
40082
|
+
if (typeof response?.then == "function")
|
|
40083
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40084
|
+
if (typeof response?.toResponse == "function")
|
|
40085
|
+
return mapEarlyResponse2(response.toResponse(), set2);
|
|
40086
|
+
if (Array.isArray(response))
|
|
40087
|
+
return Response.json(response);
|
|
40088
|
+
if ("charCodeAt" in response) {
|
|
40089
|
+
const code = response.charCodeAt(0);
|
|
40090
|
+
if (code === 123 || code === 91)
|
|
40091
|
+
return Response.json(response, set2);
|
|
40092
|
+
}
|
|
40093
|
+
return new Response(response, set2);
|
|
40094
|
+
}
|
|
40095
|
+
else
|
|
40096
|
+
switch (response?.constructor?.name) {
|
|
40097
|
+
case "String":
|
|
40098
|
+
return new Response(response);
|
|
40099
|
+
case "Array":
|
|
40100
|
+
case "Object":
|
|
40101
|
+
return Response.json(response, set2);
|
|
40102
|
+
case "ElysiaFile":
|
|
40103
|
+
return handleFile(response.value, set2);
|
|
40104
|
+
case "File":
|
|
40105
|
+
return handleFile(response, set2);
|
|
40106
|
+
case "Blob":
|
|
40107
|
+
return handleFile(response, set2);
|
|
40108
|
+
case "ElysiaCustomStatusResponse":
|
|
40109
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40110
|
+
case undefined:
|
|
40111
|
+
return response ? Response.json(response) : new Response("");
|
|
40112
|
+
case "Response":
|
|
40113
|
+
return response;
|
|
40114
|
+
case "Promise":
|
|
40115
|
+
return response.then((x) => {
|
|
40116
|
+
const r = mapEarlyResponse2(x, set2);
|
|
40117
|
+
if (r !== undefined)
|
|
40118
|
+
return r;
|
|
40119
|
+
});
|
|
40120
|
+
case "Error":
|
|
40121
|
+
return errorToResponse2(response, set2);
|
|
40122
|
+
case "Function":
|
|
40123
|
+
return mapCompactResponse2(response(), request);
|
|
40124
|
+
case "Number":
|
|
40125
|
+
case "Boolean":
|
|
40126
|
+
return new Response(response.toString());
|
|
40127
|
+
case "Cookie":
|
|
40128
|
+
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
40129
|
+
case "FormData":
|
|
40130
|
+
return new Response(response);
|
|
40131
|
+
default:
|
|
40132
|
+
if (response instanceof Response)
|
|
40133
|
+
return response;
|
|
40134
|
+
if (response instanceof Promise)
|
|
40135
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40136
|
+
if (response instanceof Error)
|
|
40137
|
+
return errorToResponse2(response, set2);
|
|
40138
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40139
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40140
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40141
|
+
return handleStream2(response, set2, request);
|
|
40142
|
+
if (typeof response?.then == "function")
|
|
40143
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40144
|
+
if (typeof response?.toResponse == "function")
|
|
40145
|
+
return mapEarlyResponse2(response.toResponse(), set2);
|
|
40146
|
+
if (Array.isArray(response))
|
|
40147
|
+
return Response.json(response);
|
|
40148
|
+
if ("charCodeAt" in response) {
|
|
40149
|
+
const code = response.charCodeAt(0);
|
|
40150
|
+
if (code === 123 || code === 91)
|
|
40151
|
+
return Response.json(response, set2);
|
|
40152
|
+
}
|
|
40153
|
+
return new Response(response);
|
|
40154
|
+
}
|
|
40155
|
+
};
|
|
40156
|
+
var mapCompactResponse2 = (response, request) => {
|
|
40157
|
+
switch (response?.constructor?.name) {
|
|
40158
|
+
case "String":
|
|
40159
|
+
return new Response(response);
|
|
40160
|
+
case "Object":
|
|
40161
|
+
case "Array":
|
|
40162
|
+
return Response.json(response);
|
|
40163
|
+
case "ElysiaFile":
|
|
40164
|
+
return handleFile(response.value);
|
|
40165
|
+
case "File":
|
|
40166
|
+
return handleFile(response);
|
|
40167
|
+
case "Blob":
|
|
40168
|
+
return handleFile(response);
|
|
40169
|
+
case "ElysiaCustomStatusResponse":
|
|
40170
|
+
return mapResponse2(response.response, {
|
|
40171
|
+
status: response.code,
|
|
40172
|
+
headers: {}
|
|
40173
|
+
});
|
|
40174
|
+
case undefined:
|
|
40175
|
+
return response ? Response.json(response) : new Response("");
|
|
40176
|
+
case "Response":
|
|
40177
|
+
return response;
|
|
40178
|
+
case "Error":
|
|
40179
|
+
return errorToResponse2(response);
|
|
40180
|
+
case "Promise":
|
|
40181
|
+
return response.then((x) => mapCompactResponse2(x, request));
|
|
40182
|
+
case "Function":
|
|
40183
|
+
return mapCompactResponse2(response(), request);
|
|
40184
|
+
case "Number":
|
|
40185
|
+
case "Boolean":
|
|
40186
|
+
return new Response(response.toString());
|
|
40187
|
+
case "FormData":
|
|
40188
|
+
return new Response(response);
|
|
40189
|
+
default:
|
|
40190
|
+
if (response instanceof Response)
|
|
40191
|
+
return response;
|
|
40192
|
+
if (response instanceof Promise)
|
|
40193
|
+
return response.then((x) => mapCompactResponse2(x, request));
|
|
40194
|
+
if (response instanceof Error)
|
|
40195
|
+
return errorToResponse2(response);
|
|
40196
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40197
|
+
return mapResponse2(response.response, {
|
|
40198
|
+
status: response.code,
|
|
40199
|
+
headers: {}
|
|
40200
|
+
});
|
|
40201
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40202
|
+
return handleStream2(response, undefined, request);
|
|
40203
|
+
if (typeof response?.then == "function")
|
|
40204
|
+
return response.then((x) => mapCompactResponse2(x, request));
|
|
40205
|
+
if (typeof response?.toResponse == "function")
|
|
40206
|
+
return mapCompactResponse2(response.toResponse());
|
|
40207
|
+
if (Array.isArray(response))
|
|
40208
|
+
return Response.json(response);
|
|
40209
|
+
if ("charCodeAt" in response) {
|
|
40210
|
+
const code = response.charCodeAt(0);
|
|
40211
|
+
if (code === 123 || code === 91)
|
|
40212
|
+
return Response.json(response);
|
|
40213
|
+
}
|
|
40214
|
+
return new Response(response);
|
|
40215
|
+
}
|
|
40216
|
+
};
|
|
40217
|
+
var errorToResponse2 = (error2, set2) => {
|
|
40218
|
+
if (typeof error2?.toResponse == "function") {
|
|
40219
|
+
const raw = error2.toResponse(), targetSet = set2 ?? { headers: {}, status: 200, redirect: "" }, apply = (resolved) => (resolved instanceof Response && (targetSet.status = resolved.status), mapResponse2(resolved, targetSet));
|
|
40220
|
+
return typeof raw?.then == "function" ? raw.then(apply) : apply(raw);
|
|
40221
|
+
}
|
|
40222
|
+
return Response.json({
|
|
40223
|
+
name: error2?.name,
|
|
40224
|
+
message: error2?.message,
|
|
40225
|
+
cause: error2?.cause
|
|
40226
|
+
}, {
|
|
40227
|
+
status: set2?.status !== 200 ? set2?.status ?? 500 : 500,
|
|
40228
|
+
headers: set2?.headers
|
|
40229
|
+
});
|
|
40230
|
+
};
|
|
40231
|
+
var createStaticHandler2 = (handle, hooks, setHeaders = {}) => {
|
|
40232
|
+
if (typeof handle == "function")
|
|
40233
|
+
return;
|
|
40234
|
+
const response = mapResponse2(handle, {
|
|
40235
|
+
headers: setHeaders
|
|
40236
|
+
});
|
|
40237
|
+
if (!hooks.parse?.length && !hooks.transform?.length && !hooks.beforeHandle?.length && !hooks.afterHandle?.length)
|
|
40238
|
+
return () => response.clone();
|
|
40239
|
+
};
|
|
40240
|
+
var handleResponse2 = createResponseHandler({
|
|
40241
|
+
mapResponse: mapResponse2,
|
|
40242
|
+
mapCompactResponse: mapCompactResponse2
|
|
40243
|
+
});
|
|
40244
|
+
var handleStream2 = createStreamHandler({
|
|
40245
|
+
mapResponse: mapResponse2,
|
|
40246
|
+
mapCompactResponse: mapCompactResponse2
|
|
40247
|
+
});
|
|
40248
|
+
|
|
39007
40249
|
// node_modules/elysia/dist/compose.mjs
|
|
39008
40250
|
var import_fast_decode_uri_component3 = __toESM(require_fast_decode_uri_component(), 1);
|
|
39009
40251
|
|
|
@@ -39306,7 +40548,7 @@ var handleTuple = (schema, property, instruction) => {
|
|
|
39306
40548
|
for (let i2 = 0;i2 < schema.length; i2++) {
|
|
39307
40549
|
if (i2 !== 0)
|
|
39308
40550
|
v += ",";
|
|
39309
|
-
v += mirror(schema[i2], joinProperty(property, i2, instruction.parentIsOptional), instruction);
|
|
40551
|
+
v += mirror(schema[i2], joinProperty(property, i2, instruction.parentIsOptional || instruction.fromUnion), instruction);
|
|
39310
40552
|
}
|
|
39311
40553
|
v += `];`;
|
|
39312
40554
|
if (!isRoot)
|
|
@@ -39377,13 +40619,15 @@ var handleUnion = (schemas3, property, instruction) => {
|
|
|
39377
40619
|
v += `if(d.unions[${ui}][${i}].Check(${property})){return ${mirror(type, property, {
|
|
39378
40620
|
...instruction,
|
|
39379
40621
|
recursion: instruction.recursion + 1,
|
|
39380
|
-
parentIsOptional: true
|
|
40622
|
+
parentIsOptional: true,
|
|
40623
|
+
fromUnion: true
|
|
39381
40624
|
})}}
|
|
39382
40625
|
`;
|
|
39383
40626
|
cleanThenCheck += (i ? "" : "let ") + "tmp=" + mirror(type, property, {
|
|
39384
40627
|
...instruction,
|
|
39385
40628
|
recursion: instruction.recursion + 1,
|
|
39386
|
-
parentIsOptional: true
|
|
40629
|
+
parentIsOptional: true,
|
|
40630
|
+
fromUnion: true
|
|
39387
40631
|
}) + `
|
|
39388
40632
|
if(d.unions[${ui}][${i}].Check(tmp))return tmp
|
|
39389
40633
|
`;
|
|
@@ -39423,7 +40667,7 @@ var mirror = (schema, property, instruction) => {
|
|
|
39423
40667
|
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
39424
40668
|
const key = keys[i2];
|
|
39425
40669
|
let isOptional = !schema.required || schema.required && !schema.required.includes(key) || Array.isArray(schema.properties[key].anyOf);
|
|
39426
|
-
const name = joinProperty(property, key, instruction.parentIsOptional);
|
|
40670
|
+
const name = joinProperty(property, key, instruction.parentIsOptional || instruction.fromUnion);
|
|
39427
40671
|
if (isOptional) {
|
|
39428
40672
|
const index = instruction.array;
|
|
39429
40673
|
if (property.startsWith("ar")) {
|
|
@@ -39778,10 +41022,16 @@ var hasElysiaMeta = (meta2, _schema) => {
|
|
|
39778
41022
|
};
|
|
39779
41023
|
var hasProperty = (expectedProperty, _schema) => {
|
|
39780
41024
|
if (!_schema)
|
|
39781
|
-
return;
|
|
41025
|
+
return false;
|
|
39782
41026
|
const schema = _schema.schema ?? _schema;
|
|
39783
41027
|
if (schema[Kind] === "Import" && _schema.References)
|
|
39784
41028
|
return _schema.References().some((schema2) => hasProperty(expectedProperty, schema2));
|
|
41029
|
+
if (schema.anyOf)
|
|
41030
|
+
return schema.anyOf.some((s) => hasProperty(expectedProperty, s));
|
|
41031
|
+
if (schema.allOf)
|
|
41032
|
+
return schema.allOf.some((s) => hasProperty(expectedProperty, s));
|
|
41033
|
+
if (schema.oneOf)
|
|
41034
|
+
return schema.oneOf.some((s) => hasProperty(expectedProperty, s));
|
|
39785
41035
|
if (schema.type === "object") {
|
|
39786
41036
|
const properties = schema.properties;
|
|
39787
41037
|
if (!properties)
|
|
@@ -39933,6 +41183,42 @@ var getSchemaValidator = (s, {
|
|
|
39933
41183
|
};
|
|
39934
41184
|
let schema = mapSchema(s), _validators = validators;
|
|
39935
41185
|
if ("~standard" in schema || validators?.length && validators.some((x) => x && typeof x != "string" && ("~standard" in x))) {
|
|
41186
|
+
let Check22 = function(value, validated = false) {
|
|
41187
|
+
let v = validated ? value : mainCheck.validate(value);
|
|
41188
|
+
if (v instanceof Promise)
|
|
41189
|
+
return v.then((v2) => Check22(v2, true));
|
|
41190
|
+
if (v.issues)
|
|
41191
|
+
return v;
|
|
41192
|
+
const values = [];
|
|
41193
|
+
return v && typeof v == "object" && values.push(v.value), runCheckers2(value, 0, values, v);
|
|
41194
|
+
}, runCheckers2 = function(value, startIndex, values, lastV) {
|
|
41195
|
+
for (let i = startIndex;i < checkers.length; i++) {
|
|
41196
|
+
let v = checkers[i].validate(value);
|
|
41197
|
+
if (v instanceof Promise)
|
|
41198
|
+
return v.then((resolved) => {
|
|
41199
|
+
if (resolved.issues)
|
|
41200
|
+
return resolved;
|
|
41201
|
+
const nextValues = [...values];
|
|
41202
|
+
return resolved && typeof resolved == "object" && nextValues.push(resolved.value), runCheckers2(value, i + 1, nextValues, resolved);
|
|
41203
|
+
});
|
|
41204
|
+
if (v.issues)
|
|
41205
|
+
return v;
|
|
41206
|
+
v && typeof v == "object" && values.push(v.value), lastV = v;
|
|
41207
|
+
}
|
|
41208
|
+
return mergeValues22(values, lastV);
|
|
41209
|
+
}, mergeValues22 = function(values, lastV) {
|
|
41210
|
+
if (!values.length)
|
|
41211
|
+
return { value: lastV };
|
|
41212
|
+
if (values.length === 1)
|
|
41213
|
+
return { value: values[0] };
|
|
41214
|
+
if (values.length === 2)
|
|
41215
|
+
return { value: mergeDeep(values[0], values[1]) };
|
|
41216
|
+
let newValue = mergeDeep(values[0], values[1]);
|
|
41217
|
+
for (let i = 2;i < values.length; i++)
|
|
41218
|
+
newValue = mergeDeep(newValue, values[i]);
|
|
41219
|
+
return { value: newValue };
|
|
41220
|
+
};
|
|
41221
|
+
var Check2 = Check22, runCheckers = runCheckers2, mergeValues2 = mergeValues22;
|
|
39936
41222
|
const typeboxSubValidator = (schema2) => {
|
|
39937
41223
|
let mirror2;
|
|
39938
41224
|
if (normalize === true || normalize === "exactMirror")
|
|
@@ -39955,12 +41241,14 @@ var getSchemaValidator = (s, {
|
|
|
39955
41241
|
coerce,
|
|
39956
41242
|
additionalCoerce
|
|
39957
41243
|
});
|
|
39958
|
-
return vali.Decode = mirror2,
|
|
39959
|
-
|
|
39960
|
-
|
|
39961
|
-
|
|
41244
|
+
return vali.Decode = mirror2, {
|
|
41245
|
+
validate: (v) => vali.Check(v) ? {
|
|
41246
|
+
value: mirror2 ? mirror2(v) : v
|
|
41247
|
+
} : {
|
|
41248
|
+
issues: [...vali.Errors(v)]
|
|
41249
|
+
}
|
|
39962
41250
|
};
|
|
39963
|
-
}, mainCheck = schema["~standard"] ? schema["~standard"]
|
|
41251
|
+
}, mainCheck = schema["~standard"] ? schema["~standard"] : typeboxSubValidator(schema);
|
|
39964
41252
|
let checkers = [];
|
|
39965
41253
|
if (validators?.length) {
|
|
39966
41254
|
for (const validator2 of validators)
|
|
@@ -39975,38 +41263,16 @@ var getSchemaValidator = (s, {
|
|
|
39975
41263
|
}
|
|
39976
41264
|
}
|
|
39977
41265
|
}
|
|
39978
|
-
async function Check2(value) {
|
|
39979
|
-
let v = mainCheck(value);
|
|
39980
|
-
if (v instanceof Promise && (v = await v), v.issues)
|
|
39981
|
-
return v;
|
|
39982
|
-
const values = [];
|
|
39983
|
-
v && typeof v == "object" && values.push(v.value);
|
|
39984
|
-
for (let i = 0;i < checkers.length; i++) {
|
|
39985
|
-
if (v = checkers[i].validate(value), v instanceof Promise && (v = await v), v.issues)
|
|
39986
|
-
return v;
|
|
39987
|
-
v && typeof v == "object" && values.push(v.value);
|
|
39988
|
-
}
|
|
39989
|
-
if (!values.length)
|
|
39990
|
-
return { value: v };
|
|
39991
|
-
if (values.length === 1)
|
|
39992
|
-
return { value: values[0] };
|
|
39993
|
-
if (values.length === 2)
|
|
39994
|
-
return { value: mergeDeep(values[0], values[1]) };
|
|
39995
|
-
let newValue = mergeDeep(values[0], values[1]);
|
|
39996
|
-
for (let i = 2;i < values.length; i++)
|
|
39997
|
-
newValue = mergeDeep(newValue, values[i]);
|
|
39998
|
-
return { value: newValue };
|
|
39999
|
-
}
|
|
40000
41266
|
const validator = {
|
|
40001
41267
|
provider: "standard",
|
|
40002
41268
|
schema,
|
|
40003
41269
|
references: "",
|
|
40004
41270
|
checkFunc: () => {},
|
|
40005
41271
|
code: "",
|
|
40006
|
-
Check:
|
|
40007
|
-
Errors: (value) =>
|
|
41272
|
+
Check: Check22,
|
|
41273
|
+
Errors: (value) => Check22(value)?.then?.((x) => x?.issues),
|
|
40008
41274
|
Code: () => "",
|
|
40009
|
-
Decode:
|
|
41275
|
+
Decode: Check22,
|
|
40010
41276
|
Encode: (value) => value,
|
|
40011
41277
|
hasAdditionalProperties: false,
|
|
40012
41278
|
hasDefault: false,
|
|
@@ -40271,6 +41537,21 @@ var getSchemaValidator = (s, {
|
|
|
40271
41537
|
}), compiled;
|
|
40272
41538
|
};
|
|
40273
41539
|
var isUnion = (schema) => schema[Kind] === "Union" || !schema.schema && !!schema.anyOf;
|
|
41540
|
+
var getSchemaProperties = (schema) => {
|
|
41541
|
+
if (!schema)
|
|
41542
|
+
return;
|
|
41543
|
+
if (schema.properties)
|
|
41544
|
+
return schema.properties;
|
|
41545
|
+
const members = schema.allOf ?? schema.anyOf ?? schema.oneOf;
|
|
41546
|
+
if (members) {
|
|
41547
|
+
const result = {};
|
|
41548
|
+
for (const member of members) {
|
|
41549
|
+
const props = getSchemaProperties(member);
|
|
41550
|
+
props && Object.assign(result, props);
|
|
41551
|
+
}
|
|
41552
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
41553
|
+
}
|
|
41554
|
+
};
|
|
40274
41555
|
var mergeObjectSchemas = (schemas3) => {
|
|
40275
41556
|
if (schemas3.length === 0)
|
|
40276
41557
|
return {
|
|
@@ -40554,7 +41835,7 @@ var isAsync = (v) => {
|
|
|
40554
41835
|
if (isObject3 && v.isAsync !== undefined)
|
|
40555
41836
|
return v.isAsync;
|
|
40556
41837
|
const fn = isObject3 ? v.fn : v;
|
|
40557
|
-
if (fn.constructor.name === "AsyncFunction")
|
|
41838
|
+
if (fn.constructor.name === "AsyncFunction" || fn.constructor.name === "AsyncGeneratorFunction")
|
|
40558
41839
|
return true;
|
|
40559
41840
|
const literal3 = fn.toString();
|
|
40560
41841
|
if (matchResponseClone.test(literal3))
|
|
@@ -40623,8 +41904,14 @@ return function(){return a}`)(handler);
|
|
|
40623
41904
|
if (_encodeCookie)
|
|
40624
41905
|
return _encodeCookie;
|
|
40625
41906
|
if (cookieMeta?.sign) {
|
|
41907
|
+
if (cookieMeta.secrets === "")
|
|
41908
|
+
throw new Error(`cookie secret can't be an empty string at (${method}) ${path2}`, {
|
|
41909
|
+
cause: `(${method}) ${path2}`
|
|
41910
|
+
});
|
|
40626
41911
|
if (!cookieMeta.secrets)
|
|
40627
|
-
throw new Error(`
|
|
41912
|
+
throw new Error(`cookie secret must be defined (${method}) ${path2}`, {
|
|
41913
|
+
cause: `(${method}) ${path2}`
|
|
41914
|
+
});
|
|
40628
41915
|
const secret = cookieMeta.secrets ? typeof cookieMeta.secrets == "string" ? cookieMeta.secrets : cookieMeta.secrets[0] : undefined;
|
|
40629
41916
|
if (_encodeCookie += `const _setCookie = c.set.cookie
|
|
40630
41917
|
if(_setCookie){`, cookieMeta.sign === true)
|
|
@@ -40659,7 +41946,7 @@ if(_setCookie){`, cookieMeta.sign === true)
|
|
|
40659
41946
|
const get = (name, defaultValue) => {
|
|
40660
41947
|
const value = cookieMeta?.[name] ?? defaultValue;
|
|
40661
41948
|
return value === undefined ? "" : value ? typeof value == "string" ? `${name}:${JSON.stringify(value)},` : value instanceof Date ? `${name}: new Date(${value.getTime()}),` : `${name}:${value},` : typeof defaultValue == "string" ? `${name}:"${defaultValue}",` : `${name}:${defaultValue},`;
|
|
40662
|
-
}, options = cookieMeta ? `{secrets:${cookieMeta.secrets !== undefined ? typeof cookieMeta.secrets == "string" ? JSON.stringify(cookieMeta.secrets) : "[" + cookieMeta.secrets.map((x) => JSON.stringify(x)).join(",") + "]" : "undefined"},sign:${cookieMeta.sign === true ? true : cookieMeta.sign !== undefined ? typeof cookieMeta.sign == "string" ? JSON.stringify(cookieMeta.sign) : "[" + cookieMeta.sign.map((x) => JSON.stringify(x)).join(",") + "]" : "undefined"},` + get("domain") + get("expires") + get("httpOnly") + get("maxAge") + get("path", "/") + get("priority") + get("sameSite") + get("secure") + "}" : "undefined";
|
|
41949
|
+
}, options = cookieMeta ? `{secrets:${cookieMeta.secrets !== undefined && cookieMeta.secrets !== null ? typeof cookieMeta.secrets == "string" ? JSON.stringify(cookieMeta.secrets) : "[" + cookieMeta.secrets.map((x) => JSON.stringify(x)).join(",") + "]" : "undefined"},sign:${cookieMeta.sign === true ? true : cookieMeta.sign !== undefined ? typeof cookieMeta.sign == "string" ? JSON.stringify(cookieMeta.sign) : "[" + cookieMeta.sign.map((x) => JSON.stringify(x)).join(",") + "]" : "undefined"},` + get("domain") + get("expires") + get("httpOnly") + get("maxAge") + get("path", "/") + get("priority") + get("sameSite") + get("secure") + "}" : "undefined";
|
|
40663
41950
|
hasHeaders ? fnLiteral += `
|
|
40664
41951
|
c.cookie=await parseCookie(c.set,c.headers.cookie,${options})
|
|
40665
41952
|
` : fnLiteral += `
|
|
@@ -40669,9 +41956,9 @@ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${options})
|
|
|
40669
41956
|
if (hasQuery) {
|
|
40670
41957
|
let arrayProperties = {}, objectProperties = {}, hasArrayProperty = false, hasObjectProperty = false;
|
|
40671
41958
|
if (validator.query?.schema) {
|
|
40672
|
-
const schema = unwrapImportSchema(validator.query?.schema);
|
|
40673
|
-
if (
|
|
40674
|
-
for (const [key, value] of Object.entries(
|
|
41959
|
+
const schema = unwrapImportSchema(validator.query?.schema), properties = getSchemaProperties(schema);
|
|
41960
|
+
if (properties)
|
|
41961
|
+
for (const [key, value] of Object.entries(properties))
|
|
40675
41962
|
hasElysiaMeta("ArrayQuery", value) && (arrayProperties[key] = true, hasArrayProperty = true), hasElysiaMeta("ObjectString", value) && (objectProperties[key] = true, hasObjectProperty = true);
|
|
40676
41963
|
}
|
|
40677
41964
|
fnLiteral += `if(c.qi===-1){c.query=Object.create(null)}else{c.query=parseQueryFromURL(c.url,c.qi+1${hasArrayProperty ? "," + JSON.stringify(arrayProperties) : hasObjectProperty ? ",undefined" : ""}${hasObjectProperty ? "," + JSON.stringify(objectProperties) : ""})}`;
|
|
@@ -40706,8 +41993,8 @@ ${prefix}e.afterResponse[${i}](c)
|
|
|
40706
41993
|
}
|
|
40707
41994
|
return reporter.resolve(), afterResponse2 += `})
|
|
40708
41995
|
`, _afterResponse = afterResponse2;
|
|
40709
|
-
},
|
|
40710
|
-
const after = afterResponse(), response = `${hasSet ? "mapResponse" : "mapCompactResponse"}(${saveResponse}${r}${hasSet ? ",c.set" : ""}${mapResponseContext})
|
|
41996
|
+
}, mapResponse3 = (r = "r") => {
|
|
41997
|
+
const after = afterResponse(), response = `${maybeStream && maybeAsync ? "await " : ""}${hasSet ? "mapResponse" : "mapCompactResponse"}(${saveResponse}${r}${hasSet ? ",c.set" : ""}${mapResponseContext})
|
|
40711
41998
|
`;
|
|
40712
41999
|
return after ? `const _res=${response}` + after + "return _res" : `return ${response}`;
|
|
40713
42000
|
}, mapResponseContext = maybeStream && adapter.mapResponseContext ? `,${adapter.mapResponseContext}` : "";
|
|
@@ -40851,7 +42138,7 @@ case 'multipart/form-data':` + adapter.parser.formData(isOptionalBody) + `break
|
|
|
40851
42138
|
for (const key of Object.keys(app["~parser"]))
|
|
40852
42139
|
fnLiteral += `case '${key}':let bo${key}=parser['${key}'](c,contentType)
|
|
40853
42140
|
if(bo${key} instanceof Promise)bo${key}=await bo${key}
|
|
40854
|
-
if(bo${key} instanceof ElysiaCustomStatusResponse){` +
|
|
42141
|
+
if(bo${key} instanceof ElysiaCustomStatusResponse){` + mapResponse3(`bo${key}`) + `}if(bo${key}!==undefined)c.body=bo${key}
|
|
40855
42142
|
break
|
|
40856
42143
|
`;
|
|
40857
42144
|
hooks.parse?.length && (fnLiteral += "}"), fnLiteral += "}";
|
|
@@ -40872,7 +42159,7 @@ delete c.contentType`);
|
|
|
40872
42159
|
const transform3 = hooks.transform[i], endUnit = reporter.resolveChild(transform3.fn.name);
|
|
40873
42160
|
fnLiteral += isAsync(transform3) ? `transformed=await e.transform[${i}](c)
|
|
40874
42161
|
` : `transformed=e.transform[${i}](c)
|
|
40875
|
-
`, transform3.subType === "mapDerive" ? fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" +
|
|
42162
|
+
`, transform3.subType === "mapDerive" ? fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" + mapResponse3("transformed") + `}else{transformed.request=c.request
|
|
40876
42163
|
transformed.store=c.store
|
|
40877
42164
|
transformed.qi=c.qi
|
|
40878
42165
|
transformed.path=c.path
|
|
@@ -40880,7 +42167,7 @@ transformed.url=c.url
|
|
|
40880
42167
|
transformed.redirect=c.redirect
|
|
40881
42168
|
transformed.set=c.set
|
|
40882
42169
|
transformed.error=c.error
|
|
40883
|
-
c=transformed}` : fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" +
|
|
42170
|
+
c=transformed}` : fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" + mapResponse3("transformed") + `}else Object.assign(c,transformed)
|
|
40884
42171
|
`, endUnit();
|
|
40885
42172
|
}
|
|
40886
42173
|
}
|
|
@@ -40990,12 +42277,7 @@ if(vab.issues){` + validation.validate("body", undefined, "vab.issues") + `}else
|
|
|
40990
42277
|
sanitize: () => app.config.sanitize
|
|
40991
42278
|
});
|
|
40992
42279
|
if (candidate) {
|
|
40993
|
-
const isFirst = fileUnions.length === 0;
|
|
40994
|
-
let properties = candidate.schema?.properties ?? type.properties;
|
|
40995
|
-
if (!properties && candidate.schema?.anyOf) {
|
|
40996
|
-
const objectSchema = candidate.schema.anyOf.find((s) => s.type === "object" || (Kind in s) && s[Kind] === "Object");
|
|
40997
|
-
objectSchema && (properties = objectSchema.properties);
|
|
40998
|
-
}
|
|
42280
|
+
const isFirst = fileUnions.length === 0, properties = getSchemaProperties(candidate.schema) ?? getSchemaProperties(type);
|
|
40999
42281
|
if (!properties)
|
|
41000
42282
|
continue;
|
|
41001
42283
|
const iterator2 = Object.entries(properties);
|
|
@@ -41014,9 +42296,12 @@ if(vab.issues){` + validation.validate("body", undefined, "vab.issues") + `}else
|
|
|
41014
42296
|
}
|
|
41015
42297
|
}
|
|
41016
42298
|
} else if (hasNonUnionFileWithDefault || !hasUnion && (hasType("File", unwrapImportSchema(validator.body.schema)) || hasType("Files", unwrapImportSchema(validator.body.schema)))) {
|
|
41017
|
-
let validateFile2 = ""
|
|
41018
|
-
|
|
41019
|
-
|
|
42299
|
+
let validateFile2 = "";
|
|
42300
|
+
const bodyProperties = getSchemaProperties(unwrapImportSchema(validator.body.schema));
|
|
42301
|
+
let i = 0;
|
|
42302
|
+
if (bodyProperties)
|
|
42303
|
+
for (const [k, v] of Object.entries(bodyProperties))
|
|
42304
|
+
!v.extension || v[Kind] !== "File" && v[Kind] !== "Files" || (i && (validateFile2 += ","), validateFile2 += `fileType(c.body.${k},${JSON.stringify(v.extension)},'body.${k}')`, i++);
|
|
41020
42305
|
i && (fnLiteral += `
|
|
41021
42306
|
`), i === 1 ? fnLiteral += `await ${validateFile2}
|
|
41022
42307
|
` : i > 1 && (fnLiteral += `await Promise.all([${validateFile2}])
|
|
@@ -41044,7 +42329,7 @@ if(vac.issues){` + validation.validate("cookie", undefined, "vac.issues") + `}el
|
|
|
41044
42329
|
let resolved
|
|
41045
42330
|
`), fnLiteral += isAsync(beforeHandle) ? `resolved=await e.beforeHandle[${i}](c);
|
|
41046
42331
|
` : `resolved=e.beforeHandle[${i}](c);
|
|
41047
|
-
`, beforeHandle.subType === "mapResolve" ? fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" +
|
|
42332
|
+
`, beforeHandle.subType === "mapResolve" ? fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" + mapResponse3("resolved") + `}else{resolved.request=c.request
|
|
41048
42333
|
resolved.store=c.store
|
|
41049
42334
|
resolved.qi=c.qi
|
|
41050
42335
|
resolved.path=c.path
|
|
@@ -41052,7 +42337,7 @@ resolved.url=c.url
|
|
|
41052
42337
|
resolved.redirect=c.redirect
|
|
41053
42338
|
resolved.set=c.set
|
|
41054
42339
|
resolved.error=c.error
|
|
41055
|
-
c=resolved}` : fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" +
|
|
42340
|
+
c=resolved}` : fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" + mapResponse3("resolved") + `}else Object.assign(c, resolved)
|
|
41056
42341
|
`, endUnit();
|
|
41057
42342
|
else if (!returning)
|
|
41058
42343
|
fnLiteral += isAsync(beforeHandle) ? `await e.beforeHandle[${i}](c)
|
|
@@ -41108,7 +42393,8 @@ if(mr!==undefined)be=c.response=c.responseValue=mr}`, endUnit2();
|
|
|
41108
42393
|
return () => {
|
|
41109
42394
|
hasTrace && (fnLiteral += 'if(r&&(r[Symbol.iterator]||r[Symbol.asyncIterator])&&typeof r.next==="function"){' + (maybeAsync ? "" : "(async()=>{") + `const stream=await tee(r,3)
|
|
41110
42395
|
r=stream[0]
|
|
41111
|
-
|
|
42396
|
+
` + (hooks.afterHandle?.length ? `c.response=c.responseValue=r
|
|
42397
|
+
` : "") + `const listener=stream[1]
|
|
41112
42398
|
` + (hasTrace || hooks.afterResponse?.length ? `afterHandlerStreamListener=stream[2]
|
|
41113
42399
|
` : "") + `${setImmediateFn}(async ()=>{if(listener)for await(const v of listener){}
|
|
41114
42400
|
`, handleReporter.resolve(), fnLiteral += "})" + (maybeAsync ? "" : "})()") + "}else{", handleReporter.resolve(), fnLiteral += `}
|
|
@@ -41146,7 +42432,7 @@ const listener=stream[1]
|
|
|
41146
42432
|
if(mr!==undefined)r=c.response=c.responseValue=mr
|
|
41147
42433
|
`, endUnit();
|
|
41148
42434
|
}
|
|
41149
|
-
mapResponseReporter.resolve(), fnLiteral +=
|
|
42435
|
+
mapResponseReporter.resolve(), fnLiteral += mapResponse3();
|
|
41150
42436
|
} else {
|
|
41151
42437
|
const resolveHandler = reportHandler(isHandleFn ? handler.name : undefined);
|
|
41152
42438
|
if (validator.response || hooks.mapResponse?.length || hasTrace) {
|
|
@@ -41170,7 +42456,7 @@ if(mr!==undefined)r=c.response=c.responseValue=mr}
|
|
|
41170
42456
|
}
|
|
41171
42457
|
mapResponseReporter.resolve(), fnLiteral += encodeCookie(), handler instanceof Response ? (fnLiteral += afterResponse(), fnLiteral += inference.set ? `if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${saveResponse}${handle}.clone(),c.set${mapResponseContext})
|
|
41172
42458
|
else return ${handle}.clone()` : `return ${handle}.clone()`, fnLiteral += `
|
|
41173
|
-
`) : fnLiteral +=
|
|
42459
|
+
`) : fnLiteral += mapResponse3();
|
|
41174
42460
|
} else if (hasCookie || hasTrace) {
|
|
41175
42461
|
fnLiteral += isAsyncHandler ? `let r=await ${handle}
|
|
41176
42462
|
` : `let r=${handle}
|
|
@@ -41187,14 +42473,14 @@ else return ${handle}.clone()` : `return ${handle}.clone()`, fnLiteral += `
|
|
|
41187
42473
|
if(mr!==undefined)r=c.response=c.responseValue=mr}`, endUnit();
|
|
41188
42474
|
}
|
|
41189
42475
|
}
|
|
41190
|
-
mapResponseReporter.resolve(), fnLiteral += encodeCookie() +
|
|
42476
|
+
mapResponseReporter.resolve(), fnLiteral += encodeCookie() + mapResponse3();
|
|
41191
42477
|
} else {
|
|
41192
42478
|
resolveHandler();
|
|
41193
42479
|
const handled = isAsyncHandler ? `await ${handle}` : handle;
|
|
41194
42480
|
handler instanceof Response ? (fnLiteral += afterResponse(), fnLiteral += inference.set ? `if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${saveResponse}${handle}.clone(),c.set${mapResponseContext})
|
|
41195
42481
|
else return ${handle}.clone()
|
|
41196
42482
|
` : `return ${handle}.clone()
|
|
41197
|
-
`) : fnLiteral +=
|
|
42483
|
+
`) : fnLiteral += mapResponse3(handled);
|
|
41198
42484
|
}
|
|
41199
42485
|
}
|
|
41200
42486
|
if (fnLiteral += `
|
|
@@ -41512,9 +42798,9 @@ error.message=error.response}if(set.status===200||!set.status)set.status=error.s
|
|
|
41512
42798
|
});
|
|
41513
42799
|
if (hooks.mapResponse?.length)
|
|
41514
42800
|
for (let i2 = 0;i2 < hooks.mapResponse.length; i2++) {
|
|
41515
|
-
const
|
|
42801
|
+
const mapResponse3 = hooks.mapResponse[i2], endUnit = mapResponseReporter2.resolveChild(mapResponse3.fn.name);
|
|
41516
42802
|
fnLiteral += `context.response=context.responseValue=_r
|
|
41517
|
-
_r=${isAsyncName(
|
|
42803
|
+
_r=${isAsyncName(mapResponse3) ? "await " : ""}onMapResponse[${i2}](context)
|
|
41518
42804
|
`, endUnit();
|
|
41519
42805
|
}
|
|
41520
42806
|
mapResponseReporter2.resolve(), fnLiteral += afterResponse() + `return mapResponse(${saveResponse}_r,set${adapter.mapResponseContext})}`;
|
|
@@ -41539,8 +42825,8 @@ if(!context.response)context.response=context.responseValue=error.message??error
|
|
|
41539
42825
|
fnLiteral += `let mr
|
|
41540
42826
|
`;
|
|
41541
42827
|
for (let i = 0;i < hooks.mapResponse.length; i++) {
|
|
41542
|
-
const
|
|
41543
|
-
fnLiteral += `if(mr===undefined){mr=${isAsyncName(
|
|
42828
|
+
const mapResponse3 = hooks.mapResponse[i], endUnit = mapResponseReporter.resolveChild(mapResponse3.fn.name);
|
|
42829
|
+
fnLiteral += `if(mr===undefined){mr=${isAsyncName(mapResponse3) ? "await " : ""}onMapResponse[${i}](context)
|
|
41544
42830
|
if(mr!==undefined)error=context.response=context.responseValue=mr}`, endUnit();
|
|
41545
42831
|
}
|
|
41546
42832
|
}
|
|
@@ -41564,587 +42850,6 @@ return mapResponse(${saveResponse}error,set${adapter.mapResponseContext})}`;
|
|
|
41564
42850
|
});
|
|
41565
42851
|
};
|
|
41566
42852
|
|
|
41567
|
-
// node_modules/elysia/dist/adapter/cloudflare-worker/index.mjs
|
|
41568
|
-
function isCloudflareWorker() {
|
|
41569
|
-
try {
|
|
41570
|
-
if (typeof caches < "u" && typeof caches.default < "u" || typeof WebSocketPair < "u")
|
|
41571
|
-
return true;
|
|
41572
|
-
} catch {
|
|
41573
|
-
return false;
|
|
41574
|
-
}
|
|
41575
|
-
return false;
|
|
41576
|
-
}
|
|
41577
|
-
var CloudflareAdapter = {
|
|
41578
|
-
...WebStandardAdapter,
|
|
41579
|
-
name: "cloudflare-worker",
|
|
41580
|
-
composeGeneralHandler: {
|
|
41581
|
-
...WebStandardAdapter.composeGeneralHandler,
|
|
41582
|
-
error404(hasEventHook, hasErrorHook, afterHandle) {
|
|
41583
|
-
const { code } = WebStandardAdapter.composeGeneralHandler.error404(hasEventHook, hasErrorHook, afterHandle);
|
|
41584
|
-
return {
|
|
41585
|
-
code,
|
|
41586
|
-
declare: hasErrorHook ? "" : `const error404Message=notFound.message.toString()
|
|
41587
|
-
const error404={clone:()=>new Response(error404Message,{status:404})}
|
|
41588
|
-
`
|
|
41589
|
-
};
|
|
41590
|
-
}
|
|
41591
|
-
},
|
|
41592
|
-
beforeCompile(app) {
|
|
41593
|
-
app.handleError = composeErrorHandler(app);
|
|
41594
|
-
for (const route of app.routes)
|
|
41595
|
-
route.compile();
|
|
41596
|
-
},
|
|
41597
|
-
listen() {
|
|
41598
|
-
return () => {
|
|
41599
|
-
console.warn("Cloudflare Worker does not support listen method. Please export default Elysia instance instead.");
|
|
41600
|
-
};
|
|
41601
|
-
}
|
|
41602
|
-
};
|
|
41603
|
-
|
|
41604
|
-
// node_modules/elysia/dist/sucrose.mjs
|
|
41605
|
-
var separateFunction = (code) => {
|
|
41606
|
-
code.startsWith("async") && (code = code.slice(5)), code = code.trimStart();
|
|
41607
|
-
let index = -1;
|
|
41608
|
-
if (code.charCodeAt(0) === 40 && (index = code.indexOf("=>", code.indexOf(")")), index !== -1)) {
|
|
41609
|
-
let bracketEndIndex = index;
|
|
41610
|
-
for (;bracketEndIndex > 0 && code.charCodeAt(--bracketEndIndex) !== 41; )
|
|
41611
|
-
;
|
|
41612
|
-
let body = code.slice(index + 2);
|
|
41613
|
-
return body.charCodeAt(0) === 32 && (body = body.trimStart()), [
|
|
41614
|
-
code.slice(1, bracketEndIndex),
|
|
41615
|
-
body,
|
|
41616
|
-
{
|
|
41617
|
-
isArrowReturn: body.charCodeAt(0) !== 123
|
|
41618
|
-
}
|
|
41619
|
-
];
|
|
41620
|
-
}
|
|
41621
|
-
if (/^(\w+)=>/g.test(code) && (index = code.indexOf("=>"), index !== -1)) {
|
|
41622
|
-
let body = code.slice(index + 2);
|
|
41623
|
-
return body.charCodeAt(0) === 32 && (body = body.trimStart()), [
|
|
41624
|
-
code.slice(0, index),
|
|
41625
|
-
body,
|
|
41626
|
-
{
|
|
41627
|
-
isArrowReturn: body.charCodeAt(0) !== 123
|
|
41628
|
-
}
|
|
41629
|
-
];
|
|
41630
|
-
}
|
|
41631
|
-
if (code.startsWith("function")) {
|
|
41632
|
-
index = code.indexOf("(");
|
|
41633
|
-
const end = code.indexOf(")");
|
|
41634
|
-
return [
|
|
41635
|
-
code.slice(index + 1, end),
|
|
41636
|
-
code.slice(end + 2),
|
|
41637
|
-
{
|
|
41638
|
-
isArrowReturn: false
|
|
41639
|
-
}
|
|
41640
|
-
];
|
|
41641
|
-
}
|
|
41642
|
-
const start = code.indexOf("(");
|
|
41643
|
-
if (start !== -1) {
|
|
41644
|
-
const sep = code.indexOf(`
|
|
41645
|
-
`, 2), parameter = code.slice(0, sep), end = parameter.lastIndexOf(")") + 1, body = code.slice(sep + 1);
|
|
41646
|
-
return [
|
|
41647
|
-
parameter.slice(start, end),
|
|
41648
|
-
"{" + body,
|
|
41649
|
-
{
|
|
41650
|
-
isArrowReturn: false
|
|
41651
|
-
}
|
|
41652
|
-
];
|
|
41653
|
-
}
|
|
41654
|
-
const x = code.split(`
|
|
41655
|
-
`, 2);
|
|
41656
|
-
return [x[0], x[1], { isArrowReturn: false }];
|
|
41657
|
-
};
|
|
41658
|
-
var bracketPairRange = (parameter) => {
|
|
41659
|
-
const start = parameter.indexOf("{");
|
|
41660
|
-
if (start === -1)
|
|
41661
|
-
return [-1, 0];
|
|
41662
|
-
let end = start + 1, deep = 1;
|
|
41663
|
-
for (;end < parameter.length; end++) {
|
|
41664
|
-
const char = parameter.charCodeAt(end);
|
|
41665
|
-
if (char === 123 ? deep++ : char === 125 && deep--, deep === 0)
|
|
41666
|
-
break;
|
|
41667
|
-
}
|
|
41668
|
-
return deep !== 0 ? [0, parameter.length] : [start, end + 1];
|
|
41669
|
-
};
|
|
41670
|
-
var bracketPairRangeReverse = (parameter) => {
|
|
41671
|
-
const end = parameter.lastIndexOf("}");
|
|
41672
|
-
if (end === -1)
|
|
41673
|
-
return [-1, 0];
|
|
41674
|
-
let start = end - 1, deep = 1;
|
|
41675
|
-
for (;start >= 0; start--) {
|
|
41676
|
-
const char = parameter.charCodeAt(start);
|
|
41677
|
-
if (char === 125 ? deep++ : char === 123 && deep--, deep === 0)
|
|
41678
|
-
break;
|
|
41679
|
-
}
|
|
41680
|
-
return deep !== 0 ? [-1, 0] : [start, end + 1];
|
|
41681
|
-
};
|
|
41682
|
-
var removeColonAlias = (parameter) => {
|
|
41683
|
-
for (;; ) {
|
|
41684
|
-
const start = parameter.indexOf(":");
|
|
41685
|
-
if (start === -1)
|
|
41686
|
-
break;
|
|
41687
|
-
let end = parameter.indexOf(",", start);
|
|
41688
|
-
end === -1 && (end = parameter.indexOf("}", start) - 1), end === -2 && (end = parameter.length), parameter = parameter.slice(0, start) + parameter.slice(end);
|
|
41689
|
-
}
|
|
41690
|
-
return parameter;
|
|
41691
|
-
};
|
|
41692
|
-
var retrieveRootParamters = (parameter) => {
|
|
41693
|
-
let hasParenthesis = false;
|
|
41694
|
-
parameter.charCodeAt(0) === 40 && (parameter = parameter.slice(1, -1)), parameter.charCodeAt(0) === 123 && (hasParenthesis = true, parameter = parameter.slice(1, -1)), parameter = parameter.replace(/( |\t|\n)/g, "").trim();
|
|
41695
|
-
let parameters = [];
|
|
41696
|
-
for (;; ) {
|
|
41697
|
-
let [start, end] = bracketPairRange(parameter);
|
|
41698
|
-
if (start === -1)
|
|
41699
|
-
break;
|
|
41700
|
-
parameters.push(parameter.slice(0, start - 1)), parameter.charCodeAt(end) === 44 && end++, parameter = parameter.slice(end);
|
|
41701
|
-
}
|
|
41702
|
-
parameter = removeColonAlias(parameter), parameter && (parameters = parameters.concat(parameter.split(",")));
|
|
41703
|
-
const parameterMap = /* @__PURE__ */ Object.create(null);
|
|
41704
|
-
for (const p of parameters) {
|
|
41705
|
-
if (p.indexOf(",") === -1) {
|
|
41706
|
-
parameterMap[p] = true;
|
|
41707
|
-
continue;
|
|
41708
|
-
}
|
|
41709
|
-
for (const q of p.split(","))
|
|
41710
|
-
parameterMap[q.trim()] = true;
|
|
41711
|
-
}
|
|
41712
|
-
return {
|
|
41713
|
-
hasParenthesis,
|
|
41714
|
-
parameters: parameterMap
|
|
41715
|
-
};
|
|
41716
|
-
};
|
|
41717
|
-
var findParameterReference = (parameter, inference) => {
|
|
41718
|
-
const { parameters, hasParenthesis } = retrieveRootParamters(parameter);
|
|
41719
|
-
return parameters.query && (inference.query = true), parameters.headers && (inference.headers = true), parameters.body && (inference.body = true), parameters.cookie && (inference.cookie = true), parameters.set && (inference.set = true), parameters.server && (inference.server = true), parameters.route && (inference.route = true), parameters.url && (inference.url = true), parameters.path && (inference.path = true), hasParenthesis ? `{ ${Object.keys(parameters).join(", ")} }` : Object.keys(parameters).join(", ");
|
|
41720
|
-
};
|
|
41721
|
-
var findEndIndex = (type, content, index) => {
|
|
41722
|
-
const regex2 = new RegExp(`${type.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\n\\t,; ]`);
|
|
41723
|
-
index !== undefined && (regex2.lastIndex = index);
|
|
41724
|
-
const match = regex2.exec(content);
|
|
41725
|
-
return match ? match.index : -1;
|
|
41726
|
-
};
|
|
41727
|
-
var findAlias = (type, body, depth = 0) => {
|
|
41728
|
-
if (depth > 5)
|
|
41729
|
-
return [];
|
|
41730
|
-
const aliases = [];
|
|
41731
|
-
let content = body;
|
|
41732
|
-
for (;; ) {
|
|
41733
|
-
let index = findEndIndex(" = " + type, content);
|
|
41734
|
-
if (index === -1 && (index = findEndIndex("=" + type, content)), index === -1) {
|
|
41735
|
-
let lastIndex = content.indexOf(" = " + type);
|
|
41736
|
-
if (lastIndex === -1 && (lastIndex = content.indexOf("=" + type)), lastIndex + 3 + type.length !== content.length)
|
|
41737
|
-
break;
|
|
41738
|
-
index = lastIndex;
|
|
41739
|
-
}
|
|
41740
|
-
const part = content.slice(0, index), lastPart = part.lastIndexOf(" ");
|
|
41741
|
-
let variable = part.slice(lastPart !== -1 ? lastPart + 1 : -1);
|
|
41742
|
-
if (variable === "}") {
|
|
41743
|
-
const [start, end] = bracketPairRangeReverse(part);
|
|
41744
|
-
aliases.push(removeColonAlias(content.slice(start, end))), content = content.slice(index + 3 + type.length);
|
|
41745
|
-
continue;
|
|
41746
|
-
}
|
|
41747
|
-
for (;variable.charCodeAt(0) === 44; )
|
|
41748
|
-
variable = variable.slice(1);
|
|
41749
|
-
for (;variable.charCodeAt(0) === 9; )
|
|
41750
|
-
variable = variable.slice(1);
|
|
41751
|
-
variable.includes("(") || aliases.push(variable), content = content.slice(index + 3 + type.length);
|
|
41752
|
-
}
|
|
41753
|
-
for (const alias of aliases) {
|
|
41754
|
-
if (alias.charCodeAt(0) === 123)
|
|
41755
|
-
continue;
|
|
41756
|
-
const deepAlias = findAlias(alias, body);
|
|
41757
|
-
deepAlias.length > 0 && aliases.push(...deepAlias);
|
|
41758
|
-
}
|
|
41759
|
-
return aliases;
|
|
41760
|
-
};
|
|
41761
|
-
var extractMainParameter = (parameter) => {
|
|
41762
|
-
if (!parameter)
|
|
41763
|
-
return;
|
|
41764
|
-
if (parameter.charCodeAt(0) !== 123)
|
|
41765
|
-
return parameter;
|
|
41766
|
-
if (parameter = parameter.slice(2, -2), !parameter.includes(","))
|
|
41767
|
-
return parameter.indexOf("...") !== -1 ? parameter.slice(parameter.indexOf("...") + 3) : undefined;
|
|
41768
|
-
const spreadIndex = parameter.indexOf("...");
|
|
41769
|
-
if (spreadIndex !== -1)
|
|
41770
|
-
return parameter.slice(spreadIndex + 3).trimEnd();
|
|
41771
|
-
};
|
|
41772
|
-
var inferBodyReference = (code, aliases, inference) => {
|
|
41773
|
-
const access = (type, alias) => new RegExp(`${alias}\\.(${type})|${alias}\\["${type}"\\]|${alias}\\['${type}'\\]`).test(code);
|
|
41774
|
-
for (const alias of aliases)
|
|
41775
|
-
if (alias) {
|
|
41776
|
-
if (alias.charCodeAt(0) === 123) {
|
|
41777
|
-
const parameters = retrieveRootParamters(alias).parameters;
|
|
41778
|
-
parameters.query && (inference.query = true), parameters.headers && (inference.headers = true), parameters.body && (inference.body = true), parameters.cookie && (inference.cookie = true), parameters.set && (inference.set = true), parameters.server && (inference.server = true), parameters.url && (inference.url = true), parameters.route && (inference.route = true), parameters.path && (inference.path = true);
|
|
41779
|
-
continue;
|
|
41780
|
-
}
|
|
41781
|
-
if (!inference.query && (access("query", alias) || code.includes("return " + alias) || code.includes("return " + alias + ".query")) && (inference.query = true), !inference.headers && access("headers", alias) && (inference.headers = true), !inference.body && access("body", alias) && (inference.body = true), !inference.cookie && access("cookie", alias) && (inference.cookie = true), !inference.set && access("set", alias) && (inference.set = true), !inference.server && access("server", alias) && (inference.server = true), !inference.route && access("route", alias) && (inference.route = true), !inference.url && access("url", alias) && (inference.url = true), !inference.path && access("path", alias) && (inference.path = true), inference.query && inference.headers && inference.body && inference.cookie && inference.set && inference.server && inference.route && inference.url && inference.path)
|
|
41782
|
-
break;
|
|
41783
|
-
}
|
|
41784
|
-
return aliases;
|
|
41785
|
-
};
|
|
41786
|
-
var isContextPassToFunction = (context, body, inference) => {
|
|
41787
|
-
try {
|
|
41788
|
-
const captureFunction = new RegExp(`\\w\\((?:.*?)?${context}(?:.*?)?\\)`, "gs"), exactParameter = new RegExp(`${context}(,|\\))`, "gs"), length = body.length;
|
|
41789
|
-
let fn;
|
|
41790
|
-
for (fn = captureFunction.exec(body) + "";captureFunction.lastIndex !== 0 && captureFunction.lastIndex < length + (fn ? fn.length : 0); ) {
|
|
41791
|
-
if (fn && exactParameter.test(fn))
|
|
41792
|
-
return inference.query = true, inference.headers = true, inference.body = true, inference.cookie = true, inference.set = true, inference.server = true, inference.url = true, inference.route = true, inference.path = true, true;
|
|
41793
|
-
fn = captureFunction.exec(body) + "";
|
|
41794
|
-
}
|
|
41795
|
-
const nextChar = body.charCodeAt(captureFunction.lastIndex);
|
|
41796
|
-
return nextChar === 41 || nextChar === 44 ? (inference.query = true, inference.headers = true, inference.body = true, inference.cookie = true, inference.set = true, inference.server = true, inference.url = true, inference.route = true, inference.path = true, true) : false;
|
|
41797
|
-
} catch {
|
|
41798
|
-
return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"), console.log("--- body ---"), console.log(body), console.log("--- context ---"), console.log(context), true;
|
|
41799
|
-
}
|
|
41800
|
-
};
|
|
41801
|
-
var pendingGC;
|
|
41802
|
-
var caches2 = {};
|
|
41803
|
-
var clearSucroseCache = (delay) => {
|
|
41804
|
-
delay === null || isCloudflareWorker() || (delay === undefined && (delay = 4 * 60 * 1000 + 55 * 1000), pendingGC && clearTimeout(pendingGC), pendingGC = setTimeout(() => {
|
|
41805
|
-
caches2 = {}, pendingGC = undefined, isBun && Bun.gc(false);
|
|
41806
|
-
}, delay), pendingGC.unref?.());
|
|
41807
|
-
};
|
|
41808
|
-
var mergeInference = (a, b) => ({
|
|
41809
|
-
body: a.body || b.body,
|
|
41810
|
-
cookie: a.cookie || b.cookie,
|
|
41811
|
-
headers: a.headers || b.headers,
|
|
41812
|
-
query: a.query || b.query,
|
|
41813
|
-
set: a.set || b.set,
|
|
41814
|
-
server: a.server || b.server,
|
|
41815
|
-
url: a.url || b.url,
|
|
41816
|
-
route: a.route || b.route,
|
|
41817
|
-
path: a.path || b.path
|
|
41818
|
-
});
|
|
41819
|
-
var sucrose = (lifeCycle, inference = {
|
|
41820
|
-
query: false,
|
|
41821
|
-
headers: false,
|
|
41822
|
-
body: false,
|
|
41823
|
-
cookie: false,
|
|
41824
|
-
set: false,
|
|
41825
|
-
server: false,
|
|
41826
|
-
url: false,
|
|
41827
|
-
route: false,
|
|
41828
|
-
path: false
|
|
41829
|
-
}, settings = {}) => {
|
|
41830
|
-
const events = [];
|
|
41831
|
-
lifeCycle.request?.length && events.push(...lifeCycle.request), lifeCycle.beforeHandle?.length && events.push(...lifeCycle.beforeHandle), lifeCycle.parse?.length && events.push(...lifeCycle.parse), lifeCycle.error?.length && events.push(...lifeCycle.error), lifeCycle.transform?.length && events.push(...lifeCycle.transform), lifeCycle.afterHandle?.length && events.push(...lifeCycle.afterHandle), lifeCycle.mapResponse?.length && events.push(...lifeCycle.mapResponse), lifeCycle.afterResponse?.length && events.push(...lifeCycle.afterResponse), lifeCycle.handler && typeof lifeCycle.handler == "function" && events.push(lifeCycle.handler);
|
|
41832
|
-
for (let i = 0;i < events.length; i++) {
|
|
41833
|
-
const e = events[i];
|
|
41834
|
-
if (!e)
|
|
41835
|
-
continue;
|
|
41836
|
-
const event = typeof e == "object" ? e.fn : e;
|
|
41837
|
-
if (typeof event != "function")
|
|
41838
|
-
continue;
|
|
41839
|
-
const content = event.toString(), key = checksum(content), cachedInference = caches2[key];
|
|
41840
|
-
if (cachedInference) {
|
|
41841
|
-
inference = mergeInference(inference, cachedInference);
|
|
41842
|
-
continue;
|
|
41843
|
-
}
|
|
41844
|
-
clearSucroseCache(settings.gcTime);
|
|
41845
|
-
const fnInference = {
|
|
41846
|
-
query: false,
|
|
41847
|
-
headers: false,
|
|
41848
|
-
body: false,
|
|
41849
|
-
cookie: false,
|
|
41850
|
-
set: false,
|
|
41851
|
-
server: false,
|
|
41852
|
-
url: false,
|
|
41853
|
-
route: false,
|
|
41854
|
-
path: false
|
|
41855
|
-
}, [parameter, body] = separateFunction(content), rootParameters = findParameterReference(parameter, fnInference), mainParameter = extractMainParameter(rootParameters);
|
|
41856
|
-
if (mainParameter) {
|
|
41857
|
-
const aliases = findAlias(mainParameter, body.slice(1, -1));
|
|
41858
|
-
aliases.splice(0, -1, mainParameter);
|
|
41859
|
-
let code = body;
|
|
41860
|
-
code.charCodeAt(0) === 123 && code.charCodeAt(body.length - 1) === 125 && (code = code.slice(1, -1).trim()), isContextPassToFunction(mainParameter, code, fnInference) || inferBodyReference(code, aliases, fnInference), !fnInference.query && code.includes("return " + mainParameter + ".query") && (fnInference.query = true);
|
|
41861
|
-
}
|
|
41862
|
-
if (caches2[key] || (caches2[key] = fnInference), inference = mergeInference(inference, fnInference), inference.query && inference.headers && inference.body && inference.cookie && inference.set && inference.server && inference.url && inference.route && inference.path)
|
|
41863
|
-
break;
|
|
41864
|
-
}
|
|
41865
|
-
return inference;
|
|
41866
|
-
};
|
|
41867
|
-
|
|
41868
|
-
// node_modules/elysia/dist/adapter/bun/handler.mjs
|
|
41869
|
-
var mapResponse2 = (response, set2, request) => {
|
|
41870
|
-
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.cookie)
|
|
41871
|
-
switch (handleSet(set2), response?.constructor?.name) {
|
|
41872
|
-
case "String":
|
|
41873
|
-
return new Response(response, set2);
|
|
41874
|
-
case "Array":
|
|
41875
|
-
case "Object":
|
|
41876
|
-
return set2.headers["content-type"] = "application/json", new Response(JSON.stringify(response), set2);
|
|
41877
|
-
case "ElysiaFile":
|
|
41878
|
-
return handleFile(response.value, set2);
|
|
41879
|
-
case "File":
|
|
41880
|
-
return handleFile(response, set2);
|
|
41881
|
-
case "Blob":
|
|
41882
|
-
return handleFile(response, set2);
|
|
41883
|
-
case "ElysiaCustomStatusResponse":
|
|
41884
|
-
return set2.status = response.code, mapResponse2(response.response, set2, request);
|
|
41885
|
-
case undefined:
|
|
41886
|
-
return response ? new Response(JSON.stringify(response), set2) : new Response("", set2);
|
|
41887
|
-
case "Response":
|
|
41888
|
-
return handleResponse2(response, set2, request);
|
|
41889
|
-
case "Error":
|
|
41890
|
-
return errorToResponse2(response, set2);
|
|
41891
|
-
case "Promise":
|
|
41892
|
-
return response.then((x) => mapResponse2(x, set2, request));
|
|
41893
|
-
case "Function":
|
|
41894
|
-
return mapResponse2(response(), set2, request);
|
|
41895
|
-
case "Number":
|
|
41896
|
-
case "Boolean":
|
|
41897
|
-
return new Response(response.toString(), set2);
|
|
41898
|
-
case "Cookie":
|
|
41899
|
-
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
41900
|
-
case "FormData":
|
|
41901
|
-
return new Response(response, set2);
|
|
41902
|
-
default:
|
|
41903
|
-
if (response instanceof Response)
|
|
41904
|
-
return handleResponse2(response, set2, request);
|
|
41905
|
-
if (response instanceof Promise)
|
|
41906
|
-
return response.then((x) => mapResponse2(x, set2));
|
|
41907
|
-
if (response instanceof Error)
|
|
41908
|
-
return errorToResponse2(response, set2);
|
|
41909
|
-
if (response instanceof ElysiaCustomStatusResponse)
|
|
41910
|
-
return set2.status = response.code, mapResponse2(response.response, set2, request);
|
|
41911
|
-
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
41912
|
-
return handleStream2(response, set2, request);
|
|
41913
|
-
if (typeof response?.then == "function")
|
|
41914
|
-
return response.then((x) => mapResponse2(x, set2));
|
|
41915
|
-
if (typeof response?.toResponse == "function")
|
|
41916
|
-
return mapResponse2(response.toResponse(), set2);
|
|
41917
|
-
if ("charCodeAt" in response) {
|
|
41918
|
-
const code = response.charCodeAt(0);
|
|
41919
|
-
if (code === 123 || code === 91)
|
|
41920
|
-
return set2.headers["Content-Type"] || (set2.headers["Content-Type"] = "application/json"), new Response(JSON.stringify(response), set2);
|
|
41921
|
-
}
|
|
41922
|
-
return new Response(response, set2);
|
|
41923
|
-
}
|
|
41924
|
-
return typeof response?.next == "function" || response instanceof ReadableStream ? handleStream2(response, set2, request) : mapCompactResponse2(response, request);
|
|
41925
|
-
};
|
|
41926
|
-
var mapEarlyResponse2 = (response, set2, request) => {
|
|
41927
|
-
if (response != null)
|
|
41928
|
-
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.cookie)
|
|
41929
|
-
switch (handleSet(set2), response?.constructor?.name) {
|
|
41930
|
-
case "String":
|
|
41931
|
-
return new Response(response, set2);
|
|
41932
|
-
case "Array":
|
|
41933
|
-
case "Object":
|
|
41934
|
-
return set2.headers["content-type"] = "application/json", new Response(JSON.stringify(response), set2);
|
|
41935
|
-
case "ElysiaFile":
|
|
41936
|
-
return handleFile(response.value, set2);
|
|
41937
|
-
case "File":
|
|
41938
|
-
return handleFile(response, set2);
|
|
41939
|
-
case "Blob":
|
|
41940
|
-
return handleFile(response, set2);
|
|
41941
|
-
case "ElysiaCustomStatusResponse":
|
|
41942
|
-
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
41943
|
-
case undefined:
|
|
41944
|
-
return response ? new Response(JSON.stringify(response), set2) : undefined;
|
|
41945
|
-
case "Response":
|
|
41946
|
-
return handleResponse2(response, set2, request);
|
|
41947
|
-
case "Promise":
|
|
41948
|
-
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
41949
|
-
case "Error":
|
|
41950
|
-
return errorToResponse2(response, set2);
|
|
41951
|
-
case "Function":
|
|
41952
|
-
return mapEarlyResponse2(response(), set2);
|
|
41953
|
-
case "Number":
|
|
41954
|
-
case "Boolean":
|
|
41955
|
-
return new Response(response.toString(), set2);
|
|
41956
|
-
case "FormData":
|
|
41957
|
-
return new Response(response);
|
|
41958
|
-
case "Cookie":
|
|
41959
|
-
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
41960
|
-
default:
|
|
41961
|
-
if (response instanceof Response)
|
|
41962
|
-
return handleResponse2(response, set2, request);
|
|
41963
|
-
if (response instanceof Promise)
|
|
41964
|
-
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
41965
|
-
if (response instanceof Error)
|
|
41966
|
-
return errorToResponse2(response, set2);
|
|
41967
|
-
if (response instanceof ElysiaCustomStatusResponse)
|
|
41968
|
-
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
41969
|
-
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
41970
|
-
return handleStream2(response, set2, request);
|
|
41971
|
-
if (typeof response?.then == "function")
|
|
41972
|
-
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
41973
|
-
if (typeof response?.toResponse == "function")
|
|
41974
|
-
return mapEarlyResponse2(response.toResponse(), set2);
|
|
41975
|
-
if ("charCodeAt" in response) {
|
|
41976
|
-
const code = response.charCodeAt(0);
|
|
41977
|
-
if (code === 123 || code === 91)
|
|
41978
|
-
return set2.headers["Content-Type"] || (set2.headers["Content-Type"] = "application/json"), new Response(JSON.stringify(response), set2);
|
|
41979
|
-
}
|
|
41980
|
-
return new Response(response, set2);
|
|
41981
|
-
}
|
|
41982
|
-
else
|
|
41983
|
-
switch (response?.constructor?.name) {
|
|
41984
|
-
case "String":
|
|
41985
|
-
return new Response(response);
|
|
41986
|
-
case "Array":
|
|
41987
|
-
case "Object":
|
|
41988
|
-
return set2.headers["content-type"] = "application/json", new Response(JSON.stringify(response), set2);
|
|
41989
|
-
case "ElysiaFile":
|
|
41990
|
-
return handleFile(response.value, set2);
|
|
41991
|
-
case "File":
|
|
41992
|
-
return handleFile(response, set2);
|
|
41993
|
-
case "Blob":
|
|
41994
|
-
return handleFile(response, set2);
|
|
41995
|
-
case "ElysiaCustomStatusResponse":
|
|
41996
|
-
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
41997
|
-
case undefined:
|
|
41998
|
-
return response ? new Response(JSON.stringify(response), {
|
|
41999
|
-
headers: {
|
|
42000
|
-
"content-type": "application/json"
|
|
42001
|
-
}
|
|
42002
|
-
}) : new Response("");
|
|
42003
|
-
case "Response":
|
|
42004
|
-
return response;
|
|
42005
|
-
case "Promise":
|
|
42006
|
-
return response.then((x) => {
|
|
42007
|
-
const r = mapEarlyResponse2(x, set2);
|
|
42008
|
-
if (r !== undefined)
|
|
42009
|
-
return r;
|
|
42010
|
-
});
|
|
42011
|
-
case "Error":
|
|
42012
|
-
return errorToResponse2(response, set2);
|
|
42013
|
-
case "Function":
|
|
42014
|
-
return mapCompactResponse2(response(), request);
|
|
42015
|
-
case "Number":
|
|
42016
|
-
case "Boolean":
|
|
42017
|
-
return new Response(response.toString());
|
|
42018
|
-
case "Cookie":
|
|
42019
|
-
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
42020
|
-
case "FormData":
|
|
42021
|
-
return new Response(response);
|
|
42022
|
-
default:
|
|
42023
|
-
if (response instanceof Response)
|
|
42024
|
-
return response;
|
|
42025
|
-
if (response instanceof Promise)
|
|
42026
|
-
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
42027
|
-
if (response instanceof Error)
|
|
42028
|
-
return errorToResponse2(response, set2);
|
|
42029
|
-
if (response instanceof ElysiaCustomStatusResponse)
|
|
42030
|
-
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
42031
|
-
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
42032
|
-
return handleStream2(response, set2, request);
|
|
42033
|
-
if (typeof response?.then == "function")
|
|
42034
|
-
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
42035
|
-
if (typeof response?.toResponse == "function")
|
|
42036
|
-
return mapEarlyResponse2(response.toResponse(), set2);
|
|
42037
|
-
if ("charCodeAt" in response) {
|
|
42038
|
-
const code = response.charCodeAt(0);
|
|
42039
|
-
if (code === 123 || code === 91)
|
|
42040
|
-
return set2.headers["Content-Type"] || (set2.headers["Content-Type"] = "application/json"), new Response(JSON.stringify(response), set2);
|
|
42041
|
-
}
|
|
42042
|
-
return new Response(response);
|
|
42043
|
-
}
|
|
42044
|
-
};
|
|
42045
|
-
var mapCompactResponse2 = (response, request) => {
|
|
42046
|
-
switch (response?.constructor?.name) {
|
|
42047
|
-
case "String":
|
|
42048
|
-
return new Response(response);
|
|
42049
|
-
case "Object":
|
|
42050
|
-
case "Array":
|
|
42051
|
-
return new Response(JSON.stringify(response), {
|
|
42052
|
-
headers: {
|
|
42053
|
-
"Content-Type": "application/json"
|
|
42054
|
-
}
|
|
42055
|
-
});
|
|
42056
|
-
case "ElysiaFile":
|
|
42057
|
-
return handleFile(response.value);
|
|
42058
|
-
case "File":
|
|
42059
|
-
return handleFile(response);
|
|
42060
|
-
case "Blob":
|
|
42061
|
-
return handleFile(response);
|
|
42062
|
-
case "ElysiaCustomStatusResponse":
|
|
42063
|
-
return mapResponse2(response.response, {
|
|
42064
|
-
status: response.code,
|
|
42065
|
-
headers: {}
|
|
42066
|
-
});
|
|
42067
|
-
case undefined:
|
|
42068
|
-
return response ? new Response(JSON.stringify(response), {
|
|
42069
|
-
headers: {
|
|
42070
|
-
"content-type": "application/json"
|
|
42071
|
-
}
|
|
42072
|
-
}) : new Response("");
|
|
42073
|
-
case "Response":
|
|
42074
|
-
return response;
|
|
42075
|
-
case "Error":
|
|
42076
|
-
return errorToResponse2(response);
|
|
42077
|
-
case "Promise":
|
|
42078
|
-
return response.then((x) => mapCompactResponse2(x, request));
|
|
42079
|
-
case "Function":
|
|
42080
|
-
return mapCompactResponse2(response(), request);
|
|
42081
|
-
case "Number":
|
|
42082
|
-
case "Boolean":
|
|
42083
|
-
return new Response(response.toString());
|
|
42084
|
-
case "FormData":
|
|
42085
|
-
return new Response(response);
|
|
42086
|
-
default:
|
|
42087
|
-
if (response instanceof Response)
|
|
42088
|
-
return response;
|
|
42089
|
-
if (response instanceof Promise)
|
|
42090
|
-
return response.then((x) => mapCompactResponse2(x, request));
|
|
42091
|
-
if (response instanceof Error)
|
|
42092
|
-
return errorToResponse2(response);
|
|
42093
|
-
if (response instanceof ElysiaCustomStatusResponse)
|
|
42094
|
-
return mapResponse2(response.response, {
|
|
42095
|
-
status: response.code,
|
|
42096
|
-
headers: {}
|
|
42097
|
-
});
|
|
42098
|
-
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
42099
|
-
return handleStream2(response, undefined, request);
|
|
42100
|
-
if (typeof response?.then == "function")
|
|
42101
|
-
return response.then((x) => mapCompactResponse2(x, request));
|
|
42102
|
-
if (typeof response?.toResponse == "function")
|
|
42103
|
-
return mapCompactResponse2(response.toResponse());
|
|
42104
|
-
if ("charCodeAt" in response) {
|
|
42105
|
-
const code = response.charCodeAt(0);
|
|
42106
|
-
if (code === 123 || code === 91)
|
|
42107
|
-
return new Response(JSON.stringify(response), {
|
|
42108
|
-
headers: {
|
|
42109
|
-
"Content-Type": "application/json"
|
|
42110
|
-
}
|
|
42111
|
-
});
|
|
42112
|
-
}
|
|
42113
|
-
return new Response(response);
|
|
42114
|
-
}
|
|
42115
|
-
};
|
|
42116
|
-
var errorToResponse2 = (error2, set2) => {
|
|
42117
|
-
if (typeof error2?.toResponse == "function") {
|
|
42118
|
-
const raw = error2.toResponse(), targetSet = set2 ?? { headers: {}, status: 200, redirect: "" }, apply = (resolved) => (resolved instanceof Response && (targetSet.status = resolved.status), mapResponse2(resolved, targetSet));
|
|
42119
|
-
return typeof raw?.then == "function" ? raw.then(apply) : apply(raw);
|
|
42120
|
-
}
|
|
42121
|
-
return new Response(JSON.stringify({
|
|
42122
|
-
name: error2?.name,
|
|
42123
|
-
message: error2?.message,
|
|
42124
|
-
cause: error2?.cause
|
|
42125
|
-
}), {
|
|
42126
|
-
status: set2?.status !== 200 ? set2?.status ?? 500 : 500,
|
|
42127
|
-
headers: set2?.headers
|
|
42128
|
-
});
|
|
42129
|
-
};
|
|
42130
|
-
var createStaticHandler2 = (handle, hooks, setHeaders = {}) => {
|
|
42131
|
-
if (typeof handle == "function")
|
|
42132
|
-
return;
|
|
42133
|
-
const response = mapResponse2(handle, {
|
|
42134
|
-
headers: setHeaders
|
|
42135
|
-
});
|
|
42136
|
-
if (!hooks.parse?.length && !hooks.transform?.length && !hooks.beforeHandle?.length && !hooks.afterHandle?.length)
|
|
42137
|
-
return () => response.clone();
|
|
42138
|
-
};
|
|
42139
|
-
var handleResponse2 = createResponseHandler({
|
|
42140
|
-
mapResponse: mapResponse2,
|
|
42141
|
-
mapCompactResponse: mapCompactResponse2
|
|
42142
|
-
});
|
|
42143
|
-
var handleStream2 = createStreamHandler({
|
|
42144
|
-
mapResponse: mapResponse2,
|
|
42145
|
-
mapCompactResponse: mapCompactResponse2
|
|
42146
|
-
});
|
|
42147
|
-
|
|
42148
42853
|
// node_modules/elysia/dist/adapter/bun/compose.mjs
|
|
42149
42854
|
var allocateIf2 = (value, condition) => condition ? value : "";
|
|
42150
42855
|
var createContext = (app, route, inference, isInline = false) => {
|
|
@@ -42202,7 +42907,7 @@ var createNativeStaticHandler = (handle, hooks, set2) => {
|
|
|
42202
42907
|
return;
|
|
42203
42908
|
if (isHTMLBundle(handle))
|
|
42204
42909
|
return () => handle;
|
|
42205
|
-
const response = mapResponse2(handle, set2 ?? {
|
|
42910
|
+
const response = mapResponse2(handle instanceof Response ? handle.clone() : handle instanceof Promise ? handle.then((x) => x instanceof Response ? x.clone() : x) : handle, set2 ?? {
|
|
42206
42911
|
headers: {}
|
|
42207
42912
|
});
|
|
42208
42913
|
if (!hooks.parse?.length && !hooks.transform?.length && !hooks.beforeHandle?.length && !hooks.afterHandle?.length)
|
|
@@ -42388,6 +43093,11 @@ var mergeRoutes = (r1, r2) => {
|
|
|
42388
43093
|
}
|
|
42389
43094
|
return r1;
|
|
42390
43095
|
};
|
|
43096
|
+
var removeTrailingPath = (routes) => {
|
|
43097
|
+
for (const key of Object.keys(routes))
|
|
43098
|
+
key.charCodeAt(key.length - 1) === 47 && (routes[key.slice(0, -1)] = routes[key], delete routes[key]);
|
|
43099
|
+
return routes;
|
|
43100
|
+
};
|
|
42391
43101
|
var BunAdapter = {
|
|
42392
43102
|
...WebStandardAdapter,
|
|
42393
43103
|
name: "bun",
|
|
@@ -42444,13 +43154,13 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42444
43154
|
staticRoutes[path2] = route;
|
|
42445
43155
|
}
|
|
42446
43156
|
return withAsync ? Promise.all(ops).then(() => staticRoutes) : staticRoutes;
|
|
42447
|
-
}, serve = typeof options == "object" ? {
|
|
43157
|
+
}, routes = removeTrailingPath(mergeRoutes(mergeRoutes(createStaticRoute(app.router.response), mapRoutes(app)), app.config.serve?.routes)), serve = typeof options == "object" ? {
|
|
42448
43158
|
development: !isProduction2,
|
|
42449
43159
|
reusePort: true,
|
|
42450
43160
|
idleTimeout: 30,
|
|
42451
43161
|
...app.config.serve || {},
|
|
42452
43162
|
...options || {},
|
|
42453
|
-
routes
|
|
43163
|
+
routes,
|
|
42454
43164
|
websocket: {
|
|
42455
43165
|
...app.config.websocket || {},
|
|
42456
43166
|
...websocket || {},
|
|
@@ -42462,7 +43172,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42462
43172
|
reusePort: true,
|
|
42463
43173
|
idleTimeout: 30,
|
|
42464
43174
|
...app.config.serve || {},
|
|
42465
|
-
routes
|
|
43175
|
+
routes,
|
|
42466
43176
|
websocket: {
|
|
42467
43177
|
...app.config.websocket || {},
|
|
42468
43178
|
...websocket || {}
|
|
@@ -42478,12 +43188,14 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42478
43188
|
for (let i = 0;i < app.event.stop.length; i++)
|
|
42479
43189
|
app.event.stop[i].fn(app);
|
|
42480
43190
|
}), app.promisedModules.then(async () => {
|
|
42481
|
-
app.config.aot, app.compile()
|
|
43191
|
+
app.config.aot, app.compile();
|
|
43192
|
+
const routes2 = removeTrailingPath(mergeRoutes(mergeRoutes(await createStaticRoute(app.router.response, {
|
|
43193
|
+
withAsync: true
|
|
43194
|
+
}), mapRoutes(app)), app.config.serve?.routes));
|
|
43195
|
+
app.server?.reload({
|
|
42482
43196
|
...serve,
|
|
42483
43197
|
fetch: app.fetch,
|
|
42484
|
-
routes:
|
|
42485
|
-
withAsync: true
|
|
42486
|
-
}), mapRoutes(app)), app.config.serve?.routes)
|
|
43198
|
+
routes: routes2
|
|
42487
43199
|
}), Bun?.gc(false);
|
|
42488
43200
|
});
|
|
42489
43201
|
};
|
|
@@ -42593,10 +43305,81 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42593
43305
|
};
|
|
42594
43306
|
|
|
42595
43307
|
// node_modules/elysia/dist/dynamic-handle.mjs
|
|
43308
|
+
var ARRAY_INDEX_REGEX = /^(.+)\[(\d+)\]$/;
|
|
43309
|
+
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
43310
|
+
var isDangerousKey = (key) => {
|
|
43311
|
+
if (DANGEROUS_KEYS.has(key))
|
|
43312
|
+
return true;
|
|
43313
|
+
const match = key.match(ARRAY_INDEX_REGEX);
|
|
43314
|
+
return match ? DANGEROUS_KEYS.has(match[1]) : false;
|
|
43315
|
+
};
|
|
43316
|
+
var parseArrayKey = (key) => {
|
|
43317
|
+
const match = key.match(ARRAY_INDEX_REGEX);
|
|
43318
|
+
return match ? {
|
|
43319
|
+
name: match[1],
|
|
43320
|
+
index: parseInt(match[2], 10)
|
|
43321
|
+
} : null;
|
|
43322
|
+
};
|
|
43323
|
+
var parseObjectString = (entry) => {
|
|
43324
|
+
if (!(typeof entry != "string" || entry.charCodeAt(0) !== 123))
|
|
43325
|
+
try {
|
|
43326
|
+
const parsed = JSON.parse(entry);
|
|
43327
|
+
if (parsed && typeof parsed == "object" && !Array.isArray(parsed))
|
|
43328
|
+
return parsed;
|
|
43329
|
+
} catch {
|
|
43330
|
+
return;
|
|
43331
|
+
}
|
|
43332
|
+
};
|
|
43333
|
+
var setNestedValue = (obj, path2, value) => {
|
|
43334
|
+
const keys = path2.split("."), lastKey = keys.pop();
|
|
43335
|
+
if (isDangerousKey(lastKey) || keys.some(isDangerousKey))
|
|
43336
|
+
return;
|
|
43337
|
+
let current = obj;
|
|
43338
|
+
for (const key of keys) {
|
|
43339
|
+
const arrayInfo2 = parseArrayKey(key);
|
|
43340
|
+
if (arrayInfo2) {
|
|
43341
|
+
Array.isArray(current[arrayInfo2.name]) || (current[arrayInfo2.name] = []);
|
|
43342
|
+
const existing = current[arrayInfo2.name][arrayInfo2.index], isFile = typeof File < "u" && existing instanceof File;
|
|
43343
|
+
(!existing || typeof existing != "object" || Array.isArray(existing) || isFile) && (current[arrayInfo2.name][arrayInfo2.index] = parseObjectString(existing) ?? {}), current = current[arrayInfo2.name][arrayInfo2.index];
|
|
43344
|
+
} else
|
|
43345
|
+
(!current[key] || typeof current[key] != "object") && (current[key] = {}), current = current[key];
|
|
43346
|
+
}
|
|
43347
|
+
const arrayInfo = parseArrayKey(lastKey);
|
|
43348
|
+
arrayInfo ? (Array.isArray(current[arrayInfo.name]) || (current[arrayInfo.name] = []), current[arrayInfo.name][arrayInfo.index] = value) : current[lastKey] = value;
|
|
43349
|
+
};
|
|
43350
|
+
var normalizeFormValue = (value) => {
|
|
43351
|
+
if (value.length === 1) {
|
|
43352
|
+
const stringValue2 = value[0];
|
|
43353
|
+
if (typeof stringValue2 == "string" && (stringValue2.charCodeAt(0) === 123 || stringValue2.charCodeAt(0) === 91))
|
|
43354
|
+
try {
|
|
43355
|
+
const parsed2 = JSON.parse(stringValue2);
|
|
43356
|
+
if (parsed2 && typeof parsed2 == "object")
|
|
43357
|
+
return parsed2;
|
|
43358
|
+
} catch {}
|
|
43359
|
+
return value[0];
|
|
43360
|
+
}
|
|
43361
|
+
const stringValue = value.find((entry) => typeof entry == "string");
|
|
43362
|
+
if (!stringValue || typeof File > "u")
|
|
43363
|
+
return value;
|
|
43364
|
+
const files = value.filter((entry) => entry instanceof File);
|
|
43365
|
+
if (!files.length || stringValue.charCodeAt(0) !== 123)
|
|
43366
|
+
return value;
|
|
43367
|
+
let parsed;
|
|
43368
|
+
try {
|
|
43369
|
+
parsed = JSON.parse(stringValue);
|
|
43370
|
+
} catch {
|
|
43371
|
+
return value;
|
|
43372
|
+
}
|
|
43373
|
+
return typeof parsed != "object" || parsed === null ? value : (!("file" in parsed) && files.length === 1 ? parsed.file = files[0] : !("files" in parsed) && files.length > 1 && (parsed.files = files), parsed);
|
|
43374
|
+
};
|
|
42596
43375
|
var injectDefaultValues = (typeChecker, obj) => {
|
|
42597
43376
|
let schema = typeChecker.schema;
|
|
42598
|
-
if (schema
|
|
42599
|
-
|
|
43377
|
+
if (!schema)
|
|
43378
|
+
return;
|
|
43379
|
+
schema.$defs?.[schema.$ref] && (schema = schema.$defs[schema.$ref]);
|
|
43380
|
+
const properties = getSchemaProperties(schema);
|
|
43381
|
+
if (properties)
|
|
43382
|
+
for (const [key, keySchema] of Object.entries(properties))
|
|
42600
43383
|
obj[key] ??= keySchema.default;
|
|
42601
43384
|
};
|
|
42602
43385
|
var createDynamicHandler = (app) => {
|
|
@@ -42653,8 +43436,8 @@ var createDynamicHandler = (app) => {
|
|
|
42653
43436
|
for (const key of form2.keys()) {
|
|
42654
43437
|
if (body[key])
|
|
42655
43438
|
continue;
|
|
42656
|
-
const value = form2.getAll(key);
|
|
42657
|
-
|
|
43439
|
+
const value = form2.getAll(key), finalValue = normalizeFormValue(value);
|
|
43440
|
+
key.includes(".") || key.includes("[") ? setNestedValue(body, key, finalValue) : body[key] = finalValue;
|
|
42658
43441
|
}
|
|
42659
43442
|
break;
|
|
42660
43443
|
}
|
|
@@ -42691,8 +43474,8 @@ var createDynamicHandler = (app) => {
|
|
|
42691
43474
|
for (const key of form2.keys()) {
|
|
42692
43475
|
if (body[key])
|
|
42693
43476
|
continue;
|
|
42694
|
-
const value = form2.getAll(key);
|
|
42695
|
-
|
|
43477
|
+
const value = form2.getAll(key), finalValue = normalizeFormValue(value);
|
|
43478
|
+
key.includes(".") || key.includes("[") ? setNestedValue(body, key, finalValue) : body[key] = finalValue;
|
|
42696
43479
|
}
|
|
42697
43480
|
break;
|
|
42698
43481
|
}
|
|
@@ -42736,8 +43519,8 @@ var createDynamicHandler = (app) => {
|
|
|
42736
43519
|
for (const key of form2.keys()) {
|
|
42737
43520
|
if (body[key])
|
|
42738
43521
|
continue;
|
|
42739
|
-
const value = form2.getAll(key);
|
|
42740
|
-
|
|
43522
|
+
const value = form2.getAll(key), finalValue = normalizeFormValue(value);
|
|
43523
|
+
key.includes(".") || key.includes("[") ? setNestedValue(body, key, finalValue) : body[key] = finalValue;
|
|
42741
43524
|
}
|
|
42742
43525
|
break;
|
|
42743
43526
|
}
|
|
@@ -42791,11 +43574,12 @@ var createDynamicHandler = (app) => {
|
|
|
42791
43574
|
if (validator.params?.Decode && (context.params = validator.params.Decode(context.params)), validator.query?.schema) {
|
|
42792
43575
|
let schema = validator.query.schema;
|
|
42793
43576
|
schema.$defs?.[schema.$ref] && (schema = schema.$defs[schema.$ref]);
|
|
42794
|
-
const properties = schema
|
|
42795
|
-
|
|
42796
|
-
const
|
|
42797
|
-
|
|
42798
|
-
|
|
43577
|
+
const properties = getSchemaProperties(schema);
|
|
43578
|
+
if (properties)
|
|
43579
|
+
for (const property of Object.keys(properties)) {
|
|
43580
|
+
const value = properties[property];
|
|
43581
|
+
(value.type === "array" || value.items?.type === "string") && typeof context.query[property] == "string" && context.query[property] && (context.query[property] = context.query[property].split(","));
|
|
43582
|
+
}
|
|
42799
43583
|
}
|
|
42800
43584
|
if (queryValidator?.Check(context.query) === false)
|
|
42801
43585
|
throw new ValidationError2("query", validator.query, context.query);
|
|
@@ -42809,7 +43593,10 @@ var createDynamicHandler = (app) => {
|
|
|
42809
43593
|
}
|
|
42810
43594
|
if (validator.createBody?.()?.Check(body) === false)
|
|
42811
43595
|
throw new ValidationError2("body", validator.body, body);
|
|
42812
|
-
|
|
43596
|
+
if (validator.body?.Decode) {
|
|
43597
|
+
let decoded = validator.body.Decode(body);
|
|
43598
|
+
decoded instanceof Promise && (decoded = await decoded), context.body = decoded?.value ?? decoded;
|
|
43599
|
+
}
|
|
42813
43600
|
}
|
|
42814
43601
|
if (hooks.beforeHandle)
|
|
42815
43602
|
for (let i = 0;i < hooks.beforeHandle.length; i++) {
|
|
@@ -42845,14 +43632,21 @@ var createDynamicHandler = (app) => {
|
|
|
42845
43632
|
isCustomStatuResponse && (set2.status = status2, response2 = response2.response);
|
|
42846
43633
|
const responseValidator = validator?.createResponse?.()?.[status2];
|
|
42847
43634
|
if (responseValidator?.Check(response2) === false)
|
|
42848
|
-
if (responseValidator?.Clean)
|
|
42849
|
-
|
|
42850
|
-
|
|
42851
|
-
|
|
42852
|
-
|
|
42853
|
-
|
|
43635
|
+
if (responseValidator?.Clean)
|
|
43636
|
+
try {
|
|
43637
|
+
const temp = responseValidator.Clean(response2);
|
|
43638
|
+
if (responseValidator?.Check(temp) === false)
|
|
43639
|
+
throw new ValidationError2("response", responseValidator, response2);
|
|
43640
|
+
response2 = temp;
|
|
43641
|
+
} catch (error2) {
|
|
43642
|
+
throw error2 instanceof ValidationError2 ? error2 : new ValidationError2("response", responseValidator, response2);
|
|
43643
|
+
}
|
|
43644
|
+
else
|
|
42854
43645
|
throw new ValidationError2("response", responseValidator, response2);
|
|
42855
|
-
responseValidator?.Encode && (context.response = response2 = responseValidator.Encode(response2)), responseValidator?.Clean
|
|
43646
|
+
if (responseValidator?.Encode && (context.response = response2 = responseValidator.Encode(response2)), responseValidator?.Clean)
|
|
43647
|
+
try {
|
|
43648
|
+
context.response = response2 = responseValidator.Clean(response2);
|
|
43649
|
+
} catch {}
|
|
42856
43650
|
const result = mapEarlyResponse3(response2, context.set);
|
|
42857
43651
|
if (result !== undefined)
|
|
42858
43652
|
return context.response = result;
|
|
@@ -42862,14 +43656,21 @@ var createDynamicHandler = (app) => {
|
|
|
42862
43656
|
isCustomStatuResponse && (set2.status = status2, response = response.response);
|
|
42863
43657
|
const responseValidator = validator?.createResponse?.()?.[status2];
|
|
42864
43658
|
if (responseValidator?.Check(response) === false)
|
|
42865
|
-
if (responseValidator?.Clean)
|
|
42866
|
-
|
|
42867
|
-
|
|
42868
|
-
|
|
42869
|
-
|
|
42870
|
-
|
|
43659
|
+
if (responseValidator?.Clean)
|
|
43660
|
+
try {
|
|
43661
|
+
const temp = responseValidator.Clean(response);
|
|
43662
|
+
if (responseValidator?.Check(temp) === false)
|
|
43663
|
+
throw new ValidationError2("response", responseValidator, response);
|
|
43664
|
+
response = temp;
|
|
43665
|
+
} catch (error2) {
|
|
43666
|
+
throw error2 instanceof ValidationError2 ? error2 : new ValidationError2("response", responseValidator, response);
|
|
43667
|
+
}
|
|
43668
|
+
else
|
|
42871
43669
|
throw new ValidationError2("response", responseValidator, response);
|
|
42872
|
-
responseValidator?.Encode && (response = responseValidator.Encode(response)), responseValidator?.Clean
|
|
43670
|
+
if (responseValidator?.Encode && (response = responseValidator.Encode(response)), responseValidator?.Clean)
|
|
43671
|
+
try {
|
|
43672
|
+
response = responseValidator.Clean(response);
|
|
43673
|
+
} catch {}
|
|
42873
43674
|
}
|
|
42874
43675
|
if (context.set.cookie && cookieMeta?.sign) {
|
|
42875
43676
|
const secret = cookieMeta.secrets ? typeof cookieMeta.secrets == "string" ? cookieMeta.secrets : cookieMeta.secrets[0] : undefined;
|
|
@@ -42878,10 +43679,10 @@ var createDynamicHandler = (app) => {
|
|
|
42878
43679
|
for (const [key, cookie] of Object.entries(context.set.cookie))
|
|
42879
43680
|
context.set.cookie[key].value = await signCookie(cookie.value, secret);
|
|
42880
43681
|
} else {
|
|
42881
|
-
const properties = validator?.cookie?.schema
|
|
43682
|
+
const properties = getSchemaProperties(validator?.cookie?.schema);
|
|
42882
43683
|
if (secret)
|
|
42883
43684
|
for (const name of cookieMeta.sign)
|
|
42884
|
-
name in properties
|
|
43685
|
+
!properties || !(name in properties) || context.set.cookie[name]?.value && (context.set.cookie[name].value = await signCookie(context.set.cookie[name].value, secret));
|
|
42885
43686
|
}
|
|
42886
43687
|
}
|
|
42887
43688
|
return mapResponse3(context.response = response, context.set);
|
|
@@ -43512,7 +44313,7 @@ var _Elysia = class _Elysia2 {
|
|
|
43512
44313
|
}, this.inference, this.config.sucrose));
|
|
43513
44314
|
for (const handle of handles) {
|
|
43514
44315
|
const fn = asHookType(handle, "global", { skipIfHasType: true });
|
|
43515
|
-
switch (type) {
|
|
44316
|
+
switch ((this.config.name || this.config.seed) && (fn.checksum = checksum(this.config.name + JSON.stringify(this.config.seed))), type) {
|
|
43516
44317
|
case "start":
|
|
43517
44318
|
this.event.start ??= [], this.event.start.push(fn);
|
|
43518
44319
|
break;
|
|
@@ -43898,19 +44699,7 @@ var _Elysia = class _Elysia2 {
|
|
|
43898
44699
|
if (path2 instanceof _Elysia2 || typeof path2 == "function" || path2.length === 0 || path2 === "/") {
|
|
43899
44700
|
const run = typeof path2 == "function" ? path2 : path2 instanceof _Elysia2 ? path2.compile().fetch : handleOrConfig instanceof _Elysia2 ? handleOrConfig.compile().fetch : typeof handleOrConfig == "function" ? handleOrConfig : (() => {
|
|
43900
44701
|
throw new Error("Invalid handler");
|
|
43901
|
-
})(), handler2 = ({ request, path: path22 }) => run(new Request(replaceUrlPath(request.url, path22),
|
|
43902
|
-
method: request.method,
|
|
43903
|
-
headers: request.headers,
|
|
43904
|
-
signal: request.signal,
|
|
43905
|
-
credentials: request.credentials,
|
|
43906
|
-
referrerPolicy: request.referrerPolicy,
|
|
43907
|
-
duplex: request.duplex,
|
|
43908
|
-
redirect: request.redirect,
|
|
43909
|
-
mode: request.mode,
|
|
43910
|
-
keepalive: request.keepalive,
|
|
43911
|
-
integrity: request.integrity,
|
|
43912
|
-
body: request.body
|
|
43913
|
-
}));
|
|
44702
|
+
})(), handler2 = ({ request, path: path22 }) => run(new Request(replaceUrlPath(request.url, path22), request));
|
|
43914
44703
|
return this.route("ALL", "/*", handler2, {
|
|
43915
44704
|
parse: "none",
|
|
43916
44705
|
...config3,
|
|
@@ -43925,19 +44714,7 @@ var _Elysia = class _Elysia2 {
|
|
|
43925
44714
|
}
|
|
43926
44715
|
const handle = handleOrConfig instanceof _Elysia2 ? handleOrConfig.compile().fetch : typeof handleOrConfig == "function" ? handleOrConfig : (() => {
|
|
43927
44716
|
throw new Error("Invalid handler");
|
|
43928
|
-
})(), length = (typeof path2 == "string" && this.config.prefix ? this.config.prefix + path2 : path2).length - (path2.endsWith("*") ? 1 : 0), handler = ({ request, path: path22 }) => handle(new Request(replaceUrlPath(request.url, path22.slice(length) || "/"),
|
|
43929
|
-
method: request.method,
|
|
43930
|
-
headers: request.headers,
|
|
43931
|
-
signal: request.signal,
|
|
43932
|
-
credentials: request.credentials,
|
|
43933
|
-
referrerPolicy: request.referrerPolicy,
|
|
43934
|
-
duplex: request.duplex,
|
|
43935
|
-
redirect: request.redirect,
|
|
43936
|
-
mode: request.mode,
|
|
43937
|
-
keepalive: request.keepalive,
|
|
43938
|
-
integrity: request.integrity,
|
|
43939
|
-
body: request.body
|
|
43940
|
-
}));
|
|
44717
|
+
})(), length = (typeof path2 == "string" && this.config.prefix ? this.config.prefix + path2 : path2).length - (path2.endsWith("*") ? 1 : 0), handler = ({ request, path: path22 }) => handle(new Request(replaceUrlPath(request.url, path22.slice(length) || "/"), request));
|
|
43941
44718
|
return this.route("ALL", path2, handler, {
|
|
43942
44719
|
parse: "none",
|
|
43943
44720
|
...config3,
|
|
@@ -44430,6 +45207,14 @@ function showVersion() {
|
|
|
44430
45207
|
console.log(`kanbo-mcp v${SERVER_INFO.version}`);
|
|
44431
45208
|
}
|
|
44432
45209
|
async function startMcpServer() {
|
|
45210
|
+
if (CONFIG.TRANSPORT === "http") {
|
|
45211
|
+
printBanner();
|
|
45212
|
+
await startHttpServer();
|
|
45213
|
+
} else {
|
|
45214
|
+
await startStdioServer();
|
|
45215
|
+
}
|
|
45216
|
+
}
|
|
45217
|
+
function printBanner() {
|
|
44433
45218
|
console.error("═══════════════════════════════════════════════════════════════");
|
|
44434
45219
|
console.error(` Kanbo MCP Server v${SERVER_INFO.version}`);
|
|
44435
45220
|
console.error(" AI-native project management via Model Context Protocol");
|
|
@@ -44438,11 +45223,6 @@ async function startMcpServer() {
|
|
|
44438
45223
|
console.error(` API URL: ${CONFIG.KANBO_API_URL}`);
|
|
44439
45224
|
console.error(` API Key: ${CONFIG.KANBO_API_KEY ? "***configured***" : "NOT SET"}`);
|
|
44440
45225
|
console.error("═══════════════════════════════════════════════════════════════");
|
|
44441
|
-
if (CONFIG.TRANSPORT === "http") {
|
|
44442
|
-
await startHttpServer();
|
|
44443
|
-
} else {
|
|
44444
|
-
await startStdioServer();
|
|
44445
|
-
}
|
|
44446
45226
|
}
|
|
44447
45227
|
async function main() {
|
|
44448
45228
|
const command = process.argv[2];
|
|
@@ -44466,4 +45246,7 @@ async function main() {
|
|
|
44466
45246
|
process.exit(1);
|
|
44467
45247
|
}
|
|
44468
45248
|
}
|
|
44469
|
-
main()
|
|
45249
|
+
main().catch((error2) => {
|
|
45250
|
+
console.error("[kanbo-mcp] Unhandled fatal error:", error2);
|
|
45251
|
+
process.exit(1);
|
|
45252
|
+
});
|