The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
rename verifyIntercomWebhookSignature
Steven Tey739a2c401722
diff --git a/apps/web/app/(ee)/api/intercom/webhook/health-check/route.ts b/apps/web/app/(ee)/api/intercom/webhook/health-check/route.tsindex 91aad15175..284d91ac43 100644--- a/apps/web/app/(ee)/api/intercom/webhook/health-check/route.ts+++ b/apps/web/app/(ee)/api/intercom/webhook/health-check/route.ts@@ -8,12 +8,12 @@ import {import { prisma } from "@dub/prisma";import { INTERCOM_INTEGRATION_ID } from "@dub/utils";import { NextResponse } from "next/server";-import { verifyWebhookSignature } from "../verify-webhook";+import { verifyIntercomWebhookSignature } from "../verify-webhook-signature";// POST /api/intercom/webhook/health-check – health check for the Intercom webhookexport const POST = withAxiom(async (req) => {try {- const rawBody = await verifyWebhookSignature(req);+ const rawBody = await verifyIntercomWebhookSignature(req);const body = JSON.parse(rawBody);const { workspace_id: intercomWorkspaceId } =diff --git a/apps/web/app/(ee)/api/intercom/webhook/route.ts b/apps/web/app/(ee)/api/intercom/webhook/route.tsindex ecb42f4667..acef8807ed 100644--- a/apps/web/app/(ee)/api/intercom/webhook/route.ts+++ b/apps/web/app/(ee)/api/intercom/webhook/route.ts@@ -4,14 +4,14 @@ import { enqueueBatchJobs } from "@/lib/cron/enqueue-batch-jobs";import { intercomWebhookSchema } from "@/lib/integrations/intercom/schema";import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";import { logAndRespond } from "../../cron/utils";-import { verifyWebhookSignature } from "./verify-webhook";+import { verifyIntercomWebhookSignature } from "./verify-webhook-signature";const relevantTopics = new Set(["conversation.admin.replied", "ping"]);// POST /api/intercom/webhook – listen to webhook events from Intercomexport const POST = withAxiom(async (req) => {try {- const rawBody = await verifyWebhookSignature(req);+ const rawBody = await verifyIntercomWebhookSignature(req);const body = JSON.parse(rawBody);const { topic } = intercomWebhookSchema.parse(body);diff --git a/apps/web/app/(ee)/api/intercom/webhook/uninstall/route.ts b/apps/web/app/(ee)/api/intercom/webhook/uninstall/route.tsindex a5f743bd46..d38b1f63e4 100644--- a/apps/web/app/(ee)/api/intercom/webhook/uninstall/route.ts+++ b/apps/web/app/(ee)/api/intercom/webhook/uninstall/route.ts@@ -4,12 +4,12 @@ import { intercomUninstallWebhookSchema } from "@/lib/integrations/intercom/scheimport { prisma } from "@dub/prisma";import { INTERCOM_INTEGRATION_ID } from "@dub/utils";import { logAndRespond } from "../../../cron/utils";-import { verifyWebhookSignature } from "../verify-webhook";+import { verifyIntercomWebhookSignature } from "../verify-webhook-signature";// POST /api/intercom/webhook/uninstall – notified when someone uninstalls the app or revokes access through any meansexport const POST = withAxiom(async (req) => {try {- const rawBody = await verifyWebhookSignature(req);+ const rawBody = await verifyIntercomWebhookSignature(req);const body = JSON.parse(rawBody);const { app_id: intercomWorkspaceId } =diff --git a/apps/web/app/(ee)/api/intercom/webhook/verify-webhook.ts b/apps/web/app/(ee)/api/intercom/webhook/verify-webhook-signature.tssimilarity index 93%rename from apps/web/app/(ee)/api/intercom/webhook/verify-webhook.tsrename to apps/web/app/(ee)/api/intercom/webhook/verify-webhook-signature.tsindex ff31d5dcc5..a11f60f66a 100644--- a/apps/web/app/(ee)/api/intercom/webhook/verify-webhook.ts+++ b/apps/web/app/(ee)/api/intercom/webhook/verify-webhook-signature.ts@@ -3,7 +3,9 @@ import crypto from "crypto";const INTERCOM_CLIENT_SECRET = process.env.INTERCOM_CLIENT_SECRET || "";-export async function verifyWebhookSignature(req: Request): Promise<string> {+export async function verifyIntercomWebhookSignature(+ req: Request,+): Promise<string> {const rawBody = await req.text();const signature = req.headers.get("X-Hub-Signature");