@mysterycode-liwen/dsh-credential-vault 1.4.2 → 1.5.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/client.js CHANGED
@@ -15,7 +15,7 @@ window.__ModuleLoader__.load({
15
15
  // whatever port the Web GUI is on.
16
16
  var API = 'dsh-credential-vault/';
17
17
  /** Plugin version shown in Settings; keep in sync with package.json on release. */
18
- var VERSION = '1.4.2';
18
+ var VERSION = '1.5.0';
19
19
 
20
20
  // Compare two semver-ish strings: -1 (left older), 0 (equal), 1 (left newer).
21
21
  // Used to decide "update available" against THIS client's version, so the
@@ -40,6 +40,7 @@ window.__ModuleLoader__.load({
40
40
  sort: 'Sort', sortRecent: 'Recently updated', sortTitle: 'Name (A–Z)', sortCategory: 'Type',
41
41
  search: 'Search name, account, URL or notes…',
42
42
  filterAll: 'All', filterAccount: 'Accounts', filterApikey: 'API keys', filterOther: 'Other',
43
+ filterWechatMp: 'Official Accounts', filterWechatMini: 'Mini Programs',
43
44
  localNotice: 'Stored locally in this browser (localStorage) on this device. Not synced or encrypted — avoid shared / public browsers.',
44
45
  show: 'Show', hide: 'Hide', copy: 'Copy', visit: 'Visit', copied: 'Copied to clipboard', copyFail: 'Copy failed — select the text manually',
45
46
  visitFail: 'Could not open the browser. Check the URL and try again.',
@@ -49,7 +50,8 @@ window.__ModuleLoader__.load({
49
50
  emptyFiltered: 'No matches',
50
51
  editorNew: 'New credential', editorEdit: 'Edit credential',
51
52
  fTitle: 'Name', fTitlePh: 'e.g. GitHub, Google', fTitlePhApikey: 'e.g. OpenAI, AWS, GitHub PAT', fTitlePhOther: 'e.g. Recovery codes, Wi-Fi, License',
52
- fCategory: 'Type',
53
+ fTitlePhWechatMp: 'e.g. My Official Account', fTitlePhWechatMini: 'e.g. My Mini Program',
54
+ fCategory: 'Type', formDetails: 'Credentials', moreFields: 'More fields', lessFields: 'Fewer fields',
53
55
  fAccount: 'Account / username', fAccountPh: 'user@example.com',
54
56
  fPassword: 'Password', fPasswordPh: 'Enter password',
55
57
  fUrl: 'Login URL (optional)', fUrlPh: 'https://…',
@@ -59,10 +61,20 @@ window.__ModuleLoader__.load({
59
61
  fExpiry: 'Expires on (optional)',
60
62
  fContent: 'Content / secret', fContentPh: 'Recovery codes, license key, certificate, PIN…',
61
63
  fNotes: 'Notes (optional)', fNotesPh: 'Any extra info…',
64
+ fAppId: 'AppID', fAppIdPh: 'wx…',
65
+ fAppSecret: 'AppSecret', fAppSecretPh: 'Application secret',
66
+ fToken: 'Server Token', fTokenPh: 'Token from server config',
67
+ fAesKey: 'EncodingAESKey', fAesKeyPh: '43-char message encryption key',
68
+ fServerUrl: 'Server URL', fServerUrlPh: 'https://… (callback URL)',
69
+ fUploadKey: 'Code upload key', fUploadKeyPh: 'Private key used to upload mini program code',
70
+ fDomains: 'Server domains', fDomainsPh: 'request / socket / upload / download domains',
62
71
  catAccount: 'Account', catApikey: 'API key', catOther: 'Other',
72
+ catWechatMp: 'WeChat Official Account', catWechatMini: 'WeChat Mini Program',
63
73
  hintAccount: 'For website / app logins — username and password.',
64
74
  hintApikey: 'For platform-issued API keys, tokens and endpoints.',
65
75
  hintOther: 'For recovery codes, licenses, certificates or any free text.',
76
+ hintWechatMp: 'For WeChat Official Account developer credentials and server config.',
77
+ hintWechatMini: 'For WeChat Mini Program developer credentials and upload key.',
66
78
  save: 'Save', cancel: 'Cancel', required: 'Please enter a name',
67
79
  confirmDelete: 'Delete this credential? This cannot be undone.',
68
80
  saved: 'Saved', deleted: 'Deleted', revealAll: 'Reveal all', hideAll: 'Hide all',
@@ -91,6 +103,8 @@ window.__ModuleLoader__.load({
91
103
  resetSubmit: 'Reset password', resetFail: 'That answer does not match.', resetDone: 'Password has been reset. Please unlock again.',
92
104
  resetUnavailable: 'No security question is configured. Restore from a backup or clear this browser\'s site data.',
93
105
  lockIdle: 'Locked after inactivity',
106
+ auditTitle: 'Access audit', auditDesc: 'In-memory log of agent reads of your vault metadata. No secrets or plaintext are ever recorded; cleared on restart.',
107
+ auditView: 'View log', auditLoading: 'Loading…', auditTotal: 'Total events', auditEmpty: 'No accesses recorded yet.', auditFail: 'Audit log is unavailable.',
94
108
  updateTitle: 'Plugin updates', updateDesc: 'Check whether a newer version of the dsh-credential-vault plugin is available.',
95
109
  updateCurrent: 'Current version', updateLatest: 'Latest version', updateCheck: 'Check for updates',
96
110
  updateChecking: 'Checking…', updateAvailable: 'A newer version is available:', updateUpToDate: 'You are up to date.',
@@ -117,6 +131,14 @@ window.__ModuleLoader__.load({
117
131
  exportFormat: 'Export format', exportJson: 'JSON backup', exportJsonHint: 'Full fidelity — restores every field exactly (recommended).',
118
132
  exportCsv: 'CSV for Excel / WPS', exportCsvHint: 'Chinese headers, readable order, UTF-8 with BOM.',
119
133
  exportMd: 'Markdown cards', exportMdHint: 'One card per entry with Chinese labels — clean and readable.',
134
+ exportEncrypted: 'Encrypted backup (password)', exportEncryptedHint: 'Full backup with secrets, sealed by AES-GCM with a password you choose. Import asks for the same password.',
135
+ exportEncryptedGo: 'Encrypt & download', exportEncryptedDone: 'Encrypted backup downloaded — keep your password safe, it cannot be recovered.',
136
+ encPwHint: 'Choose a strong password. It is never stored — losing it means the backup cannot be restored.',
137
+ encPw: 'Encryption password', encPw2: 'Confirm password', encPwShort: 'Use at least 6 characters.',
138
+ encPwMismatch: 'Passwords do not match.', encPwRequired: 'Enter the password.',
139
+ encBusy: 'Working…', encNoCrypto: 'This browser does not support the required encryption (Web Crypto).',
140
+ encDetected: 'Encrypted backup detected', encImportHint: 'Enter the password used when exporting to decrypt this backup.',
141
+ encUnlock: 'Decrypt', encWrongPw: 'Wrong password or corrupted file.',
120
142
  genButton: 'Generate password', genField: 'Generate a password for this field',
121
143
  genTitle: 'Password generator', genHint: 'Generates a strong random password using your browser’s cryptographic random source. Nothing is stored or sent anywhere.',
122
144
  genLength: 'Length', genUpper: 'Uppercase (A–Z)', genLower: 'Lowercase (a–z)', genDigits: 'Digits (0–9)',
@@ -143,6 +165,7 @@ window.__ModuleLoader__.load({
143
165
  sort: '排序', sortRecent: '最近更新', sortTitle: '名称(A–Z)', sortCategory: '类型',
144
166
  search: '搜索名称、账号、网址或备注…',
145
167
  filterAll: '全部', filterAccount: '账号密码', filterApikey: 'API Key', filterOther: '其他',
168
+ filterWechatMp: '微信公众号', filterWechatMini: '微信小程序',
146
169
  localNotice: '数据仅保存在本机浏览器的 localStorage 中,不跨设备同步、不加密,请避免在公用/共享浏览器使用。',
147
170
  show: '显示', hide: '隐藏', copy: '复制', visit: '访问', copied: '已复制到剪贴板', copyFail: '复制失败,请手动选择文本',
148
171
  visitFail: '无法打开浏览器,请检查网址后重试。',
@@ -152,7 +175,8 @@ window.__ModuleLoader__.load({
152
175
  emptyFiltered: '没有匹配项',
153
176
  editorNew: '新增凭据', editorEdit: '编辑凭据',
154
177
  fTitle: '名称', fTitlePh: '例如:GitHub、Google', fTitlePhApikey: '例如:OpenAI、AWS、GitHub PAT', fTitlePhOther: '例如:恢复码、Wi-Fi、许可证',
155
- fCategory: '类型',
178
+ fTitlePhWechatMp: '例如:我的公众号', fTitlePhWechatMini: '例如:我的小程序',
179
+ fCategory: '类型', formDetails: '凭据信息', moreFields: '更多字段', lessFields: '收起字段',
156
180
  fAccount: '账号 / 用户名', fAccountPh: 'user@example.com',
157
181
  fPassword: '密码', fPasswordPh: '输入密码',
158
182
  fUrl: '登录网址(可选)', fUrlPh: 'https://…',
@@ -162,10 +186,20 @@ window.__ModuleLoader__.load({
162
186
  fExpiry: '到期日期(可选)',
163
187
  fContent: '内容 / 密钥', fContentPh: '恢复码、许可证、证书、PIN…',
164
188
  fNotes: '备注(可选)', fNotesPh: '其他信息…',
189
+ fAppId: 'AppID', fAppIdPh: 'wx…',
190
+ fAppSecret: 'AppSecret', fAppSecretPh: '应用密钥',
191
+ fToken: '服务器 Token', fTokenPh: '服务器配置里的 Token',
192
+ fAesKey: 'EncodingAESKey', fAesKeyPh: '43 位消息加解密密钥',
193
+ fServerUrl: '服务器地址', fServerUrlPh: 'https://…(回调地址)',
194
+ fUploadKey: '代码上传密钥', fUploadKeyPh: '上传小程序代码用的私钥',
195
+ fDomains: '服务器域名', fDomainsPh: 'request / socket / upload / download 合法域名',
165
196
  catAccount: '账号密码', catApikey: 'API Key', catOther: '其他',
197
+ catWechatMp: '微信公众号', catWechatMini: '微信小程序',
166
198
  hintAccount: '用于保存网站 / 应用的登录账号与密码。',
167
199
  hintApikey: '用于保存平台签发的 API Key、令牌与接口地址。',
168
200
  hintOther: '用于保存恢复码、许可证、证书等任意文本。',
201
+ hintWechatMp: '用于保存公众号开发者凭证与服务器配置。',
202
+ hintWechatMini: '用于保存小程序开发者凭证与代码上传密钥。',
169
203
  save: '保存', cancel: '取消', required: '请输入名称',
170
204
  confirmDelete: '确定删除这条凭据?此操作不可撤销。',
171
205
  saved: '已保存', deleted: '已删除', revealAll: '全部显示', hideAll: '全部隐藏',
@@ -194,6 +228,8 @@ window.__ModuleLoader__.load({
194
228
  resetSubmit: '重置密码', resetFail: '密保答案不匹配。', resetDone: '密码已重置,请重新解锁。',
195
229
  resetUnavailable: '尚未设置密保问题。请从备份恢复,或清除此浏览器的站点数据。',
196
230
  lockIdle: '因长时间无操作已锁定',
231
+ auditTitle: '访问审计', auditDesc: '记录模型读取保险箱元数据的内存日志,不含任何密钥或明文,重启后清空。',
232
+ auditView: '查看日志', auditLoading: '加载中…', auditTotal: '事件总数', auditEmpty: '暂无访问记录。', auditFail: '访问审计不可用。',
197
233
  updateTitle: '插件更新', updateDesc: '检查凭据保险箱插件是否有新版本可用。',
198
234
  updateCurrent: '当前版本', updateLatest: '最新版本', updateCheck: '检查更新',
199
235
  updateChecking: '检查中…', updateAvailable: '发现新版本:', updateUpToDate: '已是最新版本。',
@@ -220,6 +256,14 @@ window.__ModuleLoader__.load({
220
256
  exportFormat: '导出格式', exportJson: 'JSON 备份', exportJsonHint: '完整保真,可精确恢复全部字段(推荐)。',
221
257
  exportCsv: 'CSV(Excel / WPS)', exportCsvHint: '中文表头、常用列在前,UTF-8 BOM 编码。',
222
258
  exportMd: 'Markdown 卡片', exportMdHint: '每条凭据一张卡片、中文标签,一目了然。',
259
+ exportEncrypted: '加密备份(密码保护)', exportEncryptedHint: '包含密钥的完整备份,用你设置的密码经 AES-GCM 加密。导入时需输入同一密码。',
260
+ exportEncryptedGo: '加密并下载', exportEncryptedDone: '加密备份已下载 — 请牢记密码,丢失后无法恢复。',
261
+ encPwHint: '请设置高强度密码。密码不会被存储 — 丢失后备份将无法恢复。',
262
+ encPw: '加密密码', encPw2: '确认密码', encPwShort: '密码至少 6 个字符。',
263
+ encPwMismatch: '两次输入的密码不一致。', encPwRequired: '请输入密码。',
264
+ encBusy: '处理中…', encNoCrypto: '当前浏览器不支持所需的加密功能(Web Crypto)。',
265
+ encDetected: '检测到加密备份', encImportHint: '输入导出时设置的密码以解密此备份。',
266
+ encUnlock: '解密', encWrongPw: '密码错误或文件已损坏。',
223
267
  genButton: '生成密码', genField: '为此字段生成密码',
224
268
  genTitle: '密码生成器', genHint: '使用浏览器的加密随机源生成高强度随机密码,不会存储或上传任何数据。',
225
269
  genLength: '长度', genUpper: '大写字母 (A–Z)', genLower: '小写字母 (a–z)', genDigits: '数字 (0–9)',
@@ -265,17 +309,40 @@ window.__ModuleLoader__.load({
265
309
  { key: 'title', label: 'fTitle', ph: 'fTitlePhOther', type: 'text', required: true },
266
310
  { key: 'content', label: 'fContent', ph: 'fContentPh', type: 'secretarea', mono: true },
267
311
  { key: 'notes', label: 'fNotes', ph: 'fNotesPh', type: 'textarea' }
312
+ ],
313
+ wechatMp: [
314
+ { key: 'title', label: 'fTitle', ph: 'fTitlePhWechatMp', type: 'text', required: true },
315
+ { key: 'appId', label: 'fAppId', ph: 'fAppIdPh', type: 'text', mono: true },
316
+ { key: 'appSecret', label: 'fAppSecret', ph: 'fAppSecretPh', type: 'secret', mono: true },
317
+ { key: 'token', label: 'fToken', ph: 'fTokenPh', type: 'secret', mono: true },
318
+ { key: 'encodingAesKey', label: 'fAesKey', ph: 'fAesKeyPh', type: 'secret', mono: true },
319
+ { key: 'serverUrl', label: 'fServerUrl', ph: 'fServerUrlPh', type: 'text', isUrl: true },
320
+ { key: 'notes', label: 'fNotes', ph: 'fNotesPh', type: 'textarea' }
321
+ ],
322
+ wechatMini: [
323
+ { key: 'title', label: 'fTitle', ph: 'fTitlePhWechatMini', type: 'text', required: true },
324
+ { key: 'appId', label: 'fAppId', ph: 'fAppIdPh', type: 'text', mono: true },
325
+ { key: 'appSecret', label: 'fAppSecret', ph: 'fAppSecretPh', type: 'secret', mono: true },
326
+ { key: 'uploadKey', label: 'fUploadKey', ph: 'fUploadKeyPh', type: 'secretarea', mono: true },
327
+ { key: 'domains', label: 'fDomains', ph: 'fDomainsPh', type: 'textarea' },
328
+ { key: 'notes', label: 'fNotes', ph: 'fNotesPh', type: 'textarea' }
268
329
  ]
269
330
  };
331
+ // "other" is always the LAST option — both in the type dropdown and in
332
+ // the filter chips. Keep it that way when adding new categories.
270
333
  var CATEGORIES = [
271
334
  { k: 'account', label: 'catAccount', hint: 'hintAccount' },
272
335
  { k: 'apikey', label: 'catApikey', hint: 'hintApikey' },
336
+ { k: 'wechatMp', label: 'catWechatMp', hint: 'hintWechatMp' },
337
+ { k: 'wechatMini', label: 'catWechatMini', hint: 'hintWechatMini' },
273
338
  { k: 'other', label: 'catOther', hint: 'hintOther' }
274
339
  ];
275
340
  var FILTERS = [
276
341
  { k: 'all', label: 'filterAll' },
277
342
  { k: 'account', label: 'filterAccount' },
278
343
  { k: 'apikey', label: 'filterApikey' },
344
+ { k: 'wechatMp', label: 'filterWechatMp' },
345
+ { k: 'wechatMini', label: 'filterWechatMini' },
279
346
  { k: 'other', label: 'filterOther' }
280
347
  ];
281
348
  function schemaOf(cat) { return SCHEMAS[cat] || SCHEMAS.account; }
@@ -285,7 +352,7 @@ window.__ModuleLoader__.load({
285
352
  var CSS = [
286
353
  '.cv-root{--cv-bg:var(--dsw-alias-bg-base,#fff);--cv-l1:var(--dsw-alias-bg-layer-1,#f6f7f9);--cv-l2:var(--dsw-alias-bg-layer-2,#eceef3);--cv-b1:var(--dsw-alias-border-l1,#e2e5eb);--cv-b2:var(--dsw-alias-border-l2,#c9cfd9);--cv-brand:var(--dsw-alias-brand-primary,#2563eb);--cv-t1:var(--dsw-alias-label-primary,#1d2129);--cv-t2:var(--dsw-alias-label-secondary,#6b7280);--cv-err:var(--dsw-alias-state-error-primary,#dc2626);--cv-ok:var(--dsw-alias-state-success-primary,#16a34a);color:var(--cv-t1);background:var(--cv-bg);font-family:inherit;font-size:14px;min-height:100%;box-sizing:border-box;position:relative}',
287
354
  '.cv-root *{box-sizing:border-box}',
288
- '.cv-wrap{max-width:940px;margin:0 auto;padding:28px 26px 60px}',
355
+ '.cv-wrap{max-width:90%;margin:0 auto;padding:28px 26px 60px}',
289
356
  '.cv-head{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}',
290
357
  '.cv-head-left{display:flex;align-items:center;gap:14px}',
291
358
  '.cv-head-icon{width:52px;height:52px;border-radius:14px;display:flex;align-items:center;justify-content:center;background:var(--cv-l1);border:1px solid var(--cv-b1)}',
@@ -339,6 +406,8 @@ window.__ModuleLoader__.load({
339
406
  '.cv-badge-apikey{background:var(--cv-brand);color:var(--cv-bg)}',
340
407
  '.cv-badge-account{color:var(--cv-brand)}',
341
408
  '.cv-badge-other{background:var(--cv-l2);color:var(--cv-t2)}',
409
+ '.cv-badge-wechatMp{background:#07c160;color:#fff}',
410
+ '.cv-badge-wechatMini{background:#10aec2;color:#fff}',
342
411
  '.cv-card-title{font-weight:600;font-size:14.5px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
343
412
  '.cv-card-actions{display:flex;gap:4px}',
344
413
  '.cv-icon-btn{width:28px;height:28px;border-radius:7px;border:1px solid transparent;background:transparent;color:var(--cv-t2);cursor:pointer;font-size:14px;line-height:1;display:flex;align-items:center;justify-content:center}',
@@ -356,9 +425,9 @@ window.__ModuleLoader__.load({
356
425
  '.cv-empty h3{margin:0 0 6px;color:var(--cv-t1);font-size:16px}',
357
426
  '.cv-empty p{margin:0;font-size:13px}',
358
427
  '.cv-modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.2);display:flex;align-items:flex-start;justify-content:center;z-index:9999;padding:20px}',
359
- '.cv-modal{position:sticky;top:50vh;transform:translateY(-50%);width:fit-content;max-width:500px;min-width:320px;max-height:90vh;overflow:auto;background:var(--cv-bg);border:1px solid var(--cv-b1);border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,.28);outline:none}',
360
- '.cv-modal.cv-modal-editor{min-width:500px;max-width:800px}',
361
- '.cv-settings .cv-modal{max-width:100%;min-width:0}',
428
+ '.cv-modal{position:sticky;top:50vh;transform:translateY(-50%);width:min(500px,92%);max-width:100%;min-width:0;max-height:90vh;overflow:auto;background:var(--cv-bg);border:1px solid var(--cv-b1);border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,.28);outline:none}',
429
+ '.cv-modal.cv-modal-editor{width:min(560px,96%);min-width:0}',
430
+ '.cv-settings .cv-modal{width:min(100%,800px);max-width:100%;min-width:0}',
362
431
  // Sidebar panel only: modals are positioned relative to the panel itself
363
432
  // (flex-centered inside .cv-root) — the settings-page sticky float is untouched.
364
433
  '.cv-panelroot>.cv-modal-backdrop{align-items:center}',
@@ -367,11 +436,20 @@ window.__ModuleLoader__.load({
367
436
  '.cv-modal-head h2{margin:0;font-size:17px;font-weight:650}',
368
437
  '.cv-modal-hint{margin:5px 22px 0;padding:8px 11px;border-radius:8px;background:var(--cv-l1);border:1px solid var(--cv-b1);color:var(--cv-t2);font-size:12px;line-height:1.5}',
369
438
  '.cv-modal-body{padding:14px 22px 6px;display:flex;flex-direction:column;gap:12px}',
370
- '.cv-form-row{display:flex;flex-direction:column;gap:5px}',
371
- '.cv-form-label{font-size:12px;color:var(--cv-t2)}',
372
- '.cv-input{width:100%;padding:9px 11px;border-radius:9px;border:1px solid var(--cv-b1);background:var(--cv-l1);color:var(--cv-t1);font-size:13px;outline:none;font-family:inherit}',
439
+ // Editor form: one field per row for a clean, roomy layout.
440
+ '.cv-form-body{display:grid;grid-template-columns:1fr;gap:16px;padding:20px 24px 12px}',
441
+ '.cv-form-body .cv-row-full{grid-column:1 / -1}',
442
+ '.cv-form-body .cv-form-row{gap:8px}',
443
+ '.cv-form-row{display:flex;flex-direction:column;gap:6px;min-width:0;max-width:100%}',
444
+ '.cv-form-label{font-size:12px;color:var(--cv-t2);font-weight:600;letter-spacing:.02em}',
445
+ '.cv-form-label .cv-req{color:var(--cv-err);margin-left:2px}',
446
+ '.cv-form-sep{grid-column:1 / -1;display:flex;align-items:center;gap:10px;margin:4px 0 0;color:var(--cv-t2);font-size:11px;font-weight:650;letter-spacing:.08em;text-transform:uppercase}',
447
+ '.cv-form-sep:after{content:"";flex:1;height:1px;background:var(--cv-b1)}',
448
+ '.cv-more-btn{grid-column:1 / -1;align-self:start;display:inline-flex;align-items:center;gap:5px;padding:6px 10px;border:1px dashed var(--cv-b2);border-radius:8px;background:transparent;color:var(--cv-t2);font-size:12px;font-family:inherit;cursor:pointer}',
449
+ '.cv-more-btn:hover{border-color:var(--cv-brand);color:var(--cv-brand)}',
450
+ '.cv-input{width:100%;max-width:100%;min-width:0;padding:9px 11px;border-radius:9px;border:1px solid var(--cv-b1);background:var(--cv-l1);color:var(--cv-t1);font-size:13px;outline:none;font-family:inherit;box-sizing:border-box}',
373
451
  '.cv-input:focus{border-color:var(--cv-brand)}',
374
- '.cv-textarea{min-height:64px;resize:vertical}',
452
+ '.cv-textarea{min-height:64px;max-width:100%;resize:vertical;overflow-wrap:anywhere}',
375
453
  '.cv-secret-input{display:flex;gap:6px;align-items:stretch}',
376
454
  '.cv-secret-input .cv-input{flex:1;min-width:0}',
377
455
  '.cv-secret-toggle{flex:none;display:inline-flex;align-items:center;justify-content:center;padding:0 13px;border:1px solid var(--cv-b1);border-radius:9px;background:var(--cv-l1);color:var(--cv-t2);font-size:13px;font-family:inherit;cursor:pointer;white-space:nowrap}',
@@ -392,7 +470,7 @@ window.__ModuleLoader__.load({
392
470
  '.cv-link{background:none;border:none;padding:0;color:var(--cv-brand);font-size:12.5px;cursor:pointer;text-decoration:underline;font-family:inherit}',
393
471
  '.cv-link:hover{opacity:.8}',
394
472
  '.cv-lock-foot{margin-top:16px;color:var(--cv-t2);font-size:11px;line-height:1.5}',
395
- '.cv-settings{max-width:820px;margin:0 auto;padding:28px 26px 60px;position:relative}',
473
+ '.cv-settings{max-width:90%;margin:0 auto;padding:28px 26px 60px;position:relative}',
396
474
  '.cv-settings-head{margin-bottom:8px}',
397
475
  '.cv-settings-head h2{margin:0;font-size:18px;font-weight:650}',
398
476
  '.cv-settings-head p{margin:5px 0 0;color:var(--cv-t2);font-size:13px;line-height:1.5}',
@@ -404,6 +482,11 @@ window.__ModuleLoader__.load({
404
482
  '.cv-upgrade-status{margin-top:10px;font-size:12.5px;color:var(--cv-t2);line-height:1.6}',
405
483
  '.cv-upgrade-status.cv-ok{color:var(--cv-ok)}',
406
484
  '.cv-upgrade-status.cv-err{color:var(--cv-err)}',
485
+ '.cv-audit-list{margin-top:10px;max-height:220px;overflow:auto;border:1px solid var(--cv-b1);border-radius:8px}',
486
+ '.cv-audit-row{display:flex;gap:10px;padding:7px 10px;border-bottom:1px solid var(--cv-b1);font-size:12px;line-height:1.4}',
487
+ '.cv-audit-row:last-child{border-bottom:0}',
488
+ '.cv-audit-time{color:var(--cv-t2);white-space:nowrap;font-variant-numeric:tabular-nums}',
489
+ '.cv-audit-detail{color:var(--cv-t1);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
407
490
  '.cv-switch-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 0;border-top:1px solid var(--cv-b1)}',
408
491
  '.cv-switch-row:first-of-type{border-top:none}',
409
492
  '.cv-switch-label{font-size:13.5px;font-weight:550}',
@@ -418,6 +501,7 @@ window.__ModuleLoader__.load({
418
501
  '.cv-note-err{background:rgba(239,68,68,.12);color:var(--cv-err);border:1px solid rgba(239,68,68,.4)}',
419
502
  '@keyframes cv-note-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}',
420
503
  '.cv-field-error{color:var(--cv-err);font-size:12px;margin-top:2px}',
504
+ '.cv-enc-fields{display:flex;flex-direction:column;gap:8px;margin:14px 22px 4px;padding:13px;border-radius:9px;background:var(--cv-l1);border:1px solid var(--cv-b1)}',
421
505
  '.cv-settings-fields{display:flex;flex-direction:column;gap:12px;margin-top:12px}',
422
506
  // Password generator
423
507
  '.cv-gen-secret{display:flex;gap:6px;align-items:stretch}',
@@ -486,11 +570,28 @@ window.__ModuleLoader__.load({
486
570
  try { window.localStorage.setItem(STORAGE_KEY, JSON.stringify(arr)); } catch (e) {}
487
571
  syncToHost(arr);
488
572
  }
489
- // Mirror the vault to the Host so the Harness/Agent can read it via the
490
- // dsh_credential_vault_read tool. Fire-and-forget: the browser stays usable
491
- // even if the Host route is unavailable; localStorage is still authoritative.
573
+ // Mirror only METADATA to the Host so the Harness/Agent can discover which
574
+ // credentials exist via dsh_credential_vault_read. Plaintext secrets stay in
575
+ // this browser's localStorage and are NEVER sent to the Host process. The
576
+ // Host independently re-sanitizes every entry, so this is defense in depth.
577
+ // Fire-and-forget: the browser stays usable even if the Host route is down.
492
578
  // Large vaults: DEBOUNCE so a burst of edits results in one POST, not dozens
493
579
  // of multi-megabyte payloads. A trailing timer always flushes the latest data.
580
+ var MIRROR_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'url', 'endpoint', 'expiry',
581
+ 'appId', 'serverUrl', 'domains', 'notes', 'createdAt', 'updatedAt'];
582
+ var MIRROR_SECRETS = ['password', 'apiKey', 'content', 'appSecret', 'token', 'encodingAesKey', 'uploadKey'];
583
+ function toEnvelope(entry) {
584
+ var out = {};
585
+ MIRROR_FIELDS.forEach(function (k) {
586
+ var v = entry[k];
587
+ if (typeof v === 'string' || typeof v === 'number') out[k] = v;
588
+ });
589
+ // Placeholder only — the real value never leaves this browser.
590
+ MIRROR_SECRETS.forEach(function (k) {
591
+ if (typeof entry[k] === 'string' && entry[k] !== '') out[k] = MASK;
592
+ });
593
+ return out;
594
+ }
494
595
  var syncTimer = null;
495
596
  var SYNC_DELAY = 400;
496
597
  function syncToHost(arr, immediate) {
@@ -498,11 +599,12 @@ window.__ModuleLoader__.load({
498
599
  function send() {
499
600
  syncTimer = null;
500
601
  try {
602
+ var envelope = arr.map(toEnvelope);
501
603
  window.fetch(API + 'entries', {
502
604
  method: 'POST',
503
605
  credentials: 'same-origin',
504
606
  headers: { 'content-type': 'application/json', accept: 'application/json' },
505
- body: JSON.stringify({ entries: arr })
607
+ body: JSON.stringify({ entries: envelope })
506
608
  }).catch(function () {});
507
609
  } catch (e) {}
508
610
  }
@@ -652,7 +754,9 @@ window.__ModuleLoader__.load({
652
754
  function pad(n) { return n < 10 ? '0' + n : '' + n; }
653
755
  return d.getFullYear() + pad(d.getMonth() + 1) + pad(d.getDate()) + '-' + pad(d.getHours()) + pad(d.getMinutes());
654
756
  }
655
- var EXPORT_COLS = ['id', 'title', 'category', 'username', 'password', 'url', 'provider', 'apiKey', 'endpoint', 'expiry', 'content', 'notes', 'createdAt', 'updatedAt'];
757
+ var EXPORT_COLS = ['id', 'title', 'category', 'username', 'password', 'url', 'provider', 'apiKey', 'endpoint', 'expiry', 'content',
758
+ 'appId', 'appSecret', 'token', 'encodingAesKey', 'serverUrl', 'uploadKey', 'domains',
759
+ 'notes', 'createdAt', 'updatedAt'];
656
760
 
657
761
  // ---- Human-readable labels ------------------------------------------------
658
762
  // CSV/Markdown use Chinese labels for people; every label maps back to its
@@ -660,11 +764,14 @@ window.__ModuleLoader__.load({
660
764
  var FIELD_LABELS = {
661
765
  id: 'ID', title: '标题', category: '类型', username: '用户名', password: '密码',
662
766
  url: '网址', provider: '服务商', apiKey: 'API Key', endpoint: '接口地址',
663
- expiry: '有效期', content: '内容', notes: '备注', createdAt: '创建时间', updatedAt: '更新时间'
767
+ expiry: '有效期', content: '内容',
768
+ appId: 'AppID', appSecret: 'AppSecret', token: '服务器Token', encodingAesKey: 'EncodingAESKey',
769
+ serverUrl: '服务器地址', uploadKey: '代码上传密钥', domains: '服务器域名',
770
+ notes: '备注', createdAt: '创建时间', updatedAt: '更新时间'
664
771
  };
665
772
  var LABEL_FIELDS = {};
666
773
  Object.keys(FIELD_LABELS).forEach(function (k) { LABEL_FIELDS[FIELD_LABELS[k]] = k; });
667
- var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', other: '其他' };
774
+ var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', other: '其他', wechatMp: '微信公众号', wechatMini: '微信小程序' };
668
775
  var LABEL_CATEGORIES = {};
669
776
  Object.keys(CATEGORY_LABELS).forEach(function (k) { LABEL_CATEGORIES[CATEGORY_LABELS[k]] = k; });
670
777
  // Only export fields that belong to the entry's type. A record may carry
@@ -673,7 +780,9 @@ window.__ModuleLoader__.load({
673
780
  var VISIBLE_FIELDS = {
674
781
  account: ['title', 'username', 'password', 'url', 'notes'],
675
782
  apikey: ['title', 'provider', 'apiKey', 'endpoint', 'expiry', 'notes'],
676
- other: ['title', 'content', 'notes']
783
+ other: ['title', 'content', 'notes'],
784
+ wechatMp: ['title', 'appId', 'appSecret', 'token', 'encodingAesKey', 'serverUrl', 'notes'],
785
+ wechatMini: ['title', 'appId', 'appSecret', 'uploadKey', 'domains', 'notes']
677
786
  };
678
787
  function fieldsFor(cat) { return VISIBLE_FIELDS[cat] || VISIBLE_FIELDS.account; }
679
788
  // Strip fields that do not belong to the entry's type. Applied inside
@@ -703,7 +812,9 @@ window.__ModuleLoader__.load({
703
812
  // CSV shows the fields people actually read first; technical columns
704
813
  // (ID / timestamps) go last. Import maps by header label, so order is safe.
705
814
  var CSV_COLS = ['title', 'category', 'username', 'password', 'url', 'provider',
706
- 'apiKey', 'endpoint', 'expiry', 'content', 'notes', 'id', 'createdAt', 'updatedAt'];
815
+ 'apiKey', 'endpoint', 'expiry', 'content',
816
+ 'appId', 'appSecret', 'token', 'encodingAesKey', 'serverUrl', 'uploadKey', 'domains',
817
+ 'notes', 'id', 'createdAt', 'updatedAt'];
707
818
  function buildCsv(arr) {
708
819
  var lines = [CSV_COLS.map(function (c) { return csvEscape(FIELD_LABELS[c] || c); }).join(',')];
709
820
  arr.forEach(function (e) {
@@ -926,16 +1037,113 @@ window.__ModuleLoader__.load({
926
1037
  if (fmt === 'md') return downloadText(buildMarkdown(arr), 'text/markdown;charset=utf-8', '凭据保险箱-' + stampNow() + '.md');
927
1038
  return exportBackup(arr);
928
1039
  }
1040
+ // Encrypted export: full backup (secrets included) sealed with a password.
1041
+ // Async because key derivation is Web Crypto. Resolves true on download.
1042
+ function exportEncrypted(arr, password) {
1043
+ if (!arr || arr.length === 0) return Promise.resolve(false);
1044
+ return encryptBackup(arr, password).then(function (envelope) {
1045
+ return downloadText(JSON.stringify(envelope, null, 2), 'application/json;charset=utf-8',
1046
+ '凭据保险箱-加密-' + stampNow() + '.vault.json');
1047
+ });
1048
+ }
929
1049
  // Returns entries array or throws a recognisable error (JSON backups only).
930
1050
  function parseBackup(text) {
931
1051
  var data;
932
1052
  try { data = JSON.parse(text); } catch (e) { throw new Error('parse'); }
1053
+ // An encrypted envelope is not a plain backup — surface a clear signal so
1054
+ // the import UI can prompt for the password instead of treating it as data.
1055
+ if (data && data.format === ENC_FORMAT) throw new Error('ENCRYPTED');
933
1056
  var arr = null;
934
1057
  if (data && Array.isArray(data.entries)) arr = data.entries;
935
1058
  else if (Array.isArray(data)) arr = data; // tolerate a bare array
936
1059
  if (!arr) throw new Error('shape');
937
1060
  return arr.filter(function (e) { return e && typeof e === 'object'; }).map(normalize);
938
1061
  }
1062
+
1063
+ // ---- Encrypted backup (PBKDF2 + AES-GCM, Web Crypto) ------------------
1064
+ // The whole plaintext backup (secrets included) is encrypted with a key
1065
+ // derived from a user-supplied password. Nothing about the password or the
1066
+ // plaintext is stored in this file; losing the password means losing the
1067
+ // backup. Uses only platform Web Crypto — no third-party libraries.
1068
+ var ENC_FORMAT = 'dsh-credential-vault-encrypted';
1069
+ var ENC_VERSION = 1;
1070
+ var KDF_ITERATIONS = 210000;
1071
+ function bytesToB64(bytes) {
1072
+ var out = '';
1073
+ var chunk = 0x8000;
1074
+ for (var i = 0; i < bytes.length; i += chunk) {
1075
+ var part = Array.prototype.slice.call(bytes, i, Math.min(i + chunk, bytes.length));
1076
+ out += String.fromCharCode.apply(null, part);
1077
+ }
1078
+ return btoa(out);
1079
+ }
1080
+ function b64ToBytes(b64) {
1081
+ var s = atob(String(b64));
1082
+ var out = new Uint8Array(s.length);
1083
+ for (var i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);
1084
+ return out;
1085
+ }
1086
+ function deriveEncKey(password, salt, iterations) {
1087
+ var subtle = window.crypto && window.crypto.subtle;
1088
+ if (!subtle) return Promise.reject(new Error('NO_CRYPTO'));
1089
+ var enc = new TextEncoder();
1090
+ return subtle.importKey('raw', enc.encode(String(password)), 'PBKDF2', false, ['deriveKey'])
1091
+ .then(function (baseKey) {
1092
+ return subtle.deriveKey(
1093
+ { name: 'PBKDF2', salt: salt, iterations: iterations, hash: 'SHA-256' },
1094
+ baseKey,
1095
+ { name: 'AES-GCM', length: 256 },
1096
+ false,
1097
+ ['encrypt', 'decrypt']
1098
+ );
1099
+ });
1100
+ }
1101
+ // Resolve to a JSON-serialisable encrypted envelope.
1102
+ function encryptBackup(arr, password) {
1103
+ if (!password || !String(password)) return Promise.reject(new Error('EMPTY_PASSWORD'));
1104
+ var subtle = window.crypto && window.crypto.subtle;
1105
+ if (!subtle || !window.crypto.getRandomValues) return Promise.reject(new Error('NO_CRYPTO'));
1106
+ var plaintext = JSON.stringify(buildBackup(arr));
1107
+ var salt = new Uint8Array(16), iv = new Uint8Array(12);
1108
+ window.crypto.getRandomValues(salt);
1109
+ window.crypto.getRandomValues(iv);
1110
+ return deriveEncKey(password, salt, KDF_ITERATIONS).then(function (key) {
1111
+ return subtle.encrypt({ name: 'AES-GCM', iv: iv }, key, new TextEncoder().encode(plaintext));
1112
+ }).then(function (buf) {
1113
+ return {
1114
+ format: ENC_FORMAT, version: ENC_VERSION, kdf: 'PBKDF2-SHA256',
1115
+ iterations: KDF_ITERATIONS,
1116
+ salt: bytesToB64(salt), iv: bytesToB64(iv), cipherText: bytesToB64(new Uint8Array(buf))
1117
+ };
1118
+ });
1119
+ }
1120
+ // Resolve to an entries array (decrypted + normalised), or reject with a
1121
+ // recognisable error: WRONG_PASSWORD / NOT_ENCRYPTED / NO_CRYPTO.
1122
+ function decryptBackup(envelope, password) {
1123
+ if (!envelope || envelope.format !== ENC_FORMAT) return Promise.reject(new Error('NOT_ENCRYPTED'));
1124
+ if (!password || !String(password)) return Promise.reject(new Error('EMPTY_PASSWORD'));
1125
+ var subtle = window.crypto && window.crypto.subtle;
1126
+ if (!subtle) return Promise.reject(new Error('NO_CRYPTO'));
1127
+ var salt = b64ToBytes(envelope.salt), iv = b64ToBytes(envelope.iv);
1128
+ var cipher = b64ToBytes(envelope.cipherText);
1129
+ var iterations = envelope.iterations || KDF_ITERATIONS;
1130
+ return deriveEncKey(password, salt, iterations).then(function (key) {
1131
+ return subtle.decrypt({ name: 'AES-GCM', iv: iv }, key, cipher);
1132
+ }).then(function (buf) {
1133
+ return parseBackup(new TextDecoder().decode(buf));
1134
+ }).catch(function (e) {
1135
+ if (e && (e.message === 'NOT_ENCRYPTED' || e.message === 'EMPTY_PASSWORD' || e.message === 'NO_CRYPTO')) throw e;
1136
+ throw new Error('WRONG_PASSWORD');
1137
+ });
1138
+ }
1139
+ // Detect an encrypted envelope in raw imported text. Returns the envelope
1140
+ // object or null.
1141
+ function detectEncrypted(text) {
1142
+ try {
1143
+ var data = JSON.parse(String(text || '').replace(/^\uFEFF/, ''));
1144
+ return data && data.format === ENC_FORMAT ? data : null;
1145
+ } catch (e) { return null; }
1146
+ }
939
1147
  // ---- Access-password security store ---------------------------------
940
1148
  var SEC_KEY = '@local/dsh-credential-vault:security:v1';
941
1149
  var SEC_KEY_LEGACY = '@local/credential-vault:security:v1';
@@ -1069,7 +1277,9 @@ window.__ModuleLoader__.load({
1069
1277
  id: '', title: '', category: cat || 'account',
1070
1278
  username: '', password: '', url: '',
1071
1279
  provider: '', apiKey: '', endpoint: '', expiry: '',
1072
- content: '', notes: ''
1280
+ content: '',
1281
+ appId: '', appSecret: '', token: '', encodingAesKey: '', serverUrl: '', uploadKey: '', domains: '',
1282
+ notes: ''
1073
1283
  };
1074
1284
  }
1075
1285
 
@@ -1132,7 +1342,8 @@ window.__ModuleLoader__.load({
1132
1342
  function Card(props) {
1133
1343
  var e = props.entry, t = props.t;
1134
1344
  var cat = e.category || 'account';
1135
- var catLabel = cat === 'apikey' ? t('catApikey') : (cat === 'other' ? t('catOther') : t('catAccount'));
1345
+ var catMeta = CATEGORIES.filter(function (c) { return c.k === cat; })[0];
1346
+ var catLabel = catMeta ? t(catMeta.label) : t('catAccount');
1136
1347
  return h('div', { className: 'cv-card' },
1137
1348
  h('div', { className: 'cv-card-head' },
1138
1349
  h('span', { className: 'cv-badge cv-badge-' + cat }, catLabel),
@@ -1162,6 +1373,14 @@ window.__ModuleLoader__.load({
1162
1373
  var meta = CATEGORIES.filter(function (c) { return c.k === cat; })[0] || CATEGORIES[0];
1163
1374
  var fields = schemaOf(cat);
1164
1375
 
1376
+ // Only the essential fields show by default; the rest fold behind a
1377
+ // "More fields" toggle so short forms stay short and long forms compact.
1378
+ var PRIMARY_KEYS = { title: 1, username: 1, password: 1, apiKey: 1, appId: 1, appSecret: 1, content: 1 };
1379
+ var primary = fields.filter(function (f) { return PRIMARY_KEYS[f.key]; });
1380
+ var secondary = fields.filter(function (f) { return !PRIMARY_KEYS[f.key]; });
1381
+ var hasSecondary = secondary.some(function (f) { return !!d[f.key]; });
1382
+ var moreState = useState(hasSecondary), showMore = moreState[0], setShowMore = moreState[1];
1383
+
1165
1384
  function baseInput(f, extra) {
1166
1385
  return Object.assign({
1167
1386
  className: 'cv-input', value: d[f.key] || '',
@@ -1170,6 +1389,9 @@ window.__ModuleLoader__.load({
1170
1389
  onChange: function (ev) { onChange(f.key, ev.target.value); }
1171
1390
  }, extra || {});
1172
1391
  }
1392
+ // Multiline fields and long values get a full row; everything else pairs up.
1393
+ var WIDE_KEYS = { content: 1, notes: 1, endpoint: 1, serverUrl: 1, uploadKey: 1, domains: 1, encodingAesKey: 1 };
1394
+ function isWide(f) { return f.type === 'textarea' || f.type === 'secretarea' || !!WIDE_KEYS[f.key]; }
1173
1395
  function renderField(f) {
1174
1396
  var control;
1175
1397
  if (f.type === 'text' || f.type === 'date') {
@@ -1192,8 +1414,8 @@ window.__ModuleLoader__.load({
1192
1414
  h('button', { type: 'button', className: 'cv-secret-toggle', onClick: function () { setShowSecret(!showSecret); } }, showSecret ? t('hide') : t('show'))
1193
1415
  );
1194
1416
  }
1195
- return h('label', { key: f.key, className: 'cv-form-row' },
1196
- h('span', { className: 'cv-form-label' }, t(f.label)),
1417
+ return h('label', { key: f.key, className: 'cv-form-row' + (isWide(f) ? ' cv-row-full' : '') },
1418
+ h('span', { className: 'cv-form-label' }, t(f.label), f.required ? h('span', { className: 'cv-req' }, '*') : null),
1197
1419
  control
1198
1420
  );
1199
1421
  }
@@ -1205,14 +1427,24 @@ window.__ModuleLoader__.load({
1205
1427
  },
1206
1428
  h('div', { className: 'cv-modal-head' }, h('h2', null, t(props.titleKey) + ' · ' + t(meta.label))),
1207
1429
  h('div', { className: 'cv-modal-hint' }, t(meta.hint)),
1208
- h('div', { className: 'cv-modal-body' },
1209
- h('label', { className: 'cv-form-row' },
1430
+ h('div', { className: 'cv-form-body' },
1431
+ h('label', { className: 'cv-form-row cv-row-full' },
1210
1432
  h('span', { className: 'cv-form-label' }, t('fCategory')),
1211
1433
  h('select', { className: 'cv-input', value: cat, onChange: function (ev) { onChange('category', ev.target.value); } },
1212
1434
  CATEGORIES.map(function (c) { return h('option', { key: c.k, value: c.k }, t(c.label)); })
1213
1435
  )
1214
1436
  ),
1215
- fields.map(renderField)
1437
+ h('div', { className: 'cv-form-sep' }, t('formDetails')),
1438
+ primary.map(renderField),
1439
+ secondary.length ? (showMore ? secondary.map(renderField) : null) : null,
1440
+ secondary.length && !showMore ? h('button', {
1441
+ type: 'button', className: 'cv-more-btn',
1442
+ onClick: function () { setShowMore(true); }
1443
+ }, '▾ ' + t('moreFields') + ' (' + secondary.length + ')') : null,
1444
+ secondary.length && showMore ? h('button', {
1445
+ type: 'button', className: 'cv-more-btn',
1446
+ onClick: function () { setShowMore(false); }
1447
+ }, '▴ ' + t('lessFields')) : null
1216
1448
  ),
1217
1449
  h('div', { className: 'cv-modal-foot' },
1218
1450
  h('button', { className: 'cv-btn', onClick: props.onCancel }, t('cancel')),
@@ -1323,17 +1555,23 @@ window.__ModuleLoader__.load({
1323
1555
  var errState = useState(''), err = errState[0], setErr = errState[1];
1324
1556
  var inputRef = useState({})[0];
1325
1557
  var detectedState = useState(''), detected = detectedState[0], setDetected = detectedState[1];
1558
+ var encState = useState(null), encEnv = encState[0], setEncEnv = encState[1];
1559
+ var encPwState = useState(''), encPw = encPwState[0], setEncPw = encPwState[1];
1560
+ var encBusyState = useState(false), encBusy = encBusyState[0], setEncBusy = encBusyState[1];
1326
1561
 
1327
1562
  function onFile(ev) {
1328
1563
  var f = ev.target.files && ev.target.files[0];
1329
1564
  if (!f) return;
1330
- setErr(''); setPending(null); setDetected('');
1565
+ setErr(''); setPending(null); setDetected(''); setEncEnv(null); setEncPw('');
1331
1566
  setFileInfo({ name: f.name, size: f.size });
1332
1567
  if (typeof FileReader === 'undefined') { setErr(t('importInvalid')); return; }
1333
1568
  var reader = new FileReader();
1334
1569
  reader.onload = function () {
1570
+ var text = String(reader.result || '');
1571
+ var env = detectEncrypted(text);
1572
+ if (env) { setEncEnv(env); setDetected('enc'); return; }
1335
1573
  try {
1336
- var res = parseImport(String(reader.result || ''));
1574
+ var res = parseImport(text);
1337
1575
  setPending(res.entries);
1338
1576
  setDetected(res.fmt);
1339
1577
  if (res.entries.length === 0) setErr(t('importEmpty'));
@@ -1342,6 +1580,20 @@ window.__ModuleLoader__.load({
1342
1580
  reader.onerror = function () { setErr(t('importInvalid')); setPending(null); };
1343
1581
  reader.readAsText(f, 'utf-8');
1344
1582
  }
1583
+ function decrypt() {
1584
+ if (!encEnv) return;
1585
+ if (!encPw) { setErr(t('encPwRequired')); return; }
1586
+ setErr(''); setEncBusy(true);
1587
+ decryptBackup(encEnv, encPw).then(function (arr) {
1588
+ setEncBusy(false);
1589
+ setPending(arr); setEncEnv(null); setEncPw(''); setDetected('json');
1590
+ if (arr.length === 0) setErr(t('importEmpty'));
1591
+ }).catch(function (e) {
1592
+ setEncBusy(false);
1593
+ var m = e && e.message;
1594
+ setErr(m === 'WRONG_PASSWORD' ? t('encWrongPw') : m === 'NO_CRYPTO' ? t('encNoCrypto') : t('importInvalid'));
1595
+ });
1596
+ }
1345
1597
  function submit() {
1346
1598
  if (!pending || pending.length === 0) { setErr(t('importEmpty')); return; }
1347
1599
  props.onImport(pending, mode);
@@ -1360,10 +1612,17 @@ window.__ModuleLoader__.load({
1360
1612
  h('button', { type: 'button', className: 'cv-btn', onClick: function () { if (inputRef.el) inputRef.el.click(); } },
1361
1613
  fileInfo ? '📄 ' + fileInfo.name : t('import')),
1362
1614
  fileInfo ? h('div', { className: 'cv-import-file' },
1363
- t('importFound') + ':' + (pending ? pending.length : '…') +
1364
- (detected ? ' · ' + t('importDetected') + ':' + t('fmt' + detected.charAt(0).toUpperCase() + detected.slice(1)) : '')) : null,
1365
- h('div', { className: 'cv-form-label' }, t('importMode')),
1366
- h('div', { className: 'cv-import-modes' },
1615
+ encEnv ? t('encDetected')
1616
+ : t('importFound') + ':' + (pending ? pending.length : '…') +
1617
+ (detected ? ' · ' + t('importDetected') + ':' + t('fmt' + detected.charAt(0).toUpperCase() + detected.slice(1)) : '')) : null,
1618
+ encEnv ? h('div', { className: 'cv-enc-fields' },
1619
+ h('div', { className: 'cv-card-sub' }, t('encImportHint')),
1620
+ h('input', { type: 'password', className: 'cv-input', placeholder: t('encPw'), value: encPw, autoComplete: 'off',
1621
+ onChange: function (e) { setEncPw(e.target.value); },
1622
+ onKeyDown: function (e) { if (e.key === 'Enter') decrypt(); } })
1623
+ ) : null,
1624
+ encEnv ? null : h('div', { className: 'cv-form-label' }, t('importMode')),
1625
+ encEnv ? null : h('div', { className: 'cv-import-modes' },
1367
1626
  h('label', { className: 'cv-import-opt' },
1368
1627
  h('input', { type: 'radio', name: 'cv-import-mode', checked: mode === 'merge', onChange: function () { setMode('merge'); } }),
1369
1628
  h('div', null,
@@ -1383,7 +1642,9 @@ window.__ModuleLoader__.load({
1383
1642
  ),
1384
1643
  h('div', { className: 'cv-modal-foot' },
1385
1644
  h('button', { className: 'cv-btn', onClick: props.onCancel }, t('cancel')),
1386
- h('button', { className: 'cv-btn cv-btn-primary', disabled: !pending || pending.length === 0, onClick: submit }, t('importConfirm'))
1645
+ encEnv
1646
+ ? h('button', { className: 'cv-btn cv-btn-primary', disabled: encBusy, onClick: decrypt }, encBusy ? t('encBusy') : t('encUnlock'))
1647
+ : h('button', { className: 'cv-btn cv-btn-primary', disabled: !pending || pending.length === 0, onClick: submit }, t('importConfirm'))
1387
1648
  )
1388
1649
  )
1389
1650
  );
@@ -1391,11 +1652,34 @@ window.__ModuleLoader__.load({
1391
1652
 
1392
1653
  function ExportModal(props) {
1393
1654
  var t = props.t;
1655
+ var encState = useState(false), enc = encState[0], setEnc = encState[1];
1656
+ var pwState = useState(''), pw = pwState[0], setPw = pwState[1];
1657
+ var pw2State = useState(''), pw2 = pw2State[0], setPw2 = pw2State[1];
1658
+ var errState = useState(''), err = errState[0], setErr = errState[1];
1659
+ var busyState = useState(false), busy = busyState[0], setBusy = busyState[1];
1394
1660
  var fmts = [
1661
+ { k: 'enc', name: 'exportEncrypted', hint: 'exportEncryptedHint', icon: '🔐' },
1395
1662
  { k: 'json', name: 'exportJson', hint: 'exportJsonHint', icon: '📦' },
1396
1663
  { k: 'csv', name: 'exportCsv', hint: 'exportCsvHint', icon: '📊' },
1397
1664
  { k: 'md', name: 'exportMd', hint: 'exportMdHint', icon: '📝' }
1398
1665
  ];
1666
+ function pick(f) {
1667
+ if (f.k !== 'enc') { props.onPick(f.k); return; }
1668
+ setErr(''); setEnc(true);
1669
+ }
1670
+ function doEncrypted() {
1671
+ if (!pw || pw.length < 6) { setErr(t('encPwShort')); return; }
1672
+ if (pw !== pw2) { setErr(t('encPwMismatch')); return; }
1673
+ setErr(''); setBusy(true);
1674
+ props.onEncrypted(pw).then(function (ok) {
1675
+ setBusy(false);
1676
+ if (ok) { setPw(''); setPw2(''); props.onDone(); }
1677
+ else setErr(t('exportFail'));
1678
+ }).catch(function (e) {
1679
+ setBusy(false);
1680
+ setErr(e && e.message === 'NO_CRYPTO' ? t('encNoCrypto') : t('exportFail'));
1681
+ });
1682
+ }
1399
1683
  return h('div', { className: 'cv-modal-backdrop', onMouseDown: function (e) { if (e.target === e.currentTarget) props.onCancel(); } },
1400
1684
  h('div', { className: 'cv-modal', role: 'dialog', 'aria-modal': 'true', 'aria-label': t('exportTitle'), tabIndex: -1,
1401
1685
  onKeyDown: function (e) { if (e.key === 'Escape') props.onCancel(); } },
@@ -1404,17 +1688,24 @@ window.__ModuleLoader__.load({
1404
1688
  h('div', { className: 'cv-modal-body' },
1405
1689
  h('div', { className: 'cv-form-label' }, t('exportFormat')),
1406
1690
  h('div', { className: 'cv-import-modes' }, fmts.map(function (f) {
1407
- return h('button', { type: 'button', key: f.k, className: 'cv-import-opt cv-export-opt', onClick: function () { props.onPick(f.k); } },
1691
+ return h('button', { type: 'button', key: f.k, className: 'cv-import-opt cv-export-opt', onClick: function () { pick(f); } },
1408
1692
  h('span', { className: 'cv-export-icon' }, f.icon),
1409
1693
  h('div', null,
1410
1694
  h('div', { className: 'cv-import-opt-name' }, t(f.name)),
1411
1695
  h('div', { className: 'cv-import-opt-hint' }, t(f.hint))
1412
1696
  )
1413
1697
  );
1414
- }))
1698
+ })),
1699
+ enc ? h('div', { className: 'cv-enc-fields' },
1700
+ h('div', { className: 'cv-card-sub' }, t('encPwHint')),
1701
+ h('input', { type: 'password', className: 'cv-input', placeholder: t('encPw'), value: pw, autoComplete: 'new-password', onChange: function (e) { setPw(e.target.value); } }),
1702
+ h('input', { type: 'password', className: 'cv-input', placeholder: t('encPw2'), value: pw2, autoComplete: 'new-password', onChange: function (e) { setPw2(e.target.value); } })
1703
+ ) : null,
1704
+ err ? h('div', { className: 'cv-field-error', role: 'alert' }, err) : null
1415
1705
  ),
1416
1706
  h('div', { className: 'cv-modal-foot' },
1417
- h('button', { className: 'cv-btn', onClick: props.onCancel }, t('cancel'))
1707
+ h('button', { className: 'cv-btn', onClick: props.onCancel }, t('cancel')),
1708
+ enc ? h('button', { className: 'cv-btn cv-btn-primary', disabled: busy, onClick: doEncrypted }, busy ? t('encBusy') : t('exportEncryptedGo')) : null
1418
1709
  )
1419
1710
  )
1420
1711
  );
@@ -1485,6 +1776,8 @@ window.__ModuleLoader__.load({
1485
1776
  var upgradingState = useState(false), upgrading = upgradingState[0], setUpgrading = upgradingState[1];
1486
1777
  var upgradeMsgState = useState(null), upgradeMsg = upgradeMsgState[0], setUpgradeMsg = upgradeMsgState[1];
1487
1778
  var upgradeConfirmState = useState(null), upgradeConfirmDlg = upgradeConfirmState[0], setUpgradeConfirmDlg = upgradeConfirmState[1];
1779
+ var auditState = useState(null), auditData = auditState[0], setAudit = auditState[1];
1780
+ var auditLoadingState = useState(false), auditLoading = auditLoadingState[0], setAuditLoading = auditLoadingState[1];
1488
1781
  var pollRef = useRef(null);
1489
1782
  // Inline card messages: shown inside the settings card where the action
1490
1783
  // happened, so feedback lands exactly where the user is looking.
@@ -1499,6 +1792,15 @@ window.__ModuleLoader__.load({
1499
1792
  return function () { if (pollRef.current) { clearTimeout(pollRef.current); pollRef.current = null; } };
1500
1793
  }, []);
1501
1794
 
1795
+ function fetchAudit() {
1796
+ if (auditLoading) return;
1797
+ setAuditLoading(true);
1798
+ window.fetch(API + 'audit', { credentials: 'same-origin', headers: { accept: 'application/json' } })
1799
+ .then(function (r) { return r.json(); })
1800
+ .then(function (body) { setAudit(body && body.ok === true ? body : { ok: false, events: [], total: 0 }); })
1801
+ .catch(function () { setAudit({ ok: false, events: [], total: 0 }); })
1802
+ .then(function () { setAuditLoading(false); });
1803
+ }
1502
1804
  function checkUpdate() {
1503
1805
  if (checking) return;
1504
1806
  setChecking(true);
@@ -1813,6 +2115,29 @@ window.__ModuleLoader__.load({
1813
2115
  CardNote('question')
1814
2116
  )
1815
2117
  ),
2118
+ h('div', { className: 'cv-settings-card' },
2119
+ h('h3', null, t('auditTitle')),
2120
+ h('p', { className: 'cv-card-sub' }, t('auditDesc')),
2121
+ h('div', { className: 'cv-update-row' },
2122
+ h('button', { type: 'button', className: 'cv-btn', disabled: auditLoading, onClick: fetchAudit }, auditLoading ? t('auditLoading') : t('auditView'))
2123
+ ),
2124
+ auditData ? h('div', { style: { marginTop: 10 } },
2125
+ auditData.ok !== true
2126
+ ? h('p', { className: 'cv-card-sub', style: { margin: 0 } }, t('auditFail'))
2127
+ : (auditData.events && auditData.events.length > 0
2128
+ ? h('div', { className: 'cv-audit-list' }, auditData.events.slice().reverse().map(function (ev, i) {
2129
+ var detail = ev.tool || ev.action || '-';
2130
+ if (ev.query) detail += ' · ' + ev.query;
2131
+ if (typeof ev.count === 'number') detail += ' · ' + ev.count;
2132
+ return h('div', { className: 'cv-audit-row', key: i },
2133
+ h('span', { className: 'cv-audit-time' }, String(ev.at || '').replace('T', ' ').replace('Z', '')),
2134
+ h('span', { className: 'cv-audit-detail' }, detail)
2135
+ );
2136
+ }))
2137
+ : h('p', { className: 'cv-card-sub', style: { margin: 0 } }, t('auditEmpty'))),
2138
+ h('p', { className: 'cv-card-sub', style: { marginTop: 8, marginBottom: 0 } }, t('auditTotal') + ':' + (auditData.total || 0))
2139
+ ) : null
2140
+ ),
1816
2141
  h('div', { className: 'cv-settings-card' },
1817
2142
  h('h3', null, t('updateTitle')),
1818
2143
  h('p', { className: 'cv-card-sub' }, t('updateDesc')),
@@ -2106,7 +2431,8 @@ window.__ModuleLoader__.load({
2106
2431
  }
2107
2432
  function pickExport(fmt) {
2108
2433
  setExporting(false);
2109
- setToast(exportEntries(entries, fmt) ? t('exportDone') : t('exportFail'));
2434
+ var ok = exportEntries(entries, fmt);
2435
+ setToast(ok ? t('exportDone') : t('exportFail'));
2110
2436
  }
2111
2437
  function doImport(incoming, mode) {
2112
2438
  setEntries(function (prev) {
@@ -2225,7 +2551,9 @@ window.__ModuleLoader__.load({
2225
2551
  t: t, onImport: doImport, onCancel: function () { setImporting(false); }
2226
2552
  }) : null,
2227
2553
  exporting ? h(ExportModal, {
2228
- t: t, onPick: pickExport, onCancel: function () { setExporting(false); }
2554
+ t: t, onPick: pickExport, onCancel: function () { setExporting(false); },
2555
+ onEncrypted: function (pw) { return exportEncrypted(entries, pw); },
2556
+ onDone: function () { setExporting(false); setToast(t('exportEncryptedDone')); }
2229
2557
  }) : null,
2230
2558
  auditing ? h(AuditModal, {
2231
2559
  t: t, entries: entries, onEdit: auditEditEntry, onCancel: function () { setAuditing(false); }