Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

@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-cli

Construct

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_typeshapeencryptionroutes to
messages{ message_draft: string }ratchet-pairDM.message
invites{}ecdh-envelopeDM.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 profiles

See also