@enc-protocol/registry

0.2.1

ENC Registry SDK — RegistryClient

npm i @enc-protocol/registry

@enc-protocol/registry

Registry SDK — pure, in-memory Node, real crypto.

Install

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

Usage

import { RegistryClient, createIdentity } from "@enc-protocol/registry"

// Create identity and enclave
const owner = createIdentity("alice")
const client = RegistryClient.create(owner)

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

// Query events
const events = client.query("Reg_Node")

// Grant role to another identity
const bob = createIdentity("bob")
client.grant(bob, "Member")

// Use as different identity
const bobClient = client.as(bob)

Event Schemas

Reg_Node

FieldTypeKeyRef
seq_pubPubKeyyes
endpointsstring[]
protocolsstring[]
enc_vnumber

Reg_Enclave

FieldTypeKeyRef
enclave_idHashyes
node_pubPubKeyreg_node.seq_pub
manifestJSON
appstring

Reg_Identity

FieldTypeKeyRef
pub_keyPubKeyyes
display_namestring
avatarstring
biostring

API

RegistryClient

Extends AppClient from @enc-protocol/app.

MethodParamsReturnsDescription
regnode(seq_pub, endpoints, protocols, enc_v)seq_pub, endpoints, protocols, enc_v{ ok, error? }Submit Reg_Node event
regenclave(enclave_id, node_pub, manifest, app)enclave_id, node_pub, manifest, app{ ok, error? }Submit Reg_Enclave event
regidentity(pub_key, display_name, avatar, bio)pub_key, display_name, avatar, bio{ ok, error? }Submit Reg_Identity event
query(type?)stringEvent[]Query events
grant(target, role)Identity, string{ ok, error? }Grant role
as(identity)IdentityRegistryClientSwitch identity
static create(owner)IdentityRegistryClientCreate enclave

RBAC Rules

EventRoleOps
*PublicR
TerminateownerC
Reg_NodePublicC, R, P
Reg_EnclavePublicC, R, P
Reg_IdentityPublicC, R, P
Reg_NodeSenderU, D
Reg_EnclaveSenderU, D
Reg_IdentitySenderU, D

Audit

All properties proven by Lean native_decide:

  • valid: (validate config).allPass = true := by native_decide
  • anyone_can_register: config.permits "Reg_Node" "Public" "C" = true ∧ ... := by native_decide
  • all_public_read: config.permits "Reg_Node" "Public" "R" = true ∧ ... := by native_decide
  • sender_only_modify: config.permits "Reg_Node" "Sender" "U" = true ∧ ... := by native_decide
  • all_unencrypted: config.eventSchemas.all (·.encrypt == .none) = true := by native_decide
  • owner_terminates: config.permits "Terminate" "owner" "C" = true := by native_decide
  • discovery_refs: refsResolve config = true := by native_decide
  • all_tests_pass: verifyTestSuite config tests = true := by native_decide
  • all_stateful_tests_pass: verifyStatefulSuite config statefulTests = true := by native_decide

Dependencies

  • @enc-protocol/app