@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,224 @@
|
|
|
1
|
+
// Framework-free port of sdk2's `requestCameraAccess`
|
|
2
|
+
// (sdk2/src/lib/camera/cameraStore.tsx:142-387) plus `releaseCameraAccess`
|
|
3
|
+
// (:389-407). The zustand store there mutates shared reactive state
|
|
4
|
+
// (`set({...})`) that React components subscribe to; this port has no store,
|
|
5
|
+
// so every `set(...)` call becomes one of: a value carried on the resolved
|
|
6
|
+
// `AcquiredCamera`, a typed rejection (`CaptureAttachError`), or the
|
|
7
|
+
// `onEnded` callback. See errors.ts for the sanctioned error-mapping
|
|
8
|
+
// divergences from sdk2's "set a flag and return" style.
|
|
9
|
+
import { backUltraWideCameraLabels, cameraLabelMatches, frontCameraLabels, listAvailableCameras as defaultListAvailableCameras, obtainCameraAccess, rearCameraLabels, releaseCameraAccess as releaseGlobalCameraAccess, } from './Camera';
|
|
10
|
+
import { guardGetUserMedia } from './getUserMediaIntegrity';
|
|
11
|
+
import { captureCameraSignals } from './cameraSignals';
|
|
12
|
+
import { isVirtualCamera } from './isVirtualCamera';
|
|
13
|
+
import { getPlatform as defaultGetPlatform } from '../utils/platform';
|
|
14
|
+
import { debug, error } from '../utils/logger';
|
|
15
|
+
import { CaptureAttachError } from '../idCapture/errors';
|
|
16
|
+
const LOG_TAG = 'camera:acquireCamera';
|
|
17
|
+
export async function acquireCamera(videoEl, opts = {}) {
|
|
18
|
+
const { preferFrontFacingCamera = false, preferIphoneContinuityCamera = true, allowVirtualCameras = false, enableTamperDetection = false, mediaIntegrityToken, maxVideoWidth = 1920, maxFps, onEnded, io = {}, } = opts;
|
|
19
|
+
const getUserMedia = io.getUserMedia ??
|
|
20
|
+
((constraints) => navigator.mediaDevices.getUserMedia(constraints));
|
|
21
|
+
const listAvailableCamerasFn = io.listAvailableCameras ?? defaultListAvailableCameras;
|
|
22
|
+
const getPlatformFn = io.getPlatform ?? defaultGetPlatform;
|
|
23
|
+
// Bound to globalThis for defensive consistency with the io-seam fix
|
|
24
|
+
// (see FrameLoop.ts's `schedule`). This is only called bare
|
|
25
|
+
// (`scheduleTimeout(() => {...}, 500)` below), which browsers allow for a
|
|
26
|
+
// detached native (undefined receiver -> WebIDL global fallback); only
|
|
27
|
+
// method invocation via another object (`io.setTimeout(...)`) throws
|
|
28
|
+
// `TypeError: Illegal invocation`.
|
|
29
|
+
const scheduleTimeout = io.setTimeout ?? setTimeout.bind(globalThis);
|
|
30
|
+
// cameraStore.tsx:155-158 — tamper guard trips before any device access is
|
|
31
|
+
// attempted. Divergence: sdk2 sets `cameraTamperingDetected: true` on the
|
|
32
|
+
// store and returns (void); headless callers get a typed rejection instead.
|
|
33
|
+
if (guardGetUserMedia({ enabled: enableTamperDetection, token: mediaIntegrityToken })) {
|
|
34
|
+
throw new CaptureAttachError({
|
|
35
|
+
code: 'CAMERA_TAMPERING_SUSPECTED',
|
|
36
|
+
recoverable: false,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// cameraStore.tsx:160 — release any previously held camera before
|
|
40
|
+
// re-enumerating devices (obtainCameraAccess() below also releases, but
|
|
41
|
+
// this earlier release matches the source ordering).
|
|
42
|
+
releaseGlobalCameraAccess();
|
|
43
|
+
try {
|
|
44
|
+
let availableCameras = await listAvailableCamerasFn(undefined, false, { enabled: enableTamperDetection, token: mediaIntegrityToken }, allowVirtualCameras);
|
|
45
|
+
let selectedCamera;
|
|
46
|
+
debug(`${LOG_TAG} availableCameras`, availableCameras);
|
|
47
|
+
const platform = getPlatformFn();
|
|
48
|
+
debug(`${LOG_TAG} platformDetails`, platform);
|
|
49
|
+
// cameraStore.tsx:176-195 — device-selection cascade, kept verbatim.
|
|
50
|
+
// sdk2 also gates this branch on `!iphoneContinuityCameraDenied`, a store
|
|
51
|
+
// flag tracking a denial from a *previous* requestCameraAccess() call.
|
|
52
|
+
// acquireCamera is a one-shot function with no such history — within a
|
|
53
|
+
// single call the continuity camera has, by definition, not yet been
|
|
54
|
+
// denied — so that half of the condition is always true here and drops
|
|
55
|
+
// out.
|
|
56
|
+
if (!platform?.os || platform.os.family === 'OS X') {
|
|
57
|
+
const iphoneContinuityCamera = availableCameras.find((deviceInfo) => cameraLabelMatches(deviceInfo, 'iphone'));
|
|
58
|
+
if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
|
|
59
|
+
selectedCamera = iphoneContinuityCamera;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (platform?.os?.family === 'Android' ||
|
|
63
|
+
availableCameras.every((c) => c.label.startsWith('camera2 '))) {
|
|
64
|
+
availableCameras = availableCameras.sort((a, b) => a.label.toLowerCase().localeCompare(b.label.toLowerCase()));
|
|
65
|
+
debug(`${LOG_TAG} cameras have been sorted`, availableCameras);
|
|
66
|
+
}
|
|
67
|
+
if (preferFrontFacingCamera) {
|
|
68
|
+
selectedCamera = availableCameras.find((deviceInfo) => cameraLabelMatches(deviceInfo, frontCameraLabels));
|
|
69
|
+
}
|
|
70
|
+
selectedCamera ||= availableCameras.find((deviceInfo) => cameraLabelMatches(deviceInfo, 'backtriplecamera'));
|
|
71
|
+
selectedCamera ||= availableCameras.find((deviceInfo) => cameraLabelMatches(deviceInfo, 'backdualcamera'));
|
|
72
|
+
selectedCamera ||= availableCameras.find((deviceInfo) => cameraLabelMatches(deviceInfo, rearCameraLabels) &&
|
|
73
|
+
!cameraLabelMatches(deviceInfo, backUltraWideCameraLabels));
|
|
74
|
+
selectedCamera ||= availableCameras.find((deviceInfo) => cameraLabelMatches(deviceInfo, rearCameraLabels));
|
|
75
|
+
// on iOS, the front facing camera always is at the first position in the
|
|
76
|
+
// list, so we skip it if all else fails. (cameraStore.tsx:219-226)
|
|
77
|
+
if (!preferFrontFacingCamera &&
|
|
78
|
+
platform?.os?.family === 'iOS' &&
|
|
79
|
+
availableCameras.length > 0) {
|
|
80
|
+
selectedCamera ||= availableCameras[1];
|
|
81
|
+
}
|
|
82
|
+
selectedCamera ||= availableCameras[0];
|
|
83
|
+
// Test-harness override: when virtual cameras are allowed, prefer one
|
|
84
|
+
// (e.g. OBS) over the normal front/rear selection. Placed last so it
|
|
85
|
+
// beats the hard `=` assignments in the cascade above.
|
|
86
|
+
// (cameraStore.tsx:230-236)
|
|
87
|
+
if (allowVirtualCameras) {
|
|
88
|
+
const virtual = availableCameras.find((d) => isVirtualCamera(d.label));
|
|
89
|
+
if (virtual)
|
|
90
|
+
selectedCamera = virtual;
|
|
91
|
+
}
|
|
92
|
+
debug(`${LOG_TAG} selectedCamera`, selectedCamera);
|
|
93
|
+
if (!selectedCamera) {
|
|
94
|
+
// sdk2 has no guard here — an empty device list leaves selectedCamera
|
|
95
|
+
// `undefined` and the next line's `selectedCamera.deviceId` throws a
|
|
96
|
+
// TypeError at runtime, which the outer catch below rethrows verbatim
|
|
97
|
+
// (it matches none of the mapped patterns). Strict null checks force
|
|
98
|
+
// this to be spelled out explicitly; the thrown error and its handling
|
|
99
|
+
// are otherwise unchanged from sdk2's behavior.
|
|
100
|
+
throw new TypeError("Cannot read properties of undefined (reading 'deviceId')");
|
|
101
|
+
}
|
|
102
|
+
const constraints = {
|
|
103
|
+
audio: false,
|
|
104
|
+
video: {
|
|
105
|
+
deviceId: { exact: selectedCamera.deviceId },
|
|
106
|
+
width: { ideal: maxVideoWidth },
|
|
107
|
+
aspectRatio: 1.777777778,
|
|
108
|
+
frameRate: {},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
if (maxFps) {
|
|
112
|
+
;
|
|
113
|
+
constraints.video.frameRate = { max: maxFps };
|
|
114
|
+
}
|
|
115
|
+
let stream = null;
|
|
116
|
+
try {
|
|
117
|
+
debug(`${LOG_TAG} obtaining camera access with constraints`, constraints);
|
|
118
|
+
stream = await getUserMedia(constraints);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (e.name === 'NotAllowedError') {
|
|
122
|
+
// cameraStore.tsx:265-275 — sdk2 sets a flag (either
|
|
123
|
+
// iphoneContinuityCameraDenied or cameraAccessDenied, depending on
|
|
124
|
+
// preferIphoneContinuityCamera) and returns successfully. Headless
|
|
125
|
+
// divergence: both collapse into a single typed rejection, since
|
|
126
|
+
// there is no persistent store to carry the continuity-specific
|
|
127
|
+
// flag for a later retry.
|
|
128
|
+
throw new CaptureAttachError({
|
|
129
|
+
code: 'CAMERA_PERMISSION_DENIED',
|
|
130
|
+
recoverable: true,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// cameraStore.tsx:264-276 — any other error here is silently swallowed
|
|
134
|
+
// in the source and execution falls through to the unconstrained
|
|
135
|
+
// fallback attempt below. Kept verbatim.
|
|
136
|
+
}
|
|
137
|
+
if (!stream) {
|
|
138
|
+
try {
|
|
139
|
+
stream = await getUserMedia({ audio: false, video: true });
|
|
140
|
+
debug(`${LOG_TAG} opened stream with no width and height constraints`);
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
// cameraStore.tsx:288-290 — non-fatal logging path, kept verbatim.
|
|
144
|
+
debug(`${LOG_TAG} cannot open stream at all`, e);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!stream) {
|
|
148
|
+
error(`${LOG_TAG} failed to open camera`);
|
|
149
|
+
throw new Error('failed to open camera: ');
|
|
150
|
+
}
|
|
151
|
+
debug(`${LOG_TAG} camera access requested with constraints`, constraints);
|
|
152
|
+
const handleStreamEnded = () => {
|
|
153
|
+
// cameraStore.tsx:303-326 — sdk2 branches on whether a continuity
|
|
154
|
+
// camera was in play to set different combinations of store flags
|
|
155
|
+
// (iphoneContinuityCameraAvailable/Denied vs cameraAccessDenied, plus
|
|
156
|
+
// clearing videoStream/videoDevice/videoLoaded). Headless divergence:
|
|
157
|
+
// acquireCamera has no persistent store for callers to read those
|
|
158
|
+
// flags from, so both branches collapse into a single notification.
|
|
159
|
+
debug(`${LOG_TAG}:handleStreamEnded stream ended`);
|
|
160
|
+
onEnded?.();
|
|
161
|
+
};
|
|
162
|
+
videoEl.addEventListener('ended', () => {
|
|
163
|
+
debug(`${LOG_TAG}:handleStreamEnded HTMLVideoElement ended event`);
|
|
164
|
+
handleStreamEnded();
|
|
165
|
+
});
|
|
166
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
167
|
+
captureCameraSignals(videoTrack);
|
|
168
|
+
videoTrack.onended = () => {
|
|
169
|
+
debug(`${LOG_TAG}:handleStreamEnded MediaStreamTrack onended`);
|
|
170
|
+
handleStreamEnded();
|
|
171
|
+
};
|
|
172
|
+
const camera = obtainCameraAccess(stream, selectedCamera.label, videoEl);
|
|
173
|
+
await new Promise((resolve) => {
|
|
174
|
+
scheduleTimeout(() => {
|
|
175
|
+
// iOS 17 has a strange behavior where the video track flickers
|
|
176
|
+
// between muted and unmuted when the camera access is being
|
|
177
|
+
// requested. This delay is a workaround for that.
|
|
178
|
+
// (cameraStore.tsx:353-367)
|
|
179
|
+
videoTrack.onmute = () => {
|
|
180
|
+
if (videoTrack.readyState !== 'live') {
|
|
181
|
+
debug(`${LOG_TAG}:handleStreamEnded MediaStreamTrack onmute`);
|
|
182
|
+
handleStreamEnded();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
resolve();
|
|
186
|
+
}, 500);
|
|
187
|
+
});
|
|
188
|
+
const isRearFacing = camera?.isRearFacing ?? false;
|
|
189
|
+
return {
|
|
190
|
+
camera,
|
|
191
|
+
isRearFacing,
|
|
192
|
+
videoTrack,
|
|
193
|
+
release: () => camera.release(),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
if (e instanceof CaptureAttachError)
|
|
198
|
+
throw e;
|
|
199
|
+
const err = e;
|
|
200
|
+
if (err.name === 'NotAllowedError') {
|
|
201
|
+
// cameraStore.tsx:374-381 — outer catch's "blocked by the user" path.
|
|
202
|
+
// Also covers the continuity-camera path headless-collapses into here
|
|
203
|
+
// (see the inner-catch comment above).
|
|
204
|
+
error(`${LOG_TAG} camera access has been blocked by the user`, e);
|
|
205
|
+
throw new CaptureAttachError({
|
|
206
|
+
code: 'CAMERA_PERMISSION_DENIED',
|
|
207
|
+
recoverable: true,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (err.message?.includes('failed to open camera') ||
|
|
211
|
+
err.message?.includes('Could not start video source')) {
|
|
212
|
+
error(`${LOG_TAG} camera access encountered some other error`, e);
|
|
213
|
+
throw new CaptureAttachError({
|
|
214
|
+
code: 'CAMERA_UNAVAILABLE',
|
|
215
|
+
recoverable: true,
|
|
216
|
+
cause: e,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
// cameraStore.tsx:382-385 — genuinely unexpected error; sdk2 rethrows it
|
|
220
|
+
// as-is (no CaptureError bucket exists for it), so we do too.
|
|
221
|
+
error(`${LOG_TAG} camera access encountered some other error`, e);
|
|
222
|
+
throw e;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw, prompt-free camera signals read from an already-open MediaStreamTrack.
|
|
3
|
+
* Shipped as-is to the backend for camera-authenticity scoring; no scoring or
|
|
4
|
+
* curation happens here. Dependency-free leaf module so it is unit-testable and
|
|
5
|
+
* importable from both the camera store (writer) and the submission layer
|
|
6
|
+
* (reader) without coupling.
|
|
7
|
+
*/
|
|
8
|
+
export type CameraSignals = {
|
|
9
|
+
label: string;
|
|
10
|
+
settings: Record<string, unknown> | null;
|
|
11
|
+
capabilities: Record<string, unknown> | null;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Read getSettings()/getCapabilities() from the track. Fail-open: each read is
|
|
15
|
+
* independently guarded, so an unsupported or throwing API yields null for that
|
|
16
|
+
* field and never throws.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readCameraSignals(track: MediaStreamTrack): CameraSignals;
|
|
19
|
+
/** Latest collected signals, or null if never collected this session. */
|
|
20
|
+
export declare let lastCameraSignals: CameraSignals | null;
|
|
21
|
+
/** Collect and store signals from the given track. Never throws. */
|
|
22
|
+
export declare function captureCameraSignals(track: MediaStreamTrack): void;
|
|
23
|
+
//# sourceMappingURL=cameraSignals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraSignals.d.ts","sourceRoot":"","sources":["../../src/camera/cameraSignals.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC7C,CAAA;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa,CAsBxE;AAED,yEAAyE;AACzE,eAAO,IAAI,iBAAiB,EAAE,aAAa,GAAG,IAAW,CAAA;AAEzD,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAElE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read getSettings()/getCapabilities() from the track. Fail-open: each read is
|
|
3
|
+
* independently guarded, so an unsupported or throwing API yields null for that
|
|
4
|
+
* field and never throws.
|
|
5
|
+
*/
|
|
6
|
+
export function readCameraSignals(track) {
|
|
7
|
+
let settings = null;
|
|
8
|
+
let capabilities = null;
|
|
9
|
+
const label = (track && track.label) || '';
|
|
10
|
+
try {
|
|
11
|
+
settings = { ...track.getSettings() };
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
settings = null;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
capabilities =
|
|
18
|
+
typeof track.getCapabilities === 'function'
|
|
19
|
+
? { ...track.getCapabilities() }
|
|
20
|
+
: null;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
capabilities = null;
|
|
24
|
+
}
|
|
25
|
+
return { label, settings, capabilities };
|
|
26
|
+
}
|
|
27
|
+
/** Latest collected signals, or null if never collected this session. */
|
|
28
|
+
export let lastCameraSignals = null;
|
|
29
|
+
/** Collect and store signals from the given track. Never throws. */
|
|
30
|
+
export function captureCameraSignals(track) {
|
|
31
|
+
lastCameraSignals = readCameraSignals(track);
|
|
32
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
declare const MediaIntegrityTokenBrand: unique symbol;
|
|
2
|
+
/** Opaque token capturing a snapshot of getUserMedia at the time of creation. */
|
|
3
|
+
export type MediaIntegrityToken = {
|
|
4
|
+
readonly [MediaIntegrityTokenBrand]: true;
|
|
5
|
+
};
|
|
6
|
+
export type IntegrityResult = {
|
|
7
|
+
tampered: boolean;
|
|
8
|
+
details: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Capture a snapshot of `navigator.mediaDevices.getUserMedia` at call time.
|
|
12
|
+
* Customers should call this as early as possible in their application boot,
|
|
13
|
+
* before any third-party scripts have a chance to monkey-patch browser APIs.
|
|
14
|
+
*
|
|
15
|
+
* The returned token is passed to SDK components via the `mediaIntegrityToken`
|
|
16
|
+
* prop. **Passing a token is the recommended way to enable strong tamper
|
|
17
|
+
* detection.** Without it, the SDK falls back to Layer 1 (boot-time reference
|
|
18
|
+
* snapshot) and Layer 2 (page-vs-iframe `toString` heuristic), both of which
|
|
19
|
+
* are best-effort and can produce false positives — e.g. legitimate post-init
|
|
20
|
+
* shims like `webrtc-adapter`, browser-level instrumentation in Chrome for
|
|
21
|
+
* iOS (CriOS), and some browser extensions all replace `getUserMedia` in ways
|
|
22
|
+
* that look indistinguishable from tampering at those layers.
|
|
23
|
+
*
|
|
24
|
+
* Layer 3 (this token) compares against a snapshot the customer captures at
|
|
25
|
+
* a moment of their choosing, so it is robust against post-capture tampering
|
|
26
|
+
* regardless of how sophisticated the attacker is at faking `[native code]`
|
|
27
|
+
* after the snapshot — but it cannot defend against tampering that already
|
|
28
|
+
* happened before `captureMediaIntegrity` ran. Capture early.
|
|
29
|
+
*
|
|
30
|
+
* **Must be called in a browser context** (`navigator.mediaDevices` available).
|
|
31
|
+
* Calling during SSR / pre-DOM produces a token whose snapshot is empty;
|
|
32
|
+
* subsequent integrity checks against such a token will report "unrecognized
|
|
33
|
+
* or forged token" — a false positive caused by capture-time misuse.
|
|
34
|
+
*/
|
|
35
|
+
export declare function captureMediaIntegrity(): MediaIntegrityToken;
|
|
36
|
+
export type IntegrityCheckOptions = {
|
|
37
|
+
/** When false or omitted, all checks are skipped and result is clean. */
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/** Optional customer-captured token for Layer 3. */
|
|
40
|
+
token?: MediaIntegrityToken;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Run all applicable integrity check layers.
|
|
44
|
+
*
|
|
45
|
+
* - **Layer 1**: Boot-time referential equality (corroborated by Layer 2).
|
|
46
|
+
* Best-effort; misses attackers who inject before SDK load.
|
|
47
|
+
* - **Layer 2**: Fresh-iframe cross-realm `toString` comparison. Best-effort;
|
|
48
|
+
* produces false positives in browser-level instrumentation contexts (CriOS,
|
|
49
|
+
* extensions). The page-vs-iframe disagreement case is gated on iframe
|
|
50
|
+
* trustworthiness to mitigate this.
|
|
51
|
+
* - **Layer 3**: Customer-provided token validation (only runs when a token
|
|
52
|
+
* is supplied). **This is the strong defense** — see `captureMediaIntegrity`.
|
|
53
|
+
*
|
|
54
|
+
* Returns clean immediately if `enabled` is not true.
|
|
55
|
+
*/
|
|
56
|
+
export declare function checkGetUserMediaIntegrity(options?: IntegrityCheckOptions): IntegrityResult;
|
|
57
|
+
/**
|
|
58
|
+
* Lightweight pre-call guard. Returns `true` if tampering is detected.
|
|
59
|
+
* Returns `false` immediately when not enabled.
|
|
60
|
+
*
|
|
61
|
+
* Runs Layer 1 (corroborated by a cached Layer 2 verdict) and Layer 3.
|
|
62
|
+
* The full check at mount time (`checkGetUserMediaIntegrity`) re-runs Layer 2
|
|
63
|
+
* fresh for completeness; this guard uses the cache so per-call cost is low.
|
|
64
|
+
*
|
|
65
|
+
* For strong tamper resistance, customers should pass a token captured via
|
|
66
|
+
* `captureMediaIntegrity` — Layer 1 is best-effort and can produce false
|
|
67
|
+
* positives against legitimate post-init shims (`webrtc-adapter`, polyfills,
|
|
68
|
+
* browser extensions).
|
|
69
|
+
*/
|
|
70
|
+
export declare function guardGetUserMedia(options?: IntegrityCheckOptions): boolean;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=getUserMediaIntegrity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserMediaIntegrity.d.ts","sourceRoot":"","sources":["../../src/camera/getUserMediaIntegrity.ts"],"names":[],"mappings":"AAcA,OAAO,CAAC,MAAM,wBAAwB,EAAE,OAAO,MAAM,CAAA;AAErD,iFAAiF;AACjF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,CAAC,wBAAwB,CAAC,EAAE,IAAI,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,IAAI,mBAAmB,CAS3D;AAsLD,MAAM,MAAM,qBAAqB,GAAG;IAClC,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,oDAAoD;IACpD,KAAK,CAAC,EAAE,mBAAmB,CAAA;CAC5B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,qBAA0B,GAClC,eAAe,CAwBjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAiBT"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { debug, error } from '../utils/logger';
|
|
2
|
+
const LOG_TAG = 'camera:getUserMediaIntegrity';
|
|
3
|
+
// Module-level boot-time cached references (SSR-safe)
|
|
4
|
+
const _createElement = typeof document !== 'undefined' ? Document.prototype.createElement : undefined;
|
|
5
|
+
const _getUserMedia = typeof navigator !== 'undefined'
|
|
6
|
+
? navigator.mediaDevices?.getUserMedia
|
|
7
|
+
: undefined;
|
|
8
|
+
// Cached Layer 2 verdict — Layer 2 creates an iframe (expensive). Cache the
|
|
9
|
+
// result for the lifetime of the page so repeated guard() calls are cheap.
|
|
10
|
+
// Keyed by the current navigator.mediaDevices.getUserMedia identity so a
|
|
11
|
+
// post-init replacement re-runs Layer 2 once and the new verdict sticks.
|
|
12
|
+
let _cachedLayer2;
|
|
13
|
+
function getCachedLayer2Verdict() {
|
|
14
|
+
const currentSource = typeof navigator !== 'undefined'
|
|
15
|
+
? navigator.mediaDevices?.getUserMedia
|
|
16
|
+
: undefined;
|
|
17
|
+
if (_cachedLayer2 && _cachedLayer2.source === currentSource) {
|
|
18
|
+
return _cachedLayer2.verdict;
|
|
19
|
+
}
|
|
20
|
+
const verdict = checkLayer2();
|
|
21
|
+
_cachedLayer2 = { source: currentSource, verdict };
|
|
22
|
+
return verdict;
|
|
23
|
+
}
|
|
24
|
+
// --- Layer 3: Customer-provided token ---
|
|
25
|
+
const tokenStore = new WeakMap();
|
|
26
|
+
/**
|
|
27
|
+
* Capture a snapshot of `navigator.mediaDevices.getUserMedia` at call time.
|
|
28
|
+
* Customers should call this as early as possible in their application boot,
|
|
29
|
+
* before any third-party scripts have a chance to monkey-patch browser APIs.
|
|
30
|
+
*
|
|
31
|
+
* The returned token is passed to SDK components via the `mediaIntegrityToken`
|
|
32
|
+
* prop. **Passing a token is the recommended way to enable strong tamper
|
|
33
|
+
* detection.** Without it, the SDK falls back to Layer 1 (boot-time reference
|
|
34
|
+
* snapshot) and Layer 2 (page-vs-iframe `toString` heuristic), both of which
|
|
35
|
+
* are best-effort and can produce false positives — e.g. legitimate post-init
|
|
36
|
+
* shims like `webrtc-adapter`, browser-level instrumentation in Chrome for
|
|
37
|
+
* iOS (CriOS), and some browser extensions all replace `getUserMedia` in ways
|
|
38
|
+
* that look indistinguishable from tampering at those layers.
|
|
39
|
+
*
|
|
40
|
+
* Layer 3 (this token) compares against a snapshot the customer captures at
|
|
41
|
+
* a moment of their choosing, so it is robust against post-capture tampering
|
|
42
|
+
* regardless of how sophisticated the attacker is at faking `[native code]`
|
|
43
|
+
* after the snapshot — but it cannot defend against tampering that already
|
|
44
|
+
* happened before `captureMediaIntegrity` ran. Capture early.
|
|
45
|
+
*
|
|
46
|
+
* **Must be called in a browser context** (`navigator.mediaDevices` available).
|
|
47
|
+
* Calling during SSR / pre-DOM produces a token whose snapshot is empty;
|
|
48
|
+
* subsequent integrity checks against such a token will report "unrecognized
|
|
49
|
+
* or forged token" — a false positive caused by capture-time misuse.
|
|
50
|
+
*/
|
|
51
|
+
export function captureMediaIntegrity() {
|
|
52
|
+
const token = Object.freeze({ __brand: 'MediaIntegrityToken' });
|
|
53
|
+
if (typeof navigator !== 'undefined' && navigator.mediaDevices) {
|
|
54
|
+
tokenStore.set(token, {
|
|
55
|
+
getUserMedia: navigator.mediaDevices.getUserMedia,
|
|
56
|
+
toString: Function.prototype.toString,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return token;
|
|
60
|
+
}
|
|
61
|
+
// --- Layer 1: Boot-time referential equality (with Layer 2 corroboration) ---
|
|
62
|
+
function checkLayer1(layer2) {
|
|
63
|
+
const details = [];
|
|
64
|
+
// SSR or missing mediaDevices — pass gracefully
|
|
65
|
+
if (!_getUserMedia || typeof navigator === 'undefined' || !navigator.mediaDevices) {
|
|
66
|
+
return { tampered: false, details };
|
|
67
|
+
}
|
|
68
|
+
if (navigator.mediaDevices.getUserMedia === _getUserMedia) {
|
|
69
|
+
return { tampered: false, details };
|
|
70
|
+
}
|
|
71
|
+
// Reference differs from boot snapshot. This may be a legitimate post-init
|
|
72
|
+
// shim (webrtc-adapter, polyfill, browser extension). Only flag when Layer 2
|
|
73
|
+
// gives positive evidence of tampering. If Layer 2 is unavailable (no
|
|
74
|
+
// document) or itself reports clean, defer to Layer 2's signal and don't
|
|
75
|
+
// double-report at Layer 1.
|
|
76
|
+
if (layer2?.tampered) {
|
|
77
|
+
details.push('Layer 1: navigator.mediaDevices.getUserMedia reference differs from boot-time snapshot (corroborated by Layer 2)');
|
|
78
|
+
}
|
|
79
|
+
return { tampered: details.length > 0, details };
|
|
80
|
+
}
|
|
81
|
+
// --- Layer 2: Fresh iframe cross-context toString ---
|
|
82
|
+
function checkLayer2() {
|
|
83
|
+
const details = [];
|
|
84
|
+
// SSR or missing prerequisites — pass gracefully
|
|
85
|
+
if (typeof document === 'undefined' ||
|
|
86
|
+
!_createElement ||
|
|
87
|
+
!navigator.mediaDevices) {
|
|
88
|
+
return { tampered: false, details };
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const iframe = _createElement.call(document, 'iframe');
|
|
92
|
+
iframe.style.display = 'none';
|
|
93
|
+
document.body.appendChild(iframe);
|
|
94
|
+
try {
|
|
95
|
+
const iframeWindow = iframe.contentWindow;
|
|
96
|
+
if (!iframeWindow) {
|
|
97
|
+
details.push('Layer 2: iframe contentWindow is null');
|
|
98
|
+
return { tampered: details.length > 0, details };
|
|
99
|
+
}
|
|
100
|
+
// Use same-realm toString calls to avoid cross-realm issues
|
|
101
|
+
// (Chrome produces unexpected results when calling toString from
|
|
102
|
+
// one realm on a native host function from another realm).
|
|
103
|
+
const pageToString = Function.prototype.toString;
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
+
const iframeToString = iframeWindow.Function.prototype.toString;
|
|
106
|
+
// Compare page vs iframe getUserMedia via same-realm toString.
|
|
107
|
+
// Legitimate shims (e.g. webrtc-adapter) replace getUserMedia
|
|
108
|
+
// before the SDK loads, so the page's version may not contain
|
|
109
|
+
// [native code]. We use the iframe's clean getUserMedia as a
|
|
110
|
+
// reference: if the iframe's IS native, a non-native page version
|
|
111
|
+
// is expected when a shim is present and is not flagged. We only
|
|
112
|
+
// flag when the page's getUserMedia doesn't match the boot-time
|
|
113
|
+
// snapshot (Layer 1) AND the iframe confirms no shim is in play.
|
|
114
|
+
const pageResult = String(pageToString.call(navigator.mediaDevices.getUserMedia));
|
|
115
|
+
const iframeGUM = iframeWindow.navigator?.mediaDevices?.getUserMedia;
|
|
116
|
+
if (iframeGUM) {
|
|
117
|
+
const iframeResult = String(iframeToString.call(iframeGUM));
|
|
118
|
+
const pageIsNative = pageResult.includes('[native code]');
|
|
119
|
+
const iframeIsNative = iframeResult.includes('[native code]');
|
|
120
|
+
if (!pageIsNative && !iframeIsNative) {
|
|
121
|
+
// Neither is native — something has tampered at a deep level
|
|
122
|
+
details.push('Layer 2: neither page nor iframe getUserMedia appear native');
|
|
123
|
+
}
|
|
124
|
+
else if (pageIsNative && !iframeIsNative) {
|
|
125
|
+
// Iframe disagrees with page about native-ness. Probe iframe
|
|
126
|
+
// trustworthiness via another mediaDevices method before deciding
|
|
127
|
+
// whether to flag. Browsers (Chrome for iOS / CriOS) and some
|
|
128
|
+
// extensions wrap iframe getUserMedia specifically while leaving
|
|
129
|
+
// sibling methods intact; broadly-tampered iframes also can't be
|
|
130
|
+
// trusted as a "what does native look like" reference. In neither
|
|
131
|
+
// case is the iframe a reliable witness, so we trust the page-
|
|
132
|
+
// level [native code] signal and don't flag here.
|
|
133
|
+
//
|
|
134
|
+
// The strong defense against a faked-native page-level impostor
|
|
135
|
+
// is Layer 3 (customer-captured token), not Layer 2 heuristics.
|
|
136
|
+
const iframeEnumerateDevices = iframeWindow.navigator?.mediaDevices?.enumerateDevices;
|
|
137
|
+
const iframeEnumerateNative = iframeEnumerateDevices
|
|
138
|
+
? String(iframeToString.call(iframeEnumerateDevices)).includes('[native code]')
|
|
139
|
+
: false;
|
|
140
|
+
if (iframeEnumerateNative) {
|
|
141
|
+
debug(`${LOG_TAG} Layer 2: page getUserMedia native; iframe getUserMedia wrapped but iframe enumerateDevices native — browser-level instrumentation pattern (e.g. CriOS), not flagged`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
debug(`${LOG_TAG} Layer 2: page getUserMedia native; iframe broadly unreliable as a reference (enumerateDevices also non-native or unavailable), not flagged`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// pageIsNative=false, iframeIsNative=true → legitimate shim (e.g. adapter.js), not flagged
|
|
148
|
+
// both native → clean, not flagged
|
|
149
|
+
}
|
|
150
|
+
else if (!pageResult.includes('[native code]')) {
|
|
151
|
+
// No iframe getUserMedia available to compare against;
|
|
152
|
+
// fall back to checking the page's result alone
|
|
153
|
+
details.push('Layer 2: page getUserMedia toString does not contain [native code]');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
iframe.remove();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
// CSP or other restrictions may block iframe creation — skip Layer 2
|
|
162
|
+
debug(`${LOG_TAG} Layer 2 skipped due to error:`, e);
|
|
163
|
+
}
|
|
164
|
+
return { tampered: details.length > 0, details };
|
|
165
|
+
}
|
|
166
|
+
// --- Layer 3: Customer-provided token validation ---
|
|
167
|
+
function checkLayer3(token) {
|
|
168
|
+
const details = [];
|
|
169
|
+
if (!token) {
|
|
170
|
+
return { tampered: false, details };
|
|
171
|
+
}
|
|
172
|
+
// SSR or missing mediaDevices — pass gracefully
|
|
173
|
+
if (typeof navigator === 'undefined' || !navigator.mediaDevices) {
|
|
174
|
+
return { tampered: false, details };
|
|
175
|
+
}
|
|
176
|
+
const snapshot = tokenStore.get(token);
|
|
177
|
+
if (!snapshot) {
|
|
178
|
+
details.push('Layer 3: unrecognized or forged token');
|
|
179
|
+
return { tampered: true, details };
|
|
180
|
+
}
|
|
181
|
+
if (navigator.mediaDevices.getUserMedia !== snapshot.getUserMedia) {
|
|
182
|
+
details.push('Layer 3: current getUserMedia differs from token-captured reference');
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const currentToString = snapshot.toString.call(navigator.mediaDevices.getUserMedia);
|
|
186
|
+
if (!currentToString.includes('[native code]')) {
|
|
187
|
+
details.push('Layer 3: current getUserMedia toString (via token) does not contain [native code]');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
details.push('Layer 3: toString check threw an error');
|
|
192
|
+
}
|
|
193
|
+
return { tampered: details.length > 0, details };
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Run all applicable integrity check layers.
|
|
197
|
+
*
|
|
198
|
+
* - **Layer 1**: Boot-time referential equality (corroborated by Layer 2).
|
|
199
|
+
* Best-effort; misses attackers who inject before SDK load.
|
|
200
|
+
* - **Layer 2**: Fresh-iframe cross-realm `toString` comparison. Best-effort;
|
|
201
|
+
* produces false positives in browser-level instrumentation contexts (CriOS,
|
|
202
|
+
* extensions). The page-vs-iframe disagreement case is gated on iframe
|
|
203
|
+
* trustworthiness to mitigate this.
|
|
204
|
+
* - **Layer 3**: Customer-provided token validation (only runs when a token
|
|
205
|
+
* is supplied). **This is the strong defense** — see `captureMediaIntegrity`.
|
|
206
|
+
*
|
|
207
|
+
* Returns clean immediately if `enabled` is not true.
|
|
208
|
+
*/
|
|
209
|
+
export function checkGetUserMediaIntegrity(options = {}) {
|
|
210
|
+
if (!options.enabled) {
|
|
211
|
+
return { tampered: false, details: [] };
|
|
212
|
+
}
|
|
213
|
+
const allDetails = [];
|
|
214
|
+
const l2 = checkLayer2();
|
|
215
|
+
const l1 = checkLayer1(l2);
|
|
216
|
+
allDetails.push(...l1.details);
|
|
217
|
+
allDetails.push(...l2.details);
|
|
218
|
+
const l3 = checkLayer3(options.token);
|
|
219
|
+
allDetails.push(...l3.details);
|
|
220
|
+
const tampered = l1.tampered || l2.tampered || l3.tampered;
|
|
221
|
+
if (tampered) {
|
|
222
|
+
error(`${LOG_TAG} tampering detected:`, allDetails);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
debug(`${LOG_TAG} all integrity checks passed`);
|
|
226
|
+
}
|
|
227
|
+
return { tampered, details: allDetails };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Lightweight pre-call guard. Returns `true` if tampering is detected.
|
|
231
|
+
* Returns `false` immediately when not enabled.
|
|
232
|
+
*
|
|
233
|
+
* Runs Layer 1 (corroborated by a cached Layer 2 verdict) and Layer 3.
|
|
234
|
+
* The full check at mount time (`checkGetUserMediaIntegrity`) re-runs Layer 2
|
|
235
|
+
* fresh for completeness; this guard uses the cache so per-call cost is low.
|
|
236
|
+
*
|
|
237
|
+
* For strong tamper resistance, customers should pass a token captured via
|
|
238
|
+
* `captureMediaIntegrity` — Layer 1 is best-effort and can produce false
|
|
239
|
+
* positives against legitimate post-init shims (`webrtc-adapter`, polyfills,
|
|
240
|
+
* browser extensions).
|
|
241
|
+
*/
|
|
242
|
+
export function guardGetUserMedia(options = {}) {
|
|
243
|
+
if (!options.enabled)
|
|
244
|
+
return false;
|
|
245
|
+
const l2 = getCachedLayer2Verdict();
|
|
246
|
+
const l1 = checkLayer1(l2);
|
|
247
|
+
const l3 = checkLayer3(options.token);
|
|
248
|
+
const tampered = l1.tampered || l3.tampered;
|
|
249
|
+
if (tampered) {
|
|
250
|
+
error(`${LOG_TAG} guard detected tampering:`, [
|
|
251
|
+
...l1.details,
|
|
252
|
+
...l3.details,
|
|
253
|
+
]);
|
|
254
|
+
}
|
|
255
|
+
return tampered;
|
|
256
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/camera/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when a camera device label indicates a virtual / software camera
|
|
3
|
+
* (e.g. "OBS Virtual Camera"). Single source of truth for both the
|
|
4
|
+
* device-list filter and the test-harness auto-select.
|
|
5
|
+
*
|
|
6
|
+
* Intentionally dependency-free so it is unit-testable under the project's
|
|
7
|
+
* `node --test` runner without a logger loader hook.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isVirtualCamera(label: string): boolean;
|
|
10
|
+
//# sourceMappingURL=isVirtualCamera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isVirtualCamera.d.ts","sourceRoot":"","sources":["../../src/camera/isVirtualCamera.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when a camera device label indicates a virtual / software camera
|
|
3
|
+
* (e.g. "OBS Virtual Camera"). Single source of truth for both the
|
|
4
|
+
* device-list filter and the test-harness auto-select.
|
|
5
|
+
*
|
|
6
|
+
* Intentionally dependency-free so it is unit-testable under the project's
|
|
7
|
+
* `node --test` runner without a logger loader hook.
|
|
8
|
+
*/
|
|
9
|
+
export function isVirtualCamera(label) {
|
|
10
|
+
return label.toLowerCase().includes('virtual');
|
|
11
|
+
}
|