@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,534 @@
|
|
|
1
|
+
import { createStore } from 'zustand/vanilla';
|
|
2
|
+
import { acquireCamera, } from '../camera/acquireCamera';
|
|
3
|
+
import { CaptureAttachError } from '../idCapture/errors';
|
|
4
|
+
import { evaluateSignatureValidity, meetsSignaturePrefilter, resolveSignatureValidityConfig, } from '../signature/signatureValidity';
|
|
5
|
+
import { warn } from '../utils/logger';
|
|
6
|
+
import { createSignatureCapturePipeline, } from './pipeline';
|
|
7
|
+
import { reduceSignatureCapture } from './reducer';
|
|
8
|
+
import { createInitialSignatureCaptureState, } from './state';
|
|
9
|
+
/**
|
|
10
|
+
* Marks a microphone acquisition failure so `captureError` can type it.
|
|
11
|
+
*
|
|
12
|
+
* No parameter property (`constructor(readonly cause)`) — this package's tests
|
|
13
|
+
* run under `--experimental-strip-types`, which rejects that syntax.
|
|
14
|
+
*/
|
|
15
|
+
class MicrophoneAccessDeniedError extends Error {
|
|
16
|
+
constructor(cause) {
|
|
17
|
+
super(cause instanceof Error ? cause.message : 'Microphone access was denied', { cause });
|
|
18
|
+
this.name = 'MicrophoneAccessDeniedError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function captureError(error) {
|
|
22
|
+
if (error instanceof MicrophoneAccessDeniedError) {
|
|
23
|
+
return {
|
|
24
|
+
code: 'MICROPHONE_PERMISSION_DENIED',
|
|
25
|
+
message: error.message,
|
|
26
|
+
// Recoverable: the user can grant the permission and retry, exactly as
|
|
27
|
+
// sdk2's microphone-denied overlay offered.
|
|
28
|
+
recoverable: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (error instanceof CaptureAttachError) {
|
|
32
|
+
const code = error.captureError.code;
|
|
33
|
+
return {
|
|
34
|
+
code: code === 'CAMERA_PERMISSION_DENIED' || code === 'CAMERA_UNAVAILABLE'
|
|
35
|
+
? code
|
|
36
|
+
: 'CAPTURE_FAILED',
|
|
37
|
+
message: error.message,
|
|
38
|
+
recoverable: error.captureError.recoverable,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
code: 'CAPTURE_FAILED',
|
|
43
|
+
message: error instanceof Error ? error.message : String(error),
|
|
44
|
+
recoverable: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The view renders its own copy for this code rather than the raw `message`,
|
|
49
|
+
* which exists for host logs. Recoverable: `retry()` rebuilds the recorder over
|
|
50
|
+
* a fresh capture stream, which is all this needs.
|
|
51
|
+
*/
|
|
52
|
+
function interruptedError() {
|
|
53
|
+
return {
|
|
54
|
+
code: 'RECORDING_INTERRUPTED',
|
|
55
|
+
message: 'The signature recording was interrupted before it finished.',
|
|
56
|
+
recoverable: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function createSignatureCaptureController(config = {}) {
|
|
60
|
+
const mode = config.mode ?? 'video';
|
|
61
|
+
const now = config.io?.now ?? (() => new Date());
|
|
62
|
+
const acquire = config.io?.acquireCamera ?? acquireCamera;
|
|
63
|
+
const createPipeline = config.io?.createPipeline ??
|
|
64
|
+
((pipelineConfig) => createSignatureCapturePipeline(pipelineConfig));
|
|
65
|
+
const acquireMicrophone = config.io?.acquireMicrophone ??
|
|
66
|
+
(() => navigator.mediaDevices.getUserMedia({ audio: true }));
|
|
67
|
+
// Held for the life of the attachment, exactly like the camera handle: the
|
|
68
|
+
// recorder reads the track lazily at every recording start (clear/retry
|
|
69
|
+
// rebuild the recorder), so a per-recording acquisition would re-prompt.
|
|
70
|
+
const captureAudio = (config.captureAudio ?? false) && mode === 'video';
|
|
71
|
+
let microphone = null;
|
|
72
|
+
const validityConfig = resolveSignatureValidityConfig(config.signatureValidity, config.minSignaturePadPoints);
|
|
73
|
+
const store = createStore(() => createInitialSignatureCaptureState(mode));
|
|
74
|
+
const listeners = new Set();
|
|
75
|
+
let snapshot = store.getState();
|
|
76
|
+
let attachedVideo = null;
|
|
77
|
+
let attachedCanvas = null;
|
|
78
|
+
let camera = null;
|
|
79
|
+
let pipeline = null;
|
|
80
|
+
let generation = 0;
|
|
81
|
+
let disposed = false;
|
|
82
|
+
let attachPromise = null;
|
|
83
|
+
let cameraPromise = null;
|
|
84
|
+
let startPromise = null;
|
|
85
|
+
let acceptPromise = null;
|
|
86
|
+
const maxInterruptedRestarts = config.maxInterruptedRestarts ?? 3;
|
|
87
|
+
/** Consecutive interruptions this attempt — reset by a completed capture. */
|
|
88
|
+
let interruptedRestarts = 0;
|
|
89
|
+
function bindElements(video, signatureCanvas) {
|
|
90
|
+
const previousVideo = attachedVideo;
|
|
91
|
+
const stream = camera?.camera.stream;
|
|
92
|
+
if (previousVideo &&
|
|
93
|
+
previousVideo !== video &&
|
|
94
|
+
stream &&
|
|
95
|
+
previousVideo.srcObject === stream) {
|
|
96
|
+
previousVideo.srcObject = null;
|
|
97
|
+
}
|
|
98
|
+
attachedVideo = video;
|
|
99
|
+
attachedCanvas = signatureCanvas;
|
|
100
|
+
if (stream)
|
|
101
|
+
video.srcObject = stream;
|
|
102
|
+
}
|
|
103
|
+
function publish() {
|
|
104
|
+
snapshot = store.getState();
|
|
105
|
+
for (const listener of listeners) {
|
|
106
|
+
try {
|
|
107
|
+
listener(snapshot);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// One consumer listener cannot break capture or sibling listeners.
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function dispatch(event) {
|
|
115
|
+
const current = store.getState();
|
|
116
|
+
const next = reduceSignatureCapture(current, event);
|
|
117
|
+
if (next === current)
|
|
118
|
+
return;
|
|
119
|
+
store.setState(next, true);
|
|
120
|
+
publish();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Ends the attempt at the interruption instead of letting the user finish
|
|
124
|
+
* one that cannot succeed: `MediaRecorder`'s `inactive` is terminal, so from
|
|
125
|
+
* here on the pad still works but nothing is being recorded.
|
|
126
|
+
*
|
|
127
|
+
* Only fires mid-capture. Outside `capturing` there is no attempt to end —
|
|
128
|
+
* the recording is either not the user's yet or already being finalized.
|
|
129
|
+
*/
|
|
130
|
+
function handleRecordingInterrupted(info) {
|
|
131
|
+
if (disposed || store.getState().phase !== 'capturing')
|
|
132
|
+
return;
|
|
133
|
+
const hadInk = store.getState().pointCount > 0;
|
|
134
|
+
// At the cap we stop restarting and let the capture complete: it will be
|
|
135
|
+
// hard-failed by the `recorderDied` quality signal and reported at-risk,
|
|
136
|
+
// which beats trapping the user on a screen that keeps resetting.
|
|
137
|
+
const capped = interruptedRestarts >= maxInterruptedRestarts;
|
|
138
|
+
if (!capped)
|
|
139
|
+
interruptedRestarts += 1;
|
|
140
|
+
try {
|
|
141
|
+
config.onSignatureCaptureInterrupted?.({
|
|
142
|
+
...info,
|
|
143
|
+
hadInk,
|
|
144
|
+
interruptionCount: interruptedRestarts,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
warn('[signatureCapture] onSignatureCaptureInterrupted handler threw', error);
|
|
149
|
+
}
|
|
150
|
+
if (capped)
|
|
151
|
+
return;
|
|
152
|
+
// Nothing drawn yet: there is no lost work to explain and no pad to clear,
|
|
153
|
+
// so a silent restart leaves the user where they are, none the wiser.
|
|
154
|
+
if (!hadInk) {
|
|
155
|
+
void pipeline?.restart().catch(() => {
|
|
156
|
+
if (!disposed)
|
|
157
|
+
dispatch({ type: 'failed', error: interruptedError() });
|
|
158
|
+
});
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// End the recording before showing the recovery screen. The attempt is
|
|
162
|
+
// over, but the frame loop would otherwise keep compositing the camera
|
|
163
|
+
// into a stream nobody records — for as long as the user reads the screen,
|
|
164
|
+
// or forever if they abandon it. `retry()` brings the next one up.
|
|
165
|
+
void pipeline?.endRecording().catch((error) => {
|
|
166
|
+
warn('[signatureCapture] ending the interrupted recording failed', error);
|
|
167
|
+
});
|
|
168
|
+
dispatch({ type: 'failed', error: interruptedError() });
|
|
169
|
+
}
|
|
170
|
+
async function doRequestCamera(runGeneration) {
|
|
171
|
+
if (mode === 'still' || camera)
|
|
172
|
+
return;
|
|
173
|
+
if (!attachedVideo)
|
|
174
|
+
throw new Error('attach() must be called first');
|
|
175
|
+
const requestedVideo = attachedVideo;
|
|
176
|
+
dispatch({ type: 'cameraRequested' });
|
|
177
|
+
try {
|
|
178
|
+
const acquired = await acquire(requestedVideo, {
|
|
179
|
+
preferFrontFacingCamera: true,
|
|
180
|
+
...config.camera,
|
|
181
|
+
});
|
|
182
|
+
if (disposed || runGeneration !== generation) {
|
|
183
|
+
acquired.release();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
camera = acquired;
|
|
187
|
+
if (attachedVideo && attachedVideo !== requestedVideo) {
|
|
188
|
+
if (requestedVideo.srcObject === acquired.camera.stream) {
|
|
189
|
+
requestedVideo.srcObject = null;
|
|
190
|
+
}
|
|
191
|
+
attachedVideo.srcObject = acquired.camera.stream;
|
|
192
|
+
}
|
|
193
|
+
dispatch({ type: 'cameraReady', isRearFacing: acquired.isRearFacing });
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
if (disposed || runGeneration !== generation)
|
|
197
|
+
return;
|
|
198
|
+
dispatch({ type: 'failed', error: captureError(error) });
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function requestCamera() {
|
|
203
|
+
if (cameraPromise)
|
|
204
|
+
return cameraPromise;
|
|
205
|
+
const runGeneration = generation;
|
|
206
|
+
cameraPromise = doRequestCamera(runGeneration).finally(() => {
|
|
207
|
+
cameraPromise = null;
|
|
208
|
+
});
|
|
209
|
+
return cameraPromise;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Acquires the microphone once per attachment. Shared by `doAttach` and
|
|
213
|
+
* `retry` because a camera failure releases the microphone while leaving the
|
|
214
|
+
* pipeline intact — so retry's reattach path does not run, and without this
|
|
215
|
+
* the retry would succeed and record a SILENT signature.
|
|
216
|
+
*/
|
|
217
|
+
async function ensureMicrophone() {
|
|
218
|
+
if (!captureAudio || microphone)
|
|
219
|
+
return;
|
|
220
|
+
microphone = await acquireMicrophone().catch((cause) => {
|
|
221
|
+
// Distinguished from a camera failure so the view can show the
|
|
222
|
+
// microphone screen (and its own retry) rather than a generic error.
|
|
223
|
+
throw new MicrophoneAccessDeniedError(cause);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function stopMicrophone() {
|
|
227
|
+
microphone?.getTracks().forEach((track) => track.stop());
|
|
228
|
+
microphone = null;
|
|
229
|
+
}
|
|
230
|
+
async function doAttach(runGeneration) {
|
|
231
|
+
dispatch({ type: 'loadingStarted' });
|
|
232
|
+
let resolved = null;
|
|
233
|
+
try {
|
|
234
|
+
resolved = await createPipeline({
|
|
235
|
+
...config.pipeline,
|
|
236
|
+
recordVideo: mode === 'video',
|
|
237
|
+
simulateAtRiskWarning: config.simulateAtRiskWarning,
|
|
238
|
+
simulateRecordingInterrupted: config.simulateRecordingInterrupted,
|
|
239
|
+
onRecordingStarted: () => dispatch({ type: 'recordingStarted' }),
|
|
240
|
+
onFirstChunkReceived: () => dispatch({ type: 'firstChunkReceived' }),
|
|
241
|
+
onRecordingInterrupted: handleRecordingInterrupted,
|
|
242
|
+
getAudioTrack: () => microphone?.getAudioTracks()[0] ?? null,
|
|
243
|
+
});
|
|
244
|
+
if (disposed || runGeneration !== generation) {
|
|
245
|
+
resolved.dispose();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
pipeline = resolved;
|
|
249
|
+
await resolved.warmUp();
|
|
250
|
+
if (disposed || runGeneration !== generation) {
|
|
251
|
+
resolved.dispose();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (!attachedVideo || !attachedCanvas) {
|
|
255
|
+
resolved.dispose();
|
|
256
|
+
throw new Error('Signature capture elements were detached');
|
|
257
|
+
}
|
|
258
|
+
// sdk2 asked for the microphone up front too (its loading overlay's
|
|
259
|
+
// `requireMicrophoneAccess={captureAudio}`), so the prompt lands before
|
|
260
|
+
// the user starts signing rather than interrupting mid-signature.
|
|
261
|
+
await ensureMicrophone();
|
|
262
|
+
if (disposed || runGeneration !== generation) {
|
|
263
|
+
stopMicrophone();
|
|
264
|
+
resolved.dispose();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
resolved.attach(attachedVideo, attachedCanvas);
|
|
268
|
+
dispatch({ type: 'pipelineReady' });
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
if (disposed || runGeneration !== generation)
|
|
272
|
+
return;
|
|
273
|
+
resolved?.dispose();
|
|
274
|
+
// A throw AFTER acquisition (the attach below, say) would otherwise
|
|
275
|
+
// leave the microphone live — recording indicator on — with no path to
|
|
276
|
+
// release it short of detach.
|
|
277
|
+
stopMicrophone();
|
|
278
|
+
if (pipeline === resolved)
|
|
279
|
+
pipeline = null;
|
|
280
|
+
const mapped = captureError(error);
|
|
281
|
+
dispatch({
|
|
282
|
+
type: 'failed',
|
|
283
|
+
error: mapped.code === 'CAPTURE_FAILED'
|
|
284
|
+
? { ...mapped, code: 'PIPELINE_LOAD_FAILED' }
|
|
285
|
+
: mapped,
|
|
286
|
+
});
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
if (!config.deferCameraAcquisition) {
|
|
290
|
+
// Outside the try above, so a camera rejection here would otherwise skip
|
|
291
|
+
// the cleanup and leave a just-acquired microphone live.
|
|
292
|
+
try {
|
|
293
|
+
await requestCamera();
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
stopMicrophone();
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function attach(video, signatureCanvas) {
|
|
302
|
+
const elementsChanged = video !== attachedVideo || signatureCanvas !== attachedCanvas;
|
|
303
|
+
bindElements(video, signatureCanvas);
|
|
304
|
+
if (attachPromise)
|
|
305
|
+
return attachPromise;
|
|
306
|
+
if (pipeline && store.getState().pipeline.ready) {
|
|
307
|
+
if (elementsChanged)
|
|
308
|
+
pipeline.attach(video, signatureCanvas);
|
|
309
|
+
return Promise.resolve();
|
|
310
|
+
}
|
|
311
|
+
disposed = false;
|
|
312
|
+
const runGeneration = ++generation;
|
|
313
|
+
attachPromise = doAttach(runGeneration).finally(() => {
|
|
314
|
+
attachPromise = null;
|
|
315
|
+
});
|
|
316
|
+
return attachPromise;
|
|
317
|
+
}
|
|
318
|
+
async function start() {
|
|
319
|
+
if (startPromise)
|
|
320
|
+
return startPromise;
|
|
321
|
+
startPromise = (async () => {
|
|
322
|
+
if (disposed)
|
|
323
|
+
return;
|
|
324
|
+
if (!pipeline)
|
|
325
|
+
throw new Error('Signature pipeline is not ready');
|
|
326
|
+
if (mode === 'video' && !camera)
|
|
327
|
+
await requestCamera();
|
|
328
|
+
if (disposed)
|
|
329
|
+
return;
|
|
330
|
+
dispatch({ type: 'started' });
|
|
331
|
+
if (store.getState().phase !== 'capturing')
|
|
332
|
+
return;
|
|
333
|
+
try {
|
|
334
|
+
await pipeline.start();
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
if (!disposed)
|
|
338
|
+
dispatch({ type: 'failed', error: captureError(error) });
|
|
339
|
+
throw error;
|
|
340
|
+
}
|
|
341
|
+
})().finally(() => {
|
|
342
|
+
startPromise = null;
|
|
343
|
+
});
|
|
344
|
+
return startPromise;
|
|
345
|
+
}
|
|
346
|
+
async function clear() {
|
|
347
|
+
if (store.getState().phase !== 'capturing')
|
|
348
|
+
return;
|
|
349
|
+
dispatch({ type: 'cleared' });
|
|
350
|
+
if (mode === 'video' && (config.restartVideoOnClear ?? true)) {
|
|
351
|
+
try {
|
|
352
|
+
await pipeline?.clear();
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
if (!disposed)
|
|
356
|
+
dispatch({ type: 'failed', error: captureError(error) });
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function accept() {
|
|
362
|
+
if (acceptPromise)
|
|
363
|
+
return acceptPromise;
|
|
364
|
+
acceptPromise = (async () => {
|
|
365
|
+
const state = store.getState();
|
|
366
|
+
if (disposed ||
|
|
367
|
+
state.phase !== 'capturing' ||
|
|
368
|
+
!state.guidance.satisfied ||
|
|
369
|
+
!pipeline ||
|
|
370
|
+
!attachedCanvas) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const validity = evaluateSignatureValidity(state.strokes, attachedCanvas.width, attachedCanvas.height, validityConfig);
|
|
374
|
+
if (validity.concern && config.onSignatureValidityConcern) {
|
|
375
|
+
try {
|
|
376
|
+
config.onSignatureValidityConcern(validity);
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
warn('[signatureCapture] onSignatureValidityConcern handler threw', error);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
dispatch({ type: 'processing' });
|
|
383
|
+
try {
|
|
384
|
+
const result = await pipeline.stop({
|
|
385
|
+
strokes: state.strokes,
|
|
386
|
+
pointerSignals: state.pointerSignals,
|
|
387
|
+
validity,
|
|
388
|
+
});
|
|
389
|
+
if (disposed)
|
|
390
|
+
return;
|
|
391
|
+
const capturedAt = now();
|
|
392
|
+
const artifact = {
|
|
393
|
+
data: result.data,
|
|
394
|
+
imageDataUrl: result.imageDataUrl,
|
|
395
|
+
videoBlob: result.videoBlob,
|
|
396
|
+
metadata: result.metadata,
|
|
397
|
+
validity,
|
|
398
|
+
capturedAt,
|
|
399
|
+
pointerSignals: state.pointerSignals,
|
|
400
|
+
};
|
|
401
|
+
// The cap counts CONSECUTIVE interruptions, so a capture that made it
|
|
402
|
+
// all the way through clears the tally for any later attempt.
|
|
403
|
+
interruptedRestarts = 0;
|
|
404
|
+
dispatch({ type: 'captured', artifact });
|
|
405
|
+
if (result.atRisk &&
|
|
406
|
+
result.qualityWarning &&
|
|
407
|
+
result.metadata &&
|
|
408
|
+
config.onSignatureCaptureAtRisk) {
|
|
409
|
+
try {
|
|
410
|
+
config.onSignatureCaptureAtRisk(result.qualityWarning, result.metadata);
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
warn('[signatureCapture] onSignatureCaptureAtRisk handler threw', error);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
if (!disposed)
|
|
419
|
+
dispatch({ type: 'failed', error: captureError(error) });
|
|
420
|
+
throw error;
|
|
421
|
+
}
|
|
422
|
+
})().finally(() => {
|
|
423
|
+
acceptPromise = null;
|
|
424
|
+
});
|
|
425
|
+
return acceptPromise;
|
|
426
|
+
}
|
|
427
|
+
async function retry() {
|
|
428
|
+
if (disposed)
|
|
429
|
+
return;
|
|
430
|
+
dispatch({ type: 'retry' });
|
|
431
|
+
// A failed attach disposes the pipeline and nulls it, so recovery is
|
|
432
|
+
// re-running attach -- not just re-requesting devices. Without this the
|
|
433
|
+
// retry offered ON a microphone denial cannot fix what it was offered
|
|
434
|
+
// for: the microphone comes back but `start()` throws "pipeline is not
|
|
435
|
+
// ready". doAttach re-acquires the microphone on the way through.
|
|
436
|
+
if (!pipeline && attachedVideo && attachedCanvas) {
|
|
437
|
+
await attach(attachedVideo, attachedCanvas);
|
|
438
|
+
}
|
|
439
|
+
if (mode === 'video' && !camera)
|
|
440
|
+
await requestCamera();
|
|
441
|
+
// The reattach above only runs when a failed attach disposed the pipeline.
|
|
442
|
+
// A CAMERA failure leaves the pipeline intact but still releases the
|
|
443
|
+
// microphone, so acquisition has to be reasserted here either way.
|
|
444
|
+
try {
|
|
445
|
+
await ensureMicrophone();
|
|
446
|
+
}
|
|
447
|
+
catch (cause) {
|
|
448
|
+
dispatch({ type: 'failed', error: captureError(cause) });
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (store.getState().phase === 'ready')
|
|
452
|
+
await start();
|
|
453
|
+
}
|
|
454
|
+
function collectArtifacts() {
|
|
455
|
+
const artifact = store.getState().artifact;
|
|
456
|
+
if (!artifact)
|
|
457
|
+
return {};
|
|
458
|
+
const capturedAt = artifact.capturedAt.toISOString();
|
|
459
|
+
return {
|
|
460
|
+
signature: {
|
|
461
|
+
data: artifact.data,
|
|
462
|
+
dataCapturedAt: capturedAt,
|
|
463
|
+
videoBlob: artifact.videoBlob,
|
|
464
|
+
videoCapturedAt: artifact.videoBlob ? capturedAt : null,
|
|
465
|
+
videoMetadata: artifact.metadata,
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
attach,
|
|
471
|
+
detach() {
|
|
472
|
+
disposed = true;
|
|
473
|
+
generation += 1;
|
|
474
|
+
pipeline?.dispose();
|
|
475
|
+
camera?.release();
|
|
476
|
+
stopMicrophone();
|
|
477
|
+
if (attachedVideo)
|
|
478
|
+
attachedVideo.srcObject = null;
|
|
479
|
+
pipeline = null;
|
|
480
|
+
camera = null;
|
|
481
|
+
attachedVideo = null;
|
|
482
|
+
attachedCanvas = null;
|
|
483
|
+
attachPromise = null;
|
|
484
|
+
cameraPromise = null;
|
|
485
|
+
startPromise = null;
|
|
486
|
+
acceptPromise = null;
|
|
487
|
+
interruptedRestarts = 0;
|
|
488
|
+
dispatch({ type: 'reset' });
|
|
489
|
+
},
|
|
490
|
+
getState: () => snapshot,
|
|
491
|
+
subscribe(cb) {
|
|
492
|
+
listeners.add(cb);
|
|
493
|
+
return () => listeners.delete(cb);
|
|
494
|
+
},
|
|
495
|
+
collectArtifacts,
|
|
496
|
+
actions: {
|
|
497
|
+
requestCamera,
|
|
498
|
+
start,
|
|
499
|
+
setStrokes(strokes) {
|
|
500
|
+
if (store.getState().phase !== 'capturing')
|
|
501
|
+
return;
|
|
502
|
+
pipeline?.updateStrokes(strokes);
|
|
503
|
+
dispatch({
|
|
504
|
+
type: 'strokesChanged',
|
|
505
|
+
strokes,
|
|
506
|
+
valid: meetsSignaturePrefilter(strokes, validityConfig),
|
|
507
|
+
});
|
|
508
|
+
},
|
|
509
|
+
recordPointerSignal(signal) {
|
|
510
|
+
if (store.getState().phase !== 'capturing')
|
|
511
|
+
return;
|
|
512
|
+
// Mark the live signing window before signature_pad finalizes the stroke.
|
|
513
|
+
// The authoritative stroke data is still supplied by setStrokes().
|
|
514
|
+
pipeline?.updateStrokes([
|
|
515
|
+
[
|
|
516
|
+
{
|
|
517
|
+
x: signal.x,
|
|
518
|
+
y: signal.y,
|
|
519
|
+
time: signal.at,
|
|
520
|
+
pressure: signal.pressure,
|
|
521
|
+
},
|
|
522
|
+
],
|
|
523
|
+
]);
|
|
524
|
+
dispatch({ type: 'pointerSignal', signal });
|
|
525
|
+
},
|
|
526
|
+
clear,
|
|
527
|
+
accept,
|
|
528
|
+
retry,
|
|
529
|
+
done() {
|
|
530
|
+
dispatch({ type: 'completed' });
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const SignatureCaptureGuidanceCode: {
|
|
2
|
+
readonly NONE: "NONE";
|
|
3
|
+
readonly SIGN_HERE: "SIGN_HERE";
|
|
4
|
+
readonly KEEP_SIGNING: "KEEP_SIGNING";
|
|
5
|
+
readonly READY_TO_ACCEPT: "READY_TO_ACCEPT";
|
|
6
|
+
readonly PROCESSING: "PROCESSING";
|
|
7
|
+
};
|
|
8
|
+
export type SignatureCaptureGuidanceCode = (typeof SignatureCaptureGuidanceCode)[keyof typeof SignatureCaptureGuidanceCode];
|
|
9
|
+
//# sourceMappingURL=guidance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guidance.d.ts","sourceRoot":"","sources":["../../src/signatureCapture/guidance.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B;;;;;;CAM/B,CAAA;AAEV,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,OAAO,4BAA4B,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createSignatureCaptureController, type SignatureCaptureController, type SignatureCaptureControllerConfig, } from './controller';
|
|
2
|
+
export { createSignatureCapturePipeline, buildSignatureData, waitForEncoderDrain, type SignatureCapturePipeline, type SignatureCapturePipelineConfig, type SignaturePipelineResult, } from './pipeline';
|
|
3
|
+
export { SignatureCaptureGuidanceCode } from './guidance';
|
|
4
|
+
export { createInitialSignatureCaptureState, type SignatureCaptureArtifact, type SignatureCaptureControllerState, type SignatureCaptureError, type SignatureCapturePhase, type SignaturePoint, type SignaturePointerSignal, type SignatureRecordingInterruptedDetail, type SignatureRecordingInterruptedReason, type SignatureStroke, } from './state';
|
|
5
|
+
export { reduceSignatureCapture, type SignatureCaptureEvent } from './reducer';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signatureCapture/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,GACtC,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,GAC7B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EACL,kCAAkC,EAClC,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,mCAAmC,EACxC,KAAK,mCAAmC,EACxC,KAAK,eAAe,GACrB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createSignatureCaptureController, } from './controller';
|
|
2
|
+
export { createSignatureCapturePipeline, buildSignatureData, waitForEncoderDrain, } from './pipeline';
|
|
3
|
+
export { SignatureCaptureGuidanceCode } from './guidance';
|
|
4
|
+
export { createInitialSignatureCaptureState, } from './state';
|
|
5
|
+
export { reduceSignatureCapture } from './reducer';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { SignatureData } from '../client/artifacts';
|
|
2
|
+
import { validateDecodableFrames } from '../signature/frameDecode';
|
|
3
|
+
import type { VideoSignatureMetadata } from '../signature/metadata';
|
|
4
|
+
import { type RecorderState, type VideoSignatureQualityWarning } from '../signature/quality';
|
|
5
|
+
import type { SignatureValidityResult } from '../signature/signatureValidity';
|
|
6
|
+
import type { SignaturePointerSignal, SignatureRecordingInterruptedReason, SignatureStroke } from './state';
|
|
7
|
+
export type SignaturePipelineResult = {
|
|
8
|
+
data: SignatureData;
|
|
9
|
+
imageDataUrl: string;
|
|
10
|
+
videoBlob: Blob | null;
|
|
11
|
+
metadata: VideoSignatureMetadata | null;
|
|
12
|
+
qualityWarning: VideoSignatureQualityWarning | null;
|
|
13
|
+
atRisk: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type SignatureCapturePipeline = {
|
|
16
|
+
warmUp(): Promise<void>;
|
|
17
|
+
attach(video: HTMLVideoElement, signatureCanvas: HTMLCanvasElement): void;
|
|
18
|
+
start(): Promise<void>;
|
|
19
|
+
updateStrokes(strokes: SignatureStroke[]): void;
|
|
20
|
+
stop(input: {
|
|
21
|
+
strokes: SignatureStroke[];
|
|
22
|
+
pointerSignals: SignaturePointerSignal[];
|
|
23
|
+
validity: SignatureValidityResult;
|
|
24
|
+
}): Promise<SignaturePipelineResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Ends the current recording WITHOUT starting another: releases the
|
|
27
|
+
* recorder, the capture stream, the frame loop and the visibility listener.
|
|
28
|
+
* For an interrupted attempt, where the user may sit on the recovery screen
|
|
29
|
+
* — or abandon it — before anything restarts. `start()` brings the next
|
|
30
|
+
* recording up.
|
|
31
|
+
*/
|
|
32
|
+
endRecording(): Promise<void>;
|
|
33
|
+
/** Rebuilds the recorder over a fresh capture stream, keeping the attempt's
|
|
34
|
+
* user-visible counters. `clear()` is this plus a user-clear tally. */
|
|
35
|
+
restart(): Promise<void>;
|
|
36
|
+
clear(): Promise<void>;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
};
|
|
39
|
+
export type SignatureCapturePipelineConfig = {
|
|
40
|
+
recordVideo?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Live microphone track to record ALONGSIDE the signature canvas, for
|
|
43
|
+
* sdk2's `captureAudio`. Read at recorder construction (not at pipeline
|
|
44
|
+
* creation) because the controller acquires the microphone asynchronously,
|
|
45
|
+
* after the pipeline exists. Returning null/undefined records video only,
|
|
46
|
+
* which is the default and what every non-`captureAudio` flow gets.
|
|
47
|
+
*/
|
|
48
|
+
getAudioTrack?: () => MediaStreamTrack | null | undefined;
|
|
49
|
+
simulateAtRiskWarning?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Debug switch for the interrupted-recording flow, mirroring
|
|
52
|
+
* `simulateAtRiskWarning`. Kills the real recorder shortly after the user
|
|
53
|
+
* starts signing, so the genuine death path runs — the poll in `start()`
|
|
54
|
+
* observes it exactly as it would after a phone call, rather than the signal
|
|
55
|
+
* being synthesised. Re-arms on each restart, so repeated signing walks the
|
|
56
|
+
* restart cap.
|
|
57
|
+
*/
|
|
58
|
+
simulateRecordingInterrupted?: boolean;
|
|
59
|
+
evaluateFrameDecode?: boolean;
|
|
60
|
+
onRecordingStarted?: () => void;
|
|
61
|
+
onFirstChunkReceived?: () => void;
|
|
62
|
+
/**
|
|
63
|
+
* The recorder ended without being asked to, so everything from here on goes
|
|
64
|
+
* unrecorded. Fires at most once per recording (`noteRecorderDied` keeps only
|
|
65
|
+
* the first observation) and never for a death seen while stopping — that one
|
|
66
|
+
* is the encoder finishing, not an interruption.
|
|
67
|
+
*/
|
|
68
|
+
onRecordingInterrupted?: (detail: {
|
|
69
|
+
reason: SignatureRecordingInterruptedReason;
|
|
70
|
+
state: RecorderState;
|
|
71
|
+
error?: string;
|
|
72
|
+
}) => void;
|
|
73
|
+
io?: {
|
|
74
|
+
now?: () => number;
|
|
75
|
+
setTimeout?: typeof setTimeout;
|
|
76
|
+
clearTimeout?: typeof clearTimeout;
|
|
77
|
+
setInterval?: typeof setInterval;
|
|
78
|
+
clearInterval?: typeof clearInterval;
|
|
79
|
+
createCanvas?: () => HTMLCanvasElement;
|
|
80
|
+
createMediaRecorder?: (stream: MediaStream, options: MediaRecorderOptions) => MediaRecorder;
|
|
81
|
+
createMediaStream?: (tracks: MediaStreamTrack[]) => MediaStream;
|
|
82
|
+
validateDecodableFrames?: typeof validateDecodableFrames;
|
|
83
|
+
};
|
|
84
|
+
drain?: {
|
|
85
|
+
minWaitMs?: number;
|
|
86
|
+
maxWaitMs?: number;
|
|
87
|
+
pollIntervalMs?: number;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export declare function buildSignatureData(strokes: SignatureStroke[], imageDataUrl: string): SignatureData;
|
|
91
|
+
export declare function waitForEncoderDrain(input: {
|
|
92
|
+
recorder: Pick<MediaRecorder, 'requestData' | 'state'>;
|
|
93
|
+
initialLastValueAt: number;
|
|
94
|
+
getLastValueAt: () => number;
|
|
95
|
+
now: () => number;
|
|
96
|
+
sleep: (ms: number) => Promise<void>;
|
|
97
|
+
setInterval: typeof setInterval;
|
|
98
|
+
clearInterval: typeof clearInterval;
|
|
99
|
+
minWaitMs?: number;
|
|
100
|
+
maxWaitMs?: number;
|
|
101
|
+
pollIntervalMs?: number;
|
|
102
|
+
/** Called if the recorder is found outside `recording` mid-drain — it ended
|
|
103
|
+
* before we asked it to, so nothing more is coming. */
|
|
104
|
+
onRecorderDied?: (state: RecorderState) => void;
|
|
105
|
+
}): Promise<{
|
|
106
|
+
waitedMs: number;
|
|
107
|
+
finalChunkReceived: boolean;
|
|
108
|
+
timedOut: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
export declare function createSignatureCapturePipeline(config?: SignatureCapturePipelineConfig): SignatureCapturePipeline;
|
|
111
|
+
//# sourceMappingURL=pipeline.d.ts.map
|