@kanbodev/mcp 1.1.9 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +342 -323
- package/dist/index.js +2108 -1095
- 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.1
|
|
248
|
+
version: "1.2.1",
|
|
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;
|
|
15249
|
+
}
|
|
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;
|
|
14751
15277
|
}
|
|
14752
|
-
break;
|
|
14753
15278
|
}
|
|
14754
|
-
|
|
15279
|
+
} catch (error2) {
|
|
15280
|
+
if (error2 instanceof EndOfStreamError || error2 instanceof ParserHardLimitError) {
|
|
15281
|
+
if (hasUnknownFileSize(tokenizer)) {
|
|
15282
|
+
isMalformedAsf = true;
|
|
15283
|
+
}
|
|
15284
|
+
} else {
|
|
15285
|
+
throw error2;
|
|
15286
|
+
}
|
|
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", () => {
|
|
@@ -15847,11 +16449,17 @@ function saveConfig(input) {
|
|
|
15847
16449
|
}
|
|
15848
16450
|
function deleteConfig() {
|
|
15849
16451
|
try {
|
|
15850
|
-
if (fs2.existsSync(CONFIG_PATH)) {
|
|
15851
|
-
|
|
15852
|
-
return true;
|
|
16452
|
+
if (!fs2.existsSync(CONFIG_PATH)) {
|
|
16453
|
+
return false;
|
|
15853
16454
|
}
|
|
15854
|
-
|
|
16455
|
+
fs2.unlinkSync(CONFIG_PATH);
|
|
16456
|
+
try {
|
|
16457
|
+
const remaining = fs2.readdirSync(CONFIG_DIR);
|
|
16458
|
+
if (remaining.length === 0) {
|
|
16459
|
+
fs2.rmdirSync(CONFIG_DIR);
|
|
16460
|
+
}
|
|
16461
|
+
} catch {}
|
|
16462
|
+
return true;
|
|
15855
16463
|
} catch {
|
|
15856
16464
|
return false;
|
|
15857
16465
|
}
|
|
@@ -15875,56 +16483,126 @@ var init_config = __esm(() => {
|
|
|
15875
16483
|
CONFIG_PATH = path2.join(CONFIG_DIR, "config.json");
|
|
15876
16484
|
});
|
|
15877
16485
|
|
|
15878
|
-
// src/cli/
|
|
15879
|
-
import * as fs3 from "node:fs";
|
|
16486
|
+
// src/cli/hosts.ts
|
|
15880
16487
|
import * as path3 from "node:path";
|
|
15881
16488
|
import * as os3 from "node:os";
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
const platform = process.platform;
|
|
15885
|
-
if (platform === "darwin") {
|
|
15886
|
-
return path3.join(os3.homedir(), "Library", "Application Support", "Code", "User", "mcp.json");
|
|
15887
|
-
}
|
|
15888
|
-
if (platform === "win32") {
|
|
15889
|
-
const appData = process.env.APPDATA || path3.join(os3.homedir(), "AppData", "Roaming");
|
|
15890
|
-
return path3.join(appData, "Code", "User", "mcp.json");
|
|
15891
|
-
}
|
|
15892
|
-
return path3.join(os3.homedir(), ".config", "Code", "User", "mcp.json");
|
|
16489
|
+
function getAppData() {
|
|
16490
|
+
return process.env.APPDATA || path3.join(os3.homedir(), "AppData", "Roaming");
|
|
15893
16491
|
}
|
|
15894
|
-
function
|
|
16492
|
+
function platformPath(mac2, win, linux) {
|
|
15895
16493
|
const platform = process.platform;
|
|
15896
|
-
if (platform === "darwin")
|
|
15897
|
-
return
|
|
15898
|
-
|
|
15899
|
-
|
|
15900
|
-
|
|
15901
|
-
|
|
15902
|
-
|
|
15903
|
-
|
|
16494
|
+
if (platform === "darwin")
|
|
16495
|
+
return mac2;
|
|
16496
|
+
if (platform === "win32")
|
|
16497
|
+
return win;
|
|
16498
|
+
return linux;
|
|
16499
|
+
}
|
|
16500
|
+
function getHostConfigs() {
|
|
16501
|
+
const home = os3.homedir();
|
|
16502
|
+
const appData = getAppData();
|
|
16503
|
+
return [
|
|
16504
|
+
{
|
|
16505
|
+
name: "VS Code",
|
|
16506
|
+
path: platformPath(path3.join(home, "Library", "Application Support", "Code", "User", "mcp.json"), path3.join(appData, "Code", "User", "mcp.json"), path3.join(home, ".config", "Code", "User", "mcp.json")),
|
|
16507
|
+
serversKey: "servers"
|
|
16508
|
+
},
|
|
16509
|
+
{
|
|
16510
|
+
name: "VS Code Insiders",
|
|
16511
|
+
path: platformPath(path3.join(home, "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), path3.join(appData, "Code - Insiders", "User", "mcp.json"), path3.join(home, ".config", "Code - Insiders", "User", "mcp.json")),
|
|
16512
|
+
serversKey: "servers"
|
|
16513
|
+
},
|
|
16514
|
+
{
|
|
16515
|
+
name: "Cursor",
|
|
16516
|
+
path: path3.join(home, ".cursor", "mcp.json"),
|
|
16517
|
+
serversKey: "servers"
|
|
16518
|
+
},
|
|
16519
|
+
{
|
|
16520
|
+
name: "Windsurf",
|
|
16521
|
+
path: path3.join(home, ".codeium", "windsurf", "mcp_config.json"),
|
|
16522
|
+
serversKey: "mcpServers"
|
|
16523
|
+
},
|
|
16524
|
+
{
|
|
16525
|
+
name: "Claude Code",
|
|
16526
|
+
path: path3.join(home, ".claude", "settings.json"),
|
|
16527
|
+
serversKey: "mcpServers"
|
|
16528
|
+
},
|
|
16529
|
+
{
|
|
16530
|
+
name: "Claude Desktop",
|
|
16531
|
+
path: platformPath(path3.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"), path3.join(appData, "Claude", "claude_desktop_config.json"), path3.join(home, ".config", "Claude", "claude_desktop_config.json")),
|
|
16532
|
+
serversKey: "mcpServers"
|
|
16533
|
+
}
|
|
16534
|
+
];
|
|
15904
16535
|
}
|
|
15905
|
-
function
|
|
15906
|
-
|
|
16536
|
+
function hasAnyRegistration() {
|
|
16537
|
+
const fs3 = __require("node:fs");
|
|
16538
|
+
for (const host of getHostConfigs()) {
|
|
16539
|
+
try {
|
|
16540
|
+
if (!fs3.existsSync(host.path))
|
|
16541
|
+
continue;
|
|
16542
|
+
const content = fs3.readFileSync(host.path, "utf-8");
|
|
16543
|
+
const config3 = JSON.parse(content);
|
|
16544
|
+
const servers = config3[host.serversKey];
|
|
16545
|
+
if (servers && servers[SERVER_NAME])
|
|
16546
|
+
return true;
|
|
16547
|
+
} catch {
|
|
16548
|
+
continue;
|
|
16549
|
+
}
|
|
16550
|
+
}
|
|
16551
|
+
return false;
|
|
15907
16552
|
}
|
|
15908
|
-
|
|
15909
|
-
|
|
16553
|
+
var SERVER_NAME = "kanbodev";
|
|
16554
|
+
var init_hosts = () => {};
|
|
16555
|
+
|
|
16556
|
+
// src/cli/register.ts
|
|
16557
|
+
import * as fs3 from "node:fs";
|
|
16558
|
+
import * as path4 from "node:path";
|
|
16559
|
+
import { execFileSync } from "node:child_process";
|
|
16560
|
+
function getMcpServerEntry() {
|
|
16561
|
+
if (process.platform === "win32") {
|
|
16562
|
+
const entryPoint = resolvePackageEntryPoint();
|
|
16563
|
+
if (entryPoint) {
|
|
16564
|
+
return { type: "stdio", command: "node", args: [entryPoint] };
|
|
16565
|
+
}
|
|
16566
|
+
}
|
|
16567
|
+
return { type: "stdio", command: "npx", args: ["@kanbodev/mcp"] };
|
|
15910
16568
|
}
|
|
15911
|
-
function
|
|
15912
|
-
|
|
16569
|
+
function resolvePackageEntryPoint() {
|
|
16570
|
+
try {
|
|
16571
|
+
const npmRoot = execFileSync("npm", ["root", "-g"], {
|
|
16572
|
+
stdio: "pipe",
|
|
16573
|
+
shell: true,
|
|
16574
|
+
encoding: "utf-8"
|
|
16575
|
+
}).trim();
|
|
16576
|
+
const globalEntry = path4.join(npmRoot, "@kanbodev", "mcp", "dist", "index.js");
|
|
16577
|
+
if (fs3.existsSync(globalEntry)) {
|
|
16578
|
+
return globalEntry;
|
|
16579
|
+
}
|
|
16580
|
+
} catch {}
|
|
16581
|
+
try {
|
|
16582
|
+
const dir = typeof import.meta.dirname === "string" ? import.meta.dirname : typeof __dirname === "string" ? __dirname : null;
|
|
16583
|
+
if (dir) {
|
|
16584
|
+
const selfEntry = path4.resolve(dir, "index.js");
|
|
16585
|
+
if (fs3.existsSync(selfEntry)) {
|
|
16586
|
+
return selfEntry;
|
|
16587
|
+
}
|
|
16588
|
+
const parentEntry = path4.resolve(dir, "..", "dist", "index.js");
|
|
16589
|
+
if (fs3.existsSync(parentEntry)) {
|
|
16590
|
+
return parentEntry;
|
|
16591
|
+
}
|
|
16592
|
+
}
|
|
16593
|
+
} catch {}
|
|
16594
|
+
return null;
|
|
15913
16595
|
}
|
|
15914
|
-
function
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
return path3.join(os3.homedir(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
15918
|
-
}
|
|
15919
|
-
if (platform === "win32") {
|
|
15920
|
-
const appData = process.env.APPDATA || path3.join(os3.homedir(), "AppData", "Roaming");
|
|
15921
|
-
return path3.join(appData, "Claude", "claude_desktop_config.json");
|
|
16596
|
+
function isEntryOutdated(existing) {
|
|
16597
|
+
if (process.platform !== "win32" || typeof existing !== "object" || existing === null) {
|
|
16598
|
+
return false;
|
|
15922
16599
|
}
|
|
15923
|
-
|
|
16600
|
+
const entry = existing;
|
|
16601
|
+
return entry.command === "npx" || entry.command === "npx.cmd";
|
|
15924
16602
|
}
|
|
15925
16603
|
function registerInConfigFile(configPath, hostName, serversKey = "servers") {
|
|
15926
16604
|
try {
|
|
15927
|
-
const parentDir =
|
|
16605
|
+
const parentDir = path4.dirname(configPath);
|
|
15928
16606
|
if (!fs3.existsSync(parentDir)) {
|
|
15929
16607
|
return { host: hostName, success: false, message: `${hostName} not detected` };
|
|
15930
16608
|
}
|
|
@@ -15941,6 +16619,17 @@ function registerInConfigFile(configPath, hostName, serversKey = "servers") {
|
|
|
15941
16619
|
}
|
|
15942
16620
|
const servers = config3[serversKey] || {};
|
|
15943
16621
|
if (servers[SERVER_NAME]) {
|
|
16622
|
+
if (isEntryOutdated(servers[SERVER_NAME])) {
|
|
16623
|
+
servers[SERVER_NAME] = getMcpServerEntry();
|
|
16624
|
+
config3[serversKey] = servers;
|
|
16625
|
+
fs3.writeFileSync(configPath, JSON.stringify(config3, null, 2) + `
|
|
16626
|
+
`, "utf-8");
|
|
16627
|
+
return {
|
|
16628
|
+
host: hostName,
|
|
16629
|
+
success: true,
|
|
16630
|
+
message: `Updated in ${hostName} (fixed Windows stdio)`
|
|
16631
|
+
};
|
|
16632
|
+
}
|
|
15944
16633
|
return {
|
|
15945
16634
|
host: hostName,
|
|
15946
16635
|
success: true,
|
|
@@ -15948,7 +16637,7 @@ function registerInConfigFile(configPath, hostName, serversKey = "servers") {
|
|
|
15948
16637
|
message: `Already registered in ${hostName}`
|
|
15949
16638
|
};
|
|
15950
16639
|
}
|
|
15951
|
-
servers[SERVER_NAME] =
|
|
16640
|
+
servers[SERVER_NAME] = getMcpServerEntry();
|
|
15952
16641
|
config3[serversKey] = servers;
|
|
15953
16642
|
fs3.writeFileSync(configPath, JSON.stringify(config3, null, 2) + `
|
|
15954
16643
|
`, "utf-8");
|
|
@@ -15976,7 +16665,8 @@ function registerWithClaudeCli() {
|
|
|
15976
16665
|
if (!isClaudeCliAvailable()) {
|
|
15977
16666
|
return { host: hostName, success: false, message: "Claude Code CLI not detected" };
|
|
15978
16667
|
}
|
|
15979
|
-
|
|
16668
|
+
const entry = getMcpServerEntry();
|
|
16669
|
+
execFileSync("claude", ["mcp", "add", SERVER_NAME, "--", entry.command, ...entry.args], {
|
|
15980
16670
|
stdio: "pipe",
|
|
15981
16671
|
...shellOpt
|
|
15982
16672
|
});
|
|
@@ -15991,12 +16681,10 @@ function registerWithClaudeCli() {
|
|
|
15991
16681
|
}
|
|
15992
16682
|
function registerMcpServer() {
|
|
15993
16683
|
const results = [];
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
results.push(registerInConfigFile(getClaudeCodeSettingsPath(), "Claude Code", "mcpServers"));
|
|
15999
|
-
results.push(registerInConfigFile(getClaudeDesktopMcpPath(), "Claude Desktop", "mcpServers"));
|
|
16684
|
+
const hosts = getHostConfigs();
|
|
16685
|
+
for (const host of hosts) {
|
|
16686
|
+
results.push(registerInConfigFile(host.path, host.name, host.serversKey));
|
|
16687
|
+
}
|
|
16000
16688
|
results.push(registerWithClaudeCli());
|
|
16001
16689
|
return results;
|
|
16002
16690
|
}
|
|
@@ -16015,9 +16703,9 @@ function printRegistrationResults(results) {
|
|
|
16015
16703
|
console.log(` · ${r.message}`);
|
|
16016
16704
|
}
|
|
16017
16705
|
}
|
|
16018
|
-
if (
|
|
16706
|
+
if (anySuccess) {
|
|
16019
16707
|
console.log("");
|
|
16020
|
-
console.log("
|
|
16708
|
+
console.log(" ⚡ Restart your editor or open a new chat session to activate the MCP server.");
|
|
16021
16709
|
}
|
|
16022
16710
|
if (!anySuccess) {
|
|
16023
16711
|
printManualInstructions();
|
|
@@ -16025,6 +16713,9 @@ function printRegistrationResults(results) {
|
|
|
16025
16713
|
return anySuccess;
|
|
16026
16714
|
}
|
|
16027
16715
|
function printManualInstructions() {
|
|
16716
|
+
const entry = getMcpServerEntry();
|
|
16717
|
+
const commandStr = [entry.command, ...entry.args].join(" ");
|
|
16718
|
+
const hosts = getHostConfigs();
|
|
16028
16719
|
console.log(" To register the MCP server manually, add this to your editor config:");
|
|
16029
16720
|
console.log("");
|
|
16030
16721
|
console.log(" For VS Code / Cursor (mcp.json):");
|
|
@@ -16032,8 +16723,8 @@ function printManualInstructions() {
|
|
|
16032
16723
|
console.log(' "servers": {');
|
|
16033
16724
|
console.log(' "kanbodev": {');
|
|
16034
16725
|
console.log(' "type": "stdio",');
|
|
16035
|
-
console.log(
|
|
16036
|
-
console.log(
|
|
16726
|
+
console.log(` "command": "${entry.command}",`);
|
|
16727
|
+
console.log(` "args": ${JSON.stringify(entry.args)}`);
|
|
16037
16728
|
console.log(" }");
|
|
16038
16729
|
console.log(" }");
|
|
16039
16730
|
console.log(" }");
|
|
@@ -16043,30 +16734,24 @@ function printManualInstructions() {
|
|
|
16043
16734
|
console.log(' "mcpServers": {');
|
|
16044
16735
|
console.log(' "kanbodev": {');
|
|
16045
16736
|
console.log(' "type": "stdio",');
|
|
16046
|
-
console.log(
|
|
16047
|
-
console.log(
|
|
16737
|
+
console.log(` "command": "${entry.command}",`);
|
|
16738
|
+
console.log(` "args": ${JSON.stringify(entry.args)}`);
|
|
16048
16739
|
console.log(" }");
|
|
16049
16740
|
console.log(" }");
|
|
16050
16741
|
console.log(" }");
|
|
16051
16742
|
console.log("");
|
|
16052
16743
|
console.log(" Config file locations:");
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
console.log(` Claude Code: ${getClaudeCodeSettingsPath()}`);
|
|
16058
|
-
console.log(` Claude Desktop: ${getClaudeDesktopMcpPath()}`);
|
|
16744
|
+
for (const host of hosts) {
|
|
16745
|
+
const padding = " ".repeat(Math.max(0, 18 - host.name.length));
|
|
16746
|
+
console.log(` ${host.name}:${padding}${host.path}`);
|
|
16747
|
+
}
|
|
16059
16748
|
console.log("");
|
|
16060
16749
|
console.log(" Or register via Claude Code CLI:");
|
|
16061
|
-
console.log(
|
|
16750
|
+
console.log(` claude mcp add kanbodev -- ${commandStr}`);
|
|
16062
16751
|
}
|
|
16063
|
-
var
|
|
16752
|
+
var __dirname = "C:\\Users\\cloudpg07\\0dev\\kanbo-mcp\\src\\cli", shellOpt;
|
|
16064
16753
|
var init_register = __esm(() => {
|
|
16065
|
-
|
|
16066
|
-
type: "stdio",
|
|
16067
|
-
command: "npx",
|
|
16068
|
-
args: ["@kanbodev/mcp"]
|
|
16069
|
-
};
|
|
16754
|
+
init_hosts();
|
|
16070
16755
|
shellOpt = process.platform === "win32" ? { shell: true } : {};
|
|
16071
16756
|
});
|
|
16072
16757
|
|
|
@@ -16131,10 +16816,14 @@ var isWsl = () => {
|
|
|
16131
16816
|
return true;
|
|
16132
16817
|
}
|
|
16133
16818
|
try {
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16819
|
+
if (fs6.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
16820
|
+
return !isInsideContainer();
|
|
16821
|
+
}
|
|
16822
|
+
} catch {}
|
|
16823
|
+
if (fs6.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs6.existsSync("/run/WSL")) {
|
|
16824
|
+
return !isInsideContainer();
|
|
16137
16825
|
}
|
|
16826
|
+
return false;
|
|
16138
16827
|
}, is_wsl_default;
|
|
16139
16828
|
var init_is_wsl = __esm(() => {
|
|
16140
16829
|
init_is_inside_container();
|
|
@@ -16211,15 +16900,15 @@ var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
|
|
|
16211
16900
|
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
16212
16901
|
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
16213
16902
|
return stdout.trim();
|
|
16214
|
-
}, convertWslPathToWindows = async (
|
|
16215
|
-
if (/^[a-z]+:\/\//i.test(
|
|
16216
|
-
return
|
|
16903
|
+
}, convertWslPathToWindows = async (path5) => {
|
|
16904
|
+
if (/^[a-z]+:\/\//i.test(path5)) {
|
|
16905
|
+
return path5;
|
|
16217
16906
|
}
|
|
16218
16907
|
try {
|
|
16219
|
-
const { stdout } = await execFile2("wslpath", ["-aw",
|
|
16908
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path5], { encoding: "utf8" });
|
|
16220
16909
|
return stdout.trim();
|
|
16221
16910
|
} catch {
|
|
16222
|
-
return
|
|
16911
|
+
return path5;
|
|
16223
16912
|
}
|
|
16224
16913
|
};
|
|
16225
16914
|
var init_wsl_utils = __esm(() => {
|
|
@@ -16340,11 +17029,11 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
|
16340
17029
|
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
16341
17030
|
}
|
|
16342
17031
|
const { id } = match.groups;
|
|
16343
|
-
const
|
|
16344
|
-
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
return
|
|
17032
|
+
const dotIndex = id.lastIndexOf(".");
|
|
17033
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
17034
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
17035
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
17036
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
16348
17037
|
}
|
|
16349
17038
|
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
16350
17039
|
var init_windows = __esm(() => {
|
|
@@ -16418,7 +17107,7 @@ __export(exports_open, {
|
|
|
16418
17107
|
apps: () => apps
|
|
16419
17108
|
});
|
|
16420
17109
|
import process10 from "node:process";
|
|
16421
|
-
import
|
|
17110
|
+
import path5 from "node:path";
|
|
16422
17111
|
import { fileURLToPath } from "node:url";
|
|
16423
17112
|
import childProcess3 from "node:child_process";
|
|
16424
17113
|
import fs8, { constants as fsConstants2 } from "node:fs/promises";
|
|
@@ -16607,19 +17296,19 @@ var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEach
|
|
|
16607
17296
|
}
|
|
16608
17297
|
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
16609
17298
|
if (options.wait) {
|
|
16610
|
-
return new Promise((
|
|
17299
|
+
return new Promise((resolve2, reject) => {
|
|
16611
17300
|
subprocess.once("error", reject);
|
|
16612
17301
|
subprocess.once("close", (exitCode) => {
|
|
16613
17302
|
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
16614
17303
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
16615
17304
|
return;
|
|
16616
17305
|
}
|
|
16617
|
-
|
|
17306
|
+
resolve2(subprocess);
|
|
16618
17307
|
});
|
|
16619
17308
|
});
|
|
16620
17309
|
}
|
|
16621
17310
|
if (isFallbackAttempt) {
|
|
16622
|
-
return new Promise((
|
|
17311
|
+
return new Promise((resolve2, reject) => {
|
|
16623
17312
|
subprocess.once("error", reject);
|
|
16624
17313
|
subprocess.once("spawn", () => {
|
|
16625
17314
|
subprocess.once("close", (exitCode) => {
|
|
@@ -16629,17 +17318,17 @@ var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEach
|
|
|
16629
17318
|
return;
|
|
16630
17319
|
}
|
|
16631
17320
|
subprocess.unref();
|
|
16632
|
-
|
|
17321
|
+
resolve2(subprocess);
|
|
16633
17322
|
});
|
|
16634
17323
|
});
|
|
16635
17324
|
});
|
|
16636
17325
|
}
|
|
16637
17326
|
subprocess.unref();
|
|
16638
|
-
return new Promise((
|
|
17327
|
+
return new Promise((resolve2, reject) => {
|
|
16639
17328
|
subprocess.once("error", reject);
|
|
16640
17329
|
subprocess.once("spawn", () => {
|
|
16641
17330
|
subprocess.off("error", reject);
|
|
16642
|
-
|
|
17331
|
+
resolve2(subprocess);
|
|
16643
17332
|
});
|
|
16644
17333
|
});
|
|
16645
17334
|
}, open = (target, options) => {
|
|
@@ -16673,8 +17362,8 @@ var init_open = __esm(() => {
|
|
|
16673
17362
|
init_is_inside_container();
|
|
16674
17363
|
init_is_in_ssh();
|
|
16675
17364
|
fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
16676
|
-
__dirname2 = import.meta.url ?
|
|
16677
|
-
localXdgOpenPath =
|
|
17365
|
+
__dirname2 = import.meta.url ? path5.dirname(fileURLToPath(import.meta.url)) : "";
|
|
17366
|
+
localXdgOpenPath = path5.join(__dirname2, "xdg-open");
|
|
16678
17367
|
({ platform, arch } = process10);
|
|
16679
17368
|
apps = {
|
|
16680
17369
|
browser: "browser",
|
|
@@ -16847,6 +17536,12 @@ async function logout() {
|
|
|
16847
17536
|
console.log("");
|
|
16848
17537
|
console.log(` Config removed from: ${getConfigPath()}`);
|
|
16849
17538
|
console.log("");
|
|
17539
|
+
if (hasAnyRegistration()) {
|
|
17540
|
+
console.log(" ⚠ MCP server is still registered in your editor(s).");
|
|
17541
|
+
console.log(" To remove it, run:");
|
|
17542
|
+
console.log(" kanbo-mcp uninstall");
|
|
17543
|
+
console.log("");
|
|
17544
|
+
}
|
|
16850
17545
|
console.log(" To log in again, run:");
|
|
16851
17546
|
console.log(" kanbo-mcp login");
|
|
16852
17547
|
console.log("");
|
|
@@ -16857,6 +17552,7 @@ async function logout() {
|
|
|
16857
17552
|
}
|
|
16858
17553
|
var init_logout = __esm(() => {
|
|
16859
17554
|
init_config();
|
|
17555
|
+
init_hosts();
|
|
16860
17556
|
});
|
|
16861
17557
|
|
|
16862
17558
|
// src/cli/whoami.ts
|
|
@@ -16933,6 +17629,142 @@ var init_install = __esm(() => {
|
|
|
16933
17629
|
init_register();
|
|
16934
17630
|
});
|
|
16935
17631
|
|
|
17632
|
+
// src/cli/uninstall.ts
|
|
17633
|
+
var exports_uninstall = {};
|
|
17634
|
+
__export(exports_uninstall, {
|
|
17635
|
+
uninstall: () => uninstall
|
|
17636
|
+
});
|
|
17637
|
+
import * as fs9 from "node:fs";
|
|
17638
|
+
import * as path6 from "node:path";
|
|
17639
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
17640
|
+
function removeFromConfigFile(host) {
|
|
17641
|
+
try {
|
|
17642
|
+
if (!fs9.existsSync(host.path)) {
|
|
17643
|
+
return { host: host.name, removed: false, message: "Config file not found" };
|
|
17644
|
+
}
|
|
17645
|
+
const content = fs9.readFileSync(host.path, "utf-8");
|
|
17646
|
+
let config3;
|
|
17647
|
+
try {
|
|
17648
|
+
config3 = JSON.parse(content);
|
|
17649
|
+
} catch {
|
|
17650
|
+
return { host: host.name, removed: false, message: "Config file has invalid JSON" };
|
|
17651
|
+
}
|
|
17652
|
+
const servers = config3[host.serversKey];
|
|
17653
|
+
if (!servers || !servers[SERVER_NAME]) {
|
|
17654
|
+
return { host: host.name, removed: false, message: "Not registered" };
|
|
17655
|
+
}
|
|
17656
|
+
delete servers[SERVER_NAME];
|
|
17657
|
+
config3[host.serversKey] = servers;
|
|
17658
|
+
fs9.writeFileSync(host.path, JSON.stringify(config3, null, 2) + `
|
|
17659
|
+
`, "utf-8");
|
|
17660
|
+
return { host: host.name, removed: true, message: `Removed from ${host.name}` };
|
|
17661
|
+
} catch (error2) {
|
|
17662
|
+
const msg = error2 instanceof Error ? error2.message : "Unknown error";
|
|
17663
|
+
return { host: host.name, removed: false, message: `Failed: ${msg}` };
|
|
17664
|
+
}
|
|
17665
|
+
}
|
|
17666
|
+
function removeFromProjectMcpJson() {
|
|
17667
|
+
const hostName = "Project .mcp.json";
|
|
17668
|
+
const mcpJsonPath = path6.join(process.cwd(), ".mcp.json");
|
|
17669
|
+
try {
|
|
17670
|
+
if (!fs9.existsSync(mcpJsonPath)) {
|
|
17671
|
+
return { host: hostName, removed: false, message: "No project .mcp.json found" };
|
|
17672
|
+
}
|
|
17673
|
+
const content = fs9.readFileSync(mcpJsonPath, "utf-8");
|
|
17674
|
+
let config3;
|
|
17675
|
+
try {
|
|
17676
|
+
config3 = JSON.parse(content);
|
|
17677
|
+
} catch {
|
|
17678
|
+
return { host: hostName, removed: false, message: ".mcp.json has invalid JSON" };
|
|
17679
|
+
}
|
|
17680
|
+
let found = false;
|
|
17681
|
+
for (const key of ["servers", "mcpServers"]) {
|
|
17682
|
+
const servers = config3[key];
|
|
17683
|
+
if (servers && servers[SERVER_NAME]) {
|
|
17684
|
+
delete servers[SERVER_NAME];
|
|
17685
|
+
config3[key] = servers;
|
|
17686
|
+
found = true;
|
|
17687
|
+
}
|
|
17688
|
+
}
|
|
17689
|
+
if (!found) {
|
|
17690
|
+
return { host: hostName, removed: false, message: "Not registered in .mcp.json" };
|
|
17691
|
+
}
|
|
17692
|
+
const hasOtherServers = ["servers", "mcpServers"].some((key) => {
|
|
17693
|
+
const servers = config3[key];
|
|
17694
|
+
return servers && Object.keys(servers).length > 0;
|
|
17695
|
+
});
|
|
17696
|
+
if (hasOtherServers) {
|
|
17697
|
+
fs9.writeFileSync(mcpJsonPath, JSON.stringify(config3, null, 2) + `
|
|
17698
|
+
`, "utf-8");
|
|
17699
|
+
} else {
|
|
17700
|
+
fs9.unlinkSync(mcpJsonPath);
|
|
17701
|
+
}
|
|
17702
|
+
return { host: hostName, removed: true, message: "Removed from project .mcp.json" };
|
|
17703
|
+
} catch (error2) {
|
|
17704
|
+
const msg = error2 instanceof Error ? error2.message : "Unknown error";
|
|
17705
|
+
return { host: hostName, removed: false, message: `Failed: ${msg}` };
|
|
17706
|
+
}
|
|
17707
|
+
}
|
|
17708
|
+
function removeFromClaudeCli() {
|
|
17709
|
+
const hostName = "Claude Code CLI";
|
|
17710
|
+
try {
|
|
17711
|
+
execFileSync3("claude", ["--version"], { stdio: "pipe", ...shellOpt2 });
|
|
17712
|
+
} catch {
|
|
17713
|
+
return { host: hostName, removed: false, message: "Claude Code CLI not detected" };
|
|
17714
|
+
}
|
|
17715
|
+
try {
|
|
17716
|
+
execFileSync3("claude", ["mcp", "remove", SERVER_NAME], {
|
|
17717
|
+
stdio: "pipe",
|
|
17718
|
+
...shellOpt2
|
|
17719
|
+
});
|
|
17720
|
+
return { host: hostName, removed: true, message: "Removed from Claude Code CLI" };
|
|
17721
|
+
} catch (error2) {
|
|
17722
|
+
const msg = error2 instanceof Error ? error2.message : "Unknown error";
|
|
17723
|
+
if (msg.includes("not found") || msg.includes("does not exist")) {
|
|
17724
|
+
return { host: hostName, removed: false, message: "Not registered" };
|
|
17725
|
+
}
|
|
17726
|
+
return { host: hostName, removed: false, message: `Failed: ${msg}` };
|
|
17727
|
+
}
|
|
17728
|
+
}
|
|
17729
|
+
async function uninstall() {
|
|
17730
|
+
console.log(`
|
|
17731
|
+
Kanbo MCP — Uninstall
|
|
17732
|
+
`);
|
|
17733
|
+
const results = [];
|
|
17734
|
+
for (const host of getHostConfigs()) {
|
|
17735
|
+
results.push(removeFromConfigFile(host));
|
|
17736
|
+
}
|
|
17737
|
+
results.push(removeFromProjectMcpJson());
|
|
17738
|
+
results.push(removeFromClaudeCli());
|
|
17739
|
+
const removed = results.filter((r) => r.removed);
|
|
17740
|
+
const notRegistered = results.filter((r) => !r.removed);
|
|
17741
|
+
if (removed.length > 0) {
|
|
17742
|
+
console.log(" MCP server removed from:");
|
|
17743
|
+
for (const r of removed) {
|
|
17744
|
+
console.log(` ✓ ${r.message}`);
|
|
17745
|
+
}
|
|
17746
|
+
}
|
|
17747
|
+
if (notRegistered.length > 0) {
|
|
17748
|
+
for (const r of notRegistered) {
|
|
17749
|
+
console.log(` · ${r.host}: ${r.message}`);
|
|
17750
|
+
}
|
|
17751
|
+
}
|
|
17752
|
+
console.log("");
|
|
17753
|
+
if (removed.length > 0) {
|
|
17754
|
+
console.log(" ⚡ Restart your editor or open a new chat session to complete the removal.");
|
|
17755
|
+
console.log("");
|
|
17756
|
+
}
|
|
17757
|
+
console.log(" Note: This only removes MCP server registrations.");
|
|
17758
|
+
console.log(" To also remove credentials, run: kanbo-mcp logout");
|
|
17759
|
+
console.log(" To uninstall the package: npm uninstall -g @kanbodev/mcp");
|
|
17760
|
+
console.log("");
|
|
17761
|
+
}
|
|
17762
|
+
var shellOpt2;
|
|
17763
|
+
var init_uninstall = __esm(() => {
|
|
17764
|
+
init_hosts();
|
|
17765
|
+
shellOpt2 = process.platform === "win32" ? { shell: true } : {};
|
|
17766
|
+
});
|
|
17767
|
+
|
|
16936
17768
|
// src/index.ts
|
|
16937
17769
|
init_constants();
|
|
16938
17770
|
|
|
@@ -24081,11 +24913,12 @@ init_constants();
|
|
|
24081
24913
|
// src/lib/client/index.ts
|
|
24082
24914
|
init_constants();
|
|
24083
24915
|
init_errors();
|
|
24084
|
-
import { AsyncLocalStorage as
|
|
24916
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
24085
24917
|
|
|
24086
24918
|
// src/lib/client/core.ts
|
|
24087
24919
|
init_errors();
|
|
24088
24920
|
init_constants();
|
|
24921
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
24089
24922
|
|
|
24090
24923
|
// src/config/endpoints.ts
|
|
24091
24924
|
var EP = {
|
|
@@ -24330,6 +25163,10 @@ function createLogger(bindings = {}) {
|
|
|
24330
25163
|
}
|
|
24331
25164
|
var logger = createLogger();
|
|
24332
25165
|
// src/lib/client/core.ts
|
|
25166
|
+
var orgContextStorage = new AsyncLocalStorage2;
|
|
25167
|
+
function runWithOrgContext(client, fn) {
|
|
25168
|
+
return orgContextStorage.run({ orgId: client.getDefaultOrgId() }, fn);
|
|
25169
|
+
}
|
|
24333
25170
|
var apiLogger = logger.withCategory(LogCategory.API);
|
|
24334
25171
|
var oidcTokenCache = new Map;
|
|
24335
25172
|
var OIDC_EXPIRY_BUFFER_MS = 5 * 60 * 1000;
|
|
@@ -24525,8 +25362,16 @@ class KanboClient {
|
|
|
24525
25362
|
}
|
|
24526
25363
|
setOrganization(orgId) {
|
|
24527
25364
|
this.orgId = orgId;
|
|
25365
|
+
const ctx = orgContextStorage.getStore();
|
|
25366
|
+
if (ctx) {
|
|
25367
|
+
ctx.orgId = orgId;
|
|
25368
|
+
}
|
|
24528
25369
|
}
|
|
24529
25370
|
getOrganizationId() {
|
|
25371
|
+
const ctx = orgContextStorage.getStore();
|
|
25372
|
+
return ctx ? ctx.orgId : this.orgId;
|
|
25373
|
+
}
|
|
25374
|
+
getDefaultOrgId() {
|
|
24530
25375
|
return this.orgId;
|
|
24531
25376
|
}
|
|
24532
25377
|
async validateAndGetContext() {
|
|
@@ -25025,7 +25870,7 @@ KanboClient.prototype.batchMoveTickets = async function(projectId, ticketIds, st
|
|
|
25025
25870
|
};
|
|
25026
25871
|
|
|
25027
25872
|
// src/lib/client/index.ts
|
|
25028
|
-
var requestClientStorage = new
|
|
25873
|
+
var requestClientStorage = new AsyncLocalStorage3;
|
|
25029
25874
|
function runWithClient(client, fn) {
|
|
25030
25875
|
return requestClientStorage.run(client, fn);
|
|
25031
25876
|
}
|
|
@@ -29893,42 +30738,46 @@ function createMCPServer() {
|
|
|
29893
30738
|
isError: true
|
|
29894
30739
|
};
|
|
29895
30740
|
}
|
|
29896
|
-
|
|
29897
|
-
|
|
29898
|
-
|
|
29899
|
-
|
|
29900
|
-
|
|
29901
|
-
|
|
29902
|
-
|
|
29903
|
-
|
|
29904
|
-
|
|
29905
|
-
|
|
29906
|
-
|
|
29907
|
-
|
|
29908
|
-
|
|
29909
|
-
|
|
29910
|
-
|
|
29911
|
-
|
|
29912
|
-
|
|
29913
|
-
|
|
29914
|
-
|
|
29915
|
-
|
|
29916
|
-
|
|
29917
|
-
|
|
29918
|
-
|
|
30741
|
+
const client = getKanboClient();
|
|
30742
|
+
return runWithOrgContext(client, async () => {
|
|
30743
|
+
try {
|
|
30744
|
+
const result = await handler(args || {});
|
|
30745
|
+
return {
|
|
30746
|
+
content: [
|
|
30747
|
+
{
|
|
30748
|
+
type: "text",
|
|
30749
|
+
text: formatToolResult(result)
|
|
30750
|
+
}
|
|
30751
|
+
],
|
|
30752
|
+
isError: !result.success
|
|
30753
|
+
};
|
|
30754
|
+
} catch (error2) {
|
|
30755
|
+
serverLogger.error({ err: error2, toolName: name }, "Tool execution failed");
|
|
30756
|
+
return {
|
|
30757
|
+
content: [
|
|
30758
|
+
{
|
|
30759
|
+
type: "text",
|
|
30760
|
+
text: formatToolResult(errorResultFromError(error2))
|
|
30761
|
+
}
|
|
30762
|
+
],
|
|
30763
|
+
isError: true
|
|
30764
|
+
};
|
|
30765
|
+
}
|
|
30766
|
+
});
|
|
29919
30767
|
});
|
|
29920
30768
|
return server;
|
|
29921
30769
|
}
|
|
30770
|
+
var STARTUP_AUTH_TIMEOUT_MS = 15000;
|
|
29922
30771
|
async function startStdioServer() {
|
|
29923
|
-
logToolRegistration();
|
|
29924
|
-
serverLogger.info("Starting in stdio mode");
|
|
29925
30772
|
if (!CONFIG.KANBO_API_KEY) {
|
|
29926
|
-
|
|
29927
|
-
process.exit(1);
|
|
30773
|
+
throw new Error('KANBO_API_KEY is required. Run "kanbo-mcp login" to authenticate, ' + "or set the KANBO_API_KEY environment variable.");
|
|
29928
30774
|
}
|
|
29929
30775
|
try {
|
|
29930
30776
|
const client = getKanboClient();
|
|
29931
|
-
const authContext = await
|
|
30777
|
+
const authContext = await Promise.race([
|
|
30778
|
+
client.validateAndGetContext(),
|
|
30779
|
+
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))
|
|
30780
|
+
]);
|
|
29932
30781
|
serverLogger.info({ email: authContext.email }, "Authenticated");
|
|
29933
30782
|
serverLogger.info({ organizations: authContext.organizations.map((o) => o.name) }, "Available organizations");
|
|
29934
30783
|
if (client.getOrganizationId()) {
|
|
@@ -29937,11 +30786,19 @@ async function startStdioServer() {
|
|
|
29937
30786
|
}
|
|
29938
30787
|
} catch (error2) {
|
|
29939
30788
|
serverLogger.fatal({ err: error2 }, "Authentication failed");
|
|
29940
|
-
|
|
30789
|
+
throw error2;
|
|
29941
30790
|
}
|
|
29942
30791
|
const server = createMCPServer();
|
|
29943
30792
|
const transport = new StdioServerTransport;
|
|
30793
|
+
const shutdown = async () => {
|
|
30794
|
+
serverLogger.info("Shutting down...");
|
|
30795
|
+
await server.close();
|
|
30796
|
+
process.exit(0);
|
|
30797
|
+
};
|
|
30798
|
+
process.on("SIGINT", shutdown);
|
|
30799
|
+
process.on("SIGTERM", shutdown);
|
|
29944
30800
|
await server.connect(transport);
|
|
30801
|
+
logToolRegistration();
|
|
29945
30802
|
serverLogger.info("Server running on stdio");
|
|
29946
30803
|
}
|
|
29947
30804
|
|
|
@@ -32916,7 +33773,6 @@ var Type = exports_type3;
|
|
|
32916
33773
|
|
|
32917
33774
|
// node_modules/elysia/dist/index.mjs
|
|
32918
33775
|
var import_fast_decode_uri_component4 = __toESM(require_fast_decode_uri_component(), 1);
|
|
32919
|
-
|
|
32920
33776
|
// node_modules/@sinclair/typebox/build/esm/errors/function.mjs
|
|
32921
33777
|
function DefaultErrorFunction(error2) {
|
|
32922
33778
|
switch (error2.errorType) {
|
|
@@ -34194,6 +35050,7 @@ function Errors(...args) {
|
|
|
34194
35050
|
const iterator = args.length === 3 ? Visit6(args[0], args[1], "", args[2]) : Visit6(args[0], [], "", args[1]);
|
|
34195
35051
|
return new ValueErrorIterator(iterator);
|
|
34196
35052
|
}
|
|
35053
|
+
|
|
34197
35054
|
// node_modules/@sinclair/typebox/build/esm/value/assert/assert.mjs
|
|
34198
35055
|
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
34199
35056
|
if (kind === "m")
|
|
@@ -36810,6 +37667,15 @@ var TypeCompiler;
|
|
|
36810
37667
|
|
|
36811
37668
|
// node_modules/elysia/dist/universal/utils.mjs
|
|
36812
37669
|
var isBun = typeof Bun < "u";
|
|
37670
|
+
function isCloudflareWorker() {
|
|
37671
|
+
try {
|
|
37672
|
+
if (typeof caches < "u" && typeof caches.default < "u" || typeof WebSocketPair < "u")
|
|
37673
|
+
return true;
|
|
37674
|
+
} catch {
|
|
37675
|
+
return false;
|
|
37676
|
+
}
|
|
37677
|
+
return false;
|
|
37678
|
+
}
|
|
36813
37679
|
|
|
36814
37680
|
// node_modules/elysia/dist/universal/file.mjs
|
|
36815
37681
|
var mime = {
|
|
@@ -36939,7 +37805,6 @@ class ElysiaFile {
|
|
|
36939
37805
|
}
|
|
36940
37806
|
|
|
36941
37807
|
// node_modules/elysia/dist/utils.mjs
|
|
36942
|
-
var hasHeaderShorthand = "toJSON" in new Headers;
|
|
36943
37808
|
var replaceUrlPath = (url, pathname) => {
|
|
36944
37809
|
const pathStartIndex = url.indexOf("/", 11), queryIndex = url.indexOf("?", pathStartIndex);
|
|
36945
37810
|
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 +37936,7 @@ var lifeCycleToArray = (a) => {
|
|
|
37071
37936
|
let beforeHandle = [];
|
|
37072
37937
|
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
37938
|
};
|
|
37074
|
-
var
|
|
37075
|
-
var hasBunHash = isBun2 && typeof Bun.hash == "function";
|
|
37939
|
+
var hasHeaderShorthand = isBun ? "toJSON" in new Headers : false;
|
|
37076
37940
|
var hasSetImmediate = typeof setImmediate == "function";
|
|
37077
37941
|
var checksum = (s) => {
|
|
37078
37942
|
let h = 9;
|
|
@@ -37222,8 +38086,8 @@ function removeTrailingEquals(digest) {
|
|
|
37222
38086
|
}
|
|
37223
38087
|
var encoder = new TextEncoder;
|
|
37224
38088
|
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
|
|
38089
|
+
if (typeof val == "object" ? val = JSON.stringify(val) : typeof val != "string" && (val = val + ""), secret == null)
|
|
38090
|
+
throw new TypeError("Secret key must be provided");
|
|
37227
38091
|
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
38092
|
return val + "." + removeTrailingEquals(Buffer.from(hmacBuffer).toString("base64"));
|
|
37229
38093
|
};
|
|
@@ -37234,11 +38098,9 @@ var constantTimeEqual = typeof crypto?.timingSafeEqual == "function" ? (a, b) =>
|
|
|
37234
38098
|
var unsignCookie = async (input, secret) => {
|
|
37235
38099
|
if (typeof input != "string")
|
|
37236
38100
|
throw new TypeError("Signed cookie string must be provided.");
|
|
37237
|
-
if (secret === null)
|
|
37238
|
-
throw new TypeError("Secret key must be provided.");
|
|
37239
38101
|
const dot = input.lastIndexOf(".");
|
|
37240
|
-
if (dot
|
|
37241
|
-
return false;
|
|
38102
|
+
if (dot === -1)
|
|
38103
|
+
return secret === null ? input : false;
|
|
37242
38104
|
const tentativeValue = input.slice(0, dot), expectedInput = await signCookie(tentativeValue, secret);
|
|
37243
38105
|
return constantTimeEqual(expectedInput, input) ? tentativeValue : false;
|
|
37244
38106
|
};
|
|
@@ -37350,11 +38212,11 @@ var form = (items) => {
|
|
|
37350
38212
|
}
|
|
37351
38213
|
return formData;
|
|
37352
38214
|
};
|
|
37353
|
-
var randomId = typeof crypto > "u" ? () => {
|
|
38215
|
+
var randomId = typeof crypto > "u" || isCloudflareWorker() ? () => {
|
|
37354
38216
|
let result = "";
|
|
37355
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
38217
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
37356
38218
|
for (let i = 0;i < 16; i++)
|
|
37357
|
-
result += characters.charAt(Math.floor(Math.random() *
|
|
38219
|
+
result += characters.charAt(Math.floor(Math.random() * 62));
|
|
37358
38220
|
return result;
|
|
37359
38221
|
} : () => {
|
|
37360
38222
|
const uuid2 = crypto.randomUUID();
|
|
@@ -37580,7 +38442,7 @@ class ValidationError2 extends Error {
|
|
|
37580
38442
|
value,
|
|
37581
38443
|
property: accessor,
|
|
37582
38444
|
message: error2?.message,
|
|
37583
|
-
summary: mapValueError(error2)
|
|
38445
|
+
summary: mapValueError(error2)?.summary,
|
|
37584
38446
|
found: value,
|
|
37585
38447
|
expected,
|
|
37586
38448
|
errors: "Errors" in validator ? [
|
|
@@ -37597,7 +38459,7 @@ class ValidationError2 extends Error {
|
|
|
37597
38459
|
on: type,
|
|
37598
38460
|
property: accessor,
|
|
37599
38461
|
message: error2?.message,
|
|
37600
|
-
summary: mapValueError(error2)
|
|
38462
|
+
summary: mapValueError(error2)?.summary,
|
|
37601
38463
|
expected,
|
|
37602
38464
|
found: value,
|
|
37603
38465
|
errors: "Errors" in validator ? [...validator.Errors(value)].map(mapValueError) : [...exports_value2.Errors(validator, value)].map(mapValueError)
|
|
@@ -37621,7 +38483,7 @@ class ValidationError2 extends Error {
|
|
|
37621
38483
|
path: issue2.path?.join(".") || "root",
|
|
37622
38484
|
message: issue2.message,
|
|
37623
38485
|
value: this.value
|
|
37624
|
-
})) || [] : ("Errors" in this.validator) ? [...this.validator.Errors(this.value)].map(mapValueError) : [...exports_value2.Errors(this.validator, this.value)].map(mapValueError);
|
|
38486
|
+
})) || [] : ("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
38487
|
}
|
|
37626
38488
|
static simplifyModel(validator) {
|
|
37627
38489
|
const model = "schema" in validator ? validator.schema : validator;
|
|
@@ -37657,7 +38519,7 @@ class ValidationError2 extends Error {
|
|
|
37657
38519
|
on: this.type,
|
|
37658
38520
|
property: this.valueError?.path || "root",
|
|
37659
38521
|
message,
|
|
37660
|
-
summary:
|
|
38522
|
+
summary: mapValueError(this.valueError)?.summary,
|
|
37661
38523
|
found: value,
|
|
37662
38524
|
expected,
|
|
37663
38525
|
errors: errors3
|
|
@@ -37758,7 +38620,7 @@ var fullFormats = {
|
|
|
37758
38620
|
uri,
|
|
37759
38621
|
"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
38622
|
"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):\/\/(
|
|
38623
|
+
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
38624
|
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
38625
|
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
38626
|
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 +39071,270 @@ t.BooleanString = ElysiaType.BooleanString, t.ObjectString = ElysiaType.ObjectSt
|
|
|
38209
39071
|
}
|
|
38210
39072
|
})), 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
39073
|
|
|
39074
|
+
// node_modules/elysia/dist/sucrose.mjs
|
|
39075
|
+
var separateFunction = (code) => {
|
|
39076
|
+
code.startsWith("async") && (code = code.slice(5)), code = code.trimStart();
|
|
39077
|
+
let index = -1;
|
|
39078
|
+
if (code.charCodeAt(0) === 40 && (index = code.indexOf("=>", code.indexOf(")")), index !== -1)) {
|
|
39079
|
+
let bracketEndIndex = index;
|
|
39080
|
+
for (;bracketEndIndex > 0 && code.charCodeAt(--bracketEndIndex) !== 41; )
|
|
39081
|
+
;
|
|
39082
|
+
let body = code.slice(index + 2);
|
|
39083
|
+
return body.charCodeAt(0) === 32 && (body = body.trimStart()), [
|
|
39084
|
+
code.slice(1, bracketEndIndex),
|
|
39085
|
+
body,
|
|
39086
|
+
{
|
|
39087
|
+
isArrowReturn: body.charCodeAt(0) !== 123
|
|
39088
|
+
}
|
|
39089
|
+
];
|
|
39090
|
+
}
|
|
39091
|
+
if (/^(\w+)=>/g.test(code) && (index = code.indexOf("=>"), index !== -1)) {
|
|
39092
|
+
let body = code.slice(index + 2);
|
|
39093
|
+
return body.charCodeAt(0) === 32 && (body = body.trimStart()), [
|
|
39094
|
+
code.slice(0, index),
|
|
39095
|
+
body,
|
|
39096
|
+
{
|
|
39097
|
+
isArrowReturn: body.charCodeAt(0) !== 123
|
|
39098
|
+
}
|
|
39099
|
+
];
|
|
39100
|
+
}
|
|
39101
|
+
if (code.startsWith("function")) {
|
|
39102
|
+
index = code.indexOf("(");
|
|
39103
|
+
const end = code.indexOf(")");
|
|
39104
|
+
return [
|
|
39105
|
+
code.slice(index + 1, end),
|
|
39106
|
+
code.slice(end + 2),
|
|
39107
|
+
{
|
|
39108
|
+
isArrowReturn: false
|
|
39109
|
+
}
|
|
39110
|
+
];
|
|
39111
|
+
}
|
|
39112
|
+
const start = code.indexOf("(");
|
|
39113
|
+
if (start !== -1) {
|
|
39114
|
+
const sep = code.indexOf(`
|
|
39115
|
+
`, 2), parameter = code.slice(0, sep), end = parameter.lastIndexOf(")") + 1, body = code.slice(sep + 1);
|
|
39116
|
+
return [
|
|
39117
|
+
parameter.slice(start, end),
|
|
39118
|
+
"{" + body,
|
|
39119
|
+
{
|
|
39120
|
+
isArrowReturn: false
|
|
39121
|
+
}
|
|
39122
|
+
];
|
|
39123
|
+
}
|
|
39124
|
+
const x = code.split(`
|
|
39125
|
+
`, 2);
|
|
39126
|
+
return [x[0], x[1], { isArrowReturn: false }];
|
|
39127
|
+
};
|
|
39128
|
+
var bracketPairRange = (parameter) => {
|
|
39129
|
+
const start = parameter.indexOf("{");
|
|
39130
|
+
if (start === -1)
|
|
39131
|
+
return [-1, 0];
|
|
39132
|
+
let end = start + 1, deep = 1;
|
|
39133
|
+
for (;end < parameter.length; end++) {
|
|
39134
|
+
const char = parameter.charCodeAt(end);
|
|
39135
|
+
if (char === 123 ? deep++ : char === 125 && deep--, deep === 0)
|
|
39136
|
+
break;
|
|
39137
|
+
}
|
|
39138
|
+
return deep !== 0 ? [0, parameter.length] : [start, end + 1];
|
|
39139
|
+
};
|
|
39140
|
+
var bracketPairRangeReverse = (parameter) => {
|
|
39141
|
+
const end = parameter.lastIndexOf("}");
|
|
39142
|
+
if (end === -1)
|
|
39143
|
+
return [-1, 0];
|
|
39144
|
+
let start = end - 1, deep = 1;
|
|
39145
|
+
for (;start >= 0; start--) {
|
|
39146
|
+
const char = parameter.charCodeAt(start);
|
|
39147
|
+
if (char === 125 ? deep++ : char === 123 && deep--, deep === 0)
|
|
39148
|
+
break;
|
|
39149
|
+
}
|
|
39150
|
+
return deep !== 0 ? [-1, 0] : [start, end + 1];
|
|
39151
|
+
};
|
|
39152
|
+
var removeColonAlias = (parameter) => {
|
|
39153
|
+
for (;; ) {
|
|
39154
|
+
const start = parameter.indexOf(":");
|
|
39155
|
+
if (start === -1)
|
|
39156
|
+
break;
|
|
39157
|
+
let end = parameter.indexOf(",", start);
|
|
39158
|
+
end === -1 && (end = parameter.indexOf("}", start) - 1), end === -2 && (end = parameter.length), parameter = parameter.slice(0, start) + parameter.slice(end);
|
|
39159
|
+
}
|
|
39160
|
+
return parameter;
|
|
39161
|
+
};
|
|
39162
|
+
var retrieveRootparameters = (parameter) => {
|
|
39163
|
+
let hasParenthesis = false;
|
|
39164
|
+
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();
|
|
39165
|
+
let parameters = [];
|
|
39166
|
+
for (;; ) {
|
|
39167
|
+
let [start, end] = bracketPairRange(parameter);
|
|
39168
|
+
if (start === -1)
|
|
39169
|
+
break;
|
|
39170
|
+
parameters.push(parameter.slice(0, start - 1)), parameter.charCodeAt(end) === 44 && end++, parameter = parameter.slice(end);
|
|
39171
|
+
}
|
|
39172
|
+
parameter = removeColonAlias(parameter), parameter && (parameters = parameters.concat(parameter.split(",")));
|
|
39173
|
+
const parameterMap = /* @__PURE__ */ Object.create(null);
|
|
39174
|
+
for (const p of parameters) {
|
|
39175
|
+
if (p.indexOf(",") === -1) {
|
|
39176
|
+
parameterMap[p] = true;
|
|
39177
|
+
continue;
|
|
39178
|
+
}
|
|
39179
|
+
for (const q of p.split(","))
|
|
39180
|
+
parameterMap[q.trim()] = true;
|
|
39181
|
+
}
|
|
39182
|
+
return {
|
|
39183
|
+
hasParenthesis,
|
|
39184
|
+
parameters: parameterMap
|
|
39185
|
+
};
|
|
39186
|
+
};
|
|
39187
|
+
var findParameterReference = (parameter, inference) => {
|
|
39188
|
+
const { parameters, hasParenthesis } = retrieveRootparameters(parameter);
|
|
39189
|
+
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(", ");
|
|
39190
|
+
};
|
|
39191
|
+
var findEndIndex = (type, content, index) => {
|
|
39192
|
+
const regex2 = new RegExp(`${type.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\n\\t,; ]`);
|
|
39193
|
+
index !== undefined && (regex2.lastIndex = index);
|
|
39194
|
+
const match = regex2.exec(content);
|
|
39195
|
+
return match ? match.index : -1;
|
|
39196
|
+
};
|
|
39197
|
+
var findAlias = (type, body, depth = 0) => {
|
|
39198
|
+
if (depth > 5)
|
|
39199
|
+
return [];
|
|
39200
|
+
const aliases = [];
|
|
39201
|
+
let content = body;
|
|
39202
|
+
for (;; ) {
|
|
39203
|
+
let index = findEndIndex(" = " + type, content);
|
|
39204
|
+
if (index === -1 && (index = findEndIndex("=" + type, content)), index === -1) {
|
|
39205
|
+
let lastIndex = content.indexOf(" = " + type);
|
|
39206
|
+
if (lastIndex === -1 && (lastIndex = content.indexOf("=" + type)), lastIndex + 3 + type.length !== content.length)
|
|
39207
|
+
break;
|
|
39208
|
+
index = lastIndex;
|
|
39209
|
+
}
|
|
39210
|
+
const part = content.slice(0, index), lastPart = part.lastIndexOf(" ");
|
|
39211
|
+
let variable = part.slice(lastPart !== -1 ? lastPart + 1 : -1);
|
|
39212
|
+
if (variable === "}") {
|
|
39213
|
+
const [start, end] = bracketPairRangeReverse(part);
|
|
39214
|
+
aliases.push(removeColonAlias(content.slice(start, end))), content = content.slice(index + 3 + type.length);
|
|
39215
|
+
continue;
|
|
39216
|
+
}
|
|
39217
|
+
for (;variable.charCodeAt(0) === 44; )
|
|
39218
|
+
variable = variable.slice(1);
|
|
39219
|
+
for (;variable.charCodeAt(0) === 9; )
|
|
39220
|
+
variable = variable.slice(1);
|
|
39221
|
+
variable.includes("(") || aliases.push(variable), content = content.slice(index + 3 + type.length);
|
|
39222
|
+
}
|
|
39223
|
+
for (const alias of aliases) {
|
|
39224
|
+
if (alias.charCodeAt(0) === 123)
|
|
39225
|
+
continue;
|
|
39226
|
+
const deepAlias = findAlias(alias, body);
|
|
39227
|
+
deepAlias.length > 0 && aliases.push(...deepAlias);
|
|
39228
|
+
}
|
|
39229
|
+
return aliases;
|
|
39230
|
+
};
|
|
39231
|
+
var extractMainParameter = (parameter) => {
|
|
39232
|
+
if (!parameter)
|
|
39233
|
+
return;
|
|
39234
|
+
if (parameter.charCodeAt(0) !== 123)
|
|
39235
|
+
return parameter;
|
|
39236
|
+
if (parameter = parameter.slice(2, -2), !parameter.includes(","))
|
|
39237
|
+
return parameter.indexOf("...") !== -1 ? parameter.slice(parameter.indexOf("...") + 3) : undefined;
|
|
39238
|
+
const spreadIndex = parameter.indexOf("...");
|
|
39239
|
+
if (spreadIndex !== -1)
|
|
39240
|
+
return parameter.slice(spreadIndex + 3).trimEnd();
|
|
39241
|
+
};
|
|
39242
|
+
var inferBodyReference = (code, aliases, inference) => {
|
|
39243
|
+
const access = (type, alias) => new RegExp(`${alias}\\.(${type})|${alias}\\["${type}"\\]|${alias}\\['${type}'\\]`).test(code);
|
|
39244
|
+
for (const alias of aliases)
|
|
39245
|
+
if (alias) {
|
|
39246
|
+
if (alias.charCodeAt(0) === 123) {
|
|
39247
|
+
const parameters = retrieveRootparameters(alias).parameters;
|
|
39248
|
+
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);
|
|
39249
|
+
continue;
|
|
39250
|
+
}
|
|
39251
|
+
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)
|
|
39252
|
+
break;
|
|
39253
|
+
}
|
|
39254
|
+
return aliases;
|
|
39255
|
+
};
|
|
39256
|
+
var isContextPassToFunction = (context, body, inference) => {
|
|
39257
|
+
try {
|
|
39258
|
+
const captureFunction = new RegExp(`\\w\\((?:.*?)?${context}(?:.*?)?\\)`, "gs"), exactParameter = new RegExp(`${context}(,|\\))`, "gs"), length = body.length;
|
|
39259
|
+
let fn;
|
|
39260
|
+
for (fn = captureFunction.exec(body) + "";captureFunction.lastIndex !== 0 && captureFunction.lastIndex < length + (fn ? fn.length : 0); ) {
|
|
39261
|
+
if (fn && exactParameter.test(fn))
|
|
39262
|
+
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;
|
|
39263
|
+
fn = captureFunction.exec(body) + "";
|
|
39264
|
+
}
|
|
39265
|
+
const nextChar = body.charCodeAt(captureFunction.lastIndex);
|
|
39266
|
+
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;
|
|
39267
|
+
} catch {
|
|
39268
|
+
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;
|
|
39269
|
+
}
|
|
39270
|
+
};
|
|
39271
|
+
var pendingGC;
|
|
39272
|
+
var caches2 = {};
|
|
39273
|
+
var clearSucroseCache = (delay) => {
|
|
39274
|
+
delay === null || isCloudflareWorker() || (delay === undefined && (delay = 4 * 60 * 1000 + 55 * 1000), pendingGC && clearTimeout(pendingGC), pendingGC = setTimeout(() => {
|
|
39275
|
+
caches2 = {}, pendingGC = undefined, isBun && Bun.gc(false);
|
|
39276
|
+
}, delay), pendingGC.unref?.());
|
|
39277
|
+
};
|
|
39278
|
+
var mergeInference = (a, b) => ({
|
|
39279
|
+
body: a.body || b.body,
|
|
39280
|
+
cookie: a.cookie || b.cookie,
|
|
39281
|
+
headers: a.headers || b.headers,
|
|
39282
|
+
query: a.query || b.query,
|
|
39283
|
+
set: a.set || b.set,
|
|
39284
|
+
server: a.server || b.server,
|
|
39285
|
+
url: a.url || b.url,
|
|
39286
|
+
route: a.route || b.route,
|
|
39287
|
+
path: a.path || b.path
|
|
39288
|
+
});
|
|
39289
|
+
var sucrose = (lifeCycle, inference = {
|
|
39290
|
+
query: false,
|
|
39291
|
+
headers: false,
|
|
39292
|
+
body: false,
|
|
39293
|
+
cookie: false,
|
|
39294
|
+
set: false,
|
|
39295
|
+
server: false,
|
|
39296
|
+
url: false,
|
|
39297
|
+
route: false,
|
|
39298
|
+
path: false
|
|
39299
|
+
}, settings = {}) => {
|
|
39300
|
+
const events = [];
|
|
39301
|
+
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);
|
|
39302
|
+
for (let i = 0;i < events.length; i++) {
|
|
39303
|
+
const e = events[i];
|
|
39304
|
+
if (!e)
|
|
39305
|
+
continue;
|
|
39306
|
+
const event = typeof e == "object" ? e.fn : e;
|
|
39307
|
+
if (typeof event != "function")
|
|
39308
|
+
continue;
|
|
39309
|
+
const content = event.toString(), key = checksum(content), cachedInference = caches2[key];
|
|
39310
|
+
if (cachedInference) {
|
|
39311
|
+
inference = mergeInference(inference, cachedInference);
|
|
39312
|
+
continue;
|
|
39313
|
+
}
|
|
39314
|
+
clearSucroseCache(settings.gcTime);
|
|
39315
|
+
const fnInference = {
|
|
39316
|
+
query: false,
|
|
39317
|
+
headers: false,
|
|
39318
|
+
body: false,
|
|
39319
|
+
cookie: false,
|
|
39320
|
+
set: false,
|
|
39321
|
+
server: false,
|
|
39322
|
+
url: false,
|
|
39323
|
+
route: false,
|
|
39324
|
+
path: false
|
|
39325
|
+
}, [parameter, body] = separateFunction(content), rootParameters = findParameterReference(parameter, fnInference), mainParameter = extractMainParameter(rootParameters);
|
|
39326
|
+
if (mainParameter) {
|
|
39327
|
+
const aliases = findAlias(mainParameter, body.slice(1, -1));
|
|
39328
|
+
aliases.splice(0, -1, mainParameter);
|
|
39329
|
+
let code = body;
|
|
39330
|
+
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);
|
|
39331
|
+
}
|
|
39332
|
+
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)
|
|
39333
|
+
break;
|
|
39334
|
+
}
|
|
39335
|
+
return inference;
|
|
39336
|
+
};
|
|
39337
|
+
|
|
38212
39338
|
// node_modules/elysia/dist/cookies.mjs
|
|
38213
39339
|
var import_cookie = __toESM(require_dist2(), 1);
|
|
38214
39340
|
var import_fast_decode_uri_component = __toESM(require_fast_decode_uri_component(), 1);
|
|
@@ -38221,7 +39347,7 @@ var hashString = (str) => {
|
|
|
38221
39347
|
};
|
|
38222
39348
|
|
|
38223
39349
|
class Cookie {
|
|
38224
|
-
constructor(name, jar, initial =
|
|
39350
|
+
constructor(name, jar, initial = /* @__PURE__ */ Object.create(null)) {
|
|
38225
39351
|
this.name = name;
|
|
38226
39352
|
this.jar = jar;
|
|
38227
39353
|
this.initial = initial;
|
|
@@ -38341,7 +39467,7 @@ class Cookie {
|
|
|
38341
39467
|
return typeof this.value == "object" ? JSON.stringify(this.value) : this.value?.toString() ?? "";
|
|
38342
39468
|
}
|
|
38343
39469
|
}
|
|
38344
|
-
var createCookieJar = (set2, store, initial) => (set2.cookie || (set2.cookie =
|
|
39470
|
+
var createCookieJar = (set2, store, initial) => (set2.cookie || (set2.cookie = /* @__PURE__ */ Object.create(null)), new Proxy(store, {
|
|
38345
39471
|
get(_, key) {
|
|
38346
39472
|
return key in store ? new Cookie(key, set2.cookie, Object.assign({}, initial ?? {}, store[key])) : new Cookie(key, set2.cookie, Object.assign({}, initial));
|
|
38347
39473
|
}
|
|
@@ -38350,23 +39476,16 @@ var parseCookie = async (set2, cookieString, {
|
|
|
38350
39476
|
secrets,
|
|
38351
39477
|
sign,
|
|
38352
39478
|
...initial
|
|
38353
|
-
} =
|
|
39479
|
+
} = /* @__PURE__ */ Object.create(null)) => {
|
|
38354
39480
|
if (!cookieString)
|
|
38355
|
-
return createCookieJar(set2,
|
|
39481
|
+
return createCookieJar(set2, /* @__PURE__ */ Object.create(null), initial);
|
|
38356
39482
|
const isStringKey = typeof secrets == "string";
|
|
38357
39483
|
sign && sign !== true && !Array.isArray(sign) && (sign = [sign]);
|
|
38358
|
-
const jar =
|
|
39484
|
+
const jar = /* @__PURE__ */ Object.create(null), cookies = import_cookie.parse(cookieString);
|
|
38359
39485
|
for (const [name, v] of Object.entries(cookies)) {
|
|
38360
|
-
if (v === undefined)
|
|
39486
|
+
if (v === undefined || name === "__proto__" || name === "constructor" || name === "prototype")
|
|
38361
39487
|
continue;
|
|
38362
39488
|
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
39489
|
if (sign === true || sign?.includes(name)) {
|
|
38371
39490
|
if (!secrets)
|
|
38372
39491
|
throw new Error("No secret is provided to cookie plugin");
|
|
@@ -38392,9 +39511,14 @@ var parseCookie = async (set2, cookieString, {
|
|
|
38392
39511
|
throw new InvalidCookieSignature(name);
|
|
38393
39512
|
}
|
|
38394
39513
|
}
|
|
38395
|
-
|
|
38396
|
-
value
|
|
38397
|
-
|
|
39514
|
+
if (value) {
|
|
39515
|
+
const starts = value.charCodeAt(0), ends = value.charCodeAt(value.length - 1);
|
|
39516
|
+
if (starts === 123 && ends === 125 || starts === 91 && ends === 93)
|
|
39517
|
+
try {
|
|
39518
|
+
value = JSON.parse(value);
|
|
39519
|
+
} catch {}
|
|
39520
|
+
}
|
|
39521
|
+
jar[name] = /* @__PURE__ */ Object.create(null), jar[name].value = value;
|
|
38398
39522
|
}
|
|
38399
39523
|
return createCookieJar(set2, jar, initial);
|
|
38400
39524
|
};
|
|
@@ -38572,32 +39696,33 @@ var handleSet = (set2) => {
|
|
|
38572
39696
|
}
|
|
38573
39697
|
set2.headers["set-cookie"] && Array.isArray(set2.headers["set-cookie"]) && (set2.headers = parseSetCookies(new Headers(set2.headers), set2.headers["set-cookie"]));
|
|
38574
39698
|
};
|
|
39699
|
+
function mergeHeaders(responseHeaders, setHeaders) {
|
|
39700
|
+
const headers = new Headers(responseHeaders);
|
|
39701
|
+
if (setHeaders instanceof Headers)
|
|
39702
|
+
for (const key of setHeaders.keys())
|
|
39703
|
+
if (key === "set-cookie") {
|
|
39704
|
+
if (headers.has("set-cookie"))
|
|
39705
|
+
continue;
|
|
39706
|
+
for (const cookie of setHeaders.getSetCookie())
|
|
39707
|
+
headers.append("set-cookie", cookie);
|
|
39708
|
+
} else
|
|
39709
|
+
responseHeaders.has(key) || headers.set(key, setHeaders?.get(key) ?? "");
|
|
39710
|
+
else
|
|
39711
|
+
for (const key in setHeaders)
|
|
39712
|
+
key === "set-cookie" ? headers.append(key, setHeaders[key]) : responseHeaders.has(key) || headers.set(key, setHeaders[key]);
|
|
39713
|
+
return headers;
|
|
39714
|
+
}
|
|
39715
|
+
function mergeStatus(responseStatus, setStatus) {
|
|
39716
|
+
return typeof setStatus == "string" && (setStatus = StatusMap[setStatus]), responseStatus === 200 ? setStatus : responseStatus;
|
|
39717
|
+
}
|
|
38575
39718
|
var createResponseHandler = (handler) => {
|
|
38576
39719
|
const handleStream = createStreamHandler(handler);
|
|
38577
39720
|
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;
|
|
39721
|
+
const newResponse = new Response(response.body, {
|
|
39722
|
+
headers: mergeHeaders(response.headers, set2.headers),
|
|
39723
|
+
status: mergeStatus(response.status, set2.status)
|
|
39724
|
+
});
|
|
39725
|
+
return !newResponse.headers.has("content-length") && newResponse.headers.get("transfer-encoding") === "chunked" ? handleStream(streamResponse(newResponse), responseToSetHeaders(newResponse, set2), request, true) : newResponse;
|
|
38601
39726
|
};
|
|
38602
39727
|
};
|
|
38603
39728
|
async function tee(source, branches = 2) {
|
|
@@ -38678,6 +39803,12 @@ var mapResponse = (response, set2, request) => {
|
|
|
38678
39803
|
return handleStream(response, set2, request);
|
|
38679
39804
|
if (typeof response?.then == "function")
|
|
38680
39805
|
return response.then((x) => mapResponse(x, set2));
|
|
39806
|
+
if (Array.isArray(response))
|
|
39807
|
+
return new Response(JSON.stringify(response), {
|
|
39808
|
+
headers: {
|
|
39809
|
+
"Content-Type": "application/json"
|
|
39810
|
+
}
|
|
39811
|
+
});
|
|
38681
39812
|
if (typeof response?.toResponse == "function")
|
|
38682
39813
|
return mapResponse(response.toResponse(), set2);
|
|
38683
39814
|
if ("charCodeAt" in response) {
|
|
@@ -38738,6 +39869,12 @@ var mapEarlyResponse = (response, set2, request) => {
|
|
|
38738
39869
|
return response.then((x) => mapEarlyResponse(x, set2));
|
|
38739
39870
|
if (typeof response?.toResponse == "function")
|
|
38740
39871
|
return mapEarlyResponse(response.toResponse(), set2);
|
|
39872
|
+
if (Array.isArray(response))
|
|
39873
|
+
return new Response(JSON.stringify(response), {
|
|
39874
|
+
headers: {
|
|
39875
|
+
"Content-Type": "application/json"
|
|
39876
|
+
}
|
|
39877
|
+
});
|
|
38741
39878
|
if ("charCodeAt" in response) {
|
|
38742
39879
|
const code = response.charCodeAt(0);
|
|
38743
39880
|
if (code === 123 || code === 91)
|
|
@@ -38800,6 +39937,12 @@ var mapEarlyResponse = (response, set2, request) => {
|
|
|
38800
39937
|
return response.then((x) => mapEarlyResponse(x, set2));
|
|
38801
39938
|
if (typeof response?.toResponse == "function")
|
|
38802
39939
|
return mapEarlyResponse(response.toResponse(), set2);
|
|
39940
|
+
if (Array.isArray(response))
|
|
39941
|
+
return new Response(JSON.stringify(response), {
|
|
39942
|
+
headers: {
|
|
39943
|
+
"Content-Type": "application/json"
|
|
39944
|
+
}
|
|
39945
|
+
});
|
|
38803
39946
|
if ("charCodeAt" in response) {
|
|
38804
39947
|
const code = response.charCodeAt(0);
|
|
38805
39948
|
if (code === 123 || code === 91)
|
|
@@ -38871,6 +40014,12 @@ var mapCompactResponse = (response, request) => {
|
|
|
38871
40014
|
return response.then((x) => mapCompactResponse(x, request));
|
|
38872
40015
|
if (typeof response?.toResponse == "function")
|
|
38873
40016
|
return mapCompactResponse(response.toResponse());
|
|
40017
|
+
if (Array.isArray(response))
|
|
40018
|
+
return new Response(JSON.stringify(response), {
|
|
40019
|
+
headers: {
|
|
40020
|
+
"Content-Type": "application/json"
|
|
40021
|
+
}
|
|
40022
|
+
});
|
|
38874
40023
|
if ("charCodeAt" in response) {
|
|
38875
40024
|
const code = response.charCodeAt(0);
|
|
38876
40025
|
if (code === 123 || code === 91)
|
|
@@ -38954,10 +40103,57 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
38954
40103
|
c.body={}
|
|
38955
40104
|
`;
|
|
38956
40105
|
return isOptional ? fnLiteral += "let form;try{form=await c.request.formData()}catch{}" : fnLiteral += `const form=await c.request.formData()
|
|
38957
|
-
`, fnLiteral + `
|
|
40106
|
+
`, fnLiteral + `const dangerousKeys=new Set(['__proto__','constructor','prototype'])
|
|
40107
|
+
const isDangerousKey=(k)=>{if(dangerousKeys.has(k))return true;const m=k.match(/^(.+)\\[(\\d+)\\]$/);return m?dangerousKeys.has(m[1]):false}
|
|
40108
|
+
const parseArrayKey=(k)=>{const m=k.match(/^(.+)\\[(\\d+)\\]$/);return m?{name:m[1],index:parseInt(m[2],10)}:null}
|
|
40109
|
+
for(const key of form.keys()){if(c.body[key])continue
|
|
38958
40110
|
const value=form.getAll(key)
|
|
38959
|
-
|
|
38960
|
-
|
|
40111
|
+
let finalValue
|
|
40112
|
+
if(value.length===1){
|
|
40113
|
+
const sv=value[0]
|
|
40114
|
+
if(typeof sv==='string'&&(sv.charCodeAt(0)===123||sv.charCodeAt(0)===91)){
|
|
40115
|
+
try{
|
|
40116
|
+
const p=JSON.parse(sv)
|
|
40117
|
+
if(p&&typeof p==='object')finalValue=p
|
|
40118
|
+
}catch{}
|
|
40119
|
+
}
|
|
40120
|
+
if(finalValue===undefined)finalValue=sv
|
|
40121
|
+
}else finalValue=value
|
|
40122
|
+
if(Array.isArray(finalValue)){
|
|
40123
|
+
const stringValue=finalValue.find((entry)=>typeof entry==='string')
|
|
40124
|
+
const files=typeof File==='undefined'?[]:finalValue.filter((entry)=>entry instanceof File)
|
|
40125
|
+
if(stringValue&&files.length&&stringValue.charCodeAt(0)===123){
|
|
40126
|
+
try{
|
|
40127
|
+
const parsed=JSON.parse(stringValue)
|
|
40128
|
+
if(parsed&&typeof parsed==='object'&&!Array.isArray(parsed)){
|
|
40129
|
+
if(!('file' in parsed)&&files.length===1)parsed.file=files[0]
|
|
40130
|
+
else if(!('files' in parsed)&&files.length>1)parsed.files=files
|
|
40131
|
+
finalValue=parsed
|
|
40132
|
+
}
|
|
40133
|
+
}catch{}
|
|
40134
|
+
}
|
|
40135
|
+
}
|
|
40136
|
+
if(key.includes('.')||key.includes('[')){const keys=key.split('.')
|
|
40137
|
+
const lastKey=keys.pop()
|
|
40138
|
+
if(isDangerousKey(lastKey)||keys.some(isDangerousKey))continue
|
|
40139
|
+
let current=c.body
|
|
40140
|
+
for(const k of keys){const arrayInfo=parseArrayKey(k)
|
|
40141
|
+
if(arrayInfo){if(!Array.isArray(current[arrayInfo.name]))current[arrayInfo.name]=[]
|
|
40142
|
+
const existing=current[arrayInfo.name][arrayInfo.index]
|
|
40143
|
+
const isFile=typeof File!=='undefined'&&existing instanceof File
|
|
40144
|
+
if(!existing||typeof existing!=='object'||Array.isArray(existing)||isFile){
|
|
40145
|
+
let parsed
|
|
40146
|
+
if(typeof existing==='string'&&existing.charCodeAt(0)===123){
|
|
40147
|
+
try{parsed=JSON.parse(existing)
|
|
40148
|
+
if(!parsed||typeof parsed!=='object'||Array.isArray(parsed))parsed=undefined}catch{}
|
|
40149
|
+
}
|
|
40150
|
+
current[arrayInfo.name][arrayInfo.index]=parsed||{}
|
|
40151
|
+
}
|
|
40152
|
+
current=current[arrayInfo.name][arrayInfo.index]}else{if(!current[k]||typeof current[k]!=='object')current[k]={}
|
|
40153
|
+
current=current[k]}}
|
|
40154
|
+
const arrayInfo=parseArrayKey(lastKey)
|
|
40155
|
+
if(arrayInfo){if(!Array.isArray(current[arrayInfo.name]))current[arrayInfo.name]=[]
|
|
40156
|
+
current[arrayInfo.name][arrayInfo.index]=finalValue}else{current[lastKey]=finalValue}}else c.body[key]=finalValue}`;
|
|
38961
40157
|
}
|
|
38962
40158
|
}
|
|
38963
40159
|
},
|
|
@@ -39004,6 +40200,278 @@ const error404=new Response(error404Message,{status:404})
|
|
|
39004
40200
|
}
|
|
39005
40201
|
};
|
|
39006
40202
|
|
|
40203
|
+
// node_modules/elysia/dist/adapter/bun/handler.mjs
|
|
40204
|
+
var mapResponse2 = (response, set2, request) => {
|
|
40205
|
+
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.cookie)
|
|
40206
|
+
switch (handleSet(set2), response?.constructor?.name) {
|
|
40207
|
+
case "String":
|
|
40208
|
+
return new Response(response, set2);
|
|
40209
|
+
case "Array":
|
|
40210
|
+
case "Object":
|
|
40211
|
+
return Response.json(response, set2);
|
|
40212
|
+
case "ElysiaFile":
|
|
40213
|
+
return handleFile(response.value, set2);
|
|
40214
|
+
case "File":
|
|
40215
|
+
return handleFile(response, set2);
|
|
40216
|
+
case "Blob":
|
|
40217
|
+
return handleFile(response, set2);
|
|
40218
|
+
case "ElysiaCustomStatusResponse":
|
|
40219
|
+
return set2.status = response.code, mapResponse2(response.response, set2, request);
|
|
40220
|
+
case undefined:
|
|
40221
|
+
return response ? Response.json(response, set2) : new Response("", set2);
|
|
40222
|
+
case "Response":
|
|
40223
|
+
return handleResponse2(response, set2, request);
|
|
40224
|
+
case "Error":
|
|
40225
|
+
return errorToResponse2(response, set2);
|
|
40226
|
+
case "Promise":
|
|
40227
|
+
return response.then((x) => mapResponse2(x, set2, request));
|
|
40228
|
+
case "Function":
|
|
40229
|
+
return mapResponse2(response(), set2, request);
|
|
40230
|
+
case "Number":
|
|
40231
|
+
case "Boolean":
|
|
40232
|
+
return new Response(response.toString(), set2);
|
|
40233
|
+
case "Cookie":
|
|
40234
|
+
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
40235
|
+
case "FormData":
|
|
40236
|
+
return new Response(response, set2);
|
|
40237
|
+
default:
|
|
40238
|
+
if (response instanceof Response)
|
|
40239
|
+
return handleResponse2(response, set2, request);
|
|
40240
|
+
if (response instanceof Promise)
|
|
40241
|
+
return response.then((x) => mapResponse2(x, set2));
|
|
40242
|
+
if (response instanceof Error)
|
|
40243
|
+
return errorToResponse2(response, set2);
|
|
40244
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40245
|
+
return set2.status = response.code, mapResponse2(response.response, set2, request);
|
|
40246
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40247
|
+
return handleStream2(response, set2, request);
|
|
40248
|
+
if (typeof response?.then == "function")
|
|
40249
|
+
return response.then((x) => mapResponse2(x, set2));
|
|
40250
|
+
if (Array.isArray(response))
|
|
40251
|
+
return Response.json(response);
|
|
40252
|
+
if (typeof response?.toResponse == "function")
|
|
40253
|
+
return mapResponse2(response.toResponse(), set2);
|
|
40254
|
+
if ("charCodeAt" in response) {
|
|
40255
|
+
const code = response.charCodeAt(0);
|
|
40256
|
+
if (code === 123 || code === 91)
|
|
40257
|
+
return Response.json(response, set2);
|
|
40258
|
+
}
|
|
40259
|
+
return new Response(response, set2);
|
|
40260
|
+
}
|
|
40261
|
+
return typeof response?.next == "function" || response instanceof ReadableStream ? handleStream2(response, set2, request) : mapCompactResponse2(response, request);
|
|
40262
|
+
};
|
|
40263
|
+
var mapEarlyResponse2 = (response, set2, request) => {
|
|
40264
|
+
if (response != null)
|
|
40265
|
+
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.cookie)
|
|
40266
|
+
switch (handleSet(set2), response?.constructor?.name) {
|
|
40267
|
+
case "String":
|
|
40268
|
+
return new Response(response, set2);
|
|
40269
|
+
case "Array":
|
|
40270
|
+
case "Object":
|
|
40271
|
+
return Response.json(response, set2);
|
|
40272
|
+
case "ElysiaFile":
|
|
40273
|
+
return handleFile(response.value, set2);
|
|
40274
|
+
case "File":
|
|
40275
|
+
return handleFile(response, set2);
|
|
40276
|
+
case "Blob":
|
|
40277
|
+
return handleFile(response, set2);
|
|
40278
|
+
case "ElysiaCustomStatusResponse":
|
|
40279
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40280
|
+
case undefined:
|
|
40281
|
+
return response ? Response.json(response, set2) : undefined;
|
|
40282
|
+
case "Response":
|
|
40283
|
+
return handleResponse2(response, set2, request);
|
|
40284
|
+
case "Promise":
|
|
40285
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40286
|
+
case "Error":
|
|
40287
|
+
return errorToResponse2(response, set2);
|
|
40288
|
+
case "Function":
|
|
40289
|
+
return mapEarlyResponse2(response(), set2);
|
|
40290
|
+
case "Number":
|
|
40291
|
+
case "Boolean":
|
|
40292
|
+
return new Response(response.toString(), set2);
|
|
40293
|
+
case "FormData":
|
|
40294
|
+
return new Response(response);
|
|
40295
|
+
case "Cookie":
|
|
40296
|
+
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
40297
|
+
default:
|
|
40298
|
+
if (response instanceof Response)
|
|
40299
|
+
return handleResponse2(response, set2, request);
|
|
40300
|
+
if (response instanceof Promise)
|
|
40301
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40302
|
+
if (response instanceof Error)
|
|
40303
|
+
return errorToResponse2(response, set2);
|
|
40304
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40305
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40306
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40307
|
+
return handleStream2(response, set2, request);
|
|
40308
|
+
if (typeof response?.then == "function")
|
|
40309
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40310
|
+
if (typeof response?.toResponse == "function")
|
|
40311
|
+
return mapEarlyResponse2(response.toResponse(), set2);
|
|
40312
|
+
if (Array.isArray(response))
|
|
40313
|
+
return Response.json(response);
|
|
40314
|
+
if ("charCodeAt" in response) {
|
|
40315
|
+
const code = response.charCodeAt(0);
|
|
40316
|
+
if (code === 123 || code === 91)
|
|
40317
|
+
return Response.json(response, set2);
|
|
40318
|
+
}
|
|
40319
|
+
return new Response(response, set2);
|
|
40320
|
+
}
|
|
40321
|
+
else
|
|
40322
|
+
switch (response?.constructor?.name) {
|
|
40323
|
+
case "String":
|
|
40324
|
+
return new Response(response);
|
|
40325
|
+
case "Array":
|
|
40326
|
+
case "Object":
|
|
40327
|
+
return Response.json(response, set2);
|
|
40328
|
+
case "ElysiaFile":
|
|
40329
|
+
return handleFile(response.value, set2);
|
|
40330
|
+
case "File":
|
|
40331
|
+
return handleFile(response, set2);
|
|
40332
|
+
case "Blob":
|
|
40333
|
+
return handleFile(response, set2);
|
|
40334
|
+
case "ElysiaCustomStatusResponse":
|
|
40335
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40336
|
+
case undefined:
|
|
40337
|
+
return response ? Response.json(response) : new Response("");
|
|
40338
|
+
case "Response":
|
|
40339
|
+
return response;
|
|
40340
|
+
case "Promise":
|
|
40341
|
+
return response.then((x) => {
|
|
40342
|
+
const r = mapEarlyResponse2(x, set2);
|
|
40343
|
+
if (r !== undefined)
|
|
40344
|
+
return r;
|
|
40345
|
+
});
|
|
40346
|
+
case "Error":
|
|
40347
|
+
return errorToResponse2(response, set2);
|
|
40348
|
+
case "Function":
|
|
40349
|
+
return mapCompactResponse2(response(), request);
|
|
40350
|
+
case "Number":
|
|
40351
|
+
case "Boolean":
|
|
40352
|
+
return new Response(response.toString());
|
|
40353
|
+
case "Cookie":
|
|
40354
|
+
return response instanceof Cookie ? new Response(response.value, set2) : new Response(response?.toString(), set2);
|
|
40355
|
+
case "FormData":
|
|
40356
|
+
return new Response(response);
|
|
40357
|
+
default:
|
|
40358
|
+
if (response instanceof Response)
|
|
40359
|
+
return response;
|
|
40360
|
+
if (response instanceof Promise)
|
|
40361
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40362
|
+
if (response instanceof Error)
|
|
40363
|
+
return errorToResponse2(response, set2);
|
|
40364
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40365
|
+
return set2.status = response.code, mapEarlyResponse2(response.response, set2, request);
|
|
40366
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40367
|
+
return handleStream2(response, set2, request);
|
|
40368
|
+
if (typeof response?.then == "function")
|
|
40369
|
+
return response.then((x) => mapEarlyResponse2(x, set2));
|
|
40370
|
+
if (typeof response?.toResponse == "function")
|
|
40371
|
+
return mapEarlyResponse2(response.toResponse(), set2);
|
|
40372
|
+
if (Array.isArray(response))
|
|
40373
|
+
return Response.json(response);
|
|
40374
|
+
if ("charCodeAt" in response) {
|
|
40375
|
+
const code = response.charCodeAt(0);
|
|
40376
|
+
if (code === 123 || code === 91)
|
|
40377
|
+
return Response.json(response, set2);
|
|
40378
|
+
}
|
|
40379
|
+
return new Response(response);
|
|
40380
|
+
}
|
|
40381
|
+
};
|
|
40382
|
+
var mapCompactResponse2 = (response, request) => {
|
|
40383
|
+
switch (response?.constructor?.name) {
|
|
40384
|
+
case "String":
|
|
40385
|
+
return new Response(response);
|
|
40386
|
+
case "Object":
|
|
40387
|
+
case "Array":
|
|
40388
|
+
return Response.json(response);
|
|
40389
|
+
case "ElysiaFile":
|
|
40390
|
+
return handleFile(response.value);
|
|
40391
|
+
case "File":
|
|
40392
|
+
return handleFile(response);
|
|
40393
|
+
case "Blob":
|
|
40394
|
+
return handleFile(response);
|
|
40395
|
+
case "ElysiaCustomStatusResponse":
|
|
40396
|
+
return mapResponse2(response.response, {
|
|
40397
|
+
status: response.code,
|
|
40398
|
+
headers: {}
|
|
40399
|
+
});
|
|
40400
|
+
case undefined:
|
|
40401
|
+
return response ? Response.json(response) : new Response("");
|
|
40402
|
+
case "Response":
|
|
40403
|
+
return response;
|
|
40404
|
+
case "Error":
|
|
40405
|
+
return errorToResponse2(response);
|
|
40406
|
+
case "Promise":
|
|
40407
|
+
return response.then((x) => mapCompactResponse2(x, request));
|
|
40408
|
+
case "Function":
|
|
40409
|
+
return mapCompactResponse2(response(), request);
|
|
40410
|
+
case "Number":
|
|
40411
|
+
case "Boolean":
|
|
40412
|
+
return new Response(response.toString());
|
|
40413
|
+
case "FormData":
|
|
40414
|
+
return new Response(response);
|
|
40415
|
+
default:
|
|
40416
|
+
if (response instanceof Response)
|
|
40417
|
+
return response;
|
|
40418
|
+
if (response instanceof Promise)
|
|
40419
|
+
return response.then((x) => mapCompactResponse2(x, request));
|
|
40420
|
+
if (response instanceof Error)
|
|
40421
|
+
return errorToResponse2(response);
|
|
40422
|
+
if (response instanceof ElysiaCustomStatusResponse)
|
|
40423
|
+
return mapResponse2(response.response, {
|
|
40424
|
+
status: response.code,
|
|
40425
|
+
headers: {}
|
|
40426
|
+
});
|
|
40427
|
+
if (typeof response?.next == "function" || response instanceof ReadableStream)
|
|
40428
|
+
return handleStream2(response, undefined, request);
|
|
40429
|
+
if (typeof response?.then == "function")
|
|
40430
|
+
return response.then((x) => mapCompactResponse2(x, request));
|
|
40431
|
+
if (typeof response?.toResponse == "function")
|
|
40432
|
+
return mapCompactResponse2(response.toResponse());
|
|
40433
|
+
if (Array.isArray(response))
|
|
40434
|
+
return Response.json(response);
|
|
40435
|
+
if ("charCodeAt" in response) {
|
|
40436
|
+
const code = response.charCodeAt(0);
|
|
40437
|
+
if (code === 123 || code === 91)
|
|
40438
|
+
return Response.json(response);
|
|
40439
|
+
}
|
|
40440
|
+
return new Response(response);
|
|
40441
|
+
}
|
|
40442
|
+
};
|
|
40443
|
+
var errorToResponse2 = (error2, set2) => {
|
|
40444
|
+
if (typeof error2?.toResponse == "function") {
|
|
40445
|
+
const raw = error2.toResponse(), targetSet = set2 ?? { headers: {}, status: 200, redirect: "" }, apply = (resolved) => (resolved instanceof Response && (targetSet.status = resolved.status), mapResponse2(resolved, targetSet));
|
|
40446
|
+
return typeof raw?.then == "function" ? raw.then(apply) : apply(raw);
|
|
40447
|
+
}
|
|
40448
|
+
return Response.json({
|
|
40449
|
+
name: error2?.name,
|
|
40450
|
+
message: error2?.message,
|
|
40451
|
+
cause: error2?.cause
|
|
40452
|
+
}, {
|
|
40453
|
+
status: set2?.status !== 200 ? set2?.status ?? 500 : 500,
|
|
40454
|
+
headers: set2?.headers
|
|
40455
|
+
});
|
|
40456
|
+
};
|
|
40457
|
+
var createStaticHandler2 = (handle, hooks, setHeaders = {}) => {
|
|
40458
|
+
if (typeof handle == "function")
|
|
40459
|
+
return;
|
|
40460
|
+
const response = mapResponse2(handle, {
|
|
40461
|
+
headers: setHeaders
|
|
40462
|
+
});
|
|
40463
|
+
if (!hooks.parse?.length && !hooks.transform?.length && !hooks.beforeHandle?.length && !hooks.afterHandle?.length)
|
|
40464
|
+
return () => response.clone();
|
|
40465
|
+
};
|
|
40466
|
+
var handleResponse2 = createResponseHandler({
|
|
40467
|
+
mapResponse: mapResponse2,
|
|
40468
|
+
mapCompactResponse: mapCompactResponse2
|
|
40469
|
+
});
|
|
40470
|
+
var handleStream2 = createStreamHandler({
|
|
40471
|
+
mapResponse: mapResponse2,
|
|
40472
|
+
mapCompactResponse: mapCompactResponse2
|
|
40473
|
+
});
|
|
40474
|
+
|
|
39007
40475
|
// node_modules/elysia/dist/compose.mjs
|
|
39008
40476
|
var import_fast_decode_uri_component3 = __toESM(require_fast_decode_uri_component(), 1);
|
|
39009
40477
|
|
|
@@ -39306,7 +40774,7 @@ var handleTuple = (schema, property, instruction) => {
|
|
|
39306
40774
|
for (let i2 = 0;i2 < schema.length; i2++) {
|
|
39307
40775
|
if (i2 !== 0)
|
|
39308
40776
|
v += ",";
|
|
39309
|
-
v += mirror(schema[i2], joinProperty(property, i2, instruction.parentIsOptional), instruction);
|
|
40777
|
+
v += mirror(schema[i2], joinProperty(property, i2, instruction.parentIsOptional || instruction.fromUnion), instruction);
|
|
39310
40778
|
}
|
|
39311
40779
|
v += `];`;
|
|
39312
40780
|
if (!isRoot)
|
|
@@ -39377,13 +40845,15 @@ var handleUnion = (schemas3, property, instruction) => {
|
|
|
39377
40845
|
v += `if(d.unions[${ui}][${i}].Check(${property})){return ${mirror(type, property, {
|
|
39378
40846
|
...instruction,
|
|
39379
40847
|
recursion: instruction.recursion + 1,
|
|
39380
|
-
parentIsOptional: true
|
|
40848
|
+
parentIsOptional: true,
|
|
40849
|
+
fromUnion: true
|
|
39381
40850
|
})}}
|
|
39382
40851
|
`;
|
|
39383
40852
|
cleanThenCheck += (i ? "" : "let ") + "tmp=" + mirror(type, property, {
|
|
39384
40853
|
...instruction,
|
|
39385
40854
|
recursion: instruction.recursion + 1,
|
|
39386
|
-
parentIsOptional: true
|
|
40855
|
+
parentIsOptional: true,
|
|
40856
|
+
fromUnion: true
|
|
39387
40857
|
}) + `
|
|
39388
40858
|
if(d.unions[${ui}][${i}].Check(tmp))return tmp
|
|
39389
40859
|
`;
|
|
@@ -39423,7 +40893,7 @@ var mirror = (schema, property, instruction) => {
|
|
|
39423
40893
|
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
39424
40894
|
const key = keys[i2];
|
|
39425
40895
|
let isOptional = !schema.required || schema.required && !schema.required.includes(key) || Array.isArray(schema.properties[key].anyOf);
|
|
39426
|
-
const name = joinProperty(property, key, instruction.parentIsOptional);
|
|
40896
|
+
const name = joinProperty(property, key, instruction.parentIsOptional || instruction.fromUnion);
|
|
39427
40897
|
if (isOptional) {
|
|
39428
40898
|
const index = instruction.array;
|
|
39429
40899
|
if (property.startsWith("ar")) {
|
|
@@ -39778,10 +41248,16 @@ var hasElysiaMeta = (meta2, _schema) => {
|
|
|
39778
41248
|
};
|
|
39779
41249
|
var hasProperty = (expectedProperty, _schema) => {
|
|
39780
41250
|
if (!_schema)
|
|
39781
|
-
return;
|
|
41251
|
+
return false;
|
|
39782
41252
|
const schema = _schema.schema ?? _schema;
|
|
39783
41253
|
if (schema[Kind] === "Import" && _schema.References)
|
|
39784
41254
|
return _schema.References().some((schema2) => hasProperty(expectedProperty, schema2));
|
|
41255
|
+
if (schema.anyOf)
|
|
41256
|
+
return schema.anyOf.some((s) => hasProperty(expectedProperty, s));
|
|
41257
|
+
if (schema.allOf)
|
|
41258
|
+
return schema.allOf.some((s) => hasProperty(expectedProperty, s));
|
|
41259
|
+
if (schema.oneOf)
|
|
41260
|
+
return schema.oneOf.some((s) => hasProperty(expectedProperty, s));
|
|
39785
41261
|
if (schema.type === "object") {
|
|
39786
41262
|
const properties = schema.properties;
|
|
39787
41263
|
if (!properties)
|
|
@@ -39933,6 +41409,42 @@ var getSchemaValidator = (s, {
|
|
|
39933
41409
|
};
|
|
39934
41410
|
let schema = mapSchema(s), _validators = validators;
|
|
39935
41411
|
if ("~standard" in schema || validators?.length && validators.some((x) => x && typeof x != "string" && ("~standard" in x))) {
|
|
41412
|
+
let Check22 = function(value, validated = false) {
|
|
41413
|
+
let v = validated ? value : mainCheck.validate(value);
|
|
41414
|
+
if (v instanceof Promise)
|
|
41415
|
+
return v.then((v2) => Check22(v2, true));
|
|
41416
|
+
if (v.issues)
|
|
41417
|
+
return v;
|
|
41418
|
+
const values = [];
|
|
41419
|
+
return v && typeof v == "object" && values.push(v.value), runCheckers2(value, 0, values, v);
|
|
41420
|
+
}, runCheckers2 = function(value, startIndex, values, lastV) {
|
|
41421
|
+
for (let i = startIndex;i < checkers.length; i++) {
|
|
41422
|
+
let v = checkers[i].validate(value);
|
|
41423
|
+
if (v instanceof Promise)
|
|
41424
|
+
return v.then((resolved) => {
|
|
41425
|
+
if (resolved.issues)
|
|
41426
|
+
return resolved;
|
|
41427
|
+
const nextValues = [...values];
|
|
41428
|
+
return resolved && typeof resolved == "object" && nextValues.push(resolved.value), runCheckers2(value, i + 1, nextValues, resolved);
|
|
41429
|
+
});
|
|
41430
|
+
if (v.issues)
|
|
41431
|
+
return v;
|
|
41432
|
+
v && typeof v == "object" && values.push(v.value), lastV = v;
|
|
41433
|
+
}
|
|
41434
|
+
return mergeValues22(values, lastV);
|
|
41435
|
+
}, mergeValues22 = function(values, lastV) {
|
|
41436
|
+
if (!values.length)
|
|
41437
|
+
return { value: lastV };
|
|
41438
|
+
if (values.length === 1)
|
|
41439
|
+
return { value: values[0] };
|
|
41440
|
+
if (values.length === 2)
|
|
41441
|
+
return { value: mergeDeep(values[0], values[1]) };
|
|
41442
|
+
let newValue = mergeDeep(values[0], values[1]);
|
|
41443
|
+
for (let i = 2;i < values.length; i++)
|
|
41444
|
+
newValue = mergeDeep(newValue, values[i]);
|
|
41445
|
+
return { value: newValue };
|
|
41446
|
+
};
|
|
41447
|
+
var Check2 = Check22, runCheckers = runCheckers2, mergeValues2 = mergeValues22;
|
|
39936
41448
|
const typeboxSubValidator = (schema2) => {
|
|
39937
41449
|
let mirror2;
|
|
39938
41450
|
if (normalize === true || normalize === "exactMirror")
|
|
@@ -39955,12 +41467,14 @@ var getSchemaValidator = (s, {
|
|
|
39955
41467
|
coerce,
|
|
39956
41468
|
additionalCoerce
|
|
39957
41469
|
});
|
|
39958
|
-
return vali.Decode = mirror2,
|
|
39959
|
-
|
|
39960
|
-
|
|
39961
|
-
|
|
41470
|
+
return vali.Decode = mirror2, {
|
|
41471
|
+
validate: (v) => vali.Check(v) ? {
|
|
41472
|
+
value: mirror2 ? mirror2(v) : v
|
|
41473
|
+
} : {
|
|
41474
|
+
issues: [...vali.Errors(v)]
|
|
41475
|
+
}
|
|
39962
41476
|
};
|
|
39963
|
-
}, mainCheck = schema["~standard"] ? schema["~standard"]
|
|
41477
|
+
}, mainCheck = schema["~standard"] ? schema["~standard"] : typeboxSubValidator(schema);
|
|
39964
41478
|
let checkers = [];
|
|
39965
41479
|
if (validators?.length) {
|
|
39966
41480
|
for (const validator2 of validators)
|
|
@@ -39975,38 +41489,16 @@ var getSchemaValidator = (s, {
|
|
|
39975
41489
|
}
|
|
39976
41490
|
}
|
|
39977
41491
|
}
|
|
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
41492
|
const validator = {
|
|
40001
41493
|
provider: "standard",
|
|
40002
41494
|
schema,
|
|
40003
41495
|
references: "",
|
|
40004
41496
|
checkFunc: () => {},
|
|
40005
41497
|
code: "",
|
|
40006
|
-
Check:
|
|
40007
|
-
Errors: (value) =>
|
|
41498
|
+
Check: Check22,
|
|
41499
|
+
Errors: (value) => Check22(value)?.then?.((x) => x?.issues),
|
|
40008
41500
|
Code: () => "",
|
|
40009
|
-
Decode:
|
|
41501
|
+
Decode: Check22,
|
|
40010
41502
|
Encode: (value) => value,
|
|
40011
41503
|
hasAdditionalProperties: false,
|
|
40012
41504
|
hasDefault: false,
|
|
@@ -40271,6 +41763,21 @@ var getSchemaValidator = (s, {
|
|
|
40271
41763
|
}), compiled;
|
|
40272
41764
|
};
|
|
40273
41765
|
var isUnion = (schema) => schema[Kind] === "Union" || !schema.schema && !!schema.anyOf;
|
|
41766
|
+
var getSchemaProperties = (schema) => {
|
|
41767
|
+
if (!schema)
|
|
41768
|
+
return;
|
|
41769
|
+
if (schema.properties)
|
|
41770
|
+
return schema.properties;
|
|
41771
|
+
const members = schema.allOf ?? schema.anyOf ?? schema.oneOf;
|
|
41772
|
+
if (members) {
|
|
41773
|
+
const result = {};
|
|
41774
|
+
for (const member of members) {
|
|
41775
|
+
const props = getSchemaProperties(member);
|
|
41776
|
+
props && Object.assign(result, props);
|
|
41777
|
+
}
|
|
41778
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
41779
|
+
}
|
|
41780
|
+
};
|
|
40274
41781
|
var mergeObjectSchemas = (schemas3) => {
|
|
40275
41782
|
if (schemas3.length === 0)
|
|
40276
41783
|
return {
|
|
@@ -40554,7 +42061,7 @@ var isAsync = (v) => {
|
|
|
40554
42061
|
if (isObject3 && v.isAsync !== undefined)
|
|
40555
42062
|
return v.isAsync;
|
|
40556
42063
|
const fn = isObject3 ? v.fn : v;
|
|
40557
|
-
if (fn.constructor.name === "AsyncFunction")
|
|
42064
|
+
if (fn.constructor.name === "AsyncFunction" || fn.constructor.name === "AsyncGeneratorFunction")
|
|
40558
42065
|
return true;
|
|
40559
42066
|
const literal3 = fn.toString();
|
|
40560
42067
|
if (matchResponseClone.test(literal3))
|
|
@@ -40623,8 +42130,14 @@ return function(){return a}`)(handler);
|
|
|
40623
42130
|
if (_encodeCookie)
|
|
40624
42131
|
return _encodeCookie;
|
|
40625
42132
|
if (cookieMeta?.sign) {
|
|
42133
|
+
if (cookieMeta.secrets === "")
|
|
42134
|
+
throw new Error(`cookie secret can't be an empty string at (${method}) ${path2}`, {
|
|
42135
|
+
cause: `(${method}) ${path2}`
|
|
42136
|
+
});
|
|
40626
42137
|
if (!cookieMeta.secrets)
|
|
40627
|
-
throw new Error(`
|
|
42138
|
+
throw new Error(`cookie secret must be defined (${method}) ${path2}`, {
|
|
42139
|
+
cause: `(${method}) ${path2}`
|
|
42140
|
+
});
|
|
40628
42141
|
const secret = cookieMeta.secrets ? typeof cookieMeta.secrets == "string" ? cookieMeta.secrets : cookieMeta.secrets[0] : undefined;
|
|
40629
42142
|
if (_encodeCookie += `const _setCookie = c.set.cookie
|
|
40630
42143
|
if(_setCookie){`, cookieMeta.sign === true)
|
|
@@ -40659,7 +42172,7 @@ if(_setCookie){`, cookieMeta.sign === true)
|
|
|
40659
42172
|
const get = (name, defaultValue) => {
|
|
40660
42173
|
const value = cookieMeta?.[name] ?? defaultValue;
|
|
40661
42174
|
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";
|
|
42175
|
+
}, 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
42176
|
hasHeaders ? fnLiteral += `
|
|
40664
42177
|
c.cookie=await parseCookie(c.set,c.headers.cookie,${options})
|
|
40665
42178
|
` : fnLiteral += `
|
|
@@ -40669,9 +42182,9 @@ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${options})
|
|
|
40669
42182
|
if (hasQuery) {
|
|
40670
42183
|
let arrayProperties = {}, objectProperties = {}, hasArrayProperty = false, hasObjectProperty = false;
|
|
40671
42184
|
if (validator.query?.schema) {
|
|
40672
|
-
const schema = unwrapImportSchema(validator.query?.schema);
|
|
40673
|
-
if (
|
|
40674
|
-
for (const [key, value] of Object.entries(
|
|
42185
|
+
const schema = unwrapImportSchema(validator.query?.schema), properties = getSchemaProperties(schema);
|
|
42186
|
+
if (properties)
|
|
42187
|
+
for (const [key, value] of Object.entries(properties))
|
|
40675
42188
|
hasElysiaMeta("ArrayQuery", value) && (arrayProperties[key] = true, hasArrayProperty = true), hasElysiaMeta("ObjectString", value) && (objectProperties[key] = true, hasObjectProperty = true);
|
|
40676
42189
|
}
|
|
40677
42190
|
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 +42219,8 @@ ${prefix}e.afterResponse[${i}](c)
|
|
|
40706
42219
|
}
|
|
40707
42220
|
return reporter.resolve(), afterResponse2 += `})
|
|
40708
42221
|
`, _afterResponse = afterResponse2;
|
|
40709
|
-
},
|
|
40710
|
-
const after = afterResponse(), response = `${hasSet ? "mapResponse" : "mapCompactResponse"}(${saveResponse}${r}${hasSet ? ",c.set" : ""}${mapResponseContext})
|
|
42222
|
+
}, mapResponse3 = (r = "r") => {
|
|
42223
|
+
const after = afterResponse(), response = `${maybeStream && maybeAsync ? "await " : ""}${hasSet ? "mapResponse" : "mapCompactResponse"}(${saveResponse}${r}${hasSet ? ",c.set" : ""}${mapResponseContext})
|
|
40711
42224
|
`;
|
|
40712
42225
|
return after ? `const _res=${response}` + after + "return _res" : `return ${response}`;
|
|
40713
42226
|
}, mapResponseContext = maybeStream && adapter.mapResponseContext ? `,${adapter.mapResponseContext}` : "";
|
|
@@ -40851,7 +42364,7 @@ case 'multipart/form-data':` + adapter.parser.formData(isOptionalBody) + `break
|
|
|
40851
42364
|
for (const key of Object.keys(app["~parser"]))
|
|
40852
42365
|
fnLiteral += `case '${key}':let bo${key}=parser['${key}'](c,contentType)
|
|
40853
42366
|
if(bo${key} instanceof Promise)bo${key}=await bo${key}
|
|
40854
|
-
if(bo${key} instanceof ElysiaCustomStatusResponse){` +
|
|
42367
|
+
if(bo${key} instanceof ElysiaCustomStatusResponse){` + mapResponse3(`bo${key}`) + `}if(bo${key}!==undefined)c.body=bo${key}
|
|
40855
42368
|
break
|
|
40856
42369
|
`;
|
|
40857
42370
|
hooks.parse?.length && (fnLiteral += "}"), fnLiteral += "}";
|
|
@@ -40872,7 +42385,7 @@ delete c.contentType`);
|
|
|
40872
42385
|
const transform3 = hooks.transform[i], endUnit = reporter.resolveChild(transform3.fn.name);
|
|
40873
42386
|
fnLiteral += isAsync(transform3) ? `transformed=await e.transform[${i}](c)
|
|
40874
42387
|
` : `transformed=e.transform[${i}](c)
|
|
40875
|
-
`, transform3.subType === "mapDerive" ? fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" +
|
|
42388
|
+
`, transform3.subType === "mapDerive" ? fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" + mapResponse3("transformed") + `}else{transformed.request=c.request
|
|
40876
42389
|
transformed.store=c.store
|
|
40877
42390
|
transformed.qi=c.qi
|
|
40878
42391
|
transformed.path=c.path
|
|
@@ -40880,7 +42393,7 @@ transformed.url=c.url
|
|
|
40880
42393
|
transformed.redirect=c.redirect
|
|
40881
42394
|
transformed.set=c.set
|
|
40882
42395
|
transformed.error=c.error
|
|
40883
|
-
c=transformed}` : fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" +
|
|
42396
|
+
c=transformed}` : fnLiteral += "if(transformed instanceof ElysiaCustomStatusResponse){" + mapResponse3("transformed") + `}else Object.assign(c,transformed)
|
|
40884
42397
|
`, endUnit();
|
|
40885
42398
|
}
|
|
40886
42399
|
}
|
|
@@ -40990,12 +42503,7 @@ if(vab.issues){` + validation.validate("body", undefined, "vab.issues") + `}else
|
|
|
40990
42503
|
sanitize: () => app.config.sanitize
|
|
40991
42504
|
});
|
|
40992
42505
|
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
|
-
}
|
|
42506
|
+
const isFirst = fileUnions.length === 0, properties = getSchemaProperties(candidate.schema) ?? getSchemaProperties(type);
|
|
40999
42507
|
if (!properties)
|
|
41000
42508
|
continue;
|
|
41001
42509
|
const iterator2 = Object.entries(properties);
|
|
@@ -41014,9 +42522,12 @@ if(vab.issues){` + validation.validate("body", undefined, "vab.issues") + `}else
|
|
|
41014
42522
|
}
|
|
41015
42523
|
}
|
|
41016
42524
|
} else if (hasNonUnionFileWithDefault || !hasUnion && (hasType("File", unwrapImportSchema(validator.body.schema)) || hasType("Files", unwrapImportSchema(validator.body.schema)))) {
|
|
41017
|
-
let validateFile2 = ""
|
|
41018
|
-
|
|
41019
|
-
|
|
42525
|
+
let validateFile2 = "";
|
|
42526
|
+
const bodyProperties = getSchemaProperties(unwrapImportSchema(validator.body.schema));
|
|
42527
|
+
let i = 0;
|
|
42528
|
+
if (bodyProperties)
|
|
42529
|
+
for (const [k, v] of Object.entries(bodyProperties))
|
|
42530
|
+
!v.extension || v[Kind] !== "File" && v[Kind] !== "Files" || (i && (validateFile2 += ","), validateFile2 += `fileType(c.body.${k},${JSON.stringify(v.extension)},'body.${k}')`, i++);
|
|
41020
42531
|
i && (fnLiteral += `
|
|
41021
42532
|
`), i === 1 ? fnLiteral += `await ${validateFile2}
|
|
41022
42533
|
` : i > 1 && (fnLiteral += `await Promise.all([${validateFile2}])
|
|
@@ -41044,7 +42555,7 @@ if(vac.issues){` + validation.validate("cookie", undefined, "vac.issues") + `}el
|
|
|
41044
42555
|
let resolved
|
|
41045
42556
|
`), fnLiteral += isAsync(beforeHandle) ? `resolved=await e.beforeHandle[${i}](c);
|
|
41046
42557
|
` : `resolved=e.beforeHandle[${i}](c);
|
|
41047
|
-
`, beforeHandle.subType === "mapResolve" ? fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" +
|
|
42558
|
+
`, beforeHandle.subType === "mapResolve" ? fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" + mapResponse3("resolved") + `}else{resolved.request=c.request
|
|
41048
42559
|
resolved.store=c.store
|
|
41049
42560
|
resolved.qi=c.qi
|
|
41050
42561
|
resolved.path=c.path
|
|
@@ -41052,7 +42563,7 @@ resolved.url=c.url
|
|
|
41052
42563
|
resolved.redirect=c.redirect
|
|
41053
42564
|
resolved.set=c.set
|
|
41054
42565
|
resolved.error=c.error
|
|
41055
|
-
c=resolved}` : fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" +
|
|
42566
|
+
c=resolved}` : fnLiteral += "if(resolved instanceof ElysiaCustomStatusResponse){" + mapResponse3("resolved") + `}else Object.assign(c, resolved)
|
|
41056
42567
|
`, endUnit();
|
|
41057
42568
|
else if (!returning)
|
|
41058
42569
|
fnLiteral += isAsync(beforeHandle) ? `await e.beforeHandle[${i}](c)
|
|
@@ -41108,7 +42619,8 @@ if(mr!==undefined)be=c.response=c.responseValue=mr}`, endUnit2();
|
|
|
41108
42619
|
return () => {
|
|
41109
42620
|
hasTrace && (fnLiteral += 'if(r&&(r[Symbol.iterator]||r[Symbol.asyncIterator])&&typeof r.next==="function"){' + (maybeAsync ? "" : "(async()=>{") + `const stream=await tee(r,3)
|
|
41110
42621
|
r=stream[0]
|
|
41111
|
-
|
|
42622
|
+
` + (hooks.afterHandle?.length ? `c.response=c.responseValue=r
|
|
42623
|
+
` : "") + `const listener=stream[1]
|
|
41112
42624
|
` + (hasTrace || hooks.afterResponse?.length ? `afterHandlerStreamListener=stream[2]
|
|
41113
42625
|
` : "") + `${setImmediateFn}(async ()=>{if(listener)for await(const v of listener){}
|
|
41114
42626
|
`, handleReporter.resolve(), fnLiteral += "})" + (maybeAsync ? "" : "})()") + "}else{", handleReporter.resolve(), fnLiteral += `}
|
|
@@ -41146,7 +42658,7 @@ const listener=stream[1]
|
|
|
41146
42658
|
if(mr!==undefined)r=c.response=c.responseValue=mr
|
|
41147
42659
|
`, endUnit();
|
|
41148
42660
|
}
|
|
41149
|
-
mapResponseReporter.resolve(), fnLiteral +=
|
|
42661
|
+
mapResponseReporter.resolve(), fnLiteral += mapResponse3();
|
|
41150
42662
|
} else {
|
|
41151
42663
|
const resolveHandler = reportHandler(isHandleFn ? handler.name : undefined);
|
|
41152
42664
|
if (validator.response || hooks.mapResponse?.length || hasTrace) {
|
|
@@ -41170,7 +42682,7 @@ if(mr!==undefined)r=c.response=c.responseValue=mr}
|
|
|
41170
42682
|
}
|
|
41171
42683
|
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
42684
|
else return ${handle}.clone()` : `return ${handle}.clone()`, fnLiteral += `
|
|
41173
|
-
`) : fnLiteral +=
|
|
42685
|
+
`) : fnLiteral += mapResponse3();
|
|
41174
42686
|
} else if (hasCookie || hasTrace) {
|
|
41175
42687
|
fnLiteral += isAsyncHandler ? `let r=await ${handle}
|
|
41176
42688
|
` : `let r=${handle}
|
|
@@ -41187,14 +42699,14 @@ else return ${handle}.clone()` : `return ${handle}.clone()`, fnLiteral += `
|
|
|
41187
42699
|
if(mr!==undefined)r=c.response=c.responseValue=mr}`, endUnit();
|
|
41188
42700
|
}
|
|
41189
42701
|
}
|
|
41190
|
-
mapResponseReporter.resolve(), fnLiteral += encodeCookie() +
|
|
42702
|
+
mapResponseReporter.resolve(), fnLiteral += encodeCookie() + mapResponse3();
|
|
41191
42703
|
} else {
|
|
41192
42704
|
resolveHandler();
|
|
41193
42705
|
const handled = isAsyncHandler ? `await ${handle}` : handle;
|
|
41194
42706
|
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
42707
|
else return ${handle}.clone()
|
|
41196
42708
|
` : `return ${handle}.clone()
|
|
41197
|
-
`) : fnLiteral +=
|
|
42709
|
+
`) : fnLiteral += mapResponse3(handled);
|
|
41198
42710
|
}
|
|
41199
42711
|
}
|
|
41200
42712
|
if (fnLiteral += `
|
|
@@ -41512,9 +43024,9 @@ error.message=error.response}if(set.status===200||!set.status)set.status=error.s
|
|
|
41512
43024
|
});
|
|
41513
43025
|
if (hooks.mapResponse?.length)
|
|
41514
43026
|
for (let i2 = 0;i2 < hooks.mapResponse.length; i2++) {
|
|
41515
|
-
const
|
|
43027
|
+
const mapResponse3 = hooks.mapResponse[i2], endUnit = mapResponseReporter2.resolveChild(mapResponse3.fn.name);
|
|
41516
43028
|
fnLiteral += `context.response=context.responseValue=_r
|
|
41517
|
-
_r=${isAsyncName(
|
|
43029
|
+
_r=${isAsyncName(mapResponse3) ? "await " : ""}onMapResponse[${i2}](context)
|
|
41518
43030
|
`, endUnit();
|
|
41519
43031
|
}
|
|
41520
43032
|
mapResponseReporter2.resolve(), fnLiteral += afterResponse() + `return mapResponse(${saveResponse}_r,set${adapter.mapResponseContext})}`;
|
|
@@ -41539,8 +43051,8 @@ if(!context.response)context.response=context.responseValue=error.message??error
|
|
|
41539
43051
|
fnLiteral += `let mr
|
|
41540
43052
|
`;
|
|
41541
43053
|
for (let i = 0;i < hooks.mapResponse.length; i++) {
|
|
41542
|
-
const
|
|
41543
|
-
fnLiteral += `if(mr===undefined){mr=${isAsyncName(
|
|
43054
|
+
const mapResponse3 = hooks.mapResponse[i], endUnit = mapResponseReporter.resolveChild(mapResponse3.fn.name);
|
|
43055
|
+
fnLiteral += `if(mr===undefined){mr=${isAsyncName(mapResponse3) ? "await " : ""}onMapResponse[${i}](context)
|
|
41544
43056
|
if(mr!==undefined)error=context.response=context.responseValue=mr}`, endUnit();
|
|
41545
43057
|
}
|
|
41546
43058
|
}
|
|
@@ -41564,587 +43076,6 @@ return mapResponse(${saveResponse}error,set${adapter.mapResponseContext})}`;
|
|
|
41564
43076
|
});
|
|
41565
43077
|
};
|
|
41566
43078
|
|
|
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
43079
|
// node_modules/elysia/dist/adapter/bun/compose.mjs
|
|
42149
43080
|
var allocateIf2 = (value, condition) => condition ? value : "";
|
|
42150
43081
|
var createContext = (app, route, inference, isInline = false) => {
|
|
@@ -42202,7 +43133,7 @@ var createNativeStaticHandler = (handle, hooks, set2) => {
|
|
|
42202
43133
|
return;
|
|
42203
43134
|
if (isHTMLBundle(handle))
|
|
42204
43135
|
return () => handle;
|
|
42205
|
-
const response = mapResponse2(handle, set2 ?? {
|
|
43136
|
+
const response = mapResponse2(handle instanceof Response ? handle.clone() : handle instanceof Promise ? handle.then((x) => x instanceof Response ? x.clone() : x) : handle, set2 ?? {
|
|
42206
43137
|
headers: {}
|
|
42207
43138
|
});
|
|
42208
43139
|
if (!hooks.parse?.length && !hooks.transform?.length && !hooks.beforeHandle?.length && !hooks.afterHandle?.length)
|
|
@@ -42388,6 +43319,11 @@ var mergeRoutes = (r1, r2) => {
|
|
|
42388
43319
|
}
|
|
42389
43320
|
return r1;
|
|
42390
43321
|
};
|
|
43322
|
+
var removeTrailingPath = (routes) => {
|
|
43323
|
+
for (const key of Object.keys(routes))
|
|
43324
|
+
key.charCodeAt(key.length - 1) === 47 && (routes[key.slice(0, -1)] = routes[key], delete routes[key]);
|
|
43325
|
+
return routes;
|
|
43326
|
+
};
|
|
42391
43327
|
var BunAdapter = {
|
|
42392
43328
|
...WebStandardAdapter,
|
|
42393
43329
|
name: "bun",
|
|
@@ -42444,13 +43380,13 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42444
43380
|
staticRoutes[path2] = route;
|
|
42445
43381
|
}
|
|
42446
43382
|
return withAsync ? Promise.all(ops).then(() => staticRoutes) : staticRoutes;
|
|
42447
|
-
}, serve = typeof options == "object" ? {
|
|
43383
|
+
}, routes = removeTrailingPath(mergeRoutes(mergeRoutes(createStaticRoute(app.router.response), mapRoutes(app)), app.config.serve?.routes)), serve = typeof options == "object" ? {
|
|
42448
43384
|
development: !isProduction2,
|
|
42449
43385
|
reusePort: true,
|
|
42450
43386
|
idleTimeout: 30,
|
|
42451
43387
|
...app.config.serve || {},
|
|
42452
43388
|
...options || {},
|
|
42453
|
-
routes
|
|
43389
|
+
routes,
|
|
42454
43390
|
websocket: {
|
|
42455
43391
|
...app.config.websocket || {},
|
|
42456
43392
|
...websocket || {},
|
|
@@ -42462,7 +43398,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42462
43398
|
reusePort: true,
|
|
42463
43399
|
idleTimeout: 30,
|
|
42464
43400
|
...app.config.serve || {},
|
|
42465
|
-
routes
|
|
43401
|
+
routes,
|
|
42466
43402
|
websocket: {
|
|
42467
43403
|
...app.config.websocket || {},
|
|
42468
43404
|
...websocket || {}
|
|
@@ -42478,12 +43414,14 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42478
43414
|
for (let i = 0;i < app.event.stop.length; i++)
|
|
42479
43415
|
app.event.stop[i].fn(app);
|
|
42480
43416
|
}), app.promisedModules.then(async () => {
|
|
42481
|
-
app.config.aot, app.compile()
|
|
43417
|
+
app.config.aot, app.compile();
|
|
43418
|
+
const routes2 = removeTrailingPath(mergeRoutes(mergeRoutes(await createStaticRoute(app.router.response, {
|
|
43419
|
+
withAsync: true
|
|
43420
|
+
}), mapRoutes(app)), app.config.serve?.routes));
|
|
43421
|
+
app.server?.reload({
|
|
42482
43422
|
...serve,
|
|
42483
43423
|
fetch: app.fetch,
|
|
42484
|
-
routes:
|
|
42485
|
-
withAsync: true
|
|
42486
|
-
}), mapRoutes(app)), app.config.serve?.routes)
|
|
43424
|
+
routes: routes2
|
|
42487
43425
|
}), Bun?.gc(false);
|
|
42488
43426
|
});
|
|
42489
43427
|
};
|
|
@@ -42593,10 +43531,81 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
42593
43531
|
};
|
|
42594
43532
|
|
|
42595
43533
|
// node_modules/elysia/dist/dynamic-handle.mjs
|
|
43534
|
+
var ARRAY_INDEX_REGEX = /^(.+)\[(\d+)\]$/;
|
|
43535
|
+
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
43536
|
+
var isDangerousKey = (key) => {
|
|
43537
|
+
if (DANGEROUS_KEYS.has(key))
|
|
43538
|
+
return true;
|
|
43539
|
+
const match = key.match(ARRAY_INDEX_REGEX);
|
|
43540
|
+
return match ? DANGEROUS_KEYS.has(match[1]) : false;
|
|
43541
|
+
};
|
|
43542
|
+
var parseArrayKey = (key) => {
|
|
43543
|
+
const match = key.match(ARRAY_INDEX_REGEX);
|
|
43544
|
+
return match ? {
|
|
43545
|
+
name: match[1],
|
|
43546
|
+
index: parseInt(match[2], 10)
|
|
43547
|
+
} : null;
|
|
43548
|
+
};
|
|
43549
|
+
var parseObjectString = (entry) => {
|
|
43550
|
+
if (!(typeof entry != "string" || entry.charCodeAt(0) !== 123))
|
|
43551
|
+
try {
|
|
43552
|
+
const parsed = JSON.parse(entry);
|
|
43553
|
+
if (parsed && typeof parsed == "object" && !Array.isArray(parsed))
|
|
43554
|
+
return parsed;
|
|
43555
|
+
} catch {
|
|
43556
|
+
return;
|
|
43557
|
+
}
|
|
43558
|
+
};
|
|
43559
|
+
var setNestedValue = (obj, path2, value) => {
|
|
43560
|
+
const keys = path2.split("."), lastKey = keys.pop();
|
|
43561
|
+
if (isDangerousKey(lastKey) || keys.some(isDangerousKey))
|
|
43562
|
+
return;
|
|
43563
|
+
let current = obj;
|
|
43564
|
+
for (const key of keys) {
|
|
43565
|
+
const arrayInfo2 = parseArrayKey(key);
|
|
43566
|
+
if (arrayInfo2) {
|
|
43567
|
+
Array.isArray(current[arrayInfo2.name]) || (current[arrayInfo2.name] = []);
|
|
43568
|
+
const existing = current[arrayInfo2.name][arrayInfo2.index], isFile = typeof File < "u" && existing instanceof File;
|
|
43569
|
+
(!existing || typeof existing != "object" || Array.isArray(existing) || isFile) && (current[arrayInfo2.name][arrayInfo2.index] = parseObjectString(existing) ?? {}), current = current[arrayInfo2.name][arrayInfo2.index];
|
|
43570
|
+
} else
|
|
43571
|
+
(!current[key] || typeof current[key] != "object") && (current[key] = {}), current = current[key];
|
|
43572
|
+
}
|
|
43573
|
+
const arrayInfo = parseArrayKey(lastKey);
|
|
43574
|
+
arrayInfo ? (Array.isArray(current[arrayInfo.name]) || (current[arrayInfo.name] = []), current[arrayInfo.name][arrayInfo.index] = value) : current[lastKey] = value;
|
|
43575
|
+
};
|
|
43576
|
+
var normalizeFormValue = (value) => {
|
|
43577
|
+
if (value.length === 1) {
|
|
43578
|
+
const stringValue2 = value[0];
|
|
43579
|
+
if (typeof stringValue2 == "string" && (stringValue2.charCodeAt(0) === 123 || stringValue2.charCodeAt(0) === 91))
|
|
43580
|
+
try {
|
|
43581
|
+
const parsed2 = JSON.parse(stringValue2);
|
|
43582
|
+
if (parsed2 && typeof parsed2 == "object")
|
|
43583
|
+
return parsed2;
|
|
43584
|
+
} catch {}
|
|
43585
|
+
return value[0];
|
|
43586
|
+
}
|
|
43587
|
+
const stringValue = value.find((entry) => typeof entry == "string");
|
|
43588
|
+
if (!stringValue || typeof File > "u")
|
|
43589
|
+
return value;
|
|
43590
|
+
const files = value.filter((entry) => entry instanceof File);
|
|
43591
|
+
if (!files.length || stringValue.charCodeAt(0) !== 123)
|
|
43592
|
+
return value;
|
|
43593
|
+
let parsed;
|
|
43594
|
+
try {
|
|
43595
|
+
parsed = JSON.parse(stringValue);
|
|
43596
|
+
} catch {
|
|
43597
|
+
return value;
|
|
43598
|
+
}
|
|
43599
|
+
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);
|
|
43600
|
+
};
|
|
42596
43601
|
var injectDefaultValues = (typeChecker, obj) => {
|
|
42597
43602
|
let schema = typeChecker.schema;
|
|
42598
|
-
if (schema
|
|
42599
|
-
|
|
43603
|
+
if (!schema)
|
|
43604
|
+
return;
|
|
43605
|
+
schema.$defs?.[schema.$ref] && (schema = schema.$defs[schema.$ref]);
|
|
43606
|
+
const properties = getSchemaProperties(schema);
|
|
43607
|
+
if (properties)
|
|
43608
|
+
for (const [key, keySchema] of Object.entries(properties))
|
|
42600
43609
|
obj[key] ??= keySchema.default;
|
|
42601
43610
|
};
|
|
42602
43611
|
var createDynamicHandler = (app) => {
|
|
@@ -42653,8 +43662,8 @@ var createDynamicHandler = (app) => {
|
|
|
42653
43662
|
for (const key of form2.keys()) {
|
|
42654
43663
|
if (body[key])
|
|
42655
43664
|
continue;
|
|
42656
|
-
const value = form2.getAll(key);
|
|
42657
|
-
|
|
43665
|
+
const value = form2.getAll(key), finalValue = normalizeFormValue(value);
|
|
43666
|
+
key.includes(".") || key.includes("[") ? setNestedValue(body, key, finalValue) : body[key] = finalValue;
|
|
42658
43667
|
}
|
|
42659
43668
|
break;
|
|
42660
43669
|
}
|
|
@@ -42691,8 +43700,8 @@ var createDynamicHandler = (app) => {
|
|
|
42691
43700
|
for (const key of form2.keys()) {
|
|
42692
43701
|
if (body[key])
|
|
42693
43702
|
continue;
|
|
42694
|
-
const value = form2.getAll(key);
|
|
42695
|
-
|
|
43703
|
+
const value = form2.getAll(key), finalValue = normalizeFormValue(value);
|
|
43704
|
+
key.includes(".") || key.includes("[") ? setNestedValue(body, key, finalValue) : body[key] = finalValue;
|
|
42696
43705
|
}
|
|
42697
43706
|
break;
|
|
42698
43707
|
}
|
|
@@ -42736,8 +43745,8 @@ var createDynamicHandler = (app) => {
|
|
|
42736
43745
|
for (const key of form2.keys()) {
|
|
42737
43746
|
if (body[key])
|
|
42738
43747
|
continue;
|
|
42739
|
-
const value = form2.getAll(key);
|
|
42740
|
-
|
|
43748
|
+
const value = form2.getAll(key), finalValue = normalizeFormValue(value);
|
|
43749
|
+
key.includes(".") || key.includes("[") ? setNestedValue(body, key, finalValue) : body[key] = finalValue;
|
|
42741
43750
|
}
|
|
42742
43751
|
break;
|
|
42743
43752
|
}
|
|
@@ -42791,11 +43800,12 @@ var createDynamicHandler = (app) => {
|
|
|
42791
43800
|
if (validator.params?.Decode && (context.params = validator.params.Decode(context.params)), validator.query?.schema) {
|
|
42792
43801
|
let schema = validator.query.schema;
|
|
42793
43802
|
schema.$defs?.[schema.$ref] && (schema = schema.$defs[schema.$ref]);
|
|
42794
|
-
const properties = schema
|
|
42795
|
-
|
|
42796
|
-
const
|
|
42797
|
-
|
|
42798
|
-
|
|
43803
|
+
const properties = getSchemaProperties(schema);
|
|
43804
|
+
if (properties)
|
|
43805
|
+
for (const property of Object.keys(properties)) {
|
|
43806
|
+
const value = properties[property];
|
|
43807
|
+
(value.type === "array" || value.items?.type === "string") && typeof context.query[property] == "string" && context.query[property] && (context.query[property] = context.query[property].split(","));
|
|
43808
|
+
}
|
|
42799
43809
|
}
|
|
42800
43810
|
if (queryValidator?.Check(context.query) === false)
|
|
42801
43811
|
throw new ValidationError2("query", validator.query, context.query);
|
|
@@ -42809,7 +43819,10 @@ var createDynamicHandler = (app) => {
|
|
|
42809
43819
|
}
|
|
42810
43820
|
if (validator.createBody?.()?.Check(body) === false)
|
|
42811
43821
|
throw new ValidationError2("body", validator.body, body);
|
|
42812
|
-
|
|
43822
|
+
if (validator.body?.Decode) {
|
|
43823
|
+
let decoded = validator.body.Decode(body);
|
|
43824
|
+
decoded instanceof Promise && (decoded = await decoded), context.body = decoded?.value ?? decoded;
|
|
43825
|
+
}
|
|
42813
43826
|
}
|
|
42814
43827
|
if (hooks.beforeHandle)
|
|
42815
43828
|
for (let i = 0;i < hooks.beforeHandle.length; i++) {
|
|
@@ -42845,14 +43858,21 @@ var createDynamicHandler = (app) => {
|
|
|
42845
43858
|
isCustomStatuResponse && (set2.status = status2, response2 = response2.response);
|
|
42846
43859
|
const responseValidator = validator?.createResponse?.()?.[status2];
|
|
42847
43860
|
if (responseValidator?.Check(response2) === false)
|
|
42848
|
-
if (responseValidator?.Clean)
|
|
42849
|
-
|
|
42850
|
-
|
|
42851
|
-
|
|
42852
|
-
|
|
42853
|
-
|
|
43861
|
+
if (responseValidator?.Clean)
|
|
43862
|
+
try {
|
|
43863
|
+
const temp = responseValidator.Clean(response2);
|
|
43864
|
+
if (responseValidator?.Check(temp) === false)
|
|
43865
|
+
throw new ValidationError2("response", responseValidator, response2);
|
|
43866
|
+
response2 = temp;
|
|
43867
|
+
} catch (error2) {
|
|
43868
|
+
throw error2 instanceof ValidationError2 ? error2 : new ValidationError2("response", responseValidator, response2);
|
|
43869
|
+
}
|
|
43870
|
+
else
|
|
42854
43871
|
throw new ValidationError2("response", responseValidator, response2);
|
|
42855
|
-
responseValidator?.Encode && (context.response = response2 = responseValidator.Encode(response2)), responseValidator?.Clean
|
|
43872
|
+
if (responseValidator?.Encode && (context.response = response2 = responseValidator.Encode(response2)), responseValidator?.Clean)
|
|
43873
|
+
try {
|
|
43874
|
+
context.response = response2 = responseValidator.Clean(response2);
|
|
43875
|
+
} catch {}
|
|
42856
43876
|
const result = mapEarlyResponse3(response2, context.set);
|
|
42857
43877
|
if (result !== undefined)
|
|
42858
43878
|
return context.response = result;
|
|
@@ -42862,14 +43882,21 @@ var createDynamicHandler = (app) => {
|
|
|
42862
43882
|
isCustomStatuResponse && (set2.status = status2, response = response.response);
|
|
42863
43883
|
const responseValidator = validator?.createResponse?.()?.[status2];
|
|
42864
43884
|
if (responseValidator?.Check(response) === false)
|
|
42865
|
-
if (responseValidator?.Clean)
|
|
42866
|
-
|
|
42867
|
-
|
|
42868
|
-
|
|
42869
|
-
|
|
42870
|
-
|
|
43885
|
+
if (responseValidator?.Clean)
|
|
43886
|
+
try {
|
|
43887
|
+
const temp = responseValidator.Clean(response);
|
|
43888
|
+
if (responseValidator?.Check(temp) === false)
|
|
43889
|
+
throw new ValidationError2("response", responseValidator, response);
|
|
43890
|
+
response = temp;
|
|
43891
|
+
} catch (error2) {
|
|
43892
|
+
throw error2 instanceof ValidationError2 ? error2 : new ValidationError2("response", responseValidator, response);
|
|
43893
|
+
}
|
|
43894
|
+
else
|
|
42871
43895
|
throw new ValidationError2("response", responseValidator, response);
|
|
42872
|
-
responseValidator?.Encode && (response = responseValidator.Encode(response)), responseValidator?.Clean
|
|
43896
|
+
if (responseValidator?.Encode && (response = responseValidator.Encode(response)), responseValidator?.Clean)
|
|
43897
|
+
try {
|
|
43898
|
+
response = responseValidator.Clean(response);
|
|
43899
|
+
} catch {}
|
|
42873
43900
|
}
|
|
42874
43901
|
if (context.set.cookie && cookieMeta?.sign) {
|
|
42875
43902
|
const secret = cookieMeta.secrets ? typeof cookieMeta.secrets == "string" ? cookieMeta.secrets : cookieMeta.secrets[0] : undefined;
|
|
@@ -42878,10 +43905,10 @@ var createDynamicHandler = (app) => {
|
|
|
42878
43905
|
for (const [key, cookie] of Object.entries(context.set.cookie))
|
|
42879
43906
|
context.set.cookie[key].value = await signCookie(cookie.value, secret);
|
|
42880
43907
|
} else {
|
|
42881
|
-
const properties = validator?.cookie?.schema
|
|
43908
|
+
const properties = getSchemaProperties(validator?.cookie?.schema);
|
|
42882
43909
|
if (secret)
|
|
42883
43910
|
for (const name of cookieMeta.sign)
|
|
42884
|
-
name in properties
|
|
43911
|
+
!properties || !(name in properties) || context.set.cookie[name]?.value && (context.set.cookie[name].value = await signCookie(context.set.cookie[name].value, secret));
|
|
42885
43912
|
}
|
|
42886
43913
|
}
|
|
42887
43914
|
return mapResponse3(context.response = response, context.set);
|
|
@@ -43512,7 +44539,7 @@ var _Elysia = class _Elysia2 {
|
|
|
43512
44539
|
}, this.inference, this.config.sucrose));
|
|
43513
44540
|
for (const handle of handles) {
|
|
43514
44541
|
const fn = asHookType(handle, "global", { skipIfHasType: true });
|
|
43515
|
-
switch (type) {
|
|
44542
|
+
switch ((this.config.name || this.config.seed) && (fn.checksum = checksum(this.config.name + JSON.stringify(this.config.seed))), type) {
|
|
43516
44543
|
case "start":
|
|
43517
44544
|
this.event.start ??= [], this.event.start.push(fn);
|
|
43518
44545
|
break;
|
|
@@ -43898,19 +44925,7 @@ var _Elysia = class _Elysia2 {
|
|
|
43898
44925
|
if (path2 instanceof _Elysia2 || typeof path2 == "function" || path2.length === 0 || path2 === "/") {
|
|
43899
44926
|
const run = typeof path2 == "function" ? path2 : path2 instanceof _Elysia2 ? path2.compile().fetch : handleOrConfig instanceof _Elysia2 ? handleOrConfig.compile().fetch : typeof handleOrConfig == "function" ? handleOrConfig : (() => {
|
|
43900
44927
|
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
|
-
}));
|
|
44928
|
+
})(), handler2 = ({ request, path: path22 }) => run(new Request(replaceUrlPath(request.url, path22), request));
|
|
43914
44929
|
return this.route("ALL", "/*", handler2, {
|
|
43915
44930
|
parse: "none",
|
|
43916
44931
|
...config3,
|
|
@@ -43925,19 +44940,7 @@ var _Elysia = class _Elysia2 {
|
|
|
43925
44940
|
}
|
|
43926
44941
|
const handle = handleOrConfig instanceof _Elysia2 ? handleOrConfig.compile().fetch : typeof handleOrConfig == "function" ? handleOrConfig : (() => {
|
|
43927
44942
|
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
|
-
}));
|
|
44943
|
+
})(), 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
44944
|
return this.route("ALL", path2, handler, {
|
|
43942
44945
|
parse: "none",
|
|
43943
44946
|
...config3,
|
|
@@ -44382,6 +45385,9 @@ async function handleCliCommand(command) {
|
|
|
44382
45385
|
case "install":
|
|
44383
45386
|
await Promise.resolve().then(() => (init_install(), exports_install)).then((m) => m.install());
|
|
44384
45387
|
return true;
|
|
45388
|
+
case "uninstall":
|
|
45389
|
+
await Promise.resolve().then(() => (init_uninstall(), exports_uninstall)).then((m) => m.uninstall());
|
|
45390
|
+
return true;
|
|
44385
45391
|
case "help":
|
|
44386
45392
|
case "--help":
|
|
44387
45393
|
case "-h":
|
|
@@ -44407,6 +45413,7 @@ function showHelp() {
|
|
|
44407
45413
|
(none) Start the MCP server (default)
|
|
44408
45414
|
login Authenticate via browser OAuth + register MCP server
|
|
44409
45415
|
install Register MCP server with detected editors
|
|
45416
|
+
uninstall Remove MCP server from all registered editors
|
|
44410
45417
|
logout Remove stored credentials
|
|
44411
45418
|
whoami Show current authentication status
|
|
44412
45419
|
help Show this help message
|
|
@@ -44430,6 +45437,14 @@ function showVersion() {
|
|
|
44430
45437
|
console.log(`kanbo-mcp v${SERVER_INFO.version}`);
|
|
44431
45438
|
}
|
|
44432
45439
|
async function startMcpServer() {
|
|
45440
|
+
if (CONFIG.TRANSPORT === "http") {
|
|
45441
|
+
printBanner();
|
|
45442
|
+
await startHttpServer();
|
|
45443
|
+
} else {
|
|
45444
|
+
await startStdioServer();
|
|
45445
|
+
}
|
|
45446
|
+
}
|
|
45447
|
+
function printBanner() {
|
|
44433
45448
|
console.error("═══════════════════════════════════════════════════════════════");
|
|
44434
45449
|
console.error(` Kanbo MCP Server v${SERVER_INFO.version}`);
|
|
44435
45450
|
console.error(" AI-native project management via Model Context Protocol");
|
|
@@ -44438,11 +45453,6 @@ async function startMcpServer() {
|
|
|
44438
45453
|
console.error(` API URL: ${CONFIG.KANBO_API_URL}`);
|
|
44439
45454
|
console.error(` API Key: ${CONFIG.KANBO_API_KEY ? "***configured***" : "NOT SET"}`);
|
|
44440
45455
|
console.error("═══════════════════════════════════════════════════════════════");
|
|
44441
|
-
if (CONFIG.TRANSPORT === "http") {
|
|
44442
|
-
await startHttpServer();
|
|
44443
|
-
} else {
|
|
44444
|
-
await startStdioServer();
|
|
44445
|
-
}
|
|
44446
45456
|
}
|
|
44447
45457
|
async function main() {
|
|
44448
45458
|
const command = process.argv[2];
|
|
@@ -44466,4 +45476,7 @@ async function main() {
|
|
|
44466
45476
|
process.exit(1);
|
|
44467
45477
|
}
|
|
44468
45478
|
}
|
|
44469
|
-
main()
|
|
45479
|
+
main().catch((error2) => {
|
|
45480
|
+
console.error("[kanbo-mcp] Unhandled fatal error:", error2);
|
|
45481
|
+
process.exit(1);
|
|
45482
|
+
});
|