@idmission/websdk-ui 0.5.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 +41 -3
- package/dist/flows/CompositeWizard.d.ts +7 -1
- package/dist/flows/CompositeWizard.d.ts.map +1 -1
- package/dist/flows/CompositeWizard.js +2 -2
- package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts +3 -3
- package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts.map +1 -1
- package/dist/flows/CustomerBiometricsEnrollmentFlow.js +21 -2
- package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts +3 -3
- package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts.map +1 -1
- package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.js +41 -8
- 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 +17 -1
- package/dist/flows/FlowChassis.d.ts.map +1 -1
- package/dist/flows/FlowChassis.js +22 -5
- package/dist/flows/IdAndFaceValidationFlow.d.ts +3 -3
- package/dist/flows/IdAndFaceValidationFlow.d.ts.map +1 -1
- package/dist/flows/IdAndFaceValidationFlow.js +29 -2
- package/dist/flows/IdValidationFlow.d.ts +10 -5
- package/dist/flows/IdValidationFlow.d.ts.map +1 -1
- package/dist/flows/IdValidationFlow.js +15 -2
- package/dist/flows/SignatureKYCFlow.d.ts +27 -6
- package/dist/flows/SignatureKYCFlow.d.ts.map +1 -1
- package/dist/flows/SignatureKYCFlow.js +62 -7
- package/dist/flows/SubmissionProvider.d.ts +12 -3
- package/dist/flows/SubmissionProvider.d.ts.map +1 -1
- package/dist/flows/SubmissionProvider.js +134 -15
- package/dist/flows/VideoIdValidationFlow.d.ts +3 -5
- package/dist/flows/VideoIdValidationFlow.d.ts.map +1 -1
- package/dist/flows/VideoIdValidationFlow.js +33 -2
- 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 +14 -8
- 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/signatureStep.d.ts +6 -1
- package/dist/flows/signatureStep.d.ts.map +1 -1
- package/dist/flows/types.d.ts +103 -7
- 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/i18n/index.d.ts +5 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +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/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- 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 +4 -4
- package/dist/flows/autoCaptureMountGuard.d.ts +0 -22
- package/dist/flows/autoCaptureMountGuard.d.ts.map +0 -1
- package/dist/flows/autoCaptureMountGuard.js +0 -61
|
@@ -15,6 +15,8 @@ import { buildAdditionalDocumentsStep } from './additionalDocuments';
|
|
|
15
15
|
import { buildSelfieArtifacts } from './artifacts';
|
|
16
16
|
import { FlowChassis } from './FlowChassis';
|
|
17
17
|
import { useLatestCallbacks } from './latestCallbacks';
|
|
18
|
+
import { FLOW_MOUNT_ONLY_REMEDY, useMountOnlyWarnings } from '../utils/mountOnly';
|
|
19
|
+
import { inheritFlowSettings } from './flowSettings';
|
|
18
20
|
import { buildRingScreenProps } from './ringScreens';
|
|
19
21
|
const EMPTY_ID_CAPTURE = {};
|
|
20
22
|
const EMPTY_FACE_CAPTURE = {};
|
|
@@ -23,8 +25,33 @@ const EMPTY_ID_VIEW = {};
|
|
|
23
25
|
const EMPTY_FACE_VIEW = {};
|
|
24
26
|
const EMPTY_SUBMISSION = {};
|
|
25
27
|
const EMPTY_ARTIFACTS = {};
|
|
26
|
-
export function IdAndFaceValidationFlow({ client, idController, selfieController, signatureController, idCapture = EMPTY_ID_CAPTURE, faceCapture = EMPTY_FACE_CAPTURE, signatureCapture = EMPTY_SIGNATURE_CAPTURE, idView = EMPTY_ID_VIEW, faceView = EMPTY_FACE_VIEW, signatureView, captureSignature, captureSignatureVideo, allowVirtualCameras, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, theme, className,
|
|
28
|
+
export function IdAndFaceValidationFlow({ client, idController, selfieController, signatureController, idCapture = EMPTY_ID_CAPTURE, faceCapture = EMPTY_FACE_CAPTURE, signatureCapture = EMPTY_SIGNATURE_CAPTURE, idView: idViewProp = EMPTY_ID_VIEW, faceView: faceViewProp = EMPTY_FACE_VIEW, signatureView: signatureViewProp, captureSignature, captureSignatureVideo, allowVirtualCameras, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, theme, className, lang, debugMode, skipSuccessScreen, showResultScreen, showSuccessScreen, showDiagnostics = false, captureAdditionalDocuments, additionalDocumentClassNames, additionalDocumentVerbiage, ringScreenClassNames, ringScreenVerbiage, onSubmitted, onCaptureError, onStepStarted, onStepCompleted, children, ...callbacks }) {
|
|
29
|
+
// Flow-wide settings reach each step unless its own bag sets them.
|
|
30
|
+
const { idView, faceView, signatureView } = useMemo(() => {
|
|
31
|
+
const settings = { lang, debugMode, skipSuccessScreen };
|
|
32
|
+
return {
|
|
33
|
+
idView: inheritFlowSettings(idViewProp, settings),
|
|
34
|
+
faceView: inheritFlowSettings(faceViewProp, settings),
|
|
35
|
+
signatureView: inheritFlowSettings(signatureViewProp, {
|
|
36
|
+
lang,
|
|
37
|
+
showCaptureDiagnostics: debugMode,
|
|
38
|
+
skipSuccessScreen,
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}, [
|
|
42
|
+
debugMode,
|
|
43
|
+
faceViewProp,
|
|
44
|
+
idViewProp,
|
|
45
|
+
lang,
|
|
46
|
+
signatureViewProp,
|
|
47
|
+
skipSuccessScreen,
|
|
48
|
+
]);
|
|
27
49
|
const { checkLivenessOptions, ...selfieCaptureConfig } = faceCapture;
|
|
50
|
+
useMountOnlyWarnings('IdAndFaceValidationFlow', FLOW_MOUNT_ONLY_REMEDY, {
|
|
51
|
+
faceCapture: selfieCaptureConfig,
|
|
52
|
+
idCapture,
|
|
53
|
+
signatureCapture,
|
|
54
|
+
});
|
|
28
55
|
// Config callbacks follow the latest render; see useLatestCallbacks.
|
|
29
56
|
const latestSelfieCapture = useLatestCallbacks(selfieCaptureConfig);
|
|
30
57
|
const latestSelfieLiveness = useLatestCallbacks(selfieCaptureConfig.liveness);
|
|
@@ -173,5 +200,5 @@ export function IdAndFaceValidationFlow({ client, idController, selfieController
|
|
|
173
200
|
finishingVerbiage: { finishingStage1Text: 'Uploading your captures', finishingStage2Text: 'Confirming your identity data' },
|
|
174
201
|
successVerbiage: { successTitleText: 'Identity verified! 🎉', successSubtitleText: '', successIssuerValueText: 'Identity data', successIssuerCaptionText: 'confirmed' },
|
|
175
202
|
});
|
|
176
|
-
return (_jsxs(FlowChassis, { client: client, action: SubmissionAction.VALIDATE, submission: submission, theme: theme, className: className, ...callbacks, children: [_jsx(CompositeWizard, { ...ringScreens, steps: steps, initialArtifacts: initialArtifacts,
|
|
203
|
+
return (_jsxs(FlowChassis, { client: client, action: SubmissionAction.VALIDATE, submission: submission, theme: theme, className: className, lang: lang, ...callbacks, children: [_jsx(CompositeWizard, { ...ringScreens, steps: steps, initialArtifacts: initialArtifacts, showResultScreen: showResultScreen ?? showSuccessScreen, showDiagnostics: showDiagnostics, onSubmitted: onSubmitted, onStepStarted: onStepStarted, onStepCompleted: onStepCompleted }), children] }));
|
|
177
204
|
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { type IdCaptureController } from '@idmission/websdk-core/idCapture';
|
|
2
2
|
import { type SignatureCaptureController, type SignatureCaptureControllerConfig } from '@idmission/websdk-core/signatureCapture';
|
|
3
|
+
import type { SkipSuccessScreen } from './useShowSuccessScreen';
|
|
3
4
|
import { type SignatureFlowViewProps, type SignatureStageDecision } from './signatureStep';
|
|
4
|
-
import type { CommonFlowProps, IdCaptureFlowConfig, IdCaptureFlowViewProps } from './types';
|
|
5
|
-
export type IdValidationFlowProps = CommonFlowProps & {
|
|
5
|
+
import type { CaptureOnlyProps, CommonFlowProps, SubmitMode, SubmitModeProps, IdCaptureFlowConfig, IdCaptureFlowViewProps } from './types';
|
|
6
|
+
export type IdValidationFlowProps = SubmitModeProps<SubmitMode> & CaptureOnlyProps & Omit<CommonFlowProps, 'skipSuccessScreen'> & {
|
|
7
|
+
/**
|
|
8
|
+
* Skip the review screens of the ID step and the signature step. Both take
|
|
9
|
+
* the async form, so this does too. A step bag's `skipSuccessScreen`
|
|
10
|
+
* overrides it for that step.
|
|
11
|
+
*/
|
|
12
|
+
skipSuccessScreen?: SkipSuccessScreen;
|
|
6
13
|
controller?: IdCaptureController;
|
|
7
14
|
/**
|
|
8
15
|
* Controller configuration. Read ONCE, when the flow builds its controller:
|
|
@@ -12,8 +19,6 @@ export type IdValidationFlowProps = CommonFlowProps & {
|
|
|
12
19
|
*/
|
|
13
20
|
capture?: IdCaptureFlowConfig;
|
|
14
21
|
view?: IdCaptureFlowViewProps;
|
|
15
|
-
captureOnly?: boolean;
|
|
16
|
-
onCaptured?: CommonFlowProps['onSubmissionStarted'];
|
|
17
22
|
signatureController?: SignatureCaptureController;
|
|
18
23
|
/**
|
|
19
24
|
* Controller configuration. Read ONCE, when the flow builds its controller:
|
|
@@ -37,5 +42,5 @@ export type IdValidationFlowProps = CommonFlowProps & {
|
|
|
37
42
|
/** Passed to both camera acquisitions; defaults to false in core. */
|
|
38
43
|
allowVirtualCameras?: boolean;
|
|
39
44
|
};
|
|
40
|
-
export declare function IdValidationFlow({ client, controller, capture, view, submission, initialArtifacts, captureOnly, signatureController, signatureCapture, signatureView, captureSignature, captureSignatureVideo, allowVirtualCameras, theme, className, showSuccessScreen, showDiagnostics, captureAdditionalDocuments, additionalDocumentClassNames, additionalDocumentVerbiage, ringScreenClassNames, ringScreenVerbiage, onCaptured, onSubmitted, children, ...callbacks }: IdValidationFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare function IdValidationFlow({ client, controller, capture, view: viewProp, submission, initialArtifacts, submitMode, captureOnly, signatureController, signatureCapture, signatureView: signatureViewProp, captureSignature, captureSignatureVideo, allowVirtualCameras, theme, className, lang, debugMode, skipSuccessScreen, showResultScreen, showSuccessScreen, showDiagnostics, captureAdditionalDocuments, additionalDocumentClassNames, additionalDocumentVerbiage, ringScreenClassNames, ringScreenVerbiage, onCaptured, onSubmitted, children, ...callbacks }: IdValidationFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
41
46
|
//# sourceMappingURL=IdValidationFlow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdValidationFlow.d.ts","sourceRoot":"","sources":["../../src/flows/IdValidationFlow.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK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QD,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,UAAU,EACV,OAA0B,EAC1B,IAAI,EAAE,QAAwB,EAC9B,UAA6B,EAC7B,gBAAkC,EAClC,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,gBAA0C,EAC1C,aAAa,EAAE,iBAAiB,EAChC,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,EACL,SAAS,EACT,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,eAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,qBAAqB,2CAoLvB"}
|
|
@@ -9,6 +9,8 @@ import { impliedAutoContinueAfterLoading, impliedSkipSuccessScreen, isRingIntroA
|
|
|
9
9
|
import { CompositeWizard, } from './CompositeWizard';
|
|
10
10
|
import { FlowChassis } from './FlowChassis';
|
|
11
11
|
import { useLatestCallbacks } from './latestCallbacks';
|
|
12
|
+
import { FLOW_MOUNT_ONLY_REMEDY, useMountOnlyWarnings } from '../utils/mountOnly';
|
|
13
|
+
import { inheritFlowSettings } from './flowSettings';
|
|
12
14
|
import { buildRingScreenProps } from './ringScreens';
|
|
13
15
|
import { buildAdditionalDocumentsStep } from './additionalDocuments';
|
|
14
16
|
import { createSharedCameraAcquirer, withVirtualCameras, } from './sharedCamera';
|
|
@@ -18,7 +20,17 @@ const EMPTY_SIGNATURE_CAPTURE = {};
|
|
|
18
20
|
const EMPTY_ID_VIEW = {};
|
|
19
21
|
const EMPTY_SUBMISSION = {};
|
|
20
22
|
const EMPTY_ARTIFACTS = {};
|
|
21
|
-
export function IdValidationFlow({ client, controller, capture = EMPTY_ID_CAPTURE, view = EMPTY_ID_VIEW, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, captureOnly
|
|
23
|
+
export function IdValidationFlow({ client, controller, capture = EMPTY_ID_CAPTURE, view: viewProp = EMPTY_ID_VIEW, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, submitMode, captureOnly, signatureController, signatureCapture = EMPTY_SIGNATURE_CAPTURE, signatureView: signatureViewProp, captureSignature, captureSignatureVideo, allowVirtualCameras, theme, className, lang, debugMode, skipSuccessScreen, showResultScreen, showSuccessScreen, showDiagnostics = false, captureAdditionalDocuments, additionalDocumentClassNames, additionalDocumentVerbiage, ringScreenClassNames, ringScreenVerbiage, onCaptured, onSubmitted, children, ...callbacks }) {
|
|
24
|
+
// Flow-wide settings reach each step unless its own bag sets them.
|
|
25
|
+
const { view, signatureView } = useMemo(() => ({
|
|
26
|
+
view: inheritFlowSettings(viewProp, { lang, debugMode, skipSuccessScreen }),
|
|
27
|
+
signatureView: inheritFlowSettings(signatureViewProp, {
|
|
28
|
+
lang,
|
|
29
|
+
showCaptureDiagnostics: debugMode,
|
|
30
|
+
skipSuccessScreen,
|
|
31
|
+
}),
|
|
32
|
+
}), [debugMode, lang, signatureViewProp, skipSuccessScreen, viewProp]);
|
|
33
|
+
useMountOnlyWarnings('IdValidationFlow', FLOW_MOUNT_ONLY_REMEDY, { capture, signatureCapture });
|
|
22
34
|
// Config callbacks follow the latest render; see useLatestCallbacks.
|
|
23
35
|
const latestCapture = useLatestCallbacks(capture);
|
|
24
36
|
const latestSignatureCapture = useLatestCallbacks(signatureCapture);
|
|
@@ -120,5 +132,6 @@ export function IdValidationFlow({ client, controller, capture = EMPTY_ID_CAPTUR
|
|
|
120
132
|
finishingVerbiage: { finishingStage1Text: 'Uploading your ID', finishingStage2Text: 'Confirming your identity data', finishingStage3Text: '' },
|
|
121
133
|
successVerbiage: { successTitleText: 'ID verified! 🎉', successSubtitleText: '', successIssuerValueText: 'Identity data', successIssuerCaptionText: 'confirmed' },
|
|
122
134
|
});
|
|
123
|
-
|
|
135
|
+
const mode = submitMode ?? (captureOnly ? 'capture' : undefined);
|
|
136
|
+
return (_jsxs(FlowChassis, { client: client, action: SubmissionAction.VALIDATE, submission: submission, submitMode: mode, theme: theme, className: className, lang: lang, ...callbacks, children: [_jsx(CompositeWizard, { ...ringScreens, steps: steps, initialArtifacts: initialArtifacts, captureOnly: mode === 'capture', showResultScreen: showResultScreen ?? showSuccessScreen, showDiagnostics: showDiagnostics, onArtifactsCollected: onCaptured, onSubmitted: onSubmitted }), children] }));
|
|
124
137
|
}
|
|
@@ -3,8 +3,21 @@ import { type SelfieCaptureController, type SelfieCaptureThresholds, type Selfie
|
|
|
3
3
|
import { type SignatureCaptureController, type SignatureCaptureControllerConfig } from '@idmission/websdk-core/signatureCapture';
|
|
4
4
|
import { type SelfieCaptureViewClassNames } from '../SelfieCaptureView';
|
|
5
5
|
import { type SignatureCaptureViewProps } from '../SignatureCaptureView';
|
|
6
|
-
import type {
|
|
7
|
-
|
|
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'>;
|
|
8
21
|
selfieController?: SelfieCaptureController;
|
|
9
22
|
signatureController?: SignatureCaptureController;
|
|
10
23
|
/**
|
|
@@ -29,7 +42,7 @@ export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallba
|
|
|
29
42
|
faceView?: FaceLivenessFlowViewProps & {
|
|
30
43
|
classNames?: Pick<SelfieCaptureViewClassNames, 'fallback'>;
|
|
31
44
|
};
|
|
32
|
-
signatureView?:
|
|
45
|
+
signatureView?: SignatureFlowViewProps;
|
|
33
46
|
/** One-prop challenge-response opt-in for the liveness step. */
|
|
34
47
|
challengeResponse?: NonNullable<SelfieLivenessConfig['challenge']>;
|
|
35
48
|
/** Passed to both camera acquisitions; defaults to false in core. */
|
|
@@ -51,9 +64,17 @@ export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallba
|
|
|
51
64
|
/** Lets the user continue to signature capture from the liveness failure screen. */
|
|
52
65
|
allowSignatureAfterLivenessCheckFailure?: boolean;
|
|
53
66
|
showFaceGuideThenSignaturePad?: boolean;
|
|
54
|
-
/**
|
|
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
|
+
*/
|
|
55
73
|
skipSuccessScreen?: SignatureCaptureViewProps['skipSuccessScreen'];
|
|
56
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Receives the combined selfie and signature artifacts without a network
|
|
76
|
+
* submission. Fires only in `'capture'` mode.
|
|
77
|
+
*/
|
|
57
78
|
onCaptured?: (artifacts: SubmissionArtifacts) => void;
|
|
58
79
|
onCaptureError?: (error: Error) => void;
|
|
59
80
|
};
|
|
@@ -75,5 +96,5 @@ export type SignatureKYCFlowProps = Omit<CommonFlowProps, keyof FlowResultCallba
|
|
|
75
96
|
* `thresholds` outrank both.
|
|
76
97
|
*/
|
|
77
98
|
export declare function faceThresholdsForLayout(legacyVideoLayout: boolean, thresholds: SelfieCaptureThresholds | undefined): SelfieCaptureThresholds | undefined;
|
|
78
|
-
export declare function SignatureKYCFlow({ client, selfieController, signatureController, faceCapture, signatureCapture, faceView, signatureView, challengeResponse, allowVirtualCameras, allowHigherCameraResolutions, skipLivenessValidation, allowManualSelfieCaptureOnLoadingError, headTrackingDisabled, headTrackingBoundaryPercentage, headTrackingBoundaryType, allowSignatureAfterLivenessCheckFailure, showFaceGuideThenSignaturePad, skipSuccessScreen, submission, initialArtifacts, theme, className, geolocationEnabled, geolocationRequired, captureProgress, 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;
|
|
79
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/SignatureKYC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AC/C,6BAAqC,EACrC,iBAAiB,EACjB,UAA6B,EAC7B,gBAAkC,EAClC,KAAK,EACL,SAAS,EACT,IAAI,EACJ,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,UAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,cAAc,GACf,EAAE,qBAAqB,2CAqavB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
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';
|
|
@@ -13,10 +13,17 @@ import { BrowserEdgeTint, opaqueColor } from '../components/common/BrowserEdgeTi
|
|
|
13
13
|
import { SELFIE_LOADING_OVERLAY_BACKGROUND_DEFAULT, selfieLoadingOverlayBottomEdgeColor, } from '../components/selfie_loading/SelfieCaptureLoadingOverlayDefault';
|
|
14
14
|
import { impliedAutoContinueAfterLoading, impliedSkipSuccessScreen, isRingIntroActive, } from './ringIntroImplications';
|
|
15
15
|
import { SignatureCaptureView, } from '../SignatureCaptureView';
|
|
16
|
+
import { inheritFlowSettings } from './flowSettings';
|
|
16
17
|
import { buildSelfieArtifacts, mergeSubmissionArtifacts } from './artifacts';
|
|
17
18
|
import { FlowChassis } from './FlowChassis';
|
|
18
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';
|
|
19
25
|
import { useLatestCallbacks } from './latestCallbacks';
|
|
26
|
+
import { FLOW_MOUNT_ONLY_REMEDY, useMountOnlyWarnings } from '../utils/mountOnly';
|
|
20
27
|
import { createSharedCameraAcquirer, withVirtualCameras, } from './sharedCamera';
|
|
21
28
|
/**
|
|
22
29
|
* Face-tracking thresholds the face stage runs under, given the layout its
|
|
@@ -53,13 +60,26 @@ const EMPTY_FACE_VIEW = {};
|
|
|
53
60
|
const EMPTY_SIGNATURE_VIEW = {};
|
|
54
61
|
const EMPTY_SUBMISSION = {};
|
|
55
62
|
const EMPTY_ARTIFACTS = {};
|
|
56
|
-
export function SignatureKYCFlow({ client, selfieController, signatureController, faceCapture = EMPTY_FACE_CAPTURE, signatureCapture = EMPTY_SIGNATURE_CAPTURE, faceView = EMPTY_FACE_VIEW, signatureView = 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, geolocationEnabled, geolocationRequired, captureProgress, 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]);
|
|
57
73
|
const { checkLivenessOptions, ...selfieCaptureConfig } = faceCapture;
|
|
74
|
+
useMountOnlyWarnings('SignatureKYCFlow', FLOW_MOUNT_ONLY_REMEDY, {
|
|
75
|
+
faceCapture: selfieCaptureConfig,
|
|
76
|
+
signatureCapture,
|
|
77
|
+
});
|
|
58
78
|
// Config callbacks follow the latest render; see useLatestCallbacks.
|
|
59
79
|
const latestSelfieCapture = useLatestCallbacks(selfieCaptureConfig);
|
|
60
80
|
const latestSelfieLiveness = useLatestCallbacks(selfieCaptureConfig.liveness);
|
|
61
81
|
const latestSignatureCapture = useLatestCallbacks(signatureCapture);
|
|
62
|
-
const legacyVideoLayout = signatureView
|
|
82
|
+
const legacyVideoLayout = signatureView.legacyVideoLayout ?? false;
|
|
63
83
|
const onExitAfterLivenessFailure = faceView.onExitAfterFailure;
|
|
64
84
|
const sharedVideoRef = useRef(null);
|
|
65
85
|
const [sharedVideoNode, setSharedVideoNode] = useState(null);
|
|
@@ -259,14 +279,24 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
259
279
|
resolvedSelfieController.actions.retry();
|
|
260
280
|
setStage('face-liveness');
|
|
261
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
|
+
}, []);
|
|
262
291
|
const handleSignatureCompleted = useCallback((artifacts) => {
|
|
263
292
|
if (completedRef.current)
|
|
264
293
|
return;
|
|
265
294
|
completedRef.current = true;
|
|
266
295
|
artifactsRef.current = mergeSubmissionArtifacts(artifactsRef.current, artifacts);
|
|
267
296
|
setStage('complete');
|
|
268
|
-
|
|
269
|
-
|
|
297
|
+
if (submitMode === 'capture')
|
|
298
|
+
onCaptured?.(artifactsRef.current);
|
|
299
|
+
}, [onCaptured, submitMode]);
|
|
270
300
|
const handleLivenessFailureExit = useCallback(() => {
|
|
271
301
|
onExitAfterLivenessFailure?.();
|
|
272
302
|
if (allowSignatureAfterLivenessCheckFailure)
|
|
@@ -276,7 +306,7 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
276
306
|
handleLivenessDone,
|
|
277
307
|
onExitAfterLivenessFailure,
|
|
278
308
|
]);
|
|
279
|
-
return (_jsxs(FlowChassis, { client: client, action: SubmissionAction.NONE, submission: submission, theme: theme, className: className, geolocationEnabled: geolocationEnabled, geolocationRequired: geolocationRequired, captureProgress: captureProgress, remoteDiagnostics: remoteDiagnostics, loadingSpinner: loadingSpinner, children: [_jsx(CaptureProgressCompletion, { completed: stage === 'complete' }), stage !== 'complete' ? (_jsxs(HandoffRoot, { children: [_jsx(SignatureCaptureView, { ...signatureView, skipSuccessScreen: impliedSkipSuccessScreen(
|
|
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
|
|
280
310
|
? 'off'
|
|
281
311
|
: selfieState.prediction === null
|
|
282
312
|
? 'pending'
|
|
@@ -288,6 +318,31 @@ export function SignatureKYCFlow({ client, selfieController, signatureController
|
|
|
288
318
|
// point in the wizard at which a review screen could render.
|
|
289
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] }));
|
|
290
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
|
+
}
|
|
291
346
|
/**
|
|
292
347
|
* Black, so iOS Safari's bars read as letterboxing around the camera feed
|
|
293
348
|
* rather than as one more colour a theme has to choose.
|
|
@@ -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":"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,
|
|
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"}
|
|
@@ -6,14 +6,21 @@ import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
|
6
6
|
import { SubmissionStatus, } from '@idmission/websdk-core/client';
|
|
7
7
|
import { useAuthState } from './AuthStateContext';
|
|
8
8
|
import { isApprovedResponse } from './approval';
|
|
9
|
+
import { warn } from '../utils/logger';
|
|
9
10
|
const SubmissionContext = createContext(null);
|
|
10
11
|
const EMPTY_SUBMISSION_OPTIONS = {};
|
|
11
|
-
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, }) {
|
|
12
13
|
const progress = useCaptureObserver();
|
|
13
14
|
const clientState = useSyncExternalStore(client.subscribe, client.getState, client.getState);
|
|
14
15
|
const { state: authState } = useAuthState();
|
|
15
16
|
const [submissionResponse, setSubmissionResponse] = useState(null);
|
|
16
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;
|
|
17
24
|
const [resubmitting, setResubmitting] = useState(false);
|
|
18
25
|
const lastArtifactsRef = useRef(null);
|
|
19
26
|
const submitInFlightRef = useRef(null);
|
|
@@ -30,6 +37,50 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
30
37
|
: incoming;
|
|
31
38
|
// Store the merged artifacts so a resubmit carries location too.
|
|
32
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
|
+
}
|
|
33
84
|
setSubmissionResponse(null);
|
|
34
85
|
setLocalError(null);
|
|
35
86
|
onSubmissionStarted?.(artifacts);
|
|
@@ -55,7 +106,7 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
55
106
|
.catch((cause) => {
|
|
56
107
|
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
57
108
|
setLocalError(error);
|
|
58
|
-
|
|
109
|
+
reportFailure?.(error);
|
|
59
110
|
throw error;
|
|
60
111
|
})
|
|
61
112
|
.finally(() => {
|
|
@@ -72,10 +123,11 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
72
123
|
onApproved,
|
|
73
124
|
onComplete,
|
|
74
125
|
onDenied,
|
|
75
|
-
|
|
126
|
+
reportFailure,
|
|
76
127
|
onSubmissionStarted,
|
|
77
128
|
options,
|
|
78
129
|
progress,
|
|
130
|
+
mode,
|
|
79
131
|
]);
|
|
80
132
|
const resubmit = useMemo(() => {
|
|
81
133
|
if (!authState.session.canRefreshSession)
|
|
@@ -107,31 +159,98 @@ export function SubmissionProvider({ client, action, options = EMPTY_SUBMISSION_
|
|
|
107
159
|
return promise;
|
|
108
160
|
};
|
|
109
161
|
}, [authState.session.canRefreshSession, client, submit]);
|
|
110
|
-
const value = useMemo(() =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
+
}, [
|
|
122
194
|
action,
|
|
195
|
+
attempt,
|
|
123
196
|
clientState.lastSubmissionRequest,
|
|
124
197
|
clientState.lastSubmissionTimings,
|
|
125
198
|
clientState.submissionError,
|
|
126
199
|
clientState.submissionStatus,
|
|
127
200
|
localError,
|
|
201
|
+
mode,
|
|
128
202
|
resubmit,
|
|
129
203
|
resubmitting,
|
|
204
|
+
startedExplicit,
|
|
130
205
|
submissionResponse,
|
|
131
206
|
submit,
|
|
132
207
|
]);
|
|
133
208
|
return (_jsx(SubmissionContext.Provider, { value: value, children: children }));
|
|
134
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
|
+
}
|
|
135
254
|
export function useSubmission() {
|
|
136
255
|
const context = useContext(SubmissionContext);
|
|
137
256
|
if (!context) {
|
|
@@ -4,8 +4,8 @@ import { type VideoIdCaptureController, type VideoIdCaptureControllerConfig } fr
|
|
|
4
4
|
import { type SignatureCaptureController, type SignatureCaptureControllerConfig } from '@idmission/websdk-core/signatureCapture';
|
|
5
5
|
import { type SignatureFlowViewProps, type SignatureStageDecision } from './signatureStep';
|
|
6
6
|
import { type VideoIdFlowViewProps } from './videoIdSteps';
|
|
7
|
-
import type { CommonFlowProps, FaceLivenessFlowConfig, FaceLivenessFlowViewProps, IdCaptureFlowConfig, IdCaptureFlowViewProps } from './types';
|
|
8
|
-
export type VideoIdValidationFlowProps = CommonFlowProps & {
|
|
7
|
+
import type { CaptureOnlyProps, CommonFlowProps, SubmitMode, SubmitModeProps, FaceLivenessFlowConfig, FaceLivenessFlowViewProps, IdCaptureFlowConfig, IdCaptureFlowViewProps } from './types';
|
|
8
|
+
export type VideoIdValidationFlowProps = CommonFlowProps & SubmitModeProps<SubmitMode> & CaptureOnlyProps & {
|
|
9
9
|
idController?: IdCaptureController;
|
|
10
10
|
selfieController?: SelfieCaptureController;
|
|
11
11
|
/** Controller override for the final face-and-ID recording stage. */
|
|
@@ -36,8 +36,6 @@ export type VideoIdValidationFlowProps = CommonFlowProps & {
|
|
|
36
36
|
faceView?: FaceLivenessFlowViewProps;
|
|
37
37
|
/** View options for the final face-and-ID recording stage. */
|
|
38
38
|
view?: VideoIdFlowViewProps;
|
|
39
|
-
captureOnly?: boolean;
|
|
40
|
-
onCaptured?: CommonFlowProps['onSubmissionStarted'];
|
|
41
39
|
onCaptureError?: (error: Error) => void;
|
|
42
40
|
signatureController?: SignatureCaptureController;
|
|
43
41
|
/**
|
|
@@ -81,5 +79,5 @@ export type VideoIdValidationFlowProps = CommonFlowProps & {
|
|
|
81
79
|
/** Fires when microphone access is refused. sdk2's callback of the same name. */
|
|
82
80
|
onMicrophoneAccessDenied?: () => void;
|
|
83
81
|
};
|
|
84
|
-
export declare function VideoIdValidationFlow({ client, idController, selfieController, controller, idCapture, faceCapture, capture, idView, faceView, view, submission, initialArtifacts, captureOnly, signatureController, signatureCapture, signatureView, captureSignature, captureSignatureVideo, allowVirtualCameras, skipIdCapture, matchOnly, readTextPrompt, onMicrophoneAccessDenied, theme, className, showSuccessScreen, showDiagnostics, captureAdditionalDocuments, additionalDocumentClassNames, additionalDocumentVerbiage, ringScreenClassNames, ringScreenVerbiage, onCaptured, onSubmitted, onCaptureError, children, ...callbacks }: VideoIdValidationFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
export declare function VideoIdValidationFlow({ client, idController, selfieController, controller, idCapture, faceCapture, capture, idView: idViewProp, faceView: faceViewProp, view: viewProp, submission, initialArtifacts, submitMode, captureOnly, signatureController, signatureCapture, signatureView: signatureViewProp, captureSignature, captureSignatureVideo, allowVirtualCameras, skipIdCapture, matchOnly, readTextPrompt, onMicrophoneAccessDenied, theme, className, lang, debugMode, skipSuccessScreen, showResultScreen, showSuccessScreen, showDiagnostics, captureAdditionalDocuments, additionalDocumentClassNames, additionalDocumentVerbiage, ringScreenClassNames, ringScreenVerbiage, onCaptured, onSubmitted, onCaptureError, children, ...callbacks }: VideoIdValidationFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
85
83
|
//# sourceMappingURL=VideoIdValidationFlow.d.ts.map
|