feat: nip98 timestamp window

closes https://github.com/v0l/route96/issues/12
This commit is contained in:
2025-03-31 11:49:25 +01:00
parent f569b94d19
commit afb33085b7

View File

@ -33,10 +33,12 @@ impl<'r> FromRequest<'r> for Nip98Auth {
if event.kind != Kind::HttpAuth { if event.kind != Kind::HttpAuth {
return Outcome::Error((Status::new(401), "Wrong event kind")); return Outcome::Error((Status::new(401), "Wrong event kind"));
} }
if event.created_at > Timestamp::now() { if (event.created_at.as_u64() as i64 -
Timestamp::now().as_u64() as i64).abs() >= 60
{
return Outcome::Error(( return Outcome::Error((
Status::new(401), Status::new(401),
"Created timestamp is in the future", "Created timestamp is out of range",
)); ));
} }