@regulaforensics/cordova-plugin-document-reader-api 6.4.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/example/package.json +5 -5
- package/example/www/js/index.js +86 -85
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/DocumentReader.java +12 -14
- package/src/android/Helpers.java +1 -1
- package/src/android/JSONConstructor.java +24 -47
- package/src/android/RegulaConfig.java +46 -6
- package/src/android/build.gradle +1 -1
- package/src/ios/RGLDocumentReader.m +8 -8
- package/src/ios/RGLWJSONConstructor.h +1 -0
- package/src/ios/RGLWJSONConstructor.m +22 -3
- package/src/ios/RegulaConfig.m +37 -6
- package/tmp.64209.json +30 -0
- package/www/DocumentReader.js +3191 -3112
package/example/package.json
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"author": "Regula Forensics Inc.",
|
|
14
14
|
"license": "commercial",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"cordova-android": "^
|
|
17
|
-
"cordova-ios": "^6.
|
|
16
|
+
"cordova-android": "^10.1.1",
|
|
17
|
+
"cordova-ios": "^6.2.0",
|
|
18
18
|
"cordova-plugin-add-swift-support": "^2.0.2",
|
|
19
|
-
"@regulaforensics/cordova-plugin-document-reader-api": "
|
|
20
|
-
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "
|
|
19
|
+
"@regulaforensics/cordova-plugin-document-reader-api": "6.5.0",
|
|
20
|
+
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "6.5.0",
|
|
21
21
|
"cordova-plugin-file": "^6.0.2",
|
|
22
22
|
"cordova-plugin-image-picker": "^1.1.3",
|
|
23
23
|
"cordova-plugin-android-permissions": "1.1.0",
|
|
@@ -47,4 +47,4 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"cordova-plugin-whitelist": "^1.3.4"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
package/example/www/js/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var app = {
|
|
2
|
-
initialize: function() {
|
|
2
|
+
initialize: function () {
|
|
3
3
|
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false)
|
|
4
4
|
},
|
|
5
5
|
|
|
6
|
-
onDeviceReady: function() {
|
|
6
|
+
onDeviceReady: function () {
|
|
7
7
|
this.receivedEvent('deviceready')
|
|
8
8
|
document.getElementById("status").innerHTML = "loading......"
|
|
9
9
|
document.getElementById("status").style.backgroundColor = "grey"
|
|
@@ -14,13 +14,14 @@ var app = {
|
|
|
14
14
|
var doRfid = false
|
|
15
15
|
var encryption = false
|
|
16
16
|
const ENCRYPTED_RESULT_SERVICE = "https://api.regulaforensics.com/api/process"
|
|
17
|
+
var isReadingRfidCustomUi = false
|
|
17
18
|
var isReadingRfid = false
|
|
18
19
|
var rfidUIHeader = "Reading RFID"
|
|
19
20
|
var rfidUIHeaderColor = "black"
|
|
20
21
|
var rfidDescription = "Place your phone on top of the NFC tag"
|
|
21
22
|
var rfidProgress = -1
|
|
22
|
-
document.getElementById("rfidUI").style.display =
|
|
23
|
-
document.getElementById("mainUI").style.display = !
|
|
23
|
+
document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
|
|
24
|
+
document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
|
|
24
25
|
document.getElementById("rfidUIHeader").innerHTML = rfidUIHeader
|
|
25
26
|
document.getElementById("rfidUIHeader").style.color = rfidUIHeaderColor
|
|
26
27
|
document.getElementById("rfidDescription").innerHTML = rfidDescription
|
|
@@ -35,7 +36,7 @@ var app = {
|
|
|
35
36
|
input.value = DocumentReaderScenario.fromJson(typeof scenarios[index] === "string" ? JSON.parse(scenarios[index]) : scenarios[index]).name
|
|
36
37
|
if (index == 0)
|
|
37
38
|
input.checked = true
|
|
38
|
-
input.onclick = function() { DocumentReader.setConfig({ processParams: { scenario: this.value } }, function(m) {}, function(e) {}) }
|
|
39
|
+
input.onclick = function () { DocumentReader.setConfig({ processParams: { scenario: this.value } }, function (m) { }, function (e) { }) }
|
|
39
40
|
input.style.display = "inline-block"
|
|
40
41
|
document.getElementById("scenariosRadioGroup").appendChild(input)
|
|
41
42
|
var label = document.createElement("span")
|
|
@@ -43,7 +44,7 @@ var app = {
|
|
|
43
44
|
label.style.display = "inline-block"
|
|
44
45
|
label.style.width = "200px"
|
|
45
46
|
label.radioButton = input
|
|
46
|
-
label.onclick = function() { this.radioButton.click() }
|
|
47
|
+
label.onclick = function () { this.radioButton.click() }
|
|
47
48
|
document.getElementById("scenariosRadioGroup").appendChild(label)
|
|
48
49
|
document.getElementById("scenariosRadioGroup").appendChild(document.createElement("br"))
|
|
49
50
|
}
|
|
@@ -51,25 +52,25 @@ var app = {
|
|
|
51
52
|
document.getElementById("rfidCheckbox").disabled = false
|
|
52
53
|
document.getElementById("rfidCheckboxText").style.color = "black"
|
|
53
54
|
document.getElementById("rfidCheckboxText").innerHTML = " Process rfid reading"
|
|
54
|
-
document.getElementById("rfidCheckboxText").onclick = function() { document.getElementById("rfidCheckbox").click() }
|
|
55
|
-
document.getElementById("rfidCheckbox").onchange = function() { doRfid = this.checked }
|
|
55
|
+
document.getElementById("rfidCheckboxText").onclick = function () { document.getElementById("rfidCheckbox").click() }
|
|
56
|
+
document.getElementById("rfidCheckbox").onchange = function () { doRfid = this.checked }
|
|
56
57
|
}
|
|
57
58
|
document.getElementById("encryptionCheckbox").disabled = false
|
|
58
59
|
document.getElementById("encryptionCheckboxText").style.color = "black"
|
|
59
60
|
document.getElementById("encryptionCheckboxText").innerHTML = " Data encryption"
|
|
60
|
-
document.getElementById("encryptionCheckboxText").onclick = function() { document.getElementById("encryptionCheckbox").click() }
|
|
61
|
-
document.getElementById("encryptionCheckbox").onchange = function() { encryption = this.checked }
|
|
61
|
+
document.getElementById("encryptionCheckboxText").onclick = function () { document.getElementById("encryptionCheckbox").click() }
|
|
62
|
+
document.getElementById("encryptionCheckbox").onchange = function () { encryption = this.checked }
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
function scan() {
|
|
65
|
-
DocumentReader.showScanner(function(m) {
|
|
66
|
+
DocumentReader.showScanner(function (m) {
|
|
66
67
|
handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m)))
|
|
67
|
-
}, function(e) {})
|
|
68
|
+
}, function (e) { })
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
function recognizeAndroid() {
|
|
71
72
|
var permissions = cordova.plugins.permissions
|
|
72
|
-
permissions.checkPermission(permissions.READ_EXTERNAL_STORAGE, function(status) {
|
|
73
|
+
permissions.checkPermission(permissions.READ_EXTERNAL_STORAGE, function (status) {
|
|
73
74
|
if (status.hasPermission)
|
|
74
75
|
recognize()
|
|
75
76
|
else {
|
|
@@ -85,11 +86,11 @@ var app = {
|
|
|
85
86
|
|
|
86
87
|
function stopRfid() {
|
|
87
88
|
hideRfidUI()
|
|
88
|
-
DocumentReader.stopRFIDReader(function(e) {}, function(e) {})
|
|
89
|
+
DocumentReader.stopRFIDReader(function (e) { }, function (e) { })
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
function recognize() {
|
|
92
|
-
window.imagePicker.getPictures(function(results) {
|
|
93
|
+
window.imagePicker.getPictures(function (results) {
|
|
93
94
|
if (results.length > 0) {
|
|
94
95
|
clearResults()
|
|
95
96
|
document.getElementById("status").innerHTML = "copying image......"
|
|
@@ -97,46 +98,50 @@ var app = {
|
|
|
97
98
|
}
|
|
98
99
|
var images = []
|
|
99
100
|
for (var index in results)
|
|
100
|
-
readFile(results[index], function(base64) {
|
|
101
|
+
readFile(results[index], function (base64) {
|
|
101
102
|
document.getElementById("status").innerHTML = "processing image......"
|
|
102
103
|
document.getElementById("status").style.backgroundColor = "grey"
|
|
103
104
|
images.push(base64)
|
|
104
105
|
if (images.length === results.length)
|
|
105
|
-
DocumentReader.recognizeImages(images, function(m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function(e) {})
|
|
106
|
+
DocumentReader.recognizeImages(images, function (m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function (e) { })
|
|
106
107
|
})
|
|
107
|
-
}, function(e) {}, { maximumImagesCount: 10 })
|
|
108
|
+
}, function (e) { }, { maximumImagesCount: 10 })
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
function handleCompletion(completion) {
|
|
111
|
-
if (
|
|
112
|
+
if (isReadingRfidCustomUi && (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR))
|
|
112
113
|
hideRfidUI()
|
|
113
|
-
if (
|
|
114
|
+
if (isReadingRfidCustomUi && completion.action === Enum.DocReaderAction.NOTIFICATION)
|
|
114
115
|
updateRfidUI(completion.results.documentReaderNotification)
|
|
115
116
|
if (completion.action === Enum.DocReaderAction.COMPLETE)
|
|
116
|
-
if (
|
|
117
|
+
if (isReadingRfidCustomUi)
|
|
117
118
|
if (completion.results.rfidResult !== 1)
|
|
118
119
|
restartRfidUI()
|
|
119
120
|
else {
|
|
120
121
|
hideRfidUI()
|
|
121
122
|
displayResults(completion.results)
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
else
|
|
125
|
+
handleResults(completion.results)
|
|
126
|
+
if (completion.action === Enum.DocReaderAction.TIMEOUT)
|
|
124
127
|
handleResults(completion.results)
|
|
128
|
+
if(completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR)
|
|
129
|
+
isReadingRfid = false
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
function showRfidUI() {
|
|
128
133
|
// show animation
|
|
129
|
-
|
|
130
|
-
document.getElementById("rfidUI").style.display =
|
|
131
|
-
document.getElementById("mainUI").style.display = !
|
|
134
|
+
isReadingRfidCustomUi = true
|
|
135
|
+
document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
|
|
136
|
+
document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
function hideRfidUI() {
|
|
135
140
|
// show animation
|
|
136
141
|
restartRfidUI()
|
|
137
|
-
|
|
138
|
-
document.getElementById("rfidUI").style.display =
|
|
139
|
-
document.getElementById("mainUI").style.display = !
|
|
142
|
+
isReadingRfidCustomUi = false
|
|
143
|
+
document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
|
|
144
|
+
document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
|
|
140
145
|
rfidUIHeader = "Reading RFID"
|
|
141
146
|
document.getElementById("rfidUIHeader").innerHTML = rfidUIHeader
|
|
142
147
|
rfidUIHeaderColor = "black"
|
|
@@ -166,21 +171,21 @@ var app = {
|
|
|
166
171
|
rfidProgress = results.value
|
|
167
172
|
document.getElementById("rfidProgress").value = rfidProgress
|
|
168
173
|
if (window.cordova.platformId === 'ios')
|
|
169
|
-
DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + results.value + "%", function(e) {}, function(e) {})
|
|
174
|
+
DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + results.value + "%", function (e) { }, function (e) { })
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
function customRFID() {
|
|
173
178
|
showRfidUI()
|
|
174
|
-
DocumentReader.readRFID(function(m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function(e) {})
|
|
179
|
+
DocumentReader.readRFID(function (m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function (e) { })
|
|
175
180
|
}
|
|
176
181
|
|
|
177
182
|
function usualRFID() {
|
|
178
|
-
|
|
183
|
+
isReadingRfid = true
|
|
179
184
|
var notification = "rfidNotificationCompletionEvent"
|
|
180
185
|
var paCert = "paCertificateCompletionEvent"
|
|
181
186
|
var taCert = "taCertificateCompletionEvent"
|
|
182
187
|
var taSig = "taSignatureCompletionEvent"
|
|
183
|
-
DocumentReader.startRFIDReader(function(m) {
|
|
188
|
+
DocumentReader.startRFIDReader(function (m) {
|
|
184
189
|
if (m.substring(0, notification.length) === notification) {
|
|
185
190
|
m = m.substring(notification.length, m.length)
|
|
186
191
|
console.log(notification + ": " + m)
|
|
@@ -195,48 +200,41 @@ var app = {
|
|
|
195
200
|
console.log(taSig + ": " + m)
|
|
196
201
|
} else
|
|
197
202
|
handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m)))
|
|
198
|
-
}, function(e) {})
|
|
203
|
+
}, function (e) { })
|
|
199
204
|
}
|
|
200
205
|
|
|
201
206
|
function handleResults(results) {
|
|
202
207
|
clearResults()
|
|
203
|
-
if (doRfid && results != null && results.chipPage != 0) {
|
|
204
|
-
accessKey = results.getTextFieldValueByType(DocumentReader.Enum.eVisualFieldType.FT_MRZ_STRINGS)
|
|
205
|
-
if (accessKey != null && accessKey != "") {
|
|
206
|
-
accessKey = accessKey.replace(/^/g, '').replace(/\n/g, '')
|
|
207
|
-
DocumentReader.setRfidScenario({ mrz: accessKey, pacePasswordType: DocumentReader.Enum.eRFID_Password_Type.PPT_MRZ }, function(m) {}, function(e) {})
|
|
208
|
-
} else {
|
|
209
|
-
accessKey = results.getTextFieldValueByType(DocumentReader.Enum.eVisualFieldType.FT_CARD_ACCESS_NUMBER)
|
|
210
|
-
if (accessKey != null && accessKey != "")
|
|
211
|
-
DocumentReader.setRfidScenario({ password: accessKey, pacePasswordType: DocumentReader.Enum.eRFID_Password_Type.PPT_CAN }, function(m) {}, function(e) {})
|
|
212
|
-
}
|
|
208
|
+
if (doRfid && !isReadingRfid && results != null && results.chipPage != 0) {
|
|
213
209
|
//customRFID()
|
|
214
210
|
usualRFID()
|
|
215
|
-
} else
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
211
|
+
} else {
|
|
212
|
+
isReadingRfid = false
|
|
213
|
+
if (encryption) {
|
|
214
|
+
var input = JSON.parse(results.rawResult)
|
|
215
|
+
var processParam = {
|
|
216
|
+
alreadyCropped: true,
|
|
217
|
+
scenario: "FullProcess"
|
|
218
|
+
}
|
|
219
|
+
var body = {
|
|
220
|
+
List: input["ContainerList"]["List"],
|
|
221
|
+
processParam: processParam
|
|
222
|
+
}
|
|
223
|
+
postRequest(body)
|
|
224
|
+
} else
|
|
225
|
+
displayResults(results)
|
|
226
|
+
}
|
|
229
227
|
}
|
|
230
228
|
|
|
231
229
|
function postRequest(body) {
|
|
232
230
|
document.getElementById("status").innerHTML = "Getting results from server......"
|
|
233
231
|
document.getElementById("status").style.backgroundColor = "grey"
|
|
234
232
|
http.setDataSerializer('utf8')
|
|
235
|
-
http.post(ENCRYPTED_RESULT_SERVICE, JSON.stringify(body), { "content-type": "application/json; utf-8" }, function(response) {
|
|
236
|
-
DocumentReader.parseCoreResults(response.data, function(m) {
|
|
237
|
-
displayResults(
|
|
238
|
-
}, function(e) {})
|
|
239
|
-
}, function(response) {
|
|
233
|
+
http.post(ENCRYPTED_RESULT_SERVICE, JSON.stringify(body), { "content-type": "application/json; utf-8" }, function (response) {
|
|
234
|
+
DocumentReader.parseCoreResults(response.data, function (m) {
|
|
235
|
+
displayResults(DocumentReaderResults.fromJson(JSON.parse(m)))
|
|
236
|
+
}, function (e) { })
|
|
237
|
+
}, function (response) {
|
|
240
238
|
console.error(response.error)
|
|
241
239
|
document.getElementById("status").innerHTML = "Something went wrong!"
|
|
242
240
|
document.getElementById("status").style.backgroundColor = "red"
|
|
@@ -259,8 +257,8 @@ var app = {
|
|
|
259
257
|
}
|
|
260
258
|
|
|
261
259
|
function addCertificates() {
|
|
262
|
-
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/certificates/", function(fileSystem) {
|
|
263
|
-
fileSystem.createReader().readEntries(function(entries) {
|
|
260
|
+
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/certificates/", function (fileSystem) {
|
|
261
|
+
fileSystem.createReader().readEntries(function (entries) {
|
|
264
262
|
for (var i in entries) {
|
|
265
263
|
var item = entries[i]
|
|
266
264
|
if (item.isFile) {
|
|
@@ -268,44 +266,47 @@ var app = {
|
|
|
268
266
|
var pkdResourceType = 0
|
|
269
267
|
if (findExt.length > 0)
|
|
270
268
|
pkdResourceType = Enum.PKDResourceType.getType(findExt[findExt.length - 1].toLowerCase())
|
|
271
|
-
readFile("www/certificates/" + item.name, function(file, resType) {
|
|
269
|
+
readFile("www/certificates/" + item.name, function (file, resType) {
|
|
272
270
|
resType = resType[0]
|
|
273
271
|
var certificates = []
|
|
274
272
|
certificates.push({
|
|
275
273
|
'binaryData': file,
|
|
276
274
|
'resourceType': resType
|
|
277
275
|
})
|
|
278
|
-
DocumentReader.addPKDCertificates(certificates, function(s) {
|
|
276
|
+
DocumentReader.addPKDCertificates(certificates, function (s) {
|
|
279
277
|
console.log("certificate added")
|
|
280
|
-
}, function(e) { console.log(e) })
|
|
278
|
+
}, function (e) { console.log(e) })
|
|
281
279
|
}, pkdResourceType)
|
|
282
280
|
}
|
|
283
281
|
}
|
|
284
|
-
}, function(err) { console.log(err) })
|
|
285
|
-
}, function(err) { console.log(err) })
|
|
282
|
+
}, function (err) { console.log(err) })
|
|
283
|
+
}, function (err) { console.log(err) })
|
|
286
284
|
}
|
|
287
285
|
|
|
288
286
|
function readFile(path, callback, ...items) {
|
|
289
287
|
if (path.substring(0, 8) !== "file:///")
|
|
290
288
|
path = cordova.file.applicationDirectory + path
|
|
291
|
-
window.resolveLocalFileSystemURL(path, function(fileEntry) {
|
|
292
|
-
fileEntry.file(function(file) {
|
|
289
|
+
window.resolveLocalFileSystemURL(path, function (fileEntry) {
|
|
290
|
+
fileEntry.file(function (file) {
|
|
293
291
|
var reader = new FileReader()
|
|
294
|
-
reader.onloadend = function(e) {
|
|
292
|
+
reader.onloadend = function (e) {
|
|
295
293
|
callback(this.result.substring(this.result.indexOf(',') + 1), items)
|
|
296
294
|
}
|
|
297
295
|
reader.readAsDataURL(file)
|
|
298
296
|
})
|
|
299
|
-
}, function(e) { console.log(JSON.stringify(e)) })
|
|
297
|
+
}, function (e) { console.log(JSON.stringify(e)) })
|
|
300
298
|
}
|
|
301
299
|
|
|
302
|
-
readFile("www/regula.license", function(license) {
|
|
303
|
-
DocumentReader.prepareDatabase("Full", function(message) {
|
|
300
|
+
readFile("www/regula.license", function (license) {
|
|
301
|
+
DocumentReader.prepareDatabase("Full", function (message) {
|
|
304
302
|
if (message != "database prepared")
|
|
305
303
|
document.getElementById("status").innerHTML = "Downloading database: " + message + "%"
|
|
306
304
|
else {
|
|
307
305
|
document.getElementById("status").innerHTML = "Loading......"
|
|
308
|
-
DocumentReader.initializeReader(
|
|
306
|
+
DocumentReader.initializeReader({
|
|
307
|
+
license: license,
|
|
308
|
+
delayedNNLoad: true
|
|
309
|
+
}, function (message) {
|
|
309
310
|
document.getElementById("status").innerHTML = "Ready"
|
|
310
311
|
document.getElementById("status").style.backgroundColor = "green"
|
|
311
312
|
document.getElementById("showScannerButton").addEventListener("click", scan)
|
|
@@ -326,23 +327,23 @@ var app = {
|
|
|
326
327
|
scenario: "Mrz",
|
|
327
328
|
doRfid: false,
|
|
328
329
|
},
|
|
329
|
-
}, function(m) {}, function(e) {})
|
|
330
|
-
DocumentReader.getAvailableScenarios(function(s) {
|
|
331
|
-
DocumentReader.isRFIDAvailableForUse(function(r) { postInitialize(JSON.parse(s), r) }, function(e) {})
|
|
332
|
-
}, function(e) {})
|
|
333
|
-
DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA, function(r) {}, function(e) {})
|
|
334
|
-
|
|
335
|
-
}, function(error) {
|
|
330
|
+
}, function (m) { }, function (e) { })
|
|
331
|
+
DocumentReader.getAvailableScenarios(function (s) {
|
|
332
|
+
DocumentReader.isRFIDAvailableForUse(function (r) { postInitialize(JSON.parse(s), r) }, function (e) { })
|
|
333
|
+
}, function (e) { })
|
|
334
|
+
DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA, function (r) { }, function (e) { })
|
|
335
|
+
// addCertificates()
|
|
336
|
+
}, function (error) {
|
|
336
337
|
console.log(error)
|
|
337
338
|
document.getElementById("status").innerHTML = error
|
|
338
339
|
document.getElementById("status").style.backgroundColor = "red"
|
|
339
340
|
})
|
|
340
341
|
}
|
|
341
|
-
}, function(e) { console.log(e) })
|
|
342
|
+
}, function (e) { console.log(e) })
|
|
342
343
|
})
|
|
343
344
|
},
|
|
344
345
|
|
|
345
|
-
receivedEvent: function(id) {
|
|
346
|
+
receivedEvent: function (id) {
|
|
346
347
|
var parentElement = document.getElementById(id)
|
|
347
348
|
var listeningElement = parentElement.querySelector('.listening')
|
|
348
349
|
var receivedElement = parentElement.querySelector('.received')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/cordova-plugin-document-reader-api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "Cordova plugin for reading and validation of identification documents (API framework)",
|
|
5
5
|
"cordova": {
|
|
6
6
|
"id": "@regulaforensics/cordova-plugin-document-reader-api",
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="cordova-plugin-document-reader-api" version="6.
|
|
2
|
+
<plugin id="cordova-plugin-document-reader-api" version="6.5.0"
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0">
|
|
4
4
|
<name>DocumentReaderApi</name>
|
|
5
5
|
<description>Cordova plugin Document reader api</description>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<podspec>
|
|
26
26
|
<config/>
|
|
27
27
|
<pods>
|
|
28
|
-
<pod name="DocumentReader" spec="~> 6.
|
|
28
|
+
<pod name="DocumentReader" spec="~> 6.5.2633" />
|
|
29
29
|
</pods>
|
|
30
30
|
</podspec>
|
|
31
31
|
</platform>
|
|
@@ -25,12 +25,12 @@ import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
|
25
25
|
import com.regula.documentreader.api.internal.core.CoreScenarioUtil;
|
|
26
26
|
import com.regula.documentreader.api.params.DocReaderConfig;
|
|
27
27
|
import com.regula.documentreader.api.params.ImageInputData;
|
|
28
|
-
import com.regula.documentreader.api.params.ImageInputParam;
|
|
28
|
+
import com.regula.documentreader.api.internal.params.ImageInputParam;
|
|
29
29
|
import com.regula.documentreader.api.params.rfid.PKDCertificate;
|
|
30
30
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
31
31
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
32
32
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
33
|
-
import com.regula.documentreader.api.parser.DocReaderResultsJsonParser;
|
|
33
|
+
import com.regula.documentreader.api.internal.parser.DocReaderResultsJsonParser;
|
|
34
34
|
|
|
35
35
|
import org.apache.cordova.CallbackContext;
|
|
36
36
|
import org.apache.cordova.CordovaPlugin;
|
|
@@ -315,6 +315,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
315
315
|
case "recognizeImage":
|
|
316
316
|
recognizeImage(callback, args(0));
|
|
317
317
|
break;
|
|
318
|
+
case "recognizeData":
|
|
319
|
+
recognizeData(callback, args(0));
|
|
320
|
+
break;
|
|
318
321
|
case "setRfidSessionStatus":
|
|
319
322
|
setRfidSessionStatus(callback, args(0));
|
|
320
323
|
break;
|
|
@@ -333,9 +336,6 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
333
336
|
case "setTCCParams":
|
|
334
337
|
setTCCParams(callback, args(0));
|
|
335
338
|
break;
|
|
336
|
-
case "initializeReaderWithDatabase":
|
|
337
|
-
initializeReaderWithDatabase(callback, args(0), args(1));
|
|
338
|
-
break;
|
|
339
339
|
case "recognizeImageWithOpts":
|
|
340
340
|
recognizeImageWithOpts(callback, args(0), args(1));
|
|
341
341
|
break;
|
|
@@ -500,16 +500,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
500
500
|
callback.success(Instance().isRFIDAvailableForUse());
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
private void initializeReader(Callback callback,
|
|
504
|
-
if (!Instance().isReady())
|
|
505
|
-
Instance().initializeReader(getContext(), new DocReaderConfig(Base64.decode(license.toString(), Base64.DEFAULT)), getInitCompletion(callback));
|
|
506
|
-
else
|
|
507
|
-
callback.success("already initialized");
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
private void initializeReaderWithDatabase(Callback callback, Object license, Object db) {
|
|
503
|
+
private void initializeReader(Callback callback, JSONObject config) {
|
|
511
504
|
if (!Instance().isReady())
|
|
512
|
-
Instance().initializeReader(getContext(),
|
|
505
|
+
Instance().initializeReader(getContext(), JSONConstructor.DocReaderConfigFromJSON(config), getInitCompletion(callback));
|
|
513
506
|
else
|
|
514
507
|
callback.success("already initialized");
|
|
515
508
|
}
|
|
@@ -534,6 +527,11 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
534
527
|
Instance().recognizeImage(Helpers.bitmapFromBase64(base64Image), getCompletion());
|
|
535
528
|
}
|
|
536
529
|
|
|
530
|
+
private void recognizeData(@SuppressWarnings("unused") Callback callback, Object data) {
|
|
531
|
+
stopBackgroundRFID();
|
|
532
|
+
Instance().recognizeImage(Base64.decode(data.toString(), Base64.DEFAULT), getCompletion());
|
|
533
|
+
}
|
|
534
|
+
|
|
537
535
|
private void recognizeImages(@SuppressWarnings("unused") Callback callback, JSONArray base64Images) throws JSONException {
|
|
538
536
|
stopBackgroundRFID();
|
|
539
537
|
Bitmap[] images = new Bitmap[base64Images.length()];
|
package/src/android/Helpers.java
CHANGED
|
@@ -10,7 +10,7 @@ import android.graphics.drawable.Drawable;
|
|
|
10
10
|
import android.util.Base64;
|
|
11
11
|
|
|
12
12
|
import com.regula.documentreader.api.enums.BarcodeType;
|
|
13
|
-
import com.regula.documentreader.api.params.FaceMetaData;
|
|
13
|
+
import com.regula.documentreader.api.internal.params.FaceMetaData;
|
|
14
14
|
import com.regula.documentreader.api.results.Bounds;
|
|
15
15
|
|
|
16
16
|
import org.json.JSONArray;
|
|
@@ -15,7 +15,8 @@ import com.regula.documentreader.api.enums.eGraphicFieldType;
|
|
|
15
15
|
import com.regula.documentreader.api.enums.eRPRM_Lights;
|
|
16
16
|
import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
17
17
|
import com.regula.documentreader.api.internal.core.CoreDetailedScenario;
|
|
18
|
-
import com.regula.documentreader.api.params.
|
|
18
|
+
import com.regula.documentreader.api.params.DocReaderConfig;
|
|
19
|
+
import com.regula.documentreader.api.internal.params.FaceMetaData;
|
|
19
20
|
import com.regula.documentreader.api.params.ImageInputData;
|
|
20
21
|
import com.regula.documentreader.api.params.rfid.TccParams;
|
|
21
22
|
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute;
|
|
@@ -56,7 +57,6 @@ import com.regula.documentreader.api.results.rfid.Extension;
|
|
|
56
57
|
import com.regula.documentreader.api.results.rfid.File;
|
|
57
58
|
import com.regula.documentreader.api.results.rfid.FileData;
|
|
58
59
|
import com.regula.documentreader.api.results.rfid.RFIDSessionData;
|
|
59
|
-
import com.regula.documentreader.api.results.rfid.RFIDSessionDataStatus;
|
|
60
60
|
import com.regula.documentreader.api.results.rfid.SecurityObject;
|
|
61
61
|
import com.regula.documentreader.api.results.rfid.SecurityObjectCertificates;
|
|
62
62
|
import com.regula.documentreader.api.results.rfid.SignerInfo;
|
|
@@ -361,6 +361,28 @@ class JSONConstructor {
|
|
|
361
361
|
return result;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
static DocReaderConfig DocReaderConfigFromJSON(JSONObject input) {
|
|
365
|
+
DocReaderConfig result = new DocReaderConfig(null);
|
|
366
|
+
byte[] license;
|
|
367
|
+
try {
|
|
368
|
+
if (input.has("license")) {
|
|
369
|
+
license = Base64.decode(input.getString("license"), Base64.DEFAULT);
|
|
370
|
+
result = new DocReaderConfig(license);
|
|
371
|
+
} else return result;
|
|
372
|
+
if (input.has("customDb"))
|
|
373
|
+
result = new DocReaderConfig(license, Base64.decode(input.getString("customDb"), Base64.DEFAULT));
|
|
374
|
+
if (input.has("licenseUpdate"))
|
|
375
|
+
result.setLicenseUpdate(input.getBoolean("licenseUpdate"));
|
|
376
|
+
if (input.has("delayedNNLoad"))
|
|
377
|
+
result.setDelayedNNLoad(input.getBoolean("delayedNNLoad"));
|
|
378
|
+
if (input.has("blackList"))
|
|
379
|
+
result.setBlackList(input.getJSONObject("blackList"));
|
|
380
|
+
} catch (JSONException e) {
|
|
381
|
+
e.printStackTrace();
|
|
382
|
+
}
|
|
383
|
+
return result;
|
|
384
|
+
}
|
|
385
|
+
|
|
364
386
|
static ImageInputData ImageInputDataFromJSON(JSONObject input) {
|
|
365
387
|
ImageInputData result = new ImageInputData(null);
|
|
366
388
|
int pageIndex = 0;
|
|
@@ -920,7 +942,6 @@ class JSONConstructor {
|
|
|
920
942
|
result.put("extLeSupport", input.extLeSupport);
|
|
921
943
|
result.put("processTime", input.processTime);
|
|
922
944
|
result.put("cardProperties", generateCardProperties(input.cardProperties));
|
|
923
|
-
result.put("sessionDataStatus", generateRFIDSessionDataStatus(input.sessionDataStatus));
|
|
924
945
|
result.put("accessControls", generateList(input.accessControls, JSONConstructor::generateAccessControlProcedureType));
|
|
925
946
|
result.put("applications", generateList(input.applications, JSONConstructor::generateApplication));
|
|
926
947
|
result.put("securityObjects", generateList(input.securityObjects, JSONConstructor::generateSecurityObject));
|
|
@@ -958,23 +979,6 @@ class JSONConstructor {
|
|
|
958
979
|
return result;
|
|
959
980
|
}
|
|
960
981
|
|
|
961
|
-
static JSONObject generateRFIDSessionDataStatus(RFIDSessionDataStatus input) {
|
|
962
|
-
JSONObject result = new JSONObject();
|
|
963
|
-
if (input == null) return result;
|
|
964
|
-
try {
|
|
965
|
-
result.put("AA", input.AA);
|
|
966
|
-
result.put("BAC", input.BAC);
|
|
967
|
-
result.put("CA", input.CA);
|
|
968
|
-
result.put("PA", input.PA);
|
|
969
|
-
result.put("PACE", input.PACE);
|
|
970
|
-
result.put("TA", input.TA);
|
|
971
|
-
result.put("overallStatus", input.overallStatus);
|
|
972
|
-
} catch (JSONException e) {
|
|
973
|
-
e.printStackTrace();
|
|
974
|
-
}
|
|
975
|
-
return result;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
982
|
static JSONObject generateDocumentReaderBarcodeResult(DocumentReaderBarcodeResult input) {
|
|
979
983
|
JSONObject result = new JSONObject();
|
|
980
984
|
if (input == null) return result;
|
|
@@ -1243,7 +1247,6 @@ class JSONConstructor {
|
|
|
1243
1247
|
if (input == null) return result;
|
|
1244
1248
|
try {
|
|
1245
1249
|
result.put("chipPage", input.chipPage);
|
|
1246
|
-
result.put("overallResult", input.getOverallResult());
|
|
1247
1250
|
result.put("processingFinishedStatus", input.processingFinishedStatus);
|
|
1248
1251
|
result.put("elapsedTime", input.elapsedTime);
|
|
1249
1252
|
result.put("elapsedTimeRFID", input.elapsedTimeRFID);
|
|
@@ -2038,8 +2041,6 @@ class JSONConstructor {
|
|
|
2038
2041
|
result.processTime = input.getInt("processTime");
|
|
2039
2042
|
if (input.has("cardProperties"))
|
|
2040
2043
|
result.cardProperties = CardPropertiesFromJSON(input.getJSONObject("cardProperties"));
|
|
2041
|
-
if (input.has("sessionDataStatus"))
|
|
2042
|
-
result.sessionDataStatus = RFIDSessionDataStatusFromJSON(input.getJSONObject("sessionDataStatus"));
|
|
2043
2044
|
if (input.has("accessControls")){
|
|
2044
2045
|
JSONArray jsonArray_accessControls = input.getJSONArray("accessControls");
|
|
2045
2046
|
List<AccessControlProcedureType> accessControls = new ArrayList<>();
|
|
@@ -2105,30 +2106,6 @@ class JSONConstructor {
|
|
|
2105
2106
|
return null;
|
|
2106
2107
|
}
|
|
2107
2108
|
|
|
2108
|
-
static RFIDSessionDataStatus RFIDSessionDataStatusFromJSON(JSONObject input) {
|
|
2109
|
-
try {
|
|
2110
|
-
RFIDSessionDataStatus result = new RFIDSessionDataStatus();
|
|
2111
|
-
if (input.has("AA"))
|
|
2112
|
-
result.AA = input.getInt("AA");
|
|
2113
|
-
if (input.has("BAC"))
|
|
2114
|
-
result.BAC = input.getInt("BAC");
|
|
2115
|
-
if (input.has("CA"))
|
|
2116
|
-
result.CA = input.getInt("CA");
|
|
2117
|
-
if (input.has("PA"))
|
|
2118
|
-
result.PA = input.getInt("PA");
|
|
2119
|
-
if (input.has("PACE"))
|
|
2120
|
-
result.PACE = input.getInt("PACE");
|
|
2121
|
-
if (input.has("TA"))
|
|
2122
|
-
result.TA = input.getInt("TA");
|
|
2123
|
-
if (input.has("overallStatus"))
|
|
2124
|
-
result.overallStatus = input.getInt("overallStatus");
|
|
2125
|
-
return result;
|
|
2126
|
-
} catch (JSONException e) {
|
|
2127
|
-
e.printStackTrace();
|
|
2128
|
-
}
|
|
2129
|
-
return null;
|
|
2130
|
-
}
|
|
2131
|
-
|
|
2132
2109
|
static DocumentReaderBarcodeResult DocumentReaderBarcodeResultFromJSON(JSONObject input) {
|
|
2133
2110
|
try {
|
|
2134
2111
|
DocumentReaderBarcodeResult result = new DocumentReaderBarcodeResult();
|