Telegraph is an end to end encrypted messaging service that works in your browser. Sign in once and use the service for free. Nothing is stored on the cloud (apart from your account details), and your messages stay private and secure.
Node.js 22+ and PostgreSQL for the server. The app runs entirely in the browser (it needs WebCrypto Ed25519/X25519, IndexedDB and Web Locks.
apps/
web/ the app: React UI
src/
useTelegraph.ts runs the session in this tab and keeps the UI state in sync
Login.tsx
Sidebar.tsx contacts list
Chat.tsx conversation with the selected contact
engine/
session.ts logged in/out: login, logout, starts and stops the messenger
messenger.ts encrypt + send, receive + decrypt + ack, message statuses
server-api.ts signed HTTP client for the server
server-socket.ts signed WebSocket to the server (reconnects)
local-store.ts IndexedDB: messages, logged-in account, pinned keys, address book
db.ts IndexedDB schema migrations + helpers
server/ hosted server: keys, encrypted delivery, docker setup
src/
server.ts
auth.ts request signature checks
login-codes.ts one-time email codes
mailer.ts sends the codes (Resend, or the server log in development)
hub.ts live WebSocket connections
schema.ts Drizzle table schemas
store.ts PostgreSQL queries (Drizzle ORM): identities, envelopes
drizzle/ generated SQL migrations
packages/
shared/ @telegraph/shared: wire protocol types + crypto + helper tools
npm run build compiles everything with TypeScript project references (tsc -b), shared first, then builds the web UI with Vite.
npm install
docker compose up --build # relay server + Postgres
npm run app # http://localhost:5173 (Vite, hot reload)Each browser profile is its own device, so to chat with yourself use two profiles (or a normal and a private window). Only one tab per browser runs Telegraph at a time; other tabs wait until it's closed.
Open the app and log in with your email: the server emails a 6-digit code, and the first time an email logs in you pick a username.
- Each login makes new keys on that device and replaces the account's keys on the server, so an account is logged in on one device at a time. Logging in somewhere else signs the other device out immediately.
- Contacts notice the new key automatically, and their apps refetch it. Messages that were waiting for the old device are dropped.
- Each user gets their own IndexedDB database in the browser,
telegraph-<username>. Logging out only forgets that device's keys, so switching users in one browser just switches databases, and logging back in shows your messages again. - Codes expire after 10 minutes, allow 5 tries, and can be re-requested every 30 seconds.
Type a name into the box above the contact list and press Add. The app asks the server whether that user exists and only adds them if it does. If the server can't be reached, nothing is added and you're asked to try again. Anyone you message, or who messages you, is added to the list automatically.
App build setting: VITE_SERVER_URL (default http://localhost:8080), the server URL.
Server env vars: PORT (8080), DATABASE_URL (postgres://localhost:5432/telegraph), MESSAGE_TTL_HOURS (default = 7 days),
CORS_ORIGIN (*).
- The app encrypts the message to the recipient's public key and
POSTs it to/envelopes(pending→sent). - The server stores the envelope and, if the recipient is connected, pushes it over their WebSocket.
- The recipient decrypts it, verifies the sender's signature, saves it locally, and then sends
an
ack. The server deletes the envelope and tells the sender (delivered). - A recipient who was offline gets every waiting envelope pushed as soon as it reconnects.
- If the server is unreachable, the message stays
pendinglocally and is retried.
Messages are de-duplicated by id, so retries and re-deliveries are always safe.
-
Logging in.
POST /auth/code {email}emails a code.POST /auth/login {email, code, signPub, boxPub}(plususernamefor a new account) checks it and stores the device's new public keys (Ed25519 for signing, X25519 for encryption) as that account's keys. The email proves who you are, and then the private keys on the device do. -
Signing every request. Each request (and the WebSocket connection) carries three headers:
header value X-Telegraph-NamealiceX-Telegraph-Timestampcurrent time in ms X-Telegraph-SignatureEd25519 signature of METHOD\npath\ntimestamp\nsha256(body)The server looks up alice's registered public key and checks the signature. Only the holder of alice's private key can produce it, and it covers the body, so it can't be reused for a different request. Timestamps more than 5 minutes off are rejected, which limits replays (and HTTPS stops anyone capturing requests in the first place).
-
Message-level checks. Independently of the server, each message is signed by the sender inside the encryption, and recipients pin contacts' public keys on first use.
- Messages are encrypted with ephemeral X25519 + HKDF-SHA256 + AES-256-GCM and signed by the
sender. The server only sees
id,from,toand ciphertext. - The server sees who talks to whom and when, and who is online. Apps only learn the presence of the contact
whose chat is open (
watch), not the whole online list. Typing indicators aren't encrypted, so it also sees when you're typing to someone.
Message (what the app encrypts, and stores locally):
{
"type": "message",
"id": "acf8d5e8-a395-4856-8bbd-d4618fea79e0",
"from": "alice",
"to": "bob",
"body": "hello bob",
"timestamp": "2026-10-05T19:06:53.611Z"
}Envelope (the message above, encrypted and signed; all the server sees):
{ "id": "…", "from": "alice", "to": "bob", "toKey": "<bob's boxPub>", "epk": "<base64>", "iv": "<base64>", "ciphertext": "<base64>", "tag": "<base64>" }If the recipient has logged in on a new device since, the server answers 409
and senders's app fetches recipient's new key and encrypts it again.
WebSocket frames. Server → app: {"type":"envelope","envelope":{…}}, {"type":"delivered","id":"…"},
{"type":"presence","name":"bob","online":true} (for the watched user only), {"type":"typing","from":"alice","typing":true}.
App → server also sends {"type":"watch","name":"bob"} when a chat opens (null when none is open); the server
replies with that user's presence right away and again whenever it changes.
- App (IndexedDB, in the browser):
telegraph-<username>(one per user) holds object storesmessages,identity(username, email and this device's keys; empty when logged out),contacts(pinned keys) andaddress_book(the names in your contact list).localStorage["telegraph:logged-in"]says which user the browser is logged in as. The app asks for persistent storage so the browser doesn't evict it under storage pressure. To change the local schema, append a step toMIGRATIONSinengine/db.ts. - Server (PostgreSQL):
identities(username, email, current public keys),envelopesandlogin_codes.