@incodetech/core 2.0.0-rc.0 → 2.0.0

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 (178) hide show
  1. package/package.json +3 -3
  2. package/dist/Actor-CI32dTbG.d.ts +0 -2
  3. package/dist/BaseWasmProvider-C_DLEI40.esm.js +0 -1118
  4. package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +0 -55
  5. package/dist/BrowserTimerProvider-DhNc_x02.esm.js +0 -22
  6. package/dist/ITimerCapability-C67ZRskg.esm.js +0 -7
  7. package/dist/IpifyProvider-D7jx52AL.esm.js +0 -139
  8. package/dist/Manager-C8PrhBOx.d.ts +0 -19
  9. package/dist/MotionSensorProvider-4v7xkqAp.esm.js +0 -254
  10. package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +0 -87
  11. package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
  12. package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
  13. package/dist/addressSearch-BpTbTWCa.esm.js +0 -430
  14. package/dist/ae-signature-DDDZmWXj.esm.js +0 -12
  15. package/dist/ae-signature.d.ts +0 -25
  16. package/dist/ae-signature.esm.js +0 -8
  17. package/dist/antifraud.d.ts +0 -57
  18. package/dist/antifraud.esm.js +0 -45
  19. package/dist/antifraudStateMachine-O0TMf6yc.esm.js +0 -39
  20. package/dist/api-CESGtpbH.esm.js +0 -53
  21. package/dist/authentication.d.ts +0 -12
  22. package/dist/authentication.esm.js +0 -25
  23. package/dist/authenticationManager-5M-fKzXx.esm.js +0 -67
  24. package/dist/authenticationManager-C83GNIhl.d.ts +0 -66
  25. package/dist/authenticationStateMachine-BMZqatiF.esm.js +0 -139
  26. package/dist/backCameraStream-DMdMeGk2.esm.js +0 -346
  27. package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
  28. package/dist/camera-DBSxa6ML.d.ts +0 -4
  29. package/dist/camera-PA2Ljri3.esm.js +0 -22
  30. package/dist/camera.d.ts +0 -15
  31. package/dist/camera.esm.js +0 -5
  32. package/dist/chunk-CRF6K_H_.esm.js +0 -49
  33. package/dist/consent.d.ts +0 -398
  34. package/dist/consent.esm.js +0 -79
  35. package/dist/consentStateMachine-CCT-B60O.esm.js +0 -151
  36. package/dist/cpf-PPz2Njto.esm.js +0 -38
  37. package/dist/cpf-ocr.d.ts +0 -204
  38. package/dist/cpf-ocr.esm.js +0 -177
  39. package/dist/cross-document-data-match.d.ts +0 -34
  40. package/dist/cross-document-data-match.esm.js +0 -71
  41. package/dist/curp-validation.d.ts +0 -188
  42. package/dist/curp-validation.esm.js +0 -110
  43. package/dist/curpValidationStateMachine-CitWLr2c.esm.js +0 -595
  44. package/dist/custom-fields.d.ts +0 -115
  45. package/dist/custom-fields.esm.js +0 -177
  46. package/dist/custom-watchlist.d.ts +0 -66
  47. package/dist/custom-watchlist.esm.js +0 -86
  48. package/dist/dateUtils-UoN5xswP.esm.js +0 -23
  49. package/dist/deepsightLoader-Cm4JIT_z.esm.js +0 -52
  50. package/dist/deepsightService-CEVxzehb.d.ts +0 -412
  51. package/dist/deepsightService-O74l4Y__.esm.js +0 -489
  52. package/dist/device.d.ts +0 -46
  53. package/dist/device.esm.js +0 -106
  54. package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
  55. package/dist/document-capture.d.ts +0 -906
  56. package/dist/document-capture.esm.js +0 -156
  57. package/dist/document-upload.d.ts +0 -331
  58. package/dist/document-upload.esm.js +0 -203
  59. package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +0 -394
  60. package/dist/dynamic-forms.d.ts +0 -178
  61. package/dist/dynamic-forms.esm.js +0 -323
  62. package/dist/ekyb.d.ts +0 -148
  63. package/dist/ekyb.esm.js +0 -127
  64. package/dist/ekybStateMachine-B59rQjgj.esm.js +0 -674
  65. package/dist/ekyc.d.ts +0 -164
  66. package/dist/ekyc.esm.js +0 -104
  67. package/dist/ekycStateMachine-oeO0Iekd.esm.js +0 -10626
  68. package/dist/electronic-signature.d.ts +0 -4
  69. package/dist/electronic-signature.esm.js +0 -7
  70. package/dist/electronicSignatureManager-D9OHzTpG.esm.js +0 -428
  71. package/dist/email.d.ts +0 -4
  72. package/dist/email.esm.js +0 -9
  73. package/dist/emailManager-DIfnS5g1.d.ts +0 -352
  74. package/dist/emailManager-wAV0LE-H.esm.js +0 -238
  75. package/dist/emailStateMachine-DOf4j58N.esm.js +0 -292
  76. package/dist/endpoints-CnN3SyDa.esm.js +0 -87
  77. package/dist/events-D6-e4vok.esm.js +0 -596
  78. package/dist/events.d.ts +0 -265
  79. package/dist/events.esm.js +0 -4
  80. package/dist/extensibility.d.ts +0 -122
  81. package/dist/extensibility.esm.js +0 -43
  82. package/dist/face-match.d.ts +0 -228
  83. package/dist/face-match.esm.js +0 -173
  84. package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +0 -290
  85. package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +0 -690
  86. package/dist/faceCaptureSetup-B3faSpYA.esm.js +0 -873
  87. package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +0 -127
  88. package/dist/flow-events.d.ts +0 -6
  89. package/dist/flow-events.esm.js +0 -0
  90. package/dist/flow.d.ts +0 -358
  91. package/dist/flow.esm.js +0 -825
  92. package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
  93. package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
  94. package/dist/flowServices-DTsm-Vf1.esm.js +0 -188
  95. package/dist/geolocation.d.ts +0 -127
  96. package/dist/geolocation.esm.js +0 -89
  97. package/dist/geolocationStateMachine-asasuHY2.esm.js +0 -105
  98. package/dist/getBrowser-BSXUTWXw.esm.js +0 -41
  99. package/dist/getDeviceClass-BSntT9_j.esm.js +0 -14
  100. package/dist/government-validation.d.ts +0 -67
  101. package/dist/government-validation.esm.js +0 -81
  102. package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +0 -271
  103. package/dist/home.d.ts +0 -99
  104. package/dist/home.esm.js +0 -61
  105. package/dist/http.d.ts +0 -68
  106. package/dist/http.esm.js +0 -3
  107. package/dist/id-ocr.d.ts +0 -635
  108. package/dist/id-ocr.esm.js +0 -86
  109. package/dist/id-verification.d.ts +0 -190
  110. package/dist/id-verification.esm.js +0 -43
  111. package/dist/id.d.ts +0 -24
  112. package/dist/id.esm.js +0 -164
  113. package/dist/idCaptureManager-B9TGA5dq.d.ts +0 -956
  114. package/dist/idCaptureManager-DMK0GIt3.esm.js +0 -581
  115. package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +0 -2954
  116. package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +0 -388
  117. package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +0 -71
  118. package/dist/identity-reuse.d.ts +0 -530
  119. package/dist/identity-reuse.esm.js +0 -274
  120. package/dist/index-BLKtMA0g.d.ts +0 -1177
  121. package/dist/index-BcRG8rtJ.d.ts +0 -97
  122. package/dist/index.d.ts +0 -3
  123. package/dist/index.esm.js +0 -12
  124. package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +0 -30
  125. package/dist/lib-BB0B_qQX.esm.js +0 -12499
  126. package/dist/mandatory-consent.d.ts +0 -412
  127. package/dist/mandatory-consent.esm.js +0 -78
  128. package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +0 -126
  129. package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
  130. package/dist/openviduLazy-Cok70ZSg.esm.js +0 -12
  131. package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
  132. package/dist/phone.d.ts +0 -4
  133. package/dist/phone.esm.js +0 -9
  134. package/dist/phoneManager-B6M30hKE.d.ts +0 -397
  135. package/dist/phoneManager-DAJbGhlY.esm.js +0 -256
  136. package/dist/phoneStateMachine-CuPARRaT.esm.js +0 -351
  137. package/dist/platform-CfrjKhmi.esm.js +0 -83
  138. package/dist/qe-signature-DFo_Cc-I.esm.js +0 -12
  139. package/dist/qe-signature.d.ts +0 -25
  140. package/dist/qe-signature.esm.js +0 -8
  141. package/dist/recordingService-Ig2UgbLv.esm.js +0 -1003
  142. package/dist/redirect-to-mobile.d.ts +0 -107
  143. package/dist/redirect-to-mobile.esm.js +0 -102
  144. package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +0 -249
  145. package/dist/runChildModule-CqqwqAkW.esm.js +0 -219
  146. package/dist/selfie.d.ts +0 -26
  147. package/dist/selfie.esm.js +0 -146
  148. package/dist/selfieManager-D0lSgd-J.d.ts +0 -68
  149. package/dist/selfieManager-Duisl7qN.esm.js +0 -60
  150. package/dist/selfieStateMachine-D76whWEf.esm.js +0 -68
  151. package/dist/session-BS-d_vuE.esm.js +0 -3206
  152. package/dist/session.d.ts +0 -217
  153. package/dist/session.esm.js +0 -9
  154. package/dist/setup-Buy-hyj4.esm.js +0 -887
  155. package/dist/setup-C5AITV8m.d.ts +0 -254
  156. package/dist/signature.d.ts +0 -94
  157. package/dist/signature.esm.js +0 -66
  158. package/dist/signatureStateMachine-B5-QVUve.esm.js +0 -132
  159. package/dist/stats-CIfiPzb1.esm.js +0 -16
  160. package/dist/stats.d.ts +0 -16
  161. package/dist/stats.esm.js +0 -4
  162. package/dist/trust-graph.d.ts +0 -54
  163. package/dist/trust-graph.esm.js +0 -56
  164. package/dist/types-B06Ypu2F.d.ts +0 -49
  165. package/dist/types-BP1m8VRw.d.ts +0 -340
  166. package/dist/types-CAD4va6a.d.ts +0 -5
  167. package/dist/types-CFV9G_7j.d.ts +0 -24
  168. package/dist/warmup-CEcppFiS.d.ts +0 -63
  169. package/dist/wasm.d.ts +0 -15
  170. package/dist/wasm.esm.js +0 -12
  171. package/dist/watchlist-for-business.d.ts +0 -79
  172. package/dist/watchlist-for-business.esm.js +0 -148
  173. package/dist/watchlist.d.ts +0 -62
  174. package/dist/watchlist.esm.js +0 -86
  175. package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
  176. package/dist/workflow.d.ts +0 -907
  177. package/dist/workflow.esm.js +0 -702
  178. package/dist/xstate.esm-B70JrNqo.esm.js +0 -3404
@@ -1,397 +0,0 @@
1
- import { t as Manager } from "./Manager-C8PrhBOx.js";
2
- import { t as ActorRefFrom } from "./Actor-CI32dTbG.js";
3
-
4
- //#region src/modules/phone/types.d.ts
5
-
6
- /**
7
- * Configuration options for phone verification.
8
- *
9
- * @example Standard OTP verification
10
- * ```typescript
11
- * const config: PhoneConfig = {
12
- * otpVerification: true,
13
- * otpExpirationInMinutes: 5,
14
- * prefill: false,
15
- * };
16
- * ```
17
- *
18
- * @example With all options
19
- * ```typescript
20
- * const config: PhoneConfig = {
21
- * otpVerification: true,
22
- * otpExpirationInMinutes: 10,
23
- * prefill: true,
24
- * isInstantVerify: false,
25
- * optinEnabled: true,
26
- * maxOtpAttempts: 3,
27
- * };
28
- * ```
29
- */
30
- type PhoneConfig = {
31
- /**
32
- * Whether to require OTP (SMS code) verification.
33
- * If false, phone is verified immediately after submission.
34
- */
35
- otpVerification: boolean;
36
- /**
37
- * How long the OTP code remains valid, in minutes.
38
- * After expiration, user must request a new code.
39
- */
40
- otpExpirationInMinutes: number;
41
- /**
42
- * Whether to pre-populate with user's previously stored phone number.
43
- * Useful for returning users.
44
- */
45
- prefill: boolean;
46
- /**
47
- * Use carrier-based instant verification instead of OTP.
48
- * Not available in all regions.
49
- * @default false
50
- */
51
- isInstantVerify?: boolean;
52
- /**
53
- * Show a marketing opt-in checkbox in the UI.
54
- * User's preference is sent with the phone submission.
55
- * @default false
56
- */
57
- optinEnabled?: boolean;
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
- //#endregion
66
- //#region src/modules/phone/phoneStateMachine.d.ts
67
-
68
- declare const phoneMachine: any;
69
- type PhoneMachine = typeof phoneMachine;
70
- //#endregion
71
- //#region src/modules/phone/phoneActor.d.ts
72
- type CreatePhoneActorOptions = {
73
- config: PhoneConfig;
74
- };
75
- type PhoneActor = ActorRefFrom<PhoneMachine>;
76
- //#endregion
77
- //#region src/modules/phone/phoneManager.d.ts
78
- /** Phone manager is in initial state, waiting for `load()` to be called */
79
- type PhoneIdleState = {
80
- status: 'idle';
81
- };
82
- /** Loading prefilled phone number from backend (if prefill is enabled) */
83
- type PhoneLoadingPrefillState = {
84
- status: 'loadingPrefill';
85
- };
86
- /**
87
- * Fetching start info (`ipIsoCode`, `phonePrefix`) before the phone field is interactive.
88
- */
89
- type PhoneLoadingStartInfoState = {
90
- status: 'loadingStartInfo';
91
- prefilledPhone?: string;
92
- otpVerification?: boolean;
93
- optinEnabled?: boolean;
94
- };
95
- /**
96
- * Ready for phone input - use `setPhoneNumber()` and `submit()`
97
- * @property countryCode - ISO country code (e.g., 'US', 'MX')
98
- * @property phonePrefix - International dialing prefix (e.g., '+1', '+52')
99
- * @property prefilledPhone - Pre-populated phone number (if prefill enabled)
100
- * @property phoneError - Submission error message if the backend rejected the phone number
101
- * @property otpVerification - Whether OTP SMS verification is enabled (from module config). When omitted, treat as `false`.
102
- * @property optinEnabled - Whether marketing opt-in checkbox is shown (from module config). When omitted, treat as `false`.
103
- */
104
- type PhoneInputtingState = {
105
- status: 'inputting';
106
- countryCode: string;
107
- phonePrefix: string;
108
- prefilledPhone?: string;
109
- phoneError?: string;
110
- otpVerification?: boolean;
111
- optinEnabled?: boolean;
112
- };
113
- /** Phone number is being submitted to the backend */
114
- type PhoneSubmittingState = {
115
- status: 'submitting';
116
- };
117
- /** OTP is being sent to the phone number on resend */
118
- type PhoneResendingOtpState = {
119
- status: 'resendingOtp';
120
- };
121
- /** OTP is being initialy sent to the phone number */
122
- type PhoneSendingInitialOtp = {
123
- status: 'sendingInitialOtp';
124
- };
125
- /**
126
- * Waiting for OTP code - use `submitOtp()`, `resendOtp()`, or `back()`
127
- * @property resendTimer - Seconds remaining before resend is allowed
128
- * @property canResend - Whether the resend button should be enabled
129
- * @property attemptsRemaining - Number of OTP verification attempts left
130
- */
131
- type PhoneAwaitingOtpState = {
132
- status: 'awaitingOtp';
133
- resendTimer: number;
134
- canResend: boolean;
135
- attemptsRemaining: number;
136
- };
137
- /**
138
- * OTP code is being verified against the backend
139
- * @property resendTimer - Seconds remaining on resend cooldown (unchanged while verifying)
140
- * @property canResend - Whether resend is allowed (cooldown finished)
141
- */
142
- type PhoneVerifyingOtpState = {
143
- status: 'verifyingOtp';
144
- resendTimer: number;
145
- canResend: boolean;
146
- };
147
- /**
148
- * OTP verification failed - user can retry with `submitOtp()`
149
- * @property error - Error message describing why verification failed
150
- * @property attemptsRemaining - Number of remaining attempts before lockout
151
- * @property resendTimer - Seconds remaining on resend cooldown (same as awaiting OTP)
152
- * @property canResend - Whether resend is allowed (cooldown finished)
153
- */
154
- type PhoneOtpErrorState = {
155
- status: 'otpError';
156
- otpError: string;
157
- attemptsRemaining: number;
158
- resendTimer: number;
159
- canResend: boolean;
160
- };
161
- /** Phone verification completed successfully */
162
- type PhoneFinishedState = {
163
- status: 'finished';
164
- };
165
- /**
166
- * Fatal error occurred - call `reset()` to start over
167
- * @property error - Error message describing what went wrong
168
- */
169
- type PhoneErrorState = {
170
- status: 'error';
171
- error: string;
172
- };
173
- /**
174
- * Union of all possible phone manager states.
175
- * Use discriminated union pattern to narrow the type:
176
- *
177
- * @example
178
- * ```typescript
179
- * const state = phoneManager.getState();
180
- * if (state.status === 'inputting') {
181
- * // TypeScript knows state has countryCode, phonePrefix, etc.
182
- * console.log(state.countryCode);
183
- * }
184
- * ```
185
- */
186
- type PhoneState = PhoneIdleState | PhoneLoadingPrefillState | PhoneLoadingStartInfoState | PhoneInputtingState | PhoneSubmittingState | PhoneResendingOtpState | PhoneSendingInitialOtp | PhoneAwaitingOtpState | PhoneVerifyingOtpState | PhoneOtpErrorState | PhoneFinishedState | PhoneErrorState;
187
- /**
188
- * Creates a phone verification manager for headless or UI-driven usage.
189
- *
190
- * The manager provides a state machine-based API for phone number verification
191
- * with optional OTP (one-time password) verification.
192
- *
193
- * @param options - Configuration options
194
- * @param options.config - Phone verification configuration
195
- * @param options.config.otpVerification - Whether to require OTP verification
196
- * @param options.config.otpExpirationInMinutes - How long the OTP is valid
197
- * @param options.config.prefill - Whether to fetch a pre-filled phone number
198
- * @param options.config.isInstantVerify - Use instant verification API
199
- * @param options.config.optinEnabled - Show marketing opt-in checkbox
200
- * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
201
- *
202
- * @returns Phone manager with state, API methods, and subscription
203
- *
204
- * @example Headless usage
205
- * ```typescript
206
- * const manager = createPhoneManager({
207
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
208
- * });
209
- *
210
- * manager.subscribe((state) => console.log(state.status));
211
- * manager.load();
212
- * manager.setPhoneNumber('+14155551234', true);
213
- * manager.submit();
214
- * // ... wait for 'awaitingOtp' state ...
215
- * manager.submitOtp('ABC123');
216
- * manager.stop();
217
- * ```
218
- *
219
- * @example With React/Preact UI hook
220
- * ```tsx
221
- * const [state, manager] = useManager(() => createPhoneManager({ config }));
222
- *
223
- * if (state.status === 'inputting') {
224
- * return <input onChange={(e) => manager.setPhoneNumber(e.target.value, true)} />;
225
- * }
226
- * ```
227
- */
228
- declare function createPhoneManager(options: CreatePhoneActorOptions): Manager<PhoneState> & {
229
- /**
230
- * Initializes the phone verification flow.
231
- * Transitions from 'idle' to 'loadingPrefill' or 'inputting'.
232
- * Must be called before any other method.
233
- */
234
- load(): void;
235
- /**
236
- * Sets the phone number for verification.
237
- * Should be called when state is 'inputting'.
238
- *
239
- * @param phone - Full phone number with country code (e.g., '+14155551234')
240
- * @param isValid - Whether the phone number passes validation
241
- *
242
- * @example
243
- * ```typescript
244
- * // Using libphonenumber-js for validation
245
- * import { isValidPhoneNumber } from 'libphonenumber-js';
246
- * const phone = '+14155551234';
247
- * phoneManager.setPhoneNumber(phone, isValidPhoneNumber(phone));
248
- * ```
249
- */
250
- setPhoneNumber(phone: string, isValid: boolean): void;
251
- /**
252
- * Sets the marketing opt-in preference.
253
- * Only relevant if `config.optinEnabled` is true.
254
- *
255
- * @param granted - Whether the user consented to receive marketing messages
256
- */
257
- setOptInGranted(granted: boolean): void;
258
- /**
259
- * Submits the phone number for verification.
260
- * Requires a valid phone number to be set via `setPhoneNumber()`.
261
- * Transitions to 'submitting', then to 'sendingOtp' or 'success' (if no OTP).
262
- */
263
- submit(): void;
264
- /**
265
- * Sets the OTP code without submitting.
266
- * Use this for controlled input components.
267
- *
268
- * @param code - The OTP code entered by the user
269
- */
270
- setOtpCode(code: string): void;
271
- /**
272
- * Sets and submits the OTP code in one call.
273
- * Should be called when state is 'awaitingOtp' or 'otpError'.
274
- *
275
- * @param code - The complete OTP code (typically 6 alphanumeric characters)
276
- *
277
- * @example
278
- * ```typescript
279
- * // Submit OTP when user completes entry
280
- * phoneManager.submitOtp('HH36LP');
281
- * ```
282
- */
283
- submitOtp(code: string): void;
284
- /**
285
- * Requests a new OTP code to be sent.
286
- * Only works when state is 'awaitingOtp' and `canResend` is true.
287
- * Resets the resend timer.
288
- */
289
- resendOtp(): void;
290
- /**
291
- * Returns to the phone input screen from OTP entry.
292
- * Allows the user to change their phone number.
293
- * Transitions from 'awaitingOtp' or 'otpError' back to 'inputting'.
294
- */
295
- back(): void;
296
- /**
297
- * Resets the manager to initial state.
298
- * Can be called from 'success' or 'error' states to start over.
299
- * Clears all stored data including phone number and OTP.
300
- */
301
- reset(): void;
302
- };
303
- declare function createPhoneManagerFromActor(actor: PhoneActor): Manager<PhoneState> & {
304
- /**
305
- * Initializes the phone verification flow.
306
- * Transitions from 'idle' to 'loadingPrefill' or 'inputting'.
307
- * Must be called before any other method.
308
- */
309
- load(): void;
310
- /**
311
- * Sets the phone number for verification.
312
- * Should be called when state is 'inputting'.
313
- *
314
- * @param phone - Full phone number with country code (e.g., '+14155551234')
315
- * @param isValid - Whether the phone number passes validation
316
- *
317
- * @example
318
- * ```typescript
319
- * // Using libphonenumber-js for validation
320
- * import { isValidPhoneNumber } from 'libphonenumber-js';
321
- * const phone = '+14155551234';
322
- * phoneManager.setPhoneNumber(phone, isValidPhoneNumber(phone));
323
- * ```
324
- */
325
- setPhoneNumber(phone: string, isValid: boolean): void;
326
- /**
327
- * Sets the marketing opt-in preference.
328
- * Only relevant if `config.optinEnabled` is true.
329
- *
330
- * @param granted - Whether the user consented to receive marketing messages
331
- */
332
- setOptInGranted(granted: boolean): void;
333
- /**
334
- * Submits the phone number for verification.
335
- * Requires a valid phone number to be set via `setPhoneNumber()`.
336
- * Transitions to 'submitting', then to 'sendingOtp' or 'success' (if no OTP).
337
- */
338
- submit(): void;
339
- /**
340
- * Sets the OTP code without submitting.
341
- * Use this for controlled input components.
342
- *
343
- * @param code - The OTP code entered by the user
344
- */
345
- setOtpCode(code: string): void;
346
- /**
347
- * Sets and submits the OTP code in one call.
348
- * Should be called when state is 'awaitingOtp' or 'otpError'.
349
- *
350
- * @param code - The complete OTP code (typically 6 alphanumeric characters)
351
- *
352
- * @example
353
- * ```typescript
354
- * // Submit OTP when user completes entry
355
- * phoneManager.submitOtp('HH36LP');
356
- * ```
357
- */
358
- submitOtp(code: string): void;
359
- /**
360
- * Requests a new OTP code to be sent.
361
- * Only works when state is 'awaitingOtp' and `canResend` is true.
362
- * Resets the resend timer.
363
- */
364
- resendOtp(): void;
365
- /**
366
- * Returns to the phone input screen from OTP entry.
367
- * Allows the user to change their phone number.
368
- * Transitions from 'awaitingOtp' or 'otpError' back to 'inputting'.
369
- */
370
- back(): void;
371
- /**
372
- * Resets the manager to initial state.
373
- * Can be called from 'success' or 'error' states to start over.
374
- * Clears all stored data including phone number and OTP.
375
- */
376
- reset(): void;
377
- };
378
- /**
379
- * Type representing a phone manager instance.
380
- * Includes state access, API methods, and lifecycle management.
381
- *
382
- * @property getState - Returns the current PhoneState
383
- * @property subscribe - Subscribes to state changes, returns unsubscribe function
384
- * @property stop - Stops the manager and cleans up resources
385
- * @property load - Initializes the verification flow
386
- * @property setPhoneNumber - Sets the phone number
387
- * @property setOptInGranted - Sets marketing opt-in preference
388
- * @property submit - Submits the phone number
389
- * @property setOtpCode - Sets OTP code without submitting
390
- * @property submitOtp - Sets and submits OTP code
391
- * @property resendOtp - Requests new OTP code
392
- * @property back - Returns to phone input from OTP screen
393
- * @property reset - Resets to initial state
394
- */
395
- type PhoneManager = ReturnType<typeof createPhoneManager>;
396
- //#endregion
397
- export { phoneMachine as a, createPhoneManagerFromActor as i, PhoneState as n, PhoneConfig as o, createPhoneManager as r, PhoneManager as t };
@@ -1,256 +0,0 @@
1
- import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
2
- import { c as createManager, s as createActor } from "./xstate.esm-B70JrNqo.esm.js";
3
- import { t as phoneMachine } from "./phoneStateMachine-CuPARRaT.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: "loadingStartInfo",
107
- prefilledPhone: context.prefilledPhone,
108
- otpVerification: context.config.otpVerification,
109
- optinEnabled: context.config.optinEnabled ?? false
110
- };
111
- if (typedSnapshot.matches("inputting")) return {
112
- status: "inputting",
113
- countryCode: context.countryCode,
114
- phonePrefix: context.phonePrefix,
115
- prefilledPhone: context.prefilledPhone,
116
- phoneError: context.phoneError,
117
- otpVerification: context.config.otpVerification,
118
- optinEnabled: context.config.optinEnabled ?? false
119
- };
120
- if (typedSnapshot.matches("submitting")) return { status: "submitting" };
121
- if (typedSnapshot.matches("resendingOtp")) return { status: "resendingOtp" };
122
- if (typedSnapshot.matches("sendingInitialOtp")) return { status: "sendingInitialOtp" };
123
- if (typedSnapshot.matches("awaitingOtp")) return {
124
- status: "awaitingOtp",
125
- resendTimer: context.resendTimer,
126
- canResend: !context.resendTimerActive,
127
- attemptsRemaining: context.attemptsRemaining
128
- };
129
- if (typedSnapshot.matches("verifyingOtp")) return {
130
- status: "verifyingOtp",
131
- resendTimer: context.resendTimer,
132
- canResend: !context.resendTimerActive
133
- };
134
- if (typedSnapshot.matches("otpError")) return {
135
- status: "otpError",
136
- otpError: context.otpError ?? "otp.errorv2",
137
- attemptsRemaining: context.attemptsRemaining,
138
- resendTimer: context.resendTimer,
139
- canResend: !context.resendTimerActive
140
- };
141
- if (typedSnapshot.matches("finished")) return { status: "finished" };
142
- if (typedSnapshot.matches("error")) return {
143
- status: "error",
144
- error: context.error ?? "An error occurred"
145
- };
146
- return { status: "idle" };
147
- }
148
- function createApi({ actor, trackElementClicked }) {
149
- return {
150
- load() {
151
- actor.send({ type: "LOAD" });
152
- },
153
- setPhoneNumber(phone, isValid) {
154
- actor.send({
155
- type: "PHONE_CHANGED",
156
- phone,
157
- isValid
158
- });
159
- },
160
- setOptInGranted(granted) {
161
- actor.send({
162
- type: "OPT_IN_CHANGED",
163
- granted
164
- });
165
- },
166
- submit() {
167
- trackElementClicked?.("submit");
168
- actor.send({ type: "SUBMIT" });
169
- },
170
- setOtpCode(code) {
171
- actor.send({
172
- type: "OTP_CHANGED",
173
- code
174
- });
175
- },
176
- submitOtp(code) {
177
- trackElementClicked?.("submitOtp");
178
- actor.send({
179
- type: "OTP_CHANGED",
180
- code
181
- });
182
- actor.send({ type: "VERIFY_OTP" });
183
- },
184
- resendOtp() {
185
- trackElementClicked?.("resendOtp");
186
- actor.send({ type: "RESEND_OTP" });
187
- },
188
- back() {
189
- trackElementClicked?.("back");
190
- actor.send({ type: "BACK" });
191
- },
192
- reset() {
193
- actor.send({ type: "RESET" });
194
- }
195
- };
196
- }
197
- /**
198
- * Creates a phone verification manager for headless or UI-driven usage.
199
- *
200
- * The manager provides a state machine-based API for phone number verification
201
- * with optional OTP (one-time password) verification.
202
- *
203
- * @param options - Configuration options
204
- * @param options.config - Phone verification configuration
205
- * @param options.config.otpVerification - Whether to require OTP verification
206
- * @param options.config.otpExpirationInMinutes - How long the OTP is valid
207
- * @param options.config.prefill - Whether to fetch a pre-filled phone number
208
- * @param options.config.isInstantVerify - Use instant verification API
209
- * @param options.config.optinEnabled - Show marketing opt-in checkbox
210
- * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
211
- *
212
- * @returns Phone manager with state, API methods, and subscription
213
- *
214
- * @example Headless usage
215
- * ```typescript
216
- * const manager = createPhoneManager({
217
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
218
- * });
219
- *
220
- * manager.subscribe((state) => console.log(state.status));
221
- * manager.load();
222
- * manager.setPhoneNumber('+14155551234', true);
223
- * manager.submit();
224
- * // ... wait for 'awaitingOtp' state ...
225
- * manager.submitOtp('ABC123');
226
- * manager.stop();
227
- * ```
228
- *
229
- * @example With React/Preact UI hook
230
- * ```tsx
231
- * const [state, manager] = useManager(() => createPhoneManager({ config }));
232
- *
233
- * if (state.status === 'inputting') {
234
- * return <input onChange={(e) => manager.setPhoneNumber(e.target.value, true)} />;
235
- * }
236
- * ```
237
- */
238
- function createPhoneManager(options) {
239
- return createManager({
240
- actor: createPhoneActor(options),
241
- mapState,
242
- createApi,
243
- instrumentation: createManagerInstrumentation(eventModuleNames.phone)
244
- });
245
- }
246
- function createPhoneManagerFromActor(actor) {
247
- return createManager({
248
- actor,
249
- mapState,
250
- createApi,
251
- instrumentation: createManagerInstrumentation(eventModuleNames.phone)
252
- });
253
- }
254
-
255
- //#endregion
256
- export { createPhoneManagerFromActor as n, createPhoneManager as t };