dsh-lan-guard 0.1.1 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0] — 2026-09-25
4
+
5
+ ### 修复 — 设备操作按钮折行
6
+
7
+ 「吊销并拉黑」等小号按钮在设备行里被挤窄后**折成两行**(用户截图实测)。原因:小号按钮缺 `white-space:nowrap` 与 `flex-shrink:0`,设备行的文本列也没有 `min-width:0` 让位。修复后浏览器实测按钮高度 **28px(单行)**、宽度 82px、文案完整。
8
+
9
+ ### 新增 — 设备批准与永久拉黑(SPEC F9,方案 A,进行中)
10
+
11
+ 第一步:**数据模型与设计文档**(本轮完成)
12
+
13
+ - `DeviceRecord` 新增 `status`(`pending` / `approved` / `blocked`)与 `decidedAtMs`;
14
+ - **加载时迁移**:F9 之前写入的记录没有 `status`,加载即视为 `approved`,不打断既有设备;
15
+ - 注册表新增三态 API:`add(label, { pending })`、`setStatus(id, status)`、`lookup(token)`(不论状态都能查到,供门禁渲染等待页)、`pendingCount`;
16
+ - `verify()` 收紧为**只认 `approved`**:`pending` 不放行(门禁给等待页)、`blocked` 永不放行且记录保留(这正是「永久拉黑」的实现方式,不依赖设备指纹);
17
+ - 测试新增 4 项(待批准不放行但可查、批准后放行、拉黑后拒绝且记录保留、解除拉黑是唯一出路、旧记录迁移为已批准、空操作不写盘);`pnpm test` **223 项**全绿。
18
+
19
+ 待续:`auth.requireApproval` 开关、门禁等待页与 `blocked` 拒绝、批准/拉黑/解除端点、设置页三组列表与两个开关、手机侧等待批准页。
20
+
21
+ ### 新增 — 设备批准与永久拉黑(SPEC F9,方案 A)
22
+
23
+ 「吊销」只能让设备的身份 cookie 失效;F9 让**拉黑变得永久**——不依赖设备指纹,而是把放行权交给管理员。
24
+
25
+ - **三态数据模型**:`pending` / `approved` / `blocked`;F9 之前写入的记录加载时迁移为 `approved`(不打断既有设备);
26
+ - **开关**:`auth.requireApproval`(默认 **false**=保持现状);开启后新设备命名完进入「待批准」;
27
+ - **门禁**:`pending` → 手机侧「等待管理员批准」页(`/api/*` 返回 `403 pending_approval`);`blocked` → `403`「已被移除访问权限」,**重新配对仍被拒**(唯一出路是管理员「解除拉黑」);
28
+ - **端点**:`POST /plugins/dsh-lan-guard/devices` 新增 `action: approve | block | unblock`(沿用管理面鉴权、CSRF 与远程只读规则);
29
+ - **设置页**:「已授权设备」tab 新增第二个开关「新设备需要管理员批准」+ 三组列表(**待批准**:批准 / 拒绝并拉黑;**已授权**:吊销并拉黑;**已拉黑**:解除拉黑)+ 待批准提醒条;
30
+ - 测试新增 4 项(待批准显示等待页且 API 返回 `pending_approval`、批准后放行、拉黑后拒绝、端点 approve/block/unblock、快照 `pendingCount`);`pnpm test` **229 项**全绿。
31
+
32
+ ## [0.2.0] — 2026-09-25
33
+
34
+ ### 新增 — 升级检测(SPEC F8,方案 A)
35
+
36
+ - **只读检测**:宿主查询 `https://registry.npmjs.org/dsh-lan-guard/latest`,与运行版本比较;成功/失败都缓存 **6 小时**,「检查更新」按钮可强制刷新(`?force=1`)。
37
+ - **新端点**:`GET /plugins/dsh-lan-guard/update[?force=1]`(管理面、只读、遵守原生栅栏)。
38
+ - **版本比较自实现**:支持 `x.y.z` 与预发布后缀(遵循 semver 优先级),**不引入 `semver` 依赖**。
39
+ - **失败即报告**:离线/注册表不可用 → `error: 'registry_unavailable'`,只提示、不抛错,不影响门禁与代理。
40
+ - **设置页 UI**:分区内芯片(绿「vX ✓ 最新」/ 蓝「vX ➔ vY」/ 灰「检查失败」)+「检查更新」+ 静态链接(GitHub / 更新日志 / 反馈 Issue);有新版时展开面板给出**可复制的升级命令**并提示「需你手动重启 dsh 才生效」。
41
+ - **明确不做**:不自动安装、不自动重启、不接 GitHub API(更新亮点改为指向仓库 CHANGELOG 的静态链接)——宿主只报告,操作权留在人手里。
42
+ - 测试:新增 `tests/update-check.test.ts`(9 项:版本解析/比较/预发布优先级、缓存与 force、注册表失败与网络异常均不抛错);`pnpm test` **219 项**全绿。
43
+
44
+ ### 移除 — 右下角「局域网访问已开启」状态胶囊(P4-f)
45
+
46
+ 用户反馈后移除。原因:该胶囊(官方追加型 seat `shell.overlay`)把**免密链接(含 `dsh_` token)常驻在屏幕右下角**——截屏或共享屏幕时会一并被拍到;且 `sessionStorage` 的「不再显示」只在当前标签页会话有效,**每次新会话都会再次出现**。
47
+
48
+ - 客户端不再注册任何 `shell.overlay` 内容(`StatusOverlay`、seat 常量与相关 CSS 一并删除);
49
+ - 局域网状态改由设置页「扫码访问」tab 呈现(状态胶囊「运行中」+ 地址 + 唯一二维码);
50
+ - SPEC F6 与 PLAN 的 P4-f 条目已标注为「移除」,不是「未实现」。
51
+
3
52
  ## [0.1.1] — 2026-09-25
4
53
 
5
54
  ### 文档
@@ -10,8 +59,6 @@
10
59
 
11
60
  本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 与[语义化版本](https://semver.org/lang/zh-CN/)。
12
61
 
13
- ## [Unreleased]
14
-
15
62
  ### 实现 — P2 门禁 + 设置 UI(2026-09-24)
16
63
 
17
64
  - **门禁核心** `src/auth/manager.ts`:PBKDF2-SHA256(迭代 600000、派生 32 字节、存储格式 `pbkdf2-sha256$<iterations>$<hex>`、兼容旧裸 hex 按 10000 次)、全部比较走 `timingSafeEqual`、双密码(访问 + 独立管理)、`dsh_`+36 hex 免密令牌、普通会话落盘 / 管理员会话仅内存、按 IP 失败计数与锁定、统一 `verifyRequest`、`adminPolicy` / `allowLoopback` 判定、CSRF 校验。
package/README.md CHANGED
@@ -99,6 +99,24 @@ auth:
99
99
 
100
100
  Every key above can also be changed from the settings page (the non-sensitive ones are declared as volatile config fields).
101
101
 
102
+ ## Device approval and permanent ban
103
+
104
+ Paired devices are listed under **Settings → 局域网访问 → 已授权设备** with three groups: **pending**, **approved** and **blocked**.
105
+
106
+ - Turn on **新设备需要管理员批准** to require an explicit approval before a newly paired device is let in (off by default). A pending phone sees a "waiting for approval" page until you press **批准**.
107
+ - **吊销并拉黑** cuts a device off permanently: its identity is blocked, and re-pairing with the access password from another browser is refused too. **解除拉黑** is the only way back.
108
+ - This deliberately does not use device fingerprinting (which breaks whenever the browser or OS changes) — the operator decides, and the decision sticks.
109
+
110
+ ## Updates
111
+
112
+ The settings page shows the running version next to the newest one on npm, with a **copyable** upgrade command:
113
+
114
+ ```sh
115
+ dsh plugin --profile web add dsh-lan-guard@latest
116
+ ```
117
+
118
+ The plugin never installs anything by itself and never restarts DSH — run the command yourself and restart DSH once. The check only asks the public npm registry, is cached for six hours, and a failure is reported in the UI instead of breaking the gate.
119
+
102
120
  ## Troubleshooting
103
121
 
104
122
  **The phone shows a certificate warning.** The CA is self-signed: install/trust `DSH LAN Guard CA` once per device. Compare the fingerprint shown in **连接与证书** before trusting it.
package/README.zh.md CHANGED
@@ -99,6 +99,24 @@ auth:
99
99
 
100
100
  以上各项也可在设置页修改(非敏感项声明为 volatile 配置字段)。
101
101
 
102
+ ## 设备批准与永久拉黑
103
+
104
+ 已配对的设备列在 **设置 → 局域网访问 → 已授权设备**,分三组:**待批准 / 已授权 / 已拉黑**。
105
+
106
+ - 打开 **「新设备需要管理员批准」**(默认关闭)后,新配对的设备需要你点「批准」才能进入;等待期间手机上显示「等待管理员批准」页。
107
+ - **「吊销并拉黑」** 会让该设备**永久失效**:身份被拒绝,换浏览器用访问密码重新配对也会被拒;**「解除拉黑」是唯一的恢复方式**。
108
+ - 这里刻意**不使用设备指纹**(换浏览器或升级系统就会失效)——由你决定,且决定是持久的。
109
+
110
+ ## 升级
111
+
112
+ 设置页会显示「当前版本 → npm 上最新版本」,并给出**可复制**的升级命令:
113
+
114
+ ```sh
115
+ dsh plugin --profile web add dsh-lan-guard@latest
116
+ ```
117
+
118
+ 本插件**不会自己安装任何东西,也不会重启 DSH**——命令由你执行,执行后手动重启一次 dsh。检测只访问公开的 npm registry,结果缓存 6 小时;连不上时只在界面上提示,不影响门禁与代理。
119
+
102
120
  ## 排障
103
121
 
104
122
  **手机提示证书不受信任。** CA 是自签的:每台设备安装/信任一次 `DSH LAN Guard CA`。信任前先比对 **连接与证书** 里显示的指纹。
package/lib/client.js CHANGED
@@ -33,8 +33,6 @@ window.__ModuleLoader__.load({
33
33
  const PLUGIN_ID = "dsh-lan-guard";
34
34
  /** The official additive settings seat. */
35
35
  const SEAT = "settings.section";
36
- /** The official additive frame-wide overlay seat (never replaces anything). */
37
- const OVERLAY_SEAT = "shell.overlay";
38
36
  /** The management endpoint on DSH's own origin. */
39
37
  const CONFIG_PATH = "/plugins/dsh-lan-guard/config";
40
38
  /** The four credential modes offered by the big-card selector. */
@@ -93,15 +91,6 @@ window.__ModuleLoader__.load({
93
91
  * my own invention and made 2 of 3 tabs look like they had not been themed
94
92
  * (user feedback 2026-09-24).
95
93
  */
96
- /* Frame-wide status pill (official additive shell.overlay seat). */
97
- .lg-ov{position:fixed;right:16px;bottom:16px;z-index:40;display:flex;align-items:center;gap:8px;
98
- padding:6px 10px;border-radius:999px;background:var(--dsw-alias-bg-layer-3,#2c2c2e);
99
- border:1px solid var(--dsw-alias-border-l2,#e5e6eb);color:var(--dsw-alias-label-primary,#1f2329);
100
- font:var(--dsw-font-xxs-12,12px/18px sans-serif);box-shadow:0 6px 20px rgba(0,0,0,.18)}
101
- .lg-ov-code{font-family:var(--ds-font-family-code,ui-monospace,monospace);
102
- color:var(--dsw-alias-label-secondary,#6b7280)}
103
- .lg-ov-x{border:0;background:transparent;cursor:pointer;padding:0 2px;color:var(--dsw-alias-label-tertiary,#6b7280);
104
- font:var(--dsw-font-xxs-12,12px/18px sans-serif)}
105
94
  .lg-tabs{display:flex;gap:8px;flex-wrap:wrap}
106
95
  .lg-tab{font:var(--dsw-font-s-14,14px/22px sans-serif);cursor:pointer;
107
96
  color:var(--dsw-alias-label-primary,#1f2329);background:transparent;
@@ -161,7 +150,7 @@ window.__ModuleLoader__.load({
161
150
  border:1px solid var(--dsw-alias-border-l2,#d0d3d9)}
162
151
  .lg-btn:disabled{opacity:.55;cursor:not-allowed}
163
152
  .lg-btn.full{width:100%}
164
- .lg-btn-small{height:28px;padding:0 10px;font:var(--dsw-font-xxs-12,12px/18px sans-serif)}
153
+ .lg-btn-small{height:28px;padding:0 10px;white-space:nowrap;flex-shrink:0;font:var(--dsw-font-xxs-12,12px/18px sans-serif)}
165
154
  .lg-toggle{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:14px;
166
155
  font:var(--dsw-font-s-14,14px/22px sans-serif);color:var(--dsw-alias-label-primary,#1f2329)}
167
156
  .lg-switch{width:48px;height:28px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,#d0d3d9);
@@ -190,10 +179,34 @@ window.__ModuleLoader__.load({
190
179
  color:var(--dsw-alias-label-secondary,#6b7280)}
191
180
  .lg-lock .lg-input{width:100%;text-align:left}
192
181
  .lg-lock .lg-btn{margin-top:4px}
193
- .lg-device{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px;
194
- padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-base,#f1f2f4);
195
- border:1px solid var(--dsw-alias-border-l2,#e5e6eb)}
196
- .lg-device-name{font:var(--dsw-font-s-strong-14,500 14px/22px sans-serif);
182
+ .lg-update{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
183
+ .lg-chip{padding:3px 10px;border-radius:999px;background:var(--dsw-alias-state-success-tertiary,#ecfdf5);
184
+ color:var(--dsw-alias-state-success-primary,#059669);font:var(--dsw-font-xxs-12,12px/18px sans-serif)}
185
+ .lg-chip.warn{background:var(--dsw-alias-state-business-tertiary,#eff6ff);
186
+ color:var(--dsw-static-deepseek-500,#4176e6)}
187
+ .lg-link{color:var(--dsw-alias-label-secondary,#6b7280);text-decoration:none;
188
+ font:var(--dsw-font-xxs-12,12px/18px sans-serif)}
189
+ .lg-link:hover{color:var(--dsw-alias-label-primary,#1f2329)}
190
+ .lg-update-panel{margin:0;padding:12px;border-radius:10px;
191
+ background:var(--dsw-alias-layer-2,#f1f2f4);border:1px solid var(--dsw-alias-border-l2,#e5e6eb)}
192
+ .lg-update-title{font:var(--dsw-font-s-strong-14,500 14px/22px sans-serif);
193
+ color:var(--dsw-alias-label-primary,#1f2329);margin-bottom:8px}
194
+ .lg-sec-title{margin:18px 0 2px;font:var(--dsw-font-s-strong-14,500 14px/22px sans-serif);
195
+ color:var(--dsw-alias-label-secondary,#adb2b8)}
196
+ .lg-chip.ok,.lg-chip.wait,.lg-chip.ban{margin-left:5px;flex-shrink:0}
197
+ .lg-chip.wait{background:var(--dsw-alias-state-warn-tertiary,#3a2f16);color:var(--dsw-alias-state-warn-label,#fbbf24)}
198
+ .lg-chip.ban{background:var(--dsw-static-red-600-a08,#ec13131f);color:var(--dsw-static-red-400,#f25a5a)}
199
+ .lg-danger{color:var(--dsw-static-red-400,#f25a5a);border-color:var(--dsw-static-red-400,#f25a5a)}
200
+ .lg-device{display:block;margin-top:12px;padding:10px 12px;border-radius:10px;
201
+ background:var(--dsw-alias-bg-base,#f1f2f4);border:1px solid var(--dsw-alias-border-l2,#e5e6eb)}
202
+ .lg-device-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
203
+ .lg-name-chip{display:inline-flex;align-items:center;min-width:0}
204
+ .lg-device-actions{display:inline-flex;align-items:center;gap:8px;flex-shrink:0}
205
+ .lg-device-meta{margin-top:6px;color:var(--dsw-alias-label-tertiary,#979da6);
206
+ font:var(--dsw-font-xxs-12,12px/18px sans-serif)}
207
+ .lg-device-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
208
+ font:var(--dsw-font-s-strong-14,500 14px/22px sans-serif);
209
+ color:var(--dsw-alias-label-primary,#1f2329)}
197
210
  color:var(--dsw-alias-label-primary,#1f2329)}
198
211
  .lg-recover{margin-top:8px;text-align:left;width:100%}
199
212
  .lg-recover p{font:var(--dsw-font-xs-13,13px/20px sans-serif);margin:0 0 6px;
@@ -278,6 +291,8 @@ window.__ModuleLoader__.load({
278
291
  const [showRecovery, setShowRecovery] = (0, react.useState)(false);
279
292
  const [portDraft, setPortDraft] = (0, react.useState)("");
280
293
  const [portCheck, setPortCheck] = (0, react.useState)(null);
294
+ const [update, setUpdate] = (0, react.useState)(null);
295
+ const [updateBusy, setUpdateBusy] = (0, react.useState)(false);
281
296
  const flash = (0, react.useCallback)((message) => {
282
297
  setNotice(message);
283
298
  setTimeout(() => setNotice(null), 2500);
@@ -306,8 +321,31 @@ window.__ModuleLoader__.load({
306
321
  setBusy(false);
307
322
  }
308
323
  }, [flash]);
309
- /** Revoke one device. */
310
- const revokeDevice = (0, react.useCallback)(async (id) => {
324
+ /** Approve / block / unblock a device (F9). */
325
+ const deviceAction = (0, react.useCallback)(async (id, action) => {
326
+ setBusy(true);
327
+ try {
328
+ await fetch("/plugins/dsh-lan-guard/devices", {
329
+ method: "POST",
330
+ credentials: "same-origin",
331
+ headers: {
332
+ "content-type": "application/json",
333
+ accept: "application/json"
334
+ },
335
+ body: JSON.stringify({
336
+ action,
337
+ id
338
+ })
339
+ });
340
+ setSnapshot(await loadSnapshot());
341
+ flash(action === "approve" ? "已批准" : action === "block" ? "已拉黑" : "已解除拉黑");
342
+ } catch (failure) {
343
+ setError(failure.message);
344
+ } finally {
345
+ setBusy(false);
346
+ }
347
+ }, [flash]);
348
+ (0, react.useCallback)(async (id) => {
311
349
  setBusy(true);
312
350
  try {
313
351
  await fetch("/plugins/dsh-lan-guard/devices", {
@@ -330,6 +368,30 @@ window.__ModuleLoader__.load({
330
368
  setBusy(false);
331
369
  }
332
370
  }, [flash]);
371
+ /** Ask the host what npm has (SPEC F8). Read-only; the host installs nothing. */
372
+ const loadUpdate = (0, react.useCallback)(async (force) => {
373
+ setUpdateBusy(true);
374
+ try {
375
+ const response = await fetch(`/plugins/dsh-lan-guard/update${force ? "?force=1" : ""}`, {
376
+ credentials: "same-origin",
377
+ headers: { accept: "application/json" }
378
+ });
379
+ setUpdate(await response.json());
380
+ } catch {
381
+ setUpdate({
382
+ current: "?",
383
+ latest: null,
384
+ hasUpdate: false,
385
+ checkedAtMs: null,
386
+ error: "unreachable"
387
+ });
388
+ } finally {
389
+ setUpdateBusy(false);
390
+ }
391
+ }, []);
392
+ (0, react.useEffect)(() => {
393
+ loadUpdate(false);
394
+ }, [loadUpdate]);
333
395
  /** Ask the host whether a candidate port is free (loopback-only probe). */
334
396
  const checkPort = (0, react.useCallback)(async (candidate) => {
335
397
  const port = Number.parseInt(candidate, 10);
@@ -592,15 +654,39 @@ window.__ModuleLoader__.load({
592
654
  ]
593
655
  })]);
594
656
  const when = (ms) => ms === null ? "—" : new Date(ms).toLocaleString("zh-CN");
657
+ const deviceGroups = [
658
+ {
659
+ key: "pending",
660
+ title: "待批准",
661
+ list: snapshot.devices.filter((entry) => entry.status === "pending")
662
+ },
663
+ {
664
+ key: "approved",
665
+ title: "已授权",
666
+ list: snapshot.devices.filter((entry) => entry.status === "approved")
667
+ },
668
+ {
669
+ key: "blocked",
670
+ title: "已拉黑",
671
+ list: snapshot.devices.filter((entry) => entry.status === "blocked")
672
+ }
673
+ ];
674
+ const statusChip = (status) => (0, react.createElement)("span", { className: status === "blocked" ? "lg-chip ban" : status === "pending" ? "lg-chip wait" : "lg-chip ok" }, status === "blocked" ? "已拉黑" : status === "pending" ? "待批准" : "已批准");
675
+ const devButton = (label, action, id, danger) => (0, react.createElement)("button", {
676
+ type: "button",
677
+ className: danger ? "lg-btn secondary lg-btn-small lg-danger" : "lg-btn lg-btn-small",
678
+ disabled: busy,
679
+ onClick: () => void deviceAction(id, action)
680
+ }, label);
595
681
  const devicesTab = (0, react.createElement)("div", { className: "lg-tabbody" }, locked ? [lockCard] : [(0, react.createElement)(Card, {
596
682
  key: "devices",
597
683
  title: "已授权设备",
598
- subtitle: "每个设备一条独立链接,可单独吊销",
684
+ subtitle: "每个设备一条独立身份,可逐个批准、吊销与拉黑",
599
685
  children: [
600
686
  (0, react.createElement)("p", {
601
687
  className: "lg-hint",
602
688
  key: "explain"
603
- }, "手机第一次通过门禁时会显示配对页,让你给这台设备命名;命名后它就会出现在下面。吊销某台设备只影响那一台——不必更换总密码。"),
689
+ }, "手机第一次通过门禁时会显示配对页,让你给这台设备命名;命名后它就会出现在下面。"),
604
690
  (0, react.createElement)("div", {
605
691
  className: "lg-toggle",
606
692
  key: "pairing"
@@ -612,28 +698,50 @@ window.__ModuleLoader__.load({
612
698
  disabled: busy,
613
699
  onClick: () => void write({ preferences: { requirePairing: !preferences.requirePairing } })
614
700
  }, (0, react.createElement)("span", null))]),
701
+ (0, react.createElement)("div", {
702
+ className: "lg-toggle",
703
+ key: "approval"
704
+ }, [(0, react.createElement)("span", { key: "l" }, "新设备需要管理员批准"), (0, react.createElement)("button", {
705
+ key: "s",
706
+ type: "button",
707
+ className: "lg-switch",
708
+ "aria-checked": preferences.requireApproval,
709
+ disabled: busy,
710
+ onClick: () => void write({ preferences: { requireApproval: !preferences.requireApproval } })
711
+ }, (0, react.createElement)("span", null))]),
712
+ (0, react.createElement)("p", {
713
+ className: "lg-hint",
714
+ key: "approval-hint"
715
+ }, "开启「管理员批准」后:手机完成命名 → 进入「待批准」,你在下面点「批准」它才能访问;「拒绝并拉黑」会让它即使知道密码、换浏览器重新配对也被拒绝。"),
716
+ snapshot.pendingCount > 0 ? (0, react.createElement)("div", {
717
+ className: "lg-bar warn",
718
+ key: "pending-bar"
719
+ }, `🔔 有 ${String(snapshot.pendingCount)} 台新设备等待批准`) : null,
615
720
  snapshot.devices.length === 0 ? (0, react.createElement)("p", {
616
721
  className: "lg-hint",
617
722
  key: "empty"
618
- }, "暂无已授权设备。") : (0, react.createElement)("div", { key: "list" }, snapshot.devices.map((device) => (0, react.createElement)("div", {
723
+ }, "暂无已授权设备。") : (0, react.createElement)("div", { key: "groups" }, deviceGroups.filter((group) => group.list.length > 0).map((group) => (0, react.createElement)("div", { key: group.key }, [(0, react.createElement)("div", {
724
+ key: "t",
725
+ className: "lg-sec-title"
726
+ }, `${group.title}(${String(group.list.length)})`), ...group.list.map((device) => (0, react.createElement)("div", {
619
727
  key: device.id,
620
728
  className: "lg-device"
621
- }, [(0, react.createElement)("div", { key: "meta" }, [(0, react.createElement)("div", {
622
- key: "l",
729
+ }, [(0, react.createElement)("div", {
730
+ key: "head",
731
+ className: "lg-device-head"
732
+ }, [(0, react.createElement)("span", {
733
+ key: "nc",
734
+ className: "lg-name-chip"
735
+ }, [(0, react.createElement)("span", {
736
+ key: "n",
623
737
  className: "lg-device-name"
624
- }, device.label), (0, react.createElement)("div", {
738
+ }, device.label), statusChip(device.status)]), (0, react.createElement)("span", {
739
+ key: "a",
740
+ className: "lg-device-actions"
741
+ }, device.status === "pending" ? [devButton("批准", "approve", device.id, false), devButton("拒绝并拉黑", "block", device.id, true)] : device.status === "blocked" ? [devButton("解除拉黑", "unblock", device.id, false)] : [devButton("吊销并拉黑", "block", device.id, true)])]), (0, react.createElement)("div", {
625
742
  key: "d",
626
- className: "lg-hint"
627
- }, `创建 ${when(device.createdAtMs)} · 最近使用 ${when(device.lastSeenAtMs)} · 来源 ${device.lastIp ?? "—"}`)]), device.revoked ? (0, react.createElement)("span", {
628
- key: "r",
629
- className: "lg-pill off"
630
- }, "已吊销") : (0, react.createElement)("button", {
631
- key: "r",
632
- type: "button",
633
- className: "lg-btn secondary lg-btn-small",
634
- disabled: busy,
635
- onClick: () => void revokeDevice(device.id)
636
- }, "吊销")])))
743
+ className: "lg-device-meta"
744
+ }, `创建 ${when(device.createdAtMs)} · 最近使用 ${when(device.lastSeenAtMs)} · 来源 ${device.lastIp ?? "—"}`)]))])))
637
745
  ]
638
746
  })]);
639
747
  const connectionTab = (0, react.createElement)("div", { className: "lg-tabbody" }, locked ? [lockCard] : [(0, react.createElement)(Card, {
@@ -763,6 +871,70 @@ window.__ModuleLoader__.load({
763
871
  className: "lg-bar warn",
764
872
  key: "readonly"
765
873
  }, "当前为远程访问(只读):请在运行本程序的电脑上打开本控制台修改——127.0.0.1 享有免锁特权。") : null;
874
+ const repoUrl = "https://github.com/idoall/dsh-lan-guard";
875
+ const updateChip = (0, react.createElement)("div", {
876
+ className: "lg-update",
877
+ key: "update"
878
+ }, [
879
+ (0, react.createElement)("span", {
880
+ key: "v",
881
+ className: update !== null && update.hasUpdate ? "lg-chip warn" : "lg-chip"
882
+ }, update === null ? "检查更新…" : update.error !== null ? `v${update.current} · 检查失败` : update.hasUpdate ? `v${update.current} ➔ v${String(update.latest)}` : `v${update.current} ✓ 最新`),
883
+ (0, react.createElement)("button", {
884
+ key: "b",
885
+ type: "button",
886
+ className: "lg-btn secondary lg-btn-small",
887
+ disabled: updateBusy,
888
+ onClick: () => void loadUpdate(true)
889
+ }, updateBusy ? "检查中…" : "检查更新"),
890
+ (0, react.createElement)("a", {
891
+ key: "g",
892
+ className: "lg-link",
893
+ href: repoUrl,
894
+ target: "_blank",
895
+ rel: "noreferrer"
896
+ }, "GitHub"),
897
+ (0, react.createElement)("a", {
898
+ key: "c",
899
+ className: "lg-link",
900
+ href: `${repoUrl}/blob/main/CHANGELOG.md`,
901
+ target: "_blank",
902
+ rel: "noreferrer"
903
+ }, "更新日志"),
904
+ (0, react.createElement)("a", {
905
+ key: "i",
906
+ className: "lg-link",
907
+ href: `${repoUrl}/issues`,
908
+ target: "_blank",
909
+ rel: "noreferrer"
910
+ }, "反馈 Issue")
911
+ ]);
912
+ const updatePanel = update === null || !update.hasUpdate ? null : (0, react.createElement)("div", {
913
+ className: "lg-update-panel",
914
+ key: "updatepanel"
915
+ }, [
916
+ (0, react.createElement)("div", {
917
+ key: "t",
918
+ className: "lg-update-title"
919
+ }, `发现新版本 v${String(update.latest)}(当前 v${update.current})`),
920
+ (0, react.createElement)("div", {
921
+ key: "c",
922
+ className: "lg-mono"
923
+ }, `dsh plugin --profile web add dsh-lan-guard@${String(update.latest)}`),
924
+ (0, react.createElement)("div", {
925
+ className: "lg-row",
926
+ key: "r"
927
+ }, [(0, react.createElement)("button", {
928
+ key: "cp",
929
+ type: "button",
930
+ className: "lg-btn secondary",
931
+ onClick: () => copy(`dsh plugin --profile web add dsh-lan-guard@${String(update.latest)}`, "update")
932
+ }, copied === "update" ? "已复制" : "复制命令")]),
933
+ (0, react.createElement)("p", {
934
+ key: "h",
935
+ className: "lg-hint"
936
+ }, "本插件不会自动安装,也不会重启 dsh:执行上面的命令后,需要你手动重启一次 dsh 才生效。")
937
+ ]);
766
938
  const tabBar = (0, react.createElement)("div", {
767
939
  className: "lg-tabs",
768
940
  role: "tablist",
@@ -787,6 +959,8 @@ window.__ModuleLoader__.load({
787
959
  }, notice),
788
960
  unlockBanner,
789
961
  readOnlyBanner,
962
+ updateChip,
963
+ updatePanel,
790
964
  tabBar,
791
965
  tab === "access" ? accessTab : tab === "security" ? securityTab : tab === "devices" ? devicesTab : connectionTab
792
966
  ].filter(Boolean));
@@ -794,56 +968,6 @@ window.__ModuleLoader__.load({
794
968
  /** Default port shown as a hint in the port field. */
795
969
  const DEFAULT_PORT_HINT = 3081;
796
970
  /**
797
- * Frame-wide status pill (the official ADDITIVE `shell.overlay` seat — it adds
798
- * a surface beside the shipped entries and replaces nothing).
799
- *
800
- * Shown only to the machine's own operator (`localAccess`), because a phone is
801
- * already inside the console and does not need to be told its own address.
802
- */
803
- function StatusOverlay() {
804
- const [snapshot, setSnapshot] = (0, react.useState)(null);
805
- const [dismissed, setDismissed] = (0, react.useState)(() => {
806
- try {
807
- return sessionStorage.getItem("lg-overlay-dismissed") === "1";
808
- } catch {
809
- return false;
810
- }
811
- });
812
- (0, react.useEffect)(() => {
813
- (async () => {
814
- try {
815
- setSnapshot(await loadSnapshot());
816
- } catch {
817
- setSnapshot(null);
818
- }
819
- })();
820
- }, []);
821
- if (dismissed || snapshot === null) return null;
822
- if (!snapshot.authStatus.pluginEnabled || !snapshot.authStatus.localAccess) return null;
823
- const url = snapshot.access.tokenUrl ?? snapshot.access.selectedUrl;
824
- if (url === null || url === void 0) return null;
825
- return (0, react.createElement)("div", { className: "lg-ov" }, [
826
- (0, react.createElement)("style", { key: "css" }, CSS),
827
- (0, react.createElement)("span", { key: "t" }, "🌐 局域网访问已开启"),
828
- (0, react.createElement)("span", {
829
- key: "u",
830
- className: "lg-ov-code"
831
- }, url),
832
- (0, react.createElement)("button", {
833
- key: "x",
834
- type: "button",
835
- className: "lg-ov-x",
836
- title: "本次会话不再显示",
837
- onClick: () => {
838
- try {
839
- sessionStorage.setItem("lg-overlay-dismissed", "1");
840
- } catch {}
841
- setDismissed(true);
842
- }
843
- }, "✕")
844
- ]);
845
- }
846
- /**
847
971
  * Register the settings section.
848
972
  *
849
973
  * @param ctx - the client plugin context (injects `slots`).
@@ -855,11 +979,6 @@ window.__ModuleLoader__.load({
855
979
  order: 100,
856
980
  label: "局域网访问"
857
981
  }, SettingsSection));
858
- ctx.slots.inject(OVERLAY_SEAT, () => ctx.slots.register({
859
- name: OVERLAY_SEAT,
860
- id: `${PLUGIN_ID}-status`,
861
- order: 200
862
- }, StatusOverlay));
863
982
  }
864
983
  module.exports = {
865
984
  name: PLUGIN_ID,