@trustchex/react-native-sdk 1.334.0 → 1.354.1

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 (73) hide show
  1. package/README.md +3 -1
  2. package/lib/module/Screens/Dynamic/ContractAcceptanceScreen.js +8 -2
  3. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +5 -1
  4. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +5 -1
  5. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +29 -15
  6. package/lib/module/Screens/Static/OTPVerificationScreen.js +285 -0
  7. package/lib/module/Screens/Static/ResultScreen.js +90 -26
  8. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +48 -134
  9. package/lib/module/Shared/Components/DebugNavigationPanel.js +252 -0
  10. package/lib/module/Shared/Components/EIDScanner.js +142 -17
  11. package/lib/module/Shared/Components/FaceCamera.js +23 -11
  12. package/lib/module/Shared/Components/IdentityDocumentCamera.js +295 -44
  13. package/lib/module/Shared/Components/NavigationManager.js +19 -3
  14. package/lib/module/Shared/Config/camera-enhancement.config.js +58 -0
  15. package/lib/module/Shared/Contexts/AppContext.js +1 -0
  16. package/lib/module/Shared/Libs/camera.utils.js +221 -1
  17. package/lib/module/Shared/Libs/frame-enhancement.utils.js +133 -0
  18. package/lib/module/Shared/Libs/mrz.utils.js +98 -1
  19. package/lib/module/Translation/Resources/en.js +30 -0
  20. package/lib/module/Translation/Resources/tr.js +30 -0
  21. package/lib/module/Trustchex.js +49 -39
  22. package/lib/module/version.js +1 -1
  23. package/lib/typescript/src/Screens/Dynamic/ContractAcceptanceScreen.d.ts.map +1 -1
  24. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
  25. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
  26. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  27. package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts +3 -0
  28. package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -0
  29. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  30. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
  31. package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts +3 -0
  32. package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -0
  33. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  34. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  35. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  36. package/lib/typescript/src/Shared/Components/NavigationManager.d.ts.map +1 -1
  37. package/lib/typescript/src/Shared/Config/camera-enhancement.config.d.ts +54 -0
  38. package/lib/typescript/src/Shared/Config/camera-enhancement.config.d.ts.map +1 -0
  39. package/lib/typescript/src/Shared/Contexts/AppContext.d.ts +2 -0
  40. package/lib/typescript/src/Shared/Contexts/AppContext.d.ts.map +1 -1
  41. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +65 -1
  42. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +1 -1
  43. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +25 -0
  44. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +1 -0
  45. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
  46. package/lib/typescript/src/Translation/Resources/en.d.ts +30 -0
  47. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
  48. package/lib/typescript/src/Translation/Resources/tr.d.ts +30 -0
  49. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  50. package/lib/typescript/src/Trustchex.d.ts.map +1 -1
  51. package/lib/typescript/src/version.d.ts +1 -1
  52. package/package.json +3 -3
  53. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +6 -2
  54. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +3 -1
  55. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +3 -1
  56. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +27 -17
  57. package/src/Screens/Static/OTPVerificationScreen.tsx +379 -0
  58. package/src/Screens/Static/ResultScreen.tsx +160 -101
  59. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +51 -196
  60. package/src/Shared/Components/DebugNavigationPanel.tsx +262 -0
  61. package/src/Shared/Components/EIDScanner.tsx +144 -19
  62. package/src/Shared/Components/FaceCamera.tsx +38 -21
  63. package/src/Shared/Components/IdentityDocumentCamera.tsx +399 -101
  64. package/src/Shared/Components/NavigationManager.tsx +19 -3
  65. package/src/Shared/Config/camera-enhancement.config.ts +46 -0
  66. package/src/Shared/Contexts/AppContext.ts +3 -0
  67. package/src/Shared/Libs/camera.utils.ts +240 -1
  68. package/src/Shared/Libs/frame-enhancement.utils.ts +217 -0
  69. package/src/Shared/Libs/mrz.utils.ts +78 -1
  70. package/src/Translation/Resources/en.ts +30 -0
  71. package/src/Translation/Resources/tr.ts +30 -0
  72. package/src/Trustchex.tsx +58 -46
  73. package/src/version.ts +1 -1
@@ -2,6 +2,7 @@
2
2
 
3
3
  import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
4
4
  import { Alert, Image, Platform, SafeAreaView, ScrollView, StyleSheet, Text, View } from 'react-native';
5
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
6
  import AppContext from "../../Shared/Contexts/AppContext.js";
6
7
  import httpClient from "../../Shared/Libs/http-client.js";
7
8
  import RNFS from 'react-native-fs';
@@ -30,9 +31,37 @@ const ResultScreen = () => {
30
31
  const {
31
32
  t
32
33
  } = useTranslation();
34
+ const insets = useSafeAreaInsets();
33
35
 
34
36
  // Track screen view and exit
35
37
  useScreenTracking('result_screen');
38
+ const formatDate = useCallback(dateStr => {
39
+ if (!dateStr) return '';
40
+ try {
41
+ // Check if it's YYMMDD format (6 digits)
42
+ if (dateStr.length === 6 && /^\d{6}$/.test(dateStr)) {
43
+ const yy = dateStr.substring(0, 2);
44
+ const mm = dateStr.substring(2, 4);
45
+ const dd = dateStr.substring(4, 6);
46
+
47
+ // Assume 19xx if YY >= 50, else 20xx
48
+ const year = parseInt(yy) >= 50 ? `19${yy}` : `20${yy}`;
49
+ return `${dd}/${mm}/${year}`;
50
+ }
51
+
52
+ // Otherwise try to parse as ISO 8601
53
+ const date = new Date(dateStr);
54
+ if (!isNaN(date.getTime())) {
55
+ const day = String(date.getDate()).padStart(2, '0');
56
+ const month = String(date.getMonth() + 1).padStart(2, '0');
57
+ const year = date.getFullYear();
58
+ return `${day}/${month}/${year}`;
59
+ }
60
+ return dateStr;
61
+ } catch {
62
+ return dateStr;
63
+ }
64
+ }, []);
36
65
  const apiUrl = useMemo(() => `${appContext.baseUrl}/api/app/mobile`, [appContext.baseUrl]);
37
66
  useEffect(() => {
38
67
  if (appContext.isDemoSession) {
@@ -414,7 +443,7 @@ const ResultScreen = () => {
414
443
  children: [t('eidScannerScreen.birthDate'), ":"]
415
444
  }), /*#__PURE__*/_jsx(Text, {
416
445
  style: styles.mrzInfoText,
417
- children: appContext.identificationInfo.scannedDocument.mrzFields?.birthDate
446
+ children: formatDate(appContext.identificationInfo.scannedDocument.mrzFields?.birthDate)
418
447
  })]
419
448
  }), /*#__PURE__*/_jsxs(View, {
420
449
  style: styles.mrzInfoItem,
@@ -432,18 +461,18 @@ const ResultScreen = () => {
432
461
  children: [t('eidScannerScreen.expirationDate'), ":"]
433
462
  }), /*#__PURE__*/_jsx(Text, {
434
463
  style: styles.mrzInfoText,
435
- children: appContext.identificationInfo.scannedDocument.mrzFields?.expirationDate
436
- })]
437
- }), /*#__PURE__*/_jsxs(View, {
438
- style: styles.mrzInfoItem,
439
- children: [/*#__PURE__*/_jsxs(Text, {
440
- style: styles.mrzInfoLabel,
441
- children: [t('eidScannerScreen.mrzText'), ":"]
442
- }), /*#__PURE__*/_jsx(Text, {
443
- style: styles.mrzInfoText,
444
- children: appContext.identificationInfo.scannedDocument.mrzText
464
+ children: formatDate(appContext.identificationInfo.scannedDocument.mrzFields?.expirationDate)
445
465
  })]
446
466
  })]
467
+ }), appContext.identificationInfo.scannedDocument.mrzText && /*#__PURE__*/_jsxs(View, {
468
+ style: styles.mrzTextContainer,
469
+ children: [/*#__PURE__*/_jsx(Text, {
470
+ style: styles.mrzTextLabel,
471
+ children: t('eidScannerScreen.mrzText')
472
+ }), /*#__PURE__*/_jsx(Text, {
473
+ style: styles.mrzTextValue,
474
+ children: appContext.identificationInfo.scannedDocument.mrzText
475
+ })]
447
476
  }), /*#__PURE__*/_jsx(Text, {
448
477
  style: styles.sectionText,
449
478
  children: t('resultScreen.demoImages')
@@ -547,13 +576,18 @@ const ResultScreen = () => {
547
576
  })]
548
577
  })]
549
578
  })
550
- }), /*#__PURE__*/_jsx(StyledButton, {
551
- mode: "contained",
552
- onPress: () => {
553
- appContext.onCompleted?.();
554
- navigationManagerRef.current?.reset();
579
+ }), /*#__PURE__*/_jsx(View, {
580
+ style: {
581
+ paddingBottom: insets.bottom
555
582
  },
556
- children: t('resultScreen.demoStartOver')
583
+ children: /*#__PURE__*/_jsx(StyledButton, {
584
+ mode: "contained",
585
+ onPress: () => {
586
+ appContext.onCompleted?.();
587
+ navigationManagerRef.current?.reset();
588
+ },
589
+ children: t('resultScreen.demoStartOver')
590
+ })
557
591
  })]
558
592
  }) : /*#__PURE__*/_jsxs(_Fragment, {
559
593
  children: [/*#__PURE__*/_jsx(LottieView, {
@@ -582,9 +616,11 @@ const styles = StyleSheet.create({
582
616
  container: {
583
617
  flex: 1,
584
618
  display: 'flex',
585
- padding: 20,
619
+ paddingVertical: 20,
620
+ paddingHorizontal: 10,
586
621
  justifyContent: 'center',
587
- gap: 20
622
+ gap: 20,
623
+ backgroundColor: 'white'
588
624
  },
589
625
  sectionAnimation: {
590
626
  width: 192,
@@ -627,18 +663,20 @@ const styles = StyleSheet.create({
627
663
  image: {
628
664
  width: 100,
629
665
  height: 100,
630
- objectFit: 'contain'
666
+ objectFit: 'contain',
667
+ borderRadius: 8
631
668
  },
632
669
  imageItem: {
633
670
  display: 'flex',
634
671
  flexDirection: 'column',
635
- gap: 10,
672
+ gap: 8,
636
673
  alignItems: 'center'
637
674
  },
638
675
  imageContainer: {
639
676
  display: 'flex',
640
677
  flexDirection: 'row',
641
- gap: 10
678
+ gap: 10,
679
+ paddingVertical: 8
642
680
  },
643
681
  imageText: {
644
682
  fontSize: 10,
@@ -648,14 +686,19 @@ const styles = StyleSheet.create({
648
686
  },
649
687
  mrzInfo: {
650
688
  flexDirection: 'column',
651
- width: '100%'
689
+ width: '100%',
690
+ borderWidth: 1,
691
+ borderColor: '#D1D5DB',
692
+ borderRadius: 8,
693
+ overflow: 'hidden'
652
694
  },
653
695
  mrzInfoItem: {
654
696
  flexDirection: 'row',
655
697
  justifyContent: 'space-between',
656
- borderBottomColor: 'lightgray',
698
+ borderBottomColor: '#D1D5DB',
657
699
  borderBottomWidth: 1,
658
- paddingVertical: 5
700
+ paddingVertical: 8,
701
+ paddingHorizontal: 12
659
702
  },
660
703
  mrzInfoLabel: {
661
704
  color: 'black',
@@ -664,7 +707,28 @@ const styles = StyleSheet.create({
664
707
  },
665
708
  mrzInfoText: {
666
709
  color: 'black',
667
- fontSize: 10
710
+ fontSize: 10,
711
+ fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace'
712
+ },
713
+ mrzTextContainer: {
714
+ padding: 12,
715
+ backgroundColor: '#F3F4F6',
716
+ borderRadius: 8,
717
+ borderWidth: 1,
718
+ borderColor: '#D1D5DB'
719
+ },
720
+ mrzTextLabel: {
721
+ fontSize: 12,
722
+ fontWeight: '600',
723
+ color: '#6B7280',
724
+ marginBottom: 8
725
+ },
726
+ mrzTextValue: {
727
+ fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace',
728
+ fontSize: 10,
729
+ letterSpacing: 1,
730
+ lineHeight: 14,
731
+ color: '#1F2937'
668
732
  },
669
733
  trustchexLogo: {
670
734
  width: 150,
@@ -4,7 +4,7 @@ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState }
4
4
  import { SafeAreaView, Text, StyleSheet, Alert, View, Image, Dimensions, KeyboardAvoidingView, Platform, ScrollView } from 'react-native';
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
6
6
  import AppContext from "../../Shared/Contexts/AppContext.js";
7
- import httpClient, { BadRequestError, NotFoundError, TooManyRequestsError } from "../../Shared/Libs/http-client.js";
7
+ import httpClient, { NotFoundError } from "../../Shared/Libs/http-client.js";
8
8
  import { useTranslation } from 'react-i18next';
9
9
  import LanguageSelector from "../../Shared/Components/LanguageSelector.js";
10
10
  import NavigationManager from "../../Shared/Components/NavigationManager.js";
@@ -20,11 +20,8 @@ import { trackError, trackFunnelStep, useScreenTracking } from "../../Shared/Lib
20
20
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
21
21
  const VerificationSessionCheckScreen = () => {
22
22
  const [sessionCode, setSessionCode] = useState('');
23
- const [code, setCode] = useState('');
24
23
  const [isCheckingSession, setIsCheckingSession] = useState(false);
25
- const [isSendAgainEnabled, setIsSendAgainEnabled] = useState(false);
26
- const [isCodeSent, setIsCodeSent] = useState(false);
27
- const [isCodeGettingVerified, setIsCodeGettingVerified] = useState(false);
24
+ const isCheckingSessionRef = useRef(false);
28
25
  const appContext = useContext(AppContext);
29
26
  const {
30
27
  t
@@ -42,9 +39,10 @@ const VerificationSessionCheckScreen = () => {
42
39
  const validateSessionCode = useCallback(value => {
43
40
  return SESSION_CODE_VALIDATION_PATTERN.test(value.toUpperCase());
44
41
  }, []);
45
- const getSession = useCallback(async id => {
42
+ const getSession = useCallback(async (id, isDemoMode) => {
43
+ const isDemo = isDemoMode ?? appContext.isDemoSession;
46
44
  try {
47
- const response = await httpClient.get(`${apiUrl}/verification-sessions/${id}`, appContext.isDemoSession ? getSimulatedDemoData('GET_SESSION') : undefined);
45
+ const response = await httpClient.get(`${apiUrl}/verification-sessions/${id}`, isDemo ? getSimulatedDemoData('GET_SESSION') : undefined);
48
46
  return response;
49
47
  } catch (error) {
50
48
  if (error instanceof NotFoundError) {
@@ -60,9 +58,10 @@ const VerificationSessionCheckScreen = () => {
60
58
  }, [apiUrl, appContext.isDemoSession, t]);
61
59
  const getSessionByCode = useCallback(async inputCode => {
62
60
  try {
63
- appContext.isDemoSession = isDemoSession(inputCode);
64
- analyticsService.setDemoSession(appContext.isDemoSession);
65
- const response = await httpClient.get(`${apiUrl}/verification-sessions?sessionCode=${inputCode.toUpperCase()}`, appContext.isDemoSession ? getSimulatedDemoData('GET_SESSION_BY_CODE') : undefined);
61
+ const isDemoMode = isDemoSession(inputCode);
62
+ appContext.setIsDemoSession?.(isDemoMode);
63
+ analyticsService.setDemoSession(isDemoMode);
64
+ const response = await httpClient.get(`${apiUrl}/verification-sessions?sessionCode=${inputCode.toUpperCase()}`, isDemoMode ? getSimulatedDemoData('GET_SESSION_BY_CODE') : undefined);
66
65
  if (!response || !response.id) {
67
66
  throw new NotFoundError();
68
67
  }
@@ -82,68 +81,17 @@ const VerificationSessionCheckScreen = () => {
82
81
  }
83
82
  }
84
83
  }, [apiUrl, appContext, t]);
85
- const sendVerificationCode = useCallback(async sessionId => {
86
- try {
87
- await httpClient.post(`${apiUrl}/verification-sessions/${sessionId}`, {}, appContext.isDemoSession ? getSimulatedDemoData('SEND_VERIFICATION_CODE') : undefined);
88
- return true;
89
- } catch (error) {
90
- if (error instanceof NotFoundError) {
91
- // Session expired or invalid - expected behavior, not actionable
92
- Alert.alert(t('general.error'), t('verificationSessionCheckScreen.noVerificationSessionFound'));
93
- } else if (error instanceof TooManyRequestsError) {
94
- // Code was already sent recently - this is expected behavior
95
- // Return true since the code was already sent
96
- return true;
97
- } else {
98
- trackError('VERIFICATION_CODE_SEND_FAILED', 'Failed to send verification code', 'verification_session_check', 'high', {
99
- recoverable: true,
100
- userAction: 'send_verification_code'
101
- });
102
- Alert.alert(t('general.error'), t('verificationSessionCheckScreen.cannotSendVerificationCode'));
103
- }
104
- }
105
- return false;
106
- }, [apiUrl, appContext.isDemoSession, t]);
107
- const getVerifiedSession = useCallback(async (sessionId, verificationCode) => {
108
- try {
109
- const response = await httpClient.post(`${apiUrl}/verification-sessions/${sessionId}`, {
110
- code: verificationCode
111
- }, appContext.isDemoSession ? getSimulatedDemoData('GET_VERIFIED_SESSION', {
112
- code: verificationCode
113
- }) : undefined);
114
- return response;
115
- } catch (error) {
116
- if (error instanceof NotFoundError) {
117
- // Session expired or invalid - expected behavior, not actionable
118
- Alert.alert(t('general.error'), t('verificationSessionCheckScreen.noVerificationSessionFound'));
119
- } else if (error instanceof BadRequestError) {
120
- // Wrong OTP code - expected user behavior, not actionable
121
- } else {
122
- trackError('VERIFIED_SESSION_CHECK_ERROR', error instanceof Error ? error.message : 'Unknown error', 'verification_session_check', 'high', {
123
- recoverable: false,
124
- userAction: 'check_verified_session'
125
- });
126
- }
127
- }
128
- }, [apiUrl, appContext.isDemoSession, t]);
129
- const sendOTPCode = useCallback(async sessionId => {
130
- if (!sessionId) {
131
- return false;
132
- }
133
- const isSent = await sendVerificationCode(sessionId);
134
- if (!isSent) {
135
- return false;
136
- }
137
- setIsSendAgainEnabled(false);
138
- setTimeout(() => {
139
- setIsSendAgainEnabled(true);
140
- }, 3 * 60 * 1000);
141
- setIsCodeSent(true);
142
- return true;
143
- }, [sendVerificationCode]);
84
+ const navigateToOTPScreen = useCallback(sessionId => {
85
+ navigation.navigate('OTPVerificationScreen', {
86
+ sessionId
87
+ });
88
+ }, [navigation]);
144
89
  useEffect(() => {
145
- if (!initialized.current && appContext.identificationInfo.sessionId) {
90
+ // Only run this effect if sessionId exists AND we're not currently checking a session
91
+ // This prevents race condition when session code is entered
92
+ if (!initialized.current && appContext.identificationInfo.sessionId && !isCheckingSessionRef.current) {
146
93
  initialized.current = true;
94
+ isCheckingSessionRef.current = true;
147
95
  setIsCheckingSession(true);
148
96
  getSession(appContext.identificationInfo.sessionId).then(session => {
149
97
  appContext.workflowSteps = session?.workflowSteps;
@@ -151,18 +99,21 @@ const VerificationSessionCheckScreen = () => {
151
99
  appContext.branding = appContext.branding || session.branding;
152
100
  }
153
101
  if (session?.sendOTP) {
154
- return sendOTPCode(session.id);
155
- } else if (session?.identificationId) {
156
- appContext.identificationInfo.identificationId = session?.identificationId;
102
+ navigateToOTPScreen(session.id);
103
+ } else {
104
+ if (session?.identificationId) {
105
+ appContext.identificationInfo.identificationId = session?.identificationId;
106
+ }
157
107
  navigationManagerRef.current?.navigateToNextStep();
158
108
  }
159
109
  }).finally(() => {
160
110
  setTimeout(() => {
111
+ isCheckingSessionRef.current = false;
161
112
  setIsCheckingSession(false);
162
113
  }, 1000);
163
114
  });
164
115
  }
165
- }, [appContext, appContext.identificationInfo.sessionId, getSession, sendOTPCode]);
116
+ }, [appContext, appContext.identificationInfo.sessionId, getSession, navigateToOTPScreen]);
166
117
  return /*#__PURE__*/_jsx(SafeAreaView, {
167
118
  style: styles.safeAreaContainer,
168
119
  children: /*#__PURE__*/_jsx(KeyboardAvoidingView, {
@@ -187,13 +138,13 @@ const VerificationSessionCheckScreen = () => {
187
138
  source: require('../../Shared/Assets/trustchex-logo-black.png'),
188
139
  style: styles.trustchexLogo
189
140
  })
190
- }), isCheckingSession || isCodeGettingVerified ? /*#__PURE__*/_jsx(LottieView, {
141
+ }), isCheckingSession ? /*#__PURE__*/_jsx(LottieView, {
191
142
  source: require('../../Shared/Animations/loading.json'),
192
143
  style: styles.loadingAnimation,
193
144
  autoPlay: true,
194
145
  loop: true,
195
146
  resizeMode: "cover"
196
- }) : !isCodeSent ? /*#__PURE__*/_jsxs(_Fragment, {
147
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
197
148
  children: [/*#__PURE__*/_jsx(Text, {
198
149
  style: styles.mainText,
199
150
  children: t('verificationSessionCheckScreen.mainText')
@@ -211,21 +162,37 @@ const VerificationSessionCheckScreen = () => {
211
162
  setSessionCode(alphanumericText);
212
163
  if (validateSessionCode(alphanumericText) && alphanumericText.length === 8) {
213
164
  try {
165
+ isCheckingSessionRef.current = true;
214
166
  setIsCheckingSession(true);
215
- const session = await getSessionByCode(alphanumericText);
216
- if (session?.id) {
167
+ const isDemoMode = isDemoSession(alphanumericText);
168
+ const sessionResponse = await getSessionByCode(alphanumericText);
169
+ if (sessionResponse?.id) {
217
170
  if (appContext.setSessionId) {
218
- appContext.setSessionId(session.id);
171
+ appContext.setSessionId(sessionResponse.id);
219
172
  } else {
220
- appContext.identificationInfo.sessionId = session.id;
173
+ appContext.identificationInfo.sessionId = sessionResponse.id;
174
+ }
175
+ const session = await getSession(sessionResponse.id, isDemoMode);
176
+ appContext.workflowSteps = session?.workflowSteps;
177
+ if (session?.branding) {
178
+ appContext.branding = appContext.branding || session.branding;
179
+ }
180
+ if (session?.sendOTP) {
181
+ navigateToOTPScreen(sessionResponse.id);
182
+ } else {
183
+ if (session?.identificationId) {
184
+ appContext.identificationInfo.identificationId = session?.identificationId;
185
+ }
186
+ navigationManagerRef.current?.navigateToNextStep();
221
187
  }
222
188
  } else {
223
189
  setSessionCode('');
224
190
  }
225
- } catch {
191
+ } catch (error) {
226
192
  setSessionCode('');
227
193
  } finally {
228
194
  setTimeout(() => {
195
+ isCheckingSessionRef.current = false;
229
196
  setIsCheckingSession(false);
230
197
  }, 1000);
231
198
  }
@@ -254,53 +221,6 @@ const VerificationSessionCheckScreen = () => {
254
221
  },
255
222
  children: t('verificationSessionCheckScreen.scanQRCode')
256
223
  })]
257
- }) : /*#__PURE__*/_jsxs(_Fragment, {
258
- children: [/*#__PURE__*/_jsx(Text, {
259
- style: styles.mainText,
260
- children: t('verificationSessionCheckScreen.codeText')
261
- }), /*#__PURE__*/_jsx(StyledTextInput, {
262
- autoFocus: true,
263
- placeholder: "",
264
- borderColor: primaryColor,
265
- focusedBorderColor: primaryColor,
266
- inputStyle: styles.otpCodeTextInput,
267
- keyboardType: "number-pad",
268
- textContentType: "oneTimeCode",
269
- autoComplete: "sms-otp",
270
- maxLength: 6,
271
- onChangeText: text => {
272
- const numericText = text.replace(/[^0-9]/g, '');
273
- if (numericText.length <= 6) {
274
- setCode(numericText);
275
- if (numericText.length === 6) {
276
- (async () => {
277
- setIsCodeGettingVerified(true);
278
- const verifiedSession = await getVerifiedSession(appContext.identificationInfo.sessionId, numericText);
279
- if (verifiedSession?.identificationId) {
280
- appContext.identificationInfo.identificationId = verifiedSession?.identificationId;
281
- setCode('');
282
- setIsCodeSent(false);
283
- navigationManagerRef.current?.navigateToNextStep();
284
- } else {
285
- // User entered wrong OTP code - expected behavior, not actionable
286
- appContext.onError?.('Invalid OTP code');
287
- Alert.alert(t('general.error'), t('verificationSessionCheckScreen.codeError'));
288
- setCode('');
289
- setIsCodeGettingVerified(false);
290
- }
291
- })();
292
- }
293
- }
294
- },
295
- value: code
296
- }), /*#__PURE__*/_jsx(StyledButton, {
297
- mode: "contained",
298
- disabled: !isSendAgainEnabled,
299
- onPress: () => {
300
- sendOTPCode(appContext.identificationInfo.sessionId);
301
- },
302
- children: t('verificationSessionCheckScreen.sendCodeAgain')
303
- })]
304
224
  })]
305
225
  }), appContext.branding.logoUrl && /*#__PURE__*/_jsxs(View, {
306
226
  style: [styles.footer, {
@@ -428,12 +348,6 @@ const styles = StyleSheet.create({
428
348
  letterSpacing: 0,
429
349
  textAlign: 'center',
430
350
  textTransform: 'none'
431
- },
432
- otpCodeTextInput: {
433
- fontWeight: '800',
434
- fontSize: 28,
435
- textAlign: 'center',
436
- letterSpacing: 8
437
351
  }
438
352
  });
439
353
  export default VerificationSessionCheckScreen;