bitwarden_pm/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use std::sync::Arc;
4
5use bitwarden_auth::AuthClientExt as _;
6use bitwarden_core::client::internal::ClientManagedTokens;
7use bitwarden_exporters::ExporterClientExt as _;
8use bitwarden_generators::GeneratorClientsExt as _;
9use bitwarden_send::SendClientExt as _;
10use bitwarden_vault::VaultClientExt as _;
11
12#[cfg(feature = "uniffi")]
13uniffi::setup_scaffolding!();
14
15/// Re-export subclients for easier access
16pub mod clients {
17    pub use bitwarden_auth::AuthClient;
18    pub use bitwarden_core::key_management::CryptoClient;
19    pub use bitwarden_exporters::ExporterClient;
20    pub use bitwarden_generators::GeneratorClient;
21    pub use bitwarden_send::SendClient;
22    pub use bitwarden_vault::VaultClient;
23}
24
25/// The main entry point for the Bitwarden Password Manager SDK
26pub struct PasswordManagerClient(pub bitwarden_core::Client);
27
28impl PasswordManagerClient {
29    /// Initialize a new instance of the SDK client
30    pub fn new(settings: Option<bitwarden_core::ClientSettings>) -> Self {
31        Self(bitwarden_core::Client::new(settings))
32    }
33
34    /// Initialize a new instance of the SDK client with client-managed tokens
35    pub fn new_with_client_tokens(
36        settings: Option<bitwarden_core::ClientSettings>,
37        tokens: Arc<dyn ClientManagedTokens>,
38    ) -> Self {
39        Self(bitwarden_core::Client::new_with_client_tokens(
40            settings, tokens,
41        ))
42    }
43
44    /// Auth operations
45    pub fn auth(&self) -> bitwarden_auth::AuthClient {
46        self.0.auth_new()
47    }
48
49    /// Crypto operations
50    pub fn crypto(&self) -> bitwarden_core::key_management::CryptoClient {
51        self.0.crypto()
52    }
53
54    /// Vault item operations
55    pub fn vault(&self) -> bitwarden_vault::VaultClient {
56        self.0.vault()
57    }
58
59    /// Exporter operations
60    pub fn exporters(&self) -> bitwarden_exporters::ExporterClient {
61        self.0.exporters()
62    }
63
64    /// Generator operations
65    pub fn generator(&self) -> bitwarden_generators::GeneratorClient {
66        self.0.generator()
67    }
68
69    /// Send operations
70    pub fn sends(&self) -> bitwarden_send::SendClient {
71        self.0.sends()
72    }
73}