@transfergratis/react-native-sdk 0.1.13 → 0.1.15

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 (38) hide show
  1. package/android/build.gradle +1 -1
  2. package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  3. package/build/components/KYCElements/IDCardCapture.js +2 -18
  4. package/build/components/KYCElements/IDCardCapture.js.map +1 -1
  5. package/build/components/KYCElements/VerificationProgressTemplate.js +1 -1
  6. package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -1
  7. package/build/components/TemplateKYCExample.js +0 -64
  8. package/build/components/TemplateKYCExample.js.map +1 -1
  9. package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  10. package/build/hooks/useTemplateKYCFlow.js +6 -12
  11. package/build/hooks/useTemplateKYCFlow.js.map +1 -1
  12. package/build/i18n/en/index.d.ts +1 -0
  13. package/build/i18n/en/index.d.ts.map +1 -1
  14. package/build/i18n/en/index.js +2 -1
  15. package/build/i18n/en/index.js.map +1 -1
  16. package/build/i18n/fr/index.d.ts +1 -0
  17. package/build/i18n/fr/index.d.ts.map +1 -1
  18. package/build/i18n/fr/index.js +2 -1
  19. package/build/i18n/fr/index.js.map +1 -1
  20. package/build/i18n/types.d.ts +1 -0
  21. package/build/i18n/types.d.ts.map +1 -1
  22. package/build/i18n/types.js.map +1 -1
  23. package/build/modules/camera/VisionCameraModule.d.ts.map +1 -1
  24. package/build/modules/camera/VisionCameraModule.js +74 -6
  25. package/build/modules/camera/VisionCameraModule.js.map +1 -1
  26. package/build/utils/pathToBase64.d.ts.map +1 -1
  27. package/build/utils/pathToBase64.js +8 -6
  28. package/build/utils/pathToBase64.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/components/KYCElements/IDCardCapture.tsx +2 -19
  31. package/src/components/KYCElements/VerificationProgressTemplate.tsx +1 -1
  32. package/src/components/TemplateKYCExample.tsx +0 -65
  33. package/src/hooks/useTemplateKYCFlow.tsx +7 -12
  34. package/src/i18n/en/index.ts +2 -1
  35. package/src/i18n/fr/index.ts +2 -1
  36. package/src/i18n/types.ts +1 -0
  37. package/src/modules/camera/VisionCameraModule.ts +77 -8
  38. package/src/utils/pathToBase64.ts +8 -6
@@ -1 +1 @@
1
- {"version":3,"file":"VisionCameraModule.js","sourceRoot":"","sources":["../../../src/modules/camera/VisionCameraModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmD,MAAM,4BAA4B,CAAC;AACrG,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAa/C,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAC,QAAQ,CAAqB;IAErC,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC;YACjC,kBAAkB,CAAC,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzD,CAAC;QACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB;QACpB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,CAAC,yBAAyB,EAAE,CAAC;YACnD,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB;QACxB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;YACxE,OAAO,WAAW,IAAI,IAAI,CAAC;QAC7B,CAAC;QAA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pB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,gCAAgC;iBACxC,CAAC;YACJ,CAAC;YAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACnD,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,sBAAsB;iBAC9B,CAAC;YACJ,CAAC;YAED,4EAA4E;YAC5E,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,cAAc,IAAI,CAAC,GAAG,EAAE,MAAM;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAChE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,eAAe,kBAAkB,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Platform } from 'react-native';\nimport { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-native-vision-camera';\nimport * as FileSystem from \"expo-file-system\";\n\nexport interface CameraCaptureResult {\n success: boolean;\n path?: string;\n error?: string;\n}\n\nexport interface CameraPermissions {\n camera: CameraPermissionStatus;\n microphone: CameraPermissionStatus;\n}\n\nexport class VisionCameraModule {\n private static instance: VisionCameraModule;\n\n public static getInstance(): VisionCameraModule {\n if (!VisionCameraModule.instance) {\n VisionCameraModule.instance = new VisionCameraModule();\n }\n return VisionCameraModule.instance;\n }\n\n /**\n * Get available camera devices\n */\n async getCameraDevices(): Promise<CameraDevice[]> {\n try {\n const devices = Camera.getAvailableCameraDevices();\n return devices;\n } catch (error) {\n console.error('Error getting camera devices:', error);\n return [];\n }\n }\n\n /**\n * Get the best available device for selfies (front camera)\n */\n async getFrontCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n const frontCamera = devices.find(device => device.position === 'front');\n return frontCamera || null;\n } catch (error) {\n console.error('Error getting front camera:', error);\n return null;\n }\n }\n\n /**\n * Get the best available device for document capture (back camera)\n */\n async getBackCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n const backCamera = devices.find(device => device.position === 'back');\n return backCamera || null;\n } catch (error) {\n console.error('Error getting back camera:', error);\n return null;\n }\n }\n\n /**\n * Request camera permissions\n */\n async requestCameraPermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestCameraPermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting camera permission:', error);\n return false;\n }\n }\n\n /**\n * Request microphone permissions\n */\n async requestMicrophonePermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestMicrophonePermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting microphone permission:', error);\n return false;\n }\n }\n\n /**\n * Get current permission status\n */\n async getPermissionStatus(): Promise<CameraPermissions> {\n try {\n const cameraStatus = await Camera.getCameraPermissionStatus();\n const microphoneStatus = await Camera.getMicrophonePermissionStatus();\n\n return {\n camera: cameraStatus,\n microphone: microphoneStatus,\n };\n } catch (error) {\n console.error('Error getting permission status:', error);\n return {\n camera: 'denied',\n microphone: 'denied',\n };\n }\n }\n\n /**\n * Check if all required permissions are granted\n */\n async hasAllPermissions(): Promise<boolean> {\n try {\n const status = await this.getPermissionStatus();\n console.log('status', status);\n return status.camera === 'granted';\n } catch (error) {\n console.error('Error checking permissions:', error);\n return false;\n }\n }\n\n /**\n * Request all required permissions\n */\n async requestAllPermissions(): Promise<boolean> {\n try {\n const [cameraGranted, microphoneGranted] = await Promise.all([\n this.requestCameraPermission(),\n this.requestMicrophonePermission(),\n ]);\n\n return cameraGranted && microphoneGranted;\n } catch (error) {\n console.error('Error requesting permissions:', error);\n return false;\n }\n }\n\n /**\n * Check if camera is available\n */\n async isCameraAvailable(): Promise<boolean> {\n try {\n if (Platform.OS === 'web') {\n return false; // Vision Camera doesn't support web\n }\n\n const devices = await this.getCameraDevices();\n return devices.length > 0;\n } catch (error) {\n console.error('Error checking camera availability:', error);\n return false;\n }\n }\n\n /**\n * Process photo capture result\n */\n async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {\n\n const newPath = FileSystem.documentDirectory + `photo_${Date.now()}.jpg`;\n\n await FileSystem.copyAsync({\n from: `file://${photo.path}`,\n to: newPath,\n });\n\n try {\n return {\n success: true,\n path: newPath,\n };\n } catch (error) {\n console.error('Error processing photo result:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error processing photo',\n };\n }\n }\n\n /**\n * Legacy method for backward compatibility\n * @deprecated Use VisionCameraView component instead\n */\n async openCameraWithInstructions(instructions: string): Promise<CameraCaptureResult> {\n console.warn('openCameraWithInstructions is deprecated. Use VisionCameraView component instead.');\n\n try {\n const hasPermissions = await this.requestAllPermissions();\n if (!hasPermissions) {\n return {\n success: false,\n error: 'Camera permissions not granted',\n };\n }\n\n const isAvailable = await this.isCameraAvailable();\n if (!isAvailable) {\n return {\n success: false,\n error: 'Camera not available',\n };\n }\n\n // Return a placeholder result since this should be handled by the component\n return {\n success: true,\n path: `mock_photo_${Date.now()}.jpg`,\n };\n } catch (error) {\n console.error('Error in openCameraWithInstructions:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n }\n}\n\nexport default VisionCameraModule.getInstance();"]}
1
+ {"version":3,"file":"VisionCameraModule.js","sourceRoot":"","sources":["../../../src/modules/camera/VisionCameraModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmD,MAAM,4BAA4B,CAAC;AAErG;;;;GAIG;AACH,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,EAAU;IACpD,wCAAwC;IACxC,IAAI,CAAC;QACH,k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AAC,OAAO,CAAC,CAAC,CAAC,gCAAgC;aACjF,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,0BAA0B,CAAC,YAAoB;QACnD,OAAO,CAAC,IAAI,CAAC,mFAAmF,CAAC,CAAC;QAElG,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC1D,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,gCAAgC;iBACxC,CAAC;YACJ,CAAC;YAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACnD,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,sBAAsB;iBAC9B,CAAC;YACJ,CAAC;YAED,4EAA4E;YAC5E,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,cAAc,IAAI,CAAC,GAAG,EAAE,MAAM;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAChE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,eAAe,kBAAkB,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Platform } from 'react-native';\nimport { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-native-vision-camera';\n\n/**\n * Backward-compatible file copy function\n * Tries new File API first (Expo SDK 54+), then falls back to legacy API\n * Never uses the deprecated regular import to avoid errors\n */\nasync function copyFileCompat(from: string, to: string): Promise<void> {\n // Try new File API first (Expo SDK 54+)\n try {\n // @ts-ignore - File API might not be in types yet\n const { File } = require('expo-file-system');\n if (File && typeof File === 'function') {\n const sourceFile = new File(from);\n const destFile = new File(to);\n // File.copy() is synchronous but may throw\n sourceFile.copy(destFile);\n return;\n }\n } catch (error) {\n // New API not available or failed, try legacy\n // Continue to legacy API\n }\n\n // Try legacy API from expo-file-system/legacy (Expo SDK 54+)\n // This is the recommended way to avoid deprecation warnings\n try {\n // @ts-ignore - legacy export might not be in types\n const LegacyFileSystem = require('expo-file-system/legacy');\n if (LegacyFileSystem && LegacyFileSystem.copyAsync && typeof LegacyFileSystem.copyAsync === 'function') {\n await LegacyFileSystem.copyAsync({ from, to });\n return;\n }\n } catch (error) {\n // If legacy is not available, throw a clear error\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Unable to copy file: legacy FileSystem API not available. Error: ${errorMessage}`);\n }\n\n throw new Error('Unable to copy file: legacy FileSystem API loaded but copyAsync method not found');\n}\n\n/**\n * Get document directory path in a backward-compatible way\n * Never uses the deprecated regular import to avoid errors\n */\nfunction getDocumentDirectory(): string {\n try {\n // Try new Paths API first (Expo SDK 54+)\n // @ts-ignore\n const { Paths } = require('expo-file-system');\n if (Paths?.document) {\n return Paths.document.uri;\n }\n } catch (_) {\n // New API not available, try legacy\n }\n\n // Try legacy API from expo-file-system/legacy (Expo SDK 54+)\n // This is the recommended way to avoid deprecation warnings\n try {\n // @ts-ignore\n const LegacyFileSystem = require('expo-file-system/legacy');\n if (LegacyFileSystem && LegacyFileSystem.documentDirectory) {\n return LegacyFileSystem.documentDirectory;\n }\n } catch (error) {\n // Legacy should be available in SDK 54+, but if not, throw a clear error\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Unable to get document directory: legacy FileSystem API not available. Error: ${errorMessage}`);\n }\n\n throw new Error('Unable to get document directory: legacy FileSystem API loaded but documentDirectory not found');\n}\n\nexport interface CameraCaptureResult {\n success: boolean;\n path?: string;\n error?: string;\n}\n\nexport interface CameraPermissions {\n camera: CameraPermissionStatus;\n microphone: CameraPermissionStatus;\n}\n\nexport class VisionCameraModule {\n private static instance: VisionCameraModule;\n\n public static getInstance(): VisionCameraModule {\n if (!VisionCameraModule.instance) {\n VisionCameraModule.instance = new VisionCameraModule();\n }\n return VisionCameraModule.instance;\n }\n\n /**\n * Get available camera devices\n */\n async getCameraDevices(): Promise<CameraDevice[]> {\n try {\n const devices = Camera.getAvailableCameraDevices();\n return devices;\n } catch (error) {\n console.error('Error getting camera devices:', error);\n return [];\n }\n }\n\n /**\n * Get the best available device for selfies (front camera)\n */\n async getFrontCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n const frontCamera = devices.find(device => device.position === 'front');\n return frontCamera || null;\n } catch (error) {\n console.error('Error getting front camera:', error);\n return null;\n }\n }\n\n /**\n * Get the best available device for document capture (back camera)\n */\n async getBackCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n const backCamera = devices.find(device => device.position === 'back');\n return backCamera || null;\n } catch (error) {\n console.error('Error getting back camera:', error);\n return null;\n }\n }\n\n /**\n * Request camera permissions\n */\n async requestCameraPermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestCameraPermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting camera permission:', error);\n return false;\n }\n }\n\n /**\n * Request microphone permissions\n */\n async requestMicrophonePermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestMicrophonePermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting microphone permission:', error);\n return false;\n }\n }\n\n /**\n * Get current permission status\n */\n async getPermissionStatus(): Promise<CameraPermissions> {\n try {\n const cameraStatus = await Camera.getCameraPermissionStatus();\n const microphoneStatus = await Camera.getMicrophonePermissionStatus();\n\n return {\n camera: cameraStatus,\n microphone: microphoneStatus,\n };\n } catch (error) {\n console.error('Error getting permission status:', error);\n return {\n camera: 'denied',\n microphone: 'denied',\n };\n }\n }\n\n /**\n * Check if all required permissions are granted\n */\n async hasAllPermissions(): Promise<boolean> {\n try {\n const status = await this.getPermissionStatus();\n console.log('status', status);\n return status.camera === 'granted';\n } catch (error) {\n console.error('Error checking permissions:', error);\n return false;\n }\n }\n\n /**\n * Request all required permissions\n */\n async requestAllPermissions(): Promise<boolean> {\n try {\n const [cameraGranted, microphoneGranted] = await Promise.all([\n this.requestCameraPermission(),\n this.requestMicrophonePermission(),\n ]);\n\n return cameraGranted && microphoneGranted;\n } catch (error) {\n console.error('Error requesting permissions:', error);\n return false;\n }\n }\n\n /**\n * Check if camera is available\n */\n async isCameraAvailable(): Promise<boolean> {\n try {\n if (Platform.OS === 'web') {\n return false; // Vision Camera doesn't support web\n }\n\n const devices = await this.getCameraDevices();\n return devices.length > 0;\n } catch (error) {\n console.error('Error checking camera availability:', error);\n return false;\n }\n }\n\n /**\n * Process photo capture result\n */\n async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {\n try {\n const documentDir = getDocumentDirectory();\n const newPath = documentDir + `photo_${Date.now()}.jpg`;\n\n await copyFileCompat(`file://${photo.path}`, newPath);\n\n return {\n success: true,\n path: newPath,\n };\n } catch (error) {\n console.error('Error processing photo result:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error processing photo',\n };\n }\n }\n\n /**\n * Legacy method for backward compatibility\n * @deprecated Use VisionCameraView component instead\n */\n async openCameraWithInstructions(instructions: string): Promise<CameraCaptureResult> {\n console.warn('openCameraWithInstructions is deprecated. Use VisionCameraView component instead.');\n\n try {\n const hasPermissions = await this.requestAllPermissions();\n if (!hasPermissions) {\n return {\n success: false,\n error: 'Camera permissions not granted',\n };\n }\n\n const isAvailable = await this.isCameraAvailable();\n if (!isAvailable) {\n return {\n success: false,\n error: 'Camera not available',\n };\n }\n\n // Return a placeholder result since this should be handled by the component\n return {\n success: true,\n path: `mock_photo_${Date.now()}.jpg`,\n };\n } catch (error) {\n console.error('Error in openCameraWithInstructions:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n }\n}\n\nexport default VisionCameraModule.getInstance();"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pathToBase64.d.ts","sourceRoot":"","sources":["../../src/utils/pathToBase64.ts"],"names":[],"mappings":"AAAA,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0C/D;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"pathToBase64.d.ts","sourceRoot":"","sources":["../../src/utils/pathToBase64.ts"],"names":[],"mappings":"AAAA,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4C/D;AAED,eAAe,YAAY,CAAC"}
@@ -8,17 +8,19 @@ export async function pathToBase64(uri) {
8
8
  }
9
9
  // Try Expo FileSystem if available (React Native + Expo)
10
10
  try {
11
- // Dynamically import to avoid hard dependency when not available
12
- // eslint-disable-next-line @typescript-eslint/no-var-requires
13
- const FileSystem = require('expo-file-system');
14
- if (FileSystem?.readAsStringAsync) {
15
- const base64 = await FileSystem.readAsStringAsync(uri, { encoding: FileSystem.EncodingType.Base64 });
11
+ // Use legacy API from expo-file-system/legacy (Expo SDK 54+)
12
+ // This is the recommended way to avoid deprecation warnings
13
+ // readAsStringAsync with Base64 encoding is the most straightforward approach
14
+ // @ts-ignore - legacy export might not be in types
15
+ const LegacyFileSystem = require('expo-file-system/legacy');
16
+ if (LegacyFileSystem?.readAsStringAsync) {
17
+ const base64 = await LegacyFileSystem.readAsStringAsync(uri, { encoding: LegacyFileSystem.EncodingType.Base64 });
16
18
  if (base64)
17
19
  return base64;
18
20
  }
19
21
  }
20
22
  catch (_) {
21
- // ignore - fall back to other strategies
23
+ // Legacy API not available, fall back to other strategies (fetch + FileReader)
22
24
  }
23
25
  // Generic fetch + FileReader strategy (works on web; often works on RN for file:// URIs)
24
26
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"pathToBase64.js","sourceRoot":"","sources":["../../src/utils/pathToBase64.ts"],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,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;oBACzD,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;YAC/D,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACzE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,0BAA0B;IAC5B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACnE,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["export async function pathToBase64(uri: string): Promise<string> {\n if (!uri) throw new Error('pathToBase64: uri is required');\n\n // If already a data URI, return the base64 part\n if (uri.startsWith('data:')) {\n const commaIndex = uri.indexOf(',');\n return commaIndex !== -1 ? uri.substring(commaIndex + 1) : uri;\n }\n\n // Try Expo FileSystem if available (React Native + Expo)\n try {\n // Dynamically import to avoid hard dependency when not available\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const FileSystem = require('expo-file-system');\n if (FileSystem?.readAsStringAsync) {\n const base64 = await FileSystem.readAsStringAsync(uri, { encoding: FileSystem.EncodingType.Base64 });\n if (base64) return base64;\n }\n } catch (_) {\n // ignore - fall back to other strategies\n }\n\n // Generic fetch + FileReader strategy (works on web; often works on RN for file:// URIs)\n try {\n const response = await fetch(uri);\n const blob = await response.blob();\n const dataUrl = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n if (typeof reader.result === 'string') resolve(reader.result);\n else reject(new Error('Failed to convert blob to data URL'));\n };\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n const commaIndex = dataUrl.indexOf(',');\n return commaIndex !== -1 ? dataUrl.substring(commaIndex + 1) : dataUrl;\n } catch (err) {\n // continue to final error\n }\n\n throw new Error('pathToBase64: unable to convert uri to base64');\n}\n\nexport default pathToBase64;\n\n\n"]}
1
+ {"version":3,"file":"pathToBase64.js","sourceRoot":"","sources":["../../src/utils/pathToBase64.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAE3D,gDAAgD;IAChD,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACjE,CAAC;IAED,yDAAyD;IACzD,IAAI,CAAC;QACH,6DAA6D;QAC7D,4DAA4D;QAC5D,8EAA8E;QAC9E,mDAAmD;QACnD,MAAM,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAC5D,IAAI,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;YACjH,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,+EAA+E;IACjF,CAAC;IAED,yFAAyF;IACzF,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5D,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE;gBACtB,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;oBAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;oBACzD,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;YAC/D,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACzE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,0BAA0B;IAC5B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACnE,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["export async function pathToBase64(uri: string): Promise<string> {\n if (!uri) throw new Error('pathToBase64: uri is required');\n\n // If already a data URI, return the base64 part\n if (uri.startsWith('data:')) {\n const commaIndex = uri.indexOf(',');\n return commaIndex !== -1 ? uri.substring(commaIndex + 1) : uri;\n }\n\n // Try Expo FileSystem if available (React Native + Expo)\n try {\n // Use legacy API from expo-file-system/legacy (Expo SDK 54+)\n // This is the recommended way to avoid deprecation warnings\n // readAsStringAsync with Base64 encoding is the most straightforward approach\n // @ts-ignore - legacy export might not be in types\n const LegacyFileSystem = require('expo-file-system/legacy');\n if (LegacyFileSystem?.readAsStringAsync) {\n const base64 = await LegacyFileSystem.readAsStringAsync(uri, { encoding: LegacyFileSystem.EncodingType.Base64 });\n if (base64) return base64;\n }\n } catch (_) {\n // Legacy API not available, fall back to other strategies (fetch + FileReader)\n }\n\n // Generic fetch + FileReader strategy (works on web; often works on RN for file:// URIs)\n try {\n const response = await fetch(uri);\n const blob = await response.blob();\n const dataUrl = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n if (typeof reader.result === 'string') resolve(reader.result);\n else reject(new Error('Failed to convert blob to data URL'));\n };\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n const commaIndex = dataUrl.indexOf(',');\n return commaIndex !== -1 ? dataUrl.substring(commaIndex + 1) : dataUrl;\n } catch (err) {\n // continue to final error\n }\n\n throw new Error('pathToBase64: unable to convert uri to base64');\n}\n\nexport default pathToBase64;\n\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transfergratis/react-native-sdk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "transfergratis react native sdk",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -339,30 +339,13 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
339
339
 
340
340
 
341
341
 
342
- // const renderBboxOverlay = () => {
343
- // const bbox: any = (silentCaptureResult as any)?.bbox;
344
- // if (!bbox || !imageNaturalSize) return null;
345
- // const containerWidth = Dimensions.get('window').width - 24 - 24; // approximate inner width accounting paddings/margins
346
- // const containerHeight = 200;
347
- // const scaleX = 1;
348
- // const scaleY = 1;
349
- // const left = Math.max(0, bbox.minX * scaleX);
350
- // const top = Math.max(0, bbox.minY * scaleY);
351
- // const width = Math.max(1, bbox.width * scaleX);
352
- // const height = Math.max(1, bbox.height * scaleY);
353
- // return (
354
- // <View
355
- // pointerEvents="none"
356
- // style={{ position: 'absolute', left, top, width, height, borderColor: '#2DBD60', borderWidth: 2, borderStyle: 'solid', borderRadius: 6 }}
357
- // />
358
- // );
359
- // };
360
-
361
342
 
362
343
 
363
344
 
364
345
  const handleDocumentTypeSelection = (docType: GovernmentDocumentType) => {
365
346
  setSelectedDocumentType({ type: docType, region: hasRegions(docType) ? '' : 'root' });
347
+ setSilentCaptureResult((prev) => ({ ...prev, templatePath: '', bbox: undefined, success: false, isAnalyzing: false, error: '', path: '', mrz: '', country: '', documentType: '' }));
348
+ setCapturedImages((prev) => ({ ...prev, front: { dir: '', file: '', mrz: '' }, back: { dir: '', file: '', mrz: '' } }));
366
349
  };
367
350
  const handleRegionSelection = (region: string) => {
368
351
  setSelectedDocumentType((prev) => ({ ...prev, region: region }));
@@ -155,7 +155,7 @@ export const VerificationProgressTemplate: React.FC<VerificationProgressTemplate
155
155
  <Text key={idx} style={styles.issueItem}>• {issue}</Text>
156
156
  ))}
157
157
  </View>
158
- <TouchableOpacity style={[styles.button, styles.primary]} onPress={() => actions.goToComponent(state.template.components.find(c => c.type !== 'review_submit' && c.type !== 'verification_progress')?.id || 0)}>
158
+ <TouchableOpacity style={[styles.button, styles.primary]} onPress={() => actions.resetTemplate()}>
159
159
  <Text style={styles.buttonText}>{t('kyc.verificationProgress.status.retry')}</Text>
160
160
  </TouchableOpacity>
161
161
  <TouchableOpacity style={[styles.button, styles.secondary]}>
@@ -260,68 +260,3 @@ const styles = StyleSheet.create({
260
260
  flex: 1,
261
261
  },
262
262
  });
263
-
264
- // Exemples de différents types de documents gouvernementaux supportés :
265
- /*
266
- export const documentTypeExamples = {
267
- // Carte d'identité nationale
268
- idCard: {
269
- document_type: "id_card" as const,
270
- labels: { en: "Upload your ID card", fr: "Téléversez votre carte d'identité" }
271
- },
272
-
273
- // Passeport
274
- passport: {
275
- document_type: "passport" as const,
276
- labels: { en: "Upload your passport", fr: "Téléversez votre passeport" }
277
- },
278
-
279
- // Permis de conduire
280
- driversLicense: {
281
- document_type: "drivers_license" as const,
282
- labels: { en: "Upload your driver's license", fr: "Téléversez votre permis de conduire" }
283
- },
284
-
285
- // Permis de séjour
286
- residencePermit: {
287
- document_type: "residence_permit" as const,
288
- labels: { en: "Upload your residence permit", fr: "Téléversez votre permis de séjour" }
289
- },
290
-
291
- // Carte nationale d'identité
292
- nationalId: {
293
- document_type: "national_id" as const,
294
- labels: { en: "Upload your national ID", fr: "Téléversez votre carte nationale d'identité" }
295
- },
296
-
297
- // Carte d'électeur
298
- voterId: {
299
- document_type: "voter_id" as const,
300
- labels: { en: "Upload your voter ID", fr: "Téléversez votre carte d'électeur" }
301
- },
302
-
303
- // Carte militaire
304
- militaryId: {
305
- document_type: "military_id" as const,
306
- labels: { en: "Upload your military ID", fr: "Téléversez votre carte militaire" }
307
- },
308
-
309
- // Carte d'étudiant
310
- studentId: {
311
- document_type: "student_id" as const,
312
- labels: { en: "Upload your student ID", fr: "Téléversez votre carte d'étudiant" }
313
- },
314
-
315
- // Permis de travail
316
- workPermit: {
317
- document_type: "work_permit" as const,
318
- labels: { en: "Upload your work permit", fr: "Téléversez votre permis de travail" }
319
- },
320
-
321
- // Autre document gouvernemental
322
- other: {
323
- document_type: "other" as const,
324
- labels: { en: "Upload your government document", fr: "Téléversez votre document gouvernemental" }
325
- }
326
- };
327
- */
@@ -130,8 +130,8 @@ export const useTemplateKYCFlow = (
130
130
  const templateWithReview = useMemo(() => ensureReviewSubmitStep(template), [template, ensureReviewSubmitStep]);
131
131
  const templateWithReviewAndVerification = useMemo(() => ensureVerificationProgressStep(templateWithReview), [templateWithReview, ensureVerificationProgressStep]);
132
132
 
133
- // État du flux
134
- const [state, setState] = useState<TemplateState>({
133
+ // État initial du flux
134
+ const buildInitialState = (): TemplateState => ({
135
135
  template: templateWithReviewAndVerification,
136
136
  currentComponentIndex: 0,
137
137
  completedComponents: [],
@@ -151,6 +151,9 @@ export const useTemplateKYCFlow = (
151
151
  status: 'idle',
152
152
  },
153
153
  });
154
+
155
+ // État du flux
156
+ const [state, setState] = useState<TemplateState>(() => buildInitialState());
154
157
  const mapComponentTypeToAction = useCallback((type: TemplateComponent['type']): string | null => {
155
158
  switch (type) {
156
159
  case 'id_card':
@@ -594,16 +597,8 @@ export const useTemplateKYCFlow = (
594
597
 
595
598
  // Réinitialiser le template
596
599
  resetTemplate: useCallback(() => {
597
- setState(prev => ({
598
- ...prev,
599
- currentComponentIndex: 0,
600
- completedComponents: [],
601
- componentData: {},
602
- errors: {},
603
- isProcessing: false,
604
- verification: { status: 'idle', result: undefined },
605
- }));
606
- }, []),
600
+ setState(buildInitialState());
601
+ }, [buildInitialState]),
607
602
 
608
603
  // Changer la langue
609
604
  setLanguage: useCallback((language: string) => {
@@ -140,7 +140,8 @@ export const en = {
140
140
  pending: 'Pending',
141
141
  processing: 'Processing',
142
142
  completed: 'Completed',
143
- failed: 'Failed'
143
+ failed: 'Failed',
144
+ retry: 'Retry'
144
145
  }
145
146
  },
146
147
 
@@ -140,7 +140,8 @@ export const fr = {
140
140
  pending: 'En attente',
141
141
  processing: 'En cours',
142
142
  completed: 'Terminé',
143
- failed: 'Échoué'
143
+ failed: 'Échoué',
144
+ retry: 'Réessayer'
144
145
  }
145
146
  },
146
147
 
package/src/i18n/types.ts CHANGED
@@ -98,6 +98,7 @@ export interface KYCTranslations {
98
98
  processing: string;
99
99
  completed: string;
100
100
  failed: string;
101
+ retry: string;
101
102
  };
102
103
  };
103
104
 
@@ -1,6 +1,78 @@
1
1
  import { Platform } from 'react-native';
2
2
  import { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-native-vision-camera';
3
- import * as FileSystem from "expo-file-system";
3
+
4
+ /**
5
+ * Backward-compatible file copy function
6
+ * Tries new File API first (Expo SDK 54+), then falls back to legacy API
7
+ * Never uses the deprecated regular import to avoid errors
8
+ */
9
+ async function copyFileCompat(from: string, to: string): Promise<void> {
10
+ // Try new File API first (Expo SDK 54+)
11
+ try {
12
+ // @ts-ignore - File API might not be in types yet
13
+ const { File } = require('expo-file-system');
14
+ if (File && typeof File === 'function') {
15
+ const sourceFile = new File(from);
16
+ const destFile = new File(to);
17
+ // File.copy() is synchronous but may throw
18
+ sourceFile.copy(destFile);
19
+ return;
20
+ }
21
+ } catch (error) {
22
+ // New API not available or failed, try legacy
23
+ // Continue to legacy API
24
+ }
25
+
26
+ // Try legacy API from expo-file-system/legacy (Expo SDK 54+)
27
+ // This is the recommended way to avoid deprecation warnings
28
+ try {
29
+ // @ts-ignore - legacy export might not be in types
30
+ const LegacyFileSystem = require('expo-file-system/legacy');
31
+ if (LegacyFileSystem && LegacyFileSystem.copyAsync && typeof LegacyFileSystem.copyAsync === 'function') {
32
+ await LegacyFileSystem.copyAsync({ from, to });
33
+ return;
34
+ }
35
+ } catch (error) {
36
+ // If legacy is not available, throw a clear error
37
+ const errorMessage = error instanceof Error ? error.message : String(error);
38
+ throw new Error(`Unable to copy file: legacy FileSystem API not available. Error: ${errorMessage}`);
39
+ }
40
+
41
+ throw new Error('Unable to copy file: legacy FileSystem API loaded but copyAsync method not found');
42
+ }
43
+
44
+ /**
45
+ * Get document directory path in a backward-compatible way
46
+ * Never uses the deprecated regular import to avoid errors
47
+ */
48
+ function getDocumentDirectory(): string {
49
+ try {
50
+ // Try new Paths API first (Expo SDK 54+)
51
+ // @ts-ignore
52
+ const { Paths } = require('expo-file-system');
53
+ if (Paths?.document) {
54
+ return Paths.document.uri;
55
+ }
56
+ } catch (_) {
57
+ // New API not available, try legacy
58
+ }
59
+
60
+ // Try legacy API from expo-file-system/legacy (Expo SDK 54+)
61
+ // This is the recommended way to avoid deprecation warnings
62
+ try {
63
+ // @ts-ignore
64
+ const LegacyFileSystem = require('expo-file-system/legacy');
65
+ if (LegacyFileSystem && LegacyFileSystem.documentDirectory) {
66
+ return LegacyFileSystem.documentDirectory;
67
+ }
68
+ } catch (error) {
69
+ // Legacy should be available in SDK 54+, but if not, throw a clear error
70
+ const errorMessage = error instanceof Error ? error.message : String(error);
71
+ throw new Error(`Unable to get document directory: legacy FileSystem API not available. Error: ${errorMessage}`);
72
+ }
73
+
74
+ throw new Error('Unable to get document directory: legacy FileSystem API loaded but documentDirectory not found');
75
+ }
4
76
 
5
77
  export interface CameraCaptureResult {
6
78
  success: boolean;
@@ -163,15 +235,12 @@ export class VisionCameraModule {
163
235
  * Process photo capture result
164
236
  */
165
237
  async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {
238
+ try {
239
+ const documentDir = getDocumentDirectory();
240
+ const newPath = documentDir + `photo_${Date.now()}.jpg`;
166
241
 
167
- const newPath = FileSystem.documentDirectory + `photo_${Date.now()}.jpg`;
168
-
169
- await FileSystem.copyAsync({
170
- from: `file://${photo.path}`,
171
- to: newPath,
172
- });
242
+ await copyFileCompat(`file://${photo.path}`, newPath);
173
243
 
174
- try {
175
244
  return {
176
245
  success: true,
177
246
  path: newPath,
@@ -9,15 +9,17 @@ export async function pathToBase64(uri: string): Promise<string> {
9
9
 
10
10
  // Try Expo FileSystem if available (React Native + Expo)
11
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 });
12
+ // Use legacy API from expo-file-system/legacy (Expo SDK 54+)
13
+ // This is the recommended way to avoid deprecation warnings
14
+ // readAsStringAsync with Base64 encoding is the most straightforward approach
15
+ // @ts-ignore - legacy export might not be in types
16
+ const LegacyFileSystem = require('expo-file-system/legacy');
17
+ if (LegacyFileSystem?.readAsStringAsync) {
18
+ const base64 = await LegacyFileSystem.readAsStringAsync(uri, { encoding: LegacyFileSystem.EncodingType.Base64 });
17
19
  if (base64) return base64;
18
20
  }
19
21
  } catch (_) {
20
- // ignore - fall back to other strategies
22
+ // Legacy API not available, fall back to other strategies (fetch + FileReader)
21
23
  }
22
24
 
23
25
  // Generic fetch + FileReader strategy (works on web; often works on RN for file:// URIs)