@regulaforensics/document-reader 1.1.1318-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 (483) hide show
  1. package/Package.swift +28 -0
  2. package/README.md +19 -0
  3. package/android/CVDDocumentReader.kt +76 -0
  4. package/android/build.gradle.kts +37 -0
  5. package/android/cordova.gradle.kts +13 -0
  6. package/android/src/main/kotlin/com/regula/plugin/document/reader/BluetoothUtil.kt +164 -0
  7. package/android/src/main/kotlin/com/regula/plugin/document/reader/Config.kt +1021 -0
  8. package/android/src/main/kotlin/com/regula/plugin/document/reader/JSONConstructor.kt +2192 -0
  9. package/android/src/main/kotlin/com/regula/plugin/document/reader/Main.kt +656 -0
  10. package/android/src/main/kotlin/com/regula/plugin/document/reader/RNDocumentReaderModule.kt +101 -0
  11. package/android/src/main/kotlin/com/regula/plugin/document/reader/Utils.kt +248 -0
  12. package/app.plugin.js +45 -0
  13. package/examples/capacitor/README.md +24 -0
  14. package/examples/capacitor/android/app/build.gradle +41 -0
  15. package/examples/capacitor/android/app/proguard-rules.pro +21 -0
  16. package/examples/capacitor/android/app/src/main/AndroidManifest.xml +36 -0
  17. package/examples/capacitor/android/app/src/main/assets/Regula/.gitkeep +0 -0
  18. package/examples/capacitor/android/app/src/main/java/com/regula/example/dr/capacitor/MainActivity.java +5 -0
  19. package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher.png +0 -0
  20. package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher_foreground.png +0 -0
  21. package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher_round.png +0 -0
  22. package/examples/capacitor/android/app/src/main/res/drawable/launcher.xml +4 -0
  23. package/examples/capacitor/android/app/src/main/res/drawable/launcher_round.xml +4 -0
  24. package/examples/capacitor/android/app/src/main/res/drawable/splash.png +0 -0
  25. package/examples/capacitor/android/app/src/main/res/layout/activity_main.xml +12 -0
  26. package/examples/capacitor/android/app/src/main/res/values/styles.xml +22 -0
  27. package/examples/capacitor/android/app/src/main/res/xml/file_paths.xml +5 -0
  28. package/examples/capacitor/android/build.gradle +39 -0
  29. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  30. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  31. package/examples/capacitor/android/gradle.properties +26 -0
  32. package/examples/capacitor/android/gradlew +248 -0
  33. package/examples/capacitor/android/gradlew.bat +82 -0
  34. package/examples/capacitor/android/settings.gradle +5 -0
  35. package/examples/capacitor/android/variables.gradle +20 -0
  36. package/examples/capacitor/capacitor.config.json +15 -0
  37. package/examples/capacitor/index.html +5 -0
  38. package/examples/capacitor/index.tsx +31 -0
  39. package/examples/capacitor/ios/App/App/App.entitlements +10 -0
  40. package/examples/capacitor/ios/App/App/AppDelegate.swift +14 -0
  41. package/examples/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
  42. package/examples/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  43. package/examples/capacitor/ios/App/App/Assets.xcassets/Contents.json +6 -0
  44. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
  45. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
  46. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
  47. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
  48. package/examples/capacitor/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
  49. package/examples/capacitor/ios/App/App/Info.plist +88 -0
  50. package/examples/capacitor/ios/App/App/SceneDelegate.swift +23 -0
  51. package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +374 -0
  52. package/examples/capacitor/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  53. package/examples/capacitor/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift +1 -0
  54. package/examples/capacitor/package-lock.json +1965 -0
  55. package/examples/capacitor/package.json +26 -0
  56. package/examples/capacitor/public/assets/.gitkeep +0 -0
  57. package/examples/capacitor/public/images/document.png +0 -0
  58. package/examples/capacitor/public/images/portrait.png +0 -0
  59. package/examples/capacitor/scripts/android.sh +8 -0
  60. package/examples/capacitor/scripts/ios.sh +8 -0
  61. package/examples/capacitor/scripts/setup.sh +9 -0
  62. package/examples/capacitor/src/extra/bt_device.tsx +33 -0
  63. package/examples/capacitor/src/extra/custom_rfid.tsx +61 -0
  64. package/examples/capacitor/src/main.css +153 -0
  65. package/examples/capacitor/src/main.html +38 -0
  66. package/examples/capacitor/src/main.tsx +172 -0
  67. package/examples/capacitor/tsconfig.json +5 -0
  68. package/examples/capacitor/vite.config.ts +5 -0
  69. package/examples/ionic/README.md +24 -0
  70. package/examples/ionic/angular.json +39 -0
  71. package/examples/ionic/assets/.gitkeep +0 -0
  72. package/examples/ionic/config.xml +61 -0
  73. package/examples/ionic/images/document.png +0 -0
  74. package/examples/ionic/images/icon.png +0 -0
  75. package/examples/ionic/images/portrait.png +0 -0
  76. package/examples/ionic/index.html +19 -0
  77. package/examples/ionic/index.tsx +63 -0
  78. package/examples/ionic/ionic.config.json +7 -0
  79. package/examples/ionic/package-lock.json +17554 -0
  80. package/examples/ionic/package.json +76 -0
  81. package/examples/ionic/patches/cordova-plugin-ionic-webview+5.0.1.patch +23 -0
  82. package/examples/ionic/scripts/android.sh +9 -0
  83. package/examples/ionic/scripts/ios.sh +11 -0
  84. package/examples/ionic/scripts/setup.sh +8 -0
  85. package/examples/ionic/src/extra/bt_device.tsx +33 -0
  86. package/examples/ionic/src/extra/custom_rfid.tsx +61 -0
  87. package/examples/ionic/src/main.css +148 -0
  88. package/examples/ionic/src/main.html +38 -0
  89. package/examples/ionic/src/main.tsx +172 -0
  90. package/examples/ionic/tsconfig.json +13 -0
  91. package/examples/react_native/README.md +24 -0
  92. package/examples/react_native/app.config.ts +54 -0
  93. package/examples/react_native/assets/.gitkeep +0 -0
  94. package/examples/react_native/images/document.png +0 -0
  95. package/examples/react_native/images/icon.png +0 -0
  96. package/examples/react_native/images/portrait.png +0 -0
  97. package/examples/react_native/index.tsx +111 -0
  98. package/examples/react_native/metro.config.js +5 -0
  99. package/examples/react_native/package-lock.json +6924 -0
  100. package/examples/react_native/package.json +37 -0
  101. package/examples/react_native/scripts/android.sh +8 -0
  102. package/examples/react_native/scripts/ios.sh +6 -0
  103. package/examples/react_native/scripts/setup.sh +10 -0
  104. package/examples/react_native/scripts/withoutMetroServer.js +89 -0
  105. package/examples/react_native/src/extra/bt_device.tsx +33 -0
  106. package/examples/react_native/src/extra/custom_rfid.tsx +61 -0
  107. package/examples/react_native/src/main.css +148 -0
  108. package/examples/react_native/src/main.html +38 -0
  109. package/examples/react_native/src/main.tsx +172 -0
  110. package/ios/CVDDocumentReader.h +7 -0
  111. package/ios/CVDDocumentReader.m +43 -0
  112. package/ios/RGLWConfig.h +44 -0
  113. package/ios/RGLWConfig.m +1577 -0
  114. package/ios/RGLWJSONConstructor.h +216 -0
  115. package/ios/RGLWJSONConstructor.m +2875 -0
  116. package/ios/RGLWMain.h +34 -0
  117. package/ios/RGLWMain.m +722 -0
  118. package/ios/RNDocumentReader.h +8 -0
  119. package/ios/RNDocumentReader.m +52 -0
  120. package/ios/spm/module.modulemap +7 -0
  121. package/package.json +39 -0
  122. package/plugin.xml +51 -0
  123. package/react-native-document-reader.podspec +14 -0
  124. package/test/json.tsx +1159 -0
  125. package/test/package-lock.json +584 -0
  126. package/test/package.json +9 -0
  127. package/test/test.tsx +315 -0
  128. package/test/utils.tsx +38 -0
  129. package/www/capacitor/config/FinalizeConfig.js +35 -0
  130. package/www/capacitor/config/InitConfig.js +55 -0
  131. package/www/capacitor/config/OnlineProcessingConfig.js +52 -0
  132. package/www/capacitor/config/RFIDConfig.js +47 -0
  133. package/www/capacitor/config/RecognizeConfig.js +138 -0
  134. package/www/capacitor/config/ScannerConfig.js +48 -0
  135. package/www/capacitor/index.js +758 -0
  136. package/www/capacitor/info/DocReaderException.js +68 -0
  137. package/www/capacitor/info/DocReaderScenario.js +89 -0
  138. package/www/capacitor/info/DocReaderVersion.js +32 -0
  139. package/www/capacitor/info/DocumentsDatabase.js +39 -0
  140. package/www/capacitor/info/License.js +30 -0
  141. package/www/capacitor/info/PrepareProgress.js +31 -0
  142. package/www/capacitor/info/RFIDException.js +26 -0
  143. package/www/capacitor/internal/bridge.js +131 -0
  144. package/www/capacitor/internal/cordova.js +17 -0
  145. package/www/capacitor/mdl/DataRetrieval.js +55 -0
  146. package/www/capacitor/mdl/DeviceEngagement.js +30 -0
  147. package/www/capacitor/mdl/DeviceRetrievalMethod.js +41 -0
  148. package/www/capacitor/mdl/DocumentRequestMDL.js +212 -0
  149. package/www/capacitor/mdl/NameSpaceMDL.js +33 -0
  150. package/www/capacitor/params/Functionality.js +387 -0
  151. package/www/capacitor/params/customization/Customization.js +664 -0
  152. package/www/capacitor/params/customization/CustomizationColors.js +231 -0
  153. package/www/capacitor/params/customization/CustomizationContentModes.js +55 -0
  154. package/www/capacitor/params/customization/CustomizationFonts.js +156 -0
  155. package/www/capacitor/params/customization/CustomizationImages.js +199 -0
  156. package/www/capacitor/params/customization/CustomizationMatrices.js +39 -0
  157. package/www/capacitor/params/customization/CustomizationTimings.js +71 -0
  158. package/www/capacitor/params/process_params/AuthenticityParams.js +166 -0
  159. package/www/capacitor/params/process_params/AuthenticityPropertiesParams.js +39 -0
  160. package/www/capacitor/params/process_params/BackendProcessingConfig.js +38 -0
  161. package/www/capacitor/params/process_params/Bsi.js +23 -0
  162. package/www/capacitor/params/process_params/FaceApiParams.js +55 -0
  163. package/www/capacitor/params/process_params/FaceApiSearchParams.js +29 -0
  164. package/www/capacitor/params/process_params/GlaresCheckParams.js +25 -0
  165. package/www/capacitor/params/process_params/ImageQA.js +122 -0
  166. package/www/capacitor/params/process_params/LivenessParams.js +87 -0
  167. package/www/capacitor/params/process_params/OcclusionCheckParams.js +21 -0
  168. package/www/capacitor/params/process_params/ProcessParams.js +724 -0
  169. package/www/capacitor/params/process_params/RFIDParams.js +21 -0
  170. package/www/capacitor/params/rfid_scenario/DTCDataGroup.js +63 -0
  171. package/www/capacitor/params/rfid_scenario/EDLDataGroups.js +135 -0
  172. package/www/capacitor/params/rfid_scenario/EIDDataGroups.js +191 -0
  173. package/www/capacitor/params/rfid_scenario/EPassportDataGroups.js +151 -0
  174. package/www/capacitor/params/rfid_scenario/RFIDScenario.js +584 -0
  175. package/www/capacitor/results/DocumentType.js +302 -0
  176. package/www/capacitor/results/Position.js +88 -0
  177. package/www/capacitor/results/Results.js +354 -0
  178. package/www/capacitor/results/TransactionInfo.js +24 -0
  179. package/www/capacitor/results/authenticity/Authenticity.js +24 -0
  180. package/www/capacitor/results/authenticity/AuthenticityCheck.js +43 -0
  181. package/www/capacitor/results/authenticity/AuthenticityElement.js +37 -0
  182. package/www/capacitor/results/authenticity/AuthenticityResult.js +33 -0
  183. package/www/capacitor/results/authenticity/CheckDiagnose.js +133 -0
  184. package/www/capacitor/results/authenticity/SecurityFeatureType.js +67 -0
  185. package/www/capacitor/results/barcode/BarcodeField.js +34 -0
  186. package/www/capacitor/results/barcode/BarcodeResult.js +30 -0
  187. package/www/capacitor/results/barcode/BarcodeStatus.js +33 -0
  188. package/www/capacitor/results/barcode/BarcodeType.js +21 -0
  189. package/www/capacitor/results/barcode/PDF417Info.js +24 -0
  190. package/www/capacitor/results/image_quality/ImageQuality.js +40 -0
  191. package/www/capacitor/results/image_quality/ImageQualityCheckType.js +19 -0
  192. package/www/capacitor/results/image_quality/ImageQualityGroup.js +39 -0
  193. package/www/capacitor/results/rfid/AccessControlProcedureType.js +30 -0
  194. package/www/capacitor/results/rfid/Application.js +63 -0
  195. package/www/capacitor/results/rfid/Attribute.js +23 -0
  196. package/www/capacitor/results/rfid/Authority.js +36 -0
  197. package/www/capacitor/results/rfid/CardProperties.js +57 -0
  198. package/www/capacitor/results/rfid/CertificateChain.js +69 -0
  199. package/www/capacitor/results/rfid/CertificateData.js +21 -0
  200. package/www/capacitor/results/rfid/DataField.js +23 -0
  201. package/www/capacitor/results/rfid/Extension.js +21 -0
  202. package/www/capacitor/results/rfid/File.js +56 -0
  203. package/www/capacitor/results/rfid/FileData.js +27 -0
  204. package/www/capacitor/results/rfid/RFIDAccessControlProcedureType.js +10 -0
  205. package/www/capacitor/results/rfid/RFIDCertificateType.js +14 -0
  206. package/www/capacitor/results/rfid/RFIDDataFileType.js +106 -0
  207. package/www/capacitor/results/rfid/RFIDSessionData.js +92 -0
  208. package/www/capacitor/results/rfid/RFIDValidity.js +23 -0
  209. package/www/capacitor/results/rfid/RFIDValue.js +30 -0
  210. package/www/capacitor/results/rfid/SecurityObject.js +41 -0
  211. package/www/capacitor/results/rfid/SecurityObjectCertificates.js +20 -0
  212. package/www/capacitor/results/rfid/SignerInfo.js +74 -0
  213. package/www/capacitor/results/status/AgeStatus.js +35 -0
  214. package/www/capacitor/results/status/CheckResult.js +5 -0
  215. package/www/capacitor/results/status/OpticalStatus.js +44 -0
  216. package/www/capacitor/results/status/RFIDStatus.js +38 -0
  217. package/www/capacitor/results/status/ResultsStatus.js +53 -0
  218. package/www/capacitor/results/visible_digital_seals/BytesData.js +27 -0
  219. package/www/capacitor/results/visible_digital_seals/DocFeature.js +23 -0
  220. package/www/capacitor/results/visible_digital_seals/LDSParsingErrorCodes.js +136 -0
  221. package/www/capacitor/results/visible_digital_seals/LDSParsingNotificationCodes.js +239 -0
  222. package/www/capacitor/results/visible_digital_seals/VDSData.js +75 -0
  223. package/www/capacitor/results/visible_digital_seals/VDSNCData.js +54 -0
  224. package/www/capacitor/results/visual_results/Comparison.js +27 -0
  225. package/www/capacitor/results/visual_results/FieldType.js +671 -0
  226. package/www/capacitor/results/visual_results/GraphicField.js +47 -0
  227. package/www/capacitor/results/visual_results/GraphicFieldType.js +25 -0
  228. package/www/capacitor/results/visual_results/GraphicResult.js +28 -0
  229. package/www/capacitor/results/visual_results/LCID.js +174 -0
  230. package/www/capacitor/results/visual_results/Lights.js +11 -0
  231. package/www/capacitor/results/visual_results/RFIDOrigin.js +27 -0
  232. package/www/capacitor/results/visual_results/Rect.js +27 -0
  233. package/www/capacitor/results/visual_results/Symbol.js +26 -0
  234. package/www/capacitor/results/visual_results/TextField.js +85 -0
  235. package/www/capacitor/results/visual_results/TextResult.js +52 -0
  236. package/www/capacitor/results/visual_results/TextSource.js +27 -0
  237. package/www/capacitor/results/visual_results/Validity.js +24 -0
  238. package/www/capacitor/results/visual_results/Value.js +52 -0
  239. package/www/capacitor/rfid/CAProtocol.js +27 -0
  240. package/www/capacitor/rfid/PAAttribute.js +24 -0
  241. package/www/capacitor/rfid/PACEProtocol.js +24 -0
  242. package/www/capacitor/rfid/PAResourcesIssuer.js +35 -0
  243. package/www/capacitor/rfid/PKDCertificate.js +65 -0
  244. package/www/capacitor/rfid/RFIDErrorCodes.js +123 -0
  245. package/www/capacitor/rfid/RFIDNotification.js +71 -0
  246. package/www/capacitor/rfid/TAChallenge.js +33 -0
  247. package/www/capacitor/rfid/TccParams.js +34 -0
  248. package/www/cordova.js +12948 -0
  249. package/www/react-native/config/FinalizeConfig.js +35 -0
  250. package/www/react-native/config/InitConfig.js +55 -0
  251. package/www/react-native/config/OnlineProcessingConfig.js +52 -0
  252. package/www/react-native/config/RFIDConfig.js +47 -0
  253. package/www/react-native/config/RecognizeConfig.js +138 -0
  254. package/www/react-native/config/ScannerConfig.js +48 -0
  255. package/www/react-native/index.js +758 -0
  256. package/www/react-native/info/DocReaderException.js +68 -0
  257. package/www/react-native/info/DocReaderScenario.js +89 -0
  258. package/www/react-native/info/DocReaderVersion.js +32 -0
  259. package/www/react-native/info/DocumentsDatabase.js +39 -0
  260. package/www/react-native/info/License.js +30 -0
  261. package/www/react-native/info/PrepareProgress.js +31 -0
  262. package/www/react-native/info/RFIDException.js +26 -0
  263. package/www/react-native/internal/bridge.js +131 -0
  264. package/www/react-native/mdl/DataRetrieval.js +55 -0
  265. package/www/react-native/mdl/DeviceEngagement.js +30 -0
  266. package/www/react-native/mdl/DeviceRetrievalMethod.js +41 -0
  267. package/www/react-native/mdl/DocumentRequestMDL.js +212 -0
  268. package/www/react-native/mdl/NameSpaceMDL.js +33 -0
  269. package/www/react-native/params/Functionality.js +387 -0
  270. package/www/react-native/params/customization/Customization.js +664 -0
  271. package/www/react-native/params/customization/CustomizationColors.js +231 -0
  272. package/www/react-native/params/customization/CustomizationContentModes.js +55 -0
  273. package/www/react-native/params/customization/CustomizationFonts.js +156 -0
  274. package/www/react-native/params/customization/CustomizationImages.js +199 -0
  275. package/www/react-native/params/customization/CustomizationMatrices.js +39 -0
  276. package/www/react-native/params/customization/CustomizationTimings.js +71 -0
  277. package/www/react-native/params/process_params/AuthenticityParams.js +166 -0
  278. package/www/react-native/params/process_params/AuthenticityPropertiesParams.js +39 -0
  279. package/www/react-native/params/process_params/BackendProcessingConfig.js +38 -0
  280. package/www/react-native/params/process_params/Bsi.js +23 -0
  281. package/www/react-native/params/process_params/FaceApiParams.js +55 -0
  282. package/www/react-native/params/process_params/FaceApiSearchParams.js +29 -0
  283. package/www/react-native/params/process_params/GlaresCheckParams.js +25 -0
  284. package/www/react-native/params/process_params/ImageQA.js +122 -0
  285. package/www/react-native/params/process_params/LivenessParams.js +87 -0
  286. package/www/react-native/params/process_params/OcclusionCheckParams.js +21 -0
  287. package/www/react-native/params/process_params/ProcessParams.js +724 -0
  288. package/www/react-native/params/process_params/RFIDParams.js +21 -0
  289. package/www/react-native/params/rfid_scenario/DTCDataGroup.js +63 -0
  290. package/www/react-native/params/rfid_scenario/EDLDataGroups.js +135 -0
  291. package/www/react-native/params/rfid_scenario/EIDDataGroups.js +191 -0
  292. package/www/react-native/params/rfid_scenario/EPassportDataGroups.js +151 -0
  293. package/www/react-native/params/rfid_scenario/RFIDScenario.js +584 -0
  294. package/www/react-native/results/DocumentType.js +302 -0
  295. package/www/react-native/results/Position.js +88 -0
  296. package/www/react-native/results/Results.js +354 -0
  297. package/www/react-native/results/TransactionInfo.js +24 -0
  298. package/www/react-native/results/authenticity/Authenticity.js +24 -0
  299. package/www/react-native/results/authenticity/AuthenticityCheck.js +43 -0
  300. package/www/react-native/results/authenticity/AuthenticityElement.js +37 -0
  301. package/www/react-native/results/authenticity/AuthenticityResult.js +33 -0
  302. package/www/react-native/results/authenticity/CheckDiagnose.js +133 -0
  303. package/www/react-native/results/authenticity/SecurityFeatureType.js +67 -0
  304. package/www/react-native/results/barcode/BarcodeField.js +34 -0
  305. package/www/react-native/results/barcode/BarcodeResult.js +30 -0
  306. package/www/react-native/results/barcode/BarcodeStatus.js +33 -0
  307. package/www/react-native/results/barcode/BarcodeType.js +21 -0
  308. package/www/react-native/results/barcode/PDF417Info.js +24 -0
  309. package/www/react-native/results/image_quality/ImageQuality.js +40 -0
  310. package/www/react-native/results/image_quality/ImageQualityCheckType.js +19 -0
  311. package/www/react-native/results/image_quality/ImageQualityGroup.js +39 -0
  312. package/www/react-native/results/rfid/AccessControlProcedureType.js +30 -0
  313. package/www/react-native/results/rfid/Application.js +63 -0
  314. package/www/react-native/results/rfid/Attribute.js +23 -0
  315. package/www/react-native/results/rfid/Authority.js +36 -0
  316. package/www/react-native/results/rfid/CardProperties.js +57 -0
  317. package/www/react-native/results/rfid/CertificateChain.js +69 -0
  318. package/www/react-native/results/rfid/CertificateData.js +21 -0
  319. package/www/react-native/results/rfid/DataField.js +23 -0
  320. package/www/react-native/results/rfid/Extension.js +21 -0
  321. package/www/react-native/results/rfid/File.js +56 -0
  322. package/www/react-native/results/rfid/FileData.js +27 -0
  323. package/www/react-native/results/rfid/RFIDAccessControlProcedureType.js +10 -0
  324. package/www/react-native/results/rfid/RFIDCertificateType.js +14 -0
  325. package/www/react-native/results/rfid/RFIDDataFileType.js +106 -0
  326. package/www/react-native/results/rfid/RFIDSessionData.js +92 -0
  327. package/www/react-native/results/rfid/RFIDValidity.js +23 -0
  328. package/www/react-native/results/rfid/RFIDValue.js +30 -0
  329. package/www/react-native/results/rfid/SecurityObject.js +41 -0
  330. package/www/react-native/results/rfid/SecurityObjectCertificates.js +20 -0
  331. package/www/react-native/results/rfid/SignerInfo.js +74 -0
  332. package/www/react-native/results/status/AgeStatus.js +35 -0
  333. package/www/react-native/results/status/CheckResult.js +5 -0
  334. package/www/react-native/results/status/OpticalStatus.js +44 -0
  335. package/www/react-native/results/status/RFIDStatus.js +38 -0
  336. package/www/react-native/results/status/ResultsStatus.js +53 -0
  337. package/www/react-native/results/visible_digital_seals/BytesData.js +27 -0
  338. package/www/react-native/results/visible_digital_seals/DocFeature.js +23 -0
  339. package/www/react-native/results/visible_digital_seals/LDSParsingErrorCodes.js +136 -0
  340. package/www/react-native/results/visible_digital_seals/LDSParsingNotificationCodes.js +239 -0
  341. package/www/react-native/results/visible_digital_seals/VDSData.js +75 -0
  342. package/www/react-native/results/visible_digital_seals/VDSNCData.js +54 -0
  343. package/www/react-native/results/visual_results/Comparison.js +27 -0
  344. package/www/react-native/results/visual_results/FieldType.js +671 -0
  345. package/www/react-native/results/visual_results/GraphicField.js +47 -0
  346. package/www/react-native/results/visual_results/GraphicFieldType.js +25 -0
  347. package/www/react-native/results/visual_results/GraphicResult.js +28 -0
  348. package/www/react-native/results/visual_results/LCID.js +174 -0
  349. package/www/react-native/results/visual_results/Lights.js +11 -0
  350. package/www/react-native/results/visual_results/RFIDOrigin.js +27 -0
  351. package/www/react-native/results/visual_results/Rect.js +27 -0
  352. package/www/react-native/results/visual_results/Symbol.js +26 -0
  353. package/www/react-native/results/visual_results/TextField.js +85 -0
  354. package/www/react-native/results/visual_results/TextResult.js +52 -0
  355. package/www/react-native/results/visual_results/TextSource.js +27 -0
  356. package/www/react-native/results/visual_results/Validity.js +24 -0
  357. package/www/react-native/results/visual_results/Value.js +52 -0
  358. package/www/react-native/rfid/CAProtocol.js +27 -0
  359. package/www/react-native/rfid/PAAttribute.js +24 -0
  360. package/www/react-native/rfid/PACEProtocol.js +24 -0
  361. package/www/react-native/rfid/PAResourcesIssuer.js +35 -0
  362. package/www/react-native/rfid/PKDCertificate.js +65 -0
  363. package/www/react-native/rfid/RFIDErrorCodes.js +123 -0
  364. package/www/react-native/rfid/RFIDNotification.js +71 -0
  365. package/www/react-native/rfid/TAChallenge.js +33 -0
  366. package/www/react-native/rfid/TccParams.js +34 -0
  367. package/www/types/config/FinalizeConfig.d.ts +6 -0
  368. package/www/types/config/InitConfig.d.ts +68 -0
  369. package/www/types/config/OnlineProcessingConfig.d.ts +22 -0
  370. package/www/types/config/RFIDConfig.d.ts +178 -0
  371. package/www/types/config/RecognizeConfig.d.ts +126 -0
  372. package/www/types/config/ScannerConfig.d.ts +54 -0
  373. package/www/types/index.d.ts +656 -0
  374. package/www/types/info/DocReaderException.d.ts +85 -0
  375. package/www/types/info/DocReaderScenario.d.ts +90 -0
  376. package/www/types/info/DocReaderVersion.d.ts +28 -0
  377. package/www/types/info/DocumentsDatabase.d.ts +42 -0
  378. package/www/types/info/License.d.ts +23 -0
  379. package/www/types/info/PrepareProgress.d.ts +15 -0
  380. package/www/types/info/RFIDException.d.ts +8 -0
  381. package/www/types/mdl/DataRetrieval.d.ts +28 -0
  382. package/www/types/mdl/DeviceEngagement.d.ts +16 -0
  383. package/www/types/mdl/DeviceRetrievalMethod.d.ts +18 -0
  384. package/www/types/mdl/DocumentRequestMDL.d.ts +63 -0
  385. package/www/types/mdl/NameSpaceMDL.d.ts +16 -0
  386. package/www/types/params/Functionality.d.ts +337 -0
  387. package/www/types/params/customization/Customization.d.ts +584 -0
  388. package/www/types/params/customization/CustomizationColors.d.ts +42 -0
  389. package/www/types/params/customization/CustomizationContentModes.d.ts +41 -0
  390. package/www/types/params/customization/CustomizationFonts.d.ts +63 -0
  391. package/www/types/params/customization/CustomizationImages.d.ts +34 -0
  392. package/www/types/params/customization/CustomizationMatrices.d.ts +10 -0
  393. package/www/types/params/customization/CustomizationTimings.d.ts +14 -0
  394. package/www/types/params/process_params/AuthenticityParams.d.ts +31 -0
  395. package/www/types/params/process_params/AuthenticityPropertiesParams.d.ts +12 -0
  396. package/www/types/params/process_params/BackendProcessingConfig.d.ts +27 -0
  397. package/www/types/params/process_params/Bsi.d.ts +3 -0
  398. package/www/types/params/process_params/FaceApiParams.d.ts +72 -0
  399. package/www/types/params/process_params/FaceApiSearchParams.d.ts +35 -0
  400. package/www/types/params/process_params/GlaresCheckParams.d.ts +26 -0
  401. package/www/types/params/process_params/ImageQA.d.ts +85 -0
  402. package/www/types/params/process_params/LivenessParams.d.ts +18 -0
  403. package/www/types/params/process_params/OcclusionCheckParams.d.ts +16 -0
  404. package/www/types/params/process_params/ProcessParams.d.ts +496 -0
  405. package/www/types/params/process_params/RFIDParams.d.ts +19 -0
  406. package/www/types/params/rfid_scenario/DTCDataGroup.d.ts +13 -0
  407. package/www/types/params/rfid_scenario/EDLDataGroups.d.ts +22 -0
  408. package/www/types/params/rfid_scenario/EIDDataGroups.d.ts +29 -0
  409. package/www/types/params/rfid_scenario/EPassportDataGroups.d.ts +24 -0
  410. package/www/types/params/rfid_scenario/RFIDScenario.d.ts +178 -0
  411. package/www/types/results/DocumentType.d.ts +525 -0
  412. package/www/types/results/Position.d.ts +50 -0
  413. package/www/types/results/Results.d.ts +295 -0
  414. package/www/types/results/TransactionInfo.d.ts +9 -0
  415. package/www/types/results/authenticity/Authenticity.d.ts +68 -0
  416. package/www/types/results/authenticity/AuthenticityCheck.d.ts +23 -0
  417. package/www/types/results/authenticity/AuthenticityElement.d.ts +26 -0
  418. package/www/types/results/authenticity/AuthenticityResult.d.ts +16 -0
  419. package/www/types/results/authenticity/CheckDiagnose.d.ts +242 -0
  420. package/www/types/results/authenticity/SecurityFeatureType.d.ts +110 -0
  421. package/www/types/results/barcode/BarcodeField.d.ts +37 -0
  422. package/www/types/results/barcode/BarcodeResult.d.ts +14 -0
  423. package/www/types/results/barcode/BarcodeStatus.d.ts +66 -0
  424. package/www/types/results/barcode/BarcodeType.d.ts +45 -0
  425. package/www/types/results/barcode/PDF417Info.d.ts +15 -0
  426. package/www/types/results/image_quality/ImageQuality.d.ts +18 -0
  427. package/www/types/results/image_quality/ImageQualityCheckType.d.ts +30 -0
  428. package/www/types/results/image_quality/ImageQualityGroup.d.ts +17 -0
  429. package/www/types/results/rfid/AccessControlProcedureType.d.ts +21 -0
  430. package/www/types/results/rfid/Application.d.ts +48 -0
  431. package/www/types/results/rfid/Attribute.d.ts +9 -0
  432. package/www/types/results/rfid/Authority.d.ts +11 -0
  433. package/www/types/results/rfid/CardProperties.d.ts +48 -0
  434. package/www/types/results/rfid/CertificateChain.d.ts +28 -0
  435. package/www/types/results/rfid/CertificateData.d.ts +7 -0
  436. package/www/types/results/rfid/DataField.d.ts +9 -0
  437. package/www/types/results/rfid/Extension.d.ts +7 -0
  438. package/www/types/results/rfid/File.d.ts +22 -0
  439. package/www/types/results/rfid/FileData.d.ts +9 -0
  440. package/www/types/results/rfid/RFIDAccessControlProcedureType.d.ts +18 -0
  441. package/www/types/results/rfid/RFIDCertificateType.d.ts +14 -0
  442. package/www/types/results/rfid/RFIDDataFileType.d.ts +108 -0
  443. package/www/types/results/rfid/RFIDSessionData.d.ts +48 -0
  444. package/www/types/results/rfid/RFIDValidity.d.ts +9 -0
  445. package/www/types/results/rfid/RFIDValue.d.ts +10 -0
  446. package/www/types/results/rfid/SecurityObject.d.ts +28 -0
  447. package/www/types/results/rfid/SecurityObjectCertificates.d.ts +8 -0
  448. package/www/types/results/rfid/SignerInfo.d.ts +41 -0
  449. package/www/types/results/status/AgeStatus.d.ts +14 -0
  450. package/www/types/results/status/CheckResult.d.ts +8 -0
  451. package/www/types/results/status/OpticalStatus.d.ts +29 -0
  452. package/www/types/results/status/RFIDStatus.d.ts +22 -0
  453. package/www/types/results/status/ResultsStatus.d.ts +32 -0
  454. package/www/types/results/visible_digital_seals/BytesData.d.ts +9 -0
  455. package/www/types/results/visible_digital_seals/DocFeature.d.ts +9 -0
  456. package/www/types/results/visible_digital_seals/LDSParsingErrorCodes.d.ts +134 -0
  457. package/www/types/results/visible_digital_seals/LDSParsingNotificationCodes.d.ts +237 -0
  458. package/www/types/results/visible_digital_seals/VDSData.d.ts +32 -0
  459. package/www/types/results/visible_digital_seals/VDSNCData.d.ts +35 -0
  460. package/www/types/results/visual_results/Comparison.d.ts +15 -0
  461. package/www/types/results/visual_results/FieldType.d.ts +1328 -0
  462. package/www/types/results/visual_results/GraphicField.d.ts +29 -0
  463. package/www/types/results/visual_results/GraphicFieldType.d.ts +52 -0
  464. package/www/types/results/visual_results/GraphicResult.d.ts +10 -0
  465. package/www/types/results/visual_results/LCID.d.ts +173 -0
  466. package/www/types/results/visual_results/Lights.d.ts +23 -0
  467. package/www/types/results/visual_results/RFIDOrigin.d.ts +10 -0
  468. package/www/types/results/visual_results/Rect.d.ts +9 -0
  469. package/www/types/results/visual_results/Symbol.d.ts +14 -0
  470. package/www/types/results/visual_results/TextField.d.ts +40 -0
  471. package/www/types/results/visual_results/TextResult.d.ts +23 -0
  472. package/www/types/results/visual_results/TextSource.d.ts +15 -0
  473. package/www/types/results/visual_results/Validity.d.ts +13 -0
  474. package/www/types/results/visual_results/Value.d.ts +27 -0
  475. package/www/types/rfid/CAProtocol.d.ts +6 -0
  476. package/www/types/rfid/PAAttribute.d.ts +4 -0
  477. package/www/types/rfid/PACEProtocol.d.ts +5 -0
  478. package/www/types/rfid/PAResourcesIssuer.d.ts +7 -0
  479. package/www/types/rfid/PKDCertificate.d.ts +40 -0
  480. package/www/types/rfid/RFIDErrorCodes.d.ts +121 -0
  481. package/www/types/rfid/RFIDNotification.d.ts +156 -0
  482. package/www/types/rfid/TAChallenge.d.ts +7 -0
  483. package/www/types/rfid/TccParams.d.ts +25 -0
@@ -0,0 +1,2192 @@
1
+ @file:SuppressLint("MissingPermission")
2
+ @file:Suppress("unused", "EnumValuesSoftDeprecate", "UNCHECKED_CAST")
3
+
4
+ package com.regula.plugin.document.reader
5
+
6
+ import android.annotation.SuppressLint
7
+ import android.graphics.Bitmap
8
+ import android.graphics.Matrix
9
+ import android.graphics.Rect
10
+ import android.graphics.Typeface
11
+ import android.os.Build
12
+ import android.util.Pair
13
+ import com.regula.common.exception.RegulaException
14
+ import com.regula.documentreader.api.License
15
+ import com.regula.documentreader.api.completions.model.PrepareProgress
16
+ import com.regula.documentreader.api.config.FinalizeConfig
17
+ import com.regula.documentreader.api.config.RecognizeConfig
18
+ import com.regula.documentreader.api.config.ScannerConfig
19
+ import com.regula.documentreader.api.enums.BarcodeType
20
+ import com.regula.documentreader.api.enums.DocReaderAction
21
+ import com.regula.documentreader.api.enums.PDF417Info
22
+ import com.regula.documentreader.api.enums.eGraphicFieldType
23
+ import com.regula.documentreader.api.enums.eMDLDeviceRetrieval
24
+ import com.regula.documentreader.api.enums.eMDLDocRequestPreset
25
+ import com.regula.documentreader.api.enums.eMDLIntentToRetain
26
+ import com.regula.documentreader.api.enums.eRFID_DataFile_Type
27
+ import com.regula.documentreader.api.enums.eRPRM_Lights
28
+ import com.regula.documentreader.api.listener.NetworkInterceptorListener
29
+ import com.regula.documentreader.api.params.AuthenticityParams
30
+ import com.regula.documentreader.api.params.AuthenticityPropertiesParams
31
+ import com.regula.documentreader.api.params.BackendProcessingConfig
32
+ import com.regula.documentreader.api.params.BleDeviceConfig
33
+ import com.regula.documentreader.api.params.Bsi
34
+ import com.regula.documentreader.api.params.DocReaderConfig
35
+ import com.regula.documentreader.api.params.FaceApiParams
36
+ import com.regula.documentreader.api.params.Functionality
37
+ import com.regula.documentreader.api.params.ImageInputData
38
+ import com.regula.documentreader.api.params.ImageQA
39
+ import com.regula.documentreader.api.params.ImageQA.GlaresCheckParams
40
+ import com.regula.documentreader.api.params.LivenessParams
41
+ import com.regula.documentreader.api.params.OcclusionCheckParams
42
+ import com.regula.documentreader.api.params.OnlineProcessingConfig
43
+ import com.regula.documentreader.api.params.ParamsCustomization
44
+ import com.regula.documentreader.api.params.ProcessParam
45
+ import com.regula.documentreader.api.params.RfidScenario
46
+ import com.regula.documentreader.api.params.mdl.DataRetrieval
47
+ import com.regula.documentreader.api.params.mdl.DeviceEngagement
48
+ import com.regula.documentreader.api.params.mdl.DeviceRetrievalMethod
49
+ import com.regula.documentreader.api.params.mdl.DocumentRequest18013MDL
50
+ import com.regula.documentreader.api.params.mdl.DocumentRequestMDL
51
+ import com.regula.documentreader.api.params.mdl.NameSpaceMDL
52
+ import com.regula.documentreader.api.params.rfid.CaProtocol
53
+ import com.regula.documentreader.api.params.rfid.PKDCertificate
54
+ import com.regula.documentreader.api.params.rfid.PaceProtocol
55
+ import com.regula.documentreader.api.params.rfid.RFIDParams
56
+ import com.regula.documentreader.api.params.rfid.TccParams
57
+ import com.regula.documentreader.api.params.rfid.authorization.PAAttribute
58
+ import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer
59
+ import com.regula.documentreader.api.params.rfid.authorization.TAChallenge
60
+ import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
61
+ import com.regula.documentreader.api.params.rfid.dg.EDLDataGroups
62
+ import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
63
+ import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
64
+ import com.regula.documentreader.api.results.BytesData
65
+ import com.regula.documentreader.api.results.Coordinate
66
+ import com.regula.documentreader.api.results.DocFeature
67
+ import com.regula.documentreader.api.results.DocReaderDocumentsDatabase
68
+ import com.regula.documentreader.api.results.DocReaderFieldRect
69
+ import com.regula.documentreader.api.results.DocReaderVersion
70
+ import com.regula.documentreader.api.results.DocumentReaderBarcodeField
71
+ import com.regula.documentreader.api.results.DocumentReaderBarcodeResult
72
+ import com.regula.documentreader.api.results.DocumentReaderComparison
73
+ import com.regula.documentreader.api.results.DocumentReaderDocumentType
74
+ import com.regula.documentreader.api.results.DocumentReaderGraphicField
75
+ import com.regula.documentreader.api.results.DocumentReaderGraphicResult
76
+ import com.regula.documentreader.api.results.DocumentReaderNotification
77
+ import com.regula.documentreader.api.results.DocumentReaderResults
78
+ import com.regula.documentreader.api.results.DocumentReaderResultsStatus
79
+ import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsOptical
80
+ import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsRFID
81
+ import com.regula.documentreader.api.results.DocumentReaderResultsStatus.DetailsAge
82
+ import com.regula.documentreader.api.results.DocumentReaderRfidOrigin
83
+ import com.regula.documentreader.api.results.DocumentReaderScenario
84
+ import com.regula.documentreader.api.results.DocumentReaderSymbol
85
+ import com.regula.documentreader.api.results.DocumentReaderTextField
86
+ import com.regula.documentreader.api.results.DocumentReaderTextResult
87
+ import com.regula.documentreader.api.results.DocumentReaderTextSource
88
+ import com.regula.documentreader.api.results.DocumentReaderValidity
89
+ import com.regula.documentreader.api.results.DocumentReaderValue
90
+ import com.regula.documentreader.api.results.ElementPosition
91
+ import com.regula.documentreader.api.results.ImageQuality
92
+ import com.regula.documentreader.api.results.ImageQualityGroup
93
+ import com.regula.documentreader.api.results.TransactionInfo
94
+ import com.regula.documentreader.api.results.VDSData
95
+ import com.regula.documentreader.api.results.VDSNCData
96
+ import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck
97
+ import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement
98
+ import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult
99
+ import com.regula.documentreader.api.results.rfid.AccessControlProcedureType
100
+ import com.regula.documentreader.api.results.rfid.Application
101
+ import com.regula.documentreader.api.results.rfid.Attribute
102
+ import com.regula.documentreader.api.results.rfid.Authority
103
+ import com.regula.documentreader.api.results.rfid.CardProperties
104
+ import com.regula.documentreader.api.results.rfid.CertificateChain
105
+ import com.regula.documentreader.api.results.rfid.CertificateData
106
+ import com.regula.documentreader.api.results.rfid.DataField
107
+ import com.regula.documentreader.api.results.rfid.Extension
108
+ import com.regula.documentreader.api.results.rfid.File
109
+ import com.regula.documentreader.api.results.rfid.FileData
110
+ import com.regula.documentreader.api.results.rfid.RFIDSessionData
111
+ import com.regula.documentreader.api.results.rfid.SecurityObject
112
+ import com.regula.documentreader.api.results.rfid.SecurityObjectCertificates
113
+ import com.regula.documentreader.api.results.rfid.SignerInfo
114
+ import com.regula.documentreader.api.results.rfid.Validity
115
+ import com.regula.documentreader.api.results.rfid.Value
116
+ import org.json.JSONArray
117
+ import org.json.JSONObject
118
+ import com.regula.plugin.document.reader.Convert.toBase64
119
+ import com.regula.plugin.document.reader.Convert.toBitmap
120
+ import com.regula.plugin.document.reader.Convert.toByteArray
121
+
122
+ fun generateCompletion(action: Int, results: DocumentReaderResults?, error: RegulaException?) = mapOf(
123
+ "action" to action,
124
+ "results" to if (listOf(DocReaderAction.COMPLETE, DocReaderAction.MORE_PAGES_AVAILABLE, DocReaderAction.CANCEL, DocReaderAction.ERROR, DocReaderAction.TIMEOUT).contains(action)) generateDocumentReaderResults(results) else null,
125
+ "error" to generateRegulaException(error)
126
+ ).toJson()
127
+
128
+ fun generateSuccessCompletion(success: Boolean, error: RegulaException?) = mapOf(
129
+ "success" to success,
130
+ "error" to generateRegulaException(error)
131
+ ).toJson()
132
+
133
+ fun prepareProgressFromJSON(it: JSONObject) = PrepareProgress(
134
+ it.getInt("downloadedBytes"),
135
+ it.getInt("totalBytes")
136
+ )
137
+
138
+ fun generatePrepareProgress(it: PrepareProgress) = mapOf(
139
+ "downloadedBytes" to it.downloadedBytes,
140
+ "totalBytes" to it.totalBytes,
141
+ "progress" to it.progress
142
+ ).toJson()
143
+
144
+ fun generatePACertificateCompletion(serialNumber: ByteArray?, issuer: PAResourcesIssuer?) = mapOf(
145
+ "serialNumber" to serialNumber.toBase64(),
146
+ "issuer" to generatePAResourcesIssuer(issuer)
147
+ ).toJson()
148
+
149
+ fun generateFinalizePackageCompletion(action: Int, info: TransactionInfo?, error: RegulaException?) = mapOf(
150
+ "action" to action,
151
+ "info" to generateTransactionInfo(info),
152
+ "error" to generateRegulaException(error)
153
+ ).toJson()
154
+
155
+ fun regulaExceptionFromJSON(input: JSONObject?) = input?.let {
156
+ RegulaException(
157
+ it.optInt("code"),
158
+ it.optString("message")
159
+ )
160
+ }
161
+
162
+ fun generateRegulaException(input: RegulaException?) = input?.let {
163
+ mapOf(
164
+ "code" to it.errorCode,
165
+ "message" to it.message
166
+ ).toJson()
167
+ }
168
+
169
+ fun transactionInfoFromJSON(input: JSONObject?) = input?.let {
170
+ val result = TransactionInfo()
171
+ result.transactionId = it.getStringOrNull("transactionId")
172
+ result.tag = it.getStringOrNull("tag")
173
+ result.sessionLogFolder = it.getStringOrNull("sessionLogFolder")
174
+ result
175
+ }
176
+
177
+ fun generateTransactionInfo(input: TransactionInfo?) = input?.let {
178
+ mapOf(
179
+ "transactionId" to it.transactionId,
180
+ "tag" to it.tag,
181
+ "sessionLogFolder" to it.sessionLogFolder
182
+ ).toJson()
183
+ }
184
+
185
+ fun tccParamsFromJSON(input: JSONObject) = input.let {
186
+ val result = TccParams()
187
+ result.serviceUrlTA = it.getStringOrNull("serviceUrlTA")
188
+ result.serviceUrlPA = it.getStringOrNull("serviceUrlPA")
189
+ result.pfxCertUrl = it.getStringOrNull("pfxCertUrl")
190
+ result.pfxPassPhrase = it.getStringOrNull("pfxPassPhrase")
191
+ result.pfxCert = it.getStringOrNull("pfxCert").toByteArray()
192
+ result
193
+ }
194
+
195
+ fun generateTccParams(input: TccParams?) = input?.let {
196
+ mapOf(
197
+ "serviceUrlTA" to it.serviceUrlTA,
198
+ "serviceUrlPA" to it.serviceUrlPA,
199
+ "pfxCertUrl" to it.pfxCertUrl,
200
+ "pfxPassPhrase" to it.pfxPassPhrase,
201
+ "pfxCert" to it.pfxCert.toBase64()
202
+ ).toJson()
203
+ }
204
+
205
+ fun initConfigFromJSON(input: JSONObject) = input.let {
206
+ val license = it.getString("license").toByteArray()!!
207
+ var result = DocReaderConfig(license)
208
+ if (it.has("customDb")) result = DocReaderConfig(license, it.getString("customDb").toByteArray()!!)
209
+ if (it.has("databasePath")) result = DocReaderConfig(license, it.getString("databasePath"))
210
+
211
+ if (it.has("licenseUpdate")) result.setLicenseUpdate(it.getBoolean("licenseUpdate"))
212
+ if (it.has("delayedNNLoad")) result.isDelayedNNLoad = it.getBoolean("delayedNNLoad")
213
+ result.licenseUpdateTimeout = it.getDoubleOrNull("licenseUpdateTimeout")
214
+ result.blackList = it.getJSONObjectOrNull("blackList")
215
+ result
216
+ }
217
+
218
+ fun generateInitConfig(input: DocReaderConfig?) = input?.let {
219
+ mapOf(
220
+ "license" to it.license.toBase64(),
221
+ "customDb" to it.customDb.toBase64(),
222
+ "databasePath" to it.customDbPath,
223
+ "licenseUpdate" to it.isLicenseUpdate,
224
+ "delayedNNLoad" to it.isDelayedNNLoad,
225
+ "licenseUpdateTimeout" to it.licenseUpdateTimeout,
226
+ "blackList" to it.blackList
227
+ ).toJson()
228
+ }
229
+
230
+ fun initBleDeviceConfigFromJSON(input: JSONObject) = input.let {
231
+ var result = BleDeviceConfig(bluetooth!!)
232
+ if (it.has("customDb")) result = BleDeviceConfig(bluetooth!!, it.getString("customDb").toByteArray())
233
+
234
+ if (it.has("licenseUpdate")) result.setLicenseUpdate(it.getBoolean("licenseUpdate"))
235
+ if (it.has("delayedNNLoad")) result.isDelayedNNLoad = it.getBoolean("delayedNNLoad")
236
+ result.licenseUpdateTimeout = it.getDoubleOrNull("licenseUpdateTimeout")
237
+ result.blackList = it.getJSONObjectOrNull("blackList")
238
+ result
239
+ }
240
+
241
+ fun scannerConfigFromJSON(input: JSONObject) = input.let {
242
+ val builder = if (it.has("scenario")) ScannerConfig.Builder(it.getString("scenario"))
243
+ else ScannerConfig.Builder(onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig"))!!)
244
+
245
+ if (it.has("onlineProcessingConfig")) builder.setOnlineProcessingConfig(onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig")))
246
+ if (it.has("livePortrait")) builder.setLivePortrait(it.getString("livePortrait").toBitmap()!!)
247
+ if (it.has("extPortrait")) builder.setExtPortrait(it.getString("extPortrait").toBitmap()!!)
248
+ if (it.has("cameraId")) builder.setCameraId(it.getInt("cameraId"))
249
+ builder.build()
250
+ }
251
+
252
+ fun generateScannerConfig(input: ScannerConfig?) = input?.let {
253
+ mapOf(
254
+ "scenario" to it.scenario,
255
+ "onlineProcessingConfig" to generateOnlineProcessingConfig(it.onlineProcessingConfig),
256
+ "livePortrait" to it.livePortrait.toBase64(),
257
+ "extPortrait" to it.extPortrait.toBase64(),
258
+ "cameraId" to it.cameraId
259
+ ).toJson()
260
+ }
261
+
262
+ fun recognizeConfigFromJSON(input: JSONObject) = input.let {
263
+ val builder =
264
+ if (it.has("scenario") && it.has("onlineProcessingConfig")) RecognizeConfig.Builder(it.getString("scenario"), onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig"))!!)
265
+ else if (it.has("scenario")) RecognizeConfig.Builder(it.getString("scenario"))
266
+ else RecognizeConfig.Builder(onlineProcessingConfigFromJSON(it.getJSONObject("onlineProcessingConfig"))!!)
267
+
268
+ if (it.has("oneShotIdentification")) builder.setOneShotIdentification(it.getBoolean("oneShotIdentification"))
269
+ if (it.has("dtc")) builder.setDTC(it.getString("dtc").toByteArray()!!)
270
+ if (it.has("livePortrait")) builder.setLivePortrait(it.getString("livePortrait").toBitmap()!!)
271
+ if (it.has("extPortrait")) builder.setExtPortrait(it.getString("extPortrait").toBitmap()!!)
272
+ if (it.has("image")) builder.setBitmap(it.getString("image").toBitmap()!!)
273
+ if (it.has("data")) builder.setData(it.getString("data").toByteArray()!!)
274
+ if (it.has("images")) {
275
+ val base64Images = it.getJSONArray("images")
276
+ val images = arrayOfNulls<Bitmap>(base64Images.length())
277
+ for (i in images.indices) images[i] = base64Images.getString(i).toBitmap()
278
+ builder.setBitmaps(images)
279
+ }
280
+ if (it.has("dataList")) {
281
+ val array = it.getJSONArray("dataList")
282
+ val dataList = mutableListOf<ByteArray>()
283
+ for (i in 0..< array.length()) dataList.add(array.getString(i).toByteArray()!!)
284
+ builder.setData(dataList)
285
+ }
286
+ if (it.has("imageInputData")) {
287
+ val base64InputData = it.getJSONArray("imageInputData")
288
+ val inputData = arrayOfNulls<ImageInputData>(base64InputData.length())
289
+ for (i in inputData.indices) inputData[i] = imageInputDataFromJSON(base64InputData.getJSONObject(i))
290
+ builder.setImageInputData(inputData)
291
+ }
292
+ builder.build()
293
+ }
294
+
295
+ fun generateRecognizeConfig(input: RecognizeConfig?) = input?.let {
296
+ mapOf(
297
+ "scenario" to it.scenario,
298
+ "onlineProcessingConfig" to generateOnlineProcessingConfig(it.onlineProcessingConfig),
299
+ "oneShotIdentification" to it.oneShotIdentification,
300
+ "dtc" to it.dtc.toBase64(),
301
+ "livePortrait" to it.livePortrait.toBase64(),
302
+ "extPortrait" to it.extPortrait.toBase64(),
303
+ "image" to it.bitmap.toBase64(),
304
+ "images" to it.bitmaps?.map { bp -> bp.toBase64() }?.toJson(),
305
+ "dataList" to it.data?.map { bp -> bp.toBase64() }?.toJson(),
306
+ "imageInputData" to it.imageInputData.toJson(::generateImageInputData)
307
+ ).toJson()
308
+ }
309
+
310
+ fun backendProcessingConfigFromJSON(input: JSONObject?) = input?.let {
311
+ val result = BackendProcessingConfig(it.getString("url"))
312
+ if (it.has("httpHeaders")) {
313
+ val httpHeaders: MutableMap<String, String> = HashMap()
314
+ it.getJSONObject("httpHeaders").forEach { key, value -> httpHeaders[key] = value as String }
315
+ result.httpHeaders = httpHeaders
316
+ }
317
+ result.rfidServerSideChipVerification = it.getBooleanOrNull("rfidServerSideChipVerification")
318
+ result.timeoutConnection = it.getDoubleOrNull("timeoutConnection")
319
+ if (it.has("mdlVerification")) result.mdlVerification = it.getBoolean("mdlVerification")
320
+ result
321
+ }
322
+
323
+ fun generateBackendProcessingConfig(input: BackendProcessingConfig?) = input?.let {
324
+ mapOf(
325
+ "url" to it.url,
326
+ "rfidServerSideChipVerification" to it.rfidServerSideChipVerification,
327
+ "timeoutConnection" to it.timeoutConnection,
328
+ "httpHeaders" to if (it.httpHeaders == null) null else {
329
+ val httpHeaders = JSONObject()
330
+ for ((key, value) in it.httpHeaders!!) httpHeaders.put(key, value)
331
+ httpHeaders
332
+ },
333
+ "mdlVerification" to it.mdlVerification,
334
+ ).toJson()
335
+ }
336
+
337
+ fun bsiFromJSON(input: JSONObject?) = input?.let {
338
+ val result = Bsi()
339
+ result.generateResult = it.getBooleanOrNull("generateResult")
340
+ result
341
+ }
342
+
343
+ fun generateBsi(input: Bsi?) = input?.let {
344
+ mapOf(
345
+ "generateResult" to it.generateResult,
346
+ ).toJson()
347
+ }
348
+
349
+ val weakReferencesHolder = mutableListOf<Any>()
350
+ fun onlineProcessingConfigFromJSON(input: JSONObject?) = input?.let {
351
+ val builder = OnlineProcessingConfig.Builder(it.getInt("mode"))
352
+
353
+ if (it.has("imageFormat")) builder.setImageFormat(it.getInt("imageFormat"))
354
+ if (it.has("url")) builder.setUrl(it.getString("url"))
355
+ if (it.has("imageCompressionQuality")) builder.setImageCompressionQuality(it.getDouble("imageCompressionQuality").toFloat())
356
+ if (it.has("processParams")) builder.setProcessParams(processParamFromJSON(it.getJSONObject("processParams")))
357
+ if (it.has("requestHeaders")) {
358
+ val listener = NetworkInterceptorListener { self -> input.getJSONObject("requestHeaders").forEach { k, v -> self.setRequestProperty(k, v as String) } }
359
+ weakReferencesHolder.add(listener)
360
+ builder.setNetworkInterceptorListener(listener)
361
+ }
362
+ builder.build()
363
+ }
364
+
365
+ fun generateOnlineProcessingConfig(input: OnlineProcessingConfig?) = input?.let {
366
+ mapOf(
367
+ "mode" to it.mode,
368
+ "url" to it.url,
369
+ "processParams" to getProcessParams(it.processParam),
370
+ "imageFormat" to it.imageFormat,
371
+ "imageCompressionQuality" to it.imageCompressionQuality
372
+ ).toJson()
373
+ }
374
+
375
+ fun faceApiParamsFromJSON(input: JSONObject?) = input?.let {
376
+ val result = FaceApiParams()
377
+
378
+ if (it.has("url")) result.url = it.getString("url")
379
+ if (it.has("mode")) result.mode = it.getString("mode")
380
+ if (it.has("threshold") && !it.isNull("threshold")) result.threshold = it.getInt("threshold")
381
+ if (it.has("serviceTimeout") && !it.isNull("serviceTimeout")) result.serviceTimeout = it.getInt("serviceTimeout")
382
+ result.search = faceApiSearchParamsFromJSON(it.getJSONObjectOrNull("searchParams"))
383
+ result.proxy = it.getStringOrNull("proxy")
384
+ result.proxyUserPwd = it.getStringOrNull("proxyPassword")
385
+ result.livenessTransactionId = it.getStringOrNull("livenessTransactionId")
386
+ result.proxyType = it.getIntOrNull("proxyType")
387
+
388
+ result
389
+ }
390
+
391
+ fun generateFaceApiParams(input: FaceApiParams?) = input?.let {
392
+ mapOf(
393
+ "url" to it.url,
394
+ "mode" to it.mode,
395
+ "searchParams" to generateFaceApiSearchParams(it.search),
396
+ "threshold" to it.threshold,
397
+ "serviceTimeout" to it.serviceTimeout,
398
+ "proxy" to it.proxy,
399
+ "proxyPassword" to it.proxyUserPwd,
400
+ "livenessTransactionId" to it.livenessTransactionId,
401
+ "proxyType" to it.proxyType
402
+ ).toJson()
403
+ }
404
+
405
+ fun faceApiSearchParamsFromJSON(input: JSONObject?) = input?.let {
406
+ val result = FaceApiParams.Search()
407
+
408
+ if (it.has("limit") && !it.isNull("limit")) result.limit = it.getInt("limit")
409
+ if (it.has("threshold") && !it.isNull("threshold")) result.threshold = it.getDouble("threshold").toFloat()
410
+ if (it.has("groupIds") && !it.isNull("groupIds")) {
411
+ val jsonArrayGroupIds = it.getJSONArray("groupIds")
412
+ val groupIds = arrayOfNulls<String>(jsonArrayGroupIds.length())
413
+ for (i in 0 until jsonArrayGroupIds.length())
414
+ groupIds[i] = jsonArrayGroupIds.getString(i)
415
+ result.groupIds = groupIds
416
+ }
417
+
418
+ result
419
+ }
420
+
421
+ fun generateFaceApiSearchParams(input: FaceApiParams.Search?) = input?.let {
422
+ mapOf(
423
+ "limit" to it.limit,
424
+ "threshold" to it.threshold,
425
+ "groupIds" to it.groupIds.toJson()
426
+ ).toJson()
427
+ }
428
+
429
+ fun rfidParamsFromJSON(input: JSONObject?) = input?.let {
430
+ val result = RFIDParams()
431
+ if (it.has("paIgnoreNotificationCodes")) result.paIgnoreNotificationCodes = it.getJSONArray("paIgnoreNotificationCodes").toIntArray()
432
+ result
433
+ }
434
+
435
+ fun generateRFIDParams(input: RFIDParams?) = input?.let {
436
+ mapOf(
437
+ "paIgnoreNotificationCodes" to it.paIgnoreNotificationCodes.toJson()
438
+ ).toJson()
439
+ }
440
+
441
+ fun processParamFromJSON(input: JSONObject): ProcessParam {
442
+ val result = ProcessParam()
443
+ setProcessParams(result, input)
444
+ return result
445
+ }
446
+
447
+ fun generateProcessParam(input: ProcessParam): JSONObject = getProcessParams(input)
448
+
449
+ fun imageQAFromJSON(input: JSONObject): ImageQA {
450
+ val result = ImageQA()
451
+ setImageQA(result, input)
452
+ return result
453
+ }
454
+
455
+ fun generateImageQA(input: ImageQA) = getImageQA(input)
456
+
457
+ fun authenticityParamsFromJSON(input: JSONObject): AuthenticityParams {
458
+ val result = AuthenticityParams.defaultParams()
459
+ setAuthenticityParams(result, input)
460
+ return result
461
+ }
462
+
463
+ fun generateAuthenticityParams(input: AuthenticityParams?) = getAuthenticityParams(input)
464
+
465
+ fun livenessParamsFromJSON(input: JSONObject): LivenessParams {
466
+ val result = LivenessParams.defaultParams()
467
+ setLivenessParams(result, input)
468
+ return result
469
+ }
470
+
471
+ fun generateLivenessParams(input: LivenessParams?) = getLivenessParams(input)
472
+
473
+ fun authenticityPropertiesParamsFromJSON(input: JSONObject): AuthenticityPropertiesParams {
474
+ val result = AuthenticityPropertiesParams.defaultParams()
475
+ setAuthenticityPropertiesParams(result, input)
476
+ return result
477
+ }
478
+
479
+ fun generateAuthenticityPropertiesParams(input: AuthenticityPropertiesParams?) = getAuthenticityPropertiesParams(input)
480
+
481
+ fun eDLDataGroupsFromJSON(input: JSONObject): EDLDataGroups {
482
+ val result = EDLDataGroups()
483
+ setDataGroups(result, input)
484
+ return result
485
+ }
486
+
487
+ fun generateEDLDataGroups(input: EDLDataGroups): JSONObject = getDataGroups(input)
488
+
489
+ fun ePassportDataGroupsFromJSON(input: JSONObject): EPassportDataGroups {
490
+ val result = EPassportDataGroups()
491
+ setDataGroups(result, input)
492
+ return result
493
+ }
494
+
495
+ fun generateEPassportDataGroups(input: EPassportDataGroups): JSONObject = getDataGroups(input)
496
+
497
+ fun eIDDataGroupsFromJSON(input: JSONObject): EIDDataGroups {
498
+ val result = EIDDataGroups()
499
+ setDataGroups(result, input)
500
+ return result
501
+ }
502
+
503
+ fun generateEIDDataGroups(input: EIDDataGroups): JSONObject = getDataGroups(input)
504
+
505
+ fun dtcDataGroupFromJSON(input: JSONObject): DTCDataGroup {
506
+ val result = DTCDataGroup()
507
+ setDTCDataGroup(result, input)
508
+ return result
509
+ }
510
+
511
+ fun generateDTCDataGroup(input: DTCDataGroup): JSONObject = getDTCDataGroup(input)
512
+
513
+ fun rfidScenarioFromJSON(input: JSONObject): RfidScenario {
514
+ val result = RfidScenario()
515
+ setRfidScenario(result, input)
516
+ return result
517
+ }
518
+
519
+ fun generateRfidScenario(input: RfidScenario): JSONObject = getRfidScenario(input)
520
+
521
+ fun customizationFromJSON(input: JSONObject): ParamsCustomization {
522
+ val result = ParamsCustomization()
523
+ setCustomization(result, input)
524
+ return result
525
+ }
526
+
527
+ fun generateCustomization(input: ParamsCustomization): JSONObject = getCustomization(input)
528
+
529
+ fun functionalityFromJSON(input: JSONObject): Functionality {
530
+ val result = Functionality()
531
+ setFunctionality(result, input)
532
+ return result
533
+ }
534
+
535
+ fun generateFunctionality(input: Functionality): JSONObject = getFunctionality(input)
536
+
537
+ fun glaresCheckParamsFromJSON(input: JSONObject?) = input?.let {
538
+ val result = GlaresCheckParams()
539
+ if (it.has("imgMarginPart")) result.imgMarginPart = it.getDouble("imgMarginPart")
540
+ if (it.has("maxGlaringPart")) result.maxGlaringPart = it.getDouble("maxGlaringPart")
541
+ result
542
+ }
543
+
544
+ fun generateGlaresCheckParams(input: GlaresCheckParams?) = input?.let {
545
+ mapOf(
546
+ "imgMarginPart" to it.imgMarginPart,
547
+ "maxGlaringPart" to it.maxGlaringPart
548
+ ).toJson()
549
+ }
550
+
551
+ fun occlusionCheckParamsFromJSON(input: JSONObject?) = input?.let {
552
+ val result = OcclusionCheckParams()
553
+ if (it.has("maxOcclusionPart")) result.maxOcclusionPart = it.getDouble("maxOcclusionPart")
554
+ result
555
+ }
556
+
557
+ fun generateOcclusionCheckParams(input: OcclusionCheckParams?) = input?.let {
558
+ mapOf(
559
+ "maxOcclusionPart" to it.maxOcclusionPart,
560
+ ).toJson()
561
+ }
562
+
563
+ @SuppressLint("DiscouragedApi")
564
+ fun typefaceFromJSON(it: JSONObject): Pair<Typeface?, Int?> {
565
+ val name = it.getString("name")
566
+ val font = try {
567
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
568
+ context.resources.getFont(context.resources.getIdentifier(name, "font", context.packageName))
569
+ else null
570
+ } catch (_: Exception) { null }
571
+ return Pair(
572
+ font ?: Typeface.create(name, it.optInt("style", Typeface.NORMAL)),
573
+ it.getIntOrNull("size")
574
+ )
575
+ }
576
+
577
+ fun generateTypeface(input: Typeface?, size: Int? = null) = input?.let {
578
+ mapOf(
579
+ "name" to "undefined",
580
+ "style" to it.style,
581
+ "size" to size
582
+ ).toJson()
583
+ }
584
+
585
+ fun imageInputDataFromJSON(input: JSONObject?) = input?.let {
586
+ ImageInputData(
587
+ it.getString("image").toBitmap()!!,
588
+ it.getIntOrNull("light") ?: 6,
589
+ it.getIntOrNull("pageIndex") ?: 0
590
+ )
591
+ }
592
+
593
+ fun generateImageInputData(input: ImageInputData?) = input?.let {
594
+ mapOf(
595
+ "image" to it.bitmap.toBase64(),
596
+ "light" to it.light,
597
+ "pageIndex" to it.pageIndex
598
+ ).toJson()
599
+ }
600
+
601
+ fun pkdCertificateFromJSON(input: JSONObject?): PKDCertificate? = input?.let {
602
+ var resourceType = 0
603
+ var binaryData = ByteArray(0)
604
+
605
+ if (it.has("resourceType")) resourceType = it.getInt("resourceType")
606
+ if (it.has("binaryData")) binaryData = it.getString("binaryData").toByteArray()!!
607
+ if (it.has("privateKey")) {
608
+ val privateKey = it.getString("privateKey").toByteArray()
609
+ return PKDCertificate(binaryData, resourceType, privateKey)
610
+ }
611
+ PKDCertificate(binaryData, resourceType)
612
+ }
613
+
614
+ fun generatePKDCertificate(input: PKDCertificate?) = input?.let {
615
+ mapOf(
616
+ "resourceType" to it.resourceType,
617
+ "binaryData" to it.binaryData.toBase64(),
618
+ "privateKey" to it.privateKey.toBase64()
619
+ ).toJson()
620
+ }
621
+
622
+ fun documentReaderScenarioFromJSON(input: JSONObject?) = input?.let {
623
+ DocumentReaderScenario(
624
+ it.optString("name"),
625
+ it.optString("caption"),
626
+ it.optString("description"),
627
+ if (it.optBoolean("multiPageOff")) 1 else 0,
628
+ it.optDouble("frameKWHLandscape"),
629
+ it.optDouble("frameKWHPortrait"),
630
+ it.optDouble("frameKWHDoublePageSpreadPortrait"),
631
+ it.optDouble("frameKWHDoublePageSpreadLandscape"),
632
+ it.optInt("frameOrientation"),
633
+ it.optBoolean("uvTorch"),
634
+ it.optBoolean("faceExt"),
635
+ it.optBoolean("seriesProcessMode"),
636
+ it.optBoolean("manualCrop"),
637
+ null
638
+ )
639
+ }
640
+
641
+ fun generateDocumentReaderScenario(input: DocumentReaderScenario?) = input?.let {
642
+ mapOf(
643
+ "name" to it.name,
644
+ "caption" to it.caption,
645
+ "description" to it.description,
646
+ "multiPageOff" to it.multiPageOff,
647
+ "frameKWHLandscape" to it.frameKWHLandscape,
648
+ "frameKWHPortrait" to it.frameKWHPortrait,
649
+ "frameKWHDoublePageSpreadPortrait" to it.frameKWHDoublePageSpreadPortrait,
650
+ "frameKWHDoublePageSpreadLandscape" to it.frameKWHDoublePageSpreadLandscape,
651
+ "frameOrientation" to it.frameOrientation,
652
+ "uvTorch" to it.uvTorch,
653
+ "faceExt" to it.faceExt,
654
+ "seriesProcessMode" to it.seriesProcessMode,
655
+ "manualCrop" to it.manualCrop
656
+ ).toJson()
657
+ }
658
+
659
+ fun rectFromJSON(input: JSONObject?) = input?.let {
660
+ val result = Rect()
661
+
662
+ result.bottom = it.optInt("bottom")
663
+ result.top = it.optInt("top")
664
+ result.left = it.optInt("left")
665
+ result.right = it.optInt("right")
666
+
667
+ result
668
+ }
669
+
670
+ fun generateRect(input: Rect?) = input?.let {
671
+ mapOf(
672
+ "bottom" to it.bottom,
673
+ "top" to it.top,
674
+ "left" to it.left,
675
+ "right" to it.right
676
+ ).toJson()
677
+ }
678
+
679
+ fun docReaderFieldRectFromJSON(input: JSONObject?) = input?.let {
680
+ val result = DocReaderFieldRect()
681
+
682
+ result.bottom = it.optInt("bottom")
683
+ result.top = it.optInt("top")
684
+ result.left = it.optInt("left")
685
+ result.right = it.optInt("right")
686
+
687
+ result
688
+ }
689
+
690
+ fun generateDocReaderFieldRect(input: DocReaderFieldRect?) = input?.let {
691
+ mapOf(
692
+ "bottom" to it.bottom,
693
+ "top" to it.top,
694
+ "left" to it.left,
695
+ "right" to it.right
696
+ ).toJson()
697
+ }
698
+
699
+ fun documentReaderGraphicFieldFromJSON(input: JSONObject?) = input?.let {
700
+ val result = DocumentReaderGraphicField()
701
+
702
+ it.remove("value")
703
+ result.sourceType = it.optInt("sourceType")
704
+ result.fieldType = it.optInt("fieldType")
705
+ result.light = it.optInt("light")
706
+ result.pageIndex = it.optInt("pageIndex")
707
+ result.originalPageIndex = it.optInt("originalPageIndex")
708
+ result.boundRect = docReaderFieldRectFromJSON(it.optJSONObject("fieldRect"))
709
+
710
+ result
711
+ }
712
+
713
+ fun generateDocumentReaderGraphicField(input: DocumentReaderGraphicField?) = input?.let {
714
+ mapOf(
715
+ "sourceType" to it.sourceType,
716
+ "fieldType" to it.fieldType,
717
+ "light" to it.light,
718
+ "pageIndex" to it.pageIndex,
719
+ "originalPageIndex" to it.originalPageIndex,
720
+ "fieldName" to eGraphicFieldType.getTranslation(context, it.fieldType),
721
+ "lightName" to eRPRM_Lights.getTranslation(context, it.light),
722
+ "value" to it.imageBase64(),
723
+ "fieldRect" to generateDocReaderFieldRect(it.boundRect)
724
+ ).toJson()
725
+ }
726
+
727
+ fun documentReaderGraphicResultFromJSON(input: JSONObject?) = input?.let {
728
+ val result = DocumentReaderGraphicResult()
729
+ result.fields = it.optJSONArray("fields").toList(::documentReaderGraphicFieldFromJSON)!!
730
+ result
731
+ }
732
+
733
+ fun generateDocumentReaderGraphicResult(input: DocumentReaderGraphicResult?) = input?.let {
734
+ mapOf(
735
+ "fields" to it.fields.toJson(::generateDocumentReaderGraphicField)
736
+ ).toJson()
737
+ }
738
+
739
+ fun documentReaderValueFromJSON(input: JSONObject?) = input?.let {
740
+ val result = DocumentReaderValue()
741
+
742
+ result.pageIndex = it.optInt("pageIndex")
743
+ result.sourceType = it.optInt("sourceType")
744
+ result.probability = it.optInt("probability")
745
+ result.value = it.optString("value")
746
+ result.originalValue = it.optString("originalValue")
747
+ result.boundRect = rectFromJSON(it.optJSONObject("boundRect"))
748
+ result.originalSymbols = it.optJSONArray("originalSymbols").toList(::documentReaderSymbolFromJSON)!!
749
+ result.rfidOrigin = documentReaderRFIDOriginFromJSON(it.optJSONObject("rfidOrigin"))
750
+
751
+ result
752
+ }
753
+
754
+ fun generateDocumentReaderValue(input: DocumentReaderValue?) = input?.let {
755
+ mapOf(
756
+ "pageIndex" to it.pageIndex,
757
+ "sourceType" to it.sourceType,
758
+ "probability" to it.probability,
759
+ "value" to it.value,
760
+ "originalValue" to it.originalValue,
761
+ "boundRect" to generateRect(it.boundRect),
762
+ "originalSymbols" to it.originalSymbols.toJson(::generateDocumentReaderSymbol),
763
+ "rfidOrigin" to generateDocumentReaderRFIDOrigin(it.rfidOrigin)
764
+ ).toJson()
765
+ }
766
+
767
+ fun documentReaderTextFieldFromJSON(input: JSONObject?) = input?.let {
768
+ val result = DocumentReaderTextField()
769
+
770
+ it.remove("getValue")
771
+ result.fieldType = it.optInt("fieldType")
772
+ result.lcid = it.optInt("lcid")
773
+ result.status = it.optInt("status")
774
+ result.value = it.optString("value")
775
+ result.values = it.optJSONArray("values").toList(::documentReaderValueFromJSON)!!
776
+ result.comparisonList = it.optJSONArray("comparisonList").toList(::documentReaderComparisonFromJSON)!!
777
+ result.validityList = it.optJSONArray("validityList").toList(::documentReaderValidityFromJSON)!!
778
+ result.comparisonStatus = it.optInt("comparisonStatus")
779
+ result.validityStatus = it.optInt("validityStatus")
780
+
781
+ result
782
+ }
783
+
784
+ fun generateDocumentReaderTextField(input: DocumentReaderTextField?) = input?.let {
785
+ mapOf(
786
+ "fieldType" to it.fieldType,
787
+ "lcid" to it.lcid,
788
+ "status" to it.status,
789
+ "lcidName" to it.getLcidName(context),
790
+ "fieldName" to it.getFieldName(context),
791
+ "value" to it.value,
792
+ "getValue" to generateDocumentReaderValue(it.value()),
793
+ "values" to it.values.toJson(::generateDocumentReaderValue),
794
+ "comparisonList" to it.comparisonList.toJson(::generateDocumentReaderComparison),
795
+ "validityList" to it.validityList.toJson(::generateDocumentReaderValidity),
796
+ "comparisonStatus" to it.comparisonStatus,
797
+ "validityStatus" to it.validityStatus
798
+ ).toJson()
799
+ }
800
+
801
+ fun documentReaderTextResultFromJSON(input: JSONObject?) = input?.let {
802
+ val result = DocumentReaderTextResult()
803
+
804
+ result.status = it.optInt("status")
805
+ result.comparisonStatus = it.optInt("comparisonStatus")
806
+ result.validityStatus = it.optInt("validityStatus")
807
+ result.availableSourceList = it.optJSONArray("availableSourceList").toList(::documentReaderTextSourceFromJSON)!!
808
+ result.fields = it.optJSONArray("fields").toList(::documentReaderTextFieldFromJSON)!!
809
+
810
+ result
811
+ }
812
+
813
+ fun generateDocumentReaderTextResult(input: DocumentReaderTextResult?) = input?.let {
814
+ mapOf(
815
+ "status" to it.status,
816
+ "comparisonStatus" to it.comparisonStatus,
817
+ "validityStatus" to it.validityStatus,
818
+ "availableSourceList" to it.availableSourceList.toJson(::generateDocumentReaderTextSource),
819
+ "fields" to it.fields.toJson(::generateDocumentReaderTextField)
820
+ ).toJson()
821
+ }
822
+
823
+ fun coordinateFromJSON(input: JSONObject?) = input?.let {
824
+ val result = Coordinate()
825
+ result.x = it.optInt("x")
826
+ result.y = it.optInt("y")
827
+ result
828
+ }
829
+
830
+ fun generateCoordinate(input: Coordinate?) = input?.let {
831
+ mapOf(
832
+ "x" to it.x,
833
+ "y" to it.y
834
+ ).toJson()
835
+ }
836
+
837
+ fun elementPositionFromJSON(input: JSONObject?) = input?.let {
838
+ val result = ElementPosition()
839
+
840
+ result.docFormat = it.optInt("docFormat")
841
+ result.width = it.optInt("width")
842
+ result.height = it.optInt("height")
843
+ result.dpi = it.optInt("dpi")
844
+ result.pageIndex = it.optInt("pageIndex")
845
+ result.inverse = it.optInt("inverse")
846
+ result.perspectiveTr = it.optInt("perspectiveTr")
847
+ result.objArea = it.optInt("objArea")
848
+ result.objIntAngleDev = it.optInt("objIntAngleDev")
849
+ result.resultStatus = it.optInt("resultStatus")
850
+ result.angle = it.optDouble("angle")
851
+ result.center = coordinateFromJSON(it.optJSONObject("center"))
852
+ result.leftTop = coordinateFromJSON(it.optJSONObject("leftTop"))
853
+ result.leftBottom = coordinateFromJSON(it.optJSONObject("leftBottom"))
854
+ result.rightTop = coordinateFromJSON(it.optJSONObject("rightTop"))
855
+ result.rightBottom = coordinateFromJSON(it.optJSONObject("rightBottom"))
856
+
857
+ result
858
+ }
859
+
860
+ fun generateElementPosition(input: ElementPosition?) = input?.let {
861
+ mapOf(
862
+ "docFormat" to it.docFormat,
863
+ "width" to it.width,
864
+ "height" to it.height,
865
+ "dpi" to it.dpi,
866
+ "pageIndex" to it.pageIndex,
867
+ "inverse" to it.inverse,
868
+ "perspectiveTr" to it.perspectiveTr,
869
+ "objArea" to it.objArea,
870
+ "objIntAngleDev" to it.objIntAngleDev,
871
+ "resultStatus" to it.resultStatus,
872
+ "angle" to it.angle,
873
+ "center" to generateCoordinate(it.center),
874
+ "leftTop" to generateCoordinate(it.leftTop),
875
+ "leftBottom" to generateCoordinate(it.leftBottom),
876
+ "rightTop" to generateCoordinate(it.rightTop),
877
+ "rightBottom" to generateCoordinate(it.rightBottom)
878
+ ).toJson()
879
+ }
880
+
881
+ fun imageQualityFromJSON(input: JSONObject?) = input?.let {
882
+ val result = ImageQuality()
883
+
884
+ result.featureType = it.optInt("featureType")
885
+ result.result = it.optInt("result")
886
+ result.type = it.optInt("type")
887
+ result.boundRects = it.optJSONArray("boundRects").toList(::docReaderFieldRectFromJSON)!!
888
+
889
+ result
890
+ }
891
+
892
+ fun generateImageQuality(input: ImageQuality?) = input?.let {
893
+ mapOf(
894
+ "featureType" to it.featureType,
895
+ "result" to it.result,
896
+ "type" to it.type,
897
+ "boundRects" to it.boundRects.toJson(::generateDocReaderFieldRect)
898
+ ).toJson()
899
+ }
900
+
901
+ fun imageQualityGroupFromJSON(input: JSONObject?) = input?.let {
902
+ val result = ImageQualityGroup()
903
+
904
+ result.count = it.optInt("count")
905
+ result.result = it.optInt("result")
906
+ result.pageIndex = it.optInt("pageIndex")
907
+ result.imageQualityList = it.optJSONArray("imageQualityList").toList(::imageQualityFromJSON)!!
908
+
909
+ result
910
+ }
911
+
912
+ fun generateImageQualityGroup(input: ImageQualityGroup?) = input?.let {
913
+ mapOf(
914
+ "count" to it.count,
915
+ "result" to it.result,
916
+ "imageQualityList" to it.imageQualityList.toJson(::generateImageQuality),
917
+ "pageIndex" to it.pageIndex
918
+ ).toJson()
919
+ }
920
+
921
+ fun cameraSizeFromJSON(input: JSONObject) = input.let {
922
+ val width = it.getInt("width")
923
+ val height = it.getInt("height")
924
+ Pair(width, height)
925
+ }
926
+
927
+ fun generateCameraSize(width: Int?, height: Int?): JSONObject? {
928
+ width ?: return null
929
+ height ?: return null
930
+ return mapOf(
931
+ "width" to width,
932
+ "height" to height
933
+ ).toJson()
934
+ }
935
+
936
+ fun documentReaderDocumentTypeFromJSON(input: JSONObject?) = input?.let {
937
+ val result = DocumentReaderDocumentType()
938
+
939
+ result.pageIndex = it.getInt("pageIndex")
940
+ result.documentID = it.getInt("documentID")
941
+ result.dType = it.getInt("dType")
942
+ result.dFormat = it.getInt("dFormat")
943
+ result.dMRZ = it.getBoolean("dMRZ")
944
+ result.isDeprecated = it.getBoolean("isDeprecated")
945
+ result.name = it.getStringOrNull("name")
946
+ result.ICAOCode = it.getStringOrNull("ICAOCode")
947
+ result.dDescription = it.getStringOrNull("dDescription")
948
+ result.dCountryName = it.getStringOrNull("dCountryName")
949
+ result.dYear = it.getStringOrNull("dYear")
950
+ result.FDSID = it.getJSONArrayOrNull("FDSID").toIntArray()
951
+
952
+ result
953
+ }
954
+
955
+ fun generateDocumentReaderDocumentType(input: DocumentReaderDocumentType?) = input?.let {
956
+ mapOf(
957
+ "pageIndex" to it.pageIndex,
958
+ "documentID" to it.documentID,
959
+ "dType" to it.dType,
960
+ "dFormat" to it.dFormat,
961
+ "dMRZ" to it.dMRZ,
962
+ "isDeprecated" to it.isDeprecated,
963
+ "name" to it.name,
964
+ "ICAOCode" to it.ICAOCode,
965
+ "dDescription" to it.dDescription,
966
+ "dYear" to it.dYear,
967
+ "dCountryName" to it.dCountryName,
968
+ "FDSID" to it.FDSID.toJson()
969
+ ).toJson()
970
+ }
971
+
972
+ fun generateDocumentReaderNotification(input: DocumentReaderNotification?) = input?.let {
973
+ mapOf(
974
+ "notificationCode" to it.notificationCode,
975
+ "dataFileType" to it.dataFileType,
976
+ "progress" to it.progress
977
+ ).toJson()
978
+ }
979
+
980
+ fun accessControlProcedureTypeFromJSON(input: JSONObject?) = input?.let {
981
+ val result = AccessControlProcedureType()
982
+
983
+ result.activeOptionIdx = it.optInt("activeOptionIdx")
984
+ result.type = it.optInt("type")
985
+ result.status = it.optInt("status").toLong()
986
+ result.notifications = it.optJSONArray("notifications")!!.toList()
987
+
988
+ result
989
+ }
990
+
991
+ fun generateAccessControlProcedureType(input: AccessControlProcedureType?) = input?.let {
992
+ mapOf(
993
+ "activeOptionIdx" to it.activeOptionIdx,
994
+ "type" to it.type,
995
+ "status" to it.status,
996
+ "notifications" to it.notifications.toJson()
997
+ ).toJson()
998
+ }
999
+
1000
+ fun fileDataFromJSON(input: JSONObject?) = input?.let {
1001
+ val result = FileData()
1002
+
1003
+ result.length = it.optInt("length")
1004
+ result.type = it.optInt("type")
1005
+ result.status = it.optInt("status").toLong()
1006
+ result.data = it.optString("data")
1007
+
1008
+ result
1009
+ }
1010
+
1011
+ fun generateFileData(input: FileData?) = input?.let {
1012
+ mapOf(
1013
+ "length" to it.length,
1014
+ "type" to it.type,
1015
+ "status" to it.status,
1016
+ "data" to it.data
1017
+ ).toJson()
1018
+ }
1019
+
1020
+ fun certificateDataFromJSON(input: JSONObject?) = input?.let {
1021
+ val result = CertificateData()
1022
+ result.length = it.optInt("length")
1023
+ result.data = it.optString("data")
1024
+ result
1025
+ }
1026
+
1027
+ fun generateCertificateData(input: CertificateData?) = input?.let {
1028
+ mapOf(
1029
+ "length" to it.length,
1030
+ "data" to it.data
1031
+ ).toJson()
1032
+ }
1033
+
1034
+ fun securityObjectCertificatesFromJSON(input: JSONObject?) = input?.let {
1035
+ val result = SecurityObjectCertificates()
1036
+ result.securityObject = certificateDataFromJSON(it.optJSONObject("securityObject"))
1037
+ result
1038
+ }
1039
+
1040
+ fun generateSecurityObjectCertificates(input: SecurityObjectCertificates?) = input?.let {
1041
+ mapOf(
1042
+ "securityObject" to generateCertificateData(it.securityObject)
1043
+ ).toJson()
1044
+ }
1045
+
1046
+ fun fileFromJSON(input: JSONObject?) = input?.let {
1047
+ val result = File()
1048
+
1049
+ result.readingTime = it.optInt("readingTime")
1050
+ result.type = it.optInt("type")
1051
+ result.pAStatus = it.optLong("pAStatus")
1052
+ result.readingStatus = it.optInt("readingStatus").toLong()
1053
+ result.fileID = it.optString("fileID")
1054
+ result.fileData = fileDataFromJSON(it.optJSONObject("fileData"))
1055
+ result.certificates = securityObjectCertificatesFromJSON(it.optJSONObject("certificates"))
1056
+ result.docFieldsText = it.optJSONArray("docFieldsText")!!.toList()
1057
+ result.docFieldsGraphics = it.optJSONArray("docFieldsGraphics")!!.toList()
1058
+ result.docFieldsOriginals = it.optJSONArray("docFieldsOriginals")!!.toList()
1059
+ result.notifications = it.optJSONArray("notifications")!!.toList()
1060
+
1061
+ result
1062
+ }
1063
+
1064
+ fun generateFile(input: File?) = input?.let {
1065
+ mapOf(
1066
+ "readingTime" to it.readingTime,
1067
+ "type" to it.type,
1068
+ "typeName" to eRFID_DataFile_Type.getTranslation(context, it.type),
1069
+ "pAStatus" to it.pAStatus,
1070
+ "readingStatus" to it.readingStatus,
1071
+ "fileID" to it.fileID,
1072
+ "fileData" to generateFileData(it.fileData),
1073
+ "certificates" to generateSecurityObjectCertificates(it.certificates),
1074
+ "docFieldsText" to it.docFieldsText.toJson(),
1075
+ "docFieldsGraphics" to it.docFieldsGraphics.toJson(),
1076
+ "docFieldsOriginals" to it.docFieldsOriginals.toJson(),
1077
+ "notifications" to it.notifications.toJson()
1078
+ ).toJson()
1079
+ }
1080
+
1081
+ fun applicationFromJSON(input: JSONObject?) = input?.let {
1082
+ val result = Application()
1083
+
1084
+ result.type = it.optInt("type")
1085
+ result.status = it.optInt("status")
1086
+ result.applicationID = it.optString("applicationID")
1087
+ result.dataHashAlgorithm = it.optString("dataHashAlgorithm")
1088
+ result.unicodeVersion = it.optString("unicodeVersion")
1089
+ result.version = it.optString("version")
1090
+ result.files = it.optJSONArray("files").toList(::fileFromJSON)!!
1091
+
1092
+ result
1093
+ }
1094
+
1095
+ fun generateApplication(input: Application?) = input?.let {
1096
+ mapOf(
1097
+ "type" to it.type,
1098
+ "status" to it.status,
1099
+ "applicationID" to it.applicationID,
1100
+ "dataHashAlgorithm" to it.dataHashAlgorithm,
1101
+ "unicodeVersion" to it.unicodeVersion,
1102
+ "version" to it.version,
1103
+ "files" to it.files.toJson(::generateFile)
1104
+ ).toJson()
1105
+ }
1106
+
1107
+ fun valueFromJSON(input: JSONObject?) = input?.let {
1108
+ val result = Value()
1109
+
1110
+ result.length = it.optInt("length")
1111
+ result.type = it.optInt("type")
1112
+ result.status = it.optInt("status").toLong()
1113
+ result.data = it.optString("data")
1114
+ result.format = it.optString("format")
1115
+
1116
+ result
1117
+ }
1118
+
1119
+ fun generateValue(input: Value?) = input?.let {
1120
+ mapOf(
1121
+ "length" to it.length,
1122
+ "type" to it.type,
1123
+ "status" to it.status,
1124
+ "data" to it.data,
1125
+ "format" to it.format
1126
+ ).toJson()
1127
+ }
1128
+
1129
+ fun attributeFromJSON(input: JSONObject?) = input?.let {
1130
+ val result = Attribute()
1131
+ result.type = it.optString("type")
1132
+ result.value = valueFromJSON(it.optJSONObject("value"))
1133
+ result
1134
+ }
1135
+
1136
+ fun generateAttribute(input: Attribute?) = input?.let {
1137
+ mapOf(
1138
+ "type" to it.type,
1139
+ "value" to generateValue(it.value)
1140
+ ).toJson()
1141
+ }
1142
+
1143
+ fun authorityFromJSON(input: JSONObject?) = input?.let {
1144
+ val result = Authority()
1145
+ result.data = it.optString("data")
1146
+ result.friendlyName = valueFromJSON(it.optJSONObject("friendlyName"))
1147
+ result.attributes = it.optJSONArray("attributes").toList(::attributeFromJSON)!!
1148
+ result
1149
+ }
1150
+
1151
+ fun generateAuthority(input: Authority?) = input?.let {
1152
+ mapOf(
1153
+ "data" to it.data,
1154
+ "friendlyName" to generateValue(it.friendlyName),
1155
+ "attributes" to it.attributes.toJson(::generateAttribute)
1156
+ ).toJson()
1157
+ }
1158
+
1159
+ fun extensionFromJSON(input: JSONObject?) = input?.let {
1160
+ val result = Extension()
1161
+ result.data = it.optString("data")
1162
+ result.type = it.optString("type")
1163
+ result
1164
+ }
1165
+
1166
+ fun generateExtension(input: Extension?) = input?.let {
1167
+ mapOf(
1168
+ "data" to it.data,
1169
+ "type" to it.type
1170
+ ).toJson()
1171
+ }
1172
+
1173
+ fun validityFromJSON(input: JSONObject?) = input?.let {
1174
+ val result = Validity()
1175
+ result.notAfter = valueFromJSON(it.optJSONObject("notAfter"))
1176
+ result.notBefore = valueFromJSON(it.optJSONObject("notBefore"))
1177
+ result
1178
+ }
1179
+
1180
+ fun generateValidity(input: Validity?) = input?.let {
1181
+ mapOf(
1182
+ "notAfter" to generateValue(it.notAfter),
1183
+ "notBefore" to generateValue(it.notBefore)
1184
+ ).toJson()
1185
+ }
1186
+
1187
+ fun certificateChainFromJSON(input: JSONObject?) = input?.let {
1188
+ val result = CertificateChain()
1189
+
1190
+ result.origin = it.optInt("origin")
1191
+ result.type = it.optInt("type")
1192
+ result.version = it.optInt("version")
1193
+ result.paStatus = it.optInt("paStatus").toLong()
1194
+ result.serialNumber = it.optString("serialNumber")
1195
+ result.signatureAlgorithm = it.optString("signatureAlgorithm")
1196
+ result.subjectPKAlgorithm = it.optString("subjectPKAlgorithm")
1197
+ result.fileName = valueFromJSON(it.optJSONObject("fileName"))
1198
+ result.validity = validityFromJSON(it.optJSONObject("validity"))
1199
+ result.issuer = authorityFromJSON(it.optJSONObject("issuer"))
1200
+ result.subject = authorityFromJSON(it.optJSONObject("subject"))
1201
+ result.notifications = it.optJSONArray("notifications")!!.toList()
1202
+ result.extensions = it.optJSONArray("extensions").toList(::extensionFromJSON)!!
1203
+
1204
+ result
1205
+ }
1206
+
1207
+ fun generateCertificateChain(input: CertificateChain?) = input?.let {
1208
+ mapOf(
1209
+ "origin" to it.origin,
1210
+ "type" to it.type,
1211
+ "version" to it.version,
1212
+ "paStatus" to it.paStatus,
1213
+ "serialNumber" to it.serialNumber,
1214
+ "signatureAlgorithm" to it.signatureAlgorithm,
1215
+ "subjectPKAlgorithm" to it.subjectPKAlgorithm,
1216
+ "fileName" to generateValue(it.fileName),
1217
+ "validity" to generateValidity(it.validity),
1218
+ "issuer" to generateAuthority(it.issuer),
1219
+ "subject" to generateAuthority(it.subject),
1220
+ "notifications" to it.notifications.toJson(),
1221
+ "extensions" to it.extensions.toJson(::generateExtension)
1222
+ ).toJson()
1223
+ }
1224
+
1225
+ fun signerInfoFromJSON(input: JSONObject?) = input?.let {
1226
+ val result = SignerInfo()
1227
+
1228
+ result.version = it.optInt("version")
1229
+ result.paStatus = it.optInt("paStatus").toLong()
1230
+ result.dataToHash = it.optString("dataToHash")
1231
+ result.digestAlgorithm = it.optString("digestAlgorithm")
1232
+ result.signatureAlgorithm = it.optString("signatureAlgorithm")
1233
+ result.serialNumber = valueFromJSON(it.optJSONObject("serialNumber"))
1234
+ result.signature = valueFromJSON(it.optJSONObject("signature"))
1235
+ result.subjectKeyIdentifier = valueFromJSON(it.optJSONObject("subjectKeyIdentifier"))
1236
+ result.issuer = authorityFromJSON(it.optJSONObject("issuer"))
1237
+ result.notifications = it.optJSONArray("notifications")!!.toList()
1238
+ result.signedAttributes = it.optJSONArray("signedAttributes").toList(::extensionFromJSON)!!
1239
+ result.certificateChain = it.optJSONArray("certificateChain").toList(::certificateChainFromJSON)!!
1240
+
1241
+ result
1242
+ }
1243
+
1244
+ fun generateSignerInfo(input: SignerInfo?) = input?.let {
1245
+ mapOf(
1246
+ "version" to it.version,
1247
+ "paStatus" to it.paStatus,
1248
+ "dataToHash" to it.dataToHash,
1249
+ "digestAlgorithm" to it.digestAlgorithm,
1250
+ "signatureAlgorithm" to it.signatureAlgorithm,
1251
+ "serialNumber" to generateValue(it.serialNumber),
1252
+ "signature" to generateValue(it.signature),
1253
+ "subjectKeyIdentifier" to generateValue(it.subjectKeyIdentifier),
1254
+ "issuer" to generateAuthority(it.issuer),
1255
+ "notifications" to it.notifications.toJson(),
1256
+ "signedAttributes" to it.signedAttributes.toJson(::generateExtension),
1257
+ "certificateChain" to it.certificateChain.toJson(::generateCertificateChain)
1258
+ ).toJson()
1259
+ }
1260
+
1261
+ fun securityObjectFromJSON(input: JSONObject?) = input?.let {
1262
+ val result = SecurityObject()
1263
+
1264
+ result.fileReference = it.optInt("fileReference")
1265
+ result.version = it.optInt("version")
1266
+ result.objectType = it.optString("objectType")
1267
+ result.notifications = it.optJSONArray("notifications")!!.toList()
1268
+ result.signerInfos = it.optJSONArray("signerInfos").toList(::signerInfoFromJSON)!!
1269
+
1270
+ result
1271
+ }
1272
+
1273
+ fun generateSecurityObject(input: SecurityObject?) = input?.let {
1274
+ mapOf(
1275
+ "fileReference" to it.fileReference,
1276
+ "version" to it.version,
1277
+ "objectType" to it.objectType,
1278
+ "notifications" to it.notifications.toJson(),
1279
+ "signerInfos" to it.signerInfos.toJson(::generateSignerInfo)
1280
+ ).toJson()
1281
+ }
1282
+
1283
+ fun cardPropertiesFromJSON(input: JSONObject?) = input?.let {
1284
+ val result = CardProperties()
1285
+
1286
+ result.aTQA = it.optInt("aTQA")
1287
+ result.bitRateR = it.optInt("bitRateR")
1288
+ result.bitRateS = it.optInt("bitRateS")
1289
+ result.chipTypeA = it.optInt("chipTypeA")
1290
+ result.mifareMemory = it.optInt("mifareMemory")
1291
+ result.rfidType = it.optInt("rfidType")
1292
+ result.sAK = it.optInt("sAK")
1293
+ result.support4 = it.optBoolean("support4")
1294
+ result.supportMifare = it.optBoolean("supportMifare")
1295
+ result.aTQB = it.optString("aTQB")
1296
+ result.aTR = it.optString("aTR")
1297
+ result.baudrate1 = it.optString("baudrate1")
1298
+ result.baudrate2 = it.optString("baudrate2")
1299
+ result.uID = it.optString("uID")
1300
+
1301
+ result
1302
+ }
1303
+
1304
+ fun generateCardProperties(input: CardProperties?) = input?.let {
1305
+ mapOf(
1306
+ "aTQA" to it.aTQA,
1307
+ "bitRateR" to it.bitRateR,
1308
+ "bitRateS" to it.bitRateS,
1309
+ "chipTypeA" to it.chipTypeA,
1310
+ "mifareMemory" to it.mifareMemory,
1311
+ "rfidType" to it.rfidType,
1312
+ "sAK" to it.sAK,
1313
+ "support4" to it.support4,
1314
+ "supportMifare" to it.supportMifare,
1315
+ "aTQB" to it.aTQB,
1316
+ "aTR" to it.aTR,
1317
+ "baudrate1" to it.baudrate1,
1318
+ "baudrate2" to it.baudrate2,
1319
+ "uID" to it.uID
1320
+ ).toJson()
1321
+ }
1322
+
1323
+ fun rfidSessionDataFromJSON(input: JSONObject?) = input?.let {
1324
+ val result = RFIDSessionData()
1325
+
1326
+ result.totalBytesReceived = it.optInt("totalBytesReceived")
1327
+ result.totalBytesSent = it.optInt("totalBytesSent")
1328
+ result.status = it.optInt("status").toLong()
1329
+ result.extLeSupport = it.optLong("extLeSupport")
1330
+ result.processTime = it.optLong("processTime")
1331
+ result.cardProperties = cardPropertiesFromJSON(it.optJSONObject("cardProperties"))
1332
+ result.accessControls = it.optJSONArray("accessControls").toList(::accessControlProcedureTypeFromJSON)!!
1333
+ result.applications = it.optJSONArray("applications").toList(::applicationFromJSON)!!
1334
+ result.securityObjects = it.optJSONArray("securityObjects").toList(::securityObjectFromJSON)!!
1335
+ result.dataFields = it.optJSONArray("dataFields").toList(::dataFieldFromJSON)!!
1336
+ result.dataGroups = it.optJSONArray("dataGroups").toIntArray()
1337
+
1338
+ result
1339
+ }
1340
+
1341
+ fun generateRFIDSessionData(input: RFIDSessionData?) = input?.let {
1342
+ mapOf(
1343
+ "totalBytesReceived" to it.totalBytesReceived,
1344
+ "totalBytesSent" to it.totalBytesSent,
1345
+ "status" to it.status,
1346
+ "extLeSupport" to it.extLeSupport,
1347
+ "processTime" to it.processTime,
1348
+ "cardProperties" to generateCardProperties(it.cardProperties),
1349
+ "accessControls" to it.accessControls.toJson(::generateAccessControlProcedureType),
1350
+ "applications" to it.applications.toJson(::generateApplication),
1351
+ "securityObjects" to it.securityObjects.toJson(::generateSecurityObject),
1352
+ "dataGroups" to it.dataGroups.toJson(),
1353
+ "dataFields" to it.dataFields.toJson(::generateDataField)
1354
+ ).toJson()
1355
+ }
1356
+
1357
+ fun dataFieldFromJSON(input: JSONObject?) = input?.let {
1358
+ val result = DataField()
1359
+ result.data = it.optString("data")
1360
+ result.fieldType = it.optInt("fieldType")
1361
+ result
1362
+ }
1363
+
1364
+ fun generateDataField(input: DataField?) = input?.let {
1365
+ mapOf(
1366
+ "data" to it.data,
1367
+ "fieldType" to it.fieldType
1368
+ ).toJson()
1369
+ }
1370
+
1371
+ fun documentReaderAuthenticityCheckFromJSON(input: JSONObject?) = input?.let {
1372
+ val result = DocumentReaderAuthenticityCheck()
1373
+ result.type = it.optInt("type")
1374
+ result.pageIndex = it.optInt("pageIndex")
1375
+ result.elements = it.optJSONArray("elements").toList(::documentReaderAuthenticityElementFromJSON)!!
1376
+ result
1377
+ }
1378
+
1379
+ fun generateDocumentReaderAuthenticityCheck(input: DocumentReaderAuthenticityCheck?) = input?.let {
1380
+ mapOf(
1381
+ "type" to it.type,
1382
+ "status" to it.status,
1383
+ "typeName" to it.getTypeName(context),
1384
+ "pageIndex" to it.pageIndex,
1385
+ "elements" to it.elements.toJson(::generateDocumentReaderAuthenticityElement)
1386
+ ).toJson()
1387
+ }
1388
+
1389
+ fun pdf417InfoFromJSON(input: JSONObject?) = input?.let {
1390
+ val result = PDF417Info()
1391
+ result.errorLevel = it.optInt("errorLevel")
1392
+ result.columns = it.optInt("columns")
1393
+ result.rows = it.optInt("rows")
1394
+ result
1395
+ }
1396
+
1397
+ fun generatePDF417Info(input: PDF417Info?) = input?.let {
1398
+ mapOf(
1399
+ "errorLevel" to it.errorLevel,
1400
+ "columns" to it.columns,
1401
+ "rows" to it.rows
1402
+ ).toJson()
1403
+ }
1404
+
1405
+ fun documentReaderBarcodeResultFromJSON(input: JSONObject?) = input?.let {
1406
+ val result = DocumentReaderBarcodeResult()
1407
+ result.fields = it.optJSONArray("fields").toList(::documentReaderBarcodeFieldFromJSON)!!
1408
+ result
1409
+ }
1410
+
1411
+ fun generateDocumentReaderBarcodeResult(input: DocumentReaderBarcodeResult?) = input?.let {
1412
+ mapOf(
1413
+ "fields" to it.fields.toJson(::generateDocumentReaderBarcodeField)
1414
+ ).toJson()
1415
+ }
1416
+
1417
+ fun documentReaderBarcodeFieldFromJSON(input: JSONObject?) = input?.let {
1418
+ val result = DocumentReaderBarcodeField()
1419
+
1420
+ result.barcodeType = it.optInt("barcodeType")
1421
+ result.status = it.optInt("status")
1422
+ result.pageIndex = it.optInt("pageIndex")
1423
+ result.pdf417Info = pdf417InfoFromJSON(it.optJSONObject("pdf417Info"))
1424
+ result.data = it.optString("data").toByteArray()
1425
+
1426
+ result
1427
+ }
1428
+
1429
+ fun generateDocumentReaderBarcodeField(input: DocumentReaderBarcodeField?) = input?.let {
1430
+ mapOf(
1431
+ "barcodeType" to it.barcodeType,
1432
+ "status" to it.status,
1433
+ "pageIndex" to it.pageIndex,
1434
+ "pdf417Info" to generatePDF417Info(it.pdf417Info),
1435
+ "data" to it.data.toBase64()
1436
+ ).toJson()
1437
+ }
1438
+
1439
+ fun documentReaderAuthenticityResultFromJSON(input: JSONObject?) = input?.let {
1440
+ val result = DocumentReaderAuthenticityResult()
1441
+ result.checks = it.optJSONArray("checks").toList(::documentReaderAuthenticityCheckFromJSON)!!
1442
+ result
1443
+ }
1444
+
1445
+ @Suppress("DEPRECATION")
1446
+ fun generateDocumentReaderAuthenticityResult(input: DocumentReaderAuthenticityResult?) = input?.let {
1447
+ mapOf(
1448
+ "status" to it.status,
1449
+ "checks" to it.checks.toJson(::generateDocumentReaderAuthenticityCheck)
1450
+ ).toJson()
1451
+ }
1452
+
1453
+ fun documentReaderAuthenticityElementFromJSON(input: JSONObject?) = input?.let {
1454
+ val result = DocumentReaderAuthenticityElement()
1455
+ result.status = it.optInt("status")
1456
+ result.elementType = it.optInt("elementType")
1457
+ result.elementDiagnose = it.optInt("elementDiagnose")
1458
+ result
1459
+ }
1460
+
1461
+ fun generateDocumentReaderAuthenticityElement(input: DocumentReaderAuthenticityElement?) = input?.let {
1462
+ mapOf(
1463
+ "status" to it.status,
1464
+ "elementType" to it.elementType,
1465
+ "elementDiagnose" to it.elementDiagnose,
1466
+ "elementTypeName" to it.getElementTypeName(context),
1467
+ "elementDiagnoseName" to it.getElementDiagnoseName(context)
1468
+ ).toJson()
1469
+ }
1470
+
1471
+ fun paResourcesIssuerFromJSON(input: JSONObject?) = input?.let {
1472
+ val result = PAResourcesIssuer()
1473
+ result.data = it.optString("data").toByteArray()
1474
+ result.friendlyName = it.getStringOrNull("friendlyName")
1475
+ result.attributes = it.optJSONArray("attributes").toArray(::paAttributeFromJSON)
1476
+ result
1477
+ }
1478
+
1479
+ fun generatePAResourcesIssuer(input: PAResourcesIssuer?) = input?.let {
1480
+ mapOf(
1481
+ "data" to it.data.toBase64(),
1482
+ "friendlyName" to it.friendlyName,
1483
+ "attributes" to it.attributes.toJson(::generatePAAttribute)
1484
+ ).toJson()
1485
+ }
1486
+
1487
+ fun paAttributeFromJSON(input: JSONObject?) = input?.let {
1488
+ val result = PAAttribute()
1489
+ result.type = it.optString("type")
1490
+ result.value = it.optString("value")
1491
+ result
1492
+ }
1493
+
1494
+ fun generatePAAttribute(input: PAAttribute?) = input?.let {
1495
+ mapOf(
1496
+ "type" to it.type,
1497
+ "value" to it.value
1498
+ ).toJson()
1499
+ }
1500
+
1501
+ fun taChallengeFromJSON(input: JSONObject?) = input?.let {
1502
+ val result = TAChallenge()
1503
+
1504
+ result.data = it.optString("data").toByteArray()
1505
+ result.auxPCD = it.optString("auxPCD")
1506
+ result.challengePICC = it.optString("challengePICC")
1507
+ result.hashPK = it.optString("hashPK")
1508
+ result.idPICC = it.optString("idPICC")
1509
+
1510
+ result
1511
+ }
1512
+
1513
+ fun generateTAChallenge(input: TAChallenge?) = input?.let {
1514
+ mapOf(
1515
+ "data" to it.data.toBase64(),
1516
+ "auxPCD" to it.auxPCD,
1517
+ "challengePICC" to it.challengePICC,
1518
+ "hashPK" to it.hashPK,
1519
+ "idPICC" to it.idPICC
1520
+ ).toJson()
1521
+ }
1522
+
1523
+ fun documentReaderResultsStatusFromJSON(input: JSONObject?) = input?.let {
1524
+ val result = DocumentReaderResultsStatus::class.constructor().instantiate()
1525
+ result.setPrivateProperty("overallStatus", it.getInt("overallStatus"))
1526
+ result.setPrivateProperty("optical", it.getInt("optical"))
1527
+ result.setPrivateProperty("detailsOptical", detailsOpticalFromJSON(it.getJSONObject("detailsOptical")))
1528
+ result.setPrivateProperty("rfid", it.getInt("rfid"))
1529
+ result.setPrivateProperty("detailsRFID", detailsRFIDFromJSON(it.getJSONObject("detailsRFID")))
1530
+ result.setPrivateProperty("portrait", it.getInt("portrait"))
1531
+ result.setPrivateProperty("stopList", it.getInt("stopList"))
1532
+ result.setPrivateProperty("mDL", it.getInt("mDL"))
1533
+ result.setPrivateProperty("age", it.getInt("age"))
1534
+ result.setPrivateProperty("captureProcessIntegrity", it.getInt("captureProcessIntegrity"))
1535
+ result.setPrivateProperty("detailsAge", detailsAgeFromJSON(it.getJSONObject("detailsAge")))
1536
+ result
1537
+ }
1538
+
1539
+ fun generateDocumentReaderResultsStatus(input: DocumentReaderResultsStatus?) = input?.let {
1540
+ mapOf(
1541
+ "overallStatus" to it.overallStatus,
1542
+ "optical" to it.optical,
1543
+ "detailsOptical" to generateDetailsOptical(it.detailsOptical),
1544
+ "rfid" to it.rfid,
1545
+ "detailsRFID" to generateDetailsRFID(it.detailsRFID),
1546
+ "portrait" to it.portrait,
1547
+ "stopList" to it.stopList,
1548
+ "mDL" to it.mdl,
1549
+ "age" to it.age,
1550
+ "captureProcessIntegrity" to it.captureProcessIntegrity,
1551
+ "detailsAge" to generateDetailsAge(it.detailsAge),
1552
+ ).toJson()
1553
+ }
1554
+
1555
+ fun detailsOpticalFromJSON(input: JSONObject?) = input?.let {
1556
+ val result = DetailsOptical::class.constructor().instantiate()
1557
+ result.setPrivateProperty("overallStatus", it.getInt("overallStatus"))
1558
+ result.setPrivateProperty("mrz", it.getInt("mrz"))
1559
+ result.setPrivateProperty("text", it.getInt("text"))
1560
+ result.setPrivateProperty("docType", it.getInt("docType"))
1561
+ result.setPrivateProperty("security", it.getInt("security"))
1562
+ result.setPrivateProperty("imageQA", it.getInt("imageQA"))
1563
+ result.setPrivateProperty("expiry", it.getInt("expiry"))
1564
+ result.setPrivateProperty("vds", it.getInt("vds"))
1565
+ result.setPrivateProperty("pagesCount", it.getInt("pagesCount"))
1566
+ result
1567
+ }
1568
+
1569
+ fun generateDetailsOptical(input: DetailsOptical?) = input?.let {
1570
+ mapOf(
1571
+ "overallStatus" to it.overallStatus,
1572
+ "mrz" to it.mrz,
1573
+ "text" to it.text,
1574
+ "docType" to it.docType,
1575
+ "security" to it.security,
1576
+ "imageQA" to it.imageQA,
1577
+ "expiry" to it.expiry,
1578
+ "vds" to it.vds,
1579
+ "pagesCount" to it.pagesCount
1580
+ ).toJson()
1581
+ }
1582
+
1583
+ fun detailsRFIDFromJSON(input: JSONObject?) = input?.let {
1584
+ val result = DetailsRFID::class.constructor().instantiate()
1585
+ result.setPrivateProperty("overallStatus", it.getInt("overallStatus"))
1586
+ result.setPrivateProperty("pa", it.getInt("pa"))
1587
+ result.setPrivateProperty("ca", it.getInt("ca"))
1588
+ result.setPrivateProperty("aa", it.getInt("aa"))
1589
+ result.setPrivateProperty("ta", it.getInt("ta"))
1590
+ result.setPrivateProperty("bac", it.getInt("bac"))
1591
+ result.setPrivateProperty("pace", it.getInt("pace"))
1592
+ result
1593
+ }
1594
+
1595
+ fun generateDetailsRFID(input: DetailsRFID?) = input?.let {
1596
+ mapOf(
1597
+ "pa" to it.pa,
1598
+ "ca" to it.ca,
1599
+ "aa" to it.aa,
1600
+ "ta" to it.ta,
1601
+ "bac" to it.bac,
1602
+ "pace" to it.pace,
1603
+ "overallStatus" to it.overallStatus
1604
+ ).toJson()
1605
+ }
1606
+
1607
+ fun detailsAgeFromJSON(input: JSONObject?) = input?.let {
1608
+ val result = DetailsAge::class.constructor().instantiate()
1609
+ result.setPrivateProperty("threshold", it.getInt("threshold"))
1610
+ result.setPrivateProperty("overThreshold", it.getInt("overThreshold"))
1611
+ result.setPrivateProperty("over18", it.getInt("over18"))
1612
+ result.setPrivateProperty("over21", it.getInt("over21"))
1613
+ result.setPrivateProperty("over25", it.getInt("over25"))
1614
+ result.setPrivateProperty("over65", it.getInt("over65"))
1615
+ result
1616
+ }
1617
+
1618
+ fun generateDetailsAge(input: DetailsAge?) = input?.let {
1619
+ mapOf(
1620
+ "threshold" to it.threshold,
1621
+ "overThreshold" to it.overThreshold,
1622
+ "over18" to it.over18,
1623
+ "over21" to it.over21,
1624
+ "over25" to it.over25,
1625
+ "over65" to it.over65
1626
+ ).toJson()
1627
+ }
1628
+
1629
+ fun vdsncDataFromJSON(input: JSONObject?) = input?.let {
1630
+ val result = VDSNCData::class.constructor().instantiate()
1631
+ result.setPrivateProperty("type", it.getStringOrNull("type"))
1632
+ result.setPrivateProperty("version", it.getInt("version"))
1633
+ result.setPrivateProperty("issuingCountry", it.getStringOrNull("issuingCountry"))
1634
+ result.setPrivateProperty("message", it.getJSONObjectOrNull("message"))
1635
+ result.setPrivateProperty("signatureAlg", it.getStringOrNull("signatureAlgorithm"))
1636
+ result.setPrivateProperty("signature", bytesDataFromJSON(it.getJSONObjectOrNull("signature")))
1637
+ result.setPrivateProperty("certificate", bytesDataFromJSON(it.getJSONObjectOrNull("certificate")))
1638
+ result.setPrivateProperty("certificateChain", it.getJSONArray("certificateChain").toList(::certificateChainFromJSON))
1639
+ result.setPrivateProperty("notifications", it.getJSONArray("notifications").toLongArray())
1640
+ result
1641
+ }
1642
+
1643
+ fun generateVDSNCData(input: VDSNCData?) = input?.let {
1644
+ mapOf(
1645
+ "type" to it.type,
1646
+ "version" to it.version,
1647
+ "issuingCountry" to it.issuingCountry,
1648
+ "message" to it.message,
1649
+ "signatureAlgorithm" to it.signatureAlg,
1650
+ "signature" to generateBytesData(it.signature),
1651
+ "certificate" to generateBytesData(it.certificate),
1652
+ "certificateChain" to it.certificateChain.toJson(::generateCertificateChain),
1653
+ "notifications" to it.notifications.toJson()
1654
+ ).toJson()
1655
+ }
1656
+
1657
+ fun bytesDataFromJSON(input: JSONObject?) = input?.let {
1658
+ val result = BytesData::class.constructor().instantiate()
1659
+ result.setPrivateProperty("data", it.getString("data"))
1660
+ result.setPrivateProperty("length", it.getInt("length"))
1661
+ result.setPrivateProperty("status", it.getLong("status"))
1662
+ result.setPrivateProperty("type", it.getInt("type"))
1663
+ result
1664
+ }
1665
+
1666
+ fun generateBytesData(input: BytesData?) = input?.let {
1667
+ mapOf(
1668
+ "data" to it.data,
1669
+ "length" to it.length,
1670
+ "status" to it.status,
1671
+ "type" to it.type
1672
+ ).toJson()
1673
+ }
1674
+
1675
+ fun generateLicense(input: License?) = input?.let {
1676
+ mapOf(
1677
+ "expiryDate" to it.expiryDate?.toString(),
1678
+ "countryFilter" to it.countryFilter?.toJson(),
1679
+ "isRfidAvailable" to it.isRfidAvailable
1680
+ ).toJson()
1681
+ }
1682
+
1683
+ fun generateDocReaderVersion(input: DocReaderVersion?) = input?.let {
1684
+ mapOf(
1685
+ "api" to it.api,
1686
+ "core" to it.core,
1687
+ "coreMode" to it.coreMode,
1688
+ "database" to generateDocReaderDocumentsDatabase(it.database)
1689
+ ).toJson()
1690
+ }
1691
+
1692
+ fun docReaderDocumentsDatabaseFromJSON(input: JSONObject?) = input?.let {
1693
+ DocReaderDocumentsDatabase::class.constructor(String::class, String::class, String::class, String::class, Int::class, Int::class, java.lang.Long::class).instantiate(
1694
+ it.getStringOrNull("databaseID"),
1695
+ it.getStringOrNull("version"),
1696
+ it.getStringOrNull("date"),
1697
+ it.getStringOrNull("databaseDescription"),
1698
+ it.getInt("countriesNumber"),
1699
+ it.getInt("documentsNumber"),
1700
+ it.getLongOrNull("size"),
1701
+ )
1702
+ }
1703
+
1704
+ fun generateDocReaderDocumentsDatabase(input: DocReaderDocumentsDatabase?) = input?.let {
1705
+ mapOf(
1706
+ "databaseID" to it.databaseID,
1707
+ "version" to it.version,
1708
+ "date" to it.date,
1709
+ "databaseDescription" to it.databaseDescription,
1710
+ "countriesNumber" to it.countriesNumber,
1711
+ "documentsNumber" to it.documentsNumber,
1712
+ "size" to it.size
1713
+ ).toJson()
1714
+ }
1715
+
1716
+ fun documentReaderComparisonFromJSON(input: JSONObject?) = input?.let {
1717
+ val result = DocumentReaderComparison()
1718
+ result.sourceTypeLeft = it.optInt("sourceTypeLeft")
1719
+ result.sourceTypeRight = it.optInt("sourceTypeRight")
1720
+ result.status = it.optInt("status")
1721
+ result
1722
+ }
1723
+
1724
+ fun generateDocumentReaderComparison(input: DocumentReaderComparison?) = input?.let {
1725
+ mapOf(
1726
+ "sourceTypeLeft" to it.sourceTypeLeft,
1727
+ "sourceTypeRight" to it.sourceTypeRight,
1728
+ "status" to it.status
1729
+ ).toJson()
1730
+ }
1731
+
1732
+ fun documentReaderRFIDOriginFromJSON(input: JSONObject?) = input?.let {
1733
+ val result = DocumentReaderRfidOrigin()
1734
+
1735
+ result.dg = it.optInt("dg")
1736
+ result.dgTag = it.optInt("dgTag")
1737
+ result.entryView = it.optInt("entryView")
1738
+ result.tagEntry = it.optInt("tagEntry")
1739
+
1740
+ result
1741
+ }
1742
+
1743
+ fun generateDocumentReaderRFIDOrigin(input: DocumentReaderRfidOrigin?) = input?.let {
1744
+ mapOf(
1745
+ "dg" to it.dg,
1746
+ "dgTag" to it.dgTag,
1747
+ "entryView" to it.entryView,
1748
+ "tagEntry" to it.tagEntry
1749
+ ).toJson()
1750
+ }
1751
+
1752
+ fun documentReaderTextSourceFromJSON(input: JSONObject?) = input?.let {
1753
+ val result = DocumentReaderTextSource()
1754
+ result.sourceType = it.getInt("sourceType")
1755
+ result.source = it.getStringOrNull("source")
1756
+ result.validityStatus = it.getInt("validityStatus")
1757
+ result
1758
+ }
1759
+
1760
+ fun generateDocumentReaderTextSource(input: DocumentReaderTextSource?) = input?.let {
1761
+ mapOf(
1762
+ "sourceType" to it.sourceType,
1763
+ "source" to it.source,
1764
+ "validityStatus" to it.validityStatus
1765
+ ).toJson()
1766
+ }
1767
+
1768
+ fun documentReaderSymbolFromJSON(input: JSONObject?) = input?.let {
1769
+ val result = DocumentReaderSymbol()
1770
+ result.code = it.optInt("code")
1771
+ result.probability = it.optInt("probability")
1772
+ result.rect = rectFromJSON(it.optJSONObject("rect"))
1773
+ result
1774
+ }
1775
+
1776
+ fun generateDocumentReaderSymbol(input: DocumentReaderSymbol?) = input?.let {
1777
+ mapOf(
1778
+ "code" to it.code,
1779
+ "rect" to generateRect(it.rect),
1780
+ "probability" to it.probability
1781
+ ).toJson()
1782
+ }
1783
+
1784
+ fun documentReaderValidityFromJSON(input: JSONObject?) = input?.let {
1785
+ val result = DocumentReaderValidity()
1786
+ result.sourceType = it.optInt("sourceType")
1787
+ result.status = it.optInt("status")
1788
+ result
1789
+ }
1790
+
1791
+ fun generateDocumentReaderValidity(input: DocumentReaderValidity?) = input?.let {
1792
+ mapOf(
1793
+ "sourceType" to it.sourceType,
1794
+ "status" to it.status
1795
+ ).toJson()
1796
+ }
1797
+
1798
+ fun barcodeTypeArrayFromJson(input: JSONArray?) = input?.let {
1799
+ val result = arrayOfNulls<String>(it.length())
1800
+ for (i in 0 until it.length()) result[i] = BarcodeType.valueOf(it.getInt(i))
1801
+ result
1802
+ }
1803
+
1804
+ fun generateBarcodeTypeArray(input: Array<String?>?) = input?.let {
1805
+ val result = JSONArray()
1806
+ for (s in it) result.put(
1807
+ when (s) {
1808
+ "bct_Code128" -> 1
1809
+ "bct_Code39" -> 2
1810
+ "bct_EAN8" -> 3
1811
+ "bct_ITF" -> 4
1812
+ "bct_PDF417" -> 5
1813
+ "bct_STF" -> 6
1814
+ "bct_MTF" -> 7
1815
+ "bct_IATA" -> 8
1816
+ "bct_CODABAR" -> 9
1817
+ "bct_UPCA" -> 10
1818
+ "bct_CODE93" -> 11
1819
+ "bct_UPCE" -> 12
1820
+ "bct_EAN13" -> 13
1821
+ "bct_QRCODE" -> 14
1822
+ "bct_AZTEC" -> 15
1823
+ "bct_DATAMATRIX" -> 16
1824
+ "bct_ALL_1D" -> 17
1825
+ "bct_Code11" -> 18
1826
+ "bct_JABCODE" -> 19
1827
+ else -> 0
1828
+ }
1829
+ )
1830
+ result
1831
+ }
1832
+
1833
+ fun docFeatureFromJSON(input: JSONObject?) = input?.let {
1834
+ val result = DocFeature::class.constructor().instantiate()
1835
+ result.setPrivateProperty("type", it.getIntOrNull("type"))
1836
+ result.setPrivateProperty("data", bytesDataFromJSON(it.getJSONObjectOrNull("data")))
1837
+ result
1838
+ }
1839
+
1840
+ fun generateDocFeature(input: DocFeature?) = input?.let {
1841
+ mapOf(
1842
+ "type" to it.type,
1843
+ "data" to generateBytesData(it.data),
1844
+ ).toJson()
1845
+ }
1846
+
1847
+ fun vdsDataFromJSON(input: JSONObject?) = input?.let {
1848
+ val result = VDSData::class.constructor().instantiate()
1849
+ result.setPrivateProperty("version", it.getIntOrNull("version"))
1850
+ result.setPrivateProperty("type", it.getIntOrNull("type"))
1851
+ result.setPrivateProperty("docType", it.getIntOrNull("docType"))
1852
+ result.setPrivateProperty("featureRef", it.getIntOrNull("featureRef"))
1853
+ result.setPrivateProperty("issuingCountry", it.getStringOrNull("issuingCountry"))
1854
+ result.setPrivateProperty("docIssueDate", it.getStringOrNull("docIssueDate"))
1855
+ result.setPrivateProperty("signature", bytesDataFromJSON(it.getJSONObjectOrNull("signature")))
1856
+ result.setPrivateProperty("signatureDate", it.getStringOrNull("signatureDate"))
1857
+ result.setPrivateProperty("signer", it.getStringOrNull("signer"))
1858
+ result.setPrivateProperty("certificate", it.getStringOrNull("certificate"))
1859
+ result.setPrivateProperty("certificateChain", it.getJSONArray("certificateChain").toList(::certificateChainFromJSON))
1860
+ result.setPrivateProperty("docFeatures", it.getJSONArray("docFeatures").toList(::docFeatureFromJSON))
1861
+ result.setPrivateProperty("notifications", it.getJSONArray("notifications").toLongArray())
1862
+ result
1863
+ }
1864
+
1865
+ fun generateVDSData(input: VDSData?) = input?.let {
1866
+ mapOf(
1867
+ "version" to it.version,
1868
+ "type" to it.type,
1869
+ "docType" to it.docType,
1870
+ "featureRef" to it.featureRef,
1871
+ "issuingCountry" to it.issuingCountry,
1872
+ "docIssueDate" to it.docIssueDate,
1873
+ "signature" to generateBytesData(it.signature),
1874
+ "signatureDate" to it.signatureDate,
1875
+ "signer" to it.signer,
1876
+ "certificate" to it.certificate,
1877
+ "certificateChain" to it.certificateChain.toJson(::generateCertificateChain),
1878
+ "docFeatures" to it.docFeatures.toJson(::generateDocFeature),
1879
+ "notifications" to it.notifications.toJson(),
1880
+ ).toJson()
1881
+ }
1882
+
1883
+ fun documentReaderResultsFromJSON(input: JSONObject?) = input?.let {
1884
+ val result = DocumentReaderResults()
1885
+
1886
+ result.chipPage = it.optInt("chipPage")
1887
+ result.processingFinishedStatus = it.optInt("processingFinishedStatus")
1888
+ result.elapsedTime = it.optInt("elapsedTime")
1889
+ result.elapsedTimeRFID = it.optInt("elapsedTimeRFID")
1890
+ result.morePagesAvailable = it.optInt("morePagesAvailable")
1891
+ result.graphicResult = documentReaderGraphicResultFromJSON(it.optJSONObject("graphicResult"))
1892
+ result.textResult = documentReaderTextResultFromJSON(it.optJSONObject("textResult"))
1893
+ result.documentPosition = it.optJSONArray("documentPosition").toList(::elementPositionFromJSON)!!
1894
+ result.barcodePosition = it.optJSONArray("barcodePosition").toList(::elementPositionFromJSON)!!
1895
+ result.mrzPosition = it.optJSONArray("mrzPosition").toList(::elementPositionFromJSON)!!
1896
+ result.imageQuality = it.optJSONArray("imageQuality").toList(::imageQualityGroupFromJSON)!!
1897
+ result.rawResult = it.optString("rawResult")
1898
+ result.bsiTr03135Results = it.getStringOrNull("bsiTr03135Results")
1899
+ result.rfidSessionData = rfidSessionDataFromJSON(it.optJSONObject("rfidSessionData"))
1900
+ result.authenticityResult = documentReaderAuthenticityResultFromJSON(it.optJSONObject("authenticityResult"))
1901
+ result.barcodeResult = documentReaderBarcodeResultFromJSON(it.optJSONObject("barcodeResult"))
1902
+ result.rfidSessionData = rfidSessionDataFromJSON(it.optJSONObject("rfidSessionData"))
1903
+ result.documentType = it.optJSONArray("documentType").toList(::documentReaderDocumentTypeFromJSON)!!
1904
+ result.status = documentReaderResultsStatusFromJSON(it.optJSONObject("status"))!!
1905
+ result.vdsncData = vdsncDataFromJSON(it.getJSONObject("vdsncData"))
1906
+ result.vdsData = vdsDataFromJSON(it.getJSONObjectOrNull("vdsData"))
1907
+ result.dtcData = it.getString("dtcData")
1908
+ result.transactionInfo = transactionInfoFromJSON(it.optJSONObject("transactionInfo"))!!
1909
+ result
1910
+ }
1911
+
1912
+ fun generateDocumentReaderResults(input: DocumentReaderResults?) = input?.let {
1913
+ mapOf(
1914
+ "chipPage" to it.chipPage,
1915
+ "processingFinishedStatus" to it.processingFinishedStatus,
1916
+ "elapsedTime" to it.elapsedTime,
1917
+ "elapsedTimeRFID" to it.elapsedTimeRFID,
1918
+ "morePagesAvailable" to it.morePagesAvailable,
1919
+ "graphicResult" to generateDocumentReaderGraphicResult(it.graphicResult),
1920
+ "textResult" to generateDocumentReaderTextResult(it.textResult),
1921
+ "documentPosition" to it.documentPosition.toJson(::generateElementPosition),
1922
+ "barcodePosition" to it.barcodePosition.toJson(::generateElementPosition),
1923
+ "mrzPosition" to it.mrzPosition.toJson(::generateElementPosition),
1924
+ "imageQuality" to it.imageQuality.toJson(::generateImageQualityGroup),
1925
+ "rawResult" to it.rawResult,
1926
+ "bsiTr03135Results" to it.bsiTr03135Results,
1927
+ "rfidSessionData" to generateRFIDSessionData(it.rfidSessionData),
1928
+ "authenticityResult" to generateDocumentReaderAuthenticityResult(it.authenticityResult),
1929
+ "barcodeResult" to generateDocumentReaderBarcodeResult(it.barcodeResult),
1930
+ "documentType" to it.documentType.toJson(::generateDocumentReaderDocumentType),
1931
+ "status" to generateDocumentReaderResultsStatus(it.status),
1932
+ "vdsncData" to generateVDSNCData(it.vdsncData),
1933
+ "vdsData" to generateVDSData(it.vdsData),
1934
+ "dtcData" to it.dtcData,
1935
+ "transactionInfo" to generateTransactionInfo(it.transactionInfo)
1936
+ ).toJson()
1937
+ }
1938
+
1939
+ fun matrixFromJSON(input: JSONArray?) = input?.let {
1940
+ val matrix = Matrix()
1941
+ val result = FloatArray(it.length())
1942
+ for (i in 0 until it.length()) result[i] = it.getDouble(i).toFloat()
1943
+ matrix.setValues(result)
1944
+ matrix
1945
+ }
1946
+
1947
+ fun generateMatrix(input: Matrix?) = input?.let {
1948
+ val floats = FloatArray(9)
1949
+ it.getValues(floats)
1950
+ val result = JSONArray()
1951
+ for (f in floats) result.put(java.lang.Float.valueOf(f))
1952
+ result
1953
+ }
1954
+
1955
+ fun deviceRetrievalMethodFromJSON(input: JSONObject?) = input?.let {
1956
+ val result = DeviceRetrievalMethod::class.constructor().instantiate()
1957
+ result.setPrivateProperty("type", it.getInt("type"))
1958
+ result.setPrivateProperty("version", it.getIntOrNull("version"))
1959
+ result.setPrivateProperty("cmdMaxLength", it.getIntOrNull("cmdMaxLength"))
1960
+ result.setPrivateProperty("respMaxLength", it.getIntOrNull("respMaxLength"))
1961
+ result.setPrivateProperty("clientModeSupport", it.getBooleanOrNull("clientModeSupport"))
1962
+ result.setPrivateProperty("clientModeUUID", it.getStringOrNull("clientModeUUID"))
1963
+ result.setPrivateProperty("serverModeSupport", it.getBooleanOrNull("serverModeSupport"))
1964
+ result.setPrivateProperty("serverModeUUID", it.getStringOrNull("serverModeUUID"))
1965
+ result
1966
+ }
1967
+
1968
+ fun generateDeviceRetrievalMethod(input: DeviceRetrievalMethod?) = input?.let {
1969
+ mapOf(
1970
+ "type" to it.type,
1971
+ "version" to it.version,
1972
+ "cmdMaxLength" to it.cmdMaxLength,
1973
+ "respMaxLength" to it.respMaxLength,
1974
+ "clientModeSupport" to it.clientModeSupport,
1975
+ "clientModeUUID" to it.clientModeUUID,
1976
+ "serverModeSupport" to it.serverModeSupport,
1977
+ "serverModeUUID" to it.serverModeUUID,
1978
+ ).toJson()
1979
+ }
1980
+
1981
+ fun deviceEngagementFromJSON(input: JSONObject?) = input?.let {
1982
+ val result = DeviceEngagement::class.constructor().instantiate()
1983
+
1984
+ result.setPrivateProperty("deviceRetrievalMethods", it.getJSONArray("deviceRetrievalMethods").toList(::deviceRetrievalMethodFromJSON))
1985
+
1986
+ result
1987
+ }
1988
+
1989
+ fun generateDeviceEngagement(input: DeviceEngagement?) = input?.let {
1990
+ mapOf(
1991
+ "deviceRetrievalMethods" to it.deviceRetrievalMethods.toJson(::generateDeviceRetrievalMethod)
1992
+ ).toJson()
1993
+ }
1994
+
1995
+ fun nameSpaceMDLFromJSON(input: JSONObject?) = input?.let {
1996
+ val result = NameSpaceMDL(it.getString("name"))
1997
+ it.getJSONObject("map").forEach { key, value ->
1998
+ result.addField(key, eMDLIntentToRetain.values()[value.toInt()])
1999
+ }
2000
+ result
2001
+ }
2002
+
2003
+ fun generateNameSpaceMDL(input: NameSpaceMDL?) = input?.let {
2004
+ val map = JSONObject()
2005
+ (it.getPrivateProperty("map") as Map<String, eMDLIntentToRetain>).forEach { (key, value) ->
2006
+ map.put(key, value.ordinal)
2007
+ }
2008
+ mapOf(
2009
+ "name" to it.getPrivateProperty("name"),
2010
+ "map" to map,
2011
+ ).toJson()
2012
+ }
2013
+
2014
+ fun documentRequestMDLFromJSON(input: JSONObject?): DocumentRequestMDL? = input?.let {
2015
+ val docType = it.getString("docType")
2016
+ if (docType == "org.iso.18013.5.1.mDL") return@let documentRequest18013MDLFromJSON(it)
2017
+ val result = DocumentRequestMDL(docType)
2018
+
2019
+ result.setPrivateProperty("nameSpaceMDLs", it.getJSONArray("namespaces").toList(::nameSpaceMDLFromJSON))
2020
+
2021
+ result
2022
+ }
2023
+
2024
+ fun generateDocumentRequestMDL(input: DocumentRequestMDL?): JSONObject? = input?.let {
2025
+ val docType = it.getPrivateProperty("docType") as String
2026
+ if (docType == "org.iso.18013.5.1.mDL") return@let generateDocumentRequest18013MDL(it as DocumentRequest18013MDL?)
2027
+ mapOf(
2028
+ "docType" to docType,
2029
+ "namespaces" to (it.getPrivateProperty("nameSpaceMDLs") as List<NameSpaceMDL>).toJson(::generateNameSpaceMDL),
2030
+ ).toJson()
2031
+ }
2032
+
2033
+ fun documentRequest18013MDLFromJSON(input: JSONObject?) = input?.let {
2034
+ val result = DocumentRequest18013MDL()
2035
+
2036
+ if (it.has("docType")) result.setPrivateProperty("docType", it.getString("docType"))
2037
+ if (it.has("namespaces")) result.setPrivateProperty("nameSpaceMDLs", it.getJSONArray("namespaces").toList(::nameSpaceMDLFromJSON))
2038
+ result.familyName = it.getIntOrNull("familyName")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2039
+ result.givenName = it.getIntOrNull("givenName")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2040
+ result.birthDate = it.getIntOrNull("birthDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2041
+ result.issueDate = it.getIntOrNull("issueDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2042
+ result.expiryDate = it.getIntOrNull("expiryDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2043
+ result.issuingCountry = it.getIntOrNull("issuingCountry")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2044
+ result.issuingAuthority = it.getIntOrNull("issuingAuthority")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2045
+ result.documentNumber = it.getIntOrNull("documentNumber")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2046
+ result.portrait = it.getIntOrNull("portrait")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2047
+ result.drivingPrivileges = it.getIntOrNull("drivingPrivileges")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2048
+ result.unDistinguishingSign = it.getIntOrNull("unDistinguishingSign")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2049
+ result.administrativeNumber = it.getIntOrNull("administrativeNumber")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2050
+ result.sex = it.getIntOrNull("sex")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2051
+ result.height = it.getIntOrNull("height")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2052
+ result.weight = it.getIntOrNull("weight")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2053
+ result.eyeColour = it.getIntOrNull("eyeColour")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2054
+ result.hairColour = it.getIntOrNull("hairColour")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2055
+ result.birthPlace = it.getIntOrNull("birthPlace")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2056
+ result.residentAddress = it.getIntOrNull("residentAddress")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2057
+ result.portraitCaptureDate = it.getIntOrNull("portraitCaptureDate")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2058
+ result.ageInYears = it.getIntOrNull("ageInYears")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2059
+ result.ageBirthYear = it.getIntOrNull("ageBirthYear")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2060
+ result.ageOver18 = it.getIntOrNull("ageOver18")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2061
+ result.issuingJurisdiction = it.getIntOrNull("issuingJurisdiction")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2062
+ result.nationality = it.getIntOrNull("nationality")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2063
+ result.residentCity = it.getIntOrNull("residentCity")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2064
+ result.residentState = it.getIntOrNull("residentState")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2065
+ result.residentPostalCode = it.getIntOrNull("residentPostalCode")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2066
+ result.residentCountry = it.getIntOrNull("residentCountry")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2067
+ result.biometricTemplateFace = it.getIntOrNull("biometricTemplateFace")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2068
+ result.biometricTemplateIris = it.getIntOrNull("biometricTemplateIris")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2069
+ result.biometricTemplateFinger = it.getIntOrNull("biometricTemplateFinger")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2070
+ result.biometricTemplateSignatureSign = it.getIntOrNull("biometricTemplateSignatureSign")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2071
+ result.familyNameNationalCharacter = it.getIntOrNull("familyNameNationalCharacter")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2072
+ result.givenNameNationalCharacter = it.getIntOrNull("givenNameNationalCharacter")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2073
+ result.signatureUsualMark = it.getIntOrNull("signatureUsualMark")?.let { enm -> eMDLIntentToRetain.values()[enm] }
2074
+ result
2075
+ }
2076
+
2077
+ fun generateDocumentRequest18013MDL(input: DocumentRequest18013MDL?) = input?.let {
2078
+ mapOf(
2079
+ "docType" to it.getPrivateProperty("docType"),
2080
+ "namespaces" to (it.getPrivateProperty("nameSpaceMDLs") as List<NameSpaceMDL>).toJson(::generateNameSpaceMDL),
2081
+ "familyName" to it.familyName?.ordinal,
2082
+ "givenName" to it.givenName?.ordinal,
2083
+ "birthDate" to it.birthDate?.ordinal,
2084
+ "issueDate" to it.issueDate?.ordinal,
2085
+ "expiryDate" to it.expiryDate?.ordinal,
2086
+ "issuingCountry" to it.issuingCountry?.ordinal,
2087
+ "issuingAuthority" to it.issuingAuthority?.ordinal,
2088
+ "documentNumber" to it.documentNumber?.ordinal,
2089
+ "portrait" to it.portrait?.ordinal,
2090
+ "drivingPrivileges" to it.drivingPrivileges?.ordinal,
2091
+ "unDistinguishingSign" to it.unDistinguishingSign?.ordinal,
2092
+ "administrativeNumber" to it.administrativeNumber?.ordinal,
2093
+ "sex" to it.sex?.ordinal,
2094
+ "height" to it.height?.ordinal,
2095
+ "weight" to it.weight?.ordinal,
2096
+ "eyeColour" to it.eyeColour?.ordinal,
2097
+ "hairColour" to it.hairColour?.ordinal,
2098
+ "birthPlace" to it.birthPlace?.ordinal,
2099
+ "residentAddress" to it.residentAddress?.ordinal,
2100
+ "portraitCaptureDate" to it.portraitCaptureDate?.ordinal,
2101
+ "ageInYears" to it.ageInYears?.ordinal,
2102
+ "ageBirthYear" to it.ageBirthYear?.ordinal,
2103
+ "ageOver18" to it.ageOver18?.ordinal,
2104
+ "issuingJurisdiction" to it.issuingJurisdiction?.ordinal,
2105
+ "nationality" to it.nationality?.ordinal,
2106
+ "residentCity" to it.residentCity?.ordinal,
2107
+ "residentState" to it.residentState?.ordinal,
2108
+ "residentPostalCode" to it.residentPostalCode?.ordinal,
2109
+ "residentCountry" to it.residentCountry?.ordinal,
2110
+ "biometricTemplateFace" to it.biometricTemplateFace?.ordinal,
2111
+ "biometricTemplateIris" to it.biometricTemplateIris?.ordinal,
2112
+ "biometricTemplateFinger" to it.biometricTemplateFinger?.ordinal,
2113
+ "biometricTemplateSignatureSign" to it.biometricTemplateSignatureSign?.ordinal,
2114
+ "familyNameNationalCharacter" to it.familyNameNationalCharacter?.ordinal,
2115
+ "givenNameNationalCharacter" to it.givenNameNationalCharacter?.ordinal,
2116
+ "signatureUsualMark" to it.signatureUsualMark?.ordinal,
2117
+ ).toJson()
2118
+ }
2119
+
2120
+ fun dataRetrievalFromJSON(input: JSONObject?) = input?.let {
2121
+ val result = DataRetrieval(eMDLDeviceRetrieval.values().first { enm -> enm.value == it.getInt("deviceRetrieval") })
2122
+ result.setPrivateProperty("docRequestPreset", it.getIntOrNull("docRequestPreset")?.let { enm -> eMDLDocRequestPreset.values()[enm] })
2123
+ result.setPrivateProperty("intentToRetain", it.getIntOrNull("intentToRetain")?.let { enm -> eMDLIntentToRetain.values()[enm] })
2124
+ it.getJSONArray("requests").toList(::documentRequestMDLFromJSON)?.forEach { r -> result.addDocRequest(r!!) }
2125
+ result
2126
+ }
2127
+
2128
+ fun generateDataRetrieval(input: DataRetrieval?) = input?.let {
2129
+ mapOf(
2130
+ "deviceRetrieval" to it.deviceRetrieval.value,
2131
+ "docRequestPreset" to (it.getPrivateProperty("docRequestPreset") as eMDLDocRequestPreset).ordinal,
2132
+ "intentToRetain" to (it.getPrivateProperty("intentToRetain") as eMDLIntentToRetain).ordinal,
2133
+ "requests" to (it.getPrivateProperty("docRequests") as List<DocumentRequestMDL>).toJson(::generateDocumentRequestMDL),
2134
+ ).toJson()
2135
+ }
2136
+
2137
+ fun generateDeviceEngagementCompletion(deviceEngagement: DeviceEngagement?, error: RegulaException?) = mapOf(
2138
+ "deviceEngagement" to generateDeviceEngagement(deviceEngagement),
2139
+ "error" to generateRegulaException(error)
2140
+ ).toJson()
2141
+
2142
+ fun finalizeConfigFromJSON(input: JSONObject?) = input?.let {
2143
+ val result = FinalizeConfig.Builder()
2144
+ if (it.has("rawImages")) result.setRawImages(it.getBoolean("rawImages"))
2145
+ if (it.has("video")) result.setVideo(it.getBoolean("video"))
2146
+ if (it.has("rfidSession")) result.setRfidSession(it.getBoolean("rfidSession"))
2147
+ if (it.has("mdlSession")) result.setMdlSession(it.getBoolean("mdlSession"))
2148
+ result.build()
2149
+ }
2150
+
2151
+ fun generateFinalizeConfig(input: FinalizeConfig?) = input?.let {
2152
+ mapOf(
2153
+ "rawImages" to it.getPrivateProperty("rawImages"),
2154
+ "video" to it.getPrivateProperty("video"),
2155
+ "rfidSession" to it.getPrivateProperty("rfidSession"),
2156
+ "mdlSession" to it.getPrivateProperty("mdlSession"),
2157
+ ).toJson()
2158
+ }
2159
+
2160
+ fun paceProtocolFromJSON(input: JSONObject?) = input?.let {
2161
+ PaceProtocol(
2162
+ it.getString("version"),
2163
+ it.getString("stdDomainParams"),
2164
+ it.getString("keyAlgorithm"),
2165
+ )
2166
+ }
2167
+
2168
+ fun generatePaceProtocol(input: PaceProtocol?) = input?.let {
2169
+ mapOf(
2170
+ "version" to it.version,
2171
+ "stdDomainParams" to it.stdDomainParams,
2172
+ "keyAlgorithm" to it.keyAlgorithm,
2173
+ ).toJson()
2174
+ }
2175
+
2176
+ fun caProtocolFromJSON(input: JSONObject?) = input?.let {
2177
+ CaProtocol(
2178
+ it.getString("version"),
2179
+ it.getString("scheme"),
2180
+ it.getString("keyAlgorithm"),
2181
+ it.getBoolean("chipIndividual"),
2182
+ )
2183
+ }
2184
+
2185
+ fun generateCaProtocol(input: CaProtocol?) = input?.let {
2186
+ mapOf(
2187
+ "version" to it.version,
2188
+ "scheme" to it.scheme,
2189
+ "keyAlgorithm" to it.keyAlgorithm,
2190
+ "chipIndividual" to it.isChipIndividual,
2191
+ ).toJson()
2192
+ }