fix(kyc): resume Sumsub SDK after PWA reload (TASK-20406) - #2644
Conversation
On Android the standalone PWA is evicted from memory when the user switches apps mid-KYC (opening the camera/gallery is the common trigger). On return the page cold-reloads, the SDK's open-state resets, and the user is dropped back to the start. Persist the open-state to the URL (?kyc=true) so a reload can re-acquire a token for the same applicant and reopen the SDK. New useSumsubReloadResume hook drives it; wired into the shared multi-phase flow and the Rain card flow. handleInitiateKyc now returns whether the SDK opened so a resume that can't reopen clears the flag instead of retrying on every reload. Rebased onto current main; supersedes #2316 (which predated the native-SDK refactor and its now-removed StartVerificationView autoStart machinery).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 45 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PR adds Sumsub verification resume support after a PWA reload. It persists reload state in the ChangesSumsub reload-resume flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
Code-analysis diffPainscore total: 7127.92 → 7135.63 (+7.71) 🆕 New findings (22)
…and 2 more. ✅ Resolved (19)
📈 Painscore deltas (top movers)
|
The resume re-initiated with no arguments. On the LATAM surfaces (qr-pay,
withdraw/manteca, MantecaAddMoney, MantecaFlowManager) the flow is built as
useMultiPhaseKycFlow({}) and the intent is passed at call time, so a resume
there fell back to the hook default: wrong region intent, and crossRegion and
targetCountry dropped. targetCountry is the Manteca geo stamp, which is
first-write-wins. Worse, a bare initiate still returns a token, so the resume
reported success, the flag stayed set, and the user landed silently in the
wrong verification level — a harder failure than the drop-out being fixed.
Persist the initiate arguments alongside the flag and replay them verbatim.
The URL value carries the arguments instead of a bare boolean, and is
validated on read because the param is user-editable.
Adds the useSumsubReloadResume test the PR described but did not include.
Jest needs nuqs transformed to load its testing adapter, following the
existing ESM allowlist in transformIgnorePatterns.
Problem — TASK-20406
On Android the standalone PWA is evicted from memory when a user switches apps mid-KYC (opening the camera/gallery — the exact thing the flow pushes users toward — is the common trigger). On return the page cold-reloads and the Sumsub SDK's open-state (
useState) resets to closed, so the user falls out of the SDK back to the screen they launched KYC from and has to start the flow again. iOS PWA is not affected. Reported by 2 users.This does not occur in the native app (Sumsub runs as a native screen), but ~98% of Android KYC still runs on the PWA today, so a PWA-side mitigation is worth shipping until native is the default Android path.
Scope — what this fixes
Fix
Persist "the SDK is open" to the URL (
?kyc=true) via a newuseSumsubReloadResumehook. On mount, if the flag is set but the SDK is closed, re-initiate: mint a fresh token for the existing applicant and reopen the SDK. Wired into both KYC entry points — the shared multi-phase flow and the Rain card flow.handleInitiateKycnow returns whether the SDK actually opened (return trueon the token/open path), so a resume that can't reopen (already-approved user, or a remediation flow a bare initiate can't reconstruct) clears the flag instead of retrying on every future reload.Relationship to #2316
Supersedes #2316. That PR predated the native-SDK refactor (
7b372030a), which removed the intro consent screen and itsautoStartmachinery — so on resume the SDK now launches straight into Sumsub with no extra step. This branch is rebased onto currentmainwith that obsolete machinery dropped.Test
npm run typecheck— cleanuseMultiPhaseKycFlow,useSumsubKycFlow,useSumsubReloadResume,Kyc) — 46 passnpm run build— cleanManual (preview, Android): start KYC → enter Sumsub → switch to another app / open gallery → return → SDK reopens for the same applicant instead of dropping you out of the flow.