asaihost-nodejs 0.0.5 → 0.0.6
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/{InterventionLog-PZT2CCN3.es.js → InterventionLog-OPQ6VOBV.es.js} +3 -3
- package/dist/InterventionLog-WNVDQFAH.cjs +30 -0
- package/dist/{InterventionLog-CRP6YJVM.cjs.map → InterventionLog-WNVDQFAH.cjs.map} +1 -1
- package/dist/LogStore-AP4T2CFD.cjs +54 -0
- package/dist/{LogStore-7MTUQA4G.cjs.map → LogStore-AP4T2CFD.cjs.map} +1 -1
- package/dist/{LogStore-Q35YFNAY.es.js → LogStore-DWIPPRCA.es.js} +2 -2
- package/dist/asaihost-nodejs.cjs +469 -483
- package/dist/asaihost-nodejs.cjs.map +1 -1
- package/dist/asaihost-nodejs.d.cts +18 -2
- package/dist/asaihost-nodejs.d.ts +18 -2
- package/dist/asaihost-nodejs.es.js +130 -144
- package/dist/asaihost-nodejs.es.js.map +1 -1
- package/dist/{chunk-A6VJPLDD.es.js → chunk-5WJQD4RZ.es.js} +3 -3
- package/dist/{chunk-RIRKIYET.cjs → chunk-ARHPHWT5.cjs} +12 -12
- package/dist/{chunk-RIRKIYET.cjs.map → chunk-ARHPHWT5.cjs.map} +1 -1
- package/dist/{chunk-A5CDJGJI.es.js → chunk-BOIRAQXE.es.js} +1 -1
- package/dist/chunk-BOIRAQXE.es.js.map +1 -0
- package/dist/{chunk-LTEP4XB2.es.js → chunk-EC67M7RR.es.js} +115 -21
- package/dist/chunk-EC67M7RR.es.js.map +1 -0
- package/dist/{chunk-SB23ESX2.es.js → chunk-GCR56QH7.es.js} +2 -2
- package/dist/{chunk-H3K33HBA.cjs → chunk-GXOFLFFW.cjs} +1 -1
- package/dist/{chunk-H3K33HBA.cjs.map → chunk-GXOFLFFW.cjs.map} +1 -1
- package/dist/{chunk-TKJAHTPO.cjs → chunk-HR5JKN7Y.cjs} +161 -67
- package/dist/chunk-HR5JKN7Y.cjs.map +1 -0
- package/dist/{chunk-VUZO7DCA.es.js → chunk-N6LBKGML.es.js} +2 -2
- package/dist/{chunk-57UQJKSL.es.js → chunk-OTL2B4WS.es.js} +2 -2
- package/dist/{chunk-4E7Z5K5U.cjs → chunk-U2YJH2RW.cjs} +4 -4
- package/dist/{chunk-4E7Z5K5U.cjs.map → chunk-U2YJH2RW.cjs.map} +1 -1
- package/dist/{chunk-K2QPSQEV.cjs → chunk-WXW5DYNU.cjs} +9 -9
- package/dist/{chunk-K2QPSQEV.cjs.map → chunk-WXW5DYNU.cjs.map} +1 -1
- package/dist/{chunk-LXJMGLKW.cjs → chunk-ZK4O4Z2O.cjs} +20 -20
- package/dist/{chunk-LXJMGLKW.cjs.map → chunk-ZK4O4Z2O.cjs.map} +1 -1
- package/dist/intervention-hooks-4NAAAZK3.cjs +21 -0
- package/dist/{intervention-hooks-KF3SNB5Q.cjs.map → intervention-hooks-4NAAAZK3.cjs.map} +1 -1
- package/dist/{intervention-hooks-TCGIC4IV.es.js → intervention-hooks-QNA4IZT7.es.js} +4 -4
- package/dist/{password-4BABWAG4.es.js → password-4P7IZUDQ.es.js} +3 -3
- package/dist/password-MDYRL6ZD.cjs +20 -0
- package/dist/{password-PJHJRGPE.cjs.map → password-MDYRL6ZD.cjs.map} +1 -1
- package/dist/user-store-55HOLHEM.cjs +12 -0
- package/dist/{user-store-6J2PSEIN.cjs.map → user-store-55HOLHEM.cjs.map} +1 -1
- package/dist/{user-store-UC5URX3C.es.js → user-store-FXD2N55G.es.js} +3 -3
- package/package.json +1 -1
- package/dist/InterventionLog-CRP6YJVM.cjs +0 -30
- package/dist/LogStore-7MTUQA4G.cjs +0 -54
- package/dist/chunk-A5CDJGJI.es.js.map +0 -1
- package/dist/chunk-LTEP4XB2.es.js.map +0 -1
- package/dist/chunk-TKJAHTPO.cjs.map +0 -1
- package/dist/intervention-hooks-KF3SNB5Q.cjs +0 -21
- package/dist/password-PJHJRGPE.cjs +0 -20
- package/dist/user-store-6J2PSEIN.cjs +0 -12
- /package/dist/{InterventionLog-PZT2CCN3.es.js.map → InterventionLog-OPQ6VOBV.es.js.map} +0 -0
- /package/dist/{LogStore-Q35YFNAY.es.js.map → LogStore-DWIPPRCA.es.js.map} +0 -0
- /package/dist/{chunk-A6VJPLDD.es.js.map → chunk-5WJQD4RZ.es.js.map} +0 -0
- /package/dist/{chunk-SB23ESX2.es.js.map → chunk-GCR56QH7.es.js.map} +0 -0
- /package/dist/{chunk-VUZO7DCA.es.js.map → chunk-N6LBKGML.es.js.map} +0 -0
- /package/dist/{chunk-57UQJKSL.es.js.map → chunk-OTL2B4WS.es.js.map} +0 -0
- /package/dist/{intervention-hooks-TCGIC4IV.es.js.map → intervention-hooks-QNA4IZT7.es.js.map} +0 -0
- /package/dist/{password-4BABWAG4.es.js.map → password-4P7IZUDQ.es.js.map} +0 -0
- /package/dist/{user-store-UC5URX3C.es.js.map → user-store-FXD2N55G.es.js.map} +0 -0
package/dist/asaihost-nodejs.cjs
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkARHPHWT5cjs = require('./chunk-ARHPHWT5.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkU2YJH2RWcjs = require('./chunk-U2YJH2RW.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -28,7 +28,9 @@ var _chunk4E7Z5K5Ucjs = require('./chunk-4E7Z5K5U.cjs');
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunkHR5JKN7Ycjs = require('./chunk-HR5JKN7Y.cjs');
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
|
|
@@ -48,7 +50,7 @@ var _chunkO6LVLSNBcjs = require('./chunk-O6LVLSNB.cjs');
|
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
var
|
|
53
|
+
var _chunkWXW5DYNUcjs = require('./chunk-WXW5DYNU.cjs');
|
|
52
54
|
|
|
53
55
|
|
|
54
56
|
|
|
@@ -60,7 +62,7 @@ var _chunkK2QPSQEVcjs = require('./chunk-K2QPSQEV.cjs');
|
|
|
60
62
|
|
|
61
63
|
|
|
62
64
|
|
|
63
|
-
var
|
|
65
|
+
var _chunkZK4O4Z2Ocjs = require('./chunk-ZK4O4Z2O.cjs');
|
|
64
66
|
|
|
65
67
|
|
|
66
68
|
|
|
@@ -73,7 +75,7 @@ var _chunkLXJMGLKWcjs = require('./chunk-LXJMGLKW.cjs');
|
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
|
|
76
|
-
var
|
|
78
|
+
var _chunkGXOFLFFWcjs = require('./chunk-GXOFLFFW.cjs');
|
|
77
79
|
|
|
78
80
|
|
|
79
81
|
var _chunk2BCIIKRGcjs = require('./chunk-2BCIIKRG.cjs');
|
|
@@ -212,7 +214,7 @@ ${reason.name}: ${reason.message}`;
|
|
|
212
214
|
if (restartTimes.length > MAX_RESTARTS) {
|
|
213
215
|
try {
|
|
214
216
|
$asai.$log("NO_RESTART", "Process crashed too frequently, gracefully shutdown and wait for daemon restart.");
|
|
215
|
-
void Promise.resolve().then(() => _interopRequireWildcard(require("./intervention-hooks-
|
|
217
|
+
void Promise.resolve().then(() => _interopRequireWildcard(require("./intervention-hooks-4NAAAZK3.cjs"))).then(
|
|
216
218
|
({ logProcessGuardEvent }) => logProcessGuardEvent($asai, {
|
|
217
219
|
action: "crash_loop_shutdown",
|
|
218
220
|
detail: `${restartTimes.length} crashes in ${RESTART_WINDOW}ms window`,
|
|
@@ -254,7 +256,7 @@ ${reason.name}: ${reason.message}`;
|
|
|
254
256
|
}
|
|
255
257
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, initProcess, "initProcess");
|
|
256
258
|
function gracefulShutdown($asai) {
|
|
257
|
-
void Promise.resolve().then(() => _interopRequireWildcard(require("./intervention-hooks-
|
|
259
|
+
void Promise.resolve().then(() => _interopRequireWildcard(require("./intervention-hooks-4NAAAZK3.cjs"))).then(
|
|
258
260
|
({ logProcessGuardEvent }) => logProcessGuardEvent($asai, {
|
|
259
261
|
action: "graceful_shutdown",
|
|
260
262
|
detail: "SIGTERM/SIGINT or crash guard triggered",
|
|
@@ -379,7 +381,7 @@ var LogBuffer = class _LogBuffer {
|
|
|
379
381
|
await _promises2.default.appendFile(this.filePath, logContent, "utf8");
|
|
380
382
|
const src = this.filePath.includes("/client/") || this.filePath.includes("\\client\\") ? "client" : "server";
|
|
381
383
|
const kind = logContent.includes("[SEC-AUDIT]") ? "sec" : src;
|
|
382
|
-
void
|
|
384
|
+
void _chunkHR5JKN7Ycjs.mirrorWebLog.call(void 0, this.$asai, {
|
|
383
385
|
source: kind === "sec" ? "sec" : src,
|
|
384
386
|
rawLine: logContent
|
|
385
387
|
}).catch(() => void 0);
|
|
@@ -397,7 +399,7 @@ var LogBuffer = class _LogBuffer {
|
|
|
397
399
|
}
|
|
398
400
|
};
|
|
399
401
|
function saveLog($asai, src, logstr) {
|
|
400
|
-
return new Promise((
|
|
402
|
+
return new Promise((resolve5, reject) => {
|
|
401
403
|
try {
|
|
402
404
|
const bufferKey = `${$asai.id || "default"}_${src}`;
|
|
403
405
|
let logBuffer = logBuffers.get(bufferKey);
|
|
@@ -406,7 +408,7 @@ function saveLog($asai, src, logstr) {
|
|
|
406
408
|
logBuffers.set(bufferKey, logBuffer);
|
|
407
409
|
}
|
|
408
410
|
logBuffer.add(logstr);
|
|
409
|
-
|
|
411
|
+
resolve5();
|
|
410
412
|
} catch (err) {
|
|
411
413
|
console.error(err);
|
|
412
414
|
reject(err);
|
|
@@ -480,7 +482,7 @@ async function appendAccessLog($asai, clfLine, w3cLine) {
|
|
|
480
482
|
await ensureW3CAccessHeader($asai, w3cPath, dateCur);
|
|
481
483
|
await _promises2.default.appendFile(w3cPath, w3cLine, "utf8");
|
|
482
484
|
const clfParsed = _chunkOCEBEEP5cjs.parseCLF.call(void 0, clfLine);
|
|
483
|
-
void
|
|
485
|
+
void _chunkHR5JKN7Ycjs.mirrorAccessLog.call(void 0, $asai, {
|
|
484
486
|
format: "clf",
|
|
485
487
|
rawLine: clfLine,
|
|
486
488
|
host: _optionalChain([clfParsed, 'optionalAccess', _42 => _42.host]),
|
|
@@ -488,7 +490,7 @@ async function appendAccessLog($asai, clfLine, w3cLine) {
|
|
|
488
490
|
url: _optionalChain([clfParsed, 'optionalAccess', _44 => _44.url]),
|
|
489
491
|
status: _optionalChain([clfParsed, 'optionalAccess', _45 => _45.status])
|
|
490
492
|
}).catch(() => void 0);
|
|
491
|
-
void
|
|
493
|
+
void _chunkHR5JKN7Ycjs.mirrorAccessLog.call(void 0, $asai, {
|
|
492
494
|
format: "w3c",
|
|
493
495
|
rawLine: w3cLine
|
|
494
496
|
}).catch(() => void 0);
|
|
@@ -812,8 +814,8 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, checkNtpOffset, "checkNtpOffset");
|
|
|
812
814
|
|
|
813
815
|
// src/infra/config-integrity.ts
|
|
814
816
|
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
|
|
815
|
-
var _fs = require('fs'); var fs3 = _interopRequireWildcard(_fs); var fs6 = _interopRequireWildcard(_fs); var fs4 = _interopRequireWildcard(_fs); var fs5 = _interopRequireWildcard(_fs); var fs8 = _interopRequireWildcard(_fs); var fs10 = _interopRequireWildcard(_fs);
|
|
816
|
-
var _path = require('path'); var nodePath2 = _interopRequireWildcard(_path); var path2 = _interopRequireWildcard(_path); var nodePath = _interopRequireWildcard(_path); var nodePath3 = _interopRequireWildcard(_path); var
|
|
817
|
+
var _fs = require('fs'); var fs3 = _interopRequireWildcard(_fs); var fs6 = _interopRequireWildcard(_fs); var fs4 = _interopRequireWildcard(_fs); var fs5 = _interopRequireWildcard(_fs); var fs8 = _interopRequireWildcard(_fs); var fs10 = _interopRequireWildcard(_fs);
|
|
818
|
+
var _path = require('path'); var nodePath2 = _interopRequireWildcard(_path); var path2 = _interopRequireWildcard(_path); var nodePath = _interopRequireWildcard(_path); var nodePath3 = _interopRequireWildcard(_path); var path5 = _interopRequireWildcard(_path); var path6 = _interopRequireWildcard(_path);
|
|
817
819
|
function computeConfigHash(configPath) {
|
|
818
820
|
try {
|
|
819
821
|
const raw = fs3.default.readFileSync(configPath);
|
|
@@ -867,12 +869,12 @@ function initAsaiHostNodejs($asai, _opt) {
|
|
|
867
869
|
resAES
|
|
868
870
|
};
|
|
869
871
|
}
|
|
870
|
-
if (
|
|
872
|
+
if (_chunkZK4O4Z2Ocjs.isDevDefaultPassword.call(void 0, _optionalChain([$asai, 'access', _102 => _102.hostconfig, 'optionalAccess', _103 => _103.password]) || "")) {
|
|
871
873
|
logSecurityEvent($asai, {
|
|
872
874
|
type: "CONFIG_WARN",
|
|
873
875
|
detail: "Using dev-only password; set ASAI_HOST_PASSWORD for production (IEC 62443-4-2 CR 1.7)"
|
|
874
876
|
});
|
|
875
|
-
void Promise.resolve().then(() => _interopRequireWildcard(require("./intervention-hooks-
|
|
877
|
+
void Promise.resolve().then(() => _interopRequireWildcard(require("./intervention-hooks-4NAAAZK3.cjs"))).then(
|
|
876
878
|
({ logSecurityConfigIntervention: logSecurityConfigIntervention2 }) => logSecurityConfigIntervention2($asai, {
|
|
877
879
|
section: "password",
|
|
878
880
|
detail: "dev-default-password detected at startup"
|
|
@@ -898,7 +900,7 @@ function scheduleLogComplianceCheck($asai) {
|
|
|
898
900
|
if (hours <= 0) return;
|
|
899
901
|
const ms = hours * 3600 * 1e3;
|
|
900
902
|
setInterval(() => {
|
|
901
|
-
void Promise.resolve().then(() => _interopRequireWildcard(require("./LogStore-
|
|
903
|
+
void Promise.resolve().then(() => _interopRequireWildcard(require("./LogStore-AP4T2CFD.cjs"))).then(
|
|
902
904
|
({ getComplianceReport: getComplianceReport2 }) => getComplianceReport2($asai, "prod")
|
|
903
905
|
).catch(() => void 0);
|
|
904
906
|
}, ms);
|
|
@@ -996,7 +998,7 @@ function kickUserWs($asai, us, hostdir) {
|
|
|
996
998
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, kickUserWs, "kickUserWs");
|
|
997
999
|
async function removeSessionOnWsClose($asai, us, token) {
|
|
998
1000
|
try {
|
|
999
|
-
const store =
|
|
1001
|
+
const store = _chunkZK4O4Z2Ocjs.createUserStore.call(void 0, $asai);
|
|
1000
1002
|
const sessions = await store.getSessions();
|
|
1001
1003
|
const match = sessions.find((s) => s.us === us && s.pub === token);
|
|
1002
1004
|
if (match) await store.removeSession(match.id);
|
|
@@ -1582,10 +1584,10 @@ function getStaticBaseDirs($asai) {
|
|
|
1582
1584
|
bases.push(abs);
|
|
1583
1585
|
}
|
|
1584
1586
|
}, "add");
|
|
1587
|
+
if ($asai.serverRoot) add($asai.serverRoot);
|
|
1585
1588
|
if (Array.isArray($asai.runtimeBaseDirs)) {
|
|
1586
1589
|
for (const b of $asai.runtimeBaseDirs) add(b);
|
|
1587
1590
|
}
|
|
1588
|
-
if ($asai.serverRoot) add($asai.serverRoot);
|
|
1589
1591
|
if ($asai.pkgSnapshotDir) add($asai.pkgSnapshotDir);
|
|
1590
1592
|
return bases;
|
|
1591
1593
|
}
|
|
@@ -1652,6 +1654,11 @@ function parseUrlPath(requrl) {
|
|
|
1652
1654
|
}
|
|
1653
1655
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseUrlPath, "parseUrlPath");
|
|
1654
1656
|
var STATIC_ASSET_PREFIXES = ["/assets/", "/webmodel/", "/assets/entry/", "/assets/chunk/"];
|
|
1657
|
+
function isMutableWebmodelConfig(urlPath) {
|
|
1658
|
+
const p = parseUrlPath(urlPath);
|
|
1659
|
+
return /^\/webmodel\/sys\/setting\/[^/]+\.json$/i.test(p);
|
|
1660
|
+
}
|
|
1661
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, isMutableWebmodelConfig, "isMutableWebmodelConfig");
|
|
1655
1662
|
function isStaticAssetPath(urlPath, indexFile) {
|
|
1656
1663
|
const p = parseUrlPath(urlPath);
|
|
1657
1664
|
const base = p.split("/").pop() || "";
|
|
@@ -1660,9 +1667,10 @@ function isStaticAssetPath(urlPath, indexFile) {
|
|
|
1660
1667
|
return /\.(css|js|mjs|cjs|json|png|jpe?g|gif|svg|ico|woff2?|ttf|map|wasm|zip)(\?|$)/i.test(p);
|
|
1661
1668
|
}
|
|
1662
1669
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isStaticAssetPath, "isStaticAssetPath");
|
|
1663
|
-
function sendStaticBuffer(req, res, data, mimeType, mtimeMs, $asai) {
|
|
1670
|
+
function sendStaticBuffer(req, res, data, mimeType, mtimeMs, $asai, urlPath = "") {
|
|
1664
1671
|
const etag = `"${data.length}-${mtimeMs}"`;
|
|
1665
|
-
|
|
1672
|
+
const noCache = isMutableWebmodelConfig(urlPath);
|
|
1673
|
+
if (!noCache && req.headers["if-none-match"] === etag) {
|
|
1666
1674
|
res.writeHead(304);
|
|
1667
1675
|
res.end();
|
|
1668
1676
|
return;
|
|
@@ -1671,7 +1679,7 @@ function sendStaticBuffer(req, res, data, mimeType, mtimeMs, $asai) {
|
|
|
1671
1679
|
res.writeHead(200, {
|
|
1672
1680
|
"Content-Type": mimeType,
|
|
1673
1681
|
"Content-Length": data.length,
|
|
1674
|
-
"Cache-Control": "public, max-age=3600",
|
|
1682
|
+
"Cache-Control": noCache ? "no-cache, must-revalidate" : "public, max-age=3600",
|
|
1675
1683
|
ETag: etag,
|
|
1676
1684
|
"Last-Modified": new Date(mtimeMs).toUTCString()
|
|
1677
1685
|
});
|
|
@@ -1685,7 +1693,8 @@ function sendStaticBuffer(req, res, data, mimeType, mtimeMs, $asai) {
|
|
|
1685
1693
|
}
|
|
1686
1694
|
}
|
|
1687
1695
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendStaticBuffer, "sendStaticBuffer");
|
|
1688
|
-
function serveStaticFile(req, res, foundPath, mimeType, stat, $asai) {
|
|
1696
|
+
function serveStaticFile(req, res, foundPath, mimeType, stat, $asai, urlPath = "") {
|
|
1697
|
+
const noCache = isMutableWebmodelConfig(urlPath);
|
|
1689
1698
|
if (stat.size <= STATIC_READ_MAX) {
|
|
1690
1699
|
fs6.readFile(foundPath, (err, data) => {
|
|
1691
1700
|
if (err) {
|
|
@@ -1696,13 +1705,13 @@ function serveStaticFile(req, res, foundPath, mimeType, stat, $asai) {
|
|
|
1696
1705
|
}
|
|
1697
1706
|
return;
|
|
1698
1707
|
}
|
|
1699
|
-
sendStaticBuffer(req, res, data, mimeType, stat.mtimeMs, $asai);
|
|
1708
|
+
sendStaticBuffer(req, res, data, mimeType, stat.mtimeMs, $asai, urlPath);
|
|
1700
1709
|
});
|
|
1701
1710
|
return;
|
|
1702
1711
|
}
|
|
1703
1712
|
const readStream = fs6.createReadStream(foundPath);
|
|
1704
1713
|
const etag = `"${stat.size}-${stat.mtimeMs}"`;
|
|
1705
|
-
if (req.headers["if-none-match"] === etag) {
|
|
1714
|
+
if (!noCache && req.headers["if-none-match"] === etag) {
|
|
1706
1715
|
readStream.destroy();
|
|
1707
1716
|
res.writeHead(304);
|
|
1708
1717
|
res.end();
|
|
@@ -1721,7 +1730,7 @@ function serveStaticFile(req, res, foundPath, mimeType, stat, $asai) {
|
|
|
1721
1730
|
try {
|
|
1722
1731
|
res.writeHead(200, {
|
|
1723
1732
|
"Content-Type": mimeType,
|
|
1724
|
-
"Cache-Control": "public, max-age=3600",
|
|
1733
|
+
"Cache-Control": noCache ? "no-cache, must-revalidate" : "public, max-age=3600",
|
|
1725
1734
|
ETag: etag,
|
|
1726
1735
|
"Last-Modified": stat.mtime.toUTCString()
|
|
1727
1736
|
});
|
|
@@ -1779,7 +1788,7 @@ function createStaticHandler(ctx) {
|
|
|
1779
1788
|
return;
|
|
1780
1789
|
}
|
|
1781
1790
|
const mimeType = _optionalChain([hostcfg, 'access', _192 => _192.mimetypes, 'optionalAccess', _193 => _193[nodePath2.extname(found.filePath)]]) || "application/octet-stream";
|
|
1782
|
-
serveStaticFile(req, res, found.filePath, mimeType, found.stat, $asai);
|
|
1791
|
+
serveStaticFile(req, res, found.filePath, mimeType, found.stat, $asai, processedUrl);
|
|
1783
1792
|
}, "showHostDirs");
|
|
1784
1793
|
return (req, res, url) => {
|
|
1785
1794
|
res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
|
|
@@ -2342,7 +2351,7 @@ async function attachServerUserLevel(req, $asai) {
|
|
|
2342
2351
|
if (!Array.isArray(userinfo) || !userinfo[0]) return;
|
|
2343
2352
|
const us = String(userinfo[0]);
|
|
2344
2353
|
try {
|
|
2345
|
-
const { createUserStore: createUserStore2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./user-store-
|
|
2354
|
+
const { createUserStore: createUserStore2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./user-store-55HOLHEM.cjs")));
|
|
2346
2355
|
const user = await createUserStore2($asai).findByUsername(us);
|
|
2347
2356
|
if (user && user.status === "active") {
|
|
2348
2357
|
req._serverUser = { us: user.us, lv: user.lv, status: user.status };
|
|
@@ -2526,7 +2535,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, isApiCorsAllowed, "isApiCorsAllowed");
|
|
|
2526
2535
|
|
|
2527
2536
|
// src/common/server/Api.ts
|
|
2528
2537
|
function readRequestBody(req, maxBody) {
|
|
2529
|
-
return new Promise((
|
|
2538
|
+
return new Promise((resolve5, reject) => {
|
|
2530
2539
|
const chunks = [];
|
|
2531
2540
|
let received = 0;
|
|
2532
2541
|
let settled = false;
|
|
@@ -2534,7 +2543,7 @@ function readRequestBody(req, maxBody) {
|
|
|
2534
2543
|
if (settled) return;
|
|
2535
2544
|
settled = true;
|
|
2536
2545
|
if (err) reject(err);
|
|
2537
|
-
else
|
|
2546
|
+
else resolve5(_nullishCoalesce(data, () => ( "")));
|
|
2538
2547
|
}, "finish");
|
|
2539
2548
|
req.on("data", (chunk) => {
|
|
2540
2549
|
if (settled) return;
|
|
@@ -2555,6 +2564,10 @@ function isRawUploadPost(url = "") {
|
|
|
2555
2564
|
return /\/api\/asaifile\/manage\/up(?:base64|binary)(?:batch)?\//.test(url);
|
|
2556
2565
|
}
|
|
2557
2566
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isRawUploadPost, "isRawUploadPost");
|
|
2567
|
+
function isPlainSourcePost(url = "") {
|
|
2568
|
+
return /\/api\/robotcode\//.test(url);
|
|
2569
|
+
}
|
|
2570
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, isPlainSourcePost, "isPlainSourcePost");
|
|
2558
2571
|
function processPostPayload($asai, req, postdata, pm) {
|
|
2559
2572
|
let isAes = false;
|
|
2560
2573
|
let out = postdata;
|
|
@@ -2570,7 +2583,7 @@ function processPostPayload($asai, req, postdata, pm) {
|
|
|
2570
2583
|
}
|
|
2571
2584
|
}
|
|
2572
2585
|
const plainJson = typeof out === "string" && out.trimStart().startsWith("{");
|
|
2573
|
-
if (_optionalChain([req, 'optionalAccess', _280 => _280.Userinfo, 'optionalAccess', _281 => _281[2]]) && !plainJson && !isRawUploadPost(_optionalChain([req, 'optionalAccess', _282 => _282.url]))) {
|
|
2586
|
+
if (_optionalChain([req, 'optionalAccess', _280 => _280.Userinfo, 'optionalAccess', _281 => _281[2]]) && !plainJson && !isRawUploadPost(_optionalChain([req, 'optionalAccess', _282 => _282.url])) && !isPlainSourcePost(_optionalChain([req, 'optionalAccess', _283 => _283.url]))) {
|
|
2574
2587
|
pm = req.Userinfo[2];
|
|
2575
2588
|
out = $asai.$lib.AsCode.asdecode(out, pm);
|
|
2576
2589
|
}
|
|
@@ -2578,7 +2591,7 @@ function processPostPayload($asai, req, postdata, pm) {
|
|
|
2578
2591
|
}
|
|
2579
2592
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, processPostPayload, "processPostPayload");
|
|
2580
2593
|
var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2581
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2594
|
+
_optionalChain([opt, 'optionalAccess', _284 => _284.fn, 'optionalCall', _285 => _285($asai)]);
|
|
2582
2595
|
function getHeader(req, key) {
|
|
2583
2596
|
return req.headers[key.toLowerCase()] || "";
|
|
2584
2597
|
}
|
|
@@ -2587,7 +2600,7 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2587
2600
|
let apiRouteCacheLen = -1;
|
|
2588
2601
|
function findApiHandler($asai2, pathname) {
|
|
2589
2602
|
const apis = $asai2.hostserverapis;
|
|
2590
|
-
if (!_optionalChain([apis, 'optionalAccess',
|
|
2603
|
+
if (!_optionalChain([apis, 'optionalAccess', _286 => _286.length])) return void 0;
|
|
2591
2604
|
if (!apiRouteCache || apiRouteCacheLen !== apis.length) {
|
|
2592
2605
|
apiRouteCache = apis.map((elp) => ({ key: elp, path: `/api/${elp}` }));
|
|
2593
2606
|
apiRouteCacheLen = apis.length;
|
|
@@ -2635,9 +2648,9 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2635
2648
|
pm: decodeURIComponent(urlParse.search.substring(4))
|
|
2636
2649
|
};
|
|
2637
2650
|
if (req.url.indexOf("binary") === -1) {
|
|
2638
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
2651
|
+
if (_optionalChain([req, 'optionalAccess', _287 => _287.Userinfo]) && _optionalChain([req, 'optionalAccess', _288 => _288.Userinfo, 'access', _289 => _289[2]]) && _optionalChain([query, 'optionalAccess', _290 => _290.pm])) {
|
|
2639
2652
|
pm = req.Userinfo[2];
|
|
2640
|
-
query = $asai.$lib.AsCode.asdecode(_optionalChain([query, 'optionalAccess',
|
|
2653
|
+
query = $asai.$lib.AsCode.asdecode(_optionalChain([query, 'optionalAccess', _291 => _291.pm]), pm);
|
|
2641
2654
|
query = Object.fromEntries(new URLSearchParams("?" + query).entries());
|
|
2642
2655
|
}
|
|
2643
2656
|
}
|
|
@@ -2656,7 +2669,7 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2656
2669
|
const releaseSlot = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, () => releaseApiSlot(hostdir, clientIp), "releaseSlot");
|
|
2657
2670
|
res.once("finish", releaseSlot);
|
|
2658
2671
|
res.once("close", releaseSlot);
|
|
2659
|
-
const maxBody = _optionalChain([$asai, 'access',
|
|
2672
|
+
const maxBody = _optionalChain([$asai, 'access', _292 => _292.hostconfig, 'optionalAccess', _293 => _293.maxbody]) || 100 * 1024 * 1024;
|
|
2660
2673
|
const isTextPost = req.method === "POST" && req.url.indexOf("binary") === -1;
|
|
2661
2674
|
const bodyPromise = isTextPost ? readRequestBody(req, maxBody) : null;
|
|
2662
2675
|
void (async () => {
|
|
@@ -2669,16 +2682,16 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2669
2682
|
]);
|
|
2670
2683
|
} catch (err) {
|
|
2671
2684
|
releaseSlot();
|
|
2672
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
2685
|
+
if (_optionalChain([err, 'optionalAccess', _294 => _294.message]) === "PAYLOAD_TOO_LARGE") {
|
|
2673
2686
|
return sendError(res, 413, "Payload Too Large");
|
|
2674
2687
|
}
|
|
2675
|
-
return sendError(res, 400, _optionalChain([err, 'optionalAccess',
|
|
2688
|
+
return sendError(res, 400, _optionalChain([err, 'optionalAccess', _295 => _295.message]) || "Bad Request");
|
|
2676
2689
|
}
|
|
2677
2690
|
if (!authResult.ok) {
|
|
2678
2691
|
releaseSlot();
|
|
2679
2692
|
return sendAuthError(res, authResult);
|
|
2680
2693
|
}
|
|
2681
|
-
let apiFn = _optionalChain([$asai, 'access',
|
|
2694
|
+
let apiFn = _optionalChain([$asai, 'access', _296 => _296.hostserverapi, 'access', _297 => _297[apiHandlerKey], 'optionalCall', _298 => _298($asai, query)]);
|
|
2682
2695
|
if (!apiFn) {
|
|
2683
2696
|
return sendError(res, 501, "Not Implemented");
|
|
2684
2697
|
}
|
|
@@ -2697,20 +2710,20 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2697
2710
|
} catch (e35) {
|
|
2698
2711
|
return sendError(res, 400, "AES decrypt failed");
|
|
2699
2712
|
}
|
|
2700
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2713
|
+
if (_optionalChain([apiFn, 'optionalAccess', _299 => _299.post]) && typeof _optionalChain([apiFn, 'optionalAccess', _300 => _300.post]) === "function") {
|
|
2701
2714
|
const optTmp = { qrdata, data: postdata, pm };
|
|
2702
|
-
if (isAes || _optionalChain([$asai, 'access',
|
|
2703
|
-
optTmp.resAES = _optionalChain([$asai, 'access',
|
|
2715
|
+
if (isAes || _optionalChain([$asai, 'access', _301 => _301.$lib, 'access', _302 => _302.aesfns, 'optionalAccess', _303 => _303.allaes])) {
|
|
2716
|
+
optTmp.resAES = _optionalChain([$asai, 'access', _304 => _304.$lib, 'access', _305 => _305.aesfns, 'optionalAccess', _306 => _306.resAES]);
|
|
2704
2717
|
}
|
|
2705
2718
|
apiFn.post(req, res, hostdir, optTmp);
|
|
2706
2719
|
} else {
|
|
2707
2720
|
res.end(typeof postdata === "string" ? postdata : JSON.stringify(_nullishCoalesce(postdata, () => ( ""))));
|
|
2708
2721
|
}
|
|
2709
2722
|
} else if (req.method === "GET") {
|
|
2710
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2723
|
+
if (_optionalChain([apiFn, 'optionalAccess', _307 => _307.get]) && typeof _optionalChain([apiFn, 'optionalAccess', _308 => _308.get]) === "function") {
|
|
2711
2724
|
const optTmp = { qrdata, data: qrdata, pm };
|
|
2712
|
-
if (isAes || _optionalChain([$asai, 'access',
|
|
2713
|
-
optTmp.resAES = _optionalChain([$asai, 'access',
|
|
2725
|
+
if (isAes || _optionalChain([$asai, 'access', _309 => _309.$lib, 'access', _310 => _310.aesfns, 'optionalAccess', _311 => _311.allaes])) {
|
|
2726
|
+
optTmp.resAES = _optionalChain([$asai, 'access', _312 => _312.$lib, 'access', _313 => _313.aesfns, 'optionalAccess', _314 => _314.resAES]);
|
|
2714
2727
|
}
|
|
2715
2728
|
apiFn.get(req, res, hostdir, optTmp);
|
|
2716
2729
|
} else {
|
|
@@ -2718,12 +2731,12 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2718
2731
|
}
|
|
2719
2732
|
}
|
|
2720
2733
|
} else {
|
|
2721
|
-
if (_optionalChain([Object, 'access',
|
|
2734
|
+
if (_optionalChain([Object, 'access', _315 => _315.keys, 'call', _316 => _316(query), 'optionalAccess', _317 => _317.length])) {
|
|
2722
2735
|
qrdata = query;
|
|
2723
2736
|
}
|
|
2724
2737
|
if (req.method === "POST") {
|
|
2725
2738
|
$asai.$lib.AsNodeTool.upBinary(req).then((postdata2) => {
|
|
2726
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2739
|
+
if (_optionalChain([apiFn, 'optionalAccess', _318 => _318.post]) && typeof _optionalChain([apiFn, 'optionalAccess', _319 => _319.post]) === "function") {
|
|
2727
2740
|
apiFn.post(req, res, hostdir, {
|
|
2728
2741
|
qrdata,
|
|
2729
2742
|
data: postdata2
|
|
@@ -2747,12 +2760,12 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2747
2760
|
|
|
2748
2761
|
// src/common/server/Ws.ts
|
|
2749
2762
|
var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2750
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2763
|
+
_optionalChain([opt, 'optionalAccess', _320 => _320.fn, 'optionalCall', _321 => _321($asai)]);
|
|
2751
2764
|
const wsHandlerCache = /* @__PURE__ */ new Map();
|
|
2752
2765
|
const routeIndex = ensureWsRouteIndex($asai);
|
|
2753
2766
|
function getWsHandler(handlerKey) {
|
|
2754
2767
|
if (!wsHandlerCache.has(handlerKey)) {
|
|
2755
|
-
wsHandlerCache.set(handlerKey, _optionalChain([$asai, 'access',
|
|
2768
|
+
wsHandlerCache.set(handlerKey, _optionalChain([$asai, 'access', _322 => _322.hostserverws, 'access', _323 => _323[handlerKey], 'optionalCall', _324 => _324($asai)]));
|
|
2756
2769
|
}
|
|
2757
2770
|
return wsHandlerCache.get(handlerKey);
|
|
2758
2771
|
}
|
|
@@ -2776,21 +2789,21 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2776
2789
|
let reqdata = parseMessage(msg);
|
|
2777
2790
|
let handlerKey;
|
|
2778
2791
|
if (reqdata === "ping") {
|
|
2779
|
-
_optionalChain([ws2, 'access',
|
|
2792
|
+
_optionalChain([ws2, 'access', _325 => _325.send, 'optionalCall', _326 => _326("pong")]);
|
|
2780
2793
|
return;
|
|
2781
2794
|
} else {
|
|
2782
2795
|
const reqdataisobj = typeof reqdata === "object" && reqdata !== null;
|
|
2783
|
-
handlerKey = reqdataisobj ? routeIndex.matchTy(_optionalChain([reqdata, 'optionalAccess',
|
|
2784
|
-
if (!handlerKey && _optionalChain([$asai, 'access',
|
|
2796
|
+
handlerKey = reqdataisobj ? routeIndex.matchTy(_optionalChain([reqdata, 'optionalAccess', _327 => _327.ty])) : routeIndex.matchString(reqdata);
|
|
2797
|
+
if (!handlerKey && _optionalChain([$asai, 'access', _328 => _328.hostserverwss, 'optionalAccess', _329 => _329.length])) {
|
|
2785
2798
|
handlerKey = $asai.hostserverwss.find((elp) => {
|
|
2786
2799
|
if (reqdataisobj) {
|
|
2787
|
-
return _optionalChain([reqdata, 'optionalAccess',
|
|
2800
|
+
return _optionalChain([reqdata, 'optionalAccess', _330 => _330.ty, 'optionalAccess', _331 => _331.startsWith, 'call', _332 => _332(elp)]);
|
|
2788
2801
|
}
|
|
2789
2802
|
return typeof reqdata === "string" && reqdata.startsWith(elp);
|
|
2790
2803
|
});
|
|
2791
2804
|
}
|
|
2792
2805
|
if (!handlerKey) {
|
|
2793
|
-
_optionalChain([$asai, 'access',
|
|
2806
|
+
_optionalChain([$asai, 'access', _333 => _333.asaimock, 'optionalAccess', _334 => _334.wsWorkMock, 'call', _335 => _335({
|
|
2794
2807
|
msg,
|
|
2795
2808
|
ws: ws2,
|
|
2796
2809
|
hostdir,
|
|
@@ -2802,14 +2815,14 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2802
2815
|
}
|
|
2803
2816
|
}
|
|
2804
2817
|
if (!handlerKey) return;
|
|
2805
|
-
_optionalChain([getWsHandler, 'call',
|
|
2818
|
+
_optionalChain([getWsHandler, 'call', _336 => _336(handlerKey), 'optionalAccess', _337 => _337.work, 'optionalCall', _338 => _338(reqdata, ws2, hostdir, req)]);
|
|
2806
2819
|
} catch (err) {
|
|
2807
|
-
_optionalChain([($asai.$log || console.error), 'optionalCall',
|
|
2820
|
+
_optionalChain([($asai.$log || console.error), 'optionalCall', _339 => _339("WS", "handler error", err instanceof Error ? err.message : err)]);
|
|
2808
2821
|
}
|
|
2809
2822
|
}
|
|
2810
2823
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, wsWork, "wsWork");
|
|
2811
2824
|
function _getMessage(msg) {
|
|
2812
|
-
if (_optionalChain([msg, 'optionalAccess',
|
|
2825
|
+
if (_optionalChain([msg, 'optionalAccess', _340 => _340.db, 'optionalAccess', _341 => _341.aes]) && _optionalChain([$asai, 'access', _342 => _342.$lib, 'optionalAccess', _343 => _343.aesfns, 'optionalAccess', _344 => _344.reqAES])) {
|
|
2813
2826
|
msg.db = $asai.$lib.aesfns.reqAES({ data: msg.db });
|
|
2814
2827
|
}
|
|
2815
2828
|
return msg;
|
|
@@ -2836,12 +2849,12 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2836
2849
|
|
|
2837
2850
|
// src/common/server/Sys.ts
|
|
2838
2851
|
var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2839
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2852
|
+
_optionalChain([opt, 'optionalAccess', _345 => _345.fn, 'optionalCall', _346 => _346($asai)]);
|
|
2840
2853
|
let sysRouteCache = null;
|
|
2841
2854
|
let sysRouteCacheLen = -1;
|
|
2842
2855
|
function findSystemHandler(req) {
|
|
2843
2856
|
const routes = $asai.hostserversyss;
|
|
2844
|
-
if (!_optionalChain([routes, 'optionalAccess',
|
|
2857
|
+
if (!_optionalChain([routes, 'optionalAccess', _347 => _347.length])) return void 0;
|
|
2845
2858
|
if (!sysRouteCache || sysRouteCacheLen !== routes.length) {
|
|
2846
2859
|
sysRouteCache = routes.map((elp) => ({ key: elp, route: `/${elp}` }));
|
|
2847
2860
|
sysRouteCacheLen = routes.length;
|
|
@@ -2874,11 +2887,11 @@ var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2874
2887
|
if (!authResult.ok) {
|
|
2875
2888
|
return sendAuthError(res, authResult);
|
|
2876
2889
|
}
|
|
2877
|
-
const handler = _optionalChain([$asai, 'access',
|
|
2890
|
+
const handler = _optionalChain([$asai, 'access', _348 => _348.hostserversys, 'access', _349 => _349[handlerKey], 'optionalCall', _350 => _350($asai)]);
|
|
2878
2891
|
if (!handler) {
|
|
2879
2892
|
return sendError(res, 500, "Handler Initialization Failed");
|
|
2880
2893
|
}
|
|
2881
|
-
if (_optionalChain([handler, 'optionalAccess',
|
|
2894
|
+
if (_optionalChain([handler, 'optionalAccess', _351 => _351.show]) && typeof _optionalChain([handler, 'optionalAccess', _352 => _352.show]) === "function") {
|
|
2882
2895
|
handler.show(req, res, hostdir);
|
|
2883
2896
|
} else {
|
|
2884
2897
|
res.end("postdata");
|
|
@@ -2898,18 +2911,18 @@ var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2898
2911
|
|
|
2899
2912
|
// src/common/server/WsClient.ts
|
|
2900
2913
|
var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, wsname) => {
|
|
2901
|
-
if (!_optionalChain([$asai, 'optionalAccess',
|
|
2914
|
+
if (!_optionalChain([$asai, 'optionalAccess', _353 => _353.clientws])) {
|
|
2902
2915
|
$asai.clientws = {};
|
|
2903
2916
|
}
|
|
2904
2917
|
if (!$asai.clientws[wsname]) {
|
|
2905
2918
|
$asai.clientws[wsname] = { tasks: /* @__PURE__ */ new Map() };
|
|
2906
2919
|
}
|
|
2907
2920
|
function getKeyByData(msgdata) {
|
|
2908
|
-
return _optionalChain([msgdata, 'optionalAccess',
|
|
2921
|
+
return _optionalChain([msgdata, 'optionalAccess', _354 => _354.id]) || _optionalChain([msgdata, 'optionalAccess', _355 => _355.ty]);
|
|
2909
2922
|
}
|
|
2910
2923
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getKeyByData, "getKeyByData");
|
|
2911
2924
|
function clientwsInit() {
|
|
2912
|
-
return new Promise((
|
|
2925
|
+
return new Promise((resolve5, reject) => {
|
|
2913
2926
|
$asai.clientws[wsname].socket = new $asai.asaiWs(
|
|
2914
2927
|
$asai.command.commandconfig.clientws[wsname]
|
|
2915
2928
|
);
|
|
@@ -2918,7 +2931,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2918
2931
|
};
|
|
2919
2932
|
$asai.clientws[wsname].socket.on("error", (err) => {
|
|
2920
2933
|
$asai.clientws[wsname].open = 0;
|
|
2921
|
-
_optionalChain([$asai, 'access',
|
|
2934
|
+
_optionalChain([$asai, 'access', _356 => _356.hostconfig, 'access', _357 => _357.logger, 'optionalAccess', _358 => _358.lv, 'optionalAccess', _359 => _359.view]) && console.error(
|
|
2922
2935
|
666.2203,
|
|
2923
2936
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is error.`,
|
|
2924
2937
|
err
|
|
@@ -2927,19 +2940,19 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2927
2940
|
});
|
|
2928
2941
|
$asai.clientws[wsname].socket.on("close", () => {
|
|
2929
2942
|
$asai.clientws[wsname].open = 0;
|
|
2930
|
-
_optionalChain([$asai, 'access',
|
|
2943
|
+
_optionalChain([$asai, 'access', _360 => _360.hostconfig, 'access', _361 => _361.logger, 'optionalAccess', _362 => _362.lv, 'optionalAccess', _363 => _363.view]) && console.error(
|
|
2931
2944
|
666.2205,
|
|
2932
2945
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is close.`
|
|
2933
2946
|
);
|
|
2934
2947
|
reject();
|
|
2935
2948
|
});
|
|
2936
2949
|
$asai.clientws[wsname].socket.onopen = () => {
|
|
2937
|
-
_optionalChain([$asai, 'access',
|
|
2950
|
+
_optionalChain([$asai, 'access', _364 => _364.hostconfig, 'access', _365 => _365.logger, 'optionalAccess', _366 => _366.lv, 'optionalAccess', _367 => _367.view]) && console.log(
|
|
2938
2951
|
666.2201,
|
|
2939
2952
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is open.`
|
|
2940
2953
|
);
|
|
2941
2954
|
$asai.clientws[wsname].open = 1;
|
|
2942
|
-
|
|
2955
|
+
resolve5();
|
|
2943
2956
|
};
|
|
2944
2957
|
});
|
|
2945
2958
|
}
|
|
@@ -2957,7 +2970,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2957
2970
|
const key = getKeyByData(messageData);
|
|
2958
2971
|
const task = $asai.clientws[wsname].tasks.get(key);
|
|
2959
2972
|
if (task) {
|
|
2960
|
-
_optionalChain([task, 'optionalAccess',
|
|
2973
|
+
_optionalChain([task, 'optionalAccess', _368 => _368.callback, 'call', _369 => _369(messageData)]);
|
|
2961
2974
|
if (messageData.ty && !messageData.id) {
|
|
2962
2975
|
} else {
|
|
2963
2976
|
$asai.clientws[wsname].tasks.delete(key);
|
|
@@ -2969,7 +2982,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2969
2982
|
}
|
|
2970
2983
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, clientwsOnmessage, "clientwsOnmessage");
|
|
2971
2984
|
function clientwsApi(messageData) {
|
|
2972
|
-
return new Promise((
|
|
2985
|
+
return new Promise((resolve5, reject) => {
|
|
2973
2986
|
if ($asai.clientws[wsname].open) {
|
|
2974
2987
|
try {
|
|
2975
2988
|
const taskOpt = {};
|
|
@@ -2981,7 +2994,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2981
2994
|
getKeyByData(messageData),
|
|
2982
2995
|
{
|
|
2983
2996
|
callback: /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (res) => {
|
|
2984
|
-
|
|
2997
|
+
resolve5(res);
|
|
2985
2998
|
}, "callback"),
|
|
2986
2999
|
...messageData,
|
|
2987
3000
|
...taskOpt
|
|
@@ -3011,7 +3024,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
3011
3024
|
}
|
|
3012
3025
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, clientwsWatch, "clientwsWatch");
|
|
3013
3026
|
function clientwsWatchOff(messageData) {
|
|
3014
|
-
if (_optionalChain([messageData, 'optionalAccess',
|
|
3027
|
+
if (_optionalChain([messageData, 'optionalAccess', _370 => _370.ty]) === "clear") {
|
|
3015
3028
|
$asai.clientws[wsname].tasks = /* @__PURE__ */ new Map();
|
|
3016
3029
|
} else {
|
|
3017
3030
|
const key = getKeyByData(messageData);
|
|
@@ -3052,7 +3065,7 @@ var ping_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai)
|
|
|
3052
3065
|
var web_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3053
3066
|
function chatBoard(msgdata, ws2, hostdir, req) {
|
|
3054
3067
|
let room;
|
|
3055
|
-
if (_optionalChain([msgdata, 'access',
|
|
3068
|
+
if (_optionalChain([msgdata, 'access', _371 => _371.db, 'optionalAccess', _372 => _372.room]) && typeof msgdata.db.room === "string") {
|
|
3056
3069
|
room = msgdata.db.room;
|
|
3057
3070
|
delete msgdata.db.room;
|
|
3058
3071
|
} else {
|
|
@@ -3109,26 +3122,26 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3109
3122
|
removeFile: removeFile2,
|
|
3110
3123
|
resolvePathUnderBase: resolvePathUnderBase2
|
|
3111
3124
|
} = $asai.$lib.AsFs;
|
|
3112
|
-
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'access',
|
|
3125
|
+
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'access', _373 => _373.$lib, 'optionalAccess', _374 => _374.reqWork, 'optionalCall', _375 => _375($asai)]);
|
|
3113
3126
|
function mgLog(...arg) {
|
|
3114
3127
|
mnLog("LOG", ...arg);
|
|
3115
3128
|
}
|
|
3116
3129
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mgLog, "mgLog");
|
|
3117
3130
|
function getDir(opt) {
|
|
3118
|
-
let tmpDir = _optionalChain([opt, 'access',
|
|
3131
|
+
let tmpDir = _optionalChain([opt, 'access', _376 => _376.qrdata, 'optionalAccess', _377 => _377.dir]) || _optionalChain([opt, 'access', _378 => _378.data, 'optionalAccess', _379 => _379.dir]);
|
|
3119
3132
|
if (tmpDir) {
|
|
3120
3133
|
tmpDir = decodeURIComponent(tmpDir);
|
|
3121
3134
|
} else {
|
|
3122
|
-
tmpDir = _optionalChain([opt, 'access',
|
|
3135
|
+
tmpDir = _optionalChain([opt, 'access', _380 => _380.qrdata, 'optionalAccess', _381 => _381.ty]) || _optionalChain([opt, 'access', _382 => _382.data, 'optionalAccess', _383 => _383.ty]);
|
|
3123
3136
|
if (tmpDir) {
|
|
3124
3137
|
tmpDir = decodeURIComponent(tmpDir);
|
|
3125
3138
|
if (tmpDir === "access-clf" || tmpDir === "access-w3c") {
|
|
3126
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3139
|
+
tmpDir = _optionalChain([$asai, 'access', _384 => _384.hostconfig, 'access', _385 => _385.logger, 'optionalAccess', _386 => _386.path, 'optionalAccess', _387 => _387.access]) || "";
|
|
3127
3140
|
} else {
|
|
3128
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3141
|
+
tmpDir = _optionalChain([$asai, 'access', _388 => _388.hostconfig, 'access', _389 => _389.logger, 'optionalAccess', _390 => _390.path, 'optionalAccess', _391 => _391[tmpDir]]) || "";
|
|
3129
3142
|
}
|
|
3130
3143
|
} else {
|
|
3131
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3144
|
+
tmpDir = _optionalChain([$asai, 'access', _392 => _392.hostconfig, 'access', _393 => _393.logger, 'optionalAccess', _394 => _394.path, 'optionalAccess', _395 => _395.client]) || "";
|
|
3132
3145
|
}
|
|
3133
3146
|
}
|
|
3134
3147
|
return tmpDir;
|
|
@@ -3146,7 +3159,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3146
3159
|
return;
|
|
3147
3160
|
}
|
|
3148
3161
|
if (url.startsWith("/api/asailog/manage/add/")) {
|
|
3149
|
-
if (!await ensureLv(req, $asai,
|
|
3162
|
+
if (!await ensureLv(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3150
3163
|
try {
|
|
3151
3164
|
mgLog("add", "server:", opt.data);
|
|
3152
3165
|
await $asai.$log("LOG", "ADD", opt.data);
|
|
@@ -3160,7 +3173,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3160
3173
|
if (!await ensureLv(req, $asai, 3)) return sendFail(res, "Forbidden", opt);
|
|
3161
3174
|
try {
|
|
3162
3175
|
const baseDir = getDir(opt);
|
|
3163
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3176
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _396 => _396.qrdata, 'optionalAccess', _397 => _397.path]) || _optionalChain([opt, 'access', _398 => _398.data, 'optionalAccess', _399 => _399.path]));
|
|
3164
3177
|
const jsonpath = resolvePathUnderBase2(baseDir, relPath);
|
|
3165
3178
|
await ensureFile2(jsonpath);
|
|
3166
3179
|
mgLog("ENSURE", jsonpath);
|
|
@@ -3179,13 +3192,13 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3179
3192
|
async function get(req, res, hostdir, opt) {
|
|
3180
3193
|
const url = req.url;
|
|
3181
3194
|
if (url.startsWith("/api/asailog/manage/selectlist/")) {
|
|
3182
|
-
if (!await ensureLv(req, $asai,
|
|
3195
|
+
if (!await ensureLv(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3183
3196
|
try {
|
|
3184
|
-
const ty = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3185
|
-
if (!
|
|
3197
|
+
const ty = decodeURIComponent(_optionalChain([opt, 'access', _400 => _400.qrdata, 'optionalAccess', _401 => _401.ty]) || _optionalChain([opt, 'access', _402 => _402.data, 'optionalAccess', _403 => _403.ty]) || "client");
|
|
3198
|
+
if (!_chunkHR5JKN7Ycjs.prefersDiskLogAccess.call(void 0, $asai) && _chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai) && (ty === "client" || ty === "server" || ty === "sec")) {
|
|
3186
3199
|
const kind = ty === "sec" ? "sec" : "web";
|
|
3187
|
-
const groups = await
|
|
3188
|
-
const children =
|
|
3200
|
+
const groups = await _chunkHR5JKN7Ycjs.listUnifiedGroups.call(void 0, $asai, { kind, source: ty === "sec" ? "sec" : ty });
|
|
3201
|
+
const children = _chunkHR5JKN7Ycjs.groupsToManageChildren.call(void 0, groups);
|
|
3189
3202
|
if (children.length) {
|
|
3190
3203
|
mgLog("LIST", `store:${ty}`, children.length);
|
|
3191
3204
|
return sendSuccess(res, { children, fromStore: true }, opt);
|
|
@@ -3207,12 +3220,12 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3207
3220
|
return;
|
|
3208
3221
|
}
|
|
3209
3222
|
if (url.startsWith("/api/asailog/manage/select/")) {
|
|
3210
|
-
if (!await ensureLv(req, $asai,
|
|
3223
|
+
if (!await ensureLv(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3211
3224
|
try {
|
|
3212
|
-
const ty = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3213
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3214
|
-
if (!
|
|
3215
|
-
const data2 = await
|
|
3225
|
+
const ty = decodeURIComponent(_optionalChain([opt, 'access', _404 => _404.qrdata, 'optionalAccess', _405 => _405.ty]) || _optionalChain([opt, 'access', _406 => _406.data, 'optionalAccess', _407 => _407.ty]) || "client");
|
|
3226
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _408 => _408.qrdata, 'optionalAccess', _409 => _409.path]) || _optionalChain([opt, 'access', _410 => _410.data, 'optionalAccess', _411 => _411.path]));
|
|
3227
|
+
if (!_chunkHR5JKN7Ycjs.prefersDiskLogAccess.call(void 0, $asai) && _chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai) && (ty === "client" || ty === "server" || ty === "sec")) {
|
|
3228
|
+
const data2 = await _chunkHR5JKN7Ycjs.readWebLogFromStore.call(void 0, $asai, ty, relPath);
|
|
3216
3229
|
if (data2) {
|
|
3217
3230
|
mgLog("READ", `store:${ty}/${relPath}`);
|
|
3218
3231
|
return sendSuccess(res, data2, opt);
|
|
@@ -3238,10 +3251,10 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3238
3251
|
if (!await ensureLv(req, $asai, 3)) return sendFail(res, "Forbidden", opt);
|
|
3239
3252
|
try {
|
|
3240
3253
|
const baseDir = getDir(opt);
|
|
3241
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3254
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _412 => _412.qrdata, 'optionalAccess', _413 => _413.path]) || _optionalChain([opt, 'access', _414 => _414.data, 'optionalAccess', _415 => _415.path]));
|
|
3242
3255
|
const fileName = relPath.split(/[/\\]/).pop() || relPath;
|
|
3243
|
-
if (
|
|
3244
|
-
await
|
|
3256
|
+
if (_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai)) {
|
|
3257
|
+
await _chunkHR5JKN7Ycjs.purgeStoreEntriesForFile.call(void 0, $asai, fileName).catch(() => void 0);
|
|
3245
3258
|
}
|
|
3246
3259
|
const filepath = resolvePathUnderBase2(baseDir, relPath);
|
|
3247
3260
|
mgLog("DELETE", filepath);
|
|
@@ -3261,14 +3274,14 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3261
3274
|
|
|
3262
3275
|
// src/infra/siem-auth.ts
|
|
3263
3276
|
function isSiemEnabled($asai) {
|
|
3264
|
-
const cfg = _optionalChain([$asai, 'optionalAccess',
|
|
3265
|
-
return !!(_optionalChain([cfg, 'optionalAccess',
|
|
3277
|
+
const cfg = _optionalChain([$asai, 'optionalAccess', _416 => _416.hostconfig, 'optionalAccess', _417 => _417.logger, 'optionalAccess', _418 => _418.siem]);
|
|
3278
|
+
return !!(_optionalChain([cfg, 'optionalAccess', _419 => _419.enabled]) && getSiemToken($asai));
|
|
3266
3279
|
}
|
|
3267
3280
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isSiemEnabled, "isSiemEnabled");
|
|
3268
3281
|
function getSiemToken($asai) {
|
|
3269
3282
|
const fromEnv = process.env.ASAI_SIEM_TOKEN;
|
|
3270
3283
|
if (typeof fromEnv === "string" && fromEnv.trim()) return fromEnv.trim();
|
|
3271
|
-
const fromCfg = _optionalChain([$asai, 'optionalAccess',
|
|
3284
|
+
const fromCfg = _optionalChain([$asai, 'optionalAccess', _420 => _420.hostconfig, 'optionalAccess', _421 => _421.logger, 'optionalAccess', _422 => _422.siem, 'optionalAccess', _423 => _423.token]);
|
|
3272
3285
|
return typeof fromCfg === "string" ? fromCfg.trim() : "";
|
|
3273
3286
|
}
|
|
3274
3287
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSiemToken, "getSiemToken");
|
|
@@ -3276,9 +3289,9 @@ function isSiemTokenValid($asai, req) {
|
|
|
3276
3289
|
if (!isSiemEnabled($asai)) return false;
|
|
3277
3290
|
const expected = getSiemToken($asai);
|
|
3278
3291
|
if (!expected) return false;
|
|
3279
|
-
const header = _optionalChain([req, 'optionalAccess',
|
|
3292
|
+
const header = _optionalChain([req, 'optionalAccess', _424 => _424.headers, 'optionalAccess', _425 => _425["x-siem-token"]]) || _optionalChain([req, 'optionalAccess', _426 => _426.headers, 'optionalAccess', _427 => _427["x-api-key"]]);
|
|
3280
3293
|
if (typeof header === "string" && header === expected) return true;
|
|
3281
|
-
const q = _optionalChain([req, 'optionalAccess',
|
|
3294
|
+
const q = _optionalChain([req, 'optionalAccess', _428 => _428.query]) || {};
|
|
3282
3295
|
const qToken = q.siem_token || q.token;
|
|
3283
3296
|
return typeof qToken === "string" && qToken === expected;
|
|
3284
3297
|
}
|
|
@@ -3302,24 +3315,24 @@ function getNs(raw) {
|
|
|
3302
3315
|
}
|
|
3303
3316
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getNs, "getNs");
|
|
3304
3317
|
async function ensureServerUser(req, $asai) {
|
|
3305
|
-
if (Array.isArray(_optionalChain([req, 'optionalAccess',
|
|
3318
|
+
if (Array.isArray(_optionalChain([req, 'optionalAccess', _429 => _429.Userinfo])) && req.Userinfo[0]) {
|
|
3306
3319
|
await attachServerUserLevel(req, $asai);
|
|
3307
3320
|
}
|
|
3308
3321
|
}
|
|
3309
3322
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, ensureServerUser, "ensureServerUser");
|
|
3310
3323
|
var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3311
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3324
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _430 => _430.$lib, 'optionalAccess', _431 => _431.reqWork, 'optionalCall', _432 => _432($asai)]) || {};
|
|
3312
3325
|
const IL = $asai.$lib.InterventionLog;
|
|
3313
3326
|
async function get(req, res, hostdir, opt) {
|
|
3314
3327
|
const url = req.url || "";
|
|
3315
3328
|
if (url.startsWith("/api/asailog/intervention/selectlist/")) {
|
|
3316
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3329
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3317
3330
|
try {
|
|
3318
|
-
const ns = getNs(_optionalChain([opt, 'access',
|
|
3331
|
+
const ns = getNs(_optionalChain([opt, 'access', _433 => _433.qrdata, 'optionalAccess', _434 => _434.ns]) || _optionalChain([opt, 'access', _435 => _435.data, 'optionalAccess', _436 => _436.ns]));
|
|
3319
3332
|
let list = await IL.listInterventionFiles($asai, ns);
|
|
3320
|
-
if (
|
|
3321
|
-
const groups = await
|
|
3322
|
-
const fromStore =
|
|
3333
|
+
if (_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai) && !_chunkHR5JKN7Ycjs.prefersDiskLogAccess.call(void 0, $asai)) {
|
|
3334
|
+
const groups = await _chunkHR5JKN7Ycjs.listUnifiedGroups.call(void 0, $asai, { kind: "intervention", ns });
|
|
3335
|
+
const fromStore = _chunkHR5JKN7Ycjs.groupsToInterventionFiles.call(void 0, groups, ns);
|
|
3323
3336
|
const names = new Set(list.map((f) => f.name));
|
|
3324
3337
|
for (const f of fromStore) {
|
|
3325
3338
|
if (!names.has(f.name)) list.push(f);
|
|
@@ -3327,27 +3340,27 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3327
3340
|
}
|
|
3328
3341
|
return sendSuccess(res, { ns, files: list }, opt);
|
|
3329
3342
|
} catch (err) {
|
|
3330
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3343
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _437 => _437.message]) || err, opt);
|
|
3331
3344
|
}
|
|
3332
3345
|
}
|
|
3333
3346
|
if (url.startsWith("/api/asailog/intervention/select/")) {
|
|
3334
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3347
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3335
3348
|
try {
|
|
3336
|
-
const name = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3337
|
-
const ns = getNs(_optionalChain([opt, 'access',
|
|
3349
|
+
const name = decodeURIComponent(_optionalChain([opt, 'access', _438 => _438.qrdata, 'optionalAccess', _439 => _439.name]) || _optionalChain([opt, 'access', _440 => _440.data, 'optionalAccess', _441 => _441.name]) || "");
|
|
3350
|
+
const ns = getNs(_optionalChain([opt, 'access', _442 => _442.qrdata, 'optionalAccess', _443 => _443.ns]) || _optionalChain([opt, 'access', _444 => _444.data, 'optionalAccess', _445 => _445.ns]));
|
|
3338
3351
|
if (!name) return sendFail(res, "name required", opt);
|
|
3339
3352
|
const content = await IL.readInterventionFile($asai, name, ns);
|
|
3340
3353
|
return sendSuccess(res, { ns, ...content }, opt);
|
|
3341
3354
|
} catch (err) {
|
|
3342
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3355
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _446 => _446.message]) || err, opt);
|
|
3343
3356
|
}
|
|
3344
3357
|
}
|
|
3345
3358
|
if (url.startsWith("/api/asailog/intervention/types/")) {
|
|
3346
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3359
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3347
3360
|
try {
|
|
3348
3361
|
return sendSuccess(res, IL.getInterventionTaxonomy($asai), opt);
|
|
3349
3362
|
} catch (err) {
|
|
3350
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3363
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _447 => _447.message]) || err, opt);
|
|
3351
3364
|
}
|
|
3352
3365
|
}
|
|
3353
3366
|
}
|
|
@@ -3355,7 +3368,7 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3355
3368
|
async function post(req, res, hostdir, opt) {
|
|
3356
3369
|
const url = req.url || "";
|
|
3357
3370
|
if (url.startsWith("/api/asailog/intervention/delete/")) {
|
|
3358
|
-
if (!await ensureLogWriteAccess(req, $asai,
|
|
3371
|
+
if (!await ensureLogWriteAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite"))) return sendFail(res, "Forbidden", opt);
|
|
3359
3372
|
await ensureServerUser(req, $asai);
|
|
3360
3373
|
const lv = getRequestUserLevel(req);
|
|
3361
3374
|
const us = getRequestUsername(req);
|
|
@@ -3377,7 +3390,7 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3377
3390
|
);
|
|
3378
3391
|
return sendSuccess(res, { ns, ...result }, opt);
|
|
3379
3392
|
} catch (err) {
|
|
3380
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3393
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _448 => _448.message]) || err, opt);
|
|
3381
3394
|
}
|
|
3382
3395
|
}
|
|
3383
3396
|
}
|
|
@@ -3396,7 +3409,7 @@ function parseQuery(opt) {
|
|
|
3396
3409
|
}
|
|
3397
3410
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseQuery, "parseQuery");
|
|
3398
3411
|
function parseBody(opt) {
|
|
3399
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
3412
|
+
if (!_optionalChain([opt, 'optionalAccess', _449 => _449.data])) return {};
|
|
3400
3413
|
if (typeof opt.data === "string") {
|
|
3401
3414
|
try {
|
|
3402
3415
|
return JSON.parse(opt.data);
|
|
@@ -3408,47 +3421,47 @@ function parseBody(opt) {
|
|
|
3408
3421
|
}
|
|
3409
3422
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseBody, "parseBody");
|
|
3410
3423
|
var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3411
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3424
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _450 => _450.$lib, 'optionalAccess', _451 => _451.reqWork, 'optionalCall', _452 => _452($asai)]) || {};
|
|
3412
3425
|
const IL = $asai.$lib.InterventionLog;
|
|
3413
3426
|
async function get(req, res, hostdir, opt) {
|
|
3414
3427
|
const url = req.url || "";
|
|
3415
3428
|
const q = parseQuery(opt);
|
|
3416
3429
|
if (url.startsWith("/api/asailog/store/config/")) {
|
|
3417
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3430
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3418
3431
|
try {
|
|
3419
|
-
return sendSuccess(res,
|
|
3432
|
+
return sendSuccess(res, _chunkHR5JKN7Ycjs.getLogStoreMeta.call(void 0, $asai), opt);
|
|
3420
3433
|
} catch (err) {
|
|
3421
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3434
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _453 => _453.message]) || err, opt);
|
|
3422
3435
|
}
|
|
3423
3436
|
}
|
|
3424
3437
|
if (url.startsWith("/api/asailog/store/stats/")) {
|
|
3425
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3426
|
-
if (!
|
|
3427
|
-
return sendSuccess(res, { store: "disabled", message: "logger.store not configured", config:
|
|
3438
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3439
|
+
if (!_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai)) {
|
|
3440
|
+
return sendSuccess(res, { store: "disabled", message: "logger.store not configured", config: _chunkHR5JKN7Ycjs.getLogStoreMeta.call(void 0, $asai) }, opt);
|
|
3428
3441
|
}
|
|
3429
3442
|
try {
|
|
3430
|
-
const storeType =
|
|
3431
|
-
const stats = await
|
|
3432
|
-
return sendSuccess(res, { store: storeType, stats, config:
|
|
3443
|
+
const storeType = _chunkHR5JKN7Ycjs.getEffectiveStoreType.call(void 0, $asai);
|
|
3444
|
+
const stats = await _chunkHR5JKN7Ycjs.getUnifiedStats.call(void 0, $asai);
|
|
3445
|
+
return sendSuccess(res, { store: storeType, stats, config: _chunkHR5JKN7Ycjs.getLogStoreMeta.call(void 0, $asai) }, opt);
|
|
3433
3446
|
} catch (err) {
|
|
3434
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3447
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _454 => _454.message]) || err, opt);
|
|
3435
3448
|
}
|
|
3436
3449
|
}
|
|
3437
3450
|
if (url.startsWith("/api/asailog/store/compliance/")) {
|
|
3438
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3451
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3439
3452
|
try {
|
|
3440
3453
|
const ns = q.ns === "test" ? "test" : "prod";
|
|
3441
|
-
const report = await
|
|
3454
|
+
const report = await _chunkHR5JKN7Ycjs.getComplianceReport.call(void 0, $asai, ns);
|
|
3442
3455
|
return sendSuccess(res, report, opt);
|
|
3443
3456
|
} catch (err) {
|
|
3444
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3457
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _455 => _455.message]) || err, opt);
|
|
3445
3458
|
}
|
|
3446
3459
|
}
|
|
3447
3460
|
if (url.startsWith("/api/asailog/store/search/")) {
|
|
3448
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3449
|
-
if (!
|
|
3461
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3462
|
+
if (!_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai)) return sendFail(res, "Log store not enabled", opt);
|
|
3450
3463
|
try {
|
|
3451
|
-
const result = await
|
|
3464
|
+
const result = await _chunkHR5JKN7Ycjs.searchUnifiedLogs.call(void 0, $asai, {
|
|
3452
3465
|
kind: q.kind ? q.kind : void 0,
|
|
3453
3466
|
ns: q.ns ? q.ns : void 0,
|
|
3454
3467
|
source: q.source || q.ty || void 0,
|
|
@@ -3463,11 +3476,11 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3463
3476
|
});
|
|
3464
3477
|
return sendSuccess(res, result, opt);
|
|
3465
3478
|
} catch (err) {
|
|
3466
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3479
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _456 => _456.message]) || err, opt);
|
|
3467
3480
|
}
|
|
3468
3481
|
}
|
|
3469
3482
|
if (url.startsWith("/api/asailog/store/export/")) {
|
|
3470
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3483
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3471
3484
|
try {
|
|
3472
3485
|
const kind = q.kind || "intervention";
|
|
3473
3486
|
const format = q.format || "raw";
|
|
@@ -3475,7 +3488,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3475
3488
|
const ns = q.ns === "test" ? "test" : "prod";
|
|
3476
3489
|
const source = q.source || q.ty || "server";
|
|
3477
3490
|
if (!fileName && kind === "intervention") return sendFail(res, "name required", opt);
|
|
3478
|
-
const payload = await
|
|
3491
|
+
const payload = await _chunkHR5JKN7Ycjs.exportLogContent.call(void 0, $asai, {
|
|
3479
3492
|
kind,
|
|
3480
3493
|
ns: kind === "intervention" ? ns : void 0,
|
|
3481
3494
|
fileName: fileName || void 0,
|
|
@@ -3484,36 +3497,36 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3484
3497
|
});
|
|
3485
3498
|
return sendSuccess(res, payload, opt);
|
|
3486
3499
|
} catch (err) {
|
|
3487
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3500
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _457 => _457.message]) || err, opt);
|
|
3488
3501
|
}
|
|
3489
3502
|
}
|
|
3490
3503
|
if (url.startsWith("/api/asailog/store/taxonomy/")) {
|
|
3491
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3504
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3492
3505
|
try {
|
|
3493
3506
|
return sendSuccess(res, IL.getInterventionTaxonomy($asai), opt);
|
|
3494
3507
|
} catch (err) {
|
|
3495
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3508
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _458 => _458.message]) || err, opt);
|
|
3496
3509
|
}
|
|
3497
3510
|
}
|
|
3498
3511
|
if (url.startsWith("/api/asailog/store/formats/")) {
|
|
3499
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3512
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3500
3513
|
try {
|
|
3501
3514
|
const { getLogFormatTaxonomy } = await Promise.resolve().then(() => _interopRequireWildcard(require("./log-formats-TUXGMCCU.cjs")));
|
|
3502
3515
|
return sendSuccess(res, getLogFormatTaxonomy($asai), opt);
|
|
3503
3516
|
} catch (err) {
|
|
3504
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3517
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _459 => _459.message]) || err, opt);
|
|
3505
3518
|
}
|
|
3506
3519
|
}
|
|
3507
3520
|
if (url.startsWith("/api/asailog/store/selectlist/")) {
|
|
3508
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3509
|
-
if (!
|
|
3521
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3522
|
+
if (!_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai)) return sendFail(res, "Log store not enabled", opt);
|
|
3510
3523
|
try {
|
|
3511
3524
|
const kind = q.kind ? String(q.kind) : void 0;
|
|
3512
3525
|
const ns = q.ns ? String(q.ns) : void 0;
|
|
3513
3526
|
const source = q.source || q.ty ? String(q.source || q.ty) : void 0;
|
|
3514
|
-
const groups = await
|
|
3527
|
+
const groups = await _chunkHR5JKN7Ycjs.listUnifiedGroups.call(void 0, $asai, { kind, ns, source });
|
|
3515
3528
|
if (kind === "intervention" || ns) {
|
|
3516
|
-
return sendSuccess(res, { files:
|
|
3529
|
+
return sendSuccess(res, { files: _chunkHR5JKN7Ycjs.groupsToInterventionFiles.call(void 0, groups, ns || "prod"), ns: ns || "prod" }, opt);
|
|
3517
3530
|
}
|
|
3518
3531
|
if (kind === "web" || kind === "sec" || kind === "access" || source) {
|
|
3519
3532
|
const children = kind === "access" ? groups.filter((g) => g.kind === "access").map((g) => ({
|
|
@@ -3523,21 +3536,21 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3523
3536
|
entryCount: g.entryCount,
|
|
3524
3537
|
source: g.source,
|
|
3525
3538
|
fromStore: true
|
|
3526
|
-
})) :
|
|
3539
|
+
})) : _chunkHR5JKN7Ycjs.groupsToManageChildren.call(void 0, groups);
|
|
3527
3540
|
return sendSuccess(res, { children, source }, opt);
|
|
3528
3541
|
}
|
|
3529
3542
|
return sendSuccess(res, { groups }, opt);
|
|
3530
3543
|
} catch (err) {
|
|
3531
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3544
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _460 => _460.message]) || err, opt);
|
|
3532
3545
|
}
|
|
3533
3546
|
}
|
|
3534
3547
|
if (url.startsWith("/api/asailog/store/select/")) {
|
|
3535
|
-
if (!await ensureLogReadAccess(req, $asai,
|
|
3536
|
-
if (!
|
|
3548
|
+
if (!await ensureLogReadAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3549
|
+
if (!_chunkHR5JKN7Ycjs.isLogStoreEnabled.call(void 0, $asai)) return sendFail(res, "Log store not enabled", opt);
|
|
3537
3550
|
try {
|
|
3538
3551
|
const id = q.id;
|
|
3539
3552
|
if (id != null) {
|
|
3540
|
-
const row = await
|
|
3553
|
+
const row = await _chunkHR5JKN7Ycjs.getUnifiedEntry.call(void 0, $asai, id);
|
|
3541
3554
|
if (!row) return sendFail(res, "not found", opt);
|
|
3542
3555
|
return sendSuccess(res, { entry: row }, opt);
|
|
3543
3556
|
}
|
|
@@ -3546,14 +3559,14 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3546
3559
|
const ns = q.ns ? String(q.ns) : "";
|
|
3547
3560
|
const source = q.source || q.ty ? String(q.source || q.ty) : "server";
|
|
3548
3561
|
if (kind === "web" || kind === "sec" || !kind && fileName.startsWith("log-")) {
|
|
3549
|
-
const content = await
|
|
3562
|
+
const content = await _chunkHR5JKN7Ycjs.readWebLogFromStore.call(void 0, $asai, source, fileName);
|
|
3550
3563
|
return sendSuccess(res, content, opt);
|
|
3551
3564
|
}
|
|
3552
3565
|
if (kind === "intervention" || fileName.includes(".cef.log")) {
|
|
3553
3566
|
const content = await IL.readInterventionFile($asai, fileName, ns === "test" ? "test" : "prod");
|
|
3554
3567
|
return sendSuccess(res, { ns: ns || "prod", ...content, fromStore: true }, opt);
|
|
3555
3568
|
}
|
|
3556
|
-
const rows = await
|
|
3569
|
+
const rows = await _chunkHR5JKN7Ycjs.queryUnifiedLogs.call(void 0, $asai, {
|
|
3557
3570
|
kind,
|
|
3558
3571
|
ns,
|
|
3559
3572
|
source,
|
|
@@ -3562,7 +3575,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3562
3575
|
});
|
|
3563
3576
|
return sendSuccess(res, { entries: rows }, opt);
|
|
3564
3577
|
} catch (err) {
|
|
3565
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3578
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _461 => _461.message]) || err, opt);
|
|
3566
3579
|
}
|
|
3567
3580
|
}
|
|
3568
3581
|
}
|
|
@@ -3570,13 +3583,13 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3570
3583
|
async function post(req, res, hostdir, opt) {
|
|
3571
3584
|
const url = req.url || "";
|
|
3572
3585
|
if (!url.startsWith("/api/asailog/store/archive/")) return;
|
|
3573
|
-
if (!await ensureLogWriteAccess(req, $asai,
|
|
3586
|
+
if (!await ensureLogWriteAccess(req, $asai, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite"))) return sendFail(res, "Forbidden", opt);
|
|
3574
3587
|
try {
|
|
3575
3588
|
const body = parseBody(opt);
|
|
3576
3589
|
const year = Number(body.year);
|
|
3577
3590
|
if (!year || year < 2e3 || year > 2100) return sendFail(res, "invalid year", opt);
|
|
3578
3591
|
const ns = body.ns === "test" ? "test" : "prod";
|
|
3579
|
-
const result = await
|
|
3592
|
+
const result = await _chunkHR5JKN7Ycjs.archiveInterventionYear.call(void 0, $asai, {
|
|
3580
3593
|
year,
|
|
3581
3594
|
ns,
|
|
3582
3595
|
dryRun: !!body.dryRun,
|
|
@@ -3584,7 +3597,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3584
3597
|
});
|
|
3585
3598
|
return sendSuccess(res, result, opt);
|
|
3586
3599
|
} catch (err) {
|
|
3587
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3600
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _462 => _462.message]) || err, opt);
|
|
3588
3601
|
}
|
|
3589
3602
|
}
|
|
3590
3603
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, post, "post");
|
|
@@ -3596,7 +3609,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3596
3609
|
|
|
3597
3610
|
var registry = null;
|
|
3598
3611
|
function resolveFilePath($asai) {
|
|
3599
|
-
const root = _optionalChain([$asai, 'optionalAccess',
|
|
3612
|
+
const root = _optionalChain([$asai, 'optionalAccess', _463 => _463.serverRoot]) || process.cwd();
|
|
3600
3613
|
return nodePath3.join(root, "websys/sys/errorcodes.json");
|
|
3601
3614
|
}
|
|
3602
3615
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveFilePath, "resolveFilePath");
|
|
@@ -3614,7 +3627,7 @@ function loadErrorCodes($asai) {
|
|
|
3614
3627
|
}
|
|
3615
3628
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, loadErrorCodes, "loadErrorCodes");
|
|
3616
3629
|
function getError(ec) {
|
|
3617
|
-
return _optionalChain([registry, 'optionalAccess',
|
|
3630
|
+
return _optionalChain([registry, 'optionalAccess', _464 => _464.errors, 'optionalAccess', _465 => _465[ec]]) || null;
|
|
3618
3631
|
}
|
|
3619
3632
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getError, "getError");
|
|
3620
3633
|
function hasError(ec) {
|
|
@@ -3623,11 +3636,11 @@ function hasError(ec) {
|
|
|
3623
3636
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasError, "hasError");
|
|
3624
3637
|
function logError($asai, ec, params) {
|
|
3625
3638
|
const entry = getError(ec);
|
|
3626
|
-
const logFn = _optionalChain([$asai, 'optionalAccess',
|
|
3639
|
+
const logFn = _optionalChain([$asai, 'optionalAccess', _466 => _466.$log]) || console.warn;
|
|
3627
3640
|
if (entry) {
|
|
3628
|
-
logFn(`[EC:${ec}]`, entry.id || "", entry.detail || "", _optionalChain([params, 'optionalAccess',
|
|
3641
|
+
logFn(`[EC:${ec}]`, entry.id || "", entry.detail || "", _optionalChain([params, 'optionalAccess', _467 => _467.length]) ? params : "");
|
|
3629
3642
|
} else {
|
|
3630
|
-
logFn(`[EC:${ec}]`, "(unregistered)", _optionalChain([params, 'optionalAccess',
|
|
3643
|
+
logFn(`[EC:${ec}]`, "(unregistered)", _optionalChain([params, 'optionalAccess', _468 => _468.length]) ? params : "");
|
|
3631
3644
|
}
|
|
3632
3645
|
}
|
|
3633
3646
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, logError, "logError");
|
|
@@ -3655,14 +3668,14 @@ var ErrorCode_default = {
|
|
|
3655
3668
|
|
|
3656
3669
|
// src/sysserver/api/common/errorcodes.ts
|
|
3657
3670
|
var errorcodes_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3658
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3671
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _469 => _469.$lib, 'optionalAccess', _470 => _470.reqWork, 'optionalCall', _471 => _471($asai)]) || {};
|
|
3659
3672
|
function get(req, res, _hostdir, opt) {
|
|
3660
3673
|
const url = req.url || "";
|
|
3661
3674
|
if (url.startsWith("/api/sys/errorcodes/")) {
|
|
3662
3675
|
try {
|
|
3663
3676
|
return sendSuccess(res, loadErrorCodes($asai), opt);
|
|
3664
3677
|
} catch (err) {
|
|
3665
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3678
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _472 => _472.message]) || err, opt);
|
|
3666
3679
|
}
|
|
3667
3680
|
}
|
|
3668
3681
|
}
|
|
@@ -3672,9 +3685,9 @@ var errorcodes_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3672
3685
|
|
|
3673
3686
|
// src/sysserver/api/common/sqlitemanage.ts
|
|
3674
3687
|
var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3675
|
-
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'optionalAccess',
|
|
3688
|
+
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'optionalAccess', _473 => _473.$lib, 'optionalAccess', _474 => _474.reqWork, 'optionalCall', _475 => _475($asai)]) || {};
|
|
3676
3689
|
function mgLog(...arg) {
|
|
3677
|
-
_optionalChain([mnLog, 'optionalCall',
|
|
3690
|
+
_optionalChain([mnLog, 'optionalCall', _476 => _476("SQLite", ...arg)]);
|
|
3678
3691
|
}
|
|
3679
3692
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mgLog, "mgLog");
|
|
3680
3693
|
return $asai.$lib.AsDb($asai, {
|
|
@@ -3692,7 +3705,7 @@ var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
|
3692
3705
|
if (req.url.startsWith("/api/asaisqlite/manage/post")) {
|
|
3693
3706
|
try {
|
|
3694
3707
|
mgLog("POST", "custom handler triggered");
|
|
3695
|
-
_optionalChain([sendSuccess, 'optionalCall',
|
|
3708
|
+
_optionalChain([sendSuccess, 'optionalCall', _477 => _477(res, { data: "post" }, opt)]);
|
|
3696
3709
|
} catch (err) {
|
|
3697
3710
|
mgLog("ERROR", "post handler", err);
|
|
3698
3711
|
}
|
|
@@ -3709,10 +3722,10 @@ var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
|
3709
3722
|
table: dataObj.table
|
|
3710
3723
|
});
|
|
3711
3724
|
mgLog("SELECT", "completed");
|
|
3712
|
-
_optionalChain([sendSuccess, 'optionalCall',
|
|
3725
|
+
_optionalChain([sendSuccess, 'optionalCall', _478 => _478(res, resdb, opt)]);
|
|
3713
3726
|
} catch (errdb) {
|
|
3714
3727
|
mgLog("ERROR", "select", errdb);
|
|
3715
|
-
_optionalChain([sendFail, 'optionalCall',
|
|
3728
|
+
_optionalChain([sendFail, 'optionalCall', _479 => _479(res, errdb, opt)]);
|
|
3716
3729
|
}
|
|
3717
3730
|
return "ok";
|
|
3718
3731
|
}
|
|
@@ -3728,7 +3741,7 @@ function promLine(name, value, labels) {
|
|
|
3728
3741
|
}
|
|
3729
3742
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, promLine, "promLine");
|
|
3730
3743
|
var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3731
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3744
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _480 => _480.$lib, 'optionalAccess', _481 => _481.reqWork, 'optionalCall', _482 => _482($asai)]) || {};
|
|
3732
3745
|
async function get(req, res, _hostdir, opt) {
|
|
3733
3746
|
const url = req.url || "";
|
|
3734
3747
|
if (url.startsWith("/api/sys/health/metrics/")) {
|
|
@@ -3737,10 +3750,10 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3737
3750
|
let httpTotal = 0;
|
|
3738
3751
|
let wsTotal = 0;
|
|
3739
3752
|
for (const set of Object.values($asai.connectionshttp || {})) {
|
|
3740
|
-
httpTotal += _optionalChain([set, 'optionalAccess',
|
|
3753
|
+
httpTotal += _optionalChain([set, 'optionalAccess', _483 => _483.size]) || 0;
|
|
3741
3754
|
}
|
|
3742
3755
|
for (const set of Object.values($asai.connectionsws || {})) {
|
|
3743
|
-
wsTotal += _optionalChain([set, 'optionalAccess',
|
|
3756
|
+
wsTotal += _optionalChain([set, 'optionalAccess', _484 => _484.size]) || 0;
|
|
3744
3757
|
}
|
|
3745
3758
|
const lines = [
|
|
3746
3759
|
"# HELP asai_uptime_seconds Process uptime",
|
|
@@ -3762,7 +3775,7 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3762
3775
|
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
3763
3776
|
return res.end(lines.join("\n") + "\n");
|
|
3764
3777
|
} catch (err) {
|
|
3765
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3778
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _485 => _485.message]) || err, opt);
|
|
3766
3779
|
}
|
|
3767
3780
|
}
|
|
3768
3781
|
if (url.startsWith("/api/sys/health/status/")) {
|
|
@@ -3775,10 +3788,10 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3775
3788
|
memory: process.memoryUsage(),
|
|
3776
3789
|
quota: {
|
|
3777
3790
|
http: Object.fromEntries(
|
|
3778
|
-
Object.entries($asai.connectionshttp || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess',
|
|
3791
|
+
Object.entries($asai.connectionshttp || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess', _486 => _486.size]) || 0])
|
|
3779
3792
|
),
|
|
3780
3793
|
ws: Object.fromEntries(
|
|
3781
|
-
Object.entries($asai.connectionsws || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess',
|
|
3794
|
+
Object.entries($asai.connectionsws || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess', _487 => _487.size]) || 0])
|
|
3782
3795
|
)
|
|
3783
3796
|
}
|
|
3784
3797
|
},
|
|
@@ -3819,7 +3832,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, sanitizeString, "sanitizeString");
|
|
|
3819
3832
|
// src/sysserver/api/login/service/session.ts
|
|
3820
3833
|
|
|
3821
3834
|
function getSessionTtlMs($asai) {
|
|
3822
|
-
const hours = _nullishCoalesce(_optionalChain([$asai, 'optionalAccess',
|
|
3835
|
+
const hours = _nullishCoalesce(_optionalChain([$asai, 'optionalAccess', _488 => _488.hostconfig, 'optionalAccess', _489 => _489.security, 'optionalAccess', _490 => _490.sessionTtlHours]), () => ( 24));
|
|
3823
3836
|
return Number(hours) * 3600 * 1e3;
|
|
3824
3837
|
}
|
|
3825
3838
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSessionTtlMs, "getSessionTtlMs");
|
|
@@ -3836,7 +3849,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, generatePriKey, "generatePriKey");
|
|
|
3836
3849
|
function createSessionKeys($asai) {
|
|
3837
3850
|
const sessionId = _crypto.randomUUID.call(void 0, );
|
|
3838
3851
|
const pri = generatePriKey();
|
|
3839
|
-
const sn = _optionalChain([$asai, 'optionalAccess',
|
|
3852
|
+
const sn = _optionalChain([$asai, 'optionalAccess', _491 => _491.hostconfig, 'optionalAccess', _492 => _492.asaisn]);
|
|
3840
3853
|
if (!sn) throw new Error("[session] ASAI_ASAISN \u672A\u914D\u7F6E");
|
|
3841
3854
|
const pub = $asai.$lib.AsCode.asencode(pri, sn);
|
|
3842
3855
|
return { pri, pub, sessionId };
|
|
@@ -3863,9 +3876,9 @@ var API_ADMIN_PREFIXES = ["/api/user/login/admin/"];
|
|
|
3863
3876
|
function getMinLevelForApiPath(pathname, $asai) {
|
|
3864
3877
|
if (API_ADMIN_PREFIXES.some((p) => pathname.startsWith(p))) {
|
|
3865
3878
|
if (pathname.includes("/admin/update") || pathname.includes("/admin/kick") || pathname.includes("/admin/delete") || pathname.includes("/admin/resetpass")) {
|
|
3866
|
-
return $asai ?
|
|
3879
|
+
return $asai ? _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite") : _chunkZK4O4Z2Ocjs.USER_LV.DEVELOPER;
|
|
3867
3880
|
}
|
|
3868
|
-
return $asai ?
|
|
3881
|
+
return $asai ? _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminRead") : _chunkZK4O4Z2Ocjs.USER_LV.ADMIN;
|
|
3869
3882
|
}
|
|
3870
3883
|
return 0;
|
|
3871
3884
|
}
|
|
@@ -3892,7 +3905,7 @@ function unwrapJsonString(value) {
|
|
|
3892
3905
|
}
|
|
3893
3906
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, unwrapJsonString, "unwrapJsonString");
|
|
3894
3907
|
function parseAuthBody(opt) {
|
|
3895
|
-
let raw = _optionalChain([opt, 'optionalAccess',
|
|
3908
|
+
let raw = _optionalChain([opt, 'optionalAccess', _493 => _493.data]);
|
|
3896
3909
|
if (raw == null || raw === "") return {};
|
|
3897
3910
|
if (typeof raw === "string") {
|
|
3898
3911
|
const text = raw.trim();
|
|
@@ -3968,7 +3981,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, purgeOfflineSessions, "purgeOfflineSession
|
|
|
3968
3981
|
|
|
3969
3982
|
// src/sysserver/api/login/index.ts
|
|
3970
3983
|
function getSecurity($asai) {
|
|
3971
|
-
return _optionalChain([$asai, 'optionalAccess',
|
|
3984
|
+
return _optionalChain([$asai, 'optionalAccess', _494 => _494.hostconfig, 'optionalAccess', _495 => _495.security]) || {};
|
|
3972
3985
|
}
|
|
3973
3986
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSecurity, "getSecurity");
|
|
3974
3987
|
function getQuota2($asai) {
|
|
@@ -3979,9 +3992,9 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, getQuota2, "getQuota");
|
|
|
3979
3992
|
async function canLogin($asai, us, hostdir) {
|
|
3980
3993
|
const quota = getQuota2($asai);
|
|
3981
3994
|
if (!quota.enabled) return { ok: true };
|
|
3982
|
-
const store =
|
|
3995
|
+
const store = _chunkZK4O4Z2Ocjs.createUserStore.call(void 0, $asai);
|
|
3983
3996
|
const total = await countOnlineSessions($asai, hostdir, store);
|
|
3984
|
-
const maxLogin = _nullishCoalesce(_nullishCoalesce(quota.maxLoginSessions, () => ( _optionalChain([$asai, 'optionalAccess',
|
|
3997
|
+
const maxLogin = _nullishCoalesce(_nullishCoalesce(quota.maxLoginSessions, () => ( _optionalChain([$asai, 'optionalAccess', _496 => _496.hostconfig, 'optionalAccess', _497 => _497.hosts, 'optionalAccess', _498 => _498.default, 'optionalAccess', _499 => _499.maxonline]))), () => ( 100));
|
|
3985
3998
|
if (total >= maxLogin) {
|
|
3986
3999
|
return { ok: false, message: "LOGIN_QUOTA_FULL" };
|
|
3987
4000
|
}
|
|
@@ -3994,7 +4007,7 @@ async function canLogin($asai, us, hostdir) {
|
|
|
3994
4007
|
}
|
|
3995
4008
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, canLogin, "canLogin");
|
|
3996
4009
|
function publicUser($asai, user) {
|
|
3997
|
-
const role = user.role ||
|
|
4010
|
+
const role = user.role || _chunkGXOFLFFWcjs.resolveRoleForLevel.call(void 0, $asai, user.lv).name;
|
|
3998
4011
|
return {
|
|
3999
4012
|
us: user.us,
|
|
4000
4013
|
lv: user.lv,
|
|
@@ -4008,14 +4021,14 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, publicUser, "publicUser");
|
|
|
4008
4021
|
var bootstrapPromise = null;
|
|
4009
4022
|
function ensureReady($asai) {
|
|
4010
4023
|
if (!bootstrapPromise) {
|
|
4011
|
-
bootstrapPromise = Promise.all([
|
|
4024
|
+
bootstrapPromise = Promise.all([_chunkZK4O4Z2Ocjs.ensureBootstrapAdmin.call(void 0, $asai), _chunkGXOFLFFWcjs.loadUserLevelConfig.call(void 0, $asai)]).then(() => void 0);
|
|
4012
4025
|
}
|
|
4013
4026
|
return bootstrapPromise;
|
|
4014
4027
|
}
|
|
4015
4028
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, ensureReady, "ensureReady");
|
|
4016
4029
|
var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
4017
|
-
const { sendSuccess, sendFail, sendErr } = _optionalChain([$asai, 'access',
|
|
4018
|
-
const store =
|
|
4030
|
+
const { sendSuccess, sendFail, sendErr } = _optionalChain([$asai, 'access', _500 => _500.$lib, 'optionalAccess', _501 => _501.reqWork, 'optionalCall', _502 => _502($asai)]) || {};
|
|
4031
|
+
const store = _chunkZK4O4Z2Ocjs.createUserStore.call(void 0, $asai);
|
|
4019
4032
|
async function checkAdmin(req, pathname, minOverride) {
|
|
4020
4033
|
await attachServerUserLevel(req, $asai);
|
|
4021
4034
|
const minLv = _nullishCoalesce(minOverride, () => ( getMinLevelForApiPath(pathname, $asai)));
|
|
@@ -4034,17 +4047,17 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4034
4047
|
const newPass = sanitizeString(pickAuthField(body, "newPass", "newPassword", "newpass"), 128);
|
|
4035
4048
|
if (!us || !pass || !newPass) return sendErr(res, "AUTH_CREDENTIALS_REQUIRED", void 0, opt);
|
|
4036
4049
|
const user = await store.findByUsername(us);
|
|
4037
|
-
if (!user || !
|
|
4050
|
+
if (!user || !_chunkWXW5DYNUcjs.verifyPassword.call(void 0, pass, user.passHash, user.passSalt)) {
|
|
4038
4051
|
return sendErr(res, "AUTH_INVALID_CREDENTIALS", void 0, opt);
|
|
4039
4052
|
}
|
|
4040
|
-
const policy =
|
|
4041
|
-
const policyErr =
|
|
4053
|
+
const policy = _chunkGXOFLFFWcjs.getPasswordPolicy.call(void 0, $asai);
|
|
4054
|
+
const policyErr = _chunkWXW5DYNUcjs.validatePasswordChange.call(void 0, newPass, $asai, user.passHistory);
|
|
4042
4055
|
if (policyErr === "PASSWORD_TOO_SHORT") {
|
|
4043
4056
|
return sendErr(res, policyErr, [String(policy.minLength)], opt);
|
|
4044
4057
|
}
|
|
4045
4058
|
if (policyErr) return sendErr(res, policyErr, void 0, opt);
|
|
4046
|
-
const { passHash, passSalt } =
|
|
4047
|
-
const passHistory =
|
|
4059
|
+
const { passHash, passSalt } = _chunkWXW5DYNUcjs.hashPassword.call(void 0, newPass);
|
|
4060
|
+
const passHistory = _chunkWXW5DYNUcjs.nextPassHistory.call(void 0, pass, user.passHistory, policy.historyCount);
|
|
4048
4061
|
await store.updateUser(us, {
|
|
4049
4062
|
passHash,
|
|
4050
4063
|
passSalt,
|
|
@@ -4052,10 +4065,10 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4052
4065
|
passwordChangedAt: Date.now(),
|
|
4053
4066
|
passHistory
|
|
4054
4067
|
});
|
|
4055
|
-
logSecurityEvent($asai, { type: "
|
|
4068
|
+
logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: us, ip, detail: "password_changed" });
|
|
4056
4069
|
return sendSuccess(res, { ok: true }, opt);
|
|
4057
4070
|
} catch (err) {
|
|
4058
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4071
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _503 => _503.message]) || err, opt);
|
|
4059
4072
|
}
|
|
4060
4073
|
}
|
|
4061
4074
|
if (url.startsWith("/api/user/login/register/")) {
|
|
@@ -4070,12 +4083,12 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4070
4083
|
const emailRaw = pickAuthField(body, "email");
|
|
4071
4084
|
const email = emailRaw ? sanitizeString(emailRaw, 128) : void 0;
|
|
4072
4085
|
if (!us || !pass) return sendErr(res, "AUTH_CREDENTIALS_REQUIRED", void 0, opt);
|
|
4073
|
-
const policyErr =
|
|
4086
|
+
const policyErr = _chunkWXW5DYNUcjs.validatePasswordChange.call(void 0, pass, $asai);
|
|
4074
4087
|
if (policyErr === "PASSWORD_TOO_SHORT") {
|
|
4075
|
-
return sendErr(res, policyErr, [String(
|
|
4088
|
+
return sendErr(res, policyErr, [String(_chunkGXOFLFFWcjs.getPasswordPolicy.call(void 0, $asai).minLength)], opt);
|
|
4076
4089
|
}
|
|
4077
4090
|
if (policyErr) return sendErr(res, policyErr, void 0, opt);
|
|
4078
|
-
const { passHash, passSalt } =
|
|
4091
|
+
const { passHash, passSalt } = _chunkWXW5DYNUcjs.hashPassword.call(void 0, pass);
|
|
4079
4092
|
const user = await store.createUser({
|
|
4080
4093
|
us,
|
|
4081
4094
|
email,
|
|
@@ -4085,14 +4098,14 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4085
4098
|
passwordChangedAt: Date.now(),
|
|
4086
4099
|
passHistory: "[]"
|
|
4087
4100
|
});
|
|
4088
|
-
logSecurityEvent($asai, { type: "
|
|
4101
|
+
logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: us, ip, detail: "register_ok" });
|
|
4089
4102
|
return sendSuccess(res, { user: publicUser($asai, user) }, opt);
|
|
4090
4103
|
} catch (err) {
|
|
4091
|
-
const msg = _optionalChain([err, 'optionalAccess',
|
|
4104
|
+
const msg = _optionalChain([err, 'optionalAccess', _504 => _504.message]) || String(err);
|
|
4092
4105
|
if (msg.includes("exists") || msg.includes("\u5DF2\u5B58\u5728")) {
|
|
4093
4106
|
return sendErr(res, "USER_ALREADY_EXISTS", void 0, opt);
|
|
4094
4107
|
}
|
|
4095
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4108
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _505 => _505.message]) || err, opt);
|
|
4096
4109
|
}
|
|
4097
4110
|
}
|
|
4098
4111
|
if (url.startsWith("/api/user/login/auth/")) {
|
|
@@ -4102,7 +4115,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4102
4115
|
const pass = sanitizeString(pickAuthField(body, "pass", "password", "pwd"), 128);
|
|
4103
4116
|
if (!us || !pass) return sendErr(res, "AUTH_CREDENTIALS_REQUIRED", void 0, opt);
|
|
4104
4117
|
const user = await store.findByUsername(us);
|
|
4105
|
-
if (!user || !
|
|
4118
|
+
if (!user || !_chunkWXW5DYNUcjs.verifyPassword.call(void 0, pass, user.passHash, user.passSalt)) {
|
|
4106
4119
|
if (user) {
|
|
4107
4120
|
const sec = getSecurity($asai);
|
|
4108
4121
|
const lockoutMax = _nullishCoalesce(sec.lockoutMaxFails, () => ( 5));
|
|
@@ -4124,9 +4137,9 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4124
4137
|
if (user.status === "locked" && user.lockedUntil && user.lockedUntil > Date.now()) {
|
|
4125
4138
|
return sendErr(res, "AUTH_ACCOUNT_LOCKED", void 0, opt);
|
|
4126
4139
|
}
|
|
4127
|
-
const policy =
|
|
4128
|
-
const mustChange = !!user.mustChangePassword ||
|
|
4129
|
-
const hostcfg = _optionalChain([$asai, 'access',
|
|
4140
|
+
const policy = _chunkGXOFLFFWcjs.getPasswordPolicy.call(void 0, $asai);
|
|
4141
|
+
const mustChange = !!user.mustChangePassword || _chunkGXOFLFFWcjs.isPasswordExpired.call(void 0, user.passwordChangedAt, policy.maxAgeDays);
|
|
4142
|
+
const hostcfg = _optionalChain([$asai, 'access', _506 => _506.getHost, 'optionalCall', _507 => _507(hostdir)]) || {};
|
|
4130
4143
|
if (hostcfg.ckws && isUserOnlineOnWs($asai, us, hostdir)) {
|
|
4131
4144
|
kickUserWs($asai, us, hostdir);
|
|
4132
4145
|
}
|
|
@@ -4139,7 +4152,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4139
4152
|
const session = buildSessionRecord($asai, us, ip);
|
|
4140
4153
|
session.lastActivityAt = Date.now();
|
|
4141
4154
|
await store.addSession(session);
|
|
4142
|
-
logSecurityEvent($asai, { type: "
|
|
4155
|
+
logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: us, ip, detail: "login_ok" });
|
|
4143
4156
|
return sendSuccess(
|
|
4144
4157
|
res,
|
|
4145
4158
|
{
|
|
@@ -4151,22 +4164,31 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4151
4164
|
opt
|
|
4152
4165
|
);
|
|
4153
4166
|
} catch (err) {
|
|
4154
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4167
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _508 => _508.message]) || err, opt);
|
|
4155
4168
|
}
|
|
4156
4169
|
}
|
|
4157
4170
|
if (url.startsWith("/api/user/login/logout/")) {
|
|
4158
4171
|
try {
|
|
4159
4172
|
const bodySid = body.sessionId ? sanitizeString(body.sessionId, 64) : "";
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4173
|
+
const us = _optionalChain([req, 'optionalAccess', _509 => _509.Userinfo, 'optionalAccess', _510 => _510[0]]);
|
|
4174
|
+
if (bodySid) {
|
|
4175
|
+
if (!us) {
|
|
4176
|
+
return sendErr(res, "AUTH_MISSING", void 0, opt);
|
|
4177
|
+
}
|
|
4178
|
+
const sessions = await store.getSessions();
|
|
4179
|
+
const target = sessions.find((s) => s.id === bodySid);
|
|
4180
|
+
if (target && target.us === us) {
|
|
4181
|
+
await store.removeSession(bodySid);
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
if (us) logSecurityEvent($asai, { type: "AUTH_SUCCESS", path: url, method: "POST", user: String(us), ip, detail: "logout" });
|
|
4163
4185
|
return sendSuccess(res, "ok", opt);
|
|
4164
4186
|
} catch (err) {
|
|
4165
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4187
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _511 => _511.message]) || err, opt);
|
|
4166
4188
|
}
|
|
4167
4189
|
}
|
|
4168
4190
|
if (url.startsWith("/api/user/login/admin/kick/")) {
|
|
4169
|
-
if (!await checkAdmin(req, url,
|
|
4191
|
+
if (!await checkAdmin(req, url, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite"))) {
|
|
4170
4192
|
return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4171
4193
|
}
|
|
4172
4194
|
try {
|
|
@@ -4180,8 +4202,8 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4180
4202
|
}
|
|
4181
4203
|
kickUserWs($asai, target.us, hostdir);
|
|
4182
4204
|
await store.removeSession(sessionId);
|
|
4183
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4184
|
-
await
|
|
4205
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _512 => _512.Userinfo, 'optionalAccess', _513 => _513[0]]) || "");
|
|
4206
|
+
await _chunkARHPHWT5cjs.logSessionTerminate.call(void 0, $asai, {
|
|
4185
4207
|
operator,
|
|
4186
4208
|
sessionId,
|
|
4187
4209
|
targetUs: target.us,
|
|
@@ -4189,11 +4211,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4189
4211
|
});
|
|
4190
4212
|
return sendSuccess(res, { ok: true }, opt);
|
|
4191
4213
|
} catch (err) {
|
|
4192
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4214
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _514 => _514.message]) || err, opt);
|
|
4193
4215
|
}
|
|
4194
4216
|
}
|
|
4195
4217
|
if (url.startsWith("/api/user/login/admin/delete/")) {
|
|
4196
|
-
if (!await checkAdmin(req, url,
|
|
4218
|
+
if (!await checkAdmin(req, url, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite"))) {
|
|
4197
4219
|
return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4198
4220
|
}
|
|
4199
4221
|
try {
|
|
@@ -4201,15 +4223,15 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4201
4223
|
if (!targetUs || targetUs === "admin") return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4202
4224
|
const ok = await store.deleteUser(targetUs);
|
|
4203
4225
|
if (!ok) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4204
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4205
|
-
await
|
|
4226
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _515 => _515.Userinfo, 'optionalAccess', _516 => _516[0]]) || "");
|
|
4227
|
+
await _chunkARHPHWT5cjs.logAccountPurge.call(void 0, $asai, { operator, targetUs, ip });
|
|
4206
4228
|
return sendSuccess(res, { ok: true }, opt);
|
|
4207
4229
|
} catch (err) {
|
|
4208
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4230
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _517 => _517.message]) || err, opt);
|
|
4209
4231
|
}
|
|
4210
4232
|
}
|
|
4211
4233
|
if (url.startsWith("/api/user/login/admin/levels/")) {
|
|
4212
|
-
if (!await checkAdmin(req, url,
|
|
4234
|
+
if (!await checkAdmin(req, url, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite"))) {
|
|
4213
4235
|
return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4214
4236
|
}
|
|
4215
4237
|
try {
|
|
@@ -4217,8 +4239,8 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4217
4239
|
const thresholds = body.thresholds && typeof body.thresholds === "object" ? body.thresholds : void 0;
|
|
4218
4240
|
const routeRights = Array.isArray(body.routeRights) ? body.routeRights : void 0;
|
|
4219
4241
|
const defaultResetPassword = typeof body.defaultResetPassword === "string" ? body.defaultResetPassword : void 0;
|
|
4220
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4221
|
-
const cfg = await
|
|
4242
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _518 => _518.Userinfo, 'optionalAccess', _519 => _519[0]]) || "");
|
|
4243
|
+
const cfg = await _chunkGXOFLFFWcjs.saveUserLevelConfig.call(void 0,
|
|
4222
4244
|
$asai,
|
|
4223
4245
|
{
|
|
4224
4246
|
levels,
|
|
@@ -4228,20 +4250,20 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4228
4250
|
},
|
|
4229
4251
|
operator
|
|
4230
4252
|
);
|
|
4231
|
-
await
|
|
4253
|
+
await _chunkARHPHWT5cjs.logSecurityConfigIntervention.call(void 0, $asai, {
|
|
4232
4254
|
section: "user_levels",
|
|
4233
|
-
detail: JSON.stringify({ levels: _optionalChain([levels, 'optionalAccess',
|
|
4255
|
+
detail: JSON.stringify({ levels: _optionalChain([levels, 'optionalAccess', _520 => _520.length]), thresholds: !!thresholds, routeRights: _optionalChain([routeRights, 'optionalAccess', _521 => _521.length]) }),
|
|
4234
4256
|
operator,
|
|
4235
4257
|
ip
|
|
4236
4258
|
});
|
|
4237
4259
|
return sendSuccess(res, cfg, opt);
|
|
4238
4260
|
} catch (err) {
|
|
4239
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4261
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _522 => _522.message]) || err, opt);
|
|
4240
4262
|
}
|
|
4241
4263
|
}
|
|
4242
4264
|
if (url.startsWith("/api/user/login/admin/resetpass/")) {
|
|
4243
4265
|
await ensureReady($asai);
|
|
4244
|
-
if (!await checkAdmin(req, url,
|
|
4266
|
+
if (!await checkAdmin(req, url, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminWrite"))) {
|
|
4245
4267
|
logSecurityEvent($asai, { type: "ACCESS_DENIED", path: url, method: "POST", ip });
|
|
4246
4268
|
return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4247
4269
|
}
|
|
@@ -4249,16 +4271,16 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4249
4271
|
const targetUs = sanitizeString(body.us, 64);
|
|
4250
4272
|
if (!targetUs) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4251
4273
|
let newPass = sanitizeString(pickAuthField(body, "newPass", "newPassword", "newpass"), 128);
|
|
4252
|
-
if (!newPass) newPass =
|
|
4253
|
-
const policy =
|
|
4254
|
-
const policyErr =
|
|
4274
|
+
if (!newPass) newPass = _chunkGXOFLFFWcjs.getDefaultResetPassword.call(void 0, $asai);
|
|
4275
|
+
const policy = _chunkGXOFLFFWcjs.getPasswordPolicy.call(void 0, $asai);
|
|
4276
|
+
const policyErr = _chunkGXOFLFFWcjs.validatePasswordWithPolicy.call(void 0, newPass, policy);
|
|
4255
4277
|
if (policyErr === "PASSWORD_TOO_SHORT") {
|
|
4256
4278
|
return sendErr(res, policyErr, [String(policy.minLength)], opt);
|
|
4257
4279
|
}
|
|
4258
4280
|
if (policyErr) return sendErr(res, policyErr, void 0, opt);
|
|
4259
4281
|
const user = await store.findByUsername(targetUs);
|
|
4260
4282
|
if (!user) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4261
|
-
const { passHash, passSalt } =
|
|
4283
|
+
const { passHash, passSalt } = _chunkWXW5DYNUcjs.hashPassword.call(void 0, newPass);
|
|
4262
4284
|
const updated = await store.updateUser(targetUs, {
|
|
4263
4285
|
passHash,
|
|
4264
4286
|
passSalt,
|
|
@@ -4270,8 +4292,8 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4270
4292
|
passHistory: "[]"
|
|
4271
4293
|
});
|
|
4272
4294
|
if (!updated) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4273
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4274
|
-
await
|
|
4295
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _523 => _523.Userinfo, 'optionalAccess', _524 => _524[0]]) || "");
|
|
4296
|
+
await _chunkARHPHWT5cjs.logUserRbacChange.call(void 0, $asai, {
|
|
4275
4297
|
operator,
|
|
4276
4298
|
targetUs,
|
|
4277
4299
|
patch: { resetPassword: true, mustChangePassword: 1 },
|
|
@@ -4287,7 +4309,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4287
4309
|
});
|
|
4288
4310
|
return sendSuccess(res, { user: publicUser($asai, updated) }, opt);
|
|
4289
4311
|
} catch (err) {
|
|
4290
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4312
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _525 => _525.message]) || err, opt);
|
|
4291
4313
|
}
|
|
4292
4314
|
}
|
|
4293
4315
|
if (url.startsWith("/api/user/login/admin/update/")) {
|
|
@@ -4301,11 +4323,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4301
4323
|
const patch = {};
|
|
4302
4324
|
if (body.lv != null) {
|
|
4303
4325
|
const newLv = Number(body.lv);
|
|
4304
|
-
if (!Number.isFinite(newLv) || !
|
|
4326
|
+
if (!Number.isFinite(newLv) || !_chunkGXOFLFFWcjs.isValidUserLv.call(void 0, $asai, newLv)) {
|
|
4305
4327
|
return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4306
4328
|
}
|
|
4307
4329
|
patch.lv = newLv;
|
|
4308
|
-
patch.role =
|
|
4330
|
+
patch.role = _chunkGXOFLFFWcjs.resolveRoleForLevel.call(void 0, $asai, newLv).name;
|
|
4309
4331
|
}
|
|
4310
4332
|
if (body.status) patch.status = sanitizeString(body.status, 16);
|
|
4311
4333
|
if (body.resetLock) {
|
|
@@ -4317,8 +4339,8 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4317
4339
|
const updated = await store.updateUser(targetUs, patch);
|
|
4318
4340
|
if (!updated) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4319
4341
|
if (Object.keys(patch).length) {
|
|
4320
|
-
await
|
|
4321
|
-
operator: String(_optionalChain([req, 'optionalAccess',
|
|
4342
|
+
await _chunkARHPHWT5cjs.logUserRbacChange.call(void 0, $asai, {
|
|
4343
|
+
operator: String(_optionalChain([req, 'optionalAccess', _526 => _526.Userinfo, 'optionalAccess', _527 => _527[0]]) || ""),
|
|
4322
4344
|
targetUs,
|
|
4323
4345
|
patch,
|
|
4324
4346
|
ip
|
|
@@ -4326,33 +4348,33 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4326
4348
|
}
|
|
4327
4349
|
return sendSuccess(res, { user: publicUser($asai, updated) }, opt);
|
|
4328
4350
|
} catch (err) {
|
|
4329
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4351
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _528 => _528.message]) || err, opt);
|
|
4330
4352
|
}
|
|
4331
4353
|
}
|
|
4332
4354
|
if (url.startsWith("/api/user/login/profile/")) {
|
|
4333
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4355
|
+
const us = _optionalChain([req, 'optionalAccess', _529 => _529.Userinfo, 'optionalAccess', _530 => _530[0]]);
|
|
4334
4356
|
if (!us) return sendErr(res, "AUTH_UNAUTHORIZED", void 0, opt);
|
|
4335
4357
|
try {
|
|
4336
4358
|
const user = await store.findByUsername(String(us));
|
|
4337
4359
|
if (!user) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4338
4360
|
if (pickAuthField(body, "newPass", "newPassword", "newpass")) {
|
|
4339
4361
|
const newPass = sanitizeString(pickAuthField(body, "newPass", "newPassword", "newpass"), 128);
|
|
4340
|
-
const policy =
|
|
4362
|
+
const policy = _chunkGXOFLFFWcjs.getPasswordPolicy.call(void 0, $asai);
|
|
4341
4363
|
const oldPass = pickAuthField(body, "pass", "password", "pwd");
|
|
4342
4364
|
if (oldPass) {
|
|
4343
|
-
if (!
|
|
4365
|
+
if (!_chunkWXW5DYNUcjs.verifyPassword.call(void 0, oldPass, user.passHash, user.passSalt)) {
|
|
4344
4366
|
return sendErr(res, "AUTH_INVALID_PASSWORD", void 0, opt);
|
|
4345
4367
|
}
|
|
4346
4368
|
} else if (!user.mustChangePassword) {
|
|
4347
4369
|
return sendErr(res, "AUTH_INVALID_PASSWORD", void 0, opt);
|
|
4348
4370
|
}
|
|
4349
|
-
const policyErr =
|
|
4371
|
+
const policyErr = _chunkWXW5DYNUcjs.validatePasswordChange.call(void 0, newPass, $asai, user.passHistory);
|
|
4350
4372
|
if (policyErr === "PASSWORD_TOO_SHORT") {
|
|
4351
4373
|
return sendErr(res, policyErr, [String(policy.minLength)], opt);
|
|
4352
4374
|
}
|
|
4353
4375
|
if (policyErr) return sendErr(res, policyErr, void 0, opt);
|
|
4354
|
-
const { passHash, passSalt } =
|
|
4355
|
-
const passHistory =
|
|
4376
|
+
const { passHash, passSalt } = _chunkWXW5DYNUcjs.hashPassword.call(void 0, newPass);
|
|
4377
|
+
const passHistory = _chunkWXW5DYNUcjs.nextPassHistory.call(void 0, oldPass || newPass, user.passHistory, policy.historyCount);
|
|
4356
4378
|
await store.updateUser(String(us), {
|
|
4357
4379
|
passHash,
|
|
4358
4380
|
passSalt,
|
|
@@ -4364,7 +4386,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4364
4386
|
const fresh = await store.findByUsername(String(us));
|
|
4365
4387
|
return sendSuccess(res, { user: fresh ? publicUser($asai, fresh) : null }, opt);
|
|
4366
4388
|
} catch (err) {
|
|
4367
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4389
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _531 => _531.message]) || err, opt);
|
|
4368
4390
|
}
|
|
4369
4391
|
}
|
|
4370
4392
|
}
|
|
@@ -4373,16 +4395,16 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4373
4395
|
const url = req.url || "";
|
|
4374
4396
|
const ip = getClientIp(req);
|
|
4375
4397
|
if (url.startsWith("/api/user/login/config/")) {
|
|
4376
|
-
const lang = String(_optionalChain([req, 'optionalAccess',
|
|
4377
|
-
await
|
|
4378
|
-
return sendSuccess(res,
|
|
4398
|
+
const lang = String(_optionalChain([req, 'optionalAccess', _532 => _532.headers, 'optionalAccess', _533 => _533["accept-language"]]) || _optionalChain([opt, 'optionalAccess', _534 => _534.headers, 'optionalAccess', _535 => _535["accept-language"]]) || "zh-CN").split(",")[0];
|
|
4399
|
+
await _chunkGXOFLFFWcjs.loadUserLevelConfig.call(void 0, $asai);
|
|
4400
|
+
return sendSuccess(res, _chunkGXOFLFFWcjs.getPublicSecurityConfig.call(void 0, $asai, lang), opt);
|
|
4379
4401
|
}
|
|
4380
4402
|
if (url.startsWith("/api/user/login/admin/levels/")) {
|
|
4381
|
-
if (!await checkAdmin(req, url,
|
|
4403
|
+
if (!await checkAdmin(req, url, _chunkGXOFLFFWcjs.getPermissionThreshold.call(void 0, $asai, "adminRead"))) {
|
|
4382
4404
|
return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4383
4405
|
}
|
|
4384
|
-
await
|
|
4385
|
-
return sendSuccess(res,
|
|
4406
|
+
await _chunkGXOFLFFWcjs.loadUserLevelConfig.call(void 0, $asai);
|
|
4407
|
+
return sendSuccess(res, _chunkGXOFLFFWcjs.getUserLevelConfigSync.call(void 0, $asai), opt);
|
|
4386
4408
|
}
|
|
4387
4409
|
if (url.startsWith("/api/user/login/admin/sessions/")) {
|
|
4388
4410
|
if (!await checkAdmin(req, url)) {
|
|
@@ -4434,7 +4456,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4434
4456
|
);
|
|
4435
4457
|
}
|
|
4436
4458
|
if (url.startsWith("/api/user/login/profile/")) {
|
|
4437
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4459
|
+
const us = _optionalChain([req, 'optionalAccess', _536 => _536.Userinfo, 'optionalAccess', _537 => _537[0]]);
|
|
4438
4460
|
if (!us) return sendErr(res, "AUTH_UNAUTHORIZED", void 0, opt);
|
|
4439
4461
|
const user = await store.findByUsername(String(us));
|
|
4440
4462
|
return sendSuccess(res, { user: user ? publicUser($asai, user) : null }, opt);
|
|
@@ -4476,16 +4498,16 @@ var As_default = {
|
|
|
4476
4498
|
return { code: 908, data: val };
|
|
4477
4499
|
},
|
|
4478
4500
|
ctxSuccess(val, opt = null) {
|
|
4479
|
-
if (typeof _optionalChain([opt, 'optionalAccess',
|
|
4501
|
+
if (typeof _optionalChain([opt, 'optionalAccess', _538 => _538.resAES]) === "function") {
|
|
4480
4502
|
val = opt.resAES(val);
|
|
4481
4503
|
}
|
|
4482
4504
|
return { code: 909, data: val };
|
|
4483
4505
|
},
|
|
4484
4506
|
getPath(str = "-") {
|
|
4485
|
-
return _optionalChain([str, 'optionalAccess',
|
|
4507
|
+
return _optionalChain([str, 'optionalAccess', _539 => _539.replace, 'call', _540 => _540(/[^a-zA-Z0-9.\-_\\\/]/g, "")]);
|
|
4486
4508
|
},
|
|
4487
4509
|
getName(str = "-") {
|
|
4488
|
-
return _optionalChain([str, 'optionalAccess',
|
|
4510
|
+
return _optionalChain([str, 'optionalAccess', _541 => _541.replace, 'call', _542 => _542(/[^a-zA-Z0-9.\-_]/g, "")]);
|
|
4489
4511
|
},
|
|
4490
4512
|
toDirPath(relativePath) {
|
|
4491
4513
|
const pathArr = relativePath.split("/");
|
|
@@ -4499,10 +4521,10 @@ var As_default = {
|
|
|
4499
4521
|
return relativePath;
|
|
4500
4522
|
},
|
|
4501
4523
|
//创建多层文件夹 同步
|
|
4502
|
-
ensureDir(
|
|
4524
|
+
ensureDir(fs11, relativePath) {
|
|
4503
4525
|
const absPathDir = this.toDirPath(relativePath);
|
|
4504
4526
|
const absPath = this.toAbsolutePath(relativePath);
|
|
4505
|
-
if (!
|
|
4527
|
+
if (!fs11.existsSync(absPath)) {
|
|
4506
4528
|
let pathTmp = "";
|
|
4507
4529
|
absPathDir.split("/").forEach((el) => {
|
|
4508
4530
|
if (el) {
|
|
@@ -4510,8 +4532,8 @@ var As_default = {
|
|
|
4510
4532
|
pathTmp += "/";
|
|
4511
4533
|
}
|
|
4512
4534
|
pathTmp += el;
|
|
4513
|
-
if (!
|
|
4514
|
-
if (!
|
|
4535
|
+
if (!fs11.existsSync(pathTmp)) {
|
|
4536
|
+
if (!fs11.mkdirSync(pathTmp, { recursive: true })) {
|
|
4515
4537
|
return absPath;
|
|
4516
4538
|
}
|
|
4517
4539
|
}
|
|
@@ -4520,11 +4542,11 @@ var As_default = {
|
|
|
4520
4542
|
}
|
|
4521
4543
|
return absPath;
|
|
4522
4544
|
},
|
|
4523
|
-
makeDir(
|
|
4524
|
-
return new Promise((
|
|
4545
|
+
makeDir(fs11, filePaths) {
|
|
4546
|
+
return new Promise((resolve5, reject) => {
|
|
4525
4547
|
try {
|
|
4526
|
-
const newPath = this.ensureDir(
|
|
4527
|
-
|
|
4548
|
+
const newPath = this.ensureDir(fs11, filePaths);
|
|
4549
|
+
resolve5(newPath);
|
|
4528
4550
|
} catch (err) {
|
|
4529
4551
|
reject(err);
|
|
4530
4552
|
}
|
|
@@ -4556,7 +4578,7 @@ var As_default = {
|
|
|
4556
4578
|
// immediate: false,
|
|
4557
4579
|
// });
|
|
4558
4580
|
dtImmediate(fn, opt) {
|
|
4559
|
-
if (_optionalChain([opt, 'optionalAccess',
|
|
4581
|
+
if (_optionalChain([opt, 'optionalAccess', _543 => _543.immediate])) {
|
|
4560
4582
|
fn();
|
|
4561
4583
|
opt.immediate = false;
|
|
4562
4584
|
}
|
|
@@ -4578,7 +4600,7 @@ var As_default = {
|
|
|
4578
4600
|
if (opt.endtime - opt.starttime < opt.wait) {
|
|
4579
4601
|
this.dtClearTimeout(opt);
|
|
4580
4602
|
}
|
|
4581
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
4603
|
+
if (!_optionalChain([opt, 'optionalAccess', _544 => _544.timeout])) {
|
|
4582
4604
|
opt.starttime = opt.endtime;
|
|
4583
4605
|
opt.timeout = this.dtSetTimeout(fn, opt);
|
|
4584
4606
|
}
|
|
@@ -4586,7 +4608,7 @@ var As_default = {
|
|
|
4586
4608
|
// 节流:指定长度时间内有多次触发,只fn最后一次触发
|
|
4587
4609
|
throttle(fn, opt) {
|
|
4588
4610
|
this.dtImmediate(fn, opt);
|
|
4589
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
4611
|
+
if (!_optionalChain([opt, 'optionalAccess', _545 => _545.timeout])) {
|
|
4590
4612
|
opt.timeout = this.dtSetTimeout(fn, opt);
|
|
4591
4613
|
}
|
|
4592
4614
|
},
|
|
@@ -4622,8 +4644,8 @@ var As_default = {
|
|
|
4622
4644
|
var AsCode_default = {
|
|
4623
4645
|
// 加密
|
|
4624
4646
|
asencode(str, keys) {
|
|
4625
|
-
const strlen = _optionalChain([str, 'optionalAccess',
|
|
4626
|
-
const keyslen = _optionalChain([keys, 'optionalAccess',
|
|
4647
|
+
const strlen = _optionalChain([str, 'optionalAccess', _546 => _546.length]) || 0;
|
|
4648
|
+
const keyslen = _optionalChain([keys, 'optionalAccess', _547 => _547.length]) || 0;
|
|
4627
4649
|
let newstr = "";
|
|
4628
4650
|
for (let i = 0; i < strlen; i++) {
|
|
4629
4651
|
const rnum = Math.round(Math.random() * 1e3) % keyslen;
|
|
@@ -4648,7 +4670,7 @@ var AsCode_default = {
|
|
|
4648
4670
|
const rnum = keys.indexOf(str[i + 3]);
|
|
4649
4671
|
const rnumx = Number(rnum.toString().slice(-1)) + 1;
|
|
4650
4672
|
const ylen = keyslen - rnumx;
|
|
4651
|
-
newstr += _optionalChain([String, 'optionalAccess',
|
|
4673
|
+
newstr += _optionalChain([String, 'optionalAccess', _548 => _548.fromCodePoint, 'call', _549 => _549(
|
|
4652
4674
|
(keys.indexOf(str[i++]) - rnumx) * ylen * ylen + (keys.indexOf(str[i++]) - rnumx) * ylen + (keys.indexOf(str[i++]) - rnumx)
|
|
4653
4675
|
)]);
|
|
4654
4676
|
}
|
|
@@ -4731,7 +4753,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4731
4753
|
}
|
|
4732
4754
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, decrypt, "decrypt");
|
|
4733
4755
|
function validateFields(payload, fields) {
|
|
4734
|
-
return fields.every((key) => typeof _optionalChain([payload, 'optionalAccess',
|
|
4756
|
+
return fields.every((key) => typeof _optionalChain([payload, 'optionalAccess', _550 => _550[key]]) === "string" && payload[key].length > 0);
|
|
4735
4757
|
}
|
|
4736
4758
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, validateFields, "validateFields");
|
|
4737
4759
|
function reqAES(opt, fn = (data) => data) {
|
|
@@ -4739,7 +4761,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4739
4761
|
try {
|
|
4740
4762
|
if (validateFields(reqData, ["data", "iv", "auth"])) {
|
|
4741
4763
|
let aesData = decrypt(reqData);
|
|
4742
|
-
if (_optionalChain([reqData, 'optionalAccess',
|
|
4764
|
+
if (_optionalChain([reqData, 'optionalAccess', _551 => _551.aes]) === 2) {
|
|
4743
4765
|
aesData = JSON.parse(aesData);
|
|
4744
4766
|
}
|
|
4745
4767
|
return fn(aesData);
|
|
@@ -4773,24 +4795,24 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4773
4795
|
// src/sysserver/lib/common/AsDb.ts
|
|
4774
4796
|
var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, cfg) => {
|
|
4775
4797
|
const DataServer = _chunk2BCIIKRGcjs.getDataServerForAsDb.call(void 0, $asai, {
|
|
4776
|
-
type: _optionalChain([cfg, 'optionalAccess',
|
|
4798
|
+
type: _optionalChain([cfg, 'optionalAccess', _552 => _552.type]) || "sqlite",
|
|
4777
4799
|
opt: {
|
|
4778
|
-
..._optionalChain([cfg, 'optionalAccess',
|
|
4800
|
+
..._optionalChain([cfg, 'optionalAccess', _553 => _553.opt]) || {
|
|
4779
4801
|
database: "./webdata/webdb/sqlite/asaisqlite.db",
|
|
4780
4802
|
create: 1
|
|
4781
4803
|
}
|
|
4782
4804
|
},
|
|
4783
|
-
storeKey: _optionalChain([cfg, 'optionalAccess',
|
|
4805
|
+
storeKey: _optionalChain([cfg, 'optionalAccess', _554 => _554.storeKey])
|
|
4784
4806
|
});
|
|
4785
4807
|
function reqwherestr(str) {
|
|
4786
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4808
|
+
if (_optionalChain([cfg, 'optionalAccess', _555 => _555.type]) === "sqlite" || _optionalChain([cfg, 'optionalAccess', _556 => _556.type]) === "mysql") {
|
|
4787
4809
|
return `'${str}'`;
|
|
4788
4810
|
}
|
|
4789
4811
|
return str;
|
|
4790
4812
|
}
|
|
4791
4813
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqwherestr, "reqwherestr");
|
|
4792
4814
|
function reqfield(queryData) {
|
|
4793
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4815
|
+
if (_optionalChain([queryData, 'optionalAccess', _557 => _557.fd])) {
|
|
4794
4816
|
return queryData.fd.split("-");
|
|
4795
4817
|
}
|
|
4796
4818
|
return cfg.field.data;
|
|
@@ -4798,14 +4820,14 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4798
4820
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqfield, "reqfield");
|
|
4799
4821
|
function reqwhere(queryData) {
|
|
4800
4822
|
const wheretmp = [];
|
|
4801
|
-
if ((_optionalChain([cfg, 'optionalAccess',
|
|
4823
|
+
if ((_optionalChain([cfg, 'optionalAccess', _558 => _558.type]) === "sqlite" || _optionalChain([cfg, 'optionalAccess', _559 => _559.type]) === "mysql") && _optionalChain([queryData, 'optionalAccess', _560 => _560.wlv])) {
|
|
4802
4824
|
const wlvarr = queryData.wlv.split("-");
|
|
4803
4825
|
wheretmp.push([wlvarr[0], ">", Number(wlvarr[1] || 0)]);
|
|
4804
4826
|
}
|
|
4805
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4827
|
+
if (_optionalChain([queryData, 'optionalAccess', _561 => _561.fl])) {
|
|
4806
4828
|
wheretmp.push([cfg.field.class, "LIKE", reqwherestr(`${queryData.fl}%`)]);
|
|
4807
4829
|
}
|
|
4808
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4830
|
+
if (_optionalChain([queryData, 'optionalAccess', _562 => _562.ss]) && _optionalChain([queryData, 'optionalAccess', _563 => _563.ssty])) {
|
|
4809
4831
|
wheretmp.push([queryData.ssty, "LIKE", reqwherestr(`%${queryData.ss}%`)]);
|
|
4810
4832
|
}
|
|
4811
4833
|
if (wheretmp.length > 1) {
|
|
@@ -4816,16 +4838,16 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4816
4838
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqwhere, "reqwhere");
|
|
4817
4839
|
function reqorder(queryData) {
|
|
4818
4840
|
const ordertmp = [];
|
|
4819
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4820
|
-
ordertmp.push([queryData.sx, _optionalChain([queryData, 'optionalAccess',
|
|
4841
|
+
if (_optionalChain([queryData, 'optionalAccess', _564 => _564.sx])) {
|
|
4842
|
+
ordertmp.push([queryData.sx, _optionalChain([queryData, 'optionalAccess', _565 => _565.sxty]) == 1 ? "DESC" : "ASC"]);
|
|
4821
4843
|
}
|
|
4822
4844
|
return ordertmp;
|
|
4823
4845
|
}
|
|
4824
4846
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqorder, "reqorder");
|
|
4825
4847
|
function reqlimit(queryData) {
|
|
4826
4848
|
let limittmp = "";
|
|
4827
|
-
let limitps = _optionalChain([queryData, 'optionalAccess',
|
|
4828
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4849
|
+
let limitps = _optionalChain([queryData, 'optionalAccess', _566 => _566.ps]);
|
|
4850
|
+
if (_optionalChain([queryData, 'optionalAccess', _567 => _567.pg])) {
|
|
4829
4851
|
limitps = limitps || 20;
|
|
4830
4852
|
limittmp = `${(queryData.pg - 1) * limitps},${limitps}`;
|
|
4831
4853
|
} else if (limitps) {
|
|
@@ -4878,8 +4900,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4878
4900
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, fileKeyFromSegment, "fileKeyFromSegment");
|
|
4879
4901
|
function getSqlParamsByUrl(req, opt) {
|
|
4880
4902
|
let tmpSqlParams;
|
|
4881
|
-
const reqArr = _optionalChain([req, 'optionalAccess',
|
|
4882
|
-
const table = (_optionalChain([opt, 'optionalAccess',
|
|
4903
|
+
const reqArr = _optionalChain([req, 'optionalAccess', _568 => _568.url, 'optionalAccess', _569 => _569.split, 'call', _570 => _570("?"), 'access', _571 => _571[0], 'optionalAccess', _572 => _572.split, 'call', _573 => _573("/")]) || [];
|
|
4904
|
+
const table = (_optionalChain([opt, 'optionalAccess', _574 => _574.qrdata, 'optionalAccess', _575 => _575.table]) || _optionalChain([opt, 'optionalAccess', _576 => _576.data, 'optionalAccess', _577 => _577.table]) || reqArr[3]).replaceAll("_", "/");
|
|
4883
4905
|
if (!table) return tmpSqlParams;
|
|
4884
4906
|
tmpSqlParams = {
|
|
4885
4907
|
type: "select",
|
|
@@ -4888,7 +4910,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4888
4910
|
if (reqArr[5]) {
|
|
4889
4911
|
if (reqArr[4] === "insert") {
|
|
4890
4912
|
tmpSqlParams.type = reqArr[4];
|
|
4891
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4913
|
+
if (_optionalChain([cfg, 'optionalAccess', _578 => _578.type]) === "file") {
|
|
4892
4914
|
const { name: bodyName, content } = parseFileBody(opt.data);
|
|
4893
4915
|
const fileKey = fileKeyFromSegment(reqArr[5], bodyName);
|
|
4894
4916
|
tmpSqlParams.field = cfg.field.data;
|
|
@@ -4912,11 +4934,11 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4912
4934
|
}
|
|
4913
4935
|
} else if (reqArr[4] === "update") {
|
|
4914
4936
|
tmpSqlParams.type = reqArr[4];
|
|
4915
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
4937
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _579 => _579.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4916
4938
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4917
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4939
|
+
if (_optionalChain([cfg, 'optionalAccess', _580 => _580.type]) === "file") {
|
|
4918
4940
|
const { content } = parseFileBody(opt.data);
|
|
4919
|
-
const contentField = _optionalChain([cfg, 'access',
|
|
4941
|
+
const contentField = _optionalChain([cfg, 'access', _581 => _581.field, 'access', _582 => _582.data, 'optionalAccess', _583 => _583[1]]) || "content";
|
|
4920
4942
|
tmpSqlParams.set = [[contentField, fileContentString(content)]];
|
|
4921
4943
|
} else {
|
|
4922
4944
|
tmpSqlParams.set = [];
|
|
@@ -4933,18 +4955,18 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4933
4955
|
}
|
|
4934
4956
|
} else if (reqArr[4] === "delete") {
|
|
4935
4957
|
tmpSqlParams.type = reqArr[4];
|
|
4936
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
4958
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _584 => _584.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4937
4959
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4938
4960
|
} else {
|
|
4939
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4961
|
+
if (_optionalChain([cfg, 'optionalAccess', _585 => _585.as]) > 1) {
|
|
4940
4962
|
tmpSqlParams.as = +cfg.as - 1;
|
|
4941
4963
|
}
|
|
4942
4964
|
tmpSqlParams.field = cfg.field.data;
|
|
4943
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
4965
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _586 => _586.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4944
4966
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4945
4967
|
}
|
|
4946
4968
|
} else {
|
|
4947
|
-
tmpSqlParams.as = _optionalChain([cfg, 'optionalAccess',
|
|
4969
|
+
tmpSqlParams.as = _optionalChain([cfg, 'optionalAccess', _587 => _587.as]);
|
|
4948
4970
|
tmpSqlParams.field = reqfield(opt.data);
|
|
4949
4971
|
tmpSqlParams.where = reqwhere(opt.data);
|
|
4950
4972
|
tmpSqlParams.order = reqorder(opt.data);
|
|
@@ -4954,8 +4976,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4954
4976
|
}
|
|
4955
4977
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSqlParamsByUrl, "getSqlParamsByUrl");
|
|
4956
4978
|
function dbFresh(req, resdb) {
|
|
4957
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
4958
|
-
const list = Array.isArray(resdb) ? resdb : _optionalChain([resdb, 'optionalAccess',
|
|
4979
|
+
if (_optionalChain([req, 'optionalAccess', _588 => _588.url, 'optionalAccess', _589 => _589.includes, 'call', _590 => _590("/selectlist/")])) {
|
|
4980
|
+
const list = Array.isArray(resdb) ? resdb : _optionalChain([resdb, 'optionalAccess', _591 => _591.data]);
|
|
4959
4981
|
if (Array.isArray(list)) {
|
|
4960
4982
|
const names = list.map((el) => {
|
|
4961
4983
|
if (typeof el === "string") {
|
|
@@ -4976,14 +4998,42 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4976
4998
|
return resdb;
|
|
4977
4999
|
}
|
|
4978
5000
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, dbFresh, "dbFresh");
|
|
5001
|
+
function normalizeFileSelectRow(row) {
|
|
5002
|
+
const nameKey = _optionalChain([cfg, 'access', _592 => _592.field, 'optionalAccess', _593 => _593.data, 'optionalAccess', _594 => _594[0]]) || "name";
|
|
5003
|
+
const contentKey = _optionalChain([cfg, 'access', _595 => _595.field, 'optionalAccess', _596 => _596.data, 'optionalAccess', _597 => _597[1]]) || "content";
|
|
5004
|
+
if (!row || typeof row !== "object") return row;
|
|
5005
|
+
const out = { ...row };
|
|
5006
|
+
if (out[nameKey] != null) {
|
|
5007
|
+
out[nameKey] = bareFileName(String(out[nameKey]));
|
|
5008
|
+
}
|
|
5009
|
+
const raw = out[contentKey];
|
|
5010
|
+
if (raw != null && typeof raw !== "string") {
|
|
5011
|
+
out[contentKey] = JSON.stringify(raw);
|
|
5012
|
+
}
|
|
5013
|
+
return out;
|
|
5014
|
+
}
|
|
5015
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, normalizeFileSelectRow, "normalizeFileSelectRow");
|
|
5016
|
+
function isFileSingleNameSelect(params) {
|
|
5017
|
+
return _optionalChain([cfg, 'optionalAccess', _598 => _598.type]) === "file" && _optionalChain([params, 'optionalAccess', _599 => _599.type]) === "select" && !!_optionalChain([params, 'optionalAccess', _600 => _600.where, 'optionalAccess', _601 => _601.length]);
|
|
5018
|
+
}
|
|
5019
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, isFileSingleNameSelect, "isFileSingleNameSelect");
|
|
4979
5020
|
function normalizeSelectResult(params, resdb) {
|
|
4980
5021
|
let data = resdb;
|
|
4981
|
-
if (
|
|
5022
|
+
if (isFileSingleNameSelect(params)) {
|
|
5023
|
+
if (Array.isArray(data)) {
|
|
5024
|
+
return data.map(normalizeFileSelectRow);
|
|
5025
|
+
}
|
|
5026
|
+
if (data && typeof data === "object") {
|
|
5027
|
+
return [normalizeFileSelectRow(data)];
|
|
5028
|
+
}
|
|
5029
|
+
return data;
|
|
5030
|
+
}
|
|
5031
|
+
if (_optionalChain([params, 'optionalAccess', _602 => _602.where, 'optionalAccess', _603 => _603.length]) && Array.isArray(data) && data.length === 1) {
|
|
4982
5032
|
data = data[0];
|
|
4983
5033
|
}
|
|
4984
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4985
|
-
const nameKey = _optionalChain([cfg, 'access',
|
|
4986
|
-
const contentKey = _optionalChain([cfg, 'access',
|
|
5034
|
+
if (_optionalChain([cfg, 'optionalAccess', _604 => _604.type]) === "file" && data && typeof data === "object" && !Array.isArray(data)) {
|
|
5035
|
+
const nameKey = _optionalChain([cfg, 'access', _605 => _605.field, 'optionalAccess', _606 => _606.data, 'optionalAccess', _607 => _607[0]]) || "name";
|
|
5036
|
+
const contentKey = _optionalChain([cfg, 'access', _608 => _608.field, 'optionalAccess', _609 => _609.data, 'optionalAccess', _610 => _610[1]]) || "content";
|
|
4987
5037
|
if (data[nameKey] != null) {
|
|
4988
5038
|
data[nameKey] = bareFileName(String(data[nameKey]));
|
|
4989
5039
|
}
|
|
@@ -5002,7 +5052,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5002
5052
|
}
|
|
5003
5053
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, normalizeSelectResult, "normalizeSelectResult");
|
|
5004
5054
|
function dbCodePm(req, resdb) {
|
|
5005
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
5055
|
+
if (_optionalChain([req, 'optionalAccess', _611 => _611.Userinfo]) && _optionalChain([req, 'optionalAccess', _612 => _612.Userinfo, 'access', _613 => _613[2]])) {
|
|
5006
5056
|
if (resdb != null && typeof resdb === "object") {
|
|
5007
5057
|
resdb.data = $asai.$lib.AsCode.asencode(JSON.stringify(resdb.data), req.Userinfo[2]);
|
|
5008
5058
|
}
|
|
@@ -5016,8 +5066,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5016
5066
|
DataServer.sqlDb(params).then((resdb) => {
|
|
5017
5067
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess(dbCodePm(req, dbFresh(req, resdb)), opt)));
|
|
5018
5068
|
}).catch((errdb) => {
|
|
5019
|
-
const msg = String(_optionalChain([errdb, 'optionalAccess',
|
|
5020
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5069
|
+
const msg = String(_optionalChain([errdb, 'optionalAccess', _614 => _614.message]) || errdb || "");
|
|
5070
|
+
if (_optionalChain([params, 'optionalAccess', _615 => _615.type]) === "select" && msg.includes("no such table")) {
|
|
5021
5071
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess([], opt)));
|
|
5022
5072
|
return;
|
|
5023
5073
|
}
|
|
@@ -5034,23 +5084,23 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5034
5084
|
try {
|
|
5035
5085
|
DataServer.sqlDb(params).then((resdb) => {
|
|
5036
5086
|
let resData = normalizeSelectResult(params, dbFresh(req, resdb));
|
|
5037
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5087
|
+
if (_optionalChain([params, 'optionalAccess', _616 => _616.as]) === 2 && _optionalChain([params, 'optionalAccess', _617 => _617.field, 'optionalAccess', _618 => _618.length]) > 1) {
|
|
5038
5088
|
let limitArr = [];
|
|
5039
|
-
if (_optionalChain([params, 'access',
|
|
5040
|
-
limitArr = [0, +_optionalChain([params, 'access',
|
|
5089
|
+
if (_optionalChain([params, 'access', _619 => _619.limit, 'optionalAccess', _620 => _620.split, 'call', _621 => _621(","), 'optionalAccess', _622 => _622.length]) < 2) {
|
|
5090
|
+
limitArr = [0, +_optionalChain([params, 'access', _623 => _623.limit, 'optionalAccess', _624 => _624.split, 'call', _625 => _625(","), 'optionalAccess', _626 => _626[0]])];
|
|
5041
5091
|
} else {
|
|
5042
5092
|
limitArr = params.limit.split(",");
|
|
5043
5093
|
limitArr = [+limitArr[0], +limitArr[0] + +limitArr[1]];
|
|
5044
5094
|
}
|
|
5045
|
-
if (_optionalChain([resData, 'access',
|
|
5095
|
+
if (_optionalChain([resData, 'access', _627 => _627.data, 'optionalAccess', _628 => _628.length])) {
|
|
5046
5096
|
resData.data = resData.data.slice(+limitArr[0], +limitArr[1]);
|
|
5047
5097
|
}
|
|
5048
5098
|
}
|
|
5049
5099
|
resData = dbCodePm(req, resData);
|
|
5050
5100
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess(resData, opt)));
|
|
5051
5101
|
}).catch((errdb) => {
|
|
5052
|
-
const msg = String(_optionalChain([errdb, 'optionalAccess',
|
|
5053
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5102
|
+
const msg = String(_optionalChain([errdb, 'optionalAccess', _629 => _629.message]) || errdb || "");
|
|
5103
|
+
if (_optionalChain([params, 'optionalAccess', _630 => _630.type]) === "select" && msg.includes("no such table")) {
|
|
5054
5104
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess([], opt)));
|
|
5055
5105
|
return;
|
|
5056
5106
|
}
|
|
@@ -5065,7 +5115,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5065
5115
|
}
|
|
5066
5116
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, runDefaultGet, "runDefaultGet");
|
|
5067
5117
|
function post(req, res, hostdir, opt) {
|
|
5068
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5118
|
+
if (_optionalChain([cfg, 'optionalAccess', _631 => _631.post]) && typeof cfg.post === "function") {
|
|
5069
5119
|
Promise.resolve(cfg.post(req, res, hostdir, opt, DataServer)).then((reqstat) => {
|
|
5070
5120
|
if (!reqstat) runDefaultPost(req, res, opt);
|
|
5071
5121
|
}).catch((errdb) => {
|
|
@@ -5077,7 +5127,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5077
5127
|
}
|
|
5078
5128
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, post, "post");
|
|
5079
5129
|
function get(req, res, hostdir, opt) {
|
|
5080
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5130
|
+
if (_optionalChain([cfg, 'optionalAccess', _632 => _632.get]) && typeof cfg.get === "function") {
|
|
5081
5131
|
Promise.resolve(cfg.get(req, res, hostdir, opt, DataServer)).then((reqstat) => {
|
|
5082
5132
|
if (!reqstat) runDefaultGet(req, res, opt);
|
|
5083
5133
|
}).catch((errdb) => {
|
|
@@ -5102,8 +5152,20 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5102
5152
|
}
|
|
5103
5153
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hostDefault2, "hostDefault");
|
|
5104
5154
|
function getPathFromOpt(opt) {
|
|
5105
|
-
const rawPath = _optionalChain([opt, 'access',
|
|
5106
|
-
|
|
5155
|
+
const rawPath = _optionalChain([opt, 'access', _633 => _633.qrdata, 'optionalAccess', _634 => _634.path]) || _optionalChain([opt, 'access', _635 => _635.data, 'optionalAccess', _636 => _636.path]);
|
|
5156
|
+
if (!rawPath) {
|
|
5157
|
+
throw new Error("Missing path");
|
|
5158
|
+
}
|
|
5159
|
+
const decoded = decodeURIComponent(String(rawPath));
|
|
5160
|
+
const roots = _optionalChain([$asai, 'optionalAccess', _637 => _637.asaihost, 'optionalAccess', _638 => _638.getHostAllowedRoots, 'optionalCall', _639 => _639(_optionalChain([$asai, 'optionalAccess', _640 => _640.hostconfig]))]) || [];
|
|
5161
|
+
if (!roots.length) {
|
|
5162
|
+
const fallback = _optionalChain([$asai, 'optionalAccess', _641 => _641.serverRoot]) || process.cwd();
|
|
5163
|
+
if (fallback) roots.push(fallback);
|
|
5164
|
+
}
|
|
5165
|
+
if (!_optionalChain([$asai, 'optionalAccess', _642 => _642.asaihost, 'optionalAccess', _643 => _643.resolvePathUnderRoots])) {
|
|
5166
|
+
throw new Error("Path resolver unavailable");
|
|
5167
|
+
}
|
|
5168
|
+
return $asai.asaihost.resolvePathUnderRoots(decoded, roots);
|
|
5107
5169
|
}
|
|
5108
5170
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getPathFromOpt, "getPathFromOpt");
|
|
5109
5171
|
function sendSuccess(res, data, opt) {
|
|
@@ -5112,18 +5174,18 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5112
5174
|
}
|
|
5113
5175
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendSuccess, "sendSuccess");
|
|
5114
5176
|
function sendErr(res, ec, params, opt) {
|
|
5115
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5116
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5117
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5177
|
+
const ErrorCode = _optionalChain([$asai, 'access', _644 => _644.$lib, 'optionalAccess', _645 => _645.ErrorCode]);
|
|
5178
|
+
_optionalChain([ErrorCode, 'optionalAccess', _646 => _646.loadErrorCodes, 'optionalCall', _647 => _647($asai)]);
|
|
5179
|
+
_optionalChain([ErrorCode, 'optionalAccess', _648 => _648.logError, 'optionalCall', _649 => _649($asai, ec, Array.isArray(params) ? params.map(String) : params != null ? [String(params)] : void 0)]);
|
|
5118
5180
|
const response = $asai.$lib.As.ctxErr(ec, params, opt);
|
|
5119
5181
|
res.end(JSON.stringify(response));
|
|
5120
5182
|
}
|
|
5121
5183
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendErr, "sendErr");
|
|
5122
5184
|
function sendFail(res, err, opt) {
|
|
5123
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5124
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5125
|
-
const normalized = _optionalChain([ErrorCode, 'optionalAccess',
|
|
5126
|
-
if (_optionalChain([normalized, 'optionalAccess',
|
|
5185
|
+
const ErrorCode = _optionalChain([$asai, 'access', _650 => _650.$lib, 'optionalAccess', _651 => _651.ErrorCode]);
|
|
5186
|
+
_optionalChain([ErrorCode, 'optionalAccess', _652 => _652.loadErrorCodes, 'optionalCall', _653 => _653($asai)]);
|
|
5187
|
+
const normalized = _optionalChain([ErrorCode, 'optionalAccess', _654 => _654.normalizeErrPayload, 'optionalCall', _655 => _655(err)]);
|
|
5188
|
+
if (_optionalChain([normalized, 'optionalAccess', _656 => _656.ec])) {
|
|
5127
5189
|
return sendErr(res, normalized.ec, normalized.pm, opt);
|
|
5128
5190
|
}
|
|
5129
5191
|
const response = $asai.$lib.As.ctxFail(err);
|
|
@@ -5131,7 +5193,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5131
5193
|
}
|
|
5132
5194
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendFail, "sendFail");
|
|
5133
5195
|
function mnLog(...arg) {
|
|
5134
|
-
(_optionalChain([$asai, 'optionalAccess',
|
|
5196
|
+
(_optionalChain([$asai, 'optionalAccess', _657 => _657.$log]) || console.log)(...arg);
|
|
5135
5197
|
}
|
|
5136
5198
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mnLog, "mnLog");
|
|
5137
5199
|
return { hostDefault: hostDefault2, getPathFromOpt, sendSuccess, sendFail, sendErr, mnLog };
|
|
@@ -5231,7 +5293,7 @@ async function removeFile(filePath) {
|
|
|
5231
5293
|
try {
|
|
5232
5294
|
await _promises2.default.unlink(nodePath2.default.normalize(filePath));
|
|
5233
5295
|
} catch (err) {
|
|
5234
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
5296
|
+
if (_optionalChain([err, 'optionalAccess', _658 => _658.code]) !== "ENOENT") throw err;
|
|
5235
5297
|
}
|
|
5236
5298
|
}
|
|
5237
5299
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, removeFile, "removeFile");
|
|
@@ -5251,83 +5313,6 @@ async function writeJson(filePath, data) {
|
|
|
5251
5313
|
}
|
|
5252
5314
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, writeJson, "writeJson");
|
|
5253
5315
|
|
|
5254
|
-
// src/sysserver/lib/common/AsPath.ts
|
|
5255
|
-
var AsPath_exports = {};
|
|
5256
|
-
_chunkSMVZ3ZDJcjs.__export.call(void 0, AsPath_exports, {
|
|
5257
|
-
getEntryDir: () => getEntryDir,
|
|
5258
|
-
getExecDir: () => getExecDir,
|
|
5259
|
-
getPkgSnapshotDir: () => getPkgSnapshotDir,
|
|
5260
|
-
getPrimaryServerRoot: () => getPrimaryServerRoot,
|
|
5261
|
-
getRuntimeBaseDirs: () => getRuntimeBaseDirs,
|
|
5262
|
-
isPkgRuntime: () => isPkgRuntime
|
|
5263
|
-
});
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
function isPkgRuntime() {
|
|
5267
|
-
return typeof process.pkg !== "undefined";
|
|
5268
|
-
}
|
|
5269
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, isPkgRuntime, "isPkgRuntime");
|
|
5270
|
-
function getPkgSnapshotDir() {
|
|
5271
|
-
if (!isPkgRuntime()) return void 0;
|
|
5272
|
-
const entry = _nullishCoalesce(_optionalChain([process, 'access', _641 => _641.pkg, 'optionalAccess', _642 => _642.entrypoint]), () => ( _optionalChain([process, 'access', _643 => _643.pkg, 'optionalAccess', _644 => _644.defaultEntrypoint])));
|
|
5273
|
-
if (!entry) return void 0;
|
|
5274
|
-
return nodePath4.resolve(nodePath4.dirname(entry));
|
|
5275
|
-
}
|
|
5276
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, getPkgSnapshotDir, "getPkgSnapshotDir");
|
|
5277
|
-
function getEntryDir() {
|
|
5278
|
-
const snapshot = getPkgSnapshotDir();
|
|
5279
|
-
if (snapshot) return snapshot;
|
|
5280
|
-
const entry = process.argv[1];
|
|
5281
|
-
if (!entry) {
|
|
5282
|
-
return nodePath4.dirname(process.execPath);
|
|
5283
|
-
}
|
|
5284
|
-
return nodePath4.resolve(nodePath4.dirname(entry));
|
|
5285
|
-
}
|
|
5286
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, getEntryDir, "getEntryDir");
|
|
5287
|
-
function getExecDir() {
|
|
5288
|
-
return nodePath4.dirname(process.execPath);
|
|
5289
|
-
}
|
|
5290
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, getExecDir, "getExecDir");
|
|
5291
|
-
function getRuntimeBaseDirs() {
|
|
5292
|
-
const bases = [];
|
|
5293
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5294
|
-
const add = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (p) => {
|
|
5295
|
-
if (!p) return;
|
|
5296
|
-
const abs = nodePath4.resolve(p);
|
|
5297
|
-
if (!seen.has(abs)) {
|
|
5298
|
-
seen.add(abs);
|
|
5299
|
-
bases.push(abs);
|
|
5300
|
-
}
|
|
5301
|
-
}, "add");
|
|
5302
|
-
add(process.cwd());
|
|
5303
|
-
add(getExecDir());
|
|
5304
|
-
if (isPkgRuntime()) {
|
|
5305
|
-
add(getPkgSnapshotDir());
|
|
5306
|
-
} else {
|
|
5307
|
-
const entryDir = getEntryDir();
|
|
5308
|
-
if (entryDir !== getExecDir()) {
|
|
5309
|
-
add(entryDir);
|
|
5310
|
-
}
|
|
5311
|
-
}
|
|
5312
|
-
return bases;
|
|
5313
|
-
}
|
|
5314
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, getRuntimeBaseDirs, "getRuntimeBaseDirs");
|
|
5315
|
-
function getPrimaryServerRoot() {
|
|
5316
|
-
for (const base of getRuntimeBaseDirs()) {
|
|
5317
|
-
try {
|
|
5318
|
-
if (fs10.statSync(nodePath4.join(base, "websys")).isDirectory()) {
|
|
5319
|
-
return base;
|
|
5320
|
-
}
|
|
5321
|
-
} catch (e46) {
|
|
5322
|
-
}
|
|
5323
|
-
}
|
|
5324
|
-
if (isPkgRuntime()) {
|
|
5325
|
-
return getExecDir();
|
|
5326
|
-
}
|
|
5327
|
-
return getEntryDir();
|
|
5328
|
-
}
|
|
5329
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, getPrimaryServerRoot, "getPrimaryServerRoot");
|
|
5330
|
-
|
|
5331
5316
|
// src/sysserver/lib/index.ts
|
|
5332
5317
|
var lib_default = {
|
|
5333
5318
|
As: As_default,
|
|
@@ -5335,12 +5320,12 @@ var lib_default = {
|
|
|
5335
5320
|
AsAES: AsAES_default,
|
|
5336
5321
|
AsDb: AsDb_default,
|
|
5337
5322
|
AsFs: AsFs_exports,
|
|
5338
|
-
AsPath: AsPath_exports,
|
|
5323
|
+
AsPath: _chunkHR5JKN7Ycjs.AsPath_exports,
|
|
5339
5324
|
reqWork: reqWork_default,
|
|
5340
5325
|
ErrorCode: ErrorCode_default,
|
|
5341
|
-
InterventionLog:
|
|
5342
|
-
LogStore:
|
|
5343
|
-
InterventionHooks:
|
|
5326
|
+
InterventionLog: _chunkU2YJH2RWcjs.InterventionLog_exports,
|
|
5327
|
+
LogStore: _chunkHR5JKN7Ycjs.LogStore_exports,
|
|
5328
|
+
InterventionHooks: _chunkARHPHWT5cjs.intervention_hooks_exports
|
|
5344
5329
|
};
|
|
5345
5330
|
|
|
5346
5331
|
// src/sysserver/db/src/common.ts
|
|
@@ -5358,17 +5343,17 @@ _chunkSMVZ3ZDJcjs.__export.call(void 0, common_exports, {
|
|
|
5358
5343
|
});
|
|
5359
5344
|
|
|
5360
5345
|
function promisifySqlDb(query, sql) {
|
|
5361
|
-
return new Promise((
|
|
5346
|
+
return new Promise((resolve5, reject) => {
|
|
5362
5347
|
query(sql, (err, result) => {
|
|
5363
5348
|
if (err) {
|
|
5364
5349
|
reject(err);
|
|
5365
5350
|
return;
|
|
5366
5351
|
}
|
|
5367
5352
|
if (!result || Array.isArray(result) && result.length === 0) {
|
|
5368
|
-
|
|
5353
|
+
resolve5("");
|
|
5369
5354
|
return;
|
|
5370
5355
|
}
|
|
5371
|
-
|
|
5356
|
+
resolve5(result);
|
|
5372
5357
|
});
|
|
5373
5358
|
});
|
|
5374
5359
|
}
|
|
@@ -5620,13 +5605,14 @@ function dbDriver(opt = {}) {
|
|
|
5620
5605
|
this.fileExt = config.ext === ".*" ? "" : config.ext || "";
|
|
5621
5606
|
this.fileDel = (config.del || 0) !== 0;
|
|
5622
5607
|
this.createDir = config.create || false;
|
|
5623
|
-
|
|
5608
|
+
const root = _optionalChain([config, 'access', _659 => _659.$asai, 'optionalAccess', _660 => _660.serverRoot]) || _chunkHR5JKN7Ycjs.getPrimaryServerRoot.call(void 0, );
|
|
5609
|
+
this.baseDirAbs = path6.resolve(root, config.dir);
|
|
5624
5610
|
}
|
|
5625
5611
|
dbLog(...args) {
|
|
5626
|
-
(_optionalChain([this, 'access',
|
|
5612
|
+
(_optionalChain([this, 'access', _661 => _661.config, 'optionalAccess', _662 => _662.$asai, 'optionalAccess', _663 => _663.$log]) || console.log)("FILE", ...args);
|
|
5627
5613
|
}
|
|
5628
5614
|
checkFile(file) {
|
|
5629
|
-
return
|
|
5615
|
+
return fs10.existsSync(this.getAbsPath(file, false));
|
|
5630
5616
|
}
|
|
5631
5617
|
/** 解析相对路径并限制在数据根目录内,防止路径穿越(跨平台) */
|
|
5632
5618
|
resolvePath(relPath) {
|
|
@@ -5653,9 +5639,9 @@ function dbDriver(opt = {}) {
|
|
|
5653
5639
|
const relative4 = this.normalizeRelPath(relPath);
|
|
5654
5640
|
const dirPath = path6.dirname(relative4);
|
|
5655
5641
|
const absDir = this.resolvePath(dirPath === "." ? "" : dirPath);
|
|
5656
|
-
if (this.createDir && !
|
|
5642
|
+
if (this.createDir && !fs10.existsSync(absDir)) {
|
|
5657
5643
|
this.dbLog("mkdir", "[MKDIR]", absDir);
|
|
5658
|
-
|
|
5644
|
+
fs10.mkdirSync(absDir, { recursive: true });
|
|
5659
5645
|
}
|
|
5660
5646
|
return absDir;
|
|
5661
5647
|
}
|
|
@@ -5671,25 +5657,25 @@ function dbDriver(opt = {}) {
|
|
|
5671
5657
|
}
|
|
5672
5658
|
deldir(relativePath) {
|
|
5673
5659
|
const absPath = this.resolvePath(relativePath);
|
|
5674
|
-
if (!
|
|
5660
|
+
if (!fs10.existsSync(absPath)) {
|
|
5675
5661
|
return;
|
|
5676
5662
|
}
|
|
5677
5663
|
this.dbLog("delete", "[RMDIR]", absPath);
|
|
5678
|
-
const entries =
|
|
5664
|
+
const entries = fs10.readdirSync(absPath, { withFileTypes: true });
|
|
5679
5665
|
for (const entry of entries) {
|
|
5680
5666
|
const current = path6.join(absPath, entry.name);
|
|
5681
5667
|
if (entry.isDirectory()) {
|
|
5682
5668
|
this.deldir(path6.join(relativePath, entry.name));
|
|
5683
5669
|
} else {
|
|
5684
5670
|
this.dbLog("delete", "[UNLINK]", current);
|
|
5685
|
-
|
|
5671
|
+
fs10.unlinkSync(current);
|
|
5686
5672
|
}
|
|
5687
5673
|
}
|
|
5688
|
-
|
|
5674
|
+
fs10.rmdirSync(absPath);
|
|
5689
5675
|
}
|
|
5690
5676
|
getReadPath(file, sql) {
|
|
5691
5677
|
const candidates = [];
|
|
5692
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5678
|
+
if (_optionalChain([sql, 'optionalAccess', _664 => _664.filename])) {
|
|
5693
5679
|
candidates.push({ dir: path6.join(file, sql.filename) });
|
|
5694
5680
|
candidates.push({ dir: path6.join(file + ".delete" + this.fileExt, sql.filename) });
|
|
5695
5681
|
} else {
|
|
@@ -5698,7 +5684,7 @@ function dbDriver(opt = {}) {
|
|
|
5698
5684
|
}
|
|
5699
5685
|
for (const candidate of candidates) {
|
|
5700
5686
|
const abs = this.getAbsPath(candidate.dir, false);
|
|
5701
|
-
if (
|
|
5687
|
+
if (fs10.existsSync(abs)) {
|
|
5702
5688
|
return { path: abs, dir: candidate.dir };
|
|
5703
5689
|
}
|
|
5704
5690
|
}
|
|
@@ -5709,22 +5695,22 @@ function dbDriver(opt = {}) {
|
|
|
5709
5695
|
if (!read2.path) {
|
|
5710
5696
|
return { path: "", dir: read2.dir };
|
|
5711
5697
|
}
|
|
5712
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5698
|
+
if (_optionalChain([sql, 'optionalAccess', _665 => _665.filename])) {
|
|
5713
5699
|
return { path: path6.dirname(read2.path), dir: path6.dirname(read2.dir) };
|
|
5714
5700
|
}
|
|
5715
5701
|
return { path: read2.path, dir: read2.dir };
|
|
5716
5702
|
}
|
|
5717
5703
|
getNewPath(file, sql) {
|
|
5718
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5704
|
+
if (_optionalChain([sql, 'optionalAccess', _666 => _666.filename])) {
|
|
5719
5705
|
return this.getAbsPath(path6.join(file, sql.filename), true);
|
|
5720
5706
|
}
|
|
5721
5707
|
return this.getAbsPath(file, true);
|
|
5722
5708
|
}
|
|
5723
5709
|
write(file, data, sql) {
|
|
5724
5710
|
try {
|
|
5725
|
-
const filePath = _optionalChain([sql, 'optionalAccess',
|
|
5711
|
+
const filePath = _optionalChain([sql, 'optionalAccess', _667 => _667.type]) === "insert" ? this.getNewPath(file, sql) : this.getReadPath(file, sql).path || this.getNewPath(file, sql);
|
|
5726
5712
|
this.dbLog("write", "[WRITE]", filePath);
|
|
5727
|
-
|
|
5713
|
+
fs10.writeFileSync(filePath, data, "utf8");
|
|
5728
5714
|
return "ok";
|
|
5729
5715
|
} catch (e) {
|
|
5730
5716
|
this.dbLog("write failed", "[WRITE ERROR]", e);
|
|
@@ -5738,7 +5724,7 @@ function dbDriver(opt = {}) {
|
|
|
5738
5724
|
return { error: "empty" };
|
|
5739
5725
|
}
|
|
5740
5726
|
this.dbLog("read", "[READ]", read2.path);
|
|
5741
|
-
const data =
|
|
5727
|
+
const data = fs10.readFileSync(read2.path, { encoding }) || "";
|
|
5742
5728
|
const fileName = this.fileExt && read2.dir.endsWith(this.fileExt) ? read2.dir : read2.dir + this.fileExt;
|
|
5743
5729
|
return [{ data, file: fileName }];
|
|
5744
5730
|
} catch (e) {
|
|
@@ -5752,15 +5738,15 @@ function dbDriver(opt = {}) {
|
|
|
5752
5738
|
if (!del.path) {
|
|
5753
5739
|
return "";
|
|
5754
5740
|
}
|
|
5755
|
-
if (this.fileDel && _optionalChain([sql, 'optionalAccess',
|
|
5741
|
+
if (this.fileDel && _optionalChain([sql, 'optionalAccess', _668 => _668.deltrue])) {
|
|
5756
5742
|
const target = del.path + ".delete" + this.fileExt;
|
|
5757
5743
|
this.dbLog("soft delete", "[SOFT DELETE]", `${del.path} -> ${target}`);
|
|
5758
|
-
|
|
5759
|
-
} else if (_optionalChain([sql, 'optionalAccess',
|
|
5744
|
+
fs10.renameSync(del.path, target);
|
|
5745
|
+
} else if (_optionalChain([sql, 'optionalAccess', _669 => _669.filename])) {
|
|
5760
5746
|
this.deldir(del.dir);
|
|
5761
5747
|
} else {
|
|
5762
5748
|
this.dbLog("delete", "[DELETE]", del.path);
|
|
5763
|
-
|
|
5749
|
+
fs10.unlinkSync(del.path);
|
|
5764
5750
|
}
|
|
5765
5751
|
return "ok";
|
|
5766
5752
|
} catch (e) {
|
|
@@ -5779,11 +5765,11 @@ function dbDriver(opt = {}) {
|
|
|
5779
5765
|
const original = del.path.replace(new RegExp(`.delete${extPattern}$`), "");
|
|
5780
5766
|
if (original !== del.path) {
|
|
5781
5767
|
this.dbLog("restore", "[RESTORE]", `${del.path} -> ${original}`);
|
|
5782
|
-
|
|
5768
|
+
fs10.renameSync(del.path, original);
|
|
5783
5769
|
}
|
|
5784
5770
|
} else {
|
|
5785
5771
|
this.dbLog("force delete", "[FORCE DELETE]", del.path);
|
|
5786
|
-
|
|
5772
|
+
fs10.unlinkSync(del.path);
|
|
5787
5773
|
}
|
|
5788
5774
|
return "ok";
|
|
5789
5775
|
} catch (e) {
|
|
@@ -5797,9 +5783,9 @@ function dbDriver(opt = {}) {
|
|
|
5797
5783
|
this.dbLog("list", "[LIST]", absDir);
|
|
5798
5784
|
let entries;
|
|
5799
5785
|
try {
|
|
5800
|
-
entries =
|
|
5801
|
-
} catch (
|
|
5802
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
5786
|
+
entries = fs10.readdirSync(absDir, { withFileTypes: true });
|
|
5787
|
+
} catch (e46) {
|
|
5788
|
+
return _optionalChain([sql, 'optionalAccess', _670 => _670.list]) ? { open: [], delete: [] } : [];
|
|
5803
5789
|
}
|
|
5804
5790
|
const result = { open: [], delete: [] };
|
|
5805
5791
|
const deleteSuffix = ".delete" + this.fileExt;
|
|
@@ -5811,17 +5797,17 @@ function dbDriver(opt = {}) {
|
|
|
5811
5797
|
if (this.fileExt && !baseName.endsWith(this.fileExt)) continue;
|
|
5812
5798
|
const fullPath = path6.join(absDir, fileName);
|
|
5813
5799
|
try {
|
|
5814
|
-
const data =
|
|
5800
|
+
const data = fs10.readFileSync(fullPath, "utf8");
|
|
5815
5801
|
const entryData = { data, file: baseName };
|
|
5816
5802
|
if (isDelete) {
|
|
5817
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5803
|
+
if (_optionalChain([sql, 'optionalAccess', _671 => _671.list])) result.delete.push(entryData);
|
|
5818
5804
|
} else {
|
|
5819
5805
|
result.open.push(entryData);
|
|
5820
5806
|
}
|
|
5821
|
-
} catch (
|
|
5807
|
+
} catch (e47) {
|
|
5822
5808
|
}
|
|
5823
5809
|
}
|
|
5824
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
5810
|
+
return _optionalChain([sql, 'optionalAccess', _672 => _672.list]) ? result : result.open;
|
|
5825
5811
|
} catch (e) {
|
|
5826
5812
|
this.dbLog("list failed", "[LIST ERROR]", e);
|
|
5827
5813
|
return e;
|
|
@@ -5831,14 +5817,14 @@ function dbDriver(opt = {}) {
|
|
|
5831
5817
|
getFileNameFromWhere(where) {
|
|
5832
5818
|
if (!where || !Array.isArray(where)) return "";
|
|
5833
5819
|
const first = where.find((item) => Array.isArray(item));
|
|
5834
|
-
const raw = _optionalChain([first, 'optionalAccess',
|
|
5820
|
+
const raw = _optionalChain([first, 'optionalAccess', _673 => _673[2]]);
|
|
5835
5821
|
if (typeof raw === "string") {
|
|
5836
5822
|
return raw.replace(/^'+|'+$/g, "");
|
|
5837
5823
|
}
|
|
5838
5824
|
return String(_nullishCoalesce(raw, () => ( "")));
|
|
5839
5825
|
}
|
|
5840
5826
|
sqlDb(sql) {
|
|
5841
|
-
return new Promise((
|
|
5827
|
+
return new Promise((resolve5, reject) => {
|
|
5842
5828
|
try {
|
|
5843
5829
|
let result;
|
|
5844
5830
|
const tableDir = this.tableFilePath(sql.table);
|
|
@@ -5856,22 +5842,22 @@ function dbDriver(opt = {}) {
|
|
|
5856
5842
|
const data = sql.set[0][1];
|
|
5857
5843
|
result = this.write(this.tableFilePath(sql.table, file), data, sql);
|
|
5858
5844
|
} else if (sql.type === "select") {
|
|
5859
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5845
|
+
if (_optionalChain([sql, 'optionalAccess', _674 => _674.where, 'optionalAccess', _675 => _675.length]) && _optionalChain([sql, 'optionalAccess', _676 => _676.as]) !== 2) {
|
|
5860
5846
|
const file = this.getFileNameFromWhere(sql.where);
|
|
5861
5847
|
const readRes = this.read(this.tableFilePath(sql.table, file), sql);
|
|
5862
5848
|
const resObj = {};
|
|
5863
|
-
if (_optionalChain([readRes, 'optionalAccess',
|
|
5849
|
+
if (_optionalChain([readRes, 'optionalAccess', _677 => _677[0], 'optionalAccess', _678 => _678.file]) && !readRes.error) {
|
|
5864
5850
|
if (sql.as === 1) {
|
|
5865
5851
|
try {
|
|
5866
5852
|
const parsed = JSON.parse(readRes[0].data);
|
|
5867
|
-
if (_optionalChain([sql, 'access',
|
|
5853
|
+
if (_optionalChain([sql, 'access', _679 => _679.field, 'optionalAccess', _680 => _680.length])) {
|
|
5868
5854
|
sql.field.forEach((f) => {
|
|
5869
5855
|
resObj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
5870
5856
|
});
|
|
5871
5857
|
} else {
|
|
5872
5858
|
Object.assign(resObj, parsed);
|
|
5873
5859
|
}
|
|
5874
|
-
} catch (
|
|
5860
|
+
} catch (e48) {
|
|
5875
5861
|
}
|
|
5876
5862
|
} else {
|
|
5877
5863
|
const fields = sql.field;
|
|
@@ -5885,7 +5871,7 @@ function dbDriver(opt = {}) {
|
|
|
5885
5871
|
} else {
|
|
5886
5872
|
const listRes = this.list(tableDir, sql);
|
|
5887
5873
|
if (listRes && !listRes.error) {
|
|
5888
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5874
|
+
if (_optionalChain([sql, 'optionalAccess', _681 => _681.list])) {
|
|
5889
5875
|
const mapEntry = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (el) => {
|
|
5890
5876
|
const fields = sql.field;
|
|
5891
5877
|
const item = { [fields[0]]: el.file };
|
|
@@ -5896,9 +5882,9 @@ function dbDriver(opt = {}) {
|
|
|
5896
5882
|
if (listRes.delete) listRes.delete = listRes.delete.map(mapEntry);
|
|
5897
5883
|
result = listRes;
|
|
5898
5884
|
} else {
|
|
5899
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5885
|
+
if (_optionalChain([sql, 'optionalAccess', _682 => _682.as]) === 2) {
|
|
5900
5886
|
let items = listRes;
|
|
5901
|
-
if (_optionalChain([sql, 'access',
|
|
5887
|
+
if (_optionalChain([sql, 'access', _683 => _683.where, 'optionalAccess', _684 => _684.length])) {
|
|
5902
5888
|
const where = sql.where;
|
|
5903
5889
|
const whereType = typeof where[0] === "string" ? where[0] : "and";
|
|
5904
5890
|
items = items.filter((el) => {
|
|
@@ -5912,7 +5898,7 @@ function dbDriver(opt = {}) {
|
|
|
5912
5898
|
let fieldVal = "";
|
|
5913
5899
|
try {
|
|
5914
5900
|
fieldVal = _nullishCoalesce(JSON.parse(el.data)[field], () => ( ""));
|
|
5915
|
-
} catch (
|
|
5901
|
+
} catch (e49) {
|
|
5916
5902
|
}
|
|
5917
5903
|
const condMatch = String(fieldVal).includes(searchVal);
|
|
5918
5904
|
if (whereType === "and") {
|
|
@@ -5930,18 +5916,18 @@ function dbDriver(opt = {}) {
|
|
|
5930
5916
|
const obj = {};
|
|
5931
5917
|
try {
|
|
5932
5918
|
const parsed = JSON.parse(el.data);
|
|
5933
|
-
if (_optionalChain([sql, 'access',
|
|
5919
|
+
if (_optionalChain([sql, 'access', _685 => _685.field, 'optionalAccess', _686 => _686.length])) {
|
|
5934
5920
|
sql.field.forEach((f) => {
|
|
5935
5921
|
obj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
5936
5922
|
});
|
|
5937
5923
|
} else {
|
|
5938
5924
|
Object.assign(obj, parsed);
|
|
5939
5925
|
}
|
|
5940
|
-
} catch (
|
|
5926
|
+
} catch (e50) {
|
|
5941
5927
|
}
|
|
5942
5928
|
return obj;
|
|
5943
5929
|
});
|
|
5944
|
-
if (_optionalChain([sql, 'access',
|
|
5930
|
+
if (_optionalChain([sql, 'access', _687 => _687.order, 'optionalAccess', _688 => _688.length])) {
|
|
5945
5931
|
const orderField = sql.order[0];
|
|
5946
5932
|
const orderFieldName = typeof orderField === "string" ? orderField : orderField[0];
|
|
5947
5933
|
const direction = typeof orderField === "string" ? "ASC" : String(orderField[1]).toUpperCase();
|
|
@@ -5962,12 +5948,12 @@ function dbDriver(opt = {}) {
|
|
|
5962
5948
|
}
|
|
5963
5949
|
}
|
|
5964
5950
|
} else {
|
|
5965
|
-
result = _optionalChain([sql, 'optionalAccess',
|
|
5951
|
+
result = _optionalChain([sql, 'optionalAccess', _689 => _689.list]) ? { open: [], delete: [] } : [];
|
|
5966
5952
|
}
|
|
5967
5953
|
}
|
|
5968
5954
|
}
|
|
5969
5955
|
if (result !== void 0) {
|
|
5970
|
-
|
|
5956
|
+
resolve5(result);
|
|
5971
5957
|
} else {
|
|
5972
5958
|
reject("");
|
|
5973
5959
|
}
|
|
@@ -6018,7 +6004,7 @@ function sysserver($asai, opt = {}) {
|
|
|
6018
6004
|
if (!$asai.$lib) $asai.$lib = {};
|
|
6019
6005
|
$asai.$lib = { ...lib_default, ...$asai.$lib, ...opt || {} };
|
|
6020
6006
|
$asai.dataserver = db_default;
|
|
6021
|
-
_optionalChain([$asai, 'access',
|
|
6007
|
+
_optionalChain([$asai, 'access', _690 => _690.$lib, 'access', _691 => _691.ErrorCode, 'optionalAccess', _692 => _692.loadErrorCodes, 'optionalCall', _693 => _693($asai)]);
|
|
6022
6008
|
if (!$asai.$lib.api) $asai.$lib.api = {};
|
|
6023
6009
|
$asai.$lib.api = { ...api_default, ...$asai.$lib.api };
|
|
6024
6010
|
if (!$asai.$lib.ws) $asai.$lib.ws = {};
|
|
@@ -6211,7 +6197,7 @@ function normalizeDataStoresConfig(cfg) {
|
|
|
6211
6197
|
}
|
|
6212
6198
|
if (userStore.opt.create == null) userStore.opt.create = 1;
|
|
6213
6199
|
}
|
|
6214
|
-
if (!stores.log && _optionalChain([cfg, 'access',
|
|
6200
|
+
if (!stores.log && _optionalChain([cfg, 'access', _694 => _694.logger, 'optionalAccess', _695 => _695.store])) {
|
|
6215
6201
|
const s = cfg.logger.store;
|
|
6216
6202
|
stores.log = {
|
|
6217
6203
|
type: s.type || "file",
|
|
@@ -6275,13 +6261,13 @@ function validateHostConfig(cfg) {
|
|
|
6275
6261
|
if (cfg.asaisn != null) {
|
|
6276
6262
|
errors.push("asaisn \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_ASAISN");
|
|
6277
6263
|
}
|
|
6278
|
-
if (_optionalChain([cfg, 'access',
|
|
6264
|
+
if (_optionalChain([cfg, 'access', _696 => _696.aes, 'optionalAccess', _697 => _697.keybase64]) != null) {
|
|
6279
6265
|
errors.push("aes.keybase64 \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_AES_KEYBASE64");
|
|
6280
6266
|
}
|
|
6281
|
-
if (_optionalChain([cfg, 'access',
|
|
6267
|
+
if (_optionalChain([cfg, 'access', _698 => _698.httpscert, 'optionalAccess', _699 => _699.key]) != null || _optionalChain([cfg, 'access', _700 => _700.httpscert, 'optionalAccess', _701 => _701.cert]) != null) {
|
|
6282
6268
|
errors.push("httpscert.key/cert \u7981\u6B62\u5185\u8054\u4E8E asaihost.json\uFF0C\u8BF7\u4F7F\u7528 keyPath/certPath \u6216\u73AF\u5883\u53D8\u91CF");
|
|
6283
6269
|
}
|
|
6284
|
-
if (_optionalChain([cfg, 'access',
|
|
6270
|
+
if (_optionalChain([cfg, 'access', _702 => _702.security, 'optionalAccess', _703 => _703.sessionSecret]) != null) {
|
|
6285
6271
|
errors.push("security.sessionSecret \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_SESSION_SECRET");
|
|
6286
6272
|
}
|
|
6287
6273
|
if (Array.isArray(cfg.wssec) && typeof cfg.wssec[0] === "string" && cfg.wssec[0].length > 0) {
|
|
@@ -6336,10 +6322,10 @@ function validateHostConfig(cfg) {
|
|
|
6336
6322
|
validateHostSiteLimits(name, h, errors);
|
|
6337
6323
|
}
|
|
6338
6324
|
}
|
|
6339
|
-
if (_optionalChain([cfg, 'access',
|
|
6325
|
+
if (_optionalChain([cfg, 'access', _704 => _704.logger, 'optionalAccess', _705 => _705.sample]) && typeof cfg.logger.sample !== "object") {
|
|
6340
6326
|
errors.push('logger.sample \u5FC5\u987B\u4E3A\u5BF9\u8C61\uFF08\u5982 { "REQ_OTHER": 0.1 }\uFF09');
|
|
6341
6327
|
}
|
|
6342
|
-
if (_optionalChain([cfg, 'access',
|
|
6328
|
+
if (_optionalChain([cfg, 'access', _706 => _706.logger, 'optionalAccess', _707 => _707.skip]) != null && !Array.isArray(cfg.logger.skip)) {
|
|
6343
6329
|
errors.push('logger.skip \u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5982 ["/sys/info/metrics"]\uFF09');
|
|
6344
6330
|
}
|
|
6345
6331
|
if (cfg.proxyhosts && typeof cfg.proxyhosts === "object") {
|
|
@@ -6373,7 +6359,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, validateHostSiteLimits, "validateHostSiteL
|
|
|
6373
6359
|
function validateProductionSecurity(cfg) {
|
|
6374
6360
|
const errors = [];
|
|
6375
6361
|
if (process.env.NODE_ENV !== "production") return errors;
|
|
6376
|
-
const sec = _optionalChain([cfg, 'optionalAccess',
|
|
6362
|
+
const sec = _optionalChain([cfg, 'optionalAccess', _708 => _708.security]);
|
|
6377
6363
|
if (!sec || typeof sec !== "object") {
|
|
6378
6364
|
errors.push("\u751F\u4EA7\u73AF\u5883\u5FC5\u987B\u914D\u7F6E security \u5BF9\u8C61");
|
|
6379
6365
|
return errors;
|
|
@@ -6384,7 +6370,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6384
6370
|
if (sec.allowRegister === 1) {
|
|
6385
6371
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.allowRegister \u5E94\u4E3A 0\uFF08CR 1.3 \u7981\u6B62\u5F00\u653E\u6CE8\u518C\uFF09");
|
|
6386
6372
|
}
|
|
6387
|
-
if (!_optionalChain([sec, 'access',
|
|
6373
|
+
if (!_optionalChain([sec, 'access', _709 => _709.quota, 'optionalAccess', _710 => _710.enabled])) {
|
|
6388
6374
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.quota.enabled \u5E94\u4E3A 1\uFF08CR 7.1 \u8D44\u6E90\u9650\u5236\uFF09");
|
|
6389
6375
|
}
|
|
6390
6376
|
if (sec.csp !== 1) {
|
|
@@ -6393,7 +6379,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6393
6379
|
if (typeof sec.minUserLevel !== "number" || sec.minUserLevel < 0) {
|
|
6394
6380
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.minUserLevel \u5E94\u663E\u5F0F\u914D\u7F6E");
|
|
6395
6381
|
}
|
|
6396
|
-
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess',
|
|
6382
|
+
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess', _711 => _711.httpscert, 'optionalAccess', _712 => _712.keyPath]) && !_optionalChain([cfg, 'optionalAccess', _713 => _713.httpscert, 'optionalAccess', _714 => _714.key])) {
|
|
6397
6383
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.forceWss=1 \u65F6\u9700\u914D\u7F6E HTTPS \u8BC1\u4E66");
|
|
6398
6384
|
}
|
|
6399
6385
|
return errors;
|
|
@@ -6412,12 +6398,12 @@ var DEFAULT_RECONNECT = {
|
|
|
6412
6398
|
rs485: { enabled: true, maxRetries: 60, initialDelay: 3e3, maxDelay: 3e4, factor: 2 }
|
|
6413
6399
|
};
|
|
6414
6400
|
function getTransportBlock(cfg, kind) {
|
|
6415
|
-
const block = _optionalChain([cfg, 'optionalAccess',
|
|
6401
|
+
const block = _optionalChain([cfg, 'optionalAccess', _715 => _715[kind]]);
|
|
6416
6402
|
return block && typeof block === "object" ? block : null;
|
|
6417
6403
|
}
|
|
6418
6404
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportBlock, "getTransportBlock");
|
|
6419
6405
|
function getTransportDefault(cfg, kind) {
|
|
6420
|
-
const def = _optionalChain([getTransportBlock, 'call',
|
|
6406
|
+
const def = _optionalChain([getTransportBlock, 'call', _716 => _716(cfg, kind), 'optionalAccess', _717 => _717.default]);
|
|
6421
6407
|
return def && typeof def === "object" ? def : null;
|
|
6422
6408
|
}
|
|
6423
6409
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportDefault, "getTransportDefault");
|
|
@@ -6427,7 +6413,7 @@ function hasTransportDefault(cfg, kind) {
|
|
|
6427
6413
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasTransportDefault, "hasTransportDefault");
|
|
6428
6414
|
function getDefaultConnId(cfg, kind) {
|
|
6429
6415
|
const def = getTransportDefault(cfg, kind);
|
|
6430
|
-
const id = _optionalChain([def, 'optionalAccess',
|
|
6416
|
+
const id = _optionalChain([def, 'optionalAccess', _718 => _718.id]);
|
|
6431
6417
|
return typeof id === "string" && id.length > 0 ? id : DEFAULT_CONN_ID[kind];
|
|
6432
6418
|
}
|
|
6433
6419
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getDefaultConnId, "getDefaultConnId");
|
|
@@ -6438,14 +6424,14 @@ function shouldAutoConnect(def) {
|
|
|
6438
6424
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, shouldAutoConnect, "shouldAutoConnect");
|
|
6439
6425
|
function resolveReconnectOptions(def, kind, cfg) {
|
|
6440
6426
|
const base = DEFAULT_RECONNECT[kind];
|
|
6441
|
-
const rc = _optionalChain([def, 'optionalAccess',
|
|
6442
|
-
const tmMaxTry = _optionalChain([cfg, 'optionalAccess',
|
|
6427
|
+
const rc = _optionalChain([def, 'optionalAccess', _719 => _719.reconnect]);
|
|
6428
|
+
const tmMaxTry = _optionalChain([cfg, 'optionalAccess', _720 => _720.tm, 'optionalAccess', _721 => _721.maxtry]);
|
|
6443
6429
|
return {
|
|
6444
|
-
enabled: _optionalChain([rc, 'optionalAccess',
|
|
6445
|
-
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6446
|
-
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6447
|
-
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6448
|
-
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6430
|
+
enabled: _optionalChain([rc, 'optionalAccess', _722 => _722.enabled]) !== false && base.enabled !== false,
|
|
6431
|
+
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _723 => _723.maxRetries]), () => ( tmMaxTry)), () => ( base.maxRetries)), () => ( 60)),
|
|
6432
|
+
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _724 => _724.initialDelay]), () => ( base.initialDelay)), () => ( 1e3)),
|
|
6433
|
+
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _725 => _725.maxDelay]), () => ( base.maxDelay)), () => ( 3e4)),
|
|
6434
|
+
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _726 => _726.factor]), () => ( base.factor)), () => ( 2))
|
|
6449
6435
|
};
|
|
6450
6436
|
}
|
|
6451
6437
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveReconnectOptions, "resolveReconnectOptions");
|
|
@@ -6495,17 +6481,17 @@ function createTransportDataHandler($asai, manager) {
|
|
|
6495
6481
|
if (typeof event.data === "string") {
|
|
6496
6482
|
try {
|
|
6497
6483
|
event.data = JSON.parse(event.data);
|
|
6498
|
-
} catch (
|
|
6484
|
+
} catch (e51) {
|
|
6499
6485
|
}
|
|
6500
6486
|
}
|
|
6501
|
-
if (_optionalChain([event, 'access',
|
|
6487
|
+
if (_optionalChain([event, 'access', _727 => _727.data, 'optionalAccess', _728 => _728.id])) {
|
|
6502
6488
|
manager.watch(event.id, event.data);
|
|
6503
6489
|
return;
|
|
6504
6490
|
}
|
|
6505
6491
|
try {
|
|
6506
|
-
const wsKey = _optionalChain([$asai, 'optionalAccess',
|
|
6507
|
-
_optionalChain([$asai, 'access',
|
|
6508
|
-
} catch (
|
|
6492
|
+
const wsKey = _optionalChain([$asai, 'optionalAccess', _729 => _729.command, 'optionalAccess', _730 => _730.commandconfig, 'optionalAccess', _731 => _731.config, 'optionalAccess', _732 => _732.commandclient]);
|
|
6493
|
+
_optionalChain([$asai, 'access', _733 => _733.serversws, 'optionalAccess', _734 => _734[wsKey], 'optionalAccess', _735 => _735.broadws, 'optionalCall', _736 => _736(event.data)]);
|
|
6494
|
+
} catch (e52) {
|
|
6509
6495
|
}
|
|
6510
6496
|
};
|
|
6511
6497
|
}
|
|
@@ -6552,20 +6538,20 @@ var initAsaiHostNodejs2 = {
|
|
|
6552
6538
|
initHostserverWs,
|
|
6553
6539
|
syncApiRouteKeys,
|
|
6554
6540
|
syncWsRouteKeys,
|
|
6555
|
-
secureCompare:
|
|
6541
|
+
secureCompare: _chunkWXW5DYNUcjs.secureCompare,
|
|
6556
6542
|
resolvePathUnderRoots,
|
|
6557
6543
|
getHostAllowedRoots,
|
|
6558
6544
|
logSecurityEvent,
|
|
6559
6545
|
sanitizeString,
|
|
6560
6546
|
validateHttpAuth,
|
|
6561
6547
|
normalizeSecurityConfig,
|
|
6562
|
-
stripForbiddenSecretsFromHostConfig:
|
|
6563
|
-
loadAsaiSecrets:
|
|
6564
|
-
loadDotEnvFile:
|
|
6565
|
-
applySecretsToHostConfig:
|
|
6566
|
-
resolveHttpsCertFromPaths:
|
|
6567
|
-
validateAsaiSecrets:
|
|
6568
|
-
isDevDefaultPassword:
|
|
6548
|
+
stripForbiddenSecretsFromHostConfig: _chunkZK4O4Z2Ocjs.stripForbiddenSecretsFromHostConfig,
|
|
6549
|
+
loadAsaiSecrets: _chunkZK4O4Z2Ocjs.loadAsaiSecrets,
|
|
6550
|
+
loadDotEnvFile: _chunkZK4O4Z2Ocjs.loadDotEnvFile,
|
|
6551
|
+
applySecretsToHostConfig: _chunkZK4O4Z2Ocjs.applySecretsToHostConfig,
|
|
6552
|
+
resolveHttpsCertFromPaths: _chunkZK4O4Z2Ocjs.resolveHttpsCertFromPaths,
|
|
6553
|
+
validateAsaiSecrets: _chunkZK4O4Z2Ocjs.validateAsaiSecrets,
|
|
6554
|
+
isDevDefaultPassword: _chunkZK4O4Z2Ocjs.isDevDefaultPassword,
|
|
6569
6555
|
getTransportBlock,
|
|
6570
6556
|
getTransportDefault,
|
|
6571
6557
|
hasTransportDefault,
|
|
@@ -6577,7 +6563,7 @@ var initAsaiHostNodejs2 = {
|
|
|
6577
6563
|
createTransportDataHandler,
|
|
6578
6564
|
wireTransportConnectionLogs
|
|
6579
6565
|
};
|
|
6580
|
-
var PLUGIN_VERSION = true ? "0.0.
|
|
6566
|
+
var PLUGIN_VERSION = true ? "0.0.6" : "0.0.1";
|
|
6581
6567
|
var index_default = initAsaiHostNodejs2;
|
|
6582
6568
|
|
|
6583
6569
|
|
|
@@ -6620,5 +6606,5 @@ var index_default = initAsaiHostNodejs2;
|
|
|
6620
6606
|
|
|
6621
6607
|
|
|
6622
6608
|
|
|
6623
|
-
exports.AsaiCommon = Index_default; exports.AsaiUtils = utils_exports; exports.PLUGIN_NAME = PLUGIN_NAME; exports.PLUGIN_VERSION = PLUGIN_VERSION; exports.applySecretsToHostConfig =
|
|
6609
|
+
exports.AsaiCommon = Index_default; exports.AsaiUtils = utils_exports; exports.PLUGIN_NAME = PLUGIN_NAME; exports.PLUGIN_VERSION = PLUGIN_VERSION; exports.applySecretsToHostConfig = _chunkZK4O4Z2Ocjs.applySecretsToHostConfig; exports.createTransportDataHandler = createTransportDataHandler; exports.default = index_default; exports.ensureDefaultConnection = ensureDefaultConnection; exports.getDefaultConnId = getDefaultConnId; exports.getHostAllowedRoots = getHostAllowedRoots; exports.getTransportBlock = getTransportBlock; exports.getTransportDefault = getTransportDefault; exports.hasTransportDefault = hasTransportDefault; exports.initAsaiHostNodejs = initAsaiHostNodejs2; exports.initHostserverApi = initHostserverApi; exports.initHostserverWs = initHostserverWs; exports.initTransportBridge = initTransportBridge; exports.isDevDefaultPassword = _chunkZK4O4Z2Ocjs.isDevDefaultPassword; exports.loadAsaiSecrets = _chunkZK4O4Z2Ocjs.loadAsaiSecrets; exports.loadDotEnvFile = _chunkZK4O4Z2Ocjs.loadDotEnvFile; exports.logSecurityEvent = logSecurityEvent; exports.normalizeHostConfig = normalizeHostConfig; exports.normalizeSecurityConfig = normalizeSecurityConfig; exports.registerApi = registerApi; exports.registerWs = registerWs; exports.resolveHttpsCertFromPaths = _chunkZK4O4Z2Ocjs.resolveHttpsCertFromPaths; exports.resolvePathUnderRoots = resolvePathUnderRoots; exports.resolveReconnectOptions = resolveReconnectOptions; exports.sanitizeString = sanitizeString; exports.secureCompare = _chunkWXW5DYNUcjs.secureCompare; exports.shouldAutoConnect = shouldAutoConnect; exports.stripForbiddenSecretsFromHostConfig = _chunkZK4O4Z2Ocjs.stripForbiddenSecretsFromHostConfig; exports.syncApiRouteKeys = syncApiRouteKeys; exports.syncWsRouteKeys = syncWsRouteKeys; exports.sysserver = sysserver; exports.validateAsaiSecrets = _chunkZK4O4Z2Ocjs.validateAsaiSecrets; exports.validateHostConfig = validateHostConfig; exports.validateHttpAuth = validateHttpAuth; exports.validateProductionSecurity = validateProductionSecurity; exports.wireTransportConnectionLogs = wireTransportConnectionLogs;
|
|
6624
6610
|
//# sourceMappingURL=asaihost-nodejs.cjs.map
|