WHIM Protocol Specification (1.0)
WHIM (Wormhole Instant Messenger) is an open standard for a messaging software with message and file payloads carried over Magic Wormhole–compatible encrypted transfers. The control plane (accounts, friends, presence, signaling) is a small HTTP/WebSocket API. The data plane (message bodies and files) is Magic Wormhole; files and messages never transit the control plane server.
This document describes the WHIM 1.0 behavior implemented by the reference stack, agum (whim-server + WHIM desktop client + whim-wormhole sidecar). It is published so operators and developers can build and self-host a compatible server and/or build a compatible client in any language or UI, without requiring access to the reference source code.
The reference WHIM desktop app and hosted server are not open source. This specification is the open standard: interoperability is defined here, not by reading reference implementation sources.
Table of Contents
- 1. Goals and non-goals
- 2. Architecture
- 3. Terminology
- 4. HTTP conventions
- 5. Public HTTP endpoints
- 6. Authentication and profile
- 7. Billing (optional activation)
- 8. Friends and requests
- 9. Transfers and signaling
- 10. Client data plane (normative)
- 11. Presence WebSocket
- 12. Mailbox WebSocket (optional)
- 13. WHIM message markup
- 14. whim-wormhole sidecar protocol
- 15. WHIM ID normalization
- 16. Security and trust notes
- 17. Compatibility
- 18. Reference behavior summary
1. Goals and non-goals
Goals
- Stable WHIM ID (three-word identifier) for adding friends and signing in.
- Friend graph and friend requests on the control plane.
- Presence (online / away / offline) and real-time events over a single WebSocket per signed-in client.
- End-to-end encrypted chat and files via wormhole-william (or any sidecar that speaks the same CLI + JSON line protocol).
- Server-mediated signaling only for wormhole codes and session metadata; ciphertext and file bytes stay on the wormhole path.
- Local-only chat history on each device (not specified in detail here; reference client uses SQLite).
Non-goals
- Server-side message or file storage.
- Multi-device history sync.
- Interop with non-WHIM wormhole clients (custom AppID and WHIM-specific signaling are required).
- Open-source reference implementations (this spec stands alone).
2. Architecture
+-------------+ HTTPS + WSS +------------------+
| WHIM client | <------------------> | WHIM server |
| | (control plane) | (whim-server) |
+------+------+ +------------------+
|
| spawn / IPC
v
+--------------+ WSS rendezvous +------------------+
| whim-wormhole| <-------------------> | Magic Wormhole |
| sidecar | + TCP transit | rendezvous/relay |
+------+-------+ +------------------+
|
| encrypted wormhole session
v
+-------------+
| Peer client |
+-------------+
| Plane | Responsibility |
|---|---|
| Control plane | Auth, profiles, device public keys, friends, presence, transfer offers, encrypted signaling envelopes |
| Data plane | Wormhole pairing (SPAKE2 + transit). Text and files as wormhole payloads |
| Local | Chat history, settings, device private key (never sent to server) |
3. Terminology
| Term | Meaning |
|---|---|
| WHIM ID | Public account handle: three lowercase words from a server wordlist, joined with hyphens (e.g. copper-lantern-orbit). Assigned at registration. |
| Control plane URL | Base HTTPS URL of a WHIM server (e.g. https://whim.example.com). No trailing slash required. |
| Access token | JWT returned by register/login; sent as Authorization: Bearer … on protected HTTP routes and as access_token query param on WebSockets. |
| Device key | P-256 ECDH key pair generated on the client. Public JWK stored on the server; private JWK kept locally. Used to encrypt wormhole codes for friends. |
| Transfer session | UUID created by POST /v1/transfers/start; correlates signaling, sidecar jobs, and optional history rows. |
| Wormhole code | Human wormhole pairing string produced by the sidecar (code event). Must not be sent to the control plane in plaintext in WHIM 1.0 clients. |
| AppID | Magic Wormhole application id (default agum.com/wormhole-im/v1). Both peers must use the same AppID for a session. |
| Rendezvous URL | WebSocket URL of a Magic Wormhole mailbox server (default public relay). |
| Transit relay | Host:port for wormhole transit when direct TCP fails. Empty / direct-only disables relay. |
4. HTTP conventions
4.1 Base URL and paths
- API paths are rooted at
{control_plane}/v1/…exceptGET /health. - Request and response bodies are JSON unless noted.
Content-Type: application/jsonon requests with a body.
4.2 Authentication
Protected routes require:
Authorization: Bearer <access_token>
JWT properties (WHIM 1.0 reference profile):
- Algorithm: HS256 with a server-held symmetric signing key.
- Payload claims:
sub(user UUID),whim_id(string),exp(Unix seconds). - Clients should treat tokens as opaque and refresh by re-login when expired.
Alternate servers may use other signing keys or token formats only if they do not need to interoperate with the reference desktop client's login flow.
4.3 Errors
Failed requests return JSON:
{ "error": "human-readable message" }
Common status codes: 400 validation, 401 auth, 403 forbidden, 404 not found, 409 conflict, 402 Payment Required when account activation is required but not satisfied.
4.4 CORS
Reference server allows all origins for browser-based tooling. Production deployments may restrict this; clients using native HTTP are unaffected.
4.5 UUIDs and timestamps
- Resource ids are UUID strings in JSON.
- Timestamps in API objects are ISO 8601 strings in UTC.
5. Public HTTP endpoints
5.1 GET /health
Liveness probe.
Response 200:
{ "status": "ok" }
5.2 GET /v1/client-info
Optional client metadata for About screens and update checks. No authentication. Fields are omitted when not configured on the server.
Response 200:
{
"latest_version": "1.0.1",
"update_url": "https://example.com/download",
"support_email": "[email protected]",
}
6. Authentication and profile
6.1 POST /v1/auth/register
Create an account. Server assigns a unique WHIM ID.
Request:
{
"email": "[email protected]",
"password": "string",
"display_name": "string"
}
email: optional; if present, must contain@; stored lowercase; must be unique.password: minimum 8 characters.display_name: 1–64 characters after trim.
Response 200:
{
"access_token": "<jwt>",
"user": { /* UserPublic */ }
}
UserPublic:
| Field | Type | Notes |
|---|---|---|
id | UUID | Internal user id |
whim_id | string | Three-word public id |
email | string | null | If registered with email |
display_name | string | Shown name |
device_public_key | object | null | JWK after first publish |
account_status | string | e.g. active, pending_activation |
activation_required | boolean | Server policy flag |
When activation_required is true on the user object, new accounts may start as pending_activation until the operator enables the account (see §7).
6.2 POST /v1/auth/login
Request:
{
"identifier": "word-word-word or [email protected]",
"password": "string"
}
identifier matches WHIM ID (normalized, see §3) or email (case-insensitive).
Response 200: same shape as register.
6.3 GET /v1/me
Auth required. Returns current UserPublic.
6.4 POST /v1/me/device-key
Auth required. Publish or replace the device public key.
Request:
{
"public_key": { /* JWK object, ECDH P-256 */ }
}
- Must be a JSON object (JWK).
- Serialized size limit 4096 bytes.
Response 200: updated UserPublic.
WHIM 1.0 clients generate a long-lived P-256 key pair locally, publish the public JWK after login, and use the private key to decrypt incoming signaling.
7. Billing (optional activation)
Some deployments may require paid or manual activation before social features work. Others leave every account active. These endpoints expose that policy to the client.
7.1 GET /v1/billing/status
Auth required.
Example response:
{
"required": false,
"provider": "stripe",
"account_status": "active",
"checkout_available": false
}
7.2 POST /v1/billing/checkout
Auth required. Placeholder for Stripe Checkout URL when activation is enabled.
Example response:
{
"enabled": false,
"checkout_url": null,
"message": "…"
}
Many friend, presence, and transfer routes return 402 Payment Required when account_status is not "active" and the deployment requires activation. Logging in should return 402 if the deployment requires activation and the user account is not activated
8. Friends and requests
All routes in this section require active account unless noted.
8.1 GET /v1/friends
Returns accepted friends with live presence projection.
Response 200: array of FriendPublic:
| Field | Type | Notes |
|---|---|---|
id | UUID | Friend user id |
whim_id | string | |
display_name | string | |
online | boolean | true iff friend has an open presence WebSocket |
availability | string | online, away, or offline |
status_message | string | null | Away message; only when availability is away and friend is connected |
device_public_key | JWK | null | For encrypting signals |
friends_since | string | ISO timestamp |
Presence rules:
- If the friend is not connected via WebSocket →
online: false,availability: "offline",status_message: null. - If connected and stored status is away →
online: true,availability: "away", message shown (trimmed, max 250 Unicode scalars). - If connected and not away →
online: true,availability: "online",status_message: null.
8.2 POST /v1/friends/request
Send a friend request by WHIM ID (not display name).
Request:
{
"target_whim_id": "word-word-word",
"note": "optional string"
}
Response 200:
{ "request_id": "<uuid>" }
Errors: unknown WHIM ID (404), already friends (409), self-add (400).
Target user receives a friend_request event on their presence WebSocket if connected.
8.3 GET /v1/friends/requests
Response 200: array of FriendRequestPublic:
| Field | Type |
|---|---|
id | UUID |
direction | "incoming" | "outgoing" (relative to caller) |
status | e.g. pending, accepted, declined |
note | string | null |
requester | UserLite |
addressee | UserLite |
created_at, updated_at | ISO strings |
UserLite: { "id", "whim_id", "display_name" }.
8.4 POST /v1/friends/requests/:request_id/respond
Request:
{ "accept": true }
Only the addressee may respond while status is pending.
Response 200: updated FriendRequestPublic.
Requester receives friend_accepted or friend_declined on presence WebSocket.
9. Transfers and signaling
9.1 POST /v1/transfers/start
Initiator creates a transfer session and notifies the friend.
Request:
{
"friend_id": "<uuid>",
"kind": "message",
"appid": "agum.com/wormhole-im/v1",
"rendezvous_url": "ws://relay.magic-wormhole.io:4000/v1",
"transit_relay": "transit.magic-wormhole.io:4001"
}
| Field | Notes |
|---|---|
kind | "message" or "file". If omitted, treat as "message". |
appid | Wormhole AppID for this session. If omitted, server chooses a default and echoes it in the response. |
rendezvous_url | Wormhole rendezvous WebSocket URL. If omitted, server chooses a default and echoes it. |
transit_relay | Transit relay host:port, or omit/empty for direct-only. Server echoes resolved value (may be null). |
Response 200:
{
"session_id": "<uuid>",
"appid": "…",
"rendezvous_url": "…",
"transit_relay": "…"
}
transit_relay may be null if empty.
Friend receives transfer_offer on presence WebSocket (metadata only). WHIM 1.0 reference client does not require accepting offers separately for messages; file flows use encrypted code + accept/decline signals (§10).
9.2 POST /v1/signaling/send
Deliver an arbitrary signal to a friend if they have an active presence socket.
Request:
{
"friend_id": "<uuid>",
"signal_type": "wormhole_code_encrypted",
"payload": { }
}
Response 200:
{ "delivered": true }
delivered: false means the friend is not connected; the server does not queue signals for later delivery.
WHIM 1.0 signal types (see §10): wormhole_code_encrypted, wormhole_code_ack, file_transfer_response.
The same Signal shape is also delivered as a presence WebSocket event (§11).
9.3 GET /v1/pairing/pending
Auth required. Returns session ids for pending pairing sessions where this user is the target.
{ "session_ids": ["<uuid>", …] }
The reference 1.0 desktop client does not use this for chat/file delivery (wormhole codes use encrypted signaling instead). Reserved for alternate pairing experiments and mailbox WebSocket (§12).
10. Client data plane (normative for WHIM 1.0)
This section defines what a compatible client must implement. The server only sees encrypted envelopes and opaque wormhole metadata in transfer offers.
10.1 Preconditions
- Users are friends with active accounts.
- Reference UX: messages and files may only be sent while the friend is
online(presence WebSocket connected). A compatible client may relax this only if it implements offline queueing (not part of 1.0). - Initiator and receiver must use the same
appid, compatible rendezvous URL, and compatible transit/direct-only policy for that session.
10.2 Device-key encrypted wormhole code
Plaintext wormhole codes must not be posted to /v1/signaling/send in WHIM 1.0.
Envelope (signal_type: wormhole_code_encrypted, payload):
{
"v": 1,
"alg": "ECDH-P256-AES-GCM",
"epk": { /* ephemeral P-256 public JWK */ },
"iv": "<base64, 12 bytes>",
"ciphertext": "<base64>"
}
Ciphertext decrypts to UTF-8 JSON WormholeCodeSignal:
{
"session_id": "<uuid>",
"kind": "message",
"code": "wormhole-code-string",
"appid": "…",
"rendezvous_url": "…",
"transit_relay": "…",
"direct_only": false,
"file_name": "optional-for-file-kind"
}
Encryption steps (normative):
- Generate ephemeral ECDH P-256 key pair.
- ECDH with friend's published device_public_key → AES-256-GCM key.
- Encrypt JSON signal with random 12-byte IV.
- Send envelope via signaling (HTTP or presence WS).
Decryption: reverse with local private device key and sender's epk.
On successful decrypt, receiver should send wormhole_code_ack:
{
"signal_type": "wormhole_code_ack",
"payload": { "session_id": "<uuid>" }
}
Sender should wait for ack (reference client ~12s timeout) before treating an outgoing message send as delivered.
10.3 Message transfer flow
- Initiator:
POST /v1/transfers/startwithkind: "message"and wormhole endpoints. - Initiator: start sidecar
send-textwith--messagebody (WHIM markup string, §13). - Sidecar emits
code→ initiator sendswormhole_code_encryptedto friend; waitswormhole_code_ack. - Receiver: on decrypt, start sidecar
recv-textwith--code. - Sidecar emits
messagethencomplete→ receiver stores plaintext in local history.
Message bytes travel only through wormhole; control plane sees session ids and encrypted codes only.
10.4 File transfer flow
- Initiator:
transfers/startwithkind: "file". - Initiator: start
send-file(sidecar holds file open; may emitcodebefore transfer completes). - Initiator sends encrypted code with
kind: "file"andfile_name. - Receiver: shows accept/decline UI. On decline, send
file_transfer_response{ "session_id", "accepted": false }. - On accept, receiver sends
"accepted": true, runsrecvwith--codeand--outdirectory. - Initiator: on
"accepted": true, sidecar completes send-file transfer (reference client already started send-file and waits for peer).
Only one outstanding incoming file request per friend is recommended (reference client auto-declines extras).
file_transfer_response payload:
{
"session_id": "<uuid>",
"accepted": true
}
11. Presence WebSocket
11.1 Connection
GET /v1/ws/presence?access_token=<jwt>
Upgrade to WebSocket. Invalid or expired JWT closes the connection.
On connect, server sends hello, then may send presence, status, friend events, transfer_offer, and signal events. Servers should use WebSocket ping frames for keepalive; clients must respond with pong or risk being disconnected.
11.2 Server → client events
JSON objects with "type" in snake_case:
| type | Purpose |
|---|---|
hello | Initial snapshot: { user, friends[], presence_status, status_message } |
presence | Friend online/away/offline change: { user, online, availability, status_message? } |
status | Own status persisted: { presence_status, status_message? } |
friend_request | { request_id, from: UserLite } |
friend_accepted | { by: UserLite } |
friend_declined | { by: UserLite } |
transfer_offer | { session_id, from, kind, appid, rendezvous_url, transit_relay? } |
signal | { from, signal_type, payload } |
11.3 Client → server messages
Set availability (online / away):
{
"type": "status",
"availability": "online",
"status_message": "optional away markup"
}
availability:"online"or"away".status_message: optional; if omitted on update, server keeps previous message. Empty string clears message.- Away messages use WHIM markup (§13), max 250 characters after server normalization (controls stripped,
\r\n→\n).
Relay signal (optional): clients may send { "type": "signal", "friend_id", "signal_type", "payload" } on the same socket instead of HTTP signaling. Reference client uses HTTP signaling/send.
Offline: reference client closes the WebSocket and stops reconnecting until the user chooses Online again.
12. Mailbox WebSocket (optional / legacy)
GET /v1/ws/mailbox/:session_id?access_token=<jwt>
Authenticates the initiator or target of a known pairing session_id and bridges two WebSocket peers. WHIM 1.0 chat/file delivery does not require this endpoint; peers use Magic Wormhole rendezvous via the sidecar. Optional for alternate pairing or relay designs.
13. WHIM message markup
Message bodies and away status_message values are a single UTF-8 string with BBCode-style tags. Tags are interpreted by clients for display; the wire format through wormhole is plain text including tags.
13.1 Tags
| Tag | Meaning |
|---|---|
[b]…[/b] | Bold |
[i]…[/i] | Italic |
[u]…[/u] | Underline |
[color=#rrggbb]…[/color] | Foreground color (6 hex digits) |
[size=n]…[/size] | Relative size n = 0–4 (2 = normal; composers should omit tag for normal on save) |
- Nesting up to 16 levels.
- Malformed tags render as literal text.
- Escape literal
[as[[.
13.2 Autolinks
Clients should linkify http:// and https:// substrings in plain text when rendering. No [url] tag in 1.0.
13.3 Line breaks
Composer serializes line breaks as \n in the stored string. Renderers map \n to visual line breaks.
14. whim-wormhole sidecar protocol
Compatible clients may embed wormhole-william directly; the reference app spawns a whim-wormhole binary with a stable CLI and newline-delimited JSON on stdout.
14.1 Commands
| Command | Purpose |
|---|---|
send-text | Send UTF-8 text (--message) |
recv-text | Receive text (--code) |
send-file | Send file (--path) |
recv | Receive file or text (--code, --out dir) |
Shared flags:
| Flag | Default |
|---|---|
--appid | agum.com/wormhole-im/v1 |
--rendezvous | ws://relay.magic-wormhole.io:4000/v1 |
--transit | transit.magic-wormhole.io:4001 |
--direct-only | false (clears transit) |
--timeout | 30m |
Passphrase component length is 2 (wormhole-william client setting in reference sidecar).
14.2 stdout events (one JSON object per line)
| type | Fields |
|---|---|
code | code; optional name, path for file send |
message | message, bytes (recv-text) |
file | name, path, bytes (recv file) |
complete | success |
error | error (also non-zero exit) |
Parent process should parse lines incrementally and support cancel/kill of long-running recv/send jobs.
15. WHIM ID normalization
When accepting user input for WHIM IDs (login, friend add), servers and clients should normalize:
- Trim whitespace.
- Map Unicode dash-like characters and
_/space to-. - Lowercase ASCII letters.
- Collapse repeated separators.
Validation for friend requests: at least three hyphen-separated alphanumeric segments (e.g. word-word-word).
16. Security and trust notes (1.0)
- Control plane operator sees metadata: friend graph, presence, transfer session ids, signaling ciphertext sizes, and timing. Not message bodies or files if clients follow §10.
- Device keys are TOFU: first published JWK wins; there is no built-in safety-number verification in 1.0.
- Users must trust their control plane for availability and honesty of friend lists; they must not trust it for message confidentiality when §10 is implemented.
- Wormhole provides PAKE + encrypted transit; WHIM adds friend-scoped encrypted code delivery so short codes are not exposed to the server in plaintext.
17. Compatibility
| Layer | Version |
|---|---|
| This document | WHIM 1.0 |
| Reference desktop app | 1.0.0 (check GET /v1/client-info / About for deployed builds) |
| API path prefix | /v1/ |
Future versions should introduce new optional JSON fields or new /v2/ routes rather than breaking 1.0 clients silently.
18. Reference behavior summary (checklist for alternate clients)
A minimal WHIM 1.0–compatible desktop client should:
- Register/login against control plane; store JWT.
- Generate P-256 device key;
POST /v1/me/device-key. - Open presence WebSocket while "online"; handle hello/presence/signal events.
- List friends; send/accept friend requests by WHIM ID.
- For chat:
transfers/start→ sidecar send-text → encryptcode→ signal → wait ack → complete on sidecarcomplete. - For chat receive: decrypt signal → recv-text → display with WHIM markup.
- For files: encrypted code + accept/decline + send-file/recv coordination (§10.4).
- Store history locally only.
- Fetch
GET /v1/client-infoon launch for optional About/update UI.
A minimal compatible server must implement §5–§11 and enforce friend-only signaling and transfer rules as described.
WHIM Protocol Specification 1.0 — published for interoperability and self-hosting. Reference implementations may differ in UI and local storage; behavior on the wire should match this document.