bitwarden_auth/
auth_client.rs1use bitwarden_core::Client;
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{
6 identity::IdentityClient, registration::RegistrationClient, send_access::SendAccessClient,
7};
8
9#[derive(Clone)]
11#[cfg_attr(feature = "wasm", wasm_bindgen)]
12pub struct AuthClient {
13 pub(crate) client: Client,
17}
18
19impl AuthClient {
20 pub fn new(client: Client) -> Self {
22 Self { client }
23 }
24}
25
26#[cfg_attr(feature = "wasm", wasm_bindgen)]
27impl AuthClient {
28 pub fn identity(&self) -> IdentityClient {
30 IdentityClient::new(self.client.clone())
31 }
32
33 pub fn send_access(&self) -> SendAccessClient {
35 SendAccessClient::new(self.client.clone())
36 }
37
38 pub fn registration(&self) -> RegistrationClient {
40 RegistrationClient::new(self.client.clone())
41 }
42}
43
44pub trait AuthClientExt {
46 fn auth_new(&self) -> AuthClient;
48}
49
50impl AuthClientExt for Client {
51 fn auth_new(&self) -> AuthClient {
52 AuthClient {
53 client: self.clone(),
54 }
55 }
56}