@ha_tecno/live-id-sdk 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/lib/commonjs/screens/FingerAuth/FingerAuth.js +7 -7
  2. package/lib/commonjs/screens/FingerAuth/FingerAuth.js.map +1 -1
  3. package/lib/commonjs/screens/FingerRegister/FingerRegister.js +8 -8
  4. package/lib/commonjs/screens/FingerRegister/FingerRegister.js.map +1 -1
  5. package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js +7 -4
  6. package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js.map +1 -1
  7. package/lib/commonjs/store/modules/fingerAuth/slice.js +9 -1
  8. package/lib/commonjs/store/modules/fingerAuth/slice.js.map +1 -1
  9. package/lib/commonjs/store/modules/fingerRegister/slice.js +9 -1
  10. package/lib/commonjs/store/modules/fingerRegister/slice.js.map +1 -1
  11. package/lib/commonjs/store/modules/lifeCertificate/slice.js +11 -1
  12. package/lib/commonjs/store/modules/lifeCertificate/slice.js.map +1 -1
  13. package/lib/commonjs/utils/index.js +7 -0
  14. package/lib/commonjs/utils/index.js.map +1 -1
  15. package/lib/commonjs/utils/utils.js +11 -0
  16. package/lib/commonjs/utils/utils.js.map +1 -0
  17. package/lib/module/screens/FingerAuth/FingerAuth.js +7 -7
  18. package/lib/module/screens/FingerAuth/FingerAuth.js.map +1 -1
  19. package/lib/module/screens/FingerRegister/FingerRegister.js +8 -8
  20. package/lib/module/screens/FingerRegister/FingerRegister.js.map +1 -1
  21. package/lib/module/screens/LifeCertificate/LifeCertificate.js +7 -4
  22. package/lib/module/screens/LifeCertificate/LifeCertificate.js.map +1 -1
  23. package/lib/module/store/modules/fingerAuth/slice.js +9 -1
  24. package/lib/module/store/modules/fingerAuth/slice.js.map +1 -1
  25. package/lib/module/store/modules/fingerRegister/slice.js +9 -1
  26. package/lib/module/store/modules/fingerRegister/slice.js.map +1 -1
  27. package/lib/module/store/modules/lifeCertificate/slice.js +12 -2
  28. package/lib/module/store/modules/lifeCertificate/slice.js.map +1 -1
  29. package/lib/module/utils/index.js +2 -1
  30. package/lib/module/utils/index.js.map +1 -1
  31. package/lib/module/utils/utils.js +5 -0
  32. package/lib/module/utils/utils.js.map +1 -0
  33. package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts +3 -1
  34. package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts.map +1 -1
  35. package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts +3 -1
  36. package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts.map +1 -1
  37. package/lib/typescript/src/screens/LifeCertificate/LifeCertificate.d.ts +2 -1
  38. package/lib/typescript/src/screens/LifeCertificate/LifeCertificate.d.ts.map +1 -1
  39. package/lib/typescript/src/store/modules/fingerAuth/selectors.d.ts +1 -1
  40. package/lib/typescript/src/store/modules/fingerAuth/slice.d.ts.map +1 -1
  41. package/lib/typescript/src/store/modules/fingerAuth/type.d.ts +1 -1
  42. package/lib/typescript/src/store/modules/fingerAuth/type.d.ts.map +1 -1
  43. package/lib/typescript/src/store/modules/fingerRegister/selectors.d.ts +1 -1
  44. package/lib/typescript/src/store/modules/fingerRegister/slice.d.ts.map +1 -1
  45. package/lib/typescript/src/store/modules/fingerRegister/types.d.ts +1 -1
  46. package/lib/typescript/src/store/modules/fingerRegister/types.d.ts.map +1 -1
  47. package/lib/typescript/src/store/modules/lifeCertificate/slice.d.ts.map +1 -1
  48. package/lib/typescript/src/store/modules/lifeCertificate/types.d.ts +1 -0
  49. package/lib/typescript/src/store/modules/lifeCertificate/types.d.ts.map +1 -1
  50. package/lib/typescript/src/utils/index.d.ts +2 -1
  51. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  52. package/lib/typescript/src/utils/utils.d.ts +3 -0
  53. package/lib/typescript/src/utils/utils.d.ts.map +1 -0
  54. package/package.json +1 -2
  55. package/src/screens/FingerAuth/FingerAuth.tsx +7 -7
  56. package/src/screens/FingerRegister/FingerRegister.tsx +8 -8
  57. package/src/screens/LifeCertificate/LifeCertificate.tsx +8 -4
  58. package/src/store/modules/fingerAuth/slice.ts +9 -1
  59. package/src/store/modules/fingerAuth/type.ts +1 -1
  60. package/src/store/modules/fingerRegister/slice.ts +9 -1
  61. package/src/store/modules/fingerRegister/types.ts +1 -1
  62. package/src/store/modules/lifeCertificate/slice.ts +11 -2
  63. package/src/store/modules/lifeCertificate/types.ts +1 -0
  64. package/src/utils/index.ts +2 -1
  65. package/src/utils/utils.ts +5 -0
  66. package/lib/commonjs/utils/file.js +0 -38
  67. package/lib/commonjs/utils/file.js.map +0 -1
  68. package/lib/module/utils/file.js +0 -29
  69. package/lib/module/utils/file.js.map +0 -1
  70. package/lib/typescript/src/utils/file.d.ts +0 -3
  71. package/lib/typescript/src/utils/file.d.ts.map +0 -1
  72. package/src/utils/file.ts +0 -30
@@ -50,9 +50,17 @@ const handleLoading = () => {
50
50
  }));
51
51
  };
52
52
 
53
- const sendImage = async (imagePath: string, UID: string) => {
53
+ const sendImage = async (imagePath: string, UID: string, mock?: boolean) => {
54
54
  try {
55
55
  handleLoading();
56
+ if (mock === true) {
57
+ return slice.setState((state) => ({
58
+ state: {
59
+ ...state.state,
60
+ code: 0
61
+ }
62
+ }));
63
+ }
56
64
  const convertedImage = await readFile(imagePath, "base64");
57
65
  const response = await authFinger({ UID, image: convertedImage });
58
66
  slice.setState((state) => ({
@@ -14,7 +14,7 @@ type State = {
14
14
  type Dispatch = {
15
15
  getConfig: (serviceType: "finger" | "liveness") => void;
16
16
  handleLoading: () => void;
17
- sendImage: (imagePath: string, UID: string) => void;
17
+ sendImage: (imagePath: string, UID: string, mock?: boolean) => void;
18
18
  resetState: () => void;
19
19
  setModal: (title: string, message: string) => void;
20
20
  };
@@ -34,7 +34,15 @@ const setImagePath = async (imagePath: string) => {
34
34
  }
35
35
  };
36
36
 
37
- const sendImages = async (images: string[], UID: string) => {
37
+ const sendImages = async (images: string[], UID: string, mock?: boolean) => {
38
+ if (mock === true) {
39
+ return slice.setState((state) => ({
40
+ state: {
41
+ ...state.state,
42
+ code: 0
43
+ }
44
+ }));
45
+ }
38
46
  const response = await registerFingerImages({ images, UID });
39
47
  slice.setState((state) => ({
40
48
  state: {
@@ -15,7 +15,7 @@ type Dispatch = {
15
15
  getConfig: (serviceType: "finger" | "liveness") => void;
16
16
  handleLoading: () => void;
17
17
  setImagePath: (imagePath: string) => void;
18
- sendImages: (images: string[], UID: string) => void;
18
+ sendImages: (images: string[], UID: string, mock?: boolean) => void;
19
19
  setModal: (title: string, message: string) => void;
20
20
  resetState: () => void;
21
21
  };
@@ -1,7 +1,7 @@
1
1
  import { create } from "zustand";
2
2
  import { InitialState, LifeCertificateState, SendLifeCertificateType } from "./types";
3
3
  import { lifeCertificate } from "../../../services";
4
- import { getConfigCamera } from "../../../utils";
4
+ import { getConfigCamera, randomHeartRate } from "../../../utils";
5
5
 
6
6
  const initialState: InitialState = {
7
7
  state: {
@@ -38,7 +38,16 @@ const setIsRecording = (recoding: boolean) => {
38
38
  }));
39
39
  };
40
40
 
41
- const sendLifeCertificate = async ({ videoFile, UID, exposure }: SendLifeCertificateType) => {
41
+ const sendLifeCertificate = async ({ videoFile, UID, exposure, mock }: SendLifeCertificateType) => {
42
+ if (mock === true) {
43
+ return slice.setState((state) => ({
44
+ state: {
45
+ ...state.state,
46
+ bpm: randomHeartRate(),
47
+ code: 0
48
+ }
49
+ }));
50
+ }
42
51
  const videoPath = videoFile.path;
43
52
  const response = await lifeCertificate({
44
53
  videoPath,
@@ -37,4 +37,5 @@ export type SendLifeCertificateType = {
37
37
  videoFile: VideoFile;
38
38
  UID: string;
39
39
  exposure: number;
40
+ mock?: boolean;
40
41
  };
@@ -1,4 +1,5 @@
1
1
  import getConfigCamera from "./getConfigCamera";
2
+ import randomHeartRate from "./utils";
2
3
  import { useIsForeground } from "./hooks/useIsForeground";
3
4
 
4
- export { getConfigCamera, useIsForeground };
5
+ export { getConfigCamera, useIsForeground, randomHeartRate };
@@ -0,0 +1,5 @@
1
+ const randomHeartRate = (): number => {
2
+ return Math.floor(Math.random() * (90 - 75 + 1) + 75);
3
+ };
4
+
5
+ export default randomHeartRate;
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validarBase64 = exports.encodeImageToBase64 = void 0;
7
- var _reactNativeFs = _interopRequireDefault(require("react-native-fs"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const encodeImageToBase64 = async imagePath => {
10
- try {
11
- const imageData = await _reactNativeFs.default.readFile(imagePath, "base64");
12
- return imageData;
13
- } catch (error) {
14
- return null;
15
- }
16
- };
17
- exports.encodeImageToBase64 = encodeImageToBase64;
18
- const validarBase64 = array => {
19
- // Verifica se o argumento é um array e tem exatamente 3 elementos
20
- if (!Array.isArray(array) || array.length !== 3) {
21
- return false;
22
- }
23
-
24
- // Regex para validar base64
25
- const base64Regex = /^[a-zA-Z0-9+/]*={0,2}$/;
26
-
27
- // Verifica se cada elemento do array é uma string válida em base64
28
- for (let i = 0; i < array.length; i++) {
29
- if (typeof array[i] !== "string" || !base64Regex.test(array[i])) {
30
- return false;
31
- }
32
- }
33
-
34
- // Se chegou até aqui, o array é válido
35
- return true;
36
- };
37
- exports.validarBase64 = validarBase64;
38
- //# sourceMappingURL=file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNativeFs","_interopRequireDefault","require","obj","__esModule","default","encodeImageToBase64","imagePath","imageData","RNFS","readFile","error","exports","validarBase64","array","Array","isArray","length","base64Regex","i","test"],"sourceRoot":"../../../src","sources":["utils/file.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAmC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE5B,MAAMG,mBAAmB,GAAG,MAAOC,SAAiB,IAAK;EAC9D,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMC,sBAAI,CAACC,QAAQ,CAACH,SAAS,EAAE,QAAQ,CAAC;IAC1D,OAAOC,SAAS;EAClB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC;AAACC,OAAA,CAAAN,mBAAA,GAAAA,mBAAA;AAEK,MAAMO,aAAa,GAAIC,KAAqB,IAAK;EACtD;EACA,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,IAAIA,KAAK,CAACG,MAAM,KAAK,CAAC,EAAE;IAC/C,OAAO,KAAK;EACd;;EAEA;EACA,MAAMC,WAAW,GAAG,wBAAwB;;EAE5C;EACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,KAAK,CAACG,MAAM,EAAEE,CAAC,EAAE,EAAE;IACrC,IAAI,OAAOL,KAAK,CAACK,CAAC,CAAC,KAAK,QAAQ,IAAI,CAACD,WAAW,CAACE,IAAI,CAACN,KAAK,CAACK,CAAC,CAAC,CAAC,EAAE;MAC/D,OAAO,KAAK;IACd;EACF;;EAEA;EACA,OAAO,IAAI;AACb,CAAC;AAACP,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
@@ -1,29 +0,0 @@
1
- import RNFS from "react-native-fs";
2
- export const encodeImageToBase64 = async imagePath => {
3
- try {
4
- const imageData = await RNFS.readFile(imagePath, "base64");
5
- return imageData;
6
- } catch (error) {
7
- return null;
8
- }
9
- };
10
- export const validarBase64 = array => {
11
- // Verifica se o argumento é um array e tem exatamente 3 elementos
12
- if (!Array.isArray(array) || array.length !== 3) {
13
- return false;
14
- }
15
-
16
- // Regex para validar base64
17
- const base64Regex = /^[a-zA-Z0-9+/]*={0,2}$/;
18
-
19
- // Verifica se cada elemento do array é uma string válida em base64
20
- for (let i = 0; i < array.length; i++) {
21
- if (typeof array[i] !== "string" || !base64Regex.test(array[i])) {
22
- return false;
23
- }
24
- }
25
-
26
- // Se chegou até aqui, o array é válido
27
- return true;
28
- };
29
- //# sourceMappingURL=file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["RNFS","encodeImageToBase64","imagePath","imageData","readFile","error","validarBase64","array","Array","isArray","length","base64Regex","i","test"],"sourceRoot":"../../../src","sources":["utils/file.ts"],"mappings":"AAAA,OAAOA,IAAI,MAAM,iBAAiB;AAElC,OAAO,MAAMC,mBAAmB,GAAG,MAAOC,SAAiB,IAAK;EAC9D,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMH,IAAI,CAACI,QAAQ,CAACF,SAAS,EAAE,QAAQ,CAAC;IAC1D,OAAOC,SAAS;EAClB,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAIC,KAAqB,IAAK;EACtD;EACA,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,IAAIA,KAAK,CAACG,MAAM,KAAK,CAAC,EAAE;IAC/C,OAAO,KAAK;EACd;;EAEA;EACA,MAAMC,WAAW,GAAG,wBAAwB;;EAE5C;EACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,KAAK,CAACG,MAAM,EAAEE,CAAC,EAAE,EAAE;IACrC,IAAI,OAAOL,KAAK,CAACK,CAAC,CAAC,KAAK,QAAQ,IAAI,CAACD,WAAW,CAACE,IAAI,CAACN,KAAK,CAACK,CAAC,CAAC,CAAC,EAAE;MAC/D,OAAO,KAAK;IACd;EACF;;EAEA;EACA,OAAO,IAAI;AACb,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const encodeImageToBase64: (imagePath: string) => Promise<string | null>;
2
- export declare const validarBase64: (array: string | any[]) => boolean;
3
- //# sourceMappingURL=file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../src/utils/file.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,cAAqB,MAAM,2BAO1D,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,GAAG,EAAE,YAkBlD,CAAC"}
package/src/utils/file.ts DELETED
@@ -1,30 +0,0 @@
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
- };