asaihost-nodejs 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asaihost-nodejs.cjs +454 -375
- package/dist/asaihost-nodejs.cjs.map +1 -1
- package/dist/asaihost-nodejs.es.js +106 -27
- package/dist/asaihost-nodejs.es.js.map +1 -1
- package/package.json +1 -1
package/dist/asaihost-nodejs.cjs
CHANGED
|
@@ -940,13 +940,86 @@ function deUserInfoWithAsai(userinfo, $asai) {
|
|
|
940
940
|
}
|
|
941
941
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, deUserInfoWithAsai, "deUserInfoWithAsai");
|
|
942
942
|
|
|
943
|
+
// src/ws/ws-probe.ts
|
|
944
|
+
|
|
945
|
+
function isWsStillActive(ws2) {
|
|
946
|
+
if (!ws2) return false;
|
|
947
|
+
const state = ws2.readyState;
|
|
948
|
+
return state === _ws.WebSocket.CONNECTING || state === _ws.WebSocket.OPEN;
|
|
949
|
+
}
|
|
950
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, isWsStillActive, "isWsStillActive");
|
|
951
|
+
function getWsProbeTimeoutMs($asai) {
|
|
952
|
+
return _optionalChain([$asai, 'optionalAccess', _109 => _109.hostconfig, 'optionalAccess', _110 => _110.tm, 'optionalAccess', _111 => _111.d]) || 3e3;
|
|
953
|
+
}
|
|
954
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, getWsProbeTimeoutMs, "getWsProbeTimeoutMs");
|
|
955
|
+
function probeWsAlive($asai, wsclient, timeoutMs) {
|
|
956
|
+
const waitMs = _nullishCoalesce(timeoutMs, () => ( getWsProbeTimeoutMs($asai)));
|
|
957
|
+
return new Promise((resolve6) => {
|
|
958
|
+
if (!wsclient || !isWsStillActive(wsclient)) {
|
|
959
|
+
resolve6(false);
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
let settled = false;
|
|
963
|
+
const finish = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (alive) => {
|
|
964
|
+
if (settled) return;
|
|
965
|
+
settled = true;
|
|
966
|
+
clearTimeout(timer);
|
|
967
|
+
try {
|
|
968
|
+
_optionalChain([wsclient, 'access', _112 => _112.off, 'optionalCall', _113 => _113("message", onMessage)]);
|
|
969
|
+
} catch (e16) {
|
|
970
|
+
}
|
|
971
|
+
resolve6(alive);
|
|
972
|
+
}, "finish");
|
|
973
|
+
const onMessage = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, () => finish(true), "onMessage");
|
|
974
|
+
const timer = setTimeout(() => finish(false), waitMs);
|
|
975
|
+
try {
|
|
976
|
+
_optionalChain([wsclient, 'access', _114 => _114.once, 'optionalCall', _115 => _115("message", onMessage)]);
|
|
977
|
+
wsclient.send(JSON.stringify({ ty: "publish/web", db: "pong" }));
|
|
978
|
+
} catch (e17) {
|
|
979
|
+
finish(false);
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, probeWsAlive, "probeWsAlive");
|
|
984
|
+
function terminateWs(wsclient) {
|
|
985
|
+
if (!wsclient) return;
|
|
986
|
+
try {
|
|
987
|
+
_optionalChain([wsclient, 'access', _116 => _116.terminate, 'optionalCall', _117 => _117()]);
|
|
988
|
+
} catch (e18) {
|
|
989
|
+
}
|
|
990
|
+
try {
|
|
991
|
+
_optionalChain([wsclient, 'access', _118 => _118.close, 'optionalCall', _119 => _119()]);
|
|
992
|
+
} catch (e19) {
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, terminateWs, "terminateWs");
|
|
996
|
+
async function clearStaleWsIfDead($asai, hostdir, us, existingWs) {
|
|
997
|
+
if (!us || us === "asai") return true;
|
|
998
|
+
const map = _optionalChain([$asai, 'access', _120 => _120.connectionsws, 'optionalAccess', _121 => _121[hostdir]]);
|
|
999
|
+
if (!existingWs) {
|
|
1000
|
+
if (_optionalChain([map, 'optionalAccess', _122 => _122[us]])) delete map[us];
|
|
1001
|
+
return true;
|
|
1002
|
+
}
|
|
1003
|
+
if (!isWsStillActive(existingWs)) {
|
|
1004
|
+
terminateWs(existingWs);
|
|
1005
|
+
if (_optionalChain([map, 'optionalAccess', _123 => _123[us]]) === existingWs) delete map[us];
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
const alive = await probeWsAlive($asai, existingWs);
|
|
1009
|
+
if (alive) return false;
|
|
1010
|
+
terminateWs(existingWs);
|
|
1011
|
+
if (_optionalChain([map, 'optionalAccess', _124 => _124[us]]) === existingWs) delete map[us];
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, clearStaleWsIfDead, "clearStaleWsIfDead");
|
|
1015
|
+
|
|
943
1016
|
// src/ws/auth.ts
|
|
944
1017
|
function getWsUserinfo(req, $asai) {
|
|
945
1018
|
try {
|
|
946
|
-
const raw = _optionalChain([req, 'access',
|
|
1019
|
+
const raw = _optionalChain([req, 'access', _125 => _125.headers, 'optionalAccess', _126 => _126["sec-websocket-protocol"]]);
|
|
947
1020
|
if (!raw) return null;
|
|
948
1021
|
return deUserInfoWithAsai(raw.split("##"), $asai);
|
|
949
|
-
} catch (
|
|
1022
|
+
} catch (e20) {
|
|
950
1023
|
return null;
|
|
951
1024
|
}
|
|
952
1025
|
}
|
|
@@ -960,7 +1033,7 @@ function listOnlineWsUsers($asai, hostdir) {
|
|
|
960
1033
|
if (!us || us === "asai") continue;
|
|
961
1034
|
if (isWsStillActive(ws2)) {
|
|
962
1035
|
users.push(us);
|
|
963
|
-
} else if (_optionalChain([map, 'access',
|
|
1036
|
+
} else if (_optionalChain([map, 'access', _127 => _127[dir], 'optionalAccess', _128 => _128[us]]) === ws2) {
|
|
964
1037
|
delete map[dir][us];
|
|
965
1038
|
}
|
|
966
1039
|
}
|
|
@@ -973,10 +1046,10 @@ function isUserOnlineOnWs($asai, us, hostdir) {
|
|
|
973
1046
|
const map = $asai.connectionsws || {};
|
|
974
1047
|
const dirs = hostdir ? [hostdir] : Object.keys(map);
|
|
975
1048
|
for (const dir of dirs) {
|
|
976
|
-
const ws2 = _optionalChain([map, 'access',
|
|
1049
|
+
const ws2 = _optionalChain([map, 'access', _129 => _129[dir], 'optionalAccess', _130 => _130[us]]);
|
|
977
1050
|
if (!ws2) continue;
|
|
978
1051
|
if (isWsStillActive(ws2)) return true;
|
|
979
|
-
if (_optionalChain([map, 'access',
|
|
1052
|
+
if (_optionalChain([map, 'access', _131 => _131[dir], 'optionalAccess', _132 => _132[us]]) === ws2) delete map[dir][us];
|
|
980
1053
|
}
|
|
981
1054
|
return false;
|
|
982
1055
|
}
|
|
@@ -986,13 +1059,13 @@ function kickUserWs($asai, us, hostdir) {
|
|
|
986
1059
|
const map = $asai.connectionsws || {};
|
|
987
1060
|
const dirs = hostdir ? [hostdir] : Object.keys(map);
|
|
988
1061
|
for (const dir of dirs) {
|
|
989
|
-
const ws2 = _optionalChain([map, 'access',
|
|
1062
|
+
const ws2 = _optionalChain([map, 'access', _133 => _133[dir], 'optionalAccess', _134 => _134[us]]);
|
|
990
1063
|
if (!ws2) continue;
|
|
991
1064
|
try {
|
|
992
1065
|
ws2.close();
|
|
993
|
-
} catch (
|
|
1066
|
+
} catch (e21) {
|
|
994
1067
|
}
|
|
995
|
-
if (_optionalChain([map, 'access',
|
|
1068
|
+
if (_optionalChain([map, 'access', _135 => _135[dir], 'optionalAccess', _136 => _136[us]]) === ws2) delete map[dir][us];
|
|
996
1069
|
}
|
|
997
1070
|
}
|
|
998
1071
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, kickUserWs, "kickUserWs");
|
|
@@ -1002,42 +1075,36 @@ async function removeSessionOnWsClose($asai, us, token) {
|
|
|
1002
1075
|
const sessions = await store.getSessions();
|
|
1003
1076
|
const match = sessions.find((s) => s.us === us && s.pub === token);
|
|
1004
1077
|
if (match) await store.removeSession(match.id);
|
|
1005
|
-
} catch (
|
|
1078
|
+
} catch (e22) {
|
|
1006
1079
|
}
|
|
1007
1080
|
}
|
|
1008
1081
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, removeSessionOnWsClose, "removeSessionOnWsClose");
|
|
1009
|
-
function isWsStillActive(ws2) {
|
|
1010
|
-
if (!ws2) return false;
|
|
1011
|
-
const state = ws2.readyState;
|
|
1012
|
-
return state === _ws.WebSocket.CONNECTING || state === _ws.WebSocket.OPEN;
|
|
1013
|
-
}
|
|
1014
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, isWsStillActive, "isWsStillActive");
|
|
1015
1082
|
function rejectIncomingWs(ws2, db) {
|
|
1016
1083
|
const payload = JSON.stringify({ ty: "publish/web", db: { exit: 1, type: "err", ...db } });
|
|
1017
1084
|
try {
|
|
1018
1085
|
ws2.send(payload, () => {
|
|
1019
1086
|
try {
|
|
1020
1087
|
ws2.close();
|
|
1021
|
-
} catch (
|
|
1088
|
+
} catch (e23) {
|
|
1022
1089
|
}
|
|
1023
1090
|
});
|
|
1024
|
-
} catch (
|
|
1091
|
+
} catch (e24) {
|
|
1025
1092
|
try {
|
|
1026
1093
|
ws2.close();
|
|
1027
|
-
} catch (
|
|
1094
|
+
} catch (e25) {
|
|
1028
1095
|
}
|
|
1029
1096
|
}
|
|
1030
1097
|
}
|
|
1031
1098
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, rejectIncomingWs, "rejectIncomingWs");
|
|
1032
|
-
function isOkWs($asai, hostdir, ws2, _req, hostcfg) {
|
|
1099
|
+
async function isOkWs($asai, hostdir, ws2, _req, hostcfg) {
|
|
1033
1100
|
const [us, , tk] = ws2.Userinfo || [];
|
|
1034
1101
|
if (!us) {
|
|
1035
1102
|
ws2.close();
|
|
1036
1103
|
return false;
|
|
1037
1104
|
}
|
|
1038
|
-
if (us !== "asai" && _optionalChain([$asai, 'access',
|
|
1105
|
+
if (us !== "asai" && _optionalChain([$asai, 'access', _137 => _137.connectionsws, 'access', _138 => _138[hostdir], 'optionalAccess', _139 => _139[us]])) {
|
|
1039
1106
|
const existingWs = $asai.connectionsws[hostdir][us];
|
|
1040
|
-
if (_optionalChain([existingWs, 'optionalAccess',
|
|
1107
|
+
if (_optionalChain([existingWs, 'optionalAccess', _140 => _140.Userinfo, 'optionalAccess', _141 => _141[2]]) === tk) {
|
|
1041
1108
|
if (isWsStillActive(existingWs)) {
|
|
1042
1109
|
rejectIncomingWs(ws2, {
|
|
1043
1110
|
lang: "pageworking",
|
|
@@ -1048,22 +1115,26 @@ function isOkWs($asai, hostdir, ws2, _req, hostcfg) {
|
|
|
1048
1115
|
}
|
|
1049
1116
|
try {
|
|
1050
1117
|
existingWs.close();
|
|
1051
|
-
} catch (
|
|
1118
|
+
} catch (e26) {
|
|
1052
1119
|
}
|
|
1053
1120
|
delete $asai.connectionsws[hostdir][us];
|
|
1054
1121
|
return true;
|
|
1055
1122
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1123
|
+
const cleared = await clearStaleWsIfDead($asai, hostdir, us, existingWs);
|
|
1124
|
+
if (!cleared) {
|
|
1125
|
+
rejectIncomingWs(ws2, {
|
|
1126
|
+
lang: "logged",
|
|
1127
|
+
langpm: `${us}`,
|
|
1128
|
+
con: `${us} logged in!`
|
|
1129
|
+
});
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
return true;
|
|
1062
1133
|
}
|
|
1063
1134
|
if (us !== "asai") {
|
|
1064
1135
|
const connections = $asai.connectionsws[hostdir] || {};
|
|
1065
1136
|
const sameTkWs = Object.values(connections).find(
|
|
1066
|
-
(item) => _optionalChain([item, 'access',
|
|
1137
|
+
(item) => _optionalChain([item, 'access', _142 => _142.Userinfo, 'optionalAccess', _143 => _143[2]]) === tk && _optionalChain([item, 'access', _144 => _144.Userinfo, 'optionalAccess', _145 => _145[0]]) !== us
|
|
1067
1138
|
);
|
|
1068
1139
|
const maxOnline = hostcfg.maxonline || 100;
|
|
1069
1140
|
if (sameTkWs) {
|
|
@@ -1097,15 +1168,15 @@ function loginWs($asai, hostdir, ws2, req, hostcfg, wsWorkHandler, logWsMessage)
|
|
|
1097
1168
|
}
|
|
1098
1169
|
ws2.on("message", (msg) => {
|
|
1099
1170
|
if (logWsMessage) $asai.$log("WS", "message", msg.toString());
|
|
1100
|
-
_optionalChain([wsWorkHandler, 'optionalCall',
|
|
1171
|
+
_optionalChain([wsWorkHandler, 'optionalCall', _146 => _146(msg, ws2, hostdir, req)]);
|
|
1101
1172
|
});
|
|
1102
1173
|
ws2.on("close", () => {
|
|
1103
|
-
const token = _optionalChain([ws2, 'access',
|
|
1174
|
+
const token = _optionalChain([ws2, 'access', _147 => _147.Userinfo, 'optionalAccess', _148 => _148[2]]);
|
|
1104
1175
|
if (hostcfg.ckws && ws2.tasksws) {
|
|
1105
1176
|
Object.values(ws2.tasksws).forEach((el) => el && clearInterval(el));
|
|
1106
1177
|
ws2.tasksws = void 0;
|
|
1107
1178
|
}
|
|
1108
|
-
if (us && _optionalChain([$asai, 'access',
|
|
1179
|
+
if (us && _optionalChain([$asai, 'access', _149 => _149.connectionsws, 'access', _150 => _150[hostdir], 'optionalAccess', _151 => _151[us]]) === ws2) delete $asai.connectionsws[hostdir][us];
|
|
1109
1180
|
if (us && token && !isUserOnlineOnWs($asai, us, hostdir)) {
|
|
1110
1181
|
void removeSessionOnWsClose($asai, us, String(token));
|
|
1111
1182
|
}
|
|
@@ -1129,7 +1200,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, clearWsServerTasks, "clearWsServerTasks");
|
|
|
1129
1200
|
function resWsMsg(msg, $asai) {
|
|
1130
1201
|
if (msg === "ping" || msg === "pong") return msg;
|
|
1131
1202
|
if (typeof msg !== "object" || msg === null) return msg;
|
|
1132
|
-
if ((_optionalChain([msg, 'optionalAccess',
|
|
1203
|
+
if ((_optionalChain([msg, 'optionalAccess', _152 => _152.aes]) || _optionalChain([$asai, 'access', _153 => _153.$lib, 'access', _154 => _154.aesfns, 'optionalAccess', _155 => _155.allaes])) && _optionalChain([msg, 'optionalAccess', _156 => _156.db]) && _optionalChain([$asai, 'access', _157 => _157.$lib, 'optionalAccess', _158 => _158.aesfns, 'optionalAccess', _159 => _159.resAES])) {
|
|
1133
1204
|
msg.db = $asai.$lib.aesfns.resAES(msg.db);
|
|
1134
1205
|
}
|
|
1135
1206
|
return JSON.stringify(msg);
|
|
@@ -1151,7 +1222,7 @@ function attachWssHelpers(wss, $asai) {
|
|
|
1151
1222
|
wss.broadws = (msg) => {
|
|
1152
1223
|
const data = resWsMsg(msg, $asai);
|
|
1153
1224
|
wss.clients.forEach((client) => {
|
|
1154
|
-
if (_optionalChain([client, 'optionalAccess',
|
|
1225
|
+
if (_optionalChain([client, 'optionalAccess', _160 => _160.readyState]) === _ws.WebSocket.OPEN) client.send(data);
|
|
1155
1226
|
});
|
|
1156
1227
|
};
|
|
1157
1228
|
}
|
|
@@ -1164,7 +1235,7 @@ var apiPerIp = /* @__PURE__ */ new Map();
|
|
|
1164
1235
|
var apiRatePerIp = /* @__PURE__ */ new Map();
|
|
1165
1236
|
var wsPerIp = /* @__PURE__ */ new Map();
|
|
1166
1237
|
function getQuota($asai) {
|
|
1167
|
-
return _optionalChain([$asai, 'optionalAccess',
|
|
1238
|
+
return _optionalChain([$asai, 'optionalAccess', _161 => _161.hostconfig, 'optionalAccess', _162 => _162.security, 'optionalAccess', _163 => _163.quota]) || {};
|
|
1168
1239
|
}
|
|
1169
1240
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getQuota, "getQuota");
|
|
1170
1241
|
function isEnabled($asai) {
|
|
@@ -1254,7 +1325,7 @@ function getMaxWebConnections($asai, hostcfg) {
|
|
|
1254
1325
|
const q = getQuota($asai);
|
|
1255
1326
|
const fromQuota = Number(q.maxWebConnections);
|
|
1256
1327
|
if (fromQuota > 0) return fromQuota;
|
|
1257
|
-
return Number(_optionalChain([hostcfg, 'optionalAccess',
|
|
1328
|
+
return Number(_optionalChain([hostcfg, 'optionalAccess', _164 => _164.maxws])) > 0 ? Number(hostcfg.maxws) : 100;
|
|
1258
1329
|
}
|
|
1259
1330
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getMaxWebConnections, "getMaxWebConnections");
|
|
1260
1331
|
function countActiveWsConnections(wss, incoming, $asai, hostdir, hostcfg, userinfo) {
|
|
@@ -1264,12 +1335,12 @@ function countActiveWsConnections(wss, incoming, $asai, hostdir, hostcfg, userin
|
|
|
1264
1335
|
if (client === incoming) continue;
|
|
1265
1336
|
if (client.readyState === _ws.WebSocket.CLOSED || client.readyState === _ws.WebSocket.CLOSING) continue;
|
|
1266
1337
|
const cInfo = client.Userinfo;
|
|
1267
|
-
const cUs = _optionalChain([cInfo, 'optionalAccess',
|
|
1268
|
-
const cTk = _optionalChain([cInfo, 'optionalAccess',
|
|
1338
|
+
const cUs = _optionalChain([cInfo, 'optionalAccess', _165 => _165[0]]);
|
|
1339
|
+
const cTk = _optionalChain([cInfo, 'optionalAccess', _166 => _166[2]]);
|
|
1269
1340
|
if (us && tk && cUs === us && cTk === tk) continue;
|
|
1270
|
-
if (_optionalChain([hostcfg, 'optionalAccess',
|
|
1271
|
-
const existing = _optionalChain([$asai, 'optionalAccess',
|
|
1272
|
-
if (existing === client && _optionalChain([existing, 'optionalAccess',
|
|
1341
|
+
if (_optionalChain([hostcfg, 'optionalAccess', _167 => _167.ckws]) && us && tk) {
|
|
1342
|
+
const existing = _optionalChain([$asai, 'optionalAccess', _168 => _168.connectionsws, 'optionalAccess', _169 => _169[hostdir], 'optionalAccess', _170 => _170[us]]);
|
|
1343
|
+
if (existing === client && _optionalChain([existing, 'optionalAccess', _171 => _171.Userinfo, 'optionalAccess', _172 => _172[2]]) === tk) continue;
|
|
1273
1344
|
}
|
|
1274
1345
|
count += 1;
|
|
1275
1346
|
}
|
|
@@ -1281,7 +1352,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, countActiveWsConnections, "countActiveWsCo
|
|
|
1281
1352
|
function createWSHost($asai, hostdir) {
|
|
1282
1353
|
const hostcfg = getHostCFG(hostdir, $asai);
|
|
1283
1354
|
const wsWorkHandler = getWorkHandler("wsWork");
|
|
1284
|
-
const logWsMessage = !!_optionalChain([$asai, 'access',
|
|
1355
|
+
const logWsMessage = !!_optionalChain([$asai, 'access', _173 => _173.hostconfig, 'access', _174 => _174.logger, 'optionalAccess', _175 => _175.lv, 'optionalAccess', _176 => _176.view]);
|
|
1285
1356
|
try {
|
|
1286
1357
|
if ($asai.serversws[hostdir]) return;
|
|
1287
1358
|
if (hostcfg.ckws && !$asai.connectionsws[hostdir]) {
|
|
@@ -1293,14 +1364,14 @@ function createWSHost($asai, hostdir) {
|
|
|
1293
1364
|
wss.on("error", (err) => {
|
|
1294
1365
|
clearWsServerTasks($asai, hostdir);
|
|
1295
1366
|
$asai.$log("WS", "WS Server error!", err);
|
|
1296
|
-
_optionalChain([wss, 'access',
|
|
1367
|
+
_optionalChain([wss, 'access', _177 => _177.close, 'optionalCall', _178 => _178(() => {
|
|
1297
1368
|
$asai.$log("WS", "WS Server closed");
|
|
1298
1369
|
delete $asai.serversws[hostdir];
|
|
1299
1370
|
})]);
|
|
1300
1371
|
});
|
|
1301
1372
|
wss.on("close", (code, reason) => {
|
|
1302
1373
|
try {
|
|
1303
|
-
$asai.$log("WS", `WebSocket closed, server ${hostdir}, code: ${code}, reason: ${_optionalChain([reason, 'optionalAccess',
|
|
1374
|
+
$asai.$log("WS", `WebSocket closed, server ${hostdir}, code: ${code}, reason: ${_optionalChain([reason, 'optionalAccess', _179 => _179.toString, 'call', _180 => _180()])}`);
|
|
1304
1375
|
clearWsServerTasks($asai, hostdir);
|
|
1305
1376
|
} catch (err) {
|
|
1306
1377
|
$asai.$log("WS", "WS close handler error:", err);
|
|
@@ -1331,12 +1402,14 @@ function createWSHost($asai, hostdir) {
|
|
|
1331
1402
|
ws2.send(wsmsg, () => ws2.close(1013, "Server busy"));
|
|
1332
1403
|
return;
|
|
1333
1404
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1405
|
+
void (async () => {
|
|
1406
|
+
const isOpen = !hostcfg.ckws || await isOkWs($asai, hostdir, ws2, req, hostcfg);
|
|
1407
|
+
if (isOpen) {
|
|
1408
|
+
loginWs($asai, hostdir, ws2, req, hostcfg, wsWorkHandler, logWsMessage);
|
|
1409
|
+
} else {
|
|
1410
|
+
ws2.close();
|
|
1411
|
+
}
|
|
1412
|
+
})();
|
|
1340
1413
|
});
|
|
1341
1414
|
$asai.serversws[hostdir] = wss;
|
|
1342
1415
|
} catch (err) {
|
|
@@ -1388,7 +1461,7 @@ var StaticPathCache = class {
|
|
|
1388
1461
|
const stat = fs3.statSync(entry.filePath);
|
|
1389
1462
|
if (!stat.isFile() || stat.mtimeMs !== entry.mtimeMs) return null;
|
|
1390
1463
|
return stat;
|
|
1391
|
-
} catch (
|
|
1464
|
+
} catch (e27) {
|
|
1392
1465
|
return null;
|
|
1393
1466
|
}
|
|
1394
1467
|
}
|
|
@@ -1407,8 +1480,8 @@ function applySecurityHeaders(res, isHttps = false, hostconfig) {
|
|
|
1407
1480
|
if (isHttps) {
|
|
1408
1481
|
res.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
|
|
1409
1482
|
}
|
|
1410
|
-
const sec = _optionalChain([hostconfig, 'optionalAccess',
|
|
1411
|
-
if (_optionalChain([sec, 'optionalAccess',
|
|
1483
|
+
const sec = _optionalChain([hostconfig, 'optionalAccess', _181 => _181.security]);
|
|
1484
|
+
if (_optionalChain([sec, 'optionalAccess', _182 => _182.csp])) {
|
|
1412
1485
|
const csp = typeof sec.cspPolicy === "string" && sec.cspPolicy.length > 0 ? sec.cspPolicy : DEFAULT_CSP;
|
|
1413
1486
|
res.setHeader("Content-Security-Policy", csp);
|
|
1414
1487
|
}
|
|
@@ -1416,9 +1489,9 @@ function applySecurityHeaders(res, isHttps = false, hostconfig) {
|
|
|
1416
1489
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, applySecurityHeaders, "applySecurityHeaders");
|
|
1417
1490
|
function getHttpUserinfo(req, $asai) {
|
|
1418
1491
|
try {
|
|
1419
|
-
const userinfo = _optionalChain([req, 'access',
|
|
1492
|
+
const userinfo = _optionalChain([req, 'access', _183 => _183.headers, 'optionalAccess', _184 => _184["userinfo"], 'optionalAccess', _185 => _185.split, 'call', _186 => _186("##")]);
|
|
1420
1493
|
return deUserInfoWithAsai(userinfo, $asai);
|
|
1421
|
-
} catch (
|
|
1494
|
+
} catch (e28) {
|
|
1422
1495
|
return "";
|
|
1423
1496
|
}
|
|
1424
1497
|
}
|
|
@@ -1449,7 +1522,7 @@ function normalizeRequestPath(url) {
|
|
|
1449
1522
|
}
|
|
1450
1523
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, normalizeRequestPath, "normalizeRequestPath");
|
|
1451
1524
|
function createSkipChecker($asai) {
|
|
1452
|
-
const skip = _optionalChain([$asai, 'access',
|
|
1525
|
+
const skip = _optionalChain([$asai, 'access', _187 => _187.hostconfig, 'optionalAccess', _188 => _188.logger, 'optionalAccess', _189 => _189.skip]);
|
|
1453
1526
|
if (!Array.isArray(skip) || skip.length === 0) return () => false;
|
|
1454
1527
|
const exact = /* @__PURE__ */ new Set();
|
|
1455
1528
|
const prefixes = [];
|
|
@@ -1485,7 +1558,7 @@ function attachAccessLog($asai, req, res, logType) {
|
|
|
1485
1558
|
try {
|
|
1486
1559
|
const entry = _chunkOCEBEEP5cjs.buildAccessEntry.call(void 0, req, res, logType);
|
|
1487
1560
|
void $asai.appendAccessLog(_chunkOCEBEEP5cjs.formatCLF.call(void 0, entry), _chunkOCEBEEP5cjs.formatW3CAccessRecord.call(void 0, entry));
|
|
1488
|
-
} catch (
|
|
1561
|
+
} catch (e29) {
|
|
1489
1562
|
}
|
|
1490
1563
|
}, "onFinish");
|
|
1491
1564
|
if (res.writableEnded || res.finished) onFinish();
|
|
@@ -1544,7 +1617,7 @@ function findExistingFileUnderRoots(requestedPath, allowedRoots) {
|
|
|
1544
1617
|
if (stat.isFile()) {
|
|
1545
1618
|
return { filePath: absTarget, stat };
|
|
1546
1619
|
}
|
|
1547
|
-
} catch (
|
|
1620
|
+
} catch (e30) {
|
|
1548
1621
|
}
|
|
1549
1622
|
}
|
|
1550
1623
|
return null;
|
|
@@ -1557,13 +1630,13 @@ function getHostAllowedRoots(hostconfig) {
|
|
|
1557
1630
|
try {
|
|
1558
1631
|
const abs = path2.resolve("./" + dir.replace(/\\/g, "/"));
|
|
1559
1632
|
if (fs4.existsSync(abs)) roots.add(abs);
|
|
1560
|
-
} catch (
|
|
1633
|
+
} catch (e31) {
|
|
1561
1634
|
}
|
|
1562
1635
|
}, "push");
|
|
1563
|
-
for (const dir of _optionalChain([hostconfig, 'optionalAccess',
|
|
1636
|
+
for (const dir of _optionalChain([hostconfig, 'optionalAccess', _190 => _190.hostdirs]) || []) push(dir);
|
|
1564
1637
|
push("webdata");
|
|
1565
1638
|
push("websys");
|
|
1566
|
-
if (_optionalChain([hostconfig, 'optionalAccess',
|
|
1639
|
+
if (_optionalChain([hostconfig, 'optionalAccess', _191 => _191.weburls, 'optionalAccess', _192 => _192.webdir])) push(hostconfig.weburls.webdir);
|
|
1567
1640
|
const result = [];
|
|
1568
1641
|
roots.forEach((r) => result.push(r));
|
|
1569
1642
|
return result;
|
|
@@ -1594,7 +1667,7 @@ function getStaticBaseDirs($asai) {
|
|
|
1594
1667
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getStaticBaseDirs, "getStaticBaseDirs");
|
|
1595
1668
|
function shouldForceHostdirs($asai) {
|
|
1596
1669
|
if ($asai.pkgSnapshotDir) return true;
|
|
1597
|
-
return _optionalChain([$asai, 'access',
|
|
1670
|
+
return _optionalChain([$asai, 'access', _193 => _193.hostconfig, 'optionalAccess', _194 => _194.pkg, 'optionalAccess', _195 => _195.type]) === 1;
|
|
1598
1671
|
}
|
|
1599
1672
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, shouldForceHostdirs, "shouldForceHostdirs");
|
|
1600
1673
|
function buildStaticSearchDirs(hostcfg, $asai) {
|
|
@@ -1615,12 +1688,12 @@ function buildStaticSearchDirs(hostcfg, $asai) {
|
|
|
1615
1688
|
ordered.push(dir);
|
|
1616
1689
|
return;
|
|
1617
1690
|
}
|
|
1618
|
-
} catch (
|
|
1691
|
+
} catch (e32) {
|
|
1619
1692
|
}
|
|
1620
1693
|
}
|
|
1621
1694
|
}, "pushDir");
|
|
1622
1695
|
for (const dir of hostcfg.hostdirs || []) pushDir(dir);
|
|
1623
|
-
if (_optionalChain([hostcfg, 'access',
|
|
1696
|
+
if (_optionalChain([hostcfg, 'access', _196 => _196.weburls, 'optionalAccess', _197 => _197.webdir])) pushDir(hostcfg.weburls.webdir);
|
|
1624
1697
|
return ordered;
|
|
1625
1698
|
}
|
|
1626
1699
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, buildStaticSearchDirs, "buildStaticSearchDirs");
|
|
@@ -1648,7 +1721,7 @@ function parseUrlPath(requrl) {
|
|
|
1648
1721
|
if (!requrl) return "/";
|
|
1649
1722
|
const safeUrl = requrl.startsWith("http") ? requrl : encodeURI(requrl);
|
|
1650
1723
|
return new URL(safeUrl, "http://localhost").pathname;
|
|
1651
|
-
} catch (
|
|
1724
|
+
} catch (e33) {
|
|
1652
1725
|
return requrl;
|
|
1653
1726
|
}
|
|
1654
1727
|
}
|
|
@@ -1747,8 +1820,8 @@ function serveStaticFile(req, res, foundPath, mimeType, stat, $asai, urlPath = "
|
|
|
1747
1820
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, serveStaticFile, "serveStaticFile");
|
|
1748
1821
|
function createStaticHandler(ctx) {
|
|
1749
1822
|
const { hostcfg, hostdir, indexFile, $asai, staticPathCache } = ctx;
|
|
1750
|
-
const hasRewrite = !!(_optionalChain([hostcfg, 'access',
|
|
1751
|
-
const rewriteKeys = hasRewrite ? _optionalChain([hostcfg, 'access',
|
|
1823
|
+
const hasRewrite = !!(_optionalChain([hostcfg, 'access', _198 => _198.weburls, 'optionalAccess', _199 => _199.rewrite]) && _optionalChain([hostcfg, 'access', _200 => _200.weburls, 'optionalAccess', _201 => _201.webdir]) && _optionalChain([hostcfg, 'access', _202 => _202.weburls, 'optionalAccess', _203 => _203.keys, 'optionalAccess', _204 => _204.length]));
|
|
1824
|
+
const rewriteKeys = hasRewrite ? _optionalChain([hostcfg, 'access', _205 => _205.weburls, 'optionalAccess', _206 => _206.keys]) || [] : [];
|
|
1752
1825
|
const checkWebUrls = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (rurl) => {
|
|
1753
1826
|
if (!hasRewrite || !rurl) return false;
|
|
1754
1827
|
for (let i = 0; i < rewriteKeys.length; i++) {
|
|
@@ -1763,7 +1836,7 @@ function createStaticHandler(ctx) {
|
|
|
1763
1836
|
const roots = rhostdirs.join("|") === primaryDirs.join("|") ? buildStaticRoots(primaryDirs, $asai) : buildStaticRoots(rhostdirs, $asai);
|
|
1764
1837
|
const findValidFile = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (urlPath) => {
|
|
1765
1838
|
const hit = staticPathCache.get(cacheKey);
|
|
1766
|
-
if (_optionalChain([hit, 'optionalAccess',
|
|
1839
|
+
if (_optionalChain([hit, 'optionalAccess', _207 => _207.is404])) return null;
|
|
1767
1840
|
if (hit && !hit.is404) {
|
|
1768
1841
|
const verified = staticPathCache.verify(hit);
|
|
1769
1842
|
if (verified) return { filePath: hit.filePath, stat: verified };
|
|
@@ -1787,7 +1860,7 @@ function createStaticHandler(ctx) {
|
|
|
1787
1860
|
showHostDirs(req, res, [hostcfg.weburls.webdir], "/" + indexFile, primaryDirs, rtm + 1);
|
|
1788
1861
|
return;
|
|
1789
1862
|
}
|
|
1790
|
-
const mimeType = _optionalChain([hostcfg, 'access',
|
|
1863
|
+
const mimeType = _optionalChain([hostcfg, 'access', _208 => _208.mimetypes, 'optionalAccess', _209 => _209[nodePath2.extname(found.filePath)]]) || "application/octet-stream";
|
|
1791
1864
|
serveStaticFile(req, res, found.filePath, mimeType, found.stat, $asai, processedUrl);
|
|
1792
1865
|
}, "showHostDirs");
|
|
1793
1866
|
return (req, res, url) => {
|
|
@@ -1812,7 +1885,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, createStaticHandler, "createStaticHandler"
|
|
|
1812
1885
|
function setupHttpConnectionMonitor($asai, hostdir, server, hostcfg) {
|
|
1813
1886
|
const maxHttp = hostcfg.maxhttp || 100;
|
|
1814
1887
|
const monitorInterval = setInterval(() => {
|
|
1815
|
-
const connCount = _optionalChain([$asai, 'access',
|
|
1888
|
+
const connCount = _optionalChain([$asai, 'access', _210 => _210.connectionshttp, 'access', _211 => _211[hostdir], 'optionalAccess', _212 => _212.size]) || 0;
|
|
1816
1889
|
if (connCount > maxHttp * 0.8) {
|
|
1817
1890
|
$asai.$log("HTTP", `HTTP Connection HIGH (${connCount}/${maxHttp})`);
|
|
1818
1891
|
}
|
|
@@ -1883,10 +1956,10 @@ function findListeningPids(port) {
|
|
|
1883
1956
|
stdio: ["pipe", "pipe", "ignore"]
|
|
1884
1957
|
});
|
|
1885
1958
|
return out.split(/\r?\n/).map((s) => parseInt(s.trim(), 10)).filter((n) => n > 0);
|
|
1886
|
-
} catch (
|
|
1959
|
+
} catch (e34) {
|
|
1887
1960
|
return [];
|
|
1888
1961
|
}
|
|
1889
|
-
} catch (
|
|
1962
|
+
} catch (e35) {
|
|
1890
1963
|
return [];
|
|
1891
1964
|
}
|
|
1892
1965
|
}
|
|
@@ -1897,10 +1970,10 @@ function formatOccupants(port, exclude) {
|
|
|
1897
1970
|
}
|
|
1898
1971
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, formatOccupants, "formatOccupants");
|
|
1899
1972
|
function releasePort(port, opts) {
|
|
1900
|
-
const exclude = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1973
|
+
const exclude = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _213 => _213.excludePid]), () => ( OWN_PID));
|
|
1901
1974
|
const occupants = formatOccupants(port, exclude);
|
|
1902
1975
|
if (!occupants) return true;
|
|
1903
|
-
const label = _optionalChain([opts, 'optionalAccess',
|
|
1976
|
+
const label = _optionalChain([opts, 'optionalAccess', _214 => _214.label]) ? `[${opts.label}] ` : "";
|
|
1904
1977
|
console.warn(
|
|
1905
1978
|
`[AsaiHostNodejs] ${label}\u7AEF\u53E3 ${port} \u88AB\u5360\u7528\uFF08PID: ${occupants}\uFF09\uFF0C\u8BF7\u624B\u52A8\u7ED3\u675F\u5360\u7528\u8FDB\u7A0B\u540E\u91CD\u8BD5`
|
|
1906
1979
|
);
|
|
@@ -1909,23 +1982,23 @@ function releasePort(port, opts) {
|
|
|
1909
1982
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, releasePort, "releasePort");
|
|
1910
1983
|
function collectStartupPorts($asai) {
|
|
1911
1984
|
const ports = /* @__PURE__ */ new Set();
|
|
1912
|
-
const hosts = _optionalChain([$asai, 'access',
|
|
1985
|
+
const hosts = _optionalChain([$asai, 'access', _215 => _215.hostconfig, 'optionalAccess', _216 => _216.hosts]);
|
|
1913
1986
|
if (hosts) {
|
|
1914
1987
|
for (const el of Object.keys(hosts)) {
|
|
1915
1988
|
if (el === "default") continue;
|
|
1916
1989
|
if (el !== "asai" && !validateHostdir(el)) continue;
|
|
1917
1990
|
const cfg = getHostCFG(el, $asai);
|
|
1918
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
1919
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
1991
|
+
if (_optionalChain([cfg, 'optionalAccess', _217 => _217.close])) continue;
|
|
1992
|
+
if (_optionalChain([cfg, 'optionalAccess', _218 => _218.port])) ports.add(Number(cfg.port));
|
|
1920
1993
|
}
|
|
1921
1994
|
}
|
|
1922
|
-
const proxyhosts = _optionalChain([$asai, 'access',
|
|
1995
|
+
const proxyhosts = _optionalChain([$asai, 'access', _219 => _219.hostconfig, 'optionalAccess', _220 => _220.proxyhosts]);
|
|
1923
1996
|
if (proxyhosts) {
|
|
1924
1997
|
for (const el of Object.keys(proxyhosts)) {
|
|
1925
1998
|
if (el === "default") continue;
|
|
1926
1999
|
if (!validateHostdir(el)) continue;
|
|
1927
2000
|
const cfg = getProxyHostCFG(el, $asai);
|
|
1928
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
2001
|
+
if (_optionalChain([cfg, 'optionalAccess', _221 => _221.proxyport])) ports.add(Number(cfg.proxyport));
|
|
1929
2002
|
}
|
|
1930
2003
|
}
|
|
1931
2004
|
return [...ports];
|
|
@@ -1950,7 +2023,7 @@ function scheduleHttpRetry($asai, hostdir) {
|
|
|
1950
2023
|
clearTimeout($asai.hostconfig.guardtm);
|
|
1951
2024
|
$asai.hostconfig.guardtm = null;
|
|
1952
2025
|
}
|
|
1953
|
-
}, _optionalChain([$asai, 'access',
|
|
2026
|
+
}, _optionalChain([$asai, 'access', _222 => _222.hostconfig, 'access', _223 => _223.tm, 'optionalAccess', _224 => _224.d]) || 2e3);
|
|
1954
2027
|
}
|
|
1955
2028
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, scheduleHttpRetry, "scheduleHttpRetry");
|
|
1956
2029
|
function clearFailedHttpHost($asai, hostdir, ws2) {
|
|
@@ -1963,7 +2036,7 @@ function getHTTPServer(httptype = "", cfg, $asai) {
|
|
|
1963
2036
|
if (httptype.startsWith("https")) {
|
|
1964
2037
|
return {
|
|
1965
2038
|
AsCreateServer: /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (callback) => {
|
|
1966
|
-
return https.createServer(_optionalChain([cfg, 'optionalAccess',
|
|
2039
|
+
return https.createServer(_optionalChain([cfg, 'optionalAccess', _225 => _225.httpscert]) || $asai.hostconfig.httpscert, callback);
|
|
1967
2040
|
}, "AsCreateServer"),
|
|
1968
2041
|
Agent: https.Agent,
|
|
1969
2042
|
request: https.request
|
|
@@ -2015,13 +2088,13 @@ function startHTTPServer($asai, hostdir) {
|
|
|
2015
2088
|
return;
|
|
2016
2089
|
}
|
|
2017
2090
|
applySecurityHeaders(res, isHttps, $asai.hostconfig);
|
|
2018
|
-
if (_optionalChain([req, 'access',
|
|
2091
|
+
if (_optionalChain([req, 'access', _226 => _226.url, 'optionalAccess', _227 => _227.startsWith, 'call', _228 => _228("/sys")]) && sysWork) {
|
|
2019
2092
|
logHttp($asai, "SYS", req.method, req.url, skipChecker, req, res);
|
|
2020
2093
|
sysWork(req, res, hostdir);
|
|
2021
|
-
} else if (_optionalChain([req, 'access',
|
|
2094
|
+
} else if (_optionalChain([req, 'access', _229 => _229.url, 'optionalAccess', _230 => _230.startsWith, 'call', _231 => _231("/api")]) && apiWork) {
|
|
2022
2095
|
logHttp($asai, "API", req.method, req.url, skipChecker, req, res);
|
|
2023
2096
|
apiWork(req, res, hostdir);
|
|
2024
|
-
} else if (_optionalChain([req, 'access',
|
|
2097
|
+
} else if (_optionalChain([req, 'access', _232 => _232.url, 'optionalAccess', _233 => _233.startsWith, 'call', _234 => _234("/jsonp")]) && jsonpWork) {
|
|
2025
2098
|
logHttp($asai, "JSONP", req.method, req.url, skipChecker, req, res);
|
|
2026
2099
|
jsonpWork(req, res, hostdir);
|
|
2027
2100
|
} else if (handleStatic) {
|
|
@@ -2092,7 +2165,7 @@ function findSameProcessPortOwner($asai, port, excludeHostdir) {
|
|
|
2092
2165
|
for (const hostdir of Object.keys($asai.servershttp || {})) {
|
|
2093
2166
|
if (hostdir === excludeHostdir) continue;
|
|
2094
2167
|
const cfg = getHostCFG(hostdir, $asai);
|
|
2095
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
2168
|
+
if (_optionalChain([cfg, 'optionalAccess', _235 => _235.port]) === port) return hostdir;
|
|
2096
2169
|
}
|
|
2097
2170
|
return null;
|
|
2098
2171
|
}
|
|
@@ -2100,7 +2173,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, findSameProcessPortOwner, "findSameProcess
|
|
|
2100
2173
|
function asaiGuard($asai, failedHostdir = "asai") {
|
|
2101
2174
|
const conflictPorts = $asai.hostconfig.asaiport || [];
|
|
2102
2175
|
const hostcfg = getHostCFG(failedHostdir, $asai);
|
|
2103
|
-
const port = _optionalChain([hostcfg, 'optionalAccess',
|
|
2176
|
+
const port = _optionalChain([hostcfg, 'optionalAccess', _236 => _236.port]);
|
|
2104
2177
|
if (!port || !conflictPorts.includes(port)) {
|
|
2105
2178
|
scheduleHttpRetry($asai, failedHostdir);
|
|
2106
2179
|
return;
|
|
@@ -2132,7 +2205,7 @@ var PROXY_SKIP_HEADERS = /* @__PURE__ */ new Set([
|
|
|
2132
2205
|
function startProxyServer($asai, proxyhostdir) {
|
|
2133
2206
|
const proxycfg = getProxyHostCFG(proxyhostdir, $asai);
|
|
2134
2207
|
if (!proxycfg.url) return;
|
|
2135
|
-
if (_optionalChain([$asai, 'access',
|
|
2208
|
+
if (_optionalChain([$asai, 'access', _237 => _237.serversproxy, 'optionalAccess', _238 => _238[proxyhostdir]])) return;
|
|
2136
2209
|
try {
|
|
2137
2210
|
const httpServer = getHTTPServer(proxycfg.proxyhttptype, proxycfg, $asai);
|
|
2138
2211
|
const targetHttp = getHTTPServer(proxycfg.url, proxycfg, $asai);
|
|
@@ -2214,12 +2287,12 @@ function startProxyServer($asai, proxyhostdir) {
|
|
|
2214
2287
|
proxyServer.on("error", (err) => {
|
|
2215
2288
|
if (err.code === "EADDRINUSE") {
|
|
2216
2289
|
$asai.$log("PROXY", `\x1B[41mPort ${proxycfg.proxyport} is already start!\x1B[0m`);
|
|
2217
|
-
_optionalChainDelete([$asai, 'access',
|
|
2290
|
+
_optionalChainDelete([$asai, 'access', _239 => _239.serversproxy, 'optionalAccess', _240 => delete _240[proxyhostdir]]);
|
|
2218
2291
|
releasePort(proxycfg.proxyport, {
|
|
2219
2292
|
excludePid: process.pid,
|
|
2220
2293
|
label: proxyhostdir
|
|
2221
2294
|
});
|
|
2222
|
-
setTimeout(() => startProxyServer($asai, proxyhostdir), _optionalChain([$asai, 'access',
|
|
2295
|
+
setTimeout(() => startProxyServer($asai, proxyhostdir), _optionalChain([$asai, 'access', _241 => _241.hostconfig, 'access', _242 => _242.tm, 'optionalAccess', _243 => _243.d]) || 2e3);
|
|
2223
2296
|
} else {
|
|
2224
2297
|
$asai.$log("PROXY", "Proxy server error:", err);
|
|
2225
2298
|
}
|
|
@@ -2259,7 +2332,7 @@ function src_default($asai, opt) {
|
|
|
2259
2332
|
initAsaiHostNodejs($asai, opt);
|
|
2260
2333
|
console.log(`\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B\u203B`);
|
|
2261
2334
|
releaseConfiguredPorts($asai);
|
|
2262
|
-
if (_optionalChain([$asai, 'access',
|
|
2335
|
+
if (_optionalChain([$asai, 'access', _244 => _244.hostconfig, 'optionalAccess', _245 => _245.hosts])) {
|
|
2263
2336
|
$asai.startHTTPServer = (hostdir) => startHTTPServer($asai, hostdir);
|
|
2264
2337
|
Object.keys($asai.hostconfig.hosts).forEach((el) => {
|
|
2265
2338
|
if (validateHostdir(el)) {
|
|
@@ -2270,7 +2343,7 @@ function src_default($asai, opt) {
|
|
|
2270
2343
|
startHTTPServer($asai, "asai");
|
|
2271
2344
|
}
|
|
2272
2345
|
}
|
|
2273
|
-
if (_optionalChain([$asai, 'access',
|
|
2346
|
+
if (_optionalChain([$asai, 'access', _246 => _246.hostconfig, 'optionalAccess', _247 => _247.proxyhosts])) {
|
|
2274
2347
|
Object.keys($asai.hostconfig.proxyhosts).forEach((el) => {
|
|
2275
2348
|
if (validateHostdir(el)) {
|
|
2276
2349
|
startProxyServer($asai, el);
|
|
@@ -2293,22 +2366,22 @@ _chunkSMVZ3ZDJcjs.__export.call(void 0, utils_exports, {
|
|
|
2293
2366
|
// src/utils/ws-mock.ts
|
|
2294
2367
|
function wsMock($asai) {
|
|
2295
2368
|
function getKeyByData(reqdata, hostdir) {
|
|
2296
|
-
return "_wstask_" + (hostdir || "") + "_" + (_optionalChain([reqdata, 'optionalAccess',
|
|
2369
|
+
return "_wstask_" + (hostdir || "") + "_" + (_optionalChain([reqdata, 'optionalAccess', _248 => _248.id]) || _optionalChain([reqdata, 'optionalAccess', _249 => _249.ty]) + "." + _optionalChain([reqdata, 'optionalAccess', _250 => _250.ac]));
|
|
2297
2370
|
}
|
|
2298
2371
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getKeyByData, "getKeyByData");
|
|
2299
2372
|
function getMockDb(workopt) {
|
|
2300
2373
|
const { reqdata, mockdata } = workopt;
|
|
2301
|
-
const wsfn = _optionalChain([mockdata, 'optionalAccess',
|
|
2374
|
+
const wsfn = _optionalChain([mockdata, 'optionalAccess', _251 => _251.fn]) ? _optionalChain([$asai, 'access', _252 => _252.asaimock, 'access', _253 => _253.fn, 'optionalAccess', _254 => _254[mockdata.fn]]) : null;
|
|
2302
2375
|
if (wsfn) return wsfn({ workopt, $asai, mockName: mockdata.fn });
|
|
2303
2376
|
return { ...reqdata, ...mockdata || {} };
|
|
2304
2377
|
}
|
|
2305
2378
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getMockDb, "getMockDb");
|
|
2306
2379
|
function wsWorkApi(workopt) {
|
|
2307
|
-
_optionalChain([$asai, 'access',
|
|
2380
|
+
_optionalChain([$asai, 'access', _255 => _255.serversws, 'access', _256 => _256[workopt.hostdir], 'optionalAccess', _257 => _257.sendws, 'optionalCall', _258 => _258(workopt.reqdataisobj ? getMockDb(workopt) : workopt.reqdata, 0, workopt.ws)]);
|
|
2308
2381
|
}
|
|
2309
2382
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, wsWorkApi, "wsWorkApi");
|
|
2310
2383
|
function wsWorkListen(workopt, reqkey) {
|
|
2311
|
-
if (_optionalChain([workopt, 'access',
|
|
2384
|
+
if (_optionalChain([workopt, 'access', _259 => _259.reqdata, 'optionalAccess', _260 => _260.off])) {
|
|
2312
2385
|
if ($asai.tasksws[workopt.hostdir][reqkey]) {
|
|
2313
2386
|
clearInterval($asai.tasksws[workopt.hostdir][reqkey]);
|
|
2314
2387
|
$asai.tasksws[workopt.hostdir][reqkey] = null;
|
|
@@ -2323,9 +2396,9 @@ function wsMock($asai) {
|
|
|
2323
2396
|
if (!$asai.tasksws[workopt.hostdir][reqkey]) {
|
|
2324
2397
|
clearInterval($asai.tasksws[workopt.hostdir][reqkey]);
|
|
2325
2398
|
}
|
|
2326
|
-
}, _optionalChain([newDataMock, 'optionalAccess',
|
|
2327
|
-
_optionalChain([workopt, 'access',
|
|
2328
|
-
if (_optionalChain([$asai, 'access',
|
|
2399
|
+
}, _optionalChain([newDataMock, 'optionalAccess', _261 => _261.tc]) || 2e3);
|
|
2400
|
+
_optionalChain([workopt, 'access', _262 => _262.ws, 'optionalAccess', _263 => _263.once, 'optionalCall', _264 => _264("close", () => {
|
|
2401
|
+
if (_optionalChain([$asai, 'access', _265 => _265.tasksws, 'access', _266 => _266[workopt.hostdir], 'optionalAccess', _267 => _267[reqkey]])) {
|
|
2329
2402
|
clearInterval($asai.tasksws[workopt.hostdir][reqkey]);
|
|
2330
2403
|
delete $asai.tasksws[workopt.hostdir][reqkey];
|
|
2331
2404
|
}
|
|
@@ -2333,8 +2406,8 @@ function wsMock($asai) {
|
|
|
2333
2406
|
}
|
|
2334
2407
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, wsWorkListen, "wsWorkListen");
|
|
2335
2408
|
function wsWorkMock(workopt) {
|
|
2336
|
-
workopt.mockdata = workopt.reqdataisobj && _optionalChain([$asai, 'access',
|
|
2337
|
-
if (_optionalChain([workopt, 'access',
|
|
2409
|
+
workopt.mockdata = workopt.reqdataisobj && _optionalChain([$asai, 'access', _268 => _268.asaimock, 'optionalAccess', _269 => _269.db, 'optionalAccess', _270 => _270[workopt.hostdir], 'optionalAccess', _271 => _271[_optionalChain([workopt, 'access', _272 => _272.reqdata, 'optionalAccess', _273 => _273.ty])]]) || {};
|
|
2410
|
+
if (_optionalChain([workopt, 'access', _274 => _274.mockdata, 'optionalAccess', _275 => _275.wc])) {
|
|
2338
2411
|
wsWorkListen(workopt, getKeyByData(workopt.reqdata, workopt.hostdir));
|
|
2339
2412
|
} else {
|
|
2340
2413
|
wsWorkApi(workopt);
|
|
@@ -2347,7 +2420,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, wsMock, "wsMock");
|
|
|
2347
2420
|
|
|
2348
2421
|
// src/infra/user-auth.ts
|
|
2349
2422
|
async function attachServerUserLevel(req, $asai) {
|
|
2350
|
-
const userinfo = _optionalChain([req, 'optionalAccess',
|
|
2423
|
+
const userinfo = _optionalChain([req, 'optionalAccess', _276 => _276.Userinfo]);
|
|
2351
2424
|
if (!Array.isArray(userinfo) || !userinfo[0]) return;
|
|
2352
2425
|
const us = String(userinfo[0]);
|
|
2353
2426
|
try {
|
|
@@ -2359,27 +2432,27 @@ async function attachServerUserLevel(req, $asai) {
|
|
|
2359
2432
|
} else {
|
|
2360
2433
|
req._serverUser = null;
|
|
2361
2434
|
}
|
|
2362
|
-
} catch (
|
|
2435
|
+
} catch (e36) {
|
|
2363
2436
|
req._serverUser = null;
|
|
2364
2437
|
}
|
|
2365
2438
|
}
|
|
2366
2439
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, attachServerUserLevel, "attachServerUserLevel");
|
|
2367
2440
|
function getRequestUserLevel(req) {
|
|
2368
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
2369
|
-
const n = Number(_nullishCoalesce(_optionalChain([req, 'optionalAccess',
|
|
2441
|
+
if (_optionalChain([req, 'optionalAccess', _277 => _277._serverUser, 'optionalAccess', _278 => _278.lv]) != null) return Number(req._serverUser.lv);
|
|
2442
|
+
const n = Number(_nullishCoalesce(_optionalChain([req, 'optionalAccess', _279 => _279.Userinfo, 'optionalAccess', _280 => _280[1]]), () => ( -1)));
|
|
2370
2443
|
return Number.isFinite(n) ? n : -1;
|
|
2371
2444
|
}
|
|
2372
2445
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getRequestUserLevel, "getRequestUserLevel");
|
|
2373
2446
|
function getRequestUsername(req) {
|
|
2374
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
2375
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
2447
|
+
if (_optionalChain([req, 'optionalAccess', _281 => _281._serverUser, 'optionalAccess', _282 => _282.us])) return String(req._serverUser.us);
|
|
2448
|
+
const us = _optionalChain([req, 'optionalAccess', _283 => _283.Userinfo, 'optionalAccess', _284 => _284[0]]);
|
|
2376
2449
|
return us ? String(us) : void 0;
|
|
2377
2450
|
}
|
|
2378
2451
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getRequestUsername, "getRequestUsername");
|
|
2379
2452
|
|
|
2380
2453
|
// src/infra/access-control.ts
|
|
2381
2454
|
function getSecurityConfig($asai) {
|
|
2382
|
-
return _optionalChain([$asai, 'optionalAccess',
|
|
2455
|
+
return _optionalChain([$asai, 'optionalAccess', _285 => _285.hostconfig, 'optionalAccess', _286 => _286.security]) || {};
|
|
2383
2456
|
}
|
|
2384
2457
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSecurityConfig, "getSecurityConfig");
|
|
2385
2458
|
function pathMatchesPattern(path8, pattern) {
|
|
@@ -2413,13 +2486,13 @@ function validateHttpAuth(req, $asai, pathname) {
|
|
|
2413
2486
|
if (!isAuthRequired($asai, pathname)) {
|
|
2414
2487
|
return { ok: true };
|
|
2415
2488
|
}
|
|
2416
|
-
const userinfo = _optionalChain([req, 'optionalAccess',
|
|
2489
|
+
const userinfo = _optionalChain([req, 'optionalAccess', _287 => _287.Userinfo]);
|
|
2417
2490
|
const ip = getClientIp(req);
|
|
2418
2491
|
if (!Array.isArray(userinfo) || userinfo.length < 3 || !userinfo[0]) {
|
|
2419
2492
|
logSecurityEvent($asai, {
|
|
2420
2493
|
type: "AUTH_MISSING",
|
|
2421
2494
|
path: pathname,
|
|
2422
|
-
method: _optionalChain([req, 'optionalAccess',
|
|
2495
|
+
method: _optionalChain([req, 'optionalAccess', _288 => _288.method]),
|
|
2423
2496
|
ip,
|
|
2424
2497
|
detail: "Userinfo header missing or invalid"
|
|
2425
2498
|
});
|
|
@@ -2433,7 +2506,7 @@ function validateHttpAuth(req, $asai, pathname) {
|
|
|
2433
2506
|
logSecurityEvent($asai, {
|
|
2434
2507
|
type: "ACCESS_DENIED",
|
|
2435
2508
|
path: pathname,
|
|
2436
|
-
method: _optionalChain([req, 'optionalAccess',
|
|
2509
|
+
method: _optionalChain([req, 'optionalAccess', _289 => _289.method]),
|
|
2437
2510
|
user: String(us),
|
|
2438
2511
|
level: userLevel,
|
|
2439
2512
|
ip,
|
|
@@ -2445,13 +2518,13 @@ function validateHttpAuth(req, $asai, pathname) {
|
|
|
2445
2518
|
}
|
|
2446
2519
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, validateHttpAuth, "validateHttpAuth");
|
|
2447
2520
|
async function validateHttpAuthAsync(req, $asai, pathname) {
|
|
2448
|
-
if (Array.isArray(_optionalChain([req, 'optionalAccess',
|
|
2521
|
+
if (Array.isArray(_optionalChain([req, 'optionalAccess', _290 => _290.Userinfo])) && req.Userinfo[0]) {
|
|
2449
2522
|
await attachServerUserLevel(req, $asai);
|
|
2450
2523
|
if (!req._serverUser && isAuthRequired($asai, pathname)) {
|
|
2451
2524
|
logSecurityEvent($asai, {
|
|
2452
2525
|
type: "ACCESS_DENIED",
|
|
2453
2526
|
path: pathname,
|
|
2454
|
-
method: _optionalChain([req, 'optionalAccess',
|
|
2527
|
+
method: _optionalChain([req, 'optionalAccess', _291 => _291.method]),
|
|
2455
2528
|
user: String(req.Userinfo[0]),
|
|
2456
2529
|
ip: getClientIp(req),
|
|
2457
2530
|
detail: "User not found or inactive"
|
|
@@ -2513,7 +2586,7 @@ function resolveApiCorsOrigin(req, hostcfg, getHeader) {
|
|
|
2513
2586
|
if (referer) {
|
|
2514
2587
|
try {
|
|
2515
2588
|
origin = new URL(referer).origin;
|
|
2516
|
-
} catch (
|
|
2589
|
+
} catch (e37) {
|
|
2517
2590
|
const parts = referer.split("/");
|
|
2518
2591
|
if (parts.length >= 3) origin = `${parts[0]}//${parts[2]}`;
|
|
2519
2592
|
}
|
|
@@ -2525,7 +2598,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, resolveApiCorsOrigin, "resolveApiCorsOrigi
|
|
|
2525
2598
|
function isApiCorsAllowed(origin, hostcfg, hostHeader) {
|
|
2526
2599
|
if (!origin) return false;
|
|
2527
2600
|
if (origin === "*") return true;
|
|
2528
|
-
const corsList = _optionalChain([hostcfg, 'optionalAccess',
|
|
2601
|
+
const corsList = _optionalChain([hostcfg, 'optionalAccess', _292 => _292.cors]);
|
|
2529
2602
|
if (!Array.isArray(corsList) || !corsList.length) return true;
|
|
2530
2603
|
if (corsList.includes(origin)) return true;
|
|
2531
2604
|
if (hostHeader && origin.includes(hostHeader)) return true;
|
|
@@ -2571,19 +2644,19 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, isPlainSourcePost, "isPlainSourcePost");
|
|
|
2571
2644
|
function processPostPayload($asai, req, postdata, pm) {
|
|
2572
2645
|
let isAes = false;
|
|
2573
2646
|
let out = postdata;
|
|
2574
|
-
if ($asai.$lib.aesfns && _optionalChain([out, 'optionalAccess',
|
|
2647
|
+
if ($asai.$lib.aesfns && _optionalChain([out, 'optionalAccess', _293 => _293.startsWith, 'optionalCall', _294 => _294('{"aes":')])) {
|
|
2575
2648
|
isAes = true;
|
|
2576
2649
|
const aesData = JSON.parse(out);
|
|
2577
2650
|
out = $asai.$lib.aesfns.reqAES({ data: aesData });
|
|
2578
|
-
if (_optionalChain([aesData, 'optionalAccess',
|
|
2651
|
+
if (_optionalChain([aesData, 'optionalAccess', _295 => _295.aes]) === 2 && typeof out === "string") {
|
|
2579
2652
|
try {
|
|
2580
2653
|
out = JSON.parse(out);
|
|
2581
|
-
} catch (
|
|
2654
|
+
} catch (e38) {
|
|
2582
2655
|
}
|
|
2583
2656
|
}
|
|
2584
2657
|
}
|
|
2585
2658
|
const plainJson = typeof out === "string" && out.trimStart().startsWith("{");
|
|
2586
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
2659
|
+
if (_optionalChain([req, 'optionalAccess', _296 => _296.Userinfo, 'optionalAccess', _297 => _297[2]]) && !plainJson && !isRawUploadPost(_optionalChain([req, 'optionalAccess', _298 => _298.url])) && !isPlainSourcePost(_optionalChain([req, 'optionalAccess', _299 => _299.url]))) {
|
|
2587
2660
|
pm = req.Userinfo[2];
|
|
2588
2661
|
out = $asai.$lib.AsCode.asdecode(out, pm);
|
|
2589
2662
|
}
|
|
@@ -2591,7 +2664,7 @@ function processPostPayload($asai, req, postdata, pm) {
|
|
|
2591
2664
|
}
|
|
2592
2665
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, processPostPayload, "processPostPayload");
|
|
2593
2666
|
var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2594
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2667
|
+
_optionalChain([opt, 'optionalAccess', _300 => _300.fn, 'optionalCall', _301 => _301($asai)]);
|
|
2595
2668
|
function getHeader(req, key) {
|
|
2596
2669
|
return req.headers[key.toLowerCase()] || "";
|
|
2597
2670
|
}
|
|
@@ -2600,7 +2673,7 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2600
2673
|
let apiRouteCacheLen = -1;
|
|
2601
2674
|
function findApiHandler($asai2, pathname) {
|
|
2602
2675
|
const apis = $asai2.hostserverapis;
|
|
2603
|
-
if (!_optionalChain([apis, 'optionalAccess',
|
|
2676
|
+
if (!_optionalChain([apis, 'optionalAccess', _302 => _302.length])) return void 0;
|
|
2604
2677
|
if (!apiRouteCache || apiRouteCacheLen !== apis.length) {
|
|
2605
2678
|
apiRouteCache = apis.map((elp) => ({ key: elp, path: `/api/${elp}` }));
|
|
2606
2679
|
apiRouteCacheLen = apis.length;
|
|
@@ -2648,9 +2721,9 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2648
2721
|
pm: decodeURIComponent(urlParse.search.substring(4))
|
|
2649
2722
|
};
|
|
2650
2723
|
if (req.url.indexOf("binary") === -1) {
|
|
2651
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
2724
|
+
if (_optionalChain([req, 'optionalAccess', _303 => _303.Userinfo]) && _optionalChain([req, 'optionalAccess', _304 => _304.Userinfo, 'access', _305 => _305[2]]) && _optionalChain([query, 'optionalAccess', _306 => _306.pm])) {
|
|
2652
2725
|
pm = req.Userinfo[2];
|
|
2653
|
-
query = $asai.$lib.AsCode.asdecode(_optionalChain([query, 'optionalAccess',
|
|
2726
|
+
query = $asai.$lib.AsCode.asdecode(_optionalChain([query, 'optionalAccess', _307 => _307.pm]), pm);
|
|
2654
2727
|
query = Object.fromEntries(new URLSearchParams("?" + query).entries());
|
|
2655
2728
|
}
|
|
2656
2729
|
}
|
|
@@ -2669,7 +2742,7 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2669
2742
|
const releaseSlot = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, () => releaseApiSlot(hostdir, clientIp), "releaseSlot");
|
|
2670
2743
|
res.once("finish", releaseSlot);
|
|
2671
2744
|
res.once("close", releaseSlot);
|
|
2672
|
-
const maxBody = _optionalChain([$asai, 'access',
|
|
2745
|
+
const maxBody = _optionalChain([$asai, 'access', _308 => _308.hostconfig, 'optionalAccess', _309 => _309.maxbody]) || 100 * 1024 * 1024;
|
|
2673
2746
|
const isTextPost = req.method === "POST" && req.url.indexOf("binary") === -1;
|
|
2674
2747
|
const bodyPromise = isTextPost ? readRequestBody(req, maxBody) : null;
|
|
2675
2748
|
void (async () => {
|
|
@@ -2683,16 +2756,16 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2683
2756
|
]);
|
|
2684
2757
|
} catch (err) {
|
|
2685
2758
|
releaseSlot();
|
|
2686
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
2759
|
+
if (_optionalChain([err, 'optionalAccess', _310 => _310.message]) === "PAYLOAD_TOO_LARGE") {
|
|
2687
2760
|
return sendError(res, 413, "Payload Too Large");
|
|
2688
2761
|
}
|
|
2689
|
-
return sendError(res, 400, _optionalChain([err, 'optionalAccess',
|
|
2762
|
+
return sendError(res, 400, _optionalChain([err, 'optionalAccess', _311 => _311.message]) || "Bad Request");
|
|
2690
2763
|
}
|
|
2691
2764
|
if (!authResult.ok) {
|
|
2692
2765
|
releaseSlot();
|
|
2693
2766
|
return sendAuthError(res, authResult);
|
|
2694
2767
|
}
|
|
2695
|
-
let apiFn = _optionalChain([$asai, 'access',
|
|
2768
|
+
let apiFn = _optionalChain([$asai, 'access', _312 => _312.hostserverapi, 'access', _313 => _313[apiHandlerKey], 'optionalCall', _314 => _314($asai, query)]);
|
|
2696
2769
|
if (!apiFn) {
|
|
2697
2770
|
return sendError(res, 501, "Not Implemented");
|
|
2698
2771
|
}
|
|
@@ -2708,23 +2781,23 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2708
2781
|
postdata = processed.postdata;
|
|
2709
2782
|
pm = processed.pm;
|
|
2710
2783
|
isAes = processed.isAes;
|
|
2711
|
-
} catch (
|
|
2784
|
+
} catch (e39) {
|
|
2712
2785
|
return sendError(res, 400, "AES decrypt failed");
|
|
2713
2786
|
}
|
|
2714
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2787
|
+
if (_optionalChain([apiFn, 'optionalAccess', _315 => _315.post]) && typeof _optionalChain([apiFn, 'optionalAccess', _316 => _316.post]) === "function") {
|
|
2715
2788
|
const optTmp = { qrdata, data: postdata, pm };
|
|
2716
|
-
if (isAes || _optionalChain([$asai, 'access',
|
|
2717
|
-
optTmp.resAES = _optionalChain([$asai, 'access',
|
|
2789
|
+
if (isAes || _optionalChain([$asai, 'access', _317 => _317.$lib, 'access', _318 => _318.aesfns, 'optionalAccess', _319 => _319.allaes])) {
|
|
2790
|
+
optTmp.resAES = _optionalChain([$asai, 'access', _320 => _320.$lib, 'access', _321 => _321.aesfns, 'optionalAccess', _322 => _322.resAES]);
|
|
2718
2791
|
}
|
|
2719
2792
|
apiFn.post(req, res, hostdir, optTmp);
|
|
2720
2793
|
} else {
|
|
2721
2794
|
res.end(typeof postdata === "string" ? postdata : JSON.stringify(_nullishCoalesce(postdata, () => ( ""))));
|
|
2722
2795
|
}
|
|
2723
2796
|
} else if (req.method === "GET") {
|
|
2724
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2797
|
+
if (_optionalChain([apiFn, 'optionalAccess', _323 => _323.get]) && typeof _optionalChain([apiFn, 'optionalAccess', _324 => _324.get]) === "function") {
|
|
2725
2798
|
const optTmp = { qrdata, data: qrdata, pm };
|
|
2726
|
-
if (isAes || _optionalChain([$asai, 'access',
|
|
2727
|
-
optTmp.resAES = _optionalChain([$asai, 'access',
|
|
2799
|
+
if (isAes || _optionalChain([$asai, 'access', _325 => _325.$lib, 'access', _326 => _326.aesfns, 'optionalAccess', _327 => _327.allaes])) {
|
|
2800
|
+
optTmp.resAES = _optionalChain([$asai, 'access', _328 => _328.$lib, 'access', _329 => _329.aesfns, 'optionalAccess', _330 => _330.resAES]);
|
|
2728
2801
|
}
|
|
2729
2802
|
apiFn.get(req, res, hostdir, optTmp);
|
|
2730
2803
|
} else {
|
|
@@ -2732,12 +2805,12 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2732
2805
|
}
|
|
2733
2806
|
}
|
|
2734
2807
|
} else {
|
|
2735
|
-
if (_optionalChain([Object, 'access',
|
|
2808
|
+
if (_optionalChain([Object, 'access', _331 => _331.keys, 'call', _332 => _332(query), 'optionalAccess', _333 => _333.length])) {
|
|
2736
2809
|
qrdata = query;
|
|
2737
2810
|
}
|
|
2738
2811
|
if (req.method === "POST") {
|
|
2739
2812
|
$asai.$lib.AsNodeTool.upBinary(req).then((postdata2) => {
|
|
2740
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2813
|
+
if (_optionalChain([apiFn, 'optionalAccess', _334 => _334.post]) && typeof _optionalChain([apiFn, 'optionalAccess', _335 => _335.post]) === "function") {
|
|
2741
2814
|
apiFn.post(req, res, hostdir, {
|
|
2742
2815
|
qrdata,
|
|
2743
2816
|
data: postdata2
|
|
@@ -2753,13 +2826,13 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2753
2826
|
} catch (err) {
|
|
2754
2827
|
releaseSlot();
|
|
2755
2828
|
if (!res.headersSent) {
|
|
2756
|
-
return sendError(res, 500, _optionalChain([err, 'optionalAccess',
|
|
2829
|
+
return sendError(res, 500, _optionalChain([err, 'optionalAccess', _336 => _336.message]) || "Internal Server Error");
|
|
2757
2830
|
}
|
|
2758
2831
|
}
|
|
2759
2832
|
})().catch((err) => {
|
|
2760
2833
|
releaseSlot();
|
|
2761
2834
|
if (!res.headersSent) {
|
|
2762
|
-
sendError(res, 500, _optionalChain([err, 'optionalAccess',
|
|
2835
|
+
sendError(res, 500, _optionalChain([err, 'optionalAccess', _337 => _337.message]) || "Internal Server Error");
|
|
2763
2836
|
}
|
|
2764
2837
|
});
|
|
2765
2838
|
} else {
|
|
@@ -2772,12 +2845,12 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2772
2845
|
|
|
2773
2846
|
// src/common/server/Ws.ts
|
|
2774
2847
|
var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2775
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2848
|
+
_optionalChain([opt, 'optionalAccess', _338 => _338.fn, 'optionalCall', _339 => _339($asai)]);
|
|
2776
2849
|
const wsHandlerCache = /* @__PURE__ */ new Map();
|
|
2777
2850
|
const routeIndex = ensureWsRouteIndex($asai);
|
|
2778
2851
|
function getWsHandler(handlerKey) {
|
|
2779
2852
|
if (!wsHandlerCache.has(handlerKey)) {
|
|
2780
|
-
wsHandlerCache.set(handlerKey, _optionalChain([$asai, 'access',
|
|
2853
|
+
wsHandlerCache.set(handlerKey, _optionalChain([$asai, 'access', _340 => _340.hostserverws, 'access', _341 => _341[handlerKey], 'optionalCall', _342 => _342($asai)]));
|
|
2781
2854
|
}
|
|
2782
2855
|
return wsHandlerCache.get(handlerKey);
|
|
2783
2856
|
}
|
|
@@ -2801,21 +2874,21 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2801
2874
|
let reqdata = parseMessage(msg);
|
|
2802
2875
|
let handlerKey;
|
|
2803
2876
|
if (reqdata === "ping") {
|
|
2804
|
-
_optionalChain([ws2, 'access',
|
|
2877
|
+
_optionalChain([ws2, 'access', _343 => _343.send, 'optionalCall', _344 => _344("pong")]);
|
|
2805
2878
|
return;
|
|
2806
2879
|
} else {
|
|
2807
2880
|
const reqdataisobj = typeof reqdata === "object" && reqdata !== null;
|
|
2808
|
-
handlerKey = reqdataisobj ? routeIndex.matchTy(_optionalChain([reqdata, 'optionalAccess',
|
|
2809
|
-
if (!handlerKey && _optionalChain([$asai, 'access',
|
|
2881
|
+
handlerKey = reqdataisobj ? routeIndex.matchTy(_optionalChain([reqdata, 'optionalAccess', _345 => _345.ty])) : routeIndex.matchString(reqdata);
|
|
2882
|
+
if (!handlerKey && _optionalChain([$asai, 'access', _346 => _346.hostserverwss, 'optionalAccess', _347 => _347.length])) {
|
|
2810
2883
|
handlerKey = $asai.hostserverwss.find((elp) => {
|
|
2811
2884
|
if (reqdataisobj) {
|
|
2812
|
-
return _optionalChain([reqdata, 'optionalAccess',
|
|
2885
|
+
return _optionalChain([reqdata, 'optionalAccess', _348 => _348.ty, 'optionalAccess', _349 => _349.startsWith, 'call', _350 => _350(elp)]);
|
|
2813
2886
|
}
|
|
2814
2887
|
return typeof reqdata === "string" && reqdata.startsWith(elp);
|
|
2815
2888
|
});
|
|
2816
2889
|
}
|
|
2817
2890
|
if (!handlerKey) {
|
|
2818
|
-
_optionalChain([$asai, 'access',
|
|
2891
|
+
_optionalChain([$asai, 'access', _351 => _351.asaimock, 'optionalAccess', _352 => _352.wsWorkMock, 'call', _353 => _353({
|
|
2819
2892
|
msg,
|
|
2820
2893
|
ws: ws2,
|
|
2821
2894
|
hostdir,
|
|
@@ -2827,14 +2900,14 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2827
2900
|
}
|
|
2828
2901
|
}
|
|
2829
2902
|
if (!handlerKey) return;
|
|
2830
|
-
_optionalChain([getWsHandler, 'call',
|
|
2903
|
+
_optionalChain([getWsHandler, 'call', _354 => _354(handlerKey), 'optionalAccess', _355 => _355.work, 'optionalCall', _356 => _356(reqdata, ws2, hostdir, req)]);
|
|
2831
2904
|
} catch (err) {
|
|
2832
|
-
_optionalChain([($asai.$log || console.error), 'optionalCall',
|
|
2905
|
+
_optionalChain([($asai.$log || console.error), 'optionalCall', _357 => _357("WS", "handler error", err instanceof Error ? err.message : err)]);
|
|
2833
2906
|
}
|
|
2834
2907
|
}
|
|
2835
2908
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, wsWork, "wsWork");
|
|
2836
2909
|
function _getMessage(msg) {
|
|
2837
|
-
if (_optionalChain([msg, 'optionalAccess',
|
|
2910
|
+
if (_optionalChain([msg, 'optionalAccess', _358 => _358.db, 'optionalAccess', _359 => _359.aes]) && _optionalChain([$asai, 'access', _360 => _360.$lib, 'optionalAccess', _361 => _361.aesfns, 'optionalAccess', _362 => _362.reqAES])) {
|
|
2838
2911
|
msg.db = $asai.$lib.aesfns.reqAES({ data: msg.db });
|
|
2839
2912
|
}
|
|
2840
2913
|
return msg;
|
|
@@ -2861,12 +2934,12 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2861
2934
|
|
|
2862
2935
|
// src/common/server/Sys.ts
|
|
2863
2936
|
var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2864
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2937
|
+
_optionalChain([opt, 'optionalAccess', _363 => _363.fn, 'optionalCall', _364 => _364($asai)]);
|
|
2865
2938
|
let sysRouteCache = null;
|
|
2866
2939
|
let sysRouteCacheLen = -1;
|
|
2867
2940
|
function findSystemHandler(req) {
|
|
2868
2941
|
const routes = $asai.hostserversyss;
|
|
2869
|
-
if (!_optionalChain([routes, 'optionalAccess',
|
|
2942
|
+
if (!_optionalChain([routes, 'optionalAccess', _365 => _365.length])) return void 0;
|
|
2870
2943
|
if (!sysRouteCache || sysRouteCacheLen !== routes.length) {
|
|
2871
2944
|
sysRouteCache = routes.map((elp) => ({ key: elp, route: `/${elp}` }));
|
|
2872
2945
|
sysRouteCacheLen = routes.length;
|
|
@@ -2900,21 +2973,21 @@ var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2900
2973
|
if (!authResult.ok) {
|
|
2901
2974
|
return sendAuthError(res, authResult);
|
|
2902
2975
|
}
|
|
2903
|
-
const handler = _optionalChain([$asai, 'access',
|
|
2976
|
+
const handler = _optionalChain([$asai, 'access', _366 => _366.hostserversys, 'access', _367 => _367[handlerKey], 'optionalCall', _368 => _368($asai)]);
|
|
2904
2977
|
if (!handler) {
|
|
2905
2978
|
return sendError(res, 500, "Handler Initialization Failed");
|
|
2906
2979
|
}
|
|
2907
|
-
if (_optionalChain([handler, 'optionalAccess',
|
|
2980
|
+
if (_optionalChain([handler, 'optionalAccess', _369 => _369.show]) && typeof _optionalChain([handler, 'optionalAccess', _370 => _370.show]) === "function") {
|
|
2908
2981
|
handler.show(req, res, hostdir);
|
|
2909
2982
|
} else {
|
|
2910
2983
|
res.end("postdata");
|
|
2911
2984
|
}
|
|
2912
2985
|
} catch (err) {
|
|
2913
|
-
return sendError(res, 500, _optionalChain([err, 'optionalAccess',
|
|
2986
|
+
return sendError(res, 500, _optionalChain([err, 'optionalAccess', _371 => _371.message]) || "Internal Server Error");
|
|
2914
2987
|
}
|
|
2915
2988
|
})().catch((err) => {
|
|
2916
2989
|
if (!res.headersSent) {
|
|
2917
|
-
sendError(res, 500, _optionalChain([err, 'optionalAccess',
|
|
2990
|
+
sendError(res, 500, _optionalChain([err, 'optionalAccess', _372 => _372.message]) || "Internal Server Error");
|
|
2918
2991
|
}
|
|
2919
2992
|
});
|
|
2920
2993
|
}
|
|
@@ -2924,14 +2997,14 @@ var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2924
2997
|
|
|
2925
2998
|
// src/common/server/WsClient.ts
|
|
2926
2999
|
var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, wsname) => {
|
|
2927
|
-
if (!_optionalChain([$asai, 'optionalAccess',
|
|
3000
|
+
if (!_optionalChain([$asai, 'optionalAccess', _373 => _373.clientws])) {
|
|
2928
3001
|
$asai.clientws = {};
|
|
2929
3002
|
}
|
|
2930
3003
|
if (!$asai.clientws[wsname]) {
|
|
2931
3004
|
$asai.clientws[wsname] = { tasks: /* @__PURE__ */ new Map() };
|
|
2932
3005
|
}
|
|
2933
3006
|
function getKeyByData(msgdata) {
|
|
2934
|
-
return _optionalChain([msgdata, 'optionalAccess',
|
|
3007
|
+
return _optionalChain([msgdata, 'optionalAccess', _374 => _374.id]) || _optionalChain([msgdata, 'optionalAccess', _375 => _375.ty]);
|
|
2935
3008
|
}
|
|
2936
3009
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getKeyByData, "getKeyByData");
|
|
2937
3010
|
function clientwsInit() {
|
|
@@ -2944,7 +3017,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2944
3017
|
};
|
|
2945
3018
|
$asai.clientws[wsname].socket.on("error", (err) => {
|
|
2946
3019
|
$asai.clientws[wsname].open = 0;
|
|
2947
|
-
_optionalChain([$asai, 'access',
|
|
3020
|
+
_optionalChain([$asai, 'access', _376 => _376.hostconfig, 'access', _377 => _377.logger, 'optionalAccess', _378 => _378.lv, 'optionalAccess', _379 => _379.view]) && console.error(
|
|
2948
3021
|
666.2203,
|
|
2949
3022
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is error.`,
|
|
2950
3023
|
err
|
|
@@ -2953,14 +3026,14 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2953
3026
|
});
|
|
2954
3027
|
$asai.clientws[wsname].socket.on("close", () => {
|
|
2955
3028
|
$asai.clientws[wsname].open = 0;
|
|
2956
|
-
_optionalChain([$asai, 'access',
|
|
3029
|
+
_optionalChain([$asai, 'access', _380 => _380.hostconfig, 'access', _381 => _381.logger, 'optionalAccess', _382 => _382.lv, 'optionalAccess', _383 => _383.view]) && console.error(
|
|
2957
3030
|
666.2205,
|
|
2958
3031
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is close.`
|
|
2959
3032
|
);
|
|
2960
3033
|
reject();
|
|
2961
3034
|
});
|
|
2962
3035
|
$asai.clientws[wsname].socket.onopen = () => {
|
|
2963
|
-
_optionalChain([$asai, 'access',
|
|
3036
|
+
_optionalChain([$asai, 'access', _384 => _384.hostconfig, 'access', _385 => _385.logger, 'optionalAccess', _386 => _386.lv, 'optionalAccess', _387 => _387.view]) && console.log(
|
|
2964
3037
|
666.2201,
|
|
2965
3038
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is open.`
|
|
2966
3039
|
);
|
|
@@ -2983,7 +3056,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2983
3056
|
const key = getKeyByData(messageData);
|
|
2984
3057
|
const task = $asai.clientws[wsname].tasks.get(key);
|
|
2985
3058
|
if (task) {
|
|
2986
|
-
_optionalChain([task, 'optionalAccess',
|
|
3059
|
+
_optionalChain([task, 'optionalAccess', _388 => _388.callback, 'call', _389 => _389(messageData)]);
|
|
2987
3060
|
if (messageData.ty && !messageData.id) {
|
|
2988
3061
|
} else {
|
|
2989
3062
|
$asai.clientws[wsname].tasks.delete(key);
|
|
@@ -3037,7 +3110,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
3037
3110
|
}
|
|
3038
3111
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, clientwsWatch, "clientwsWatch");
|
|
3039
3112
|
function clientwsWatchOff(messageData) {
|
|
3040
|
-
if (_optionalChain([messageData, 'optionalAccess',
|
|
3113
|
+
if (_optionalChain([messageData, 'optionalAccess', _390 => _390.ty]) === "clear") {
|
|
3041
3114
|
$asai.clientws[wsname].tasks = /* @__PURE__ */ new Map();
|
|
3042
3115
|
} else {
|
|
3043
3116
|
const key = getKeyByData(messageData);
|
|
@@ -3078,7 +3151,7 @@ var ping_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai)
|
|
|
3078
3151
|
var web_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3079
3152
|
function chatBoard(msgdata, ws2, hostdir, req) {
|
|
3080
3153
|
let room;
|
|
3081
|
-
if (_optionalChain([msgdata, 'access',
|
|
3154
|
+
if (_optionalChain([msgdata, 'access', _391 => _391.db, 'optionalAccess', _392 => _392.room]) && typeof msgdata.db.room === "string") {
|
|
3082
3155
|
room = msgdata.db.room;
|
|
3083
3156
|
delete msgdata.db.room;
|
|
3084
3157
|
} else {
|
|
@@ -3135,26 +3208,26 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3135
3208
|
removeFile: removeFile2,
|
|
3136
3209
|
resolvePathUnderBase: resolvePathUnderBase2
|
|
3137
3210
|
} = $asai.$lib.AsFs;
|
|
3138
|
-
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'access',
|
|
3211
|
+
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'access', _393 => _393.$lib, 'optionalAccess', _394 => _394.reqWork, 'optionalCall', _395 => _395($asai)]);
|
|
3139
3212
|
function mgLog(...arg) {
|
|
3140
3213
|
mnLog("LOG", ...arg);
|
|
3141
3214
|
}
|
|
3142
3215
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mgLog, "mgLog");
|
|
3143
3216
|
function getDir(opt) {
|
|
3144
|
-
let tmpDir = _optionalChain([opt, 'access',
|
|
3217
|
+
let tmpDir = _optionalChain([opt, 'access', _396 => _396.qrdata, 'optionalAccess', _397 => _397.dir]) || _optionalChain([opt, 'access', _398 => _398.data, 'optionalAccess', _399 => _399.dir]);
|
|
3145
3218
|
if (tmpDir) {
|
|
3146
3219
|
tmpDir = decodeURIComponent(tmpDir);
|
|
3147
3220
|
} else {
|
|
3148
|
-
tmpDir = _optionalChain([opt, 'access',
|
|
3221
|
+
tmpDir = _optionalChain([opt, 'access', _400 => _400.qrdata, 'optionalAccess', _401 => _401.ty]) || _optionalChain([opt, 'access', _402 => _402.data, 'optionalAccess', _403 => _403.ty]);
|
|
3149
3222
|
if (tmpDir) {
|
|
3150
3223
|
tmpDir = decodeURIComponent(tmpDir);
|
|
3151
3224
|
if (tmpDir === "access-clf" || tmpDir === "access-w3c") {
|
|
3152
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3225
|
+
tmpDir = _optionalChain([$asai, 'access', _404 => _404.hostconfig, 'access', _405 => _405.logger, 'optionalAccess', _406 => _406.path, 'optionalAccess', _407 => _407.access]) || "";
|
|
3153
3226
|
} else {
|
|
3154
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3227
|
+
tmpDir = _optionalChain([$asai, 'access', _408 => _408.hostconfig, 'access', _409 => _409.logger, 'optionalAccess', _410 => _410.path, 'optionalAccess', _411 => _411[tmpDir]]) || "";
|
|
3155
3228
|
}
|
|
3156
3229
|
} else {
|
|
3157
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3230
|
+
tmpDir = _optionalChain([$asai, 'access', _412 => _412.hostconfig, 'access', _413 => _413.logger, 'optionalAccess', _414 => _414.path, 'optionalAccess', _415 => _415.client]) || "";
|
|
3158
3231
|
}
|
|
3159
3232
|
}
|
|
3160
3233
|
return tmpDir;
|
|
@@ -3186,7 +3259,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3186
3259
|
if (!await ensureLv(req, $asai, 3)) return sendFail(res, "Forbidden", opt);
|
|
3187
3260
|
try {
|
|
3188
3261
|
const baseDir = getDir(opt);
|
|
3189
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3262
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _416 => _416.qrdata, 'optionalAccess', _417 => _417.path]) || _optionalChain([opt, 'access', _418 => _418.data, 'optionalAccess', _419 => _419.path]));
|
|
3190
3263
|
const jsonpath = resolvePathUnderBase2(baseDir, relPath);
|
|
3191
3264
|
await ensureFile2(jsonpath);
|
|
3192
3265
|
mgLog("ENSURE", jsonpath);
|
|
@@ -3207,7 +3280,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3207
3280
|
if (url.startsWith("/api/asailog/manage/selectlist/")) {
|
|
3208
3281
|
if (!await ensureLv(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3209
3282
|
try {
|
|
3210
|
-
const ty = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3283
|
+
const ty = decodeURIComponent(_optionalChain([opt, 'access', _420 => _420.qrdata, 'optionalAccess', _421 => _421.ty]) || _optionalChain([opt, 'access', _422 => _422.data, 'optionalAccess', _423 => _423.ty]) || "client");
|
|
3211
3284
|
if (!_chunkHR5JKN7Ycjs.prefersDiskLogAccess.call(void 0, $asai) && _chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai) && (ty === "client" || ty === "server" || ty === "sec")) {
|
|
3212
3285
|
const kind = ty === "sec" ? "sec" : "web";
|
|
3213
3286
|
const groups = await _chunkHR5JKN7Ycjs.listUnifiedGroups.call(void 0, $asai, { kind, source: ty === "sec" ? "sec" : ty });
|
|
@@ -3235,8 +3308,8 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3235
3308
|
if (url.startsWith("/api/asailog/manage/select/")) {
|
|
3236
3309
|
if (!await ensureLv(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3237
3310
|
try {
|
|
3238
|
-
const ty = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3239
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3311
|
+
const ty = decodeURIComponent(_optionalChain([opt, 'access', _424 => _424.qrdata, 'optionalAccess', _425 => _425.ty]) || _optionalChain([opt, 'access', _426 => _426.data, 'optionalAccess', _427 => _427.ty]) || "client");
|
|
3312
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _428 => _428.qrdata, 'optionalAccess', _429 => _429.path]) || _optionalChain([opt, 'access', _430 => _430.data, 'optionalAccess', _431 => _431.path]));
|
|
3240
3313
|
if (!_chunkHR5JKN7Ycjs.prefersDiskLogAccess.call(void 0, $asai) && _chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai) && (ty === "client" || ty === "server" || ty === "sec")) {
|
|
3241
3314
|
const data2 = await _chunkHR5JKN7Ycjs.readWebLogFromStore.call(void 0, $asai, ty, relPath);
|
|
3242
3315
|
if (data2) {
|
|
@@ -3264,7 +3337,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3264
3337
|
if (!await ensureLv(req, $asai, 3)) return sendFail(res, "Forbidden", opt);
|
|
3265
3338
|
try {
|
|
3266
3339
|
const baseDir = getDir(opt);
|
|
3267
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3340
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _432 => _432.qrdata, 'optionalAccess', _433 => _433.path]) || _optionalChain([opt, 'access', _434 => _434.data, 'optionalAccess', _435 => _435.path]));
|
|
3268
3341
|
const fileName = relPath.split(/[/\\]/).pop() || relPath;
|
|
3269
3342
|
if (_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai)) {
|
|
3270
3343
|
await _chunkHR5JKN7Ycjs.purgeStoreEntriesForFile.call(void 0, $asai, fileName).catch(() => void 0);
|
|
@@ -3287,14 +3360,14 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3287
3360
|
|
|
3288
3361
|
// src/infra/siem-auth.ts
|
|
3289
3362
|
function isSiemEnabled($asai) {
|
|
3290
|
-
const cfg = _optionalChain([$asai, 'optionalAccess',
|
|
3291
|
-
return !!(_optionalChain([cfg, 'optionalAccess',
|
|
3363
|
+
const cfg = _optionalChain([$asai, 'optionalAccess', _436 => _436.hostconfig, 'optionalAccess', _437 => _437.logger, 'optionalAccess', _438 => _438.siem]);
|
|
3364
|
+
return !!(_optionalChain([cfg, 'optionalAccess', _439 => _439.enabled]) && getSiemToken($asai));
|
|
3292
3365
|
}
|
|
3293
3366
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isSiemEnabled, "isSiemEnabled");
|
|
3294
3367
|
function getSiemToken($asai) {
|
|
3295
3368
|
const fromEnv = process.env.ASAI_SIEM_TOKEN;
|
|
3296
3369
|
if (typeof fromEnv === "string" && fromEnv.trim()) return fromEnv.trim();
|
|
3297
|
-
const fromCfg = _optionalChain([$asai, 'optionalAccess',
|
|
3370
|
+
const fromCfg = _optionalChain([$asai, 'optionalAccess', _440 => _440.hostconfig, 'optionalAccess', _441 => _441.logger, 'optionalAccess', _442 => _442.siem, 'optionalAccess', _443 => _443.token]);
|
|
3298
3371
|
return typeof fromCfg === "string" ? fromCfg.trim() : "";
|
|
3299
3372
|
}
|
|
3300
3373
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSiemToken, "getSiemToken");
|
|
@@ -3302,9 +3375,9 @@ function isSiemTokenValid($asai, req) {
|
|
|
3302
3375
|
if (!isSiemEnabled($asai)) return false;
|
|
3303
3376
|
const expected = getSiemToken($asai);
|
|
3304
3377
|
if (!expected) return false;
|
|
3305
|
-
const header = _optionalChain([req, 'optionalAccess',
|
|
3378
|
+
const header = _optionalChain([req, 'optionalAccess', _444 => _444.headers, 'optionalAccess', _445 => _445["x-siem-token"]]) || _optionalChain([req, 'optionalAccess', _446 => _446.headers, 'optionalAccess', _447 => _447["x-api-key"]]);
|
|
3306
3379
|
if (typeof header === "string" && header === expected) return true;
|
|
3307
|
-
const q = _optionalChain([req, 'optionalAccess',
|
|
3380
|
+
const q = _optionalChain([req, 'optionalAccess', _448 => _448.query]) || {};
|
|
3308
3381
|
const qToken = q.siem_token || q.token;
|
|
3309
3382
|
return typeof qToken === "string" && qToken === expected;
|
|
3310
3383
|
}
|
|
@@ -3328,20 +3401,20 @@ function getNs(raw) {
|
|
|
3328
3401
|
}
|
|
3329
3402
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getNs, "getNs");
|
|
3330
3403
|
async function ensureServerUser(req, $asai) {
|
|
3331
|
-
if (Array.isArray(_optionalChain([req, 'optionalAccess',
|
|
3404
|
+
if (Array.isArray(_optionalChain([req, 'optionalAccess', _449 => _449.Userinfo])) && req.Userinfo[0]) {
|
|
3332
3405
|
await attachServerUserLevel(req, $asai);
|
|
3333
3406
|
}
|
|
3334
3407
|
}
|
|
3335
3408
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, ensureServerUser, "ensureServerUser");
|
|
3336
3409
|
var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3337
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3410
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _450 => _450.$lib, 'optionalAccess', _451 => _451.reqWork, 'optionalCall', _452 => _452($asai)]) || {};
|
|
3338
3411
|
const IL = $asai.$lib.InterventionLog;
|
|
3339
3412
|
async function get(req, res, hostdir, opt) {
|
|
3340
3413
|
const url = req.url || "";
|
|
3341
3414
|
if (url.startsWith("/api/asailog/intervention/selectlist/")) {
|
|
3342
3415
|
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3343
3416
|
try {
|
|
3344
|
-
const ns = getNs(_optionalChain([opt, 'access',
|
|
3417
|
+
const ns = getNs(_optionalChain([opt, 'access', _453 => _453.qrdata, 'optionalAccess', _454 => _454.ns]) || _optionalChain([opt, 'access', _455 => _455.data, 'optionalAccess', _456 => _456.ns]));
|
|
3345
3418
|
let list = await IL.listInterventionFiles($asai, ns);
|
|
3346
3419
|
if (_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai) && !_chunkHR5JKN7Ycjs.prefersDiskLogAccess.call(void 0, $asai)) {
|
|
3347
3420
|
const groups = await _chunkHR5JKN7Ycjs.listUnifiedGroups.call(void 0, $asai, { kind: "intervention", ns });
|
|
@@ -3353,19 +3426,19 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3353
3426
|
}
|
|
3354
3427
|
return sendSuccess(res, { ns, files: list }, opt);
|
|
3355
3428
|
} catch (err) {
|
|
3356
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3429
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _457 => _457.message]) || err, opt);
|
|
3357
3430
|
}
|
|
3358
3431
|
}
|
|
3359
3432
|
if (url.startsWith("/api/asailog/intervention/select/")) {
|
|
3360
3433
|
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3361
3434
|
try {
|
|
3362
|
-
const name = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3363
|
-
const ns = getNs(_optionalChain([opt, 'access',
|
|
3435
|
+
const name = decodeURIComponent(_optionalChain([opt, 'access', _458 => _458.qrdata, 'optionalAccess', _459 => _459.name]) || _optionalChain([opt, 'access', _460 => _460.data, 'optionalAccess', _461 => _461.name]) || "");
|
|
3436
|
+
const ns = getNs(_optionalChain([opt, 'access', _462 => _462.qrdata, 'optionalAccess', _463 => _463.ns]) || _optionalChain([opt, 'access', _464 => _464.data, 'optionalAccess', _465 => _465.ns]));
|
|
3364
3437
|
if (!name) return sendFail(res, "name required", opt);
|
|
3365
3438
|
const content = await IL.readInterventionFile($asai, name, ns);
|
|
3366
3439
|
return sendSuccess(res, { ns, ...content }, opt);
|
|
3367
3440
|
} catch (err) {
|
|
3368
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3441
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _466 => _466.message]) || err, opt);
|
|
3369
3442
|
}
|
|
3370
3443
|
}
|
|
3371
3444
|
if (url.startsWith("/api/asailog/intervention/types/")) {
|
|
@@ -3373,7 +3446,7 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3373
3446
|
try {
|
|
3374
3447
|
return sendSuccess(res, IL.getInterventionTaxonomy($asai), opt);
|
|
3375
3448
|
} catch (err) {
|
|
3376
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3449
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _467 => _467.message]) || err, opt);
|
|
3377
3450
|
}
|
|
3378
3451
|
}
|
|
3379
3452
|
}
|
|
@@ -3403,7 +3476,7 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3403
3476
|
);
|
|
3404
3477
|
return sendSuccess(res, { ns, ...result }, opt);
|
|
3405
3478
|
} catch (err) {
|
|
3406
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3479
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _468 => _468.message]) || err, opt);
|
|
3407
3480
|
}
|
|
3408
3481
|
}
|
|
3409
3482
|
}
|
|
@@ -3422,11 +3495,11 @@ function parseQuery(opt) {
|
|
|
3422
3495
|
}
|
|
3423
3496
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseQuery, "parseQuery");
|
|
3424
3497
|
function parseBody(opt) {
|
|
3425
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
3498
|
+
if (!_optionalChain([opt, 'optionalAccess', _469 => _469.data])) return {};
|
|
3426
3499
|
if (typeof opt.data === "string") {
|
|
3427
3500
|
try {
|
|
3428
3501
|
return JSON.parse(opt.data);
|
|
3429
|
-
} catch (
|
|
3502
|
+
} catch (e40) {
|
|
3430
3503
|
return {};
|
|
3431
3504
|
}
|
|
3432
3505
|
}
|
|
@@ -3434,7 +3507,7 @@ function parseBody(opt) {
|
|
|
3434
3507
|
}
|
|
3435
3508
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseBody, "parseBody");
|
|
3436
3509
|
var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3437
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3510
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _470 => _470.$lib, 'optionalAccess', _471 => _471.reqWork, 'optionalCall', _472 => _472($asai)]) || {};
|
|
3438
3511
|
const IL = $asai.$lib.InterventionLog;
|
|
3439
3512
|
async function get(req, res, hostdir, opt) {
|
|
3440
3513
|
const url = req.url || "";
|
|
@@ -3444,7 +3517,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3444
3517
|
try {
|
|
3445
3518
|
return sendSuccess(res, _chunkHR5JKN7Ycjs.getLogStoreMeta.call(void 0, $asai), opt);
|
|
3446
3519
|
} catch (err) {
|
|
3447
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3520
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _473 => _473.message]) || err, opt);
|
|
3448
3521
|
}
|
|
3449
3522
|
}
|
|
3450
3523
|
if (url.startsWith("/api/asailog/store/stats/")) {
|
|
@@ -3457,7 +3530,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3457
3530
|
const stats = await _chunkHR5JKN7Ycjs.getUnifiedStats.call(void 0, $asai);
|
|
3458
3531
|
return sendSuccess(res, { store: storeType, stats, config: _chunkHR5JKN7Ycjs.getLogStoreMeta.call(void 0, $asai) }, opt);
|
|
3459
3532
|
} catch (err) {
|
|
3460
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3533
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _474 => _474.message]) || err, opt);
|
|
3461
3534
|
}
|
|
3462
3535
|
}
|
|
3463
3536
|
if (url.startsWith("/api/asailog/store/compliance/")) {
|
|
@@ -3467,7 +3540,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3467
3540
|
const report = await _chunkHR5JKN7Ycjs.getComplianceReport.call(void 0, $asai, ns);
|
|
3468
3541
|
return sendSuccess(res, report, opt);
|
|
3469
3542
|
} catch (err) {
|
|
3470
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3543
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _475 => _475.message]) || err, opt);
|
|
3471
3544
|
}
|
|
3472
3545
|
}
|
|
3473
3546
|
if (url.startsWith("/api/asailog/store/search/")) {
|
|
@@ -3489,7 +3562,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3489
3562
|
});
|
|
3490
3563
|
return sendSuccess(res, result, opt);
|
|
3491
3564
|
} catch (err) {
|
|
3492
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3565
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _476 => _476.message]) || err, opt);
|
|
3493
3566
|
}
|
|
3494
3567
|
}
|
|
3495
3568
|
if (url.startsWith("/api/asailog/store/export/")) {
|
|
@@ -3510,7 +3583,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3510
3583
|
});
|
|
3511
3584
|
return sendSuccess(res, payload, opt);
|
|
3512
3585
|
} catch (err) {
|
|
3513
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3586
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _477 => _477.message]) || err, opt);
|
|
3514
3587
|
}
|
|
3515
3588
|
}
|
|
3516
3589
|
if (url.startsWith("/api/asailog/store/taxonomy/")) {
|
|
@@ -3518,7 +3591,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3518
3591
|
try {
|
|
3519
3592
|
return sendSuccess(res, IL.getInterventionTaxonomy($asai), opt);
|
|
3520
3593
|
} catch (err) {
|
|
3521
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3594
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _478 => _478.message]) || err, opt);
|
|
3522
3595
|
}
|
|
3523
3596
|
}
|
|
3524
3597
|
if (url.startsWith("/api/asailog/store/formats/")) {
|
|
@@ -3527,7 +3600,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3527
3600
|
const { getLogFormatTaxonomy } = await Promise.resolve().then(() => _interopRequireWildcard(require("./log-formats-TUXGMCCU.cjs")));
|
|
3528
3601
|
return sendSuccess(res, getLogFormatTaxonomy($asai), opt);
|
|
3529
3602
|
} catch (err) {
|
|
3530
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3603
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _479 => _479.message]) || err, opt);
|
|
3531
3604
|
}
|
|
3532
3605
|
}
|
|
3533
3606
|
if (url.startsWith("/api/asailog/store/selectlist/")) {
|
|
@@ -3554,7 +3627,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3554
3627
|
}
|
|
3555
3628
|
return sendSuccess(res, { groups }, opt);
|
|
3556
3629
|
} catch (err) {
|
|
3557
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3630
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _480 => _480.message]) || err, opt);
|
|
3558
3631
|
}
|
|
3559
3632
|
}
|
|
3560
3633
|
if (url.startsWith("/api/asailog/store/select/")) {
|
|
@@ -3588,7 +3661,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3588
3661
|
});
|
|
3589
3662
|
return sendSuccess(res, { entries: rows }, opt);
|
|
3590
3663
|
} catch (err) {
|
|
3591
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3664
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _481 => _481.message]) || err, opt);
|
|
3592
3665
|
}
|
|
3593
3666
|
}
|
|
3594
3667
|
}
|
|
@@ -3610,7 +3683,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3610
3683
|
});
|
|
3611
3684
|
return sendSuccess(res, result, opt);
|
|
3612
3685
|
} catch (err) {
|
|
3613
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3686
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _482 => _482.message]) || err, opt);
|
|
3614
3687
|
}
|
|
3615
3688
|
}
|
|
3616
3689
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, post, "post");
|
|
@@ -3622,7 +3695,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3622
3695
|
|
|
3623
3696
|
var registry = null;
|
|
3624
3697
|
function resolveFilePath($asai) {
|
|
3625
|
-
const root = _optionalChain([$asai, 'optionalAccess',
|
|
3698
|
+
const root = _optionalChain([$asai, 'optionalAccess', _483 => _483.serverRoot]) || process.cwd();
|
|
3626
3699
|
return nodePath3.join(root, "websys/sys/errorcodes.json");
|
|
3627
3700
|
}
|
|
3628
3701
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveFilePath, "resolveFilePath");
|
|
@@ -3632,7 +3705,7 @@ function loadErrorCodes($asai) {
|
|
|
3632
3705
|
try {
|
|
3633
3706
|
const raw = fs8.readFileSync(filePath, "utf8");
|
|
3634
3707
|
registry = JSON.parse(raw);
|
|
3635
|
-
} catch (
|
|
3708
|
+
} catch (e41) {
|
|
3636
3709
|
registry = { version: "0", errors: {} };
|
|
3637
3710
|
}
|
|
3638
3711
|
if ($asai) $asai.errorcodes = registry;
|
|
@@ -3640,7 +3713,7 @@ function loadErrorCodes($asai) {
|
|
|
3640
3713
|
}
|
|
3641
3714
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, loadErrorCodes, "loadErrorCodes");
|
|
3642
3715
|
function getError(ec) {
|
|
3643
|
-
return _optionalChain([registry, 'optionalAccess',
|
|
3716
|
+
return _optionalChain([registry, 'optionalAccess', _484 => _484.errors, 'optionalAccess', _485 => _485[ec]]) || null;
|
|
3644
3717
|
}
|
|
3645
3718
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getError, "getError");
|
|
3646
3719
|
function hasError(ec) {
|
|
@@ -3649,11 +3722,11 @@ function hasError(ec) {
|
|
|
3649
3722
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasError, "hasError");
|
|
3650
3723
|
function logError($asai, ec, params) {
|
|
3651
3724
|
const entry = getError(ec);
|
|
3652
|
-
const logFn = _optionalChain([$asai, 'optionalAccess',
|
|
3725
|
+
const logFn = _optionalChain([$asai, 'optionalAccess', _486 => _486.$log]) || console.warn;
|
|
3653
3726
|
if (entry) {
|
|
3654
|
-
logFn(`[EC:${ec}]`, entry.id || "", entry.detail || "", _optionalChain([params, 'optionalAccess',
|
|
3727
|
+
logFn(`[EC:${ec}]`, entry.id || "", entry.detail || "", _optionalChain([params, 'optionalAccess', _487 => _487.length]) ? params : "");
|
|
3655
3728
|
} else {
|
|
3656
|
-
logFn(`[EC:${ec}]`, "(unregistered)", _optionalChain([params, 'optionalAccess',
|
|
3729
|
+
logFn(`[EC:${ec}]`, "(unregistered)", _optionalChain([params, 'optionalAccess', _488 => _488.length]) ? params : "");
|
|
3657
3730
|
}
|
|
3658
3731
|
}
|
|
3659
3732
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, logError, "logError");
|
|
@@ -3681,14 +3754,14 @@ var ErrorCode_default = {
|
|
|
3681
3754
|
|
|
3682
3755
|
// src/sysserver/api/common/errorcodes.ts
|
|
3683
3756
|
var errorcodes_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3684
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3757
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _489 => _489.$lib, 'optionalAccess', _490 => _490.reqWork, 'optionalCall', _491 => _491($asai)]) || {};
|
|
3685
3758
|
function get(req, res, _hostdir, opt) {
|
|
3686
3759
|
const url = req.url || "";
|
|
3687
3760
|
if (url.startsWith("/api/sys/errorcodes/")) {
|
|
3688
3761
|
try {
|
|
3689
3762
|
return sendSuccess(res, loadErrorCodes($asai), opt);
|
|
3690
3763
|
} catch (err) {
|
|
3691
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3764
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _492 => _492.message]) || err, opt);
|
|
3692
3765
|
}
|
|
3693
3766
|
}
|
|
3694
3767
|
}
|
|
@@ -3698,9 +3771,9 @@ var errorcodes_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3698
3771
|
|
|
3699
3772
|
// src/sysserver/api/common/sqlitemanage.ts
|
|
3700
3773
|
var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3701
|
-
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'optionalAccess',
|
|
3774
|
+
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'optionalAccess', _493 => _493.$lib, 'optionalAccess', _494 => _494.reqWork, 'optionalCall', _495 => _495($asai)]) || {};
|
|
3702
3775
|
function mgLog(...arg) {
|
|
3703
|
-
_optionalChain([mnLog, 'optionalCall',
|
|
3776
|
+
_optionalChain([mnLog, 'optionalCall', _496 => _496("SQLite", ...arg)]);
|
|
3704
3777
|
}
|
|
3705
3778
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mgLog, "mgLog");
|
|
3706
3779
|
return $asai.$lib.AsDb($asai, {
|
|
@@ -3718,7 +3791,7 @@ var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
|
3718
3791
|
if (req.url.startsWith("/api/asaisqlite/manage/post")) {
|
|
3719
3792
|
try {
|
|
3720
3793
|
mgLog("POST", "custom handler triggered");
|
|
3721
|
-
_optionalChain([sendSuccess, 'optionalCall',
|
|
3794
|
+
_optionalChain([sendSuccess, 'optionalCall', _497 => _497(res, { data: "post" }, opt)]);
|
|
3722
3795
|
} catch (err) {
|
|
3723
3796
|
mgLog("ERROR", "post handler", err);
|
|
3724
3797
|
}
|
|
@@ -3735,10 +3808,10 @@ var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
|
3735
3808
|
table: dataObj.table
|
|
3736
3809
|
});
|
|
3737
3810
|
mgLog("SELECT", "completed");
|
|
3738
|
-
_optionalChain([sendSuccess, 'optionalCall',
|
|
3811
|
+
_optionalChain([sendSuccess, 'optionalCall', _498 => _498(res, resdb, opt)]);
|
|
3739
3812
|
} catch (errdb) {
|
|
3740
3813
|
mgLog("ERROR", "select", errdb);
|
|
3741
|
-
_optionalChain([sendFail, 'optionalCall',
|
|
3814
|
+
_optionalChain([sendFail, 'optionalCall', _499 => _499(res, errdb, opt)]);
|
|
3742
3815
|
}
|
|
3743
3816
|
return "ok";
|
|
3744
3817
|
}
|
|
@@ -3754,7 +3827,7 @@ function promLine(name, value, labels) {
|
|
|
3754
3827
|
}
|
|
3755
3828
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, promLine, "promLine");
|
|
3756
3829
|
var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3757
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3830
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _500 => _500.$lib, 'optionalAccess', _501 => _501.reqWork, 'optionalCall', _502 => _502($asai)]) || {};
|
|
3758
3831
|
async function get(req, res, _hostdir, opt) {
|
|
3759
3832
|
const url = req.url || "";
|
|
3760
3833
|
if (url.startsWith("/api/sys/health/metrics/")) {
|
|
@@ -3763,10 +3836,10 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3763
3836
|
let httpTotal = 0;
|
|
3764
3837
|
let wsTotal = 0;
|
|
3765
3838
|
for (const set of Object.values($asai.connectionshttp || {})) {
|
|
3766
|
-
httpTotal += _optionalChain([set, 'optionalAccess',
|
|
3839
|
+
httpTotal += _optionalChain([set, 'optionalAccess', _503 => _503.size]) || 0;
|
|
3767
3840
|
}
|
|
3768
3841
|
for (const set of Object.values($asai.connectionsws || {})) {
|
|
3769
|
-
wsTotal += _optionalChain([set, 'optionalAccess',
|
|
3842
|
+
wsTotal += _optionalChain([set, 'optionalAccess', _504 => _504.size]) || 0;
|
|
3770
3843
|
}
|
|
3771
3844
|
const lines = [
|
|
3772
3845
|
"# HELP asai_uptime_seconds Process uptime",
|
|
@@ -3788,7 +3861,7 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3788
3861
|
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
3789
3862
|
return res.end(lines.join("\n") + "\n");
|
|
3790
3863
|
} catch (err) {
|
|
3791
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3864
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _505 => _505.message]) || err, opt);
|
|
3792
3865
|
}
|
|
3793
3866
|
}
|
|
3794
3867
|
if (url.startsWith("/api/sys/health/status/")) {
|
|
@@ -3801,10 +3874,10 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3801
3874
|
memory: process.memoryUsage(),
|
|
3802
3875
|
quota: {
|
|
3803
3876
|
http: Object.fromEntries(
|
|
3804
|
-
Object.entries($asai.connectionshttp || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess',
|
|
3877
|
+
Object.entries($asai.connectionshttp || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess', _506 => _506.size]) || 0])
|
|
3805
3878
|
),
|
|
3806
3879
|
ws: Object.fromEntries(
|
|
3807
|
-
Object.entries($asai.connectionsws || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess',
|
|
3880
|
+
Object.entries($asai.connectionsws || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess', _507 => _507.size]) || 0])
|
|
3808
3881
|
)
|
|
3809
3882
|
}
|
|
3810
3883
|
},
|
|
@@ -3845,7 +3918,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, sanitizeString, "sanitizeString");
|
|
|
3845
3918
|
// src/sysserver/api/login/service/session.ts
|
|
3846
3919
|
|
|
3847
3920
|
function getSessionTtlMs($asai) {
|
|
3848
|
-
const hours = _nullishCoalesce(_optionalChain([$asai, 'optionalAccess',
|
|
3921
|
+
const hours = _nullishCoalesce(_optionalChain([$asai, 'optionalAccess', _508 => _508.hostconfig, 'optionalAccess', _509 => _509.security, 'optionalAccess', _510 => _510.sessionTtlHours]), () => ( 24));
|
|
3849
3922
|
return Number(hours) * 3600 * 1e3;
|
|
3850
3923
|
}
|
|
3851
3924
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSessionTtlMs, "getSessionTtlMs");
|
|
@@ -3862,7 +3935,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, generatePriKey, "generatePriKey");
|
|
|
3862
3935
|
function createSessionKeys($asai) {
|
|
3863
3936
|
const sessionId = _crypto.randomUUID.call(void 0, );
|
|
3864
3937
|
const pri = generatePriKey();
|
|
3865
|
-
const sn = _optionalChain([$asai, 'optionalAccess',
|
|
3938
|
+
const sn = _optionalChain([$asai, 'optionalAccess', _511 => _511.hostconfig, 'optionalAccess', _512 => _512.asaisn]);
|
|
3866
3939
|
if (!sn) throw new Error("[session] ASAI_ASAISN \u672A\u914D\u7F6E");
|
|
3867
3940
|
const pub = $asai.$lib.AsCode.asencode(pri, sn);
|
|
3868
3941
|
return { pri, pub, sessionId };
|
|
@@ -3912,20 +3985,20 @@ function unwrapJsonString(value) {
|
|
|
3912
3985
|
if (!text.startsWith("{") && !text.startsWith("[")) return value;
|
|
3913
3986
|
try {
|
|
3914
3987
|
return JSON.parse(text);
|
|
3915
|
-
} catch (
|
|
3988
|
+
} catch (e42) {
|
|
3916
3989
|
return value;
|
|
3917
3990
|
}
|
|
3918
3991
|
}
|
|
3919
3992
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, unwrapJsonString, "unwrapJsonString");
|
|
3920
3993
|
function parseAuthBody(opt) {
|
|
3921
|
-
let raw = _optionalChain([opt, 'optionalAccess',
|
|
3994
|
+
let raw = _optionalChain([opt, 'optionalAccess', _513 => _513.data]);
|
|
3922
3995
|
if (raw == null || raw === "") return {};
|
|
3923
3996
|
if (typeof raw === "string") {
|
|
3924
3997
|
const text = raw.trim();
|
|
3925
3998
|
if (!text) return {};
|
|
3926
3999
|
try {
|
|
3927
4000
|
raw = JSON.parse(text);
|
|
3928
|
-
} catch (
|
|
4001
|
+
} catch (e43) {
|
|
3929
4002
|
if (text.includes("=") && !text.startsWith("{") && !text.startsWith("[")) {
|
|
3930
4003
|
raw = Object.fromEntries(new URLSearchParams(text));
|
|
3931
4004
|
} else {
|
|
@@ -3994,7 +4067,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, purgeOfflineSessions, "purgeOfflineSession
|
|
|
3994
4067
|
|
|
3995
4068
|
// src/sysserver/api/login/index.ts
|
|
3996
4069
|
function getSecurity($asai) {
|
|
3997
|
-
return _optionalChain([$asai, 'optionalAccess',
|
|
4070
|
+
return _optionalChain([$asai, 'optionalAccess', _514 => _514.hostconfig, 'optionalAccess', _515 => _515.security]) || {};
|
|
3998
4071
|
}
|
|
3999
4072
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSecurity, "getSecurity");
|
|
4000
4073
|
function getQuota2($asai) {
|
|
@@ -4007,7 +4080,7 @@ async function canLogin($asai, us, hostdir) {
|
|
|
4007
4080
|
if (!quota.enabled) return { ok: true };
|
|
4008
4081
|
const store = _chunkZK4O4Z2Ocjs.createUserStore.call(void 0, $asai);
|
|
4009
4082
|
const total = await countOnlineSessions($asai, hostdir, store);
|
|
4010
|
-
const maxLogin = _nullishCoalesce(_nullishCoalesce(quota.maxLoginSessions, () => ( _optionalChain([$asai, 'optionalAccess',
|
|
4083
|
+
const maxLogin = _nullishCoalesce(_nullishCoalesce(quota.maxLoginSessions, () => ( _optionalChain([$asai, 'optionalAccess', _516 => _516.hostconfig, 'optionalAccess', _517 => _517.hosts, 'optionalAccess', _518 => _518.default, 'optionalAccess', _519 => _519.maxonline]))), () => ( 100));
|
|
4011
4084
|
if (total >= maxLogin) {
|
|
4012
4085
|
return { ok: false, message: "LOGIN_QUOTA_FULL" };
|
|
4013
4086
|
}
|
|
@@ -4040,7 +4113,7 @@ function ensureReady($asai) {
|
|
|
4040
4113
|
}
|
|
4041
4114
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, ensureReady, "ensureReady");
|
|
4042
4115
|
var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
4043
|
-
const { sendSuccess, sendFail, sendErr } = _optionalChain([$asai, 'access',
|
|
4116
|
+
const { sendSuccess, sendFail, sendErr } = _optionalChain([$asai, 'access', _520 => _520.$lib, 'optionalAccess', _521 => _521.reqWork, 'optionalCall', _522 => _522($asai)]) || {};
|
|
4044
4117
|
const store = _chunkZK4O4Z2Ocjs.createUserStore.call(void 0, $asai);
|
|
4045
4118
|
async function checkAdmin(req, pathname, minOverride) {
|
|
4046
4119
|
await attachServerUserLevel(req, $asai);
|
|
@@ -4081,7 +4154,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4081
4154
|
logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: us, ip, detail: "password_changed" });
|
|
4082
4155
|
return sendSuccess(res, { ok: true }, opt);
|
|
4083
4156
|
} catch (err) {
|
|
4084
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4157
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _523 => _523.message]) || err, opt);
|
|
4085
4158
|
}
|
|
4086
4159
|
}
|
|
4087
4160
|
if (url.startsWith("/api/user/login/register/")) {
|
|
@@ -4114,11 +4187,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4114
4187
|
logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: us, ip, detail: "register_ok" });
|
|
4115
4188
|
return sendSuccess(res, { user: publicUser($asai, user) }, opt);
|
|
4116
4189
|
} catch (err) {
|
|
4117
|
-
const msg = _optionalChain([err, 'optionalAccess',
|
|
4190
|
+
const msg = _optionalChain([err, 'optionalAccess', _524 => _524.message]) || String(err);
|
|
4118
4191
|
if (msg.includes("exists") || msg.includes("\u5DF2\u5B58\u5728")) {
|
|
4119
4192
|
return sendErr(res, "USER_ALREADY_EXISTS", void 0, opt);
|
|
4120
4193
|
}
|
|
4121
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4194
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _525 => _525.message]) || err, opt);
|
|
4122
4195
|
}
|
|
4123
4196
|
}
|
|
4124
4197
|
if (url.startsWith("/api/user/login/auth/")) {
|
|
@@ -4152,9 +4225,15 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4152
4225
|
}
|
|
4153
4226
|
const policy = _chunkGXOFLFFWcjs.getPasswordPolicy.call(void 0, $asai);
|
|
4154
4227
|
const mustChange = !!user.mustChangePassword || _chunkGXOFLFFWcjs.isPasswordExpired.call(void 0, user.passwordChangedAt, policy.maxAgeDays);
|
|
4155
|
-
const hostcfg = _optionalChain([$asai, 'access',
|
|
4156
|
-
if (hostcfg.ckws
|
|
4157
|
-
|
|
4228
|
+
const hostcfg = _optionalChain([$asai, 'access', _526 => _526.getHost, 'optionalCall', _527 => _527(hostdir)]) || {};
|
|
4229
|
+
if (hostcfg.ckws) {
|
|
4230
|
+
const existingWs = _optionalChain([$asai, 'access', _528 => _528.connectionsws, 'optionalAccess', _529 => _529[hostdir], 'optionalAccess', _530 => _530[us]]);
|
|
4231
|
+
if (existingWs) {
|
|
4232
|
+
const cleared = await clearStaleWsIfDead($asai, hostdir, us, existingWs);
|
|
4233
|
+
if (!cleared) {
|
|
4234
|
+
kickUserWs($asai, us, hostdir);
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4158
4237
|
}
|
|
4159
4238
|
const quotaCheck = await canLogin($asai, us, hostdir);
|
|
4160
4239
|
if (!quotaCheck.ok) {
|
|
@@ -4177,13 +4256,13 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4177
4256
|
opt
|
|
4178
4257
|
);
|
|
4179
4258
|
} catch (err) {
|
|
4180
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4259
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _531 => _531.message]) || err, opt);
|
|
4181
4260
|
}
|
|
4182
4261
|
}
|
|
4183
4262
|
if (url.startsWith("/api/user/login/logout/")) {
|
|
4184
4263
|
try {
|
|
4185
4264
|
const bodySid = body.sessionId ? sanitizeString(body.sessionId, 64) : "";
|
|
4186
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4265
|
+
const us = _optionalChain([req, 'optionalAccess', _532 => _532.Userinfo, 'optionalAccess', _533 => _533[0]]);
|
|
4187
4266
|
if (bodySid) {
|
|
4188
4267
|
if (!us) {
|
|
4189
4268
|
return sendErr(res, "AUTH_MISSING", void 0, opt);
|
|
@@ -4197,7 +4276,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4197
4276
|
if (us) logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: String(us), ip, detail: "logout" });
|
|
4198
4277
|
return sendSuccess(res, "ok", opt);
|
|
4199
4278
|
} catch (err) {
|
|
4200
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4279
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _534 => _534.message]) || err, opt);
|
|
4201
4280
|
}
|
|
4202
4281
|
}
|
|
4203
4282
|
if (url.startsWith("/api/user/login/admin/kick/")) {
|
|
@@ -4215,7 +4294,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4215
4294
|
}
|
|
4216
4295
|
kickUserWs($asai, target.us, hostdir);
|
|
4217
4296
|
await store.removeSession(sessionId);
|
|
4218
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4297
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _535 => _535.Userinfo, 'optionalAccess', _536 => _536[0]]) || "");
|
|
4219
4298
|
await _chunkARHPHWT5cjs.logSessionTerminate.call(void 0, $asai, {
|
|
4220
4299
|
operator,
|
|
4221
4300
|
sessionId,
|
|
@@ -4224,7 +4303,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4224
4303
|
});
|
|
4225
4304
|
return sendSuccess(res, { ok: true }, opt);
|
|
4226
4305
|
} catch (err) {
|
|
4227
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4306
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _537 => _537.message]) || err, opt);
|
|
4228
4307
|
}
|
|
4229
4308
|
}
|
|
4230
4309
|
if (url.startsWith("/api/user/login/admin/delete/")) {
|
|
@@ -4236,11 +4315,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4236
4315
|
if (!targetUs || targetUs === "admin") return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4237
4316
|
const ok = await store.deleteUser(targetUs);
|
|
4238
4317
|
if (!ok) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4239
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4318
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _538 => _538.Userinfo, 'optionalAccess', _539 => _539[0]]) || "");
|
|
4240
4319
|
await _chunkARHPHWT5cjs.logAccountPurge.call(void 0, $asai, { operator, targetUs, ip });
|
|
4241
4320
|
return sendSuccess(res, { ok: true }, opt);
|
|
4242
4321
|
} catch (err) {
|
|
4243
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4322
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _540 => _540.message]) || err, opt);
|
|
4244
4323
|
}
|
|
4245
4324
|
}
|
|
4246
4325
|
if (url.startsWith("/api/user/login/admin/levels/")) {
|
|
@@ -4252,7 +4331,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4252
4331
|
const thresholds = body.thresholds && typeof body.thresholds === "object" ? body.thresholds : void 0;
|
|
4253
4332
|
const routeRights = Array.isArray(body.routeRights) ? body.routeRights : void 0;
|
|
4254
4333
|
const defaultResetPassword = typeof body.defaultResetPassword === "string" ? body.defaultResetPassword : void 0;
|
|
4255
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4334
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _541 => _541.Userinfo, 'optionalAccess', _542 => _542[0]]) || "");
|
|
4256
4335
|
const cfg = await _chunkGXOFLFFWcjs.saveUserLevelConfig.call(void 0,
|
|
4257
4336
|
$asai,
|
|
4258
4337
|
{
|
|
@@ -4265,13 +4344,13 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4265
4344
|
);
|
|
4266
4345
|
await _chunkARHPHWT5cjs.logSecurityConfigIntervention.call(void 0, $asai, {
|
|
4267
4346
|
section: "user_levels",
|
|
4268
|
-
detail: JSON.stringify({ levels: _optionalChain([levels, 'optionalAccess',
|
|
4347
|
+
detail: JSON.stringify({ levels: _optionalChain([levels, 'optionalAccess', _543 => _543.length]), thresholds: !!thresholds, routeRights: _optionalChain([routeRights, 'optionalAccess', _544 => _544.length]) }),
|
|
4269
4348
|
operator,
|
|
4270
4349
|
ip
|
|
4271
4350
|
});
|
|
4272
4351
|
return sendSuccess(res, cfg, opt);
|
|
4273
4352
|
} catch (err) {
|
|
4274
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4353
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _545 => _545.message]) || err, opt);
|
|
4275
4354
|
}
|
|
4276
4355
|
}
|
|
4277
4356
|
if (url.startsWith("/api/user/login/admin/resetpass/")) {
|
|
@@ -4305,7 +4384,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4305
4384
|
passHistory: "[]"
|
|
4306
4385
|
});
|
|
4307
4386
|
if (!updated) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4308
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4387
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _546 => _546.Userinfo, 'optionalAccess', _547 => _547[0]]) || "");
|
|
4309
4388
|
await _chunkARHPHWT5cjs.logUserRbacChange.call(void 0, $asai, {
|
|
4310
4389
|
operator,
|
|
4311
4390
|
targetUs,
|
|
@@ -4322,7 +4401,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4322
4401
|
});
|
|
4323
4402
|
return sendSuccess(res, { user: publicUser($asai, updated) }, opt);
|
|
4324
4403
|
} catch (err) {
|
|
4325
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4404
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _548 => _548.message]) || err, opt);
|
|
4326
4405
|
}
|
|
4327
4406
|
}
|
|
4328
4407
|
if (url.startsWith("/api/user/login/admin/update/")) {
|
|
@@ -4353,7 +4432,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4353
4432
|
if (!updated) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4354
4433
|
if (Object.keys(patch).length) {
|
|
4355
4434
|
await _chunkARHPHWT5cjs.logUserRbacChange.call(void 0, $asai, {
|
|
4356
|
-
operator: String(_optionalChain([req, 'optionalAccess',
|
|
4435
|
+
operator: String(_optionalChain([req, 'optionalAccess', _549 => _549.Userinfo, 'optionalAccess', _550 => _550[0]]) || ""),
|
|
4357
4436
|
targetUs,
|
|
4358
4437
|
patch,
|
|
4359
4438
|
ip
|
|
@@ -4361,11 +4440,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4361
4440
|
}
|
|
4362
4441
|
return sendSuccess(res, { user: publicUser($asai, updated) }, opt);
|
|
4363
4442
|
} catch (err) {
|
|
4364
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4443
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _551 => _551.message]) || err, opt);
|
|
4365
4444
|
}
|
|
4366
4445
|
}
|
|
4367
4446
|
if (url.startsWith("/api/user/login/profile/")) {
|
|
4368
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4447
|
+
const us = _optionalChain([req, 'optionalAccess', _552 => _552.Userinfo, 'optionalAccess', _553 => _553[0]]);
|
|
4369
4448
|
if (!us) return sendErr(res, "AUTH_UNAUTHORIZED", void 0, opt);
|
|
4370
4449
|
try {
|
|
4371
4450
|
const user = await store.findByUsername(String(us));
|
|
@@ -4399,7 +4478,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4399
4478
|
const fresh = await store.findByUsername(String(us));
|
|
4400
4479
|
return sendSuccess(res, { user: fresh ? publicUser($asai, fresh) : null }, opt);
|
|
4401
4480
|
} catch (err) {
|
|
4402
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4481
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _554 => _554.message]) || err, opt);
|
|
4403
4482
|
}
|
|
4404
4483
|
}
|
|
4405
4484
|
}
|
|
@@ -4408,7 +4487,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4408
4487
|
const url = req.url || "";
|
|
4409
4488
|
const ip = getClientIp(req);
|
|
4410
4489
|
if (url.startsWith("/api/user/login/config/")) {
|
|
4411
|
-
const lang = String(_optionalChain([req, 'optionalAccess',
|
|
4490
|
+
const lang = String(_optionalChain([req, 'optionalAccess', _555 => _555.headers, 'optionalAccess', _556 => _556["accept-language"]]) || _optionalChain([opt, 'optionalAccess', _557 => _557.headers, 'optionalAccess', _558 => _558["accept-language"]]) || "zh-CN").split(",")[0];
|
|
4412
4491
|
await _chunkGXOFLFFWcjs.loadUserLevelConfig.call(void 0, $asai);
|
|
4413
4492
|
return sendSuccess(res, _chunkGXOFLFFWcjs.getPublicSecurityConfig.call(void 0, $asai, lang), opt);
|
|
4414
4493
|
}
|
|
@@ -4469,7 +4548,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4469
4548
|
);
|
|
4470
4549
|
}
|
|
4471
4550
|
if (url.startsWith("/api/user/login/profile/")) {
|
|
4472
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4551
|
+
const us = _optionalChain([req, 'optionalAccess', _559 => _559.Userinfo, 'optionalAccess', _560 => _560[0]]);
|
|
4473
4552
|
if (!us) return sendErr(res, "AUTH_UNAUTHORIZED", void 0, opt);
|
|
4474
4553
|
const user = await store.findByUsername(String(us));
|
|
4475
4554
|
return sendSuccess(res, { user: user ? publicUser($asai, user) : null }, opt);
|
|
@@ -4511,16 +4590,16 @@ var As_default = {
|
|
|
4511
4590
|
return { code: 908, data: val };
|
|
4512
4591
|
},
|
|
4513
4592
|
ctxSuccess(val, opt = null) {
|
|
4514
|
-
if (typeof _optionalChain([opt, 'optionalAccess',
|
|
4593
|
+
if (typeof _optionalChain([opt, 'optionalAccess', _561 => _561.resAES]) === "function") {
|
|
4515
4594
|
val = opt.resAES(val);
|
|
4516
4595
|
}
|
|
4517
4596
|
return { code: 909, data: val };
|
|
4518
4597
|
},
|
|
4519
4598
|
getPath(str = "-") {
|
|
4520
|
-
return _optionalChain([str, 'optionalAccess',
|
|
4599
|
+
return _optionalChain([str, 'optionalAccess', _562 => _562.replace, 'call', _563 => _563(/[^a-zA-Z0-9.\-_\\\/]/g, "")]);
|
|
4521
4600
|
},
|
|
4522
4601
|
getName(str = "-") {
|
|
4523
|
-
return _optionalChain([str, 'optionalAccess',
|
|
4602
|
+
return _optionalChain([str, 'optionalAccess', _564 => _564.replace, 'call', _565 => _565(/[^a-zA-Z0-9.\-_]/g, "")]);
|
|
4524
4603
|
},
|
|
4525
4604
|
toDirPath(relativePath) {
|
|
4526
4605
|
const pathArr = relativePath.split("/");
|
|
@@ -4591,7 +4670,7 @@ var As_default = {
|
|
|
4591
4670
|
// immediate: false,
|
|
4592
4671
|
// });
|
|
4593
4672
|
dtImmediate(fn, opt) {
|
|
4594
|
-
if (_optionalChain([opt, 'optionalAccess',
|
|
4673
|
+
if (_optionalChain([opt, 'optionalAccess', _566 => _566.immediate])) {
|
|
4595
4674
|
fn();
|
|
4596
4675
|
opt.immediate = false;
|
|
4597
4676
|
}
|
|
@@ -4613,7 +4692,7 @@ var As_default = {
|
|
|
4613
4692
|
if (opt.endtime - opt.starttime < opt.wait) {
|
|
4614
4693
|
this.dtClearTimeout(opt);
|
|
4615
4694
|
}
|
|
4616
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
4695
|
+
if (!_optionalChain([opt, 'optionalAccess', _567 => _567.timeout])) {
|
|
4617
4696
|
opt.starttime = opt.endtime;
|
|
4618
4697
|
opt.timeout = this.dtSetTimeout(fn, opt);
|
|
4619
4698
|
}
|
|
@@ -4621,7 +4700,7 @@ var As_default = {
|
|
|
4621
4700
|
// 节流:指定长度时间内有多次触发,只fn最后一次触发
|
|
4622
4701
|
throttle(fn, opt) {
|
|
4623
4702
|
this.dtImmediate(fn, opt);
|
|
4624
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
4703
|
+
if (!_optionalChain([opt, 'optionalAccess', _568 => _568.timeout])) {
|
|
4625
4704
|
opt.timeout = this.dtSetTimeout(fn, opt);
|
|
4626
4705
|
}
|
|
4627
4706
|
},
|
|
@@ -4657,8 +4736,8 @@ var As_default = {
|
|
|
4657
4736
|
var AsCode_default = {
|
|
4658
4737
|
// 加密
|
|
4659
4738
|
asencode(str, keys) {
|
|
4660
|
-
const strlen = _optionalChain([str, 'optionalAccess',
|
|
4661
|
-
const keyslen = _optionalChain([keys, 'optionalAccess',
|
|
4739
|
+
const strlen = _optionalChain([str, 'optionalAccess', _569 => _569.length]) || 0;
|
|
4740
|
+
const keyslen = _optionalChain([keys, 'optionalAccess', _570 => _570.length]) || 0;
|
|
4662
4741
|
let newstr = "";
|
|
4663
4742
|
for (let i = 0; i < strlen; i++) {
|
|
4664
4743
|
const rnum = Math.round(Math.random() * 1e3) % keyslen;
|
|
@@ -4683,7 +4762,7 @@ var AsCode_default = {
|
|
|
4683
4762
|
const rnum = keys.indexOf(str[i + 3]);
|
|
4684
4763
|
const rnumx = Number(rnum.toString().slice(-1)) + 1;
|
|
4685
4764
|
const ylen = keyslen - rnumx;
|
|
4686
|
-
newstr += _optionalChain([String, 'optionalAccess',
|
|
4765
|
+
newstr += _optionalChain([String, 'optionalAccess', _571 => _571.fromCodePoint, 'call', _572 => _572(
|
|
4687
4766
|
(keys.indexOf(str[i++]) - rnumx) * ylen * ylen + (keys.indexOf(str[i++]) - rnumx) * ylen + (keys.indexOf(str[i++]) - rnumx)
|
|
4688
4767
|
)]);
|
|
4689
4768
|
}
|
|
@@ -4730,7 +4809,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4730
4809
|
if (typeof value !== "string") return value;
|
|
4731
4810
|
try {
|
|
4732
4811
|
return JSON.parse(value);
|
|
4733
|
-
} catch (
|
|
4812
|
+
} catch (e44) {
|
|
4734
4813
|
return value;
|
|
4735
4814
|
}
|
|
4736
4815
|
}
|
|
@@ -4766,7 +4845,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4766
4845
|
}
|
|
4767
4846
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, decrypt, "decrypt");
|
|
4768
4847
|
function validateFields(payload, fields) {
|
|
4769
|
-
return fields.every((key) => typeof _optionalChain([payload, 'optionalAccess',
|
|
4848
|
+
return fields.every((key) => typeof _optionalChain([payload, 'optionalAccess', _573 => _573[key]]) === "string" && payload[key].length > 0);
|
|
4770
4849
|
}
|
|
4771
4850
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, validateFields, "validateFields");
|
|
4772
4851
|
function reqAES(opt, fn = (data) => data) {
|
|
@@ -4774,7 +4853,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4774
4853
|
try {
|
|
4775
4854
|
if (validateFields(reqData, ["data", "iv", "auth"])) {
|
|
4776
4855
|
let aesData = decrypt(reqData);
|
|
4777
|
-
if (_optionalChain([reqData, 'optionalAccess',
|
|
4856
|
+
if (_optionalChain([reqData, 'optionalAccess', _574 => _574.aes]) === 2) {
|
|
4778
4857
|
aesData = JSON.parse(aesData);
|
|
4779
4858
|
}
|
|
4780
4859
|
return fn(aesData);
|
|
@@ -4808,24 +4887,24 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4808
4887
|
// src/sysserver/lib/common/AsDb.ts
|
|
4809
4888
|
var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, cfg) => {
|
|
4810
4889
|
const DataServer = _chunk2BCIIKRGcjs.getDataServerForAsDb.call(void 0, $asai, {
|
|
4811
|
-
type: _optionalChain([cfg, 'optionalAccess',
|
|
4890
|
+
type: _optionalChain([cfg, 'optionalAccess', _575 => _575.type]) || "sqlite",
|
|
4812
4891
|
opt: {
|
|
4813
|
-
..._optionalChain([cfg, 'optionalAccess',
|
|
4892
|
+
..._optionalChain([cfg, 'optionalAccess', _576 => _576.opt]) || {
|
|
4814
4893
|
database: "./webdata/webdb/sqlite/asaisqlite.db",
|
|
4815
4894
|
create: 1
|
|
4816
4895
|
}
|
|
4817
4896
|
},
|
|
4818
|
-
storeKey: _optionalChain([cfg, 'optionalAccess',
|
|
4897
|
+
storeKey: _optionalChain([cfg, 'optionalAccess', _577 => _577.storeKey])
|
|
4819
4898
|
});
|
|
4820
4899
|
function reqwherestr(str) {
|
|
4821
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4900
|
+
if (_optionalChain([cfg, 'optionalAccess', _578 => _578.type]) === "sqlite" || _optionalChain([cfg, 'optionalAccess', _579 => _579.type]) === "mysql") {
|
|
4822
4901
|
return `'${str}'`;
|
|
4823
4902
|
}
|
|
4824
4903
|
return str;
|
|
4825
4904
|
}
|
|
4826
4905
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqwherestr, "reqwherestr");
|
|
4827
4906
|
function reqfield(queryData) {
|
|
4828
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4907
|
+
if (_optionalChain([queryData, 'optionalAccess', _580 => _580.fd])) {
|
|
4829
4908
|
return queryData.fd.split("-");
|
|
4830
4909
|
}
|
|
4831
4910
|
return cfg.field.data;
|
|
@@ -4833,14 +4912,14 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4833
4912
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqfield, "reqfield");
|
|
4834
4913
|
function reqwhere(queryData) {
|
|
4835
4914
|
const wheretmp = [];
|
|
4836
|
-
if ((_optionalChain([cfg, 'optionalAccess',
|
|
4915
|
+
if ((_optionalChain([cfg, 'optionalAccess', _581 => _581.type]) === "sqlite" || _optionalChain([cfg, 'optionalAccess', _582 => _582.type]) === "mysql") && _optionalChain([queryData, 'optionalAccess', _583 => _583.wlv])) {
|
|
4837
4916
|
const wlvarr = queryData.wlv.split("-");
|
|
4838
4917
|
wheretmp.push([wlvarr[0], ">", Number(wlvarr[1] || 0)]);
|
|
4839
4918
|
}
|
|
4840
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4919
|
+
if (_optionalChain([queryData, 'optionalAccess', _584 => _584.fl])) {
|
|
4841
4920
|
wheretmp.push([cfg.field.class, "LIKE", reqwherestr(`${queryData.fl}%`)]);
|
|
4842
4921
|
}
|
|
4843
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4922
|
+
if (_optionalChain([queryData, 'optionalAccess', _585 => _585.ss]) && _optionalChain([queryData, 'optionalAccess', _586 => _586.ssty])) {
|
|
4844
4923
|
wheretmp.push([queryData.ssty, "LIKE", reqwherestr(`%${queryData.ss}%`)]);
|
|
4845
4924
|
}
|
|
4846
4925
|
if (wheretmp.length > 1) {
|
|
@@ -4851,16 +4930,16 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4851
4930
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqwhere, "reqwhere");
|
|
4852
4931
|
function reqorder(queryData) {
|
|
4853
4932
|
const ordertmp = [];
|
|
4854
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4855
|
-
ordertmp.push([queryData.sx, _optionalChain([queryData, 'optionalAccess',
|
|
4933
|
+
if (_optionalChain([queryData, 'optionalAccess', _587 => _587.sx])) {
|
|
4934
|
+
ordertmp.push([queryData.sx, _optionalChain([queryData, 'optionalAccess', _588 => _588.sxty]) == 1 ? "DESC" : "ASC"]);
|
|
4856
4935
|
}
|
|
4857
4936
|
return ordertmp;
|
|
4858
4937
|
}
|
|
4859
4938
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqorder, "reqorder");
|
|
4860
4939
|
function reqlimit(queryData) {
|
|
4861
4940
|
let limittmp = "";
|
|
4862
|
-
let limitps = _optionalChain([queryData, 'optionalAccess',
|
|
4863
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4941
|
+
let limitps = _optionalChain([queryData, 'optionalAccess', _589 => _589.ps]);
|
|
4942
|
+
if (_optionalChain([queryData, 'optionalAccess', _590 => _590.pg])) {
|
|
4864
4943
|
limitps = limitps || 20;
|
|
4865
4944
|
limittmp = `${(queryData.pg - 1) * limitps},${limitps}`;
|
|
4866
4945
|
} else if (limitps) {
|
|
@@ -4872,7 +4951,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4872
4951
|
function decodePathSegment(seg) {
|
|
4873
4952
|
try {
|
|
4874
4953
|
return decodeURIComponent(seg);
|
|
4875
|
-
} catch (
|
|
4954
|
+
} catch (e45) {
|
|
4876
4955
|
return seg;
|
|
4877
4956
|
}
|
|
4878
4957
|
}
|
|
@@ -4888,7 +4967,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4888
4967
|
if (typeof body === "string") {
|
|
4889
4968
|
try {
|
|
4890
4969
|
body = JSON.parse(body);
|
|
4891
|
-
} catch (
|
|
4970
|
+
} catch (e46) {
|
|
4892
4971
|
return { content: body };
|
|
4893
4972
|
}
|
|
4894
4973
|
}
|
|
@@ -4913,8 +4992,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4913
4992
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, fileKeyFromSegment, "fileKeyFromSegment");
|
|
4914
4993
|
function getSqlParamsByUrl(req, opt) {
|
|
4915
4994
|
let tmpSqlParams;
|
|
4916
|
-
const reqArr = _optionalChain([req, 'optionalAccess',
|
|
4917
|
-
const table = (_optionalChain([opt, 'optionalAccess',
|
|
4995
|
+
const reqArr = _optionalChain([req, 'optionalAccess', _591 => _591.url, 'optionalAccess', _592 => _592.split, 'call', _593 => _593("?"), 'access', _594 => _594[0], 'optionalAccess', _595 => _595.split, 'call', _596 => _596("/")]) || [];
|
|
4996
|
+
const table = (_optionalChain([opt, 'optionalAccess', _597 => _597.qrdata, 'optionalAccess', _598 => _598.table]) || _optionalChain([opt, 'optionalAccess', _599 => _599.data, 'optionalAccess', _600 => _600.table]) || reqArr[3]).replaceAll("_", "/");
|
|
4918
4997
|
if (!table) return tmpSqlParams;
|
|
4919
4998
|
tmpSqlParams = {
|
|
4920
4999
|
type: "select",
|
|
@@ -4923,7 +5002,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4923
5002
|
if (reqArr[5]) {
|
|
4924
5003
|
if (reqArr[4] === "insert") {
|
|
4925
5004
|
tmpSqlParams.type = reqArr[4];
|
|
4926
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5005
|
+
if (_optionalChain([cfg, 'optionalAccess', _601 => _601.type]) === "file") {
|
|
4927
5006
|
const { name: bodyName, content } = parseFileBody(opt.data);
|
|
4928
5007
|
const fileKey = fileKeyFromSegment(reqArr[5], bodyName);
|
|
4929
5008
|
tmpSqlParams.field = cfg.field.data;
|
|
@@ -4947,11 +5026,11 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4947
5026
|
}
|
|
4948
5027
|
} else if (reqArr[4] === "update") {
|
|
4949
5028
|
tmpSqlParams.type = reqArr[4];
|
|
4950
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
5029
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _602 => _602.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4951
5030
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4952
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5031
|
+
if (_optionalChain([cfg, 'optionalAccess', _603 => _603.type]) === "file") {
|
|
4953
5032
|
const { content } = parseFileBody(opt.data);
|
|
4954
|
-
const contentField = _optionalChain([cfg, 'access',
|
|
5033
|
+
const contentField = _optionalChain([cfg, 'access', _604 => _604.field, 'access', _605 => _605.data, 'optionalAccess', _606 => _606[1]]) || "content";
|
|
4955
5034
|
tmpSqlParams.set = [[contentField, fileContentString(content)]];
|
|
4956
5035
|
} else {
|
|
4957
5036
|
tmpSqlParams.set = [];
|
|
@@ -4968,18 +5047,18 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4968
5047
|
}
|
|
4969
5048
|
} else if (reqArr[4] === "delete") {
|
|
4970
5049
|
tmpSqlParams.type = reqArr[4];
|
|
4971
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
5050
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _607 => _607.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4972
5051
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4973
5052
|
} else {
|
|
4974
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5053
|
+
if (_optionalChain([cfg, 'optionalAccess', _608 => _608.as]) > 1) {
|
|
4975
5054
|
tmpSqlParams.as = +cfg.as - 1;
|
|
4976
5055
|
}
|
|
4977
5056
|
tmpSqlParams.field = cfg.field.data;
|
|
4978
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
5057
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _609 => _609.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4979
5058
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4980
5059
|
}
|
|
4981
5060
|
} else {
|
|
4982
|
-
tmpSqlParams.as = _optionalChain([cfg, 'optionalAccess',
|
|
5061
|
+
tmpSqlParams.as = _optionalChain([cfg, 'optionalAccess', _610 => _610.as]);
|
|
4983
5062
|
tmpSqlParams.field = reqfield(opt.data);
|
|
4984
5063
|
tmpSqlParams.where = reqwhere(opt.data);
|
|
4985
5064
|
tmpSqlParams.order = reqorder(opt.data);
|
|
@@ -4989,8 +5068,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4989
5068
|
}
|
|
4990
5069
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSqlParamsByUrl, "getSqlParamsByUrl");
|
|
4991
5070
|
function dbFresh(req, resdb) {
|
|
4992
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
4993
|
-
const list = Array.isArray(resdb) ? resdb : _optionalChain([resdb, 'optionalAccess',
|
|
5071
|
+
if (_optionalChain([req, 'optionalAccess', _611 => _611.url, 'optionalAccess', _612 => _612.includes, 'call', _613 => _613("/selectlist/")])) {
|
|
5072
|
+
const list = Array.isArray(resdb) ? resdb : _optionalChain([resdb, 'optionalAccess', _614 => _614.data]);
|
|
4994
5073
|
if (Array.isArray(list)) {
|
|
4995
5074
|
const names = list.map((el) => {
|
|
4996
5075
|
if (typeof el === "string") {
|
|
@@ -5012,8 +5091,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5012
5091
|
}
|
|
5013
5092
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, dbFresh, "dbFresh");
|
|
5014
5093
|
function normalizeFileSelectRow(row) {
|
|
5015
|
-
const nameKey = _optionalChain([cfg, 'access',
|
|
5016
|
-
const contentKey = _optionalChain([cfg, 'access',
|
|
5094
|
+
const nameKey = _optionalChain([cfg, 'access', _615 => _615.field, 'optionalAccess', _616 => _616.data, 'optionalAccess', _617 => _617[0]]) || "name";
|
|
5095
|
+
const contentKey = _optionalChain([cfg, 'access', _618 => _618.field, 'optionalAccess', _619 => _619.data, 'optionalAccess', _620 => _620[1]]) || "content";
|
|
5017
5096
|
if (!row || typeof row !== "object") return row;
|
|
5018
5097
|
const out = { ...row };
|
|
5019
5098
|
if (out[nameKey] != null) {
|
|
@@ -5027,7 +5106,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5027
5106
|
}
|
|
5028
5107
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, normalizeFileSelectRow, "normalizeFileSelectRow");
|
|
5029
5108
|
function isFileSingleNameSelect(params) {
|
|
5030
|
-
return _optionalChain([cfg, 'optionalAccess',
|
|
5109
|
+
return _optionalChain([cfg, 'optionalAccess', _621 => _621.type]) === "file" && _optionalChain([params, 'optionalAccess', _622 => _622.type]) === "select" && !!_optionalChain([params, 'optionalAccess', _623 => _623.where, 'optionalAccess', _624 => _624.length]);
|
|
5031
5110
|
}
|
|
5032
5111
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isFileSingleNameSelect, "isFileSingleNameSelect");
|
|
5033
5112
|
function normalizeSelectResult(params, resdb) {
|
|
@@ -5041,12 +5120,12 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5041
5120
|
}
|
|
5042
5121
|
return data;
|
|
5043
5122
|
}
|
|
5044
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5123
|
+
if (_optionalChain([params, 'optionalAccess', _625 => _625.where, 'optionalAccess', _626 => _626.length]) && Array.isArray(data) && data.length === 1) {
|
|
5045
5124
|
data = data[0];
|
|
5046
5125
|
}
|
|
5047
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5048
|
-
const nameKey = _optionalChain([cfg, 'access',
|
|
5049
|
-
const contentKey = _optionalChain([cfg, 'access',
|
|
5126
|
+
if (_optionalChain([cfg, 'optionalAccess', _627 => _627.type]) === "file" && data && typeof data === "object" && !Array.isArray(data)) {
|
|
5127
|
+
const nameKey = _optionalChain([cfg, 'access', _628 => _628.field, 'optionalAccess', _629 => _629.data, 'optionalAccess', _630 => _630[0]]) || "name";
|
|
5128
|
+
const contentKey = _optionalChain([cfg, 'access', _631 => _631.field, 'optionalAccess', _632 => _632.data, 'optionalAccess', _633 => _633[1]]) || "content";
|
|
5050
5129
|
if (data[nameKey] != null) {
|
|
5051
5130
|
data[nameKey] = bareFileName(String(data[nameKey]));
|
|
5052
5131
|
}
|
|
@@ -5056,7 +5135,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5056
5135
|
if (text.startsWith("{") || text.startsWith("[")) {
|
|
5057
5136
|
try {
|
|
5058
5137
|
data[contentKey] = JSON.parse(text);
|
|
5059
|
-
} catch (
|
|
5138
|
+
} catch (e47) {
|
|
5060
5139
|
}
|
|
5061
5140
|
}
|
|
5062
5141
|
}
|
|
@@ -5065,7 +5144,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5065
5144
|
}
|
|
5066
5145
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, normalizeSelectResult, "normalizeSelectResult");
|
|
5067
5146
|
function dbCodePm(req, resdb) {
|
|
5068
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
5147
|
+
if (_optionalChain([req, 'optionalAccess', _634 => _634.Userinfo]) && _optionalChain([req, 'optionalAccess', _635 => _635.Userinfo, 'access', _636 => _636[2]])) {
|
|
5069
5148
|
if (resdb != null && typeof resdb === "object") {
|
|
5070
5149
|
resdb.data = $asai.$lib.AsCode.asencode(JSON.stringify(resdb.data), req.Userinfo[2]);
|
|
5071
5150
|
}
|
|
@@ -5079,8 +5158,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5079
5158
|
DataServer.sqlDb(params).then((resdb) => {
|
|
5080
5159
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess(dbCodePm(req, dbFresh(req, resdb)), opt)));
|
|
5081
5160
|
}).catch((errdb) => {
|
|
5082
|
-
const msg = String(_optionalChain([errdb, 'optionalAccess',
|
|
5083
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5161
|
+
const msg = String(_optionalChain([errdb, 'optionalAccess', _637 => _637.message]) || errdb || "");
|
|
5162
|
+
if (_optionalChain([params, 'optionalAccess', _638 => _638.type]) === "select" && msg.includes("no such table")) {
|
|
5084
5163
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess([], opt)));
|
|
5085
5164
|
return;
|
|
5086
5165
|
}
|
|
@@ -5097,29 +5176,29 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5097
5176
|
try {
|
|
5098
5177
|
DataServer.sqlDb(params).then((resdb) => {
|
|
5099
5178
|
let resData = normalizeSelectResult(params, dbFresh(req, resdb));
|
|
5100
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5179
|
+
if (_optionalChain([params, 'optionalAccess', _639 => _639.as]) === 2 && _optionalChain([params, 'optionalAccess', _640 => _640.field, 'optionalAccess', _641 => _641.length]) > 1) {
|
|
5101
5180
|
let limitArr = [];
|
|
5102
|
-
if (_optionalChain([params, 'access',
|
|
5103
|
-
limitArr = [0, +_optionalChain([params, 'access',
|
|
5181
|
+
if (_optionalChain([params, 'access', _642 => _642.limit, 'optionalAccess', _643 => _643.split, 'call', _644 => _644(","), 'optionalAccess', _645 => _645.length]) < 2) {
|
|
5182
|
+
limitArr = [0, +_optionalChain([params, 'access', _646 => _646.limit, 'optionalAccess', _647 => _647.split, 'call', _648 => _648(","), 'optionalAccess', _649 => _649[0]])];
|
|
5104
5183
|
} else {
|
|
5105
5184
|
limitArr = params.limit.split(",");
|
|
5106
5185
|
limitArr = [+limitArr[0], +limitArr[0] + +limitArr[1]];
|
|
5107
5186
|
}
|
|
5108
|
-
if (_optionalChain([resData, 'access',
|
|
5187
|
+
if (_optionalChain([resData, 'access', _650 => _650.data, 'optionalAccess', _651 => _651.length])) {
|
|
5109
5188
|
resData.data = resData.data.slice(+limitArr[0], +limitArr[1]);
|
|
5110
5189
|
}
|
|
5111
5190
|
}
|
|
5112
5191
|
resData = dbCodePm(req, resData);
|
|
5113
5192
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess(resData, opt)));
|
|
5114
5193
|
}).catch((errdb) => {
|
|
5115
|
-
const msg = String(_optionalChain([errdb, 'optionalAccess',
|
|
5116
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5194
|
+
const msg = String(_optionalChain([errdb, 'optionalAccess', _652 => _652.message]) || errdb || "");
|
|
5195
|
+
if (_optionalChain([params, 'optionalAccess', _653 => _653.type]) === "select" && msg.includes("no such table")) {
|
|
5117
5196
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess([], opt)));
|
|
5118
5197
|
return;
|
|
5119
5198
|
}
|
|
5120
5199
|
res.end(JSON.stringify($asai.$lib.As.ctxFail(errdb)));
|
|
5121
5200
|
});
|
|
5122
|
-
} catch (
|
|
5201
|
+
} catch (e48) {
|
|
5123
5202
|
res.end(JSON.stringify({ code: 901 }));
|
|
5124
5203
|
}
|
|
5125
5204
|
} else {
|
|
@@ -5128,7 +5207,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5128
5207
|
}
|
|
5129
5208
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, runDefaultGet, "runDefaultGet");
|
|
5130
5209
|
function post(req, res, hostdir, opt) {
|
|
5131
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5210
|
+
if (_optionalChain([cfg, 'optionalAccess', _654 => _654.post]) && typeof cfg.post === "function") {
|
|
5132
5211
|
Promise.resolve(cfg.post(req, res, hostdir, opt, DataServer)).then((reqstat) => {
|
|
5133
5212
|
if (!reqstat) runDefaultPost(req, res, opt);
|
|
5134
5213
|
}).catch((errdb) => {
|
|
@@ -5140,7 +5219,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5140
5219
|
}
|
|
5141
5220
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, post, "post");
|
|
5142
5221
|
function get(req, res, hostdir, opt) {
|
|
5143
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5222
|
+
if (_optionalChain([cfg, 'optionalAccess', _655 => _655.get]) && typeof cfg.get === "function") {
|
|
5144
5223
|
Promise.resolve(cfg.get(req, res, hostdir, opt, DataServer)).then((reqstat) => {
|
|
5145
5224
|
if (!reqstat) runDefaultGet(req, res, opt);
|
|
5146
5225
|
}).catch((errdb) => {
|
|
@@ -5166,7 +5245,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5166
5245
|
}
|
|
5167
5246
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hostDefault2, "hostDefault");
|
|
5168
5247
|
function getPathFromOpt(opt) {
|
|
5169
|
-
const rawPath = _optionalChain([opt, 'access',
|
|
5248
|
+
const rawPath = _optionalChain([opt, 'access', _656 => _656.qrdata, 'optionalAccess', _657 => _657.path]) || _optionalChain([opt, 'access', _658 => _658.data, 'optionalAccess', _659 => _659.path]);
|
|
5170
5249
|
if (!rawPath) {
|
|
5171
5250
|
throw new Error("Missing path");
|
|
5172
5251
|
}
|
|
@@ -5175,7 +5254,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5175
5254
|
return path4.normalize(decoded);
|
|
5176
5255
|
}
|
|
5177
5256
|
const rel = decoded.replace(/^\.(\/)?/, "");
|
|
5178
|
-
const serverRoot = _optionalChain([$asai, 'optionalAccess',
|
|
5257
|
+
const serverRoot = _optionalChain([$asai, 'optionalAccess', _660 => _660.serverRoot]);
|
|
5179
5258
|
if (serverRoot && rel) {
|
|
5180
5259
|
const absRoot = path4.resolve(serverRoot);
|
|
5181
5260
|
const abs = path4.resolve(absRoot, rel);
|
|
@@ -5184,12 +5263,12 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5184
5263
|
return abs;
|
|
5185
5264
|
}
|
|
5186
5265
|
}
|
|
5187
|
-
const roots = _optionalChain([$asai, 'optionalAccess',
|
|
5266
|
+
const roots = _optionalChain([$asai, 'optionalAccess', _661 => _661.asaihost, 'optionalAccess', _662 => _662.getHostAllowedRoots, 'optionalCall', _663 => _663(_optionalChain([$asai, 'optionalAccess', _664 => _664.hostconfig]))]) || [];
|
|
5188
5267
|
if (!roots.length) {
|
|
5189
|
-
const fallback = _optionalChain([$asai, 'optionalAccess',
|
|
5268
|
+
const fallback = _optionalChain([$asai, 'optionalAccess', _665 => _665.serverRoot]) || process.cwd();
|
|
5190
5269
|
if (fallback) roots.push(fallback);
|
|
5191
5270
|
}
|
|
5192
|
-
if (!_optionalChain([$asai, 'optionalAccess',
|
|
5271
|
+
if (!_optionalChain([$asai, 'optionalAccess', _666 => _666.asaihost, 'optionalAccess', _667 => _667.resolvePathUnderRoots])) {
|
|
5193
5272
|
throw new Error("Path resolver unavailable");
|
|
5194
5273
|
}
|
|
5195
5274
|
return $asai.asaihost.resolvePathUnderRoots(decoded, roots);
|
|
@@ -5201,18 +5280,18 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5201
5280
|
}
|
|
5202
5281
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendSuccess, "sendSuccess");
|
|
5203
5282
|
function sendErr(res, ec, params, opt) {
|
|
5204
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5205
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5206
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5283
|
+
const ErrorCode = _optionalChain([$asai, 'access', _668 => _668.$lib, 'optionalAccess', _669 => _669.ErrorCode]);
|
|
5284
|
+
_optionalChain([ErrorCode, 'optionalAccess', _670 => _670.loadErrorCodes, 'optionalCall', _671 => _671($asai)]);
|
|
5285
|
+
_optionalChain([ErrorCode, 'optionalAccess', _672 => _672.logError, 'optionalCall', _673 => _673($asai, ec, Array.isArray(params) ? params.map(String) : params != null ? [String(params)] : void 0)]);
|
|
5207
5286
|
const response = $asai.$lib.As.ctxErr(ec, params, opt);
|
|
5208
5287
|
res.end(JSON.stringify(response));
|
|
5209
5288
|
}
|
|
5210
5289
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendErr, "sendErr");
|
|
5211
5290
|
function sendFail(res, err, opt) {
|
|
5212
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5213
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5214
|
-
const normalized = _optionalChain([ErrorCode, 'optionalAccess',
|
|
5215
|
-
if (_optionalChain([normalized, 'optionalAccess',
|
|
5291
|
+
const ErrorCode = _optionalChain([$asai, 'access', _674 => _674.$lib, 'optionalAccess', _675 => _675.ErrorCode]);
|
|
5292
|
+
_optionalChain([ErrorCode, 'optionalAccess', _676 => _676.loadErrorCodes, 'optionalCall', _677 => _677($asai)]);
|
|
5293
|
+
const normalized = _optionalChain([ErrorCode, 'optionalAccess', _678 => _678.normalizeErrPayload, 'optionalCall', _679 => _679(err)]);
|
|
5294
|
+
if (_optionalChain([normalized, 'optionalAccess', _680 => _680.ec])) {
|
|
5216
5295
|
return sendErr(res, normalized.ec, normalized.pm, opt);
|
|
5217
5296
|
}
|
|
5218
5297
|
const response = $asai.$lib.As.ctxFail(err);
|
|
@@ -5220,7 +5299,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5220
5299
|
}
|
|
5221
5300
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendFail, "sendFail");
|
|
5222
5301
|
function mnLog(...arg) {
|
|
5223
|
-
(_optionalChain([$asai, 'optionalAccess',
|
|
5302
|
+
(_optionalChain([$asai, 'optionalAccess', _681 => _681.$log]) || console.log)(...arg);
|
|
5224
5303
|
}
|
|
5225
5304
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mnLog, "mnLog");
|
|
5226
5305
|
return { hostDefault: hostDefault2, getPathFromOpt, sendSuccess, sendFail, sendErr, mnLog };
|
|
@@ -5253,7 +5332,7 @@ async function pathExists(filePath) {
|
|
|
5253
5332
|
try {
|
|
5254
5333
|
await _promises2.default.access(nodePath2.default.normalize(filePath));
|
|
5255
5334
|
return true;
|
|
5256
|
-
} catch (
|
|
5335
|
+
} catch (e49) {
|
|
5257
5336
|
return false;
|
|
5258
5337
|
}
|
|
5259
5338
|
}
|
|
@@ -5320,7 +5399,7 @@ async function removeFile(filePath) {
|
|
|
5320
5399
|
try {
|
|
5321
5400
|
await _promises2.default.unlink(nodePath2.default.normalize(filePath));
|
|
5322
5401
|
} catch (err) {
|
|
5323
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
5402
|
+
if (_optionalChain([err, 'optionalAccess', _682 => _682.code]) !== "ENOENT") throw err;
|
|
5324
5403
|
}
|
|
5325
5404
|
}
|
|
5326
5405
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, removeFile, "removeFile");
|
|
@@ -5632,11 +5711,11 @@ function dbDriver(opt = {}) {
|
|
|
5632
5711
|
this.fileExt = config.ext === ".*" ? "" : config.ext || "";
|
|
5633
5712
|
this.fileDel = (config.del || 0) !== 0;
|
|
5634
5713
|
this.createDir = config.create || false;
|
|
5635
|
-
const root = _optionalChain([config, 'access',
|
|
5714
|
+
const root = _optionalChain([config, 'access', _683 => _683.$asai, 'optionalAccess', _684 => _684.serverRoot]) || _chunkHR5JKN7Ycjs.getPrimaryServerRoot.call(void 0, );
|
|
5636
5715
|
this.baseDirAbs = path7.resolve(root, config.dir);
|
|
5637
5716
|
}
|
|
5638
5717
|
dbLog(...args) {
|
|
5639
|
-
(_optionalChain([this, 'access',
|
|
5718
|
+
(_optionalChain([this, 'access', _685 => _685.config, 'optionalAccess', _686 => _686.$asai, 'optionalAccess', _687 => _687.$log]) || console.log)("FILE", ...args);
|
|
5640
5719
|
}
|
|
5641
5720
|
checkFile(file) {
|
|
5642
5721
|
return fs10.existsSync(this.getAbsPath(file, false));
|
|
@@ -5702,7 +5781,7 @@ function dbDriver(opt = {}) {
|
|
|
5702
5781
|
}
|
|
5703
5782
|
getReadPath(file, sql) {
|
|
5704
5783
|
const candidates = [];
|
|
5705
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5784
|
+
if (_optionalChain([sql, 'optionalAccess', _688 => _688.filename])) {
|
|
5706
5785
|
candidates.push({ dir: path7.join(file, sql.filename) });
|
|
5707
5786
|
candidates.push({ dir: path7.join(file + ".delete" + this.fileExt, sql.filename) });
|
|
5708
5787
|
} else {
|
|
@@ -5722,20 +5801,20 @@ function dbDriver(opt = {}) {
|
|
|
5722
5801
|
if (!read2.path) {
|
|
5723
5802
|
return { path: "", dir: read2.dir };
|
|
5724
5803
|
}
|
|
5725
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5804
|
+
if (_optionalChain([sql, 'optionalAccess', _689 => _689.filename])) {
|
|
5726
5805
|
return { path: path7.dirname(read2.path), dir: path7.dirname(read2.dir) };
|
|
5727
5806
|
}
|
|
5728
5807
|
return { path: read2.path, dir: read2.dir };
|
|
5729
5808
|
}
|
|
5730
5809
|
getNewPath(file, sql) {
|
|
5731
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5810
|
+
if (_optionalChain([sql, 'optionalAccess', _690 => _690.filename])) {
|
|
5732
5811
|
return this.getAbsPath(path7.join(file, sql.filename), true);
|
|
5733
5812
|
}
|
|
5734
5813
|
return this.getAbsPath(file, true);
|
|
5735
5814
|
}
|
|
5736
5815
|
write(file, data, sql) {
|
|
5737
5816
|
try {
|
|
5738
|
-
const filePath = _optionalChain([sql, 'optionalAccess',
|
|
5817
|
+
const filePath = _optionalChain([sql, 'optionalAccess', _691 => _691.type]) === "insert" ? this.getNewPath(file, sql) : this.getReadPath(file, sql).path || this.getNewPath(file, sql);
|
|
5739
5818
|
this.dbLog("write", "[WRITE]", filePath);
|
|
5740
5819
|
fs10.writeFileSync(filePath, data, "utf8");
|
|
5741
5820
|
return "ok";
|
|
@@ -5765,11 +5844,11 @@ function dbDriver(opt = {}) {
|
|
|
5765
5844
|
if (!del.path) {
|
|
5766
5845
|
return "";
|
|
5767
5846
|
}
|
|
5768
|
-
if (this.fileDel && _optionalChain([sql, 'optionalAccess',
|
|
5847
|
+
if (this.fileDel && _optionalChain([sql, 'optionalAccess', _692 => _692.deltrue])) {
|
|
5769
5848
|
const target = del.path + ".delete" + this.fileExt;
|
|
5770
5849
|
this.dbLog("soft delete", "[SOFT DELETE]", `${del.path} -> ${target}`);
|
|
5771
5850
|
fs10.renameSync(del.path, target);
|
|
5772
|
-
} else if (_optionalChain([sql, 'optionalAccess',
|
|
5851
|
+
} else if (_optionalChain([sql, 'optionalAccess', _693 => _693.filename])) {
|
|
5773
5852
|
this.deldir(del.dir);
|
|
5774
5853
|
} else {
|
|
5775
5854
|
this.dbLog("delete", "[DELETE]", del.path);
|
|
@@ -5811,8 +5890,8 @@ function dbDriver(opt = {}) {
|
|
|
5811
5890
|
let entries;
|
|
5812
5891
|
try {
|
|
5813
5892
|
entries = fs10.readdirSync(absDir, { withFileTypes: true });
|
|
5814
|
-
} catch (
|
|
5815
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
5893
|
+
} catch (e50) {
|
|
5894
|
+
return _optionalChain([sql, 'optionalAccess', _694 => _694.list]) ? { open: [], delete: [] } : [];
|
|
5816
5895
|
}
|
|
5817
5896
|
const result = { open: [], delete: [] };
|
|
5818
5897
|
const deleteSuffix = ".delete" + this.fileExt;
|
|
@@ -5827,14 +5906,14 @@ function dbDriver(opt = {}) {
|
|
|
5827
5906
|
const data = fs10.readFileSync(fullPath, "utf8");
|
|
5828
5907
|
const entryData = { data, file: baseName };
|
|
5829
5908
|
if (isDelete) {
|
|
5830
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5909
|
+
if (_optionalChain([sql, 'optionalAccess', _695 => _695.list])) result.delete.push(entryData);
|
|
5831
5910
|
} else {
|
|
5832
5911
|
result.open.push(entryData);
|
|
5833
5912
|
}
|
|
5834
|
-
} catch (
|
|
5913
|
+
} catch (e51) {
|
|
5835
5914
|
}
|
|
5836
5915
|
}
|
|
5837
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
5916
|
+
return _optionalChain([sql, 'optionalAccess', _696 => _696.list]) ? result : result.open;
|
|
5838
5917
|
} catch (e) {
|
|
5839
5918
|
this.dbLog("list failed", "[LIST ERROR]", e);
|
|
5840
5919
|
return e;
|
|
@@ -5844,7 +5923,7 @@ function dbDriver(opt = {}) {
|
|
|
5844
5923
|
getFileNameFromWhere(where) {
|
|
5845
5924
|
if (!where || !Array.isArray(where)) return "";
|
|
5846
5925
|
const first = where.find((item) => Array.isArray(item));
|
|
5847
|
-
const raw = _optionalChain([first, 'optionalAccess',
|
|
5926
|
+
const raw = _optionalChain([first, 'optionalAccess', _697 => _697[2]]);
|
|
5848
5927
|
if (typeof raw === "string") {
|
|
5849
5928
|
return raw.replace(/^'+|'+$/g, "");
|
|
5850
5929
|
}
|
|
@@ -5869,22 +5948,22 @@ function dbDriver(opt = {}) {
|
|
|
5869
5948
|
const data = sql.set[0][1];
|
|
5870
5949
|
result = this.write(this.tableFilePath(sql.table, file), data, sql);
|
|
5871
5950
|
} else if (sql.type === "select") {
|
|
5872
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5951
|
+
if (_optionalChain([sql, 'optionalAccess', _698 => _698.where, 'optionalAccess', _699 => _699.length]) && _optionalChain([sql, 'optionalAccess', _700 => _700.as]) !== 2) {
|
|
5873
5952
|
const file = this.getFileNameFromWhere(sql.where);
|
|
5874
5953
|
const readRes = this.read(this.tableFilePath(sql.table, file), sql);
|
|
5875
5954
|
const resObj = {};
|
|
5876
|
-
if (_optionalChain([readRes, 'optionalAccess',
|
|
5955
|
+
if (_optionalChain([readRes, 'optionalAccess', _701 => _701[0], 'optionalAccess', _702 => _702.file]) && !readRes.error) {
|
|
5877
5956
|
if (sql.as === 1) {
|
|
5878
5957
|
try {
|
|
5879
5958
|
const parsed = JSON.parse(readRes[0].data);
|
|
5880
|
-
if (_optionalChain([sql, 'access',
|
|
5959
|
+
if (_optionalChain([sql, 'access', _703 => _703.field, 'optionalAccess', _704 => _704.length])) {
|
|
5881
5960
|
sql.field.forEach((f) => {
|
|
5882
5961
|
resObj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
5883
5962
|
});
|
|
5884
5963
|
} else {
|
|
5885
5964
|
Object.assign(resObj, parsed);
|
|
5886
5965
|
}
|
|
5887
|
-
} catch (
|
|
5966
|
+
} catch (e52) {
|
|
5888
5967
|
}
|
|
5889
5968
|
} else {
|
|
5890
5969
|
const fields = sql.field;
|
|
@@ -5898,7 +5977,7 @@ function dbDriver(opt = {}) {
|
|
|
5898
5977
|
} else {
|
|
5899
5978
|
const listRes = this.list(tableDir, sql);
|
|
5900
5979
|
if (listRes && !listRes.error) {
|
|
5901
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5980
|
+
if (_optionalChain([sql, 'optionalAccess', _705 => _705.list])) {
|
|
5902
5981
|
const mapEntry = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (el) => {
|
|
5903
5982
|
const fields = sql.field;
|
|
5904
5983
|
const item = { [fields[0]]: el.file };
|
|
@@ -5909,9 +5988,9 @@ function dbDriver(opt = {}) {
|
|
|
5909
5988
|
if (listRes.delete) listRes.delete = listRes.delete.map(mapEntry);
|
|
5910
5989
|
result = listRes;
|
|
5911
5990
|
} else {
|
|
5912
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5991
|
+
if (_optionalChain([sql, 'optionalAccess', _706 => _706.as]) === 2) {
|
|
5913
5992
|
let items = listRes;
|
|
5914
|
-
if (_optionalChain([sql, 'access',
|
|
5993
|
+
if (_optionalChain([sql, 'access', _707 => _707.where, 'optionalAccess', _708 => _708.length])) {
|
|
5915
5994
|
const where = sql.where;
|
|
5916
5995
|
const whereType = typeof where[0] === "string" ? where[0] : "and";
|
|
5917
5996
|
items = items.filter((el) => {
|
|
@@ -5925,7 +6004,7 @@ function dbDriver(opt = {}) {
|
|
|
5925
6004
|
let fieldVal = "";
|
|
5926
6005
|
try {
|
|
5927
6006
|
fieldVal = _nullishCoalesce(JSON.parse(el.data)[field], () => ( ""));
|
|
5928
|
-
} catch (
|
|
6007
|
+
} catch (e53) {
|
|
5929
6008
|
}
|
|
5930
6009
|
const condMatch = String(fieldVal).includes(searchVal);
|
|
5931
6010
|
if (whereType === "and") {
|
|
@@ -5943,18 +6022,18 @@ function dbDriver(opt = {}) {
|
|
|
5943
6022
|
const obj = {};
|
|
5944
6023
|
try {
|
|
5945
6024
|
const parsed = JSON.parse(el.data);
|
|
5946
|
-
if (_optionalChain([sql, 'access',
|
|
6025
|
+
if (_optionalChain([sql, 'access', _709 => _709.field, 'optionalAccess', _710 => _710.length])) {
|
|
5947
6026
|
sql.field.forEach((f) => {
|
|
5948
6027
|
obj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
5949
6028
|
});
|
|
5950
6029
|
} else {
|
|
5951
6030
|
Object.assign(obj, parsed);
|
|
5952
6031
|
}
|
|
5953
|
-
} catch (
|
|
6032
|
+
} catch (e54) {
|
|
5954
6033
|
}
|
|
5955
6034
|
return obj;
|
|
5956
6035
|
});
|
|
5957
|
-
if (_optionalChain([sql, 'access',
|
|
6036
|
+
if (_optionalChain([sql, 'access', _711 => _711.order, 'optionalAccess', _712 => _712.length])) {
|
|
5958
6037
|
const orderField = sql.order[0];
|
|
5959
6038
|
const orderFieldName = typeof orderField === "string" ? orderField : orderField[0];
|
|
5960
6039
|
const direction = typeof orderField === "string" ? "ASC" : String(orderField[1]).toUpperCase();
|
|
@@ -5975,7 +6054,7 @@ function dbDriver(opt = {}) {
|
|
|
5975
6054
|
}
|
|
5976
6055
|
}
|
|
5977
6056
|
} else {
|
|
5978
|
-
result = _optionalChain([sql, 'optionalAccess',
|
|
6057
|
+
result = _optionalChain([sql, 'optionalAccess', _713 => _713.list]) ? { open: [], delete: [] } : [];
|
|
5979
6058
|
}
|
|
5980
6059
|
}
|
|
5981
6060
|
}
|
|
@@ -6031,7 +6110,7 @@ function sysserver($asai, opt = {}) {
|
|
|
6031
6110
|
if (!$asai.$lib) $asai.$lib = {};
|
|
6032
6111
|
$asai.$lib = { ...lib_default, ...$asai.$lib, ...opt || {} };
|
|
6033
6112
|
$asai.dataserver = db_default;
|
|
6034
|
-
_optionalChain([$asai, 'access',
|
|
6113
|
+
_optionalChain([$asai, 'access', _714 => _714.$lib, 'access', _715 => _715.ErrorCode, 'optionalAccess', _716 => _716.loadErrorCodes, 'optionalCall', _717 => _717($asai)]);
|
|
6035
6114
|
if (!$asai.$lib.api) $asai.$lib.api = {};
|
|
6036
6115
|
$asai.$lib.api = { ...api_default, ...$asai.$lib.api };
|
|
6037
6116
|
if (!$asai.$lib.ws) $asai.$lib.ws = {};
|
|
@@ -6224,7 +6303,7 @@ function normalizeDataStoresConfig(cfg) {
|
|
|
6224
6303
|
}
|
|
6225
6304
|
if (userStore.opt.create == null) userStore.opt.create = 1;
|
|
6226
6305
|
}
|
|
6227
|
-
if (!stores.log && _optionalChain([cfg, 'access',
|
|
6306
|
+
if (!stores.log && _optionalChain([cfg, 'access', _718 => _718.logger, 'optionalAccess', _719 => _719.store])) {
|
|
6228
6307
|
const s = cfg.logger.store;
|
|
6229
6308
|
stores.log = {
|
|
6230
6309
|
type: s.type || "file",
|
|
@@ -6288,13 +6367,13 @@ function validateHostConfig(cfg) {
|
|
|
6288
6367
|
if (cfg.asaisn != null) {
|
|
6289
6368
|
errors.push("asaisn \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_ASAISN");
|
|
6290
6369
|
}
|
|
6291
|
-
if (_optionalChain([cfg, 'access',
|
|
6370
|
+
if (_optionalChain([cfg, 'access', _720 => _720.aes, 'optionalAccess', _721 => _721.keybase64]) != null) {
|
|
6292
6371
|
errors.push("aes.keybase64 \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_AES_KEYBASE64");
|
|
6293
6372
|
}
|
|
6294
|
-
if (_optionalChain([cfg, 'access',
|
|
6373
|
+
if (_optionalChain([cfg, 'access', _722 => _722.httpscert, 'optionalAccess', _723 => _723.key]) != null || _optionalChain([cfg, 'access', _724 => _724.httpscert, 'optionalAccess', _725 => _725.cert]) != null) {
|
|
6295
6374
|
errors.push("httpscert.key/cert \u7981\u6B62\u5185\u8054\u4E8E asaihost.json\uFF0C\u8BF7\u4F7F\u7528 keyPath/certPath \u6216\u73AF\u5883\u53D8\u91CF");
|
|
6296
6375
|
}
|
|
6297
|
-
if (_optionalChain([cfg, 'access',
|
|
6376
|
+
if (_optionalChain([cfg, 'access', _726 => _726.security, 'optionalAccess', _727 => _727.sessionSecret]) != null) {
|
|
6298
6377
|
errors.push("security.sessionSecret \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_SESSION_SECRET");
|
|
6299
6378
|
}
|
|
6300
6379
|
if (Array.isArray(cfg.wssec) && typeof cfg.wssec[0] === "string" && cfg.wssec[0].length > 0) {
|
|
@@ -6349,10 +6428,10 @@ function validateHostConfig(cfg) {
|
|
|
6349
6428
|
validateHostSiteLimits(name, h, errors);
|
|
6350
6429
|
}
|
|
6351
6430
|
}
|
|
6352
|
-
if (_optionalChain([cfg, 'access',
|
|
6431
|
+
if (_optionalChain([cfg, 'access', _728 => _728.logger, 'optionalAccess', _729 => _729.sample]) && typeof cfg.logger.sample !== "object") {
|
|
6353
6432
|
errors.push('logger.sample \u5FC5\u987B\u4E3A\u5BF9\u8C61\uFF08\u5982 { "REQ_OTHER": 0.1 }\uFF09');
|
|
6354
6433
|
}
|
|
6355
|
-
if (_optionalChain([cfg, 'access',
|
|
6434
|
+
if (_optionalChain([cfg, 'access', _730 => _730.logger, 'optionalAccess', _731 => _731.skip]) != null && !Array.isArray(cfg.logger.skip)) {
|
|
6356
6435
|
errors.push('logger.skip \u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5982 ["/sys/info/metrics"]\uFF09');
|
|
6357
6436
|
}
|
|
6358
6437
|
if (cfg.proxyhosts && typeof cfg.proxyhosts === "object") {
|
|
@@ -6386,7 +6465,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, validateHostSiteLimits, "validateHostSiteL
|
|
|
6386
6465
|
function validateProductionSecurity(cfg) {
|
|
6387
6466
|
const errors = [];
|
|
6388
6467
|
if (process.env.NODE_ENV !== "production") return errors;
|
|
6389
|
-
const sec = _optionalChain([cfg, 'optionalAccess',
|
|
6468
|
+
const sec = _optionalChain([cfg, 'optionalAccess', _732 => _732.security]);
|
|
6390
6469
|
if (!sec || typeof sec !== "object") {
|
|
6391
6470
|
errors.push("\u751F\u4EA7\u73AF\u5883\u5FC5\u987B\u914D\u7F6E security \u5BF9\u8C61");
|
|
6392
6471
|
return errors;
|
|
@@ -6397,7 +6476,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6397
6476
|
if (sec.allowRegister === 1) {
|
|
6398
6477
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.allowRegister \u5E94\u4E3A 0\uFF08CR 1.3 \u7981\u6B62\u5F00\u653E\u6CE8\u518C\uFF09");
|
|
6399
6478
|
}
|
|
6400
|
-
if (!_optionalChain([sec, 'access',
|
|
6479
|
+
if (!_optionalChain([sec, 'access', _733 => _733.quota, 'optionalAccess', _734 => _734.enabled])) {
|
|
6401
6480
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.quota.enabled \u5E94\u4E3A 1\uFF08CR 7.1 \u8D44\u6E90\u9650\u5236\uFF09");
|
|
6402
6481
|
}
|
|
6403
6482
|
if (sec.csp !== 1) {
|
|
@@ -6406,7 +6485,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6406
6485
|
if (typeof sec.minUserLevel !== "number" || sec.minUserLevel < 0) {
|
|
6407
6486
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.minUserLevel \u5E94\u663E\u5F0F\u914D\u7F6E");
|
|
6408
6487
|
}
|
|
6409
|
-
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess',
|
|
6488
|
+
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess', _735 => _735.httpscert, 'optionalAccess', _736 => _736.keyPath]) && !_optionalChain([cfg, 'optionalAccess', _737 => _737.httpscert, 'optionalAccess', _738 => _738.key])) {
|
|
6410
6489
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.forceWss=1 \u65F6\u9700\u914D\u7F6E HTTPS \u8BC1\u4E66");
|
|
6411
6490
|
}
|
|
6412
6491
|
return errors;
|
|
@@ -6425,12 +6504,12 @@ var DEFAULT_RECONNECT = {
|
|
|
6425
6504
|
rs485: { enabled: true, maxRetries: 60, initialDelay: 3e3, maxDelay: 3e4, factor: 2 }
|
|
6426
6505
|
};
|
|
6427
6506
|
function getTransportBlock(cfg, kind) {
|
|
6428
|
-
const block = _optionalChain([cfg, 'optionalAccess',
|
|
6507
|
+
const block = _optionalChain([cfg, 'optionalAccess', _739 => _739[kind]]);
|
|
6429
6508
|
return block && typeof block === "object" ? block : null;
|
|
6430
6509
|
}
|
|
6431
6510
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportBlock, "getTransportBlock");
|
|
6432
6511
|
function getTransportDefault(cfg, kind) {
|
|
6433
|
-
const def = _optionalChain([getTransportBlock, 'call',
|
|
6512
|
+
const def = _optionalChain([getTransportBlock, 'call', _740 => _740(cfg, kind), 'optionalAccess', _741 => _741.default]);
|
|
6434
6513
|
return def && typeof def === "object" ? def : null;
|
|
6435
6514
|
}
|
|
6436
6515
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportDefault, "getTransportDefault");
|
|
@@ -6440,7 +6519,7 @@ function hasTransportDefault(cfg, kind) {
|
|
|
6440
6519
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasTransportDefault, "hasTransportDefault");
|
|
6441
6520
|
function getDefaultConnId(cfg, kind) {
|
|
6442
6521
|
const def = getTransportDefault(cfg, kind);
|
|
6443
|
-
const id = _optionalChain([def, 'optionalAccess',
|
|
6522
|
+
const id = _optionalChain([def, 'optionalAccess', _742 => _742.id]);
|
|
6444
6523
|
return typeof id === "string" && id.length > 0 ? id : DEFAULT_CONN_ID[kind];
|
|
6445
6524
|
}
|
|
6446
6525
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getDefaultConnId, "getDefaultConnId");
|
|
@@ -6451,14 +6530,14 @@ function shouldAutoConnect(def) {
|
|
|
6451
6530
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, shouldAutoConnect, "shouldAutoConnect");
|
|
6452
6531
|
function resolveReconnectOptions(def, kind, cfg) {
|
|
6453
6532
|
const base = DEFAULT_RECONNECT[kind];
|
|
6454
|
-
const rc = _optionalChain([def, 'optionalAccess',
|
|
6455
|
-
const tmMaxTry = _optionalChain([cfg, 'optionalAccess',
|
|
6533
|
+
const rc = _optionalChain([def, 'optionalAccess', _743 => _743.reconnect]);
|
|
6534
|
+
const tmMaxTry = _optionalChain([cfg, 'optionalAccess', _744 => _744.tm, 'optionalAccess', _745 => _745.maxtry]);
|
|
6456
6535
|
return {
|
|
6457
|
-
enabled: _optionalChain([rc, 'optionalAccess',
|
|
6458
|
-
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6459
|
-
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6460
|
-
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6461
|
-
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6536
|
+
enabled: _optionalChain([rc, 'optionalAccess', _746 => _746.enabled]) !== false && base.enabled !== false,
|
|
6537
|
+
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _747 => _747.maxRetries]), () => ( tmMaxTry)), () => ( base.maxRetries)), () => ( 60)),
|
|
6538
|
+
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _748 => _748.initialDelay]), () => ( base.initialDelay)), () => ( 1e3)),
|
|
6539
|
+
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _749 => _749.maxDelay]), () => ( base.maxDelay)), () => ( 3e4)),
|
|
6540
|
+
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _750 => _750.factor]), () => ( base.factor)), () => ( 2))
|
|
6462
6541
|
};
|
|
6463
6542
|
}
|
|
6464
6543
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveReconnectOptions, "resolveReconnectOptions");
|
|
@@ -6508,17 +6587,17 @@ function createTransportDataHandler($asai, manager) {
|
|
|
6508
6587
|
if (typeof event.data === "string") {
|
|
6509
6588
|
try {
|
|
6510
6589
|
event.data = JSON.parse(event.data);
|
|
6511
|
-
} catch (
|
|
6590
|
+
} catch (e55) {
|
|
6512
6591
|
}
|
|
6513
6592
|
}
|
|
6514
|
-
if (_optionalChain([event, 'access',
|
|
6593
|
+
if (_optionalChain([event, 'access', _751 => _751.data, 'optionalAccess', _752 => _752.id])) {
|
|
6515
6594
|
manager.watch(event.id, event.data);
|
|
6516
6595
|
return;
|
|
6517
6596
|
}
|
|
6518
6597
|
try {
|
|
6519
|
-
const wsKey = _optionalChain([$asai, 'optionalAccess',
|
|
6520
|
-
_optionalChain([$asai, 'access',
|
|
6521
|
-
} catch (
|
|
6598
|
+
const wsKey = _optionalChain([$asai, 'optionalAccess', _753 => _753.command, 'optionalAccess', _754 => _754.commandconfig, 'optionalAccess', _755 => _755.config, 'optionalAccess', _756 => _756.commandclient]);
|
|
6599
|
+
_optionalChain([$asai, 'access', _757 => _757.serversws, 'optionalAccess', _758 => _758[wsKey], 'optionalAccess', _759 => _759.broadws, 'optionalCall', _760 => _760(event.data)]);
|
|
6600
|
+
} catch (e56) {
|
|
6522
6601
|
}
|
|
6523
6602
|
};
|
|
6524
6603
|
}
|
|
@@ -6590,7 +6669,7 @@ var initAsaiHostNodejs2 = {
|
|
|
6590
6669
|
createTransportDataHandler,
|
|
6591
6670
|
wireTransportConnectionLogs
|
|
6592
6671
|
};
|
|
6593
|
-
var PLUGIN_VERSION = true ? "0.0.
|
|
6672
|
+
var PLUGIN_VERSION = true ? "0.0.9" : "0.0.1";
|
|
6594
6673
|
var index_default = initAsaiHostNodejs2;
|
|
6595
6674
|
|
|
6596
6675
|
|