@mysterycode-liwen/dsh-credential-vault 1.4.1 → 1.4.2

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 (3) hide show
  1. package/README.md +7 -1
  2. package/client.js +30 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -123,6 +123,12 @@ Host 侧工具在 Harness 启动时注册。重启 Harness,或在插件管理
123
123
 
124
124
  ## 更新日志 / Changelog
125
125
 
126
+ ### 1.4.2 — 2026-11-22
127
+
128
+ - **字段过滤**:导入 / 加载 / 导出时统一按凭据类型清理字段,API Key 记录若残留账号类的「用户名 / 密码 / 网址」会被自动剔除,不再出现在卡片或导出文件中。
129
+ - 清理在 `normalize()` 里统一完成:从 localStorage 加载、三种格式导入、导出渲染都走同一入口;合法字段(ID / 类型 / 时间戳)保留,无损导回不变。
130
+ - 新增回归测试:验证脏 API Key 记录经 JSON / CSV / Markdown 导入后脏字段被清除、真字段保留。
131
+
126
132
  ### 1.4.1 — 2026-11-22
127
133
 
128
134
  - **可读性改进**:Markdown 导出由超宽表格改为每条凭据一张卡片、中文标签两列表、空字段省略、类型显示为「账号 / API Key / 其他」,一目了然。
@@ -155,7 +161,7 @@ Host 侧工具在 Harness 启动时注册。重启 Harness,或在插件管理
155
161
  npm run check # 发布前自检:client.js 的模块 id 与 cordis.patch.yml 的 name 必须等于包名
156
162
  npm pack --dry-run # 核对实际打包的文件清单
157
163
  npm publish # publishConfig.access = public;会先自动跑一次 npm run check,不一致则中止
158
- git tag v1.4.1 && git push --tags
164
+ git tag v1.4.2 && git push --tags
159
165
  ```
160
166
 
161
167
  `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.4.1';
18
+ var VERSION = '1.4.2';
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
@@ -467,7 +467,7 @@ window.__ModuleLoader__.load({
467
467
  if (n.provider == null && n.username) n.provider = n.username;
468
468
  if (n.endpoint == null && n.url) n.endpoint = n.url;
469
469
  }
470
- return n;
470
+ return sanitize(n);
471
471
  }
472
472
  function loadEntries() {
473
473
  try {
@@ -667,6 +667,26 @@ window.__ModuleLoader__.load({
667
667
  var CATEGORY_LABELS = { account: '账号', apikey: 'API Key', other: '其他' };
668
668
  var LABEL_CATEGORIES = {};
669
669
  Object.keys(CATEGORY_LABELS).forEach(function (k) { LABEL_CATEGORIES[CATEGORY_LABELS[k]] = k; });
670
+ // Only export fields that belong to the entry's type. A record may carry
671
+ // stale fields from a past type change (e.g. an API Key with leftover
672
+ // username/password/url); those must not leak into readable exports.
673
+ var VISIBLE_FIELDS = {
674
+ account: ['title', 'username', 'password', 'url', 'notes'],
675
+ apikey: ['title', 'provider', 'apiKey', 'endpoint', 'expiry', 'notes'],
676
+ other: ['title', 'content', 'notes']
677
+ };
678
+ function fieldsFor(cat) { return VISIBLE_FIELDS[cat] || VISIBLE_FIELDS.account; }
679
+ // Strip fields that do not belong to the entry's type. Applied inside
680
+ // normalize(), so stale fields (e.g. an API Key carrying username/password/
681
+ // url from a past type change) are removed everywhere data enters the app:
682
+ // loading from localStorage, importing, and exporting. Technical columns
683
+ // (id / category / timestamps) stay for identity and ordering.
684
+ function sanitize(e) {
685
+ var keep = fieldsFor(e.category).concat(['id', 'category', 'createdAt', 'updatedAt']);
686
+ var out = {};
687
+ keep.forEach(function (k) { if (e[k] !== undefined) out[k] = e[k]; });
688
+ return out;
689
+ }
670
690
 
671
691
  // CSV helpers (RFC 4180): quote fields containing comma / quote / newline,
672
692
  // double embedded quotes. The file carries a UTF-8 BOM so Excel/WPS show
@@ -688,7 +708,11 @@ window.__ModuleLoader__.load({
688
708
  var lines = [CSV_COLS.map(function (c) { return csvEscape(FIELD_LABELS[c] || c); }).join(',')];
689
709
  arr.forEach(function (e) {
690
710
  var n = normalize(e);
711
+ var visible = fieldsFor(n.category);
691
712
  lines.push(CSV_COLS.map(function (c) {
713
+ // Technical columns stay for lossless import; business columns that
714
+ // do not belong to this type are left blank.
715
+ if (visible.indexOf(c) < 0 && c !== 'id' && c !== 'category' && c !== 'createdAt' && c !== 'updatedAt') return '';
692
716
  var v = (c === 'createdAt' || c === 'updatedAt') ? csvDate(n[c]) : n[c];
693
717
  if (c === 'category') v = CATEGORY_LABELS[v] || v;
694
718
  return csvEscape(v);
@@ -800,13 +824,12 @@ window.__ModuleLoader__.load({
800
824
  lines.push('');
801
825
  lines.push('| 字段 | 内容 |');
802
826
  lines.push('| --- | --- |');
803
- EXPORT_COLS.forEach(function (c) {
804
- if (c === 'id' || c === 'title' || c === 'createdAt' || c === 'updatedAt') return;
827
+ lines.push('| 类型 | ' + mdCell(CATEGORY_LABELS[n.category] || n.category || '账号') + ' |');
828
+ fieldsFor(n.category).forEach(function (c) {
829
+ if (c === 'title') return;
805
830
  var v = n[c];
806
831
  if (v == null || v === '') return;
807
- var label = FIELD_LABELS[c] || c;
808
- if (c === 'category') v = CATEGORY_LABELS[v] || v;
809
- lines.push('| ' + label + ' | ' + mdCell(v) + ' |');
832
+ lines.push('| ' + (FIELD_LABELS[c] || c) + ' | ' + mdCell(v) + ' |');
810
833
  });
811
834
  lines.push('');
812
835
  lines.push('---');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysterycode-liwen/dsh-credential-vault",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "DeepSeek Harness 侧边栏凭据保险箱:本地保存账号密码、API Key 与恢复码,支持访问密码、密保重置、闲置自动锁定,并提供默认脱敏的 Agent 读取工具。",