This commit is contained in:
2026-09-28 23:15:47 +05:30
commit 605c6a2e58
41 changed files with 4299 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
import { createHash, timingSafeEqual } from "crypto";
export function isAuthorized(header: string | null): boolean {
const expected = process.env.SYNC_TOKEN;
if (!expected || !header) return false;
const match = /^Bearer (\S+)$/.exec(header);
if (!match) return false;
const presented = createHash("sha256").update(match[1]).digest();
const actual = createHash("sha256").update(expected).digest();
return timingSafeEqual(presented, actual);
}