@transfergratis/react-native-sdk 0.1.23 → 0.1.25
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/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +12 -5
- 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/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- 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 +61 -59
- 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 +12 -5
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.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 +26 -34
- package/android/src/main/AndroidManifest.xml +13 -5
- package/build/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.js +26 -3
- package/build/components/EnhancedCameraView.js.map +1 -1
- package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.web.js +21 -0
- package/build/components/EnhancedCameraView.web.js.map +1 -1
- package/build/components/KYCElements/AdditionalDocumentsTemplate.d.ts +12 -0
- package/build/components/KYCElements/AdditionalDocumentsTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/AdditionalDocumentsTemplate.js +283 -0
- package/build/components/KYCElements/AdditionalDocumentsTemplate.js.map +1 -0
- package/build/components/KYCElements/CameraCapture.d.ts.map +1 -1
- package/build/components/KYCElements/CameraCapture.js +4 -3
- package/build/components/KYCElements/CameraCapture.js.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts +5 -2
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.js +360 -101
- package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
- package/build/components/KYCElements/EmailVerificationTemplate.d.ts +12 -0
- package/build/components/KYCElements/EmailVerificationTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/EmailVerificationTemplate.js +193 -0
- package/build/components/KYCElements/EmailVerificationTemplate.js.map +1 -0
- package/build/components/KYCElements/FileUpload.d.ts.map +1 -1
- package/build/components/KYCElements/FileUpload.js +5 -4
- package/build/components/KYCElements/FileUpload.js.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.js +5 -4
- package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
- package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/components/KYCElements/IDCardCapture.js +356 -227
- package/build/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/LocationCaptureTemplate.js +78 -37
- package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -0
- package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.js +5 -4
- package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -0
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js +5 -4
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -0
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.js +5 -4
- package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
- package/build/components/KYCElements/PersonalInformationTemplate.d.ts +12 -0
- package/build/components/KYCElements/PersonalInformationTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/PersonalInformationTemplate.js +120 -0
- package/build/components/KYCElements/PersonalInformationTemplate.js.map +1 -0
- package/build/components/KYCElements/PhoneVerificationTemplate.d.ts +12 -0
- package/build/components/KYCElements/PhoneVerificationTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/PhoneVerificationTemplate.js +185 -0
- package/build/components/KYCElements/PhoneVerificationTemplate.js.map +1 -0
- package/build/components/KYCElements/SelfieCapture.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCapture.js +4 -3
- package/build/components/KYCElements/SelfieCapture.js.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.js +189 -42
- package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/WelcomeTemplate.d.ts +12 -0
- package/build/components/KYCElements/WelcomeTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/WelcomeTemplate.js +243 -0
- package/build/components/KYCElements/WelcomeTemplate.js.map +1 -0
- package/build/components/TemplateKYCExample.d.ts +8 -2
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js +10 -97
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts +6 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +108 -11
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/components/example/DynamicTemplateExample.d.ts +10 -0
- package/build/components/example/DynamicTemplateExample.d.ts.map +1 -0
- package/build/components/example/DynamicTemplateExample.js +241 -0
- package/build/components/example/DynamicTemplateExample.js.map +1 -0
- package/build/config/KYCConfig.d.ts +14 -0
- package/build/config/KYCConfig.d.ts.map +1 -0
- package/build/config/KYCConfig.js +26 -0
- package/build/config/KYCConfig.js.map +1 -0
- package/build/config/allowedDomains.d.ts +30 -0
- package/build/config/allowedDomains.d.ts.map +1 -0
- package/build/config/allowedDomains.js +112 -0
- package/build/config/allowedDomains.js.map +1 -0
- package/build/hooks/useOrientationVideo.d.ts +2 -1
- package/build/hooks/useOrientationVideo.d.ts.map +1 -1
- package/build/hooks/useOrientationVideo.js +3 -3
- package/build/hooks/useOrientationVideo.js.map +1 -1
- package/build/hooks/useTemplateKYCFlow.d.ts +6 -1
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +317 -34
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/hooks/useTemplateLoader.d.ts +14 -0
- package/build/hooks/useTemplateLoader.d.ts.map +1 -0
- package/build/hooks/useTemplateLoader.js +85 -0
- package/build/hooks/useTemplateLoader.js.map +1 -0
- package/build/i18n/en/index.d.ts +49 -0
- package/build/i18n/en/index.d.ts.map +1 -1
- package/build/i18n/en/index.js +50 -1
- package/build/i18n/en/index.js.map +1 -1
- package/build/i18n/fr/index.d.ts +35 -0
- package/build/i18n/fr/index.d.ts.map +1 -1
- package/build/i18n/fr/index.js +36 -1
- package/build/i18n/fr/index.js.map +1 -1
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/modules/api/CardAuthentification.d.ts +24 -3
- package/build/modules/api/CardAuthentification.d.ts.map +1 -1
- package/build/modules/api/CardAuthentification.js +69 -10
- package/build/modules/api/CardAuthentification.js.map +1 -1
- package/build/modules/api/KYCService.d.ts +7 -7
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +108 -39
- package/build/modules/api/KYCService.js.map +1 -1
- package/build/modules/api/SelfieVerification.d.ts +3 -1
- package/build/modules/api/SelfieVerification.d.ts.map +1 -1
- package/build/modules/api/SelfieVerification.js +17 -1
- package/build/modules/api/SelfieVerification.js.map +1 -1
- package/build/modules/api/TemplateService.d.ts +44 -0
- package/build/modules/api/TemplateService.d.ts.map +1 -0
- package/build/modules/api/TemplateService.js +145 -0
- package/build/modules/api/TemplateService.js.map +1 -0
- package/build/types/KYC.types.d.ts +265 -4
- package/build/types/KYC.types.d.ts.map +1 -1
- package/build/types/KYC.types.js +15 -0
- package/build/types/KYC.types.js.map +1 -1
- package/build/types/env.types.d.ts +13 -0
- package/build/types/env.types.d.ts.map +1 -0
- package/build/types/env.types.js +2 -0
- package/build/types/env.types.js.map +1 -0
- package/build/utils/cropByObb.d.ts +1 -0
- package/build/utils/cropByObb.d.ts.map +1 -1
- package/build/utils/cropByObb.js +70 -0
- package/build/utils/cropByObb.js.map +1 -1
- package/build/utils/deviceDetection.d.ts +6 -0
- package/build/utils/deviceDetection.d.ts.map +1 -0
- package/build/utils/deviceDetection.js +12 -0
- package/build/utils/deviceDetection.js.map +1 -0
- package/build/utils/platformAlert.d.ts +20 -0
- package/build/utils/platformAlert.d.ts.map +1 -0
- package/build/utils/platformAlert.js +67 -0
- package/build/utils/platformAlert.js.map +1 -0
- package/build/utils/template-transformer.d.ts +10 -0
- package/build/utils/template-transformer.d.ts.map +1 -0
- package/build/utils/template-transformer.js +365 -0
- package/build/utils/template-transformer.js.map +1 -0
- package/build/web/WebKYCEntry.d.ts.map +1 -1
- package/build/web/WebKYCEntry.js +158 -32
- package/build/web/WebKYCEntry.js.map +1 -1
- package/package.json +1 -1
- package/plugin/build/withVisionCamera.js +3 -4
- package/plugin/src/withVisionCamera.js +3 -4
- package/plugin/src/withVisionCamera.ts +3 -4
- package/src/components/EnhancedCameraView.tsx +31 -2
- package/src/components/EnhancedCameraView.web.tsx +24 -0
- package/src/components/KYCElements/AdditionalDocumentsTemplate.tsx +346 -0
- package/src/components/KYCElements/CameraCapture.tsx +4 -3
- package/src/components/KYCElements/CountrySelectionTemplate.tsx +410 -113
- package/src/components/KYCElements/EmailVerificationTemplate.tsx +264 -0
- package/src/components/KYCElements/FileUpload.tsx +5 -4
- package/src/components/KYCElements/FileUploadTemplate.tsx +5 -4
- package/src/components/KYCElements/IDCardCapture.tsx +397 -254
- package/src/components/KYCElements/LocationCaptureTemplate.tsx +95 -44
- package/src/components/KYCElements/OrientationVideoCapture.tsx +6 -3
- package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +6 -3
- package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +6 -3
- package/src/components/KYCElements/PersonalInformationTemplate.tsx +158 -0
- package/src/components/KYCElements/PhoneVerificationTemplate.tsx +253 -0
- package/src/components/KYCElements/SelfieCapture.tsx +4 -3
- package/src/components/KYCElements/SelfieCaptureTemplate.tsx +201 -44
- package/src/components/KYCElements/WelcomeTemplate.tsx +289 -0
- package/src/components/TemplateKYCExample.tsx +37 -108
- package/src/components/TemplateKYCFlowRefactored.tsx +148 -12
- package/src/components/example/DynamicTemplateExample.tsx +289 -0
- package/src/config/KYCConfig.ts +34 -0
- package/src/config/allowedDomains.ts +133 -0
- package/src/hooks/useOrientationVideo.ts +5 -4
- package/src/hooks/useTemplateKYCFlow.tsx +347 -32
- package/src/hooks/useTemplateLoader.ts +102 -0
- package/src/i18n/en/index.ts +53 -2
- package/src/i18n/fr/index.ts +37 -1
- package/src/index.ts +14 -0
- package/src/modules/api/CardAuthentification.ts +76 -11
- package/src/modules/api/KYCService.ts +129 -45
- package/src/modules/api/SelfieVerification.ts +25 -3
- package/src/modules/api/TemplateService.ts +167 -0
- package/src/types/KYC.types.ts +331 -3
- package/src/types/env.types.ts +13 -0
- package/src/utils/cropByObb.ts +83 -3
- package/src/utils/deviceDetection.ts +11 -0
- package/src/utils/platformAlert.ts +86 -0
- package/src/utils/template-transformer.ts +445 -0
- package/src/web/WebKYCEntry.tsx +199 -50
package/src/i18n/en/index.ts
CHANGED
|
@@ -15,6 +15,19 @@ export const en = {
|
|
|
15
15
|
success: 'Success',
|
|
16
16
|
warning: 'Warning',
|
|
17
17
|
info: 'Information',
|
|
18
|
+
invalidCode: 'Invalid code',
|
|
19
|
+
resendCode: 'Resend code',
|
|
20
|
+
verify: 'Verify',
|
|
21
|
+
sendCode: 'Send code',
|
|
22
|
+
resend: 'Resend',
|
|
23
|
+
email: 'Email',
|
|
24
|
+
otp: 'OTP',
|
|
25
|
+
verificationCode: 'Verification code',
|
|
26
|
+
changeEmail: 'Change Email',
|
|
27
|
+
processing: "Processing",
|
|
28
|
+
codeResent: 'Code Resent',
|
|
29
|
+
codeResentMessage: 'Code resent to %{email}',
|
|
30
|
+
phone: 'Phone number with country code',
|
|
18
31
|
},
|
|
19
32
|
|
|
20
33
|
// KYC Flow
|
|
@@ -22,7 +35,22 @@ export const en = {
|
|
|
22
35
|
title: 'Identity Verification',
|
|
23
36
|
subtitle: 'Complete your identity verification to continue',
|
|
24
37
|
step: 'Step %{current} of %{total}',
|
|
25
|
-
|
|
38
|
+
enterCodeSent: "Enter code sent",
|
|
39
|
+
|
|
40
|
+
additionalDocs: {
|
|
41
|
+
title: 'Additional Documents',
|
|
42
|
+
add: "Press to select file",
|
|
43
|
+
subtitle: 'Upload additional documents to complete your identity verification',
|
|
44
|
+
uploadButton: 'Upload',
|
|
45
|
+
uploadButtonText: 'Upload',
|
|
46
|
+
uploadSubtext: 'Upload a clear photo of your document',
|
|
47
|
+
supportedFormats: 'Supported formats: JPG, PNG, PDF',
|
|
48
|
+
maxSize: 'Max file size: 10MB',
|
|
49
|
+
processing: 'Processing file...',
|
|
50
|
+
success: 'File uploaded successfully',
|
|
51
|
+
error: 'Failed to upload file. Please try again.'
|
|
52
|
+
},
|
|
53
|
+
|
|
26
54
|
// Initialization
|
|
27
55
|
initialization: {
|
|
28
56
|
title: 'Welcome to Identity Verification',
|
|
@@ -36,6 +64,16 @@ export const en = {
|
|
|
36
64
|
]
|
|
37
65
|
},
|
|
38
66
|
|
|
67
|
+
welcome: {
|
|
68
|
+
requirements: 'What you\'ll need:',
|
|
69
|
+
estimatedTime: 'Estimated time:',
|
|
70
|
+
consent: 'Please accept the following:',
|
|
71
|
+
privacyPolicy: 'I agree to the Privacy Policy',
|
|
72
|
+
termsOfService: 'I agree to the Terms of Service',
|
|
73
|
+
marketingConsent: 'I agree to receive marketing communications',
|
|
74
|
+
readMore: 'Read more'
|
|
75
|
+
},
|
|
76
|
+
|
|
39
77
|
// Location Capture
|
|
40
78
|
locationCapture: {
|
|
41
79
|
title: 'Secure Your Verification',
|
|
@@ -88,6 +126,9 @@ export const en = {
|
|
|
88
126
|
success: 'ID captured successfully',
|
|
89
127
|
error: 'Failed to capture ID. Please try again.',
|
|
90
128
|
captureTitle: '%{side} side of your government document',
|
|
129
|
+
continueOnPhone: 'Continue on Phone',
|
|
130
|
+
continueOnMobile: 'Continue on Mobile',
|
|
131
|
+
scanQrCode: 'Scan this QR code with your phone to continue the verification process.',
|
|
91
132
|
},
|
|
92
133
|
|
|
93
134
|
// Selfie Capture
|
|
@@ -204,7 +245,17 @@ export const en = {
|
|
|
204
245
|
cameraError: 'Camera error. Please try again.',
|
|
205
246
|
fileError: 'File error. Please try again.',
|
|
206
247
|
timeoutError: 'Request timeout. Please try again.',
|
|
207
|
-
unknownError: 'An unknown error occurred. Please try again.'
|
|
248
|
+
unknownError: 'An unknown error occurred. Please try again.',
|
|
249
|
+
wrongCode: "Wrong code",
|
|
250
|
+
invalidCode: "Invalid code",
|
|
251
|
+
invalidEmail: "Invalid email",
|
|
252
|
+
invalidPhone: "Invalid phone",
|
|
253
|
+
invalidDate: "Invalid date",
|
|
254
|
+
minLength: "Min length",
|
|
255
|
+
maxLength: "Max length",
|
|
256
|
+
invalidFormat: "Invalid format",
|
|
257
|
+
fileTooLarge: "File too large",
|
|
258
|
+
fileTypeNotSupported: "File type not supported",
|
|
208
259
|
},
|
|
209
260
|
|
|
210
261
|
// Validation messages
|
package/src/i18n/fr/index.ts
CHANGED
|
@@ -15,6 +15,20 @@ export const fr = {
|
|
|
15
15
|
success: 'Succès',
|
|
16
16
|
warning: 'Avertissement',
|
|
17
17
|
info: 'Information',
|
|
18
|
+
invalidCode: 'Code invalide',
|
|
19
|
+
resendCode: 'Renvoyer le code',
|
|
20
|
+
verify: 'Vérifier',
|
|
21
|
+
sendCode: 'Envoyer le code',
|
|
22
|
+
resend: 'Renvoyer',
|
|
23
|
+
email: 'Email',
|
|
24
|
+
otp: 'OTP',
|
|
25
|
+
verificationCode: 'Code de vérification',
|
|
26
|
+
changeEmail: 'Changer d\'email',
|
|
27
|
+
processing: "Traitement",
|
|
28
|
+
codeResent: 'Code Renvoyé',
|
|
29
|
+
codeResentMessage: 'Code renvoyé à %{email}',
|
|
30
|
+
phone: 'Numéro de téléphone avec code pays',
|
|
31
|
+
|
|
18
32
|
},
|
|
19
33
|
|
|
20
34
|
// KYC Flow
|
|
@@ -35,6 +49,15 @@ export const fr = {
|
|
|
35
49
|
'Une connexion internet stable'
|
|
36
50
|
]
|
|
37
51
|
},
|
|
52
|
+
welcome: {
|
|
53
|
+
requirements: 'Ce dont vous aurez besoin :',
|
|
54
|
+
estimatedTime: 'Temps estimé :',
|
|
55
|
+
consent: 'Veuillez accepter les suivants :',
|
|
56
|
+
privacyPolicy: 'J\'accepte la Politique de Confidentialité',
|
|
57
|
+
termsOfService: 'J\'accepte les Conditions d\'Utilisation',
|
|
58
|
+
marketingConsent: 'J\'accepte de recevoir des communications marketing',
|
|
59
|
+
readMore: 'Lire plus'
|
|
60
|
+
},
|
|
38
61
|
|
|
39
62
|
// Location Capture
|
|
40
63
|
locationCapture: {
|
|
@@ -88,6 +111,9 @@ export const fr = {
|
|
|
88
111
|
success: 'Document d\'identité capturé avec succès',
|
|
89
112
|
error: 'Échec de la capture du document. Veuillez réessayer.',
|
|
90
113
|
captureTitle: '%{side} de votre document d\'identité',
|
|
114
|
+
continueOnPhone: 'Continuer sur mobile',
|
|
115
|
+
continueOnMobile: 'Continuer sur mobile',
|
|
116
|
+
scanQrCode: 'Scannez ce code QR avec votre téléphone pour continuer la vérification.',
|
|
91
117
|
},
|
|
92
118
|
|
|
93
119
|
// Selfie Capture
|
|
@@ -204,7 +230,17 @@ export const fr = {
|
|
|
204
230
|
cameraError: 'Erreur caméra. Veuillez réessayer.',
|
|
205
231
|
fileError: 'Erreur fichier. Veuillez réessayer.',
|
|
206
232
|
timeoutError: 'Délai d\'attente dépassé. Veuillez réessayer.',
|
|
207
|
-
unknownError: 'Une erreur inconnue s\'est produite. Veuillez réessayer.'
|
|
233
|
+
unknownError: 'Une erreur inconnue s\'est produite. Veuillez réessayer.',
|
|
234
|
+
wrongCode: "Wrong code",
|
|
235
|
+
invalidCode: "Invalid code",
|
|
236
|
+
invalidEmail: "Invalid email",
|
|
237
|
+
invalidPhone: "Invalid phone",
|
|
238
|
+
invalidDate: "Invalid date",
|
|
239
|
+
minLength: "Min length",
|
|
240
|
+
maxLength: "Max length",
|
|
241
|
+
invalidFormat: "Invalid format",
|
|
242
|
+
fileTooLarge: "File too large",
|
|
243
|
+
fileTypeNotSupported: "File type not supported",
|
|
208
244
|
},
|
|
209
245
|
|
|
210
246
|
validation: {
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,22 @@ export * from './TransfergratisSdk.types';
|
|
|
4
4
|
// Export KYC types
|
|
5
5
|
export * from './types/KYC.types';
|
|
6
6
|
|
|
7
|
+
// Export Environment types
|
|
8
|
+
export * from './types/env.types';
|
|
9
|
+
|
|
7
10
|
|
|
8
11
|
export { TemplateKYCExample as LauchTransferGratisKYC } from './components/TemplateKYCExample';
|
|
9
12
|
|
|
13
|
+
// Export Template Flow Components
|
|
14
|
+
export { TemplateKYCFlow } from './components/TemplateKYCFlowRefactored';
|
|
15
|
+
|
|
16
|
+
// Export Template Service and Utilities
|
|
17
|
+
export { default as templateService } from './modules/api/TemplateService';
|
|
18
|
+
export { transformBackendTemplateToSDK, validateTransformedTemplate } from './utils/template-transformer';
|
|
19
|
+
export { useTemplateLoader } from './hooks/useTemplateLoader';
|
|
20
|
+
|
|
21
|
+
// Export Template Components
|
|
22
|
+
export { WelcomeTemplate } from './components/KYCElements/WelcomeTemplate';
|
|
23
|
+
|
|
10
24
|
// Export Web KYC Components
|
|
11
25
|
export { WebKYCEntry } from './web';
|
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import kycService, { authentification, errorMessage, truncateFields } from "./KYCService";
|
|
2
2
|
import { cropByObb } from "../../utils/cropByObb";
|
|
3
3
|
import { GovernmentDocumentType, IBbox } from "../../types/KYC.types";
|
|
4
|
+
import { KycEnvironment } from "../../types/env.types";
|
|
4
5
|
import { logger } from "../../utils/logger";
|
|
5
6
|
|
|
6
|
-
export async function frontVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string, mrzType?: string }) {
|
|
7
|
+
export async function frontVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string, mrzType?: string }, env: KycEnvironment = 'PRODUCTION') {
|
|
7
8
|
try {
|
|
8
|
-
|
|
9
|
+
console.log("Front verification START", JSON.stringify({ result }, null, 2));
|
|
9
10
|
logger.log("Front verification", JSON.stringify({ result }, null, 2));
|
|
11
|
+
|
|
12
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
13
|
+
if (env === 'SANDBOX') {
|
|
14
|
+
console.log("SANDBOX mode: Skipping AI verification for front document");
|
|
15
|
+
logger.log("SANDBOX mode: Returning mock front verification response");
|
|
16
|
+
const mockBbox: IBbox = { minX: 50, minY: 50, width: 200, height: 200 };
|
|
17
|
+
const mockResponse = {
|
|
18
|
+
result: true,
|
|
19
|
+
detail: [{ confidence: 0.95 }],
|
|
20
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 },
|
|
21
|
+
bbox: mockBbox,
|
|
22
|
+
...(result.regionMapping.authMethod.includes('MRZ') ? {
|
|
23
|
+
mrz: {
|
|
24
|
+
success: true,
|
|
25
|
+
parsed_data: {
|
|
26
|
+
status: 'success',
|
|
27
|
+
document_type: result.selectedDocumentType,
|
|
28
|
+
mrz_type: result.mrzType || 'TD1'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} : {})
|
|
32
|
+
};
|
|
33
|
+
return mockResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
10
36
|
const token = await authentification();
|
|
11
|
-
const detected = await kycService.detectFaceOnId(result?.path || '', token, result?.selectedDocumentType || '')
|
|
37
|
+
const detected = await kycService.detectFaceOnId(result?.path || '', token, result?.selectedDocumentType || '', env)
|
|
12
38
|
|
|
13
39
|
if (!detected.result) {
|
|
14
40
|
throw new Error('Aucun visage détecté sur la carte. Veuillez reprendre.');
|
|
@@ -36,7 +62,8 @@ export async function frontVerification(result: { path?: string, regionMapping:
|
|
|
36
62
|
token: token,
|
|
37
63
|
template_path: result?.templatePath || '',
|
|
38
64
|
mrz_type: result?.mrzType || ''
|
|
39
|
-
}
|
|
65
|
+
},
|
|
66
|
+
env)
|
|
40
67
|
|
|
41
68
|
}
|
|
42
69
|
|
|
@@ -47,10 +74,38 @@ export async function frontVerification(result: { path?: string, regionMapping:
|
|
|
47
74
|
}
|
|
48
75
|
}
|
|
49
76
|
|
|
50
|
-
export async function backVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string, mrzType?: string }) {
|
|
77
|
+
export async function backVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string, mrzType?: string }, env: KycEnvironment = 'PRODUCTION') {
|
|
51
78
|
try {
|
|
52
79
|
if (!result.path) throw new Error('No path provided');
|
|
53
80
|
logger.log("result.regionMapping", result.regionMapping, result.currentSide, result.code);
|
|
81
|
+
|
|
82
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
83
|
+
if (env === 'SANDBOX') {
|
|
84
|
+
console.log("SANDBOX mode: Skipping AI verification for back document");
|
|
85
|
+
logger.log("SANDBOX mode: Returning mock back verification response");
|
|
86
|
+
const mockBbox: IBbox = { minX: 50, minY: 50, width: 200, height: 200 };
|
|
87
|
+
|
|
88
|
+
if (result.regionMapping.authMethod.includes('MRZ')) {
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
parsed_data: {
|
|
92
|
+
status: 'success',
|
|
93
|
+
document_type: result.selectedDocumentType,
|
|
94
|
+
mrz_type: result.mrzType || 'TD1'
|
|
95
|
+
},
|
|
96
|
+
bbox: mockBbox,
|
|
97
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
98
|
+
};
|
|
99
|
+
} else if (result.regionMapping.authMethod.includes('2D_barcode')) {
|
|
100
|
+
return {
|
|
101
|
+
barcode_data: 'SANDBOX_MOCK_BARCODE',
|
|
102
|
+
bbox: mockBbox,
|
|
103
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return { bbox: mockBbox };
|
|
107
|
+
}
|
|
108
|
+
|
|
54
109
|
const token = await authentification();
|
|
55
110
|
|
|
56
111
|
|
|
@@ -68,7 +123,7 @@ export async function backVerification(result: { path?: string, regionMapping: {
|
|
|
68
123
|
token: token,
|
|
69
124
|
template_path: result?.templatePath || '',
|
|
70
125
|
mrz_type: result?.mrzType || ''
|
|
71
|
-
});
|
|
126
|
+
}, env);
|
|
72
127
|
let bbox: IBbox | undefined;
|
|
73
128
|
let croppedBase64: string | undefined;
|
|
74
129
|
|
|
@@ -82,7 +137,7 @@ export async function backVerification(result: { path?: string, regionMapping: {
|
|
|
82
137
|
} catch (mrzError: any) {
|
|
83
138
|
logger.log("MRZ échoué, tentative d'extraction barcode");
|
|
84
139
|
try {
|
|
85
|
-
const barcode = await kycService.extractBarcode({ fileUri: result.path!, token: token });
|
|
140
|
+
const barcode = await kycService.extractBarcode({ fileUri: result.path!, token: token }, env);
|
|
86
141
|
return barcode;
|
|
87
142
|
} catch (barcodeError: any) {
|
|
88
143
|
throw new Error(`MRZ et barcode ont échoué. MRZ: ${mrzError?.message}, Barcode: ${barcodeError?.message}`);
|
|
@@ -108,7 +163,7 @@ export async function backVerification(result: { path?: string, regionMapping: {
|
|
|
108
163
|
token: token,
|
|
109
164
|
template_path: result?.templatePath || '',
|
|
110
165
|
mrz_type: result?.mrzType || ''
|
|
111
|
-
});
|
|
166
|
+
}, env);
|
|
112
167
|
let bbox: IBbox | undefined;
|
|
113
168
|
try {
|
|
114
169
|
const crop = await cropByObb(result?.path || '', (mrz as any).card_obb);
|
|
@@ -123,7 +178,7 @@ export async function backVerification(result: { path?: string, regionMapping: {
|
|
|
123
178
|
if (result.regionMapping.authMethod.length > 0 && result.regionMapping.authMethod.includes('2D_barcode')) {
|
|
124
179
|
try {
|
|
125
180
|
logger.log("Tentative d'extraction barcode");
|
|
126
|
-
const barcode = await kycService.extractBarcode({ fileUri: result.path!, token: token });
|
|
181
|
+
const barcode = await kycService.extractBarcode({ fileUri: result.path!, token: token }, env);
|
|
127
182
|
let bbox: IBbox | undefined;
|
|
128
183
|
try {
|
|
129
184
|
const crop = await cropByObb(result?.path || '', (barcode as any).card_obb);
|
|
@@ -145,10 +200,20 @@ export async function backVerification(result: { path?: string, regionMapping: {
|
|
|
145
200
|
* @param result
|
|
146
201
|
* @returns
|
|
147
202
|
*/
|
|
148
|
-
export async function checkTemplateType(result: { path?: string, docType: string, docRegion: string, postfix: string }) {
|
|
203
|
+
export async function checkTemplateType(result: { path?: string, docType: string, docRegion: string, postfix: string }, env: KycEnvironment = 'PRODUCTION') {
|
|
149
204
|
try {
|
|
205
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
206
|
+
if (env === 'SANDBOX') {
|
|
207
|
+
console.log("SANDBOX mode: Skipping AI template type check");
|
|
208
|
+
logger.log("SANDBOX mode: Returning mock template type response");
|
|
209
|
+
return {
|
|
210
|
+
template_path: `templates/${result.docType}_${result.docRegion}_${result.postfix}.jpg`,
|
|
211
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
150
215
|
const token = await authentification();
|
|
151
|
-
const templateType = await kycService.checkTemplateType({ fileUri: result.path || '', docType: result?.docType as GovernmentDocumentType, docRegion: result?.docRegion || "", postfix: result?.postfix, token: token });
|
|
216
|
+
const templateType = await kycService.checkTemplateType({ fileUri: result.path || '', docType: result?.docType as GovernmentDocumentType, docRegion: result?.docRegion || "", postfix: result?.postfix, token: token }, env);
|
|
152
217
|
|
|
153
218
|
logger.log("templateType result", JSON.stringify(truncateFields(templateType), null, 2));
|
|
154
219
|
return templateType;
|
|
@@ -2,7 +2,21 @@ import axios from 'axios';
|
|
|
2
2
|
import { GovernmentDocumentType, GovernmentDocumentTypeShorted, OrientationVideoResponse } from '../../types/KYC.types';
|
|
3
3
|
import { CheckTemplateTypeResponse, ExtractMrzTextResponse } from '../../components/OverLay/type';
|
|
4
4
|
import { SessionResponse, VerificationResult, VerificationSessionRequest } from './types';
|
|
5
|
+
import { KycEnvironment } from '../../types/env.types';
|
|
5
6
|
import { logger } from '../../utils/logger';
|
|
7
|
+
import { Platform } from 'react-native';
|
|
8
|
+
import KYCConfig from '../../config/KYCConfig';
|
|
9
|
+
|
|
10
|
+
const appendFileToFormData = async (formData: FormData, key: string, uri: string, name: string = 'file.jpg', type: string = 'image/jpeg') => {
|
|
11
|
+
if (Platform.OS === 'web') {
|
|
12
|
+
const response = await fetch(uri);
|
|
13
|
+
const blob = await response.blob();
|
|
14
|
+
formData.append(key, blob, name);
|
|
15
|
+
} else {
|
|
16
|
+
formData.append(key, { uri, type, name } as any);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
|
|
7
21
|
export interface KYCRequest {
|
|
8
22
|
userId: string;
|
|
@@ -48,7 +62,6 @@ export class KYCService {
|
|
|
48
62
|
private mrzServiceURL = 'https://kyc-engine.transfergratis.net:8002';
|
|
49
63
|
private barcodeServiceURL = 'https://kyc-engine.transfergratis.net:8000';
|
|
50
64
|
private orientationServiceURL = 'http://18.188.180.154:8080';
|
|
51
|
-
private backendServiceURL = 'https://service.sanctumkey.com/api/v1';
|
|
52
65
|
|
|
53
66
|
constructor(baseURL: string, apiKey: string) {
|
|
54
67
|
this.baseURL = baseURL;
|
|
@@ -120,12 +133,8 @@ export class KYCService {
|
|
|
120
133
|
async processSelfieOrientationPicture(videoFile: string, token: string): Promise<SelfieVideoResponse[]> {
|
|
121
134
|
try {
|
|
122
135
|
const formData = new FormData();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
type: 'image/jpeg',
|
|
126
|
-
name: 'selfie_picture.jpg',
|
|
127
|
-
};
|
|
128
|
-
formData.append('file', rnFile);
|
|
136
|
+
await appendFileToFormData(formData, 'file', videoFile, 'selfie_picture.jpg', 'image/jpeg');
|
|
137
|
+
|
|
129
138
|
const response = await axios.post<SelfieVideoResponse[]>(
|
|
130
139
|
`${this.faceServiceURL}/detect_face_orientation/`,
|
|
131
140
|
formData,
|
|
@@ -141,17 +150,27 @@ export class KYCService {
|
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
async processOrientationVideo(videoFile: string): Promise<OrientationVideoResponse> {
|
|
153
|
+
async processOrientationVideo(videoFile: string, env: KycEnvironment = 'PRODUCTION'): Promise<OrientationVideoResponse> {
|
|
145
154
|
try {
|
|
155
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
156
|
+
if (env === 'SANDBOX') {
|
|
157
|
+
console.log("SANDBOX mode: Skipping AI orientation video processing");
|
|
158
|
+
logger.log("SANDBOX mode: Returning mock orientation video response");
|
|
159
|
+
return {
|
|
160
|
+
success: true,
|
|
161
|
+
data: {
|
|
162
|
+
center: { captured: true, frame: 10 },
|
|
163
|
+
left: { captured: true, frame: 30 },
|
|
164
|
+
right: { captured: true, frame: 50 }
|
|
165
|
+
},
|
|
166
|
+
message: 'SANDBOX: Orientation video processed successfully (mocked)'
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
146
170
|
// Create FormData for multipart/form-data request
|
|
147
171
|
const formData = new FormData();
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
uri: videoFile,
|
|
151
|
-
type: 'video/mp4',
|
|
152
|
-
name: 'orientation_video.mp4',
|
|
153
|
-
};
|
|
154
|
-
formData.append('file', rnFile);
|
|
172
|
+
await appendFileToFormData(formData, 'file', videoFile, 'orientation_video.mp4', 'video/mp4');
|
|
173
|
+
|
|
155
174
|
|
|
156
175
|
const response = await axios.post(
|
|
157
176
|
`${this.orientationServiceURL}/process_orientation_video_stream/`,
|
|
@@ -196,13 +215,25 @@ export class KYCService {
|
|
|
196
215
|
}
|
|
197
216
|
|
|
198
217
|
// STEP 1 - ID CARD VALIDATION
|
|
199
|
-
async detectFaceOnId(idCardImageUri: string, token: string, docType: string): Promise<{ result: boolean, detail: any[] }> {
|
|
218
|
+
async detectFaceOnId(idCardImageUri: string, token: string, docType: string, env: KycEnvironment = 'PRODUCTION'): Promise<{ result: boolean, detail: any[] }> {
|
|
219
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
220
|
+
if (env === 'SANDBOX') {
|
|
221
|
+
console.log("SANDBOX mode: Skipping AI face detection on ID");
|
|
222
|
+
logger.log("SANDBOX mode: Returning mock face detection response");
|
|
223
|
+
return {
|
|
224
|
+
result: true,
|
|
225
|
+
detail: [{ confidence: 0.95, bbox: [50, 50, 200, 200] }],
|
|
226
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
227
|
+
} as any;
|
|
228
|
+
}
|
|
229
|
+
|
|
200
230
|
const formData = new FormData();
|
|
201
|
-
|
|
202
|
-
formData.append('file', rnFile);
|
|
231
|
+
await appendFileToFormData(formData, 'file', idCardImageUri, 'id_card_photo.jpg', 'image/jpeg');
|
|
203
232
|
|
|
204
|
-
|
|
233
|
+
logger.log('detectFaceOnId formData', JSON.stringify(formData, null, 2));
|
|
205
234
|
|
|
235
|
+
const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];
|
|
236
|
+
logger.log('detectFaceOnId docTypeShorted', docTypeShorted);
|
|
206
237
|
try {
|
|
207
238
|
const res = await axios.post(`${this.faceServiceURL}/detect_face/?doc_type=${docTypeShorted}`, formData,
|
|
208
239
|
{
|
|
@@ -220,11 +251,22 @@ export class KYCService {
|
|
|
220
251
|
}
|
|
221
252
|
|
|
222
253
|
//check templatetemplate_type
|
|
223
|
-
async checkTemplateType(params: { fileUri: string; docType: string; docRegion: string; token: string; postfix: string }): Promise<any> {
|
|
254
|
+
async checkTemplateType(params: { fileUri: string; docType: string; docRegion: string; token: string; postfix: string }, env: KycEnvironment = 'PRODUCTION'): Promise<any> {
|
|
255
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
256
|
+
if (env === 'SANDBOX') {
|
|
257
|
+
console.log("SANDBOX mode: Skipping AI template type check");
|
|
258
|
+
logger.log("SANDBOX mode: Returning mock template type response");
|
|
259
|
+
const { docType, docRegion, postfix } = params;
|
|
260
|
+
return {
|
|
261
|
+
template_path: `templates/${docType}_${docRegion}_${postfix}.jpg`,
|
|
262
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
224
266
|
const { fileUri, docType, docRegion, token, postfix } = params;
|
|
225
267
|
const formData = new FormData();
|
|
226
|
-
|
|
227
|
-
|
|
268
|
+
await appendFileToFormData(formData, 'file', fileUri, 'id_card_front.jpg', 'image/jpeg');
|
|
269
|
+
|
|
228
270
|
const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];
|
|
229
271
|
const url = `${this.mrzServiceURL}/get_template_version/?doc_type=${encodeURIComponent(docTypeShorted)}&doc_region=${encodeURIComponent(docRegion)}&postfix=${postfix}`;
|
|
230
272
|
|
|
@@ -246,8 +288,8 @@ export class KYCService {
|
|
|
246
288
|
async extractDocumentInformation(params: { fileUri: string; docType: string; docRegion: string; token: string }): Promise<any> {
|
|
247
289
|
const { fileUri, docType, docRegion, token } = params;
|
|
248
290
|
const formData = new FormData();
|
|
249
|
-
|
|
250
|
-
|
|
291
|
+
await appendFileToFormData(formData, 'file', fileUri, 'id_card_front.jpg', 'image/jpeg');
|
|
292
|
+
|
|
251
293
|
|
|
252
294
|
const url = `${this.textExtractionServiceURL}/extract_doc_information/?doc_type=${encodeURIComponent(docType)}&doc_region=${encodeURIComponent(docRegion)}`;
|
|
253
295
|
const attempt = async () => {
|
|
@@ -270,11 +312,21 @@ export class KYCService {
|
|
|
270
312
|
}
|
|
271
313
|
}
|
|
272
314
|
// STEP 2 - barcode extraction
|
|
273
|
-
async extractBarcode(params: { fileUri: string; token: string }): Promise<any> {
|
|
315
|
+
async extractBarcode(params: { fileUri: string; token: string }, env: KycEnvironment = 'PRODUCTION'): Promise<any> {
|
|
316
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
317
|
+
if (env === 'SANDBOX') {
|
|
318
|
+
console.log("SANDBOX mode: Skipping AI barcode extraction");
|
|
319
|
+
logger.log("SANDBOX mode: Returning mock barcode response");
|
|
320
|
+
return {
|
|
321
|
+
barcode_data: 'SANDBOX_MOCK_BARCODE_DATA',
|
|
322
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
274
326
|
const { fileUri, token } = params;
|
|
275
327
|
const formData = new FormData();
|
|
276
|
-
|
|
277
|
-
|
|
328
|
+
await appendFileToFormData(formData, 'file', fileUri, 'id_card_back.jpg', 'image/jpeg');
|
|
329
|
+
|
|
278
330
|
|
|
279
331
|
const url = `${this.barcodeServiceURL}/decode_barcode/`;
|
|
280
332
|
const attempt = async () => {
|
|
@@ -299,11 +351,29 @@ export class KYCService {
|
|
|
299
351
|
}
|
|
300
352
|
}
|
|
301
353
|
// STEP 3 - MRZ TEXT EXTRACTION
|
|
302
|
-
async extractMrzText(params: { fileUri: string; docType: string; docRegion: string; postfix?: string; token: string; template_path: string; mrz_type: string }): Promise<any> {
|
|
354
|
+
async extractMrzText(params: { fileUri: string; docType: string; docRegion: string; postfix?: string; token: string; template_path: string; mrz_type: string }, env: KycEnvironment = 'PRODUCTION'): Promise<any> {
|
|
355
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
356
|
+
if (env === 'SANDBOX') {
|
|
357
|
+
console.log("SANDBOX mode: Skipping AI MRZ extraction");
|
|
358
|
+
logger.log("SANDBOX mode: Returning mock MRZ response");
|
|
359
|
+
const { docType, docRegion, postfix = 'back', mrz_type } = params;
|
|
360
|
+
return {
|
|
361
|
+
success: true,
|
|
362
|
+
parsed_data: {
|
|
363
|
+
status: 'success',
|
|
364
|
+
document_type: docType,
|
|
365
|
+
mrz_type: mrz_type || 'TD1',
|
|
366
|
+
doc_region: docRegion,
|
|
367
|
+
postfix: postfix
|
|
368
|
+
},
|
|
369
|
+
card_obb: { x: 50, y: 50, width: 200, height: 200 }
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
303
373
|
const { fileUri, docType, docRegion, postfix = 'back', token, template_path, mrz_type } = params;
|
|
304
374
|
const formData = new FormData();
|
|
305
|
-
|
|
306
|
-
|
|
375
|
+
await appendFileToFormData(formData, 'file', fileUri, 'id_card_back.jpg', 'image/jpeg');
|
|
376
|
+
|
|
307
377
|
const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];
|
|
308
378
|
logger.log("docTypeShorted", docTypeShorted, docRegion, postfix);
|
|
309
379
|
|
|
@@ -334,13 +404,24 @@ export class KYCService {
|
|
|
334
404
|
}
|
|
335
405
|
|
|
336
406
|
// STEP 2 - SELFIE VALIDATION
|
|
337
|
-
async recognizeFace(params: { idPhotoUri: string; selfiePhotoUri: string }): Promise<{ is_match: boolean; similarity: number; id_bbox?: number[]; selfie_bbox?: number[] }> {
|
|
407
|
+
async recognizeFace(params: { idPhotoUri: string; selfiePhotoUri: string }, env: KycEnvironment = 'PRODUCTION'): Promise<{ is_match: boolean; similarity: number; id_bbox?: number[]; selfie_bbox?: number[] }> {
|
|
408
|
+
// SANDBOX mode: skip AI verification and return mock response
|
|
409
|
+
if (env === 'SANDBOX') {
|
|
410
|
+
console.log("SANDBOX mode: Skipping AI face recognition");
|
|
411
|
+
logger.log("SANDBOX mode: Returning mock face recognition response");
|
|
412
|
+
return {
|
|
413
|
+
is_match: true,
|
|
414
|
+
similarity: 0.95,
|
|
415
|
+
id_bbox: [50, 50, 200, 200],
|
|
416
|
+
selfie_bbox: [50, 50, 200, 200]
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
338
420
|
const { idPhotoUri, selfiePhotoUri } = params;
|
|
339
421
|
const formData = new FormData();
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
formData.append('selfie_photo', selfieFile);
|
|
422
|
+
await appendFileToFormData(formData, 'id_photo', idPhotoUri, 'id_card_photo.jpg', 'image/jpeg');
|
|
423
|
+
await appendFileToFormData(formData, 'selfie_photo', selfiePhotoUri, 'selfie_final.jpg', 'image/jpeg');
|
|
424
|
+
|
|
344
425
|
|
|
345
426
|
const res = await axios.post(`${this.faceServiceURL}/recognize_face/`, formData, { timeout: 45000 });
|
|
346
427
|
if (res.data?.detail) throw new Error(res.data.detail);
|
|
@@ -374,12 +455,12 @@ export class KYCService {
|
|
|
374
455
|
"status": "PENDING",
|
|
375
456
|
"metadata": {},
|
|
376
457
|
}
|
|
377
|
-
const res = await axios.post<SessionResponse>(`${
|
|
458
|
+
const res = await axios.post<SessionResponse>(`${KYCConfig.getBackendUrl()}/verification/sessions/`,
|
|
378
459
|
data, {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
460
|
+
headers: {
|
|
461
|
+
'Content-Type': 'application/json',
|
|
462
|
+
...(apiKey ? { 'Authorization': `ApiKey ${apiKey}` } : { 'Authorization': `Bearer ${token}` })
|
|
463
|
+
}
|
|
383
464
|
});
|
|
384
465
|
return res.data;
|
|
385
466
|
} catch (error: any) {
|
|
@@ -418,19 +499,21 @@ export class KYCService {
|
|
|
418
499
|
...({ session_id: session_id }),
|
|
419
500
|
timestamp: new Date().toISOString()
|
|
420
501
|
}
|
|
421
|
-
const url = `${
|
|
502
|
+
const url = `${KYCConfig.getBackendUrl()}/verification/api/kyc/sessions/${session_id}/steps/${step}/`;
|
|
422
503
|
|
|
423
504
|
|
|
424
505
|
const logPayload = truncateFields({ payloadData, session_id, step });
|
|
425
506
|
logger.log('verificationSession payload',
|
|
426
|
-
JSON.stringify(truncateFields({ logPayload, token:token??"-", path: url, apiKey }),
|
|
507
|
+
JSON.stringify(truncateFields({ logPayload, token: token ?? "-", path: url, apiKey }),
|
|
427
508
|
null, 2))
|
|
428
509
|
|
|
429
510
|
const res = await axios.post<SessionResponse>(url,
|
|
430
511
|
payloadData,
|
|
431
512
|
{
|
|
432
|
-
headers: {
|
|
433
|
-
|
|
513
|
+
headers: {
|
|
514
|
+
'Content-Type': 'application/json',
|
|
515
|
+
...(apiKey ? { 'Authorization': `ApiKey ${apiKey}` } : { 'Authorization': `Bearer ${token}` })
|
|
516
|
+
}
|
|
434
517
|
});
|
|
435
518
|
logger.log('verificationSession res', JSON.stringify(truncateFields(res.data), null, 2));
|
|
436
519
|
return res.data;
|
|
@@ -445,7 +528,7 @@ export class KYCService {
|
|
|
445
528
|
async getVerificationResult(session_id: string): Promise<VerificationResult> {
|
|
446
529
|
try {
|
|
447
530
|
const token = await authentification();
|
|
448
|
-
const url = `${
|
|
531
|
+
const url = `${KYCConfig.getBackendUrl()}/verification/api/kyc/result/?session_id=${session_id}`;
|
|
449
532
|
const res = await axios.get<VerificationResult>(url,
|
|
450
533
|
{ headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` } });
|
|
451
534
|
logger.log('getVerificationResult res', JSON.stringify(truncateFields(res.data), null, 2));
|
|
@@ -482,6 +565,7 @@ export function truncateFields(obj: any, maxLength = 420): any {
|
|
|
482
565
|
}
|
|
483
566
|
export const authentification = async () => {
|
|
484
567
|
try {
|
|
568
|
+
logger.log('authentification params', 'kyc_frontend', 'ZCW4mGaJXWR0UuI40lM1pHNQmYLw2xvX');
|
|
485
569
|
const params = new URLSearchParams();
|
|
486
570
|
params.append('client_id', 'kyc_frontend');
|
|
487
571
|
params.append('client_secret', 'ZCW4mGaJXWR0UuI40lM1pHNQmYLw2xvX');
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import kycService, { authentification } from "./KYCService";
|
|
1
|
+
import kycService, { authentification, SelfieVideoResponse } from "./KYCService";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { KycEnvironment } from "../../types/env.types";
|
|
4
|
+
|
|
5
|
+
const selfieVerification = async (selfieImage: string, env: KycEnvironment = 'PRODUCTION'): Promise<SelfieVideoResponse[]> => {
|
|
6
|
+
// In SANDBOX mode, skip AI verification and return a mock success response
|
|
7
|
+
if (env === 'SANDBOX') {
|
|
8
|
+
console.log("SANDBOX mode: Skipping AI verification for selfie");
|
|
9
|
+
// Return a mock response that simulates successful verification
|
|
10
|
+
// This allows the flow to continue without actual AI processing
|
|
11
|
+
|
|
12
|
+
const mockResponse: SelfieVideoResponse[] = [{
|
|
13
|
+
orientation_direction: "center",
|
|
14
|
+
turn_score: 1.0,
|
|
15
|
+
bbox: [0, 0, 100, 100],
|
|
16
|
+
capture: true,
|
|
17
|
+
instruction: "SANDBOX: AI verification skipped",
|
|
18
|
+
error: ""
|
|
19
|
+
}];
|
|
20
|
+
return mockResponse;
|
|
21
|
+
}
|
|
5
22
|
|
|
23
|
+
// PRODUCTION mode: perform actual AI verification
|
|
24
|
+
const token = await authentification();
|
|
6
25
|
const response = await kycService.processSelfieOrientationPicture(selfieImage, token);
|
|
7
26
|
console.log("selfieVerification response", JSON.stringify(response, null, 2));
|
|
8
27
|
return response;
|
|
9
28
|
}
|
|
10
29
|
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
11
33
|
export default selfieVerification;
|