ENC Protocol app base — AppClient (pure)
Base class for all app SDKs. Pure, in-memory Node — no network.
npm install @enc-protocol/app --registry https://npm-registry.ocrybit.workers.dev/import { AppClient, createIdentity } from '@enc-protocol/app'
const owner = createIdentity('alice')
const schema = [
{ event: 'Message', role: 'Any', ops: ['C', 'R'] },
{ event: 'Grant', role: 'Owner', ops: ['C'] },
]
// Create enclave
const client = AppClient.create(schema, owner)
// Submit events
const result = client.submit('Message', { text: 'hello' })
console.log(result.ok) // true
// Query
const events = client.query('Message')
// Grant role
client.grant(bob, 'Admin')
// Switch identity (same node)
const bobClient = client.as(bob)| Method | Params | Returns | Description |
|---|---|---|---|
submit(type, content) | string, object | { ok, event?, error? } | Submit signed commit |
query(type?) | string | Event[] | Query events by type |
grant(target, role) | Identity, string | { ok, error? } | Grant role |
revoke(target, role) | Identity, string | { ok, error? } | Revoke role |
as(identity) | Identity | AppClient | New client, same node |
static create(schema, owner) | Rule[], Identity | AppClient | Create enclave |
@enc-protocol/core@enc-protocol/core-node