@regulaforensics/document-reader 8.2.186-beta → 8.2.204-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/RNDocumentReader.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/cordova.gradle +2 -2
- package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +2 -0
- package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +6 -0
- package/examples/capacitor/package.json +1 -1
- package/examples/capacitor/src/extra/bt_device.tsx +2 -2
- package/examples/capacitor/src/extra/custom_rfid.tsx +29 -42
- package/examples/capacitor/src/main.tsx +85 -53
- package/examples/cordova/config.xml +3 -2
- package/examples/cordova/package.json +1 -1
- package/examples/cordova/www/images/portrait.png +0 -0
- package/examples/cordova/www/index.html +2 -17
- package/examples/cordova/www/index.js +40 -0
- package/examples/cordova/www/src/extra/bt_device.js +31 -0
- package/examples/cordova/www/src/extra/custom_rfid.js +60 -0
- package/examples/cordova/www/src/main.css +7 -6
- package/examples/cordova/www/src/main.html +10 -32
- package/examples/cordova/www/src/main.js +174 -22
- package/examples/ionic/config.xml +9 -4
- package/examples/ionic/index.ts +1 -2
- package/examples/ionic/package-lock.json +1862 -1638
- package/examples/ionic/package.json +1 -4
- package/examples/ionic/src/extra/bt_device.ts +32 -0
- package/examples/ionic/src/extra/custom_rfid.ts +61 -0
- package/examples/ionic/src/images/portrait.png +0 -0
- package/examples/ionic/src/main.css +7 -6
- package/examples/ionic/src/main.html +39 -61
- package/examples/ionic/src/main.ts +183 -36
- package/examples/react_native/app.config.ts +3 -1
- package/examples/react_native/images/portrait.png +0 -0
- package/examples/react_native/index.tsx +8 -2
- package/examples/react_native/package.json +1 -1
- package/examples/react_native/src/extra/bt_device.tsx +33 -0
- package/examples/react_native/src/extra/custom_rfid.tsx +62 -0
- package/examples/react_native/src/main.css +7 -6
- package/examples/react_native/src/main.html +10 -32
- package/examples/react_native/src/main.tsx +167 -21
- package/ios/RGLWConfig.m +2 -0
- package/ios/RGLWMain.m +10 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/www/capacitor/index.js +16 -0
- package/www/capacitor/params/customization/Customization.js +7 -0
- package/www/capacitor/results/visual_results/FieldType.js +3 -1
- package/www/cordova.js +26 -1
- package/www/react-native/index.js +16 -0
- package/www/react-native/internal/bridge.js +1 -1
- package/www/react-native/params/customization/Customization.js +7 -0
- package/www/react-native/results/visual_results/FieldType.js +3 -1
- package/www/types/index.d.ts +6 -0
- package/www/types/params/customization/Customization.d.ts +5 -0
- package/www/types/results/visual_results/FieldType.d.ts +5 -1
|
@@ -7,45 +7,23 @@
|
|
|
7
7
|
<div class="row">
|
|
8
8
|
<div class="column" style="padding: 5px;">
|
|
9
9
|
<p>Portrait</p>
|
|
10
|
-
<img id="portrait-image" src="images/portrait.png" height="
|
|
10
|
+
<img id="portrait-image" src="images/portrait.png" height="160px" width="120px">
|
|
11
11
|
</div>
|
|
12
12
|
<div class="column" style="padding: 5px;">
|
|
13
13
|
<p>Document image</p>
|
|
14
|
-
<img id="document-image" src="images/document.png" height="
|
|
14
|
+
<img id="document-image" src="images/document.png" height="160px" width="200px">
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
<div id="scenario-container" class="column no-scroll"
|
|
18
|
-
style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
19
|
-
<div id="scenarios" class="scroll">
|
|
20
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
21
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
22
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
25
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
26
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
29
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
30
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
31
|
-
</div>
|
|
32
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
33
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
34
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
35
|
-
</div>
|
|
36
|
-
<div class="row" style="align-items: baseline; padding: 15px;">
|
|
37
|
-
<input type="radio" name="scenario" value="Aaa">
|
|
38
|
-
<span style="width: 200px; padding-left: 5px;">Aaa</span>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
43
|
-
<span id="rfid-checkbox-description" style="font-size: 18px;">Process rfid reading</span>
|
|
44
|
-
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" />
|
|
45
|
-
</div>
|
|
46
17
|
<div id="bt-device" class="row" style="display: none;">
|
|
47
18
|
<input type="text" placeholder="Regula 0000" />
|
|
48
|
-
<button class="button">Connect</button>
|
|
19
|
+
<button id="connect" class="button">Connect</button>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
22
|
+
<div id="scenarios" class="scroll"></div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
25
|
+
<span id="rfid-checkbox-description" style="font-size: 18px;width: 100%;">Process rfid reading(unavailable)</span>
|
|
26
|
+
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" disabled />
|
|
49
27
|
</div>
|
|
50
28
|
<div class="row">
|
|
51
29
|
<button id="scan" class="button">Scan document</button>
|
|
@@ -1,42 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
DocumentReader = DocumentReaderPlugin.DocumentReader
|
|
4
|
-
InitConfig = DocumentReaderPlugin.InitConfig
|
|
1
|
+
import { setupBTDevice, useBtDevice } from './extra/bt_device.js'
|
|
2
|
+
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid.js'
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
var documentReader = DocumentReader.instance
|
|
5
|
+
var selectedScenario
|
|
6
|
+
var doRfid = false
|
|
7
|
+
var isReadingRfid = false
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
async function init() {
|
|
10
|
+
if (!await initialize()) return
|
|
11
|
+
setScenarios(documentReader.availableScenarios)
|
|
12
|
+
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
13
|
+
setStatus("Ready")
|
|
14
|
+
}
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
async function scan() {
|
|
17
|
+
if (!await documentReader.isReady()) return
|
|
18
|
+
clearResults()
|
|
19
|
+
documentReader.startScanner(
|
|
20
|
+
ScannerConfig.withScenario(selectedScenario),
|
|
21
|
+
handleCompletion,
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function recognize() {
|
|
26
|
+
if (!await documentReader.isReady()) return
|
|
27
|
+
var image = await pickImage()
|
|
28
|
+
if (image == null) return
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
clearResults()
|
|
31
|
+
documentReader.recognize(
|
|
32
|
+
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
33
|
+
handleCompletion,
|
|
34
|
+
)
|
|
18
35
|
}
|
|
19
36
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
export function handleCompletion(action, results, error) {
|
|
38
|
+
handleException(error)
|
|
39
|
+
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
40
|
+
displayResults(results)
|
|
41
|
+
} else if (DocReaderAction.finished(action) && shouldRfid(results)) {
|
|
42
|
+
isReadingRfid = true
|
|
43
|
+
readRfid()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function displayResults(results) {
|
|
48
|
+
isReadingRfid = false
|
|
49
|
+
clearResults()
|
|
50
|
+
if (results == null) return
|
|
51
|
+
|
|
52
|
+
var name = await results.textFieldValueByType(FieldType.SURNAME_AND_GIVEN_NAMES)
|
|
53
|
+
var docImage = await results.graphicFieldImageByType(GraphicFieldType.DOCUMENT_IMAGE)
|
|
54
|
+
var portrait = await results.graphicFieldImageByType(GraphicFieldType.PORTRAIT)
|
|
55
|
+
portrait = await results.graphicFieldImageByTypeSource(GraphicFieldType.PORTRAIT, ResultType.RFID_IMAGE_DATA) ?? portrait
|
|
56
|
+
|
|
57
|
+
setStatus(name)
|
|
58
|
+
setPortrait(portrait)
|
|
59
|
+
setDocImage(docImage)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var readRfid = () => {
|
|
63
|
+
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function shouldRfid(results) {
|
|
67
|
+
return doRfid &&
|
|
68
|
+
!isReadingRfid &&
|
|
69
|
+
results != null && results.chipPage != 0
|
|
23
70
|
}
|
|
24
71
|
|
|
25
72
|
async function initialize() {
|
|
26
73
|
setStatus("Initializing...")
|
|
27
74
|
|
|
28
|
-
var license = await
|
|
75
|
+
var license = await loadAsset("regula.license")
|
|
29
76
|
var initConfig = new InitConfig(license)
|
|
30
77
|
var [success, error] = await documentReader.initialize(initConfig)
|
|
31
|
-
|
|
32
|
-
|
|
78
|
+
|
|
79
|
+
handleException(error)
|
|
80
|
+
return success
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function handleException(error) {
|
|
84
|
+
if (error != null) {
|
|
33
85
|
setStatus(error.message)
|
|
34
86
|
console.log(error.code + ": " + error.message)
|
|
35
87
|
}
|
|
36
|
-
return success
|
|
37
88
|
}
|
|
38
89
|
|
|
39
|
-
|
|
90
|
+
// ui --------------------------------------------------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
export function setStatus(data) {
|
|
93
|
+
if (data != null)
|
|
94
|
+
document.getElementById("status").innerHTML = data
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function setPortrait(data) {
|
|
98
|
+
if (data != null)
|
|
99
|
+
portraitUIImage.src = "data:image/png;base64," + data
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function setDocImage(data) {
|
|
103
|
+
if (data != null)
|
|
104
|
+
documentUIImage.src = "data:image/png;base64," + data
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function clearResults() {
|
|
108
|
+
setStatus("Ready")
|
|
109
|
+
portraitUIImage.src = "images/portrait.png"
|
|
110
|
+
documentUIImage.src = "images/document.png"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function setCanRfid(data) {
|
|
114
|
+
var checkbox // implicitly any, since cordova sample is pure js
|
|
115
|
+
checkbox = document.getElementById('rfid-checkbox')
|
|
116
|
+
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
117
|
+
if (data) {
|
|
118
|
+
checkbox.disabled = false
|
|
119
|
+
checkboxDescription.innerHTML = "Process rfid reading"
|
|
120
|
+
checkboxDescription.onclick = () => {
|
|
121
|
+
doRfid = !doRfid
|
|
122
|
+
checkbox.checked = doRfid
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// not equal --------------------------------------------------------------------------------------------------------------------
|
|
128
|
+
|
|
129
|
+
async function loadAsset(path) {
|
|
40
130
|
path = cordova.file.applicationDirectory + "www/" + path
|
|
41
131
|
return new Promise((resolve, _) => {
|
|
42
132
|
window.resolveLocalFileSystemURL(path, (fileEntry) => {
|
|
@@ -45,6 +135,68 @@ async function loadAssetIfExists(path) {
|
|
|
45
135
|
reader.onloadend = function (_) { resolve(this.result) }
|
|
46
136
|
reader.readAsDataURL(file)
|
|
47
137
|
})
|
|
48
|
-
}
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function pickImage() {
|
|
143
|
+
return new Promise((resolve, _) => {
|
|
144
|
+
navigator.camera.getPicture(
|
|
145
|
+
(imageData) => resolve(imageData),
|
|
146
|
+
(_) => resolve(null),
|
|
147
|
+
{
|
|
148
|
+
destinationType: Camera.DestinationType.DATA_URL,
|
|
149
|
+
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
|
150
|
+
mediaType: Camera.MediaType.PICTURE
|
|
151
|
+
}
|
|
152
|
+
)
|
|
49
153
|
})
|
|
50
154
|
}
|
|
155
|
+
|
|
156
|
+
var documentUIImage
|
|
157
|
+
var portraitUIImage
|
|
158
|
+
document.addEventListener('ready', () => {
|
|
159
|
+
documentUIImage = document.getElementById("document-image")
|
|
160
|
+
portraitUIImage = document.getElementById("portrait-image")
|
|
161
|
+
document.getElementById("scan").onclick = () => scan()
|
|
162
|
+
document.getElementById("recognize").onclick = () => recognize()
|
|
163
|
+
|
|
164
|
+
// custom rfid
|
|
165
|
+
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
166
|
+
|
|
167
|
+
// bt device
|
|
168
|
+
if (!useBtDevice) init()
|
|
169
|
+
else setupBTDevice()
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
// not resolved --------------------------------------------------------------------------------------------------------------------
|
|
173
|
+
|
|
174
|
+
function setScenarios(data) {
|
|
175
|
+
selectedScenario = Scenario.MRZ
|
|
176
|
+
const scenariosContainer = document.getElementById("scenarios")
|
|
177
|
+
data.forEach(scenario => scenariosContainer.appendChild(createScenarioElement(scenario)))
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function createScenarioElement(scenario) {
|
|
181
|
+
const div = document.createElement('div')
|
|
182
|
+
div.className = 'row radio'
|
|
183
|
+
|
|
184
|
+
const input = document.createElement('input')
|
|
185
|
+
input.type = 'radio'
|
|
186
|
+
input.name = 'scenario'
|
|
187
|
+
input.value = scenario.name
|
|
188
|
+
input.checked = scenario.name === selectedScenario
|
|
189
|
+
|
|
190
|
+
const span = document.createElement('span')
|
|
191
|
+
span.style.width = '200px'
|
|
192
|
+
span.style.paddingLeft = '5px'
|
|
193
|
+
span.textContent = scenario.caption
|
|
194
|
+
|
|
195
|
+
input.onclick = () => selectedScenario = scenario.name
|
|
196
|
+
span.onclick = () => input.click()
|
|
197
|
+
|
|
198
|
+
div.appendChild(input)
|
|
199
|
+
div.appendChild(span)
|
|
200
|
+
|
|
201
|
+
return div
|
|
202
|
+
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<widget android-packageName="com.regula.dr.fullauthrfid" ios-CFBundleIdentifier="regula.DocumentReader" version="1.0.0"
|
|
2
|
+
<widget android-packageName="com.regula.dr.fullauthrfid" ios-CFBundleIdentifier="regula.DocumentReader" version="1.0.0"
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
4
|
<name>DocumentReader</name>
|
|
4
5
|
<icon src="src/images/icon.png" />
|
|
5
6
|
<platform name="android">
|
|
6
7
|
<preference name="orientation" value="portrait" />
|
|
7
|
-
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
8
|
-
<application android:usesCleartextTraffic="true" />
|
|
9
|
-
</edit-config>
|
|
10
8
|
<preference name="android-minSdkVersion" value="24" />
|
|
11
9
|
<preference name="android-targetSdkVersion" value="35" />
|
|
12
10
|
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
11
|
+
<config-file parent="/*" target="AndroidManifest.xml">
|
|
12
|
+
<uses-permission android:name="android.permission.NFC" />
|
|
13
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
14
|
+
</config-file>
|
|
15
|
+
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
16
|
+
<application android:usesCleartextTraffic="true" />
|
|
17
|
+
</edit-config>
|
|
13
18
|
</platform>
|
|
14
19
|
<platform name="ios">
|
|
15
20
|
<preference name="orientation" value="portrait" />
|
package/examples/ionic/index.ts
CHANGED
|
@@ -2,14 +2,13 @@ import 'zone.js';
|
|
|
2
2
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
3
3
|
import { BrowserModule } from '@angular/platform-browser'
|
|
4
4
|
import { IonicModule, Platform } from '@ionic/angular'
|
|
5
|
-
import { Dialogs } from '@awesome-cordova-plugins/dialogs/ngx'
|
|
6
5
|
import { Camera } from '@awesome-cordova-plugins/camera/ngx'
|
|
7
6
|
import { Main } from './src/main'
|
|
8
7
|
import { NgModule } from '@angular/core'
|
|
9
8
|
|
|
10
9
|
@NgModule({
|
|
11
10
|
bootstrap: [Main],
|
|
12
|
-
providers: [Platform,
|
|
11
|
+
providers: [Platform, Camera],
|
|
13
12
|
imports: [BrowserModule, IonicModule.forRoot()]
|
|
14
13
|
})
|
|
15
14
|
class MainModule { }
|