dsh-over-ssh 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/agents/agent-manifest.json +1 -1
- package/lib/client.js +363 -314
- package/lib/file-references.js +80 -35
- package/lib/fs.js +158 -75
- package/lib/index.js +4103 -3397
- package/lib/terminal-wrapper.js +9 -4
- package/lib/types/src/config.d.ts +80 -9
- package/lib/types/src/file-references.d.ts +0 -1
- package/lib/types/src/host/app/backend.d.ts +9 -1
- package/lib/types/src/host/app/recycle-bin/recycle-bin-contract.d.ts +0 -1
- package/lib/types/src/host/app/recycle-bin/recycle-bin-service.d.ts +0 -1
- package/lib/types/src/host/app/session-admin/session-admin-contract.d.ts +12 -1
- package/lib/types/src/host/app/session-admin/session-admin-service.d.ts +0 -1
- package/lib/types/src/host/app/transport/transport-selector.d.ts +0 -1
- package/lib/types/src/host/app/transport/transport-service.d.ts +0 -1
- package/lib/types/src/host/domain/capability.d.ts +0 -1
- package/lib/types/src/host/domain/errors.d.ts +0 -1
- package/lib/types/src/host/domain/roots/connection.d.ts +0 -1
- package/lib/types/src/host/domain/roots/root.d.ts +24 -9
- package/lib/types/src/host/domain/roots/session-roots.d.ts +0 -1
- package/lib/types/src/host/domain/roots/ssh-config.d.ts +0 -1
- package/lib/types/src/host/domain/session/session-admin.d.ts +0 -1
- package/lib/types/src/host/domain/transfer/recycle-bin.d.ts +0 -1
- package/lib/types/src/host/domain/transfer/transfer.d.ts +0 -1
- package/lib/types/src/host/infra/transport/agent/agent-installer.d.ts +0 -1
- package/lib/types/src/host/infra/transport/ssh/ssh2-transport.d.ts +0 -1
- package/lib/types/src/host/infra/transport/transport-base.d.ts +0 -1
- package/lib/types/src/host/infra/transport/transport.d.ts +16 -2
- package/lib/types/src/host/integration/agent/agent-preflight.d.ts +0 -1
- package/lib/types/src/host/integration/fs/file-reference-provider.d.ts +0 -1
- package/lib/types/src/host/integration/fs/fs-provider.d.ts +0 -2
- package/lib/types/src/host/integration/transfer/transfer-service.d.ts +0 -1
- package/lib/types/src/index.d.ts +23 -1
- package/lib/types/src/local-bridge-refs.d.ts +0 -1
- package/lib/types/src/local-bridge.d.ts +0 -1
- package/lib/types/src/shared/root-keys.d.ts +120 -0
- package/lib/types/src/wiring/helpers.d.ts +0 -1
- package/package.json +5 -3
- package/lib/types/src/client/controls.d.ts +0 -131
- package/lib/types/src/client/core/card-focus-trap.d.ts +0 -45
- package/lib/types/src/client/core/controls.d.ts +0 -164
- package/lib/types/src/client/core/latest.d.ts +0 -48
- package/lib/types/src/client/core/locale.d.ts +0 -38
- package/lib/types/src/client/core/message.d.ts +0 -37
- package/lib/types/src/client/core/panel-model.d.ts +0 -134
- package/lib/types/src/client/core/portal.d.ts +0 -266
- package/lib/types/src/client/core/remote.d.ts +0 -84
- package/lib/types/src/client/core/styles.d.ts +0 -458
- package/lib/types/src/client/file-tree-io.d.ts +0 -19
- package/lib/types/src/client/file-tree.d.ts +0 -271
- package/lib/types/src/client/flows/directory-browser.d.ts +0 -587
- package/lib/types/src/client/flows/session-directory.d.ts +0 -415
- package/lib/types/src/client/flows/workspace-directory-flow.d.ts +0 -480
- package/lib/types/src/client/locale.d.ts +0 -31
- package/lib/types/src/client/panel-model.d.ts +0 -37
- package/lib/types/src/client/panel.d.ts +0 -77
- package/lib/types/src/client/roots/connection-test.d.ts +0 -69
- package/lib/types/src/client/roots/roots-panel-state.d.ts +0 -307
- package/lib/types/src/client/roots/roots-panel-view.d.ts +0 -280
- package/lib/types/src/client/roots/roots-panel.d.ts +0 -364
- package/lib/types/src/client/roots/transfer-panel-view.d.ts +0 -35
- package/lib/types/src/client/roots/transfer-panel.d.ts +0 -241
- package/lib/types/src/client/roots/transfer-progress.d.ts +0 -67
- package/lib/types/src/client/roots-panel-view.d.ts +0 -236
- package/lib/types/src/client/roots-panel.d.ts +0 -347
- package/lib/types/src/client/session/session-panel-view.d.ts +0 -336
- package/lib/types/src/client/session/session-panel.d.ts +0 -322
- package/lib/types/src/client/session/session-remote-mark.d.ts +0 -110
- package/lib/types/src/client/session/session-row-actions.d.ts +0 -398
- package/lib/types/src/client/session-panel.d.ts +0 -152
- package/lib/types/src/client/styles.d.ts +0 -252
- package/lib/types/src/client/workspace-directory-flow.d.ts +0 -342
- package/lib/types/src/fs.d.ts +0 -46
- package/lib/types/src/host/app/recycle-bin/recycle-bin-move.d.ts +0 -18
- package/lib/types/src/host/app/recycle-bin/recycle-bin-world.d.ts +0 -38
- package/lib/types/src/host/app/recycle-bin-contract.d.ts +0 -215
- package/lib/types/src/host/app/recycle-bin-move.d.ts +0 -18
- package/lib/types/src/host/app/recycle-bin-service.d.ts +0 -45
- package/lib/types/src/host/app/recycle-bin-world.d.ts +0 -35
- package/lib/types/src/host/app/roots/roots-api-connections.d.ts +0 -49
- package/lib/types/src/host/app/roots/roots-api-contract.d.ts +0 -369
- package/lib/types/src/host/app/roots/roots-api-directories.d.ts +0 -13
- package/lib/types/src/host/app/roots/roots-api-http.d.ts +0 -77
- package/lib/types/src/host/app/roots/roots-api-long-poll.d.ts +0 -130
- package/lib/types/src/host/app/roots/roots-api-projections.d.ts +0 -102
- package/lib/types/src/host/app/roots/roots-api-roots.d.ts +0 -13
- package/lib/types/src/host/app/roots/roots-api-state.d.ts +0 -22
- package/lib/types/src/host/app/roots/roots-api-transfers.d.ts +0 -26
- package/lib/types/src/host/app/roots/roots-api.d.ts +0 -55
- package/lib/types/src/host/app/roots/user-roots.d.ts +0 -552
- package/lib/types/src/host/app/roots-api-connections.d.ts +0 -49
- package/lib/types/src/host/app/roots-api-contract.d.ts +0 -339
- package/lib/types/src/host/app/roots-api-directories.d.ts +0 -13
- package/lib/types/src/host/app/roots-api-http.d.ts +0 -77
- package/lib/types/src/host/app/roots-api-projections.d.ts +0 -102
- package/lib/types/src/host/app/roots-api-roots.d.ts +0 -13
- package/lib/types/src/host/app/roots-api-state.d.ts +0 -22
- package/lib/types/src/host/app/roots-api-support.d.ts +0 -182
- package/lib/types/src/host/app/roots-api-transfers.d.ts +0 -13
- package/lib/types/src/host/app/roots-api.d.ts +0 -55
- package/lib/types/src/host/app/routed-fs.d.ts +0 -239
- package/lib/types/src/host/app/serialize.d.ts +0 -37
- package/lib/types/src/host/app/session-admin/session-admin-context.d.ts +0 -36
- package/lib/types/src/host/app/session-admin/session-admin-delete.d.ts +0 -34
- package/lib/types/src/host/app/session-admin-context.d.ts +0 -36
- package/lib/types/src/host/app/session-admin-contract.d.ts +0 -214
- package/lib/types/src/host/app/session-admin-delete.d.ts +0 -34
- package/lib/types/src/host/app/session-admin-service.d.ts +0 -38
- package/lib/types/src/host/app/takeover/takeover-plan.d.ts +0 -227
- package/lib/types/src/host/app/takeover/takeover-rows.d.ts +0 -55
- package/lib/types/src/host/app/transport-selector.d.ts +0 -98
- package/lib/types/src/host/app/transport-service.d.ts +0 -75
- package/lib/types/src/host/app/user-roots.d.ts +0 -461
- package/lib/types/src/host/domain/bin-location.d.ts +0 -79
- package/lib/types/src/host/domain/connection.d.ts +0 -95
- package/lib/types/src/host/domain/glob-pattern.d.ts +0 -62
- package/lib/types/src/host/domain/literal-text.d.ts +0 -63
- package/lib/types/src/host/domain/path-grammar.d.ts +0 -84
- package/lib/types/src/host/domain/recycle-bin.d.ts +0 -337
- package/lib/types/src/host/domain/root.d.ts +0 -74
- package/lib/types/src/host/domain/roots/bin-location.d.ts +0 -91
- package/lib/types/src/host/domain/roots/route-table.d.ts +0 -102
- package/lib/types/src/host/domain/route-table.d.ts +0 -80
- package/lib/types/src/host/domain/session/terminal-target.d.ts +0 -136
- package/lib/types/src/host/domain/session-admin.d.ts +0 -330
- package/lib/types/src/host/domain/shell.d.ts +0 -47
- package/lib/types/src/host/domain/ssh-config.d.ts +0 -73
- package/lib/types/src/host/domain/terminal-target.d.ts +0 -132
- package/lib/types/src/host/domain/tool-requests.d.ts +0 -369
- package/lib/types/src/host/domain/transfer.d.ts +0 -260
- package/lib/types/src/host/infra/backend/local-backend.d.ts +0 -84
- package/lib/types/src/host/infra/backend/local-version.d.ts +0 -43
- package/lib/types/src/host/infra/backend/platform-local-backend.d.ts +0 -89
- package/lib/types/src/host/infra/backend/remote-backend.d.ts +0 -239
- package/lib/types/src/host/infra/cache/lru.d.ts +0 -52
- package/lib/types/src/host/infra/cache/versioned.d.ts +0 -77
- package/lib/types/src/host/infra/temp-name.d.ts +0 -19
- package/lib/types/src/host/infra/transport/agent/agent-protocol-client.d.ts +0 -132
- package/lib/types/src/host/infra/transport/agent/agent-protocol-codec.d.ts +0 -140
- package/lib/types/src/host/infra/transport/agent/agent-protocol-errors.d.ts +0 -41
- package/lib/types/src/host/infra/transport/agent/agent-protocol-frames.d.ts +0 -197
- package/lib/types/src/host/infra/transport/agent/agent-protocol-types.d.ts +0 -564
- package/lib/types/src/host/infra/transport/agent/agent-transport.d.ts +0 -418
- package/lib/types/src/host/infra/transport/agent-installer.d.ts +0 -121
- package/lib/types/src/host/infra/transport/agent-protocol-client.d.ts +0 -123
- package/lib/types/src/host/infra/transport/agent-protocol-codec.d.ts +0 -131
- package/lib/types/src/host/infra/transport/agent-protocol-errors.d.ts +0 -41
- package/lib/types/src/host/infra/transport/agent-protocol-frames.d.ts +0 -197
- package/lib/types/src/host/infra/transport/agent-protocol-types.d.ts +0 -509
- package/lib/types/src/host/infra/transport/agent-transport.d.ts +0 -353
- package/lib/types/src/host/infra/transport/alias-transport.d.ts +0 -206
- package/lib/types/src/host/infra/transport/askpass-fs.d.ts +0 -20
- package/lib/types/src/host/infra/transport/askpass.d.ts +0 -133
- package/lib/types/src/host/infra/transport/command-pool.d.ts +0 -61
- package/lib/types/src/host/infra/transport/fs-commands.d.ts +0 -140
- package/lib/types/src/host/infra/transport/git-status-route.d.ts +0 -63
- package/lib/types/src/host/infra/transport/git-status.d.ts +0 -101
- package/lib/types/src/host/infra/transport/node-spawn.d.ts +0 -26
- package/lib/types/src/host/infra/transport/session-window.d.ts +0 -51
- package/lib/types/src/host/infra/transport/shell-quote.d.ts +0 -59
- package/lib/types/src/host/infra/transport/ssh/alias-transport.d.ts +0 -206
- package/lib/types/src/host/infra/transport/ssh/askpass-fs.d.ts +0 -20
- package/lib/types/src/host/infra/transport/ssh/askpass.d.ts +0 -133
- package/lib/types/src/host/infra/transport/ssh/shell-quote.d.ts +0 -62
- package/lib/types/src/host/infra/transport/ssh/ssh-argv.d.ts +0 -43
- package/lib/types/src/host/infra/transport/ssh-argv.d.ts +0 -43
- package/lib/types/src/host/infra/transport/ssh2-transport.d.ts +0 -302
- package/lib/types/src/host/integration/agent/agent-install-io.d.ts +0 -33
- package/lib/types/src/host/integration/agent/askpass-registry.d.ts +0 -66
- package/lib/types/src/host/integration/agent-install-io.d.ts +0 -33
- package/lib/types/src/host/integration/agent-preflight.d.ts +0 -56
- package/lib/types/src/host/integration/anchor-directory.d.ts +0 -56
- package/lib/types/src/host/integration/askpass-registry.d.ts +0 -59
- package/lib/types/src/host/integration/bin-root-resolver.d.ts +0 -81
- package/lib/types/src/host/integration/connection-test.d.ts +0 -73
- package/lib/types/src/host/integration/file-reference-provider.d.ts +0 -115
- package/lib/types/src/host/integration/fs/git-status-wiring.d.ts +0 -21
- package/lib/types/src/host/integration/fs/platform-errors.d.ts +0 -94
- package/lib/types/src/host/integration/fs/remote-file-tools.d.ts +0 -369
- package/lib/types/src/host/integration/fs/remote-index.d.ts +0 -177
- package/lib/types/src/host/integration/fs-provider.d.ts +0 -226
- package/lib/types/src/host/integration/lsp/lsp-framing.d.ts +0 -38
- package/lib/types/src/host/integration/lsp/lsp-registry.d.ts +0 -67
- package/lib/types/src/host/integration/lsp/lsp-session.d.ts +0 -130
- package/lib/types/src/host/integration/management-tools.d.ts +0 -64
- package/lib/types/src/host/integration/recycle-bin-service.d.ts +0 -247
- package/lib/types/src/host/integration/remote/connection-test.d.ts +0 -73
- package/lib/types/src/host/integration/remote/remote-face.d.ts +0 -127
- package/lib/types/src/host/integration/remote/remote-tool-backend.d.ts +0 -108
- package/lib/types/src/host/integration/remote-face.d.ts +0 -127
- package/lib/types/src/host/integration/remote-file-tools.d.ts +0 -241
- package/lib/types/src/host/integration/remote-home.d.ts +0 -69
- package/lib/types/src/host/integration/remote-index.d.ts +0 -165
- package/lib/types/src/host/integration/remote-job-tools.d.ts +0 -295
- package/lib/types/src/host/integration/remote-tool-backend.d.ts +0 -97
- package/lib/types/src/host/integration/remote-tools.d.ts +0 -206
- package/lib/types/src/host/integration/root-registry.d.ts +0 -115
- package/lib/types/src/host/integration/roots/anchor-directory.d.ts +0 -56
- package/lib/types/src/host/integration/roots/bin-root-resolver.d.ts +0 -81
- package/lib/types/src/host/integration/roots/remote-home.d.ts +0 -69
- package/lib/types/src/host/integration/roots/root-registry.d.ts +0 -144
- package/lib/types/src/host/integration/roots/roots-wiring.d.ts +0 -219
- package/lib/types/src/host/integration/roots/session-root-index.d.ts +0 -52
- package/lib/types/src/host/integration/roots-api.d.ts +0 -407
- package/lib/types/src/host/integration/roots-wiring.d.ts +0 -211
- package/lib/types/src/host/integration/session/session-api.d.ts +0 -88
- package/lib/types/src/host/integration/session/session-bin-lock.d.ts +0 -80
- package/lib/types/src/host/integration/session/session-header.d.ts +0 -151
- package/lib/types/src/host/integration/session/session-labels.d.ts +0 -56
- package/lib/types/src/host/integration/session/session-route-wiring.d.ts +0 -50
- package/lib/types/src/host/integration/session-admin-service.d.ts +0 -236
- package/lib/types/src/host/integration/session-api.d.ts +0 -81
- package/lib/types/src/host/integration/session-bin-lock.d.ts +0 -80
- package/lib/types/src/host/integration/session-header.d.ts +0 -118
- package/lib/types/src/host/integration/session-labels.d.ts +0 -56
- package/lib/types/src/host/integration/session-route-wiring.d.ts +0 -50
- package/lib/types/src/host/integration/session-scope.d.ts +0 -113
- package/lib/types/src/host/integration/session-tools.d.ts +0 -44
- package/lib/types/src/host/integration/strict-arguments.d.ts +0 -79
- package/lib/types/src/host/integration/takeover/takeover-api.d.ts +0 -62
- package/lib/types/src/host/integration/takeover/takeover-route-wiring.d.ts +0 -60
- package/lib/types/src/host/integration/takeover/takeover-service.d.ts +0 -167
- package/lib/types/src/host/integration/terminal-manifest.d.ts +0 -94
- package/lib/types/src/host/integration/tools/management-tools.d.ts +0 -245
- package/lib/types/src/host/integration/tools/remote-job-tools.d.ts +0 -316
- package/lib/types/src/host/integration/tools/remote-lsp-tools.d.ts +0 -43
- package/lib/types/src/host/integration/tools/remote-tools.d.ts +0 -236
- package/lib/types/src/host/integration/tools/session-target.d.ts +0 -52
- package/lib/types/src/host/integration/tools/session-tools.d.ts +0 -46
- package/lib/types/src/host/integration/tools/strict-arguments.d.ts +0 -79
- package/lib/types/src/host/integration/tools/terminal-manifest.d.ts +0 -94
- package/lib/types/src/host/integration/transfer/remote-copy.d.ts +0 -66
- package/lib/types/src/host/integration/transfer/transfer-adapters.d.ts +0 -48
- package/lib/types/src/host/integration/transfer/transfer-tracker.d.ts +0 -106
- package/lib/types/src/host/integration/transfer-adapters.d.ts +0 -44
- package/lib/types/src/host/integration/transfer-service.d.ts +0 -164
- package/lib/types/src/host/integration/transfer-tracker.d.ts +0 -106
- package/lib/types/src/host/integration/user-roots.d.ts +0 -461
- package/lib/types/src/wiring/connections.d.ts +0 -189
- package/lib/types/src/wiring/fs.d.ts +0 -13
- package/lib/types/src/wiring/install-memo.d.ts +0 -32
- package/lib/types/src/wiring/legacy-dirs.d.ts +0 -62
- package/lib/types/src/wiring/package-paths.d.ts +0 -35
- package/lib/types/src/wiring/roots.d.ts +0 -21
- package/lib/types/src/wiring/state-dir.d.ts +0 -29
- package/lib/types/src/wiring/tools.d.ts +0 -35
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The same-origin HTTP route a client panel uses to **edit** roots and connections.
|
|
3
|
-
*
|
|
4
|
-
* Why a plain HTTP route instead of a Typert `@Remote` service (the shape audit 0021 used for reads):
|
|
5
|
-
*
|
|
6
|
-
* - every action here carries **parameters**, and a Client Remote descriptor with parameters requires a
|
|
7
|
-
* generated strict codec that this repository cannot produce (`doc/02-platform/client-plugin.md` §4);
|
|
8
|
-
* - the panel is served from the GUI's own origin, so a relative `fetch` is same-origin: no CORS
|
|
9
|
-
* concession, no code generation, no `@Remote` registration — exactly the shape the third-party
|
|
10
|
-
* `dsh-plugin-stock-market` uses (`ctx.webServer.register({ kind: 'exact', path, handler })`).
|
|
11
|
-
*
|
|
12
|
-
* This module is a **handler factory decoupled from cordis**: everything it needs arrives through
|
|
13
|
-
* {@link RootsApiDeps}, so it can be unit-tested with fake dependencies and fake request/response objects.
|
|
14
|
-
* The Lead performs the actual registration:
|
|
15
|
-
*
|
|
16
|
-
* ```ts
|
|
17
|
-
* const api = createRootsApi({ ... })
|
|
18
|
-
* disposers.push(webServer.register({ kind: 'exact', path: ROOTS_API_PATH, handler: api.handle }))
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Contract:
|
|
22
|
-
*
|
|
23
|
-
* | Request | Answer |
|
|
24
|
-
* |---|---|
|
|
25
|
-
* | `GET` | `200 { ok: true, roots, connections, userRoots, warnings }` |
|
|
26
|
-
* | `POST` `{ action: 'add-root' \| 'remove-root' \| 'add-connection' \| 'update-connection' \| 'remove-connection', ... }` | `200 { ok: true, action, state }` |
|
|
27
|
-
* | `POST` `{ action: 'add-root', location, path, connectionId?, workspaces?, reuseExisting? }` | `200 { ok: true, action, state, anchorPath? }` — `reuseExisting: true` makes an already-persisted root idempotent and answers its anchor instead of `400 该根已存在` |
|
|
28
|
-
* | `POST` `{ action: 'remove-root', key, workspace? }` | `200 { ok: true, action, state }` — `workspace` removes the root from that workspace only; the root disappears when the last one drops it |
|
|
29
|
-
* | `POST` `{ action: 'update-connection', id, newId?, host?, user?, port?, authKind?, keyPath?, credentialKey?, transport?, password? }` | `200 { ok: true, action, state }` — absent fields keep their value; `newId` renames and migrates the connection's roots (keeping their anchors) |
|
|
30
|
-
* | `POST` `{ action: 'list-remote', connectionId, path }` | `200 { ok: true, action, connectionId, path, entries: [{ name, kind }], truncated }` |
|
|
31
|
-
* | `POST` `{ action: 'list-local', path? }` | `200 { ok: true, action, path, entries: [{ name, kind }], crumbs, truncated }` |
|
|
32
|
-
* | `POST` `{ action: 'list-ssh-config' }` | `200 { ok: true, action, candidates: [{ alias, host, user?, port?, hasIdentityFile, hasProxyJump, suggestedId }], skipped: [{ pattern, reason, line }] }` (FR-2.1.4) |
|
|
33
|
-
* | `POST` `{ action: 'import-ssh-config', aliases: [alias, …] }` | `200 { ok: true, action, imported: [id, …], refused: [{ alias, reason }], state }` — the body names **aliases**, never ids/hosts/paths: every field is re-derived from the config |
|
|
34
|
-
* | any validation / trust / body failure | `400`/`403` `{ ok: false, error, reason? }` |
|
|
35
|
-
* | any other method | `405` `{ ok: false, error }` + `Allow: GET, HEAD, POST` |
|
|
36
|
-
*
|
|
37
|
-
* Two invariants this layer owns:
|
|
38
|
-
*
|
|
39
|
-
* 1. **Credentials never come back out.** `connections` (live and persisted), the `state` echoed by
|
|
40
|
-
* `POST` and every directory row (`list-remote` and `list-local`) are whitelist projections:
|
|
41
|
-
* `{ id, host, user, port, authKind, transport? }` and `{ name, kind }` respectively. `keyPath`, `password`,
|
|
42
|
-
* `passphrase`, `credentialKey`, `alias`, `proxyJump`, sizes, times, modes and symlink targets are
|
|
43
|
-
* never serialised, and no file content is readable through this route at all.
|
|
44
|
-
* 2. **Parameters are taken from a whitelist, one field at a time** — the body is never spread into a
|
|
45
|
-
* call. A field the UI does not own cannot reach the seam, however the body is shaped.
|
|
46
|
-
*
|
|
47
|
-
* @module dsh-remote-workspace/integration/roots-api
|
|
48
|
-
*/
|
|
49
|
-
import { type UserConnectionRecord, type UserRootEntry, type UserRootsState } from './user-roots.ts';
|
|
50
|
-
/** The one path this plugin claims on the host HTTP carrier. */
|
|
51
|
-
export declare const ROOTS_API_PATH = "/api/remote-workspace/roots";
|
|
52
|
-
/** Largest accepted request body. A root/connection edit is a few hundred bytes; 64 KiB is a ceiling, not a budget. */
|
|
53
|
-
export declare const ROOTS_API_MAX_BODY_BYTES: number;
|
|
54
|
-
/** Entries one `list-remote` answer carries at most; the tail is dropped and `truncated` says so. */
|
|
55
|
-
export declare const REMOTE_LIST_MAX_ENTRIES = 2000;
|
|
56
|
-
/** Entries one `list-local` answer carries at most (the same budget as `list-remote`). */
|
|
57
|
-
export declare const LOCAL_LIST_MAX_ENTRIES = 2000;
|
|
58
|
-
/**
|
|
59
|
-
* One remote directory row as the wire may carry it.
|
|
60
|
-
*
|
|
61
|
-
* **Names and kinds only.** A browsing client needs to render a list and decide what is enterable, and
|
|
62
|
-
* nothing else: no sizes, no times, no symlink targets, no file contents, no credentials. The projection
|
|
63
|
-
* below is what enforces that, field by field, exactly like `publicConnection` does for connections.
|
|
64
|
-
*/
|
|
65
|
-
export interface RemoteDirectoryEntry {
|
|
66
|
-
/** Base name of the entry. */
|
|
67
|
-
readonly name: string;
|
|
68
|
-
/** What the row is; anything the listing cannot classify is reported as `file`. */
|
|
69
|
-
readonly kind: 'directory' | 'file' | 'symlink';
|
|
70
|
-
}
|
|
71
|
-
/** Where one `list-remote` request points. */
|
|
72
|
-
export interface RemoteListRequest {
|
|
73
|
-
/** Connection the directory lives behind. */
|
|
74
|
-
readonly connectionId: string;
|
|
75
|
-
/** Absolute POSIX path on that host. */
|
|
76
|
-
readonly path: string;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* One **local** directory row as the wire may carry it.
|
|
80
|
-
*
|
|
81
|
-
* The same discipline as {@link RemoteDirectoryEntry} with a narrower vocabulary: a local `readdir` can
|
|
82
|
-
* report sizes, modes, owners and times without a second syscall, and it can only tell a link from a
|
|
83
|
-
* directory by following it — which this route never does. So anything that is neither a plain file nor a
|
|
84
|
-
* plain directory is answered as `other`, and no field but the name and the kind ever leaves the host.
|
|
85
|
-
*/
|
|
86
|
-
export interface LocalDirectoryEntry {
|
|
87
|
-
/** Base name of the entry. */
|
|
88
|
-
readonly name: string;
|
|
89
|
-
/** What the row is: a plain file, a plain directory, or something else (a symlink, a socket, a device). */
|
|
90
|
-
readonly kind: 'file' | 'directory' | 'other';
|
|
91
|
-
}
|
|
92
|
-
/** Where one `list-local` request points. */
|
|
93
|
-
export interface LocalListRequest {
|
|
94
|
-
/** Absolute, `..`-free path on **this** machine, already defaulted and canonicalised by the handler. */
|
|
95
|
-
readonly path: string;
|
|
96
|
-
}
|
|
97
|
-
/** One action `POST` accepts; anything else is refused with the list. */
|
|
98
|
-
export declare const ROOTS_API_ACTIONS: readonly ["add-root", "remove-root", "add-connection", "update-connection", "test-connection", "remove-connection", "list-remote", "list-local", "list-ssh-config", "import-ssh-config", "mkdir-remote", "rename-remote", "remove-remote", "list-transfers", "clear-transfers"];
|
|
99
|
-
/** One accepted action. */
|
|
100
|
-
export type RootsApiAction = (typeof ROOTS_API_ACTIONS)[number];
|
|
101
|
-
/**
|
|
102
|
-
* The request surface this handler consumes: a structural subset of `node:http`'s `IncomingMessage`, so a
|
|
103
|
-
* test can pass a `Readable` with `method`/`url`/`headers` and no cast, while a real `IncomingMessage`
|
|
104
|
-
* still satisfies it (asserted at compile time in `tests/roots-api.test.ts`).
|
|
105
|
-
*/
|
|
106
|
-
export interface RootsApiRequest {
|
|
107
|
-
readonly method?: string | undefined;
|
|
108
|
-
readonly url?: string | undefined;
|
|
109
|
-
readonly headers: Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
110
|
-
[Symbol.asyncIterator](): AsyncIterator<unknown>;
|
|
111
|
-
}
|
|
112
|
-
/** The response surface this handler consumes: a structural subset of `ServerResponse`. */
|
|
113
|
-
export interface RootsApiResponse {
|
|
114
|
-
statusCode: number;
|
|
115
|
-
setHeader(name: string, value: string): void;
|
|
116
|
-
end(chunk?: string): void;
|
|
117
|
-
}
|
|
118
|
-
/** The seams the handler needs. All of them are the Lead's wiring; none of them is imported from cordis. */
|
|
119
|
-
export interface RootsApiDeps {
|
|
120
|
-
/** Live roots (the registry snapshot), as roots — credentials are stripped here anyway. */
|
|
121
|
-
listRoots(): Promise<readonly unknown[]> | readonly unknown[];
|
|
122
|
-
/** Live connections (profiles), which **do** carry credentials; only the whitelist is answered. */
|
|
123
|
-
listConnections(): Promise<readonly unknown[]> | readonly unknown[];
|
|
124
|
-
/** The persisted panel-owned state plus its warnings (see `createUserRootsStore().load`). */
|
|
125
|
-
loadUserState(): Promise<{
|
|
126
|
-
readonly state: UserRootsState;
|
|
127
|
-
readonly warnings: readonly string[];
|
|
128
|
-
}> | {
|
|
129
|
-
readonly state: UserRootsState;
|
|
130
|
-
readonly warnings: readonly string[];
|
|
131
|
-
};
|
|
132
|
-
/** Persist a whole state; returns what was written (normalised). */
|
|
133
|
-
saveUserState(next: UserRootsState): Promise<UserRootsState> | UserRootsState;
|
|
134
|
-
/** Make a root live **and** remember it. The handler reconciles the file afterwards, so persisting here is expected but not required (a second write is skipped when the content already matches). */
|
|
135
|
-
registerRoot(entry: UserRootEntry): Promise<unknown> | unknown;
|
|
136
|
-
/** Drop a root from the live side (and, if the wiring persists there, from the file). */
|
|
137
|
-
unregisterRoot(key: string): Promise<unknown> | unknown;
|
|
138
|
-
/** Remember a connection. Applying it to a live profile is a reload concern, not this handler's. */
|
|
139
|
-
addConnection(entry: UserConnectionRecord): Promise<unknown> | unknown;
|
|
140
|
-
/**
|
|
141
|
-
* Optional: apply a patched connection to the **live** profile map (and, if the wiring chooses, forget what
|
|
142
|
-
* was cached for it: the agent installation state and the probed remote home are properties of the account,
|
|
143
|
-
* so a changed host must not keep the previous host's answers).
|
|
144
|
-
*
|
|
145
|
-
* The handler already made the rename coherent for the *roots* (see {@link updateConnectionInState}); this
|
|
146
|
-
* seam is what makes it coherent for the live transports. Absent means the change is persisted only, and
|
|
147
|
-
* takes effect after a restart — which is why the wiring provides it.
|
|
148
|
-
*/
|
|
149
|
-
applyConnection?: ((entry: UserConnectionRecord, previousId: string) => Promise<unknown> | unknown) | undefined;
|
|
150
|
-
/**
|
|
151
|
-
* Optional: forget a connection on the **live** side after it was removed.
|
|
152
|
-
*
|
|
153
|
-
* The mirror image of {@link RootsApiDeps.applyConnection}, and it exists for a reason that is easy to miss:
|
|
154
|
-
* the `GET` answer lists connections from the **live** profile map, not from the file. Dropping the record
|
|
155
|
-
* from `user-roots.json` alone therefore leaves the connection on screen — the panel would show a row that
|
|
156
|
-
* no longer exists in any file and whose 「删除」 button reports success forever. Everything the plugin caches
|
|
157
|
-
* **per connection** belongs to this call too: the live transport (a real SSH master or agent child process),
|
|
158
|
-
* the remote index, the installed-agent bookkeeping, the stored askpass secret and its temp directory, the
|
|
159
|
-
* probed remote home. A connection the user deleted must stop costing memory and processes.
|
|
160
|
-
*
|
|
161
|
-
* Absent means the removal is persisted only and the connection stays visible until a restart, which is why
|
|
162
|
-
* the wiring provides it.
|
|
163
|
-
*/
|
|
164
|
-
removeConnection?: ((id: string) => Promise<unknown> | unknown) | undefined;
|
|
165
|
-
/**
|
|
166
|
-
* Optional: hands back the credential store for **this** request; it writes and drops, never reads.
|
|
167
|
-
*
|
|
168
|
-
* A getter rather than a value on purpose: a service read while the entry activates can still be absent —
|
|
169
|
-
* `ctx.get('webServer')` behaved exactly that way on the packaged runtime — and capturing `undefined` once
|
|
170
|
-
* would disable password connections for the whole process. A composition that never provides one refuses
|
|
171
|
-
* `authKind: 'password'` with an explicit message instead of storing a password in a file the user was told
|
|
172
|
-
* holds no secrets.
|
|
173
|
-
*/
|
|
174
|
-
credentials?: (() => CredentialsSeam | undefined) | undefined;
|
|
175
|
-
/**
|
|
176
|
-
* Optional: really connect to one saved connection and run one command, for the panel's 「测试」 button.
|
|
177
|
-
*
|
|
178
|
-
* Optional for the same reason as every other capability here: a composition without a transport service
|
|
179
|
-
* answers the action with an explicit failure instead of pretending the connection is fine. The result is
|
|
180
|
-
* projected field by field, so a wiring that returns extra facts cannot leak them.
|
|
181
|
-
*/
|
|
182
|
-
testConnection?: ((id: string) => Promise<unknown> | unknown) | undefined;
|
|
183
|
-
/**
|
|
184
|
-
* Optional: list one directory on a connection, for the browsing action (`list-remote`).
|
|
185
|
-
*
|
|
186
|
-
* The wiring implements it with the transport's own directory primitive; a composition that does not
|
|
187
|
-
* provide it answers `list-remote` with an explicit failure instead of failing to activate. Whatever it
|
|
188
|
-
* returns is projected to `{ name, kind }` before it reaches the wire.
|
|
189
|
-
*/
|
|
190
|
-
listRemoteDirectory?: ((input: RemoteListRequest) => Promise<readonly unknown[]> | readonly unknown[]) | undefined;
|
|
191
|
-
/**
|
|
192
|
-
* Optional: the directory a remote browse starts at when the client names none.
|
|
193
|
-
*
|
|
194
|
-
* A getter rather than a value for the same reason as {@link credentials}: resolving it may need a live
|
|
195
|
-
* transport, which can appear after this entry activates. When absent, an empty `path` degrades to `/`.
|
|
196
|
-
*/
|
|
197
|
-
remoteHomeDirectory?: ((connectionId: string) => Promise<string> | string) | undefined;
|
|
198
|
-
/**
|
|
199
|
-
* Optional: list one directory **on this machine**, for the browsing action (`list-local`).
|
|
200
|
-
*
|
|
201
|
-
* Same contract as {@link RootsApiDeps.listRemoteDirectory} — rows in, `{ name, kind }` out — and injected
|
|
202
|
-
* for the same two reasons: the domain layer imports no `@deepseek-ai/*` (and no `node:fs`), and a test can
|
|
203
|
-
* assert what the seam was asked for without touching the disk. The wiring implements it with `node:fs`,
|
|
204
|
-
* so a machine whose platform directory picker has no `browse` capability still has a working browser.
|
|
205
|
-
*
|
|
206
|
-
* Whatever it throws must carry the filesystem's own `errno` code (`ENOENT`, `ENOTDIR`, `EACCES`, …): that
|
|
207
|
-
* is how the handler turns "there is no such directory" into a machine-readable `400 reason` instead of an
|
|
208
|
-
* empty listing. A row without a usable name is dropped before it reaches the wire.
|
|
209
|
-
*/
|
|
210
|
-
listLocalDirectory?: ((input: LocalListRequest) => Promise<readonly unknown[]> | readonly unknown[]) | undefined;
|
|
211
|
-
/**
|
|
212
|
-
* Optional: read the user's own `~/.ssh/config` for the import action (FR-2.1.4).
|
|
213
|
-
*
|
|
214
|
-
* Injected for the same two reasons as the directory seams: the domain layer reads no files, and a test can
|
|
215
|
-
* answer with a fixture instead of depending on the developer's home directory. It returns the **text**, not
|
|
216
|
-
* parsed entries, so the parsing (`domain/ssh-config.ts`) stays a pure function under test.
|
|
217
|
-
*
|
|
218
|
-
* Absent means the action answers an explicit "this composition cannot read the file" failure rather than
|
|
219
|
-
* silently importing nothing.
|
|
220
|
-
*/
|
|
221
|
-
readSshConfig?: (() => Promise<string | undefined> | string | undefined) | undefined;
|
|
222
|
-
/**
|
|
223
|
-
* Optional: the remote-file operations the file tree needs (FR-2.2.2).
|
|
224
|
-
*
|
|
225
|
-
* One seam rather than three, because all three are the same capability from this route's point of view
|
|
226
|
-
* ("change the remote filesystem") and a composition either has it or does not. `rename` must refuse to
|
|
227
|
-
* clobber and `remove` must refuse a directory without `recursive` — the contract is in `app/backend.ts`.
|
|
228
|
-
*/
|
|
229
|
-
remoteFiles?: RemoteFileOperations | undefined;
|
|
230
|
-
/**
|
|
231
|
-
* Optional: the in-flight and recent transfers (FR-2.6.4).
|
|
232
|
-
*
|
|
233
|
-
* A **pull** seam, not a push one: the client half has exactly one HTTP route, so "what is happening" is a
|
|
234
|
-
* question it asks, not a stream it subscribes to. Absent means the two transfer actions answer an explicit
|
|
235
|
-
* refusal instead of an empty list — "nothing is running" and "this composition cannot tell you" are
|
|
236
|
-
* different answers, and only one of them is honest.
|
|
237
|
-
*/
|
|
238
|
-
transfers?: TransferReport | undefined;
|
|
239
|
-
}
|
|
240
|
-
/** What the route needs from the tracker, without importing it (the handler stays decoupled). */
|
|
241
|
-
export interface TransferReport {
|
|
242
|
-
list(): readonly unknown[];
|
|
243
|
-
clearFinished(): number;
|
|
244
|
-
}
|
|
245
|
-
/** The three mutating remote-file operations (FR-2.2.2). */
|
|
246
|
-
export interface RemoteFileOperations {
|
|
247
|
-
mkdir(input: {
|
|
248
|
-
readonly connectionId: string;
|
|
249
|
-
readonly path: string;
|
|
250
|
-
readonly recursive: boolean;
|
|
251
|
-
}): Promise<void> | void;
|
|
252
|
-
rename(input: {
|
|
253
|
-
readonly connectionId: string;
|
|
254
|
-
readonly from: string;
|
|
255
|
-
readonly to: string;
|
|
256
|
-
readonly createParents: boolean;
|
|
257
|
-
}): Promise<void> | void;
|
|
258
|
-
remove(input: {
|
|
259
|
-
readonly connectionId: string;
|
|
260
|
-
readonly path: string;
|
|
261
|
-
readonly recursive: boolean;
|
|
262
|
-
}): Promise<void> | void;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* The credential store as this route needs it: **write, drop, and nothing else**.
|
|
266
|
-
*
|
|
267
|
-
* There is deliberately no read here. The route must not be able to answer with a stored secret, so the only
|
|
268
|
-
* operations it can ask for are the two that leave the value in the store.
|
|
269
|
-
*/
|
|
270
|
-
export interface CredentialsSeam {
|
|
271
|
-
/** Store one value under a reference name (the platform rejects an empty one). */
|
|
272
|
-
set(ref: string, value: string): Promise<void> | void;
|
|
273
|
-
/** Drop one stored value; a no-op when the name is not present. */
|
|
274
|
-
unset(ref: string): Promise<void> | void;
|
|
275
|
-
}
|
|
276
|
-
/** The handler pair the Lead registers. */
|
|
277
|
-
export interface RootsApi {
|
|
278
|
-
/**
|
|
279
|
-
* Serve one request. Never throws: a handler that rejects would leave the socket without a status.
|
|
280
|
-
*
|
|
281
|
-
* Bound as an arrow property so `handler: api.handle` can be passed directly.
|
|
282
|
-
*/
|
|
283
|
-
readonly handle: (req: RootsApiRequest, res: RootsApiResponse) => Promise<void>;
|
|
284
|
-
/** No resources are held; the route registration belongs to the caller. */
|
|
285
|
-
dispose(): void;
|
|
286
|
-
}
|
|
287
|
-
/** Reasons a request is refused before any action runs. */
|
|
288
|
-
export type TrustVerdict = 'ok' | 'no-host' | 'bad-host' | 'cross-site' | 'bad-origin';
|
|
289
|
-
/** Fields a root action may carry. Everything else in the body is ignored. */
|
|
290
|
-
export declare const ROOT_FIELDS: readonly ["location", "path", "connectionId", "label", "writable", "workspaces"];
|
|
291
|
-
/**
|
|
292
|
-
* Fields a connection action may carry.
|
|
293
|
-
*
|
|
294
|
-
* `password` is deliberately **not** here: it is not part of a connection record. `add-connection` takes it out
|
|
295
|
-
* of the body separately, writes it to the credential store, and persists only the reference name.
|
|
296
|
-
* `passphrase` is not here either — nothing in this feature has a representation for it.
|
|
297
|
-
*
|
|
298
|
-
* `transport` **is** here, and it has to be: the panel's form sends the user's explicit choice, and this
|
|
299
|
-
* whitelist is what decides which fields survive to `normalizeConnectionEntry`. Leaving it out would drop the
|
|
300
|
-
* field silently — the connection would be persisted with no transport and every reader would fall back to
|
|
301
|
-
* the default, which is exactly the "no escape hatch from the agent" bug this field exists to fix.
|
|
302
|
-
*/
|
|
303
|
-
export declare const CONNECTION_FIELDS: readonly ["id", "host", "user", "port", "authKind", "keyPath", "credentialKey", "transport"];
|
|
304
|
-
/**
|
|
305
|
-
* Fields `update-connection` may patch.
|
|
306
|
-
*
|
|
307
|
-
* `id` is deliberately **not** here. In `add-connection` it names the connection being created; in an edit it
|
|
308
|
-
* is the *lookup* key ("which connection am I changing"), so reusing it for the new name would make the two
|
|
309
|
-
* meanings collide and a rename impossible to express. The new id therefore travels in its own field,
|
|
310
|
-
* **`newId`** (optional; absent means "keep the id").
|
|
311
|
-
*/
|
|
312
|
-
export declare const UPDATE_CONNECTION_FIELDS: readonly ["host", "user", "port", "authKind", "keyPath", "credentialKey", "transport"];
|
|
313
|
-
/**
|
|
314
|
-
* Decide whether a request is same-origin enough to serve.
|
|
315
|
-
*
|
|
316
|
-
* The rule, and why it is not stricter:
|
|
317
|
-
*
|
|
318
|
-
* - **A missing `Origin` is allowed.** Non-browser clients do not send it: `curl`, a Node-side `fetch`, and
|
|
319
|
-
* the DSH desktop shell's own calls. Browsers always send `Origin` on a `POST` (including a cross-site
|
|
320
|
-
* `no-cors` form post), which is the case this fence exists for, so "absent" cannot be produced by a
|
|
321
|
-
* cross-site page.
|
|
322
|
-
* - **`Origin: null` is refused** (sandboxed iframe, `file:` document).
|
|
323
|
-
* - **`Origin` must match `Host`.** A different port or hostname is a different origin.
|
|
324
|
-
* - **A port-less loopback spelling is accepted** when the `Origin` carried no port at all: some Chromium
|
|
325
|
-
* builds serialise a loopback page as `http://127.0.0.1` even when the page is on a non-default port
|
|
326
|
-
* (observed in this workspace by the `dsh-remote-ssh` plugin, which fences the same way). A *different*
|
|
327
|
-
* explicit port still fails, because that path compares full `host`.
|
|
328
|
-
* - **`Sec-Fetch-Site: cross-site` is refused** even if the two headers were somehow consistent.
|
|
329
|
-
*
|
|
330
|
-
* The host allowlist itself (loopback / trusted hosts) is **not** re-implemented here: the carrier already
|
|
331
|
-
* decides what it serves. See the audit's unverified list.
|
|
332
|
-
*
|
|
333
|
-
* @param req - incoming request.
|
|
334
|
-
* @returns `'ok'`, or the reason to refuse.
|
|
335
|
-
*/
|
|
336
|
-
export declare function trustVerdict(req: RootsApiRequest): TrustVerdict;
|
|
337
|
-
/** User-facing text for one {@link TrustVerdict}. */
|
|
338
|
-
export declare function trustMessage(verdict: TrustVerdict): string;
|
|
339
|
-
//# sourceMappingURL=roots-api-contract.d.ts.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* roots-api-directories
|
|
3
|
-
*
|
|
4
|
-
* 目录与文件操作的 5 个 action:mkdir/rename/remove、远端列举、本机列举。
|
|
5
|
-
*
|
|
6
|
-
* 从 `roots-api.ts` 的 `serveAction`(543 行 / 15 个 case)拆出(审计 0076):
|
|
7
|
-
* case 体逐字搬移,只把 `return;` 改成 `return true;`,未命中时返回 `false` 由分发器报 400。
|
|
8
|
-
*
|
|
9
|
-
* @module dsh-remote-workspace/app/roots-api-directories
|
|
10
|
-
*/
|
|
11
|
-
import type { RootsApiRequest, RootsApiResponse, RootsApiDeps } from './roots-api-contract.ts';
|
|
12
|
-
export declare function handleDirectoryActions(action: string, body: Record<string, unknown>, req: RootsApiRequest, res: RootsApiResponse, deps: RootsApiDeps): Promise<boolean>;
|
|
13
|
-
//# sourceMappingURL=roots-api-directories.d.ts.map
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 根路由的**请求/响应原语**:读 body、发 JSON、字段校验、凭据字段拦截。
|
|
3
|
-
*
|
|
4
|
-
* 从 `roots-api-support.ts` 拆出(审计 0079):这一层只认 HTTP 与 body 形状,
|
|
5
|
-
* 不知道任何 DTO,也不读用户状态。
|
|
6
|
-
*
|
|
7
|
-
* @module dsh-remote-workspace/app/roots-api-http
|
|
8
|
-
*/
|
|
9
|
-
import { type UserRootEntry } from './user-roots.ts';
|
|
10
|
-
import type { RootsApiRequest, RootsApiResponse, RootsApiDeps } from './roots-api-contract.ts';
|
|
11
|
-
export declare function readBody(req: RootsApiRequest): Promise<string>;
|
|
12
|
-
export declare function toBytes(chunk: unknown): Uint8Array;
|
|
13
|
-
export declare function send(req: RootsApiRequest, res: RootsApiResponse, status: number, value: unknown): void;
|
|
14
|
-
export declare function asRecord(value: unknown): Record<string, unknown> | undefined;
|
|
15
|
-
export declare function messageOf(error: unknown): string;
|
|
16
|
-
/** The machine-readable reason a refusal carries in its details, when it has one. */
|
|
17
|
-
export declare function reasonOf(error: unknown): string | undefined;
|
|
18
|
-
export declare function isValidationFailure(error: unknown): boolean;
|
|
19
|
-
/** One required non-empty string field of a body. */
|
|
20
|
-
export declare function requiredString(value: unknown, field: string): string;
|
|
21
|
-
export declare function requiredKey(value: unknown): string;
|
|
22
|
-
/**
|
|
23
|
-
* The optional `path` field of a `list-local` body.
|
|
24
|
-
*
|
|
25
|
-
* Absent and empty (or blank) both mean "the host default", which is the user's home directory. Anything else
|
|
26
|
-
* that is not a string — `null` included — is the caller's fault and is refused before a directory is chosen:
|
|
27
|
-
* silently browsing the home directory because a client sent `null` would look like the request succeeded.
|
|
28
|
-
*/
|
|
29
|
-
export declare function optionalPath(value: unknown): string | undefined;
|
|
30
|
-
/** Take only the named fields from a body; the body itself is never handed to a seam. */
|
|
31
|
-
export declare function pick(source: Record<string, unknown>, fields: readonly string[]): Record<string, unknown>;
|
|
32
|
-
/**
|
|
33
|
-
* The one body field this route refuses outright, whatever the action.
|
|
34
|
-
*
|
|
35
|
-
* `passphrase` has no representation anywhere in this feature, so accepting it would be a lie — and silently
|
|
36
|
-
* dropping it would tell the user their passphrase was stored.
|
|
37
|
-
*
|
|
38
|
-
* `password` is **not** refused any more: `add-connection` and `update-connection` take it, write it into the
|
|
39
|
-
* credential store and keep only the reference (FR-2.1.2). `credentialKey` is a *name*, not a secret, and
|
|
40
|
-
* travels normally.
|
|
41
|
-
*/
|
|
42
|
-
export declare function firstCredentialField(body: Record<string, unknown>, action: string): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* The live registry's own key for one persisted entry, or `undefined` when it is not live.
|
|
45
|
-
*
|
|
46
|
-
* The comparison goes through `sameUserRootKey` rather than `===`: the registry lower-cases Windows local
|
|
47
|
-
* paths (`domain/root.ts`'s `rootKey`), the persisted file keeps the caller's case, and the client rebuilds
|
|
48
|
-
* the key from the `path` the answer carried. Comparing them verbatim made a Windows local root impossible to
|
|
49
|
-
* remove - the file entry went, the live root stayed, and the row then had no delete button because it was no
|
|
50
|
-
* longer in the file.
|
|
51
|
-
*
|
|
52
|
-
* @param deps - the injected seams (only `listRoots` is read).
|
|
53
|
-
* @param entry - the entry to look for.
|
|
54
|
-
* @returns the key the registry holds it under, or `undefined`.
|
|
55
|
-
*/
|
|
56
|
-
export declare function matchedLiveKey(deps: RootsApiDeps, entry: UserRootEntry): Promise<string | undefined>;
|
|
57
|
-
/**
|
|
58
|
-
* Read one live record as a root key, matching it against `entry`.
|
|
59
|
-
*
|
|
60
|
-
* @param raw - a `RootRecord` (key + root) or a bare `RootRef`.
|
|
61
|
-
* @param entry - the entry to match.
|
|
62
|
-
* @returns the record's own key when it names `entry`, else `undefined`.
|
|
63
|
-
*/
|
|
64
|
-
export declare function liveKeyOfRecord(raw: unknown, entry: UserRootEntry): string | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Turn an alias into a connection id that passes {@link isValidConnectionId}.
|
|
67
|
-
*
|
|
68
|
-
* `~/.ssh/config` aliases routinely contain characters this plugin's ids reject (`@`, `:`, `/`, spaces) —
|
|
69
|
-
* `deploy@bastion` is a perfectly normal alias. Importing one verbatim would be refused by
|
|
70
|
-
* {@link normalizeConnectionEntry} with a message about id grammar, which reads as "the import is broken".
|
|
71
|
-
* The alias is therefore **kept as the ssh target** (`alias`), and only the *id* is sanitised.
|
|
72
|
-
*
|
|
73
|
-
* @param alias - the literal alias from the config.
|
|
74
|
-
* @returns a valid id, or `undefined` when sanitising leaves nothing usable.
|
|
75
|
-
*/
|
|
76
|
-
export declare function connectionIdFromAlias(alias: string): string | undefined;
|
|
77
|
-
//# sourceMappingURL=roots-api-http.d.ts.map
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 根路由的**投影层**:把内部状态/后端条目压成对外的 DTO,以及路径面包屑与失败文案。
|
|
3
|
-
*
|
|
4
|
-
* 从 `roots-api-support.ts` 拆出(审计 0079):纯函数,输入输出都是普通对象,
|
|
5
|
-
* 因此可以单独断言「哪些字段能出网」。
|
|
6
|
-
*
|
|
7
|
-
* @module dsh-remote-workspace/app/roots-api-projections
|
|
8
|
-
*/
|
|
9
|
-
import { type ConnectionPatch, type UserRootEntry, type UserRootsState } from './user-roots.ts';
|
|
10
|
-
/**
|
|
11
|
-
* Whitelist one live root, dropping everything else it carries (argv, anchor paths, transports).
|
|
12
|
-
*
|
|
13
|
-
* Both spellings the Lead may hand over are accepted: a bare `RootRef` and a `RootRecord`
|
|
14
|
-
* (`{ key, root, backend }` — what `RootRegistry.records` returns). Reading the nested `root` here is what
|
|
15
|
-
* keeps a wiring mistake from showing every root as `location: "unknown", path: ""`.
|
|
16
|
-
*/
|
|
17
|
-
export declare function publicRoot(raw: unknown): PublicRoot;
|
|
18
|
-
/**
|
|
19
|
-
* Whitelist one live connection.
|
|
20
|
-
*
|
|
21
|
-
* This is the only place the host's connection profiles are turned into wire data, so it is the one place
|
|
22
|
-
* that must never copy a field it was not explicitly told to copy: `auth`, `keyPath`, `credentialKey`,
|
|
23
|
-
* `password`, `alias`, `proxyJump` and everything added later stay behind.
|
|
24
|
-
*/
|
|
25
|
-
export declare function publicConnection(raw: unknown): PublicConnection;
|
|
26
|
-
/** The persisted state as the panel may see it: same connection projection, so `keyPath` never travels. */
|
|
27
|
-
export declare function publicUserState(state: UserRootsState): {
|
|
28
|
-
readonly version: number;
|
|
29
|
-
readonly roots: readonly UserRootEntry[];
|
|
30
|
-
readonly connections: readonly PublicConnection[];
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* The wire shape of one tracked transfer.
|
|
34
|
-
*
|
|
35
|
-
* Whitelisted field by field, like every other projection on this route: the tracker's own object is a
|
|
36
|
-
* host-side value, and a field added there must be a deliberate decision to publish, not a leak.
|
|
37
|
-
*
|
|
38
|
-
* @param value - one entry from the tracker.
|
|
39
|
-
* @returns the row the client may see.
|
|
40
|
-
*/
|
|
41
|
-
export declare function publicTransfer(value: unknown): Record<string, unknown>;
|
|
42
|
-
/**
|
|
43
|
-
* The absolute chain from the filesystem root down to `absolute`, inclusive.
|
|
44
|
-
*
|
|
45
|
-
* The client renders "up" and "home" from this instead of composing a parent path itself: drive letters, UNC
|
|
46
|
-
* shares and `/` are exactly the dialects a web client gets wrong, and one wrong guess sends `list-local` to a
|
|
47
|
-
* directory the user never asked for. Every element is an ancestor of the path the answer already carries, so
|
|
48
|
-
* the field discloses nothing the `path` field did not.
|
|
49
|
-
*
|
|
50
|
-
* @param absolute - an absolute, resolved path (what the handler answers with).
|
|
51
|
-
* @returns the chain, root first; empty when the platform reports no root (impossible for a resolved path).
|
|
52
|
-
*/
|
|
53
|
-
export declare function localPathCrumbs(absolute: string): readonly string[];
|
|
54
|
-
/** The machine-readable reason for one local listing failure, or `undefined` when it is not the caller's fault. */
|
|
55
|
-
export declare function localFailureReason(error: unknown): LocalFailureReason | undefined;
|
|
56
|
-
/** The human text for one {@link LocalFailureReason}; the path is always named so the message is actionable. */
|
|
57
|
-
export declare function localFailureMessage(reason: LocalFailureReason, path: string): string;
|
|
58
|
-
/**
|
|
59
|
-
* Narrow a whitelisted body down to the fields of a {@link ConnectionPatch} (never the id: see
|
|
60
|
-
* {@link UPDATE_CONNECTION_FIELDS}).
|
|
61
|
-
*
|
|
62
|
-
* **Absent means "keep what is there"** for every field, and this function is what makes that true rather than
|
|
63
|
-
* accidental: only keys the body actually carries are copied, so a body that names three fields cannot blank
|
|
64
|
-
* the four it did not mention.
|
|
65
|
-
*
|
|
66
|
-
* `port: ''`/`null` becomes `null`, which is the one value that means **drop the field** (back to the ssh
|
|
67
|
-
* default). Every other value is passed through untouched and judged by `normalizeConnectionEntry`; nothing is
|
|
68
|
-
* coerced here, because a bad port must be reported, not silently rounded.
|
|
69
|
-
*
|
|
70
|
-
* @param source - the whitelisted fields of the request body.
|
|
71
|
-
* @returns the patch.
|
|
72
|
-
*/
|
|
73
|
-
export declare function connectionPatchOf(source: Record<string, unknown>): Omit<ConnectionPatch, 'id'>;
|
|
74
|
-
/** One root as the panel may see it: no credential can appear in a root, but the shape is still fixed. */
|
|
75
|
-
export interface PublicRoot {
|
|
76
|
-
readonly key?: string;
|
|
77
|
-
readonly location: string;
|
|
78
|
-
readonly connectionId?: string;
|
|
79
|
-
readonly path: string;
|
|
80
|
-
readonly label?: string;
|
|
81
|
-
readonly writable?: boolean;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* One connection as the panel may see it. **Deliberately without `keyPath`.**
|
|
85
|
-
*
|
|
86
|
-
* `transport` **is** projected, and it has to be: the edit form is filled from this answer and submits what it
|
|
87
|
-
* was filled with, so omitting the field silently rewrote every `alias`/`ssh2` connection to the default
|
|
88
|
-
* (`agent`) on the next save - even when the operator only changed the host.
|
|
89
|
-
*/
|
|
90
|
-
export interface PublicConnection {
|
|
91
|
-
readonly id: string;
|
|
92
|
-
readonly host: string;
|
|
93
|
-
readonly user: string;
|
|
94
|
-
readonly port?: number;
|
|
95
|
-
readonly authKind: string;
|
|
96
|
-
/** The transport this connection asks for; absent only for a record that names none. */
|
|
97
|
-
readonly transport?: string;
|
|
98
|
-
}
|
|
99
|
-
/** The reasons a local listing of a syntactically valid path can be refused with. */
|
|
100
|
-
type LocalFailureReason = 'not-found' | 'not-a-directory' | 'unreadable';
|
|
101
|
-
export {};
|
|
102
|
-
//# sourceMappingURL=roots-api-projections.d.ts.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* roots-api-roots
|
|
3
|
-
*
|
|
4
|
-
* 根的两个 action:add-root / remove-root,以及根的存活判定与锚点解析。
|
|
5
|
-
*
|
|
6
|
-
* 从 `roots-api-roots.ts` 拆出(审计 0077):根与连接是两套独立的状态机,
|
|
7
|
-
* 原先共处一个 switch,各自的辅助函数也互不相干。
|
|
8
|
-
*
|
|
9
|
-
* @module dsh-remote-workspace/app/roots-api-roots
|
|
10
|
-
*/
|
|
11
|
-
import type { RootsApiRequest, RootsApiResponse, RootsApiDeps } from './roots-api-contract.ts';
|
|
12
|
-
export declare function handleRootActions(action: string, body: Record<string, unknown>, req: RootsApiRequest, res: RootsApiResponse, deps: RootsApiDeps): Promise<boolean>;
|
|
13
|
-
//# sourceMappingURL=roots-api-roots.d.ts.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 根路由的**状态读取**:取当前用户状态、在其上做一次可串行化的变更。
|
|
3
|
-
*
|
|
4
|
-
* 从 `roots-api-support.ts` 拆出(审计 0079):它是根与连接两族 handler 的公共入口,
|
|
5
|
-
* 与 HTTP 原语、DTO 投影互不相干。
|
|
6
|
-
*
|
|
7
|
-
* @module dsh-remote-workspace/app/roots-api-state
|
|
8
|
-
*/
|
|
9
|
-
import { type UserRootsState } from './user-roots.ts';
|
|
10
|
-
import type { RootsApiDeps } from './roots-api-contract.ts';
|
|
11
|
-
/** The persisted state, read fresh for every check (the file is the source of truth, not a cache). */
|
|
12
|
-
export declare function currentUserState(deps: RootsApiDeps): Promise<UserRootsState>;
|
|
13
|
-
/**
|
|
14
|
-
* Converge the persisted state on a target shape and return it.
|
|
15
|
-
*
|
|
16
|
-
* The handler never assumes who persisted what: it consults the file **after** the live seam ran, computes
|
|
17
|
-
* the state the request implies, and writes only when that differs. So a wiring whose `registerRoot` already
|
|
18
|
-
* persists produces no second write, and a wiring that only touches the live registry still ends with a file
|
|
19
|
-
* that matches reality.
|
|
20
|
-
*/
|
|
21
|
-
export declare function reconcile(deps: RootsApiDeps, transition: (state: UserRootsState) => UserRootsState): Promise<UserRootsState>;
|
|
22
|
-
//# sourceMappingURL=roots-api-state.d.ts.map
|