@test-web/react-native-sdk 1.0.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.
- package/README.md +58 -0
- package/android/build.gradle +50 -0
- package/android/src/main/AndroidManifest.xml +24 -0
- package/android/src/main/java/com/yourcompany/sdk/YourSDKModule.java +40 -0
- package/android/src/main/java/com/yourcompany/sdk/YourSDKPackage.java +24 -0
- package/ios/YourSDK-Bridging-Header.h +1 -0
- package/ios/YourSDK-Info.plist +30 -0
- package/ios/YourSDK.podspec +19 -0
- package/ios/YourSDKModule.h +5 -0
- package/ios/YourSDKModule.m +32 -0
- package/ios/YourSDKModule.swift +22 -0
- package/package.json +38 -0
- package/src/apis/index.ts +32 -0
- package/src/components/common/CustomOverlay.tsx +44 -0
- package/src/components/common/Footer.tsx +30 -0
- package/src/components/common/Header.tsx +29 -0
- package/src/components/common/Loader.tsx +23 -0
- package/src/components/index.tsx +6 -0
- package/src/components/ui/Button.tsx +41 -0
- package/src/components/ui/ThemedText.tsx +42 -0
- package/src/components/ui/index.tsx +2 -0
- package/src/context/IDMConfigurationContext.tsx +44 -0
- package/src/context/KeyboardContext.tsx +61 -0
- package/src/context/ThemeContext.tsx +34 -0
- package/src/context/themes.ts +134 -0
- package/src/hooks/useOrientation.ts +25 -0
- package/src/index.tsx +110 -0
- package/src/native/NativeModule.ts +10 -0
- package/src/screens/BackDocumentAdvice.tsx +52 -0
- package/src/screens/BarcodeAdvice.tsx +52 -0
- package/src/screens/BarcodeCapture.tsx +66 -0
- package/src/screens/CameraPermission.tsx +74 -0
- package/src/screens/DocumentCaptureBack.tsx +65 -0
- package/src/screens/DocumentCaptureFront.tsx +65 -0
- package/src/screens/FrontDocumentAdvice.tsx +52 -0
- package/src/screens/LocationPermission.tsx +74 -0
- package/src/screens/MrzAdvice.tsx +52 -0
- package/src/screens/MrzCapture.tsx +64 -0
- package/src/screens/NoCameraFound.tsx +64 -0
- package/src/screens/RetakeSelfie.tsx +56 -0
- package/src/screens/SelectDocuments.tsx +250 -0
- package/src/screens/SelfieAdvice.tsx +35 -0
- package/src/screens/SelfieCapture.tsx +56 -0
- package/src/screens/ThankYou.tsx +23 -0
- package/src/screens/VerifyIdentity.tsx +54 -0
- package/src/screens/index.tsx +17 -0
- package/src/styles/BarcodeAdviceStyles.ts +45 -0
- package/src/styles/DocumentAdviceStyles.ts +44 -0
- package/src/styles/DocumentCaptureStyles.ts +55 -0
- package/src/styles/PermissionStyle.ts +61 -0
- package/src/styles/RetakeStyles.ts +67 -0
- package/src/styles/ScannerStyles.ts +28 -0
- package/src/styles/SelectDocumentsStyles.ts +90 -0
- package/src/styles/SelfieAdviceStyles.ts +61 -0
- package/src/styles/SelfieCaptureStyles.ts +48 -0
- package/src/styles/ThankYouStyles.ts +31 -0
- package/src/styles/VerifyIdentityStyles.ts +86 -0
- package/src/types/IDMConf.ts +28 -0
- package/src/types/index.ts +12 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/metadata_new.json +1 -0
- package/src/utils/performance.ts +176 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Theme } from '../types';
|
|
3
|
+
import { Orientation } from '../hooks/useOrientation';
|
|
4
|
+
|
|
5
|
+
export default (theme: Theme, orientation: Orientation) => {
|
|
6
|
+
const isPortrait = orientation === 'portrait';
|
|
7
|
+
|
|
8
|
+
return StyleSheet.create({
|
|
9
|
+
container: {
|
|
10
|
+
flex: 1,
|
|
11
|
+
backgroundColor: theme.colors.background,
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
paddingHorizontal: 20,
|
|
15
|
+
},
|
|
16
|
+
maintitle: {
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
fontWeight: 'bold',
|
|
19
|
+
marginBottom: 20,
|
|
20
|
+
color: theme.colors.text,
|
|
21
|
+
fontSize: 32,
|
|
22
|
+
},
|
|
23
|
+
subtitle: {
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
fontWeight: '300',
|
|
26
|
+
color: theme.colors.subtitle,
|
|
27
|
+
fontSize: 20,
|
|
28
|
+
lineHeight: 30,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Theme } from '../types';
|
|
3
|
+
import { Orientation } from '../hooks/useOrientation';
|
|
4
|
+
|
|
5
|
+
export default (theme: Theme, orientation: Orientation) => {
|
|
6
|
+
const isPortrait = orientation === 'portrait';
|
|
7
|
+
|
|
8
|
+
return StyleSheet.create({
|
|
9
|
+
container: {
|
|
10
|
+
flex: 1,
|
|
11
|
+
backgroundColor: theme.colors.background,
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
paddingHorizontal: 20,
|
|
14
|
+
paddingTop: isPortrait ? 40 : 20,
|
|
15
|
+
},
|
|
16
|
+
maintitle: {
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
fontWeight: '300',
|
|
19
|
+
marginBottom: isPortrait ? 30 : 15,
|
|
20
|
+
color: theme.colors.text,
|
|
21
|
+
},
|
|
22
|
+
subtitle: {
|
|
23
|
+
fontSize: 17,
|
|
24
|
+
lineHeight: 24,
|
|
25
|
+
fontWeight: '400',
|
|
26
|
+
textAlign: 'center',
|
|
27
|
+
color: theme.colors.subtitle,
|
|
28
|
+
},
|
|
29
|
+
list: {
|
|
30
|
+
marginTop: isPortrait ? 30 : 15,
|
|
31
|
+
marginBottom: isPortrait ? 20 : 10,
|
|
32
|
+
marginLeft: 'auto',
|
|
33
|
+
marginRight: 'auto',
|
|
34
|
+
justifyContent: 'center',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
width: 135,
|
|
37
|
+
},
|
|
38
|
+
listItem: {
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
marginBottom: 15,
|
|
41
|
+
},
|
|
42
|
+
numberCircle: {
|
|
43
|
+
width: 24,
|
|
44
|
+
height: 24,
|
|
45
|
+
borderRadius: 12,
|
|
46
|
+
backgroundColor: theme.colors.primary,
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
marginRight: 10,
|
|
50
|
+
},
|
|
51
|
+
numberText: {
|
|
52
|
+
color: theme.colors.buttonText,
|
|
53
|
+
fontWeight: 'bold',
|
|
54
|
+
fontSize: 14,
|
|
55
|
+
},
|
|
56
|
+
listText: {
|
|
57
|
+
fontSize: 16,
|
|
58
|
+
fontWeight: 'bold',
|
|
59
|
+
color: theme.colors.text,
|
|
60
|
+
},
|
|
61
|
+
saprater: {
|
|
62
|
+
height: 10,
|
|
63
|
+
width: 4,
|
|
64
|
+
backgroundColor: '#ee7e22',
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
left: 14,
|
|
67
|
+
top: 27,
|
|
68
|
+
},
|
|
69
|
+
buttonplace: {
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
bottom: isPortrait ? 80 : 20,
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
},
|
|
75
|
+
button: {
|
|
76
|
+
backgroundColor: theme.colors.buttonBackground,
|
|
77
|
+
color: theme.colors.buttonText,
|
|
78
|
+
fontSize: 16,
|
|
79
|
+
fontWeight: 'bold',
|
|
80
|
+
paddingVertical: 6,
|
|
81
|
+
paddingHorizontal: 15,
|
|
82
|
+
borderRadius: 5,
|
|
83
|
+
textAlign: 'center',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface IDMConf {
|
|
2
|
+
theme?: string | any;
|
|
3
|
+
userDetails?: UserDetails;
|
|
4
|
+
accessToken?: string;
|
|
5
|
+
verificationCode?: string;
|
|
6
|
+
requestData?: any;
|
|
7
|
+
configuration?: any;
|
|
8
|
+
countryDetails?: CountryDetail[];
|
|
9
|
+
selectedCountryDetails?: any;
|
|
10
|
+
requestConfiguration?: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface UserDetails {
|
|
14
|
+
permissionGranted?: boolean;
|
|
15
|
+
location?: {
|
|
16
|
+
coords: {
|
|
17
|
+
latitude: number;
|
|
18
|
+
longitude: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CountryDetail {
|
|
25
|
+
label: string;
|
|
26
|
+
value: string;
|
|
27
|
+
metadata: any[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const formatDate = (date: Date): string => {
|
|
2
|
+
return date.toLocaleDateString();
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export const validateApiKey = (key: string): boolean => {
|
|
6
|
+
return key.length > 0;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// Performance utilities
|
|
10
|
+
export {
|
|
11
|
+
debounce,
|
|
12
|
+
throttle,
|
|
13
|
+
memoize,
|
|
14
|
+
shallowEqual,
|
|
15
|
+
measurePerformance,
|
|
16
|
+
measureAsyncPerformance,
|
|
17
|
+
BatchUpdater,
|
|
18
|
+
createStableRef,
|
|
19
|
+
} from './performance';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance utilities for the SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Debounce function to limit how often a function can be called
|
|
7
|
+
* Useful for search inputs, scroll handlers, etc.
|
|
8
|
+
*/
|
|
9
|
+
export function debounce<T extends (...args: any[]) => any>(
|
|
10
|
+
func: T,
|
|
11
|
+
wait: number
|
|
12
|
+
): (...args: Parameters<T>) => void {
|
|
13
|
+
let timeout: NodeJS.Timeout | null = null;
|
|
14
|
+
|
|
15
|
+
return function executedFunction(...args: Parameters<T>) {
|
|
16
|
+
const later = () => {
|
|
17
|
+
timeout = null;
|
|
18
|
+
func(...args);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
if (timeout) {
|
|
22
|
+
clearTimeout(timeout);
|
|
23
|
+
}
|
|
24
|
+
timeout = setTimeout(later, wait);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Throttle function to ensure a function is called at most once per interval
|
|
30
|
+
* Useful for scroll handlers, resize handlers, etc.
|
|
31
|
+
*/
|
|
32
|
+
export function throttle<T extends (...args: any[]) => any>(
|
|
33
|
+
func: T,
|
|
34
|
+
limit: number
|
|
35
|
+
): (...args: Parameters<T>) => void {
|
|
36
|
+
let inThrottle: boolean;
|
|
37
|
+
|
|
38
|
+
return function executedFunction(...args: Parameters<T>) {
|
|
39
|
+
if (!inThrottle) {
|
|
40
|
+
func(...args);
|
|
41
|
+
inThrottle = true;
|
|
42
|
+
setTimeout(() => (inThrottle = false), limit);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Memoize function results to avoid expensive recalculations
|
|
49
|
+
* Simple implementation for single-argument functions
|
|
50
|
+
*/
|
|
51
|
+
export function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
|
52
|
+
const cache = new Map();
|
|
53
|
+
|
|
54
|
+
return ((...args: any[]) => {
|
|
55
|
+
const key = JSON.stringify(args);
|
|
56
|
+
if (cache.has(key)) {
|
|
57
|
+
return cache.get(key);
|
|
58
|
+
}
|
|
59
|
+
const result = fn(...args);
|
|
60
|
+
cache.set(key, result);
|
|
61
|
+
return result;
|
|
62
|
+
}) as T;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Check if two objects are shallowly equal
|
|
67
|
+
* Useful for custom comparison in React.memo
|
|
68
|
+
*/
|
|
69
|
+
export function shallowEqual(obj1: any, obj2: any): boolean {
|
|
70
|
+
if (obj1 === obj2) return true;
|
|
71
|
+
if (!obj1 || !obj2) return false;
|
|
72
|
+
|
|
73
|
+
const keys1 = Object.keys(obj1);
|
|
74
|
+
const keys2 = Object.keys(obj2);
|
|
75
|
+
|
|
76
|
+
if (keys1.length !== keys2.length) return false;
|
|
77
|
+
|
|
78
|
+
for (const key of keys1) {
|
|
79
|
+
if (obj1[key] !== obj2[key]) return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Performance logger for development
|
|
87
|
+
* Measures execution time of functions
|
|
88
|
+
*/
|
|
89
|
+
export function measurePerformance<T extends (...args: any[]) => any>(
|
|
90
|
+
fn: T,
|
|
91
|
+
label: string
|
|
92
|
+
): T {
|
|
93
|
+
return ((...args: any[]) => {
|
|
94
|
+
const start = performance.now();
|
|
95
|
+
const result = fn(...args);
|
|
96
|
+
const end = performance.now();
|
|
97
|
+
console.log(`[Performance] ${label}: ${(end - start).toFixed(2)}ms`);
|
|
98
|
+
return result;
|
|
99
|
+
}) as T;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Async performance logger
|
|
104
|
+
*/
|
|
105
|
+
export function measureAsyncPerformance<T extends (...args: any[]) => Promise<any>>(
|
|
106
|
+
fn: T,
|
|
107
|
+
label: string
|
|
108
|
+
): T {
|
|
109
|
+
return (async (...args: any[]) => {
|
|
110
|
+
const start = performance.now();
|
|
111
|
+
const result = await fn(...args);
|
|
112
|
+
const end = performance.now();
|
|
113
|
+
console.log(`[Performance] ${label}: ${(end - start).toFixed(2)}ms`);
|
|
114
|
+
return result;
|
|
115
|
+
}) as T;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Batch updates to reduce re-renders
|
|
120
|
+
* Collects multiple state updates and applies them together
|
|
121
|
+
*/
|
|
122
|
+
export class BatchUpdater<T> {
|
|
123
|
+
private updates: Partial<T>[] = [];
|
|
124
|
+
private timeout: NodeJS.Timeout | null = null;
|
|
125
|
+
private callback: (updates: Partial<T>) => void;
|
|
126
|
+
|
|
127
|
+
constructor(callback: (updates: Partial<T>) => void, delay: number = 16) {
|
|
128
|
+
this.callback = callback;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
add(update: Partial<T>) {
|
|
132
|
+
this.updates.push(update);
|
|
133
|
+
|
|
134
|
+
if (this.timeout) {
|
|
135
|
+
clearTimeout(this.timeout);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.timeout = setTimeout(() => {
|
|
139
|
+
this.flush();
|
|
140
|
+
}, 16);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
flush() {
|
|
144
|
+
if (this.updates.length === 0) return;
|
|
145
|
+
|
|
146
|
+
const merged = Object.assign({}, ...this.updates);
|
|
147
|
+
this.callback(merged);
|
|
148
|
+
this.updates = [];
|
|
149
|
+
this.timeout = null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Create a stable reference that only changes when dependencies change
|
|
155
|
+
* Similar to useMemo but for non-React contexts
|
|
156
|
+
*/
|
|
157
|
+
export function createStableRef<T>(
|
|
158
|
+
factory: () => T,
|
|
159
|
+
deps: any[]
|
|
160
|
+
): { current: T; update: () => void } {
|
|
161
|
+
let value = factory();
|
|
162
|
+
let lastDeps = deps;
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
get current() {
|
|
166
|
+
return value;
|
|
167
|
+
},
|
|
168
|
+
update() {
|
|
169
|
+
const depsChanged = lastDeps.some((dep, i) => dep !== deps[i]);
|
|
170
|
+
if (depsChanged) {
|
|
171
|
+
value = factory();
|
|
172
|
+
lastDeps = deps;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|