@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
| Field | Type | Key | Ref |
|---|
| seq_pub | PubKey | yes |
| endpoints | string[] |
| protocols | string[] |
| enc_v | number |
Reg_Enclave
| Field | Type | Key | Ref |
|---|
| enclave_id | Hash | yes |
| node_pub | PubKey | reg_node.seq_pub |
| manifest | JSON |
| app | string |
Reg_Identity
| Field | Type | Key | Ref |
|---|
| pub_key | PubKey | yes |
| display_name | string |
| avatar | string |
| bio | string |
API
RegistryClient
Extends AppClient from @enc-protocol/app.
| Method | Params | Returns | Description |
|---|
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?) | string | Event[] | Query events |
grant(target, role) | Identity, string | { ok, error? } | Grant role |
as(identity) | Identity | RegistryClient | Switch identity |
static create(owner) | Identity | RegistryClient | Create enclave |
RBAC Rules
| Event | Role | Ops |
|---|
| * | Public | R |
| Terminate | owner | C |
| Reg_Node | Public | C, R, P |
| Reg_Enclave | Public | C, R, P |
| Reg_Identity | Public | C, R, P |
| Reg_Node | Sender | U, D |
| Reg_Enclave | Sender | U, D |
| Reg_Identity | Sender | U, 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