@fish-under-sea/dsh-ssh-fish 0.0.0-stage → 1.0.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.
Files changed (82) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +23 -0
  3. package/README.en.md +29 -0
  4. package/README.i18n.yaml +6 -0
  5. package/README.md +28 -2
  6. package/README.zh.md +29 -0
  7. package/cordis.patch.yml +12 -0
  8. package/icon.svg +3 -0
  9. package/lib/client.js +16487 -0
  10. package/lib/client.js.map +1 -0
  11. package/lib/index.js +3511 -0
  12. package/lib/types/client/api.d.ts +141 -0
  13. package/lib/types/client/index.d.ts +37 -0
  14. package/lib/types/client/locales.d.ts +164 -0
  15. package/lib/types/client/native-panel.d.ts +70 -0
  16. package/lib/types/client/panel/ClusterTab.d.ts +7 -0
  17. package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
  18. package/lib/types/client/panel/HostsTab.d.ts +25 -0
  19. package/lib/types/client/panel/SshPanel.d.ts +14 -0
  20. package/lib/types/client/panel/TerminalTab.d.ts +22 -0
  21. package/lib/types/client/panel/TransferTab.d.ts +7 -0
  22. package/lib/types/client/panel/TunnelsTab.d.ts +19 -0
  23. package/lib/types/client/panel/controller.d.ts +89 -0
  24. package/lib/types/client/panel/helpers.d.ts +45 -0
  25. package/lib/types/client/panel/xterm.css.d.ts +2 -0
  26. package/lib/types/client/settings-binding.d.ts +61 -0
  27. package/lib/types/dsh-home.d.ts +16 -0
  28. package/lib/types/engine/cluster.d.ts +19 -0
  29. package/lib/types/engine/connection-pool.d.ts +112 -0
  30. package/lib/types/engine/proxy-command.d.ts +36 -0
  31. package/lib/types/engine/pty.d.ts +32 -0
  32. package/lib/types/engine/sftp.d.ts +20 -0
  33. package/lib/types/engine/terminal-sessions.d.ts +67 -0
  34. package/lib/types/engine/tunnel.d.ts +36 -0
  35. package/lib/types/engine.d.ts +89 -0
  36. package/lib/types/http.d.ts +59 -0
  37. package/lib/types/index.d.ts +83 -0
  38. package/lib/types/loopback.d.ts +24 -0
  39. package/lib/types/mount-once.d.ts +55 -0
  40. package/lib/types/protocol.d.ts +239 -0
  41. package/lib/types/routes.d.ts +33 -0
  42. package/lib/types/ssh-config.d.ts +34 -0
  43. package/lib/types/store.d.ts +71 -0
  44. package/lib/types/tool-surface.d.ts +71 -0
  45. package/lib/types/tools.d.ts +42 -0
  46. package/package.json +109 -4
  47. package/src/client/api.ts +562 -0
  48. package/src/client/css-modules.d.ts +5 -0
  49. package/src/client/index.ts +137 -0
  50. package/src/client/locales.ts +338 -0
  51. package/src/client/native-panel.tsx +141 -0
  52. package/src/client/panel/ClusterTab.tsx +123 -0
  53. package/src/client/panel/HostFormDialog.tsx +258 -0
  54. package/src/client/panel/HostsTab.tsx +325 -0
  55. package/src/client/panel/SshPanel.tsx +90 -0
  56. package/src/client/panel/TerminalTab.tsx +330 -0
  57. package/src/client/panel/TransferTab.tsx +232 -0
  58. package/src/client/panel/TunnelsTab.tsx +244 -0
  59. package/src/client/panel/controller.ts +167 -0
  60. package/src/client/panel/helpers.ts +84 -0
  61. package/src/client/panel/panel.module.css +876 -0
  62. package/src/client/panel/xterm.css.ts +2 -0
  63. package/src/client/settings-binding.ts +165 -0
  64. package/src/dsh-home.ts +42 -0
  65. package/src/engine/cluster.ts +60 -0
  66. package/src/engine/connection-pool.ts +543 -0
  67. package/src/engine/proxy-command.ts +248 -0
  68. package/src/engine/pty.ts +78 -0
  69. package/src/engine/sftp.ts +226 -0
  70. package/src/engine/terminal-sessions.ts +280 -0
  71. package/src/engine/tunnel.ts +194 -0
  72. package/src/engine.ts +176 -0
  73. package/src/http.ts +127 -0
  74. package/src/index.ts +234 -0
  75. package/src/loopback.ts +63 -0
  76. package/src/mount-once.ts +142 -0
  77. package/src/protocol.ts +230 -0
  78. package/src/routes.ts +494 -0
  79. package/src/ssh-config.ts +153 -0
  80. package/src/store.ts +419 -0
  81. package/src/tool-surface.ts +95 -0
  82. package/src/tools.ts +404 -0
@@ -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 }