bitwarden_vault/
password_history_client.rs1use bitwarden_core::Client;
2
3use crate::{DecryptError, EncryptError, PasswordHistory, PasswordHistoryView, VaultClient};
4
5pub struct PasswordHistoryClient {
6 pub(crate) client: Client,
7}
8
9impl PasswordHistoryClient {
10 pub fn encrypt(
11 &self,
12 history_view: PasswordHistoryView,
13 ) -> Result<PasswordHistory, EncryptError> {
14 let key_store = self.client.internal.get_key_store();
15 let history = key_store.encrypt(history_view)?;
16 Ok(history)
17 }
18
19 pub fn decrypt_list(
20 &self,
21 history: Vec<PasswordHistory>,
22 ) -> Result<Vec<PasswordHistoryView>, DecryptError> {
23 let key_store = self.client.internal.get_key_store();
24 let history_view = key_store.decrypt_list(&history)?;
25 Ok(history_view)
26 }
27}
28
29impl VaultClient {
30 pub fn password_history(&self) -> PasswordHistoryClient {
31 PasswordHistoryClient {
32 client: self.client.clone(),
33 }
34 }
35}