@idmission/websdk-core 0.1.0-rc.1

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 (416) hide show
  1. package/README.md +66 -0
  2. package/dist/attestation/attestationState.d.ts +24 -0
  3. package/dist/attestation/attestationState.d.ts.map +1 -0
  4. package/dist/attestation/attestationState.js +57 -0
  5. package/dist/attestation/clientAttestation.d.ts +40 -0
  6. package/dist/attestation/clientAttestation.d.ts.map +1 -0
  7. package/dist/attestation/clientAttestation.js +19 -0
  8. package/dist/attestation/collectClientAttestation.d.ts +10 -0
  9. package/dist/attestation/collectClientAttestation.d.ts.map +1 -0
  10. package/dist/attestation/collectClientAttestation.js +18 -0
  11. package/dist/attestation/index.d.ts +5 -0
  12. package/dist/attestation/index.d.ts.map +1 -0
  13. package/dist/attestation/index.js +4 -0
  14. package/dist/attestation/nativeAttestationBridge.d.ts +3 -0
  15. package/dist/attestation/nativeAttestationBridge.d.ts.map +1 -0
  16. package/dist/attestation/nativeAttestationBridge.js +38 -0
  17. package/dist/barcode/AAMVAParser.d.ts +77 -0
  18. package/dist/barcode/AAMVAParser.d.ts.map +1 -0
  19. package/dist/barcode/AAMVAParser.js +422 -0
  20. package/dist/barcode/NativeBarcodeDecoder.d.ts +157 -0
  21. package/dist/barcode/NativeBarcodeDecoder.d.ts.map +1 -0
  22. package/dist/barcode/NativeBarcodeDecoder.js +832 -0
  23. package/dist/barcode/Parse.d.ts +6 -0
  24. package/dist/barcode/Parse.d.ts.map +1 -0
  25. package/dist/barcode/Parse.js +148 -0
  26. package/dist/barcode/decodeSummary.d.ts +45 -0
  27. package/dist/barcode/decodeSummary.d.ts.map +1 -0
  28. package/dist/barcode/decodeSummary.js +23 -0
  29. package/dist/barcode/index.d.ts +5 -0
  30. package/dist/barcode/index.d.ts.map +1 -0
  31. package/dist/barcode/index.js +4 -0
  32. package/dist/camera/Camera.d.ts +37 -0
  33. package/dist/camera/Camera.d.ts.map +1 -0
  34. package/dist/camera/Camera.js +453 -0
  35. package/dist/camera/acquireCamera.d.ts +29 -0
  36. package/dist/camera/acquireCamera.d.ts.map +1 -0
  37. package/dist/camera/acquireCamera.js +224 -0
  38. package/dist/camera/cameraSignals.d.ts +23 -0
  39. package/dist/camera/cameraSignals.d.ts.map +1 -0
  40. package/dist/camera/cameraSignals.js +32 -0
  41. package/dist/camera/getUserMediaIntegrity.d.ts +72 -0
  42. package/dist/camera/getUserMediaIntegrity.d.ts.map +1 -0
  43. package/dist/camera/getUserMediaIntegrity.js +256 -0
  44. package/dist/camera/index.d.ts +6 -0
  45. package/dist/camera/index.d.ts.map +1 -0
  46. package/dist/camera/index.js +5 -0
  47. package/dist/camera/isVirtualCamera.d.ts +10 -0
  48. package/dist/camera/isVirtualCamera.d.ts.map +1 -0
  49. package/dist/camera/isVirtualCamera.js +11 -0
  50. package/dist/client/IdmissionClient.d.ts +151 -0
  51. package/dist/client/IdmissionClient.d.ts.map +1 -0
  52. package/dist/client/IdmissionClient.js +638 -0
  53. package/dist/client/additionalDocument.d.ts +14 -0
  54. package/dist/client/additionalDocument.d.ts.map +1 -0
  55. package/dist/client/additionalDocument.js +24 -0
  56. package/dist/client/artifacts.d.ts +146 -0
  57. package/dist/client/artifacts.d.ts.map +1 -0
  58. package/dist/client/artifacts.js +1 -0
  59. package/dist/client/blobToB64.d.ts +2 -0
  60. package/dist/client/blobToB64.d.ts.map +1 -0
  61. package/dist/client/blobToB64.js +17 -0
  62. package/dist/client/endpoints.d.ts +7 -0
  63. package/dist/client/endpoints.d.ts.map +1 -0
  64. package/dist/client/endpoints.js +59 -0
  65. package/dist/client/errors.d.ts +20 -0
  66. package/dist/client/errors.d.ts.map +1 -0
  67. package/dist/client/errors.js +45 -0
  68. package/dist/client/index.d.ts +23 -0
  69. package/dist/client/index.d.ts.map +1 -0
  70. package/dist/client/index.js +38 -0
  71. package/dist/client/payload.d.ts +36 -0
  72. package/dist/client/payload.d.ts.map +1 -0
  73. package/dist/client/payload.js +397 -0
  74. package/dist/client/sessionMachine.d.ts +26 -0
  75. package/dist/client/sessionMachine.d.ts.map +1 -0
  76. package/dist/client/sessionMachine.js +23 -0
  77. package/dist/client/submissionMetadata.d.ts +31 -0
  78. package/dist/client/submissionMetadata.d.ts.map +1 -0
  79. package/dist/client/submissionMetadata.js +90 -0
  80. package/dist/client/timings.d.ts +49 -0
  81. package/dist/client/timings.d.ts.map +1 -0
  82. package/dist/client/timings.js +32 -0
  83. package/dist/client/types.d.ts +305 -0
  84. package/dist/client/types.d.ts.map +1 -0
  85. package/dist/client/types.js +18 -0
  86. package/dist/client/upload.d.ts +60 -0
  87. package/dist/client/upload.d.ts.map +1 -0
  88. package/dist/client/upload.js +313 -0
  89. package/dist/client/uploadedDocument.d.ts +7 -0
  90. package/dist/client/uploadedDocument.d.ts.map +1 -0
  91. package/dist/client/uploadedDocument.js +4 -0
  92. package/dist/client/urls.d.ts +30 -0
  93. package/dist/client/urls.d.ts.map +1 -0
  94. package/dist/client/urls.js +73 -0
  95. package/dist/client/validateSession.d.ts +7 -0
  96. package/dist/client/validateSession.d.ts.map +1 -0
  97. package/dist/client/validateSession.js +63 -0
  98. package/dist/config/cdn.d.ts +2 -0
  99. package/dist/config/cdn.d.ts.map +1 -0
  100. package/dist/config/cdn.js +1 -0
  101. package/dist/diagnostics/buffer.d.ts +8 -0
  102. package/dist/diagnostics/buffer.d.ts.map +1 -0
  103. package/dist/diagnostics/buffer.js +25 -0
  104. package/dist/diagnostics/envCapability.d.ts +3 -0
  105. package/dist/diagnostics/envCapability.d.ts.map +1 -0
  106. package/dist/diagnostics/envCapability.js +40 -0
  107. package/dist/diagnostics/floodControl.d.ts +6 -0
  108. package/dist/diagnostics/floodControl.d.ts.map +1 -0
  109. package/dist/diagnostics/floodControl.js +29 -0
  110. package/dist/diagnostics/index.d.ts +8 -0
  111. package/dist/diagnostics/index.d.ts.map +1 -0
  112. package/dist/diagnostics/index.js +17 -0
  113. package/dist/diagnostics/install.d.ts +20 -0
  114. package/dist/diagnostics/install.d.ts.map +1 -0
  115. package/dist/diagnostics/install.js +159 -0
  116. package/dist/diagnostics/redaction.d.ts +7 -0
  117. package/dist/diagnostics/redaction.d.ts.map +1 -0
  118. package/dist/diagnostics/redaction.js +73 -0
  119. package/dist/diagnostics/transport.d.ts +15 -0
  120. package/dist/diagnostics/transport.d.ts.map +1 -0
  121. package/dist/diagnostics/transport.js +35 -0
  122. package/dist/diagnostics/types.d.ts +59 -0
  123. package/dist/diagnostics/types.d.ts.map +1 -0
  124. package/dist/diagnostics/types.js +1 -0
  125. package/dist/documentCapture/controller.d.ts +35 -0
  126. package/dist/documentCapture/controller.d.ts.map +1 -0
  127. package/dist/documentCapture/controller.js +254 -0
  128. package/dist/documentCapture/index.d.ts +4 -0
  129. package/dist/documentCapture/index.d.ts.map +1 -0
  130. package/dist/documentCapture/index.js +8 -0
  131. package/dist/documentCapture/reducer.d.ts +31 -0
  132. package/dist/documentCapture/reducer.d.ts.map +1 -0
  133. package/dist/documentCapture/reducer.js +87 -0
  134. package/dist/documentCapture/state.d.ts +49 -0
  135. package/dist/documentCapture/state.d.ts.map +1 -0
  136. package/dist/documentCapture/state.js +36 -0
  137. package/dist/idCapture/controller.d.ts +228 -0
  138. package/dist/idCapture/controller.d.ts.map +1 -0
  139. package/dist/idCapture/controller.js +1453 -0
  140. package/dist/idCapture/errors.d.ts +36 -0
  141. package/dist/idCapture/errors.d.ts.map +1 -0
  142. package/dist/idCapture/errors.js +18 -0
  143. package/dist/idCapture/guidance.d.ts +80 -0
  144. package/dist/idCapture/guidance.d.ts.map +1 -0
  145. package/dist/idCapture/guidance.js +143 -0
  146. package/dist/idCapture/index.d.ts +22 -0
  147. package/dist/idCapture/index.d.ts.map +1 -0
  148. package/dist/idCapture/index.js +46 -0
  149. package/dist/idCapture/phase.d.ts +10 -0
  150. package/dist/idCapture/phase.d.ts.map +1 -0
  151. package/dist/idCapture/phase.js +28 -0
  152. package/dist/idCapture/pipeline.d.ts +176 -0
  153. package/dist/idCapture/pipeline.d.ts.map +1 -0
  154. package/dist/idCapture/pipeline.js +1028 -0
  155. package/dist/idCapture/reducer.d.ts +3 -0
  156. package/dist/idCapture/reducer.d.ts.map +1 -0
  157. package/dist/idCapture/reducer.js +661 -0
  158. package/dist/idCapture/requirements.d.ts +10 -0
  159. package/dist/idCapture/requirements.d.ts.map +1 -0
  160. package/dist/idCapture/requirements.js +43 -0
  161. package/dist/idCapture/stabilizer.d.ts +2 -0
  162. package/dist/idCapture/stabilizer.d.ts.map +1 -0
  163. package/dist/idCapture/stabilizer.js +4 -0
  164. package/dist/idCapture/state.d.ts +426 -0
  165. package/dist/idCapture/state.d.ts.map +1 -0
  166. package/dist/idCapture/state.js +91 -0
  167. package/dist/idCapture/submit.d.ts +33 -0
  168. package/dist/idCapture/submit.d.ts.map +1 -0
  169. package/dist/idCapture/submit.js +105 -0
  170. package/dist/idCapture/types.d.ts +20 -0
  171. package/dist/idCapture/types.d.ts.map +1 -0
  172. package/dist/idCapture/types.js +12 -0
  173. package/dist/index.d.ts +6 -0
  174. package/dist/index.d.ts.map +1 -0
  175. package/dist/index.js +5 -0
  176. package/dist/liveness/challengeGeometry.d.ts +66 -0
  177. package/dist/liveness/challengeGeometry.d.ts.map +1 -0
  178. package/dist/liveness/challengeGeometry.js +226 -0
  179. package/dist/liveness/challengeSequence.d.ts +49 -0
  180. package/dist/liveness/challengeSequence.d.ts.map +1 -0
  181. package/dist/liveness/challengeSequence.js +71 -0
  182. package/dist/liveness/index.d.ts +4 -0
  183. package/dist/liveness/index.d.ts.map +1 -0
  184. package/dist/liveness/index.js +3 -0
  185. package/dist/liveness/livenessResult.d.ts +11 -0
  186. package/dist/liveness/livenessResult.d.ts.map +1 -0
  187. package/dist/liveness/livenessResult.js +16 -0
  188. package/dist/models/BarcodeReadability.d.ts +36 -0
  189. package/dist/models/BarcodeReadability.d.ts.map +1 -0
  190. package/dist/models/BarcodeReadability.js +71 -0
  191. package/dist/models/CapabilityProbing.d.ts +25 -0
  192. package/dist/models/CapabilityProbing.d.ts.map +1 -0
  193. package/dist/models/CapabilityProbing.js +172 -0
  194. package/dist/models/DocumentDetection.d.ts +96 -0
  195. package/dist/models/DocumentDetection.d.ts.map +1 -0
  196. package/dist/models/DocumentDetection.js +257 -0
  197. package/dist/models/FaceDetection.d.ts +21 -0
  198. package/dist/models/FaceDetection.d.ts.map +1 -0
  199. package/dist/models/FaceDetection.js +4 -0
  200. package/dist/models/Focus.d.ts +36 -0
  201. package/dist/models/Focus.d.ts.map +1 -0
  202. package/dist/models/Focus.js +69 -0
  203. package/dist/models/FrameLoop.d.ts +13 -0
  204. package/dist/models/FrameLoop.d.ts.map +1 -0
  205. package/dist/models/FrameLoop.js +56 -0
  206. package/dist/models/VisionRuntime.d.ts +18 -0
  207. package/dist/models/VisionRuntime.d.ts.map +1 -0
  208. package/dist/models/VisionRuntime.js +158 -0
  209. package/dist/models/defaults/BarcodeReadability.d.ts +3 -0
  210. package/dist/models/defaults/BarcodeReadability.d.ts.map +1 -0
  211. package/dist/models/defaults/BarcodeReadability.js +3 -0
  212. package/dist/models/defaults/BarcodeReadabilityLiteRT.d.ts +3 -0
  213. package/dist/models/defaults/BarcodeReadabilityLiteRT.d.ts.map +1 -0
  214. package/dist/models/defaults/BarcodeReadabilityLiteRT.js +3 -0
  215. package/dist/models/defaults/DocumentDetector.d.ts +3 -0
  216. package/dist/models/defaults/DocumentDetector.d.ts.map +1 -0
  217. package/dist/models/defaults/DocumentDetector.js +3 -0
  218. package/dist/models/defaults/DocumentDetectorLiteRT.d.ts +3 -0
  219. package/dist/models/defaults/DocumentDetectorLiteRT.d.ts.map +1 -0
  220. package/dist/models/defaults/DocumentDetectorLiteRT.js +3 -0
  221. package/dist/models/defaults/FaceDetector.d.ts +3 -0
  222. package/dist/models/defaults/FaceDetector.d.ts.map +1 -0
  223. package/dist/models/defaults/FaceDetector.js +3 -0
  224. package/dist/models/defaults/FaceLandmarker.d.ts +3 -0
  225. package/dist/models/defaults/FaceLandmarker.d.ts.map +1 -0
  226. package/dist/models/defaults/FaceLandmarker.js +8 -0
  227. package/dist/models/defaults/FaceLandmarkerLiteRT.d.ts +3 -0
  228. package/dist/models/defaults/FaceLandmarkerLiteRT.d.ts.map +1 -0
  229. package/dist/models/defaults/FaceLandmarkerLiteRT.js +3 -0
  230. package/dist/models/defaults/Focus.d.ts +3 -0
  231. package/dist/models/defaults/Focus.d.ts.map +1 -0
  232. package/dist/models/defaults/Focus.js +3 -0
  233. package/dist/models/defaults/FocusLiteRT.d.ts +3 -0
  234. package/dist/models/defaults/FocusLiteRT.d.ts.map +1 -0
  235. package/dist/models/defaults/FocusLiteRT.js +3 -0
  236. package/dist/models/defaults/index.d.ts +31 -0
  237. package/dist/models/defaults/index.d.ts.map +1 -0
  238. package/dist/models/defaults/index.js +38 -0
  239. package/dist/models/helpers.d.ts +25 -0
  240. package/dist/models/helpers.d.ts.map +1 -0
  241. package/dist/models/helpers.js +98 -0
  242. package/dist/models/index.d.ts +15 -0
  243. package/dist/models/index.d.ts.map +1 -0
  244. package/dist/models/index.js +14 -0
  245. package/dist/models/modelLifecycle.d.ts +26 -0
  246. package/dist/models/modelLifecycle.d.ts.map +1 -0
  247. package/dist/models/modelLifecycle.js +137 -0
  248. package/dist/models/occlusion.d.ts +20 -0
  249. package/dist/models/occlusion.d.ts.map +1 -0
  250. package/dist/models/occlusion.js +109 -0
  251. package/dist/models/passportBooklet.d.ts +34 -0
  252. package/dist/models/passportBooklet.d.ts.map +1 -0
  253. package/dist/models/passportBooklet.js +152 -0
  254. package/dist/models/preloadModels.d.ts +42 -0
  255. package/dist/models/preloadModels.d.ts.map +1 -0
  256. package/dist/models/preloadModels.js +204 -0
  257. package/dist/models/providers/litert/BarcodeReadability.d.ts +11 -0
  258. package/dist/models/providers/litert/BarcodeReadability.d.ts.map +1 -0
  259. package/dist/models/providers/litert/BarcodeReadability.js +135 -0
  260. package/dist/models/providers/litert/CapabilityProbe.d.ts +3 -0
  261. package/dist/models/providers/litert/CapabilityProbe.d.ts.map +1 -0
  262. package/dist/models/providers/litert/CapabilityProbe.js +44 -0
  263. package/dist/models/providers/litert/DocumentDetection.d.ts +18 -0
  264. package/dist/models/providers/litert/DocumentDetection.d.ts.map +1 -0
  265. package/dist/models/providers/litert/DocumentDetection.js +194 -0
  266. package/dist/models/providers/litert/FaceDetection.d.ts +11 -0
  267. package/dist/models/providers/litert/FaceDetection.d.ts.map +1 -0
  268. package/dist/models/providers/litert/FaceDetection.js +204 -0
  269. package/dist/models/providers/litert/FaceLandmarker.d.ts +11 -0
  270. package/dist/models/providers/litert/FaceLandmarker.d.ts.map +1 -0
  271. package/dist/models/providers/litert/FaceLandmarker.js +199 -0
  272. package/dist/models/providers/litert/Focus.d.ts +11 -0
  273. package/dist/models/providers/litert/Focus.d.ts.map +1 -0
  274. package/dist/models/providers/litert/Focus.js +141 -0
  275. package/dist/models/providers/litert/barcodeReadabilityPrePost.d.ts +6 -0
  276. package/dist/models/providers/litert/barcodeReadabilityPrePost.d.ts.map +1 -0
  277. package/dist/models/providers/litert/barcodeReadabilityPrePost.js +68 -0
  278. package/dist/models/providers/litert/blazeFacePrePost.d.ts +30 -0
  279. package/dist/models/providers/litert/blazeFacePrePost.d.ts.map +1 -0
  280. package/dist/models/providers/litert/blazeFacePrePost.js +206 -0
  281. package/dist/models/providers/litert/docDetectPrePost.d.ts +25 -0
  282. package/dist/models/providers/litert/docDetectPrePost.d.ts.map +1 -0
  283. package/dist/models/providers/litert/docDetectPrePost.js +197 -0
  284. package/dist/models/providers/litert/faceMeshPrePost.d.ts +23 -0
  285. package/dist/models/providers/litert/faceMeshPrePost.d.ts.map +1 -0
  286. package/dist/models/providers/litert/faceMeshPrePost.js +86 -0
  287. package/dist/models/providers/litert/focusPrePost.d.ts +6 -0
  288. package/dist/models/providers/litert/focusPrePost.d.ts.map +1 -0
  289. package/dist/models/providers/litert/focusPrePost.js +67 -0
  290. package/dist/models/providers/litert/runtime.d.ts +14 -0
  291. package/dist/models/providers/litert/runtime.d.ts.map +1 -0
  292. package/dist/models/providers/litert/runtime.js +83 -0
  293. package/dist/models/providers/mediapipe/BarcodeReadability.d.ts +11 -0
  294. package/dist/models/providers/mediapipe/BarcodeReadability.d.ts.map +1 -0
  295. package/dist/models/providers/mediapipe/BarcodeReadability.js +68 -0
  296. package/dist/models/providers/mediapipe/CapabilityProbe.d.ts +2 -0
  297. package/dist/models/providers/mediapipe/CapabilityProbe.d.ts.map +1 -0
  298. package/dist/models/providers/mediapipe/CapabilityProbe.js +14 -0
  299. package/dist/models/providers/mediapipe/DocumentDetection.d.ts +12 -0
  300. package/dist/models/providers/mediapipe/DocumentDetection.d.ts.map +1 -0
  301. package/dist/models/providers/mediapipe/DocumentDetection.js +90 -0
  302. package/dist/models/providers/mediapipe/FaceDetection.d.ts +11 -0
  303. package/dist/models/providers/mediapipe/FaceDetection.d.ts.map +1 -0
  304. package/dist/models/providers/mediapipe/FaceDetection.js +93 -0
  305. package/dist/models/providers/mediapipe/FaceLandmarker.d.ts +46 -0
  306. package/dist/models/providers/mediapipe/FaceLandmarker.d.ts.map +1 -0
  307. package/dist/models/providers/mediapipe/FaceLandmarker.js +166 -0
  308. package/dist/models/providers/mediapipe/Focus.d.ts +11 -0
  309. package/dist/models/providers/mediapipe/Focus.d.ts.map +1 -0
  310. package/dist/models/providers/mediapipe/Focus.js +51 -0
  311. package/dist/models/runtimeSelection.d.ts +5 -0
  312. package/dist/models/runtimeSelection.d.ts.map +1 -0
  313. package/dist/models/runtimeSelection.js +21 -0
  314. package/dist/selfieCapture/challengeRunner.d.ts +38 -0
  315. package/dist/selfieCapture/challengeRunner.d.ts.map +1 -0
  316. package/dist/selfieCapture/challengeRunner.js +181 -0
  317. package/dist/selfieCapture/controller.d.ts +166 -0
  318. package/dist/selfieCapture/controller.d.ts.map +1 -0
  319. package/dist/selfieCapture/controller.js +1253 -0
  320. package/dist/selfieCapture/faceTracking.d.ts +67 -0
  321. package/dist/selfieCapture/faceTracking.d.ts.map +1 -0
  322. package/dist/selfieCapture/faceTracking.js +158 -0
  323. package/dist/selfieCapture/guidance.d.ts +24 -0
  324. package/dist/selfieCapture/guidance.d.ts.map +1 -0
  325. package/dist/selfieCapture/guidance.js +41 -0
  326. package/dist/selfieCapture/index.d.ts +18 -0
  327. package/dist/selfieCapture/index.d.ts.map +1 -0
  328. package/dist/selfieCapture/index.js +11 -0
  329. package/dist/selfieCapture/lighting.d.ts +36 -0
  330. package/dist/selfieCapture/lighting.d.ts.map +1 -0
  331. package/dist/selfieCapture/lighting.js +95 -0
  332. package/dist/selfieCapture/livenessMachine.d.ts +66 -0
  333. package/dist/selfieCapture/livenessMachine.d.ts.map +1 -0
  334. package/dist/selfieCapture/livenessMachine.js +137 -0
  335. package/dist/selfieCapture/pipeline.d.ts +42 -0
  336. package/dist/selfieCapture/pipeline.d.ts.map +1 -0
  337. package/dist/selfieCapture/pipeline.js +282 -0
  338. package/dist/selfieCapture/reducer.d.ts +35 -0
  339. package/dist/selfieCapture/reducer.d.ts.map +1 -0
  340. package/dist/selfieCapture/reducer.js +143 -0
  341. package/dist/selfieCapture/state.d.ts +40 -0
  342. package/dist/selfieCapture/state.d.ts.map +1 -0
  343. package/dist/selfieCapture/state.js +36 -0
  344. package/dist/selfieCapture/testing/challengeFixtures.d.ts +43 -0
  345. package/dist/selfieCapture/testing/challengeFixtures.d.ts.map +1 -0
  346. package/dist/selfieCapture/testing/challengeFixtures.js +43 -0
  347. package/dist/signature/frameDecode.d.ts +48 -0
  348. package/dist/signature/frameDecode.d.ts.map +1 -0
  349. package/dist/signature/frameDecode.js +491 -0
  350. package/dist/signature/index.d.ts +5 -0
  351. package/dist/signature/index.d.ts.map +1 -0
  352. package/dist/signature/index.js +4 -0
  353. package/dist/signature/metadata.d.ts +63 -0
  354. package/dist/signature/metadata.d.ts.map +1 -0
  355. package/dist/signature/metadata.js +1 -0
  356. package/dist/signature/quality.d.ts +169 -0
  357. package/dist/signature/quality.d.ts.map +1 -0
  358. package/dist/signature/quality.js +186 -0
  359. package/dist/signature/signatureValidity.d.ts +149 -0
  360. package/dist/signature/signatureValidity.d.ts.map +1 -0
  361. package/dist/signature/signatureValidity.js +305 -0
  362. package/dist/signatureCapture/controller.d.ts +67 -0
  363. package/dist/signatureCapture/controller.d.ts.map +1 -0
  364. package/dist/signatureCapture/controller.js +534 -0
  365. package/dist/signatureCapture/guidance.d.ts +9 -0
  366. package/dist/signatureCapture/guidance.d.ts.map +1 -0
  367. package/dist/signatureCapture/guidance.js +7 -0
  368. package/dist/signatureCapture/index.d.ts +6 -0
  369. package/dist/signatureCapture/index.d.ts.map +1 -0
  370. package/dist/signatureCapture/index.js +5 -0
  371. package/dist/signatureCapture/pipeline.d.ts +111 -0
  372. package/dist/signatureCapture/pipeline.d.ts.map +1 -0
  373. package/dist/signatureCapture/pipeline.js +680 -0
  374. package/dist/signatureCapture/reducer.d.ts +42 -0
  375. package/dist/signatureCapture/reducer.d.ts.map +1 -0
  376. package/dist/signatureCapture/reducer.js +159 -0
  377. package/dist/signatureCapture/state.d.ts +92 -0
  378. package/dist/signatureCapture/state.d.ts.map +1 -0
  379. package/dist/signatureCapture/state.js +24 -0
  380. package/dist/utils/canvas.d.ts +4 -0
  381. package/dist/utils/canvas.d.ts.map +1 -0
  382. package/dist/utils/canvas.js +21 -0
  383. package/dist/utils/cropping.d.ts +8 -0
  384. package/dist/utils/cropping.d.ts.map +1 -0
  385. package/dist/utils/cropping.js +85 -0
  386. package/dist/utils/dataUrlToBase64.d.ts +7 -0
  387. package/dist/utils/dataUrlToBase64.d.ts.map +1 -0
  388. package/dist/utils/dataUrlToBase64.js +67 -0
  389. package/dist/utils/getFrameDimensions.d.ts +3 -0
  390. package/dist/utils/getFrameDimensions.d.ts.map +1 -0
  391. package/dist/utils/getFrameDimensions.js +12 -0
  392. package/dist/utils/isMobile.d.ts +3 -0
  393. package/dist/utils/isMobile.d.ts.map +1 -0
  394. package/dist/utils/isMobile.js +36 -0
  395. package/dist/utils/logger.d.ts +19 -0
  396. package/dist/utils/logger.d.ts.map +1 -0
  397. package/dist/utils/logger.js +25 -0
  398. package/dist/utils/platform.d.ts +4 -0
  399. package/dist/utils/platform.d.ts.map +1 -0
  400. package/dist/utils/platform.js +11 -0
  401. package/dist/utils/stabilizer.d.ts +26 -0
  402. package/dist/utils/stabilizer.d.ts.map +1 -0
  403. package/dist/utils/stabilizer.js +65 -0
  404. package/dist/version.d.ts +2 -0
  405. package/dist/version.d.ts.map +1 -0
  406. package/dist/version.js +1 -0
  407. package/dist/videoIdCapture/controller.d.ts +108 -0
  408. package/dist/videoIdCapture/controller.d.ts.map +1 -0
  409. package/dist/videoIdCapture/controller.js +833 -0
  410. package/dist/videoIdCapture/index.d.ts +5 -0
  411. package/dist/videoIdCapture/index.d.ts.map +1 -0
  412. package/dist/videoIdCapture/index.js +2 -0
  413. package/dist/videoIdCapture/state.d.ts +88 -0
  414. package/dist/videoIdCapture/state.d.ts.map +1 -0
  415. package/dist/videoIdCapture/state.js +67 -0
  416. package/package.json +111 -0
@@ -0,0 +1,25 @@
1
+ export declare const DOC_DETECT_INPUT_SIZE = 300;
2
+ export declare const DOC_DETECT_LABEL_MAP: Record<number, string>;
3
+ export declare const DEFAULT_SCALE_FACTORS: readonly [number, number, number, number];
4
+ export type DocDetection = {
5
+ classId: number;
6
+ label: string;
7
+ score: number;
8
+ xMin: number;
9
+ yMin: number;
10
+ xMax: number;
11
+ yMax: number;
12
+ };
13
+ export declare function preprocessFrame(source: HTMLVideoElement | HTMLCanvasElement): Uint8Array<ArrayBuffer>;
14
+ export type RawOutputs = {
15
+ boxEncodings: Float32Array;
16
+ classPredictions: Float32Array;
17
+ anchors: Float32Array;
18
+ };
19
+ export type RawDecodeOptions = {
20
+ scoreThreshold?: number;
21
+ iouThreshold?: number;
22
+ scaleFactors?: readonly [number, number, number, number];
23
+ };
24
+ export declare function decodeRawDetections(outputs: RawOutputs, options: RawDecodeOptions): DocDetection[];
25
+ //# sourceMappingURL=docDetectPrePost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docDetectPrePost.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/litert/docDetectPrePost.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAYzC,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0BvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CACpD,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAGd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAyBF,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,GAC3C,UAAU,CAAC,WAAW,CAAC,CAgBzB;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,YAAY,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1D,CAAC;AA4BF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,gBAAgB,GACxB,YAAY,EAAE,CA2FhB"}
@@ -0,0 +1,197 @@
1
+ // Pre/post-processing for the DocumentDetector .tflite — raw SSD outputs
2
+ // (post-stripping of the embedded `TFLite_Detection_PostProcess` head).
3
+ //
4
+ // Input contract:
5
+ // `input` — uint8 [1, 300, 300, 3], stretch-resized RGB. The model is
6
+ // quantized for `(px - 127.5) / 127.5` input normalization with
7
+ // scale ≈ 2/255 and zero_point ≈ 128, which means raw 0-255 pixel bytes
8
+ // are a close enough quantized representation that the model produces
9
+ // sensible outputs without explicit dequant/requant on the input.
10
+ //
11
+ // Output contract (three float32 tensors). The 20260602 re-export renamed the
12
+ // outputs to generic `StatefulPartitionedCall:N` (LiteRT.js surfaces these as
13
+ // `output_N`) and reordered them, so the loader identifies them by shape+dtype,
14
+ // not name (see providers/litert/DocumentDetection.ts):
15
+ // box encodings — float32 [1, 1917, 4] (ty, tx, th, tw) deltas
16
+ // class predictions — float32 [1, 1917, 23] per-anchor scores (class 0 = background)
17
+ // anchors — float32 [1917, 4] (ycenter, xcenter, h, w) priors
18
+ //
19
+ // This export is NOT quantized — outputs are float32 and consumed directly,
20
+ // with no dequantization step. The class output has sigmoid applied *inside*
21
+ // the model graph, so values are scores in [0, 1] directly — do NOT re-apply
22
+ // sigmoid client-side. (The earlier export was uint8-quantized and required
23
+ // per-tensor scale/zero_point that LiteRT.js doesn't surface; the float export
24
+ // removes that fragility.)
25
+ //
26
+ // Decode uses the standard TF Object Detection API SSD formula:
27
+ // w = exp(tw / w_scale) * wa
28
+ // h = exp(th / h_scale) * ha
29
+ // ycenter = ty / y_scale * ha + ycenter_a
30
+ // xcenter = tx / x_scale * wa + xcenter_a
31
+ // with scale factors (10, 10, 5, 5). Per-class NMS is applied client-side.
32
+ export const DOC_DETECT_INPUT_SIZE = 300;
33
+ // Class index → human-readable label, per the ML team's `label_map`. This map
34
+ // is LiteRT-model-specific — the MediaPipe detector carries its own labels
35
+ // embedded in its .tflite. The two are kept separate on purpose: the models
36
+ // number their classes differently, so the only safe interop surface is the
37
+ // resulting label *string* (matched in the shared DocumentDetection.ts).
38
+ // The raw model emits class indices 0..22 where 0 is background; the
39
+ // remaining 1..22 map directly to these labels (no further offset needed —
40
+ // the team's "+1" instruction applies to a different indexing convention
41
+ // that we don't use here, since our loop already skips background and
42
+ // preserves the model's 1-based class index).
43
+ export const DOC_DETECT_LABEL_MAP = {
44
+ 1: "Document",
45
+ 2: "MRZ",
46
+ 3: "PDF417",
47
+ 4: "Primary face",
48
+ 5: "Secondary face",
49
+ 6: "Glare",
50
+ 7: "Punch Hole",
51
+ 8: "Passport page",
52
+ 9: "Hologram",
53
+ 10: "Primary signature",
54
+ 11: "Official signature",
55
+ 12: "1-D barcode",
56
+ 13: "QR code",
57
+ 14: "Fingerprint",
58
+ 15: "Finger",
59
+ 16: "Real ID star",
60
+ 17: "Watermark",
61
+ 18: "NFC chip",
62
+ 19: "Issuer emblem",
63
+ 20: "Document back",
64
+ 21: "Document title",
65
+ // "Single page" resolves to detectedDocumentType="singlePage" in the shared
66
+ // post-processor (DocumentDetection.ts). The string must match the MediaPipe
67
+ // model's label for the same concept so both runtimes route identically.
68
+ 22: "Single page",
69
+ };
70
+ export const DEFAULT_SCALE_FACTORS = [10.0, 10.0, 5.0, 5.0];
71
+ let preprocessCanvas = null;
72
+ let preprocessCtx = null;
73
+ function getPreprocessContext() {
74
+ if (!preprocessCtx) {
75
+ preprocessCanvas = document.createElement("canvas");
76
+ preprocessCanvas.width = DOC_DETECT_INPUT_SIZE;
77
+ preprocessCanvas.height = DOC_DETECT_INPUT_SIZE;
78
+ const ctx = preprocessCanvas.getContext("2d", { willReadFrequently: true });
79
+ if (!ctx)
80
+ throw new Error("docDetectPrePost: 2d context unavailable");
81
+ preprocessCtx = ctx;
82
+ }
83
+ return preprocessCtx;
84
+ }
85
+ // Stretch-resize into 300×300 NHWC uint8. The reference Python script uses
86
+ // a direct cv2.resize with no letterboxing.
87
+ //
88
+ // Return type narrows to `Uint8Array<ArrayBuffer>` (not the default
89
+ // `Uint8Array<ArrayBufferLike>`) because we always allocate a fresh
90
+ // `new Uint8Array(numel)` here, never a SharedArrayBuffer view. The
91
+ // narrower type lets the result flow into `Tensor.fromTypedArray` without
92
+ // a downstream cast.
93
+ export function preprocessFrame(source) {
94
+ const ctx = getPreprocessContext();
95
+ ctx.drawImage(source, 0, 0, DOC_DETECT_INPUT_SIZE, DOC_DETECT_INPUT_SIZE);
96
+ const pixels = ctx.getImageData(0, 0, DOC_DETECT_INPUT_SIZE, DOC_DETECT_INPUT_SIZE).data;
97
+ const out = new Uint8Array(DOC_DETECT_INPUT_SIZE * DOC_DETECT_INPUT_SIZE * 3);
98
+ for (let i = 0, j = 0; i < pixels.length; i += 4, j += 3) {
99
+ out[j] = pixels[i];
100
+ out[j + 1] = pixels[i + 1];
101
+ out[j + 2] = pixels[i + 2];
102
+ }
103
+ return out;
104
+ }
105
+ function iou(ay0, ax0, ay1, ax1, by0, bx0, by1, bx1) {
106
+ const interY0 = Math.max(ay0, by0);
107
+ const interX0 = Math.max(ax0, bx0);
108
+ const interY1 = Math.min(ay1, by1);
109
+ const interX1 = Math.min(ax1, bx1);
110
+ const interW = Math.max(0, interX1 - interX0);
111
+ const interH = Math.max(0, interY1 - interY0);
112
+ const inter = interW * interH;
113
+ const aArea = Math.max(0, ax1 - ax0) * Math.max(0, ay1 - ay0);
114
+ const bArea = Math.max(0, bx1 - bx0) * Math.max(0, by1 - by0);
115
+ const union = aArea + bArea - inter;
116
+ return union <= 0 ? 0 : inter / union;
117
+ }
118
+ // Decode the three raw SSD outputs into a final detection list. Skips class
119
+ // 0 (background); reads class scores directly (sigmoid is baked into the
120
+ // model graph); applies per-class NMS.
121
+ export function decodeRawDetections(outputs, options) {
122
+ const scoreThreshold = options.scoreThreshold ?? 0.3;
123
+ const iouThreshold = options.iouThreshold ?? 0.5;
124
+ const [yScale, xScale, hScale, wScale] = options.scaleFactors ?? DEFAULT_SCALE_FACTORS;
125
+ const anchors = outputs.anchors;
126
+ const numAnchors = anchors.length / 4;
127
+ if (outputs.boxEncodings.length !== numAnchors * 4)
128
+ return [];
129
+ if (outputs.classPredictions.length % numAnchors !== 0)
130
+ return [];
131
+ const numClasses = outputs.classPredictions.length / numAnchors;
132
+ // Decode all anchor boxes up-front; per-class NMS reuses these.
133
+ const decoded = new Float32Array(numAnchors * 4);
134
+ for (let i = 0; i < numAnchors; i++) {
135
+ const ay = anchors[i * 4];
136
+ const ax = anchors[i * 4 + 1];
137
+ const ah = anchors[i * 4 + 2];
138
+ const aw = anchors[i * 4 + 3];
139
+ const ty = outputs.boxEncodings[i * 4];
140
+ const tx = outputs.boxEncodings[i * 4 + 1];
141
+ const th = outputs.boxEncodings[i * 4 + 2];
142
+ const tw = outputs.boxEncodings[i * 4 + 3];
143
+ const w = Math.exp(tw / wScale) * aw;
144
+ const h = Math.exp(th / hScale) * ah;
145
+ const yc = (ty / yScale) * ah + ay;
146
+ const xc = (tx / xScale) * aw + ax;
147
+ decoded[i * 4] = yc - h / 2;
148
+ decoded[i * 4 + 1] = xc - w / 2;
149
+ decoded[i * 4 + 2] = yc + h / 2;
150
+ decoded[i * 4 + 3] = xc + w / 2;
151
+ }
152
+ // Per-class NMS. Class 0 is background; classes 1..numClasses-1 are real
153
+ // and align with the 1-based DOC_DETECT_LABEL_MAP.
154
+ const detections = [];
155
+ for (let c = 1; c < numClasses; c++) {
156
+ const candidates = [];
157
+ for (let i = 0; i < numAnchors; i++) {
158
+ const score = outputs.classPredictions[i * numClasses + c];
159
+ if (score >= scoreThreshold) {
160
+ candidates.push({ score, idx: i });
161
+ }
162
+ }
163
+ if (candidates.length === 0)
164
+ continue;
165
+ candidates.sort((a, b) => b.score - a.score);
166
+ const suppressed = new Array(candidates.length).fill(false);
167
+ const label = DOC_DETECT_LABEL_MAP[c] ?? `class_${c}`;
168
+ for (let i = 0; i < candidates.length; i++) {
169
+ if (suppressed[i])
170
+ continue;
171
+ const ai = candidates[i].idx;
172
+ const ay0 = decoded[ai * 4];
173
+ const ax0 = decoded[ai * 4 + 1];
174
+ const ay1 = decoded[ai * 4 + 2];
175
+ const ax1 = decoded[ai * 4 + 3];
176
+ detections.push({
177
+ classId: c,
178
+ label,
179
+ score: candidates[i].score,
180
+ yMin: ay0,
181
+ xMin: ax0,
182
+ yMax: ay1,
183
+ xMax: ax1,
184
+ });
185
+ for (let j = i + 1; j < candidates.length; j++) {
186
+ if (suppressed[j])
187
+ continue;
188
+ const bi = candidates[j].idx;
189
+ if (iou(ay0, ax0, ay1, ax1, decoded[bi * 4], decoded[bi * 4 + 1], decoded[bi * 4 + 2], decoded[bi * 4 + 3]) > iouThreshold) {
190
+ suppressed[j] = true;
191
+ }
192
+ }
193
+ }
194
+ }
195
+ detections.sort((a, b) => b.score - a.score);
196
+ return detections;
197
+ }
@@ -0,0 +1,23 @@
1
+ import type { Detection } from "./blazeFacePrePost";
2
+ export declare const FACE_MESH_INPUT_SIZE = 192;
3
+ export declare const NUM_FACE_LANDMARKS = 468;
4
+ export type FaceMeshPreprocessResult = {
5
+ data: Float32Array;
6
+ roiX: number;
7
+ roiY: number;
8
+ roiSize: number;
9
+ };
10
+ export declare function preprocessFaceROI(source: HTMLVideoElement | HTMLCanvasElement, detection: Detection): FaceMeshPreprocessResult;
11
+ export type FaceLandmark = {
12
+ x: number;
13
+ y: number;
14
+ z: number;
15
+ };
16
+ export type DecodeFaceLandmarksOptions = {
17
+ preprocess: FaceMeshPreprocessResult;
18
+ videoWidth: number;
19
+ videoHeight: number;
20
+ };
21
+ export declare function decodeFaceLandmarks(raw: Float32Array, options: DecodeFaceLandmarksOptions): FaceLandmark[];
22
+ export declare function decodeFacePresence(raw: Float32Array): number;
23
+ //# sourceMappingURL=faceMeshPrePost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faceMeshPrePost.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/litert/faceMeshPrePost.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAmBtC,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,YAAY,CAAC;IAGnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,EAC5C,SAAS,EAAE,SAAS,GACnB,wBAAwB,CAwD1B;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,wBAAwB,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,0BAA0B,GAClC,YAAY,EAAE,CAiBhB;AASD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAE5D"}
@@ -0,0 +1,86 @@
1
+ // Pre/post-processing for the standalone `face_landmark.tflite` (468 points).
2
+ //
3
+ // MediaPipe's face_landmarker pipeline computes a rotation-corrected ROI from
4
+ // the BlazeFace detection and feeds a 192×192 crop into the landmarker. We
5
+ // approximate that here without rotation: a square crop centered on the
6
+ // detection bbox, scaled by ROI_PADDING_SCALE so the model sees forehead and
7
+ // chin margins it was trained on. Skipping rotation keeps the math simple and
8
+ // is acceptable for a diagnostic — landmarks drift visibly when the head tilts
9
+ // past ~20°, which is itself a useful signal for the non-starter watch list.
10
+ export const FACE_MESH_INPUT_SIZE = 192;
11
+ export const NUM_FACE_LANDMARKS = 468;
12
+ const ROI_PADDING_SCALE = 1.5;
13
+ let preprocessCanvas = null;
14
+ let preprocessCtx = null;
15
+ function getPreprocessContext() {
16
+ if (!preprocessCtx) {
17
+ preprocessCanvas = document.createElement("canvas");
18
+ preprocessCanvas.width = FACE_MESH_INPUT_SIZE;
19
+ preprocessCanvas.height = FACE_MESH_INPUT_SIZE;
20
+ const ctx = preprocessCanvas.getContext("2d", { willReadFrequently: true });
21
+ if (!ctx)
22
+ throw new Error("faceMeshPrePost: 2d context unavailable");
23
+ preprocessCtx = ctx;
24
+ }
25
+ return preprocessCtx;
26
+ }
27
+ export function preprocessFaceROI(source, detection) {
28
+ const ctx = getPreprocessContext();
29
+ const sw = source instanceof HTMLVideoElement ? source.videoWidth : source.width;
30
+ const sh = source instanceof HTMLVideoElement ? source.videoHeight : source.height;
31
+ const cx = ((detection.xMin + detection.xMax) / 2) * sw;
32
+ const cy = ((detection.yMin + detection.yMax) / 2) * sh;
33
+ const widthPx = (detection.xMax - detection.xMin) * sw;
34
+ const heightPx = (detection.yMax - detection.yMin) * sh;
35
+ const baseSizePx = Math.max(widthPx, heightPx);
36
+ const roiSizePx = baseSizePx * ROI_PADDING_SCALE;
37
+ // ROI in source pixel coords (may extend past the frame; ctx.drawImage
38
+ // handles clipping by leaving sampled pixels black, which approximates
39
+ // MediaPipe's letterbox behavior).
40
+ const roiX = cx - roiSizePx / 2;
41
+ const roiY = cy - roiSizePx / 2;
42
+ ctx.fillStyle = "black";
43
+ ctx.fillRect(0, 0, FACE_MESH_INPUT_SIZE, FACE_MESH_INPUT_SIZE);
44
+ ctx.drawImage(source, roiX, roiY, roiSizePx, roiSizePx, 0, 0, FACE_MESH_INPUT_SIZE, FACE_MESH_INPUT_SIZE);
45
+ const imageData = ctx.getImageData(0, 0, FACE_MESH_INPUT_SIZE, FACE_MESH_INPUT_SIZE);
46
+ const pixels = imageData.data;
47
+ const out = new Float32Array(FACE_MESH_INPUT_SIZE * FACE_MESH_INPUT_SIZE * 3);
48
+ // face_landmark.tflite expects [0, 1] normalized input.
49
+ for (let i = 0, j = 0; i < pixels.length; i += 4, j += 3) {
50
+ out[j] = pixels[i] / 255;
51
+ out[j + 1] = pixels[i + 1] / 255;
52
+ out[j + 2] = pixels[i + 2] / 255;
53
+ }
54
+ return {
55
+ data: out,
56
+ roiX: roiX / sw,
57
+ roiY: roiY / sh,
58
+ roiSize: roiSizePx,
59
+ };
60
+ }
61
+ export function decodeFaceLandmarks(raw, options) {
62
+ const { preprocess, videoWidth, videoHeight } = options;
63
+ const landmarks = new Array(NUM_FACE_LANDMARKS);
64
+ const roiToSrcX = preprocess.roiSize / videoWidth;
65
+ const roiToSrcY = preprocess.roiSize / videoHeight;
66
+ for (let i = 0; i < NUM_FACE_LANDMARKS; i++) {
67
+ const px = raw[i * 3] / FACE_MESH_INPUT_SIZE;
68
+ const py = raw[i * 3 + 1] / FACE_MESH_INPUT_SIZE;
69
+ const pz = raw[i * 3 + 2];
70
+ landmarks[i] = {
71
+ x: preprocess.roiX + px * roiToSrcX,
72
+ y: preprocess.roiY + py * roiToSrcY,
73
+ z: pz,
74
+ };
75
+ }
76
+ return landmarks;
77
+ }
78
+ function sigmoid(x) {
79
+ const clipped = Math.max(-100, Math.min(100, x));
80
+ return 1 / (1 + Math.exp(-clipped));
81
+ }
82
+ // face_landmark.tflite emits a face-presence flag as a logit (single value).
83
+ // Apply sigmoid for a 0-1 confidence.
84
+ export function decodeFacePresence(raw) {
85
+ return sigmoid(raw[0]);
86
+ }
@@ -0,0 +1,6 @@
1
+ export declare const FOCUS_INPUT_SIZE = 224;
2
+ export declare const FOCUS_FOCUSED_INDEX = 1;
3
+ export declare function resizeAndExtractRgb(source: HTMLCanvasElement): Uint8Array<ArrayBuffer>;
4
+ export declare function normalizePixelsToFloat32(pixels: Uint8Array): Float32Array<ArrayBuffer>;
5
+ export declare function decodeFocusScore(output: Float32Array): number;
6
+ //# sourceMappingURL=focusPrePost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusPrePost.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/litert/focusPrePost.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAwBpC,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,GACxB,UAAU,CAAC,WAAW,CAAC,CAWzB;AAOD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,UAAU,GACjB,YAAY,CAAC,WAAW,CAAC,CAM3B;AAKD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,67 @@
1
+ // Pre/post-processing for the LiteRT focus classifier.
2
+ //
3
+ // Input contract:
4
+ // `input` — float32 [1, 224, 224, 3], stretch-resized RGB, normalized as
5
+ // `(px / 127.5) - 1` mapping pixel bytes [0, 255] to [-1, 1]. ML team
6
+ // confirmed the normalization on 2026-05-28.
7
+ //
8
+ // Output contract:
9
+ // `output` — float32 [1, 2] with softmax already applied inside the model
10
+ // graph. Index 1 is the "focused" class probability; index 0 is the
11
+ // complementary "not focused" probability. Do NOT re-apply softmax.
12
+ //
13
+ // If the ML team re-exports the model with a different input shape or class
14
+ // ordering, both FOCUS_INPUT_SIZE and FOCUS_FOCUSED_INDEX need updating.
15
+ export const FOCUS_INPUT_SIZE = 224;
16
+ export const FOCUS_FOCUSED_INDEX = 1;
17
+ let preprocessCanvas = null;
18
+ let preprocessCtx = null;
19
+ function getPreprocessContext() {
20
+ if (!preprocessCtx) {
21
+ preprocessCanvas = document.createElement('canvas');
22
+ preprocessCanvas.width = FOCUS_INPUT_SIZE;
23
+ preprocessCanvas.height = FOCUS_INPUT_SIZE;
24
+ const ctx = preprocessCanvas.getContext('2d', { willReadFrequently: true });
25
+ if (!ctx)
26
+ throw new Error('focusPrePost: 2d context unavailable');
27
+ preprocessCtx = ctx;
28
+ }
29
+ return preprocessCtx;
30
+ }
31
+ // Stretch-resize source into a 224×224 RGB uint8 buffer (alpha stripped).
32
+ //
33
+ // Return type narrows to `Uint8Array<ArrayBuffer>` (not the default
34
+ // `Uint8Array<ArrayBufferLike>`) because we always allocate a fresh
35
+ // `new Uint8Array(numel)` here, never a SharedArrayBuffer view. The
36
+ // narrower type lets the result flow into normalizePixelsToFloat32 and
37
+ // `Tensor.fromTypedArray` without a downstream cast.
38
+ export function resizeAndExtractRgb(source) {
39
+ const ctx = getPreprocessContext();
40
+ ctx.drawImage(source, 0, 0, FOCUS_INPUT_SIZE, FOCUS_INPUT_SIZE);
41
+ const pixels = ctx.getImageData(0, 0, FOCUS_INPUT_SIZE, FOCUS_INPUT_SIZE).data;
42
+ const out = new Uint8Array(FOCUS_INPUT_SIZE * FOCUS_INPUT_SIZE * 3);
43
+ for (let i = 0, j = 0; i < pixels.length; i += 4, j += 3) {
44
+ out[j] = pixels[i];
45
+ out[j + 1] = pixels[i + 1];
46
+ out[j + 2] = pixels[i + 2];
47
+ }
48
+ return out;
49
+ }
50
+ // Apply `(px / 127.5) - 1` per element, mapping [0, 255] → [-1, 1].
51
+ //
52
+ // Returns `Float32Array<ArrayBuffer>` (not the default `<ArrayBufferLike>`)
53
+ // for the same reason as resizeAndExtractRgb — always a fresh allocation,
54
+ // never a SharedArrayBuffer view.
55
+ export function normalizePixelsToFloat32(pixels) {
56
+ const out = new Float32Array(pixels.length);
57
+ for (let i = 0; i < pixels.length; i++) {
58
+ out[i] = pixels[i] / 127.5 - 1;
59
+ }
60
+ return out;
61
+ }
62
+ // Read the "focused" class probability. The model graph already applies
63
+ // softmax, so `output[FOCUS_FOCUSED_INDEX]` is already in [0, 1] and can be
64
+ // returned directly. Returns 0 when output is empty (defensive).
65
+ export function decodeFocusScore(output) {
66
+ return output[FOCUS_FOCUSED_INDEX] ?? 0;
67
+ }
@@ -0,0 +1,14 @@
1
+ import { CompiledModel } from '@litertjs/core';
2
+ export declare const LITERT_WASM_DIR = "https://websdk-cdn-dev.idmission.com/assets/litert/2.5.1/wasm/";
3
+ export declare function ensureLiteRtLoaded(): Promise<void>;
4
+ export type AcceleratorChoice = 'webgpu' | 'wasm' | 'auto';
5
+ export type ResolvedAccelerator = 'webgpu' | 'wasm';
6
+ export declare function resolveAccelerator(choice: AcceleratorChoice): ResolvedAccelerator;
7
+ export type LoadModelResult = {
8
+ model: CompiledModel;
9
+ resolvedAccelerator: ResolvedAccelerator;
10
+ loadMs: number;
11
+ };
12
+ export type ModelSource = string | URL | Uint8Array;
13
+ export declare function loadModel(source: ModelSource, choice: AcceleratorChoice): Promise<LoadModelResult>;
14
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/litert/runtime.ts"],"names":[],"mappings":"AASA,OAAO,EACL,aAAa,EAId,MAAM,gBAAgB,CAAA;AAOvB,eAAO,MAAM,eAAe,mEAAsD,CAAA;AAIlF,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBlD;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAC1D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEnD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,GACxB,mBAAmB,CAGrB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,aAAa,CAAA;IACpB,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,GAAG,GAAG,UAAU,CAAA;AAInD,wBAAsB,SAAS,CAC7B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,eAAe,CAAC,CA8B1B"}
@@ -0,0 +1,83 @@
1
+ // Thin wrapper around @litertjs/core for the LiteRT-backed providers.
2
+ //
3
+ // `loadLiteRt` initializes the global LiteRT WASM module (one-time per page).
4
+ // Subsequent model loads share the global instance. The WASM files are served
5
+ // from the SDK's own CloudFront CDN (alongside the .tflite models), pinned to
6
+ // `LITERT_VERSION` so the runtime bytes match the installed @litertjs/core npm
7
+ // bindings. Upload them with `scripts/setlitertwasm.sh` whenever the version
8
+ // here changes.
9
+ import { isWebGPUSupported, loadAndCompile, loadLiteRt, } from '@litertjs/core';
10
+ import { DEFAULT_CDN_URL } from '../../../config/cdn';
11
+ import { withQuietWasm } from '../../VisionRuntime';
12
+ // Keep in sync with the installed @litertjs/core version in package.json; the
13
+ // CDN-hosted WASM runtime must match the bundled JS bindings.
14
+ const LITERT_VERSION = '2.5.1';
15
+ export const LITERT_WASM_DIR = `${DEFAULT_CDN_URL}/litert/${LITERT_VERSION}/wasm/`;
16
+ let runtimePromise = null;
17
+ export function ensureLiteRtLoaded() {
18
+ if (!runtimePromise) {
19
+ // Quiet scope covers the load, not just the later compiles: creating the
20
+ // default environment registers the WebGPU/CPU accelerators, and each
21
+ // registration logs through Emscripten's stderr.
22
+ runtimePromise = withQuietWasm(() => loadLiteRt(LITERT_WASM_DIR)).then(() => undefined, (err) => {
23
+ // Clear the cache on rejection so the next caller gets a fresh attempt
24
+ // instead of the stuck rejection.
25
+ runtimePromise = null;
26
+ throw err;
27
+ });
28
+ }
29
+ return runtimePromise;
30
+ }
31
+ export function resolveAccelerator(choice) {
32
+ if (choice === 'auto')
33
+ return isWebGPUSupported() ? 'webgpu' : 'wasm';
34
+ return choice;
35
+ }
36
+ // Load and compile a .tflite. Accepts either a URL (LiteRT fetches) or a
37
+ // Uint8Array (SRI-validated bytes from preloadDependency). Caller decides.
38
+ export async function loadModel(source, choice) {
39
+ await ensureLiteRtLoaded();
40
+ const resolvedAccelerator = resolveAccelerator(choice);
41
+ const t0 = performance.now();
42
+ let model;
43
+ try {
44
+ model = await withQuietWasm(() => loadAndCompile(source, { accelerator: resolvedAccelerator }));
45
+ }
46
+ catch (cause) {
47
+ // LiteRT's own failure is `Failed to load model from buffer` with a stack
48
+ // of wasm-function frames and NOTHING identifying the model — the bytes
49
+ // are already in WASM by then, so the URL is not in the message, the
50
+ // stack, or anything downstream. That leaves an integrator unable to tell
51
+ // "our default model is broken" from "the model URL I pinned in 2.x is a
52
+ // MediaPipe export and this is the LiteRT runtime", which are opposite
53
+ // problems with opposite fixes. Re-thrown with the source attached, and
54
+ // `cause` preserved so the WASM stack survives.
55
+ throw new Error(`LiteRT failed to compile the model at ${describeModelSource(source)} ` +
56
+ `(accelerator: ${resolvedAccelerator}). If this URL was set explicitly, ` +
57
+ `check it is a LiteRT export rather than a MediaPipe one — the two are ` +
58
+ `not interchangeable and the runtime defaults to LiteRT.`, { cause });
59
+ }
60
+ const loadMs = performance.now() - t0;
61
+ return { model, resolvedAccelerator, loadMs };
62
+ }
63
+ /**
64
+ * Origin + pathname only. The model path is caller-supplied and may be a
65
+ * signed URL, where the signature lives in the query string and credentials
66
+ * can live in the userinfo — neither belongs in a console line or in an
67
+ * `Error` handed to a host's error handler. `URL.origin` excludes userinfo by
68
+ * construction, and dropping the query costs nothing diagnostically: the
69
+ * pathname is the part that says WHICH model.
70
+ */
71
+ function describeModelSource(source) {
72
+ if (source instanceof Uint8Array)
73
+ return `<${source.byteLength} preloaded bytes>`;
74
+ try {
75
+ const base = typeof location === 'undefined' ? undefined : location.href;
76
+ const url = new URL(String(source), base);
77
+ return url.origin + url.pathname;
78
+ }
79
+ catch {
80
+ // A relative path with no document to resolve against (Node, workers).
81
+ return '<model source>';
82
+ }
83
+ }
@@ -0,0 +1,11 @@
1
+ import { Frame } from '../../../utils/getFrameDimensions';
2
+ import { DetectedObjectBox } from '../../DocumentDetection';
3
+ import type { BarcodeReadabilityPrediction } from '../../BarcodeReadability';
4
+ export type LoadOptions = {
5
+ modelAssetPath: string;
6
+ };
7
+ export declare function load({ modelAssetPath }: LoadOptions): Promise<void>;
8
+ export declare function predict(imageData: Frame, cropCanvas: HTMLCanvasElement, rotateCanvas: HTMLCanvasElement, resizeCanvas: HTMLCanvasElement, box?: DetectedObjectBox): BarcodeReadabilityPrediction | null;
9
+ export declare function classifyForVideo(frame: Frame): void;
10
+ export declare function close(): void;
11
+ //# sourceMappingURL=BarcodeReadability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BarcodeReadability.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/mediapipe/BarcodeReadability.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAO3D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAK5E,MAAM,MAAM,WAAW,GAAG;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,wBAAsB,IAAI,CAAC,EAAE,cAAc,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BzE;AAcD,wBAAgB,OAAO,CACrB,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,iBAAiB,EAC/B,YAAY,EAAE,iBAAiB,EAC/B,GAAG,CAAC,EAAE,iBAAiB,GACtB,4BAA4B,GAAG,IAAI,CA2BrC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAInD;AAED,wBAAgB,KAAK,IAAI,IAAI,CAI5B"}
@@ -0,0 +1,68 @@
1
+ import { FilesetResolver, ImageClassifier } from '@mediapipe/tasks-vision';
2
+ import { getDelegate } from '../../CapabilityProbing';
3
+ const RUNTIME = 'mediapipe';
4
+ import { visionTasksBasePath, withQuietWasm, withQuietWasmSync, } from '../../VisionRuntime';
5
+ import { cropAndRotateIfNecessary, resizeIfNecessary, } from '../../../utils/cropping';
6
+ import { debug } from '../../../utils/logger';
7
+ import { getCachedModelBuffer } from '../../preloadModels';
8
+ let classifier = null;
9
+ let classifierSettings = null;
10
+ export async function load({ modelAssetPath }) {
11
+ if (classifier && classifierSettings?.modelAssetPath === modelAssetPath)
12
+ return;
13
+ close();
14
+ if (getDelegate(RUNTIME) === 'NONE') {
15
+ throw new Error('No available delegate for barcode readability model.');
16
+ }
17
+ const cachedBuffer = getCachedModelBuffer(modelAssetPath);
18
+ classifier = await withQuietWasm(async () => ImageClassifier.createFromOptions(await FilesetResolver.forVisionTasks(visionTasksBasePath), {
19
+ baseOptions: {
20
+ ...(cachedBuffer
21
+ ? { modelAssetBuffer: cachedBuffer }
22
+ : { modelAssetPath }),
23
+ delegate: 'CPU',
24
+ },
25
+ runningMode: 'VIDEO',
26
+ maxResults: 1,
27
+ }));
28
+ classifierSettings = { modelAssetPath };
29
+ }
30
+ // Minimum box size (in pixels) before we'll attempt a readability
31
+ // prediction. Sub-pixel widths get truncated to 0 by HTMLCanvasElement,
32
+ // producing an empty canvas that MediaPipe's classifyForVideo rejects
33
+ // (`texImage2D: no canvas`) and OpenCV's internal warpPerspective trips
34
+ // (`_src.total() > 0`). The LiteRT document detector occasionally emits
35
+ // barcode-class detections whose normalized coords clip near a frame
36
+ // edge, yielding a sliver box that survives the adapter's `width <= 0`
37
+ // filter but still produces an unusable crop. 8px is large enough to
38
+ // guarantee a valid texture upload and small enough that no real
39
+ // barcode/face/etc. detection should ever be below it.
40
+ const MIN_PREDICT_BOX_PX = 8;
41
+ export function predict(imageData, cropCanvas, rotateCanvas, resizeCanvas, box) {
42
+ const c = classifier;
43
+ if (!c)
44
+ return null;
45
+ if (box &&
46
+ (box.width < MIN_PREDICT_BOX_PX || box.height < MIN_PREDICT_BOX_PX)) {
47
+ return null;
48
+ }
49
+ const startedAt = performance.now();
50
+ const image = cropAndRotateIfNecessary(imageData, cropCanvas, rotateCanvas, box);
51
+ const resized = resizeIfNecessary(image, resizeCanvas, 500);
52
+ const result = withQuietWasmSync(() => c.classifyForVideo(resized, performance.now()));
53
+ const score = result?.classifications?.[0]?.categories?.find((c) => c.categoryName === 'blurry')?.score ?? 0;
54
+ debug('barcode prediction', `${performance.now() - startedAt}ms`, score);
55
+ const predictionTime = performance.now() - startedAt;
56
+ return { score, predictionTime };
57
+ }
58
+ export function classifyForVideo(frame) {
59
+ const c = classifier;
60
+ if (!c)
61
+ return;
62
+ withQuietWasmSync(() => c.classifyForVideo(frame, performance.now()));
63
+ }
64
+ export function close() {
65
+ classifier?.close();
66
+ classifier = null;
67
+ classifierSettings = null;
68
+ }
@@ -0,0 +1,2 @@
1
+ export declare function verifyMediaPipeDelegate(delegate: 'GPU' | 'CPU', modelAssetPath: string): Promise<void>;
2
+ //# sourceMappingURL=CapabilityProbe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CapabilityProbe.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/mediapipe/CapabilityProbe.ts"],"names":[],"mappings":"AASA,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,KAAK,GAAG,KAAK,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAUf"}
@@ -0,0 +1,14 @@
1
+ import { FilesetResolver, ImageSegmenter } from '@mediapipe/tasks-vision';
2
+ import { visionTasksBasePath, withQuietWasm } from '../../VisionRuntime';
3
+ // Verify a given delegate (GPU or CPU) can actually run a TFLite model in this
4
+ // browser. Creates an ImageSegmenter, runs it once against an empty canvas,
5
+ // and lets any thrown error propagate up so the caller can fall back. We
6
+ // intentionally don't close the segmenter or remove the canvas to match the
7
+ // pre-refactor behavior — changing that mid-refactor would conflate two
8
+ // concerns.
9
+ export async function verifyMediaPipeDelegate(delegate, modelAssetPath) {
10
+ const model = await withQuietWasm(async () => ImageSegmenter.createFromOptions(await FilesetResolver.forVisionTasks(visionTasksBasePath), { baseOptions: { modelAssetPath, delegate } }));
11
+ const emptyFrame = document.createElement('canvas');
12
+ model.segment(emptyFrame);
13
+ emptyFrame.remove();
14
+ }
@@ -0,0 +1,12 @@
1
+ import { ObjectDetector } from '@mediapipe/tasks-vision';
2
+ import type { ObjectDetectorPrediction } from '../../DocumentDetection';
3
+ export type LoadOptions = {
4
+ modelAssetPath: string;
5
+ scoreThreshold: number;
6
+ };
7
+ export declare function load({ modelAssetPath, scoreThreshold, }: LoadOptions): Promise<void>;
8
+ export declare function predict(frame: HTMLCanvasElement): Promise<ObjectDetectorPrediction | null>;
9
+ export declare function getRawDetector(): ObjectDetector | null;
10
+ export declare function close(): void;
11
+ export declare function testAgainstKnownImage(): Promise<void>;
12
+ //# sourceMappingURL=DocumentDetection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentDetection.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/mediapipe/DocumentDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAYzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAQvE,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,wBAAsB,IAAI,CAAC,EACzB,cAAc,EACd,cAAc,GACf,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAkC7B;AAED,wBAAsB,OAAO,CAC3B,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAuB1C;AAED,wBAAgB,cAAc,IAAI,cAAc,GAAG,IAAI,CAEtD;AAED,wBAAgB,KAAK,IAAI,IAAI,CAI5B;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmC3D"}