@regulaforensics/cordova-plugin-document-reader-api 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/README.md +0 -2
- 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 +32 -29
- package/src/android/Helpers.java +1 -1
- package/src/android/JSONConstructor.java +78 -47
- package/src/android/RegulaConfig.java +52 -6
- package/src/android/build.gradle +1 -1
- package/src/ios/RGLDocumentReader.m +25 -18
- package/src/ios/RGLWJSONConstructor.h +2 -0
- package/src/ios/RGLWJSONConstructor.m +68 -6
- package/src/ios/RegulaConfig.m +40 -6
- package/tmp.64209.json +30 -0
- package/www/DocumentReader.js +3169 -3044
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: "[BR] "
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Before Submitting, be sure to**
|
|
11
|
+
- [ ] Update to the latest stable version.
|
|
12
|
+
- [ ] Read and follow the guides described in the [documentation](https://docs.regulaforensics.com?utm_source=github).
|
|
13
|
+
- [ ] Try to reproduce in our demo project.
|
|
14
|
+
- [ ] Search for your issue in the existing GitHub issues.
|
|
15
|
+
|
|
16
|
+
**Bug Description**
|
|
17
|
+
<!--A clear and concise description of what the bug is.-->
|
|
18
|
+
|
|
19
|
+
**Steps To Reproduce**
|
|
20
|
+
<!--
|
|
21
|
+
1. Go to '...'
|
|
22
|
+
2. Click on '....'
|
|
23
|
+
3. Scroll down to '....'
|
|
24
|
+
4. See error
|
|
25
|
+
-->
|
|
26
|
+
|
|
27
|
+
**Expected behavior**
|
|
28
|
+
<!--A clear and concise description of what you expected to happen.-->
|
|
29
|
+
|
|
30
|
+
**Screenshots**
|
|
31
|
+
<!--If applicable, add screenshots to help explain your issue.-->
|
|
32
|
+
|
|
33
|
+
**Environment:**
|
|
34
|
+
- Device: <!--[e.g. iPhone 12]-->
|
|
35
|
+
- OS: <!--[e.g. iOS]-->
|
|
36
|
+
- OS version: <!--[e.g. 10.0]-->
|
|
37
|
+
|
|
38
|
+
**Additional context**
|
|
39
|
+
<!--Add any other context about the problem here.-->
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature Request
|
|
3
|
+
about: Suggest an idea for this product
|
|
4
|
+
title: "[FR] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
<!--A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]-->
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
<!--A clear and concise description of what you want to happen.-->
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
<!--A clear and concise description of any alternative solutions or features you've considered.-->
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
<!--Add any other context or screenshots about the feature request here.-->
|
package/README.md
CHANGED
|
@@ -23,7 +23,6 @@ $ cordova prepare
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
4. Copy the `regula.license` file to the `example/www` folder.
|
|
26
|
-
5. Change the application ID to the one you have specified during the registration at [client.regulaforensics.com](https://client.regulaforensics.com).
|
|
27
26
|
6. Android:
|
|
28
27
|
* Run `cordova run android` inside `example` folder - this is just one way to run the app. You can also run it directly from within Android Studio.
|
|
29
28
|
|
|
@@ -36,7 +35,6 @@ $ cordova prepare
|
|
|
36
35
|
### Troubleshooting license issues
|
|
37
36
|
If you have issues with license verification when running the application, please verify that next is true:
|
|
38
37
|
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
|
|
39
|
-
2. The application (Bundle) ID, which you use, is specified in the license.
|
|
40
38
|
3. The license is valid (not expired).
|
|
41
39
|
4. The date and time on the device, where you run the application, are valid.
|
|
42
40
|
5. You use the latest release version of the Document Reader SDK.
|
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>
|
|
@@ -9,7 +9,7 @@ import android.content.IntentFilter;
|
|
|
9
9
|
import android.graphics.Bitmap;
|
|
10
10
|
import android.nfc.NfcAdapter;
|
|
11
11
|
import android.nfc.tech.IsoDep;
|
|
12
|
-
import
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
13
13
|
import android.os.Bundle;
|
|
14
14
|
import android.util.Base64;
|
|
15
15
|
|
|
@@ -24,12 +24,13 @@ import com.regula.documentreader.api.enums.DocReaderAction;
|
|
|
24
24
|
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
|
-
import com.regula.documentreader.api.params.
|
|
27
|
+
import com.regula.documentreader.api.params.ImageInputData;
|
|
28
|
+
import com.regula.documentreader.api.internal.params.ImageInputParam;
|
|
28
29
|
import com.regula.documentreader.api.params.rfid.PKDCertificate;
|
|
29
30
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
30
31
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
31
32
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
32
|
-
import com.regula.documentreader.api.parser.DocReaderResultsJsonParser;
|
|
33
|
+
import com.regula.documentreader.api.internal.parser.DocReaderResultsJsonParser;
|
|
33
34
|
|
|
34
35
|
import org.apache.cordova.CallbackContext;
|
|
35
36
|
import org.apache.cordova.CordovaPlugin;
|
|
@@ -227,6 +228,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
227
228
|
case "stopRFIDReader":
|
|
228
229
|
stopRFIDReader(callback);
|
|
229
230
|
break;
|
|
231
|
+
case "stopRFIDReaderWithErrorMessage":
|
|
232
|
+
stopRFIDReaderWithErrorMessage(callback, args(0));
|
|
233
|
+
break;
|
|
230
234
|
case "stopScanner":
|
|
231
235
|
stopScanner(callback);
|
|
232
236
|
break;
|
|
@@ -311,6 +315,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
311
315
|
case "recognizeImage":
|
|
312
316
|
recognizeImage(callback, args(0));
|
|
313
317
|
break;
|
|
318
|
+
case "recognizeData":
|
|
319
|
+
recognizeData(callback, args(0));
|
|
320
|
+
break;
|
|
314
321
|
case "setRfidSessionStatus":
|
|
315
322
|
setRfidSessionStatus(callback, args(0));
|
|
316
323
|
break;
|
|
@@ -329,12 +336,6 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
329
336
|
case "setTCCParams":
|
|
330
337
|
setTCCParams(callback, args(0));
|
|
331
338
|
break;
|
|
332
|
-
case "initializeReaderWithDatabase":
|
|
333
|
-
initializeReaderWithDatabase(callback, args(0), args(1));
|
|
334
|
-
break;
|
|
335
|
-
case "recognizeImageFrame":
|
|
336
|
-
recognizeImageFrame(callback, args(0), args(1));
|
|
337
|
-
break;
|
|
338
339
|
case "recognizeImageWithOpts":
|
|
339
340
|
recognizeImageWithOpts(callback, args(0), args(1));
|
|
340
341
|
break;
|
|
@@ -344,12 +345,12 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
344
345
|
case "showScannerWithCameraIDAndOpts":
|
|
345
346
|
showScannerWithCameraIDAndOpts(callback, args(0), args(1));
|
|
346
347
|
break;
|
|
347
|
-
case "recognizeImageWithImageInputParams":
|
|
348
|
-
recognizeImageWithImageInputParams(callback, args(0), args(1));
|
|
349
|
-
break;
|
|
350
348
|
case "recognizeImageWithCameraMode":
|
|
351
349
|
recognizeImageWithCameraMode(callback, args(0), args(1));
|
|
352
350
|
break;
|
|
351
|
+
case "recognizeImagesWithImageInputs":
|
|
352
|
+
recognizeImagesWithImageInputs(callback, args(0));
|
|
353
|
+
break;
|
|
353
354
|
}
|
|
354
355
|
} catch (Exception ignored) {
|
|
355
356
|
}
|
|
@@ -499,16 +500,9 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
499
500
|
callback.success(Instance().isRFIDAvailableForUse());
|
|
500
501
|
}
|
|
501
502
|
|
|
502
|
-
private void initializeReader(Callback callback,
|
|
503
|
+
private void initializeReader(Callback callback, JSONObject config) {
|
|
503
504
|
if (!Instance().isReady())
|
|
504
|
-
Instance().initializeReader(getContext(),
|
|
505
|
-
else
|
|
506
|
-
callback.success("already initialized");
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
private void initializeReaderWithDatabase(Callback callback, Object license, Object db) {
|
|
510
|
-
if (!Instance().isReady())
|
|
511
|
-
Instance().initializeReader(getContext(), new DocReaderConfig(Base64.decode(license.toString(), Base64.DEFAULT), Base64.decode(db.toString(), Base64.DEFAULT)), getInitCompletion(callback));
|
|
505
|
+
Instance().initializeReader(getContext(), JSONConstructor.DocReaderConfigFromJSON(config), getInitCompletion(callback));
|
|
512
506
|
else
|
|
513
507
|
callback.success("already initialized");
|
|
514
508
|
}
|
|
@@ -523,10 +517,6 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
523
517
|
callback.success();
|
|
524
518
|
}
|
|
525
519
|
|
|
526
|
-
private void recognizeImageWithImageInputParams(@SuppressWarnings("unused") Callback callback, String base64Image, final JSONObject params) throws JSONException {
|
|
527
|
-
Instance().recognizeImage(Helpers.bitmapFromBase64(base64Image), new ImageInputParam(params.getInt("width"), params.getInt("height"), params.getInt("type")), getCompletion());
|
|
528
|
-
}
|
|
529
|
-
|
|
530
520
|
private void recognizeImageWithOpts(Callback callback, String base64Image, final JSONObject opts) throws JSONException {
|
|
531
521
|
RegulaConfig.setConfig(Instance(), opts, getContext());
|
|
532
522
|
recognizeImage(callback, base64Image);
|
|
@@ -537,6 +527,11 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
537
527
|
Instance().recognizeImage(Helpers.bitmapFromBase64(base64Image), getCompletion());
|
|
538
528
|
}
|
|
539
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
|
+
|
|
540
535
|
private void recognizeImages(@SuppressWarnings("unused") Callback callback, JSONArray base64Images) throws JSONException {
|
|
541
536
|
stopBackgroundRFID();
|
|
542
537
|
Bitmap[] images = new Bitmap[base64Images.length()];
|
|
@@ -545,6 +540,14 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
545
540
|
Instance().recognizeImages(images, getCompletion());
|
|
546
541
|
}
|
|
547
542
|
|
|
543
|
+
private void recognizeImagesWithImageInputs(@SuppressWarnings("unused") Callback callback, JSONArray base64Images) throws JSONException {
|
|
544
|
+
stopBackgroundRFID();
|
|
545
|
+
ImageInputData[] images = new ImageInputData[base64Images.length()];
|
|
546
|
+
for (int i = 0; i < images.length; i++)
|
|
547
|
+
images[i] = JSONConstructor.ImageInputDataFromJSON(base64Images.getJSONObject(i));
|
|
548
|
+
Instance().recognizeImages(images, getCompletion());
|
|
549
|
+
}
|
|
550
|
+
|
|
548
551
|
private void removeDatabase(Callback callback) {
|
|
549
552
|
callback.success(Instance().removeDatabase(getContext()));
|
|
550
553
|
}
|
|
@@ -578,10 +581,6 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
578
581
|
callback.success();
|
|
579
582
|
}
|
|
580
583
|
|
|
581
|
-
private void recognizeImageFrame(@SuppressWarnings("unused") Callback callback, String base64Image, final JSONObject opts) throws JSONException {
|
|
582
|
-
Instance().recognizeImageFrame(Helpers.bitmapFromBase64(base64Image), new ImageInputParam(opts.getInt("width"), opts.getInt("height"), opts.getInt("type")), getCompletion());
|
|
583
|
-
}
|
|
584
|
-
|
|
585
584
|
private void recognizeVideoFrame(@SuppressWarnings("unused") Callback callback, String byteString, final JSONObject opts) throws JSONException {
|
|
586
585
|
stopBackgroundRFID();
|
|
587
586
|
Instance().recognizeVideoFrame(byteString.getBytes(), new ImageInputParam(opts.getInt("width"), opts.getInt("height"), opts.getInt("type")), getCompletion());
|
|
@@ -700,6 +699,10 @@ public class DocumentReader extends CordovaPlugin {
|
|
|
700
699
|
callback.error("getCameraSessionIsPaused() is an ios-only method");
|
|
701
700
|
}
|
|
702
701
|
|
|
702
|
+
private void stopRFIDReaderWithErrorMessage(Callback callback, String message) {
|
|
703
|
+
callback.error("stopRFIDReaderWithErrorMessage() is an ios-only method");
|
|
704
|
+
}
|
|
705
|
+
|
|
703
706
|
@SuppressWarnings("unused")
|
|
704
707
|
private void recognizeImageWithCameraMode(Callback callback, String base64, boolean mode) {
|
|
705
708
|
callback.error("recognizeImageWithCameraMode() is an ios-only method");
|
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;
|