@incodetech/core 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +51 -0
- package/src/camera/cameraActor.ts +21 -0
- package/src/camera/cameraService.test.ts +437 -0
- package/src/camera/cameraService.ts +165 -0
- package/src/camera/cameraServices.test.ts +66 -0
- package/src/camera/cameraServices.ts +26 -0
- package/src/camera/cameraStateMachine.test.ts +602 -0
- package/src/camera/cameraStateMachine.ts +264 -0
- package/src/camera/index.ts +5 -0
- package/src/camera/types.ts +17 -0
- package/src/device/getBrowser.ts +31 -0
- package/src/device/getDeviceClass.ts +29 -0
- package/src/device/index.ts +2 -0
- package/src/email/__mocks__/emailMocks.ts +59 -0
- package/src/email/emailActor.ts +15 -0
- package/src/email/emailManager.test.ts +573 -0
- package/src/email/emailManager.ts +427 -0
- package/src/email/emailServices.ts +66 -0
- package/src/email/emailStateMachine.test.ts +741 -0
- package/src/email/emailStateMachine.ts +367 -0
- package/src/email/index.ts +39 -0
- package/src/email/types.ts +60 -0
- package/src/events/addEvent.ts +20 -0
- package/src/events/types.ts +7 -0
- package/src/flow/__mocks__/flowMocks.ts +84 -0
- package/src/flow/flowActor.ts +13 -0
- package/src/flow/flowAnalyzer.test.ts +266 -0
- package/src/flow/flowAnalyzer.ts +37 -0
- package/src/flow/flowCompletionService.ts +21 -0
- package/src/flow/flowManager.test.ts +560 -0
- package/src/flow/flowManager.ts +235 -0
- package/src/flow/flowServices.test.ts +109 -0
- package/src/flow/flowServices.ts +13 -0
- package/src/flow/flowStateMachine.test.ts +334 -0
- package/src/flow/flowStateMachine.ts +182 -0
- package/src/flow/index.ts +21 -0
- package/src/flow/moduleLoader.test.ts +136 -0
- package/src/flow/moduleLoader.ts +73 -0
- package/src/flow/orchestratedFlowManager.test.ts +240 -0
- package/src/flow/orchestratedFlowManager.ts +231 -0
- package/src/flow/orchestratedFlowStateMachine.test.ts +199 -0
- package/src/flow/orchestratedFlowStateMachine.ts +325 -0
- package/src/flow/types.ts +434 -0
- package/src/http/__mocks__/api.ts +88 -0
- package/src/http/api.test.ts +231 -0
- package/src/http/api.ts +90 -0
- package/src/http/endpoints.ts +17 -0
- package/src/index.ts +33 -0
- package/src/permissions/index.ts +2 -0
- package/src/permissions/permissionServices.ts +31 -0
- package/src/permissions/types.ts +3 -0
- package/src/phone/__mocks__/phoneMocks.ts +71 -0
- package/src/phone/index.ts +39 -0
- package/src/phone/phoneActor.ts +15 -0
- package/src/phone/phoneManager.test.ts +393 -0
- package/src/phone/phoneManager.ts +458 -0
- package/src/phone/phoneServices.ts +98 -0
- package/src/phone/phoneStateMachine.test.ts +918 -0
- package/src/phone/phoneStateMachine.ts +422 -0
- package/src/phone/types.ts +83 -0
- package/src/recordings/recordingsRepository.test.ts +87 -0
- package/src/recordings/recordingsRepository.ts +48 -0
- package/src/recordings/streamingEvents.ts +10 -0
- package/src/selfie/__mocks__/selfieMocks.ts +26 -0
- package/src/selfie/index.ts +14 -0
- package/src/selfie/selfieActor.ts +17 -0
- package/src/selfie/selfieErrorUtils.test.ts +116 -0
- package/src/selfie/selfieErrorUtils.ts +66 -0
- package/src/selfie/selfieManager.test.ts +297 -0
- package/src/selfie/selfieManager.ts +301 -0
- package/src/selfie/selfieServices.ts +362 -0
- package/src/selfie/selfieStateMachine.test.ts +283 -0
- package/src/selfie/selfieStateMachine.ts +804 -0
- package/src/selfie/selfieUploadService.test.ts +90 -0
- package/src/selfie/selfieUploadService.ts +81 -0
- package/src/selfie/types.ts +103 -0
- package/src/session/index.ts +5 -0
- package/src/session/sessionService.ts +78 -0
- package/src/setup.test.ts +61 -0
- package/src/setup.ts +171 -0
- package/tsconfig.json +13 -0
- package/tsdown.config.ts +22 -0
- package/vitest.config.ts +37 -0
- package/vitest.setup.ts +135 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getRequiredWasmPipelines } from './flowAnalyzer';
|
|
3
|
+
import type { Flow } from './types';
|
|
4
|
+
|
|
5
|
+
describe('getRequiredWasmPipelines', () => {
|
|
6
|
+
it('should return empty array for flow with no WASM modules', () => {
|
|
7
|
+
const flow: Flow = {
|
|
8
|
+
flowId: 'test-flow',
|
|
9
|
+
name: 'Test Flow',
|
|
10
|
+
flowModules: [
|
|
11
|
+
{
|
|
12
|
+
key: 'PHONE',
|
|
13
|
+
configuration: {
|
|
14
|
+
otpVerification: true,
|
|
15
|
+
otpExpirationInMinutes: 5,
|
|
16
|
+
prefill: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: 'EMAIL',
|
|
21
|
+
configuration: {
|
|
22
|
+
otpVerification: true,
|
|
23
|
+
otpExpirationInMinutes: 5,
|
|
24
|
+
prefill: false,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
31
|
+
expect(pipelines).toEqual([]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should return selfie pipeline for SELFIE module', () => {
|
|
35
|
+
const flow: Flow = {
|
|
36
|
+
flowId: 'test-flow',
|
|
37
|
+
name: 'Test Flow',
|
|
38
|
+
flowModules: [
|
|
39
|
+
{
|
|
40
|
+
key: 'SELFIE',
|
|
41
|
+
configuration: {
|
|
42
|
+
showTutorial: true,
|
|
43
|
+
showPreview: false,
|
|
44
|
+
assistedOnboarding: false,
|
|
45
|
+
enableFaceRecording: false,
|
|
46
|
+
autoCaptureTimeout: 5000,
|
|
47
|
+
captureAttempts: 3,
|
|
48
|
+
validateLenses: false,
|
|
49
|
+
validateFaceMask: false,
|
|
50
|
+
validateHeadCover: false,
|
|
51
|
+
validateClosedEyes: false,
|
|
52
|
+
validateBrightness: false,
|
|
53
|
+
deepsightLiveness: 'SINGLE_FRAME',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
60
|
+
expect(pipelines).toEqual(['selfie']);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should return idCapture pipeline for ID module', () => {
|
|
64
|
+
const flow: Flow = {
|
|
65
|
+
flowId: 'test-flow',
|
|
66
|
+
name: 'Test Flow',
|
|
67
|
+
flowModules: [
|
|
68
|
+
{
|
|
69
|
+
key: 'ID',
|
|
70
|
+
configuration: {
|
|
71
|
+
showTutorial: true,
|
|
72
|
+
enableId: true,
|
|
73
|
+
enablePassport: false,
|
|
74
|
+
onlyFront: false,
|
|
75
|
+
onlyBack: false,
|
|
76
|
+
barcodeCapture: false,
|
|
77
|
+
fetchAdditionalPage: false,
|
|
78
|
+
secondId: false,
|
|
79
|
+
thirdId: false,
|
|
80
|
+
autoCaptureTimeout: 5000,
|
|
81
|
+
deviceIdleTimeout: 30000,
|
|
82
|
+
captureAttempts: 3,
|
|
83
|
+
manualUploadIdCapture: false,
|
|
84
|
+
digitalIdsUpload: false,
|
|
85
|
+
showDocumentChooserScreen: false,
|
|
86
|
+
enableIdRecording: false,
|
|
87
|
+
usSmartCapture: false,
|
|
88
|
+
perCountryPerDocOverrides: {},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
95
|
+
expect(pipelines).toEqual(['idCapture']);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should return both pipelines for mixed modules', () => {
|
|
99
|
+
const flow: Flow = {
|
|
100
|
+
flowId: 'test-flow',
|
|
101
|
+
name: 'Test Flow',
|
|
102
|
+
flowModules: [
|
|
103
|
+
{
|
|
104
|
+
key: 'SELFIE',
|
|
105
|
+
configuration: {
|
|
106
|
+
showTutorial: true,
|
|
107
|
+
showPreview: false,
|
|
108
|
+
assistedOnboarding: false,
|
|
109
|
+
enableFaceRecording: false,
|
|
110
|
+
autoCaptureTimeout: 5000,
|
|
111
|
+
captureAttempts: 3,
|
|
112
|
+
validateLenses: false,
|
|
113
|
+
validateFaceMask: false,
|
|
114
|
+
validateHeadCover: false,
|
|
115
|
+
validateClosedEyes: false,
|
|
116
|
+
validateBrightness: false,
|
|
117
|
+
deepsightLiveness: 'SINGLE_FRAME',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: 'ID',
|
|
122
|
+
configuration: {
|
|
123
|
+
showTutorial: true,
|
|
124
|
+
enableId: true,
|
|
125
|
+
enablePassport: false,
|
|
126
|
+
onlyFront: false,
|
|
127
|
+
onlyBack: false,
|
|
128
|
+
barcodeCapture: false,
|
|
129
|
+
fetchAdditionalPage: false,
|
|
130
|
+
secondId: false,
|
|
131
|
+
thirdId: false,
|
|
132
|
+
autoCaptureTimeout: 5000,
|
|
133
|
+
deviceIdleTimeout: 30000,
|
|
134
|
+
captureAttempts: 3,
|
|
135
|
+
manualUploadIdCapture: false,
|
|
136
|
+
digitalIdsUpload: false,
|
|
137
|
+
showDocumentChooserScreen: false,
|
|
138
|
+
enableIdRecording: false,
|
|
139
|
+
usSmartCapture: false,
|
|
140
|
+
perCountryPerDocOverrides: {},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
147
|
+
expect(pipelines).toContain('selfie');
|
|
148
|
+
expect(pipelines).toContain('idCapture');
|
|
149
|
+
expect(pipelines.length).toBe(2);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should deduplicate pipelines', () => {
|
|
153
|
+
const flow: Flow = {
|
|
154
|
+
flowId: 'test-flow',
|
|
155
|
+
name: 'Test Flow',
|
|
156
|
+
flowModules: [
|
|
157
|
+
{
|
|
158
|
+
key: 'SELFIE',
|
|
159
|
+
configuration: {
|
|
160
|
+
showTutorial: true,
|
|
161
|
+
showPreview: false,
|
|
162
|
+
assistedOnboarding: false,
|
|
163
|
+
enableFaceRecording: false,
|
|
164
|
+
autoCaptureTimeout: 5000,
|
|
165
|
+
captureAttempts: 3,
|
|
166
|
+
validateLenses: false,
|
|
167
|
+
validateFaceMask: false,
|
|
168
|
+
validateHeadCover: false,
|
|
169
|
+
validateClosedEyes: false,
|
|
170
|
+
validateBrightness: false,
|
|
171
|
+
deepsightLiveness: 'SINGLE_FRAME',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
key: 'AUTHENTICATION',
|
|
176
|
+
configuration: {
|
|
177
|
+
showTutorial: true,
|
|
178
|
+
autoCaptureTimeout: 5000,
|
|
179
|
+
numberOfAttempts: 3,
|
|
180
|
+
type: 'ONE_TO_ONE',
|
|
181
|
+
deepsightLiveness: 'SINGLE_FRAME',
|
|
182
|
+
validateClosedEyes: false,
|
|
183
|
+
validateFaceMask: false,
|
|
184
|
+
validateHeadCover: false,
|
|
185
|
+
validateLenses: false,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
192
|
+
expect(pipelines).toEqual(['selfie']);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('should handle empty flow modules', () => {
|
|
196
|
+
const flow: Flow = {
|
|
197
|
+
flowId: 'test-flow',
|
|
198
|
+
name: 'Test Flow',
|
|
199
|
+
flowModules: [],
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
203
|
+
expect(pipelines).toEqual([]);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('should handle AUTHENTICATION module', () => {
|
|
207
|
+
const flow: Flow = {
|
|
208
|
+
flowId: 'test-flow',
|
|
209
|
+
name: 'Test Flow',
|
|
210
|
+
flowModules: [
|
|
211
|
+
{
|
|
212
|
+
key: 'AUTHENTICATION',
|
|
213
|
+
configuration: {
|
|
214
|
+
showTutorial: true,
|
|
215
|
+
autoCaptureTimeout: 5000,
|
|
216
|
+
numberOfAttempts: 3,
|
|
217
|
+
type: 'ONE_TO_ONE',
|
|
218
|
+
deepsightLiveness: 'SINGLE_FRAME',
|
|
219
|
+
validateClosedEyes: false,
|
|
220
|
+
validateFaceMask: false,
|
|
221
|
+
validateHeadCover: false,
|
|
222
|
+
validateLenses: false,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
229
|
+
expect(pipelines).toEqual(['selfie']);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('should handle TUTORIAL_ID module', () => {
|
|
233
|
+
const flow: Flow = {
|
|
234
|
+
flowId: 'test-flow',
|
|
235
|
+
name: 'Test Flow',
|
|
236
|
+
flowModules: [
|
|
237
|
+
{
|
|
238
|
+
key: 'TUTORIAL_ID',
|
|
239
|
+
configuration: {
|
|
240
|
+
showTutorial: true,
|
|
241
|
+
enableId: true,
|
|
242
|
+
enablePassport: false,
|
|
243
|
+
onlyFront: false,
|
|
244
|
+
onlyBack: false,
|
|
245
|
+
barcodeCapture: false,
|
|
246
|
+
fetchAdditionalPage: false,
|
|
247
|
+
secondId: false,
|
|
248
|
+
thirdId: false,
|
|
249
|
+
autoCaptureTimeout: 5000,
|
|
250
|
+
deviceIdleTimeout: 30000,
|
|
251
|
+
captureAttempts: 3,
|
|
252
|
+
manualUploadIdCapture: false,
|
|
253
|
+
digitalIdsUpload: false,
|
|
254
|
+
showDocumentChooserScreen: false,
|
|
255
|
+
enableIdRecording: false,
|
|
256
|
+
usSmartCapture: false,
|
|
257
|
+
perCountryPerDocOverrides: {},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const pipelines = getRequiredWasmPipelines(flow);
|
|
264
|
+
expect(pipelines).toEqual(['idCapture']);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { WasmPipeline } from '@incodetech/infra';
|
|
2
|
+
import type { Flow } from './types';
|
|
3
|
+
|
|
4
|
+
const WASM_MODULE_PIPELINES: Record<string, WasmPipeline> = {
|
|
5
|
+
SELFIE: 'selfie',
|
|
6
|
+
AUTHENTICATION: 'selfie',
|
|
7
|
+
FACE_MATCH: 'selfie',
|
|
8
|
+
VIDEO_ONBOARDING: 'selfie',
|
|
9
|
+
ID: 'idCapture',
|
|
10
|
+
TUTORIAL_ID: 'idCapture',
|
|
11
|
+
SECOND_ID: 'idCapture',
|
|
12
|
+
THIRD_ID: 'idCapture',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Analyzes a flow configuration and returns the WASM pipelines needed.
|
|
17
|
+
* Use this to conditionally warmup WASM only when required by the flow.
|
|
18
|
+
*
|
|
19
|
+
* @param flow - The flow configuration from /omni/onboarding/flow
|
|
20
|
+
* @returns Array of WASM pipelines needed (e.g., ['selfie', 'idCapture'])
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const pipelines = getRequiredWasmPipelines(flow);
|
|
25
|
+
* if (pipelines.length > 0) {
|
|
26
|
+
* warmupWasm({ ...wasmConfig, pipelines });
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function getRequiredWasmPipelines(flow: Flow): WasmPipeline[] {
|
|
31
|
+
const pipelines = new Set<WasmPipeline>();
|
|
32
|
+
for (const module of flow.flowModules) {
|
|
33
|
+
const pipeline = WASM_MODULE_PIPELINES[module.key];
|
|
34
|
+
if (pipeline) pipelines.add(pipeline);
|
|
35
|
+
}
|
|
36
|
+
return [...pipelines];
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { api } from '../http/api';
|
|
2
|
+
|
|
3
|
+
export type FinishStatus = {
|
|
4
|
+
redirectionUrl: string;
|
|
5
|
+
action: 'approved' | 'rejected' | 'none';
|
|
6
|
+
scoreStatus: 'OK' | 'WARN' | 'MANUAL_OK' | 'FAIL' | 'UNKNOWN' | 'MANUAL_FAIL';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type GetFinishStatusFn = (
|
|
10
|
+
flowId: string | undefined | null,
|
|
11
|
+
signal?: AbortSignal,
|
|
12
|
+
) => Promise<FinishStatus>;
|
|
13
|
+
|
|
14
|
+
export const getFinishStatus: GetFinishStatusFn = async (flowId, signal) => {
|
|
15
|
+
const url = `/omni/finish-status${flowId ? `?flowId=${flowId}` : ''}`;
|
|
16
|
+
const res = await api.get<FinishStatus>(url, { signal });
|
|
17
|
+
if (!res.ok) {
|
|
18
|
+
throw new Error(`GET ${url} failed: ${res.status} ${res.statusText}`);
|
|
19
|
+
}
|
|
20
|
+
return res.data;
|
|
21
|
+
};
|