-
Notifications
You must be signed in to change notification settings - Fork 94
feat: integrate Didit identity verification for KYC compliance #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
0xdevcollins
merged 3 commits into
boundlessfi:main
from
Ekene001:feat/Integrate-Didit-identity-verification-(KYC)-into-the-application
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| 'use client'; | ||
|
|
||
| import { useState } from 'react'; | ||
| import { Button } from '@/components/ui/button'; | ||
| import clsx from 'clsx'; | ||
| import { createDiditSession } from '@/lib/api/didit'; | ||
|
|
||
| export interface DiditVerifyButtonProps { | ||
| onSuccess?: (session: { sessionId?: string; status?: string }) => void; | ||
| onError?: (error: Error | { code?: string; message?: string }) => void; | ||
| onCancel?: () => void; | ||
| className?: string; | ||
| disabled?: boolean; | ||
| /** Optional user id for vendor_data (backend uses authenticated user if omitted). */ | ||
| userId?: string; | ||
| } | ||
|
|
||
| export function DiditVerifyButton({ | ||
| onSuccess, | ||
| onError, | ||
| onCancel, | ||
| className, | ||
| disabled = false, | ||
| userId, | ||
| }: DiditVerifyButtonProps) { | ||
| const [loading, setLoading] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| const handleVerify = async () => { | ||
| setLoading(true); | ||
| setError(null); | ||
| try { | ||
| const { session_token, verification_url } = await createDiditSession( | ||
| userId != null ? { user_id: userId } : undefined | ||
| ); | ||
|
|
||
| if (!session_token || !verification_url) { | ||
| throw new Error('Invalid session response'); | ||
| } | ||
|
|
||
| const DiditSdkModule = await import('@didit-protocol/sdk-web'); | ||
| const DiditSdk = DiditSdkModule.default; | ||
| const sdk = DiditSdk.shared; | ||
|
|
||
| sdk.onComplete = (result: { | ||
| type: string; | ||
| session?: { sessionId?: string; status?: string }; | ||
| error?: { message?: string }; | ||
| }) => { | ||
| setLoading(false); | ||
| if (result.type === 'completed' && result.session) { | ||
| setError(null); | ||
| onSuccess?.(result.session); | ||
| } else if (result.type === 'failed' && result.error) { | ||
| setError(result.error.message ?? 'Verification failed'); | ||
| onError?.({ message: result.error.message }); | ||
| } else if (result.type === 'cancelled') { | ||
| onCancel?.(); | ||
| } | ||
| }; | ||
|
|
||
| await sdk.startVerification({ url: verification_url }); | ||
| } catch (e) { | ||
| const message = | ||
| e instanceof Error ? e.message : 'Failed to start verification'; | ||
| const error = e instanceof Error ? e : new Error(message); | ||
| setError(message); | ||
| setLoading(false); | ||
| onError?.(error); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| return ( | ||
| <div className='space-y-2'> | ||
| <Button | ||
| type='button' | ||
| onClick={handleVerify} | ||
| disabled={disabled || loading} | ||
| className={clsx(className)} | ||
| > | ||
| {loading ? 'Opening verification…' : 'Verify identity'} | ||
| </Button> | ||
| {error && ( | ||
| <p className='text-sm text-red-500' role='alert'> | ||
| {error} | ||
| </p> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| 'use client'; | ||
|
|
||
| import { DiditVerifyButton } from './DiditVerifyButton'; | ||
| import { | ||
| Card, | ||
| CardContent, | ||
| CardDescription, | ||
| CardHeader, | ||
| CardTitle, | ||
| } from '@/components/ui/card'; | ||
| import { Badge } from '@/components/ui/badge'; | ||
| import { CheckCircle2, XCircle, Clock, AlertCircle } from 'lucide-react'; | ||
| import clsx from 'clsx'; | ||
| import type { GetMeResponse } from '@/lib/api/types'; | ||
|
|
||
| export type IdentityVerificationStatus = | ||
| | 'Approved' | ||
| | 'Declined' | ||
| | 'In Review' | ||
| | null | ||
| | undefined; | ||
|
|
||
| export interface IdentityVerificationSectionProps { | ||
| user: GetMeResponse | null; | ||
| onVerificationComplete?: () => void; | ||
| } | ||
|
|
||
| const statusConfig: Record< | ||
| string, | ||
| { label: string; icon: React.ElementType; className: string } | ||
| > = { | ||
| Approved: { | ||
| label: 'Verified', | ||
| icon: CheckCircle2, | ||
| className: 'text-emerald-500 bg-emerald-500/10 border-emerald-500/20', | ||
| }, | ||
| Declined: { | ||
| label: 'Declined', | ||
| icon: XCircle, | ||
| className: 'text-red-500 bg-red-500/10 border-red-500/20', | ||
| }, | ||
| 'In Review': { | ||
| label: 'In review', | ||
| icon: Clock, | ||
| className: 'text-amber-500 bg-amber-500/10 border-amber-500/20', | ||
| }, | ||
| }; | ||
|
|
||
| const isLocalhost = (): boolean => | ||
| typeof window !== 'undefined' && | ||
| (window.location.hostname === 'localhost' || | ||
| window.location.hostname === '127.0.0.1'); | ||
|
|
||
| export function IdentityVerificationSection({ | ||
| user, | ||
| onVerificationComplete, | ||
| }: IdentityVerificationSectionProps) { | ||
| const status = user?.user | ||
| ?.identityVerificationStatus as IdentityVerificationStatus; | ||
| const verifiedAt = user?.user?.identityVerificationAt; | ||
| const config = status ? statusConfig[status] : null; | ||
| const StatusIcon = config?.icon ?? AlertCircle; | ||
|
|
||
| return ( | ||
| <Card className='border-zinc-800 bg-zinc-900/30'> | ||
| <CardHeader> | ||
| <CardTitle className='text-white'>Identity verification</CardTitle> | ||
| <CardDescription className='text-zinc-400'> | ||
| Verify your identity with Didit for KYC and compliance. Your data is | ||
| processed securely. | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent className='space-y-4'> | ||
| {status && config ? ( | ||
| <div className='flex flex-wrap items-center gap-3'> | ||
| <Badge | ||
| variant='outline' | ||
| className={clsx( | ||
| 'inline-flex items-center gap-1.5 font-medium', | ||
| config.className | ||
| )} | ||
| > | ||
| <StatusIcon className='h-3.5 w-3.5' /> | ||
| {config.label} | ||
| </Badge> | ||
| {verifiedAt && status === 'Approved' && ( | ||
| <span className='text-sm text-zinc-500'> | ||
| Verified on{' '} | ||
| {new Date(verifiedAt).toLocaleDateString(undefined, { | ||
| dateStyle: 'medium', | ||
| })} | ||
| </span> | ||
| )} | ||
| </div> | ||
| ) : ( | ||
| <p className='text-sm text-zinc-500'> | ||
| You have not completed identity verification yet. | ||
| </p> | ||
| )} | ||
|
|
||
| {(status !== 'Approved' || !status) && ( | ||
| <> | ||
| <DiditVerifyButton | ||
| onSuccess={() => { | ||
| onVerificationComplete?.(); | ||
| }} | ||
| /> | ||
| {isLocalhost() && ( | ||
| <p className='rounded-md border border-zinc-700 bg-zinc-800/50 px-3 py-2 text-xs text-zinc-500'> | ||
| Using localhost? If verification is blocked by the browser, use | ||
| a tunnel (e.g. ngrok) and set your backend FRONTEND_URL or | ||
| DIDIT_CALLBACK_URL to the tunnel URL. See DIDIT_INTEGRATION.md → | ||
| Troubleshooting. | ||
| </p> | ||
| )} | ||
| </> | ||
| )} | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.