enbox
A TypeScript SDK for decentralised identity and personal data storage. Your users own their data. You build the experience.
Built with Bun
import { Enbox, defineProtocol } from '@enbox/api';
// Define a typed protocol
const Notes = defineProtocol({
protocol: 'https://example.com/notes',
published: true,
types: {
note: {
schema: 'https://example.com/note',
dataFormats: ['application/json'],
},
},
structure: { note: {} },
});
// Connect to an Enbox instance
const enbox = Enbox.connect({ agent, connectedDid: did });
const notes = enbox.using(Notes);
await notes.configure();
// Create
const { record } = await notes.records.create('note', {
data: { title: 'First note', body: 'Hello from Enbox!' },
});
// Read
const data = await record.data.json();
// Update
await record.update({
data: { title: 'Updated note', body: 'Changed.' },
});
// Query
const { records } = await notes.records.query('note');
// Delete
await record.delete();Decentralised Identity
DID-based identity that users own. No central account server. Supports did:dht, did:jwk, did:key, and did:web.
Personal Data Vaults
Data stored in Decentralised Web Nodes. Users choose where their data lives. Sync across devices automatically.
Type-Safe Protocols
Define DWN protocols with TypeScript types. Compile-time checks for paths, schemas, and record data.
End-to-End Encryption
Records encrypted with ECDH key agreement and AES-256-GCM content encryption. Per-protocol encryption policies.
Real-Time Subscriptions
LiveQuery provides an initial snapshot plus deduplicated change events. Connection lifecycle built in.
Self-Hostable Server
Run your own DWN server with PostgreSQL, MySQL, or SQLite. Rate limiting, quotas, and admin dashboard included.