@regulaforensics/ionic-native-document-reader 6.3.0 → 6.5.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/.github/ISSUE_TEMPLATE/bug-report.md +39 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/ISSUE_TEMPLATE/feature-request.md +20 -0
- package/example/README.md +0 -3
- package/example/package.json +10 -10
- package/example/src/app/app.component.spec.ts +2 -2
- package/example/src/app/app.component.ts +2 -2
- package/example/src/app/app.module.ts +2 -2
- package/example/src/app/home/home.module.ts +2 -2
- package/example/src/app/home/home.page.ts +24 -24
- package/index.d.ts +3584 -3484
- package/index.js +3292 -3105
- package/ngx/index.d.ts +3584 -3484
- package/ngx/index.js +3292 -3105
- package/ngx/index.metadata.json +1 -1
- package/package.json +1 -1
- package/reactExample/README.md +0 -3
- package/reactExample/package.json +8 -8
- package/reactExample/src/pages/Home.tsx +40 -39
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IonPage, isPlatform } from '@ionic/react';
|
|
2
2
|
import { DocumentReader, DocumentReaderScenario, Enum, DocumentReaderCompletion, DocumentReaderResults, DocumentReaderNotification } from '@regulaforensics/ionic-native-document-reader';
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { File } from '@
|
|
5
|
-
import { AndroidPermissions } from "@
|
|
6
|
-
import { ImagePicker } from "@
|
|
4
|
+
import { File } from '@awesome-cordova-plugins/file'
|
|
5
|
+
import { AndroidPermissions } from "@awesome-cordova-plugins/android-permissions"
|
|
6
|
+
import { ImagePicker } from "@awesome-cordova-plugins/image-picker"
|
|
7
7
|
|
|
8
8
|
var doRfid: boolean = false
|
|
9
|
+
var isReadingRfidCustomUi: boolean = false
|
|
9
10
|
var isReadingRfid: boolean = false
|
|
10
11
|
var rfidUIHeader: string = "Reading RFID"
|
|
11
12
|
var rfidUIHeaderColor: string = "black"
|
|
@@ -44,14 +45,17 @@ status.innerHTML = "loading......"
|
|
|
44
45
|
status.style.backgroundColor = "grey"
|
|
45
46
|
document.addEventListener("deviceready", onDeviceReady, false);
|
|
46
47
|
|
|
47
|
-
function onDeviceReady(){
|
|
48
|
+
function onDeviceReady() {
|
|
48
49
|
readFile("public/assets", "regula.license", (license: any) => {
|
|
49
50
|
DocumentReader.prepareDatabase("Full").subscribe(r => {
|
|
50
51
|
if (r != "database prepared")
|
|
51
52
|
status.innerHTML = "Downloading database: " + r + "%"
|
|
52
53
|
else {
|
|
53
54
|
status.innerHTML = "Loading......"
|
|
54
|
-
DocumentReader.initializeReader(
|
|
55
|
+
DocumentReader.initializeReader({
|
|
56
|
+
license: license,
|
|
57
|
+
delayedNNLoad: true
|
|
58
|
+
}).then(m => onInitialized()).catch(error1)
|
|
55
59
|
}
|
|
56
60
|
})
|
|
57
61
|
})
|
|
@@ -94,8 +98,8 @@ function readFile(dirPath: string, fileName: string, callback: any, ...items: an
|
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
function updateUI() {
|
|
97
|
-
mainUI.style.display =
|
|
98
|
-
rfidUI.style.display =
|
|
101
|
+
mainUI.style.display = isReadingRfidCustomUi ? "none" : ""
|
|
102
|
+
rfidUI.style.display = isReadingRfidCustomUi ? "" : "none"
|
|
99
103
|
rfidUIHeaderRef.innerHTML = rfidUIHeader
|
|
100
104
|
rfidUIHeaderRef.style.color = rfidUIHeaderColor
|
|
101
105
|
rfidDescriptionRef.innerHTML = rfidDescription
|
|
@@ -107,34 +111,39 @@ function stopRfid() {
|
|
|
107
111
|
DocumentReader.stopRFIDReader()
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
function handleCompletion(completion
|
|
111
|
-
if (
|
|
114
|
+
function handleCompletion(completion?: DocumentReaderCompletion) {
|
|
115
|
+
if (completion == undefined) return;
|
|
116
|
+
if (isReadingRfidCustomUi && (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR))
|
|
112
117
|
hideRfidUI()
|
|
113
|
-
if (
|
|
114
|
-
updateRfidUI(completion.results
|
|
118
|
+
if (isReadingRfidCustomUi && completion.action === Enum.DocReaderAction.NOTIFICATION)
|
|
119
|
+
updateRfidUI(completion.results!.documentReaderNotification!)
|
|
115
120
|
if (completion.action === Enum.DocReaderAction.COMPLETE)
|
|
116
|
-
if (
|
|
117
|
-
if (completion.results
|
|
121
|
+
if (isReadingRfidCustomUi) {
|
|
122
|
+
if (completion.results!.rfidResult !== 1)
|
|
118
123
|
restartRfidUI()
|
|
119
124
|
else {
|
|
120
125
|
hideRfidUI()
|
|
121
|
-
displayResults(completion.results
|
|
126
|
+
displayResults(completion.results!)
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
else
|
|
125
|
-
handleResults(completion.results
|
|
130
|
+
handleResults(completion.results!)
|
|
131
|
+
if (completion.action === Enum.DocReaderAction.TIMEOUT)
|
|
132
|
+
handleResults(completion.results!)
|
|
133
|
+
if (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR)
|
|
134
|
+
isReadingRfid = false
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
function showRfidUI() {
|
|
129
138
|
// show animation
|
|
130
|
-
|
|
139
|
+
isReadingRfidCustomUi = true
|
|
131
140
|
updateUI()
|
|
132
141
|
}
|
|
133
142
|
|
|
134
143
|
function hideRfidUI() {
|
|
135
144
|
// show animation
|
|
136
145
|
restartRfidUI()
|
|
137
|
-
|
|
146
|
+
isReadingRfidCustomUi = false
|
|
138
147
|
rfidUIHeader = "Reading RFID"
|
|
139
148
|
rfidUIHeaderColor = "black"
|
|
140
149
|
updateUI()
|
|
@@ -150,10 +159,10 @@ function restartRfidUI() {
|
|
|
150
159
|
|
|
151
160
|
function updateRfidUI(notification: DocumentReaderNotification) {
|
|
152
161
|
if (notification.code === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
|
|
153
|
-
rfidDescription = Enum.eRFID_DataFile_Type.getTranslation(notification.attachment
|
|
162
|
+
rfidDescription = Enum.eRFID_DataFile_Type.getTranslation(notification.attachment!)
|
|
154
163
|
rfidUIHeader = "Reading RFID"
|
|
155
164
|
rfidUIHeaderColor = "black"
|
|
156
|
-
rfidProgress = notification.value
|
|
165
|
+
rfidProgress = notification.value!
|
|
157
166
|
updateUI()
|
|
158
167
|
if (isPlatform("ios"))
|
|
159
168
|
DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + notification.value + "%")
|
|
@@ -166,8 +175,7 @@ function customRFID() {
|
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
function usualRFID() {
|
|
169
|
-
|
|
170
|
-
rfidCheckbox.checked = false
|
|
178
|
+
isReadingRfid = true
|
|
171
179
|
var notification = "rfidNotificationCompletionEvent"
|
|
172
180
|
var paCert = "paCertificateCompletionEvent"
|
|
173
181
|
var taCert = "taCertificateCompletionEvent"
|
|
@@ -226,10 +234,10 @@ function postInitialize(scenarios: Array<any>, canRfid: boolean) {
|
|
|
226
234
|
inputs.push(input)
|
|
227
235
|
input.type = "radio"
|
|
228
236
|
input.name = "scenario"
|
|
229
|
-
input.value = (DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)
|
|
237
|
+
input.value = (DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name)!
|
|
230
238
|
if (index == 0)
|
|
231
239
|
input.checked = true
|
|
232
|
-
input.onclick = () => DocumentReader.setConfig({ processParams: { scenario: DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)
|
|
240
|
+
input.onclick = () => DocumentReader.setConfig({ processParams: { scenario: DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name } })
|
|
233
241
|
input.style.display = "inline-block"
|
|
234
242
|
}
|
|
235
243
|
for (let input of inputs) {
|
|
@@ -252,29 +260,22 @@ function postInitialize(scenarios: Array<any>, canRfid: boolean) {
|
|
|
252
260
|
|
|
253
261
|
function handleResults(results: DocumentReaderResults) {
|
|
254
262
|
clearResults()
|
|
255
|
-
if (doRfid && results != null && results.chipPage != 0) {
|
|
256
|
-
var accessKey = results.getTextFieldValueByType!!({ fieldType: 51 })
|
|
257
|
-
if (accessKey != null && accessKey != "") {
|
|
258
|
-
accessKey = accessKey.replace(/^/g, '').replace(/\n/g, '')
|
|
259
|
-
DocumentReader.setRfidScenario({ mMrz: accessKey, mPacePasswordType: 1, })
|
|
260
|
-
} else {
|
|
261
|
-
accessKey = results.getTextFieldValueByType!!({ fieldType: 159 })
|
|
262
|
-
if (accessKey != null && accessKey != "")
|
|
263
|
-
DocumentReader.setRfidScenario({ mMrz: accessKey, mPacePasswordType: 2, })
|
|
264
|
-
}
|
|
263
|
+
if (doRfid && !isReadingRfid && results != null && results.chipPage != 0) {
|
|
265
264
|
// customRFID()
|
|
266
265
|
usualRFID()
|
|
267
|
-
} else
|
|
266
|
+
} else {
|
|
267
|
+
isReadingRfid = false
|
|
268
268
|
displayResults(results)
|
|
269
|
+
}
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
function displayResults(results: DocumentReaderResults) {
|
|
272
|
-
status.innerHTML = results.getTextFieldValueByType
|
|
273
|
+
status.innerHTML = results.getTextFieldValueByType({ fieldType: Enum.eVisualFieldType.FT_SURNAME_AND_GIVEN_NAMES })!
|
|
273
274
|
status.style.backgroundColor = "green"
|
|
274
|
-
if (results.getGraphicFieldImageByType
|
|
275
|
-
documentImage.src = "data:image/png;base64," + results.getGraphicFieldImageByType
|
|
276
|
-
if (results.getGraphicFieldImageByType
|
|
277
|
-
portraitImage.src = "data:image/png;base64," + results.getGraphicFieldImageByType
|
|
275
|
+
if (results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE }) != null)
|
|
276
|
+
documentImage.src = "data:image/png;base64," + results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE })
|
|
277
|
+
if (results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_PORTRAIT }) != null)
|
|
278
|
+
portraitImage.src = "data:image/png;base64," + results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_PORTRAIT })
|
|
278
279
|
}
|
|
279
280
|
|
|
280
281
|
function clearResults() {
|