Jarvis supports pairing a mobile device (iOS/Android) with a desktop instance to access terminal sessions remotely. The pairing uses QR codes for connection setup and end-to-end encryption for all terminal data.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dyoburon/jarvis/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The pairing flow establishes a secure, encrypted WebSocket connection between your mobile device and desktop through a relay server:jarvis-rs/crates/jarvis-app/src/app_state/ws_server/pairing.rsjarvis-mobile/lib/relay-connection.tsjarvis-mobile/lib/crypto.ts
QR Code Pairing Flow
Trigger Pairing
On the desktop, trigger the
PairMobile action from the command palette (or run the command).The desktop must have an active relay session. If not, one is created automatically.Generate QR Code
A pairing URL is constructed containing:
- Relay server WebSocket URL
- Session ID (32-character alphanumeric)
- Desktop’s ECDH public key (SPKI DER, base64, URL-encoded)
Display QR Code
The URL is encoded as a QR code using Unicode half-block characters (upper/lower half blocks for two-row compression) and displayed in the focused terminal pane:The raw URL is also shown for manual entry.
Scan with Mobile App
Open the Jarvis mobile app and scan the QR code. The app parses the pairing URL and extracts:
relay: Relay server URLsession: Session IDdhpub: Desktop’s ECDH public key
Connect to Relay
The mobile app connects to the relay server and sends
mobile_hello with the session ID.The relay responds with peer_connected to both sides.Key Exchange
Both sides perform ECDH key exchange:
-
Desktop (already has ephemeral ECDH keypair):
- Sends
KeyExchangeenvelope with DH public key (redundant since it’s in the QR code, but handles cases where QR didn’t include it)
- Sends
-
Mobile (generates ephemeral ECDH keypair):
- Derives shared secret using desktop’s DH public key
- Sends
KeyExchangeenvelope with its DH public key
-
Desktop:
- Derives shared secret using mobile’s DH public key
- Creates
RelayCipherwith shared AES-256 key
- Both sides now have the same AES-256-GCM key derived from ECDH
Key Exchange Details
Desktop Side (Rust)
jarvis-rs/crates/jarvis-platform/src/crypto.rs:419-450
Mobile Side (TypeScript)
jarvis-mobile/lib/crypto.ts:72-96
Both sides compute the same 32-byte AES-256 key by hashing the ECDH shared secret with SHA-256. This matches the Rust implementation.
Encryption and Decryption
Encrypt (Mobile)
Decrypt (Mobile)
Encrypt (Desktop)
Decrypt (Desktop)
Terminal Data Flow
Output (Desktop → Mobile)
Input (Mobile → Desktop)
Pairing Revocation
TheRevokeMobilePairing action invalidates the current pairing:
Clear State
MobileBroadcastercleared- Command and event receivers closed
- Cipher cleared
- Peer-connected flag reset
Delete Session ID
The persisted session ID file is deleted from disk (
~/.config/jarvis/relay_session_id).The old mobile device can no longer connect because the session ID has changed. A new QR code pairing is required.
Security Considerations
Ephemeral Keys
Each pairing generates a new ephemeral ECDH keypair on both sides. Keys are never persisted and exist only in memory for the duration of the session.Forward Secrecy
Because keys are ephemeral, past sessions cannot be decrypted even if a current session key is compromised.Downgrade Protection
Once encryption is established:Plaintextrelay envelopes are rejectedPeerDisconnectedmessages from the relay do not clear the cipher (prevents relay-initiated downgrade)- Cipher is only cleared on explicit revocation or disconnect
docs/manual/09-networking.md:548-553
QR Code Security
The QR code contains:- Relay URL (public, typically TLS-protected)
- Session ID (32 chars, 192 bits entropy when random)
- Desktop ECDH public key (public by design)
- Join the relay session
- Perform ECDH key exchange
- Access the terminal
- Display QR code only in the terminal (not saved to disk)
- Clear QR code from screen after successful pairing
- Use short-lived relay sessions (300s TTL for stale sessions)
- Revoke pairing when suspicious activity is detected
Relay Trust
The relay server:- Sees only encrypted data (cannot read PTY content)
- Can drop connections or send fake
peer_disconnected(handled by downgrade protection) - Can log connection metadata (IP addresses, session IDs, connection times)
- Cannot inject or modify encrypted payloads (AES-GCM provides authentication)
Mobile App Components
Terminal UI
components/CodeTerminal.tsx renders the terminal using TerminalWebView with xterm.js:
Connection Status
Pane Management
The mobile app supports multiple terminal panes:Configuration
Fromjarvis-rs/crates/jarvis-config/src/schema/relay.rs:
auto_connect = true to automatically connect to the relay on startup (desktop will be waiting for mobile to join).
Troubleshooting
QR Code Not Scanning
- Ensure adequate lighting and camera focus
- Try manual URL entry (copy-paste from desktop terminal)
- Check that the URL is complete (not truncated)
Connection Timeout
- Verify relay server is reachable from mobile network
- Check firewall rules (relay typically uses port 8080 or 443)
- Ensure session ID matches between desktop and mobile
Encryption Fails
- Verify desktop and mobile are using compatible crypto libraries
- Check that ECDH public keys are correctly base64-encoded
- Look for SPKI DER parsing errors in mobile logs
PTY Output Garbled
- Check terminal size matches (cols/rows)
- Ensure UTF-8 encoding on both sides
- Verify ANSI escape sequences are preserved