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(&self, ciphers: Vec<Cipher>) -> DecryptCipherListResult {
33 self.0.decrypt_list_with_failures(ciphers)
34 }
35
36 pub fn decrypt_fido2_credentials(
37 &self,
38 cipher_view: CipherView,
39 ) -> Result<Vec<Fido2CredentialView>> {
40 Ok(self
41 .0
42 .decrypt_fido2_credentials(cipher_view)
43 .map_err(Error::Decrypt)?)
44 }
45
46 pub fn move_to_organization(
48 &self,
49 cipher: CipherView,
50 organization_id: OrganizationId,
51 ) -> Result<CipherView> {
52 Ok(self
53 .0
54 .move_to_organization(cipher, organization_id)
55 .map_err(Error::Cipher)?)
56 }
57}