@mysterycode-liwen/dsh-credential-vault 1.5.1 → 1.5.3

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.
Files changed (4) hide show
  1. package/README.md +13 -1
  2. package/client.js +177 -14
  3. package/index.js +3 -3
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -126,6 +126,18 @@ Host 侧工具在 Harness 启动时注册。重启 Harness,或在插件管理
126
126
 
127
127
  ## 更新日志 / Changelog
128
128
 
129
+ ### 1.5.3 — 2026-11-28 — 关联凭据改为可搜索下拉框
130
+
131
+ - **关联凭据编辑器改为下拉多选框**:点击展开浮层,顶部可按名称实时搜索;提供「全部 / API Key / 密钥 / 其他」类型筛选 chips,快速定位目标凭据。
132
+ - **已选更直观**:已关联项以 chip 展示在触发框下方可逐个移除,并支持一键清空;点击外部自动收起浮层。
133
+ - 数据格式与 1.5.2 完全一致,旧数据/导出文件无需迁移。
134
+
135
+ ### 1.5.2 — 2026-11-28 — 账号关联凭据与类型改名
136
+
137
+ - **账号可关联其它凭据**:账号类型新增「关联凭据」字段,编辑时多选已有的 API Key / 密钥 / 其他凭据(不含账号自身);卡片上以可点击标签展示,点击直接跳转定位。
138
+ - **关联无损**:关联关系随 JSON / CSV / Markdown 三格式无损导回(显示为 `标题(id)`),删除凭据时自动清理其它条目对它的引用,不留死链。
139
+ - **「通用密钥」改名为「密钥」**:界面显示名全部更新,内部类型 key 保持 `secretKey`;旧导出文件中的「通用密钥」标签仍兼容识别。
140
+
129
141
  ### 1.5.1 — 2026-11-28 — 新增「通用密钥」类型
130
142
 
131
143
  - **新增凭据类型「通用密钥」**(`secretKey`):标题 + 密钥名称 + 密钥值 + 备注,适合保存零散的 token / secret / 口令,密钥值默认脱敏。
@@ -186,7 +198,7 @@ Host 侧工具在 Harness 启动时注册。重启 Harness,或在插件管理
186
198
  npm run check # 发布前自检:client.js 的模块 id 与 cordis.patch.yml 的 name 必须等于包名
187
199
  npm pack --dry-run # 核对实际打包的文件清单
188
200
  npm publish # publishConfig.access = public;会先自动跑一次 npm run check,不一致则中止
189
- git tag v1.4.2 && git push --tags
201
+ git tag v1.5.2 && git push --tags
190
202
  ```
191
203
 
192
204
  `client.js` 里 `window.__ModuleLoader__.load({ id })` 的 `id` **必须等于 `package.json` 的 `name`**:DSH 按包名去浏览器模块表里查找,不一致时浏览器端不会挂载,表现为侧边栏入口与设置页整块消失(Host 端仍然正常)。改包名或改 scope 时,三处要同步:`package.json` 的 `name`、`client.js` 的 `id`、`cordis.patch.yml` 的 `name`。
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.5.1';
18
+ var VERSION = '1.5.3';
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
@@ -62,6 +62,7 @@ window.__ModuleLoader__.load({
62
62
  fExpiry: 'Expires on (optional)',
63
63
  fContent: 'Content / secret', fContentPh: 'Recovery codes, license key, certificate, PIN…',
64
64
  fNotes: 'Notes (optional)', fNotesPh: 'Any extra info…',
65
+ fLinks: 'Linked credentials', linkNone: 'No API Key / Key / Other credentials yet', linkMissing: 'Linked credential no longer exists', linkPlaceholder: 'Select credentials…', linkSearch: 'Search by name…', linkSelected: 'selected', linkNoMatch: 'No matching credentials', linkClear: 'Clear',
65
66
  fAppId: 'AppID', fAppIdPh: 'wx…',
66
67
  fAppSecret: 'AppSecret', fAppSecretPh: 'Application secret',
67
68
  fToken: 'Server Token', fTokenPh: 'Token from server config',
@@ -169,7 +170,7 @@ window.__ModuleLoader__.load({
169
170
  sort: '排序', sortRecent: '最近更新', sortTitle: '名称(A–Z)', sortCategory: '类型',
170
171
  search: '搜索名称、账号、网址或备注…',
171
172
  filterAll: '全部', filterAccount: '账号密码', filterApikey: 'API Key', filterOther: '其他',
172
- filterWechatMp: '微信公众号', filterWechatMini: '微信小程序', filterSecretKey: '通用密钥',
173
+ filterWechatMp: '微信公众号', filterWechatMini: '微信小程序', filterSecretKey: '密钥',
173
174
  localNotice: '数据仅保存在本机浏览器的 localStorage 中,不跨设备同步、不加密,请避免在公用/共享浏览器使用。',
174
175
  show: '显示', hide: '隐藏', copy: '复制', visit: '访问', copied: '已复制到剪贴板', copyFail: '复制失败,请手动选择文本',
175
176
  visitFail: '无法打开浏览器,请检查网址后重试。',
@@ -191,6 +192,7 @@ window.__ModuleLoader__.load({
191
192
  fExpiry: '到期日期(可选)',
192
193
  fContent: '内容 / 密钥', fContentPh: '恢复码、许可证、证书、PIN…',
193
194
  fNotes: '备注(可选)', fNotesPh: '其他信息…',
195
+ fLinks: '关联凭据', linkNone: '还没有 API Key / 密钥 / 其他凭据', linkMissing: '关联的凭据已不存在', linkPlaceholder: '选择凭据…', linkSearch: '按名称搜索…', linkSelected: '项已选', linkNoMatch: '没有匹配的凭据', linkClear: '清空',
194
196
  fAppId: 'AppID', fAppIdPh: 'wx…',
195
197
  fAppSecret: 'AppSecret', fAppSecretPh: '应用密钥',
196
198
  fToken: '服务器 Token', fTokenPh: '服务器配置里的 Token',
@@ -201,7 +203,7 @@ window.__ModuleLoader__.load({
201
203
  fKeyName: '密钥名称', fKeyNamePh: '例如:访问令牌、Webhook 密钥',
202
204
  fKeyValue: '密钥值', fKeyValuePh: '粘贴令牌 / 密钥 / 口令',
203
205
  catAccount: '账号密码', catApikey: 'API Key', catOther: '其他',
204
- catWechatMp: '微信公众号', catWechatMini: '微信小程序', catSecretKey: '通用密钥',
206
+ catWechatMp: '微信公众号', catWechatMini: '微信小程序', catSecretKey: '密钥',
205
207
  hintAccount: '用于保存网站 / 应用的登录账号与密码。',
206
208
  hintApikey: '用于保存平台签发的 API Key、令牌与接口地址。',
207
209
  hintOther: '用于保存恢复码、许可证、证书等任意文本。',
@@ -303,6 +305,7 @@ window.__ModuleLoader__.load({
303
305
  { key: 'username', label: 'fAccount', ph: 'fAccountPh', type: 'text', mono: true },
304
306
  { key: 'password', label: 'fPassword', ph: 'fPasswordPh', type: 'secret', mono: true, generatable: true },
305
307
  { key: 'url', label: 'fUrl', ph: 'fUrlPh', type: 'text', isUrl: true },
308
+ { key: 'links', label: 'fLinks', type: 'links' },
306
309
  { key: 'notes', label: 'fNotes', ph: 'fNotesPh', type: 'textarea' }
307
310
  ],
308
311
  apikey: [
@@ -425,6 +428,31 @@ window.__ModuleLoader__.load({
425
428
  '.cv-badge-wechatMp{background:#07c160;color:#fff}',
426
429
  '.cv-badge-wechatMini{background:#10aec2;color:#fff}',
427
430
  '.cv-badge-secretKey{background:#8b5cf6;color:#fff}',
431
+ '.cv-links{margin:10px 0 2px;padding-top:8px;border-top:1px dashed var(--cv-b1)}',
432
+ '.cv-link-chip{display:inline-flex;align-items:center;gap:3px;margin:3px 5px 0 0;padding:4px 9px;border:1px solid var(--cv-b1);border-radius:999px;background:var(--cv-l2);color:var(--cv-brand);font-size:11.5px;cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
433
+ '.cv-link-chip:hover{border-color:var(--cv-brand)}',
434
+ '.cv-link-picker{position:relative}',
435
+ '.cv-link-picker-top{display:flex;gap:6px;align-items:center}',
436
+ '.cv-link-trigger{flex:1;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:9px 12px;border-radius:9px;border:1px solid var(--cv-b1);background:var(--cv-l1);color:var(--cv-t1);font-size:13px;cursor:pointer;text-align:left}',
437
+ '.cv-link-trigger:hover{border-color:var(--cv-b2)}',
438
+ '.cv-link-trigger-on{border-color:var(--cv-brand)}',
439
+ '.cv-link-caret{color:var(--cv-t2);font-size:11px}',
440
+ '.cv-link-clear{border:none;background:var(--cv-l2);color:var(--cv-t2);border-radius:7px;width:30px;height:30px;cursor:pointer;font-size:16px;line-height:1}',
441
+ '.cv-link-selected{display:flex;flex-wrap:wrap;gap:5px;margin-top:7px}',
442
+ '.cv-link-sel-chip{display:inline-flex;align-items:center;gap:3px;padding:4px 6px 4px 9px;border-radius:999px;background:var(--cv-l2);border:1px solid var(--cv-b1);color:var(--cv-brand);font-size:11.5px;max-width:100%}',
443
+ '.cv-link-sel-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:180px}',
444
+ '.cv-link-sel-x{border:none;background:transparent;color:var(--cv-t2);cursor:pointer;font-size:14px;line-height:1;padding:0 2px}',
445
+ '.cv-link-sel-x:hover{color:var(--cv-err)}',
446
+ '.cv-link-popover{position:absolute;z-index:30;left:0;right:0;top:calc(100% + 6px);padding:9px;border:1px solid var(--cv-b1);border-radius:10px;background:var(--cv-bg);box-shadow:0 8px 24px rgba(0,0,0,.16)}',
447
+ '.cv-link-search{width:100%;padding:8px 10px;font-size:12.5px}',
448
+ '.cv-link-typechips{display:flex;gap:5px;flex-wrap:wrap;margin:8px 0}',
449
+ '.cv-link-typechip{padding:4px 10px;border-radius:999px;border:1px solid var(--cv-b1);background:transparent;color:var(--cv-t2);font-size:11.5px;cursor:pointer}',
450
+ '.cv-link-typechip:hover{background:var(--cv-l2)}',
451
+ '.cv-link-typechip-on{background:var(--cv-brand);border-color:var(--cv-brand);color:var(--cv-bg)}',
452
+ '.cv-link-options{max-height:170px;overflow:auto;border:1px solid var(--cv-b1);border-radius:8px;padding:6px 9px;background:var(--cv-l1)}',
453
+ '.cv-link-opt{display:flex;align-items:center;gap:7px;padding:5px 2px;font-size:12.5px;cursor:pointer}',
454
+ '.cv-link-opt:hover{background:var(--cv-l2)}',
455
+ '.cv-link-empty{font-size:12px;color:var(--cv-t2);padding:8px 2px}',
428
456
  '.cv-card-title{font-weight:600;font-size:14.5px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
429
457
  '.cv-card-actions{display:flex;gap:4px}',
430
458
  '.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}',
@@ -569,6 +597,17 @@ window.__ModuleLoader__.load({
569
597
  if (n.provider == null && n.username) n.provider = n.username;
570
598
  if (n.endpoint == null && n.url) n.endpoint = n.url;
571
599
  }
600
+ // Links are credential IDs. Accept arrays, the human-readable "Title(id)"
601
+ // form used in CSV/Markdown exports, and the legacy comma-separated form.
602
+ if (Array.isArray(n.links)) {
603
+ n.links = n.links.map(function (x) { return String(x); }).filter(Boolean);
604
+ } else if (typeof n.links === 'string' && n.links.trim()) {
605
+ var ids = [], lm, lre = /[((]([^())]+)[))]/g;
606
+ while ((lm = lre.exec(n.links)) !== null) ids.push(lm[1].trim());
607
+ n.links = ids.length ? ids : n.links.split(/[,,、]/).map(function (x) { return x.trim(); }).filter(Boolean);
608
+ } else {
609
+ delete n.links;
610
+ }
572
611
  return sanitize(n);
573
612
  }
574
613
  function loadEntries() {
@@ -596,7 +635,7 @@ window.__ModuleLoader__.load({
596
635
  // Large vaults: DEBOUNCE so a burst of edits results in one POST, not dozens
597
636
  // of multi-megabyte payloads. A trailing timer always flushes the latest data.
598
637
  var MIRROR_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'keyName', 'url', 'endpoint', 'expiry',
599
- 'appId', 'serverUrl', 'domains', 'notes', 'createdAt', 'updatedAt'];
638
+ 'appId', 'serverUrl', 'domains', 'notes', 'links', 'createdAt', 'updatedAt'];
600
639
  var MIRROR_SECRETS = ['password', 'apiKey', 'content', 'appSecret', 'token', 'encodingAesKey', 'uploadKey', 'keyValue'];
601
640
  function toEnvelope(entry) {
602
641
  var out = {};
@@ -775,7 +814,7 @@ window.__ModuleLoader__.load({
775
814
  }
776
815
  var EXPORT_COLS = ['id', 'title', 'category', 'username', 'password', 'url', 'provider', 'apiKey', 'endpoint', 'expiry', 'content', 'keyName', 'keyValue',
777
816
  'appId', 'appSecret', 'token', 'encodingAesKey', 'serverUrl', 'uploadKey', 'domains',
778
- 'notes', 'createdAt', 'updatedAt'];
817
+ 'notes', 'links', 'createdAt', 'updatedAt'];
779
818
 
780
819
  // ---- Human-readable labels ------------------------------------------------
781
820
  // CSV/Markdown use Chinese labels for people; every label maps back to its
@@ -786,18 +825,19 @@ window.__ModuleLoader__.load({
786
825
  expiry: '有效期', content: '内容', keyName: '密钥名称', keyValue: '密钥值',
787
826
  appId: 'AppID', appSecret: 'AppSecret', token: '服务器Token', encodingAesKey: 'EncodingAESKey',
788
827
  serverUrl: '服务器地址', uploadKey: '代码上传密钥', domains: '服务器域名',
789
- notes: '备注', createdAt: '创建时间', updatedAt: '更新时间'
828
+ notes: '备注', links: '关联凭据', createdAt: '创建时间', updatedAt: '更新时间'
790
829
  };
791
830
  var LABEL_FIELDS = {};
792
831
  Object.keys(FIELD_LABELS).forEach(function (k) { LABEL_FIELDS[FIELD_LABELS[k]] = k; });
793
- var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', secretKey: '通用密钥', other: '其他', wechatMp: '微信公众号', wechatMini: '微信小程序' };
832
+ var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', secretKey: '密钥', other: '其他', wechatMp: '微信公众号', wechatMini: '微信小程序' };
794
833
  var LABEL_CATEGORIES = {};
795
834
  Object.keys(CATEGORY_LABELS).forEach(function (k) { LABEL_CATEGORIES[CATEGORY_LABELS[k]] = k; });
835
+ LABEL_CATEGORIES['通用密钥'] = 'secretKey'; // legacy exports before the rename
796
836
  // Only export fields that belong to the entry's type. A record may carry
797
837
  // stale fields from a past type change (e.g. an API Key with leftover
798
838
  // username/password/url); those must not leak into readable exports.
799
839
  var VISIBLE_FIELDS = {
800
- account: ['title', 'username', 'password', 'url', 'notes'],
840
+ account: ['title', 'username', 'password', 'url', 'links', 'notes'],
801
841
  apikey: ['title', 'provider', 'apiKey', 'endpoint', 'expiry', 'notes'],
802
842
  secretKey: ['title', 'keyName', 'keyValue', 'notes'],
803
843
  other: ['title', 'content', 'notes'],
@@ -829,12 +869,20 @@ window.__ModuleLoader__.load({
829
869
  var d = new Date(Number(v));
830
870
  return isNaN(d.getTime()) ? String(v) : d.toISOString();
831
871
  }
872
+ // Render links as "Linked title(id)" so exports stay readable AND re-importable.
873
+ function formatLinks(links, arr) {
874
+ if (!Array.isArray(links) || !links.length) return '';
875
+ return links.map(function (id) {
876
+ var target = arr.filter(function (x) { return x.id === id; })[0];
877
+ return target && target.title ? target.title + '(' + id + ')' : String(id);
878
+ }).join('、');
879
+ }
832
880
  // CSV shows the fields people actually read first; technical columns
833
881
  // (ID / timestamps) go last. Import maps by header label, so order is safe.
834
882
  var CSV_COLS = ['title', 'category', 'username', 'password', 'url', 'provider',
835
883
  'apiKey', 'endpoint', 'expiry', 'content', 'keyName', 'keyValue',
836
884
  'appId', 'appSecret', 'token', 'encodingAesKey', 'serverUrl', 'uploadKey', 'domains',
837
- 'notes', 'id', 'createdAt', 'updatedAt'];
885
+ 'notes', 'links', 'id', 'createdAt', 'updatedAt'];
838
886
  function buildCsv(arr) {
839
887
  var lines = [CSV_COLS.map(function (c) { return csvEscape(FIELD_LABELS[c] || c); }).join(',')];
840
888
  arr.forEach(function (e) {
@@ -845,6 +893,7 @@ window.__ModuleLoader__.load({
845
893
  // do not belong to this type are left blank.
846
894
  if (visible.indexOf(c) < 0 && c !== 'id' && c !== 'category' && c !== 'createdAt' && c !== 'updatedAt') return '';
847
895
  var v = (c === 'createdAt' || c === 'updatedAt') ? csvDate(n[c]) : n[c];
896
+ if (c === 'links') v = formatLinks(n.links, arr);
848
897
  if (c === 'category') v = CATEGORY_LABELS[v] || v;
849
898
  return csvEscape(v);
850
899
  }).join(','));
@@ -959,6 +1008,7 @@ window.__ModuleLoader__.load({
959
1008
  fieldsFor(n.category).forEach(function (c) {
960
1009
  if (c === 'title') return;
961
1010
  var v = n[c];
1011
+ if (c === 'links') v = formatLinks(n.links, arr);
962
1012
  if (v == null || v === '') return;
963
1013
  lines.push('| ' + (FIELD_LABELS[c] || c) + ' | ' + mdCell(v) + ' |');
964
1014
  });
@@ -1298,6 +1348,7 @@ window.__ModuleLoader__.load({
1298
1348
  username: '', password: '', url: '',
1299
1349
  provider: '', apiKey: '', endpoint: '', expiry: '',
1300
1350
  content: '', keyName: '', keyValue: '',
1351
+ links: [],
1301
1352
  appId: '', appSecret: '', token: '', encodingAesKey: '', serverUrl: '', uploadKey: '', domains: '',
1302
1353
  notes: ''
1303
1354
  };
@@ -1364,6 +1415,15 @@ window.__ModuleLoader__.load({
1364
1415
  var cat = e.category || 'account';
1365
1416
  var catMeta = CATEGORIES.filter(function (c) { return c.k === cat; })[0];
1366
1417
  var catLabel = catMeta ? t(catMeta.label) : t('catAccount');
1418
+ var linkChips = Array.isArray(e.links) && e.links.length ? e.links.map(function (id) {
1419
+ var target = (props.entries || []).filter(function (x) { return x.id === id; })[0];
1420
+ if (!target) return null;
1421
+ var tc = CATEGORIES.filter(function (c) { return c.k === target.category; })[0];
1422
+ return h('button', {
1423
+ key: id, className: 'cv-link-chip', title: target.title,
1424
+ onClick: function () { props.onGo(id); }
1425
+ }, '🔗 ' + target.title + (tc ? ' · ' + t(tc.label) : ''));
1426
+ }).filter(Boolean) : [];
1367
1427
  return h('div', { className: 'cv-card' },
1368
1428
  h('div', { className: 'cv-card-head' },
1369
1429
  h('span', { className: 'cv-badge cv-badge-' + cat }, catLabel),
@@ -1375,13 +1435,16 @@ window.__ModuleLoader__.load({
1375
1435
  ),
1376
1436
  h('div', { className: 'cv-card-body' },
1377
1437
  schemaOf(cat).slice(1).map(function (f) {
1438
+ if (f.key === 'links') return null;
1378
1439
  if (!e[f.key]) return null;
1379
1440
  return h(Field, {
1380
1441
  key: f.key, t: t, label: f.label, value: e[f.key],
1381
1442
  mono: !!f.mono, secret: isSecretField(f), multiline: isMultilineField(f), isUrl: !!f.isUrl,
1382
1443
  revealed: !!props.revealed, onToggle: props.onToggle, onCopy: props.onCopy, onVisit: props.onVisit
1383
1444
  });
1384
- })
1445
+ }),
1446
+ linkChips.length ? h('div', { className: 'cv-links' },
1447
+ h('div', { className: 'cv-field-label' }, t('fLinks')), linkChips) : null
1385
1448
  )
1386
1449
  );
1387
1450
  }
@@ -1395,11 +1458,22 @@ window.__ModuleLoader__.load({
1395
1458
 
1396
1459
  // Only the essential fields show by default; the rest fold behind a
1397
1460
  // "More fields" toggle so short forms stay short and long forms compact.
1398
- var PRIMARY_KEYS = { title: 1, username: 1, password: 1, apiKey: 1, appId: 1, appSecret: 1, content: 1, keyName: 1, keyValue: 1 };
1461
+ var PRIMARY_KEYS = { title: 1, username: 1, password: 1, apiKey: 1, appId: 1, appSecret: 1, content: 1, keyName: 1, keyValue: 1, links: 1 };
1399
1462
  var primary = fields.filter(function (f) { return PRIMARY_KEYS[f.key]; });
1400
1463
  var secondary = fields.filter(function (f) { return !PRIMARY_KEYS[f.key]; });
1401
1464
  var hasSecondary = secondary.some(function (f) { return !!d[f.key]; });
1402
1465
  var moreState = useState(hasSecondary), showMore = moreState[0], setShowMore = moreState[1];
1466
+ // Link picker: dropdown with search + type filter (account "linked credentials").
1467
+ var lkOpenState = useState(false), linksOpen = lkOpenState[0], setLinksOpen = lkOpenState[1];
1468
+ var lkQueryState = useState(''), linkQuery = lkQueryState[0], setLinkQuery = lkQueryState[1];
1469
+ var lkTypeState = useState('all'), linkType = lkTypeState[0], setLinkType = lkTypeState[1];
1470
+ var lkRef = useRef(null);
1471
+ useEffect(function () {
1472
+ if (!linksOpen) return;
1473
+ function onDoc(ev) { if (lkRef.current && !lkRef.current.contains(ev.target)) setLinksOpen(false); }
1474
+ document.addEventListener('mousedown', onDoc);
1475
+ return function () { document.removeEventListener('mousedown', onDoc); };
1476
+ }, [linksOpen]);
1403
1477
 
1404
1478
  function baseInput(f, extra) {
1405
1479
  return Object.assign({
@@ -1410,11 +1484,87 @@ window.__ModuleLoader__.load({
1410
1484
  }, extra || {});
1411
1485
  }
1412
1486
  // Multiline fields and long values get a full row; everything else pairs up.
1413
- var WIDE_KEYS = { content: 1, notes: 1, endpoint: 1, serverUrl: 1, uploadKey: 1, domains: 1, encodingAesKey: 1 };
1487
+ var WIDE_KEYS = { content: 1, notes: 1, endpoint: 1, serverUrl: 1, uploadKey: 1, domains: 1, encodingAesKey: 1, links: 1 };
1414
1488
  function isWide(f) { return f.type === 'textarea' || f.type === 'secretarea' || !!WIDE_KEYS[f.key]; }
1415
1489
  function renderField(f) {
1416
1490
  var control;
1417
- if (f.type === 'text' || f.type === 'date') {
1491
+ if (f.type === 'links') {
1492
+ var candidates = (props.entries || []).filter(function (x) {
1493
+ return x.id !== d.id && ['apikey', 'secretKey', 'other'].indexOf(x.category) >= 0;
1494
+ });
1495
+ var selected = Array.isArray(d.links) ? d.links : [];
1496
+ function toggleLink(id) {
1497
+ var next = selected.indexOf(id) >= 0
1498
+ ? selected.filter(function (lid) { return lid !== id; })
1499
+ : selected.concat([id]);
1500
+ onChange('links', next);
1501
+ }
1502
+ var typeOpts = [
1503
+ { k: 'all', label: 'filterAll' },
1504
+ { k: 'apikey', label: 'filterApikey' },
1505
+ { k: 'secretKey', label: 'filterSecretKey' },
1506
+ { k: 'other', label: 'filterOther' }
1507
+ ];
1508
+ var shown = candidates.filter(function (x) {
1509
+ if (linkType !== 'all' && x.category !== linkType) return false;
1510
+ var q = linkQuery.trim().toLowerCase();
1511
+ return !q || String(x.title || '').toLowerCase().indexOf(q) >= 0;
1512
+ });
1513
+ control = h('div', { className: 'cv-link-picker', ref: lkRef },
1514
+ h('div', { className: 'cv-link-picker-top' },
1515
+ h('button', {
1516
+ type: 'button', className: 'cv-link-trigger' + (linksOpen ? ' cv-link-trigger-on' : ''),
1517
+ onClick: function () { setLinksOpen(!linksOpen); }
1518
+ },
1519
+ h('span', null, selected.length ? (selected.length + ' ' + t('linkSelected')) : t('linkPlaceholder')),
1520
+ h('span', { className: 'cv-link-caret' }, linksOpen ? '▴' : '▾')
1521
+ ),
1522
+ selected.length ? h('button', {
1523
+ type: 'button', className: 'cv-link-clear', title: t('linkClear'),
1524
+ onClick: function () { onChange('links', []); }
1525
+ }, '×') : null
1526
+ ),
1527
+ selected.length ? h('div', { className: 'cv-link-selected' },
1528
+ selected.map(function (id) {
1529
+ var tgt = candidates.filter(function (x) { return x.id === id; })[0];
1530
+ var label = tgt ? tgt.title : t('linkMissing');
1531
+ return h('span', { key: id, className: 'cv-link-sel-chip', title: label },
1532
+ h('span', { className: 'cv-link-sel-text' }, '🔗 ' + label),
1533
+ h('button', {
1534
+ type: 'button', className: 'cv-link-sel-x', title: t('linkClear'),
1535
+ onClick: function () { toggleLink(id); }
1536
+ }, '×')
1537
+ );
1538
+ })
1539
+ ) : null,
1540
+ linksOpen ? h('div', { className: 'cv-link-popover' },
1541
+ h('input', {
1542
+ className: 'cv-input cv-link-search', type: 'text',
1543
+ placeholder: t('linkSearch'), value: linkQuery,
1544
+ onChange: function (ev) { setLinkQuery(ev.target.value); }
1545
+ }),
1546
+ h('div', { className: 'cv-link-typechips' },
1547
+ typeOpts.map(function (o) {
1548
+ return h('button', {
1549
+ type: 'button', key: o.k,
1550
+ className: 'cv-link-typechip' + (linkType === o.k ? ' cv-link-typechip-on' : ''),
1551
+ onClick: function () { setLinkType(o.k); }
1552
+ }, t(o.label));
1553
+ })
1554
+ ),
1555
+ h('div', { className: 'cv-link-options' },
1556
+ shown.length ? shown.map(function (x) {
1557
+ var checked = selected.indexOf(x.id) >= 0;
1558
+ var cm = CATEGORIES.filter(function (c) { return c.k === x.category; })[0];
1559
+ return h('label', { key: x.id, className: 'cv-link-opt' },
1560
+ h('input', { type: 'checkbox', checked: checked, onChange: function () { toggleLink(x.id); } }),
1561
+ h('span', null, x.title + (cm ? ' · ' + t(cm.label) : ''))
1562
+ );
1563
+ }) : h('span', { className: 'cv-link-empty' }, t('linkNoMatch'))
1564
+ )
1565
+ ) : null
1566
+ );
1567
+ } else if (f.type === 'text' || f.type === 'date') {
1418
1568
  control = h('input', baseInput(f, { type: f.type === 'date' ? 'date' : 'text' }));
1419
1569
  } else if (f.type === 'textarea') {
1420
1570
  control = h('textarea', baseInput(f, { className: 'cv-input cv-textarea' }));
@@ -2442,7 +2592,12 @@ window.__ModuleLoader__.load({
2442
2592
  }
2443
2593
  function delEntry(id) {
2444
2594
  if (!window.confirm(t('confirmDelete'))) return;
2445
- setEntries(function (prev) { return prev.filter(function (x) { return x.id !== id; }); });
2595
+ setEntries(function (prev) {
2596
+ return prev.filter(function (x) { return x.id !== id; }).map(function (x) {
2597
+ if (!Array.isArray(x.links) || x.links.indexOf(id) < 0) return x;
2598
+ return Object.assign({}, x, { links: x.links.filter(function (lid) { return lid !== id; }) });
2599
+ });
2600
+ });
2446
2601
  setToast(t('deleted'));
2447
2602
  }
2448
2603
  function doExport() {
@@ -2476,6 +2631,12 @@ window.__ModuleLoader__.load({
2476
2631
  setGenTarget(null);
2477
2632
  setToast(t('copied'));
2478
2633
  }
2634
+ function goToEntry(id) {
2635
+ var target = entries.filter(function (x) { return x.id === id; })[0];
2636
+ if (!target) { setToast(t('linkMissing')); return; }
2637
+ setFilter('all');
2638
+ setQuery(target.title || '');
2639
+ }
2479
2640
  function auditEditEntry(id) {
2480
2641
  var e = entries.filter(function (x) { return x.id === id; })[0];
2481
2642
  setAuditing(false);
@@ -2552,6 +2713,7 @@ window.__ModuleLoader__.load({
2552
2713
  : list.map(function (e) {
2553
2714
  return h(Card, {
2554
2715
  key: e.id, entry: e, t: t, revealed: !!revealed[e.id],
2716
+ entries: entries, onGo: goToEntry,
2555
2717
  onToggle: function () { toggleReveal(e.id); },
2556
2718
  onEdit: function () { openEdit(e); },
2557
2719
  onDelete: function () { delEntry(e.id); },
@@ -2564,6 +2726,7 @@ window.__ModuleLoader__.load({
2564
2726
  ),
2565
2727
  editing ? h(EditorModal, {
2566
2728
  t: t, draft: editing.draft, titleKey: editing.mode === 'new' ? 'editorNew' : 'editorEdit',
2729
+ entries: entries,
2567
2730
  onChange: setDraftField, onSave: saveDraft, onCancel: function () { setEditing(null); },
2568
2731
  onGenerate: function (field) { setGenTarget({ field: field }); }
2569
2732
  }) : null,
package/index.js CHANGED
@@ -46,7 +46,7 @@ const MAX_LIMIT = 200
46
46
  const SUMMARY_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'expiry', 'updatedAt']
47
47
 
48
48
  /** Current plugin version. Keep in sync with package.json when releasing. */
49
- const CURRENT_VERSION = '1.5.1'
49
+ const CURRENT_VERSION = '1.5.3'
50
50
 
51
51
  /** Where update checks read the latest published version from (GitHub Releases latest). */
52
52
  const RELEASES_API = 'https://api.github.com/repos/mysterycode-liwen/dsh-credential-vault/releases/latest'
@@ -63,7 +63,7 @@ let snapshot = { entries: [], updatedAt: 0 }
63
63
  * is dropped, so the Host can never hold a plaintext password / key / body.
64
64
  */
65
65
  const META_FIELDS = ['id', 'title', 'category', 'username', 'provider', 'keyName', 'url', 'endpoint', 'expiry',
66
- 'appId', 'serverUrl', 'domains', 'notes', 'createdAt', 'updatedAt']
66
+ 'appId', 'serverUrl', 'domains', 'notes', 'links', 'createdAt', 'updatedAt']
67
67
 
68
68
  /**
69
69
  * Force every incoming entry into a metadata-only shape. Applied defensively on
@@ -404,7 +404,7 @@ export function apply(ctx) {
404
404
  name: 'tool:dsh-credential-vault',
405
405
  order: 118,
406
406
  text:
407
- '凭据保险箱:用户把账号密码、API Key、微信公众号 / 小程序开发信息、通用密钥、恢复码等保存在侧边栏「凭据保险箱」里。需要知道有哪些凭据时用 dsh_credential_vault_read 工具(按 query / category 过滤,category 可选 account / apikey / secretKey / other / wechatMp / wechatMini;数据多时先用 mode="summary" 看标题清单,再用 limit/offset 翻页)。出于安全,该工具只返回元数据——密码 / API Key / 密钥值 / AppSecret / Token / 上传密钥等一律显示为 ••••••••,明文只留在浏览器内、不会进入模型上下文,revealSecrets 参数已失效。不要向用户索要明文密钥;需要用到具体密钥时,请让用户自行在侧边栏面板中查看或复制。',
407
+ '凭据保险箱:用户把账号密码、API Key、微信公众号 / 小程序开发信息、密钥、恢复码等保存在侧边栏「凭据保险箱」里。需要知道有哪些凭据时用 dsh_credential_vault_read 工具(按 query / category 过滤,category 可选 account / apikey / secretKey / other / wechatMp / wechatMini;数据多时先用 mode="summary" 看标题清单,再用 limit/offset 翻页)。出于安全,该工具只返回元数据——密码 / API Key / 密钥值 / AppSecret / Token / 上传密钥等一律显示为 ••••••••,明文只留在浏览器内、不会进入模型上下文,revealSecrets 参数已失效。不要向用户索要明文密钥;需要用到具体密钥时,请让用户自行在侧边栏面板中查看或复制。',
408
408
  })
409
409
  return () => {}
410
410
  }, 'dsh-credential-vault-prompt')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysterycode-liwen/dsh-credential-vault",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "DeepSeek Harness 侧边栏凭据保险箱:本地保存账号密码、API Key 与恢复码,支持访问密码、密保重置、闲置自动锁定,并提供默认脱敏的 Agent 读取工具。",