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 edit;
15mod get;
16mod restore;
17
18pub use get::GetAssignedOrgCiphersAdminError;
19
20/// Client for performing admin operations on ciphers. Unlike the regular CiphersClient,
21/// this client uses the admin server API endpoints, and does not modify local state.
22#[cfg_attr(feature = "wasm", wasm_bindgen)]
23pub struct CipherAdminClient {
24    pub(crate) key_store: KeyStore<KeySlotIds>,
25    pub(crate) api_configurations: Arc<ApiConfigurations>,
26    #[deprecated(
27        note = "Use the component fields (key_store, api_configurations) for new operations"
28    )]
29    pub(crate) client: Client,
30}
31
32impl FromClient for CipherAdminClient {
33    fn from_client(client: &Client) -> Self {
34        #[allow(deprecated)]
35        Self {
36            key_store: client.get_part(),
37            api_configurations: client.get_part(),
38            client: client.clone(),
39        }
40    }
41}
42
43#[allow(deprecated)]
44impl CipherAdminClient {
45    async fn is_strict_decrypt(&self) -> bool {
46        self.client.flags().get().await.strict_cipher_decryption
47    }
48}