1use reqwest::StatusCode;
2
3#[derive(thiserror::Error, Debug)]
4pub enum OpenIdError {
5 #[error("Reqwest error: {0}")]
6 Reqwest(#[from] reqwest::Error),
7 #[error("http request failed with status: {0}")]
8 HTTPRequestFailedWithInvalidStatus(StatusCode),
9 #[error("Serde json error: {0}")]
10 SerdeJson(#[from] serde_json::Error),
11 #[error("encode authorization url query: {0}")]
12 EncodeAuthorizationUrlQuery(#[source] serde_qs::Error),
13 #[error("validate id token: {0}")]
14 ValidateIdToken(Box<Self>),
15 #[error("decode jwt header: {0}")]
16 DecodeJWTHeader(#[source] jsonwebtoken::errors::Error),
17 #[error("kid is required for signature verification!")]
18 KidRequiredForSignatureVerification,
19 #[error("missing jwks in client configuration!")]
20 MissingJWKs,
21 #[error("unknown kid for signature verification: {0}")]
22 UnknownKid(String),
23 #[error("failed to decode jwk: {0}")]
24 DecodeJWK(#[source] jsonwebtoken::errors::Error),
25 #[error("failed to validate jwk: {0}")]
26 ValidateJWT(#[source] jsonwebtoken::errors::Error),
27 #[error("missing nonce in id token!")]
28 MissingNonceInIdToken,
29 #[error("invalid nonce in id token!")]
30 InvalidNonceInIdToken,
31 #[error("missing refresh token")]
32 MissingRefreshToken,
33 #[cfg(feature = "crypto-wrapper")]
34 #[error("State error: invalid IP")]
35 StateErrorInvalidIP,
36 #[cfg(feature = "crypto-wrapper")]
37 #[error("State error: expired")]
38 StateErrorExpired,
39 #[cfg(feature = "crypto-wrapper")]
40 #[error("Rkyv error: {0}")]
41 RkyvError(#[from] rkyv::rancor::Error),
42 #[cfg(feature = "crypto-wrapper")]
43 #[error("Base64 decoding error: {0}")]
44 Base64Decode(#[from] base64::DecodeError),
45 #[cfg(feature = "crypto-wrapper")]
46 #[error("Input string is smaller than nonce!")]
47 DecInputStringSmallerThanNonce,
48 #[cfg(feature = "crypto-wrapper")]
49 #[error("Failed to decrypt wrapped data!")]
50 DecryptWrappedData,
51 #[cfg(feature = "crypto-wrapper")]
52 #[error("try from slice error: {0}")]
53 TryFromSliceError(#[from] std::array::TryFromSliceError),
54}
55
56pub(crate) type Res<T = ()> = Result<T, OpenIdError>;