@trustchex/react-native-sdk 1.161.0

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 (650) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +223 -0
  3. package/TrustchexSDK.podspec +26 -0
  4. package/android/build.gradle +103 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +11 -0
  7. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKModule.kt +40 -0
  8. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +61 -0
  9. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +301 -0
  10. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +205 -0
  11. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +72 -0
  12. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +4 -0
  13. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +303 -0
  14. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +115 -0
  15. package/ios/TrustchexSDK.h +5 -0
  16. package/ios/TrustchexSDK.mm +28 -0
  17. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +22 -0
  18. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +172 -0
  19. package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +13 -0
  20. package/ios/VisionCameraPlugins/Cropper/Cropper.h +20 -0
  21. package/ios/VisionCameraPlugins/Cropper/Cropper.mm +22 -0
  22. package/ios/VisionCameraPlugins/Cropper/Cropper.swift +145 -0
  23. package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +49 -0
  24. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +4 -0
  25. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +22 -0
  26. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +320 -0
  27. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +4 -0
  28. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +27 -0
  29. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +144 -0
  30. package/lib/module/NativeTrustchexSDK.js +4 -0
  31. package/lib/module/Screens/Dynamic/ContractAcceptanceScreen.js +141 -0
  32. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +140 -0
  33. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +100 -0
  34. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +596 -0
  35. package/lib/module/Screens/Static/QrCodeScanningScreen.js +36 -0
  36. package/lib/module/Screens/Static/ResultScreen.js +627 -0
  37. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +381 -0
  38. package/lib/module/Shared/Animations/face-scan.json +1 -0
  39. package/lib/module/Shared/Animations/hole.json +76 -0
  40. package/lib/module/Shared/Animations/hologram-scan.json +1 -0
  41. package/lib/module/Shared/Animations/id-or-passport.json +1 -0
  42. package/lib/module/Shared/Animations/light.json +1 -0
  43. package/lib/module/Shared/Animations/loading.json +1 -0
  44. package/lib/module/Shared/Animations/nfc-scan.json +1 -0
  45. package/lib/module/Shared/Animations/nfc.json +1 -0
  46. package/lib/module/Shared/Animations/scanning.json +1 -0
  47. package/lib/module/Shared/Animations/success.json +1 -0
  48. package/lib/module/Shared/Assets/trustchex-logo-black.png +0 -0
  49. package/lib/module/Shared/Components/EIDScanner.js +372 -0
  50. package/lib/module/Shared/Components/FaceCamera.js +223 -0
  51. package/lib/module/Shared/Components/IdentityDocumentCamera.js +968 -0
  52. package/lib/module/Shared/Components/LanguageSelector.js +53 -0
  53. package/lib/module/Shared/Components/NativeCircularProgress.js +64 -0
  54. package/lib/module/Shared/Components/NativeProgressBar.js +53 -0
  55. package/lib/module/Shared/Components/NavigationManager.js +180 -0
  56. package/lib/module/Shared/Components/OTPCodeInput.js +74 -0
  57. package/lib/module/Shared/Components/QrCodeScannerCamera.js +262 -0
  58. package/lib/module/Shared/Contexts/AppContext.js +27 -0
  59. package/lib/module/Shared/EIDReader/abstractMRTDCardService.js +4 -0
  60. package/lib/module/Shared/EIDReader/accessKeySpec.js +1 -0
  61. package/lib/module/Shared/EIDReader/apduLevelBACCapable.js +1 -0
  62. package/lib/module/Shared/EIDReader/apduLevelReadBinaryCapable.js +3 -0
  63. package/lib/module/Shared/EIDReader/bacKey.js +112 -0
  64. package/lib/module/Shared/EIDReader/bacKeySpec.js +3 -0
  65. package/lib/module/Shared/EIDReader/cardFileInputStream.js +140 -0
  66. package/lib/module/Shared/EIDReader/cardService.js +31 -0
  67. package/lib/module/Shared/EIDReader/cbeff/biometricDataBlock.js +3 -0
  68. package/lib/module/Shared/EIDReader/cbeff/biometricDataBlockDecoder.js +3 -0
  69. package/lib/module/Shared/EIDReader/cbeff/biometricDataBlockEncoder.js +3 -0
  70. package/lib/module/Shared/EIDReader/cbeff/cbeffInfo.js +102 -0
  71. package/lib/module/Shared/EIDReader/cbeff/complexCBEFFInfo.js +46 -0
  72. package/lib/module/Shared/EIDReader/cbeff/faceDataBlockDecoder.js +8 -0
  73. package/lib/module/Shared/EIDReader/cbeff/iso781611.js +79 -0
  74. package/lib/module/Shared/EIDReader/cbeff/iso781611Decoder.js +141 -0
  75. package/lib/module/Shared/EIDReader/cbeff/iso781611Encoder.js +53 -0
  76. package/lib/module/Shared/EIDReader/cbeff/simpleCBEFFInfo.js +21 -0
  77. package/lib/module/Shared/EIDReader/cbeff/standardBiometricHeader.js +97 -0
  78. package/lib/module/Shared/EIDReader/cert/cvcPrincipal.js +48 -0
  79. package/lib/module/Shared/EIDReader/data/country.js +66 -0
  80. package/lib/module/Shared/EIDReader/data/gender.js +29 -0
  81. package/lib/module/Shared/EIDReader/data/isoCountry.js +283 -0
  82. package/lib/module/Shared/EIDReader/data/unicodeCountry.js +278 -0
  83. package/lib/module/Shared/EIDReader/defaultFileInfo.js +29 -0
  84. package/lib/module/Shared/EIDReader/defaultFileSystem.js +171 -0
  85. package/lib/module/Shared/EIDReader/eidReader.js +90 -0
  86. package/lib/module/Shared/EIDReader/eidService.js +280 -0
  87. package/lib/module/Shared/EIDReader/fileInfo.js +3 -0
  88. package/lib/module/Shared/EIDReader/fileSystemCardService.js +4 -0
  89. package/lib/module/Shared/EIDReader/fragment.js +17 -0
  90. package/lib/module/Shared/EIDReader/fragmentBuffer.js +130 -0
  91. package/lib/module/Shared/EIDReader/java/byteArrayInputStream.js +73 -0
  92. package/lib/module/Shared/EIDReader/java/byteArrayOutputStream.js +55 -0
  93. package/lib/module/Shared/EIDReader/java/dataInput.js +1 -0
  94. package/lib/module/Shared/EIDReader/java/dataInputStream.js +167 -0
  95. package/lib/module/Shared/EIDReader/java/dataOutputStream.js +91 -0
  96. package/lib/module/Shared/EIDReader/java/filterInputStream.js +134 -0
  97. package/lib/module/Shared/EIDReader/java/filterOutputStream.js +124 -0
  98. package/lib/module/Shared/EIDReader/java/inputStream.js +139 -0
  99. package/lib/module/Shared/EIDReader/java/inputStreamBuffer.js +144 -0
  100. package/lib/module/Shared/EIDReader/java/objectInputStream.js +39 -0
  101. package/lib/module/Shared/EIDReader/java/outputStream.js +77 -0
  102. package/lib/module/Shared/EIDReader/java/positionInputStream.js +50 -0
  103. package/lib/module/Shared/EIDReader/java/splittableInputStream.js +54 -0
  104. package/lib/module/Shared/EIDReader/lds/abstractImageInfo.js +137 -0
  105. package/lib/module/Shared/EIDReader/lds/abstractLDSFile.js +101 -0
  106. package/lib/module/Shared/EIDReader/lds/abstractLDSInfo.js +29 -0
  107. package/lib/module/Shared/EIDReader/lds/abstractListInfo.js +66 -0
  108. package/lib/module/Shared/EIDReader/lds/abstractTaggedLDSFile.js +65 -0
  109. package/lib/module/Shared/EIDReader/lds/cbeffDataGroup.js +118 -0
  110. package/lib/module/Shared/EIDReader/lds/cvcaFile.js +89 -0
  111. package/lib/module/Shared/EIDReader/lds/dataGroup.js +10 -0
  112. package/lib/module/Shared/EIDReader/lds/icao/comFile.js +101 -0
  113. package/lib/module/Shared/EIDReader/lds/icao/dg1File.js +33 -0
  114. package/lib/module/Shared/EIDReader/lds/icao/dg2File.js +42 -0
  115. package/lib/module/Shared/EIDReader/lds/icao/icaoCountry.js +114 -0
  116. package/lib/module/Shared/EIDReader/lds/icao/mrzInfo.js +1418 -0
  117. package/lib/module/Shared/EIDReader/lds/imageInfo.js +3 -0
  118. package/lib/module/Shared/EIDReader/lds/iso19794/faceImageInfo.js +817 -0
  119. package/lib/module/Shared/EIDReader/lds/iso19794/faceInfo.js +116 -0
  120. package/lib/module/Shared/EIDReader/lds/ldsElement.js +1 -0
  121. package/lib/module/Shared/EIDReader/lds/ldsFile.js +3 -0
  122. package/lib/module/Shared/EIDReader/nfcManagerCardService.js +44 -0
  123. package/lib/module/Shared/EIDReader/protocol/bacAPDUSender.js +83 -0
  124. package/lib/module/Shared/EIDReader/protocol/bacProtocol.js +70 -0
  125. package/lib/module/Shared/EIDReader/protocol/bacResult.js +32 -0
  126. package/lib/module/Shared/EIDReader/protocol/readBinaryAPDUSender.js +126 -0
  127. package/lib/module/Shared/EIDReader/protocol/secureMessagingAPDUSender.js +102 -0
  128. package/lib/module/Shared/EIDReader/secureMessagingWrapper.js +218 -0
  129. package/lib/module/Shared/EIDReader/smartcards/apduEvent.js +23 -0
  130. package/lib/module/Shared/EIDReader/smartcards/apduListener.js +3 -0
  131. package/lib/module/Shared/EIDReader/smartcards/apduWrapper.js +3 -0
  132. package/lib/module/Shared/EIDReader/smartcards/commandAPDU.js +124 -0
  133. package/lib/module/Shared/EIDReader/smartcards/fileSystemStructured.js +3 -0
  134. package/lib/module/Shared/EIDReader/smartcards/iso7816.js +107 -0
  135. package/lib/module/Shared/EIDReader/smartcards/responseAPDU.js +35 -0
  136. package/lib/module/Shared/EIDReader/tlv/asn1Constants.js +48 -0
  137. package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +186 -0
  138. package/lib/module/Shared/EIDReader/tlv/tlvInputState.js +141 -0
  139. package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +180 -0
  140. package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +186 -0
  141. package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +85 -0
  142. package/lib/module/Shared/EIDReader/tripleDesSecureMessagingWrapper.js +37 -0
  143. package/lib/module/Shared/EIDReader/utils/crypto.utils.js +218 -0
  144. package/lib/module/Shared/EIDReader/utils/random.js +166 -0
  145. package/lib/module/Shared/EIDReader/wrappedAPDUEvent.js +16 -0
  146. package/lib/module/Shared/Libs/camera.utils.js +32 -0
  147. package/lib/module/Shared/Libs/contains.js +40 -0
  148. package/lib/module/Shared/Libs/crypto.utils.js +35 -0
  149. package/lib/module/Shared/Libs/debounce.utils.js +35 -0
  150. package/lib/module/Shared/Libs/deeplink.utils.js +20 -0
  151. package/lib/module/Shared/Libs/demo.utils.js +57 -0
  152. package/lib/module/Shared/Libs/http-client.js +104 -0
  153. package/lib/module/Shared/Libs/mrz.utils.js +99 -0
  154. package/lib/module/Shared/Libs/native-device-info.utils.js +44 -0
  155. package/lib/module/Shared/Libs/native-keep-awake.utils.js +85 -0
  156. package/lib/module/Shared/Libs/opencv.utils.js +21 -0
  157. package/lib/module/Shared/Libs/promise.utils.js +17 -0
  158. package/lib/module/Shared/Libs/tts.utils.js +31 -0
  159. package/lib/module/Shared/Types/identificationInfo.js +3 -0
  160. package/lib/module/Shared/Types/instruction.js +1 -0
  161. package/lib/module/Shared/Types/livenessIntructionType.js +1 -0
  162. package/lib/module/Shared/Types/verificationSession.js +3 -0
  163. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.js +66 -0
  164. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +46 -0
  165. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +34 -0
  166. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +21 -0
  167. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +24 -0
  168. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +3 -0
  169. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +197 -0
  170. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +101 -0
  171. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +60 -0
  172. package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +47 -0
  173. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +42 -0
  174. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +35 -0
  175. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +4 -0
  176. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +3 -0
  177. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +56 -0
  178. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +20 -0
  179. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +9 -0
  180. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +6 -0
  181. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +20 -0
  182. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +19 -0
  183. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +3 -0
  184. package/lib/module/Translation/Resources/en.js +109 -0
  185. package/lib/module/Translation/Resources/index.js +4 -0
  186. package/lib/module/Translation/Resources/tr.js +112 -0
  187. package/lib/module/Translation/index.js +27 -0
  188. package/lib/module/Trustchex.js +149 -0
  189. package/lib/module/index.js +5 -0
  190. package/lib/module/package.json +1 -0
  191. package/lib/typescript/package.json +1 -0
  192. package/lib/typescript/src/NativeTrustchexSDK.d.ts +8 -0
  193. package/lib/typescript/src/NativeTrustchexSDK.d.ts.map +1 -0
  194. package/lib/typescript/src/Screens/Dynamic/ContractAcceptanceScreen.d.ts +3 -0
  195. package/lib/typescript/src/Screens/Dynamic/ContractAcceptanceScreen.d.ts.map +1 -0
  196. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts +3 -0
  197. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -0
  198. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts +3 -0
  199. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -0
  200. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts +3 -0
  201. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -0
  202. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts +3 -0
  203. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -0
  204. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts +3 -0
  205. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -0
  206. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts +3 -0
  207. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -0
  208. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +12 -0
  209. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -0
  210. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +9 -0
  211. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -0
  212. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +58 -0
  213. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -0
  214. package/lib/typescript/src/Shared/Components/LanguageSelector.d.ts +3 -0
  215. package/lib/typescript/src/Shared/Components/LanguageSelector.d.ts.map +1 -0
  216. package/lib/typescript/src/Shared/Components/NativeCircularProgress.d.ts +13 -0
  217. package/lib/typescript/src/Shared/Components/NativeCircularProgress.d.ts.map +1 -0
  218. package/lib/typescript/src/Shared/Components/NativeProgressBar.d.ts +12 -0
  219. package/lib/typescript/src/Shared/Components/NativeProgressBar.d.ts.map +1 -0
  220. package/lib/typescript/src/Shared/Components/NavigationManager.d.ts +11 -0
  221. package/lib/typescript/src/Shared/Components/NavigationManager.d.ts.map +1 -0
  222. package/lib/typescript/src/Shared/Components/OTPCodeInput.d.ts +10 -0
  223. package/lib/typescript/src/Shared/Components/OTPCodeInput.d.ts.map +1 -0
  224. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +6 -0
  225. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -0
  226. package/lib/typescript/src/Shared/Contexts/AppContext.d.ts +20 -0
  227. package/lib/typescript/src/Shared/Contexts/AppContext.d.ts.map +1 -0
  228. package/lib/typescript/src/Shared/EIDReader/abstractMRTDCardService.d.ts +50 -0
  229. package/lib/typescript/src/Shared/EIDReader/abstractMRTDCardService.d.ts.map +1 -0
  230. package/lib/typescript/src/Shared/EIDReader/accessKeySpec.d.ts +16 -0
  231. package/lib/typescript/src/Shared/EIDReader/accessKeySpec.d.ts.map +1 -0
  232. package/lib/typescript/src/Shared/EIDReader/apduLevelBACCapable.d.ts +5 -0
  233. package/lib/typescript/src/Shared/EIDReader/apduLevelBACCapable.d.ts.map +1 -0
  234. package/lib/typescript/src/Shared/EIDReader/apduLevelReadBinaryCapable.d.ts +8 -0
  235. package/lib/typescript/src/Shared/EIDReader/apduLevelReadBinaryCapable.d.ts.map +1 -0
  236. package/lib/typescript/src/Shared/EIDReader/bacKey.d.ts +65 -0
  237. package/lib/typescript/src/Shared/EIDReader/bacKey.d.ts.map +1 -0
  238. package/lib/typescript/src/Shared/EIDReader/bacKeySpec.d.ts +24 -0
  239. package/lib/typescript/src/Shared/EIDReader/bacKeySpec.d.ts.map +1 -0
  240. package/lib/typescript/src/Shared/EIDReader/cardFileInputStream.d.ts +26 -0
  241. package/lib/typescript/src/Shared/EIDReader/cardFileInputStream.d.ts.map +1 -0
  242. package/lib/typescript/src/Shared/EIDReader/cardService.d.ts +22 -0
  243. package/lib/typescript/src/Shared/EIDReader/cardService.d.ts.map +1 -0
  244. package/lib/typescript/src/Shared/EIDReader/cbeff/biometricDataBlock.d.ts +5 -0
  245. package/lib/typescript/src/Shared/EIDReader/cbeff/biometricDataBlock.d.ts.map +1 -0
  246. package/lib/typescript/src/Shared/EIDReader/cbeff/biometricDataBlockDecoder.d.ts +7 -0
  247. package/lib/typescript/src/Shared/EIDReader/cbeff/biometricDataBlockDecoder.d.ts.map +1 -0
  248. package/lib/typescript/src/Shared/EIDReader/cbeff/biometricDataBlockEncoder.d.ts +6 -0
  249. package/lib/typescript/src/Shared/EIDReader/cbeff/biometricDataBlockEncoder.d.ts.map +1 -0
  250. package/lib/typescript/src/Shared/EIDReader/cbeff/cbeffInfo.d.ts +61 -0
  251. package/lib/typescript/src/Shared/EIDReader/cbeff/cbeffInfo.d.ts.map +1 -0
  252. package/lib/typescript/src/Shared/EIDReader/cbeff/complexCBEFFInfo.d.ts +33 -0
  253. package/lib/typescript/src/Shared/EIDReader/cbeff/complexCBEFFInfo.d.ts.map +1 -0
  254. package/lib/typescript/src/Shared/EIDReader/cbeff/faceDataBlockDecoder.d.ts +8 -0
  255. package/lib/typescript/src/Shared/EIDReader/cbeff/faceDataBlockDecoder.d.ts.map +1 -0
  256. package/lib/typescript/src/Shared/EIDReader/cbeff/iso781611.d.ts +60 -0
  257. package/lib/typescript/src/Shared/EIDReader/cbeff/iso781611.d.ts.map +1 -0
  258. package/lib/typescript/src/Shared/EIDReader/cbeff/iso781611Decoder.d.ts +19 -0
  259. package/lib/typescript/src/Shared/EIDReader/cbeff/iso781611Decoder.d.ts.map +1 -0
  260. package/lib/typescript/src/Shared/EIDReader/cbeff/iso781611Encoder.d.ts +15 -0
  261. package/lib/typescript/src/Shared/EIDReader/cbeff/iso781611Encoder.d.ts.map +1 -0
  262. package/lib/typescript/src/Shared/EIDReader/cbeff/simpleCBEFFInfo.d.ts +18 -0
  263. package/lib/typescript/src/Shared/EIDReader/cbeff/simpleCBEFFInfo.d.ts.map +1 -0
  264. package/lib/typescript/src/Shared/EIDReader/cbeff/standardBiometricHeader.d.ts +43 -0
  265. package/lib/typescript/src/Shared/EIDReader/cbeff/standardBiometricHeader.d.ts.map +1 -0
  266. package/lib/typescript/src/Shared/EIDReader/cert/cvcPrincipal.d.ts +14 -0
  267. package/lib/typescript/src/Shared/EIDReader/cert/cvcPrincipal.d.ts.map +1 -0
  268. package/lib/typescript/src/Shared/EIDReader/data/country.d.ts +14 -0
  269. package/lib/typescript/src/Shared/EIDReader/data/country.d.ts.map +1 -0
  270. package/lib/typescript/src/Shared/EIDReader/data/gender.d.ts +14 -0
  271. package/lib/typescript/src/Shared/EIDReader/data/gender.d.ts.map +1 -0
  272. package/lib/typescript/src/Shared/EIDReader/data/isoCountry.d.ts +268 -0
  273. package/lib/typescript/src/Shared/EIDReader/data/isoCountry.d.ts.map +1 -0
  274. package/lib/typescript/src/Shared/EIDReader/data/unicodeCountry.d.ts +263 -0
  275. package/lib/typescript/src/Shared/EIDReader/data/unicodeCountry.d.ts.map +1 -0
  276. package/lib/typescript/src/Shared/EIDReader/defaultFileInfo.d.ts +14 -0
  277. package/lib/typescript/src/Shared/EIDReader/defaultFileInfo.d.ts.map +1 -0
  278. package/lib/typescript/src/Shared/EIDReader/defaultFileSystem.d.ts +30 -0
  279. package/lib/typescript/src/Shared/EIDReader/defaultFileSystem.d.ts.map +1 -0
  280. package/lib/typescript/src/Shared/EIDReader/eidReader.d.ts +8 -0
  281. package/lib/typescript/src/Shared/EIDReader/eidReader.d.ts.map +1 -0
  282. package/lib/typescript/src/Shared/EIDReader/eidService.d.ts +150 -0
  283. package/lib/typescript/src/Shared/EIDReader/eidService.d.ts.map +1 -0
  284. package/lib/typescript/src/Shared/EIDReader/fileInfo.d.ts +5 -0
  285. package/lib/typescript/src/Shared/EIDReader/fileInfo.d.ts.map +1 -0
  286. package/lib/typescript/src/Shared/EIDReader/fileSystemCardService.d.ts +28 -0
  287. package/lib/typescript/src/Shared/EIDReader/fileSystemCardService.d.ts.map +1 -0
  288. package/lib/typescript/src/Shared/EIDReader/fragment.d.ts +9 -0
  289. package/lib/typescript/src/Shared/EIDReader/fragment.d.ts.map +1 -0
  290. package/lib/typescript/src/Shared/EIDReader/fragmentBuffer.d.ts +22 -0
  291. package/lib/typescript/src/Shared/EIDReader/fragmentBuffer.d.ts.map +1 -0
  292. package/lib/typescript/src/Shared/EIDReader/java/byteArrayInputStream.d.ts +22 -0
  293. package/lib/typescript/src/Shared/EIDReader/java/byteArrayInputStream.d.ts.map +1 -0
  294. package/lib/typescript/src/Shared/EIDReader/java/byteArrayOutputStream.d.ts +18 -0
  295. package/lib/typescript/src/Shared/EIDReader/java/byteArrayOutputStream.d.ts.map +1 -0
  296. package/lib/typescript/src/Shared/EIDReader/java/dataInput.d.ts +17 -0
  297. package/lib/typescript/src/Shared/EIDReader/java/dataInput.d.ts.map +1 -0
  298. package/lib/typescript/src/Shared/EIDReader/java/dataInputStream.d.ts +28 -0
  299. package/lib/typescript/src/Shared/EIDReader/java/dataInputStream.d.ts.map +1 -0
  300. package/lib/typescript/src/Shared/EIDReader/java/dataOutputStream.d.ts +18 -0
  301. package/lib/typescript/src/Shared/EIDReader/java/dataOutputStream.d.ts.map +1 -0
  302. package/lib/typescript/src/Shared/EIDReader/java/filterInputStream.d.ts +103 -0
  303. package/lib/typescript/src/Shared/EIDReader/java/filterInputStream.d.ts.map +1 -0
  304. package/lib/typescript/src/Shared/EIDReader/java/filterOutputStream.d.ts +83 -0
  305. package/lib/typescript/src/Shared/EIDReader/java/filterOutputStream.d.ts.map +1 -0
  306. package/lib/typescript/src/Shared/EIDReader/java/inputStream.d.ts +21 -0
  307. package/lib/typescript/src/Shared/EIDReader/java/inputStream.d.ts.map +1 -0
  308. package/lib/typescript/src/Shared/EIDReader/java/inputStreamBuffer.d.ts +32 -0
  309. package/lib/typescript/src/Shared/EIDReader/java/inputStreamBuffer.d.ts.map +1 -0
  310. package/lib/typescript/src/Shared/EIDReader/java/objectInputStream.d.ts +11 -0
  311. package/lib/typescript/src/Shared/EIDReader/java/objectInputStream.d.ts.map +1 -0
  312. package/lib/typescript/src/Shared/EIDReader/java/outputStream.d.ts +64 -0
  313. package/lib/typescript/src/Shared/EIDReader/java/outputStream.d.ts.map +1 -0
  314. package/lib/typescript/src/Shared/EIDReader/java/positionInputStream.d.ts +17 -0
  315. package/lib/typescript/src/Shared/EIDReader/java/positionInputStream.d.ts.map +1 -0
  316. package/lib/typescript/src/Shared/EIDReader/java/splittableInputStream.d.ts +19 -0
  317. package/lib/typescript/src/Shared/EIDReader/java/splittableInputStream.d.ts.map +1 -0
  318. package/lib/typescript/src/Shared/EIDReader/lds/abstractImageInfo.d.ts +50 -0
  319. package/lib/typescript/src/Shared/EIDReader/lds/abstractImageInfo.d.ts.map +1 -0
  320. package/lib/typescript/src/Shared/EIDReader/lds/abstractLDSFile.d.ts +71 -0
  321. package/lib/typescript/src/Shared/EIDReader/lds/abstractLDSFile.d.ts.map +1 -0
  322. package/lib/typescript/src/Shared/EIDReader/lds/abstractLDSInfo.d.ts +19 -0
  323. package/lib/typescript/src/Shared/EIDReader/lds/abstractLDSInfo.d.ts.map +1 -0
  324. package/lib/typescript/src/Shared/EIDReader/lds/abstractListInfo.d.ts +45 -0
  325. package/lib/typescript/src/Shared/EIDReader/lds/abstractListInfo.d.ts.map +1 -0
  326. package/lib/typescript/src/Shared/EIDReader/lds/abstractTaggedLDSFile.d.ts +18 -0
  327. package/lib/typescript/src/Shared/EIDReader/lds/abstractTaggedLDSFile.d.ts.map +1 -0
  328. package/lib/typescript/src/Shared/EIDReader/lds/cbeffDataGroup.d.ts +59 -0
  329. package/lib/typescript/src/Shared/EIDReader/lds/cbeffDataGroup.d.ts.map +1 -0
  330. package/lib/typescript/src/Shared/EIDReader/lds/cvcaFile.d.ts +19 -0
  331. package/lib/typescript/src/Shared/EIDReader/lds/cvcaFile.d.ts.map +1 -0
  332. package/lib/typescript/src/Shared/EIDReader/lds/dataGroup.d.ts +8 -0
  333. package/lib/typescript/src/Shared/EIDReader/lds/dataGroup.d.ts.map +1 -0
  334. package/lib/typescript/src/Shared/EIDReader/lds/icao/comFile.d.ts +22 -0
  335. package/lib/typescript/src/Shared/EIDReader/lds/icao/comFile.d.ts.map +1 -0
  336. package/lib/typescript/src/Shared/EIDReader/lds/icao/dg1File.d.ts +13 -0
  337. package/lib/typescript/src/Shared/EIDReader/lds/icao/dg1File.d.ts.map +1 -0
  338. package/lib/typescript/src/Shared/EIDReader/lds/icao/dg2File.d.ts +14 -0
  339. package/lib/typescript/src/Shared/EIDReader/lds/icao/dg2File.d.ts.map +1 -0
  340. package/lib/typescript/src/Shared/EIDReader/lds/icao/icaoCountry.d.ts +80 -0
  341. package/lib/typescript/src/Shared/EIDReader/lds/icao/icaoCountry.d.ts.map +1 -0
  342. package/lib/typescript/src/Shared/EIDReader/lds/icao/mrzInfo.d.ts +579 -0
  343. package/lib/typescript/src/Shared/EIDReader/lds/icao/mrzInfo.d.ts.map +1 -0
  344. package/lib/typescript/src/Shared/EIDReader/lds/imageInfo.d.ts +52 -0
  345. package/lib/typescript/src/Shared/EIDReader/lds/imageInfo.d.ts.map +1 -0
  346. package/lib/typescript/src/Shared/EIDReader/lds/iso19794/faceImageInfo.d.ts +392 -0
  347. package/lib/typescript/src/Shared/EIDReader/lds/iso19794/faceImageInfo.d.ts.map +1 -0
  348. package/lib/typescript/src/Shared/EIDReader/lds/iso19794/faceInfo.d.ts +22 -0
  349. package/lib/typescript/src/Shared/EIDReader/lds/iso19794/faceInfo.d.ts.map +1 -0
  350. package/lib/typescript/src/Shared/EIDReader/lds/ldsElement.d.ts +9 -0
  351. package/lib/typescript/src/Shared/EIDReader/lds/ldsElement.d.ts.map +1 -0
  352. package/lib/typescript/src/Shared/EIDReader/lds/ldsFile.d.ts +10 -0
  353. package/lib/typescript/src/Shared/EIDReader/lds/ldsFile.d.ts.map +1 -0
  354. package/lib/typescript/src/Shared/EIDReader/nfcManagerCardService.d.ts +13 -0
  355. package/lib/typescript/src/Shared/EIDReader/nfcManagerCardService.d.ts.map +1 -0
  356. package/lib/typescript/src/Shared/EIDReader/protocol/bacAPDUSender.d.ts +9 -0
  357. package/lib/typescript/src/Shared/EIDReader/protocol/bacAPDUSender.d.ts.map +1 -0
  358. package/lib/typescript/src/Shared/EIDReader/protocol/bacProtocol.d.ts +17 -0
  359. package/lib/typescript/src/Shared/EIDReader/protocol/bacProtocol.d.ts.map +1 -0
  360. package/lib/typescript/src/Shared/EIDReader/protocol/bacResult.d.ts +26 -0
  361. package/lib/typescript/src/Shared/EIDReader/protocol/bacResult.d.ts.map +1 -0
  362. package/lib/typescript/src/Shared/EIDReader/protocol/readBinaryAPDUSender.d.ts +15 -0
  363. package/lib/typescript/src/Shared/EIDReader/protocol/readBinaryAPDUSender.d.ts.map +1 -0
  364. package/lib/typescript/src/Shared/EIDReader/protocol/secureMessagingAPDUSender.d.ts +19 -0
  365. package/lib/typescript/src/Shared/EIDReader/protocol/secureMessagingAPDUSender.d.ts.map +1 -0
  366. package/lib/typescript/src/Shared/EIDReader/secureMessagingWrapper.d.ts +30 -0
  367. package/lib/typescript/src/Shared/EIDReader/secureMessagingWrapper.d.ts.map +1 -0
  368. package/lib/typescript/src/Shared/EIDReader/smartcards/apduEvent.d.ts +15 -0
  369. package/lib/typescript/src/Shared/EIDReader/smartcards/apduEvent.d.ts.map +1 -0
  370. package/lib/typescript/src/Shared/EIDReader/smartcards/apduListener.d.ts +5 -0
  371. package/lib/typescript/src/Shared/EIDReader/smartcards/apduListener.d.ts.map +1 -0
  372. package/lib/typescript/src/Shared/EIDReader/smartcards/apduWrapper.d.ts +8 -0
  373. package/lib/typescript/src/Shared/EIDReader/smartcards/apduWrapper.d.ts.map +1 -0
  374. package/lib/typescript/src/Shared/EIDReader/smartcards/commandAPDU.d.ts +20 -0
  375. package/lib/typescript/src/Shared/EIDReader/smartcards/commandAPDU.d.ts.map +1 -0
  376. package/lib/typescript/src/Shared/EIDReader/smartcards/fileSystemStructured.d.ts +7 -0
  377. package/lib/typescript/src/Shared/EIDReader/smartcards/fileSystemStructured.d.ts.map +1 -0
  378. package/lib/typescript/src/Shared/EIDReader/smartcards/iso7816.d.ts +101 -0
  379. package/lib/typescript/src/Shared/EIDReader/smartcards/iso7816.d.ts.map +1 -0
  380. package/lib/typescript/src/Shared/EIDReader/smartcards/responseAPDU.d.ts +13 -0
  381. package/lib/typescript/src/Shared/EIDReader/smartcards/responseAPDU.d.ts.map +1 -0
  382. package/lib/typescript/src/Shared/EIDReader/tlv/asn1Constants.d.ts +36 -0
  383. package/lib/typescript/src/Shared/EIDReader/tlv/asn1Constants.d.ts.map +1 -0
  384. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +44 -0
  385. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -0
  386. package/lib/typescript/src/Shared/EIDReader/tlv/tlvInputState.d.ts +34 -0
  387. package/lib/typescript/src/Shared/EIDReader/tlv/tlvInputState.d.ts.map +1 -0
  388. package/lib/typescript/src/Shared/EIDReader/tlv/tlvInputStream.d.ts +23 -0
  389. package/lib/typescript/src/Shared/EIDReader/tlv/tlvInputStream.d.ts.map +1 -0
  390. package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputState.d.ts +24 -0
  391. package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputState.d.ts.map +1 -0
  392. package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts +16 -0
  393. package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts.map +1 -0
  394. package/lib/typescript/src/Shared/EIDReader/tripleDesSecureMessagingWrapper.d.ts +10 -0
  395. package/lib/typescript/src/Shared/EIDReader/tripleDesSecureMessagingWrapper.d.ts.map +1 -0
  396. package/lib/typescript/src/Shared/EIDReader/utils/crypto.utils.d.ts +16 -0
  397. package/lib/typescript/src/Shared/EIDReader/utils/crypto.utils.d.ts.map +1 -0
  398. package/lib/typescript/src/Shared/EIDReader/utils/random.d.ts +25 -0
  399. package/lib/typescript/src/Shared/EIDReader/utils/random.d.ts.map +1 -0
  400. package/lib/typescript/src/Shared/EIDReader/wrappedAPDUEvent.d.ts +11 -0
  401. package/lib/typescript/src/Shared/EIDReader/wrappedAPDUEvent.d.ts.map +1 -0
  402. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +5 -0
  403. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +1 -0
  404. package/lib/typescript/src/Shared/Libs/contains.d.ts +14 -0
  405. package/lib/typescript/src/Shared/Libs/contains.d.ts.map +1 -0
  406. package/lib/typescript/src/Shared/Libs/crypto.utils.d.ts +9 -0
  407. package/lib/typescript/src/Shared/Libs/crypto.utils.d.ts.map +1 -0
  408. package/lib/typescript/src/Shared/Libs/debounce.utils.d.ts +10 -0
  409. package/lib/typescript/src/Shared/Libs/debounce.utils.d.ts.map +1 -0
  410. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts +5 -0
  411. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -0
  412. package/lib/typescript/src/Shared/Libs/demo.utils.d.ts +5 -0
  413. package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -0
  414. package/lib/typescript/src/Shared/Libs/http-client.d.ts +27 -0
  415. package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -0
  416. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +9 -0
  417. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -0
  418. package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts +14 -0
  419. package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -0
  420. package/lib/typescript/src/Shared/Libs/native-keep-awake.utils.d.ts +31 -0
  421. package/lib/typescript/src/Shared/Libs/native-keep-awake.utils.d.ts.map +1 -0
  422. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +3 -0
  423. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +1 -0
  424. package/lib/typescript/src/Shared/Libs/promise.utils.d.ts +3 -0
  425. package/lib/typescript/src/Shared/Libs/promise.utils.d.ts.map +1 -0
  426. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +6 -0
  427. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -0
  428. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +57 -0
  429. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -0
  430. package/lib/typescript/src/Shared/Types/instruction.d.ts +5 -0
  431. package/lib/typescript/src/Shared/Types/instruction.d.ts.map +1 -0
  432. package/lib/typescript/src/Shared/Types/livenessIntructionType.d.ts +2 -0
  433. package/lib/typescript/src/Shared/Types/livenessIntructionType.d.ts.map +1 -0
  434. package/lib/typescript/src/Shared/Types/verificationSession.d.ts +16 -0
  435. package/lib/typescript/src/Shared/Types/verificationSession.d.ts.map +1 -0
  436. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts +13 -0
  437. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts.map +1 -0
  438. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +13 -0
  439. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +1 -0
  440. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +6 -0
  441. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +1 -0
  442. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +14 -0
  443. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +1 -0
  444. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +3 -0
  445. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +1 -0
  446. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +52 -0
  447. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +1 -0
  448. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +62 -0
  449. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +1 -0
  450. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +34 -0
  451. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +1 -0
  452. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +32 -0
  453. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +1 -0
  454. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +23 -0
  455. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +1 -0
  456. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +9 -0
  457. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +1 -0
  458. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +3 -0
  459. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +1 -0
  460. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +3 -0
  461. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +1 -0
  462. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +79 -0
  463. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +1 -0
  464. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +6 -0
  465. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +1 -0
  466. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +3 -0
  467. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +1 -0
  468. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +3 -0
  469. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +1 -0
  470. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +5 -0
  471. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +1 -0
  472. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +3 -0
  473. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +1 -0
  474. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +3 -0
  475. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +1 -0
  476. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +67 -0
  477. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +1 -0
  478. package/lib/typescript/src/Translation/Resources/en.d.ts +109 -0
  479. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -0
  480. package/lib/typescript/src/Translation/Resources/index.d.ts +3 -0
  481. package/lib/typescript/src/Translation/Resources/index.d.ts.map +1 -0
  482. package/lib/typescript/src/Translation/Resources/tr.d.ts +112 -0
  483. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -0
  484. package/lib/typescript/src/Translation/index.d.ts +3 -0
  485. package/lib/typescript/src/Translation/index.d.ts.map +1 -0
  486. package/lib/typescript/src/Trustchex.d.ts +18 -0
  487. package/lib/typescript/src/Trustchex.d.ts.map +1 -0
  488. package/lib/typescript/src/index.d.ts +4 -0
  489. package/lib/typescript/src/index.d.ts.map +1 -0
  490. package/package.json +288 -0
  491. package/src/NativeTrustchexSDK.ts +9 -0
  492. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +165 -0
  493. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +205 -0
  494. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +152 -0
  495. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +699 -0
  496. package/src/Screens/Static/QrCodeScanningScreen.tsx +37 -0
  497. package/src/Screens/Static/ResultScreen.tsx +877 -0
  498. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +524 -0
  499. package/src/Shared/Animations/face-scan.json +1 -0
  500. package/src/Shared/Animations/hole.json +76 -0
  501. package/src/Shared/Animations/hologram-scan.json +1 -0
  502. package/src/Shared/Animations/id-or-passport.json +1 -0
  503. package/src/Shared/Animations/light.json +1 -0
  504. package/src/Shared/Animations/loading.json +1 -0
  505. package/src/Shared/Animations/nfc-scan.json +1 -0
  506. package/src/Shared/Animations/nfc.json +1 -0
  507. package/src/Shared/Animations/scanning.json +1 -0
  508. package/src/Shared/Animations/success.json +1 -0
  509. package/src/Shared/Assets/trustchex-logo-black.png +0 -0
  510. package/src/Shared/Components/EIDScanner.tsx +472 -0
  511. package/src/Shared/Components/FaceCamera.tsx +267 -0
  512. package/src/Shared/Components/IdentityDocumentCamera.tsx +1377 -0
  513. package/src/Shared/Components/LanguageSelector.tsx +62 -0
  514. package/src/Shared/Components/NativeCircularProgress.tsx +76 -0
  515. package/src/Shared/Components/NativeProgressBar.tsx +74 -0
  516. package/src/Shared/Components/NavigationManager.tsx +275 -0
  517. package/src/Shared/Components/OTPCodeInput.tsx +93 -0
  518. package/src/Shared/Components/QrCodeScannerCamera.tsx +306 -0
  519. package/src/Shared/Contexts/AppContext.ts +47 -0
  520. package/src/Shared/EIDReader/abstractMRTDCardService.ts +195 -0
  521. package/src/Shared/EIDReader/accessKeySpec.ts +16 -0
  522. package/src/Shared/EIDReader/apduLevelBACCapable.ts +10 -0
  523. package/src/Shared/EIDReader/apduLevelReadBinaryCapable.ts +15 -0
  524. package/src/Shared/EIDReader/bacKey.ts +132 -0
  525. package/src/Shared/EIDReader/bacKeySpec.ts +26 -0
  526. package/src/Shared/EIDReader/cardFileInputStream.ts +188 -0
  527. package/src/Shared/EIDReader/cardService.ts +51 -0
  528. package/src/Shared/EIDReader/cbeff/biometricDataBlock.ts +5 -0
  529. package/src/Shared/EIDReader/cbeff/biometricDataBlockDecoder.ts +12 -0
  530. package/src/Shared/EIDReader/cbeff/biometricDataBlockEncoder.ts +6 -0
  531. package/src/Shared/EIDReader/cbeff/cbeffInfo.ts +100 -0
  532. package/src/Shared/EIDReader/cbeff/complexCBEFFInfo.ts +48 -0
  533. package/src/Shared/EIDReader/cbeff/faceDataBlockDecoder.ts +17 -0
  534. package/src/Shared/EIDReader/cbeff/iso781611.ts +79 -0
  535. package/src/Shared/EIDReader/cbeff/iso781611Decoder.ts +242 -0
  536. package/src/Shared/EIDReader/cbeff/iso781611Encoder.ts +91 -0
  537. package/src/Shared/EIDReader/cbeff/simpleCBEFFInfo.ts +26 -0
  538. package/src/Shared/EIDReader/cbeff/standardBiometricHeader.ts +116 -0
  539. package/src/Shared/EIDReader/cert/cvcPrincipal.ts +63 -0
  540. package/src/Shared/EIDReader/data/country.ts +76 -0
  541. package/src/Shared/EIDReader/data/gender.ts +36 -0
  542. package/src/Shared/EIDReader/data/isoCountry.ts +1251 -0
  543. package/src/Shared/EIDReader/data/unicodeCountry.ts +1516 -0
  544. package/src/Shared/EIDReader/defaultFileInfo.ts +41 -0
  545. package/src/Shared/EIDReader/defaultFileSystem.ts +287 -0
  546. package/src/Shared/EIDReader/eidReader.ts +113 -0
  547. package/src/Shared/EIDReader/eidService.ts +349 -0
  548. package/src/Shared/EIDReader/fileInfo.ts +5 -0
  549. package/src/Shared/EIDReader/fileSystemCardService.ts +32 -0
  550. package/src/Shared/EIDReader/fragment.ts +21 -0
  551. package/src/Shared/EIDReader/fragmentBuffer.ts +191 -0
  552. package/src/Shared/EIDReader/java/byteArrayInputStream.ts +103 -0
  553. package/src/Shared/EIDReader/java/byteArrayOutputStream.ts +67 -0
  554. package/src/Shared/EIDReader/java/dataInput.ts +16 -0
  555. package/src/Shared/EIDReader/java/dataInputStream.ts +203 -0
  556. package/src/Shared/EIDReader/java/dataOutputStream.ts +107 -0
  557. package/src/Shared/EIDReader/java/filterInputStream.ts +138 -0
  558. package/src/Shared/EIDReader/java/filterOutputStream.ts +126 -0
  559. package/src/Shared/EIDReader/java/inputStream.ts +186 -0
  560. package/src/Shared/EIDReader/java/inputStreamBuffer.ts +200 -0
  561. package/src/Shared/EIDReader/java/objectInputStream.ts +45 -0
  562. package/src/Shared/EIDReader/java/outputStream.ts +76 -0
  563. package/src/Shared/EIDReader/java/positionInputStream.ts +64 -0
  564. package/src/Shared/EIDReader/java/splittableInputStream.ts +69 -0
  565. package/src/Shared/EIDReader/lds/abstractImageInfo.ts +191 -0
  566. package/src/Shared/EIDReader/lds/abstractLDSFile.ts +106 -0
  567. package/src/Shared/EIDReader/lds/abstractLDSInfo.ts +31 -0
  568. package/src/Shared/EIDReader/lds/abstractListInfo.ts +72 -0
  569. package/src/Shared/EIDReader/lds/abstractTaggedLDSFile.ts +85 -0
  570. package/src/Shared/EIDReader/lds/cbeffDataGroup.ts +128 -0
  571. package/src/Shared/EIDReader/lds/cvcaFile.ts +112 -0
  572. package/src/Shared/EIDReader/lds/dataGroup.ts +11 -0
  573. package/src/Shared/EIDReader/lds/icao/comFile.ts +166 -0
  574. package/src/Shared/EIDReader/lds/icao/dg1File.ts +45 -0
  575. package/src/Shared/EIDReader/lds/icao/dg2File.ts +54 -0
  576. package/src/Shared/EIDReader/lds/icao/icaoCountry.ts +253 -0
  577. package/src/Shared/EIDReader/lds/icao/mrzInfo.ts +1669 -0
  578. package/src/Shared/EIDReader/lds/imageInfo.ts +58 -0
  579. package/src/Shared/EIDReader/lds/iso19794/faceImageInfo.ts +948 -0
  580. package/src/Shared/EIDReader/lds/iso19794/faceInfo.ts +198 -0
  581. package/src/Shared/EIDReader/lds/ldsElement.ts +8 -0
  582. package/src/Shared/EIDReader/lds/ldsFile.ts +14 -0
  583. package/src/Shared/EIDReader/nfcManagerCardService.ts +58 -0
  584. package/src/Shared/EIDReader/protocol/bacAPDUSender.ts +146 -0
  585. package/src/Shared/EIDReader/protocol/bacProtocol.ts +121 -0
  586. package/src/Shared/EIDReader/protocol/bacResult.ts +36 -0
  587. package/src/Shared/EIDReader/protocol/readBinaryAPDUSender.ts +251 -0
  588. package/src/Shared/EIDReader/protocol/secureMessagingAPDUSender.ts +170 -0
  589. package/src/Shared/EIDReader/secureMessagingWrapper.ts +361 -0
  590. package/src/Shared/EIDReader/smartcards/apduEvent.ts +38 -0
  591. package/src/Shared/EIDReader/smartcards/apduListener.ts +5 -0
  592. package/src/Shared/EIDReader/smartcards/apduWrapper.ts +10 -0
  593. package/src/Shared/EIDReader/smartcards/commandAPDU.ts +172 -0
  594. package/src/Shared/EIDReader/smartcards/fileSystemStructured.ts +7 -0
  595. package/src/Shared/EIDReader/smartcards/iso7816.ts +104 -0
  596. package/src/Shared/EIDReader/smartcards/responseAPDU.ts +44 -0
  597. package/src/Shared/EIDReader/tlv/asn1Constants.ts +46 -0
  598. package/src/Shared/EIDReader/tlv/tlv.utils.ts +201 -0
  599. package/src/Shared/EIDReader/tlv/tlvInputState.ts +186 -0
  600. package/src/Shared/EIDReader/tlv/tlvInputStream.ts +207 -0
  601. package/src/Shared/EIDReader/tlv/tlvOutputState.ts +244 -0
  602. package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +112 -0
  603. package/src/Shared/EIDReader/tripleDesSecureMessagingWrapper.ts +48 -0
  604. package/src/Shared/EIDReader/utils/crypto.utils.ts +273 -0
  605. package/src/Shared/EIDReader/utils/random.ts +198 -0
  606. package/src/Shared/EIDReader/wrappedAPDUEvent.ts +36 -0
  607. package/src/Shared/Libs/camera.utils.ts +34 -0
  608. package/src/Shared/Libs/contains.ts +59 -0
  609. package/src/Shared/Libs/crypto.utils.ts +47 -0
  610. package/src/Shared/Libs/debounce.utils.ts +38 -0
  611. package/src/Shared/Libs/deeplink.utils.ts +19 -0
  612. package/src/Shared/Libs/demo.utils.ts +82 -0
  613. package/src/Shared/Libs/http-client.ts +148 -0
  614. package/src/Shared/Libs/mrz.utils.ts +110 -0
  615. package/src/Shared/Libs/native-device-info.utils.ts +50 -0
  616. package/src/Shared/Libs/native-keep-awake.utils.ts +104 -0
  617. package/src/Shared/Libs/opencv.utils.ts +40 -0
  618. package/src/Shared/Libs/promise.utils.ts +20 -0
  619. package/src/Shared/Libs/tts.utils.ts +40 -0
  620. package/src/Shared/Types/identificationInfo.ts +62 -0
  621. package/src/Shared/Types/instruction.ts +4 -0
  622. package/src/Shared/Types/livenessIntructionType.ts +8 -0
  623. package/src/Shared/Types/verificationSession.ts +17 -0
  624. package/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.tsx +85 -0
  625. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +79 -0
  626. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +45 -0
  627. package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +64 -0
  628. package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +30 -0
  629. package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +82 -0
  630. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +195 -0
  631. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +135 -0
  632. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +84 -0
  633. package/src/Shared/VisionCameraPlugins/Cropper/index.ts +78 -0
  634. package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +63 -0
  635. package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +44 -0
  636. package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +3 -0
  637. package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +99 -0
  638. package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +76 -0
  639. package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +18 -0
  640. package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +7 -0
  641. package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +7 -0
  642. package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +27 -0
  643. package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +21 -0
  644. package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +141 -0
  645. package/src/Translation/Resources/en.ts +151 -0
  646. package/src/Translation/Resources/index.ts +2 -0
  647. package/src/Translation/Resources/tr.ts +152 -0
  648. package/src/Translation/index.ts +37 -0
  649. package/src/Trustchex.tsx +171 -0
  650. package/src/index.tsx +5 -0
@@ -0,0 +1,1418 @@
1
+ "use strict";
2
+
3
+ import { Gender } from "../../data/gender.js";
4
+ import { ByteArrayInputStream } from "../../java/byteArrayInputStream.js";
5
+ import { DataInputStream } from "../../java/dataInputStream.js";
6
+ import { DataOutputStream } from "../../java/dataOutputStream.js";
7
+ import { AbstractLDSInfo } from "../abstractLDSInfo.js";
8
+ import { Buffer } from 'buffer';
9
+
10
+ /**
11
+ * The type of document (MRZ), determining the number of lines,
12
+ * number of characters per line, and positions and lengths of fields,
13
+ * and check-digits.
14
+ */
15
+ export class DocumentType {
16
+ /** Unspecified document type (do not use, choose ID1 or ID3). */
17
+ static UNKNOWN = new DocumentType(0, 'UNKNOWN');
18
+
19
+ /** MROTD 3 lines of 30 characters, as per part 5. */
20
+ static TD1 = new DocumentType(1, 'TD1');
21
+
22
+ /** MROTD 2 lines of 36 characters, as per part 6. */
23
+ static TD2 = new DocumentType(2, 'TD2');
24
+
25
+ /** MRP 2 lines of 44 characters, as per part 4. */
26
+ static TD3 = new DocumentType(3, 'TD3');
27
+
28
+ /** MRV type A. */
29
+ static MRVA = new DocumentType(4, 'MRVA');
30
+
31
+ /** MRV type B. */
32
+ static MRVB = new DocumentType(5, 'MRVB');
33
+
34
+ /** The code representing the document type. */
35
+
36
+ /** The string representation of the document type. */
37
+
38
+ /**
39
+ * Creates a new DocumentType instance.
40
+ *
41
+ * @param code The code representing the document type.
42
+ * @param strCode The string representation of the document type.
43
+ */
44
+ constructor(code, strCode) {
45
+ this.code = code;
46
+ this.strCode = strCode;
47
+ }
48
+
49
+ /**
50
+ * Returns the code representing the document type.
51
+ *
52
+ * @return the code representing the document type
53
+ */
54
+ getCode() {
55
+ return this.code;
56
+ }
57
+
58
+ /**
59
+ * Returns the string representation of the document type.
60
+ *
61
+ * @return the string representation of the document type
62
+ */
63
+ getStrCode() {
64
+ return this.strCode;
65
+ }
66
+ }
67
+ export class MRZInfo extends AbstractLDSInfo {
68
+ /** All valid characters in MRZ. */
69
+ static MRZ_CHARS = '<0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
70
+
71
+ /* NOTE: Over optionalData1, but only for TD3. When empty we prefer '<' over '0'. */
72
+
73
+ /* NOTE: For TD1 holds personal number for some issuing states (e.g. NL), but is used to hold (part of) document number for others. */
74
+
75
+ /**
76
+ * Creates a new MRZ based on an input stream.
77
+ *
78
+ * @param inputStream contains the contents (value) of DG1 (without the tag and length)
79
+ * @param length the length of the MRZInfo structure
80
+ */
81
+ static async fromStream(inputStream, length) {
82
+ const mrzInfo = new MRZInfo();
83
+ try {
84
+ await mrzInfo.readObject(inputStream, length);
85
+ } catch (error) {
86
+ throw new Error(`Error reading MRZ: ${error}`);
87
+ }
88
+ return mrzInfo;
89
+ }
90
+
91
+ /**
92
+ * Creates a new MRZ based on the text input.
93
+ * The text input may contain newlines, which will be ignored.
94
+ *
95
+ * @param str input text
96
+ */
97
+ static async fromString(str) {
98
+ const mrzInfo = new MRZInfo();
99
+ if (str == null) {
100
+ throw new Error('Null string');
101
+ }
102
+ str = str.trim().replace('\n', '');
103
+ try {
104
+ await mrzInfo.readObject(new ByteArrayInputStream(Buffer.from(str, 'utf-8')), str.length);
105
+ } catch (error) {
106
+ throw new Error(`Error reading MRZ: ${error}`);
107
+ }
108
+ return mrzInfo;
109
+ }
110
+
111
+ /**
112
+ * Returns the date of birth of the passport holder.
113
+ *
114
+ * @return date of birth
115
+ */
116
+ getDateOfBirth() {
117
+ return this.dateOfBirth;
118
+ }
119
+
120
+ /**
121
+ * Returns the date of expiry.
122
+ *
123
+ * @return the date of expiry
124
+ */
125
+ getDateOfExpiry() {
126
+ return this.dateOfExpiry;
127
+ }
128
+
129
+ /**
130
+ * Returns the document number.
131
+ *
132
+ * @return document number
133
+ */
134
+ getDocumentNumber() {
135
+ return this.documentNumber;
136
+ }
137
+
138
+ /**
139
+ * Returns the document type.
140
+ *
141
+ * @return document type
142
+ *
143
+ * @deprecated Clients should determine type based on {@link #getDocumentCode()}
144
+ */
145
+ getDocumentType() {
146
+ return this.documentType;
147
+ }
148
+
149
+ /**
150
+ * Returns the document code.
151
+ *
152
+ * @return document type
153
+ */
154
+ getDocumentCode() {
155
+ return this.documentCode;
156
+ }
157
+
158
+ /**
159
+ * Returns the issuing state as a 3 letter code.
160
+ *
161
+ * @return the issuing state
162
+ */
163
+ getIssuingState() {
164
+ return MRZInfo.mrzFormat(this.issuingState, 3);
165
+ }
166
+
167
+ /**
168
+ * Returns the passport holder's last name.
169
+ *
170
+ * @return name
171
+ */
172
+ getPrimaryIdentifier() {
173
+ return this.primaryIdentifier;
174
+ }
175
+
176
+ /**
177
+ * Returns the document holder's first names.
178
+ *
179
+ * @return the secondary identifier
180
+ */
181
+ getSecondaryIdentifier() {
182
+ return this.secondaryIdentifier;
183
+ }
184
+
185
+ /**
186
+ * Returns the document holder's first names.
187
+ *
188
+ * @return first names
189
+ */
190
+ getSecondaryIdentifierComponents() {
191
+ return this.secondaryIdentifier.split(' |<');
192
+ }
193
+
194
+ /**
195
+ * Returns the passport holder's nationality as a 3 digit code.
196
+ *
197
+ * @return a country
198
+ */
199
+ getNationality() {
200
+ return MRZInfo.mrzFormat(this.nationality, 3);
201
+ }
202
+
203
+ /**
204
+ * Returns the personal number (if a personal number is encoded in optional data 1).
205
+ *
206
+ * @return personal number
207
+ */
208
+ getPersonalNumber() {
209
+ if (this.optionalData1 == null) {
210
+ return null;
211
+ }
212
+ if (this.optionalData1.length > 14) {
213
+ return MRZInfo.trimTrailingFillerChars(this.optionalData1.substring(0, 14));
214
+ } else {
215
+ return MRZInfo.trimTrailingFillerChars(this.optionalData1);
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Returns the passport holder's gender.
221
+ *
222
+ * @return gender
223
+ */
224
+ getGender() {
225
+ return this.gender;
226
+ }
227
+
228
+ /**
229
+ * Returns the contents of the first optional data field for ID-1 and ID-3 style MRZs.
230
+ *
231
+ * @return optional data 1
232
+ */
233
+ getOptionalData1() {
234
+ return this.optionalData1;
235
+ }
236
+
237
+ /**
238
+ * Returns the contents of the second optional data field for ID-1 style MRZs.
239
+ *
240
+ * @return optional data 2
241
+ */
242
+ getOptionalData2() {
243
+ return this.optionalData2;
244
+ }
245
+
246
+ /**
247
+ * Sets the document code.
248
+ *
249
+ * @param documentCode the new document code
250
+ *
251
+ * @deprecated Class will become immutable
252
+ */
253
+ setDocumentCode(documentCode) {
254
+ this.documentCode = documentCode;
255
+ this.documentType = MRZInfo.getDocumentTypeFromDocumentCode(documentCode);
256
+ if (this.documentType === DocumentType.TD1 && this.optionalData2 === null) {
257
+ this.optionalData2 = '';
258
+ }
259
+ /* FIXME: need to adjust some other lengths if we go from ID1 to ID3 or back... */
260
+ }
261
+
262
+ /**
263
+ * Sets the document number.
264
+ *
265
+ * @param documentNumber new document number
266
+ *
267
+ * @deprecated Class will become immutable
268
+ */
269
+ setDocumentNumber(documentNumber) {
270
+ this.documentNumber = documentNumber.trim();
271
+ this.checkDigit();
272
+ }
273
+
274
+ /**
275
+ * Sets the passport holder's last name.
276
+ *
277
+ * @param primaryIdentifier new primary identifier
278
+ *
279
+ * @deprecated Class will become immutable
280
+ */
281
+ setPrimaryIdentifier(primaryIdentifier) {
282
+ this.primaryIdentifier = MRZInfo.trimTrailingFillerChars(primaryIdentifier).replace('<', ' ');
283
+ this.checkDigit();
284
+ }
285
+
286
+ /**
287
+ * Sets the passport holder's first names.
288
+ *
289
+ * @param secondaryIdentifiers new secondary identifiers
290
+ *
291
+ * @deprecated Class will become immutable
292
+ */
293
+ setSecondaryIdentifierComponents(secondaryIdentifiers) {
294
+ if (secondaryIdentifiers == null) {
295
+ this.secondaryIdentifier = '';
296
+ } else {
297
+ let stringBuilder = '';
298
+ for (let i = 0; i < secondaryIdentifiers.length; i++) {
299
+ stringBuilder += secondaryIdentifiers[i];
300
+ if (i < secondaryIdentifiers.length - 1) {
301
+ stringBuilder += '<';
302
+ }
303
+ }
304
+ this.secondaryIdentifier = stringBuilder;
305
+ }
306
+ this.checkDigit();
307
+ }
308
+
309
+ /**
310
+ * Sets the passport holder's first names.
311
+ *
312
+ * @param secondaryIdentifiers new secondary identifiers
313
+ *
314
+ * @deprecated Class will become immutable
315
+ */
316
+ setSecondaryIdentifiers(secondaryIdentifiers) {
317
+ this.readSecondaryIdentifiers(secondaryIdentifiers.trim());
318
+ this.checkDigit();
319
+ }
320
+
321
+ /**
322
+ * Sets the date of birth.
323
+ *
324
+ * @param dateOfBirth new date of birth
325
+ *
326
+ * @deprecated Class will become immutable
327
+ */
328
+ setDateOfBirth(dateOfBirth) {
329
+ this.dateOfBirth = dateOfBirth;
330
+ this.checkDigit();
331
+ }
332
+
333
+ /**
334
+ * Sets the date of expiry.
335
+ *
336
+ * @param dateOfExpiry new date of expiry
337
+ *
338
+ * @deprecated Class will become immutable
339
+ */
340
+ setDateOfExpiry(dateOfExpiry) {
341
+ this.dateOfExpiry = dateOfExpiry;
342
+ this.checkDigit();
343
+ }
344
+
345
+ /**
346
+ * Sets the issuing state.
347
+ *
348
+ * @param issuingState new issuing state
349
+ *
350
+ * @deprecated Class will become immutable
351
+ */
352
+ setIssuingState(issuingState) {
353
+ this.issuingState = issuingState;
354
+ this.checkDigit();
355
+ }
356
+
357
+ /**
358
+ * Sets the personal number. Replacing any optional data 1.
359
+ *
360
+ * @param personalNumber new personal number
361
+ *
362
+ * @deprecated Class will become immutable
363
+ */
364
+ setPersonalNumber(personalNumber) {
365
+ if (personalNumber == null || personalNumber.length > 14) {
366
+ throw new Error('Wrong personal number');
367
+ }
368
+ this.optionalData1 = MRZInfo.mrzFormat(personalNumber, 14);
369
+ this.personalNumberCheckDigit = MRZInfo.checkDigit(this.optionalData1);
370
+ }
371
+
372
+ /**
373
+ * Sets the passport holder's nationality.
374
+ *
375
+ * @param nationality new nationality
376
+ *
377
+ * @deprecated Class will become immutable
378
+ */
379
+ setNationality(nationality) {
380
+ this.nationality = nationality;
381
+ this.checkDigit();
382
+ }
383
+
384
+ /**
385
+ * Sets the contents for the second optional data field for ID-1 style MRZs.
386
+ *
387
+ * @param optionalData2 optional data 2
388
+ *
389
+ * @deprecated Class will become immutable
390
+ */
391
+ setOptionalData2(optionalData2) {
392
+ this.optionalData2 = MRZInfo.trimTrailingFillerChars(optionalData2);
393
+ this.checkDigit();
394
+ }
395
+
396
+ /**
397
+ * Sets the gender.
398
+ *
399
+ * @param gender new gender
400
+ *
401
+ * @deprecated Class will become immutable
402
+ */
403
+ setGender(gender) {
404
+ if (gender == null) {
405
+ throw new Error('Gender must not be null');
406
+ }
407
+ this.gender = gender;
408
+ this.checkDigit();
409
+ }
410
+
411
+ /* ONLY PRIVATE METHODS BELOW */
412
+
413
+ /**
414
+ * Reads the object value from a stream.
415
+ *
416
+ * @param inputStream the stream to read from
417
+ * @param length the length of the value
418
+ *
419
+ * @throws IOException on error reading from the stream
420
+ */
421
+ async readObject(inputStream, length) {
422
+ const dataIn = inputStream instanceof DataInputStream ? inputStream : new DataInputStream(inputStream);
423
+
424
+ /* line 1, pos 1 to 2, Document code, all types. */
425
+ this.documentCode = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 2));
426
+ this.documentType = MRZInfo.getDocumentType(this.documentCode, length);
427
+ switch (this.documentType) {
428
+ case DocumentType.TD1:
429
+ await this.readObjectTD1(dataIn);
430
+ break;
431
+ case DocumentType.TD2:
432
+ /* Fall through... */
433
+ case DocumentType.MRVB:
434
+ await this.readObjectTD2orMRVB(dataIn);
435
+ break;
436
+ case DocumentType.MRVA:
437
+ /* Fall through... */
438
+ case DocumentType.TD3:
439
+ /* Fall through... */
440
+ default:
441
+ /* Assume it's a ID3 document, i.e. 2-line MRZ. */
442
+ await this.readObjectTD3OrMRVA(dataIn);
443
+ break;
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Reads the object value from a stream after document-code has already
449
+ * been read, and it is determined that we are dealing with a TD1 style MRZ.
450
+ *
451
+ * @param inputStream the stream to read from
452
+ *
453
+ * @throws IOException on error reading from the stream
454
+ */
455
+ async readObjectTD1(inputStream) {
456
+ const dataIn = inputStream instanceof DataInputStream ? inputStream : new DataInputStream(inputStream);
457
+
458
+ /* line 1, pos 3 to 5 Issuing State or organization */
459
+ this.issuingState = await MRZInfo.readCountryCode(dataIn);
460
+
461
+ /* line 1, pos 6 to 14 Document number */
462
+ this.documentNumber = await MRZInfo.readString(dataIn, 9);
463
+
464
+ /* line 1, pos 15 Check digit */
465
+ this.documentNumberCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
466
+
467
+ /* line 1, pos 16 to 30, Optional data elements */
468
+ const rawOptionalData1 = await MRZInfo.readString(dataIn, 15);
469
+ this.optionalData1 = MRZInfo.trimTrailingFillerChars(rawOptionalData1);
470
+ if (this.documentNumberCheckDigit === '<' && this.optionalData1 !== '') {
471
+ /* Interpret personal number as part of document number, see note j. */
472
+ let extendedDocumentNumberEnd = this.optionalData1.indexOf('<');
473
+ if (extendedDocumentNumberEnd < 0) {
474
+ extendedDocumentNumberEnd = this.optionalData1.length;
475
+ }
476
+ const documentNumberRemainder = this.optionalData1.substring(0, extendedDocumentNumberEnd - 1);
477
+ this.documentNumber += documentNumberRemainder;
478
+ this.documentNumberCheckDigit = this.optionalData1.charAt(extendedDocumentNumberEnd - 1);
479
+ this.optionalData1 = this.optionalData1.substring(Math.min(extendedDocumentNumberEnd + 1, this.optionalData1.length));
480
+ }
481
+ this.documentNumber = MRZInfo.trimTrailingFillerChars(this.documentNumber);
482
+
483
+ /* line 2, pos 1 to 6, Date of birth */
484
+ this.dateOfBirth = await this.readDate(dataIn);
485
+
486
+ /* line 2, pos 7, Check digit */
487
+ this.dateOfBirthCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
488
+
489
+ /* line 2, pos 8, Sex */
490
+ this.gender = await this.readGender(dataIn);
491
+
492
+ /* line 2, Pos 9 to 14, Date of expiry */
493
+ this.dateOfExpiry = await this.readDate(dataIn);
494
+
495
+ /* line 2, pos 15, Check digit */
496
+ this.dateOfExpiryCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
497
+
498
+ /* line 2, pos 16 to 18, Nationality */
499
+ this.nationality = await MRZInfo.readCountryCode(dataIn);
500
+
501
+ /* line 2, pos 19 to 29, Optional data elements */
502
+ this.optionalData2 = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 11));
503
+
504
+ /* line 2, pos 30, Overall check digit */
505
+ this.compositeCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
506
+
507
+ /* line 3 */
508
+ this.readNameIdentifiers(await MRZInfo.readString(dataIn, 30));
509
+ }
510
+
511
+ /**
512
+ * Reads the object value from a stream after document-code has already
513
+ * been read, and it is determined that we are dealing with a TD2 or MRV-B style MRZ.
514
+ *
515
+ * @param inputStream the stream to read from
516
+ *
517
+ * @throws IOException on error reading from the stream
518
+ */
519
+ async readObjectTD2orMRVB(inputStream) {
520
+ const dataIn = inputStream instanceof DataInputStream ? inputStream : new DataInputStream(inputStream);
521
+
522
+ /* line 1, pos 3 to 5 */
523
+ this.issuingState = await MRZInfo.readCountryCode(dataIn);
524
+
525
+ /* line 1, pos 6 to 36 */
526
+ this.readNameIdentifiers(await MRZInfo.readString(dataIn, 31));
527
+
528
+ /* line 2 */
529
+ this.documentNumber = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 9));
530
+ this.documentNumberCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
531
+ this.nationality = await MRZInfo.readCountryCode(dataIn);
532
+ this.dateOfBirth = await this.readDate(dataIn);
533
+ this.dateOfBirthCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
534
+ this.gender = await this.readGender(dataIn);
535
+ this.dateOfExpiry = await this.readDate(dataIn);
536
+ this.dateOfExpiryCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
537
+ if (this.documentType === DocumentType.MRVB) {
538
+ this.optionalData1 = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 8));
539
+ } else if (this.documentType === DocumentType.TD2) {
540
+ this.optionalData1 = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 7));
541
+ if (this.documentNumberCheckDigit === '<' && this.optionalData1.length > 0) {
542
+ /* Interpret optional data as part of document number, see note j. */
543
+ this.documentNumber += this.optionalData1.substring(0, this.optionalData1.length - 1);
544
+ this.documentNumberCheckDigit = this.optionalData1.charAt(this.optionalData1.length - 1);
545
+ this.optionalData1 = '';
546
+ }
547
+ }
548
+ this.documentNumber = MRZInfo.trimTrailingFillerChars(this.documentNumber);
549
+ if (this.documentType === DocumentType.TD2) {
550
+ this.compositeCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
551
+ }
552
+ }
553
+
554
+ /**
555
+ * Reads the object value from a stream after document-code has already
556
+ * been read, and it is determined that we are dealing with a TD3 or MRV-A style MRZ.
557
+ *
558
+ * @param inputStream the stream to read from
559
+ *
560
+ * @throws IOException on error reading from the stream
561
+ */
562
+ async readObjectTD3OrMRVA(inputStream) {
563
+ const dataIn = inputStream instanceof DataInputStream ? inputStream : new DataInputStream(inputStream);
564
+
565
+ /* line 1, pos 3 to 5 */
566
+ this.issuingState = await MRZInfo.readCountryCode(dataIn);
567
+
568
+ /* line 1, pos 6 to 44 */
569
+ this.readNameIdentifiers(await MRZInfo.readString(dataIn, 39));
570
+
571
+ /* line 2 */
572
+ this.documentNumber = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 9));
573
+ this.documentNumberCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
574
+ this.nationality = await MRZInfo.readCountryCode(dataIn);
575
+ this.dateOfBirth = await this.readDate(dataIn);
576
+ this.dateOfBirthCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
577
+ this.gender = await this.readGender(dataIn);
578
+ this.dateOfExpiry = await this.readDate(dataIn);
579
+ this.dateOfExpiryCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
580
+ if (this.documentType === DocumentType.MRVA) {
581
+ this.optionalData1 = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 16));
582
+ } else {
583
+ this.optionalData1 = MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(dataIn, 14));
584
+ this.personalNumberCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
585
+ this.compositeCheckDigit = String.fromCharCode(await dataIn.readUnsignedByte());
586
+ }
587
+ }
588
+
589
+ /**
590
+ * Writes the MRZ to an output stream.
591
+ * This just outputs the MRZ characters, and does not add newlines.
592
+ *
593
+ * @param outputStream the output stream to write to
594
+ */
595
+ writeObject(outputStream) {
596
+ switch (this.documentType) {
597
+ case DocumentType.TD1:
598
+ this.writeObjectTD1(outputStream);
599
+ break;
600
+ case DocumentType.TD2:
601
+ /* Fall through. */
602
+ case DocumentType.MRVB:
603
+ this.writeObjectTD2OrMRVB(outputStream);
604
+ break;
605
+ case DocumentType.TD3:
606
+ /* Fall through. */
607
+ case DocumentType.MRVA:
608
+ this.writeObjectTD3OrMRVA(outputStream);
609
+ break;
610
+ default:
611
+ throw new Error('Unsupported document type');
612
+ }
613
+ }
614
+
615
+ /**
616
+ * Tests equality of two MRZ string while ignoring extra filler characters.
617
+ *
618
+ * @param str1 an MRZ string
619
+ * @param str2 another MRZ string
620
+ *
621
+ * @return a boolean indicating whether the strings are equal modulo filler characters
622
+ */
623
+ static equalsModuloFillerChars(str1, str2) {
624
+ if (str1 === str2) {
625
+ return true;
626
+ }
627
+ if (str1 === null) {
628
+ str1 = '';
629
+ }
630
+ if (str2 === null) {
631
+ str2 = '';
632
+ }
633
+ const length = Math.max(str1.length, str2.length);
634
+ return MRZInfo.mrzFormat(str1, length) === MRZInfo.mrzFormat(str2, length);
635
+ }
636
+
637
+ /**
638
+ * Writes this MRZ to stream.
639
+ *
640
+ * @param outputStream the stream to write to
641
+ *
642
+ * @throws IOException on error writing to the stream
643
+ */
644
+ writeObjectTD1(outputStream) {
645
+ const dataOut = outputStream instanceof DataOutputStream ? outputStream : new DataOutputStream(outputStream);
646
+
647
+ /* top line */
648
+ this.writeDocumentType(dataOut);
649
+ MRZInfo.writeCountryCode(this.issuingState, dataOut);
650
+ const isExtendedDocumentNumber = this.documentNumber.length > 9;
651
+ if (isExtendedDocumentNumber) {
652
+ /*
653
+ * If document number has more than 9 character, the 9 principal
654
+ * character shall be shown in the MRZ in character positions 1 to 9.
655
+ * They shall be followed by a filler character instead of a check
656
+ * digit to indicate a truncated number. The remaining character of
657
+ * the document number shall be shown at the beginning of the field
658
+ * reserved of optional data element (character position 29 to 35 of
659
+ * the lower machine readable line) followed by a check digit and a
660
+ * filler character.
661
+ *
662
+ * Corresponds to Doc 9303 (pre-seventh edition) pt 3 vol 1 page V-10 (note j) (FIXED by Paulo Assumcao)
663
+ *
664
+ * Also see R3-p1_v2_sIV_0041 in Supplement to Doc 9303, release 11.
665
+ */
666
+ this.writeString(this.documentNumber.substring(0, 9), dataOut, 9);
667
+ dataOut.writeUTF('<'); /* NOTE: instead of check digit */
668
+ this.writeString(this.documentNumber.substring(9) + this.documentNumberCheckDigit + '<' + this.optionalData1, dataOut, 15);
669
+ } else {
670
+ this.writeString(this.documentNumber, dataOut, 9); /* FIXME: max size of field */
671
+ dataOut.writeUTF(this.documentNumberCheckDigit);
672
+ this.writeString(this.optionalData1, dataOut, 15); /* FIXME: max size of field */
673
+ }
674
+
675
+ /* middle line */
676
+ this.writeDateOfBirth(dataOut);
677
+ dataOut.writeUTF(this.dateOfBirthCheckDigit);
678
+ this.writeGender(dataOut);
679
+ this.writeDateOfExpiry(dataOut);
680
+ dataOut.writeUTF(this.dateOfExpiryCheckDigit);
681
+ MRZInfo.writeCountryCode(this.nationality, dataOut);
682
+ this.writeString(this.optionalData2, dataOut, 11);
683
+ dataOut.writeUTF(this.compositeCheckDigit);
684
+
685
+ /* bottom line */
686
+ this.writeName(dataOut, 30);
687
+ }
688
+
689
+ /**
690
+ * Writes this MRZ to stream.
691
+ *
692
+ * @param outputStream the stream to write to
693
+ *
694
+ * @throws IOException on error writing to the stream
695
+ */
696
+ writeObjectTD2OrMRVB(outputStream) {
697
+ const dataOut = outputStream instanceof DataOutputStream ? outputStream : new DataOutputStream(outputStream);
698
+
699
+ /* top line */
700
+ this.writeDocumentType(dataOut);
701
+ MRZInfo.writeCountryCode(this.issuingState, dataOut);
702
+ this.writeName(dataOut, 31);
703
+
704
+ /* bottom line */
705
+
706
+ const isExtendedDocumentNumber = this.documentType === DocumentType.TD2 && this.documentNumber.length > 9 && MRZInfo.equalsModuloFillerChars(this.optionalData1, '');
707
+ if (isExtendedDocumentNumber) {
708
+ this.writeString(this.documentNumber.substring(0, 9), dataOut, 9);
709
+ dataOut.writeUTF('<'); /* NOTE: instead of check digit */
710
+ } else {
711
+ this.writeString(this.documentNumber, dataOut, 9); /* FIXME: max size of field */
712
+ dataOut.writeUTF(this.documentNumberCheckDigit);
713
+ }
714
+ MRZInfo.writeCountryCode(this.nationality, dataOut);
715
+ this.writeDateOfBirth(dataOut);
716
+ dataOut.writeUTF(this.dateOfBirthCheckDigit);
717
+ this.writeGender(dataOut);
718
+ this.writeDateOfExpiry(dataOut);
719
+ dataOut.writeUTF(this.dateOfExpiryCheckDigit);
720
+ if (this.documentType === DocumentType.MRVB) {
721
+ this.writeString(this.optionalData1, dataOut, 8);
722
+ } else if (isExtendedDocumentNumber) {
723
+ this.writeString(this.documentNumber.substring(9) + this.documentNumberCheckDigit + '<', dataOut, 7);
724
+ dataOut.writeUTF(this.compositeCheckDigit);
725
+ } else {
726
+ this.writeString(this.optionalData1, dataOut, 7);
727
+ dataOut.writeUTF(this.compositeCheckDigit);
728
+ }
729
+ }
730
+
731
+ /**
732
+ * Writes this MRZ to stream.
733
+ *
734
+ * @param outputStream the stream to write to
735
+ *
736
+ * @throws IOException on error writing to the stream
737
+ */
738
+ writeObjectTD3OrMRVA(outputStream) {
739
+ const dataOut = outputStream instanceof DataOutputStream ? outputStream : new DataOutputStream(outputStream);
740
+
741
+ /* top line */
742
+ this.writeDocumentType(dataOut);
743
+ MRZInfo.writeCountryCode(this.issuingState, dataOut);
744
+ this.writeName(dataOut, 39);
745
+
746
+ /* bottom line */
747
+ this.writeString(this.documentNumber, dataOut, 9);
748
+ dataOut.writeUTF(this.documentNumberCheckDigit);
749
+ MRZInfo.writeCountryCode(this.nationality, dataOut);
750
+ this.writeDateOfBirth(dataOut);
751
+ dataOut.writeUTF(this.dateOfBirthCheckDigit);
752
+ this.writeGender(dataOut);
753
+ this.writeDateOfExpiry(dataOut);
754
+ dataOut.writeUTF(this.dateOfExpiryCheckDigit);
755
+ if (this.documentType === DocumentType.MRVA) {
756
+ this.writeString(this.optionalData1, dataOut, 16);
757
+ } else {
758
+ // Must be TD3.
759
+ this.writeString(this.optionalData1, dataOut, 14);
760
+ dataOut.writeUTF(this.personalNumberCheckDigit);
761
+ dataOut.writeUTF(this.compositeCheckDigit);
762
+ }
763
+ }
764
+
765
+ /**
766
+ * Sets the name identifiers (primary and secondary identifier) based on
767
+ * the name in the MRZ.
768
+ *
769
+ * @param mrzNameString the name field as it occurs in the MRZ
770
+ */
771
+ readNameIdentifiers(mrzNameString) {
772
+ const delimIndex = mrzNameString.indexOf('<<');
773
+ if (delimIndex < 0) {
774
+ /* Only a primary identifier. */
775
+ this.primaryIdentifier = MRZInfo.trimTrailingFillerChars(mrzNameString).replace('<', ' ');
776
+ this.secondaryIdentifier = '';
777
+ return;
778
+ }
779
+ this.primaryIdentifier = MRZInfo.trimTrailingFillerChars(mrzNameString.substring(0, delimIndex)).replace('<', ' ');
780
+ const rest = mrzNameString.substring(delimIndex + 2);
781
+ this.readSecondaryIdentifiers(rest);
782
+ }
783
+
784
+ /**
785
+ * Sets the secondary identifier.
786
+ *
787
+ * @param secondaryIdentifier the new secondary identifier
788
+ */
789
+ readSecondaryIdentifiers(secondaryIdentifier) {
790
+ this.secondaryIdentifier = MRZInfo.trimTrailingFillerChars(secondaryIdentifier).replace('<', ' ');
791
+ }
792
+
793
+ /**
794
+ * Writes a MRZ string to a stream, optionally formatting the MRZ string.
795
+ *
796
+ * @param str the string to write
797
+ * @param dataOutputStream the stream to write to
798
+ * @param width the width of the MRZ field (the string will be augmented with trailing fillers)
799
+ *
800
+ * @throws IOException on error writing to the stream
801
+ */
802
+ writeString(str, dataOutputStream, width) {
803
+ dataOutputStream.writeUTF(MRZInfo.mrzFormat(str, width));
804
+ }
805
+
806
+ /**
807
+ * Writes the issuing state to a stream.
808
+ *
809
+ * @param dataOutputStream the stream to write to
810
+ *
811
+ * @throws IOException on error writing to the stream
812
+ */
813
+ static writeCountryCode(countryCode, dataOutputStream) {
814
+ dataOutputStream.writeUTF(MRZInfo.mrzFormat(countryCode, 3));
815
+ }
816
+
817
+ /**
818
+ * Writes the date of expiry to a stream.
819
+ *
820
+ * @param dateOutputStream the stream to write to
821
+ *
822
+ * @throws IOException on error writing to the stream
823
+ */
824
+ writeDateOfExpiry(dateOutputStream) {
825
+ dateOutputStream.writeUTF(this.dateOfExpiry);
826
+ }
827
+
828
+ /**
829
+ * Writes the gender to a stream.
830
+ *
831
+ * @param dataOutputStream the stream to write to
832
+ *
833
+ * @throws IOException on error writing to the stream
834
+ */
835
+ writeGender(dataOutputStream) {
836
+ dataOutputStream.writeUTF(this.gender.getStrCode());
837
+ }
838
+
839
+ /**
840
+ * Writes the data of birth to a stream.
841
+ *
842
+ * @param dataOutputStream the stream to write to
843
+ *
844
+ * @throws IOException on error writing to the stream
845
+ */
846
+ writeDateOfBirth(dataOutputStream) {
847
+ dataOutputStream.writeUTF(this.dateOfBirth);
848
+ }
849
+
850
+ /**
851
+ * Writes the name to a stream.
852
+ *
853
+ * @param dataOutputStream the stream to write to
854
+ * @param width the width of the field
855
+ *
856
+ * @throws IOException on error writing to the stream
857
+ */
858
+ writeName(dataOutputStream, width) {
859
+ dataOutputStream.writeUTF(MRZInfo.nameToString(this.primaryIdentifier, this.secondaryIdentifier, width));
860
+ }
861
+
862
+ /**
863
+ * Write the document type to a stream.
864
+ *
865
+ * @param dataOutputStream the stream to write to
866
+ *
867
+ * @throws IOException on error writing to the stream
868
+ */
869
+ writeDocumentType(dataOutputStream) {
870
+ this.writeString(this.documentCode, dataOutputStream, 2);
871
+ }
872
+
873
+ /**
874
+ * Encodes the personal number as optional data in case of TD3 style MRZ.
875
+ * If the number does not yet include a check-digit it will be added.
876
+ *
877
+ * @param personalNumber the personal number (or optional data)
878
+ *
879
+ * @return the optional data to include in the MRZ
880
+ */
881
+ static personalNumberToOptionalData(personalNumber) {
882
+ if (personalNumber == null || MRZInfo.equalsModuloFillerChars(personalNumber, '')) {
883
+ /* optional data field is not used */
884
+ return '';
885
+ } else if (personalNumber.length === 15) {
886
+ /* it's either a personalNumber with check digit included, or some other optional data. FIXME: Is this case possible? */
887
+ return personalNumber;
888
+ } else if (personalNumber.length <= 14) {
889
+ /* we'll assume it's a personalNumber without check digit, and we add the check digit ourselves */
890
+ return MRZInfo.mrzFormat(personalNumber, 14);
891
+ } else {
892
+ throw new Error(`Wrong personal number${personalNumber}`);
893
+ }
894
+ }
895
+
896
+ /**
897
+ * Converts the name (primary and secondary identifier) to a single MRZ formatted name
898
+ * field of the given length.
899
+ *
900
+ * @param primaryIdentifier the primary identifier part of the name
901
+ * @param secondaryIdentifier the secondary identifier part of the name
902
+ * @param width the width of the resulting MRZ formatted string
903
+ *
904
+ * @return the string containing the MRZ formatted name field
905
+ */
906
+ static nameToString(primaryIdentifier, secondaryIdentifier, width) {
907
+ const primaryComponents = primaryIdentifier.split(' |<');
908
+ const secondaryComponents = secondaryIdentifier == null || secondaryIdentifier.trim().length === 0 ? [] : secondaryIdentifier.split(' |<');
909
+ const name = [];
910
+ let isFirstPrimaryComponent = true;
911
+ for (const primaryComponent of primaryComponents) {
912
+ if (isFirstPrimaryComponent) {
913
+ isFirstPrimaryComponent = false;
914
+ } else {
915
+ name.push('<');
916
+ }
917
+ name.push(primaryComponent);
918
+ }
919
+ if (secondaryIdentifier != null && secondaryIdentifier.trim().length !== 0) {
920
+ name.push('<<');
921
+ let isFirstSecondaryComponent = true;
922
+ for (const secondaryComponent of secondaryComponents) {
923
+ if (isFirstSecondaryComponent) {
924
+ isFirstSecondaryComponent = false;
925
+ } else {
926
+ name.push('<');
927
+ }
928
+ name.push(secondaryComponent);
929
+ }
930
+ }
931
+ return MRZInfo.mrzFormat(name.join(''), width);
932
+ }
933
+
934
+ /**
935
+ * Reads the issuing state as a three letter string.
936
+ *
937
+ * @param inputStream the stream to read from
938
+ *
939
+ * @return a string of length 3 containing an abbreviation
940
+ * of the issuing state or organization
941
+ *
942
+ * @throws IOException error reading from the stream
943
+ */
944
+ static async readCountryCode(inputStream) {
945
+ return MRZInfo.trimTrailingFillerChars(await MRZInfo.readString(inputStream, 3));
946
+ }
947
+
948
+ /**
949
+ * Reads the 1 letter gender information.
950
+ *
951
+ * @param inputStream input source
952
+ *
953
+ * @return the gender of the passport holder
954
+ *
955
+ * @throws IOException if something goes wrong
956
+ */
957
+ async readGender(inputStream) {
958
+ const genderStr = await MRZInfo.readString(inputStream, 1);
959
+ if (genderStr.toUpperCase() === 'M') {
960
+ return Gender.MALE;
961
+ }
962
+ if (genderStr.toUpperCase() === 'F') {
963
+ return Gender.FEMALE;
964
+ }
965
+ return Gender.UNKNOWN;
966
+ }
967
+
968
+ /**
969
+ * Reads a date.
970
+ * Result is typically in "yyMMdd" format.
971
+ *
972
+ * @param inputStream the stream to read from
973
+ *
974
+ * @return the date of birth
975
+ *
976
+ * @throws IOException if something goes wrong
977
+ * @throws NumberFormatException if a data could not be constructed
978
+ */
979
+ async readDate(inputStream) {
980
+ return await MRZInfo.readString(inputStream, 6);
981
+ }
982
+
983
+ /**
984
+ * Reads a fixed length string from a stream.
985
+ *
986
+ * @param inputStream the stream to read from
987
+ * @param count the fixed length
988
+ *
989
+ * @return the string that was read
990
+ *
991
+ * @throws IOException on error reading from the stream
992
+ */
993
+ static async readString(inputStream, count) {
994
+ const data = Buffer.alloc(count);
995
+ await inputStream.readFully(data);
996
+ return Buffer.from(data).toString('utf8');
997
+ }
998
+
999
+ /**
1000
+ * Returns the composite part over which the composite check digit is computed.
1001
+ *
1002
+ * @param documentType the type of document, either {@code DOC_TYPE_ID1} or {@code DOC_TYPE_ID3}
1003
+ *
1004
+ * @return a string with the composite part
1005
+ */
1006
+ getComposite(documentType) {
1007
+ const composite = [];
1008
+ const documentNumberLength = this.documentNumber.length;
1009
+ switch (documentType) {
1010
+ case DocumentType.TD1:
1011
+ /*
1012
+ * Upper line:
1013
+ * 6-30, i.e., documentNumber, documentNumberCheckDigit, optionaldata1(15)
1014
+ *
1015
+ * Middle line:
1016
+ * 1-7, i.e., dateOfBirth, dateOfBirthCheckDigit
1017
+ * 9-15, i.e., dateOfExpiry, dateOfExpiryCheckDigit
1018
+ * 19-29, i.e., optionalData2(11)
1019
+ */
1020
+ if (documentNumberLength <= 9) {
1021
+ composite.push(MRZInfo.mrzFormat(this.documentNumber, 9));
1022
+ composite.push(this.documentNumberCheckDigit);
1023
+ composite.push(MRZInfo.mrzFormat(this.optionalData1, 15));
1024
+ } else {
1025
+ /* Document number, first 9 characters. */
1026
+ composite.push(this.documentNumber.substring(0, 9));
1027
+ composite.push('<'); /* Filler instead of check digit. */
1028
+
1029
+ /* Remainder of document number. */
1030
+ const documentNumberRemainder = this.documentNumber.substring(9);
1031
+ composite.push(documentNumberRemainder);
1032
+ composite.push(this.documentNumberCheckDigit);
1033
+ composite.push('<');
1034
+
1035
+ /* Remainder of optional data 1 (removing any prefix). */
1036
+ const optionalData1Remainder = MRZInfo.mrzFormat(this.optionalData1, 15 - 2 - documentNumberRemainder.length);
1037
+ composite.push(optionalData1Remainder);
1038
+ }
1039
+ composite.push(this.dateOfBirth);
1040
+ composite.push(this.dateOfBirthCheckDigit);
1041
+ composite.push(this.dateOfExpiry);
1042
+ composite.push(this.dateOfExpiryCheckDigit);
1043
+ composite.push(MRZInfo.mrzFormat(this.optionalData2, 11));
1044
+ return composite.join('');
1045
+ case DocumentType.TD2:
1046
+ /* Composite check digit lower line: 1-10, 14-20, 22-35. */
1047
+ composite.push(this.documentNumber);
1048
+ composite.push(this.documentNumberCheckDigit);
1049
+ composite.push(this.dateOfBirth);
1050
+ composite.push(this.dateOfBirthCheckDigit);
1051
+ composite.push(this.dateOfExpiry);
1052
+ composite.push(this.dateOfExpiryCheckDigit);
1053
+ composite.push(MRZInfo.mrzFormat(this.optionalData1, 7));
1054
+ return composite.join('');
1055
+ case DocumentType.MRVB:
1056
+ /* No composite checkdigit for MRV-B. */
1057
+ return null;
1058
+ case DocumentType.TD3:
1059
+ /* Composite check digit lower line: 1-10, 14-20, 22-43. */
1060
+ composite.push(MRZInfo.mrzFormat(this.documentNumber, 9));
1061
+ composite.push(this.documentNumberCheckDigit);
1062
+ composite.push(this.dateOfBirth);
1063
+ composite.push(this.dateOfBirthCheckDigit);
1064
+ composite.push(this.dateOfExpiry);
1065
+ composite.push(this.dateOfExpiryCheckDigit);
1066
+ composite.push(MRZInfo.mrzFormat(this.optionalData1, 14));
1067
+ composite.push(this.personalNumberCheckDigit);
1068
+ return composite.join('');
1069
+ case DocumentType.MRVA:
1070
+ /* No composite checkdigit for MRV-A. */
1071
+ return null;
1072
+ default:
1073
+ throw new Error('Unsupported document type');
1074
+ }
1075
+ }
1076
+
1077
+ /**
1078
+ * Updates the check digit fields for document number,
1079
+ * date of birth, date of expiry, and composite.
1080
+ */
1081
+ checkDigit() {
1082
+ this.documentNumberCheckDigit = MRZInfo.checkDigit(this.documentNumber);
1083
+ this.dateOfBirthCheckDigit = MRZInfo.checkDigit(this.dateOfBirth);
1084
+ this.dateOfExpiryCheckDigit = MRZInfo.checkDigit(this.dateOfExpiry);
1085
+ if (this.documentType === DocumentType.TD3 && this.optionalData1.length < 15) {
1086
+ this.personalNumberCheckDigit = MRZInfo.checkDigit(MRZInfo.mrzFormat(this.optionalData1, 14), true); /* FIXME: Uses '<' over '0'. Where specified? */
1087
+ }
1088
+ const composite = this.getComposite(this.documentType);
1089
+ if (composite != null) {
1090
+ this.compositeCheckDigit = MRZInfo.checkDigit(composite);
1091
+ }
1092
+ }
1093
+
1094
+ /**
1095
+ * Reformats the input string such that it
1096
+ * only contains ['A'-'Z'], ['0'-'9'], '<' characters
1097
+ * by replacing other characters with '<'.
1098
+ * Also extends to the given length by adding '<' to the right.
1099
+ *
1100
+ * @param str the input string
1101
+ * @param width the (minimal) width of the result
1102
+ *
1103
+ * @return the reformatted string
1104
+ */
1105
+ static mrzFormat(str, width) {
1106
+ if (str == null) {
1107
+ return '';
1108
+ }
1109
+ if (str.length > width) {
1110
+ throw new Error(`Argument too wide (${str.length} > ${width})`);
1111
+ }
1112
+ str = str.toUpperCase().trim();
1113
+ let result = '';
1114
+ for (let i = 0; i < str.length; i++) {
1115
+ const c = str.charAt(i);
1116
+ if (MRZInfo.MRZ_CHARS.indexOf(c) === -1) {
1117
+ result += '<';
1118
+ } else {
1119
+ result += c;
1120
+ }
1121
+ }
1122
+ while (result.length < width) {
1123
+ result += '<';
1124
+ }
1125
+ return result;
1126
+ }
1127
+
1128
+ /**
1129
+ * Determines the document-type.
1130
+ *
1131
+ * @param documentCode the document-code
1132
+ * @param length the length of the complete MRZ (excluding whitespace)
1133
+ *
1134
+ * @return the document-type enum value
1135
+ */
1136
+ static getDocumentType(documentCode, length) {
1137
+ if (documentCode == null || documentCode.length < 1 || documentCode.length > 2) {
1138
+ throw new Error('Was expecting 1 or 2 digit document code, got ' + documentCode);
1139
+ }
1140
+ switch (length) {
1141
+ case 90:
1142
+ /* Document-code must start with C, I, or A. */
1143
+ return DocumentType.TD1;
1144
+ case 72:
1145
+ if (documentCode.startsWith('V')) {
1146
+ return DocumentType.MRVB;
1147
+ } else {
1148
+ /* Document-code must start with C, I, or A. */
1149
+ return DocumentType.TD2;
1150
+ }
1151
+ case 88:
1152
+ if (documentCode.startsWith('V')) {
1153
+ return DocumentType.MRVA;
1154
+ } else {
1155
+ /* Document-code must start with P. */
1156
+ return DocumentType.TD3;
1157
+ }
1158
+ default:
1159
+ return DocumentType.UNKNOWN;
1160
+ }
1161
+ }
1162
+
1163
+ /*
1164
+ * NOTE: Can be removed once deprecated methods are gone.
1165
+ */
1166
+ /**
1167
+ * Determines the document type based on the document code (the first two characters of the MRZ).
1168
+ *
1169
+ * ICAO Doc 9303 part 3 vol 1 defines MRTDs with 3-line MRZs,
1170
+ * in this case the document code starts with "A", "C", or "I"
1171
+ * according to note j to Section 6.6 (page V-9).
1172
+ *
1173
+ * ICAO Doc 9303 part 2 defines MRVs with 2-line MRZs,
1174
+ * in this case the document code starts with "V".
1175
+ *
1176
+ * ICAO Doc 9303 part 1 vol 1 defines MRPs with 2-line MRZs,
1177
+ * in this case the document code starts with "P"
1178
+ * according to Section 9.6 (page IV-15).
1179
+ *
1180
+ * @param documentCode a two letter code
1181
+ *
1182
+ * @return a document type, one of {@link #DOC_TYPE_ID1}, {@link #DOC_TYPE_ID2},
1183
+ * {@link #DOC_TYPE_ID3}, or {@link #DOC_TYPE_UNSPECIFIED}
1184
+ */
1185
+ static getDocumentTypeFromDocumentCode(documentCode) {
1186
+ if (documentCode.startsWith('A') || documentCode.startsWith('C') || documentCode.startsWith('I')) {
1187
+ /* MRTD according to ICAO Doc 9303 (seventh edition) part 5 or 6. NOTE: Could also be TD2. */
1188
+ return DocumentType.TD1;
1189
+ } else if (documentCode.startsWith('V')) {
1190
+ /* MRV according to ICAO Doc 9303 (old) part 2. NOTE: Could also be MRVA. */
1191
+ return DocumentType.MRVB;
1192
+ } else if (documentCode.startsWith('P')) {
1193
+ /* MRP according to ICAO Doc 9303 (old) part 1 vol 1 */
1194
+ return DocumentType.TD3;
1195
+ }
1196
+ return DocumentType.UNKNOWN;
1197
+ }
1198
+
1199
+ /**
1200
+ * Replaces '<' with ' ' and trims leading and trailing whitespace.
1201
+ *
1202
+ * @param str the string to read from
1203
+ *
1204
+ * @return a trimmed string
1205
+ */
1206
+ static trimTrailingFillerChars(str) {
1207
+ if (str == null) {
1208
+ return '';
1209
+ }
1210
+ return str.replace(/</g, ' ').trim();
1211
+ }
1212
+
1213
+ /**
1214
+ * Checks if the document-code is consistent with the given document-type.
1215
+ *
1216
+ * @param documentType the document-type
1217
+ * @param documentCode the document-code
1218
+ *
1219
+ * @return a boolean
1220
+ */
1221
+ static isDocumentCodeConsistentWithDocumentType(documentType, documentCode) {
1222
+ if (documentCode == null) {
1223
+ return false;
1224
+ }
1225
+ if (documentCode.length !== 1 && documentCode.length !== 2) {
1226
+ return false;
1227
+ }
1228
+ switch (documentType) {
1229
+ case DocumentType.TD1:
1230
+ /* Fall through... */
1231
+ case DocumentType.TD2:
1232
+ return documentCode.startsWith('C') || documentCode.startsWith('I') || documentCode.startsWith('A');
1233
+ case DocumentType.TD3:
1234
+ return documentCode.startsWith('P');
1235
+ case DocumentType.MRVA:
1236
+ /* Fall through... */
1237
+ case DocumentType.MRVB:
1238
+ return documentCode.startsWith('V');
1239
+ default:
1240
+ return false;
1241
+ }
1242
+ }
1243
+
1244
+ /**
1245
+ * Checks if the optional data is consistent with the given document-type.
1246
+ *
1247
+ * @param documentType the document-type
1248
+ * @param optionalData1 optional data 1 or personal number
1249
+ * @param optionalData2 optional data 2 or {@code null} if not present
1250
+ *
1251
+ * @return a boolean
1252
+ */
1253
+ static isOptionalDataConsistentWithDocumentType(documentType, optionalData1, optionalData2) {
1254
+ switch (documentType) {
1255
+ case DocumentType.TD1:
1256
+ return (optionalData1 == null || optionalData1.length <= 15) && (optionalData2 == null || optionalData2.length <= 11);
1257
+ case DocumentType.TD2:
1258
+ return (optionalData1 == null || optionalData1.length <= 7) && optionalData2 == null;
1259
+ case DocumentType.MRVB:
1260
+ return (optionalData1 == null || optionalData1.length <= 8) && optionalData2 == null;
1261
+ case DocumentType.TD3:
1262
+ return (optionalData1 == null || optionalData1.length <= 15) && optionalData2 == null;
1263
+ case DocumentType.MRVA:
1264
+ return (optionalData1 == null || optionalData1.length <= 16) && optionalData2 == null;
1265
+ default:
1266
+ return false;
1267
+ }
1268
+ }
1269
+
1270
+ /**
1271
+ * Computes the 7-3-1 check digit for part of the MRZ.
1272
+ * If `preferFillerOverZero` is `true` then '<' will be
1273
+ * returned on check digit 0.
1274
+ *
1275
+ * @param str a part of the MRZ
1276
+ * @param preferFillerOverZero a boolean indicating whether fillers should be preferred
1277
+ *
1278
+ * @return the resulting check digit (in '0' - '9', '<')
1279
+ */
1280
+ static checkDigit(str, preferFillerOverZero = false) {
1281
+ try {
1282
+ const chars = str == null ? [] : Array.from(str, char => char.charCodeAt(0));
1283
+ const weights = [7, 3, 1];
1284
+ let result = 0;
1285
+ for (let i = 0; i < chars.length; i++) {
1286
+ result = (result + weights[i % 3] * this.decodeMRZDigit(chars[i])) % 10;
1287
+ }
1288
+ const checkDigitString = result.toString();
1289
+ if (checkDigitString.length !== 1) {
1290
+ throw new Error('Error in computing check digit.'); /* NOTE: Never happens. */
1291
+ }
1292
+ let checkDigit = String.fromCharCode(checkDigitString.charCodeAt(0));
1293
+ if (preferFillerOverZero && checkDigit === '0') {
1294
+ checkDigit = '<';
1295
+ }
1296
+ return checkDigit;
1297
+ } catch (error) {
1298
+ /* NOTE: never happens. */
1299
+ throw new Error('Error in computing check digit');
1300
+ }
1301
+ }
1302
+
1303
+ /**
1304
+ * Looks up the numerical value for MRZ characters. In order to be able
1305
+ * to compute check digits.
1306
+ *
1307
+ * @param ch a character from the MRZ.
1308
+ *
1309
+ * @return the numerical value of the character.
1310
+ *
1311
+ * @throws NumberFormatException if {@code ch} is not a valid MRZ character
1312
+ */
1313
+ static decodeMRZDigit(ch) {
1314
+ switch (ch) {
1315
+ case '<'.charCodeAt(0):
1316
+ case '0'.charCodeAt(0):
1317
+ return 0;
1318
+ case '1'.charCodeAt(0):
1319
+ return 1;
1320
+ case '2'.charCodeAt(0):
1321
+ return 2;
1322
+ case '3'.charCodeAt(0):
1323
+ return 3;
1324
+ case '4'.charCodeAt(0):
1325
+ return 4;
1326
+ case '5'.charCodeAt(0):
1327
+ return 5;
1328
+ case '6'.charCodeAt(0):
1329
+ return 6;
1330
+ case '7'.charCodeAt(0):
1331
+ return 7;
1332
+ case '8'.charCodeAt(0):
1333
+ return 8;
1334
+ case '9'.charCodeAt(0):
1335
+ return 9;
1336
+ case 'a'.charCodeAt(0):
1337
+ case 'A'.charCodeAt(0):
1338
+ return 10;
1339
+ case 'b'.charCodeAt(0):
1340
+ case 'B'.charCodeAt(0):
1341
+ return 11;
1342
+ case 'c'.charCodeAt(0):
1343
+ case 'C'.charCodeAt(0):
1344
+ return 12;
1345
+ case 'd'.charCodeAt(0):
1346
+ case 'D'.charCodeAt(0):
1347
+ return 13;
1348
+ case 'e'.charCodeAt(0):
1349
+ case 'E'.charCodeAt(0):
1350
+ return 14;
1351
+ case 'f'.charCodeAt(0):
1352
+ case 'F'.charCodeAt(0):
1353
+ return 15;
1354
+ case 'g'.charCodeAt(0):
1355
+ case 'G'.charCodeAt(0):
1356
+ return 16;
1357
+ case 'h'.charCodeAt(0):
1358
+ case 'H'.charCodeAt(0):
1359
+ return 17;
1360
+ case 'i'.charCodeAt(0):
1361
+ case 'I'.charCodeAt(0):
1362
+ return 18;
1363
+ case 'j'.charCodeAt(0):
1364
+ case 'J'.charCodeAt(0):
1365
+ return 19;
1366
+ case 'k'.charCodeAt(0):
1367
+ case 'K'.charCodeAt(0):
1368
+ return 20;
1369
+ case 'l'.charCodeAt(0):
1370
+ case 'L'.charCodeAt(0):
1371
+ return 21;
1372
+ case 'm'.charCodeAt(0):
1373
+ case 'M'.charCodeAt(0):
1374
+ return 22;
1375
+ case 'n'.charCodeAt(0):
1376
+ case 'N'.charCodeAt(0):
1377
+ return 23;
1378
+ case 'o'.charCodeAt(0):
1379
+ case 'O'.charCodeAt(0):
1380
+ return 24;
1381
+ case 'p'.charCodeAt(0):
1382
+ case 'P'.charCodeAt(0):
1383
+ return 25;
1384
+ case 'q'.charCodeAt(0):
1385
+ case 'Q'.charCodeAt(0):
1386
+ return 26;
1387
+ case 'r'.charCodeAt(0):
1388
+ case 'R'.charCodeAt(0):
1389
+ return 27;
1390
+ case 's'.charCodeAt(0):
1391
+ case 'S'.charCodeAt(0):
1392
+ return 28;
1393
+ case 't'.charCodeAt(0):
1394
+ case 'T'.charCodeAt(0):
1395
+ return 29;
1396
+ case 'u'.charCodeAt(0):
1397
+ case 'U'.charCodeAt(0):
1398
+ return 30;
1399
+ case 'v'.charCodeAt(0):
1400
+ case 'V'.charCodeAt(0):
1401
+ return 31;
1402
+ case 'w'.charCodeAt(0):
1403
+ case 'W'.charCodeAt(0):
1404
+ return 32;
1405
+ case 'x'.charCodeAt(0):
1406
+ case 'X'.charCodeAt(0):
1407
+ return 33;
1408
+ case 'y'.charCodeAt(0):
1409
+ case 'Y'.charCodeAt(0):
1410
+ return 34;
1411
+ case 'z'.charCodeAt(0):
1412
+ case 'Z'.charCodeAt(0):
1413
+ return 35;
1414
+ default:
1415
+ throw new Error(`Could not decode MRZ character ${ch} ('${String.fromCharCode(ch)}')`);
1416
+ }
1417
+ }
1418
+ }