dsh-privacy-gateway 0.1.4 → 0.1.5

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.en.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  [简体中文](README.md) | English
4
4
 
5
- A DeepSeek Harness plugin that adds a redaction gateway on the host process's undici global dispatcher. Secrets in outgoing model request bodies are replaced with placeholders, and placeholders in the replies are replaced back with the real values. The agent, adapters and providers don't notice it, and one interception point covers every provider that goes through `fetch()`, including adapters that plugins provide.
5
+ ![The model only sees {{placeholder}}: secrets, credentials and personal data are replaced with placeholders before they are sent, and restored in the replies — one interception point, every provider goes through it](docs/assets/screenshots/0-banner.png)
6
6
 
7
- Status: published on npm.
7
+ A redaction gateway on the host process's undici global dispatcher. Secrets in outgoing model request bodies are replaced with placeholders, and placeholders in the replies are replaced back with the real values. The agent, adapters and providers don't notice it, and one interception point covers every provider that goes through `fetch()`, including adapters that plugins provide.
8
+
9
+ If you are using an **API relay**, or you are working with **sensitive information** or **production data**, please be sure to protect information security.
8
10
 
9
11
  ## Install
10
12
 
@@ -13,12 +15,20 @@ Status: published on npm.
13
15
  dsh plugin --profile web add dsh-privacy-gateway@latest
14
16
 
15
17
  # The same version as a GitHub Release asset (prereleases get one too)
16
- dsh plugin --profile web add https://github.com/xbzbing/dsh-privacy-gateway/releases/download/v0.1.0/dsh-privacy-gateway-0.1.0.tgz
18
+ dsh plugin --profile web add https://github.com/xbzbing/dsh-privacy-gateway/releases/download/v0.1.4/dsh-privacy-gateway-0.1.4.tgz
17
19
  ```
18
20
 
19
21
  A prerelease version has a `-` in it and goes to GitHub Releases only, never to npm. The repository does not commit `lib/`, so `dsh plugin add github:…` cannot load the plugin ([ADR-0006](docs/adr/0006-distribution-and-build-artifacts.md)).
20
22
 
21
- In the default web profile the first install works at once, with no restart. After an upgrade, a release that changed only the client takes effect at once; one with host changes needs a restart of dsh.
23
+ In the default web profile the first install works at once, with no restart of the dsh instance. Updating the plugin through the dsh web profile's plugin update feature needs no restart of the dsh instance either. When updating by hand, uninstall the old version before installing the new one, and that needs no restart either.
24
+
25
+ ## Features
26
+
27
+ - **What is masked**: keys, tokens, passwords, private keys, cookies, email addresses, phone numbers, ID card and bank card numbers, and your own words — each with its own switch.
28
+ - **Actions**: pick `mask` / `warn` / `block` per kind; a key can be sent as a made-up key of its own form (`shape`).
29
+ - **Records and statistics**: records written to disk by the day, a statistics card, and the session's 「隐私保护」 (Privacy) tab; a record holds placeholders, never a value.
30
+ - **The `/privacy` command**: status, a temporary on / off, and `test` to preview how a text would go out.
31
+ - **Live configuration**: everyday items are changed on the plugin page and apply from the next call; when masking fails, the request is not sent.
22
32
 
23
33
  ## What is masked
24
34
 
@@ -58,6 +68,7 @@ someone@gmail.com → EMAIL
58
68
  - One value seen again gets the same placeholder.
59
69
  - A secret shorter than 8 characters (`abc123`, `666666`, `888888`: a short password) is no value: it goes as written and makes no record. It is guessed in no time, so masking it only promises a protection that is not there — and the value table never matched anything that short as known anyway ([ADR-0031](docs/adr/0031-no-short-or-template-values.md)).
60
70
  - A value typed to stand for a key is no value: eight or more of one character in a row (`sk-proj-xxxx…`, `AKIA0000…`), or one that says what it is (`your_api_key`, `example`, `changeme`, `placeholder`, `dummy`, `***`). A random key has such a run with a chance below one in a billion, and a vendor's real test key (`sk_test_…`) is still masked ([ADR-0031](docs/adr/0031-no-short-or-template-values.md)).
71
+ - The name of a cryptographic algorithm is no value: names like `SCRAM-SHA-512` and `PBKDF2WithHmacSHA256` are published in a spec for anyone to read, so masking one hides nothing; they go as they are ([ADR-0033](docs/adr/0033-algorithm-names.md)).
61
72
  - A key is masked the way a value is: the key in `{"metadata": {"sk-…": …}}` goes as a placeholder and comes back in the reply. The protocol's own keys (`model`, `role`, `type`, `name`, `id` and so on), the tool definitions and a tool call's argument names are never touched ([ADR-0029](docs/adr/0029-mask-json-keys.md)).
62
73
 
63
74
  ## Screens
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  [English](README.en.md) | 简体中文
4
4
 
5
- DeepSeek Harness 插件:在宿主进程的 undici 全局 dispatcher 上装一层脱敏网关。出站把模型请求体里的密钥换成占位符,入站把回流里的占位符换回真值。对 agent、adapter、provider 都无感,一处拦截覆盖所有走 `fetch()` 的 provider,包括插件提供的 adapter。
5
+ ![模型只看见 {{占位符}}:密钥、凭据、个人信息发出前换成占位符,回复里再换回原值,一处拦截,所有 provider 都经过它](docs/assets/screenshots/0-banner.png)
6
6
 
7
- 状态:已发布到 npm。
7
+ 在宿主进程的 undici 全局 dispatcher 上装一层脱敏网关。出站把模型请求体里的密钥换成占位符,入站把回流里的占位符换回真值。对 agent、adapter、provider 都无感,一处拦截覆盖所有走 `fetch()` 的 provider,包括插件提供的 adapter。
8
+
9
+ 如果你在用**中转站**或者在处理**敏感信息**、**线上数据**,请务必注意保护信息安全。
8
10
 
9
11
  ## 安装
10
12
 
@@ -13,12 +15,20 @@ DeepSeek Harness 插件:在宿主进程的 undici 全局 dispatcher 上装一
13
15
  dsh plugin --profile web add dsh-privacy-gateway@latest
14
16
 
15
17
  # 同一版本的 GitHub Release 附件(预发布也发在这里)
16
- dsh plugin --profile web add https://github.com/xbzbing/dsh-privacy-gateway/releases/download/v0.1.0/dsh-privacy-gateway-0.1.0.tgz
18
+ dsh plugin --profile web add https://github.com/xbzbing/dsh-privacy-gateway/releases/download/v0.1.4/dsh-privacy-gateway-0.1.4.tgz
17
19
  ```
18
20
 
19
21
  预发布版本号带 `-`,只发 GitHub Release、不发 npm。仓库不提交 `lib/`,`dsh plugin add github:…` 拿到的树加载不了([ADR-0006](docs/adr/0006-distribution-and-build-artifacts.md))。
20
22
 
21
- 在默认的 web profile 里首次安装即装即用,无需重启。更新时,只改 client 的版本立即生效;含 host 改动的版本需重启 dsh。
23
+ 在默认的 web profile 里首次安装即装即用,无需重启 dsh 实例。通过 dsh web profile 的插件更新功能更新插件时,无需重启 dsh 实例。手动更新时建议先卸载旧版本再安装新版本,这样也不需要重启。
24
+
25
+ ## 功能
26
+
27
+ - **脱敏范围**:密钥、token、密码、私钥、cookie、邮箱、手机号、身份证、银行卡、自定义敏感词,各有开关。
28
+ - **动作可选**:按 kind 选 `mask` / `warn` / `block`,密钥可换成同形的假 key(`shape`)。
29
+ - **记录与统计**:按天落盘的脱敏记录、统计卡、会话「隐私保护」标签页;记录里只有占位符,没有真值。
30
+ - **`/privacy` 命令**:查状态、临时开关、`test` 预览一段文本会怎样发出。
31
+ - **配置热更新**:日常项在插件页上改,下一次调用即生效;脱敏出错时请求不发出。
22
32
 
23
33
  ## 脱敏范围
24
34
 
@@ -58,6 +68,7 @@ someone@gmail.com → EMAIL
58
68
  - 同一个值重复出现,占位符相同。
59
69
  - 短于 8 个字符的秘密(`abc123`、`666666`、`888888` 这类口令)不算值:照原样发出,也不进记录。它们随时能被爆破,遮住只是给人一种并不存在的保护;值表本来也不把这么短的值当作已知值([ADR-0031](docs/adr/0031-no-short-or-template-values.md))。
60
70
  - 明显是占位写法的值不算值:8 个以上相同字符连排(`sk-proj-xxxx…`、`AKIA0000…`),或自带「这是占位」说明(`your_api_key`、`example`、`changeme`、`placeholder`、`dummy`、`***`)。随机 key 出现 8 连排的概率低于十亿分之一,`sk_test_…` 这种真测试 key 照旧脱敏([ADR-0031](docs/adr/0031-no-short-or-template-values.md))。
71
+ - 加密算法的名字不算值:`SCRAM-SHA-512`、`PBKDF2WithHmacSHA256` 这类名字写在规范里、人人可读,遮住什么都不保护,原样发出([ADR-0033](docs/adr/0033-algorithm-names.md))。
61
72
  - 键名和值一样脱敏:`{"metadata": {"sk-…": …}}` 里的键名也换成占位符,回复里再换回来;协议自身的键(`model`、`role`、`type`、`name`、`id` 等)、工具定义和工具调用的参数名不动([ADR-0029](docs/adr/0029-mask-json-keys.md))。
62
73
 
63
74
  ## 界面
package/lib/index.js CHANGED
@@ -1113,6 +1113,37 @@ function fileNameValue(v) {
1113
1113
  const dot = v.lastIndexOf(".");
1114
1114
  return dot > 0 && dot < v.length - 1 && FILE_EXT$1.has(v.slice(dot + 1).toLowerCase());
1115
1115
  }
1116
+ /**
1117
+ * The words a published cryptographic algorithm's name is built from: scram,
1118
+ * sha, aes, gcm, pbkdf, with, padding, tls, siv, poly. The list is closed and
1119
+ * disjoint from SECRET_WORDS, so a real secret's random characters spell no
1120
+ * word of it (docs/adr/0033).
1121
+ */
1122
+ const ALGO_WORDS = new Set("scram sha shake md blake ripemd whirlpool crc xxh siphash hmac hkdf pbkdf argon bcrypt scrypt with aes des desede rc twofish serpent camellia idea chacha cha salsa blowfish aria sm ecb cbc ctr ccm gcm cfb ofb xts siv kw kwr padding pkcs oaep pss no rsa dsa dh ecdsa ecdh ecdhe ed x p ecc curve id tls ssl sasl gssapi jwt jose hs rs es ps poly".split(" "));
1123
+ /** The words in a value: runs of letters, with the boundary of a camelCase word opened. */
1124
+ function algorithmWords(v) {
1125
+ const out = [];
1126
+ for (const part of v.split(/[^A-Za-z]+/)) {
1127
+ if (part === "") continue;
1128
+ for (const w of part.match(/[A-Z]+[a-z]*|[a-z]+|[A-Z]+/g) ?? []) out.push(w.toLowerCase());
1129
+ }
1130
+ return out;
1131
+ }
1132
+ /**
1133
+ * The name of a published cryptographic algorithm, not a value: a Kafka
1134
+ * scram_mechanism's SCRAM-SHA-512, PBKDF2WithHmacSHA256,
1135
+ * ECDHE-RSA-AES128-GCM-SHA256. A spec publishes these names for anyone to
1136
+ * read, so masking one hides nothing — it only mangles a config in a tool's
1137
+ * output, and a reader suspects the config was edited. Every word of the
1138
+ * value has to be one of ALGO_WORDS and its characters a name's, or it is not
1139
+ * one: the words are published vocabulary, and a secret is not spelled out of
1140
+ * them (docs/adr/0033).
1141
+ */
1142
+ function algorithmValue(v) {
1143
+ if (!hasDigit(v) || !/^[A-Za-z0-9][A-Za-z0-9 ._+/-]*$/.test(v)) return false;
1144
+ const words = algorithmWords(v);
1145
+ return words.length > 0 && words.every((w) => ALGO_WORDS.has(w));
1146
+ }
1116
1147
  const SECRET_WORDS = new Set([
1117
1148
  "token",
1118
1149
  "tokens",
@@ -2024,7 +2055,7 @@ function takes(r, s$1, a, b) {
2024
2055
  if (r.bound && (a > 0 && r.bound.includes(s$1[a - 1]) || b < s$1.length && r.bound.includes(s$1[b]))) return false;
2025
2056
  if (r.cat === "secret") {
2026
2057
  const v = s$1.slice(a, b);
2027
- if (v.length < MIN_SECRET_CHARS || !notATemplate(v)) return false;
2058
+ if (v.length < MIN_SECRET_CHARS || !notATemplate(v) || algorithmValue(v)) return false;
2028
2059
  }
2029
2060
  if (r.ok && !r.ok(s$1.slice(a, b))) return false;
2030
2061
  return !r.at || r.at(s$1, a, b);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-privacy-gateway",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Process-wide HTTP redaction gateway for DSH: masks secrets in outgoing model requests and restores placeholders in the replies, for every provider.",
6
6
  "icon": "./assets/icon.svg",