@linxin666/dsh-ssh 0.4.19 → 0.4.21
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.i18n.yaml +2 -2
- package/README.md +13 -2
- package/README.zh.md +13 -2
- package/lib/client.js +726 -109
- package/lib/client.js.map +1 -1
- package/lib/index.js +1074 -352
- package/lib/types/client/api.d.ts +8 -4
- package/lib/types/client/locales.d.ts +27 -1
- package/lib/types/client/panel/HostFormDialog.d.ts +3 -3
- package/lib/types/client/panel/HostsTab.d.ts +3 -3
- package/lib/types/client/panel/KeysTab.d.ts +8 -0
- package/lib/types/client/panel/controller.d.ts +1 -1
- package/lib/types/connection-trust.d.ts +26 -0
- package/lib/types/engine/cluster.d.ts +7 -2
- package/lib/types/engine/connection-pool.d.ts +11 -2
- package/lib/types/engine/sftp.d.ts +5 -0
- package/lib/types/engine/terminal-sessions.d.ts +5 -3
- package/lib/types/index.d.ts +6 -5
- package/lib/types/protocol.d.ts +41 -0
- package/lib/types/routes.d.ts +3 -0
- package/lib/types/service.d.ts +148 -0
- package/lib/types/store.d.ts +16 -4
- package/package.json +1 -1
- package/src/client/api.ts +147 -58
- package/src/client/locales.ts +55 -2
- package/src/client/panel/HostFormDialog.tsx +76 -17
- package/src/client/panel/HostsTab.tsx +50 -25
- package/src/client/panel/KeysTab.tsx +192 -0
- package/src/client/panel/SshPanel.tsx +4 -1
- package/src/client/panel/TerminalTab.tsx +14 -9
- package/src/client/panel/TunnelsTab.tsx +24 -7
- package/src/client/panel/controller.ts +77 -12
- package/src/client/panel/helpers.ts +3 -2
- package/src/connection-trust.ts +70 -0
- package/src/engine/cluster.ts +45 -13
- package/src/engine/connection-pool.ts +279 -96
- package/src/engine/proxy-command.ts +27 -10
- package/src/engine/sftp.ts +69 -35
- package/src/engine/terminal-sessions.ts +110 -35
- package/src/engine/tunnel.ts +20 -2
- package/src/engine.ts +5 -8
- package/src/index.ts +113 -39
- package/src/protocol.ts +45 -0
- package/src/routes.ts +130 -23
- package/src/service.ts +158 -0
- package/src/store.ts +324 -104
- package/src/tools.ts +3 -5
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": "编辑时密码 /
|
|
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,
|
|
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("
|
|
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
|
}
|
|
@@ -688,27 +761,43 @@ window.__ModuleLoader__.load({
|
|
|
688
761
|
let finalError;
|
|
689
762
|
let sawResult = false;
|
|
690
763
|
let transferredBytes = 0;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
if (
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
764
|
+
let doneReading = false;
|
|
765
|
+
const processLine = (line) => {
|
|
766
|
+
if (line.trim() === "") return;
|
|
767
|
+
let parsed;
|
|
768
|
+
try {
|
|
769
|
+
parsed = JSON.parse(line);
|
|
770
|
+
} catch {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (parsed.type === "progress") onProgress?.(parsed.progress);
|
|
774
|
+
else if (parsed.type === "result") {
|
|
775
|
+
sawResult = true;
|
|
776
|
+
if (parsed.ok) transferredBytes = parsed.transferredBytes ?? 0;
|
|
777
|
+
finalError = parsed.ok ? void 0 : parsed.error ?? "upload failed";
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
try {
|
|
781
|
+
for (;;) {
|
|
782
|
+
const { done, value } = await reader.read();
|
|
783
|
+
if (done) {
|
|
784
|
+
doneReading = true;
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
buffer += decoder.decode(value, { stream: true });
|
|
788
|
+
const lines = buffer.split("\n");
|
|
789
|
+
buffer = lines.pop() ?? "";
|
|
790
|
+
for (const line of lines) processLine(line);
|
|
711
791
|
}
|
|
792
|
+
buffer += decoder.decode();
|
|
793
|
+
if (buffer !== "") for (const line of buffer.split("\n")) processLine(line);
|
|
794
|
+
} finally {
|
|
795
|
+
if (!doneReading) try {
|
|
796
|
+
await reader.cancel();
|
|
797
|
+
} catch {}
|
|
798
|
+
try {
|
|
799
|
+
reader.releaseLock();
|
|
800
|
+
} catch {}
|
|
712
801
|
}
|
|
713
802
|
if (finalError !== void 0) throw new SshApiError(finalError);
|
|
714
803
|
if (!sawResult) throw new SshApiError("upload ended without a result frame — the transfer did not complete");
|
|
@@ -734,8 +823,14 @@ window.__ModuleLoader__.load({
|
|
|
734
823
|
let writable;
|
|
735
824
|
const chunks = [];
|
|
736
825
|
let received = 0;
|
|
737
|
-
|
|
738
|
-
|
|
826
|
+
let lastProgressAt = -Infinity;
|
|
827
|
+
const PROGRESS_THROTTLE_MS = 100;
|
|
828
|
+
const emitProgress = (force = false) => {
|
|
829
|
+
if (onProgress === void 0) return;
|
|
830
|
+
const now = Date.now();
|
|
831
|
+
if (!force && now - lastProgressAt < PROGRESS_THROTTLE_MS) return;
|
|
832
|
+
lastProgressAt = now;
|
|
833
|
+
onProgress({
|
|
739
834
|
phase: "transferring",
|
|
740
835
|
file: remotePath,
|
|
741
836
|
transferred: received,
|
|
@@ -743,34 +838,53 @@ window.__ModuleLoader__.load({
|
|
|
743
838
|
percent: total > 0 ? Math.round(received / total * 1e3) / 10 : 0
|
|
744
839
|
});
|
|
745
840
|
};
|
|
841
|
+
let doneReading = false;
|
|
842
|
+
let completed = false;
|
|
746
843
|
try {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
844
|
+
try {
|
|
845
|
+
if (picker !== void 0) {
|
|
846
|
+
writable = await (await picker.call(window, { suggestedName: filename })).createWritable();
|
|
847
|
+
streamed = true;
|
|
848
|
+
}
|
|
849
|
+
} catch {}
|
|
850
|
+
for (;;) {
|
|
851
|
+
const { done, value } = await reader.read();
|
|
852
|
+
if (done) {
|
|
853
|
+
doneReading = true;
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
if (writable !== void 0) await writable.write(value);
|
|
857
|
+
else chunks.push(value);
|
|
858
|
+
received += value.length;
|
|
859
|
+
emitProgress(lastProgressAt < 0);
|
|
750
860
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
861
|
+
if (writable !== void 0) await writable.close();
|
|
862
|
+
completed = true;
|
|
863
|
+
onProgress?.({
|
|
864
|
+
phase: "done",
|
|
865
|
+
file: remotePath,
|
|
866
|
+
transferred: received,
|
|
867
|
+
total: received > 0 ? received : total,
|
|
868
|
+
percent: 100
|
|
869
|
+
});
|
|
870
|
+
return {
|
|
871
|
+
blob: streamed ? void 0 : new Blob(chunks),
|
|
872
|
+
filename,
|
|
873
|
+
streamed,
|
|
874
|
+
bytes: received
|
|
875
|
+
};
|
|
876
|
+
} finally {
|
|
877
|
+
if (!completed && writable !== void 0) try {
|
|
878
|
+
if (writable.abort !== void 0) await writable.abort();
|
|
879
|
+
else await writable.close();
|
|
880
|
+
} catch {}
|
|
881
|
+
if (!doneReading) try {
|
|
882
|
+
await reader.cancel();
|
|
883
|
+
} catch {}
|
|
884
|
+
try {
|
|
885
|
+
reader.releaseLock();
|
|
886
|
+
} catch {}
|
|
759
887
|
}
|
|
760
|
-
if (writable !== void 0) await writable.close();
|
|
761
|
-
onProgress?.({
|
|
762
|
-
phase: "done",
|
|
763
|
-
file: remotePath,
|
|
764
|
-
transferred: received,
|
|
765
|
-
total: received > 0 ? received : total,
|
|
766
|
-
percent: 100
|
|
767
|
-
});
|
|
768
|
-
return {
|
|
769
|
-
blob: streamed ? void 0 : new Blob(chunks),
|
|
770
|
-
filename,
|
|
771
|
-
streamed,
|
|
772
|
-
bytes: received
|
|
773
|
-
};
|
|
774
888
|
}
|
|
775
889
|
/**
|
|
776
890
|
* Open a new host terminal session for the alias.
|
|
@@ -884,6 +998,12 @@ window.__ModuleLoader__.load({
|
|
|
884
998
|
return failedTerminal(error instanceof Error ? error.message : String(error));
|
|
885
999
|
}
|
|
886
1000
|
let leaving = false;
|
|
1001
|
+
let exited = false;
|
|
1002
|
+
const notifyExit = (code, error) => {
|
|
1003
|
+
if (exited) return;
|
|
1004
|
+
exited = true;
|
|
1005
|
+
connection.onExit?.(code, error);
|
|
1006
|
+
};
|
|
887
1007
|
const sendFrame = (frame) => {
|
|
888
1008
|
if (socket.readyState === WebSocket.OPEN) socket.send(JSON.stringify(frame));
|
|
889
1009
|
};
|
|
@@ -935,14 +1055,14 @@ window.__ModuleLoader__.load({
|
|
|
935
1055
|
}
|
|
936
1056
|
if (frame.type === "ready") connection.onReady?.(frame.sessionId, frame.alias);
|
|
937
1057
|
else if (frame.type === "output") connection.onOutput?.(frame.data);
|
|
938
|
-
else if (frame.type === "exit")
|
|
1058
|
+
else if (frame.type === "exit") notifyExit(frame.code, frame.error);
|
|
939
1059
|
else if (frame.type === "auth_prompt") connection.onAuthPrompt?.(frame.name, frame.instructions, frame.prompts);
|
|
940
1060
|
};
|
|
941
1061
|
socket.onclose = () => {
|
|
942
|
-
if (!leaving)
|
|
1062
|
+
if (!leaving) notifyExit(null, "connection closed");
|
|
943
1063
|
};
|
|
944
1064
|
socket.onerror = () => {
|
|
945
|
-
if (!leaving)
|
|
1065
|
+
if (!leaving) notifyExit(null, "connection error");
|
|
946
1066
|
};
|
|
947
1067
|
return connection;
|
|
948
1068
|
}
|
|
@@ -957,12 +1077,45 @@ window.__ModuleLoader__.load({
|
|
|
957
1077
|
*/
|
|
958
1078
|
function utf8Bytes(text) {
|
|
959
1079
|
let bytes = 0;
|
|
960
|
-
for (
|
|
961
|
-
const code =
|
|
962
|
-
|
|
1080
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
1081
|
+
const code = text.charCodeAt(i);
|
|
1082
|
+
if (code >= 55296 && code <= 56319 && i + 1 < text.length) {
|
|
1083
|
+
const low = text.charCodeAt(i + 1);
|
|
1084
|
+
if (low >= 56320 && low <= 57343) {
|
|
1085
|
+
bytes += 4;
|
|
1086
|
+
i += 1;
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
bytes += code < 128 ? 1 : code < 2048 ? 2 : 3;
|
|
963
1091
|
}
|
|
964
1092
|
return bytes;
|
|
965
1093
|
}
|
|
1094
|
+
/** Trim leading code units from an oversized chunk so its tail fits maxBytes without splitting surrogate pairs. */
|
|
1095
|
+
function trimTrailingUtf8(text, maxBytes) {
|
|
1096
|
+
let bytes = 0;
|
|
1097
|
+
let start = text.length;
|
|
1098
|
+
for (let i = text.length - 1; i >= 0; i -= 1) {
|
|
1099
|
+
const code = text.charCodeAt(i);
|
|
1100
|
+
let charBytes;
|
|
1101
|
+
let stepStart = i;
|
|
1102
|
+
if (code >= 56320 && code <= 57343 && i > 0) {
|
|
1103
|
+
const high = text.charCodeAt(i - 1);
|
|
1104
|
+
if (high >= 55296 && high <= 56319) {
|
|
1105
|
+
charBytes = 4;
|
|
1106
|
+
stepStart = i - 1;
|
|
1107
|
+
} else charBytes = 3;
|
|
1108
|
+
} else charBytes = code < 128 ? 1 : code < 2048 ? 2 : 3;
|
|
1109
|
+
if (bytes + charBytes > maxBytes) break;
|
|
1110
|
+
bytes += charBytes;
|
|
1111
|
+
start = stepStart;
|
|
1112
|
+
i = stepStart;
|
|
1113
|
+
}
|
|
1114
|
+
return {
|
|
1115
|
+
text: start === 0 ? text : text.slice(start),
|
|
1116
|
+
bytes
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
966
1119
|
/** The panel state owner the sidebar row and the view both read. */
|
|
967
1120
|
var PanelController = class {
|
|
968
1121
|
deps;
|
|
@@ -1231,21 +1384,46 @@ window.__ModuleLoader__.load({
|
|
|
1231
1384
|
}
|
|
1232
1385
|
/** Append one output chunk to the retained screen of a tab. */
|
|
1233
1386
|
appendTerminalOutput(id, chunk) {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1387
|
+
if (chunk === "") return;
|
|
1388
|
+
const size = utf8Bytes(chunk);
|
|
1389
|
+
if (size > MAX_RETAINED_BYTES) {
|
|
1390
|
+
const trimmed = trimTrailingUtf8(chunk, MAX_RETAINED_BYTES);
|
|
1391
|
+
this.retainedScreens.set(id, {
|
|
1392
|
+
chunks: trimmed.text === "" ? [] : [trimmed.text],
|
|
1393
|
+
chunkBytes: trimmed.text === "" ? [] : [trimmed.bytes],
|
|
1394
|
+
head: 0,
|
|
1395
|
+
bytes: trimmed.bytes
|
|
1396
|
+
});
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
let screen = this.retainedScreens.get(id);
|
|
1400
|
+
if (screen === void 0) {
|
|
1401
|
+
this.retainedScreens.set(id, {
|
|
1402
|
+
chunks: [chunk],
|
|
1403
|
+
chunkBytes: [size],
|
|
1404
|
+
head: 0,
|
|
1405
|
+
bytes: size
|
|
1406
|
+
});
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1238
1409
|
screen.chunks.push(chunk);
|
|
1239
|
-
screen.
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
screen.bytes -=
|
|
1410
|
+
screen.chunkBytes.push(size);
|
|
1411
|
+
screen.bytes += size;
|
|
1412
|
+
while (screen.bytes > MAX_RETAINED_BYTES && screen.chunks.length - screen.head > 1) {
|
|
1413
|
+
screen.bytes -= screen.chunkBytes[screen.head];
|
|
1414
|
+
screen.head += 1;
|
|
1415
|
+
}
|
|
1416
|
+
if (screen.head >= 256 && screen.head * 2 >= screen.chunks.length) {
|
|
1417
|
+
screen.chunks = screen.chunks.slice(screen.head);
|
|
1418
|
+
screen.chunkBytes = screen.chunkBytes.slice(screen.head);
|
|
1419
|
+
screen.head = 0;
|
|
1243
1420
|
}
|
|
1244
|
-
this.retainedScreens.set(id, screen);
|
|
1245
1421
|
}
|
|
1246
1422
|
/** The retained screen of a tab, concatenated for a redraw. */
|
|
1247
1423
|
readTerminalOutput(id) {
|
|
1248
|
-
|
|
1424
|
+
const screen = this.retainedScreens.get(id);
|
|
1425
|
+
if (screen === void 0) return "";
|
|
1426
|
+
return screen.head === 0 ? screen.chunks.join("") : screen.chunks.slice(screen.head).join("");
|
|
1249
1427
|
}
|
|
1250
1428
|
/** Forget the retained screen (a fresh replay from the host replaces it). */
|
|
1251
1429
|
clearTerminalOutput(id) {
|
|
@@ -1595,9 +1773,9 @@ window.__ModuleLoader__.load({
|
|
|
1595
1773
|
//#region src/client/panel/HostFormDialog.tsx
|
|
1596
1774
|
/**
|
|
1597
1775
|
* Host form dialog: create/edit one stored host entry. A fixed backdrop with
|
|
1598
|
-
* a centered card; Escape and backdrop clicks close it.
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1776
|
+
* a centered card; Escape and backdrop clicks close it. Passwords and
|
|
1777
|
+
* passphrases are never pre-filled. The browser-only panel summary includes
|
|
1778
|
+
* the key path solely to match a managed key; passphrases resolve Host-side.
|
|
1601
1779
|
*/
|
|
1602
1780
|
/** Split a comma-separated input into a trimmed, non-empty string list. */
|
|
1603
1781
|
function splitList(text) {
|
|
@@ -1611,7 +1789,8 @@ window.__ModuleLoader__.load({
|
|
|
1611
1789
|
port: String(editing?.port ?? 22),
|
|
1612
1790
|
user: editing?.user ?? "",
|
|
1613
1791
|
authKind: editing?.auth ?? "key",
|
|
1614
|
-
keyPath: "",
|
|
1792
|
+
keyPath: editing?.keyPath ?? "",
|
|
1793
|
+
managedKeyId: "",
|
|
1615
1794
|
passphrase: "",
|
|
1616
1795
|
password: "",
|
|
1617
1796
|
agentPath: "",
|
|
@@ -1629,6 +1808,9 @@ window.__ModuleLoader__.load({
|
|
|
1629
1808
|
const [form, setForm] = (0, react.useState)(() => blankOf(editing));
|
|
1630
1809
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
1631
1810
|
const [error, setError] = (0, react.useState)(null);
|
|
1811
|
+
const [keys, setKeys] = (0, react.useState)(null);
|
|
1812
|
+
const [keysError, setKeysError] = (0, react.useState)(null);
|
|
1813
|
+
const keySelectionTouched = (0, react.useRef)(false);
|
|
1632
1814
|
(0, react.useEffect)(() => {
|
|
1633
1815
|
const onKey = (event) => {
|
|
1634
1816
|
if (event.key === "Escape") onClose();
|
|
@@ -1638,12 +1820,43 @@ window.__ModuleLoader__.load({
|
|
|
1638
1820
|
document.removeEventListener("keydown", onKey);
|
|
1639
1821
|
};
|
|
1640
1822
|
}, [onClose]);
|
|
1823
|
+
(0, react.useEffect)(() => {
|
|
1824
|
+
let cancelled = false;
|
|
1825
|
+
api.listKeys().then((list) => {
|
|
1826
|
+
if (cancelled) return;
|
|
1827
|
+
setKeys(list);
|
|
1828
|
+
setForm((previous) => {
|
|
1829
|
+
if (keySelectionTouched.current || previous.authKind !== "key" || previous.managedKeyId !== "" || previous.keyPath === "") return previous;
|
|
1830
|
+
const match = list.find((key) => key.path === previous.keyPath);
|
|
1831
|
+
return match === void 0 ? previous : {
|
|
1832
|
+
...previous,
|
|
1833
|
+
managedKeyId: match.id,
|
|
1834
|
+
keyPath: match.path
|
|
1835
|
+
};
|
|
1836
|
+
});
|
|
1837
|
+
}, (cause) => {
|
|
1838
|
+
if (!cancelled) setKeysError(errorMessage(cause));
|
|
1839
|
+
});
|
|
1840
|
+
return () => {
|
|
1841
|
+
cancelled = true;
|
|
1842
|
+
};
|
|
1843
|
+
}, [api]);
|
|
1641
1844
|
const set = (key, value) => {
|
|
1642
1845
|
setForm((prev) => ({
|
|
1643
1846
|
...prev,
|
|
1644
1847
|
[key]: value
|
|
1645
1848
|
}));
|
|
1646
1849
|
};
|
|
1850
|
+
const chooseManagedKey = (id) => {
|
|
1851
|
+
keySelectionTouched.current = true;
|
|
1852
|
+
const selected = keys?.find((key) => key.id === id);
|
|
1853
|
+
setForm((previous) => ({
|
|
1854
|
+
...previous,
|
|
1855
|
+
managedKeyId: selected?.id ?? "",
|
|
1856
|
+
keyPath: selected?.path ?? previous.keyPath,
|
|
1857
|
+
passphrase: ""
|
|
1858
|
+
}));
|
|
1859
|
+
};
|
|
1647
1860
|
const save = async () => {
|
|
1648
1861
|
const alias = form.alias.trim();
|
|
1649
1862
|
const host = form.host.trim();
|
|
@@ -1657,6 +1870,10 @@ window.__ModuleLoader__.load({
|
|
|
1657
1870
|
setError(tt("form.portInvalid"));
|
|
1658
1871
|
return;
|
|
1659
1872
|
}
|
|
1873
|
+
if (form.authKind === "key" && form.keyPath.trim() === "" && (editing == null || editing.auth !== "key")) {
|
|
1874
|
+
setError(tt("form.keyPathRequired"));
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1660
1877
|
if (editing == null && form.authKind === "password" && form.password === "") {
|
|
1661
1878
|
setError(tt("form.passwordRequired"));
|
|
1662
1879
|
return;
|
|
@@ -1672,18 +1889,19 @@ window.__ModuleLoader__.load({
|
|
|
1672
1889
|
} : form.authKind === "key" ? {
|
|
1673
1890
|
kind: "key",
|
|
1674
1891
|
keyPath: form.keyPath.trim(),
|
|
1675
|
-
passphrase: form.passphrase === "" ? void 0 : form.passphrase
|
|
1892
|
+
passphrase: form.managedKeyId !== "" || form.passphrase === "" ? void 0 : form.passphrase
|
|
1676
1893
|
} : {
|
|
1677
1894
|
kind: "agent",
|
|
1678
1895
|
agentPath: form.agentPath.trim() === "" ? void 0 : form.agentPath.trim()
|
|
1679
1896
|
},
|
|
1897
|
+
...form.authKind === "key" && form.managedKeyId !== "" && (editing == null || keySelectionTouched.current) ? { managedKeyId: form.managedKeyId } : {},
|
|
1680
1898
|
proxyJump: splitList(form.proxyJump),
|
|
1681
1899
|
proxyCommand: form.proxyCommand.trim(),
|
|
1682
1900
|
forwardAgent: form.forwardAgent,
|
|
1683
|
-
description: form.description.trim()
|
|
1684
|
-
environment: form.environment.trim()
|
|
1901
|
+
description: form.description.trim(),
|
|
1902
|
+
environment: form.environment.trim(),
|
|
1685
1903
|
tags: splitList(form.tags),
|
|
1686
|
-
location: form.location.trim()
|
|
1904
|
+
location: form.location.trim()
|
|
1687
1905
|
};
|
|
1688
1906
|
setSaving(true);
|
|
1689
1907
|
setError(null);
|
|
@@ -1830,7 +2048,39 @@ window.__ModuleLoader__.load({
|
|
|
1830
2048
|
})
|
|
1831
2049
|
]
|
|
1832
2050
|
}),
|
|
1833
|
-
form.authKind === "key" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2051
|
+
form.authKind === "key" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2052
|
+
className: panel_module_css_default.field,
|
|
2053
|
+
children: [
|
|
2054
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2055
|
+
className: panel_module_css_default.fieldLabel,
|
|
2056
|
+
children: tt("form.managedKey")
|
|
2057
|
+
}),
|
|
2058
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
2059
|
+
className: panel_module_css_default.input,
|
|
2060
|
+
"aria-label": tt("form.managedKey"),
|
|
2061
|
+
value: form.managedKeyId,
|
|
2062
|
+
disabled: keys === null,
|
|
2063
|
+
onChange: (event) => {
|
|
2064
|
+
chooseManagedKey(event.target.value);
|
|
2065
|
+
},
|
|
2066
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2067
|
+
value: "",
|
|
2068
|
+
children: tt("form.key.custom")
|
|
2069
|
+
}), (keys ?? []).map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
|
|
2070
|
+
value: key.id,
|
|
2071
|
+
children: [
|
|
2072
|
+
key.name,
|
|
2073
|
+
" — ",
|
|
2074
|
+
key.path
|
|
2075
|
+
]
|
|
2076
|
+
}, key.id))]
|
|
2077
|
+
}),
|
|
2078
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2079
|
+
className: panel_module_css_default.hint,
|
|
2080
|
+
children: keysError !== null ? tt("form.keyListError", { error: keysError }) : form.managedKeyId !== "" ? tt("form.key.managedHint") : tt("form.key.customHint")
|
|
2081
|
+
})
|
|
2082
|
+
]
|
|
2083
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1834
2084
|
className: panel_module_css_default.formRow,
|
|
1835
2085
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1836
2086
|
className: panel_module_css_default.field,
|
|
@@ -1842,6 +2092,7 @@ window.__ModuleLoader__.load({
|
|
|
1842
2092
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1843
2093
|
className: panel_module_css_default.input,
|
|
1844
2094
|
value: form.keyPath,
|
|
2095
|
+
readOnly: form.managedKeyId !== "",
|
|
1845
2096
|
onChange: (event) => {
|
|
1846
2097
|
set("keyPath", event.target.value);
|
|
1847
2098
|
}
|
|
@@ -1860,12 +2111,13 @@ window.__ModuleLoader__.load({
|
|
|
1860
2111
|
className: panel_module_css_default.input,
|
|
1861
2112
|
type: "password",
|
|
1862
2113
|
value: form.passphrase,
|
|
2114
|
+
disabled: form.managedKeyId !== "",
|
|
1863
2115
|
onChange: (event) => {
|
|
1864
2116
|
set("passphrase", event.target.value);
|
|
1865
2117
|
}
|
|
1866
2118
|
})]
|
|
1867
2119
|
})]
|
|
1868
|
-
}) : form.authKind === "agent" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2120
|
+
})] }) : form.authKind === "agent" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1869
2121
|
className: panel_module_css_default.field,
|
|
1870
2122
|
children: [
|
|
1871
2123
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -2106,7 +2358,7 @@ window.__ModuleLoader__.load({
|
|
|
2106
2358
|
const [hosts, setHosts] = (0, react.useState)(null);
|
|
2107
2359
|
const [error, setError] = (0, react.useState)(null);
|
|
2108
2360
|
const [search, setSearch] = (0, react.useState)("");
|
|
2109
|
-
const [
|
|
2361
|
+
const [testingAliases, setTestingAliases] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
2110
2362
|
const [testResults, setTestResults] = (0, react.useState)({});
|
|
2111
2363
|
const [importing, setImporting] = (0, react.useState)(false);
|
|
2112
2364
|
const [notice, setNotice] = (0, react.useState)(null);
|
|
@@ -2118,8 +2370,11 @@ window.__ModuleLoader__.load({
|
|
|
2118
2370
|
const [testingGroup, setTestingGroup] = (0, react.useState)(null);
|
|
2119
2371
|
const seqRef = (0, react.useRef)(0);
|
|
2120
2372
|
const mountedRef = (0, react.useRef)(true);
|
|
2121
|
-
(0, react.useEffect)(() =>
|
|
2122
|
-
mountedRef.current =
|
|
2373
|
+
(0, react.useEffect)(() => {
|
|
2374
|
+
mountedRef.current = true;
|
|
2375
|
+
return () => {
|
|
2376
|
+
mountedRef.current = false;
|
|
2377
|
+
};
|
|
2123
2378
|
}, []);
|
|
2124
2379
|
const load = (0, react.useCallback)(async (query) => {
|
|
2125
2380
|
const seq = ++seqRef.current;
|
|
@@ -2133,21 +2388,37 @@ window.__ModuleLoader__.load({
|
|
|
2133
2388
|
setError(errorMessage(cause));
|
|
2134
2389
|
}
|
|
2135
2390
|
}, [api]);
|
|
2391
|
+
const loadedApiRef = (0, react.useRef)(null);
|
|
2136
2392
|
(0, react.useEffect)(() => {
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2393
|
+
const query = search.trim();
|
|
2394
|
+
const normalized = query === "" ? void 0 : query;
|
|
2395
|
+
if (loadedApiRef.current !== api) {
|
|
2396
|
+
loadedApiRef.current = api;
|
|
2397
|
+
load(normalized);
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2140
2400
|
const timer = setTimeout(() => {
|
|
2141
|
-
|
|
2142
|
-
load(query === "" ? void 0 : query);
|
|
2401
|
+
load(normalized);
|
|
2143
2402
|
}, 300);
|
|
2144
2403
|
return () => {
|
|
2145
2404
|
clearTimeout(timer);
|
|
2146
2405
|
};
|
|
2147
|
-
}, [
|
|
2406
|
+
}, [
|
|
2407
|
+
api,
|
|
2408
|
+
search,
|
|
2409
|
+
load
|
|
2410
|
+
]);
|
|
2411
|
+
const reloadCurrent = () => {
|
|
2412
|
+
const query = search.trim();
|
|
2413
|
+
load(query === "" ? void 0 : query);
|
|
2414
|
+
};
|
|
2148
2415
|
const runTest = async (alias) => {
|
|
2149
2416
|
if (!mountedRef.current) return;
|
|
2150
|
-
|
|
2417
|
+
setTestingAliases((prev) => {
|
|
2418
|
+
const next = new Set(prev);
|
|
2419
|
+
next.add(alias);
|
|
2420
|
+
return next;
|
|
2421
|
+
});
|
|
2151
2422
|
try {
|
|
2152
2423
|
const result = await api.testHost(alias);
|
|
2153
2424
|
if (!mountedRef.current) return;
|
|
@@ -2165,7 +2436,12 @@ window.__ModuleLoader__.load({
|
|
|
2165
2436
|
}
|
|
2166
2437
|
}));
|
|
2167
2438
|
} finally {
|
|
2168
|
-
if (mountedRef.current)
|
|
2439
|
+
if (mountedRef.current) setTestingAliases((prev) => {
|
|
2440
|
+
if (!prev.has(alias)) return prev;
|
|
2441
|
+
const next = new Set(prev);
|
|
2442
|
+
next.delete(alias);
|
|
2443
|
+
return next;
|
|
2444
|
+
});
|
|
2169
2445
|
}
|
|
2170
2446
|
};
|
|
2171
2447
|
const deleteHost = async (alias) => {
|
|
@@ -2173,7 +2449,7 @@ window.__ModuleLoader__.load({
|
|
|
2173
2449
|
try {
|
|
2174
2450
|
await api.deleteHost(alias);
|
|
2175
2451
|
if (!mountedRef.current) return;
|
|
2176
|
-
|
|
2452
|
+
reloadCurrent();
|
|
2177
2453
|
} catch (cause) {
|
|
2178
2454
|
if (!mountedRef.current) return;
|
|
2179
2455
|
setError(errorMessage(cause));
|
|
@@ -2200,7 +2476,7 @@ window.__ModuleLoader__.load({
|
|
|
2200
2476
|
skipped: result.skipped
|
|
2201
2477
|
}));
|
|
2202
2478
|
setImportSkips(result.skippedBlocks);
|
|
2203
|
-
|
|
2479
|
+
reloadCurrent();
|
|
2204
2480
|
} catch (cause) {
|
|
2205
2481
|
if (!mountedRef.current) return;
|
|
2206
2482
|
setError(errorMessage(cause));
|
|
@@ -2210,6 +2486,7 @@ window.__ModuleLoader__.load({
|
|
|
2210
2486
|
};
|
|
2211
2487
|
const renderHostRow = (host) => {
|
|
2212
2488
|
const test = testResults[host.alias];
|
|
2489
|
+
const testing = testingAliases.has(host.alias);
|
|
2213
2490
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2214
2491
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2215
2492
|
className: panel_module_css_default.mono,
|
|
@@ -2259,13 +2536,13 @@ window.__ModuleLoader__.load({
|
|
|
2259
2536
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2260
2537
|
type: "button",
|
|
2261
2538
|
className: panel_module_css_default.linkButton,
|
|
2262
|
-
disabled:
|
|
2539
|
+
disabled: testing,
|
|
2263
2540
|
onClick: () => {
|
|
2264
2541
|
runTest(host.alias);
|
|
2265
2542
|
},
|
|
2266
|
-
children:
|
|
2543
|
+
children: testing ? tt("hosts.testing") : tt("hosts.test")
|
|
2267
2544
|
}),
|
|
2268
|
-
|
|
2545
|
+
testing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2269
2546
|
className: panel_module_css_default.spinner,
|
|
2270
2547
|
"aria-hidden": "true"
|
|
2271
2548
|
}),
|
|
@@ -2473,13 +2750,317 @@ window.__ModuleLoader__.load({
|
|
|
2473
2750
|
},
|
|
2474
2751
|
onSaved: () => {
|
|
2475
2752
|
setDialog(null);
|
|
2476
|
-
|
|
2753
|
+
reloadCurrent();
|
|
2477
2754
|
}
|
|
2478
2755
|
})
|
|
2479
2756
|
]
|
|
2480
2757
|
});
|
|
2481
2758
|
}
|
|
2482
2759
|
//#endregion
|
|
2760
|
+
//#region src/client/panel/KeysTab.tsx
|
|
2761
|
+
/** Managed local private-key references: CRUD without reading key contents. */
|
|
2762
|
+
function KeyFormDialog(props) {
|
|
2763
|
+
const { api, editing, onClose, onSaved, confirmAction } = props;
|
|
2764
|
+
const [name, setName] = (0, react.useState)(editing?.name ?? "");
|
|
2765
|
+
const [path, setPath] = (0, react.useState)(editing?.path ?? "");
|
|
2766
|
+
const [passphrase, setPassphrase] = (0, react.useState)("");
|
|
2767
|
+
const [clearPassphrase, setClearPassphrase] = (0, react.useState)(false);
|
|
2768
|
+
const [note, setNote] = (0, react.useState)(editing?.note ?? "");
|
|
2769
|
+
const [saving, setSaving] = (0, react.useState)(false);
|
|
2770
|
+
const [error, setError] = (0, react.useState)(null);
|
|
2771
|
+
(0, react.useEffect)(() => {
|
|
2772
|
+
const onKey = (event) => {
|
|
2773
|
+
if (event.key === "Escape") onClose();
|
|
2774
|
+
};
|
|
2775
|
+
document.addEventListener("keydown", onKey);
|
|
2776
|
+
return () => {
|
|
2777
|
+
document.removeEventListener("keydown", onKey);
|
|
2778
|
+
};
|
|
2779
|
+
}, [onClose]);
|
|
2780
|
+
const save = async () => {
|
|
2781
|
+
if (name.trim() === "" || path.trim() === "") {
|
|
2782
|
+
setError(tt("keys.required"));
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
if (editing !== void 0 && editing.usedBy.length > 0) {
|
|
2786
|
+
if (!confirmAction(tt("keys.editConfirm", {
|
|
2787
|
+
count: editing.usedBy.length,
|
|
2788
|
+
hosts: editing.usedBy.join(", ")
|
|
2789
|
+
}))) return;
|
|
2790
|
+
}
|
|
2791
|
+
const payload = {
|
|
2792
|
+
name: name.trim(),
|
|
2793
|
+
path: path.trim(),
|
|
2794
|
+
note,
|
|
2795
|
+
...passphrase !== "" ? { passphrase } : editing !== void 0 && clearPassphrase ? { passphrase: null } : {}
|
|
2796
|
+
};
|
|
2797
|
+
setSaving(true);
|
|
2798
|
+
setError(null);
|
|
2799
|
+
try {
|
|
2800
|
+
if (editing === void 0) await api.createKey(payload);
|
|
2801
|
+
else await api.updateKey(editing.id, payload);
|
|
2802
|
+
onSaved();
|
|
2803
|
+
} catch (cause) {
|
|
2804
|
+
setError(errorMessage(cause));
|
|
2805
|
+
setSaving(false);
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2809
|
+
className: panel_module_css_default.modalBackdrop,
|
|
2810
|
+
onClick: onClose,
|
|
2811
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2812
|
+
className: panel_module_css_default.modal,
|
|
2813
|
+
role: "dialog",
|
|
2814
|
+
"aria-modal": "true",
|
|
2815
|
+
"aria-label": editing === void 0 ? tt("keys.form.create") : tt("keys.form.edit", { name: editing.name }),
|
|
2816
|
+
onClick: (event) => {
|
|
2817
|
+
event.stopPropagation();
|
|
2818
|
+
},
|
|
2819
|
+
children: [
|
|
2820
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2821
|
+
className: panel_module_css_default.modalTitle,
|
|
2822
|
+
children: editing === void 0 ? tt("keys.form.create") : tt("keys.form.edit", { name: editing.name })
|
|
2823
|
+
}),
|
|
2824
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2825
|
+
className: panel_module_css_default.field,
|
|
2826
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2827
|
+
className: panel_module_css_default.fieldLabel,
|
|
2828
|
+
children: tt("keys.name")
|
|
2829
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2830
|
+
className: panel_module_css_default.input,
|
|
2831
|
+
value: name,
|
|
2832
|
+
onChange: (event) => {
|
|
2833
|
+
setName(event.target.value);
|
|
2834
|
+
}
|
|
2835
|
+
})]
|
|
2836
|
+
}),
|
|
2837
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2838
|
+
className: panel_module_css_default.field,
|
|
2839
|
+
children: [
|
|
2840
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2841
|
+
className: panel_module_css_default.fieldLabel,
|
|
2842
|
+
children: tt("form.keyPath")
|
|
2843
|
+
}),
|
|
2844
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2845
|
+
className: panel_module_css_default.input,
|
|
2846
|
+
value: path,
|
|
2847
|
+
onChange: (event) => {
|
|
2848
|
+
setPath(event.target.value);
|
|
2849
|
+
}
|
|
2850
|
+
}),
|
|
2851
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2852
|
+
className: panel_module_css_default.hint,
|
|
2853
|
+
children: tt("keys.pathHint")
|
|
2854
|
+
})
|
|
2855
|
+
]
|
|
2856
|
+
}),
|
|
2857
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2858
|
+
className: panel_module_css_default.field,
|
|
2859
|
+
children: [
|
|
2860
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2861
|
+
className: panel_module_css_default.fieldLabel,
|
|
2862
|
+
children: tt("form.passphrase")
|
|
2863
|
+
}),
|
|
2864
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2865
|
+
className: panel_module_css_default.input,
|
|
2866
|
+
type: "password",
|
|
2867
|
+
value: passphrase,
|
|
2868
|
+
disabled: clearPassphrase,
|
|
2869
|
+
onChange: (event) => {
|
|
2870
|
+
setPassphrase(event.target.value);
|
|
2871
|
+
}
|
|
2872
|
+
}),
|
|
2873
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2874
|
+
className: panel_module_css_default.hint,
|
|
2875
|
+
children: tt("keys.passphraseHint")
|
|
2876
|
+
})
|
|
2877
|
+
]
|
|
2878
|
+
}),
|
|
2879
|
+
editing?.hasPassphrase === true && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2880
|
+
className: panel_module_css_default.radioLabel,
|
|
2881
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2882
|
+
type: "checkbox",
|
|
2883
|
+
checked: clearPassphrase,
|
|
2884
|
+
onChange: (event) => {
|
|
2885
|
+
const checked = event.target.checked;
|
|
2886
|
+
setClearPassphrase(checked);
|
|
2887
|
+
if (checked) setPassphrase("");
|
|
2888
|
+
}
|
|
2889
|
+
}), tt("keys.clearPassphrase")]
|
|
2890
|
+
}),
|
|
2891
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2892
|
+
className: panel_module_css_default.field,
|
|
2893
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2894
|
+
className: panel_module_css_default.fieldLabel,
|
|
2895
|
+
children: tt("form.description")
|
|
2896
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2897
|
+
className: panel_module_css_default.input,
|
|
2898
|
+
value: note,
|
|
2899
|
+
onChange: (event) => {
|
|
2900
|
+
setNote(event.target.value);
|
|
2901
|
+
}
|
|
2902
|
+
})]
|
|
2903
|
+
}),
|
|
2904
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2905
|
+
className: panel_module_css_default.formError,
|
|
2906
|
+
children: tt("common.error", { error })
|
|
2907
|
+
}),
|
|
2908
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2909
|
+
className: panel_module_css_default.modalFooter,
|
|
2910
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2911
|
+
type: "button",
|
|
2912
|
+
className: panel_module_css_default.ghostButton,
|
|
2913
|
+
disabled: saving,
|
|
2914
|
+
onClick: onClose,
|
|
2915
|
+
children: tt("form.cancel")
|
|
2916
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2917
|
+
type: "button",
|
|
2918
|
+
className: panel_module_css_default.primaryButton,
|
|
2919
|
+
disabled: saving,
|
|
2920
|
+
onClick: () => {
|
|
2921
|
+
save();
|
|
2922
|
+
},
|
|
2923
|
+
children: tt("form.save")
|
|
2924
|
+
})]
|
|
2925
|
+
})
|
|
2926
|
+
]
|
|
2927
|
+
})
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
function KeysTab({ api, confirmAction }) {
|
|
2931
|
+
const ask = confirmAction ?? ((message) => window.confirm(message));
|
|
2932
|
+
const [keys, setKeys] = (0, react.useState)(null);
|
|
2933
|
+
const [error, setError] = (0, react.useState)(null);
|
|
2934
|
+
const [dialog, setDialog] = (0, react.useState)(null);
|
|
2935
|
+
const mounted = (0, react.useRef)(true);
|
|
2936
|
+
(0, react.useEffect)(() => () => {
|
|
2937
|
+
mounted.current = false;
|
|
2938
|
+
}, []);
|
|
2939
|
+
const load = (0, react.useCallback)(async () => {
|
|
2940
|
+
try {
|
|
2941
|
+
const list = await api.listKeys();
|
|
2942
|
+
if (!mounted.current) return;
|
|
2943
|
+
setKeys(list);
|
|
2944
|
+
setError(null);
|
|
2945
|
+
} catch (cause) {
|
|
2946
|
+
if (mounted.current) setError(errorMessage(cause));
|
|
2947
|
+
}
|
|
2948
|
+
}, [api]);
|
|
2949
|
+
(0, react.useEffect)(() => {
|
|
2950
|
+
load();
|
|
2951
|
+
}, [load]);
|
|
2952
|
+
const remove = async (key) => {
|
|
2953
|
+
const message = key.usedBy.length === 0 ? tt("keys.deleteConfirmUnused", { name: key.name }) : tt("keys.deleteConfirm", {
|
|
2954
|
+
name: key.name,
|
|
2955
|
+
count: key.usedBy.length,
|
|
2956
|
+
hosts: key.usedBy.join(", ")
|
|
2957
|
+
});
|
|
2958
|
+
if (!ask(message)) return;
|
|
2959
|
+
try {
|
|
2960
|
+
await api.deleteKey(key.id);
|
|
2961
|
+
await load();
|
|
2962
|
+
} catch (cause) {
|
|
2963
|
+
if (mounted.current) setError(errorMessage(cause));
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2966
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2967
|
+
className: panel_module_css_default.fillBody,
|
|
2968
|
+
children: [
|
|
2969
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2970
|
+
className: panel_module_css_default.toolbar,
|
|
2971
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: panel_module_css_default.toolbarSpacer }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2972
|
+
type: "button",
|
|
2973
|
+
className: panel_module_css_default.primaryButton,
|
|
2974
|
+
onClick: () => {
|
|
2975
|
+
setDialog({ mode: "create" });
|
|
2976
|
+
},
|
|
2977
|
+
children: tt("keys.add")
|
|
2978
|
+
})]
|
|
2979
|
+
}),
|
|
2980
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2981
|
+
className: panel_module_css_default.banner,
|
|
2982
|
+
"data-kind": "error",
|
|
2983
|
+
children: tt("common.error", { error })
|
|
2984
|
+
}),
|
|
2985
|
+
keys === null && error === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2986
|
+
className: panel_module_css_default.loading,
|
|
2987
|
+
children: tt("common.loading")
|
|
2988
|
+
}),
|
|
2989
|
+
keys !== null && keys.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2990
|
+
className: panel_module_css_default.empty,
|
|
2991
|
+
children: tt("keys.empty")
|
|
2992
|
+
}),
|
|
2993
|
+
keys !== null && keys.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2994
|
+
className: panel_module_css_default.tableWrap,
|
|
2995
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
2996
|
+
className: panel_module_css_default.table,
|
|
2997
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2998
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("keys.col.name") }),
|
|
2999
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("form.keyPath") }),
|
|
3000
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("keys.col.status") }),
|
|
3001
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("keys.col.usedBy") }),
|
|
3002
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("hosts.col.description") }),
|
|
3003
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: tt("hosts.col.actions") })
|
|
3004
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: keys.map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3005
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: key.name }),
|
|
3006
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3007
|
+
className: panel_module_css_default.mono,
|
|
3008
|
+
children: key.path
|
|
3009
|
+
}),
|
|
3010
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3011
|
+
className: panel_module_css_default.badge,
|
|
3012
|
+
"data-status": key.exists ? "ok" : "fail",
|
|
3013
|
+
children: key.exists ? tt("keys.exists") : tt("keys.missing")
|
|
3014
|
+
}) }),
|
|
3015
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: key.usedBy.length === 0 ? tt("keys.unused") : tt("keys.usedBy", {
|
|
3016
|
+
count: key.usedBy.length,
|
|
3017
|
+
hosts: key.usedBy.join(", ")
|
|
3018
|
+
}) }),
|
|
3019
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3020
|
+
className: panel_module_css_default.cellMuted,
|
|
3021
|
+
children: key.note ?? ""
|
|
3022
|
+
}),
|
|
3023
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3024
|
+
className: panel_module_css_default.actions,
|
|
3025
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3026
|
+
type: "button",
|
|
3027
|
+
className: panel_module_css_default.linkButton,
|
|
3028
|
+
onClick: () => {
|
|
3029
|
+
setDialog({
|
|
3030
|
+
mode: "edit",
|
|
3031
|
+
key
|
|
3032
|
+
});
|
|
3033
|
+
},
|
|
3034
|
+
children: tt("hosts.edit")
|
|
3035
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3036
|
+
type: "button",
|
|
3037
|
+
className: panel_module_css_default.linkButton,
|
|
3038
|
+
"data-danger": true,
|
|
3039
|
+
onClick: () => {
|
|
3040
|
+
remove(key);
|
|
3041
|
+
},
|
|
3042
|
+
children: tt("hosts.delete")
|
|
3043
|
+
})]
|
|
3044
|
+
}) })
|
|
3045
|
+
] }, key.id)) })]
|
|
3046
|
+
})
|
|
3047
|
+
}),
|
|
3048
|
+
dialog !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyFormDialog, {
|
|
3049
|
+
api,
|
|
3050
|
+
editing: dialog.mode === "edit" ? dialog.key : void 0,
|
|
3051
|
+
onClose: () => {
|
|
3052
|
+
setDialog(null);
|
|
3053
|
+
},
|
|
3054
|
+
onSaved: () => {
|
|
3055
|
+
setDialog(null);
|
|
3056
|
+
load();
|
|
3057
|
+
},
|
|
3058
|
+
confirmAction: ask
|
|
3059
|
+
})
|
|
3060
|
+
]
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
//#endregion
|
|
2483
3064
|
//#region ../../node_modules/.pnpm/@xterm+xterm@6.0.0/node_modules/@xterm/xterm/lib/xterm.js
|
|
2484
3065
|
var require_xterm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2485
3066
|
(function(e, t) {
|
|
@@ -15592,6 +16173,8 @@ window.__ModuleLoader__.load({
|
|
|
15592
16173
|
const dataSubRef = (0, react.useRef)(null);
|
|
15593
16174
|
/** Tab whose screen the terminal currently holds. */
|
|
15594
16175
|
const renderedRef = (0, react.useRef)(void 0);
|
|
16176
|
+
/** Last geometry pushed to the active socket to skip duplicate resizes. */
|
|
16177
|
+
const lastSentSizeRef = (0, react.useRef)(null);
|
|
15595
16178
|
/** Tabs with a background close in flight, so one click cannot open two. */
|
|
15596
16179
|
const closingRef = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
15597
16180
|
const fontSource = terminalFont ?? NO_FONT_SOURCE;
|
|
@@ -15608,7 +16191,14 @@ window.__ModuleLoader__.load({
|
|
|
15608
16191
|
term.options.fontFamily = next;
|
|
15609
16192
|
fitRef.current?.fit();
|
|
15610
16193
|
const link = linkRef.current;
|
|
15611
|
-
if (link !== null)
|
|
16194
|
+
if (link !== null) {
|
|
16195
|
+
link.connection.resize(term.cols, term.rows);
|
|
16196
|
+
lastSentSizeRef.current = {
|
|
16197
|
+
connection: link.connection,
|
|
16198
|
+
cols: term.cols,
|
|
16199
|
+
rows: term.rows
|
|
16200
|
+
};
|
|
16201
|
+
}
|
|
15612
16202
|
}, [fontOverride]);
|
|
15613
16203
|
(0, react.useEffect)(() => {
|
|
15614
16204
|
let disposed = false;
|
|
@@ -15629,17 +16219,20 @@ window.__ModuleLoader__.load({
|
|
|
15629
16219
|
controller.setDraftAlias(presetAlias);
|
|
15630
16220
|
}, [presetAlias, controller]);
|
|
15631
16221
|
(0, react.useEffect)(() => {
|
|
15632
|
-
let lastCols = -1;
|
|
15633
|
-
let lastRows = -1;
|
|
15634
16222
|
const sync = () => {
|
|
15635
16223
|
const term = termRef.current;
|
|
15636
16224
|
const fit = fitRef.current;
|
|
15637
16225
|
if (term === null || fit === null) return;
|
|
15638
16226
|
fit.fit();
|
|
15639
16227
|
const link = linkRef.current;
|
|
15640
|
-
if (link
|
|
15641
|
-
|
|
15642
|
-
|
|
16228
|
+
if (link === null) return;
|
|
16229
|
+
const last = lastSentSizeRef.current;
|
|
16230
|
+
if (last === null || last.connection !== link.connection || term.cols !== last.cols || term.rows !== last.rows) {
|
|
16231
|
+
lastSentSizeRef.current = {
|
|
16232
|
+
connection: link.connection,
|
|
16233
|
+
cols: term.cols,
|
|
16234
|
+
rows: term.rows
|
|
16235
|
+
};
|
|
15643
16236
|
link.connection.resize(term.cols, term.rows);
|
|
15644
16237
|
}
|
|
15645
16238
|
};
|
|
@@ -15803,9 +16396,9 @@ window.__ModuleLoader__.load({
|
|
|
15803
16396
|
}
|
|
15804
16397
|
if (tab.status === "connected" && tab.sessionId !== void 0) {
|
|
15805
16398
|
const sessionId = tab.sessionId;
|
|
16399
|
+
controller.clearTerminalOutput(tab.id);
|
|
15806
16400
|
if (needsScreenClear(tab.id)) {
|
|
15807
16401
|
view.term.reset();
|
|
15808
|
-
controller.clearTerminalOutput(tab.id);
|
|
15809
16402
|
renderedRef.current = tab.id;
|
|
15810
16403
|
}
|
|
15811
16404
|
bindConnection(tab, api.attachTerminal(sessionId, view.term.cols, view.term.rows));
|
|
@@ -16457,6 +17050,13 @@ window.__ModuleLoader__.load({
|
|
|
16457
17050
|
};
|
|
16458
17051
|
}, [api]);
|
|
16459
17052
|
const seqRef = (0, react.useRef)(0);
|
|
17053
|
+
const mountedRef = (0, react.useRef)(true);
|
|
17054
|
+
(0, react.useEffect)(() => {
|
|
17055
|
+
mountedRef.current = true;
|
|
17056
|
+
return () => {
|
|
17057
|
+
mountedRef.current = false;
|
|
17058
|
+
};
|
|
17059
|
+
}, []);
|
|
16460
17060
|
const automaticRead = (0, react.useRef)({ running: false });
|
|
16461
17061
|
(0, react.useEffect)(() => {
|
|
16462
17062
|
if (!active) return;
|
|
@@ -16512,23 +17112,25 @@ window.__ModuleLoader__.load({
|
|
|
16512
17112
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
16513
17113
|
};
|
|
16514
17114
|
}, [api, active]);
|
|
16515
|
-
const refresh = async () => {
|
|
17115
|
+
const refresh = async (preserveError = false) => {
|
|
16516
17116
|
const seq = ++seqRef.current;
|
|
16517
17117
|
try {
|
|
16518
17118
|
const list = await api.listTunnels();
|
|
16519
|
-
if (seq !== seqRef.current) return;
|
|
17119
|
+
if (!mountedRef.current || seq !== seqRef.current) return;
|
|
16520
17120
|
setTunnels(list);
|
|
16521
|
-
setError(null);
|
|
17121
|
+
if (!preserveError) setError(null);
|
|
16522
17122
|
} catch (cause) {
|
|
16523
|
-
if (seq !== seqRef.current) return;
|
|
16524
|
-
setError(errorMessage(cause));
|
|
17123
|
+
if (!mountedRef.current || seq !== seqRef.current) return;
|
|
17124
|
+
if (!preserveError) setError(errorMessage(cause));
|
|
16525
17125
|
}
|
|
16526
17126
|
};
|
|
16527
17127
|
const stopTunnel = async (tunnelId) => {
|
|
16528
17128
|
try {
|
|
16529
17129
|
await api.stopTunnel(tunnelId);
|
|
17130
|
+
if (!mountedRef.current) return;
|
|
16530
17131
|
await refresh();
|
|
16531
17132
|
} catch (cause) {
|
|
17133
|
+
if (!mountedRef.current) return;
|
|
16532
17134
|
setError(errorMessage(cause));
|
|
16533
17135
|
}
|
|
16534
17136
|
};
|
|
@@ -16537,11 +17139,13 @@ window.__ModuleLoader__.load({
|
|
|
16537
17139
|
setBusy(true);
|
|
16538
17140
|
try {
|
|
16539
17141
|
await api.stopAllTunnels(alias === "" ? void 0 : alias);
|
|
17142
|
+
if (!mountedRef.current) return;
|
|
16540
17143
|
await refresh();
|
|
16541
17144
|
} catch (cause) {
|
|
17145
|
+
if (!mountedRef.current) return;
|
|
16542
17146
|
setError(errorMessage(cause));
|
|
16543
17147
|
} finally {
|
|
16544
|
-
setBusy(false);
|
|
17148
|
+
if (mountedRef.current) setBusy(false);
|
|
16545
17149
|
}
|
|
16546
17150
|
};
|
|
16547
17151
|
const start = async () => {
|
|
@@ -16557,6 +17161,7 @@ window.__ModuleLoader__.load({
|
|
|
16557
17161
|
return;
|
|
16558
17162
|
}
|
|
16559
17163
|
setBusy(true);
|
|
17164
|
+
setError(null);
|
|
16560
17165
|
setNotice(null);
|
|
16561
17166
|
try {
|
|
16562
17167
|
const tunnel = await api.startTunnel({
|
|
@@ -16565,15 +17170,22 @@ window.__ModuleLoader__.load({
|
|
|
16565
17170
|
remoteHost: remoteHost.trim() === "" ? void 0 : remoteHost.trim(),
|
|
16566
17171
|
localPort: localPortNumber
|
|
16567
17172
|
});
|
|
17173
|
+
if (!mountedRef.current) return;
|
|
17174
|
+
if (tunnel.state === "failed") {
|
|
17175
|
+
setError(tt("tunnel.failed", { error: tunnel.error ?? "unknown error" }));
|
|
17176
|
+
await refresh(true);
|
|
17177
|
+
return;
|
|
17178
|
+
}
|
|
16568
17179
|
setNotice(tt("tunnel.started", { localPort: tunnel.localPort }));
|
|
16569
17180
|
setRemotePort("");
|
|
16570
17181
|
setRemoteHost("");
|
|
16571
17182
|
setLocalPort("");
|
|
16572
17183
|
await refresh();
|
|
16573
17184
|
} catch (cause) {
|
|
17185
|
+
if (!mountedRef.current) return;
|
|
16574
17186
|
setError(tt("tunnel.failed", { error: errorMessage(cause) }));
|
|
16575
17187
|
} finally {
|
|
16576
|
-
setBusy(false);
|
|
17188
|
+
if (mountedRef.current) setBusy(false);
|
|
16577
17189
|
}
|
|
16578
17190
|
};
|
|
16579
17191
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -16724,7 +17336,7 @@ window.__ModuleLoader__.load({
|
|
|
16724
17336
|
//#endregion
|
|
16725
17337
|
//#region src/client/panel/SshPanel.tsx
|
|
16726
17338
|
/**
|
|
16727
|
-
* The SSH operations panel shell: a header with a close control, a
|
|
17339
|
+
* The SSH operations panel shell: a header with a close control, a six-tab
|
|
16728
17340
|
* bar, and the active tab's content.
|
|
16729
17341
|
*
|
|
16730
17342
|
* The active tab and the terminal tabs live in the controller, not in
|
|
@@ -16739,6 +17351,10 @@ window.__ModuleLoader__.load({
|
|
|
16739
17351
|
id: "hosts",
|
|
16740
17352
|
label: () => tt("tab.hosts")
|
|
16741
17353
|
},
|
|
17354
|
+
{
|
|
17355
|
+
id: "keys",
|
|
17356
|
+
label: () => tt("tab.keys")
|
|
17357
|
+
},
|
|
16742
17358
|
{
|
|
16743
17359
|
id: "terminal",
|
|
16744
17360
|
label: () => tt("tab.terminal")
|
|
@@ -16808,6 +17424,7 @@ window.__ModuleLoader__.load({
|
|
|
16808
17424
|
controller.requestConnect(alias);
|
|
16809
17425
|
}
|
|
16810
17426
|
}),
|
|
17427
|
+
activeTab === "keys" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeysTab, { api }),
|
|
16811
17428
|
activeTab === "terminal" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TerminalTab, {
|
|
16812
17429
|
api,
|
|
16813
17430
|
controller,
|
|
@@ -17030,7 +17647,7 @@ window.__ModuleLoader__.load({
|
|
|
17030
17647
|
/** The building package's version, when the bundle carries it. */
|
|
17031
17648
|
function bakedVersion() {
|
|
17032
17649
|
try {
|
|
17033
|
-
return "0.4.
|
|
17650
|
+
return "0.4.21";
|
|
17034
17651
|
} catch {
|
|
17035
17652
|
return;
|
|
17036
17653
|
}
|