Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

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.ts
index 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 webhook
export 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.ts
index 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 Intercom
export 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.ts
index 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/sche
import { 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 means
export 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.ts
similarity index 93%
rename from apps/web/app/(ee)/api/intercom/webhook/verify-webhook.ts
rename to apps/web/app/(ee)/api/intercom/webhook/verify-webhook-signature.ts
index 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");