@regulaforensics/react-native-document-reader-api 8.4.328-nightly → 8.4.371-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/RNDocumentReaderApi.podspec +1 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +8 -0
- package/android/src/main/java/com/regula/plugin/documentreader/JSONConstructor.kt +346 -40
- package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +69 -12
- package/android/src/main/java/com/regula/plugin/documentreader/Utils.kt +62 -0
- package/example/package-lock.json +12 -12
- package/example/package.json +2 -2
- package/index.d.ts +369 -4
- package/index.js +248 -4
- package/ios/RGLWConfig.m +9 -2
- package/ios/RGLWJSONConstructor.h +19 -0
- package/ios/RGLWJSONConstructor.m +349 -0
- package/ios/RGLWMain.m +49 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@file:SuppressLint("MissingPermission")
|
|
2
|
+
@file:Suppress("EnumValuesSoftDeprecate")
|
|
2
3
|
|
|
3
4
|
package com.regula.plugin.documentreader
|
|
4
5
|
|
|
@@ -16,6 +17,7 @@ import com.regula.documentreader.api.DocumentReader.Instance
|
|
|
16
17
|
import com.regula.documentreader.api.completions.IDocumentReaderCompletion
|
|
17
18
|
import com.regula.documentreader.api.completions.IDocumentReaderInitCompletion
|
|
18
19
|
import com.regula.documentreader.api.completions.IDocumentReaderPrepareDbCompletion
|
|
20
|
+
import com.regula.documentreader.api.completions.IVideoEncoderCompletion
|
|
19
21
|
import com.regula.documentreader.api.completions.model.PrepareProgress
|
|
20
22
|
import com.regula.documentreader.api.completions.rfid.IRfidPKDCertificateCompletion
|
|
21
23
|
import com.regula.documentreader.api.completions.rfid.IRfidReaderCompletion
|
|
@@ -29,12 +31,14 @@ import com.regula.documentreader.api.enums.LCID
|
|
|
29
31
|
import com.regula.documentreader.api.enums.eImageQualityCheckType
|
|
30
32
|
import com.regula.documentreader.api.enums.eLDS_ParsingErrorCodes
|
|
31
33
|
import com.regula.documentreader.api.enums.eLDS_ParsingNotificationCodes
|
|
34
|
+
import com.regula.documentreader.api.enums.eMDLDeviceEngagement
|
|
32
35
|
import com.regula.documentreader.api.enums.eRFID_DataFile_Type
|
|
33
36
|
import com.regula.documentreader.api.enums.eRFID_ErrorCodes
|
|
34
37
|
import com.regula.documentreader.api.enums.eVisualFieldType
|
|
35
38
|
import com.regula.documentreader.api.errors.DocReaderRfidException
|
|
36
39
|
import com.regula.documentreader.api.errors.DocumentReaderException
|
|
37
40
|
import com.regula.documentreader.api.internal.core.CoreScenarioUtil
|
|
41
|
+
import com.regula.documentreader.api.params.mdl.DataRetrieval
|
|
38
42
|
import com.regula.documentreader.api.results.DocumentReaderNotification
|
|
39
43
|
import com.regula.documentreader.api.results.DocumentReaderResults
|
|
40
44
|
import com.regula.documentreader.api.results.DocumentReaderResults.fromRawResults
|
|
@@ -44,7 +48,7 @@ import org.json.JSONObject
|
|
|
44
48
|
import com.regula.plugin.documentreader.Convert.toBase64
|
|
45
49
|
import com.regula.plugin.documentreader.Convert.toByteArray
|
|
46
50
|
|
|
47
|
-
fun methodCall(method: String, callback: (Any?) -> Unit): Any
|
|
51
|
+
fun methodCall(method: String, callback: (Any?) -> Unit): Any = when (method) {
|
|
48
52
|
"getDocumentReaderIsReady" -> getDocumentReaderIsReady(callback)
|
|
49
53
|
"getDocumentReaderStatus" -> getDocumentReaderStatus(callback)
|
|
50
54
|
"getRfidSessionStatus" -> getRfidSessionStatus(callback)
|
|
@@ -94,6 +98,13 @@ fun methodCall(method: String, callback: (Any?) -> Unit): Any? = when (method) {
|
|
|
94
98
|
"btDeviceRequestFlashing" -> btDeviceRequestFlashing()
|
|
95
99
|
"btDeviceRequestFlashingFullIR" -> btDeviceRequestFlashingFullIR()
|
|
96
100
|
"btDeviceRequestTurnOffAll" -> btDeviceRequestTurnOffAll()
|
|
101
|
+
"startReadMDl" -> startReadMDl(args(0), args(1), callback)
|
|
102
|
+
"startEngageDevice" -> startEngageDevice(args(0), callback)
|
|
103
|
+
"engageDeviceNFC" -> engageDeviceNFC(callback)
|
|
104
|
+
"engageDeviceData" -> engageDeviceData(args(0), callback)
|
|
105
|
+
"startRetrieveData" -> startRetrieveData(args(0), args(1), callback)
|
|
106
|
+
"retrieveDataNFC" -> retrieveDataNFC(args(0), callback)
|
|
107
|
+
"retrieveDataBLE" -> retrieveDataBLE(args(0), args(1), callback)
|
|
97
108
|
"setLocalizationDictionary" -> setLocalizationDictionary(args(0))
|
|
98
109
|
"getLicense" -> getLicense(callback)
|
|
99
110
|
"getAvailableScenarios" -> getAvailableScenarios(callback)
|
|
@@ -219,12 +230,12 @@ fun checkDatabaseUpdate(callback: Callback, databaseID: String) = Instance().che
|
|
|
219
230
|
@Suppress("DEPRECATION")
|
|
220
231
|
fun scan(config: JSONObject) {
|
|
221
232
|
stopBackgroundRFID()
|
|
222
|
-
Instance().showScanner(
|
|
233
|
+
Instance().showScanner(activity, scannerConfigFromJSON(config), IDocumentReaderCompletion(completion))
|
|
223
234
|
}
|
|
224
235
|
|
|
225
236
|
fun startScanner(config: JSONObject) {
|
|
226
237
|
stopBackgroundRFID()
|
|
227
|
-
Instance().startScanner(
|
|
238
|
+
Instance().startScanner(activity, scannerConfigFromJSON(config), IDocumentReaderCompletion(completion))
|
|
228
239
|
}
|
|
229
240
|
|
|
230
241
|
fun recognize(config: JSONObject) {
|
|
@@ -243,7 +254,7 @@ fun startRFIDReader(onRequestPACertificates: Boolean, onRequestTACertificates: B
|
|
|
243
254
|
onRequestTACertificates,
|
|
244
255
|
onRequestTASignature
|
|
245
256
|
)
|
|
246
|
-
Instance().startRFIDReader(
|
|
257
|
+
Instance().startRFIDReader(activity, rfidReaderCompletion, requestType.getRfidReaderRequest())
|
|
247
258
|
}
|
|
248
259
|
|
|
249
260
|
fun readRFID(onRequestPACertificates: Boolean, onRequestTACertificates: Boolean, onRequestTASignature: Boolean) {
|
|
@@ -252,7 +263,7 @@ fun readRFID(onRequestPACertificates: Boolean, onRequestTACertificates: Boolean,
|
|
|
252
263
|
onRequestTACertificates,
|
|
253
264
|
onRequestTASignature
|
|
254
265
|
)
|
|
255
|
-
startForegroundDispatch()
|
|
266
|
+
startForegroundDispatch("readRFID")
|
|
256
267
|
}
|
|
257
268
|
|
|
258
269
|
fun stopRFIDReader() {
|
|
@@ -286,6 +297,47 @@ fun clearPKDCertificates() = Instance().clearPKDCertificates()
|
|
|
286
297
|
|
|
287
298
|
fun startNewSession() = Instance().startNewSession()
|
|
288
299
|
|
|
300
|
+
fun startReadMDl(type: Int, dataRetrieval: JSONObject, callback: Callback) {
|
|
301
|
+
stopBackgroundRFID()
|
|
302
|
+
Instance().startReadMDL(activity, eMDLDeviceEngagement.values()[type], dataRetrievalFromJSON(dataRetrieval)!!) { v1, v2, v3 -> callback(generateCompletion(v1, v2, v3)) }
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
fun startEngageDevice(type: Int, callback: Callback) {
|
|
306
|
+
stopBackgroundRFID()
|
|
307
|
+
Instance().startEngageDevice(activity, eMDLDeviceEngagement.values()[type]) { v1, v2 -> callback(generateDeviceEngagementCompletion(v1, v2)) }
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
lateinit var engageDeviceNFCCallback: Callback
|
|
311
|
+
fun engageDeviceNFC(callback: Callback) {
|
|
312
|
+
engageDeviceNFCCallback = callback
|
|
313
|
+
stopBackgroundRFID()
|
|
314
|
+
startForegroundDispatch("engageDeviceNFC")
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
fun engageDeviceData(data: String, callback: Callback) {
|
|
318
|
+
stopBackgroundRFID()
|
|
319
|
+
Instance().engageDeviceData(data) { v1, v2 -> callback(generateDeviceEngagementCompletion(v1, v2)) }
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
fun startRetrieveData(dataRetrieval: JSONObject, deviceEngagement: JSONObject, callback: Callback) {
|
|
323
|
+
stopBackgroundRFID()
|
|
324
|
+
Instance().startRetrieveData(activity, deviceEngagementFromJSON(deviceEngagement)!!, dataRetrievalFromJSON(dataRetrieval)!!){ v1, v2, v3 -> callback(generateCompletion(v1, v2, v3)) }
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
lateinit var retrieveDataNFCCallback: Callback
|
|
328
|
+
lateinit var retrieveDataNFCProp: DataRetrieval
|
|
329
|
+
fun retrieveDataNFC(dataRetrieval: JSONObject, callback: Callback) {
|
|
330
|
+
retrieveDataNFCCallback = callback
|
|
331
|
+
retrieveDataNFCProp = dataRetrievalFromJSON(dataRetrieval)!!
|
|
332
|
+
stopBackgroundRFID()
|
|
333
|
+
startForegroundDispatch("retrieveDataNFC")
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
fun retrieveDataBLE(dataRetrieval: JSONObject, deviceEngagement: JSONObject, callback: Callback) {
|
|
337
|
+
stopBackgroundRFID()
|
|
338
|
+
Instance().retrieveDataBLE(context, deviceEngagementFromJSON(deviceEngagement)!!, dataRetrievalFromJSON(dataRetrieval)!!){ v1, v2, v3 -> callback(generateCompletion(v1, v2, v3)) }
|
|
339
|
+
}
|
|
340
|
+
|
|
289
341
|
fun setLocalizationDictionary(dictionary: JSONObject) {
|
|
290
342
|
localizationCallbacks = LocalizationCallbacks { if (dictionary.has(it)) dictionary.getString(it) else null }
|
|
291
343
|
Instance().setLocalizationCallback(localizationCallbacks)
|
|
@@ -476,7 +528,8 @@ fun prepareCompletion(callback: Callback) = object : IDocumentReaderPrepareDbCom
|
|
|
476
528
|
|
|
477
529
|
fun initCompletion(callback: Callback) = IDocumentReaderInitCompletion { success, error ->
|
|
478
530
|
if (success) {
|
|
479
|
-
|
|
531
|
+
videoEncoderCompletion = IVideoEncoderCompletion { _, file -> sendEvent(videoEncoderCompletionEvent, file.path) }
|
|
532
|
+
Instance().setVideoEncoderCompletion(videoEncoderCompletion)
|
|
480
533
|
Instance().setOnClickListener { sendEvent(onCustomButtonTappedEvent, it.tag) }
|
|
481
534
|
}
|
|
482
535
|
callback(generateSuccessCompletion(success, error))
|
|
@@ -525,19 +578,22 @@ var requestType = RfidReaderRequestType(
|
|
|
525
578
|
@Suppress("DEPRECATION", "MissingPermission")
|
|
526
579
|
fun newIntent(intent: Intent): Boolean {
|
|
527
580
|
if (intent.action != NfcAdapter.ACTION_TECH_DISCOVERED) return false
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
rfidReaderCompletion,
|
|
531
|
-
|
|
532
|
-
|
|
581
|
+
val isoDep = IsoDep.get(intent.getParcelableExtra(NfcAdapter.EXTRA_TAG))
|
|
582
|
+
when (nfcFunction) {
|
|
583
|
+
"readRFID" -> Instance().readRFID(isoDep, rfidReaderCompletion, requestType.getRfidReaderRequest())
|
|
584
|
+
"engageDeviceNFC" -> Instance().engageDeviceNFC(isoDep) { v1, v2 -> engageDeviceNFCCallback(generateDeviceEngagementCompletion(v1, v2)) }
|
|
585
|
+
"retrieveDataNFC" -> Instance().retrieveDataNFC(isoDep, retrieveDataNFCProp) { v1, v2, v3 -> retrieveDataNFCCallback(generateCompletion(v1, v2, v3)) }
|
|
586
|
+
}
|
|
533
587
|
return true
|
|
534
588
|
}
|
|
535
589
|
|
|
536
590
|
var backgroundRFIDEnabled = false
|
|
591
|
+
var nfcFunction = ""
|
|
537
592
|
lateinit var lifecycleObserver: LifecycleEventObserver
|
|
538
593
|
|
|
539
|
-
fun startForegroundDispatch() {
|
|
594
|
+
fun startForegroundDispatch(tag: String) {
|
|
540
595
|
backgroundRFIDEnabled = true
|
|
596
|
+
nfcFunction = tag
|
|
541
597
|
val filters: Array<IntentFilter?> = arrayOfNulls(1)
|
|
542
598
|
filters[0] = IntentFilter()
|
|
543
599
|
filters[0]!!.addAction(NfcAdapter.ACTION_TECH_DISCOVERED)
|
|
@@ -577,3 +633,4 @@ fun stopBackgroundRFID() {
|
|
|
577
633
|
|
|
578
634
|
// Weak references
|
|
579
635
|
lateinit var localizationCallbacks: LocalizationCallbacks
|
|
636
|
+
lateinit var videoEncoderCompletion: IVideoEncoderCompletion
|
|
@@ -12,7 +12,9 @@ import android.util.Base64
|
|
|
12
12
|
import org.json.JSONArray
|
|
13
13
|
import org.json.JSONObject
|
|
14
14
|
import java.io.ByteArrayOutputStream
|
|
15
|
+
import java.lang.reflect.Constructor
|
|
15
16
|
import kotlin.math.sqrt
|
|
17
|
+
import kotlin.reflect.KClass
|
|
16
18
|
|
|
17
19
|
fun List<*>.toJson(): JSONArray {
|
|
18
20
|
val result = JSONArray()
|
|
@@ -105,6 +107,18 @@ fun IntArray?.toJson() = this?.let {
|
|
|
105
107
|
result
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
fun JSONArray.toLongArray(): LongArray {
|
|
111
|
+
val result = LongArray(length())
|
|
112
|
+
for (i in 0 until length()) result[i] = getLong(i)
|
|
113
|
+
return result
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
fun LongArray.toJson(): JSONArray {
|
|
117
|
+
val result = JSONArray()
|
|
118
|
+
for (i in indices) result.put(i, this[i])
|
|
119
|
+
return result
|
|
120
|
+
}
|
|
121
|
+
|
|
108
122
|
fun JSONObject.forEach(action: (String, Any) -> Unit) {
|
|
109
123
|
val keys: Iterator<String> = keys()
|
|
110
124
|
while (keys.hasNext()) {
|
|
@@ -123,6 +137,11 @@ fun JSONObject.getIntOrNull(name: String): Int? {
|
|
|
123
137
|
return null
|
|
124
138
|
}
|
|
125
139
|
|
|
140
|
+
fun JSONObject.getLongOrNull(name: String): Long? {
|
|
141
|
+
if (has(name) && get(name).toString() != "null") return getLong(name)
|
|
142
|
+
return null
|
|
143
|
+
}
|
|
144
|
+
|
|
126
145
|
fun JSONObject.getDoubleOrNull(name: String): Double? {
|
|
127
146
|
if (has(name) && get(name).toString() != "null") return getDouble(name)
|
|
128
147
|
return null
|
|
@@ -138,6 +157,49 @@ fun JSONObject.getStringOrNull(name: String): String? {
|
|
|
138
157
|
return null
|
|
139
158
|
}
|
|
140
159
|
|
|
160
|
+
fun <T : Any> KClass<T>.constructor(vararg argTypes: KClass<*>): Constructor<T> {
|
|
161
|
+
val types = mutableListOf<Class<*>>()
|
|
162
|
+
for (argType in argTypes) types.add(argType.java)
|
|
163
|
+
return java.getDeclaredConstructor(*types.toTypedArray())
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fun <T : Any> Constructor<T>.instantiate(vararg args: Any?): T {
|
|
167
|
+
isAccessible = true
|
|
168
|
+
return newInstance(*args)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
fun <T : Any> T.setPrivateProperty(varName: String, data: Any?) {
|
|
172
|
+
try {
|
|
173
|
+
setPrivateProperty(javaClass, varName, data)
|
|
174
|
+
} catch (_: java.lang.Exception) {
|
|
175
|
+
try {
|
|
176
|
+
setPrivateProperty(javaClass.superclass!!, varName, data)
|
|
177
|
+
} catch (_: java.lang.Exception) {
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fun <T : Any> T.setPrivateProperty(clazz: Class<T>, varName: String, data: Any?) = clazz.getDeclaredField(varName).let {
|
|
183
|
+
it.isAccessible = true
|
|
184
|
+
it.set(this, data)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
fun <T : Any> T.getPrivateProperty(varName: String): Any? {
|
|
188
|
+
var clazz: Class<*>? = this.javaClass
|
|
189
|
+
while (clazz != null) {
|
|
190
|
+
try {
|
|
191
|
+
val field = clazz.getDeclaredField(varName)
|
|
192
|
+
field.isAccessible = true
|
|
193
|
+
return field.get(this)
|
|
194
|
+
} catch (_: NoSuchFieldException) {
|
|
195
|
+
clazz = clazz.superclass
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
throw NoSuchFieldException(
|
|
199
|
+
"Field '$varName' not found in class hierarchy of ${this.javaClass.name}"
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
141
203
|
internal object Convert {
|
|
142
204
|
fun String?.toByteArray(): ByteArray? {
|
|
143
205
|
var str = this ?: return null
|
|
@@ -2075,9 +2075,9 @@
|
|
|
2075
2075
|
}
|
|
2076
2076
|
},
|
|
2077
2077
|
"node_modules/@eslint/eslintrc/node_modules/js-yaml": {
|
|
2078
|
-
"version": "4.1.
|
|
2079
|
-
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.
|
|
2080
|
-
"integrity": "sha512-
|
|
2078
|
+
"version": "4.1.1",
|
|
2079
|
+
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
|
2080
|
+
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
|
2081
2081
|
"dev": true,
|
|
2082
2082
|
"license": "MIT",
|
|
2083
2083
|
"dependencies": {
|
|
@@ -5076,9 +5076,9 @@
|
|
|
5076
5076
|
"license": "Python-2.0"
|
|
5077
5077
|
},
|
|
5078
5078
|
"node_modules/cosmiconfig/node_modules/js-yaml": {
|
|
5079
|
-
"version": "4.1.
|
|
5080
|
-
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.
|
|
5081
|
-
"integrity": "sha512-
|
|
5079
|
+
"version": "4.1.1",
|
|
5080
|
+
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
|
5081
|
+
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
|
5082
5082
|
"devOptional": true,
|
|
5083
5083
|
"license": "MIT",
|
|
5084
5084
|
"dependencies": {
|
|
@@ -6273,9 +6273,9 @@
|
|
|
6273
6273
|
}
|
|
6274
6274
|
},
|
|
6275
6275
|
"node_modules/eslint/node_modules/js-yaml": {
|
|
6276
|
-
"version": "4.1.
|
|
6277
|
-
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.
|
|
6278
|
-
"integrity": "sha512-
|
|
6276
|
+
"version": "4.1.1",
|
|
6277
|
+
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
|
6278
|
+
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
|
6279
6279
|
"dev": true,
|
|
6280
6280
|
"license": "MIT",
|
|
6281
6281
|
"dependencies": {
|
|
@@ -8850,9 +8850,9 @@
|
|
|
8850
8850
|
"license": "MIT"
|
|
8851
8851
|
},
|
|
8852
8852
|
"node_modules/js-yaml": {
|
|
8853
|
-
"version": "3.14.
|
|
8854
|
-
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.
|
|
8855
|
-
"integrity": "sha512-
|
|
8853
|
+
"version": "3.14.2",
|
|
8854
|
+
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
|
|
8855
|
+
"integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
|
|
8856
8856
|
"license": "MIT",
|
|
8857
8857
|
"dependencies": {
|
|
8858
8858
|
"argparse": "^1.0.7",
|
package/example/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"test": "jest"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@regulaforensics/react-native-document-reader-api": "8.4.
|
|
14
|
-
"@regulaforensics/react-native-document-reader-core-fullauthrfid": "
|
|
13
|
+
"@regulaforensics/react-native-document-reader-api": "8.4.371-rc",
|
|
14
|
+
"@regulaforensics/react-native-document-reader-core-fullauthrfid": "9.1.1642-rc",
|
|
15
15
|
"@rneui/base": "4.0.0-rc.7",
|
|
16
16
|
"@rneui/themed": "4.0.0-rc.7",
|
|
17
17
|
"react": "19.0.0",
|