Add player bug reports and profile identity features

This commit is contained in:
2026-10-08 18:27:20 +05:00
parent 36e8d11eb4
commit 0b08672f4a
51 changed files with 3938 additions and 45 deletions

22
lib/support-signature.ts Normal file
View File

@@ -0,0 +1,22 @@
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifySupportWebhook(
raw: string,
signature: string | null,
secret: string,
now = Date.now(),
) {
if (!secret || !signature || !/^[a-f0-9]{64}$/i.test(signature)) return false;
const expected = createHmac("sha256", secret).update(raw).digest();
if (!timingSafeEqual(expected, Buffer.from(signature, "hex"))) return false;
try {
const timestamp = JSON.parse(raw).webhookTimestamp;
return (
typeof timestamp === "number" &&
Number.isFinite(timestamp) &&
Math.abs(now - timestamp) <= 60_000
);
} catch {
return false;
}
}