TinyOlm is a minimal and powerful wrapper around Olm, designed to handle secure end-to-end encryption for Matrix-compatible environments — but small enough to fit in any project 🛡️
Whether you're building a chat app, a P2P network, or just need secure encryption between devices, TinyOlm gives you the essentials: identity management, session handling, and message encryption — all wrapped in a compact and intuitive interface.
⚠️ Important: All encryption and decryption operations are automatically queued and executed in order using an internalTinyPromiseQueuefrom moduletiny-essentials.
This ensures that all cryptographic requests are processed in the correct sequence, so you don't need to handle the ordering manually.
- 🔐 Identity & Device Key Management
- 🔄 One-Time & Session Key Generation
- 📦 Lightweight API for encrypting/decrypting messages
- 🧪 Supports both structured and raw message formats
- 🔌 Fully compatible with Olm (WebAssembly)
const encrypted = tinyOlm.encrypt('alice', { hello: 'world' });const message = tinyOlm.decrypt('alice', 1, encrypted.body);TinyOlm works through a class-based instance system. Every device gets its own TinyOlm.Instance, which manages your encryption identity, sessions, and storage 🔐
import { TinyOlm } from 'tiny-crypto-suite';
const olm = new TinyOlm.Instance('@pudding', 'DEVICE123', 'optional-password');await olm.init(); // Load Olm and create a new identityawait olm.initIndexedDb(); // Load identity + restore sessions from the browserTo encrypt any message or object:
const encrypted = olm.encrypt('@friend', { hello: '🌍' });This returns:
{
type: 1,
body: 'ENCRYPTED_PAYLOAD'
}To decrypt a received message:
const message = olm.decrypt('@friend', 1, encrypted.body);
console.log(message); // → { hello: '🌍' }You can also decrypt raw plaintexts (from encryptMessage) or expect a specific type for validation.
Once initIndexedDb() is called, TinyOlm automatically stores and restores:
- Your account identity
- One-to-one sessions
- Group sessions (inbound + outbound)
Making it a persistent and browser-safe encryption solution 💾🔐