bitwarden_wasm_internal/
crypto.rsuse std::rc::Rc;
use bitwarden_core::{
client::encryption_settings::EncryptionSettingsError,
mobile::crypto::{
InitOrgCryptoRequest, InitUserCryptoRequest, MakeKeyPairResponse,
VerifyAsymmetricKeysRequest, VerifyAsymmetricKeysResponse,
},
Client,
};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct CryptoClient(Rc<Client>);
impl CryptoClient {
pub fn new(client: Rc<Client>) -> Self {
Self(client)
}
}
#[wasm_bindgen]
impl CryptoClient {
pub async fn initialize_user_crypto(
&self,
req: InitUserCryptoRequest,
) -> Result<(), EncryptionSettingsError> {
self.0.crypto().initialize_user_crypto(req).await
}
pub async fn initialize_org_crypto(
&self,
req: InitOrgCryptoRequest,
) -> Result<(), EncryptionSettingsError> {
self.0.crypto().initialize_org_crypto(req).await
}
pub fn make_key_pair(
&self,
user_key: String,
) -> Result<MakeKeyPairResponse, bitwarden_core::Error> {
self.0.crypto().make_key_pair(user_key)
}
pub fn verify_asymmetric_keys(
&self,
request: VerifyAsymmetricKeysRequest,
) -> Result<VerifyAsymmetricKeysResponse, bitwarden_core::Error> {
self.0.crypto().verify_asymmetric_keys(request)
}
}