* version and verify-booking-token * username route * api/me * logo route * render email in dev * link route * future * nope and geo location * referal link and daily * intercom route and dynamic variables * intercom route and dynamic variables * scim 2.0 and helpscout route * app credentials * api/book events * fix daily import path in tests * fix buildLegacyRequest generation * fix type errors * migrate the /teams/ routes * move cron jobs * fix daily import path in tests * fix buildLegacyRequest generation * fix type errors * migrate the /teams/ routes * move cron jobs * Revert "api/book events" This reverts commit 607a32fb5b754cad090c2d0cbf64a68f990e220e. * mock next server NextResponse to fix daily video * add default responder to teams api * fix search params * uses nextUrl.searchParams instead of new url * uses nextUrl.searchParams instead of new url * remove outdated api config * remove app dir version of inbound dynamic variables * restore pages version of inbound variables * fix missing code from stupid cursor --------- Co-authored-by: Benny Joo <sldisek783@gmail.com>
31 lines
947 B
TypeScript
31 lines
947 B
TypeScript
import { cookies, headers } from "next/headers";
|
|
import { NextResponse } from "next/server";
|
|
import crypto from "node:crypto";
|
|
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
|
|
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
|
|
|
export async function GET() {
|
|
const headersList = headers();
|
|
const cookiesList = cookies();
|
|
const legacyReq = buildLegacyRequest(headersList, cookiesList);
|
|
|
|
const session = await getServerSession({ req: legacyReq });
|
|
const secret = process.env.INTERCOM_SECRET;
|
|
|
|
if (!session) {
|
|
return NextResponse.json({ message: "user not authenticated" }, { status: 401 });
|
|
}
|
|
|
|
if (!secret) {
|
|
return NextResponse.json({ message: "Intercom Identity Verification secret not set" }, { status: 400 });
|
|
}
|
|
|
|
const hmac = crypto.createHmac("sha256", secret);
|
|
hmac.update(String(session.user.id));
|
|
const hash = hmac.digest("hex");
|
|
|
|
return NextResponse.json({ hash });
|
|
}
|