@ha_tecno/live-id-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +20 -0
- package/README.md +323 -0
- package/android/build.gradle +94 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/liveidsdk/LiveIdSdkModule.kt +25 -0
- package/android/src/main/java/com/liveidsdk/LiveIdSdkPackage.kt +17 -0
- package/ios/LiveIdSdk-Bridging-Header.h +2 -0
- package/ios/LiveIdSdk.mm +14 -0
- package/ios/LiveIdSdk.swift +8 -0
- package/lib/commonjs/assets/arrow.png +0 -0
- package/lib/commonjs/assets/exampleInstructionWithBorder.jpeg +0 -0
- package/lib/commonjs/assets/exampleInstructionWithoutFinger.jpeg +0 -0
- package/lib/commonjs/assets/ic_redness_capture_tip.png +0 -0
- package/lib/commonjs/assets/logo.png +0 -0
- package/lib/commonjs/components/CameraConfigInfos/index.js +21 -0
- package/lib/commonjs/components/CameraConfigInfos/index.js.map +1 -0
- package/lib/commonjs/components/CameraConfigInfos/styles.js +19 -0
- package/lib/commonjs/components/CameraConfigInfos/styles.js.map +1 -0
- package/lib/commonjs/components/DeviceNullDisplay/index.js +59 -0
- package/lib/commonjs/components/DeviceNullDisplay/index.js.map +1 -0
- package/lib/commonjs/components/ErrorDisplay/index.js +59 -0
- package/lib/commonjs/components/ErrorDisplay/index.js.map +1 -0
- package/lib/commonjs/components/Gabarito/index.js +19 -0
- package/lib/commonjs/components/Gabarito/index.js.map +1 -0
- package/lib/commonjs/components/Gabarito/styles.js +30 -0
- package/lib/commonjs/components/Gabarito/styles.js.map +1 -0
- package/lib/commonjs/components/Toast/Toast.js +66 -0
- package/lib/commonjs/components/Toast/Toast.js.map +1 -0
- package/lib/commonjs/components/WaitingForResult/index.js +24 -0
- package/lib/commonjs/components/WaitingForResult/index.js.map +1 -0
- package/lib/commonjs/components/WaitingForResult/styles.js +32 -0
- package/lib/commonjs/components/WaitingForResult/styles.js.map +1 -0
- package/lib/commonjs/index.js +34 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/index.js +49 -0
- package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/index.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/styles.js +62 -0
- package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/styles.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/index.js +298 -0
- package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/index.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/styles.js +54 -0
- package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/styles.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/index.js +44 -0
- package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/index.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/styles.js +65 -0
- package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/styles.js.map +1 -0
- package/lib/commonjs/screens/CadastroFinger/index.js +50 -0
- package/lib/commonjs/screens/CadastroFinger/index.js.map +1 -0
- package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js +186 -0
- package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js.map +1 -0
- package/lib/commonjs/screens/ProvaVidas/index.js +246 -0
- package/lib/commonjs/screens/ProvaVidas/index.js.map +1 -0
- package/lib/commonjs/screens/ProvaVidas/styles.js +93 -0
- package/lib/commonjs/screens/ProvaVidas/styles.js.map +1 -0
- package/lib/commonjs/screens/ValidadeFinger/index.js +216 -0
- package/lib/commonjs/screens/ValidadeFinger/index.js.map +1 -0
- package/lib/commonjs/screens/ValidadeFinger/styles.js +54 -0
- package/lib/commonjs/screens/ValidadeFinger/styles.js.map +1 -0
- package/lib/commonjs/services/index.js +145 -0
- package/lib/commonjs/services/index.js.map +1 -0
- package/lib/commonjs/types/screen.js +2 -0
- package/lib/commonjs/types/screen.js.map +1 -0
- package/lib/commonjs/utils/file.js +38 -0
- package/lib/commonjs/utils/file.js.map +1 -0
- package/lib/commonjs/utils/getConfigCamera.js +25 -0
- package/lib/commonjs/utils/getConfigCamera.js.map +1 -0
- package/lib/commonjs/utils/index.js +14 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/assets/arrow.png +0 -0
- package/lib/module/assets/exampleInstructionWithBorder.jpeg +0 -0
- package/lib/module/assets/exampleInstructionWithoutFinger.jpeg +0 -0
- package/lib/module/assets/ic_redness_capture_tip.png +0 -0
- package/lib/module/assets/logo.png +0 -0
- package/lib/module/components/CameraConfigInfos/index.js +13 -0
- package/lib/module/components/CameraConfigInfos/index.js.map +1 -0
- package/lib/module/components/CameraConfigInfos/styles.js +13 -0
- package/lib/module/components/CameraConfigInfos/styles.js.map +1 -0
- package/lib/module/components/DeviceNullDisplay/index.js +51 -0
- package/lib/module/components/DeviceNullDisplay/index.js.map +1 -0
- package/lib/module/components/ErrorDisplay/index.js +51 -0
- package/lib/module/components/ErrorDisplay/index.js.map +1 -0
- package/lib/module/components/Gabarito/index.js +11 -0
- package/lib/module/components/Gabarito/index.js.map +1 -0
- package/lib/module/components/Gabarito/styles.js +24 -0
- package/lib/module/components/Gabarito/styles.js.map +1 -0
- package/lib/module/components/Toast/Toast.js +58 -0
- package/lib/module/components/Toast/Toast.js.map +1 -0
- package/lib/module/components/WaitingForResult/index.js +17 -0
- package/lib/module/components/WaitingForResult/index.js.map +1 -0
- package/lib/module/components/WaitingForResult/styles.js +26 -0
- package/lib/module/components/WaitingForResult/styles.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/screens/CadastroFinger/components/AjudaCadastro/index.js +41 -0
- package/lib/module/screens/CadastroFinger/components/AjudaCadastro/index.js.map +1 -0
- package/lib/module/screens/CadastroFinger/components/AjudaCadastro/styles.js +56 -0
- package/lib/module/screens/CadastroFinger/components/AjudaCadastro/styles.js.map +1 -0
- package/lib/module/screens/CadastroFinger/components/CameraCadastro/index.js +288 -0
- package/lib/module/screens/CadastroFinger/components/CameraCadastro/index.js.map +1 -0
- package/lib/module/screens/CadastroFinger/components/CameraCadastro/styles.js +48 -0
- package/lib/module/screens/CadastroFinger/components/CameraCadastro/styles.js.map +1 -0
- package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/index.js +36 -0
- package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/index.js.map +1 -0
- package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/styles.js +59 -0
- package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/styles.js.map +1 -0
- package/lib/module/screens/CadastroFinger/index.js +42 -0
- package/lib/module/screens/CadastroFinger/index.js.map +1 -0
- package/lib/module/screens/CadastroScreen/CadastroScreen.js +177 -0
- package/lib/module/screens/CadastroScreen/CadastroScreen.js.map +1 -0
- package/lib/module/screens/ProvaVidas/index.js +239 -0
- package/lib/module/screens/ProvaVidas/index.js.map +1 -0
- package/lib/module/screens/ProvaVidas/styles.js +87 -0
- package/lib/module/screens/ProvaVidas/styles.js.map +1 -0
- package/lib/module/screens/ValidadeFinger/index.js +206 -0
- package/lib/module/screens/ValidadeFinger/index.js.map +1 -0
- package/lib/module/screens/ValidadeFinger/styles.js +48 -0
- package/lib/module/screens/ValidadeFinger/styles.js.map +1 -0
- package/lib/module/services/index.js +131 -0
- package/lib/module/services/index.js.map +1 -0
- package/lib/module/types/screen.js +2 -0
- package/lib/module/types/screen.js.map +1 -0
- package/lib/module/utils/file.js +29 -0
- package/lib/module/utils/file.js.map +1 -0
- package/lib/module/utils/getConfigCamera.js +19 -0
- package/lib/module/utils/getConfigCamera.js.map +1 -0
- package/lib/module/utils/index.js +3 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/src/components/CameraConfigInfos/index.d.ts +9 -0
- package/lib/typescript/src/components/CameraConfigInfos/index.d.ts.map +1 -0
- package/lib/typescript/src/components/CameraConfigInfos/styles.d.ts +11 -0
- package/lib/typescript/src/components/CameraConfigInfos/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/DeviceNullDisplay/index.d.ts +11 -0
- package/lib/typescript/src/components/DeviceNullDisplay/index.d.ts.map +1 -0
- package/lib/typescript/src/components/ErrorDisplay/index.d.ts +11 -0
- package/lib/typescript/src/components/ErrorDisplay/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Gabarito/index.d.ts +3 -0
- package/lib/typescript/src/components/Gabarito/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Gabarito/styles.d.ts +21 -0
- package/lib/typescript/src/components/Gabarito/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Toast/Toast.d.ts +42 -0
- package/lib/typescript/src/components/Toast/Toast.d.ts.map +1 -0
- package/lib/typescript/src/components/WaitingForResult/index.d.ts +7 -0
- package/lib/typescript/src/components/WaitingForResult/index.d.ts.map +1 -0
- package/lib/typescript/src/components/WaitingForResult/styles.d.ts +24 -0
- package/lib/typescript/src/components/WaitingForResult/styles.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/index.d.ts +7 -0
- package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/styles.d.ts +55 -0
- package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/styles.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/index.d.ts +16 -0
- package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/styles.d.ts +44 -0
- package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/styles.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/index.d.ts +12 -0
- package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/styles.d.ts +54 -0
- package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/styles.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroFinger/index.d.ts +16 -0
- package/lib/typescript/src/screens/CadastroFinger/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts +14 -0
- package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts.map +1 -0
- package/lib/typescript/src/screens/ProvaVidas/index.d.ts +14 -0
- package/lib/typescript/src/screens/ProvaVidas/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/ProvaVidas/styles.d.ts +85 -0
- package/lib/typescript/src/screens/ProvaVidas/styles.d.ts.map +1 -0
- package/lib/typescript/src/screens/ValidadeFinger/index.d.ts +14 -0
- package/lib/typescript/src/screens/ValidadeFinger/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/ValidadeFinger/styles.d.ts +44 -0
- package/lib/typescript/src/screens/ValidadeFinger/styles.d.ts.map +1 -0
- package/lib/typescript/src/services/index.d.ts +21 -0
- package/lib/typescript/src/services/index.d.ts.map +1 -0
- package/lib/typescript/src/types/screen.d.ts +6 -0
- package/lib/typescript/src/types/screen.d.ts.map +1 -0
- package/lib/typescript/src/utils/file.d.ts +3 -0
- package/lib/typescript/src/utils/file.d.ts.map +1 -0
- package/lib/typescript/src/utils/getConfigCamera.d.ts +14 -0
- package/lib/typescript/src/utils/getConfigCamera.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +3 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/live-id-sdk.podspec +41 -0
- package/package.json +184 -0
- package/src/assets/arrow.png +0 -0
- package/src/assets/exampleInstructionWithBorder.jpeg +0 -0
- package/src/assets/exampleInstructionWithoutFinger.jpeg +0 -0
- package/src/assets/ic_redness_capture_tip.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/CameraConfigInfos/index.tsx +25 -0
- package/src/components/CameraConfigInfos/styles.ts +13 -0
- package/src/components/DeviceNullDisplay/index.tsx +59 -0
- package/src/components/ErrorDisplay/index.tsx +60 -0
- package/src/components/Gabarito/index.tsx +11 -0
- package/src/components/Gabarito/styles.ts +23 -0
- package/src/components/Toast/Toast.tsx +61 -0
- package/src/components/WaitingForResult/index.tsx +22 -0
- package/src/components/WaitingForResult/styles.ts +27 -0
- package/src/index.tsx +6 -0
- package/src/screens/CadastroFinger/components/AjudaCadastro/index.tsx +49 -0
- package/src/screens/CadastroFinger/components/AjudaCadastro/styles.ts +56 -0
- package/src/screens/CadastroFinger/components/CameraCadastro/index.tsx +356 -0
- package/src/screens/CadastroFinger/components/CameraCadastro/styles.ts +47 -0
- package/src/screens/CadastroFinger/components/ImageDisplayScreen/index.tsx +45 -0
- package/src/screens/CadastroFinger/components/ImageDisplayScreen/styles.ts +55 -0
- package/src/screens/CadastroFinger/index.tsx +56 -0
- package/src/screens/CadastroScreen/CadastroScreen.tsx +212 -0
- package/src/screens/ProvaVidas/index.tsx +308 -0
- package/src/screens/ProvaVidas/styles.ts +99 -0
- package/src/screens/ValidadeFinger/index.tsx +263 -0
- package/src/screens/ValidadeFinger/styles.ts +47 -0
- package/src/services/index.ts +143 -0
- package/src/types/screen.ts +5 -0
- package/src/utils/file.ts +30 -0
- package/src/utils/getConfigCamera.ts +45 -0
- package/src/utils/index.ts +3 -0
@@ -0,0 +1,263 @@
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
2
|
+
import { Button, Text, View, Alert, TouchableOpacity } from 'react-native';
|
3
|
+
import {
|
4
|
+
Camera,
|
5
|
+
useCameraFormat,
|
6
|
+
type Point,
|
7
|
+
useCameraDevice,
|
8
|
+
} from 'react-native-vision-camera';
|
9
|
+
import Modal, { type ModalProps } from 'react-native-modal';
|
10
|
+
import Orientation from 'react-native-orientation-locker';
|
11
|
+
import {
|
12
|
+
Gesture,
|
13
|
+
GestureDetector,
|
14
|
+
GestureHandlerRootView,
|
15
|
+
} from 'react-native-gesture-handler';
|
16
|
+
import { runOnJS } from 'react-native-reanimated';
|
17
|
+
|
18
|
+
import { verifyDigital } from '../../services';
|
19
|
+
import { encodeImageToBase64 } from '../../utils/file';
|
20
|
+
import type { ScreenProps } from '../../types/screen';
|
21
|
+
import { DeviceNullDisplay } from '../../components/DeviceNullDisplay';
|
22
|
+
import { ErrorDisplay } from '../../components/ErrorDisplay';
|
23
|
+
import { Gabarito } from '../../components/Gabarito';
|
24
|
+
import { WaitingForResult } from '../../components/WaitingForResult';
|
25
|
+
import { styles } from './styles';
|
26
|
+
import { CameraConfigInfos } from '../../components/CameraConfigInfos';
|
27
|
+
import { getConfigCamera } from '../../utils';
|
28
|
+
|
29
|
+
interface ValidaFingerProps {
|
30
|
+
isVisible: boolean;
|
31
|
+
ModalParams?: ModalProps;
|
32
|
+
screenProps?: ScreenProps;
|
33
|
+
onCloseModal?: () => void;
|
34
|
+
onError?: (response?: any) => void;
|
35
|
+
onSuccess?: (response?: any) => void;
|
36
|
+
}
|
37
|
+
|
38
|
+
type GetConfigApi = {
|
39
|
+
id: number;
|
40
|
+
deviceModels: string[];
|
41
|
+
deviceType: string;
|
42
|
+
fps: number;
|
43
|
+
exposure: number;
|
44
|
+
zoom: number;
|
45
|
+
serviceType: string;
|
46
|
+
showButtonInfo: boolean;
|
47
|
+
};
|
48
|
+
|
49
|
+
export const ValidaFinger: React.FC<ValidaFingerProps> = ({
|
50
|
+
isVisible = false,
|
51
|
+
onCloseModal,
|
52
|
+
onError,
|
53
|
+
onSuccess,
|
54
|
+
ModalParams,
|
55
|
+
screenProps,
|
56
|
+
}) => {
|
57
|
+
const id = screenProps?.id;
|
58
|
+
|
59
|
+
const camera = useRef<Camera>(null);
|
60
|
+
const [showOverlay, setShowOverlay] = useState(false);
|
61
|
+
const [load, setLoad] = useState(false);
|
62
|
+
const [cameraConfigs, setCameraConfigs] = useState<GetConfigApi>();
|
63
|
+
|
64
|
+
// mantem a tela em modo portrait
|
65
|
+
useEffect(() => {
|
66
|
+
Orientation.lockToPortrait();
|
67
|
+
return () => {
|
68
|
+
Orientation.unlockAllOrientations();
|
69
|
+
};
|
70
|
+
}, []);
|
71
|
+
|
72
|
+
// Pega a permissão da camera do dispositivo
|
73
|
+
const requestCameraPermission = useCallback(async () => {
|
74
|
+
try {
|
75
|
+
await Camera.requestCameraPermission();
|
76
|
+
} catch (error) {}
|
77
|
+
}, []);
|
78
|
+
|
79
|
+
// pra garantir que a permissão da camera seja solicitada
|
80
|
+
useEffect(() => {
|
81
|
+
requestCameraPermission();
|
82
|
+
}, [requestCameraPermission]);
|
83
|
+
|
84
|
+
useEffect(() => {
|
85
|
+
getConfigCamera('finger')
|
86
|
+
.then((config) => {
|
87
|
+
setCameraConfigs(config);
|
88
|
+
})
|
89
|
+
.catch((error) => {
|
90
|
+
console.error(error);
|
91
|
+
});
|
92
|
+
}, []);
|
93
|
+
|
94
|
+
const device = useCameraDevice('back', {
|
95
|
+
physicalDevices: ['wide-angle-camera'],
|
96
|
+
});
|
97
|
+
|
98
|
+
const cameraFormat = useCameraFormat(device, [
|
99
|
+
{
|
100
|
+
photoResolution: {
|
101
|
+
height: 1280,
|
102
|
+
width: 720,
|
103
|
+
},
|
104
|
+
},
|
105
|
+
]);
|
106
|
+
|
107
|
+
const capturedPhoto = async () => {
|
108
|
+
const snapshot = await camera.current?.takePhoto({
|
109
|
+
qualityPrioritization: 'speed',
|
110
|
+
flash: 'on',
|
111
|
+
});
|
112
|
+
if (snapshot == null) {
|
113
|
+
Alert.alert('Erro ao capturar imagem');
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
let base64 = await encodeImageToBase64(snapshot.path);
|
117
|
+
|
118
|
+
setLoad(true);
|
119
|
+
setShowOverlay(true);
|
120
|
+
sendFile(base64);
|
121
|
+
return true;
|
122
|
+
};
|
123
|
+
|
124
|
+
// Fecha o modal
|
125
|
+
const onCloseModalHandler = useCallback(() => {
|
126
|
+
onCloseModal && onCloseModal();
|
127
|
+
}, [onCloseModal]);
|
128
|
+
|
129
|
+
// Envia a imagem para a validação da digital
|
130
|
+
const sendFile = useCallback(
|
131
|
+
async (image) => {
|
132
|
+
try {
|
133
|
+
let UID = id;
|
134
|
+
let finger = 'DI';
|
135
|
+
let req = await verifyDigital(UID, finger, image);
|
136
|
+
if (req.code === 0) {
|
137
|
+
Alert.alert('Sucesso identificado !');
|
138
|
+
onSuccess && onSuccess(req);
|
139
|
+
} else if (req.code === 1) {
|
140
|
+
Alert.alert('Não Identificado !');
|
141
|
+
onError && onError(req);
|
142
|
+
setLoad(false);
|
143
|
+
} else {
|
144
|
+
Alert.alert('Erro ao tentar validar');
|
145
|
+
onError && onError(req);
|
146
|
+
setLoad(false);
|
147
|
+
}
|
148
|
+
setLoad(false);
|
149
|
+
onCloseModalHandler();
|
150
|
+
setShowOverlay(false);
|
151
|
+
} catch (error) {
|
152
|
+
onError && onError(error);
|
153
|
+
setShowOverlay(false);
|
154
|
+
}
|
155
|
+
},
|
156
|
+
[id, onError, onSuccess, onCloseModalHandler]
|
157
|
+
);
|
158
|
+
|
159
|
+
// Foca a camera na posição do toque
|
160
|
+
const focus = useCallback((point: Point) => {
|
161
|
+
const c = camera.current;
|
162
|
+
if (c == null) return;
|
163
|
+
c.focus(point);
|
164
|
+
}, []);
|
165
|
+
|
166
|
+
// Gestos para focar a camera
|
167
|
+
const gesture = Gesture.Tap().onBegin(({ x, y }) => {
|
168
|
+
runOnJS(focus)({ x, y });
|
169
|
+
});
|
170
|
+
|
171
|
+
if (!screenProps && isVisible) {
|
172
|
+
return (
|
173
|
+
<ErrorDisplay
|
174
|
+
isVisible={isVisible}
|
175
|
+
modalParams={ModalParams}
|
176
|
+
onCloseModalHandler={onCloseModalHandler}
|
177
|
+
requestCameraPermission={requestCameraPermission}
|
178
|
+
/>
|
179
|
+
);
|
180
|
+
}
|
181
|
+
|
182
|
+
if (device == null) {
|
183
|
+
return (
|
184
|
+
<DeviceNullDisplay
|
185
|
+
isVisible={isVisible}
|
186
|
+
modalParams={ModalParams}
|
187
|
+
onCloseModalHandler={onCloseModalHandler}
|
188
|
+
requestCameraPermission={requestCameraPermission}
|
189
|
+
/>
|
190
|
+
);
|
191
|
+
}
|
192
|
+
|
193
|
+
if (screenProps) {
|
194
|
+
return (
|
195
|
+
<Modal
|
196
|
+
style={styles.modal}
|
197
|
+
isVisible={isVisible}
|
198
|
+
swipeDirection="down"
|
199
|
+
propagateSwipe={true}
|
200
|
+
onSwipeComplete={onCloseModalHandler}
|
201
|
+
{...ModalParams}
|
202
|
+
>
|
203
|
+
<GestureHandlerRootView style={styles.root}>
|
204
|
+
<View style={styles.container}>
|
205
|
+
{showOverlay && (
|
206
|
+
<WaitingForResult
|
207
|
+
onPress={() => {
|
208
|
+
setShowOverlay(false);
|
209
|
+
}}
|
210
|
+
/>
|
211
|
+
)}
|
212
|
+
<GestureDetector gesture={gesture}>
|
213
|
+
<View style={styles.cameraContainer}>
|
214
|
+
<Camera
|
215
|
+
ref={camera}
|
216
|
+
format={cameraFormat}
|
217
|
+
isActive={true}
|
218
|
+
device={device}
|
219
|
+
torch={'on'}
|
220
|
+
exposure={cameraConfigs?.exposure}
|
221
|
+
zoom={cameraConfigs?.zoom}
|
222
|
+
photo={true}
|
223
|
+
enableHighQualityPhotos={true}
|
224
|
+
style={styles.camera}
|
225
|
+
/>
|
226
|
+
{!showOverlay && <Gabarito />}
|
227
|
+
</View>
|
228
|
+
</GestureDetector>
|
229
|
+
<View style={styles.containerCapture}>
|
230
|
+
<TouchableOpacity disabled={load} onPress={() => capturedPhoto()}>
|
231
|
+
<View style={styles.containerButton}>
|
232
|
+
{load ? (
|
233
|
+
<Text style={styles.textButton}>
|
234
|
+
Verificando Digital...
|
235
|
+
</Text>
|
236
|
+
) : (
|
237
|
+
<Text style={styles.textButton}>Tirar Foto</Text>
|
238
|
+
)}
|
239
|
+
</View>
|
240
|
+
</TouchableOpacity>
|
241
|
+
</View>
|
242
|
+
<View style={styles.containerButtonClose}>
|
243
|
+
<Button
|
244
|
+
disabled={load}
|
245
|
+
title="Fechar Camera"
|
246
|
+
onPress={onCloseModalHandler}
|
247
|
+
/>
|
248
|
+
<View style={styles.cameraConfigs}>
|
249
|
+
<CameraConfigInfos
|
250
|
+
exposure={cameraConfigs?.exposure}
|
251
|
+
zoom={cameraConfigs?.zoom}
|
252
|
+
showButtonInfo={cameraConfigs?.showButtonInfo}
|
253
|
+
/>
|
254
|
+
</View>
|
255
|
+
</View>
|
256
|
+
</View>
|
257
|
+
</GestureHandlerRootView>
|
258
|
+
</Modal>
|
259
|
+
);
|
260
|
+
}
|
261
|
+
|
262
|
+
return null;
|
263
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { StyleSheet, Dimensions, Platform } from 'react-native';
|
2
|
+
|
3
|
+
const { height } = Dimensions.get('window');
|
4
|
+
|
5
|
+
export const styles = StyleSheet.create({
|
6
|
+
container: {
|
7
|
+
flex: 1,
|
8
|
+
},
|
9
|
+
root: {
|
10
|
+
flex: 1,
|
11
|
+
},
|
12
|
+
cameraContainer: {
|
13
|
+
flex: 1,
|
14
|
+
},
|
15
|
+
camera: {
|
16
|
+
flex: 1,
|
17
|
+
justifyContent: 'flex-end',
|
18
|
+
paddingBottom: height * 0.2,
|
19
|
+
},
|
20
|
+
containerCapture: {
|
21
|
+
height: height * 0.2,
|
22
|
+
alignItems: 'center',
|
23
|
+
justifyContent: 'center',
|
24
|
+
},
|
25
|
+
containerButton: {
|
26
|
+
width: 350,
|
27
|
+
height: 100,
|
28
|
+
borderRadius: 80,
|
29
|
+
backgroundColor: 'blue',
|
30
|
+
alignItems: 'center',
|
31
|
+
justifyContent: 'center',
|
32
|
+
},
|
33
|
+
textButton: {
|
34
|
+
fontSize: 18,
|
35
|
+
fontWeight: '500',
|
36
|
+
color: '#fff',
|
37
|
+
},
|
38
|
+
modal: {
|
39
|
+
margin: 0,
|
40
|
+
},
|
41
|
+
containerButtonClose: {
|
42
|
+
marginBottom: Platform.OS === 'ios' ? 48 : 0,
|
43
|
+
},
|
44
|
+
cameraConfigs: {
|
45
|
+
alignItems: 'center',
|
46
|
+
},
|
47
|
+
});
|
@@ -0,0 +1,143 @@
|
|
1
|
+
import { Platform } from 'react-native';
|
2
|
+
import axios from 'axios';
|
3
|
+
|
4
|
+
const BASE_URL = 'https://api.liveid.app.br';
|
5
|
+
const TOKEN =
|
6
|
+
'eyJhbGciOiJIUzI1NiJ9.NmU5ZmQ0MzEtOTE0Yy00Njc1LWFkYjAtZjVjNjRlZDUxNDg0.9J8eydQk5fbkH5GKdXkmXpt6wdQWyw8bsbaP5POU6YA';
|
7
|
+
|
8
|
+
const BASE_HEADER = {
|
9
|
+
'Content-Type': 'application/json',
|
10
|
+
'Authorization': `Bearer ${TOKEN}`,
|
11
|
+
};
|
12
|
+
|
13
|
+
const axiosInstance = axios.create({
|
14
|
+
baseURL: BASE_URL,
|
15
|
+
});
|
16
|
+
|
17
|
+
export const login = async (cpf: any, senha: any) => {
|
18
|
+
const response = await fetch(`${BASE_URL}/login`, {
|
19
|
+
method: 'POST',
|
20
|
+
headers: BASE_HEADER,
|
21
|
+
body: JSON.stringify({ cpf, senha }),
|
22
|
+
});
|
23
|
+
const data = await response.json();
|
24
|
+
return data;
|
25
|
+
};
|
26
|
+
|
27
|
+
export const cadastro = async (cpf: string, name: string, senha: string) => {
|
28
|
+
const response = await fetch(`${BASE_URL}/signup`, {
|
29
|
+
method: 'POST',
|
30
|
+
headers: BASE_HEADER,
|
31
|
+
body: JSON.stringify({ cpf, name, senha }),
|
32
|
+
});
|
33
|
+
const data = await response.json();
|
34
|
+
return data;
|
35
|
+
};
|
36
|
+
|
37
|
+
export const sendImages = async (UID: any, finger: any, images: any) => {
|
38
|
+
const response = await fetch(`${BASE_URL}/enroll-images`, {
|
39
|
+
method: 'POST',
|
40
|
+
headers: BASE_HEADER,
|
41
|
+
body: JSON.stringify({ UID, finger, images }),
|
42
|
+
});
|
43
|
+
const data = await response.json();
|
44
|
+
return data;
|
45
|
+
};
|
46
|
+
|
47
|
+
export const verifyDigital = async (UID: any, finger: any, image: any) => {
|
48
|
+
const response = await fetch(`${BASE_URL}/verify`, {
|
49
|
+
method: 'POST',
|
50
|
+
headers: BASE_HEADER,
|
51
|
+
body: JSON.stringify({ UID, finger, image }),
|
52
|
+
});
|
53
|
+
const data = await response.json();
|
54
|
+
return data;
|
55
|
+
};
|
56
|
+
|
57
|
+
type GetConfigApi = {
|
58
|
+
id: number;
|
59
|
+
deviceModels: string[];
|
60
|
+
deviceType: string;
|
61
|
+
fps: number;
|
62
|
+
exposure: number;
|
63
|
+
zoom: number;
|
64
|
+
serviceType: string;
|
65
|
+
showButtonInfo: boolean;
|
66
|
+
}[];
|
67
|
+
|
68
|
+
export const getConfigsApi = async (): Promise<GetConfigApi> => {
|
69
|
+
const { data } = await axiosInstance.get('/configs', {
|
70
|
+
headers: {
|
71
|
+
'Content-Type': 'application/json',
|
72
|
+
'Authorization': `Bearer ${TOKEN}`,
|
73
|
+
},
|
74
|
+
});
|
75
|
+
return data.deviceParamsConfig;
|
76
|
+
};
|
77
|
+
|
78
|
+
export const verificaCPF = async (cpf: any) => {
|
79
|
+
const response = await fetch(`${BASE_URL}/validcpf`, {
|
80
|
+
method: 'POST',
|
81
|
+
headers: BASE_HEADER,
|
82
|
+
body: JSON.stringify({ cpf }),
|
83
|
+
});
|
84
|
+
const data = await response.json();
|
85
|
+
return data;
|
86
|
+
};
|
87
|
+
|
88
|
+
export const provaVida = async (
|
89
|
+
video: { path: any },
|
90
|
+
UID: string,
|
91
|
+
vlexposure: any
|
92
|
+
) => {
|
93
|
+
const numeroAleatorio = gerarNumeroAleatorio();
|
94
|
+
|
95
|
+
const formData = new FormData();
|
96
|
+
formData.append('video', {
|
97
|
+
uri: Platform.select({
|
98
|
+
ios: video.path,
|
99
|
+
android: `file://${video.path}`,
|
100
|
+
}),
|
101
|
+
type: 'video/mp4',
|
102
|
+
name: `${UID}_${numeroAleatorio}.mp4`,
|
103
|
+
});
|
104
|
+
|
105
|
+
formData.append('video_key', numeroAleatorio);
|
106
|
+
formData.append('person_id', UID);
|
107
|
+
formData.append('exposure', vlexposure);
|
108
|
+
|
109
|
+
const response = await fetch(`${BASE_URL}/liveness`, {
|
110
|
+
method: 'POST',
|
111
|
+
headers: {
|
112
|
+
'Content-Type': 'multipart/form-data',
|
113
|
+
'Authorization': `Bearer ${TOKEN}`,
|
114
|
+
},
|
115
|
+
body: formData,
|
116
|
+
});
|
117
|
+
|
118
|
+
if (response.status === 200) {
|
119
|
+
const json = await response.json();
|
120
|
+
return json;
|
121
|
+
} else {
|
122
|
+
const errorJson = {
|
123
|
+
code: -1,
|
124
|
+
message: 'Erro, por favor, verifique e tente novamente!',
|
125
|
+
};
|
126
|
+
return errorJson;
|
127
|
+
}
|
128
|
+
};
|
129
|
+
|
130
|
+
const gerarNumeroAleatorio = () => {
|
131
|
+
const min = 10000000; // Menor número de 8 dígitos (10 milhões)
|
132
|
+
const max = 99999999; // Maior número de 8 dígitos (99 milhões 999 mil 999)
|
133
|
+
|
134
|
+
// Gera um número aleatório entre min e max
|
135
|
+
const numeroAleatorio = Math.floor(Math.random() * (max - min + 1)) + min;
|
136
|
+
|
137
|
+
// Converte o número para string
|
138
|
+
const numeroString = numeroAleatorio.toString();
|
139
|
+
|
140
|
+
return numeroString;
|
141
|
+
};
|
142
|
+
|
143
|
+
//https://api.liveid.app.br/change_configs
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import RNFS from 'react-native-fs';
|
2
|
+
|
3
|
+
export const encodeImageToBase64 = async (imagePath: string) => {
|
4
|
+
try {
|
5
|
+
const imageData = await RNFS.readFile(imagePath, 'base64');
|
6
|
+
return imageData;
|
7
|
+
} catch (error) {
|
8
|
+
return null;
|
9
|
+
}
|
10
|
+
};
|
11
|
+
|
12
|
+
export const validarBase64 = (array: string | any[]) => {
|
13
|
+
// Verifica se o argumento é um array e tem exatamente 3 elementos
|
14
|
+
if (!Array.isArray(array) || array.length !== 3) {
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
|
18
|
+
// Regex para validar base64
|
19
|
+
const base64Regex = /^[a-zA-Z0-9+/]*={0,2}$/;
|
20
|
+
|
21
|
+
// Verifica se cada elemento do array é uma string válida em base64
|
22
|
+
for (let i = 0; i < array.length; i++) {
|
23
|
+
if (typeof array[i] !== 'string' || !base64Regex.test(array[i])) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
// Se chegou até aqui, o array é válido
|
29
|
+
return true;
|
30
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { Platform } from 'react-native';
|
2
|
+
import { getModel } from 'react-native-device-info';
|
3
|
+
import { getConfigsApi } from '../services';
|
4
|
+
|
5
|
+
type ServiceType = 'finger' | 'liveness';
|
6
|
+
|
7
|
+
type GetConfigCameraReturn =
|
8
|
+
| {
|
9
|
+
id: number;
|
10
|
+
deviceModels: string[];
|
11
|
+
deviceType: string;
|
12
|
+
fps: number;
|
13
|
+
exposure: number;
|
14
|
+
zoom: number;
|
15
|
+
serviceType: string;
|
16
|
+
showButtonInfo: boolean;
|
17
|
+
}
|
18
|
+
| undefined;
|
19
|
+
|
20
|
+
const getConfigCamera = async (
|
21
|
+
serviceType: ServiceType
|
22
|
+
): Promise<GetConfigCameraReturn> => {
|
23
|
+
const deviceModel = getModel();
|
24
|
+
const deviceType = Platform.OS;
|
25
|
+
try {
|
26
|
+
const configs = await getConfigsApi();
|
27
|
+
const configsDeviceType = configs.filter(
|
28
|
+
(config) =>
|
29
|
+
config.deviceType === deviceType && config.serviceType === serviceType
|
30
|
+
);
|
31
|
+
const configDeviceModel = configsDeviceType.find(
|
32
|
+
(config) =>
|
33
|
+
config.deviceModels.includes(deviceModel) ||
|
34
|
+
config.deviceModels.includes('default')
|
35
|
+
);
|
36
|
+
|
37
|
+
return configDeviceModel;
|
38
|
+
} catch (error) {
|
39
|
+
console.error(error);
|
40
|
+
// Estudar futuramente a possibilidade de incluir um wrapper para personalização de erro
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
export default getConfigCamera;
|