@regulaforensics/document-reader 8.2.186-beta

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