dsh-vault 0.1.1 → 0.2.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-zh.md +50 -10
- package/README.md +50 -10
- package/lib/client.js +63 -25
- package/lib/client.js.map +1 -1
- package/lib/index.js +62 -0
- package/package.json +1 -1
package/README-zh.md
CHANGED
|
@@ -53,6 +53,15 @@ dsh-vault 是一个面向 DeepSeek Harness 的安全加密插件:把你在使
|
|
|
53
53
|
|
|
54
54
|
dsh-vault 是一个 **bundle**(声明 `dsh.bundle` 的包):安装到 profile 后,它的 `cordis.patch.yml` 会自动插入 `vault` 插件行(按包名 `dsh-vault` 引用,主密码经 `DSH_VAULT_PASSWORD` 环境变量注入)。包内含自包含构建脚本,git 安装时会自动编译 `lib/`。
|
|
55
55
|
|
|
56
|
+
以下四种安装方式均已**端到端实测通过**(安装 → bundle 层被识别 → 插件激活且 7 个 `vault_*` 工具全部注册 → `vault_add`/`vault_get` 真实往返成功 → 卸载移除 layer):
|
|
57
|
+
|
|
58
|
+
| 方式 | 命令 | 需构建 | 需 allowBuilds |
|
|
59
|
+
|---|---|---|---|
|
|
60
|
+
| npm | `add dsh-vault` | 否(预构建 lib) | 否 |
|
|
61
|
+
| GitHub | `add github:Ox0400/dsh-vault#v0.1.1` | 是(prepare) | 是(首次) |
|
|
62
|
+
| 本地路径 | `add /绝对/路径/to/dsh-vault` | 否(链接已构建源码) | 否 |
|
|
63
|
+
| tarball | `add ./dsh-vault-0.1.1.tgz` | 否(预构建 lib) | 否 |
|
|
64
|
+
|
|
56
65
|
### 方式一:从 npm 安装(最省事)
|
|
57
66
|
|
|
58
67
|
```sh
|
|
@@ -68,16 +77,28 @@ export DSH_VAULT_PASSWORD='你的强主密码'
|
|
|
68
77
|
### 方式二:从 GitHub 安装(锁 tag 或 commit)
|
|
69
78
|
|
|
70
79
|
```sh
|
|
71
|
-
dsh plugin --profile demo add github:Ox0400/dsh-vault#v0.1.
|
|
80
|
+
dsh plugin --profile demo add github:Ox0400/dsh-vault#v0.1.1
|
|
72
81
|
```
|
|
73
82
|
|
|
74
|
-
git 安装拉取的是**源码**,`prepare` 脚本会在安装时构建 `lib/`。pnpm ≥10 默认阻止 git
|
|
83
|
+
git 安装拉取的是**源码**,`prepare` 脚本会在安装时构建 `lib/`。pnpm ≥10 默认阻止 git 依赖执行构建脚本。实测流程:
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
1. 执行 `add` 命令——会因 `allowBuilds` 失败,并打印需要放行的**精确键**(含仓库 URL 与解析后的 commit hash 的那行):
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
allowBuilds:
|
|
89
|
+
dsh-vault@https://codeload.github.com/Ox0400/dsh-vault/tar.gz/<sha>: true
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
2. 把该精确键追加到 profile 的 `pnpm-workspace.yaml`(`$DSH_HOME/profiles/<name>/pnpm-workspace.yaml`):
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
packages:
|
|
96
|
+
- .
|
|
97
|
+
allowBuilds:
|
|
98
|
+
dsh-vault@https://codeload.github.com/Ox0400/dsh-vault/tar.gz/<sha>: true
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
3. 重新执行 `add`——pnpm 现在会运行 `prepare` 脚本,构建 `lib/` 并完成安装。
|
|
81
102
|
|
|
82
103
|
建议**锁定 tag/commit** 再安装,避免上游推送改变安装时执行的代码。允许构建 = 允许该包的代码在你的机器上于安装时执行;只对你信任的源码授予。
|
|
83
104
|
|
|
@@ -87,12 +108,16 @@ allowBuilds:
|
|
|
87
108
|
dsh plugin --profile demo add /绝对/路径/to/dsh-vault
|
|
88
109
|
```
|
|
89
110
|
|
|
111
|
+
pnpm 将 checkout 链接进 profile;只要 `lib/` 存在(必要时先在 checkout 里执行 `pnpm build`)即被识别为 bundle。
|
|
112
|
+
|
|
90
113
|
### 方式四:本地 tarball 安装
|
|
91
114
|
|
|
92
115
|
```sh
|
|
93
|
-
npm pack && dsh plugin --profile demo add ./dsh-vault-0.1.
|
|
116
|
+
npm pack && dsh plugin --profile demo add ./dsh-vault-0.1.1.tgz
|
|
94
117
|
```
|
|
95
118
|
|
|
119
|
+
tarball 自带预构建 `lib/` 产物,无需构建或 allowBuilds。
|
|
120
|
+
|
|
96
121
|
`dsh plugin --profile demo remove dsh-vault` 卸载(同时移除依赖与 layer)。
|
|
97
122
|
|
|
98
123
|
## 配置
|
|
@@ -103,6 +128,21 @@ npm pack && dsh plugin --profile demo add ./dsh-vault-0.1.0.tgz
|
|
|
103
128
|
| `masterPasswordEnv` | 环境变量名,运行时从该变量读取主密码(推荐) |
|
|
104
129
|
| `path` | 保险库文件路径,默认 `$DSH_HOME/vault/default.json` |
|
|
105
130
|
| `name` | 保险库名,用于默认路径(如 `name: work` → `$DSH_HOME/vault/work.json`) |
|
|
131
|
+
| `accessMode` | 模型工具的访问策略:`readwrite`(默认)或 `readonly`。`readonly` 下工具与设置页的增/改/删全部被拒绝。 |
|
|
132
|
+
| `autoCapture` | `false`(默认)。设为 `true` 时,系统提示词会指导模型识别对话中出现的凭据,并**按用户偏好**用 `vault_add` 提供保存。 |
|
|
133
|
+
|
|
134
|
+
示例:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
- id: vault
|
|
138
|
+
name: dsh-vault
|
|
139
|
+
config:
|
|
140
|
+
masterPasswordEnv: DSH_VAULT_PASSWORD
|
|
141
|
+
accessMode: readwrite
|
|
142
|
+
autoCapture: true
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`autoCapture: true` 时,当你在对话中分享凭据(如 "我的 npm token 是 npm_…"),助手会提议存入;你同意后立即调用 `vault_add`。`autoCapture` 关闭时,只有你明确要求才保存。设置页会显示当前模式,空库提示会引导你开始存入密钥。
|
|
106
146
|
|
|
107
147
|
首次调用任一工具时自动创建保险库;之后每次启动用主密码重新解锁。**忘记主密码 = 数据永久丢失**(无后门,这是设计使然)。
|
|
108
148
|
|
|
@@ -132,7 +172,7 @@ pnpm typecheck # tsc -p tsconfig.json --noEmit
|
|
|
132
172
|
# 构建(host 侧 lib/*.js 与浏览器 bundle lib/client.js)
|
|
133
173
|
pnpm build # = build:host (tsc) + build:client (tsdown)
|
|
134
174
|
|
|
135
|
-
# 打包发布(可选:npm pack 产物可直接 `dsh plugin add ./dsh-vault-0.1.
|
|
175
|
+
# 打包发布(可选:npm pack 产物可直接 `dsh plugin add ./dsh-vault-0.1.1.tgz`)
|
|
136
176
|
npm pack
|
|
137
177
|
```
|
|
138
178
|
|
|
@@ -150,7 +190,7 @@ npm pack
|
|
|
150
190
|
可选发布途径:
|
|
151
191
|
|
|
152
192
|
```sh
|
|
153
|
-
npm pack # 产出 tarball → dsh plugin add ./dsh-vault-0.1.
|
|
193
|
+
npm pack # 产出 tarball → dsh plugin add ./dsh-vault-0.1.1.tgz
|
|
154
194
|
npm publish --access public # 发布 npm → dsh plugin add dsh-vault
|
|
155
195
|
```
|
|
156
196
|
|
package/README.md
CHANGED
|
@@ -55,6 +55,15 @@ Each record has a `title`, an optional `kind`, and any combination of fields:
|
|
|
55
55
|
|
|
56
56
|
dsh-vault is a **bundle** (a package declaring `dsh.bundle`): once installed into a profile, its `cordis.patch.yml` automatically inserts the `vault` plugin row (referenced by package name `dsh-vault`; the master password is injected via the `DSH_VAULT_PASSWORD` environment variable). The package ships a self-contained build script — git installs compile `lib/` automatically.
|
|
57
57
|
|
|
58
|
+
All four install paths below are **verified end-to-end** (install → bundle layer recognized → plugin activates with all 7 `vault_*` tools registered → real `vault_add`/`vault_get` round trip → uninstall removes the layer):
|
|
59
|
+
|
|
60
|
+
| Path | Command | Build needed | `allowBuilds` |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| npm | `add dsh-vault` | no (prebuilt `lib/`) | no |
|
|
63
|
+
| GitHub | `add github:Ox0400/dsh-vault#v0.1.1` | yes (`prepare`) | yes (first run) |
|
|
64
|
+
| local path | `add /abs/path/to/dsh-vault` | no (link to built source) | no |
|
|
65
|
+
| tarball | `add ./dsh-vault-0.1.1.tgz` | no (prebuilt `lib/`) | no |
|
|
66
|
+
|
|
58
67
|
### Option 1: Install from npm (easiest)
|
|
59
68
|
|
|
60
69
|
```sh
|
|
@@ -70,16 +79,28 @@ export DSH_VAULT_PASSWORD='your strong master password'
|
|
|
70
79
|
### Option 2: Install from GitHub (pin a tag or commit)
|
|
71
80
|
|
|
72
81
|
```sh
|
|
73
|
-
dsh plugin --profile demo add github:Ox0400/dsh-vault#v0.1.
|
|
82
|
+
dsh plugin --profile demo add github:Ox0400/dsh-vault#v0.1.1
|
|
74
83
|
```
|
|
75
84
|
|
|
76
|
-
A git install fetches **sources, not built artifacts**, so the `prepare` script builds `lib/` at install time. pnpm ≥10 blocks git dependencies from running build scripts by default
|
|
85
|
+
A git install fetches **sources, not built artifacts**, so the `prepare` script builds `lib/` at install time. pnpm ≥10 blocks git dependencies from running build scripts by default. The verified flow:
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
1. Run the `add` command — it fails with an `allowBuilds` error and prints the exact key to allow (the line containing the repo URL, including the resolved commit hash):
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
allowBuilds:
|
|
91
|
+
dsh-vault@https://codeload.github.com/Ox0400/dsh-vault/tar.gz/<sha>: true
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
2. Append that exact key to the profile's `pnpm-workspace.yaml` (`$DSH_HOME/profiles/<name>/pnpm-workspace.yaml`):
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
packages:
|
|
98
|
+
- .
|
|
99
|
+
allowBuilds:
|
|
100
|
+
dsh-vault@https://codeload.github.com/Ox0400/dsh-vault/tar.gz/<sha>: true
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
3. Re-run the `add` — pnpm now runs the `prepare` script, builds `lib/`, and installs.
|
|
83
104
|
|
|
84
105
|
**Pin a tag/commit** so a later upstream push cannot silently change what runs on install. Treat the allowance for what it is: permission to execute that package's code on your machine at install time — only grant it to sources you trust.
|
|
85
106
|
|
|
@@ -89,12 +110,16 @@ allowBuilds:
|
|
|
89
110
|
dsh plugin --profile demo add /absolute/path/to/dsh-vault
|
|
90
111
|
```
|
|
91
112
|
|
|
113
|
+
pnpm links the checkout into the profile; the bundle is recognized as long as `lib/` exists (run `pnpm build` in the checkout first if needed).
|
|
114
|
+
|
|
92
115
|
### Option 4: Install from a tarball
|
|
93
116
|
|
|
94
117
|
```sh
|
|
95
|
-
npm pack && dsh plugin --profile demo add ./dsh-vault-0.1.
|
|
118
|
+
npm pack && dsh plugin --profile demo add ./dsh-vault-0.1.1.tgz
|
|
96
119
|
```
|
|
97
120
|
|
|
121
|
+
The tarball ships prebuilt `lib/` artifacts, so no build step or `allowBuilds` is required.
|
|
122
|
+
|
|
98
123
|
`dsh plugin --profile demo remove dsh-vault` uninstalls (removes both the dependency and the layer).
|
|
99
124
|
|
|
100
125
|
## Configuration
|
|
@@ -105,6 +130,21 @@ npm pack && dsh plugin --profile demo add ./dsh-vault-0.1.0.tgz
|
|
|
105
130
|
| `masterPasswordEnv` | Environment variable name holding the master password (recommended) |
|
|
106
131
|
| `path` | Vault file path; defaults to `$DSH_HOME/vault/default.json` |
|
|
107
132
|
| `name` | Vault name for the default path (e.g. `name: work` → `$DSH_HOME/vault/work.json`) |
|
|
133
|
+
| `accessMode` | Access policy for the model tools: `readwrite` (default) or `readonly`. `readonly` rejects every add/update/delete on both the tools and the Settings UI. |
|
|
134
|
+
| `autoCapture` | `false` (default). When `true`, the system prompt instructs the model to detect credentials shared in conversation and — per user preference — offer to save them with `vault_add`. |
|
|
135
|
+
|
|
136
|
+
Example:
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
- id: vault
|
|
140
|
+
name: dsh-vault
|
|
141
|
+
config:
|
|
142
|
+
masterPasswordEnv: DSH_VAULT_PASSWORD
|
|
143
|
+
accessMode: readwrite
|
|
144
|
+
autoCapture: true
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
With `autoCapture: true`, when you share a credential in chat (e.g. "my npm token is npm_…"), the assistant offers to store it; on your consent it calls `vault_add` immediately. With `autoCapture` off, credentials are only saved when you explicitly ask. The Settings UI shows the current mode and the empty-vault hint tells you how to get started.
|
|
108
148
|
|
|
109
149
|
The vault is created automatically on first tool use; every launch re-unlocks with the master password. **Forgetting the master password = permanent data loss** (no backdoor — by design).
|
|
110
150
|
|
|
@@ -128,7 +168,7 @@ Common commands:
|
|
|
128
168
|
pnpm test # unit + integration tests (vitest, 41)
|
|
129
169
|
pnpm typecheck # tsc -p tsconfig.json --noEmit
|
|
130
170
|
pnpm build # = build:host (tsc) + build:client (tsdown)
|
|
131
|
-
npm pack # optional: tarball for `dsh plugin add ./dsh-vault-0.1.
|
|
171
|
+
npm pack # optional: tarball for `dsh plugin add ./dsh-vault-0.1.1.tgz`
|
|
132
172
|
```
|
|
133
173
|
|
|
134
174
|
All 41 tests pass (crypto / TOTP / password generation / store CRUD / gateway / integration).
|
|
@@ -145,7 +185,7 @@ This package is a standard npm bundle:
|
|
|
145
185
|
Distribution options:
|
|
146
186
|
|
|
147
187
|
```sh
|
|
148
|
-
npm pack # tarball → dsh plugin add ./dsh-vault-0.1.
|
|
188
|
+
npm pack # tarball → dsh plugin add ./dsh-vault-0.1.1.tgz
|
|
149
189
|
npm publish --access public # registry → dsh plugin add dsh-vault
|
|
150
190
|
```
|
|
151
191
|
|
package/lib/client.js
CHANGED
|
@@ -7,7 +7,7 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region \0dsh-css:/Users/zhipeng/Desktop/work/dsh test/dsh-vault/src/client/VaultSection.module.css.mjs
|
|
10
|
-
const css = ".t_j5va_section{flex-direction:column;gap:12px;padding:16px 0;display:flex}.t_j5va_intro{opacity:.75;margin:0;font-size:13px}.t_j5va_toolbar{align-items:center;gap:8px;display:flex}.t_j5va_searchBox{flex:1;display:flex}.t_j5va_searchBox input{border:1px solid var(--color-border,#444);color:inherit;background:0 0;border-radius:6px;flex:1;padding:6px 10px;font-size:13px}.t_j5va_addButton,.t_j5va_saveButton{background:var(--color-accent,#4f8cff);color:#fff;cursor:pointer;border:1px solid #0000;border-radius:6px;padding:6px 12px;font-size:13px}.t_j5va_addButton:disabled,.t_j5va_saveButton:disabled,.t_j5va_rowActions button:disabled{opacity:.5;cursor:not-allowed}.t_j5va_list{flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;display:flex}.t_j5va_row{border:1px solid var(--color-border,#333);border-radius:8px;justify-content:space-between;align-items:center;gap:12px;padding:8px 10px;display:flex}.t_j5va_rowMain{flex-direction:column;gap:2px;min-width:0;display:flex}.t_j5va_title{font-size:14px;font-weight:600}.t_j5va_identity{opacity:.7;text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.t_j5va_totp{font-family:var(--font-mono,monospace);color:var(--color-accent,#4f8cff);font-size:13px}.t_j5va_rowActions{flex-shrink:0;align-items:center;gap:6px;display:flex}.t_j5va_rowActions button{border:1px solid var(--color-border,#444);color:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:4px 8px;font-size:12px}.t_j5va_deleteButton{color:#e5484d}.t_j5va_copied{color:#30a46c;font-size:12px}.t_j5va_empty,.t_j5va_status,.t_j5va_error{opacity:.8;font-size:13px}.t_j5va_error{color:#e5484d}.t_j5va_editor{border:1px solid var(--color-border,#444);border-radius:8px;padding:12px}.t_j5va_editorBody{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:8px 12px;display:grid}.t_j5va_field{flex-direction:column;gap:4px;font-size:12px;display:flex}.t_j5va_field input,.t_j5va_field select{border:1px solid var(--color-border,#444);color:inherit;background:0 0;border-radius:6px;padding:5px 8px;font-size:13px}.t_j5va_editorActions{justify-content:flex-end;gap:8px;margin-top:12px;display:flex}.t_j5va_editorActions button{border:1px solid var(--color-border,#444);color:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:6px 12px;font-size:13px}";
|
|
10
|
+
const css = ".t_j5va_section{flex-direction:column;gap:12px;padding:16px 0;display:flex}.t_j5va_intro{opacity:.75;margin:0;font-size:13px}.t_j5va_toolbar{align-items:center;gap:8px;display:flex}.t_j5va_searchBox{flex:1;display:flex}.t_j5va_searchBox input{border:1px solid var(--color-border,#444);color:inherit;background:0 0;border-radius:6px;flex:1;padding:6px 10px;font-size:13px}.t_j5va_addButton,.t_j5va_saveButton{background:var(--color-accent,#4f8cff);color:#fff;cursor:pointer;border:1px solid #0000;border-radius:6px;padding:6px 12px;font-size:13px}.t_j5va_addButton:disabled,.t_j5va_saveButton:disabled,.t_j5va_rowActions button:disabled{opacity:.5;cursor:not-allowed}.t_j5va_list{flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;display:flex}.t_j5va_row{border:1px solid var(--color-border,#333);border-radius:8px;justify-content:space-between;align-items:center;gap:12px;padding:8px 10px;display:flex}.t_j5va_rowMain{flex-direction:column;gap:2px;min-width:0;display:flex}.t_j5va_title{font-size:14px;font-weight:600}.t_j5va_identity{opacity:.7;text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.t_j5va_totp{font-family:var(--font-mono,monospace);color:var(--color-accent,#4f8cff);font-size:13px}.t_j5va_rowActions{flex-shrink:0;align-items:center;gap:6px;display:flex}.t_j5va_rowActions button{border:1px solid var(--color-border,#444);color:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:4px 8px;font-size:12px}.t_j5va_deleteButton{color:#e5484d}.t_j5va_copied{color:#30a46c;font-size:12px}.t_j5va_empty,.t_j5va_status,.t_j5va_error{opacity:.8;font-size:13px}.t_j5va_modeReadonly,.t_j5va_modeReadwrite{border-radius:999px;width:fit-content;margin:0;padding:4px 10px;font-size:12px;display:inline-block}.t_j5va_modeReadonly{color:#e5484d;border:1px solid #e5484d80}.t_j5va_modeReadwrite{color:#30a46c;border:1px solid #30a46c80}.t_j5va_emptyBox{flex-direction:column;gap:4px;display:flex}.t_j5va_emptyHint{opacity:.65;margin:0;font-size:12px}.t_j5va_error{color:#e5484d}.t_j5va_editor{border:1px solid var(--color-border,#444);border-radius:8px;padding:12px}.t_j5va_editorBody{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:8px 12px;display:grid}.t_j5va_field{flex-direction:column;gap:4px;font-size:12px;display:flex}.t_j5va_field input,.t_j5va_field select{border:1px solid var(--color-border,#444);color:inherit;background:0 0;border-radius:6px;padding:5px 8px;font-size:13px}.t_j5va_editorActions{justify-content:flex-end;gap:8px;margin-top:12px;display:flex}.t_j5va_editorActions button{border:1px solid var(--color-border,#444);color:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:6px 12px;font-size:13px}";
|
|
11
11
|
const tagId = "dsh-vault/VaultSection.module.css";
|
|
12
12
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
13
13
|
const tag = document.createElement("style");
|
|
@@ -17,28 +17,32 @@ window.__ModuleLoader__.load({
|
|
|
17
17
|
document.head.appendChild(tag);
|
|
18
18
|
}
|
|
19
19
|
var VaultSection_module_css_default = {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
20
|
+
"empty": "t_j5va_empty",
|
|
21
|
+
"modeReadonly": "t_j5va_modeReadonly",
|
|
22
|
+
"modeReadwrite": "t_j5va_modeReadwrite",
|
|
23
|
+
"emptyBox": "t_j5va_emptyBox",
|
|
24
|
+
"emptyHint": "t_j5va_emptyHint",
|
|
25
|
+
"copied": "t_j5va_copied",
|
|
26
|
+
"identity": "t_j5va_identity",
|
|
24
27
|
"deleteButton": "t_j5va_deleteButton",
|
|
28
|
+
"searchBox": "t_j5va_searchBox",
|
|
29
|
+
"status": "t_j5va_status",
|
|
25
30
|
"addButton": "t_j5va_addButton",
|
|
26
|
-
"toolbar": "t_j5va_toolbar",
|
|
27
|
-
"rowMain": "t_j5va_rowMain",
|
|
28
|
-
"identity": "t_j5va_identity",
|
|
29
|
-
"rowActions": "t_j5va_rowActions",
|
|
30
|
-
"section": "t_j5va_section",
|
|
31
|
-
"copied": "t_j5va_copied",
|
|
32
|
-
"saveButton": "t_j5va_saveButton",
|
|
33
31
|
"list": "t_j5va_list",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
32
|
+
"error": "t_j5va_error",
|
|
33
|
+
"editorBody": "t_j5va_editorBody",
|
|
34
|
+
"section": "t_j5va_section",
|
|
37
35
|
"totp": "t_j5va_totp",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
36
|
+
"editor": "t_j5va_editor",
|
|
37
|
+
"field": "t_j5va_field",
|
|
40
38
|
"editorActions": "t_j5va_editorActions",
|
|
41
|
-
"
|
|
39
|
+
"rowActions": "t_j5va_rowActions",
|
|
40
|
+
"row": "t_j5va_row",
|
|
41
|
+
"title": "t_j5va_title",
|
|
42
|
+
"intro": "t_j5va_intro",
|
|
43
|
+
"rowMain": "t_j5va_rowMain",
|
|
44
|
+
"saveButton": "t_j5va_saveButton",
|
|
45
|
+
"toolbar": "t_j5va_toolbar"
|
|
42
46
|
};
|
|
43
47
|
//#endregion
|
|
44
48
|
//#region src/client/VaultSection.tsx
|
|
@@ -131,7 +135,7 @@ window.__ModuleLoader__.load({
|
|
|
131
135
|
}
|
|
132
136
|
/** Render the Vault settings section. */
|
|
133
137
|
function VaultSection(props) {
|
|
134
|
-
const { t, list, search, get, add, update, remove, totp } = props;
|
|
138
|
+
const { t, config, list, search, get, add, update, remove, totp } = props;
|
|
135
139
|
const searchId = (0, react.useId)();
|
|
136
140
|
const [query, setQuery] = (0, react.useState)("");
|
|
137
141
|
const [state, setState] = (0, react.useState)({ status: "loading" });
|
|
@@ -142,6 +146,17 @@ window.__ModuleLoader__.load({
|
|
|
142
146
|
const [copiedId, setCopiedId] = (0, react.useState)(null);
|
|
143
147
|
const [codeMap, setCodeMap] = (0, react.useState)({});
|
|
144
148
|
const [tagsDraft, setTagsDraft] = (0, react.useState)("");
|
|
149
|
+
const [policy, setPolicy] = (0, react.useState)(null);
|
|
150
|
+
const readonly = policy?.accessMode === "readonly";
|
|
151
|
+
(0, react.useEffect)(() => {
|
|
152
|
+
let current = true;
|
|
153
|
+
config().then((value) => {
|
|
154
|
+
if (current) setPolicy(value);
|
|
155
|
+
}, () => {});
|
|
156
|
+
return () => {
|
|
157
|
+
current = false;
|
|
158
|
+
};
|
|
159
|
+
}, [config]);
|
|
145
160
|
const refresh = (0, react.useMemo)(() => async () => {
|
|
146
161
|
setState({ status: "loading" });
|
|
147
162
|
try {
|
|
@@ -339,10 +354,14 @@ window.__ModuleLoader__.load({
|
|
|
339
354
|
type: "button",
|
|
340
355
|
className: VaultSection_module_css_default.addButton,
|
|
341
356
|
onClick: startCreate,
|
|
342
|
-
disabled: busy,
|
|
357
|
+
disabled: busy || readonly,
|
|
343
358
|
children: ["+ ", t("add")]
|
|
344
359
|
})]
|
|
345
360
|
}),
|
|
361
|
+
policy !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
362
|
+
className: readonly ? VaultSection_module_css_default.modeReadonly : VaultSection_module_css_default.modeReadwrite,
|
|
363
|
+
children: [readonly ? t("modeReadonly") : t("modeReadwrite"), policy.autoCapture ? ` · ${t("autoCaptureOn")}` : ` · ${t("autoCaptureOff")}`]
|
|
364
|
+
}),
|
|
346
365
|
message !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
347
366
|
role: "alert",
|
|
348
367
|
className: VaultSection_module_css_default.error,
|
|
@@ -357,9 +376,15 @@ window.__ModuleLoader__.load({
|
|
|
357
376
|
className: VaultSection_module_css_default.error,
|
|
358
377
|
children: t("error")
|
|
359
378
|
}),
|
|
360
|
-
state.status === "ready" && state.entries.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
361
|
-
className: VaultSection_module_css_default.
|
|
362
|
-
children:
|
|
379
|
+
state.status === "ready" && state.entries.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
380
|
+
className: VaultSection_module_css_default.emptyBox,
|
|
381
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
382
|
+
className: VaultSection_module_css_default.empty,
|
|
383
|
+
children: t("empty")
|
|
384
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
385
|
+
className: VaultSection_module_css_default.emptyHint,
|
|
386
|
+
children: readonly ? t("emptyHintReadonly") : t("emptyHint")
|
|
387
|
+
})]
|
|
363
388
|
}),
|
|
364
389
|
state.status === "ready" && state.entries.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
365
390
|
className: VaultSection_module_css_default.list,
|
|
@@ -405,14 +430,14 @@ window.__ModuleLoader__.load({
|
|
|
405
430
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
406
431
|
type: "button",
|
|
407
432
|
onClick: () => void startEdit(entry.id),
|
|
408
|
-
disabled: busy,
|
|
433
|
+
disabled: busy || readonly,
|
|
409
434
|
children: t("edit")
|
|
410
435
|
}),
|
|
411
436
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
412
437
|
type: "button",
|
|
413
438
|
className: VaultSection_module_css_default.deleteButton,
|
|
414
439
|
onClick: () => void removeEntry(entry.id),
|
|
415
|
-
disabled: busy,
|
|
440
|
+
disabled: busy || readonly,
|
|
416
441
|
children: t("delete")
|
|
417
442
|
})
|
|
418
443
|
]
|
|
@@ -490,6 +515,12 @@ window.__ModuleLoader__.load({
|
|
|
490
515
|
searchPlaceholder: "Search title, username, email, host…",
|
|
491
516
|
loading: "Loading…",
|
|
492
517
|
empty: "No credentials yet. Add one to get started.",
|
|
518
|
+
emptyHint: "Tip: you can ask the assistant to save an API key or token you share in chat — with auto-capture on it offers to store it for you.",
|
|
519
|
+
emptyHintReadonly: "The vault is in readonly mode — credentials can be read but not added here. Switch accessMode to \"readwrite\" to enable writes.",
|
|
520
|
+
modeReadonly: "Readonly mode — mutations disabled",
|
|
521
|
+
modeReadwrite: "Read-write mode",
|
|
522
|
+
autoCaptureOn: "auto-capture on",
|
|
523
|
+
autoCaptureOff: "auto-capture off",
|
|
493
524
|
add: "Add credential",
|
|
494
525
|
cancel: "Cancel",
|
|
495
526
|
save: "Save",
|
|
@@ -531,6 +562,12 @@ window.__ModuleLoader__.load({
|
|
|
531
562
|
searchPlaceholder: "搜索标题、用户名、邮箱、主机…",
|
|
532
563
|
loading: "加载中…",
|
|
533
564
|
empty: "还没有凭据,添加一条开始使用。",
|
|
565
|
+
emptyHint: "提示:你可以在对话中把 API Key 或 token 交给助手保存——开启自动捕获后,它会在你同意时帮你存入本库。",
|
|
566
|
+
emptyHintReadonly: "当前为只读模式——只能读取凭据,不能在此添加。将 accessMode 改为 \"readwrite\" 即可启用写入。",
|
|
567
|
+
modeReadonly: "只读模式 —— 变更已禁用",
|
|
568
|
+
modeReadwrite: "读写模式",
|
|
569
|
+
autoCaptureOn: "自动捕获已开启",
|
|
570
|
+
autoCaptureOff: "自动捕获已关闭",
|
|
534
571
|
add: "新增凭据",
|
|
535
572
|
cancel: "取消",
|
|
536
573
|
save: "保存",
|
|
@@ -594,6 +631,7 @@ window.__ModuleLoader__.load({
|
|
|
594
631
|
}
|
|
595
632
|
const injected = () => ({
|
|
596
633
|
t,
|
|
634
|
+
config: () => invoke("config"),
|
|
597
635
|
list: () => invoke("list").then((r) => r.entries),
|
|
598
636
|
search: (query, limit) => invoke("search", {
|
|
599
637
|
query,
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["css"],"sources":["../src/client/VaultSection.tsx","../src/client/locales.ts","../src/client/index.ts"],"sourcesContent":["/**\n * Vault settings section: list, search, add, edit, delete, and copy encrypted\n * credentials. All mutations go through the host VaultGateway remote; secrets\n * are shown only inside the edit form or a copy action, never in the list.\n */\n\nimport { useEffect, useId, useMemo, useState, type ReactNode } from 'react'\nimport type { PropsLocale, PropsRuntime, InjectFace, TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { VaultLocaleKey } from './locales.ts'\nimport css from './VaultSection.module.css'\n\n/** Wire shapes shared with the host gateway (mirror of src/index.ts types). */\nexport interface VaultSummaryWire {\n id: string\n title: string\n kind?: string\n username?: string\n email?: string\n phone?: string\n host?: string\n port?: string\n url?: string\n tags?: string[]\n}\n\nexport interface VaultFullWire {\n id: string\n title: string\n kind?: string\n username?: string\n email?: string\n phone?: string\n password?: string\n host?: string\n port?: string\n privateKey?: string\n apiKey?: string\n secret?: string\n accessToken?: string\n refreshToken?: string\n expiresAt?: number\n otpSecret?: string\n url?: string\n notes?: string\n tags?: string[]\n fields?: Record<string, unknown>\n}\n\n/** Patch shape accepted by vault.add / vault.update. */\nexport type VaultPatch = Partial<Omit<VaultFullWire, 'id'>>\n\n/** Registration-side business face supplied by the plugin entry. */\nexport interface VaultSectionInjected {\n t: TranslateNS<'settings.vault'>\n list: () => Promise<VaultSummaryWire[]>\n search: (query: string, limit?: number) => Promise<VaultSummaryWire[]>\n get: (id: string) => Promise<{ found: boolean; entry?: VaultFullWire }>\n add: (patch: VaultPatch & { title: string }) => Promise<VaultSummaryWire>\n update: (id: string, patch: VaultPatch) => Promise<{ found: boolean; entry?: VaultSummaryWire }>\n remove: (id: string) => Promise<{ deleted: boolean }>\n totp: (id: string) => Promise<{ code: string; label?: string; secondsRemaining: number }>\n}\n\n/** Type-level alias so consumers can reference the wire shapes without values. */\nexport type VaultSectionTypes = {\n entries: VaultSummaryWire[]\n fullEntry: VaultFullWire\n summaryEntry: VaultSummaryWire\n}\n\n/** Full component props assembled by the Settings slot renderer. */\nexport type VaultSectionProps =\n PropsRuntime<'settings.section'>\n & PropsLocale<'settings.vault'>\n & InjectFace<VaultSectionInjected>\n\n/** The editable form fields we render (subset of the full wire). */\ntype FormFields = Pick<\n VaultFullWire, 'title' | 'kind' | 'username' | 'email' | 'phone' | 'password' | 'host' | 'port'\n | 'privateKey' | 'apiKey' | 'secret' | 'accessToken' | 'refreshToken' | 'otpSecret' | 'url' | 'notes'\n>\n\nconst FORM_FIELDS: Array<{ key: keyof FormFields; label: VaultLocaleKey }> = [\n { key: 'title', label: 'fieldTitle' },\n { key: 'kind', label: 'fieldKind' },\n { key: 'username', label: 'fieldUsername' },\n { key: 'email', label: 'fieldEmail' },\n { key: 'phone', label: 'fieldPhone' },\n { key: 'password', label: 'fieldPassword' },\n { key: 'host', label: 'fieldHost' },\n { key: 'port', label: 'fieldPort' },\n { key: 'apiKey', label: 'fieldApiKey' },\n { key: 'secret', label: 'fieldSecret' },\n { key: 'accessToken', label: 'fieldAccessToken' },\n { key: 'refreshToken', label: 'fieldRefreshToken' },\n { key: 'otpSecret', label: 'fieldOtpSecret' },\n { key: 'url', label: 'fieldUrl' },\n { key: 'notes', label: 'fieldNotes' },\n]\n\nconst KIND_KEYS: Record<string, VaultLocaleKey> = {\n login: 'kindLogin',\n ssh: 'kindSsh',\n 'api-key': 'kindApiKey',\n secret: 'kindSecret',\n oauth: 'kindOauth',\n custom: 'kindCustom',\n}\n\ntype ViewState =\n | { readonly status: 'loading' }\n | { readonly status: 'error' }\n | { readonly status: 'ready'; readonly entries: VaultSummaryWire[] }\n\ntype EditorState =\n | { readonly status: 'closed' }\n | { readonly status: 'creating' }\n | { readonly status: 'editing'; readonly entry: VaultFullWire }\n\nfunction emptyForm(): FormFields {\n return { title: '', kind: 'login', username: '', email: '', phone: '', password: '', host: '', port: '' }\n}\n\n/** Render the Vault settings section. */\nexport function VaultSection(props: VaultSectionProps): ReactNode {\n const { t, list, search, get, add, update, remove, totp } = props\n const searchId = useId()\n const [query, setQuery] = useState('')\n const [state, setState] = useState<ViewState>({ status: 'loading' })\n const [editor, setEditor] = useState<EditorState>({ status: 'closed' })\n const [form, setForm] = useState<FormFields>(emptyForm())\n const [busy, setBusy] = useState(false)\n const [message, setMessage] = useState<string | null>(null)\n const [copiedId, setCopiedId] = useState<string | null>(null)\n const [codeMap, setCodeMap] = useState<Record<string, string>>({})\n const [tagsDraft, setTagsDraft] = useState('')\n\n const refresh = useMemo(() => async () => {\n setState({ status: 'loading' })\n try {\n const entries = query.trim().length === 0\n ? await list()\n : await search(query.trim())\n setState({ status: 'ready', entries })\n } catch {\n setState({ status: 'error' })\n }\n }, [list, search, query])\n\n useEffect(() => {\n let current = true\n void Promise.resolve().then(refresh).then(\n () => { /* state already set inside refresh */ },\n () => { if (current) setState({ status: 'error' }) },\n )\n return () => { current = false }\n // refresh is memoized on query; list/search are stable inject faces.\n }, [refresh])\n\n /** Open the editor for a new entry. */\n function startCreate(): void {\n setForm(emptyForm())\n setTagsDraft('')\n setMessage(null)\n setEditor({ status: 'creating' })\n }\n\n /** Open the editor for an existing entry (fetches full secrets). */\n async function startEdit(id: string): Promise<void> {\n setBusy(true)\n setMessage(null)\n try {\n const result = await get(id)\n if (!result.found || result.entry === undefined) {\n setMessage(t('error'))\n return\n }\n const entry = result.entry\n setForm({\n title: entry.title ?? '',\n kind: entry.kind ?? 'login',\n username: entry.username ?? '',\n email: entry.email ?? '',\n phone: entry.phone ?? '',\n password: entry.password ?? '',\n host: entry.host ?? '',\n port: entry.port ?? '',\n privateKey: entry.privateKey ?? '',\n apiKey: entry.apiKey ?? '',\n secret: entry.secret ?? '',\n accessToken: entry.accessToken ?? '',\n refreshToken: entry.refreshToken ?? '',\n otpSecret: entry.otpSecret ?? '',\n url: entry.url ?? '',\n notes: entry.notes ?? '',\n })\n setTagsDraft((entry.tags ?? []).join(', '))\n setEditor({ status: 'editing', entry })\n } catch {\n setMessage(t('error'))\n } finally {\n setBusy(false)\n }\n }\n\n /** Save the current form (create or update). */\n async function save(): Promise<void> {\n if (!form.title.trim()) {\n setMessage(t('error'))\n return\n }\n setBusy(true)\n setMessage(null)\n try {\n const tags = tagsDraft.split(',').map(x => x.trim()).filter(x => x.length > 0)\n const patch: VaultPatch = {\n title: form.title.trim(),\n ...(form.kind !== undefined ? { kind: form.kind } : {}),\n ...(form.username !== undefined ? { username: form.username } : {}),\n ...(form.email !== undefined ? { email: form.email } : {}),\n ...(form.phone !== undefined ? { phone: form.phone } : {}),\n ...(form.password !== undefined ? { password: form.password } : {}),\n ...(form.host !== undefined ? { host: form.host } : {}),\n ...(form.port !== undefined ? { port: form.port } : {}),\n ...(form.privateKey !== undefined ? { privateKey: form.privateKey } : {}),\n ...(form.apiKey !== undefined ? { apiKey: form.apiKey } : {}),\n ...(form.secret !== undefined ? { secret: form.secret } : {}),\n ...(form.accessToken !== undefined ? { accessToken: form.accessToken } : {}),\n ...(form.refreshToken !== undefined ? { refreshToken: form.refreshToken } : {}),\n ...(form.otpSecret !== undefined ? { otpSecret: form.otpSecret } : {}),\n ...(form.url !== undefined ? { url: form.url } : {}),\n ...(form.notes !== undefined ? { notes: form.notes } : {}),\n // Always send tags: an empty array clears them, and the host store\n // treats empty string values as \"clear this field\" too.\n tags,\n }\n if (editor.status === 'creating') {\n await add(patch as VaultPatch & { title: string })\n } else if (editor.status === 'editing') {\n await update(editor.entry.id, patch)\n }\n setEditor({ status: 'closed' })\n await refresh()\n } catch {\n setMessage(t('error'))\n } finally {\n setBusy(false)\n }\n }\n\n /** Delete an entry after confirmation. */\n async function removeEntry(id: string): Promise<void> {\n if (!window.confirm(t('deleteConfirm'))) return\n setBusy(true)\n try {\n await remove(id)\n await refresh()\n } catch {\n setMessage(t('error'))\n } finally {\n setBusy(false)\n }\n }\n\n /** Copy a field value to the clipboard and flash the row. */\n async function copyValue(id: string, value: string): Promise<void> {\n try {\n await navigator.clipboard.writeText(value)\n } catch {\n // Clipboard may be blocked; fall back to a temporary textarea.\n const textarea = document.createElement('textarea')\n textarea.value = value\n document.body.appendChild(textarea)\n textarea.select()\n document.execCommand('copy')\n textarea.remove()\n }\n setCopiedId(id)\n window.setTimeout(() => setCopiedId(null), 1500)\n }\n\n /** Fetch and display a TOTP code for an entry with an otpSecret. */\n async function showTotp(id: string): Promise<void> {\n setBusy(true)\n try {\n const result = await totp(id)\n setCodeMap(previous => ({ ...previous, [id]: `${result.code} (${result.secondsRemaining}s)` }))\n } catch {\n setCodeMap(previous => ({ ...previous, [id]: t('error') }))\n } finally {\n setBusy(false)\n }\n }\n\n /** Field-set summary line for one entry (non-secret). */\n function identityLine(entry: VaultSummaryWire): string {\n const parts = [\n entry.kind !== undefined ? t(KIND_KEYS[entry.kind] ?? 'kindCustom') : t('kindLogin'),\n entry.username,\n entry.email,\n entry.phone,\n entry.host !== undefined ? `${entry.host}${entry.port !== undefined ? `:${entry.port}` : ''}` : undefined,\n entry.url,\n ].filter((value): value is string => value !== undefined && value.length > 0)\n return parts.join(' · ')\n }\n\n return (\n <section className={css.section} aria-labelledby=\"vault-heading\">\n <h2 id=\"vault-heading\">{t('heading')}</h2>\n <p className={css.intro}>{t('intro')}</p>\n\n <div className={css.toolbar}>\n <label className={css.searchBox}>\n <span className=\"sr-only\">{t('searchPlaceholder')}</span>\n <input\n id={searchId}\n type=\"search\"\n placeholder={t('searchPlaceholder')}\n value={query}\n onChange={event => setQuery(event.target.value)}\n />\n </label>\n <button type=\"button\" className={css.addButton} onClick={startCreate} disabled={busy}>\n + {t('add')}\n </button>\n </div>\n\n {message !== null && <p role=\"alert\" className={css.error}>{message}</p>}\n\n {state.status === 'loading' && <p className={css.status}>{t('loading')}</p>}\n {state.status === 'error' && <p role=\"alert\" className={css.error}>{t('error')}</p>}\n {state.status === 'ready' && state.entries.length === 0 && <p className={css.empty}>{t('empty')}</p>}\n\n {state.status === 'ready' && state.entries.length > 0 && (\n <ul className={css.list}>\n {state.entries.map(entry => {\n const code = codeMap[entry.id]\n return (\n <li key={entry.id} className={css.row}>\n <div className={css.rowMain}>\n <span className={css.title}>{entry.title}</span>\n <span className={css.identity}>{identityLine(entry)}</span>\n {code !== undefined && <span className={css.totp}>{code}</span>}\n </div>\n <div className={css.rowActions}>\n {copiedId === entry.id && <span className={css.copied}>{t('copied')}</span>}\n <button\n type=\"button\"\n onClick={() => void copyValue(entry.id, entry.username ?? entry.title)}\n disabled={busy}\n >{t('copy')}</button>\n <button type=\"button\" onClick={() => void showTotp(entry.id)} disabled={busy}>{t('totp')}</button>\n <button type=\"button\" onClick={() => void startEdit(entry.id)} disabled={busy}>{t('edit')}</button>\n <button\n type=\"button\"\n className={css.deleteButton}\n onClick={() => void removeEntry(entry.id)}\n disabled={busy}\n >{t('delete')}</button>\n </div>\n </li>\n )\n })}\n </ul>\n )}\n\n {editor.status !== 'closed' && (\n <div className={css.editor} role=\"dialog\" aria-label={editor.status === 'creating' ? t('add') : t('edit')}>\n <div className={css.editorBody}>\n {FORM_FIELDS.map(field => (\n <label key={field.key} className={css.field}>\n <span>{t(field.label)}</span>\n {field.key === 'kind' ? (\n <select\n value={form.kind ?? 'login'}\n onChange={event => setForm(previous => ({ ...previous, kind: event.target.value }))}\n >\n {Object.entries(KIND_KEYS).map(([value, key]) => (\n <option key={value} value={value}>{t(key)}</option>\n ))}\n </select>\n ) : field.key === 'title' ? (\n <input\n value={form.title ?? ''}\n onChange={event => setForm(previous => ({ ...previous, title: event.target.value }))}\n />\n ) : (\n <input\n type={field.key === 'password' || field.key === 'otpSecret' ? 'password' : 'text'}\n value={(form[field.key] as string | undefined) ?? ''}\n onChange={event => setForm(previous => ({ ...previous, [field.key]: event.target.value }))}\n />\n )}\n </label>\n ))}\n <label className={css.field}>\n <span>{t('fieldTags')}</span>\n <input\n value={tagsDraft}\n onChange={event => setTagsDraft(event.target.value)}\n placeholder=\"dev, prod\"\n />\n </label>\n </div>\n <div className={css.editorActions}>\n <button type=\"button\" onClick={() => setEditor({ status: 'closed' })} disabled={busy}>{t('cancel')}</button>\n <button type=\"button\" className={css.saveButton} onClick={() => void save()} disabled={busy}>{t('save')}</button>\n </div>\n </div>\n )}\n </section>\n )\n}\n","/** Copy dictionaries for the Vault settings section. */\n\n/** English strings (the key-set source of truth for this pair). */\nexport const en = {\n nav: 'Vault',\n heading: 'Vault',\n intro: 'Encrypted credentials stored on this machine.',\n searchPlaceholder: 'Search title, username, email, host…',\n loading: 'Loading…',\n empty: 'No credentials yet. Add one to get started.',\n add: 'Add credential',\n cancel: 'Cancel',\n save: 'Save',\n edit: 'Edit',\n delete: 'Delete',\n deleteConfirm: 'Delete this entry? This cannot be undone.',\n copy: 'Copy',\n copied: 'Copied',\n totp: 'Code',\n fieldTitle: 'Title',\n fieldKind: 'Kind',\n fieldUsername: 'Username',\n fieldEmail: 'Email',\n fieldPhone: 'Phone',\n fieldPassword: 'Password',\n fieldHost: 'Host',\n fieldPort: 'Port',\n fieldApiKey: 'API key',\n fieldSecret: 'Secret',\n fieldAccessToken: 'Access token',\n fieldRefreshToken: 'Refresh token',\n fieldOtpSecret: 'OTP secret',\n fieldUrl: 'URL',\n fieldNotes: 'Notes',\n fieldTags: 'Tags',\n error: 'Something went wrong.',\n kindLogin: 'Login',\n kindSsh: 'SSH',\n kindApiKey: 'API key',\n kindSecret: 'Secret',\n kindOauth: 'OAuth',\n kindCustom: 'Custom',\n} as const\n\nexport type VaultLocaleKey = keyof typeof en\n\n/** Chinese strings (same keys as English). */\nexport const zh: Record<VaultLocaleKey, string> = {\n nav: '凭据库',\n heading: 'Vault 凭据库',\n intro: '本机加密存储的凭据。',\n searchPlaceholder: '搜索标题、用户名、邮箱、主机…',\n loading: '加载中…',\n empty: '还没有凭据,添加一条开始使用。',\n add: '新增凭据',\n cancel: '取消',\n save: '保存',\n edit: '编辑',\n delete: '删除',\n deleteConfirm: '确定删除该条目?此操作不可撤销。',\n copy: '复制',\n copied: '已复制',\n totp: '验证码',\n fieldTitle: '标题',\n fieldKind: '类型',\n fieldUsername: '用户名',\n fieldEmail: '邮箱',\n fieldPhone: '手机号',\n fieldPassword: '密码',\n fieldHost: '主机',\n fieldPort: '端口',\n fieldApiKey: 'API 密钥',\n fieldSecret: 'Secret',\n fieldAccessToken: '访问令牌',\n fieldRefreshToken: '刷新令牌',\n fieldOtpSecret: 'TOTP 密钥',\n fieldUrl: 'URL',\n fieldNotes: '备注',\n fieldTags: '标签',\n error: '操作失败。',\n kindLogin: '登录',\n kindSsh: 'SSH',\n kindApiKey: 'API 密钥',\n kindSecret: 'Secret',\n kindOauth: 'OAuth',\n kindCustom: '自定义',\n}\n","/**\n * dsh-vault browser half: a Vault settings page managing encrypted\n * credentials — list, search, add, edit, delete, and copy — through the host\n * VaultGateway remote over the /api RPC channel.\n *\n * @module dsh-vault/client\n */\n\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-api-remotes/client'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport { VaultSection, type VaultSectionInjected } from './VaultSection.tsx'\nimport type { VaultSectionTypes } from './VaultSection.tsx'\nimport { en, zh, type VaultLocaleKey } from './locales.ts'\n\nexport type { VaultSectionInjected, VaultSectionProps } from './VaultSection.tsx'\nexport type { VaultSectionTypes } from './VaultSection.tsx'\nexport type { VaultLocaleKey } from './locales.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Vault settings page copy. */\n 'settings.vault': VaultLocaleKey\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nexport const NS = 'settings.vault'\n\n/** Services required by the Settings registration and the RPC face. */\nexport const inject = ['slots', 'locale', 'connection']\n\n/**\n * Register the Vault settings section once the `settings.section` declaration\n * is on the ledger. The section talks to the host through the connection RPC\n * channel (endpoints `vault/*` served by the host VaultGateway remote).\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-vault: dictionaries')\n\n const t = ctx.locale.bind(NS)\n const connection = ctx.get('connection') as ConnectionHandle\n\n /** Invoke one host vault remote and normalize the RPC envelope. */\n async function invoke<T>(method: string, args: Record<string, unknown> = {}): Promise<T> {\n const result = await connection.rpc.call('/api', `vault/${method}`, { args })\n if (!result.ok) {\n throw new Error(`vault.${method} failed: ${result.error.code}: ${result.error.message}`)\n }\n return result.value as T\n }\n\n const injected = (): VaultSectionInjected => ({\n t,\n list: () => invoke<{ entries: VaultSectionTypes['entries'] }>('list').then(r => r.entries),\n search: (query, limit) => invoke<{ entries: VaultSectionTypes['entries'] }>('search', { query, limit: limit ?? 50 }).then(r => r.entries),\n get: (id) => invoke<{ found: boolean; entry?: VaultSectionTypes['fullEntry'] }>('get', { id }),\n add: (patch) => invoke<VaultSectionTypes['summaryEntry']>('add', { patch }),\n update: (id, patch) => invoke<{ found: boolean; entry?: VaultSectionTypes['summaryEntry'] }>('update', { id, patch }),\n remove: (id) => invoke<{ deleted: boolean }>('delete', { id }),\n totp: (id) => invoke<{ code: string; label?: string; secondsRemaining: number }>('totp', { id }),\n })\n\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section',\n id: 'vault',\n order: 30,\n label: () => t('nav'),\n inject: injected,\n }, VaultSection))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkFA,MAAM,cAAuE;GAC3E;IAAE,KAAK;IAAS,OAAO;GAAa;GACpC;IAAE,KAAK;IAAQ,OAAO;GAAY;GAClC;IAAE,KAAK;IAAY,OAAO;GAAgB;GAC1C;IAAE,KAAK;IAAS,OAAO;GAAa;GACpC;IAAE,KAAK;IAAS,OAAO;GAAa;GACpC;IAAE,KAAK;IAAY,OAAO;GAAgB;GAC1C;IAAE,KAAK;IAAQ,OAAO;GAAY;GAClC;IAAE,KAAK;IAAQ,OAAO;GAAY;GAClC;IAAE,KAAK;IAAU,OAAO;GAAc;GACtC;IAAE,KAAK;IAAU,OAAO;GAAc;GACtC;IAAE,KAAK;IAAe,OAAO;GAAmB;GAChD;IAAE,KAAK;IAAgB,OAAO;GAAoB;GAClD;IAAE,KAAK;IAAa,OAAO;GAAiB;GAC5C;IAAE,KA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a,SAAS;GAAC;GAAS;GAAU;EAAY;;;;;;EAOtD,SAAgB,MAAM,KAA0B;GAC9C,IAAI,aAAa,IAAI,OAAO,SAAS,IAAI;IAAE;IAAI;GAAG,CAAC,GAAG,yBAAyB;GAE/E,MAAM,IAAI,IAAI,OAAO,KAAK,EAAE;GAC5B,MAAM,aAAa,IAAI,IAAI,YAAY;;GAGvC,eAAe,OAAU,QAAgB,OAAgC,CAAC,GAAe;IACvF,MAAM,SAAS,MAAM,WAAW,IAAI,KAAK,QAAQ,SAAS,UAAU,EAAE,KAAK,CAAC;IAC5E,IAAI,CAAC,OAAO,IACV,MAAM,IAAI,MAAM,SAAS,OAAO,WAAW,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS;IAEzF,OAAO,OAAO;GAChB;GAEA,MAAM,kBAAwC;IAC5C;IACA,YAAY,OAAkD,MAAM,CAAC,CAAC,MAAK,MAAK,EAAE,OAAO;IACzF,SAAS,OAAO,UAAU,OAAkD,UAAU;KAAE;KAAO,OAAO,SAAS;IAAG,CAAC,CAAC,CAAC,MAAK,MAAK,EAAE,OAAO;IACxI,MAAM,OAAO,OAAmE,OAAO,EAAE,GAAG,CAAC;IAC7F,MAAM,UAAU,OAA0C,OAAO,EAAE,MAAM,CAAC;IAC1E,SAAS,IAAI,UAAU,OAAsE,UAAU;KAAE;KAAI;IAAM,CAAC;IACpH,SAAS,OAAO,OAA6B,UAAU,EAAE,GAAG,CAAC;IAC7D,OAAO,OAAO,OAAmE,QAAQ,EAAE,GAAG,CAAC;GACjG;GAEA,IAAI,MAAM,OAAO,0BAA0B,IAAI,MAAM,SAAS;IAC5D,MAAM;IACN,IAAI;IACJ,OAAO;IACP,aAAa,EAAE,KAAK;IACpB,QAAQ;GACV,GAAG,YAAY,CAAC;EAClB"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["css"],"sources":["../src/client/VaultSection.tsx","../src/client/locales.ts","../src/client/index.ts"],"sourcesContent":["/**\n * Vault settings section: list, search, add, edit, delete, and copy encrypted\n * credentials. All mutations go through the host VaultGateway remote; secrets\n * are shown only inside the edit form or a copy action, never in the list.\n */\n\nimport { useEffect, useId, useMemo, useState, type ReactNode } from 'react'\nimport type { PropsLocale, PropsRuntime, InjectFace, TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { VaultLocaleKey } from './locales.ts'\nimport css from './VaultSection.module.css'\n\n/** Wire shapes shared with the host gateway (mirror of src/index.ts types). */\nexport interface VaultSummaryWire {\n id: string\n title: string\n kind?: string\n username?: string\n email?: string\n phone?: string\n host?: string\n port?: string\n url?: string\n tags?: string[]\n}\n\nexport interface VaultFullWire {\n id: string\n title: string\n kind?: string\n username?: string\n email?: string\n phone?: string\n password?: string\n host?: string\n port?: string\n privateKey?: string\n apiKey?: string\n secret?: string\n accessToken?: string\n refreshToken?: string\n expiresAt?: number\n otpSecret?: string\n url?: string\n notes?: string\n tags?: string[]\n fields?: Record<string, unknown>\n}\n\n/** Patch shape accepted by vault.add / vault.update. */\nexport type VaultPatch = Partial<Omit<VaultFullWire, 'id'>>\n\n/** Registration-side business face supplied by the plugin entry. */\nexport interface VaultSectionInjected {\n t: TranslateNS<'settings.vault'>\n config: () => Promise<{ accessMode: 'readonly' | 'readwrite'; autoCapture: boolean }>\n list: () => Promise<VaultSummaryWire[]>\n search: (query: string, limit?: number) => Promise<VaultSummaryWire[]>\n get: (id: string) => Promise<{ found: boolean; entry?: VaultFullWire }>\n add: (patch: VaultPatch & { title: string }) => Promise<VaultSummaryWire>\n update: (id: string, patch: VaultPatch) => Promise<{ found: boolean; entry?: VaultSummaryWire }>\n remove: (id: string) => Promise<{ deleted: boolean }>\n totp: (id: string) => Promise<{ code: string; label?: string; secondsRemaining: number }>\n}\n\n/** Type-level alias so consumers can reference the wire shapes without values. */\nexport type VaultSectionTypes = {\n entries: VaultSummaryWire[]\n fullEntry: VaultFullWire\n summaryEntry: VaultSummaryWire\n config: { accessMode: 'readonly' | 'readwrite'; autoCapture: boolean }\n}\n\n/** Full component props assembled by the Settings slot renderer. */\nexport type VaultSectionProps =\n PropsRuntime<'settings.section'>\n & PropsLocale<'settings.vault'>\n & InjectFace<VaultSectionInjected>\n\n/** The editable form fields we render (subset of the full wire). */\ntype FormFields = Pick<\n VaultFullWire, 'title' | 'kind' | 'username' | 'email' | 'phone' | 'password' | 'host' | 'port'\n | 'privateKey' | 'apiKey' | 'secret' | 'accessToken' | 'refreshToken' | 'otpSecret' | 'url' | 'notes'\n>\n\nconst FORM_FIELDS: Array<{ key: keyof FormFields; label: VaultLocaleKey }> = [\n { key: 'title', label: 'fieldTitle' },\n { key: 'kind', label: 'fieldKind' },\n { key: 'username', label: 'fieldUsername' },\n { key: 'email', label: 'fieldEmail' },\n { key: 'phone', label: 'fieldPhone' },\n { key: 'password', label: 'fieldPassword' },\n { key: 'host', label: 'fieldHost' },\n { key: 'port', label: 'fieldPort' },\n { key: 'apiKey', label: 'fieldApiKey' },\n { key: 'secret', label: 'fieldSecret' },\n { key: 'accessToken', label: 'fieldAccessToken' },\n { key: 'refreshToken', label: 'fieldRefreshToken' },\n { key: 'otpSecret', label: 'fieldOtpSecret' },\n { key: 'url', label: 'fieldUrl' },\n { key: 'notes', label: 'fieldNotes' },\n]\n\nconst KIND_KEYS: Record<string, VaultLocaleKey> = {\n login: 'kindLogin',\n ssh: 'kindSsh',\n 'api-key': 'kindApiKey',\n secret: 'kindSecret',\n oauth: 'kindOauth',\n custom: 'kindCustom',\n}\n\ntype ViewState =\n | { readonly status: 'loading' }\n | { readonly status: 'error' }\n | { readonly status: 'ready'; readonly entries: VaultSummaryWire[] }\n\ntype EditorState =\n | { readonly status: 'closed' }\n | { readonly status: 'creating' }\n | { readonly status: 'editing'; readonly entry: VaultFullWire }\n\nfunction emptyForm(): FormFields {\n return { title: '', kind: 'login', username: '', email: '', phone: '', password: '', host: '', port: '' }\n}\n\n/** Render the Vault settings section. */\nexport function VaultSection(props: VaultSectionProps): ReactNode {\n const { t, config, list, search, get, add, update, remove, totp } = props\n const searchId = useId()\n const [query, setQuery] = useState('')\n const [state, setState] = useState<ViewState>({ status: 'loading' })\n const [editor, setEditor] = useState<EditorState>({ status: 'closed' })\n const [form, setForm] = useState<FormFields>(emptyForm())\n const [busy, setBusy] = useState(false)\n const [message, setMessage] = useState<string | null>(null)\n const [copiedId, setCopiedId] = useState<string | null>(null)\n const [codeMap, setCodeMap] = useState<Record<string, string>>({})\n const [tagsDraft, setTagsDraft] = useState('')\n const [policy, setPolicy] = useState<{ accessMode: 'readonly' | 'readwrite'; autoCapture: boolean } | null>(null)\n\n const readonly = policy?.accessMode === 'readonly'\n\n useEffect(() => {\n let current = true\n void config().then(\n value => { if (current) setPolicy(value) },\n () => { /* policy is informational; ignore failures */ },\n )\n return () => { current = false }\n }, [config])\n\n const refresh = useMemo(() => async () => {\n setState({ status: 'loading' })\n try {\n const entries = query.trim().length === 0\n ? await list()\n : await search(query.trim())\n setState({ status: 'ready', entries })\n } catch {\n setState({ status: 'error' })\n }\n }, [list, search, query])\n\n useEffect(() => {\n let current = true\n void Promise.resolve().then(refresh).then(\n () => { /* state already set inside refresh */ },\n () => { if (current) setState({ status: 'error' }) },\n )\n return () => { current = false }\n // refresh is memoized on query; list/search are stable inject faces.\n }, [refresh])\n\n /** Open the editor for a new entry. */\n function startCreate(): void {\n setForm(emptyForm())\n setTagsDraft('')\n setMessage(null)\n setEditor({ status: 'creating' })\n }\n\n /** Open the editor for an existing entry (fetches full secrets). */\n async function startEdit(id: string): Promise<void> {\n setBusy(true)\n setMessage(null)\n try {\n const result = await get(id)\n if (!result.found || result.entry === undefined) {\n setMessage(t('error'))\n return\n }\n const entry = result.entry\n setForm({\n title: entry.title ?? '',\n kind: entry.kind ?? 'login',\n username: entry.username ?? '',\n email: entry.email ?? '',\n phone: entry.phone ?? '',\n password: entry.password ?? '',\n host: entry.host ?? '',\n port: entry.port ?? '',\n privateKey: entry.privateKey ?? '',\n apiKey: entry.apiKey ?? '',\n secret: entry.secret ?? '',\n accessToken: entry.accessToken ?? '',\n refreshToken: entry.refreshToken ?? '',\n otpSecret: entry.otpSecret ?? '',\n url: entry.url ?? '',\n notes: entry.notes ?? '',\n })\n setTagsDraft((entry.tags ?? []).join(', '))\n setEditor({ status: 'editing', entry })\n } catch {\n setMessage(t('error'))\n } finally {\n setBusy(false)\n }\n }\n\n /** Save the current form (create or update). */\n async function save(): Promise<void> {\n if (!form.title.trim()) {\n setMessage(t('error'))\n return\n }\n setBusy(true)\n setMessage(null)\n try {\n const tags = tagsDraft.split(',').map(x => x.trim()).filter(x => x.length > 0)\n const patch: VaultPatch = {\n title: form.title.trim(),\n ...(form.kind !== undefined ? { kind: form.kind } : {}),\n ...(form.username !== undefined ? { username: form.username } : {}),\n ...(form.email !== undefined ? { email: form.email } : {}),\n ...(form.phone !== undefined ? { phone: form.phone } : {}),\n ...(form.password !== undefined ? { password: form.password } : {}),\n ...(form.host !== undefined ? { host: form.host } : {}),\n ...(form.port !== undefined ? { port: form.port } : {}),\n ...(form.privateKey !== undefined ? { privateKey: form.privateKey } : {}),\n ...(form.apiKey !== undefined ? { apiKey: form.apiKey } : {}),\n ...(form.secret !== undefined ? { secret: form.secret } : {}),\n ...(form.accessToken !== undefined ? { accessToken: form.accessToken } : {}),\n ...(form.refreshToken !== undefined ? { refreshToken: form.refreshToken } : {}),\n ...(form.otpSecret !== undefined ? { otpSecret: form.otpSecret } : {}),\n ...(form.url !== undefined ? { url: form.url } : {}),\n ...(form.notes !== undefined ? { notes: form.notes } : {}),\n // Always send tags: an empty array clears them, and the host store\n // treats empty string values as \"clear this field\" too.\n tags,\n }\n if (editor.status === 'creating') {\n await add(patch as VaultPatch & { title: string })\n } else if (editor.status === 'editing') {\n await update(editor.entry.id, patch)\n }\n setEditor({ status: 'closed' })\n await refresh()\n } catch {\n setMessage(t('error'))\n } finally {\n setBusy(false)\n }\n }\n\n /** Delete an entry after confirmation. */\n async function removeEntry(id: string): Promise<void> {\n if (!window.confirm(t('deleteConfirm'))) return\n setBusy(true)\n try {\n await remove(id)\n await refresh()\n } catch {\n setMessage(t('error'))\n } finally {\n setBusy(false)\n }\n }\n\n /** Copy a field value to the clipboard and flash the row. */\n async function copyValue(id: string, value: string): Promise<void> {\n try {\n await navigator.clipboard.writeText(value)\n } catch {\n // Clipboard may be blocked; fall back to a temporary textarea.\n const textarea = document.createElement('textarea')\n textarea.value = value\n document.body.appendChild(textarea)\n textarea.select()\n document.execCommand('copy')\n textarea.remove()\n }\n setCopiedId(id)\n window.setTimeout(() => setCopiedId(null), 1500)\n }\n\n /** Fetch and display a TOTP code for an entry with an otpSecret. */\n async function showTotp(id: string): Promise<void> {\n setBusy(true)\n try {\n const result = await totp(id)\n setCodeMap(previous => ({ ...previous, [id]: `${result.code} (${result.secondsRemaining}s)` }))\n } catch {\n setCodeMap(previous => ({ ...previous, [id]: t('error') }))\n } finally {\n setBusy(false)\n }\n }\n\n /** Field-set summary line for one entry (non-secret). */\n function identityLine(entry: VaultSummaryWire): string {\n const parts = [\n entry.kind !== undefined ? t(KIND_KEYS[entry.kind] ?? 'kindCustom') : t('kindLogin'),\n entry.username,\n entry.email,\n entry.phone,\n entry.host !== undefined ? `${entry.host}${entry.port !== undefined ? `:${entry.port}` : ''}` : undefined,\n entry.url,\n ].filter((value): value is string => value !== undefined && value.length > 0)\n return parts.join(' · ')\n }\n\n return (\n <section className={css.section} aria-labelledby=\"vault-heading\">\n <h2 id=\"vault-heading\">{t('heading')}</h2>\n <p className={css.intro}>{t('intro')}</p>\n\n <div className={css.toolbar}>\n <label className={css.searchBox}>\n <span className=\"sr-only\">{t('searchPlaceholder')}</span>\n <input\n id={searchId}\n type=\"search\"\n placeholder={t('searchPlaceholder')}\n value={query}\n onChange={event => setQuery(event.target.value)}\n />\n </label>\n <button type=\"button\" className={css.addButton} onClick={startCreate} disabled={busy || readonly}>\n + {t('add')}\n </button>\n </div>\n\n {policy !== null && (\n <p className={readonly ? css.modeReadonly : css.modeReadwrite}>\n {readonly ? t('modeReadonly') : t('modeReadwrite')}\n {policy.autoCapture ? ` · ${t('autoCaptureOn')}` : ` · ${t('autoCaptureOff')}`}\n </p>\n )}\n\n {message !== null && <p role=\"alert\" className={css.error}>{message}</p>}\n\n {state.status === 'loading' && <p className={css.status}>{t('loading')}</p>}\n {state.status === 'error' && <p role=\"alert\" className={css.error}>{t('error')}</p>}\n {state.status === 'ready' && state.entries.length === 0 && (\n <div className={css.emptyBox}>\n <p className={css.empty}>{t('empty')}</p>\n <p className={css.emptyHint}>{readonly ? t('emptyHintReadonly') : t('emptyHint')}</p>\n </div>\n )}\n\n {state.status === 'ready' && state.entries.length > 0 && (\n <ul className={css.list}>\n {state.entries.map(entry => {\n const code = codeMap[entry.id]\n return (\n <li key={entry.id} className={css.row}>\n <div className={css.rowMain}>\n <span className={css.title}>{entry.title}</span>\n <span className={css.identity}>{identityLine(entry)}</span>\n {code !== undefined && <span className={css.totp}>{code}</span>}\n </div>\n <div className={css.rowActions}>\n {copiedId === entry.id && <span className={css.copied}>{t('copied')}</span>}\n <button\n type=\"button\"\n onClick={() => void copyValue(entry.id, entry.username ?? entry.title)}\n disabled={busy}\n >{t('copy')}</button>\n <button type=\"button\" onClick={() => void showTotp(entry.id)} disabled={busy}>{t('totp')}</button>\n <button type=\"button\" onClick={() => void startEdit(entry.id)} disabled={busy || readonly}>{t('edit')}</button>\n <button\n type=\"button\"\n className={css.deleteButton}\n onClick={() => void removeEntry(entry.id)}\n disabled={busy || readonly}\n >{t('delete')}</button>\n </div>\n </li>\n )\n })}\n </ul>\n )}\n\n {editor.status !== 'closed' && (\n <div className={css.editor} role=\"dialog\" aria-label={editor.status === 'creating' ? t('add') : t('edit')}>\n <div className={css.editorBody}>\n {FORM_FIELDS.map(field => (\n <label key={field.key} className={css.field}>\n <span>{t(field.label)}</span>\n {field.key === 'kind' ? (\n <select\n value={form.kind ?? 'login'}\n onChange={event => setForm(previous => ({ ...previous, kind: event.target.value }))}\n >\n {Object.entries(KIND_KEYS).map(([value, key]) => (\n <option key={value} value={value}>{t(key)}</option>\n ))}\n </select>\n ) : field.key === 'title' ? (\n <input\n value={form.title ?? ''}\n onChange={event => setForm(previous => ({ ...previous, title: event.target.value }))}\n />\n ) : (\n <input\n type={field.key === 'password' || field.key === 'otpSecret' ? 'password' : 'text'}\n value={(form[field.key] as string | undefined) ?? ''}\n onChange={event => setForm(previous => ({ ...previous, [field.key]: event.target.value }))}\n />\n )}\n </label>\n ))}\n <label className={css.field}>\n <span>{t('fieldTags')}</span>\n <input\n value={tagsDraft}\n onChange={event => setTagsDraft(event.target.value)}\n placeholder=\"dev, prod\"\n />\n </label>\n </div>\n <div className={css.editorActions}>\n <button type=\"button\" onClick={() => setEditor({ status: 'closed' })} disabled={busy}>{t('cancel')}</button>\n <button type=\"button\" className={css.saveButton} onClick={() => void save()} disabled={busy}>{t('save')}</button>\n </div>\n </div>\n )}\n </section>\n )\n}\n","/** Copy dictionaries for the Vault settings section. */\n\n/** English strings (the key-set source of truth for this pair). */\nexport const en = {\n nav: 'Vault',\n heading: 'Vault',\n intro: 'Encrypted credentials stored on this machine.',\n searchPlaceholder: 'Search title, username, email, host…',\n loading: 'Loading…',\n empty: 'No credentials yet. Add one to get started.',\n emptyHint: 'Tip: you can ask the assistant to save an API key or token you share in chat — with auto-capture on it offers to store it for you.',\n emptyHintReadonly: 'The vault is in readonly mode — credentials can be read but not added here. Switch accessMode to \"readwrite\" to enable writes.',\n modeReadonly: 'Readonly mode — mutations disabled',\n modeReadwrite: 'Read-write mode',\n autoCaptureOn: 'auto-capture on',\n autoCaptureOff: 'auto-capture off',\n add: 'Add credential',\n cancel: 'Cancel',\n save: 'Save',\n edit: 'Edit',\n delete: 'Delete',\n deleteConfirm: 'Delete this entry? This cannot be undone.',\n copy: 'Copy',\n copied: 'Copied',\n totp: 'Code',\n fieldTitle: 'Title',\n fieldKind: 'Kind',\n fieldUsername: 'Username',\n fieldEmail: 'Email',\n fieldPhone: 'Phone',\n fieldPassword: 'Password',\n fieldHost: 'Host',\n fieldPort: 'Port',\n fieldApiKey: 'API key',\n fieldSecret: 'Secret',\n fieldAccessToken: 'Access token',\n fieldRefreshToken: 'Refresh token',\n fieldOtpSecret: 'OTP secret',\n fieldUrl: 'URL',\n fieldNotes: 'Notes',\n fieldTags: 'Tags',\n error: 'Something went wrong.',\n kindLogin: 'Login',\n kindSsh: 'SSH',\n kindApiKey: 'API key',\n kindSecret: 'Secret',\n kindOauth: 'OAuth',\n kindCustom: 'Custom',\n} as const\n\nexport type VaultLocaleKey = keyof typeof en\n\n/** Chinese strings (same keys as English). */\nexport const zh: Record<VaultLocaleKey, string> = {\n nav: '凭据库',\n heading: 'Vault 凭据库',\n intro: '本机加密存储的凭据。',\n searchPlaceholder: '搜索标题、用户名、邮箱、主机…',\n loading: '加载中…',\n empty: '还没有凭据,添加一条开始使用。',\n emptyHint: '提示:你可以在对话中把 API Key 或 token 交给助手保存——开启自动捕获后,它会在你同意时帮你存入本库。',\n emptyHintReadonly: '当前为只读模式——只能读取凭据,不能在此添加。将 accessMode 改为 \"readwrite\" 即可启用写入。',\n modeReadonly: '只读模式 —— 变更已禁用',\n modeReadwrite: '读写模式',\n autoCaptureOn: '自动捕获已开启',\n autoCaptureOff: '自动捕获已关闭',\n add: '新增凭据',\n cancel: '取消',\n save: '保存',\n edit: '编辑',\n delete: '删除',\n deleteConfirm: '确定删除该条目?此操作不可撤销。',\n copy: '复制',\n copied: '已复制',\n totp: '验证码',\n fieldTitle: '标题',\n fieldKind: '类型',\n fieldUsername: '用户名',\n fieldEmail: '邮箱',\n fieldPhone: '手机号',\n fieldPassword: '密码',\n fieldHost: '主机',\n fieldPort: '端口',\n fieldApiKey: 'API 密钥',\n fieldSecret: 'Secret',\n fieldAccessToken: '访问令牌',\n fieldRefreshToken: '刷新令牌',\n fieldOtpSecret: 'TOTP 密钥',\n fieldUrl: 'URL',\n fieldNotes: '备注',\n fieldTags: '标签',\n error: '操作失败。',\n kindLogin: '登录',\n kindSsh: 'SSH',\n kindApiKey: 'API 密钥',\n kindSecret: 'Secret',\n kindOauth: 'OAuth',\n kindCustom: '自定义',\n}\n","/**\n * dsh-vault browser half: a Vault settings page managing encrypted\n * credentials — list, search, add, edit, delete, and copy — through the host\n * VaultGateway remote over the /api RPC channel.\n *\n * @module dsh-vault/client\n */\n\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-api-remotes/client'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport { VaultSection, type VaultSectionInjected } from './VaultSection.tsx'\nimport type { VaultSectionTypes } from './VaultSection.tsx'\nimport { en, zh, type VaultLocaleKey } from './locales.ts'\n\nexport type { VaultSectionInjected, VaultSectionProps } from './VaultSection.tsx'\nexport type { VaultSectionTypes } from './VaultSection.tsx'\nexport type { VaultLocaleKey } from './locales.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Vault settings page copy. */\n 'settings.vault': VaultLocaleKey\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nexport const NS = 'settings.vault'\n\n/** Services required by the Settings registration and the RPC face. */\nexport const inject = ['slots', 'locale', 'connection']\n\n/**\n * Register the Vault settings section once the `settings.section` declaration\n * is on the ledger. The section talks to the host through the connection RPC\n * channel (endpoints `vault/*` served by the host VaultGateway remote).\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-vault: dictionaries')\n\n const t = ctx.locale.bind(NS)\n const connection = ctx.get('connection') as ConnectionHandle\n\n /** Invoke one host vault remote and normalize the RPC envelope. */\n async function invoke<T>(method: string, args: Record<string, unknown> = {}): Promise<T> {\n const result = await connection.rpc.call('/api', `vault/${method}`, { args })\n if (!result.ok) {\n throw new Error(`vault.${method} failed: ${result.error.code}: ${result.error.message}`)\n }\n return result.value as T\n }\n\n const injected = (): VaultSectionInjected => ({\n t,\n config: () => invoke<VaultSectionTypes['config']>('config'),\n list: () => invoke<{ entries: VaultSectionTypes['entries'] }>('list').then(r => r.entries),\n search: (query, limit) => invoke<{ entries: VaultSectionTypes['entries'] }>('search', { query, limit: limit ?? 50 }).then(r => r.entries),\n get: (id) => invoke<{ found: boolean; entry?: VaultSectionTypes['fullEntry'] }>('get', { id }),\n add: (patch) => invoke<VaultSectionTypes['summaryEntry']>('add', { patch }),\n update: (id, patch) => invoke<{ found: boolean; entry?: VaultSectionTypes['summaryEntry'] }>('update', { id, patch }),\n remove: (id) => invoke<{ deleted: boolean }>('delete', { id }),\n totp: (id) => invoke<{ code: string; label?: string; secondsRemaining: number }>('totp', { id }),\n })\n\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section',\n id: 'vault',\n order: 30,\n label: () => t('nav'),\n inject: injected,\n }, VaultSection))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoFA,MAAM,cAAuE;GAC3E;IAAE,KAAK;IAAS,OAAO;GAAa;GACpC;IAAE,KAAK;IAAQ,OAAO;GAAY;GAClC;IAAE,KAAK;IAAY,OAAO;GAAgB;GAC1C;IAAE,KAAK;IAAS,OAAO;GAAa;GACpC;IAAE,KAAK;IAAS,OAAO;GAAa;GACpC;IAAE,KAAK;IAAY,OAAO;GAAgB;GAC1C;IAAE,KAAK;IAAQ,OAAO;GAAY;GAClC;IAAE,KAAK;IAAQ,OAAO;GAAY;GAClC;IAAE,KAAK;IAAU,OAAO;GAAc;GACtC;IAAE,KAAK;IAAU,OAAO;GAAc;GACtC;IAAE,KAAK;IAAe,OAAO;GAAmB;GAChD;IAAE,KAAK;IAAgB,OAAO;GAAoB;GAClD;IAAE,KAAK;IAAa,OAAO;GAAiB;GAC5C;IAAE,KAAK;IAAO,OAAO;GAAW;GAChC;IAAE,KAAK;IAAS,OAAO;GAAa;EACtC;EAEA,MAAM,YAA4C;GAChD,OAAO;GACP,KAAK;GACL,WAAW;GACX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S;IAEzF,OAAO,OAAO;GAChB;GAEA,MAAM,kBAAwC;IAC5C;IACA,cAAc,OAAoC,QAAQ;IAC1D,YAAY,OAAkD,MAAM,CAAC,CAAC,MAAK,MAAK,EAAE,OAAO;IACzF,SAAS,OAAO,UAAU,OAAkD,UAAU;KAAE;KAAO,OAAO,SAAS;IAAG,CAAC,CAAC,CAAC,MAAK,MAAK,EAAE,OAAO;IACxI,MAAM,OAAO,OAAmE,OAAO,EAAE,GAAG,CAAC;IAC7F,MAAM,UAAU,OAA0C,OAAO,EAAE,MAAM,CAAC;IAC1E,SAAS,IAAI,UAAU,OAAsE,UAAU;KAAE;KAAI;IAAM,CAAC;IACpH,SAAS,OAAO,OAA6B,UAAU,EAAE,GAAG,CAAC;IAC7D,OAAO,OAAO,OAAmE,QAAQ,EAAE,GAAG,CAAC;GACjG;GAEA,IAAI,MAAM,OAAO,0BAA0B,IAAI,MAAM,SAAS;IAC5D,MAAM;IACN,IAAI;IACJ,OAAO;IACP,aAAa,EAAE,KAAK;IACpB,QAAQ;GACV,GAAG,YAAY,CAAC;EAClB"}
|
package/lib/index.js
CHANGED
|
@@ -63,9 +63,22 @@ export const Config = Schema.object({
|
|
|
63
63
|
masterPasswordEnv: Schema.string(),
|
|
64
64
|
path: Schema.string(),
|
|
65
65
|
name: Schema.string(),
|
|
66
|
+
accessMode: Schema.union([
|
|
67
|
+
Schema.const('readonly'),
|
|
68
|
+
Schema.const('readwrite'),
|
|
69
|
+
]),
|
|
70
|
+
autoCapture: Schema.boolean(),
|
|
66
71
|
});
|
|
67
72
|
export function apply(ctx, config) {
|
|
68
73
|
const masterPassword = resolveMasterPassword(config);
|
|
74
|
+
const accessMode = config.accessMode ?? 'readwrite';
|
|
75
|
+
const autoCapture = config.autoCapture ?? false;
|
|
76
|
+
/** Reject mutations when the vault is in readonly mode. */
|
|
77
|
+
function assertWritable(action) {
|
|
78
|
+
if (accessMode === 'readonly') {
|
|
79
|
+
throw new Error(`vault: ${action} is disabled in readonly mode (set accessMode: "readwrite" to enable)`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
69
82
|
/** Ensure the shared store is open (lazily on first use, so a missing
|
|
70
83
|
* master password fails at the first tool call with a clear message). */
|
|
71
84
|
async function ensureStore() {
|
|
@@ -76,6 +89,30 @@ export function apply(ctx, config) {
|
|
|
76
89
|
const s = await ensureStore();
|
|
77
90
|
return s.get(id);
|
|
78
91
|
}
|
|
92
|
+
// System prompt guidance: tells the model how the vault works, what the
|
|
93
|
+
// current access mode allows, and — when autoCapture is enabled — to detect
|
|
94
|
+
// credentials in the conversation and offer to save them via vault_add.
|
|
95
|
+
const systemPrompt = ctx.get('systemPrompt');
|
|
96
|
+
systemPrompt?.section({
|
|
97
|
+
name: 'dsh-vault',
|
|
98
|
+
order: 150,
|
|
99
|
+
text: () => {
|
|
100
|
+
const lines = [
|
|
101
|
+
'## Encrypted credential vault (dsh-vault)',
|
|
102
|
+
`Access mode: ${accessMode === 'readonly' ? 'READONLY — you may search/read/generate codes but MUST NOT add, update, or delete entries.' : 'readwrite — you may add, update, delete, search, and read entries.'}`,
|
|
103
|
+
'Credentials are encrypted at rest (AES-256-GCM) under a master password the user configured; never ask for that password.',
|
|
104
|
+
'Use vault_search to find entries by title/username/host and vault_get (by id) to read full credentials when the task needs them.',
|
|
105
|
+
'Do not repeat secrets in the conversation when a credential was obtained via vault_get.',
|
|
106
|
+
];
|
|
107
|
+
if (autoCapture) {
|
|
108
|
+
lines.push('Auto-capture is ON: when the user shares an API key, token, password, or other credential in conversation', '(e.g. "my npm token is npm_…", "use this GitHub PAT"), offer to store it with vault_add under a clear title.', 'Capture user preference: if they agree (or have previously agreed to auto-save), call vault_add immediately;', 'if they decline or it is unclear, do NOT store it. Never auto-save credentials that were not explicitly shared.');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
lines.push('Auto-capture is OFF: do not save credentials from the conversation unless the user explicitly asks you to.');
|
|
112
|
+
}
|
|
113
|
+
return lines.join('\n');
|
|
114
|
+
},
|
|
115
|
+
});
|
|
79
116
|
ctx.tools.register(defineTool({
|
|
80
117
|
name: 'vault_add',
|
|
81
118
|
description: 'Add a new credential entry to the encrypted vault. '
|
|
@@ -126,6 +163,7 @@ export function apply(ctx, config) {
|
|
|
126
163
|
render: (_args, value) => [{ type: 'text', text: `${value.message} (id: ${value.id})` }],
|
|
127
164
|
},
|
|
128
165
|
async execute(args) {
|
|
166
|
+
assertWritable('vault_add');
|
|
129
167
|
if (!args.title.trim())
|
|
130
168
|
throw new Error('vault_add: title must not be empty');
|
|
131
169
|
const s = await ensureStore();
|
|
@@ -262,6 +300,7 @@ export function apply(ctx, config) {
|
|
|
262
300
|
render: (_args, value) => [{ type: 'text', text: value.found ? 'entry updated' : 'entry not found' }],
|
|
263
301
|
},
|
|
264
302
|
async execute(args) {
|
|
303
|
+
assertWritable('vault_update');
|
|
265
304
|
const s = await ensureStore();
|
|
266
305
|
const patch = {};
|
|
267
306
|
for (const key of [
|
|
@@ -298,6 +337,7 @@ export function apply(ctx, config) {
|
|
|
298
337
|
render: (_args, value) => [{ type: 'text', text: value.message }],
|
|
299
338
|
},
|
|
300
339
|
async execute(args) {
|
|
340
|
+
assertWritable('vault_delete');
|
|
301
341
|
const s = await ensureStore();
|
|
302
342
|
const deleted = await s.delete(args.id);
|
|
303
343
|
return { deleted, message: deleted ? 'entry deleted' : 'entry not found' };
|
|
@@ -397,6 +437,8 @@ export function apply(ctx, config) {
|
|
|
397
437
|
masterPassword,
|
|
398
438
|
...(config.path !== undefined ? { path: config.path } : {}),
|
|
399
439
|
...(config.name !== undefined ? { name: config.name } : {}),
|
|
440
|
+
accessMode,
|
|
441
|
+
autoCapture,
|
|
400
442
|
});
|
|
401
443
|
}
|
|
402
444
|
/**
|
|
@@ -408,6 +450,7 @@ export function apply(ctx, config) {
|
|
|
408
450
|
let VaultGateway = (() => {
|
|
409
451
|
let _classSuper = TypertRemoteService;
|
|
410
452
|
let _instanceExtraInitializers = [];
|
|
453
|
+
let _config_decorators;
|
|
411
454
|
let _list_decorators;
|
|
412
455
|
let _get_decorators;
|
|
413
456
|
let _search_decorators;
|
|
@@ -418,6 +461,7 @@ let VaultGateway = (() => {
|
|
|
418
461
|
return class VaultGateway extends _classSuper {
|
|
419
462
|
static {
|
|
420
463
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
464
|
+
_config_decorators = [Remote('config')];
|
|
421
465
|
_list_decorators = [Remote('list')];
|
|
422
466
|
_get_decorators = [Remote('get')];
|
|
423
467
|
_search_decorators = [Remote('search')];
|
|
@@ -425,6 +469,7 @@ let VaultGateway = (() => {
|
|
|
425
469
|
_update_decorators = [Remote('update')];
|
|
426
470
|
_delete_decorators = [Remote('delete')];
|
|
427
471
|
_totp_decorators = [Remote('totp')];
|
|
472
|
+
__esDecorate(this, null, _config_decorators, { kind: "method", name: "config", static: false, private: false, access: { has: obj => "config" in obj, get: obj => obj.config }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
428
473
|
__esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
429
474
|
__esDecorate(this, null, _get_decorators, { kind: "method", name: "get", static: false, private: false, access: { has: obj => "get" in obj, get: obj => obj.get }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
430
475
|
__esDecorate(this, null, _search_decorators, { kind: "method", name: "search", static: false, private: false, access: { has: obj => "search" in obj, get: obj => obj.search }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -438,11 +483,15 @@ let VaultGateway = (() => {
|
|
|
438
483
|
masterPassword = __runInitializers(this, _instanceExtraInitializers);
|
|
439
484
|
vaultPath;
|
|
440
485
|
vaultName;
|
|
486
|
+
accessMode;
|
|
487
|
+
autoCapture;
|
|
441
488
|
constructor(ctx, config) {
|
|
442
489
|
super(ctx, 'vault');
|
|
443
490
|
this.masterPassword = config.masterPassword ?? resolveMasterPassword(config);
|
|
444
491
|
this.vaultPath = config.path;
|
|
445
492
|
this.vaultName = config.name;
|
|
493
|
+
this.accessMode = config.accessMode ?? 'readwrite';
|
|
494
|
+
this.autoCapture = config.autoCapture ?? false;
|
|
446
495
|
}
|
|
447
496
|
async ensureStore() {
|
|
448
497
|
return sharedVaultStore(this.masterPassword, {
|
|
@@ -450,6 +499,16 @@ let VaultGateway = (() => {
|
|
|
450
499
|
...(this.vaultName !== undefined ? { name: this.vaultName } : {}),
|
|
451
500
|
});
|
|
452
501
|
}
|
|
502
|
+
/** Reject mutations when the vault is in readonly mode (UI surface). */
|
|
503
|
+
assertWritable(action) {
|
|
504
|
+
if (this.accessMode === 'readonly') {
|
|
505
|
+
throw new Error(`vault: ${action} is disabled in readonly mode (set accessMode: "readwrite" to enable)`);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
/** Current access policy and capture preference, for the Settings UI. */
|
|
509
|
+
async config() {
|
|
510
|
+
return { accessMode: this.accessMode, autoCapture: this.autoCapture };
|
|
511
|
+
}
|
|
453
512
|
/** List every entry as a non-secret summary. */
|
|
454
513
|
async list() {
|
|
455
514
|
const store = await this.ensureStore();
|
|
@@ -470,6 +529,7 @@ let VaultGateway = (() => {
|
|
|
470
529
|
}
|
|
471
530
|
/** Add a new entry; returns its id and summary. */
|
|
472
531
|
async add(patch) {
|
|
532
|
+
this.assertWritable('add');
|
|
473
533
|
if (!patch.title.trim())
|
|
474
534
|
throw new Error('vault: title must not be empty');
|
|
475
535
|
const store = await this.ensureStore();
|
|
@@ -478,6 +538,7 @@ let VaultGateway = (() => {
|
|
|
478
538
|
}
|
|
479
539
|
/** Update an existing entry's fields; returns the updated summary or not-found. */
|
|
480
540
|
async update(id, patch) {
|
|
541
|
+
this.assertWritable('update');
|
|
481
542
|
const store = await this.ensureStore();
|
|
482
543
|
const updated = await store.update(id, patch);
|
|
483
544
|
if (updated === undefined)
|
|
@@ -486,6 +547,7 @@ let VaultGateway = (() => {
|
|
|
486
547
|
}
|
|
487
548
|
/** Delete an entry by id. */
|
|
488
549
|
async delete(id) {
|
|
550
|
+
this.assertWritable('delete');
|
|
489
551
|
const store = await this.ensureStore();
|
|
490
552
|
return { deleted: await store.delete(id) };
|
|
491
553
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vault",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Encrypted credential vault for DeepSeek Harness: store and retrieve usernames, emails, phone numbers, passwords, TOTP secrets, SSH/API-key/OAuth developer credentials through model tools and a Settings UI page.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|