Skip to main content

clasp_registry/
lib.rs

1//! CLASP Entity Registry
2//!
3//! Persistent identity for devices, users, services, and routers in the CLASP network.
4//! Each entity has an Ed25519 keypair and a stable ID derived from its public key.
5//!
6//! # Entity ID Format
7//! ```text
8//! clasp:<base58-ed25519-pubkey-prefix>
9//! ```
10//!
11//! # Token Format
12//! ```text
13//! ent_<base64url(msgpack(entity_id + timestamp + ed25519_signature))>
14//! ```
15//!
16//! # Storage Backends
17//! - `MemoryEntityStore` -- default, no deps, for dev/testing
18//! - `SqliteEntityStore` -- feature-gated behind `sqlite`, single file, WAL mode
19//!
20//! # Integration
21//!
22//! `EntityValidator` implements `clasp_core::TokenValidator` and plugs into the existing
23//! `ValidatorChain`. Existing `cpsk_` tokens continue working unchanged.
24//!
25//! ```rust,no_run
26//! use std::sync::Arc;
27//! use clasp_core::ValidatorChain;
28//! use clasp_registry::{EntityValidator, MemoryEntityStore};
29//!
30//! let store = Arc::new(MemoryEntityStore::new());
31//! let chain = ValidatorChain::new()
32//!     .with(clasp_core::CpskValidator::new())
33//!     .with(EntityValidator::new(store));
34//! ```
35
36pub mod entity;
37pub mod error;
38#[cfg(feature = "sqlite")]
39pub mod sqlite;
40pub mod store;
41pub mod token;
42pub mod validator;
43
44pub use entity::{Entity, EntityId, EntityKeypair, EntityStatus, EntityType};
45pub use error::{RegistryError, Result};
46#[cfg(feature = "sqlite")]
47pub use sqlite::SqliteEntityStore;
48pub use store::{EntityStore, MemoryEntityStore};
49pub use token::{generate_token, parse_token, ENTITY_TOKEN_PREFIX};
50pub use validator::EntityValidator;