How inji/inji-wallet works
1. Repository shape
This is a React Native mobile wallet named Inji, with a shared TypeScript app layer plus native Android/iOS modules. The main product is the wallet app in the repo root; sample-application/ is a separate Android demo app that exercises wallet capabilities from an external relying-party perspective.
2. App shell and navigation
The user-facing app is started from index.js and App.tsx, then organized into route/layout modules under routes/ and screens/. screens/AppController.ts, screens/AppLayout.tsx, and the screen-specific controllers act as the app’s composition layer, deciding which flows are visible and wiring state into UI.
3. Screen architecture
The UI is split into feature screens such as home, issuers, QR login, scan/share, settings, backup/restore, passcode, and identity verification. Most screens follow a Controller + View pattern: the controller manages state and side effects, while the view component renders the interaction. This separation is consistent across screens/Home, screens/Scan, screens/QrLogin, screens/Settings, and screens/Request.
4. State management boundary
Business flow orchestration lives in the machines/ directory. These are XState-style finite state machines for app bootstrap, auth, issuers, VC lifecycle, QR login, BLE sharing, backup/restore, biometrics, settings, and PIN input. This is the main boundary for asynchronous flow control, retries, guards, and derived selectors, while screens mostly consume machine state.
5. Credential domain model
Verifiable Credential handling is centralized in shared/vcVerifier, shared/vcRenderer, shared/vcjs, shared/openId4VCI, and the machines/VerifiableCredential/ subtree. These layers are responsible for parsing, rendering, validating, and formatting credential data, plus supporting issuer metadata and credential-type specific UI in components/VC/.
6. Issuance and download flow
Credential issuance is split across the OpenID4VCI-related shared code and the issuer machines/screens. The app fetches issuer configuration, selects credential types, handles OTP/code-based steps, and downloads credentials into the wallet. Native modules under Android/iOS expose pieces of the issuer/client bridge used by the issuance flow.
7. Presentation and login flow
Relying-party login and credential presentation are handled by the OpenID4VP stack in shared/openID4VP/, machines/openID4VP/, and the QR login screens. The app can produce and send verifiable presentations for authentication, while the QR login flow coordinates consent, wallet binding, and success messaging.
8. Offline and proximity sharing
The wallet supports offline/off-device sharing via QR and Bluetooth LE. QR-based sharing is implemented through scan/request screens and the machines/bleShare and machines/QrLogin/machines/openID4VP pathways. BLE sharing has separate request and scan state machines, with native support exposed in Android/iOS modules.
9. Security and local secrets
Sensitive operations are isolated in shared/keystore, shared/cryptoutil, and native keystore modules (RNSecureKeystoreModule on both platforms). Biometrics and passcode flows are modeled separately in machines/biometrics.ts, machines/pinInput.ts, and their corresponding screens. This boundary protects key material, wallet binding state, and encrypted backups.
10. Backup and restore
Backup/restore is a major subsystem spanning machines/backupAndRestore/, shared/backupUtils/, shared/CloudBackupAndRestoreUtils.ts, and settings screens. It includes account selection, encryption, encrypted export/import, and cloud-related credential restore setup. The README’s Google client ID environment variable is specifically tied to this flow.
11. Native bridge layer
The app relies on custom native code under android/app/src/main/java/io/mosip/residentapp/ and ios/. These modules expose wallet, VC rendering, OpenID4VP, secure keystore, deep linking, versioning, and BLE-related functionality to JavaScript. The bridge is a real architectural boundary: crypto, device capabilities, and some protocol operations are executed natively rather than in JS.
12. Shared utility and infrastructure layer
Common app-wide concerns live in shared/: API wrappers, storage, file storage, telemetry, localization hooks, error types, request helpers, and shared constants. This is the glue layer used by both machines and screens, keeping protocol logic and device integration out of UI components.
13. UI component library
The components/ and components/ui/ directories provide reusable controls such as modals, buttons, overlays, scanners, banners, toast items, typography, and VC cards. These are presentation-only pieces; they generally receive state from screens or controllers and do not own business logic.
14. Asset, localization, and theme inputs
Assets are bundled in assets/ and localized strings in locales/. Theme variants are in components/ui/themes/, and the app can switch themes via environment/config. This means the diagram should show a separate content/config layer feeding the UI, not part of the core business pipeline.
15. Testing and build/deploy boundaries
The repository is heavily tested with Jest and many component/machine tests plus mocks in __mocks__/. Build and release are split across Expo/RN tooling, Android Gradle/Fastlane, iOS Xcode/Pods/Fastlane, and GitHub Actions workflows. The sample-application/ directory is a separate Android consumer app, useful to diagram as an external integration example rather than part of the wallet runtime.
16. High-level data flow to capture
A useful architecture diagram should show: user interaction enters via screens; controllers delegate to state machines; machines call shared services/utilities; shared services talk to storage, network, telemetry, or native modules; native modules access device security/capabilities; results flow back into machines and then UI. The key external dependencies are issuer/relying-party backend services, telemetry endpoints, and device-local secure storage/biometrics.
Main entry points: AppController.ts App control · index.ts UI kit · OpenID4VP.ts OpenID stacks · InjiPackage.java Android bridge
Components 31
App shell
React Native entrypoint, routing, and screen composition.
- Entry · Bootstraps the app runtime.
index.js - App · Top-level app component and provider setup.
App.tsx - Routes · Route definitions and route constants.
routes/index.ts - App control · Composes app-level screens and flow selection.
screens/AppController.ts - App layout · Root visual layout for the app.
screens/AppLayout.tsx
UI layer
Screens and reusable presentation components.
- Home flow · Wallet home, onboarding, and VC management screens.
screens/Home/HomeScreen.tsx - Issuer flow · Issuer browsing, credential type selection, and issuance steps.
screens/Issuers/IssuersScreen.tsx - Scan share · QR and VP sharing screens for scan and send flows.
screens/Scan/ScanScreen.tsx - QR login · Relying-party login and consent screens.
screens/QrLogin/QrLogin.tsx - Request flow · Receive and request credential screens.
screens/Request/RequestScreen.tsx - Settings · App settings, key management, and backup/restore entry points.
screens/Settings/SettingScreen.tsx - UI kit · Reusable controls, overlays, and VC presentation components.
components/ui/index.ts
State machines
XState-style orchestration and flow control.
- App machine · Global app bootstrap and session coordination.
machines/app.ts - Auth machine · Authentication and authorization orchestration.
machines/auth.ts - VC machines · Credential lifecycle and VC item/meta management.
machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.ts - Issuer machine · Issuer discovery and credential issuance flow control.
machines/Issuers/IssuersMachine.ts - OpenID4VP · Login and presentation protocol orchestration.
machines/openID4VP/openID4VPMachine.ts - BLE share · QR/BLE sharing request and scan coordination.
machines/bleShare/scan/scanMachine.ts - Backup flow · Backup, restore, and setup orchestration.
machines/backupAndRestore/backup/backupMachine.ts - Security · Biometrics and PIN/passcode gates.
machines/biometrics.ts
Shared logic
Protocol, storage, crypto, and domain utilities.
- Shared core · API, storage, file, request, and common helpers.
shared/api.ts - Crypto · Key handling, encryption, and cryptographic formatting.
shared/cryptoutil/cryptoUtil.ts - VC domain · VC verification, rendering, formatting, and presentation helpers.
shared/vcVerifier/VcVerifier.ts - OpenID stacks · OpenID4VP, OpenID4VCI, and BLE protocol helpers.
shared/openID4VP/OpenID4VP.ts - Backup utils · Backup and restore data transformation helpers.
shared/backupUtils/backupData.ts
Native bridge
Android/iOS modules and platform-specific implementations.
- Android bridge · Android React Native modules for wallet, VC, keystore, and protocol bridges.
android/app/src/main/java/io/mosip/residentapp/InjiPackage.java - iOS bridge · iOS bridge, wallet, VC, keystore, and protocol modules.
ios/Inji/RNWalletModule.swift
Sample app
Separate Android consumer app demonstrating wallet integration.
- Sample app · Separate Android demo wallet consumer and integration example.
sample-application/sample-application/app/src/main/java/com/example/samplecredentialwallet/MainActivity.kt
Connections 37
- Entry → App: boots · Entry file mounts the root React component.
- App → Routes: navigates · App wires navigation and route selection.
- App → App control: composes · Root component feeds app controller composition.
- App control → App layout: renders · Controller selects the root layout.
- App control → Home flow: shows · Routes user into wallet home and VC flows.
- App control → Settings: shows · Routes user into settings and account flows.
- App control → Scan share: shows · Routes user into scan/share flows.
- App control → QR login: shows · Routes user into login/consent flows.
- App control → Issuer flow: shows · Routes user into issuance flows.
- App control → Request flow: shows · Routes user into receive/request flows.
- Home flow → VC machines: consumes · Home and VC subflows read credential state.
- Issuer flow → Issuer machine: driven by · Issuer screens are driven by issuance state.
- QR login → OpenID4VP: driven by · QR login uses presentation/login orchestration.
- Scan share → BLE share: driven by · Scan/share screens use BLE and QR state.
- Request flow → OpenID4VP: driven by · Receive/request flow reuses presentation protocol state.
- Settings → Backup flow: driven by · Backup and restore screens use backup flow machines.
- Settings → Security: gates · Settings exposes biometrics and passcode protections.
- VC machines → VC domain: uses · Credential machines rely on VC parsing and rendering helpers.
- Issuer machine → OpenID stacks: uses · Issuance machine consumes OpenID4VCI helpers.
- OpenID4VP → OpenID stacks: uses · Presentation machine consumes OpenID4VP helpers.
- BLE share → OpenID stacks: uses · BLE share paths share protocol helpers.
- Backup flow → Backup utils: uses · Backup flows transform data through shared backup utilities.
- Security → Crypto: uses · Security flows depend on crypto and key handling.
- Shared core → Android bridge: bridges · Shared helpers call into Android native modules when needed.
- Shared core → iOS bridge: bridges · Shared helpers call into iOS native modules when needed.
- Crypto → Android bridge: secures · Android keystore module backs sensitive operations.
- Crypto → iOS bridge: secures · iOS keystore module backs sensitive operations.
- VC domain → Android bridge: renders via · Credential verification and rendering can delegate to Android modules.
- VC domain → iOS bridge: renders via · Credential verification and rendering can delegate to iOS modules.
- OpenID stacks → Android bridge: calls · Protocol helpers use Android bridge capabilities.
- OpenID stacks → iOS bridge: calls · Protocol helpers use iOS bridge capabilities.
- Home flow → UI kit: uses · Home and VC screens use shared presentation components.
- Settings → UI kit: uses · Settings screens use shared presentation components.
- UI kit → Assets: loads · UI kit renders bundled visual assets.
- UI kit → Locales: localizes · UI kit consumes translated strings.
- UI kit → Themes: themes · UI kit is styled by theme variants.
- Sample app → Android bridge: integrates · Sample Android app exercises the wallet bridge.