@transfergratis/react-native-sdk 0.1.4 → 0.1.5

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 (199) hide show
  1. package/build/api/axios.d.ts +30 -0
  2. package/build/api/axios.d.ts.map +1 -0
  3. package/build/api/axios.js +92 -0
  4. package/build/api/axios.js.map +1 -0
  5. package/build/components/EnhancedCameraView.d.ts +1 -41
  6. package/build/components/EnhancedCameraView.d.ts.map +1 -1
  7. package/build/components/EnhancedCameraView.js +75 -34
  8. package/build/components/EnhancedCameraView.js.map +1 -1
  9. package/build/components/EnhancedCameraView.web.d.ts +1 -41
  10. package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
  11. package/build/components/EnhancedCameraView.web.js +28 -4
  12. package/build/components/EnhancedCameraView.web.js.map +1 -1
  13. package/build/components/KYCElements/CountrySelectionTemplate.d.ts +2 -2
  14. package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
  15. package/build/components/KYCElements/CountrySelectionTemplate.js +71 -114
  16. package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
  17. package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
  18. package/build/components/KYCElements/FileUploadTemplate.js +7 -3
  19. package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
  20. package/build/components/KYCElements/IDCardCapture.d.ts +7 -2
  21. package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  22. package/build/components/KYCElements/IDCardCapture.js +253 -104
  23. package/build/components/KYCElements/IDCardCapture.js.map +1 -1
  24. package/build/components/KYCElements/InitializationStep.d.ts +5 -0
  25. package/build/components/KYCElements/InitializationStep.d.ts.map +1 -0
  26. package/build/components/KYCElements/InitializationStep.js +41 -0
  27. package/build/components/KYCElements/InitializationStep.js.map +1 -0
  28. package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
  29. package/build/components/KYCElements/LocationCaptureTemplate.js +15 -13
  30. package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
  31. package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -2
  32. package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
  33. package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
  34. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -2
  35. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
  36. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
  37. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -2
  38. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
  39. package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
  40. package/build/components/KYCElements/ReviewSubmitTemplate.d.ts +12 -0
  41. package/build/components/KYCElements/ReviewSubmitTemplate.d.ts.map +1 -0
  42. package/build/components/KYCElements/ReviewSubmitTemplate.js +171 -0
  43. package/build/components/KYCElements/ReviewSubmitTemplate.js.map +1 -0
  44. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts +6 -2
  45. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  46. package/build/components/KYCElements/SelfieCaptureTemplate.js +105 -35
  47. package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  48. package/build/components/KYCElements/VerificationProgressTemplate.d.ts +12 -0
  49. package/build/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -0
  50. package/build/components/KYCElements/VerificationProgressTemplate.js +93 -0
  51. package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -0
  52. package/build/components/OverLay/IdCard.d.ts +1 -1
  53. package/build/components/OverLay/IdCard.d.ts.map +1 -1
  54. package/build/components/OverLay/IdCard.js +10 -6
  55. package/build/components/OverLay/IdCard.js.map +1 -1
  56. package/build/components/OverLay/SelfieOverlay.d.ts +1 -1
  57. package/build/components/OverLay/SelfieOverlay.d.ts.map +1 -1
  58. package/build/components/OverLay/SelfieOverlay.js +5 -4
  59. package/build/components/OverLay/SelfieOverlay.js.map +1 -1
  60. package/build/components/OverLay/type.d.ts +71 -1
  61. package/build/components/OverLay/type.d.ts.map +1 -1
  62. package/build/components/OverLay/type.js.map +1 -1
  63. package/build/components/TemplateKYCExample.d.ts.map +1 -1
  64. package/build/components/TemplateKYCExample.js +72 -197
  65. package/build/components/TemplateKYCExample.js.map +1 -1
  66. package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
  67. package/build/components/TemplateKYCFlowRefactored.js +63 -39
  68. package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
  69. package/build/components/example/OrientationVideoExample.d.ts.map +1 -1
  70. package/build/components/example/OrientationVideoExample.js +1 -5
  71. package/build/components/example/OrientationVideoExample.js.map +1 -1
  72. package/build/config/countriesData.d.ts +3 -0
  73. package/build/config/countriesData.d.ts.map +1 -0
  74. package/build/config/countriesData.js +79 -0
  75. package/build/config/countriesData.js.map +1 -0
  76. package/build/config/region_mapping.d.ts +3 -0
  77. package/build/config/region_mapping.d.ts.map +1 -0
  78. package/build/config/region_mapping.js +687 -0
  79. package/build/config/region_mapping.js.map +1 -0
  80. package/build/hooks/useI18n.d.ts +11 -0
  81. package/build/hooks/useI18n.d.ts.map +1 -0
  82. package/build/hooks/useI18n.js +37 -0
  83. package/build/hooks/useI18n.js.map +1 -0
  84. package/build/hooks/useOrientationVideo.d.ts +1 -2
  85. package/build/hooks/useOrientationVideo.d.ts.map +1 -1
  86. package/build/hooks/useOrientationVideo.js +2 -1
  87. package/build/hooks/useOrientationVideo.js.map +1 -1
  88. package/build/hooks/useRealtimeVerifier.d.ts +28 -0
  89. package/build/hooks/useRealtimeVerifier.d.ts.map +1 -0
  90. package/build/hooks/useRealtimeVerifier.js +91 -0
  91. package/build/hooks/useRealtimeVerifier.js.map +1 -0
  92. package/build/hooks/useTemplateKYCFlow.d.ts +1 -0
  93. package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  94. package/build/hooks/useTemplateKYCFlow.js +337 -38
  95. package/build/hooks/useTemplateKYCFlow.js.map +1 -1
  96. package/build/i18n/en/index.d.ts +168 -0
  97. package/build/i18n/en/index.d.ts.map +1 -0
  98. package/build/i18n/en/index.js +195 -0
  99. package/build/i18n/en/index.js.map +1 -0
  100. package/build/i18n/fr/index.d.ts +168 -0
  101. package/build/i18n/fr/index.d.ts.map +1 -0
  102. package/build/i18n/fr/index.js +194 -0
  103. package/build/i18n/fr/index.js.map +1 -0
  104. package/build/i18n/index.d.ts +10 -0
  105. package/build/i18n/index.d.ts.map +1 -0
  106. package/build/i18n/index.js +56 -0
  107. package/build/i18n/index.js.map +1 -0
  108. package/build/i18n/types.d.ts +153 -0
  109. package/build/i18n/types.d.ts.map +1 -0
  110. package/build/i18n/types.js +3 -0
  111. package/build/i18n/types.js.map +1 -0
  112. package/build/i18n/usage-example.d.ts +4 -0
  113. package/build/i18n/usage-example.d.ts.map +1 -0
  114. package/build/i18n/usage-example.js +189 -0
  115. package/build/i18n/usage-example.js.map +1 -0
  116. package/build/modules/api/CardAuthentification.d.ts +22 -0
  117. package/build/modules/api/CardAuthentification.d.ts.map +1 -0
  118. package/build/modules/api/CardAuthentification.js +107 -0
  119. package/build/modules/api/CardAuthentification.js.map +1 -0
  120. package/build/modules/api/KYCService.d.ts +57 -1
  121. package/build/modules/api/KYCService.d.ts.map +1 -1
  122. package/build/modules/api/KYCService.js +348 -27
  123. package/build/modules/api/KYCService.js.map +1 -1
  124. package/build/modules/api/SelfieVerification.d.ts +3 -0
  125. package/build/modules/api/SelfieVerification.d.ts.map +1 -0
  126. package/build/modules/api/SelfieVerification.js +9 -0
  127. package/build/modules/api/SelfieVerification.js.map +1 -0
  128. package/build/modules/api/backendApi.d.ts +2 -0
  129. package/build/modules/api/backendApi.d.ts.map +1 -0
  130. package/build/modules/api/backendApi.js +6 -0
  131. package/build/modules/api/backendApi.js.map +1 -0
  132. package/build/modules/api/types.d.ts +20 -0
  133. package/build/modules/api/types.d.ts.map +1 -0
  134. package/build/modules/api/types.js +2 -0
  135. package/build/modules/api/types.js.map +1 -0
  136. package/build/types/KYC.types.d.ts +59 -7
  137. package/build/types/KYC.types.d.ts.map +1 -1
  138. package/build/types/KYC.types.js +9 -1
  139. package/build/types/KYC.types.js.map +1 -1
  140. package/build/utils/cropByObb.d.ts +11 -0
  141. package/build/utils/cropByObb.d.ts.map +1 -0
  142. package/build/utils/cropByObb.js +78 -0
  143. package/build/utils/cropByObb.js.map +1 -0
  144. package/build/utils/get-document-type-info.d.ts +13 -0
  145. package/build/utils/get-document-type-info.d.ts.map +1 -0
  146. package/build/utils/get-document-type-info.js +59 -0
  147. package/build/utils/get-document-type-info.js.map +1 -0
  148. package/build/utils/pathToBase64.d.ts +3 -0
  149. package/build/utils/pathToBase64.d.ts.map +1 -0
  150. package/build/utils/pathToBase64.js +47 -0
  151. package/build/utils/pathToBase64.js.map +1 -0
  152. package/build/utils/remove-duplicate.d.ts +2 -0
  153. package/build/utils/remove-duplicate.d.ts.map +1 -0
  154. package/build/utils/remove-duplicate.js +4 -0
  155. package/build/utils/remove-duplicate.js.map +1 -0
  156. package/package.json +3 -1
  157. package/src/api/axios.ts +144 -0
  158. package/src/components/EnhancedCameraView.tsx +96 -78
  159. package/src/components/EnhancedCameraView.web.tsx +41 -40
  160. package/src/components/KYCElements/CountrySelectionTemplate.tsx +104 -136
  161. package/src/components/KYCElements/FileUploadTemplate.tsx +14 -8
  162. package/src/components/KYCElements/IDCardCapture.tsx +311 -115
  163. package/src/components/KYCElements/InitializationStep.tsx +53 -0
  164. package/src/components/KYCElements/LocationCaptureTemplate.tsx +17 -15
  165. package/src/components/KYCElements/OrientationVideoCapture.tsx +2 -2
  166. package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +2 -2
  167. package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +2 -2
  168. package/src/components/KYCElements/ReviewSubmitTemplate.tsx +201 -0
  169. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +140 -53
  170. package/src/components/KYCElements/VerificationProgressTemplate.tsx +123 -0
  171. package/src/components/OverLay/IdCard.tsx +17 -9
  172. package/src/components/OverLay/SelfieOverlay.tsx +6 -5
  173. package/src/components/OverLay/type.ts +64 -2
  174. package/src/components/TemplateKYCExample.tsx +76 -197
  175. package/src/components/TemplateKYCFlowRefactored.tsx +74 -46
  176. package/src/components/example/OrientationVideoExample.tsx +3 -7
  177. package/src/config/countriesData.ts +84 -0
  178. package/src/config/region_mapping.ts +688 -0
  179. package/src/hooks/useI18n.ts +53 -0
  180. package/src/hooks/useOrientationVideo.ts +2 -2
  181. package/src/hooks/useRealtimeVerifier.ts +128 -0
  182. package/src/hooks/useTemplateKYCFlow.tsx +375 -53
  183. package/src/i18n/README.md +288 -0
  184. package/src/i18n/en/index.ts +206 -0
  185. package/src/i18n/fr/index.ts +205 -0
  186. package/src/i18n/index.ts +65 -0
  187. package/src/i18n/types.ts +172 -0
  188. package/src/i18n/usage-example.tsx +202 -0
  189. package/src/modules/api/CardAuthentification.ts +114 -0
  190. package/src/modules/api/KYCService.ts +403 -30
  191. package/src/modules/api/SelfieVerification.ts +11 -0
  192. package/src/modules/api/backendApi.ts +8 -0
  193. package/src/modules/api/types.ts +24 -0
  194. package/src/types/KYC.types.ts +83 -14
  195. package/src/utils/cropByObb.ts +99 -0
  196. package/src/utils/get-document-type-info.ts +62 -0
  197. package/src/utils/pathToBase64.ts +47 -0
  198. package/src/utils/remove-duplicate.ts +3 -0
  199. package/src/types/nativewind.d.ts +0 -2
@@ -111,6 +111,8 @@ export type KYCElementType =
111
111
  | 'selfie_capture'
112
112
  | 'verification'
113
113
  | 'completion';
114
+ //KYCElementType shorted
115
+
114
116
 
115
117
  // Configuration d'un élément KYC
116
118
  export interface KYCElement {
@@ -306,7 +308,7 @@ export interface LocalizedText {
306
308
  export interface ComponentUI {
307
309
  icon?: string;
308
310
  themeColor?: string;
309
- buttonText: LocalizedText;
311
+ buttonText: LocalizedText | Record<string, LocalizedText>;
310
312
  backgroundColor?: string;
311
313
  textColor?: string;
312
314
  borderRadius?: number;
@@ -314,16 +316,23 @@ export interface ComponentUI {
314
316
 
315
317
  // Types de documents gouvernementaux supportés
316
318
  export type GovernmentDocumentType =
317
- | 'id_card'
319
+ | 'identity_card'
318
320
  | 'passport'
319
- | 'drivers_license'
320
- | 'residence_permit'
321
+ | 'drivers_licence'
322
+ | 'health_insurance_card'
323
+ | 'permanent_residence'
321
324
  | 'national_id'
322
- | 'voter_id'
323
- | 'military_id'
324
- | 'student_id'
325
325
  | 'work_permit'
326
- | 'other';
326
+
327
+ export const GovernmentDocumentTypeShorted: Record<GovernmentDocumentType, string> = {
328
+ identity_card: 'id',
329
+ passport: 'pp',
330
+ drivers_licence: 'dl',
331
+ health_insurance_card: 'hic',
332
+ permanent_residence: 'pr',
333
+ national_id: 'id',
334
+ work_permit: 'wp',
335
+ }
327
336
 
328
337
  // Configuration spécifique pour chaque type de composant
329
338
  export interface IDCardConfig {
@@ -346,7 +355,7 @@ export interface IDCardConfig {
346
355
  export interface SelfieConfig {
347
356
  liveness_check: boolean;
348
357
  max_attempts: number;
349
- orientations: ('front' | 'left' | 'right')[]; // Tableau d'orientations à capturer
358
+ orientations: ('center' | 'left' | 'right')[]; // Tableau d'orientations à capturer
350
359
  }
351
360
 
352
361
  export interface FileUploadConfig {
@@ -377,12 +386,12 @@ export type ComponentConfig =
377
386
  // Nouveau type de composant basé sur le template JSON
378
387
  export interface TemplateComponent {
379
388
  id: number;
380
- type: 'id_card' | 'selfie' | 'file_upload' | 'location' | 'country_selection';
389
+ type: 'id_card' | 'selfie' | 'file_upload' | 'location' | 'country_selection' | 'initialization' | 'review_submit' | 'verification_progress';
381
390
  order: number;
382
391
  templateId?: number;
383
- labels: LocalizedText;
384
- instructions: LocalizedText;
385
- ui: ComponentUI;
392
+ labels: LocalizedText | Record<string, LocalizedText>;
393
+ instructions: LocalizedText | Record<string, LocalizedText>;
394
+ ui: ComponentUI | Record<string, ComponentUI>;
386
395
  config: ComponentConfig;
387
396
  }
388
397
 
@@ -405,6 +414,29 @@ export interface TemplateState {
405
414
  isProcessing: boolean;
406
415
  currentLanguage: string;
407
416
  showCustomStepper: boolean;
417
+ session: SessionState;
418
+ verification: VerificationState;
419
+ }
420
+
421
+ export interface SessionState {
422
+ session_id: string;
423
+ token: string;
424
+ isInitialized: boolean;
425
+ isProcessing: boolean;
426
+ error: string | null;
427
+ }
428
+
429
+ export type VerificationStatus = 'idle' | 'in_progress' | 'success' | 'failed';
430
+
431
+ export interface VerificationResult {
432
+ referenceId?: string;
433
+ message?: string;
434
+ issues?: string[];
435
+ }
436
+
437
+ export interface VerificationState {
438
+ status: VerificationStatus;
439
+ result?: VerificationResult;
408
440
  }
409
441
 
410
442
  // Actions pour le template KYC
@@ -419,6 +451,7 @@ export interface TemplateActions {
419
451
  resetTemplate: () => void;
420
452
  setLanguage: (language: string) => void;
421
453
  showCustomStepper: (show: boolean) => void;
454
+ setVerificationState: (state: VerificationState) => void;
422
455
  }
423
456
 
424
457
  // Hook pour le template KYC
@@ -431,4 +464,40 @@ export interface UseTemplateReturn {
431
464
  canGoPrevious: boolean;
432
465
  isComplete: boolean;
433
466
  getLocalizedText: (text: LocalizedText) => string;
434
- }
467
+ initializeSession: () => Promise<void>;
468
+ }
469
+
470
+
471
+ export interface ISilentCaptureResult {
472
+ success: boolean;
473
+ path?: string;
474
+ mrz?: string;
475
+ error?: string;
476
+ isAnalyzing?: boolean;
477
+ bbox?: IBbox;
478
+ country?: string;
479
+ documentType?: string;
480
+ }
481
+
482
+ export interface IBbox {
483
+ minX: number;
484
+ minY: number;
485
+ width: number;
486
+ height: number;
487
+ }
488
+
489
+ export interface ICountryMapping {
490
+ py_file?: string;
491
+ front?: string;
492
+ back?: string;
493
+ keys_found?: string | null;
494
+ }
495
+
496
+ export interface Country {
497
+ code?: string; // ISO 3166-1 alpha-2
498
+ name: string;
499
+ name_en: string;
500
+ flag: string;
501
+ regionMapping?: ICountryMapping;
502
+ hasRegions?: boolean;
503
+ }
@@ -0,0 +1,99 @@
1
+ import { Image as RNImage, Platform } from 'react-native';
2
+ import * as ImageManipulator from "expo-image-manipulator";
3
+
4
+ type Point = [number, number];
5
+
6
+ // Compute axis-aligned bounding box from oriented quadrilateral
7
+ function computeAabb(points: Point[]) {
8
+ const xs = points.map(p => p[0]);
9
+ const ys = points.map(p => p[1]);
10
+ const minX = Math.min(...xs);
11
+ const minY = Math.min(...ys);
12
+ const maxX = Math.max(...xs);
13
+ const maxY = Math.max(...ys);
14
+ return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY };
15
+ }
16
+
17
+ // Web-only crop using Canvas; returns dataURL (base64)
18
+ async function cropWeb(uri: string, points: Point[]): Promise<string> {
19
+ return new Promise((resolve, reject) => {
20
+ const img = new Image();
21
+ img.crossOrigin = 'anonymous';
22
+ img.onload = () => {
23
+ const { minX, minY, width, height } = computeAabb(points);
24
+ const canvas = document.createElement('canvas');
25
+ canvas.width = Math.max(1, Math.round(width));
26
+ canvas.height = Math.max(1, Math.round(height));
27
+ const ctx = canvas.getContext('2d');
28
+ if (!ctx) return reject(new Error('Canvas context not available'));
29
+ ctx.drawImage(
30
+ img,
31
+ minX, // sx
32
+ minY, // sy
33
+ width, // sw
34
+ height, // sh
35
+ 0,
36
+ 0,
37
+ canvas.width,
38
+ canvas.height
39
+ );
40
+ resolve(canvas.toDataURL('image/jpeg', 0.92));
41
+ };
42
+ img.onerror = (e) => reject(e);
43
+ img.src = uri;
44
+ });
45
+ }
46
+
47
+ // Fallback: return original for native (no dependency added); caller can still use bbox to draw overlay
48
+ export async function cropByObb(uri: string, cardObb: any): Promise<{ base64?: string; bbox?: { minX: number; minY: number; width: number; height: number } }> {
49
+ try {
50
+ // card_obb format: [ [ [p1,p2,p3,p4], score ] ]
51
+ const first = Array.isArray(cardObb) ? cardObb[0] : null;
52
+ const points = Array.isArray(first?.[0]) ? (first[0] as Point[]) : null;
53
+ if (!points || points.length !== 4) return {};
54
+
55
+ const { minX, minY, width, height } = computeAabb(points);
56
+
57
+ if (Platform.OS === 'web') {
58
+ const base64 = await cropWeb(uri, points);
59
+ return { base64, bbox: { minX, minY, width, height } };
60
+ }
61
+ // Native: return bbox only; keep base64 undefined
62
+ return { bbox: { minX, minY, width, height } };
63
+ } catch (e) {
64
+ return {};
65
+ }
66
+ }
67
+
68
+
69
+
70
+
71
+ // exemple d'appel :
72
+ export async function cropImageWithBBox(uri: string, bbox: any) {
73
+ // 1️⃣ Récupère la taille originale de l'image
74
+ await RNImage.getSize(uri, (width, height) => {
75
+ console.log("Image originale:", width, height);
76
+ });
77
+
78
+ // // 2️⃣ Suppose que ton bbox vient d'une image affichée dans `displayedSize`
79
+ // const scaleX = originalWidth / displayedSize.width;
80
+ // const scaleY = originalHeight / displayedSize.height;
81
+
82
+ // 3️⃣ Convertir le bbox à la taille réelle
83
+ const crop = {
84
+ originX: bbox.minX,
85
+ originY: bbox.minY,
86
+ width: bbox.width,
87
+ height: bbox.height,
88
+ };
89
+
90
+ // 4️⃣ Appliquer le crop
91
+ const result = await ImageManipulator.manipulateAsync(
92
+ uri,
93
+ [{ crop }],
94
+ { compress: 1, format: ImageManipulator.SaveFormat.PNG }
95
+ );
96
+
97
+ console.log("Image recadrée:", result.uri);
98
+ return result.uri;
99
+ }
@@ -0,0 +1,62 @@
1
+ import { GovernmentDocumentType } from "../types/KYC.types";
2
+
3
+ export const getDocumentTypeInfo = (docType: GovernmentDocumentType) => {
4
+ switch (docType) {
5
+ case 'identity_card':
6
+ return {
7
+ name: { en: 'ID Card', fr: 'Carte d\'identité' },
8
+ icon: '🆔',
9
+ instructions: { en: 'Position your ID card within the frame', fr: 'Positionnez votre carte d\'identité dans le cadre' }
10
+ };
11
+ case 'passport':
12
+ return {
13
+ name: { en: 'Passport', fr: 'Passeport' },
14
+ icon: '📘',
15
+ instructions: { en: 'Position your passport within the frame', fr: 'Positionnez votre passeport dans le cadre' }
16
+ };
17
+ case 'drivers_licence':
18
+ return {
19
+ name: { en: 'Driver\'s License', fr: 'Permis de conduire' },
20
+ icon: '🚗',
21
+ instructions: { en: 'Position your driver\'s license within the frame', fr: 'Positionnez votre permis de conduire dans le cadre' }
22
+ };
23
+ case 'permanent_residence':
24
+ return {
25
+ name: { en: 'Residence Permit', fr: 'Permis de séjour' },
26
+ icon: '🏠',
27
+ instructions: { en: 'Position your residence permit within the frame', fr: 'Positionnez votre permis de séjour dans le cadre' }
28
+ };
29
+ case 'national_id':
30
+ return {
31
+ name: { en: 'National ID', fr: 'Carte nationale d\'identité' },
32
+ icon: '🏛️',
33
+ instructions: { en: 'Position your national ID within the frame', fr: 'Positionnez votre carte nationale d\'identité dans le cadre' }
34
+ };
35
+ case 'health_insurance_card':
36
+ return {
37
+ name: { en: 'Health Insurance Card', fr: 'Carte d\'assurance santé' },
38
+ icon: '🗳️',
39
+ instructions: { en: 'Position your health insurance card within the frame', fr: 'Positionnez votre carte d\'assurance santé dans le cadre' }
40
+ };
41
+ case 'work_permit':
42
+ return {
43
+ name: { en: 'Work Permit', fr: 'Permis de travail' },
44
+ icon: '🎖️',
45
+ instructions: { en: 'Position your work permit within the frame', fr: 'Positionnez votre permis de travail dans le cadre' }
46
+ };
47
+
48
+ case 'passport':
49
+ return {
50
+ name: { en: 'Passport', fr: 'Passeport' },
51
+ icon: '💼',
52
+ instructions: { en: 'Position your passport within the frame', fr: 'Positionnez votre passeport dans le cadre' }
53
+ };
54
+
55
+ default:
56
+ return {
57
+ name: { en: 'Government Document', fr: 'Document gouvernemental' },
58
+ icon: '📄',
59
+ instructions: { en: 'Position your document within the frame', fr: 'Positionnez votre document dans le cadre' }
60
+ };
61
+ }
62
+ };
@@ -0,0 +1,47 @@
1
+ export async function pathToBase64(uri: string): Promise<string> {
2
+ if (!uri) throw new Error('pathToBase64: uri is required');
3
+
4
+ // If already a data URI, return the base64 part
5
+ if (uri.startsWith('data:')) {
6
+ const commaIndex = uri.indexOf(',');
7
+ return commaIndex !== -1 ? uri.substring(commaIndex + 1) : uri;
8
+ }
9
+
10
+ // Try Expo FileSystem if available (React Native + Expo)
11
+ try {
12
+ // Dynamically import to avoid hard dependency when not available
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ const FileSystem = require('expo-file-system');
15
+ if (FileSystem?.readAsStringAsync) {
16
+ const base64 = await FileSystem.readAsStringAsync(uri, { encoding: FileSystem.EncodingType.Base64 });
17
+ if (base64) return base64;
18
+ }
19
+ } catch (_) {
20
+ // ignore - fall back to other strategies
21
+ }
22
+
23
+ // Generic fetch + FileReader strategy (works on web; often works on RN for file:// URIs)
24
+ try {
25
+ const response = await fetch(uri);
26
+ const blob = await response.blob();
27
+ const dataUrl = await new Promise<string>((resolve, reject) => {
28
+ const reader = new FileReader();
29
+ reader.onloadend = () => {
30
+ if (typeof reader.result === 'string') resolve(reader.result);
31
+ else reject(new Error('Failed to convert blob to data URL'));
32
+ };
33
+ reader.onerror = reject;
34
+ reader.readAsDataURL(blob);
35
+ });
36
+ const commaIndex = dataUrl.indexOf(',');
37
+ return commaIndex !== -1 ? dataUrl.substring(commaIndex + 1) : dataUrl;
38
+ } catch (err) {
39
+ // continue to final error
40
+ }
41
+
42
+ throw new Error('pathToBase64: unable to convert uri to base64');
43
+ }
44
+
45
+ export default pathToBase64;
46
+
47
+
@@ -0,0 +1,3 @@
1
+ export function removeDuplicates(arr: string[]): string[] {
2
+ return [...new Set(arr)];
3
+ }
@@ -1,2 +0,0 @@
1
- /// <reference types="nativewind/types" />
2
-