mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
11 lines
351 B
TypeScript
11 lines
351 B
TypeScript
import { hmacSha256Hex, timingSafeEqual } from "../hmac";
|
|
|
|
export async function verifySignature(
|
|
payload: string,
|
|
signature: string | undefined,
|
|
secret: string,
|
|
): Promise<boolean> {
|
|
if (!signature || !secret) return false;
|
|
const expected = `sha256=${await hmacSha256Hex(secret, payload)}`;
|
|
return timingSafeEqual(signature, expected);
|
|
}
|