#[cfg(feature = "biome-client-reqwest")]
mod reqwest;
use crate::error::InternalError;
#[cfg(feature = "biome-client-reqwest")]
pub use self::reqwest::ReqwestBiomeClient;
#[derive(Debug)]
pub struct Credentials {
pub user_id: String,
pub username: String,
}
#[derive(Debug)]
pub struct Authorization {
pub user_id: String,
pub token: String,
pub refresh_token: String,
}
#[derive(Debug)]
pub struct Key {
pub display_name: String,
pub encrypted_private_key: String,
pub public_key: String,
pub user_id: String,
}
#[derive(Debug)]
pub struct Profile {
pub user_id: String,
pub subject: String,
pub name: Option<String>,
}
#[derive(Debug)]
pub struct UpdateUser {
pub username: String,
pub hashed_password: String,
pub new_password: Option<String>,
pub new_key_pairs: Vec<NewKey>,
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct NewKey {
pub public_key: String,
pub encrypted_private_key: String,
pub display_name: String,
}
pub trait BiomeClient {
fn register(&self, username: &str, password: &str) -> Result<Credentials, InternalError>;
fn login(&self, username: &str, password: &str) -> Result<Authorization, InternalError>;
fn logout(&self) -> Result<(), InternalError>;
fn get_new_access_token(&self, refresh_token: &str) -> Result<String, InternalError>;
fn verify(&self, username: &str, password: &str) -> Result<(), InternalError>;
fn list_users(&self) -> Result<Box<dyn Iterator<Item = Credentials>>, InternalError>;
fn get_user(&self, user_id: &str) -> Result<Option<Credentials>, InternalError>;
fn update_user(
&self,
user_id: &str,
updated_user: UpdateUser,
) -> Result<Box<dyn Iterator<Item = Key>>, InternalError>;
fn delete_user(&self, user_id: &str) -> Result<(), InternalError>;
fn list_profiles(&self) -> Result<Box<dyn Iterator<Item = Profile>>, InternalError>;
fn get_profile(&self, user_id: &str) -> Result<Option<Profile>, InternalError>;
fn list_user_keys(&self) -> Result<Box<dyn Iterator<Item = Key>>, InternalError>;
fn update_key(&self, public_key: &str, new_display_name: &str) -> Result<(), InternalError>;
fn replace_keys(&self, keys: Vec<NewKey>) -> Result<(), InternalError>;
fn add_key(&self, user_id: &str, new_key: NewKey) -> Result<(), InternalError>;
fn get_key(&self, public_key: &str) -> Result<Option<Key>, InternalError>;
fn delete_key(&self, public_key: &str) -> Result<Option<Key>, InternalError>;
}