Back to packages list

Vals using @octokit/webhooks-methods

Description from the NPM package:
Methods to handle GitHub Webhook requests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { verify } from "https://esm.sh/@octokit/webhooks-methods@3.0.2?pin=v106";
import { email } from "https://esm.town/v/std/email?v=11";
export const githubWebhookWithVerify = async (req: Request) => {
const payload = await req.json();
const verified = await verify(
Deno.env.get("githubWebhookToken"),
JSON.stringify(payload),
req.headers.get("X-Hub-Signature-256"),
);
if (!verified) {
return new Response("Unauthorized", { status: 401 });
}
const { action, sender, repository } = payload;
if (action === "created") {
email({ text: `Repository ${repository.full_name} starred by ${sender.login}` });
}
return new Response("OK", { status: 200 });
};
1
2
3
4
5
6
7
8
9
10
export const verifyGithubWebhookSignature = async (
secret: string,
payload: string,
signatureHeader: string,
) => {
const { verify } = await import(
"https://esm.sh/@octokit/webhooks-methods@3.0.2?pin=v106"
);
return await verify(secret, payload, signatureHeader) === true;
};
1
Next