ENC Timeline client (Node.js) — TimelineRestClient, TimelineWsClient
Timeline Node SDK — REST + WebSocket clients for real servers.
npm install @enc-protocol/timeline-node --registry https://npm-registry.ocrybit.workers.dev/import { TimelineRestClient, createIdentity } from "@enc-protocol/timeline-node/rest.js"
const owner = createIdentity("alice")
const client = await TimelineRestClient.create("http://localhost:8787", owner)
const result = await client.public({ content: "..." })
console.log(result.ok)
const events = await client.query("public")
await client.grant(bob, "Member")import { TimelineWsClient } from "@enc-protocol/timeline-node/ws.js"
const ws = new TimelineWsClient("ws://localhost:8787", identity, enclaveId)
await ws.connect()
ws.onEvent((event) => console.log("New:", event.type, event.content))
// later: ws.close()| Method | Params | Returns |
|---|---|---|
async public(content) | content | { ok, error? } |
async private(content) | content | { ok, error? } |
async query(type?) | string | Event[] |
async grant(target, role) | Identity, string | { ok, error? } |
static async create(url, owner) | string, Identity | TimelineRestClient |
| Method | Description |
|---|---|
async connect() | Open WebSocket, authenticate |
onEvent(fn) | Subscribe to events, returns unsubscribe fn |
close() | Disconnect |
@enc-protocol/app-node@enc-protocol/timeline