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