@ha_tecno/live-id-sdk 2.12.2 → 2.13.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/lib/commonjs/components/Typograph/typograph.js +28 -0
- package/lib/commonjs/components/Typograph/typograph.js.map +1 -0
- package/lib/commonjs/components/index.js +14 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/screens/FingerAuth/FingerAuth.js +4 -1
- package/lib/commonjs/screens/FingerAuth/FingerAuth.js.map +1 -1
- package/lib/commonjs/screens/FingerRegister/FingerRegister.js +4 -1
- package/lib/commonjs/screens/FingerRegister/FingerRegister.js.map +1 -1
- package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js +6 -3
- package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js.map +1 -1
- package/lib/commonjs/screens/RegisterOperations/registerOperationPointsBiometrics.js +185 -0
- package/lib/commonjs/screens/RegisterOperations/registerOperationPointsBiometrics.js.map +1 -0
- package/lib/commonjs/screens/RegisterOperations/registerOperationPointsLifeCertificate.js +165 -0
- package/lib/commonjs/screens/RegisterOperations/registerOperationPointsLifeCertificate.js.map +1 -0
- package/lib/commonjs/screens/RegisterOperations/styles.js +47 -0
- package/lib/commonjs/screens/RegisterOperations/styles.js.map +1 -0
- package/lib/commonjs/screens/index.js +14 -0
- package/lib/commonjs/screens/index.js.map +1 -1
- package/lib/commonjs/services/index.js +18 -0
- package/lib/commonjs/services/index.js.map +1 -1
- package/lib/commonjs/services/services.js +106 -1
- package/lib/commonjs/services/services.js.map +1 -1
- package/lib/commonjs/store/modules/operationPoints/index.js +19 -0
- package/lib/commonjs/store/modules/operationPoints/index.js.map +1 -0
- package/lib/commonjs/store/modules/operationPoints/selectors.js +13 -0
- package/lib/commonjs/store/modules/operationPoints/selectors.js.map +1 -0
- package/lib/commonjs/store/modules/operationPoints/slice.js +233 -0
- package/lib/commonjs/store/modules/operationPoints/slice.js.map +1 -0
- package/lib/commonjs/store/modules/operationPoints/types.js +2 -0
- package/lib/commonjs/store/modules/operationPoints/types.js.map +1 -0
- package/lib/commonjs/utils/index.js +12 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/utils.js +9 -1
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/module/components/Typograph/typograph.js +21 -0
- package/lib/module/components/Typograph/typograph.js.map +1 -0
- package/lib/module/components/index.js +3 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/FingerAuth/FingerAuth.js +5 -2
- package/lib/module/screens/FingerAuth/FingerAuth.js.map +1 -1
- package/lib/module/screens/FingerRegister/FingerRegister.js +5 -2
- package/lib/module/screens/FingerRegister/FingerRegister.js.map +1 -1
- package/lib/module/screens/LifeCertificate/LifeCertificate.js +6 -3
- package/lib/module/screens/LifeCertificate/LifeCertificate.js.map +1 -1
- package/lib/module/screens/RegisterOperations/registerOperationPointsBiometrics.js +176 -0
- package/lib/module/screens/RegisterOperations/registerOperationPointsBiometrics.js.map +1 -0
- package/lib/module/screens/RegisterOperations/registerOperationPointsLifeCertificate.js +157 -0
- package/lib/module/screens/RegisterOperations/registerOperationPointsLifeCertificate.js.map +1 -0
- package/lib/module/screens/RegisterOperations/styles.js +41 -0
- package/lib/module/screens/RegisterOperations/styles.js.map +1 -0
- package/lib/module/screens/index.js +3 -1
- package/lib/module/screens/index.js.map +1 -1
- package/lib/module/services/index.js +2 -2
- package/lib/module/services/index.js.map +1 -1
- package/lib/module/services/services.js +102 -0
- package/lib/module/services/services.js.map +1 -1
- package/lib/module/store/modules/operationPoints/index.js +3 -0
- package/lib/module/store/modules/operationPoints/index.js.map +1 -0
- package/lib/module/store/modules/operationPoints/selectors.js +6 -0
- package/lib/module/store/modules/operationPoints/selectors.js.map +1 -0
- package/lib/module/store/modules/operationPoints/slice.js +227 -0
- package/lib/module/store/modules/operationPoints/slice.js.map +1 -0
- package/lib/module/store/modules/operationPoints/types.js +2 -0
- package/lib/module/store/modules/operationPoints/types.js.map +1 -0
- package/lib/module/utils/index.js +2 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/utils.js +7 -1
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/typescript/src/components/Typograph/typograph.d.ts +10 -0
- package/lib/typescript/src/components/Typograph/typograph.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts.map +1 -1
- package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts.map +1 -1
- package/lib/typescript/src/screens/LifeCertificate/LifeCertificate.d.ts.map +1 -1
- package/lib/typescript/src/screens/RegisterOperations/registerOperationPointsBiometrics.d.ts +7 -0
- package/lib/typescript/src/screens/RegisterOperations/registerOperationPointsBiometrics.d.ts.map +1 -0
- package/lib/typescript/src/screens/RegisterOperations/registerOperationPointsLifeCertificate.d.ts +7 -0
- package/lib/typescript/src/screens/RegisterOperations/registerOperationPointsLifeCertificate.d.ts.map +1 -0
- package/lib/typescript/src/screens/RegisterOperations/styles.d.ts +40 -0
- package/lib/typescript/src/screens/RegisterOperations/styles.d.ts.map +1 -0
- package/lib/typescript/src/screens/index.d.ts +3 -1
- package/lib/typescript/src/screens/index.d.ts.map +1 -1
- package/lib/typescript/src/services/index.d.ts +2 -2
- package/lib/typescript/src/services/index.d.ts.map +1 -1
- package/lib/typescript/src/services/services.d.ts +4 -1
- package/lib/typescript/src/services/services.d.ts.map +1 -1
- package/lib/typescript/src/services/types.d.ts +29 -0
- package/lib/typescript/src/services/types.d.ts.map +1 -1
- package/lib/typescript/src/store/modules/operationPoints/index.d.ts +3 -0
- package/lib/typescript/src/store/modules/operationPoints/index.d.ts.map +1 -0
- package/lib/typescript/src/store/modules/operationPoints/selectors.d.ts +24 -0
- package/lib/typescript/src/store/modules/operationPoints/selectors.d.ts.map +1 -0
- package/lib/typescript/src/store/modules/operationPoints/slice.d.ts +4 -0
- package/lib/typescript/src/store/modules/operationPoints/slice.d.ts.map +1 -0
- package/lib/typescript/src/store/modules/operationPoints/types.d.ts +51 -0
- package/lib/typescript/src/store/modules/operationPoints/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -2
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/utils.d.ts +3 -1
- package/lib/typescript/src/utils/utils.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/Typograph/typograph.tsx +24 -0
- package/src/components/index.ts +3 -1
- package/src/index.tsx +14 -2
- package/src/screens/FingerAuth/FingerAuth.tsx +7 -3
- package/src/screens/FingerRegister/FingerRegister.tsx +6 -2
- package/src/screens/LifeCertificate/LifeCertificate.tsx +6 -2
- package/src/screens/RegisterOperations/registerOperationPointsBiometrics.tsx +168 -0
- package/src/screens/RegisterOperations/registerOperationPointsLifeCertificate.tsx +175 -0
- package/src/screens/RegisterOperations/styles.ts +41 -0
- package/src/screens/index.ts +9 -1
- package/src/services/index.ts +18 -2
- package/src/services/services.ts +113 -1
- package/src/services/types.ts +33 -0
- package/src/store/modules/operationPoints/index.ts +3 -0
- package/src/store/modules/operationPoints/selectors.ts +7 -0
- package/src/store/modules/operationPoints/slice.ts +240 -0
- package/src/store/modules/operationPoints/types.ts +61 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/utils.ts +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -7,5 +7,7 @@ declare const filteredFingers: (registeredFingers: string[], items: {
|
|
|
7
7
|
label: string;
|
|
8
8
|
value: Finger;
|
|
9
9
|
}[];
|
|
10
|
-
|
|
10
|
+
declare const scale0to1: (value: number, min: number, max: number) => number;
|
|
11
|
+
declare const scale0to1Inverse: (scaledValue: number, min: number, max: number) => number;
|
|
12
|
+
export { randomHeartRate, filteredFingers, scale0to1, scale0to1Inverse };
|
|
11
13
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,QAAA,MAAM,eAAe,QAAO,MAE3B,CAAC;AAEF,QAAA,MAAM,eAAe,sBACA,MAAM,EAAE,SACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,KACxC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAElC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,QAAA,MAAM,eAAe,QAAO,MAE3B,CAAC;AAEF,QAAA,MAAM,eAAe,sBACA,MAAM,EAAE,SACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,KACxC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAElC,CAAC;AAEF,QAAA,MAAM,SAAS,UAAW,MAAM,OAAO,MAAM,OAAO,MAAM,WAEzD,CAAC;AAEF,QAAA,MAAM,gBAAgB,gBAAiB,MAAM,OAAO,MAAM,OAAO,MAAM,WAEtE,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ha_tecno/live-id-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "React Native SDK for Live ID",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -147,6 +147,7 @@
|
|
|
147
147
|
},
|
|
148
148
|
"dependencies": {
|
|
149
149
|
"@react-native-camera-roll/camera-roll": "^7.8.3",
|
|
150
|
+
"@react-native-community/slider": "^4.5.3",
|
|
150
151
|
"@react-native-picker/picker": "^2.7.7",
|
|
151
152
|
"axios": "^1.6.8",
|
|
152
153
|
"react-native-device-info": "^10.13.1",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Text, TextStyle, useColorScheme } from "react-native";
|
|
3
|
+
import { RFValue } from "react-native-responsive-fontsize";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
children: string | string[] | undefined;
|
|
7
|
+
bold?: boolean;
|
|
8
|
+
style?: TextStyle;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const HAText = ({ children, bold, style }: Props) => {
|
|
12
|
+
const isDark = useColorScheme() === "dark";
|
|
13
|
+
|
|
14
|
+
const textStyle: TextStyle = {
|
|
15
|
+
fontWeight: bold ? "bold" : "normal",
|
|
16
|
+
color: isDark ? "white" : "black",
|
|
17
|
+
fontSize: RFValue(16),
|
|
18
|
+
...style
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return <Text style={textStyle}>{children}</Text>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default HAText;
|
package/src/components/index.ts
CHANGED
|
@@ -4,5 +4,7 @@ import RecordButton from "./recordButton/recordButton";
|
|
|
4
4
|
import CaptureButton from "./CaptureButton";
|
|
5
5
|
import CameraConfigInfo from "./CameraConfigInfo";
|
|
6
6
|
import Gabarito from "./Gabarito";
|
|
7
|
+
import HAText from "./Typograph/typograph";
|
|
8
|
+
import Icon from "./icon/icon";
|
|
7
9
|
|
|
8
|
-
export { DeviceNotFound, ModalMessage, RecordButton, CaptureButton, CameraConfigInfo, Gabarito };
|
|
10
|
+
export { DeviceNotFound, ModalMessage, RecordButton, CaptureButton, CameraConfigInfo, Gabarito, HAText, Icon };
|
package/src/index.tsx
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
LifeCertificate,
|
|
3
|
+
FingerRegister,
|
|
4
|
+
FingerAuth,
|
|
5
|
+
RegisterOperationPointsBiometrics,
|
|
6
|
+
RegisterOperationPointsLifeCertificate
|
|
7
|
+
} from "./screens";
|
|
2
8
|
|
|
3
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
LifeCertificate,
|
|
11
|
+
FingerRegister,
|
|
12
|
+
FingerAuth,
|
|
13
|
+
RegisterOperationPointsBiometrics,
|
|
14
|
+
RegisterOperationPointsLifeCertificate
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { Camera, useCameraFormat, Point, useCameraDevice, useCameraPermission } from "react-native-vision-camera";
|
|
4
4
|
import Orientation from "react-native-orientation-locker";
|
|
@@ -19,6 +19,7 @@ type Props = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const FingerAuth = ({ testID, UID, onSuccess, isFocused, mock }: Props) => {
|
|
22
|
+
const [torch, setTorch] = useState<"off" | "on">("off");
|
|
22
23
|
const cameraRef = useRef<Camera>(null);
|
|
23
24
|
const isForeground = useIsForeground();
|
|
24
25
|
const isActive = isFocused !== undefined ? isForeground && isFocused : isForeground;
|
|
@@ -85,6 +86,8 @@ const FingerAuth = ({ testID, UID, onSuccess, isFocused, mock }: Props) => {
|
|
|
85
86
|
runOnJS(focus)({ x, y });
|
|
86
87
|
});
|
|
87
88
|
|
|
89
|
+
const onInitialized = () => setTorch("on");
|
|
90
|
+
|
|
88
91
|
if (device == null || hasPermission === false)
|
|
89
92
|
return <DeviceNotFound hasPermission={hasPermission} cameraPermission={cameraPermission} />;
|
|
90
93
|
|
|
@@ -98,10 +101,11 @@ const FingerAuth = ({ testID, UID, onSuccess, isFocused, mock }: Props) => {
|
|
|
98
101
|
isActive={isActive}
|
|
99
102
|
device={device}
|
|
100
103
|
format={cameraFormat}
|
|
101
|
-
torch={
|
|
104
|
+
torch={torch}
|
|
102
105
|
exposure={state.exposure}
|
|
103
106
|
zoom={state.zoom}
|
|
104
|
-
|
|
107
|
+
onInitialized={onInitialized}
|
|
108
|
+
photo
|
|
105
109
|
/>
|
|
106
110
|
<Gabarito />
|
|
107
111
|
</View>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { View, Text } from "react-native";
|
|
3
3
|
import { Camera, Point, useCameraDevice, useCameraFormat, useCameraPermission } from "react-native-vision-camera";
|
|
4
4
|
import Orientation from "react-native-orientation-locker";
|
|
@@ -36,6 +36,7 @@ type Props = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const MultiFingerRegister = ({ testID, UID, onSuccess, isFocused, mock, registerUser, registeredFingers }: Props) => {
|
|
39
|
+
const [torch, setTorch] = useState<"off" | "on">("off");
|
|
39
40
|
const cameraRef = useRef<Camera>(null);
|
|
40
41
|
const isForeground = useIsForeground();
|
|
41
42
|
const isActive = isFocused !== undefined ? isForeground && isFocused : isForeground;
|
|
@@ -148,6 +149,8 @@ const MultiFingerRegister = ({ testID, UID, onSuccess, isFocused, mock, register
|
|
|
148
149
|
dispatch.setCurrentFinger(value as Finger);
|
|
149
150
|
};
|
|
150
151
|
|
|
152
|
+
const onInitialized = () => setTorch("on");
|
|
153
|
+
|
|
151
154
|
if (device == null || hasPermission === false)
|
|
152
155
|
return <DeviceNotFound hasPermission={hasPermission} cameraPermission={cameraPermission} />;
|
|
153
156
|
|
|
@@ -161,9 +164,10 @@ const MultiFingerRegister = ({ testID, UID, onSuccess, isFocused, mock, register
|
|
|
161
164
|
device={device}
|
|
162
165
|
format={cameraFormat}
|
|
163
166
|
isActive={isActive}
|
|
164
|
-
torch={
|
|
167
|
+
torch={torch}
|
|
165
168
|
exposure={state.exposure}
|
|
166
169
|
zoom={state.zoom}
|
|
170
|
+
onInitialized={onInitialized}
|
|
167
171
|
photo
|
|
168
172
|
/>
|
|
169
173
|
<Gabarito />
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const LifeCertificate = ({ testID, UID, mock }: Props) => {
|
|
17
|
+
const [torch, setTorch] = useState<"on" | "off">("off");
|
|
17
18
|
const camera = useRef<Camera>(null);
|
|
18
19
|
const isActive = useIsForeground();
|
|
19
20
|
const state = useSelector();
|
|
@@ -118,6 +119,8 @@ const LifeCertificate = ({ testID, UID, mock }: Props) => {
|
|
|
118
119
|
dispatch.handleLoading();
|
|
119
120
|
};
|
|
120
121
|
|
|
122
|
+
const onInitialized = () => setTorch("on");
|
|
123
|
+
|
|
121
124
|
if (device == null || hasPermission === false)
|
|
122
125
|
return <DeviceNotFound hasPermission={hasPermission} cameraPermission={cameraPermission} />;
|
|
123
126
|
|
|
@@ -129,13 +132,14 @@ const LifeCertificate = ({ testID, UID, mock }: Props) => {
|
|
|
129
132
|
style={styles.camera}
|
|
130
133
|
isActive={isActive}
|
|
131
134
|
device={device}
|
|
132
|
-
|
|
133
|
-
torch={"on"}
|
|
135
|
+
torch={torch}
|
|
134
136
|
format={format}
|
|
135
137
|
exposure={state.exposure}
|
|
136
138
|
zoom={state.zoom}
|
|
137
139
|
focusable={true}
|
|
138
140
|
fps={30}
|
|
141
|
+
onInitialized={onInitialized}
|
|
142
|
+
video
|
|
139
143
|
/>
|
|
140
144
|
<View style={containerRecordStyled}>
|
|
141
145
|
<RecordButton
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { ActivityIndicator, Alert, BackHandler, Modal, View, useColorScheme } from "react-native";
|
|
3
|
+
import { Camera, Point, useCameraDevice, useCameraFormat, useCameraPermission } from "react-native-vision-camera";
|
|
4
|
+
import { runOnJS } from "react-native-reanimated";
|
|
5
|
+
import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
|
|
6
|
+
import { readFile } from "react-native-fs";
|
|
7
|
+
import Slider from "@react-native-community/slider";
|
|
8
|
+
|
|
9
|
+
import { useDispatch, useSelector } from "../../store/modules/operationPoints";
|
|
10
|
+
import { scale0to1Inverse, useIsForeground } from "../../utils";
|
|
11
|
+
import { CaptureButton, DeviceNotFound, Gabarito, HAText } from "../../components";
|
|
12
|
+
import { styles } from "./styles";
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
onSuccess: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const RegisterOperationPointsBiometrics = ({ onSuccess }: Props) => {
|
|
19
|
+
const isDark = useColorScheme() === "dark";
|
|
20
|
+
const backgroundColor = isDark ? "black" : "white";
|
|
21
|
+
const [zoom, setZoom] = useState<number>(2);
|
|
22
|
+
const [torch, setTorch] = useState<"off" | "on">("off");
|
|
23
|
+
const dispatch = useDispatch();
|
|
24
|
+
const { hasPermission, requestPermission } = useCameraPermission();
|
|
25
|
+
const cameraRef = useRef<Camera>(null);
|
|
26
|
+
const isForeground = useIsForeground();
|
|
27
|
+
const isActive = isForeground;
|
|
28
|
+
|
|
29
|
+
const { loading, exposureScaleZeroToOneBiometrics, message, base64Images } = useSelector();
|
|
30
|
+
const imagesCount = base64Images.length;
|
|
31
|
+
|
|
32
|
+
const containerCaptureStyled = [styles.containerCapture, { bottom: 20 }];
|
|
33
|
+
|
|
34
|
+
const device = useCameraDevice("back");
|
|
35
|
+
const cameraFormat = useCameraFormat(device, [
|
|
36
|
+
{
|
|
37
|
+
photoResolution: {
|
|
38
|
+
width: 1280,
|
|
39
|
+
height: 720
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const cameraPermission = useCallback(async () => {
|
|
45
|
+
if (!hasPermission) {
|
|
46
|
+
await requestPermission();
|
|
47
|
+
}
|
|
48
|
+
}, [hasPermission, requestPermission]);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
cameraPermission();
|
|
52
|
+
}, [cameraPermission]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (imagesCount === 3 && device != null) {
|
|
56
|
+
dispatch.sendImagesBase64({
|
|
57
|
+
base64Images,
|
|
58
|
+
exposureScaleZeroToOneBiometrics,
|
|
59
|
+
exposureMin: device.minExposure,
|
|
60
|
+
exposureMax: device.maxExposure,
|
|
61
|
+
zoomMin: device.minZoom,
|
|
62
|
+
zoomMax: device.maxZoom
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, [imagesCount, device, dispatch]);
|
|
66
|
+
|
|
67
|
+
const takePhoto = async () => {
|
|
68
|
+
const photo = await cameraRef.current?.takePhoto();
|
|
69
|
+
if (photo != null) {
|
|
70
|
+
const imageBase64 = await readFile(photo.path, "base64");
|
|
71
|
+
dispatch.setImageBase64(imageBase64);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const focus = useCallback((point: Point) => {
|
|
76
|
+
const camera = cameraRef.current;
|
|
77
|
+
if (camera != null) {
|
|
78
|
+
camera.focus(point);
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
const gesture = Gesture.Tap().onBegin(({ x, y }) => {
|
|
83
|
+
runOnJS(focus)({ x, y });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (loading === "succeeded") {
|
|
88
|
+
Alert.alert("Sucesso", message, [{ text: "OK", onPress: () => onSuccess && onSuccess() }]);
|
|
89
|
+
}
|
|
90
|
+
if (loading === "failed") {
|
|
91
|
+
Alert.alert("Continue", message, [
|
|
92
|
+
{
|
|
93
|
+
text: "OK",
|
|
94
|
+
onPress: () => dispatch.changeExposureBiometrics()
|
|
95
|
+
}
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
}, [loading, message, dispatch]);
|
|
99
|
+
|
|
100
|
+
const backAction = () => {
|
|
101
|
+
const exit = BackHandler.exitApp;
|
|
102
|
+
Alert.alert("Atenção!", "Tem certeza que deseja sair?", [
|
|
103
|
+
{
|
|
104
|
+
text: "Cancelar",
|
|
105
|
+
onPress: () => null,
|
|
106
|
+
style: "cancel"
|
|
107
|
+
},
|
|
108
|
+
{ text: "Sim", onPress: exit }
|
|
109
|
+
]);
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
useEffect(
|
|
114
|
+
useCallback(() => {
|
|
115
|
+
const onBackPress = () => {
|
|
116
|
+
backAction();
|
|
117
|
+
return true;
|
|
118
|
+
};
|
|
119
|
+
BackHandler.addEventListener("hardwareBackPress", onBackPress);
|
|
120
|
+
return () => {
|
|
121
|
+
BackHandler.removeEventListener("hardwareBackPress", onBackPress);
|
|
122
|
+
};
|
|
123
|
+
}, [backAction])
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const onInitialized = () => setTorch("on");
|
|
127
|
+
|
|
128
|
+
if (device == null || hasPermission === false)
|
|
129
|
+
return <DeviceNotFound hasPermission cameraPermission={cameraPermission} />;
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
133
|
+
<GestureDetector gesture={gesture}>
|
|
134
|
+
<View style={styles.containerCamera}>
|
|
135
|
+
<Camera
|
|
136
|
+
ref={cameraRef}
|
|
137
|
+
device={device}
|
|
138
|
+
style={styles.camera}
|
|
139
|
+
format={cameraFormat}
|
|
140
|
+
isActive={isActive}
|
|
141
|
+
torch={torch}
|
|
142
|
+
exposure={scale0to1Inverse(exposureScaleZeroToOneBiometrics, device.minExposure, device.maxExposure)}
|
|
143
|
+
zoom={zoom}
|
|
144
|
+
onInitialized={onInitialized}
|
|
145
|
+
photo
|
|
146
|
+
/>
|
|
147
|
+
<Gabarito />
|
|
148
|
+
</View>
|
|
149
|
+
</GestureDetector>
|
|
150
|
+
<View style={containerCaptureStyled}>
|
|
151
|
+
<CaptureButton onPress={takePhoto} imagesCount={imagesCount} />
|
|
152
|
+
</View>
|
|
153
|
+
<View style={[styles.containerSlider, { backgroundColor }]}>
|
|
154
|
+
<HAText bold>{`Ponto de operação`}</HAText>
|
|
155
|
+
<Slider maximumValue={4} minimumValue={2} value={zoom} onValueChange={(value) => setZoom(value)} step={1} />
|
|
156
|
+
</View>
|
|
157
|
+
{loading === "pending" && (
|
|
158
|
+
<Modal animationType="fade" transparent visible={true}>
|
|
159
|
+
<View style={styles.containerModalLoading}>
|
|
160
|
+
<ActivityIndicator size="large" color="#fff" />
|
|
161
|
+
</View>
|
|
162
|
+
</Modal>
|
|
163
|
+
)}
|
|
164
|
+
</GestureHandlerRootView>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export default RegisterOperationPointsBiometrics;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { ActivityIndicator, Alert, BackHandler, Modal, View } from "react-native";
|
|
3
|
+
import { Camera, useCameraDevice, useCameraFormat, useCameraPermission } from "react-native-vision-camera";
|
|
4
|
+
|
|
5
|
+
import { useDispatch, useSelector } from "../../store/modules/operationPoints";
|
|
6
|
+
import { scale0to1Inverse, useIsForeground } from "../../utils";
|
|
7
|
+
import { DeviceNotFound, RecordButton } from "../../components";
|
|
8
|
+
import { styles } from "./styles";
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
onSuccess: () => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const RegisterOperationPointsLifeCertificate = ({ onSuccess }: Props) => {
|
|
15
|
+
const [torch, setTorch] = useState<"off" | "on">("off");
|
|
16
|
+
const dispatch = useDispatch();
|
|
17
|
+
const { hasPermission, requestPermission } = useCameraPermission();
|
|
18
|
+
const cameraRef = useRef<Camera>(null);
|
|
19
|
+
const isForeground = useIsForeground();
|
|
20
|
+
const isActive = isForeground;
|
|
21
|
+
|
|
22
|
+
const [intervalState, setIntervalState] = useState<NodeJS.Timeout | null>(null);
|
|
23
|
+
const [timer, setTimer] = useState(10);
|
|
24
|
+
const [isRecord, setIsRecord] = useState(false);
|
|
25
|
+
|
|
26
|
+
const { loading, registered, exposureScaleZeroToOneLifeCertificate, message } = useSelector();
|
|
27
|
+
|
|
28
|
+
const device = useCameraDevice("back");
|
|
29
|
+
const cameraFormat = useCameraFormat(device, [
|
|
30
|
+
{
|
|
31
|
+
videoResolution: {
|
|
32
|
+
width: 1280,
|
|
33
|
+
height: 720
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]);
|
|
37
|
+
const exposure = scale0to1Inverse(
|
|
38
|
+
exposureScaleZeroToOneLifeCertificate,
|
|
39
|
+
device !== undefined ? device.minExposure : 0,
|
|
40
|
+
device !== undefined ? device.maxExposure : 0
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const cameraPermission = useCallback(async () => {
|
|
44
|
+
if (!hasPermission) {
|
|
45
|
+
await requestPermission();
|
|
46
|
+
}
|
|
47
|
+
}, [hasPermission, requestPermission]);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
cameraPermission();
|
|
51
|
+
}, [cameraPermission]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (loading === "succeeded") {
|
|
55
|
+
Alert.alert("Sucesso", message, [
|
|
56
|
+
{
|
|
57
|
+
text: "OK",
|
|
58
|
+
onPress: () => {
|
|
59
|
+
registered ? () => onSuccess && onSuccess() : null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
if (loading === "failed") {
|
|
65
|
+
Alert.alert("Continue", message, [
|
|
66
|
+
{
|
|
67
|
+
text: "OK",
|
|
68
|
+
onPress: () => dispatch.changeExposureLifeCertificate()
|
|
69
|
+
}
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
setTimer(10);
|
|
73
|
+
}, [loading, message, dispatch]);
|
|
74
|
+
|
|
75
|
+
const backAction = () => {
|
|
76
|
+
const exit = BackHandler.exitApp;
|
|
77
|
+
Alert.alert("Atenção!", "Tem certeza que deseja sair?", [
|
|
78
|
+
{
|
|
79
|
+
text: "Cancelar",
|
|
80
|
+
onPress: () => null,
|
|
81
|
+
style: "cancel"
|
|
82
|
+
},
|
|
83
|
+
{ text: "Sim", onPress: exit }
|
|
84
|
+
]);
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
useEffect(
|
|
89
|
+
useCallback(() => {
|
|
90
|
+
const onBackPress = () => {
|
|
91
|
+
backAction();
|
|
92
|
+
return true;
|
|
93
|
+
};
|
|
94
|
+
BackHandler.addEventListener("hardwareBackPress", onBackPress);
|
|
95
|
+
return () => {
|
|
96
|
+
BackHandler.removeEventListener("hardwareBackPress", onBackPress);
|
|
97
|
+
};
|
|
98
|
+
}, [backAction])
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const startVideoRecording = useCallback(() => {
|
|
102
|
+
setIsRecord(true);
|
|
103
|
+
if (device !== undefined) {
|
|
104
|
+
cameraRef.current?.startRecording({
|
|
105
|
+
fileType: "mp4",
|
|
106
|
+
onRecordingFinished: (video) =>
|
|
107
|
+
dispatch.sendVideosLifeCertificate({
|
|
108
|
+
exposureScaleZeroToOneLifeCertificate,
|
|
109
|
+
exposureMax: device.maxExposure,
|
|
110
|
+
exposureMin: device.minExposure,
|
|
111
|
+
videoPath: video.path
|
|
112
|
+
}),
|
|
113
|
+
onRecordingError: (error) => console.error(error)
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, [dispatch]);
|
|
117
|
+
|
|
118
|
+
const recordingVideo = useCallback(() => {
|
|
119
|
+
startVideoRecording();
|
|
120
|
+
setIntervalState(
|
|
121
|
+
setInterval(() => {
|
|
122
|
+
setTimer((prevTimer) => prevTimer - 1);
|
|
123
|
+
}, 1000)
|
|
124
|
+
);
|
|
125
|
+
}, [startVideoRecording]);
|
|
126
|
+
|
|
127
|
+
const stopRecodingVideo = useCallback(async () => {
|
|
128
|
+
setIsRecord(false);
|
|
129
|
+
await cameraRef.current?.stopRecording();
|
|
130
|
+
}, [dispatch]);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (timer < 0) {
|
|
134
|
+
if (!intervalState) return;
|
|
135
|
+
clearInterval(intervalState);
|
|
136
|
+
stopRecodingVideo();
|
|
137
|
+
}
|
|
138
|
+
}, [timer, intervalState, stopRecodingVideo]);
|
|
139
|
+
|
|
140
|
+
const onInitialized = () => setTorch("on");
|
|
141
|
+
|
|
142
|
+
if (device == null || hasPermission === false)
|
|
143
|
+
return <DeviceNotFound hasPermission={hasPermission} cameraPermission={cameraPermission} />;
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<>
|
|
147
|
+
<View style={styles.containerCamera}>
|
|
148
|
+
<Camera
|
|
149
|
+
ref={cameraRef}
|
|
150
|
+
device={device}
|
|
151
|
+
style={styles.camera}
|
|
152
|
+
format={cameraFormat}
|
|
153
|
+
isActive={isActive}
|
|
154
|
+
torch={torch}
|
|
155
|
+
exposure={exposure}
|
|
156
|
+
zoom={0}
|
|
157
|
+
onInitialized={onInitialized}
|
|
158
|
+
video
|
|
159
|
+
/>
|
|
160
|
+
</View>
|
|
161
|
+
<View style={[styles.containerCapture, { bottom: 0 }]}>
|
|
162
|
+
<RecordButton onPress={recordingVideo} disabled={loading === "pending"} timer={timer} isRecording={isRecord} />
|
|
163
|
+
</View>
|
|
164
|
+
{loading === "pending" && (
|
|
165
|
+
<Modal animationType="fade" transparent visible>
|
|
166
|
+
<View style={styles.containerModalLoading}>
|
|
167
|
+
<ActivityIndicator size="large" color="#fff" />
|
|
168
|
+
</View>
|
|
169
|
+
</Modal>
|
|
170
|
+
)}
|
|
171
|
+
</>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export default RegisterOperationPointsLifeCertificate;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StyleSheet, Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
containerCamera: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
justifyContent: "center"
|
|
7
|
+
},
|
|
8
|
+
camera: {
|
|
9
|
+
flex: 1
|
|
10
|
+
},
|
|
11
|
+
box: {
|
|
12
|
+
flexDirection: "row",
|
|
13
|
+
height: 50,
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
borderRadius: 50,
|
|
17
|
+
backgroundColor: "#1F75FF",
|
|
18
|
+
marginVertical: Platform.OS === "android" ? 100 : 120
|
|
19
|
+
},
|
|
20
|
+
text: {
|
|
21
|
+
position: "absolute",
|
|
22
|
+
color: "#fff"
|
|
23
|
+
},
|
|
24
|
+
containerCapture: {
|
|
25
|
+
position: "absolute",
|
|
26
|
+
width: "100%",
|
|
27
|
+
marginBottom: "30%",
|
|
28
|
+
alignItems: "center"
|
|
29
|
+
},
|
|
30
|
+
containerModalLoading: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
35
|
+
},
|
|
36
|
+
containerSlider: {
|
|
37
|
+
height: Platform.OS === "android" ? 100 : 120,
|
|
38
|
+
padding: 20,
|
|
39
|
+
gap: 10
|
|
40
|
+
}
|
|
41
|
+
});
|
package/src/screens/index.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import FingerRegister from "./FingerRegister/FingerRegister";
|
|
2
2
|
import LifeCertificate from "./LifeCertificate/LifeCertificate";
|
|
3
3
|
import FingerAuth from "./FingerAuth/FingerAuth";
|
|
4
|
+
import RegisterOperationPointsBiometrics from "./RegisterOperations/registerOperationPointsBiometrics";
|
|
5
|
+
import RegisterOperationPointsLifeCertificate from "./RegisterOperations/registerOperationPointsLifeCertificate";
|
|
4
6
|
|
|
5
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
FingerRegister,
|
|
9
|
+
LifeCertificate,
|
|
10
|
+
FingerAuth,
|
|
11
|
+
RegisterOperationPointsBiometrics,
|
|
12
|
+
RegisterOperationPointsLifeCertificate
|
|
13
|
+
};
|
package/src/services/index.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
lifeCertificate,
|
|
3
|
+
getConfigsApi,
|
|
4
|
+
registerFingerImages,
|
|
5
|
+
authFinger,
|
|
6
|
+
getConfigOperationPoints,
|
|
7
|
+
sendImagesForRegisterOperationPoints,
|
|
8
|
+
sendVideoForRegisterOperationPoints
|
|
9
|
+
} from "./services";
|
|
2
10
|
|
|
3
11
|
const BASE_URL = "https://api.liveid.app.br";
|
|
4
12
|
const TOKEN =
|
|
@@ -39,4 +47,12 @@ export const verificaCPF = async (cpf: any) => {
|
|
|
39
47
|
return data;
|
|
40
48
|
};
|
|
41
49
|
|
|
42
|
-
export {
|
|
50
|
+
export {
|
|
51
|
+
lifeCertificate,
|
|
52
|
+
getConfigsApi,
|
|
53
|
+
registerFingerImages,
|
|
54
|
+
authFinger,
|
|
55
|
+
getConfigOperationPoints,
|
|
56
|
+
sendImagesForRegisterOperationPoints,
|
|
57
|
+
sendVideoForRegisterOperationPoints
|
|
58
|
+
};
|