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

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/README.md +1 -1
  2. package/build/package.json +3 -2
  3. package/build/src/components/EnhancedCameraView.d.ts.map +1 -1
  4. package/build/src/components/EnhancedCameraView.js +19 -182
  5. package/build/src/components/EnhancedCameraView.js.map +1 -1
  6. package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  7. package/build/src/components/KYCElements/IDCardCapture.js +189 -191
  8. package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
  9. package/build/src/components/KYCElements/PhoneVerificationTemplate.d.ts.map +1 -1
  10. package/build/src/components/KYCElements/PhoneVerificationTemplate.js +0 -2
  11. package/build/src/components/KYCElements/PhoneVerificationTemplate.js.map +1 -1
  12. package/build/src/components/OverLay/IdCard.d.ts +6 -1
  13. package/build/src/components/OverLay/IdCard.d.ts.map +1 -1
  14. package/build/src/components/OverLay/IdCard.js +36 -34
  15. package/build/src/components/OverLay/IdCard.js.map +1 -1
  16. package/build/src/config/countriesData.d.ts.map +1 -1
  17. package/build/src/config/countriesData.js.map +1 -1
  18. package/build/src/modules/api/CardAuthentification.d.ts.map +1 -1
  19. package/build/src/modules/api/CardAuthentification.js +0 -1
  20. package/build/src/modules/api/CardAuthentification.js.map +1 -1
  21. package/build/src/modules/api/KYCService.d.ts.map +1 -1
  22. package/build/src/modules/api/KYCService.js +41 -24
  23. package/build/src/modules/api/KYCService.js.map +1 -1
  24. package/package.json +3 -2
  25. package/src/components/EnhancedCameraView.tsx +28 -219
  26. package/src/components/KYCElements/IDCardCapture.tsx +560 -581
  27. package/src/components/KYCElements/PhoneVerificationTemplate.tsx +0 -2
  28. package/src/components/OverLay/IdCard.tsx +48 -36
  29. package/src/config/countriesData.ts +0 -4
  30. package/src/modules/api/CardAuthentification.ts +0 -1
  31. package/src/modules/api/KYCService.ts +48 -29
package/README.md CHANGED
@@ -45,7 +45,7 @@ npm install @sanctum-key/react-native-sdk --legacy-peer-deps
45
45
  Use `npx expo install` so Expo automatically resolves the correct versions for your SDK build (e.g., SDK 53 or 54):
46
46
 
47
47
  ```bash
48
- npx expo install react-native-vision-camera expo-location expo-image-manipulator react-native-svg expo-file-system expo-dev-client
48
+ npx expo install react-native-vision-camera expo-location expo-image-manipulator react-native-svg expo-file-system expo-dev-client react-native-qrcode-svg
49
49
  ```
50
50
 
51
51
  ### Step 3 — Install Standard NPM Dependencies
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanctum-key/react-native-sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Sanctum Key React Native SDK",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -51,6 +51,7 @@
51
51
  "expo-blur": "~15.0.8",
52
52
  "i18n-js": "4.5.1",
53
53
  "iconsax-react-nativejs": "^0.0.8",
54
+ "react-native-qrcode-svg": "^6.3.21",
54
55
  "zustand": "^5.0.8"
55
56
  },
56
57
  "devDependencies": {
@@ -66,7 +67,7 @@
66
67
  "expo-location": "*",
67
68
  "react": "*",
68
69
  "react-native": "*",
69
- "react-native-svg": "*",
70
+ "react-native-svg": "^15.15.5",
70
71
  "react-native-vision-camera": "^4.7.1"
71
72
  }
72
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EnhancedCameraView.d.ts","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.tsx"],"names":[],"mappings":"AAuKA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA2IhE,CAAC"}
1
+ {"version":3,"file":"EnhancedCameraView.d.ts","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAOxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAIzD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAgHhE,CAAC"}
@@ -1,146 +1,3 @@
1
- // import React, { useCallback, useEffect, useRef, useState } from 'react';
2
- // import { View, StyleSheet, Text, AppState } from 'react-native';
3
- // import { Camera, useCameraDevice, useCameraFormat } from 'react-native-vision-camera';
4
- // import VisionCameraModule from '../modules/camera/VisionCameraModule';
5
- // import { useI18n } from '../hooks/useI18n';
6
- // import { EnhancedCameraViewProps } from './OverLay/type';
7
- // import { Button } from './ui/Button';
8
- // export const EnhancedCameraView: React.FC<EnhancedCameraViewProps> = ({
9
- // showCamera,
10
- // cameraType: initialCameraType = 'front',
11
- // style,
12
- // onError,
13
- // onSilentCapture,
14
- // silentCaptureResult,
15
- // isProcessing = false,
16
- // overlayComponent,
17
- // }) => {
18
- // const { t } = useI18n();
19
- // const camera = useRef<Camera>(null);
20
- // const isCapturingRef = useRef(false);
21
- // const isProcessingRef = useRef(isProcessing);
22
- // const [cameraType] = useState<'front' | 'back'>(initialCameraType);
23
- // const [hasPermission, setHasPermission] = useState<boolean | null>(null);
24
- // const [isInitialized, setIsInitialized] = useState(false);
25
- // const [refreshCamera, setRefreshCamera] = useState(false);
26
- // const [layout, setLayout] = useState({ width: 0, height: 0 });
27
- // const device = useCameraDevice(cameraType, {
28
- // physicalDevices: [
29
- // 'wide-angle-camera' // Explicitly request standard 1x lens
30
- // ]
31
- // });
32
- // const targetRatio = layout.width > 0 ? layout.height / layout.width : 16 / 9;
33
- // const format = useCameraFormat(device, [
34
- // { photoAspectRatio: targetRatio },
35
- // { photoResolution: 'max' }
36
- // ]);
37
- // useEffect(() => {
38
- // isProcessingRef.current = isProcessing;
39
- // }, [isProcessing]);
40
- // const checkPermissions = async () => {
41
- // try {
42
- // const hasAllPermissions = await VisionCameraModule.hasAllPermissions();
43
- // if (!hasAllPermissions) {
44
- // const granted = await VisionCameraModule.requestAllPermissions();
45
- // if (!granted) {
46
- // setHasPermission(false);
47
- // onError?.({ message: t('camera.permissionRequired') });
48
- // return;
49
- // }
50
- // }
51
- // setHasPermission(true);
52
- // } catch (error) {
53
- // setHasPermission(false);
54
- // onError?.({ message: t('camera.errorOccurred') });
55
- // }
56
- // };
57
- // useEffect(() => {
58
- // if (showCamera) checkPermissions();
59
- // }, [showCamera, refreshCamera]);
60
- // useEffect(() => {
61
- // const subscription = AppState.addEventListener('change', nextAppState => {
62
- // if (nextAppState === 'active' && showCamera && hasPermission === false) {
63
- // checkPermissions();
64
- // }
65
- // });
66
- // return () => subscription.remove();
67
- // }, [showCamera, hasPermission]);
68
- // const onInitialized = useCallback(() => setIsInitialized(true), []);
69
- // const onCameraError = useCallback((error: any) => {
70
- // onError?.({ message: error.message || t('camera.errorOccurred') });
71
- // }, [onError, t]);
72
- // const captureSilentPhoto = useCallback(async () => {
73
- // if (!camera.current || !isInitialized || isProcessingRef.current || isCapturingRef.current) return;
74
- // if (silentCaptureResult?.isAnalyzing) return;
75
- // try {
76
- // isCapturingRef.current = true;
77
- // const photo = await camera.current.takePhoto({
78
- // enableShutterSound: false,
79
- // flash: 'off',
80
- // });
81
- // const result = await VisionCameraModule.processPhotoResult(photo);
82
- // onSilentCapture?.({
83
- // ...result,
84
- // path: result.path || photo.path,
85
- // });
86
- // } catch (error) {
87
- // // Silent background fail
88
- // } finally {
89
- // isCapturingRef.current = false;
90
- // }
91
- // }, [isInitialized, onSilentCapture, silentCaptureResult]);
92
- // useEffect(() => {
93
- // if (!showCamera || !isInitialized || isProcessing) return;
94
- // let isActive = true;
95
- // let intervalId: ReturnType<typeof setInterval>;
96
- // const warmupTimer = setTimeout(() => {
97
- // if (!isActive) return;
98
- // intervalId = setInterval(() => {
99
- // captureSilentPhoto();
100
- // }, 1500);
101
- // }, 1000);
102
- // return () => {
103
- // isActive = false;
104
- // clearTimeout(warmupTimer);
105
- // if (intervalId) clearInterval(intervalId);
106
- // };
107
- // }, [showCamera, isInitialized, isProcessing, captureSilentPhoto]);
108
- // if (hasPermission === null) return <View style={[styles.container, style]} />;
109
- // if (hasPermission === false) {
110
- // return (
111
- // <View style={[styles.container, style, { justifyContent: 'center', alignItems: 'center' }]}>
112
- // <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>
113
- // <Button title="Refresh Camera" onPress={() => setRefreshCamera(prev => !prev)} variant="primary" />
114
- // </View>
115
- // );
116
- // }
117
- // if (!device || !showCamera) return <View style={[styles.container, style]} />;
118
- // return (
119
- // <View
120
- // style={[styles.container, style]}
121
- // onLayout={(e) => setLayout({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height })}
122
- // >
123
- // <Camera
124
- // ref={camera}
125
- // style={StyleSheet.absoluteFill}
126
- // device={device}
127
- // format={format}
128
- // resizeMode="cover"
129
- // isActive={showCamera && !isProcessing}
130
- // photo={true}
131
- // video={false}
132
- // audio={false}
133
- // onInitialized={onInitialized}
134
- // onError={onCameraError}
135
- // />
136
- // {overlayComponent}
137
- // </View>
138
- // );
139
- // };
140
- // const styles = StyleSheet.create({
141
- // container: { flex: 1, backgroundColor: 'black' },
142
- // permissionMessage: { color: 'white', textAlign: 'center', margin: 20, fontSize: 16 },
143
- // });
144
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
145
2
  import { View, StyleSheet, Text, AppState } from 'react-native';
146
3
  import { Camera, useCameraDevice } from 'react-native-vision-camera';
@@ -156,12 +13,8 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
156
13
  const [hasPermission, setHasPermission] = useState(null);
157
14
  const [isInitialized, setIsInitialized] = useState(false);
158
15
  const [refreshCamera, setRefreshCamera] = useState(false);
159
- // 🚨 THE FIX: Removed the strict physical device filtering and custom format.
160
- // This allows Android to select its own supported, stable hardware stream, preventing crashes.
161
16
  const device = useCameraDevice(cameraType);
162
- useEffect(() => {
163
- isProcessingRef.current = isProcessing;
164
- }, [isProcessing]);
17
+ useEffect(() => { isProcessingRef.current = isProcessing; }, [isProcessing]);
165
18
  const checkPermissions = async () => {
166
19
  try {
167
20
  const hasAllPermissions = await VisionCameraModule.hasAllPermissions();
@@ -175,22 +28,19 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
175
28
  }
176
29
  setHasPermission(true);
177
30
  }
178
- catch (error) {
31
+ catch {
179
32
  setHasPermission(false);
180
33
  onError?.({ message: t('camera.errorOccurred') });
181
34
  }
182
35
  };
36
+ useEffect(() => { if (showCamera)
37
+ checkPermissions(); }, [showCamera, refreshCamera]);
183
38
  useEffect(() => {
184
- if (showCamera)
185
- checkPermissions();
186
- }, [showCamera, refreshCamera]);
187
- useEffect(() => {
188
- const subscription = AppState.addEventListener('change', nextAppState => {
189
- if (nextAppState === 'active' && showCamera && hasPermission === false) {
39
+ const sub = AppState.addEventListener('change', next => {
40
+ if (next === 'active' && showCamera && hasPermission === false)
190
41
  checkPermissions();
191
- }
192
42
  });
193
- return () => subscription.remove();
43
+ return () => sub.remove();
194
44
  }, [showCamera, hasPermission]);
195
45
  const onInitialized = useCallback(() => setIsInitialized(true), []);
196
46
  const onCameraError = useCallback((error) => {
@@ -203,19 +53,11 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
203
53
  return;
204
54
  try {
205
55
  isCapturingRef.current = true;
206
- const photo = await camera.current.takePhoto({
207
- enableShutterSound: false,
208
- flash: 'off',
209
- });
56
+ const photo = await camera.current.takePhoto({ enableShutterSound: false, flash: 'off' });
210
57
  const result = await VisionCameraModule.processPhotoResult(photo);
211
- onSilentCapture?.({
212
- ...result,
213
- path: result.path || photo.path,
214
- });
215
- }
216
- catch (error) {
217
- // Silent background fail
58
+ onSilentCapture?.({ ...result, path: result.path || photo.path });
218
59
  }
60
+ catch { /* silent */ }
219
61
  finally {
220
62
  isCapturingRef.current = false;
221
63
  }
@@ -223,34 +65,29 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
223
65
  useEffect(() => {
224
66
  if (!showCamera || !isInitialized || isProcessing)
225
67
  return;
226
- let isActive = true;
227
- let intervalId;
228
- const warmupTimer = setTimeout(() => {
229
- if (!isActive)
68
+ let active = true;
69
+ let id;
70
+ const timer = setTimeout(() => {
71
+ if (!active)
230
72
  return;
231
- intervalId = setInterval(() => {
232
- captureSilentPhoto();
233
- }, 1500);
73
+ id = setInterval(captureSilentPhoto, 1500);
234
74
  }, 1000);
235
- return () => {
236
- isActive = false;
237
- clearTimeout(warmupTimer);
238
- if (intervalId)
239
- clearInterval(intervalId);
240
- };
75
+ return () => { active = false; clearTimeout(timer); if (id)
76
+ clearInterval(id); };
241
77
  }, [showCamera, isInitialized, isProcessing, captureSilentPhoto]);
242
78
  if (hasPermission === null)
243
79
  return <View style={[styles.container, style]}/>;
244
80
  if (hasPermission === false) {
245
81
  return (<View style={[styles.container, style, { justifyContent: 'center', alignItems: 'center' }]}>
246
82
  <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>
247
- <Button title="Refresh Camera" onPress={() => setRefreshCamera(prev => !prev)} variant="primary"/>
83
+ <Button title="Refresh Camera" onPress={() => setRefreshCamera(p => !p)} variant="primary"/>
248
84
  </View>);
249
85
  }
250
86
  if (!device || !showCamera)
251
87
  return <View style={[styles.container, style]}/>;
252
88
  return (<View style={[styles.container, style]}>
253
89
  <Camera ref={camera} style={StyleSheet.absoluteFill} device={device} resizeMode="cover" isActive={showCamera && !isProcessing} photo={true} video={false} audio={false} onInitialized={onInitialized} onError={onCameraError}/>
90
+
254
91
  {overlayComponent}
255
92
  </View>);
256
93
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EnhancedCameraView.js","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.tsx"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mEAAmE;AACnE,0FAA0F;AAC1F,yEAAyE;AACzE,8CAA8C;AAC9C,4DAA4D;AAC5D,wCAAwC;AAExC,0EAA0E;AAC1E,gBAAgB;AAChB,6CAA6C;AA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IAAI,CAAC,CACZ,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,OAAO,CAAC,CAAC,aAAa,CAAC,EAEzB;MAAA,CAAC,gBAAgB,CACnB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE;IAChD,iBAAiB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CACrF,CAAC,CAAC","sourcesContent":["// import React, { useCallback, useEffect, useRef, useState } from 'react';\n// import { View, StyleSheet, Text, AppState } from 'react-native';\n// import { Camera, useCameraDevice, useCameraFormat } from 'react-native-vision-camera'; \n// import VisionCameraModule from '../modules/camera/VisionCameraModule';\n// import { useI18n } from '../hooks/useI18n';\n// import { EnhancedCameraViewProps } from './OverLay/type';\n// import { Button } from './ui/Button';\n\n// export const EnhancedCameraView: React.FC<EnhancedCameraViewProps> = ({\n// showCamera,\n// cameraType: initialCameraType = 'front',\n// style,\n// onError,\n// onSilentCapture,\n// silentCaptureResult,\n// isProcessing = false,\n// overlayComponent,\n// }) => {\n// const { t } = useI18n();\n// const camera = useRef<Camera>(null);\n\n// const isCapturingRef = useRef(false);\n// const isProcessingRef = useRef(isProcessing);\n\n// const [cameraType] = useState<'front' | 'back'>(initialCameraType);\n// const [hasPermission, setHasPermission] = useState<boolean | null>(null);\n// const [isInitialized, setIsInitialized] = useState(false);\n// const [refreshCamera, setRefreshCamera] = useState(false);\n// const [layout, setLayout] = useState({ width: 0, height: 0 });\n\n\n// const device = useCameraDevice(cameraType, {\n// physicalDevices: [\n// 'wide-angle-camera' // Explicitly request standard 1x lens\n// ]\n// });\n\n// const targetRatio = layout.width > 0 ? layout.height / layout.width : 16 / 9;\n\n// const format = useCameraFormat(device, [\n// { photoAspectRatio: targetRatio },\n// { photoResolution: 'max' } \n// ]);\n\n// useEffect(() => {\n// isProcessingRef.current = isProcessing;\n// }, [isProcessing]);\n\n// const checkPermissions = async () => {\n// try {\n// const hasAllPermissions = await VisionCameraModule.hasAllPermissions();\n// if (!hasAllPermissions) {\n// const granted = await VisionCameraModule.requestAllPermissions();\n// if (!granted) {\n// setHasPermission(false);\n// onError?.({ message: t('camera.permissionRequired') });\n// return;\n// }\n// }\n// setHasPermission(true);\n// } catch (error) {\n// setHasPermission(false);\n// onError?.({ message: t('camera.errorOccurred') });\n// }\n// };\n\n// useEffect(() => {\n// if (showCamera) checkPermissions();\n// }, [showCamera, refreshCamera]);\n\n// useEffect(() => {\n// const subscription = AppState.addEventListener('change', nextAppState => {\n// if (nextAppState === 'active' && showCamera && hasPermission === false) {\n// checkPermissions();\n// }\n// });\n// return () => subscription.remove();\n// }, [showCamera, hasPermission]);\n\n// const onInitialized = useCallback(() => setIsInitialized(true), []);\n// const onCameraError = useCallback((error: any) => {\n// onError?.({ message: error.message || t('camera.errorOccurred') });\n// }, [onError, t]);\n\n// const captureSilentPhoto = useCallback(async () => {\n// if (!camera.current || !isInitialized || isProcessingRef.current || isCapturingRef.current) return;\n// if (silentCaptureResult?.isAnalyzing) return;\n\n// try {\n// isCapturingRef.current = true;\n// const photo = await camera.current.takePhoto({\n// enableShutterSound: false,\n// flash: 'off',\n// });\n// const result = await VisionCameraModule.processPhotoResult(photo);\n\n// onSilentCapture?.({\n// ...result,\n// path: result.path || photo.path,\n// });\n// } catch (error) {\n// // Silent background fail\n// } finally {\n// isCapturingRef.current = false;\n// }\n// }, [isInitialized, onSilentCapture, silentCaptureResult]);\n\n// useEffect(() => {\n// if (!showCamera || !isInitialized || isProcessing) return;\n// let isActive = true;\n// let intervalId: ReturnType<typeof setInterval>;\n\n// const warmupTimer = setTimeout(() => {\n// if (!isActive) return;\n// intervalId = setInterval(() => {\n// captureSilentPhoto();\n// }, 1500);\n// }, 1000);\n\n// return () => {\n// isActive = false;\n// clearTimeout(warmupTimer);\n// if (intervalId) clearInterval(intervalId);\n// };\n// }, [showCamera, isInitialized, isProcessing, captureSilentPhoto]);\n\n// if (hasPermission === null) return <View style={[styles.container, style]} />;\n\n// if (hasPermission === false) {\n// return (\n// <View style={[styles.container, style, { justifyContent: 'center', alignItems: 'center' }]}>\n// <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>\n// <Button title=\"Refresh Camera\" onPress={() => setRefreshCamera(prev => !prev)} variant=\"primary\" />\n// </View>\n// );\n// }\n\n// if (!device || !showCamera) return <View style={[styles.container, style]} />;\n\n// return (\n// <View \n// style={[styles.container, style]}\n// onLayout={(e) => setLayout({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height })}\n// >\n// <Camera\n// ref={camera}\n// style={StyleSheet.absoluteFill}\n// device={device}\n// format={format} \n// resizeMode=\"cover\" \n// isActive={showCamera && !isProcessing}\n// photo={true}\n// video={false}\n// audio={false}\n// onInitialized={onInitialized}\n// onError={onCameraError}\n// />\n// {overlayComponent}\n// </View>\n// );\n// };\n\n// const styles = StyleSheet.create({\n// container: { flex: 1, backgroundColor: 'black' },\n// permissionMessage: { color: 'white', textAlign: 'center', margin: 20, fontSize: 16 },\n// });\n\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { View, StyleSheet, Text, AppState } from 'react-native';\nimport { Camera, useCameraDevice } from 'react-native-vision-camera'; \nimport VisionCameraModule from '../modules/camera/VisionCameraModule';\nimport { useI18n } from '../hooks/useI18n';\nimport { EnhancedCameraViewProps } from './OverLay/type';\nimport { Button } from './ui/Button';\n\nexport const EnhancedCameraView: React.FC<EnhancedCameraViewProps> = ({\n showCamera,\n cameraType: initialCameraType = 'front',\n style,\n onError,\n onSilentCapture,\n silentCaptureResult,\n isProcessing = false,\n overlayComponent,\n}) => {\n const { t } = useI18n();\n const camera = useRef<Camera>(null);\n\n const isCapturingRef = useRef(false);\n const isProcessingRef = useRef(isProcessing);\n\n const [cameraType] = useState<'front' | 'back'>(initialCameraType);\n const [hasPermission, setHasPermission] = useState<boolean | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [refreshCamera, setRefreshCamera] = useState(false);\n\n // 🚨 THE FIX: Removed the strict physical device filtering and custom format.\n // This allows Android to select its own supported, stable hardware stream, preventing crashes.\n const device = useCameraDevice(cameraType);\n\n useEffect(() => {\n isProcessingRef.current = isProcessing;\n }, [isProcessing]);\n\n const checkPermissions = async () => {\n try {\n const hasAllPermissions = await VisionCameraModule.hasAllPermissions();\n if (!hasAllPermissions) {\n const granted = await VisionCameraModule.requestAllPermissions();\n if (!granted) {\n setHasPermission(false);\n onError?.({ message: t('camera.permissionRequired') });\n return;\n }\n }\n setHasPermission(true);\n } catch (error) {\n setHasPermission(false);\n onError?.({ message: t('camera.errorOccurred') });\n }\n };\n\n useEffect(() => {\n if (showCamera) checkPermissions();\n }, [showCamera, refreshCamera]);\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', nextAppState => {\n if (nextAppState === 'active' && showCamera && hasPermission === false) {\n checkPermissions();\n }\n });\n return () => subscription.remove();\n }, [showCamera, hasPermission]);\n\n const onInitialized = useCallback(() => setIsInitialized(true), []);\n const onCameraError = useCallback((error: any) => {\n onError?.({ message: error.message || t('camera.errorOccurred') });\n }, [onError, t]);\n\n const captureSilentPhoto = useCallback(async () => {\n if (!camera.current || !isInitialized || isProcessingRef.current || isCapturingRef.current) return;\n if (silentCaptureResult?.isAnalyzing) return;\n\n try {\n isCapturingRef.current = true;\n const photo = await camera.current.takePhoto({\n enableShutterSound: false,\n flash: 'off',\n });\n \n const result = await VisionCameraModule.processPhotoResult(photo);\n\n onSilentCapture?.({\n ...result,\n path: result.path || photo.path,\n });\n } catch (error) {\n // Silent background fail\n } finally {\n isCapturingRef.current = false;\n }\n }, [isInitialized, onSilentCapture, silentCaptureResult]);\n\n useEffect(() => {\n if (!showCamera || !isInitialized || isProcessing) return;\n \n let isActive = true;\n let intervalId: ReturnType<typeof setInterval>;\n\n const warmupTimer = setTimeout(() => {\n if (!isActive) return;\n intervalId = setInterval(() => {\n captureSilentPhoto();\n }, 1500);\n }, 1000);\n\n return () => {\n isActive = false;\n clearTimeout(warmupTimer);\n if (intervalId) clearInterval(intervalId);\n };\n }, [showCamera, isInitialized, isProcessing, captureSilentPhoto]);\n\n if (hasPermission === null) return <View style={[styles.container, style]} />;\n\n if (hasPermission === false) {\n return (\n <View style={[styles.container, style, { justifyContent: 'center', alignItems: 'center' }]}>\n <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>\n <Button title=\"Refresh Camera\" onPress={() => setRefreshCamera(prev => !prev)} variant=\"primary\" />\n </View>\n );\n }\n\n if (!device || !showCamera) return <View style={[styles.container, style]} />;\n\n return (\n <View style={[styles.container, style]}>\n <Camera\n ref={camera}\n style={StyleSheet.absoluteFill}\n device={device}\n resizeMode=\"cover\" \n isActive={showCamera && !isProcessing}\n photo={true}\n video={false}\n audio={false}\n onInitialized={onInitialized}\n onError={onCameraError}\n />\n {overlayComponent}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { flex: 1, backgroundColor: 'black' },\n permissionMessage: { color: 'white', textAlign: 'center', margin: 20, fontSize: 16 },\n});"]}
1
+ {"version":3,"file":"EnhancedCameraView.js","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EACL,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AACtE,OAAO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UAAU,CAAC,YAAY,CAAC,CAC/B,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,UAAU,CAAC,OAAO,CAClB,QAAQ,CAAC,CAAC,UAAU,IAAI,CAAC,YAAY,CAAC,CACtC,KAAK,CAAC,CAAC,IAAI,CAAC,CACZ,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,OAAO,CAAC,CAAC,aAAa,CAAC,EAGzB;;MAAA,CAAC,gBAAgB,CACnB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE;IAChD,iBAAiB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CACrF,CAAC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport {\n View, StyleSheet, Text, AppState\n} from 'react-native';\nimport { Camera, useCameraDevice } from 'react-native-vision-camera';\nimport VisionCameraModule from '../modules/camera/VisionCameraModule';\nimport { useI18n } from '../hooks/useI18n';\nimport { EnhancedCameraViewProps } from './OverLay/type';\nimport { Button } from './ui/Button';\n\n\nexport const EnhancedCameraView: React.FC<EnhancedCameraViewProps> = ({\n showCamera,\n cameraType: initialCameraType = 'front',\n style,\n onError,\n onSilentCapture,\n silentCaptureResult,\n isProcessing = false,\n overlayComponent,\n}) => {\n const { t } = useI18n();\n const camera = useRef<Camera>(null);\n\n const isCapturingRef = useRef(false);\n const isProcessingRef = useRef(isProcessing);\n\n const [cameraType] = useState<'front' | 'back'>(initialCameraType);\n const [hasPermission, setHasPermission] = useState<boolean | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [refreshCamera, setRefreshCamera] = useState(false);\n\n const device = useCameraDevice(cameraType);\n\n useEffect(() => { isProcessingRef.current = isProcessing; }, [isProcessing]);\n\n const checkPermissions = async () => {\n try {\n const hasAllPermissions = await VisionCameraModule.hasAllPermissions();\n if (!hasAllPermissions) {\n const granted = await VisionCameraModule.requestAllPermissions();\n if (!granted) {\n setHasPermission(false);\n onError?.({ message: t('camera.permissionRequired') });\n return;\n }\n }\n setHasPermission(true);\n } catch {\n setHasPermission(false);\n onError?.({ message: t('camera.errorOccurred') });\n }\n };\n\n useEffect(() => { if (showCamera) checkPermissions(); }, [showCamera, refreshCamera]);\n\n useEffect(() => {\n const sub = AppState.addEventListener('change', next => {\n if (next === 'active' && showCamera && hasPermission === false) checkPermissions();\n });\n return () => sub.remove();\n }, [showCamera, hasPermission]);\n\n const onInitialized = useCallback(() => setIsInitialized(true), []);\n const onCameraError = useCallback((error: any) => {\n onError?.({ message: error.message || t('camera.errorOccurred') });\n }, [onError, t]);\n\n const captureSilentPhoto = useCallback(async () => {\n if (!camera.current || !isInitialized || isProcessingRef.current || isCapturingRef.current) return;\n if (silentCaptureResult?.isAnalyzing) return;\n try {\n isCapturingRef.current = true;\n const photo = await camera.current.takePhoto({ enableShutterSound: false, flash: 'off' });\n const result = await VisionCameraModule.processPhotoResult(photo);\n onSilentCapture?.({ ...result, path: result.path || photo.path });\n } catch { /* silent */ } finally {\n isCapturingRef.current = false;\n }\n }, [isInitialized, onSilentCapture, silentCaptureResult]);\n\n useEffect(() => {\n if (!showCamera || !isInitialized || isProcessing) return;\n let active = true;\n let id: ReturnType<typeof setInterval>;\n const timer = setTimeout(() => {\n if (!active) return;\n id = setInterval(captureSilentPhoto, 1500);\n }, 1000);\n return () => { active = false; clearTimeout(timer); if (id) clearInterval(id); };\n }, [showCamera, isInitialized, isProcessing, captureSilentPhoto]);\n\n if (hasPermission === null) return <View style={[styles.container, style]} />;\n\n if (hasPermission === false) {\n return (\n <View style={[styles.container, style, { justifyContent: 'center', alignItems: 'center' }]}>\n <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>\n <Button title=\"Refresh Camera\" onPress={() => setRefreshCamera(p => !p)} variant=\"primary\" />\n </View>\n );\n }\n\n if (!device || !showCamera) return <View style={[styles.container, style]} />;\n\n return (\n <View style={[styles.container, style]}>\n <Camera\n ref={camera}\n style={StyleSheet.absoluteFill}\n device={device}\n resizeMode=\"cover\"\n isActive={showCamera && !isProcessing}\n photo={true}\n video={false}\n audio={false}\n onInitialized={onInitialized}\n onError={onCameraError}\n />\n\n {overlayComponent}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { flex: 1, backgroundColor: 'black' },\n permissionMessage: { color: 'white', textAlign: 'center', margin: 20, fontSize: 16 },\n});"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDCardCapture.d.ts","sourceRoot":"","sources":["../../../../src/components/KYCElements/IDCardCapture.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAI5D,OAAO,EAAE,iBAAiB,EAAoI,MAAM,uBAAuB,CAAC;AAc5L,UAAU,cAAc;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAAE;AAC3F,UAAU,kBAAkB;IAAG,SAAS,EAAE,iBAAiB,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAAE;AAExO,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmft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