asaihost-nodejs 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/asaihost-nodejs.cjs
CHANGED
|
@@ -994,7 +994,7 @@ function terminateWs(wsclient) {
|
|
|
994
994
|
}
|
|
995
995
|
}
|
|
996
996
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, terminateWs, "terminateWs");
|
|
997
|
-
async function clearStaleWsIfDead($asai, hostdir, us, existingWs) {
|
|
997
|
+
async function clearStaleWsIfDead($asai, hostdir, us, existingWs, timeoutMs) {
|
|
998
998
|
if (!us || us === "asai") return true;
|
|
999
999
|
const map = _optionalChain([$asai, 'access', _120 => _120.connectionsws, 'optionalAccess', _121 => _121[hostdir]]);
|
|
1000
1000
|
if (!existingWs) {
|
|
@@ -1011,7 +1011,7 @@ async function clearStaleWsIfDead($asai, hostdir, us, existingWs) {
|
|
|
1011
1011
|
if (_optionalChain([map, 'optionalAccess', _124 => _124[us]]) === existingWs) delete map[us];
|
|
1012
1012
|
return true;
|
|
1013
1013
|
}
|
|
1014
|
-
const alive = await probeWsAlive($asai, existingWs);
|
|
1014
|
+
const alive = await probeWsAlive($asai, existingWs, timeoutMs);
|
|
1015
1015
|
if (alive) return false;
|
|
1016
1016
|
terminateWs(existingWs);
|
|
1017
1017
|
if (_optionalChain([map, 'optionalAccess', _125 => _125[us]]) === existingWs) delete map[us];
|
|
@@ -1181,21 +1181,23 @@ async function isOkWs($asai, hostdir, ws2, _req, hostcfg) {
|
|
|
1181
1181
|
if (us !== "asai" && _optionalChain([$asai, 'access', _144 => _144.connectionsws, 'access', _145 => _145[hostdir], 'optionalAccess', _146 => _146[us]])) {
|
|
1182
1182
|
const existingWs = $asai.connectionsws[hostdir][us];
|
|
1183
1183
|
if (_optionalChain([existingWs, 'optionalAccess', _147 => _147.Userinfo, 'optionalAccess', _148 => _148[2]]) === tk) {
|
|
1184
|
-
if (isWsStillActive(existingWs)) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
return false;
|
|
1192
|
-
}
|
|
1193
|
-
try {
|
|
1194
|
-
existingWs.close();
|
|
1195
|
-
} catch (e31) {
|
|
1184
|
+
if (!isWsStillActive(existingWs)) {
|
|
1185
|
+
try {
|
|
1186
|
+
existingWs.close();
|
|
1187
|
+
} catch (e31) {
|
|
1188
|
+
}
|
|
1189
|
+
delete $asai.connectionsws[hostdir][us];
|
|
1190
|
+
return true;
|
|
1196
1191
|
}
|
|
1197
|
-
|
|
1198
|
-
return true;
|
|
1192
|
+
const cleared2 = await clearStaleWsIfDead($asai, hostdir, us, existingWs, 800);
|
|
1193
|
+
if (cleared2) return true;
|
|
1194
|
+
rejectIncomingWs(ws2, {
|
|
1195
|
+
lang: "pageworking",
|
|
1196
|
+
langpm: `${us}`,
|
|
1197
|
+
con: `${us} page already running`,
|
|
1198
|
+
online: listOnlineWsEntries($asai, hostdir)
|
|
1199
|
+
});
|
|
1200
|
+
return false;
|
|
1199
1201
|
}
|
|
1200
1202
|
const cleared = await clearStaleWsIfDead($asai, hostdir, us, existingWs);
|
|
1201
1203
|
if (!cleared) {
|
|
@@ -5442,28 +5444,29 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5442
5444
|
throw new Error("Missing path");
|
|
5443
5445
|
}
|
|
5444
5446
|
const decoded = decodeURIComponent(String(rawPath));
|
|
5445
|
-
if (
|
|
5446
|
-
|
|
5447
|
+
if (decoded.includes("\0")) {
|
|
5448
|
+
throw new Error("Invalid path");
|
|
5447
5449
|
}
|
|
5448
|
-
const
|
|
5449
|
-
const
|
|
5450
|
-
if (
|
|
5451
|
-
|
|
5452
|
-
const abs = path5.resolve(absRoot, rel);
|
|
5453
|
-
const relCheck = path5.relative(absRoot, abs);
|
|
5454
|
-
if (relCheck === "" || !relCheck.startsWith("..") && !path5.isAbsolute(relCheck)) {
|
|
5455
|
-
return abs;
|
|
5456
|
-
}
|
|
5450
|
+
const serverRoot = path5.resolve(_optionalChain([$asai, 'optionalAccess', _685 => _685.serverRoot]) || process.cwd() || ".");
|
|
5451
|
+
const cleaned = String(decoded).replace(/\\/g, "/").trim();
|
|
5452
|
+
if (path5.isAbsolute(cleaned) || /^[a-zA-Z]:/.test(cleaned) || cleaned.startsWith("//")) {
|
|
5453
|
+
return path5.normalize(cleaned);
|
|
5457
5454
|
}
|
|
5455
|
+
const absTarget = path5.resolve(serverRoot, cleaned.replace(/^\.\//, ""));
|
|
5458
5456
|
const roots = _optionalChain([$asai, 'optionalAccess', _686 => _686.asaihost, 'optionalAccess', _687 => _687.getHostAllowedRoots, 'optionalCall', _688 => _688(_optionalChain([$asai, 'optionalAccess', _689 => _689.hostconfig]))]) || [];
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
if (
|
|
5457
|
+
const allow = /* @__PURE__ */ new Set();
|
|
5458
|
+
for (const r of roots) {
|
|
5459
|
+
if (r) allow.add(path5.resolve(r));
|
|
5462
5460
|
}
|
|
5463
|
-
|
|
5464
|
-
|
|
5461
|
+
allow.add(serverRoot);
|
|
5462
|
+
allow.add(path5.resolve(serverRoot, ".."));
|
|
5463
|
+
for (const root of allow) {
|
|
5464
|
+
const rel = path5.relative(root, absTarget);
|
|
5465
|
+
if (rel === "" || !rel.startsWith("..") && !path5.isAbsolute(rel)) {
|
|
5466
|
+
return absTarget;
|
|
5467
|
+
}
|
|
5465
5468
|
}
|
|
5466
|
-
|
|
5469
|
+
throw new Error("Path not allowed");
|
|
5467
5470
|
}
|
|
5468
5471
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getPathFromOpt, "getPathFromOpt");
|
|
5469
5472
|
function sendSuccess(res, data, opt) {
|
|
@@ -5472,18 +5475,18 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5472
5475
|
}
|
|
5473
5476
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendSuccess, "sendSuccess");
|
|
5474
5477
|
function sendErr(res, ec, params, opt) {
|
|
5475
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5476
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5477
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5478
|
+
const ErrorCode = _optionalChain([$asai, 'access', _690 => _690.$lib, 'optionalAccess', _691 => _691.ErrorCode]);
|
|
5479
|
+
_optionalChain([ErrorCode, 'optionalAccess', _692 => _692.loadErrorCodes, 'optionalCall', _693 => _693($asai)]);
|
|
5480
|
+
_optionalChain([ErrorCode, 'optionalAccess', _694 => _694.logError, 'optionalCall', _695 => _695($asai, ec, Array.isArray(params) ? params.map(String) : params != null ? [String(params)] : void 0)]);
|
|
5478
5481
|
const response = $asai.$lib.As.ctxErr(ec, params, opt);
|
|
5479
5482
|
res.end(JSON.stringify(response));
|
|
5480
5483
|
}
|
|
5481
5484
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendErr, "sendErr");
|
|
5482
5485
|
function sendFail(res, err, opt) {
|
|
5483
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5484
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5485
|
-
const normalized = _optionalChain([ErrorCode, 'optionalAccess',
|
|
5486
|
-
if (_optionalChain([normalized, 'optionalAccess',
|
|
5486
|
+
const ErrorCode = _optionalChain([$asai, 'access', _696 => _696.$lib, 'optionalAccess', _697 => _697.ErrorCode]);
|
|
5487
|
+
_optionalChain([ErrorCode, 'optionalAccess', _698 => _698.loadErrorCodes, 'optionalCall', _699 => _699($asai)]);
|
|
5488
|
+
const normalized = _optionalChain([ErrorCode, 'optionalAccess', _700 => _700.normalizeErrPayload, 'optionalCall', _701 => _701(err)]);
|
|
5489
|
+
if (_optionalChain([normalized, 'optionalAccess', _702 => _702.ec])) {
|
|
5487
5490
|
return sendErr(res, normalized.ec, normalized.pm, opt);
|
|
5488
5491
|
}
|
|
5489
5492
|
const response = $asai.$lib.As.ctxFail(err);
|
|
@@ -5491,7 +5494,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5491
5494
|
}
|
|
5492
5495
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendFail, "sendFail");
|
|
5493
5496
|
function mnLog(...arg) {
|
|
5494
|
-
(_optionalChain([$asai, 'optionalAccess',
|
|
5497
|
+
(_optionalChain([$asai, 'optionalAccess', _703 => _703.$log]) || console.log)(...arg);
|
|
5495
5498
|
}
|
|
5496
5499
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mnLog, "mnLog");
|
|
5497
5500
|
return { hostDefault: hostDefault2, getPathFromOpt, sendSuccess, sendFail, sendErr, mnLog };
|
|
@@ -5591,7 +5594,7 @@ async function removeFile(filePath) {
|
|
|
5591
5594
|
try {
|
|
5592
5595
|
await _promises2.default.unlink(nodePath2.default.normalize(filePath));
|
|
5593
5596
|
} catch (err) {
|
|
5594
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
5597
|
+
if (_optionalChain([err, 'optionalAccess', _704 => _704.code]) !== "ENOENT") throw err;
|
|
5595
5598
|
}
|
|
5596
5599
|
}
|
|
5597
5600
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, removeFile, "removeFile");
|
|
@@ -5903,11 +5906,11 @@ function dbDriver(opt = {}) {
|
|
|
5903
5906
|
this.fileExt = config.ext === ".*" ? "" : config.ext || "";
|
|
5904
5907
|
this.fileDel = (config.del || 0) !== 0;
|
|
5905
5908
|
this.createDir = config.create || false;
|
|
5906
|
-
const root = _optionalChain([config, 'access',
|
|
5909
|
+
const root = _optionalChain([config, 'access', _705 => _705.$asai, 'optionalAccess', _706 => _706.serverRoot]) || _chunkHR5JKN7Ycjs.getPrimaryServerRoot.call(void 0, );
|
|
5907
5910
|
this.baseDirAbs = path8.resolve(root, config.dir);
|
|
5908
5911
|
}
|
|
5909
5912
|
dbLog(...args) {
|
|
5910
|
-
(_optionalChain([this, 'access',
|
|
5913
|
+
(_optionalChain([this, 'access', _707 => _707.config, 'optionalAccess', _708 => _708.$asai, 'optionalAccess', _709 => _709.$log]) || console.log)("FILE", ...args);
|
|
5911
5914
|
}
|
|
5912
5915
|
checkFile(file) {
|
|
5913
5916
|
return fs11.existsSync(this.getAbsPath(file, false));
|
|
@@ -5973,7 +5976,7 @@ function dbDriver(opt = {}) {
|
|
|
5973
5976
|
}
|
|
5974
5977
|
getReadPath(file, sql) {
|
|
5975
5978
|
const candidates = [];
|
|
5976
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5979
|
+
if (_optionalChain([sql, 'optionalAccess', _710 => _710.filename])) {
|
|
5977
5980
|
candidates.push({ dir: path8.join(file, sql.filename) });
|
|
5978
5981
|
candidates.push({ dir: path8.join(file + ".delete" + this.fileExt, sql.filename) });
|
|
5979
5982
|
} else {
|
|
@@ -5993,20 +5996,20 @@ function dbDriver(opt = {}) {
|
|
|
5993
5996
|
if (!read2.path) {
|
|
5994
5997
|
return { path: "", dir: read2.dir };
|
|
5995
5998
|
}
|
|
5996
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5999
|
+
if (_optionalChain([sql, 'optionalAccess', _711 => _711.filename])) {
|
|
5997
6000
|
return { path: path8.dirname(read2.path), dir: path8.dirname(read2.dir) };
|
|
5998
6001
|
}
|
|
5999
6002
|
return { path: read2.path, dir: read2.dir };
|
|
6000
6003
|
}
|
|
6001
6004
|
getNewPath(file, sql) {
|
|
6002
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
6005
|
+
if (_optionalChain([sql, 'optionalAccess', _712 => _712.filename])) {
|
|
6003
6006
|
return this.getAbsPath(path8.join(file, sql.filename), true);
|
|
6004
6007
|
}
|
|
6005
6008
|
return this.getAbsPath(file, true);
|
|
6006
6009
|
}
|
|
6007
6010
|
write(file, data, sql) {
|
|
6008
6011
|
try {
|
|
6009
|
-
const filePath = _optionalChain([sql, 'optionalAccess',
|
|
6012
|
+
const filePath = _optionalChain([sql, 'optionalAccess', _713 => _713.type]) === "insert" ? this.getNewPath(file, sql) : this.getReadPath(file, sql).path || this.getNewPath(file, sql);
|
|
6010
6013
|
this.dbLog("write", "[WRITE]", filePath);
|
|
6011
6014
|
fs11.writeFileSync(filePath, data, "utf8");
|
|
6012
6015
|
return "ok";
|
|
@@ -6036,11 +6039,11 @@ function dbDriver(opt = {}) {
|
|
|
6036
6039
|
if (!del.path) {
|
|
6037
6040
|
return "";
|
|
6038
6041
|
}
|
|
6039
|
-
if (this.fileDel && _optionalChain([sql, 'optionalAccess',
|
|
6042
|
+
if (this.fileDel && _optionalChain([sql, 'optionalAccess', _714 => _714.deltrue])) {
|
|
6040
6043
|
const target = del.path + ".delete" + this.fileExt;
|
|
6041
6044
|
this.dbLog("soft delete", "[SOFT DELETE]", `${del.path} -> ${target}`);
|
|
6042
6045
|
fs11.renameSync(del.path, target);
|
|
6043
|
-
} else if (_optionalChain([sql, 'optionalAccess',
|
|
6046
|
+
} else if (_optionalChain([sql, 'optionalAccess', _715 => _715.filename])) {
|
|
6044
6047
|
this.deldir(del.dir);
|
|
6045
6048
|
} else {
|
|
6046
6049
|
this.dbLog("delete", "[DELETE]", del.path);
|
|
@@ -6083,7 +6086,7 @@ function dbDriver(opt = {}) {
|
|
|
6083
6086
|
try {
|
|
6084
6087
|
entries = fs11.readdirSync(absDir, { withFileTypes: true });
|
|
6085
6088
|
} catch (e57) {
|
|
6086
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
6089
|
+
return _optionalChain([sql, 'optionalAccess', _716 => _716.list]) ? { open: [], delete: [] } : [];
|
|
6087
6090
|
}
|
|
6088
6091
|
const result = { open: [], delete: [] };
|
|
6089
6092
|
const deleteSuffix = ".delete" + this.fileExt;
|
|
@@ -6098,14 +6101,14 @@ function dbDriver(opt = {}) {
|
|
|
6098
6101
|
const data = fs11.readFileSync(fullPath, "utf8");
|
|
6099
6102
|
const entryData = { data, file: baseName };
|
|
6100
6103
|
if (isDelete) {
|
|
6101
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
6104
|
+
if (_optionalChain([sql, 'optionalAccess', _717 => _717.list])) result.delete.push(entryData);
|
|
6102
6105
|
} else {
|
|
6103
6106
|
result.open.push(entryData);
|
|
6104
6107
|
}
|
|
6105
6108
|
} catch (e58) {
|
|
6106
6109
|
}
|
|
6107
6110
|
}
|
|
6108
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
6111
|
+
return _optionalChain([sql, 'optionalAccess', _718 => _718.list]) ? result : result.open;
|
|
6109
6112
|
} catch (e) {
|
|
6110
6113
|
this.dbLog("list failed", "[LIST ERROR]", e);
|
|
6111
6114
|
return e;
|
|
@@ -6115,7 +6118,7 @@ function dbDriver(opt = {}) {
|
|
|
6115
6118
|
getFileNameFromWhere(where) {
|
|
6116
6119
|
if (!where || !Array.isArray(where)) return "";
|
|
6117
6120
|
const first = where.find((item) => Array.isArray(item));
|
|
6118
|
-
const raw = _optionalChain([first, 'optionalAccess',
|
|
6121
|
+
const raw = _optionalChain([first, 'optionalAccess', _719 => _719[2]]);
|
|
6119
6122
|
if (typeof raw === "string") {
|
|
6120
6123
|
return raw.replace(/^'+|'+$/g, "");
|
|
6121
6124
|
}
|
|
@@ -6140,15 +6143,15 @@ function dbDriver(opt = {}) {
|
|
|
6140
6143
|
const data = sql.set[0][1];
|
|
6141
6144
|
result = this.write(this.tableFilePath(sql.table, file), data, sql);
|
|
6142
6145
|
} else if (sql.type === "select") {
|
|
6143
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
6146
|
+
if (_optionalChain([sql, 'optionalAccess', _720 => _720.where, 'optionalAccess', _721 => _721.length]) && _optionalChain([sql, 'optionalAccess', _722 => _722.as]) !== 2) {
|
|
6144
6147
|
const file = this.getFileNameFromWhere(sql.where);
|
|
6145
6148
|
const readRes = this.read(this.tableFilePath(sql.table, file), sql);
|
|
6146
6149
|
const resObj = {};
|
|
6147
|
-
if (_optionalChain([readRes, 'optionalAccess',
|
|
6150
|
+
if (_optionalChain([readRes, 'optionalAccess', _723 => _723[0], 'optionalAccess', _724 => _724.file]) && !readRes.error) {
|
|
6148
6151
|
if (sql.as === 1) {
|
|
6149
6152
|
try {
|
|
6150
6153
|
const parsed = JSON.parse(readRes[0].data);
|
|
6151
|
-
if (_optionalChain([sql, 'access',
|
|
6154
|
+
if (_optionalChain([sql, 'access', _725 => _725.field, 'optionalAccess', _726 => _726.length])) {
|
|
6152
6155
|
sql.field.forEach((f) => {
|
|
6153
6156
|
resObj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
6154
6157
|
});
|
|
@@ -6169,7 +6172,7 @@ function dbDriver(opt = {}) {
|
|
|
6169
6172
|
} else {
|
|
6170
6173
|
const listRes = this.list(tableDir, sql);
|
|
6171
6174
|
if (listRes && !listRes.error) {
|
|
6172
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
6175
|
+
if (_optionalChain([sql, 'optionalAccess', _727 => _727.list])) {
|
|
6173
6176
|
const mapEntry = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (el) => {
|
|
6174
6177
|
const fields = sql.field;
|
|
6175
6178
|
const item = { [fields[0]]: el.file };
|
|
@@ -6180,9 +6183,9 @@ function dbDriver(opt = {}) {
|
|
|
6180
6183
|
if (listRes.delete) listRes.delete = listRes.delete.map(mapEntry);
|
|
6181
6184
|
result = listRes;
|
|
6182
6185
|
} else {
|
|
6183
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
6186
|
+
if (_optionalChain([sql, 'optionalAccess', _728 => _728.as]) === 2) {
|
|
6184
6187
|
let items = listRes;
|
|
6185
|
-
if (_optionalChain([sql, 'access',
|
|
6188
|
+
if (_optionalChain([sql, 'access', _729 => _729.where, 'optionalAccess', _730 => _730.length])) {
|
|
6186
6189
|
const where = sql.where;
|
|
6187
6190
|
const whereType = typeof where[0] === "string" ? where[0] : "and";
|
|
6188
6191
|
items = items.filter((el) => {
|
|
@@ -6214,7 +6217,7 @@ function dbDriver(opt = {}) {
|
|
|
6214
6217
|
const obj = {};
|
|
6215
6218
|
try {
|
|
6216
6219
|
const parsed = JSON.parse(el.data);
|
|
6217
|
-
if (_optionalChain([sql, 'access',
|
|
6220
|
+
if (_optionalChain([sql, 'access', _731 => _731.field, 'optionalAccess', _732 => _732.length])) {
|
|
6218
6221
|
sql.field.forEach((f) => {
|
|
6219
6222
|
obj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
6220
6223
|
});
|
|
@@ -6225,7 +6228,7 @@ function dbDriver(opt = {}) {
|
|
|
6225
6228
|
}
|
|
6226
6229
|
return obj;
|
|
6227
6230
|
});
|
|
6228
|
-
if (_optionalChain([sql, 'access',
|
|
6231
|
+
if (_optionalChain([sql, 'access', _733 => _733.order, 'optionalAccess', _734 => _734.length])) {
|
|
6229
6232
|
const orderField = sql.order[0];
|
|
6230
6233
|
const orderFieldName = typeof orderField === "string" ? orderField : orderField[0];
|
|
6231
6234
|
const direction = typeof orderField === "string" ? "ASC" : String(orderField[1]).toUpperCase();
|
|
@@ -6246,7 +6249,7 @@ function dbDriver(opt = {}) {
|
|
|
6246
6249
|
}
|
|
6247
6250
|
}
|
|
6248
6251
|
} else {
|
|
6249
|
-
result = _optionalChain([sql, 'optionalAccess',
|
|
6252
|
+
result = _optionalChain([sql, 'optionalAccess', _735 => _735.list]) ? { open: [], delete: [] } : [];
|
|
6250
6253
|
}
|
|
6251
6254
|
}
|
|
6252
6255
|
}
|
|
@@ -6302,7 +6305,7 @@ function sysserver($asai, opt = {}) {
|
|
|
6302
6305
|
if (!$asai.$lib) $asai.$lib = {};
|
|
6303
6306
|
$asai.$lib = { ...lib_default, ...$asai.$lib, ...opt || {} };
|
|
6304
6307
|
$asai.dataserver = db_default;
|
|
6305
|
-
_optionalChain([$asai, 'access',
|
|
6308
|
+
_optionalChain([$asai, 'access', _736 => _736.$lib, 'access', _737 => _737.ErrorCode, 'optionalAccess', _738 => _738.loadErrorCodes, 'optionalCall', _739 => _739($asai)]);
|
|
6306
6309
|
if (!$asai.$lib.api) $asai.$lib.api = {};
|
|
6307
6310
|
$asai.$lib.api = { ...api_default, ...$asai.$lib.api };
|
|
6308
6311
|
if (!$asai.$lib.ws) $asai.$lib.ws = {};
|
|
@@ -6495,7 +6498,7 @@ function normalizeDataStoresConfig(cfg) {
|
|
|
6495
6498
|
}
|
|
6496
6499
|
if (userStore.opt.create == null) userStore.opt.create = 1;
|
|
6497
6500
|
}
|
|
6498
|
-
if (!stores.log && _optionalChain([cfg, 'access',
|
|
6501
|
+
if (!stores.log && _optionalChain([cfg, 'access', _740 => _740.logger, 'optionalAccess', _741 => _741.store])) {
|
|
6499
6502
|
const s = cfg.logger.store;
|
|
6500
6503
|
stores.log = {
|
|
6501
6504
|
type: s.type || "file",
|
|
@@ -6559,13 +6562,13 @@ function validateHostConfig(cfg) {
|
|
|
6559
6562
|
if (cfg.asaisn != null) {
|
|
6560
6563
|
errors.push("asaisn \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_ASAISN");
|
|
6561
6564
|
}
|
|
6562
|
-
if (_optionalChain([cfg, 'access',
|
|
6565
|
+
if (_optionalChain([cfg, 'access', _742 => _742.aes, 'optionalAccess', _743 => _743.keybase64]) != null) {
|
|
6563
6566
|
errors.push("aes.keybase64 \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_AES_KEYBASE64");
|
|
6564
6567
|
}
|
|
6565
|
-
if (_optionalChain([cfg, 'access',
|
|
6568
|
+
if (_optionalChain([cfg, 'access', _744 => _744.httpscert, 'optionalAccess', _745 => _745.key]) != null || _optionalChain([cfg, 'access', _746 => _746.httpscert, 'optionalAccess', _747 => _747.cert]) != null) {
|
|
6566
6569
|
errors.push("httpscert.key/cert \u7981\u6B62\u5185\u8054\u4E8E asaihost.json\uFF0C\u8BF7\u4F7F\u7528 keyPath/certPath \u6216\u73AF\u5883\u53D8\u91CF");
|
|
6567
6570
|
}
|
|
6568
|
-
if (_optionalChain([cfg, 'access',
|
|
6571
|
+
if (_optionalChain([cfg, 'access', _748 => _748.security, 'optionalAccess', _749 => _749.sessionSecret]) != null) {
|
|
6569
6572
|
errors.push("security.sessionSecret \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_SESSION_SECRET");
|
|
6570
6573
|
}
|
|
6571
6574
|
if (Array.isArray(cfg.wssec) && typeof cfg.wssec[0] === "string" && cfg.wssec[0].length > 0) {
|
|
@@ -6620,10 +6623,10 @@ function validateHostConfig(cfg) {
|
|
|
6620
6623
|
validateHostSiteLimits(name, h, errors);
|
|
6621
6624
|
}
|
|
6622
6625
|
}
|
|
6623
|
-
if (_optionalChain([cfg, 'access',
|
|
6626
|
+
if (_optionalChain([cfg, 'access', _750 => _750.logger, 'optionalAccess', _751 => _751.sample]) && typeof cfg.logger.sample !== "object") {
|
|
6624
6627
|
errors.push('logger.sample \u5FC5\u987B\u4E3A\u5BF9\u8C61\uFF08\u5982 { "REQ_OTHER": 0.1 }\uFF09');
|
|
6625
6628
|
}
|
|
6626
|
-
if (_optionalChain([cfg, 'access',
|
|
6629
|
+
if (_optionalChain([cfg, 'access', _752 => _752.logger, 'optionalAccess', _753 => _753.skip]) != null && !Array.isArray(cfg.logger.skip)) {
|
|
6627
6630
|
errors.push('logger.skip \u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5982 ["/sys/info/metrics"]\uFF09');
|
|
6628
6631
|
}
|
|
6629
6632
|
if (cfg.proxyhosts && typeof cfg.proxyhosts === "object") {
|
|
@@ -6657,7 +6660,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, validateHostSiteLimits, "validateHostSiteL
|
|
|
6657
6660
|
function validateProductionSecurity(cfg) {
|
|
6658
6661
|
const errors = [];
|
|
6659
6662
|
if (process.env.NODE_ENV !== "production") return errors;
|
|
6660
|
-
const sec = _optionalChain([cfg, 'optionalAccess',
|
|
6663
|
+
const sec = _optionalChain([cfg, 'optionalAccess', _754 => _754.security]);
|
|
6661
6664
|
if (!sec || typeof sec !== "object") {
|
|
6662
6665
|
errors.push("\u751F\u4EA7\u73AF\u5883\u5FC5\u987B\u914D\u7F6E security \u5BF9\u8C61");
|
|
6663
6666
|
return errors;
|
|
@@ -6668,7 +6671,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6668
6671
|
if (sec.allowRegister === 1) {
|
|
6669
6672
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.allowRegister \u5E94\u4E3A 0\uFF08CR 1.3 \u7981\u6B62\u5F00\u653E\u6CE8\u518C\uFF09");
|
|
6670
6673
|
}
|
|
6671
|
-
if (!_optionalChain([sec, 'access',
|
|
6674
|
+
if (!_optionalChain([sec, 'access', _755 => _755.quota, 'optionalAccess', _756 => _756.enabled])) {
|
|
6672
6675
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.quota.enabled \u5E94\u4E3A 1\uFF08CR 7.1 \u8D44\u6E90\u9650\u5236\uFF09");
|
|
6673
6676
|
}
|
|
6674
6677
|
if (sec.csp !== 1) {
|
|
@@ -6677,7 +6680,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6677
6680
|
if (typeof sec.minUserLevel !== "number" || sec.minUserLevel < 0) {
|
|
6678
6681
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.minUserLevel \u5E94\u663E\u5F0F\u914D\u7F6E");
|
|
6679
6682
|
}
|
|
6680
|
-
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess',
|
|
6683
|
+
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess', _757 => _757.httpscert, 'optionalAccess', _758 => _758.keyPath]) && !_optionalChain([cfg, 'optionalAccess', _759 => _759.httpscert, 'optionalAccess', _760 => _760.key])) {
|
|
6681
6684
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.forceWss=1 \u65F6\u9700\u914D\u7F6E HTTPS \u8BC1\u4E66");
|
|
6682
6685
|
}
|
|
6683
6686
|
return errors;
|
|
@@ -6696,12 +6699,12 @@ var DEFAULT_RECONNECT = {
|
|
|
6696
6699
|
rs485: { enabled: true, maxRetries: 60, initialDelay: 3e3, maxDelay: 3e4, factor: 2 }
|
|
6697
6700
|
};
|
|
6698
6701
|
function getTransportBlock(cfg, kind) {
|
|
6699
|
-
const block = _optionalChain([cfg, 'optionalAccess',
|
|
6702
|
+
const block = _optionalChain([cfg, 'optionalAccess', _761 => _761[kind]]);
|
|
6700
6703
|
return block && typeof block === "object" ? block : null;
|
|
6701
6704
|
}
|
|
6702
6705
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportBlock, "getTransportBlock");
|
|
6703
6706
|
function getTransportDefault(cfg, kind) {
|
|
6704
|
-
const def = _optionalChain([getTransportBlock, 'call',
|
|
6707
|
+
const def = _optionalChain([getTransportBlock, 'call', _762 => _762(cfg, kind), 'optionalAccess', _763 => _763.default]);
|
|
6705
6708
|
return def && typeof def === "object" ? def : null;
|
|
6706
6709
|
}
|
|
6707
6710
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportDefault, "getTransportDefault");
|
|
@@ -6711,7 +6714,7 @@ function hasTransportDefault(cfg, kind) {
|
|
|
6711
6714
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasTransportDefault, "hasTransportDefault");
|
|
6712
6715
|
function getDefaultConnId(cfg, kind) {
|
|
6713
6716
|
const def = getTransportDefault(cfg, kind);
|
|
6714
|
-
const id = _optionalChain([def, 'optionalAccess',
|
|
6717
|
+
const id = _optionalChain([def, 'optionalAccess', _764 => _764.id]);
|
|
6715
6718
|
return typeof id === "string" && id.length > 0 ? id : DEFAULT_CONN_ID[kind];
|
|
6716
6719
|
}
|
|
6717
6720
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getDefaultConnId, "getDefaultConnId");
|
|
@@ -6722,14 +6725,14 @@ function shouldAutoConnect(def) {
|
|
|
6722
6725
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, shouldAutoConnect, "shouldAutoConnect");
|
|
6723
6726
|
function resolveReconnectOptions(def, kind, cfg) {
|
|
6724
6727
|
const base = DEFAULT_RECONNECT[kind];
|
|
6725
|
-
const rc = _optionalChain([def, 'optionalAccess',
|
|
6726
|
-
const tmMaxTry = _optionalChain([cfg, 'optionalAccess',
|
|
6728
|
+
const rc = _optionalChain([def, 'optionalAccess', _765 => _765.reconnect]);
|
|
6729
|
+
const tmMaxTry = _optionalChain([cfg, 'optionalAccess', _766 => _766.tm, 'optionalAccess', _767 => _767.maxtry]);
|
|
6727
6730
|
return {
|
|
6728
|
-
enabled: _optionalChain([rc, 'optionalAccess',
|
|
6729
|
-
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6730
|
-
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6731
|
-
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6732
|
-
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6731
|
+
enabled: _optionalChain([rc, 'optionalAccess', _768 => _768.enabled]) !== false && base.enabled !== false,
|
|
6732
|
+
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _769 => _769.maxRetries]), () => ( tmMaxTry)), () => ( base.maxRetries)), () => ( 60)),
|
|
6733
|
+
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _770 => _770.initialDelay]), () => ( base.initialDelay)), () => ( 1e3)),
|
|
6734
|
+
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _771 => _771.maxDelay]), () => ( base.maxDelay)), () => ( 3e4)),
|
|
6735
|
+
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _772 => _772.factor]), () => ( base.factor)), () => ( 2))
|
|
6733
6736
|
};
|
|
6734
6737
|
}
|
|
6735
6738
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveReconnectOptions, "resolveReconnectOptions");
|
|
@@ -6782,13 +6785,13 @@ function createTransportDataHandler($asai, manager) {
|
|
|
6782
6785
|
} catch (e62) {
|
|
6783
6786
|
}
|
|
6784
6787
|
}
|
|
6785
|
-
if (_optionalChain([event, 'access',
|
|
6788
|
+
if (_optionalChain([event, 'access', _773 => _773.data, 'optionalAccess', _774 => _774.id])) {
|
|
6786
6789
|
manager.watch(event.id, event.data);
|
|
6787
6790
|
return;
|
|
6788
6791
|
}
|
|
6789
6792
|
try {
|
|
6790
|
-
const wsKey = _optionalChain([$asai, 'optionalAccess',
|
|
6791
|
-
_optionalChain([$asai, 'access',
|
|
6793
|
+
const wsKey = _optionalChain([$asai, 'optionalAccess', _775 => _775.command, 'optionalAccess', _776 => _776.commandconfig, 'optionalAccess', _777 => _777.config, 'optionalAccess', _778 => _778.commandclient]);
|
|
6794
|
+
_optionalChain([$asai, 'access', _779 => _779.serversws, 'optionalAccess', _780 => _780[wsKey], 'optionalAccess', _781 => _781.broadws, 'optionalCall', _782 => _782(event.data)]);
|
|
6792
6795
|
} catch (e63) {
|
|
6793
6796
|
}
|
|
6794
6797
|
};
|
|
@@ -6861,7 +6864,7 @@ var initAsaiHostNodejs2 = {
|
|
|
6861
6864
|
createTransportDataHandler,
|
|
6862
6865
|
wireTransportConnectionLogs
|
|
6863
6866
|
};
|
|
6864
|
-
var PLUGIN_VERSION = true ? "0.0.
|
|
6867
|
+
var PLUGIN_VERSION = true ? "0.0.11" : "0.0.1";
|
|
6865
6868
|
var index_default = initAsaiHostNodejs2;
|
|
6866
6869
|
|
|
6867
6870
|
|