@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.
- package/README.md +66 -0
- package/dist/attestation/attestationState.d.ts +24 -0
- package/dist/attestation/attestationState.d.ts.map +1 -0
- package/dist/attestation/attestationState.js +57 -0
- package/dist/attestation/clientAttestation.d.ts +40 -0
- package/dist/attestation/clientAttestation.d.ts.map +1 -0
- package/dist/attestation/clientAttestation.js +19 -0
- package/dist/attestation/collectClientAttestation.d.ts +10 -0
- package/dist/attestation/collectClientAttestation.d.ts.map +1 -0
- package/dist/attestation/collectClientAttestation.js +18 -0
- package/dist/attestation/index.d.ts +5 -0
- package/dist/attestation/index.d.ts.map +1 -0
- package/dist/attestation/index.js +4 -0
- package/dist/attestation/nativeAttestationBridge.d.ts +3 -0
- package/dist/attestation/nativeAttestationBridge.d.ts.map +1 -0
- package/dist/attestation/nativeAttestationBridge.js +38 -0
- package/dist/barcode/AAMVAParser.d.ts +77 -0
- package/dist/barcode/AAMVAParser.d.ts.map +1 -0
- package/dist/barcode/AAMVAParser.js +422 -0
- package/dist/barcode/NativeBarcodeDecoder.d.ts +157 -0
- package/dist/barcode/NativeBarcodeDecoder.d.ts.map +1 -0
- package/dist/barcode/NativeBarcodeDecoder.js +832 -0
- package/dist/barcode/Parse.d.ts +6 -0
- package/dist/barcode/Parse.d.ts.map +1 -0
- package/dist/barcode/Parse.js +148 -0
- package/dist/barcode/decodeSummary.d.ts +45 -0
- package/dist/barcode/decodeSummary.d.ts.map +1 -0
- package/dist/barcode/decodeSummary.js +23 -0
- package/dist/barcode/index.d.ts +5 -0
- package/dist/barcode/index.d.ts.map +1 -0
- package/dist/barcode/index.js +4 -0
- package/dist/camera/Camera.d.ts +37 -0
- package/dist/camera/Camera.d.ts.map +1 -0
- package/dist/camera/Camera.js +453 -0
- package/dist/camera/acquireCamera.d.ts +29 -0
- package/dist/camera/acquireCamera.d.ts.map +1 -0
- package/dist/camera/acquireCamera.js +224 -0
- package/dist/camera/cameraSignals.d.ts +23 -0
- package/dist/camera/cameraSignals.d.ts.map +1 -0
- package/dist/camera/cameraSignals.js +32 -0
- package/dist/camera/getUserMediaIntegrity.d.ts +72 -0
- package/dist/camera/getUserMediaIntegrity.d.ts.map +1 -0
- package/dist/camera/getUserMediaIntegrity.js +256 -0
- package/dist/camera/index.d.ts +6 -0
- package/dist/camera/index.d.ts.map +1 -0
- package/dist/camera/index.js +5 -0
- package/dist/camera/isVirtualCamera.d.ts +10 -0
- package/dist/camera/isVirtualCamera.d.ts.map +1 -0
- package/dist/camera/isVirtualCamera.js +11 -0
- package/dist/client/IdmissionClient.d.ts +151 -0
- package/dist/client/IdmissionClient.d.ts.map +1 -0
- package/dist/client/IdmissionClient.js +638 -0
- package/dist/client/additionalDocument.d.ts +14 -0
- package/dist/client/additionalDocument.d.ts.map +1 -0
- package/dist/client/additionalDocument.js +24 -0
- package/dist/client/artifacts.d.ts +146 -0
- package/dist/client/artifacts.d.ts.map +1 -0
- package/dist/client/artifacts.js +1 -0
- package/dist/client/blobToB64.d.ts +2 -0
- package/dist/client/blobToB64.d.ts.map +1 -0
- package/dist/client/blobToB64.js +17 -0
- package/dist/client/endpoints.d.ts +7 -0
- package/dist/client/endpoints.d.ts.map +1 -0
- package/dist/client/endpoints.js +59 -0
- package/dist/client/errors.d.ts +20 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +45 -0
- package/dist/client/index.d.ts +23 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +38 -0
- package/dist/client/payload.d.ts +36 -0
- package/dist/client/payload.d.ts.map +1 -0
- package/dist/client/payload.js +397 -0
- package/dist/client/sessionMachine.d.ts +26 -0
- package/dist/client/sessionMachine.d.ts.map +1 -0
- package/dist/client/sessionMachine.js +23 -0
- package/dist/client/submissionMetadata.d.ts +31 -0
- package/dist/client/submissionMetadata.d.ts.map +1 -0
- package/dist/client/submissionMetadata.js +90 -0
- package/dist/client/timings.d.ts +49 -0
- package/dist/client/timings.d.ts.map +1 -0
- package/dist/client/timings.js +32 -0
- package/dist/client/types.d.ts +305 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +18 -0
- package/dist/client/upload.d.ts +60 -0
- package/dist/client/upload.d.ts.map +1 -0
- package/dist/client/upload.js +313 -0
- package/dist/client/uploadedDocument.d.ts +7 -0
- package/dist/client/uploadedDocument.d.ts.map +1 -0
- package/dist/client/uploadedDocument.js +4 -0
- package/dist/client/urls.d.ts +30 -0
- package/dist/client/urls.d.ts.map +1 -0
- package/dist/client/urls.js +73 -0
- package/dist/client/validateSession.d.ts +7 -0
- package/dist/client/validateSession.d.ts.map +1 -0
- package/dist/client/validateSession.js +63 -0
- package/dist/config/cdn.d.ts +2 -0
- package/dist/config/cdn.d.ts.map +1 -0
- package/dist/config/cdn.js +1 -0
- package/dist/diagnostics/buffer.d.ts +8 -0
- package/dist/diagnostics/buffer.d.ts.map +1 -0
- package/dist/diagnostics/buffer.js +25 -0
- package/dist/diagnostics/envCapability.d.ts +3 -0
- package/dist/diagnostics/envCapability.d.ts.map +1 -0
- package/dist/diagnostics/envCapability.js +40 -0
- package/dist/diagnostics/floodControl.d.ts +6 -0
- package/dist/diagnostics/floodControl.d.ts.map +1 -0
- package/dist/diagnostics/floodControl.js +29 -0
- package/dist/diagnostics/index.d.ts +8 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +17 -0
- package/dist/diagnostics/install.d.ts +20 -0
- package/dist/diagnostics/install.d.ts.map +1 -0
- package/dist/diagnostics/install.js +159 -0
- package/dist/diagnostics/redaction.d.ts +7 -0
- package/dist/diagnostics/redaction.d.ts.map +1 -0
- package/dist/diagnostics/redaction.js +73 -0
- package/dist/diagnostics/transport.d.ts +15 -0
- package/dist/diagnostics/transport.d.ts.map +1 -0
- package/dist/diagnostics/transport.js +35 -0
- package/dist/diagnostics/types.d.ts +59 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/diagnostics/types.js +1 -0
- package/dist/documentCapture/controller.d.ts +35 -0
- package/dist/documentCapture/controller.d.ts.map +1 -0
- package/dist/documentCapture/controller.js +254 -0
- package/dist/documentCapture/index.d.ts +4 -0
- package/dist/documentCapture/index.d.ts.map +1 -0
- package/dist/documentCapture/index.js +8 -0
- package/dist/documentCapture/reducer.d.ts +31 -0
- package/dist/documentCapture/reducer.d.ts.map +1 -0
- package/dist/documentCapture/reducer.js +87 -0
- package/dist/documentCapture/state.d.ts +49 -0
- package/dist/documentCapture/state.d.ts.map +1 -0
- package/dist/documentCapture/state.js +36 -0
- package/dist/idCapture/controller.d.ts +228 -0
- package/dist/idCapture/controller.d.ts.map +1 -0
- package/dist/idCapture/controller.js +1453 -0
- package/dist/idCapture/errors.d.ts +36 -0
- package/dist/idCapture/errors.d.ts.map +1 -0
- package/dist/idCapture/errors.js +18 -0
- package/dist/idCapture/guidance.d.ts +80 -0
- package/dist/idCapture/guidance.d.ts.map +1 -0
- package/dist/idCapture/guidance.js +143 -0
- package/dist/idCapture/index.d.ts +22 -0
- package/dist/idCapture/index.d.ts.map +1 -0
- package/dist/idCapture/index.js +46 -0
- package/dist/idCapture/phase.d.ts +10 -0
- package/dist/idCapture/phase.d.ts.map +1 -0
- package/dist/idCapture/phase.js +28 -0
- package/dist/idCapture/pipeline.d.ts +176 -0
- package/dist/idCapture/pipeline.d.ts.map +1 -0
- package/dist/idCapture/pipeline.js +1028 -0
- package/dist/idCapture/reducer.d.ts +3 -0
- package/dist/idCapture/reducer.d.ts.map +1 -0
- package/dist/idCapture/reducer.js +661 -0
- package/dist/idCapture/requirements.d.ts +10 -0
- package/dist/idCapture/requirements.d.ts.map +1 -0
- package/dist/idCapture/requirements.js +43 -0
- package/dist/idCapture/stabilizer.d.ts +2 -0
- package/dist/idCapture/stabilizer.d.ts.map +1 -0
- package/dist/idCapture/stabilizer.js +4 -0
- package/dist/idCapture/state.d.ts +426 -0
- package/dist/idCapture/state.d.ts.map +1 -0
- package/dist/idCapture/state.js +91 -0
- package/dist/idCapture/submit.d.ts +33 -0
- package/dist/idCapture/submit.d.ts.map +1 -0
- package/dist/idCapture/submit.js +105 -0
- package/dist/idCapture/types.d.ts +20 -0
- package/dist/idCapture/types.d.ts.map +1 -0
- package/dist/idCapture/types.js +12 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/liveness/challengeGeometry.d.ts +66 -0
- package/dist/liveness/challengeGeometry.d.ts.map +1 -0
- package/dist/liveness/challengeGeometry.js +226 -0
- package/dist/liveness/challengeSequence.d.ts +49 -0
- package/dist/liveness/challengeSequence.d.ts.map +1 -0
- package/dist/liveness/challengeSequence.js +71 -0
- package/dist/liveness/index.d.ts +4 -0
- package/dist/liveness/index.d.ts.map +1 -0
- package/dist/liveness/index.js +3 -0
- package/dist/liveness/livenessResult.d.ts +11 -0
- package/dist/liveness/livenessResult.d.ts.map +1 -0
- package/dist/liveness/livenessResult.js +16 -0
- package/dist/models/BarcodeReadability.d.ts +36 -0
- package/dist/models/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/BarcodeReadability.js +71 -0
- package/dist/models/CapabilityProbing.d.ts +25 -0
- package/dist/models/CapabilityProbing.d.ts.map +1 -0
- package/dist/models/CapabilityProbing.js +172 -0
- package/dist/models/DocumentDetection.d.ts +96 -0
- package/dist/models/DocumentDetection.d.ts.map +1 -0
- package/dist/models/DocumentDetection.js +257 -0
- package/dist/models/FaceDetection.d.ts +21 -0
- package/dist/models/FaceDetection.d.ts.map +1 -0
- package/dist/models/FaceDetection.js +4 -0
- package/dist/models/Focus.d.ts +36 -0
- package/dist/models/Focus.d.ts.map +1 -0
- package/dist/models/Focus.js +69 -0
- package/dist/models/FrameLoop.d.ts +13 -0
- package/dist/models/FrameLoop.d.ts.map +1 -0
- package/dist/models/FrameLoop.js +56 -0
- package/dist/models/VisionRuntime.d.ts +18 -0
- package/dist/models/VisionRuntime.d.ts.map +1 -0
- package/dist/models/VisionRuntime.js +158 -0
- package/dist/models/defaults/BarcodeReadability.d.ts +3 -0
- package/dist/models/defaults/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/defaults/BarcodeReadability.js +3 -0
- package/dist/models/defaults/BarcodeReadabilityLiteRT.d.ts +3 -0
- package/dist/models/defaults/BarcodeReadabilityLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/BarcodeReadabilityLiteRT.js +3 -0
- package/dist/models/defaults/DocumentDetector.d.ts +3 -0
- package/dist/models/defaults/DocumentDetector.d.ts.map +1 -0
- package/dist/models/defaults/DocumentDetector.js +3 -0
- package/dist/models/defaults/DocumentDetectorLiteRT.d.ts +3 -0
- package/dist/models/defaults/DocumentDetectorLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/DocumentDetectorLiteRT.js +3 -0
- package/dist/models/defaults/FaceDetector.d.ts +3 -0
- package/dist/models/defaults/FaceDetector.d.ts.map +1 -0
- package/dist/models/defaults/FaceDetector.js +3 -0
- package/dist/models/defaults/FaceLandmarker.d.ts +3 -0
- package/dist/models/defaults/FaceLandmarker.d.ts.map +1 -0
- package/dist/models/defaults/FaceLandmarker.js +8 -0
- package/dist/models/defaults/FaceLandmarkerLiteRT.d.ts +3 -0
- package/dist/models/defaults/FaceLandmarkerLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/FaceLandmarkerLiteRT.js +3 -0
- package/dist/models/defaults/Focus.d.ts +3 -0
- package/dist/models/defaults/Focus.d.ts.map +1 -0
- package/dist/models/defaults/Focus.js +3 -0
- package/dist/models/defaults/FocusLiteRT.d.ts +3 -0
- package/dist/models/defaults/FocusLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/FocusLiteRT.js +3 -0
- package/dist/models/defaults/index.d.ts +31 -0
- package/dist/models/defaults/index.d.ts.map +1 -0
- package/dist/models/defaults/index.js +38 -0
- package/dist/models/helpers.d.ts +25 -0
- package/dist/models/helpers.d.ts.map +1 -0
- package/dist/models/helpers.js +98 -0
- package/dist/models/index.d.ts +15 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +14 -0
- package/dist/models/modelLifecycle.d.ts +26 -0
- package/dist/models/modelLifecycle.d.ts.map +1 -0
- package/dist/models/modelLifecycle.js +137 -0
- package/dist/models/occlusion.d.ts +20 -0
- package/dist/models/occlusion.d.ts.map +1 -0
- package/dist/models/occlusion.js +109 -0
- package/dist/models/passportBooklet.d.ts +34 -0
- package/dist/models/passportBooklet.d.ts.map +1 -0
- package/dist/models/passportBooklet.js +152 -0
- package/dist/models/preloadModels.d.ts +42 -0
- package/dist/models/preloadModels.d.ts.map +1 -0
- package/dist/models/preloadModels.js +204 -0
- package/dist/models/providers/litert/BarcodeReadability.d.ts +11 -0
- package/dist/models/providers/litert/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/providers/litert/BarcodeReadability.js +135 -0
- package/dist/models/providers/litert/CapabilityProbe.d.ts +3 -0
- package/dist/models/providers/litert/CapabilityProbe.d.ts.map +1 -0
- package/dist/models/providers/litert/CapabilityProbe.js +44 -0
- package/dist/models/providers/litert/DocumentDetection.d.ts +18 -0
- package/dist/models/providers/litert/DocumentDetection.d.ts.map +1 -0
- package/dist/models/providers/litert/DocumentDetection.js +194 -0
- package/dist/models/providers/litert/FaceDetection.d.ts +11 -0
- package/dist/models/providers/litert/FaceDetection.d.ts.map +1 -0
- package/dist/models/providers/litert/FaceDetection.js +204 -0
- package/dist/models/providers/litert/FaceLandmarker.d.ts +11 -0
- package/dist/models/providers/litert/FaceLandmarker.d.ts.map +1 -0
- package/dist/models/providers/litert/FaceLandmarker.js +199 -0
- package/dist/models/providers/litert/Focus.d.ts +11 -0
- package/dist/models/providers/litert/Focus.d.ts.map +1 -0
- package/dist/models/providers/litert/Focus.js +141 -0
- package/dist/models/providers/litert/barcodeReadabilityPrePost.d.ts +6 -0
- package/dist/models/providers/litert/barcodeReadabilityPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/barcodeReadabilityPrePost.js +68 -0
- package/dist/models/providers/litert/blazeFacePrePost.d.ts +30 -0
- package/dist/models/providers/litert/blazeFacePrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/blazeFacePrePost.js +206 -0
- package/dist/models/providers/litert/docDetectPrePost.d.ts +25 -0
- package/dist/models/providers/litert/docDetectPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/docDetectPrePost.js +197 -0
- package/dist/models/providers/litert/faceMeshPrePost.d.ts +23 -0
- package/dist/models/providers/litert/faceMeshPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/faceMeshPrePost.js +86 -0
- package/dist/models/providers/litert/focusPrePost.d.ts +6 -0
- package/dist/models/providers/litert/focusPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/focusPrePost.js +67 -0
- package/dist/models/providers/litert/runtime.d.ts +14 -0
- package/dist/models/providers/litert/runtime.d.ts.map +1 -0
- package/dist/models/providers/litert/runtime.js +83 -0
- package/dist/models/providers/mediapipe/BarcodeReadability.d.ts +11 -0
- package/dist/models/providers/mediapipe/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/BarcodeReadability.js +68 -0
- package/dist/models/providers/mediapipe/CapabilityProbe.d.ts +2 -0
- package/dist/models/providers/mediapipe/CapabilityProbe.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/CapabilityProbe.js +14 -0
- package/dist/models/providers/mediapipe/DocumentDetection.d.ts +12 -0
- package/dist/models/providers/mediapipe/DocumentDetection.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/DocumentDetection.js +90 -0
- package/dist/models/providers/mediapipe/FaceDetection.d.ts +11 -0
- package/dist/models/providers/mediapipe/FaceDetection.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/FaceDetection.js +93 -0
- package/dist/models/providers/mediapipe/FaceLandmarker.d.ts +46 -0
- package/dist/models/providers/mediapipe/FaceLandmarker.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/FaceLandmarker.js +166 -0
- package/dist/models/providers/mediapipe/Focus.d.ts +11 -0
- package/dist/models/providers/mediapipe/Focus.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/Focus.js +51 -0
- package/dist/models/runtimeSelection.d.ts +5 -0
- package/dist/models/runtimeSelection.d.ts.map +1 -0
- package/dist/models/runtimeSelection.js +21 -0
- package/dist/selfieCapture/challengeRunner.d.ts +38 -0
- package/dist/selfieCapture/challengeRunner.d.ts.map +1 -0
- package/dist/selfieCapture/challengeRunner.js +181 -0
- package/dist/selfieCapture/controller.d.ts +166 -0
- package/dist/selfieCapture/controller.d.ts.map +1 -0
- package/dist/selfieCapture/controller.js +1253 -0
- package/dist/selfieCapture/faceTracking.d.ts +67 -0
- package/dist/selfieCapture/faceTracking.d.ts.map +1 -0
- package/dist/selfieCapture/faceTracking.js +158 -0
- package/dist/selfieCapture/guidance.d.ts +24 -0
- package/dist/selfieCapture/guidance.d.ts.map +1 -0
- package/dist/selfieCapture/guidance.js +41 -0
- package/dist/selfieCapture/index.d.ts +18 -0
- package/dist/selfieCapture/index.d.ts.map +1 -0
- package/dist/selfieCapture/index.js +11 -0
- package/dist/selfieCapture/lighting.d.ts +36 -0
- package/dist/selfieCapture/lighting.d.ts.map +1 -0
- package/dist/selfieCapture/lighting.js +95 -0
- package/dist/selfieCapture/livenessMachine.d.ts +66 -0
- package/dist/selfieCapture/livenessMachine.d.ts.map +1 -0
- package/dist/selfieCapture/livenessMachine.js +137 -0
- package/dist/selfieCapture/pipeline.d.ts +42 -0
- package/dist/selfieCapture/pipeline.d.ts.map +1 -0
- package/dist/selfieCapture/pipeline.js +282 -0
- package/dist/selfieCapture/reducer.d.ts +35 -0
- package/dist/selfieCapture/reducer.d.ts.map +1 -0
- package/dist/selfieCapture/reducer.js +143 -0
- package/dist/selfieCapture/state.d.ts +40 -0
- package/dist/selfieCapture/state.d.ts.map +1 -0
- package/dist/selfieCapture/state.js +36 -0
- package/dist/selfieCapture/testing/challengeFixtures.d.ts +43 -0
- package/dist/selfieCapture/testing/challengeFixtures.d.ts.map +1 -0
- package/dist/selfieCapture/testing/challengeFixtures.js +43 -0
- package/dist/signature/frameDecode.d.ts +48 -0
- package/dist/signature/frameDecode.d.ts.map +1 -0
- package/dist/signature/frameDecode.js +491 -0
- package/dist/signature/index.d.ts +5 -0
- package/dist/signature/index.d.ts.map +1 -0
- package/dist/signature/index.js +4 -0
- package/dist/signature/metadata.d.ts +63 -0
- package/dist/signature/metadata.d.ts.map +1 -0
- package/dist/signature/metadata.js +1 -0
- package/dist/signature/quality.d.ts +169 -0
- package/dist/signature/quality.d.ts.map +1 -0
- package/dist/signature/quality.js +186 -0
- package/dist/signature/signatureValidity.d.ts +149 -0
- package/dist/signature/signatureValidity.d.ts.map +1 -0
- package/dist/signature/signatureValidity.js +305 -0
- package/dist/signatureCapture/controller.d.ts +67 -0
- package/dist/signatureCapture/controller.d.ts.map +1 -0
- package/dist/signatureCapture/controller.js +534 -0
- package/dist/signatureCapture/guidance.d.ts +9 -0
- package/dist/signatureCapture/guidance.d.ts.map +1 -0
- package/dist/signatureCapture/guidance.js +7 -0
- package/dist/signatureCapture/index.d.ts +6 -0
- package/dist/signatureCapture/index.d.ts.map +1 -0
- package/dist/signatureCapture/index.js +5 -0
- package/dist/signatureCapture/pipeline.d.ts +111 -0
- package/dist/signatureCapture/pipeline.d.ts.map +1 -0
- package/dist/signatureCapture/pipeline.js +680 -0
- package/dist/signatureCapture/reducer.d.ts +42 -0
- package/dist/signatureCapture/reducer.d.ts.map +1 -0
- package/dist/signatureCapture/reducer.js +159 -0
- package/dist/signatureCapture/state.d.ts +92 -0
- package/dist/signatureCapture/state.d.ts.map +1 -0
- package/dist/signatureCapture/state.js +24 -0
- package/dist/utils/canvas.d.ts +4 -0
- package/dist/utils/canvas.d.ts.map +1 -0
- package/dist/utils/canvas.js +21 -0
- package/dist/utils/cropping.d.ts +8 -0
- package/dist/utils/cropping.d.ts.map +1 -0
- package/dist/utils/cropping.js +85 -0
- package/dist/utils/dataUrlToBase64.d.ts +7 -0
- package/dist/utils/dataUrlToBase64.d.ts.map +1 -0
- package/dist/utils/dataUrlToBase64.js +67 -0
- package/dist/utils/getFrameDimensions.d.ts +3 -0
- package/dist/utils/getFrameDimensions.d.ts.map +1 -0
- package/dist/utils/getFrameDimensions.js +12 -0
- package/dist/utils/isMobile.d.ts +3 -0
- package/dist/utils/isMobile.d.ts.map +1 -0
- package/dist/utils/isMobile.js +36 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +25 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +11 -0
- package/dist/utils/stabilizer.d.ts +26 -0
- package/dist/utils/stabilizer.d.ts.map +1 -0
- package/dist/utils/stabilizer.js +65 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -0
- package/dist/videoIdCapture/controller.d.ts +108 -0
- package/dist/videoIdCapture/controller.d.ts.map +1 -0
- package/dist/videoIdCapture/controller.js +833 -0
- package/dist/videoIdCapture/index.d.ts +5 -0
- package/dist/videoIdCapture/index.d.ts.map +1 -0
- package/dist/videoIdCapture/index.js +2 -0
- package/dist/videoIdCapture/state.d.ts +88 -0
- package/dist/videoIdCapture/state.d.ts.map +1 -0
- package/dist/videoIdCapture/state.js +67 -0
- package/package.json +111 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const DEFAULT_THRESHOLD = 0.03;
|
|
2
|
+
// Minimum confidence a `'Finger'` detection must clear before it counts
|
|
3
|
+
// toward occlusion. The LiteRT document detector emits low-score
|
|
4
|
+
// false-positive Finger boxes (we've observed 0.1–0.2 scores during smoke
|
|
5
|
+
// testing) that would otherwise block capture indefinitely. 0.3 sits
|
|
6
|
+
// above the observed false-positive ceiling while letting through
|
|
7
|
+
// low-confidence-but-real fingers that the prior 0.5 cutoff was dropping.
|
|
8
|
+
// Matches MIN_GLARE_SCORE for consistency. Tune in code if field data
|
|
9
|
+
// shows this is wrong.
|
|
10
|
+
const MIN_FINGER_SCORE = 0.3;
|
|
11
|
+
// Same rationale as MIN_FINGER_SCORE, applied to `'Glare'` detections,
|
|
12
|
+
// but the score distribution for Glare runs lower than for Finger: smoke
|
|
13
|
+
// testing showed real, visible glare patches detected at scores around
|
|
14
|
+
// 0.4–0.5, well below the 0.5 floor that works for fingers. Glare gating
|
|
15
|
+
// intentionally has no per-doc-type overlap threshold (any overlap blocks),
|
|
16
|
+
// so the score floor is the main noise filter on this axis — keep it low
|
|
17
|
+
// enough that the model's real glare detections actually trigger.
|
|
18
|
+
const MIN_GLARE_SCORE = 0.3;
|
|
19
|
+
// Same any-overlap-blocks treatment as Glare. The LiteRT model treats
|
|
20
|
+
// Hologram as a distinct class but in practice it behaves as another
|
|
21
|
+
// reflective-artifact category that degrades OCR/face-comparison the
|
|
22
|
+
// same way Glare does, so we mirror MIN_GLARE_SCORE until field data
|
|
23
|
+
// suggests otherwise.
|
|
24
|
+
const MIN_HOLOGRAM_SCORE = 0.3;
|
|
25
|
+
function clamp01(n) {
|
|
26
|
+
if (n < 0)
|
|
27
|
+
return 0;
|
|
28
|
+
if (n > 1)
|
|
29
|
+
return 1;
|
|
30
|
+
return n;
|
|
31
|
+
}
|
|
32
|
+
export function resolveFingerOcclusionThresholds(config) {
|
|
33
|
+
return {
|
|
34
|
+
idCardFront: clamp01(config?.idCardFront ?? DEFAULT_THRESHOLD),
|
|
35
|
+
idCardBack: clamp01(config?.idCardBack ?? DEFAULT_THRESHOLD),
|
|
36
|
+
passport: clamp01(config?.passport ?? DEFAULT_THRESHOLD),
|
|
37
|
+
singlePage: clamp01(config?.singlePage ?? DEFAULT_THRESHOLD),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function computeFingerOcclusion(bestDocument, detectedObjects, documentType, thresholds) {
|
|
41
|
+
if (!bestDocument || documentType === 'none')
|
|
42
|
+
return false;
|
|
43
|
+
const docBox = bestDocument.box;
|
|
44
|
+
const docArea = Math.max(0, docBox.width) * Math.max(0, docBox.height);
|
|
45
|
+
if (docArea <= 0)
|
|
46
|
+
return false;
|
|
47
|
+
const threshold = thresholds[documentType];
|
|
48
|
+
// Sum overlap across ALL qualifying finger detections so that several
|
|
49
|
+
// small fingers (each below threshold individually) still trigger when
|
|
50
|
+
// their combined coverage crosses the threshold. If two finger boxes
|
|
51
|
+
// overlap each other the shared area gets double-counted — that errs
|
|
52
|
+
// toward over-blocking, which is the safer direction for occlusion.
|
|
53
|
+
let totalOverlap = 0;
|
|
54
|
+
for (const obj of detectedObjects) {
|
|
55
|
+
if (obj.label !== 'Finger')
|
|
56
|
+
continue;
|
|
57
|
+
if (obj.score < MIN_FINGER_SCORE)
|
|
58
|
+
continue;
|
|
59
|
+
const fb = obj.box;
|
|
60
|
+
if (fb.width <= 0 || fb.height <= 0)
|
|
61
|
+
continue;
|
|
62
|
+
const interW = Math.min(docBox.xMax, fb.xMax) - Math.max(docBox.xMin, fb.xMin);
|
|
63
|
+
if (interW <= 0)
|
|
64
|
+
continue;
|
|
65
|
+
const interH = Math.min(docBox.yMax, fb.yMax) - Math.max(docBox.yMin, fb.yMin);
|
|
66
|
+
if (interH <= 0)
|
|
67
|
+
continue;
|
|
68
|
+
totalOverlap += (interW * interH) / docArea;
|
|
69
|
+
}
|
|
70
|
+
return totalOverlap >= threshold;
|
|
71
|
+
}
|
|
72
|
+
// Any `'Glare'` detection (score >= MIN_GLARE_SCORE) whose box intersects
|
|
73
|
+
// the document's bounding box triggers. Intentionally has no overlap-area
|
|
74
|
+
// threshold — even small glare patches degrade OCR/face-comparison, so
|
|
75
|
+
// callers want them all flagged. Edge-clipped boxes outside the document
|
|
76
|
+
// are filtered by the standard intersection check.
|
|
77
|
+
export function computeGlareOcclusion(bestDocument, detectedObjects) {
|
|
78
|
+
return anyOverlapByLabel(bestDocument, detectedObjects, 'Glare', MIN_GLARE_SCORE);
|
|
79
|
+
}
|
|
80
|
+
// Same shape as computeGlareOcclusion, applied to `'Hologram'` detections.
|
|
81
|
+
// Hologram is treated as another reflective-artifact category — see the
|
|
82
|
+
// MIN_HOLOGRAM_SCORE comment for the rationale.
|
|
83
|
+
export function computeHologramOcclusion(bestDocument, detectedObjects) {
|
|
84
|
+
return anyOverlapByLabel(bestDocument, detectedObjects, 'Hologram', MIN_HOLOGRAM_SCORE);
|
|
85
|
+
}
|
|
86
|
+
function anyOverlapByLabel(bestDocument, detectedObjects, label, minScore) {
|
|
87
|
+
if (!bestDocument)
|
|
88
|
+
return false;
|
|
89
|
+
const docBox = bestDocument.box;
|
|
90
|
+
if (docBox.width <= 0 || docBox.height <= 0)
|
|
91
|
+
return false;
|
|
92
|
+
for (const obj of detectedObjects) {
|
|
93
|
+
if (obj.label !== label)
|
|
94
|
+
continue;
|
|
95
|
+
if (obj.score < minScore)
|
|
96
|
+
continue;
|
|
97
|
+
const b = obj.box;
|
|
98
|
+
if (b.width <= 0 || b.height <= 0)
|
|
99
|
+
continue;
|
|
100
|
+
const interW = Math.min(docBox.xMax, b.xMax) - Math.max(docBox.xMin, b.xMin);
|
|
101
|
+
if (interW <= 0)
|
|
102
|
+
continue;
|
|
103
|
+
const interH = Math.min(docBox.yMax, b.yMax) - Math.max(docBox.yMin, b.yMin);
|
|
104
|
+
if (interH <= 0)
|
|
105
|
+
continue;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DetectedObjectBox } from './DocumentDetection';
|
|
2
|
+
type DetectedObjectLike = {
|
|
3
|
+
box: DetectedObjectBox;
|
|
4
|
+
label: string;
|
|
5
|
+
score: number;
|
|
6
|
+
};
|
|
7
|
+
export type BookletFraming = 'tooFar' | 'cornersCutOff' | 'ok';
|
|
8
|
+
export type BookletOrientation = 'upright' | 'rotated' | 'upsideDown' | 'unknown';
|
|
9
|
+
export type BookletMetrics = {
|
|
10
|
+
mrzInPage: number;
|
|
11
|
+
pageInDocument: number;
|
|
12
|
+
leafRatio: number;
|
|
13
|
+
aspectRatio: number;
|
|
14
|
+
};
|
|
15
|
+
export type BookletVerdict = {
|
|
16
|
+
isFullBooklet: boolean;
|
|
17
|
+
orientation: BookletOrientation;
|
|
18
|
+
framing: BookletFraming;
|
|
19
|
+
metrics: BookletMetrics | null;
|
|
20
|
+
};
|
|
21
|
+
export declare const CONTAINMENT_MIN = 0.8;
|
|
22
|
+
export declare const LEAF_VS_PAGE_MIN = 0.4;
|
|
23
|
+
export declare const DOC_ASPECT_MIN = 1;
|
|
24
|
+
export declare const BOOKLET_FILL_MIN = 0.55;
|
|
25
|
+
export declare const BOOKLET_EDGE_PADDING = 0.04;
|
|
26
|
+
/**
|
|
27
|
+
* Decide whether the frame shows a fully-opened passport booklet, and report
|
|
28
|
+
* the Document's framing so the caller can pick "move closer" vs "move back".
|
|
29
|
+
* Pure: finds the best Document / Passport page / MRZ boxes by label (highest
|
|
30
|
+
* score above the confidence floor) and reasons geometrically. No React/state.
|
|
31
|
+
*/
|
|
32
|
+
export declare function analyzePassportBooklet(detectedObjects: readonly DetectedObjectLike[], frameWidth: number, frameHeight: number): BookletVerdict;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=passportBooklet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passportBooklet.d.ts","sourceRoot":"","sources":["../../src/models/passportBooklet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAK5D,KAAK,kBAAkB,GAAG;IACxB,GAAG,EAAE,iBAAiB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAA;AAC9D,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAA;AAKjF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAK3B,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,kBAAkB,CAAA;IAC/B,OAAO,EAAE,cAAc,CAAA;IAEvB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAA;CAC/B,CAAA;AAID,eAAO,MAAM,eAAe,MAAM,CAAA;AAClC,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,cAAc,IAAM,CAAA;AACjC,eAAO,MAAM,gBAAgB,OAAO,CAAA;AACpC,eAAO,MAAM,oBAAoB,OAAO,CAAA;AA6HxC;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,SAAS,kBAAkB,EAAE,EAC9C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,cAAc,CA6ChB"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Tuning constants — seeded estimates. Expect on-device tuning against real
|
|
2
|
+
// captures across angles/devices (same posture as the liveness geometry).
|
|
3
|
+
export const CONTAINMENT_MIN = 0.8; // fraction of inner box inside the outer box
|
|
4
|
+
export const LEAF_VS_PAGE_MIN = 0.4; // leaf extent / passport-page extent on the open side
|
|
5
|
+
export const DOC_ASPECT_MIN = 1.0; // document open-axis extent / cross-axis extent
|
|
6
|
+
export const BOOKLET_FILL_MIN = 0.55; // document max dimension / frame dimension
|
|
7
|
+
export const BOOKLET_EDGE_PADDING = 0.04; // min margin from each frame edge
|
|
8
|
+
// Confidence floor (mirrors occlusion.ts MIN_*_SCORE): the detector emits
|
|
9
|
+
// low-score false positives that would otherwise corrupt the geometry.
|
|
10
|
+
const MIN_BOOKLET_SCORE = 0.3;
|
|
11
|
+
function area(b) {
|
|
12
|
+
return Math.max(0, b.width) * Math.max(0, b.height);
|
|
13
|
+
}
|
|
14
|
+
function intersectionArea(a, b) {
|
|
15
|
+
const w = Math.min(a.xMax, b.xMax) - Math.max(a.xMin, b.xMin);
|
|
16
|
+
const h = Math.min(a.yMax, b.yMax) - Math.max(a.yMin, b.yMin);
|
|
17
|
+
if (w <= 0 || h <= 0)
|
|
18
|
+
return 0;
|
|
19
|
+
return w * h;
|
|
20
|
+
}
|
|
21
|
+
// Fraction of the inner box's area that lies within the outer box.
|
|
22
|
+
function containment(inner, outer) {
|
|
23
|
+
const innerArea = area(inner);
|
|
24
|
+
if (innerArea <= 0)
|
|
25
|
+
return 0;
|
|
26
|
+
return intersectionArea(inner, outer) / innerArea;
|
|
27
|
+
}
|
|
28
|
+
function bestByLabel(objs, label) {
|
|
29
|
+
let best = null;
|
|
30
|
+
for (const o of objs) {
|
|
31
|
+
if (o.label !== label)
|
|
32
|
+
continue;
|
|
33
|
+
if (o.score < MIN_BOOKLET_SCORE)
|
|
34
|
+
continue;
|
|
35
|
+
if (o.box.width <= 0 || o.box.height <= 0)
|
|
36
|
+
continue;
|
|
37
|
+
if (!best || o.score > best.score)
|
|
38
|
+
best = o;
|
|
39
|
+
}
|
|
40
|
+
return best ? best.box : null;
|
|
41
|
+
}
|
|
42
|
+
function computeFraming(document, frameWidth, frameHeight) {
|
|
43
|
+
if (frameWidth <= 0 || frameHeight <= 0)
|
|
44
|
+
return 'tooFar';
|
|
45
|
+
const leftMargin = document.xMin / frameWidth;
|
|
46
|
+
const rightMargin = (frameWidth - document.xMax) / frameWidth;
|
|
47
|
+
const topMargin = document.yMin / frameHeight;
|
|
48
|
+
const bottomMargin = (frameHeight - document.yMax) / frameHeight;
|
|
49
|
+
const cutOff = leftMargin < BOOKLET_EDGE_PADDING ||
|
|
50
|
+
rightMargin < BOOKLET_EDGE_PADDING ||
|
|
51
|
+
topMargin < BOOKLET_EDGE_PADDING ||
|
|
52
|
+
bottomMargin < BOOKLET_EDGE_PADDING;
|
|
53
|
+
// Cut-off takes precedence over too-far: if it both clips an edge and fails to
|
|
54
|
+
// fill, the actionable instruction is "move back".
|
|
55
|
+
if (cutOff)
|
|
56
|
+
return 'cornersCutOff';
|
|
57
|
+
const fill = Math.max(document.width / frameWidth, document.height / frameHeight);
|
|
58
|
+
if (fill < BOOKLET_FILL_MIN)
|
|
59
|
+
return 'tooFar';
|
|
60
|
+
return 'ok';
|
|
61
|
+
}
|
|
62
|
+
// Orientation from the MRZ's position relative to the passport-page center.
|
|
63
|
+
// Image-space y grows downward, so MRZ below center = upright.
|
|
64
|
+
function computeOrientation(passportPage, mrz) {
|
|
65
|
+
const pageCx = (passportPage.xMin + passportPage.xMax) / 2;
|
|
66
|
+
const pageCy = (passportPage.yMin + passportPage.yMax) / 2;
|
|
67
|
+
const mrzCx = (mrz.xMin + mrz.xMax) / 2;
|
|
68
|
+
const mrzCy = (mrz.yMin + mrz.yMax) / 2;
|
|
69
|
+
const dx = mrzCx - pageCx;
|
|
70
|
+
const dy = mrzCy - pageCy;
|
|
71
|
+
if (Math.abs(dy) >= Math.abs(dx))
|
|
72
|
+
return dy > 0 ? 'upright' : 'upsideDown';
|
|
73
|
+
return 'rotated';
|
|
74
|
+
}
|
|
75
|
+
// The "full booklet" tell: on the side opposite the MRZ, the Document must
|
|
76
|
+
// extend beyond the Passport page by at least LEAF_VS_PAGE_MIN of the PAGE's
|
|
77
|
+
// extent along that axis — that extra region is the spread's second leaf. The
|
|
78
|
+
// page (not the document) is the denominator on purpose: physically the second
|
|
79
|
+
// leaf is the same size as the data page, so an angled shot that foreshortens
|
|
80
|
+
// the leaf to a thin strip scores ~0.1-0.2 and is rejected, while "slightly
|
|
81
|
+
// ajar" still projects ~0.5-0.7 and passes.
|
|
82
|
+
function computeLeafRatio(document, passportPage, mrz, orientation) {
|
|
83
|
+
if (orientation === 'upright') {
|
|
84
|
+
const gap = passportPage.yMin - document.yMin; // leaf above the data page
|
|
85
|
+
return gap / Math.max(1e-6, passportPage.height);
|
|
86
|
+
}
|
|
87
|
+
if (orientation === 'upsideDown') {
|
|
88
|
+
const gap = document.yMax - passportPage.yMax; // leaf below the data page
|
|
89
|
+
return gap / Math.max(1e-6, passportPage.height);
|
|
90
|
+
}
|
|
91
|
+
// rotated
|
|
92
|
+
const mrzCx = (mrz.xMin + mrz.xMax) / 2;
|
|
93
|
+
const pageCx = (passportPage.xMin + passportPage.xMax) / 2;
|
|
94
|
+
const gap = mrzCx < pageCx
|
|
95
|
+
? document.xMax - passportPage.xMax // MRZ left → leaf on the right
|
|
96
|
+
: passportPage.xMin - document.xMin; // MRZ right → leaf on the left
|
|
97
|
+
return gap / Math.max(1e-6, passportPage.width);
|
|
98
|
+
}
|
|
99
|
+
// A fully open booklet is elongated along the open direction (~125x176mm →
|
|
100
|
+
// aspect ~1.4) while a lone data page is elongated the other way (~0.7). An
|
|
101
|
+
// angled shot lands in between, so requiring the open-axis extent to at least
|
|
102
|
+
// match the cross axis rejects it independently of the leaf check — which
|
|
103
|
+
// matters when a mis-fit Passport page box makes the leaf gap look generous.
|
|
104
|
+
function computeAspectRatio(document, orientation) {
|
|
105
|
+
return orientation === 'rotated'
|
|
106
|
+
? document.width / Math.max(1e-6, document.height)
|
|
107
|
+
: document.height / Math.max(1e-6, document.width);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Decide whether the frame shows a fully-opened passport booklet, and report
|
|
111
|
+
* the Document's framing so the caller can pick "move closer" vs "move back".
|
|
112
|
+
* Pure: finds the best Document / Passport page / MRZ boxes by label (highest
|
|
113
|
+
* score above the confidence floor) and reasons geometrically. No React/state.
|
|
114
|
+
*/
|
|
115
|
+
export function analyzePassportBooklet(detectedObjects, frameWidth, frameHeight) {
|
|
116
|
+
const document = bestByLabel(detectedObjects, 'Document');
|
|
117
|
+
const passportPage = bestByLabel(detectedObjects, 'Passport page');
|
|
118
|
+
const mrz = bestByLabel(detectedObjects, 'MRZ');
|
|
119
|
+
// Framing drives the booklet guidance message. With a Document box we judge it
|
|
120
|
+
// directly. With NO Document box but a visible data leaf (Passport page / MRZ),
|
|
121
|
+
// the full spread is running off the frame — the user is too close for the
|
|
122
|
+
// whole booklet to be seen, so tell them to move back to fit all four corners,
|
|
123
|
+
// not closer. Only when nothing is detected at all is it genuinely too far.
|
|
124
|
+
const framing = document
|
|
125
|
+
? computeFraming(document, frameWidth, frameHeight)
|
|
126
|
+
: passportPage || mrz
|
|
127
|
+
? 'cornersCutOff'
|
|
128
|
+
: 'tooFar';
|
|
129
|
+
// Presence: all three boxes required. MRZ is the only orientation signal and
|
|
130
|
+
// the marker of the data-page leaf.
|
|
131
|
+
if (!document || !passportPage || !mrz) {
|
|
132
|
+
return { isFullBooklet: false, orientation: 'unknown', framing, metrics: null };
|
|
133
|
+
}
|
|
134
|
+
const orientation = computeOrientation(passportPage, mrz);
|
|
135
|
+
const metrics = {
|
|
136
|
+
mrzInPage: containment(mrz, passportPage),
|
|
137
|
+
pageInDocument: containment(passportPage, document),
|
|
138
|
+
leafRatio: computeLeafRatio(document, passportPage, mrz, orientation),
|
|
139
|
+
aspectRatio: computeAspectRatio(document, orientation),
|
|
140
|
+
};
|
|
141
|
+
// Concentric containment: MRZ ⊂ Passport page ⊂ Document. Rejects the
|
|
142
|
+
// non-concentric "screen / mismatched box" cases for free.
|
|
143
|
+
const concentric = metrics.mrzInPage >= CONTAINMENT_MIN &&
|
|
144
|
+
metrics.pageInDocument >= CONTAINMENT_MIN;
|
|
145
|
+
if (!concentric) {
|
|
146
|
+
return { isFullBooklet: false, orientation: 'unknown', framing, metrics };
|
|
147
|
+
}
|
|
148
|
+
const isFullBooklet = (orientation === 'upright' || orientation === 'rotated') &&
|
|
149
|
+
metrics.leafRatio >= LEAF_VS_PAGE_MIN &&
|
|
150
|
+
metrics.aspectRatio >= DOC_ASPECT_MIN;
|
|
151
|
+
return { isFullBooklet, orientation, framing, metrics };
|
|
152
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type RuntimeName } from './CapabilityProbing';
|
|
2
|
+
export declare const preloadModels: ({ documentDetectionModel, focusModel, faceDetectionModel, faceLandmarkerModel, barcodeReadabilityModel, runtime, documentDetectorRuntime, focusRuntime, barcodeReadabilityRuntime, faceLandmarkerRuntime, }: {
|
|
3
|
+
documentDetectionModel?: string | boolean;
|
|
4
|
+
focusModel?: string | boolean;
|
|
5
|
+
faceDetectionModel?: boolean;
|
|
6
|
+
faceLandmarkerModel?: boolean;
|
|
7
|
+
barcodeReadabilityModel?: boolean;
|
|
8
|
+
runtime?: RuntimeName;
|
|
9
|
+
documentDetectorRuntime?: RuntimeName;
|
|
10
|
+
focusRuntime?: RuntimeName;
|
|
11
|
+
barcodeReadabilityRuntime?: RuntimeName;
|
|
12
|
+
faceLandmarkerRuntime?: RuntimeName;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
export type PreloadProgress = {
|
|
15
|
+
loaded: number;
|
|
16
|
+
total: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function getCachedModelBuffer(url: string): Uint8Array | undefined;
|
|
19
|
+
export declare const progressByUseCase: {
|
|
20
|
+
visionRuntime: PreloadProgress;
|
|
21
|
+
documentDetector: PreloadProgress;
|
|
22
|
+
documentDetectorLiteRT: PreloadProgress;
|
|
23
|
+
focus: PreloadProgress;
|
|
24
|
+
focusLiteRT: PreloadProgress;
|
|
25
|
+
faceDetection: PreloadProgress;
|
|
26
|
+
faceLandmarker: PreloadProgress;
|
|
27
|
+
faceLandmarkerLiteRT: PreloadProgress;
|
|
28
|
+
barcodeReadability: PreloadProgress;
|
|
29
|
+
barcodeReadabilityLiteRT: PreloadProgress;
|
|
30
|
+
};
|
|
31
|
+
export declare function preloadDependency(url: string, hash: string): Promise<unknown>;
|
|
32
|
+
type PreloadableModel = 'documentDetector' | 'documentDetectorLiteRT' | 'focus' | 'focusLiteRT' | 'faceDetection' | 'faceLandmarker' | 'faceLandmarkerLiteRT' | 'barcodeReadability' | 'barcodeReadabilityLiteRT';
|
|
33
|
+
export declare const preloadDocumentDetectorDependencies: (runtime?: RuntimeName) => Promise<void>;
|
|
34
|
+
export declare const preloadFocusModelDependencies: (runtime?: RuntimeName) => Promise<void>;
|
|
35
|
+
export declare const preloadFaceDetectorDependencies: (runtime?: RuntimeName) => Promise<void>;
|
|
36
|
+
export declare const preloadFaceLandmarkerDependencies: (runtime?: RuntimeName) => Promise<void>;
|
|
37
|
+
export declare const preloadBarcodeReadabilityModelDependencies: (runtime?: RuntimeName) => Promise<void>;
|
|
38
|
+
export declare function preloadModelDependencies(model: PreloadableModel, runtime?: RuntimeName): Promise<void>;
|
|
39
|
+
export declare function progressToPercentage(progress: PreloadProgress): number;
|
|
40
|
+
export declare function sumUpProgressForDependencies(dependencies: string[]): PreloadProgress;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=preloadModels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preloadModels.d.ts","sourceRoot":"","sources":["../../src/models/preloadModels.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAIjB,MAAM,qBAAqB,CAAA;AAI5B,eAAO,MAAM,aAAa,GAAU,6MAWjC;IACD,sBAAsB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAI5B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAA;IAMjC,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,uBAAuB,CAAC,EAAE,WAAW,CAAA;IACrC,YAAY,CAAC,EAAE,WAAW,CAAA;IAC1B,yBAAyB,CAAC,EAAE,WAAW,CAAA;IACvC,qBAAqB,CAAC,EAAE,WAAW,CAAA;CACpC,KAAG,OAAO,CAAC,IAAI,CA8Df,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAKD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAExE;AACD,eAAO,MAAM,iBAAiB,EAAE;IAC9B,aAAa,EAAE,eAAe,CAAA;IAC9B,gBAAgB,EAAE,eAAe,CAAA;IACjC,sBAAsB,EAAE,eAAe,CAAA;IACvC,KAAK,EAAE,eAAe,CAAA;IACtB,WAAW,EAAE,eAAe,CAAA;IAC5B,aAAa,EAAE,eAAe,CAAA;IAC9B,cAAc,EAAE,eAAe,CAAA;IAC/B,oBAAoB,EAAE,eAAe,CAAA;IACrC,kBAAkB,EAAE,eAAe,CAAA;IACnC,wBAAwB,EAAE,eAAe,CAAA;CAY1C,CAAA;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAqChE;AAeD,KAAK,gBAAgB,GACjB,kBAAkB,GAClB,wBAAwB,GACxB,OAAO,GACP,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,sBAAsB,GACtB,oBAAoB,GACpB,0BAA0B,CAAA;AAkB9B,eAAO,MAAM,mCAAmC,GAC9C,UAAS,WAAyB,kBAKjC,CAAA;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAS,WAAyB,kBAKjC,CAAA;AACH,eAAO,MAAM,+BAA+B,GAC1C,UAAS,WAAyB,kBACmB,CAAA;AACvD,eAAO,MAAM,iCAAiC,GAC5C,UAAS,WAAyB,kBAKjC,CAAA;AACH,eAAO,MAAM,0CAA0C,GACrD,UAAS,WAAyB,kBAKjC,CAAA;AAEH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,WAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAgBf;AA+DD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,UAI7D;AAED,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,MAAM,EAAE,GACrB,eAAe,CAWjB"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { getDelegate, probeDelegateForRuntime, probeNetworkSpeed, } from './CapabilityProbing';
|
|
2
|
+
import { defaultModelPaths } from './defaults';
|
|
3
|
+
import { DEFAULT_RUNTIME } from './runtimeSelection';
|
|
4
|
+
export const preloadModels = async ({ documentDetectionModel = true, focusModel = true, faceDetectionModel = true, faceLandmarkerModel = true, barcodeReadabilityModel = true, runtime = DEFAULT_RUNTIME, documentDetectorRuntime, focusRuntime, barcodeReadabilityRuntime, faceLandmarkerRuntime, }) => {
|
|
5
|
+
const docRuntime = documentDetectorRuntime ?? runtime;
|
|
6
|
+
const focusRuntimeResolved = focusRuntime ?? runtime;
|
|
7
|
+
const faceRuntime = runtime;
|
|
8
|
+
const barcodeRuntime = barcodeReadabilityRuntime ?? runtime;
|
|
9
|
+
const faceLandmarkerRuntimeResolved = faceLandmarkerRuntime ?? runtime;
|
|
10
|
+
// Network probe is runtime-agnostic. The delegate probe is per-runtime;
|
|
11
|
+
// skip the MP probe entirely when the consumer is in LiteRT-only mode and
|
|
12
|
+
// is only preloading face detection.
|
|
13
|
+
await probeNetworkSpeed();
|
|
14
|
+
const docDetectIsLitert = docRuntime === 'litert' && !!documentDetectionModel;
|
|
15
|
+
const faceDetectIsLitert = faceRuntime === 'litert' && !!faceDetectionModel;
|
|
16
|
+
const focusIsLitert = focusRuntimeResolved === 'litert' && !!focusModel;
|
|
17
|
+
const faceLandmarkerIsLitert = faceLandmarkerRuntimeResolved === 'litert' && !!faceLandmarkerModel;
|
|
18
|
+
const barcodeIsLitert = barcodeRuntime === 'litert' && !!barcodeReadabilityModel;
|
|
19
|
+
const needsMediaPipe = (!!documentDetectionModel && !docDetectIsLitert) ||
|
|
20
|
+
(!!focusModel && !focusIsLitert) ||
|
|
21
|
+
(!!faceDetectionModel && !faceDetectIsLitert) ||
|
|
22
|
+
(!!faceLandmarkerModel && !faceLandmarkerIsLitert) ||
|
|
23
|
+
(!!barcodeReadabilityModel && !barcodeIsLitert);
|
|
24
|
+
const needsLitert = docDetectIsLitert ||
|
|
25
|
+
faceDetectIsLitert ||
|
|
26
|
+
focusIsLitert ||
|
|
27
|
+
faceLandmarkerIsLitert ||
|
|
28
|
+
barcodeIsLitert;
|
|
29
|
+
if (needsMediaPipe)
|
|
30
|
+
await probeDelegateForRuntime('mediapipe');
|
|
31
|
+
if (needsLitert)
|
|
32
|
+
await probeDelegateForRuntime('litert');
|
|
33
|
+
const preloadTasks = [];
|
|
34
|
+
if (documentDetectionModel) {
|
|
35
|
+
preloadTasks.push(preloadDocumentDetectorDependencies(docRuntime));
|
|
36
|
+
}
|
|
37
|
+
if (focusModel) {
|
|
38
|
+
preloadTasks.push(preloadFocusModelDependencies(focusRuntimeResolved));
|
|
39
|
+
}
|
|
40
|
+
if (faceDetectionModel) {
|
|
41
|
+
preloadTasks.push(preloadFaceDetectorDependencies(faceRuntime));
|
|
42
|
+
}
|
|
43
|
+
if (faceLandmarkerModel) {
|
|
44
|
+
preloadTasks.push(preloadFaceLandmarkerDependencies(faceLandmarkerRuntimeResolved));
|
|
45
|
+
}
|
|
46
|
+
if (barcodeReadabilityModel) {
|
|
47
|
+
preloadTasks.push(preloadBarcodeReadabilityModelDependencies(barcodeRuntime));
|
|
48
|
+
}
|
|
49
|
+
await Promise.all(preloadTasks);
|
|
50
|
+
};
|
|
51
|
+
const progressByUrl = {};
|
|
52
|
+
const modelBufferCache = new Map();
|
|
53
|
+
export function getCachedModelBuffer(url) {
|
|
54
|
+
return modelBufferCache.get(url);
|
|
55
|
+
}
|
|
56
|
+
export const progressByUseCase = {
|
|
57
|
+
visionRuntime: { loaded: 0, total: 0 },
|
|
58
|
+
documentDetector: { loaded: 0, total: 0 },
|
|
59
|
+
documentDetectorLiteRT: { loaded: 0, total: 0 },
|
|
60
|
+
focus: { loaded: 0, total: 0 },
|
|
61
|
+
focusLiteRT: { loaded: 0, total: 0 },
|
|
62
|
+
faceDetection: { loaded: 0, total: 0 },
|
|
63
|
+
faceLandmarker: { loaded: 0, total: 0 },
|
|
64
|
+
faceLandmarkerLiteRT: { loaded: 0, total: 0 },
|
|
65
|
+
barcodeReadability: { loaded: 0, total: 0 },
|
|
66
|
+
barcodeReadabilityLiteRT: { loaded: 0, total: 0 },
|
|
67
|
+
};
|
|
68
|
+
export async function preloadDependency(url, hash) {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const req = new XMLHttpRequest();
|
|
71
|
+
req.addEventListener('progress', (event) => {
|
|
72
|
+
if (!event.lengthComputable)
|
|
73
|
+
return;
|
|
74
|
+
progressByUrl[url] = event;
|
|
75
|
+
document.dispatchEvent(new CustomEvent('idmission.preloadProgress', {
|
|
76
|
+
detail: { url, loaded: event.loaded, total: event.total },
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
req.addEventListener('loadend', async () => {
|
|
80
|
+
try {
|
|
81
|
+
if (req.status !== 200 || req.readyState !== 4)
|
|
82
|
+
return resolve(false);
|
|
83
|
+
const ok = await verifySRI(req.response, hash);
|
|
84
|
+
if (!ok)
|
|
85
|
+
return reject(new Error(`SRI mismatch for ${url}`));
|
|
86
|
+
// Store the buffer for later use by model loaders
|
|
87
|
+
modelBufferCache.set(url, new Uint8Array(req.response));
|
|
88
|
+
resolve(true);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
reject(err);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
req.addEventListener('error', reject);
|
|
95
|
+
req.open('GET', url, true);
|
|
96
|
+
req.responseType = 'arraybuffer';
|
|
97
|
+
req.send();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function base64FromArrayBuffer(ab) {
|
|
101
|
+
const bytes = new Uint8Array(ab);
|
|
102
|
+
let bin = '';
|
|
103
|
+
for (let i = 0; i < bytes.length; i++)
|
|
104
|
+
bin += String.fromCharCode(bytes[i]);
|
|
105
|
+
return btoa(bin);
|
|
106
|
+
}
|
|
107
|
+
async function verifySRI(buf, hash) {
|
|
108
|
+
const hashBuf = await crypto.subtle.digest('SHA-384', buf);
|
|
109
|
+
const actualB64 = base64FromArrayBuffer(hashBuf);
|
|
110
|
+
return hash === actualB64;
|
|
111
|
+
}
|
|
112
|
+
// The in-flight attempt per model AND runtime, so concurrent callers share ONE
|
|
113
|
+
// attempt and its outcome. This was a boolean plus a 100ms polling loop that
|
|
114
|
+
// resolved as soon as the flag cleared — which meant a second caller resolved
|
|
115
|
+
// successfully even when the first had just failed, silently undoing the
|
|
116
|
+
// non-200 rejection below for everyone but the first caller.
|
|
117
|
+
//
|
|
118
|
+
// Keyed by runtime too because the attempt does a runtime-specific delegate
|
|
119
|
+
// probe, and `faceDetection` is reachable under BOTH runtimes (it is the one
|
|
120
|
+
// model with no separate `…LiteRT` name — see
|
|
121
|
+
// preloadFaceDetectorDependencies). Keyed by model alone, a litert caller
|
|
122
|
+
// could join a mediapipe attempt and never get the `No available delegate`
|
|
123
|
+
// error its own runtime warranted.
|
|
124
|
+
const modelsPreloading = new Map();
|
|
125
|
+
const preloadKey = (model, runtime) => `${model}:${runtime}`;
|
|
126
|
+
export const preloadDocumentDetectorDependencies = (runtime = 'mediapipe') => preloadModelDependencies(runtime === 'litert' ? 'documentDetectorLiteRT' : 'documentDetector', runtime);
|
|
127
|
+
export const preloadFocusModelDependencies = (runtime = 'mediapipe') => preloadModelDependencies(runtime === 'litert' ? 'focusLiteRT' : 'focus', runtime);
|
|
128
|
+
export const preloadFaceDetectorDependencies = (runtime = 'mediapipe') => preloadModelDependencies('faceDetection', runtime);
|
|
129
|
+
export const preloadFaceLandmarkerDependencies = (runtime = 'mediapipe') => preloadModelDependencies(runtime === 'litert' ? 'faceLandmarkerLiteRT' : 'faceLandmarker', runtime);
|
|
130
|
+
export const preloadBarcodeReadabilityModelDependencies = (runtime = 'mediapipe') => preloadModelDependencies(runtime === 'litert' ? 'barcodeReadabilityLiteRT' : 'barcodeReadability', runtime);
|
|
131
|
+
export async function preloadModelDependencies(model, runtime = 'mediapipe') {
|
|
132
|
+
// Join the in-flight attempt rather than starting a second download. Every
|
|
133
|
+
// joiner sees the same resolution — crucially including a rejection.
|
|
134
|
+
const key = preloadKey(model, runtime);
|
|
135
|
+
const inFlight = modelsPreloading.get(key);
|
|
136
|
+
if (inFlight)
|
|
137
|
+
return inFlight;
|
|
138
|
+
const attempt = runPreload(model, runtime);
|
|
139
|
+
modelsPreloading.set(key, attempt);
|
|
140
|
+
try {
|
|
141
|
+
await attempt;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
// Cleared here, not inside runPreload, so it is gone before any joiner's
|
|
145
|
+
// continuation runs and the next caller starts a fresh attempt.
|
|
146
|
+
modelsPreloading.delete(key);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function runPreload(model, runtime) {
|
|
150
|
+
{
|
|
151
|
+
// Probe the runtime that will actually run this model so we surface
|
|
152
|
+
// NONE before wasting bandwidth on bytes the device can't run.
|
|
153
|
+
await probeNetworkSpeed();
|
|
154
|
+
await probeDelegateForRuntime(runtime);
|
|
155
|
+
if (getDelegate(runtime) === 'NONE') {
|
|
156
|
+
throw new Error(`No available delegate for ${model} model.`);
|
|
157
|
+
}
|
|
158
|
+
const dependencies = [
|
|
159
|
+
{
|
|
160
|
+
url: defaultModelPaths[model],
|
|
161
|
+
hash: defaultModelPaths[(model + 'Hash')],
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
const handleModelDownloadProgress = (event) => {
|
|
165
|
+
const detail = event.detail;
|
|
166
|
+
if (!dependencies.some((d) => d.url === detail.url))
|
|
167
|
+
return;
|
|
168
|
+
progressByUseCase[model] = sumUpProgressForDependencies(dependencies.map((d) => d.url));
|
|
169
|
+
document.dispatchEvent(new CustomEvent(`idmission.preloadProgress.${model}`, {
|
|
170
|
+
detail: progressByUseCase[model],
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
document.addEventListener('idmission.preloadProgress', handleModelDownloadProgress);
|
|
174
|
+
try {
|
|
175
|
+
// preloadDependency resolves `false` on a non-200 (rather than rejecting,
|
|
176
|
+
// a contract 3 callers share), so treat a false result as a download
|
|
177
|
+
// failure here — otherwise a 404/403 model fetch (the "models not
|
|
178
|
+
// downloading" case) resolves as if the model were ready, and the first
|
|
179
|
+
// real inference is where the customer finds out.
|
|
180
|
+
const results = await Promise.all(dependencies.map((d) => preloadDependency(d.url, d.hash)));
|
|
181
|
+
if (results.some((ok) => ok === false)) {
|
|
182
|
+
throw new Error(`Model dependency for ${model} failed to download (non-200 response).`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
document.removeEventListener('idmission.preloadProgress', handleModelDownloadProgress);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export function progressToPercentage(progress) {
|
|
191
|
+
return progress.total > 0
|
|
192
|
+
? Math.round((100.0 * progress.loaded) / progress.total)
|
|
193
|
+
: 0;
|
|
194
|
+
}
|
|
195
|
+
export function sumUpProgressForDependencies(dependencies) {
|
|
196
|
+
return dependencies.reduce((result, dependency) => {
|
|
197
|
+
const dependencyProgress = progressByUrl[dependency];
|
|
198
|
+
if (!dependencyProgress)
|
|
199
|
+
return result;
|
|
200
|
+
result.loaded += dependencyProgress.loaded;
|
|
201
|
+
result.total += dependencyProgress.total;
|
|
202
|
+
return result;
|
|
203
|
+
}, { loaded: 0, total: 0 });
|
|
204
|
+
}
|
|
@@ -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 close(): void;
|
|
9
|
+
export declare function predict(imageData: Frame, cropCanvas: HTMLCanvasElement, rotateCanvas: HTMLCanvasElement, _resizeCanvas: HTMLCanvasElement, box?: DetectedObjectBox): Promise<BarcodeReadabilityPrediction | null>;
|
|
10
|
+
export declare function classifyForVideo(frame: Frame): void;
|
|
11
|
+
//# sourceMappingURL=BarcodeReadability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarcodeReadability.d.ts","sourceRoot":"","sources":["../../../../src/models/providers/litert/BarcodeReadability.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAsB,MAAM,mCAAmC,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAiB5E,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,CAyBzE;AAED,wBAAgB,KAAK,IAAI,IAAI,CAI5B;AAsBD,wBAAsB,OAAO,CAC3B,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,iBAAiB,EAC/B,aAAa,EAAE,iBAAiB,EAChC,GAAG,CAAC,EAAE,iBAAiB,GACtB,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA6C9C;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA0BnD"}
|