Skip to content

feat(idv): ID capture, evidence upload and verification status (ENG-608 Phase 1) - #736

Merged
islandbitcoin merged 8 commits into
mainfrom
feat/eng-608-id-capture
Sep 25, 2026
Merged

islandbitcoin merged 8 commits into
mainfrom
feat/eng-608-id-capture

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

Mobile half of ENG-608 (ID verification, Phase 1). Adds structured ID capture to the bank cash-out (L2) and business (L3) upgrade flows, sends evidence[] to the backend, and surfaces the reviewer's verification status in the app.

Flow

AccountType → PersonalInformation → [Validation] → IdentityDocumentType → IdentityCapture(front) → [IdentityCapture(back)] → IdentityCapture(selfie) → IdentityReview → BusinessInformation → BankInformation → Success

Three new screens in app/screens/account-upgrade-flow/:

  1. IdentityDocumentType — Passport / National ID / Driver's licence. Passport skips the back side. Switching document type discards captures already taken.
  2. IdentityCapture (side: front | back | selfie) — useCameraDevice(side === "selfie" ? "front" : "back"), photoQualityBalance="quality" on the Camera, takePhoto({ enableShutterSound: false }). SVG scrim overlay with a rounded ID-card window (front/back) or an oval (selfie), drawn with react-native-svg (already a dependency). The still is gated client-side: long edge < 1200 px or aspect outside 1.15–2.4 is rejected with a plain message and a retake. Then a full-screen preview with Retake / Use photo. Permission denied shows a message and an Open Settings button. Nothing leaves the phone on this screen.
  3. IdentityReview — three thumbnails (two for passport), a retake on each, and Confirm and continue disabled until every required side is present. This is the first point at which anything uploads. On the resubmit path (below) the button is Confirm and submit and the whole request goes out from here.

New components: CaptureOverlay, CapturePreview in app/components/account-upgrade-flow/. PhotoUploadField is removed from BankInformation and deleted (nothing else used it).

What uploads, when

useAccountUpgrade().uploadEvidence() loops front → back → selfie through the existing idDocumentUploadUrlGenerate mutation + presigned PUT. Each file's hex SHA-256 is computed client-side with js-sha256 over a react-native-fs base64 read (both already in package.json; no new native dependency). Per-side keys are recorded in the slice as each PUT completes, so a failure mid-set shows a retry that only re-sends what is missing; a retake invalidates that side's key. submitAccountUpgrade() builds evidence: [{ type: ID_FRONT, fileKey, sha256, documentType, issuingCountry }, { type: ID_BACK, … }, { type: SELFIE, fileKey, sha256 }] and keeps the legacy idDocument = front key so older backends keep working. Partial upload failure → no submit.

Status UI

LatestAccountUpgradeRequest adds verification { status reasonCode reasonMessage reviewedAt }. The accountUpgrade slice stores the enum (SUBMITTED | UNDER_REVIEW | MORE_INFO_NEEDED | APPROVED | REJECTED) plus reasonCode / reasonMessage.

  • AccountType shows a status card: Submitted / Under review / More information needed (reviewer's reasonMessage + Resubmit → IdentityDocumentType with resubmit: true) / Approved / Not approved (reasonMessage).
  • QuickStart and the account-settings upgrade button treat SUBMITTED and UNDER_REVIEW as pending; MORE_INFO_NEEDED shows the resubmit prompt with the reviewer's message.

Address

L2 now collects a real address. BusinessInformation shows editable street / line 2 (optional) / city / parish / postal code (optional) / country (default Jamaica) fields, prefilled by the existing Places search, required and validated for every level. The "1 Grenada Way" / "Kingston 5" / "000000" fallback and the console.log of the request input (PII) in useAccountUpgrade are gone, as is the "000000" postal-code fallback in the Places handler.

Decisions (already made, not re-opened here)

  • No blur/glare detection and no new native dependency. Quality gate = overlay guide + minimum resolution/aspect check + user confirmation + retake. Reviewers send back with the seeded resubmit reasons.
  • L2 address is required; placeholder fallback deleted.
  • Legacy idDocument (front key) is sent alongside evidence[].
  • qualityPrioritization is not a takePhoto option in vision-camera 4.7.3; the equivalent is the photoQualityBalance="quality" camera prop, which is what is used.

Persisted state

accountUpgrade is whitelisted in redux-persist. This PR bumps the persist version to 1 with a migration that drops bankInfo.idDocument, maps the old Pending / Approved / Rejected strings to the enum, adds the identity block and defaults the country. Killing the app mid-flow keeps the captures (file URIs) and any keys already uploaded.

Backend dependency

Requires lnflash/flash#515 (feat/eng-608-idv-status) for AccountUpgradeRequest.verification. app/graphql/public-schema.graphql was refreshed from that branch (git show origin/feat/eng-608-idv-status:src/graphql/public/schema.graphql), so the schema-drift CI check will fail on this PR until #515 is on flash main. Against a backend without #515 the LatestAccountUpgradeRequest query itself errors (unknown field), so this should ship after or with the backend.

Tests

yarn test green (see check results in the PR conversation). New specs:

  • __tests__/utils/identity-verification.spec.ts — evidence builder (order, legacy key, passport has no back, metadata only on ID sides), upload planning / key reuse, capture dimension gate, address validation with no fallback, status → label/tone/CTA mapping.
  • __tests__/store/account-upgrade-slice.spec.ts — retake drops the stale key; persist v1 migration.
  • __tests__/screens/identity-review.spec.tsx — renders three thumbnails (two for passport), confirm disabled until all present, uploads before navigating, partial failure keeps a retry, resubmit path submits.
  • __tests__/screens/account-type-status.spec.tsx — status card for each status, reviewer reason, Resubmit CTA into IdentityDocumentType, step count.
  • quick-start.spec.tsx / upgrade-trial-account.spec.tsx updated to the new enum, with MORE_INFO_NEEDED cases.

yarn check-code green (tsc, translations, codegen, graphql-check); check:translation-drift green (23 locales backfilled with English, same as #729).

Device checklist (not run here; nothing ran on a device)

  • Camera permission denied → message + Open Settings; granting and returning shows the camera
  • Front → back → selfie switches to the front camera for the selfie
  • Passport skips the back side; review shows two thumbnails
  • Retake from preview and from review returns to the same side and then back to review
  • Kill the app mid-flow → reopen: captures and document type survive; a missing file can be retaken
  • Airplane mode after the first upload → error + Try again; back online, only the remaining files upload (watch Metro network: one idDocumentUploadUrlGenerate per side)
  • Submit → status card shows Submitted; after reviewer sends back, More information needed + reason + Resubmit → new photos → Confirm and submit → success
  • Rejected shows the reviewer's reason; Approved shows Approved
  • Metro logs contain no file paths, addresses, names, or request input
  • Android: image/jpg normalisation still applies (ENG-291)

🤖 Generated with Claude Code

@linear

linear Bot commented Sep 24, 2026

Copy link
Copy Markdown

ENG-608

islandbitcoin pushed a commit that referenced this pull request Sep 24, 2026
…resubmit

Review fixes for #736.

- Logout: `cleanUp` reset the accountUpgrade slice but left the captures
  under <documents>/idv/ with nothing referencing them, so photos of a
  government ID survived the account that took them. Add
  `removeIdentityDir` and call it before `resetAccountUpgrade`.
- Resubmit: `submitAccountUpgrade` flattened the upload failure to
  `errors`, dropping `failedSide`/`reason`, so a file-reason failure on
  the resubmit path kept the side in the slice with confirm enabled and
  Try again failed identically. `UpgradeResult` now carries both and
  IdentityReview clears the side on `reason === "file"` exactly as the
  first-submission branch does.

Tests: removeIdentityDir cases, a use-logout spec pinning the wipe before
the slice reset, resubmit file/network failure cases on IdentityReview,
and the hook spec now asserts the propagated side/reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Dread and others added 8 commits September 24, 2026 23:18
Adds the three-screen ID capture step to the L2/L3 upgrade flow, between
phone validation and business information:

- IdentityDocumentType: passport / national ID / driver's licence. A
  passport skips the back side.
- IdentityCapture (side = front | back | selfie): vision-camera still with
  an SVG scrim overlay (card window or selfie oval), a resolution/aspect
  gate on the captured still, preview with Retake / Use photo, and a
  permission-denied state that links to Settings. Nothing uploads here.
- IdentityReview: thumbnails with per-side retake; confirm is disabled
  until every required side is present.

The accountUpgrade slice replaces bankInfo.idDocument with an identity
block (document type, issuing country, per-side captures, and per-side
upload bookkeeping so a retry reuses keys already in storage). The slice
is persisted, so a redux-persist v1 migration drops the old shape and maps
the legacy status strings.

PhotoUploadField is removed from BankInformation and deleted; nothing else
used it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…G-608)

useAccountUpgrade gains uploadEvidence(): each required side goes through
the existing idDocumentUploadUrlGenerate + presigned PUT, with a hex
SHA-256 of the file (js-sha256 over a react-native-fs base64 read; no new
native dependency). Keys are recorded per side as they land, so a failure
mid-set leaves nothing to re-send but what is missing. submitAccountUpgrade
builds evidence[] (ID_FRONT, ID_BACK, SELFIE) and keeps the legacy
idDocument = front key for older backends.

The address is now collected for real: BusinessInformation shows editable
line1 / line2 / city / parish / postal code / country fields (prefilled by
the Places search), required for every level. The "1 Grenada Way" /
"Kingston 5" / "000000" fallback and the PII console.log of the request
input are gone.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
LatestAccountUpgradeRequest now reads verification { status reasonCode
reasonMessage reviewedAt } and the slice stores the enum instead of the raw
ERPNext string.

- AccountType shows a status card: Submitted / Under review / More
  information needed (reviewer's message + Resubmit into the identity
  flow) / Approved / Not approved (reviewer's message).
- QuickStart and the upgrade button treat SUBMITTED and UNDER_REVIEW as
  pending and surface the resubmit prompt on MORE_INFO_NEEDED.
- The bank cash-out / business setups gain a step for identity.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
New AccountUpgrade strings for the capture flow, address fields and status
card; typesafe-i18n regenerated and the 23 locale files backfilled with the
English source so check:translation-drift passes.

public-schema.graphql refreshed from lnflash/flash feat/eng-608-idv-status
(PR #515) for AccountUpgradeRequest.verification; generated.ts/.gql
regenerated.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ew (ENG-608)

- evidence builder: order, legacy key, passport has no back, metadata on
  ID sides only; upload planning reuses unchanged keys
- capture dimension gate; address validation with no fallback
- status enum to label / tone / CTA mapping
- slice: retake drops the stale key; persist v1 migration
- IdentityReview renders three thumbnails, disables confirm until all
  present, uploads before moving on, keeps a retry on partial failure
- AccountType status card + Resubmit CTA; QuickStart and upgrade button on
  the new enum

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ENG-608)

Captures no longer live in the OS temp directory. On accept the still is
moved into <documents>/idv/<side>-<ts>.jpg and the slice persists only the
document-relative path; the absolute path is rebuilt at read time (iOS
changes the container path on every update). IdentityReview checks each
side's file on mount and clears any that is gone so the card reads
"Not taken yet" and confirm disables.

- upload failures carry a reason (file | network); IdentityReview surfaces
  the hook's message for file problems and clears that side instead of a
  generic retry that fails forever; network failures keep the capture
- uploadOne checks the file exists before requesting a presigned URL
- fileSha256Hex uses native RNFS.hash instead of a base64 read + pure-JS
  SHA-256 on the JS thread
- issuingCountry dropped: the schema field is optional and there is no
  picker, so nothing is sent rather than "JM" on every document
- aspect gate removed (takePhoto returns the full sensor frame, so it could
  never fire); captureBadShape key removed from all 24 locales
- resetIdentity is dispatched and the stills unlinked once the upgrade
  request is on file; switching document type also unlinks old captures
- IdentityCapture has a close control (headerShown is false, and the
  permission-denied / no-camera branches had no way out)
- tests: use-account-upgrade.spec (upload loop, key reuse, stop on first
  failure, no submit on partial failure, evidence + legacy idDocument),
  identity-capture.spec (permission, gate, accept/persist/next side,
  close), identity-files.spec, plus review/slice/utils spec updates

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…resubmit

Review fixes for #736.

- Logout: `cleanUp` reset the accountUpgrade slice but left the captures
  under <documents>/idv/ with nothing referencing them, so photos of a
  government ID survived the account that took them. Add
  `removeIdentityDir` and call it before `resetAccountUpgrade`.
- Resubmit: `submitAccountUpgrade` flattened the upload failure to
  `errors`, dropping `failedSide`/`reason`, so a file-reason failure on
  the resubmit path kept the side in the slice with confirm enabled and
  Try again failed identically. `UpgradeResult` now carries both and
  IdentityReview clears the side on `reason === "file"` exactly as the
  first-submission branch does.

Tests: removeIdentityDir cases, a use-logout spec pinning the wipe before
the slice reset, resubmit file/network failure cases on IdentityReview,
and the hook spec now asserts the propagated side/reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Both were pre-existing patterns my diff touched, so the gate flagged them:
- upgrade-trial-account: the #FF7e1c literal duplicated the palette's
  _orange token; moved into useStyles as awaitingReview.
- BankInformation: the global alert() is banned by no-alert; use
  Alert.alert("", msg), matching the rest of the flow.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@islandbitcoin
islandbitcoin force-pushed the feat/eng-608-id-capture branch from 4f56042 to 6c7f0dc Compare September 25, 2026 06:18
@islandbitcoin

Copy link
Copy Markdown
Contributor Author

Device test — Pixel 8 Pro (Android 17 / API 37), targetSdk 36, TEST backend

Drove the whole flow on hardware against TEST with flash#515 live on the cluster.

Passes: document-type screen; front capture with the card overlay, close control and shutter; passport correctly skips the back side straight to the selfie; selfie uses the oval overlay and the front camera; preview Retake / Use photo; review screen shows exactly two rows with per-side retake; Confirm and continue uploads and advances; the old PhotoUploadField is gone from Banking Information; submit succeeds.

Backend round trip: AUR q1fsglgd10 (Pending) → IDV-00012 (Checks pending), two evidence rows carrying evidence_type id_front / selfie, per-side file_keys and full sha256 hashes. The app's status card then rendered "Submitted — We received your request and are running the first checks", i.e. #515's derivation end to end.

One gap, not a blocker: document_type and issuing_country are empty on both rows. Dropping the hard-coded issuingCountry: "JM" in round 2 was right, but #515 resolves the registry Link from (documentType + ISO-2 country) and the seeded codes are country-prefixed (JM_PASSPORT), so with no country the mapper correctly omits both. Reviewers get typed sides but not which document. Filed as ENG-610 (country picker).

Worth knowing for anyone else testing this: at level Zero, PersonalInformation.tsx:106 routes through phone Validation, which fails for the TEST review account because the number is its own login. Level 1+ goes straight to IdentityDocumentType. Bumped the account to level 1 for the run and restored it to 0 afterwards. Pre-existing — this PR only changed the navigation target in that file.

@islandbitcoin
islandbitcoin merged commit ce85783 into main Sep 25, 2026
11 checks passed
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