bitwarden_core/auth/
mod.rs

1//! Authentication module
2//!
3//! Contains all the authentication related functionality for registering and logging in.
4
5use thiserror::Error;
6
7use crate::{NotAuthenticatedError, WrongPasswordError};
8
9mod access_token;
10// API is intentionally not visible outside of `auth` as these should be considered private.
11mod api;
12#[cfg(feature = "internal")]
13pub(crate) use api::response::user_decryption_options_response::UserDecryptionOptionsResponseModel;
14#[allow(missing_docs)]
15pub mod auth_client;
16mod jwt_token;
17#[allow(missing_docs)]
18pub mod login;
19#[allow(missing_docs)]
20#[cfg(feature = "internal")]
21pub mod password;
22#[allow(missing_docs)]
23#[cfg(feature = "internal")]
24pub mod pin;
25#[allow(missing_docs)]
26pub mod renew;
27pub use access_token::{AccessToken, AccessTokenInvalidError};
28pub use jwt_token::*;
29
30#[cfg(feature = "internal")]
31mod auth_request;
32#[cfg(feature = "internal")]
33pub use auth_request::{ApproveAuthRequestError, AuthRequestResponse};
34#[cfg(feature = "internal")]
35pub(crate) use auth_request::{auth_request_decrypt_master_key, auth_request_decrypt_user_key};
36
37#[cfg(feature = "internal")]
38mod register;
39#[cfg(feature = "internal")]
40pub use register::{RegisterError, RegisterKeyResponse, RegisterRequest};
41
42#[cfg(feature = "internal")]
43mod tde;
44#[cfg(feature = "internal")]
45pub use tde::RegisterTdeKeyResponse;
46#[cfg(feature = "internal")]
47mod key_connector;
48#[cfg(feature = "internal")]
49pub use key_connector::KeyConnectorResponse;
50
51/// Error for authentication related operations
52#[allow(missing_docs)]
53#[derive(Debug, Error)]
54#[cfg_attr(feature = "uniffi", derive(uniffi::Error), uniffi(flat_error))]
55pub enum AuthValidateError {
56    #[error(transparent)]
57    NotAuthenticated(#[from] NotAuthenticatedError),
58    #[error(transparent)]
59    WrongPassword(#[from] WrongPasswordError),
60    #[error("wrong user key")]
61    WrongUserKey,
62    #[error(transparent)]
63    Crypto(#[from] bitwarden_crypto::CryptoError),
64}