import { timingSafeEqual } from 'node:crypto'; // Constant-time string comparison. Returns false for length mismatch (the // length difference itself is observable, but the per-byte loop isn't). // Used for shared-secret header checks (commands-sync-key, system-key, // etc.) to keep timing-oracle attacks off the table. export function safeEqual(a: string, b: string): boolean { const ab = Buffer.from(a); const bb = Buffer.from(b); if (ab.length !== bb.length) return false; return timingSafeEqual(ab, bb); }