@regulaforensics/cordova-plugin-document-reader-api 7.5.649-nightly → 7.5.652-nightly
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 +4 -4
- package/package.json +1 -1
- package/plugin.xml +6 -4
- package/src/android/BluetoothUtil.kt +95 -45
- package/src/android/Config.kt +43 -2
- package/src/android/DocumentReader.kt +36 -21
- package/src/android/JSONConstructor.kt +27 -13
- package/src/android/Utils.kt +7 -2
- package/src/android/build.gradle +1 -3
- package/src/ios/RGLWConfig.m +45 -0
- package/src/ios/RGLWDocumentReader.h +4 -1
- package/src/ios/RGLWDocumentReader.m +71 -21
- package/src/ios/RGLWJSONConstructor.h +3 -0
- package/src/ios/RGLWJSONConstructor.m +33 -2
- package/www/DocumentReader.js +81 -3
package/example/package.json
CHANGED
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"author": "Regula Forensics Inc.",
|
|
14
14
|
"license": "commercial",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@regulaforensics/cordova-plugin-document-reader-api": "7.5.
|
|
17
|
-
"@regulaforensics/cordova-plugin-document-reader-core-fullauthrfid": "7.5.
|
|
18
|
-
"cordova-android": "
|
|
19
|
-
"cordova-ios": "7.
|
|
16
|
+
"@regulaforensics/cordova-plugin-document-reader-api": "7.5.652-nightly",
|
|
17
|
+
"@regulaforensics/cordova-plugin-document-reader-core-fullauthrfid": "7.5.773-nightly",
|
|
18
|
+
"cordova-android": "13.0.0",
|
|
19
|
+
"cordova-ios": "7.1.1",
|
|
20
20
|
"cordova-plugin-add-swift-support": "2.0.2",
|
|
21
21
|
"cordova-plugin-advanced-http": "3.3.1",
|
|
22
22
|
"cordova-plugin-camera": "7.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/cordova-plugin-document-reader-api",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.652-nightly",
|
|
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="7.5.
|
|
2
|
+
<plugin id="cordova-plugin-document-reader-api" version="7.5.652-nightly"
|
|
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>
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<feature name="DocumentReader">
|
|
16
16
|
<param name="ios-package" value="RGLWDocumentReader" />
|
|
17
17
|
</feature>
|
|
18
|
+
<preference name="deployment-target" value="12.0" />
|
|
18
19
|
</config-file>
|
|
19
20
|
<header-file src="src/ios/RGLWDocumentReader.h" />
|
|
20
21
|
<source-file src="src/ios/RGLWDocumentReader.m" />
|
|
@@ -23,16 +24,17 @@
|
|
|
23
24
|
<header-file src="src/ios/RGLWConfig.h" />
|
|
24
25
|
<source-file src="src/ios/RGLWConfig.m" />
|
|
25
26
|
<podspec>
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
<config>
|
|
28
|
+
</config>
|
|
28
29
|
<pods>
|
|
29
|
-
<pod name="DocumentReaderNightly" spec="7.5.
|
|
30
|
+
<pod name="DocumentReaderNightly" spec="7.5.4172" />
|
|
30
31
|
</pods>
|
|
31
32
|
</podspec>
|
|
32
33
|
</platform>
|
|
33
34
|
|
|
34
35
|
<platform name="android">
|
|
35
36
|
<config-file parent="/*" target="res/xml/config.xml">
|
|
37
|
+
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
36
38
|
<feature name="DocumentReader">
|
|
37
39
|
<param name="android-package" value="cordova.plugin.documentreader.DocumentReader" />
|
|
38
40
|
</feature>
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
// Created by Pavel Masiuk on 21.09.2023.
|
|
6
6
|
// Copyright © 2023 Regula. All rights reserved.
|
|
7
7
|
//
|
|
8
|
+
@file:SuppressLint("MissingPermission")
|
|
8
9
|
|
|
9
10
|
package cordova.plugin.documentreader
|
|
10
11
|
|
|
11
|
-
import android.Manifest.permission
|
|
12
|
+
import android.Manifest.permission.ACCESS_FINE_LOCATION
|
|
13
|
+
import android.Manifest.permission.BLUETOOTH_CONNECT
|
|
14
|
+
import android.Manifest.permission.BLUETOOTH_SCAN
|
|
12
15
|
import android.annotation.SuppressLint
|
|
13
16
|
import android.app.Activity
|
|
14
17
|
import android.bluetooth.BluetoothAdapter
|
|
@@ -19,7 +22,6 @@ import android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
|
19
22
|
import android.os.Build
|
|
20
23
|
import android.os.IBinder
|
|
21
24
|
import android.provider.Settings
|
|
22
|
-
import androidx.annotation.RequiresPermission
|
|
23
25
|
import androidx.core.app.ActivityCompat.requestPermissions
|
|
24
26
|
import androidx.core.content.ContextCompat.checkSelfPermission
|
|
25
27
|
import com.regula.documentreader.api.ble.BLEWrapper
|
|
@@ -28,37 +30,103 @@ import com.regula.documentreader.api.ble.RegulaBleService
|
|
|
28
30
|
import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelper.BLE_ACCESS_PERMISSION
|
|
29
31
|
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
|
|
30
32
|
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
|
|
33
|
+
import java.util.Timer
|
|
34
|
+
import java.util.TimerTask
|
|
31
35
|
|
|
32
|
-
const val
|
|
33
|
-
|
|
36
|
+
const val SEARCHING_TIMEOUT: Long = 7000
|
|
37
|
+
|
|
38
|
+
const val INTENT_REQUEST_ENABLE_LOCATION = 196
|
|
39
|
+
const val INTENT_REQUEST_ENABLE_BLUETOOTH = 197
|
|
34
40
|
|
|
35
41
|
@SuppressLint("StaticFieldLeak")
|
|
36
|
-
var
|
|
42
|
+
lateinit var bluetooth: BLEWrapper
|
|
43
|
+
lateinit var savedCallbackForPermissionResult: Callback
|
|
44
|
+
var deviceConnected = false
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
fun connectBluetoothDevice(callback: Callback) {
|
|
47
|
+
// return if already connected
|
|
48
|
+
if (deviceConnected) return
|
|
49
|
+
|
|
50
|
+
// If some of the bluetooth permissions/settings don't match the requirements,
|
|
51
|
+
// save callback for later and request the permissions/settings.
|
|
52
|
+
// Callback will then be used in onRequestPermissionsResult for permission requests
|
|
53
|
+
// and in onActivityResult for settings change requests.
|
|
54
|
+
if (!isBluetoothSettingsReady(activity)) {
|
|
55
|
+
savedCallbackForPermissionResult = callback
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// set searching timeout
|
|
60
|
+
val timer = object : TimerTask() {
|
|
61
|
+
override fun run() {
|
|
62
|
+
callback.success(false)
|
|
63
|
+
bluetooth.stopDeviceScan()
|
|
64
|
+
bluetooth.disconnect()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
Timer().schedule(timer, SEARCHING_TIMEOUT)
|
|
68
|
+
|
|
69
|
+
// start searching devices
|
|
70
|
+
val bleIntent = Intent(activity, RegulaBleService::class.java)
|
|
71
|
+
activity.startService(bleIntent)
|
|
72
|
+
activity.bindService(bleIntent, object : ServiceConnection {
|
|
73
|
+
override fun onServiceConnected(name: ComponentName, service: IBinder) {
|
|
74
|
+
bluetooth = (service as RegulaBleService.LocalBinder).service.bleManager
|
|
75
|
+
bluetooth.addCallback(object : BleWrapperCallback() {
|
|
76
|
+
override fun onDeviceReady() {
|
|
77
|
+
timer.cancel()
|
|
78
|
+
bluetooth.removeCallback(this)
|
|
79
|
+
deviceConnected = true
|
|
80
|
+
callback.success(true)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
override fun onServiceDisconnected(name: ComponentName) {}
|
|
86
|
+
}, 0)
|
|
42
87
|
}
|
|
43
88
|
|
|
44
|
-
fun
|
|
45
|
-
|
|
46
|
-
|
|
89
|
+
fun onRequestPermissionsResult(
|
|
90
|
+
requestCode: Int,
|
|
91
|
+
permissions: Array<out String>,
|
|
92
|
+
grantResults: IntArray
|
|
93
|
+
): Boolean {
|
|
94
|
+
if (requestCode != BLE_ACCESS_PERMISSION || permissions.isEmpty()) return false
|
|
95
|
+
if (grantResults.isEmpty() || grantResults[0] != PERMISSION_GRANTED) {
|
|
96
|
+
savedCallbackForPermissionResult.success(false)
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
connectBluetoothDevice(savedCallbackForPermissionResult)
|
|
100
|
+
return true
|
|
47
101
|
}
|
|
48
102
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
103
|
+
fun onActivityResult(requestCode: Int, rc: Int, @Suppress("UNUSED_PARAMETER") data: Intent?): Boolean {
|
|
104
|
+
var resultCode = rc
|
|
105
|
+
if (requestCode == INTENT_REQUEST_ENABLE_LOCATION)
|
|
106
|
+
resultCode = if (isLocationServiceEnabled(activity)) Activity.RESULT_OK
|
|
107
|
+
else requestCode
|
|
108
|
+
|
|
109
|
+
if (requestCode == INTENT_REQUEST_ENABLE_BLUETOOTH || requestCode == INTENT_REQUEST_ENABLE_LOCATION) {
|
|
110
|
+
if (resultCode == Activity.RESULT_OK)
|
|
111
|
+
connectBluetoothDevice(savedCallbackForPermissionResult)
|
|
112
|
+
else
|
|
113
|
+
savedCallbackForPermissionResult.success(false)
|
|
114
|
+
return true
|
|
55
115
|
}
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fun isBluetoothSettingsReady(activity: Activity): Boolean {
|
|
56
120
|
deniedBluetoothPermissions(activity)?.let {
|
|
57
121
|
requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
|
|
58
122
|
return false
|
|
59
123
|
}
|
|
60
124
|
if (!isBluetoothEnabled(activity)) {
|
|
61
|
-
|
|
125
|
+
requestEnableBluetooth(activity)
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
if (!isLocationServiceEnabled(activity)) {
|
|
129
|
+
requestEnableLocationService(activity)
|
|
62
130
|
return false
|
|
63
131
|
}
|
|
64
132
|
return true
|
|
@@ -83,30 +151,12 @@ fun deniedBluetoothPermission(
|
|
|
83
151
|
return arrayOf()
|
|
84
152
|
}
|
|
85
153
|
|
|
86
|
-
fun
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
onReady: () -> Unit
|
|
91
|
-
) {
|
|
92
|
-
val bleIntent = Intent(activity, RegulaBleService::class.java)
|
|
93
|
-
activity.startService(bleIntent)
|
|
94
|
-
|
|
95
|
-
activity.bindService(bleIntent, object : ServiceConnection {
|
|
96
|
-
override fun onServiceConnected(name: ComponentName, service: IBinder) {
|
|
97
|
-
bleManager = (service as RegulaBleService.LocalBinder).service.bleManager
|
|
98
|
-
val isBleManagerConnected = bleManager?.isConnected == true
|
|
99
|
-
onConnected(isBleManagerConnected)
|
|
100
|
-
if (!isBleManagerConnected) {
|
|
101
|
-
bleManager?.addCallback(object : BleWrapperCallback() {
|
|
102
|
-
override fun onDeviceReady() {
|
|
103
|
-
bleManager!!.removeCallback(this)
|
|
104
|
-
onReady()
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
}
|
|
154
|
+
fun requestEnableBluetooth(activity: Activity) {
|
|
155
|
+
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
|
|
156
|
+
activity.startActivityForResult(enableIntent, INTENT_REQUEST_ENABLE_BLUETOOTH)
|
|
157
|
+
}
|
|
109
158
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
159
|
+
fun requestEnableLocationService(activity: Activity) {
|
|
160
|
+
val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
|
161
|
+
activity.startActivityForResult(myIntent, INTENT_REQUEST_ENABLE_LOCATION)
|
|
162
|
+
}
|
package/src/android/Config.kt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Config.
|
|
2
|
+
// Config.kt
|
|
3
3
|
// DocumentReader
|
|
4
4
|
//
|
|
5
5
|
// Created by Pavel Masiuk on 21.09.2023.
|
|
@@ -26,6 +26,7 @@ import com.regula.documentreader.api.params.LivenessParams
|
|
|
26
26
|
import com.regula.documentreader.api.params.ParamsCustomization
|
|
27
27
|
import com.regula.documentreader.api.params.ProcessParam
|
|
28
28
|
import com.regula.documentreader.api.params.RfidScenario
|
|
29
|
+
import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
|
|
29
30
|
import com.regula.documentreader.api.params.rfid.dg.DataGroups
|
|
30
31
|
import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
|
|
31
32
|
import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
|
|
@@ -129,12 +130,16 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
|
|
|
129
130
|
"shouldReturnPackageForReprocess" -> processParams.shouldReturnPackageForReprocess = v as Boolean
|
|
130
131
|
"disablePerforationOCR" -> processParams.disablePerforationOCR = v as Boolean
|
|
131
132
|
"respectImageQuality" -> processParams.respectImageQuality = v as Boolean
|
|
133
|
+
"strictImageQuality" -> processParams.strictImageQuality = v as Boolean
|
|
132
134
|
"splitNames" -> processParams.splitNames = v as Boolean
|
|
133
135
|
"doDetectCan" -> processParams.doDetectCan = v as Boolean
|
|
134
136
|
"useFaceApi" -> processParams.useFaceApi = v as Boolean
|
|
135
137
|
"useAuthenticityCheck" -> processParams.useAuthenticityCheck = v as Boolean
|
|
136
138
|
"checkHologram" -> processParams.checkHologram = v as Boolean
|
|
137
139
|
"generateNumericCodes" -> processParams.generateNumericCodes = v as Boolean
|
|
140
|
+
"strictBarcodeDigitalSignatureCheck" -> processParams.strictBarcodeDigitalSignatureCheck = v as Boolean
|
|
141
|
+
"selectLongestNames" -> processParams.selectLongestNames = v as Boolean
|
|
142
|
+
"generateDTCVC" -> processParams.generateDTCVC = v as Boolean
|
|
138
143
|
"measureSystem" -> processParams.measureSystem = v.toInt()
|
|
139
144
|
"barcodeParserType" -> processParams.barcodeParserType = v.toInt()
|
|
140
145
|
"perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
|
|
@@ -207,12 +212,16 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
|
|
|
207
212
|
"shouldReturnPackageForReprocess" to processParams.shouldReturnPackageForReprocess,
|
|
208
213
|
"disablePerforationOCR" to processParams.disablePerforationOCR,
|
|
209
214
|
"respectImageQuality" to processParams.respectImageQuality,
|
|
215
|
+
"strictImageQuality" to processParams.strictImageQuality,
|
|
210
216
|
"splitNames" to processParams.splitNames,
|
|
211
217
|
"doDetectCan" to processParams.doDetectCan,
|
|
212
218
|
"useFaceApi" to processParams.useFaceApi,
|
|
213
219
|
"useAuthenticityCheck" to processParams.useAuthenticityCheck,
|
|
214
220
|
"checkHologram" to processParams.checkHologram,
|
|
215
221
|
"generateNumericCodes" to processParams.generateNumericCodes,
|
|
222
|
+
"strictBarcodeDigitalSignatureCheck" to processParams.strictBarcodeDigitalSignatureCheck,
|
|
223
|
+
"selectLongestNames" to processParams.selectLongestNames,
|
|
224
|
+
"generateDTCVC" to processParams.generateDTCVC,
|
|
216
225
|
"measureSystem" to processParams.measureSystem,
|
|
217
226
|
"barcodeParserType" to processParams.barcodeParserType,
|
|
218
227
|
"perspectiveAngle" to processParams.perspectiveAngle,
|
|
@@ -265,6 +274,8 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
|
|
|
265
274
|
"cameraFrameLineLength" -> editor.setCameraFrameLineLength(v.toInt())
|
|
266
275
|
"cameraFrameShapeType" -> editor.setCameraFrameShapeType(v.toInt())
|
|
267
276
|
"cameraFrameOffsetWidth" -> editor.setCameraFrameOffsetWidth(v.toInt())
|
|
277
|
+
"nextPageAnimationStartDelay" -> editor.setNextPageAnimationStartDelay(v.toInt())
|
|
278
|
+
"nextPageAnimationEndDelay" -> editor.setNextPageAnimationEndDelay(v.toInt())
|
|
268
279
|
"activityIndicatorSize" -> editor.setActivityIndicatorSize(v.toInt())
|
|
269
280
|
"status" -> editor.setStatus(v as String)
|
|
270
281
|
"resultStatus" -> editor.setResultStatus(v as String)
|
|
@@ -278,6 +289,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
|
|
|
278
289
|
"activityIndicatorColor" -> editor.setActivityIndicatorColor(v.toColor())
|
|
279
290
|
"statusBackgroundColor" -> editor.setStatusBackgroundColor(v.toColor())
|
|
280
291
|
"cameraPreviewBackgroundColor" -> editor.setCameraPreviewBackgroundColor(v.toColor())
|
|
292
|
+
"backgroundMaskColor" -> editor.setBackgroundMaskColor(v.toColor())
|
|
281
293
|
"statusPositionMultiplier" -> editor.setStatusPositionMultiplier(v.toFloat())
|
|
282
294
|
"resultStatusPositionMultiplier" -> editor.setResultStatusPositionMultiplier(v.toFloat())
|
|
283
295
|
"toolbarSize" -> editor.setToolbarSize(v.toFloat())
|
|
@@ -336,6 +348,8 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
|
|
|
336
348
|
"cameraFrameLineLength" to customization.cameraFrameLineLength,
|
|
337
349
|
"cameraFrameShapeType" to customization.cameraFrameShapeType,
|
|
338
350
|
"cameraFrameOffsetWidth" to customization.cameraFrameOffsetWidth,
|
|
351
|
+
"nextPageAnimationStartDelay" to customization.nextPageAnimationStartDelay,
|
|
352
|
+
"nextPageAnimationEndDelay" to customization.nextPageAnimationEndDelay,
|
|
339
353
|
"activityIndicatorSize" to customization.activityIndicatorSize,
|
|
340
354
|
"status" to customization.status,
|
|
341
355
|
"resultStatus" to customization.resultStatus,
|
|
@@ -349,6 +363,7 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
|
|
|
349
363
|
"activityIndicatorColor" to customization.activityIndicatorColor.toLong(),
|
|
350
364
|
"statusBackgroundColor" to customization.statusBackgroundColor.toLong(),
|
|
351
365
|
"cameraPreviewBackgroundColor" to customization.cameraPreviewBackgroundColor.toLong(),
|
|
366
|
+
"backgroundMaskColor" to customization.backgroundMaskColor.toLong(),
|
|
352
367
|
"statusPositionMultiplier" to customization.statusPositionMultiplier,
|
|
353
368
|
"resultStatusPositionMultiplier" to customization.resultStatusPositionMultiplier,
|
|
354
369
|
"backgroundMaskAlpha" to customization.backgroundMaskAlpha,
|
|
@@ -422,6 +437,8 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
|
|
|
422
437
|
"applyAmendments" -> rfidScenario.isApplyAmendments = v as Boolean
|
|
423
438
|
"autoSettings" -> rfidScenario.isAutoSettings = v as Boolean
|
|
424
439
|
"proceedReadingAlways" -> rfidScenario.proceedReadingAlways = v as Boolean
|
|
440
|
+
"readDTC" -> rfidScenario.isReadDTC = v as Boolean
|
|
441
|
+
"mrzStrictCheck" -> rfidScenario.isMrzStrictCheck = v as Boolean
|
|
425
442
|
"signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
|
|
426
443
|
"readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
|
|
427
444
|
"onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
|
|
@@ -437,9 +454,11 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
|
|
|
437
454
|
"mrz" -> rfidScenario.mrz = v as String
|
|
438
455
|
"eSignPINDefault" -> rfidScenario.seteSignPINDefault(v as String)
|
|
439
456
|
"eSignPINNewValue" -> rfidScenario.seteSignPINNewValue(v as String)
|
|
457
|
+
"cardAccess" -> rfidScenario.cardAccess = v as String
|
|
440
458
|
"ePassportDataGroups" -> setDataGroups(rfidScenario.ePassportDataGroups(), v as JSONObject)
|
|
441
459
|
"eIDDataGroups" -> setDataGroups(rfidScenario.eIDDataGroups(), v as JSONObject)
|
|
442
460
|
"eDLDataGroups" -> setDataGroups(rfidScenario.eDLDataGroups(), v as JSONObject)
|
|
461
|
+
"dtcDataGroups" -> setDataGroups(rfidScenario.DTCDataGroup(), v as JSONObject)
|
|
443
462
|
}
|
|
444
463
|
}
|
|
445
464
|
|
|
@@ -478,6 +497,8 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
|
|
|
478
497
|
"applyAmendments" to rfidScenario.isApplyAmendments,
|
|
479
498
|
"autoSettings" to rfidScenario.isAutoSettings,
|
|
480
499
|
"proceedReadingAlways" to rfidScenario.proceedReadingAlways,
|
|
500
|
+
"readDTC" to rfidScenario.isReadDTC,
|
|
501
|
+
"mrzStrictCheck" to rfidScenario.isMrzStrictCheck,
|
|
481
502
|
"signManagementAction" to rfidScenario.signManagementAction,
|
|
482
503
|
"readingBuffer" to rfidScenario.readingBuffer,
|
|
483
504
|
"onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
|
|
@@ -493,9 +514,11 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
|
|
|
493
514
|
"mrz" to rfidScenario.mrz,
|
|
494
515
|
"eSignPINDefault" to rfidScenario.geteSignPINDefault(),
|
|
495
516
|
"eSignPINNewValue" to rfidScenario.geteSignPINNewValue(),
|
|
517
|
+
"cardAccess" to rfidScenario.cardAccess,
|
|
496
518
|
"ePassportDataGroups" to getDataGroups(rfidScenario.ePassportDataGroups()),
|
|
497
519
|
"eIDDataGroups" to getDataGroups(rfidScenario.eIDDataGroups()),
|
|
498
|
-
"eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups())
|
|
520
|
+
"eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups()),
|
|
521
|
+
"dtcDataGroups" to getDataGroups(rfidScenario.DTCDataGroup())
|
|
499
522
|
).toJsonObject()
|
|
500
523
|
|
|
501
524
|
fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v ->
|
|
@@ -529,6 +552,15 @@ fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v
|
|
|
529
552
|
"DG20" -> dataGroup.isDG20 = value
|
|
530
553
|
"DG21" -> dataGroup.isDG21 = value
|
|
531
554
|
}
|
|
555
|
+
if (dataGroup is DTCDataGroup) when (k) {
|
|
556
|
+
"DG15" -> dataGroup.isDG15 = value
|
|
557
|
+
"DG16" -> dataGroup.isDG16 = value
|
|
558
|
+
"DG17" -> dataGroup.isDG17 = value
|
|
559
|
+
"DG18" -> dataGroup.isDG18 = value
|
|
560
|
+
"DG22" -> dataGroup.isDG22 = value
|
|
561
|
+
"DG23" -> dataGroup.isDG23 = value
|
|
562
|
+
"DG24" -> dataGroup.isDG24 = value
|
|
563
|
+
}
|
|
532
564
|
}
|
|
533
565
|
|
|
534
566
|
fun getDataGroups(dataGroup: DataGroups): JSONObject {
|
|
@@ -561,6 +593,15 @@ fun getDataGroups(dataGroup: DataGroups): JSONObject {
|
|
|
561
593
|
result["DG20"] = dataGroup.isDG20
|
|
562
594
|
result["DG21"] = dataGroup.isDG21
|
|
563
595
|
}
|
|
596
|
+
if (dataGroup is DTCDataGroup) {
|
|
597
|
+
result["DG15"] = dataGroup.isDG15
|
|
598
|
+
result["DG16"] = dataGroup.isDG16
|
|
599
|
+
result["DG17"] = dataGroup.isDG17
|
|
600
|
+
result["DG18"] = dataGroup.isDG18
|
|
601
|
+
result["DG22"] = dataGroup.isDG22
|
|
602
|
+
result["DG23"] = dataGroup.isDG23
|
|
603
|
+
result["DG24"] = dataGroup.isDG24
|
|
604
|
+
}
|
|
564
605
|
return result.toJsonObject()
|
|
565
606
|
}
|
|
566
607
|
|
|
@@ -48,7 +48,18 @@ import org.json.JSONArray
|
|
|
48
48
|
import org.json.JSONObject
|
|
49
49
|
|
|
50
50
|
class DocumentReader : CordovaPlugin() {
|
|
51
|
-
override fun onNewIntent(intent: Intent)
|
|
51
|
+
override fun onNewIntent(intent: Intent) {
|
|
52
|
+
newIntent(intent)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
|
56
|
+
myOnActivityResult(requestCode, resultCode, intent)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?) {
|
|
60
|
+
myOnRequestPermissionsResult(requestCode, permissions!!, grantResults!!)
|
|
61
|
+
}
|
|
62
|
+
|
|
52
63
|
override fun execute(action: String, args: JSONArray, callbackContext: CallbackContext): Boolean {
|
|
53
64
|
activity = cordova.activity
|
|
54
65
|
exec(args, callbackContext)
|
|
@@ -56,6 +67,12 @@ class DocumentReader : CordovaPlugin() {
|
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
|
|
70
|
+
fun myOnActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
|
71
|
+
onActivityResult(requestCode, resultCode, intent)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fun myOnRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?) = onRequestPermissionsResult(requestCode, permissions!!, grantResults!!)
|
|
75
|
+
|
|
59
76
|
fun sendEvent(event: String, data: Any? = "") {
|
|
60
77
|
// These events are not working in cordova and ionic because they don't have a method
|
|
61
78
|
// associated with it. Callbacks are set automatically right after init.
|
|
@@ -98,8 +115,6 @@ fun exec(arguments: JSONArray, tempContext: CallbackContext) {
|
|
|
98
115
|
when (action) {
|
|
99
116
|
"getDocumentReaderIsReady" -> getDocumentReaderIsReady(callback)
|
|
100
117
|
"getDocumentReaderStatus" -> getDocumentReaderStatus(callback)
|
|
101
|
-
"isAuthenticatorAvailableForUse" -> isAuthenticatorAvailableForUse(callback)
|
|
102
|
-
"isBlePermissionsGranted" -> isBlePermissionsGranted(callback)
|
|
103
118
|
"getRfidSessionStatus" -> getRfidSessionStatus(callback)
|
|
104
119
|
"setRfidSessionStatus" -> setRfidSessionStatus(callback)
|
|
105
120
|
"getTag" -> getTag(callback)
|
|
@@ -139,11 +154,13 @@ fun exec(arguments: JSONArray, tempContext: CallbackContext) {
|
|
|
139
154
|
"addPKDCertificates" -> addPKDCertificates(callback, args(0))
|
|
140
155
|
"clearPKDCertificates" -> clearPKDCertificates(callback)
|
|
141
156
|
"startNewSession" -> startNewSession(callback)
|
|
142
|
-
"
|
|
157
|
+
"connectBluetoothDevice" -> connectBluetoothDevice(callback)
|
|
143
158
|
"setLocalizationDictionary" -> setLocalizationDictionary(args(0))
|
|
144
159
|
"getLicense" -> getLicense(callback)
|
|
145
160
|
"getAvailableScenarios" -> getAvailableScenarios(callback)
|
|
146
161
|
"getIsRFIDAvailableForUse" -> getIsRFIDAvailableForUse(callback)
|
|
162
|
+
"isAuthenticatorAvailableForUse" -> isAuthenticatorAvailableForUse(callback)
|
|
163
|
+
"isAuthenticatorRFIDAvailableForUse" -> isAuthenticatorRFIDAvailableForUse(callback)
|
|
147
164
|
"getDocReaderVersion" -> getDocReaderVersion(callback)
|
|
148
165
|
"getDocReaderDocumentsDatabase" -> getDocReaderDocumentsDatabase(callback)
|
|
149
166
|
"textFieldValueByType" -> textFieldValueByType(callback, args(0), args(1))
|
|
@@ -164,6 +181,7 @@ fun exec(arguments: JSONArray, tempContext: CallbackContext) {
|
|
|
164
181
|
"containers" -> containers(callback, args(0), args(1))
|
|
165
182
|
"encryptedContainers" -> encryptedContainers(callback, args(0))
|
|
166
183
|
"finalizePackage" -> finalizePackage(callback)
|
|
184
|
+
"endBackendTransaction" -> endBackendTransaction(callback)
|
|
167
185
|
"getTranslation" -> getTranslation(callback, args(0), args(1))
|
|
168
186
|
}
|
|
169
187
|
}
|
|
@@ -193,10 +211,6 @@ const val eventPACertificateCompletion = "pa_certificate_completion"
|
|
|
193
211
|
const val eventTACertificateCompletion = "ta_certificate_completion"
|
|
194
212
|
const val eventTASignatureCompletion = "ta_signature_completion"
|
|
195
213
|
|
|
196
|
-
const val bleOnServiceConnectedEvent = "bleOnServiceConnectedEvent"
|
|
197
|
-
const val bleOnServiceDisconnectedEvent = "bleOnServiceDisconnectedEvent"
|
|
198
|
-
const val bleOnDeviceReadyEvent = "bleOnDeviceReadyEvent"
|
|
199
|
-
|
|
200
214
|
const val eventVideoEncoderCompletion = "video_encoder_completion"
|
|
201
215
|
const val onCustomButtonTappedEvent = "onCustomButtonTappedEvent"
|
|
202
216
|
|
|
@@ -204,10 +218,6 @@ fun getDocumentReaderIsReady(callback: Callback) = callback.success(Instance().i
|
|
|
204
218
|
|
|
205
219
|
fun getDocumentReaderStatus(callback: Callback) = callback.success(Instance().status)
|
|
206
220
|
|
|
207
|
-
fun isAuthenticatorAvailableForUse(callback: Callback) = callback.success(Instance().isAuthenticatorAvailableForUse)
|
|
208
|
-
|
|
209
|
-
fun isBlePermissionsGranted(callback: Callback) = callback.success(isBlePermissionsGranted((activity)))
|
|
210
|
-
|
|
211
221
|
fun getRfidSessionStatus(callback: Callback) = callback.error("getRfidSessionStatus() is an ios-only method")
|
|
212
222
|
|
|
213
223
|
fun setRfidSessionStatus(callback: Callback) = callback.error("setRfidSessionStatus() is an ios-only method")
|
|
@@ -342,13 +352,6 @@ fun startNewSession(callback: Callback) {
|
|
|
342
352
|
callback.success()
|
|
343
353
|
}
|
|
344
354
|
|
|
345
|
-
fun startBluetoothService() = startBluetoothService(
|
|
346
|
-
activity,
|
|
347
|
-
{ sendEvent(bleOnServiceConnectedEvent, it) },
|
|
348
|
-
{ sendEvent(bleOnServiceDisconnectedEvent) },
|
|
349
|
-
{ sendEvent(bleOnDeviceReadyEvent) }
|
|
350
|
-
)
|
|
351
|
-
|
|
352
355
|
fun setLocalizationDictionary(dictionary: JSONObject) {
|
|
353
356
|
localizationCallbacks = LocalizationCallbacks { if (dictionary.has(it)) dictionary.getString(it) else null }
|
|
354
357
|
Instance().setLocalizationCallback(localizationCallbacks!!)
|
|
@@ -365,6 +368,10 @@ fun getAvailableScenarios(callback: Callback) {
|
|
|
365
368
|
|
|
366
369
|
fun getIsRFIDAvailableForUse(callback: Callback) = callback.success(Instance().isRFIDAvailableForUse)
|
|
367
370
|
|
|
371
|
+
fun isAuthenticatorAvailableForUse(callback: Callback) = callback.success(Instance().isAuthenticatorAvailableForUse)
|
|
372
|
+
|
|
373
|
+
fun isAuthenticatorRFIDAvailableForUse(callback: Callback) = callback.success(Instance().isAuthenticatorRFIDAvailableForUse)
|
|
374
|
+
|
|
368
375
|
fun getDocReaderVersion(callback: Callback) = callback.success(generateDocReaderVersion(Instance().version))
|
|
369
376
|
|
|
370
377
|
fun getDocReaderDocumentsDatabase(callback: Callback) = callback.success(Instance().version?.let { generateDocReaderDocumentsDatabase(it.database) })
|
|
@@ -405,6 +412,11 @@ fun encryptedContainers(callback: Callback, raw: String) = callback.success(from
|
|
|
405
412
|
|
|
406
413
|
fun finalizePackage(callback: Callback) = Instance().finalizePackage { action, info, error -> callback.success(generateFinalizePackageCompletion(action, info, error)) }
|
|
407
414
|
|
|
415
|
+
fun endBackendTransaction(callback: Callback) {
|
|
416
|
+
Instance().endBackendTransaction()
|
|
417
|
+
callback.success()
|
|
418
|
+
}
|
|
419
|
+
|
|
408
420
|
fun getTranslation(callback: Callback, className: String, value: Int) = when (className) {
|
|
409
421
|
"RFIDErrorCodes" -> callback.success(eRFID_ErrorCodes.getTranslation(context, value))
|
|
410
422
|
"LDSParsingErrorCodes" -> callback.success(eLDS_ParsingErrorCodes.getTranslation(context, value))
|
|
@@ -485,12 +497,15 @@ var requestType = RfidReaderRequestType(
|
|
|
485
497
|
)
|
|
486
498
|
|
|
487
499
|
@Suppress("DEPRECATION")
|
|
488
|
-
fun newIntent(intent: Intent)
|
|
500
|
+
fun newIntent(intent: Intent): Boolean {
|
|
501
|
+
if (intent.action != NfcAdapter.ACTION_TECH_DISCOVERED) return false
|
|
489
502
|
Instance().readRFID(
|
|
490
503
|
IsoDep.get(intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)),
|
|
491
504
|
rfidReaderCompletion,
|
|
492
505
|
requestType.getRfidReaderRequest()
|
|
493
|
-
)
|
|
506
|
+
)
|
|
507
|
+
return true
|
|
508
|
+
}
|
|
494
509
|
|
|
495
510
|
fun startForegroundDispatch() {
|
|
496
511
|
backgroundRFIDEnabled = true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// JSONConstructor.
|
|
2
|
+
// JSONConstructor.kt
|
|
3
3
|
// DocumentReader
|
|
4
4
|
//
|
|
5
5
|
// Created by Pavel Masiuk on 21.09.2023.
|
|
@@ -46,6 +46,7 @@ import com.regula.documentreader.api.params.rfid.TccParams
|
|
|
46
46
|
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute
|
|
47
47
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer
|
|
48
48
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge
|
|
49
|
+
import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
|
|
49
50
|
import com.regula.documentreader.api.params.rfid.dg.EDLDataGroups
|
|
50
51
|
import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
|
|
51
52
|
import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
|
|
@@ -243,6 +244,17 @@ fun generateDocReaderConfig(temp: DocReaderConfig?): JSONObject? {
|
|
|
243
244
|
return result
|
|
244
245
|
}
|
|
245
246
|
|
|
247
|
+
fun bleDeviceConfigFromJSON(input: JSONObject): BleDeviceConfig {
|
|
248
|
+
var result = BleDeviceConfig(bluetooth)
|
|
249
|
+
|
|
250
|
+
if (input.has("customDb")) result = BleDeviceConfig(bluetooth, byteArrayFromBase64(input.getString("customDb")))
|
|
251
|
+
if (input.has("licenseUpdate")) result.setLicenseUpdate(input.getBoolean("licenseUpdate"))
|
|
252
|
+
if (input.has("delayedNNLoad")) result.isDelayedNNLoad = input.getBoolean("delayedNNLoad")
|
|
253
|
+
if (input.has("blackList")) result.blackList = input.getJSONObject("blackList")
|
|
254
|
+
|
|
255
|
+
return result
|
|
256
|
+
}
|
|
257
|
+
|
|
246
258
|
fun scannerConfigFromJSON(input: JSONObject): ScannerConfig {
|
|
247
259
|
val builder = if (input.has("scenario")) ScannerConfig.Builder(input.getString("scenario"))
|
|
248
260
|
else ScannerConfig.Builder(onlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig"))!!)
|
|
@@ -274,6 +286,7 @@ fun recognizeConfigFromJSON(input: JSONObject): RecognizeConfig {
|
|
|
274
286
|
else RecognizeConfig.Builder(onlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig"))!!)
|
|
275
287
|
|
|
276
288
|
if (input.has("oneShotIdentification")) builder.setOneShotIdentification(input.getBoolean("oneShotIdentification"))
|
|
289
|
+
if (input.has("dtc")) builder.setDTC(byteArrayFromBase64(input.getString("dtc"))!!)
|
|
277
290
|
if (input.has("livePortrait")) builder.setLivePortrait(bitmapFromBase64(input.getString("livePortrait"))!!)
|
|
278
291
|
if (input.has("extPortrait")) builder.setExtPortrait(bitmapFromBase64(input.getString("extPortrait"))!!)
|
|
279
292
|
if (input.has("image")) builder.setBitmap(bitmapFromBase64(input.getString("image"))!!)
|
|
@@ -302,6 +315,7 @@ fun generateRecognizeConfig(temp: RecognizeConfig?): JSONObject? {
|
|
|
302
315
|
result.put("scenario", input.scenario)
|
|
303
316
|
result.put("onlineProcessingConfig", generateOnlineProcessingConfig(input.onlineProcessingConfig))
|
|
304
317
|
result.put("oneShotIdentification", input.oneShotIdentification)
|
|
318
|
+
result.put("dtc", generateByteArray(input.dtc))
|
|
305
319
|
result.put("livePortrait", bitmapToBase64(input.livePortrait))
|
|
306
320
|
result.put("extPortrait", bitmapToBase64(input.extPortrait))
|
|
307
321
|
result.put("image", bitmapToBase64(input.bitmap))
|
|
@@ -325,6 +339,7 @@ fun backendProcessingConfigFromJSON(temp: JSONObject?): BackendProcessingConfig?
|
|
|
325
339
|
val result = BackendProcessingConfig(input.getString("url"))
|
|
326
340
|
if (input.has("httpHeaders")) result.httpHeaders = stringMapFromJson(input.getJSONObject("httpHeaders"))
|
|
327
341
|
if (input.has("rfidServerSideChipVerification")) result.rfidServerSideChipVerification = input.getBoolean("rfidServerSideChipVerification")
|
|
342
|
+
if (input.has("timeoutConnection")) result.timeoutConnection = input.getDouble("timeoutConnection")
|
|
328
343
|
|
|
329
344
|
return result
|
|
330
345
|
}
|
|
@@ -337,6 +352,7 @@ fun generateBackendProcessingConfig(temp: BackendProcessingConfig?): JSONObject?
|
|
|
337
352
|
result.put("url", input.url)
|
|
338
353
|
result.put("httpHeaders", generateStringMap(input.httpHeaders))
|
|
339
354
|
result.put("rfidServerSideChipVerification", input.rfidServerSideChipVerification)
|
|
355
|
+
result.put("timeoutConnection", input.timeoutConnection)
|
|
340
356
|
|
|
341
357
|
return result
|
|
342
358
|
}
|
|
@@ -508,6 +524,14 @@ fun eIDDataGroupsFromJSON(input: JSONObject): EIDDataGroups {
|
|
|
508
524
|
|
|
509
525
|
fun generateEIDDataGroups(input: EIDDataGroups): JSONObject = getDataGroups(input)
|
|
510
526
|
|
|
527
|
+
fun dtcDataGroupsFromJSON(input: JSONObject): DTCDataGroup {
|
|
528
|
+
val result = DTCDataGroup()
|
|
529
|
+
setDataGroups(result, input)
|
|
530
|
+
return result
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
fun generateDTCDataGroups(input: DTCDataGroup): JSONObject = getDataGroups(input)
|
|
534
|
+
|
|
511
535
|
fun rfidScenarioFromJSON(input: JSONObject): RfidScenario {
|
|
512
536
|
val result = RfidScenario()
|
|
513
537
|
setRfidScenario(result, input)
|
|
@@ -573,18 +597,6 @@ fun generateTypeface(temp: Typeface?, size: Int? = null): JSONObject? {
|
|
|
573
597
|
return result
|
|
574
598
|
}
|
|
575
599
|
|
|
576
|
-
fun bleDeviceConfigFromJSON(input: JSONObject): BleDeviceConfig {
|
|
577
|
-
val bleWrapper = bleManager
|
|
578
|
-
var result = BleDeviceConfig(bleWrapper)
|
|
579
|
-
|
|
580
|
-
if (input.has("customDb")) result = BleDeviceConfig(bleWrapper!!, byteArrayFromBase64(input.getString("customDb")))
|
|
581
|
-
if (input.has("licenseUpdate")) result.setLicenseUpdate(input.getBoolean("licenseUpdate"))
|
|
582
|
-
if (input.has("delayedNNLoad")) result.isDelayedNNLoad = input.getBoolean("delayedNNLoad")
|
|
583
|
-
if (input.has("blackList")) result.blackList = input.getJSONObject("blackList")
|
|
584
|
-
|
|
585
|
-
return result
|
|
586
|
-
}
|
|
587
|
-
|
|
588
600
|
fun imageInputDataFromJSON(temp: JSONObject?): ImageInputData? {
|
|
589
601
|
if (temp == null || !temp.has("image")) return null
|
|
590
602
|
val input: JSONObject = temp
|
|
@@ -2168,6 +2180,7 @@ fun documentReaderResultsFromJSON(temp: JSONObject?): DocumentReaderResults? {
|
|
|
2168
2180
|
result.documentType = listFromJSON(input.optJSONArray("documentType"), ::documentReaderDocumentTypeFromJSON)!!
|
|
2169
2181
|
result.status = documentReaderResultsStatusFromJSON(input.optJSONObject("status"))!!
|
|
2170
2182
|
result.vdsncData = vdsncDataFromJSON(input.optJSONObject("vdsncData")!!)
|
|
2183
|
+
result.dtcData = input.getString("dtcData")
|
|
2171
2184
|
result.transactionInfo = transactionInfoFromJSON(input.optJSONObject("transactionInfo"))
|
|
2172
2185
|
|
|
2173
2186
|
return result
|
|
@@ -2196,6 +2209,7 @@ fun generateDocumentReaderResults(temp: DocumentReaderResults?, context: Context
|
|
|
2196
2209
|
result.put("documentType", generateList(input.documentType, ::generateDocumentReaderDocumentType))
|
|
2197
2210
|
result.put("status", generateDocumentReaderResultsStatus(input.status))
|
|
2198
2211
|
result.put("vdsncData", generateVDSNCData(input.vdsncData))
|
|
2212
|
+
result.put("dtcData", input.dtcData)
|
|
2199
2213
|
result.put("transactionInfo", generateTransactionInfo(input.transactionInfo))
|
|
2200
2214
|
|
|
2201
2215
|
return result
|