@sleep2agi/commhub-server 0.9.0-preview.233 → 0.9.0-preview.234

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/commhub-server",
3
- "version": "0.9.0-preview.233",
3
+ "version": "0.9.0-preview.234",
4
4
  "description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and MCP tools (17 collaboration-core + node/provider ops tools; authoritative list: docs-site/docs/api/mcp-tools.md).",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1187,6 +1187,25 @@ describe("#473 anonymous /health — watchdog contract intact, no topology leak"
1187
1187
  expect(Math.abs(derived - body.uptime)).toBeLessThanOrEqual(5);
1188
1188
  });
1189
1189
 
1190
+ // 2026-10-31 —— **响应头也不能泄露指纹**(外部复核:「匿名 /health 响应头里不得出现
1191
+ // git / commit / build(sha|id) 类头;这两条不需要会话就能读 ⇒ 它们回答『我站在哪一层』,
1192
+ // 不是『我有没有登录』」)。
1193
+ // 为什么需要它:body 有白名单,**头没有**。将来有人把 build id 塞进 `X-Build-Id`,
1194
+ // body 侧断言全绿,而匿名读者已经拿到了指纹。
1195
+ test("anonymous /health exposes no fingerprint-bearing response header", async () => {
1196
+ const res = await fetch(`${BASE}/health`);
1197
+ expect(res.status).toBe(200);
1198
+ const names = [...res.headers.keys()].map((k) => k.toLowerCase());
1199
+ const forbidden = names.filter((n) => /git|commit|build[-_]?(sha|id)?/.test(n));
1200
+ if (forbidden.length) {
1201
+ throw new Error(`匿名 /health 出现了指纹类响应头:${forbidden.join(", ")}\n` +
1202
+ " ⇒ body 白名单不覆盖响应头;要么删掉这个头,要么它只在鉴权分支发。");
1203
+ }
1204
+ // 镜像:同一个端点在**鉴权**分支下可以有 X-* 头,但也不能有指纹 —— 迄今也没有;
1205
+ // 这条留作记录:若哪天加了,必须先在白名单测试里显式放行。
1206
+ expect(forbidden).toEqual([]);
1207
+ });
1208
+
1190
1209
  test("no dead entries: every allow-listed key is actually served to anonymous callers", async () => {
1191
1210
  const { PUBLIC_HEALTH_KEYS } = await import("./server.js");
1192
1211
  const plain = await (await fetch(`${BASE}/health`)).json() as any;
@@ -429,9 +429,23 @@ describe("GET /api/providers", () => {
429
429
  expect(defs.length).toBe(1);
430
430
  const readers = files.flatMap(({ f, src }) =>
431
431
  src.split("\n").map((line, i) => ({ line, f, i }))
432
- .filter(({ line }) => line.includes(name) && !line.includes(`export const ${name}`)));
432
+ .filter(({ line }) => line.includes(name) && !line.includes(`export const ${name}`))
433
+ // 2026-10-31 —— **注释不是读点**:`// 状态码来自穷尽表(PROVIDER_WRITE_STATUS…)`
434
+ // 会满足「读到过」而实际上没有任何代码用它。这正是本仓实测到的形态。
435
+ .filter(({ line }) => {
436
+ const t = line.trim();
437
+ return !t.startsWith("//") && !t.startsWith("*") && !t.startsWith("/*");
438
+ }));
433
439
  // 「读」= 出现但不是定义行(索引 / 展开 / 断言都算)
434
440
  expect(readers.length).toBeGreaterThan(0);
441
+ // 2026-10-31 —— **计数 = 1 还不够,位置也要在集合内**(外部复核:
442
+ // 「只断言计数 1 ⇒ 留下的是『1 个读点,它自己另搞一套』—— 完全满足计数 1,
443
+ // 而语义已经不是你想的那个。」)
444
+ // ⇒ 读点必须落在**路由文件**里(server.ts),否则等于表有了、用法另有其处。
445
+ // 位置:读点必须落在**实现或路由**里(不是只落在注释里)
446
+ const readerFiles = new Set(readers.map((r) => String(r.f).split("/").pop()));
447
+ expect(readerFiles.size).toBeGreaterThan(0);
448
+ expect([...readerFiles].some((f) => f === "server.ts" || f === "hub-provider-config.ts" || f === "requirements.ts")).toBe(true);
435
449
  }
436
450
  });
437
451