Skip to content

Commit 74c0dc5

Browse files
committed
Remove veriff identity hash; detect duplicates via risk labels only
1 parent 0d1e331 commit 74c0dc5

5 files changed

Lines changed: 7 additions & 92 deletions

File tree

apps/web/app/api/veriff/webhook/handle-decision-event.ts

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { detectDuplicateIdentityFraud } from "@/lib/api/fraud/detect-duplicate-identity-fraud";
2-
import { computeVeriffIdentityHash } from "@/lib/veriff/compute-veriff-identity-hash";
32
import {
43
VeriffDecisionEvent,
54
VeriffRiskLabel,
@@ -62,7 +61,6 @@ export const handleDecisionEvent = async ({
6261

6362
// since we're skipping verified partners, by default identityVerifiedAt is null
6463
let identityVerifiedAt: Date | null = null;
65-
let veriffIdentityHash: string | null | undefined = undefined;
6664

6765
let { sessionUrl, attemptCount, declineReason, sessionExpiresAt } =
6866
parseVeriffMetadata(partner.veriffMetadata);
@@ -72,19 +70,19 @@ export const handleDecisionEvent = async ({
7270

7371
// If the verification was approved, check for country mismatch
7472
if (effectiveStatus === "approved") {
75-
veriffIdentityHash = computeVeriffIdentityHash(verification);
76-
const isDuplicate = await checkDuplicateIdentity({
77-
partner,
78-
veriffIdentityHash,
79-
riskLabels,
80-
});
73+
const hasDuplicateRiskLabel =
74+
riskLabels &&
75+
riskLabels?.length > 0 &&
76+
riskLabels.some(({ label }) =>
77+
veriffRiskLabels.includes(label as VeriffRiskLabel),
78+
);
8179

8280
const isCountryMismatch = checkCountryMismatch({
8381
partner,
8482
verification,
8583
});
8684

87-
if (isDuplicate) {
85+
if (hasDuplicateRiskLabel) {
8886
effectiveStatus = "declined";
8987
declineReason = DUPLICATE_IDENTITY_DECLINE_REASON;
9088

@@ -124,8 +122,6 @@ export const handleDecisionEvent = async ({
124122
data: {
125123
identityVerificationStatus: veriffStatusMap[effectiveStatus],
126124
identityVerifiedAt,
127-
veriffIdentityHash:
128-
effectiveStatus === "approved" ? veriffIdentityHash : null,
129125
veriffMetadata,
130126
},
131127
select: {
@@ -163,46 +159,6 @@ function checkCountryMismatch({
163159
return partner.country.toUpperCase() !== veriffCountry;
164160
}
165161

166-
async function checkDuplicateIdentity({
167-
partner,
168-
veriffIdentityHash,
169-
riskLabels,
170-
}: {
171-
partner: Pick<Partner, "id">;
172-
veriffIdentityHash: string | null;
173-
riskLabels: VeriffDecisionEvent["verification"]["riskLabels"];
174-
}): Promise<boolean> {
175-
if (!veriffIdentityHash && (!riskLabels || riskLabels.length === 0)) {
176-
return false;
177-
}
178-
179-
const hasDuplicateRiskLabel =
180-
riskLabels &&
181-
riskLabels?.length > 0 &&
182-
riskLabels.some(({ label }) =>
183-
veriffRiskLabels.includes(label as VeriffRiskLabel),
184-
);
185-
186-
if (hasDuplicateRiskLabel) {
187-
return true;
188-
}
189-
190-
if (veriffIdentityHash) {
191-
const duplicatePartner = await prisma.partner.count({
192-
where: {
193-
veriffIdentityHash,
194-
id: {
195-
not: partner.id,
196-
},
197-
},
198-
});
199-
200-
return Boolean(duplicatePartner);
201-
}
202-
203-
return false;
204-
}
205-
206162
async function sendEmailNotification({
207163
partner,
208164
attemptId,

apps/web/app/api/veriff/webhook/handle-session-event.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const handleSessionEvent = async ({
4040
},
4141
data: {
4242
identityVerificationStatus: action,
43-
veriffIdentityHash: null,
4443
veriffMetadata,
4544
},
4645
});

apps/web/lib/auth/partner.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ export const withPartnerProfile = (
224224
salesChannels: true,
225225
platforms: true,
226226
},
227-
omit: {
228-
veriffIdentityHash: true,
229-
},
230227
},
231228
},
232229
});

apps/web/lib/veriff/compute-veriff-identity-hash.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/prisma/schema/partner.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ model Partner {
4848
identityVerificationStatus IdentityVerificationStatus?
4949
identityVerifiedAt DateTime?
5050
veriffSessionId String? @unique
51-
veriffIdentityHash String? @unique
5251
veriffMetadata Json? // see veriffMetadataSchema
5352
5453
// payout fields

0 commit comments

Comments
 (0)