@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,638 @@
|
|
|
1
|
+
// The integration point: `createIdmissionClient` wires together every
|
|
2
|
+
// previously-landed client/ module (session machine, wire validateSession,
|
|
3
|
+
// url resolution, endpoint/header helpers, payload assembly, tus upload) into
|
|
4
|
+
// the single stateful surface plan 3's controller and plan 4's UI consume.
|
|
5
|
+
//
|
|
6
|
+
// Response classification (submit / checkLiveness) is ported verbatim
|
|
7
|
+
// (behavior-wise) from sdk2/src/components/submission/SubmissionProvider.tsx:
|
|
8
|
+
// submit classification :1266-1295 (401/403, empty/'Load failed',
|
|
9
|
+
// non-ok, ok+statusCode!=='000')
|
|
10
|
+
// submit outer catch :1296-1321 (error normalization; original
|
|
11
|
+
// error always rethrown, never the normalized
|
|
12
|
+
// one — a subtlety of the source worth calling
|
|
13
|
+
// out explicitly)
|
|
14
|
+
// checkLiveness classification :1453-1486 (same shape) + token capture :1482
|
|
15
|
+
// checkLiveness outer catch :1487-1516 (softFail short-circuit :1488-1495)
|
|
16
|
+
// The `'Load failed'` string heuristic ports AS-IS — brittle, but wire-faithful
|
|
17
|
+
// (known-carryover, not a bug this port should fix).
|
|
18
|
+
//
|
|
19
|
+
// Session driving (validateSession()/retrySession()) ports the *effect*
|
|
20
|
+
// sequence of sdk2/src/contexts/AuthStateContext.tsx:167-227 as one sequential
|
|
21
|
+
// async function instead of two React effects racing off a shared reducer.
|
|
22
|
+
// Because nothing here re-enters concurrently the way React's effect
|
|
23
|
+
// re-invocation can, the sequential form is behavior-equivalent for every
|
|
24
|
+
// state the machine can reach (allowlist gate is checked first and is
|
|
25
|
+
// terminal; sessionId resolution then wire-validates), it just gets there
|
|
26
|
+
// without the transient double-dispatch sdk2's effect racing produces.
|
|
27
|
+
//
|
|
28
|
+
// Value-imports several sibling modules extensionless (the repo source
|
|
29
|
+
// convention — see errors.ts / sessionMachine.ts); consuming test files
|
|
30
|
+
// register a loader hook.
|
|
31
|
+
import { createStore } from 'zustand/vanilla';
|
|
32
|
+
import { sessionReducer, } from './sessionMachine';
|
|
33
|
+
import { validateSession as wireValidateSession } from './validateSession';
|
|
34
|
+
import { resolveClientUrls, isAllowedAuthUrl } from './urls';
|
|
35
|
+
import { AuthenticationError, NetworkError, SubmissionError, SessionValidationFailedError, } from './errors';
|
|
36
|
+
import { determineSubmissionEndpoint, liveCheckEndpoint, apiHeaders, } from './endpoints';
|
|
37
|
+
import { attachMetadataToRequest, } from './submissionMetadata';
|
|
38
|
+
import { isLiveFaceConfirmed } from '../liveness/livenessResult';
|
|
39
|
+
import { buildSubmissionPayload } from './payload';
|
|
40
|
+
import { uploadDocument as tusUploadDocument, } from './upload';
|
|
41
|
+
import { SubmissionAction, SubmissionStatus } from './types';
|
|
42
|
+
import { buildSubmissionTimings, } from './timings';
|
|
43
|
+
// sdk2/src/lib/utils/dataUrlToBase64.ts:31-33, verbatim. Kept as a local copy
|
|
44
|
+
// (matching payload.ts's own convention of self-contained small helpers)
|
|
45
|
+
// rather than exporting it from payload.ts for one caller.
|
|
46
|
+
function dataUrlToBase64Sync(url) {
|
|
47
|
+
return url.replace(/^data:.*;base64,/, '');
|
|
48
|
+
}
|
|
49
|
+
// SubmissionProvider.tsx:1717-1737 (`convertBase64ToBlob`), verbatim logic;
|
|
50
|
+
// only used here (checkLiveness's documentService branch needs a Blob for
|
|
51
|
+
// io.uploadDocument), so it is not exported.
|
|
52
|
+
function dataUrlToBlob(dataUrl) {
|
|
53
|
+
const parts = dataUrl.split(';base64,');
|
|
54
|
+
const contentType = parts[0].split(':')[1];
|
|
55
|
+
const decodedData = atob(parts[1]);
|
|
56
|
+
const bytes = new Uint8Array(decodedData.length);
|
|
57
|
+
for (let i = 0; i < decodedData.length; i++) {
|
|
58
|
+
bytes[i] = decodedData.charCodeAt(i);
|
|
59
|
+
}
|
|
60
|
+
return new Blob([bytes], { type: contentType });
|
|
61
|
+
}
|
|
62
|
+
// Shared classification-error normalization, ported verbatim from the shape
|
|
63
|
+
// duplicated at SubmissionProvider.tsx:1301-1311 (submit) and :1499-1509
|
|
64
|
+
// (checkLiveness): known error classes pass through untouched; a raw
|
|
65
|
+
// 'Load failed' message becomes a bare NetworkError; anything else becomes a
|
|
66
|
+
// SubmissionError carrying the raw message. The ORIGINAL error is always what
|
|
67
|
+
// gets thrown/rejected by the caller — this normalized value is only for the
|
|
68
|
+
// state slot (submissionError), exactly like the source.
|
|
69
|
+
function normalizeSubmissionError(e) {
|
|
70
|
+
if (e instanceof SubmissionError ||
|
|
71
|
+
e instanceof NetworkError ||
|
|
72
|
+
e instanceof AuthenticationError) {
|
|
73
|
+
return e;
|
|
74
|
+
}
|
|
75
|
+
const err = e;
|
|
76
|
+
if (err?.message === 'Load failed')
|
|
77
|
+
return new NetworkError();
|
|
78
|
+
return new SubmissionError({ statusCode: '', statusMessage: err?.message });
|
|
79
|
+
}
|
|
80
|
+
// SubmissionProvider.tsx:748-750 (the component-level `uploadDocument`
|
|
81
|
+
// closure): `if (jobId) metadata.jobid = jobId; if (taskId) metadata.taskid =
|
|
82
|
+
// taskId` — stamped only when present, never unconditionally (an absent
|
|
83
|
+
// jobID/taskID must not add an empty key that upload.ts would then key an
|
|
84
|
+
// X-Job-Id/X-Task-Id header or Upload-Metadata entry off of). Shared by both
|
|
85
|
+
// submit's per-document uploads and checkLiveness's document-service selfie
|
|
86
|
+
// upload (buildLivenessCheckPayload calls the SAME component-level
|
|
87
|
+
// uploadDocument at :1361, so the same stamping applies there too).
|
|
88
|
+
function withJobTaskMetadata(metadata, jobID, taskID) {
|
|
89
|
+
const merged = { ...metadata };
|
|
90
|
+
if (jobID)
|
|
91
|
+
merged.jobid = jobID;
|
|
92
|
+
if (taskID)
|
|
93
|
+
merged.taskid = taskID;
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
96
|
+
export function createIdmissionClient(config) {
|
|
97
|
+
// `let`: when config.sessionId is an async resolver, the session URN (and
|
|
98
|
+
// with it the inferred regional base URL — sdk2 PR #244) is only known
|
|
99
|
+
// after it resolves inside runSessionValidation, which re-derives and
|
|
100
|
+
// adopts the urls then. An explicit config.authUrl always wins, so late
|
|
101
|
+
// adoption never overrides an integrator's pinned URL.
|
|
102
|
+
let urls = resolveClientUrls({
|
|
103
|
+
authUrl: config.authUrl,
|
|
104
|
+
submissionUrl: config.submissionUrl,
|
|
105
|
+
// resolveClientUrls' ClientUrlConfig only accepts string|undefined; an
|
|
106
|
+
// explicit disable sentinel (null/'') is handled below via
|
|
107
|
+
// documentServiceEnabled instead of being threaded through here.
|
|
108
|
+
documentServiceUrl: config.documentServiceUrl == null ? undefined : config.documentServiceUrl,
|
|
109
|
+
sessionId: typeof config.sessionId === 'string' ? config.sessionId : undefined,
|
|
110
|
+
});
|
|
111
|
+
const documentServiceEnabled = config.documentServiceUrl !== null && config.documentServiceUrl !== '';
|
|
112
|
+
// Bound to globalThis for defensive consistency with the io-seam fix.
|
|
113
|
+
// `fetchImpl` is only called bare (`fetchImpl(...)` in timedFetch below),
|
|
114
|
+
// which browsers allow for a detached native (undefined receiver -> WebIDL
|
|
115
|
+
// global fallback). The brand check that motivated this fix wave only
|
|
116
|
+
// fails on method invocation via another object (`io.fetch(...)` ->
|
|
117
|
+
// `TypeError: Illegal invocation`, see validateSession.ts); the bind
|
|
118
|
+
// guards against this default ever being threaded into such a seam, and
|
|
119
|
+
// satisfies the receiver-strict test fakes (stricter than browsers).
|
|
120
|
+
const fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
121
|
+
const nowImpl = config.now ?? Date.now;
|
|
122
|
+
const initialSession = {
|
|
123
|
+
authUrl: urls.authUrl,
|
|
124
|
+
sessionCheckState: 'READY',
|
|
125
|
+
canRefreshSession: typeof config.sessionId === 'function',
|
|
126
|
+
};
|
|
127
|
+
const store = createStore(() => ({
|
|
128
|
+
session: initialSession,
|
|
129
|
+
submissionStatus: SubmissionStatus.READY,
|
|
130
|
+
}));
|
|
131
|
+
function dispatchSession(action) {
|
|
132
|
+
store.setState((s) => ({ session: sessionReducer(s.session, action) }));
|
|
133
|
+
}
|
|
134
|
+
// Single-use liveness token capture (sdk2's `livenessTokenRef`,
|
|
135
|
+
// AuthStateContext-adjacent state at SubmissionProvider.tsx:683/1482/1350).
|
|
136
|
+
let livenessToken;
|
|
137
|
+
async function timedFetch(url, init) {
|
|
138
|
+
if (config.timeoutMs === undefined)
|
|
139
|
+
return fetchImpl(url, init);
|
|
140
|
+
const controller = new AbortController();
|
|
141
|
+
const timer = setTimeout(() => controller.abort(), config.timeoutMs);
|
|
142
|
+
try {
|
|
143
|
+
return await fetchImpl(url, { ...init, signal: controller.signal });
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function performUpload(blob, metadata) {
|
|
150
|
+
return tusUploadDocument(blob, metadata, {
|
|
151
|
+
documentServiceUrl: urls.documentServiceUrl,
|
|
152
|
+
sessionId: store.getState().session.sessionId,
|
|
153
|
+
Upload: config.tusUpload,
|
|
154
|
+
delay: config.delay,
|
|
155
|
+
calculateMd5: config.calculateMd5,
|
|
156
|
+
blobToB64: config.blobToB64,
|
|
157
|
+
onBeforeUpload: config.onBeforeDocumentUpload,
|
|
158
|
+
onProgress: config.onDocumentUploadProgress,
|
|
159
|
+
onUploaded: config.onDocumentUploaded
|
|
160
|
+
? async (id, meta) => config.onDocumentUploaded(id, meta)
|
|
161
|
+
: undefined,
|
|
162
|
+
onUploadFailed: config.onDocumentUploadFailed,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// Reviewer-flagged race (final-review fix, not in the original port): two
|
|
166
|
+
// concurrent validateSession() calls double-fire the wire validate call,
|
|
167
|
+
// and a retrySession() racing an in-flight validateSession() can land the
|
|
168
|
+
// machine in PASSED with sessionId already cleared by the retry (a later
|
|
169
|
+
// submit() then posts with no X-Session-Id). Each validateSession/
|
|
170
|
+
// retrySession *run* captures a monotonically-increasing epoch at start;
|
|
171
|
+
// every dispatch the run performs is gated on still being the current
|
|
172
|
+
// epoch, so a run superseded by a newer validateSession/retrySession call
|
|
173
|
+
// is left to run to completion (its own returned promise still resolves
|
|
174
|
+
// to whatever it computed) but can no longer mutate the shared session
|
|
175
|
+
// state. The sessionReducer itself is untouched -- this is purely a guard
|
|
176
|
+
// in the async driver around it.
|
|
177
|
+
let sessionRunEpoch = 0;
|
|
178
|
+
function dispatchSessionIfCurrent(epoch, action) {
|
|
179
|
+
if (epoch !== sessionRunEpoch)
|
|
180
|
+
return;
|
|
181
|
+
dispatchSession(action);
|
|
182
|
+
}
|
|
183
|
+
// Ports the sequential outcome of AuthStateContext.tsx:167-227's two effects
|
|
184
|
+
// (allowlist gate -> sessionId resolution -> wire validate) as one async
|
|
185
|
+
// function. See module header for why the sequential form is
|
|
186
|
+
// behavior-equivalent to the React effect race for every reachable state.
|
|
187
|
+
async function runSessionValidation(epoch) {
|
|
188
|
+
let authUrl = store.getState().session.authUrl;
|
|
189
|
+
if (!isAllowedAuthUrl(authUrl)) {
|
|
190
|
+
dispatchSessionIfCurrent(epoch, {
|
|
191
|
+
type: 'setCheckState',
|
|
192
|
+
payload: 'AUTH_URL_NOT_ALLOWED',
|
|
193
|
+
});
|
|
194
|
+
return 'AUTH_URL_NOT_ALLOWED';
|
|
195
|
+
}
|
|
196
|
+
// Re-derives the client urls from a freshly resolved session id (sdk2 PR
|
|
197
|
+
// #244: setSessionId carries the inferred regional authUrl with it).
|
|
198
|
+
// With an explicit config.authUrl — or a legacy non-URN session id —
|
|
199
|
+
// this resolves to the URLs already in place. The shared-state writes
|
|
200
|
+
// (`urls`, the store dispatch) are epoch-gated like every other mutation
|
|
201
|
+
// in this run: a superseded run must not retarget the shared urls under
|
|
202
|
+
// the run that replaced it. The `authUrl` local is deliberately UNgated —
|
|
203
|
+
// it is run-local, feeding only this run's own wire validate and error
|
|
204
|
+
// wrapping, which are owed to this run's caller regardless of
|
|
205
|
+
// supersession.
|
|
206
|
+
function adoptSessionUrls(sessionId) {
|
|
207
|
+
const next = resolveClientUrls({
|
|
208
|
+
authUrl: config.authUrl,
|
|
209
|
+
submissionUrl: config.submissionUrl,
|
|
210
|
+
documentServiceUrl: config.documentServiceUrl == null
|
|
211
|
+
? undefined
|
|
212
|
+
: config.documentServiceUrl,
|
|
213
|
+
sessionId,
|
|
214
|
+
});
|
|
215
|
+
if (epoch === sessionRunEpoch)
|
|
216
|
+
urls = next;
|
|
217
|
+
authUrl = next.authUrl;
|
|
218
|
+
dispatchSessionIfCurrent(epoch, {
|
|
219
|
+
type: 'setSessionId',
|
|
220
|
+
payload: { sessionId, authUrl: next.authUrl },
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
let resolvedSessionId = store.getState().session.sessionId;
|
|
224
|
+
if (!resolvedSessionId) {
|
|
225
|
+
if (!config.sessionId) {
|
|
226
|
+
dispatchSessionIfCurrent(epoch, {
|
|
227
|
+
type: 'setCheckState',
|
|
228
|
+
payload: 'MISSING',
|
|
229
|
+
});
|
|
230
|
+
return 'MISSING';
|
|
231
|
+
}
|
|
232
|
+
if (typeof config.sessionId === 'string') {
|
|
233
|
+
resolvedSessionId = config.sessionId;
|
|
234
|
+
adoptSessionUrls(resolvedSessionId);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
try {
|
|
238
|
+
resolvedSessionId = await config.sessionId();
|
|
239
|
+
}
|
|
240
|
+
catch (e) {
|
|
241
|
+
const err = new SessionValidationFailedError(e, authUrl);
|
|
242
|
+
dispatchSessionIfCurrent(epoch, { type: 'setError', payload: err });
|
|
243
|
+
config.onAuthError?.(err);
|
|
244
|
+
return 'ERROR';
|
|
245
|
+
}
|
|
246
|
+
adoptSessionUrls(resolvedSessionId);
|
|
247
|
+
// Mirrors sdk2's allowlist effect re-running against the
|
|
248
|
+
// late-resolved URL. Inference only maps to allowlisted URLs, so
|
|
249
|
+
// today this can only trip for a disallowed explicit authUrl —
|
|
250
|
+
// already caught above — but the guard keeps the invariant local
|
|
251
|
+
// instead of depending on the map's contents.
|
|
252
|
+
if (!isAllowedAuthUrl(authUrl)) {
|
|
253
|
+
dispatchSessionIfCurrent(epoch, {
|
|
254
|
+
type: 'setCheckState',
|
|
255
|
+
payload: 'AUTH_URL_NOT_ALLOWED',
|
|
256
|
+
});
|
|
257
|
+
return 'AUTH_URL_NOT_ALLOWED';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
dispatchSessionIfCurrent(epoch, {
|
|
262
|
+
type: 'setCheckState',
|
|
263
|
+
payload: 'RUNNING',
|
|
264
|
+
});
|
|
265
|
+
try {
|
|
266
|
+
const valid = await wireValidateSession(authUrl, resolvedSessionId, {
|
|
267
|
+
fetch: config.fetch,
|
|
268
|
+
delay: config.delay,
|
|
269
|
+
});
|
|
270
|
+
const finalState = valid ? 'PASSED' : 'FAILED';
|
|
271
|
+
dispatchSessionIfCurrent(epoch, {
|
|
272
|
+
type: 'setCheckState',
|
|
273
|
+
payload: finalState,
|
|
274
|
+
});
|
|
275
|
+
return finalState;
|
|
276
|
+
}
|
|
277
|
+
catch (e) {
|
|
278
|
+
// AuthStateContext.tsx:217-222 always wraps whatever rejected here in a
|
|
279
|
+
// fresh SessionValidationFailedError, even when `e` already is one (the
|
|
280
|
+
// wire validateSession's own !resp.ok throw) — ported byte-faithful,
|
|
281
|
+
// not de-duplicated, since `super(err.message)` preserves the message
|
|
282
|
+
// through the re-wrap either way.
|
|
283
|
+
const err = new SessionValidationFailedError(e, authUrl);
|
|
284
|
+
dispatchSessionIfCurrent(epoch, { type: 'setError', payload: err });
|
|
285
|
+
config.onAuthError?.(err);
|
|
286
|
+
return 'ERROR';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async function validateSessionMethod() {
|
|
290
|
+
const epoch = ++sessionRunEpoch;
|
|
291
|
+
return runSessionValidation(epoch);
|
|
292
|
+
}
|
|
293
|
+
async function retrySession() {
|
|
294
|
+
const epoch = ++sessionRunEpoch;
|
|
295
|
+
dispatchSession({ type: 'retry' });
|
|
296
|
+
return runSessionValidation(epoch);
|
|
297
|
+
}
|
|
298
|
+
async function submit(artifacts, options) {
|
|
299
|
+
// Reviewer-flagged gap (final-review fix): sdk2 short-circuits
|
|
300
|
+
// action: 'NONE' to a synthetic success response before any network
|
|
301
|
+
// activity, including before buildSubmissionPayload's document uploads
|
|
302
|
+
// (SubmissionProvider.tsx:1203-1225 -- checked ahead of even
|
|
303
|
+
// setSubmissionStatus(SUBMITTING)). This client deliberately does NOT
|
|
304
|
+
// replicate that synthetic-success path: recognizing a capture-only flow
|
|
305
|
+
// and fabricating its "success" response is a controller-layer concern
|
|
306
|
+
// (plan 3's job, not this network client's). What this client DOES need
|
|
307
|
+
// to preserve is the "NONE performs no network/upload work" guarantee,
|
|
308
|
+
// so NONE is rejected right here -- before buildSubmissionPayload (and
|
|
309
|
+
// therefore before any io.uploadDocument call) ever runs -- rather than
|
|
310
|
+
// uploading every artifact and only then throwing from
|
|
311
|
+
// determineSubmissionEndpoint's default case.
|
|
312
|
+
// `&& !config.onSubmit`: sdk2 checks `onSubmit` BEFORE its own NONE branch
|
|
313
|
+
// (SubmissionProvider.tsx:1374 vs :1237), so a capture-only submission
|
|
314
|
+
// still builds its payload and hands it over — uploads included. Without
|
|
315
|
+
// this, a caller with both would get silence where 2.x gave them a
|
|
316
|
+
// request, which contradicts the precedence `onSubmit` documents.
|
|
317
|
+
if (options.action === SubmissionAction.NONE && !config.onSubmit) {
|
|
318
|
+
throw new SubmissionError({
|
|
319
|
+
statusCode: 'UNSUPPORTED_ACTION',
|
|
320
|
+
statusMessage: "submit() rejects action: 'NONE' -- capture-only, no-network submission is the controller layer's responsibility (plan 3), not this client's",
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (store.getState().session.sessionCheckState !== 'PASSED') {
|
|
324
|
+
throw new AuthenticationError(401, 'session not validated');
|
|
325
|
+
}
|
|
326
|
+
store.setState({
|
|
327
|
+
submissionStatus: SubmissionStatus.SUBMITTING,
|
|
328
|
+
submissionError: undefined,
|
|
329
|
+
});
|
|
330
|
+
const startedAt = nowImpl();
|
|
331
|
+
const payloadBuildStart = performance.now();
|
|
332
|
+
let payloadBuildEnd = payloadBuildStart;
|
|
333
|
+
let uploadMeasurements = [];
|
|
334
|
+
let apiCallStart;
|
|
335
|
+
let apiCallEnd;
|
|
336
|
+
let responseParseStart;
|
|
337
|
+
let responseParseEnd;
|
|
338
|
+
let failedAt;
|
|
339
|
+
try {
|
|
340
|
+
let payloadResult;
|
|
341
|
+
try {
|
|
342
|
+
payloadResult = await buildSubmissionPayload({
|
|
343
|
+
...artifacts,
|
|
344
|
+
meta: {
|
|
345
|
+
...artifacts.meta,
|
|
346
|
+
livenessToken: artifacts.meta?.livenessToken ?? livenessToken,
|
|
347
|
+
},
|
|
348
|
+
}, {
|
|
349
|
+
...options,
|
|
350
|
+
onBeforeSubmit: options.onBeforeSubmit ?? config.onBeforeSubmit,
|
|
351
|
+
}, {
|
|
352
|
+
// SubmissionProvider.tsx:748-750 stamping, ported via
|
|
353
|
+
// withJobTaskMetadata (see its own comment above): only present
|
|
354
|
+
// when options.jobID/taskID are present.
|
|
355
|
+
uploadDocument: documentServiceEnabled
|
|
356
|
+
? (blob, metadata) => performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID))
|
|
357
|
+
: undefined,
|
|
358
|
+
now: config.now,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
catch (e) {
|
|
362
|
+
failedAt = e instanceof NetworkError ? 'uploads' : 'payload';
|
|
363
|
+
throw e;
|
|
364
|
+
}
|
|
365
|
+
payloadBuildEnd = payloadResult.uploadTimings.payloadBuildEnd;
|
|
366
|
+
uploadMeasurements = payloadResult.uploadTimings.uploads;
|
|
367
|
+
const request = payloadResult.request;
|
|
368
|
+
// Stashed HERE rather than next to `lastSubmissionTimings` in the
|
|
369
|
+
// `finally`, because the hand-off below returns early: parking it in
|
|
370
|
+
// the same setState as the timings would leave `onSubmit` customers
|
|
371
|
+
// with a timings block and no request to go with it.
|
|
372
|
+
store.setState({
|
|
373
|
+
attestationAttached: payloadResult.attestationAttached,
|
|
374
|
+
lastSubmissionRequest: request,
|
|
375
|
+
});
|
|
376
|
+
// THE HAND-OFF. sdk2 short-circuits at the equivalent point
|
|
377
|
+
// (SubmissionProvider.tsx:1374-1377, `return onSubmit.current(request)`
|
|
378
|
+
// before `defaultOnSubmit`), so everything above this line runs and
|
|
379
|
+
// nothing below it does.
|
|
380
|
+
//
|
|
381
|
+
// The status goes to SUBMITTED, where sdk2 leaves it at READY. That is a
|
|
382
|
+
// deliberate divergence in INTERNAL state to preserve the VISIBLE
|
|
383
|
+
// behaviour: sdk2's wizard renders an empty fragment for READY via its
|
|
384
|
+
// switch `default`, whereas this codebase renders the submitting screen
|
|
385
|
+
// for READY — so inheriting READY would park the user on a spinner
|
|
386
|
+
// forever. SUBMITTED with no response falls through every terminal
|
|
387
|
+
// branch to `return null`, which is sdk2's empty fragment.
|
|
388
|
+
if (config.onSubmit) {
|
|
389
|
+
store.setState({ submissionStatus: SubmissionStatus.SUBMITTED });
|
|
390
|
+
config.onSubmit(request);
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
const sessionId = store.getState().session.sessionId;
|
|
394
|
+
const endpoint = determineSubmissionEndpoint(options.action, !!(artifacts.id?.frontImage ||
|
|
395
|
+
artifacts.id?.backImage ||
|
|
396
|
+
artifacts.id?.passportImage), !!artifacts.face?.selfieImage);
|
|
397
|
+
apiCallStart = performance.now();
|
|
398
|
+
let response;
|
|
399
|
+
try {
|
|
400
|
+
response = await timedFetch(urls.submissionUrl + endpoint, {
|
|
401
|
+
method: 'POST',
|
|
402
|
+
headers: apiHeaders(sessionId, options.sendBase64DocumentsInSwaggerProxy),
|
|
403
|
+
body: JSON.stringify(request),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
catch (e) {
|
|
407
|
+
apiCallEnd = performance.now();
|
|
408
|
+
throw new NetworkError(e instanceof Error ? e.message : String(e));
|
|
409
|
+
}
|
|
410
|
+
apiCallEnd = performance.now();
|
|
411
|
+
if (!response.ok) {
|
|
412
|
+
if (response.status === 401 || response.status === 403) {
|
|
413
|
+
throw new AuthenticationError(response.status, await response.text());
|
|
414
|
+
}
|
|
415
|
+
const statusMessage = await response.text();
|
|
416
|
+
if (!statusMessage || statusMessage === 'Load failed') {
|
|
417
|
+
throw new NetworkError(statusMessage);
|
|
418
|
+
}
|
|
419
|
+
throw new SubmissionError({
|
|
420
|
+
statusCode: response.statusText ?? '???',
|
|
421
|
+
statusMessage,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
responseParseStart = performance.now();
|
|
425
|
+
const submissionResponse = (await response.json());
|
|
426
|
+
responseParseEnd = performance.now();
|
|
427
|
+
if (submissionResponse.status.statusCode !== '000') {
|
|
428
|
+
throw new SubmissionError(submissionResponse.status);
|
|
429
|
+
}
|
|
430
|
+
store.setState({ submissionStatus: SubmissionStatus.SUBMITTED });
|
|
431
|
+
config.onResponseReceived?.(submissionResponse, request);
|
|
432
|
+
return submissionResponse;
|
|
433
|
+
}
|
|
434
|
+
catch (e) {
|
|
435
|
+
if (failedAt === undefined)
|
|
436
|
+
failedAt = 'submission';
|
|
437
|
+
const err = e;
|
|
438
|
+
store.setState({
|
|
439
|
+
submissionStatus: SubmissionStatus.FAILED,
|
|
440
|
+
submissionError: normalizeSubmissionError(e),
|
|
441
|
+
});
|
|
442
|
+
config.onRequestFailure?.(err);
|
|
443
|
+
// UNLIKE sdk2 (`if (throwErrorsOnFailure) throw err`) there is no
|
|
444
|
+
// catch-swallow path: rejection always propagates.
|
|
445
|
+
throw err;
|
|
446
|
+
}
|
|
447
|
+
finally {
|
|
448
|
+
// Liveness tokens are single-use: clear after each submit so a stale
|
|
449
|
+
// token isn't reapplied on a retry (SubmissionProvider.tsx:1350).
|
|
450
|
+
livenessToken = undefined;
|
|
451
|
+
const endedAt = nowImpl();
|
|
452
|
+
store.setState({
|
|
453
|
+
lastSubmissionTimings: buildSubmissionTimings({
|
|
454
|
+
startedAt,
|
|
455
|
+
endedAt,
|
|
456
|
+
payloadBuildStart,
|
|
457
|
+
payloadBuildEnd,
|
|
458
|
+
uploads: uploadMeasurements,
|
|
459
|
+
apiCallStart,
|
|
460
|
+
apiCallEnd,
|
|
461
|
+
responseParseStart,
|
|
462
|
+
responseParseEnd,
|
|
463
|
+
failedAt,
|
|
464
|
+
}),
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function checkLiveness(imageDataUrl, options = {}) {
|
|
469
|
+
try {
|
|
470
|
+
let selfie = imageDataUrl;
|
|
471
|
+
if (options.useDocumentServiceForLivenessChecks &&
|
|
472
|
+
documentServiceEnabled) {
|
|
473
|
+
if (!selfie.startsWith('data:')) {
|
|
474
|
+
selfie = `data:image/jpeg;base64,${selfie}`;
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
// SubmissionProvider.tsx:748-750 stamping applies here too:
|
|
478
|
+
// buildLivenessCheckPayload's document-service upload (:1361) calls
|
|
479
|
+
// the SAME component-level uploadDocument as submit's, so the
|
|
480
|
+
// liveness selfie's DocumentMetadata gets jobid/taskid whenever
|
|
481
|
+
// options.jobID/taskID are present, exactly like submit's uploads.
|
|
482
|
+
selfie = await performUpload(dataUrlToBlob(selfie), withJobTaskMetadata({ filename: 'liveness', filetype: 'image/jpeg' }, options.jobID, options.taskID));
|
|
483
|
+
}
|
|
484
|
+
catch (e) {
|
|
485
|
+
throw new NetworkError(e instanceof Error ? e.message : String(e));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
selfie = dataUrlToBase64Sync(selfie);
|
|
490
|
+
}
|
|
491
|
+
// `estimateAge`/`predictGender` are sdk2 provider-level props
|
|
492
|
+
// (SubmissionProvider.tsx:430-431) and are now options here, defaulting
|
|
493
|
+
// to sdk2's own `false`. `webhooksStripSpecialCharacters` (:410) has no
|
|
494
|
+
// option yet and keeps sdk2's `true` default hardcoded.
|
|
495
|
+
let request = {
|
|
496
|
+
securityData: { userName: '', password: '', merchantId: 0 },
|
|
497
|
+
customerData: { biometricData: { selfie } },
|
|
498
|
+
additionalData: {
|
|
499
|
+
uniqueRequestId: nowImpl().toString(),
|
|
500
|
+
stripSpecialCharacters: 'Y',
|
|
501
|
+
estimateAge: options.estimateAge ? 'Y' : 'N',
|
|
502
|
+
predictGender: options.predictGender ? 'Y' : 'N',
|
|
503
|
+
},
|
|
504
|
+
};
|
|
505
|
+
// SubmissionProvider.tsx:1382-1388: request ids attach only when present.
|
|
506
|
+
if (options.clientRequestID) {
|
|
507
|
+
request.additionalData.clientRequestID = options.clientRequestID;
|
|
508
|
+
}
|
|
509
|
+
if (options.jobID) {
|
|
510
|
+
request.additionalData.jobID = options.jobID;
|
|
511
|
+
}
|
|
512
|
+
if (options.idCardForFaceMatch) {
|
|
513
|
+
request.customerData.idData = {
|
|
514
|
+
idImageFront: options.idCardForFaceMatch,
|
|
515
|
+
};
|
|
516
|
+
request.customerData.additionalData = {
|
|
517
|
+
uniqueRequestId: request.additionalData.uniqueRequestId,
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
// SubmissionProvider.tsx:1398-1405: metadata attaches unconditionally
|
|
521
|
+
// (sdk2 passes its provider-state values, which default to empty arrays
|
|
522
|
+
// and a null geolocation), placed after the idCardForFaceMatch block and
|
|
523
|
+
// before onBeforeLivenessCheck. The empty-array defaults matter: they
|
|
524
|
+
// make JSON.stringify emit "selfie":[]/"front":[]/"back":[]/"barcode":[]
|
|
525
|
+
// rather than omitting the keys (same reasoning as payload.ts's
|
|
526
|
+
// barcodeCaptureAttempts note) -- defaulted per-field (not by falling
|
|
527
|
+
// back to a whole default object only when options.metadata is
|
|
528
|
+
// entirely absent) so a caller-supplied partial object can't cause its
|
|
529
|
+
// omitted sibling arrays to serialize as `undefined`/missing instead of
|
|
530
|
+
// `[]`. attestationAttached mirrors submit's flow into ClientState —
|
|
531
|
+
// the liveness metadata carries the same attestation envelope, so
|
|
532
|
+
// degradation must be equally visible.
|
|
533
|
+
const { attestationAttached } = attachMetadataToRequest(request, {
|
|
534
|
+
selfieCaptureAttempts: options.metadata?.selfieCaptureAttempts ?? [],
|
|
535
|
+
idFrontCaptureAttempts: options.metadata?.idFrontCaptureAttempts ?? [],
|
|
536
|
+
idBackCaptureAttempts: options.metadata?.idBackCaptureAttempts ?? [],
|
|
537
|
+
barcodeCaptureAttempts: options.metadata?.barcodeCaptureAttempts ?? [],
|
|
538
|
+
barcodeDecodeSummary: options.metadata?.barcodeDecodeSummary,
|
|
539
|
+
geolocationResult: options.metadata?.geolocationResult ?? null,
|
|
540
|
+
});
|
|
541
|
+
store.setState({ attestationAttached });
|
|
542
|
+
if (config.onBeforeLivenessCheck) {
|
|
543
|
+
const result = await config.onBeforeLivenessCheck(request);
|
|
544
|
+
if (result)
|
|
545
|
+
request = result;
|
|
546
|
+
}
|
|
547
|
+
const endpoint = liveCheckEndpoint(!!options.idCardForFaceMatch);
|
|
548
|
+
const sessionId = store.getState().session.sessionId;
|
|
549
|
+
let response;
|
|
550
|
+
try {
|
|
551
|
+
response = await timedFetch(urls.submissionUrl + endpoint, {
|
|
552
|
+
method: 'POST',
|
|
553
|
+
// SubmissionProvider.tsx:1447 — sourced from the same
|
|
554
|
+
// sendBase64DocumentsInSwaggerProxy flag submit() reads off
|
|
555
|
+
// SubmissionOptions (:368 above), just on LivenessOptions instead.
|
|
556
|
+
// apiHeaders' own default (false) covers the omitted case.
|
|
557
|
+
headers: apiHeaders(sessionId, options.sendBase64DocumentsInSwaggerProxy),
|
|
558
|
+
body: JSON.stringify(request),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch (e) {
|
|
562
|
+
throw new NetworkError(e instanceof Error ? e.message : String(e));
|
|
563
|
+
}
|
|
564
|
+
if (!response.ok) {
|
|
565
|
+
if (response.status === 401 || response.status === 403) {
|
|
566
|
+
throw new AuthenticationError(response.status, await response.text());
|
|
567
|
+
}
|
|
568
|
+
const statusMessage = await response.text();
|
|
569
|
+
if (!statusMessage || statusMessage === 'Load failed') {
|
|
570
|
+
throw new NetworkError(statusMessage);
|
|
571
|
+
}
|
|
572
|
+
throw new SubmissionError({
|
|
573
|
+
statusCode: response.statusText,
|
|
574
|
+
statusMessage,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
const livenessResponse = (await response.json());
|
|
578
|
+
if (livenessResponse.status.statusCode !== '000') {
|
|
579
|
+
throw new SubmissionError(livenessResponse.status);
|
|
580
|
+
}
|
|
581
|
+
// Reflect this call's outcome, mirroring SubmissionProvider.tsx:1477-1483:
|
|
582
|
+
// if the server didn't issue a token, clear any stale one from a prior
|
|
583
|
+
// call. Source gates this on `useFrontendLivenessToken`, a
|
|
584
|
+
// SubmissionOptions-level flag; LivenessOptions (this task's mandated
|
|
585
|
+
// surface) has no analogous per-check toggle, so capture is
|
|
586
|
+
// unconditional here — a deliberate scope narrowing, not a silent drop.
|
|
587
|
+
livenessToken = livenessResponse.resultData?.livenessToken;
|
|
588
|
+
if (options.softFail &&
|
|
589
|
+
!isLiveFaceConfirmed(livenessResponse.resultData?.verificationResult)) {
|
|
590
|
+
// Current sdk2 (SubmissionProvider.tsx checkLiveness): softFail also
|
|
591
|
+
// fails on a statusCode-000 response without a confirmed live face —
|
|
592
|
+
// clear the just-stashed token (single-use, and this one is for a
|
|
593
|
+
// non-live capture) and hand back a typed failure that still carries
|
|
594
|
+
// the response so callers can read the detection flags.
|
|
595
|
+
livenessToken = undefined;
|
|
596
|
+
return {
|
|
597
|
+
ok: false,
|
|
598
|
+
error: new Error(`Liveness not confirmed: ${livenessResponse.resultData?.verificationResult ??
|
|
599
|
+
'no verificationResult'}`),
|
|
600
|
+
response: livenessResponse,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
return { ok: true, response: livenessResponse };
|
|
604
|
+
}
|
|
605
|
+
catch (e) {
|
|
606
|
+
if (options.softFail) {
|
|
607
|
+
// Caller is treating this as a best-effort check. Don't surface the
|
|
608
|
+
// error globally; clear any stashed token (:1493) and hand back a
|
|
609
|
+
// typed failure result instead of sdk2's silent `undefined` (deliberate
|
|
610
|
+
// divergence #3).
|
|
611
|
+
livenessToken = undefined;
|
|
612
|
+
return { ok: false, error: e };
|
|
613
|
+
}
|
|
614
|
+
const err = e;
|
|
615
|
+
store.setState({
|
|
616
|
+
submissionStatus: SubmissionStatus.FAILED,
|
|
617
|
+
submissionError: normalizeSubmissionError(e),
|
|
618
|
+
});
|
|
619
|
+
config.onRequestFailure?.(err);
|
|
620
|
+
throw err;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
async function clientUploadDocument(blob, metadata) {
|
|
624
|
+
if (!documentServiceEnabled) {
|
|
625
|
+
throw new Error('document upload is disabled: no documentServiceUrl configured');
|
|
626
|
+
}
|
|
627
|
+
return performUpload(blob, metadata ?? {});
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
getState: () => store.getState(),
|
|
631
|
+
subscribe: (listener) => store.subscribe((s) => listener(s)),
|
|
632
|
+
validateSession: validateSessionMethod,
|
|
633
|
+
retrySession,
|
|
634
|
+
submit,
|
|
635
|
+
checkLiveness,
|
|
636
|
+
uploadDocument: clientUploadDocument,
|
|
637
|
+
};
|
|
638
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UploadedDocument } from './uploadedDocument';
|
|
2
|
+
export type BuildUploadedDocumentInput = {
|
|
3
|
+
/** The document's configured name, e.g. 'POA'. Becomes `documentName`. */
|
|
4
|
+
name: string;
|
|
5
|
+
processAsPOA?: boolean;
|
|
6
|
+
/** The selected file's own name, e.g. 'proof.png'. */
|
|
7
|
+
fileName: string;
|
|
8
|
+
/** A full data URL as produced by `FileReader.readAsDataURL`. */
|
|
9
|
+
dataUrl: string;
|
|
10
|
+
/** ISO-8601 timestamp of when the user selected the file. */
|
|
11
|
+
capturedAt: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function buildUploadedDocument({ name, processAsPOA, fileName, dataUrl, capturedAt, }: BuildUploadedDocumentInput): UploadedDocument;
|
|
14
|
+
//# sourceMappingURL=additionalDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"additionalDocument.d.ts","sourceRoot":"","sources":["../../src/client/additionalDocument.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,MAAM,MAAM,0BAA0B,GAAG;IACvC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAA;IAChB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAA;IACf,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAaD,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,UAAU,GACX,EAAE,0BAA0B,GAAG,gBAAgB,CAc/C"}
|