bitwarden_pm/
lib.rs

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