react-native-biometric-verifier 0.0.38 → 0.0.39
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/package.json +1 -1
- package/src/index.js +0 -4
- package/src/hooks/useImageProcessing.js +0 -64
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
TouchableOpacity,
|
|
11
11
|
Text,
|
|
12
12
|
Modal,
|
|
13
|
-
InteractionManager,
|
|
14
13
|
StyleSheet,
|
|
15
14
|
Platform,
|
|
16
15
|
Animated,
|
|
@@ -21,7 +20,6 @@ import { useNavigation } from "@react-navigation/native";
|
|
|
21
20
|
// Custom hooks
|
|
22
21
|
import { useCountdown } from "./hooks/useCountdown";
|
|
23
22
|
import { useGeolocation } from "./hooks/useGeolocation";
|
|
24
|
-
import { useImageProcessing } from "./hooks/useImageProcessing";
|
|
25
23
|
import { useNotifyMessage } from "./hooks/useNotifyMessage";
|
|
26
24
|
import { useSafeCallback } from "./hooks/useSafeCallback";
|
|
27
25
|
|
|
@@ -46,7 +44,6 @@ const BiometricModal = React.memo(
|
|
|
46
44
|
// Custom hooks
|
|
47
45
|
const { countdown, startCountdown, resetCountdown, pauseCountdown, resumeCountdown } = useCountdown();
|
|
48
46
|
const { requestLocationPermission, getCurrentLocation } = useGeolocation();
|
|
49
|
-
const { convertImageToBase64 } = useImageProcessing();
|
|
50
47
|
const { notification, fadeAnim, slideAnim, notifyMessage, clearNotification } = useNotifyMessage();
|
|
51
48
|
const safeCallback = useSafeCallback(callback, notifyMessage);
|
|
52
49
|
|
|
@@ -293,7 +290,6 @@ const BiometricModal = React.memo(
|
|
|
293
290
|
}
|
|
294
291
|
},
|
|
295
292
|
[
|
|
296
|
-
convertImageToBase64,
|
|
297
293
|
notifyMessage,
|
|
298
294
|
qrscan,
|
|
299
295
|
resetState,
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import ImageResizer from 'react-native-image-resizer';
|
|
3
|
-
import RNFS from 'react-native-fs';
|
|
4
|
-
import { Global } from '../utils/Global';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Custom hook to process images: resize and convert to Base64.
|
|
8
|
-
*
|
|
9
|
-
* @returns {Object} { convertImageToBase64 }
|
|
10
|
-
*/
|
|
11
|
-
export const useImageProcessing = () => {
|
|
12
|
-
/**
|
|
13
|
-
* Converts an image URI to a Base64 string after resizing.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} uri - Image file URI.
|
|
16
|
-
* @param {boolean} includeMimeType - Whether to include MIME type in the result.
|
|
17
|
-
* @returns {Promise<string>} Base64 string of the image.
|
|
18
|
-
*/
|
|
19
|
-
const convertImageToBase64 = useCallback(async (uri, includeMimeType = false) => {
|
|
20
|
-
try {
|
|
21
|
-
if (!uri || typeof uri !== 'string') {
|
|
22
|
-
throw new Error('Invalid image URI provided.');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Optional: Check file info
|
|
26
|
-
try {
|
|
27
|
-
await RNFS.stat(uri);
|
|
28
|
-
} catch {
|
|
29
|
-
// Skip warnings; silently ignore
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Resize image
|
|
33
|
-
const resizedImage = await ImageResizer.createResizedImage(
|
|
34
|
-
uri,
|
|
35
|
-
Global.ImageResize.width,
|
|
36
|
-
Global.ImageResize.height,
|
|
37
|
-
Global.ImageResize.format, // 'JPEG' or 'PNG'
|
|
38
|
-
Global.ImageResize.quality, // e.g., 80
|
|
39
|
-
0, // Rotation
|
|
40
|
-
undefined, // Output path
|
|
41
|
-
false // Keep EXIF metadata
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (!resizedImage?.uri) {
|
|
45
|
-
throw new Error('Image resizing returned an invalid result.');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Convert resized image to Base64
|
|
49
|
-
let base64Data = await RNFS.readFile(resizedImage.uri, 'base64');
|
|
50
|
-
|
|
51
|
-
if (includeMimeType) {
|
|
52
|
-
const mimeType = Global.ImageResize.format.toLowerCase() === 'png' ? 'image/png' : 'image/jpeg';
|
|
53
|
-
base64Data = `data:${mimeType};base64,${base64Data}`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return base64Data;
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error('Error in convertImageToBase64:', error.message || error);
|
|
59
|
-
throw error; // Rethrow for caller handling
|
|
60
|
-
}
|
|
61
|
-
}, []);
|
|
62
|
-
|
|
63
|
-
return { convertImageToBase64 };
|
|
64
|
-
};
|