Skip to content

fix: gate KYC on device support and patch Segment deeplink crash - #2200

Draft
transphorm wants to merge 2 commits into
devfrom
chore/minor-rn-bug-fixes
Draft

fix: gate KYC on device support and patch Segment deeplink crash#2200
transphorm wants to merge 2 commits into
devfrom
chore/minor-rn-bug-fixes

Conversation

@transphorm

@transphorm transphorm commented Jul 5, 2026

Copy link
Copy Markdown
Member

Addreseses

Summary

  • Adds a two-layer device-support gate for KYC (Didit) on Android: Didit's MediaPipe auto-capture links aligned_alloc, which Android only provides from API 28, so launching it on Android 8 and below throws an uncatchable UnsatisfiedLinkError in a background coroutine and crashes the app.
  • Layer 1 (service, fail-closed): launchKycVerification returns a failed result with a new unsupportedDevice error type instead of calling the SDK; the KYC failure screen disables retry for it via isRetryableKycFailure.
  • Layer 2 (UI, never offer): every KYC entry point — ID picker's "View other supported IDs", NFC/MRZ/camera trouble screens, registration fallback screens, Aadhaar upload error, data confirmation, and the camera-permission alert — hides its KYC offer via useKycLauncher().isKycSupported; fallback handlers no longer flip the onboarding funnel branch to kyc before the support check passes.
  • Patches @segment/analytics-react-native@2.23.0 to fix a bridgeless-mode (New Architecture) crash in trackDeepLinks, mirroring upstream fix(android): crash on New Architecture in trackDeepLinks segmentio/analytics-react-native#1146.

Flow

flowchart LR
  subgraph Entry points
    A[IDPickerScreen] & B[Trouble / fallback screens] & C[Camera permission alert]
  end
  A -->|showKycOption| G{isKycSupportedOnDevice}
  B -->|"isKycSupported (hide button)"| G
  C -->|onFallback only if supported| G
  G -->|supported| H[useKycLauncher.launchKycVerification]
  G -->|unsupported| M[Device-not-supported modal / hidden]
  H --> S[kycService.launchKycVerification]
  S -->|unsupported guard| F["failed: unsupportedDevice (canRetry=false)"]
  S -->|supported| D[Didit SDK startVerification]
Loading

Changes

React Native app

  • integrations/kyc: new KYC_MIN_ANDROID_API_LEVEL (28), KYC_UNSUPPORTED_DEVICE_MESSAGE, isKycSupportedOnDevice(), isRetryableKycFailure(); launchKycVerification fails closed with unsupportedDevice before touching the Didit SDK.
  • useKycLauncher: exposes isKycSupported, shows a "Device not supported" modal if a launch is somehow triggered anyway, and routes the fallback modal through the same check.
  • selfClientProvider: the kyc document-type branch navigates straight to KycFailure (no retry) on unsupported devices, and canRetry now respects isRetryableKycFailure.
  • Screens (IDPicker, DocumentNFCScan, DocumentNFCTrouble, DocumentCameraTrouble, DataConfirmation, RegistrationFallbackNFC/MRZ, AadhaarUploadError, LogoConfirmation, DocumentOnboarding): KYC buttons/options render only when supported; setOnboardingBranch('kyc') only fires when the launch can proceed; the camera-permission alert omits "Try Alternative Verification" when unsupported.

SDK core

  • id-selection-screen accepts an optional showKycOption prop (default true, backwards-compatible) to hide the limited-security IDs section.

Tests

  • New coverage for the service guard, isRetryableKycFailure, and the hook's unsupported-device modal; screen/provider test mocks updated for the new isKycSupported / isKycSupportedOnDevice surface.

Config/infra

  • pnpm patch for @segment/analytics-react-native@2.23.0 replacing the ReactNativeHost.reactInstanceManager lookup (unsupported on New Architecture) with reactApplicationContext.getNativeModule; drop once a release newer than 2.23.0 ships the upstream fix.

Test Plan

  • pnpm --filter @selfxyz/mobile-app exec jest on affected suites (kycService, useKycLauncher, selfClientProvider, DataConfirmation, DocumentNFCTrouble, navigation, cameraPermission) — 61 tests passing
  • tsc --noEmit and eslint clean on changed files
  • Manual: Android < 9 device/emulator sees no KYC offers anywhere and gets a non-retryable failure screen if the KYC doc type is forced
  • Manual: deeplink open on New Architecture Android build no longer crashes in Segment trackDeepLinks

Native Consolidation Checklist

  • CONTRACTS.md reviewed - no unintended contract changes
  • Layer 1 bridge contract tests pass
  • Layer 3 builds pass (app iOS, RN test app iOS, RN test app Android)
  • No new native business logic added (Segment patch mirrors an upstream fix; logic stays in TypeScript)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • KYC/alternative verification options are now shown only when KYC is supported on the current device.
    • Added a clearer “Device not supported” message and flow when KYC can’t run.
  • Bug Fixes
    • Retry buttons now appear only for failures that are retryable; unsupported-device failures no longer suggest retry.
    • Improved reliability of deep-link handling for analytics tracking.
  • Documentation / Tests
    • Updated tests to cover unsupported-device and retryability behavior.

…unches

Two-layer gate for KYC on unsupported (non-Play-Services) Android devices:
the service guard fails closed at launch, and every UI entry point now hides
its KYC offer via useKycLauncher's isKycSupported. Fallback screens no longer
mutate the onboarding funnel branch before the support check passes, and the
camera-permission alert only offers alternative verification when supported.
Also patches @segment/analytics-react-native to fix a crash.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
self-webview-app Ready Ready Preview, Comment Jul 12, 2026 3:13pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc3e5b64-e488-420a-8795-290e9c3673c5

📥 Commits

Reviewing files that changed from the base of the PR and between f5de1e5 and f6dbf4f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • app/src/screens/documents/scanning/DataConfirmationScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/tests/src/screens/documents/scanning/DataConfirmationScreen.test.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DataConfirmationScreen.tsx

📝 Walkthrough

Walkthrough

This PR adds Android device-support and KYC retryability checks, propagates support state through KYC launchers and document screens, conditionally hides unsupported alternative-verification paths, and patches Segment native deeplink dispatch.

Changes

KYC device support gating

Layer / File(s) Summary
KYC support and retry contracts
app/src/integrations/kyc/*, app/tests/src/integrations/kyc/kycService.test.ts
Adds Android API-level support constants, support and retryability helpers, guarded verification, re-exports, and platform-specific tests.
Launcher hook and modal handling
app/src/hooks/useKycLauncher.ts, app/tests/src/hooks/useKycLauncher.test.ts
Adds unsupported-device modal handling, support guards, retryability-based failure navigation, isKycSupported, and coverage for unsupported-device flows.
Provider failure routing
app/src/providers/selfClientProvider.tsx, app/tests/src/providers/selfClientProvider.test.tsx
Routes unsupported devices to KycFailure without retry and derives retryability from verification results.
Alternative-verification screen gating
app/src/screens/documents/aadhaar/*, app/src/screens/documents/scanning/*, app/src/screens/documents/selection/*, matching tests
Uses device support to conditionally render or execute alternative-verification actions and updates related test mocks.
ID selection visibility
app/src/screens/documents/selection/IDPickerScreen.tsx, packages/mobile-sdk-alpha/src/flows/onboarding/id-selection-screen.tsx
Adds showKycOption and gates the KYC footer entry based on device support.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Segment analytics deeplink patch

Layer / File(s) Summary
SovranModule retrieval and patch registration
pnpm-patches/@segment__analytics-react-native@2.23.0.patch, pnpm-workspace.yaml
Retrieves SovranModule directly from reactApplicationContext and registers the patch for the Segment package.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: KYC device support gating and the Segment deeplink crash patch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/minor-rn-bug-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant