mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-20 17:13:49 +00:00
Add POST /webhook/{groupId} with per-group secrets (KV tenant:{groupId}), a custom provider (X-WebHooker-Signature HMAC, arbitrary JSON -> custom events through the route pipeline), and GitHub App installation isolation (Group.installationId) with automatic provisioning on installation.created (inst-{id} groups or binding matching owners groups). Includes WebhookPanel admin UI, custom route template, docs and 157 passing tests.
21 lines
707 B
TypeScript
21 lines
707 B
TypeScript
import type { WebhookEvent } from "../../types";
|
|
|
|
export function parseEvent(headers: Record<string, string>, body: string): WebhookEvent | null {
|
|
const event = headers["x-github-event"];
|
|
const signature = headers["x-hub-signature-256"];
|
|
const deliveryId = headers["x-github-delivery"];
|
|
|
|
if (!event) return null;
|
|
|
|
try {
|
|
const payload = JSON.parse(body) as Record<string, unknown>;
|
|
const installationId =
|
|
typeof (payload.installation as { id?: unknown } | undefined)?.id === "number"
|
|
? (payload.installation as { id: number }).id
|
|
: undefined;
|
|
return { provider: "github", event, payload, signature, deliveryId, installationId };
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|