Skip to main content

bitwarden_auth/registration/
registration_client.rs

1//! Client for account registration and cryptography initialization related API methods.
2//! It is used both for the initial registration request in the case of password registrations,
3//! and for cryptography initialization for a jit provisioned user. After a method
4//! on this client is called, the user account should have initialized account keys, an
5//! authentication method such as SSO or master password, and a decryption method such as
6//! key-connector, TDE, or master password.
7
8use bitwarden_core::Client;
9use bitwarden_error::bitwarden_error;
10use thiserror::Error;
11#[cfg(feature = "wasm")]
12use wasm_bindgen::prelude::*;
13
14/// Client for initializing a user account.
15#[derive(Clone)]
16#[cfg_attr(feature = "wasm", wasm_bindgen)]
17pub struct RegistrationClient {
18    #[allow(dead_code)]
19    pub(crate) client: Client,
20}
21
22impl RegistrationClient {
23    pub(crate) fn new(client: Client) -> Self {
24        Self { client }
25    }
26}
27
28/// Errors that can occur during user registration.
29#[derive(Debug, Error)]
30#[bitwarden_error(flat)]
31pub enum RegistrationError {
32    /// Key Connector API call failed.
33    #[error("Key Connector Api call failed")]
34    KeyConnectorApi,
35    /// API call failed.
36    #[error("Api call failed")]
37    Api,
38    /// Cryptography initialization failed.
39    #[error("Cryptography initialization failed")]
40    Crypto,
41}