@incodetech/core 2.0.0-alpha.1 → 2.0.0-alpha.11
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/Manager-Cy9-TMC9.d.ts +19 -0
- package/dist/OpenViduLogger-20ZYS-mT.esm.js +3 -0
- package/dist/OpenViduLogger-5b7KqNTo.esm.js +803 -0
- package/dist/StateMachine-BqPpBhOz.d.ts +2 -0
- package/dist/addEvent-s2Za-pK3.esm.js +16 -0
- package/dist/chunk-C_Yo44FK.esm.js +49 -0
- package/dist/deepsightLoader-Bn2D0REl.esm.js +25 -0
- package/dist/email.d.ts +264 -0
- package/dist/email.esm.js +479 -0
- package/dist/endpoints-B0ltwtb5.esm.js +2335 -0
- package/dist/flow.d.ts +578 -0
- package/dist/flow.esm.js +628 -0
- package/dist/getBrowser-CLEzz0Hi.esm.js +8 -0
- package/dist/index.d.ts +226 -0
- package/dist/index.esm.js +156 -0
- package/dist/lib-CykGFCEr.esm.js +11700 -0
- package/dist/permissionServices-BhD0KxsO.esm.js +66 -0
- package/dist/phone.d.ts +292 -0
- package/dist/phone.esm.js +550 -0
- package/dist/recordingsRepository-CTjaf-ER.esm.js +256 -0
- package/dist/selfie.d.ts +821 -0
- package/dist/selfie.esm.js +1087 -0
- package/dist/types-Dif6MQmX.d.ts +5 -0
- package/dist/warmup-Cijuyvoc.d.ts +55 -0
- package/dist/xstate.esm-2T5fOCTq.esm.js +3261 -0
- package/package.json +14 -11
- package/src/camera/cameraActor.ts +0 -21
- package/src/camera/cameraService.test.ts +0 -437
- package/src/camera/cameraService.ts +0 -165
- package/src/camera/cameraServices.test.ts +0 -66
- package/src/camera/cameraServices.ts +0 -26
- package/src/camera/cameraStateMachine.test.ts +0 -602
- package/src/camera/cameraStateMachine.ts +0 -264
- package/src/camera/index.ts +0 -5
- package/src/camera/types.ts +0 -17
- package/src/device/getBrowser.ts +0 -31
- package/src/device/getDeviceClass.ts +0 -29
- package/src/device/index.ts +0 -2
- package/src/email/__mocks__/emailMocks.ts +0 -59
- package/src/email/emailActor.ts +0 -15
- package/src/email/emailManager.test.ts +0 -573
- package/src/email/emailManager.ts +0 -427
- package/src/email/emailServices.ts +0 -66
- package/src/email/emailStateMachine.test.ts +0 -741
- package/src/email/emailStateMachine.ts +0 -367
- package/src/email/index.ts +0 -39
- package/src/email/types.ts +0 -60
- package/src/events/addEvent.ts +0 -20
- package/src/events/types.ts +0 -7
- package/src/flow/__mocks__/flowMocks.ts +0 -84
- package/src/flow/flowActor.ts +0 -13
- package/src/flow/flowAnalyzer.test.ts +0 -266
- package/src/flow/flowAnalyzer.ts +0 -37
- package/src/flow/flowCompletionService.ts +0 -21
- package/src/flow/flowManager.test.ts +0 -560
- package/src/flow/flowManager.ts +0 -235
- package/src/flow/flowServices.test.ts +0 -109
- package/src/flow/flowServices.ts +0 -13
- package/src/flow/flowStateMachine.test.ts +0 -334
- package/src/flow/flowStateMachine.ts +0 -182
- package/src/flow/index.ts +0 -21
- package/src/flow/moduleLoader.test.ts +0 -136
- package/src/flow/moduleLoader.ts +0 -73
- package/src/flow/orchestratedFlowManager.test.ts +0 -240
- package/src/flow/orchestratedFlowManager.ts +0 -231
- package/src/flow/orchestratedFlowStateMachine.test.ts +0 -199
- package/src/flow/orchestratedFlowStateMachine.ts +0 -325
- package/src/flow/types.ts +0 -434
- package/src/http/__mocks__/api.ts +0 -88
- package/src/http/api.test.ts +0 -231
- package/src/http/api.ts +0 -90
- package/src/http/endpoints.ts +0 -17
- package/src/index.ts +0 -33
- package/src/permissions/index.ts +0 -2
- package/src/permissions/permissionServices.ts +0 -31
- package/src/permissions/types.ts +0 -3
- package/src/phone/__mocks__/phoneMocks.ts +0 -71
- package/src/phone/index.ts +0 -39
- package/src/phone/phoneActor.ts +0 -15
- package/src/phone/phoneManager.test.ts +0 -393
- package/src/phone/phoneManager.ts +0 -458
- package/src/phone/phoneServices.ts +0 -98
- package/src/phone/phoneStateMachine.test.ts +0 -918
- package/src/phone/phoneStateMachine.ts +0 -422
- package/src/phone/types.ts +0 -83
- package/src/recordings/recordingsRepository.test.ts +0 -87
- package/src/recordings/recordingsRepository.ts +0 -48
- package/src/recordings/streamingEvents.ts +0 -10
- package/src/selfie/__mocks__/selfieMocks.ts +0 -26
- package/src/selfie/index.ts +0 -14
- package/src/selfie/selfieActor.ts +0 -17
- package/src/selfie/selfieErrorUtils.test.ts +0 -116
- package/src/selfie/selfieErrorUtils.ts +0 -66
- package/src/selfie/selfieManager.test.ts +0 -297
- package/src/selfie/selfieManager.ts +0 -301
- package/src/selfie/selfieServices.ts +0 -362
- package/src/selfie/selfieStateMachine.test.ts +0 -283
- package/src/selfie/selfieStateMachine.ts +0 -804
- package/src/selfie/selfieUploadService.test.ts +0 -90
- package/src/selfie/selfieUploadService.ts +0 -81
- package/src/selfie/types.ts +0 -103
- package/src/session/index.ts +0 -5
- package/src/session/sessionService.ts +0 -78
- package/src/setup.test.ts +0 -61
- package/src/setup.ts +0 -171
- package/tsconfig.json +0 -13
- package/tsdown.config.ts +0 -22
- package/vitest.config.ts +0 -37
- package/vitest.setup.ts +0 -135
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { assign, fromCallback, fromPromise, setup } from '@incodetech/infra';
|
|
2
|
-
import { addEvent } from '../events/addEvent';
|
|
3
|
-
import {
|
|
4
|
-
addEmail,
|
|
5
|
-
fetchEmail,
|
|
6
|
-
sendEmailOtp,
|
|
7
|
-
verifyEmailOtp,
|
|
8
|
-
} from './emailServices';
|
|
9
|
-
import type { EmailConfig } from './types';
|
|
10
|
-
|
|
11
|
-
export type EmailContext = {
|
|
12
|
-
config: EmailConfig;
|
|
13
|
-
email: string;
|
|
14
|
-
isValid: boolean;
|
|
15
|
-
emailError: string | undefined;
|
|
16
|
-
prefilledEmail: string | undefined;
|
|
17
|
-
error: string | undefined;
|
|
18
|
-
otpCode: string;
|
|
19
|
-
otpError: string | undefined;
|
|
20
|
-
attemptsRemaining: number;
|
|
21
|
-
resendTimer: number;
|
|
22
|
-
resendTimerActive: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type EmailEvent =
|
|
26
|
-
| { type: 'LOAD' }
|
|
27
|
-
| { type: 'EMAIL_CHANGED'; email: string; isValid: boolean }
|
|
28
|
-
| { type: 'SUBMIT' }
|
|
29
|
-
| { type: 'OTP_CHANGED'; code: string }
|
|
30
|
-
| { type: 'VERIFY_OTP' }
|
|
31
|
-
| { type: 'RESEND_OTP' }
|
|
32
|
-
| { type: 'BACK' }
|
|
33
|
-
| { type: 'RESET' }
|
|
34
|
-
| { type: 'TICK' };
|
|
35
|
-
|
|
36
|
-
export type EmailInput = {
|
|
37
|
-
config: EmailConfig;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const RESEND_TIMER_SECONDS = 30;
|
|
41
|
-
|
|
42
|
-
export const emailMachine = setup({
|
|
43
|
-
types: {
|
|
44
|
-
context: {} as EmailContext,
|
|
45
|
-
events: {} as EmailEvent,
|
|
46
|
-
input: {} as EmailInput,
|
|
47
|
-
},
|
|
48
|
-
actors: {
|
|
49
|
-
fetchEmail: fromPromise<{ email: string }, void>(async ({ signal }) => {
|
|
50
|
-
return fetchEmail(signal);
|
|
51
|
-
}),
|
|
52
|
-
submitEmail: fromPromise<{ success: boolean }, { email: string }>(
|
|
53
|
-
async ({ input, signal }) => {
|
|
54
|
-
return addEmail({ email: input.email }, signal);
|
|
55
|
-
},
|
|
56
|
-
),
|
|
57
|
-
sendOtp: fromPromise<void, void>(async ({ signal }) => {
|
|
58
|
-
return sendEmailOtp(signal);
|
|
59
|
-
}),
|
|
60
|
-
verifyOtp: fromPromise<{ success: boolean }, { code: string }>(
|
|
61
|
-
async ({ input, signal }) => {
|
|
62
|
-
return verifyEmailOtp(input.code, signal);
|
|
63
|
-
},
|
|
64
|
-
),
|
|
65
|
-
resendTimer: fromCallback(({ sendBack }) => {
|
|
66
|
-
let seconds = RESEND_TIMER_SECONDS;
|
|
67
|
-
const interval = setInterval(() => {
|
|
68
|
-
seconds -= 1;
|
|
69
|
-
sendBack({ type: 'TICK' });
|
|
70
|
-
if (seconds <= 0) {
|
|
71
|
-
clearInterval(interval);
|
|
72
|
-
}
|
|
73
|
-
}, 1000);
|
|
74
|
-
return () => clearInterval(interval);
|
|
75
|
-
}),
|
|
76
|
-
},
|
|
77
|
-
actions: {
|
|
78
|
-
setPrefilledEmail: assign(({ event }) => {
|
|
79
|
-
const email = (event as unknown as { output: { email: string } }).output
|
|
80
|
-
.email;
|
|
81
|
-
return {
|
|
82
|
-
prefilledEmail: email,
|
|
83
|
-
email,
|
|
84
|
-
};
|
|
85
|
-
}),
|
|
86
|
-
setEmail: assign(({ event }) => {
|
|
87
|
-
const e = event as {
|
|
88
|
-
type: 'EMAIL_CHANGED';
|
|
89
|
-
email: string;
|
|
90
|
-
isValid: boolean;
|
|
91
|
-
};
|
|
92
|
-
return {
|
|
93
|
-
email: e.email,
|
|
94
|
-
isValid: e.isValid,
|
|
95
|
-
emailError: e.isValid ? undefined : 'Invalid email address',
|
|
96
|
-
};
|
|
97
|
-
}),
|
|
98
|
-
setEmailError: assign(({ event }) => ({
|
|
99
|
-
emailError: String((event as unknown as { error: unknown }).error),
|
|
100
|
-
})),
|
|
101
|
-
setError: assign(({ event }) => ({
|
|
102
|
-
error: String((event as unknown as { error: unknown }).error),
|
|
103
|
-
})),
|
|
104
|
-
clearError: assign({
|
|
105
|
-
error: () => undefined,
|
|
106
|
-
}),
|
|
107
|
-
clearEmailError: assign({
|
|
108
|
-
emailError: () => undefined,
|
|
109
|
-
}),
|
|
110
|
-
setOtpCode: assign(({ event }) => ({
|
|
111
|
-
otpCode: (event as { type: 'OTP_CHANGED'; code: string }).code,
|
|
112
|
-
otpError: undefined,
|
|
113
|
-
})),
|
|
114
|
-
setOtpError: assign(({ context, event }) => ({
|
|
115
|
-
otpError: String((event as unknown as { error: unknown }).error),
|
|
116
|
-
attemptsRemaining: context.attemptsRemaining - 1,
|
|
117
|
-
})),
|
|
118
|
-
clearOtpError: assign({
|
|
119
|
-
otpError: () => undefined,
|
|
120
|
-
otpCode: () => '',
|
|
121
|
-
}),
|
|
122
|
-
startResendTimer: assign({
|
|
123
|
-
resendTimer: () => RESEND_TIMER_SECONDS,
|
|
124
|
-
resendTimerActive: () => true,
|
|
125
|
-
}),
|
|
126
|
-
tickResendTimer: assign(({ context }) => {
|
|
127
|
-
const newTimer = Math.max(0, context.resendTimer - 1);
|
|
128
|
-
return {
|
|
129
|
-
resendTimer: newTimer,
|
|
130
|
-
resendTimerActive: newTimer > 0,
|
|
131
|
-
};
|
|
132
|
-
}),
|
|
133
|
-
stopResendTimer: assign({
|
|
134
|
-
resendTimerActive: () => false,
|
|
135
|
-
}),
|
|
136
|
-
resetContext: assign(({ context }) => ({
|
|
137
|
-
config: context.config,
|
|
138
|
-
email: '',
|
|
139
|
-
isValid: false,
|
|
140
|
-
emailError: undefined,
|
|
141
|
-
prefilledEmail: undefined,
|
|
142
|
-
error: undefined,
|
|
143
|
-
otpCode: '',
|
|
144
|
-
otpError: undefined,
|
|
145
|
-
attemptsRemaining: context.config.maxOtpAttempts ?? 3,
|
|
146
|
-
resendTimer: 0,
|
|
147
|
-
resendTimerActive: false,
|
|
148
|
-
})),
|
|
149
|
-
sendEmailSubmitEvent: () => {
|
|
150
|
-
addEvent({
|
|
151
|
-
code: 'continue',
|
|
152
|
-
module: 'email',
|
|
153
|
-
screen: 'emailInput',
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
guards: {
|
|
158
|
-
hasPrefill: ({ context }): boolean => context.config.prefill,
|
|
159
|
-
hasOtpVerification: ({ context }): boolean =>
|
|
160
|
-
context.config.otpVerification,
|
|
161
|
-
isValidEmail: ({ context }): boolean => context.isValid,
|
|
162
|
-
hasAttemptsRemaining: ({ context }): boolean =>
|
|
163
|
-
context.attemptsRemaining > 0,
|
|
164
|
-
canResend: ({ context }): boolean => !context.resendTimerActive,
|
|
165
|
-
},
|
|
166
|
-
}).createMachine({
|
|
167
|
-
id: 'email',
|
|
168
|
-
initial: 'idle',
|
|
169
|
-
context: ({ input }) => ({
|
|
170
|
-
config: input.config,
|
|
171
|
-
email: '',
|
|
172
|
-
isValid: false,
|
|
173
|
-
emailError: undefined,
|
|
174
|
-
prefilledEmail: undefined,
|
|
175
|
-
error: undefined,
|
|
176
|
-
otpCode: '',
|
|
177
|
-
otpError: undefined,
|
|
178
|
-
attemptsRemaining: input.config.maxOtpAttempts ?? 3,
|
|
179
|
-
resendTimer: 0,
|
|
180
|
-
resendTimerActive: false,
|
|
181
|
-
}),
|
|
182
|
-
states: {
|
|
183
|
-
idle: {
|
|
184
|
-
on: {
|
|
185
|
-
LOAD: [
|
|
186
|
-
{
|
|
187
|
-
target: 'loadingPrefill',
|
|
188
|
-
guard: 'hasPrefill',
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
target: 'inputting',
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
loadingPrefill: {
|
|
198
|
-
invoke: {
|
|
199
|
-
id: 'fetchEmail',
|
|
200
|
-
src: 'fetchEmail',
|
|
201
|
-
onDone: {
|
|
202
|
-
target: 'inputting',
|
|
203
|
-
actions: 'setPrefilledEmail',
|
|
204
|
-
},
|
|
205
|
-
onError: {
|
|
206
|
-
target: 'inputting',
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
inputting: {
|
|
212
|
-
entry: 'clearEmailError',
|
|
213
|
-
on: {
|
|
214
|
-
EMAIL_CHANGED: {
|
|
215
|
-
actions: 'setEmail',
|
|
216
|
-
},
|
|
217
|
-
SUBMIT: {
|
|
218
|
-
target: 'submitting',
|
|
219
|
-
guard: 'isValidEmail',
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
submitting: {
|
|
225
|
-
invoke: {
|
|
226
|
-
id: 'submitEmail',
|
|
227
|
-
src: 'submitEmail',
|
|
228
|
-
input: ({ context }) => ({
|
|
229
|
-
email: context.email,
|
|
230
|
-
}),
|
|
231
|
-
onDone: [
|
|
232
|
-
{
|
|
233
|
-
target: 'sendingOtp',
|
|
234
|
-
guard: 'hasOtpVerification',
|
|
235
|
-
actions: 'sendEmailSubmitEvent',
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
target: 'success',
|
|
239
|
-
actions: 'sendEmailSubmitEvent',
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
onError: {
|
|
243
|
-
target: 'inputting',
|
|
244
|
-
actions: 'setEmailError',
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
sendingOtp: {
|
|
250
|
-
invoke: {
|
|
251
|
-
id: 'sendOtp',
|
|
252
|
-
src: 'sendOtp',
|
|
253
|
-
onDone: {
|
|
254
|
-
target: 'awaitingOtp',
|
|
255
|
-
},
|
|
256
|
-
onError: {
|
|
257
|
-
target: 'awaitingOtp',
|
|
258
|
-
actions: 'setError',
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
awaitingOtp: {
|
|
264
|
-
entry: 'startResendTimer',
|
|
265
|
-
invoke: {
|
|
266
|
-
id: 'resendTimer',
|
|
267
|
-
src: 'resendTimer',
|
|
268
|
-
},
|
|
269
|
-
on: {
|
|
270
|
-
TICK: {
|
|
271
|
-
actions: 'tickResendTimer',
|
|
272
|
-
},
|
|
273
|
-
OTP_CHANGED: {
|
|
274
|
-
actions: 'setOtpCode',
|
|
275
|
-
},
|
|
276
|
-
VERIFY_OTP: {
|
|
277
|
-
target: 'verifyingOtp',
|
|
278
|
-
},
|
|
279
|
-
RESEND_OTP: {
|
|
280
|
-
target: 'sendingOtp',
|
|
281
|
-
guard: 'canResend',
|
|
282
|
-
},
|
|
283
|
-
BACK: {
|
|
284
|
-
target: 'inputting',
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
verifyingOtp: {
|
|
290
|
-
invoke: {
|
|
291
|
-
id: 'verifyOtp',
|
|
292
|
-
src: 'verifyOtp',
|
|
293
|
-
input: ({ context }) => ({
|
|
294
|
-
code: context.otpCode,
|
|
295
|
-
}),
|
|
296
|
-
onDone: [
|
|
297
|
-
{
|
|
298
|
-
target: 'success',
|
|
299
|
-
guard: ({ event }) => event.output.success === true,
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
target: 'otpError',
|
|
303
|
-
guard: 'hasAttemptsRemaining',
|
|
304
|
-
actions: assign(({ context }) => ({
|
|
305
|
-
otpError: 'Invalid OTP code',
|
|
306
|
-
attemptsRemaining: context.attemptsRemaining - 1,
|
|
307
|
-
})),
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
target: 'error',
|
|
311
|
-
actions: assign({
|
|
312
|
-
error: () => 'Maximum OTP attempts exceeded',
|
|
313
|
-
}),
|
|
314
|
-
},
|
|
315
|
-
],
|
|
316
|
-
onError: [
|
|
317
|
-
{
|
|
318
|
-
target: 'otpError',
|
|
319
|
-
guard: 'hasAttemptsRemaining',
|
|
320
|
-
actions: 'setOtpError',
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
target: 'error',
|
|
324
|
-
actions: 'setError',
|
|
325
|
-
},
|
|
326
|
-
],
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
otpError: {
|
|
331
|
-
on: {
|
|
332
|
-
OTP_CHANGED: {
|
|
333
|
-
target: 'awaitingOtp',
|
|
334
|
-
actions: 'setOtpCode',
|
|
335
|
-
},
|
|
336
|
-
RESEND_OTP: {
|
|
337
|
-
target: 'sendingOtp',
|
|
338
|
-
guard: 'canResend',
|
|
339
|
-
},
|
|
340
|
-
BACK: {
|
|
341
|
-
target: 'inputting',
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
success: {
|
|
347
|
-
on: {
|
|
348
|
-
RESET: {
|
|
349
|
-
target: 'idle',
|
|
350
|
-
actions: 'resetContext',
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
error: {
|
|
356
|
-
on: {
|
|
357
|
-
RESET: {
|
|
358
|
-
target: 'idle',
|
|
359
|
-
actions: 'resetContext',
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
// biome-ignore lint/suspicious/noExplicitAny: XState type inference issue with guards in declaration files
|
|
365
|
-
}) as any;
|
|
366
|
-
|
|
367
|
-
export type EmailMachine = typeof emailMachine;
|
package/src/email/index.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Email verification module - supports headless and UI-driven usage.
|
|
3
|
-
*
|
|
4
|
-
* ## Headless Usage (Programmatic)
|
|
5
|
-
*
|
|
6
|
-
* Use `createEmailManager` to control email verification without any UI.
|
|
7
|
-
* Perfect for custom UI implementations, backend integrations, or automated testing.
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { createEmailManager } from '@incodetech/core/email';
|
|
11
|
-
*
|
|
12
|
-
* const manager = createEmailManager({
|
|
13
|
-
* config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
|
|
14
|
-
* });
|
|
15
|
-
*
|
|
16
|
-
* manager.subscribe((state) => console.log(state.status));
|
|
17
|
-
* manager.load();
|
|
18
|
-
* manager.setEmail('user@example.com', true);
|
|
19
|
-
* manager.submit();
|
|
20
|
-
* manager.submitOtp('ABC123');
|
|
21
|
-
* manager.stop();
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* ## UI Usage
|
|
25
|
-
*
|
|
26
|
-
* For a ready-to-use UI, import the Email component from `@incodetech/ui/email`.
|
|
27
|
-
*
|
|
28
|
-
* @module @incodetech/core/email
|
|
29
|
-
* @see {@link createEmailManager} for headless API documentation
|
|
30
|
-
* @see {@link EmailConfig} for configuration options
|
|
31
|
-
* @see {@link EmailState} for state machine states
|
|
32
|
-
*/
|
|
33
|
-
export {
|
|
34
|
-
createEmailManager,
|
|
35
|
-
type EmailManager,
|
|
36
|
-
type EmailState,
|
|
37
|
-
} from './emailManager';
|
|
38
|
-
export { emailMachine } from './emailStateMachine';
|
|
39
|
-
export type { EmailConfig } from './types';
|
package/src/email/types.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration options for email verification.
|
|
3
|
-
*
|
|
4
|
-
* @example Standard OTP verification
|
|
5
|
-
* ```typescript
|
|
6
|
-
* const config: EmailConfig = {
|
|
7
|
-
* otpVerification: true,
|
|
8
|
-
* otpExpirationInMinutes: 5,
|
|
9
|
-
* prefill: false,
|
|
10
|
-
* };
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @example With all options
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const config: EmailConfig = {
|
|
16
|
-
* otpVerification: true,
|
|
17
|
-
* otpExpirationInMinutes: 10,
|
|
18
|
-
* prefill: true,
|
|
19
|
-
* maxOtpAttempts: 3,
|
|
20
|
-
* };
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export type EmailConfig = {
|
|
24
|
-
/**
|
|
25
|
-
* Whether to require OTP (email code) verification.
|
|
26
|
-
* If false, email is verified immediately after submission.
|
|
27
|
-
*/
|
|
28
|
-
otpVerification: boolean;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* How long the OTP code remains valid, in minutes.
|
|
32
|
-
* After expiration, user must request a new code.
|
|
33
|
-
*/
|
|
34
|
-
otpExpirationInMinutes: number;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Whether to pre-populate with user's previously stored email address.
|
|
38
|
-
* Useful for returning users.
|
|
39
|
-
*/
|
|
40
|
-
prefill: boolean;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Maximum number of OTP verification attempts before lockout.
|
|
44
|
-
* After exhausting attempts, user sees an error state.
|
|
45
|
-
* @default 3
|
|
46
|
-
*/
|
|
47
|
-
maxOtpAttempts?: number;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export type AddEmailResponse = {
|
|
51
|
-
success: boolean;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type VerifyOtpResponse = {
|
|
55
|
-
success: boolean;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type AddEmailParams = {
|
|
59
|
-
email: string;
|
|
60
|
-
};
|
package/src/events/addEvent.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { api } from '../http/api';
|
|
2
|
-
import { endpoints } from '../http/endpoints';
|
|
3
|
-
import type { Event } from './types';
|
|
4
|
-
|
|
5
|
-
export function addEvent(event: Event): Promise<void> {
|
|
6
|
-
const { code, module, screen, clientTimestamp, payload = {} } = event;
|
|
7
|
-
|
|
8
|
-
return api
|
|
9
|
-
.post(endpoints.events, [
|
|
10
|
-
{
|
|
11
|
-
code,
|
|
12
|
-
module,
|
|
13
|
-
screen,
|
|
14
|
-
clientTimestamp: clientTimestamp ?? Date.now(),
|
|
15
|
-
payload,
|
|
16
|
-
},
|
|
17
|
-
])
|
|
18
|
-
.then(() => undefined)
|
|
19
|
-
.catch(() => undefined);
|
|
20
|
-
}
|
package/src/events/types.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
import type { Flow, FlowModule } from '../types';
|
|
3
|
-
|
|
4
|
-
export const mockTutorialIdModule: FlowModule = {
|
|
5
|
-
key: 'TUTORIAL_ID',
|
|
6
|
-
configuration: {
|
|
7
|
-
showTutorial: true,
|
|
8
|
-
enableId: true,
|
|
9
|
-
enablePassport: false,
|
|
10
|
-
onlyFront: false,
|
|
11
|
-
onlyBack: false,
|
|
12
|
-
barcodeCapture: false,
|
|
13
|
-
fetchAdditionalPage: false,
|
|
14
|
-
secondId: false,
|
|
15
|
-
thirdId: false,
|
|
16
|
-
autoCaptureTimeout: 30,
|
|
17
|
-
deviceIdleTimeout: 60,
|
|
18
|
-
captureAttempts: 3,
|
|
19
|
-
manualUploadIdCapture: false,
|
|
20
|
-
digitalIdsUpload: false,
|
|
21
|
-
showDocumentChooserScreen: false,
|
|
22
|
-
enableIdRecording: false,
|
|
23
|
-
usSmartCapture: false,
|
|
24
|
-
perCountryPerDocOverrides: {},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const mockSelfieModule: FlowModule = {
|
|
29
|
-
key: 'SELFIE',
|
|
30
|
-
configuration: {
|
|
31
|
-
showTutorial: false,
|
|
32
|
-
showPreview: true,
|
|
33
|
-
assistedOnboarding: false,
|
|
34
|
-
enableFaceRecording: false,
|
|
35
|
-
autoCaptureTimeout: 30,
|
|
36
|
-
captureAttempts: 3,
|
|
37
|
-
validateLenses: false,
|
|
38
|
-
validateFaceMask: false,
|
|
39
|
-
validateHeadCover: false,
|
|
40
|
-
validateClosedEyes: false,
|
|
41
|
-
validateBrightness: false,
|
|
42
|
-
deepsightLiveness: 'SINGLE_FRAME',
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const mockFaceMatchModule: FlowModule = {
|
|
47
|
-
key: 'FACE_MATCH',
|
|
48
|
-
configuration: {
|
|
49
|
-
matchingType: 'selfieVsId',
|
|
50
|
-
disableFaceMatchAnimation: false,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const mockModules: FlowModule[] = [
|
|
55
|
-
mockTutorialIdModule,
|
|
56
|
-
mockSelfieModule,
|
|
57
|
-
mockFaceMatchModule,
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
export function createMockFlow(modules: FlowModule[] = mockModules): Flow {
|
|
61
|
-
return {
|
|
62
|
-
flowId: 'test-flow-id',
|
|
63
|
-
name: 'Test Flow',
|
|
64
|
-
flowModules: modules,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const mockFlow = createMockFlow();
|
|
69
|
-
|
|
70
|
-
export function createMockGetFlow(flow: Flow = mockFlow) {
|
|
71
|
-
return vi.fn().mockResolvedValue(flow);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function createFailingGetFlow(error: string) {
|
|
75
|
-
return vi.fn().mockRejectedValue(new Error(error));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function createDelayedGetFlow(flow: Flow = mockFlow, delayMs = 1000) {
|
|
79
|
-
return vi
|
|
80
|
-
.fn()
|
|
81
|
-
.mockImplementation(
|
|
82
|
-
() => new Promise((resolve) => setTimeout(() => resolve(flow), delayMs)),
|
|
83
|
-
);
|
|
84
|
-
}
|
package/src/flow/flowActor.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createActor } from '@incodetech/infra';
|
|
2
|
-
import { getFlow as defaultGetFlow, type GetFlow } from './flowServices';
|
|
3
|
-
import { flowMachine } from './flowStateMachine';
|
|
4
|
-
|
|
5
|
-
export type CreateFlowActorOptions = {
|
|
6
|
-
getFlow?: GetFlow;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function createFlowActor(options?: CreateFlowActorOptions) {
|
|
10
|
-
const getFlow = options?.getFlow ?? defaultGetFlow;
|
|
11
|
-
|
|
12
|
-
return createActor(flowMachine, { input: { getFlow } }).start();
|
|
13
|
-
}
|