@incodetech/core 2.0.0-alpha.2 → 2.0.0-alpha.3

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.
Files changed (134) hide show
  1. package/package.json +4 -1
  2. package/.turbo/turbo-build.log +0 -33
  3. package/.turbo/turbo-coverage.log +0 -22
  4. package/.turbo/turbo-format.log +0 -6
  5. package/.turbo/turbo-lint$colon$fix.log +0 -77
  6. package/.turbo/turbo-lint.log +0 -95
  7. package/.turbo/turbo-test.log +0 -870
  8. package/.turbo/turbo-typecheck.log +0 -5
  9. package/coverage/base.css +0 -224
  10. package/coverage/block-navigation.js +0 -87
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +0 -221
  13. package/coverage/prettify.css +0 -1
  14. package/coverage/prettify.js +0 -2
  15. package/coverage/sort-arrow-sprite.png +0 -0
  16. package/coverage/sorter.js +0 -210
  17. package/coverage/src/camera/cameraService.ts.html +0 -580
  18. package/coverage/src/camera/cameraServices.ts.html +0 -163
  19. package/coverage/src/camera/cameraStateMachine.ts.html +0 -877
  20. package/coverage/src/camera/index.html +0 -146
  21. package/coverage/src/email/emailActor.ts.html +0 -130
  22. package/coverage/src/email/emailManager.ts.html +0 -1366
  23. package/coverage/src/email/emailStateMachine.ts.html +0 -1186
  24. package/coverage/src/email/index.html +0 -146
  25. package/coverage/src/flow/flowActor.ts.html +0 -124
  26. package/coverage/src/flow/flowAnalyzer.ts.html +0 -196
  27. package/coverage/src/flow/flowManager.ts.html +0 -790
  28. package/coverage/src/flow/flowServices.ts.html +0 -124
  29. package/coverage/src/flow/flowStateMachine.ts.html +0 -631
  30. package/coverage/src/flow/index.html +0 -221
  31. package/coverage/src/flow/moduleLoader.ts.html +0 -304
  32. package/coverage/src/flow/orchestratedFlowManager.ts.html +0 -778
  33. package/coverage/src/flow/orchestratedFlowStateMachine.ts.html +0 -1060
  34. package/coverage/src/http/api.ts.html +0 -355
  35. package/coverage/src/http/endpoints.ts.html +0 -136
  36. package/coverage/src/http/index.html +0 -131
  37. package/coverage/src/index.html +0 -116
  38. package/coverage/src/phone/index.html +0 -146
  39. package/coverage/src/phone/phoneActor.ts.html +0 -130
  40. package/coverage/src/phone/phoneManager.ts.html +0 -1459
  41. package/coverage/src/phone/phoneStateMachine.ts.html +0 -1351
  42. package/coverage/src/recordings/index.html +0 -116
  43. package/coverage/src/recordings/recordingsRepository.ts.html +0 -229
  44. package/coverage/src/selfie/index.html +0 -191
  45. package/coverage/src/selfie/selfieActor.ts.html +0 -136
  46. package/coverage/src/selfie/selfieErrorUtils.ts.html +0 -283
  47. package/coverage/src/selfie/selfieManager.ts.html +0 -988
  48. package/coverage/src/selfie/selfieStateMachine.ts.html +0 -2497
  49. package/coverage/src/selfie/selfieUploadService.ts.html +0 -328
  50. package/coverage/src/selfie/types.ts.html +0 -394
  51. package/coverage/src/setup.ts.html +0 -598
  52. package/src/camera/cameraActor.ts +0 -21
  53. package/src/camera/cameraService.test.ts +0 -437
  54. package/src/camera/cameraService.ts +0 -165
  55. package/src/camera/cameraServices.test.ts +0 -66
  56. package/src/camera/cameraServices.ts +0 -26
  57. package/src/camera/cameraStateMachine.test.ts +0 -602
  58. package/src/camera/cameraStateMachine.ts +0 -264
  59. package/src/camera/index.ts +0 -5
  60. package/src/camera/types.ts +0 -17
  61. package/src/device/getBrowser.ts +0 -31
  62. package/src/device/getDeviceClass.ts +0 -29
  63. package/src/device/index.ts +0 -2
  64. package/src/email/__mocks__/emailMocks.ts +0 -59
  65. package/src/email/emailActor.ts +0 -15
  66. package/src/email/emailManager.test.ts +0 -573
  67. package/src/email/emailManager.ts +0 -427
  68. package/src/email/emailServices.ts +0 -66
  69. package/src/email/emailStateMachine.test.ts +0 -741
  70. package/src/email/emailStateMachine.ts +0 -367
  71. package/src/email/index.ts +0 -39
  72. package/src/email/types.ts +0 -60
  73. package/src/events/addEvent.ts +0 -20
  74. package/src/events/types.ts +0 -7
  75. package/src/flow/__mocks__/flowMocks.ts +0 -84
  76. package/src/flow/flowActor.ts +0 -13
  77. package/src/flow/flowAnalyzer.test.ts +0 -266
  78. package/src/flow/flowAnalyzer.ts +0 -37
  79. package/src/flow/flowCompletionService.ts +0 -21
  80. package/src/flow/flowManager.test.ts +0 -560
  81. package/src/flow/flowManager.ts +0 -235
  82. package/src/flow/flowServices.test.ts +0 -109
  83. package/src/flow/flowServices.ts +0 -13
  84. package/src/flow/flowStateMachine.test.ts +0 -334
  85. package/src/flow/flowStateMachine.ts +0 -182
  86. package/src/flow/index.ts +0 -21
  87. package/src/flow/moduleLoader.test.ts +0 -136
  88. package/src/flow/moduleLoader.ts +0 -73
  89. package/src/flow/orchestratedFlowManager.test.ts +0 -240
  90. package/src/flow/orchestratedFlowManager.ts +0 -231
  91. package/src/flow/orchestratedFlowStateMachine.test.ts +0 -199
  92. package/src/flow/orchestratedFlowStateMachine.ts +0 -325
  93. package/src/flow/types.ts +0 -434
  94. package/src/http/__mocks__/api.ts +0 -88
  95. package/src/http/api.test.ts +0 -231
  96. package/src/http/api.ts +0 -90
  97. package/src/http/endpoints.ts +0 -17
  98. package/src/index.ts +0 -33
  99. package/src/permissions/index.ts +0 -2
  100. package/src/permissions/permissionServices.ts +0 -31
  101. package/src/permissions/types.ts +0 -3
  102. package/src/phone/__mocks__/phoneMocks.ts +0 -71
  103. package/src/phone/index.ts +0 -39
  104. package/src/phone/phoneActor.ts +0 -15
  105. package/src/phone/phoneManager.test.ts +0 -393
  106. package/src/phone/phoneManager.ts +0 -458
  107. package/src/phone/phoneServices.ts +0 -98
  108. package/src/phone/phoneStateMachine.test.ts +0 -918
  109. package/src/phone/phoneStateMachine.ts +0 -422
  110. package/src/phone/types.ts +0 -83
  111. package/src/recordings/recordingsRepository.test.ts +0 -87
  112. package/src/recordings/recordingsRepository.ts +0 -48
  113. package/src/recordings/streamingEvents.ts +0 -10
  114. package/src/selfie/__mocks__/selfieMocks.ts +0 -26
  115. package/src/selfie/index.ts +0 -14
  116. package/src/selfie/selfieActor.ts +0 -17
  117. package/src/selfie/selfieErrorUtils.test.ts +0 -116
  118. package/src/selfie/selfieErrorUtils.ts +0 -66
  119. package/src/selfie/selfieManager.test.ts +0 -297
  120. package/src/selfie/selfieManager.ts +0 -301
  121. package/src/selfie/selfieServices.ts +0 -362
  122. package/src/selfie/selfieStateMachine.test.ts +0 -283
  123. package/src/selfie/selfieStateMachine.ts +0 -804
  124. package/src/selfie/selfieUploadService.test.ts +0 -90
  125. package/src/selfie/selfieUploadService.ts +0 -81
  126. package/src/selfie/types.ts +0 -103
  127. package/src/session/index.ts +0 -5
  128. package/src/session/sessionService.ts +0 -78
  129. package/src/setup.test.ts +0 -61
  130. package/src/setup.ts +0 -171
  131. package/tsconfig.json +0 -13
  132. package/tsdown.config.ts +0 -22
  133. package/vitest.config.ts +0 -37
  134. package/vitest.setup.ts +0 -135
@@ -1,422 +0,0 @@
1
- import { assign, fromCallback, fromPromise, setup } from '@incodetech/infra';
2
- import { addEvent } from '../events/addEvent';
3
- import {
4
- addPhone,
5
- addPhoneInstantVerify,
6
- fetchPhone,
7
- fetchStartInfo,
8
- sendOtp,
9
- verifyOtp,
10
- } from './phoneServices';
11
- import type { PhoneConfig, StartInfo } from './types';
12
-
13
- export type PhoneContext = {
14
- config: PhoneConfig;
15
- phone: string;
16
- isValid: boolean;
17
- phoneError: string | undefined;
18
- countryCode: string;
19
- phonePrefix: string;
20
- prefilledPhone: string | undefined;
21
- optInGranted: boolean;
22
- startInfo: StartInfo | undefined;
23
- error: string | undefined;
24
- otpCode: string;
25
- otpError: string | undefined;
26
- attemptsRemaining: number;
27
- resendTimer: number;
28
- resendTimerActive: boolean;
29
- };
30
-
31
- export type PhoneEvent =
32
- | { type: 'LOAD' }
33
- | { type: 'PHONE_CHANGED'; phone: string; isValid: boolean }
34
- | { type: 'OPT_IN_CHANGED'; granted: boolean }
35
- | { type: 'SUBMIT' }
36
- | { type: 'OTP_CHANGED'; code: string }
37
- | { type: 'VERIFY_OTP' }
38
- | { type: 'RESEND_OTP' }
39
- | { type: 'BACK' }
40
- | { type: 'RESET' };
41
-
42
- export type PhoneInput = {
43
- config: PhoneConfig;
44
- };
45
-
46
- const RESEND_TIMER_SECONDS = 30;
47
-
48
- export const phoneMachine = setup({
49
- types: {
50
- context: {} as PhoneContext,
51
- events: {} as PhoneEvent,
52
- input: {} as PhoneInput,
53
- },
54
- actors: {
55
- fetchPhone: fromPromise<{ phone: string }, void>(async ({ signal }) => {
56
- return fetchPhone(signal);
57
- }),
58
- fetchStartInfo: fromPromise<StartInfo, void>(async ({ signal }) => {
59
- return fetchStartInfo(signal);
60
- }),
61
- submitPhone: fromPromise<
62
- { success: boolean },
63
- { phone: string; optInGranted?: boolean; isInstantVerify: boolean }
64
- >(async ({ input, signal }) => {
65
- if (input.isInstantVerify) {
66
- return addPhoneInstantVerify(
67
- { phone: input.phone, optInGranted: input.optInGranted },
68
- signal,
69
- );
70
- }
71
- return addPhone(
72
- { phone: input.phone, optInGranted: input.optInGranted },
73
- signal,
74
- );
75
- }),
76
- sendOtp: fromPromise<void, void>(async ({ signal }) => {
77
- return sendOtp(signal);
78
- }),
79
- verifyOtp: fromPromise<{ success: boolean }, { code: string }>(
80
- async ({ input, signal }) => {
81
- return verifyOtp(input.code, signal);
82
- },
83
- ),
84
- resendTimer: fromCallback(({ sendBack }) => {
85
- let seconds = RESEND_TIMER_SECONDS;
86
- const interval = setInterval(() => {
87
- seconds -= 1;
88
- sendBack({ type: 'TICK' });
89
- if (seconds <= 0) {
90
- clearInterval(interval);
91
- }
92
- }, 1000);
93
- return () => clearInterval(interval);
94
- }),
95
- },
96
- actions: {
97
- setStartInfo: assign(({ event }) => {
98
- const info = (event as unknown as { output: StartInfo }).output;
99
- return {
100
- startInfo: info,
101
- countryCode: info.ipIsoCode,
102
- phonePrefix: info.phonePrefix,
103
- };
104
- }),
105
- setPrefilledPhone: assign(({ event }) => {
106
- const phone = (event as unknown as { output: { phone: string } }).output
107
- .phone;
108
- return {
109
- prefilledPhone: phone,
110
- phone,
111
- };
112
- }),
113
- setPhone: assign(({ event }) => {
114
- const e = event as {
115
- type: 'PHONE_CHANGED';
116
- phone: string;
117
- isValid: boolean;
118
- };
119
- return {
120
- phone: e.phone,
121
- isValid: e.isValid,
122
- phoneError: e.isValid ? undefined : 'Invalid phone number',
123
- };
124
- }),
125
- setPhoneError: assign(({ event }) => ({
126
- phoneError: String((event as unknown as { error: unknown }).error),
127
- })),
128
- setOptInGranted: assign(({ event }) => ({
129
- optInGranted: (event as { type: 'OPT_IN_CHANGED'; granted: boolean })
130
- .granted,
131
- })),
132
- setError: assign(({ event }) => ({
133
- error: String((event as unknown as { error: unknown }).error),
134
- })),
135
- clearError: assign({
136
- error: () => undefined,
137
- }),
138
- clearPhoneError: assign({
139
- phoneError: () => undefined,
140
- }),
141
- setOtpCode: assign(({ event }) => ({
142
- otpCode: (event as { type: 'OTP_CHANGED'; code: string }).code,
143
- otpError: undefined,
144
- })),
145
- setOtpError: assign(({ context, event }) => ({
146
- otpError: String((event as unknown as { error: unknown }).error),
147
- attemptsRemaining: context.attemptsRemaining - 1,
148
- })),
149
- clearOtpError: assign({
150
- otpError: () => undefined,
151
- otpCode: () => '',
152
- }),
153
- startResendTimer: assign({
154
- resendTimer: () => RESEND_TIMER_SECONDS,
155
- resendTimerActive: () => true,
156
- }),
157
- tickResendTimer: assign(({ context }) => {
158
- const newTimer = Math.max(0, context.resendTimer - 1);
159
- return {
160
- resendTimer: newTimer,
161
- resendTimerActive: newTimer > 0,
162
- };
163
- }),
164
- stopResendTimer: assign({
165
- resendTimerActive: () => false,
166
- }),
167
- resetContext: assign(({ context }) => ({
168
- config: context.config,
169
- phone: '',
170
- isValid: false,
171
- phoneError: undefined,
172
- countryCode: '',
173
- phonePrefix: '',
174
- prefilledPhone: undefined,
175
- optInGranted: false,
176
- startInfo: undefined,
177
- error: undefined,
178
- otpCode: '',
179
- otpError: undefined,
180
- attemptsRemaining: context.config.maxOtpAttempts ?? 3,
181
- resendTimer: 0,
182
- resendTimerActive: false,
183
- })),
184
- sendPhoneSubmitEvent: () => {
185
- addEvent({
186
- code: 'continue',
187
- module: 'phone',
188
- screen: 'phoneInput',
189
- });
190
- },
191
- },
192
- guards: {
193
- hasPrefill: ({ context }): boolean => context.config.prefill,
194
- hasOtpVerification: ({ context }): boolean =>
195
- context.config.otpVerification,
196
- isValidPhone: ({ context }): boolean => context.isValid,
197
- hasAttemptsRemaining: ({ context }): boolean =>
198
- context.attemptsRemaining > 0,
199
- canResend: ({ context }): boolean => !context.resendTimerActive,
200
- },
201
- }).createMachine({
202
- id: 'phone',
203
- initial: 'idle',
204
- context: ({ input }) => ({
205
- config: input.config,
206
- phone: '',
207
- isValid: false,
208
- phoneError: undefined,
209
- countryCode: '',
210
- phonePrefix: '',
211
- prefilledPhone: undefined,
212
- optInGranted: false,
213
- startInfo: undefined,
214
- error: undefined,
215
- otpCode: '',
216
- otpError: undefined,
217
- attemptsRemaining: input.config.maxOtpAttempts ?? 3,
218
- resendTimer: 0,
219
- resendTimerActive: false,
220
- }),
221
- states: {
222
- idle: {
223
- on: {
224
- LOAD: [
225
- {
226
- target: 'loadingPrefill',
227
- guard: 'hasPrefill',
228
- },
229
- {
230
- target: 'loadingStartInfo',
231
- },
232
- ],
233
- },
234
- },
235
-
236
- loadingPrefill: {
237
- invoke: {
238
- id: 'fetchPhone',
239
- src: 'fetchPhone',
240
- onDone: {
241
- target: 'loadingStartInfo',
242
- actions: 'setPrefilledPhone',
243
- },
244
- onError: {
245
- target: 'loadingStartInfo',
246
- },
247
- },
248
- },
249
-
250
- loadingStartInfo: {
251
- invoke: {
252
- id: 'fetchStartInfo',
253
- src: 'fetchStartInfo',
254
- onDone: {
255
- target: 'inputting',
256
- actions: 'setStartInfo',
257
- },
258
- onError: {
259
- target: 'inputting',
260
- },
261
- },
262
- },
263
-
264
- inputting: {
265
- entry: 'clearPhoneError',
266
- on: {
267
- PHONE_CHANGED: {
268
- actions: 'setPhone',
269
- },
270
- OPT_IN_CHANGED: {
271
- actions: 'setOptInGranted',
272
- },
273
- SUBMIT: {
274
- target: 'submitting',
275
- guard: 'isValidPhone',
276
- },
277
- },
278
- },
279
-
280
- submitting: {
281
- invoke: {
282
- id: 'submitPhone',
283
- src: 'submitPhone',
284
- input: ({ context }) => ({
285
- phone: context.phone,
286
- optInGranted: context.config.optinEnabled
287
- ? context.optInGranted
288
- : undefined,
289
- isInstantVerify: context.config.isInstantVerify ?? false,
290
- }),
291
- onDone: [
292
- {
293
- target: 'sendingOtp',
294
- guard: 'hasOtpVerification',
295
- actions: 'sendPhoneSubmitEvent',
296
- },
297
- {
298
- target: 'success',
299
- actions: 'sendPhoneSubmitEvent',
300
- },
301
- ],
302
- onError: {
303
- target: 'inputting',
304
- actions: 'setPhoneError',
305
- },
306
- },
307
- },
308
-
309
- sendingOtp: {
310
- invoke: {
311
- id: 'sendOtp',
312
- src: 'sendOtp',
313
- onDone: {
314
- target: 'awaitingOtp',
315
- },
316
- onError: {
317
- target: 'awaitingOtp',
318
- actions: 'setError',
319
- },
320
- },
321
- },
322
-
323
- awaitingOtp: {
324
- entry: 'startResendTimer',
325
- invoke: {
326
- id: 'resendTimer',
327
- src: 'resendTimer',
328
- },
329
- on: {
330
- TICK: {
331
- actions: 'tickResendTimer',
332
- },
333
- OTP_CHANGED: {
334
- actions: 'setOtpCode',
335
- },
336
- VERIFY_OTP: {
337
- target: 'verifyingOtp',
338
- },
339
- RESEND_OTP: {
340
- target: 'sendingOtp',
341
- guard: 'canResend',
342
- },
343
- BACK: {
344
- target: 'inputting',
345
- },
346
- },
347
- },
348
-
349
- verifyingOtp: {
350
- invoke: {
351
- id: 'verifyOtp',
352
- src: 'verifyOtp',
353
- input: ({ context }) => ({
354
- code: context.otpCode,
355
- }),
356
- onDone: [
357
- {
358
- target: 'success',
359
- guard: ({ event }) => event.output.success === true,
360
- },
361
- {
362
- target: 'otpError',
363
- guard: 'hasAttemptsRemaining',
364
- actions: assign(({ context }) => ({
365
- otpError: 'Invalid OTP code',
366
- attemptsRemaining: context.attemptsRemaining - 1,
367
- })),
368
- },
369
- {
370
- target: 'error',
371
- actions: assign({
372
- error: () => 'Maximum OTP attempts exceeded',
373
- }),
374
- },
375
- ],
376
- onError: [
377
- {
378
- target: 'otpError',
379
- guard: 'hasAttemptsRemaining',
380
- actions: 'setOtpError',
381
- },
382
- {
383
- target: 'error',
384
- actions: 'setError',
385
- },
386
- ],
387
- },
388
- },
389
-
390
- otpError: {
391
- on: {
392
- OTP_CHANGED: {
393
- target: 'awaitingOtp',
394
- actions: 'setOtpCode',
395
- },
396
- RESEND_OTP: {
397
- target: 'sendingOtp',
398
- guard: 'canResend',
399
- },
400
- BACK: {
401
- target: 'inputting',
402
- },
403
- },
404
- },
405
-
406
- success: {
407
- type: 'final',
408
- },
409
-
410
- error: {
411
- on: {
412
- RESET: {
413
- target: 'idle',
414
- actions: 'resetContext',
415
- },
416
- },
417
- },
418
- },
419
- // biome-ignore lint/suspicious/noExplicitAny: XState type inference issue with guards in declaration files
420
- }) as any;
421
-
422
- export type PhoneMachine = typeof phoneMachine;
@@ -1,83 +0,0 @@
1
- /**
2
- * Configuration options for phone verification.
3
- *
4
- * @example Standard OTP verification
5
- * ```typescript
6
- * const config: PhoneConfig = {
7
- * otpVerification: true,
8
- * otpExpirationInMinutes: 5,
9
- * prefill: false,
10
- * };
11
- * ```
12
- *
13
- * @example With all options
14
- * ```typescript
15
- * const config: PhoneConfig = {
16
- * otpVerification: true,
17
- * otpExpirationInMinutes: 10,
18
- * prefill: true,
19
- * isInstantVerify: false,
20
- * optinEnabled: true,
21
- * maxOtpAttempts: 3,
22
- * };
23
- * ```
24
- */
25
- export type PhoneConfig = {
26
- /**
27
- * Whether to require OTP (SMS code) verification.
28
- * If false, phone is verified immediately after submission.
29
- */
30
- otpVerification: boolean;
31
-
32
- /**
33
- * How long the OTP code remains valid, in minutes.
34
- * After expiration, user must request a new code.
35
- */
36
- otpExpirationInMinutes: number;
37
-
38
- /**
39
- * Whether to pre-populate with user's previously stored phone number.
40
- * Useful for returning users.
41
- */
42
- prefill: boolean;
43
-
44
- /**
45
- * Use carrier-based instant verification instead of OTP.
46
- * Not available in all regions.
47
- * @default false
48
- */
49
- isInstantVerify?: boolean;
50
-
51
- /**
52
- * Show a marketing opt-in checkbox in the UI.
53
- * User's preference is sent with the phone submission.
54
- * @default false
55
- */
56
- optinEnabled?: boolean;
57
-
58
- /**
59
- * Maximum number of OTP verification attempts before lockout.
60
- * After exhausting attempts, user sees an error state.
61
- * @default 3
62
- */
63
- maxOtpAttempts?: number;
64
- };
65
-
66
- export type StartInfo = {
67
- phonePrefix: string;
68
- country: string;
69
- ipIsoCode: string;
70
- };
71
-
72
- export type AddPhoneResponse = {
73
- success: boolean;
74
- };
75
-
76
- export type VerifyOtpResponse = {
77
- success: boolean;
78
- };
79
-
80
- export type AddPhoneParams = {
81
- phone: string;
82
- optInGranted?: boolean;
83
- };
@@ -1,87 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
- import { endpoints } from '../http/endpoints';
3
- import {
4
- createRecordingSession,
5
- startRecording,
6
- stopRecording,
7
- } from './recordingsRepository';
8
-
9
- vi.mock('../http/api', () => ({
10
- api: {
11
- post: vi.fn(),
12
- },
13
- }));
14
-
15
- describe('recordingsRepository', () => {
16
- it('creates a recording session using the v2 endpoint', async () => {
17
- const { api } = await import('../http/api');
18
- vi.mocked(api.post).mockResolvedValueOnce({
19
- ok: true,
20
- status: 200,
21
- statusText: 'OK',
22
- url: 'x',
23
- headers: {},
24
- data: {
25
- token: 't',
26
- videoRecordingId: 'v',
27
- sessionId: 's',
28
- },
29
- });
30
-
31
- await expect(createRecordingSession('selfie')).resolves.toEqual({
32
- token: 't',
33
- videoRecordingId: 'v',
34
- sessionId: 's',
35
- });
36
-
37
- expect(api.post).toHaveBeenCalledWith(endpoints.recordingCreateSessionV2, {
38
- type: 'selfie',
39
- });
40
- });
41
-
42
- it('starts recording with v2 endpoint and composed output', async () => {
43
- const { api } = await import('../http/api');
44
- vi.mocked(api.post).mockResolvedValueOnce({
45
- ok: true,
46
- status: 200,
47
- statusText: 'OK',
48
- url: 'x',
49
- headers: {},
50
- data: { ok: true },
51
- });
52
-
53
- await startRecording({
54
- videoRecordingId: 'vid',
55
- type: 'selfie',
56
- resolution: '640x480',
57
- hasAudio: true,
58
- });
59
-
60
- expect(api.post).toHaveBeenCalledWith(endpoints.recordingStartV2, {
61
- videoRecordingId: 'vid',
62
- frameRate: 30,
63
- outputMode: 'COMPOSED',
64
- resolution: '640x480',
65
- type: 'selfie',
66
- hasAudio: true,
67
- });
68
- });
69
-
70
- it('stops recording with v2 endpoint', async () => {
71
- const { api } = await import('../http/api');
72
- vi.mocked(api.post).mockResolvedValueOnce({
73
- ok: true,
74
- status: 200,
75
- statusText: 'OK',
76
- url: 'x',
77
- headers: {},
78
- data: { ok: true },
79
- });
80
-
81
- await stopRecording('vid');
82
-
83
- expect(api.post).toHaveBeenCalledWith(endpoints.recordingStopV2, {
84
- videoRecordingId: 'vid',
85
- });
86
- });
87
- });
@@ -1,48 +0,0 @@
1
- import { api } from '../http/api';
2
- import { endpoints } from '../http/endpoints';
3
-
4
- export type CreateRecordingSessionResponse = {
5
- token: string;
6
- videoRecordingId: string;
7
- sessionId: string;
8
- };
9
-
10
- export async function createRecordingSession(
11
- type: string,
12
- ): Promise<CreateRecordingSessionResponse> {
13
- const response = await api.post<CreateRecordingSessionResponse>(
14
- endpoints.recordingCreateSessionV2,
15
- { type },
16
- );
17
- return response.data;
18
- }
19
-
20
- export type StartRecordingParams = {
21
- videoRecordingId: string;
22
- type?: string;
23
- resolution?: string;
24
- hasAudio?: boolean;
25
- };
26
-
27
- export async function startRecording(
28
- params: StartRecordingParams,
29
- ): Promise<unknown> {
30
- const response = await api.post(endpoints.recordingStartV2, {
31
- videoRecordingId: params.videoRecordingId,
32
- frameRate: 30,
33
- outputMode: 'COMPOSED',
34
- resolution: params.resolution,
35
- type: params.type,
36
- hasAudio: params.hasAudio ?? false,
37
- });
38
- return response.data;
39
- }
40
-
41
- export async function stopRecording(
42
- videoRecordingId: string,
43
- ): Promise<unknown> {
44
- const response = await api.post(endpoints.recordingStopV2, {
45
- videoRecordingId,
46
- });
47
- return response.data;
48
- }
@@ -1,10 +0,0 @@
1
- export const streamingEvents = {
2
- strSessionDidConnect: 'strSessionDidConnect',
3
- strSessionDidDisconnect: 'strSessionDidDisconnect',
4
- strSessionDidFailWithError: 'strSessionDidFailWithError',
5
- strStreamVideoCaptureStart: 'strStreamVideoCaptureStart',
6
- strStreamVideoCaptureStop: 'strStreamVideoCaptureStop',
7
- strStreamPublisherCreated: 'strStreamPublisherCreated',
8
- strStreamPublisherDestroyed: 'strStreamPublisherDestroyed',
9
- strStreamPublisherDidFailWithError: 'strStreamPublisherDidFailWithError',
10
- } as const;
@@ -1,26 +0,0 @@
1
- import type { SelfieConfig } from '../types';
2
-
3
- export const mockSelfieConfig: SelfieConfig = {
4
- showTutorial: false,
5
- showPreview: false,
6
- assistedOnboarding: false,
7
- enableFaceRecording: false,
8
- autoCaptureTimeout: 10_000,
9
- captureAttempts: 2,
10
- validateLenses: false,
11
- validateFaceMask: false,
12
- validateHeadCover: false,
13
- validateClosedEyes: false,
14
- validateBrightness: false,
15
- deepsightLiveness: 'SINGLE_FRAME',
16
- };
17
-
18
- export const mockSelfieConfigWithTutorial: SelfieConfig = {
19
- ...mockSelfieConfig,
20
- showTutorial: true,
21
- };
22
-
23
- export const mockSelfieConfigWithOneAttempt: SelfieConfig = {
24
- ...mockSelfieConfig,
25
- captureAttempts: 1,
26
- };
@@ -1,14 +0,0 @@
1
- export {
2
- createSelfieManager,
3
- type SelfieManager,
4
- type SelfieState,
5
- } from './selfieManager';
6
- export type { CameraStream } from './selfieServices';
7
- export { type SelfieMachine, selfieMachine } from './selfieStateMachine';
8
- export type {
9
- DetectionStatus,
10
- FaceErrorCode,
11
- PermissionResult,
12
- PermissionStatus,
13
- SelfieConfig,
14
- } from './types';
@@ -1,17 +0,0 @@
1
- import { type ActorRefFrom, createActor } from '@incodetech/infra';
2
- import { type SelfieMachine, selfieMachine } from './selfieStateMachine';
3
- import type { SelfieConfig } from './types';
4
-
5
- export type CreateSelfieActorOptions = {
6
- config: SelfieConfig;
7
- };
8
-
9
- export type SelfieActor = ActorRefFrom<SelfieMachine>;
10
-
11
- export function createSelfieActor(
12
- options: CreateSelfieActorOptions,
13
- ): SelfieActor {
14
- return createActor(selfieMachine, {
15
- input: { config: options.config },
16
- }).start();
17
- }