@regulaforensics/cordova-plugin-document-reader-api 7.6.674-nightly → 8.1.61-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.
@@ -0,0 +1,75 @@
1
+ spec:
2
+ inputs:
3
+ stage:
4
+ default: reports
5
+ image:
6
+ default: ubuntu:22.04
7
+ ignore_vulnerabilities:
8
+ default: "false"
9
+ sast_report_file:
10
+ default: gl-sast-report.json
11
+ secret_detection_report_file:
12
+ default: gl-secret-detection-report.json
13
+ dependency_scanning_report_file:
14
+ default: gl-dependency-scanning-report.json
15
+ ---
16
+
17
+ view reports:
18
+ image: $[[ inputs.image ]]
19
+ stage: $[[ inputs.stage ]]
20
+ variables:
21
+ IGNORE_VULNERABILITIES: $[[ inputs.ignore_vulnerabilities ]]
22
+ SAST_REPORT_FILE: $[[ inputs.sast_report_file ]]
23
+ SECRET_DETECTION_REPORT_FILE: $[[ inputs.secret_detection_report_file ]]
24
+ DEPENDENCY_SCANNING_REPORT_FILE: $[[ inputs.dependency_scanning_report_file ]]
25
+ RED: \033[0;31m
26
+ YELLOW: \033[1;33m
27
+ GREEN: \033[0;32m
28
+ NC: \033[0m
29
+ needs:
30
+ - job: semgrep-sast
31
+ artifacts: true
32
+ - job: secret_detection
33
+ artifacts: true
34
+ - job: gemnasium-dependency_scanning
35
+ artifacts: true
36
+ rules:
37
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
38
+ script:
39
+ - ls -la
40
+ - apt update && apt install -y jq
41
+ - |
42
+ for f in SAST_REPORT_FILE SECRET_DETECTION_REPORT_FILE DEPENDENCY_SCANNING_REPORT_FILE
43
+ do
44
+ if [[ -f "${!f}" ]]
45
+ then
46
+ echo -e "${GREEN}File ${!f} exists, adding report${NC}"
47
+ r=${f/%_FILE}
48
+ declare $r="$(cat ${!f} | jq 'select(.vulnerabilities != []).vulnerabilities')"
49
+ if [[ ! -z "${!r}" ]]
50
+ then
51
+ VULNERABILITIES_FOUND=true
52
+ echo -e "${RED}Found $r vulnerabilities${NC}"
53
+ echo "${!r}"
54
+ echo
55
+ fi
56
+ else
57
+ echo -e "${YELLOW}File ${!f} doesn't exist, skipping${NC}"
58
+ fi
59
+ done
60
+
61
+ if [[ "$VULNERABILITIES_FOUND" == true ]]
62
+ then
63
+ if [[ "$IGNORE_VULNERABILITIES" == true ]]
64
+ then
65
+ echo -e "${GREEN}All found vulnerabilities were ignored due to IGNORE_VULNERABILITIES=true${NC}"
66
+ exit 0
67
+ else
68
+ echo -e "${RED}Vulnerabilities found, please see reports above${NC}"
69
+ exit 1
70
+ fi
71
+ fi
72
+
73
+ echo -e "${GREEN}No vulnerabilities found${NC}"
74
+
75
+ exit 0
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,49 @@
1
+ stages:
2
+ - test
3
+ - reports
4
+
5
+ include:
6
+ - template: Jobs/SAST.gitlab-ci.yml
7
+ - template: Jobs/Secret-Detection.gitlab-ci.yml
8
+ - template: Jobs/Dependency-Scanning.gitlab-ci.yml
9
+ - local: .gitlab/report.yaml
10
+ rules:
11
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
12
+ inputs:
13
+ stage: reports
14
+ image: ubuntu:22.04
15
+ ignore_vulnerabilities: "false"
16
+ sast_report_file: gl-sast-report.json
17
+ secret_detection_report_file: gl-secret-detection-report.json
18
+ dependency_scanning_report_file: gl-dependency-scanning-report.json
19
+
20
+ trivy scan:
21
+ stage: test
22
+ image: aquasec/trivy
23
+ rules:
24
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
25
+ script:
26
+ - trivy fs --severity CRITICAL,HIGH,MEDIUM,LOW --ignore-unfixed --db-repository container-registry.regula.local:80/aquasecurity/trivy-db:2 --exit-code 1 .
27
+
28
+ semgrep-sast:
29
+ rules:
30
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
31
+ artifacts:
32
+ paths:
33
+ - gl-sast-report.json
34
+
35
+ secret_detection:
36
+ rules:
37
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
38
+ artifacts:
39
+ paths:
40
+ - gl-secret-detection-report.json
41
+
42
+ gemnasium-dependency_scanning:
43
+ variables:
44
+ DS_MAX_DEPTH: -1
45
+ rules:
46
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
47
+ artifacts:
48
+ paths:
49
+ - gl-dependency-scanning-report.json
@@ -13,8 +13,8 @@
13
13
  "author": "Regula Forensics Inc.",
14
14
  "license": "commercial",
15
15
  "dependencies": {
16
- "@regulaforensics/cordova-plugin-document-reader-api": "7.6.674-nightly",
17
- "@regulaforensics/cordova-plugin-document-reader-core-fullauthrfid": "7.6.892-nightly",
16
+ "@regulaforensics/cordova-plugin-document-reader-api": "8.1.61-nightly",
17
+ "@regulaforensics/cordova-plugin-document-reader-core-fullauthrfid": "8.1.78-nightly",
18
18
  "cordova-android": "13.0.0",
19
19
  "cordova-ios": "7.1.1",
20
20
  "cordova-plugin-add-swift-support": "2.0.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regulaforensics/cordova-plugin-document-reader-api",
3
- "version": "7.6.674-nightly",
3
+ "version": "8.1.61-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",
@@ -11,17 +11,13 @@
11
11
  },
12
12
  "max_body_size": "1000mb",
13
13
  "keywords": [
14
- "cordova",
15
- "documentreader",
16
- "reader",
17
- "scanner",
18
- "regula"
14
+ "cordova", "documentreader", "reader", "scanner", "regula"
19
15
  ],
20
16
  "author": "RegulaForensics",
21
17
  "license": "commercial",
22
18
  "repository": {
23
- "type": "git",
24
- "url": "https://github.com/regulaforensics/DocumentReader-Cordova-Plugin.git"
19
+ "type": "git",
20
+ "url": "https://github.com/regulaforensics/DocumentReader-Cordova-Plugin.git"
25
21
  },
26
22
  "homepage": "https://mobile.regulaforensics.com",
27
23
  "publishConfig": {
package/plugin.xml CHANGED
@@ -1,6 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-document-reader-api" version="7.6.674-nightly"
3
- xmlns="http://apache.org/cordova/ns/plugins/1.0">
2
+ <plugin id="@regulaforensics/cordova-plugin-document-reader-api" version="8.1.61-nightly" xmlns="http://apache.org/cordova/ns/plugins/1.0">
4
3
  <name>DocumentReaderApi</name>
5
4
  <description>Cordova plugin Document reader api</description>
6
5
  <license>commercial</license>
@@ -15,7 +14,7 @@
15
14
  <feature name="DocumentReader">
16
15
  <param name="ios-package" value="RGLWDocumentReader" />
17
16
  </feature>
18
- <preference name="deployment-target" value="12.0" />
17
+ <preference name="deployment-target" value="13.0" />
19
18
  </config-file>
20
19
  <header-file src="src/ios/RGLWDocumentReader.h" />
21
20
  <source-file src="src/ios/RGLWDocumentReader.m" />
@@ -25,9 +24,10 @@
25
24
  <source-file src="src/ios/RGLWConfig.m" />
26
25
  <podspec>
27
26
  <config>
27
+ <source url="https://github.com/CocoaPods/Specs.git"/>
28
28
  </config>
29
29
  <pods>
30
- <pod name="DocumentReaderNightly" spec="7.6.4234" />
30
+ <pod name="DocumentReaderNightly" spec="8.1.4473" />
31
31
  </pods>
32
32
  </podspec>
33
33
  </platform>
@@ -22,11 +22,10 @@ import android.content.pm.PackageManager.PERMISSION_GRANTED
22
22
  import android.os.Build
23
23
  import android.os.IBinder
24
24
  import android.provider.Settings
25
- import androidx.core.app.ActivityCompat.requestPermissions
26
25
  import androidx.core.content.ContextCompat.checkSelfPermission
27
- import com.regula.documentreader.api.ble.BLEWrapper
28
- import com.regula.documentreader.api.ble.BleWrapperCallback
29
- 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
30
29
  import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelper.BLE_ACCESS_PERMISSION
31
30
  import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
32
31
  import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
@@ -67,9 +66,9 @@ fun connectBluetoothDevice(callback: Callback) {
67
66
  Timer().schedule(timer, SEARCHING_TIMEOUT)
68
67
 
69
68
  // start searching devices
70
- val bleIntent = Intent(activity, RegulaBleService::class.java)
71
- activity.startService(bleIntent)
72
- activity.bindService(bleIntent, object : ServiceConnection {
69
+ val bleIntent = Intent(context, RegulaBleService::class.java)
70
+ context.startService(bleIntent)
71
+ context.bindService(bleIntent, object : ServiceConnection {
73
72
  override fun onServiceConnected(name: ComponentName, service: IBinder) {
74
73
  bluetooth = (service as RegulaBleService.LocalBinder).service.bleManager
75
74
  bluetooth.addCallback(object : BleWrapperCallback() {
@@ -88,7 +87,7 @@ fun connectBluetoothDevice(callback: Callback) {
88
87
 
89
88
  fun onRequestPermissionsResult(
90
89
  requestCode: Int,
91
- permissions: Array<out String>,
90
+ permissions: Array<String>,
92
91
  grantResults: IntArray
93
92
  ): Boolean {
94
93
  if (requestCode != BLE_ACCESS_PERMISSION || permissions.isEmpty()) return false
@@ -117,7 +116,7 @@ fun onActivityResult(requestCode: Int, rc: Int, @Suppress("UNUSED_PARAMETER") da
117
116
  }
118
117
 
119
118
  fun isBluetoothSettingsReady(activity: Activity): Boolean {
120
- deniedBluetoothPermissions(activity)?.let {
119
+ deniedBluetoothPermissions()?.let {
121
120
  requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
122
121
  return false
123
122
  }
@@ -132,31 +131,28 @@ fun isBluetoothSettingsReady(activity: Activity): Boolean {
132
131
  return true
133
132
  }
134
133
 
135
- fun deniedBluetoothPermissions(activity: Activity): Array<String>? {
134
+ fun deniedBluetoothPermissions(): Array<String>? {
136
135
  val result = mutableListOf<String>()
137
136
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
138
- result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_SCAN))
139
- result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_CONNECT))
137
+ result.addAll(deniedBluetoothPermission(BLUETOOTH_SCAN))
138
+ result.addAll(deniedBluetoothPermission(BLUETOOTH_CONNECT))
140
139
  } else
141
- result.addAll(deniedBluetoothPermission(activity, ACCESS_FINE_LOCATION))
140
+ result.addAll(deniedBluetoothPermission(ACCESS_FINE_LOCATION))
142
141
  return result.let { if (it.size > 0) it.toTypedArray() else null }
143
142
  }
144
143
 
145
- fun deniedBluetoothPermission(
146
- activity: Activity,
147
- permission: String
148
- ): Array<String> {
149
- if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
144
+ fun deniedBluetoothPermission(permission: String): Array<String> {
145
+ if (checkSelfPermission(context, permission) != PERMISSION_GRANTED)
150
146
  return arrayOf(permission)
151
147
  return arrayOf()
152
148
  }
153
149
 
154
150
  fun requestEnableBluetooth(activity: Activity) {
155
151
  val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
156
- activity.startActivityForResult(enableIntent, INTENT_REQUEST_ENABLE_BLUETOOTH)
152
+ startActivityForResult(activity, enableIntent, INTENT_REQUEST_ENABLE_BLUETOOTH)
157
153
  }
158
154
 
159
155
  fun requestEnableLocationService(activity: Activity) {
160
156
  val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
161
- activity.startActivityForResult(myIntent, INTENT_REQUEST_ENABLE_LOCATION)
157
+ startActivityForResult(activity, myIntent, INTENT_REQUEST_ENABLE_LOCATION)
162
158
  }
@@ -6,6 +6,8 @@
6
6
  // Copyright © 2023 Regula. All rights reserved.
7
7
  //
8
8
 
9
+ @file:Suppress("EnumValuesSoftDeprecate")
10
+
9
11
  package cordova.plugin.documentreader
10
12
 
11
13
  import android.content.Context
@@ -53,6 +55,7 @@ fun setFunctionality(functionality: Functionality, opts: JSONObject) = opts.forE
53
55
  "isCameraTorchCheckDisabled" -> editor.setIsCameraTorchCheckDisabled(v as Boolean)
54
56
  "recordScanningProcess" -> editor.setDoRecordProcessingVideo(v as Boolean)
55
57
  "manualMultipageMode" -> editor.setManualMultipageMode(v as Boolean)
58
+ "torchTurnedOn" -> editor.setTorchTurnedOn(v as Boolean)
56
59
  "showCaptureButtonDelayFromDetect" -> editor.setShowCaptureButtonDelayFromDetect(v.toLong())
57
60
  "showCaptureButtonDelayFromStart" -> editor.setShowCaptureButtonDelayFromStart(v.toLong())
58
61
  "orientation" -> editor.setOrientation(v.toInt())
@@ -86,6 +89,7 @@ fun getFunctionality(functionality: Functionality) = mapOf(
86
89
  "isCameraTorchCheckDisabled" to functionality.isCameraTorchCheckDisabled,
87
90
  "recordScanningProcess" to functionality.doRecordProcessingVideo(),
88
91
  "manualMultipageMode" to functionality.isManualMultipageMode,
92
+ "torchTurnedOn" to functionality.isTorchTurnedOn,
89
93
  "showCaptureButtonDelayFromDetect" to functionality.showCaptureButtonDelayFromDetect,
90
94
  "showCaptureButtonDelayFromStart" to functionality.showCaptureButtonDelayFromStart,
91
95
  "orientation" to functionality.orientation,
@@ -140,6 +144,7 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
140
144
  "strictBarcodeDigitalSignatureCheck" -> processParams.strictBarcodeDigitalSignatureCheck = v as Boolean
141
145
  "selectLongestNames" -> processParams.selectLongestNames = v as Boolean
142
146
  "generateDTCVC" -> processParams.generateDTCVC = v as Boolean
147
+ "strictDLCategoryExpiry" -> processParams.strictDLCategoryExpiry = v as Boolean
143
148
  "measureSystem" -> processParams.measureSystem = v.toInt()
144
149
  "barcodeParserType" -> processParams.barcodeParserType = v.toInt()
145
150
  "perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
@@ -158,7 +163,6 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
158
163
  "dateFormat" -> processParams.dateFormat = v as String
159
164
  "scenario" -> processParams.scenario = v as String
160
165
  "captureButtonScenario" -> processParams.captureButtonScenario = v as String
161
- "sessionLogFolder" -> processParams.sessionLogFolder = v as String
162
166
  "timeout" -> processParams.timeout = v.toDouble()
163
167
  "timeoutFromFirstDetect" -> processParams.timeoutFromFirstDetect = v.toDouble()
164
168
  "timeoutFromFirstDocType" -> processParams.timeoutFromFirstDocType = v.toDouble()
@@ -222,6 +226,7 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
222
226
  "strictBarcodeDigitalSignatureCheck" to processParams.strictBarcodeDigitalSignatureCheck,
223
227
  "selectLongestNames" to processParams.selectLongestNames,
224
228
  "generateDTCVC" to processParams.generateDTCVC,
229
+ "strictDLCategoryExpiry" to processParams.strictDLCategoryExpiry,
225
230
  "measureSystem" to processParams.measureSystem,
226
231
  "barcodeParserType" to processParams.barcodeParserType,
227
232
  "perspectiveAngle" to processParams.perspectiveAngle,
@@ -240,7 +245,6 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
240
245
  "dateFormat" to processParams.dateFormat,
241
246
  "scenario" to processParams.scenario,
242
247
  "captureButtonScenario" to processParams.captureButtonScenario,
243
- "sessionLogFolder" to processParams.sessionLogFolder,
244
248
  "timeout" to processParams.timeout,
245
249
  "timeoutFromFirstDetect" to processParams.timeoutFromFirstDetect,
246
250
  "timeoutFromFirstDocType" to processParams.timeoutFromFirstDocType,
@@ -439,6 +443,8 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
439
443
  "proceedReadingAlways" -> rfidScenario.proceedReadingAlways = v as Boolean
440
444
  "readDTC" -> rfidScenario.isReadDTC = v as Boolean
441
445
  "mrzStrictCheck" -> rfidScenario.isMrzStrictCheck = v as Boolean
446
+ "loadCRLFromRemote" -> rfidScenario.isLoadCRLFromRemote = v as Boolean
447
+ "independentSODStatus" -> rfidScenario.isIndependentSODStatus = v as Boolean
442
448
  "signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
443
449
  "readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
444
450
  "onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
@@ -458,7 +464,7 @@ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach
458
464
  "ePassportDataGroups" -> setDataGroups(rfidScenario.ePassportDataGroups(), v as JSONObject)
459
465
  "eIDDataGroups" -> setDataGroups(rfidScenario.eIDDataGroups(), v as JSONObject)
460
466
  "eDLDataGroups" -> setDataGroups(rfidScenario.eDLDataGroups(), v as JSONObject)
461
- "dtcDataGroups" -> setDataGroups(rfidScenario.DTCDataGroup(), v as JSONObject)
467
+ "dtcDataGroups" -> setDTCDataGroup(rfidScenario.DTCDataGroup(), v as JSONObject)
462
468
  }
463
469
  }
464
470
 
@@ -499,6 +505,8 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
499
505
  "proceedReadingAlways" to rfidScenario.proceedReadingAlways,
500
506
  "readDTC" to rfidScenario.isReadDTC,
501
507
  "mrzStrictCheck" to rfidScenario.isMrzStrictCheck,
508
+ "loadCRLFromRemote" to rfidScenario.isLoadCRLFromRemote,
509
+ "independentSODStatus" to rfidScenario.isIndependentSODStatus,
502
510
  "signManagementAction" to rfidScenario.signManagementAction,
503
511
  "readingBuffer" to rfidScenario.readingBuffer,
504
512
  "onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
@@ -518,7 +526,7 @@ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
518
526
  "ePassportDataGroups" to getDataGroups(rfidScenario.ePassportDataGroups()),
519
527
  "eIDDataGroups" to getDataGroups(rfidScenario.eIDDataGroups()),
520
528
  "eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups()),
521
- "dtcDataGroups" to getDataGroups(rfidScenario.DTCDataGroup())
529
+ "dtcDataGroups" to getDTCDataGroup(rfidScenario.DTCDataGroup())
522
530
  ).toJsonObject()
523
531
 
524
532
  fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v ->
@@ -552,15 +560,6 @@ fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v
552
560
  "DG20" -> dataGroup.isDG20 = value
553
561
  "DG21" -> dataGroup.isDG21 = value
554
562
  }
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
- }
564
563
  }
565
564
 
566
565
  fun getDataGroups(dataGroup: DataGroups): JSONObject {
@@ -593,18 +592,28 @@ fun getDataGroups(dataGroup: DataGroups): JSONObject {
593
592
  result["DG20"] = dataGroup.isDG20
594
593
  result["DG21"] = dataGroup.isDG21
595
594
  }
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
- }
605
595
  return result.toJsonObject()
606
596
  }
607
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
+
608
617
  fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
609
618
  when (k) {
610
619
  "focusCheck" -> input.focusCheck = v as Boolean
@@ -617,6 +626,7 @@ fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
617
626
  "brightnessThreshold" -> input.brightnessThreshold = v.toDouble()
618
627
  "expectedPass" -> input.expectedPass = v.toIntArray()
619
628
  "glaresCheckParams" -> input.glaresCheckParams = glaresCheckParamsFromJSON(v as JSONObject)
629
+ "occlusionCheck" -> input.occlusionCheck = v as Boolean
620
630
  }
621
631
  }
622
632
 
@@ -631,6 +641,7 @@ fun getImageQA(input: ImageQA) = mapOf(
631
641
  "brightnessThreshold" to input.brightnessThreshold,
632
642
  "expectedPass" to input.expectedPass.generate(),
633
643
  "glaresCheckParams" to generateGlaresCheckParams(input.glaresCheckParams),
644
+ "occlusionCheck" to input.occlusionCheck,
634
645
  ).toJsonObject()
635
646
 
636
647
  fun setAuthenticityParams(input: AuthenticityParams, opts: JSONObject) = opts.forEach { k, v ->
@@ -649,6 +660,7 @@ fun setAuthenticityParams(input: AuthenticityParams, opts: JSONObject) = opts.fo
649
660
  "checkPhotoEmbedding" -> input.checkPhotoEmbedding = v as Boolean
650
661
  "checkPhotoComparison" -> input.checkPhotoComparison = v as Boolean
651
662
  "checkLetterScreen" -> input.checkLetterScreen = v as Boolean
663
+ "checkSecurityText" -> input.checkSecurityText = v as Boolean
652
664
  "livenessParams" -> {
653
665
  if (input.livenessParams == null) input.livenessParams = LivenessParams.defaultParams()
654
666
  setLivenessParams(input.livenessParams!!, v as JSONObject)
@@ -672,6 +684,7 @@ fun getAuthenticityParams(input: AuthenticityParams?) = input?.let {
672
684
  "checkPhotoEmbedding" to it.checkPhotoEmbedding,
673
685
  "checkPhotoComparison" to it.checkPhotoComparison,
674
686
  "checkLetterScreen" to it.checkLetterScreen,
687
+ "checkSecurityText" to it.checkSecurityText,
675
688
  "livenessParams" to getLivenessParams(it.livenessParams)
676
689
  ).toJsonObject()
677
690
  }
@@ -682,6 +695,8 @@ fun setLivenessParams(input: LivenessParams, opts: JSONObject) = opts.forEach {
682
695
  "checkMLI" -> input.checkMLI = v as Boolean
683
696
  "checkHolo" -> input.checkHolo = v as Boolean
684
697
  "checkED" -> input.checkED = v as Boolean
698
+ "checkBlackAndWhiteCopy" -> input.checkBlackAndWhiteCopy = v as Boolean
699
+ "checkDynaprint" -> input.checkDynaprint = v as Boolean
685
700
  }
686
701
  }
687
702
 
@@ -690,7 +705,9 @@ fun getLivenessParams(input: LivenessParams?) = input?.let {
690
705
  "checkOVI" to input.checkOVI,
691
706
  "checkMLI" to input.checkMLI,
692
707
  "checkHolo" to input.checkHolo,
693
- "checkED" to input.checkED
708
+ "checkED" to input.checkED,
709
+ "checkBlackAndWhiteCopy" to input.checkBlackAndWhiteCopy,
710
+ "checkDynaprint" to input.checkDynaprint,
694
711
  ).toJsonObject()
695
712
  }
696
713
 
@@ -1,8 +1,8 @@
1
1
  package cordova.plugin.documentreader
2
2
 
3
- import android.annotation.SuppressLint
4
3
  import android.app.Activity
5
4
  import android.app.PendingIntent
5
+ import android.content.Context
6
6
  import android.content.Intent
7
7
  import android.content.IntentFilter
8
8
  import android.nfc.NfcAdapter
@@ -47,31 +47,16 @@ import org.apache.cordova.PluginResult
47
47
  import org.json.JSONArray
48
48
  import org.json.JSONObject
49
49
 
50
- class DocumentReader : CordovaPlugin() {
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
-
63
- override fun execute(action: String, args: JSONArray, callbackContext: CallbackContext): Boolean {
64
- activity = cordova.activity
65
- exec(args, callbackContext)
66
- return true
67
- }
68
- }
69
-
70
- fun myOnActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
71
- onActivityResult(requestCode, resultCode, intent)
72
- }
50
+ lateinit var callbackContext: CallbackContext
73
51
 
74
- fun myOnRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?) = onRequestPermissionsResult(requestCode, permissions!!, grantResults!!)
52
+ lateinit var args: JSONArray
53
+ lateinit var binding: CordovaPlugin
54
+ val context: Context
55
+ get() = binding.cordova.context
56
+ val activity: Activity
57
+ get() = binding.cordova.activity
58
+ val lifecycle: Lifecycle
59
+ get() = (activity as AppCompatActivity).lifecycle
75
60
 
76
61
  fun sendEvent(event: String, data: Any? = "") {
77
62
  // These events are not working in cordova and ionic because they don't have a method
@@ -99,10 +84,34 @@ fun <T> argsNullable(index: Int): T? = if (args.get(index).toString() != "null")
99
84
  args.get(index) as T
100
85
  } else null
101
86
 
102
- lateinit var args: JSONArray
103
- lateinit var callbackContext: CallbackContext
104
- val lifecycle: Lifecycle
105
- get() = (activity as AppCompatActivity).lifecycle
87
+ class DocumentReader : CordovaPlugin() {
88
+ init {
89
+ binding = this
90
+ }
91
+
92
+ override fun onNewIntent(intent: Intent) {
93
+ newIntent(intent)
94
+ }
95
+
96
+ override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
97
+ myOnActivityResult(requestCode, resultCode, intent)
98
+ }
99
+
100
+ @Suppress("OVERRIDE_DEPRECATION")
101
+ override fun onRequestPermissionResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
102
+ myOnRequestPermissionsResult(requestCode, permissions, grantResults)
103
+ }
104
+
105
+ override fun execute(action: String, args: JSONArray, callbackContext: CallbackContext): Boolean {
106
+ exec(args, callbackContext)
107
+ return true
108
+ }
109
+ }
110
+
111
+ fun requestPermissions(@Suppress("UNUSED_PARAMETER") activity: Activity, permissions: Array<String>, requestCode: Int) = binding.cordova.requestPermissions(binding, requestCode, permissions)
112
+ fun startActivityForResult(@Suppress("UNUSED_PARAMETER") activity: Activity, intent: Intent, requestCode: Int) = binding.cordova.startActivityForResult(binding, intent, requestCode)
113
+ fun myOnRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) = onRequestPermissionsResult(requestCode, permissions, grantResults)
114
+ fun myOnActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) = onActivityResult(requestCode, resultCode, intent)
106
115
 
107
116
  fun exec(arguments: JSONArray, tempContext: CallbackContext) {
108
117
  args = arguments
@@ -192,14 +201,6 @@ interface Callback {
192
201
  fun error(message: String)
193
202
  }
194
203
 
195
- @SuppressLint("StaticFieldLeak")
196
- lateinit var activity: Activity
197
- lateinit var lifecycleObserver: LifecycleEventObserver
198
- val context
199
- get() = activity
200
-
201
- var backgroundRFIDEnabled = false
202
-
203
204
  const val eventCompletion = "completion"
204
205
  const val eventDatabaseProgress = "database_progress"
205
206
 
@@ -507,6 +508,9 @@ fun newIntent(intent: Intent): Boolean {
507
508
  return true
508
509
  }
509
510
 
511
+ var backgroundRFIDEnabled = false
512
+ lateinit var lifecycleObserver: LifecycleEventObserver
513
+
510
514
  fun startForegroundDispatch() {
511
515
  backgroundRFIDEnabled = true
512
516
  val filters: Array<IntentFilter?> = arrayOfNulls(1)
@@ -514,9 +518,9 @@ fun startForegroundDispatch() {
514
518
  filters[0]!!.addAction(NfcAdapter.ACTION_TECH_DISCOVERED)
515
519
  filters[0]!!.addCategory(Intent.CATEGORY_DEFAULT)
516
520
  val techList = arrayOf(arrayOf("android.nfc.tech.IsoDep"))
517
- val intent = Intent(context, context.javaClass)
521
+ val intent = Intent(activity, activity.javaClass)
518
522
  val flag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_MUTABLE else 0
519
- val pendingIntent = PendingIntent.getActivity(context, 0, intent, flag)
523
+ val pendingIntent = PendingIntent.getActivity(activity, 0, intent, flag)
520
524
 
521
525
  if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED))
522
526
  enableForegroundDispatch(pendingIntent, filters, techList)
@@ -527,7 +531,7 @@ fun startForegroundDispatch() {
527
531
  else -> Unit
528
532
  }
529
533
  }
530
- context.runOnUiThread { lifecycle.addObserver(lifecycleObserver) }
534
+ activity.runOnUiThread { lifecycle.addObserver(lifecycleObserver) }
531
535
  }
532
536
 
533
537
  fun enableForegroundDispatch(
@@ -536,15 +540,15 @@ fun enableForegroundDispatch(
536
540
  techList: Array<Array<String>>
537
541
  ) = NfcAdapter.getDefaultAdapter(context).enableForegroundDispatch(activity, pendingIntent, filters, techList)
538
542
 
539
- fun disableForegroundDispatch() = NfcAdapter.getDefaultAdapter(activity).disableForegroundDispatch(activity)
543
+ fun disableForegroundDispatch() = NfcAdapter.getDefaultAdapter(context).disableForegroundDispatch(activity)
540
544
 
541
545
  fun stopBackgroundRFID() {
542
546
  if (!backgroundRFIDEnabled) return
543
547
  backgroundRFIDEnabled = false
544
548
  if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED))
545
549
  disableForegroundDispatch()
546
- context.runOnUiThread { lifecycle.removeObserver(lifecycleObserver) }
550
+ activity.runOnUiThread { lifecycle.removeObserver(lifecycleObserver) }
547
551
  }
548
552
 
549
553
  // Weak references
550
- var localizationCallbacks: LocalizationCallbacks? = null
554
+ var localizationCallbacks: LocalizationCallbacks? = null