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, VaultLockedError, 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(crate) use auth_request::{auth_request_decrypt_master_key, auth_request_decrypt_user_key};
34#[cfg(feature = "internal")]
35pub use auth_request::{ApproveAuthRequestError, AuthRequestResponse};
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)]
54pub enum AuthValidateError {
55    #[error(transparent)]
56    NotAuthenticated(#[from] NotAuthenticatedError),
57    #[error(transparent)]
58    WrongPassword(#[from] WrongPasswordError),
59    #[error(transparent)]
60    VaultLocked(#[from] VaultLockedError),
61    #[error("wrong user key")]
62    WrongUserKey,
63    #[error(transparent)]
64    Crypto(#[from] bitwarden_crypto::CryptoError),
65}