qq-bot-roost 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs//345/217/221/347/211/210/346/270/205/345/215/225.md +9 -10
- package/docs//345/274/200/346/224/276/345/271/263/345/217/260/346/216/245/345/217/243.md +17 -0
- package/docs//346/236/266/346/236/204/350/257/264/346/230/216.md +44 -0
- package/package.json +1 -1
- package/src/api.js +6 -0
- package/src/bot.js +37 -2
- package/src/dev/browser.js +81 -0
- package/src/dev/platform.js +96 -0
- package/src/host/ops.js +14 -23
- package/src/mail/verify.js +3 -0
- package/src/onebot/ids.js +33 -16
- package/src/outbound.js +30 -3
- package/src/plugin/market.js +8 -45
- package/src/proxy.js +3 -0
- package/src/trust.js +7 -5
- package/src/updater.js +1 -1
- package/src/web/server.js +22 -26
- package/web/app.js +937 -153
- package/web/index.html +128 -34
- package/web/style.css +534 -193
- package/web/theme-boot.js +56 -5
package/src/onebot/ids.js
CHANGED
|
@@ -52,6 +52,17 @@ export class OneBotIds {
|
|
|
52
52
|
/** openid → 合成号(反查用) */
|
|
53
53
|
this.synthUsers = new Map();
|
|
54
54
|
this.synthGroups = new Map();
|
|
55
|
+
/**
|
|
56
|
+
* 合成号占用表,与上面两个 Map 严格同增同存(本类不淘汰合成号)。
|
|
57
|
+
* #synth 原来每次 `new Set([...bucket.values()])` 做碰撞检测是 O(n) 分配,
|
|
58
|
+
* 几万路人时每次新 openid 都要全量扫一遍。这里按 bucket 各留一份 Set,
|
|
59
|
+
* 判碰撞变 O(1) 查。
|
|
60
|
+
*/
|
|
61
|
+
this.usedUserNums = new Set();
|
|
62
|
+
this.usedGroupNums = new Set();
|
|
63
|
+
/** 合成号 → openid 反查索引,替掉 openidOfUser/Group 的 O(n) 遍历 */
|
|
64
|
+
this.userNumToOpenid = new Map();
|
|
65
|
+
this.groupNumToOpenid = new Map();
|
|
55
66
|
/** onebot message_id → {m: 官方 msg_id, i: msgIdx, c: chatId, t: 时间} */
|
|
56
67
|
this.msgs = new Map();
|
|
57
68
|
/** 官方 msg_id → onebot message_id(同一条消息重复推送时复用) */
|
|
@@ -76,8 +87,18 @@ export class OneBotIds {
|
|
|
76
87
|
this.data.groups ??= {};
|
|
77
88
|
this.data.msgs ??= [];
|
|
78
89
|
|
|
79
|
-
for (const [openid, id] of Object.entries(this.data.users))
|
|
80
|
-
|
|
90
|
+
for (const [openid, id] of Object.entries(this.data.users)) {
|
|
91
|
+
const n = Number(id);
|
|
92
|
+
this.synthUsers.set(openid, n);
|
|
93
|
+
this.usedUserNums.add(n);
|
|
94
|
+
this.userNumToOpenid.set(n, openid);
|
|
95
|
+
}
|
|
96
|
+
for (const [openid, id] of Object.entries(this.data.groups)) {
|
|
97
|
+
const n = Number(id);
|
|
98
|
+
this.synthGroups.set(openid, n);
|
|
99
|
+
this.usedGroupNums.add(n);
|
|
100
|
+
this.groupNumToOpenid.set(n, openid);
|
|
101
|
+
}
|
|
81
102
|
for (const row of this.data.msgs) {
|
|
82
103
|
if (!Array.isArray(row) || row.length !== 2) continue;
|
|
83
104
|
const [id, v] = row;
|
|
@@ -92,15 +113,17 @@ export class OneBotIds {
|
|
|
92
113
|
/* ---------------- 号码 ---------------- */
|
|
93
114
|
|
|
94
115
|
/** 合成号:稳定、13 位、9 开头 */
|
|
95
|
-
#synth(openid, bucket) {
|
|
116
|
+
#synth(openid, bucket, used, reverse) {
|
|
96
117
|
const hit = bucket.get(openid);
|
|
97
118
|
if (hit) return hit;
|
|
98
119
|
const h = crypto.createHash('sha1').update(String(openid)).digest();
|
|
99
120
|
let n = SYNTH_BASE + (h.readUIntBE(0, 6) % SYNTH_MOD);
|
|
100
|
-
// 理论上可能撞(同一机器人下的两个 openid
|
|
101
|
-
|
|
121
|
+
// 理论上可能撞(同一机器人下的两个 openid 截断到同一值),撞了就顺延。
|
|
122
|
+
// 用常驻 Set 判占用,不再每次 new Set 全量扫(见构造函数注释)。
|
|
102
123
|
while (used.has(n)) n += 1;
|
|
103
124
|
bucket.set(openid, n);
|
|
125
|
+
used.add(n);
|
|
126
|
+
reverse.set(n, openid);
|
|
104
127
|
this.#touch();
|
|
105
128
|
return n;
|
|
106
129
|
}
|
|
@@ -111,7 +134,7 @@ export class OneBotIds {
|
|
|
111
134
|
if (!id) return 0;
|
|
112
135
|
const uin = this.identity?.uinOf?.(id) ?? '';
|
|
113
136
|
if (uin) return Number(uin);
|
|
114
|
-
return this.#synth(id, this.synthUsers);
|
|
137
|
+
return this.#synth(id, this.synthUsers, this.usedUserNums, this.userNumToOpenid);
|
|
115
138
|
}
|
|
116
139
|
|
|
117
140
|
/** group_openid → OneBot group_id(真号优先) */
|
|
@@ -120,28 +143,22 @@ export class OneBotIds {
|
|
|
120
143
|
if (!id) return 0;
|
|
121
144
|
const uin = this.identity?.groupUinOf?.(id) ?? '';
|
|
122
145
|
if (uin) return Number(uin);
|
|
123
|
-
return this.#synth(id, this.synthGroups);
|
|
146
|
+
return this.#synth(id, this.synthGroups, this.usedGroupNums, this.groupNumToOpenid);
|
|
124
147
|
}
|
|
125
148
|
|
|
126
149
|
/** OneBot user_id → openid;找不到返回空串 */
|
|
127
150
|
openidOfUser(id) {
|
|
128
151
|
const n = Number(id);
|
|
129
152
|
if (!Number.isFinite(n) || n <= 0) return '';
|
|
130
|
-
//
|
|
131
|
-
if (n >= SYNTH_BASE)
|
|
132
|
-
for (const [openid, v] of this.synthUsers) if (v === n) return openid;
|
|
133
|
-
return '';
|
|
134
|
-
}
|
|
153
|
+
// 合成号段:只可能是我们发出去的,反查索引里一定有
|
|
154
|
+
if (n >= SYNTH_BASE) return this.userNumToOpenid.get(n) ?? '';
|
|
135
155
|
return this.identity?.openidOf?.(this.botId, String(n)) ?? '';
|
|
136
156
|
}
|
|
137
157
|
|
|
138
158
|
openidOfGroup(id) {
|
|
139
159
|
const n = Number(id);
|
|
140
160
|
if (!Number.isFinite(n) || n <= 0) return '';
|
|
141
|
-
if (n >= SYNTH_BASE)
|
|
142
|
-
for (const [openid, v] of this.synthGroups) if (v === n) return openid;
|
|
143
|
-
return '';
|
|
144
|
-
}
|
|
161
|
+
if (n >= SYNTH_BASE) return this.groupNumToOpenid.get(n) ?? '';
|
|
145
162
|
return this.identity?.groupOpenidOf?.(this.botId, String(n)) ?? '';
|
|
146
163
|
}
|
|
147
164
|
|
package/src/outbound.js
CHANGED
|
@@ -6,6 +6,9 @@ import { DIRS } from './paths.js';
|
|
|
6
6
|
|
|
7
7
|
const log = createLogger('outbound');
|
|
8
8
|
|
|
9
|
+
/** 队列空闲多久后回收(分钟)。有会话在发就一直续,停了才删键 */
|
|
10
|
+
const QUEUE_IDLE_MS = 60 * 1000;
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* 出站消息调度器。
|
|
11
14
|
*
|
|
@@ -293,8 +296,10 @@ export class Outbound {
|
|
|
293
296
|
* @param {object} opts.cfg 全局配置
|
|
294
297
|
* @param {() => boolean} opts.isOnline 机器人是否已连上网关
|
|
295
298
|
*/
|
|
296
|
-
constructor({ api, cfg, isOnline = () => true, quotaFile, delivery = null, ledger = null }) {
|
|
299
|
+
constructor({ api, cfg, isOnline = () => true, quotaFile, delivery = null, ledger = null, queueIdleMs = QUEUE_IDLE_MS }) {
|
|
297
300
|
this.api = api;
|
|
301
|
+
/** 队列空闲回收时长(毫秒)。默认 60s,测试可传短值 */
|
|
302
|
+
this.queueIdleMs = Math.max(1, Number(queueIdleMs) || QUEUE_IDLE_MS);
|
|
298
303
|
/** 投递账本(阶段 5)。没有它就退回原来的「发一次算一次」 */
|
|
299
304
|
this.delivery = delivery;
|
|
300
305
|
/**
|
|
@@ -337,7 +342,7 @@ export class Outbound {
|
|
|
337
342
|
|
|
338
343
|
// 额度账本按机器人分开,不同机器人的额度互不影响
|
|
339
344
|
this.quota = new QuotaLedger(quotaFile ?? path.join(DIRS.data, 'quota.json'));
|
|
340
|
-
/** chatKey -> { chain: Promise, history: number[] } */
|
|
345
|
+
/** chatKey -> { chain: Promise, history: number[], idleTimer } */
|
|
341
346
|
this.queues = new Map();
|
|
342
347
|
|
|
343
348
|
this.stats = {
|
|
@@ -798,9 +803,16 @@ export class Outbound {
|
|
|
798
803
|
#enqueue(chatKey, task) {
|
|
799
804
|
let q = this.queues.get(chatKey);
|
|
800
805
|
if (!q) {
|
|
801
|
-
q = { chain: Promise.resolve(), history: [] };
|
|
806
|
+
q = { chain: Promise.resolve(), history: [], idleTimer: null, idleGen: 0 };
|
|
802
807
|
this.queues.set(chatKey, q);
|
|
803
808
|
}
|
|
809
|
+
// 有活了:撤销上一次排的空闲回收(连同它那代编号一起作废)
|
|
810
|
+
if (q.idleTimer) {
|
|
811
|
+
clearTimeout(q.idleTimer);
|
|
812
|
+
q.idleTimer = null;
|
|
813
|
+
}
|
|
814
|
+
q.idleGen += 1;
|
|
815
|
+
const gen = q.idleGen;
|
|
804
816
|
const run = q.chain.then(async () => {
|
|
805
817
|
await this.#throttle(q);
|
|
806
818
|
return task();
|
|
@@ -810,9 +822,24 @@ export class Outbound {
|
|
|
810
822
|
() => {},
|
|
811
823
|
() => {},
|
|
812
824
|
);
|
|
825
|
+
// 这一批任务跑完后排空闲回收:只有「仍是同一个 q、代号没变」才删,
|
|
826
|
+
// 这样后来入队的任务撤销旧 timer 后,旧回调不会误删正在用的队列。
|
|
827
|
+
q.chain.then(() => this.#retireIdleQueue(chatKey, q, gen));
|
|
813
828
|
return run;
|
|
814
829
|
}
|
|
815
830
|
|
|
831
|
+
/** 队列空闲 QUEUE_IDLE_MS 后删键;代号不匹配说明期间又有新任务,放弃本次回收 */
|
|
832
|
+
#retireIdleQueue(chatKey, q, gen) {
|
|
833
|
+
const timer = setTimeout(() => {
|
|
834
|
+
q.idleTimer = null;
|
|
835
|
+
if (q.idleGen !== gen) return;
|
|
836
|
+
if (this.queues.get(chatKey) !== q) return;
|
|
837
|
+
this.queues.delete(chatKey);
|
|
838
|
+
}, this.queueIdleMs);
|
|
839
|
+
timer.unref?.();
|
|
840
|
+
q.idleTimer = timer;
|
|
841
|
+
}
|
|
842
|
+
|
|
816
843
|
async #throttle(q) {
|
|
817
844
|
for (;;) {
|
|
818
845
|
const now = Date.now();
|
package/src/plugin/market.js
CHANGED
|
@@ -11,7 +11,6 @@ import { compareVersion } from '../semver.js';
|
|
|
11
11
|
import { fetchViaMirror, currentMirror } from '../mirror.js';
|
|
12
12
|
import { fetchGiteeTree } from '../gitee.js';
|
|
13
13
|
import { CORE_SKIP } from '../skipdirs.js';
|
|
14
|
-
import { resolveTrust, checkTrust } from '../trust.js';
|
|
15
14
|
|
|
16
15
|
const log = createLogger('market');
|
|
17
16
|
|
|
@@ -142,7 +141,7 @@ function assertSafeIndexUrl(raw) {
|
|
|
142
141
|
|
|
143
142
|
/**
|
|
144
143
|
* @param {string} [url]
|
|
145
|
-
* @param {{
|
|
144
|
+
* @param {{maxAge?: number}} [opts] `maxAge` 是内存缓存的新鲜期
|
|
146
145
|
* (毫秒,默认 60 秒;传 0 表示强制重新拉取,写路径必须这么传)
|
|
147
146
|
*/
|
|
148
147
|
export async function fetchIndex(url = DEFAULT_INDEX_URL, opts = {}) {
|
|
@@ -163,7 +162,7 @@ export async function fetchIndex(url = DEFAULT_INDEX_URL, opts = {}) {
|
|
|
163
162
|
const running = indexInFlight.get(key);
|
|
164
163
|
if (running) return running;
|
|
165
164
|
|
|
166
|
-
const task = fetchIndexOnce(key
|
|
165
|
+
const task = fetchIndexOnce(key)
|
|
167
166
|
.then(async (data) => {
|
|
168
167
|
indexCache.set(key, { at: Date.now(), data });
|
|
169
168
|
await writeIndexCache(key, data).catch(() => {});
|
|
@@ -216,33 +215,7 @@ async function readIndexCache(url) {
|
|
|
216
215
|
return { data: obj.data, age };
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
|
|
220
|
-
* 拉 `.sig`。**只有配了公钥才拉**——没配就是本版不验签,多一次请求纯属浪费,
|
|
221
|
-
* 也会让离线/镜像用户多等一次超时。
|
|
222
|
-
*
|
|
223
|
-
* 地址构造用 `URL` 而不是字符串拼接:自定义市场源可能带 query,
|
|
224
|
-
* 直接拼 `.sig` 会拼到 query 后面去。
|
|
225
|
-
*/
|
|
226
|
-
async function fetchIndexSig(url, bust) {
|
|
227
|
-
let sigUrl;
|
|
228
|
-
try {
|
|
229
|
-
const u = new URL(url);
|
|
230
|
-
u.pathname = `${u.pathname}.sig`;
|
|
231
|
-
u.searchParams.set('_t', bust);
|
|
232
|
-
sigUrl = u.toString();
|
|
233
|
-
} catch {
|
|
234
|
-
return '';
|
|
235
|
-
}
|
|
236
|
-
try {
|
|
237
|
-
const res = await fetchViaMirror(sigUrl, { signal: AbortSignal.timeout(8000) }, { retry4xx: true });
|
|
238
|
-
if (!res.ok) return '';
|
|
239
|
-
return await res.text();
|
|
240
|
-
} catch {
|
|
241
|
-
return '';
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async function fetchIndexOnce(url, opts = {}) {
|
|
218
|
+
async function fetchIndexOnce(url) {
|
|
246
219
|
let lastErr = null;
|
|
247
220
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
248
221
|
if (attempt > 0) await new Promise((r) => setTimeout(r, 1500));
|
|
@@ -288,22 +261,12 @@ async function fetchIndexOnce(url, opts = {}) {
|
|
|
288
261
|
if (!Array.isArray(data?.plugins)) throw new Error('插件市场索引格式不对(缺少 plugins 数组)');
|
|
289
262
|
|
|
290
263
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
264
|
+
* 这里**不再做索引验签**(2026-11-19 决定):插件市场是社区内容,
|
|
265
|
+
* 用签名把整个生态挡在门外代价太大。安装时仍然校验 tarball 的 sha256
|
|
266
|
+
* (见 verifyPluginDir),内容完整性没有丢。
|
|
267
|
+
*
|
|
268
|
+
* 框架**自更新**的 SHA256SUMS.sig 验签不受影响,在 src/updater.js。
|
|
294
269
|
*/
|
|
295
|
-
const trust = opts.trust ?? resolveTrust({});
|
|
296
|
-
let sigText = '';
|
|
297
|
-
if (trust.pubkey) sigText = await fetchIndexSig(url, `${Date.now()}-${attempt}`);
|
|
298
|
-
|
|
299
|
-
const verdict = checkTrust({ data, sigText, trust, kind: '插件索引' });
|
|
300
|
-
data._trust = verdict;
|
|
301
|
-
// `why` 里已经带了「插件索引」前缀,这里不要再加一遍
|
|
302
|
-
if (verdict.status === 'bad') log.error(verdict.why);
|
|
303
|
-
else if (verdict.status === 'invalid') log.error(verdict.why);
|
|
304
|
-
else if (verdict.status === 'unsigned') log.warn(`${verdict.why}(本版只警告,不阻断)`);
|
|
305
|
-
else if (verdict.status === 'ok') log.info('插件索引签名校验通过');
|
|
306
|
-
|
|
307
270
|
return data;
|
|
308
271
|
}
|
|
309
272
|
throw lastErr ?? new Error('连不上插件市场');
|
package/src/proxy.js
CHANGED
|
@@ -354,6 +354,9 @@ function candidatesFor(target) {
|
|
|
354
354
|
if (!c.list.length) return [];
|
|
355
355
|
if (shouldBypass(target.hostname, target.port, c.bypass)) return [];
|
|
356
356
|
const now = Date.now();
|
|
357
|
+
// 顺手清掉到期的判死记录:判死地址只会来自配置(一两个),但只增不删
|
|
358
|
+
// 会让改过的旧地址永久留在表里。读取时清理,语义与原来的 <= now 判断一致。
|
|
359
|
+
for (const [raw, until] of deadUntil) if (until <= now) deadUntil.delete(raw);
|
|
357
360
|
return c.list.filter((p) => (deadUntil.get(p.raw) ?? 0) <= now);
|
|
358
361
|
}
|
|
359
362
|
|
package/src/trust.js
CHANGED
|
@@ -29,8 +29,8 @@ export const EMBEDDED_PUBKEY = 'bqmZDZi/gnW7FppqKCOa5Zvc1XUvT/vw7fiiHR2hcIo=';
|
|
|
29
29
|
* **发版时把它改成 `true`,所有没显式配置的用户就默认开启强制验签**——
|
|
30
30
|
* 这就是「后续一个更新就能马上打开」的那个开关。
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* 为什么不默认开:自更新签名是 beta,`SHA256SUMS.sig` 还没跟着一次正式发版
|
|
33
|
+
* 走完流程,现在开会让还没铺到签名的用户更新失败。
|
|
34
34
|
*
|
|
35
35
|
* 优先级(见 `resolveTrust`):
|
|
36
36
|
* 配置 `security.trust.enforce` > 环境变量 `ROOST_TRUST_ENFORCE` > 本常量
|
|
@@ -38,10 +38,12 @@ export const EMBEDDED_PUBKEY = 'bqmZDZi/gnW7FppqKCOa5Zvc1XUvT/vw7fiiHR2hcIo=';
|
|
|
38
38
|
export const EMBEDDED_ENFORCE = false;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* **发版时保持 false。**
|
|
42
|
-
* · `
|
|
43
|
-
* ·
|
|
41
|
+
* **发版时保持 false。** 自更新签名链路是 beta:
|
|
42
|
+
* · `SHA256SUMS.sig` 还没跟着一次正式发版走完流程
|
|
43
|
+
* · 现在打开会让还没铺到签名的用户更新失败
|
|
44
44
|
* 等发版验证过一轮,再决定是否默认开启(或继续让用户自己在面板里开)。
|
|
45
|
+
* 注意:2026-11-19 起插件市场索引已不验签,本开关**只管框架自更新**,
|
|
46
|
+
* 不影响官方插件市场安装(下载内容仍校验 sha256)。
|
|
45
47
|
*/
|
|
46
48
|
|
|
47
49
|
/**
|
package/src/updater.js
CHANGED
|
@@ -605,7 +605,7 @@ async function applyUpdateOnce(info) {
|
|
|
605
605
|
if (trustWhy) {
|
|
606
606
|
throw new Error(
|
|
607
607
|
`自更新被拒绝:${trustWhy}\n` +
|
|
608
|
-
'你的代码没有任何改动。可以到 GitHub Releases
|
|
608
|
+
'你的代码没有任何改动。可以到 GitHub Releases 手动下载安装,或先在设置里关掉「自更新签名校验」。',
|
|
609
609
|
);
|
|
610
610
|
}
|
|
611
611
|
|
package/src/web/server.js
CHANGED
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
mergeWithInstalled,
|
|
20
20
|
detectUpdates,
|
|
21
21
|
compareVersion,
|
|
22
|
-
isOfficialSource,
|
|
23
22
|
} from '../plugin/market.js';
|
|
24
23
|
import {
|
|
25
24
|
checkUpdate as checkFrameworkUpdate,
|
|
@@ -46,7 +45,8 @@ import { devErrorPayload, devErrorTable } from '../dev/errors.js';
|
|
|
46
45
|
import * as extDeps from '../ext-deps.js';
|
|
47
46
|
import { runDoctor, summarize } from '../doctor.js';
|
|
48
47
|
import { createBindTask, pollBindResult } from '../qq/qrlogin.js';
|
|
49
|
-
|
|
48
|
+
// 自更新验签状态还要给面板看,resolveTrust / pubkeyUsable 保留;插件市场不再走信任闸
|
|
49
|
+
import { resolveTrust, pubkeyUsable } from '../trust.js';
|
|
50
50
|
import { toSvg as qrToSvg } from '../qq/qrsvg.js';
|
|
51
51
|
import {
|
|
52
52
|
PRESETS,
|
|
@@ -994,7 +994,7 @@ async function startWebServerInstance({
|
|
|
994
994
|
const refreshUpdates = async (r) => {
|
|
995
995
|
const out = { at: Date.now(), updates: [], error: '' };
|
|
996
996
|
try {
|
|
997
|
-
const idx = await fetchIndex(globalCfg.plugins?.marketUrl || undefined
|
|
997
|
+
const idx = await fetchIndex(globalCfg.plugins?.marketUrl || undefined);
|
|
998
998
|
const localVers = await r.plugins.localVersions();
|
|
999
999
|
out.updates = detectUpdates(idx.plugins, localVers).map((u) => ({
|
|
1000
1000
|
id: u.id,
|
|
@@ -1528,6 +1528,16 @@ async function startWebServerInstance({
|
|
|
1528
1528
|
await dev.cancelScan();
|
|
1529
1529
|
return json(res, 200, { ok: true, ...(await dev.status()) });
|
|
1530
1530
|
}
|
|
1531
|
+
/**
|
|
1532
|
+
* 手动核一次登录态。
|
|
1533
|
+
*
|
|
1534
|
+
* 扫码轮询有自己的节奏和退避,偶尔会漏(页面登录慢半拍、票刚种上又
|
|
1535
|
+
* 被刷掉、窗口被随手关掉)。这个入口让人自己点一下:窗口还在就先读
|
|
1536
|
+
* 窗口里的票,窗口没了就拿手里的票真发一次 `list_bots`。
|
|
1537
|
+
*/
|
|
1538
|
+
if (pathname === '/api/dev/login/recheck' && req.method === 'POST') {
|
|
1539
|
+
return json(res, 200, { ok: true, ...(await dev.recheckLogin({ bound })) });
|
|
1540
|
+
}
|
|
1531
1541
|
if (pathname === '/api/dev/login/import' && req.method === 'POST') {
|
|
1532
1542
|
const b = await readBody(req);
|
|
1533
1543
|
const r = await dev.loginImport(b?.input, { remember: b?.remember ?? true });
|
|
@@ -1888,7 +1898,7 @@ async function startWebServerInstance({
|
|
|
1888
1898
|
},
|
|
1889
1899
|
logLevel: globalCfg.logLevel ?? 'info',
|
|
1890
1900
|
/**
|
|
1891
|
-
*
|
|
1901
|
+
* 自更新签名校验(全局设置;字段仍是 security.trust.*)。只回「开没开」和「有没有公钥」——
|
|
1892
1902
|
* 公钥本身是公开的,但配置里可能是整段 PEM,回显没意义还占地方。
|
|
1893
1903
|
* `pubkeySet: false` 时面板要提示「开关不起作用」。
|
|
1894
1904
|
*/
|
|
@@ -1965,7 +1975,7 @@ async function startWebServerInstance({
|
|
|
1965
1975
|
configureProxy(globalCfg);
|
|
1966
1976
|
}
|
|
1967
1977
|
/**
|
|
1968
|
-
*
|
|
1978
|
+
* 自更新签名校验开关(全局,默认关;字段仍是 security.trust.enforce)。
|
|
1969
1979
|
*
|
|
1970
1980
|
* 只接受布尔值:面板传字符串 "false" 时如果按真值判断,会把「关」
|
|
1971
1981
|
* 读成「开」——这类错误在安全开关上代价最大,所以这里严格比类型。
|
|
@@ -2648,7 +2658,7 @@ async function startWebServerInstance({
|
|
|
2648
2658
|
if (pathname === '/api/market' && req.method === 'GET') {
|
|
2649
2659
|
const url2 = url.searchParams.get('source') || globalCfg.plugins?.marketUrl || undefined;
|
|
2650
2660
|
try {
|
|
2651
|
-
const idx = await fetchIndex(url2
|
|
2661
|
+
const idx = await fetchIndex(url2);
|
|
2652
2662
|
const installedIds = new Set(plugins.loaded.keys());
|
|
2653
2663
|
// 目录里存在但没加载成功的也算「已装」
|
|
2654
2664
|
try {
|
|
@@ -2670,8 +2680,6 @@ async function startWebServerInstance({
|
|
|
2670
2680
|
latest: u.latest,
|
|
2671
2681
|
})),
|
|
2672
2682
|
localVersions: localVers,
|
|
2673
|
-
// 索引签名状态:ok / unsigned / bad / unavailable(面板可据此提示)
|
|
2674
|
-
trust: idx?._trust?.status || 'unavailable',
|
|
2675
2683
|
// 网络挂了用的是本地缓存,面板要提示用户「这是旧数据」
|
|
2676
2684
|
stale: idx.stale === true,
|
|
2677
2685
|
staleAge: idx.staleAge || '',
|
|
@@ -2693,18 +2701,12 @@ async function startWebServerInstance({
|
|
|
2693
2701
|
* 恰好最容易撞上那 60 秒——作者发完版立刻装自己那个。
|
|
2694
2702
|
* 用旧索引会 404(市场里还没有这个 id)或者装到上一个版本。
|
|
2695
2703
|
*/
|
|
2696
|
-
const idx = await fetchIndex(src, {
|
|
2704
|
+
const idx = await fetchIndex(src, { maxAge: 0 });
|
|
2697
2705
|
const entry = idx.plugins.find((p) => p.id === id);
|
|
2698
2706
|
if (!entry) return json(res, 404, { error: `市场里没有 ${id}` });
|
|
2699
2707
|
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
* 市场索引;用户自己填的市场源是他自己的信任决定,不拦。
|
|
2703
|
-
* 本版 `enforce` 默认 false,所以这里恒放行。
|
|
2704
|
-
*/
|
|
2705
|
-
const official = isOfficialSource(src, globalCfg);
|
|
2706
|
-
const trustWhy = blockReason(resolveTrust(globalCfg), idx?._trust?.status || 'unavailable', id, { official });
|
|
2707
|
-
if (trustWhy) return json(res, 403, { error: trustWhy });
|
|
2708
|
+
/* 2026-11-19 起不再按索引签名拦截(详见 src/plugin/market.js);
|
|
2709
|
+
框架自更新的验签在 src/updater.js,与此无关。 */
|
|
2708
2710
|
|
|
2709
2711
|
/**
|
|
2710
2712
|
* 下载 + 解包期间要挂起插件热重载。
|
|
@@ -4530,18 +4532,12 @@ async function startWebServerInstance({
|
|
|
4530
4532
|
try {
|
|
4531
4533
|
const src = globalCfg.plugins?.marketUrl || undefined;
|
|
4532
4534
|
// 更新是写路径:索引必须是最新的,不能吃 60 秒内存缓存
|
|
4533
|
-
const idx = await fetchIndex(src, {
|
|
4535
|
+
const idx = await fetchIndex(src, { maxAge: 0 });
|
|
4534
4536
|
const entry = idx.plugins.find((p) => p.id === id);
|
|
4535
4537
|
if (!entry) return json(res, 404, { error: `市场里没有 ${id}` });
|
|
4536
4538
|
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
* 市场索引;用户自己填的市场源是他自己的信任决定,不拦。
|
|
4540
|
-
* 本版 `enforce` 默认 false,所以这里恒放行。
|
|
4541
|
-
*/
|
|
4542
|
-
const official = isOfficialSource(src, globalCfg);
|
|
4543
|
-
const trustWhy = blockReason(resolveTrust(globalCfg), idx?._trust?.status || 'unavailable', id, { official });
|
|
4544
|
-
if (trustWhy) return json(res, 403, { error: trustWhy });
|
|
4539
|
+
/* 2026-11-19 起不再按索引签名拦截(详见 src/plugin/market.js);
|
|
4540
|
+
框架自更新的验签在 src/updater.js,与此无关。 */
|
|
4545
4541
|
|
|
4546
4542
|
const localVers = await plugins.localVersions();
|
|
4547
4543
|
const cur = localVers[id];
|