apps/gateway/src/routes/integrations.ts
Metadata
- Purpose: Gateway HTTP route handlers and request/response behavior.
- Domain:
applications - Language:
ts - Bytes: 3823
- Lines: 104
- Content hash (short):
e622473b - Source (start): apps/gateway/src/routes/integrations.ts:1
- Source (end): apps/gateway/src/routes/integrations.ts:104
Indexed Symbols
validateSignature(line 9, function) - Implements validate signature for HTTP request handling.
Markdown Headings (if applicable)
No markdown headings detected.
Source Preview
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
import type { FastifyPluginAsync } from "fastify";
import { env } from "../config/env.js";
import { enqueueOutboxEvent } from "../services/event-pipeline.js";
import { getEffectivePlatformSettings, resolveSecretValue } from "../services/runtime-config.js";
import { recordWebhookReceipt } from "../services/webhook-repository.js";
import { ensureUuid, isUuid } from "../utils/uuid.js";
function validateSignature(rawBody: string, signatureHeader: string | undefined, secret: string | undefined): boolean {
if (!secret) {
return false;
}
if (!signatureHeader?.startsWith("sha256=")) {
return false;
}
const expected = Buffer.from(
`sha256=${createHmac("sha256", secret).update(rawBody).digest("hex")}`,
"utf8"
);
const received = Buffer.from(signatureHeader, "utf8");
if (expected.length !== received.length) {
return false;
}