@mysterycode-liwen/dsh-credential-vault 1.5.2 → 1.6.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 CHANGED
@@ -126,6 +126,18 @@ Host 侧工具在 Harness 启动时注册。重启 Harness,或在插件管理
126
126
 
127
127
  ## 更新日志 / Changelog
128
128
 
129
+ ### 1.6.0 — 2026-11-28 — 跨插件加密数据接口
130
+
131
+ - 新增:浏览器内加密桥接 API(ECDH P-256 + AES-GCM,一次性会话),供本人开发的其它插件安全读取凭据——调用方需持有凭据保险箱插件,未安装时自动空转、不影响使用。
132
+ - 新增:通用客户端模块模板 `bridge/vault-bridge-client.js`(零依赖、随包发布),其它插件复制即可接入;支持按标题/类型查询真实密钥值。
133
+ - 新增:授权方 dsh-mail 已接入,「邮箱授权码」可从保险箱一键填入。
134
+
135
+ ### 1.5.3 — 2026-11-28 — 关联凭据改为可搜索下拉框
136
+
137
+ - **关联凭据编辑器改为下拉多选框**:点击展开浮层,顶部可按名称实时搜索;提供「全部 / API Key / 密钥 / 其他」类型筛选 chips,快速定位目标凭据。
138
+ - **已选更直观**:已关联项以 chip 展示在触发框下方可逐个移除,并支持一键清空;点击外部自动收起浮层。
139
+ - 数据格式与 1.5.2 完全一致,旧数据/导出文件无需迁移。
140
+
129
141
  ### 1.5.2 — 2026-11-28 — 账号关联凭据与类型改名
130
142
 
131
143
  - **账号可关联其它凭据**:账号类型新增「关联凭据」字段,编辑时多选已有的 API Key / 密钥 / 其他凭据(不含账号自身);卡片上以可点击标签展示,点击直接跳转定位。
@@ -0,0 +1,166 @@
1
+ /*
2
+ * vault-bridge-client.js — reusable client module for the DSH credential vault bridge
3
+ * ------------------------------------------------------------------------------
4
+ * Copy this whole file's contents into your plugin's client.js (inside
5
+ * factory(require)), or load it through your plugin's build step. ZERO deps:
6
+ * it only uses window.crypto.subtle, btoa/atob and TextEncoder/TextDecoder.
7
+ *
8
+ * WHY THIS EXISTS
9
+ * The vault keeps real secrets in its own browser localStorage. The Harness
10
+ * Host process only ever sees metadata (secrets are masked), so a plugin that
11
+ * needs a real value (e.g. a mail app password) must talk to the vault's
12
+ * browser-side bridge. This module does that.
13
+ *
14
+ * All payloads are encrypted with an ECDH (P-256) + AES-GCM session:
15
+ * 1. client.query(...) -> bridge.hello() = vault ephemeral public key + id
16
+ * 2. client generates its own ephemeral key pair, derives the shared AES key
17
+ * 3. client seals the query, vault decrypts / reads secrets / seals result
18
+ * 4. client opens the result with the same derived key.
19
+ * No plaintext and no long-lived key ever crosses the bridge. If the vault is
20
+ * not installed, isAvailable() is false and query() rejects NOT_INSTALLED —
21
+ * gate your UI on isAvailable() so the feature silently disappears.
22
+ *
23
+ * SECURITY NOTE
24
+ * The bridge is a same-document JS object. ECDH stops passive observers and
25
+ * other plugins from reading the payload, but a hostile script in the same
26
+ * document could still call the bridge as if it were your plugin. The vault
27
+ * never auto-authorises: each session is one-time use and expires in 60s.
28
+ *
29
+ * USAGE
30
+ * const vault = createVaultV1Client();
31
+ * if (vault.isAvailable()) {
32
+ * const entries = await vault.query({ category: 'account', title: 'qq' });
33
+ * const secret = vault.secretOf(entries[0]); // real password / key value
34
+ * }
35
+ *
36
+ * Node (tests): also exported via module.exports when available.
37
+ */
38
+
39
+ function createVaultV1Client(options) {
40
+ options = options || {};
41
+ var win = options.window || (typeof window !== 'undefined' ? window : null);
42
+ var BRIDGE_KEY = '@mysterycode-liwen/dsh-credential-vault/bridge/v1';
43
+
44
+ function cryptoObj() {
45
+ return (win && win.crypto) || (typeof globalThis !== 'undefined' && globalThis.crypto) || null;
46
+ }
47
+ function subtle() {
48
+ var c = cryptoObj();
49
+ return c && c.subtle ? c.subtle : null;
50
+ }
51
+ function randomFill(bytes) {
52
+ var c = cryptoObj();
53
+ if (!c || !c.getRandomValues) throw new Error('NO_CRYPTO');
54
+ c.getRandomValues(bytes);
55
+ return bytes;
56
+ }
57
+ function toB64u(bytes) {
58
+ var s = '';
59
+ for (var i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
60
+ var btoaFn = options.btoa || (typeof btoa === 'function' ? btoa : (win && win.btoa));
61
+ return btoaFn(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
62
+ }
63
+ function fromB64u(str) {
64
+ var s = String(str).replace(/-/g, '+').replace(/_/g, '/');
65
+ while (s.length % 4) s += '=';
66
+ var atobFn = options.atob || (typeof atob === 'function' ? atob : (win && win.atob));
67
+ var bin = atobFn(s), out = new Uint8Array(bin.length);
68
+ for (var i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
69
+ return out;
70
+ }
71
+ function enc(str) { return new TextEncoder().encode(str); }
72
+ function dec(bytes) { return new TextDecoder().decode(bytes); }
73
+
74
+ function bridge() {
75
+ if (!win || !win[BRIDGE_KEY]) return null;
76
+ var b = win[BRIDGE_KEY];
77
+ return b && b.version === 1 && typeof b.hello === 'function' && typeof b.query === 'function' ? b : null;
78
+ }
79
+
80
+ function generatePair(s) {
81
+ return s.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, ['deriveBits']);
82
+ }
83
+ function deriveKey(s, priv, peerJwk) {
84
+ return s.importKey('jwk', peerJwk, { name: 'ECDH', namedCurve: 'P-256' }, false, [])
85
+ .then(function (pub) { return s.deriveBits({ name: 'ECDH', public: pub }, priv, 256); })
86
+ .then(function (bits) { return s.importKey('raw', bits, { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']); });
87
+ }
88
+ function seal(s, key, obj) {
89
+ var iv = randomFill(new Uint8Array(12));
90
+ return s.encrypt({ name: 'AES-GCM', iv: iv }, key, enc(JSON.stringify(obj)))
91
+ .then(function (ct) { return { iv: toB64u(iv), ciphertext: toB64u(new Uint8Array(ct)) }; });
92
+ }
93
+ function open(s, key, payload) {
94
+ if (!payload || typeof payload.iv !== 'string' || typeof payload.ciphertext !== 'string') {
95
+ return Promise.reject(new Error('BAD_CIPHERTEXT'));
96
+ }
97
+ return s.decrypt({ name: 'AES-GCM', iv: fromB64u(payload.iv) }, key, fromB64u(payload.ciphertext))
98
+ .then(function (plain) { return JSON.parse(dec(new Uint8Array(plain))); });
99
+ }
100
+
101
+ function isAvailable() { return !!bridge(); }
102
+
103
+ function query(criteria) {
104
+ criteria = criteria || {};
105
+ var b = bridge();
106
+ if (!b) return Promise.reject(new Error('NOT_INSTALLED'));
107
+ var s = subtle();
108
+ if (!s) return Promise.reject(new Error('NO_CRYPTO'));
109
+ var vaultPub, sessionId, priv, aes;
110
+ return Promise.resolve(b.hello())
111
+ .then(function (hello) {
112
+ if (!hello || !hello.sessionId || !hello.publicKeyJwk) throw new Error('BAD_HELLO');
113
+ sessionId = hello.sessionId;
114
+ vaultPub = hello.publicKeyJwk;
115
+ return generatePair(s);
116
+ })
117
+ .then(function (kp) {
118
+ priv = kp.privateKey;
119
+ return s.exportKey('jwk', kp.publicKey);
120
+ })
121
+ .then(function (pubJwk) {
122
+ return deriveKey(s, priv, vaultPub).then(function (key) {
123
+ aes = key;
124
+ return seal(s, aes, {
125
+ category: criteria.category || 'all',
126
+ title: criteria.title || '',
127
+ limit: criteria.limit || 100
128
+ }).then(function (sealed) {
129
+ return b.query({
130
+ sessionId: sessionId,
131
+ publicKeyJwk: pubJwk,
132
+ iv: sealed.iv,
133
+ ciphertext: sealed.ciphertext
134
+ });
135
+ });
136
+ });
137
+ })
138
+ .then(function (result) {
139
+ if (!result) throw new Error('NO_RESPONSE');
140
+ if (result.error) throw new Error(result.error);
141
+ return open(s, aes, result);
142
+ })
143
+ .then(function (plain) { return plain && Array.isArray(plain.entries) ? plain.entries : []; });
144
+ }
145
+
146
+ function secretOf(entry) {
147
+ if (!entry) return '';
148
+ var keys = ['password', 'keyValue', 'apiKey', 'content', 'appSecret', 'token', 'encodingAesKey', 'uploadKey'];
149
+ for (var i = 0; i < keys.length; i++) {
150
+ if (typeof entry[keys[i]] === 'string' && entry[keys[i]]) return entry[keys[i]];
151
+ }
152
+ return '';
153
+ }
154
+
155
+ return {
156
+ version: 1,
157
+ isAvailable: isAvailable,
158
+ query: query,
159
+ secretOf: secretOf,
160
+ _debug: { toB64u: toB64u, fromB64u: fromB64u, deriveKey: deriveKey, seal: seal, open: open }
161
+ };
162
+ }
163
+
164
+ if (typeof module !== 'undefined' && module.exports) {
165
+ module.exports = { createVaultV1Client: createVaultV1Client };
166
+ }
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.2';
18
+ var VERSION = '1.6.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
@@ -62,7 +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',
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',
66
66
  fAppId: 'AppID', fAppIdPh: 'wx…',
67
67
  fAppSecret: 'AppSecret', fAppSecretPh: 'Application secret',
68
68
  fToken: 'Server Token', fTokenPh: 'Token from server config',
@@ -192,7 +192,7 @@ window.__ModuleLoader__.load({
192
192
  fExpiry: '到期日期(可选)',
193
193
  fContent: '内容 / 密钥', fContentPh: '恢复码、许可证、证书、PIN…',
194
194
  fNotes: '备注(可选)', fNotesPh: '其他信息…',
195
- fLinks: '关联凭据', linkNone: '还没有 API Key / 密钥 / 其他凭据', linkMissing: '关联的凭据已不存在',
195
+ fLinks: '关联凭据', linkNone: '还没有 API Key / 密钥 / 其他凭据', linkMissing: '关联的凭据已不存在', linkPlaceholder: '选择凭据…', linkSearch: '按名称搜索…', linkSelected: '项已选', linkNoMatch: '没有匹配的凭据', linkClear: '清空',
196
196
  fAppId: 'AppID', fAppIdPh: 'wx…',
197
197
  fAppSecret: 'AppSecret', fAppSecretPh: '应用密钥',
198
198
  fToken: '服务器 Token', fTokenPh: '服务器配置里的 Token',
@@ -431,9 +431,28 @@ window.__ModuleLoader__.load({
431
431
  '.cv-links{margin:10px 0 2px;padding-top:8px;border-top:1px dashed var(--cv-b1)}',
432
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
433
  '.cv-link-chip:hover{border-color:var(--cv-brand)}',
434
- '.cv-link-options{max-height:170px;overflow:auto;border:1px solid var(--cv-b1);border-radius:8px;padding:6px 9px;background:var(--cv-bg)}',
435
- '.cv-link-opt{display:flex;align-items:center;gap:7px;padding:4px 0;font-size:12.5px;cursor:pointer}',
436
- '.cv-link-empty{font-size:12px;color:var(--cv-t2)}',
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}',
437
456
  '.cv-card-title{font-weight:600;font-size:14.5px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
438
457
  '.cv-card-actions{display:flex;gap:4px}',
439
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}',
@@ -608,6 +627,117 @@ window.__ModuleLoader__.load({
608
627
  try { window.localStorage.setItem(STORAGE_KEY, JSON.stringify(arr)); } catch (e) {}
609
628
  syncToHost(arr);
610
629
  }
630
+
631
+ // ---- Cross-plugin encrypted bridge (ECDH P-256 + AES-GCM) ------------
632
+ // Other plugins (e.g. dsh-mail) need a real secret from the vault. The Host
633
+ // process only has a metadata snapshot, so the only place that can answer
634
+ // is this browser client. We publish a same-document bridge object that
635
+ // speaks an encrypted, one-time-session protocol; nothing here touches the
636
+ // Host route and nothing persists. Registered on window in apply(); if this
637
+ // plugin is not installed, the object simply never exists and consumers
638
+ // detect that via isAvailable() and silently no-op.
639
+ var BRIDGE_KEY = '@mysterycode-liwen/dsh-credential-vault/bridge/v1';
640
+ var bridgeSessions = {}; // sessionId -> { key, used, expires }
641
+ function bridgeB64u(bytes) {
642
+ var s = '';
643
+ for (var i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
644
+ return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
645
+ }
646
+ function bridgeUnb64u(str) {
647
+ var b = String(str).replace(/-/g, '+').replace(/_/g, '/');
648
+ while (b.length % 4) b += '=';
649
+ var bin = atob(b), out = new Uint8Array(bin.length);
650
+ for (var i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
651
+ return out;
652
+ }
653
+ function bridgeEnc(str) { return new TextEncoder().encode(str); }
654
+ function bridgeDec(bytes) { return new TextDecoder().decode(bytes); }
655
+ function bridgeDerive(s, priv, peerJwk) {
656
+ return s.importKey('jwk', peerJwk, { name: 'ECDH', namedCurve: 'P-256' }, false, [])
657
+ .then(function (pub) { return s.deriveBits({ name: 'ECDH', public: pub }, priv, 256); })
658
+ .then(function (bits) { return s.importKey('raw', bits, { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']); });
659
+ }
660
+ function bridgeSeal(s, key, obj) {
661
+ var iv = new Uint8Array(12);
662
+ window.crypto.getRandomValues(iv);
663
+ return s.encrypt({ name: 'AES-GCM', iv: iv }, key, bridgeEnc(JSON.stringify(obj)))
664
+ .then(function (ct) {
665
+ return { iv: bridgeB64u(iv), ciphertext: bridgeB64u(new Uint8Array(ct)) };
666
+ });
667
+ }
668
+ function bridgeOpen(s, key, payload) {
669
+ if (!payload || typeof payload.iv !== 'string' || typeof payload.ciphertext !== 'string') {
670
+ return Promise.reject(new Error('BAD_CIPHERTEXT'));
671
+ }
672
+ return s.decrypt({ name: 'AES-GCM', iv: bridgeUnb64u(payload.iv) }, key, bridgeUnb64u(payload.ciphertext))
673
+ .then(function (plain) { return JSON.parse(bridgeDec(new Uint8Array(plain))); });
674
+ }
675
+ function newBridge() {
676
+ var s = (window.crypto && window.crypto.subtle) || null;
677
+ return {
678
+ version: 1,
679
+ hello: function () {
680
+ if (!s) return Promise.reject(new Error('NO_CRYPTO'));
681
+ return s.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, ['deriveBits'])
682
+ .then(function (kp) {
683
+ var id = Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10);
684
+ return s.exportKey('jwk', kp.publicKey).then(function (pubJwk) {
685
+ bridgeSessions[id] = { keyPair: kp, used: false, expires: Date.now() + 60000 };
686
+ return { sessionId: id, publicKeyJwk: pubJwk };
687
+ });
688
+ });
689
+ },
690
+ query: function (req) {
691
+ if (!s) return Promise.resolve({ error: 'NO_CRYPTO' });
692
+ if (!req || !req.sessionId || !req.publicKeyJwk) {
693
+ return Promise.resolve({ error: 'BAD_REQUEST' });
694
+ }
695
+ var sess = bridgeSessions[req.sessionId];
696
+ if (!sess) return Promise.resolve({ error: 'UNKNOWN_SESSION' });
697
+ if (sess.expires < Date.now()) {
698
+ delete bridgeSessions[req.sessionId];
699
+ return Promise.resolve({ error: 'SESSION_EXPIRED' });
700
+ }
701
+ if (sess.used) return Promise.resolve({ error: 'SESSION_USED' });
702
+ // One-time session: consume immediately, even if decryption later fails.
703
+ sess.used = true;
704
+ try { delete bridgeSessions[req.sessionId]; } catch (e) {}
705
+ var sharedKey = null;
706
+ return bridgeDerive(s, sess.keyPair.privateKey, req.publicKeyJwk)
707
+ .then(function (key) { sharedKey = key; return bridgeOpen(s, key, req); })
708
+ .then(function (criteria) {
709
+ var cat = criteria && criteria.category ? criteria.category : 'all';
710
+ var title = criteria && typeof criteria.title === 'string' ? criteria.title.toLowerCase() : '';
711
+ var limit = criteria && criteria.limit ? Math.min(Number(criteria.limit) || 100, 500) : 100;
712
+ var all = loadEntries(); // REAL entries incl. secrets, from localStorage
713
+ var SECRET_KEYS = ['password', 'apiKey', 'content', 'appSecret', 'token',
714
+ 'encodingAesKey', 'uploadKey', 'keyValue'];
715
+ var out = [];
716
+ for (var i = 0; i < all.length && out.length < limit; i++) {
717
+ var e = all[i];
718
+ if (cat !== 'all' && e.category !== cat) continue;
719
+ if (title && String(e.title || '').toLowerCase().indexOf(title) < 0) continue;
720
+ var item = {};
721
+ Object.keys(e).forEach(function (k) { item[k] = e[k]; });
722
+ // Belt-and-braces: only known secret keys are included; all are
723
+ // real values because the consumer authenticated with the AES key.
724
+ SECRET_KEYS.forEach(function (k) {
725
+ if (typeof e[k] === 'string') item[k] = e[k];
726
+ });
727
+ out.push(item);
728
+ }
729
+ return bridgeSeal(s, sharedKey, { entries: out });
730
+ })
731
+ .then(function (sealed) { return sealed; })
732
+ .catch(function () { return { error: 'DECRYPT_FAILED' }; });
733
+ }
734
+ };
735
+ }
736
+ function registerBridge() {
737
+ try {
738
+ if (!window[BRIDGE_KEY]) window[BRIDGE_KEY] = newBridge();
739
+ } catch (e) {}
740
+ }
611
741
  // Mirror only METADATA to the Host so the Harness/Agent can discover which
612
742
  // credentials exist via dsh_credential_vault_read. Plaintext secrets stay in
613
743
  // this browser's localStorage and are NEVER sent to the Host process. The
@@ -1444,6 +1574,17 @@ window.__ModuleLoader__.load({
1444
1574
  var secondary = fields.filter(function (f) { return !PRIMARY_KEYS[f.key]; });
1445
1575
  var hasSecondary = secondary.some(function (f) { return !!d[f.key]; });
1446
1576
  var moreState = useState(hasSecondary), showMore = moreState[0], setShowMore = moreState[1];
1577
+ // Link picker: dropdown with search + type filter (account "linked credentials").
1578
+ var lkOpenState = useState(false), linksOpen = lkOpenState[0], setLinksOpen = lkOpenState[1];
1579
+ var lkQueryState = useState(''), linkQuery = lkQueryState[0], setLinkQuery = lkQueryState[1];
1580
+ var lkTypeState = useState('all'), linkType = lkTypeState[0], setLinkType = lkTypeState[1];
1581
+ var lkRef = useRef(null);
1582
+ useEffect(function () {
1583
+ if (!linksOpen) return;
1584
+ function onDoc(ev) { if (lkRef.current && !lkRef.current.contains(ev.target)) setLinksOpen(false); }
1585
+ document.addEventListener('mousedown', onDoc);
1586
+ return function () { document.removeEventListener('mousedown', onDoc); };
1587
+ }, [linksOpen]);
1447
1588
 
1448
1589
  function baseInput(f, extra) {
1449
1590
  return Object.assign({
@@ -1463,21 +1604,76 @@ window.__ModuleLoader__.load({
1463
1604
  return x.id !== d.id && ['apikey', 'secretKey', 'other'].indexOf(x.category) >= 0;
1464
1605
  });
1465
1606
  var selected = Array.isArray(d.links) ? d.links : [];
1466
- control = h('div', { className: 'cv-link-options' },
1467
- candidates.length ? candidates.map(function (x) {
1468
- var checked = selected.indexOf(x.id) >= 0;
1469
- var cm = CATEGORIES.filter(function (c) { return c.k === x.category; })[0];
1470
- return h('label', { key: x.id, className: 'cv-link-opt' },
1471
- h('input', {
1472
- type: 'checkbox', checked: checked,
1473
- onChange: function () {
1474
- var next = checked ? selected.filter(function (lid) { return lid !== x.id; }) : selected.concat([x.id]);
1475
- onChange('links', next);
1476
- }
1477
- }),
1478
- h('span', null, x.title + (cm ? ' · ' + t(cm.label) : ''))
1479
- );
1480
- }) : h('span', { className: 'cv-link-empty' }, t('linkNone'))
1607
+ function toggleLink(id) {
1608
+ var next = selected.indexOf(id) >= 0
1609
+ ? selected.filter(function (lid) { return lid !== id; })
1610
+ : selected.concat([id]);
1611
+ onChange('links', next);
1612
+ }
1613
+ var typeOpts = [
1614
+ { k: 'all', label: 'filterAll' },
1615
+ { k: 'apikey', label: 'filterApikey' },
1616
+ { k: 'secretKey', label: 'filterSecretKey' },
1617
+ { k: 'other', label: 'filterOther' }
1618
+ ];
1619
+ var shown = candidates.filter(function (x) {
1620
+ if (linkType !== 'all' && x.category !== linkType) return false;
1621
+ var q = linkQuery.trim().toLowerCase();
1622
+ return !q || String(x.title || '').toLowerCase().indexOf(q) >= 0;
1623
+ });
1624
+ control = h('div', { className: 'cv-link-picker', ref: lkRef },
1625
+ h('div', { className: 'cv-link-picker-top' },
1626
+ h('button', {
1627
+ type: 'button', className: 'cv-link-trigger' + (linksOpen ? ' cv-link-trigger-on' : ''),
1628
+ onClick: function () { setLinksOpen(!linksOpen); }
1629
+ },
1630
+ h('span', null, selected.length ? (selected.length + ' ' + t('linkSelected')) : t('linkPlaceholder')),
1631
+ h('span', { className: 'cv-link-caret' }, linksOpen ? '▴' : '▾')
1632
+ ),
1633
+ selected.length ? h('button', {
1634
+ type: 'button', className: 'cv-link-clear', title: t('linkClear'),
1635
+ onClick: function () { onChange('links', []); }
1636
+ }, '×') : null
1637
+ ),
1638
+ selected.length ? h('div', { className: 'cv-link-selected' },
1639
+ selected.map(function (id) {
1640
+ var tgt = candidates.filter(function (x) { return x.id === id; })[0];
1641
+ var label = tgt ? tgt.title : t('linkMissing');
1642
+ return h('span', { key: id, className: 'cv-link-sel-chip', title: label },
1643
+ h('span', { className: 'cv-link-sel-text' }, '🔗 ' + label),
1644
+ h('button', {
1645
+ type: 'button', className: 'cv-link-sel-x', title: t('linkClear'),
1646
+ onClick: function () { toggleLink(id); }
1647
+ }, '×')
1648
+ );
1649
+ })
1650
+ ) : null,
1651
+ linksOpen ? h('div', { className: 'cv-link-popover' },
1652
+ h('input', {
1653
+ className: 'cv-input cv-link-search', type: 'text',
1654
+ placeholder: t('linkSearch'), value: linkQuery,
1655
+ onChange: function (ev) { setLinkQuery(ev.target.value); }
1656
+ }),
1657
+ h('div', { className: 'cv-link-typechips' },
1658
+ typeOpts.map(function (o) {
1659
+ return h('button', {
1660
+ type: 'button', key: o.k,
1661
+ className: 'cv-link-typechip' + (linkType === o.k ? ' cv-link-typechip-on' : ''),
1662
+ onClick: function () { setLinkType(o.k); }
1663
+ }, t(o.label));
1664
+ })
1665
+ ),
1666
+ h('div', { className: 'cv-link-options' },
1667
+ shown.length ? shown.map(function (x) {
1668
+ var checked = selected.indexOf(x.id) >= 0;
1669
+ var cm = CATEGORIES.filter(function (c) { return c.k === x.category; })[0];
1670
+ return h('label', { key: x.id, className: 'cv-link-opt' },
1671
+ h('input', { type: 'checkbox', checked: checked, onChange: function () { toggleLink(x.id); } }),
1672
+ h('span', null, x.title + (cm ? ' · ' + t(cm.label) : ''))
1673
+ );
1674
+ }) : h('span', { className: 'cv-link-empty' }, t('linkNoMatch'))
1675
+ )
1676
+ ) : null
1481
1677
  );
1482
1678
  } else if (f.type === 'text' || f.type === 'date') {
1483
1679
  control = h('input', baseInput(f, { type: f.type === 'date' ? 'date' : 'text' }));
@@ -2671,6 +2867,7 @@ window.__ModuleLoader__.load({
2671
2867
  return {
2672
2868
  inject: ['slots'],
2673
2869
  apply(ctx) {
2870
+ registerBridge();
2674
2871
  ctxRef = ctx;
2675
2872
  layout = (ctx.get && ctx.get('layout')) || null;
2676
2873
  locale = (ctx.get && ctx.get('locale')) || 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.2'
49
+ const CURRENT_VERSION = '1.6.0'
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'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysterycode-liwen/dsh-credential-vault",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "DeepSeek Harness 侧边栏凭据保险箱:本地保存账号密码、API Key 与恢复码,支持访问密码、密保重置、闲置自动锁定,并提供默认脱敏的 Agent 读取工具。",
@@ -38,6 +38,7 @@
38
38
  "client.js",
39
39
  "cordis.patch.yml",
40
40
  "locale/*.json",
41
+ "bridge/*.js",
41
42
  "icon.svg",
42
43
  "README.md",
43
44
  "LICENSE"