@enc-protocol/dm-cli — DmSdk
Direct messages: end-to-end encrypted 1:1 conversations with an invite handshake, where each message is written to the recipient's own DM enclave (resolved through the registry).
Extends AppSdk. Enclaves: DM,
Personal, Registry.
Encrypted data_types: messages (ratchet-pair), invites
(ecdh-envelope).
Install
npm config set @enc-protocol:registry https://npm-registry.ocrybit.workers.dev/
npm install @enc-protocol/dm-cliConstruct
import { DmSdk } from '@enc-protocol/dm-cli'
const sdk = new DmSdk({ mode: 'cf', nodeUrl: process.env.NODE_URL, identity })
await sdk.init()Options are the standard AppSdk constructor.
Data types
| data_type | shape | encryption | routes to |
|---|---|---|---|
messages | { message_draft: string } | ratchet-pair | DM.message |
invites | {} | ecdh-envelope | DM.invite |
contacts | {} | — | declared; no generated accessor |
Methods
submitMessages(args)
await sdk.submitMessages({ message_draft: 'hi' }) // → DM.message (encrypted)Encrypts the draft with ratchet-pair (a per-message symmetric ratchet) and writes it to the conversation's DM enclave.
deleteInvites(args)
await sdk.deleteInvites({}) // → DM.invite (delete)Deletes an invite from the DM enclave.
queryMessages()
Read decrypted messages. Row fields: body, outgoing.
queryInvites()
Read pending invites. Row fields: greeting, pub, accept, reject.
queryProfiles()
Cross-enclave dataview read of Personal.Shared(profile) — the latest profile per identity.
Recipient routing
DM resolves the recipient's DM enclave through Registry.reg_identity (the _enclave_routing
cross-enclave route) so a message lands in the right person's enclave.
Example
import { DmSdk } from '@enc-protocol/dm-cli'
const sdk = new DmSdk({ mode: 'cf', nodeUrl: process.env.NODE_URL, identity })
await sdk.init()
await sdk.submitMessages({ message_draft: 'hi' }) // encrypted (ratchet-pair)
const thread = await sdk.queryMessages() // decrypted
const invites = await sdk.queryInvites()
const me = await sdk.queryProfiles() // cross-enclave profilesSee also
- Enclave profiles: DM, Personal, Registry
- Confidentiality plugins: ratchet-pair, ecdh-envelope
- App SDK pattern ·
cli-sdk-base