dsh-linked-workspace 0.11.0 → 0.12.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/CHANGELOG.md +7 -0
- package/README.en.md +5 -3
- package/README.md +5 -3
- package/docs/API.md +6 -1
- package/docs/VERIFY.md +12 -1
- package/lib/client.js +240 -18
- package/lib/index.js +51 -4
- package/lib/ssh.js +154 -20
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
English · [简体中文](CHANGELOG.zh.md)
|
|
4
4
|
|
|
5
|
+
## 0.12.0 — 2026-11-14
|
|
6
|
+
|
|
7
|
+
- **Password diagnostics**: an SSH failure now shows the server's own reason next to the translated text (for example “SSH 认证失败:… All configured authentication methods failed.”), and the add-workspace dialog gained a **Check password** button that stores the secret and opens a probe connection, so a wrong password is caught before creating the workspace. Password logins also answer `keyboard-interactive` prompts with the same secret, which is what PAM-based servers often ask for.
|
|
8
|
+
- **Local SSH credentials**: hosts listed in `~/.ssh/config` without an `IdentityFile` used to require `dsh-ssh-tunnel` for a password. The “Add workspace” dialog now shows them as “Password needed” instead of disabling them, takes the password once, and stores it in the plugin's own `$DSH_HOME/linked-workspace/ssh-credentials.json` (mode `0600`, Host process only). New API `hosts.credentials` (`{ hostId, password?, passphrase?, privateKey?, clear? }`); `hosts.list` entries gained `hasStoredPassword`, and a password typed earlier is reused when the field is left empty.
|
|
9
|
+
- **Settings nav icon**: the “Linked workspaces” entry in the settings list now uses the plugin's own stacked-sheets glyph (registered through the host's `settings.section.icon` seat) instead of the default gear.
|
|
10
|
+
- **Dialog scrolling (fix)**: a wheel over the “Add workspace” dialog used to scroll the conversation behind it — the SSH host list and the dialog body never moved. The dialog now takes the gesture in the capture phase, scrolls its own scroll areas (host list first, then the body) and never lets the page behind move while it is open.
|
|
11
|
+
|
|
5
12
|
## 0.11.0 — 2026-11-13
|
|
6
13
|
|
|
7
14
|
**Breaking change**: Remote workspaces replace remote directories.
|
package/README.en.md
CHANGED
|
@@ -23,7 +23,7 @@ Turn an existing SSH connection into a **linked workspace** or a **remote worksp
|
|
|
23
23
|
## Requirements
|
|
24
24
|
|
|
25
25
|
- **DSH**: 0.2.1-rc.4 or newer (`engines` allows `>=0.2.0-rc.2 <0.3.0-0`).
|
|
26
|
-
- **SSH**: the host
|
|
26
|
+
- **SSH**: the host lives in `~/.ssh/config`, or in DSH's SSH Manager (`dsh-ssh-tunnel`, optional). A plain `~/.ssh/config` is enough: the plugin ships its own SSH client and pins the host key on first use into `$DSH_HOME/linked-workspace/known_hosts.json` (a changed key is refused, with instructions to delete that entry). **`dsh-ssh-tunnel` is optional**: a host in `~/.ssh/config` without an `IdentityFile` can be given a password once in the “Add workspace” dialog, and it stays on this machine (see “SSH credentials” under Configuration).
|
|
27
27
|
- **dsh-better-sidebar** (optional): `>=0.24.0`. It renders the sidebar directory pages and the file editor; without it everything else (settings page, directory pickers, agent tools) still works.
|
|
28
28
|
- **Document editing** (optional): Python 3 with `python-docx`, `openpyxl`, `python-pptx` and `PyMuPDF`; set `DSH_OFFICE_PYTHON` to choose the interpreter. Markdown needs no Python.
|
|
29
29
|
- **Development**: Node.js ≥ 20.
|
|
@@ -31,7 +31,7 @@ Turn an existing SSH connection into a **linked workspace** or a **remote worksp
|
|
|
31
31
|
## Quick start
|
|
32
32
|
|
|
33
33
|
1. **Install** the plugin (see [Install](#install)) and restart the DSH client.
|
|
34
|
-
2. **Add a workspace**: Settings → Linked workspaces → “Create linked workspace” or “Create remote workspace”, then pick an existing SSH host (add it
|
|
34
|
+
2. **Add a workspace**: Settings → Linked workspaces → “Create linked workspace” or “Create remote workspace”, then pick an existing SSH host (add it to `~/.ssh/config` or the DSH SSH Manager, then press “Refresh”, if the list is empty).
|
|
35
35
|
3. **Pick directories**: a linked workspace needs a remote path plus a local folder (empty or new); a remote workspace needs only a remote path, and that directory must already exist — the plugin never creates it.
|
|
36
36
|
4. **Open the sidebar**: on the right sidebar start page choose “Linked Workspace Directory” or “Remote Workspace Directory”.
|
|
37
37
|
5. **Edit**: single-click a file to preview it, double-click to pin the tab; `Ctrl/Cmd + S` saves.
|
|
@@ -40,7 +40,7 @@ Turn an existing SSH connection into a **linked workspace** or a **remote worksp
|
|
|
40
40
|
|
|
41
41
|
### Settings → Linked workspaces
|
|
42
42
|
|
|
43
|
-
- SSH hosts come from the `dsh-ssh-tunnel` SSH Manager (`~/.dsh/ssh-tunnel/hosts.json
|
|
43
|
+
- SSH hosts come from the `dsh-ssh-tunnel` SSH Manager (`~/.dsh/ssh-tunnel/hosts.json`, optional) and `~/.ssh/config`; passwords and keys from either source stay inside the Host process and are never returned to the page or the model. Without the SSH Manager, the plugin stores a password on this machine itself (see “SSH credentials” under Configuration).
|
|
44
44
|
- Remote workspace list: each card shows “remote · user@host + remote path” and the local placeholder directory, with **open workspace**, **open directory tree**, **test connection**, **rename** (renames the DSH workspace too) and **remove** (two-step confirmation; deletes the record, the placeholder directory and the DSH workspace, never remote files).
|
|
45
45
|
- Linked workspace list: local ⇄ remote paths, mirror toggle (**off by default**), background sync (archive into `.remote`, with file/byte progress and cancel), remove (optionally remove the DSH workspace and delete `.local`/`.remote`). With the mirror on, the first check runs immediately and then **every 5 minutes**: new or changed remote files are downloaded, mirror files that no longer exist remotely are deleted, unchanged files are skipped via `.local/mirror-manifest.json`, and `.git`/`node_modules`/cache directories are excluded. With the mirror off the two sides may diverge freely.
|
|
46
46
|
- A linked record without a DSH workspace shows “Register workspace” in its settings card, which registers it without recreating the record.
|
|
@@ -165,6 +165,8 @@ The npm package is `dsh-linked-workspace`; released versions can also be install
|
|
|
165
165
|
- **Python interpreter**: `DSH_OFFICE_PYTHON` for Office/PDF operations.
|
|
166
166
|
- **Terminal**: `DSH_LINKED_WORKSPACE_NO_TERMINAL=1` keeps “Open terminal” from launching a real window (used in tests).
|
|
167
167
|
- **SSH**: aliases from `~/.ssh/config` appear in the host list; host fingerprints are stored in the plugin data directory.
|
|
168
|
+
- **SSH credentials**: there are three sources — `IdentityFile` in `~/.ssh/config` (plus the SSH agent), the `dsh-ssh-tunnel` SSH Manager when installed, and the plugin's own `$DSH_HOME/linked-workspace/ssh-credentials.json`. A host with no key shows “Password needed” in the “Add workspace” dialog: pick it, type the password once, then “Create”. The password is written only to that file on this machine (mode `0600`) and read only by the Host process; it is never returned to the page or the model. Later workspaces can leave the field empty to reuse it. **Check password** probes a connection first and reports either “Password works” or the server's own reason (e.g. `All configured authentication methods failed.`); `hosts.credentials` with `clear: true` removes the secret.
|
|
169
|
+
- **A new feature reports `unknown method` after upgrading**: the Host process is still running older code (the page hot-reloads, the Host does not). Quit DSH completely and start it again.
|
|
168
170
|
|
|
169
171
|
## Upgrading and versions
|
|
170
172
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
## 环境要求
|
|
24
24
|
|
|
25
25
|
- **DSH**:0.2.1-rc.4 或更高(`engines` 允许 `>=0.2.0-rc.2 <0.3.0-0`)。
|
|
26
|
-
- **SSH
|
|
26
|
+
- **SSH**:主机写在 `~/.ssh/config`,或加入 DSH 的 SSH Manager(`dsh-ssh-tunnel`,可选)。裸 `~/.ssh/config` 也够用:插件自带 SSH 客户端,首次连接**自动信任并记录**主机指纹到 `$DSH_HOME/linked-workspace/known_hosts.json`,指纹变化时拒绝连接并提示删除对应条目。**不安装 `dsh-ssh-tunnel` 也能用**:没有 `IdentityFile` 的主机可在这个插件的「添加工作区」弹窗里填一次密码,密码保存在本机(见「配置 → SSH 凭据」)。
|
|
27
27
|
- **dsh-better-sidebar**(可选):`>=0.24.0`。装上才有右侧栏目录页与文件编辑页;缺少时其余功能(设置页、目录选择、模型工具)照常可用。
|
|
28
28
|
- **文档编辑**(可选):Python 3 及 `python-docx`、`openpyxl`、`python-pptx`、`PyMuPDF`;可用 `DSH_OFFICE_PYTHON` 指定解释器。Markdown 不需要 Python。
|
|
29
29
|
- **开发**:Node.js ≥ 20。
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
## 快速开始
|
|
32
32
|
|
|
33
33
|
1. **安装插件**(见[安装](#安装)),重启 DSH 客户端。
|
|
34
|
-
2. **添加工作区**:设置 → 联动工作区 →「创建联动工作区」或「创建远程工作区」,选择已有 SSH
|
|
34
|
+
2. **添加工作区**:设置 → 联动工作区 →「创建联动工作区」或「创建远程工作区」,选择已有 SSH 主机;列表里没有就把主机写进 `~/.ssh/config`(或在 DSH 的 SSH Manager 里添加),然后点「刷新」。
|
|
35
35
|
3. **选目录**:联动工作区需选远端路径和本地目录;远程工作区只需选远端路径(该目录必须已存在,插件不会自动创建)。
|
|
36
36
|
4. **打开右侧栏**:会话右侧栏开始页点「联动工作区目录」(联动)或「远程工作区目录」(远程)。
|
|
37
37
|
5. **开始编辑**:单击文件打开预览,双击固定标签;`Ctrl/Cmd + S` 保存。
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
### 连接与设置(设置 → 联动工作区)
|
|
42
42
|
|
|
43
|
-
- SSH 主机来自 `dsh-ssh-tunnel` 的 SSH Manager(`~/.dsh/ssh-tunnel/hosts.json
|
|
43
|
+
- SSH 主机来自 `dsh-ssh-tunnel` 的 SSH Manager(`~/.dsh/ssh-tunnel/hosts.json`,可选),也支持 `~/.ssh/config`;两者的密码/私钥只在 Host 进程内使用,永不返回给页面或模型。没有安装 SSH Manager 时,插件会自己在本机保存密码(见「配置 → SSH 凭据」)。
|
|
44
44
|
- **联动工作区**列表:本地 ⇄ 远端路径、镜像开关(**默认关闭**)、后台同步(归档到 `.remote`,显示文件数/体积进度,可取消)、移除(可选同时移除 DSH 工作区、删除 `.local`/`.remote`)。开启镜像后首次立即检查,之后**每 5 分钟**自动比较远端与 `.remote`:下载新增/变更文件、删除远端已不存在的镜像文件、跳过未变更文件(`.local/mirror-manifest.json`),并排除 `.git`/`node_modules`/缓存目录;关闭镜像时允许两侧存在版本和文件差异。
|
|
45
45
|
- **远程工作区**列表:每张卡片显示「远端 · 用户名@主机 + 远端路径」和「本地占位目录」,提供**打开工作区**(切到该 DSH 工作区)、**打开目录树**、**测试连接**、**重命名**(同步改名 DSH 工作区)、**移除远程工作区**(两步确认;同时删除占位目录和 DSH workspace 注册,不动远端文件)。
|
|
46
46
|
- 联动记录若没有对应的 DSH 工作区,设置卡会显示「注册为工作区」,点击即可补注册,无需删除重建。
|
|
@@ -165,6 +165,8 @@ npm 包名为 `dsh-linked-workspace`,也可以从 npm 安装已发布版本(
|
|
|
165
165
|
- **Python 解释器**:`DSH_OFFICE_PYTHON` 指定用于 Office/PDF 的 Python。
|
|
166
166
|
- **终端**:`DSH_LINKED_WORKSPACE_NO_TERMINAL=1` 关闭「打开终端」的实际启动(测试环境用)。
|
|
167
167
|
- **SSH 配置**:`~/.ssh/config` 中的别名会出现在主机列表;主机指纹保存在插件数据目录。
|
|
168
|
+
- **SSH 凭据**:主机列表的凭据来源有三处——`~/.ssh/config` 的 `IdentityFile`(含 SSH agent)、`dsh-ssh-tunnel` 的 SSH Manager(若已安装),以及插件自己的 `$DSH_HOME/linked-workspace/ssh-credentials.json`。没有私钥的主机在「添加工作区」弹窗里显示「需要密码」,选它、填一次密码再点「创建」即可:密码只写在本机这个文件里(权限 `0600`),只由 Host 进程读取,不会返回给页面或模型;之后再建工作区留空即沿用已存密码。填完可点「**验证密码**」先探一条连接,成功显示「密码可用」,失败直接给出服务器原话(例如 `All configured authentication methods failed.`)。用 `hosts.credentials` 的 `clear: true` 可以删除。
|
|
169
|
+
- **升级后某个新功能报 `unknown method`**:说明 Host 进程还在跑旧代码(页面会热更新、Host 不会)。完全退出 DSH 再启动即可。
|
|
168
170
|
|
|
169
171
|
## 升级与版本
|
|
170
172
|
|
package/docs/API.md
CHANGED
|
@@ -51,7 +51,8 @@ scope root, or absolute inside it.
|
|
|
51
51
|
|
|
52
52
|
| method | params | data |
|
|
53
53
|
| --- | --- | --- |
|
|
54
|
-
| `hosts.list` | `{ refresh? }` | `{ hosts: HostInfo[] }` |
|
|
54
|
+
| `hosts.list` | `{ refresh? }` | `{ hosts: HostInfo[] }` (`HostInfo` carries `authType`, `hasCredential`, `hasStoredPassword`) |
|
|
55
|
+
| `hosts.credentials` | `{ hostId, password?, passphrase?, privateKey?, clear? }` | `{ hostId, authType, hasCredential, hasStoredPassword }` (stores the secret in the plugin's own `ssh-credentials.json`; `clear: true` deletes it) |
|
|
55
56
|
| `hosts.browse` | `{ hostId, path? }` | `{ path, parent, home, entries }` (dirs + files) |
|
|
56
57
|
| `remote_workspaces.list` | `{}` | `{ workspaces: RemoteWorkspaceInfo[] }` |
|
|
57
58
|
| `remote_workspaces.create` | `{ hostId, remotePath, name? }` | `{ workspace }` |
|
|
@@ -125,6 +126,10 @@ Under `$DSH_HOME/linked-workspace/`:
|
|
|
125
126
|
- `remote-workspaces.json` — remote workspaces (no credentials).
|
|
126
127
|
- `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave }`.
|
|
127
128
|
- `known_hosts.json` — trust-on-first-use host key fingerprints.
|
|
129
|
+
- `ssh-credentials.json` — `{ version, byHostId: { <hostId>: { password?, privateKey?, passphrase? } } }`,
|
|
130
|
+
written by `hosts.credentials` with mode `0600`. Hosts listed in `~/.ssh/config`
|
|
131
|
+
without an `IdentityFile` can be paired with a password here, so the plugin does
|
|
132
|
+
not need `dsh-ssh-tunnel` for password logins.
|
|
128
133
|
- `remote-placeholders/<uuid>/` — placeholder directories for remote workspaces.
|
|
129
134
|
- Local linked directories also hold `.local/linked.json` (same binding without
|
|
130
135
|
secrets) and the optional `.remote/` mirror.
|
package/docs/VERIFY.md
CHANGED
|
@@ -5,7 +5,7 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
|
|
|
5
5
|
## 设置 → 联动工作区
|
|
6
6
|
|
|
7
7
|
1. 左下角「账号菜单」→ 设置 →「联动工作区」。
|
|
8
|
-
2. 页面:标题「联动&远程工作区」、编辑器主题卡片(10
|
|
8
|
+
2. 页面:标题「联动&远程工作区」、编辑器主题卡片(10 套,点击立即切换,编辑器配色跟随)、联动工作区组、**远程工作区组**;左侧导航里的本项图标是层叠纸张(不是齿轮)。
|
|
9
9
|
3. 创建远程工作区:选 `RTX-PRO-6000-1`,路径 `/shared_data_ssd1/huangjh/code` → 卡片出现(`[远程] [已连接]`、远端路径、本地占位目录);「测试连接」显示「连接正常」。
|
|
10
10
|
4. 添加联动工作区:
|
|
11
11
|
- SSH 连接 + 远端目录(浏览),本地目录(浏览/新建文件夹/系统选择器),镜像可选,名称可选;
|
|
@@ -44,6 +44,17 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
|
|
|
44
44
|
4. **没有 dsh-better-sidebar 时仍能运行**:停用 `dsh-better-sidebar` 后重启客户端——插件仍加载(设置 → 联动工作区 可正常打开与创建/移除工作区)、「添加工作区」弹窗可用、会话里 `linked_workspace` 工具可用;控制台不再出现因缺少 `betterSidebar` 服务而抛出的错误,右侧栏也不出现本插件的目录页。
|
|
45
45
|
5. **插件显示名**:插件市场列表中本插件显示为「联动与远程工作区」(英文 `Linked & Remote Workspaces`)。
|
|
46
46
|
|
|
47
|
+
## 本机 SSH 凭据(0.12.0)
|
|
48
|
+
|
|
49
|
+
1. **没有私钥的主机不再置灰**:在 `~/.ssh/config` 里写一个没有 `IdentityFile` 的 Host(例如 `Host demo` / `HostName 10.9.9.9` / `User dev`),重启后「添加工作区」弹窗里该主机可点选,右侧 chip 显示「需要密码」,主机列表下方出现「SSH 密码」输入框与「密码只保存在本机…不需要安装 SSH Manager 插件」的提示。
|
|
50
|
+
2. **保存后立即生效**:填入任意密码点「创建」(远端目录不可达时创建会失败,但凭据已写入)——该主机 chip 变回 `~/.ssh/config`,hint 变「已保存密码。想更换就重新输入,留空则继续使用原密码。」;`$DSH_HOME/linked-workspace/ssh-credentials.json` 出现 `{"version":1,"byHostId":{"sshconfig:demo":{"password":"…"}}}`,权限 `0600`。
|
|
51
|
+
2b. **验证密码按钮**:填一个错误密码点「验证密码」→ 输入框下方出现红字「验证失败:SSH 认证失败,请检查主机凭据:… All configured authentication methods failed.」;填对后显示绿色「密码可用,可以继续创建。」。
|
|
52
|
+
3. **主机状态跟着变**:`hosts.list` 里该主机 `authType` 从 `agent` 变 `password`、`hasCredential` 与 `hasStoredPassword` 均为 `true`;再连会进入真实网络(错误是连接层面的 `SSH_CONNECT`,而不是「没有密码」)。
|
|
53
|
+
4. **清除**:`hosts.credentials` 传 `{ hostId, clear: true }` → 返回 `authType: 'agent'`、`hasCredential: false`,文件里的条目被删掉,弹窗里又显示「需要密码」。
|
|
54
|
+
5. **不装 dsh-ssh-tunnel 也照常**:没有 SSH Manager 时上述流程全部可用;`identityFile` 与 agent 的主机行为不变,仍显示 `~/.ssh/config`。
|
|
55
|
+
6. **不影响已有的密钥主机**:`~/.ssh/config` 里带 `IdentityFile` 的主机 `authType` 仍是 `privateKey`、`hasCredential` 仍为 `true`。
|
|
56
|
+
7. **弹窗内滚轮只滚弹窗**:主机多到出现滚动条时(≥6 台),把鼠标放在 SSH 主机列表上滚动滚轮 → 列表先滚;到底后继续滚 → 表单滚;全程背后会话区域不滚动。鼠标放到弹窗遮罩上滚动也一样,背后页面不动。
|
|
57
|
+
|
|
47
58
|
## 工作区图标与连接状态(0.11.0)
|
|
48
59
|
|
|
49
60
|
1. **图标区分**:左侧栏工作区行、侧栏「+」菜单、目录树工作区 chip 与分组头、设置页卡片与两个创建按钮、「添加工作区」弹窗三个页签——联动工作区统一是「双链环」,远程工作区统一是「显示器 + 出链箭头」,本地工作区仍是文件夹。
|
package/lib/client.js
CHANGED
|
@@ -2261,6 +2261,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
2261
2261
|
sheetTruncated: '仅显示前 {{rows}} 行 × {{cols}} 列',
|
|
2262
2262
|
sheetMore: '工作表较多,仅显示前 20 个',
|
|
2263
2263
|
noCredential: '缺少凭据',
|
|
2264
|
+
needPassword: '需要密码',
|
|
2265
|
+
sshPassword: 'SSH 密码',
|
|
2266
|
+
sshPasswordPlaceholder: '输入这台主机的密码',
|
|
2267
|
+
sshPasswordHint: '密码只保存在本机(DSH 数据目录的 ssh-credentials.json),只有本插件读取;不需要安装 SSH Manager 插件。',
|
|
2268
|
+
sshPasswordStored: '已保存密码,留空则保持不变',
|
|
2269
|
+
sshPasswordStoredHint: '已保存密码。想更换就重新输入,留空则继续使用原密码。',
|
|
2270
|
+
sshPasswordRequired: '请先在下面填写这台 SSH 主机的密码',
|
|
2271
|
+
sshVerify: '验证密码',
|
|
2272
|
+
sshVerifying: '验证中…',
|
|
2273
|
+
sshPasswordOk: '密码可用,可以继续创建。',
|
|
2274
|
+
sshPasswordFailed: '验证失败:',
|
|
2275
|
+
staleHost: 'DSH 的插件进程仍在运行旧版代码,请完全退出并重启 DSH 后再试',
|
|
2264
2276
|
sourceManagerShort: 'SSH',
|
|
2265
2277
|
linkedGroup: '联动工作区',
|
|
2266
2278
|
linkedEmpty: '还没有联动工作区。联动工作区会把本地目录与远端目录配对,会话可直接编辑远端文件。',
|
|
@@ -2666,6 +2678,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
2666
2678
|
sheetTruncated: 'Showing the first {{rows}} rows × {{cols}} columns',
|
|
2667
2679
|
sheetMore: 'Showing the first 20 worksheets only',
|
|
2668
2680
|
noCredential: 'No credentials',
|
|
2681
|
+
needPassword: 'Password needed',
|
|
2682
|
+
sshPassword: 'SSH password',
|
|
2683
|
+
sshPasswordPlaceholder: 'Enter the password for this host',
|
|
2684
|
+
sshPasswordHint: 'Stored on this machine only (ssh-credentials.json in the DSH data directory) and read by this plugin. The SSH Manager plugin is not required.',
|
|
2685
|
+
sshPasswordStored: 'Password stored — leave empty to keep it',
|
|
2686
|
+
sshPasswordStoredHint: 'A password is already stored. Type a new one to replace it, or leave empty to keep it.',
|
|
2687
|
+
sshPasswordRequired: 'Enter the password for this SSH host below first',
|
|
2688
|
+
sshVerify: 'Check password',
|
|
2689
|
+
sshVerifying: 'Checking…',
|
|
2690
|
+
sshPasswordOk: 'The password works — you can create the workspace now.',
|
|
2691
|
+
sshPasswordFailed: 'Check failed:',
|
|
2692
|
+
staleHost: 'The plugin host is still running older code; quit and restart DSH, then retry',
|
|
2669
2693
|
sourceManagerShort: 'SSH',
|
|
2670
2694
|
linkedGroup: 'Linked workspaces',
|
|
2671
2695
|
linkedEmpty: 'No linked workspaces yet. A linked workspace pairs a local folder with a remote folder so sessions can edit remote files directly.',
|
|
@@ -3038,9 +3062,19 @@ function attributeViolation(name, value, tagName) {
|
|
|
3038
3062
|
|
|
3039
3063
|
function messageOf(error, t, locale) {
|
|
3040
3064
|
if (!error) return '';
|
|
3065
|
+
// `unknown method` means the page is newer than the Host process: the
|
|
3066
|
+
// plugin's server half only changes on restart.
|
|
3067
|
+
if (typeof error.message === 'string' && error.message.indexOf('unknown method:') === 0) {
|
|
3068
|
+
return t('staleHost') + ' (' + error.message + ')';
|
|
3069
|
+
}
|
|
3041
3070
|
var known = error.code ? (locale === 'zh' ? CODE_TEXT.zh : CODE_TEXT.en)[error.code] : '';
|
|
3042
|
-
if (known) return error.
|
|
3043
|
-
|
|
3071
|
+
if (!known) return error.message || String(error);
|
|
3072
|
+
if (error.code === 'BAD_REQUEST' && error.message) return error.message;
|
|
3073
|
+
// Keep the server's own wording: "All configured authentication methods
|
|
3074
|
+
// failed" tells the user far more than the generic code text alone.
|
|
3075
|
+
var detail = typeof error.message === 'string' ? error.message.trim() : '';
|
|
3076
|
+
if (!detail || detail === known) return known;
|
|
3077
|
+
return known + (locale === 'zh' ? ':' : ': ') + detail;
|
|
3044
3078
|
}
|
|
3045
3079
|
|
|
3046
3080
|
function documentKindOf(path) {
|
|
@@ -3648,6 +3682,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
3648
3682
|
'M262.4 224h243.2a38.4 38.4 0 1 1 0 76.8H351.808L586.24 535.168a38.4 38.4 0 0 1 4.032 49.536l-4.032 4.736-4.736 4.032a38.4 38.4 0 0 1-49.6-4.032L300.8 358.272 300.8 505.6a38.4 38.4 0 0 1-76.8 0V262.4a38.4 38.4 0 0 1 38.4-38.4z',
|
|
3649
3683
|
];
|
|
3650
3684
|
|
|
3685
|
+
// Settings-nav glyph: a stack of sheets (the linked / remote pairing sits on
|
|
3686
|
+
// top of the plain local workspace). Registered through the host's
|
|
3687
|
+
// `settings.section.icon` seat so the settings list shows it instead of the
|
|
3688
|
+
// default gear.
|
|
3689
|
+
var SETTINGS_ICON_PATHS = [
|
|
3690
|
+
'M20.66204445 509.34044445l475.70488888 256.27306667A35.10044445 35.10044445 0 0 0 542.72 753.6896a31.07271111 31.07271111 0 0 0-10.71786667-42.60977778c-0.63715555-0.38684445-1.29706667-0.73955555-1.96835555-1.08088888L54.35164445 453.72586667a35.11182222 35.11182222 0 0 0-46.31893334 11.91253333 31.08408889 31.08408889 0 0 0 10.68373334 42.63253334c0.62577778 0.37546667 1.28568889 0.73955555 1.9456 1.06951111z',
|
|
3691
|
+
'M972.07182222 453.72586667l-475.70488889 256.27306667a31.07271111 31.07271111 0 0 0-13.65333333 41.75644444c0.34133333 0.65991111 0.69404445 1.30844445 1.06951111 1.93422222 9.29564445 15.38275555 30.04871111 20.69617778 46.31893334 11.92391112L1005.79555555 509.34044445a31.07271111 31.07271111 0 0 0 13.76711112-41.73368889c-0.32995555-0.67128889-0.69404445-1.31982222-1.13777778-1.96835556a35.10044445 35.10044445 0 0 0-46.35306667-11.91253333z',
|
|
3692
|
+
'M20.66204445 701.54524445l475.70488888 256.27306667A35.10044445 35.10044445 0 0 0 542.72 945.84888889a31.07271111 31.07271111 0 0 0-10.71786667-42.60977777c-0.63715555-0.38684445-1.29706667-0.75093333-1.96835555-1.13777778L54.35164445 645.93066667a35.11182222 35.11182222 0 0 0-46.31893334 11.91253333 31.08408889 31.08408889 0 0 0 10.68373334 42.63253334c0.62577778 0.37546667 1.28568889 0.75093333 1.9456 1.06951111z',
|
|
3693
|
+
'M972.07182222 645.93066667l-475.70488889 256.27306667a31.07271111 31.07271111 0 0 0-13.65333333 41.75644444c0.34133333 0.65991111 0.69404445 1.30844445 1.06951111 1.93422222 9.29564445 15.38275555 30.04871111 20.69617778 46.31893334 11.92391112L1005.79555555 701.54524445a31.07271111 31.07271111 0 0 0 13.76711112-41.73368889c-0.32995555-0.67128889-0.69404445-1.31982222-1.13777778-1.96835556a35.10044445 35.10044445 0 0 0-46.35306667-11.91253333z',
|
|
3694
|
+
'M500.62222222 122.496L142.32462222 291.62666667 512 509.34044445l357.48977778-196.36906667z m3.77742223-70.54222222l483.04355555 249.42364444a13.75573333 13.75573333 0 0 1 6.53084445 17.80622223 12.12871111 12.12871111 0 0 1-5.12 5.50684444L520.64711111 581.76a13.23235555 13.23235555 0 0 1-13.07306666-0.38684444L23.54062222 296.24604445a13.65333333 13.65333333 0 0 1-5.44995555-18.20444445 12.25386667 12.25386667 0 0 1 5.44995555-5.13137778l469.17404445-221.27502222a13.18684445 13.18684445 0 0 1 11.71911111 0.31857778z',
|
|
3695
|
+
];
|
|
3696
|
+
|
|
3651
3697
|
var ICON_DISCONNECTED_COLOR = '#f85149';
|
|
3652
3698
|
var ICON_BUSY_COLOR = '#2f81f7';
|
|
3653
3699
|
|
|
@@ -3923,6 +3969,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
3923
3969
|
return solidIcon(size || 14, REMOTE_ICON_PATHS);
|
|
3924
3970
|
}
|
|
3925
3971
|
|
|
3972
|
+
function IconSettingsNav(size) {
|
|
3973
|
+
return solidIcon(size || 16, SETTINGS_ICON_PATHS);
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3926
3976
|
function IconChevron(size) {
|
|
3927
3977
|
return svg(size || 14, h('path', {
|
|
3928
3978
|
d: 'm6 3 5 5-5 5', stroke: 'currentColor', strokeWidth: 1.6,
|
|
@@ -8036,10 +8086,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
8036
8086
|
type: 'button',
|
|
8037
8087
|
role: 'option',
|
|
8038
8088
|
'aria-selected': on,
|
|
8039
|
-
|
|
8040
|
-
title: usable ? host.name : t('noCredential'),
|
|
8089
|
+
title: host.name,
|
|
8041
8090
|
className: 'rw-host' + (on ? ' is-on' : ''),
|
|
8042
|
-
onClick: function () { if (
|
|
8091
|
+
onClick: function () { if (props.onSelect) props.onSelect(host); },
|
|
8043
8092
|
},
|
|
8044
8093
|
h('span', { className: 'rw-file-icon', style: { color: on ? 'var(--dsw-alias-brand-primary)' : undefined } }, IconServer(16)),
|
|
8045
8094
|
h('span', { className: 'rw-host-main' },
|
|
@@ -8047,12 +8096,74 @@ function attributeViolation(name, value, tagName) {
|
|
|
8047
8096
|
h('span', { className: 'rw-host-meta' }, host.username + '@' + host.host + ':' + host.port)),
|
|
8048
8097
|
usable
|
|
8049
8098
|
? h('span', { className: 'rw-chip' }, host.source === 'ssh-config' ? t('sourceConfig') : t('sourceManager'))
|
|
8050
|
-
: h('span', { className: 'rw-chip', style: { color: 'var(--dsw-alias-state-warn-primary)' } }, t('
|
|
8099
|
+
: h('span', { className: 'rw-chip', style: { color: 'var(--dsw-alias-state-warn-primary)' } }, t('needPassword')));
|
|
8051
8100
|
}));
|
|
8052
8101
|
}
|
|
8053
8102
|
|
|
8054
|
-
|
|
8055
|
-
|
|
8103
|
+
// Password field for a host that has no usable key. The plugin keeps the
|
|
8104
|
+
// secret itself, so this works without the optional `dsh-ssh-tunnel` plugin.
|
|
8105
|
+
function SshCredentialField(props) {
|
|
8106
|
+
var t = props.t;
|
|
8107
|
+
var host = props.host;
|
|
8108
|
+
if (!host) return null;
|
|
8109
|
+
var stored = host.hasStoredPassword === true;
|
|
8110
|
+
var needed = host.hasCredential === false || host.authType === 'password';
|
|
8111
|
+
if (!needed && !stored) return null;
|
|
8112
|
+
var checkState = useState({ busy: false, ok: false, message: '' });
|
|
8113
|
+
var check = checkState[0];
|
|
8114
|
+
var setCheck = checkState[1];
|
|
8115
|
+
var inputRef = useRef(null);
|
|
8116
|
+
// Selecting a host that still needs a secret should put the cursor in the
|
|
8117
|
+
// password box, so the dialog asks for it instead of leaving the user to
|
|
8118
|
+
// find the field.
|
|
8119
|
+
useEffect(function () {
|
|
8120
|
+
if (!needed && !stored) return;
|
|
8121
|
+
var node = inputRef.current;
|
|
8122
|
+
if (node && typeof node.focus === 'function') node.focus();
|
|
8123
|
+
}, [host.id, needed, stored]);
|
|
8124
|
+
function verify() {
|
|
8125
|
+
if (check.busy || props.busy) return;
|
|
8126
|
+
var value = props.value || '';
|
|
8127
|
+
if (value === '') { setCheck({ busy: false, ok: false, message: t('sshPasswordRequired') }); return; }
|
|
8128
|
+
setCheck({ busy: true, ok: false, message: '' });
|
|
8129
|
+
apiCall('hosts.credentials', { hostId: host.id, password: value })
|
|
8130
|
+
.then(function () { return apiCall('hosts.browse', { hostId: host.id, path: '' }); })
|
|
8131
|
+
.then(function () {
|
|
8132
|
+
setCheck({ busy: false, ok: true, message: t('sshPasswordOk') });
|
|
8133
|
+
if (props.onVerified) props.onVerified();
|
|
8134
|
+
})
|
|
8135
|
+
.catch(function (err) {
|
|
8136
|
+
setCheck({ busy: false, ok: false, message: t('sshPasswordFailed') + ' ' + messageOf(err, t, props.locale) });
|
|
8137
|
+
if (props.onVerified) props.onVerified();
|
|
8138
|
+
});
|
|
8139
|
+
}
|
|
8140
|
+
return h('div', { className: 'rw-field' },
|
|
8141
|
+
h('div', { className: 'rw-label' }, t('sshPassword')),
|
|
8142
|
+
h('div', { className: 'rw-inline' },
|
|
8143
|
+
h('input', {
|
|
8144
|
+
className: 'rw-input',
|
|
8145
|
+
type: 'password',
|
|
8146
|
+
ref: inputRef,
|
|
8147
|
+
value: props.value || '',
|
|
8148
|
+
placeholder: stored ? t('sshPasswordStored') : t('sshPasswordPlaceholder'),
|
|
8149
|
+
autoComplete: 'new-password',
|
|
8150
|
+
spellCheck: false,
|
|
8151
|
+
disabled: props.busy,
|
|
8152
|
+
onChange: function (event) { props.onChange(event.currentTarget.value); },
|
|
8153
|
+
onKeyDown: function (event) { if (event.key === 'Enter' && props.onSubmit) props.onSubmit(); },
|
|
8154
|
+
}),
|
|
8155
|
+
h('button', {
|
|
8156
|
+
type: 'button',
|
|
8157
|
+
className: 'rw-btn rw-btn-sm',
|
|
8158
|
+
disabled: check.busy || props.busy,
|
|
8159
|
+
onClick: verify,
|
|
8160
|
+
}, check.busy ? t('sshVerifying') : t('sshVerify'))),
|
|
8161
|
+
check.message
|
|
8162
|
+
? h('div', { className: 'rw-hint', style: check.ok ? { color: '#3fb950' } : { color: '#f85149' } }, check.message)
|
|
8163
|
+
: h('div', { className: 'rw-hint' }, needed && !stored ? t('sshPasswordHint') : t('sshPasswordStoredHint')));
|
|
8164
|
+
}
|
|
8165
|
+
|
|
8166
|
+
function AddWorkspaceFlow(props) { var ctx = props.ctx;
|
|
8056
8167
|
var t = props.t;
|
|
8057
8168
|
var locale = props.locale;
|
|
8058
8169
|
var onDone = props.onDone;
|
|
@@ -8088,6 +8199,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
8088
8199
|
var localOpenState = useState(false);
|
|
8089
8200
|
var localOpen = localOpenState[0];
|
|
8090
8201
|
var setLocalOpen = localOpenState[1];
|
|
8202
|
+
var passwordState = useState('');
|
|
8203
|
+
var password = passwordState[0];
|
|
8204
|
+
var setPassword = passwordState[1];
|
|
8091
8205
|
|
|
8092
8206
|
var loadHosts = useCallback(function () {
|
|
8093
8207
|
setHostData(function (previous) { return { loading: previous.hosts.length === 0, hosts: previous.hosts, error: null }; });
|
|
@@ -8106,6 +8220,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8106
8220
|
|
|
8107
8221
|
function chooseHost(host) {
|
|
8108
8222
|
setSelectedHostId(host.id);
|
|
8223
|
+
setPassword('');
|
|
8109
8224
|
setError('');
|
|
8110
8225
|
setRemoteOpen(false);
|
|
8111
8226
|
if (remotePath.trim() === '' && host && host.hasCredential !== false) {
|
|
@@ -8115,6 +8230,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
8115
8230
|
}
|
|
8116
8231
|
}
|
|
8117
8232
|
|
|
8233
|
+
function selectedHost() {
|
|
8234
|
+
return hostData.hosts.filter(function (item) { return item.id === selectedHostId; })[0] || null;
|
|
8235
|
+
}
|
|
8236
|
+
|
|
8237
|
+
function needsPassword(host) {
|
|
8238
|
+
if (!host) return false;
|
|
8239
|
+
if (host.hasCredential === false) return true;
|
|
8240
|
+
return host.authType === 'password' && host.hasStoredPassword !== true;
|
|
8241
|
+
}
|
|
8242
|
+
|
|
8118
8243
|
function submit() {
|
|
8119
8244
|
if (busy) return;
|
|
8120
8245
|
if (!selectedHostId) { setError(t('stepHost')); return; }
|
|
@@ -8122,14 +8247,21 @@ function attributeViolation(name, value, tagName) {
|
|
|
8122
8247
|
if (trimmedRemote === '') { setError(t('stepPath')); return; }
|
|
8123
8248
|
var trimmedLocal = localPath.trim();
|
|
8124
8249
|
if (trimmedLocal === '') { setBusy(false); setError(t('stepLocalPath')); return; }
|
|
8250
|
+
var typedPassword = password;
|
|
8251
|
+
if (needsPassword(selectedHost()) && typedPassword === '') { setError(t('sshPasswordRequired')); return; }
|
|
8125
8252
|
setBusy(true);
|
|
8126
8253
|
setError('');
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8254
|
+
var stored = typedPassword === ''
|
|
8255
|
+
? Promise.resolve()
|
|
8256
|
+
: apiCall('hosts.credentials', { hostId: selectedHostId, password: typedPassword }).then(loadHosts);
|
|
8257
|
+
stored.then(function () {
|
|
8258
|
+
return apiCall('linked.create', {
|
|
8259
|
+
hostId: selectedHostId,
|
|
8260
|
+
remotePath: trimmedRemote,
|
|
8261
|
+
localPath: trimmedLocal,
|
|
8262
|
+
name: name.trim(),
|
|
8263
|
+
mirror: mirror,
|
|
8264
|
+
});
|
|
8133
8265
|
}).then(function () {
|
|
8134
8266
|
setBusy(false);
|
|
8135
8267
|
bus.emit();
|
|
@@ -8149,6 +8281,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
8149
8281
|
h('div', { className: 'rw-label' }, t('stepHost')),
|
|
8150
8282
|
h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
|
|
8151
8283
|
hostData.error ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(hostData.error, t, locale)) : null),
|
|
8284
|
+
h(SshCredentialField, {
|
|
8285
|
+
t: t, locale: locale, host: selectedHost(), value: password, busy: busy,
|
|
8286
|
+
onChange: setPassword, onSubmit: submit, onVerified: loadHosts,
|
|
8287
|
+
}),
|
|
8152
8288
|
h('div', { className: 'rw-field' },
|
|
8153
8289
|
h('div', { className: 'rw-label' }, t('stepPath')),
|
|
8154
8290
|
h('div', { className: 'rw-input-row' },
|
|
@@ -8250,6 +8386,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
8250
8386
|
var remoteOpenState = useState(false);
|
|
8251
8387
|
var remoteOpen = remoteOpenState[0];
|
|
8252
8388
|
var setRemoteOpen = remoteOpenState[1];
|
|
8389
|
+
var passwordState = useState('');
|
|
8390
|
+
var password = passwordState[0];
|
|
8391
|
+
var setPassword = passwordState[1];
|
|
8253
8392
|
|
|
8254
8393
|
var loadHosts = useCallback(function () {
|
|
8255
8394
|
setHostData(function (previous) { return { loading: previous.hosts.length === 0, hosts: previous.hosts, error: null }; });
|
|
@@ -8268,6 +8407,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8268
8407
|
|
|
8269
8408
|
function chooseHost(host) {
|
|
8270
8409
|
setSelectedHostId(host.id);
|
|
8410
|
+
setPassword('');
|
|
8271
8411
|
setError('');
|
|
8272
8412
|
setRemoteOpen(false);
|
|
8273
8413
|
if (remotePath.trim() === '' && host && host.hasCredential !== false) {
|
|
@@ -8277,17 +8417,34 @@ function attributeViolation(name, value, tagName) {
|
|
|
8277
8417
|
}
|
|
8278
8418
|
}
|
|
8279
8419
|
|
|
8420
|
+
function selectedHost() {
|
|
8421
|
+
return hostData.hosts.filter(function (item) { return item.id === selectedHostId; })[0] || null;
|
|
8422
|
+
}
|
|
8423
|
+
|
|
8424
|
+
function needsPassword(host) {
|
|
8425
|
+
if (!host) return false;
|
|
8426
|
+
if (host.hasCredential === false) return true;
|
|
8427
|
+
return host.authType === 'password' && host.hasStoredPassword !== true;
|
|
8428
|
+
}
|
|
8429
|
+
|
|
8280
8430
|
function submit() {
|
|
8281
8431
|
if (busy) return;
|
|
8282
8432
|
if (!selectedHostId) { setError(t('stepHost')); return; }
|
|
8283
8433
|
var trimmedRemote = remotePath.trim();
|
|
8284
8434
|
if (trimmedRemote === '') { setError(t('stepPath')); return; }
|
|
8435
|
+
var typedPassword = password;
|
|
8436
|
+
if (needsPassword(selectedHost()) && typedPassword === '') { setError(t('sshPasswordRequired')); return; }
|
|
8285
8437
|
setBusy(true);
|
|
8286
8438
|
setError('');
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8439
|
+
var stored = typedPassword === ''
|
|
8440
|
+
? Promise.resolve()
|
|
8441
|
+
: apiCall('hosts.credentials', { hostId: selectedHostId, password: typedPassword }).then(loadHosts);
|
|
8442
|
+
stored.then(function () {
|
|
8443
|
+
return apiCall('remote_workspaces.create', {
|
|
8444
|
+
hostId: selectedHostId,
|
|
8445
|
+
remotePath: trimmedRemote,
|
|
8446
|
+
name: name.trim(),
|
|
8447
|
+
});
|
|
8291
8448
|
}).then(function () {
|
|
8292
8449
|
setBusy(false);
|
|
8293
8450
|
bus.emit();
|
|
@@ -8308,6 +8465,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
8308
8465
|
h('div', { className: 'rw-label' }, t('stepHost')),
|
|
8309
8466
|
h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
|
|
8310
8467
|
hostData.error ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(hostData.error, t, locale)) : null),
|
|
8468
|
+
h(SshCredentialField, {
|
|
8469
|
+
t: t, locale: locale, host: selectedHost(), value: password, busy: busy,
|
|
8470
|
+
onChange: setPassword, onSubmit: submit, onVerified: loadHosts,
|
|
8471
|
+
}),
|
|
8311
8472
|
h('div', { className: 'rw-field' },
|
|
8312
8473
|
h('div', { className: 'rw-label' }, t('stepPath')),
|
|
8313
8474
|
h('div', { className: 'rw-input-row' },
|
|
@@ -8416,6 +8577,50 @@ function attributeViolation(name, value, tagName) {
|
|
|
8416
8577
|
if (target && typeof target.focus === 'function') target.focus();
|
|
8417
8578
|
}, [props.open, flow]);
|
|
8418
8579
|
|
|
8580
|
+
// The app shell listens for wheel gestures on the document root and moves
|
|
8581
|
+
// the conversation behind the dialog, so a wheel over the host list (or
|
|
8582
|
+
// anywhere else in the dialog) never reaches the dialog's own scroll
|
|
8583
|
+
// areas. Take the gesture in the capture phase: scroll the innermost
|
|
8584
|
+
// scrollable element inside the dialog, chain to the next one at the
|
|
8585
|
+
// edges, and never let the page behind move while the dialog is open.
|
|
8586
|
+
useEffect(function () {
|
|
8587
|
+
if (!props.open) return undefined;
|
|
8588
|
+
var node = modalRef.current;
|
|
8589
|
+
if (!node) return undefined;
|
|
8590
|
+
var overlay = node.closest ? (node.closest('.rw-modal-backdrop') || node) : node;
|
|
8591
|
+
|
|
8592
|
+
function firstScrollable(start) {
|
|
8593
|
+
var el = start;
|
|
8594
|
+
while (el && el !== overlay) {
|
|
8595
|
+
if (el.scrollHeight > el.clientHeight + 1) {
|
|
8596
|
+
var overflow = getComputedStyle(el).overflowY;
|
|
8597
|
+
if (overflow === 'auto' || overflow === 'scroll') return el;
|
|
8598
|
+
}
|
|
8599
|
+
el = el.parentElement;
|
|
8600
|
+
}
|
|
8601
|
+
return null;
|
|
8602
|
+
}
|
|
8603
|
+
|
|
8604
|
+
function onWheel(event) {
|
|
8605
|
+
if (!event.deltaY) return;
|
|
8606
|
+
if (!overlay.contains(event.target)) return;
|
|
8607
|
+
event.preventDefault();
|
|
8608
|
+
event.stopPropagation();
|
|
8609
|
+
if (event.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
8610
|
+
var step = event.deltaY * (event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? 400 : 1);
|
|
8611
|
+
var el = firstScrollable(event.target && event.target.nodeType === 1 ? event.target : overlay);
|
|
8612
|
+
while (el) {
|
|
8613
|
+
var before = el.scrollTop;
|
|
8614
|
+
el.scrollTop = before + step;
|
|
8615
|
+
if (el.scrollTop !== before) return;
|
|
8616
|
+
el = firstScrollable(el.parentElement);
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
|
|
8620
|
+
window.addEventListener('wheel', onWheel, { passive: false, capture: true });
|
|
8621
|
+
return function () { window.removeEventListener('wheel', onWheel, { capture: true }); };
|
|
8622
|
+
}, [props.open]);
|
|
8623
|
+
|
|
8419
8624
|
function onModalKeyDown(event) {
|
|
8420
8625
|
if (event.key === 'Escape') {
|
|
8421
8626
|
event.preventDefault();
|
|
@@ -9153,6 +9358,23 @@ function attributeViolation(name, value, tagName) {
|
|
|
9153
9358
|
};
|
|
9154
9359
|
}, 'dsh-linked-workspace: workspace row icons');
|
|
9155
9360
|
|
|
9361
|
+
// The settings list draws a default glyph unless a plugin claims the icon
|
|
9362
|
+
// seat; the id has to match the section id above.
|
|
9363
|
+
try {
|
|
9364
|
+
ctx.slots.inject('settings.section.icon', function () {
|
|
9365
|
+
return ctx.slots.register({
|
|
9366
|
+
name: 'settings.section.icon',
|
|
9367
|
+
id: 'linked-workspaces',
|
|
9368
|
+
order: 52,
|
|
9369
|
+
label: function () { return makeT(readLocale(ctx))('settingsNav'); },
|
|
9370
|
+
}, function (props) {
|
|
9371
|
+
return IconSettingsNav(props && props.size ? props.size : 16);
|
|
9372
|
+
});
|
|
9373
|
+
});
|
|
9374
|
+
} catch (error) {
|
|
9375
|
+
console.error('[dsh-linked-workspace] settings icon registration failed', error && error.message ? error.message : error);
|
|
9376
|
+
}
|
|
9377
|
+
|
|
9156
9378
|
try {
|
|
9157
9379
|
ctx.slots.inject('settings.section', function () {
|
|
9158
9380
|
return ctx.slots.register({
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import { mkdir, readdir, stat as fsStat } from 'node:fs/promises'
|
|
|
22
22
|
import { homedir, tmpdir } from 'node:os'
|
|
23
23
|
import { basename, dirname, extname, isAbsolute, join, posix, resolve, sep } from 'node:path'
|
|
24
24
|
import { fileURLToPath } from 'node:url'
|
|
25
|
-
import { listHosts, RemoteHost, SshError } from './ssh.js'
|
|
25
|
+
import { listHosts, RemoteHost, SshError, writeLocalCredential } from './ssh.js'
|
|
26
26
|
import * as linkedFs from './linked.js'
|
|
27
27
|
import * as git from './git.js'
|
|
28
28
|
|
|
@@ -754,8 +754,11 @@ function linkedManifestFor(record) {
|
|
|
754
754
|
// ── connection pool ─────────────────────────────────────────────────────────
|
|
755
755
|
|
|
756
756
|
class HostPool {
|
|
757
|
-
constructor({ knownHostsFile }) {
|
|
757
|
+
constructor({ knownHostsFile, credentialFile }) {
|
|
758
758
|
this.knownHostsFile = knownHostsFile
|
|
759
|
+
// Secrets the user stored from the add-workspace dialog. Kept apart from the
|
|
760
|
+
// SSH Manager so the plugin works without `dsh-ssh-tunnel`.
|
|
761
|
+
this.credentialFile = credentialFile || null
|
|
759
762
|
this.records = new Map() // hostId -> HostRecord
|
|
760
763
|
this.connections = new Map() // hostId -> { authority, remote: RemoteHost }
|
|
761
764
|
this.connecting = new Map() // hostId -> { authority, promise }
|
|
@@ -849,6 +852,7 @@ class HostPool {
|
|
|
849
852
|
const remote = new RemoteHost({
|
|
850
853
|
host: hostRecord,
|
|
851
854
|
knownHostsFile: this.knownHostsFile,
|
|
855
|
+
credentialFile: this.credentialFile,
|
|
852
856
|
connectTimeoutMs: CONNECT_TIMEOUT_MS,
|
|
853
857
|
logger: log,
|
|
854
858
|
onLost: (info) => this.noteConnectionLost(hostRecord.id, remote, info && info.reason),
|
|
@@ -906,7 +910,10 @@ export function apply(ctx) {
|
|
|
906
910
|
}
|
|
907
911
|
}
|
|
908
912
|
}
|
|
909
|
-
const pool = new HostPool({
|
|
913
|
+
const pool = new HostPool({
|
|
914
|
+
knownHostsFile: join(dir, 'known_hosts.json'),
|
|
915
|
+
credentialFile: join(dir, 'ssh-credentials.json'),
|
|
916
|
+
})
|
|
910
917
|
|
|
911
918
|
let hostsCache = null
|
|
912
919
|
let hostsRefreshedAt = 0
|
|
@@ -914,7 +921,7 @@ export function apply(ctx) {
|
|
|
914
921
|
const refreshHosts = async (force) => {
|
|
915
922
|
if (!force && hostsCache !== null && Date.now() - hostsRefreshedAt < 15_000) return hostsCache
|
|
916
923
|
try {
|
|
917
|
-
const hosts = await listHosts()
|
|
924
|
+
const hosts = await listHosts({ credentialFile: join(dir, 'ssh-credentials.json') })
|
|
918
925
|
hostsCache = hosts
|
|
919
926
|
hostsRefreshedAt = Date.now()
|
|
920
927
|
pool.setHosts(hosts)
|
|
@@ -1979,10 +1986,50 @@ export function apply(ctx) {
|
|
|
1979
1986
|
authType: host.authType,
|
|
1980
1987
|
source: host.source,
|
|
1981
1988
|
hasCredential: host.hasCredential,
|
|
1989
|
+
hasStoredPassword: Boolean(host.hasStoredPassword),
|
|
1982
1990
|
})),
|
|
1983
1991
|
}
|
|
1984
1992
|
},
|
|
1985
1993
|
|
|
1994
|
+
/**
|
|
1995
|
+
* Store a credential for one SSH host on this machine.
|
|
1996
|
+
*
|
|
1997
|
+
* This is what makes the plugin usable without `dsh-ssh-tunnel`: a host from
|
|
1998
|
+
* `~/.ssh/config` that has no `IdentityFile` becomes selectable once a
|
|
1999
|
+
* password is stored here. The secret is written to
|
|
2000
|
+
* `<dataDir>/ssh-credentials.json` (mode 0600) and never returned.
|
|
2001
|
+
*/
|
|
2002
|
+
async 'hosts.credentials'(params = {}) {
|
|
2003
|
+
const hostId = typeof params.hostId === 'string' ? params.hostId.trim() : ''
|
|
2004
|
+
if (!hostId) throw new ApiError('BAD_REQUEST', 'hostId is required')
|
|
2005
|
+
const clear = params.clear === true
|
|
2006
|
+
const password = typeof params.password === 'string' ? params.password : ''
|
|
2007
|
+
const passphrase = typeof params.passphrase === 'string' ? params.passphrase : ''
|
|
2008
|
+
const privateKey = typeof params.privateKey === 'string' ? params.privateKey : ''
|
|
2009
|
+
if (!clear && !password && !passphrase && !privateKey) {
|
|
2010
|
+
throw new ApiError('BAD_REQUEST', '请填写 SSH 密码(或用 clear 清除已保存的凭据)')
|
|
2011
|
+
}
|
|
2012
|
+
const host = await findHost(hostId)
|
|
2013
|
+
// A live socket authenticated with the old credential must be dropped so
|
|
2014
|
+
// the next request dials again.
|
|
2015
|
+
const live = pool.connection(hostId)
|
|
2016
|
+
if (live) {
|
|
2017
|
+
pool.connections.delete(hostId)
|
|
2018
|
+
live.dispose().catch(() => {})
|
|
2019
|
+
}
|
|
2020
|
+
await writeLocalCredential(join(dir, 'ssh-credentials.json'), hostId, clear
|
|
2021
|
+
? null
|
|
2022
|
+
: { password, passphrase, privateKey })
|
|
2023
|
+
const hosts = await refreshHosts(true)
|
|
2024
|
+
const updated = hosts.find((item) => item.id === host.id) || host
|
|
2025
|
+
return {
|
|
2026
|
+
hostId: host.id,
|
|
2027
|
+
authType: updated.authType,
|
|
2028
|
+
hasCredential: Boolean(updated.hasCredential),
|
|
2029
|
+
hasStoredPassword: Boolean(updated.hasStoredPassword),
|
|
2030
|
+
}
|
|
2031
|
+
},
|
|
2032
|
+
|
|
1986
2033
|
async 'hosts.browse'(params = {}) {
|
|
1987
2034
|
const host = await findHost(params.hostId)
|
|
1988
2035
|
const remote = await connectHost(host)
|
package/lib/ssh.js
CHANGED
|
@@ -469,6 +469,16 @@ async function resolveSsh2() {
|
|
|
469
469
|
// Host discovery - DSH SSH Manager store
|
|
470
470
|
// ---------------------------------------------------------------------------
|
|
471
471
|
|
|
472
|
+
function mergeSecrets(base, override) {
|
|
473
|
+
if (!base && !override) return null;
|
|
474
|
+
const merged = { ...(base || {}) };
|
|
475
|
+
for (const key of Object.keys(override || {})) {
|
|
476
|
+
const value = override[key];
|
|
477
|
+
if (typeof value === 'string' && value) merged[key] = value;
|
|
478
|
+
}
|
|
479
|
+
return Object.keys(merged).length > 0 ? merged : null;
|
|
480
|
+
}
|
|
481
|
+
|
|
472
482
|
/**
|
|
473
483
|
* Read and normalize an SSH Manager secrets file.
|
|
474
484
|
* The result never leaves this module: it is only used to authenticate and to
|
|
@@ -479,17 +489,89 @@ async function readSshManagerSecrets(dataDir) {
|
|
|
479
489
|
const byHostId = isPlainObject(raw) && isPlainObject(raw.byHostId) ? raw.byHostId : {};
|
|
480
490
|
const secrets = {};
|
|
481
491
|
for (const id of Object.keys(byHostId)) {
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
484
|
-
const entry = {};
|
|
485
|
-
if (typeof value.password === 'string' && value.password) entry.password = value.password;
|
|
486
|
-
if (typeof value.privateKey === 'string' && value.privateKey) entry.privateKey = value.privateKey;
|
|
487
|
-
if (typeof value.passphrase === 'string' && value.passphrase) entry.passphrase = value.passphrase;
|
|
488
|
-
if (Object.keys(entry).length > 0) secrets[id] = entry;
|
|
492
|
+
const entry = normalizeSecretEntry(byHostId[id]);
|
|
493
|
+
if (entry) secrets[id] = entry;
|
|
489
494
|
}
|
|
490
495
|
return secrets;
|
|
491
496
|
}
|
|
492
497
|
|
|
498
|
+
// ---------------------------------------------------------------------------
|
|
499
|
+
// Host discovery - plugin-local credential store
|
|
500
|
+
// ---------------------------------------------------------------------------
|
|
501
|
+
//
|
|
502
|
+
// `dsh-ssh-tunnel` (the SSH Manager) is optional. Without it there is no place
|
|
503
|
+
// to keep a password, so hosts parsed from `~/.ssh/config` that have no
|
|
504
|
+
// `IdentityFile` used to be unusable. The plugin therefore keeps its own store
|
|
505
|
+
// at `<dataDir>/ssh-credentials.json`:
|
|
506
|
+
//
|
|
507
|
+
// { "version": 1, "byHostId": { "<hostId>": { "password"|"privateKey"|"passphrase": "..." } } }
|
|
508
|
+
//
|
|
509
|
+
// It is written with 0600 permissions and never leaves the Host process: the
|
|
510
|
+
// API only ever reports `authType` / `hasCredential` / `hasStoredPassword`.
|
|
511
|
+
|
|
512
|
+
const CREDENTIALS_VERSION = 1;
|
|
513
|
+
|
|
514
|
+
function normalizeSecretEntry(value) {
|
|
515
|
+
if (!isPlainObject(value)) return null;
|
|
516
|
+
const entry = {};
|
|
517
|
+
if (typeof value.password === 'string' && value.password) entry.password = value.password;
|
|
518
|
+
if (typeof value.privateKey === 'string' && value.privateKey) entry.privateKey = value.privateKey;
|
|
519
|
+
if (typeof value.passphrase === 'string' && value.passphrase) entry.passphrase = value.passphrase;
|
|
520
|
+
return Object.keys(entry).length > 0 ? entry : null;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Read the plugin's own credential store.
|
|
525
|
+
* @param {string} file
|
|
526
|
+
* @returns {Promise<Record<string, { password?: string, privateKey?: string, passphrase?: string }>>}
|
|
527
|
+
*/
|
|
528
|
+
export async function readLocalCredentials(file) {
|
|
529
|
+
if (typeof file !== 'string' || !file.trim()) return {};
|
|
530
|
+
const raw = await readJsonFile(file);
|
|
531
|
+
const byHostId = isPlainObject(raw) && isPlainObject(raw.byHostId) ? raw.byHostId : {};
|
|
532
|
+
const secrets = {};
|
|
533
|
+
for (const id of Object.keys(byHostId)) {
|
|
534
|
+
const entry = normalizeSecretEntry(byHostId[id]);
|
|
535
|
+
if (entry) secrets[id] = entry;
|
|
536
|
+
}
|
|
537
|
+
return secrets;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Store (or delete) the plugin-local credential of one host.
|
|
542
|
+
* Passing `null` removes the entry. The secret is never returned.
|
|
543
|
+
*
|
|
544
|
+
* @param {string} file
|
|
545
|
+
* @param {string} hostId
|
|
546
|
+
* @param {{ password?: string, privateKey?: string, passphrase?: string } | null} patch
|
|
547
|
+
* @returns {Promise<boolean>} true when the host now has a stored credential
|
|
548
|
+
*/
|
|
549
|
+
export async function writeLocalCredential(file, hostId, patch) {
|
|
550
|
+
if (typeof file !== 'string' || !file.trim()) {
|
|
551
|
+
throw new SshError('INTERNAL', 'A credentials file path is required');
|
|
552
|
+
}
|
|
553
|
+
const id = asString(hostId).trim();
|
|
554
|
+
if (!id) throw new SshError('BAD_REQUEST', 'A host id is required');
|
|
555
|
+
return withFileLock(file, async () => {
|
|
556
|
+
const current = await readJsonFile(file);
|
|
557
|
+
const byHostId = isPlainObject(current) && isPlainObject(current.byHostId) ? { ...current.byHostId } : {};
|
|
558
|
+
const entry = patch === null ? null : normalizeSecretEntry(patch);
|
|
559
|
+
if (entry) byHostId[id] = entry;
|
|
560
|
+
else delete byHostId[id];
|
|
561
|
+
const payload = `${JSON.stringify({ version: CREDENTIALS_VERSION, byHostId }, null, 2)}\n`;
|
|
562
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
563
|
+
const temp = `${file}.${randomToken(6)}.tmp`;
|
|
564
|
+
await fs.writeFile(temp, payload, { encoding: 'utf8', mode: 0o600 });
|
|
565
|
+
await fs.rename(temp, file);
|
|
566
|
+
try {
|
|
567
|
+
await fs.chmod(file, 0o600);
|
|
568
|
+
} catch {
|
|
569
|
+
/* best effort on filesystems without POSIX modes */
|
|
570
|
+
}
|
|
571
|
+
return Boolean(entry);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
493
575
|
function normalizeAuthType(value, context = {}) {
|
|
494
576
|
if (typeof value === 'string' && AUTH_TYPES.has(value)) return value;
|
|
495
577
|
const secret = context.secret && typeof context.secret === 'object' ? context.secret : null;
|
|
@@ -522,7 +604,7 @@ function pickHostKeyAlgorithms(record) {
|
|
|
522
604
|
* file yields an empty list. Secrets are only inspected to set
|
|
523
605
|
* `hasCredential`; no secret value is ever placed on a returned record.
|
|
524
606
|
*
|
|
525
|
-
* @param {{ homeDir?: string, dataDir?: string }} [opts]
|
|
607
|
+
* @param {{ homeDir?: string, dataDir?: string, credentials?: Record<string, object> }} [opts]
|
|
526
608
|
* @returns {Promise<Array<object>>}
|
|
527
609
|
*/
|
|
528
610
|
export async function readSshManagerHosts(opts = {}) {
|
|
@@ -530,6 +612,7 @@ export async function readSshManagerHosts(opts = {}) {
|
|
|
530
612
|
const raw = await readJsonFile(path.join(dataDir, 'hosts.json'));
|
|
531
613
|
const list = Array.isArray(raw) ? raw : isPlainObject(raw) && Array.isArray(raw.hosts) ? raw.hosts : [];
|
|
532
614
|
const secrets = await readSshManagerSecrets(dataDir);
|
|
615
|
+
const local = isPlainObject(opts.credentials) ? opts.credentials : {};
|
|
533
616
|
const records = [];
|
|
534
617
|
|
|
535
618
|
for (const entry of list) {
|
|
@@ -541,7 +624,9 @@ export async function readSshManagerHosts(opts = {}) {
|
|
|
541
624
|
const id = asString(entry.id) || `ssh-manager:${username}@${host}:${port}`;
|
|
542
625
|
const name = asString(entry.name) || host;
|
|
543
626
|
const privateKeyPath = asString(entry.privateKeyPath) || asString(entry.identityFile) || undefined;
|
|
544
|
-
|
|
627
|
+
// A credential stored by this plugin wins over the SSH Manager one, so a
|
|
628
|
+
// stale password can be fixed without the companion plugin.
|
|
629
|
+
const secret = mergeSecrets(secrets[id] || null, local[id] || null);
|
|
545
630
|
const authType = normalizeAuthType(entry.authType, { privateKeyPath, secret });
|
|
546
631
|
const record = {
|
|
547
632
|
id,
|
|
@@ -554,6 +639,7 @@ export async function readSshManagerHosts(opts = {}) {
|
|
|
554
639
|
hasCredential: await computeHasCredential(authType, privateKeyPath, secret),
|
|
555
640
|
};
|
|
556
641
|
if (privateKeyPath) record.privateKeyPath = privateKeyPath;
|
|
642
|
+
if (secret && secret.password) record.hasStoredPassword = true;
|
|
557
643
|
const hostKeyAlgorithms = pickHostKeyAlgorithms(entry);
|
|
558
644
|
if (hostKeyAlgorithms) record.hostKeyAlgorithms = hostKeyAlgorithms;
|
|
559
645
|
records.push(record);
|
|
@@ -625,6 +711,21 @@ function resolveLocalConfigPath(value, homeDir) {
|
|
|
625
711
|
return path.resolve(path.join(homeDir, '.ssh'), expanded);
|
|
626
712
|
}
|
|
627
713
|
|
|
714
|
+
/**
|
|
715
|
+
* Auth type for a `~/.ssh/config` host.
|
|
716
|
+
* A stored password only wins when there is no usable key file, so a host with
|
|
717
|
+
* a working `IdentityFile` keeps using the key.
|
|
718
|
+
*/
|
|
719
|
+
async function resolveConfigAuthType(privateKeyPath, secret) {
|
|
720
|
+
if (secret && secret.password) {
|
|
721
|
+
if (!privateKeyPath) return 'password';
|
|
722
|
+
return (await fileExists(privateKeyPath)) ? 'privateKey' : 'password';
|
|
723
|
+
}
|
|
724
|
+
if (privateKeyPath) return 'privateKey';
|
|
725
|
+
if (secret && secret.privateKey) return 'privateKey';
|
|
726
|
+
return 'agent';
|
|
727
|
+
}
|
|
728
|
+
|
|
628
729
|
/**
|
|
629
730
|
* Parse ~/.ssh/config into host records.
|
|
630
731
|
*
|
|
@@ -632,11 +733,12 @@ function resolveLocalConfigPath(value, homeDir) {
|
|
|
632
733
|
* wildcard, negated and `Match` blocks are skipped. `Include` is not followed.
|
|
633
734
|
* The first definition of an alias wins, like OpenSSH.
|
|
634
735
|
*
|
|
635
|
-
* @param {{ homeDir?: string }} [opts]
|
|
736
|
+
* @param {{ homeDir?: string, credentials?: Record<string, object> }} [opts]
|
|
636
737
|
* @returns {Promise<Array<object>>}
|
|
637
738
|
*/
|
|
638
739
|
export async function readSshConfigHosts(opts = {}) {
|
|
639
740
|
const homeDir = typeof opts.homeDir === 'string' && opts.homeDir ? opts.homeDir : os.homedir();
|
|
741
|
+
const local = isPlainObject(opts.credentials) ? opts.credentials : {};
|
|
640
742
|
const configFile = path.join(homeDir, '.ssh', 'config');
|
|
641
743
|
let text;
|
|
642
744
|
try {
|
|
@@ -662,18 +764,21 @@ export async function readSshConfigHosts(opts = {}) {
|
|
|
662
764
|
const port = asPort(options.port);
|
|
663
765
|
const username = unquote(options.user || '') || defaultUser;
|
|
664
766
|
const privateKeyPath = options.identityfile ? resolveLocalConfigPath(options.identityfile, homeDir) : undefined;
|
|
665
|
-
const
|
|
767
|
+
const id = `sshconfig:${alias}`;
|
|
768
|
+
const secret = mergeSecrets(null, local[id] || null);
|
|
769
|
+
const authType = await resolveConfigAuthType(privateKeyPath, secret);
|
|
666
770
|
const record = {
|
|
667
|
-
id
|
|
771
|
+
id,
|
|
668
772
|
name: alias,
|
|
669
773
|
host,
|
|
670
774
|
port,
|
|
671
775
|
username,
|
|
672
776
|
authType,
|
|
673
777
|
source: 'ssh-config',
|
|
674
|
-
hasCredential: await computeHasCredential(authType, privateKeyPath,
|
|
778
|
+
hasCredential: await computeHasCredential(authType, privateKeyPath, secret),
|
|
675
779
|
};
|
|
676
780
|
if (privateKeyPath) record.privateKeyPath = privateKeyPath;
|
|
781
|
+
if (secret && secret.password) record.hasStoredPassword = true;
|
|
677
782
|
seenAliases.add(alias);
|
|
678
783
|
records.push(record);
|
|
679
784
|
}
|
|
@@ -713,11 +818,19 @@ export async function readSshConfigHosts(opts = {}) {
|
|
|
713
818
|
* Merge SSH Manager hosts and ~/.ssh/config hosts, de-duplicated by
|
|
714
819
|
* username@host:port. Manager hosts win and appear first.
|
|
715
820
|
*
|
|
716
|
-
*
|
|
821
|
+
* `credentialFile` points at this plugin's own credential store, which makes a
|
|
822
|
+
* `~/.ssh/config` host without `IdentityFile` usable even when the SSH Manager
|
|
823
|
+
* (`dsh-ssh-tunnel`) is not installed.
|
|
824
|
+
*
|
|
825
|
+
* @param {{ homeDir?: string, dataDir?: string, credentialFile?: string }} [opts]
|
|
717
826
|
* @returns {Promise<Array<object>>}
|
|
718
827
|
*/
|
|
719
828
|
export async function listHosts(opts = {}) {
|
|
720
|
-
const
|
|
829
|
+
const credentials = await readLocalCredentials(opts.credentialFile);
|
|
830
|
+
const [managerHosts, configHosts] = await Promise.all([
|
|
831
|
+
readSshManagerHosts({ ...opts, credentials }),
|
|
832
|
+
readSshConfigHosts({ ...opts, credentials }),
|
|
833
|
+
]);
|
|
721
834
|
const merged = [];
|
|
722
835
|
const seen = new Set();
|
|
723
836
|
for (const record of [...managerHosts, ...configHosts]) {
|
|
@@ -805,6 +918,7 @@ export class RemoteHost {
|
|
|
805
918
|
#generation = 0;
|
|
806
919
|
#logger;
|
|
807
920
|
#dataDir;
|
|
921
|
+
#credentialFile = null;
|
|
808
922
|
#onLost = null;
|
|
809
923
|
|
|
810
924
|
/**
|
|
@@ -814,11 +928,12 @@ export class RemoteHost {
|
|
|
814
928
|
* connectTimeoutMs?: number,
|
|
815
929
|
* logger?: (level: 'info'|'warn'|'error', message: string) => void,
|
|
816
930
|
* dataDir?: string,
|
|
931
|
+
* credentialFile?: string,
|
|
817
932
|
* onLost?: (info: { reason: string, authority: string }) => void,
|
|
818
933
|
* }} options
|
|
819
934
|
*/
|
|
820
935
|
constructor(options = {}) {
|
|
821
|
-
const { host, knownHostsFile, connectTimeoutMs, logger, dataDir, onLost } = options || {};
|
|
936
|
+
const { host, knownHostsFile, connectTimeoutMs, logger, dataDir, credentialFile, onLost } = options || {};
|
|
822
937
|
if (!isPlainObject(host) || !asString(host.host).trim()) {
|
|
823
938
|
throw new SshError('INTERNAL', 'RemoteHost requires a host record with a non-empty "host" field');
|
|
824
939
|
}
|
|
@@ -838,6 +953,7 @@ export class RemoteHost {
|
|
|
838
953
|
this.connectTimeoutMs = Number.isFinite(timeout) && timeout > 0 ? timeout : DEFAULT_CONNECT_TIMEOUT_MS;
|
|
839
954
|
this.#logger = typeof logger === 'function' ? logger : null;
|
|
840
955
|
this.#dataDir = typeof dataDir === 'string' && dataDir ? dataDir : null;
|
|
956
|
+
this.#credentialFile = typeof credentialFile === 'string' && credentialFile ? credentialFile : null;
|
|
841
957
|
this.#onLost = typeof onLost === 'function' ? onLost : null;
|
|
842
958
|
}
|
|
843
959
|
|
|
@@ -900,6 +1016,16 @@ export class RemoteHost {
|
|
|
900
1016
|
this.#client = client;
|
|
901
1017
|
this.#ready = false;
|
|
902
1018
|
|
|
1019
|
+
// Servers that route logins through PAM often accept only
|
|
1020
|
+
// `keyboard-interactive`. Answer those prompts with the same stored
|
|
1021
|
+
// password so one secret works for both methods.
|
|
1022
|
+
const interactivePassword = auth.password || '';
|
|
1023
|
+
if (interactivePassword) {
|
|
1024
|
+
client.on('keyboard-interactive', (_name, _instructions, _language, prompts, finish) => {
|
|
1025
|
+
finish(prompts.map(() => interactivePassword));
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
|
|
903
1029
|
const config = {
|
|
904
1030
|
host: this.host.host,
|
|
905
1031
|
port: this.host.port,
|
|
@@ -907,7 +1033,7 @@ export class RemoteHost {
|
|
|
907
1033
|
readyTimeout: this.connectTimeoutMs,
|
|
908
1034
|
keepaliveInterval: KEEPALIVE_INTERVAL_MS,
|
|
909
1035
|
keepaliveCountMax: KEEPALIVE_COUNT_MAX,
|
|
910
|
-
tryKeyboard:
|
|
1036
|
+
tryKeyboard: Boolean(interactivePassword),
|
|
911
1037
|
hostHash: 'sha256',
|
|
912
1038
|
hostVerifier: (hashedKey, callback) => this.#verifyHostKey(knownHosts, hashedKey, callback),
|
|
913
1039
|
};
|
|
@@ -1072,9 +1198,14 @@ export class RemoteHost {
|
|
|
1072
1198
|
// -- authentication -------------------------------------------------------
|
|
1073
1199
|
|
|
1074
1200
|
async #secretForHost() {
|
|
1201
|
+
const local = this.#credentialFile
|
|
1202
|
+
? (await readLocalCredentials(this.#credentialFile))[this.host.id] || null
|
|
1203
|
+
: null;
|
|
1075
1204
|
const dataDir = this.#dataDir || defaultSshDataDir();
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1205
|
+
const manager = (await readSshManagerSecrets(dataDir))[this.host.id] || null;
|
|
1206
|
+
// The plugin-local store wins, so a password set in the add-workspace dialog
|
|
1207
|
+
// takes effect even when the SSH Manager holds a stale one.
|
|
1208
|
+
return mergeSecrets(manager, local);
|
|
1078
1209
|
}
|
|
1079
1210
|
|
|
1080
1211
|
async #resolveAuth() {
|
|
@@ -1101,7 +1232,10 @@ export class RemoteHost {
|
|
|
1101
1232
|
if (authType === 'password') {
|
|
1102
1233
|
const password = asString(this.host.password) || (secret && secret.password) || '';
|
|
1103
1234
|
if (!password) {
|
|
1104
|
-
throw new SshError(
|
|
1235
|
+
throw new SshError(
|
|
1236
|
+
'AUTH_FAILED',
|
|
1237
|
+
`No password is stored for ${authority}. Enter it in the add-workspace dialog (it stays on this machine) or in the SSH Tunnel tab.`,
|
|
1238
|
+
);
|
|
1105
1239
|
}
|
|
1106
1240
|
return { username, password };
|
|
1107
1241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Linked local ⇄ remote workspaces and remote workspaces for DeepSeek Harness: theme-aware split editor, file-type icons, and agent tools that edit remote files directly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build": "node scripts/build-client.mjs",
|
|
74
|
-
"test": "node --test test/linked.test.mjs test/parts.test.mjs test/git.test.mjs test/file-creation.test.mjs && node test/client-smoke.mjs",
|
|
74
|
+
"test": "node --test test/linked.test.mjs test/parts.test.mjs test/git.test.mjs test/file-creation.test.mjs && node test/ssh-credentials.test.mjs && node test/client-smoke.mjs",
|
|
75
75
|
"prepack": "node scripts/build-client.mjs"
|
|
76
76
|
},
|
|
77
77
|
"repository": {
|