bitwarden_uniffi/vault/
ciphers.rs1use bitwarden_core::OrganizationId;
2use bitwarden_vault::{
3 Cipher, CipherListView, CipherView, DecryptCipherListResult, EncryptionContext,
4 Fido2CredentialView,
5};
6
7use crate::{error::Error, Result};
8
9#[allow(missing_docs)]
10#[derive(uniffi::Object)]
11pub struct CiphersClient(pub(crate) bitwarden_vault::CiphersClient);
12
13#[uniffi::export]
14impl CiphersClient {
15 pub fn encrypt(&self, cipher_view: CipherView) -> Result<EncryptionContext> {
17 Ok(self.0.encrypt(cipher_view).map_err(Error::Encrypt)?)
18 }
19
20 pub fn decrypt(&self, cipher: Cipher) -> Result<CipherView> {
22 Ok(self.0.decrypt(cipher).map_err(Error::Decrypt)?)
23 }
24
25 pub fn decrypt_list(&self, ciphers: Vec<Cipher>) -> Result<Vec<CipherListView>> {
27 Ok(self.0.decrypt_list(ciphers).map_err(Error::Decrypt)?)
28 }
29
30 pub fn decrypt_list_with_failures(
35 &self,
36 ciphers: Vec<Cipher>,
37 ) -> Result<DecryptCipherListResult> {
38 Ok(self.0.decrypt_list_with_failures(ciphers))
39 }
40
41 pub fn decrypt_fido2_credentials(
42 &self,
43 cipher_view: CipherView,
44 ) -> Result<Vec<Fido2CredentialView>> {
45 Ok(self
46 .0
47 .decrypt_fido2_credentials(cipher_view)
48 .map_err(Error::Decrypt)?)
49 }
50
51 pub fn move_to_organization(
53 &self,
54 cipher: CipherView,
55 organization_id: OrganizationId,
56 ) -> Result<CipherView> {
57 Ok(self
58 .0
59 .move_to_organization(cipher, organization_id)
60 .map_err(Error::Cipher)?)
61 }
62}