-
Notifications
You must be signed in to change notification settings - Fork 13
feat: kyc 2.0 frontend #1679
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
Merged
feat: kyc 2.0 frontend #1679
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
2a66155
feat: sumsub sdk types and declrations
kushagrasarathe b7a4141
feat: initiateSumsubKyc server action
kushagrasarathe 0dd89d3
feat: useSumsubKycFlow hook setup using initiateSumsubKyc server action
kushagrasarathe 2c2bf14
feat: handle websocket event receiving for sumsub kyc
kushagrasarathe 27ea649
feat: SumsubKycWrapper component to handle sumsub web sdk intializati…
kushagrasarathe 1fa243f
feat: SumsubKycFlow entry point for sumsub kyc wrapper and pending st…
kushagrasarathe 61bd07e
fix: update verification view ux copy + add region intent type
kushagrasarathe 2d79044
chore: fix formatting
kushagrasarathe e3c9bd8
feat: add sumsub provider to kyc types and shared status consts
kushagrasarathe b2b90e1
feat: unified kyc status hook
kushagrasarathe a3316cc
fix: sumsub flow, regionIntent and levelName resolution
kushagrasarathe 6b8f838
feat: sumsub region routing
kushagrasarathe 3188926
feat: unified kyc status drawer
kushagrasarathe 4fb61d4
feat: sumsub kyc gate for qr payments
kushagrasarathe 6d390ad
feat: update views for sumsub flow
kushagrasarathe ec0d1e9
chore: remove dead code
kushagrasarathe 22fa6b7
Merge branch 'peanut-wallet-dev' into feat/kyc2.0
kushagrasarathe d0b2764
chore: format
kushagrasarathe e9715af
fix: address cr review comments
kushagrasarathe 7297b9b
fix: remove levelName param and use regionIntent
kushagrasarathe b564cb9
fix: reuse exiting start kyc modal and fix its copy
kushagrasarathe 9bf32ae
fix: new cr comments
kushagrasarathe a8ddab2
fix: more cr comments xD
kushagrasarathe 9fbb5d8
feat: add UserRail types, rejectType and metadata to kyc verification…
kushagrasarathe 60e9dc9
feat: add action_required status category and human-readable sumsub r…
kushagrasarathe fe5f07d
feat: scope region unlocking by verification regionIntent, expose act…
kushagrasarathe ea64d17
feat: handle sumsub_kyc_status_update websocket messages
kushagrasarathe 7ed541a
feat: add bridge tos acceptance flow: tos step component, reminder ca…
kushagrasarathe 235724f
feat: handle bridge tos acceptance
kushagrasarathe 9e996b0
fix: listen to additional sumsub sdk methods
kushagrasarathe 250cea8
feat: listen to user rail websocket events
kushagrasarathe 40d222f
fix: move PeanutDoesntStoreAnyPersonalInformation out to a separate c…
kushagrasarathe 2f892cb
feat: add useRailStatusTracking hook
kushagrasarathe f58ad8d
fix: update SumsubKycFlow and KycVerificationInProgressModal to handl…
kushagrasarathe 8c64be9
feat: add isTerminalRejection utility and sumsubRejectType to unified…
kushagrasarathe 302df7b
refactor: extract shared rejectlabelslist component and simplify draw…
kushagrasarathe 8e5ab8b
fix: handle kyc status transitions for non-success terminal states
kushagrasarathe 2bc70ba
feat: add status-aware modals for regions verification page
kushagrasarathe 1170822
fix: re-submit verification flow and stop verification button in kyc …
kushagrasarathe bebaeef
fix: gate terminal rejection logic by provider and log tos retry failure
kushagrasarathe 05029c0
docs: update kyc 2.0 testing guide with all implemented test cases
kushagrasarathe 3c62aef
fix: remove kyc testing guide
kushagrasarathe 4cda4bb
feat: bridge additional document collection UI
kushagrasarathe 91d7b1f
chore: format
kushagrasarathe bcb698c
fix: address code review findings
kushagrasarathe 10f5ee5
fix: aggregate additional requirements across all rails, guard termin…
kushagrasarathe 1b4a9e7
fix: label copy
kushagrasarathe 3c929c2
Merge pull request #1689 from peanutprotocol/feat/kyc2.0-provider-res…
kushagrasarathe 908e38d
Merge pull request #1683 from peanutprotocol/feat/kyc2.0-error-retry-ui
kushagrasarathe 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
Some comments aren't visible on the classic Files Changed page.
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
6 changes: 0 additions & 6 deletions
6
src/app/(mobile-ui)/profile/identity-verification/[region]/[country]/page.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/app/(mobile-ui)/profile/identity-verification/[region]/page.tsx
This file was deleted.
Oops, something went wrong.
54 changes: 1 addition & 53 deletions
54
src/app/(mobile-ui)/profile/identity-verification/layout.tsx
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 |
|---|---|---|
| @@ -1,59 +1,7 @@ | ||
| 'use client' | ||
|
|
||
| import PageContainer from '@/components/0_Bruddle/PageContainer' | ||
| import ActionModal from '@/components/Global/ActionModal' | ||
| import { useIdentityVerification } from '@/hooks/useIdentityVerification' | ||
| import { useParams, useRouter } from 'next/navigation' | ||
| import { useEffect, useState } from 'react' | ||
|
|
||
| export default function IdentityVerificationLayout({ children }: { children: React.ReactNode }) { | ||
| const [isAlreadyVerifiedModalOpen, setIsAlreadyVerifiedModalOpen] = useState(false) | ||
| const router = useRouter() | ||
| const { isRegionAlreadyUnlocked, isVerifiedForCountry } = useIdentityVerification() | ||
| const params = useParams() | ||
| const regionParams = params.region as string | ||
| const countryParams = params.country as string | ||
|
|
||
| useEffect(() => { | ||
| const isAlreadyVerified = | ||
| (countryParams && isVerifiedForCountry(countryParams)) || | ||
| (regionParams && isRegionAlreadyUnlocked(regionParams)) | ||
|
|
||
| if (isAlreadyVerified) { | ||
| setIsAlreadyVerifiedModalOpen(true) | ||
| } | ||
| }, [countryParams, regionParams, isVerifiedForCountry, isRegionAlreadyUnlocked]) | ||
|
|
||
| return ( | ||
| <PageContainer> | ||
| {children} | ||
|
|
||
| <ActionModal | ||
| visible={isAlreadyVerifiedModalOpen} | ||
| onClose={() => { | ||
| setIsAlreadyVerifiedModalOpen(false) | ||
| router.push('/profile') | ||
| }} | ||
| title="You're already verified" | ||
| description={ | ||
| <p> | ||
| Your identity has already been successfully verified for this region. You can continue to use | ||
| features available in this region. No further action is needed. | ||
| </p> | ||
| } | ||
| icon="shield" | ||
| ctas={[ | ||
| { | ||
| text: 'Close', | ||
| shadowSize: '4', | ||
| className: 'md:py-2', | ||
| onClick: () => { | ||
| setIsAlreadyVerifiedModalOpen(false) | ||
| router.push('/profile') | ||
| }, | ||
| }, | ||
| ]} | ||
| /> | ||
| </PageContainer> | ||
| ) | ||
| return <PageContainer>{children}</PageContainer> | ||
| } |
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,54 @@ | ||
| 'use server' | ||
|
|
||
| import { type InitiateSumsubKycResponse, type KYCRegionIntent } from './types/sumsub.types' | ||
| import { fetchWithSentry } from '@/utils/sentry.utils' | ||
| import { PEANUT_API_URL } from '@/constants/general.consts' | ||
| import { getJWTCookie } from '@/utils/cookie-migration.utils' | ||
|
|
||
| const API_KEY = process.env.PEANUT_API_KEY! | ||
|
|
||
| // initiate kyc flow (using sumsub) and get websdk access token | ||
| export const initiateSumsubKyc = async (params?: { | ||
| regionIntent?: KYCRegionIntent | ||
| levelName?: string | ||
| }): Promise<{ data?: InitiateSumsubKycResponse; error?: string }> => { | ||
| const jwtToken = (await getJWTCookie())?.value | ||
|
|
||
| if (!jwtToken) { | ||
| return { error: 'Authentication required' } | ||
| } | ||
|
|
||
| const body: Record<string, string | undefined> = { | ||
| regionIntent: params?.regionIntent, | ||
| levelName: params?.levelName, | ||
| } | ||
|
|
||
| try { | ||
| const response = await fetchWithSentry(`${PEANUT_API_URL}/users/identity`, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| Authorization: `Bearer ${jwtToken}`, | ||
| 'api-key': API_KEY, | ||
| }, | ||
| body: JSON.stringify(body), | ||
| }) | ||
|
|
||
| const responseJson = await response.json() | ||
|
|
||
| if (!response.ok) { | ||
| return { error: responseJson.message || responseJson.error || 'Failed to initiate identity verification' } | ||
| } | ||
|
|
||
| return { | ||
| data: { | ||
| token: responseJson.token, | ||
| applicantId: responseJson.applicantId, | ||
| status: responseJson.status, | ||
| }, | ||
| } | ||
| } catch (e: unknown) { | ||
| const message = e instanceof Error ? e.message : 'An unexpected error occurred' | ||
| return { error: message } | ||
| } | ||
| } | ||
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,9 @@ | ||
| export interface InitiateSumsubKycResponse { | ||
| token: string | null // null when user is already APPROVED | ||
| applicantId: string | null | ||
| status: SumsubKycStatus | ||
| } | ||
|
|
||
| export type SumsubKycStatus = 'NOT_STARTED' | 'PENDING' | 'IN_REVIEW' | 'APPROVED' | 'REJECTED' | 'ACTION_REQUIRED' | ||
|
|
||
| export type KYCRegionIntent = 'STANDARD' | 'LATAM' |
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
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
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.