@regulaforensics/face-sdk 7.2.414-beta → 7.2.421-beta
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/README.md +3 -2
- package/RNFaceSDK.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/cordova.gradle +2 -2
- package/android/src/main/java/com/regula/plugin/facesdk/JSONConstructor.kt +0 -2
- package/android/src/main/java/com/regula/plugin/facesdk/Main.kt +0 -18
- package/examples/capacitor/android/app/src/main/AndroidManifest.xml +2 -2
- package/examples/capacitor/index.html +7 -2
- package/examples/capacitor/package-lock.json +3 -17
- package/examples/capacitor/package.json +3 -3
- package/examples/capacitor/scripts/setup.sh +2 -4
- package/examples/capacitor/src/main.css +6 -60
- package/examples/capacitor/src/main.html +1 -1
- package/examples/capacitor/src/main.tsx +87 -51
- package/examples/cordova/.vscode/launch.json +28 -0
- package/examples/cordova/README.md +25 -0
- package/examples/cordova/config.xml +26 -0
- package/examples/cordova/package-lock.json +1313 -0
- package/examples/cordova/package.json +30 -0
- package/examples/cordova/scripts/android.sh +8 -0
- package/examples/cordova/scripts/ios.sh +8 -0
- package/examples/cordova/scripts/setup.sh +8 -0
- package/examples/cordova/www/images/logo.png +0 -0
- package/examples/cordova/www/index.html +21 -0
- package/examples/cordova/www/src/main.css +83 -0
- package/examples/cordova/www/src/main.html +25 -0
- package/examples/cordova/www/src/main.js +152 -0
- package/examples/ionic/angular.json +3 -3
- package/examples/ionic/config.xml +1 -1
- package/examples/ionic/index.ts +17 -0
- package/examples/ionic/package-lock.json +765 -851
- package/examples/ionic/package.json +3 -3
- package/examples/ionic/src/images/portrait.png +0 -0
- package/examples/ionic/src/main.css +6 -60
- package/examples/ionic/src/main.html +1 -1
- package/examples/ionic/src/{main.tsx → main.ts} +97 -52
- package/examples/ionic/tsconfig.json +2 -3
- package/examples/react_native/index.tsx +7 -49
- package/examples/react_native/package-lock.json +9296 -0
- package/examples/react_native/package.json +9 -9
- package/examples/react_native/src/main.css +6 -60
- package/examples/react_native/src/main.html +1 -1
- package/examples/react_native/src/main.tsx +79 -54
- package/ios/RFSWJSONConstructor.h +1 -0
- package/ios/RFSWJSONConstructor.m +14 -5
- package/ios/RFSWMain.m +0 -30
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/www/capacitor/customization/customization_fonts.js +1 -1
- package/www/capacitor/customization/customization_images.js +1 -1
- package/www/capacitor/customization/font.js +0 -8
- package/www/capacitor/detect_faces/detect_face_result.js +0 -12
- package/www/capacitor/detect_faces/detect_faces_attribute_result.js +0 -9
- package/www/capacitor/detect_faces/detect_faces_backend_exception.js +0 -7
- package/www/capacitor/detect_faces/detect_faces_config.js +0 -34
- package/www/capacitor/detect_faces/detect_faces_exception.js +0 -8
- package/www/capacitor/detect_faces/detect_faces_request.js +0 -22
- package/www/capacitor/detect_faces/detect_faces_response.js +0 -9
- package/www/capacitor/face_capture/face_capture_config.js +0 -37
- package/www/capacitor/face_capture/face_capture_exception.js +0 -7
- package/www/capacitor/face_capture/face_capture_image.js +0 -8
- package/www/capacitor/face_capture/face_capture_response.js +0 -7
- package/www/capacitor/image_params/output_image_crop.js +0 -23
- package/www/capacitor/image_params/output_image_params.js +0 -19
- package/www/capacitor/image_params/point.js +0 -7
- package/www/capacitor/image_params/rect.js +0 -9
- package/www/capacitor/image_params/size.js +0 -12
- package/www/capacitor/image_quality/image_quality_characteristic.js +0 -22
- package/www/capacitor/image_quality/image_quality_range.js +0 -7
- package/www/capacitor/image_quality/image_quality_result.js +0 -10
- package/www/capacitor/index.js +0 -48
- package/www/capacitor/init/face_sdk_version.js +0 -8
- package/www/capacitor/init/init_config.js +0 -19
- package/www/capacitor/init/init_exception.js +0 -8
- package/www/capacitor/init/license_exception.js +0 -7
- package/www/capacitor/internal/bridge.js +1 -20
- package/www/capacitor/liveness/liveness_backend_exception.js +0 -7
- package/www/capacitor/liveness/liveness_config.js +0 -43
- package/www/capacitor/liveness/liveness_exception.js +0 -8
- package/www/capacitor/liveness/liveness_notification.js +0 -7
- package/www/capacitor/liveness/liveness_response.js +0 -11
- package/www/capacitor/match_faces/compared_face.js +0 -9
- package/www/capacitor/match_faces/compared_faces_pair.js +0 -10
- package/www/capacitor/match_faces/compared_faces_split.js +0 -7
- package/www/capacitor/match_faces/match_faces_backend_exception.js +0 -7
- package/www/capacitor/match_faces/match_faces_config.js +0 -19
- package/www/capacitor/match_faces/match_faces_detection.js +0 -9
- package/www/capacitor/match_faces/match_faces_detection_face.js +0 -11
- package/www/capacitor/match_faces/match_faces_exception.js +0 -8
- package/www/capacitor/match_faces/match_faces_image.js +0 -9
- package/www/capacitor/match_faces/match_faces_request.js +0 -27
- package/www/capacitor/match_faces/match_faces_response.js +0 -9
- package/www/capacitor/person_database/edit_group_persons_request.js +0 -15
- package/www/capacitor/person_database/image_upload.js +0 -17
- package/www/capacitor/person_database/pageable_item_list.js +0 -8
- package/www/capacitor/person_database/person.js +0 -13
- package/www/capacitor/person_database/person_group.js +0 -11
- package/www/capacitor/person_database/person_image.js +0 -13
- package/www/capacitor/person_database/search_person.js +0 -14
- package/www/capacitor/person_database/search_person_detection.js +0 -9
- package/www/capacitor/person_database/search_person_image.js +0 -15
- package/www/capacitor/person_database/search_person_request.js +0 -29
- package/www/cordova.js +6 -753
- package/www/react-native/customization/customization_fonts.js +1 -1
- package/www/react-native/customization/customization_images.js +1 -1
- package/www/react-native/customization/font.js +0 -8
- package/www/react-native/detect_faces/detect_face_result.js +0 -12
- package/www/react-native/detect_faces/detect_faces_attribute_result.js +0 -9
- package/www/react-native/detect_faces/detect_faces_backend_exception.js +0 -7
- package/www/react-native/detect_faces/detect_faces_config.js +0 -34
- package/www/react-native/detect_faces/detect_faces_exception.js +0 -8
- package/www/react-native/detect_faces/detect_faces_request.js +0 -22
- package/www/react-native/detect_faces/detect_faces_response.js +0 -9
- package/www/react-native/face_capture/face_capture_config.js +0 -37
- package/www/react-native/face_capture/face_capture_exception.js +0 -7
- package/www/react-native/face_capture/face_capture_image.js +0 -8
- package/www/react-native/face_capture/face_capture_response.js +0 -7
- package/www/react-native/image_params/output_image_crop.js +0 -23
- package/www/react-native/image_params/output_image_params.js +0 -19
- package/www/react-native/image_params/point.js +0 -7
- package/www/react-native/image_params/rect.js +0 -9
- package/www/react-native/image_params/size.js +0 -12
- package/www/react-native/image_quality/image_quality_characteristic.js +0 -22
- package/www/react-native/image_quality/image_quality_range.js +0 -7
- package/www/react-native/image_quality/image_quality_result.js +0 -10
- package/www/react-native/index.js +0 -48
- package/www/react-native/init/face_sdk_version.js +0 -8
- package/www/react-native/init/init_config.js +0 -19
- package/www/react-native/init/init_exception.js +0 -8
- package/www/react-native/init/license_exception.js +0 -7
- package/www/react-native/internal/bridge.js +1 -20
- package/www/react-native/liveness/liveness_backend_exception.js +0 -7
- package/www/react-native/liveness/liveness_config.js +0 -43
- package/www/react-native/liveness/liveness_exception.js +0 -8
- package/www/react-native/liveness/liveness_notification.js +0 -7
- package/www/react-native/liveness/liveness_response.js +0 -11
- package/www/react-native/match_faces/compared_face.js +0 -9
- package/www/react-native/match_faces/compared_faces_pair.js +0 -10
- package/www/react-native/match_faces/compared_faces_split.js +0 -7
- package/www/react-native/match_faces/match_faces_backend_exception.js +0 -7
- package/www/react-native/match_faces/match_faces_config.js +0 -19
- package/www/react-native/match_faces/match_faces_detection.js +0 -9
- package/www/react-native/match_faces/match_faces_detection_face.js +0 -11
- package/www/react-native/match_faces/match_faces_exception.js +0 -8
- package/www/react-native/match_faces/match_faces_image.js +0 -9
- package/www/react-native/match_faces/match_faces_request.js +0 -27
- package/www/react-native/match_faces/match_faces_response.js +0 -9
- package/www/react-native/person_database/edit_group_persons_request.js +0 -15
- package/www/react-native/person_database/image_upload.js +0 -17
- package/www/react-native/person_database/pageable_item_list.js +0 -8
- package/www/react-native/person_database/person.js +0 -13
- package/www/react-native/person_database/person_group.js +0 -11
- package/www/react-native/person_database/person_image.js +0 -13
- package/www/react-native/person_database/search_person.js +0 -14
- package/www/react-native/person_database/search_person_detection.js +0 -9
- package/www/react-native/person_database/search_person_image.js +0 -15
- package/www/react-native/person_database/search_person_request.js +0 -29
- package/www/types/index.d.ts +0 -12
- package/www/types/match_faces/match_faces_config.d.ts +0 -2
- package/www/types/person_database/search_person_request.d.ts +0 -4
- package/examples/capacitor/index.tsx +0 -53
- package/examples/ionic/index.tsx +0 -68
- package/test/json.tsx +0 -375
- package/test/package-lock.json +0 -584
- package/test/package.json +0 -9
- package/test/test.tsx +0 -61
- package/test/utils.tsx +0 -38
- /package/examples/{ionic → cordova/www}/images/portrait.png +0 -0
- /package/examples/ionic/{assets → src/assets}/.gitkeep +0 -0
- /package/examples/ionic/{images → src/images}/icon.png +0 -0
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"android": "scripts/android.sh"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@regulaforensics/face-sdk": "7.2.
|
|
10
|
-
"@regulaforensics/face-core-basic": "7.1.
|
|
9
|
+
"@regulaforensics/face-sdk": "7.2.421-beta",
|
|
10
|
+
"@regulaforensics/face-core-basic": "7.1.202",
|
|
11
11
|
"@awesome-cordova-plugins/file": "6.16.0",
|
|
12
12
|
"@awesome-cordova-plugins/camera": "6.16.0",
|
|
13
13
|
"@awesome-cordova-plugins/dialogs": "6.16.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@angular/compiler-cli": "19.2.9",
|
|
25
25
|
"@angular/router": "19.2.9",
|
|
26
26
|
"@angular/platform-browser-dynamic": "19.2.9",
|
|
27
|
-
"@angular-devkit/build-angular": "19.2.
|
|
27
|
+
"@angular-devkit/build-angular": "19.2.10",
|
|
28
28
|
"@ionic/angular": "8.5.6",
|
|
29
29
|
"@ionic/cordova-builders": "12.2.0"
|
|
30
30
|
},
|
|
Binary file
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
html,
|
|
2
2
|
body {
|
|
3
|
-
|
|
4
|
-
width: 100%;
|
|
3
|
+
width: 99%;
|
|
5
4
|
height: 99vh;
|
|
6
5
|
display: flex;
|
|
7
|
-
overflow: hidden;
|
|
8
6
|
flex-direction: column;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-webkit-user-drag: none !important;
|
|
16
|
-
-webkit-touch-callout: none !important;
|
|
9
|
+
.page {
|
|
10
|
+
height: 100%;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
.column {
|
|
@@ -56,14 +52,10 @@ body {
|
|
|
56
52
|
margin-top: 13px;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
.scroll {
|
|
60
|
-
flex-grow: 1;
|
|
61
|
-
overflow-y: auto;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
55
|
.no-scroll {
|
|
65
56
|
flex-grow: 1;
|
|
66
57
|
overflow-y: hidden;
|
|
58
|
+
overflow-x: hidden;
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
.button {
|
|
@@ -75,7 +67,6 @@ body {
|
|
|
75
67
|
color: white;
|
|
76
68
|
border: none;
|
|
77
69
|
padding: 10px 20px;
|
|
78
|
-
justify-content: center;
|
|
79
70
|
font-size: 16px;
|
|
80
71
|
border-radius: 100px;
|
|
81
72
|
cursor: pointer;
|
|
@@ -89,49 +80,4 @@ body {
|
|
|
89
80
|
.button:active {
|
|
90
81
|
position: relative;
|
|
91
82
|
top: 1px;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.text-button {
|
|
95
|
-
background: none;
|
|
96
|
-
border: none;
|
|
97
|
-
color: #2196f3;
|
|
98
|
-
font-size: 20px;
|
|
99
|
-
font-weight: bold;
|
|
100
|
-
padding: 5px;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.text-button:active {
|
|
104
|
-
position: relative;
|
|
105
|
-
top: 1px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.radio {
|
|
109
|
-
align-items: baseline;
|
|
110
|
-
padding: 15px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
input[type="checkbox"] {
|
|
114
|
-
width: 20px;
|
|
115
|
-
height: 20px;
|
|
116
|
-
border: 2px solid black;
|
|
117
|
-
background-color: white;
|
|
118
|
-
display: inline-block;
|
|
119
|
-
position: relative;
|
|
120
|
-
cursor: pointer;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.progress-bar {
|
|
124
|
-
width: 75%;
|
|
125
|
-
padding: 3px;
|
|
126
|
-
margin-top: 40px;
|
|
127
|
-
background-color: #eee;
|
|
128
|
-
border-radius: 8px;
|
|
129
|
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
#progress {
|
|
133
|
-
width: 0%;
|
|
134
|
-
height: 20px;
|
|
135
|
-
background-color: #4285F4;
|
|
136
|
-
border-radius: 5px;
|
|
137
83
|
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
+
import { Component } from '@angular/core'
|
|
2
|
+
import { Dialogs } from '@awesome-cordova-plugins/dialogs/ngx'
|
|
3
|
+
import { File } from '@awesome-cordova-plugins/file'
|
|
4
|
+
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
|
|
5
|
+
import { Platform } from '@ionic/angular'
|
|
1
6
|
import { FaceSDK, MatchFacesRequest, MatchFacesImage, InitConfig, LivenessSkipStep, ImageType, LivenessStatus, LivenessConfig } from '@regulaforensics/face-sdk'
|
|
2
|
-
import { loadAssetIfExists, chooseOption, pickImage } from '../index'
|
|
3
|
-
|
|
4
|
-
var faceSdk = FaceSDK.instance
|
|
5
|
-
var image1: MatchFacesImage | null
|
|
6
|
-
var image2: MatchFacesImage | null
|
|
7
7
|
|
|
8
8
|
async function init() {
|
|
9
|
-
if (!await
|
|
9
|
+
if (!await initialize()) return
|
|
10
10
|
setStatus("Ready")
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async function startFaceCapture(position: number) {
|
|
14
|
-
var image = (await faceSdk.startFaceCapture()).image
|
|
15
|
-
if (image == null) return
|
|
16
|
-
setImage("data:image/png;base64," + image.image, image.imageType, position)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
async function startLiveness() {
|
|
20
14
|
var response = await faceSdk.startLiveness({
|
|
21
15
|
config: new LivenessConfig({
|
|
@@ -46,15 +40,30 @@ async function matchFaces() {
|
|
|
46
40
|
setStatus("Ready")
|
|
47
41
|
}
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
function clearResults() {
|
|
44
|
+
setStatus("Ready")
|
|
45
|
+
setSimilarityStatus("null")
|
|
46
|
+
setLivenessStatus("null")
|
|
47
|
+
resetImages()
|
|
48
|
+
image1 = null
|
|
49
|
+
image2 = null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If 'regula.license' exists, init using license(enables offline match)
|
|
53
|
+
// otherwise init without license.
|
|
54
|
+
async function initialize() {
|
|
55
|
+
setStatus("Initializing...")
|
|
56
|
+
|
|
57
|
+
var license = await loadAssetIfExists("regula.license")
|
|
58
|
+
var config: InitConfig | undefined
|
|
59
|
+
if (license != null) config = new InitConfig(license)
|
|
60
|
+
var [success, error] = await faceSdk.initialize({ config: config })
|
|
61
|
+
|
|
62
|
+
if (!success && error != null) {
|
|
63
|
+
setStatus(error.message)
|
|
64
|
+
console.log(error.code + ": " + error.message)
|
|
57
65
|
}
|
|
66
|
+
return success
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
function setImage(base64: string, type: number, position: number) {
|
|
@@ -71,46 +80,82 @@ function setImage(base64: string, type: number, position: number) {
|
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var license = await loadAssetIfExists("regula.license")
|
|
80
|
-
var config: InitConfig | undefined
|
|
81
|
-
if (license != null) config = new InitConfig(license)
|
|
82
|
-
var [success, error] = await faceSdk.initialize({ config: config })
|
|
83
|
-
|
|
84
|
-
if (error != null) {
|
|
85
|
-
setStatus(error.message)
|
|
86
|
-
console.log(error.code + ": " + error.message)
|
|
87
|
-
}
|
|
88
|
-
return success
|
|
83
|
+
async function useCamera(position: number) {
|
|
84
|
+
var response = await faceSdk.startFaceCapture()
|
|
85
|
+
if (response.image == null) return
|
|
86
|
+
var image = response.image
|
|
87
|
+
setImage("data:image/png;base64," + image.image, image.imageType, position)
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
async function useGallery(position: number) {
|
|
91
|
+
var image = await app.camera.getPicture({
|
|
92
|
+
destinationType: DestinationType.DATA_URL,
|
|
93
|
+
mediaType: MediaType.PICTURE,
|
|
94
|
+
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
95
|
+
})
|
|
96
|
+
setImage(image, ImageType.PRINTED, position)
|
|
97
|
+
}
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
document.getElementById("clear-results")!.onclick = () => clearResults()
|
|
99
|
+
async function pickImage(position: number) {
|
|
100
|
+
var option = await app.dialogs.confirm("", "Select option", ["Use gallery", "Use camera"])
|
|
101
|
+
if (option == 1) useGallery(position)
|
|
102
|
+
else useCamera(position)
|
|
103
|
+
}
|
|
99
104
|
|
|
100
|
-
|
|
105
|
+
async function loadAssetIfExists(path: string): Promise<string | null> {
|
|
106
|
+
try {
|
|
107
|
+
var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
|
|
108
|
+
var fileEntry = await File.getFile(dir, path, null)
|
|
109
|
+
var result = await new Promise<string | null>((resolve, _) => {
|
|
110
|
+
fileEntry.file(file => {
|
|
111
|
+
var reader = new FileReader()
|
|
112
|
+
reader.onloadend = (_) => resolve(reader.result as string)
|
|
113
|
+
reader.readAsDataURL(file)
|
|
114
|
+
}, _ => resolve(null))
|
|
115
|
+
})
|
|
116
|
+
return result
|
|
117
|
+
} catch (_) {
|
|
118
|
+
return null
|
|
119
|
+
}
|
|
101
120
|
}
|
|
102
121
|
|
|
103
|
-
var
|
|
104
|
-
var
|
|
105
|
-
var
|
|
122
|
+
var app: Main
|
|
123
|
+
var faceSdk = FaceSDK.instance
|
|
124
|
+
var image1: MatchFacesImage | null
|
|
125
|
+
var image2: MatchFacesImage | null
|
|
126
|
+
|
|
127
|
+
var setStatus = (data: string) => document.getElementById("status").innerHTML = data
|
|
128
|
+
var setLivenessStatus = (data: string) => document.getElementById("liveness-status").innerHTML = data
|
|
129
|
+
var setSimilarityStatus = (data: string) => document.getElementById("similarity-status").innerHTML = data
|
|
106
130
|
var setUiImage1 = (data: string) => (document.getElementById("first-image") as HTMLImageElement).src = data
|
|
107
131
|
var setUiImage2 = (data: string) => (document.getElementById("second-image") as HTMLImageElement).src = data
|
|
108
|
-
var
|
|
109
|
-
setStatus("Ready")
|
|
110
|
-
setSimilarityStatus("null")
|
|
111
|
-
setLivenessStatus("null")
|
|
132
|
+
var resetImages = () => {
|
|
112
133
|
setUiImage1("images/portrait.png")
|
|
113
134
|
setUiImage2("images/portrait.png")
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@Component({
|
|
138
|
+
selector: 'app-root',
|
|
139
|
+
templateUrl: 'main.html',
|
|
140
|
+
styleUrl: 'main.css'
|
|
141
|
+
})
|
|
142
|
+
export class Main {
|
|
143
|
+
dialogs: Dialogs
|
|
144
|
+
camera: Camera
|
|
145
|
+
|
|
146
|
+
constructor(platform: Platform, dialogs: Dialogs, camera: Camera) {
|
|
147
|
+
platform.ready().then(() => {
|
|
148
|
+
this.dialogs = dialogs
|
|
149
|
+
this.camera = camera
|
|
150
|
+
app = this
|
|
151
|
+
|
|
152
|
+
document.getElementById("first-image").onclick = () => pickImage(1)
|
|
153
|
+
document.getElementById("second-image").onclick = () => pickImage(2)
|
|
154
|
+
document.getElementById("match-faces").onclick = () => matchFaces()
|
|
155
|
+
document.getElementById("start-liveness").onclick = () => startLiveness()
|
|
156
|
+
document.getElementById("clear-results").onclick = () => clearResults()
|
|
157
|
+
|
|
158
|
+
init()
|
|
159
|
+
});
|
|
160
|
+
}
|
|
116
161
|
}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { registerRootComponent } from 'expo'
|
|
2
2
|
import WebView from 'react-native-webview'
|
|
3
|
-
import
|
|
4
|
-
import * as RNFS from 'react-native-fs'
|
|
5
|
-
import { Alert, Platform } from 'react-native'
|
|
6
|
-
import { launchImageLibrary } from 'react-native-image-picker'
|
|
7
|
-
import { main } from './src/main'
|
|
3
|
+
import { onload } from './src/main'
|
|
8
4
|
|
|
9
5
|
var webViewRef: any
|
|
10
6
|
const onclicks: any = {}
|
|
11
7
|
const onMessage = (json: any) => {
|
|
12
8
|
const event = JSON.parse(json.nativeEvent.data)
|
|
13
|
-
if (event.id === "ready")
|
|
9
|
+
if (event.id === "ready") onload()
|
|
14
10
|
if (event.id === "onclick") {
|
|
15
11
|
onclicks[event.value]()
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
14
|
|
|
19
|
-
const document = {
|
|
15
|
+
export const document = {
|
|
20
16
|
getElementById(id: string): any {
|
|
21
17
|
return new Proxy({}, {
|
|
22
18
|
set(_, prop: string, value) {
|
|
@@ -28,67 +24,29 @@ const document = {
|
|
|
28
24
|
}; true
|
|
29
25
|
`)
|
|
30
26
|
} else
|
|
31
|
-
webViewRef.injectJavaScript(`document.getElementById("${id}").${prop} = ${
|
|
27
|
+
webViewRef.injectJavaScript(`document.getElementById("${id}").${prop} = "${value}"; true`)
|
|
32
28
|
return true
|
|
33
29
|
},
|
|
34
30
|
get(_, prop: string) {
|
|
35
31
|
if (prop === "style") return new Proxy({}, {
|
|
36
32
|
set(_, styleProp: string, value) {
|
|
37
|
-
webViewRef.injectJavaScript(`document.getElementById("${id}").style.${styleProp} = ${
|
|
33
|
+
webViewRef.injectJavaScript(`document.getElementById("${id}").style.${styleProp} = "${value}"; true`)
|
|
38
34
|
return true
|
|
39
35
|
}
|
|
40
36
|
})
|
|
41
|
-
if (prop === "insertAdjacentHTML") return (position: string, html: string) => {
|
|
42
|
-
webViewRef.injectJavaScript(`document.getElementById("${id}").insertAdjacentHTML('${position}', \`${html}\`); true`)
|
|
43
|
-
return true
|
|
44
|
-
}
|
|
45
37
|
return undefined
|
|
46
|
-
}
|
|
38
|
+
},
|
|
47
39
|
}
|
|
48
40
|
)
|
|
49
41
|
}
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
function parseValue(value: any) {
|
|
53
|
-
if (value !== true && value !== false) return `"${value}"`
|
|
54
|
-
return value
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
(globalThis as any).document = document;
|
|
58
44
|
registerRootComponent(() =>
|
|
59
45
|
<WebView
|
|
60
46
|
ref={ref => { webViewRef = ref }}
|
|
61
47
|
onMessage={onMessage}
|
|
62
48
|
source={require("./index.html")}
|
|
63
49
|
scrollEnabled={false}
|
|
64
|
-
|
|
50
|
+
injectedJavaScript="document.body.addEventListener('touchmove', function(e) { e.preventDefault() }, { passive: false })"
|
|
65
51
|
/>
|
|
66
52
|
)
|
|
67
|
-
|
|
68
|
-
export async function loadAssetIfExists(path: string): Promise<string | null> {
|
|
69
|
-
if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
|
|
70
|
-
var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
|
|
71
|
-
try {
|
|
72
|
-
return await readFile(path, 'base64')
|
|
73
|
-
} catch {
|
|
74
|
-
return null
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function pickImage(): Promise<string | null> {
|
|
79
|
-
var response = await launchImageLibrary({
|
|
80
|
-
mediaType: 'photo',
|
|
81
|
-
selectionLimit: 1,
|
|
82
|
-
includeBase64: true
|
|
83
|
-
})
|
|
84
|
-
return "data:image/png;base64," + response?.assets?.[0].base64!
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export async function chooseOption(): Promise<boolean | null> {
|
|
88
|
-
return new Promise<boolean | null>((resolve) => {
|
|
89
|
-
Alert.alert("Select option", "", [
|
|
90
|
-
{ text: "Use gallery", onPress: () => { resolve(false) } },
|
|
91
|
-
{ text: "Use camera", onPress: () => { resolve(true) } }
|
|
92
|
-
], { cancelable: true, onDismiss: () => resolve(null) })
|
|
93
|
-
})
|
|
94
|
-
}
|