@incodetech/core 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.
Files changed (154) hide show
  1. package/dist/OpenViduLogger-BdPfiZO6.esm.js +3 -0
  2. package/dist/OpenViduLogger-CQyDxBvM.esm.js +803 -0
  3. package/dist/{addEvent-1Mi5CEiq.esm.js → addEvent-9v4w5iO-.esm.js} +1 -1
  4. package/dist/email.d.ts +1 -1
  5. package/dist/email.esm.js +2 -2
  6. package/dist/{endpoints-D_pUMaqA.esm.js → endpoints-Dn1t57hJ.esm.js} +8 -3
  7. package/dist/flow.d.ts +3 -3
  8. package/dist/flow.esm.js +1 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.esm.js +2 -2
  11. package/dist/{lib-CyIAFRfr.esm.js → lib-Bu9XGMBW.esm.js} +1 -800
  12. package/dist/{permissionServices-CVR0Pq38.esm.js → permissionServices-CCpxd8le.esm.js} +1 -1
  13. package/dist/phone.d.ts +1 -1
  14. package/dist/phone.esm.js +2 -2
  15. package/dist/selfie.d.ts +5 -4
  16. package/dist/selfie.esm.js +27 -10
  17. package/package.json +4 -1
  18. package/.turbo/turbo-build.log +0 -33
  19. package/.turbo/turbo-coverage.log +0 -22
  20. package/.turbo/turbo-format.log +0 -6
  21. package/.turbo/turbo-lint$colon$fix.log +0 -77
  22. package/.turbo/turbo-lint.log +0 -95
  23. package/.turbo/turbo-test.log +0 -870
  24. package/.turbo/turbo-typecheck.log +0 -5
  25. package/coverage/base.css +0 -224
  26. package/coverage/block-navigation.js +0 -87
  27. package/coverage/favicon.png +0 -0
  28. package/coverage/index.html +0 -221
  29. package/coverage/prettify.css +0 -1
  30. package/coverage/prettify.js +0 -2
  31. package/coverage/sort-arrow-sprite.png +0 -0
  32. package/coverage/sorter.js +0 -210
  33. package/coverage/src/camera/cameraService.ts.html +0 -580
  34. package/coverage/src/camera/cameraServices.ts.html +0 -163
  35. package/coverage/src/camera/cameraStateMachine.ts.html +0 -877
  36. package/coverage/src/camera/index.html +0 -146
  37. package/coverage/src/email/emailActor.ts.html +0 -130
  38. package/coverage/src/email/emailManager.ts.html +0 -1366
  39. package/coverage/src/email/emailStateMachine.ts.html +0 -1186
  40. package/coverage/src/email/index.html +0 -146
  41. package/coverage/src/flow/flowActor.ts.html +0 -124
  42. package/coverage/src/flow/flowAnalyzer.ts.html +0 -196
  43. package/coverage/src/flow/flowManager.ts.html +0 -790
  44. package/coverage/src/flow/flowServices.ts.html +0 -124
  45. package/coverage/src/flow/flowStateMachine.ts.html +0 -631
  46. package/coverage/src/flow/index.html +0 -221
  47. package/coverage/src/flow/moduleLoader.ts.html +0 -304
  48. package/coverage/src/flow/orchestratedFlowManager.ts.html +0 -778
  49. package/coverage/src/flow/orchestratedFlowStateMachine.ts.html +0 -1060
  50. package/coverage/src/http/api.ts.html +0 -355
  51. package/coverage/src/http/endpoints.ts.html +0 -136
  52. package/coverage/src/http/index.html +0 -131
  53. package/coverage/src/index.html +0 -116
  54. package/coverage/src/phone/index.html +0 -146
  55. package/coverage/src/phone/phoneActor.ts.html +0 -130
  56. package/coverage/src/phone/phoneManager.ts.html +0 -1459
  57. package/coverage/src/phone/phoneStateMachine.ts.html +0 -1351
  58. package/coverage/src/recordings/index.html +0 -116
  59. package/coverage/src/recordings/recordingsRepository.ts.html +0 -229
  60. package/coverage/src/selfie/index.html +0 -191
  61. package/coverage/src/selfie/selfieActor.ts.html +0 -136
  62. package/coverage/src/selfie/selfieErrorUtils.ts.html +0 -283
  63. package/coverage/src/selfie/selfieManager.ts.html +0 -988
  64. package/coverage/src/selfie/selfieStateMachine.ts.html +0 -2497
  65. package/coverage/src/selfie/selfieUploadService.ts.html +0 -328
  66. package/coverage/src/selfie/types.ts.html +0 -394
  67. package/coverage/src/setup.ts.html +0 -598
  68. package/src/camera/cameraActor.ts +0 -21
  69. package/src/camera/cameraService.test.ts +0 -437
  70. package/src/camera/cameraService.ts +0 -165
  71. package/src/camera/cameraServices.test.ts +0 -66
  72. package/src/camera/cameraServices.ts +0 -26
  73. package/src/camera/cameraStateMachine.test.ts +0 -602
  74. package/src/camera/cameraStateMachine.ts +0 -264
  75. package/src/camera/index.ts +0 -5
  76. package/src/camera/types.ts +0 -17
  77. package/src/device/getBrowser.ts +0 -31
  78. package/src/device/getDeviceClass.ts +0 -29
  79. package/src/device/index.ts +0 -2
  80. package/src/email/__mocks__/emailMocks.ts +0 -59
  81. package/src/email/emailActor.ts +0 -15
  82. package/src/email/emailManager.test.ts +0 -573
  83. package/src/email/emailManager.ts +0 -427
  84. package/src/email/emailServices.ts +0 -66
  85. package/src/email/emailStateMachine.test.ts +0 -741
  86. package/src/email/emailStateMachine.ts +0 -367
  87. package/src/email/index.ts +0 -39
  88. package/src/email/types.ts +0 -60
  89. package/src/events/addEvent.ts +0 -20
  90. package/src/events/types.ts +0 -7
  91. package/src/flow/__mocks__/flowMocks.ts +0 -84
  92. package/src/flow/flowActor.ts +0 -13
  93. package/src/flow/flowAnalyzer.test.ts +0 -266
  94. package/src/flow/flowAnalyzer.ts +0 -37
  95. package/src/flow/flowCompletionService.ts +0 -21
  96. package/src/flow/flowManager.test.ts +0 -560
  97. package/src/flow/flowManager.ts +0 -235
  98. package/src/flow/flowServices.test.ts +0 -109
  99. package/src/flow/flowServices.ts +0 -13
  100. package/src/flow/flowStateMachine.test.ts +0 -334
  101. package/src/flow/flowStateMachine.ts +0 -182
  102. package/src/flow/index.ts +0 -21
  103. package/src/flow/moduleLoader.test.ts +0 -136
  104. package/src/flow/moduleLoader.ts +0 -73
  105. package/src/flow/orchestratedFlowManager.test.ts +0 -240
  106. package/src/flow/orchestratedFlowManager.ts +0 -231
  107. package/src/flow/orchestratedFlowStateMachine.test.ts +0 -199
  108. package/src/flow/orchestratedFlowStateMachine.ts +0 -325
  109. package/src/flow/types.ts +0 -434
  110. package/src/http/__mocks__/api.ts +0 -88
  111. package/src/http/api.test.ts +0 -231
  112. package/src/http/api.ts +0 -90
  113. package/src/http/endpoints.ts +0 -17
  114. package/src/index.ts +0 -33
  115. package/src/permissions/index.ts +0 -2
  116. package/src/permissions/permissionServices.ts +0 -31
  117. package/src/permissions/types.ts +0 -3
  118. package/src/phone/__mocks__/phoneMocks.ts +0 -71
  119. package/src/phone/index.ts +0 -39
  120. package/src/phone/phoneActor.ts +0 -15
  121. package/src/phone/phoneManager.test.ts +0 -393
  122. package/src/phone/phoneManager.ts +0 -458
  123. package/src/phone/phoneServices.ts +0 -98
  124. package/src/phone/phoneStateMachine.test.ts +0 -918
  125. package/src/phone/phoneStateMachine.ts +0 -422
  126. package/src/phone/types.ts +0 -83
  127. package/src/recordings/recordingsRepository.test.ts +0 -87
  128. package/src/recordings/recordingsRepository.ts +0 -48
  129. package/src/recordings/streamingEvents.ts +0 -10
  130. package/src/selfie/__mocks__/selfieMocks.ts +0 -26
  131. package/src/selfie/index.ts +0 -14
  132. package/src/selfie/selfieActor.ts +0 -17
  133. package/src/selfie/selfieErrorUtils.test.ts +0 -116
  134. package/src/selfie/selfieErrorUtils.ts +0 -66
  135. package/src/selfie/selfieManager.test.ts +0 -297
  136. package/src/selfie/selfieManager.ts +0 -301
  137. package/src/selfie/selfieServices.ts +0 -362
  138. package/src/selfie/selfieStateMachine.test.ts +0 -283
  139. package/src/selfie/selfieStateMachine.ts +0 -804
  140. package/src/selfie/selfieUploadService.test.ts +0 -90
  141. package/src/selfie/selfieUploadService.ts +0 -81
  142. package/src/selfie/types.ts +0 -103
  143. package/src/session/index.ts +0 -5
  144. package/src/session/sessionService.ts +0 -78
  145. package/src/setup.test.ts +0 -61
  146. package/src/setup.ts +0 -171
  147. package/tsconfig.json +0 -13
  148. package/tsdown.config.ts +0 -22
  149. package/vitest.config.ts +0 -37
  150. package/vitest.setup.ts +0 -135
  151. /package/dist/{Manager-6BwbaI_H.d.ts → Manager-BGfxEmyv.d.ts} +0 -0
  152. /package/dist/{StateMachine-7c1gcu94.d.ts → StateMachine-DRE1oH2B.d.ts} +0 -0
  153. /package/dist/{types-tq1ypYSL.d.ts → types-kWlqshfM.d.ts} +0 -0
  154. /package/dist/{warmup-Dr7OcFND.d.ts → warmup-CEJTfxQr.d.ts} +0 -0
@@ -1,231 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { setup } from '../setup';
3
- import {
4
- api,
5
- getApi,
6
- getToken,
7
- isApiConfigured,
8
- resetApi,
9
- setToken,
10
- } from './api';
11
-
12
- const mockResponse = {
13
- data: {},
14
- status: 200,
15
- headers: {},
16
- ok: true,
17
- statusText: 'OK',
18
- url: 'https://api.test.com/test',
19
- };
20
-
21
- describe('api', () => {
22
- beforeEach(() => {
23
- resetApi();
24
- });
25
-
26
- describe('api wrapper', () => {
27
- it('should throw error when accessing methods before setup()', () => {
28
- expect(() => api.get('/test')).toThrow(
29
- 'SDK not configured. Call setup({ apiURL: "..." }) first.',
30
- );
31
- });
32
-
33
- it('should have method functions after setup()', () => {
34
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
35
-
36
- expect(typeof api.get).toBe('function');
37
- expect(typeof api.post).toBe('function');
38
- expect(typeof api.put).toBe('function');
39
- expect(typeof api.patch).toBe('function');
40
- expect(typeof api.delete).toBe('function');
41
- });
42
- });
43
-
44
- describe('getApi()', () => {
45
- it('should throw error if setup() was not called', () => {
46
- expect(() => getApi()).toThrow(
47
- 'SDK not configured. Call setup({ apiURL: "..." }) first.',
48
- );
49
- });
50
-
51
- it('should return the client after setup()', () => {
52
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
53
-
54
- const client = getApi();
55
- expect(client).toBeDefined();
56
- expect(client.defaults.baseURL).toBe('https://api.test.com');
57
- expect(getToken()).toBe('test-token');
58
- });
59
- });
60
-
61
- describe('isApiConfigured()', () => {
62
- it('should return false before setup()', () => {
63
- expect(isApiConfigured()).toBe(false);
64
- });
65
-
66
- it('should return true after setup()', () => {
67
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
68
-
69
- expect(isApiConfigured()).toBe(true);
70
- });
71
- });
72
-
73
- describe('resetApi()', () => {
74
- it('should reset the client to null', () => {
75
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
76
- expect(isApiConfigured()).toBe(true);
77
-
78
- resetApi();
79
- expect(isApiConfigured()).toBe(false);
80
- });
81
-
82
- it('should cause getApi() to throw after reset', () => {
83
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
84
- resetApi();
85
-
86
- expect(() => getApi()).toThrow();
87
- });
88
-
89
- it('should reset the token to null', () => {
90
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
91
- expect(getToken()).toBe('test-token');
92
-
93
- resetApi();
94
- expect(getToken()).toBeNull();
95
- });
96
- });
97
-
98
- describe('setToken()', () => {
99
- it('should set the token', () => {
100
- setToken('my-token');
101
- expect(getToken()).toBe('my-token');
102
- });
103
-
104
- it('should override existing token', () => {
105
- setToken('first-token');
106
- setToken('second-token');
107
- expect(getToken()).toBe('second-token');
108
- });
109
- });
110
-
111
- describe('api methods with token', () => {
112
- beforeEach(() => {
113
- setup({ apiURL: 'https://api.test.com', token: 'test-token' });
114
- });
115
-
116
- it('should add token header to get requests', async () => {
117
- const client = getApi();
118
- const getSpy = vi.spyOn(client, 'get').mockResolvedValue(mockResponse);
119
-
120
- await api.get('/test');
121
-
122
- expect(getSpy).toHaveBeenCalledWith('/test', {
123
- headers: { 'X-Incode-Hardware-Id': 'test-token' },
124
- });
125
- });
126
-
127
- it('should add token header to post requests', async () => {
128
- const client = getApi();
129
- const postSpy = vi.spyOn(client, 'post').mockResolvedValue(mockResponse);
130
-
131
- await api.post('/test', { foo: 'bar' });
132
-
133
- expect(postSpy).toHaveBeenCalledWith(
134
- '/test',
135
- { foo: 'bar' },
136
- {
137
- headers: { 'X-Incode-Hardware-Id': 'test-token' },
138
- },
139
- );
140
- });
141
-
142
- it('should add token header to put requests', async () => {
143
- const client = getApi();
144
- const putSpy = vi.spyOn(client, 'put').mockResolvedValue(mockResponse);
145
-
146
- await api.put('/test', { foo: 'bar' });
147
-
148
- expect(putSpy).toHaveBeenCalledWith(
149
- '/test',
150
- { foo: 'bar' },
151
- {
152
- headers: { 'X-Incode-Hardware-Id': 'test-token' },
153
- },
154
- );
155
- });
156
-
157
- it('should add token header to patch requests', async () => {
158
- const client = getApi();
159
- const patchSpy = vi
160
- .spyOn(client, 'patch')
161
- .mockResolvedValue(mockResponse);
162
-
163
- await api.patch('/test', { foo: 'bar' });
164
-
165
- expect(patchSpy).toHaveBeenCalledWith(
166
- '/test',
167
- { foo: 'bar' },
168
- {
169
- headers: { 'X-Incode-Hardware-Id': 'test-token' },
170
- },
171
- );
172
- });
173
-
174
- it('should add token header to delete requests', async () => {
175
- const client = getApi();
176
- const deleteSpy = vi
177
- .spyOn(client, 'delete')
178
- .mockResolvedValue(mockResponse);
179
-
180
- await api.delete('/test');
181
-
182
- expect(deleteSpy).toHaveBeenCalledWith('/test', {
183
- headers: { 'X-Incode-Hardware-Id': 'test-token' },
184
- });
185
- });
186
-
187
- it('should merge token header with existing headers', async () => {
188
- const client = getApi();
189
- const getSpy = vi.spyOn(client, 'get').mockResolvedValue(mockResponse);
190
-
191
- await api.get('/test', { headers: { 'X-Custom': 'value' } });
192
-
193
- expect(getSpy).toHaveBeenCalledWith('/test', {
194
- headers: {
195
- 'X-Custom': 'value',
196
- 'X-Incode-Hardware-Id': 'test-token',
197
- },
198
- });
199
- });
200
- });
201
-
202
- describe('api methods without token', () => {
203
- beforeEach(() => {
204
- setup({ apiURL: 'https://api.test.com', token: '' });
205
- resetApi();
206
- setup({ apiURL: 'https://api.test.com', token: '' });
207
- });
208
-
209
- it('should not add token header when token is empty', async () => {
210
- setToken('');
211
- const client = getApi();
212
- const getSpy = vi.spyOn(client, 'get').mockResolvedValue(mockResponse);
213
-
214
- await api.get('/test');
215
-
216
- expect(getSpy).toHaveBeenCalledWith('/test', {});
217
- });
218
-
219
- it('should pass through config without modification when no token', async () => {
220
- setToken('');
221
- const client = getApi();
222
- const getSpy = vi.spyOn(client, 'get').mockResolvedValue(mockResponse);
223
-
224
- await api.get('/test', { headers: { 'X-Custom': 'value' } });
225
-
226
- expect(getSpy).toHaveBeenCalledWith('/test', {
227
- headers: { 'X-Custom': 'value' },
228
- });
229
- });
230
- });
231
- });
package/src/http/api.ts DELETED
@@ -1,90 +0,0 @@
1
- import type { HttpClient, HttpResponse } from '@incodetech/infra';
2
-
3
- type MethodConfig = {
4
- headers?: Record<string, string>;
5
- signal?: AbortSignal;
6
- timeout?: number;
7
- query?: Record<string, string | number | boolean | undefined>;
8
- };
9
-
10
- type ApiClient = {
11
- get<T>(url: string, config?: MethodConfig): Promise<HttpResponse<T>>;
12
- post<T>(
13
- url: string,
14
- data?: unknown,
15
- config?: MethodConfig,
16
- ): Promise<HttpResponse<T>>;
17
- put<T>(
18
- url: string,
19
- data?: unknown,
20
- config?: MethodConfig,
21
- ): Promise<HttpResponse<T>>;
22
- patch<T>(
23
- url: string,
24
- data?: unknown,
25
- config?: MethodConfig,
26
- ): Promise<HttpResponse<T>>;
27
- delete<T>(url: string, config?: MethodConfig): Promise<HttpResponse<T>>;
28
- };
29
-
30
- let client: HttpClient | null = null;
31
- let currentToken: string | null = null;
32
-
33
- export function setClient(httpClient: HttpClient): void {
34
- client = httpClient;
35
- }
36
-
37
- export function setToken(token: string): void {
38
- currentToken = token;
39
- }
40
-
41
- export function getToken(): string | null {
42
- return currentToken;
43
- }
44
-
45
- export function getApi(): HttpClient {
46
- if (!client) {
47
- throw new Error('SDK not configured. Call setup({ apiURL: "..." }) first.');
48
- }
49
- return client;
50
- }
51
-
52
- export function isApiConfigured(): boolean {
53
- return client !== null;
54
- }
55
-
56
- export function resetApi(): void {
57
- client = null;
58
- currentToken = null;
59
- }
60
-
61
- function addTokenHeader(config?: MethodConfig): MethodConfig {
62
- if (!currentToken) {
63
- return config ?? {};
64
- }
65
- return {
66
- ...config,
67
- headers: {
68
- ...config?.headers,
69
- 'X-Incode-Hardware-Id': currentToken,
70
- },
71
- };
72
- }
73
-
74
- export const api: ApiClient = {
75
- get<T>(url: string, config?: MethodConfig) {
76
- return getApi().get<T>(url, addTokenHeader(config));
77
- },
78
- post<T>(url: string, data?: unknown, config?: MethodConfig) {
79
- return getApi().post<T>(url, data, addTokenHeader(config));
80
- },
81
- put<T>(url: string, data?: unknown, config?: MethodConfig) {
82
- return getApi().put<T>(url, data, addTokenHeader(config));
83
- },
84
- patch<T>(url: string, data?: unknown, config?: MethodConfig) {
85
- return getApi().patch<T>(url, data, addTokenHeader(config));
86
- },
87
- delete<T>(url: string, config?: MethodConfig) {
88
- return getApi().delete<T>(url, addTokenHeader(config));
89
- },
90
- };
@@ -1,17 +0,0 @@
1
- export const endpoints = {
2
- createSession: '/omni/start',
3
- flow: '/omni/onboarding/flow',
4
- events: '/omni/interview-events',
5
- selfie: '/omni/add/face',
6
- recordingCreateSessionV2: '/omni/recordings/create-session/v2',
7
- recordingStartV2: '/omni/recordings/record-start/v2',
8
- recordingStopV2: '/omni/recordings/record-stop/v2',
9
- phone: '/omni/add/phone',
10
- phoneInstant: '/omni/instant/add/phone',
11
- getPhone: '/omni/get/phone',
12
- startInfo: '/omni/start-info',
13
- sendSmsOtp: '/omni/send/sms-otp',
14
- compareOtp: '/omni/compare/otp',
15
- email: '/omni/add/email',
16
- getEmail: '/omni/get/email',
17
- } as const;
package/src/index.ts DELETED
@@ -1,33 +0,0 @@
1
- export {
2
- createApi,
3
- type HttpClient,
4
- type WasmPipeline,
5
- warmupWasm,
6
- } from '@incodetech/infra';
7
- export {
8
- type Browser,
9
- type DeviceClass,
10
- getBrowser,
11
- getDeviceClass,
12
- } from './device';
13
- export { api, getApi } from './http/api';
14
- export {
15
- checkPermission as checkCameraPermission,
16
- type PermissionResult,
17
- type PermissionStatus,
18
- requestPermission as requestCameraPermission,
19
- } from './permissions';
20
- export {
21
- type CreateSessionOptions,
22
- createSession,
23
- type Session,
24
- } from './session';
25
- export {
26
- initializeWasmUtil,
27
- isConfigured,
28
- reset,
29
- type SetupOptions,
30
- setup,
31
- setWasmConfig,
32
- type WasmConfig,
33
- } from './setup';
@@ -1,2 +0,0 @@
1
- export { checkPermission, requestPermission } from './permissionServices';
2
- export type { PermissionResult, PermissionStatus } from './types';
@@ -1,31 +0,0 @@
1
- import {
2
- queryCameraPermission,
3
- requestCameraAccess,
4
- stopCameraStream,
5
- } from '@incodetech/infra';
6
- import type { PermissionResult } from './types';
7
-
8
- /**
9
- * Checks the current camera permission state without prompting the user.
10
- */
11
- export async function checkPermission(): Promise<PermissionResult> {
12
- return queryCameraPermission();
13
- }
14
-
15
- /**
16
- * Requests camera permission by attempting to access the camera, then immediately
17
- * stops the obtained stream. This function does not keep or return the stream.
18
- */
19
- export async function requestPermission(): Promise<PermissionResult> {
20
- try {
21
- const stream = await requestCameraAccess({ video: true });
22
- stopCameraStream(stream);
23
- return 'granted';
24
- } catch (error) {
25
- const name = error instanceof Error ? error.name : undefined;
26
- if (name === 'NotAllowedError' || name === 'PermissionDeniedError') {
27
- return 'denied';
28
- }
29
- return 'prompt';
30
- }
31
- }
@@ -1,3 +0,0 @@
1
- export type PermissionResult = 'granted' | 'denied' | 'prompt';
2
-
3
- export type PermissionStatus = 'idle' | 'requesting' | 'denied' | 'learnMore';
@@ -1,71 +0,0 @@
1
- import { vi } from 'vitest';
2
- import type { PhoneConfig, StartInfo, VerifyOtpResponse } from '../types';
3
-
4
- export const mockPhoneConfig: PhoneConfig = {
5
- otpVerification: true,
6
- otpExpirationInMinutes: 5,
7
- prefill: false,
8
- isInstantVerify: false,
9
- optinEnabled: false,
10
- maxOtpAttempts: 3,
11
- };
12
-
13
- export const mockPhoneConfigNoOtp: PhoneConfig = {
14
- ...mockPhoneConfig,
15
- otpVerification: false,
16
- };
17
-
18
- export const mockPhoneConfigWithPrefill: PhoneConfig = {
19
- ...mockPhoneConfig,
20
- prefill: true,
21
- };
22
-
23
- export const mockStartInfo: StartInfo = {
24
- ipIsoCode: 'US',
25
- phonePrefix: '+1',
26
- country: 'United States',
27
- };
28
-
29
- export const mockPrefilledPhone = '+14155551234';
30
-
31
- export function createMockFetchPhone(phone = mockPrefilledPhone) {
32
- return vi.fn().mockResolvedValue({ phone });
33
- }
34
-
35
- export function createMockFetchStartInfo(startInfo = mockStartInfo) {
36
- return vi.fn().mockResolvedValue(startInfo);
37
- }
38
-
39
- export function createMockAddPhone(success = true) {
40
- return vi.fn().mockResolvedValue({ success });
41
- }
42
-
43
- export function createMockSendOtp() {
44
- return vi.fn().mockResolvedValue(undefined);
45
- }
46
-
47
- export function createMockVerifyOtp(
48
- success = true,
49
- ): () => Promise<VerifyOtpResponse> {
50
- return vi.fn().mockResolvedValue({ success });
51
- }
52
-
53
- export function createFailingMockFetchPhone(error: string) {
54
- return vi.fn().mockRejectedValue(new Error(error));
55
- }
56
-
57
- export function createFailingMockAddPhone(error: string) {
58
- return vi.fn().mockRejectedValue(new Error(error));
59
- }
60
-
61
- export function createFailingMockVerifyOtp(error: string) {
62
- return vi.fn().mockRejectedValue(new Error(error));
63
- }
64
-
65
- export function createDelayedMock<T>(value: T, delayMs = 1000) {
66
- return vi
67
- .fn()
68
- .mockImplementation(
69
- () => new Promise((resolve) => setTimeout(() => resolve(value), delayMs)),
70
- );
71
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Phone verification module - supports headless and UI-driven usage.
3
- *
4
- * ## Headless Usage (Programmatic)
5
- *
6
- * Use `createPhoneManager` to control phone verification without any UI.
7
- * Perfect for custom UI implementations, backend integrations, or automated testing.
8
- *
9
- * ```typescript
10
- * import { createPhoneManager } from '@incodetech/core/phone';
11
- *
12
- * const manager = createPhoneManager({
13
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
14
- * });
15
- *
16
- * manager.subscribe((state) => console.log(state.status));
17
- * manager.load();
18
- * manager.setPhoneNumber('+14155551234', 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 Phone component from `@incodetech/ui/phone`.
27
- *
28
- * @module @incodetech/core/phone
29
- * @see {@link createPhoneManager} for headless API documentation
30
- * @see {@link PhoneConfig} for configuration options
31
- * @see {@link PhoneState} for state machine states
32
- */
33
- export {
34
- createPhoneManager,
35
- type PhoneManager,
36
- type PhoneState,
37
- } from './phoneManager';
38
- export { phoneMachine } from './phoneStateMachine';
39
- export type { PhoneConfig } from './types';
@@ -1,15 +0,0 @@
1
- import { type ActorRefFrom, createActor } from '@incodetech/infra';
2
- import { type PhoneMachine, phoneMachine } from './phoneStateMachine';
3
- import type { PhoneConfig } from './types';
4
-
5
- export type CreatePhoneActorOptions = {
6
- config: PhoneConfig;
7
- };
8
-
9
- export type PhoneActor = ActorRefFrom<PhoneMachine>;
10
-
11
- export function createPhoneActor(options: CreatePhoneActorOptions): PhoneActor {
12
- return createActor(phoneMachine, {
13
- input: { config: options.config },
14
- }).start();
15
- }