MCPcopy Create free account
hub / github.com/ColeMurray/background-agents / verifyWebhookSignature

Function verifyWebhookSignature

packages/github-bot/src/verify.ts:3–16  ·  view source on GitHub ↗
(
  secret: string,
  rawBody: string,
  signatureHeader: string | null
)

Source from the content-addressed store, hash-verified

1import { computeHmacHex, timingSafeEqual } from "@open-inspect/shared/auth";
2
3export async function verifyWebhookSignature(
4 secret: string,
5 rawBody: string,
6 signatureHeader: string | null
7): Promise<boolean> {
8 if (!signatureHeader || !signatureHeader.startsWith("sha256=")) {
9 return false;
10 }
11
12 const expectedHex = signatureHeader.slice("sha256=".length);
13 const computedHex = await computeHmacHex(rawBody, secret);
14
15 return timingSafeEqual(expectedHex, computedHex);
16}

Callers 2

verify.test.tsFile · 0.90
index.tsFile · 0.90

Calls 2

computeHmacHexFunction · 0.90
timingSafeEqualFunction · 0.90

Tested by

no test coverage detected