@idmission/websdk-ui 0.2.0 → 0.6.0
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 +75 -4
- package/dist/DocumentCaptureView.d.ts +7 -5
- package/dist/DocumentCaptureView.d.ts.map +1 -1
- package/dist/DocumentCaptureView.js +30 -26
- package/dist/FaceLivenessView.d.ts +2 -2
- package/dist/FaceLivenessView.d.ts.map +1 -1
- package/dist/FaceLivenessView.js +47 -13
- package/dist/IdCaptureView.d.ts +27 -15
- package/dist/IdCaptureView.d.ts.map +1 -1
- package/dist/IdCaptureView.js +149 -26
- package/dist/SelfieCaptureView.d.ts +18 -1
- package/dist/SelfieCaptureView.d.ts.map +1 -1
- package/dist/SelfieCaptureView.js +13 -4
- package/dist/SignatureCaptureView.d.ts +18 -5
- package/dist/SignatureCaptureView.d.ts.map +1 -1
- package/dist/SignatureCaptureView.js +90 -15
- package/dist/VideoIdCaptureView.d.ts +14 -2
- package/dist/VideoIdCaptureView.d.ts.map +1 -1
- package/dist/VideoIdCaptureView.js +13 -6
- package/dist/bindings/useDocumentCapture.d.ts.map +1 -1
- package/dist/bindings/useDocumentCapture.js +2 -1
- package/dist/bindings/useIdCapture.d.ts.map +1 -1
- package/dist/bindings/useIdCapture.js +2 -1
- package/dist/bindings/useSelfieCapture.d.ts.map +1 -1
- package/dist/bindings/useSelfieCapture.js +2 -1
- package/dist/bindings/useSignatureCapture.d.ts.map +1 -1
- package/dist/bindings/useSignatureCapture.js +2 -1
- package/dist/bindings/useVideoIdCapture.d.ts.map +1 -1
- package/dist/bindings/useVideoIdCapture.js +2 -1
- package/dist/components/common/BrowserEdgeTint.d.ts +63 -0
- package/dist/components/common/BrowserEdgeTint.d.ts.map +1 -0
- package/dist/components/common/BrowserEdgeTint.js +111 -0
- package/dist/components/common/LoaderButton.d.ts +9 -0
- package/dist/components/common/LoaderButton.d.ts.map +1 -1
- package/dist/components/common/LoaderButton.js +44 -321
- package/dist/components/common/ScreenReaderStatus.d.ts +8 -0
- package/dist/components/common/ScreenReaderStatus.d.ts.map +1 -0
- package/dist/components/common/ScreenReaderStatus.js +18 -0
- package/dist/components/common/overlay.d.ts +6 -0
- package/dist/components/common/overlay.d.ts.map +1 -1
- package/dist/components/common/overlay.js +7 -1
- package/dist/components/debug/debug.d.ts +6 -0
- package/dist/components/debug/debug.d.ts.map +1 -1
- package/dist/components/debug/debug.js +5 -1
- package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.d.ts.map +1 -1
- package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.js +4 -5
- package/dist/components/document/DocumentCaptureAutoCaptureGuidance.d.ts.map +1 -1
- package/dist/components/document/DocumentCaptureAutoCaptureGuidance.js +40 -13
- package/dist/components/error/CameraAccessDeniedOverlay.d.ts +8 -1
- package/dist/components/error/CameraAccessDeniedOverlay.d.ts.map +1 -1
- package/dist/components/error/useCameraAccessDeniedReport.d.ts +12 -0
- package/dist/components/error/useCameraAccessDeniedReport.d.ts.map +1 -0
- package/dist/components/error/useCameraAccessDeniedReport.js +31 -0
- package/dist/components/face_liveness/FaceLivenessFailure.d.ts +4 -1
- package/dist/components/face_liveness/FaceLivenessFailure.d.ts.map +1 -1
- package/dist/components/face_liveness/FaceLivenessFailure.js +4 -2
- package/dist/components/face_liveness/FaceLivenessSuccess.d.ts +4 -1
- package/dist/components/face_liveness/FaceLivenessSuccess.d.ts.map +1 -1
- package/dist/components/face_liveness/FaceLivenessSuccess.js +6 -2
- package/dist/components/guides/IdCaptureFitGuide.d.ts +2 -0
- package/dist/components/guides/IdCaptureFitGuide.d.ts.map +1 -1
- package/dist/components/guides/IdCaptureFitGuide.js +4 -1
- package/dist/components/guides/IdCaptureGuideOverlay.d.ts +2 -0
- package/dist/components/guides/IdCaptureGuideOverlay.d.ts.map +1 -1
- package/dist/components/guides/IdCaptureGuideOverlay.js +3 -1
- package/dist/components/guides/IdCaptureGuides.d.ts +14 -0
- package/dist/components/guides/IdCaptureGuides.d.ts.map +1 -1
- package/dist/components/guides/IdCaptureGuides.js +22 -7
- package/dist/components/guides/IdCaptureGuidesCommon.d.ts.map +1 -1
- package/dist/components/guides/IdCaptureGuidesCommon.js +12 -7
- package/dist/components/loading/IdCaptureLoadingOverlayDefault.d.ts +9 -0
- package/dist/components/loading/IdCaptureLoadingOverlayDefault.d.ts.map +1 -1
- package/dist/components/loading/IdCaptureLoadingOverlayDefault.js +26 -4
- package/dist/components/loading/RingIntroScreen.d.ts.map +1 -1
- package/dist/components/loading/RingIntroScreen.js +4 -34
- package/dist/components/review/ReviewScreen.d.ts +10 -1
- package/dist/components/review/ReviewScreen.d.ts.map +1 -1
- package/dist/components/review/ReviewScreen.js +8 -8
- package/dist/components/review/SignatureCaptureDiagnostics.d.ts +5 -1
- package/dist/components/review/SignatureCaptureDiagnostics.d.ts.map +1 -1
- package/dist/components/review/SignatureCaptureDiagnostics.js +4 -2
- package/dist/components/selfie/FaceCaptureGuideOverlay.d.ts +9 -2
- package/dist/components/selfie/FaceCaptureGuideOverlay.d.ts.map +1 -1
- package/dist/components/selfie/FaceCaptureGuideOverlay.js +10 -4
- package/dist/components/selfie/SelfieCaptureAnimatedMask.d.ts +8 -1
- package/dist/components/selfie/SelfieCaptureAnimatedMask.d.ts.map +1 -1
- package/dist/components/selfie/SelfieCaptureAnimatedMask.js +55 -21
- package/dist/components/selfie/SelfieCaptureSurface.d.ts +9 -2
- package/dist/components/selfie/SelfieCaptureSurface.d.ts.map +1 -1
- package/dist/components/selfie/SelfieCaptureSurface.js +77 -16
- package/dist/components/selfie_loading/SelfieCaptureLoadingOverlayDefault.d.ts +9 -0
- package/dist/components/selfie_loading/SelfieCaptureLoadingOverlayDefault.d.ts.map +1 -1
- package/dist/components/selfie_loading/SelfieCaptureLoadingOverlayDefault.js +26 -4
- package/dist/flows/AuthStateContext.d.ts.map +1 -1
- package/dist/flows/AuthStateContext.js +2 -1
- package/dist/flows/CaptureProgress.d.ts +14 -0
- package/dist/flows/CaptureProgress.d.ts.map +1 -0
- package/dist/flows/CaptureProgress.js +51 -0
- package/dist/flows/CompositeWizard.d.ts +7 -1
- package/dist/flows/CompositeWizard.d.ts.map +1 -1
- package/dist/flows/CompositeWizard.js +6 -2
- package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts +3 -3
- package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts.map +1 -1
- package/dist/flows/CustomerBiometricsEnrollmentFlow.js +26 -4
- package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts +3 -3
- package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts.map +1 -1
- package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.js +45 -9
- package/dist/flows/DocumentCaptureFlow.d.ts +4 -3
- package/dist/flows/DocumentCaptureFlow.d.ts.map +1 -1
- package/dist/flows/DocumentCaptureFlow.js +14 -8
- package/dist/flows/FaceValidationFlow.d.ts +2 -2
- package/dist/flows/FaceValidationFlow.d.ts.map +1 -1
- package/dist/flows/FaceValidationFlow.js +7 -2
- package/dist/flows/FlowChassis.d.ts +19 -1
- package/dist/flows/FlowChassis.d.ts.map +1 -1
- package/dist/flows/FlowChassis.js +40 -4
- package/dist/flows/IdAndFaceValidationFlow.d.ts +3 -3
- package/dist/flows/IdAndFaceValidationFlow.d.ts.map +1 -1
- package/dist/flows/IdAndFaceValidationFlow.js +33 -3
- package/dist/flows/IdValidationFlow.d.ts +10 -5
- package/dist/flows/IdValidationFlow.d.ts.map +1 -1
- package/dist/flows/IdValidationFlow.js +32 -5
- package/dist/flows/SignatureKYCFlow.d.ts +43 -7
- package/dist/flows/SignatureKYCFlow.d.ts.map +1 -1
- package/dist/flows/SignatureKYCFlow.js +154 -16
- package/dist/flows/SubmissionProvider.d.ts +12 -3
- package/dist/flows/SubmissionProvider.d.ts.map +1 -1
- package/dist/flows/SubmissionProvider.js +142 -16
- package/dist/flows/VideoIdValidationFlow.d.ts +3 -5
- package/dist/flows/VideoIdValidationFlow.d.ts.map +1 -1
- package/dist/flows/VideoIdValidationFlow.js +38 -4
- package/dist/flows/additionalDocuments.d.ts.map +1 -1
- package/dist/flows/additionalDocuments.js +3 -6
- package/dist/flows/approval.d.ts +1 -14
- package/dist/flows/approval.d.ts.map +1 -1
- package/dist/flows/approval.js +1 -19
- package/dist/flows/artifacts.d.ts +1 -1
- package/dist/flows/artifacts.d.ts.map +1 -1
- package/dist/flows/artifacts.js +29 -9
- package/dist/flows/customerMatch/CustomerMatchCapture.d.ts +3 -2
- package/dist/flows/customerMatch/CustomerMatchCapture.d.ts.map +1 -1
- package/dist/flows/customerMatch/CustomerMatchCapture.js +3 -2
- package/dist/flows/customerMatch/CustomerMatchFlow.d.ts +13 -4
- package/dist/flows/customerMatch/CustomerMatchFlow.d.ts.map +1 -1
- package/dist/flows/customerMatch/CustomerMatchFlow.js +17 -12
- package/dist/flows/flowSettings.d.ts +11 -0
- package/dist/flows/flowSettings.d.ts.map +1 -0
- package/dist/flows/flowSettings.js +20 -0
- package/dist/flows/ringScreens.d.ts +1 -0
- package/dist/flows/ringScreens.d.ts.map +1 -1
- package/dist/flows/ringScreens.js +17 -2
- package/dist/flows/signatureStep.d.ts +6 -1
- package/dist/flows/signatureStep.d.ts.map +1 -1
- package/dist/flows/types.d.ts +120 -10
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/flows/videoIdSteps.d.ts +2 -2
- package/dist/flows/videoIdSteps.d.ts.map +1 -1
- package/dist/guidance/selfieStrings.d.ts.map +1 -1
- package/dist/guidance/selfieStrings.js +8 -4
- package/dist/guidance/strings.d.ts +34 -1
- package/dist/guidance/strings.d.ts.map +1 -1
- package/dist/guidance/strings.js +39 -0
- package/dist/i18n/index.d.ts +5 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +13 -2
- package/dist/i18n/locales/threeOh.d.ts.map +1 -1
- package/dist/i18n/locales/threeOh.js +56 -2
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/testing/autoCaptureFrames.d.ts.map +1 -1
- package/dist/testing/autoCaptureFrames.js +10 -4
- package/dist/testing/buildSelfieState.d.ts.map +1 -1
- package/dist/testing/buildSelfieState.js +5 -0
- package/dist/testing/classNamesLeaves.js +1 -1
- package/dist/testing/fakeClient.d.ts +41 -2
- package/dist/testing/fakeClient.d.ts.map +1 -1
- package/dist/testing/fakeClient.js +71 -16
- package/dist/testing/fakeSelfieController.d.ts.map +1 -1
- package/dist/testing/fakeSelfieController.js +7 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/useDocumentUpload.d.ts +63 -0
- package/dist/useDocumentUpload.d.ts.map +1 -0
- package/dist/useDocumentUpload.js +45 -0
- package/dist/useIdmissionClient.d.ts +24 -3
- package/dist/useIdmissionClient.d.ts.map +1 -1
- package/dist/useIdmissionClient.js +46 -0
- package/dist/utils/mountOnly.d.ts +25 -0
- package/dist/utils/mountOnly.d.ts.map +1 -0
- package/dist/utils/mountOnly.js +111 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -9
- package/dist/flows/autoCaptureMountGuard.d.ts +0 -22
- package/dist/flows/autoCaptureMountGuard.d.ts.map +0 -1
- package/dist/flows/autoCaptureMountGuard.js +0 -61
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { type SubmissionArtifacts } from '@idmission/websdk-core/client';
|
|
2
2
|
import { type SelfieCaptureController, type SelfieCaptureThresholds, type SelfieLivenessConfig } from '@idmission/websdk-core/selfieCapture';
|
|
3
3
|
import { type SignatureCaptureController, type SignatureCaptureControllerConfig } from '@idmission/websdk-core/signatureCapture';
|
|
4
|
+
import { type SelfieCaptureViewClassNames } from '../SelfieCaptureView';
|
|
4
5
|
import { type SignatureCaptureViewProps } from '../SignatureCaptureView';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
6
|
+
import type { SignatureFlowViewProps } from './signatureStep';
|
|
7
|
+
import type { CommonFlowProps, FaceLivenessFlowConfig, FaceLivenessFlowViewProps, FlowResultCallbacks, SubmitMode } from './types';
|
|
8
|
+
export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallbacks | 'children' | 'showResultScreen' | 'showSuccessScreen' | 'skipSuccessScreen' | 'showDiagnostics' | 'captureAdditionalDocuments' | 'additionalDocumentVerbiage' | 'ringScreenVerbiage'> & Pick<FlowResultCallbacks, 'onSubmissionStarted' | 'onSubmissionFailure'> & {
|
|
9
|
+
/**
|
|
10
|
+
* What the flow does once the signature is complete. There is no `'post'`:
|
|
11
|
+
* signature KYC collects evidence and has no endpoint of its own.
|
|
12
|
+
*
|
|
13
|
+
* - `'capture'` (the default): nothing is submitted; `onCaptured` receives
|
|
14
|
+
* the selfie and signature artifacts.
|
|
15
|
+
* - `{ handoff }`: once the session has passed, the SDK builds the request,
|
|
16
|
+
* uploading the documents, and passes it to `handoff` instead of posting
|
|
17
|
+
* it. The flow shows a finishing screen meanwhile and a retry screen if
|
|
18
|
+
* the build fails.
|
|
19
|
+
*/
|
|
20
|
+
submitMode?: Exclude<SubmitMode, 'post'>;
|
|
7
21
|
selfieController?: SelfieCaptureController;
|
|
8
22
|
signatureController?: SignatureCaptureController;
|
|
9
23
|
/**
|
|
@@ -21,12 +35,26 @@ export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallba
|
|
|
21
35
|
* render, so the whole object can be written inline.
|
|
22
36
|
*/
|
|
23
37
|
signatureCapture?: SignatureCaptureControllerConfig;
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Under `skipLivenessValidation` these drive a plain `SelfieCaptureView`,
|
|
40
|
+
* which also shows the stock-camera fallback, hence its classes.
|
|
41
|
+
*/
|
|
42
|
+
faceView?: FaceLivenessFlowViewProps & {
|
|
43
|
+
classNames?: Pick<SelfieCaptureViewClassNames, 'fallback'>;
|
|
44
|
+
};
|
|
45
|
+
signatureView?: SignatureFlowViewProps;
|
|
26
46
|
/** One-prop challenge-response opt-in for the liveness step. */
|
|
27
47
|
challengeResponse?: NonNullable<SelfieLivenessConfig['challenge']>;
|
|
28
48
|
/** Passed to both camera acquisitions; defaults to false in core. */
|
|
29
49
|
allowVirtualCameras?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Allows the flow-owned shared front camera above the default 1280×720 cap.
|
|
52
|
+
* Defaults to false. True preserves normal camera selection and any explicit
|
|
53
|
+
* `faceCapture.camera` / `signatureCapture.camera` maximum. Read once at mount;
|
|
54
|
+
* remount to change it. Higher resolutions can reduce signing responsiveness
|
|
55
|
+
* on slower devices. Supplied controllers manage their own cameras.
|
|
56
|
+
*/
|
|
57
|
+
allowHigherCameraResolutions?: boolean;
|
|
30
58
|
/** Captures a selfie without calling the liveness endpoint, matching 2.x. */
|
|
31
59
|
skipLivenessValidation?: boolean;
|
|
32
60
|
allowManualSelfieCaptureOnLoadingError?: boolean;
|
|
@@ -36,9 +64,17 @@ export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallba
|
|
|
36
64
|
/** Lets the user continue to signature capture from the liveness failure screen. */
|
|
37
65
|
allowSignatureAfterLivenessCheckFailure?: boolean;
|
|
38
66
|
showFaceGuideThenSignaturePad?: boolean;
|
|
39
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Skips the signature review and completes automatically, matching 2.x.
|
|
69
|
+
* `signatureView.skipSuccessScreen`, when set, overrides it. (The face step
|
|
70
|
+
* never shows a review screen here: it hands the camera straight back to the
|
|
71
|
+
* signature pad.)
|
|
72
|
+
*/
|
|
40
73
|
skipSuccessScreen?: SignatureCaptureViewProps['skipSuccessScreen'];
|
|
41
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Receives the combined selfie and signature artifacts without a network
|
|
76
|
+
* submission. Fires only in `'capture'` mode.
|
|
77
|
+
*/
|
|
42
78
|
onCaptured?: (artifacts: SubmissionArtifacts) => void;
|
|
43
79
|
onCaptureError?: (error: Error) => void;
|
|
44
80
|
};
|
|
@@ -60,5 +96,5 @@ export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallba
|
|
|
60
96
|
* `thresholds` outrank both.
|
|
61
97
|
*/
|
|
62
98
|
export declare function faceThresholdsForLayout(legacyVideoLayout: boolean, thresholds: SelfieCaptureThresholds | undefined): SelfieCaptureThresholds | undefined;
|
|
63
|
-
export declare function SignatureKYCFlow({ client, selfieController, signatureController, faceCapture, signatureCapture, faceView, signatureView, challengeResponse, allowVirtualCameras, skipLivenessValidation, allowManualSelfieCaptureOnLoadingError, headTrackingDisabled, headTrackingBoundaryPercentage, headTrackingBoundaryType, allowSignatureAfterLivenessCheckFailure, showFaceGuideThenSignaturePad, skipSuccessScreen, submission, initialArtifacts, theme, className, geolocationEnabled, geolocationRequired, remoteDiagnostics, loadingSpinner, onCaptured, onCaptureError, }: SignatureKYCFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
99
|
+
export declare function SignatureKYCFlow({ client, selfieController, signatureController, faceCapture, signatureCapture, faceView: faceViewProp, signatureView: signatureViewProp, challengeResponse, allowVirtualCameras, allowHigherCameraResolutions, skipLivenessValidation, allowManualSelfieCaptureOnLoadingError, headTrackingDisabled, headTrackingBoundaryPercentage, headTrackingBoundaryType, allowSignatureAfterLivenessCheckFailure, showFaceGuideThenSignaturePad, skipSuccessScreen, submission, initialArtifacts, theme, className, lang, debugMode, geolocationEnabled, geolocationRequired, captureProgress, remoteDiagnostics, loadingSpinner, submitMode, onSubmissionStarted, onSubmissionFailure, onCaptured, onCaptureError, }: SignatureKYCFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
64
100
|
//# sourceMappingURL=SignatureKYCFlow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureKYCFlow.d.ts","sourceRoot":"","sources":["../../src/flows/SignatureKYCFlow.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"SignatureKYCFlow.d.ts","sourceRoot":"","sources":["../../src/flows/SignatureKYCFlow.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { styled } from 'styled-components';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { styled, useTheme } from 'styled-components';
|
|
4
4
|
import { acquireCamera } from '@idmission/websdk-core/camera';
|
|
5
|
-
import { SubmissionAction, } from '@idmission/websdk-core/client';
|
|
5
|
+
import { SubmissionAction, SubmissionStatus, } from '@idmission/websdk-core/client';
|
|
6
6
|
import { createSelfieCaptureController, } from '@idmission/websdk-core/selfieCapture';
|
|
7
7
|
import { createSignatureCaptureController, } from '@idmission/websdk-core/signatureCapture';
|
|
8
8
|
import { FaceLivenessView } from '../FaceLivenessView';
|
|
9
9
|
import { SelfieCaptureView } from '../SelfieCaptureView';
|
|
10
10
|
import { useSelfieCapture } from '../bindings/useSelfieCapture';
|
|
11
|
+
import { useSignatureCapture } from '../bindings/useSignatureCapture';
|
|
12
|
+
import { BrowserEdgeTint, opaqueColor } from '../components/common/BrowserEdgeTint';
|
|
13
|
+
import { SELFIE_LOADING_OVERLAY_BACKGROUND_DEFAULT, selfieLoadingOverlayBottomEdgeColor, } from '../components/selfie_loading/SelfieCaptureLoadingOverlayDefault';
|
|
11
14
|
import { impliedAutoContinueAfterLoading, impliedSkipSuccessScreen, isRingIntroActive, } from './ringIntroImplications';
|
|
12
15
|
import { SignatureCaptureView, } from '../SignatureCaptureView';
|
|
16
|
+
import { inheritFlowSettings } from './flowSettings';
|
|
13
17
|
import { buildSelfieArtifacts, mergeSubmissionArtifacts } from './artifacts';
|
|
14
18
|
import { FlowChassis } from './FlowChassis';
|
|
19
|
+
import { CaptureProgressCompletion } from './CaptureProgress';
|
|
20
|
+
import { useSessionReady } from './AuthStateContext';
|
|
21
|
+
import { submissionStatusText } from './CompositeWizard';
|
|
22
|
+
import { OrbStatusScreen } from './OrbStatusScreen';
|
|
23
|
+
import { SubmissionErrorOverlay } from './overlays';
|
|
24
|
+
import { useSubmission } from './SubmissionProvider';
|
|
15
25
|
import { useLatestCallbacks } from './latestCallbacks';
|
|
26
|
+
import { FLOW_MOUNT_ONLY_REMEDY, useMountOnlyWarnings } from '../utils/mountOnly';
|
|
16
27
|
import { createSharedCameraAcquirer, withVirtualCameras, } from './sharedCamera';
|
|
17
28
|
/**
|
|
18
29
|
* Face-tracking thresholds the face stage runs under, given the layout its
|
|
@@ -49,13 +60,26 @@ const EMPTY_FACE_VIEW = {};
|
|
|
49
60
|
const EMPTY_SIGNATURE_VIEW = {};
|
|
50
61
|
const EMPTY_SUBMISSION = {};
|
|
51
62
|
const EMPTY_ARTIFACTS = {};
|
|
52
|
-
export function SignatureKYCFlow({ client, selfieController, signatureController, faceCapture = EMPTY_FACE_CAPTURE, signatureCapture = EMPTY_SIGNATURE_CAPTURE, faceView = EMPTY_FACE_VIEW, signatureView = EMPTY_SIGNATURE_VIEW, challengeResponse, allowVirtualCameras, skipLivenessValidation = false, allowManualSelfieCaptureOnLoadingError = false, headTrackingDisabled = false, headTrackingBoundaryPercentage = 0.01, headTrackingBoundaryType = 'head', allowSignatureAfterLivenessCheckFailure = false, showFaceGuideThenSignaturePad = false, skipSuccessScreen, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, theme, className, geolocationEnabled, geolocationRequired, remoteDiagnostics, loadingSpinner, onCaptured, onCaptureError, }) {
|
|
63
|
+
export function SignatureKYCFlow({ client, selfieController, signatureController, faceCapture = EMPTY_FACE_CAPTURE, signatureCapture = EMPTY_SIGNATURE_CAPTURE, faceView: faceViewProp = EMPTY_FACE_VIEW, signatureView: signatureViewProp = EMPTY_SIGNATURE_VIEW, challengeResponse, allowVirtualCameras, allowHigherCameraResolutions = false, skipLivenessValidation = false, allowManualSelfieCaptureOnLoadingError = false, headTrackingDisabled = false, headTrackingBoundaryPercentage = 0.01, headTrackingBoundaryType = 'head', allowSignatureAfterLivenessCheckFailure = false, showFaceGuideThenSignaturePad = false, skipSuccessScreen, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, theme, className, lang, debugMode, geolocationEnabled, geolocationRequired, captureProgress, remoteDiagnostics, loadingSpinner, submitMode = 'capture', onSubmissionStarted, onSubmissionFailure, onCaptured, onCaptureError, }) {
|
|
64
|
+
// Flow-wide settings reach each step unless its own bag sets them.
|
|
65
|
+
const { faceView, signatureView } = useMemo(() => ({
|
|
66
|
+
faceView: inheritFlowSettings(faceViewProp, { lang, debugMode }),
|
|
67
|
+
signatureView: inheritFlowSettings(signatureViewProp, {
|
|
68
|
+
lang,
|
|
69
|
+
showCaptureDiagnostics: debugMode,
|
|
70
|
+
skipSuccessScreen,
|
|
71
|
+
}),
|
|
72
|
+
}), [debugMode, faceViewProp, lang, signatureViewProp, skipSuccessScreen]);
|
|
53
73
|
const { checkLivenessOptions, ...selfieCaptureConfig } = faceCapture;
|
|
74
|
+
useMountOnlyWarnings('SignatureKYCFlow', FLOW_MOUNT_ONLY_REMEDY, {
|
|
75
|
+
faceCapture: selfieCaptureConfig,
|
|
76
|
+
signatureCapture,
|
|
77
|
+
});
|
|
54
78
|
// Config callbacks follow the latest render; see useLatestCallbacks.
|
|
55
79
|
const latestSelfieCapture = useLatestCallbacks(selfieCaptureConfig);
|
|
56
80
|
const latestSelfieLiveness = useLatestCallbacks(selfieCaptureConfig.liveness);
|
|
57
81
|
const latestSignatureCapture = useLatestCallbacks(signatureCapture);
|
|
58
|
-
const legacyVideoLayout = signatureView
|
|
82
|
+
const legacyVideoLayout = signatureView.legacyVideoLayout ?? false;
|
|
59
83
|
const onExitAfterLivenessFailure = faceView.onExitAfterFailure;
|
|
60
84
|
const sharedVideoRef = useRef(null);
|
|
61
85
|
const [sharedVideoNode, setSharedVideoNode] = useState(null);
|
|
@@ -67,9 +91,22 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
67
91
|
useEffect(() => {
|
|
68
92
|
checkLivenessOptionsRef.current = checkLivenessOptions;
|
|
69
93
|
}, [checkLivenessOptions]);
|
|
70
|
-
const [sharedAcquireCamera] = useState(() =>
|
|
71
|
-
|
|
72
|
-
|
|
94
|
+
const [sharedAcquireCamera] = useState(() => {
|
|
95
|
+
const baseAcquire = selfieCaptureConfig.io?.acquireCamera ??
|
|
96
|
+
signatureCapture.io?.acquireCamera ??
|
|
97
|
+
acquireCamera;
|
|
98
|
+
// Both stages share the first stream. Unless the host opts into higher
|
|
99
|
+
// resolutions, cap acquisition before selfie guidance and direct signing.
|
|
100
|
+
return createSharedCameraAcquirer((video, options) => baseAcquire(video, {
|
|
101
|
+
...options,
|
|
102
|
+
...(!allowHigherCameraResolutions && options?.preferFrontFacingCamera && {
|
|
103
|
+
maxVideoResolution: {
|
|
104
|
+
width: Math.min(options.maxVideoResolution?.width ?? 1280, 1280),
|
|
105
|
+
height: Math.min(options.maxVideoResolution?.height ?? 720, 720),
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
73
110
|
const [resolvedSelfieController] = useState(() => selfieController ??
|
|
74
111
|
createSelfieCaptureController({
|
|
75
112
|
...latestSelfieCapture,
|
|
@@ -101,6 +138,7 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
101
138
|
},
|
|
102
139
|
}));
|
|
103
140
|
const selfieState = useSelfieCapture(resolvedSelfieController);
|
|
141
|
+
const signatureState = useSignatureCapture(resolvedSignatureController);
|
|
104
142
|
const hasPrecapturedSelfie = Boolean(initialArtifacts.face?.selfieImage);
|
|
105
143
|
const [stage, setStage] = useState(hasPrecapturedSelfie ? 'signature-capture' : 'face-liveness');
|
|
106
144
|
/**
|
|
@@ -128,11 +166,37 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
128
166
|
!awaitingRestartSelfie
|
|
129
167
|
? 'signature-capture'
|
|
130
168
|
: stage;
|
|
169
|
+
// What is touching the viewport edges, for iOS Safari's bars (FlowEdgeTint).
|
|
170
|
+
// The face stage's loading overlay is dismissed inside its view, so the view
|
|
171
|
+
// reports it; only the default overlay paints one flat colour.
|
|
172
|
+
const [faceOverlayDismissed, setFaceOverlayDismissed] = useState(false);
|
|
173
|
+
const handleFaceOverlayDismissed = useCallback(() => {
|
|
174
|
+
setFaceOverlayDismissed(true);
|
|
175
|
+
faceView.onLoadingOverlayDismissed?.();
|
|
176
|
+
}, [faceView]);
|
|
177
|
+
const edgeSurface = renderedStage === 'face-liveness' && !faceOverlayDismissed
|
|
178
|
+
? (faceView.loadingOverlayMode ?? 'default') === 'default'
|
|
179
|
+
? 'overlay'
|
|
180
|
+
: null
|
|
181
|
+
: renderedStage === 'signature-capture' &&
|
|
182
|
+
(signatureState.phase === 'reviewing' ||
|
|
183
|
+
signatureState.phase === 'completed' ||
|
|
184
|
+
signatureState.phase === 'error')
|
|
185
|
+
? 'panel'
|
|
186
|
+
: renderedStage === 'face-liveness' ||
|
|
187
|
+
signatureState.captureMode === 'video'
|
|
188
|
+
? 'camera'
|
|
189
|
+
: 'panel';
|
|
131
190
|
useEffect(() => {
|
|
132
191
|
if (stage !== 'signature-capture' ||
|
|
133
|
-
headTrackingDisabled ||
|
|
134
192
|
!selfieState.models.ready)
|
|
135
193
|
return;
|
|
194
|
+
if (headTrackingDisabled) {
|
|
195
|
+
// Without liveness validation, the selfie remains in processing and its
|
|
196
|
+
// overlay prediction loop is still running behind the signature pad.
|
|
197
|
+
resolvedSelfieController.actions.stopTracking();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
136
200
|
resolvedSelfieController.actions.startTracking();
|
|
137
201
|
return () => resolvedSelfieController.actions.stopTracking();
|
|
138
202
|
}, [
|
|
@@ -215,14 +279,24 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
215
279
|
resolvedSelfieController.actions.retry();
|
|
216
280
|
setStage('face-liveness');
|
|
217
281
|
}, [resolvedSelfieController]);
|
|
282
|
+
// Lives here, above the chassis's session gate: a session error unmounts
|
|
283
|
+
// and remounts `SignatureHandoff`, and must not start the hand-off again.
|
|
284
|
+
const handoffStartedRef = useRef(false);
|
|
285
|
+
const claimHandoffStart = useCallback(() => {
|
|
286
|
+
if (handoffStartedRef.current)
|
|
287
|
+
return false;
|
|
288
|
+
handoffStartedRef.current = true;
|
|
289
|
+
return true;
|
|
290
|
+
}, []);
|
|
218
291
|
const handleSignatureCompleted = useCallback((artifacts) => {
|
|
219
292
|
if (completedRef.current)
|
|
220
293
|
return;
|
|
221
294
|
completedRef.current = true;
|
|
222
295
|
artifactsRef.current = mergeSubmissionArtifacts(artifactsRef.current, artifacts);
|
|
223
296
|
setStage('complete');
|
|
224
|
-
|
|
225
|
-
|
|
297
|
+
if (submitMode === 'capture')
|
|
298
|
+
onCaptured?.(artifactsRef.current);
|
|
299
|
+
}, [onCaptured, submitMode]);
|
|
226
300
|
const handleLivenessFailureExit = useCallback(() => {
|
|
227
301
|
onExitAfterLivenessFailure?.();
|
|
228
302
|
if (allowSignatureAfterLivenessCheckFailure)
|
|
@@ -232,11 +306,75 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
232
306
|
handleLivenessDone,
|
|
233
307
|
onExitAfterLivenessFailure,
|
|
234
308
|
]);
|
|
235
|
-
return (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
309
|
+
return (_jsxs(FlowChassis, { client: client, action: SubmissionAction.NONE, submission: submission, submitMode: submitMode, onSubmissionStarted: onSubmissionStarted, onSubmissionFailure: onSubmissionFailure, theme: theme, className: className, lang: lang, geolocationEnabled: geolocationEnabled, geolocationRequired: geolocationRequired, captureProgress: captureProgress, remoteDiagnostics: remoteDiagnostics, loadingSpinner: loadingSpinner, children: [_jsx(CaptureProgressCompletion, { completed: stage === 'complete' && submitMode === 'capture' }), stage === 'complete' && submitMode !== 'capture' ? (_jsx(SignatureHandoff, { artifacts: artifactsRef.current, claimStart: claimHandoffStart })) : null, stage !== 'complete' ? (_jsxs(HandoffRoot, { children: [_jsx(SignatureCaptureView, { ...signatureView, skipSuccessScreen: impliedSkipSuccessScreen(signatureView.skipSuccessScreen, isRingIntroActive(faceView)), controller: resolvedSignatureController, sessionReady: renderedStage === 'signature-capture', videoRef: sharedVideoRef, onVideoElementChange: setSharedVideoNode, forceCameraFeed: renderedStage === 'face-liveness', headTrackingSatisfied: headTrackingSatisfied, headTrackingStatus: headTrackingDisabled || !selfieState.models.ready
|
|
310
|
+
? 'off'
|
|
311
|
+
: selfieState.prediction === null
|
|
312
|
+
? 'pending'
|
|
313
|
+
: headTrackingSatisfied
|
|
314
|
+
? 'satisfied'
|
|
315
|
+
: 'unsatisfied', showFaceGuideThenSignaturePad: showFaceGuideThenSignaturePad, faceGuideStatus: faceGuideStatus, onCompleted: handleSignatureCompleted, onRestartRequested: hasPrecapturedSelfie ? undefined : handleInterruptedRestart }), hasPrecapturedSelfie && !headTrackingDisabled ? (_jsx(SelfieTrackerAttachment, { controller: resolvedSelfieController, video: sharedVideoNode })) : null, !hasPrecapturedSelfie ? (_jsx(FaceStage, { "$visible": renderedStage === 'face-liveness', children: skipLivenessValidation ? (_jsx(SelfieCaptureView, { ...faceView, onLoadingOverlayDismissed: handleFaceOverlayDismissed, autoContinueAfterLoading: impliedAutoContinueAfterLoading(faceView.autoContinueAfterLoading, isRingIntroActive(faceView)), controller: resolvedSelfieController, videoRef: sharedVideoRef, renderCameraFeed: false, renderFaceGuide: !legacyVideoLayout, allowManualSelfieCaptureOnLoadingError: allowManualSelfieCaptureOnLoadingError, onCaptured: handleLivenessDone })) : (_jsx(FaceLivenessView, { ...faceView, onLoadingOverlayDismissed: handleFaceOverlayDismissed, autoContinueAfterLoading: impliedAutoContinueAfterLoading(faceView.autoContinueAfterLoading, isRingIntroActive(faceView)), controller: resolvedSelfieController,
|
|
316
|
+
// Always: this stage is an overlay that must hand the shared
|
|
317
|
+
// camera straight back to the signature view, so there is no
|
|
318
|
+
// point in the wizard at which a review screen could render.
|
|
319
|
+
skipSuccessScreen: true, videoRef: sharedVideoRef, renderCameraFeed: false, renderFaceGuide: !legacyVideoLayout, allowManualSelfieCaptureOnLoadingError: allowManualSelfieCaptureOnLoadingError, onExitAfterFailure: handleLivenessFailureExit, onDone: handleLivenessDone })) })) : null, _jsx(FlowEdgeTint, { surface: edgeSurface, modelsReady: selfieState.models.ready })] })) : null] }));
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Hands the finished capture off once the session has passed: a finishing
|
|
323
|
+
* screen while the request is built, a retry screen if that fails, and
|
|
324
|
+
* nothing once it has been handed off.
|
|
325
|
+
*/
|
|
326
|
+
function SignatureHandoff({ artifacts, claimStart, }) {
|
|
327
|
+
const { action, submit, submissionStatus, submissionError } = useSubmission();
|
|
328
|
+
const sessionReady = useSessionReady();
|
|
329
|
+
// The provider reports a failure itself; these catches only keep the
|
|
330
|
+
// rejection from going unhandled.
|
|
331
|
+
useEffect(() => {
|
|
332
|
+
if (!sessionReady || !claimStart())
|
|
333
|
+
return;
|
|
334
|
+
submit(artifacts).catch(() => { });
|
|
335
|
+
}, [artifacts, claimStart, sessionReady, submit]);
|
|
336
|
+
if (submissionStatus === SubmissionStatus.SUBMITTED)
|
|
337
|
+
return null;
|
|
338
|
+
if (submissionStatus === SubmissionStatus.FAILED) {
|
|
339
|
+
return (_jsx(SubmissionErrorOverlay, { error: submissionError, onRetry: () => {
|
|
340
|
+
submit(artifacts).catch(() => { });
|
|
341
|
+
} }));
|
|
342
|
+
}
|
|
343
|
+
const text = submissionStatusText(action, artifacts);
|
|
344
|
+
return (_jsx(OrbStatusScreen, { state: "working", text: text, accessibleLabel: text, loadingStage: "submission" }));
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Black, so iOS Safari's bars read as letterboxing around the camera feed
|
|
348
|
+
* rather than as one more colour a theme has to choose.
|
|
349
|
+
*/
|
|
350
|
+
const CAMERA_EDGE_COLOR = '#000';
|
|
351
|
+
/**
|
|
352
|
+
* Tints iOS Safari's bars to whatever this flow has on screen — see
|
|
353
|
+
* `BrowserEdgeTint`. It follows every screen, not only the camera: Safari keeps
|
|
354
|
+
* the last strip colour when the strips leave while a full-viewport surface is
|
|
355
|
+
* still up, so dropping them after the camera would leave black bars over a
|
|
356
|
+
* light panel. Rendered under the flow's theme, which is where `isFullscreen`
|
|
357
|
+
* lives; an embedded flow leaves the host's chrome alone.
|
|
358
|
+
*
|
|
359
|
+
* The loading overlay ends in its progress row, part filled while it loads, so
|
|
360
|
+
* no flat strip can sit on its bottom edge unseen: that one is drawn invisibly,
|
|
361
|
+
* as on ID capture's overlay. Opaque, it covered the bottom 12px of the bar.
|
|
362
|
+
*/
|
|
363
|
+
function FlowEdgeTint({ surface, modelsReady, }) {
|
|
364
|
+
const theme = useTheme();
|
|
365
|
+
if (theme.isFullscreen === false || surface === null)
|
|
366
|
+
return null;
|
|
367
|
+
const color = opaqueColor(surface === 'camera'
|
|
368
|
+
? CAMERA_EDGE_COLOR
|
|
369
|
+
: surface === 'overlay'
|
|
370
|
+
? (theme.selfieCapture?.loadingOverlay?.backgroundColor ??
|
|
371
|
+
SELFIE_LOADING_OVERLAY_BACKGROUND_DEFAULT)
|
|
372
|
+
: (theme.background ?? '#fff'));
|
|
373
|
+
if (!color)
|
|
374
|
+
return null;
|
|
375
|
+
return (_jsx(BrowserEdgeTint, { color: color, hiddenBottomColor: surface === 'overlay'
|
|
376
|
+
? selfieLoadingOverlayBottomEdgeColor(theme, modelsReady)
|
|
377
|
+
: undefined }));
|
|
240
378
|
}
|
|
241
379
|
function SelfieTrackerAttachment({ controller, video, }) {
|
|
242
380
|
useEffect(() => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { SubmissionStatus, type IdmissionClient, type SubmissionCallbacks, type SubmissionAction, type SubmissionArtifacts, type SubmissionConfig, type SubmissionRequest, type SubmissionResponse, type SubmissionTimings } from '@idmission/websdk-core/client';
|
|
3
|
+
import type { SubmitMode } from './types';
|
|
3
4
|
export type { SubmissionCallbacks } from '@idmission/websdk-core/client';
|
|
4
5
|
export type SubmissionContextValue = {
|
|
5
6
|
action: SubmissionAction;
|
|
6
|
-
/** Resolves `null` when the
|
|
7
|
-
*
|
|
7
|
+
/** Resolves `null` when the request was handed off instead of posted:
|
|
8
|
+
* `submitMode: { handoff }`, or the client's deprecated `onSubmit`. */
|
|
8
9
|
submit: (artifacts: SubmissionArtifacts) => Promise<SubmissionResponse | null>;
|
|
9
10
|
submissionStatus: SubmissionStatus;
|
|
10
11
|
submissionResponse: SubmissionResponse | null;
|
|
@@ -19,6 +20,14 @@ export type SubmissionProviderProps = SubmissionCallbacks & {
|
|
|
19
20
|
client: IdmissionClient;
|
|
20
21
|
action: SubmissionAction;
|
|
21
22
|
options?: SubmissionConfig;
|
|
23
|
+
/**
|
|
24
|
+
* The flow's resolved `submitMode`. Unset keeps the legacy path: the
|
|
25
|
+
* client's `submit()`, with status read from the client. Set, every attempt
|
|
26
|
+
* goes through `post()` or `handoff()` and its status and diagnostics are
|
|
27
|
+
* this provider's own, never the client's. In `'capture'` mode nothing is
|
|
28
|
+
* submitted and the status stays `READY`.
|
|
29
|
+
*/
|
|
30
|
+
mode?: SubmitMode;
|
|
22
31
|
/**
|
|
23
32
|
* Position from the chassis's geolocation gate, folded into
|
|
24
33
|
* `artifacts.meta.geolocation` at submit time so core's existing path
|
|
@@ -29,6 +38,6 @@ export type SubmissionProviderProps = SubmissionCallbacks & {
|
|
|
29
38
|
geolocation?: GeolocationPosition | null;
|
|
30
39
|
children: ReactNode;
|
|
31
40
|
};
|
|
32
|
-
export declare function SubmissionProvider({ client, action, options, geolocation, children, onSubmissionStarted, onComplete, onApproved, onDenied, onRequestFailure, }: SubmissionProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare function SubmissionProvider({ client, action, options, geolocation, children, onSubmissionStarted, onComplete, onApproved, onDenied, onSubmissionFailure, onRequestFailure, mode, }: SubmissionProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
33
42
|
export declare function useSubmission(): SubmissionContextValue;
|
|
34
43
|
//# sourceMappingURL=SubmissionProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubmissionProvider.d.ts","sourceRoot":"","sources":["../../src/flows/SubmissionProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubmissionProvider.d.ts","sourceRoot":"","sources":["../../src/flows/SubmissionProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AAEd,OAAO,EACL,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAErB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAA;AAGtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGzC,YAAY,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,gBAAgB,CAAA;IACxB;2EACuE;IACvE,MAAM,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;IAC9E,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAA;IAC7C,eAAe,EAAE,KAAK,GAAG,IAAI,CAAA;IAC7B,qBAAqB,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC/C;iFAC6E;IAC7E,qBAAqB,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC/C,QAAQ,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAA;CACvC,CAAA;AAKD,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG;IAC1D,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,gBAAgB,CAAA;IACxB,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACxC,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,MAAM,EACN,OAAkC,EAClC,WAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,IAAI,GACL,EAAE,uBAAuB,2CA4NzB;AAkED,wBAAgB,aAAa,IAAI,sBAAsB,CAMtD"}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCaptureObserver } from './CaptureProgress';
|
|
3
|
+
import { bindSubmissionObserver } from '@idmission/websdk-core/captureProgress/internal';
|
|
4
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState, } from 'react';
|
|
5
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
6
|
import { SubmissionStatus, } from '@idmission/websdk-core/client';
|
|
4
7
|
import { useAuthState } from './AuthStateContext';
|
|
5
8
|
import { isApprovedResponse } from './approval';
|
|
9
|
+
import { warn } from '../utils/logger';
|
|
6
10
|
const SubmissionContext = createContext(null);
|
|
7
11
|
const EMPTY_SUBMISSION_OPTIONS = {};
|
|
8
|
-
export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_OPTIONS, geolocation = null, children, onSubmissionStarted, onComplete, onApproved, onDenied, onRequestFailure, }) {
|
|
12
|
+
export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_OPTIONS, geolocation = null, children, onSubmissionStarted, onComplete, onApproved, onDenied, onSubmissionFailure, onRequestFailure, mode, }) {
|
|
13
|
+
const progress = useCaptureObserver();
|
|
9
14
|
const clientState = useSyncExternalStore(client.subscribe, client.getState, client.getState);
|
|
10
15
|
const { state: authState } = useAuthState();
|
|
11
16
|
const [submissionResponse, setSubmissionResponse] = useState(null);
|
|
12
17
|
const [localError, setLocalError] = useState(null);
|
|
18
|
+
const [attempt, setAttempt] = useState(IDLE_ATTEMPT);
|
|
19
|
+
// Which path the latest submission took. State is read from that path even
|
|
20
|
+
// if `mode` changes while it is in flight; before any submission, `mode`
|
|
21
|
+
// decides.
|
|
22
|
+
const [startedExplicit, setStartedExplicit] = useState(null);
|
|
23
|
+
const reportFailure = onSubmissionFailure ?? onRequestFailure;
|
|
13
24
|
const [resubmitting, setResubmitting] = useState(false);
|
|
14
25
|
const lastArtifactsRef = useRef(null);
|
|
15
26
|
const submitInFlightRef = useRef(null);
|
|
@@ -26,9 +37,54 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
26
37
|
: incoming;
|
|
27
38
|
// Store the merged artifacts so a resubmit carries location too.
|
|
28
39
|
lastArtifactsRef.current = artifacts;
|
|
40
|
+
setStartedExplicit(mode !== undefined);
|
|
41
|
+
if (mode !== undefined) {
|
|
42
|
+
// Registered before anything customer-supplied runs, so a throw from
|
|
43
|
+
// a notification can never leave the flow without a status.
|
|
44
|
+
setAttempt({ ...IDLE_ATTEMPT, status: SubmissionStatus.SUBMITTING });
|
|
45
|
+
const unbindProgress = bindSubmissionObserver(artifacts, progress);
|
|
46
|
+
// The client call waits one microtask so the in-flight promise is
|
|
47
|
+
// registered first: an `onSubmissionStarted` that calls `submit()`
|
|
48
|
+
// gets this attempt back instead of starting a second one.
|
|
49
|
+
const promise = Promise.resolve()
|
|
50
|
+
.then(() => runAttempt(client, mode, artifacts, { ...options, action }))
|
|
51
|
+
.then((outcome) => {
|
|
52
|
+
setAttempt({ ...outcome, status: SubmissionStatus.SUBMITTED, error: null });
|
|
53
|
+
const { response, request } = outcome;
|
|
54
|
+
if (response === null) {
|
|
55
|
+
// Terminal once called; the handler is never awaited.
|
|
56
|
+
if (typeof mode === 'object') {
|
|
57
|
+
notifySafely('submitMode.handoff', () => mode.handoff(request));
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
notifySafely('onComplete', () => onComplete?.(response));
|
|
62
|
+
if (isApprovedResponse(action, response)) {
|
|
63
|
+
notifySafely('onApproved', () => onApproved?.(response));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
notifySafely('onDenied', () => onDenied?.(response));
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
}, (cause) => {
|
|
70
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
71
|
+
setAttempt({ ...IDLE_ATTEMPT, status: SubmissionStatus.FAILED, error });
|
|
72
|
+
notifySafely('onSubmissionFailure', () => reportFailure?.(error));
|
|
73
|
+
throw error;
|
|
74
|
+
})
|
|
75
|
+
.finally(() => {
|
|
76
|
+
unbindProgress();
|
|
77
|
+
submitInFlightRef.current = null;
|
|
78
|
+
setResubmitting(false);
|
|
79
|
+
});
|
|
80
|
+
submitInFlightRef.current = promise;
|
|
81
|
+
notifySafely('onSubmissionStarted', () => onSubmissionStarted?.(artifacts));
|
|
82
|
+
return promise;
|
|
83
|
+
}
|
|
29
84
|
setSubmissionResponse(null);
|
|
30
85
|
setLocalError(null);
|
|
31
86
|
onSubmissionStarted?.(artifacts);
|
|
87
|
+
const unbindProgress = bindSubmissionObserver(artifacts, progress);
|
|
32
88
|
const promise = client
|
|
33
89
|
.submit(artifacts, { ...options, action })
|
|
34
90
|
.then((response) => {
|
|
@@ -50,10 +106,11 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
50
106
|
.catch((cause) => {
|
|
51
107
|
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
52
108
|
setLocalError(error);
|
|
53
|
-
|
|
109
|
+
reportFailure?.(error);
|
|
54
110
|
throw error;
|
|
55
111
|
})
|
|
56
112
|
.finally(() => {
|
|
113
|
+
unbindProgress();
|
|
57
114
|
submitInFlightRef.current = null;
|
|
58
115
|
setResubmitting(false);
|
|
59
116
|
});
|
|
@@ -66,9 +123,11 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
66
123
|
onApproved,
|
|
67
124
|
onComplete,
|
|
68
125
|
onDenied,
|
|
69
|
-
|
|
126
|
+
reportFailure,
|
|
70
127
|
onSubmissionStarted,
|
|
71
128
|
options,
|
|
129
|
+
progress,
|
|
130
|
+
mode,
|
|
72
131
|
]);
|
|
73
132
|
const resubmit = useMemo(() => {
|
|
74
133
|
if (!authState.session.canRefreshSession)
|
|
@@ -100,31 +159,98 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
100
159
|
return promise;
|
|
101
160
|
};
|
|
102
161
|
}, [authState.session.canRefreshSession, client, submit]);
|
|
103
|
-
const value = useMemo(() =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
162
|
+
const value = useMemo(() => {
|
|
163
|
+
if (startedExplicit ?? mode !== undefined) {
|
|
164
|
+
return {
|
|
165
|
+
action,
|
|
166
|
+
submit,
|
|
167
|
+
submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : attempt.status,
|
|
168
|
+
submissionResponse: attempt.response,
|
|
169
|
+
submissionError: attempt.error,
|
|
170
|
+
lastSubmissionTimings: attempt.timings,
|
|
171
|
+
lastSubmissionRequest: attempt.request,
|
|
172
|
+
resubmit,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
action,
|
|
177
|
+
submit,
|
|
178
|
+
// A rejection before the client records anything (an unsupported
|
|
179
|
+
// action, an unvalidated session) leaves the client at READY, which the
|
|
180
|
+
// wizard renders as its submitting screen; the local error is the
|
|
181
|
+
// failure it would otherwise never show.
|
|
182
|
+
submissionStatus: resubmitting
|
|
183
|
+
? SubmissionStatus.SUBMITTING
|
|
184
|
+
: localError && clientState.submissionStatus === SubmissionStatus.READY
|
|
185
|
+
? SubmissionStatus.FAILED
|
|
186
|
+
: clientState.submissionStatus,
|
|
187
|
+
submissionResponse,
|
|
188
|
+
submissionError: localError ?? clientState.submissionError ?? null,
|
|
189
|
+
lastSubmissionTimings: clientState.lastSubmissionTimings ?? null,
|
|
190
|
+
lastSubmissionRequest: clientState.lastSubmissionRequest ?? null,
|
|
191
|
+
resubmit,
|
|
192
|
+
};
|
|
193
|
+
}, [
|
|
115
194
|
action,
|
|
195
|
+
attempt,
|
|
116
196
|
clientState.lastSubmissionRequest,
|
|
117
197
|
clientState.lastSubmissionTimings,
|
|
118
198
|
clientState.submissionError,
|
|
119
199
|
clientState.submissionStatus,
|
|
120
200
|
localError,
|
|
201
|
+
mode,
|
|
121
202
|
resubmit,
|
|
122
203
|
resubmitting,
|
|
204
|
+
startedExplicit,
|
|
123
205
|
submissionResponse,
|
|
124
206
|
submit,
|
|
125
207
|
]);
|
|
126
208
|
return (_jsx(SubmissionContext.Provider, { value: value, children: children }));
|
|
127
209
|
}
|
|
210
|
+
const IDLE_ATTEMPT = {
|
|
211
|
+
status: SubmissionStatus.READY,
|
|
212
|
+
response: null,
|
|
213
|
+
request: null,
|
|
214
|
+
timings: null,
|
|
215
|
+
error: null,
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* One explicit-mode attempt through the client's `post()` or `handoff()`.
|
|
219
|
+
* Never falls back to `submit()`: that would let the deprecated
|
|
220
|
+
* `config.onSubmit` decide what an explicit mode already decided.
|
|
221
|
+
*/
|
|
222
|
+
async function runAttempt(client, mode, artifacts, options) {
|
|
223
|
+
if (mode === 'capture') {
|
|
224
|
+
throw new Error("submitMode 'capture' does not submit; the flow reports onCaptured instead");
|
|
225
|
+
}
|
|
226
|
+
if (mode === 'post') {
|
|
227
|
+
if (!client.post)
|
|
228
|
+
throw missingMethod('post', "submitMode 'post'");
|
|
229
|
+
return client.post(artifacts, options);
|
|
230
|
+
}
|
|
231
|
+
if (!client.handoff)
|
|
232
|
+
throw missingMethod('handoff', 'submitMode { handoff }');
|
|
233
|
+
const { request, timings } = await client.handoff(artifacts, options);
|
|
234
|
+
return { request, timings, response: null };
|
|
235
|
+
}
|
|
236
|
+
function missingMethod(method, needs) {
|
|
237
|
+
return new Error(`${needs} needs client.${method}(), which this client does not have. ` +
|
|
238
|
+
'Create the client with createIdmissionClient or useIdmissionClient.');
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Runs a customer callback whose failure must not change an outcome that is
|
|
242
|
+
* already settled: a throw or a rejected promise is logged, never rethrown.
|
|
243
|
+
*/
|
|
244
|
+
function notifySafely(name, notify) {
|
|
245
|
+
try {
|
|
246
|
+
// `Promise.resolve`, not `instanceof Promise`: a promise from another
|
|
247
|
+
// realm (an iframe) fails that check, and its rejection would go unhandled.
|
|
248
|
+
Promise.resolve(notify()).catch((e) => warn(`${name} rejected`, e));
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
warn(`${name} threw`, e);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
128
254
|
export function useSubmission() {
|
|
129
255
|
const context = useContext(SubmissionContext);
|
|
130
256
|
if (!context) {
|