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.

Partner account verification via Veriff (#3614)

Kiran Kde53046d46a2
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 6c7688bfeb..d871b5a0e4 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -188,4 +188,8 @@ HUBSPOT_CLIENT_SECRET=
# E2E Playwright Tests
PLAYWRIGHT_BASE_URL=http://partners.localhost:8888
E2E_PARTNER_EMAIL=
-E2E_PARTNER_PASSWORD=
\ No newline at end of file
+E2E_PARTNER_PASSWORD=
+
+# Veriff (Identity Verification)
+VERIFF_API_KEY=
+VERIFF_SHARED_SECRET=
diff --git a/apps/web/app/(ee)/api/cron/partners/verify-country-change/route.ts b/apps/web/app/(ee)/api/cron/partners/verify-country-change/route.ts
new file mode 100644
index 0000000000..008272ee94
--- /dev/null
+++ b/apps/web/app/(ee)/api/cron/partners/verify-country-change/route.ts
@@ -0,0 +1,150 @@
+import { withCron } from "@/lib/cron/with-cron";
+import { fetchVeriffSessionDecision } from "@/lib/veriff/fetch-veriff-session-decision";
+import {
+ mergeVeriffMetadata,
+ parseVeriffMetadata,
+} from "@/lib/veriff/veriff-metadata";
+import { sendEmail } from "@dub/email";
+import PartnerIdentityVerificationFailed from "@dub/email/templates/partner-identity-verification-failed";
+import PartnerIdentityVerified from "@dub/email/templates/partner-identity-verified";
+import { prisma } from "@dub/prisma";
+import { logAndRespond } from "app/(ee)/api/cron/utils";
+import * as z from "zod/v4";
+
+export const dynamic = "force-dynamic";
+
+const schema = z.object({
+ partnerId: z.string(),
+});
+
+// POST /api/cron/partners/verify-country-change
+export const POST = withCron(async ({ rawBody }) => {
+ const { partnerId } = schema.parse(JSON.parse(rawBody));
+
+ const partner = await prisma.partner.findUnique({
+ where: {
+ id: partnerId,
+ },
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ country: true,
+ identityVerificationStatus: true,
+ identityVerifiedAt: true,
+ veriffSessionId: true,
+ veriffMetadata: true,
+ },
+ });
+
+ if (!partner) {
+ return logAndRespond("Partner not found.");
+ }
+
+ if (!partner.veriffSessionId) {
+ return logAndRespond("No Veriff session ID found. Skipping.");
+ }
+
+ if (!partner.country) {
+ return logAndRespond("Partner has no country set. Skipping.");
+ }
+
+ // Fetch the original Veriff decision to get the document country
+ let documentCountry: string | null = null;
+
+ try {
+ const { verification } = await fetchVeriffSessionDecision(
+ partner.veriffSessionId,
+ );
+
+ documentCountry =
+ (verification.document?.country || verification.person?.nationality) ??
+ null;
+ } catch (error) {
+ console.error(
+ `Failed to fetch Veriff decision for partner ${partnerId}:`,
+ error,
+ );
+
+ // Don't revoke on uncertainty — QStash will retry
+ throw error;
+ }
+
+ if (!documentCountry) {
+ return logAndRespond(
+ "Could not determine document country from Veriff decision. Skipping.",
+ );
+ }
+
+ // Compare partner's current country with the verified document country
+ if (partner.country.toLowerCase() === documentCountry.toLowerCase()) {
+ if (partner.identityVerifiedAt) {
+ return logAndRespond(
+ "Country matches and partner is already verified. No action needed.",
+ );
+ }
+ await prisma.partner.update({
+ where: {
+ id: partner.id,
+ },
+ data: {
+ identityVerifiedAt: new Date(),
+ },
+ });
+ if (partner.email) {
+ await sendEmail({
+ to: partner.email,
+ subject: "Your identity has been verified",
+ react: PartnerIdentityVerified({
+ partner: {
+ name: partner.name,
+ email: partner.email,
+ },
+ }),
+ });
+ }
+ return logAndRespond("Country matches, verified partner.");
+ } else {
+ // Mismatch — reset identity verification, but preserve attemptCount
+ const declineReason =
+ "Your account country no longer matches your verified identity document country. Please re-verify.";
+
+ const { attemptCount } = parseVeriffMetadata(partner.veriffMetadata);
+
+ await prisma.partner.update({
+ where: {
+ id: partner.id,
+ },
+ data: {
+ identityVerificationStatus: null,
+ identityVerifiedAt: null,
+ veriffSessionId: null,
+ veriffMetadata: mergeVeriffMetadata(partner.veriffMetadata, {
+ sessionUrl: null,
+ sessionExpiresAt: null,
+ declineReason,
+ attemptCount,
+ }),
+ },
+ });
+
+ if (partner.email) {
+ await sendEmail({
+ to: partner.email,
+ subject: "Identity re-verification required",
+ react: PartnerIdentityVerificationFailed({
+ failureType: "countryChange",
+ failureReasonText: declineReason,
+ partner: {
+ name: partner.name,
+ email: partner.email,
+ },
+ }),
+ });
+ }
+
+ return logAndRespond(
+ `Country mismatch detected for partner ${partnerId}. Verification reset and email sent.`,
+ );
+ }
+});
diff --git a/apps/web/app/(ee)/api/network/partners/route.ts b/apps/web/app/(ee)/api/network/partners/route.ts
index d4c52893b7..0729ba58c0 100644
--- a/apps/web/app/(ee)/api/network/partners/route.ts
+++ b/apps/web/app/(ee)/api/network/partners/route.ts
@@ -83,6 +83,11 @@ export const GET = withWorkspace(
starredAt: partner.starredAt ? new Date(partner.starredAt) : null,
ignoredAt: partner.ignoredAt ? new Date(partner.ignoredAt) : null,
invitedAt: partner.invitedAt ? new Date(partner.invitedAt) : null,
+ identityVerificationStatus:
+ partner.identityVerificationStatus ?? null,
+ identityVerifiedAt: partner.identityVerifiedAt
+ ? new Date(partner.identityVerifiedAt)
+ : null,
categories: partner.categories
? partner.categories.split(",").map((c: string) => c.trim())
: [],
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/identity-verification-section.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/identity-verification-section.tsx
new file mode 100644
index 0000000000..87d4fdd497
--- /dev/null
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/identity-verification-section.tsx
@@ -0,0 +1,201 @@
+"use client";
+
+import { parseActionError } from "@/lib/actions/parse-action-errors";
+import { startIdentityVerificationAction } from "@/lib/actions/partners/start-identity-verification";
+import { hasPermission } from "@/lib/auth/partner-users/partner-user-permissions";
+import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { PartnerProps } from "@/lib/types";
+import { MAX_PARTNER_IDENTITY_VERIFICATION_ATTEMPTS } from "@/lib/zod/schemas/partners";
+import { Button, StatusBadge } from "@dub/ui";
+import {
+ ShieldCheck,
+ TriangleWarning,
+ Veriff,
+ VerifiedBadge,
+} from "@dub/ui/icons";
+import { cn } from "@dub/utils";
+import { useAction } from "next-safe-action/hooks";
+import { toast } from "sonner";
+
+export function IdentityVerificationSection({
+ partner,
+}: {
+ partner?: PartnerProps;
+}) {
+ const { mutate } = usePartnerProfile();
+
+ const { executeAsync, isPending } = useAction(
+ startIdentityVerificationAction,
+ {
+ onError: ({ error }) => {
+ toast.error(
+ parseActionError(error, "Failed to start identity verification."),
+ );
+ },
+ onSuccess: async ({ data }) => {
+ const { createVeriffFrame, MESSAGES } = await import(
+ "@veriff/incontext-sdk"
+ );
+
+ createVeriffFrame({
+ url: data.sessionUrl,
+ onEvent: (msg) => {
+ if (msg === MESSAGES.FINISHED) {
+ toast.success(
+ "Verification submitted. We'll update your status shortly.",
+ );
+ mutate();
+ }
+ },
+ });
+
+ mutate();
+ },
+ },
+ );
+
+ if (!partner) {
+ return null;
+ }
+
+ const {
+ identityVerificationStatus,
+ identityVerificationDeclineReason,
+ identityVerificationAttemptCount,
+ } = partner;
+
+ const cannotUpdateProfile = !hasPermission(
+ partner.role,
+ "partner_profile.update",
+ );
+
+ const isPendingReview =
+ identityVerificationStatus === "submitted" ||
+ identityVerificationStatus === "review";
+
+ const isMaxAttemptsReached =
+ identityVerificationAttemptCount >=
+ MAX_PARTNER_IDENTITY_VERIFICATION_ATTEMPTS &&
+ identityVerificationStatus !== "approved" &&
+ !isPendingReview;
+
+ const isFailed = [
+ "declined",
+ "resubmissionRequested",
+ "expired",
+ "abandoned",
+ ].includes(identityVerificationStatus || "");
+
+ let buttonText = "Start verification";
+ let failedReason = identityVerificationDeclineReason || null;
+
+ // If the verification failed and no reason is provided, set the reason based on the status
+ if (isFailed && failedReason === null) {
+ switch (identityVerificationStatus) {
+ case "declined":
+ failedReason =
+ "We couldn't verify your identity. Please check your information or documents and try again.";
+ break;
+ case "resubmissionRequested":
+ failedReason =
+ "Verification couldn't be completed. Please check your information and resubmit.";
+ break;
+ case "expired":
+ failedReason =
+ "Verification attempt expired. Please start a new verification";
+ break;
+ case "abandoned":
+ failedReason =
+ "Verification attempt abandoned. Please start a new verification";
+ break;
+ }
+ }
+
+ switch (identityVerificationStatus) {
+ case "started":
+ buttonText = "Complete verification";
+ break;
+ case "declined":
+ case "resubmissionRequested":
+ buttonText = "Resubmit verification";
+ break;
+ }
+
+ return (
+ <div
+ id="identity-verification"
+ className={cn(
+ failedReason && "overflow-hidden rounded-lg bg-amber-100 p-1",
+ )}
+ >
+ {failedReason && (
+ <div className="flex items-center gap-2 px-2 py-2">
+ <TriangleWarning className="size-3.5 shrink-0 text-amber-500" />
+ <p className="leading-0 text-sm font-medium text-amber-900">
+ <span className="font-semibold">Verification failed:</span>{" "}
+ {failedReason}
+ </p>
+ </div>
+ )}
+
+ <div className="border-border-subtle relative overflow-hidden rounded-lg border bg-neutral-50">
+ <div
+ className="pointer-events-none absolute inset-0 opacity-[0.4] [-webkit-mask-image:radial-gradient(ellipse_95%_85%_at_50%_42%,#000_0%,transparent_68%)] [background-image:radial-gradient(rgb(163_163_163)_1px,transparent_1px)] [background-size:4px_4px] [mask-image:radial-gradient(ellipse_95%_85%_at_50%_42%,#000_0%,transparent_68%)]"
+ aria-hidden
+ />
+ <div className="relative flex flex-col items-center gap-3 px-6 py-3">
+ {identityVerificationStatus === "approved" ? (
+ <VerifiedBadge className="size-6" />
+ ) : (
+ <ShieldCheck className="size-6 text-neutral-400" />
+ )}
+
+ {identityVerificationStatus === "approved" && (
+ <StatusBadge
+ variant="success"
+ className="rounded-lg font-semibold"
+ icon={null}
+ >
+ Identity verified
+ </StatusBadge>
+ )}
+
+ {isPendingReview && (
+ <StatusBadge
+ variant="pending"
+ className="rounded-lg font-semibold"
+ icon={null}
+ >
+ Pending review
+ </StatusBadge>
+ )}
+
+ {identityVerificationStatus !== "approved" &&
+ !isPendingReview &&
+ buttonText && (
+ <Button
+ text={buttonText}
+ variant="secondary"
+ disabled={isMaxAttemptsReached || cannotUpdateProfile}
+ disabledTooltip={
+ cannotUpdateProfile
+ ? "You don't have permission to update this field"
+ : isMaxAttemptsReached
+ ? "You have reached the maximum number of verification attempts. Please contact support if you need help."
+ : undefined
+ }
+ onClick={() => executeAsync()}
+ loading={isPending}
+ className="h-10 w-fit rounded-lg px-4 py-1.5"
+ />
+ )}
+
+ <div className="flex items-center gap-1 text-xs font-medium text-neutral-400">
+ <span>Powered by</span>
+ <Veriff className="w-auto" />
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
index c882dc2774..d3e64cac7f 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
@@ -4,6 +4,7 @@ import { hasPermission } from "@/lib/auth/partner-users/partner-user-permissions
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+
import { useMergePartnerAccountsModal } from "@/ui/partners/merge-accounts/merge-partner-accounts-modal";
import { ThreeDots } from "@/ui/shared/icons";
import { Button, Popover, Users2 } from "@dub/ui";
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
index 191c593f38..19c888d908 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
@@ -32,6 +32,7 @@ import {
useFormContext,
} from "react-hook-form";
import { toast } from "sonner";
+import { IdentityVerificationSection } from "./identity-verification-section";
import { SettingsRow } from "./settings-row";
type BasicInfoFormData = {
@@ -102,6 +103,16 @@ export function ProfileDetailsForm({ partner }: { partner?: PartnerProps }) {
</FormProvider>
</SettingsRow>
+ {partner?.email?.endsWith("@dub.co") && (
+ <SettingsRow
+ id="identity-verification"
+ heading="Identity verification"
+ description="Verify your identity to build trust with programs and get approved for programs faster."
+ >
+ <IdentityVerificationSection partner={partner} />
+ </SettingsRow>
+ )}
+
<SettingsRow
id="platforms"
heading="Website and socials"
diff --git a/apps/web/app/api/veriff/webhook/handle-decision-event.ts b/apps/web/app/api/veriff/webhook/handle-decision-event.ts
new file mode 100644
index 0000000000..2d01faaa68
--- /dev/null
+++ b/apps/web/app/api/veriff/webhook/handle-decision-event.ts
@@ -0,0 +1,206 @@
+import { veriffDecisionEventSchema } from "@/lib/veriff/schema";
+import {
+ mergeVeriffMetadata,
+ parseVeriffMetadata,
+} from "@/lib/veriff/veriff-metadata";
+import { sendEmail } from "@dub/email";
+import PartnerIdentityVerificationFailed from "@dub/email/templates/partner-identity-verification-failed";
+import PartnerIdentityVerified from "@dub/email/templates/partner-identity-verified";
+import { prisma } from "@dub/prisma";
+import { IdentityVerificationStatus, Partner } from "@dub/prisma/client";
+import { logAndRespond } from "app/(ee)/api/cron/utils";
+import * as z from "zod/v4";
+
+type VeriffDecisionEvent = z.infer<typeof veriffDecisionEventSchema>;
+
+const veriffStatusMap: Record<
+ VeriffDecisionEvent["verification"]["status"],
+ IdentityVerificationStatus
+> = {
+ approved: "approved",
+ declined: "declined",
+ expired: "expired",
+ abandoned: "abandoned",
+ review: "review",
+ resubmission_requested: "resubmissionRequested",
+};
+
+export const handleDecisionEvent = async ({
+ verification,
+}: VeriffDecisionEvent) => {
+ const { id, status, decisionTime, reason, attemptId } = verification;
+
+ let effectiveStatus = status;
+
+ const partner = await prisma.partner.findUnique({
+ where: {
+ veriffSessionId: id,
+ },
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ country: true,
+ identityVerifiedAt: true,
+ veriffMetadata: true,
+ },
+ });
+
+ if (!partner) {
+ return logAndRespond("[Veriff Webhook] No partner found for session.");
+ }
+
+ if (partner.identityVerifiedAt) {
+ return logAndRespond("[Veriff Webhook] Partner already verified.");
+ }
+
+ // since we're skipping verified partners, by default identityVerifiedAt is null
+ let identityVerifiedAt: Date | null = null;
+
+ let { sessionUrl, attemptCount, declineReason, sessionExpiresAt } =
+ parseVeriffMetadata(partner.veriffMetadata);
+
+ // set decline reason to the reason from the webhook
+ declineReason = reason;
+
+ // If the verification was approved, check for country mismatch
+ if (effectiveStatus === "approved") {
+ const isCountryMismatch = checkCountryMismatch({
+ partner,
+ verification,
+ });
+
+ if (isCountryMismatch) {
+ effectiveStatus = "declined";
+ declineReason = `Your document country (${verification.document?.country}) does not match your account country (${partner.country})`;
+ } else {
+ identityVerifiedAt = decisionTime ? new Date(decisionTime) : new Date();
+ }
+ }
+
+ // if not resubmission, clear the sessionUrl and sessionExpiresAt and increment the attempt count
+ if (effectiveStatus !== "resubmission_requested") {
+ sessionUrl = null;
+ sessionExpiresAt = null;
+ attemptCount = attemptCount + 1;
+ }
+
+ const veriffMetadata = mergeVeriffMetadata(partner.veriffMetadata, {
+ attemptCount,
+ declineReason,
+ sessionExpiresAt,
+ sessionUrl,
+ });
+
+ const updatedPartner = await prisma.partner.update({
+ where: {
+ id: partner.id,
+ identityVerifiedAt: null,
+ },
+ data: {
+ identityVerificationStatus: veriffStatusMap[effectiveStatus],
+ identityVerifiedAt,
+ veriffMetadata,
+ },
+ select: {
+ identityVerificationStatus: true,
+ name: true,
+ email: true,
+ },
+ });
+
+ await sendEmailNotification({
+ partner: updatedPartner,
+ attemptId,
+ failureReasonText: declineReason || "",
+ });
+
+ return logAndRespond("[Veriff Webhook] Decision event handled successfully.");
+};
+
+function checkCountryMismatch({
+ partner,
+ verification,
+}: {
+ partner: Pick<Partner, "id" | "country">;
+ verification: VeriffDecisionEvent["verification"];
+}): boolean {
+ const veriffCountry = (
+ verification.document?.country || verification.person?.nationality
+ )?.toUpperCase();
+
+ // If either country is missing, skip the check — don't decline for missing data
+ if (!veriffCountry || !partner.country) {
+ return false;
+ }
+
+ return partner.country.toUpperCase() !== veriffCountry;
+}
+
+async function sendEmailNotification({
+ partner,
+ attemptId,
+ failureReasonText,
+}: {
+ partner: Pick<Partner, "name" | "email" | "identityVerificationStatus">;
+ attemptId: string;
+ failureReasonText: string;
+}) {
+ const { name, email, identityVerificationStatus } = partner;
+
+ if (!email) {
+ return;
+ }
+
+ if (identityVerificationStatus === "approved") {
+ return await sendEmail({
+ to: email,
+ subject: "Your identity has been verified",
+ headers: {
+ "Idempotency-Key": `${attemptId}-verified`,
+ },
+ react: PartnerIdentityVerified({
+ partner: {
+ name,
+ email,
+ },
+ }),
+ });
+ }
+
+ if (identityVerificationStatus === "resubmissionRequested") {
+ return await sendEmail({
+ to: email,
+ subject: "Please resubmit your identity verification",
+ headers: {
+ "Idempotency-Key": `${attemptId}-resubmission-requested`,
+ },
+ react: PartnerIdentityVerificationFailed({
+ failureType: "resubmissionRequested",
+ failureReasonText,
+ partner: {
+ name,
+ email,
+ },
+ }),
+ });
+ }
+
+ if (identityVerificationStatus === "declined") {
+ return await sendEmail({
+ to: email,
+ subject: "Your identity verification was declined",
+ headers: {
+ "Idempotency-Key": `${attemptId}-verification-failed`,
+ },
+ react: PartnerIdentityVerificationFailed({
+ failureType: "declined",
+ failureReasonText,
+ partner: {
+ name,
+ email,
+ },
+ }),
+ });
+ }
+}
diff --git a/apps/web/app/api/veriff/webhook/handle-session-event.ts b/apps/web/app/api/veriff/webhook/handle-session-event.ts
new file mode 100644
index 0000000000..b79b303c1a
--- /dev/null
+++ b/apps/web/app/api/veriff/webhook/handle-session-event.ts
@@ -0,0 +1,48 @@
+import { veriffSessionEventSchema } from "@/lib/veriff/schema";
+import { mergeVeriffMetadata } from "@/lib/veriff/veriff-metadata";
+import { prisma } from "@dub/prisma";
+import { logAndRespond } from "app/(ee)/api/cron/utils";
+import * as z from "zod/v4";
+
+type VeriffSessionEvent = z.infer<typeof veriffSessionEventSchema>;
+
+export const handleSessionEvent = async ({
+ id,
+ action,
+}: VeriffSessionEvent) => {
+ const partner = await prisma.partner.findUnique({
+ where: {
+ veriffSessionId: id,
+ },
+ select: {
+ id: true,
+ identityVerifiedAt: true,
+ veriffMetadata: true,
+ },
+ });
+
+ if (!partner) {
+ return logAndRespond("[Veriff Webhook] No partner found for session.");
+ }
+
+ if (partner.identityVerifiedAt) {
+ return logAndRespond("[Veriff Webhook] Partner already verified.");
+ }
+
+ const veriffMetadata = mergeVeriffMetadata(partner.veriffMetadata, {
+ declineReason: null,
+ });
+
+ await prisma.partner.update({
+ where: {
+ id: partner.id,
+ identityVerifiedAt: null,
+ },
+ data: {
+ identityVerificationStatus: action,
+ veriffMetadata,
+ },
+ });
+
+ return logAndRespond("[Veriff Webhook] Session event handled.");
+};
diff --git a/apps/web/app/api/veriff/webhook/route.ts b/apps/web/app/api/veriff/webhook/route.ts
new file mode 100644
index 0000000000..0dd3c21526
--- /dev/null
+++ b/apps/web/app/api/veriff/webhook/route.ts
@@ -0,0 +1,65 @@
+import { logAndRespond } from "app/(ee)/api/cron/utils";
+import crypto from "crypto";
+import { handleDecisionEvent } from "./handle-decision-event";
+import { handleSessionEvent } from "./handle-session-event";
+
+// POST /api/veriff/webhook
+export const POST = async (req: Request) => {
+ const rawBody = await req.text();
+
+ const signature = req.headers.get("x-hmac-signature");
+ const authClient = req.headers.get("x-auth-client");
+ const webhookSecret = process.env.VERIFF_SHARED_SECRET;
+
+ if (!signature) {
+ return logAndRespond("No signature provided.", { status: 401 });
+ }
+
+ const expectedApiKey = process.env.VERIFF_API_KEY;
+
+ if (!expectedApiKey || !authClient) {
+ return logAndRespond("Invalid auth client.", { status: 401 });
+ }
+
+ const authClientBuffer = Uint8Array.from(Buffer.from(authClient));
+ const expectedApiKeyBuffer = Uint8Array.from(Buffer.from(expectedApiKey));
+
+ if (
+ authClientBuffer.length !== expectedApiKeyBuffer.length ||
+ !crypto.timingSafeEqual(authClientBuffer, expectedApiKeyBuffer)
+ ) {
+ return logAndRespond("Invalid auth client.", { status: 401 });
+ }
+
+ if (!webhookSecret) {
+ return logAndRespond("VERIFF_SHARED_SECRET is not configured.", {
+ status: 500,
+ });
+ }
+
+ const computedSignature = crypto
+ .createHmac("sha256", webhookSecret)
+ .update(rawBody)
+ .digest("hex");
+
+ const computedSignatureBuffer = Uint8Array.from(
+ Buffer.from(computedSignature),
+ );
+ const signatureBuffer = Uint8Array.from(Buffer.from(signature));
+
+ const isSignatureValid =
+ computedSignatureBuffer.length === signatureBuffer.length &&
+ crypto.timingSafeEqual(computedSignatureBuffer, signatureBuffer);
+
+ if (!isSignatureValid) {
+ return logAndRespond("Invalid signature.", { status: 400 });
+ }
+
+ const body = JSON.parse(rawBody);
+
+ if ("verification" in body) {
+ return await handleDecisionEvent(body);
+ } else {
+ return await handleSessionEvent(body);
+ }
+};
diff --git a/apps/web/lib/actions/check-account-exists.ts b/apps/web/lib/actions/check-account-exists.ts
index bca10da47d..c72b0e528e 100644
--- a/apps/web/lib/actions/check-account-exists.ts
+++ b/apps/web/lib/actions/check-account-exists.ts
@@ -4,7 +4,7 @@ import { getIP } from "@/lib/api/utils/get-ip";
import { ratelimit } from "@/lib/upstash";
import { prisma } from "@dub/prisma";
import * as z from "zod/v4";
-import { skipAuthThrottling } from "../api/environment";
+import { shouldApplyRateLimit } from "../api/environment";
import { isSamlEnforcedForEmailDomain } from "../api/workspaces/is-saml-enforced-for-email-domain";
import { emailSchema } from "../zod/schemas/auth";
import { throwIfAuthenticated } from "./auth/throw-if-authenticated";
@@ -21,7 +21,7 @@ export const checkAccountExistsAction = actionClient
.action(async ({ parsedInput }) => {
const { email } = parsedInput;
- if (!skipAuthThrottling) {
+ if (shouldApplyRateLimit) {
const { success } = await ratelimit(8, "1 m").limit(
`account-exists:${await getIP()}`,
);
diff --git a/apps/web/lib/actions/create-user-account.ts b/apps/web/lib/actions/create-user-account.ts
index 88fcc73c9d..45849dd96c 100644
--- a/apps/web/lib/actions/create-user-account.ts
+++ b/apps/web/lib/actions/create-user-account.ts
@@ -6,7 +6,7 @@ import { waitUntil } from "@vercel/functions";
import { flattenValidationErrors } from "next-safe-action";
import * as z from "zod/v4";
import { createId } from "../api/create-id";
-import { skipAuthThrottling } from "../api/environment";
+import { shouldApplyRateLimit } from "../api/environment";
import { hashPassword } from "../auth/password";
import { signUpSchema } from "../zod/schemas/auth";
import { throwIfAuthenticated } from "./auth/throw-if-authenticated";
@@ -31,7 +31,7 @@ export const createUserAccountAction = actionClient
const signupAttemptKey = `signup:attempts:${email}`;
- if (!skipAuthThrottling) {
+ if (shouldApplyRateLimit) {
const { remaining: attemptsRemaining } = await ratelimit(
MAX_OTP_ATTEMPTS,
OTP_LOCKOUT_DURATION,
diff --git a/apps/web/lib/actions/partners/start-identity-verification.ts b/apps/web/lib/actions/partners/start-identity-verification.ts
new file mode 100644
index 0000000000..1ba9f4e3db
--- /dev/null
+++ b/apps/web/lib/actions/partners/start-identity-verification.ts
@@ -0,0 +1,97 @@
+"use server";
+
+import { shouldApplyRateLimit } from "@/lib/api/environment";
+import { throwIfNoPermission } from "@/lib/auth/partner-users/throw-if-no-permission";
+import { ratelimit } from "@/lib/upstash/ratelimit";
+import { createVeriffSession } from "@/lib/veriff/create-veriff-session";
+import {
+ mergeVeriffMetadata,
+ parseVeriffMetadata,
+} from "@/lib/veriff/veriff-metadata";
+import { MAX_PARTNER_IDENTITY_VERIFICATION_ATTEMPTS } from "@/lib/zod/schemas/partners";
+import { prisma } from "@dub/prisma";
+import { addDays } from "date-fns/addDays";
+import { authPartnerActionClient } from "../safe-action";
+
+export const startIdentityVerificationAction = authPartnerActionClient.action(
+ async ({ ctx }) => {
+ const { partner, partnerUser } = ctx;
+
+ throwIfNoPermission({
+ role: partnerUser.role,
+ permission: "partner_profile.update",
+ });
+
+ if (partner.identityVerificationStatus) {
+ switch (partner.identityVerificationStatus) {
+ case "approved":
+ throw new Error(
+ "Your identity has already been verified. No further action is required.",
+ );
+ case "submitted":
+ case "review":
+ throw new Error(
+ "A verification attempt is already in progress. Please wait for it to complete or resubmit.",
+ );
+ }
+ }
+
+ const veriffMetadata = parseVeriffMetadata(partner.veriffMetadata);
+
+ if (
+ veriffMetadata.attemptCount >= MAX_PARTNER_IDENTITY_VERIFICATION_ATTEMPTS
+ ) {
+ throw new Error(
+ "You've reached the maximum number of identity verification attempts. Please contact support: https://dub.co/support",
+ );
+ }
+
+ // If the session is already created and not expired, return the existing session
+ // this is to avoid creating duplicate sessions
+ if (
+ partner.veriffSessionId &&
+ veriffMetadata.sessionUrl &&
+ veriffMetadata.sessionExpiresAt &&
+ veriffMetadata.sessionExpiresAt > new Date()
+ ) {
+ return {
+ sessionUrl: veriffMetadata.sessionUrl,
+ };
+ }
+
+ // Rate limit check
+ if (shouldApplyRateLimit) {
+ const { success } = await ratelimit(1, "1 h").limit(
+ `identityVerification:${partner.id}`,
+ );
+
+ if (!success) {
+ throw new Error(
+ "Too many verification attempts. Please try again later.",
+ );
+ }
+ }
+
+ // Create a new session
+ const { verification } = await createVeriffSession({
+ partner,
+ });
+
+ await prisma.partner.update({
+ where: {
+ id: partner.id,
+ },
+ data: {
+ veriffSessionId: verification.id,
+ veriffMetadata: mergeVeriffMetadata(partner.veriffMetadata, {
+ sessionUrl: verification.url,
+ sessionExpiresAt: addDays(new Date(), 7),
+ }),
+ },
+ });
+
+ return {
+ sessionUrl: verification.url,
+ };
+ },
+);
diff --git a/apps/web/lib/actions/partners/update-partner-profile.ts b/apps/web/lib/actions/partners/update-partner-profile.ts
index f89698aaab..f45b6d1bbf 100644
--- a/apps/web/lib/actions/partners/update-partner-profile.ts
+++ b/apps/web/lib/actions/partners/update-partner-profile.ts
@@ -236,6 +236,18 @@ const updatedComplianceFieldsChecks = async ({
to: input.country as string,
changedAt: new Date(),
});
+
+ // if there was an existing veriff session, trigger a country change verification
+ if (partner.veriffSessionId) {
+ waitUntil(
+ qstash.publishJSON({
+ url: `${APP_DOMAIN_WITH_NGROK}/api/cron/partners/verify-country-change`,
+ body: {
+ partnerId: partner.id,
+ },
+ }),
+ );
+ }
}
if (profileTypeChanged) {
diff --git a/apps/web/lib/api/environment.ts b/apps/web/lib/api/environment.ts
index 495778b738..d1f0268552 100644
--- a/apps/web/lib/api/environment.ts
+++ b/apps/web/lib/api/environment.ts
@@ -2,4 +2,4 @@ export const isProduction = process.env.NODE_ENV === "production";
export const isLocalDev = process.env.NODE_ENV === "development";
export const isCI = process.env.CI === "true";
-export const skipAuthThrottling = isCI || isLocalDev;
+export const shouldApplyRateLimit = !(isCI || isLocalDev);
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.ts
index 7eeeed7243..ace8024fc4 100644
--- a/apps/web/lib/auth/options.ts
+++ b/apps/web/lib/auth/options.ts
@@ -18,7 +18,7 @@ import EmailProvider from "next-auth/providers/email";
import GithubProvider from "next-auth/providers/github";
import GoogleProvider from "next-auth/providers/google";
import { createId } from "../api/create-id";
-import { isProduction, skipAuthThrottling } from "../api/environment";
+import { isProduction, shouldApplyRateLimit } from "../api/environment";
import { isSamlEnforcedForEmailDomain } from "../api/workspaces/is-saml-enforced-for-email-domain";
import { qstash } from "../cron";
import { completeProgramApplications } from "../partners/complete-program-applications";
@@ -223,7 +223,7 @@ export const authOptions: NextAuthOptions = {
throw new Error("no-credentials");
}
- if (!skipAuthThrottling) {
+ if (shouldApplyRateLimit) {
const { success } = await ratelimit(5, "1 m").limit(
`login-attempts:${email}`,
);
diff --git a/apps/web/lib/auth/partner.ts b/apps/web/lib/auth/partner.ts
index e80ae2f2f7..d9a5053f3a 100644
--- a/apps/web/lib/auth/partner.ts
+++ b/apps/web/lib/auth/partner.ts
@@ -1,6 +1,7 @@
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";
import { withAxiom } from "@/lib/axiom/server";
import { PartnerBetaFeatures, PartnerProps } from "@/lib/types";
+import { flattenVeriffMetadata } from "@/lib/veriff/veriff-metadata";
import { prisma } from "@dub/prisma";
import { PartnerUser } from "@dub/prisma/client";
import { getSearchParams, PARTNERS_DOMAIN } from "@dub/utils";
@@ -268,7 +269,7 @@ export const withPartnerProfile = (
searchParams,
session,
partner: {
- ...partner,
+ ...flattenVeriffMetadata(partner),
industryInterests: industryInterests.map(
({ industryInterest }) => industryInterest,
),
diff --git a/apps/web/lib/veriff/create-veriff-session.ts b/apps/web/lib/veriff/create-veriff-session.ts
new file mode 100644
index 0000000000..748005f570
--- /dev/null
+++ b/apps/web/lib/veriff/create-veriff-session.ts
@@ -0,0 +1,56 @@
+import { Partner } from "@dub/prisma/client";
+import {
+ veriffCreateSessionInputSchema,
+ veriffCreateSessionOutputSchema,
+} from "./schema";
+
+export async function createVeriffSession({
+ partner,
+}: {
+ partner: Pick<Partner, "id" | "email" | "name">;
+}) {
+ const apiKey = process.env.VERIFF_API_KEY;
+
+ if (!apiKey) {
+ throw new Error("VERIFF_API_KEY is not configured.");
+ }
+
+ const nameParts = partner.name.split(" ");
+ const firstName = nameParts[0] || partner.name;
+ const lastName = nameParts.slice(1).join(" ") || partner.name;
+
+ const input = veriffCreateSessionInputSchema.parse({
+ verification: {
+ vendorData: partner.id,
+ person: {
+ firstName,
+ lastName,
+ },
+ },
+ });
+
+ const rawResponse = await fetch("https://stationapi.veriff.com/v1/sessions", {
+ method: "POST",
+ headers: {
+ "X-AUTH-CLIENT": apiKey,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(input),
+ });
+
+ const response = await rawResponse.json();
+
+ if (!rawResponse.ok) {
+ console.error("[Veriff] Error", response);
+ throw new Error("Failed to create verification session.");
+ }
+
+ const parsedResponse = veriffCreateSessionOutputSchema.safeParse(response);
+
+ if (!parsedResponse.success) {
+ console.error("[Veriff] Invalid response", parsedResponse.error);
+ throw new Error("Failed to create verification session.");
+ }
+
+ return parsedResponse.data;
+}
diff --git a/apps/web/lib/veriff/fetch-veriff-session-decision.ts b/apps/web/lib/veriff/fetch-veriff-session-decision.ts
new file mode 100644
index 0000000000..42c6f40bc1
--- /dev/null
+++ b/apps/web/lib/veriff/fetch-veriff-session-decision.ts
@@ -0,0 +1,66 @@
+import crypto from "crypto";
+import { veriffDecisionEventSchema } from "./schema";
+
+// GET /v1/sessions/{sessionId}/decision
+export async function fetchVeriffSessionDecision(sessionId: string) {
+ const apiKey = process.env.VERIFF_API_KEY;
+ const sharedSecret = process.env.VERIFF_SHARED_SECRET;
+
+ if (!apiKey) {
+ throw new Error("VERIFF_API_KEY is not configured.");
+ }
+
+ if (!sharedSecret) {
+ throw new Error("VERIFF_SHARED_SECRET is not configured.");
+ }
+
+ const hmacSignature = crypto
+ .createHmac("sha256", sharedSecret)
+ .update(sessionId)
+ .digest("hex");
+
+ const rawResponse = await fetch(
+ `https://stationapi.veriff.com/v1/sessions/${sessionId}/decision`,
+ {
+ method: "GET",
+ headers: {
+ "X-AUTH-CLIENT": apiKey,
+ "X-HMAC-SIGNATURE": hmacSignature,
+ "Content-Type": "application/json",
+ },
+ },
+ );
+
+ const responseText = await rawResponse.text();
+ const response = responseText ? JSON.parse(responseText) : null;
+
+ if (!rawResponse.ok) {
+ throw new VeriffApiError({
+ message: `[Veriff] Failed to fetch decision for session ${sessionId}: ${rawResponse.status}`,
+ status: rawResponse.status,
+ responseBody: responseText || null,
+ });
+ }
+
+ return veriffDecisionEventSchema.parse(response);
+}
+
+class VeriffApiError extends Error {
+ status: number;
+ responseBody: string | null;
+
+ constructor({
+ message,
+ status,
+ responseBody,
+ }: {
+ message: string;
+ status: number;
+ responseBody: string | null;
+ }) {
+ super(message);
+ this.name = "VeriffApiError";
+ this.status = status;
+ this.responseBody = responseBody;
+ }
+}
diff --git a/apps/web/lib/veriff/schema.ts b/apps/web/lib/veriff/schema.ts
new file mode 100644
index 0000000000..ec51e3a0ec
--- /dev/null
+++ b/apps/web/lib/veriff/schema.ts
@@ -0,0 +1,73 @@
+import * as z from "zod/v4";
+
+// POST /v1/sessions request body
+export const veriffCreateSessionInputSchema = z.object({
+ verification: z.object({
+ vendorData: z.string(),
+ person: z.object({
+ firstName: z.string(),
+ lastName: z.string(),
+ }),
+ }),
+});
+
+// POST /v1/sessions response
+export const veriffCreateSessionOutputSchema = z.object({
+ status: z.enum(["success"]),
+ verification: z.object({
+ id: z.string(),
+ url: z.string(),
+ host: z.string(),
+ status: z.string(),
+ sessionToken: z.string(),
+ }),
+});
+
+// Session webhook payload
+export const veriffSessionEventSchema = z.object({
+ id: z.string(),
+ code: z.number(),
+ vendorData: z.string(),
+ action: z.enum(["started", "submitted"]),
+});
+
+// Decision webhook payload
+export const veriffDecisionEventSchema = z.object({
+ verification: z.object({
+ id: z.string(),
+ vendorData: z.string(),
+ decisionTime: z.string().nullable(),
+ attemptId: z.string(),
+ status: z.enum([
+ "approved",
+ "declined",
+ "expired",
+ "resubmission_requested",
+ "abandoned",
+ "review",
+ ]),
+ reason: z.string().nullable(),
+ reasonCode: z.number().nullable(),
+ person: z
+ .object({
+ firstName: z.string().nullable(),
+ lastName: z.string().nullable(),
+ dateOfBirth: z.string().nullable(),
+ nationality: z.string().nullable(),
+ idNumber: z.string().nullable(),
+ })
+ .optional(),
+ document: z
+ .object({
+ number: z.string().nullable(),
+ type: z.string().nullable(),
+ country: z.string().nullable(),
+ })
+ .optional(),
+ }),
+});
+
+export const veriffEventSchema = z.union([
+ veriffSessionEventSchema,
+ veriffDecisionEventSchema,
+]);
diff --git a/apps/web/lib/veriff/veriff-metadata.ts b/apps/web/lib/veriff/veriff-metadata.ts
new file mode 100644
index 0000000000..3d90dc55f0
--- /dev/null
+++ b/apps/web/lib/veriff/veriff-metadata.ts
@@ -0,0 +1,66 @@
+import { Prisma } from "@dub/prisma/client";
+import * as z from "zod/v4";
+
+const veriffMetadataSchema = z.object({
+ sessionExpiresAt: z.coerce.date().nullable().optional().default(null),
+ sessionUrl: z.string().nullable().optional().default(null),
+ declineReason: z.string().nullable().optional().default(null),
+ attemptCount: z.number().int().nonnegative().optional().default(0),
+});
+
+type VeriffMetadata = z.infer<typeof veriffMetadataSchema>;
+
+const defaultVeriffMetadata = veriffMetadataSchema.parse({
+ sessionExpiresAt: null,
+ sessionUrl: null,
+ declineReason: null,
+ attemptCount: 0,
+});
+
+export function flattenVeriffMetadata<
+ T extends { veriffMetadata: Prisma.JsonValue | null },
+>(partner: T) {
+ const { veriffMetadata, ...rest } = partner;
+ const metadata = parseVeriffMetadata(veriffMetadata);
+
+ return {
+ ...rest,
+ identityVerificationAttemptCount: metadata.attemptCount,
+ identityVerificationDeclineReason: metadata.declineReason,
+ veriffSessionExpiresAt: metadata.sessionExpiresAt,
+ veriffSessionUrl: metadata.sessionUrl,
+ };
+}
+
+export function parseVeriffMetadata(
+ json: Prisma.JsonValue | null | undefined,
+): VeriffMetadata {
+ if (json == null || typeof json !== "object" || Array.isArray(json)) {
+ return defaultVeriffMetadata;
+ }
+
+ try {
+ return veriffMetadataSchema.parse(json);
+ } catch (error) {
+ return defaultVeriffMetadata;
+ }
+}
+
+export function mergeVeriffMetadata(
+ existing: Prisma.JsonValue | null | undefined,
+ patch: Partial<VeriffMetadata>,
+): Prisma.InputJsonValue {
+ const base = parseVeriffMetadata(existing);
+
+ const next: VeriffMetadata = {
+ ...base,
+ ...patch,
+ };
+
+ return {
+ sessionExpiresAt: next.sessionExpiresAt?.toISOString() ?? null,
+ sessionUrl: next.sessionUrl,
+ declineReason: next.declineReason,
+ attemptCount: next.attemptCount,
+ };
+}
diff --git a/apps/web/lib/webhook/sample-events/partner-enrolled.json b/apps/web/lib/webhook/sample-events/partner-enrolled.json
index 5bf408a1d8..3994d05d4f 100644
--- a/apps/web/lib/webhook/sample-events/partner-enrolled.json
+++ b/apps/web/lib/webhook/sample-events/partner-enrolled.json
@@ -15,6 +15,7 @@
"paypalEmail": null,
"stripeConnectId": null,
"payoutsEnabledAt": null,
+ "identityVerifiedAt": null,
"trustedAt": null,
"createdAt": "2025-02-07T17:58:18.793Z",
"applicationId": null,
diff --git a/apps/web/lib/zod/schemas/partner-network.ts b/apps/web/lib/zod/schemas/partner-network.ts
index c3b1f82370..bc56c73660 100644
--- a/apps/web/lib/zod/schemas/partner-network.ts
+++ b/apps/web/lib/zod/schemas/partner-network.ts
@@ -78,6 +78,8 @@ export const NetworkPartnerSchema = PartnerSchema.pick({
monthlyTraffic: true,
preferredEarningStructures: true,
salesChannels: true,
+ identityVerificationStatus: true,
+ identityVerifiedAt: true,
}).extend({
lastConversionAt: z.date().nullable(),
conversionScore: PartnerConversionScoreSchema,
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index 457810b0aa..fa61078cef 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -1,5 +1,6 @@
import { MAX_PARTNERS_INVITES_PER_REQUEST } from "@/lib/constants/program";
import {
+ IdentityVerificationStatus,
IndustryInterest,
MonthlyTraffic,
PartnerBannedReason,
@@ -27,6 +28,9 @@ import { ProgramEnrollmentSchema } from "./programs";
import { centsSchema, centsSchemaWithDefault, parseUrlSchema } from "./utils";
export const PARTNERS_MAX_PAGE_SIZE = 100;
+export const MAX_PARTNER_INDUSTRY_INTERESTS = 8;
+export const MAX_PARTNER_DESCRIPTION_LENGTH = 500;
+export const MAX_PARTNER_IDENTITY_VERIFICATION_ATTEMPTS = 2;
export const ACTIVE_ENROLLMENT_STATUSES: ProgramEnrollmentStatus[] = [
ProgramEnrollmentStatus.approved,
@@ -312,8 +316,6 @@ export const PartnerPartnerPlatformsSchema = z.object({
.describe("The partner's TikTok username (e.g. `johndoe`)."),
});
-export const MAX_PARTNER_INDUSTRY_INTERESTS = 8;
-
export const PartnerProfileSchema = z.object({
monthlyTraffic: z
.enum(MonthlyTraffic)
@@ -340,8 +342,6 @@ export const PartnerProfileSchema = z.object({
.describe("The partner's sales channels."),
});
-export const MAX_PARTNER_DESCRIPTION_LENGTH = 500;
-
export const PartnerSchema = z
.object({
id: z.string().describe("The partner's unique ID on Dub."),
@@ -421,6 +421,25 @@ export const PartnerSchema = z
.describe(
"The date when the partner received the trusted badge in the partner network.",
),
+ identityVerificationStatus: z
+ .enum(IdentityVerificationStatus)
+ .nullable()
+ .describe(
+ "The partner's identity verification status. Null means not yet initiated.",
+ ),
+ identityVerificationAttemptCount: z
+ .number()
+ .describe(
+ "The number of identity verification attempts started by the partner.",
+ ),
+ identityVerificationDeclineReason: z
+ .string()
+ .nullable()
+ .describe("The reason for the partner's identity verification decline."),
+ identityVerifiedAt: z
+ .date()
+ .nullable()
+ .describe("The date when the partner's identity was verified."),
})
.extend(PartnerPartnerPlatformsSchema.shape)
.extend(PartnerProfileSchema.partial().shape);
@@ -457,6 +476,7 @@ export const EnrolledPartnerSchema = PartnerSchema.pick({
stripeConnectId: true,
payoutsEnabledAt: true,
trustedAt: true,
+ identityVerifiedAt: true,
})
.extend(
ProgramEnrollmentSchema.omit({
diff --git a/apps/web/package.json b/apps/web/package.json
index d095a54c62..9d8263e0dd 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -64,6 +64,7 @@
"@vercel/edge-config": "^0.4.1",
"@vercel/functions": "^3.4.3",
"@vercel/og": "^0.6.5",
+ "@veriff/incontext-sdk": "^2.5.0",
"@visx/curve": "^3.3.0",
"@visx/geo": "^2.10.0",
"@visx/gradient": "^3.3.0",
@@ -141,6 +142,7 @@
"zod-openapi": "5.4.6"
},
"devDependencies": {
+ "@playwright/test": "^1.52.0",
"@types/he": "^1.2.3",
"@types/html-escaper": "^3.0.0",
"@types/luxon": "^3.7.1",
@@ -162,7 +164,6 @@
"typescript": "^5.4.4",
"vite": "7.2.2",
"vite-tsconfig-paths": "5.1.4",
- "@playwright/test": "^1.52.0",
"vitest": "4.0.8"
},
"browser": {
diff --git a/apps/web/tests/partners/resource.ts b/apps/web/tests/partners/resource.ts
index cc03a89cd4..9d187161af 100644
--- a/apps/web/tests/partners/resource.ts
+++ b/apps/web/tests/partners/resource.ts
@@ -30,4 +30,5 @@ export const normalizedPartnerDateFields = z.object({
bannedAt: z.string().nullish(),
payoutsEnabledAt: z.string().nullish(),
trustedAt: z.string().nullish(),
+ identityVerifiedAt: z.string().nullish(),
});
diff --git a/apps/web/tests/webhooks/index.test.ts b/apps/web/tests/webhooks/index.test.ts
index 50da4316d2..905868c6a3 100644
--- a/apps/web/tests/webhooks/index.test.ts
+++ b/apps/web/tests/webhooks/index.test.ts
@@ -37,8 +37,9 @@ const saleWebhookEventSchemaExtended = saleWebhookEventSchema.extend({
});
const enrolledPartnerSchemaExtended = EnrolledPartnerSchema.extend({
- payoutsEnabledAt: z.string().nullable(),
createdAt: z.string(),
+ payoutsEnabledAt: z.string().nullable(),
+ identityVerifiedAt: z.string().nullable(),
});
const commissionWebhookEventSchemaExtended = CommissionWebhookSchema.extend({
diff --git a/apps/web/ui/partners/identity-verification/identity-verification-banner.tsx b/apps/web/ui/partners/identity-verification/identity-verification-banner.tsx
new file mode 100644
index 0000000000..76b0b3ddd5
--- /dev/null
+++ b/apps/web/ui/partners/identity-verification/identity-verification-banner.tsx
@@ -0,0 +1,112 @@
+"use client";
+
+import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { useIdentityVerificationPromo } from "@/ui/partners/identity-verification/use-identity-verification-promo";
+import { X } from "@/ui/shared/icons";
+import { Button, Grid, buttonVariants } from "@dub/ui";
+import { cn } from "@dub/utils";
+import { AnimatePresence, motion } from "motion/react";
+import Image from "next/image";
+import Link from "next/link";
+import type { CSSProperties } from "react";
+
+export function IdentityVerificationBanner() {
+ const { partner } = usePartnerProfile();
+ const { status, setStatus } = useIdentityVerificationPromo();
+
+ return (
+ <AnimatePresence>
+ {partner && status === "banner" && (
+ <motion.div
+ initial={{ opacity: 0, height: 0 }}
+ animate={{ opacity: 1, height: "auto" }}
+ exit={{ opacity: 0, height: 0 }}
+ transition={{ duration: 0.2 }}
+ className="overflow-hidden"
+ >
+ <div
+ className={cn(
+ "border-border-subtle relative mb-4 gap-x-2 overflow-hidden rounded-xl border bg-white sm:h-12 lg:mb-6",
+ )}
+ >
+ <div className="absolute inset-0">
+ <div
+ className={cn(
+ "absolute inset-0 opacity-10 blur-xl sm:-scale-x-100 sm:opacity-20",
+ "[background-image:radial-gradient(140%_146%_at_93%_14%,#F6DEAE,rgba(246,222,174,0)_50%),radial-gradient(126%_82%_at_56%_100%,#94704C,rgba(148,112,76,0)_50%),radial-gradient(131%_124%_at_11%_35%,#3A8BFD,rgba(58,139,253,0)_45%),radial-gradient(117%_77%_at_100%_100%,#C28E52,rgba(194,142,82,0)_50%),radial-gradient(86%_74%_at_40%_59%,#855AFC,rgba(133,90,252,0)_40%)]",
+ )}
+ />
+ <Grid
+ cellSize={32}
+ strokeWidth={2}
+ patternOffset={[-8, -12]}
+ className="text-border-subtle/40 [mask-image:linear-gradient(90deg,black_50%,#0003_100%)]"
+ />
+ </div>
+
+ <div className="relative flex h-full flex-col justify-between sm:flex-row">
+ <div className="flex h-full min-w-0 flex-col gap-x-2 sm:flex-row sm:items-center">
+ <div className="h-full shrink-0 overflow-hidden px-2 py-3 sm:p-0">
+ <div className="relative h-24 w-40 shrink-0 sm:h-full sm:w-16">
+ <div className="absolute left-2 right-0 top-1/2 flex h-full -translate-y-1/2 items-center justify-center sm:h-24 sm:rotate-[-4deg]">
+ <div
+ className="animate-float"
+ style={{ "--r": "2%" } as CSSProperties}
+ >
+ <Image
+ src="https://assets.dub.co/misc/verified-badge-shield.png"
+ alt="Verified badge shield"
+ width={128}
+ height={128}
+ className="size-12 object-contain sm:size-10"
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <p
+ className="text-content-subtle flex min-w-0 flex-col px-3 text-base sm:block sm:truncate sm:px-0 sm:text-sm xl:text-base"
+ title="Verify your identity on Dub. Programs trust verified partners—stand out and get approved faster."
+ >
+ <span className="text-content-emphasis font-semibold">
+ Verify your identity on Dub.
+ </span>{" "}
+ <span className="font-medium">
+ Build trust with programs and improve your approval chances.
+ </span>
+ </p>
+ </div>
+
+ <div className="flex items-center gap-2 p-3 sm:px-2 sm:py-0">
+ <Link
+ href="/profile#identity-verification"
+ className={cn(
+ buttonVariants({ variant: "primary" }),
+ "flex h-8 w-fit items-center justify-center whitespace-nowrap rounded-lg border px-3 text-sm",
+ )}
+ >
+ Verify now
+ </Link>
+
+ <Button
+ variant="outline"
+ icon={<X className="size-4" />}
+ className="hidden size-8 rounded-lg bg-black/5 p-0 hover:bg-black/10 sm:flex"
+ onClick={() => setStatus("card")}
+ />
+ </div>
+ </div>
+
+ <Button
+ variant="outline"
+ icon={<X className="size-4" />}
+ className="absolute right-2 top-2 size-8 rounded-lg bg-black/5 p-0 hover:bg-black/10 sm:hidden"
+ onClick={() => setStatus("card")}
+ />
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ );
+}
diff --git a/apps/web/ui/partners/identity-verification/identity-verification-card.tsx b/apps/web/ui/partners/identity-verification/identity-verification-card.tsx
new file mode 100644
index 0000000000..c58beb752a
--- /dev/null
+++ b/apps/web/ui/partners/identity-verification/identity-verification-card.tsx
@@ -0,0 +1,78 @@
+"use client";
+
+import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { useIdentityVerificationPromo } from "@/ui/partners/identity-verification/use-identity-verification-promo";
+import { Grid, buttonVariants } from "@dub/ui";
+import { cn } from "@dub/utils";
+import { AnimatePresence, motion } from "motion/react";
+import Image from "next/image";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import type { CSSProperties } from "react";
+
+export function IdentityVerificationCard() {
+ const pathname = usePathname();
+ const { partner } = usePartnerProfile();
+ const { status } = useIdentityVerificationPromo();
+
+ if (!partner || status !== "card") return null;
+
+ if (pathname === "/profile") return null;
+
+ return (
+ <AnimatePresence>
+ <motion.div
+ initial={{ opacity: 0, y: 10 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: 10 }}
+ transition={{ duration: 0.2 }}
+ className="border-border-subtle relative m-3 mt-8 select-none gap-2 overflow-hidden rounded-lg border bg-white"
+ >
+ <div className="absolute inset-0 [background-image:radial-gradient(200%_150%_at_100%_0%,#C28E5222,transparent_50%)]">
+ <Grid
+ cellSize={32}
+ strokeWidth={2}
+ patternOffset={[-8, -12]}
+ className="text-border-subtle/40 [mask-image:linear-gradient(45deg,black_50%,#0003_100%)]"
+ />
+ </div>
+
+ <Link
+ href="/profile#identity-verification"
+ className="relative flex w-full flex-col gap-3 p-3 text-left"
+ >
+ <div
+ className="animate-float"
+ style={{ "--r": "0.5%" } as CSSProperties}
+ >
+ <Image
+ src="https://assets.dub.co/misc/verified-badge-shield.png"
+ alt="Verified badge shield"
+ width={128}
+ height={128}
+ className="m-4 size-14 rotate-[-8deg] scale-125 object-contain"
+ />
+ </div>
+
+ <div className="flex flex-col gap-1">
+ <span className="text-content-emphasis line-clamp-1 text-sm font-semibold">
+ Verify your identity
+ </span>
+ <p className="text-content-subtle line-clamp-2 text-xs">
+ Build trust with programs and improve your approval chances.
+ </p>
+ </div>
+
+ <span
+ className={cn(
+ buttonVariants({ variant: "primary" }),
+ "flex h-6 w-fit items-center justify-center whitespace-nowrap rounded-md border px-1.5 text-xs",
+ )}
+ >
+ Verify now
+ </span>
+ </Link>
+ </motion.div>
+ </AnimatePresence>
+ );
+}
diff --git a/apps/web/ui/partners/identity-verification/use-identity-verification-promo.tsx b/apps/web/ui/partners/identity-verification/use-identity-verification-promo.tsx
new file mode 100644
index 0000000000..4e832819a6
--- /dev/null
+++ b/apps/web/ui/partners/identity-verification/use-identity-verification-promo.tsx
@@ -0,0 +1,24 @@
+import { useSyncedLocalStorage } from "@/lib/hooks/use-synced-local-storage";
+
+const identityVerificationPromoStatuses = ["banner", "card"] as const;
+type IdentityVerificationPromoStatus =
+ (typeof identityVerificationPromoStatuses)[number];
+
+export function useIdentityVerificationPromo(): {
+ status: IdentityVerificationPromoStatus;
+ setStatus: (status: IdentityVerificationPromoStatus) => void;
+} {
+ const [identityVerificationPromoStatus, setIdentityVerificationPromoStatus] =
+ useSyncedLocalStorage<string>(
+ "identity-verification-promo-status",
+ "banner",
+ );
+
+ return {
+ status:
+ identityVerificationPromoStatuses.find(
+ (status) => status === identityVerificationPromoStatus,
+ ) ?? "banner",
+ setStatus: setIdentityVerificationPromoStatus,
+ };
+}
diff --git a/apps/web/ui/partners/partner-info-cards.tsx b/apps/web/ui/partners/partner-info-cards.tsx
index f16c39eca3..b12f3aaf27 100644
--- a/apps/web/ui/partners/partner-info-cards.tsx
+++ b/apps/web/ui/partners/partner-info-cards.tsx
@@ -21,6 +21,7 @@ import {
TimestampTooltip,
Trophy,
} from "@dub/ui";
+import { VerifiedBadge } from "@dub/ui/icons";
import {
COUNTRIES,
capitalize,
@@ -30,7 +31,7 @@ import {
timeAgo,
} from "@dub/utils";
import Link from "next/link";
-import { ReactNode } from "react";
+import { Fragment, ReactNode, createElement } from "react";
import useSWR from "swr";
import { ConversionScoreIcon } from "./conversion-score-icon";
import { PartnerApplicationRiskSummary } from "./fraud-risks/partner-application-risk-summary";
@@ -71,7 +72,10 @@ type BasicField = {
id: string;
icon: React.ReactElement;
text: string | null | undefined;
- wrapper?: React.ComponentType<{ children: React.ReactNode }> | string;
+ /** When set, the row is wrapped in TimestampTooltip (local / UTC / unix). */
+ timestamp?: Date | string | number;
+ /** Optional outer wrapper (e.g. ConversionScoreTooltip) around the row content. */
+ wrapper?: React.ComponentType<{ children: React.ReactNode }>;
};
export function PartnerInfoCards({
@@ -147,6 +151,7 @@ export function PartnerInfoCards({
text: partner.lastLeadAt
? `Last lead event ${timeAgo(new Date(partner.lastLeadAt), { withAgo: true })}`
: null,
+ timestamp: partner.lastLeadAt ?? undefined,
},
{
id: "lastConversionAt",
@@ -154,6 +159,7 @@ export function PartnerInfoCards({
text: partner.lastConversionAt
? `Last conversion event ${timeAgo(new Date(partner.lastConversionAt), { withAgo: true })}`
: null,
+ timestamp: partner.lastConversionAt ?? undefined,
},
]
: []),
@@ -168,35 +174,30 @@ export function PartnerInfoCards({
text: partner
? `${partner.status === "approved" ? "Partner since" : "Applied"} ${formatDate(partner.createdAt)}`
: undefined,
+ timestamp: partner?.createdAt,
},
...(showPayoutMethodField && partner
- ? (() => {
- const { Icon: PayoutMethodIcon } = getPayoutMethodIconConfig(
- partner.defaultPayoutMethod!,
- );
- const payoutTimestamp = partner.payoutsEnabledAt!;
- const PayoutTimestampWrapper = ({
- children,
- }: {
- children: React.ReactNode;
- }) => (
- <TimestampTooltip
- timestamp={payoutTimestamp}
- rows={["local", "utc", "unix"]}
- side="left"
- >
- {children}
- </TimestampTooltip>
- );
- return [
- {
- id: "payoutMethod" as const,
- icon: <PayoutMethodIcon className="size-3.5 shrink-0" />,
- text: `${getPayoutMethodLabel(partner.defaultPayoutMethod!)} connected ${formatDateTimeSmart(partner.payoutsEnabledAt!)}`,
- wrapper: PayoutTimestampWrapper,
- },
- ];
- })()
+ ? [
+ {
+ id: "payoutMethod" as const,
+ icon: createElement(
+ getPayoutMethodIconConfig(partner.defaultPayoutMethod!).Icon,
+ { className: "size-3.5 shrink-0" },
+ ),
+ text: `${getPayoutMethodLabel(partner.defaultPayoutMethod!)} connected ${formatDateTimeSmart(partner.payoutsEnabledAt!)}`,
+ timestamp: partner.payoutsEnabledAt!,
+ },
+ ]
+ : []),
+ ...(partner?.identityVerifiedAt
+ ? [
+ {
+ id: "identityVerifiedAt",
+ icon: <VerifiedBadge className="size-3.5 shrink-0" />,
+ text: `Identity verified ${formatDate(partner.identityVerifiedAt, { month: "short" })}`,
+ timestamp: partner.identityVerifiedAt,
+ },
+ ]
: []),
]);
}
@@ -226,6 +227,7 @@ export function PartnerInfoCards({
? `Last conversion ${timeAgo(partner.lastConversionAt, { withAgo: true })}`
: "No conversions yet"
: undefined,
+ timestamp: partner?.lastConversionAt ?? undefined,
},
{
id: "companyName",
@@ -236,7 +238,19 @@ export function PartnerInfoCards({
id: "joinedAt",
icon: <CalendarIcon className="size-3.5" />,
text: partner ? `Joined ${formatDate(partner.createdAt!)}` : undefined,
+ timestamp: partner?.createdAt,
},
+ ...(partner?.identityVerificationStatus === "approved" &&
+ partner?.identityVerifiedAt
+ ? [
+ {
+ id: "identityVerifiedAt",
+ icon: <VerifiedBadge className="size-3.5 shrink-0" />,
+ text: `Identity verified ${formatDate(partner.identityVerifiedAt, { month: "short" })}`,
+ timestamp: partner.identityVerifiedAt,
+ },
+ ]
+ : []),
]);
}
@@ -320,8 +334,8 @@ export function PartnerInfoCards({
<div className="flex flex-col gap-2 p-4">
{basicFields
.filter(({ text }) => text !== null)
- .map(({ id, icon, text, wrapper: Wrapper = "div" }) => (
- <Wrapper key={id}>
+ .map(({ id, icon, text, timestamp, wrapper: RowWrapper }) => {
+ const rowInner = (
<div className="text-content-subtle flex items-center gap-1">
{text !== undefined ? (
<>
@@ -332,8 +346,30 @@ export function PartnerInfoCards({
<div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />
)}
</div>
- </Wrapper>
- ))}
+ );
+ const withTimestamp =
+ timestamp != null ? (
+ <TimestampTooltip
+ timestamp={timestamp}
+ rows={["local", "utc", "unix"]}
+ side="left"
+ delayDuration={250}
+ >
+ {rowInner}
+ </TimestampTooltip>
+ ) : (
+ rowInner
+ );
+ return (
+ <Fragment key={id}>
+ {RowWrapper ? (
+ <RowWrapper>{withTimestamp}</RowWrapper>
+ ) : (
+ withTimestamp
+ )}
+ </Fragment>
+ );
+ })}
</div>
{partner && isEnrolled && showApplicationRiskAnalysis && (
diff --git a/apps/web/ui/partners/program-marketplace/programs-promo-banner.tsx b/apps/web/ui/partners/program-marketplace/programs-promo-banner.tsx
index 0fb27b8883..fffd6530e2 100644
--- a/apps/web/ui/partners/program-marketplace/programs-promo-banner.tsx
+++ b/apps/web/ui/partners/program-marketplace/programs-promo-banner.tsx
@@ -1,13 +1,14 @@
"use client";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { IdentityVerificationBanner } from "@/ui/partners/identity-verification/identity-verification-banner";
import { StablecoinPayoutBanner } from "@/ui/partners/payouts/stablecoin-payout-banner";
import { ProgramMarketplaceBanner } from "@/ui/partners/program-marketplace/program-marketplace-banner";
/**
- * Single promo banner slot for the programs page: show stablecoin payouts banner
- * only when the partner has access to stablecoin payouts; otherwise show the
- * program marketplace banner.
+ * Single promo banner slot for the programs page: identity verification when the
+ * partner is not verified yet; then stablecoin payouts when available and not
+ * connected; otherwise the program marketplace banner.
*/
export function ProgramsPromoBanner() {
const { partner, availablePayoutMethods } = usePartnerProfile();
@@ -16,6 +17,10 @@ export function ProgramsPromoBanner() {
return null;
}
+ if (!partner.identityVerifiedAt) {
+ return <IdentityVerificationBanner />;
+ }
+
if (
availablePayoutMethods.includes("stablecoin") &&
!partner.stripeRecipientId
diff --git a/apps/web/ui/partners/program-marketplace/programs-promo-card.tsx b/apps/web/ui/partners/program-marketplace/programs-promo-card.tsx
index 2de5df1072..4fb5a5f086 100644
--- a/apps/web/ui/partners/program-marketplace/programs-promo-card.tsx
+++ b/apps/web/ui/partners/program-marketplace/programs-promo-card.tsx
@@ -1,13 +1,14 @@
"use client";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { IdentityVerificationCard } from "@/ui/partners/identity-verification/identity-verification-card";
import { StablecoinPayoutCard } from "@/ui/partners/payouts/stablecoin-payout-card";
import { ProgramMarketplaceCard } from "@/ui/partners/program-marketplace/program-marketplace-card";
/**
- * Single promo card slot for the sidebar: show stablecoin payouts card only when
- * the partner has access to stablecoin payouts and hasn't connected stablecoin
- * yet; otherwise show the program marketplace card.
+ * Single promo card slot for the sidebar: identity verification when the partner
+ * is not verified yet; then stablecoin payouts when available and not connected;
+ * otherwise the program marketplace card.
*/
export function ProgramsPromoCard() {
const { partner, availablePayoutMethods } = usePartnerProfile();
@@ -16,6 +17,10 @@ export function ProgramsPromoCard() {
return null;
}
+ if (!partner.identityVerifiedAt) {
+ return <IdentityVerificationCard />;
+ }
+
if (
availablePayoutMethods.includes("stablecoin") &&
!partner.stripeRecipientId
diff --git a/packages/email/src/templates/broadcasts/identity-verification-announcement.tsx b/packages/email/src/templates/broadcasts/identity-verification-announcement.tsx
new file mode 100644
index 0000000000..cdba00f262
--- /dev/null
+++ b/packages/email/src/templates/broadcasts/identity-verification-announcement.tsx
@@ -0,0 +1,106 @@
+import { DUB_WORDMARK } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Link,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "src/components/footer";
+
+export default function IdentityVerificationAnnouncement({
+ email = "[email protected]",
+ unsubscribeUrl = "https://partners.dub.co/account/settings",
+}: {
+ email: string;
+ unsubscribeUrl: string;
+}) {
+ return (
+ <Html>
+ <Head>
+ <style>{`
+ @media only screen and (max-width: 600px) {
+ .email-container {
+ padding-left: 16px !important;
+ padding-right: 16px !important;
+ }
+ }
+ `}</style>
+ </Head>
+ <Preview>
+ To keep our partner network secure, please verify your identity at your
+ earliest convenience.
+ </Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="email-container mx-auto my-10 max-w-[600px] px-10 py-5">
+ <Section className="mt-2 text-center">
+ <Img
+ src={DUB_WORDMARK}
+ width="77"
+ height="40"
+ alt="Dub"
+ style={{
+ display: "block",
+ margin: "0 auto",
+ }}
+ />
+ </Section>
+
+ <Heading className="mx-auto mb-2 mt-10 max-w-[436px] text-center text-2xl font-semibold leading-8 tracking-tight text-neutral-800">
+ Verify your identity on Dub
+ </Heading>
+
+ <Text className="mx-auto mb-10 mt-0 max-w-[436px] text-center text-base leading-6 tracking-tight text-neutral-600">
+ To keep our partner network secure, please verify your identity at
+ your earliest convenience.
+ </Text>
+
+ <Section className="mb-10 text-center">
+ <Img
+ src="https://assets.dub.co/email-assets/partner-verify-identity-hero.jpg"
+ width="196"
+ height="153"
+ alt="Identity verification"
+ style={{
+ display: "block",
+ margin: "0 auto",
+ }}
+ />
+ </Section>
+
+ <Text className="text mx-auto mb-8 mt-0 max-w-[420px] text-center text-base text-neutral-600">
+ Verifying your identity builds trust with programs and improves
+ your approval chances.
+ </Text>
+
+ <Section className="mb-10 text-center">
+ <Link
+ className="rounded-lg bg-neutral-900 px-6 py-3 text-[13px] font-medium text-white no-underline"
+ href="https://ship.dub.co/verify"
+ >
+ Start verification
+ </Link>
+ </Section>
+
+ <Text className="mt-3 text-center text-xs text-neutral-500">
+ Identity verification is powered by Veriff.
+ <br />
+ No personal data is stored on Dub.
+ </Text>
+
+ <Section className="mx-auto max-w-[400px] text-center">
+ <Footer email={email} />
+ </Section>
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/email/src/templates/partner-identity-verification-failed.tsx b/packages/email/src/templates/partner-identity-verification-failed.tsx
new file mode 100644
index 0000000000..4a37a68a84
--- /dev/null
+++ b/packages/email/src/templates/partner-identity-verification-failed.tsx
@@ -0,0 +1,114 @@
+import { DUB_WORDMARK } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Link,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "../components/footer";
+
+export default function PartnerIdentityVerificationFailed({
+ partner = {
+ name: "John",
+ email: "[email protected]",
+ },
+ failureType = "countryChange",
+ failureReasonText = "Document Obscured: ID document is partially obscured (e.g. by fingers)",
+}: {
+ partner: {
+ name: string;
+ email: string;
+ };
+ failureType?: "declined" | "resubmissionRequested" | "countryChange";
+ failureReasonText: string;
+}) {
+ const isCountryChange = failureType === "countryChange";
+ const isResubmission = failureType === "resubmissionRequested";
+
+ let previewText = "Your identity verification failed";
+ let headingText = "Identity verification failed";
+
+ if (isCountryChange) {
+ previewText = "Identity re-verification required";
+ headingText = "Identity re-verification required";
+ } else if (isResubmission) {
+ previewText = "Please resubmit your identity verification";
+ headingText = "Resubmission requested";
+ }
+
+ return (
+ <Html>
+ <Head />
+ <Preview>{previewText}</Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-10 max-w-[600px] rounded border border-solid border-neutral-200 px-10 py-5">
+ <Section className="mb-8 mt-6">
+ <Img src={DUB_WORDMARK} width="61" height="32" alt="dub" />
+ </Section>
+
+ <Heading className="mx-0 p-0 text-lg font-semibold text-neutral-800">
+ {headingText}
+ </Heading>
+
+ {isCountryChange ? (
+ <>
+ <Text className="text-sm leading-6 text-neutral-600">
+ Hi {partner.name}, you recently changed your account country.
+ Because your new country doesn't match the country on your
+ verified identity document, you need to complete identity
+ verification again.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Please log in to your dashboard to start a new verification.
+ </Text>
+ </>
+ ) : isResubmission ? (
+ <>
+ <Text className="text-sm leading-6 text-neutral-600">
+ Hi {partner.name}, we need you to resubmit your identity
+ verification because {failureReasonText}.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Please log in to your dashboard and resubmit your documents.
+ </Text>
+ </>
+ ) : (
+ <>
+ <Text className="text-sm leading-6 text-neutral-600">
+ Hi {partner.name}, your identity verification couldn't be
+ completed because {failureReasonText}.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Please log back in to your dashboard and resubmit your
+ details.
+ </Text>
+ </>
+ )}
+
+ <Section className="mb-10 mt-6">
+ <Link
+ className="rounded-lg bg-neutral-900 px-6 py-3 text-[13px] font-medium text-white no-underline"
+ href="https://partners.dub.co/profile"
+ >
+ Go to your dashboard
+ </Link>
+ </Section>
+
+ <Footer email={partner.email} />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/email/src/templates/partner-identity-verified.tsx b/packages/email/src/templates/partner-identity-verified.tsx
new file mode 100644
index 0000000000..375f30df86
--- /dev/null
+++ b/packages/email/src/templates/partner-identity-verified.tsx
@@ -0,0 +1,58 @@
+import { DUB_WORDMARK } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "../components/footer";
+
+export default function PartnerIdentityVerified({
+ partner = {
+ name: "John",
+ email: "[email protected]",
+ },
+}: {
+ partner: {
+ name: string;
+ email: string;
+ };
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>Your identity has been verified</Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-10 max-w-[600px] rounded border border-solid border-neutral-200 px-10 py-5">
+ <Section className="mb-8 mt-6">
+ <Img src={DUB_WORDMARK} width="61" height="32" alt="dub" />
+ </Section>
+
+ <Heading className="mx-0 p-0 text-lg font-semibold text-neutral-800">
+ You're verified!
+ </Heading>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Hi {partner.name}, your identity has been verified for your
+ partner profile on Dub!
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Thank you for helping create a more trustworthy partner network.
+ You can now get approved for programs faster.
+ </Text>
+
+ <Footer email={partner.email} />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/email/src/templates/welcome-email-partner.tsx b/packages/email/src/templates/welcome-email-partner.tsx
index ff76890b42..ade7a778b4 100644
--- a/packages/email/src/templates/welcome-email-partner.tsx
+++ b/packages/email/src/templates/welcome-email-partner.tsx
@@ -57,65 +57,62 @@ export default function WelcomeEmailPartner({
href="https://ship.dub.co/partner-profile"
className="font-semibold text-black underline underline-offset-4"
>
- filling out your partner profile and verifying your social
- platforms
- </Link>
- . This will help you stand out from other partners in our partner
- network.
+ filling out your partner profile
+ </Link>{" "}
+ and verifying your social platforms, which will allow you to start
+ applying to programs on Dub.
</Text>
<Text className="mb-4 text-sm leading-6 text-gray-600">
<strong className="font-medium text-black">
- 2. Set up payouts
+ 2. Verify your identity
</strong>
- :{" "}
- <Link
- href="https://ship.dub.co/connect-payouts"
- className="font-semibold text-black underline underline-offset-4"
- >
- Connect a payout method
- </Link>{" "}
- to get paid for your referrals. Your payout bank account must
- match your local currency for compliance reasons.{" "}
+ : Next, you'll need to{" "}
<Link
- href="https://ship.dub.co/payouts-guide"
+ href="https://ship.dub.co/partner-profile"
className="font-semibold text-black underline underline-offset-4"
>
- Learn more ↗
+ verify your identity
</Link>
+ . This will build trust with programs and improve your chances of
+ being approved.
</Text>
<Text className="mb-4 text-sm leading-6 text-gray-600">
<strong className="font-medium text-black">
3. Join a program
</strong>
- : If you haven't already, join an affiliate program and start
- earning commissions for your referrals
+ : Now that your profile is ready, you can start applying to
+ programs via our{" "}
+ <Link
+ href="https://ship.dub.co/marketplace"
+ className="font-semibold text-black underline underline-offset-4"
+ >
+ program marketplace
+ </Link>{" "}
+ and earn commissions for your referrals.
</Text>
<Text className="mb-4 text-sm leading-6 text-gray-600">
<strong className="font-medium text-black">
- 4. Start sharing your links
+ 4. Set up payouts
</strong>
- : Once you've joined a program, you can start sharing and creating
- additional referral links.
- </Text>
-
- <Text className="mb-8 text-sm leading-6 text-gray-600">
- <strong className="font-medium text-black">
- 5. Track your performance
- </strong>
- : Monitor traffic and earnings with real-time analytics
- </Text>
-
- <Section className="mb-8">
+ :{" "}
<Link
- className="rounded-lg bg-black px-6 py-3 text-center text-[12px] font-semibold text-white no-underline"
- href="https://ship.dub.co/partners-dashboard"
+ href="https://ship.dub.co/connect-payouts"
+ className="font-semibold text-black underline underline-offset-4"
>
- Go to your dashboard
+ Connect a payout method
+ </Link>{" "}
+ to get paid for your referrals. Learn more about{" "}
+ <Link
+ href="https://dub.co/help/article/receiving-payouts"
+ className="font-semibold text-black underline underline-offset-4"
+ >
+ receiving payouts on Dub
</Link>
- </Section>
+ .
+ </Text>
<Footer email={email} marketing unsubscribeUrl={unsubscribeUrl} />
</Container>
diff --git a/packages/prisma/schema/partner.prisma b/packages/prisma/schema/partner.prisma
index 2649a524e2..a1719d772d 100644
--- a/packages/prisma/schema/partner.prisma
+++ b/packages/prisma/schema/partner.prisma
@@ -22,6 +22,18 @@ enum PartnerPayoutMethod {
paypal
}
+// https://devdocs.veriff.com/v1/docs/how-to-generate-sessions-manually#verification-session-statuses
+enum IdentityVerificationStatus {
+ started
+ submitted
+ approved
+ declined
+ resubmissionRequested
+ expired
+ abandoned
+ review
+}
+
model Partner {
id String @id @default(cuid())
name String
@@ -32,6 +44,12 @@ model Partner {
description String? @db.Text
country String?
+ // identity verification fields
+ identityVerificationStatus IdentityVerificationStatus?
+ identityVerifiedAt DateTime?
+ veriffSessionId String? @unique
+ veriffMetadata Json? // see veriffMetadataSchema
+
// payout fields
defaultPayoutMethod PartnerPayoutMethod?
payoutsEnabledAt DateTime?
@@ -82,6 +100,7 @@ model Partner {
@@index(trustedAt)
@@index(payoutMethodHash)
@@index(cryptoWalletAddress)
+ @@index(identityVerifiedAt)
@@fulltext([email, name, companyName]) // For full-text search
}
diff --git a/packages/ui/src/icons/index.tsx b/packages/ui/src/icons/index.tsx
index 9808223e0c..f045ceeec0 100644
--- a/packages/ui/src/icons/index.tsx
+++ b/packages/ui/src/icons/index.tsx
@@ -25,6 +25,7 @@ export * from "./photo";
export * from "./sort-order";
export * from "./success";
export * from "./tick";
+export * from "./verified-badge";
export * from "./user-clock";
// loaders
@@ -47,6 +48,7 @@ export * from "./slack";
export * from "./tiktok";
export * from "./twitter";
export * from "./unsplash";
+export * from "./veriff";
export * from "./youtube";
// Payment platforms
diff --git a/packages/ui/src/icons/veriff.tsx b/packages/ui/src/icons/veriff.tsx
new file mode 100644
index 0000000000..e8c5135ca8
--- /dev/null
+++ b/packages/ui/src/icons/veriff.tsx
@@ -0,0 +1,54 @@
+import { SVGProps } from "react";
+
+export function Veriff({ className, ...props }: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ width={41}
+ height={12}
+ viewBox="0 0 41 12"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g clipPath="url(#clip0_51173_146452)">
+ <path
+ d="M37.2386 4.66467V9.2818H37.2543C37.5636 6.9493 38.9389 5.42527 40.9999 4.69957V0C38.6296 0.414717 37.2383 1.91778 37.2383 4.66467H37.2386Z"
+ fill="#14E5C5"
+ />
+ <path
+ d="M32.8279 8.61312L36.5896 11.7227V5.55496L32.8279 2.44507V8.61312Z"
+ fill="#14E5C5"
+ />
+ <path
+ d="M26.1553 4.21311C26.1553 2.33237 27.7345 1.68755 29.1923 1.95623V3.28617C28.5444 3.08467 27.829 3.23244 27.829 4.21311V4.72358H29.1923V6.10725H27.829V11.4808H26.1553V6.10725H24.927V4.72358H26.1553V4.21311Z"
+ fill="#0C3035"
+ />
+ <path
+ d="M22.2644 4.21311C22.2644 2.33237 23.8436 1.68755 25.3014 1.95623V3.28617C24.6535 3.08467 23.9381 3.23244 23.9381 4.21311V4.72358H25.4229V6.10725H23.9381V11.4808H22.2644V6.10725H21.1658V4.72358H22.2644V4.21311Z"
+ fill="#0C3035"
+ />
+ <path
+ d="M18.8418 11.4806V4.72345H20.5156V11.4806H18.8418ZM18.5989 2.68151C18.5989 2.07699 19.0713 1.60681 19.6787 1.60681C20.2996 1.60681 20.772 2.07699 20.772 2.68151C20.772 3.29947 20.2996 3.76965 19.6787 3.76965C19.0713 3.76965 18.5989 3.29947 18.5989 2.68151Z"
+ fill="#0C3035"
+ />
+ <path
+ d="M13.9939 11.481V4.72386H15.6676L15.6271 6.57773C15.9241 5.00596 17.0444 4.48206 18.1917 4.71043V6.36276C16.8824 6.17469 15.6676 6.76579 15.6676 8.60623V11.481H13.9939Z"
+ fill="#0C3035"
+ />
+ <path
+ d="M10.127 11.7229C8.08887 11.7229 6.6311 10.2048 6.6311 8.09572C6.6311 6.00006 8.08887 4.48206 10.1 4.48206C12.4487 4.48206 13.7039 6.49712 13.407 8.60622H8.31834C8.37234 9.65406 9.1147 10.4198 10.1405 10.4198C10.9504 10.4198 11.6253 9.96302 11.8548 9.27789L13.2855 9.49286C13.0156 10.7422 11.7738 11.7229 10.127 11.7229ZM8.33184 7.35686H11.7873C11.7873 6.45682 11.0989 5.73139 10.1 5.73139C9.1687 5.73139 8.4533 6.38966 8.33184 7.35686Z"
+ fill="#0C3035"
+ />
+ <path
+ d="M2.72962 11.4811L-0.000244141 4.72388H1.78308L3.62129 9.66751L5.47319 4.72388H7.18792L4.45806 11.4811H2.72962Z"
+ fill="#0C3035"
+ />
+ </g>
+ <defs>
+ <clipPath id="clip0_51173_146452">
+ <rect width={41} height={12} fill="white" />
+ </clipPath>
+ </defs>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/verified-badge.tsx b/packages/ui/src/icons/verified-badge.tsx
new file mode 100644
index 0000000000..a2aee1e8c8
--- /dev/null
+++ b/packages/ui/src/icons/verified-badge.tsx
@@ -0,0 +1,88 @@
+import { SVGProps } from "react";
+
+export function VerifiedBadge(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ width={32}
+ height={32}
+ viewBox="0 0 32 32"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g filter="url(#verifiedBadgeFilter)">
+ <path
+ d="M26.6745 7.91113L18.7995 5.37618C18.276 5.20719 17.7225 5.20869 17.2005 5.37618L9.324 7.91113C8.232 8.26271 7.5 9.27367 7.5 10.4265V20.2645C7.5 25.5577 14.919 28.3809 17.19 29.1202C17.4555 29.2062 17.727 29.25 18 29.25C18.273 29.25 18.543 29.2078 18.807 29.1217C21.081 28.3824 28.5 25.5592 28.5 20.266V10.4265C28.5 9.27367 27.7665 8.26271 26.6745 7.91113Z"
+ fill="url(#verifiedBadgeGradient)"
+ />
+ </g>
+ <defs>
+ <linearGradient
+ id="verifiedBadgeGradient"
+ x1={7.5}
+ y1={5.25}
+ x2={30.3}
+ y2={25.5}
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="#CFA165" />
+ <stop offset="0.18" stopColor="#94704C" />
+ <stop offset="0.32" stopColor="#684D32" />
+ <stop offset="0.46" stopColor="#C28E52" />
+ <stop offset="0.58" stopColor="#F6DEAE" />
+ <stop offset="0.74" stopColor="#E2B87C" />
+ <stop offset="0.9" stopColor="#956D4A" />
+ <stop offset="1" stopColor="#AC7D53" />
+ </linearGradient>
+ <filter
+ id="verifiedBadgeFilter"
+ x={0}
+ y={0}
+ width={36}
+ height={39}
+ filterUnits="userSpaceOnUse"
+ colorInterpolationFilters="sRGB"
+ >
+ <feFlood floodOpacity={0} result="BackgroundImageFix" />
+ <feColorMatrix
+ in="SourceAlpha"
+ type="matrix"
+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
+ result="hardAlpha"
+ />
+ <feOffset dy={2.25} />
+ <feGaussianBlur stdDeviation={3.75} />
+ <feComposite in2="hardAlpha" operator="out" />
+ <feColorMatrix
+ type="matrix"
+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"
+ />
+ <feBlend
+ mode="normal"
+ in2="BackgroundImageFix"
+ result="effect1DropShadow"
+ />
+ <feBlend
+ mode="normal"
+ in="SourceGraphic"
+ in2="effect1DropShadow"
+ result="shape"
+ />
+ <feColorMatrix
+ in="SourceAlpha"
+ type="matrix"
+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
+ result="hardAlpha2"
+ />
+ <feGaussianBlur stdDeviation={2.625} />
+ <feComposite in2="hardAlpha2" operator="arithmetic" k2={-1} k3={1} />
+ <feColorMatrix
+ type="matrix"
+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0"
+ />
+ <feBlend mode="normal" in2="shape" result="effect2InnerShadow" />
+ </filter>
+ </defs>
+ </svg>
+ );
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ab71ee694f..1ef1784df6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -170,6 +170,9 @@ importers:
'@vercel/og':
specifier: ^0.6.5
version: 0.6.5
+ '@veriff/incontext-sdk':
+ specifier: ^2.5.0
+ version: 2.5.0
'@visx/curve':
specifier: ^3.3.0
version: 3.3.0
@@ -657,7 +660,7 @@ importers:
dependencies:
'@hubspot/cli':
specifier: ^7.6.2
devDependencies:
'@types/node':
specifier: 18.11.9
@@ -6088,6 +6091,9 @@ packages:
resolution: {integrity: sha512-UycprH3T6n3jH0k44NHMa7pnFHGu/N05MjojYr+Mc6I7obkoLIJujSWwin1pCvdy/eOxrI/l3uDLQsmcrOb4ug==}
engines: {node: '>= 20'}
+ '@veriff/[email protected]':
+ resolution: {integrity: sha512-ORL5eDBKq7nBa+uuAjLWK/NsvbUi0nkIEdKP8FeppOEh5hmsdIK0UFTAnyApx7szr9dJPsiC/pgrx1B+jlpBxw==}
+
resolution: {integrity: sha512-/mJuPiAUN/YdatSlXkkXD/8Pb4gVclbucNZkpUk6JVhnrmow0a1x73QiMXKuH2qDO5GDaqQS0C3Ly9lI3qTQ5Q==}
peerDependencies:
@@ -7622,6 +7628,9 @@ packages:
resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==}
+ resolution: {integrity: sha512-Tiz2EYedB14UW0/lY5PEzFAie66e9itoEVKhz0M9xz1cHqP4Jd0XUg/AT2m6DtbhCFa9DHo6nQyePuLH7Mx9+A==}
+
resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
@@ -8354,6 +8363,9 @@ packages:
resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==}
+ resolution: {integrity: sha512-vkHTluRCoq9FcsrldC0ulQHiyBYgVJB2CX53I8r0nTC6KnEij7Of0jpBspjt3/CuNb6fyoj3aOh9J2HgQUM0og==}
+
resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==}
engines: {node: '>=4.0'}
@@ -12356,7 +12368,7 @@ packages:
resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==}
engines: {node: '>=10'}
- deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting [email protected]
+ deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]
resolution: {integrity: sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ==}
@@ -12636,6 +12648,9 @@ packages:
engines: {node: '>=18.0.0'}
hasBin: true
+ resolution: {integrity: sha512-DuGbQxIBSbz7/aAwh0oMThOwCwDdYzsU8nF5XQPAvoeOBWp/qhjrZfOtc84gj6CQLZu5L1+TgMNX6fW3OuafHA==}
+
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
@@ -14551,9 +14566,9 @@ snapshots:
'@babel/core': 7.24.5
'@babel/helper-plugin-utils': 7.25.9
dependencies:
- '@babel/core': 7.28.4
+ '@babel/core': 7.24.5
'@babel/helper-plugin-utils': 7.27.1
optional: true
@@ -15383,7 +15398,7 @@ snapshots:
- encoding
- supports-color
dependencies:
'@hubspot/local-dev-lib': 3.19.1
'@hubspot/project-parsing-lib': 0.8.6(@hubspot/[email protected])
@@ -15414,7 +15429,7 @@ snapshots:
yargs: 17.7.2
yargs-parser: 21.1.1
optionalDependencies:
'@modelcontextprotocol/sdk': 1.13.3
transitivePeerDependencies:
- '@babel/core'
@@ -15452,7 +15467,7 @@ snapshots:
react-dom: 18.3.1([email protected])
optional: true
dependencies:
'@babel/code-frame': 7.26.2
'@babel/parser': 7.26.2
@@ -15479,7 +15494,7 @@ snapshots:
'@vitejs/plugin-react': 4.7.0([email protected](@types/[email protected])([email protected]))
ansi-to-html: 0.7.2
babel-plugin-macros: 3.1.0
chalk: 5.4.1
class-variance-authority: 0.7.0
cli-progress: 3.12.0
@@ -15498,7 +15513,7 @@ snapshots:
react-dom: 18.3.1([email protected])
request: 2.88.2
storybook: 8.6.14([email protected])
tailwind-merge: 2.6.0
tailwindcss-animate: 1.0.7
typescript: 4.7.4
@@ -19809,6 +19824,11 @@ snapshots:
'@vercel/[email protected]': {}
+ '@veriff/[email protected]':
+ dependencies:
+ dom-focus-lock: 1.0.4
+ tua-body-scroll-lock: 1.2.1
+
dependencies:
'@types/react': 19.1.15
@@ -20516,11 +20536,11 @@ snapshots:
resolve: 1.22.6
optional: true
dependencies:
'@babel/helper-annotate-as-pure': 7.27.3
'@babel/helper-module-imports': 7.25.9
- '@babel/plugin-syntax-jsx': 7.27.1(@babel/[email protected])
+ '@babel/plugin-syntax-jsx': 7.27.1(@babel/[email protected])
lodash: 4.17.21
picomatch: 2.3.1
@@ -21565,6 +21585,10 @@ snapshots:
optional: true
+ dependencies:
+ focus-lock: 0.6.8
+
dependencies:
domelementtype: 2.3.0
@@ -22638,6 +22662,8 @@ snapshots:
+
optionalDependencies:
debug: 4.4.0
@@ -27596,12 +27622,12 @@ snapshots:
tslib: 2.6.2
optional: true
dependencies:
client-only: 0.0.1
react: 18.3.1
optionalDependencies:
- '@babel/core': 7.28.4
+ '@babel/core': 7.24.5
babel-plugin-macros: 3.1.0
optional: true
@@ -28296,6 +28322,8 @@ snapshots:
optionalDependencies:
fsevents: 2.3.3
+
dependencies:
safe-buffer: 5.2.1