@regulaforensics/react-native-document-reader-api 7.4.735 → 7.5.85-rc

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/README.md CHANGED
@@ -8,7 +8,7 @@ This repository contains the source code of the Document Reader API, and the sam
8
8
 
9
9
  ## Documentation
10
10
 
11
- You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/react-native).
11
+ You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile).
12
12
 
13
13
  ## License
14
14
 
@@ -12,8 +12,8 @@ Pod::Spec.new do |s|
12
12
  s.homepage = 'https://regulaforensics.com'
13
13
 
14
14
  s.source = { :http => 'file:' + __dir__ }
15
- s.ios.deployment_target = '11.0'
15
+ s.ios.deployment_target = '13.0'
16
16
  s.source_files = "ios/*.{h,m}"
17
- s.dependency 'DocumentReader', '7.4.3900'
17
+ s.dependency 'DocumentReaderStage', '7.7.4492'
18
18
  s.dependency 'React'
19
19
  end
@@ -32,7 +32,7 @@ android {
32
32
  rootProject.allprojects {
33
33
  repositories {
34
34
  maven {
35
- url "https://maven.regulaforensics.com/RegulaDocumentReader"
35
+ url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
36
36
  }
37
37
  }
38
38
  }
@@ -41,7 +41,7 @@ dependencies {
41
41
  //noinspection GradleDynamicVersion
42
42
  implementation 'com.facebook.react:react-native:+'
43
43
  //noinspection GradleDependency
44
- implementation('com.regula.documentreader:api:7.4.10181') {
44
+ implementation('com.regula.documentreader:api:7.5.11319') {
45
45
  transitive = true
46
46
  }
47
47
  }
@@ -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 com.regula.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,94 +22,137 @@ 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
- import androidx.core.app.ActivityCompat.requestPermissions
24
25
  import androidx.core.content.ContextCompat.checkSelfPermission
25
- import com.regula.documentreader.api.ble.BLEWrapper
26
- import com.regula.documentreader.api.ble.BleWrapperCallback
27
- import com.regula.documentreader.api.ble.RegulaBleService
26
+ import com.regula.common.ble.BLEWrapper
27
+ import com.regula.common.ble.BleWrapperCallback
28
+ import com.regula.common.ble.RegulaBleService
28
29
  import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelper.BLE_ACCESS_PERMISSION
29
30
  import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
30
31
  import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
32
+ import java.util.Timer
33
+ import java.util.TimerTask
31
34
 
32
- const val REQUEST_ENABLE_LOCATION = 196
33
- const val REQUEST_ENABLE_BT = 197
35
+ const val SEARCHING_TIMEOUT: Long = 7000
36
+
37
+ const val INTENT_REQUEST_ENABLE_LOCATION = 196
38
+ const val INTENT_REQUEST_ENABLE_BLUETOOTH = 197
34
39
 
35
40
  @SuppressLint("StaticFieldLeak")
36
- var bleManager: BLEWrapper? = null
41
+ lateinit var bluetooth: BLEWrapper
42
+ lateinit var savedCallbackForPermissionResult: Callback
43
+ var deviceConnected = false
37
44
 
38
- @RequiresPermission("android.permission.BLUETOOTH_CONNECT")
39
- fun requestEnableBle(activity: Activity) {
40
- val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
41
- activity.startActivityForResult(enableIntent, REQUEST_ENABLE_BT)
45
+ fun connectBluetoothDevice(callback: Callback) {
46
+ // return if already connected
47
+ if (deviceConnected) return
48
+
49
+ // If some of the bluetooth permissions/settings don't match the requirements,
50
+ // save callback for later and request the permissions/settings.
51
+ // Callback will then be used in onRequestPermissionsResult for permission requests
52
+ // and in onActivityResult for settings change requests.
53
+ if (!isBluetoothSettingsReady(activity)) {
54
+ savedCallbackForPermissionResult = callback
55
+ return
56
+ }
57
+
58
+ // set searching timeout
59
+ val timer = object : TimerTask() {
60
+ override fun run() {
61
+ callback.success(false)
62
+ bluetooth.stopDeviceScan()
63
+ bluetooth.disconnect()
64
+ }
65
+ }
66
+ Timer().schedule(timer, SEARCHING_TIMEOUT)
67
+
68
+ // start searching devices
69
+ val bleIntent = Intent(context, RegulaBleService::class.java)
70
+ context.startService(bleIntent)
71
+ context.bindService(bleIntent, object : ServiceConnection {
72
+ override fun onServiceConnected(name: ComponentName, service: IBinder) {
73
+ bluetooth = (service as RegulaBleService.LocalBinder).service.bleManager
74
+ bluetooth.addCallback(object : BleWrapperCallback() {
75
+ override fun onDeviceReady() {
76
+ timer.cancel()
77
+ bluetooth.removeCallback(this)
78
+ deviceConnected = true
79
+ callback.success(true)
80
+ }
81
+ })
82
+ }
83
+
84
+ override fun onServiceDisconnected(name: ComponentName) {}
85
+ }, 0)
42
86
  }
43
87
 
44
- fun requestEnableLocationService(activity: Activity) {
45
- val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
46
- activity.startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION)
88
+ fun onRequestPermissionsResult(
89
+ requestCode: Int,
90
+ permissions: Array<String>,
91
+ grantResults: IntArray
92
+ ): Boolean {
93
+ if (requestCode != BLE_ACCESS_PERMISSION || permissions.isEmpty()) return false
94
+ if (grantResults.isEmpty() || grantResults[0] != PERMISSION_GRANTED) {
95
+ savedCallbackForPermissionResult.success(false)
96
+ return true
97
+ }
98
+ connectBluetoothDevice(savedCallbackForPermissionResult)
99
+ return true
47
100
  }
48
101
 
49
- // requestEnableBle() is called after a check for permission
50
- @SuppressLint("MissingPermission")
51
- fun isBlePermissionsGranted(activity: Activity): Boolean {
52
- if (!isLocationServiceEnabled(activity)) {
53
- requestEnableLocationService(activity)
54
- return false
102
+ fun onActivityResult(requestCode: Int, rc: Int, @Suppress("UNUSED_PARAMETER") data: Intent?): Boolean {
103
+ var resultCode = rc
104
+ if (requestCode == INTENT_REQUEST_ENABLE_LOCATION)
105
+ resultCode = if (isLocationServiceEnabled(activity)) Activity.RESULT_OK
106
+ else requestCode
107
+
108
+ if (requestCode == INTENT_REQUEST_ENABLE_BLUETOOTH || requestCode == INTENT_REQUEST_ENABLE_LOCATION) {
109
+ if (resultCode == Activity.RESULT_OK)
110
+ connectBluetoothDevice(savedCallbackForPermissionResult)
111
+ else
112
+ savedCallbackForPermissionResult.success(false)
113
+ return true
55
114
  }
56
- deniedBluetoothPermissions(activity)?.let {
115
+ return false
116
+ }
117
+
118
+ fun isBluetoothSettingsReady(activity: Activity): Boolean {
119
+ deniedBluetoothPermissions()?.let {
57
120
  requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
58
121
  return false
59
122
  }
60
123
  if (!isBluetoothEnabled(activity)) {
61
- requestEnableBle(activity)
124
+ requestEnableBluetooth(activity)
125
+ return false
126
+ }
127
+ if (!isLocationServiceEnabled(activity)) {
128
+ requestEnableLocationService(activity)
62
129
  return false
63
130
  }
64
131
  return true
65
132
  }
66
133
 
67
- fun deniedBluetoothPermissions(activity: Activity): Array<String>? {
134
+ fun deniedBluetoothPermissions(): Array<String>? {
68
135
  val result = mutableListOf<String>()
69
136
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
70
- result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_SCAN))
71
- result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_CONNECT))
137
+ result.addAll(deniedBluetoothPermission(BLUETOOTH_SCAN))
138
+ result.addAll(deniedBluetoothPermission(BLUETOOTH_CONNECT))
72
139
  } else
73
- result.addAll(deniedBluetoothPermission(activity, ACCESS_FINE_LOCATION))
140
+ result.addAll(deniedBluetoothPermission(ACCESS_FINE_LOCATION))
74
141
  return result.let { if (it.size > 0) it.toTypedArray() else null }
75
142
  }
76
143
 
77
- fun deniedBluetoothPermission(
78
- activity: Activity,
79
- permission: String
80
- ): Array<String> {
81
- if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
144
+ fun deniedBluetoothPermission(permission: String): Array<String> {
145
+ if (checkSelfPermission(context, permission) != PERMISSION_GRANTED)
82
146
  return arrayOf(permission)
83
147
  return arrayOf()
84
148
  }
85
149
 
86
- fun startBluetoothService(
87
- activity: Activity,
88
- onConnected: (Boolean) -> Unit,
89
- onDisconnected: () -> Unit,
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
- }
150
+ fun requestEnableBluetooth(activity: Activity) {
151
+ val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
152
+ startActivityForResult(activity, enableIntent, INTENT_REQUEST_ENABLE_BLUETOOTH)
153
+ }
109
154
 
110
- override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
111
- }, 0)
112
- }
155
+ fun requestEnableLocationService(activity: Activity) {
156
+ val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
157
+ startActivityForResult(activity, myIntent, INTENT_REQUEST_ENABLE_LOCATION)
158
+ }
@@ -1,11 +1,13 @@
1
1
  //
2
- // Config.java
2
+ // Config.kt
3
3
  // DocumentReader
4
4
  //
5
5
  // Created by Pavel Masiuk on 21.09.2023.
6
6
  // Copyright © 2023 Regula. All rights reserved.
7
7
  //
8
8
 
9
+ @file:Suppress("EnumValuesSoftDeprecate")
10
+
9
11
  package com.regula.documentreader
10
12
 
11
13
  import android.content.Context
@@ -26,6 +28,7 @@ import com.regula.documentreader.api.params.LivenessParams
26
28
  import com.regula.documentreader.api.params.ParamsCustomization
27
29
  import com.regula.documentreader.api.params.ProcessParam
28
30
  import com.regula.documentreader.api.params.RfidScenario
31
+ import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
29
32
  import com.regula.documentreader.api.params.rfid.dg.DataGroups
30
33
  import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
31
34
  import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
@@ -52,6 +55,7 @@ fun setFunctionality(functionality: Functionality, opts: JSONObject) = opts.forE
52
55
  "isCameraTorchCheckDisabled" -> editor.setIsCameraTorchCheckDisabled(v as Boolean)
53
56
  "recordScanningProcess" -> editor.setDoRecordProcessingVideo(v as Boolean)
54
57
  "manualMultipageMode" -> editor.setManualMultipageMode(v as Boolean)
58
+ "torchTurnedOn" -> editor.setTorchTurnedOn(v as Boolean)
55
59
  "showCaptureButtonDelayFromDetect" -> editor.setShowCaptureButtonDelayFromDetect(v.toLong())
56
60
  "showCaptureButtonDelayFromStart" -> editor.setShowCaptureButtonDelayFromStart(v.toLong())
57
61
  "orientation" -> editor.setOrientation(v.toInt())
@@ -85,6 +89,7 @@ fun getFunctionality(functionality: Functionality) = mapOf(
85
89
  "isCameraTorchCheckDisabled" to functionality.isCameraTorchCheckDisabled,
86
90
  "recordScanningProcess" to functionality.doRecordProcessingVideo(),
87
91
  "manualMultipageMode" to functionality.isManualMultipageMode,
92
+ "torchTurnedOn" to functionality.isTorchTurnedOn,
88
93
  "showCaptureButtonDelayFromDetect" to functionality.showCaptureButtonDelayFromDetect,
89
94
  "showCaptureButtonDelayFromStart" to functionality.showCaptureButtonDelayFromStart,
90
95
  "orientation" to functionality.orientation,
@@ -129,12 +134,17 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
129
134
  "shouldReturnPackageForReprocess" -> processParams.shouldReturnPackageForReprocess = v as Boolean
130
135
  "disablePerforationOCR" -> processParams.disablePerforationOCR = v as Boolean
131
136
  "respectImageQuality" -> processParams.respectImageQuality = v as Boolean
137
+ "strictImageQuality" -> processParams.strictImageQuality = v as Boolean
132
138
  "splitNames" -> processParams.splitNames = v as Boolean
133
139
  "doDetectCan" -> processParams.doDetectCan = v as Boolean
134
140
  "useFaceApi" -> processParams.useFaceApi = v as Boolean
135
141
  "useAuthenticityCheck" -> processParams.useAuthenticityCheck = v as Boolean
136
142
  "checkHologram" -> processParams.checkHologram = v as Boolean
137
143
  "generateNumericCodes" -> processParams.generateNumericCodes = v as Boolean
144
+ "strictBarcodeDigitalSignatureCheck" -> processParams.strictBarcodeDigitalSignatureCheck = v as Boolean
145
+ "selectLongestNames" -> processParams.selectLongestNames = v as Boolean
146
+ "generateDTCVC" -> processParams.generateDTCVC = v as Boolean
147
+ "strictDLCategoryExpiry" -> processParams.strictDLCategoryExpiry = v as Boolean
138
148
  "measureSystem" -> processParams.measureSystem = v.toInt()
139
149
  "barcodeParserType" -> processParams.barcodeParserType = v.toInt()
140
150
  "perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
@@ -153,7 +163,6 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
153
163
  "dateFormat" -> processParams.dateFormat = v as String
154
164
  "scenario" -> processParams.scenario = v as String
155
165
  "captureButtonScenario" -> processParams.captureButtonScenario = v as String
156
- "sessionLogFolder" -> processParams.sessionLogFolder = v as String
157
166
  "timeout" -> processParams.timeout = v.toDouble()
158
167
  "timeoutFromFirstDetect" -> processParams.timeoutFromFirstDetect = v.toDouble()
159
168
  "timeoutFromFirstDocType" -> processParams.timeoutFromFirstDocType = v.toDouble()
@@ -207,12 +216,17 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
207
216
  "shouldReturnPackageForReprocess" to processParams.shouldReturnPackageForReprocess,
208
217
  "disablePerforationOCR" to processParams.disablePerforationOCR,
209
218
  "respectImageQuality" to processParams.respectImageQuality,
219
+ "strictImageQuality" to processParams.strictImageQuality,
210
220
  "splitNames" to processParams.splitNames,
211
221
  "doDetectCan" to processParams.doDetectCan,
212
222
  "useFaceApi" to processParams.useFaceApi,
213
223
  "useAuthenticityCheck" to processParams.useAuthenticityCheck,
214
224
  "checkHologram" to processParams.checkHologram,
215
225
  "generateNumericCodes" to processParams.generateNumericCodes,
226
+ "strictBarcodeDigitalSignatureCheck" to processParams.strictBarcodeDigitalSignatureCheck,
227
+ "selectLongestNames" to processParams.selectLongestNames,
228
+ "generateDTCVC" to processParams.generateDTCVC,
229
+ "strictDLCategoryExpiry" to processParams.strictDLCategoryExpiry,
216
230
  "measureSystem" to processParams.measureSystem,
217
231
  "barcodeParserType" to processParams.barcodeParserType,
218
232
  "perspectiveAngle" to processParams.perspectiveAngle,
@@ -231,7 +245,6 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
231
245
  "dateFormat" to processParams.dateFormat,
232
246
  "scenario" to processParams.scenario,
233
247
  "captureButtonScenario" to processParams.captureButtonScenario,
234
- "sessionLogFolder" to processParams.sessionLogFolder,
235
248
  "timeout" to processParams.timeout,
236
249
  "timeoutFromFirstDetect" to processParams.timeoutFromFirstDetect,
237
250
  "timeoutFromFirstDocType" to processParams.timeoutFromFirstDocType,
@@ -278,6 +291,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
278
291
  "activityIndicatorColor" -> editor.setActivityIndicatorColor(v.toColor())
279
292
  "statusBackgroundColor" -> editor.setStatusBackgroundColor(v.toColor())
280
293
  "cameraPreviewBackgroundColor" -> editor.setCameraPreviewBackgroundColor(v.toColor())
294
+ "backgroundMaskColor" -> editor.setBackgroundMaskColor(v.toColor())
281
295
  "statusPositionMultiplier" -> editor.setStatusPositionMultiplier(v.toFloat())
282
296
  "resultStatusPositionMultiplier" -> editor.setResultStatusPositionMultiplier(v.toFloat())
283
297
  "toolbarSize" -> editor.setToolbarSize(v.toFloat())
@@ -288,6 +302,8 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, conte
288
302
  "cameraFramePortraitAspectRatio" -> editor.setCameraFramePortraitAspectRatio(v.toFloat())
289
303
  "cameraFrameCornerRadius" -> editor.setCameraFrameCornerRadius(v.toFloat())
290
304
  "livenessAnimationPositionMultiplier" -> editor.setLivenessAnimationPositionMultiplier(v.toFloat())
305
+ "nextPageAnimationStartDelay" -> editor.setNextPageAnimationStartDelay(v.toFloat())
306
+ "nextPageAnimationEndDelay" -> editor.setNextPageAnimationEndDelay(v.toFloat())
291
307
  "multipageAnimationFrontImage" -> editor.setMultipageAnimationFrontImage(v.toDrawable(context))
292
308
  "multipageAnimationBackImage" -> editor.setMultipageAnimationBackImage(v.toDrawable(context))
293
309
  "borderBackgroundImage" -> editor.setBorderBackgroundImage(v.toDrawable(context))
@@ -349,6 +365,7 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
349
365
  "activityIndicatorColor" to customization.activityIndicatorColor.toLong(),
350
366
  "statusBackgroundColor" to customization.statusBackgroundColor.toLong(),
351
367
  "cameraPreviewBackgroundColor" to customization.cameraPreviewBackgroundColor.toLong(),
368
+ "backgroundMaskColor" to customization.backgroundMaskColor.toLong(),
352
369
  "statusPositionMultiplier" to customization.statusPositionMultiplier,
353
370
  "resultStatusPositionMultiplier" to customization.resultStatusPositionMultiplier,
354
371
  "backgroundMaskAlpha" to customization.backgroundMaskAlpha,
@@ -359,6 +376,8 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
359
376
  "cameraFramePortraitAspectRatio" to customization.cameraFramePortraitAspectRatio,
360
377
  "cameraFrameCornerRadius" to customization.cameraFrameCornerRadius,
361
378
  "livenessAnimationPositionMultiplier" to customization.livenessAnimationPositionMultiplier,
379
+ "nextPageAnimationStartDelay" to customization.nextPageAnimationStartDelay,
380
+ "nextPageAnimationEndDelay" to customization.nextPageAnimationEndDelay,
362
381
  "multipageAnimationFrontImage" to customization.multipageAnimationFrontImage.toString(),
363
382
  "multipageAnimationBackImage" to customization.multipageAnimationBackImage.toString(),
364
383
  "borderBackgroundImage" to customization.borderBackgroundImage.toString(),
@@ -422,6 +441,10 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
422
441
  "applyAmendments" -> rfidScenario.isApplyAmendments = v as Boolean
423
442
  "autoSettings" -> rfidScenario.isAutoSettings = v as Boolean
424
443
  "proceedReadingAlways" -> rfidScenario.proceedReadingAlways = v as Boolean
444
+ "readDTC" -> rfidScenario.isReadDTC = v as Boolean
445
+ "mrzStrictCheck" -> rfidScenario.isMrzStrictCheck = v as Boolean
446
+ "loadCRLFromRemote" -> rfidScenario.isLoadCRLFromRemote = v as Boolean
447
+ "independentSODStatus" -> rfidScenario.isIndependentSODStatus = v as Boolean
425
448
  "signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
426
449
  "readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
427
450
  "onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
@@ -437,9 +460,11 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
437
460
  "mrz" -> rfidScenario.mrz = v as String
438
461
  "eSignPINDefault" -> rfidScenario.seteSignPINDefault(v as String)
439
462
  "eSignPINNewValue" -> rfidScenario.seteSignPINNewValue(v as String)
463
+ "cardAccess" -> rfidScenario.cardAccess = v as String
440
464
  "ePassportDataGroups" -> setDataGroups(rfidScenario.ePassportDataGroups(), v as JSONObject)
441
465
  "eIDDataGroups" -> setDataGroups(rfidScenario.eIDDataGroups(), v as JSONObject)
442
466
  "eDLDataGroups" -> setDataGroups(rfidScenario.eDLDataGroups(), v as JSONObject)
467
+ "dtcDataGroups" -> setDTCDataGroup(rfidScenario.DTCDataGroup(), v as JSONObject)
443
468
  }
444
469
  }
445
470
 
@@ -478,6 +503,10 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
478
503
  "applyAmendments" to rfidScenario.isApplyAmendments,
479
504
  "autoSettings" to rfidScenario.isAutoSettings,
480
505
  "proceedReadingAlways" to rfidScenario.proceedReadingAlways,
506
+ "readDTC" to rfidScenario.isReadDTC,
507
+ "mrzStrictCheck" to rfidScenario.isMrzStrictCheck,
508
+ "loadCRLFromRemote" to rfidScenario.isLoadCRLFromRemote,
509
+ "independentSODStatus" to rfidScenario.isIndependentSODStatus,
481
510
  "signManagementAction" to rfidScenario.signManagementAction,
482
511
  "readingBuffer" to rfidScenario.readingBuffer,
483
512
  "onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
@@ -493,9 +522,11 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
493
522
  "mrz" to rfidScenario.mrz,
494
523
  "eSignPINDefault" to rfidScenario.geteSignPINDefault(),
495
524
  "eSignPINNewValue" to rfidScenario.geteSignPINNewValue(),
525
+ "cardAccess" to rfidScenario.cardAccess,
496
526
  "ePassportDataGroups" to getDataGroups(rfidScenario.ePassportDataGroups()),
497
527
  "eIDDataGroups" to getDataGroups(rfidScenario.eIDDataGroups()),
498
- "eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups())
528
+ "eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups()),
529
+ "dtcDataGroups" to getDTCDataGroup(rfidScenario.DTCDataGroup())
499
530
  ).toJsonObject()
500
531
 
501
532
  fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v ->
@@ -564,6 +595,25 @@ fun getDataGroups(dataGroup: DataGroups): JSONObject {
564
595
  return result.toJsonObject()
565
596
  }
566
597
 
598
+ fun setDTCDataGroup(dataGroup: DTCDataGroup, opts: JSONObject) = opts.forEach { k, v ->
599
+ val value = v as Boolean
600
+ when (k) {
601
+ "DG17" -> dataGroup.isDG17 = value
602
+ "DG18" -> dataGroup.isDG18 = value
603
+ "DG22" -> dataGroup.isDG22 = value
604
+ "DG23" -> dataGroup.isDG23 = value
605
+ "DG24" -> dataGroup.isDG24 = value
606
+ }
607
+ }
608
+
609
+ fun getDTCDataGroup(dataGroup: DTCDataGroup) = mapOf(
610
+ "DG17" to dataGroup.isDG17,
611
+ "DG18" to dataGroup.isDG18,
612
+ "DG22" to dataGroup.isDG22,
613
+ "DG23" to dataGroup.isDG23,
614
+ "DG24" to dataGroup.isDG24,
615
+ ).toJsonObject()
616
+
567
617
  fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
568
618
  when (k) {
569
619
  "focusCheck" -> input.focusCheck = v as Boolean
@@ -576,6 +626,7 @@ fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
576
626
  "brightnessThreshold" -> input.brightnessThreshold = v.toDouble()
577
627
  "expectedPass" -> input.expectedPass = v.toIntArray()
578
628
  "glaresCheckParams" -> input.glaresCheckParams = glaresCheckParamsFromJSON(v as JSONObject)
629
+ "occlusionCheck" -> input.occlusionCheck = v as Boolean
579
630
  }
580
631
  }
581
632
 
@@ -590,6 +641,7 @@ fun getImageQA(input: ImageQA) = mapOf(
590
641
  "brightnessThreshold" to input.brightnessThreshold,
591
642
  "expectedPass" to input.expectedPass.generate(),
592
643
  "glaresCheckParams" to generateGlaresCheckParams(input.glaresCheckParams),
644
+ "occlusionCheck" to input.occlusionCheck,
593
645
  ).toJsonObject()
594
646
 
595
647
  fun setAuthenticityParams(input: AuthenticityParams, opts: JSONObject) = opts.forEach { k, v ->
@@ -608,6 +660,7 @@ fun setAuthenticityParams(input: AuthenticityParams, opts: JSONObject) = opts.fo
608
660
  "checkPhotoEmbedding" -> input.checkPhotoEmbedding = v as Boolean
609
661
  "checkPhotoComparison" -> input.checkPhotoComparison = v as Boolean
610
662
  "checkLetterScreen" -> input.checkLetterScreen = v as Boolean
663
+ "checkSecurityText" -> input.checkSecurityText = v as Boolean
611
664
  "livenessParams" -> {
612
665
  if (input.livenessParams == null) input.livenessParams = LivenessParams.defaultParams()
613
666
  setLivenessParams(input.livenessParams!!, v as JSONObject)
@@ -631,6 +684,7 @@ fun getAuthenticityParams(input: AuthenticityParams?) = input?.let {
631
684
  "checkPhotoEmbedding" to it.checkPhotoEmbedding,
632
685
  "checkPhotoComparison" to it.checkPhotoComparison,
633
686
  "checkLetterScreen" to it.checkLetterScreen,
687
+ "checkSecurityText" to it.checkSecurityText,
634
688
  "livenessParams" to getLivenessParams(it.livenessParams)
635
689
  ).toJsonObject()
636
690
  }
@@ -641,6 +695,8 @@ fun setLivenessParams(input: LivenessParams, opts: JSONObject) = opts.forEach {
641
695
  "checkMLI" -> input.checkMLI = v as Boolean
642
696
  "checkHolo" -> input.checkHolo = v as Boolean
643
697
  "checkED" -> input.checkED = v as Boolean
698
+ "checkBlackAndWhiteCopy" -> input.checkBlackAndWhiteCopy = v as Boolean
699
+ "checkDynaprint" -> input.checkDynaprint = v as Boolean
644
700
  }
645
701
  }
646
702
 
@@ -649,7 +705,9 @@ fun getLivenessParams(input: LivenessParams?) = input?.let {
649
705
  "checkOVI" to input.checkOVI,
650
706
  "checkMLI" to input.checkMLI,
651
707
  "checkHolo" to input.checkHolo,
652
- "checkED" to input.checkED
708
+ "checkED" to input.checkED,
709
+ "checkBlackAndWhiteCopy" to input.checkBlackAndWhiteCopy,
710
+ "checkDynaprint" to input.checkDynaprint,
653
711
  ).toJsonObject()
654
712
  }
655
713
 
@@ -1,5 +1,5 @@
1
1
  //
2
- // JSONConstructor.java
2
+ // JSONConstructor.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.enums.PDF417Info
26
26
  import com.regula.documentreader.api.enums.eGraphicFieldType
27
27
  import com.regula.documentreader.api.enums.eRFID_DataFile_Type
28
28
  import com.regula.documentreader.api.enums.eRPRM_Lights
29
+ import com.regula.documentreader.api.listener.NetworkInterceptorListener
29
30
  import com.regula.documentreader.api.params.AuthenticityParams
30
31
  import com.regula.documentreader.api.params.BackendProcessingConfig
31
32
  import com.regula.documentreader.api.params.BleDeviceConfig
@@ -46,6 +47,7 @@ import com.regula.documentreader.api.params.rfid.TccParams
46
47
  import com.regula.documentreader.api.params.rfid.authorization.PAAttribute
47
48
  import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer
48
49
  import com.regula.documentreader.api.params.rfid.authorization.TAChallenge
50
+ import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
49
51
  import com.regula.documentreader.api.params.rfid.dg.EDLDataGroups
50
52
  import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
51
53
  import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
@@ -105,6 +107,8 @@ import com.regula.documentreader.Convert.generateByteArray
105
107
  import org.json.JSONArray
106
108
  import org.json.JSONObject
107
109
 
110
+ val weakReferencesHolder = mutableListOf<Any>()
111
+
108
112
  fun generateCompletion(action: Int, results: DocumentReaderResults?, error: RegulaException?, context: Context?) = object : JSONObject() { init {
109
113
  put("action", action)
110
114
  if (listOf(
@@ -174,6 +178,7 @@ fun transactionInfoFromJSON(temp: JSONObject?): TransactionInfo? {
174
178
 
175
179
  if (input.has("transactionId")) result.transactionId = input.getString("transactionId")
176
180
  if (input.has("tag")) result.tag = input.getString("tag")
181
+ if (input.has("sessionLogFolder")) result.sessionLogFolder = input.getString("sessionLogFolder")
177
182
 
178
183
  return result
179
184
  }
@@ -185,6 +190,7 @@ fun generateTransactionInfo(temp: TransactionInfo?): JSONObject? {
185
190
 
186
191
  result.put("transactionId", input.transactionId)
187
192
  result.put("tag", input.tag)
193
+ result.put("sessionLogFolder", input.sessionLogFolder)
188
194
 
189
195
  return result
190
196
  }
@@ -243,6 +249,17 @@ fun generateDocReaderConfig(temp: DocReaderConfig?): JSONObject? {
243
249
  return result
244
250
  }
245
251
 
252
+ fun bleDeviceConfigFromJSON(input: JSONObject): BleDeviceConfig {
253
+ var result = BleDeviceConfig(bluetooth)
254
+
255
+ if (input.has("customDb")) result = BleDeviceConfig(bluetooth, byteArrayFromBase64(input.getString("customDb")))
256
+ if (input.has("licenseUpdate")) result.setLicenseUpdate(input.getBoolean("licenseUpdate"))
257
+ if (input.has("delayedNNLoad")) result.isDelayedNNLoad = input.getBoolean("delayedNNLoad")
258
+ if (input.has("blackList")) result.blackList = input.getJSONObject("blackList")
259
+
260
+ return result
261
+ }
262
+
246
263
  fun scannerConfigFromJSON(input: JSONObject): ScannerConfig {
247
264
  val builder = if (input.has("scenario")) ScannerConfig.Builder(input.getString("scenario"))
248
265
  else ScannerConfig.Builder(onlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig"))!!)
@@ -274,6 +291,7 @@ fun recognizeConfigFromJSON(input: JSONObject): RecognizeConfig {
274
291
  else RecognizeConfig.Builder(onlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig"))!!)
275
292
 
276
293
  if (input.has("oneShotIdentification")) builder.setOneShotIdentification(input.getBoolean("oneShotIdentification"))
294
+ if (input.has("dtc")) builder.setDTC(byteArrayFromBase64(input.getString("dtc"))!!)
277
295
  if (input.has("livePortrait")) builder.setLivePortrait(bitmapFromBase64(input.getString("livePortrait"))!!)
278
296
  if (input.has("extPortrait")) builder.setExtPortrait(bitmapFromBase64(input.getString("extPortrait"))!!)
279
297
  if (input.has("image")) builder.setBitmap(bitmapFromBase64(input.getString("image"))!!)
@@ -302,6 +320,7 @@ fun generateRecognizeConfig(temp: RecognizeConfig?): JSONObject? {
302
320
  result.put("scenario", input.scenario)
303
321
  result.put("onlineProcessingConfig", generateOnlineProcessingConfig(input.onlineProcessingConfig))
304
322
  result.put("oneShotIdentification", input.oneShotIdentification)
323
+ result.put("dtc", generateByteArray(input.dtc))
305
324
  result.put("livePortrait", bitmapToBase64(input.livePortrait))
306
325
  result.put("extPortrait", bitmapToBase64(input.extPortrait))
307
326
  result.put("image", bitmapToBase64(input.bitmap))
@@ -325,6 +344,7 @@ fun backendProcessingConfigFromJSON(temp: JSONObject?): BackendProcessingConfig?
325
344
  val result = BackendProcessingConfig(input.getString("url"))
326
345
  if (input.has("httpHeaders")) result.httpHeaders = stringMapFromJson(input.getJSONObject("httpHeaders"))
327
346
  if (input.has("rfidServerSideChipVerification")) result.rfidServerSideChipVerification = input.getBoolean("rfidServerSideChipVerification")
347
+ if (input.has("timeoutConnection")) result.timeoutConnection = input.getDouble("timeoutConnection")
328
348
 
329
349
  return result
330
350
  }
@@ -337,6 +357,7 @@ fun generateBackendProcessingConfig(temp: BackendProcessingConfig?): JSONObject?
337
357
  result.put("url", input.url)
338
358
  result.put("httpHeaders", generateStringMap(input.httpHeaders))
339
359
  result.put("rfidServerSideChipVerification", input.rfidServerSideChipVerification)
360
+ result.put("timeoutConnection", input.timeoutConnection)
340
361
 
341
362
  return result
342
363
  }
@@ -350,6 +371,11 @@ fun onlineProcessingConfigFromJSON(temp: JSONObject?): OnlineProcessingConfig? {
350
371
  if (input.has("url")) builder.setUrl(input.getString("url"))
351
372
  if (input.has("imageCompressionQuality")) builder.setImageCompressionQuality(input.getDouble("imageCompressionQuality").toFloat())
352
373
  if (input.has("processParams")) builder.setProcessParams(processParamFromJSON(input.getJSONObject("processParams")))
374
+ if (input.has("requestHeaders")) {
375
+ val listener = NetworkInterceptorListener { input.getJSONObject("requestHeaders").forEach { k, v -> it.setRequestProperty(k, v as String) } }
376
+ weakReferencesHolder.add(listener)
377
+ builder.setNetworkInterceptorListener(listener)
378
+ }
353
379
 
354
380
  return builder.build()
355
381
  }
@@ -508,6 +534,14 @@ fun eIDDataGroupsFromJSON(input: JSONObject): EIDDataGroups {
508
534
 
509
535
  fun generateEIDDataGroups(input: EIDDataGroups): JSONObject = getDataGroups(input)
510
536
 
537
+ fun dtcDataGroupFromJSON(input: JSONObject): DTCDataGroup {
538
+ val result = DTCDataGroup()
539
+ setDTCDataGroup(result, input)
540
+ return result
541
+ }
542
+
543
+ fun generateDTCDataGroup(input: DTCDataGroup): JSONObject = getDTCDataGroup(input)
544
+
511
545
  fun rfidScenarioFromJSON(input: JSONObject): RfidScenario {
512
546
  val result = RfidScenario()
513
547
  setRfidScenario(result, input)
@@ -573,18 +607,6 @@ fun generateTypeface(temp: Typeface?, size: Int? = null): JSONObject? {
573
607
  return result
574
608
  }
575
609
 
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
610
  fun imageInputDataFromJSON(temp: JSONObject?): ImageInputData? {
589
611
  if (temp == null || !temp.has("image")) return null
590
612
  val input: JSONObject = temp
@@ -1701,6 +1723,7 @@ fun generateDocumentReaderAuthenticityResult(temp: DocumentReaderAuthenticityRes
1701
1723
  temp ?: return null
1702
1724
  val input: DocumentReaderAuthenticityResult = temp
1703
1725
 
1726
+ @Suppress("DEPRECATION")
1704
1727
  result.put("status", input.status)
1705
1728
  result.put("checks", generateList(input.checks, ::generateDocumentReaderAuthenticityCheck, context))
1706
1729
 
@@ -2168,7 +2191,8 @@ fun documentReaderResultsFromJSON(temp: JSONObject?): DocumentReaderResults? {
2168
2191
  result.documentType = listFromJSON(input.optJSONArray("documentType"), ::documentReaderDocumentTypeFromJSON)!!
2169
2192
  result.status = documentReaderResultsStatusFromJSON(input.optJSONObject("status"))!!
2170
2193
  result.vdsncData = vdsncDataFromJSON(input.optJSONObject("vdsncData")!!)
2171
- result.transactionInfo = transactionInfoFromJSON(input.optJSONObject("transactionInfo"))
2194
+ result.dtcData = input.getString("dtcData")
2195
+ result.transactionInfo = transactionInfoFromJSON(input.optJSONObject("transactionInfo"))!!
2172
2196
 
2173
2197
  return result
2174
2198
  }
@@ -2196,6 +2220,7 @@ fun generateDocumentReaderResults(temp: DocumentReaderResults?, context: Context
2196
2220
  result.put("documentType", generateList(input.documentType, ::generateDocumentReaderDocumentType))
2197
2221
  result.put("status", generateDocumentReaderResultsStatus(input.status))
2198
2222
  result.put("vdsncData", generateVDSNCData(input.vdsncData))
2223
+ result.put("dtcData", input.dtcData)
2199
2224
  result.put("transactionInfo", generateTransactionInfo(input.transactionInfo))
2200
2225
 
2201
2226
  return result