pub struct User { /* private fields */ }Expand description
Authenticated user with shared session state Clones share the same underlying session — leave() invalidates all holders.
Implementations§
Source§impl User
impl User
Sourcepub async fn create(
alias: &str,
pass: &str,
db: &mut Node,
) -> Result<Self, SeaError>
pub async fn create( alias: &str, pass: &str, db: &mut Node, ) -> Result<Self, SeaError>
Create a new user with alias and password.
Stores encrypted key pair in BEAM’s graph at ~@alias.
Sourcepub async fn auth(
alias: &str,
pass: &str,
db: &mut Node,
) -> Result<Self, SeaError>
pub async fn auth( alias: &str, pass: &str, db: &mut Node, ) -> Result<Self, SeaError>
Authenticate existing user from BEAM’s graph.
Sourcepub fn from_pair(pair: KeyPair, alias: Option<&str>) -> Self
pub fn from_pair(pair: KeyPair, alias: Option<&str>) -> Self
Create user directly from existing key pair.
Sourcepub async fn recall(
alias: &str,
storage: &dyn SessionStorage,
) -> Result<Self, SeaError>
pub async fn recall( alias: &str, storage: &dyn SessionStorage, ) -> Result<Self, SeaError>
Recall user from session storage.
Sourcepub async fn save_to(
&self,
storage: &dyn SessionStorage,
) -> Result<(), SeaError>
pub async fn save_to( &self, storage: &dyn SessionStorage, ) -> Result<(), SeaError>
Save current session to storage.
Note: clones the KeyPair and alias out of the session lock
before awaiting storage.save(...) to keep the future Send.
Holding the std::sync::RwLock read guard across an .await
would make the returned future non-Send (the std guard is not
Send), which breaks callers that need to await auth flows
while holding a tokio lock (e.g. the MCP identity_auth tool).
Source§impl User
impl User
Sourcepub async fn trust(
&self,
recipient_pubkey: &str,
path: Option<&str>,
db: &mut Node,
) -> Result<(), SeaError>
pub async fn trust( &self, recipient_pubkey: &str, path: Option<&str>, db: &mut Node, ) -> Result<(), SeaError>
Delegate write trust to a recipient for an optional path.
Stores a capability certificate at ~{pub}/trust/{path}.