@linxin666/dsh-ssh 0.4.6 → 0.4.8

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/lib/index.js CHANGED
@@ -216,6 +216,7 @@ function validateHostPayload(payload) {
216
216
  const proxyJump = Array.isArray(p.proxyJump) ? p.proxyJump : [];
217
217
  if (proxyCommand !== void 0 && proxyJump.length > 0) return "proxyCommand and proxyJump cannot be combined — pick one transport per host";
218
218
  if (p.tags !== void 0 && (!Array.isArray(p.tags) || p.tags.some((x) => typeof x !== "string"))) return "tags must be an array of strings";
219
+ if (p.forwardAgent !== void 0 && typeof p.forwardAgent !== "boolean") return "forwardAgent must be a boolean";
219
220
  }
220
221
  /** Alias grammar: letters/digits plus dots, hyphens, underscores (IP/domain aliases included). */
221
222
  const ALIAS_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
@@ -265,6 +266,7 @@ var HostStore = class {
265
266
  ...entry.environment !== void 0 ? { environment: entry.environment } : {},
266
267
  tags: [...entry.tags],
267
268
  ...entry.location !== void 0 ? { location: entry.location } : {},
269
+ forwardAgent: entry.forwardAgent === true,
268
270
  createdAt: entry.createdAt,
269
271
  updatedAt: entry.updatedAt
270
272
  };
@@ -299,6 +301,7 @@ var HostStore = class {
299
301
  environment: payload.environment?.trim() || void 0,
300
302
  tags: [...payload.tags ?? []].map((tag) => tag.trim()).filter((tag) => tag !== ""),
301
303
  location: payload.location?.trim() || void 0,
304
+ forwardAgent: payload.forwardAgent === true ? true : void 0,
302
305
  createdAt: now,
303
306
  updatedAt: now
304
307
  };
@@ -316,6 +319,7 @@ var HostStore = class {
316
319
  if (patch.port !== void 0 && (typeof patch.port !== "number" || !Number.isInteger(patch.port) || patch.port < 1 || patch.port > 65535)) throw new Error("port must be an integer in 1..65535");
317
320
  if (patch.proxyJump !== void 0 && (!Array.isArray(patch.proxyJump) || patch.proxyJump.some((x) => typeof x !== "string" || x === ""))) throw new Error("proxyJump must be an array of alias strings");
318
321
  if (patch.proxyCommand !== void 0 && typeof patch.proxyCommand !== "string") throw new Error("proxyCommand must be a string when provided");
322
+ if (patch.forwardAgent !== void 0 && typeof patch.forwardAgent !== "boolean") throw new Error("forwardAgent must be a boolean");
319
323
  const mergedProxyCommand = patch.proxyCommand !== void 0 ? normalizeProxyCommand(patch.proxyCommand) : entry.proxyCommand;
320
324
  if (mergedProxyCommand !== void 0 && (patch.proxyJump ?? entry.proxyJump).length > 0) throw new Error("proxyCommand and proxyJump cannot be combined — pick one transport per host");
321
325
  if (patch.tags !== void 0 && (!Array.isArray(patch.tags) || patch.tags.some((x) => typeof x !== "string"))) throw new Error("tags must be an array of strings");
@@ -343,6 +347,7 @@ var HostStore = class {
343
347
  if (patch.environment !== void 0) entry.environment = patch.environment.trim() || void 0;
344
348
  if (patch.tags !== void 0) entry.tags = [...patch.tags].map((tag) => tag.trim()).filter((tag) => tag !== "");
345
349
  if (patch.location !== void 0) entry.location = patch.location.trim() || void 0;
350
+ if (patch.forwardAgent !== void 0) entry.forwardAgent = patch.forwardAgent === true ? true : void 0;
346
351
  entry.updatedAt = Date.now();
347
352
  this.save(file);
348
353
  return entry;
@@ -410,7 +415,8 @@ var HostStore = class {
410
415
  description: block.props.description,
411
416
  environment: block.props.environment,
412
417
  tags: (block.props.tags ?? "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== ""),
413
- location: block.props.location
418
+ location: block.props.location,
419
+ forwardAgent: parseForwardAgentValue(block.props.forwardagent)
414
420
  };
415
421
  try {
416
422
  this.create(payload);
@@ -500,6 +506,16 @@ function normalizeProxyCommand(raw) {
500
506
  if (trimmed.toLowerCase() === "none") return void 0;
501
507
  return trimmed;
502
508
  }
509
+ /**
510
+ * Read an ssh_config `ForwardAgent` value into the stored boolean flag. Only
511
+ * an explicit yes/true/on enables forwarding; an absent value, no/false/off,
512
+ * and anything unrecognized leave it off instead of failing the import — an
513
+ * unknown keyword must never cost the user the whole Host block.
514
+ */
515
+ function parseForwardAgentValue(raw) {
516
+ const value = raw?.trim().toLowerCase();
517
+ return value === "yes" || value === "true" || value === "on";
518
+ }
503
519
  /** Expand a leading `~` in a filesystem path. */
504
520
  function expandHome(path) {
505
521
  if (path === "~") return homedir();
@@ -746,6 +762,12 @@ function buildConnectConfig(entry, sock, opts) {
746
762
  config.privateKey = readFileSync(keyPath, "utf8");
747
763
  if (entry.auth.passphrase !== void 0 && entry.auth.passphrase !== "") config.passphrase = entry.auth.passphrase;
748
764
  }
765
+ if (entry.forwardAgent === true) {
766
+ const agentPath = typeof config.agent === "string" ? config.agent : resolveForwardAgentPath(entry.auth.agentPath);
767
+ if (agentPath === void 0) throw new Error("agent forwarding is enabled for this host but no ssh-agent endpoint is available: set SSH_AUTH_SOCK, start Pageant on Windows, or configure an agent path");
768
+ config.agent = agentPath;
769
+ config.agentForward = true;
770
+ }
749
771
  return config;
750
772
  }
751
773
  /** Resolve the ssh2 agent path for 'agent' auth. */
@@ -756,6 +778,18 @@ function resolveAgentPath(agentPath) {
756
778
  if (sock !== void 0 && sock !== "") return sock;
757
779
  if (process.platform === "win32") return "pageant";
758
780
  }
781
+ /**
782
+ * Resolve the ssh-agent endpoint that forwarding brokers signatures through:
783
+ * an explicitly configured agent path wins, then SSH_AUTH_SOCK, then Pageant
784
+ * on Windows. Undefined means no endpoint exists on this machine.
785
+ *
786
+ * Forwarding shares the auth resolution on purpose — the endpoint a host
787
+ * signs through is the same one it authenticates with — but it is a separate
788
+ * name so the forwarding path can evolve without touching auth.
789
+ */
790
+ function resolveForwardAgentPath(agentPath) {
791
+ return resolveAgentPath(agentPath);
792
+ }
759
793
  /** Connect one ssh2 client (resolve on ready, reject on error/close). */
760
794
  function connectClient(config, onKeyboardInteractive) {
761
795
  return new Promise((resolve, reject) => {
@@ -865,6 +899,12 @@ function parseJumpSpec(spec) {
865
899
  * Resolve one ProxyJump spec: an alias configured in this plugin wins, and any
866
900
  * other value is read as an OpenSSH address whose credentials come from the
867
901
  * target entry (an ad-hoc hop has no stored auth of its own).
902
+ *
903
+ * An address hop deliberately carries no forwardAgent flag: OpenSSH's
904
+ * ForwardAgent is a per-Host setting and an ad-hoc address was never
905
+ * configured, so it must never inherit the target's opt-in. A hop written as
906
+ * an alias uses that alias's own entry, which is how a user forwards on a
907
+ * bastion on purpose.
868
908
  */
869
909
  function resolveHop(engine, entry, spec) {
870
910
  const configured = engine.store.find(spec);
@@ -2088,12 +2128,26 @@ function isLoopbackHostname(hostname) {
2088
2128
  return isIPv4Loopback(hostname);
2089
2129
  }
2090
2130
  /**
2131
+ * Whether a reverse proxy stood between the client and this host: the request
2132
+ * carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
2133
+ * hop that forwards traffic, so the request did not originate on this machine.
2134
+ * @param request - node HTTP request.
2135
+ * @returns true when a forwarding header is present.
2136
+ */
2137
+ function isProxiedRequest(request) {
2138
+ return request.headers["cf-connecting-ip"] !== void 0 || request.headers["x-forwarded-for"] !== void 0;
2139
+ }
2140
+ /**
2091
2141
  * Request-level trust fence: a loopback socket address AND a loopback Host
2092
2142
  * header, plus browser same-origin markers. The socket address is
2093
- * authoritative; X-Forwarded-For is never trusted.
2143
+ * authoritative for a direct connection; a request that carries a forwarding
2144
+ * header is refused outright, because a proxy in front of the host makes both
2145
+ * the socket address and the Host header describe the proxy rather than the
2146
+ * client. X-Forwarded-For is therefore never evidence *for* loopback.
2094
2147
  */
2095
2148
  function isLoopbackRequest(request) {
2096
2149
  if (!isLoopbackAddress(request.socket.remoteAddress)) return false;
2150
+ if (isProxiedRequest(request)) return false;
2097
2151
  const host = request.headers.host;
2098
2152
  if (typeof host !== "string") return false;
2099
2153
  let hostUrl;
@@ -2227,7 +2281,8 @@ function makeRoutes(deps) {
2227
2281
  "user",
2228
2282
  "auth",
2229
2283
  "proxyJump",
2230
- "proxyCommand"
2284
+ "proxyCommand",
2285
+ "forwardAgent"
2231
2286
  ].some((key) => patch[key] !== void 0)) engine.dropAlias(alias);
2232
2287
  writeJson(res, 200, { host: store.summarize(entry) });
2233
2288
  } catch (error) {
@@ -2632,8 +2687,8 @@ function toAgentHostRow(host) {
2632
2687
  function renderHosts(hosts) {
2633
2688
  if (hosts.length === 0) return "no hosts configured";
2634
2689
  return [
2635
- "alias | host | port | user | auth | proxy | environment | tags | description",
2636
- "--- | --- | --- | --- | --- | --- | --- | --- | ---",
2690
+ "alias | host | port | user | auth | proxy | forward | environment | tags | description",
2691
+ "--- | --- | --- | --- | --- | --- | --- | --- | --- | ---",
2637
2692
  ...hosts.map((host) => [
2638
2693
  host.alias,
2639
2694
  host.host,
@@ -2641,6 +2696,7 @@ function renderHosts(hosts) {
2641
2696
  host.user,
2642
2697
  host.auth,
2643
2698
  host.proxyJump.length > 0 ? "jump:" + host.proxyJump.join(",") : host.proxyCommandConfigured ? "proxy-command" : "-",
2699
+ host.forwardAgent ? "yes" : "-",
2644
2700
  host.environment ?? "-",
2645
2701
  host.tags.length > 0 ? host.tags.join(",") : "-",
2646
2702
  host.description ?? ""
@@ -2673,7 +2729,7 @@ function renderTunnel(tunnel) {
2673
2729
  function sshListTool(engine) {
2674
2730
  return defineTool({
2675
2731
  name: "ssh_list",
2676
- description: "List configured SSH hosts (alias, host, user, auth, environment, tags, description). Use ssh_exec etc. with the alias.",
2732
+ description: "List configured SSH hosts (alias, host, user, auth, agent forwarding, environment, tags, description). Use ssh_exec etc. with the alias.",
2677
2733
  parameters: { query: {
2678
2734
  type: "string",
2679
2735
  description: "Optional fuzzy match against alias, description, host, and tags."
@@ -2727,6 +2783,10 @@ function sshListTool(engine) {
2727
2783
  type: "boolean",
2728
2784
  required: true
2729
2785
  },
2786
+ forwardAgent: {
2787
+ type: "boolean",
2788
+ required: true
2789
+ },
2730
2790
  description: { type: "string" },
2731
2791
  environment: { type: "string" },
2732
2792
  tags: {
@@ -37,6 +37,8 @@ export declare const zh: {
37
37
  readonly 'hosts.deleteConfirm': "确定删除主机「{alias}」?将同时停止其隧道。";
38
38
  readonly 'hosts.imported': "解析 {parsed} 个配置块,新增 {added} 台主机,跳过 {skipped} 个。";
39
39
  readonly 'hosts.proxyBadge': "代理";
40
+ readonly 'hosts.forwardAgentBadge': "Agent 转发";
41
+ readonly 'hosts.forwardAgentHint': "仅对可信主机开启:远端可用本机私钥签名(等价 ssh -A)。";
40
42
  readonly 'import.reason.wildcard': "通配符 pattern,需手动配置";
41
43
  readonly 'import.reason.existing': "别名已存在";
42
44
  readonly 'import.reason.match': "Match 条件块,不支持";
@@ -71,6 +73,8 @@ export declare const zh: {
71
73
  readonly 'form.proxyJumpHint': "逗号分隔的本地主机别名,或 [user@]host[:port] 地址,按顺序连接";
72
74
  readonly 'form.proxyCommand': "ProxyCommand";
73
75
  readonly 'form.proxyCommandHint': "OpenSSH ProxyCommand:%h 主机、%p 端口、%r 用户、%n 别名;留空或填 none 表示不使用。与跳板机别名互斥。";
76
+ readonly 'form.forwardAgent': "启用 Agent 转发";
77
+ readonly 'form.forwardAgentHint': "把本机 SSH Agent 转发到该主机(等价 ssh -A):远端可用本机私钥签名。仅对可信主机开启。";
74
78
  readonly 'form.description': "备注";
75
79
  readonly 'form.environment': "环境";
76
80
  readonly 'form.environmentHint': "如 development / production";
@@ -6,8 +6,12 @@
6
6
  * The payload carries no conversation data and no identifiers beyond a random
7
7
  * UUID generated in localStorage; the server hashes it with a deployment salt
8
8
  * before storage and never persists IP addresses. Sends are fire-and-forget:
9
- * failures stay silent and simply retry on a later mount or day. The system
10
- * is documented in docs/telemetry.md.
9
+ * failures stay silent and simply retry on a later mount or day. Frames where
10
+ * storage is unavailable report nothing.
11
+ *
12
+ * The family-wide opt-out and the browser's Do Not Track signal both suppress
13
+ * the heartbeat; the Web Plugins settings switch writes the same localStorage
14
+ * key. The system is documented in docs/telemetry.md.
11
15
  */
12
16
  export type TelemetryChannel = 'market' | 'npm' | 'unknown';
13
17
  export interface TelemetryItem {
@@ -18,6 +22,14 @@ export interface TelemetryItem {
18
22
  /** Install channel when determinable (market = Workshop install). */
19
23
  channel?: TelemetryChannel;
20
24
  }
25
+ /** localStorage key carrying the family-wide telemetry opt-out ('1' = off). */
26
+ export declare const TELEMETRY_OPT_OUT_KEY = "dsh-web-ui-telemetry-opt-out";
27
+ /** Whether the user switched the family-wide opt-out on (reads storage only). */
28
+ export declare function isTelemetryOptedOut(): boolean;
29
+ /** Turn the family-wide opt-out on or off (writing '1' / removing the key); never throws. */
30
+ export declare function setTelemetryOptedOut(optedOut: boolean): void;
31
+ /** Whether a heartbeat must be suppressed right now: opt-out stored, or the browser asks not to be tracked. */
32
+ export declare function isTelemetrySuppressed(): boolean;
21
33
  /**
22
34
  * Fire the daily heartbeat for the given items at most once per UTC day per
23
35
  * browser. Never throws and never blocks the caller. Items without an explicit
@@ -50,6 +50,16 @@ export interface PoolEngine {
50
50
  export declare function buildConnectConfig(entry: SshHostEntry, sock: ConnectConfig['sock'] | undefined, opts: Required<EngineOptions>): ConnectConfig;
51
51
  /** Resolve the ssh2 agent path for 'agent' auth. */
52
52
  export declare function resolveAgentPath(agentPath?: string): string | undefined;
53
+ /**
54
+ * Resolve the ssh-agent endpoint that forwarding brokers signatures through:
55
+ * an explicitly configured agent path wins, then SSH_AUTH_SOCK, then Pageant
56
+ * on Windows. Undefined means no endpoint exists on this machine.
57
+ *
58
+ * Forwarding shares the auth resolution on purpose — the endpoint a host
59
+ * signs through is the same one it authenticates with — but it is a separate
60
+ * name so the forwarding path can evolve without touching auth.
61
+ */
62
+ export declare function resolveForwardAgentPath(agentPath?: string): string | undefined;
53
63
  /** Keyboard-interactive handler callback for 2FA / dynamic prompt flow. */
54
64
  export type KeyboardInteractiveHandler = (name: string, instructions: string, instructionsLang: string, prompts: Array<{
55
65
  prompt: string;
@@ -76,6 +86,12 @@ export declare function parseJumpSpec(spec: string): {
76
86
  * Resolve one ProxyJump spec: an alias configured in this plugin wins, and any
77
87
  * other value is read as an OpenSSH address whose credentials come from the
78
88
  * target entry (an ad-hoc hop has no stored auth of its own).
89
+ *
90
+ * An address hop deliberately carries no forwardAgent flag: OpenSSH's
91
+ * ForwardAgent is a per-Host setting and an ad-hoc address was never
92
+ * configured, so it must never inherit the target's opt-in. A hop written as
93
+ * an alias uses that alias's own entry, which is how a user forwards on a
94
+ * bastion on purpose.
79
95
  */
80
96
  export declare function resolveHop(engine: PoolEngine, entry: SshHostEntry, spec: string): SshHostEntry;
81
97
  /**
@@ -7,6 +7,14 @@
7
7
  * Semantics: RFC 5735 IPv4 127/8, ::1, IPv4-mapped ::ffff:127/8 (matching the
8
8
  * remote-web-ui gate), localhost hostnames, plus the browser same-origin
9
9
  * markers (sec-fetch-site and Origin) for the request-level fence.
10
+ *
11
+ * A reverse proxy in front of the host rewrites the Host header to its own
12
+ * upstream literal (a Cloudflare tunnel, frp and an nginx reverse proxy all
13
+ * dial 127.0.0.1:<port>), and the socket the origin sees is the proxy's, which
14
+ * is loopback by construction. Both halves of the fence then hold for a public
15
+ * request. Forwarding headers are the signal that a hop stands in between: a
16
+ * request that carries CF-Connecting-IP or X-Forwarded-For is answered through
17
+ * a proxy and is never treated as a local one (issue #1906).
10
18
  * @module dsh-web-shared/host/loopback
11
19
  */
12
20
  import type { IncomingMessage } from 'node:http';
@@ -16,9 +24,20 @@ export declare function isIPv4Loopback(v4: string): boolean;
16
24
  export declare function isLoopbackAddress(address: string | undefined): boolean;
17
25
  /** Whether a normalized URL hostname names the loopback authority (localhost, [::1], 127/8). */
18
26
  export declare function isLoopbackHostname(hostname: string): boolean;
27
+ /**
28
+ * Whether a reverse proxy stood between the client and this host: the request
29
+ * carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
30
+ * hop that forwards traffic, so the request did not originate on this machine.
31
+ * @param request - node HTTP request.
32
+ * @returns true when a forwarding header is present.
33
+ */
34
+ export declare function isProxiedRequest(request: IncomingMessage): boolean;
19
35
  /**
20
36
  * Request-level trust fence: a loopback socket address AND a loopback Host
21
37
  * header, plus browser same-origin markers. The socket address is
22
- * authoritative; X-Forwarded-For is never trusted.
38
+ * authoritative for a direct connection; a request that carries a forwarding
39
+ * header is refused outright, because a proxy in front of the host makes both
40
+ * the socket address and the Host header describe the proxy rather than the
41
+ * client. X-Forwarded-For is therefore never evidence *for* loopback.
23
42
  */
24
43
  export declare function isLoopbackRequest(request: IncomingMessage): boolean;
@@ -48,6 +48,12 @@ export interface SshHostEntry {
48
48
  tags: string[];
49
49
  /** Physical location note. */
50
50
  location?: string;
51
+ /**
52
+ * Opt-in ssh-agent forwarding (OpenSSH ForwardAgent / ssh -A): the host's
53
+ * sessions request agent forwarding so the remote can sign with this
54
+ * machine's agent. Default off; stored only when enabled.
55
+ */
56
+ forwardAgent?: boolean;
51
57
  createdAt: number;
52
58
  updatedAt: number;
53
59
  }
@@ -67,6 +73,12 @@ export interface SshHostSummary {
67
73
  environment?: string;
68
74
  tags: string[];
69
75
  location?: string;
76
+ /**
77
+ * Whether agent forwarding is enabled. Always projected as a definite
78
+ * boolean: the browser and the tool bridge need a value even for entries
79
+ * stored before the feature existed.
80
+ */
81
+ forwardAgent: boolean;
70
82
  createdAt: number;
71
83
  updatedAt: number;
72
84
  }
@@ -150,6 +162,11 @@ export interface HostPayload {
150
162
  environment?: string;
151
163
  tags?: string[];
152
164
  location?: string;
165
+ /**
166
+ * Agent forwarding for this host. Omitted on update keeps the stored value;
167
+ * false clears it (PATCH semantics).
168
+ */
169
+ forwardAgent?: boolean;
153
170
  }
154
171
  /** Why one ssh_config Host block was not imported. */
155
172
  export type ImportSkipReason = 'wildcard' | 'existing' | 'match' | 'invalid';
@@ -67,5 +67,12 @@ export declare function normalizeAgentPath(agentPath: string | undefined): strin
67
67
  * OpenSSH's `none` keyword as "no proxy command" (an explicit clear).
68
68
  */
69
69
  export declare function normalizeProxyCommand(raw: string | undefined): string | undefined;
70
+ /**
71
+ * Read an ssh_config `ForwardAgent` value into the stored boolean flag. Only
72
+ * an explicit yes/true/on enables forwarding; an absent value, no/false/off,
73
+ * and anything unrecognized leave it off instead of failing the import — an
74
+ * unknown keyword must never cost the user the whole Host block.
75
+ */
76
+ export declare function parseForwardAgentValue(raw: string | undefined): boolean;
70
77
  /** Expand a leading `~` in a filesystem path. */
71
78
  export declare function expandHome(path: string): string;
@@ -19,6 +19,7 @@ export interface AgentHostRow {
19
19
  keyReady: boolean;
20
20
  proxyJump: string[];
21
21
  proxyCommandConfigured: boolean;
22
+ forwardAgent: boolean;
22
23
  description?: string;
23
24
  environment?: string;
24
25
  tags: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-ssh",
3
3
  "description": "Remote SSH operations for the dsh web GUI: host config store (~/.dsh/dsh-ssh.json, import from ~/.ssh/config), a persistent ssh2 connection pool with jump-host support, exec / PTY web terminal / SFTP transfer / local port-forward tunnels / cluster execution, plus agent tools (ssh_list, ssh_exec, ssh_upload, ssh_download, ssh_tunnel, ssh_cluster). Hot-pluggable — mounted via ~/.dsh/cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "0.4.6",
4
+ "version": "0.4.8",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dsh": {
25
25
  "engines": {
26
- "dsh": ">=0.2.0-rc.2"
26
+ "dsh": ">=0.2.1-rc.2"
27
27
  },
28
28
  "bundle": {
29
29
  "patch": "./cordis.patch.yml"
@@ -39,33 +39,33 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@deepseek-ai/schemastery": "^3.18.4",
42
+ "@deepseek-ai/schemastery": "^3.18.5",
43
43
  "@xterm/addon-fit": "^0.11.0",
44
44
  "@xterm/xterm": "^6.0.0",
45
45
  "ssh2": "^1.17.0",
46
46
  "ws": "^8.18.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@deepseek-ai/dsh": ">=0.2.0-rc.2",
49
+ "@deepseek-ai/dsh": ">=0.2.1-rc.2",
50
50
  "react": "^18.2.0",
51
51
  "react-dom": "^18.2.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@deepseek-ai/cordis": "^4.0.4",
55
- "@deepseek-ai/dsh-client-connection": "^0.2.0-rc.2",
56
- "@deepseek-ai/dsh-client-locale": "^0.2.0-rc.2",
57
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.0-rc.2",
58
- "@deepseek-ai/dsh-client-ui-layout": "^0.2.0-rc.2",
59
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.0-rc.2",
60
- "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.0-rc.2",
61
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.0-rc.2",
62
- "@deepseek-ai/dsh-host-webserver": "^0.2.0-rc.2",
63
- "@deepseek-ai/dsh-llm": "^0.2.0-rc.2",
64
- "@deepseek-ai/dsh-scope": "^0.2.0-rc.2",
65
- "@deepseek-ai/dsh-settings": "^0.2.0-rc.2",
66
- "@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.2",
67
- "@deepseek-ai/dsh-timeout": "^0.2.0-rc.2",
68
- "@deepseek-ai/dsh-tools": "^0.2.0-rc.2",
54
+ "@deepseek-ai/cordis": "^4.0.5",
55
+ "@deepseek-ai/dsh-client-connection": "^0.2.1-rc.2",
56
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.2",
57
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.2",
58
+ "@deepseek-ai/dsh-client-ui-layout": "^0.2.1-rc.2",
59
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.2",
60
+ "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.1-rc.2",
61
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.2",
62
+ "@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.2",
63
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.2",
64
+ "@deepseek-ai/dsh-scope": "^0.2.1-rc.2",
65
+ "@deepseek-ai/dsh-settings": "^0.2.1-rc.2",
66
+ "@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.2",
67
+ "@deepseek-ai/dsh-timeout": "^0.2.1-rc.2",
68
+ "@deepseek-ai/dsh-tools": "^0.2.1-rc.2",
69
69
  "@types/node": "^22.20.0",
70
70
  "@types/react": "~18.3.1",
71
71
  "@types/react-dom": "^18.3.5",
@@ -98,7 +98,7 @@
98
98
  "build": "tsc -b tsconfig.build.json && tsdown",
99
99
  "bundle": "tsdown",
100
100
  "watch": "tsdown --watch",
101
- "typecheck": "tsc --noEmit",
101
+ "typecheck": "tsgo --noEmit",
102
102
  "test": "vitest run",
103
103
  "test:watch": "vitest"
104
104
  }
@@ -39,6 +39,8 @@ export const zh = {
39
39
  'hosts.deleteConfirm': '确定删除主机「{alias}」?将同时停止其隧道。',
40
40
  'hosts.imported': '解析 {parsed} 个配置块,新增 {added} 台主机,跳过 {skipped} 个。',
41
41
  'hosts.proxyBadge': '代理',
42
+ 'hosts.forwardAgentBadge': 'Agent 转发',
43
+ 'hosts.forwardAgentHint': '仅对可信主机开启:远端可用本机私钥签名(等价 ssh -A)。',
42
44
  'import.reason.wildcard': '通配符 pattern,需手动配置',
43
45
  'import.reason.existing': '别名已存在',
44
46
  'import.reason.match': 'Match 条件块,不支持',
@@ -74,6 +76,8 @@ export const zh = {
74
76
  'form.proxyJumpHint': '逗号分隔的本地主机别名,或 [user@]host[:port] 地址,按顺序连接',
75
77
  'form.proxyCommand': 'ProxyCommand',
76
78
  'form.proxyCommandHint': 'OpenSSH ProxyCommand:%h 主机、%p 端口、%r 用户、%n 别名;留空或填 none 表示不使用。与跳板机别名互斥。',
79
+ 'form.forwardAgent': '启用 Agent 转发',
80
+ 'form.forwardAgentHint': '把本机 SSH Agent 转发到该主机(等价 ssh -A):远端可用本机私钥签名。仅对可信主机开启。',
77
81
  'form.description': '备注',
78
82
  'form.environment': '环境',
79
83
  'form.environmentHint': '如 development / production',
@@ -202,6 +206,8 @@ export const en: Record<keyof typeof zh, string> = {
202
206
  'hosts.deleteConfirm': 'Delete host "{alias}"? Its tunnels will be stopped.',
203
207
  'hosts.imported': 'Parsed {parsed} blocks, added {added} hosts, skipped {skipped}.',
204
208
  'hosts.proxyBadge': 'proxy',
209
+ 'hosts.forwardAgentBadge': 'agent-fwd',
210
+ 'hosts.forwardAgentHint': 'Enable only for hosts you trust: the remote can sign with your local private keys (equivalent to ssh -A).',
205
211
  'import.reason.wildcard': 'wildcard pattern — configure it by hand',
206
212
  'import.reason.existing': 'alias already configured',
207
213
  'import.reason.match': 'Match block — not supported',
@@ -236,6 +242,8 @@ export const en: Record<keyof typeof zh, string> = {
236
242
  'form.proxyJumpHint': 'Comma-separated local aliases or [user@]host[:port] addresses, chained in order',
237
243
  'form.proxyCommand': 'ProxyCommand',
238
244
  'form.proxyCommandHint': 'OpenSSH ProxyCommand: %h host, %p port, %r user, %n alias; empty or none disables it. Mutually exclusive with the jump chain.',
245
+ 'form.forwardAgent': 'Enable agent forwarding',
246
+ 'form.forwardAgentHint': 'Forward your local SSH agent to this host (equivalent to ssh -A): the remote can sign with your private keys. Enable it only for hosts you trust.',
239
247
  'form.description': 'Description',
240
248
  'form.environment': 'Environment',
241
249
  'form.environmentHint': 'e.g. development / production',
@@ -32,6 +32,7 @@ interface FormState {
32
32
  agentPath: string
33
33
  proxyJump: string
34
34
  proxyCommand: string
35
+ forwardAgent: boolean
35
36
  description: string
36
37
  environment: string
37
38
  tags: string
@@ -57,6 +58,7 @@ function blankOf(editing: SshHostSummary | null | undefined): FormState {
57
58
  agentPath: '',
58
59
  proxyJump: (editing?.proxyJump ?? []).join(', '),
59
60
  proxyCommand: editing?.proxyCommand ?? '',
61
+ forwardAgent: editing?.forwardAgent === true,
60
62
  description: editing?.description ?? '',
61
63
  environment: editing?.environment ?? '',
62
64
  tags: (editing?.tags ?? []).join(', '),
@@ -126,6 +128,10 @@ export function HostFormDialog({ api, editing, onClose, onSaved }: HostFormDialo
126
128
  // Always sent (never omitted): an empty value is the explicit clear,
127
129
  // because the API cannot express "remove this field" any other way.
128
130
  proxyCommand: form.proxyCommand.trim(),
131
+ // Always sent (never omitted): the flag is a plain boolean, so saving the
132
+ // form can both enable and clear forwarding (omitting it would keep the
133
+ // stored value under PATCH semantics).
134
+ forwardAgent: form.forwardAgent,
129
135
  description: form.description.trim() === '' ? undefined : form.description.trim(),
130
136
  environment: form.environment.trim() === '' ? undefined : form.environment.trim(),
131
137
  tags: splitList(form.tags),
@@ -227,6 +233,11 @@ export function HostFormDialog({ api, editing, onClose, onSaved }: HostFormDialo
227
233
  />
228
234
  <span className={css.hint}>{tt('form.proxyCommandHint')}</span>
229
235
  </label>
236
+ <label className={css.field}>
237
+ <span className={css.fieldLabel}>{tt('form.forwardAgent')}</span>
238
+ <input type="checkbox" checked={form.forwardAgent} onChange={event => { set('forwardAgent', event.target.checked) }} />
239
+ <span className={css.hint}>{tt('form.forwardAgentHint')}</span>
240
+ </label>
230
241
  <div className={css.formRow}>
231
242
  <label className={css.field}>
232
243
  <span className={css.fieldLabel}>{tt('form.environment')}</span>
@@ -187,6 +187,9 @@ export function HostsTab({ api, onConnect }: HostsTabProps) {
187
187
  {host.proxyCommand !== undefined && (
188
188
  <span className={css.badge} data-kind="proxy" title={host.proxyCommand}>{tt('hosts.proxyBadge')}</span>
189
189
  )}
190
+ {host.forwardAgent === true && (
191
+ <span className={css.badge} data-kind="forward-agent" title={tt('hosts.forwardAgentHint')}>{tt('hosts.forwardAgentBadge')}</span>
192
+ )}
190
193
  </td>
191
194
  <td>{host.user}</td>
192
195
  <td><span className={css.badge} data-kind={host.auth}>{host.auth === 'key' ? tt('form.auth.key') : host.auth === 'password' ? tt('form.auth.password') : tt('form.auth.agent')}</span></td>
@@ -338,6 +338,12 @@
338
338
  border-color: var(--dsw-alias-state-business-primary);
339
339
  }
340
340
 
341
+ .badge[data-kind='forward-agent'] {
342
+ margin-left: 6px;
343
+ color: var(--dsw-alias-state-warn-primary);
344
+ border-color: var(--dsw-alias-state-warn-primary);
345
+ }
346
+
341
347
  .badge[data-status='ok'] {
342
348
  color: var(--dsw-alias-state-success-primary);
343
349
  border-color: var(--dsw-alias-state-success-primary);
@@ -66,7 +66,6 @@ const PENDING_SNAPSHOT: ConfigFormSnapshot<never> = {
66
66
  user: undefined,
67
67
  revision: undefined,
68
68
  writable: false,
69
- mode: 'host',
70
69
  }
71
70
 
72
71
  /** Whether one Host namespace section carries a field this plugin's schema declares. */
@@ -7,8 +7,12 @@
7
7
  * The payload carries no conversation data and no identifiers beyond a random
8
8
  * UUID generated in localStorage; the server hashes it with a deployment salt
9
9
  * before storage and never persists IP addresses. Sends are fire-and-forget:
10
- * failures stay silent and simply retry on a later mount or day. The system
11
- * is documented in docs/telemetry.md.
10
+ * failures stay silent and simply retry on a later mount or day. Frames where
11
+ * storage is unavailable report nothing.
12
+ *
13
+ * The family-wide opt-out and the browser's Do Not Track signal both suppress
14
+ * the heartbeat; the Web Plugins settings switch writes the same localStorage
15
+ * key. The system is documented in docs/telemetry.md.
12
16
  */
13
17
 
14
18
  export type TelemetryChannel = 'market' | 'npm' | 'unknown'
@@ -22,6 +26,9 @@ export interface TelemetryItem {
22
26
  channel?: TelemetryChannel
23
27
  }
24
28
 
29
+ /** localStorage key carrying the family-wide telemetry opt-out ('1' = off). */
30
+ export const TELEMETRY_OPT_OUT_KEY = 'dsh-web-ui-telemetry-opt-out'
31
+
25
32
  const VISITOR_KEY = 'dsh-web-ui-telemetry-visitor'
26
33
  const DAY_KEY_PREFIX = 'dsh-web-ui-telemetry-day:'
27
34
  const ENDPOINT = 'https://dsh-market.com/api/telemetry/event'
@@ -41,6 +48,41 @@ function bakedVersion(): string | undefined {
41
48
  }
42
49
  }
43
50
 
51
+ /** Whether the user switched the family-wide opt-out on (reads storage only). */
52
+ export function isTelemetryOptedOut(): boolean {
53
+ try {
54
+ return localStorage.getItem(TELEMETRY_OPT_OUT_KEY) === '1'
55
+ } catch {
56
+ // Storage unavailable: there is no stored opt-out to honour.
57
+ return false
58
+ }
59
+ }
60
+
61
+ /** Turn the family-wide opt-out on or off (writing '1' / removing the key); never throws. */
62
+ export function setTelemetryOptedOut(optedOut: boolean): void {
63
+ try {
64
+ if (optedOut) localStorage.setItem(TELEMETRY_OPT_OUT_KEY, '1')
65
+ else localStorage.removeItem(TELEMETRY_OPT_OUT_KEY)
66
+ } catch {
67
+ // Storage unavailable: the preference cannot be persisted on this machine.
68
+ }
69
+ }
70
+
71
+ /** Whether the browser itself asks not to be tracked; a failed read means no signal. */
72
+ function doNotTrackRequested(): boolean {
73
+ try {
74
+ // '1' per the DNT header spec, 'yes' from older Firefox builds.
75
+ return navigator.doNotTrack === '1' || navigator.doNotTrack === 'yes'
76
+ } catch {
77
+ return false
78
+ }
79
+ }
80
+
81
+ /** Whether a heartbeat must be suppressed right now: opt-out stored, or the browser asks not to be tracked. */
82
+ export function isTelemetrySuppressed(): boolean {
83
+ return isTelemetryOptedOut() || doNotTrackRequested()
84
+ }
85
+
44
86
  /** Read or lazily create the anonymous visitor id; null when storage is unavailable. */
45
87
  function visitorId(): string | null {
46
88
  try {
@@ -74,6 +116,9 @@ function pruneDayKeys(today: string): void {
74
116
  */
75
117
  export function reportDailyHeartbeat(items: readonly TelemetryItem[]): void {
76
118
  try {
119
+ // First guard: a stored opt-out or the browser's Do Not Track stops every
120
+ // read below from minting an id, marking the day, or reaching the network.
121
+ if (isTelemetrySuppressed()) return
77
122
  if (items.length === 0) return
78
123
  const today = new Date().toISOString().slice(0, 10)
79
124
  // Automation contexts (CDP-driven QA browsers, fresh isolated profiles)