bitwarden_uniffi/vault/
ciphers.rs1use bitwarden_collections::collection::CollectionId;
2use bitwarden_core::OrganizationId;
3use bitwarden_vault::{
4 Cipher, CipherListView, CipherView, DecryptCipherListResult, EncryptionContext,
5 Fido2CredentialView,
6};
7
8use crate::Result;
9
10#[allow(missing_docs)]
11#[derive(uniffi::Object)]
12pub struct CiphersClient(pub(crate) bitwarden_vault::CiphersClient);
13
14#[uniffi::export]
15impl CiphersClient {
16 pub fn encrypt(&self, cipher_view: CipherView) -> Result<EncryptionContext> {
18 Ok(self.0.encrypt(cipher_view)?)
19 }
20
21 pub fn decrypt(&self, cipher: Cipher) -> Result<CipherView> {
23 Ok(self.0.decrypt(cipher)?)
24 }
25
26 pub fn decrypt_list(&self, ciphers: Vec<Cipher>) -> Result<Vec<CipherListView>> {
28 Ok(self.0.decrypt_list(ciphers)?)
29 }
30
31 pub fn decrypt_list_with_failures(
36 &self,
37 ciphers: Vec<Cipher>,
38 ) -> Result<DecryptCipherListResult> {
39 Ok(self.0.decrypt_list_with_failures(ciphers))
40 }
41
42 pub fn decrypt_fido2_credentials(
43 &self,
44 cipher_view: CipherView,
45 ) -> Result<Vec<Fido2CredentialView>> {
46 Ok(self.0.decrypt_fido2_credentials(cipher_view)?)
47 }
48
49 pub fn move_to_organization(
51 &self,
52 cipher: CipherView,
53 organization_id: OrganizationId,
54 ) -> Result<CipherView> {
55 Ok(self.0.move_to_organization(cipher, organization_id)?)
56 }
57
58 pub async fn prepare_ciphers_for_bulk_share(
60 &self,
61 ciphers: Vec<CipherView>,
62 organization_id: OrganizationId,
63 collection_ids: Vec<CollectionId>,
64 ) -> Result<Vec<EncryptionContext>> {
65 Ok(self
66 .0
67 .prepare_ciphers_for_bulk_share(ciphers, organization_id, collection_ids)
68 .await?)
69 }
70}