@trustchex/react-native-sdk 1.464.0 → 1.475.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +190 -12
  3. package/ios/Camera/TrustchexCameraView.swift +244 -46
  4. package/ios/Permission/PermissionModule.m +22 -0
  5. package/ios/Permission/PermissionModule.swift +67 -0
  6. package/lib/module/Screens/Debug/MRZTestScreen.js +121 -147
  7. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +24 -3
  8. package/lib/module/Screens/Dynamic/VerbalConsentScreen.js +1 -1
  9. package/lib/module/Screens/Dynamic/VideoCallScreen.js +7 -12
  10. package/lib/module/Screens/Static/ResultScreen.js +9 -1
  11. package/lib/module/Shared/Components/EIDScanner.js +166 -163
  12. package/lib/module/Shared/Components/FaceCamera.js +14 -8
  13. package/lib/module/Shared/Components/IdentityDocumentCamera.js +45 -10
  14. package/lib/module/Shared/Libs/MRZ_KNOWN_ISSUES.md +112 -0
  15. package/lib/module/Shared/Libs/PERMISSIONS_MANAGER.md +268 -0
  16. package/lib/module/Shared/Libs/index.js +20 -0
  17. package/lib/module/Shared/Libs/mrz.utils.js +570 -16
  18. package/lib/module/Shared/Libs/mrzFrameAggregator.js +301 -0
  19. package/lib/module/Shared/Libs/mrzOcrIntegration.js +109 -0
  20. package/lib/module/Shared/Libs/permissions.utils.js +199 -0
  21. package/lib/module/Translation/Resources/en.js +1 -0
  22. package/lib/module/Translation/Resources/tr.js +1 -0
  23. package/lib/module/version.js +1 -1
  24. package/lib/typescript/src/Screens/Debug/MRZTestScreen.d.ts.map +1 -1
  25. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  26. package/lib/typescript/src/Screens/Dynamic/VideoCallScreen.d.ts.map +1 -1
  27. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  28. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  29. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  30. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  31. package/lib/typescript/src/Shared/Libs/index.d.ts +20 -0
  32. package/lib/typescript/src/Shared/Libs/index.d.ts.map +1 -0
  33. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +8 -0
  34. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
  35. package/lib/typescript/src/Shared/Libs/mrzFrameAggregator.d.ts +76 -0
  36. package/lib/typescript/src/Shared/Libs/mrzFrameAggregator.d.ts.map +1 -0
  37. package/lib/typescript/src/Shared/Libs/mrzOcrIntegration.d.ts +73 -0
  38. package/lib/typescript/src/Shared/Libs/mrzOcrIntegration.d.ts.map +1 -0
  39. package/lib/typescript/src/Shared/Libs/permissions.utils.d.ts +58 -0
  40. package/lib/typescript/src/Shared/Libs/permissions.utils.d.ts.map +1 -0
  41. package/lib/typescript/src/Translation/Resources/en.d.ts +1 -0
  42. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
  43. package/lib/typescript/src/Translation/Resources/tr.d.ts +1 -0
  44. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  45. package/lib/typescript/src/version.d.ts +1 -1
  46. package/package.json +14 -10
  47. package/src/Screens/Debug/MRZTestScreen.tsx +137 -166
  48. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +45 -5
  49. package/src/Screens/Dynamic/VerbalConsentScreen.tsx +1 -1
  50. package/src/Screens/Dynamic/VideoCallScreen.tsx +8 -19
  51. package/src/Screens/Static/ResultScreen.tsx +18 -9
  52. package/src/Shared/Components/EIDScanner.tsx +210 -160
  53. package/src/Shared/Components/FaceCamera.tsx +19 -16
  54. package/src/Shared/Components/IdentityDocumentCamera.tsx +53 -13
  55. package/src/Shared/Libs/MRZ_KNOWN_ISSUES.md +112 -0
  56. package/src/Shared/Libs/PERMISSIONS_MANAGER.md +268 -0
  57. package/src/Shared/Libs/index.ts +63 -0
  58. package/src/Shared/Libs/mrz.utils.ts +639 -11
  59. package/src/Shared/Libs/mrzFrameAggregator.ts +370 -0
  60. package/src/Shared/Libs/mrzOcrIntegration.ts +175 -0
  61. package/src/Shared/Libs/permissions.utils.ts +251 -0
  62. package/src/Translation/Resources/en.ts +1 -0
  63. package/src/Translation/Resources/tr.ts +1 -0
  64. package/src/version.ts +1 -1
@@ -0,0 +1,268 @@
1
+ # PermissionManager Documentation
2
+
3
+ ## Overview
4
+
5
+ `PermissionManager` is a centralized utility for handling all platform-specific permission requests (camera, microphone, NFC, etc.) in the React Native SDK. It abstracts away platform differences (iOS vs Android) and provides a clean, consistent API.
6
+
7
+ ## Location
8
+
9
+ - **File**: `src/Shared/Libs/permissions.utils.ts`
10
+ - **Export**: Can be imported from `src/Shared/Libs/index.ts`
11
+
12
+ ## Supported Permissions
13
+
14
+ ```typescript
15
+ type PermissionType = 'camera' | 'microphone' | 'nfc';
16
+ ```
17
+
18
+ | Permission | iOS | Android | Notes |
19
+ | ------------ | --- | ------- | ---------------------------------------- |
20
+ | `camera` | ✅ | ✅ | Camera access for video recording |
21
+ | `microphone` | ✅ | ✅ | Microphone access for audio recording |
22
+ | `nfc` | ✅ | ✅ | NFC chip reading (document verification) |
23
+
24
+ ## API Reference
25
+
26
+ ### Request Methods
27
+
28
+ #### `requestPermission(permission: PermissionType): Promise<boolean>`
29
+
30
+ Request a single permission. Returns `true` if granted, `false` if denied.
31
+
32
+ ```typescript
33
+ import PermissionManager from '../../Shared/Libs/permissions.utils';
34
+
35
+ const hasCamera = await PermissionManager.requestPermission('camera');
36
+ if (!hasCamera) {
37
+ console.log('Camera permission denied');
38
+ }
39
+ ```
40
+
41
+ #### `requestPermissions(permissions: PermissionType[]): Promise<Map<PermissionType, boolean>>`
42
+
43
+ Request multiple permissions at once. Returns a Map with permission status for each.
44
+
45
+ ```typescript
46
+ const results = await PermissionManager.requestPermissions([
47
+ 'camera',
48
+ 'microphone',
49
+ ]);
50
+ const hasCamera = results.get('camera') ?? false;
51
+ const hasMicrophone = results.get('microphone') ?? false;
52
+ ```
53
+
54
+ #### `requestCameraAndMicrophone(): Promise<boolean>`
55
+
56
+ **⭐ Convenience method** — Request camera and microphone together (common for video recording). Returns `true` only if BOTH are granted.
57
+
58
+ ```typescript
59
+ const hasBothPermissions = await PermissionManager.requestCameraAndMicrophone();
60
+ if (!hasBothPermissions) {
61
+ showError('Camera and microphone access required for video call');
62
+ }
63
+ ```
64
+
65
+ #### `requestCamera(): Promise<boolean>`
66
+
67
+ Request camera permission only.
68
+
69
+ ```typescript
70
+ const hasCamera = await PermissionManager.requestCamera();
71
+ ```
72
+
73
+ #### `requestMicrophone(): Promise<boolean>`
74
+
75
+ Request microphone permission only.
76
+
77
+ ```typescript
78
+ const hasMicrophone = await PermissionManager.requestMicrophone();
79
+ ```
80
+
81
+ #### `requestNFC(): Promise<boolean>`
82
+
83
+ Request NFC permission for document verification.
84
+
85
+ ```typescript
86
+ const hasNFC = await PermissionManager.requestNFC();
87
+ ```
88
+
89
+ #### `requestWithFallback(permission: PermissionType, onDenied?: () => void): Promise<boolean>`
90
+
91
+ Request permission with custom callback when denied.
92
+
93
+ ```typescript
94
+ const granted = await PermissionManager.requestWithFallback('camera', () => {
95
+ showAlert('Camera access is required for verification');
96
+ });
97
+ ```
98
+
99
+ ### Check Methods (Non-requesting)
100
+
101
+ Check if a permission is already granted without requesting.
102
+
103
+ #### `checkPermission(permission: PermissionType): Promise<boolean>`
104
+
105
+ Check a single permission status.
106
+
107
+ ```typescript
108
+ const hasCamera = await PermissionManager.checkPermission('camera');
109
+ ```
110
+
111
+ #### `hasCameraAndMicrophone(): Promise<boolean>`
112
+
113
+ Check if both camera and microphone are granted.
114
+
115
+ ```typescript
116
+ const ready = await PermissionManager.hasCameraAndMicrophone();
117
+ ```
118
+
119
+ #### `hasCamera(): Promise<boolean>`
120
+
121
+ Check if camera is granted.
122
+
123
+ ```typescript
124
+ const hasCamera = await PermissionManager.hasCamera();
125
+ ```
126
+
127
+ #### `hasMicrophone(): Promise<boolean>`
128
+
129
+ Check if microphone is granted.
130
+
131
+ ```typescript
132
+ const hasMicrophone = await PermissionManager.hasMicrophone();
133
+ ```
134
+
135
+ #### `hasNFC(): Promise<boolean>`
136
+
137
+ Check if NFC is granted.
138
+
139
+ ```typescript
140
+ const hasNFC = await PermissionManager.hasNFC();
141
+ ```
142
+
143
+ ## Common Patterns
144
+
145
+ ### Pattern 1: Video Call Setup (Camera + Microphone)
146
+
147
+ ```typescript
148
+ import PermissionManager from '../../Shared/Libs/permissions.utils';
149
+
150
+ async function initializeVideoCall() {
151
+ const hasBothPermissions =
152
+ await PermissionManager.requestCameraAndMicrophone();
153
+
154
+ if (!hasBothPermissions) {
155
+ setConnectionState('permissions_denied');
156
+ return;
157
+ }
158
+
159
+ // Proceed with video call initialization
160
+ const stream = await service.initialize();
161
+ setLocalStream(stream);
162
+ }
163
+ ```
164
+
165
+ ### Pattern 2: Document Verification (NFC)
166
+
167
+ ```typescript
168
+ const hasNFC = await PermissionManager.requestNFC();
169
+
170
+ if (!hasNFC) {
171
+ showError('NFC access required to read document');
172
+ return;
173
+ }
174
+
175
+ const result = await readNFCChip();
176
+ ```
177
+
178
+ ### Pattern 3: Check Before Requesting
179
+
180
+ ```typescript
181
+ // First check if permission is already granted
182
+ const alreadyHasCamera = await PermissionManager.checkPermission('camera');
183
+
184
+ if (alreadyHasCamera) {
185
+ // Skip request dialog
186
+ startCamera();
187
+ } else {
188
+ // Request permission (shows OS dialog)
189
+ const granted = await PermissionManager.requestCamera();
190
+ if (granted) {
191
+ startCamera();
192
+ } else {
193
+ showErrorMessage('Camera access required');
194
+ }
195
+ }
196
+ ```
197
+
198
+ ## Platform Implementation Details
199
+
200
+ ### iOS
201
+
202
+ Uses the `react-native-permissions` library with `RNPermissions` module.
203
+
204
+ **Permissions layout location**: `ios/App.xcodeproj/Info.plist`
205
+
206
+ Required Info.plist keys:
207
+
208
+ - `NSCameraUsageDescription` — Camera access explanation
209
+ - `NSMicrophoneUsageDescription` — Microphone access explanation
210
+ - `NFCReaderUsageDescription` — NFC access explanation
211
+
212
+ ### Android
213
+
214
+ Uses built-in `PermissionsAndroid` from React Native core.
215
+
216
+ **Permissions manifest location**: `android/app/src/main/AndroidManifest.xml`
217
+
218
+ Required manifest permissions:
219
+
220
+ - `android.permission.CAMERA` — Camera access
221
+ - `android.permission.RECORD_AUDIO` — Microphone access
222
+ - `android.permission.NFC` — NFC chip reading
223
+
224
+ ## Error Handling
225
+
226
+ The PermissionManager handles errors internally and logs them using the debug utility. All methods return clear boolean or Map results so you can check status directly:
227
+
228
+ ```typescript
229
+ const granted = await PermissionManager.requestCamera();
230
+
231
+ // Simple check
232
+ if (!granted) {
233
+ // Handle permission denied
234
+ }
235
+ ```
236
+
237
+ ## Best Practices
238
+
239
+ 1. ✅ **Use convenience methods** — `requestCameraAndMicrophone()` instead of manually requesting both
240
+ 2. ✅ **Request at the right time** — Request permissions when the feature is about to be used
241
+ 3. ✅ **Check before requesting** — Use `checkPermission()` if you want to skip the OS dialog
242
+ 4. ✅ **Handle denial gracefully** — Always provide clear error messages when permissions are denied
243
+ 5. ✅ **Use the centralized manager** — Never import React Native permissions directly; always use PermissionManager
244
+
245
+ ## Troubleshooting
246
+
247
+ ### Permission request dialog not appearing
248
+
249
+ - Check that you're using `request*` methods, not `check*` methods
250
+ - Verify the permission is in the app's manifest (Android) or Info.plist (iOS)
251
+ - Test on a device where the permission hasn't been granted yet
252
+
253
+ ### Camera/Microphone not working after permission granted
254
+
255
+ - Check that you're handling successful permission grant and initializing the feature
256
+ - Verify other features aren't holding exclusive access to the device
257
+
258
+ ### NFC not working on iOS
259
+
260
+ - Ensure `NFCReaderUsageDescription` is set in Info.plist
261
+ - The app must be signed with proper entitlements for NFC
262
+ - NFC requires iPhone XS or later
263
+
264
+ ## Related Files
265
+
266
+ - `src/Screens/Dynamic/VideoCallScreen.tsx` — Example usage with video calls
267
+ - `src/Shared/Libs/index.ts` — Exported for easy importing
268
+ - `src/Shared/Libs/debug.utils.ts` — Used internally for debug logging
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ // Export utility modules with validated symbols only.
4
+ export { default as PermissionManager } from "./permissions.utils.js";
5
+ export { SignalingClient } from "./SignalingClient.js";
6
+ export { setDebugMode, setLogLevel, isDebugEnabled, getLogLevel, traceLog, debugLog, infoLog, debugWarn, debugError, logError, logWarn } from "./debug.utils.js";
7
+ export { default as HTTPClient, HttpClientError, UnauthorizedError, ForbiddenError, NotFoundError, BadRequestError, TooManyRequestsError, InternalServerError } from "./http-client.js";
8
+ export * from "./analytics.utils.js";
9
+ export { getLocalizedCountryName } from "./country-display.utils.js";
10
+ export { getSessionKey, encryptWithAes, decryptWithAes } from "./crypto.utils.js";
11
+ export { default as debounce } from "./debounce.utils.js";
12
+ export { handleDeepLink } from "./deeplink.utils.js";
13
+ export { getSimulatedDemoData, isDemoSession } from "./demo.utils.js";
14
+ export { default as MRZUtils } from "./mrz.utils.js";
15
+ export { NativeDeviceInfo } from "./native-device-info.utils.js";
16
+ export { default as getDeviceInfo } from "./native-device-info.utils.js";
17
+ export { useKeepAwake, enableKeepAwake, disableKeepAwake, isKeepAwakeCurrentlyActive, getKeepAwakeStats } from "./native-keep-awake.utils.js";
18
+ export { runWithRetry } from "./promise.utils.js";
19
+ export { configureStatusBarForWhiteBackground, useStatusBarWhiteBackground } from "./status-bar.utils.js";
20
+ export { speak, speakWithDebounce, stopSpeaking, resetLastMessage, initializeTTS } from "./tts.utils.js";