Owner key, availability and clock.
A backend that also exposes deliver().
const backend = createMemoryBackend({ owner: 'me', now: () => 1_700_000_000 });
await backend.send({ recipients: ['alice'], content: 'hi' });
backend.deliver({ senderPubkey: 'alice', content: 'hello' });
(await backend.conversations()).conversations[0];
// { id: 'direct:alice', kind: 'direct', participants: [{ pubkey: 'alice' }], unread: 1, updatedAt: 1700000000 }
A complete
MessagingBackendthat lives in memory.Used by the shell's offline preview and by tests. Conversations are keyed
direct:<pubkey>orgroup:<pubkey>,<pubkey>over the sorted correspondents.send()stores the message assent, notifies subscribers and returns it;deliver()plays the other side. Unread counts are the number ofreceivedmessages in a conversation. Cursors are numeric offsets.send()rejects withinvalid:no-recipientswhen neither a conversation nor a recipient is named, withinvalid:unknown-conversationfor an id the backend has never seen, and withunavailable:offlinewhileavailableis false. Reads keep working offline so a preview can still show history.