@fish-under-sea/dsh-ssh-fish 0.0.0-stage → 0.5.0
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/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +98 -2
- package/README.zh.md +99 -0
- package/cordis.patch.yml +12 -0
- package/icon.svg +3 -0
- package/lib/client.js +16487 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +3511 -0
- package/lib/types/client/api.d.ts +141 -0
- package/lib/types/client/index.d.ts +37 -0
- package/lib/types/client/locales.d.ts +164 -0
- package/lib/types/client/native-panel.d.ts +70 -0
- package/lib/types/client/panel/ClusterTab.d.ts +7 -0
- package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
- package/lib/types/client/panel/HostsTab.d.ts +25 -0
- package/lib/types/client/panel/SshPanel.d.ts +14 -0
- package/lib/types/client/panel/TerminalTab.d.ts +22 -0
- package/lib/types/client/panel/TransferTab.d.ts +7 -0
- package/lib/types/client/panel/TunnelsTab.d.ts +19 -0
- package/lib/types/client/panel/controller.d.ts +89 -0
- package/lib/types/client/panel/helpers.d.ts +45 -0
- package/lib/types/client/panel/xterm.css.d.ts +2 -0
- package/lib/types/client/settings-binding.d.ts +61 -0
- package/lib/types/dsh-home.d.ts +16 -0
- package/lib/types/engine/cluster.d.ts +19 -0
- package/lib/types/engine/connection-pool.d.ts +112 -0
- package/lib/types/engine/proxy-command.d.ts +36 -0
- package/lib/types/engine/pty.d.ts +32 -0
- package/lib/types/engine/sftp.d.ts +20 -0
- package/lib/types/engine/terminal-sessions.d.ts +67 -0
- package/lib/types/engine/tunnel.d.ts +36 -0
- package/lib/types/engine.d.ts +89 -0
- package/lib/types/http.d.ts +59 -0
- package/lib/types/index.d.ts +83 -0
- package/lib/types/loopback.d.ts +24 -0
- package/lib/types/mount-once.d.ts +55 -0
- package/lib/types/protocol.d.ts +239 -0
- package/lib/types/routes.d.ts +33 -0
- package/lib/types/ssh-config.d.ts +34 -0
- package/lib/types/store.d.ts +71 -0
- package/lib/types/tool-surface.d.ts +71 -0
- package/lib/types/tools.d.ts +42 -0
- package/package.json +106 -4
- package/src/client/api.ts +562 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/index.ts +137 -0
- package/src/client/locales.ts +338 -0
- package/src/client/native-panel.tsx +141 -0
- package/src/client/panel/ClusterTab.tsx +123 -0
- package/src/client/panel/HostFormDialog.tsx +258 -0
- package/src/client/panel/HostsTab.tsx +325 -0
- package/src/client/panel/SshPanel.tsx +90 -0
- package/src/client/panel/TerminalTab.tsx +330 -0
- package/src/client/panel/TransferTab.tsx +232 -0
- package/src/client/panel/TunnelsTab.tsx +244 -0
- package/src/client/panel/controller.ts +167 -0
- package/src/client/panel/helpers.ts +84 -0
- package/src/client/panel/panel.module.css +876 -0
- package/src/client/panel/xterm.css.ts +2 -0
- package/src/client/settings-binding.ts +165 -0
- package/src/dsh-home.ts +42 -0
- package/src/engine/cluster.ts +60 -0
- package/src/engine/connection-pool.ts +543 -0
- package/src/engine/proxy-command.ts +248 -0
- package/src/engine/pty.ts +78 -0
- package/src/engine/sftp.ts +226 -0
- package/src/engine/terminal-sessions.ts +280 -0
- package/src/engine/tunnel.ts +194 -0
- package/src/engine.ts +176 -0
- package/src/http.ts +127 -0
- package/src/index.ts +234 -0
- package/src/loopback.ts +63 -0
- package/src/mount-once.ts +142 -0
- package/src/protocol.ts +230 -0
- package/src/routes.ts +494 -0
- package/src/ssh-config.ts +153 -0
- package/src/store.ts +419 -0
- package/src/tool-surface.ts +95 -0
- package/src/tools.ts +404 -0
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract between the host half (routes.ts) and the browser half
|
|
3
|
+
* (client/api.ts). Pure types only — imported by both halves, bundled into
|
|
4
|
+
* each, no runtime identity to share.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Authentication flavors a host entry may carry. */
|
|
8
|
+
export type SshAuthKind = 'key' | 'password' | 'agent'
|
|
9
|
+
|
|
10
|
+
/** One stored host entry (the $DSH_HOME/dsh-ssh.json store shape). */
|
|
11
|
+
export interface SshHostEntry {
|
|
12
|
+
/** Stable, user-chosen identifier used by every operation. */
|
|
13
|
+
alias: string
|
|
14
|
+
/** Hostname or IP of the target. */
|
|
15
|
+
host: string
|
|
16
|
+
/** SSH port (default 22). */
|
|
17
|
+
port: number
|
|
18
|
+
/** Login user. */
|
|
19
|
+
user: string
|
|
20
|
+
/** Authentication. */
|
|
21
|
+
auth: {
|
|
22
|
+
kind: SshAuthKind
|
|
23
|
+
/** Absolute path to the private key for 'key' auth. */
|
|
24
|
+
keyPath?: string
|
|
25
|
+
/** Passphrase for an encrypted key. */
|
|
26
|
+
passphrase?: string
|
|
27
|
+
/** Password for 'password' auth. */
|
|
28
|
+
password?: string
|
|
29
|
+
/**
|
|
30
|
+
* ssh-agent endpoint for 'agent' auth. A socket path, the special value
|
|
31
|
+
* 'pageant' (PuTTY Pageant on Windows), or undefined for auto-detect
|
|
32
|
+
* (SSH_AUTH_SOCK, then Pageant on Windows).
|
|
33
|
+
*/
|
|
34
|
+
agentPath?: string
|
|
35
|
+
}
|
|
36
|
+
/** Jump chain: local aliases connected through in order (ProxyJump). */
|
|
37
|
+
proxyJump: string[]
|
|
38
|
+
/**
|
|
39
|
+
* OpenSSH-compatible ProxyCommand: a shell command whose stdio becomes the
|
|
40
|
+
* connection transport. Tokens %h (host) / %p (port) / %r (user) / %n (alias)
|
|
41
|
+
* expand before exec and %% is a literal percent; an empty value or 'none'
|
|
42
|
+
* means "no proxy command". Mutually exclusive with a non-empty proxyJump.
|
|
43
|
+
*/
|
|
44
|
+
proxyCommand?: string
|
|
45
|
+
/** Free-form note. */
|
|
46
|
+
description?: string
|
|
47
|
+
/** Deployment environment label (development / production / ...). */
|
|
48
|
+
environment?: string
|
|
49
|
+
/** Free-form tags. */
|
|
50
|
+
tags: string[]
|
|
51
|
+
/** Physical location note. */
|
|
52
|
+
location?: string
|
|
53
|
+
createdAt: number
|
|
54
|
+
updatedAt: number
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Public (secret-free) projection of an entry, safe for the browser/agent. */
|
|
58
|
+
export interface SshHostSummary {
|
|
59
|
+
alias: string
|
|
60
|
+
host: string
|
|
61
|
+
port: number
|
|
62
|
+
user: string
|
|
63
|
+
auth: SshAuthKind
|
|
64
|
+
/** Whether the key path exists on the host machine (key auth only). */
|
|
65
|
+
keyReady: boolean
|
|
66
|
+
proxyJump: string[]
|
|
67
|
+
/** Configured ProxyCommand, echoed to the browser so the form can edit it. */
|
|
68
|
+
proxyCommand?: string
|
|
69
|
+
description?: string
|
|
70
|
+
environment?: string
|
|
71
|
+
tags: string[]
|
|
72
|
+
location?: string
|
|
73
|
+
createdAt: number
|
|
74
|
+
updatedAt: number
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Result of one non-interactive command execution. */
|
|
78
|
+
export interface ExecResult {
|
|
79
|
+
success: boolean
|
|
80
|
+
/** Remote exit code, or null when the channel died without one. */
|
|
81
|
+
exitCode: number | null
|
|
82
|
+
timedOut: boolean
|
|
83
|
+
stdout: string
|
|
84
|
+
stderr: string
|
|
85
|
+
/** Wall-clock duration of the round trip in ms. */
|
|
86
|
+
durationMs: number
|
|
87
|
+
/** Connection error message when the command never ran. */
|
|
88
|
+
error?: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** One server entry in a cluster run. */
|
|
92
|
+
export interface ClusterResult {
|
|
93
|
+
alias: string
|
|
94
|
+
ok: boolean
|
|
95
|
+
exitCode?: number | null
|
|
96
|
+
timedOut?: boolean
|
|
97
|
+
stdout?: string
|
|
98
|
+
stderr?: string
|
|
99
|
+
durationMs?: number
|
|
100
|
+
error?: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** SFTP transfer progress frame (upload stream). */
|
|
104
|
+
export interface TransferProgress {
|
|
105
|
+
phase: 'connecting' | 'transferring' | 'done' | 'error'
|
|
106
|
+
file: string
|
|
107
|
+
transferred: number
|
|
108
|
+
total: number
|
|
109
|
+
percent: number
|
|
110
|
+
speedBps?: number
|
|
111
|
+
error?: string
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** One active local port-forward tunnel. */
|
|
115
|
+
export interface TunnelInfo {
|
|
116
|
+
id: string
|
|
117
|
+
alias: string
|
|
118
|
+
localPort: number
|
|
119
|
+
remoteHost: string
|
|
120
|
+
remotePort: number
|
|
121
|
+
state: 'forwarding' | 'connecting' | 'failed'
|
|
122
|
+
error?: string
|
|
123
|
+
startedAt: number
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** One directory listing entry (remote file browser). */
|
|
127
|
+
export interface RemoteDirEntry {
|
|
128
|
+
name: string
|
|
129
|
+
type: 'dir' | 'file' | 'other'
|
|
130
|
+
size: number
|
|
131
|
+
mtimeMs: number
|
|
132
|
+
mode?: number
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Test-connection outcome. */
|
|
136
|
+
export interface TestResult {
|
|
137
|
+
ok: boolean
|
|
138
|
+
latencyMs?: number
|
|
139
|
+
error?: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Host edit payload (create/update); 'alias' comes from the URL for updates. */
|
|
143
|
+
export interface HostPayload {
|
|
144
|
+
alias?: string
|
|
145
|
+
host: string
|
|
146
|
+
port?: number
|
|
147
|
+
user: string
|
|
148
|
+
/**
|
|
149
|
+
* Authentication. Required on create; on update an omitted auth keeps the
|
|
150
|
+
* stored secrets (the browser never receives them back).
|
|
151
|
+
*/
|
|
152
|
+
auth?: SshHostEntry['auth']
|
|
153
|
+
proxyJump?: string[]
|
|
154
|
+
/**
|
|
155
|
+
* ProxyCommand to store. An empty string or 'none' clears a stored value;
|
|
156
|
+
* omitting the key leaves it untouched (PATCH semantics).
|
|
157
|
+
*/
|
|
158
|
+
proxyCommand?: string
|
|
159
|
+
description?: string
|
|
160
|
+
environment?: string
|
|
161
|
+
tags?: string[]
|
|
162
|
+
location?: string
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Why one ssh_config Host block was not imported. */
|
|
166
|
+
export type ImportSkipReason = 'wildcard' | 'existing' | 'match' | 'invalid'
|
|
167
|
+
|
|
168
|
+
/** One skipped ssh_config block and the reason it could not be imported. */
|
|
169
|
+
export interface ImportSkipBlock {
|
|
170
|
+
/** Host pattern (or '`Match …`' label) that was skipped. */
|
|
171
|
+
name: string
|
|
172
|
+
reason: ImportSkipReason
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Import outcome from ~/.ssh/config. */
|
|
176
|
+
export interface ImportResult {
|
|
177
|
+
parsed: number
|
|
178
|
+
added: number
|
|
179
|
+
skipped: number
|
|
180
|
+
/** Every skipped block with its reason, in scan order and deduplicated by name. */
|
|
181
|
+
skippedBlocks: ImportSkipBlock[]
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** JSON error body used by every route. */
|
|
185
|
+
export interface ApiErrorBody {
|
|
186
|
+
error: string
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** WebSocket terminal protocol frames (host -> client and client -> host). */
|
|
190
|
+
export type TerminalServerFrame =
|
|
191
|
+
/** The shell is up; `sessionId` reattaches to it after a view detach. */
|
|
192
|
+
| { type: 'ready'; alias: string; sessionId: string }
|
|
193
|
+
| { type: 'output'; data: string }
|
|
194
|
+
| { type: 'exit'; code: number | null; error?: string }
|
|
195
|
+
| {
|
|
196
|
+
type: 'auth_prompt'
|
|
197
|
+
name: string
|
|
198
|
+
instructions: string
|
|
199
|
+
prompts: Array<{ prompt: string; echo: boolean }>
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type TerminalClientFrame =
|
|
203
|
+
| { type: 'input'; data: string }
|
|
204
|
+
| { type: 'resize'; cols: number; rows: number }
|
|
205
|
+
| { type: 'auth_response'; responses: string[] }
|
|
206
|
+
/** Leave the socket while the host keeps the shell alive for a reattach. */
|
|
207
|
+
| { type: 'detach' }
|
|
208
|
+
/** End the session outright (the view's disconnect control). */
|
|
209
|
+
| { type: 'close' }
|
|
210
|
+
|
|
211
|
+
/** Route paths the client calls (shared literals). */
|
|
212
|
+
export const SSH_API_BASE = '/api/dsh-ssh' as const
|
|
213
|
+
|
|
214
|
+
export const SSH_API = {
|
|
215
|
+
hosts: SSH_API_BASE + '/hosts',
|
|
216
|
+
importSshConfig: SSH_API_BASE + '/hosts/import-ssh-config',
|
|
217
|
+
test: SSH_API_BASE + '/test',
|
|
218
|
+
exec: SSH_API_BASE + '/exec',
|
|
219
|
+
cluster: SSH_API_BASE + '/cluster',
|
|
220
|
+
upload: SSH_API_BASE + '/upload',
|
|
221
|
+
download: SSH_API_BASE + '/download',
|
|
222
|
+
ls: SSH_API_BASE + '/ls',
|
|
223
|
+
tunnel: SSH_API_BASE + '/tunnel',
|
|
224
|
+
terminal: SSH_API_BASE + '/terminal',
|
|
225
|
+
} as const
|
|
226
|
+
|
|
227
|
+
/** NDJSON transfer stream line shapes (upload). */
|
|
228
|
+
export type TransferStreamLine =
|
|
229
|
+
| { type: 'progress'; progress: TransferProgress }
|
|
230
|
+
| { type: 'result'; ok: boolean; transferredBytes?: number; error?: string }
|