@linxin666/dsh-ssh 0.4.18 → 0.4.20

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/client.js CHANGED
@@ -12,6 +12,7 @@ window.__ModuleLoader__.load({
12
12
  //#region src/protocol.ts
13
13
  const SSH_API = {
14
14
  hosts: "/api/dsh-ssh/hosts",
15
+ keys: "/api/dsh-ssh/keys",
15
16
  importSshConfig: "/api/dsh-ssh/hosts/import-ssh-config",
16
17
  test: "/api/dsh-ssh/test",
17
18
  exec: "/api/dsh-ssh/exec",
@@ -33,6 +34,7 @@ window.__ModuleLoader__.load({
33
34
  "panel.title": "远程 SSH",
34
35
  "panel.backToConversation": "返回会话",
35
36
  "tab.hosts": "主机",
37
+ "tab.keys": "密钥",
36
38
  "tab.terminal": "终端",
37
39
  "tab.transfer": "传输",
38
40
  "tab.tunnels": "隧道",
@@ -88,9 +90,15 @@ window.__ModuleLoader__.load({
88
90
  "form.auth.agent": "SSH Agent",
89
91
  "form.agentPath": "Agent 路径",
90
92
  "form.agentPathHint": "留空自动检测(SSH_AUTH_SOCK;Windows 上为原生 ssh-agent 命名管道);也可填 socket 路径或 pageant",
91
- "form.authKeepHint": "编辑时密码 / 私钥留空将保留已存凭据;Agent 路径留空是合法的自动检测,选「SSH Agent」即切换到 agent 认证。",
93
+ "form.authKeepHint": "编辑时密码 / 密钥口令留空将保留已存凭据;私钥路径用于匹配受管密钥且不会回读口令。Agent 路径留空是合法的自动检测。",
92
94
  "form.keyPath": "私钥路径",
93
95
  "form.keyPathHint": "如 ~/.ssh/id_ed25519",
96
+ "form.keyPathRequired": "请选择受管密钥或填写自定义私钥路径。",
97
+ "form.managedKey": "受管密钥",
98
+ "form.key.custom": "自定义路径…",
99
+ "form.key.customHint": "手动填写路径;编辑时口令留空保留原值。",
100
+ "form.key.managedHint": "路径与口令由受管密钥在宿主侧解析,不会向浏览器回读口令。",
101
+ "form.keyListError": "受管密钥列表读取失败:{error}。仍可使用自定义路径。",
94
102
  "form.passphrase": "密钥口令",
95
103
  "form.password": "密码",
96
104
  "form.passwordHint": "明文保存在 $DSH_HOME/dsh-ssh.json(本机私有文件)",
@@ -111,6 +119,25 @@ window.__ModuleLoader__.load({
111
119
  "form.cancel": "取消",
112
120
  "form.required": "请填写必填字段:别名、主机地址、用户名。",
113
121
  "form.portInvalid": "端口必须是 1-65535 之间的整数。",
122
+ "keys.add": "新增密钥",
123
+ "keys.empty": "尚未登记密钥。密钥只保存本机路径与可选口令,不复制或读取私钥内容。",
124
+ "keys.name": "名称",
125
+ "keys.col.name": "名称",
126
+ "keys.col.status": "文件状态",
127
+ "keys.col.usedBy": "引用主机",
128
+ "keys.exists": "文件存在",
129
+ "keys.missing": "文件不存在",
130
+ "keys.unused": "未被引用",
131
+ "keys.usedBy": "{count} 台:{hosts}",
132
+ "keys.pathHint": "绝对路径或 ~ 开头的路径;只检查文件元数据,不读取私钥内容。",
133
+ "keys.passphraseHint": "可选口令,明文存入本机 0600 配置文件;编辑时留空保留,勾选清除可移除。",
134
+ "keys.clearPassphrase": "清除已保存的口令",
135
+ "keys.required": "请填写密钥名称与路径。",
136
+ "keys.form.create": "新增受管密钥",
137
+ "keys.form.edit": "编辑受管密钥「{name}」",
138
+ "keys.editConfirm": "此密钥正被 {count} 台主机引用:{hosts}。本次只修改受管记录,不会自动改写这些主机的现有路径或凭据。继续?",
139
+ "keys.deleteConfirm": "删除受管密钥「{name}」?{count} 台引用主机({hosts})会保留各自现有私钥路径与凭据,不会被删除或改写。",
140
+ "keys.deleteConfirmUnused": "删除受管密钥「{name}」?只会删除这条受管记录,不会删除私钥文件。",
114
141
  "terminal.selectHost": "选择主机",
115
142
  "terminal.connect": "连接",
116
143
  "terminal.disconnect": "断开",
@@ -200,6 +227,7 @@ window.__ModuleLoader__.load({
200
227
  "panel.title": "Remote SSH",
201
228
  "panel.backToConversation": "Back to chat",
202
229
  "tab.hosts": "Hosts",
230
+ "tab.keys": "Keys",
203
231
  "tab.terminal": "Terminal",
204
232
  "tab.transfer": "Transfer",
205
233
  "tab.tunnels": "Tunnels",
@@ -255,9 +283,15 @@ window.__ModuleLoader__.load({
255
283
  "form.auth.agent": "SSH Agent",
256
284
  "form.agentPath": "Agent path",
257
285
  "form.agentPathHint": "Leave empty to auto-detect (SSH_AUTH_SOCK; the native ssh-agent named pipe on Windows), or set a socket path or \"pageant\"",
258
- "form.authKeepHint": "While editing, an empty password or key field keeps the stored credential; an empty agent path is a valid auto-detect, so choosing SSH Agent switches the host to agent auth.",
286
+ "form.authKeepHint": "While editing, empty password/passphrase fields keep stored secrets. The private-key path is shown for managed-key matching, never its passphrase. An empty agent path remains a valid auto-detect.",
259
287
  "form.keyPath": "Private key path",
260
288
  "form.keyPathHint": "e.g. ~/.ssh/id_ed25519",
289
+ "form.keyPathRequired": "Choose a managed key or enter a custom private-key path.",
290
+ "form.managedKey": "Managed key",
291
+ "form.key.custom": "Custom path…",
292
+ "form.key.customHint": "Enter a path yourself; an empty passphrase keeps the old value while editing.",
293
+ "form.key.managedHint": "The Host resolves the managed path and passphrase without returning the passphrase to the browser.",
294
+ "form.keyListError": "Could not load managed keys: {error}. Custom paths remain available.",
261
295
  "form.passphrase": "Key passphrase",
262
296
  "form.password": "Password",
263
297
  "form.passwordHint": "Stored in plaintext in $DSH_HOME/dsh-ssh.json (private local file)",
@@ -278,6 +312,25 @@ window.__ModuleLoader__.load({
278
312
  "form.cancel": "Cancel",
279
313
  "form.required": "Required fields missing: alias, host, user.",
280
314
  "form.portInvalid": "Port must be an integer between 1 and 65535.",
315
+ "keys.add": "Add key",
316
+ "keys.empty": "No managed keys yet. A key stores only a local path and optional passphrase; private-key contents are never copied or read.",
317
+ "keys.name": "Name",
318
+ "keys.col.name": "Name",
319
+ "keys.col.status": "File status",
320
+ "keys.col.usedBy": "Used by",
321
+ "keys.exists": "File exists",
322
+ "keys.missing": "File missing",
323
+ "keys.unused": "Unused",
324
+ "keys.usedBy": "{count}: {hosts}",
325
+ "keys.pathHint": "An absolute or ~-relative path; only file metadata is checked, never private-key contents.",
326
+ "keys.passphraseHint": "Optional passphrase stored in plaintext in the local 0600 config. Blank preserves it while editing; use the clear checkbox to remove it.",
327
+ "keys.clearPassphrase": "Clear the saved passphrase",
328
+ "keys.required": "Enter both a key name and path.",
329
+ "keys.form.create": "Add managed key",
330
+ "keys.form.edit": "Edit managed key \"{name}\"",
331
+ "keys.editConfirm": "{count} hosts reference this key: {hosts}. This edits only the managed record; existing host paths and credentials are not rewritten. Continue?",
332
+ "keys.deleteConfirm": "Delete managed key \"{name}\"? Its {count} referencing hosts ({hosts}) keep their existing private-key paths and credentials; no host is deleted or rewritten.",
333
+ "keys.deleteConfirmUnused": "Delete managed key \"{name}\"? Only the managed record is removed; the private-key file is never deleted.",
281
334
  "terminal.selectHost": "Select host",
282
335
  "terminal.connect": "Connect",
283
336
  "terminal.disconnect": "Disconnect",
@@ -376,7 +429,7 @@ window.__ModuleLoader__.load({
376
429
  */
377
430
  /** Active dictionary, picked by the document language at call time. */
378
431
  function dictionary() {
379
- return (typeof document !== "undefined" ? document.documentElement.lang : "zh").toLowerCase().startsWith("en") ? { ...en } : { ...zh };
432
+ return (typeof document !== "undefined" && document.documentElement.lang !== "" ? document.documentElement.lang : "zh").toLowerCase().startsWith("zh") ? { ...zh } : { ...en };
380
433
  }
381
434
  /**
382
435
  * SDK translate seat wired by the browser apply() once ctx.locale is bound
@@ -598,6 +651,26 @@ window.__ModuleLoader__.load({
598
651
  async deleteHost(alias) {
599
652
  await readJson(await fetch(SSH_API.hosts + query({ alias }), { method: "DELETE" }));
600
653
  }
654
+ async listKeys() {
655
+ return (await readJson(await fetch(SSH_API.keys))).keys;
656
+ }
657
+ async createKey(payload) {
658
+ return (await readJson(await fetch(SSH_API.keys, {
659
+ method: "POST",
660
+ headers: { "content-type": "application/json" },
661
+ body: JSON.stringify(payload)
662
+ }))).key;
663
+ }
664
+ async updateKey(id, patch) {
665
+ return (await readJson(await fetch(SSH_API.keys + query({ id }), {
666
+ method: "PATCH",
667
+ headers: { "content-type": "application/json" },
668
+ body: JSON.stringify(patch)
669
+ }))).key;
670
+ }
671
+ async deleteKey(id) {
672
+ await readJson(await fetch(SSH_API.keys + query({ id }), { method: "DELETE" }));
673
+ }
601
674
  async importSshConfig() {
602
675
  return (await readJson(await fetch(SSH_API.importSshConfig, { method: "POST" }))).result;
603
676
  }
@@ -1595,9 +1668,9 @@ window.__ModuleLoader__.load({
1595
1668
  //#region src/client/panel/HostFormDialog.tsx
1596
1669
  /**
1597
1670
  * Host form dialog: create/edit one stored host entry. A fixed backdrop with
1598
- * a centered card; Escape and backdrop clicks close it. Secrets (key path,
1599
- * passphrase, password) are never pre-filled when editing (the API only
1600
- * exposes the secret-free summary).
1671
+ * a centered card; Escape and backdrop clicks close it. Passwords and
1672
+ * passphrases are never pre-filled. The browser-only panel summary includes
1673
+ * the key path solely to match a managed key; passphrases resolve Host-side.
1601
1674
  */
1602
1675
  /** Split a comma-separated input into a trimmed, non-empty string list. */
1603
1676
  function splitList(text) {
@@ -1611,7 +1684,8 @@ window.__ModuleLoader__.load({
1611
1684
  port: String(editing?.port ?? 22),
1612
1685
  user: editing?.user ?? "",
1613
1686
  authKind: editing?.auth ?? "key",
1614
- keyPath: "",
1687
+ keyPath: editing?.keyPath ?? "",
1688
+ managedKeyId: "",
1615
1689
  passphrase: "",
1616
1690
  password: "",
1617
1691
  agentPath: "",
@@ -1629,6 +1703,9 @@ window.__ModuleLoader__.load({
1629
1703
  const [form, setForm] = (0, react.useState)(() => blankOf(editing));
1630
1704
  const [saving, setSaving] = (0, react.useState)(false);
1631
1705
  const [error, setError] = (0, react.useState)(null);
1706
+ const [keys, setKeys] = (0, react.useState)(null);
1707
+ const [keysError, setKeysError] = (0, react.useState)(null);
1708
+ const keySelectionTouched = (0, react.useRef)(false);
1632
1709
  (0, react.useEffect)(() => {
1633
1710
  const onKey = (event) => {
1634
1711
  if (event.key === "Escape") onClose();
@@ -1638,12 +1715,43 @@ window.__ModuleLoader__.load({
1638
1715
  document.removeEventListener("keydown", onKey);
1639
1716
  };
1640
1717
  }, [onClose]);
1718
+ (0, react.useEffect)(() => {
1719
+ let cancelled = false;
1720
+ api.listKeys().then((list) => {
1721
+ if (cancelled) return;
1722
+ setKeys(list);
1723
+ setForm((previous) => {
1724
+ if (keySelectionTouched.current || previous.authKind !== "key" || previous.managedKeyId !== "" || previous.keyPath === "") return previous;
1725
+ const match = list.find((key) => key.path === previous.keyPath);
1726
+ return match === void 0 ? previous : {
1727
+ ...previous,
1728
+ managedKeyId: match.id,
1729
+ keyPath: match.path
1730
+ };
1731
+ });
1732
+ }, (cause) => {
1733
+ if (!cancelled) setKeysError(errorMessage(cause));
1734
+ });
1735
+ return () => {
1736
+ cancelled = true;
1737
+ };
1738
+ }, [api]);
1641
1739
  const set = (key, value) => {
1642
1740
  setForm((prev) => ({
1643
1741
  ...prev,
1644
1742
  [key]: value
1645
1743
  }));
1646
1744
  };
1745
+ const chooseManagedKey = (id) => {
1746
+ keySelectionTouched.current = true;
1747
+ const selected = keys?.find((key) => key.id === id);
1748
+ setForm((previous) => ({
1749
+ ...previous,
1750
+ managedKeyId: selected?.id ?? "",
1751
+ keyPath: selected?.path ?? previous.keyPath,
1752
+ passphrase: ""
1753
+ }));
1754
+ };
1647
1755
  const save = async () => {
1648
1756
  const alias = form.alias.trim();
1649
1757
  const host = form.host.trim();
@@ -1657,6 +1765,10 @@ window.__ModuleLoader__.load({
1657
1765
  setError(tt("form.portInvalid"));
1658
1766
  return;
1659
1767
  }
1768
+ if (form.authKind === "key" && form.keyPath.trim() === "" && (editing == null || editing.auth !== "key")) {
1769
+ setError(tt("form.keyPathRequired"));
1770
+ return;
1771
+ }
1660
1772
  if (editing == null && form.authKind === "password" && form.password === "") {
1661
1773
  setError(tt("form.passwordRequired"));
1662
1774
  return;
@@ -1672,11 +1784,12 @@ window.__ModuleLoader__.load({
1672
1784
  } : form.authKind === "key" ? {
1673
1785
  kind: "key",
1674
1786
  keyPath: form.keyPath.trim(),
1675
- passphrase: form.passphrase === "" ? void 0 : form.passphrase
1787
+ passphrase: form.managedKeyId !== "" || form.passphrase === "" ? void 0 : form.passphrase
1676
1788
  } : {
1677
1789
  kind: "agent",
1678
1790
  agentPath: form.agentPath.trim() === "" ? void 0 : form.agentPath.trim()
1679
1791
  },
1792
+ ...form.authKind === "key" && form.managedKeyId !== "" && (editing == null || keySelectionTouched.current) ? { managedKeyId: form.managedKeyId } : {},
1680
1793
  proxyJump: splitList(form.proxyJump),
1681
1794
  proxyCommand: form.proxyCommand.trim(),
1682
1795
  forwardAgent: form.forwardAgent,
@@ -1830,7 +1943,39 @@ window.__ModuleLoader__.load({
1830
1943
  })
1831
1944
  ]
1832
1945
  }),
1833
- form.authKind === "key" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1946
+ form.authKind === "key" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1947
+ className: panel_module_css_default.field,
1948
+ children: [
1949
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1950
+ className: panel_module_css_default.fieldLabel,
1951
+ children: tt("form.managedKey")
1952
+ }),
1953
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1954
+ className: panel_module_css_default.input,
1955
+ "aria-label": tt("form.managedKey"),
1956
+ value: form.managedKeyId,
1957
+ disabled: keys === null,
1958
+ onChange: (event) => {
1959
+ chooseManagedKey(event.target.value);
1960
+ },
1961
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1962
+ value: "",
1963
+ children: tt("form.key.custom")
1964
+ }), (keys ?? []).map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
1965
+ value: key.id,
1966
+ children: [
1967
+ key.name,
1968
+ " — ",
1969
+ key.path
1970
+ ]
1971
+ }, key.id))]
1972
+ }),
1973
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1974
+ className: panel_module_css_default.hint,
1975
+ children: keysError !== null ? tt("form.keyListError", { error: keysError }) : form.managedKeyId !== "" ? tt("form.key.managedHint") : tt("form.key.customHint")
1976
+ })
1977
+ ]
1978
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1834
1979
  className: panel_module_css_default.formRow,
1835
1980
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1836
1981
  className: panel_module_css_default.field,
@@ -1842,6 +1987,7 @@ window.__ModuleLoader__.load({
1842
1987
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1843
1988
  className: panel_module_css_default.input,
1844
1989
  value: form.keyPath,
1990
+ readOnly: form.managedKeyId !== "",
1845
1991
  onChange: (event) => {
1846
1992
  set("keyPath", event.target.value);
1847
1993
  }
@@ -1860,12 +2006,13 @@ window.__ModuleLoader__.load({
1860
2006
  className: panel_module_css_default.input,
1861
2007
  type: "password",
1862
2008
  value: form.passphrase,
2009
+ disabled: form.managedKeyId !== "",
1863
2010
  onChange: (event) => {
1864
2011
  set("passphrase", event.target.value);
1865
2012
  }
1866
2013
  })]
1867
2014
  })]
1868
- }) : form.authKind === "agent" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2015
+ })] }) : form.authKind === "agent" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1869
2016
  className: panel_module_css_default.field,
1870
2017
  children: [
1871
2018
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -2480,6 +2627,310 @@ window.__ModuleLoader__.load({
2480
2627
  });
2481
2628
  }
2482
2629
  //#endregion
2630
+ //#region src/client/panel/KeysTab.tsx
2631
+ /** Managed local private-key references: CRUD without reading key contents. */
2632
+ function KeyFormDialog(props) {
2633
+ const { api, editing, onClose, onSaved, confirmAction } = props;
2634
+ const [name, setName] = (0, react.useState)(editing?.name ?? "");
2635
+ const [path, setPath] = (0, react.useState)(editing?.path ?? "");
2636
+ const [passphrase, setPassphrase] = (0, react.useState)("");
2637
+ const [clearPassphrase, setClearPassphrase] = (0, react.useState)(false);
2638
+ const [note, setNote] = (0, react.useState)(editing?.note ?? "");
2639
+ const [saving, setSaving] = (0, react.useState)(false);
2640
+ const [error, setError] = (0, react.useState)(null);
2641
+ (0, react.useEffect)(() => {
2642
+ const onKey = (event) => {
2643
+ if (event.key === "Escape") onClose();
2644
+ };
2645
+ document.addEventListener("keydown", onKey);
2646
+ return () => {
2647
+ document.removeEventListener("keydown", onKey);
2648
+ };
2649
+ }, [onClose]);
2650
+ const save = async () => {
2651
+ if (name.trim() === "" || path.trim() === "") {
2652
+ setError(tt("keys.required"));
2653
+ return;
2654
+ }
2655
+ if (editing !== void 0 && editing.usedBy.length > 0) {
2656
+ if (!confirmAction(tt("keys.editConfirm", {
2657
+ count: editing.usedBy.length,
2658
+ hosts: editing.usedBy.join(", ")
2659
+ }))) return;
2660
+ }
2661
+ const payload = {
2662
+ name: name.trim(),
2663
+ path: path.trim(),
2664
+ note,
2665
+ ...passphrase !== "" ? { passphrase } : editing !== void 0 && clearPassphrase ? { passphrase: null } : {}
2666
+ };
2667
+ setSaving(true);
2668
+ setError(null);
2669
+ try {
2670
+ if (editing === void 0) await api.createKey(payload);
2671
+ else await api.updateKey(editing.id, payload);
2672
+ onSaved();
2673
+ } catch (cause) {
2674
+ setError(errorMessage(cause));
2675
+ setSaving(false);
2676
+ }
2677
+ };
2678
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2679
+ className: panel_module_css_default.modalBackdrop,
2680
+ onClick: onClose,
2681
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2682
+ className: panel_module_css_default.modal,
2683
+ role: "dialog",
2684
+ "aria-modal": "true",
2685
+ "aria-label": editing === void 0 ? tt("keys.form.create") : tt("keys.form.edit", { name: editing.name }),
2686
+ onClick: (event) => {
2687
+ event.stopPropagation();
2688
+ },
2689
+ children: [
2690
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2691
+ className: panel_module_css_default.modalTitle,
2692
+ children: editing === void 0 ? tt("keys.form.create") : tt("keys.form.edit", { name: editing.name })
2693
+ }),
2694
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2695
+ className: panel_module_css_default.field,
2696
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2697
+ className: panel_module_css_default.fieldLabel,
2698
+ children: tt("keys.name")
2699
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2700
+ className: panel_module_css_default.input,
2701
+ value: name,
2702
+ onChange: (event) => {
2703
+ setName(event.target.value);
2704
+ }
2705
+ })]
2706
+ }),
2707
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2708
+ className: panel_module_css_default.field,
2709
+ children: [
2710
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2711
+ className: panel_module_css_default.fieldLabel,
2712
+ children: tt("form.keyPath")
2713
+ }),
2714
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2715
+ className: panel_module_css_default.input,
2716
+ value: path,
2717
+ onChange: (event) => {
2718
+ setPath(event.target.value);
2719
+ }
2720
+ }),
2721
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2722
+ className: panel_module_css_default.hint,
2723
+ children: tt("keys.pathHint")
2724
+ })
2725
+ ]
2726
+ }),
2727
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2728
+ className: panel_module_css_default.field,
2729
+ children: [
2730
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2731
+ className: panel_module_css_default.fieldLabel,
2732
+ children: tt("form.passphrase")
2733
+ }),
2734
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2735
+ className: panel_module_css_default.input,
2736
+ type: "password",
2737
+ value: passphrase,
2738
+ disabled: clearPassphrase,
2739
+ onChange: (event) => {
2740
+ setPassphrase(event.target.value);
2741
+ }
2742
+ }),
2743
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2744
+ className: panel_module_css_default.hint,
2745
+ children: tt("keys.passphraseHint")
2746
+ })
2747
+ ]
2748
+ }),
2749
+ editing?.hasPassphrase === true && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2750
+ className: panel_module_css_default.radioLabel,
2751
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2752
+ type: "checkbox",
2753
+ checked: clearPassphrase,
2754
+ onChange: (event) => {
2755
+ const checked = event.target.checked;
2756
+ setClearPassphrase(checked);
2757
+ if (checked) setPassphrase("");
2758
+ }
2759
+ }), tt("keys.clearPassphrase")]
2760
+ }),
2761
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2762
+ className: panel_module_css_default.field,
2763
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2764
+ className: panel_module_css_default.fieldLabel,
2765
+ children: tt("form.description")
2766
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2767
+ className: panel_module_css_default.input,
2768
+ value: note,
2769
+ onChange: (event) => {
2770
+ setNote(event.target.value);
2771
+ }
2772
+ })]
2773
+ }),
2774
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2775
+ className: panel_module_css_default.formError,
2776
+ children: tt("common.error", { error })
2777
+ }),
2778
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2779
+ className: panel_module_css_default.modalFooter,
2780
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2781
+ type: "button",
2782
+ className: panel_module_css_default.ghostButton,
2783
+ disabled: saving,
2784
+ onClick: onClose,
2785
+ children: tt("form.cancel")
2786
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2787
+ type: "button",
2788
+ className: panel_module_css_default.primaryButton,
2789
+ disabled: saving,
2790
+ onClick: () => {
2791
+ save();
2792
+ },
2793
+ children: tt("form.save")
2794
+ })]
2795
+ })
2796
+ ]
2797
+ })
2798
+ });
2799
+ }
2800
+ function KeysTab({ api, confirmAction }) {
2801
+ const ask = confirmAction ?? ((message) => window.confirm(message));
2802
+ const [keys, setKeys] = (0, react.useState)(null);
2803
+ const [error, setError] = (0, react.useState)(null);
2804
+ const [dialog, setDialog] = (0, react.useState)(null);
2805
+ const mounted = (0, react.useRef)(true);
2806
+ (0, react.useEffect)(() => () => {
2807
+ mounted.current = false;
2808
+ }, []);
2809
+ const load = (0, react.useCallback)(async () => {
2810
+ try {
2811
+ const list = await api.listKeys();
2812
+ if (!mounted.current) return;
2813
+ setKeys(list);
2814
+ setError(null);
2815
+ } catch (cause) {
2816
+ if (mounted.current) setError(errorMessage(cause));
2817
+ }
2818
+ }, [api]);
2819
+ (0, react.useEffect)(() => {
2820
+ load();
2821
+ }, [load]);
2822
+ const remove = async (key) => {
2823
+ const message = key.usedBy.length === 0 ? tt("keys.deleteConfirmUnused", { name: key.name }) : tt("keys.deleteConfirm", {
2824
+ name: key.name,
2825
+ count: key.usedBy.length,
2826
+ hosts: key.usedBy.join(", ")
2827
+ });
2828
+ if (!ask(message)) return;
2829
+ try {
2830
+ await api.deleteKey(key.id);
2831
+ await load();
2832
+ } catch (cause) {
2833
+ if (mounted.current) setError(errorMessage(cause));
2834
+ }
2835
+ };
2836
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2837
+ className: panel_module_css_default.fillBody,
2838
+ children: [
2839
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2840
+ className: panel_module_css_default.toolbar,
2841
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: panel_module_css_default.toolbarSpacer }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2842
+ type: "button",
2843
+ className: panel_module_css_default.primaryButton,
2844
+ onClick: () => {
2845
+ setDialog({ mode: "create" });
2846
+ },
2847
+ children: tt("keys.add")
2848
+ })]
2849
+ }),
2850
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2851
+ className: panel_module_css_default.banner,
2852
+ "data-kind": "error",
2853
+ children: tt("common.error", { error })
2854
+ }),
2855
+ keys === null && error === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2856
+ className: panel_module_css_default.loading,
2857
+ children: tt("common.loading")
2858
+ }),
2859
+ keys !== null && keys.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2860
+ className: panel_module_css_default.empty,
2861
+ children: tt("keys.empty")
2862
+ }),
2863
+ keys !== null && keys.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2864
+ className: panel_module_css_default.tableWrap,
2865
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2866
+ className: panel_module_css_default.table,
2867
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2868
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("keys.col.name") }),
2869
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("form.keyPath") }),
2870
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("keys.col.status") }),
2871
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("keys.col.usedBy") }),
2872
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("hosts.col.description") }),
2873
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("hosts.col.actions") })
2874
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: keys.map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2875
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: key.name }),
2876
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2877
+ className: panel_module_css_default.mono,
2878
+ children: key.path
2879
+ }),
2880
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2881
+ className: panel_module_css_default.badge,
2882
+ "data-status": key.exists ? "ok" : "fail",
2883
+ children: key.exists ? tt("keys.exists") : tt("keys.missing")
2884
+ }) }),
2885
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: key.usedBy.length === 0 ? tt("keys.unused") : tt("keys.usedBy", {
2886
+ count: key.usedBy.length,
2887
+ hosts: key.usedBy.join(", ")
2888
+ }) }),
2889
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2890
+ className: panel_module_css_default.cellMuted,
2891
+ children: key.note ?? ""
2892
+ }),
2893
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2894
+ className: panel_module_css_default.actions,
2895
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2896
+ type: "button",
2897
+ className: panel_module_css_default.linkButton,
2898
+ onClick: () => {
2899
+ setDialog({
2900
+ mode: "edit",
2901
+ key
2902
+ });
2903
+ },
2904
+ children: tt("hosts.edit")
2905
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2906
+ type: "button",
2907
+ className: panel_module_css_default.linkButton,
2908
+ "data-danger": true,
2909
+ onClick: () => {
2910
+ remove(key);
2911
+ },
2912
+ children: tt("hosts.delete")
2913
+ })]
2914
+ }) })
2915
+ ] }, key.id)) })]
2916
+ })
2917
+ }),
2918
+ dialog !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyFormDialog, {
2919
+ api,
2920
+ editing: dialog.mode === "edit" ? dialog.key : void 0,
2921
+ onClose: () => {
2922
+ setDialog(null);
2923
+ },
2924
+ onSaved: () => {
2925
+ setDialog(null);
2926
+ load();
2927
+ },
2928
+ confirmAction: ask
2929
+ })
2930
+ ]
2931
+ });
2932
+ }
2933
+ //#endregion
2483
2934
  //#region ../../node_modules/.pnpm/@xterm+xterm@6.0.0/node_modules/@xterm/xterm/lib/xterm.js
2484
2935
  var require_xterm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2485
2936
  (function(e, t) {
@@ -16724,7 +17175,7 @@ window.__ModuleLoader__.load({
16724
17175
  //#endregion
16725
17176
  //#region src/client/panel/SshPanel.tsx
16726
17177
  /**
16727
- * The SSH operations panel shell: a header with a close control, a five-tab
17178
+ * The SSH operations panel shell: a header with a close control, a six-tab
16728
17179
  * bar, and the active tab's content.
16729
17180
  *
16730
17181
  * The active tab and the terminal tabs live in the controller, not in
@@ -16739,6 +17190,10 @@ window.__ModuleLoader__.load({
16739
17190
  id: "hosts",
16740
17191
  label: () => tt("tab.hosts")
16741
17192
  },
17193
+ {
17194
+ id: "keys",
17195
+ label: () => tt("tab.keys")
17196
+ },
16742
17197
  {
16743
17198
  id: "terminal",
16744
17199
  label: () => tt("tab.terminal")
@@ -16808,6 +17263,7 @@ window.__ModuleLoader__.load({
16808
17263
  controller.requestConnect(alias);
16809
17264
  }
16810
17265
  }),
17266
+ activeTab === "keys" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeysTab, { api }),
16811
17267
  activeTab === "terminal" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TerminalTab, {
16812
17268
  api,
16813
17269
  controller,
@@ -17030,7 +17486,7 @@ window.__ModuleLoader__.load({
17030
17486
  /** The building package's version, when the bundle carries it. */
17031
17487
  function bakedVersion() {
17032
17488
  try {
17033
- return "0.4.18";
17489
+ return "0.4.20";
17034
17490
  } catch {
17035
17491
  return;
17036
17492
  }