Check it came from Routr
Routr-Signature is t= the time in seconds, then v1= an HMAC-SHA256 of t.body (the raw body, as sent) with your address’s signing secret. For 24 hours after the secret is replaced there are two v1=, one for each secret. Refuse a time more than 5 minutes old, so an old message can’t be sent again.
import crypto from 'node:crypto';
// rawBody: the request's body exactly as it came, before any JSON parsing.
function fromRoutr(rawBody, header, secret) {
const parts = header.split(',').map((p) => p.split('='));
const t = Number(parts.find(([k]) => k === 't')?.[1]);
if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false;
const want = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
return parts.some(([k, v]) => k === 'v1' && v.length === want.length &&
crypto.timingSafeEqual(Buffer.from(v), Buffer.from(want)));
}