@regulaforensics/document-reader 9.1.485-nightly → 9.1.494-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.
Files changed (77) hide show
  1. package/RNDocumentReader.podspec +2 -2
  2. package/android/build.gradle +2 -2
  3. package/android/cordova.gradle +2 -2
  4. package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +8 -0
  5. package/android/src/main/java/com/regula/plugin/documentreader/JSONConstructor.kt +346 -40
  6. package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +62 -8
  7. package/android/src/main/java/com/regula/plugin/documentreader/Utils.kt +62 -0
  8. package/examples/capacitor/ios/App/App/Info.plist +2 -0
  9. package/examples/capacitor/package.json +3 -3
  10. package/examples/ionic/config.xml +2 -0
  11. package/examples/ionic/package-lock.json +5257 -2650
  12. package/examples/ionic/package.json +12 -12
  13. package/examples/react_native/app.config.ts +3 -1
  14. package/examples/react_native/package-lock.json +3 -3
  15. package/examples/react_native/package.json +3 -3
  16. package/ios/RGLWConfig.m +9 -2
  17. package/ios/RGLWJSONConstructor.h +19 -0
  18. package/ios/RGLWJSONConstructor.m +349 -0
  19. package/ios/RGLWMain.m +49 -0
  20. package/package.json +1 -1
  21. package/plugin.xml +2 -2
  22. package/test/json.tsx +200 -95
  23. package/test/package-lock.json +1 -1
  24. package/test/test.tsx +12 -2
  25. package/www/capacitor/engagement/DataRetrieval.js +55 -0
  26. package/www/capacitor/engagement/DeviceEngagement.js +30 -0
  27. package/www/capacitor/engagement/DeviceRetrievalMethod.js +41 -0
  28. package/www/capacitor/engagement/DocumentRequestMDL.js +212 -0
  29. package/www/capacitor/engagement/NameSpaceMDL.js +33 -0
  30. package/www/capacitor/index.js +54 -2
  31. package/www/capacitor/info/DocReaderException.js +2 -0
  32. package/www/capacitor/params/Functionality.js +16 -0
  33. package/www/capacitor/params/customization/Customization.js +8 -0
  34. package/www/capacitor/params/process_params/ProcessParams.js +16 -0
  35. package/www/capacitor/results/Results.js +8 -1
  36. package/www/capacitor/results/status/AgeStatus.js +35 -0
  37. package/www/capacitor/results/status/ResultsStatus.js +13 -0
  38. package/www/capacitor/results/visible_digital_seals/DocFeature.js +23 -0
  39. package/www/capacitor/results/visible_digital_seals/VDSData.js +75 -0
  40. package/www/capacitor/results/visual_results/FieldType.js +3 -0
  41. package/www/capacitor/rfid/PKDCertificate.js +3 -0
  42. package/www/cordova.js +951 -177
  43. package/www/react-native/engagement/DataRetrieval.js +55 -0
  44. package/www/react-native/engagement/DeviceEngagement.js +30 -0
  45. package/www/react-native/engagement/DeviceRetrievalMethod.js +41 -0
  46. package/www/react-native/engagement/DocumentRequestMDL.js +212 -0
  47. package/www/react-native/engagement/NameSpaceMDL.js +33 -0
  48. package/www/react-native/index.js +54 -2
  49. package/www/react-native/info/DocReaderException.js +2 -0
  50. package/www/react-native/params/Functionality.js +16 -0
  51. package/www/react-native/params/customization/Customization.js +8 -0
  52. package/www/react-native/params/process_params/ProcessParams.js +16 -0
  53. package/www/react-native/results/Results.js +8 -1
  54. package/www/react-native/results/status/AgeStatus.js +35 -0
  55. package/www/react-native/results/status/ResultsStatus.js +13 -0
  56. package/www/react-native/results/visible_digital_seals/DocFeature.js +23 -0
  57. package/www/react-native/results/visible_digital_seals/VDSData.js +75 -0
  58. package/www/react-native/results/visual_results/FieldType.js +3 -0
  59. package/www/react-native/rfid/PKDCertificate.js +3 -0
  60. package/www/types/engagement/DataRetrieval.d.ts +28 -0
  61. package/www/types/engagement/DeviceEngagement.d.ts +16 -0
  62. package/www/types/engagement/DeviceRetrievalMethod.d.ts +18 -0
  63. package/www/types/engagement/DocumentRequestMDL.d.ts +61 -0
  64. package/www/types/engagement/NameSpaceMDL.d.ts +16 -0
  65. package/www/types/index.d.ts +35 -2
  66. package/www/types/info/DocReaderException.d.ts +2 -0
  67. package/www/types/params/Functionality.d.ts +7 -0
  68. package/www/types/params/customization/Customization.d.ts +5 -0
  69. package/www/types/params/process_params/ProcessParams.d.ts +13 -0
  70. package/www/types/results/Results.d.ts +9 -1
  71. package/www/types/results/status/AgeStatus.d.ts +14 -0
  72. package/www/types/results/status/ResultsStatus.d.ts +9 -0
  73. package/www/types/results/visible_digital_seals/DocFeature.d.ts +9 -0
  74. package/www/types/results/visible_digital_seals/VDSData.d.ts +32 -0
  75. package/www/types/results/visible_digital_seals/VDSNCData.d.ts +1 -1
  76. package/www/types/results/visual_results/FieldType.d.ts +6 -0
  77. package/www/types/rfid/PKDCertificate.d.ts +7 -1
@@ -5,7 +5,7 @@ source = File.join(__dir__, 'ios')
5
5
 
6
6
  Pod::Spec.new do |s|
7
7
  s.name = 'RNDocumentReader'
8
- s.version = '9.1.485-nightly'
8
+ s.version = '9.1.494-rc'
9
9
  s.summary = package['description']
10
10
  s.license = package['license']
11
11
 
@@ -16,6 +16,6 @@ Pod::Spec.new do |s|
16
16
  s.ios.deployment_target = '13.0'
17
17
  s.source_files = 'ios/**/*.{h,m}'
18
18
  s.exclude_files = [ 'ios/CVDDocumentReader.h', 'ios/CVDDocumentReader.m' ]
19
- s.dependency 'DocumentReaderNightly', '9.1.5674'
19
+ s.dependency 'DocumentReaderStage', '9.1.5685'
20
20
  s.dependency 'React'
21
21
  end
@@ -20,7 +20,7 @@ android {
20
20
  rootProject.allprojects {
21
21
  repositories {
22
22
  maven {
23
- url "https://maven.regulaforensics.com/RegulaDocumentReader/Nightly"
23
+ url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
24
24
  }
25
25
  }
26
26
  }
@@ -29,7 +29,7 @@ dependencies {
29
29
  //noinspection GradleDynamicVersion
30
30
  implementation 'com.facebook.react:react-native:+'
31
31
  //noinspection GradleDependency
32
- implementation('com.regula.documentreader:api:9.1.12225'){
32
+ implementation('com.regula.documentreader:api:9.1.12236'){
33
33
  transitive = true
34
34
  }
35
35
  }
@@ -1,12 +1,12 @@
1
1
  repositories {
2
2
  maven {
3
- url "https://maven.regulaforensics.com/RegulaDocumentReader/Nightly"
3
+ url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
4
4
  }
5
5
  }
6
6
 
7
7
  dependencies {
8
8
  //noinspection GradleDependency
9
- implementation('com.regula.documentreader:api:9.1.12225'){
9
+ implementation('com.regula.documentreader:api:9.1.12236'){
10
10
  transitive = true
11
11
  }
12
12
  }
@@ -60,6 +60,7 @@ fun setFunctionality(config: Functionality, input: JSONObject) = input.forEach {
60
60
  "zoomFactor" -> editor.setZoomFactor(v.toFloat())
61
61
  "exposure" -> editor.setExposure(v.toFloat())
62
62
  "videoRecordingSizeDownscaleFactor" -> editor.setVideoRecordingSizeDownscaleFactor(v.toFloat())
63
+ "mdlTimeout" -> editor.setMDLTimeout(v.toDouble())
63
64
  "excludedCamera2Models" -> editor.setExcludedCamera2Models((v as JSONArray).toList())
64
65
  "cameraSize" -> editor.setCameraSize(cameraSizeFromJSON(v as JSONObject).first, cameraSizeFromJSON(v).second)
65
66
  }
@@ -96,6 +97,7 @@ fun getFunctionality(input: Functionality) = mapOf(
96
97
  "zoomFactor" to input.zoomFactor,
97
98
  "exposure" to input.exposure,
98
99
  "videoRecordingSizeDownscaleFactor" to input.videoRecordingSizeDownscaleFactor,
100
+ "mdlTimeout" to input.mdlTimeout,
99
101
  "excludedCamera2Models" to input.excludedCamera2Models.toJson(),
100
102
  "cameraSize" to generateCameraSize(input.cameraWidth, input.cameraHeight)
101
103
  ).toJson()
@@ -144,6 +146,7 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
144
146
  "disableAuthResolutionFilter" -> processParams.disableAuthResolutionFilter = v as Boolean
145
147
  "strictSecurityChecks" -> processParams.strictSecurityChecks = v as Boolean
146
148
  "returnTransliteratedFields" -> processParams.returnTransliteratedFields = v as Boolean
149
+ "checkCaptureProcessIntegrity" -> processParams.checkCaptureProcessIntegrity = v as Boolean
147
150
  "measureSystem" -> processParams.measureSystem = v.toInt()
148
151
  "barcodeParserType" -> processParams.barcodeParserType = v.toInt()
149
152
  "perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
@@ -174,6 +177,7 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
174
177
  "documentGroupFilter" -> processParams.documentGroupFilter = v.toIntArray()
175
178
  "lcidIgnoreFilter" -> processParams.lcidIgnoreFilter = v.toIntArray()
176
179
  "lcidFilter" -> processParams.lcidFilter = v.toIntArray()
180
+ "fieldTypesIgnoreFilter" -> processParams.fieldTypesIgnoreFilter = v.toIntArray()
177
181
  "barcodeTypes" -> processParams.doBarcodes = barcodeTypeArrayFromJson(v as JSONArray)
178
182
  "mrzFormatsFilter" -> processParams.mrzFormatsFilter = (v as JSONArray).toArray()
179
183
  "customParams" -> processParams.customParams = v as JSONObject
@@ -231,6 +235,7 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
231
235
  "disableAuthResolutionFilter" to processParams.disableAuthResolutionFilter,
232
236
  "strictSecurityChecks" to processParams.strictSecurityChecks,
233
237
  "returnTransliteratedFields" to processParams.returnTransliteratedFields,
238
+ "checkCaptureProcessIntegrity" to processParams.checkCaptureProcessIntegrity,
234
239
  "measureSystem" to processParams.measureSystem,
235
240
  "barcodeParserType" to processParams.barcodeParserType,
236
241
  "perspectiveAngle" to processParams.perspectiveAngle,
@@ -260,6 +265,7 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
260
265
  "documentGroupFilter" to processParams.documentGroupFilter.toJson(),
261
266
  "lcidIgnoreFilter" to processParams.lcidIgnoreFilter.toJson(),
262
267
  "lcidFilter" to processParams.lcidFilter.toJson(),
268
+ "fieldTypesIgnoreFilter" to processParams.fieldTypesIgnoreFilter.toJson(),
263
269
  "resultTypeOutput" to processParams.resultTypeOutput.toJson(),
264
270
  "mrzFormatsFilter" to processParams.mrzFormatsFilter.toJson(),
265
271
  "barcodeTypes" to generateBarcodeTypeArray(processParams.doBarcodes),
@@ -314,6 +320,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject) = opt
314
320
  "activityIndicatorPortraitPositionMultiplier" -> editor.setActivityIndicatorPortraitPositionMultiplier(v.toFloat())
315
321
  "activityIndicatorLandscapePositionMultiplier" -> editor.setActivityIndicatorLandscapePositionMultiplier(v.toFloat())
316
322
  "cameraPreviewVerticalPositionMultiplier" -> editor.setCameraPreviewVerticalPositionMultiplier(v.toFloat())
323
+ "multipageButtonPositionMultiplier" -> editor.setMultipageButtonPositionMultiplier(v.toFloat())
317
324
  "multipageAnimationFrontImage" -> editor.setMultipageAnimationFrontImage(v.toDrawable())
318
325
  "multipageAnimationBackImage" -> editor.setMultipageAnimationBackImage(v.toDrawable())
319
326
  "borderBackgroundImage" -> editor.setBorderBackgroundImage(v.toDrawable())
@@ -400,6 +407,7 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
400
407
  "activityIndicatorPortraitPositionMultiplier" to customization.activityIndicatorPortraitPositionMultiplier,
401
408
  "activityIndicatorLandscapePositionMultiplier" to customization.activityIndicatorLandscapePositionMultiplier,
402
409
  "cameraPreviewVerticalPositionMultiplier" to customization.cameraPreviewVerticalPositionMultiplier,
410
+ "multipageButtonPositionMultiplier" to customization.multipageButtonPositionMultiplier,
403
411
  "multipageAnimationFrontImage" to customization.multipageAnimationFrontImage.toBase64(),
404
412
  "multipageAnimationBackImage" to customization.multipageAnimationBackImage.toBase64(),
405
413
  "borderBackgroundImage" to customization.borderBackgroundImage.toBase64(),
@@ -1,5 +1,5 @@
1
1
  @file:SuppressLint("MissingPermission")
2
- @file:Suppress("unused")
2
+ @file:Suppress("unused", "EnumValuesSoftDeprecate", "UNCHECKED_CAST")
3
3
 
4
4
  package com.regula.plugin.documentreader
5
5
 
@@ -19,6 +19,9 @@ import com.regula.documentreader.api.enums.BarcodeType
19
19
  import com.regula.documentreader.api.enums.DocReaderAction
20
20
  import com.regula.documentreader.api.enums.PDF417Info
21
21
  import com.regula.documentreader.api.enums.eGraphicFieldType
22
+ import com.regula.documentreader.api.enums.eMDLDeviceRetrieval
23
+ import com.regula.documentreader.api.enums.eMDLDocRequestPreset
24
+ import com.regula.documentreader.api.enums.eMDLIntentToRetain
22
25
  import com.regula.documentreader.api.enums.eRFID_DataFile_Type
23
26
  import com.regula.documentreader.api.enums.eRPRM_Lights
24
27
  import com.regula.documentreader.api.listener.NetworkInterceptorListener
@@ -36,6 +39,12 @@ import com.regula.documentreader.api.params.OnlineProcessingConfig
36
39
  import com.regula.documentreader.api.params.ParamsCustomization
37
40
  import com.regula.documentreader.api.params.ProcessParam
38
41
  import com.regula.documentreader.api.params.RfidScenario
42
+ import com.regula.documentreader.api.params.mdl.DataRetrieval
43
+ import com.regula.documentreader.api.params.mdl.DeviceEngagement
44
+ import com.regula.documentreader.api.params.mdl.DeviceRetrievalMethod
45
+ import com.regula.documentreader.api.params.mdl.DocumentRequest18013MDL
46
+ import com.regula.documentreader.api.params.mdl.DocumentRequestMDL
47
+ import com.regula.documentreader.api.params.mdl.NameSpaceMDL
39
48
  import com.regula.documentreader.api.params.rfid.PKDCertificate
40
49
  import com.regula.documentreader.api.params.rfid.RFIDParams
41
50
  import com.regula.documentreader.api.params.rfid.TccParams
@@ -48,6 +57,7 @@ import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
48
57
  import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
49
58
  import com.regula.documentreader.api.results.BytesData
50
59
  import com.regula.documentreader.api.results.Coordinate
60
+ import com.regula.documentreader.api.results.DocFeature
51
61
  import com.regula.documentreader.api.results.DocReaderDocumentsDatabase
52
62
  import com.regula.documentreader.api.results.DocReaderFieldRect
53
63
  import com.regula.documentreader.api.results.DocReaderVersion
@@ -62,6 +72,7 @@ import com.regula.documentreader.api.results.DocumentReaderResults
62
72
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus
63
73
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsOptical
64
74
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsRFID
75
+ import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsAge
65
76
  import com.regula.documentreader.api.results.DocumentReaderRfidOrigin
66
77
  import com.regula.documentreader.api.results.DocumentReaderScenario
67
78
  import com.regula.documentreader.api.results.DocumentReaderSymbol
@@ -74,6 +85,7 @@ import com.regula.documentreader.api.results.ElementPosition
74
85
  import com.regula.documentreader.api.results.ImageQuality
75
86
  import com.regula.documentreader.api.results.ImageQualityGroup
76
87
  import com.regula.documentreader.api.results.TransactionInfo
88
+ import com.regula.documentreader.api.results.VDSData
77
89
  import com.regula.documentreader.api.results.VDSNCData
78
90
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck
79
91
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement
@@ -1475,8 +1487,19 @@ fun generateTAChallenge(input: TAChallenge?) = input?.let {
1475
1487
  }
1476
1488
 
1477
1489
  fun documentReaderResultsStatusFromJSON(input: JSONObject?) = input?.let {
1478
- it.remove("detailsRFID")
1479
- DocumentReaderResultsStatus.fromJson(input)
1490
+ val result = DocumentReaderResultsStatus::class.constructor().instantiate()
1491
+ result.setPrivateProperty("overallStatus", it.getInt("overallStatus"))
1492
+ result.setPrivateProperty("optical", it.getInt("optical"))
1493
+ result.setPrivateProperty("detailsOptical", detailsOpticalFromJSON(it.getJSONObject("detailsOptical")))
1494
+ result.setPrivateProperty("rfid", it.getInt("rfid"))
1495
+ result.setPrivateProperty("detailsRFID", detailsRFIDFromJSON(it.getJSONObject("detailsRFID")))
1496
+ result.setPrivateProperty("portrait", it.getInt("portrait"))
1497
+ result.setPrivateProperty("stopList", it.getInt("stopList"))
1498
+ result.setPrivateProperty("mDL", it.getInt("mDL"))
1499
+ result.setPrivateProperty("age", it.getInt("age"))
1500
+ result.setPrivateProperty("captureProcessIntegrity", it.getInt("captureProcessIntegrity"))
1501
+ result.setPrivateProperty("detailsAge", detailsAgeFromJSON(it.getJSONObject("detailsAge")))
1502
+ result
1480
1503
  }
1481
1504
 
1482
1505
  fun generateDocumentReaderResultsStatus(input: DocumentReaderResultsStatus?) = input?.let {
@@ -1487,8 +1510,26 @@ fun generateDocumentReaderResultsStatus(input: DocumentReaderResultsStatus?) = i
1487
1510
  "rfid" to it.rfid,
1488
1511
  "detailsRFID" to generateDetailsRFID(it.detailsRFID),
1489
1512
  "portrait" to it.portrait,
1490
- "stopList" to it.stopList
1491
- ).toJson()
1513
+ "stopList" to it.stopList,
1514
+ "mDL" to it.mdl,
1515
+ "age" to it.age,
1516
+ "captureProcessIntegrity" to it.captureProcessIntegrity,
1517
+ "detailsAge" to generateDetailsAge(it.detailsAge),
1518
+ ).toJson()
1519
+ }
1520
+
1521
+ fun detailsOpticalFromJSON(input: JSONObject?) = input?.let {
1522
+ val result = DetailsOptical::class.constructor().instantiate()
1523
+ result.setPrivateProperty("overallStatus", it.getInt("overallStatus"))
1524
+ result.setPrivateProperty("mrz", it.getInt("mrz"))
1525
+ result.setPrivateProperty("text", it.getInt("text"))
1526
+ result.setPrivateProperty("docType", it.getInt("docType"))
1527
+ result.setPrivateProperty("security", it.getInt("security"))
1528
+ result.setPrivateProperty("imageQA", it.getInt("imageQA"))
1529
+ result.setPrivateProperty("expiry", it.getInt("expiry"))
1530
+ result.setPrivateProperty("vds", it.getInt("vds"))
1531
+ result.setPrivateProperty("pagesCount", it.getInt("pagesCount"))
1532
+ result
1492
1533
  }
1493
1534
 
1494
1535
  fun generateDetailsOptical(input: DetailsOptical?) = input?.let {
@@ -1505,6 +1546,18 @@ fun generateDetailsOptical(input: DetailsOptical?) = input?.let {
1505
1546
  ).toJson()
1506
1547
  }
1507
1548
 
1549
+ fun detailsRFIDFromJSON(input: JSONObject?) = input?.let {
1550
+ val result = DetailsRFID::class.constructor().instantiate()
1551
+ result.setPrivateProperty("overallStatus", it.getInt("overallStatus"))
1552
+ result.setPrivateProperty("pa", it.getInt("pa"))
1553
+ result.setPrivateProperty("ca", it.getInt("ca"))
1554
+ result.setPrivateProperty("aa", it.getInt("aa"))
1555
+ result.setPrivateProperty("ta", it.getInt("ta"))
1556
+ result.setPrivateProperty("bac", it.getInt("bac"))
1557
+ result.setPrivateProperty("pace", it.getInt("pace"))
1558
+ result
1559
+ }
1560
+
1508
1561
  fun generateDetailsRFID(input: DetailsRFID?) = input?.let {
1509
1562
  mapOf(
1510
1563
  "pa" to it.pa,
@@ -1517,23 +1570,41 @@ fun generateDetailsRFID(input: DetailsRFID?) = input?.let {
1517
1570
  ).toJson()
1518
1571
  }
1519
1572
 
1520
- fun vdsncDataDictionaryFromJSON(input: JSONObject) = input.let {
1521
- val result = JSONObject(it.toString())
1522
-
1523
- result.put("Type", it.optString("type"))
1524
- result.put("Version", it.optInt("version"))
1525
- result.put("IssuingCountry", it.optString("issuingCountry"))
1526
- result.put("Message", it.optJSONObject("message"))
1527
- result.put("SignatureAlg", it.optString("signatureAlgorithm"))
1528
- result.put("Signature", bytesDataDictionaryFromJSON(it.optJSONObject("signature")))
1529
- result.put("Certificate", bytesDataDictionaryFromJSON(it.optJSONObject("certificate")))
1530
- result.put("CertificateChain", it.optJSONArray("certificateChain"))
1531
- result.put("Notifications", it.optJSONArray("notifications"))
1532
-
1573
+ fun detailsAgeFromJSON(input: JSONObject?) = input?.let {
1574
+ val result = DetailsAge::class.constructor().instantiate()
1575
+ result.setPrivateProperty("threshold", it.getInt("threshold"))
1576
+ result.setPrivateProperty("overThreshold", it.getInt("overThreshold"))
1577
+ result.setPrivateProperty("over18", it.getInt("over18"))
1578
+ result.setPrivateProperty("over21", it.getInt("over21"))
1579
+ result.setPrivateProperty("over25", it.getInt("over25"))
1580
+ result.setPrivateProperty("over65", it.getInt("over65"))
1533
1581
  result
1534
1582
  }
1535
1583
 
1536
- fun vdsncDataFromJSON(input: JSONObject) = VDSNCData.fromJson(vdsncDataDictionaryFromJSON(input))
1584
+ fun generateDetailsAge(input: DetailsAge?) = input?.let {
1585
+ mapOf(
1586
+ "threshold" to it.threshold,
1587
+ "overThreshold" to it.overThreshold,
1588
+ "over18" to it.over18,
1589
+ "over21" to it.over21,
1590
+ "over25" to it.over25,
1591
+ "over65" to it.over65
1592
+ ).toJson()
1593
+ }
1594
+
1595
+ fun vdsncDataFromJSON(input: JSONObject?) = input?.let {
1596
+ val result = VDSNCData::class.constructor().instantiate()
1597
+ result.setPrivateProperty("type", it.getStringOrNull("type"))
1598
+ result.setPrivateProperty("version", it.getInt("version"))
1599
+ result.setPrivateProperty("issuingCountry", it.getStringOrNull("issuingCountry"))
1600
+ result.setPrivateProperty("message", it.getJSONObjectOrNull("message"))
1601
+ result.setPrivateProperty("signatureAlg", it.getStringOrNull("signatureAlgorithm"))
1602
+ result.setPrivateProperty("signature", bytesDataFromJSON(it.getJSONObjectOrNull("signature")))
1603
+ result.setPrivateProperty("certificate", bytesDataFromJSON(it.getJSONObjectOrNull("certificate")))
1604
+ result.setPrivateProperty("certificateChain", it.getJSONArray("certificateChain").toList(::certificateChainFromJSON))
1605
+ result.setPrivateProperty("notifications", it.getJSONArray("notifications").toLongArray())
1606
+ result
1607
+ }
1537
1608
 
1538
1609
  fun generateVDSNCData(input: VDSNCData?) = input?.let {
1539
1610
  mapOf(
@@ -1545,27 +1616,19 @@ fun generateVDSNCData(input: VDSNCData?) = input?.let {
1545
1616
  "signature" to generateBytesData(it.signature),
1546
1617
  "certificate" to generateBytesData(it.certificate),
1547
1618
  "certificateChain" to it.certificateChain.toJson(::generateCertificateChain),
1548
- "notifications" to if (it.notifications == null) null else {
1549
- val notifications = JSONArray()
1550
- for (i in it.notifications!!.indices) notifications.put(i, it.notifications!![i])
1551
- notifications
1552
- }
1619
+ "notifications" to it.notifications.toJson()
1553
1620
  ).toJson()
1554
1621
  }
1555
1622
 
1556
- fun bytesDataDictionaryFromJSON(input: JSONObject?) = input?.let {
1557
- val result = JSONObject(input.toString())
1558
-
1559
- result.put("Data", input.optString("data"))
1560
- result.put("Length", input.optInt("length"))
1561
- result.put("Status", input.optLong("status"))
1562
- result.put("Type", input.optInt("type"))
1563
-
1623
+ fun bytesDataFromJSON(input: JSONObject?) = input?.let {
1624
+ val result = BytesData::class.constructor().instantiate()
1625
+ result.setPrivateProperty("data", it.getString("data"))
1626
+ result.setPrivateProperty("length", it.getInt("length"))
1627
+ result.setPrivateProperty("status", it.getLong("status"))
1628
+ result.setPrivateProperty("type", it.getInt("type"))
1564
1629
  result
1565
1630
  }
1566
1631
 
1567
- fun bytesDataFromJSON(input: JSONObject?) = BytesData.fromJson(bytesDataDictionaryFromJSON(input))
1568
-
1569
1632
  fun generateBytesData(input: BytesData?) = input?.let {
1570
1633
  mapOf(
1571
1634
  "data" to it.data,
@@ -1593,11 +1656,15 @@ fun generateDocReaderVersion(input: DocReaderVersion?) = input?.let {
1593
1656
  }
1594
1657
 
1595
1658
  fun docReaderDocumentsDatabaseFromJSON(input: JSONObject?) = input?.let {
1596
- val result = JSONObject(it.toString())
1597
- result.put("id", it.optString("databaseID"))
1598
- result.put("export_date", it.optString("date"))
1599
- result.put("description", it.optString("databaseDescription"))
1600
- DocReaderDocumentsDatabase.fromJson(result)
1659
+ DocReaderDocumentsDatabase::class.constructor(String::class, String::class, String::class, String::class, Int::class, Int::class, java.lang.Long::class).instantiate(
1660
+ it.getStringOrNull("databaseID"),
1661
+ it.getStringOrNull("version"),
1662
+ it.getStringOrNull("date"),
1663
+ it.getStringOrNull("databaseDescription"),
1664
+ it.getInt("countriesNumber"),
1665
+ it.getInt("documentsNumber"),
1666
+ it.getLongOrNull("size"),
1667
+ )
1601
1668
  }
1602
1669
 
1603
1670
  fun generateDocReaderDocumentsDatabase(input: DocReaderDocumentsDatabase?) = input?.let {
@@ -1729,6 +1796,56 @@ fun generateBarcodeTypeArray(input: Array<String?>?) = input?.let {
1729
1796
  result
1730
1797
  }
1731
1798
 
1799
+ fun docFeatureFromJSON(input: JSONObject?) = input?.let {
1800
+ val result = DocFeature::class.constructor().instantiate()
1801
+ result.setPrivateProperty("type", it.getIntOrNull("type"))
1802
+ result.setPrivateProperty("data", bytesDataFromJSON(it.getJSONObjectOrNull("data")))
1803
+ result
1804
+ }
1805
+
1806
+ fun generateDocFeature(input: DocFeature?) = input?.let {
1807
+ mapOf(
1808
+ "type" to it.type,
1809
+ "data" to generateBytesData(it.data),
1810
+ ).toJson()
1811
+ }
1812
+
1813
+ fun vdsDataFromJSON(input: JSONObject?) = input?.let {
1814
+ val result = VDSData::class.constructor().instantiate()
1815
+ result.setPrivateProperty("version", it.getIntOrNull("version"))
1816
+ result.setPrivateProperty("type", it.getIntOrNull("type"))
1817
+ result.setPrivateProperty("docType", it.getIntOrNull("docType"))
1818
+ result.setPrivateProperty("featureRef", it.getIntOrNull("featureRef"))
1819
+ result.setPrivateProperty("issuingCountry", it.getStringOrNull("issuingCountry"))
1820
+ result.setPrivateProperty("docIssueDate", it.getStringOrNull("docIssueDate"))
1821
+ result.setPrivateProperty("signature", bytesDataFromJSON(it.getJSONObjectOrNull("signature")))
1822
+ result.setPrivateProperty("signatureDate", it.getStringOrNull("signatureDate"))
1823
+ result.setPrivateProperty("signer", it.getStringOrNull("signer"))
1824
+ result.setPrivateProperty("certificate", it.getStringOrNull("certificate"))
1825
+ result.setPrivateProperty("certificateChain", it.getJSONArray("certificateChain").toList(::certificateChainFromJSON))
1826
+ result.setPrivateProperty("docFeatures", it.getJSONArray("docFeatures").toList(::docFeatureFromJSON))
1827
+ result.setPrivateProperty("notifications", it.getJSONArray("notifications").toLongArray())
1828
+ result
1829
+ }
1830
+
1831
+ fun generateVDSData(input: VDSData?) = input?.let {
1832
+ mapOf(
1833
+ "version" to it.version,
1834
+ "type" to it.type,
1835
+ "docType" to it.docType,
1836
+ "featureRef" to it.featureRef,
1837
+ "issuingCountry" to it.issuingCountry,
1838
+ "docIssueDate" to it.docIssueDate,
1839
+ "signature" to generateBytesData(it.signature),
1840
+ "signatureDate" to it.signatureDate,
1841
+ "signer" to it.signer,
1842
+ "certificate" to it.certificate,
1843
+ "certificateChain" to it.certificateChain.toJson(::generateCertificateChain),
1844
+ "docFeatures" to it.docFeatures.toJson(::generateDocFeature),
1845
+ "notifications" to it.notifications.toJson(),
1846
+ ).toJson()
1847
+ }
1848
+
1732
1849
  fun documentReaderResultsFromJSON(input: JSONObject?) = input?.let {
1733
1850
  val result = DocumentReaderResults()
1734
1851
 
@@ -1750,7 +1867,8 @@ fun documentReaderResultsFromJSON(input: JSONObject?) = input?.let {
1750
1867
  result.rfidSessionData = rfidSessionDataFromJSON(it.optJSONObject("rfidSessionData"))
1751
1868
  result.documentType = it.optJSONArray("documentType").toList(::documentReaderDocumentTypeFromJSON)!!
1752
1869
  result.status = documentReaderResultsStatusFromJSON(it.optJSONObject("status"))!!
1753
- result.vdsncData = vdsncDataFromJSON(it.optJSONObject("vdsncData")!!)
1870
+ result.vdsncData = vdsncDataFromJSON(it.getJSONObject("vdsncData"))
1871
+ result.vdsData = vdsDataFromJSON(it.getJSONObjectOrNull("vdsData"))
1754
1872
  result.dtcData = it.getString("dtcData")
1755
1873
  result.transactionInfo = transactionInfoFromJSON(it.optJSONObject("transactionInfo"))!!
1756
1874
  result
@@ -1776,6 +1894,7 @@ fun generateDocumentReaderResults(input: DocumentReaderResults?) = input?.let {
1776
1894
  "documentType" to it.documentType.toJson(::generateDocumentReaderDocumentType),
1777
1895
  "status" to generateDocumentReaderResultsStatus(it.status),
1778
1896
  "vdsncData" to generateVDSNCData(it.vdsncData),
1897
+ "vdsData" to generateVDSData(it.vdsData),
1779
1898
  "dtcData" to it.dtcData,
1780
1899
  "transactionInfo" to generateTransactionInfo(it.transactionInfo)
1781
1900
  ).toJson()
@@ -1796,3 +1915,190 @@ fun generateMatrix(input: Matrix?) = input?.let {
1796
1915
  for (f in floats) result.put(java.lang.Float.valueOf(f))
1797
1916
  result
1798
1917
  }
1918
+
1919
+ fun deviceRetrievalMethodFromJSON(input: JSONObject?) = input?.let {
1920
+ val result = DeviceRetrievalMethod::class.constructor().instantiate()
1921
+ result.setPrivateProperty("type", it.getInt("type"))
1922
+ result.setPrivateProperty("version", it.getIntOrNull("version"))
1923
+ result.setPrivateProperty("cmdMaxLength", it.getIntOrNull("cmdMaxLength"))
1924
+ result.setPrivateProperty("respMaxLength", it.getIntOrNull("respMaxLength"))
1925
+ result.setPrivateProperty("clientModeSupport", it.getBooleanOrNull("clientModeSupport"))
1926
+ result.setPrivateProperty("clientModeUUID", it.getStringOrNull("clientModeUUID"))
1927
+ result.setPrivateProperty("serverModeSupport", it.getBooleanOrNull("serverModeSupport"))
1928
+ result.setPrivateProperty("serverModeUUID", it.getStringOrNull("serverModeUUID"))
1929
+ result
1930
+ }
1931
+
1932
+ fun generateDeviceRetrievalMethod(input: DeviceRetrievalMethod?) = input?.let {
1933
+ mapOf(
1934
+ "type" to it.type,
1935
+ "version" to it.version,
1936
+ "cmdMaxLength" to it.cmdMaxLength,
1937
+ "respMaxLength" to it.respMaxLength,
1938
+ "clientModeSupport" to it.clientModeSupport,
1939
+ "clientModeUUID" to it.clientModeUUID,
1940
+ "serverModeSupport" to it.serverModeSupport,
1941
+ "serverModeUUID" to it.serverModeUUID,
1942
+ ).toJson()
1943
+ }
1944
+
1945
+ fun deviceEngagementFromJSON(input: JSONObject?) = input?.let {
1946
+ val result = DeviceEngagement::class.constructor().instantiate()
1947
+
1948
+ result.setPrivateProperty("deviceRetrievalMethods", it.getJSONArray("deviceRetrievalMethods").toList(::deviceRetrievalMethodFromJSON))
1949
+
1950
+ result
1951
+ }
1952
+
1953
+ fun generateDeviceEngagement(input: DeviceEngagement?) = input?.let {
1954
+ mapOf(
1955
+ "deviceRetrievalMethods" to it.deviceRetrievalMethods.toJson(::generateDeviceRetrievalMethod)
1956
+ ).toJson()
1957
+ }
1958
+
1959
+ fun nameSpaceMDLFromJSON(input: JSONObject?) = input?.let {
1960
+ val result = NameSpaceMDL(it.getString("name"))
1961
+ it.getJSONObject("map").forEach { key, value ->
1962
+ result.addField(key, eMDLIntentToRetain.values()[value as Int])
1963
+ }
1964
+ result
1965
+ }
1966
+
1967
+ fun generateNameSpaceMDL(input: NameSpaceMDL?) = input?.let {
1968
+ val map = JSONObject()
1969
+ (it.getPrivateProperty("map") as Map<String, eMDLIntentToRetain>).forEach { (key, value) ->
1970
+ map.put(key, value.ordinal)
1971
+ }
1972
+ mapOf(
1973
+ "name" to it.getPrivateProperty("name"),
1974
+ "map" to map,
1975
+ ).toJson()
1976
+ }
1977
+
1978
+ fun documentRequestMDLFromJSON(input: JSONObject?): DocumentRequestMDL? = input?.let {
1979
+ val docType = it.getString("docType")
1980
+ if (docType == "org.iso.18013.5.1.mDL") return@let documentRequest18013MDLFromJSON(it)
1981
+ val result = DocumentRequestMDL(docType)
1982
+
1983
+ result.setPrivateProperty("nameSpaceMDLs", it.getJSONArray("namespaces").toList(::nameSpaceMDLFromJSON))
1984
+
1985
+ result
1986
+ }
1987
+
1988
+ fun generateDocumentRequestMDL(input: DocumentRequestMDL?): JSONObject? = input?.let {
1989
+ val docType = it.getPrivateProperty("docType") as String
1990
+ if (docType == "org.iso.18013.5.1.mDL") return@let generateDocumentRequest18013MDL(it as DocumentRequest18013MDL?)
1991
+ mapOf(
1992
+ "docType" to docType,
1993
+ "namespaces" to (it.getPrivateProperty("nameSpaceMDLs") as List<NameSpaceMDL>).toJson(::generateNameSpaceMDL),
1994
+ ).toJson()
1995
+ }
1996
+
1997
+ fun documentRequest18013MDLFromJSON(input: JSONObject?) = input?.let {
1998
+ val result = DocumentRequest18013MDL()
1999
+
2000
+ result.setPrivateProperty("docType", it.getString("docType"))
2001
+ result.setPrivateProperty("nameSpaceMDLs", it.getJSONArray("namespaces").toList(::nameSpaceMDLFromJSON))
2002
+ result.familyName = it.getIntOrNull("familyName")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2003
+ result.givenName = it.getIntOrNull("givenName")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2004
+ result.birthDate = it.getIntOrNull("birthDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2005
+ result.issueDate = it.getIntOrNull("issueDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2006
+ result.expiryDate = it.getIntOrNull("expiryDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2007
+ result.issuingCountry = it.getIntOrNull("issuingCountry")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2008
+ result.issuingAuthority = it.getIntOrNull("issuingAuthority")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2009
+ result.documentNumber = it.getIntOrNull("documentNumber")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2010
+ result.portrait = it.getIntOrNull("portrait")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2011
+ result.drivingPrivileges = it.getIntOrNull("drivingPrivileges")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2012
+ result.unDistinguishingSign = it.getIntOrNull("unDistinguishingSign")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2013
+ result.administrativeNumber = it.getIntOrNull("administrativeNumber")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2014
+ result.sex = it.getIntOrNull("sex")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2015
+ result.height = it.getIntOrNull("height")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2016
+ result.weight = it.getIntOrNull("weight")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2017
+ result.eyeColour = it.getIntOrNull("eyeColour")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2018
+ result.hairColour = it.getIntOrNull("hairColour")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2019
+ result.birthPlace = it.getIntOrNull("birthPlace")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2020
+ result.residentAddress = it.getIntOrNull("residentAddress")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2021
+ result.portraitCaptureDate = it.getIntOrNull("portraitCaptureDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2022
+ result.ageInYears = it.getIntOrNull("ageInYears")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2023
+ result.ageBirthYear = it.getIntOrNull("ageBirthYear")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2024
+ result.ageOver18 = it.getIntOrNull("ageOver18")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2025
+ result.issuingJurisdiction = it.getIntOrNull("issuingJurisdiction")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2026
+ result.nationality = it.getIntOrNull("nationality")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2027
+ result.residentCity = it.getIntOrNull("residentCity")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2028
+ result.residentState = it.getIntOrNull("residentState")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2029
+ result.residentPostalCode = it.getIntOrNull("residentPostalCode")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2030
+ result.residentCountry = it.getIntOrNull("residentCountry")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2031
+ result.biometricTemplateFace = it.getIntOrNull("biometricTemplateFace")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2032
+ result.biometricTemplateIris = it.getIntOrNull("biometricTemplateIris")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2033
+ result.biometricTemplateFinger = it.getIntOrNull("biometricTemplateFinger")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2034
+ result.biometricTemplateSignatureSign = it.getIntOrNull("biometricTemplateSignatureSign")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2035
+ result.familyNameNationalCharacter = it.getIntOrNull("familyNameNationalCharacter")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2036
+ result.givenNameNationalCharacter = it.getIntOrNull("givenNameNationalCharacter")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2037
+ result.signatureUsualMark = it.getIntOrNull("signatureUsualMark")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2038
+ result
2039
+ }
2040
+
2041
+ fun generateDocumentRequest18013MDL(input: DocumentRequest18013MDL?) = input?.let {
2042
+ mapOf(
2043
+ "docType" to it.getPrivateProperty("docType"),
2044
+ "namespaces" to (it.getPrivateProperty("nameSpaceMDLs") as List<NameSpaceMDL>).toJson(::generateNameSpaceMDL),
2045
+ "familyName" to it.familyName?.ordinal,
2046
+ "givenName" to it.givenName?.ordinal,
2047
+ "birthDate" to it.birthDate?.ordinal,
2048
+ "issueDate" to it.issueDate?.ordinal,
2049
+ "expiryDate" to it.expiryDate?.ordinal,
2050
+ "issuingCountry" to it.issuingCountry?.ordinal,
2051
+ "issuingAuthority" to it.issuingAuthority?.ordinal,
2052
+ "documentNumber" to it.documentNumber?.ordinal,
2053
+ "portrait" to it.portrait?.ordinal,
2054
+ "drivingPrivileges" to it.drivingPrivileges?.ordinal,
2055
+ "unDistinguishingSign" to it.unDistinguishingSign?.ordinal,
2056
+ "administrativeNumber" to it.administrativeNumber?.ordinal,
2057
+ "sex" to it.sex?.ordinal,
2058
+ "height" to it.height?.ordinal,
2059
+ "weight" to it.weight?.ordinal,
2060
+ "eyeColour" to it.eyeColour?.ordinal,
2061
+ "hairColour" to it.hairColour?.ordinal,
2062
+ "birthPlace" to it.birthPlace?.ordinal,
2063
+ "residentAddress" to it.residentAddress?.ordinal,
2064
+ "portraitCaptureDate" to it.portraitCaptureDate?.ordinal,
2065
+ "ageInYears" to it.ageInYears?.ordinal,
2066
+ "ageBirthYear" to it.ageBirthYear?.ordinal,
2067
+ "ageOver18" to it.ageOver18?.ordinal,
2068
+ "issuingJurisdiction" to it.issuingJurisdiction?.ordinal,
2069
+ "nationality" to it.nationality?.ordinal,
2070
+ "residentCity" to it.residentCity?.ordinal,
2071
+ "residentState" to it.residentState?.ordinal,
2072
+ "residentPostalCode" to it.residentPostalCode?.ordinal,
2073
+ "residentCountry" to it.residentCountry?.ordinal,
2074
+ "biometricTemplateFace" to it.biometricTemplateFace?.ordinal,
2075
+ "biometricTemplateIris" to it.biometricTemplateIris?.ordinal,
2076
+ "biometricTemplateFinger" to it.biometricTemplateFinger?.ordinal,
2077
+ "biometricTemplateSignatureSign" to it.biometricTemplateSignatureSign?.ordinal,
2078
+ "familyNameNationalCharacter" to it.familyNameNationalCharacter?.ordinal,
2079
+ "givenNameNationalCharacter" to it.givenNameNationalCharacter?.ordinal,
2080
+ "signatureUsualMark" to it.signatureUsualMark?.ordinal,
2081
+ ).toJson()
2082
+ }
2083
+
2084
+ fun dataRetrievalFromJSON(input: JSONObject?) = input?.let {
2085
+ val result = DataRetrieval(eMDLDeviceRetrieval.values().first { enm -> enm.value == it.getInt("deviceRetrieval") })
2086
+ result.setPrivateProperty("docRequestPreset", it.getIntOrNull("docRequestPreset")?.let { enm -> eMDLDocRequestPreset.values()[enm] })
2087
+ result.setPrivateProperty("intentToRetain", it.getIntOrNull("intentToRetain")?.let { enm -> eMDLIntentToRetain.values()[enm] })
2088
+ it.getJSONArray("requests").toList(::documentRequestMDLFromJSON)?.forEach { r -> result.addDocRequest(r!!) }
2089
+ result
2090
+ }
2091
+
2092
+ fun generateDataRetrieval(input: DataRetrieval?) = input?.let {
2093
+ mapOf(
2094
+ "deviceRetrieval" to it.deviceRetrieval.value,
2095
+ "docRequestPreset" to (it.getPrivateProperty("docRequestPreset") as eMDLDocRequestPreset).ordinal,
2096
+ "intentToRetain" to (it.getPrivateProperty("intentToRetain") as eMDLIntentToRetain).ordinal,
2097
+ "requests" to (it.getPrivateProperty("docRequests") as List<DocumentRequestMDL>).toJson(::generateDocumentRequestMDL),
2098
+ ).toJson()
2099
+ }
2100
+
2101
+ fun generateDeviceEngagementCompletion(deviceEngagement: DeviceEngagement?, error: RegulaException?) = mapOf(
2102
+ "deviceEngagement" to generateDeviceEngagement(deviceEngagement),
2103
+ "error" to generateRegulaException(error)
2104
+ )