@trustchex/react-native-sdk 1.250.0 → 1.266.0

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 (100) hide show
  1. package/README.md +43 -2
  2. package/android/src/main/java/com/trustchex/reactnativesdk/DeviceBrightnessModule.kt +66 -0
  3. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +12 -0
  4. package/ios/DeviceBrightnessModule.h +4 -0
  5. package/ios/DeviceBrightnessModule.m +27 -0
  6. package/lib/module/Screens/Dynamic/ContractAcceptanceScreen.js +25 -0
  7. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +19 -0
  8. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +19 -0
  9. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +18 -5
  10. package/lib/module/Screens/Static/QrCodeScanningScreen.js +10 -2
  11. package/lib/module/Screens/Static/ResultScreen.js +52 -3
  12. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +82 -72
  13. package/lib/module/Shared/Components/EIDScanner.js +63 -3
  14. package/lib/module/Shared/Components/FaceCamera.js +73 -6
  15. package/lib/module/Shared/Components/IdentityDocumentCamera.js +9 -4
  16. package/lib/module/Shared/Components/LanguageSelector.js +14 -10
  17. package/lib/module/Shared/Components/NavigationManager.js +4 -2
  18. package/lib/module/Shared/Components/QrCodeScannerCamera.js +6 -1
  19. package/lib/module/Shared/Components/StyledButton.js +108 -9
  20. package/lib/module/Shared/Components/StyledTextInput.js +87 -0
  21. package/lib/module/Shared/Contexts/AppContext.js +3 -1
  22. package/lib/module/Shared/Contexts/ThemeContext.js +40 -0
  23. package/lib/module/Shared/Libs/analytics.utils.js +430 -0
  24. package/lib/module/Shared/Libs/camera.utils.js +58 -2
  25. package/lib/module/Shared/Libs/deeplink.utils.js +8 -0
  26. package/lib/module/Shared/Libs/http-client.js +89 -28
  27. package/lib/module/Shared/Services/AnalyticsService.js +404 -0
  28. package/lib/module/Shared/Types/analytics.types.js +111 -0
  29. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +1 -0
  30. package/lib/module/Translation/index.js +17 -5
  31. package/lib/module/Trustchex.js +52 -16
  32. package/lib/module/index.js +3 -0
  33. package/lib/typescript/src/Screens/Dynamic/ContractAcceptanceScreen.d.ts.map +1 -1
  34. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
  35. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
  36. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  37. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
  38. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  39. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
  40. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  41. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +7 -1
  42. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  43. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  44. package/lib/typescript/src/Shared/Components/LanguageSelector.d.ts.map +1 -1
  45. package/lib/typescript/src/Shared/Components/NavigationManager.d.ts.map +1 -1
  46. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
  47. package/lib/typescript/src/Shared/Components/StyledButton.d.ts +12 -2
  48. package/lib/typescript/src/Shared/Components/StyledButton.d.ts.map +1 -1
  49. package/lib/typescript/src/Shared/Components/StyledTextInput.d.ts +15 -0
  50. package/lib/typescript/src/Shared/Components/StyledTextInput.d.ts.map +1 -0
  51. package/lib/typescript/src/Shared/Contexts/AppContext.d.ts +2 -0
  52. package/lib/typescript/src/Shared/Contexts/AppContext.d.ts.map +1 -1
  53. package/lib/typescript/src/Shared/Contexts/ThemeContext.d.ts +26 -0
  54. package/lib/typescript/src/Shared/Contexts/ThemeContext.d.ts.map +1 -0
  55. package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts +98 -0
  56. package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -0
  57. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +19 -1
  58. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +1 -1
  59. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
  60. package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
  61. package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts +86 -0
  62. package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -0
  63. package/lib/typescript/src/Shared/Types/analytics.types.d.ts +146 -0
  64. package/lib/typescript/src/Shared/Types/analytics.types.d.ts.map +1 -0
  65. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +1 -1
  66. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  67. package/lib/typescript/src/Translation/index.d.ts.map +1 -1
  68. package/lib/typescript/src/Trustchex.d.ts +1 -0
  69. package/lib/typescript/src/Trustchex.d.ts.map +1 -1
  70. package/lib/typescript/src/index.d.ts +4 -0
  71. package/lib/typescript/src/index.d.ts.map +1 -1
  72. package/package.json +6 -7
  73. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +35 -1
  74. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +30 -0
  75. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +30 -0
  76. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +30 -4
  77. package/src/Screens/Static/QrCodeScanningScreen.tsx +12 -2
  78. package/src/Screens/Static/ResultScreen.tsx +79 -4
  79. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +113 -90
  80. package/src/Shared/Components/EIDScanner.tsx +132 -3
  81. package/src/Shared/Components/FaceCamera.tsx +81 -4
  82. package/src/Shared/Components/IdentityDocumentCamera.tsx +8 -6
  83. package/src/Shared/Components/LanguageSelector.tsx +12 -11
  84. package/src/Shared/Components/NavigationManager.tsx +5 -3
  85. package/src/Shared/Components/QrCodeScannerCamera.tsx +5 -1
  86. package/src/Shared/Components/StyledButton.tsx +141 -10
  87. package/src/Shared/Components/StyledTextInput.tsx +128 -0
  88. package/src/Shared/Contexts/AppContext.ts +4 -0
  89. package/src/Shared/Contexts/ThemeContext.tsx +67 -0
  90. package/src/Shared/Libs/analytics.utils.ts +644 -0
  91. package/src/Shared/Libs/camera.utils.ts +74 -2
  92. package/src/Shared/Libs/deeplink.utils.ts +5 -0
  93. package/src/Shared/Libs/http-client.ts +105 -31
  94. package/src/Shared/Services/AnalyticsService.ts +470 -0
  95. package/src/Shared/Types/analytics.types.ts +179 -0
  96. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +1 -0
  97. package/src/Translation/Resources/tr.ts +2 -1
  98. package/src/Translation/index.ts +21 -10
  99. package/src/Trustchex.tsx +65 -20
  100. package/src/index.tsx +33 -0
@@ -6,7 +6,8 @@ import { CommonActions, useNavigation, usePreventRemove } from '@react-navigatio
6
6
  import { View, StyleSheet, Alert } from 'react-native';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import i18n from "../../Translation/index.js";
9
- import { Button } from 'react-native-paper';
9
+ import StyledButton from "./StyledButton.js";
10
+ import { analyticsService } from "../Services/AnalyticsService.js";
10
11
 
11
12
  // Simple global navigation lock
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -107,6 +108,7 @@ const NavigationManager = /*#__PURE__*/forwardRef(({
107
108
  appContext.currentWorkflowStep = undefined;
108
109
  appContext.workflowSteps = undefined;
109
110
  appContext.isDemoSession = false;
111
+ analyticsService.setDemoSession(false);
110
112
  appContext.identificationInfo = {
111
113
  sessionId: '',
112
114
  identificationId: '',
@@ -150,7 +152,7 @@ const NavigationManager = /*#__PURE__*/forwardRef(({
150
152
  }));
151
153
  return appContext.currentWorkflowStep && (!appContext.currentWorkflowStep?.required || canSkipStep) && /*#__PURE__*/_jsx(View, {
152
154
  style: styles.container,
153
- children: /*#__PURE__*/_jsx(Button, {
155
+ children: /*#__PURE__*/_jsx(StyledButton, {
154
156
  mode: "text",
155
157
  onPress: goToNextRouteWithAlert,
156
158
  children: t('navigationManager.skipStepLabel')
@@ -10,11 +10,13 @@ import { useTranslation } from 'react-i18next';
10
10
  import LottieView from 'lottie-react-native';
11
11
  import { scanCodes } from "../VisionCameraPlugins/BarcodeScanner/index.js";
12
12
  import StyledButton from "./StyledButton.js";
13
+ import { useTheme } from "../Contexts/ThemeContext.js";
13
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
15
  const QrCodeScannerCamera = ({
15
16
  onQrCodeScanned
16
17
  }) => {
17
18
  useKeepAwake();
19
+ const theme = useTheme();
18
20
  const cameraPermission = useCameraPermission();
19
21
  const [permissionsRequested, setPermissionsRequested] = React.useState(false);
20
22
  const [isActive, setIsActive] = React.useState(false);
@@ -123,11 +125,13 @@ const QrCodeScannerCamera = ({
123
125
  return /*#__PURE__*/_jsx(View, {
124
126
  style: styles.permissionContainer,
125
127
  children: /*#__PURE__*/_jsx(ActivityIndicator, {
126
- size: "large"
128
+ size: "large",
129
+ color: theme.colors.primary
127
130
  })
128
131
  });
129
132
  }
130
133
  if (!cameraPermission.hasPermission) {
134
+ // Camera permission denied by user - their choice, not actionable
131
135
  return /*#__PURE__*/_jsxs(View, {
132
136
  style: styles.permissionContainer,
133
137
  children: [/*#__PURE__*/_jsx(Text, {
@@ -143,6 +147,7 @@ const QrCodeScannerCamera = ({
143
147
  });
144
148
  }
145
149
  if (device == null) {
150
+ // No camera device - device limitation, not actionable
146
151
  return /*#__PURE__*/_jsx(View, {
147
152
  style: styles.permissionContainer,
148
153
  children: /*#__PURE__*/_jsx(TextView, {
@@ -1,18 +1,89 @@
1
1
  "use strict";
2
2
 
3
3
  import React from 'react';
4
- import { StyleSheet } from 'react-native';
5
- import { Button } from 'react-native-paper';
4
+ import { StyleSheet, TouchableOpacity, Text, ActivityIndicator } from 'react-native';
5
+ import { useTheme } from "../Contexts/ThemeContext.js";
6
+
7
+ // Calculate if a color is light or dark to determine text color
6
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
+ const isLightColor = color => {
10
+ // Remove # if present
11
+ const hex = color.replace('#', '');
12
+
13
+ // Convert to RGB
14
+ const r = parseInt(hex.substring(0, 2), 16);
15
+ const g = parseInt(hex.substring(2, 4), 16);
16
+ const b = parseInt(hex.substring(4, 6), 16);
17
+
18
+ // Calculate relative luminance using WCAG formula
19
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
20
+
21
+ // Return true if light (luminance > 0.5)
22
+ return luminance > 0.5;
23
+ };
7
24
  const StyledButton = ({
25
+ mode = 'contained',
26
+ onPress,
27
+ disabled = false,
28
+ loading = false,
29
+ children,
8
30
  style,
9
31
  labelStyle,
10
- ...props
32
+ buttonColor,
33
+ textColor
11
34
  }) => {
12
- return /*#__PURE__*/_jsx(Button, {
13
- ...props,
14
- style: [styles.button, style],
15
- labelStyle: [styles.label, labelStyle]
35
+ const theme = useTheme();
36
+ const primaryColor = buttonColor || theme.colors.primary;
37
+
38
+ // Determine text color based on background color for contained mode
39
+ const getContainedTextColor = () => {
40
+ if (textColor) return textColor;
41
+ return isLightColor(primaryColor) ? '#000000' : '#FFFFFF';
42
+ };
43
+ const containedTextColor = getContainedTextColor();
44
+ const getButtonStyle = () => {
45
+ const baseStyle = [styles.button, style];
46
+ if (mode === 'contained') {
47
+ return [...baseStyle, styles.containedButton, {
48
+ backgroundColor: primaryColor
49
+ }, disabled && styles.disabledButton];
50
+ }
51
+ if (mode === 'outlined') {
52
+ return [...baseStyle, styles.outlinedButton, {
53
+ borderColor: primaryColor
54
+ }, disabled && styles.disabledButton];
55
+ }
56
+ return [...baseStyle, styles.textButton];
57
+ };
58
+ const getTextStyle = () => {
59
+ const baseStyle = [styles.label, labelStyle];
60
+ if (mode === 'contained') {
61
+ return [...baseStyle, styles.containedLabel, {
62
+ color: containedTextColor
63
+ }, disabled && styles.disabledLabel];
64
+ }
65
+ if (mode === 'outlined') {
66
+ return [...baseStyle, styles.outlinedLabel, {
67
+ color: primaryColor
68
+ }, disabled && styles.disabledLabel];
69
+ }
70
+ return [...baseStyle, styles.textLabel, {
71
+ color: primaryColor
72
+ }, disabled && styles.disabledLabel];
73
+ };
74
+ const loadingColor = mode === 'contained' ? containedTextColor : primaryColor;
75
+ return /*#__PURE__*/_jsx(TouchableOpacity, {
76
+ style: getButtonStyle(),
77
+ onPress: onPress,
78
+ disabled: disabled || loading,
79
+ activeOpacity: 0.7,
80
+ children: loading ? /*#__PURE__*/_jsx(ActivityIndicator, {
81
+ size: "small",
82
+ color: loadingColor
83
+ }) : /*#__PURE__*/_jsx(Text, {
84
+ style: getTextStyle(),
85
+ children: children
86
+ })
16
87
  });
17
88
  };
18
89
  const styles = StyleSheet.create({
@@ -20,11 +91,39 @@ const styles = StyleSheet.create({
20
91
  borderRadius: 8,
21
92
  height: 56,
22
93
  justifyContent: 'center',
23
- elevation: 2
94
+ alignItems: 'center',
95
+ paddingHorizontal: 16
96
+ },
97
+ containedButton: {
98
+ elevation: 2,
99
+ shadowColor: '#000',
100
+ shadowOffset: {
101
+ width: 0,
102
+ height: 2
103
+ },
104
+ shadowOpacity: 0.25,
105
+ shadowRadius: 3.84
106
+ },
107
+ outlinedButton: {
108
+ backgroundColor: 'transparent',
109
+ borderWidth: 2
110
+ },
111
+ textButton: {
112
+ backgroundColor: 'transparent'
113
+ },
114
+ disabledButton: {
115
+ opacity: 0.5
24
116
  },
25
117
  label: {
26
118
  fontWeight: 'bold',
27
- fontSize: 16
119
+ fontSize: 16,
120
+ textAlign: 'center'
121
+ },
122
+ containedLabel: {},
123
+ outlinedLabel: {},
124
+ textLabel: {},
125
+ disabledLabel: {
126
+ opacity: 0.6
28
127
  }
29
128
  });
30
129
  export default StyledButton;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { StyleSheet, TextInput, View, Text } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ const StyledTextInput = /*#__PURE__*/React.forwardRef(({
7
+ containerStyle,
8
+ inputStyle,
9
+ placeholderStyle,
10
+ borderColor = '#DDDDDD',
11
+ focusedBorderColor,
12
+ backgroundColor = '#FFFFFF',
13
+ textColor = '#000000',
14
+ placeholderColor = '#999999',
15
+ style,
16
+ placeholderTextColor,
17
+ onFocus,
18
+ onBlur,
19
+ value,
20
+ ...props
21
+ }, ref) => {
22
+ const [isFocused, setIsFocused] = React.useState(false);
23
+ const hasValue = value !== undefined && value !== '';
24
+ const handleFocus = e => {
25
+ setIsFocused(true);
26
+ onFocus?.(e);
27
+ };
28
+ const handleBlur = e => {
29
+ setIsFocused(false);
30
+ onBlur?.(e);
31
+ };
32
+ const currentBorderColor = isFocused ? focusedBorderColor || borderColor : borderColor;
33
+ return /*#__PURE__*/_jsxs(View, {
34
+ style: [styles.container, containerStyle],
35
+ children: [/*#__PURE__*/_jsx(TextInput, {
36
+ ref: ref,
37
+ ...props,
38
+ value: value,
39
+ placeholder: "",
40
+ style: [styles.input, {
41
+ backgroundColor,
42
+ borderColor: currentBorderColor,
43
+ color: textColor
44
+ }, inputStyle, style],
45
+ onFocus: handleFocus,
46
+ onBlur: handleBlur
47
+ }), !hasValue && props.placeholder && /*#__PURE__*/_jsx(View, {
48
+ style: styles.placeholderContainer,
49
+ pointerEvents: "none",
50
+ children: /*#__PURE__*/_jsx(Text, {
51
+ style: [styles.placeholderText, {
52
+ color: placeholderColor || placeholderTextColor || '#999'
53
+ }, placeholderStyle],
54
+ children: props.placeholder
55
+ })
56
+ })]
57
+ });
58
+ });
59
+ StyledTextInput.displayName = 'StyledTextInput';
60
+ const styles = StyleSheet.create({
61
+ container: {
62
+ width: '100%',
63
+ position: 'relative'
64
+ },
65
+ input: {
66
+ borderWidth: 2,
67
+ borderRadius: 8,
68
+ height: 56,
69
+ paddingHorizontal: 16,
70
+ fontSize: 16,
71
+ fontWeight: '400'
72
+ },
73
+ placeholderContainer: {
74
+ position: 'absolute',
75
+ top: 0,
76
+ left: 0,
77
+ right: 0,
78
+ bottom: 0,
79
+ justifyContent: 'center',
80
+ paddingHorizontal: 16
81
+ },
82
+ placeholderText: {
83
+ fontSize: 16,
84
+ fontWeight: '400'
85
+ }
86
+ });
87
+ export default StyledTextInput;
@@ -23,5 +23,7 @@ export default /*#__PURE__*/createContext({
23
23
  workflowSteps: [],
24
24
  currentWorkflowStep: undefined,
25
25
  onCompleted: undefined,
26
- onError: undefined
26
+ onError: undefined,
27
+ setSessionId: undefined,
28
+ setBaseUrl: undefined
27
29
  });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ import React, { createContext, useContext, useMemo } from 'react';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const defaultColors = {
6
+ primary: '#000000',
7
+ secondary: '#CCCCCC',
8
+ tertiary: '#FF0000',
9
+ background: '#FFFFFF',
10
+ surface: '#F5F5F5',
11
+ text: '#000000',
12
+ textSecondary: '#666666',
13
+ border: '#DDDDDD',
14
+ error: '#E53935',
15
+ success: '#43A047'
16
+ };
17
+ const ThemeContext = /*#__PURE__*/createContext({
18
+ colors: defaultColors
19
+ });
20
+ export const useTheme = () => useContext(ThemeContext);
21
+ export const ThemeProvider = ({
22
+ children,
23
+ primaryColor,
24
+ secondaryColor,
25
+ tertiaryColor
26
+ }) => {
27
+ const colors = useMemo(() => ({
28
+ ...defaultColors,
29
+ primary: primaryColor || defaultColors.primary,
30
+ secondary: secondaryColor || defaultColors.secondary,
31
+ tertiary: tertiaryColor || defaultColors.tertiary
32
+ }), [primaryColor, secondaryColor, tertiaryColor]);
33
+ const value = useMemo(() => ({
34
+ colors
35
+ }), [colors]);
36
+ return /*#__PURE__*/_jsx(ThemeContext.Provider, {
37
+ value: value,
38
+ children: children
39
+ });
40
+ };