@transfergratis/react-native-sdk 0.1.3 → 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.
- package/android/.idea/caches/deviceStreaming.xml +860 -0
- package/android/build/.transforms/{7ec900c0f64f5f1a7c88998dd44001b8 → 01c28d00c798aa4846f16ce72123ebf9}/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +1 -0
- package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
- package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +2 -2
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +51 -48
- package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-transfergratis-react-native-sdk.jar +0 -0
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +1 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/aar/transfergratis-react-native-sdk-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +27 -23
- package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkView.class +0 -0
- package/android/build.gradle +1 -5
- package/android/src/main/AndroidManifest.xml +1 -0
- package/build/api/axios.d.ts +30 -0
- package/build/api/axios.d.ts.map +1 -0
- package/build/api/axios.js +92 -0
- package/build/api/axios.js.map +1 -0
- package/build/components/EnhancedCameraView.d.ts +1 -41
- package/build/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.js +76 -35
- package/build/components/EnhancedCameraView.js.map +1 -1
- package/build/components/EnhancedCameraView.web.d.ts +1 -41
- package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.web.js +28 -4
- package/build/components/EnhancedCameraView.web.js.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts +2 -2
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.js +71 -114
- package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.js +7 -3
- package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
- package/build/components/KYCElements/IDCardCapture.d.ts +7 -2
- package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/components/KYCElements/IDCardCapture.js +253 -104
- package/build/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/components/KYCElements/InitializationStep.d.ts +5 -0
- package/build/components/KYCElements/InitializationStep.d.ts.map +1 -0
- package/build/components/KYCElements/InitializationStep.js +41 -0
- package/build/components/KYCElements/InitializationStep.js.map +1 -0
- package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/LocationCaptureTemplate.js +15 -13
- package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
- package/build/components/KYCElements/ReviewSubmitTemplate.d.ts +12 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.js +171 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.js.map +1 -0
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts +6 -2
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.js +105 -35
- package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/VerificationProgressTemplate.d.ts +12 -0
- package/build/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/VerificationProgressTemplate.js +93 -0
- package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -0
- package/build/components/OverLay/IdCard.d.ts +1 -1
- package/build/components/OverLay/IdCard.d.ts.map +1 -1
- package/build/components/OverLay/IdCard.js +10 -6
- package/build/components/OverLay/IdCard.js.map +1 -1
- package/build/components/OverLay/SelfieOverlay.d.ts +1 -1
- package/build/components/OverLay/SelfieOverlay.d.ts.map +1 -1
- package/build/components/OverLay/SelfieOverlay.js +5 -4
- package/build/components/OverLay/SelfieOverlay.js.map +1 -1
- package/build/components/OverLay/type.d.ts +71 -1
- package/build/components/OverLay/type.d.ts.map +1 -1
- package/build/components/OverLay/type.js.map +1 -1
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js +72 -197
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +63 -39
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/components/VisionCameraView.js +1 -1
- package/build/components/VisionCameraView.js.map +1 -1
- package/build/components/example/OrientationVideoExample.d.ts.map +1 -1
- package/build/components/example/OrientationVideoExample.js +1 -5
- package/build/components/example/OrientationVideoExample.js.map +1 -1
- package/build/components/ui/Button.js +1 -1
- package/build/components/ui/Button.js.map +1 -1
- package/build/config/countriesData.d.ts +3 -0
- package/build/config/countriesData.d.ts.map +1 -0
- package/build/config/countriesData.js +79 -0
- package/build/config/countriesData.js.map +1 -0
- package/build/config/region_mapping.d.ts +3 -0
- package/build/config/region_mapping.d.ts.map +1 -0
- package/build/config/region_mapping.js +687 -0
- package/build/config/region_mapping.js.map +1 -0
- package/build/hooks/useI18n.d.ts +11 -0
- package/build/hooks/useI18n.d.ts.map +1 -0
- package/build/hooks/useI18n.js +37 -0
- package/build/hooks/useI18n.js.map +1 -0
- package/build/hooks/useOrientationVideo.d.ts +1 -2
- package/build/hooks/useOrientationVideo.d.ts.map +1 -1
- package/build/hooks/useOrientationVideo.js +2 -1
- package/build/hooks/useOrientationVideo.js.map +1 -1
- package/build/hooks/useRealtimeVerifier.d.ts +28 -0
- package/build/hooks/useRealtimeVerifier.d.ts.map +1 -0
- package/build/hooks/useRealtimeVerifier.js +91 -0
- package/build/hooks/useRealtimeVerifier.js.map +1 -0
- package/build/hooks/useTemplateKYCFlow.d.ts +1 -0
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +337 -38
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/i18n/en/index.d.ts +168 -0
- package/build/i18n/en/index.d.ts.map +1 -0
- package/build/i18n/en/index.js +195 -0
- package/build/i18n/en/index.js.map +1 -0
- package/build/i18n/fr/index.d.ts +168 -0
- package/build/i18n/fr/index.d.ts.map +1 -0
- package/build/i18n/fr/index.js +194 -0
- package/build/i18n/fr/index.js.map +1 -0
- package/build/i18n/index.d.ts +10 -0
- package/build/i18n/index.d.ts.map +1 -0
- package/build/i18n/index.js +56 -0
- package/build/i18n/index.js.map +1 -0
- package/build/i18n/types.d.ts +153 -0
- package/build/i18n/types.d.ts.map +1 -0
- package/build/i18n/types.js +3 -0
- package/build/i18n/types.js.map +1 -0
- package/build/i18n/usage-example.d.ts +4 -0
- package/build/i18n/usage-example.d.ts.map +1 -0
- package/build/i18n/usage-example.js +189 -0
- package/build/i18n/usage-example.js.map +1 -0
- package/build/modules/api/CardAuthentification.d.ts +22 -0
- package/build/modules/api/CardAuthentification.d.ts.map +1 -0
- package/build/modules/api/CardAuthentification.js +107 -0
- package/build/modules/api/CardAuthentification.js.map +1 -0
- package/build/modules/api/KYCService.d.ts +57 -1
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +348 -27
- package/build/modules/api/KYCService.js.map +1 -1
- package/build/modules/api/SelfieVerification.d.ts +3 -0
- package/build/modules/api/SelfieVerification.d.ts.map +1 -0
- package/build/modules/api/SelfieVerification.js +9 -0
- package/build/modules/api/SelfieVerification.js.map +1 -0
- package/build/modules/api/backendApi.d.ts +2 -0
- package/build/modules/api/backendApi.d.ts.map +1 -0
- package/build/modules/api/backendApi.js +6 -0
- package/build/modules/api/backendApi.js.map +1 -0
- package/build/modules/api/types.d.ts +20 -0
- package/build/modules/api/types.d.ts.map +1 -0
- package/build/modules/api/types.js +2 -0
- package/build/modules/api/types.js.map +1 -0
- package/build/modules/camera/VisionCameraModule.d.ts +1 -1
- package/build/modules/camera/VisionCameraModule.d.ts.map +1 -1
- package/build/modules/camera/VisionCameraModule.js +8 -2
- package/build/modules/camera/VisionCameraModule.js.map +1 -1
- package/build/types/KYC.types.d.ts +59 -7
- package/build/types/KYC.types.d.ts.map +1 -1
- package/build/types/KYC.types.js +9 -1
- package/build/types/KYC.types.js.map +1 -1
- package/build/utils/cropByObb.d.ts +11 -0
- package/build/utils/cropByObb.d.ts.map +1 -0
- package/build/utils/cropByObb.js +78 -0
- package/build/utils/cropByObb.js.map +1 -0
- package/build/utils/get-document-type-info.d.ts +13 -0
- package/build/utils/get-document-type-info.d.ts.map +1 -0
- package/build/utils/get-document-type-info.js +59 -0
- package/build/utils/get-document-type-info.js.map +1 -0
- package/build/utils/pathToBase64.d.ts +3 -0
- package/build/utils/pathToBase64.d.ts.map +1 -0
- package/build/utils/pathToBase64.js +47 -0
- package/build/utils/pathToBase64.js.map +1 -0
- package/build/utils/remove-duplicate.d.ts +2 -0
- package/build/utils/remove-duplicate.d.ts.map +1 -0
- package/build/utils/remove-duplicate.js +4 -0
- package/build/utils/remove-duplicate.js.map +1 -0
- package/package.json +3 -1
- package/src/api/axios.ts +144 -0
- package/src/components/EnhancedCameraView.tsx +96 -78
- package/src/components/EnhancedCameraView.web.tsx +41 -40
- package/src/components/KYCElements/CountrySelectionTemplate.tsx +104 -136
- package/src/components/KYCElements/FileUploadTemplate.tsx +14 -8
- package/src/components/KYCElements/IDCardCapture.tsx +311 -115
- package/src/components/KYCElements/InitializationStep.tsx +53 -0
- package/src/components/KYCElements/LocationCaptureTemplate.tsx +17 -15
- package/src/components/KYCElements/OrientationVideoCapture.tsx +2 -2
- package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +2 -2
- package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +2 -2
- package/src/components/KYCElements/ReviewSubmitTemplate.tsx +201 -0
- package/src/components/KYCElements/SelfieCaptureTemplate.tsx +140 -53
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +123 -0
- package/src/components/OverLay/IdCard.tsx +17 -9
- package/src/components/OverLay/SelfieOverlay.tsx +6 -5
- package/src/components/OverLay/type.ts +64 -2
- package/src/components/TemplateKYCExample.tsx +76 -197
- package/src/components/TemplateKYCFlowRefactored.tsx +74 -46
- package/src/components/VisionCameraView.tsx +1 -1
- package/src/components/example/OrientationVideoExample.tsx +3 -7
- package/src/components/ui/Button.tsx +1 -1
- package/src/config/countriesData.ts +84 -0
- package/src/config/region_mapping.ts +688 -0
- package/src/hooks/useI18n.ts +53 -0
- package/src/hooks/useOrientationVideo.ts +2 -2
- package/src/hooks/useRealtimeVerifier.ts +128 -0
- package/src/hooks/useTemplateKYCFlow.tsx +375 -53
- package/src/i18n/README.md +288 -0
- package/src/i18n/en/index.ts +206 -0
- package/src/i18n/fr/index.ts +205 -0
- package/src/i18n/index.ts +65 -0
- package/src/i18n/types.ts +172 -0
- package/src/i18n/usage-example.tsx +202 -0
- package/src/modules/api/CardAuthentification.ts +114 -0
- package/src/modules/api/KYCService.ts +403 -30
- package/src/modules/api/SelfieVerification.ts +11 -0
- package/src/modules/api/backendApi.ts +8 -0
- package/src/modules/api/types.ts +24 -0
- package/src/modules/camera/VisionCameraModule.ts +16 -7
- package/src/types/KYC.types.ts +83 -14
- package/src/utils/cropByObb.ts +99 -0
- package/src/utils/get-document-type-info.ts +62 -0
- package/src/utils/pathToBase64.ts +47 -0
- package/src/utils/remove-duplicate.ts +3 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/results.bin +0 -1
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/BuildConfig.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$3.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$4.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$5.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$6.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$View$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkView.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$View$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkView.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/transfergratis-sdk_debug.kotlin_module +0 -0
- package/src/types/nativewind.d.ts +0 -2
- /package/android/build/.transforms/{7ec900c0f64f5f1a7c88998dd44001b8 → 01c28d00c798aa4846f16ce72123ebf9}/results.bin +0 -0
- /package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/{transfergratis-sdk_debug.kotlin_module → transfergratis-react-native-sdk_debug.kotlin_module} +0 -0
- /package/android/build/{intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/transfergratis-sdk_debug.kotlin_module → tmp/kotlin-classes/debug/META-INF/transfergratis-react-native-sdk_debug.kotlin_module} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React, { useState, useCallback, useMemo, createContext, useContext, ReactNode } from 'react';
|
|
2
|
-
import { KYCTemplate, TemplateState, TemplateActions, UseTemplateReturn } from '../types/KYC.types';
|
|
1
|
+
import React, { useState, useCallback, useMemo, createContext, useContext, ReactNode, useEffect } from 'react';
|
|
2
|
+
import { KYCTemplate, TemplateState, TemplateActions, UseTemplateReturn, TemplateComponent } from '../types/KYC.types';
|
|
3
|
+
import kycService, { authentification, truncateFields } from '../modules/api/KYCService';
|
|
4
|
+
import useI18n from './useI18n';
|
|
3
5
|
|
|
4
6
|
// Context pour le provider
|
|
5
7
|
interface TemplateKYCFlowContextType {
|
|
@@ -10,7 +12,8 @@ interface TemplateKYCFlowContextType {
|
|
|
10
12
|
canGoNext: boolean;
|
|
11
13
|
canGoPrevious: boolean;
|
|
12
14
|
isComplete: boolean;
|
|
13
|
-
getLocalizedText: (text: { en: string; fr: string;
|
|
15
|
+
getLocalizedText: (text: { en: string; fr: string;[key: string]: string }) => string;
|
|
16
|
+
initializeSession: () => Promise<void>;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const TemplateKYCFlowContext = createContext<TemplateKYCFlowContextType | undefined>(undefined);
|
|
@@ -32,7 +35,7 @@ export const TemplateKYCFlowProvider: React.FC<TemplateKYCFlowProviderProps> = (
|
|
|
32
35
|
initialLanguage = 'en',
|
|
33
36
|
}) => {
|
|
34
37
|
const hookResult = useTemplateKYCFlow(template, onComplete, onError, initialLanguage);
|
|
35
|
-
|
|
38
|
+
|
|
36
39
|
return (
|
|
37
40
|
<TemplateKYCFlowContext.Provider value={hookResult}>
|
|
38
41
|
{children}
|
|
@@ -53,11 +56,155 @@ export const useTemplateKYCFlow = (
|
|
|
53
56
|
template: KYCTemplate,
|
|
54
57
|
onComplete?: (data: Record<number, any>) => void,
|
|
55
58
|
onError?: (error: string) => void,
|
|
56
|
-
initialLanguage: string = 'en'
|
|
59
|
+
initialLanguage: string = 'en',
|
|
57
60
|
): UseTemplateReturn => {
|
|
61
|
+
|
|
62
|
+
const { setLocale } = useI18n();
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setLocale(initialLanguage);
|
|
66
|
+
}, [initialLanguage]);
|
|
67
|
+
|
|
68
|
+
// Helpers to align SDK steps with backend actions/templates
|
|
69
|
+
const isUiOnlyStep = useCallback((type: TemplateComponent['type']) => {
|
|
70
|
+
return type === 'verification_progress';
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const mapComponentTypeToAction = useCallback((type: TemplateComponent['type']): string | null => {
|
|
74
|
+
switch (type) {
|
|
75
|
+
case 'id_card':
|
|
76
|
+
case 'file_upload':
|
|
77
|
+
return 'document_upload';
|
|
78
|
+
case 'selfie':
|
|
79
|
+
return 'selfie_capture';
|
|
80
|
+
case 'location':
|
|
81
|
+
return 'location_permission';
|
|
82
|
+
case 'review_submit':
|
|
83
|
+
return 'final_submit';
|
|
84
|
+
case 'country_selection':
|
|
85
|
+
// No direct backend action; pack into metadata of next actionable step
|
|
86
|
+
return null;
|
|
87
|
+
case 'initialization':
|
|
88
|
+
return 'initialize_session';
|
|
89
|
+
case 'verification_progress':
|
|
90
|
+
return null; // UI-only
|
|
91
|
+
default:
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
const chooseTemplateId = useCallback((tpl: KYCTemplate): string => {
|
|
97
|
+
const types = tpl.components.map(c => c.type);
|
|
98
|
+
const hasLocation = types.includes('location');
|
|
99
|
+
const hasSelfie = types.includes('selfie');
|
|
100
|
+
const hasIdDoc = types.includes('id_card') || types.includes('file_upload');
|
|
101
|
+
// Simple heuristic to map to backend examples
|
|
102
|
+
if (hasLocation && hasSelfie && hasIdDoc) return 'enhanced_id';
|
|
103
|
+
if (hasSelfie && hasIdDoc) return 'standard_passport';
|
|
104
|
+
return 'standard_passport';
|
|
105
|
+
}, []);
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const computeServerStepIndex = useCallback((tpl: KYCTemplate, upToIndex: number): number => {
|
|
109
|
+
// Count actionable steps before the current component (exclude UI-only and country_selection)
|
|
110
|
+
const actionable = tpl.components
|
|
111
|
+
.slice(0, upToIndex)
|
|
112
|
+
.filter(c => !isUiOnlyStep(c.type) && mapComponentTypeToAction(c.type) !== null);
|
|
113
|
+
return actionable.length; // 0-based
|
|
114
|
+
}, [isUiOnlyStep, mapComponentTypeToAction]);
|
|
115
|
+
|
|
116
|
+
// Build backend-friendly payloads per action
|
|
117
|
+
const buildPayloadForComponent = useCallback((action: string | null, component: TemplateComponent, rawData: any, templateId: string, step: number) => {
|
|
118
|
+
const base = { template_id: null, step: component.order, permissionGranted: true } as any;
|
|
119
|
+
if (!action) {
|
|
120
|
+
return base;
|
|
121
|
+
}
|
|
122
|
+
// Document upload expects an array of documents with base64 and metadata
|
|
123
|
+
if (action === 'document_upload') {
|
|
124
|
+
const documents: Record<string, any> = {};
|
|
125
|
+
if (rawData && typeof rawData === 'object') {
|
|
126
|
+
Object.keys(rawData).forEach((key) => {
|
|
127
|
+
documents[key] = rawData[key];
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...base,
|
|
132
|
+
documents,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (action === 'selfie_capture') {
|
|
137
|
+
const metatada: Record<string, any> = {};
|
|
138
|
+
if (rawData && typeof rawData === 'object') {
|
|
139
|
+
|
|
140
|
+
Object.keys(rawData).forEach((key) => {
|
|
141
|
+
metatada[key] = rawData[key];
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return { ...base, metatada };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (action === 'location_permission') {
|
|
148
|
+
return { ...base, ...({ metadata: rawData || {} }), ...({ permissionGranted: true, }) };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Default: wrap as metadata
|
|
152
|
+
return { ...base, metadata: { ...(rawData || {}) } };
|
|
153
|
+
}, []);
|
|
154
|
+
// Ensure the template contains a final review step
|
|
155
|
+
const ensureReviewSubmitStep = useCallback((tpl: KYCTemplate): KYCTemplate => {
|
|
156
|
+
const hasReview = tpl.components.some(c => c.type === 'review_submit');
|
|
157
|
+
if (hasReview) return tpl;
|
|
158
|
+
|
|
159
|
+
const lastOrder = tpl.components.reduce((acc, c) => Math.max(acc, c.order ?? 0), 0);
|
|
160
|
+
const lastId = tpl.components.reduce((acc, c) => Math.max(acc, c.id), 0);
|
|
161
|
+
|
|
162
|
+
const reviewComponent: TemplateComponent = {
|
|
163
|
+
id: lastId + 1,
|
|
164
|
+
type: 'review_submit',
|
|
165
|
+
order: lastOrder + 1,
|
|
166
|
+
labels: { en: 'Review & Submit', fr: 'Revoir & Soumettre' },
|
|
167
|
+
instructions: { en: 'Confirm and submit', fr: 'Confirmer et soumettre' },
|
|
168
|
+
ui: { buttonText: { en: 'Complete Verification', fr: 'Terminer la vérification' } },
|
|
169
|
+
// @ts-ignore - config unused for review component
|
|
170
|
+
config: {},
|
|
171
|
+
} as TemplateComponent;
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
...tpl,
|
|
175
|
+
components: [...tpl.components, reviewComponent],
|
|
176
|
+
};
|
|
177
|
+
}, []);
|
|
178
|
+
|
|
179
|
+
const ensureVerificationProgressStep = useCallback((tpl: KYCTemplate): KYCTemplate => {
|
|
180
|
+
const hasVerification = tpl.components.some(c => c.type === 'verification_progress');
|
|
181
|
+
if (hasVerification) return tpl;
|
|
182
|
+
|
|
183
|
+
const lastOrder = tpl.components.reduce((acc, c) => Math.max(acc, c.order ?? 0), 0);
|
|
184
|
+
const lastId = tpl.components.reduce((acc, c) => Math.max(acc, c.id), 0);
|
|
185
|
+
|
|
186
|
+
const verificationComponent: TemplateComponent = {
|
|
187
|
+
id: lastId + 2,
|
|
188
|
+
type: 'verification_progress',
|
|
189
|
+
order: lastOrder + 2,
|
|
190
|
+
labels: { en: 'Verification', fr: 'Vérification' },
|
|
191
|
+
instructions: { en: 'We\'re reviewing your documents', fr: 'Nous analysons vos documents' },
|
|
192
|
+
ui: { buttonText: { en: '', fr: '' } },
|
|
193
|
+
// @ts-ignore - config unused for progress component
|
|
194
|
+
config: {},
|
|
195
|
+
} as TemplateComponent;
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
...tpl,
|
|
199
|
+
components: [...tpl.components, verificationComponent],
|
|
200
|
+
};
|
|
201
|
+
}, []);
|
|
202
|
+
|
|
203
|
+
const templateWithReview = useMemo(() => ensureReviewSubmitStep(template), [template, ensureReviewSubmitStep]);
|
|
204
|
+
const templateWithReviewAndVerification = useMemo(() => ensureVerificationProgressStep(templateWithReview), [templateWithReview, ensureVerificationProgressStep]);
|
|
58
205
|
// État du flux
|
|
59
206
|
const [state, setState] = useState<TemplateState>({
|
|
60
|
-
template,
|
|
207
|
+
template: templateWithReviewAndVerification,
|
|
61
208
|
currentComponentIndex: 0,
|
|
62
209
|
completedComponents: [],
|
|
63
210
|
componentData: {},
|
|
@@ -65,121 +212,284 @@ export const useTemplateKYCFlow = (
|
|
|
65
212
|
isProcessing: false,
|
|
66
213
|
currentLanguage: initialLanguage,
|
|
67
214
|
showCustomStepper: true,
|
|
215
|
+
session: {
|
|
216
|
+
session_id: '',
|
|
217
|
+
token: '',
|
|
218
|
+
isInitialized: false,
|
|
219
|
+
isProcessing: false,
|
|
220
|
+
error: null,
|
|
221
|
+
},
|
|
222
|
+
verification: {
|
|
223
|
+
status: 'idle',
|
|
224
|
+
},
|
|
68
225
|
});
|
|
69
226
|
|
|
70
227
|
// Composant actuel
|
|
71
228
|
const currentComponent = useMemo(() => {
|
|
72
|
-
return template.components[state.currentComponentIndex] || null;
|
|
73
|
-
}, [template.components, state.currentComponentIndex]);
|
|
229
|
+
return state.template.components[state.currentComponentIndex] || null;
|
|
230
|
+
}, [state.template.components, state.currentComponentIndex]);
|
|
74
231
|
|
|
75
232
|
// Progression du flux
|
|
76
233
|
const progress = useMemo(() => {
|
|
77
|
-
return template.components.length > 0
|
|
78
|
-
? ((state.currentComponentIndex + 1) / template.components.length) * 100
|
|
234
|
+
return state.template.components.length > 0
|
|
235
|
+
? ((state.currentComponentIndex + 1) / state.template.components.length) * 100
|
|
79
236
|
: 0;
|
|
80
|
-
}, [state.currentComponentIndex, template.components.length]);
|
|
237
|
+
}, [state.currentComponentIndex, state.template.components.length]);
|
|
81
238
|
|
|
82
239
|
// Vérifications de navigation
|
|
83
240
|
const canGoNext = useMemo(() => {
|
|
84
|
-
return state.currentComponentIndex < template.components.length - 1;
|
|
85
|
-
}, [state.currentComponentIndex, template.components.length]);
|
|
241
|
+
return state.currentComponentIndex < state.template.components.length - 1;
|
|
242
|
+
}, [state.currentComponentIndex, state.template.components.length]);
|
|
86
243
|
|
|
87
244
|
const canGoPrevious = useMemo(() => {
|
|
88
245
|
return state.currentComponentIndex > 0;
|
|
89
246
|
}, [state.currentComponentIndex]);
|
|
90
247
|
|
|
91
248
|
const isComplete = useMemo(() => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
249
|
+
const atReview = state.template.components[state.currentComponentIndex]?.type === 'review_submit';
|
|
250
|
+
const nonReviewCount = state.template.components.filter(c => c.type !== 'review_submit').length;
|
|
251
|
+
const completedNonReview = state.completedComponents.length >= nonReviewCount;
|
|
252
|
+
return atReview && completedNonReview;
|
|
253
|
+
}, [state.currentComponentIndex, state.completedComponents.length, state.template.components]);
|
|
95
254
|
|
|
96
255
|
// Fonction pour obtenir le texte localisé
|
|
97
|
-
const getLocalizedText = useCallback((text: { en: string; fr: string;
|
|
256
|
+
const getLocalizedText = useCallback((text: { en: string; fr: string;[key: string]: string }): string => {
|
|
98
257
|
return text[state.currentLanguage] || text.en || '';
|
|
99
258
|
}, [state.currentLanguage]);
|
|
100
259
|
|
|
260
|
+
const initializeSession = useCallback(async () => {
|
|
261
|
+
try {
|
|
262
|
+
setState(prev => ({
|
|
263
|
+
...prev,
|
|
264
|
+
session: {
|
|
265
|
+
...prev.session,
|
|
266
|
+
isInitialized: false,
|
|
267
|
+
isProcessing: true,
|
|
268
|
+
error: null,
|
|
269
|
+
},
|
|
270
|
+
}));
|
|
271
|
+
console.log('Initializing session');
|
|
272
|
+
|
|
273
|
+
const token = await authentification();
|
|
274
|
+
|
|
275
|
+
const session = await kycService.newSession(token);
|
|
276
|
+
|
|
277
|
+
// Align backend flow from step 0 with initialize_session
|
|
278
|
+
try {
|
|
279
|
+
const templateId = chooseTemplateId(templateWithReviewAndVerification);
|
|
280
|
+
await kycService.verificationSession({
|
|
281
|
+
session_id: session.session_id,
|
|
282
|
+
step: 0,
|
|
283
|
+
data: { template_id: templateId, metadata: { language: initialLanguage } },
|
|
284
|
+
templateId: templateId,
|
|
285
|
+
token: token,
|
|
286
|
+
action: 'initialize_session'
|
|
287
|
+
});
|
|
288
|
+
} catch (e) {
|
|
289
|
+
console.error('Error initializing session:', JSON.stringify(e, null, 2));
|
|
290
|
+
// Non-fatal: we will surface errors via state below if needed
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
setState(prev => ({
|
|
294
|
+
...prev,
|
|
295
|
+
session: {
|
|
296
|
+
...prev.session,
|
|
297
|
+
session_id: session.session_id,
|
|
298
|
+
token: token,
|
|
299
|
+
isInitialized: true,
|
|
300
|
+
isProcessing: false,
|
|
301
|
+
error: null,
|
|
302
|
+
}
|
|
303
|
+
}));
|
|
304
|
+
} catch (error) {
|
|
305
|
+
|
|
306
|
+
console.error('Error initializing session:', JSON.stringify(error, null, 2));
|
|
307
|
+
setState(prev => ({
|
|
308
|
+
...prev,
|
|
309
|
+
session: {
|
|
310
|
+
...prev.session,
|
|
311
|
+
isInitialized: false,
|
|
312
|
+
isProcessing: false,
|
|
313
|
+
error: "Erreur lors de l'initialisation de la session",
|
|
314
|
+
},
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
}, []);
|
|
101
318
|
// Validation d'un composant
|
|
102
319
|
const validateComponent = useCallback((componentId: number): boolean => {
|
|
103
|
-
const component = template.components.find(c => c.id === componentId);
|
|
320
|
+
const component = state.template.components.find(c => c.id === componentId);
|
|
104
321
|
if (!component) return false;
|
|
105
322
|
|
|
106
323
|
const componentData = state.componentData[componentId];
|
|
107
|
-
|
|
324
|
+
|
|
108
325
|
switch (component.type) {
|
|
109
326
|
case 'id_card':
|
|
110
327
|
// Vérifier si au moins un côté a été capturé
|
|
111
328
|
return componentData && Object.keys(componentData).length > 0;
|
|
112
|
-
|
|
329
|
+
|
|
113
330
|
case 'selfie':
|
|
114
331
|
// Vérifier si toutes les orientations ont été capturées
|
|
115
332
|
const config = component.config as any;
|
|
116
333
|
const orientations = config.orientations || ['front'];
|
|
117
334
|
return componentData && orientations.every((orientation: string) => componentData[orientation]);
|
|
118
|
-
|
|
335
|
+
|
|
119
336
|
case 'file_upload':
|
|
120
337
|
// Vérifier si un fichier a été uploadé
|
|
121
338
|
return componentData && componentData.file;
|
|
122
|
-
|
|
339
|
+
|
|
123
340
|
case 'location':
|
|
124
341
|
// Vérifier si la localisation a été obtenue
|
|
125
342
|
return componentData && componentData.latitude && componentData.longitude;
|
|
126
|
-
|
|
343
|
+
|
|
127
344
|
case 'country_selection':
|
|
128
345
|
// Vérifier si un pays a été sélectionné
|
|
129
|
-
|
|
130
|
-
|
|
346
|
+
console.log("componentData", truncateFields(componentData), componentId);
|
|
347
|
+
|
|
348
|
+
return componentData && componentData.code && componentData.regionMapping;
|
|
349
|
+
|
|
350
|
+
case 'review_submit':
|
|
351
|
+
return true;
|
|
131
352
|
default:
|
|
132
353
|
return false;
|
|
133
354
|
}
|
|
134
|
-
}, [template.components, state.componentData]);
|
|
355
|
+
}, [state.template.components, state.componentData]);
|
|
135
356
|
|
|
136
357
|
// Actions du flux
|
|
137
358
|
const actions: TemplateActions = {
|
|
138
359
|
// Initialiser le template
|
|
139
360
|
initializeTemplate: useCallback((newTemplate: KYCTemplate) => {
|
|
361
|
+
const withReview = ensureReviewSubmitStep(newTemplate);
|
|
362
|
+
const withVerification = ensureVerificationProgressStep(withReview);
|
|
140
363
|
setState(prev => ({
|
|
141
364
|
...prev,
|
|
142
|
-
template:
|
|
365
|
+
template: withVerification,
|
|
143
366
|
currentComponentIndex: 0,
|
|
144
367
|
completedComponents: [],
|
|
145
368
|
componentData: {},
|
|
146
369
|
errors: {},
|
|
147
370
|
isProcessing: false,
|
|
371
|
+
verification: { status: 'idle', result: undefined },
|
|
148
372
|
}));
|
|
149
|
-
}, []),
|
|
373
|
+
}, [ensureReviewSubmitStep, ensureVerificationProgressStep]),
|
|
150
374
|
|
|
151
375
|
// Passer au composant suivant
|
|
152
|
-
nextComponent: useCallback(() => {
|
|
376
|
+
nextComponent: useCallback(async () => {
|
|
153
377
|
if (!canGoNext) return;
|
|
154
378
|
|
|
155
|
-
const currentComp = template.components[state.currentComponentIndex];
|
|
379
|
+
const currentComp = state.template.components[state.currentComponentIndex];
|
|
156
380
|
if (!currentComp) return;
|
|
157
381
|
|
|
382
|
+
setState(prev => ({
|
|
383
|
+
...prev,
|
|
384
|
+
isProcessing: true,
|
|
385
|
+
}));
|
|
158
386
|
// Valider le composant actuel
|
|
159
387
|
if (!validateComponent(currentComp.id)) {
|
|
160
388
|
setState(prev => ({
|
|
161
389
|
...prev,
|
|
390
|
+
isProcessing: false,
|
|
162
391
|
errors: {
|
|
163
392
|
...prev.errors,
|
|
164
|
-
[currentComp.id]: 'Veuillez compléter cette étape avant de continuer'
|
|
393
|
+
[currentComp.id]: state.currentLanguage === "en" ? "please complete this step before move on" : " 'Veuillez compléter cette étape avant de continuer'"
|
|
165
394
|
}
|
|
166
395
|
}));
|
|
167
396
|
return;
|
|
397
|
+
|
|
168
398
|
}
|
|
169
399
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
400
|
+
try {
|
|
401
|
+
const component = state.template.components.find(c => c.id === currentComp.id);
|
|
402
|
+
if (!component) return;
|
|
403
|
+
if (component.type === 'review_submit') {
|
|
404
|
+
// Move to verification screen and mark verification in progress
|
|
405
|
+
setState(prev => ({
|
|
406
|
+
...prev,
|
|
407
|
+
currentComponentIndex: prev.currentComponentIndex + 1,
|
|
408
|
+
completedComponents: [...prev.completedComponents, currentComp.id],
|
|
409
|
+
isProcessing: false,
|
|
410
|
+
verification: { status: 'in_progress' },
|
|
411
|
+
errors: {
|
|
412
|
+
...prev.errors,
|
|
413
|
+
[currentComp.id]: ''
|
|
414
|
+
}
|
|
415
|
+
}));
|
|
416
|
+
return;
|
|
178
417
|
}
|
|
179
|
-
|
|
418
|
+
// Determine backend action and step index
|
|
419
|
+
const action = mapComponentTypeToAction(component.type);
|
|
420
|
+
const templateId = chooseTemplateId(state.template);
|
|
421
|
+
const serverStep = computeServerStepIndex(state.template, state.currentComponentIndex);
|
|
422
|
+
|
|
423
|
+
// Optionally send initialize_session at step 0 before first actionable action
|
|
424
|
+
if (serverStep === 0) {
|
|
425
|
+
try {
|
|
426
|
+
// await kycService.verificationSession({
|
|
427
|
+
// sessionId: state.session.session_id,
|
|
428
|
+
// step: 0,
|
|
429
|
+
// data: { template_id: templateId, metadata: { language: state.currentLanguage } },
|
|
430
|
+
// templateId: templateId,
|
|
431
|
+
// token: state.session.token,
|
|
432
|
+
// action: 'initialize_session'
|
|
433
|
+
// });
|
|
434
|
+
} catch (e) {
|
|
435
|
+
// if init fails, surface error below in the main call handling
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Skip UI-only and data-only steps that have no backend action
|
|
440
|
+
if (!action) {
|
|
441
|
+
setState(prev => ({
|
|
442
|
+
...prev,
|
|
443
|
+
currentComponentIndex: prev.currentComponentIndex + 1,
|
|
444
|
+
completedComponents: [...prev.completedComponents, currentComp.id],
|
|
445
|
+
isProcessing: false,
|
|
446
|
+
errors: {
|
|
447
|
+
...prev.errors,
|
|
448
|
+
[currentComp.id]: ''
|
|
449
|
+
}
|
|
450
|
+
}));
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const step = serverStep === 0 && action !== 'initialize_session' ? 1 : serverStep;
|
|
455
|
+
// Build payload data per action
|
|
456
|
+
const payloadData = buildPayloadForComponent(action, component, state.componentData[currentComp.id], templateId, step);
|
|
457
|
+
|
|
458
|
+
await kycService.verificationSession({
|
|
459
|
+
session_id: state.session.session_id,
|
|
460
|
+
step: step,
|
|
461
|
+
data: payloadData,
|
|
462
|
+
templateId: null,
|
|
463
|
+
token: state.session.token,
|
|
464
|
+
action: action
|
|
465
|
+
});
|
|
466
|
+
console.log("currentComp state", truncateFields(state));
|
|
467
|
+
// Marquer comme complété et passer au suivant
|
|
468
|
+
setState(prev => ({
|
|
469
|
+
...prev,
|
|
470
|
+
currentComponentIndex: prev.currentComponentIndex + 1,
|
|
471
|
+
completedComponents: [...prev.completedComponents, currentComp.id],
|
|
472
|
+
isProcessing: false,
|
|
473
|
+
...(action === "location_permission" ? { permissionGranted: true } : {}),
|
|
474
|
+
errors: {
|
|
475
|
+
...prev.errors,
|
|
476
|
+
[currentComp.id]: ''
|
|
477
|
+
}
|
|
478
|
+
}));
|
|
180
479
|
|
|
480
|
+
} catch (error) {
|
|
481
|
+
// console.error('Error validating component:', error);
|
|
482
|
+
setState(prev => ({
|
|
483
|
+
...prev,
|
|
484
|
+
isProcessing: false,
|
|
485
|
+
errors: {
|
|
486
|
+
...prev.errors,
|
|
487
|
+
[currentComp.id]: 'Erreur lors de la validation du composant'
|
|
488
|
+
}
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
181
491
|
|
|
182
|
-
}, [canGoNext, state.currentComponentIndex, template.components, validateComponent]),
|
|
492
|
+
}, [canGoNext, state.currentComponentIndex, state.template.components, validateComponent]),
|
|
183
493
|
|
|
184
494
|
// Retourner au composant précédent
|
|
185
495
|
previousComponent: useCallback(() => {
|
|
@@ -193,17 +503,19 @@ export const useTemplateKYCFlow = (
|
|
|
193
503
|
|
|
194
504
|
// Aller à un composant spécifique
|
|
195
505
|
goToComponent: useCallback((componentId: number) => {
|
|
196
|
-
const componentIndex = template.components.findIndex(c => c.id === componentId);
|
|
506
|
+
const componentIndex = state.template.components.findIndex(c => c.id === componentId);
|
|
197
507
|
if (componentIndex !== -1) {
|
|
198
508
|
setState(prev => ({
|
|
199
509
|
...prev,
|
|
200
510
|
currentComponentIndex: componentIndex,
|
|
201
511
|
}));
|
|
202
512
|
}
|
|
203
|
-
}, [template.components]),
|
|
513
|
+
}, [state.template.components]),
|
|
204
514
|
|
|
205
515
|
// Mettre à jour les données d'un composant
|
|
206
516
|
updateComponentData: useCallback((componentId: number, data: any) => {
|
|
517
|
+
console.log("updateComponentData", componentId, truncateFields(data));
|
|
518
|
+
|
|
207
519
|
setState(prev => ({
|
|
208
520
|
...prev,
|
|
209
521
|
componentData: {
|
|
@@ -215,7 +527,7 @@ export const useTemplateKYCFlow = (
|
|
|
215
527
|
[componentId]: ''
|
|
216
528
|
}
|
|
217
529
|
}));
|
|
218
|
-
|
|
530
|
+
|
|
219
531
|
}, []),
|
|
220
532
|
|
|
221
533
|
// Valider un composant
|
|
@@ -225,7 +537,12 @@ export const useTemplateKYCFlow = (
|
|
|
225
537
|
|
|
226
538
|
// Soumettre le template complet
|
|
227
539
|
submitTemplate: useCallback(async () => {
|
|
228
|
-
|
|
540
|
+
// Allow submission when on the review step and all previous steps are valid
|
|
541
|
+
const atReview = state.template.components[state.currentComponentIndex]?.type === 'review_submit';
|
|
542
|
+
const allValid = state.template.components
|
|
543
|
+
.filter(c => c.type !== 'review_submit')
|
|
544
|
+
.every(comp => validateComponent(comp.id));
|
|
545
|
+
if (!(atReview && allValid)) {
|
|
229
546
|
onError?.('Le flux KYC n\'est pas encore terminé');
|
|
230
547
|
return;
|
|
231
548
|
}
|
|
@@ -233,22 +550,18 @@ export const useTemplateKYCFlow = (
|
|
|
233
550
|
setState(prev => ({ ...prev, isProcessing: true }));
|
|
234
551
|
|
|
235
552
|
try {
|
|
236
|
-
// Vérifier que tous les composants sont validés
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (!allValid) {
|
|
240
|
-
throw new Error('Certaines étapes ne sont pas complètes');
|
|
241
|
-
}
|
|
553
|
+
// Vérifier que tous les composants (hors review) sont validés
|
|
554
|
+
if (!allValid) throw new Error('Certaines étapes ne sont pas complètes');
|
|
242
555
|
|
|
243
556
|
// Appeler le callback de completion
|
|
244
557
|
onComplete?.(state.componentData);
|
|
245
|
-
|
|
558
|
+
|
|
246
559
|
setState(prev => ({ ...prev, isProcessing: false }));
|
|
247
560
|
} catch (error) {
|
|
248
561
|
setState(prev => ({ ...prev, isProcessing: false }));
|
|
249
562
|
onError?.(error instanceof Error ? error.message : 'Erreur lors de la soumission');
|
|
250
563
|
}
|
|
251
|
-
}, [
|
|
564
|
+
}, [state.template.components, state.currentComponentIndex, validateComponent, state.componentData, onComplete, onError]),
|
|
252
565
|
|
|
253
566
|
// Réinitialiser le template
|
|
254
567
|
resetTemplate: useCallback(() => {
|
|
@@ -259,6 +572,7 @@ export const useTemplateKYCFlow = (
|
|
|
259
572
|
componentData: {},
|
|
260
573
|
errors: {},
|
|
261
574
|
isProcessing: false,
|
|
575
|
+
verification: { status: 'idle', result: undefined },
|
|
262
576
|
}));
|
|
263
577
|
}, []),
|
|
264
578
|
|
|
@@ -277,6 +591,13 @@ export const useTemplateKYCFlow = (
|
|
|
277
591
|
showCustomStepper: show,
|
|
278
592
|
}));
|
|
279
593
|
}, []),
|
|
594
|
+
|
|
595
|
+
setVerificationState: useCallback((verificationState) => {
|
|
596
|
+
setState(prev => ({
|
|
597
|
+
...prev,
|
|
598
|
+
verification: verificationState,
|
|
599
|
+
}));
|
|
600
|
+
}, []),
|
|
280
601
|
};
|
|
281
602
|
|
|
282
603
|
return {
|
|
@@ -288,5 +609,6 @@ export const useTemplateKYCFlow = (
|
|
|
288
609
|
canGoPrevious,
|
|
289
610
|
isComplete,
|
|
290
611
|
getLocalizedText,
|
|
612
|
+
initializeSession,
|
|
291
613
|
};
|
|
292
614
|
};
|