Architecture
jarvis://localhost/chat/index.html) and connects directly to Supabase Realtime. The Rust backend provides cryptographic operations via IPC but does not proxy chat traffic.
Source files:
jarvis-rs/assets/panels/chat/index.htmljarvis-rs/crates/jarvis-social/src/chat.rsjarvis-rs/crates/jarvis-platform/src/crypto.rs
Channels
Seven channels are pre-configured in the chat panel:| Channel ID | Display Name | Description |
|---|---|---|
jarvis-livechat | # general | Primary channel with presence tracking |
jarvis-livechat-discord | # discord | Discord community discussion |
jarvis-livechat-showoff | # showoff | Share your projects |
jarvis-livechat-help | # help | Technical support |
jarvis-livechat-random | # random | Off-topic conversation |
jarvis-livechat-games | # games | Gaming discussion and invites |
jarvis-livechat-memes | # memes | Memes and humor |
All channels are subscribed at startup so messages on background channels are buffered and unread counts are tracked. Channel switching is instant.
Message Structure
Standard Message
Encrypted DM
DM signatures are computed over
id|userId|nick|ts|iv|ct (the ciphertext), not plaintext, to prevent chosen-plaintext attacks on the signature oracle.Message Flow
Sending a Message
AutoMod Checks
Sender-side moderation runs:
- Keyword filter (banned words)
- Spam detection (repeated characters, duplicate messages)
- Rate limit (5 messages per 10 seconds)
Receiving a Message
AutoMod Validation
Receiver-side checks:
- Keyword filter on text and nickname
- Spam check (repeated character ratio, identical message history)
- Per-user rate limiting
TOFU Trust Check
The TOFU (Trust On First Use) store checks if the fingerprint matches the previously-seen identity for this nickname:
- β Verified: Signature valid, fingerprint matches or is new
- β οΈ Key Changed: Signature valid but fingerprint differs (possible impersonation)
- β Invalid: Signature verification failed
- β Unverified: No signature present
Chat History (Backend)
The Rust backend (jarvis-rs/crates/jarvis-social/src/chat.rs) provides an in-memory ring buffer for storing chat history:
Configuration
API
Direct Messages (DMs)
Users can open end-to-end encrypted DMs from the online users dropdown.Create DM Channel
A deterministic channel name is computed from both fingerprints (sorted, concatenated with
jarvis-dm- prefix):The relay server and Supabase backend see only ciphertext. Only the two DM participants can decrypt the messages.
Image Messages
Users can paste images (Ctrl+V) or drag-and-drop image files into the chat input.Image Processing
- Compression: Images are compressed via HTML canvas to JPEG at 0.5 quality, max width 300px
- Encoding: Produces a
data:image/jpeg;base64,...data URL - Sending: The data URL is sent as the
textfield of a normal message - Rendering: Images are rendered as
<img>elements with a click-to-lightbox viewer
Limits
| Parameter | Value |
|---|---|
MAX_IMAGE_LEN | 150,000 chars (~100 KB base64) |
IMAGE_MAX_WIDTH | 300 px |
IMAGE_QUALITY | 0.5 |
Reactions
Messages support emoji reactions. Reactions are broadcast as separatereaction events (unencrypted) with { msgId, emoji, userId, action }.
- A picker of 16 emoji is shown on hover
- Reactions are tracked per message in local history
- Persisted across channel switches
AutoMod
Client-side auto-moderation runs on both outgoing and incoming messages.Keyword Filter
A set of banned words is checked using pre-compiled word-boundary regexes (\b<word>\b, case-insensitive).
Rate Limiting
Sliding-window rate limiter tracks message timestamps per user:| Parameter | Default |
|---|---|
RATE_LIMIT_COUNT | 5 |
RATE_LIMIT_WINDOW | 10,000 ms |
Spam Detection
- Repeated character ratio: If >80% of a message (>5 chars) is the same character, itβs blocked (
spam_repeated_chars) - Repeated message history: If the last 3 messages from a user are identical, the message is blocked (
spam_repeated_message)
Cleanup
A periodic cleanup runs every 60 seconds to prune stale rate-limit entries and cap spam history to 200 users.Reconnection
If the primary channel drops, an exponential backoff reconnect strategy engages:| Parameter | Value |
|---|---|
| Base delay | 2 s |
| Max delay | 30 s |
| Max attempts | 8 |
| Jitter | 75-125% |
Configuration Reference
Fromjarvis-rs/crates/jarvis-config/src/schema/livechat.rs:
Security
XSS Prevention
All user-generated content (nicknames, message text) is rendered usingelement.textContent = value rather than innerHTML, preventing XSS injection.
SRI for External Dependencies
The Supabase JavaScript SDK is loaded with Subresource Integrity:TOFU Trust Store
The Trust On First Use model records nickname-to-fingerprint bindings inlocalStorage under jarvis-chat-tofu. Key changes trigger visible warnings in the chat UI.