Skip to main content

bitwarden_uniffi/auth/
registration.rs

1use bitwarden_auth::{
2    AuthClientExt,
3    registration::{
4        JitMasterPasswordRegistrationRequest, JitMasterPasswordRegistrationResponse,
5        KeyConnectorRegistrationResult, TdeRegistrationRequest, TdeRegistrationResponse,
6    },
7};
8
9use crate::error::BitwardenError;
10
11#[derive(uniffi::Object)]
12pub struct RegistrationClient(pub(crate) bitwarden_core::Client);
13
14#[uniffi::export(async_runtime = "tokio")]
15impl RegistrationClient {
16    /// Initializes a new cryptographic state for a user and posts it to the server; enrolls in
17    /// admin password reset and finally enrolls the user to TDE unlock.
18    pub async fn post_keys_for_tde_registration(
19        &self,
20        request: TdeRegistrationRequest,
21    ) -> Result<TdeRegistrationResponse, BitwardenError> {
22        Ok(self
23            .0
24            .auth_new()
25            .registration()
26            .post_keys_for_tde_registration(request)
27            .await?)
28    }
29
30    /// Initializes a new cryptographic state for a user and posts it to the server; enrolls the
31    /// user to key connector unlock.
32    pub async fn post_keys_for_key_connector_registration(
33        &self,
34        key_connector_url: String,
35        sso_org_identifier: String,
36    ) -> Result<KeyConnectorRegistrationResult, BitwardenError> {
37        Ok(self
38            .0
39            .auth_new()
40            .registration()
41            .post_keys_for_key_connector_registration(key_connector_url, sso_org_identifier)
42            .await?)
43    }
44
45    /// Initializes a new cryptographic state for a user and posts it to the server;
46    /// enrolls the user to master password unlock.
47    pub async fn post_keys_for_jit_password_registration(
48        &self,
49        request: JitMasterPasswordRegistrationRequest,
50    ) -> Result<JitMasterPasswordRegistrationResponse, BitwardenError> {
51        Ok(self
52            .0
53            .auth_new()
54            .registration()
55            .post_keys_for_jit_password_registration(request)
56            .await?)
57    }
58}