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
12/// Client for initializing a user account.
13#[derive(Clone)]
14#[bitwarden_ffi::wasm_object]
15pub struct RegistrationClient {
16    #[allow(dead_code)]
17    pub(crate) client: Client,
18}
19
20impl RegistrationClient {
21    pub(crate) fn new(client: Client) -> Self {
22        Self { client }
23    }
24}
25
26/// Errors that can occur during user registration.
27#[derive(Debug, Error)]
28#[bitwarden_error(flat)]
29pub enum RegistrationError {
30    /// Key Connector API call failed.
31    #[error("Key Connector Api call failed")]
32    KeyConnectorApi,
33    /// API call failed.
34    #[error("Api call failed")]
35    Api,
36    /// Cryptography initialization failed.
37    #[error("Cryptography initialization failed")]
38    Crypto,
39    /// Caller-provided input failed validation (e.g. malformed UUID).
40    #[error("Invalid input: {0}")]
41    InvalidInput(String),
42}