@trustchex/react-native-sdk 1.355.1 → 1.357.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 (254) hide show
  1. package/README.md +2 -9
  2. package/TrustchexSDK.podspec +5 -4
  3. package/android/build.gradle +6 -4
  4. package/android/src/main/AndroidManifest.xml +1 -1
  5. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
  6. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
  7. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
  8. package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
  9. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
  10. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
  11. package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
  12. package/ios/Camera/TrustchexCameraManager.m +37 -0
  13. package/ios/Camera/TrustchexCameraManager.swift +125 -0
  14. package/ios/Camera/TrustchexCameraView.swift +1176 -0
  15. package/ios/MLKit/MLKitModule.m +23 -0
  16. package/ios/MLKit/MLKitModule.swift +250 -0
  17. package/ios/MRZValidation.m +39 -0
  18. package/ios/MRZValidation.swift +802 -0
  19. package/ios/MRZValidator.swift +466 -0
  20. package/ios/OpenCV/OpenCVModule.h +4 -0
  21. package/ios/OpenCV/OpenCVModule.mm +810 -0
  22. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
  23. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
  24. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
  25. package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
  26. package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
  27. package/lib/module/Screens/Static/ResultScreen.js +25 -2
  28. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
  29. package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
  30. package/lib/module/Shared/Components/EIDScanner.js +99 -9
  31. package/lib/module/Shared/Components/FaceCamera.js +170 -179
  32. package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
  33. package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
  34. package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
  35. package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
  36. package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
  37. package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
  38. package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
  39. package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
  40. package/lib/module/Shared/Libs/analytics.utils.js +2 -2
  41. package/lib/module/Shared/Libs/debug.utils.js +132 -0
  42. package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
  43. package/lib/module/Shared/Libs/demo.utils.js +13 -3
  44. package/lib/module/Shared/Libs/mrz.utils.js +1 -175
  45. package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
  46. package/lib/module/Shared/Libs/tts.utils.js +40 -6
  47. package/lib/module/Shared/Services/AnalyticsService.js +9 -8
  48. package/lib/module/Shared/Types/mrzFields.js +1 -0
  49. package/lib/module/Translation/Resources/en.js +87 -88
  50. package/lib/module/Translation/Resources/tr.js +84 -85
  51. package/lib/module/Trustchex.js +9 -2
  52. package/lib/module/index.js +1 -0
  53. package/lib/module/version.js +1 -1
  54. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
  55. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
  56. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  57. package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
  58. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
  59. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  60. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
  61. package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
  62. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
  63. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  64. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
  65. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  66. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
  67. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  68. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
  69. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
  70. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
  71. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
  72. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
  73. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
  74. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
  75. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
  76. package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
  77. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
  78. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
  79. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
  80. package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
  81. package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
  82. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
  83. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
  84. package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
  85. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
  86. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
  87. package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
  88. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
  89. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
  90. package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
  91. package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
  92. package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
  93. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
  94. package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
  95. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  96. package/lib/typescript/src/Trustchex.d.ts +2 -0
  97. package/lib/typescript/src/Trustchex.d.ts.map +1 -1
  98. package/lib/typescript/src/index.d.ts +1 -0
  99. package/lib/typescript/src/index.d.ts.map +1 -1
  100. package/lib/typescript/src/version.d.ts +1 -1
  101. package/package.json +4 -35
  102. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
  103. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
  104. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
  105. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
  106. package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
  107. package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
  108. package/src/Screens/Static/ResultScreen.tsx +136 -88
  109. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
  110. package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
  111. package/src/Shared/Components/EIDScanner.tsx +94 -16
  112. package/src/Shared/Components/FaceCamera.tsx +236 -203
  113. package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
  114. package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
  115. package/src/Shared/Components/TrustchexCamera.tsx +289 -0
  116. package/src/Shared/Config/camera-enhancement.config.ts +2 -2
  117. package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
  118. package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
  119. package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
  120. package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
  121. package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
  122. package/src/Shared/Libs/analytics.utils.ts +48 -20
  123. package/src/Shared/Libs/debug.utils.ts +149 -0
  124. package/src/Shared/Libs/deeplink.utils.ts +7 -5
  125. package/src/Shared/Libs/demo.utils.ts +4 -0
  126. package/src/Shared/Libs/http-client.ts +12 -8
  127. package/src/Shared/Libs/mrz.utils.ts +1 -163
  128. package/src/Shared/Libs/native-device-info.utils.ts +12 -6
  129. package/src/Shared/Libs/tts.utils.ts +48 -6
  130. package/src/Shared/Services/AnalyticsService.ts +69 -24
  131. package/src/Shared/Types/identificationInfo.ts +2 -2
  132. package/src/Shared/Types/mrzFields.ts +29 -0
  133. package/src/Translation/Resources/en.ts +90 -100
  134. package/src/Translation/Resources/tr.ts +89 -97
  135. package/src/Translation/index.ts +1 -1
  136. package/src/Trustchex.tsx +21 -4
  137. package/src/index.tsx +14 -0
  138. package/src/version.ts +1 -1
  139. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
  140. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
  141. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
  142. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
  143. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
  144. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
  145. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
  146. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
  147. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
  148. package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
  149. package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
  150. package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
  151. package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
  152. package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
  153. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
  154. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
  155. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
  156. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
  157. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
  158. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
  159. package/lib/module/Shared/Libs/camera.utils.js +0 -308
  160. package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
  161. package/lib/module/Shared/Libs/opencv.utils.js +0 -21
  162. package/lib/module/Shared/Libs/worklet.utils.js +0 -68
  163. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
  164. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
  165. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
  166. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
  167. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
  168. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
  169. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
  170. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
  171. package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
  172. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
  173. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
  174. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
  175. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
  176. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
  177. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
  178. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
  179. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
  180. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
  181. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
  182. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
  183. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
  184. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
  185. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
  186. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
  187. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
  188. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
  189. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
  190. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
  191. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
  192. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
  193. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
  194. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
  195. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
  196. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
  197. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
  198. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
  199. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
  200. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
  201. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
  202. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
  203. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
  204. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
  205. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
  206. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
  207. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
  208. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
  209. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
  210. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
  211. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
  212. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
  213. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
  214. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
  215. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
  216. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
  217. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
  218. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
  219. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
  220. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
  221. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
  222. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
  223. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
  224. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
  225. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
  226. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
  227. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
  228. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
  229. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
  230. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
  231. package/src/Shared/Libs/camera.utils.ts +0 -345
  232. package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
  233. package/src/Shared/Libs/opencv.utils.ts +0 -40
  234. package/src/Shared/Libs/worklet.utils.ts +0 -72
  235. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
  236. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
  237. package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
  238. package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
  239. package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
  240. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
  241. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
  242. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
  243. package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
  244. package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
  245. package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
  246. package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
  247. package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
  248. package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
  249. package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
  250. package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
  251. package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
  252. package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
  253. package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
  254. package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
@@ -1,118 +1,99 @@
1
1
  "use strict";
2
2
 
3
- import React, { useEffect } from 'react';
4
- import { View, StyleSheet, ActivityIndicator, Text as TextView, Text, Linking, Platform } from 'react-native';
5
- import { Camera, useCameraDevice, useCameraFormat, useCameraPermission, useFrameProcessor } from 'react-native-vision-camera';
6
- import { useRunOnJS, useSharedValue } from 'react-native-worklets-core';
3
+ import React, { useEffect, useRef, useCallback, useState } from 'react';
4
+ import { View, StyleSheet, ActivityIndicator, Text as TextView, Text, Linking, Platform, PermissionsAndroid, TouchableOpacity } from 'react-native';
5
+ import { TrustchexCamera } from "./TrustchexCamera.js";
7
6
  import { useKeepAwake } from "../Libs/native-keep-awake.utils.js";
8
7
  import { useIsFocused } from '@react-navigation/native';
9
8
  import { useTranslation } from 'react-i18next';
9
+ import { debugLog, logError } from "../Libs/debug.utils.js";
10
10
  import LottieView from 'lottie-react-native';
11
- import { scanCodes } from "../VisionCameraPlugins/BarcodeScanner/index.js";
12
11
  import StyledButton from "./StyledButton.js";
13
12
  import { useTheme } from "../Contexts/ThemeContext.js";
13
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
14
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const QrCodeScannerCamera = ({
16
- onQrCodeScanned
16
+ onQrCodeScanned,
17
+ onClose
17
18
  }) => {
18
19
  useKeepAwake();
19
20
  const theme = useTheme();
20
- const cameraPermission = useCameraPermission();
21
- const [permissionsRequested, setPermissionsRequested] = React.useState(false);
22
- const [isActive, setIsActive] = React.useState(false);
21
+ const insets = useSafeAreaInsets();
22
+ const cameraRef = useRef(null);
23
+ const [hasPermission, setHasPermission] = useState(false);
24
+ const [permissionsRequested, setPermissionsRequested] = useState(false);
25
+ const [isActive, setIsActive] = useState(false);
23
26
  const isFocused = useIsFocused();
24
- const device = useCameraDevice('back', {
25
- physicalDevices: ['wide-angle-camera']
26
- });
27
- const format = useCameraFormat(device, [{
28
- videoResolution: {
29
- width: 1920,
30
- height: 1080
31
- },
32
- iso: 'max',
33
- photoHdr: false,
34
- videoHdr: false
35
- }]);
36
- const isCameraInitialized = useSharedValue(false);
37
27
  const {
38
28
  t
39
29
  } = useTranslation();
40
- const isInScanningFrame = (code, width, height, orientation) => {
30
+ const lastScanTime = useRef(0);
31
+ const hasScanned = useRef(false);
32
+ const isInScanningFrame = (boundingBox, width, height) => {
33
+ // Match UI scanArea: top: '35%', left: '3%', right: '3%', bottom: '35%'
34
+ // Add 2% margin buffer to ensure code is comfortably inside frame
35
+ const marginBuffer = 0.02;
41
36
  const scanningFrame = {
42
- x: 0.35 * width,
43
- y: 0.03 * height,
44
- width: 0.3 * width,
45
- height: 0.94 * height
37
+ left: width * (0.03 + marginBuffer),
38
+ top: height * (0.35 + marginBuffer),
39
+ right: width * (0.97 - marginBuffer),
40
+ bottom: height * (0.65 - marginBuffer)
46
41
  };
47
- if (orientation === 'landscape-right' || orientation === 'landscape-left') {
48
- // Adjust scanning frame for landscape orientation
49
- scanningFrame.x = 0.03 * height;
50
- scanningFrame.y = 0.35 * width;
51
- scanningFrame.width = 0.94 * height;
52
- scanningFrame.height = 0.3 * width;
53
- }
42
+ console.log(`[QR Frame Check] Frame: ${width}x${height}, Scanning: left=${scanningFrame.left}, top=${scanningFrame.top}, right=${scanningFrame.right}, bottom=${scanningFrame.bottom}`);
43
+ console.log(`[QR Frame Check] Code bbox: left=${boundingBox.left}, top=${boundingBox.top}, right=${boundingBox.right}, bottom=${boundingBox.bottom}`);
54
44
 
55
- // Assuming Barcode has a boundingBox property: { x, y, width, height }
56
- const boundingBox = code.boundingBox;
57
- if (!boundingBox) {
58
- return false;
59
- }
60
- const codeX = boundingBox.origin.x;
61
- const codeY = boundingBox.origin.y;
62
- const codeWidth = boundingBox.size.width;
63
- const codeHeight = boundingBox.size.height;
64
- const codeRight = codeX + codeWidth;
65
- const codeBottom = codeY + codeHeight;
66
- const frameRight = scanningFrame.x + scanningFrame.width;
67
- const frameBottom = scanningFrame.y + scanningFrame.height;
68
-
69
- // Check if the code is within the scanning frame
70
- if (codeX >= scanningFrame.x && codeY >= scanningFrame.y && codeRight <= frameRight && codeBottom <= frameBottom) {
71
- return true;
72
- }
73
- return false;
45
+ // Check if entire bounding box is within scanning frame (with margin buffer)
46
+ const isInFrame = boundingBox.left >= scanningFrame.left && boundingBox.top >= scanningFrame.top && boundingBox.right <= scanningFrame.right && boundingBox.bottom <= scanningFrame.bottom;
47
+ console.log(`[QR Frame Check] Is in frame: ${isInFrame}`);
48
+ return isInFrame;
74
49
  };
75
- const handleQrCode = useRunOnJS((code, width, height, orientation) => {
76
- // TODO: Fix iOS coordinates - iOS coordinate system conversion may be incorrect
77
- // causing frame checking to fail. Need to verify coordinate normalization
78
- // between iOS Vision framework and React Native coordinate systems.
50
+ const handleFrame = useCallback(async event => {
51
+ if (hasScanned.current) return;
52
+ const now = Date.now();
53
+ // Throttle to ~3 FPS for QR scanning
54
+ if (now - lastScanTime.current < 333) {
55
+ return;
56
+ }
57
+ lastScanTime.current = now;
58
+ const {
59
+ frame
60
+ } = event.nativeEvent;
61
+ try {
62
+ // Barcodes are already detected natively — read directly from frame
63
+ const barcodes = frame.barcodes;
64
+ if (!barcodes || barcodes.length !== 1) return;
65
+ const code = barcodes[0];
79
66
 
80
- // On iOS, skip frame checking and scan any QR code found
81
- if (Platform.OS === 'ios') {
82
- if (code.value) {
83
- onQrCodeScanned(code.value);
84
- }
85
- } else {
86
- // On Android, continue with frame checking
87
- if (isInScanningFrame(code, width, height, orientation) && code.value) {
88
- onQrCodeScanned(code.value);
67
+ // Use frame checking on both platforms for consistent behavior
68
+ if (code.boundingBox && isInScanningFrame(code.boundingBox, frame.width, frame.height) && code.rawValue) {
69
+ hasScanned.current = true;
70
+ onQrCodeScanned(code.rawValue);
89
71
  }
72
+ } catch (error) {
73
+ logError('[QrCodeScannerCamera] Error processing frame:', error);
90
74
  }
91
75
  }, [onQrCodeScanned]);
92
- const frameProcessor = useFrameProcessor(frame => {
93
- 'worklet';
94
-
95
- if (!isCameraInitialized.value) {
96
- return;
97
- }
98
- const codes = scanCodes(frame, {
99
- barcodeTypes: ['qr']
100
- });
101
- if (codes && codes.length === 1) {
102
- handleQrCode(codes[0], frame.width, frame.height, frame.orientation);
103
- }
76
+ const handleCameraReady = useCallback(() => {
77
+ debugLog('QrCodeScannerCamera', '[QrCodeScannerCamera] Camera ready');
78
+ }, []);
79
+ const handleCameraError = useCallback(event => {
80
+ logError('[QrCodeScannerCamera] Camera error:', event.nativeEvent.error);
104
81
  }, []);
105
82
  useEffect(() => {
106
83
  const requestPermissions = async () => {
107
- if (!cameraPermission.hasPermission) {
108
- await cameraPermission.requestPermission();
84
+ if (Platform.OS === 'android') {
85
+ const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);
86
+ setHasPermission(granted === PermissionsAndroid.RESULTS.GRANTED);
87
+ } else {
88
+ // iOS permissions handled by native camera
89
+ setHasPermission(true);
109
90
  }
110
91
  setPermissionsRequested(true);
111
92
  };
112
93
  requestPermissions();
113
- }, [cameraPermission]);
94
+ }, []);
114
95
  useEffect(() => {
115
- if (!!device && !!format && isFocused) {
96
+ if (isFocused && hasPermission) {
116
97
  setIsActive(true);
117
98
  } else {
118
99
  setIsActive(false);
@@ -120,7 +101,7 @@ const QrCodeScannerCamera = ({
120
101
  return () => {
121
102
  setIsActive(false);
122
103
  };
123
- }, [device, format, isFocused]);
104
+ }, [isFocused, hasPermission]);
124
105
  if (!permissionsRequested) {
125
106
  return /*#__PURE__*/_jsx(View, {
126
107
  style: styles.permissionContainer,
@@ -130,8 +111,7 @@ const QrCodeScannerCamera = ({
130
111
  })
131
112
  });
132
113
  }
133
- if (!cameraPermission.hasPermission) {
134
- // Camera permission denied by user - their choice, not actionable
114
+ if (!hasPermission) {
135
115
  return /*#__PURE__*/_jsxs(View, {
136
116
  style: styles.permissionContainer,
137
117
  children: [/*#__PURE__*/_jsx(Text, {
@@ -146,31 +126,18 @@ const QrCodeScannerCamera = ({
146
126
  })]
147
127
  });
148
128
  }
149
- if (device == null) {
150
- // No camera device - device limitation, not actionable
151
- return /*#__PURE__*/_jsx(View, {
152
- style: styles.permissionContainer,
153
- children: /*#__PURE__*/_jsx(TextView, {
154
- style: styles.permissionText,
155
- children: t('general.noCameraDetected')
156
- })
157
- });
158
- }
159
129
  return /*#__PURE__*/_jsxs(View, {
160
130
  style: StyleSheet.absoluteFill,
161
- children: [/*#__PURE__*/_jsx(Camera, {
131
+ children: [/*#__PURE__*/_jsx(TrustchexCamera, {
132
+ ref: cameraRef,
162
133
  style: StyleSheet.absoluteFill,
163
- frameProcessor: frameProcessor,
164
- device: device,
165
- format: format,
166
- isActive: isActive,
167
- photo: false,
168
- video: false,
169
- audio: false,
170
- onInitialized: () => {
171
- isCameraInitialized.value = true;
172
- },
173
- fps: 30
134
+ cameraType: "back",
135
+ enableFrameProcessing: isActive,
136
+ enableBarcodeScanning: isActive,
137
+ targetFps: 30,
138
+ onFrameAvailable: handleFrame,
139
+ onCameraReady: handleCameraReady,
140
+ onCameraError: handleCameraError
174
141
  }), /*#__PURE__*/_jsx(View, {
175
142
  style: styles.topZone,
176
143
  children: /*#__PURE__*/_jsx(TextView, {
@@ -191,6 +158,22 @@ const QrCodeScannerCamera = ({
191
158
  loop: true,
192
159
  autoPlay: true
193
160
  })
161
+ }), onClose && /*#__PURE__*/_jsx(TouchableOpacity, {
162
+ onPress: onClose,
163
+ style: [styles.backButton, {
164
+ top: Math.max(insets.top + 10, 50)
165
+ }],
166
+ hitSlop: {
167
+ top: 10,
168
+ bottom: 10,
169
+ left: 10,
170
+ right: 10
171
+ },
172
+ activeOpacity: 0.7,
173
+ children: /*#__PURE__*/_jsx(TextView, {
174
+ style: styles.backButtonText,
175
+ children: "\xD7"
176
+ })
194
177
  })]
195
178
  });
196
179
  };
@@ -246,6 +229,25 @@ const styles = StyleSheet.create({
246
229
  fontWeight: 'bold',
247
230
  padding: 20
248
231
  },
232
+ backButton: {
233
+ position: 'absolute',
234
+ top: 20,
235
+ left: 20,
236
+ width: 40,
237
+ height: 40,
238
+ borderRadius: 20,
239
+ backgroundColor: 'rgba(255, 255, 255, 0.3)',
240
+ justifyContent: 'center',
241
+ alignItems: 'center',
242
+ zIndex: 999,
243
+ elevation: 5
244
+ },
245
+ backButtonText: {
246
+ color: 'white',
247
+ fontSize: 28,
248
+ fontWeight: 'bold',
249
+ lineHeight: 28
250
+ },
249
251
  leftZone: {
250
252
  position: 'absolute',
251
253
  top: '35%',
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ import React, { useRef, useCallback } from 'react';
4
+ import { requireNativeComponent, StyleSheet } from 'react-native';
5
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
6
+ import { logError } from "../Libs/debug.utils.js";
7
+
8
+ // Native component interface
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const TrustchexCameraViewNative = requireNativeComponent('TrustchexCamera');
11
+
12
+ // Commands interface for Fabric
13
+
14
+ const Commands = codegenNativeCommands({
15
+ supportedCommands: ['setFocusPoint', 'setExposureOffset', 'startRecording', 'stopRecording', 'cancelRecording', 'deleteRecording']
16
+ });
17
+
18
+ // Frame data structure — ML Kit results come pre-processed from native
19
+
20
+ export const TrustchexCamera = /*#__PURE__*/React.forwardRef((props, ref) => {
21
+ const cameraRef = useRef(null);
22
+ const recordingCallbacksRef = useRef({});
23
+ const handleRecordingFinished = useCallback(event => {
24
+ recordingCallbacksRef.current.onRecordingFinished?.({
25
+ path: event.nativeEvent.path
26
+ });
27
+ }, []);
28
+ const handleRecordingError = useCallback(event => {
29
+ recordingCallbacksRef.current.onRecordingError?.({
30
+ error: event.nativeEvent.error
31
+ });
32
+ }, []);
33
+ const setFocusPoint = useCallback((x, y) => {
34
+ try {
35
+ if (cameraRef.current) {
36
+ Commands.setFocusPoint(cameraRef.current, x, y);
37
+ }
38
+ } catch (error) {
39
+ logError('[TrustchexCamera] setFocusPoint error:', error);
40
+ }
41
+ }, []);
42
+ const setExposureOffset = useCallback(offset => {
43
+ try {
44
+ if (cameraRef.current) {
45
+ Commands.setExposureOffset(cameraRef.current, offset);
46
+ }
47
+ } catch (error) {
48
+ logError('[TrustchexCamera] setExposureOffset error:', error);
49
+ }
50
+ }, []);
51
+ const startRecording = useCallback(options => {
52
+ recordingCallbacksRef.current = {
53
+ onRecordingFinished: options.onRecordingFinished,
54
+ onRecordingError: options.onRecordingError
55
+ };
56
+ try {
57
+ if (cameraRef.current) {
58
+ Commands.startRecording(cameraRef.current);
59
+ }
60
+ } catch (error) {
61
+ logError('[TrustchexCamera] startRecording error:', error);
62
+ options.onRecordingError?.({
63
+ error: error.message
64
+ });
65
+ }
66
+ }, []);
67
+ const stopRecording = useCallback(() => {
68
+ return new Promise(resolve => {
69
+ try {
70
+ if (cameraRef.current) {
71
+ Commands.stopRecording(cameraRef.current);
72
+ }
73
+ } catch (error) {
74
+ logError('[TrustchexCamera] stopRecording error:', error);
75
+ }
76
+ resolve();
77
+ });
78
+ }, []);
79
+ const cancelRecording = useCallback(() => {
80
+ return new Promise(resolve => {
81
+ // Clear callbacks to prevent stale onRecordingFinished from firing
82
+ recordingCallbacksRef.current = {};
83
+ try {
84
+ if (cameraRef.current) {
85
+ Commands.cancelRecording(cameraRef.current);
86
+ }
87
+ } catch (error) {
88
+ logError('[TrustchexCamera] cancelRecording error:', error);
89
+ }
90
+ resolve();
91
+ });
92
+ }, []);
93
+ const deleteRecording = useCallback(filePath => {
94
+ try {
95
+ if (cameraRef.current) {
96
+ Commands.deleteRecording(cameraRef.current, filePath);
97
+ }
98
+ } catch (error) {
99
+ logError('[TrustchexCamera] deleteRecording error:', error);
100
+ }
101
+ }, []);
102
+ React.useImperativeHandle(ref, () => ({
103
+ setFocusPoint,
104
+ setExposureOffset,
105
+ startRecording,
106
+ stopRecording,
107
+ cancelRecording,
108
+ deleteRecording
109
+ }));
110
+ return /*#__PURE__*/_jsx(TrustchexCameraViewNative, {
111
+ ref: cameraRef,
112
+ ...props,
113
+ onRecordingFinished: handleRecordingFinished,
114
+ onRecordingError: handleRecordingError,
115
+ style: [styles.camera, props.style]
116
+ });
117
+ });
118
+ const styles = StyleSheet.create({
119
+ camera: {
120
+ flex: 1
121
+ }
122
+ });
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ import { ASN1Constants } from "./asn1Constants.js";
4
+ export class TLVHelpers extends ASN1Constants {
5
+ static isPrimitive(tag) {
6
+ let i = 3;
7
+ for (; i >= 0; i--) {
8
+ const mask = 0xff << 8 * i;
9
+ if ((tag & mask) !== 0x00) {
10
+ break;
11
+ }
12
+ }
13
+ const msByte = (tag & 0xff << 8 * i) >> 8 * i & 0xff;
14
+ return (msByte & 0x20) === 0x00;
15
+ }
16
+ static getTagLength(tag) {
17
+ return TLVHelpers.getTagAsBytes(tag).length;
18
+ }
19
+ static getLengthLength(length) {
20
+ return TLVHelpers.getLengthAsBytes(length).length;
21
+ }
22
+ static getTagAsBytes(tag) {
23
+ const out = [];
24
+ const byteCount = Math.floor(Math.log(tag) / Math.log(256)) + 1;
25
+ for (let i = 0; i < byteCount; i++) {
26
+ const pos = 8 * (byteCount - i - 1);
27
+ out.push((tag & 0xff << pos) >> pos);
28
+ }
29
+ const tagBytes = out;
30
+ switch (TLVHelpers.getTagClass(tag)) {
31
+ case TLVHelpers.APPLICATION_CLASS:
32
+ tagBytes[0] |= 0x40;
33
+ break;
34
+ case TLVHelpers.CONTEXT_SPECIFIC_CLASS:
35
+ tagBytes[0] |= 0x80;
36
+ break;
37
+ case TLVHelpers.PRIVATE_CLASS:
38
+ tagBytes[0] |= 0xc0;
39
+ break;
40
+ default:
41
+ break;
42
+ }
43
+ if (!TLVHelpers.isPrimitive(tag)) {
44
+ tagBytes[0] |= 0x20;
45
+ }
46
+ return tagBytes;
47
+ }
48
+ static getLengthAsBytes(length) {
49
+ const out = [];
50
+ if (length < 0x80) {
51
+ out.push(length);
52
+ } else {
53
+ const byteCount = TLVHelpers.log(length, 256);
54
+ out.push(0x80 | byteCount);
55
+ for (let i = 0; i < byteCount; i++) {
56
+ const pos = 8 * (byteCount - i - 1);
57
+ out.push((length & 0xff << pos) >> pos);
58
+ }
59
+ }
60
+ return out;
61
+ }
62
+ static getTagClass(tag) {
63
+ let i = 3;
64
+ for (; i >= 0; i--) {
65
+ const mask = 0xff << 8 * i;
66
+ if ((tag & mask) !== 0x00) {
67
+ break;
68
+ }
69
+ }
70
+ const msByte = (tag & 0xff << 8 * i) >> 8 * i & 0xff;
71
+ switch (msByte & 0xc0) {
72
+ case 0x00:
73
+ return TLVHelpers.UNIVERSAL_CLASS;
74
+ case 0x40:
75
+ return TLVHelpers.APPLICATION_CLASS;
76
+ case 0x80:
77
+ return TLVHelpers.CONTEXT_SPECIFIC_CLASS;
78
+ case 0xc0:
79
+ default:
80
+ return TLVHelpers.PRIVATE_CLASS;
81
+ }
82
+ }
83
+ static log(n, base) {
84
+ let result = 0;
85
+ while (n > 0) {
86
+ n = n / base;
87
+ result++;
88
+ }
89
+ return result;
90
+ }
91
+ }
@@ -2,95 +2,11 @@
2
2
 
3
3
  import { ByteArrayInputStream } from "../java/byteArrayInputStream.js";
4
4
  import { ByteArrayOutputStream } from "../java/byteArrayOutputStream.js";
5
- import { ASN1Constants } from "./asn1Constants.js";
6
5
  import { TLVInputStream } from "./tlvInputStream.js";
7
6
  import { TLVOutputStream } from "./tlvOutputStream.js";
8
7
  import { Buffer } from 'buffer';
9
- class TLVUtil extends ASN1Constants {
10
- static isPrimitive(tag) {
11
- let i = 3;
12
- for (; i >= 0; i--) {
13
- const mask = 0xff << 8 * i;
14
- if ((tag & mask) !== 0x00) {
15
- break;
16
- }
17
- }
18
- const msByte = (tag & 0xff << 8 * i) >> 8 * i & 0xff;
19
- return (msByte & 0x20) === 0x00;
20
- }
21
- static getTagLength(tag) {
22
- return TLVUtil.getTagAsBytes(tag).length;
23
- }
24
- static getLengthLength(length) {
25
- return TLVUtil.getLengthAsBytes(length).length;
26
- }
27
-
28
- /**
29
- * The tag bytes of this object.
30
- *
31
- * @param tag the tag
32
- *
33
- * @return the tag bytes of this object.
34
- */
35
- static getTagAsBytes(tag) {
36
- const out = [];
37
- const byteCount = Math.floor(Math.log(tag) / Math.log(256)) + 1;
38
- for (let i = 0; i < byteCount; i++) {
39
- const pos = 8 * (byteCount - i - 1);
40
- out.push((tag & 0xff << pos) >> pos);
41
- }
42
- const tagBytes = out;
43
- switch (TLVUtil.getTagClass(tag)) {
44
- case TLVUtil.APPLICATION_CLASS:
45
- tagBytes[0] |= 0x40;
46
- break;
47
- case TLVUtil.CONTEXT_SPECIFIC_CLASS:
48
- tagBytes[0] |= 0x80;
49
- break;
50
- case TLVUtil.PRIVATE_CLASS:
51
- tagBytes[0] |= 0xc0;
52
- break;
53
- default:
54
- /* NOTE: Unsupported tag class. Now what? */
55
- break;
56
- }
57
- if (!TLVUtil.isPrimitive(tag)) {
58
- tagBytes[0] |= 0x20;
59
- }
60
- return tagBytes;
61
- }
62
-
63
- /**
64
- * The length bytes of this object.
65
- *
66
- * @param length the length
67
- *
68
- * @return length of encoded value as bytes
69
- */
70
- static getLengthAsBytes(length) {
71
- const out = [];
72
- if (length < 0x80) {
73
- /* short form */
74
- out.push(length);
75
- } else {
76
- const byteCount = TLVUtil.log(length, 256);
77
- out.push(0x80 | byteCount);
78
- for (let i = 0; i < byteCount; i++) {
79
- const pos = 8 * (byteCount - i - 1);
80
- out.push((length & 0xff << pos) >> pos);
81
- }
82
- }
83
- return out;
84
- }
85
-
86
- /**
87
- * TLV encodes an encoded data object with a tag.
88
- *
89
- * @param tag the tag
90
- * @param data the data to encode
91
- *
92
- * @return the TLV encoded data
93
- */
8
+ import { TLVHelpers } from "./tlv.helpers.js";
9
+ class TLVUtil extends TLVHelpers {
94
10
  static wrapDO(tag, data) {
95
11
  if (data == null) {
96
12
  throw new Error('Data to wrap is null');
@@ -114,15 +30,6 @@ class TLVUtil extends ASN1Constants {
114
30
  }
115
31
  }
116
32
  }
117
-
118
- /**
119
- * TLV decodes tagged TLV data object.
120
- *
121
- * @param expectedTag the tag to expect, an {@code IllegalArgumentException} will be throws if a different tag is read
122
- * @param wrappedData the encoded data
123
- *
124
- * @return the decoded data
125
- */
126
33
  static async unwrapDO(expectedTag, wrappedData) {
127
34
  if (wrappedData == null || wrappedData.length < 2) {
128
35
  throw new Error('Wrapped data is null or length < 2');
@@ -153,34 +60,5 @@ class TLVUtil extends ASN1Constants {
153
60
  }
154
61
  }
155
62
  }
156
- static getTagClass(tag) {
157
- let i = 3;
158
- for (; i >= 0; i--) {
159
- const mask = 0xff << 8 * i;
160
- if ((tag & mask) !== 0x00) {
161
- break;
162
- }
163
- }
164
- const msByte = (tag & 0xff << 8 * i) >> 8 * i & 0xff;
165
- switch (msByte & 0xc0) {
166
- case 0x00:
167
- return TLVUtil.UNIVERSAL_CLASS;
168
- case 0x40:
169
- return TLVUtil.APPLICATION_CLASS;
170
- case 0x80:
171
- return TLVUtil.CONTEXT_SPECIFIC_CLASS;
172
- case 0xc0:
173
- default:
174
- return TLVUtil.PRIVATE_CLASS;
175
- }
176
- }
177
- static log(n, base) {
178
- let result = 0;
179
- while (n > 0) {
180
- n = n / base;
181
- result++;
182
- }
183
- return result;
184
- }
185
63
  }
186
64
  export default TLVUtil;
@@ -3,7 +3,7 @@
3
3
  import { ByteArrayInputStream } from "../java/byteArrayInputStream.js";
4
4
  import { DataInputStream } from "../java/dataInputStream.js";
5
5
  import { InputStream } from "../java/inputStream.js";
6
- import TLVUtil from "./tlv.utils.js";
6
+ import { TLVHelpers } from "./tlv.helpers.js";
7
7
  import { TLVInputState } from "./tlvInputState.js";
8
8
  export class TLVInputStream extends InputStream {
9
9
  static MAX_BUFFER_LENGTH = 65535;
@@ -117,11 +117,11 @@ export class TLVInputStream extends InputStream {
117
117
  let tag = -1;
118
118
  if (this.state.getIsAtStartOfTag()) {} else if (this.state.getIsAtStartOfLength()) {
119
119
  await this.readLength();
120
- if (TLVUtil.isPrimitive(this.state.getTag())) {
120
+ if (TLVHelpers.isPrimitive(this.state.getTag())) {
121
121
  await this.skipValue();
122
122
  }
123
123
  } else {
124
- if (TLVUtil.isPrimitive(this.state.getTag())) {
124
+ if (TLVHelpers.isPrimitive(this.state.getTag())) {
125
125
  await this.skipValue();
126
126
  }
127
127
  }
@@ -129,7 +129,7 @@ export class TLVInputStream extends InputStream {
129
129
  if (tag === searchTag) {
130
130
  return;
131
131
  }
132
- if (TLVUtil.isPrimitive(tag)) {
132
+ if (TLVHelpers.isPrimitive(tag)) {
133
133
  const length = await this.readLength();
134
134
  const skippedBytes = await this.skipValue();
135
135
  if (skippedBytes >= length) {