dsh-sensitive-guard 0.4.0 → 0.5.1

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/client.js CHANGED
@@ -25,27 +25,76 @@ window.__ModuleLoader__.load({
25
25
  hide: '隐藏明文',
26
26
  refresh: '刷新',
27
27
  autoHide: '20 秒后自动重新遮挡',
28
- colValue: '值',
28
+ colValue: '名称 / 值',
29
+ colCategory: '分类',
29
30
  colKind: '规则',
30
- colTime: '入库时间',
31
- colHits: '命中',
31
+ copyPlain: '复制明文',
32
+ copyOk: '已复制',
33
+ copyFail: '复制失败',
32
34
  stats: '共 {count} 条 · 揭示只记录在本机',
33
35
  placeholder: '上下文占位符格式:<SG_十六进制>',
34
36
  usage: '模型侧取用:sensitive_guard_export 工具把明文写入 0600 文件,命令里用 "$(cat <路径>)" 引用,明文不进上下文。',
35
37
  statusOn: '保护中',
36
38
  statusOff: '已暂停',
39
+ statusDisabled: '保护已关闭',
37
40
  pause30: '暂停 30 分钟',
38
41
  pause120: '暂停 2 小时',
39
42
  pauseRestart: '暂停到重启',
40
43
  pauseRestartLeft: '重启前不再脱敏',
41
44
  resume: '恢复保护',
45
+ disable: '关闭保护',
46
+ enable: '开启保护',
42
47
  pausedHint: '暂停期间不做任何脱敏,明文会直接进入上下文与日志。到期自动恢复。',
48
+ disabledHint: '保护已持久关闭:不做任何脱敏,明文直接进入上下文与日志;重启也不会自动恢复,需要时手动点「开启保护」。',
49
+ disableTitle: '关闭保护?',
50
+ disableBody: '关闭后所有脱敏立即停止,明文会直接进入模型上下文与日志,而且重启也不会自动恢复。只有再点「开启保护」才会恢复。建议优先用限时暂停。',
51
+ disableConfirm: '确认关闭',
52
+ disableCancel: '取消',
43
53
  lanExposed: '⚠ 本页经局域网访问(允许网段:{cidrs})。这条链路上的明文与预览对该网段可见,用完建议把 allowCidrs 收回。',
44
54
  restrictedTitle: '只读:这台机器不是服务所在的本机',
45
55
  restrictedBody: '服务端默认只接受本机回环,所以这里能看到“有哪些凭据被保护”,看不到值。当前访问地址:{host}',
46
56
  restrictedFile: '要在这里查看或揭示明文,二选一。① 在服务所在机器上编辑下面这个文件,加一行:',
47
57
  restrictedAlt: '② 或者直接在服务所在机器的浏览器打开 http://127.0.0.1:<端口>。',
48
58
  restrictedUnlock: '需在服务所在的本机打开才能揭示',
59
+ tabRules: '自动检测规则',
60
+ tabEntries: '敏感数据管理',
61
+ rulesSearch: '搜索规则名称或关键词',
62
+ rulesAll: '全部状态',
63
+ rulesOn: '已开启',
64
+ rulesOff: '已关闭',
65
+ rulesPrev: '上一页',
66
+ rulesNext: '下一页',
67
+ rulesPage: '第 {current} / {total} 页',
68
+ rulesNoMatch: '没有匹配的规则',
69
+ rulesLoading: '载入规则中…',
70
+ ruleSystem: '系统规则',
71
+ ruleBuiltin: '内置规则',
72
+ ruleCustom: '自定义规则',
73
+ ruleApprox: '近似转换',
74
+ ruleLoose: '宽松规则',
75
+ ruleSkipped: '{count} 条文件型规则不适用文本检测',
76
+ addEntry: '添加敏感数据',
77
+ addEntryTitle: '添加敏感数据',
78
+ addEntryName: '例如:公司内网口令',
79
+ addEntryNameLabel: '名称',
80
+ addEntryPlain: '明文内容',
81
+ addEntryPlainLabel: '明文',
82
+ addEntryKind: '类型',
83
+ addEntryKindLabel: '类型',
84
+ addEntrySubmit: '保存',
85
+ addEntryCancel: '取消',
86
+ addEntryClose: '关闭',
87
+ addEntryOk: '已加密保存,以后会自动遮挡',
88
+ addEntryFail: '保存失败,确认是在本机打开的页面',
89
+ addEntryNeedKind: '给自定义分类起个名字',
90
+ addKindCustom: '自定义分类…',
91
+ addKindCustomLabel: '分类名称',
92
+ addKindCustomPlaceholder: '例如:公司内部凭据',
93
+ entrySearch: '搜索名称、预览或代号',
94
+ entryDelete: '删除',
95
+ kindPassword: '密码',
96
+ kindToken: '令牌',
97
+ kindKey: '密钥',
49
98
  };
50
99
  const en = {
51
100
  nav: 'Sensitive guard',
@@ -58,27 +107,76 @@ window.__ModuleLoader__.load({
58
107
  hide: 'Hide secret',
59
108
  refresh: 'Refresh',
60
109
  autoHide: 'Re-masks in 20 seconds',
61
- colValue: 'Value',
110
+ colValue: 'Name / value',
111
+ colCategory: 'Type',
62
112
  colKind: 'Rule',
63
- colTime: 'Captured',
64
- colHits: 'Hits',
113
+ copyPlain: 'Copy plaintext',
114
+ copyOk: 'Copied',
115
+ copyFail: 'Copy failed',
65
116
  stats: '{count} entries · reveals stay on this machine',
66
117
  placeholder: 'Context placeholder format: <SG_hex>',
67
118
  usage: 'For the agent: sensitive_guard_export writes the plaintext to a 0600 file; reference it as "$(cat <path>)" so plaintext never enters context.',
68
119
  statusOn: 'Protecting',
69
120
  statusOff: 'Paused',
121
+ statusDisabled: 'Protection off',
70
122
  pause30: 'Pause 30 min',
71
123
  pause120: 'Pause 2 h',
72
124
  pauseRestart: 'Pause until restart',
73
125
  pauseRestartLeft: 'No masking until restart',
74
126
  resume: 'Resume',
127
+ disable: 'Disable protection',
128
+ enable: 'Enable protection',
75
129
  pausedHint: 'Nothing is masked while paused — plaintext reaches context and logs. Re-arms automatically.',
130
+ disabledHint: 'Protection is persistently off: nothing is masked, plaintext reaches context and logs, and a restart will NOT re-arm it. Click "Enable protection" to restore it.',
131
+ disableTitle: 'Disable protection?',
132
+ disableBody: 'All masking stops immediately. Plaintext will reach the model context and logs, and a restart will not re-arm the guard — only "Enable protection" restores it. Prefer a timed pause when possible.',
133
+ disableConfirm: 'Disable',
134
+ disableCancel: 'Cancel',
76
135
  lanExposed: '⚠ This page is served over LAN (allowed: {cidrs}). Plaintext and previews on this route are visible to that network; narrow allowCidrs when you are done.',
77
136
  restrictedTitle: 'Read-only: this machine is not the one running the server',
78
137
  restrictedBody: 'The server only accepts loopback by default, so you can see which credentials are protected, but not their values. Current address: {host}',
79
138
  restrictedFile: 'To view or reveal values here, pick one. ① On the server machine, edit this file and add one line:',
80
139
  restrictedAlt: '② Or open http://127.0.0.1:<port> in a browser on that machine.',
81
140
  restrictedUnlock: 'Reveal requires the browser on the server machine',
141
+ tabRules: 'Detection rules',
142
+ tabEntries: 'Sensitive data',
143
+ rulesSearch: 'Search rule names or keywords',
144
+ rulesAll: 'All statuses',
145
+ rulesOn: 'Enabled',
146
+ rulesOff: 'Disabled',
147
+ rulesPrev: 'Previous',
148
+ rulesNext: 'Next',
149
+ rulesPage: 'Page {current} / {total}',
150
+ rulesNoMatch: 'No matching rules',
151
+ rulesLoading: 'Loading rules…',
152
+ ruleSystem: 'System',
153
+ ruleBuiltin: 'Built-in',
154
+ ruleCustom: 'Custom',
155
+ ruleApprox: 'Approximate',
156
+ ruleLoose: 'Loose',
157
+ ruleSkipped: '{count} file-only rule(s) skipped',
158
+ addEntry: 'Add sensitive data',
159
+ addEntryTitle: 'Add sensitive data',
160
+ addEntryName: 'e.g. intranet password',
161
+ addEntryNameLabel: 'Name',
162
+ addEntryPlain: 'Plaintext value',
163
+ addEntryPlainLabel: 'Plaintext',
164
+ addEntryKind: 'Type',
165
+ addEntryKindLabel: 'Type',
166
+ addEntrySubmit: 'Save',
167
+ addEntryCancel: 'Cancel',
168
+ addEntryClose: 'Close',
169
+ addEntryOk: 'Saved encrypted; it will be masked from now on',
170
+ addEntryFail: 'Could not save; open this page on the server machine',
171
+ addEntryNeedKind: 'Give the custom type a name',
172
+ addKindCustom: 'Custom type…',
173
+ addKindCustomLabel: 'Type name',
174
+ addKindCustomPlaceholder: 'e.g. internal credential',
175
+ entrySearch: 'Search name, preview or placeholder',
176
+ entryDelete: 'Delete',
177
+ kindPassword: 'Password',
178
+ kindToken: 'Token',
179
+ kindKey: 'Key',
82
180
  };
83
181
 
84
182
  const REVEAL_MS = 20_000;
@@ -114,6 +212,58 @@ window.__ModuleLoader__.load({
114
212
  cursor: 'pointer',
115
213
  };
116
214
  const focusCss = '.dsguard-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}';
215
+ /** Some hosts only substitute a single {count}; fill placeholders locally too. */
216
+ function fillTemplate(text, params) {
217
+ let out = String(text || '');
218
+ for (const [k, v] of Object.entries(params || {})) out = out.replace(`{${k}}`, String(v));
219
+ return out;
220
+ }
221
+ const inputStyle = {
222
+ flex: '1 1 200px', minWidth: 0, padding: '7px 10px', borderRadius: 8,
223
+ border: '1px solid var(--dsw-alias-border-l2)',
224
+ background: 'var(--dsw-alias-bg-layer-1)',
225
+ color: 'var(--dsw-alias-label-primary)', fontSize: 12,
226
+ };
227
+ const selectStyle = { ...inputStyle, flex: '0 0 auto', cursor: 'pointer' };
228
+ const primaryBtn = {
229
+ ...btnStyle, width: 'auto', height: 32, padding: '0 14px', fontSize: 12,
230
+ background: 'var(--dsw-alias-label-primary)', color: 'var(--dsw-alias-bg-layer-1)',
231
+ border: '1px solid transparent',
232
+ };
233
+ const dangerBtn = {
234
+ ...btnStyle, width: 'auto', height: 30, padding: '0 10px', fontSize: 12,
235
+ color: 'var(--dsw-alias-state-error-primary, #e5534b)',
236
+ borderColor: 'rgba(229,83,75,0.55)',
237
+ };
238
+ const dangerPrimary = {
239
+ ...dangerBtn, padding: '0 14px', fontWeight: 500,
240
+ background: 'rgba(229,83,75,0.14)',
241
+ };
242
+ const tagStyle = {
243
+ padding: '2px 7px', borderRadius: 6, fontSize: 11,
244
+ background: 'var(--dsw-alias-bg-layer-1)',
245
+ color: 'var(--dsw-alias-label-secondary)',
246
+ border: '1px solid var(--dsw-alias-border-l2)',
247
+ };
248
+ const warnTagStyle = { ...tagStyle, color: 'var(--dsw-alias-state-warn-label)', borderColor: 'rgba(239,159,39,0.55)' };
249
+ const tabBarStyle = { display: 'flex', gap: 8, borderBottom: '1px solid var(--dsw-alias-border-l2)', paddingBottom: 8 };
250
+ function tabStyle(active) {
251
+ return {
252
+ ...btnStyle, width: 'auto', height: 30, padding: '0 12px', fontSize: 12,
253
+ border: '1px solid transparent',
254
+ background: active ? 'var(--dsw-alias-bg-layer-1)' : 'transparent',
255
+ color: active ? 'var(--dsw-alias-label-primary)' : 'var(--dsw-alias-label-secondary)',
256
+ };
257
+ }
258
+ function switchStyle(on) {
259
+ return {
260
+ ...btnStyle, width: 38, height: 22, borderRadius: 11, padding: 0,
261
+ background: on ? '#1D9E75' : 'var(--dsw-alias-border-l2)',
262
+ border: '1px solid transparent',
263
+ justifyContent: on ? 'flex-end' : 'flex-start',
264
+ };
265
+ }
266
+ const knobStyle = { width: 16, height: 16, borderRadius: 8, background: '#fff', display: 'block' };
117
267
 
118
268
  function LockGlyph({ open }) {
119
269
  return h('svg', { width: 15, height: 15, viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.3, 'aria-hidden': 'true' },
@@ -121,6 +271,33 @@ window.__ModuleLoader__.load({
121
271
  h('path', { d: open ? 'M5.5 7.5V5.5a2.5 2.5 0 0 1 4.9-.7' : 'M5.5 7.5V5.5a2.5 2.5 0 0 1 5 0v2' }));
122
272
  }
123
273
 
274
+ function CopyGlyph() {
275
+ return h('svg', { width: 15, height: 15, viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.3, 'aria-hidden': 'true' },
276
+ h('rect', { x: 5.5, y: 5.5, width: 8, height: 8, rx: 1.4 }),
277
+ h('path', { d: 'M10.5 3.5H4A1.5 1.5 0 0 0 2.5 5v6.5' }));
278
+ }
279
+
280
+ /** Never put plaintext into model context: this is a browser-side copy. */
281
+ async function copyToClipboard(text) {
282
+ try {
283
+ if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
284
+ await navigator.clipboard.writeText(text);
285
+ return true;
286
+ }
287
+ } catch { /* fall through to the legacy path */ }
288
+ try {
289
+ const ta = document.createElement('textarea');
290
+ ta.value = text;
291
+ ta.style.position = 'fixed';
292
+ ta.style.opacity = '0';
293
+ document.body.appendChild(ta);
294
+ ta.select();
295
+ const ok = document.execCommand('copy');
296
+ document.body.removeChild(ta);
297
+ return ok;
298
+ } catch { return false; }
299
+ }
300
+
124
301
  function formatLeft(ms) {
125
302
  const total = Math.max(0, Math.ceil((Number(ms) || 0) / 1000));
126
303
  const m = Math.floor(total / 60);
@@ -171,6 +348,284 @@ window.__ModuleLoader__.load({
171
348
  t('restrictedAlt')));
172
349
  }
173
350
 
351
+ /** Detection-rule catalogue: search, status filter, pagination, per-rule switch. */
352
+ function RulesPane({ t }) {
353
+ const [data, setData] = useState(null);
354
+ const [query, setQuery] = useState('');
355
+ const [filter, setFilter] = useState('all');
356
+ const [page, setPage] = useState(1);
357
+ const [busy, setBusy] = useState(null);
358
+ const alive = useRef(true);
359
+
360
+ const load = useCallback(async () => {
361
+ try {
362
+ const res = await fetch('/guard/rules', { cache: 'no-store' });
363
+ const json = await res.json().catch(() => null);
364
+ if (alive.current && res.ok && json) setData(json);
365
+ } catch { /* leave the last known list */ }
366
+ }, []);
367
+ useEffect(() => {
368
+ alive.current = true;
369
+ load();
370
+ return () => { alive.current = false; };
371
+ }, [load]);
372
+
373
+ const toggle = useCallback(async (id, enabled) => {
374
+ setBusy(id);
375
+ try {
376
+ const res = await fetch('/guard/rules', {
377
+ method: 'POST', headers: { 'content-type': 'application/json' },
378
+ body: JSON.stringify({ id, enabled }),
379
+ });
380
+ const json = await res.json().catch(() => null);
381
+ if (alive.current && res.ok && json) setData(json);
382
+ } catch { /* keep the old state */ }
383
+ if (alive.current) setBusy(null);
384
+ }, []);
385
+
386
+ const all = (data && data.rules) || [];
387
+ const q = String(query || '').trim().toLowerCase();
388
+ const filtered = all.filter((r) => {
389
+ if (filter === 'on' && !r.enabled) return false;
390
+ if (filter === 'off' && r.enabled) return false;
391
+ if (!q) return true;
392
+ return `${r.name} ${r.id} ${(r.keywords || []).join(' ')}`.toLowerCase().includes(q);
393
+ });
394
+ // Enabled rules first, so the 14 default-off ones collect on the last page
395
+ // instead of being scattered through the list.
396
+ const sorted = filtered.slice().sort((a, b) => (a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1));
397
+ const size = (data && data.pageSize) || 20;
398
+ const pages = Math.max(1, Math.ceil(sorted.length / size));
399
+ const current = Math.min(Math.max(1, page), pages);
400
+ const rows = sorted.slice((current - 1) * size, current * size);
401
+ const sourceLabel = (r) => (r.source === 'gitleaks' ? t('ruleSystem') : r.source === 'custom' ? t('ruleCustom') : t('ruleBuiltin'));
402
+
403
+ let listNode;
404
+ if (!data) {
405
+ listNode = h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, t('rulesLoading'));
406
+ } else if (rows.length === 0) {
407
+ listNode = h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, t('rulesNoMatch'));
408
+ } else {
409
+ listNode = h('div', { style: { display: 'grid', gap: 8 } },
410
+ rows.map((r) => h('div', { key: r.id, style: boxStyle },
411
+ h('span', { style: { flex: '1 1 auto', minWidth: 0, display: 'grid', gap: 5 } },
412
+ h('span', { style: { fontSize: 13, color: 'var(--dsw-alias-label-primary)' } }, r.name),
413
+ h('span', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
414
+ (r.detectors || []).map((d) => h('span', { key: d, style: tagStyle }, d)),
415
+ h('span', { style: tagStyle }, sourceLabel(r)),
416
+ r.approx ? h('span', { style: warnTagStyle }, t('ruleApprox')) : null,
417
+ r.tier === 'loose' ? h('span', { style: warnTagStyle }, t('ruleLoose')) : null)),
418
+ h('button', {
419
+ type: 'button', className: 'dsguard-btn', style: switchStyle(r.enabled),
420
+ 'aria-pressed': Boolean(r.enabled), 'aria-label': r.name,
421
+ disabled: busy === r.id,
422
+ onClick: () => toggle(r.id, !r.enabled),
423
+ }, h('span', { style: knobStyle })))));
424
+ }
425
+
426
+ return h('div', { style: { display: 'grid', gap: 12 } },
427
+ h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
428
+ h('select', {
429
+ value: filter, style: selectStyle,
430
+ onChange: (e) => { setFilter(e && e.target ? e.target.value : 'all'); setPage(1); },
431
+ },
432
+ h('option', { value: 'all' }, t('rulesAll')),
433
+ h('option', { value: 'on' }, t('rulesOn')),
434
+ h('option', { value: 'off' }, t('rulesOff'))),
435
+ h('input', {
436
+ type: 'text', value: query, placeholder: t('rulesSearch'), style: inputStyle,
437
+ onChange: (e) => { setQuery(e && e.target ? e.target.value : ''); setPage(1); },
438
+ }),
439
+ h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)' } },
440
+ `${filtered.length} / ${all.length}`)),
441
+ listNode,
442
+ h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 10 } },
443
+ h('button', {
444
+ type: 'button', className: 'dsguard-btn',
445
+ style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12, opacity: current <= 1 ? 0.45 : 1 },
446
+ disabled: current <= 1, onClick: () => setPage(current - 1),
447
+ }, t('rulesPrev')),
448
+ h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)' } },
449
+ fillTemplate(t('rulesPage', { current: String(current), total: String(pages) }),
450
+ { current: String(current), total: String(pages) })),
451
+ h('button', {
452
+ type: 'button', className: 'dsguard-btn',
453
+ style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12, opacity: current >= pages ? 0.45 : 1 },
454
+ disabled: current >= pages, onClick: () => setPage(current + 1),
455
+ }, t('rulesNext'))),
456
+ data && data.skipped && data.skipped.length
457
+ ? h('p', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)', margin: 0 } },
458
+ fillTemplate(t('ruleSkipped', { count: String(data.skipped.length) }),
459
+ { count: String(data.skipped.length) }))
460
+ : null);
461
+ }
462
+
463
+ /** Add a secret by hand in a modal. Plaintext is sent once, never written to config. */
464
+ const KIND_CUSTOM = '__custom__';
465
+ function AddEntryForm({ t, onAdded, disabled }) {
466
+ const [open, setOpen] = useState(false);
467
+ const [name, setName] = useState('');
468
+ const [plain, setPlain] = useState('');
469
+ const [kind, setKind] = useState('密码');
470
+ const [customKind, setCustomKind] = useState('');
471
+ const [note, setNote] = useState('');
472
+
473
+ const close = () => { setOpen(false); setPlain(''); setCustomKind(''); };
474
+ useEffect(() => {
475
+ if (!open) return undefined;
476
+ const onKey = (e) => { if (e && e.key === 'Escape') close(); };
477
+ try {
478
+ window.addEventListener('keydown', onKey);
479
+ return () => window.removeEventListener('keydown', onKey);
480
+ } catch { return undefined; }
481
+ }, [open]);
482
+
483
+ const fieldStyle = { display: 'grid', gap: 5 };
484
+ const labelStyle = { fontSize: 11, color: 'var(--dsw-alias-label-secondary)' };
485
+ const fullInput = { ...inputStyle, flex: 'none', width: '100%', boxSizing: 'border-box' };
486
+
487
+ const submit = async () => {
488
+ const value = String(plain || '').trim();
489
+ if (!value) return;
490
+ const resolved = kind === KIND_CUSTOM ? String(customKind || '').trim() : kind;
491
+ if (!resolved) { setNote(t('addEntryNeedKind')); return; }
492
+ try {
493
+ const res = await fetch('/guard/entries', {
494
+ method: 'POST', headers: { 'content-type': 'application/json' },
495
+ body: JSON.stringify({ action: 'add', name: String(name || '').trim(), plaintext: value, kind: resolved }),
496
+ });
497
+ if (!res.ok) throw new Error('failed');
498
+ setName(''); close(); setNote(t('addEntryOk'));
499
+ if (onAdded) onAdded();
500
+ } catch { setNote(t('addEntryFail')); }
501
+ };
502
+
503
+ if (!open) {
504
+ return h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
505
+ h('button', {
506
+ type: 'button', className: 'dsguard-btn', style: primaryBtn,
507
+ disabled, onClick: () => { setNote(''); setOpen(true); },
508
+ }, t('addEntry')),
509
+ note ? h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)' } }, note) : null);
510
+ }
511
+
512
+ return h('div', {
513
+ style: {
514
+ position: 'fixed', inset: 0, zIndex: 9999, padding: 20,
515
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
516
+ background: 'rgba(0,0,0,0.45)',
517
+ },
518
+ onClick: (e) => { if (e && e.target === e.currentTarget) close(); },
519
+ },
520
+ h('div', {
521
+ style: {
522
+ width: 'min(420px, 100%)', display: 'grid', gap: 14, padding: 20,
523
+ borderRadius: 14, background: 'var(--dsw-alias-bg-layer-1)',
524
+ border: '1px solid var(--dsw-alias-border-l2)',
525
+ boxShadow: '0 12px 32px rgba(0,0,0,0.28)',
526
+ },
527
+ },
528
+ h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } },
529
+ h('h3', { style: { margin: 0, fontSize: 15, fontWeight: 500, color: 'var(--dsw-alias-label-primary)' } }, t('addEntryTitle')),
530
+ h('button', {
531
+ type: 'button', className: 'dsguard-btn',
532
+ style: { ...btnStyle, width: 26, height: 26, fontSize: 14 },
533
+ 'aria-label': t('addEntryClose'), title: t('addEntryClose'),
534
+ onClick: close,
535
+ }, '×')),
536
+ h('div', { style: fieldStyle },
537
+ h('span', { style: labelStyle }, t('addEntryNameLabel')),
538
+ h('input', {
539
+ type: 'text', value: name, placeholder: t('addEntryName'), style: fullInput,
540
+ onChange: (e) => setName(e && e.target ? e.target.value : ''),
541
+ })),
542
+ h('div', { style: fieldStyle },
543
+ h('span', { style: labelStyle }, t('addEntryPlainLabel')),
544
+ h('input', {
545
+ type: 'text', value: plain, placeholder: t('addEntryPlain'), style: fullInput,
546
+ onChange: (e) => setPlain(e && e.target ? e.target.value : ''),
547
+ })),
548
+ h('div', { style: fieldStyle },
549
+ h('span', { style: labelStyle }, t('addEntryKindLabel')),
550
+ h('select', {
551
+ value: kind, style: { ...fullInput, cursor: 'pointer' },
552
+ onChange: (e) => setKind(e && e.target ? e.target.value : '密码'),
553
+ },
554
+ h('option', { value: '密码' }, t('kindPassword')),
555
+ h('option', { value: '令牌' }, t('kindToken')),
556
+ h('option', { value: '密钥' }, t('kindKey')),
557
+ h('option', { value: KIND_CUSTOM }, t('addKindCustom')))),
558
+ kind === KIND_CUSTOM
559
+ ? h('div', { style: fieldStyle },
560
+ h('span', { style: labelStyle }, t('addKindCustomLabel')),
561
+ h('input', {
562
+ type: 'text', value: customKind, placeholder: t('addKindCustomPlaceholder'), style: fullInput,
563
+ onChange: (e) => setCustomKind(e && e.target ? e.target.value : ''),
564
+ }))
565
+ : null,
566
+ note ? h('p', { style: { margin: 0, fontSize: 11, color: 'var(--dsw-alias-state-warn-label)' } }, note) : null,
567
+ h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 2 } },
568
+ h('button', {
569
+ type: 'button', className: 'dsguard-btn',
570
+ style: { ...btnStyle, width: 'auto', padding: '0 14px', fontSize: 12 },
571
+ onClick: close,
572
+ }, t('addEntryCancel')),
573
+ h('button', {
574
+ type: 'button', className: 'dsguard-btn', style: primaryBtn,
575
+ disabled, onClick: submit,
576
+ }, t('addEntrySubmit')))));
577
+ }
578
+
579
+ /** Destructive, persistent action — always confirm before disabling. */
580
+ function DisableConfirm({ t, onConfirm, onCancel }) {
581
+ useEffect(() => {
582
+ const onKey = (e) => { if (e && e.key === 'Escape') onCancel(); };
583
+ try {
584
+ window.addEventListener('keydown', onKey);
585
+ return () => window.removeEventListener('keydown', onKey);
586
+ } catch { return undefined; }
587
+ }, [onCancel]);
588
+ return h('div', {
589
+ style: {
590
+ position: 'fixed', inset: 0, zIndex: 9999, padding: 20,
591
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
592
+ background: 'rgba(0,0,0,0.45)',
593
+ },
594
+ onClick: (e) => { if (e && e.target === e.currentTarget) onCancel(); },
595
+ },
596
+ h('div', {
597
+ style: {
598
+ width: 'min(400px, 100%)', display: 'grid', gap: 14, padding: 20,
599
+ borderRadius: 14, background: 'var(--dsw-alias-bg-layer-1)',
600
+ border: '1px solid var(--dsw-alias-border-l2)',
601
+ boxShadow: '0 12px 32px rgba(0,0,0,0.28)',
602
+ },
603
+ },
604
+ h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } },
605
+ h('h3', {
606
+ style: { margin: 0, fontSize: 15, fontWeight: 500, color: 'var(--dsw-alias-state-error-primary, #e5534b)' },
607
+ }, t('disableTitle')),
608
+ h('button', {
609
+ type: 'button', className: 'dsguard-btn',
610
+ style: { ...btnStyle, width: 26, height: 26, fontSize: 14 },
611
+ 'aria-label': t('disableCancel'), title: t('disableCancel'),
612
+ onClick: onCancel,
613
+ }, '×')),
614
+ h('p', {
615
+ style: { margin: 0, fontSize: 12, lineHeight: 1.7, color: 'var(--dsw-alias-label-primary)' },
616
+ }, t('disableBody')),
617
+ h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8 } },
618
+ h('button', {
619
+ type: 'button', className: 'dsguard-btn',
620
+ style: { ...btnStyle, width: 'auto', padding: '0 14px', fontSize: 12 },
621
+ onClick: onCancel,
622
+ }, t('disableCancel')),
623
+ h('button', {
624
+ type: 'button', className: 'dsguard-btn', style: dangerPrimary,
625
+ onClick: onConfirm,
626
+ }, t('disableConfirm')))));
627
+ }
628
+
174
629
  function GuardView({ t }) {
175
630
  const [data, setData] = useState(null);
176
631
  const [status, setStatus] = useState('loading');
@@ -179,6 +634,10 @@ window.__ModuleLoader__.load({
179
634
  // Set when the server explains a rejection; keeps the page actionable
180
635
  // instead of showing a bare "failed to load".
181
636
  const [denied, setDenied] = useState(null);
637
+ const [tab, setTab] = useState('entries');
638
+ const [entryQuery, setEntryQuery] = useState('');
639
+ const [copied, setCopied] = useState('');
640
+ const [confirmDisable, setConfirmDisable] = useState(false);
182
641
  const timers = useRef({});
183
642
  const alive = useRef(true);
184
643
 
@@ -268,17 +727,46 @@ window.__ModuleLoader__.load({
268
727
  headers: { 'content-type': 'application/json' },
269
728
  body: JSON.stringify(payload),
270
729
  });
271
- if (res.ok) setGuard(await res.json());
730
+ if (res.ok) { setGuard(await res.json()); setConfirmDisable(false); }
272
731
  } catch { /* ignore */ }
273
732
  }, []);
274
733
 
734
+ const deleteEntry = useCallback(async (ph) => {
735
+ try {
736
+ const res = await fetch('/guard/entries', {
737
+ method: 'POST', headers: { 'content-type': 'application/json' },
738
+ body: JSON.stringify({ action: 'delete', placeholder: ph }),
739
+ });
740
+ if (res.ok) load();
741
+ } catch { /* leave the row in place */ }
742
+ }, [load]);
743
+
744
+ const copyPlaintext = useCallback(async (ph) => {
745
+ try {
746
+ const res = await fetch('/guard/reveal', {
747
+ method: 'POST', headers: { 'content-type': 'application/json' },
748
+ body: JSON.stringify({ placeholder: ph }),
749
+ });
750
+ if (!res.ok) throw new Error('failed');
751
+ const json = await res.json();
752
+ const ok = await copyToClipboard(json.plaintext || '');
753
+ if (!alive.current) return;
754
+ setCopied(ok ? ph : `error:${ph}`);
755
+ window.clearTimeout(timers.current.copy);
756
+ timers.current.copy = window.setTimeout(() => { if (alive.current) setCopied(''); }, 1800);
757
+ } catch {
758
+ if (alive.current) setCopied(`error:${ph}`);
759
+ }
760
+ }, []);
761
+
275
762
  useEffect(() => { loadGuard(); }, [loadGuard]);
276
763
 
277
764
  const paused = Boolean(guard && guard.paused);
278
765
  const untilRestart = Boolean(guard && guard.untilRestart);
766
+ const disabled = Boolean(guard && guard.off);
279
767
 
280
768
  useEffect(() => {
281
- if (!paused || untilRestart) return undefined;
769
+ if (!paused || untilRestart || disabled) return undefined;
282
770
  const id = window.setInterval(() => {
283
771
  setGuard((prev) => {
284
772
  if (!prev || !prev.paused) return prev;
@@ -288,15 +776,70 @@ window.__ModuleLoader__.load({
288
776
  });
289
777
  }, 1000);
290
778
  return () => window.clearInterval(id);
291
- }, [paused, untilRestart, loadGuard]);
779
+ }, [paused, untilRestart, disabled, loadGuard]);
292
780
 
293
781
  const entries = (data && data.entries) || [];
782
+ const eq = String(entryQuery || '').trim().toLowerCase();
783
+ const visibleEntries = eq
784
+ ? entries.filter((e) => `${e.name || ''} ${e.preview || ''} ${e.ph} ${e.rule || ''}`.toLowerCase().includes(eq))
785
+ : entries;
294
786
  const access = (data && data.access) || denied || {};
295
787
  // Either the server degraded us to metadata-only, or it refused outright.
296
788
  const restricted = Boolean(data && data.restricted) || Boolean(denied);
297
789
 
790
+ // One row of state controls: a persistent disable is always reachable,
791
+ // but it goes through a confirmation modal first.
792
+ const stateButtons = disabled
793
+ ? [h('button', {
794
+ key: 'enable', type: 'button', className: 'dsguard-btn',
795
+ style: { ...primaryBtn, width: 'auto', padding: '0 12px', fontSize: 12 },
796
+ onClick: () => applyPause({ action: 'enable' }),
797
+ }, t('enable'))]
798
+ : [
799
+ ...(paused
800
+ ? [h('button', {
801
+ key: 'resume', type: 'button', className: 'dsguard-btn',
802
+ style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
803
+ onClick: () => applyPause({ action: 'resume' }),
804
+ }, t('resume'))]
805
+ : [
806
+ h('button', {
807
+ key: 'p30', type: 'button', className: 'dsguard-btn',
808
+ style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
809
+ onClick: () => applyPause({ action: 'pause', minutes: 30 }),
810
+ }, t('pause30')),
811
+ h('button', {
812
+ key: 'p120', type: 'button', className: 'dsguard-btn',
813
+ style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
814
+ onClick: () => applyPause({ action: 'pause', minutes: 120 }),
815
+ }, t('pause120')),
816
+ h('button', {
817
+ key: 'pr', type: 'button', className: 'dsguard-btn',
818
+ style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
819
+ onClick: () => applyPause({ action: 'pause', untilRestart: true }),
820
+ }, t('pauseRestart')),
821
+ ]),
822
+ h('button', {
823
+ key: 'disable', type: 'button', className: 'dsguard-btn',
824
+ style: dangerBtn, title: t('disableTitle'),
825
+ onClick: () => setConfirmDisable(true),
826
+ }, t('disable')),
827
+ ];
828
+
298
829
  return h('div', { style: { display: 'grid', gap: 14 } },
299
830
  h('style', {}, focusCss),
831
+ h('div', { style: tabBarStyle },
832
+ h('button', {
833
+ type: 'button', className: 'dsguard-btn', style: tabStyle(tab === 'rules'),
834
+ onClick: () => setTab('rules'),
835
+ }, t('tabRules')),
836
+ h('button', {
837
+ type: 'button', className: 'dsguard-btn', style: tabStyle(tab === 'entries'),
838
+ onClick: () => setTab('entries'),
839
+ }, t('tabEntries'))),
840
+ tab === 'rules'
841
+ ? h(RulesPane, { t })
842
+ : h('div', { style: { display: 'grid', gap: 14 } },
300
843
  restricted
301
844
  ? h(RestrictedNotice, {
302
845
  t,
@@ -312,56 +855,37 @@ window.__ModuleLoader__.load({
312
855
  flexWrap: 'wrap',
313
856
  padding: '8px 12px',
314
857
  borderRadius: 10,
315
- border: `1px solid ${paused ? 'rgba(239,159,39,0.55)' : 'var(--dsw-alias-border-l2)'}`,
316
- background: paused ? 'rgba(239,159,39,0.12)' : 'var(--dsw-alias-bg-layer-1)',
858
+ border: `1px solid ${disabled ? 'rgba(229,83,75,0.6)' : paused ? 'rgba(239,159,39,0.55)' : 'var(--dsw-alias-border-l2)'}`,
859
+ background: disabled ? 'rgba(229,83,75,0.12)' : paused ? 'rgba(239,159,39,0.12)' : 'var(--dsw-alias-bg-layer-1)',
317
860
  },
318
861
  },
319
862
  h('span', {
320
863
  style: {
321
864
  fontSize: 12,
322
865
  fontWeight: 500,
323
- color: paused ? 'var(--dsw-alias-state-warn-label)' : 'var(--dsw-alias-label-primary)',
866
+ color: disabled
867
+ ? 'var(--dsw-alias-state-error-primary, #e5534b)'
868
+ : paused ? 'var(--dsw-alias-state-warn-label)' : 'var(--dsw-alias-label-primary)',
324
869
  },
325
- }, paused ? `● ${t('statusOff')}` : `● ${t('statusOn')}`),
326
- paused
870
+ }, disabled ? `● ${t('statusDisabled')}` : paused ? `● ${t('statusOff')}` : `● ${t('statusOn')}`),
871
+ paused && !disabled
327
872
  ? h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)' } },
328
873
  untilRestart ? t('pauseRestartLeft') : formatLeft(guard && guard.remainingMs))
329
874
  : null,
330
875
  h('span', { style: { flex: 1 } }),
331
- paused
332
- ? h('button', {
333
- type: 'button',
334
- className: 'dsguard-btn',
335
- style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
336
- onClick: () => applyPause({ action: 'resume' }),
337
- }, t('resume'))
338
- : [
339
- h('button', {
340
- key: 'p30', type: 'button', className: 'dsguard-btn',
341
- style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
342
- onClick: () => applyPause({ action: 'pause', minutes: 30 }),
343
- }, t('pause30')),
344
- h('button', {
345
- key: 'p120', type: 'button', className: 'dsguard-btn',
346
- style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
347
- onClick: () => applyPause({ action: 'pause', minutes: 120 }),
348
- }, t('pause120')),
349
- h('button', {
350
- key: 'pr', type: 'button', className: 'dsguard-btn',
351
- style: { ...btnStyle, width: 'auto', padding: '0 10px', fontSize: 12 },
352
- onClick: () => applyPause({ action: 'pause', untilRestart: true }),
353
- }, t('pauseRestart')),
354
- ]),
355
- paused
356
- ? h('p', { style: { fontSize: 11, color: 'var(--dsw-alias-state-warn-label)', margin: 0 } }, t('pausedHint'))
357
- : null,
876
+ ...stateButtons),
877
+ disabled
878
+ ? h('p', { style: { fontSize: 11, lineHeight: 1.6, color: 'var(--dsw-alias-state-error-primary, #e5534b)', margin: 0 } }, t('disabledHint'))
879
+ : paused
880
+ ? h('p', { style: { fontSize: 11, color: 'var(--dsw-alias-state-warn-label)', margin: 0 } }, t('pausedHint'))
881
+ : null,
358
882
  data && data.access && data.access.level === 'lan'
359
883
  ? h('p', { style: { fontSize: 11, lineHeight: 1.6, color: 'var(--dsw-alias-state-warn-label)', margin: 0 } },
360
884
  t('lanExposed', { cidrs: (data.access.allowCidrs || []).join(', ') || '-' }))
361
885
  : null,
362
886
  h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 12, flexWrap: 'wrap' } },
363
887
  h('h3', { style: { fontSize: 13, fontWeight: 500, margin: 0, color: 'var(--dsw-alias-label-primary)' } }, t('heading')),
364
- data ? h('span', { style: { fontSize: 12, color: 'var(--dsw-alias-label-dimmed)' } }, t('stats', { count: String(entries.length) })) : null,
888
+ data ? h('span', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, t('stats', { count: String(entries.length) })) : null,
365
889
  h('button', {
366
890
  type: 'button',
367
891
  className: 'dsguard-btn',
@@ -369,26 +893,34 @@ window.__ModuleLoader__.load({
369
893
  onClick: () => load(),
370
894
  }, t('refresh'))),
371
895
  h('p', { style: { fontSize: 12, lineHeight: 1.6, color: 'var(--dsw-alias-label-secondary)', margin: 0 } }, t('intro')),
896
+ h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
897
+ h(AddEntryForm, { t, onAdded: load, disabled: restricted }),
898
+ h('input', {
899
+ type: 'text', value: entryQuery, placeholder: t('entrySearch'), style: inputStyle,
900
+ onChange: (e) => setEntryQuery(e && e.target ? e.target.value : ''),
901
+ })),
372
902
  status === 'loading' && !data
373
- ? h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-label-dimmed)' } }, t('loading'))
903
+ ? h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, t('loading'))
374
904
  : status === 'error' && !data
375
905
  ? (denied ? null : h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-state-error-primary)' } }, t('error')))
376
- : entries.length === 0
377
- ? h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-label-dimmed)' } }, t('empty'))
906
+ : visibleEntries.length === 0
907
+ ? h('p', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, t('empty'))
378
908
  : h('div', { style: { display: 'grid', gap: 8 } },
379
909
  h('div', {
380
- style: { display: 'flex', gap: 10, padding: '0 12px', fontSize: 11, color: 'var(--dsw-alias-label-dimmed)' },
910
+ style: { display: 'flex', gap: 10, padding: '0 12px', fontSize: 11, color: 'var(--dsw-alias-label-secondary)', whiteSpace: 'nowrap' },
381
911
  },
382
- h('span', { style: { flex: '1 1 46%' } }, t('colValue')),
383
- h('span', { style: { flex: '0 0 90px' } }, t('colKind')),
384
- h('span', { style: { flex: '0 0 140px' } }, t('colTime')),
385
- h('span', { style: { flex: '0 0 48px' } }, t('colHits')),
386
- h('span', { style: { flex: '0 0 30px' } }, '')),
387
- ...entries.map((entry) => {
912
+ h('span', { style: { flex: '1 1 auto', minWidth: 0 } }, t('colValue')),
913
+ h('span', { style: { flex: '0 0 100px' } }, t('colCategory')),
914
+ h('span', { style: { flex: '0 0 120px' } }, t('colKind')),
915
+ h('span', { style: { flex: '0 0 110px' } }, '')),
916
+ ...visibleEntries.map((entry) => {
388
917
  const revealed = Boolean(shown[entry.ph]);
389
- const value = revealed ? shown[entry.ph] : (entry.preview || entry.ph);
390
- return h('div', { key: entry.ph, style: boxStyle },
391
- h('span', { style: { flex: '1 1 46%', minWidth: 0, display: 'grid', gap: 2 } },
918
+ const value = revealed ? shown[entry.ph] : (entry.name || entry.preview || entry.ph);
919
+ const copyState = copied === entry.ph
920
+ ? t('copyOk')
921
+ : copied === `error:${entry.ph}` ? t('copyFail') : null;
922
+ return h('div', { key: entry.ph, style: { ...boxStyle, alignItems: 'center' } },
923
+ h('span', { style: { flex: '1 1 auto', minWidth: 0, display: 'grid', gap: 2 } },
392
924
  h('span', {
393
925
  style: {
394
926
  ...monoStyle,
@@ -397,30 +929,51 @@ window.__ModuleLoader__.load({
397
929
  textOverflow: 'ellipsis',
398
930
  whiteSpace: 'nowrap',
399
931
  },
400
- title: revealed ? undefined : entry.ph,
932
+ title: revealed ? shown[entry.ph] : (entry.name || entry.ph),
401
933
  }, value),
402
- h('span', { style: { ...monoStyle, fontSize: 11, color: 'var(--dsw-alias-label-dimmed)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, entry.ph)),
403
- h('span', { style: { flex: '0 0 90px', fontSize: 12, color: 'var(--dsw-alias-label-secondary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, entry.rule),
404
- h('span', { style: { flex: '0 0 140px', fontSize: 12, color: 'var(--dsw-alias-label-dimmed)' } }, formatTime(entry.createdAt)),
405
- h('span', { style: { flex: '0 0 48px', fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, String(entry.hits)),
406
- h('button', {
407
- type: 'button',
408
- className: 'dsguard-btn',
409
- style: { ...btnStyle, opacity: restricted ? 0.45 : 1, cursor: restricted ? 'not-allowed' : 'pointer' },
410
- 'aria-pressed': revealed,
411
- 'aria-label': restricted ? t('restrictedUnlock') : t(revealed ? 'hide' : 'reveal'),
412
- title: restricted ? t('restrictedUnlock') : t(revealed ? 'hide' : 'reveal'),
413
- disabled: restricted,
414
- onClick: () => { if (!restricted) toggle(entry.ph); },
415
- }, h(LockGlyph, { open: revealed })));
934
+ h('span', { style: { ...monoStyle, fontSize: 11, color: 'var(--dsw-alias-label-secondary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, entry.ph)),
935
+ h('span', { style: { flex: '0 0 100px', fontSize: 12, color: 'var(--dsw-alias-label-primary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: entry.label || '' }, entry.label || '—'),
936
+ h('span', { style: { flex: '0 0 120px', fontSize: 12, color: 'var(--dsw-alias-label-secondary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: entry.rule || '' }, entry.rule),
937
+ h('div', { style: { flex: '0 0 110px', display: 'flex', gap: 6, justifyContent: 'flex-end' } },
938
+ h('button', {
939
+ type: 'button', className: 'dsguard-btn',
940
+ style: { ...btnStyle, opacity: restricted ? 0.45 : 1, cursor: restricted ? 'not-allowed' : 'pointer' },
941
+ 'aria-pressed': revealed,
942
+ 'aria-label': restricted ? t('restrictedUnlock') : t(revealed ? 'hide' : 'reveal'),
943
+ title: restricted ? t('restrictedUnlock') : t(revealed ? 'hide' : 'reveal'),
944
+ disabled: restricted,
945
+ onClick: () => { if (!restricted) toggle(entry.ph); },
946
+ }, h(LockGlyph, { open: revealed })),
947
+ h('button', {
948
+ type: 'button', className: 'dsguard-btn',
949
+ style: { ...btnStyle, width: copyState ? 'auto' : 30, padding: copyState ? '0 8px' : 0, fontSize: 11, opacity: restricted ? 0.45 : 1, cursor: restricted ? 'not-allowed' : 'pointer' },
950
+ 'aria-label': t('copyPlain'), title: t('copyPlain'),
951
+ disabled: restricted,
952
+ onClick: () => { if (!restricted) copyPlaintext(entry.ph); },
953
+ }, copyState || h(CopyGlyph)),
954
+ entry.pinned
955
+ ? h('button', {
956
+ type: 'button', className: 'dsguard-btn',
957
+ style: { ...btnStyle, width: 'auto', padding: '0 8px', fontSize: 11, opacity: restricted ? 0.45 : 1 },
958
+ title: t('entryDelete'), disabled: restricted,
959
+ onClick: () => deleteEntry(entry.ph),
960
+ }, t('entryDelete'))
961
+ : null));
416
962
  }),
417
963
  revealedAny(shown)
418
964
  ? h('p', { style: { fontSize: 11, color: 'var(--dsw-alias-state-warn-label)', margin: 0 } }, t('autoHide'))
419
965
  : null),
420
- h('p', { style: { fontSize: 11, lineHeight: 1.6, color: 'var(--dsw-alias-label-dimmed)', margin: 0 } }, `${t('placeholder')} · ${t('usage')}`),
421
- h('p', { style: { fontSize: 11, color: 'var(--dsw-alias-label-dimmed)', margin: 0 } }, `inline reveal: ${inlineState}`),
966
+ h('p', { style: { fontSize: 11, lineHeight: 1.6, color: 'var(--dsw-alias-label-secondary)', margin: 0 } }, `${t('placeholder')} · ${t('usage')}`),
967
+ h('p', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)', margin: 0 } }, `inline reveal: ${inlineState}`),
422
968
  data && data.lastError
423
969
  ? h('p', { style: { fontSize: 11, color: 'var(--dsh-alias-state-error-primary, var(--dsw-alias-state-error-primary))', margin: 0 } }, `lastError: ${data.lastError}`)
970
+ : null),
971
+ confirmDisable
972
+ ? h(DisableConfirm, {
973
+ t,
974
+ onCancel: () => setConfirmDisable(false),
975
+ onConfirm: () => applyPause({ action: 'disable' }),
976
+ })
424
977
  : null);
425
978
  }
426
979
 
@@ -672,12 +1225,6 @@ window.__ModuleLoader__.load({
672
1225
  }
673
1226
  }
674
1227
 
675
- function formatTime(iso) {
676
- const d = new Date(iso);
677
- if (Number.isNaN(d.getTime())) return '';
678
- return d.toLocaleString(undefined, { hour12: false });
679
- }
680
-
681
1228
  function apply(ctx) {
682
1229
  // The host is fail-fast: a throwing client entry stops the entire app from
683
1230
  // booting ("web boot: 1 entry did not activate"). Never let one plugin do that.