bitwarden_wasm_internal/
crypto.rs1use bitwarden_core::{
2 client::encryption_settings::EncryptionSettingsError,
3 mobile::crypto::{
4 InitOrgCryptoRequest, InitUserCryptoRequest, MakeKeyPairResponse,
5 VerifyAsymmetricKeysRequest, VerifyAsymmetricKeysResponse,
6 },
7};
8use bitwarden_crypto::CryptoError;
9use wasm_bindgen::prelude::*;
10
11#[wasm_bindgen]
12pub struct CryptoClient(bitwarden_core::mobile::CryptoClient);
13
14impl CryptoClient {
15 pub fn new(client: bitwarden_core::mobile::CryptoClient) -> Self {
16 Self(client)
17 }
18}
19
20#[wasm_bindgen]
21impl CryptoClient {
22 pub async fn initialize_user_crypto(
25 &self,
26 req: InitUserCryptoRequest,
27 ) -> Result<(), EncryptionSettingsError> {
28 self.0.initialize_user_crypto(req).await
29 }
30
31 pub async fn initialize_org_crypto(
34 &self,
35 req: InitOrgCryptoRequest,
36 ) -> Result<(), EncryptionSettingsError> {
37 self.0.initialize_org_crypto(req).await
38 }
39
40 pub fn make_key_pair(&self, user_key: String) -> Result<MakeKeyPairResponse, CryptoError> {
43 self.0.make_key_pair(user_key)
44 }
45
46 pub fn verify_asymmetric_keys(
50 &self,
51 request: VerifyAsymmetricKeysRequest,
52 ) -> Result<VerifyAsymmetricKeysResponse, CryptoError> {
53 self.0.verify_asymmetric_keys(request)
54 }
55}