bitwarden_uniffi/vault/
ciphers.rs1use bitwarden_core::OrganizationId;
2use bitwarden_vault::{Cipher, CipherListView, CipherView, EncryptionContext, Fido2CredentialView};
3use uuid::Uuid;
4
5use crate::{error::Error, Result};
6
7#[allow(missing_docs)]
8#[derive(uniffi::Object)]
9pub struct CiphersClient(pub(crate) bitwarden_vault::CiphersClient);
10
11#[uniffi::export]
12impl CiphersClient {
13 pub fn encrypt(&self, cipher_view: CipherView) -> Result<EncryptionContext> {
15 Ok(self.0.encrypt(cipher_view).map_err(Error::Encrypt)?)
16 }
17
18 pub fn decrypt(&self, cipher: Cipher) -> Result<CipherView> {
20 Ok(self.0.decrypt(cipher).map_err(Error::Decrypt)?)
21 }
22
23 pub fn decrypt_list(&self, ciphers: Vec<Cipher>) -> Result<Vec<CipherListView>> {
25 Ok(self.0.decrypt_list(ciphers).map_err(Error::Decrypt)?)
26 }
27
28 pub fn decrypt_fido2_credentials(
29 &self,
30 cipher_view: CipherView,
31 ) -> Result<Vec<Fido2CredentialView>> {
32 Ok(self
33 .0
34 .decrypt_fido2_credentials(cipher_view)
35 .map_err(Error::Decrypt)?)
36 }
37
38 pub fn move_to_organization(
40 &self,
41 cipher: CipherView,
42 organization_id: Uuid,
43 ) -> Result<CipherView> {
44 Ok(self
45 .0
46 .move_to_organization(cipher, OrganizationId::new(organization_id))
47 .map_err(Error::Cipher)?)
48 }
49}