i hyperfocused and here is v1
This commit is contained in:
parent
8f43e6a6a9
commit
4090fd621e
34 changed files with 4135 additions and 22 deletions
19
apps/ingest/src/util/verifyGithub.ts
Normal file
19
apps/ingest/src/util/verifyGithub.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { createHmac, timingSafeEqual } from "node:crypto";
|
||||
|
||||
if (!process.env.GITHUB_WEBHOOK_SECRET) {
|
||||
throw new Error("GITHUB_WEBHOOK_SECRET is not defined");
|
||||
}
|
||||
|
||||
export function verifyGithub(signature: string, body: object): boolean {
|
||||
const verify = createHmac(
|
||||
"sha256",
|
||||
// biome-ignore lint/style/noNonNullAssertion: check is ran before the function
|
||||
process.env.GITHUB_WEBHOOK_SECRET!,
|
||||
)
|
||||
.update(JSON.stringify(body))
|
||||
.digest("hex");
|
||||
return timingSafeEqual(
|
||||
Buffer.from(signature),
|
||||
Buffer.from(`sha256=${verify}`),
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue