bitwarden_auth/
auth_client.rs1use bitwarden_core::Client;
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{login::LoginClient, registration::RegistrationClient, send_access::SendAccessClient};
6
7#[derive(Clone)]
9#[cfg_attr(feature = "wasm", wasm_bindgen)]
10pub struct AuthClient {
11 pub(crate) client: Client,
15}
16
17impl AuthClient {
18 pub fn new(client: Client) -> Self {
20 Self { client }
21 }
22}
23
24#[cfg_attr(feature = "wasm", wasm_bindgen)]
25impl AuthClient {
26 pub fn login(&self, client_settings: bitwarden_core::ClientSettings) -> LoginClient {
31 LoginClient::new(client_settings)
32 }
33
34 pub fn send_access(&self) -> SendAccessClient {
36 SendAccessClient::new(self.client.clone())
37 }
38
39 pub fn registration(&self) -> RegistrationClient {
41 RegistrationClient::new(self.client.clone())
42 }
43}
44
45pub trait AuthClientExt {
47 fn auth_new(&self) -> AuthClient;
49}
50
51impl AuthClientExt for Client {
52 fn auth_new(&self) -> AuthClient {
53 AuthClient {
54 client: self.clone(),
55 }
56 }
57}