@mysterycode-liwen/dsh-credential-vault 1.4.3 → 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/README.md +7 -0
- package/client.js +118 -26
- package/index.js +412 -411
- package/locale/en.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,13 @@ Host 侧工具在 Harness 启动时注册。重启 Harness,或在插件管理
|
|
|
126
126
|
|
|
127
127
|
## 更新日志 / Changelog
|
|
128
128
|
|
|
129
|
+
### 1.5.0 — 2026-11-26 — 微信开发凭据类型与表单改版
|
|
130
|
+
|
|
131
|
+
- **新增两种凭据类型**:微信公众号(`wechatMp`)与微信小程序(`wechatMini`),字段包含 AppID、AppSecret、Token / EncodingAESKey、服务器地址、上传密钥、服务器域名等;密钥类字段默认脱敏。
|
|
132
|
+
- **类型排序**:「其他」始终排在类型列表最后。
|
|
133
|
+
- **表单改版**:编辑表单改为每个字段独占一行的单列布局,次要字段折叠到「更多字段」,弹窗与输入框自适应窄容器。
|
|
134
|
+
- **安全字段同步扩展**:新增的微信密钥字段纳入 Host 脱敏与加密导出范围,测试覆盖新类型的导入 / 导出 / 脱敏往返。
|
|
135
|
+
|
|
129
136
|
### 1.4.3 — 2026-11-23 — 安全加固
|
|
130
137
|
|
|
131
138
|
- **明文不再落盘**:移除 Host 端 `vault.json` 镜像与相关迁移逻辑,内存快照重启即清空。
|
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.
|
|
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
|
-
|
|
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',
|
|
@@ -153,6 +165,7 @@ window.__ModuleLoader__.load({
|
|
|
153
165
|
sort: '排序', sortRecent: '最近更新', sortTitle: '名称(A–Z)', sortCategory: '类型',
|
|
154
166
|
search: '搜索名称、账号、网址或备注…',
|
|
155
167
|
filterAll: '全部', filterAccount: '账号密码', filterApikey: 'API Key', filterOther: '其他',
|
|
168
|
+
filterWechatMp: '微信公众号', filterWechatMini: '微信小程序',
|
|
156
169
|
localNotice: '数据仅保存在本机浏览器的 localStorage 中,不跨设备同步、不加密,请避免在公用/共享浏览器使用。',
|
|
157
170
|
show: '显示', hide: '隐藏', copy: '复制', visit: '访问', copied: '已复制到剪贴板', copyFail: '复制失败,请手动选择文本',
|
|
158
171
|
visitFail: '无法打开浏览器,请检查网址后重试。',
|
|
@@ -162,7 +175,8 @@ window.__ModuleLoader__.load({
|
|
|
162
175
|
emptyFiltered: '没有匹配项',
|
|
163
176
|
editorNew: '新增凭据', editorEdit: '编辑凭据',
|
|
164
177
|
fTitle: '名称', fTitlePh: '例如:GitHub、Google', fTitlePhApikey: '例如:OpenAI、AWS、GitHub PAT', fTitlePhOther: '例如:恢复码、Wi-Fi、许可证',
|
|
165
|
-
|
|
178
|
+
fTitlePhWechatMp: '例如:我的公众号', fTitlePhWechatMini: '例如:我的小程序',
|
|
179
|
+
fCategory: '类型', formDetails: '凭据信息', moreFields: '更多字段', lessFields: '收起字段',
|
|
166
180
|
fAccount: '账号 / 用户名', fAccountPh: 'user@example.com',
|
|
167
181
|
fPassword: '密码', fPasswordPh: '输入密码',
|
|
168
182
|
fUrl: '登录网址(可选)', fUrlPh: 'https://…',
|
|
@@ -172,10 +186,20 @@ window.__ModuleLoader__.load({
|
|
|
172
186
|
fExpiry: '到期日期(可选)',
|
|
173
187
|
fContent: '内容 / 密钥', fContentPh: '恢复码、许可证、证书、PIN…',
|
|
174
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 合法域名',
|
|
175
196
|
catAccount: '账号密码', catApikey: 'API Key', catOther: '其他',
|
|
197
|
+
catWechatMp: '微信公众号', catWechatMini: '微信小程序',
|
|
176
198
|
hintAccount: '用于保存网站 / 应用的登录账号与密码。',
|
|
177
199
|
hintApikey: '用于保存平台签发的 API Key、令牌与接口地址。',
|
|
178
200
|
hintOther: '用于保存恢复码、许可证、证书等任意文本。',
|
|
201
|
+
hintWechatMp: '用于保存公众号开发者凭证与服务器配置。',
|
|
202
|
+
hintWechatMini: '用于保存小程序开发者凭证与代码上传密钥。',
|
|
179
203
|
save: '保存', cancel: '取消', required: '请输入名称',
|
|
180
204
|
confirmDelete: '确定删除这条凭据?此操作不可撤销。',
|
|
181
205
|
saved: '已保存', deleted: '已删除', revealAll: '全部显示', hideAll: '全部隐藏',
|
|
@@ -285,17 +309,40 @@ window.__ModuleLoader__.load({
|
|
|
285
309
|
{ key: 'title', label: 'fTitle', ph: 'fTitlePhOther', type: 'text', required: true },
|
|
286
310
|
{ key: 'content', label: 'fContent', ph: 'fContentPh', type: 'secretarea', mono: true },
|
|
287
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' }
|
|
288
329
|
]
|
|
289
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.
|
|
290
333
|
var CATEGORIES = [
|
|
291
334
|
{ k: 'account', label: 'catAccount', hint: 'hintAccount' },
|
|
292
335
|
{ k: 'apikey', label: 'catApikey', hint: 'hintApikey' },
|
|
336
|
+
{ k: 'wechatMp', label: 'catWechatMp', hint: 'hintWechatMp' },
|
|
337
|
+
{ k: 'wechatMini', label: 'catWechatMini', hint: 'hintWechatMini' },
|
|
293
338
|
{ k: 'other', label: 'catOther', hint: 'hintOther' }
|
|
294
339
|
];
|
|
295
340
|
var FILTERS = [
|
|
296
341
|
{ k: 'all', label: 'filterAll' },
|
|
297
342
|
{ k: 'account', label: 'filterAccount' },
|
|
298
343
|
{ k: 'apikey', label: 'filterApikey' },
|
|
344
|
+
{ k: 'wechatMp', label: 'filterWechatMp' },
|
|
345
|
+
{ k: 'wechatMini', label: 'filterWechatMini' },
|
|
299
346
|
{ k: 'other', label: 'filterOther' }
|
|
300
347
|
];
|
|
301
348
|
function schemaOf(cat) { return SCHEMAS[cat] || SCHEMAS.account; }
|
|
@@ -305,7 +352,7 @@ window.__ModuleLoader__.load({
|
|
|
305
352
|
var CSS = [
|
|
306
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}',
|
|
307
354
|
'.cv-root *{box-sizing:border-box}',
|
|
308
|
-
'.cv-wrap{max-width:
|
|
355
|
+
'.cv-wrap{max-width:90%;margin:0 auto;padding:28px 26px 60px}',
|
|
309
356
|
'.cv-head{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}',
|
|
310
357
|
'.cv-head-left{display:flex;align-items:center;gap:14px}',
|
|
311
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)}',
|
|
@@ -359,6 +406,8 @@ window.__ModuleLoader__.load({
|
|
|
359
406
|
'.cv-badge-apikey{background:var(--cv-brand);color:var(--cv-bg)}',
|
|
360
407
|
'.cv-badge-account{color:var(--cv-brand)}',
|
|
361
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}',
|
|
362
411
|
'.cv-card-title{font-weight:600;font-size:14.5px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
363
412
|
'.cv-card-actions{display:flex;gap:4px}',
|
|
364
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}',
|
|
@@ -376,9 +425,9 @@ window.__ModuleLoader__.load({
|
|
|
376
425
|
'.cv-empty h3{margin:0 0 6px;color:var(--cv-t1);font-size:16px}',
|
|
377
426
|
'.cv-empty p{margin:0;font-size:13px}',
|
|
378
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}',
|
|
379
|
-
'.cv-modal{position:sticky;top:50vh;transform:translateY(-50%);width:
|
|
380
|
-
'.cv-modal.cv-modal-editor{
|
|
381
|
-
'.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}',
|
|
382
431
|
// Sidebar panel only: modals are positioned relative to the panel itself
|
|
383
432
|
// (flex-centered inside .cv-root) — the settings-page sticky float is untouched.
|
|
384
433
|
'.cv-panelroot>.cv-modal-backdrop{align-items:center}',
|
|
@@ -387,11 +436,20 @@ window.__ModuleLoader__.load({
|
|
|
387
436
|
'.cv-modal-head h2{margin:0;font-size:17px;font-weight:650}',
|
|
388
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}',
|
|
389
438
|
'.cv-modal-body{padding:14px 22px 6px;display:flex;flex-direction:column;gap:12px}',
|
|
390
|
-
|
|
391
|
-
'.cv-form-
|
|
392
|
-
'.cv-
|
|
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}',
|
|
393
451
|
'.cv-input:focus{border-color:var(--cv-brand)}',
|
|
394
|
-
'.cv-textarea{min-height:64px;resize:vertical}',
|
|
452
|
+
'.cv-textarea{min-height:64px;max-width:100%;resize:vertical;overflow-wrap:anywhere}',
|
|
395
453
|
'.cv-secret-input{display:flex;gap:6px;align-items:stretch}',
|
|
396
454
|
'.cv-secret-input .cv-input{flex:1;min-width:0}',
|
|
397
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}',
|
|
@@ -412,7 +470,7 @@ window.__ModuleLoader__.load({
|
|
|
412
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}',
|
|
413
471
|
'.cv-link:hover{opacity:.8}',
|
|
414
472
|
'.cv-lock-foot{margin-top:16px;color:var(--cv-t2);font-size:11px;line-height:1.5}',
|
|
415
|
-
'.cv-settings{max-width:
|
|
473
|
+
'.cv-settings{max-width:90%;margin:0 auto;padding:28px 26px 60px;position:relative}',
|
|
416
474
|
'.cv-settings-head{margin-bottom:8px}',
|
|
417
475
|
'.cv-settings-head h2{margin:0;font-size:18px;font-weight:650}',
|
|
418
476
|
'.cv-settings-head p{margin:5px 0 0;color:var(--cv-t2);font-size:13px;line-height:1.5}',
|
|
@@ -519,8 +577,9 @@ window.__ModuleLoader__.load({
|
|
|
519
577
|
// Fire-and-forget: the browser stays usable even if the Host route is down.
|
|
520
578
|
// Large vaults: DEBOUNCE so a burst of edits results in one POST, not dozens
|
|
521
579
|
// of multi-megabyte payloads. A trailing timer always flushes the latest data.
|
|
522
|
-
var MIRROR_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'url', 'endpoint', 'expiry',
|
|
523
|
-
|
|
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'];
|
|
524
583
|
function toEnvelope(entry) {
|
|
525
584
|
var out = {};
|
|
526
585
|
MIRROR_FIELDS.forEach(function (k) {
|
|
@@ -695,7 +754,9 @@ window.__ModuleLoader__.load({
|
|
|
695
754
|
function pad(n) { return n < 10 ? '0' + n : '' + n; }
|
|
696
755
|
return d.getFullYear() + pad(d.getMonth() + 1) + pad(d.getDate()) + '-' + pad(d.getHours()) + pad(d.getMinutes());
|
|
697
756
|
}
|
|
698
|
-
var EXPORT_COLS = ['id', 'title', 'category', 'username', 'password', 'url', 'provider', 'apiKey', 'endpoint', 'expiry', 'content',
|
|
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'];
|
|
699
760
|
|
|
700
761
|
// ---- Human-readable labels ------------------------------------------------
|
|
701
762
|
// CSV/Markdown use Chinese labels for people; every label maps back to its
|
|
@@ -703,11 +764,14 @@ window.__ModuleLoader__.load({
|
|
|
703
764
|
var FIELD_LABELS = {
|
|
704
765
|
id: 'ID', title: '标题', category: '类型', username: '用户名', password: '密码',
|
|
705
766
|
url: '网址', provider: '服务商', apiKey: 'API Key', endpoint: '接口地址',
|
|
706
|
-
expiry: '有效期', content: '内容',
|
|
767
|
+
expiry: '有效期', content: '内容',
|
|
768
|
+
appId: 'AppID', appSecret: 'AppSecret', token: '服务器Token', encodingAesKey: 'EncodingAESKey',
|
|
769
|
+
serverUrl: '服务器地址', uploadKey: '代码上传密钥', domains: '服务器域名',
|
|
770
|
+
notes: '备注', createdAt: '创建时间', updatedAt: '更新时间'
|
|
707
771
|
};
|
|
708
772
|
var LABEL_FIELDS = {};
|
|
709
773
|
Object.keys(FIELD_LABELS).forEach(function (k) { LABEL_FIELDS[FIELD_LABELS[k]] = k; });
|
|
710
|
-
var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', other: '其他' };
|
|
774
|
+
var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', other: '其他', wechatMp: '微信公众号', wechatMini: '微信小程序' };
|
|
711
775
|
var LABEL_CATEGORIES = {};
|
|
712
776
|
Object.keys(CATEGORY_LABELS).forEach(function (k) { LABEL_CATEGORIES[CATEGORY_LABELS[k]] = k; });
|
|
713
777
|
// Only export fields that belong to the entry's type. A record may carry
|
|
@@ -716,7 +780,9 @@ window.__ModuleLoader__.load({
|
|
|
716
780
|
var VISIBLE_FIELDS = {
|
|
717
781
|
account: ['title', 'username', 'password', 'url', 'notes'],
|
|
718
782
|
apikey: ['title', 'provider', 'apiKey', 'endpoint', 'expiry', 'notes'],
|
|
719
|
-
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']
|
|
720
786
|
};
|
|
721
787
|
function fieldsFor(cat) { return VISIBLE_FIELDS[cat] || VISIBLE_FIELDS.account; }
|
|
722
788
|
// Strip fields that do not belong to the entry's type. Applied inside
|
|
@@ -746,7 +812,9 @@ window.__ModuleLoader__.load({
|
|
|
746
812
|
// CSV shows the fields people actually read first; technical columns
|
|
747
813
|
// (ID / timestamps) go last. Import maps by header label, so order is safe.
|
|
748
814
|
var CSV_COLS = ['title', 'category', 'username', 'password', 'url', 'provider',
|
|
749
|
-
'apiKey', 'endpoint', 'expiry', 'content',
|
|
815
|
+
'apiKey', 'endpoint', 'expiry', 'content',
|
|
816
|
+
'appId', 'appSecret', 'token', 'encodingAesKey', 'serverUrl', 'uploadKey', 'domains',
|
|
817
|
+
'notes', 'id', 'createdAt', 'updatedAt'];
|
|
750
818
|
function buildCsv(arr) {
|
|
751
819
|
var lines = [CSV_COLS.map(function (c) { return csvEscape(FIELD_LABELS[c] || c); }).join(',')];
|
|
752
820
|
arr.forEach(function (e) {
|
|
@@ -1209,7 +1277,9 @@ window.__ModuleLoader__.load({
|
|
|
1209
1277
|
id: '', title: '', category: cat || 'account',
|
|
1210
1278
|
username: '', password: '', url: '',
|
|
1211
1279
|
provider: '', apiKey: '', endpoint: '', expiry: '',
|
|
1212
|
-
content: '',
|
|
1280
|
+
content: '',
|
|
1281
|
+
appId: '', appSecret: '', token: '', encodingAesKey: '', serverUrl: '', uploadKey: '', domains: '',
|
|
1282
|
+
notes: ''
|
|
1213
1283
|
};
|
|
1214
1284
|
}
|
|
1215
1285
|
|
|
@@ -1272,7 +1342,8 @@ window.__ModuleLoader__.load({
|
|
|
1272
1342
|
function Card(props) {
|
|
1273
1343
|
var e = props.entry, t = props.t;
|
|
1274
1344
|
var cat = e.category || 'account';
|
|
1275
|
-
var
|
|
1345
|
+
var catMeta = CATEGORIES.filter(function (c) { return c.k === cat; })[0];
|
|
1346
|
+
var catLabel = catMeta ? t(catMeta.label) : t('catAccount');
|
|
1276
1347
|
return h('div', { className: 'cv-card' },
|
|
1277
1348
|
h('div', { className: 'cv-card-head' },
|
|
1278
1349
|
h('span', { className: 'cv-badge cv-badge-' + cat }, catLabel),
|
|
@@ -1302,6 +1373,14 @@ window.__ModuleLoader__.load({
|
|
|
1302
1373
|
var meta = CATEGORIES.filter(function (c) { return c.k === cat; })[0] || CATEGORIES[0];
|
|
1303
1374
|
var fields = schemaOf(cat);
|
|
1304
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
|
+
|
|
1305
1384
|
function baseInput(f, extra) {
|
|
1306
1385
|
return Object.assign({
|
|
1307
1386
|
className: 'cv-input', value: d[f.key] || '',
|
|
@@ -1310,6 +1389,9 @@ window.__ModuleLoader__.load({
|
|
|
1310
1389
|
onChange: function (ev) { onChange(f.key, ev.target.value); }
|
|
1311
1390
|
}, extra || {});
|
|
1312
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]; }
|
|
1313
1395
|
function renderField(f) {
|
|
1314
1396
|
var control;
|
|
1315
1397
|
if (f.type === 'text' || f.type === 'date') {
|
|
@@ -1332,8 +1414,8 @@ window.__ModuleLoader__.load({
|
|
|
1332
1414
|
h('button', { type: 'button', className: 'cv-secret-toggle', onClick: function () { setShowSecret(!showSecret); } }, showSecret ? t('hide') : t('show'))
|
|
1333
1415
|
);
|
|
1334
1416
|
}
|
|
1335
|
-
return h('label', { key: f.key, className: 'cv-form-row' },
|
|
1336
|
-
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),
|
|
1337
1419
|
control
|
|
1338
1420
|
);
|
|
1339
1421
|
}
|
|
@@ -1345,14 +1427,24 @@ window.__ModuleLoader__.load({
|
|
|
1345
1427
|
},
|
|
1346
1428
|
h('div', { className: 'cv-modal-head' }, h('h2', null, t(props.titleKey) + ' · ' + t(meta.label))),
|
|
1347
1429
|
h('div', { className: 'cv-modal-hint' }, t(meta.hint)),
|
|
1348
|
-
h('div', { className: 'cv-
|
|
1349
|
-
h('label', { className: 'cv-form-row' },
|
|
1430
|
+
h('div', { className: 'cv-form-body' },
|
|
1431
|
+
h('label', { className: 'cv-form-row cv-row-full' },
|
|
1350
1432
|
h('span', { className: 'cv-form-label' }, t('fCategory')),
|
|
1351
1433
|
h('select', { className: 'cv-input', value: cat, onChange: function (ev) { onChange('category', ev.target.value); } },
|
|
1352
1434
|
CATEGORIES.map(function (c) { return h('option', { key: c.k, value: c.k }, t(c.label)); })
|
|
1353
1435
|
)
|
|
1354
1436
|
),
|
|
1355
|
-
|
|
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
|
|
1356
1448
|
),
|
|
1357
1449
|
h('div', { className: 'cv-modal-foot' },
|
|
1358
1450
|
h('button', { className: 'cv-btn', onClick: props.onCancel }, t('cancel')),
|
package/index.js
CHANGED
|
@@ -1,411 +1,412 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host half of the dsh-credential-vault bundle.
|
|
3
|
-
*
|
|
4
|
-
* The browser (client.js) owns the vault data in localStorage. This half
|
|
5
|
-
* exposes it to the Harness through two things:
|
|
6
|
-
* 1. a loopback-only HTTP surface the browser POSTs its entries to, and
|
|
7
|
-
* 2. an agent tool (`dsh_credential_vault_read`) the model calls to read them.
|
|
8
|
-
*
|
|
9
|
-
* SECURITY MODEL (hardened):
|
|
10
|
-
* - The browser sends a METADATA-ONLY envelope. Secret fields (password /
|
|
11
|
-
* apiKey / content) never reach this Host process; plaintext stays in the
|
|
12
|
-
* browser's localStorage. Even a malicious full payload is sanitized here.
|
|
13
|
-
* - Nothing is persisted to disk. The snapshot lives only in memory and is
|
|
14
|
-
* re-synced by the browser on mount / change, so a restart simply starts
|
|
15
|
-
* empty until the browser reconnects.
|
|
16
|
-
* - Every tool access is recorded in a bounded, in-memory audit log that
|
|
17
|
-
* contains no plaintext (GET /audit, same-origin + loopback only).
|
|
18
|
-
*
|
|
19
|
-
* @module dsh-credential-vault
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/** Cordis plugin name. */
|
|
23
|
-
export const name = 'dsh-credential-vault'
|
|
24
|
-
|
|
25
|
-
/** The web server is the only hard dependency. */
|
|
26
|
-
export const inject = ['webServer']
|
|
27
|
-
|
|
28
|
-
/** Route prefix owned by this plugin. */
|
|
29
|
-
const PREFIX = '/dsh-credential-vault'
|
|
30
|
-
|
|
31
|
-
/** Cap the synced payload so a stray client cannot blow up the Host. Raised for large vaults. */
|
|
32
|
-
const MAX_BODY_BYTES = 16 * 1024 * 1024
|
|
33
|
-
|
|
34
|
-
/** Max entries mirrored from the browser; beyond this the tool output would be unwieldy. */
|
|
35
|
-
const MAX_ENTRIES = 20000
|
|
36
|
-
|
|
37
|
-
/** Fields that hold secrets; masked by default in tool output. */
|
|
38
|
-
const SECRET_FIELDS = ['password', 'apiKey', 'content']
|
|
39
|
-
const MASK = '••••••••'
|
|
40
|
-
|
|
41
|
-
/** Pagination defaults / limits for the read tool. */
|
|
42
|
-
const DEFAULT_LIMIT = 20
|
|
43
|
-
const MAX_LIMIT = 200
|
|
44
|
-
|
|
45
|
-
/** Fields kept in the compact "summary" projection. */
|
|
46
|
-
const SUMMARY_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'expiry', 'updatedAt']
|
|
47
|
-
|
|
48
|
-
/** Current plugin version. Keep in sync with package.json when releasing. */
|
|
49
|
-
const CURRENT_VERSION = '1.
|
|
50
|
-
|
|
51
|
-
/** Where update checks read the latest published version from (GitHub Releases latest). */
|
|
52
|
-
const RELEASES_API = 'https://api.github.com/repos/mysterycode-liwen/dsh-credential-vault/releases/latest'
|
|
53
|
-
const RELEASES_URL = 'https://github.com/mysterycode-liwen/dsh-credential-vault/releases/latest'
|
|
54
|
-
const UPDATE_CHECK_TIMEOUT_MS = 8000
|
|
55
|
-
const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
56
|
-
let updateCache = { at: 0, result: null }
|
|
57
|
-
|
|
58
|
-
/** Last metadata-only snapshot received from the browser (never contains secrets). */
|
|
59
|
-
let snapshot = { entries: [], updatedAt: 0 }
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Fields mirrored from the browser. Everything else (especially SECRET_FIELDS)
|
|
63
|
-
* is dropped, so the Host can never hold a plaintext password / key / body.
|
|
64
|
-
*/
|
|
65
|
-
const META_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'url', 'endpoint', 'expiry',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
'
|
|
121
|
-
'
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (!l.prerelease) return
|
|
172
|
-
if (!
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (!
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
if
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
.
|
|
235
|
-
.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
.
|
|
295
|
-
.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
//
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Host half of the dsh-credential-vault bundle.
|
|
3
|
+
*
|
|
4
|
+
* The browser (client.js) owns the vault data in localStorage. This half
|
|
5
|
+
* exposes it to the Harness through two things:
|
|
6
|
+
* 1. a loopback-only HTTP surface the browser POSTs its entries to, and
|
|
7
|
+
* 2. an agent tool (`dsh_credential_vault_read`) the model calls to read them.
|
|
8
|
+
*
|
|
9
|
+
* SECURITY MODEL (hardened):
|
|
10
|
+
* - The browser sends a METADATA-ONLY envelope. Secret fields (password /
|
|
11
|
+
* apiKey / content) never reach this Host process; plaintext stays in the
|
|
12
|
+
* browser's localStorage. Even a malicious full payload is sanitized here.
|
|
13
|
+
* - Nothing is persisted to disk. The snapshot lives only in memory and is
|
|
14
|
+
* re-synced by the browser on mount / change, so a restart simply starts
|
|
15
|
+
* empty until the browser reconnects.
|
|
16
|
+
* - Every tool access is recorded in a bounded, in-memory audit log that
|
|
17
|
+
* contains no plaintext (GET /audit, same-origin + loopback only).
|
|
18
|
+
*
|
|
19
|
+
* @module dsh-credential-vault
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Cordis plugin name. */
|
|
23
|
+
export const name = 'dsh-credential-vault'
|
|
24
|
+
|
|
25
|
+
/** The web server is the only hard dependency. */
|
|
26
|
+
export const inject = ['webServer']
|
|
27
|
+
|
|
28
|
+
/** Route prefix owned by this plugin. */
|
|
29
|
+
const PREFIX = '/dsh-credential-vault'
|
|
30
|
+
|
|
31
|
+
/** Cap the synced payload so a stray client cannot blow up the Host. Raised for large vaults. */
|
|
32
|
+
const MAX_BODY_BYTES = 16 * 1024 * 1024
|
|
33
|
+
|
|
34
|
+
/** Max entries mirrored from the browser; beyond this the tool output would be unwieldy. */
|
|
35
|
+
const MAX_ENTRIES = 20000
|
|
36
|
+
|
|
37
|
+
/** Fields that hold secrets; masked by default in tool output. */
|
|
38
|
+
const SECRET_FIELDS = ['password', 'apiKey', 'content', 'appSecret', 'token', 'encodingAesKey', 'uploadKey']
|
|
39
|
+
const MASK = '••••••••'
|
|
40
|
+
|
|
41
|
+
/** Pagination defaults / limits for the read tool. */
|
|
42
|
+
const DEFAULT_LIMIT = 20
|
|
43
|
+
const MAX_LIMIT = 200
|
|
44
|
+
|
|
45
|
+
/** Fields kept in the compact "summary" projection. */
|
|
46
|
+
const SUMMARY_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'expiry', 'updatedAt']
|
|
47
|
+
|
|
48
|
+
/** Current plugin version. Keep in sync with package.json when releasing. */
|
|
49
|
+
const CURRENT_VERSION = '1.5.0'
|
|
50
|
+
|
|
51
|
+
/** Where update checks read the latest published version from (GitHub Releases latest). */
|
|
52
|
+
const RELEASES_API = 'https://api.github.com/repos/mysterycode-liwen/dsh-credential-vault/releases/latest'
|
|
53
|
+
const RELEASES_URL = 'https://github.com/mysterycode-liwen/dsh-credential-vault/releases/latest'
|
|
54
|
+
const UPDATE_CHECK_TIMEOUT_MS = 8000
|
|
55
|
+
const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
56
|
+
let updateCache = { at: 0, result: null }
|
|
57
|
+
|
|
58
|
+
/** Last metadata-only snapshot received from the browser (never contains secrets). */
|
|
59
|
+
let snapshot = { entries: [], updatedAt: 0 }
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Fields mirrored from the browser. Everything else (especially SECRET_FIELDS)
|
|
63
|
+
* is dropped, so the Host can never hold a plaintext password / key / body.
|
|
64
|
+
*/
|
|
65
|
+
const META_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'url', 'endpoint', 'expiry',
|
|
66
|
+
'appId', 'serverUrl', 'domains', 'notes', 'createdAt', 'updatedAt']
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Force every incoming entry into a metadata-only shape. Applied defensively on
|
|
70
|
+
* POST /entries, so even a buggy or hostile client cannot smuggle a secret into
|
|
71
|
+
* the Host, the tool output, or the audit log.
|
|
72
|
+
*/
|
|
73
|
+
function sanitizeEnvelope(entry) {
|
|
74
|
+
const out = {}
|
|
75
|
+
for (const key of META_FIELDS) {
|
|
76
|
+
const value = entry[key]
|
|
77
|
+
if (typeof value === 'string' || typeof value === 'number') out[key] = value
|
|
78
|
+
}
|
|
79
|
+
// Keep the masked placeholders so the UI shape stays stable for the model.
|
|
80
|
+
for (const key of SECRET_FIELDS) {
|
|
81
|
+
if (typeof entry[key] === 'string' && entry[key] !== '') out[key] = MASK
|
|
82
|
+
}
|
|
83
|
+
return out
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// --- in-memory access audit (no plaintext, bounded) ------------------------
|
|
87
|
+
|
|
88
|
+
const MAX_AUDIT = 200
|
|
89
|
+
/** @type {{at:string, tool:string, action:string, entryId?:string, query?:string, count?:number}[]} */
|
|
90
|
+
const auditLog = []
|
|
91
|
+
function recordAudit(event) {
|
|
92
|
+
auditLog.push(Object.assign({ at: new Date().toISOString() }, event))
|
|
93
|
+
if (auditLog.length > MAX_AUDIT) auditLog.splice(0, auditLog.length - MAX_AUDIT)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// --- tiny HTTP helpers (self-contained so the bundle stays 7 files) --------
|
|
97
|
+
|
|
98
|
+
function isLoopback(req) {
|
|
99
|
+
const address = req && req.socket ? req.socket.remoteAddress : undefined
|
|
100
|
+
if (address === undefined) return true
|
|
101
|
+
return address === '127.0.0.1' || address === '::1' || address === '::ffff:127.0.0.1' || address.startsWith('127.')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isSameOrigin(req) {
|
|
105
|
+
const origin = req && req.headers ? req.headers.origin : undefined
|
|
106
|
+
if (typeof origin !== 'string' || origin === '') return true
|
|
107
|
+
const host = req && req.headers ? req.headers.host : undefined
|
|
108
|
+
if (typeof host !== 'string' || host === '') return false
|
|
109
|
+
try {
|
|
110
|
+
return new URL(origin).host === host
|
|
111
|
+
} catch {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function sendJson(res, status, payload) {
|
|
117
|
+
if (!res || res.writableEnded || res.destroyed) return
|
|
118
|
+
const body = JSON.stringify(payload)
|
|
119
|
+
res.writeHead(status, {
|
|
120
|
+
'content-type': 'application/json; charset=utf-8',
|
|
121
|
+
'cache-control': 'no-store',
|
|
122
|
+
'content-length': Buffer.byteLength(body),
|
|
123
|
+
})
|
|
124
|
+
res.end(body)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function fail(res, status, code, message) {
|
|
128
|
+
sendJson(res, status, { ok: false, error: { code, ...(message === undefined ? {} : { message }) } })
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function readJson(req, cap = MAX_BODY_BYTES) {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
const chunks = []
|
|
134
|
+
let size = 0
|
|
135
|
+
req.on('data', (chunk) => {
|
|
136
|
+
size += chunk.length
|
|
137
|
+
if (size > cap) {
|
|
138
|
+
reject(new Error('body too large'))
|
|
139
|
+
req.destroy()
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
chunks.push(chunk)
|
|
143
|
+
})
|
|
144
|
+
req.on('end', () => {
|
|
145
|
+
try {
|
|
146
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString('utf8')))
|
|
147
|
+
} catch {
|
|
148
|
+
reject(new Error('invalid json'))
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
req.on('error', reject)
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// --- update check helpers --------------------------------------------------
|
|
156
|
+
|
|
157
|
+
/** Parse a semver-ish tag into comparable parts. Returns null when unparseable. */
|
|
158
|
+
function parseSemver(value) {
|
|
159
|
+
if (typeof value !== 'string') return null
|
|
160
|
+
const m = value.trim().replace(/^v/i, '').match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/)
|
|
161
|
+
if (!m) return null
|
|
162
|
+
return { major: Number(m[1]), minor: Number(m[2]), patch: Number(m[3]), prerelease: m[4] || '' }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Compare two parsed semvers: -1 (left older), 0 (equal), 1 (left newer). */
|
|
166
|
+
function compareSemver(l, r) {
|
|
167
|
+
const parts = ['major', 'minor', 'patch']
|
|
168
|
+
for (const key of parts) {
|
|
169
|
+
if (l[key] !== r[key]) return l[key] < r[key] ? -1 : 1
|
|
170
|
+
}
|
|
171
|
+
if (!l.prerelease && !r.prerelease) return 0
|
|
172
|
+
if (!l.prerelease) return 1
|
|
173
|
+
if (!r.prerelease) return -1
|
|
174
|
+
return l.prerelease < r.prerelease ? -1 : l.prerelease > r.prerelease ? 1 : 0
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Fetch the latest Release tag from GitHub, with a timeout and short cache. */
|
|
178
|
+
async function checkForUpdate() {
|
|
179
|
+
if (updateCache.result && Date.now() - updateCache.at < UPDATE_CACHE_MS) {
|
|
180
|
+
return Object.assign({}, updateCache.result, { cached: true })
|
|
181
|
+
}
|
|
182
|
+
const fetchImpl = typeof globalThis.fetch === 'function' ? globalThis.fetch.bind(globalThis) : undefined
|
|
183
|
+
if (!fetchImpl) throw new Error('fetch is not available on this Node runtime')
|
|
184
|
+
let signal
|
|
185
|
+
try { signal = AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) } catch { /* no timeout support */ }
|
|
186
|
+
const response = await fetchImpl(RELEASES_API, {
|
|
187
|
+
headers: { accept: 'application/vnd.github+json', 'user-agent': 'dsh-credential-vault-update-check' },
|
|
188
|
+
...(signal ? { signal } : {}),
|
|
189
|
+
})
|
|
190
|
+
if (!response.ok) throw new Error('GitHub API returned ' + response.status)
|
|
191
|
+
const body = await response.json()
|
|
192
|
+
const tag = body && typeof body.tag_name === 'string' ? body.tag_name : ''
|
|
193
|
+
const latest = parseSemver(tag)
|
|
194
|
+
if (!latest) throw new Error('Latest release tag is not a valid version: ' + tag)
|
|
195
|
+
const current = parseSemver(CURRENT_VERSION) || { major: 0, minor: 0, patch: 0, prerelease: '' }
|
|
196
|
+
const result = {
|
|
197
|
+
ok: true,
|
|
198
|
+
currentVersion: CURRENT_VERSION,
|
|
199
|
+
latestVersion: tag.replace(/^v/i, ''),
|
|
200
|
+
updateAvailable: compareSemver(current, latest) < 0,
|
|
201
|
+
releaseUrl: RELEASES_URL,
|
|
202
|
+
checkedAt: new Date().toISOString(),
|
|
203
|
+
cached: false,
|
|
204
|
+
}
|
|
205
|
+
updateCache = { at: Date.now(), result }
|
|
206
|
+
return result
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// --- HTTP surface ----------------------------------------------------------
|
|
210
|
+
|
|
211
|
+
async function handle(req, res) {
|
|
212
|
+
try {
|
|
213
|
+
if (!isLoopback(req)) return fail(res, 403, 'NOT_LOOPBACK')
|
|
214
|
+
if (!isSameOrigin(req)) return fail(res, 403, 'BAD_ORIGIN')
|
|
215
|
+
|
|
216
|
+
let pathname = (req.url || '/').split('?')[0]
|
|
217
|
+
if (pathname.startsWith(PREFIX)) pathname = pathname.slice(PREFIX.length) || '/'
|
|
218
|
+
const method = (req.method || 'GET').toUpperCase()
|
|
219
|
+
|
|
220
|
+
// Browser -> Host: replace the snapshot with the browser's current vault.
|
|
221
|
+
// Every entry is forced through sanitizeEnvelope(), so secrets never enter
|
|
222
|
+
// this process even if the browser sends a full (legacy) payload.
|
|
223
|
+
if (pathname === '/entries' && method === 'POST') {
|
|
224
|
+
let body
|
|
225
|
+
try {
|
|
226
|
+
body = await readJson(req)
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return fail(res, 400, 'BAD_JSON', String(error && error.message ? error.message : error))
|
|
229
|
+
}
|
|
230
|
+
const list = body && Array.isArray(body.entries) ? body.entries : null
|
|
231
|
+
if (!list) return fail(res, 400, 'BAD_ENTRIES', 'expected { entries: [] }')
|
|
232
|
+
// Keep only plain objects, cap the count, then strip all secret fields.
|
|
233
|
+
const entries = list
|
|
234
|
+
.filter((e) => e !== null && typeof e === 'object' && !Array.isArray(e))
|
|
235
|
+
.slice(0, MAX_ENTRIES)
|
|
236
|
+
.map(sanitizeEnvelope)
|
|
237
|
+
snapshot = { entries, updatedAt: Date.now() }
|
|
238
|
+
return sendJson(res, 200, { ok: true, count: entries.length, truncated: list.length > entries.length })
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Debug / inspection endpoint removed: it used to return a page of the raw
|
|
242
|
+
// snapshot. It is not needed by the browser and only widened the read
|
|
243
|
+
// surface. The dsh_credential_vault_read tool is the sanctioned read path.
|
|
244
|
+
if (pathname === '/entries' && method === 'GET') {
|
|
245
|
+
return fail(res, 404, 'NOT_FOUND')
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// In-memory access audit (same-origin + loopback already enforced above).
|
|
249
|
+
// Contains no plaintext — only tool names, actions, ids and counts.
|
|
250
|
+
if (pathname === '/audit' && method === 'GET') {
|
|
251
|
+
return sendJson(res, 200, { ok: true, total: auditLog.length, events: auditLog.slice() })
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Check GitHub Releases latest for a newer plugin version.
|
|
255
|
+
if (pathname === '/update-check' && method === 'GET') {
|
|
256
|
+
try {
|
|
257
|
+
return sendJson(res, 200, await checkForUpdate())
|
|
258
|
+
} catch (error) {
|
|
259
|
+
return sendJson(res, 200, {
|
|
260
|
+
ok: false,
|
|
261
|
+
currentVersion: CURRENT_VERSION,
|
|
262
|
+
error: String(error && error.message ? error.message : error),
|
|
263
|
+
checkedAt: new Date().toISOString(),
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return fail(res, 404, 'NOT_FOUND')
|
|
269
|
+
} catch (error) {
|
|
270
|
+
return fail(res, 500, 'INTERNAL', String(error && error.message ? error.message : error))
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// --- tool projection helpers ----------------------------------------------
|
|
275
|
+
|
|
276
|
+
function projectEntry(entry, mode) {
|
|
277
|
+
const keys = mode === 'summary' ? SUMMARY_FIELDS : Object.keys(entry)
|
|
278
|
+
const out = {}
|
|
279
|
+
for (const key of keys) {
|
|
280
|
+
const value = entry[key]
|
|
281
|
+
if (value === null || value === undefined || value === '') continue
|
|
282
|
+
// Secret fields in the snapshot are already MASK placeholders (the Host
|
|
283
|
+
// never receives plaintext). Guard here too, defense-in-depth.
|
|
284
|
+
out[key] = SECRET_FIELDS.includes(key) ? MASK : value
|
|
285
|
+
}
|
|
286
|
+
return out
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function matches(entry, query, category) {
|
|
290
|
+
if (category && category !== 'all' && entry.category !== category) return false
|
|
291
|
+
if (!query) return true
|
|
292
|
+
const q = query.toLowerCase()
|
|
293
|
+
const haystack = [entry.title, entry.username, entry.provider, entry.url, entry.endpoint, entry.notes]
|
|
294
|
+
.filter((v) => typeof v === 'string')
|
|
295
|
+
.join(' ')
|
|
296
|
+
.toLowerCase()
|
|
297
|
+
return haystack.includes(q)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @param {import('@deepseek-ai/cordis').Context} ctx
|
|
302
|
+
*/
|
|
303
|
+
export function apply(ctx) {
|
|
304
|
+
ctx.effect(() => {
|
|
305
|
+
const dispose = ctx.webServer.register({
|
|
306
|
+
kind: 'prefix',
|
|
307
|
+
path: PREFIX,
|
|
308
|
+
handler: (req, res) => handle(req, res),
|
|
309
|
+
})
|
|
310
|
+
return () => {
|
|
311
|
+
if (typeof dispose === 'function') dispose()
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
// Tools / systemPrompt are optional services: read them defensively so the
|
|
316
|
+
// plugin still loads where they are unavailable.
|
|
317
|
+
const tools = typeof ctx.get === 'function' ? ctx.get('tools') : undefined
|
|
318
|
+
if (tools !== undefined && tools !== null && typeof tools.register === 'function') {
|
|
319
|
+
ctx.effect(() => {
|
|
320
|
+
const dispose = tools.register(
|
|
321
|
+
{
|
|
322
|
+
name: 'dsh_credential_vault_read',
|
|
323
|
+
description:
|
|
324
|
+
'Read metadata about credentials in the user\'s local vault (accounts, API keys, other entries stored in the sidebar vault panel). Results are paginated: use limit/offset to page through large vaults, or mode="summary" for a lightweight id/title/category list first. Secret values (passwords / API keys / text bodies) are ALWAYS masked — plaintext never leaves the browser and cannot be returned by this tool; the revealSecrets parameter is accepted for compatibility but has no effect. Use this to discover which credentials exist; to actually use a secret, ask the user to open the vault panel and copy it.',
|
|
325
|
+
parameters: {
|
|
326
|
+
type: 'object',
|
|
327
|
+
properties: {
|
|
328
|
+
query: {
|
|
329
|
+
type: 'string',
|
|
330
|
+
description: 'Optional text to filter by title, account, provider, URL or notes (case-insensitive substring).',
|
|
331
|
+
},
|
|
332
|
+
category: {
|
|
333
|
+
type: 'string',
|
|
334
|
+
enum: ['all', 'account', 'apikey', 'other', 'wechatMp', 'wechatMini'],
|
|
335
|
+
description: 'Only return entries of this category. Defaults to all.',
|
|
336
|
+
},
|
|
337
|
+
mode: {
|
|
338
|
+
type: 'string',
|
|
339
|
+
enum: ['summary', 'full'],
|
|
340
|
+
description: 'summary = only id/title/category/account/provider/expiry (lightweight, recommended for browsing); full = all metadata fields (secrets always masked). Defaults to full.',
|
|
341
|
+
},
|
|
342
|
+
limit: {
|
|
343
|
+
type: 'number',
|
|
344
|
+
description: 'Page size, 1-200. Defaults to 20. Use with offset to page through large vaults.',
|
|
345
|
+
},
|
|
346
|
+
offset: {
|
|
347
|
+
type: 'number',
|
|
348
|
+
description: 'How many matching entries to skip. Defaults to 0. Increase by limit to get the next page.',
|
|
349
|
+
},
|
|
350
|
+
revealSecrets: {
|
|
351
|
+
type: 'boolean',
|
|
352
|
+
description: 'Deprecated / no-op. Secret values are always masked and are never returned by this tool. Accepted only so older tool calls keep working.',
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
additionalProperties: false,
|
|
356
|
+
},
|
|
357
|
+
output: {
|
|
358
|
+
schema: {
|
|
359
|
+
type: 'object',
|
|
360
|
+
properties: {
|
|
361
|
+
total: { type: 'number' },
|
|
362
|
+
returned: { type: 'number' },
|
|
363
|
+
hasMore: { type: 'boolean' },
|
|
364
|
+
entries: { type: 'array', items: { type: 'object' } },
|
|
365
|
+
},
|
|
366
|
+
additionalProperties: true,
|
|
367
|
+
},
|
|
368
|
+
render: () => [{ type: 'text', text: 'dsh_credential_vault_read' }],
|
|
369
|
+
},
|
|
370
|
+
async execute(args) {
|
|
371
|
+
const a = args !== null && typeof args === 'object' ? args : {}
|
|
372
|
+
const query = typeof a.query === 'string' ? a.query : ''
|
|
373
|
+
const category = typeof a.category === 'string' ? a.category : 'all'
|
|
374
|
+
const mode = a.mode === 'summary' ? 'summary' : 'full'
|
|
375
|
+
// revealSecrets is intentionally ignored: plaintext never reaches
|
|
376
|
+
// the Host, so there is nothing to reveal. Kept for compatibility.
|
|
377
|
+
const limit = Math.max(1, Math.min(MAX_LIMIT, Number.isFinite(a.limit) ? Math.floor(a.limit) : DEFAULT_LIMIT))
|
|
378
|
+
const offset = Math.max(0, Number.isFinite(a.offset) ? Math.floor(a.offset) : 0)
|
|
379
|
+
const all = Array.isArray(snapshot.entries) ? snapshot.entries : []
|
|
380
|
+
const filtered = all.filter((e) => matches(e, query, category))
|
|
381
|
+
const page = filtered.slice(offset, offset + limit)
|
|
382
|
+
recordAudit({ tool: 'dsh_credential_vault_read', action: 'read', category, query: query || undefined, count: page.length })
|
|
383
|
+
return {
|
|
384
|
+
total: filtered.length,
|
|
385
|
+
returned: page.length,
|
|
386
|
+
offset,
|
|
387
|
+
limit,
|
|
388
|
+
hasMore: offset + page.length < filtered.length,
|
|
389
|
+
updatedAt: snapshot.updatedAt,
|
|
390
|
+
entries: page.map((e) => projectEntry(e, mode)),
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
{},
|
|
395
|
+
)
|
|
396
|
+
return typeof dispose === 'function' ? dispose : () => {}
|
|
397
|
+
}, 'dsh-credential-vault-read-tool')
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const systemPrompt = typeof ctx.get === 'function' ? ctx.get('systemPrompt') : undefined
|
|
401
|
+
if (systemPrompt !== undefined && systemPrompt !== null && typeof systemPrompt.section === 'function') {
|
|
402
|
+
ctx.effect(() => {
|
|
403
|
+
systemPrompt.section({
|
|
404
|
+
name: 'tool:dsh-credential-vault',
|
|
405
|
+
order: 118,
|
|
406
|
+
text:
|
|
407
|
+
'凭据保险箱:用户把账号密码、API Key、微信公众号 / 小程序开发信息、恢复码等保存在侧边栏「凭据保险箱」里。需要知道有哪些凭据时用 dsh_credential_vault_read 工具(按 query / category 过滤,category 可选 account / apikey / other / wechatMp / wechatMini;数据多时先用 mode="summary" 看标题清单,再用 limit/offset 翻页)。出于安全,该工具只返回元数据——密码 / API Key / AppSecret / Token / 上传密钥等一律显示为 ••••••••,明文只留在浏览器内、不会进入模型上下文,revealSecrets 参数已失效。不要向用户索要明文密钥;需要用到具体密钥时,请让用户自行在侧边栏面板中查看或复制。',
|
|
408
|
+
})
|
|
409
|
+
return () => {}
|
|
410
|
+
}, 'dsh-credential-vault-prompt')
|
|
411
|
+
}
|
|
412
|
+
}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Credential vault",
|
|
4
|
-
"description": "Store accounts, passwords and API keys locally. Secrets stay in your browser — the agent sees metadata only, nothing is written to disk."
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Credential vault",
|
|
4
|
+
"description": "Store accounts, passwords and API keys locally. Secrets stay in your browser — the agent sees metadata only, nothing is written to disk."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "凭据保险箱",
|
|
4
|
-
"description": "本机集中管理账号、密码和 API Key。明文只留浏览器,模型仅见元数据,不落盘。"
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "凭据保险箱",
|
|
4
|
+
"description": "本机集中管理账号、密码和 API Key。明文只留浏览器,模型仅见元数据,不落盘。"
|
|
5
|
+
}
|
|
6
|
+
}
|
package/package.json
CHANGED