@enc-protocol/registry-node

0.2.1

ENC Registry client (Node.js) — RegistryRestClient, RegistryWsClient

npm i @enc-protocol/registry-node

@enc-protocol/registry-node

Registry Node SDK — REST + WebSocket clients for real servers.

Install

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

REST Usage

import { RegistryRestClient, createIdentity } from "@enc-protocol/registry-node/rest.js"

const owner = createIdentity("alice")
const client = await RegistryRestClient.create("http://localhost:8787", owner)

const result = await client.regnode({ seq_pub: "...", endpoints: "...", protocols: "...", enc_v: "..." })
console.log(result.ok)

const events = await client.query("Reg_Node")
await client.grant(bob, "Member")

WebSocket Usage

import { RegistryWsClient } from "@enc-protocol/registry-node/ws.js"

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

API

RegistryRestClient (extends AppNodeClient)

MethodParamsReturns
async regnode(seq_pub, endpoints, protocols, enc_v)seq_pub, endpoints, protocols, enc_v{ ok, error? }
async regenclave(enclave_id, node_pub, manifest, app)enclave_id, node_pub, manifest, app{ ok, error? }
async regidentity(pub_key, display_name, avatar, bio)pub_key, display_name, avatar, bio{ ok, error? }
async query(type?)stringEvent[]
async grant(target, role)Identity, string{ ok, error? }
static async create(url, owner)string, IdentityRegistryRestClient

RegistryWsClient (extends AppWsClient)

MethodDescription
async connect()Open WebSocket, authenticate
onEvent(fn)Subscribe to events, returns unsubscribe fn
close()Disconnect

Dependencies

  • @enc-protocol/app-node
  • @enc-protocol/registry