@incodetech/web 2.0.0-alpha.2 → 2.0.0-alpha.4
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/dist/{styles/core.css → base.css} +53 -57
- package/dist/email/email.es.js +1 -1
- package/dist/email/styles.css +11 -11
- package/dist/flow/styles.css +688 -1
- package/dist/{incodeModule-BF5MX9GT.js → incodeModule-Ct9jp5k6.js} +22 -19
- package/dist/index.es.js +18 -18
- package/dist/phone/phone.es.js +1 -1
- package/dist/phone/styles.css +31 -31
- package/dist/selfie/selfie.es.js +16 -16
- package/dist/selfie/styles.css +0 -51
- package/dist/themes/dark.css +652 -0
- package/dist/types/dark.d.ts +1 -0
- package/dist/types/light.d.ts +1 -0
- package/dist/types/themes/light.d.ts +1 -0
- package/package.json +12 -6
- package/.turbo/turbo-build.log +0 -58
- package/.turbo/turbo-coverage.log +0 -23
- package/.turbo/turbo-format.log +0 -6
- package/.turbo/turbo-lint$colon$fix.log +0 -6
- package/.turbo/turbo-lint.log +0 -6
- package/.turbo/turbo-test.log +0 -1033
- package/.turbo/turbo-typecheck.log +0 -5
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/email/email.tsx.html +0 -850
- package/coverage/email/emailInput.tsx.html +0 -340
- package/coverage/email/index.html +0 -131
- package/coverage/favicon.png +0 -0
- package/coverage/flow/flow.tsx.html +0 -961
- package/coverage/flow/flowCompleted.tsx.html +0 -448
- package/coverage/flow/flowInit.ts.html +0 -367
- package/coverage/flow/flowStart.tsx.html +0 -208
- package/coverage/flow/index.html +0 -221
- package/coverage/flow/preloadFlow.ts.html +0 -598
- package/coverage/flow/unsupportedModule.tsx.html +0 -202
- package/coverage/flow/useFlowInitialization.ts.html +0 -469
- package/coverage/flow/useModuleLoader.ts.html +0 -361
- package/coverage/hooks/index.html +0 -116
- package/coverage/hooks/useManager.ts.html +0 -205
- package/coverage/index.html +0 -401
- package/coverage/permissions/boldWithArrow.tsx.html +0 -208
- package/coverage/permissions/denied.tsx.html +0 -172
- package/coverage/permissions/deniedAndroid.tsx.html +0 -253
- package/coverage/permissions/deniedDesktop.tsx.html +0 -277
- package/coverage/permissions/deniedIOS.tsx.html +0 -304
- package/coverage/permissions/deniedInstructions.tsx.html +0 -142
- package/coverage/permissions/iconWrapper.tsx.html +0 -130
- package/coverage/permissions/index.html +0 -251
- package/coverage/permissions/learnMore.tsx.html +0 -340
- package/coverage/permissions/numberedStep.tsx.html +0 -127
- package/coverage/permissions/permissions.tsx.html +0 -289
- package/coverage/phone/index.html +0 -116
- package/coverage/phone/phoneInput.tsx.html +0 -832
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/selfie/index.html +0 -131
- package/coverage/selfie/selfie.tsx.html +0 -334
- package/coverage/selfie/tutorial.tsx.html +0 -214
- package/coverage/shared/baseTutorial/baseTutorial.tsx.html +0 -250
- package/coverage/shared/baseTutorial/index.html +0 -131
- package/coverage/shared/baseTutorial/replaceBaseTutorial.ts.html +0 -289
- package/coverage/shared/button/button.tsx.html +0 -226
- package/coverage/shared/button/index.html +0 -116
- package/coverage/shared/componentRoot/incodeComponent.tsx.html +0 -121
- package/coverage/shared/componentRoot/index.html +0 -116
- package/coverage/shared/countries/countries.ts.html +0 -502
- package/coverage/shared/countries/index.html +0 -116
- package/coverage/shared/icons/chevronDown.tsx.html +0 -151
- package/coverage/shared/icons/index.html +0 -131
- package/coverage/shared/icons/successIcon.tsx.html +0 -163
- package/coverage/shared/loader/index.html +0 -116
- package/coverage/shared/loader/loadingIcon.tsx.html +0 -286
- package/coverage/shared/otpInput/index.html +0 -116
- package/coverage/shared/otpInput/otpInput.tsx.html +0 -808
- package/coverage/shared/page/index.html +0 -146
- package/coverage/shared/page/page.tsx.html +0 -358
- package/coverage/shared/page/pageUiConfig.ts.html +0 -277
- package/coverage/shared/page/verifiedByIncode.tsx.html +0 -310
- package/coverage/shared/spacer/index.html +0 -116
- package/coverage/shared/spacer/spacer.tsx.html +0 -349
- package/coverage/shared/spinner/index.html +0 -116
- package/coverage/shared/spinner/spinner.tsx.html +0 -280
- package/coverage/shared/title/index.html +0 -116
- package/coverage/shared/title/title.tsx.html +0 -121
- package/coverage/shared/uiConfig/index.html +0 -116
- package/coverage/shared/uiConfig/uiConfig.ts.html +0 -193
- package/coverage/shared/webComponent/incodeModule.ts.html +0 -172
- package/coverage/shared/webComponent/index.html +0 -131
- package/coverage/shared/webComponent/registerIncodeElement.ts.html +0 -130
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/styles/cn.tsx.html +0 -148
- package/coverage/styles/fetchTheme.ts.html +0 -349
- package/coverage/styles/index.html +0 -131
- package/dev/README.md +0 -163
- package/dev/getToken.ts +0 -36
- package/dev/headless.html +0 -875
- package/dev/index.html +0 -366
- package/dev/main-headless.tsx +0 -1332
- package/dev/main-orchestrated-flow.tsx +0 -1158
- package/dev/main-preact.tsx +0 -323
- package/dev/main-simplified.tsx +0 -123
- package/dev/main-web-component.tsx +0 -256
- package/dev/main.tsx +0 -332
- package/dev/manual.html +0 -27
- package/dev/orchestrated-flow.html +0 -64
- package/dev/simplified.html +0 -64
- package/dev/tiktok-logo.svg +0 -7
- package/dist/asset-manifest.json +0 -18
- package/src/defineCustomElement.tsx +0 -30
- package/src/email/email.test.tsx +0 -368
- package/src/email/email.tsx +0 -255
- package/src/email/emailInput.test.tsx +0 -264
- package/src/email/emailInput.tsx +0 -85
- package/src/email/styles.css +0 -59
- package/src/flow/flow.test.tsx +0 -796
- package/src/flow/flow.tsx +0 -292
- package/src/flow/flowCompleted.css +0 -30
- package/src/flow/flowCompleted.test.tsx +0 -331
- package/src/flow/flowCompleted.tsx +0 -121
- package/src/flow/flowInit.test.ts +0 -264
- package/src/flow/flowInit.ts +0 -94
- package/src/flow/flowStart.css +0 -58
- package/src/flow/flowStart.test.tsx +0 -49
- package/src/flow/flowStart.tsx +0 -41
- package/src/flow/incode-logo.svg +0 -8
- package/src/flow/index.ts +0 -7
- package/src/flow/preloadFlow.test.ts +0 -421
- package/src/flow/preloadFlow.ts +0 -171
- package/src/flow/styles.css +0 -9
- package/src/flow/unsupportedModule.css +0 -21
- package/src/flow/unsupportedModule.tsx +0 -39
- package/src/flow/useFlowInitialization.test.tsx +0 -292
- package/src/flow/useFlowInitialization.ts +0 -128
- package/src/flow/useModuleLoader.test.tsx +0 -212
- package/src/flow/useModuleLoader.ts +0 -92
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useManager.test.ts +0 -91
- package/src/hooks/useManager.ts +0 -40
- package/src/i18n/index.ts +0 -3
- package/src/i18n/instance.ts +0 -16
- package/src/i18n/setup.ts +0 -184
- package/src/i18n/useTranslation.ts +0 -42
- package/src/index.ts +0 -27
- package/src/permissions/assets/android-dots-icon.svg +0 -7
- package/src/permissions/assets/android-settings-icon.svg +0 -16
- package/src/permissions/assets/android-toggle-icon.svg +0 -20
- package/src/permissions/assets/bank-card-icon.svg +0 -14
- package/src/permissions/assets/camera-icon.svg +0 -12
- package/src/permissions/assets/camera-ios.svg +0 -53
- package/src/permissions/assets/check-icon.svg +0 -8
- package/src/permissions/assets/chrome-icon.svg +0 -43
- package/src/permissions/assets/password-icon.svg +0 -11
- package/src/permissions/assets/permissions-img.svg +0 -51
- package/src/permissions/assets/safari-icon.svg +0 -37
- package/src/permissions/assets/settings-icon.svg +0 -33
- package/src/permissions/assets/toggle-icon.svg +0 -19
- package/src/permissions/assets/warning-icon.svg +0 -6
- package/src/permissions/boldWithArrow.css +0 -9
- package/src/permissions/boldWithArrow.tsx +0 -41
- package/src/permissions/denied.css +0 -37
- package/src/permissions/denied.tsx +0 -29
- package/src/permissions/deniedAndroid.tsx +0 -56
- package/src/permissions/deniedDesktop.css +0 -9
- package/src/permissions/deniedDesktop.tsx +0 -64
- package/src/permissions/deniedIOS.tsx +0 -73
- package/src/permissions/deniedInstructions.tsx +0 -19
- package/src/permissions/iconWrapper.css +0 -9
- package/src/permissions/iconWrapper.tsx +0 -15
- package/src/permissions/learnMore.css +0 -37
- package/src/permissions/learnMore.tsx +0 -85
- package/src/permissions/numberedStep.css +0 -13
- package/src/permissions/numberedStep.tsx +0 -14
- package/src/permissions/permissions.css +0 -13
- package/src/permissions/permissions.tsx +0 -68
- package/src/phone/phone.tsx +0 -246
- package/src/phone/phoneInput.test.tsx +0 -275
- package/src/phone/phoneInput.tsx +0 -249
- package/src/phone/styles.css +0 -158
- package/src/selfie/cameraButton.css +0 -13
- package/src/selfie/cameraButton.tsx +0 -35
- package/src/selfie/capture.css +0 -57
- package/src/selfie/capture.tsx +0 -232
- package/src/selfie/errorModal.tsx +0 -218
- package/src/selfie/errorModalContent.css +0 -33
- package/src/selfie/errorModalContent.tsx +0 -44
- package/src/selfie/faceOutline.css +0 -5
- package/src/selfie/faceOutline.tsx +0 -22
- package/src/selfie/loadingBorder.css +0 -12
- package/src/selfie/loadingBorder.tsx +0 -77
- package/src/selfie/manualCaptureButton.css +0 -13
- package/src/selfie/manualCaptureButton.tsx +0 -35
- package/src/selfie/noMoreAttemptsModal.tsx +0 -44
- package/src/selfie/notification.css +0 -9
- package/src/selfie/notification.tsx +0 -36
- package/src/selfie/retryErrorModal.tsx +0 -56
- package/src/selfie/selfie.test.tsx +0 -458
- package/src/selfie/selfie.tsx +0 -83
- package/src/selfie/selfieTutorial.json +0 -2626
- package/src/selfie/styles.css +0 -1
- package/src/selfie/tutorial.test.tsx +0 -200
- package/src/selfie/tutorial.tsx +0 -43
- package/src/setup.ts +0 -33
- package/src/shared/baseTutorial/baseTutorial.css +0 -21
- package/src/shared/baseTutorial/baseTutorial.test.tsx +0 -184
- package/src/shared/baseTutorial/baseTutorial.tsx +0 -55
- package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +0 -267
- package/src/shared/baseTutorial/replaceBaseTutorial.ts +0 -68
- package/src/shared/button/button.css +0 -55
- package/src/shared/button/button.test.tsx +0 -101
- package/src/shared/button/button.tsx +0 -47
- package/src/shared/componentRoot/incodeComponent.tsx +0 -12
- package/src/shared/countries/countries.test.ts +0 -75
- package/src/shared/countries/countries.ts +0 -139
- package/src/shared/countries/index.ts +0 -6
- package/src/shared/icons/chevronDown.tsx +0 -22
- package/src/shared/icons/index.ts +0 -2
- package/src/shared/icons/successIcon.css +0 -5
- package/src/shared/icons/successIcon.test.tsx +0 -40
- package/src/shared/icons/successIcon.tsx +0 -26
- package/src/shared/loader/loadingIcon.css +0 -28
- package/src/shared/loader/loadingIcon.tsx +0 -67
- package/src/shared/lottie/lottie.tsx +0 -108
- package/src/shared/otpInput/otpInput.css +0 -85
- package/src/shared/otpInput/otpInput.test.tsx +0 -356
- package/src/shared/otpInput/otpInput.tsx +0 -241
- package/src/shared/page/incode-logo.svg +0 -3
- package/src/shared/page/page.css +0 -47
- package/src/shared/page/page.test.tsx +0 -97
- package/src/shared/page/page.tsx +0 -91
- package/src/shared/page/pageUiConfig.test.ts +0 -112
- package/src/shared/page/pageUiConfig.ts +0 -64
- package/src/shared/page/verifiedByIncode.css +0 -5
- package/src/shared/page/verifiedByIncode.tsx +0 -75
- package/src/shared/spacer/spacer.css +0 -149
- package/src/shared/spacer/spacer.test.tsx +0 -143
- package/src/shared/spacer/spacer.tsx +0 -88
- package/src/shared/spinner/index.ts +0 -2
- package/src/shared/spinner/spinner.css +0 -28
- package/src/shared/spinner/spinner.test.tsx +0 -82
- package/src/shared/spinner/spinner.tsx +0 -65
- package/src/shared/title/title.css +0 -7
- package/src/shared/title/title.tsx +0 -12
- package/src/shared/uiConfig/uiConfig.ts +0 -36
- package/src/shared/webComponent/incodeModule.ts +0 -29
- package/src/shared/webComponent/registerIncodeElement.ts +0 -15
- package/src/styles/__mocks__/fetchTheme.ts +0 -19
- package/src/styles/applyTheme.ts +0 -37
- package/src/styles/cn.test.tsx +0 -57
- package/src/styles/cn.tsx +0 -21
- package/src/styles/core.css +0 -12
- package/src/styles/fetchTheme.test.ts +0 -390
- package/src/styles/fetchTheme.ts +0 -88
- package/src/styles/generatePalette.ts +0 -111
- package/src/styles/reset.css +0 -65
- package/src/styles/resolveCssVariableToHex.ts +0 -28
- package/src/styles/tailwind.css +0 -291
- package/src/styles/themeTypes.ts +0 -18
- package/src/styles/tokens/colors.css +0 -190
- package/src/styles/tokens/components.css +0 -174
- package/src/styles/tokens/index.css +0 -4
- package/src/styles/tokens/primitives.css +0 -129
- package/src/styles/tokens/semantic.css +0 -51
- package/src/svg.d.ts +0 -4
- package/src/types/assets.d.ts +0 -1
- package/src/types/custom-elements.d.ts +0 -104
- package/tsconfig.json +0 -22
- package/vite.config.ts +0 -260
- package/vitest.config.ts +0 -40
- package/vitest.setup.ts +0 -16
- /package/dist/{styles/tokens.css → themes/light.css} +0 -0
- /package/dist/types/{core.d.ts → base.d.ts} +0 -0
- /package/dist/types/{styles/core.d.ts → themes/dark.d.ts} +0 -0
package/src/flow/flow.tsx
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import type { WasmConfig } from '@incodetech/core';
|
|
2
|
-
import type {
|
|
3
|
-
FinishStatus,
|
|
4
|
-
FlowModuleConfig,
|
|
5
|
-
OrchestratedFlowReadyState,
|
|
6
|
-
} from '@incodetech/core/flow';
|
|
7
|
-
import { getRequiredWasmPipelines } from '@incodetech/core/flow';
|
|
8
|
-
import type { FC } from 'preact/compat';
|
|
9
|
-
import { useEffect } from 'preact/hooks';
|
|
10
|
-
import register from 'preact-custom-element';
|
|
11
|
-
import { useManager } from '@/hooks';
|
|
12
|
-
import { useTranslation } from '@/i18n';
|
|
13
|
-
import { Spinner, type SpinnerSize } from '../shared/spinner';
|
|
14
|
-
import { warmupWasmIfNeeded } from './flowInit';
|
|
15
|
-
import { UnsupportedModule } from './unsupportedModule';
|
|
16
|
-
import { useFlowInitialization } from './useFlowInitialization';
|
|
17
|
-
import { useModuleLoader, usePrefetchNextModule } from './useModuleLoader';
|
|
18
|
-
import './styles.css';
|
|
19
|
-
import './flowStart.css';
|
|
20
|
-
import './flowCompleted.css';
|
|
21
|
-
|
|
22
|
-
export type SpinnerConfig = {
|
|
23
|
-
title?: string;
|
|
24
|
-
subtitle?: string;
|
|
25
|
-
size?: SpinnerSize;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type IncodeFlowProps = {
|
|
29
|
-
apiURL: string;
|
|
30
|
-
token: string;
|
|
31
|
-
wasmConfig?: WasmConfig;
|
|
32
|
-
lang?: string;
|
|
33
|
-
disableDashboardTheme?: boolean;
|
|
34
|
-
onComplete: (result: FinishStatus) => void;
|
|
35
|
-
onError?: (error: string) => void;
|
|
36
|
-
onModuleLoading?: (moduleKey: string) => void;
|
|
37
|
-
onModuleLoaded?: (moduleKey: string) => void;
|
|
38
|
-
onWasmWarmup?: (pipelines: string[]) => void;
|
|
39
|
-
spinnerConfig?: SpinnerConfig;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const IncodeFlowContent: FC<IncodeFlowProps> = ({
|
|
43
|
-
apiURL,
|
|
44
|
-
token,
|
|
45
|
-
wasmConfig,
|
|
46
|
-
lang,
|
|
47
|
-
disableDashboardTheme,
|
|
48
|
-
onComplete,
|
|
49
|
-
onError,
|
|
50
|
-
onModuleLoading,
|
|
51
|
-
onModuleLoaded,
|
|
52
|
-
onWasmWarmup,
|
|
53
|
-
spinnerConfig,
|
|
54
|
-
}) => {
|
|
55
|
-
const { t } = useTranslation();
|
|
56
|
-
|
|
57
|
-
const initState = useFlowInitialization({
|
|
58
|
-
apiURL,
|
|
59
|
-
token,
|
|
60
|
-
lang,
|
|
61
|
-
disableDashboardTheme,
|
|
62
|
-
onError,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const [flowState, flowManager] = useManager(() => initState.flowManager, {
|
|
66
|
-
autoLoad: false,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const moduleLoaderState = useModuleLoader({
|
|
70
|
-
moduleKey:
|
|
71
|
-
flowState?.status === 'ready' ? flowState.currentStep : undefined,
|
|
72
|
-
onModuleLoading,
|
|
73
|
-
onModuleLoaded,
|
|
74
|
-
onError,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
usePrefetchNextModule(
|
|
78
|
-
flowState?.status === 'ready' ? flowState.steps : [],
|
|
79
|
-
flowState?.status === 'ready' ? flowState.currentStepIndex : -1,
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (flowState?.status === 'ready' && wasmConfig) {
|
|
84
|
-
const readyState = flowState as OrchestratedFlowReadyState;
|
|
85
|
-
const requiredPipelines = getRequiredWasmPipelines(readyState.flow);
|
|
86
|
-
if (requiredPipelines.length > 0) {
|
|
87
|
-
onWasmWarmup?.(requiredPipelines);
|
|
88
|
-
warmupWasmIfNeeded(readyState, wasmConfig);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, [flowState?.status, wasmConfig, flowState, onWasmWarmup]);
|
|
92
|
-
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (flowState?.status === 'finished') {
|
|
95
|
-
onComplete(flowState.finishStatus);
|
|
96
|
-
}
|
|
97
|
-
}, [flowState?.status, onComplete, flowState]);
|
|
98
|
-
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (flowState?.status === 'error' && onError) {
|
|
101
|
-
onError(flowState.error);
|
|
102
|
-
}
|
|
103
|
-
}, [flowState?.status, onError, flowState]);
|
|
104
|
-
|
|
105
|
-
if (initState.status === 'error') {
|
|
106
|
-
return (
|
|
107
|
-
<div class="IncodeFlow">
|
|
108
|
-
<div>Error: {initState.error}</div>
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (initState.status === 'initializing') {
|
|
114
|
-
return (
|
|
115
|
-
<div class="IncodeFlow">
|
|
116
|
-
<Spinner
|
|
117
|
-
title={spinnerConfig?.title ?? t('home.settingUp')}
|
|
118
|
-
subtitle={spinnerConfig?.subtitle}
|
|
119
|
-
size={spinnerConfig?.size}
|
|
120
|
-
fullScreen
|
|
121
|
-
/>
|
|
122
|
-
</div>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
!flowState ||
|
|
128
|
-
flowState.status === 'idle' ||
|
|
129
|
-
flowState.status === 'loading'
|
|
130
|
-
) {
|
|
131
|
-
return (
|
|
132
|
-
<div class="IncodeFlow">
|
|
133
|
-
<Spinner
|
|
134
|
-
title={spinnerConfig?.title ?? t('home.settingUp')}
|
|
135
|
-
subtitle={spinnerConfig?.subtitle}
|
|
136
|
-
size={spinnerConfig?.size}
|
|
137
|
-
fullScreen
|
|
138
|
-
/>
|
|
139
|
-
</div>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (flowState.status === 'error') {
|
|
144
|
-
return (
|
|
145
|
-
<div class="IncodeFlow">
|
|
146
|
-
<div>Error: {flowState.error}</div>
|
|
147
|
-
</div>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (flowState.status === 'finished') {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (flowState.status === 'ready') {
|
|
156
|
-
const { currentStep, config } = flowState;
|
|
157
|
-
|
|
158
|
-
if (!currentStep || !config) {
|
|
159
|
-
return (
|
|
160
|
-
<div class="IncodeFlow">
|
|
161
|
-
<Spinner
|
|
162
|
-
title={spinnerConfig?.title ?? t('loadingCircle.hangOn')}
|
|
163
|
-
subtitle={spinnerConfig?.subtitle ?? t('loadingCircle.validating')}
|
|
164
|
-
size={spinnerConfig?.size}
|
|
165
|
-
fullScreen
|
|
166
|
-
/>
|
|
167
|
-
</div>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (moduleLoaderState.status === 'unsupported') {
|
|
172
|
-
return (
|
|
173
|
-
<div class="IncodeFlow">
|
|
174
|
-
<UnsupportedModule
|
|
175
|
-
moduleKey={currentStep}
|
|
176
|
-
onNext={() => flowManager.completeModule()}
|
|
177
|
-
/>
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
moduleLoaderState.status === 'idle' ||
|
|
184
|
-
moduleLoaderState.status === 'loading' ||
|
|
185
|
-
moduleLoaderState.status === 'error'
|
|
186
|
-
) {
|
|
187
|
-
return (
|
|
188
|
-
<div class="IncodeFlow">
|
|
189
|
-
<Spinner
|
|
190
|
-
title={spinnerConfig?.title ?? t('loadingCircle.hangOn')}
|
|
191
|
-
subtitle={spinnerConfig?.subtitle ?? t('loadingCircle.validating')}
|
|
192
|
-
size={spinnerConfig?.size}
|
|
193
|
-
fullScreen
|
|
194
|
-
/>
|
|
195
|
-
</div>
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const { Component } = moduleLoaderState;
|
|
200
|
-
|
|
201
|
-
if (currentStep === 'SELFIE') {
|
|
202
|
-
const selfieConfig = config as FlowModuleConfig['SELFIE'];
|
|
203
|
-
return (
|
|
204
|
-
<div class="IncodeFlow">
|
|
205
|
-
<Component
|
|
206
|
-
key={`selfie-${flowState.currentStepIndex}`}
|
|
207
|
-
config={selfieConfig}
|
|
208
|
-
onFinish={() => flowManager.completeModule()}
|
|
209
|
-
onError={(error: string | undefined) => {
|
|
210
|
-
onError?.(error ?? 'Selfie verification error');
|
|
211
|
-
}}
|
|
212
|
-
/>
|
|
213
|
-
</div>
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (currentStep === 'PHONE') {
|
|
218
|
-
const phoneConfig = config as FlowModuleConfig['PHONE'];
|
|
219
|
-
return (
|
|
220
|
-
<div class="IncodeFlow">
|
|
221
|
-
<Component
|
|
222
|
-
key={`phone-${flowState.currentStepIndex}`}
|
|
223
|
-
config={phoneConfig}
|
|
224
|
-
onFinish={() => flowManager.completeModule()}
|
|
225
|
-
onError={(error: string | undefined) => {
|
|
226
|
-
onError?.(error ?? 'Phone verification error');
|
|
227
|
-
}}
|
|
228
|
-
/>
|
|
229
|
-
</div>
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (currentStep === 'EMAIL') {
|
|
234
|
-
const emailConfig = config as FlowModuleConfig['EMAIL'];
|
|
235
|
-
if (
|
|
236
|
-
!emailConfig ||
|
|
237
|
-
typeof emailConfig.otpVerification !== 'boolean' ||
|
|
238
|
-
typeof emailConfig.otpExpirationInMinutes !== 'number'
|
|
239
|
-
) {
|
|
240
|
-
return (
|
|
241
|
-
<div class="IncodeFlow">
|
|
242
|
-
<div>Error: Invalid email configuration</div>
|
|
243
|
-
</div>
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
return (
|
|
247
|
-
<div class="IncodeFlow">
|
|
248
|
-
<Component
|
|
249
|
-
key={`email-${flowState.currentStepIndex}`}
|
|
250
|
-
config={{
|
|
251
|
-
...emailConfig,
|
|
252
|
-
prefill: emailConfig.prefill ?? false,
|
|
253
|
-
}}
|
|
254
|
-
onFinish={() => flowManager.completeModule()}
|
|
255
|
-
onError={(error: string | undefined) => {
|
|
256
|
-
onError?.(error ?? 'Email verification error');
|
|
257
|
-
}}
|
|
258
|
-
/>
|
|
259
|
-
</div>
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return null;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
export const IncodeFlow: FC<IncodeFlowProps> = (props) => (
|
|
268
|
-
<div class="IncodeComponent">
|
|
269
|
-
<IncodeFlowContent {...props} />
|
|
270
|
-
</div>
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
register(
|
|
274
|
-
IncodeFlow,
|
|
275
|
-
'incode-flow',
|
|
276
|
-
[
|
|
277
|
-
'apiURL',
|
|
278
|
-
'token',
|
|
279
|
-
'wasmConfig',
|
|
280
|
-
'lang',
|
|
281
|
-
'disableDashboardTheme',
|
|
282
|
-
'spinnerConfig',
|
|
283
|
-
'onComplete',
|
|
284
|
-
'onError',
|
|
285
|
-
],
|
|
286
|
-
{
|
|
287
|
-
shadow: false,
|
|
288
|
-
},
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
export type { PreloadHandle } from './preloadFlow';
|
|
292
|
-
export { preloadIncodeFlow } from './preloadFlow';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
@reference "../styles/tailwind.css";
|
|
2
|
-
|
|
3
|
-
.IncodeFlowCompleted {
|
|
4
|
-
@apply flex flex-col items-center justify-center h-full w-full p-20;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.IncodeComponent .IncodeFlowCompleted h1.IncodeFlowCompletedTitle {
|
|
8
|
-
font-size: 2rem;
|
|
9
|
-
margin: 20px 0;
|
|
10
|
-
font-weight: 700;
|
|
11
|
-
color: #20263d;
|
|
12
|
-
text-align: left;
|
|
13
|
-
width: 100%;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.IncodeComponent .IncodeFlowCompleted p.IncodeFlowCompletedSubtitle {
|
|
17
|
-
font-size: 1rem;
|
|
18
|
-
margin: 20px 0;
|
|
19
|
-
font-weight: 700;
|
|
20
|
-
color: #20263d;
|
|
21
|
-
text-align: left;
|
|
22
|
-
width: 100%;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@media screen and (min-width: 992px) {
|
|
26
|
-
.IncodeComponent .IncodeFlowCompleted h1.IncodeFlowCompletedTitle,
|
|
27
|
-
.IncodeComponent .IncodeFlowCompleted p.IncodeFlowCompletedSubtitle {
|
|
28
|
-
text-align: center;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/preact';
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import { FlowCompleted } from './flowCompleted';
|
|
4
|
-
|
|
5
|
-
describe('FlowCompleted', () => {
|
|
6
|
-
const originalLocation = window.location;
|
|
7
|
-
const mockLocation = {
|
|
8
|
-
...originalLocation,
|
|
9
|
-
href: '',
|
|
10
|
-
origin: 'https://example.com',
|
|
11
|
-
search: '',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
vi.clearAllMocks();
|
|
16
|
-
vi.useFakeTimers();
|
|
17
|
-
Object.defineProperty(window, 'location', {
|
|
18
|
-
writable: true,
|
|
19
|
-
value: mockLocation,
|
|
20
|
-
});
|
|
21
|
-
mockLocation.href = '';
|
|
22
|
-
mockLocation.search = '';
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
vi.useRealTimers();
|
|
27
|
-
Object.defineProperty(window, 'location', {
|
|
28
|
-
writable: true,
|
|
29
|
-
value: originalLocation,
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('Rendering', () => {
|
|
34
|
-
it('renders with default i18n title and message', () => {
|
|
35
|
-
render(<FlowCompleted />);
|
|
36
|
-
|
|
37
|
-
expect(screen.getByText('verificationComplete.title')).toBeTruthy();
|
|
38
|
-
expect(screen.getByText('verificationComplete.message')).toBeTruthy();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('renders with custom title', () => {
|
|
42
|
-
render(<FlowCompleted title="Custom Title" />);
|
|
43
|
-
|
|
44
|
-
expect(screen.getByText('Custom Title')).toBeTruthy();
|
|
45
|
-
expect(screen.getByText('verificationComplete.message')).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('renders with custom message', () => {
|
|
49
|
-
render(<FlowCompleted message="Custom Message" />);
|
|
50
|
-
|
|
51
|
-
expect(screen.getByText('verificationComplete.title')).toBeTruthy();
|
|
52
|
-
expect(screen.getByText('Custom Message')).toBeTruthy();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('renders with both custom title and message', () => {
|
|
56
|
-
render(<FlowCompleted title="Custom Title" message="Custom Message" />);
|
|
57
|
-
|
|
58
|
-
expect(screen.getByText('Custom Title')).toBeTruthy();
|
|
59
|
-
expect(screen.getByText('Custom Message')).toBeTruthy();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('renders with section element and correct structure', () => {
|
|
63
|
-
const { container } = render(
|
|
64
|
-
<FlowCompleted title="Test Title" message="Test Message" />,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const section = container.querySelector('section.IncodeFlowCompleted');
|
|
68
|
-
expect(section).toBeTruthy();
|
|
69
|
-
expect(section?.getAttribute('aria-live')).toBe('assertive');
|
|
70
|
-
expect(screen.getByText('Test Title')).toBeTruthy();
|
|
71
|
-
expect(screen.getByText('Test Message')).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('renders with IncodeFlowCompleted wrapper class', () => {
|
|
75
|
-
const { container } = render(<FlowCompleted />);
|
|
76
|
-
|
|
77
|
-
const wrapper = container.querySelector('.IncodeFlowCompleted');
|
|
78
|
-
expect(wrapper).toBeTruthy();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('Redirect functionality', () => {
|
|
83
|
-
it('redirects after default delay (3000ms)', async () => {
|
|
84
|
-
render(<FlowCompleted redirectionUrl="https://example.com/redirect" />);
|
|
85
|
-
|
|
86
|
-
expect(mockLocation.href).toBe('');
|
|
87
|
-
|
|
88
|
-
await vi.runAllTimersAsync();
|
|
89
|
-
|
|
90
|
-
expect(mockLocation.href).toBe('https://example.com/redirect');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('redirects after custom delay', async () => {
|
|
94
|
-
render(
|
|
95
|
-
<FlowCompleted
|
|
96
|
-
redirectionUrl="https://example.com/redirect"
|
|
97
|
-
redirectDelay={5000}
|
|
98
|
-
/>,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
expect(mockLocation.href).toBe('');
|
|
102
|
-
|
|
103
|
-
vi.advanceTimersByTime(4999);
|
|
104
|
-
expect(mockLocation.href).toBe('');
|
|
105
|
-
|
|
106
|
-
await vi.runAllTimersAsync();
|
|
107
|
-
|
|
108
|
-
expect(mockLocation.href).toBe('https://example.com/redirect');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('does not redirect when disableRedirect is true', async () => {
|
|
112
|
-
render(
|
|
113
|
-
<FlowCompleted
|
|
114
|
-
redirectionUrl="https://example.com/redirect"
|
|
115
|
-
disableRedirect
|
|
116
|
-
/>,
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
await vi.runAllTimersAsync();
|
|
120
|
-
|
|
121
|
-
expect(mockLocation.href).toBe('');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('does not redirect when redirectionUrl is not provided', async () => {
|
|
125
|
-
render(<FlowCompleted />);
|
|
126
|
-
|
|
127
|
-
await vi.runAllTimersAsync();
|
|
128
|
-
|
|
129
|
-
expect(mockLocation.href).toBe('');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('does not redirect when redirectOriginOnly is true and isRedirect query param is present', async () => {
|
|
133
|
-
mockLocation.search = '?isRedirect=true';
|
|
134
|
-
render(
|
|
135
|
-
<FlowCompleted
|
|
136
|
-
redirectionUrl="https://example.com/redirect"
|
|
137
|
-
redirectOriginOnly
|
|
138
|
-
/>,
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
await vi.runAllTimersAsync();
|
|
142
|
-
|
|
143
|
-
expect(mockLocation.href).toBe('');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('redirects when redirectOriginOnly is true but isRedirect query param is not present', async () => {
|
|
147
|
-
mockLocation.search = '';
|
|
148
|
-
render(
|
|
149
|
-
<FlowCompleted
|
|
150
|
-
redirectionUrl="https://example.com/redirect"
|
|
151
|
-
redirectOriginOnly
|
|
152
|
-
/>,
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
await vi.runAllTimersAsync();
|
|
156
|
-
|
|
157
|
-
expect(mockLocation.href).toBe('https://example.com/redirect');
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
describe('URL query parameter handling', () => {
|
|
162
|
-
it('adds flowId to redirect URL', async () => {
|
|
163
|
-
render(
|
|
164
|
-
<FlowCompleted
|
|
165
|
-
redirectionUrl="https://example.com/redirect"
|
|
166
|
-
flowId="test-flow-id"
|
|
167
|
-
/>,
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
await vi.runAllTimersAsync();
|
|
171
|
-
|
|
172
|
-
expect(mockLocation.href).toBe(
|
|
173
|
-
'https://example.com/redirect?flowId=test-flow-id',
|
|
174
|
-
);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('adds interviewId to redirect URL when origins differ', async () => {
|
|
178
|
-
mockLocation.origin = 'https://example.com';
|
|
179
|
-
render(
|
|
180
|
-
<FlowCompleted
|
|
181
|
-
redirectionUrl="https://other-domain.com/redirect"
|
|
182
|
-
flowId="test-flow-id"
|
|
183
|
-
interviewId="test-interview-id"
|
|
184
|
-
/>,
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
await vi.runAllTimersAsync();
|
|
188
|
-
|
|
189
|
-
const url = new URL(mockLocation.href);
|
|
190
|
-
expect(url.searchParams.get('flowId')).toBe('test-flow-id');
|
|
191
|
-
expect(url.searchParams.get('interviewId')).toBe('test-interview-id');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('does not add interviewId when origins match', async () => {
|
|
195
|
-
mockLocation.origin = 'https://example.com';
|
|
196
|
-
render(
|
|
197
|
-
<FlowCompleted
|
|
198
|
-
redirectionUrl="https://example.com/redirect"
|
|
199
|
-
flowId="test-flow-id"
|
|
200
|
-
interviewId="test-interview-id"
|
|
201
|
-
/>,
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
await vi.runAllTimersAsync();
|
|
205
|
-
|
|
206
|
-
const url = new URL(mockLocation.href);
|
|
207
|
-
expect(url.searchParams.get('flowId')).toBe('test-flow-id');
|
|
208
|
-
expect(url.searchParams.get('interviewId')).toBeNull();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('handles invalid URL gracefully', async () => {
|
|
212
|
-
render(
|
|
213
|
-
<FlowCompleted
|
|
214
|
-
redirectionUrl="not-a-valid-url"
|
|
215
|
-
flowId="test-flow-id"
|
|
216
|
-
interviewId="test-interview-id"
|
|
217
|
-
/>,
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
await vi.runAllTimersAsync();
|
|
221
|
-
|
|
222
|
-
expect(mockLocation.href).toContain('not-a-valid-url');
|
|
223
|
-
expect(mockLocation.href).toContain('flowId=test-flow-id');
|
|
224
|
-
expect(mockLocation.href).toContain('interviewId=test-interview-id');
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('handles URL with existing query parameters', async () => {
|
|
228
|
-
render(
|
|
229
|
-
<FlowCompleted
|
|
230
|
-
redirectionUrl="https://example.com/redirect?existing=param"
|
|
231
|
-
flowId="test-flow-id"
|
|
232
|
-
/>,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
await vi.runAllTimersAsync();
|
|
236
|
-
|
|
237
|
-
const url = new URL(mockLocation.href);
|
|
238
|
-
expect(url.searchParams.get('existing')).toBe('param');
|
|
239
|
-
expect(url.searchParams.get('flowId')).toBe('test-flow-id');
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
describe('Props handling', () => {
|
|
244
|
-
it('accepts action prop without affecting rendering', () => {
|
|
245
|
-
const { container } = render(
|
|
246
|
-
<FlowCompleted action="approved" title="Test" />,
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
expect(container.querySelector('.IncodeFlowCompleted')).toBeTruthy();
|
|
250
|
-
expect(screen.getByText('Test')).toBeTruthy();
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('accepts scoreStatus prop without affecting rendering', () => {
|
|
254
|
-
const { container } = render(
|
|
255
|
-
<FlowCompleted scoreStatus="OK" title="Test" />,
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
expect(container.querySelector('.IncodeFlowCompleted')).toBeTruthy();
|
|
259
|
-
expect(screen.getByText('Test')).toBeTruthy();
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('handles all scoreStatus values', () => {
|
|
263
|
-
const statuses = [
|
|
264
|
-
'OK',
|
|
265
|
-
'WARN',
|
|
266
|
-
'MANUAL_OK',
|
|
267
|
-
'FAIL',
|
|
268
|
-
'UNKNOWN',
|
|
269
|
-
'MANUAL_FAIL',
|
|
270
|
-
] as const;
|
|
271
|
-
|
|
272
|
-
statuses.forEach((status) => {
|
|
273
|
-
const { unmount } = render(
|
|
274
|
-
<FlowCompleted scoreStatus={status} title="Test" />,
|
|
275
|
-
);
|
|
276
|
-
expect(screen.getByText('Test')).toBeTruthy();
|
|
277
|
-
unmount();
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('handles all action values', () => {
|
|
282
|
-
const actions = ['approved', 'rejected', 'none'] as const;
|
|
283
|
-
|
|
284
|
-
actions.forEach((action) => {
|
|
285
|
-
const { unmount } = render(
|
|
286
|
-
<FlowCompleted action={action} title="Test" />,
|
|
287
|
-
);
|
|
288
|
-
expect(screen.getByText('Test')).toBeTruthy();
|
|
289
|
-
unmount();
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
describe('Edge cases', () => {
|
|
295
|
-
it('handles empty strings for title and message', () => {
|
|
296
|
-
render(<FlowCompleted title="" message="" />);
|
|
297
|
-
|
|
298
|
-
expect(screen.getByText('verificationComplete.title')).toBeTruthy();
|
|
299
|
-
expect(screen.getByText('verificationComplete.message')).toBeTruthy();
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('handles very long redirect delay', async () => {
|
|
303
|
-
render(
|
|
304
|
-
<FlowCompleted
|
|
305
|
-
redirectionUrl="https://example.com/redirect"
|
|
306
|
-
redirectDelay={100000}
|
|
307
|
-
/>,
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
vi.advanceTimersByTime(99999);
|
|
311
|
-
expect(mockLocation.href).toBe('');
|
|
312
|
-
|
|
313
|
-
await vi.runAllTimersAsync();
|
|
314
|
-
|
|
315
|
-
expect(mockLocation.href).toBe('https://example.com/redirect');
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('handles zero redirect delay', async () => {
|
|
319
|
-
render(
|
|
320
|
-
<FlowCompleted
|
|
321
|
-
redirectionUrl="https://example.com/redirect"
|
|
322
|
-
redirectDelay={0}
|
|
323
|
-
/>,
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
await vi.runAllTimersAsync();
|
|
327
|
-
|
|
328
|
-
expect(mockLocation.href).toBe('https://example.com/redirect');
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
});
|