dsh-privacy-gateway 0.1.3 → 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
@@ -125,7 +136,7 @@ With `vendorView` on (「保留发出内容,供对照查看」, Keep what was
125
136
 
126
137
  - The session log holds the real values: replies are restored before the log is written ([ADR-0003](docs/adr/0003-restore-before-session-log.md)). Session sync, backups and shares carry the real values.
127
138
  - Only traffic through the global `fetch()` is covered; direct `node:http`, worker threads and separate processes bypass the gateway ([ADR-0001](docs/adr/0001-intercept-at-undici-global-dispatcher.md)).
128
- - Compressed requests and replies are decompressed before they are masked or restored; a `content-encoding` with no decoder fails the request ([ADR-0025](docs/adr/0025-compression-and-upgrades.md)). Upgrades (the WebSocket handshake) are refused as well: Codex falls back to SSE the first time and takes SSE from then on in that session; a WebSocket another plugin opens through the global dispatcher is refused too, so put its host in `excludeHosts` if it needs one.
139
+ - Compressed requests and replies are decompressed before they are masked or restored; a `content-encoding` with no decoder fails the request ([ADR-0025](docs/adr/0025-compression-and-upgrades.md)). An upgrade (the WebSocket handshake) or a `CONNECT` tunnel inside a model call is refused as well: Codex falls back to SSE the first time and takes SSE from then on in that session. One opened by a plugin outside a model call (dsh-im-infoflow's inbound, say) is let through, its messages unmasked, with one warning per host ([ADR-0032](docs/adr/0032-upgrade-scoped-to-masked-calls.md)) — a fail-closed to fail-open trade whose cost the ADR records; a host that needs a transparent link can still go into `excludeHosts`.
129
140
  - The value table is in memory only ([ADR-0009](docs/adr/0009-value-table-and-restore-exfiltration.md)). After a restart, a value no rule finds, masked only because it was remembered, goes as written the first time it is sent again.
130
141
  - Replies are restored everywhere, tool call arguments included: a model led into writing a placeholder into a command such as `curl` runs the tool with the real value. The plugin counts these places (the tool-argument count on the card and in `/privacy status`) and does not block them ([ADR-0009](docs/adr/0009-value-table-and-restore-exfiltration.md)).
131
142
  - When masking fails, the request is not sent and fails with `dsh-privacy-gateway: masking failed, request not sent` ([ADR-0005](docs/adr/0005-fail-closed.md)). To recover, run `/privacy off`, or disable the plugin on the Plugins page or set `enabled` to `false`.
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
  ## 界面
@@ -123,7 +134,7 @@ someone@gmail.com → EMAIL
123
134
 
124
135
  - 会话日志里是真值:还原发生在日志落盘之前([ADR-0003](docs/adr/0003-restore-before-session-log.md))。会话同步、备份、分享带走的是真值。
125
136
  - 覆盖面只有走全局 `fetch()` 的流量;`node:http` 直连、worker 线程、独立进程不经过网关([ADR-0001](docs/adr/0001-intercept-at-undici-global-dispatcher.md))。
126
- - 压缩的请求与回复先解压再脱敏、还原;认不出的 `content-encoding` 不发([ADR-0025](docs/adr/0025-compression-and-upgrades.md))。带 `upgrade` 的握手(WebSocket)也不发:Codex 第一次被拒后回落到 SSE,之后同一会话直接走 SSE;其他插件经全局 dispatcher 打开的 WebSocket 同样被拒,需要时把它的 host 加进 `excludeHosts`。
137
+ - 压缩的请求与回复先解压再脱敏、还原;认不出的 `content-encoding` 不发([ADR-0025](docs/adr/0025-compression-and-upgrades.md))。模型调用里的 `upgrade` 握手(WebSocket)与 `CONNECT` 隧道也不发:Codex 第一次被拒后回落到 SSE,之后同一会话直接走 SSE;模型调用之外的升级与隧道(别的插件自己的连接,如 dsh-im-infoflow 的入站)放行,消息不脱敏,每个 host 提示一次([ADR-0032](docs/adr/0032-upgrade-scoped-to-masked-calls.md))——这是 fail-closed 往 fail-open 的取舍,代价见 ADR;需要整条链路放行的 host 仍可加进 `excludeHosts`。
127
138
  - 值表只在内存里([ADR-0009](docs/adr/0009-value-table-and-restore-exfiltration.md))。重启后,规则命不中、只靠记忆兜住的值第一次出站会按原文发出。
128
139
  - 还原发生在回复里,包括工具调用参数:模型被诱导把占位符写进 `curl` 之类的命令时,工具执行时用的是真值。插件只记账(统计卡与 `/privacy status` 里的「工具参数」计数),不拦截([ADR-0009](docs/adr/0009-value-table-and-restore-exfiltration.md))。
129
140
  - 脱敏出错时请求不会发出,报错 `dsh-privacy-gateway: masking failed, request not sent`([ADR-0005](docs/adr/0005-fail-closed.md))。止血办法是 `/privacy off`,或在插件页停用本插件、把配置 `enabled` 设为 `false`。
package/lib/index.d.ts CHANGED
@@ -168,8 +168,11 @@ interface LayerInfo {
168
168
  * The gateway: an undici dispatcher chained in front of whatever dispatcher
169
169
  * was global before it (docs/adr/0001). A POST whose body is a JSON model
170
170
  * request goes on masked, its reply restored; everything else goes on
171
- * untouched. Masking that throws fails the request instead of sending it
172
- * (docs/adr/0005). The layers under it are ordered by role (docs/adr/0012).
171
+ * untouched. An upgrade a model call opens (the Codex WebSocket) is refused
172
+ * (docs/adr/0025); one a plugin opens outside a call — dsh-im-infoflow's
173
+ * inbound, say — is let through unmasked, with one warn per host
174
+ * (docs/adr/0032). Masking that throws fails the request instead of sending
175
+ * it (docs/adr/0005). The layers under it are ordered by role (docs/adr/0012).
173
176
  */
174
177
  declare class MaskingDispatcher extends Dispatcher {
175
178
  #private;
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);
@@ -4463,27 +4494,46 @@ function elapsed(started) {
4463
4494
  const current = new AsyncLocalStorage();
4464
4495
  /**
4465
4496
  * The excluded provider whose stream the caller runs in, if any. A context
4466
- * that only carries the session (a masked provider's stream) names none: an
4467
- * empty or absent provider is never a bypass.
4497
+ * that is a model call names none: an empty or absent provider is never a
4498
+ * bypass.
4468
4499
  */
4469
4500
  function bypassedProvider() {
4470
- const provider = current.getStore()?.provider;
4471
- return typeof provider === "string" && provider !== "" ? provider : void 0;
4501
+ const store = current.getStore();
4502
+ return store?.kind === "excluded" && store.provider !== "" ? store.provider : void 0;
4472
4503
  }
4473
4504
  /** The session the request being started belongs to, when it is one the host named (docs/adr/0020). */
4474
4505
  function currentSession() {
4475
4506
  return current.getStore()?.session;
4476
4507
  }
4508
+ /**
4509
+ * Whether the current async context is a model call (docs/adr/0032). An
4510
+ * upgrade inside one is the provider's transport and is refused; one a plugin
4511
+ * opens outside any call is its own connection and was let through. It answers
4512
+ * "is this call", not "is masking on": a call an explicit bypass lets by is
4513
+ * still one, and the dispatcher asks the bypass first.
4514
+ */
4515
+ function inModelCall() {
4516
+ return current.getStore()?.kind === "masked";
4517
+ }
4477
4518
  /** `open`'s stream, with each step it takes (the request it starts, every chunk it reads) run in the context of `provider`. */
4478
4519
  function bypassing(provider, open$1, session) {
4479
4520
  return within((f) => current.run({
4521
+ kind: "excluded",
4480
4522
  provider,
4481
4523
  ...session ? { session } : {}
4482
4524
  }, f), open$1);
4483
4525
  }
4484
- /** `open`'s stream run outside any excluded provider: a nested call to a provider that is masked is masked. */
4485
- function unbypassing(open$1, session) {
4486
- return within((f) => current.run(session ? { session } : void 0, f), open$1);
4526
+ /**
4527
+ * `open`'s stream as a model call: it leaves any excluded provider's context
4528
+ * (a nested call to a provider that is masked is masked) and marks the stream
4529
+ * as a call, so the gateway can refuse an upgrade the call opens
4530
+ * (docs/adr/0032) and still name the session in its records.
4531
+ */
4532
+ function asModelCall(open$1, session) {
4533
+ return within((f) => current.run({
4534
+ kind: "masked",
4535
+ ...session ? { session } : {}
4536
+ }, f), open$1);
4487
4537
  }
4488
4538
  /**
4489
4539
  * What the `llm/stream` listener hands on for a call to `provider`: the stream
@@ -4493,7 +4543,7 @@ function unbypassing(open$1, session) {
4493
4543
  function routeStream(provider, excluded, next, sessionId) {
4494
4544
  const session = typeof sessionId === "string" && sessionId !== "" ? sessionId : void 0;
4495
4545
  if (isExcluded(provider, excluded)) return bypassing(provider, next, session);
4496
- return current.getStore() === void 0 && session === void 0 ? next() : unbypassing(next, session);
4546
+ return asModelCall(next, session);
4497
4547
  }
4498
4548
  function within(run, open$1) {
4499
4549
  return { [Symbol.asyncIterator]() {
@@ -5003,8 +5053,11 @@ const RANK = {
5003
5053
  * The gateway: an undici dispatcher chained in front of whatever dispatcher
5004
5054
  * was global before it (docs/adr/0001). A POST whose body is a JSON model
5005
5055
  * request goes on masked, its reply restored; everything else goes on
5006
- * untouched. Masking that throws fails the request instead of sending it
5007
- * (docs/adr/0005). The layers under it are ordered by role (docs/adr/0012).
5056
+ * untouched. An upgrade a model call opens (the Codex WebSocket) is refused
5057
+ * (docs/adr/0025); one a plugin opens outside a call — dsh-im-infoflow's
5058
+ * inbound, say — is let through unmasked, with one warn per host
5059
+ * (docs/adr/0032). Masking that throws fails the request instead of sending
5060
+ * it (docs/adr/0005). The layers under it are ordered by role (docs/adr/0012).
5008
5061
  */
5009
5062
  var MaskingDispatcher = class extends Dispatcher {
5010
5063
  #engine;
@@ -5014,6 +5067,8 @@ var MaskingDispatcher = class extends Dispatcher {
5014
5067
  #layers;
5015
5068
  #seq = 0;
5016
5069
  #order;
5070
+ /** Hosts a tunnel was let through to: each warned about once, however often it reconnects. */
5071
+ #warnedTunnels = /* @__PURE__ */ new Set();
5017
5072
  /** Set once the gateway is disposed: every request that still reaches it (through a layer that holds it) passes through. */
5018
5073
  bypass = false;
5019
5074
  [kGateway] = true;
@@ -5115,9 +5170,17 @@ var MaskingDispatcher = class extends Dispatcher {
5115
5170
  }
5116
5171
  if (!this.bypass) this.heal?.();
5117
5172
  if (!this.bypass && isTunnel(opts) && !this.#passes(opts)) {
5118
- this.#logger?.warn(`dsh-privacy-gateway: a ${tunnelName(opts)} connection to ${targetHost(opts)?.host ?? "an unknown host"} was refused: its messages cannot be masked`);
5119
- failRequest(wrapHandler(handler), new PrivacyGatewayError("a WebSocket or other upgraded connection cannot be masked, it was not opened", void 0, "DSH_PRIVACY_GATEWAY_UPGRADE_REFUSED"));
5120
- return true;
5173
+ const host = targetHost(opts)?.host ?? "an unknown host";
5174
+ if (inModelCall()) {
5175
+ this.#logger?.warn(`dsh-privacy-gateway: a ${tunnelName(opts)} connection to ${host} was refused: its messages cannot be masked`);
5176
+ failRequest(wrapHandler(handler), new PrivacyGatewayError("a WebSocket or other upgraded connection cannot be masked, it was not opened", void 0, "DSH_PRIVACY_GATEWAY_UPGRADE_REFUSED"));
5177
+ return true;
5178
+ }
5179
+ if (!this.#warnedTunnels.has(host)) {
5180
+ if (this.#warnedTunnels.size >= 32) this.#warnedTunnels.clear();
5181
+ this.#warnedTunnels.add(host);
5182
+ this.#logger?.warn(`dsh-privacy-gateway: a ${tunnelName(opts)} connection to ${host} was let through: its messages are not masked, and neither are those of further connections to it`);
5183
+ }
5121
5184
  }
5122
5185
  const next = this.downstream();
5123
5186
  if (this.bypass || !this.#candidate(opts)) return next.dispatch({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-privacy-gateway",
3
- "version": "0.1.3",
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",