Repository navigation
feat: use a phone for navigation and text input over the local network - #226
Merged
Merged
Conversation
Menu > Conectar celular shows a QR code for a short-lived, single-use pairing session. The phone opens a page served by ControlFS (no app, no cloud), the PC shows the phone's IP and a verification code and asks to allow it, then the phone sends semantic actions and text for the focused on-screen keyboard field over an AES-256-GCM encrypted WebSocket. Closes #223 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… parser Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Menu → Conectar celular… starts a pairing session and shows a QR code. The phone opens a page served by ControlFS itself (no app install, no cloud, no relay). The PC shows the phone's IP and a 6-digit code (the phone shows the same one) and the user must Permitir on the PC. After that the phone sends semantic
InputActions and text for the focused on-screen keyboard field. Menu → Desconectar celular (or Desconectar on the phone) ends it.Security design (shipped)
TcpListenerexists only during a user-started session: bound to one private LAN IPv4 (RFC 1918; never0.0.0.0, loopback, link-local or public), random high port, exclusive address use. It stops listening as soon as a phone authenticates. Everything closes on Cancel/Refuse/Disconnect (PC or phone), 2 min unused, 2 min unconfirmed, connection loss (WebSocket keep-alive 5 s / 15 s timeout) and app exit. No auto-reconnect: a new QR is needed.HttpRequestParser) for exactly two routes,GET /<sid>(page) andGET /<sid>/ws(upgrade). GET only, no body, ASCII/CRLF only, ≤ 4 KB head, ≤ 32 headers, 5 s head timeout, duplicate headers refused. ExactHost(ip:port, DNS-rebinding defence) and exactOriginfor the WebSocket. Only private-LAN peers; ≤ 4 concurrent TCP connections. ThenWebSocket.CreateFromStream(isServer: true).#k=…, never sent; the page strips it from the address bar) plus a random 128-bit session id in the path. HKDF-SHA256 (salt = session id) derives one key per direction. Each frame iscounter(8, BE) ‖ ciphertext ‖ tagwith nonce = counter, which must be exactly the next one; a replayed, reordered, tampered or wrong-direction frame closes the connection on the first failure. Keys are zeroed on close. Single use: the first authenticated connection owns the key (≤ 2 concurrent handshakes, 8 failures end the session).TypeText,TypeBackspace, OK). Unknown/extra-field/oversized messages are rejected. Rate limit 30/s (burst 60). While a sensitive confirmation is open (delete, replace, undo, mapping), the phone can only send Back. Phone presses are discrete: repeat happens on the phone, so a lost connection leaves no held or repeating state on the PC.connect-src ws://ip:port,no-store,no-referrer,nosniff,DENYframing.docs/security-model.md): the page is plain HTTP on the LAN, so an active LAN attacker could tamper with it. Mitigated by short lifetime, single use, IP + code confirmation on the PC, and the limited action set; not for untrusted networks.Deviations from the requested design
ChaCha20Poly1305needs Windows 10 build 20142+ / Windows 11, and ControlFS supports Windows 10 2004 (19041).AesGcmis OS-backed (CNG) on every supported version. Same frame format and nonce/counter rules; the phone uses@noble/ciphersgcm.Core/Remote/QrCode.cs, byte mode, ECC M, v1–10, following Project Nayuki's MIT reference structure). QRCoder's net6 asset pulls inSystem.Drawing.Common, which isn't worth it. Validated during development by decoding generated codes for every version 1–10 with jsQR.Dependencies / licenses
@noble/ciphers2.4.0 +@noble/hashes2.4.0 (MIT): only AES-GCM, HKDF and SHA-256, bundled and minified with esbuild intoInfrastructure.Remote/Companion/noble-ciphers.min.jswith both license texts at the top. Recipe inTHIRD_PARTY_NOTICES.md. No new NuGet packages; the new projectControlFS.Infrastructure.Remotedepends only on Core.Tests
CI (this PR):
PhoneChannelTests: HTTP parser limits; RFC 6455 accept; key derivation, code and frames cross-checked against vectors produced by the page's noble bundle; tamper, replay, reorder and wrong-direction rejection; session expiry, single use, second connection refused, confirmation required, confirmation timeout, rate limit, too many failures; message → InputAction mapping plus rejection of unknown, extra, oversized and control-char input.PhoneJourneyTests: menu → QR dialog → permission → phone actions and text on the on-screen keyboard → sensitive delete dialog accepts only Back → Menu → Desconectar celular; stale sessions ignored; phone loss closes the dialogs.PhoneLinkIntegrationTests(Windows): real listener on 127.0.0.1, page GET with CSP, foreign Origin refused,ClientWebSocket"phone" deriving keys like the page, listener gone after authentication and a second phone refused, no input before Permitir, navigate/menu/text/backspace/enter reach theAppController, theendmessage on Disconnect and no listener on the port afterwards; tampered frame ends the session.m10-phone-pairing,m10b-phone-allow(fake link, no network).Also verified during development: the real server with the real page in headless Chromium at a phone viewport (pairing, matching code, buttons, text diffing, disconnect, port closed afterwards), and C#↔JS crypto interop.
Manual (not hardware-validated, listed in
docs/TESTING.md→ "Celular como controle (#223)"): real Android Chrome / iOS Safari, Windows Firewall prompt, QR readability at distance, IME/autocorrect typing, screen lock/network loss, multiple adapters.Docs: CHANGELOG pair, GUIDE pair, README pair (privacy line), PRIVACY, security-model, input-and-focus, ui-redesign (new row), TESTING, architecture, THIRD_PARTY_NOTICES.
Closes #223
🤖 Generated with Claude Code