@incodetech/core 0.0.0-dev-20260409-a38d5e8 → 0.0.0-dev-20260409-09dfd52

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/dist/BrowserStorageProvider-CXaS5Ooj.esm.js +55 -0
  2. package/dist/{OpenViduRecordingProvider-Bn2meybK.esm.js → OpenViduRecordingProvider-D_cVAwYQ.esm.js} +1 -1
  3. package/dist/{WasmUtilProvider-BpZSvZbg.esm.js → WasmUtilProvider-mWSXzp7b.esm.js} +1 -1
  4. package/dist/{addressSearch-DOFI7lwy.esm.js → addressSearch-C26OZIx0.esm.js} +4 -4
  5. package/dist/antifraud.d.ts +1 -1
  6. package/dist/antifraud.esm.js +4 -37
  7. package/dist/antifraudStateMachine-B74mO8vr.esm.js +39 -0
  8. package/dist/authentication.d.ts +11 -11
  9. package/dist/authentication.esm.js +22 -19
  10. package/dist/authenticationManager-BBQHippG.esm.js +67 -0
  11. package/dist/{authenticationManager-C2mk36yK.d.ts → authenticationManager-DOTo1EYF.d.ts} +2 -2
  12. package/dist/{authenticationManager-C7dL_avf.esm.js → authenticationStateMachine-DCJ0ArAt.esm.js} +7 -67
  13. package/dist/{backCameraStream-tabTmwDS.esm.js → backCameraStream-D9g2wyil.esm.js} +3 -3
  14. package/dist/camera.d.ts +1 -1
  15. package/dist/camera.esm.js +3 -3
  16. package/dist/consent.d.ts +55 -55
  17. package/dist/consent.esm.js +4 -149
  18. package/dist/consentStateMachine-DIdJXJW0.esm.js +151 -0
  19. package/dist/cross-document-data-match.d.ts +1 -1
  20. package/dist/cross-document-data-match.esm.js +4 -4
  21. package/dist/curp-validation.d.ts +5 -5
  22. package/dist/curp-validation.esm.js +4 -417
  23. package/dist/curpValidationStateMachine-Dp5WB6__.esm.js +419 -0
  24. package/dist/{deepsightLoader-Cj6SyUQ-.esm.js → deepsightLoader-CaULV07H.esm.js} +10 -10
  25. package/dist/{deepsightService-ByD6uIs7.d.ts → deepsightService-S-tU77m-.d.ts} +2 -2
  26. package/dist/{deepsightService-BjgXl5hs.esm.js → deepsightService-rPGLH8Xp.esm.js} +5 -5
  27. package/dist/device.esm.js +3 -3
  28. package/dist/document-capture.d.ts +80 -78
  29. package/dist/document-capture.esm.js +8 -403
  30. package/dist/document-upload.d.ts +53 -53
  31. package/dist/document-upload.esm.js +7 -7
  32. package/dist/documentCaptureStateMachine-ByYOCKz5.esm.js +403 -0
  33. package/dist/ekyb.d.ts +3 -3
  34. package/dist/ekyb.esm.js +10 -655
  35. package/dist/ekybStateMachine-DRku_YmR.esm.js +653 -0
  36. package/dist/ekyc.d.ts +3 -3
  37. package/dist/ekyc.esm.js +6 -10614
  38. package/dist/ekycStateMachine-CSWaaWVl.esm.js +10615 -0
  39. package/dist/email.d.ts +3 -3
  40. package/dist/email.esm.js +6 -5
  41. package/dist/{emailManager-CU_hzrsl.d.ts → emailManager-D6CHM2QO.d.ts} +4 -3
  42. package/dist/emailManager-DByjyeY8.esm.js +238 -0
  43. package/dist/{emailManager-_9R4vm6g.esm.js → emailStateMachine-BoIkeCw5.esm.js} +6 -239
  44. package/dist/{events-DlHrOIRc.esm.js → events-W91zLpx4.esm.js} +5 -1
  45. package/dist/events.esm.js +2 -2
  46. package/dist/extensibility.d.ts +15 -15
  47. package/dist/extensibility.esm.js +33 -26
  48. package/dist/face-match.d.ts +7 -6
  49. package/dist/face-match.esm.js +8 -129
  50. package/dist/faceCaptureManagerFactory-Bspg2Tyf.esm.js +117 -0
  51. package/dist/{faceCaptureManagerFactory-Da_-ohdg.d.ts → faceCaptureManagerFactory-P2yy30KU.d.ts} +8 -8
  52. package/dist/{faceCaptureSetup-CaVWkjvE.esm.js → faceCaptureSetup-CQevz86q.esm.js} +5 -119
  53. package/dist/faceMatchStateMachine-CLterVEC.esm.js +127 -0
  54. package/dist/flow.d.ts +8 -13
  55. package/dist/flow.esm.js +10 -29
  56. package/dist/{flowCompletionService-B5JemmC6.esm.js → flowCompletionService-DZSDUXus.esm.js} +2 -2
  57. package/dist/{flowServices-p22wrYPf.esm.js → flowServices-YATk0fgY.esm.js} +3 -3
  58. package/dist/geolocation.d.ts +7 -6
  59. package/dist/geolocation.esm.js +7 -105
  60. package/dist/geolocationStateMachine-CRRUCl9K.esm.js +105 -0
  61. package/dist/{getDeviceClass-DEzz4cmY.esm.js → getDeviceClass-DBF-ExLR.esm.js} +1 -1
  62. package/dist/government-validation.d.ts +2 -2
  63. package/dist/government-validation.esm.js +5 -269
  64. package/dist/governmentValidationStateMachine-C_iPX9VE.esm.js +271 -0
  65. package/dist/http.esm.js +1 -1
  66. package/dist/id.d.ts +10 -10
  67. package/dist/id.esm.js +22 -20
  68. package/dist/idCaptureManager-CJfatzuY.esm.js +335 -0
  69. package/dist/{idCaptureManager-CV08v1e3.d.ts → idCaptureManager-CbZvdr9y.d.ts} +7 -7
  70. package/dist/{idCaptureManager-dyZzKv8L.esm.js → idCaptureStateMachine-gf-Q9piu.esm.js} +17 -346
  71. package/dist/index.d.ts +2 -2
  72. package/dist/index.esm.js +8 -8
  73. package/dist/{lib-Bavz2qmt.esm.js → lib-BzVJ-zxG.esm.js} +1 -1
  74. package/dist/mandatory-consent.d.ts +55 -55
  75. package/dist/mandatory-consent.esm.js +4 -124
  76. package/dist/mandatoryConsentStateMachine-BZNBJ1fK.esm.js +126 -0
  77. package/dist/{openviduLazy-vhrVZCr_.esm.js → openviduLazy-CLg_-u0m.esm.js} +2 -2
  78. package/dist/openviduLazy-rFXBtZVZ.esm.js +3 -0
  79. package/dist/{permissionServices-Cskq32Yd.esm.js → permissionServices-Cisv73eQ.esm.js} +2 -2
  80. package/dist/phone.d.ts +3 -3
  81. package/dist/phone.esm.js +6 -5
  82. package/dist/phoneManager-DhC4obPF.esm.js +258 -0
  83. package/dist/{phoneManager-ulJuGvJ8.d.ts → phoneManager-Zwr-qCnC.d.ts} +2 -2
  84. package/dist/{phoneManager-DerdUfd4.esm.js → phoneStateMachine-Cc_w4tC0.esm.js} +5 -258
  85. package/dist/{recordingService-483wQ6kR.esm.js → recordingService-CCfxUY7-.esm.js} +14 -68
  86. package/dist/redirect-to-mobile.d.ts +2 -2
  87. package/dist/redirect-to-mobile.esm.js +5 -247
  88. package/dist/redirectToMobileStateMachine-vOe27Ufw.esm.js +249 -0
  89. package/dist/runChildModule-DVC4JEjp.esm.js +27 -0
  90. package/dist/selfie.d.ts +11 -11
  91. package/dist/selfie.esm.js +22 -19
  92. package/dist/selfieManager-CorEST5h.esm.js +60 -0
  93. package/dist/{selfieManager-DCRP7X75.d.ts → selfieManager-DNwfxieF.d.ts} +2 -2
  94. package/dist/selfieStateMachine-3b19ON1z.esm.js +56 -0
  95. package/dist/{session-CUh77zj3.esm.js → session-B_rKSRql.esm.js} +4 -4
  96. package/dist/session.d.ts +1 -1
  97. package/dist/session.esm.js +6 -6
  98. package/dist/{setup-DpHakxsC.d.ts → setup-BYqwVLiv.d.ts} +1 -1
  99. package/dist/{setup-XpxfZgKn.esm.js → setup-DLvhsDol.esm.js} +6 -5
  100. package/dist/signature.d.ts +4 -3
  101. package/dist/signature.esm.js +6 -189
  102. package/dist/signatureStateMachine-CU92zCXU.esm.js +189 -0
  103. package/dist/{stats-DHDoqSBV.esm.js → stats-gFD2351t.esm.js} +1 -1
  104. package/dist/stats.esm.js +2 -2
  105. package/dist/{types-2OPf1pyv.d.ts → types-CYJ0Ish6.d.ts} +1 -1
  106. package/dist/types-CjsEZRcz.d.ts +35 -0
  107. package/dist/{types-CVJVQ7fp.d.ts → types-DU8HmI5U.d.ts} +1 -1
  108. package/dist/wasm.d.ts +2 -2
  109. package/dist/wasm.esm.js +8 -8
  110. package/dist/workflow.d.ts +813 -0
  111. package/dist/workflow.esm.js +600 -0
  112. package/package.json +7 -3
  113. package/dist/openviduLazy-BIPHozOu.esm.js +0 -3
  114. package/dist/selfieManager-DeOcNel4.esm.js +0 -110
  115. /package/dist/{Actor-Ba71-_30.d.ts → Actor-DbWH1K6E.d.ts} +0 -0
  116. /package/dist/{BaseWasmProvider-D-s_6M5H.esm.js → BaseWasmProvider-DoYDYH1z.esm.js} +0 -0
  117. /package/dist/{BrowserEnvironmentProvider-DaHeLJQw.esm.js → BrowserEnvironmentProvider-BtKLxTx4.esm.js} +0 -0
  118. /package/dist/{BrowserTimerProvider-BhD2MlHg.esm.js → BrowserTimerProvider-v7bpbrAk.esm.js} +0 -0
  119. /package/dist/{ITimerCapability-oixwa6nj.esm.js → ITimerCapability-BZO_FsCo.esm.js} +0 -0
  120. /package/dist/{Manager-BN2g_I8W.d.ts → Manager-DcPMRgTm.d.ts} +0 -0
  121. /package/dist/{MotionSensorProvider-CodM3e0E.esm.js → MotionSensorProvider-D90R4qwV.esm.js} +0 -0
  122. /package/dist/{StateMachine-BoJsfMvg.d.ts → StateMachine-BBuIgsHT.d.ts} +0 -0
  123. /package/dist/{api-DzpnV6O7.esm.js → api-aa9Mx20l.esm.js} +0 -0
  124. /package/dist/{browserSimulation-B4ubb2OL.esm.js → browserSimulation-DFqGKQAD.esm.js} +0 -0
  125. /package/dist/{camera-1eeGnAaL.d.ts → camera-DATT31my.d.ts} +0 -0
  126. /package/dist/{camera-DmkFpf5N.esm.js → camera-DpPQS_-5.esm.js} +0 -0
  127. /package/dist/{chunk-DsxENsBR.esm.js → chunk-YGHKo4MY.esm.js} +0 -0
  128. /package/dist/{displayErrors-BZLX7idb.d.ts → displayErrors-xrg0ejaS.d.ts} +0 -0
  129. /package/dist/{flowCompletionService-D-3YCHyO.d.ts → flowCompletionService-gxt5reFV.d.ts} +0 -0
  130. /package/dist/{getBrowser-Dtyt9J_h.esm.js → getBrowser-DCcD7H-M.esm.js} +0 -0
  131. /package/dist/{platform-Dv7a2fv-.esm.js → platform-DctkySJU.esm.js} +0 -0
  132. /package/dist/{types-D_QfFKxT.d.ts → types-CIjb0FKu.d.ts} +0 -0
  133. /package/dist/{warmup-CIj_wEV_.d.ts → warmup-Ckb1hN85.d.ts} +0 -0
  134. /package/dist/{xstate.esm-Bv55-lJ4.esm.js → xstate.esm-B7FPE6br.esm.js} +0 -0
@@ -0,0 +1,258 @@
1
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-W91zLpx4.esm.js";
2
+ import { a as createActor, o as createManager } from "./xstate.esm-B7FPE6br.esm.js";
3
+ import { t as phoneMachine } from "./phoneStateMachine-Cc_w4tC0.esm.js";
4
+
5
+ //#region src/modules/phone/phoneActor.ts
6
+ function createPhoneActor(options) {
7
+ return createActor(phoneMachine, { input: { config: options.config } }).start();
8
+ }
9
+
10
+ //#endregion
11
+ //#region src/modules/phone/phoneManager.ts
12
+ /**
13
+ * @module @incodetech/core/phone
14
+ *
15
+ * Phone verification module for the Incode Web SDK.
16
+ * Supports both headless (programmatic) and UI-driven usage patterns.
17
+ *
18
+ * ## Headless Usage
19
+ *
20
+ * The phone manager can be used entirely without UI for backend integrations,
21
+ * custom UI implementations, or automated workflows.
22
+ *
23
+ * @example Basic headless phone verification with OTP
24
+ * ```typescript
25
+ * import { createPhoneManager } from '@incodetech/core/phone';
26
+ * import { setup } from '@incodetech/core';
27
+ *
28
+ * // 1. Configure the SDK (required before using any module)
29
+ * setup({ apiURL: 'https://api.example.com', token: 'your-token' });
30
+ *
31
+ * // 2. Create the phone manager
32
+ * const phoneManager = createPhoneManager({
33
+ * config: {
34
+ * otpVerification: true,
35
+ * otpExpirationInMinutes: 5,
36
+ * prefill: false,
37
+ * maxOtpAttempts: 3,
38
+ * },
39
+ * });
40
+ *
41
+ * // 3. Subscribe to state changes (optional but recommended)
42
+ * phoneManager.subscribe((state) => {
43
+ * console.log('Phone state:', state.status);
44
+ * if (state.status === 'finished') {
45
+ * console.log('Phone verified successfully!');
46
+ * }
47
+ * if (state.status === 'error') {
48
+ * console.error('Error:', state.error);
49
+ * }
50
+ * });
51
+ *
52
+ * // 4. Start the flow
53
+ * phoneManager.load();
54
+ *
55
+ * // 5. When state is 'inputting', set the phone number
56
+ * phoneManager.setPhoneNumber('+14155551234', true);
57
+ *
58
+ * // 6. Submit the phone number
59
+ * phoneManager.submit();
60
+ *
61
+ * // 7. When state is 'awaitingOtp', submit the OTP code
62
+ * phoneManager.submitOtp('ABC123');
63
+ *
64
+ * // 8. Clean up when done
65
+ * phoneManager.stop();
66
+ * ```
67
+ *
68
+ * @example Polling-based headless usage
69
+ * ```typescript
70
+ * const phoneManager = createPhoneManager({ config });
71
+ *
72
+ * phoneManager.load();
73
+ *
74
+ * // Poll for state changes
75
+ * const interval = setInterval(() => {
76
+ * const state = phoneManager.getState();
77
+ *
78
+ * switch (state.status) {
79
+ * case 'inputting':
80
+ * phoneManager.setPhoneNumber('+14155551234', true);
81
+ * phoneManager.submit();
82
+ * break;
83
+ * case 'awaitingOtp':
84
+ * // Get OTP from user or external source
85
+ * phoneManager.submitOtp(otpCode);
86
+ * break;
87
+ * case 'finished':
88
+ * clearInterval(interval);
89
+ * phoneManager.stop();
90
+ * break;
91
+ * case 'error':
92
+ * clearInterval(interval);
93
+ * console.error(state.error);
94
+ * phoneManager.stop();
95
+ * break;
96
+ * }
97
+ * }, 100);
98
+ * ```
99
+ */
100
+ function mapState(snapshot) {
101
+ const typedSnapshot = snapshot;
102
+ const { context } = typedSnapshot;
103
+ if (typedSnapshot.matches("idle")) return { status: "idle" };
104
+ if (typedSnapshot.matches("loadingPrefill")) return { status: "loadingPrefill" };
105
+ if (typedSnapshot.matches("loadingStartInfo")) return {
106
+ status: "inputting",
107
+ countryCode: context.countryCode,
108
+ phonePrefix: context.phonePrefix,
109
+ prefilledPhone: context.prefilledPhone,
110
+ otpVerification: context.config.otpVerification,
111
+ optinEnabled: context.config.optinEnabled ?? false
112
+ };
113
+ if (typedSnapshot.matches("inputting")) return {
114
+ status: "inputting",
115
+ countryCode: context.countryCode,
116
+ phonePrefix: context.phonePrefix,
117
+ prefilledPhone: context.prefilledPhone,
118
+ phoneError: context.phoneError,
119
+ otpVerification: context.config.otpVerification,
120
+ optinEnabled: context.config.optinEnabled ?? false
121
+ };
122
+ if (typedSnapshot.matches("submitting")) return { status: "submitting" };
123
+ if (typedSnapshot.matches("resendingOtp")) return { status: "resendingOtp" };
124
+ if (typedSnapshot.matches("sendingInitialOtp")) return { status: "sendingInitialOtp" };
125
+ if (typedSnapshot.matches("awaitingOtp")) return {
126
+ status: "awaitingOtp",
127
+ resendTimer: context.resendTimer,
128
+ canResend: !context.resendTimerActive,
129
+ attemptsRemaining: context.attemptsRemaining
130
+ };
131
+ if (typedSnapshot.matches("verifyingOtp")) return {
132
+ status: "verifyingOtp",
133
+ resendTimer: context.resendTimer,
134
+ canResend: !context.resendTimerActive
135
+ };
136
+ if (typedSnapshot.matches("otpError")) return {
137
+ status: "otpError",
138
+ otpError: context.otpError ?? "otp.errorv2",
139
+ attemptsRemaining: context.attemptsRemaining,
140
+ resendTimer: context.resendTimer,
141
+ canResend: !context.resendTimerActive
142
+ };
143
+ if (typedSnapshot.matches("finished")) return { status: "finished" };
144
+ if (typedSnapshot.matches("error")) return {
145
+ status: "error",
146
+ error: context.error ?? "An error occurred"
147
+ };
148
+ return { status: "idle" };
149
+ }
150
+ function createApi({ actor, trackElementClicked }) {
151
+ return {
152
+ load() {
153
+ actor.send({ type: "LOAD" });
154
+ },
155
+ setPhoneNumber(phone, isValid) {
156
+ actor.send({
157
+ type: "PHONE_CHANGED",
158
+ phone,
159
+ isValid
160
+ });
161
+ },
162
+ setOptInGranted(granted) {
163
+ actor.send({
164
+ type: "OPT_IN_CHANGED",
165
+ granted
166
+ });
167
+ },
168
+ submit() {
169
+ trackElementClicked?.("submit");
170
+ actor.send({ type: "SUBMIT" });
171
+ },
172
+ setOtpCode(code) {
173
+ actor.send({
174
+ type: "OTP_CHANGED",
175
+ code
176
+ });
177
+ },
178
+ submitOtp(code) {
179
+ trackElementClicked?.("submitOtp");
180
+ actor.send({
181
+ type: "OTP_CHANGED",
182
+ code
183
+ });
184
+ actor.send({ type: "VERIFY_OTP" });
185
+ },
186
+ resendOtp() {
187
+ trackElementClicked?.("resendOtp");
188
+ actor.send({ type: "RESEND_OTP" });
189
+ },
190
+ back() {
191
+ trackElementClicked?.("back");
192
+ actor.send({ type: "BACK" });
193
+ },
194
+ reset() {
195
+ actor.send({ type: "RESET" });
196
+ }
197
+ };
198
+ }
199
+ /**
200
+ * Creates a phone verification manager for headless or UI-driven usage.
201
+ *
202
+ * The manager provides a state machine-based API for phone number verification
203
+ * with optional OTP (one-time password) verification.
204
+ *
205
+ * @param options - Configuration options
206
+ * @param options.config - Phone verification configuration
207
+ * @param options.config.otpVerification - Whether to require OTP verification
208
+ * @param options.config.otpExpirationInMinutes - How long the OTP is valid
209
+ * @param options.config.prefill - Whether to fetch a pre-filled phone number
210
+ * @param options.config.isInstantVerify - Use instant verification API
211
+ * @param options.config.optinEnabled - Show marketing opt-in checkbox
212
+ * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
213
+ *
214
+ * @returns Phone manager with state, API methods, and subscription
215
+ *
216
+ * @example Headless usage
217
+ * ```typescript
218
+ * const manager = createPhoneManager({
219
+ * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
220
+ * });
221
+ *
222
+ * manager.subscribe((state) => console.log(state.status));
223
+ * manager.load();
224
+ * manager.setPhoneNumber('+14155551234', true);
225
+ * manager.submit();
226
+ * // ... wait for 'awaitingOtp' state ...
227
+ * manager.submitOtp('ABC123');
228
+ * manager.stop();
229
+ * ```
230
+ *
231
+ * @example With React/Preact UI hook
232
+ * ```tsx
233
+ * const [state, manager] = useManager(() => createPhoneManager({ config }));
234
+ *
235
+ * if (state.status === 'inputting') {
236
+ * return <input onChange={(e) => manager.setPhoneNumber(e.target.value, true)} />;
237
+ * }
238
+ * ```
239
+ */
240
+ function createPhoneManager(options) {
241
+ return createManager({
242
+ actor: createPhoneActor(options),
243
+ mapState,
244
+ createApi,
245
+ instrumentation: createManagerInstrumentation(eventModuleNames.phone)
246
+ });
247
+ }
248
+ function createPhoneManagerFromActor(actor) {
249
+ return createManager({
250
+ actor,
251
+ mapState,
252
+ createApi,
253
+ instrumentation: createManagerInstrumentation(eventModuleNames.phone)
254
+ });
255
+ }
256
+
257
+ //#endregion
258
+ export { createPhoneManagerFromActor as n, createPhoneManager as t };
@@ -1,5 +1,5 @@
1
- import { t as Manager } from "./Manager-BN2g_I8W.js";
2
- import { t as ActorRefFrom } from "./Actor-Ba71-_30.js";
1
+ import { t as Manager } from "./Manager-DcPMRgTm.js";
2
+ import { t as ActorRefFrom } from "./Actor-DbWH1K6E.js";
3
3
 
4
4
  //#region src/modules/phone/types.d.ts
5
5
 
@@ -1,7 +1,7 @@
1
- import { t as api } from "./api-DzpnV6O7.esm.js";
2
- import { _ as endpoints, n as eventModuleNames, o as createManagerInstrumentation } from "./events-DlHrOIRc.esm.js";
3
- import { a as createActor, i as fromPromise, n as assign, o as createManager, r as fromCallback, t as setup } from "./xstate.esm-Bv55-lJ4.esm.js";
4
- import { t as BrowserTimerProvider } from "./BrowserTimerProvider-BhD2MlHg.esm.js";
1
+ import { t as api } from "./api-aa9Mx20l.esm.js";
2
+ import { _ as endpoints } from "./events-W91zLpx4.esm.js";
3
+ import { i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-B7FPE6br.esm.js";
4
+ import { t as BrowserTimerProvider } from "./BrowserTimerProvider-v7bpbrAk.esm.js";
5
5
 
6
6
  //#region src/modules/phone/phoneServices.ts
7
7
  async function fetchPhone(signal) {
@@ -332,257 +332,4 @@ const phoneMachine = setup({
332
332
  });
333
333
 
334
334
  //#endregion
335
- //#region src/modules/phone/phoneActor.ts
336
- function createPhoneActor(options) {
337
- return createActor(phoneMachine, { input: { config: options.config } }).start();
338
- }
339
-
340
- //#endregion
341
- //#region src/modules/phone/phoneManager.ts
342
- /**
343
- * @module @incodetech/core/phone
344
- *
345
- * Phone verification module for the Incode Web SDK.
346
- * Supports both headless (programmatic) and UI-driven usage patterns.
347
- *
348
- * ## Headless Usage
349
- *
350
- * The phone manager can be used entirely without UI for backend integrations,
351
- * custom UI implementations, or automated workflows.
352
- *
353
- * @example Basic headless phone verification with OTP
354
- * ```typescript
355
- * import { createPhoneManager } from '@incodetech/core/phone';
356
- * import { setup } from '@incodetech/core';
357
- *
358
- * // 1. Configure the SDK (required before using any module)
359
- * setup({ apiURL: 'https://api.example.com', token: 'your-token' });
360
- *
361
- * // 2. Create the phone manager
362
- * const phoneManager = createPhoneManager({
363
- * config: {
364
- * otpVerification: true,
365
- * otpExpirationInMinutes: 5,
366
- * prefill: false,
367
- * maxOtpAttempts: 3,
368
- * },
369
- * });
370
- *
371
- * // 3. Subscribe to state changes (optional but recommended)
372
- * phoneManager.subscribe((state) => {
373
- * console.log('Phone state:', state.status);
374
- * if (state.status === 'finished') {
375
- * console.log('Phone verified successfully!');
376
- * }
377
- * if (state.status === 'error') {
378
- * console.error('Error:', state.error);
379
- * }
380
- * });
381
- *
382
- * // 4. Start the flow
383
- * phoneManager.load();
384
- *
385
- * // 5. When state is 'inputting', set the phone number
386
- * phoneManager.setPhoneNumber('+14155551234', true);
387
- *
388
- * // 6. Submit the phone number
389
- * phoneManager.submit();
390
- *
391
- * // 7. When state is 'awaitingOtp', submit the OTP code
392
- * phoneManager.submitOtp('ABC123');
393
- *
394
- * // 8. Clean up when done
395
- * phoneManager.stop();
396
- * ```
397
- *
398
- * @example Polling-based headless usage
399
- * ```typescript
400
- * const phoneManager = createPhoneManager({ config });
401
- *
402
- * phoneManager.load();
403
- *
404
- * // Poll for state changes
405
- * const interval = setInterval(() => {
406
- * const state = phoneManager.getState();
407
- *
408
- * switch (state.status) {
409
- * case 'inputting':
410
- * phoneManager.setPhoneNumber('+14155551234', true);
411
- * phoneManager.submit();
412
- * break;
413
- * case 'awaitingOtp':
414
- * // Get OTP from user or external source
415
- * phoneManager.submitOtp(otpCode);
416
- * break;
417
- * case 'finished':
418
- * clearInterval(interval);
419
- * phoneManager.stop();
420
- * break;
421
- * case 'error':
422
- * clearInterval(interval);
423
- * console.error(state.error);
424
- * phoneManager.stop();
425
- * break;
426
- * }
427
- * }, 100);
428
- * ```
429
- */
430
- function mapState(snapshot) {
431
- const typedSnapshot = snapshot;
432
- const { context } = typedSnapshot;
433
- if (typedSnapshot.matches("idle")) return { status: "idle" };
434
- if (typedSnapshot.matches("loadingPrefill")) return { status: "loadingPrefill" };
435
- if (typedSnapshot.matches("loadingStartInfo")) return {
436
- status: "inputting",
437
- countryCode: context.countryCode,
438
- phonePrefix: context.phonePrefix,
439
- prefilledPhone: context.prefilledPhone,
440
- otpVerification: context.config.otpVerification,
441
- optinEnabled: context.config.optinEnabled ?? false
442
- };
443
- if (typedSnapshot.matches("inputting")) return {
444
- status: "inputting",
445
- countryCode: context.countryCode,
446
- phonePrefix: context.phonePrefix,
447
- prefilledPhone: context.prefilledPhone,
448
- phoneError: context.phoneError,
449
- otpVerification: context.config.otpVerification,
450
- optinEnabled: context.config.optinEnabled ?? false
451
- };
452
- if (typedSnapshot.matches("submitting")) return { status: "submitting" };
453
- if (typedSnapshot.matches("resendingOtp")) return { status: "resendingOtp" };
454
- if (typedSnapshot.matches("sendingInitialOtp")) return { status: "sendingInitialOtp" };
455
- if (typedSnapshot.matches("awaitingOtp")) return {
456
- status: "awaitingOtp",
457
- resendTimer: context.resendTimer,
458
- canResend: !context.resendTimerActive,
459
- attemptsRemaining: context.attemptsRemaining
460
- };
461
- if (typedSnapshot.matches("verifyingOtp")) return {
462
- status: "verifyingOtp",
463
- resendTimer: context.resendTimer,
464
- canResend: !context.resendTimerActive
465
- };
466
- if (typedSnapshot.matches("otpError")) return {
467
- status: "otpError",
468
- otpError: context.otpError ?? "otp.errorv2",
469
- attemptsRemaining: context.attemptsRemaining,
470
- resendTimer: context.resendTimer,
471
- canResend: !context.resendTimerActive
472
- };
473
- if (typedSnapshot.matches("finished")) return { status: "finished" };
474
- if (typedSnapshot.matches("error")) return {
475
- status: "error",
476
- error: context.error ?? "An error occurred"
477
- };
478
- return { status: "idle" };
479
- }
480
- function createApi({ actor, trackElementClicked }) {
481
- return {
482
- load() {
483
- actor.send({ type: "LOAD" });
484
- },
485
- setPhoneNumber(phone, isValid) {
486
- actor.send({
487
- type: "PHONE_CHANGED",
488
- phone,
489
- isValid
490
- });
491
- },
492
- setOptInGranted(granted) {
493
- actor.send({
494
- type: "OPT_IN_CHANGED",
495
- granted
496
- });
497
- },
498
- submit() {
499
- trackElementClicked?.("submit");
500
- actor.send({ type: "SUBMIT" });
501
- },
502
- setOtpCode(code) {
503
- actor.send({
504
- type: "OTP_CHANGED",
505
- code
506
- });
507
- },
508
- submitOtp(code) {
509
- trackElementClicked?.("submitOtp");
510
- actor.send({
511
- type: "OTP_CHANGED",
512
- code
513
- });
514
- actor.send({ type: "VERIFY_OTP" });
515
- },
516
- resendOtp() {
517
- trackElementClicked?.("resendOtp");
518
- actor.send({ type: "RESEND_OTP" });
519
- },
520
- back() {
521
- trackElementClicked?.("back");
522
- actor.send({ type: "BACK" });
523
- },
524
- reset() {
525
- actor.send({ type: "RESET" });
526
- }
527
- };
528
- }
529
- /**
530
- * Creates a phone verification manager for headless or UI-driven usage.
531
- *
532
- * The manager provides a state machine-based API for phone number verification
533
- * with optional OTP (one-time password) verification.
534
- *
535
- * @param options - Configuration options
536
- * @param options.config - Phone verification configuration
537
- * @param options.config.otpVerification - Whether to require OTP verification
538
- * @param options.config.otpExpirationInMinutes - How long the OTP is valid
539
- * @param options.config.prefill - Whether to fetch a pre-filled phone number
540
- * @param options.config.isInstantVerify - Use instant verification API
541
- * @param options.config.optinEnabled - Show marketing opt-in checkbox
542
- * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
543
- *
544
- * @returns Phone manager with state, API methods, and subscription
545
- *
546
- * @example Headless usage
547
- * ```typescript
548
- * const manager = createPhoneManager({
549
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
550
- * });
551
- *
552
- * manager.subscribe((state) => console.log(state.status));
553
- * manager.load();
554
- * manager.setPhoneNumber('+14155551234', true);
555
- * manager.submit();
556
- * // ... wait for 'awaitingOtp' state ...
557
- * manager.submitOtp('ABC123');
558
- * manager.stop();
559
- * ```
560
- *
561
- * @example With React/Preact UI hook
562
- * ```tsx
563
- * const [state, manager] = useManager(() => createPhoneManager({ config }));
564
- *
565
- * if (state.status === 'inputting') {
566
- * return <input onChange={(e) => manager.setPhoneNumber(e.target.value, true)} />;
567
- * }
568
- * ```
569
- */
570
- function createPhoneManager(options) {
571
- return createManager({
572
- actor: createPhoneActor(options),
573
- mapState,
574
- createApi,
575
- instrumentation: createManagerInstrumentation(eventModuleNames.phone)
576
- });
577
- }
578
- function createPhoneManagerFromActor(actor) {
579
- return createManager({
580
- actor,
581
- mapState,
582
- createApi,
583
- instrumentation: createManagerInstrumentation(eventModuleNames.phone)
584
- });
585
- }
586
-
587
- //#endregion
588
- export { createPhoneManagerFromActor as n, phoneMachine as r, createPhoneManager as t };
335
+ export { phoneMachine as t };
@@ -1,67 +1,13 @@
1
- import { i as WasmPipelineType, r as mlWasmJSApi_default, t as BaseWasmProvider } from "./BaseWasmProvider-D-s_6M5H.esm.js";
2
- import { t as api } from "./api-DzpnV6O7.esm.js";
3
- import { _ as endpoints } from "./events-DlHrOIRc.esm.js";
4
- import { n as IncodeCanvas } from "./deepsightService-BjgXl5hs.esm.js";
5
- import { i as stopCameraStream, r as requestCameraAccess } from "./camera-DmkFpf5N.esm.js";
6
- import { t as addDeviceStats } from "./stats-DHDoqSBV.esm.js";
7
- import { a as isIPhone14OrHigher, n as isDesktop, r as isIOS, t as isAndroid } from "./platform-Dv7a2fv-.esm.js";
8
- import { n as getDesktopCameraStream, t as getBackCameraStream } from "./backCameraStream-tabTmwDS.esm.js";
9
- import { t as getDeviceClass } from "./getDeviceClass-DEzz4cmY.esm.js";
1
+ import { i as WasmPipelineType, r as mlWasmJSApi_default, t as BaseWasmProvider } from "./BaseWasmProvider-DoYDYH1z.esm.js";
2
+ import { t as api } from "./api-aa9Mx20l.esm.js";
3
+ import { _ as endpoints } from "./events-W91zLpx4.esm.js";
4
+ import { n as IncodeCanvas } from "./deepsightService-rPGLH8Xp.esm.js";
5
+ import { i as stopCameraStream, r as requestCameraAccess } from "./camera-DpPQS_-5.esm.js";
6
+ import { t as addDeviceStats } from "./stats-gFD2351t.esm.js";
7
+ import { a as isIPhone14OrHigher, n as isDesktop, r as isIOS, t as isAndroid } from "./platform-DctkySJU.esm.js";
8
+ import { n as getDesktopCameraStream, t as getBackCameraStream } from "./backCameraStream-D9g2wyil.esm.js";
9
+ import { t as getDeviceClass } from "./getDeviceClass-DBF-ExLR.esm.js";
10
10
 
11
- //#region ../infra/src/providers/browser/BrowserStorageProvider.ts
12
- /**
13
- * Browser-based storage provider wrapping localStorage.
14
- * Handles JSON serialization/deserialization automatically.
15
- */
16
- var BrowserStorageProvider = class {
17
- /**
18
- * Retrieves a value from localStorage.
19
- * @param key - The storage key
20
- * @returns The stored value or null if not found
21
- * @throws Error if stored value is invalid JSON
22
- */
23
- async get(key) {
24
- try {
25
- const item = localStorage.getItem(key);
26
- if (item === null) return null;
27
- return JSON.parse(item);
28
- } catch (error) {
29
- if (error instanceof SyntaxError) throw new Error(`Invalid JSON stored at key "${key}": ${error.message}`);
30
- throw error;
31
- }
32
- }
33
- /**
34
- * Stores a value in localStorage.
35
- * @param key - The storage key
36
- * @param value - The value to store (will be serialized as JSON)
37
- * @throws Error if value cannot be serialized or quota is exceeded
38
- */
39
- async set(key, value) {
40
- try {
41
- const serialized = JSON.stringify(value);
42
- localStorage.setItem(key, serialized);
43
- } catch (error) {
44
- if ((error instanceof DOMException || error.name === "QuotaExceededError") && error.name === "QuotaExceededError") throw new Error(`Storage quota exceeded for key "${key}"`);
45
- if (error instanceof TypeError) throw new Error(`Failed to serialize value for key "${key}": ${error.message}`);
46
- throw error;
47
- }
48
- }
49
- /**
50
- * Removes a value from localStorage.
51
- * @param key - The storage key to remove
52
- */
53
- async remove(key) {
54
- localStorage.removeItem(key);
55
- }
56
- /**
57
- * Clears all values from localStorage.
58
- */
59
- async clear() {
60
- localStorage.clear();
61
- }
62
- };
63
-
64
- //#endregion
65
11
  //#region src/internal/faceCapture/types.ts
66
12
  const FACE_ERROR_CODES = {
67
13
  FACE_OCCLUDED: "FACE_OCCLUDED",
@@ -647,7 +593,7 @@ function buildResolutionFromStream(stream) {
647
593
  if (typeof width === "number" && typeof height === "number") return `${width}x${height}`;
648
594
  }
649
595
  async function createOpenViduRecordingProvider() {
650
- const { OpenViduRecordingProvider } = await import("./OpenViduRecordingProvider-Bn2meybK.esm.js");
596
+ const { OpenViduRecordingProvider } = await import("./OpenViduRecordingProvider-D_cVAwYQ.esm.js");
651
597
  return new OpenViduRecordingProvider();
652
598
  }
653
599
  async function startRecordingSession(params) {
@@ -687,7 +633,7 @@ async function stopRecording(session) {
687
633
  }
688
634
  }
689
635
  async function initializeDeepsightSession(options) {
690
- const { loadDeepsightSession } = await import("./deepsightLoader-Cj6SyUQ-.esm.js");
636
+ const { loadDeepsightSession } = await import("./deepsightLoader-CaULV07H.esm.js");
691
637
  return loadDeepsightSession({
692
638
  ds: options.ds,
693
639
  storage: options.storage
@@ -945,12 +891,12 @@ var LocalRecordingProvider = class {
945
891
  let openViduProviderImportPromise;
946
892
  let openViduBrowserImportPromise;
947
893
  function loadOpenViduProviderModule() {
948
- if (!openViduProviderImportPromise) openViduProviderImportPromise = import("./OpenViduRecordingProvider-Bn2meybK.esm.js");
894
+ if (!openViduProviderImportPromise) openViduProviderImportPromise = import("./OpenViduRecordingProvider-D_cVAwYQ.esm.js");
949
895
  return openViduProviderImportPromise;
950
896
  }
951
897
  function loadOpenViduBrowserModule() {
952
898
  if (!openViduBrowserImportPromise) openViduBrowserImportPromise = (async () => {
953
- return (await import("./openviduLazy-BIPHozOu.esm.js")).loadOpenVidu();
899
+ return (await import("./openviduLazy-rFXBtZVZ.esm.js")).loadOpenVidu();
954
900
  })();
955
901
  return openViduBrowserImportPromise;
956
902
  }
@@ -1021,4 +967,4 @@ function createRecordingService(params) {
1021
967
  }
1022
968
 
1023
969
  //#endregion
1024
- export { StreamCanvasCapture as _, initializeDeepsightSession as a, stopStream as c, createRecordingSession as d, startRecording as f, flagIdManualReview as g, flagFaceManualReview as h, initializeCamera as i, processFace as l, StreamCanvasProcessingSession as m, preloadOpenViduProvider as n, sendLabelInspectionEvent as o, stopRecording$1 as p, encryptSelfieImage as r, startDetection as s, createRecordingService as t, uploadSelfie as u, FACE_ERROR_CODES as v, BrowserStorageProvider as y };
970
+ export { StreamCanvasCapture as _, initializeDeepsightSession as a, stopStream as c, createRecordingSession as d, startRecording as f, flagIdManualReview as g, flagFaceManualReview as h, initializeCamera as i, processFace as l, StreamCanvasProcessingSession as m, preloadOpenViduProvider as n, sendLabelInspectionEvent as o, stopRecording$1 as p, encryptSelfieImage as r, startDetection as s, createRecordingService as t, uploadSelfie as u, FACE_ERROR_CODES as v };
@@ -1,5 +1,5 @@
1
- import { t as Manager } from "./Manager-BN2g_I8W.js";
2
- import "./Actor-Ba71-_30.js";
1
+ import { t as Manager } from "./Manager-DcPMRgTm.js";
2
+ import "./Actor-DbWH1K6E.js";
3
3
 
4
4
  //#region src/modules/redirect-to-mobile/types.d.ts
5
5
  type RedirectToMobileConfig = {