@deep-podder/dsh-remote-mobile 0.0.0-stage → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/PROTOCOL.md +627 -0
- package/README.md +313 -2
- package/SECURITY.md +207 -0
- package/auth.js +290 -0
- package/bridge.js +3167 -0
- package/client.js +687 -0
- package/cordis.patch.yml +7 -0
- package/docs/api-notes-v2.md +978 -0
- package/docs/api-notes.md +583 -0
- package/docs/screenshots/chat-light.png +0 -0
- package/docs/screenshots/commands-dark.png +0 -0
- package/docs/screenshots/pairing-light.png +0 -0
- package/docs/screenshots/sessions-light.png +0 -0
- package/docs/verification.md +92 -0
- package/icon.svg +14 -0
- package/index.js +108 -0
- package/locale/en.json +29 -0
- package/mobile/README.md +1281 -0
- package/mobile/app.js +10835 -0
- package/mobile/favicon.svg +6 -0
- package/mobile/icons/apple-touch-icon.png +0 -0
- package/mobile/icons/icon-192.png +0 -0
- package/mobile/icons/icon-512.png +0 -0
- package/mobile/icons/icon-maskable-512.png +0 -0
- package/mobile/index.html +377 -0
- package/mobile/manifest.webmanifest +40 -0
- package/mobile/mock-server.js +2800 -0
- package/mobile/styles.css +4698 -0
- package/mobile/sw.js +396 -0
- package/package.json +74 -4
- package/push.js +531 -0
- package/qr.js +49 -0
- package/server.js +2648 -0
- package/vendor/LICENSE +25 -0
- package/vendor/qrcode.js +2302 -0
package/README.md
CHANGED
|
@@ -1,3 +1,314 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-remote-mobile
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@deep-podder/dsh-remote-mobile)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
A [DeepSeek Harness](https://github.com/deepseek-ai) plugin that turns your phone into a
|
|
7
|
+
remote control for a live desktop Harness session. A small pairing server runs inside the
|
|
8
|
+
Harness Host, serves an installable mobile web app, and bridges the phone to the same
|
|
9
|
+
session, streaming, tool and approval pipeline the desktop UI uses.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
phone browser ──HTTP(S)/WS──► <host>:3456 ──bridge──► DSH Host services
|
|
13
|
+
▲ (pairing, cookie, rate limit) │
|
|
14
|
+
└──────────── QR / 4-digit PIN from the desktop panel ◄───────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
No npm dependencies. Plain ESM in the Host plugin, plain browser JavaScript in the SPA, and
|
|
18
|
+
one vendored MIT QR encoder.
|
|
19
|
+
|
|
20
|
+
## Screenshots
|
|
21
|
+
|
|
22
|
+
Captured from the bundled mock server (demo data, 390×844 @2x). They show the pair-once flow,
|
|
23
|
+
the desktop-style project grouping, the chat surface and the Host command palette.
|
|
24
|
+
|
|
25
|
+
| Pair this phone | Sessions grouped by project |
|
|
26
|
+
|:---:|:---:|
|
|
27
|
+
|  |  |
|
|
28
|
+
| **Chat — light** | **Host commands — dark** |
|
|
29
|
+
|  |  |
|
|
30
|
+
|
|
31
|
+
## What you get
|
|
32
|
+
|
|
33
|
+
- **Real-time chat** — token streaming, markdown, syntax-highlighted code, stop and steer.
|
|
34
|
+
- **Sessions** — list, open, create (with an agent preset, a project shortcut and an optional
|
|
35
|
+
working directory), rename, fork, pin/unpin and archive/unarchive. The list is grouped by
|
|
36
|
+
registered project workspace exactly like the desktop sidebar (collapsible project sections,
|
|
37
|
+
an **Ungrouped** section, pinned rows first) and archived sessions are hidden behind an
|
|
38
|
+
explicit **Show archived** control. Content search when the deployment enables the Host's
|
|
39
|
+
session-query index.
|
|
40
|
+
- **Model and preset selection** — switch the session's provider/model/reasoning effort and
|
|
41
|
+
the DSH agent preset from the phone.
|
|
42
|
+
- **Host commands** — the phone mirrors the live Agent's command palette (`/compact`,
|
|
43
|
+
`/goal`, `/plan`, `/feedback` and any other Host-registered command). `/export` and
|
|
44
|
+
`/permission` are desktop-only: `/export` downloads a browser-authenticated ZIP, and
|
|
45
|
+
`/permission` changes the session's sandbox/approval preset (including
|
|
46
|
+
`danger-full-access`), so sandbox policy stays a desktop decision. Argument commands open a
|
|
47
|
+
small input sheet; unknown commands are refused.
|
|
48
|
+
- **Queue and steer** — watch queued messages, edit or remove them, steer one into the
|
|
49
|
+
running turn, and choose Queue vs Steer for the next send.
|
|
50
|
+
- **Approvals and questions** — approvals surface as cards with a bounded, secret-scrubbed
|
|
51
|
+
preview of the command or file write/edit when the bridge saw the tool call; per-device
|
|
52
|
+
"can approve" control lives in the desktop pairing panel. `ask_user_question` renders as a
|
|
53
|
+
native question card and answers the waiting tool.
|
|
54
|
+
- **Activity** — live tool cards, and the session's changed files with unified diffs for text
|
|
55
|
+
files (live sessions only).
|
|
56
|
+
- **Context meter** — used/window tokens with an estimated badge when the Host has no usage
|
|
57
|
+
sample.
|
|
58
|
+
- **Attachments** — camera/library/file uploads, inline images delivered to the model as real
|
|
59
|
+
image content parts, and Android share-sheet text/links into a session.
|
|
60
|
+
- **Background notifications (Web Push)** — approvals, questions and finished replies reach
|
|
61
|
+
the phone through its service worker while the app is backgrounded or the screen is off.
|
|
62
|
+
Real RFC 8291 `aes128gcm` payload encryption and RFC 8292 VAPID, implemented in `push.js`
|
|
63
|
+
with no dependencies. Requires a secure context (Tailscale Serve HTTPS or localhost) and
|
|
64
|
+
notification permission.
|
|
65
|
+
- **Installable PWA** — manifest, service worker, offline shell (requires a secure context)
|
|
66
|
+
and voice input.
|
|
67
|
+
- **App lock** — an optional WebAuthn passkey gate on cold start/inactivity. Client-side
|
|
68
|
+
privacy only; see [SECURITY.md](SECURITY.md).
|
|
69
|
+
- **Pairing panel in the desktop UI** — QR code, fallback PIN, expiry countdown, per-device
|
|
70
|
+
approval permission, per-device and global revoke, and an on/off switch for the phone
|
|
71
|
+
server.
|
|
72
|
+
|
|
73
|
+
## Requirements
|
|
74
|
+
|
|
75
|
+
- **DeepSeek Harness 0.2.2-rc.1** with the Desktop/Web profile (the desktop pairing panel is
|
|
76
|
+
a client module of the Harness Web UI). Other 0.2.2-rc builds may work; the Host API surface
|
|
77
|
+
this plugin uses is documented in [docs/api-notes.md](docs/api-notes.md).
|
|
78
|
+
- **Node 22 or newer** (the Host's runtime; the plugin itself has no npm dependencies and uses
|
|
79
|
+
only `node:` built-ins). `dev/` checks use the built-in `fetch`.
|
|
80
|
+
- A phone with a current browser. For use away from the LAN, **Tailscale** (or any HTTPS
|
|
81
|
+
reverse proxy) is strongly recommended; see [Security](#security).
|
|
82
|
+
- For **background notifications** a secure context is required: HTTPS (Tailscale Serve or a
|
|
83
|
+
trusted TLS proxy) or `http://localhost`. Plain-HTTP LAN access keeps working but has no
|
|
84
|
+
service worker, so Web Push is unavailable there. The user also has to grant notification
|
|
85
|
+
permission once.
|
|
86
|
+
|
|
87
|
+
## Install
|
|
88
|
+
|
|
89
|
+
From npm:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
plugin_manager action=install_bundle target=@deep-podder/dsh-remote-mobile
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Or from a checkout of this folder:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
plugin_manager action=install_bundle target=<absolute path to this folder>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The bundle inserts one Host row (id `dsh-remote-mobile`, package
|
|
102
|
+
`@deep-podder/dsh-remote-mobile`) and one Client module. Enabling or disabling the row is the
|
|
103
|
+
on/off switch; `config.enabled: false` skips starting the phone server entirely.
|
|
104
|
+
|
|
105
|
+
## Pairing quick start
|
|
106
|
+
|
|
107
|
+
1. The Host generates a **4-digit PIN** (5 minutes) and a one-time **pairing token** (10
|
|
108
|
+
minutes) at startup and after every successful pair.
|
|
109
|
+
2. Open **Settings → Remote mobile access** in the desktop Web UI. The panel shows a QR code
|
|
110
|
+
for `http://<lan-ip>:3456/?t=<token>`, the PIN, the address and paired devices. When the
|
|
111
|
+
machine has several interfaces (Wi-Fi, hotspot, Tailscale, WSL) each is offered as a
|
|
112
|
+
selectable chip and the QR follows the selected one.
|
|
113
|
+
3. Scan the QR with the phone, or open the address and enter the PIN.
|
|
114
|
+
4. Pairing mints an `HttpOnly`, `SameSite=Lax` signed cookie (30 days, `Secure` only over
|
|
115
|
+
TLS). Unauthenticated WebSocket upgrades are refused.
|
|
116
|
+
|
|
117
|
+
PIN attempts are rate limited per client address: 5 failures in 5 minutes → `429` with a
|
|
118
|
+
retry delay. PINs and tokens are never logged.
|
|
119
|
+
|
|
120
|
+
### Tailscale (recommended off-LAN)
|
|
121
|
+
|
|
122
|
+
Two options:
|
|
123
|
+
|
|
124
|
+
- **Plain tailnet IP** — sign in on both devices, pick the `100.x.y.z` chip in the panel.
|
|
125
|
+
There is no public exposure.
|
|
126
|
+
- **Tailscale Serve (HTTPS, no inbound port)** — run
|
|
127
|
+
`tailscale serve --bg --https=8443 http://127.0.0.1:3456` once, then write that URL to
|
|
128
|
+
`$DSH_HOME/remote-mobile-state.json.public-url` (or set
|
|
129
|
+
`PA_REMOTE_MOBILE_PUBLIC_URL=https://<node>.<tailnet>.ts.net:8443`) and restart the plugin.
|
|
130
|
+
The panel advertises that HTTPS URL, the QR encodes it, the cookie is issued over TLS, and
|
|
131
|
+
the service worker, app lock and background Web Push become available. Serve proxies both
|
|
132
|
+
HTTP and the WebSocket.
|
|
133
|
+
|
|
134
|
+
## Configuration
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
- id: dsh-remote-mobile
|
|
138
|
+
name: 'dsh-remote-mobile'
|
|
139
|
+
config:
|
|
140
|
+
enabled: true # false unloads the server and the desktop pairing panel
|
|
141
|
+
host: '0.0.0.0' # bind all interfaces so LAN/Tailscale devices can reach it
|
|
142
|
+
port: 3456 # 0 picks a free port
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Environment overrides (all optional):
|
|
146
|
+
|
|
147
|
+
| Variable | Meaning |
|
|
148
|
+
|---|---|
|
|
149
|
+
| `PA_REMOTE_MOBILE_PUBLIC_URL` | HTTPS origin advertised by the pairing panel/QR when a reverse proxy (Tailscale Serve) fronts the server. |
|
|
150
|
+
| `PA_REMOTE_MOBILE_PUSH_HOSTS` | Comma-separated extra push-service host suffixes for a self-hosted relay. Known provider hosts (FCM/APNs/Mozilla/WNS) are always accepted; arbitrary endpoints are refused. |
|
|
151
|
+
| `PA_REMOTE_MOBILE_VAPID_SUBJECT` | VAPID `sub` contact sent to the push service (defaults to a placeholder `mailto:`; set a real contact for a long-lived deployment). |
|
|
152
|
+
|
|
153
|
+
The pairing panel's **Remote access** switch closes/reopens the listener and every mobile
|
|
154
|
+
WebSocket without discarding paired devices or the bridge. The choice persists in
|
|
155
|
+
`$DSH_HOME/remote-mobile-state.json.enabled`. Turning it off while a phone is connected asks
|
|
156
|
+
for confirmation first.
|
|
157
|
+
|
|
158
|
+
State lives in `$DSH_HOME/remote-mobile-state.json` (mode 0600), falling back to
|
|
159
|
+
`~/.dsh/remote-mobile-state.json` when a desktop-launched Host does not export `DSH_HOME`. The
|
|
160
|
+
same file holds the VAPID key pair and the per-device push subscriptions under `push`; the
|
|
161
|
+
private key never leaves that file, and unpairing/revoking a device deletes its subscriptions.
|
|
162
|
+
A per-process desk key is written beside it as `remote-mobile-state.json.desk-key` so local
|
|
163
|
+
tooling can read pairing status; the key alone grants nothing over the network. When no state
|
|
164
|
+
directory exists the plugin runs memory-only.
|
|
165
|
+
|
|
166
|
+
## Security
|
|
167
|
+
|
|
168
|
+
Pairing is the trust boundary: a paired phone is treated as the same user as the desktop. Use
|
|
169
|
+
a trusted LAN or a tailnet, and do not expose the mobile port to the public internet. The full
|
|
170
|
+
threat model, cookie/approval rules, LAN HTTP risks, upload containment and the
|
|
171
|
+
revoke/rotate procedures are in [SECURITY.md](SECURITY.md).
|
|
172
|
+
|
|
173
|
+
Highlights:
|
|
174
|
+
|
|
175
|
+
- One-time token/PIN pairing, HMAC-signed `HttpOnly` cookie, constant-time secret comparison,
|
|
176
|
+
per-address PIN rate limiting.
|
|
177
|
+
- Desktop pairing data only answers a loopback peer or the per-process desk key; remote
|
|
178
|
+
origins get `403`.
|
|
179
|
+
- Approval routing is exclusive to the connected phone, with a desktop dock on the same
|
|
180
|
+
pending list; first answer wins, and a device marked `canApprove: false` cannot answer.
|
|
181
|
+
- Uploads are capped at 32 MiB and confined to the session's
|
|
182
|
+
`var/remote-mobile-uploads`; previews refuse arbitrary paths.
|
|
183
|
+
- The phone server serves a strict CSP, `nosniff`, referrer/permissions headers and no
|
|
184
|
+
third-party assets.
|
|
185
|
+
|
|
186
|
+
## Known limitations
|
|
187
|
+
|
|
188
|
+
- **Approval routing is exclusive to whichever side is attached.** While a phone client is
|
|
189
|
+
connected the phone answers Host approval requests (the desktop gets a plugin-rendered dock
|
|
190
|
+
on the same pending list, so either device can answer and the first answer clears both).
|
|
191
|
+
With no phone connected, requests go straight to the shipped desktop answerer.
|
|
192
|
+
- **Questions have a narrower safety net.** While a phone is connected it is the exclusive
|
|
193
|
+
answerer, like approvals. If no phone is connected when a question is asked, the bridge
|
|
194
|
+
waits up to 45 seconds for a phone to (re)connect, then hands the question to the desktop
|
|
195
|
+
card. A phone that disconnects after receiving a question does not trigger that handoff.
|
|
196
|
+
- **Content search depends on the deployment.** When the Host disables its session-query
|
|
197
|
+
index, `sessions.search` reports `unavailable` and the phone falls back to filtering the
|
|
198
|
+
loaded session list; the UI hides search where the deployment reports it disabled.
|
|
199
|
+
- **File diffs are live-process only.** Change summaries live in Host memory for recorded
|
|
200
|
+
sessions; after a Host restart or for a cold/foreign session the phone shows "diff
|
|
201
|
+
unavailable" while the durable event stays listed.
|
|
202
|
+
- **The command palette mirrors the live Agent registry.** Commands are read from the Host
|
|
203
|
+
registry mounted for the session's Agent preset (so a preset that omits a command hides it
|
|
204
|
+
here too), and only live sessions can list or run them — a cold session answers
|
|
205
|
+
`available:false`. Two commands stay desktop-only: `/export` (the ZIP is produced by a
|
|
206
|
+
browser-authenticated Host route) and `/permission` (it switches the sandbox/approval preset,
|
|
207
|
+
including `danger-full-access`, so it must not be changed from a device that may itself lack
|
|
208
|
+
approval rights). Commands that accept attachments are run without attachments from the
|
|
209
|
+
phone; use the composer for files.
|
|
210
|
+
- **Background notifications need a secure context, permission and a browser push service.**
|
|
211
|
+
Web Push works over HTTPS (Tailscale Serve or a trusted TLS proxy) or `localhost`; plain-HTTP
|
|
212
|
+
LAN access has no service worker. The user must grant notification permission once, and the
|
|
213
|
+
phone must have a working browser push service (FCM on most Android builds, Apple push on
|
|
214
|
+
iOS 16.4+ installed web apps; known provider hosts are required — self-hosted relays opt in
|
|
215
|
+
with `PA_REMOTE_MOBILE_PUSH_HOSTS`). Subscriptions expire and the SPA re-subscribes on start.
|
|
216
|
+
While any phone page is in the foreground the Host sends no push; delivery is capped at
|
|
217
|
+
~30/min and deduplicated by tag. A finished-reply push carries the session title plus the
|
|
218
|
+
first ~150 characters of the assistant reply, so lock-screen notifications can show
|
|
219
|
+
conversation content — approval/question pushes are bounded and secret-scrubbed, and the
|
|
220
|
+
reply excerpt is flattened plain text.
|
|
221
|
+
- **The app lock is a client-side deterrent, not server enforcement.** WebAuthn needs a
|
|
222
|
+
secure context (Tailscale Serve HTTPS or localhost). A determined attacker with the unlocked
|
|
223
|
+
phone and developer tools can bypass the JS gate; the authoritative protection is the
|
|
224
|
+
paired-device cookie plus desktop revoke.
|
|
225
|
+
- **Image inlining has limits** (byte/dimension/count caps advertised by the Host,
|
|
226
|
+
png/jpeg/webp/gif only). Unsupported or unreadable images degrade to file-path attachments
|
|
227
|
+
so a send never fails.
|
|
228
|
+
- **The phone cannot delete or reorder sessions**, and there is no terminal, file browser,
|
|
229
|
+
plugin manager or settings editor — the phone covers the conversation surface, not the
|
|
230
|
+
whole desktop application.
|
|
231
|
+
- **Single Harness Host**: one process, one mobile server; multiple phones share the same
|
|
232
|
+
session set.
|
|
233
|
+
- **Plain HTTP on the LAN is not private.** Use Tailscale, a trusted Wi-Fi network, or TLS in
|
|
234
|
+
front of the port.
|
|
235
|
+
- **Unpaired clients can read `/api/health` and `/api/state`** (version and
|
|
236
|
+
paired/not-paired state only; no secrets).
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
All checks are deterministic and run without a Host unless labelled *live*:
|
|
241
|
+
|
|
242
|
+
```text
|
|
243
|
+
node --check server.js && node --check bridge.js && node --check auth.js
|
|
244
|
+
node --check index.js && node --check client.js && node --check qr.js && node --check push.js
|
|
245
|
+
node dev/server-smoke.mjs # transport: pairing, cookies, rate limit, desktop API, WS, approvals, push surface
|
|
246
|
+
node dev/push-check.mjs # Web Push wire proof: RFC 8291 Appendix A vector, VAPID JWT verify, aes128gcm decrypt, pruning, caps, logs
|
|
247
|
+
node dev/static-check.mjs # served SPA files, headers/CSP, PWA surface, share target
|
|
248
|
+
node dev/client-check.mjs # executes the browser half against a fake loader/React shim
|
|
249
|
+
node dev/desk-auth-check.mjs # desktop endpoint loopback/key policy and same-origin route
|
|
250
|
+
node dev/toggle-check.mjs # on/off switch closes and reopens the listener
|
|
251
|
+
node dev/changes-bridge-check.mjs# context meter, changed files/diffs, command palette, project mapping
|
|
252
|
+
node dev/spa-check.mjs # SPA helper/id/version consistency (reads mobile/)
|
|
253
|
+
node dev/release-check.mjs # package files completeness + public-release invariants
|
|
254
|
+
node dev/ui-check.mjs # live: project grouping, archived filter, command palette (headless Chrome)
|
|
255
|
+
node dev/capture-screenshots.mjs # regenerates docs/screenshots from the mock server (headless Chrome)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`dev/*-live.mjs` scripts pair a real device and create sessions against an installed plugin;
|
|
259
|
+
they are manual probes for a development Host, not CI checks, and they must not be run
|
|
260
|
+
against a Host you are not prepared to mutate. `dev/model-effort-live.mjs` additionally
|
|
261
|
+
verifies the reasoning-effort catalog/selection round-trip without spending model tokens.
|
|
262
|
+
`dev/ui-check.mjs` is a live check too: it pairs a temporary device, installs its cookie in
|
|
263
|
+
headless Chrome, and asserts the project-grouped Sessions sheet, the archived filter and the
|
|
264
|
+
command palette end to end (it needs the installed plugin and Chrome; `CHROME_PATH` and
|
|
265
|
+
`CDP_PORT` override the defaults, and it revokes its device afterwards).
|
|
266
|
+
|
|
267
|
+
Web Push has also been confirmed on hardware: with the plugin installed and the phone
|
|
268
|
+
backgrounded, `POST /api/push/test` delivered through FCM, the service worker reported
|
|
269
|
+
`push-shown` in the Host debug log, and the notification appeared on the phone. The
|
|
270
|
+
`aes128gcm` body is pinned byte-for-byte against the RFC 8291 Appendix A vector so an
|
|
271
|
+
interoperable-but-wrong encryption cannot regress silently.
|
|
272
|
+
|
|
273
|
+
`mobile/mock-server.js` is a development-only mock of the phone API and WebSocket protocol,
|
|
274
|
+
useful when iterating on the SPA without DSH. It mirrors the current (v20) `workspaces`,
|
|
275
|
+
`workspaceId` and command-palette frames, so the project-grouped sessions sheet and the
|
|
276
|
+
Commands sheet can be exercised without a Host. `node dev/capture-screenshots.mjs` drives that
|
|
277
|
+
mock in headless Chrome and refreshes the images above.
|
|
278
|
+
|
|
279
|
+
## Releasing
|
|
280
|
+
|
|
281
|
+
The package publishes publicly to npm as
|
|
282
|
+
[`@deep-podder/dsh-remote-mobile`](https://www.npmjs.com/package/@deep-podder/dsh-remote-mobile)
|
|
283
|
+
(`publishConfig.access: public`). Before `npm publish`:
|
|
284
|
+
|
|
285
|
+
1. `node dev/release-check.mjs` — verifies the `files` list covers every runtime asset,
|
|
286
|
+
`README` screenshots are present, the version agrees everywhere, `/permission` stays
|
|
287
|
+
hidden from the phone, and no personal paths leak into published files.
|
|
288
|
+
2. `npm pack --dry-run` — review the tarball contents.
|
|
289
|
+
3. `npm login` (once) and `npm publish` from this folder. The package has no build step and
|
|
290
|
+
no dependencies, so the published files are the tracked source.
|
|
291
|
+
|
|
292
|
+
Version bumps touch `package.json`, `index.js`, `server.js`, `mobile/app.js`
|
|
293
|
+
(`FALLBACK_VERSION`) and the PROTOCOL example; `release-check` enforces that they agree.
|
|
294
|
+
|
|
295
|
+
## Documentation
|
|
296
|
+
|
|
297
|
+
- [npm package](https://www.npmjs.com/package/@deep-podder/dsh-remote-mobile) ·
|
|
298
|
+
[source on GitHub](https://github.com/unknown-spec10/dsg-remote-mobile) ·
|
|
299
|
+
[issues](https://github.com/unknown-spec10/dsg-remote-mobile/issues)
|
|
300
|
+
- [PROTOCOL.md](PROTOCOL.md) — authoritative HTTP/WebSocket wire contract.
|
|
301
|
+
- [SECURITY.md](SECURITY.md) — threat model and revocation/rotation procedures; report
|
|
302
|
+
vulnerabilities through the repository's private advisory form.
|
|
303
|
+
- [docs/api-notes.md](docs/api-notes.md) — verified DeepSeek Harness Host API notes behind the
|
|
304
|
+
bridge (v1 surface).
|
|
305
|
+
- [docs/api-notes-v2.md](docs/api-notes-v2.md) — the v2 feature-API research (session
|
|
306
|
+
management, queue, diffs, context, commands, attachments).
|
|
307
|
+
- [docs/verification.md](docs/verification.md) — internal maintainer verification log kept for
|
|
308
|
+
release evidence; not part of the public contract.
|
|
309
|
+
- [mobile/README.md](mobile/README.md) — mobile SPA implementation notes and design decisions.
|
|
310
|
+
|
|
311
|
+
## License
|
|
312
|
+
|
|
313
|
+
MIT — see [LICENSE](LICENSE). The vendored QR encoder is MIT (Kazuhiko Arase), attribution in
|
|
314
|
+
`vendor/LICENSE`.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Security model
|
|
2
|
+
|
|
3
|
+
`dsh-remote-mobile` lets a phone browser drive a DeepSeek Harness Host over the local
|
|
4
|
+
network. That is a deliberately powerful capability: a paired phone can read a session's
|
|
5
|
+
transcript, send prompts and answer tool approvals. This document states the trust
|
|
6
|
+
boundary, what is and is not protected, and how to revoke access.
|
|
7
|
+
|
|
8
|
+
## Threat model
|
|
9
|
+
|
|
10
|
+
**Trusted:** the paired device and the person using it. Pairing is the security boundary.
|
|
11
|
+
Once a device pairs it is treated as the same user as the desktop Host: it can read the
|
|
12
|
+
session list/history it opens, send prompts, run the Host commands registered for the live
|
|
13
|
+
Agent (the same palette the desktop offers, minus the desktop-only `/export` download),
|
|
14
|
+
answer approvals (unless the desktop restricts that device) and upload files into the session
|
|
15
|
+
directory.
|
|
16
|
+
|
|
17
|
+
**Untrusted:** every other network peer, and any web page the phone or desktop browser
|
|
18
|
+
visits. The server never accepts commands from an unpaired peer; remote origins cannot read
|
|
19
|
+
the desktop pairing data.
|
|
20
|
+
|
|
21
|
+
The design targets a single user on a trusted LAN or a private tailnet, not an
|
|
22
|
+
internet-exposed multi-tenant service. Do not port-forward the mobile port from the public
|
|
23
|
+
internet.
|
|
24
|
+
|
|
25
|
+
## Authentication and secrets
|
|
26
|
+
|
|
27
|
+
- **Pairing.** Two ephemeral secrets exist per Host process: a one-time pairing **token**
|
|
28
|
+
(192-bit, 10 minutes, embedded in the QR URL) and a 4-digit **PIN** (5 minutes). A valid
|
|
29
|
+
token or PIN creates a device record and rotates both secrets. Pairing is the only way in.
|
|
30
|
+
- **Session cookie.** Pairing returns `dsh_rm_session`, an HMAC-SHA256 signed value of
|
|
31
|
+
`deviceId|expiry|signature` (30 days). It is `HttpOnly`, `SameSite=Lax`, `Path=/`, and
|
|
32
|
+
`Secure` when the request arrived over TLS. The cookie-signing secret is generated once and
|
|
33
|
+
persisted in `$DSH_HOME/remote-mobile-state.json` (created with mode 0600; Windows relies on
|
|
34
|
+
the per-user profile ACL instead of POSIX modes) so devices survive a restart.
|
|
35
|
+
- **Constant-time comparisons** are used for the pairing token, the PIN and the cookie
|
|
36
|
+
signature. PIN attempts are rate-limited per client address (5 failures in 5 minutes →
|
|
37
|
+
`429` with `retryAfterMs`); token attempts are not rate-limited because the token is a
|
|
38
|
+
192-bit random value.
|
|
39
|
+
- **Desktop pairing data.** The panel endpoint (`/api/desktop/*`,
|
|
40
|
+
`/remote-mobile/pairing/*`) exposes the PIN, pairing token, QR SVG and device list. It
|
|
41
|
+
answers only a loopback TCP peer, or a request carrying the per-process desk key written to
|
|
42
|
+
`$DSH_HOME/remote-mobile-state.json.desk-key` (0600). Remote origins get `403` even when
|
|
43
|
+
the request originates on the same machine.
|
|
44
|
+
- **No secret logging.** PINs, tokens, cookies and the desk key are never written to a log.
|
|
45
|
+
The optional request trail (`*.debug.log`, `*.access.log`, both mode 0600) records request
|
|
46
|
+
metadata (method, path, origin, Host header, peer address, user agent, allowed/denied
|
|
47
|
+
outcomes), pairing device names, approval/push event identifiers and the bounded
|
|
48
|
+
`POST /api/push/report` diagnostics line. Client-supplied diagnostic fields are collapsed to
|
|
49
|
+
a single bounded line; no transcript text, prompt, tool argument, cookie or key is logged.
|
|
50
|
+
|
|
51
|
+
## Approvals
|
|
52
|
+
|
|
53
|
+
Approvals are the highest-value interaction: approving a sandbox escalation can run a host
|
|
54
|
+
command. The rules are:
|
|
55
|
+
|
|
56
|
+
- While a phone is connected, the phone is the **exclusive answerer** for Host approval
|
|
57
|
+
requests; with no phone connected the request goes to the shipped desktop answerer. This
|
|
58
|
+
prevents a stale duplicate card on one surface after the other answered.
|
|
59
|
+
- The desktop approval dock polls the same pending list, so the desktop can still answer a
|
|
60
|
+
request the phone received. **First answer wins**; the other surface is cleared by the
|
|
61
|
+
`approval.resolved` frame (`by: "phone" | "desktop"`).
|
|
62
|
+
- Each paired device has a `canApprove` flag (default `true`, persisted). A restricted device
|
|
63
|
+
receives `{"type":"error","code":"forbidden"}` and the answer never reaches the bridge.
|
|
64
|
+
Restrict a device when it is used by someone who should read the conversation and chat but
|
|
65
|
+
not grant approvals. The restriction is not a read-only mode: a restricted phone can still
|
|
66
|
+
send prompts and run benign Host commands. It cannot widen its own sandbox either — the
|
|
67
|
+
policy-changing `/permission` command and the desktop-only `/export` are hidden from the
|
|
68
|
+
phone command palette and refused by the bridge, so a restricted device can never turn off
|
|
69
|
+
the approval gate it is not allowed to answer.
|
|
70
|
+
- Approval cards show a bounded, secret-scrubbed preview of the tool call when the bridge saw
|
|
71
|
+
it. Values whose argument key looks like a password/secret/token/key/credential are never
|
|
72
|
+
cached or displayed.
|
|
73
|
+
- Only `allowed-once`, `rejected`, `cancelled` and `unavailable` exist; there is no
|
|
74
|
+
always-allow grant. The Host's `ask | never` policy decides whether a request is raised at
|
|
75
|
+
all.
|
|
76
|
+
|
|
77
|
+
## App lock is client-side
|
|
78
|
+
|
|
79
|
+
The optional biometric app lock (WebAuthn platform passkey) is a **client-side privacy gate**
|
|
80
|
+
over an already authenticated session. It is not server enforcement and cannot be: the
|
|
81
|
+
authoritative credential is the pairing cookie. An attacker holding the unlocked phone and
|
|
82
|
+
developer tools can bypass the JS gate. Its purpose is to keep a shoulder-surfer or a briefly
|
|
83
|
+
unattended phone out of the app. It requires a secure context (HTTPS or localhost); over
|
|
84
|
+
plain HTTP the switch is unavailable. The recovery path is to revoke the device on the
|
|
85
|
+
desktop.
|
|
86
|
+
|
|
87
|
+
## Network exposure
|
|
88
|
+
|
|
89
|
+
- The default bind is `0.0.0.0:3456` so LAN and tailnet devices can reach it. Plain HTTP
|
|
90
|
+
means the cookie and transcript are readable by anyone who can observe that traffic. Use
|
|
91
|
+
it only on a network you trust.
|
|
92
|
+
- **Recommended: Tailscale.** Either use the `100.x` tailnet address (traffic is encrypted by
|
|
93
|
+
WireGuard) or terminate HTTPS in front of the port with Tailscale Serve. HTTPS is also
|
|
94
|
+
required for the service worker, installation and the app-lock switch.
|
|
95
|
+
- If you terminate TLS yourself, forward `X-Forwarded-Proto: https` so the cookie is marked
|
|
96
|
+
`Secure`, and bind the Node server to loopback where possible. The server trusts that
|
|
97
|
+
header; a direct client can only make its own cookie stricter, not weaker.
|
|
98
|
+
- WebSocket upgrades require the cookie. When an `Origin` header is present it must match the
|
|
99
|
+
request `Host`, which blocks cross-site WebSocket hijacking.
|
|
100
|
+
|
|
101
|
+
## What an attacker on the LAN can still do
|
|
102
|
+
|
|
103
|
+
- Reach `/api/health` and `/api/state` (unauthenticated by design; they expose version and
|
|
104
|
+
paired/not-paired state, never a secret). Without a valid cookie `/api/state` returns
|
|
105
|
+
`device: null`; with one it returns that device's own summary (name and approval flag).
|
|
106
|
+
- Attempt PIN guessing: 10,000 combinations against a 5-minute window, with per-address
|
|
107
|
+
lockout. A distributed attacker with many source addresses on the same LAN could still try;
|
|
108
|
+
this is why the port should not be exposed to an untrusted network. Token pairing is not
|
|
109
|
+
brute-forceable.
|
|
110
|
+
- Copy or replay the session cookie if it can read it (HTTP, or a TLS-terminating proxy it
|
|
111
|
+
controls). Revocation is the only mitigation, so keep the listen port private.
|
|
112
|
+
- A sandboxed `Origin: null` page running in a browser on the Host machine can read the
|
|
113
|
+
loopback desktop pairing endpoint (this is what lets the Electron `file://` client panel
|
|
114
|
+
work). It cannot reach the cookie-protected phone API without a paired cookie. Treat
|
|
115
|
+
untrusted local web content on the Host machine as a risk.
|
|
116
|
+
|
|
117
|
+
## Uploads and previews
|
|
118
|
+
|
|
119
|
+
- `POST /api/upload` is cookie-authenticated and capped at 32 MiB per request; JSON request
|
|
120
|
+
bodies are capped at 64 KiB.
|
|
121
|
+
- Uploads are written under `<session workspace>/var/remote-mobile-uploads/` with the file
|
|
122
|
+
name sanitised to `[\w.\- ]` and a timestamp prefix, so a name cannot traverse the
|
|
123
|
+
filesystem.
|
|
124
|
+
- `GET /api/preview` and inline-image delivery re-resolve the requested path and refuse
|
|
125
|
+
anything outside that directory, with an image extension and within the preview byte cap.
|
|
126
|
+
They never serve an arbitrary host file.
|
|
127
|
+
- Tool output, error text and changed-file paths sent to the phone are truncated and
|
|
128
|
+
path-redacted; tool arguments are shown to the paired device by design (the approval card
|
|
129
|
+
is useless without them) unless the bridge is created with `redactPaths: true`.
|
|
130
|
+
|
|
131
|
+
## Web Push
|
|
132
|
+
|
|
133
|
+
Background notifications use standard Web Push: the Host holds a VAPID (P-256) key pair, the
|
|
134
|
+
phone's service worker registers a browser push subscription, and the Host encrypts each
|
|
135
|
+
payload to that subscription (RFC 8291 `aes128gcm`). Consequences:
|
|
136
|
+
|
|
137
|
+
- **Per-device and revocable.** A subscription is bound to the paired device that registered
|
|
138
|
+
it. Unpairing, the desktop per-device *Revoke*, *Revoke all devices* and eviction by the
|
|
139
|
+
paired-device cap delete that device's subscriptions. The VAPID key pair is independent of
|
|
140
|
+
device revocation and lives until the state file is deleted.
|
|
141
|
+
- **The VAPID private key is a secret.** It lives only in memory and in
|
|
142
|
+
`$DSH_HOME/remote-mobile-state.json` (`push.vapid`, the same 0600 file as the cookie secret)
|
|
143
|
+
so notifications survive a Host restart. It is never logged and never returned by a route;
|
|
144
|
+
only the public key (`GET /api/push/key`) is exposed, which is exactly what the browser needs
|
|
145
|
+
for `applicationServerKey`.
|
|
146
|
+
- **Subscription endpoints and keys are stored locally.** The browser push endpoint URL and
|
|
147
|
+
the `p256dh`/`auth` subscription keys are persisted in the same 0600 file. They are delivery
|
|
148
|
+
capabilities for that browser, not read access to the session; revoking the device removes
|
|
149
|
+
them, and a device can only unsubscribe its own endpoint.
|
|
150
|
+
- **Payloads are bounded and scrubbed.** A push carries a kind, a title, ≤160 characters of
|
|
151
|
+
body, a tag, the session id and an app URL — never tool output, tool arguments or secrets.
|
|
152
|
+
Control characters are stripped, secret-looking `key=value` pairs are redacted and
|
|
153
|
+
approval/question text is truncated like an approval card. A finished-reply notification
|
|
154
|
+
additionally carries a flattened excerpt (≤150 characters) of the assistant's reply, which is
|
|
155
|
+
conversation content rendered by the lock screen — treat lock-screen previews of this app like
|
|
156
|
+
any messaging app's, and turn the notification category off on the phone if that is not
|
|
157
|
+
acceptable. A notification carries no buttons that could answer an approval.
|
|
158
|
+
- **Delivery is best-effort and foreground-aware.** Payload TTL is 300 s; delivery is capped at
|
|
159
|
+
~30/minute process-wide, deduplicated by tag for 5 minutes and skipped entirely while any
|
|
160
|
+
phone page reports itself visible or the desktop **Remote access** switch is off (the
|
|
161
|
+
subscriptions are kept in the latter case). The explicit **Send test notification** action is
|
|
162
|
+
exempt from the foreground gate by design but has its own per-device rate limit (6/minute) and
|
|
163
|
+
never returns the push service's response body. A failure (offline phone, expired
|
|
164
|
+
subscription, push service error, 404/410) never affects the WebSocket path or the transcript;
|
|
165
|
+
404/410 prunes the subscription.
|
|
166
|
+
- **Only known push services are contacted.** Subscription endpoints must be `https:` and use a
|
|
167
|
+
known browser push provider (FCM, Mozilla autopush, Windows WNS, Apple push), or a suffix the
|
|
168
|
+
operator configured with `PA_REMOTE_MOBILE_PUSH_HOSTS`. Anything else is refused when the
|
|
169
|
+
phone registers it and when a saved subscription is restored, so a paired device cannot turn
|
|
170
|
+
the Host into a request proxy to an arbitrary host.
|
|
171
|
+
- **The push endpoint is the browser vendor's service** (FCM on Android, Apple push for
|
|
172
|
+
installed iOS web apps). A notification travels from the Host to that service and then to the
|
|
173
|
+
device; the payload is encrypted to the subscription by design, while delivery metadata
|
|
174
|
+
(endpoint, timing) is visible to the push service as with any web push.
|
|
175
|
+
|
|
176
|
+
## Revoking and rotating
|
|
177
|
+
|
|
178
|
+
- **Revoke one device:** desktop panel → *Remote mobile access* → device row → *Revoke*, or
|
|
179
|
+
`POST /api/desktop/revoke` with `{ "deviceId": "..." }`. Its socket is closed immediately,
|
|
180
|
+
its push subscriptions are deleted and every outstanding pairing token/PIN is rotated.
|
|
181
|
+
- **Revoke everything:** *Revoke all devices* (or `{ "all": true }`). All sockets close, all
|
|
182
|
+
push subscriptions are deleted and all pairing material rotates, so a saved `?t=` QR link
|
|
183
|
+
cannot re-pair.
|
|
184
|
+
- **Unpair from the phone:** `POST /api/unpair` revokes the calling device (and its push
|
|
185
|
+
subscriptions), rotates the pairing material and clears the cookie.
|
|
186
|
+
- **Delete `$DSH_HOME/remote-mobile-state.json`** while the plugin is stopped to forget every
|
|
187
|
+
device and the VAPID key pair; a new signing secret and VAPID pair are generated on the next
|
|
188
|
+
start, so every old cookie is dead and old push subscriptions must re-subscribe.
|
|
189
|
+
- **Turn access off** with the desktop switch: the listener and all phone sockets close;
|
|
190
|
+
the on/off choice and paired devices persist.
|
|
191
|
+
|
|
192
|
+
## Releasing / sharing a build
|
|
193
|
+
|
|
194
|
+
Before publishing a bundle, confirm `node dev/release-check.mjs` passes: it asserts the
|
|
195
|
+
package `files` list covers every runtime asset, `LICENSE`/`SECURITY.md` exist, every published
|
|
196
|
+
file is free of the build machine's personal paths, the version is consistent across the
|
|
197
|
+
package, Host constants, SPA fallback and PROTOCOL example, the phone cannot reach the
|
|
198
|
+
policy-changing `/permission` command, and the removed `/api/client-error` endpoint is not
|
|
199
|
+
referenced anywhere. Run the deterministic checks in `README.md`; live-pairing checks
|
|
200
|
+
(`dev/*-live.mjs`) touch a real Host.
|
|
201
|
+
|
|
202
|
+
## Reporting a vulnerability
|
|
203
|
+
|
|
204
|
+
Use the repository's private vulnerability reporting form
|
|
205
|
+
(https://github.com/unknown-spec10/dsg-remote-mobile/security/advisories/new) rather than a
|
|
206
|
+
public issue. Include the plugin version, the Harness version, and a minimal reproduction. Do
|
|
207
|
+
not attach real session transcripts or pairing data.
|