-
Notifications
You must be signed in to change notification settings - Fork 208
SELF-1231: feat- add restore account #1445
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
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughAdds a bulk "restore all documents" account-restore flow: new exported restoreSecretForAllDocuments(selfClient, secret) iterates documents, validates registration/CSCA per document, re-stores MRZ passport data when needed, marks documents registered, and returns updated document IDs; navigation and recovery screens accept a restoreAllDocuments flag to trigger this flow. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SettingsScreen
participant AccountRestoreScreen
participant AccountRecoveryChoiceScreen
participant SelfClient
participant PassportProvider
User->>SettingsScreen: Tap "Restore account"
SettingsScreen->>AccountRestoreScreen: Navigate
AccountRestoreScreen->>SelfClient: loadDocumentCatalog()
SelfClient-->>AccountRestoreScreen: documents
alt Unregistered docs exist
AccountRestoreScreen->>AccountRecoveryChoiceScreen: Navigate (restoreAllDocuments: true)
else No unregistered docs
AccountRestoreScreen->>SelfClient: Navigate to CountryPicker
end
User->>AccountRecoveryChoiceScreen: Submit secret
AccountRecoveryChoiceScreen->>SelfClient: restoreDocumentSecret()
SelfClient-->>AccountRecoveryChoiceScreen: registration confirmed
alt restoreAllDocuments == true
AccountRecoveryChoiceScreen->>PassportProvider: restoreSecretForAllDocuments(secret)
PassportProvider->>SelfClient: loadDocumentCatalog()/loadDocumentData()
loop per document
PassportProvider->>PassportProvider: check isRegistered, isMRZ, CSCA (callback-style)
alt eligible
PassportProvider->>PassportProvider: reStorePassportDataWithRightCSCA()
PassportProvider->>SelfClient: updateDocumentRegistration(docId, registered)
else not-eligible or error
PassportProvider-->>PassportProvider: log error and continue
end
end
PassportProvider-->>AccountRecoveryChoiceScreen: succeeded IDs
end
AccountRecoveryChoiceScreen->>User: Show success/failure outcome
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
app/src/providers/passportDataProvider.tsx(2 hunks)app/src/providers/selfClientProvider.tsx(1 hunks)app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx(6 hunks)app/src/screens/account/recovery/AccountRecoveryScreen.tsx(1 hunks)app/src/screens/account/recovery/AccountRestoreScreen.tsx(1 hunks)app/src/screens/account/recovery/RecoverWithPhraseScreen.tsx(5 hunks)app/src/screens/account/settings/SettingsScreen.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/providers/passportDataProvider.tsxapp/src/screens/account/recovery/AccountRestoreScreen.tsxapp/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsxapp/src/screens/account/recovery/AccountRecoveryScreen.tsxapp/src/providers/selfClientProvider.tsxapp/src/screens/account/settings/SettingsScreen.tsx
🧠 Learnings (6)
📚 Learning: 2025-09-10T14:47:40.945Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1041
File: app/src/providers/passportDataProvider.tsx:297-301
Timestamp: 2025-09-10T14:47:40.945Z
Learning: In app/src/providers/passportDataProvider.tsx: The deleteDocumentDirectlyFromKeychain function is a low-level utility used by the DocumentsAdapter and should not include error handling since callers like deleteDocument() already implement appropriate try/catch with logging for Keychain operations.
Applied to files:
app/src/providers/passportDataProvider.tsxapp/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsxapp/src/providers/selfClientProvider.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: The main App.tsx file is located at app/App.tsx (not in app/src), and it properly wraps the entire app with SelfClientProvider at the top of the provider hierarchy, enabling useSelfClient() hook usage throughout all navigation screens.
Applied to files:
app/src/screens/account/recovery/AccountRestoreScreen.tsxapp/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.
Applied to files:
app/src/screens/account/recovery/AccountRestoreScreen.tsxapp/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsxapp/src/providers/selfClientProvider.tsx
📚 Learning: 2025-08-26T14:41:41.821Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/aesop/PassportOnboardingScreen.tsx:0-0
Timestamp: 2025-08-26T14:41:41.821Z
Learning: When verifying provider hierarchies in React Native apps, always check the main App.tsx file at the app root, not just navigation/index.tsx and layout files, as providers are often configured at the top-level App component.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-08-23T02:02:02.556Z
Learnt from: transphorm
Repo: selfxyz/self PR: 942
File: app/vite.config.ts:170-0
Timestamp: 2025-08-23T02:02:02.556Z
Learning: In the selfxyz/self React Native app, devTools from '@/navigation/devTools' are intentionally shipped to production builds for testing purposes, not excluded as is typical in most applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-10-23T12:08:55.529Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1236
File: packages/mobile-sdk-alpha/src/flows/onboarding/document-nfc-screen.tsx:356-378
Timestamp: 2025-10-23T12:08:55.529Z
Learning: In packages/mobile-sdk-alpha/src/flows/onboarding/document-nfc-screen.tsx, the NFC native events emitted via NativeEventEmitter are generic status strings (e.g., "PACE succeeded", "BAC failed", "Reading DG1 succeeded") and do not contain sensitive MRZ data or passport numbers, so they do not require sanitization before logging.
Applied to files:
app/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
🧬 Code graph analysis (5)
app/src/providers/passportDataProvider.tsx (6)
packages/mobile-sdk-alpha/src/index.ts (2)
SelfClient(22-22)reStorePassportDataWithRightCSCA(105-105)common/src/utils/passports/validate.ts (1)
isUserRegisteredWithAlternativeCSCA(311-391)common/index.ts (1)
isMRZDocument(125-125)common/src/utils/types.ts (1)
isMRZDocument(171-177)common/src/utils/index.ts (1)
isMRZDocument(73-73)packages/mobile-sdk-alpha/src/documents/utils.ts (1)
reStorePassportDataWithRightCSCA(180-209)
app/src/screens/account/recovery/AccountRestoreScreen.tsx (3)
packages/mobile-sdk-alpha/src/constants/colors.ts (3)
white(59-59)blue600(10-10)black(8-8)packages/mobile-sdk-alpha/src/constants/analytics.ts (1)
BackupEvents(61-78)packages/mobile-sdk-demo/tests/mocks/react-native.ts (1)
StyleSheet(27-29)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (1)
app/src/providers/passportDataProvider.tsx (1)
restoreSecretForAllDocuments(897-938)
app/src/screens/account/recovery/RecoverWithPhraseScreen.tsx (1)
app/src/providers/passportDataProvider.tsx (1)
restoreSecretForAllDocuments(897-938)
app/src/providers/selfClientProvider.tsx (1)
app/src/navigation/index.tsx (1)
navigationRef(186-186)
🔇 Additional comments (4)
app/src/providers/selfClientProvider.tsx (1)
184-190: Consistent routing for account recovery triggerWiring
PROVING_ACCOUNT_RECOVERY_REQUIREDtoAccountRecoveryChoicewithrestoreAllDocuments: falselooks correct and keeps this entry point aligned with the new param-driven flow.app/src/screens/account/recovery/AccountRecoveryScreen.tsx (1)
25-35: Restore-all flag propagation from entry screen looks goodPassing
restoreAllDocuments: truewhen enteringAccountRecoveryChoicefrom this screen cleanly selects the bulk-restore path; no correctness or safety issues here.app/src/screens/account/settings/SettingsScreen.tsx (1)
72-86: New “Restore account” settings entry is correctly wiredAdding
['Restore account', 'AccountRestore']intoroutesintegrates cleanly with the existingonMenuPressswitch and navigation flow; assuming theAccountRestoreroute is registered in your navigator/param list, this looks solid.app/src/screens/account/recovery/AccountRestoreScreen.tsx (1)
22-52: Restore-all entry logic is soundThe
hasUnregisteredDocumentshelper andonRestoreAccountPressdecision (route toAccountRecoveryChoicewithrestoreAllDocuments: truevsCountryPicker) are straightforward and correctly scoped to non-mock, unregistered documents. No medium+ risks spotted here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/src/navigation/account.ts(2 hunks)app/src/providers/passportDataProvider.tsx(2 hunks)app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx(5 hunks)app/src/screens/account/recovery/RecoverWithPhraseScreen.tsx(5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/providers/passportDataProvider.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsxapp/src/navigation/account.ts
🧠 Learnings (6)
📚 Learning: 2025-09-10T14:47:40.945Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1041
File: app/src/providers/passportDataProvider.tsx:297-301
Timestamp: 2025-09-10T14:47:40.945Z
Learning: In app/src/providers/passportDataProvider.tsx: The deleteDocumentDirectlyFromKeychain function is a low-level utility used by the DocumentsAdapter and should not include error handling since callers like deleteDocument() already implement appropriate try/catch with logging for Keychain operations.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/providers/passportDataProvider.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-10-23T12:08:55.529Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1236
File: packages/mobile-sdk-alpha/src/flows/onboarding/document-nfc-screen.tsx:356-378
Timestamp: 2025-10-23T12:08:55.529Z
Learning: In packages/mobile-sdk-alpha/src/flows/onboarding/document-nfc-screen.tsx, the NFC native events emitted via NativeEventEmitter are generic status strings (e.g., "PACE succeeded", "BAC failed", "Reading DG1 succeeded") and do not contain sensitive MRZ data or passport numbers, so they do not require sanitization before logging.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: The main App.tsx file is located at app/App.tsx (not in app/src), and it properly wraps the entire app with SelfClientProvider at the top of the provider hierarchy, enabling useSelfClient() hook usage throughout all navigation screens.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-08-26T14:41:41.821Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/aesop/PassportOnboardingScreen.tsx:0-0
Timestamp: 2025-08-26T14:41:41.821Z
Learning: When verifying provider hierarchies in React Native apps, always check the main App.tsx file at the app root, not just navigation/index.tsx and layout files, as providers are often configured at the top-level App component.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
📚 Learning: 2025-08-23T02:02:02.556Z
Learnt from: transphorm
Repo: selfxyz/self PR: 942
File: app/vite.config.ts:170-0
Timestamp: 2025-08-23T02:02:02.556Z
Learning: In the selfxyz/self React Native app, devTools from '@/navigation/devTools' are intentionally shipped to production builds for testing purposes, not excluded as is typical in most applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/src/screens/account/recovery/RecoverWithPhraseScreen.tsx
🧬 Code graph analysis (2)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (4)
packages/mobile-sdk-alpha/src/constants/analytics.ts (1)
BackupEvents(61-78)app/src/providers/passportDataProvider.tsx (2)
restoreSecretForAllDocuments(897-948)reStorePassportDataWithRightCSCA(702-744)common/src/utils/passports/validate.ts (1)
isUserRegisteredWithAlternativeCSCA(311-391)packages/mobile-sdk-alpha/src/documents/utils.ts (2)
reStorePassportDataWithRightCSCA(180-209)markCurrentDocumentAsRegistered(170-178)
app/src/screens/account/recovery/RecoverWithPhraseScreen.tsx (2)
app/src/providers/passportDataProvider.tsx (2)
restoreSecretForAllDocuments(897-948)reStorePassportDataWithRightCSCA(702-744)common/src/utils/passports/validate.ts (1)
isUserRegisteredWithAlternativeCSCA(311-391)
🔇 Additional comments (3)
app/src/navigation/account.ts (1)
15-21: AccountRestore route wiring is consistent with existing navigation configThe new
AccountRestorescreen is imported and registered with options matching the other account settings screens (header colors, title). No navigation or type-safety issues stand out.Also applies to: 83-94
app/src/screens/account/recovery/RecoverWithPhraseScreen.tsx (1)
10-50: Recover-with-phrase flow now enforces commitment checks and handles bulk restore safely
- Route params are handled defensively via
route.params?.restoreAllDocuments ?? false, avoiding crashes on missing params.- The single-document path always requires
isRegistered === truebefore restoring CSCA data and marking the document registered.- The all-documents path delegates verification to
restoreSecretForAllDocumentsand treats “0 successful docs” as a hard failure viahandleRestoreFailed.This keeps the “secret ↔ commitment tree” check mandatory while adding the bulk-restore capability without weakening registration guarantees.
Also applies to: 66-77, 99-184
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (1)
7-8: Account recovery choice flow cleanly integrates bulk restore without weakening checks
- Route params are handled defensively (
route.params?.restoreAllDocuments ?? false), avoiding the earlier risk of destructuringundefined.- Manual recovery navigation correctly forwards
restoreAllDocumentstoRecoverWithPhrase.- In cloud restore:
- The single-doc path always enforces
isRegisteredbefore toggling cloud backup, updating CSCA, or marking the document registered.- The bulk path relies on
restoreSecretForAllDocumentsto enforce per-document verification and treats “no document restored” as a failure viahandleRestoreFailed.Overall, the new branching keeps the registration checks mandatory while adding the “restore all documents” capability in a controlled way.
Also applies to: 47-55, 74-80, 86-101, 128-205
| import { isUserRegisteredWithAlternativeCSCA } from '@selfxyz/common/utils/passports/validate'; | ||
| import type { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid hard‑coding 'prod' when fetching Aadhaar protocol data in bulk restore
In restoreSecretForAllDocuments, Aadhaar keys are loaded with a hard‑coded production environment:
if (!useProtocolStore.getState().aadhaar.public_keys) {
await useProtocolStore.getState().aadhaar.fetch_all('prod');
}This couples bulk restore to prod only and will likely break or silently mis‑verify documents in staging/dev (or any non‑prod environment), since the commitment tree and public keys won’t match the environment the app/selfClient is actually using.
Consider deriving the environment from existing configuration (e.g., a field on selfClient, a global env setting, or whatever your other protocol-store fetches already use) and passing that through instead of a literal:
const env = /* derive from selfClient or config */;
if (!useProtocolStore.getState().aadhaar.public_keys) {
await useProtocolStore.getState().aadhaar.fetch_all(env);
}This keeps restore behavior aligned with the currently active network and avoids hard‑to‑debug environment mismatches.
Also applies to: 892-947
🤖 Prompt for AI Agents
In app/src/providers/passportDataProvider.tsx around lines 57-58 (and similarly
at 892-947), the code hard-codes the Aadhaar protocol fetch environment to
'prod' which can cause restore/verification mismatches in non-production
environments; change the call to derive the environment from the current
runtime/config (for example use a field on selfClient, a protocol-store helper,
or a global env/config value the app already uses) and pass that derived env
into useProtocolStore.getState().aadhaar.fetch_all(env) instead of 'prod';
ensure the derived value is validated (fallback to a sensible default) and
update all other instances (892-947) to use the same derived environment
variable so bulk restore aligns with the active network.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The screen where we hardcoded will be accessible only in the ‘prod’ environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seshanthS, thanks for clarifying! If the restore feature is prod-only by design, then hard-coding 'prod' is reasonable.
To make that constraint more explicit for future maintainers, you could consider adding a comment above the fetch call:
// Restore feature is prod-only; always use prod environment
if (!useProtocolStore.getState().aadhaar.public_keys) {
await useProtocolStore.getState().aadhaar.fetch_all('prod');
}Or if you want to be extra defensive, add a runtime check that throws early if someone tries to use this in non-prod. But if the UI already enforces the prod-only access, the current approach is fine.
🧠 Learnings used
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement certificate validation for passport data verification.
Learnt from: shazarre
Repo: selfxyz/self PR: 1041
File: app/src/providers/passportDataProvider.tsx:297-301
Timestamp: 2025-09-10T14:47:40.945Z
Learning: In app/src/providers/passportDataProvider.tsx: The deleteDocumentDirectlyFromKeychain function is a low-level utility used by the DocumentsAdapter and should not include error handling since callers like deleteDocument() already implement appropriate try/catch with logging for Keychain operations.
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:51.177Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.test.{ts,tsx} : Test `isPassportDataValid()` with realistic, synthetic passport data and never use real user PII
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/compliance-verification.mdc:0-0
Timestamp: 2025-11-25T14:07:28.188Z
Learning: Applies to **/{compliance,ofac,verification,identity}/**/*.{ts,tsx,js,py} : Validate passport numbers by removing whitespace/punctuation and performing country-specific format validation
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/compliance-verification.mdc:0-0
Timestamp: 2025-11-25T14:07:28.188Z
Learning: Applies to **/{compliance,ofac,verification,identity}/**/*.{ts,tsx,js,py} : Implement three-tier OFAC verification system: Passport Number Check (direct passport validation), Name + DOB Check (full name with exact date of birth), and Name + Year Check (name with year of birth, defaulting to Jan-01)
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Do not log sensitive data in production, including identity verification and passport information.
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to **/*.{ts,tsx,js} : Never log PII, credentials, or private keys in production code; use DEBUG_SECRETS_TOKEN flag for debug-level secrets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/src/navigation/account.ts(2 hunks)app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx(5 hunks)app/src/screens/account/settings/SettingsScreen.tsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- app/src/screens/account/settings/SettingsScreen.tsx
- app/src/navigation/account.ts
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{js,jsx,ts,tsx}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g.,***-***-1234for passport numbers,J*** D***for names).
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{ts,tsx,js,jsx}: Use React Navigation withcreateStaticNavigationfor type-safe navigation in React Native applications.
Implement platform-specific handling withPlatform.OS === 'ios' ? 'iOS' : 'Android'checks before platform-specific code in React Native.
Initialize native modules withinitializeNativeModules()before any native operations in React Native.
Implement lazy loading for screens usingReact.lazy()in React Native applications.
Implement custom modal system withuseModalhook and callback registry in React Native.
Integrate haptic feedback usinguseHapticNavigationhook in React Native navigation.
Use platform-specific initial routes: web uses 'Home', mobile uses 'Splash' in React Navigation.
Use Zustand for global state management in React Native applications.
Use custom hooks for complex state (useModal,useHapticNavigation) instead of inline logic.
Use AsyncStorage for simple data, SQLite for complex data, and Keychain for sensitive data in React Native.
Use@/alias for src imports and@tests/alias for test imports in TypeScript/JavaScript files.
Use conditional rendering with Platform.OS for platform-specific code in React Native.
Use Tamagui for UI components in React Native applications.
Do not log sensitive data in production, including identity verification and passport information.
Use Keychain for secure storage of sensitive data in React Native.
Implement proper cleanup of sensitive data after use.
Implement certificate validation for passport data verification.
Always use try-catch for async operations in React Native and TypeScript code.
Implement graceful degradation when native modules fail in React Native.
Provide user-friendly error messages in UI and error handlers.
Lazy load screens and components to optimize bundle size in React Native.
Prevent memory leaks in native modules in React Native.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursorrules)
Implement comprehensive error boundaries in React components.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{tsx,jsx,ts,js}
📄 CodeRabbit inference engine (.cursorrules)
Implement proper cleanup in useEffect and component unmount hooks in React.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/{mobile,client,app,time,verification}/**/*.{ts,tsx,js,swift,kt}
📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)
Use server-signed time tokens or chain block timestamps for trusted time in mobile clients, do not trust device wall-clock alone
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}
📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}: Include trusted time anchor in proof generation and verify time anchor authenticity before proof generation in mobile implementations
Achieve proof generation in <60 seconds on mid-tier mobile devices
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/src/**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Use module mapping
@/→src/and@tests/→tests/src/in app Jest configuration
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
**/*.{ts,tsx,js}: Never log PII, credentials, or private keys in production code; use DEBUG_SECRETS_TOKEN flag for debug-level secrets
Use consistent redaction patterns for sensitive fields in logs and test data
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Update app to consume mobile-sdk-alpha modules after migration and validate all existing app tests pass
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx,js,jsx,json,yml,yaml}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn nicepasses (fixes linting and formatting) before creating a PR
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn typespasses (TypeScript validation) before creating a PR
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx,js,jsx,swift,kt,java}
📄 CodeRabbit inference engine (app/AGENTS.md)
app/**/*.{ts,tsx,js,jsx,swift,kt,java}: Flag security-sensitive operations and note performance implications in code comments
Ensure no sensitive data (PII, credentials, tokens) is present in logs
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
🧠 Learnings (19)
📚 Learning: 2025-09-10T14:47:40.945Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1041
File: app/src/providers/passportDataProvider.tsx:297-301
Timestamp: 2025-09-10T14:47:40.945Z
Learning: In app/src/providers/passportDataProvider.tsx: The deleteDocumentDirectlyFromKeychain function is a low-level utility used by the DocumentsAdapter and should not include error handling since callers like deleteDocument() already implement appropriate try/catch with logging for Keychain operations.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/processing/**/*.{ts,tsx} : Migrate MRZ processing helpers from app/src/utils/ to packages/mobile-sdk-alpha/src/processing/ with comprehensive tests for MRZ parsing and cross-platform compatibility
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:23.106Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: app/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:23.106Z
Learning: Applies to app/{ios,android}/** : Document complex native module changes and explain platform-specific code paths
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/validation/**/*.{ts,tsx} : Migrate document validation logic from app/src/utils/ to packages/mobile-sdk-alpha/src/validation/ with unit tests for each validation rule and edge cases
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/index.ts : Re-export all new migrated modules via packages/mobile-sdk-alpha/src/index.ts and document them in packages/mobile-sdk-alpha/README.md
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/tests/**/*.integration.{test.ts,test.tsx,spec.ts,spec.tsx} : Test end-to-end flows covering complete user journeys through the identity verification process
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:11.887Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:11.887Z
Learning: Address CodeRabbitAI feedback or document why not; resolve security warnings; verify performance benchmarks; confirm no sensitive data exposed in logs/comments.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:23.106Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: app/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:23.106Z
Learning: Address CodeRabbitAI feedback and resolve security warnings during code review
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use React Navigation with `createStaticNavigation` for type-safe navigation in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: The main App.tsx file is located at app/App.tsx (not in app/src), and it properly wraps the entire app with SelfClientProvider at the top of the provider hierarchy, enabling useSelfClient() hook usage throughout all navigation screens.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Tamagui for UI components in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Zustand for global state management in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:41:41.821Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/aesop/PassportOnboardingScreen.tsx:0-0
Timestamp: 2025-08-26T14:41:41.821Z
Learning: When verifying provider hierarchies in React Native apps, always check the main App.tsx file at the app root, not just navigation/index.tsx and layout files, as providers are often configured at the top-level App component.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement lazy loading for screens using `React.lazy()` in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement custom modal system with `useModal` hook and callback registry in React Native.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Integrate haptic feedback using `useHapticNavigation` hook in React Native navigation.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-23T02:02:02.556Z
Learnt from: transphorm
Repo: selfxyz/self PR: 942
File: app/vite.config.ts:170-0
Timestamp: 2025-08-23T02:02:02.556Z
Learning: In the selfxyz/self React Native app, devTools from '@/navigation/devTools' are intentionally shipped to production builds for testing purposes, not excluded as is typical in most applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:51.177Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:51.177Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.test.{ts,tsx} : Test `isPassportDataValid()` with realistic, synthetic passport data and never use real user PII
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
🪛 GitHub Actions: Mobile CI
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
[error] 95-95: TypeScript error: Cannot find name 'setRestoring'. Ensure 'setRestoring' is defined (e.g., from useState) or fix its usage.
🪛 GitHub Check: build-deps
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
[warning] 12-12:
'isMRZDocument' is defined but never used
🪛 GitHub Check: workspace-lint
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
[warning] 12-12:
'isMRZDocument' is defined but never used
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: test-common
- GitHub Check: type-check
- GitHub Check: e2e-ios
- GitHub Check: android-build-test
- GitHub Check: analyze-android
- GitHub Check: analyze-ios
🔇 Additional comments (2)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (2)
47-55: Safe route-param handling and propagation ofrestoreAllDocumentslooks solidSwitching the component signature to receive
routeand derivingrestoreAllDocumentsviaroute.params?.restoreAllDocuments ?? falseavoids the earlier unsafe destructuring and gracefully handles missing params. Passing the same flag throughuseHapticNavigation('RecoverWithPhrase', { params: { restoreAllDocuments } })keeps the manual recovery flow correctly wired without introducing new edge cases.Also applies to: 75-81
130-181: Bulk vs per-document restore branching keeps the commitment check mandatoryThe new
restoreAllDocumentsbranch usesrestoreSecretForAllDocumentsand fails whensuccessDocuments.length === 0, while the per-document path now unconditionally treats!isRegisteredas a hard failure before restoring/marking the document or toggling cloud backup. This closes the earlier hole where a failed commitment check could be treated as non-fatal whenrestoreAllDocumentswas true, and maintains a clear, security-focused separation between bulk and single-document flows.
| const handleRestoreFailed = useCallback( | ||
| (reason: string, hasCSCA: boolean) => { | ||
| console.warn('Failed to restore account'); | ||
| trackEvent(BackupEvents.CLOUD_RESTORE_FAILED_PASSPORT_NOT_REGISTERED, { | ||
| reason: reason, | ||
| hasCSCA: hasCSCA, | ||
| }); | ||
| navigation.navigate({ name: 'Home', params: {} }); | ||
| setRestoring(false); | ||
| }, | ||
| [trackEvent, navigation], | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
find . -type f -name "AccountRecoveryChoiceScreen.tsx" | head -5Repository: selfxyz/self
Length of output: 122
🏁 Script executed:
cat -n app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxRepository: selfxyz/self
Length of output: 14363
🏁 Script executed:
cd app && yarn types 2>&1 | grep -A 5 "AccountRecoveryChoiceScreen"Repository: selfxyz/self
Length of output: 38
🏁 Script executed:
cd app && yarn types 2>&1 | head -100Repository: selfxyz/self
Length of output: 525
🏁 Script executed:
cd app && npx tsc --noEmit 2>&1 | grep -A 3 "AccountRecoveryChoiceScreen"Repository: selfxyz/self
Length of output: 38
Move handleRestoreFailed inside restoreAccountFlow to fix scope error on setRestoring
Line 95 references setRestoring(false), but setRestoring only exists as a parameter to restoreAccountFlow (line 104), not in the scope where handleRestoreFailed is defined (lines 87-98). This causes a TypeScript error and would crash at runtime.
Move handleRestoreFailed inside restoreAccountFlow so it can close over setRestoring, and remove it from the dependency array at line 205. This preserves all analytics and navigation behavior while fixing the scope error.
🧰 Tools
🪛 GitHub Actions: Mobile CI
[error] 95-95: TypeScript error: Cannot find name 'setRestoring'. Ensure 'setRestoring' is defined (e.g., from useState) or fix its usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (1)
175-179: Add defensive null check before using CSCA.The type assertion
csca as stringat line 177 assumescscais non-null whenisRegisteredis true. While this aligns with the expected API contract ofisUserRegisteredWithAlternativeCSCA, there's no runtime guarantee.Apply this diff to add a defensive check:
if (!isRegistered) { console.warn( 'Secret provided did not match a registered ID. Please try again.', ); handleRestoreFailed('document_not_registered', !!csca); + setRestoring(false); return false; } + if (!csca) { + console.error('Registration verified but CSCA is missing'); + handleRestoreFailed('missing_csca', false); + setRestoring(false); + return false; + } if (isCloudRestore && !cloudBackupEnabled) { toggleCloudBackupEnabled(); } await reStorePassportDataWithRightCSCA( passportDataParsed, - csca as string, + csca, ); await markCurrentDocumentAsRegistered(selfClient);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx(5 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{js,jsx,ts,tsx}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g.,***-***-1234for passport numbers,J*** D***for names).
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{ts,tsx,js,jsx}: Use React Navigation withcreateStaticNavigationfor type-safe navigation in React Native applications.
Implement platform-specific handling withPlatform.OS === 'ios' ? 'iOS' : 'Android'checks before platform-specific code in React Native.
Initialize native modules withinitializeNativeModules()before any native operations in React Native.
Implement lazy loading for screens usingReact.lazy()in React Native applications.
Implement custom modal system withuseModalhook and callback registry in React Native.
Integrate haptic feedback usinguseHapticNavigationhook in React Native navigation.
Use platform-specific initial routes: web uses 'Home', mobile uses 'Splash' in React Navigation.
Use Zustand for global state management in React Native applications.
Use custom hooks for complex state (useModal,useHapticNavigation) instead of inline logic.
Use AsyncStorage for simple data, SQLite for complex data, and Keychain for sensitive data in React Native.
Use@/alias for src imports and@tests/alias for test imports in TypeScript/JavaScript files.
Use conditional rendering with Platform.OS for platform-specific code in React Native.
Use Tamagui for UI components in React Native applications.
Do not log sensitive data in production, including identity verification and passport information.
Use Keychain for secure storage of sensitive data in React Native.
Implement proper cleanup of sensitive data after use.
Implement certificate validation for passport data verification.
Always use try-catch for async operations in React Native and TypeScript code.
Implement graceful degradation when native modules fail in React Native.
Provide user-friendly error messages in UI and error handlers.
Lazy load screens and components to optimize bundle size in React Native.
Prevent memory leaks in native modules in React Native.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursorrules)
Implement comprehensive error boundaries in React components.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{tsx,jsx,ts,js}
📄 CodeRabbit inference engine (.cursorrules)
Implement proper cleanup in useEffect and component unmount hooks in React.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/{mobile,client,app,time,verification}/**/*.{ts,tsx,js,swift,kt}
📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)
Use server-signed time tokens or chain block timestamps for trusted time in mobile clients, do not trust device wall-clock alone
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}
📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}: Include trusted time anchor in proof generation and verify time anchor authenticity before proof generation in mobile implementations
Achieve proof generation in <60 seconds on mid-tier mobile devices
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/src/**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Use module mapping
@/→src/and@tests/→tests/src/in app Jest configuration
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
**/*.{ts,tsx,js}: Never log PII, credentials, or private keys in production code; use DEBUG_SECRETS_TOKEN flag for debug-level secrets
Use consistent redaction patterns for sensitive fields in logs and test data
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Update app to consume mobile-sdk-alpha modules after migration and validate all existing app tests pass
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx,js,jsx,json,yml,yaml}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn nicepasses (fixes linting and formatting) before creating a PR
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn typespasses (TypeScript validation) before creating a PR
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx,js,jsx,swift,kt,java}
📄 CodeRabbit inference engine (app/AGENTS.md)
app/**/*.{ts,tsx,js,jsx,swift,kt,java}: Flag security-sensitive operations and note performance implications in code comments
Ensure no sensitive data (PII, credentials, tokens) is present in logs
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
🧠 Learnings (18)
📚 Learning: 2025-11-25T14:08:23.106Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: app/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:23.106Z
Learning: Applies to app/{ios,android}/** : Document complex native module changes and explain platform-specific code paths
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/processing/**/*.{ts,tsx} : Migrate MRZ processing helpers from app/src/utils/ to packages/mobile-sdk-alpha/src/processing/ with comprehensive tests for MRZ parsing and cross-platform compatibility
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/validation/**/*.{ts,tsx} : Migrate document validation logic from app/src/utils/ to packages/mobile-sdk-alpha/src/validation/ with unit tests for each validation rule and edge cases
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:11.887Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:11.887Z
Learning: Address CodeRabbitAI feedback or document why not; resolve security warnings; verify performance benchmarks; confirm no sensitive data exposed in logs/comments.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/tee/**/*.{ts,tsx} : Migrate TEE session management from app/src/utils/ to packages/mobile-sdk-alpha/src/tee/ with tests for WebSocket handling, abort, timeout, and lifecycle events
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/protocol/**/*.{ts,tsx} : Migrate protocol synchronization from app/src/utils/ to packages/mobile-sdk-alpha/src/protocol/ with tests for tree fetching, TTL caching, rate limiting, and memory bounds
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use React Navigation with `createStaticNavigation` for type-safe navigation in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Tamagui for UI components in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Zustand for global state management in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement lazy loading for screens using `React.lazy()` in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Integrate haptic feedback using `useHapticNavigation` hook in React Native navigation.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement custom modal system with `useModal` hook and callback registry in React Native.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:41:41.821Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/aesop/PassportOnboardingScreen.tsx:0-0
Timestamp: 2025-08-26T14:41:41.821Z
Learning: When verifying provider hierarchies in React Native apps, always check the main App.tsx file at the app root, not just navigation/index.tsx and layout files, as providers are often configured at the top-level App component.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: The main App.tsx file is located at app/App.tsx (not in app/src), and it properly wraps the entire app with SelfClientProvider at the top of the provider hierarchy, enabling useSelfClient() hook usage throughout all navigation screens.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use custom hooks for complex state (`useModal`, `useHapticNavigation`) instead of inline logic.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-09-10T14:47:40.945Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1041
File: app/src/providers/passportDataProvider.tsx:297-301
Timestamp: 2025-09-10T14:47:40.945Z
Learning: In app/src/providers/passportDataProvider.tsx: The deleteDocumentDirectlyFromKeychain function is a low-level utility used by the DocumentsAdapter and should not include error handling since callers like deleteDocument() already implement appropriate try/catch with logging for Keychain operations.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:51.177Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:51.177Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.test.{ts,tsx} : Test `isPassportDataValid()` with realistic, synthetic passport data and never use real user PII
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
🧬 Code graph analysis (1)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (3)
app/src/providers/passportDataProvider.tsx (2)
restoreSecretForAllDocuments(897-948)reStorePassportDataWithRightCSCA(702-744)common/src/utils/passports/validate.ts (1)
isUserRegisteredWithAlternativeCSCA(311-391)packages/mobile-sdk-alpha/src/stores/protocolStore.ts (1)
useProtocolStore(160-528)
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: build-android
- GitHub Check: build-ios
- GitHub Check: test
- GitHub Check: type-check
- GitHub Check: e2e-ios
- GitHub Check: android-build-test
- GitHub Check: analyze-android
- GitHub Check: analyze-ios
|
@seshanthS nice 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx(5 hunks)app/tests/src/navigation.test.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{js,jsx,ts,tsx}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g.,***-***-1234for passport numbers,J*** D***for names).
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{ts,tsx,js,jsx}: Use React Navigation withcreateStaticNavigationfor type-safe navigation in React Native applications.
Implement platform-specific handling withPlatform.OS === 'ios' ? 'iOS' : 'Android'checks before platform-specific code in React Native.
Initialize native modules withinitializeNativeModules()before any native operations in React Native.
Implement lazy loading for screens usingReact.lazy()in React Native applications.
Implement custom modal system withuseModalhook and callback registry in React Native.
Integrate haptic feedback usinguseHapticNavigationhook in React Native navigation.
Use platform-specific initial routes: web uses 'Home', mobile uses 'Splash' in React Navigation.
Use Zustand for global state management in React Native applications.
Use custom hooks for complex state (useModal,useHapticNavigation) instead of inline logic.
Use AsyncStorage for simple data, SQLite for complex data, and Keychain for sensitive data in React Native.
Use@/alias for src imports and@tests/alias for test imports in TypeScript/JavaScript files.
Use conditional rendering with Platform.OS for platform-specific code in React Native.
Use Tamagui for UI components in React Native applications.
Do not log sensitive data in production, including identity verification and passport information.
Use Keychain for secure storage of sensitive data in React Native.
Implement proper cleanup of sensitive data after use.
Implement certificate validation for passport data verification.
Always use try-catch for async operations in React Native and TypeScript code.
Implement graceful degradation when native modules fail in React Native.
Provide user-friendly error messages in UI and error handlers.
Lazy load screens and components to optimize bundle size in React Native.
Prevent memory leaks in native modules in React Native.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursorrules)
Implement comprehensive error boundaries in React components.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
**/*.{tsx,jsx,ts,js}
📄 CodeRabbit inference engine (.cursorrules)
Implement proper cleanup in useEffect and component unmount hooks in React.
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
**/{mobile,client,app,time,verification}/**/*.{ts,tsx,js,swift,kt}
📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)
Use server-signed time tokens or chain block timestamps for trusted time in mobile clients, do not trust device wall-clock alone
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}
📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}: Include trusted time anchor in proof generation and verify time anchor authenticity before proof generation in mobile implementations
Achieve proof generation in <60 seconds on mid-tier mobile devices
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
app/src/**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Use module mapping
@/→src/and@tests/→tests/src/in app Jest configuration
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
**/*.{ts,tsx,js}: Never log PII, credentials, or private keys in production code; use DEBUG_SECRETS_TOKEN flag for debug-level secrets
Use consistent redaction patterns for sensitive fields in logs and test data
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
app/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Update app to consume mobile-sdk-alpha modules after migration and validate all existing app tests pass
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
app/**/*.{ts,tsx,js,jsx,json,yml,yaml}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn nicepasses (fixes linting and formatting) before creating a PR
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn typespasses (TypeScript validation) before creating a PR
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
app/**/*.{ts,tsx,js,jsx,swift,kt,java}
📄 CodeRabbit inference engine (app/AGENTS.md)
app/**/*.{ts,tsx,js,jsx,swift,kt,java}: Flag security-sensitive operations and note performance implications in code comments
Ensure no sensitive data (PII, credentials, tokens) is present in logs
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.test.{ts,tsx,js,jsx}: UserenderHookfor testing custom React hooks instead of rendering components.
Mock console.error in tests to avoid test output clutter while testing error scenarios.
Test error boundaries and recovery mechanisms in React components.
Mock SQLite operations withexecuteSqlmethod in database tests using utilities fromtests/__setup__/databaseMocks.ts.
Files:
app/tests/src/navigation.test.tsx
app/**/*.{test.js,test.ts,test.tsx,spec.js,spec.ts,spec.tsx}
📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)
Use Jest for testing in the app directory with React Native preset configured in jest.config.cjs
Files:
app/tests/src/navigation.test.tsx
app/**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (app/AGENTS.md)
Ensure
yarn testpasses (unit tests) before creating a PR
Files:
app/tests/src/navigation.test.tsx
**/*.{test,spec}.{ts,js,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{test,spec}.{ts,js,tsx,jsx}: Review test files for:
- Test coverage completeness
- Test case quality and edge cases
- Mock usage appropriateness
- Test readability and maintainability
Files:
app/tests/src/navigation.test.tsx
🧠 Learnings (27)
📚 Learning: 2025-11-25T14:08:23.106Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: app/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:23.106Z
Learning: Applies to app/{ios,android}/** : Document complex native module changes and explain platform-specific code paths
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/validation/**/*.{ts,tsx} : Migrate document validation logic from app/src/utils/ to packages/mobile-sdk-alpha/src/validation/ with unit tests for each validation rule and edge cases
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsxapp/tests/src/navigation.test.tsx
📚 Learning: 2025-09-10T14:47:40.945Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1041
File: app/src/providers/passportDataProvider.tsx:297-301
Timestamp: 2025-09-10T14:47:40.945Z
Learning: In app/src/providers/passportDataProvider.tsx: The deleteDocumentDirectlyFromKeychain function is a low-level utility used by the DocumentsAdapter and should not include error handling since callers like deleteDocument() already implement appropriate try/catch with logging for Keychain operations.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:11.887Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:11.887Z
Learning: Address CodeRabbitAI feedback or document why not; resolve security warnings; verify performance benchmarks; confirm no sensitive data exposed in logs/comments.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:23.106Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: app/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:23.106Z
Learning: Address CodeRabbitAI feedback and resolve security warnings during code review
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/tee/**/*.{ts,tsx} : Migrate TEE session management from app/src/utils/ to packages/mobile-sdk-alpha/src/tee/ with tests for WebSocket handling, abort, timeout, and lifecycle events
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/protocol/**/*.{ts,tsx} : Migrate protocol synchronization from app/src/utils/ to packages/mobile-sdk-alpha/src/protocol/ with tests for tree fetching, TTL caching, rate limiting, and memory bounds
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use React Navigation with `createStaticNavigation` for type-safe navigation in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Tamagui for UI components in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Zustand for global state management in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement lazy loading for screens using `React.lazy()` in React Native applications.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Integrate haptic feedback using `useHapticNavigation` hook in React Native navigation.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement custom modal system with `useModal` hook and callback registry in React Native.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:41:41.821Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/aesop/PassportOnboardingScreen.tsx:0-0
Timestamp: 2025-08-26T14:41:41.821Z
Learning: When verifying provider hierarchies in React Native apps, always check the main App.tsx file at the app root, not just navigation/index.tsx and layout files, as providers are often configured at the top-level App component.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
Repo: selfxyz/self PR: 936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: The main App.tsx file is located at app/App.tsx (not in app/src), and it properly wraps the entire app with SelfClientProvider at the top of the provider hierarchy, enabling useSelfClient() hook usage throughout all navigation screens.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use custom hooks for complex state (`useModal`, `useHapticNavigation`) instead of inline logic.
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:08:51.177Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-11-25T14:08:51.177Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.test.{ts,tsx} : Test `isPassportDataValid()` with realistic, synthetic passport data and never use real user PII
Applied to files:
app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/tests/**/*.{test.ts,test.tsx,spec.ts,spec.tsx} : Create comprehensive test fixtures and mock data for each migrated module without exposing sensitive information
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/tests/**/*.integration.{test.ts,test.tsx,spec.ts,spec.tsx} : Test end-to-end flows covering complete user journeys through the identity verification process
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/tests/**/*.{ts,tsx,test.ts,test.tsx} : Create tests BEFORE migrating logic to verify functionality works correctly in the mobile-sdk-alpha package
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to app/src/**/*.{ts,tsx} : Update app to consume mobile-sdk-alpha modules after migration and validate all existing app tests pass
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/tests/**/*.{test.ts,test.tsx,spec.ts,spec.tsx} : Mock native dependencies appropriately in tests when testing platform-specific code
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/**/*.{ts,tsx} : Test platform-specific code paths for React Native (iOS and Android) and web implementations
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Test error boundaries and recovery mechanisms in React components.
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/src/proving/**/*.{ts,tsx} : Migrate proof input generation from app/src/utils/proving/ to packages/mobile-sdk-alpha/src/proving/ with tests for register, disclose, and TEE input generation
Applied to files:
app/tests/src/navigation.test.tsx
📚 Learning: 2025-11-25T14:07:55.507Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-11-25T14:07:55.507Z
Learning: Applies to packages/mobile-sdk-alpha/tests/**/*.{test.ts,test.tsx,spec.ts,spec.tsx} : Suppress console noise in mobile-sdk-alpha tests using setup in tests/setup.ts
Applied to files:
app/tests/src/navigation.test.tsx
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build-android
- GitHub Check: build-ios
- GitHub Check: test
- GitHub Check: test-common
- GitHub Check: type-check
- GitHub Check: android-build-test
- GitHub Check: e2e-ios
- GitHub Check: analyze-android
- GitHub Check: analyze-ios
🔇 Additional comments (2)
app/tests/src/navigation.test.tsx (1)
35-86: Navigation test update forAccountRestorelooks correctIncluding
'AccountRestore'in the sortedlistOfScreensexpectation keeps this test aligned with the new route and maintains coverage of the navigation registry.app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx (1)
46-54: Route param handling and propagation ofrestoreAllDocumentsis now robustUsing
StaticScreenPropswithroute.params?.restoreAllDocuments ?? falseavoids crashes when params are missing and keeps therestoreAllDocumentsflag consistently forwarded into theRecoverWithPhrasenavigation params. This closes the earlier unsafe-destructuring gap while preserving the intended behavior.Also applies to: 75-79
| if (restoreAllDocuments) { | ||
| const successDocuments = await restoreSecretForAllDocuments( | ||
| selfClient, | ||
| secret as string, | ||
| { | ||
| getCommitmentTree(docCategory) { | ||
| return useProtocolStore.getState()[docCategory].commitment_tree; | ||
| }, | ||
| getAltCSCA(docCategory) { | ||
| if (docCategory === 'aadhaar') { | ||
| const publicKeys = | ||
| useProtocolStore.getState().aadhaar.public_keys; | ||
| // Convert string[] to Record<string, string> format expected by AlternativeCSCA | ||
| return publicKeys | ||
| ? Object.fromEntries(publicKeys.map(key => [key, key])) | ||
| : {}; | ||
| } | ||
| ); | ||
| if (successDocuments.length === 0) { | ||
| handleRestoreFailed('all_documents_not_registered', false); | ||
| setRestoring(false); | ||
| return false; | ||
| } | ||
| } else { | ||
| const passportDataParsed = JSON.parse(passportData); | ||
|
|
||
| return useProtocolStore.getState()[docCategory] | ||
| .alternative_csca; | ||
| const { isRegistered, csca } = | ||
| await isUserRegisteredWithAlternativeCSCA( | ||
| passportDataParsed, | ||
| secret as string, | ||
| { | ||
| getCommitmentTree(docCategory) { | ||
| return useProtocolStore.getState()[docCategory] | ||
| .commitment_tree; | ||
| }, | ||
| getAltCSCA(docCategory) { | ||
| if (docCategory === 'aadhaar') { | ||
| const publicKeys = | ||
| useProtocolStore.getState().aadhaar.public_keys; | ||
| // Convert string[] to Record<string, string> format expected by AlternativeCSCA | ||
| return publicKeys | ||
| ? Object.fromEntries(publicKeys.map(key => [key, key])) | ||
| : {}; | ||
| } | ||
|
|
||
| return useProtocolStore.getState()[docCategory] | ||
| .alternative_csca; | ||
| }, | ||
| }, | ||
| }, | ||
| ); | ||
| if (!isRegistered) { | ||
| console.warn( | ||
| 'Secret provided did not match a registered ID. Please try again.', | ||
| ); | ||
| trackEvent( | ||
| BackupEvents.CLOUD_RESTORE_FAILED_PASSPORT_NOT_REGISTERED, | ||
| { | ||
| reason: 'document_not_registered', | ||
| hasCSCA: !!csca, | ||
| }, | ||
| ); | ||
| if (!isRegistered) { | ||
| console.warn( | ||
| 'Secret provided did not match a registered ID. Please try again.', | ||
| ); | ||
| handleRestoreFailed('document_not_registered', !!csca); | ||
| setRestoring(false); | ||
| return false; | ||
| } | ||
| if (isCloudRestore && !cloudBackupEnabled) { | ||
| toggleCloudBackupEnabled(); | ||
| } | ||
| await reStorePassportDataWithRightCSCA( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloud backup toggle is skipped for “restore all documents” cloud restores
In restoreAccountFlow, the isCloudRestore && !cloudBackupEnabled toggle only runs in the single-document branch:
if (restoreAllDocuments) {
const successDocuments = await restoreSecretForAllDocuments(...);
if (successDocuments.length === 0) {
handleRestoreFailed(...);
setRestoring(false);
return false;
}
} else {
// ...
if (isCloudRestore && !cloudBackupEnabled) {
toggleCloudBackupEnabled();
}
await reStorePassportDataWithRightCSCA(...);
await markCurrentDocumentAsRegistered(selfClient);
}When restoreAllDocuments === true and the user comes via the cloud-restore path (isCloudRestore === true), a successful restore never enables cloudBackupEnabled. That’s a reliability issue: users who just recovered from cloud backup on the “restore all documents” path will silently remain without backup enabled.
You can restore the original “enable backup whenever a cloud restore succeeds” behavior (for both single-doc and all-doc flows) by moving the toggle to after the branch, just before logging success:
- if (isCloudRestore && !cloudBackupEnabled) {
- toggleCloudBackupEnabled();
- }
- await reStorePassportDataWithRightCSCA(
+ await reStorePassportDataWithRightCSCA(
passportDataParsed,
csca as string,
);
await markCurrentDocumentAsRegistered(selfClient);
}
-
- trackEvent(BackupEvents.CLOUD_RESTORE_SUCCESS);
+ if (isCloudRestore && !cloudBackupEnabled) {
+ toggleCloudBackupEnabled();
+ }
+
+ trackEvent(BackupEvents.CLOUD_RESTORE_SUCCESS);This keeps the early-return failure paths unchanged while ensuring any successful cloud-based restore (single doc or all docs) leaves the account with cloud backup correctly enabled.
Also applies to: 183-187, 198-209
🤖 Prompt for AI Agents
In app/src/screens/account/recovery/AccountRecoveryChoiceScreen.tsx around lines
128-176 (and also consider related sections at 183-187 and 198-209), the
cloud-backup toggle runs only in the single-document branch so successful cloud
restores that use the "restore all documents" path never enable cloud backup;
move the isCloudRestore && !cloudBackupEnabled check out of the else branch and
instead perform it once after the if/else completes successfully (i.e., after
the early-return failure checks for restoreAllDocuments and after the single-doc
registration check) so that for both the all-docs and single-doc successful
flows you call toggleCloudBackupEnabled() when needed while leaving all existing
early returns unchanged.
Summary by CodeRabbit
New Features
Navigation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.