@sanctum-key/react-native-sdk 1.0.19 → 1.0.20

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 (31) hide show
  1. package/build/package.json +1 -1
  2. package/build/src/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
  3. package/build/src/components/KYCElements/CountrySelectionTemplate.js +40 -128
  4. package/build/src/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
  5. package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  6. package/build/src/components/KYCElements/IDCardCapture.js +166 -129
  7. package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
  8. package/build/src/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -1
  9. package/build/src/components/KYCElements/VerificationProgressTemplate.js +38 -33
  10. package/build/src/components/KYCElements/VerificationProgressTemplate.js.map +1 -1
  11. package/build/src/hooks/useTemplateKYCFlow.js +1 -1
  12. package/build/src/hooks/useTemplateKYCFlow.js.map +1 -1
  13. package/build/src/modules/api/CardAuthentification.d.ts +5 -0
  14. package/build/src/modules/api/CardAuthentification.d.ts.map +1 -1
  15. package/build/src/modules/api/CardAuthentification.js +67 -13
  16. package/build/src/modules/api/CardAuthentification.js.map +1 -1
  17. package/build/src/modules/api/KYCService.d.ts +10 -0
  18. package/build/src/modules/api/KYCService.d.ts.map +1 -1
  19. package/build/src/modules/api/KYCService.js +94 -25
  20. package/build/src/modules/api/KYCService.js.map +1 -1
  21. package/build/src/web/WebKYCEntry.d.ts.map +1 -1
  22. package/build/src/web/WebKYCEntry.js +34 -6
  23. package/build/src/web/WebKYCEntry.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/KYCElements/CountrySelectionTemplate.tsx +53 -133
  26. package/src/components/KYCElements/IDCardCapture.tsx +613 -556
  27. package/src/components/KYCElements/VerificationProgressTemplate.tsx +54 -66
  28. package/src/hooks/useTemplateKYCFlow.tsx +14 -14
  29. package/src/modules/api/CardAuthentification.ts +133 -66
  30. package/src/modules/api/KYCService.ts +142 -38
  31. package/src/web/WebKYCEntry.tsx +42 -7
@@ -111,6 +111,7 @@ export function WebKYCEntry({
111
111
  onCancel,
112
112
  onSessionSave,
113
113
  }: WebKYCEntryProps): JSX.Element {
114
+ console.log('first')
114
115
  const { setLocale } = useI18n();
115
116
  const [urlParams, setUrlParams] = useState<URLParams>({});
116
117
  const [isLoading, setIsLoading] = useState(true);
@@ -204,7 +205,6 @@ export function WebKYCEntry({
204
205
  }
205
206
  }, [urlParams]);
206
207
 
207
- // Handle KYC completion
208
208
  const handleComplete = useCallback(async (data: any) => {
209
209
  console.log('KYC completed:', data);
210
210
 
@@ -214,15 +214,48 @@ export function WebKYCEntry({
214
214
  // Handle Push URL webhook if provided
215
215
  if (urlParams.push_url) {
216
216
  try {
217
+ const innerResult = data?.result?.result || data?.result || data;
218
+ const nestedDataMap = innerResult?.data;
219
+
220
+ let kycSessionId = data?.session_id || urlParams.kyc_id || '';
221
+ let parsedKycData: any = null;
222
+
223
+ if (nestedDataMap) {
224
+ const mapKeys = Object.keys(nestedDataMap);
225
+ if (mapKeys.length > 0) {
226
+ const detectedSessionId = mapKeys.find(key => key.startsWith('kyc-')) || mapKeys[0];
227
+ if (detectedSessionId) {
228
+ kycSessionId = detectedSessionId;
229
+ }
230
+
231
+ const rawData = nestedDataMap[kycSessionId]?.data;
232
+
233
+ if (typeof rawData === 'string') {
234
+ try {
235
+ parsedKycData = JSON.parse(rawData);
236
+ } catch (parseErr) {
237
+ console.warn('Failed parsing inner stringified JSON string:', parseErr);
238
+ parsedKycData = rawData;
239
+ }
240
+ } else {
241
+ parsedKycData = rawData;
242
+ }
243
+ }
244
+ }
245
+
246
+ const finalSessionId = kycSessionId || parsedKycData?.session_id || urlParams.kyc_id || 'unknown';
247
+
248
+ // 3. Build your exact un-nested payload signature
217
249
  const verificationState = {
218
- status: 'success', // verification completed successfully
219
- result: data, // pass complete data object as result
220
- reference_id: urlParams.reference_id,
250
+ session_id: finalSessionId,
251
+ status: 'success',
252
+ message: innerResult?.message || 'Verification data retrieved successfully.',
253
+ data: parsedKycData || {}
221
254
  };
255
+
222
256
  await postWebhook(urlParams.push_url, verificationState, 5000);
223
- console.log('Successfully pushed KYC data to webhook');
257
+ console.log('Successfully pushed beautifully clean KYC data payload to webhook');
224
258
  } catch (err) {
225
- // Fail open - redirect anyway even if webhook fails
226
259
  console.warn('Failed to push data to webhook URL:', err);
227
260
  }
228
261
  }
@@ -238,6 +271,7 @@ export function WebKYCEntry({
238
271
  liveness_checked: data.livenessCheckComplete || false,
239
272
  },
240
273
  });
274
+
241
275
  onComplete?.(data);
242
276
  }, [redirectToReturnUrl, urlParams, onComplete]);
243
277
 
@@ -311,6 +345,7 @@ export function WebKYCEntry({
311
345
  useEffect(() => {
312
346
  try {
313
347
  const params = parseUrlParams();
348
+
314
349
  setUrlParams(params);
315
350
 
316
351
  // Set language if provided
@@ -447,4 +482,4 @@ const styles = StyleSheet.create({
447
482
  },
448
483
  });
449
484
 
450
- export default WebKYCEntry;
485
+ export default WebKYCEntry;