A better Rust ATProto crate
1use miette::Diagnostic; 2use thiserror::Error; 3 4/// Errors emitted by OAuth helpers. 5#[derive(Debug, Error, Diagnostic)] 6pub enum OAuthError { 7 /// Invalid or unsupported JWK 8 #[error("invalid JWK: {0}")] 9 #[diagnostic( 10 code(jacquard_oauth::jwk), 11 help("Ensure EC P-256 JWK with base64url x,y,d values") 12 )] 13 Jwk(String), 14 /// Signing error 15 #[error("signing error: {0}")] 16 #[diagnostic( 17 code(jacquard_oauth::signing), 18 help("Check ES256 key material and input payloads") 19 )] 20 Signing(String), 21 /// Serialization error 22 #[error(transparent)] 23 #[diagnostic(code(jacquard_oauth::serde))] 24 Serde(#[from] serde_json::Error), 25 /// URL error 26 #[error(transparent)] 27 #[diagnostic(code(jacquard_oauth::url))] 28 Url(#[from] url::ParseError), 29 /// URL error 30 #[error(transparent)] 31 #[diagnostic(code(jacquard_oauth::url))] 32 UrlEncoding(#[from] serde_html_form::ser::Error), 33 /// PKCE error 34 #[error("pkce error: {0}")] 35 #[diagnostic( 36 code(jacquard_oauth::pkce), 37 help("PKCE must use S256; ensure verifier/challenge generated") 38 )] 39 Pkce(String), 40} 41 42pub type Result<T> = core::result::Result<T, OAuthError>;