@enc-protocol/app-client-node

0.2.1

ENC Protocol app client (Node.js) — AppNodeClient, AppWsClient

npm i @enc-protocol/app-client-node

@enc-protocol/app-node

REST + WebSocket base classes for app SDKs. Talks to real servers via fetch.

Install

npm install @enc-protocol/app-node --registry https://npm-registry.ocrybit.workers.dev/

Usage

REST

import { AppNodeClient, createIdentity } from '@enc-protocol/app-node'

const owner = createIdentity('alice')
const client = await AppNodeClient.create(schema, 'http://localhost:8787', owner)

const result = await client.submit('Message', { text: 'hello' })
const events = await client.query('Message')
await client.grant(bob, 'Admin')

WebSocket

import { AppWsClient } from '@enc-protocol/app-node/ws.js'

const ws = new AppWsClient('ws://localhost:8787', identity, enclaveId)
await ws.connect()
ws.onEvent((event) => console.log('New:', event.type))
// later
ws.close()

Dependencies

  • @enc-protocol/core
  • @enc-protocol/core-client