Sending Messages
Messages are encrypted client-side and sent as opaque binary blobs. The server never sees plaintext.
const { messageId } = await client.sendMessage(
'alice-user-id',
'Hey Alice, this is end-to-end encrypted!'
);
console.log('Sent:', messageId);Parameters
toUserId, string, Recipient's stable user ID (must match their JWT subject)plaintextMessage, string, Message content; encrypted by the SDK
Returns Promise<{ messageId: string }>
Encryption flow
- 1. Fetch recipient's public key from your key directory (cached after first call)
- 2. Derive shared secret via X25519 ECDH → HKDF-SHA256 → AES-256 key
- 3. Encrypt with AES-256-GCM (96-bit nonce, AAD = messageId+senderId+recipientId+timestamp)
- 4. Serialize into a protobuf Envelope with opaque
encryptedPayloadbytes - 5. Send as a binary WebSocket frame to DropOnAir