dsh-ssh-hub 0.0.0-stage → 0.2.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 (133) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +271 -2
  3. package/cordis.patch.yml +16 -0
  4. package/icon.svg +3 -0
  5. package/lib/client.js +13975 -0
  6. package/lib/index.js +6908 -0
  7. package/lib/types/activity/history.d.ts +50 -0
  8. package/lib/types/alerting/notify.d.ts +89 -0
  9. package/lib/types/alerting/prompt-summary.d.ts +28 -0
  10. package/lib/types/alerting/rules.d.ts +135 -0
  11. package/lib/types/alerting/tools.d.ts +30 -0
  12. package/lib/types/audit/audit-log.d.ts +84 -0
  13. package/lib/types/audit/recorder.d.ts +50 -0
  14. package/lib/types/client/api.d.ts +222 -0
  15. package/lib/types/client/index.d.ts +45 -0
  16. package/lib/types/client/locales.d.ts +319 -0
  17. package/lib/types/client/native-panel.d.ts +70 -0
  18. package/lib/types/client/panel/ClusterTab.d.ts +7 -0
  19. package/lib/types/client/panel/DeployTab.d.ts +10 -0
  20. package/lib/types/client/panel/FleetTab.d.ts +10 -0
  21. package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
  22. package/lib/types/client/panel/HostsTab.d.ts +25 -0
  23. package/lib/types/client/panel/LogsTab.d.ts +10 -0
  24. package/lib/types/client/panel/SshPanel.d.ts +14 -0
  25. package/lib/types/client/panel/TerminalTab.d.ts +27 -0
  26. package/lib/types/client/panel/TransferTab.d.ts +7 -0
  27. package/lib/types/client/panel/TunnelEditDialog.d.ts +15 -0
  28. package/lib/types/client/panel/TunnelsTab.d.ts +27 -0
  29. package/lib/types/client/panel/controller.d.ts +253 -0
  30. package/lib/types/client/panel/helpers.d.ts +45 -0
  31. package/lib/types/client/panel/tabs.d.ts +62 -0
  32. package/lib/types/client/panel/xterm.css.d.ts +2 -0
  33. package/lib/types/client/settings-binding.d.ts +71 -0
  34. package/lib/types/deploy/orchestrator.d.ts +158 -0
  35. package/lib/types/deploy/tools.d.ts +14 -0
  36. package/lib/types/dsh-home.d.ts +16 -0
  37. package/lib/types/engine/cluster.d.ts +19 -0
  38. package/lib/types/engine/connection-pool.d.ts +183 -0
  39. package/lib/types/engine/proxy-command.d.ts +36 -0
  40. package/lib/types/engine/pty.d.ts +32 -0
  41. package/lib/types/engine/sftp.d.ts +20 -0
  42. package/lib/types/engine/terminal-sessions.d.ts +67 -0
  43. package/lib/types/engine/tunnel-discovery.d.ts +89 -0
  44. package/lib/types/engine/tunnel-remarks.d.ts +49 -0
  45. package/lib/types/engine/tunnel.d.ts +76 -0
  46. package/lib/types/engine.d.ts +103 -0
  47. package/lib/types/http.d.ts +59 -0
  48. package/lib/types/index.d.ts +128 -0
  49. package/lib/types/inspect/checks.d.ts +118 -0
  50. package/lib/types/inspect/inspection.d.ts +111 -0
  51. package/lib/types/inspect/tools.d.ts +50 -0
  52. package/lib/types/logs/search.d.ts +131 -0
  53. package/lib/types/logs/tools.d.ts +6 -0
  54. package/lib/types/loopback.d.ts +64 -0
  55. package/lib/types/monitor/loop.d.ts +133 -0
  56. package/lib/types/monitor/metrics.d.ts +151 -0
  57. package/lib/types/mount-once.d.ts +55 -0
  58. package/lib/types/protocol.d.ts +524 -0
  59. package/lib/types/routes.d.ts +82 -0
  60. package/lib/types/security/known-hosts.d.ts +153 -0
  61. package/lib/types/security/master-secret.d.ts +157 -0
  62. package/lib/types/security/redact.d.ts +44 -0
  63. package/lib/types/security/secrets.d.ts +70 -0
  64. package/lib/types/ssh-config.d.ts +42 -0
  65. package/lib/types/store.d.ts +183 -0
  66. package/lib/types/tool-surface.d.ts +72 -0
  67. package/lib/types/tools.d.ts +56 -0
  68. package/locale/en.json +6 -0
  69. package/locale/zh.json +6 -0
  70. package/package.json +126 -6
  71. package/src/activity/history.ts +117 -0
  72. package/src/alerting/notify.ts +212 -0
  73. package/src/alerting/prompt-summary.ts +71 -0
  74. package/src/alerting/rules.ts +281 -0
  75. package/src/alerting/tools.ts +263 -0
  76. package/src/audit/audit-log.ts +199 -0
  77. package/src/audit/recorder.ts +73 -0
  78. package/src/client/api.ts +782 -0
  79. package/src/client/css-modules.d.ts +5 -0
  80. package/src/client/index.ts +150 -0
  81. package/src/client/locales.ts +654 -0
  82. package/src/client/native-panel.tsx +141 -0
  83. package/src/client/panel/ClusterTab.tsx +141 -0
  84. package/src/client/panel/DeployTab.tsx +314 -0
  85. package/src/client/panel/FleetTab.tsx +494 -0
  86. package/src/client/panel/HostFormDialog.tsx +289 -0
  87. package/src/client/panel/HostsTab.tsx +395 -0
  88. package/src/client/panel/LogsTab.tsx +208 -0
  89. package/src/client/panel/SshPanel.tsx +105 -0
  90. package/src/client/panel/TerminalTab.tsx +550 -0
  91. package/src/client/panel/TransferTab.tsx +238 -0
  92. package/src/client/panel/TunnelEditDialog.tsx +174 -0
  93. package/src/client/panel/TunnelsTab.tsx +328 -0
  94. package/src/client/panel/controller.ts +507 -0
  95. package/src/client/panel/helpers.ts +84 -0
  96. package/src/client/panel/panel.module.css +1734 -0
  97. package/src/client/panel/tabs.ts +52 -0
  98. package/src/client/panel/xterm.css.ts +2 -0
  99. package/src/client/settings-binding.ts +184 -0
  100. package/src/deploy/orchestrator.ts +326 -0
  101. package/src/deploy/tools.ts +225 -0
  102. package/src/dsh-home.ts +42 -0
  103. package/src/engine/cluster.ts +60 -0
  104. package/src/engine/connection-pool.ts +721 -0
  105. package/src/engine/proxy-command.ts +248 -0
  106. package/src/engine/pty.ts +78 -0
  107. package/src/engine/sftp.ts +229 -0
  108. package/src/engine/terminal-sessions.ts +280 -0
  109. package/src/engine/tunnel-discovery.ts +353 -0
  110. package/src/engine/tunnel-remarks.ts +120 -0
  111. package/src/engine/tunnel.ts +300 -0
  112. package/src/engine.ts +195 -0
  113. package/src/http.ts +127 -0
  114. package/src/index.ts +690 -0
  115. package/src/inspect/checks.ts +251 -0
  116. package/src/inspect/inspection.ts +321 -0
  117. package/src/inspect/tools.ts +366 -0
  118. package/src/logs/search.ts +251 -0
  119. package/src/logs/tools.ts +160 -0
  120. package/src/loopback.ts +119 -0
  121. package/src/monitor/loop.ts +265 -0
  122. package/src/monitor/metrics.ts +333 -0
  123. package/src/mount-once.ts +142 -0
  124. package/src/protocol.ts +534 -0
  125. package/src/routes.ts +998 -0
  126. package/src/security/known-hosts.ts +342 -0
  127. package/src/security/master-secret.ts +334 -0
  128. package/src/security/redact.ts +119 -0
  129. package/src/security/secrets.ts +152 -0
  130. package/src/ssh-config.ts +182 -0
  131. package/src/store.ts +757 -0
  132. package/src/tool-surface.ts +96 -0
  133. package/src/tools.ts +550 -0
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Host form dialog: create/edit one stored host entry. A fixed backdrop with
3
+ * a centered card; Escape and backdrop clicks close it. Secrets (key path,
4
+ * passphrase, password) are never pre-filled when editing (the API only
5
+ * exposes the secret-free summary).
6
+ */
7
+ import { useEffect, useState } from 'react'
8
+ import type { SshApi } from '../api.ts'
9
+ import type { HostPayload, SshAuthKind, SshHostSummary } from '../../protocol.ts'
10
+ import { errorMessage, tt } from './helpers.ts'
11
+ import css from './panel.module.css'
12
+
13
+ /** Host form dialog props. */
14
+ export interface HostFormDialogProps {
15
+ api: SshApi
16
+ /** The host being edited; null/undefined means create. */
17
+ editing?: SshHostSummary | null
18
+ onClose: () => void
19
+ onSaved: (host: SshHostSummary) => void
20
+ }
21
+
22
+ /** The staged form values (all strings; parsed on save). */
23
+ interface FormState {
24
+ alias: string
25
+ host: string
26
+ port: string
27
+ user: string
28
+ authKind: SshAuthKind
29
+ keyPath: string
30
+ passphrase: string
31
+ password: string
32
+ agentPath: string
33
+ proxyJump: string
34
+ proxyCommand: string
35
+ forwardAgent: boolean
36
+ description: string
37
+ environment: string
38
+ tags: string
39
+ location: string
40
+ }
41
+
42
+ /** Split a comma-separated input into a trimmed, non-empty string list. */
43
+ function splitList(text: string): string[] {
44
+ return text.split(',').map(part => part.trim()).filter(part => part !== '')
45
+ }
46
+
47
+ /** Initial form state: the summary's public fields plus empty secrets. */
48
+ function blankOf(editing: SshHostSummary | null | undefined): FormState {
49
+ return {
50
+ alias: editing?.alias ?? '',
51
+ host: editing?.host ?? '',
52
+ port: String(editing?.port ?? 22),
53
+ user: editing?.user ?? '',
54
+ authKind: editing?.auth ?? 'key',
55
+ keyPath: '',
56
+ passphrase: '',
57
+ password: '',
58
+ agentPath: '',
59
+ proxyJump: (editing?.proxyJump ?? []).join(', '),
60
+ proxyCommand: editing?.proxyCommand ?? '',
61
+ forwardAgent: editing?.forwardAgent === true,
62
+ description: editing?.description ?? '',
63
+ environment: editing?.environment ?? '',
64
+ tags: (editing?.tags ?? []).join(', '),
65
+ location: editing?.location ?? '',
66
+ }
67
+ }
68
+
69
+ /** The create/edit host modal. */
70
+ export function HostFormDialog({ api, editing, onClose, onSaved }: HostFormDialogProps) {
71
+ const [form, setForm] = useState<FormState>(() => blankOf(editing))
72
+ const [saving, setSaving] = useState(false)
73
+ const [error, setError] = useState<string | null>(null)
74
+
75
+ // Escape closes the dialog.
76
+ useEffect(() => {
77
+ const onKey = (event: KeyboardEvent): void => {
78
+ if (event.key === 'Escape') onClose()
79
+ }
80
+ document.addEventListener('keydown', onKey)
81
+ return () => { document.removeEventListener('keydown', onKey) }
82
+ }, [onClose])
83
+
84
+ const set = <K extends keyof FormState>(key: K, value: FormState[K]): void => {
85
+ setForm(prev => ({ ...prev, [key]: value }))
86
+ }
87
+
88
+ const save = async (): Promise<void> => {
89
+ const alias = form.alias.trim()
90
+ const host = form.host.trim()
91
+ const user = form.user.trim()
92
+ if (alias === '' || host === '' || user === '') {
93
+ setError(tt('form.required'))
94
+ return
95
+ }
96
+ const port = Number(form.port)
97
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
98
+ setError(tt('form.portInvalid'))
99
+ return
100
+ }
101
+ // A password-auth host needs a password on create; when editing, a blank
102
+ // secret field preserves the stored credential instead.
103
+ if (editing == null && form.authKind === 'password' && form.password === '') {
104
+ setError(tt('form.passwordRequired'))
105
+ return
106
+ }
107
+ // Secrets are never echoed back by the API: when editing and the secret
108
+ // fields are left empty, the auth block is omitted so the stored
109
+ // authentication is preserved. The agent path is not a secret — an empty
110
+ // one is the documented "auto-detect" choice — so an agent form always
111
+ // submits its auth block; omitting it would make the PATCH a silent no-op
112
+ // that keeps the previous auth kind (#1910).
113
+ const secretEmpty = form.authKind === 'password'
114
+ ? form.password === ''
115
+ : form.authKind === 'key'
116
+ ? form.keyPath.trim() === ''
117
+ : false
118
+ const auth: HostPayload['auth'] = editing != null && secretEmpty
119
+ ? undefined
120
+ : form.authKind === 'password'
121
+ ? { kind: 'password', password: form.password }
122
+ : form.authKind === 'key'
123
+ ? { kind: 'key', keyPath: form.keyPath.trim(), passphrase: form.passphrase === '' ? undefined : form.passphrase }
124
+ : form.authKind === 'none'
125
+ ? { kind: 'none' }
126
+ : { kind: 'agent', agentPath: form.agentPath.trim() === '' ? undefined : form.agentPath.trim() }
127
+ const payload: HostPayload = {
128
+ host,
129
+ port,
130
+ user,
131
+ auth,
132
+ proxyJump: splitList(form.proxyJump),
133
+ // Always sent (never omitted): an empty value is the explicit clear,
134
+ // because the API cannot express "remove this field" any other way.
135
+ proxyCommand: form.proxyCommand.trim(),
136
+ // Always sent (never omitted): the flag is a plain boolean, so saving the
137
+ // form can both enable and clear forwarding (omitting it would keep the
138
+ // stored value under PATCH semantics).
139
+ forwardAgent: form.forwardAgent,
140
+ description: form.description.trim() === '' ? undefined : form.description.trim(),
141
+ environment: form.environment.trim() === '' ? undefined : form.environment.trim(),
142
+ tags: splitList(form.tags),
143
+ location: form.location.trim() === '' ? undefined : form.location.trim(),
144
+ }
145
+ setSaving(true)
146
+ setError(null)
147
+ try {
148
+ const saved = editing != null
149
+ ? await api.updateHost(editing.alias, payload)
150
+ : await api.createHost({ ...payload, alias })
151
+ onSaved(saved)
152
+ } catch (cause) {
153
+ setError(errorMessage(cause))
154
+ setSaving(false)
155
+ }
156
+ }
157
+
158
+ return (
159
+ <div className={css.modalBackdrop} onClick={onClose}>
160
+ <div
161
+ className={css.modal}
162
+ role="dialog"
163
+ aria-modal="true"
164
+ // A dialog with no accessible name is announced as just "dialog", so a
165
+ // screen-reader user cannot tell add-host from edit-host. The title
166
+ // already says which; it only needed to be referenced.
167
+ aria-labelledby="dsh-ssh-host-form-title"
168
+ onClick={event => { event.stopPropagation() }}
169
+ >
170
+ <h3 className={css.modalTitle} id="dsh-ssh-host-form-title">{editing != null ? tt('form.title.edit', { alias: editing.alias }) : tt('form.title.create')}</h3>
171
+ <div className={css.formRow}>
172
+ <label className={css.field}>
173
+ <span className={css.fieldLabel}>{tt('form.alias')}</span>
174
+ <input className={css.input} value={form.alias} disabled={editing != null} onChange={event => { set('alias', event.target.value) }} />
175
+ <span className={css.hint}>{tt('form.aliasHint')}</span>
176
+ </label>
177
+ <label className={css.field}>
178
+ <span className={css.fieldLabel}>{tt('form.host')}</span>
179
+ <input className={css.input} value={form.host} onChange={event => { set('host', event.target.value) }} />
180
+ </label>
181
+ </div>
182
+ <div className={css.formRow}>
183
+ <label className={css.field}>
184
+ <span className={css.fieldLabel}>{tt('form.port')}</span>
185
+ <input className={css.input} type="number" min={1} max={65535} value={form.port} onChange={event => { set('port', event.target.value) }} />
186
+ </label>
187
+ <label className={css.field}>
188
+ <span className={css.fieldLabel}>{tt('form.user')}</span>
189
+ <input className={css.input} value={form.user} onChange={event => { set('user', event.target.value) }} />
190
+ </label>
191
+ </div>
192
+ <div className={css.field}>
193
+ <span className={css.fieldLabel}>{tt('form.auth')}</span>
194
+ <div className={css.radioRow}>
195
+ <label className={css.radioLabel}>
196
+ <input type="radio" name="dsh-ssh-auth" checked={form.authKind === 'key'} onChange={() => { set('authKind', 'key') }} />
197
+ {tt('form.auth.key')}
198
+ </label>
199
+ <label className={css.radioLabel}>
200
+ <input type="radio" name="dsh-ssh-auth" checked={form.authKind === 'password'} onChange={() => { set('authKind', 'password') }} />
201
+ {tt('form.auth.password')}
202
+ </label>
203
+ <label className={css.radioLabel}>
204
+ <input type="radio" name="dsh-ssh-auth" checked={form.authKind === 'agent'} onChange={() => { set('authKind', 'agent') }} />
205
+ {tt('form.auth.agent')}
206
+ </label>
207
+ <label className={css.radioLabel}>
208
+ <input type="radio" name="dsh-ssh-auth" checked={form.authKind === 'none'} onChange={() => { set('authKind', 'none') }} />
209
+ {tt('form.auth.none')}
210
+ </label>
211
+ </div>
212
+ {editing != null && <span className={css.hint}>{tt('form.authKeepHint')}</span>}
213
+ </div>
214
+ {form.authKind === 'key' ? (
215
+ <div className={css.formRow}>
216
+ <label className={css.field}>
217
+ <span className={css.fieldLabel}>{tt('form.keyPath')}</span>
218
+ <input className={css.input} value={form.keyPath} onChange={event => { set('keyPath', event.target.value) }} />
219
+ <span className={css.hint}>{tt('form.keyPathHint')}</span>
220
+ </label>
221
+ <label className={css.field}>
222
+ <span className={css.fieldLabel}>{tt('form.passphrase')}</span>
223
+ <input className={css.input} type="password" value={form.passphrase} onChange={event => { set('passphrase', event.target.value) }} />
224
+ </label>
225
+ </div>
226
+ ) : form.authKind === 'agent' ? (
227
+ <label className={css.field}>
228
+ <span className={css.fieldLabel}>{tt('form.agentPath')}</span>
229
+ <input className={css.input} value={form.agentPath} onChange={event => { set('agentPath', event.target.value) }} />
230
+ <span className={css.hint}>{tt('form.agentPathHint')}</span>
231
+ </label>
232
+ ) : form.authKind === 'none' ? (
233
+ <span className={css.hint}>{tt('form.auth.noneHint')}</span>
234
+ ) : (
235
+ <label className={css.field}>
236
+ <span className={css.fieldLabel}>{tt('form.password')}</span>
237
+ <input className={css.input} type="password" value={form.password} onChange={event => { set('password', event.target.value) }} />
238
+ <span className={css.hint}>{tt('form.passwordHint')}</span>
239
+ </label>
240
+ )}
241
+ <label className={css.field}>
242
+ <span className={css.fieldLabel}>{tt('form.proxyJump')}</span>
243
+ <input className={css.input} value={form.proxyJump} onChange={event => { set('proxyJump', event.target.value) }} />
244
+ <span className={css.hint}>{tt('form.proxyJumpHint')}</span>
245
+ </label>
246
+ <label className={css.field}>
247
+ <span className={css.fieldLabel}>{tt('form.proxyCommand')}</span>
248
+ <input
249
+ className={css.input}
250
+ value={form.proxyCommand}
251
+ placeholder="corp-vpn proxy %h %p %r"
252
+ onChange={event => { set('proxyCommand', event.target.value) }}
253
+ />
254
+ <span className={css.hint}>{tt('form.proxyCommandHint')}</span>
255
+ </label>
256
+ <label className={css.field}>
257
+ <span className={css.fieldLabel}>{tt('form.forwardAgent')}</span>
258
+ <input type="checkbox" checked={form.forwardAgent} onChange={event => { set('forwardAgent', event.target.checked) }} />
259
+ <span className={css.hint}>{tt('form.forwardAgentHint')}</span>
260
+ </label>
261
+ <div className={css.formRow}>
262
+ <label className={css.field}>
263
+ <span className={css.fieldLabel}>{tt('form.environment')}</span>
264
+ <input className={css.input} value={form.environment} onChange={event => { set('environment', event.target.value) }} />
265
+ <span className={css.hint}>{tt('form.environmentHint')}</span>
266
+ </label>
267
+ <label className={css.field}>
268
+ <span className={css.fieldLabel}>{tt('form.location')}</span>
269
+ <input className={css.input} value={form.location} onChange={event => { set('location', event.target.value) }} />
270
+ </label>
271
+ </div>
272
+ <label className={css.field}>
273
+ <span className={css.fieldLabel}>{tt('form.description')}</span>
274
+ <input className={css.input} value={form.description} onChange={event => { set('description', event.target.value) }} />
275
+ </label>
276
+ <label className={css.field}>
277
+ <span className={css.fieldLabel}>{tt('form.tags')}</span>
278
+ <input className={css.input} value={form.tags} onChange={event => { set('tags', event.target.value) }} />
279
+ <span className={css.hint}>{tt('form.tagsHint')}</span>
280
+ </label>
281
+ {error !== null && <p className={css.formError} role="alert">{tt('common.error', { error })}</p>}
282
+ <div className={css.modalFooter}>
283
+ <button type="button" className={css.ghostButton} disabled={saving} onClick={onClose}>{tt('form.cancel')}</button>
284
+ <button type="button" className={css.primaryButton} disabled={saving} onClick={() => { void save() }}>{tt('form.save')}</button>
285
+ </div>
286
+ </div>
287
+ </div>
288
+ )
289
+ }