Skip to main content

bitwarden_vault/cipher/cipher_client/admin/
mod.rs

1use std::sync::Arc;
2
3use bitwarden_core::{
4    Client, FromClient,
5    client::{ApiConfigurations, FromClientPart},
6    key_management::KeySlotIds,
7};
8use bitwarden_crypto::KeyStore;
9#[cfg(feature = "wasm")]
10use wasm_bindgen::prelude::*;
11
12mod create;
13mod delete;
14mod delete_attachment;
15mod edit;
16mod get;
17mod restore;
18
19pub use get::GetAssignedOrgCiphersAdminError;
20
21/// Client for performing admin operations on ciphers. Unlike the regular CiphersClient,
22/// this client uses the admin server API endpoints, and does not modify local state.
23#[cfg_attr(feature = "wasm", wasm_bindgen)]
24pub struct CipherAdminClient {
25    pub(crate) key_store: KeyStore<KeySlotIds>,
26    pub(crate) api_configurations: Arc<ApiConfigurations>,
27    #[deprecated(
28        note = "Use the component fields (key_store, api_configurations) for new operations"
29    )]
30    pub(crate) client: Client,
31}
32
33impl FromClient for CipherAdminClient {
34    fn from_client(client: &Client) -> Self {
35        #[allow(deprecated)]
36        Self {
37            key_store: client.get_part(),
38            api_configurations: client.get_part(),
39            client: client.clone(),
40        }
41    }
42}
43
44#[allow(deprecated)]
45impl CipherAdminClient {
46    async fn is_strict_decrypt(&self) -> bool {
47        self.client.flags().get().await.strict_cipher_decryption
48    }
49}