@velion-la/onboarding-sdk-react-native 1.0.0-beta.6 → 1.0.0-beta.7
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/lib/commonjs/core/VelionOnboarding.js +69 -6
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
- package/lib/commonjs/core/retryStepCopy.js +43 -0
- package/lib/commonjs/core/retryStepCopy.js.map +1 -0
- package/lib/commonjs/i18n/strings/en.js +27 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +27 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/steps/FaceMatchStep.js +16 -13
- package/lib/commonjs/steps/FaceMatchStep.js.map +1 -1
- package/lib/commonjs/types/index.js +21 -5
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/core/VelionOnboarding.js +69 -6
- package/lib/module/core/VelionOnboarding.js.map +1 -1
- package/lib/module/core/retryStepCopy.js +39 -0
- package/lib/module/core/retryStepCopy.js.map +1 -0
- package/lib/module/i18n/strings/en.js +27 -0
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +27 -0
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/steps/FaceMatchStep.js +16 -13
- package/lib/module/steps/FaceMatchStep.js.map +1 -1
- package/lib/module/types/index.js +22 -5
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/core/VelionOnboarding.d.ts +15 -4
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
- package/lib/typescript/core/retryStepCopy.d.ts +27 -0
- package/lib/typescript/core/retryStepCopy.d.ts.map +1 -0
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +24 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +34 -11
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/VelionOnboarding.ts +80 -8
- package/src/core/retryStepCopy.ts +54 -0
- package/src/i18n/strings/en.ts +32 -0
- package/src/i18n/strings/es.ts +32 -0
- package/src/index.ts +1 -0
- package/src/steps/FaceMatchStep.tsx +18 -19
- package/src/types/index.ts +39 -11
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* Invariants:
|
|
9
9
|
* - SSE dedupe by `event_id` (monotonic)
|
|
10
10
|
* - Suppress duplicate `NEXT_STEP` for the just-completed step
|
|
11
|
+
* - `RETRY_STEP` shows a retry dialog (Retry re-mounts the step, Cancel exits);
|
|
12
|
+
* once the retry quota is exhausted the backend emits SESSION_DECLINED instead
|
|
11
13
|
* - 45 s watchdog for terminal SSE event after final step → fallback GET
|
|
12
14
|
* - SESSION_DECLINED handling races with module.run()
|
|
13
15
|
*/
|
|
@@ -26,6 +28,7 @@ import {
|
|
|
26
28
|
} from './sessionStateMapper';
|
|
27
29
|
import { createSessionEventSource } from '../transport/sse';
|
|
28
30
|
import { resolveSessionDeclinedCopy } from './sessionDeclinedCopy';
|
|
31
|
+
import { resolveRetryStepCopy } from './retryStepCopy';
|
|
29
32
|
import {
|
|
30
33
|
parseBackExitCommand,
|
|
31
34
|
parsePreviousStepCommand,
|
|
@@ -61,7 +64,8 @@ import {
|
|
|
61
64
|
type SessionState,
|
|
62
65
|
} from '../types';
|
|
63
66
|
import type { StepModule, StepUiHandle } from '../steps/types';
|
|
64
|
-
import type
|
|
67
|
+
import { createElement, type ReactNode } from 'react';
|
|
68
|
+
import { RetryDialog } from '../ui/overlays/RetryDialog';
|
|
65
69
|
|
|
66
70
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
67
71
|
// PUBLIC CONFIG (RN flavor)
|
|
@@ -85,7 +89,7 @@ export type VelionConfig = Omit<
|
|
|
85
89
|
interface NextStepCommand {
|
|
86
90
|
step: OnboardingStep;
|
|
87
91
|
stepConfig?: Record<string, unknown>;
|
|
88
|
-
/** `NEXT_STEP` advances; `RETRY_STEP` re-
|
|
92
|
+
/** `NEXT_STEP` advances; `RETRY_STEP` re-presents the same step (via a retry dialog). */
|
|
89
93
|
action: 'NEXT_STEP' | 'RETRY_STEP';
|
|
90
94
|
/** Whether the target step can go back (when the backend sends it on the command). */
|
|
91
95
|
canGoBack?: boolean;
|
|
@@ -196,6 +200,9 @@ export class VelionOnboarding {
|
|
|
196
200
|
private queuedBackExitStep: { step: OnboardingStep | undefined } | null = null;
|
|
197
201
|
private backRequestInFlight = false;
|
|
198
202
|
|
|
203
|
+
/** Resolver for the in-flight retry dialog (RETRY_STEP), cleared on destroy. */
|
|
204
|
+
private retryDialogResolve: ((choice: 'retry' | 'cancel') => void) | null = null;
|
|
205
|
+
|
|
199
206
|
/** Per-step reversibility (workflow order) cached from the initial GET, used to
|
|
200
207
|
* derive `can_go_back` for steps reached via SSE (which doesn't carry it). */
|
|
201
208
|
private stepReversibility: ReadonlyArray<{ code: OnboardingStep; reversible: boolean }> = [];
|
|
@@ -316,6 +323,7 @@ export class VelionOnboarding {
|
|
|
316
323
|
this.queuedPreviousStepCommand = null;
|
|
317
324
|
this.backExitResolve = null;
|
|
318
325
|
this.queuedBackExitStep = null;
|
|
326
|
+
this.retryDialogResolve = null;
|
|
319
327
|
}
|
|
320
328
|
|
|
321
329
|
// ── Initialization ────────────────────────────────────────────────────────
|
|
@@ -555,6 +563,29 @@ export class VelionOnboarding {
|
|
|
555
563
|
this.showLoading(null);
|
|
556
564
|
}
|
|
557
565
|
if (!next?.step) break;
|
|
566
|
+
|
|
567
|
+
// RETRY_STEP: the step failed but the retry quota is not exhausted. Show a
|
|
568
|
+
// retry dialog before re-presenting the step. "Retry" re-mounts the same
|
|
569
|
+
// step for a fresh submit; "Cancel" exits the flow cleanly (no verdict).
|
|
570
|
+
// When the quota IS exhausted the backend emits SESSION_DECLINED instead,
|
|
571
|
+
// so this dialog never shows for the final attempt.
|
|
572
|
+
if (next.action === 'RETRY_STEP') {
|
|
573
|
+
const choice = await this.presentRetryStepDialog(next.step);
|
|
574
|
+
if (this.sessionEnded || this.status === 'DESTROYED') return;
|
|
575
|
+
if (await this.consumePendingTerminalEvent()) return;
|
|
576
|
+
if (this.pendingSessionDeclined) {
|
|
577
|
+
const ev = this.pendingSessionDeclined;
|
|
578
|
+
this.pendingSessionDeclined = null;
|
|
579
|
+
this.endFlowWithSessionDeclined(ev);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (choice === 'cancel') {
|
|
583
|
+
this.exitFlow(next.step, 'RETRY_CANCELLED');
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
this.showLoading(this.localizedLoadingMsg());
|
|
587
|
+
}
|
|
588
|
+
|
|
558
589
|
currentStep = next.step;
|
|
559
590
|
currentStepConfig = next.stepConfig ?? knownStepConfigs[next.step];
|
|
560
591
|
// Forward navigation: no prefill. `can_go_back` comes from the command
|
|
@@ -749,26 +780,67 @@ export class VelionOnboarding {
|
|
|
749
780
|
}
|
|
750
781
|
|
|
751
782
|
/**
|
|
752
|
-
* Ends the flow
|
|
753
|
-
*
|
|
754
|
-
*
|
|
783
|
+
* Ends the flow without a verdict and notifies the host via `onExit`. Not an
|
|
784
|
+
* error: the UI is cleared so the host can dismiss the SDK. Triggered by
|
|
785
|
+
* backing out of the first reversible step (`BACK_EXIT`) or cancelling the
|
|
786
|
+
* retry dialog (`RETRY_CANCELLED`).
|
|
755
787
|
*/
|
|
756
|
-
private exitFlow(
|
|
788
|
+
private exitFlow(
|
|
789
|
+
step: OnboardingStep | undefined,
|
|
790
|
+
reason: OnboardingExit['reason'] = 'BACK_EXIT',
|
|
791
|
+
): void {
|
|
757
792
|
if (this.sessionEnded) return;
|
|
758
793
|
this.sessionEnded = true;
|
|
794
|
+
this.view.setStepNode?.(null);
|
|
759
795
|
this.setStatus('EXITED');
|
|
760
|
-
log.info('[Flow] Session exited
|
|
796
|
+
log.info('[Flow] Session exited', {
|
|
761
797
|
sessionId: this.config.sessionId,
|
|
798
|
+
reason,
|
|
762
799
|
step,
|
|
763
800
|
});
|
|
764
801
|
const exit: OnboardingExit = {
|
|
765
|
-
reason
|
|
802
|
+
reason,
|
|
766
803
|
...(step !== undefined && { step }),
|
|
767
804
|
};
|
|
768
805
|
this.view.setExit?.(exit);
|
|
769
806
|
this.emitter.emit('flow:exit', exit);
|
|
770
807
|
}
|
|
771
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Mounts the retry dialog for a `RETRY_STEP` and resolves with the user's
|
|
811
|
+
* choice. Copy is derived from the step (not the backend `reason`, which is a
|
|
812
|
+
* diagnostic string) and can be overridden per-step via `retryStepTexts`.
|
|
813
|
+
*/
|
|
814
|
+
private presentRetryStepDialog(
|
|
815
|
+
step: OnboardingStep,
|
|
816
|
+
): Promise<'retry' | 'cancel'> {
|
|
817
|
+
const copy = resolveRetryStepCopy(
|
|
818
|
+
this.config.locale,
|
|
819
|
+
this.config.retryStepTexts,
|
|
820
|
+
step,
|
|
821
|
+
);
|
|
822
|
+
log.info('[Flow] Presenting RETRY_STEP dialog', { step });
|
|
823
|
+
return new Promise<'retry' | 'cancel'>((resolve) => {
|
|
824
|
+
const settle = (choice: 'retry' | 'cancel'): void => {
|
|
825
|
+
if (this.retryDialogResolve === null) return;
|
|
826
|
+
this.retryDialogResolve = null;
|
|
827
|
+
this.view.setStepNode?.(null);
|
|
828
|
+
resolve(choice);
|
|
829
|
+
};
|
|
830
|
+
this.retryDialogResolve = resolve;
|
|
831
|
+
this.view.setStepNode?.(
|
|
832
|
+
createElement(RetryDialog, {
|
|
833
|
+
title: copy.title,
|
|
834
|
+
message: copy.message,
|
|
835
|
+
retryLabel: copy.retryLabel,
|
|
836
|
+
cancelLabel: copy.cancelLabel,
|
|
837
|
+
onRetry: () => settle('retry'),
|
|
838
|
+
onCancel: () => settle('cancel'),
|
|
839
|
+
}),
|
|
840
|
+
);
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
|
|
772
844
|
private endFlowWithSessionDeclined(event: OnboardingSessionEvent): void {
|
|
773
845
|
if (this.sessionEnded) return;
|
|
774
846
|
this.sessionEnded = true;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Copy resolution for the retry dialog shown on
|
|
3
|
+
* `ROUTING_COMMAND / RETRY_STEP` (a step failed but the retry quota is not yet
|
|
4
|
+
* exhausted, so the backend asks the SDK to re-present it).
|
|
5
|
+
*
|
|
6
|
+
* The backend `reason` is intentionally NOT used here: it is a diagnostic string
|
|
7
|
+
* (e.g. `"STEP_FAILED_RETRY_ALLOWED (attempt 1/3)"`), not user-facing localized
|
|
8
|
+
* copy. The dialog title/message are derived from the step being retried, with a
|
|
9
|
+
* generic fallback, and can be overridden per-step by the host via
|
|
10
|
+
* `VelionConfig.retryStepTexts`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { OnboardingStep, VelionRetryStepTexts } from '../types';
|
|
14
|
+
import { getStrings } from '../i18n';
|
|
15
|
+
|
|
16
|
+
export interface ResolvedRetryStepCopy {
|
|
17
|
+
title: string;
|
|
18
|
+
message: string;
|
|
19
|
+
retryLabel: string;
|
|
20
|
+
cancelLabel: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isEnglishLocale(locale: string | undefined): boolean {
|
|
24
|
+
return (locale ?? 'es').toLowerCase().startsWith('en');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the retry dialog copy for `step`. Precedence for title/message:
|
|
29
|
+
* 1. host override (`retryStepTexts[step][lang]`),
|
|
30
|
+
* 2. SDK per-step default (i18n `retryStep.steps[step]`),
|
|
31
|
+
* 3. generic SDK default (i18n `retryStep.default*`).
|
|
32
|
+
* The retry/cancel button labels always come from the i18n table.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveRetryStepCopy(
|
|
35
|
+
locale: string | undefined,
|
|
36
|
+
texts: VelionRetryStepTexts | undefined,
|
|
37
|
+
step: OnboardingStep,
|
|
38
|
+
): ResolvedRetryStepCopy {
|
|
39
|
+
const t = getStrings(locale);
|
|
40
|
+
const lang = isEnglishLocale(locale) ? 'en' : 'es';
|
|
41
|
+
|
|
42
|
+
const perStepDefault = (
|
|
43
|
+
t.retryStep.steps as Record<string, { title: string; message: string }>
|
|
44
|
+
)[step];
|
|
45
|
+
const override = texts?.[step]?.[lang];
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
title: override?.title ?? perStepDefault?.title ?? t.retryStep.defaultTitle,
|
|
49
|
+
message:
|
|
50
|
+
override?.message ?? perStepDefault?.message ?? t.retryStep.defaultMessage,
|
|
51
|
+
retryLabel: t.retryStep.retry,
|
|
52
|
+
cancelLabel: t.retryStep.cancel,
|
|
53
|
+
};
|
|
54
|
+
}
|
package/src/i18n/strings/en.ts
CHANGED
|
@@ -288,4 +288,36 @@ export const EN: StringsTable = {
|
|
|
288
288
|
rejectedBody: 'This session could not be completed.',
|
|
289
289
|
declineHeadline: 'We could not continue',
|
|
290
290
|
},
|
|
291
|
+
// Retry dialog shown when the backend asks the SDK to re-present a failed step
|
|
292
|
+
// (ROUTING_COMMAND / RETRY_STEP). Copy is derived from the step, not the
|
|
293
|
+
// backend `reason` (which is a diagnostic string).
|
|
294
|
+
retryStep: {
|
|
295
|
+
retry: 'Try again',
|
|
296
|
+
cancel: 'Cancel',
|
|
297
|
+
defaultTitle: "Let's retry this step",
|
|
298
|
+
defaultMessage:
|
|
299
|
+
'We could not verify this step. Try again to continue, or cancel to leave.',
|
|
300
|
+
steps: {
|
|
301
|
+
LIVENESS_MATCH: {
|
|
302
|
+
title: "Let's redo the liveness check",
|
|
303
|
+
message:
|
|
304
|
+
'We need a slightly better capture to verify your liveness check. Try again in a well-lit area, follow the on-screen instructions, and keep your face clearly visible.',
|
|
305
|
+
},
|
|
306
|
+
DOCUMENTS_OCR: {
|
|
307
|
+
title: "Let's recapture your document",
|
|
308
|
+
message:
|
|
309
|
+
'We could not read the document clearly. Try again in good light, keeping it flat and in focus, without glare or cut-off edges.',
|
|
310
|
+
},
|
|
311
|
+
HUMAN_BASIC_INFO: {
|
|
312
|
+
title: 'Review your personal details',
|
|
313
|
+
message:
|
|
314
|
+
'We could not validate your personal details. Try again and make sure they match your ID document.',
|
|
315
|
+
},
|
|
316
|
+
TAX_INFO: {
|
|
317
|
+
title: 'Review your tax information',
|
|
318
|
+
message:
|
|
319
|
+
'We could not validate your tax information. Try again and review the details you entered.',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
291
323
|
};
|
package/src/i18n/strings/es.ts
CHANGED
|
@@ -288,6 +288,38 @@ export const ES = {
|
|
|
288
288
|
rejectedBody: 'No se pudo completar esta sesión.',
|
|
289
289
|
declineHeadline: 'No pudimos continuar',
|
|
290
290
|
},
|
|
291
|
+
// Retry dialog shown when the backend asks the SDK to re-present a failed step
|
|
292
|
+
// (ROUTING_COMMAND / RETRY_STEP). Copy is derived from the step, not the
|
|
293
|
+
// backend `reason` (which is a diagnostic string).
|
|
294
|
+
retryStep: {
|
|
295
|
+
retry: 'Reintentar',
|
|
296
|
+
cancel: 'Cancelar',
|
|
297
|
+
defaultTitle: 'Reintentemos este paso',
|
|
298
|
+
defaultMessage:
|
|
299
|
+
'No pudimos verificar este paso. Reintentá para continuar o cancelá para salir.',
|
|
300
|
+
steps: {
|
|
301
|
+
LIVENESS_MATCH: {
|
|
302
|
+
title: 'Repitamos la prueba de vida',
|
|
303
|
+
message:
|
|
304
|
+
'Necesitamos una captura un poco mejor para verificar tu prueba de vida. Reintentá en un lugar bien iluminado, seguí las instrucciones en pantalla y mantené el rostro bien visible.',
|
|
305
|
+
},
|
|
306
|
+
DOCUMENTS_OCR: {
|
|
307
|
+
title: 'Volvamos a capturar tu documento',
|
|
308
|
+
message:
|
|
309
|
+
'No pudimos leer el documento con claridad. Reintentá con buena luz, manteniéndolo plano y enfocado, sin reflejos ni bordes cortados.',
|
|
310
|
+
},
|
|
311
|
+
HUMAN_BASIC_INFO: {
|
|
312
|
+
title: 'Revisá tus datos personales',
|
|
313
|
+
message:
|
|
314
|
+
'No pudimos validar tus datos personales. Reintentá revisando que coincidan con tu documento de identidad.',
|
|
315
|
+
},
|
|
316
|
+
TAX_INFO: {
|
|
317
|
+
title: 'Revisá tu información impositiva',
|
|
318
|
+
message:
|
|
319
|
+
'No pudimos validar tu información impositiva. Reintentá revisando los datos ingresados.',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
291
323
|
};
|
|
292
324
|
|
|
293
325
|
export type StringsTable = typeof ES;
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type SdkError,
|
|
22
22
|
} from '../types';
|
|
23
23
|
import { getStrings } from '../i18n';
|
|
24
|
+
import { isTerminalSessionStatusFromDto } from '../core/sessionStateMapper';
|
|
24
25
|
import { useTheme } from '../ui/theme';
|
|
25
26
|
import { log } from '../utils/log';
|
|
26
27
|
import type { StepDeps, StepModule } from './types';
|
|
@@ -68,17 +69,13 @@ export class FaceMatchStep implements StepModule {
|
|
|
68
69
|
},
|
|
69
70
|
);
|
|
70
71
|
const status = (dto.status ?? '').toUpperCase();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (status === 'APPROVED' || status === 'MANUAL_REVIEW') {
|
|
72
|
+
// Any terminal session status (APPROVED / MANUAL_REVIEW / DECLINED /
|
|
73
|
+
// REJECTED) hands control back to the orchestrator, which finalizes via
|
|
74
|
+
// its SSE terminal/decline path — showing the proper result or decline
|
|
75
|
+
// screen. We resolve (not reject) even on DECLINED so a genuine
|
|
76
|
+
// face-match business failure surfaces the decline copy, not a generic
|
|
77
|
+
// error.
|
|
78
|
+
if (isTerminalSessionStatusFromDto(status)) {
|
|
82
79
|
this.resolveStep();
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
@@ -88,15 +85,17 @@ export class FaceMatchStep implements StepModule {
|
|
|
88
85
|
this.resolveStep();
|
|
89
86
|
return;
|
|
90
87
|
}
|
|
88
|
+
// FACE_MATCH = FAILED while the session is still IN_PROGRESS is NOT
|
|
89
|
+
// fatal: per VON-26 the orchestrator re-marks an auto-backend step
|
|
90
|
+
// IN_PROGRESS and re-dispatches the command on a transient failure
|
|
91
|
+
// (Rekognition / RENAPER error, selfie not ready yet), bounded by
|
|
92
|
+
// maxRetries. A genuine business failure hard-fails the session, which
|
|
93
|
+
// we catch via the terminal-status check above. So on a transient
|
|
94
|
+
// FAILED we keep polling instead of erroring the whole flow.
|
|
91
95
|
if (stepStatus === 'FAILED') {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.deps.locale === 'en'
|
|
96
|
-
? 'Face match step failed.'
|
|
97
|
-
: 'La verificación facial no pudo completarse.',
|
|
98
|
-
});
|
|
99
|
-
return;
|
|
96
|
+
log.info(
|
|
97
|
+
'[FaceMatch] step FAILED while session IN_PROGRESS — backend may be retrying (VON-26), continuing to poll',
|
|
98
|
+
);
|
|
100
99
|
}
|
|
101
100
|
} catch (err) {
|
|
102
101
|
if (this.destroyed) return;
|
package/src/types/index.ts
CHANGED
|
@@ -469,6 +469,21 @@ export type VelionSessionDeclinedReasonTexts = Record<
|
|
|
469
469
|
VelionSessionDeclinedReasonMessages
|
|
470
470
|
>;
|
|
471
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Per-step overrides for the retry dialog shown when the backend emits a
|
|
474
|
+
* `ROUTING_COMMAND / RETRY_STEP` (the step failed but the retry quota is not
|
|
475
|
+
* exhausted). Keyed by step code (e.g. `LIVENESS_MATCH`, `DOCUMENTS_OCR`).
|
|
476
|
+
* Unspecified steps fall back to SDK per-step defaults, then generic copy.
|
|
477
|
+
*
|
|
478
|
+
* Note: the SDK intentionally ignores the backend `reason` for this dialog —
|
|
479
|
+
* it is a diagnostic string (e.g. `"STEP_FAILED_RETRY_ALLOWED (attempt 1/3)"`),
|
|
480
|
+
* not user-facing localized copy. The copy is derived from the step instead.
|
|
481
|
+
*/
|
|
482
|
+
export type VelionRetryStepTexts = Record<
|
|
483
|
+
string,
|
|
484
|
+
VelionSessionDeclinedReasonMessages
|
|
485
|
+
>;
|
|
486
|
+
|
|
472
487
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
473
488
|
// CALLBACKS
|
|
474
489
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -533,11 +548,11 @@ export interface VelionCallbacks {
|
|
|
533
548
|
onFinalResultScreenDismiss?: () => void;
|
|
534
549
|
|
|
535
550
|
/**
|
|
536
|
-
* Fires when the user leaves the flow without a verdict —
|
|
537
|
-
*
|
|
538
|
-
* The SDK has already torn
|
|
539
|
-
*
|
|
540
|
-
* `onError` fires in this case.
|
|
551
|
+
* Fires when the user leaves the flow without a verdict — either by tapping
|
|
552
|
+
* "back" on the first reversible step (`BACK_EXIT`) or "Cancel" on the retry
|
|
553
|
+
* dialog after a `RETRY_STEP` (`RETRY_CANCELLED`). The SDK has already torn
|
|
554
|
+
* down its UI; the host should dismiss the SDK screen and return the user to
|
|
555
|
+
* the previous context. Neither `onSuccess` nor `onError` fires in this case.
|
|
541
556
|
*
|
|
542
557
|
* @param exit - Why the flow ended and, when available, the step exited from.
|
|
543
558
|
*/
|
|
@@ -670,6 +685,13 @@ export interface VelionConfig extends VelionCallbacks {
|
|
|
670
685
|
*/
|
|
671
686
|
sessionDeclinedReasonTexts?: VelionSessionDeclinedReasonTexts;
|
|
672
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Optional copy for the retry dialog (`ROUTING_COMMAND / RETRY_STEP`), keyed by
|
|
690
|
+
* step code (e.g. `LIVENESS_MATCH`). Merged with SDK per-step defaults for
|
|
691
|
+
* `locale` `en` / `es`; unspecified steps fall back to generic retry copy.
|
|
692
|
+
*/
|
|
693
|
+
retryStepTexts?: VelionRetryStepTexts;
|
|
694
|
+
|
|
673
695
|
/**
|
|
674
696
|
* When `true` (default), shows the Velion preparation screen (face icon, tips,
|
|
675
697
|
* "Start verification") before connecting to Iris. When `false`, skips it and
|
|
@@ -885,15 +907,21 @@ export interface SessionState {
|
|
|
885
907
|
/**
|
|
886
908
|
* Emitted when the user leaves the onboarding flow without a backend verdict.
|
|
887
909
|
*
|
|
888
|
-
*
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
910
|
+
* Triggers:
|
|
911
|
+
* - `BACK_EXIT`: the user tapped "back" on the first reversible step, where
|
|
912
|
+
* there is no earlier step to return to, so the backend instructs the SDK to
|
|
913
|
+
* exit.
|
|
914
|
+
* - `RETRY_CANCELLED`: the user tapped "Cancel" on the retry dialog shown after
|
|
915
|
+
* a `ROUTING_COMMAND / RETRY_STEP`. The backend session stays `IN_PROGRESS`
|
|
916
|
+
* (there is no cancellation endpoint); the host may re-open it later via
|
|
917
|
+
* `GET /sessions/:id`.
|
|
918
|
+
*
|
|
919
|
+
* This is neither success nor error — the host should dismiss the SDK screen and
|
|
920
|
+
* return the user to wherever they came from. See {@link VelionCallbacks.onExit}.
|
|
893
921
|
*/
|
|
894
922
|
export interface OnboardingExit {
|
|
895
923
|
/** Why the flow ended without a verdict. */
|
|
896
|
-
reason: 'BACK_EXIT';
|
|
924
|
+
reason: 'BACK_EXIT' | 'RETRY_CANCELLED';
|
|
897
925
|
/** The step the user exited from (SSE `step_code`), when the backend provides it. */
|
|
898
926
|
step?: OnboardingStep;
|
|
899
927
|
}
|