@transfergratis/react-native-sdk 0.1.24 → 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.
Files changed (149) hide show
  1. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +12 -5
  2. package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
  3. package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
  4. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  5. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  6. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +61 -59
  7. package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-transfergratis-react-native-sdk.jar +0 -0
  8. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +12 -5
  9. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  10. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  11. package/android/build/outputs/aar/transfergratis-react-native-sdk-debug.aar +0 -0
  12. package/android/build/outputs/logs/manifest-merger-debug-report.txt +26 -34
  13. package/android/src/main/AndroidManifest.xml +10 -7
  14. package/build/components/KYCElements/AdditionalDocumentsTemplate.d.ts +12 -0
  15. package/build/components/KYCElements/AdditionalDocumentsTemplate.d.ts.map +1 -0
  16. package/build/components/KYCElements/AdditionalDocumentsTemplate.js +283 -0
  17. package/build/components/KYCElements/AdditionalDocumentsTemplate.js.map +1 -0
  18. package/build/components/KYCElements/EmailVerificationTemplate.d.ts +12 -0
  19. package/build/components/KYCElements/EmailVerificationTemplate.d.ts.map +1 -0
  20. package/build/components/KYCElements/EmailVerificationTemplate.js +193 -0
  21. package/build/components/KYCElements/EmailVerificationTemplate.js.map +1 -0
  22. package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  23. package/build/components/KYCElements/IDCardCapture.js +180 -7
  24. package/build/components/KYCElements/IDCardCapture.js.map +1 -1
  25. package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -0
  26. package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
  27. package/build/components/KYCElements/OrientationVideoCapture.js +2 -2
  28. package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
  29. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -0
  30. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
  31. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js +2 -2
  32. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
  33. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -0
  34. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
  35. package/build/components/KYCElements/OrientationVideoCaptureFinal.js +2 -2
  36. package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
  37. package/build/components/KYCElements/PersonalInformationTemplate.d.ts +12 -0
  38. package/build/components/KYCElements/PersonalInformationTemplate.d.ts.map +1 -0
  39. package/build/components/KYCElements/PersonalInformationTemplate.js +120 -0
  40. package/build/components/KYCElements/PersonalInformationTemplate.js.map +1 -0
  41. package/build/components/KYCElements/PhoneVerificationTemplate.d.ts +12 -0
  42. package/build/components/KYCElements/PhoneVerificationTemplate.d.ts.map +1 -0
  43. package/build/components/KYCElements/PhoneVerificationTemplate.js +185 -0
  44. package/build/components/KYCElements/PhoneVerificationTemplate.js.map +1 -0
  45. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  46. package/build/components/KYCElements/SelfieCaptureTemplate.js +7 -3
  47. package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  48. package/build/components/TemplateKYCExample.d.ts +4 -0
  49. package/build/components/TemplateKYCExample.d.ts.map +1 -1
  50. package/build/components/TemplateKYCExample.js +7 -30
  51. package/build/components/TemplateKYCExample.js.map +1 -1
  52. package/build/components/TemplateKYCFlowRefactored.d.ts +4 -0
  53. package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
  54. package/build/components/TemplateKYCFlowRefactored.js +14 -2
  55. package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
  56. package/build/config/KYCConfig.d.ts +14 -0
  57. package/build/config/KYCConfig.d.ts.map +1 -0
  58. package/build/config/KYCConfig.js +26 -0
  59. package/build/config/KYCConfig.js.map +1 -0
  60. package/build/config/allowedDomains.d.ts.map +1 -1
  61. package/build/config/allowedDomains.js +4 -19
  62. package/build/config/allowedDomains.js.map +1 -1
  63. package/build/hooks/useOrientationVideo.d.ts +2 -1
  64. package/build/hooks/useOrientationVideo.d.ts.map +1 -1
  65. package/build/hooks/useOrientationVideo.js +3 -3
  66. package/build/hooks/useOrientationVideo.js.map +1 -1
  67. package/build/hooks/useTemplateKYCFlow.d.ts +6 -1
  68. package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  69. package/build/hooks/useTemplateKYCFlow.js +286 -23
  70. package/build/hooks/useTemplateKYCFlow.js.map +1 -1
  71. package/build/i18n/en/index.d.ts +40 -0
  72. package/build/i18n/en/index.d.ts.map +1 -1
  73. package/build/i18n/en/index.js +41 -1
  74. package/build/i18n/en/index.js.map +1 -1
  75. package/build/i18n/fr/index.d.ts +26 -0
  76. package/build/i18n/fr/index.d.ts.map +1 -1
  77. package/build/i18n/fr/index.js +27 -1
  78. package/build/i18n/fr/index.js.map +1 -1
  79. package/build/index.d.ts +1 -0
  80. package/build/index.d.ts.map +1 -1
  81. package/build/index.js +2 -0
  82. package/build/index.js.map +1 -1
  83. package/build/modules/api/CardAuthentification.d.ts +24 -3
  84. package/build/modules/api/CardAuthentification.d.ts.map +1 -1
  85. package/build/modules/api/CardAuthentification.js +68 -10
  86. package/build/modules/api/CardAuthentification.js.map +1 -1
  87. package/build/modules/api/KYCService.d.ts +7 -7
  88. package/build/modules/api/KYCService.d.ts.map +1 -1
  89. package/build/modules/api/KYCService.js +101 -37
  90. package/build/modules/api/KYCService.js.map +1 -1
  91. package/build/modules/api/SelfieVerification.d.ts +3 -1
  92. package/build/modules/api/SelfieVerification.d.ts.map +1 -1
  93. package/build/modules/api/SelfieVerification.js +17 -1
  94. package/build/modules/api/SelfieVerification.js.map +1 -1
  95. package/build/modules/api/TemplateService.d.ts +0 -1
  96. package/build/modules/api/TemplateService.d.ts.map +1 -1
  97. package/build/modules/api/TemplateService.js +3 -3
  98. package/build/modules/api/TemplateService.js.map +1 -1
  99. package/build/types/KYC.types.d.ts +124 -3
  100. package/build/types/KYC.types.d.ts.map +1 -1
  101. package/build/types/KYC.types.js.map +1 -1
  102. package/build/types/env.types.d.ts +13 -0
  103. package/build/types/env.types.d.ts.map +1 -0
  104. package/build/types/env.types.js +2 -0
  105. package/build/types/env.types.js.map +1 -0
  106. package/build/utils/deviceDetection.d.ts +6 -0
  107. package/build/utils/deviceDetection.d.ts.map +1 -0
  108. package/build/utils/deviceDetection.js +12 -0
  109. package/build/utils/deviceDetection.js.map +1 -0
  110. package/build/utils/platformAlert.d.ts.map +1 -1
  111. package/build/utils/platformAlert.js.map +1 -1
  112. package/build/utils/template-transformer.d.ts.map +1 -1
  113. package/build/utils/template-transformer.js +12 -0
  114. package/build/utils/template-transformer.js.map +1 -1
  115. package/build/web/WebKYCEntry.d.ts.map +1 -1
  116. package/build/web/WebKYCEntry.js +82 -38
  117. package/build/web/WebKYCEntry.js.map +1 -1
  118. package/package.json +1 -1
  119. package/plugin/build/withVisionCamera.js +3 -4
  120. package/plugin/src/withVisionCamera.js +3 -4
  121. package/plugin/src/withVisionCamera.ts +3 -4
  122. package/src/components/KYCElements/AdditionalDocumentsTemplate.tsx +346 -0
  123. package/src/components/KYCElements/EmailVerificationTemplate.tsx +264 -0
  124. package/src/components/KYCElements/IDCardCapture.tsx +216 -15
  125. package/src/components/KYCElements/OrientationVideoCapture.tsx +4 -1
  126. package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +4 -1
  127. package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +4 -1
  128. package/src/components/KYCElements/PersonalInformationTemplate.tsx +158 -0
  129. package/src/components/KYCElements/PhoneVerificationTemplate.tsx +253 -0
  130. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +6 -3
  131. package/src/components/TemplateKYCExample.tsx +31 -46
  132. package/src/components/TemplateKYCFlowRefactored.tsx +27 -1
  133. package/src/config/KYCConfig.ts +34 -0
  134. package/src/config/allowedDomains.ts +7 -26
  135. package/src/hooks/useOrientationVideo.ts +5 -4
  136. package/src/hooks/useTemplateKYCFlow.tsx +314 -21
  137. package/src/i18n/en/index.ts +43 -2
  138. package/src/i18n/fr/index.ts +28 -1
  139. package/src/index.ts +3 -0
  140. package/src/modules/api/CardAuthentification.ts +75 -10
  141. package/src/modules/api/KYCService.ts +117 -37
  142. package/src/modules/api/SelfieVerification.ts +25 -3
  143. package/src/modules/api/TemplateService.ts +4 -4
  144. package/src/types/KYC.types.ts +146 -3
  145. package/src/types/env.types.ts +13 -0
  146. package/src/utils/deviceDetection.ts +11 -0
  147. package/src/utils/platformAlert.ts +1 -0
  148. package/src/utils/template-transformer.ts +20 -8
  149. package/src/web/WebKYCEntry.tsx +112 -61
@@ -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, generateCallbackSignature } from '../config/allowedDomains';
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,15 @@ 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; // Step index to resume verification at the correct point
22
29
  }
23
30
 
24
31
  interface VerificationSteps {
@@ -41,15 +48,28 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
41
48
  // Parse URL parameters
42
49
  const parseUrlParams = useCallback((): URLParams => {
43
50
  if (typeof window === 'undefined') return {};
44
-
51
+
45
52
  const urlParams = new URLSearchParams(window.location.search);
53
+ const envParam = urlParams.get('env');
54
+ const validEnv = envParam === 'SANDBOX' || envParam === 'PRODUCTION' ? envParam : 'PRODUCTION';
55
+
56
+ const serverEnvParam = urlParams.get('server_env');
57
+ const validServerEnv: BackendEnvironment = serverEnvParam === 'TEST' || serverEnvParam === 'PRODUCTION'
58
+ ? (serverEnvParam as BackendEnvironment)
59
+ : 'PRODUCTION';
60
+
46
61
  return {
47
62
  token: urlParams.get('token') || undefined,
48
63
  return_url: urlParams.get('return_url') || undefined,
64
+ push_url: urlParams.get('push_url') || undefined,
49
65
  lang: urlParams.get('lang') || 'en',
50
66
  theme: urlParams.get('theme') || 'light',
51
67
  kyc_id: urlParams.get('kyc_id') || undefined,
52
68
  secret: urlParams.get('secret') || undefined,
69
+ env: validEnv,
70
+ template_id: urlParams.get('template_id') || undefined,
71
+ server_env: validServerEnv,
72
+ step: urlParams.get('step') || undefined,
53
73
  };
54
74
  }, []);
55
75
 
@@ -61,8 +81,8 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
61
81
  processing_state?: 'analyzing' | 'completed' | 'pending';
62
82
  verification_steps?: VerificationSteps;
63
83
  }) => {
64
- const { return_url, secret } = urlParams;
65
-
84
+ const { return_url } = urlParams;
85
+
66
86
  if (!return_url) {
67
87
  console.warn('No return_url provided');
68
88
  return;
@@ -74,7 +94,7 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
74
94
  if (!validation.allowed) {
75
95
  console.error('Callback URL validation failed:', validation.reason);
76
96
  setError(`Security Error: ${validation.reason}`);
77
-
97
+
78
98
  // Log suspicious redirect attempt
79
99
  console.warn('Suspicious redirect attempt blocked:', {
80
100
  url: return_url,
@@ -83,46 +103,9 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
83
103
  });
84
104
  return;
85
105
  }
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
106
  // Send postMessage to parent if in iframe
125
107
  if (window.parent !== window) {
108
+ const targetOrigin = new URL(return_url).origin;
126
109
  window.parent.postMessage({
127
110
  type: 'kyc_result',
128
111
  status: params.status,
@@ -130,11 +113,10 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
130
113
  message: params.message,
131
114
  processing_state: params.processing_state,
132
115
  verification_steps: params.verification_steps,
133
- }, returnUrl.origin); // Use specific origin instead of '*'
116
+ }, targetOrigin);
117
+ } else {
118
+ window.location.href = return_url;
134
119
  }
135
-
136
- // Redirect to return URL
137
- window.location.href = redirectUrl.toString();
138
120
  } catch (error) {
139
121
  console.error('Error during redirect:', error);
140
122
  setError('Failed to redirect to callback URL');
@@ -142,12 +124,41 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
142
124
  }, [urlParams]);
143
125
 
144
126
  // Handle KYC completion
145
- const handleComplete = useCallback((data: any) => {
127
+ const handleComplete = useCallback(async (data: any) => {
146
128
  console.log('KYC completed:', data);
147
-
129
+
148
130
  // Check if still processing/analyzing
149
131
  const isStillProcessing = data.isProcessing || data.session?.isProcessing;
150
-
132
+
133
+ // Handle Push URL webhook if provided
134
+ if (urlParams.push_url) {
135
+ try {
136
+ const verificationState = {
137
+ status: 'success', // verification completed successfully
138
+ result: data, // pass complete data object as result
139
+ };
140
+
141
+ // Send data to provided push_url with a timeout
142
+ const controller = new AbortController();
143
+ const timeoutId = setTimeout(() => controller.abort(), 5000); // 5s timeout
144
+
145
+ await fetch(urlParams.push_url, {
146
+ method: 'POST',
147
+ headers: {
148
+ 'Content-Type': 'application/json',
149
+ },
150
+ body: JSON.stringify(verificationState),
151
+ signal: controller.signal,
152
+ });
153
+
154
+ clearTimeout(timeoutId);
155
+ console.log('Successfully pushed KYC data to webhook');
156
+ } catch (err) {
157
+ // Fail open - redirect anyway even if webhook fails
158
+ console.warn('Failed to push data to webhook URL:', err);
159
+ }
160
+ }
161
+
151
162
  redirectToReturnUrl({
152
163
  status: 'completed',
153
164
  kyc_id: data.session_id || urlParams.kyc_id,
@@ -160,7 +171,7 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
160
171
  },
161
172
  });
162
173
  onComplete?.(data);
163
- }, [redirectToReturnUrl, urlParams.kyc_id, onComplete]);
174
+ }, [redirectToReturnUrl, urlParams, onComplete]);
164
175
 
165
176
  // Handle KYC error
166
177
  const handleError = useCallback((error: string) => {
@@ -177,8 +188,35 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
177
188
 
178
189
  // Handle KYC cancellation
179
190
  const handleCancel = useCallback(() => {
180
- console.log('KYC cancelled');
191
+ console.log('KYC cancelled', urlParams.push_url, urlParams);
181
192
  setIsAnalyzing(false);
193
+ if (urlParams.push_url) {
194
+ try {
195
+ const verificationState = {
196
+ status: 'cancelled', // verification cancelled
197
+ result: null, // pass null as result
198
+ };
199
+
200
+ // Send data to provided push_url with a timeout
201
+ const controller = new AbortController();
202
+ const timeoutId = setTimeout(() => controller.abort(), 5000); // 5s timeout
203
+
204
+ fetch(urlParams.push_url, {
205
+ method: 'POST',
206
+ headers: {
207
+ 'Content-Type': 'application/json',
208
+ },
209
+ body: JSON.stringify(verificationState),
210
+ signal: controller.signal,
211
+ });
212
+
213
+ clearTimeout(timeoutId);
214
+ console.log('Successfully pushed KYC cancellation data to webhook');
215
+ } catch (err) {
216
+ // Fail open - redirect anyway even if webhook fails
217
+ console.warn('Failed to push data to webhook URL:', err);
218
+ }
219
+ }
182
220
  redirectToReturnUrl({
183
221
  status: 'cancelled',
184
222
  kyc_id: urlParams.kyc_id,
@@ -193,12 +231,17 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
193
231
  try {
194
232
  const params = parseUrlParams();
195
233
  setUrlParams(params);
196
-
234
+
197
235
  // Set language if provided
198
236
  if (params.lang) {
199
237
  setLocale(params.lang);
200
238
  }
201
-
239
+
240
+ // Configure backend environment
241
+ if (params.server_env) {
242
+ KYCConfig.setBackendEnvironment(params.server_env);
243
+ }
244
+
202
245
  setIsLoading(false);
203
246
  } catch (error) {
204
247
  console.error('Error parsing URL parameters:', error);
@@ -243,13 +286,21 @@ const WebKYCEntry: React.FC<WebKYCEntryProps> = ({
243
286
  </View>
244
287
  </View>
245
288
  )}
246
- <TemplateKYCExample
247
- onComplete={handleComplete}
248
- onCancel={handleCancel}
249
- onError={handleError}
250
- language={urlParams.lang || 'en'}
251
- API_KEY={urlParams.token}
252
- />
289
+ <TemplateKYCExample
290
+ onComplete={handleComplete}
291
+ onCancel={handleCancel}
292
+ onError={handleError}
293
+ language={urlParams.lang || 'en'}
294
+ API_KEY={urlParams.token}
295
+ templateId={urlParams.template_id}
296
+ env={urlParams.env || 'PRODUCTION'}
297
+ existingSessionId={urlParams.kyc_id}
298
+ initialStep={urlParams.step ? (() => {
299
+ const stepNum = parseInt(urlParams.step, 10);
300
+ console.log('Parsing step from URL:', { stepString: urlParams.step, stepNumber: stepNum, isNaN: isNaN(stepNum) });
301
+ return isNaN(stepNum) ? undefined : stepNum;
302
+ })() : undefined}
303
+ />
253
304
  </SafeAreaView>
254
305
  );
255
306
  };