@transfergratis/react-native-sdk 0.1.24 → 0.1.26
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 +22 -7
- package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.web.js +76 -21
- 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/EmailVerificationTemplate.d.ts +12 -0
- package/build/components/KYCElements/EmailVerificationTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/EmailVerificationTemplate.js +212 -0
- package/build/components/KYCElements/EmailVerificationTemplate.js.map +1 -0
- package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/components/KYCElements/IDCardCapture.js +216 -14
- package/build/components/KYCElements/IDCardCapture.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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/SelfieCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.js +7 -3
- package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/WelcomeTemplate.js +2 -1
- package/build/components/KYCElements/WelcomeTemplate.js.map +1 -1
- package/build/components/OverLay/type.d.ts +2 -0
- 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 +10 -0
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js +7 -30
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts +12 -0
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +25 -3
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- 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.map +1 -1
- package/build/config/allowedDomains.js +4 -19
- package/build/config/allowedDomains.js.map +1 -1
- 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 +18 -1
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +410 -56
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/i18n/en/index.d.ts +42 -0
- package/build/i18n/en/index.d.ts.map +1 -1
- package/build/i18n/en/index.js +44 -2
- package/build/i18n/en/index.js.map +1 -1
- package/build/i18n/fr/index.d.ts +28 -0
- package/build/i18n/fr/index.d.ts.map +1 -1
- package/build/i18n/fr/index.js +30 -2
- package/build/i18n/fr/index.js.map +1 -1
- package/build/i18n/types.d.ts +2 -0
- package/build/i18n/types.d.ts.map +1 -1
- package/build/i18n/types.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -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 +90 -12
- package/build/modules/api/CardAuthentification.js.map +1 -1
- package/build/modules/api/KYCService.d.ts +17 -7
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +125 -37
- 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 +0 -1
- package/build/modules/api/TemplateService.d.ts.map +1 -1
- package/build/modules/api/TemplateService.js +3 -3
- package/build/modules/api/TemplateService.js.map +1 -1
- package/build/modules/camera/VisionCameraModule.web.d.ts.map +1 -1
- package/build/modules/camera/VisionCameraModule.web.js +27 -8
- package/build/modules/camera/VisionCameraModule.web.js.map +1 -1
- package/build/types/KYC.types.d.ts +130 -5
- package/build/types/KYC.types.d.ts.map +1 -1
- 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 +7 -0
- package/build/utils/cropByObb.d.ts.map +1 -1
- package/build/utils/cropByObb.js +20 -1
- 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.map +1 -1
- package/build/utils/platformAlert.js.map +1 -1
- package/build/utils/template-transformer.d.ts.map +1 -1
- package/build/utils/template-transformer.js +12 -0
- package/build/utils/template-transformer.js.map +1 -1
- package/build/web/WebKYCEntry.d.ts.map +1 -1
- package/build/web/WebKYCEntry.js +88 -38
- package/build/web/WebKYCEntry.js.map +1 -1
- package/package.json +1 -1
- package/plugin/build/index.d.ts +1 -0
- package/plugin/build/index.js +3 -1
- package/plugin/build/withRemovePermissions.d.ts +3 -0
- package/plugin/build/withRemovePermissions.js +67 -0
- package/plugin/build/withVisionCamera.js +3 -4
- package/plugin/src/index.ts +2 -1
- package/plugin/src/withRemovePermissions.js +85 -0
- package/plugin/src/withRemovePermissions.ts +83 -0
- package/plugin/src/withVisionCamera.js +3 -4
- package/plugin/src/withVisionCamera.ts +3 -4
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/plugin.js +6 -1
- package/src/components/EnhancedCameraView.web.tsx +76 -21
- package/src/components/KYCElements/AdditionalDocumentsTemplate.tsx +346 -0
- package/src/components/KYCElements/EmailVerificationTemplate.tsx +278 -0
- package/src/components/KYCElements/IDCardCapture.tsx +253 -21
- package/src/components/KYCElements/OrientationVideoCapture.tsx +4 -1
- package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +4 -1
- package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +4 -1
- package/src/components/KYCElements/PersonalInformationTemplate.tsx +158 -0
- package/src/components/KYCElements/PhoneVerificationTemplate.tsx +253 -0
- package/src/components/KYCElements/SelfieCaptureTemplate.tsx +6 -3
- package/src/components/KYCElements/WelcomeTemplate.tsx +2 -1
- package/src/components/OverLay/type.ts +2 -0
- package/src/components/TemplateKYCExample.tsx +35 -46
- package/src/components/TemplateKYCFlowRefactored.tsx +46 -2
- package/src/config/KYCConfig.ts +34 -0
- package/src/config/allowedDomains.ts +7 -26
- package/src/hooks/useOrientationVideo.ts +5 -4
- package/src/hooks/useTemplateKYCFlow.tsx +443 -56
- package/src/i18n/en/index.ts +46 -3
- package/src/i18n/fr/index.ts +31 -2
- package/src/i18n/types.ts +2 -0
- package/src/index.ts +3 -0
- package/src/modules/api/CardAuthentification.ts +98 -12
- package/src/modules/api/KYCService.ts +158 -37
- package/src/modules/api/SelfieVerification.ts +25 -3
- package/src/modules/api/TemplateService.ts +4 -4
- package/src/modules/camera/VisionCameraModule.web.ts +30 -12
- package/src/types/KYC.types.ts +153 -6
- package/src/types/env.types.ts +13 -0
- package/src/utils/cropByObb.ts +20 -1
- package/src/utils/deviceDetection.ts +11 -0
- package/src/utils/platformAlert.ts +1 -0
- package/src/utils/template-transformer.ts +20 -8
- package/src/web/WebKYCEntry.tsx +123 -61
package/src/web/WebKYCEntry.tsx
CHANGED
|
@@ -4,7 +4,9 @@ import { View, Text, StyleSheet, SafeAreaView, ActivityIndicator } from 'react-n
|
|
|
4
4
|
// import { KYCTemplate } from '../types/KYC.types';
|
|
5
5
|
import { useI18n } from '../hooks/useI18n';
|
|
6
6
|
import { TemplateKYCExample } from '../components/TemplateKYCExample';
|
|
7
|
-
import { isCallbackUrlAllowed
|
|
7
|
+
import { isCallbackUrlAllowed } from '../config/allowedDomains';
|
|
8
|
+
import KYCConfig from '../config/KYCConfig';
|
|
9
|
+
import { BackendEnvironment } from '../types/env.types';
|
|
8
10
|
|
|
9
11
|
interface WebKYCEntryProps {
|
|
10
12
|
onComplete?: (data: any) => void;
|
|
@@ -15,10 +17,19 @@ interface WebKYCEntryProps {
|
|
|
15
17
|
interface URLParams {
|
|
16
18
|
token?: string;
|
|
17
19
|
return_url?: string;
|
|
20
|
+
push_url?: string;
|
|
18
21
|
lang?: string;
|
|
19
22
|
theme?: string;
|
|
20
23
|
kyc_id?: string;
|
|
21
24
|
secret?: string; // Optional secret for signature generation
|
|
25
|
+
env?: 'PRODUCTION' | 'SANDBOX'; // Environment mode
|
|
26
|
+
template_id?: string; // Template ID for dynamic template loading
|
|
27
|
+
server_env?: BackendEnvironment; // Backend environment mode
|
|
28
|
+
step?: string; // Deprecated: use component_index.
|
|
29
|
+
component_index?: string; // Index in template.components (0-based) to resume at
|
|
30
|
+
country?: string; // Code pays pour restaurer la sélection (reprise multi-appareil)
|
|
31
|
+
document_type?: string; // Type de document (national_id, passport, etc.)
|
|
32
|
+
region?: string; // Région si applicable
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
interface VerificationSteps {
|
|
@@ -41,15 +52,32 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
41
52
|
// Parse URL parameters
|
|
42
53
|
const parseUrlParams = useCallback((): URLParams => {
|
|
43
54
|
if (typeof window === 'undefined') return {};
|
|
44
|
-
|
|
55
|
+
|
|
45
56
|
const urlParams = new URLSearchParams(window.location.search);
|
|
57
|
+
const envParam = urlParams.get('env');
|
|
58
|
+
const validEnv = envParam === 'SANDBOX' || envParam === 'PRODUCTION' ? envParam : 'PRODUCTION';
|
|
59
|
+
|
|
60
|
+
const serverEnvParam = urlParams.get('server_env');
|
|
61
|
+
const validServerEnv: BackendEnvironment = serverEnvParam === 'TEST' || serverEnvParam === 'PRODUCTION'
|
|
62
|
+
? (serverEnvParam as BackendEnvironment)
|
|
63
|
+
: 'PRODUCTION';
|
|
64
|
+
|
|
46
65
|
return {
|
|
47
66
|
token: urlParams.get('token') || undefined,
|
|
48
67
|
return_url: urlParams.get('return_url') || undefined,
|
|
68
|
+
push_url: urlParams.get('push_url') || undefined,
|
|
49
69
|
lang: urlParams.get('lang') || 'en',
|
|
50
70
|
theme: urlParams.get('theme') || 'light',
|
|
51
71
|
kyc_id: urlParams.get('kyc_id') || undefined,
|
|
52
72
|
secret: urlParams.get('secret') || undefined,
|
|
73
|
+
env: validEnv,
|
|
74
|
+
template_id: urlParams.get('template_id') || undefined,
|
|
75
|
+
server_env: validServerEnv,
|
|
76
|
+
step: urlParams.get('step') || undefined,
|
|
77
|
+
component_index: urlParams.get('component_index') || undefined,
|
|
78
|
+
country: urlParams.get('country') || undefined,
|
|
79
|
+
document_type: urlParams.get('document_type') || undefined,
|
|
80
|
+
region: urlParams.get('region') || undefined,
|
|
53
81
|
};
|
|
54
82
|
}, []);
|
|
55
83
|
|
|
@@ -61,8 +89,8 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
61
89
|
processing_state?: 'analyzing' | 'completed' | 'pending';
|
|
62
90
|
verification_steps?: VerificationSteps;
|
|
63
91
|
}) => {
|
|
64
|
-
const { return_url
|
|
65
|
-
|
|
92
|
+
const { return_url } = urlParams;
|
|
93
|
+
|
|
66
94
|
if (!return_url) {
|
|
67
95
|
console.warn('No return_url provided');
|
|
68
96
|
return;
|
|
@@ -74,7 +102,7 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
74
102
|
if (!validation.allowed) {
|
|
75
103
|
console.error('Callback URL validation failed:', validation.reason);
|
|
76
104
|
setError(`Security Error: ${validation.reason}`);
|
|
77
|
-
|
|
105
|
+
|
|
78
106
|
// Log suspicious redirect attempt
|
|
79
107
|
console.warn('Suspicious redirect attempt blocked:', {
|
|
80
108
|
url: return_url,
|
|
@@ -83,46 +111,9 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
83
111
|
});
|
|
84
112
|
return;
|
|
85
113
|
}
|
|
86
|
-
|
|
87
|
-
const returnUrl = new URL(return_url);
|
|
88
|
-
|
|
89
|
-
// Build redirect URL with parameters
|
|
90
|
-
const redirectUrl = new URL(returnUrl);
|
|
91
|
-
const redirectParams: Record<string, string> = {
|
|
92
|
-
status: params.status,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
if (params.kyc_id) {
|
|
96
|
-
redirectParams.kyc_id = params.kyc_id;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (params.message) {
|
|
100
|
-
redirectParams.message = params.message;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (params.processing_state) {
|
|
104
|
-
redirectParams.processing_state = params.processing_state;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (params.verification_steps) {
|
|
108
|
-
redirectParams.verification_steps = JSON.stringify(params.verification_steps);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Generate signature for integrity verification
|
|
112
|
-
if (secret) {
|
|
113
|
-
const signature = await generateCallbackSignature(redirectParams, secret);
|
|
114
|
-
if (signature) {
|
|
115
|
-
redirectParams.sig = signature;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Add all params to URL
|
|
120
|
-
Object.entries(redirectParams).forEach(([key, value]) => {
|
|
121
|
-
redirectUrl.searchParams.set(key, value);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
114
|
// Send postMessage to parent if in iframe
|
|
125
115
|
if (window.parent !== window) {
|
|
116
|
+
const targetOrigin = new URL(return_url).origin;
|
|
126
117
|
window.parent.postMessage({
|
|
127
118
|
type: 'kyc_result',
|
|
128
119
|
status: params.status,
|
|
@@ -130,11 +121,10 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
130
121
|
message: params.message,
|
|
131
122
|
processing_state: params.processing_state,
|
|
132
123
|
verification_steps: params.verification_steps,
|
|
133
|
-
},
|
|
124
|
+
}, targetOrigin);
|
|
125
|
+
} else {
|
|
126
|
+
window.location.href = return_url;
|
|
134
127
|
}
|
|
135
|
-
|
|
136
|
-
// Redirect to return URL
|
|
137
|
-
window.location.href = redirectUrl.toString();
|
|
138
128
|
} catch (error) {
|
|
139
129
|
console.error('Error during redirect:', error);
|
|
140
130
|
setError('Failed to redirect to callback URL');
|
|
@@ -142,12 +132,41 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
142
132
|
}, [urlParams]);
|
|
143
133
|
|
|
144
134
|
// Handle KYC completion
|
|
145
|
-
const handleComplete = useCallback((data: any) => {
|
|
135
|
+
const handleComplete = useCallback(async (data: any) => {
|
|
146
136
|
console.log('KYC completed:', data);
|
|
147
|
-
|
|
137
|
+
|
|
148
138
|
// Check if still processing/analyzing
|
|
149
139
|
const isStillProcessing = data.isProcessing || data.session?.isProcessing;
|
|
150
|
-
|
|
140
|
+
|
|
141
|
+
// Handle Push URL webhook if provided
|
|
142
|
+
if (urlParams.push_url) {
|
|
143
|
+
try {
|
|
144
|
+
const verificationState = {
|
|
145
|
+
status: 'success', // verification completed successfully
|
|
146
|
+
result: data, // pass complete data object as result
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Send data to provided push_url with a timeout
|
|
150
|
+
const controller = new AbortController();
|
|
151
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5s timeout
|
|
152
|
+
|
|
153
|
+
await fetch(urlParams.push_url, {
|
|
154
|
+
method: 'POST',
|
|
155
|
+
headers: {
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify(verificationState),
|
|
159
|
+
signal: controller.signal,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
clearTimeout(timeoutId);
|
|
163
|
+
console.log('Successfully pushed KYC data to webhook');
|
|
164
|
+
} catch (err) {
|
|
165
|
+
// Fail open - redirect anyway even if webhook fails
|
|
166
|
+
console.warn('Failed to push data to webhook URL:', err);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
151
170
|
redirectToReturnUrl({
|
|
152
171
|
status: 'completed',
|
|
153
172
|
kyc_id: data.session_id || urlParams.kyc_id,
|
|
@@ -160,7 +179,7 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
160
179
|
},
|
|
161
180
|
});
|
|
162
181
|
onComplete?.(data);
|
|
163
|
-
}, [redirectToReturnUrl, urlParams
|
|
182
|
+
}, [redirectToReturnUrl, urlParams, onComplete]);
|
|
164
183
|
|
|
165
184
|
// Handle KYC error
|
|
166
185
|
const handleError = useCallback((error: string) => {
|
|
@@ -177,8 +196,35 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
177
196
|
|
|
178
197
|
// Handle KYC cancellation
|
|
179
198
|
const handleCancel = useCallback(() => {
|
|
180
|
-
console.log('KYC cancelled');
|
|
199
|
+
console.log('KYC cancelled', urlParams.push_url, urlParams);
|
|
181
200
|
setIsAnalyzing(false);
|
|
201
|
+
if (urlParams.push_url) {
|
|
202
|
+
try {
|
|
203
|
+
const verificationState = {
|
|
204
|
+
status: 'cancelled', // verification cancelled
|
|
205
|
+
result: null, // pass null as result
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Send data to provided push_url with a timeout
|
|
209
|
+
const controller = new AbortController();
|
|
210
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5s timeout
|
|
211
|
+
|
|
212
|
+
fetch(urlParams.push_url, {
|
|
213
|
+
method: 'POST',
|
|
214
|
+
headers: {
|
|
215
|
+
'Content-Type': 'application/json',
|
|
216
|
+
},
|
|
217
|
+
body: JSON.stringify(verificationState),
|
|
218
|
+
signal: controller.signal,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
clearTimeout(timeoutId);
|
|
222
|
+
console.log('Successfully pushed KYC cancellation data to webhook');
|
|
223
|
+
} catch (err) {
|
|
224
|
+
// Fail open - redirect anyway even if webhook fails
|
|
225
|
+
console.warn('Failed to push data to webhook URL:', err);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
182
228
|
redirectToReturnUrl({
|
|
183
229
|
status: 'cancelled',
|
|
184
230
|
kyc_id: urlParams.kyc_id,
|
|
@@ -193,12 +239,17 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
193
239
|
try {
|
|
194
240
|
const params = parseUrlParams();
|
|
195
241
|
setUrlParams(params);
|
|
196
|
-
|
|
242
|
+
|
|
197
243
|
// Set language if provided
|
|
198
244
|
if (params.lang) {
|
|
199
245
|
setLocale(params.lang);
|
|
200
246
|
}
|
|
201
|
-
|
|
247
|
+
|
|
248
|
+
// Configure backend environment
|
|
249
|
+
if (params.server_env) {
|
|
250
|
+
KYCConfig.setBackendEnvironment(params.server_env);
|
|
251
|
+
}
|
|
252
|
+
|
|
202
253
|
setIsLoading(false);
|
|
203
254
|
} catch (error) {
|
|
204
255
|
console.error('Error parsing URL parameters:', error);
|
|
@@ -243,13 +294,24 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
|
|
|
243
294
|
</View>
|
|
244
295
|
</View>
|
|
245
296
|
)}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
297
|
+
<TemplateKYCExample
|
|
298
|
+
onComplete={handleComplete}
|
|
299
|
+
onCancel={handleCancel}
|
|
300
|
+
onError={handleError}
|
|
301
|
+
language={urlParams.lang || 'en'}
|
|
302
|
+
API_KEY={urlParams.token}
|
|
303
|
+
templateId={urlParams.template_id}
|
|
304
|
+
env={urlParams.env || 'PRODUCTION'}
|
|
305
|
+
serverEnv={urlParams.server_env}
|
|
306
|
+
existingSessionId={urlParams.kyc_id}
|
|
307
|
+
initialComponentIndex={(() => {
|
|
308
|
+
const raw = urlParams.component_index ?? urlParams.step;
|
|
309
|
+
if (raw == null || raw === '') return undefined;
|
|
310
|
+
const index = parseInt(raw, 10);
|
|
311
|
+
return Number.isNaN(index) ? undefined : index;
|
|
312
|
+
})()}
|
|
313
|
+
initialCountryResume={urlParams.country && urlParams.document_type ? { code: urlParams.country, documentType: urlParams.document_type, region: urlParams.region || undefined } : undefined}
|
|
314
|
+
/>
|
|
253
315
|
</SafeAreaView>
|
|
254
316
|
);
|
|
255
317
|
};
|