@incodetech/core 0.0.0-dev-20260313-486e658 → 0.0.0-dev-20260313-bc2dab4

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 (80) hide show
  1. package/dist/Actor-BAf9LRYf.d.ts +2 -0
  2. package/dist/StateMachine-DJpZF_HP.d.ts +2 -0
  3. package/dist/authentication.d.ts +10 -78
  4. package/dist/authentication.esm.js +11 -195
  5. package/dist/authenticationManager-4j4j8ac9.esm.js +197 -0
  6. package/dist/authenticationManager-DQL9XsaI.d.ts +66 -0
  7. package/dist/{backCameraStream-B57NWDGu.esm.js → backCameraStream-4aLwsDOv.esm.js} +1 -1
  8. package/dist/curp-validation.d.ts +4 -4
  9. package/dist/curp-validation.esm.js +5 -5
  10. package/dist/{deepsightLoader-BXTRzhYx.esm.js → deepsightLoader-C-Xil8cg.esm.js} +4 -4
  11. package/dist/{deepsightService-CTK55DG8.esm.js → deepsightService-BgqD33AH.esm.js} +3 -3
  12. package/dist/{deepsightService-CYCDsan2.d.ts → deepsightService-UhtHJCFb.d.ts} +131 -3
  13. package/dist/document-capture.d.ts +49 -49
  14. package/dist/document-capture.esm.js +6 -6
  15. package/dist/document-upload.d.ts +49 -49
  16. package/dist/document-upload.esm.js +5 -5
  17. package/dist/ekyb.d.ts +2 -2
  18. package/dist/ekyb.esm.js +6 -6
  19. package/dist/ekyc.d.ts +2 -2
  20. package/dist/ekyc.esm.js +6 -6
  21. package/dist/email.d.ts +3 -263
  22. package/dist/email.esm.js +6 -477
  23. package/dist/emailManager-DZeOYBQ6.d.ts +335 -0
  24. package/dist/emailManager-e7j__XBB.esm.js +486 -0
  25. package/dist/{events-b4_xvENs.esm.js → events-3HzCcoEy.esm.js} +2 -2
  26. package/dist/extensibility.d.ts +95 -0
  27. package/dist/extensibility.esm.js +17 -0
  28. package/dist/face-match.d.ts +1 -1
  29. package/dist/face-match.esm.js +5 -5
  30. package/dist/faceCaptureManagerFactory-CiQWYHp2.d.ts +610 -0
  31. package/dist/{faceCaptureSetup-10lCb_yE.esm.js → faceCaptureSetup-CF9TJlsc.esm.js} +11 -11
  32. package/dist/flow.d.ts +7 -7
  33. package/dist/flow.esm.js +5 -5
  34. package/dist/{flowCompletionService-DHXqHOAk.esm.js → flowCompletionService-CV8Ywiut.esm.js} +2 -2
  35. package/dist/geolocation.d.ts +1 -1
  36. package/dist/geolocation.esm.js +5 -5
  37. package/dist/government-validation.d.ts +1 -1
  38. package/dist/government-validation.esm.js +4 -4
  39. package/dist/id-A_upgNRR.esm.js +0 -0
  40. package/dist/id.d.ts +9 -9
  41. package/dist/id.esm.js +11 -10
  42. package/dist/{id-TUJyOPso.esm.js → idCaptureManager-B9BsU7-M.esm.js} +18 -11
  43. package/dist/{index-5ZEjz-8I.d.ts → idCaptureManager-D8FwP0TW.d.ts} +30 -8
  44. package/dist/index-BtQzTfU9.d.ts +1 -0
  45. package/dist/index.d.ts +21 -12
  46. package/dist/index.esm.js +33 -21
  47. package/dist/{lib-V3Lo-Jit.esm.js → lib-COh1FH9n.esm.js} +1 -1
  48. package/dist/phone.d.ts +3 -291
  49. package/dist/phone.esm.js +6 -551
  50. package/dist/phoneManager-B6fNmxhw.esm.js +560 -0
  51. package/dist/phoneManager-BsamACjL.d.ts +370 -0
  52. package/dist/redirect-to-mobile.d.ts +1 -1
  53. package/dist/redirect-to-mobile.esm.js +4 -4
  54. package/dist/selfie.d.ts +10 -408
  55. package/dist/selfie.esm.js +11 -118
  56. package/dist/selfieManager-ByV0akn-.esm.js +117 -0
  57. package/dist/selfieManager-Czysy-lv.d.ts +68 -0
  58. package/dist/session.d.ts +1 -1
  59. package/dist/session.esm.js +3 -3
  60. package/dist/{src-D3v6I2la.esm.js → src-BmVrWkLJ.esm.js} +2 -2
  61. package/dist/{stats-D76Thmqp.esm.js → stats-kLtQIgsA.esm.js} +1 -1
  62. package/dist/stats.esm.js +2 -2
  63. package/dist/{streamingEvents-CQq5fJCL.esm.js → streamingEvents-Cw6kqXEh.esm.js} +3 -3
  64. package/dist/{types-DnrAr9fb.d.ts → types-BugcSDaO.d.ts} +1 -1
  65. package/dist/{types-Bn54lmeM.d.ts → types-C9Jo2XOb.d.ts} +1 -1
  66. package/package.json +5 -1
  67. package/dist/Actor-B6Lr-x6S.d.ts +0 -2
  68. package/dist/StateMachine-WHeQE3lC.d.ts +0 -2
  69. package/dist/faceCaptureManagerFactory-D1NUo68Z.d.ts +0 -231
  70. package/dist/types-B4KNFqC4.d.ts +0 -130
  71. /package/dist/{Manager-CG5CQ1kY.d.ts → Manager-CXnC-tN_.d.ts} +0 -0
  72. /package/dist/{api-3fZO5bmj.esm.js → api-C2uzxrpN.esm.js} +0 -0
  73. /package/dist/{camera-D7zu0Mls.d.ts → camera-DDn9ILon.d.ts} +0 -0
  74. /package/dist/{chunk-B1Ox1Owh.esm.js → chunk-C4_ANvih.esm.js} +0 -0
  75. /package/dist/{endpoints-5sPFFmaB.esm.js → endpoints-IAlXA1zN.esm.js} +0 -0
  76. /package/dist/{flowCompletionService-DeWKduBI.d.ts → flowCompletionService-D4YDcHQR.d.ts} +0 -0
  77. /package/dist/{types-BYYaKde4.d.ts → types-DTieLton.d.ts} +0 -0
  78. /package/dist/{usStates-D4SmlpeT.esm.js → usStates-vWM_ZgEH.esm.js} +0 -0
  79. /package/dist/{warmup-Da5qDIWZ.d.ts → warmup-Bp_1oXoL.d.ts} +0 -0
  80. /package/dist/{xstate.esm-07M59Cte.esm.js → xstate.esm-CcoTezCZ.esm.js} +0 -0
package/dist/phone.esm.js CHANGED
@@ -1,553 +1,8 @@
1
- import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-b4_xvENs.esm.js";
2
- import { A as createManager, g as BrowserTimerProvider } from "./src-D3v6I2la.esm.js";
3
- import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-07M59Cte.esm.js";
4
- import { t as api } from "./api-3fZO5bmj.esm.js";
5
- import { t as endpoints } from "./endpoints-5sPFFmaB.esm.js";
1
+ import "./events-3HzCcoEy.esm.js";
2
+ import "./src-BmVrWkLJ.esm.js";
3
+ import "./xstate.esm-CcoTezCZ.esm.js";
4
+ import "./api-C2uzxrpN.esm.js";
5
+ import "./endpoints-IAlXA1zN.esm.js";
6
+ import { r as phoneMachine, t as createPhoneManager } from "./phoneManager-B6fNmxhw.esm.js";
6
7
 
7
- //#region src/modules/phone/phoneServices.ts
8
- async function fetchPhone(signal) {
9
- const res = await api.get(endpoints.getPhone, { signal });
10
- if (!res.ok) throw new Error(`GET ${endpoints.getPhone} failed: ${res.status} ${res.statusText}`);
11
- return res.data;
12
- }
13
- async function fetchStartInfo(signal) {
14
- const res = await api.get(endpoints.startInfo, { signal });
15
- if (!res.ok) throw new Error(`GET ${endpoints.startInfo} failed: ${res.status} ${res.statusText}`);
16
- return res.data;
17
- }
18
- async function addPhone(params, signal) {
19
- const res = await api.post(endpoints.phone, {
20
- phone: params.phone,
21
- optInGranted: params.optInGranted
22
- }, { signal });
23
- if (!res.ok) throw new Error(`POST ${endpoints.phone} failed: ${res.status} ${res.statusText}`);
24
- return res.data;
25
- }
26
- async function addPhoneInstantVerify(params, signal) {
27
- const res = await api.post(endpoints.phoneInstant, {
28
- phone: params.phone,
29
- optInGranted: params.optInGranted
30
- }, { signal });
31
- if (!res.ok) throw new Error(`POST ${endpoints.phoneInstant} failed: ${res.status} ${res.statusText}`);
32
- return res.data;
33
- }
34
- async function sendOtp(signal) {
35
- const res = await api.get(`${endpoints.sendSmsOtp}?communicationchannel=SMS`, { signal });
36
- if (!res.ok) throw new Error(`GET ${endpoints.sendSmsOtp} failed: ${res.status} ${res.statusText}`);
37
- }
38
- async function verifyOtp(code, signal) {
39
- const res = await api.get(`${endpoints.compareOtp}?code=${code}&channel=SMS`, { signal });
40
- if (!res.ok) throw new Error(`GET ${endpoints.compareOtp} failed: ${res.status} ${res.statusText}`);
41
- return res.data;
42
- }
43
-
44
- //#endregion
45
- //#region src/modules/phone/phoneStateMachine.ts
46
- const RESEND_TIMER_SECONDS = 30;
47
- const phoneMachine = setup({
48
- types: {
49
- context: {},
50
- events: {},
51
- input: {}
52
- },
53
- actors: {
54
- fetchPhone: fromPromise(async ({ signal }) => {
55
- return fetchPhone(signal);
56
- }),
57
- fetchStartInfo: fromPromise(async ({ signal }) => {
58
- return fetchStartInfo(signal);
59
- }),
60
- submitPhone: fromPromise(async ({ input, signal }) => {
61
- if (input.isInstantVerify) return addPhoneInstantVerify({
62
- phone: input.phone,
63
- optInGranted: input.optInGranted
64
- }, signal);
65
- return addPhone({
66
- phone: input.phone,
67
- optInGranted: input.optInGranted
68
- }, signal);
69
- }),
70
- sendOtp: fromPromise(async ({ signal }) => {
71
- return sendOtp(signal);
72
- }),
73
- verifyOtp: fromPromise(async ({ input, signal }) => {
74
- return verifyOtp(input.code, signal);
75
- }),
76
- resendTimer: fromCallback(({ sendBack }) => {
77
- const timer = BrowserTimerProvider.getInstance();
78
- let seconds = RESEND_TIMER_SECONDS;
79
- const interval = timer.setInterval(() => {
80
- seconds -= 1;
81
- sendBack({ type: "TICK" });
82
- if (seconds <= 0) timer.clearInterval(interval);
83
- }, 1e3);
84
- return () => timer.clearInterval(interval);
85
- })
86
- },
87
- actions: {
88
- setStartInfo: assign(({ event }) => {
89
- const info = event.output;
90
- return {
91
- startInfo: info,
92
- countryCode: info.ipIsoCode,
93
- phonePrefix: info.phonePrefix
94
- };
95
- }),
96
- setPrefilledPhone: assign(({ event }) => {
97
- const phone = event.output.phone;
98
- return {
99
- prefilledPhone: phone,
100
- phone
101
- };
102
- }),
103
- setPhone: assign(({ event }) => {
104
- const e = event;
105
- return {
106
- phone: e.phone,
107
- isValid: e.isValid,
108
- phoneError: e.isValid ? void 0 : "Invalid phone number"
109
- };
110
- }),
111
- setPhoneError: assign(({ event }) => ({ phoneError: String(event.error) })),
112
- setOptInGranted: assign(({ event }) => ({ optInGranted: event.granted })),
113
- setError: assign(({ event }) => ({ error: String(event.error) })),
114
- clearError: assign({ error: () => void 0 }),
115
- clearPhoneError: assign({ phoneError: () => void 0 }),
116
- setOtpCode: assign(({ event }) => ({
117
- otpCode: event.code,
118
- otpError: void 0
119
- })),
120
- setOtpError: assign(({ context, event }) => ({
121
- otpError: String(event.error),
122
- attemptsRemaining: context.attemptsRemaining - 1
123
- })),
124
- clearOtpError: assign({
125
- otpError: () => void 0,
126
- otpCode: () => ""
127
- }),
128
- startResendTimer: assign({
129
- resendTimer: () => RESEND_TIMER_SECONDS,
130
- resendTimerActive: () => true
131
- }),
132
- tickResendTimer: assign(({ context }) => {
133
- const newTimer = Math.max(0, context.resendTimer - 1);
134
- return {
135
- resendTimer: newTimer,
136
- resendTimerActive: newTimer > 0
137
- };
138
- }),
139
- stopResendTimer: assign({ resendTimerActive: () => false }),
140
- resetContext: assign(({ context }) => ({
141
- config: context.config,
142
- phone: "",
143
- isValid: false,
144
- phoneError: void 0,
145
- countryCode: "",
146
- phonePrefix: "",
147
- prefilledPhone: void 0,
148
- optInGranted: false,
149
- startInfo: void 0,
150
- error: void 0,
151
- otpCode: "",
152
- otpError: void 0,
153
- attemptsRemaining: context.config.maxOtpAttempts ?? 3,
154
- resendTimer: 0,
155
- resendTimerActive: false
156
- })),
157
- sendPhoneSubmitEvent: () => {
158
- addEvent({
159
- code: "continue",
160
- module: eventModuleNames.phone,
161
- screen: eventScreenNames.phoneInput
162
- });
163
- }
164
- },
165
- guards: {
166
- hasPrefill: ({ context }) => context.config.prefill,
167
- hasOtpVerification: ({ context }) => context.config.otpVerification,
168
- isValidPhone: ({ context }) => context.isValid,
169
- hasAttemptsRemaining: ({ context }) => context.attemptsRemaining > 0,
170
- canResend: ({ context }) => !context.resendTimerActive
171
- }
172
- }).createMachine({
173
- id: "phone",
174
- initial: "idle",
175
- context: ({ input }) => ({
176
- config: input.config,
177
- phone: "",
178
- isValid: false,
179
- phoneError: void 0,
180
- countryCode: "",
181
- phonePrefix: "",
182
- prefilledPhone: void 0,
183
- optInGranted: false,
184
- startInfo: void 0,
185
- error: void 0,
186
- otpCode: "",
187
- otpError: void 0,
188
- attemptsRemaining: input.config.maxOtpAttempts ?? 3,
189
- resendTimer: 0,
190
- resendTimerActive: false
191
- }),
192
- states: {
193
- idle: { on: { LOAD: [{
194
- target: "loadingPrefill",
195
- guard: "hasPrefill"
196
- }, { target: "loadingStartInfo" }] } },
197
- loadingPrefill: { invoke: {
198
- id: "fetchPhone",
199
- src: "fetchPhone",
200
- onDone: {
201
- target: "loadingStartInfo",
202
- actions: "setPrefilledPhone"
203
- },
204
- onError: { target: "loadingStartInfo" }
205
- } },
206
- loadingStartInfo: { invoke: {
207
- id: "fetchStartInfo",
208
- src: "fetchStartInfo",
209
- onDone: {
210
- target: "inputting",
211
- actions: "setStartInfo"
212
- },
213
- onError: { target: "inputting" }
214
- } },
215
- inputting: {
216
- entry: "clearPhoneError",
217
- on: {
218
- PHONE_CHANGED: { actions: "setPhone" },
219
- OPT_IN_CHANGED: { actions: "setOptInGranted" },
220
- SUBMIT: {
221
- target: "submitting",
222
- guard: "isValidPhone"
223
- }
224
- }
225
- },
226
- submitting: { invoke: {
227
- id: "submitPhone",
228
- src: "submitPhone",
229
- input: ({ context }) => ({
230
- phone: context.phone,
231
- optInGranted: context.config.optinEnabled ? context.optInGranted : void 0,
232
- isInstantVerify: context.config.isInstantVerify ?? false
233
- }),
234
- onDone: [{
235
- target: "sendingOtp",
236
- guard: "hasOtpVerification",
237
- actions: "sendPhoneSubmitEvent"
238
- }, {
239
- target: "finished",
240
- actions: "sendPhoneSubmitEvent"
241
- }],
242
- onError: {
243
- target: "inputting",
244
- actions: "setPhoneError"
245
- }
246
- } },
247
- sendingOtp: { invoke: {
248
- id: "sendOtp",
249
- src: "sendOtp",
250
- onDone: { target: "awaitingOtp" },
251
- onError: {
252
- target: "awaitingOtp",
253
- actions: "setError"
254
- }
255
- } },
256
- awaitingOtp: {
257
- entry: "startResendTimer",
258
- invoke: {
259
- id: "resendTimer",
260
- src: "resendTimer"
261
- },
262
- on: {
263
- TICK: { actions: "tickResendTimer" },
264
- OTP_CHANGED: { actions: "setOtpCode" },
265
- VERIFY_OTP: { target: "verifyingOtp" },
266
- RESEND_OTP: {
267
- target: "sendingOtp",
268
- guard: "canResend"
269
- },
270
- BACK: { target: "inputting" }
271
- }
272
- },
273
- verifyingOtp: { invoke: {
274
- id: "verifyOtp",
275
- src: "verifyOtp",
276
- input: ({ context }) => ({ code: context.otpCode }),
277
- onDone: [
278
- {
279
- target: "finished",
280
- guard: ({ event }) => event.output.success === true
281
- },
282
- {
283
- target: "otpError",
284
- guard: "hasAttemptsRemaining",
285
- actions: assign(({ context }) => ({
286
- otpError: "Invalid OTP code",
287
- attemptsRemaining: context.attemptsRemaining - 1
288
- }))
289
- },
290
- {
291
- target: "error",
292
- actions: assign({ error: () => "Maximum OTP attempts exceeded" })
293
- }
294
- ],
295
- onError: [{
296
- target: "otpError",
297
- guard: "hasAttemptsRemaining",
298
- actions: "setOtpError"
299
- }, {
300
- target: "error",
301
- actions: "setError"
302
- }]
303
- } },
304
- otpError: { on: {
305
- OTP_CHANGED: {
306
- target: "awaitingOtp",
307
- actions: "setOtpCode"
308
- },
309
- RESEND_OTP: {
310
- target: "sendingOtp",
311
- guard: "canResend"
312
- },
313
- BACK: { target: "inputting" }
314
- } },
315
- finished: { type: "final" },
316
- error: { on: { RESET: {
317
- target: "idle",
318
- actions: "resetContext"
319
- } } }
320
- }
321
- });
322
-
323
- //#endregion
324
- //#region src/modules/phone/phoneActor.ts
325
- function createPhoneActor(options) {
326
- return createActor(phoneMachine, { input: { config: options.config } }).start();
327
- }
328
-
329
- //#endregion
330
- //#region src/modules/phone/phoneManager.ts
331
- /**
332
- * @module @incodetech/core/phone
333
- *
334
- * Phone verification module for the Incode Web SDK.
335
- * Supports both headless (programmatic) and UI-driven usage patterns.
336
- *
337
- * ## Headless Usage
338
- *
339
- * The phone manager can be used entirely without UI for backend integrations,
340
- * custom UI implementations, or automated workflows.
341
- *
342
- * @example Basic headless phone verification with OTP
343
- * ```typescript
344
- * import { createPhoneManager } from '@incodetech/core/phone';
345
- * import { setup } from '@incodetech/core';
346
- *
347
- * // 1. Configure the SDK (required before using any module)
348
- * setup({ apiURL: 'https://api.example.com', token: 'your-token' });
349
- *
350
- * // 2. Create the phone manager
351
- * const phoneManager = createPhoneManager({
352
- * config: {
353
- * otpVerification: true,
354
- * otpExpirationInMinutes: 5,
355
- * prefill: false,
356
- * maxOtpAttempts: 3,
357
- * },
358
- * });
359
- *
360
- * // 3. Subscribe to state changes (optional but recommended)
361
- * phoneManager.subscribe((state) => {
362
- * console.log('Phone state:', state.status);
363
- * if (state.status === 'finished') {
364
- * console.log('Phone verified successfully!');
365
- * }
366
- * if (state.status === 'error') {
367
- * console.error('Error:', state.error);
368
- * }
369
- * });
370
- *
371
- * // 4. Start the flow
372
- * phoneManager.load();
373
- *
374
- * // 5. When state is 'inputting', set the phone number
375
- * phoneManager.setPhoneNumber('+14155551234', true);
376
- *
377
- * // 6. Submit the phone number
378
- * phoneManager.submit();
379
- *
380
- * // 7. When state is 'awaitingOtp', submit the OTP code
381
- * phoneManager.submitOtp('ABC123');
382
- *
383
- * // 8. Clean up when done
384
- * phoneManager.stop();
385
- * ```
386
- *
387
- * @example Polling-based headless usage
388
- * ```typescript
389
- * const phoneManager = createPhoneManager({ config });
390
- *
391
- * phoneManager.load();
392
- *
393
- * // Poll for state changes
394
- * const interval = setInterval(() => {
395
- * const state = phoneManager.getState();
396
- *
397
- * switch (state.status) {
398
- * case 'inputting':
399
- * phoneManager.setPhoneNumber('+14155551234', true);
400
- * phoneManager.submit();
401
- * break;
402
- * case 'awaitingOtp':
403
- * // Get OTP from user or external source
404
- * phoneManager.submitOtp(otpCode);
405
- * break;
406
- * case 'finished':
407
- * clearInterval(interval);
408
- * phoneManager.stop();
409
- * break;
410
- * case 'error':
411
- * clearInterval(interval);
412
- * console.error(state.error);
413
- * phoneManager.stop();
414
- * break;
415
- * }
416
- * }, 100);
417
- * ```
418
- */
419
- function mapState(snapshot) {
420
- const typedSnapshot = snapshot;
421
- const { context } = typedSnapshot;
422
- if (typedSnapshot.matches("idle")) return { status: "idle" };
423
- if (typedSnapshot.matches("loadingPrefill")) return { status: "loadingPrefill" };
424
- if (typedSnapshot.matches("loadingStartInfo")) return {
425
- status: "inputting",
426
- countryCode: context.countryCode,
427
- phonePrefix: context.phonePrefix,
428
- prefilledPhone: context.prefilledPhone
429
- };
430
- if (typedSnapshot.matches("inputting")) return {
431
- status: "inputting",
432
- countryCode: context.countryCode,
433
- phonePrefix: context.phonePrefix,
434
- prefilledPhone: context.prefilledPhone,
435
- phoneError: context.phoneError
436
- };
437
- if (typedSnapshot.matches("submitting")) return { status: "submitting" };
438
- if (typedSnapshot.matches("sendingOtp")) return { status: "sendingOtp" };
439
- if (typedSnapshot.matches("awaitingOtp")) return {
440
- status: "awaitingOtp",
441
- resendTimer: context.resendTimer,
442
- canResend: !context.resendTimerActive,
443
- attemptsRemaining: context.attemptsRemaining
444
- };
445
- if (typedSnapshot.matches("verifyingOtp")) return { status: "verifyingOtp" };
446
- if (typedSnapshot.matches("otpError")) return {
447
- status: "otpError",
448
- error: context.otpError ?? "Invalid OTP code",
449
- attemptsRemaining: context.attemptsRemaining
450
- };
451
- if (typedSnapshot.matches("finished")) return { status: "finished" };
452
- if (typedSnapshot.matches("error")) return {
453
- status: "error",
454
- error: context.error ?? "An error occurred"
455
- };
456
- return { status: "idle" };
457
- }
458
- function createApi({ actor }) {
459
- return {
460
- load() {
461
- actor.send({ type: "LOAD" });
462
- },
463
- setPhoneNumber(phone, isValid) {
464
- actor.send({
465
- type: "PHONE_CHANGED",
466
- phone,
467
- isValid
468
- });
469
- },
470
- setOptInGranted(granted) {
471
- actor.send({
472
- type: "OPT_IN_CHANGED",
473
- granted
474
- });
475
- },
476
- submit() {
477
- actor.send({ type: "SUBMIT" });
478
- },
479
- setOtpCode(code) {
480
- actor.send({
481
- type: "OTP_CHANGED",
482
- code
483
- });
484
- },
485
- submitOtp(code) {
486
- actor.send({
487
- type: "OTP_CHANGED",
488
- code
489
- });
490
- actor.send({ type: "VERIFY_OTP" });
491
- },
492
- resendOtp() {
493
- actor.send({ type: "RESEND_OTP" });
494
- },
495
- back() {
496
- actor.send({ type: "BACK" });
497
- },
498
- reset() {
499
- actor.send({ type: "RESET" });
500
- }
501
- };
502
- }
503
- /**
504
- * Creates a phone verification manager for headless or UI-driven usage.
505
- *
506
- * The manager provides a state machine-based API for phone number verification
507
- * with optional OTP (one-time password) verification.
508
- *
509
- * @param options - Configuration options
510
- * @param options.config - Phone verification configuration
511
- * @param options.config.otpVerification - Whether to require OTP verification
512
- * @param options.config.otpExpirationInMinutes - How long the OTP is valid
513
- * @param options.config.prefill - Whether to fetch a pre-filled phone number
514
- * @param options.config.isInstantVerify - Use instant verification API
515
- * @param options.config.optinEnabled - Show marketing opt-in checkbox
516
- * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
517
- *
518
- * @returns Phone manager with state, API methods, and subscription
519
- *
520
- * @example Headless usage
521
- * ```typescript
522
- * const manager = createPhoneManager({
523
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
524
- * });
525
- *
526
- * manager.subscribe((state) => console.log(state.status));
527
- * manager.load();
528
- * manager.setPhoneNumber('+14155551234', true);
529
- * manager.submit();
530
- * // ... wait for 'awaitingOtp' state ...
531
- * manager.submitOtp('ABC123');
532
- * manager.stop();
533
- * ```
534
- *
535
- * @example With React/Preact UI hook
536
- * ```tsx
537
- * const [state, manager] = useManager(() => createPhoneManager({ config }));
538
- *
539
- * if (state.status === 'inputting') {
540
- * return <input onChange={(e) => manager.setPhoneNumber(e.target.value, true)} />;
541
- * }
542
- * ```
543
- */
544
- function createPhoneManager(options) {
545
- return createManager({
546
- actor: createPhoneActor(options),
547
- mapState,
548
- createApi
549
- });
550
- }
551
-
552
- //#endregion
553
8
  export { createPhoneManager, phoneMachine };