1#[derive(Debug, thiserror::Error)]
3pub enum KeyError {
4 #[error("invalid algorithm for key type")]
5 InvalidAlgorithm,
6
7 #[error("invalid algorithm for {0} curve")]
8 InvalidAlgorithmForCurve(&'static str),
9
10 #[error("invalid coordinate length for {0}")]
11 InvalidCoordinateLength(&'static str),
12
13 #[error("invalid curve for {0} key")]
14 InvalidCurve(&'static str),
15
16 #[error("missing private key")]
17 MissingPrivateKey,
18
19 #[error("OCT key cannot be converted to public key")]
20 NoPublicKey,
21
22 #[error("key does not support verification")]
23 VerifyUnsupported,
24
25 #[error("key does not support signing")]
26 SignUnsupported,
27
28 #[error("cannot find signing key")]
29 NoSigningKey,
30
31 #[error("cannot find key with kid {0}")]
32 KeyNotFound(String),
33
34 #[error("missing kid in JWT header")]
35 MissingKid,
36
37 #[error("missing x() point in EC key")]
38 MissingEcX,
39
40 #[error("missing y() point in EC key")]
41 MissingEcY,
42}
43
44#[derive(Debug, thiserror::Error)]
46pub enum Error {
47 #[error(transparent)]
48 Key(#[from] KeyError),
49
50 #[error("no publish or subscribe allowed; token is useless")]
51 UselessToken,
52
53 #[error("invalid algorithm: {0}")]
54 InvalidAlgorithm(String),
55
56 #[error("token has expired")]
57 TokenExpired,
58
59 #[error(transparent)]
60 Json(#[from] serde_json::Error),
61
62 #[error(transparent)]
63 Io(#[from] std::io::Error),
64
65 #[error(transparent)]
66 Base64(#[from] base64::DecodeError),
67
68 #[error(transparent)]
69 Utf8(#[from] std::string::FromUtf8Error),
70
71 #[error(transparent)]
72 Jwt(#[from] jsonwebtoken::errors::Error),
73
74 #[error(transparent)]
75 Pkcs8(#[from] elliptic_curve::pkcs8::Error),
76
77 #[error(transparent)]
78 EllipticCurve(#[from] elliptic_curve::Error),
79
80 #[error(transparent)]
81 Rsa(#[from] rsa::Error),
82
83 #[error(transparent)]
84 RsaPkcs1(#[from] rsa::pkcs1::Error),
85
86 #[error(transparent)]
87 AwsUnspecified(#[from] aws_lc_rs::error::Unspecified),
88
89 #[error(transparent)]
90 AwsKeyRejected(#[from] aws_lc_rs::error::KeyRejected),
91
92 #[cfg(feature = "jwks-loader")]
93 #[error(transparent)]
94 Reqwest(#[from] reqwest::Error),
95
96 #[error("{0}")]
97 Other(String),
98}
99
100pub type Result<T> = std::result::Result<T, Error>;