feat: add gitea/forgejo support

This commit is contained in:
RhenCloud 2026-08-11 22:01:04 +08:00
parent ace036c209
commit aec0d1a257
43 changed files with 683 additions and 130 deletions

View file

@ -0,0 +1,15 @@
import { hmacSha256Hex, timingSafeEqual } from "../hmac";
/**
* Gitea signs webhooks with the HMAC-SHA256 hex digest of the raw body in the
* `X-Gitea-Signature` header (no `sha256=` prefix, unlike GitHub).
*/
export async function verifyGiteaSignature(
payload: string,
signature: string | undefined,
secret: string | undefined,
): Promise<boolean> {
if (!signature || !secret) return false;
const expected = await hmacSha256Hex(secret, payload);
return timingSafeEqual(signature, expected);
}