use bitwarden_core::Client;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
use crate::{login::LoginClient, registration::RegistrationClient, send_access::SendAccessClient};
#[derive(Clone)]
#[cfg_attr(feature = "wasm", wasm_bindgen)]
pub struct AuthClient {
pub(crate) client: Client,
}
impl AuthClient {
pub fn new(client: Client) -> Self {
Self { client }
}
}
#[cfg_attr(feature = "wasm", wasm_bindgen)]
impl AuthClient {
pub fn login(&self, client_settings: bitwarden_core::ClientSettings) -> LoginClient {
LoginClient::new(client_settings)
}
pub fn send_access(&self) -> SendAccessClient {
SendAccessClient::new(self.client.clone())
}
pub fn registration(&self) -> RegistrationClient {
RegistrationClient::new(self.client.clone())
}
}
pub trait AuthClientExt {
fn auth_new(&self) -> AuthClient;
}
impl AuthClientExt for Client {
fn auth_new(&self) -> AuthClient {
AuthClient {
client: self.clone(),
}
}
}