hive_client/client/authentication/
error.rs1use crate::client::authentication::ChallengeRequest;
2use aws_cognito_srp::SrpError;
3use aws_sdk_cognitoidentityprovider::error::SdkError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7#[error(transparent)]
8#[non_exhaustive]
9pub enum AuthenticationError {
11 #[error("The session token was not found in the response")]
12 InvalidAccessToken,
14
15 #[error("The presented challenge is not supported. Challenge was: {0}")]
16 UnsupportedChallenge(String),
18
19 #[error(transparent)]
20 LoginFailed(
22 #[from]
23 SdkError<aws_sdk_cognitoidentityprovider::operation::initiate_auth::InitiateAuthError>,
24 ),
25
26 #[error(transparent)]
27 ChallengeFailed(
29 #[from]
30 SdkError<aws_sdk_cognitoidentityprovider::operation::respond_to_auth_challenge::RespondToAuthChallengeError>,
31 ),
32
33 #[error("The challenge was not handled correctly")]
34 MissingChallengeParameter(String),
36
37 #[error("An error occurred while trying to authenticate the user")]
38 SrpFailed(
40 #[from]
41 SrpError,
42 ),
43
44 #[error("A challenge was requested")]
45 NextChallenge(ChallengeRequest),
49
50 DeviceConfirmationError(
52 #[from]
53 DeviceConfirmationError
54 ),
55
56 #[error("There is currently no valid authentication in progress")]
57 NoAuthenticationInProgress,
59}
60
61#[derive(Error, Debug)]
62#[error(transparent)]
63pub enum RefreshError {
65 #[error("The request to refresh the authentication tokens failed as the access token could not be validated")]
66 InvalidAccessToken,
69
70 #[error("The request to refresh the authentication tokens failed")]
71 RequestFailed(String),
73
74 #[error("There is currently no valid authentication in progress")]
75 NotLoggedIn,
77}
78
79#[derive(Error, Debug)]
80#[error(transparent)]
81pub enum DeviceConfirmationError {
84 #[error(transparent)]
85 ConfirmationFailed(
87 #[from]
88 SdkError<aws_sdk_cognitoidentityprovider::operation::confirm_device::ConfirmDeviceError>,
89 ),
90
91 #[error(transparent)]
92 StatusUpdateFailed(
94 #[from]
95 SdkError<aws_sdk_cognitoidentityprovider::operation::update_device_status::UpdateDeviceStatusError>,
96 ),
97
98 #[error("The device being confirmed is already tracked")]
99 DeviceAlreadyTracked,
101}