@regulaforensics/document-reader 8.4.401-beta → 8.4.507-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 (88) hide show
  1. package/README.md +1 -1
  2. package/RNDocumentReader.podspec +2 -2
  3. package/android/build.gradle +2 -2
  4. package/android/cordova.gradle +2 -2
  5. package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +11 -31
  6. package/android/src/main/java/com/regula/plugin/documentreader/JSONConstructor.kt +338 -59
  7. package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +69 -35
  8. package/android/src/main/java/com/regula/plugin/documentreader/Utils.kt +62 -0
  9. package/examples/capacitor/ios/App/App/Info.plist +2 -0
  10. package/examples/capacitor/package-lock.json +9 -9
  11. package/examples/capacitor/package.json +3 -3
  12. package/examples/ionic/config.xml +2 -0
  13. package/examples/ionic/package-lock.json +5262 -2655
  14. package/examples/ionic/package.json +12 -12
  15. package/examples/react_native/app.config.ts +3 -1
  16. package/examples/react_native/package-lock.json +37 -37
  17. package/examples/react_native/package.json +3 -3
  18. package/ios/RGLWConfig.m +11 -32
  19. package/ios/RGLWJSONConstructor.h +19 -1
  20. package/ios/RGLWJSONConstructor.m +349 -18
  21. package/ios/RGLWMain.m +49 -46
  22. package/package.json +1 -1
  23. package/plugin.xml +2 -2
  24. package/test/json.tsx +201 -124
  25. package/test/package-lock.json +1 -1
  26. package/test/test.tsx +12 -3
  27. package/www/capacitor/engagement/DataRetrieval.js +55 -0
  28. package/www/capacitor/engagement/DeviceEngagement.js +30 -0
  29. package/www/capacitor/engagement/DeviceRetrievalMethod.js +41 -0
  30. package/www/capacitor/engagement/DocumentRequestMDL.js +212 -0
  31. package/www/capacitor/engagement/NameSpaceMDL.js +33 -0
  32. package/www/capacitor/index.js +58 -7
  33. package/www/capacitor/info/DocReaderException.js +2 -0
  34. package/www/capacitor/params/Functionality.js +16 -0
  35. package/www/capacitor/params/customization/Customization.js +8 -0
  36. package/www/capacitor/params/process_params/AuthenticityParams.js +1 -44
  37. package/www/capacitor/params/process_params/LivenessParams.js +0 -36
  38. package/www/capacitor/params/process_params/ProcessParams.js +26 -30
  39. package/www/capacitor/results/Results.js +8 -1
  40. package/www/capacitor/results/status/AgeStatus.js +35 -0
  41. package/www/capacitor/results/status/ResultsStatus.js +13 -0
  42. package/www/capacitor/results/visible_digital_seals/DocFeature.js +23 -0
  43. package/www/capacitor/results/visible_digital_seals/VDSData.js +75 -0
  44. package/www/capacitor/results/visual_results/FieldType.js +3 -0
  45. package/www/capacitor/rfid/PKDCertificate.js +3 -0
  46. package/www/cordova.js +1276 -683
  47. package/www/react-native/engagement/DataRetrieval.js +55 -0
  48. package/www/react-native/engagement/DeviceEngagement.js +30 -0
  49. package/www/react-native/engagement/DeviceRetrievalMethod.js +41 -0
  50. package/www/react-native/engagement/DocumentRequestMDL.js +212 -0
  51. package/www/react-native/engagement/NameSpaceMDL.js +33 -0
  52. package/www/react-native/index.js +58 -7
  53. package/www/react-native/info/DocReaderException.js +2 -0
  54. package/www/react-native/params/Functionality.js +16 -0
  55. package/www/react-native/params/customization/Customization.js +8 -0
  56. package/www/react-native/params/process_params/AuthenticityParams.js +1 -44
  57. package/www/react-native/params/process_params/LivenessParams.js +0 -36
  58. package/www/react-native/params/process_params/ProcessParams.js +26 -30
  59. package/www/react-native/results/Results.js +8 -1
  60. package/www/react-native/results/status/AgeStatus.js +35 -0
  61. package/www/react-native/results/status/ResultsStatus.js +13 -0
  62. package/www/react-native/results/visible_digital_seals/DocFeature.js +23 -0
  63. package/www/react-native/results/visible_digital_seals/VDSData.js +75 -0
  64. package/www/react-native/results/visual_results/FieldType.js +3 -0
  65. package/www/react-native/rfid/PKDCertificate.js +3 -0
  66. package/www/types/engagement/DataRetrieval.d.ts +28 -0
  67. package/www/types/engagement/DeviceEngagement.d.ts +16 -0
  68. package/www/types/engagement/DeviceRetrievalMethod.d.ts +18 -0
  69. package/www/types/engagement/DocumentRequestMDL.d.ts +61 -0
  70. package/www/types/engagement/NameSpaceMDL.d.ts +16 -0
  71. package/www/types/index.d.ts +40 -8
  72. package/www/types/info/DocReaderException.d.ts +2 -0
  73. package/www/types/params/Functionality.d.ts +7 -0
  74. package/www/types/params/customization/Customization.d.ts +5 -0
  75. package/www/types/params/process_params/AuthenticityParams.d.ts +0 -25
  76. package/www/types/params/process_params/LivenessParams.d.ts +0 -18
  77. package/www/types/params/process_params/ProcessParams.d.ts +18 -11
  78. package/www/types/results/Results.d.ts +9 -1
  79. package/www/types/results/status/AgeStatus.d.ts +14 -0
  80. package/www/types/results/status/ResultsStatus.d.ts +9 -0
  81. package/www/types/results/visible_digital_seals/DocFeature.d.ts +9 -0
  82. package/www/types/results/visible_digital_seals/VDSData.d.ts +32 -0
  83. package/www/types/results/visible_digital_seals/VDSNCData.d.ts +1 -1
  84. package/www/types/results/visual_results/FieldType.d.ts +6 -0
  85. package/www/types/rfid/PKDCertificate.d.ts +7 -1
  86. package/www/capacitor/params/process_params/FilterObject.js +0 -60
  87. package/www/react-native/params/process_params/FilterObject.js +0 -60
  88. package/www/types/params/process_params/FilterObject.d.ts +0 -32
@@ -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
@@ -27,8 +30,6 @@ import com.regula.documentreader.api.params.BackendProcessingConfig
27
30
  import com.regula.documentreader.api.params.BleDeviceConfig
28
31
  import com.regula.documentreader.api.params.DocReaderConfig
29
32
  import com.regula.documentreader.api.params.FaceApiParams
30
- import com.regula.documentreader.api.params.FilterObject
31
- import com.regula.documentreader.api.params.FilterObjectType
32
33
  import com.regula.documentreader.api.params.Functionality
33
34
  import com.regula.documentreader.api.params.ImageInputData
34
35
  import com.regula.documentreader.api.params.ImageQA
@@ -38,6 +39,12 @@ import com.regula.documentreader.api.params.OnlineProcessingConfig
38
39
  import com.regula.documentreader.api.params.ParamsCustomization
39
40
  import com.regula.documentreader.api.params.ProcessParam
40
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
41
48
  import com.regula.documentreader.api.params.rfid.PKDCertificate
42
49
  import com.regula.documentreader.api.params.rfid.RFIDParams
43
50
  import com.regula.documentreader.api.params.rfid.TccParams
@@ -50,6 +57,7 @@ import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
50
57
  import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
51
58
  import com.regula.documentreader.api.results.BytesData
52
59
  import com.regula.documentreader.api.results.Coordinate
60
+ import com.regula.documentreader.api.results.DocFeature
53
61
  import com.regula.documentreader.api.results.DocReaderDocumentsDatabase
54
62
  import com.regula.documentreader.api.results.DocReaderFieldRect
55
63
  import com.regula.documentreader.api.results.DocReaderVersion
@@ -64,6 +72,7 @@ import com.regula.documentreader.api.results.DocumentReaderResults
64
72
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus
65
73
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsOptical
66
74
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsRFID
75
+ import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsAge
67
76
  import com.regula.documentreader.api.results.DocumentReaderRfidOrigin
68
77
  import com.regula.documentreader.api.results.DocumentReaderScenario
69
78
  import com.regula.documentreader.api.results.DocumentReaderSymbol
@@ -76,6 +85,7 @@ import com.regula.documentreader.api.results.ElementPosition
76
85
  import com.regula.documentreader.api.results.ImageQuality
77
86
  import com.regula.documentreader.api.results.ImageQualityGroup
78
87
  import com.regula.documentreader.api.results.TransactionInfo
88
+ import com.regula.documentreader.api.results.VDSData
79
89
  import com.regula.documentreader.api.results.VDSNCData
80
90
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck
81
91
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement
@@ -1477,8 +1487,19 @@ fun generateTAChallenge(input: TAChallenge?) = input?.let {
1477
1487
  }
1478
1488
 
1479
1489
  fun documentReaderResultsStatusFromJSON(input: JSONObject?) = input?.let {
1480
- it.remove("detailsRFID")
1481
- 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
1482
1503
  }
1483
1504
 
1484
1505
  fun generateDocumentReaderResultsStatus(input: DocumentReaderResultsStatus?) = input?.let {
@@ -1489,8 +1510,26 @@ fun generateDocumentReaderResultsStatus(input: DocumentReaderResultsStatus?) = i
1489
1510
  "rfid" to it.rfid,
1490
1511
  "detailsRFID" to generateDetailsRFID(it.detailsRFID),
1491
1512
  "portrait" to it.portrait,
1492
- "stopList" to it.stopList
1493
- ).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
1494
1533
  }
1495
1534
 
1496
1535
  fun generateDetailsOptical(input: DetailsOptical?) = input?.let {
@@ -1507,6 +1546,18 @@ fun generateDetailsOptical(input: DetailsOptical?) = input?.let {
1507
1546
  ).toJson()
1508
1547
  }
1509
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
+
1510
1561
  fun generateDetailsRFID(input: DetailsRFID?) = input?.let {
1511
1562
  mapOf(
1512
1563
  "pa" to it.pa,
@@ -1519,23 +1570,41 @@ fun generateDetailsRFID(input: DetailsRFID?) = input?.let {
1519
1570
  ).toJson()
1520
1571
  }
1521
1572
 
1522
- fun vdsncDataDictionaryFromJSON(input: JSONObject) = input.let {
1523
- val result = JSONObject(it.toString())
1524
-
1525
- result.put("Type", it.optString("type"))
1526
- result.put("Version", it.optInt("version"))
1527
- result.put("IssuingCountry", it.optString("issuingCountry"))
1528
- result.put("Message", it.optJSONObject("message"))
1529
- result.put("SignatureAlg", it.optString("signatureAlgorithm"))
1530
- result.put("Signature", bytesDataDictionaryFromJSON(it.optJSONObject("signature")))
1531
- result.put("Certificate", bytesDataDictionaryFromJSON(it.optJSONObject("certificate")))
1532
- result.put("CertificateChain", it.optJSONArray("certificateChain"))
1533
- result.put("Notifications", it.optJSONArray("notifications"))
1534
-
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"))
1535
1581
  result
1536
1582
  }
1537
1583
 
1538
- 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
+ }
1539
1608
 
1540
1609
  fun generateVDSNCData(input: VDSNCData?) = input?.let {
1541
1610
  mapOf(
@@ -1547,27 +1616,19 @@ fun generateVDSNCData(input: VDSNCData?) = input?.let {
1547
1616
  "signature" to generateBytesData(it.signature),
1548
1617
  "certificate" to generateBytesData(it.certificate),
1549
1618
  "certificateChain" to it.certificateChain.toJson(::generateCertificateChain),
1550
- "notifications" to if (it.notifications == null) null else {
1551
- val notifications = JSONArray()
1552
- for (i in it.notifications!!.indices) notifications.put(i, it.notifications!![i])
1553
- notifications
1554
- }
1619
+ "notifications" to it.notifications.toJson()
1555
1620
  ).toJson()
1556
1621
  }
1557
1622
 
1558
- fun bytesDataDictionaryFromJSON(input: JSONObject?) = input?.let {
1559
- val result = JSONObject(input.toString())
1560
-
1561
- result.put("Data", input.optString("data"))
1562
- result.put("Length", input.optInt("length"))
1563
- result.put("Status", input.optLong("status"))
1564
- result.put("Type", input.optInt("type"))
1565
-
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"))
1566
1629
  result
1567
1630
  }
1568
1631
 
1569
- fun bytesDataFromJSON(input: JSONObject?) = BytesData.fromJson(bytesDataDictionaryFromJSON(input))
1570
-
1571
1632
  fun generateBytesData(input: BytesData?) = input?.let {
1572
1633
  mapOf(
1573
1634
  "data" to it.data,
@@ -1595,11 +1656,15 @@ fun generateDocReaderVersion(input: DocReaderVersion?) = input?.let {
1595
1656
  }
1596
1657
 
1597
1658
  fun docReaderDocumentsDatabaseFromJSON(input: JSONObject?) = input?.let {
1598
- val result = JSONObject(it.toString())
1599
- result.put("id", it.optString("databaseID"))
1600
- result.put("export_date", it.optString("date"))
1601
- result.put("description", it.optString("databaseDescription"))
1602
- 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
+ )
1603
1668
  }
1604
1669
 
1605
1670
  fun generateDocReaderDocumentsDatabase(input: DocReaderDocumentsDatabase?) = input?.let {
@@ -1731,6 +1796,56 @@ fun generateBarcodeTypeArray(input: Array<String?>?) = input?.let {
1731
1796
  result
1732
1797
  }
1733
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
+
1734
1849
  fun documentReaderResultsFromJSON(input: JSONObject?) = input?.let {
1735
1850
  val result = DocumentReaderResults()
1736
1851
 
@@ -1752,7 +1867,8 @@ fun documentReaderResultsFromJSON(input: JSONObject?) = input?.let {
1752
1867
  result.rfidSessionData = rfidSessionDataFromJSON(it.optJSONObject("rfidSessionData"))
1753
1868
  result.documentType = it.optJSONArray("documentType").toList(::documentReaderDocumentTypeFromJSON)!!
1754
1869
  result.status = documentReaderResultsStatusFromJSON(it.optJSONObject("status"))!!
1755
- result.vdsncData = vdsncDataFromJSON(it.optJSONObject("vdsncData")!!)
1870
+ result.vdsncData = vdsncDataFromJSON(it.getJSONObject("vdsncData"))
1871
+ result.vdsData = vdsDataFromJSON(it.getJSONObjectOrNull("vdsData"))
1756
1872
  result.dtcData = it.getString("dtcData")
1757
1873
  result.transactionInfo = transactionInfoFromJSON(it.optJSONObject("transactionInfo"))!!
1758
1874
  result
@@ -1778,6 +1894,7 @@ fun generateDocumentReaderResults(input: DocumentReaderResults?) = input?.let {
1778
1894
  "documentType" to it.documentType.toJson(::generateDocumentReaderDocumentType),
1779
1895
  "status" to generateDocumentReaderResultsStatus(it.status),
1780
1896
  "vdsncData" to generateVDSNCData(it.vdsncData),
1897
+ "vdsData" to generateVDSData(it.vdsData),
1781
1898
  "dtcData" to it.dtcData,
1782
1899
  "transactionInfo" to generateTransactionInfo(it.transactionInfo)
1783
1900
  ).toJson()
@@ -1799,27 +1916,189 @@ fun generateMatrix(input: Matrix?) = input?.let {
1799
1916
  result
1800
1917
  }
1801
1918
 
1802
- fun filterObjectFromJSON(it: JSONObject): FilterObject {
1803
- val result = FilterObject()
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
+ }
1804
1944
 
1805
- result.docIDsFilter = filterObjectTypeIntFromJSON(it.getJSONObjectOrNull("docIDsFilter"))
1806
- result.docFormatsFilter = filterObjectTypeIntFromJSON(it.getJSONObjectOrNull("docFormatsFilter"))
1807
- result.docCategoriesFilter = filterObjectTypeIntFromJSON(it.getJSONObjectOrNull("docCategoriesFilter"))
1808
- result.docCountriesFilter = filterObjectTypeStringFromJSON(it.getJSONObjectOrNull("docCountriesFilter"))
1945
+ fun deviceEngagementFromJSON(input: JSONObject?) = input?.let {
1946
+ val result = DeviceEngagement::class.constructor().instantiate()
1809
1947
 
1810
- return result
1948
+ result.setPrivateProperty("deviceRetrievalMethods", it.getJSONArray("deviceRetrievalMethods").toList(::deviceRetrievalMethodFromJSON))
1949
+
1950
+ result
1811
1951
  }
1812
1952
 
1813
- fun filterObjectTypeIntFromJSON(input: JSONObject?): FilterObjectType<Int>? = input?.let {
1814
- val array = it.getJSONArray("list").toArray<Int>()!!
1815
- if (it.getBoolean("isInclude"))
1816
- return FilterObjectType.createIncludeList(array)
1817
- return FilterObjectType.createExcludeList(array)
1953
+ fun generateDeviceEngagement(input: DeviceEngagement?) = input?.let {
1954
+ mapOf(
1955
+ "deviceRetrievalMethods" to it.deviceRetrievalMethods.toJson(::generateDeviceRetrievalMethod)
1956
+ ).toJson()
1818
1957
  }
1819
1958
 
1820
- fun filterObjectTypeStringFromJSON(input: JSONObject?): FilterObjectType<String>? = input?.let {
1821
- val array = it.getJSONArray("list").toArray<String>()!!
1822
- if (it.getBoolean("isInclude"))
1823
- return FilterObjectType.createIncludeList(array)
1824
- return FilterObjectType.createExcludeList(array)
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()
1825
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
+ )