clasp-registry
Persistent Ed25519 identity registry for devices, users, services, and routers in CLASP.
Features
- Entity Identity - Ed25519 keypairs with globally unique
clasp:IDs - Entity Types - Device, User, Service, Router
- Status Lifecycle - Active, Suspended, Revoked
- Token Generation - Ed25519-signed entity tokens (
ent_prefix) - Pluggable Storage - In-memory or SQLite backends
- ValidatorChain Integration - Works alongside CPSK and Capability validators
- Namespace-Based Scopes - Entities can be scoped to namespace patterns
Installation
[]
= "3.5"
# With SQLite persistence
= { = "3.5", = ["sqlite"] }
Feature Flags
| Feature | Description |
|---|---|
sqlite |
Enables SqliteEntityStore for persistent storage |
Usage
Generate an Entity Keypair
use ;
let keypair = generate?;
println!; // clasp:4j8Ygfakd8xZ9q7m...
// Create an Entity from the keypair
let entity = keypair.to_entity;
Store and Retrieve Entities
use ;
let store = new;
// Create
store.create.await?;
// Retrieve
let found = store.get.await?;
assert!;
// Find by public key
let by_key = store.find_by_public_key.await?;
// Find by tag or namespace
let sensors = store.find_by_tag.await?;
let site_a = store.find_by_namespace.await?;
// List with pagination
let page = store.list.await?;
// Update status (suspend, revoke)
use EntityStatus;
store.update_status.await?;
SQLite Persistence
use SqliteEntityStore;
let store = open?;
// Same EntityStore API as MemoryEntityStore
Generate and Validate Tokens
use ;
use Arc;
// Generate a token from a keypair
let token = generate_token?; // "ent_<base64url(msgpack)>"
// Set up validation
let store = new;
store.create.await?;
let validator = new
.with_max_token_age; // reject tokens older than 1 hour
// Implements clasp_core::security::TokenValidator
use TokenValidator;
match validator.validate
Token Wire Format
Entity tokens use the ent_ prefix followed by URL-safe base64-encoded MessagePack:
ent_<base64url(msgpack(EntityTokenPayload))>
The payload contains the entity ID, a timestamp, and an Ed25519 signature over both.
Configuration Reference
Entity
| Field | Type | Description |
|---|---|---|
id |
EntityId |
Globally unique ID (clasp:<base58>) |
entity_type |
EntityType |
Device, User, Service, or Router |
name |
String |
Human-readable name |
public_key |
Vec<u8> |
Ed25519 public key (32 bytes, hex in JSON) |
created_at |
SystemTime |
Creation timestamp |
metadata |
HashMap<String, String> |
Arbitrary key-value metadata |
tags |
Vec<String> |
Searchable tags |
namespaces |
Vec<String> |
Namespace patterns (converted to scopes) |
scopes |
Vec<String> |
Explicit action:pattern scopes |
status |
EntityStatus |
Active, Suspended, or Revoked |
EntityId Format
clasp:<base58(first 16 bytes of Ed25519 public key)>
Scope Resolution
When validating, scopes are resolved in order:
- If
entity.scopesis non-empty, use them as-is - Otherwise, convert
entity.namespacesto scopes:/lightsbecomesadmin:/lights/**
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Maintained by LumenCanvas