diff --git a/relay_rpc/src/auth/cacao.rs b/relay_rpc/src/auth/cacao.rs index 52bd759..18689e6 100644 --- a/relay_rpc/src/auth/cacao.rs +++ b/relay_rpc/src/auth/cacao.rs @@ -7,7 +7,10 @@ use { core::fmt::Debug, serde::{Deserialize, Serialize}, serde_json::value::RawValue, - std::fmt::{Display, Write}, + std::{ + fmt::{Display, Write}, + sync::Arc, + }, }; pub mod header; @@ -17,8 +20,8 @@ pub mod signature; /// Errors that can occur during Cacao verification. #[derive(Debug, thiserror::Error)] pub enum CacaoError { - #[error("Invalid header")] - Header, + #[error("Header `t` value unsupported: {0}")] + HeaderTypeUnsupported(Arc), #[error("Invalid or missing identity key in payload resources")] PayloadIdentityKey, diff --git a/relay_rpc/src/auth/cacao/header.rs b/relay_rpc/src/auth/cacao/header.rs index fb9823b..6fed5cd 100644 --- a/relay_rpc/src/auth/cacao/header.rs +++ b/relay_rpc/src/auth/cacao/header.rs @@ -1,20 +1,21 @@ use { super::CacaoError, serde::{Deserialize, Serialize}, + std::sync::Arc, }; pub const EIP4361: &str = "eip4361"; #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Hash)] pub struct Header { - pub t: String, + pub t: Arc, } impl Header { pub fn validate(&self) -> Result<(), CacaoError> { - match self.t.as_str() { + match self.t.as_ref() { EIP4361 => Ok(()), - _ => Err(CacaoError::Header), + _ => Err(CacaoError::HeaderTypeUnsupported(self.t.clone())), } } }