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

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 (71) hide show
  1. package/.turbo/turbo-build.log +33 -0
  2. package/.turbo/turbo-coverage.log +22 -0
  3. package/.turbo/turbo-format.log +6 -0
  4. package/.turbo/turbo-lint$colon$fix.log +77 -0
  5. package/.turbo/turbo-lint.log +95 -0
  6. package/.turbo/turbo-test.log +870 -0
  7. package/.turbo/turbo-typecheck.log +5 -0
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +221 -0
  12. package/coverage/prettify.css +1 -0
  13. package/coverage/prettify.js +2 -0
  14. package/coverage/sort-arrow-sprite.png +0 -0
  15. package/coverage/sorter.js +210 -0
  16. package/coverage/src/camera/cameraService.ts.html +580 -0
  17. package/coverage/src/camera/cameraServices.ts.html +163 -0
  18. package/coverage/src/camera/cameraStateMachine.ts.html +877 -0
  19. package/coverage/src/camera/index.html +146 -0
  20. package/coverage/src/email/emailActor.ts.html +130 -0
  21. package/coverage/src/email/emailManager.ts.html +1366 -0
  22. package/coverage/src/email/emailStateMachine.ts.html +1186 -0
  23. package/coverage/src/email/index.html +146 -0
  24. package/coverage/src/flow/flowActor.ts.html +124 -0
  25. package/coverage/src/flow/flowAnalyzer.ts.html +196 -0
  26. package/coverage/src/flow/flowManager.ts.html +790 -0
  27. package/coverage/src/flow/flowServices.ts.html +124 -0
  28. package/coverage/src/flow/flowStateMachine.ts.html +631 -0
  29. package/coverage/src/flow/index.html +221 -0
  30. package/coverage/src/flow/moduleLoader.ts.html +304 -0
  31. package/coverage/src/flow/orchestratedFlowManager.ts.html +778 -0
  32. package/coverage/src/flow/orchestratedFlowStateMachine.ts.html +1060 -0
  33. package/coverage/src/http/api.ts.html +355 -0
  34. package/coverage/src/http/endpoints.ts.html +136 -0
  35. package/coverage/src/http/index.html +131 -0
  36. package/coverage/src/index.html +116 -0
  37. package/coverage/src/phone/index.html +146 -0
  38. package/coverage/src/phone/phoneActor.ts.html +130 -0
  39. package/coverage/src/phone/phoneManager.ts.html +1459 -0
  40. package/coverage/src/phone/phoneStateMachine.ts.html +1351 -0
  41. package/coverage/src/recordings/index.html +116 -0
  42. package/coverage/src/recordings/recordingsRepository.ts.html +229 -0
  43. package/coverage/src/selfie/index.html +191 -0
  44. package/coverage/src/selfie/selfieActor.ts.html +136 -0
  45. package/coverage/src/selfie/selfieErrorUtils.ts.html +283 -0
  46. package/coverage/src/selfie/selfieManager.ts.html +988 -0
  47. package/coverage/src/selfie/selfieStateMachine.ts.html +2497 -0
  48. package/coverage/src/selfie/selfieUploadService.ts.html +328 -0
  49. package/coverage/src/selfie/types.ts.html +394 -0
  50. package/coverage/src/setup.ts.html +598 -0
  51. package/dist/Manager-6BwbaI_H.d.ts +19 -0
  52. package/dist/StateMachine-7c1gcu94.d.ts +2 -0
  53. package/dist/addEvent-1Mi5CEiq.esm.js +16 -0
  54. package/dist/chunk-C_Yo44FK.esm.js +49 -0
  55. package/dist/email.d.ts +264 -0
  56. package/dist/email.esm.js +479 -0
  57. package/dist/endpoints-D_pUMaqA.esm.js +1701 -0
  58. package/dist/flow.d.ts +578 -0
  59. package/dist/flow.esm.js +628 -0
  60. package/dist/index.d.ts +226 -0
  61. package/dist/index.esm.js +155 -0
  62. package/dist/lib-CyIAFRfr.esm.js +12499 -0
  63. package/dist/permissionServices-CVR0Pq38.esm.js +72 -0
  64. package/dist/phone.d.ts +292 -0
  65. package/dist/phone.esm.js +550 -0
  66. package/dist/selfie.d.ts +758 -0
  67. package/dist/selfie.esm.js +978 -0
  68. package/dist/types-tq1ypYSL.d.ts +5 -0
  69. package/dist/warmup-Dr7OcFND.d.ts +55 -0
  70. package/dist/xstate.esm-B_rda9yU.esm.js +3261 -0
  71. package/package.json +11 -11
@@ -0,0 +1,72 @@
1
+ import { h as stopCameraStream, m as requestCameraAccess, p as queryCameraPermission } from "./endpoints-D_pUMaqA.esm.js";
2
+
3
+ //#region ../infra/src/device/getBrowser.ts
4
+ function getUserAgent() {
5
+ if (typeof navigator === "undefined") return "";
6
+ return navigator.userAgent;
7
+ }
8
+
9
+ //#endregion
10
+ //#region ../infra/src/device/getDeviceClass.ts
11
+ function getDeviceInfo() {
12
+ if (typeof navigator === "undefined") return {
13
+ userAgent: "",
14
+ platform: "",
15
+ maxTouchPoints: 0
16
+ };
17
+ return {
18
+ userAgent: navigator.userAgent,
19
+ platform: navigator.platform,
20
+ maxTouchPoints: navigator.maxTouchPoints
21
+ };
22
+ }
23
+
24
+ //#endregion
25
+ //#region src/device/getBrowser.ts
26
+ function getBrowser() {
27
+ const userAgent = getUserAgent();
28
+ if (!userAgent) return "other";
29
+ const ua = userAgent.toLowerCase();
30
+ if (ua.includes("edg/")) return "edge";
31
+ if (ua.includes("chrome") && !ua.includes("edg/")) return "chrome";
32
+ if (ua.includes("firefox")) return "firefox";
33
+ if (ua.includes("safari") && !ua.includes("chrome")) return "safari";
34
+ return "other";
35
+ }
36
+
37
+ //#endregion
38
+ //#region src/device/getDeviceClass.ts
39
+ function getDeviceClass() {
40
+ const { userAgent, platform, maxTouchPoints } = getDeviceInfo();
41
+ if (!userAgent) return "desktop";
42
+ const ua = userAgent.toLowerCase();
43
+ if (/iphone|ipad|ipod/.test(ua) || platform === "MacIntel" && maxTouchPoints > 1) return "ios";
44
+ if (/android/.test(ua)) return "android";
45
+ return "desktop";
46
+ }
47
+
48
+ //#endregion
49
+ //#region src/permissions/permissionServices.ts
50
+ /**
51
+ * Checks the current camera permission state without prompting the user.
52
+ */
53
+ async function checkPermission() {
54
+ return queryCameraPermission();
55
+ }
56
+ /**
57
+ * Requests camera permission by attempting to access the camera, then immediately
58
+ * stops the obtained stream. This function does not keep or return the stream.
59
+ */
60
+ async function requestPermission() {
61
+ try {
62
+ stopCameraStream(await requestCameraAccess({ video: true }));
63
+ return "granted";
64
+ } catch (error) {
65
+ const name = error instanceof Error ? error.name : void 0;
66
+ if (name === "NotAllowedError" || name === "PermissionDeniedError") return "denied";
67
+ return "prompt";
68
+ }
69
+ }
70
+
71
+ //#endregion
72
+ export { getBrowser as i, requestPermission as n, getDeviceClass as r, checkPermission as t };
@@ -0,0 +1,292 @@
1
+ import { t as Manager } from "./Manager-6BwbaI_H.js";
2
+
3
+ //#region src/phone/types.d.ts
4
+
5
+ /**
6
+ * Configuration options for phone verification.
7
+ *
8
+ * @example Standard OTP verification
9
+ * ```typescript
10
+ * const config: PhoneConfig = {
11
+ * otpVerification: true,
12
+ * otpExpirationInMinutes: 5,
13
+ * prefill: false,
14
+ * };
15
+ * ```
16
+ *
17
+ * @example With all options
18
+ * ```typescript
19
+ * const config: PhoneConfig = {
20
+ * otpVerification: true,
21
+ * otpExpirationInMinutes: 10,
22
+ * prefill: true,
23
+ * isInstantVerify: false,
24
+ * optinEnabled: true,
25
+ * maxOtpAttempts: 3,
26
+ * };
27
+ * ```
28
+ */
29
+ type PhoneConfig = {
30
+ /**
31
+ * Whether to require OTP (SMS code) verification.
32
+ * If false, phone is verified immediately after submission.
33
+ */
34
+ otpVerification: boolean;
35
+ /**
36
+ * How long the OTP code remains valid, in minutes.
37
+ * After expiration, user must request a new code.
38
+ */
39
+ otpExpirationInMinutes: number;
40
+ /**
41
+ * Whether to pre-populate with user's previously stored phone number.
42
+ * Useful for returning users.
43
+ */
44
+ prefill: boolean;
45
+ /**
46
+ * Use carrier-based instant verification instead of OTP.
47
+ * Not available in all regions.
48
+ * @default false
49
+ */
50
+ isInstantVerify?: boolean;
51
+ /**
52
+ * Show a marketing opt-in checkbox in the UI.
53
+ * User's preference is sent with the phone submission.
54
+ * @default false
55
+ */
56
+ optinEnabled?: boolean;
57
+ /**
58
+ * Maximum number of OTP verification attempts before lockout.
59
+ * After exhausting attempts, user sees an error state.
60
+ * @default 3
61
+ */
62
+ maxOtpAttempts?: number;
63
+ };
64
+ //#endregion
65
+ //#region src/phone/phoneStateMachine.d.ts
66
+
67
+ declare const phoneMachine: any;
68
+ //#endregion
69
+ //#region src/phone/phoneActor.d.ts
70
+ type CreatePhoneActorOptions = {
71
+ config: PhoneConfig;
72
+ };
73
+ //#endregion
74
+ //#region src/phone/phoneManager.d.ts
75
+ /** Phone manager is in initial state, waiting for `load()` to be called */
76
+ type PhoneIdleState = {
77
+ status: 'idle';
78
+ };
79
+ /** Loading prefilled phone number from backend (if prefill is enabled) */
80
+ type PhoneLoadingPrefillState = {
81
+ status: 'loadingPrefill';
82
+ };
83
+ /**
84
+ * Ready for phone input - use `setPhoneNumber()` and `submit()`
85
+ * @property countryCode - ISO country code (e.g., 'US', 'MX')
86
+ * @property phonePrefix - International dialing prefix (e.g., '+1', '+52')
87
+ * @property prefilledPhone - Pre-populated phone number (if prefill enabled)
88
+ * @property phoneError - Validation error message if phone was rejected
89
+ */
90
+ type PhoneInputtingState = {
91
+ status: 'inputting';
92
+ countryCode: string;
93
+ phonePrefix: string;
94
+ prefilledPhone?: string;
95
+ phoneError?: string;
96
+ };
97
+ /** Phone number is being submitted to the backend */
98
+ type PhoneSubmittingState = {
99
+ status: 'submitting';
100
+ };
101
+ /** OTP is being sent to the phone number */
102
+ type PhoneSendingOtpState = {
103
+ status: 'sendingOtp';
104
+ };
105
+ /**
106
+ * Waiting for OTP code - use `submitOtp()`, `resendOtp()`, or `back()`
107
+ * @property resendTimer - Seconds remaining before resend is allowed
108
+ * @property canResend - Whether the resend button should be enabled
109
+ * @property attemptsRemaining - Number of OTP verification attempts left
110
+ */
111
+ type PhoneAwaitingOtpState = {
112
+ status: 'awaitingOtp';
113
+ resendTimer: number;
114
+ canResend: boolean;
115
+ attemptsRemaining: number;
116
+ };
117
+ /** OTP code is being verified against the backend */
118
+ type PhoneVerifyingOtpState = {
119
+ status: 'verifyingOtp';
120
+ };
121
+ /**
122
+ * OTP verification failed - user can retry with `submitOtp()`
123
+ * @property error - Error message describing why verification failed
124
+ * @property attemptsRemaining - Number of remaining attempts before lockout
125
+ */
126
+ type PhoneOtpErrorState = {
127
+ status: 'otpError';
128
+ error: string;
129
+ attemptsRemaining: number;
130
+ };
131
+ /** Phone verification completed successfully - call `reset()` to start over */
132
+ type PhoneSuccessState = {
133
+ status: 'success';
134
+ };
135
+ /**
136
+ * Fatal error occurred - call `reset()` to start over
137
+ * @property error - Error message describing what went wrong
138
+ */
139
+ type PhoneErrorState = {
140
+ status: 'error';
141
+ error: string;
142
+ };
143
+ /**
144
+ * Union of all possible phone manager states.
145
+ * Use discriminated union pattern to narrow the type:
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const state = phoneManager.getState();
150
+ * if (state.status === 'inputting') {
151
+ * // TypeScript knows state has countryCode, phonePrefix, etc.
152
+ * console.log(state.countryCode);
153
+ * }
154
+ * ```
155
+ */
156
+ type PhoneState = PhoneIdleState | PhoneLoadingPrefillState | PhoneInputtingState | PhoneSubmittingState | PhoneSendingOtpState | PhoneAwaitingOtpState | PhoneVerifyingOtpState | PhoneOtpErrorState | PhoneSuccessState | PhoneErrorState;
157
+ /**
158
+ * Creates a phone verification manager for headless or UI-driven usage.
159
+ *
160
+ * The manager provides a state machine-based API for phone number verification
161
+ * with optional OTP (one-time password) verification.
162
+ *
163
+ * @param options - Configuration options
164
+ * @param options.config - Phone verification configuration
165
+ * @param options.config.otpVerification - Whether to require OTP verification
166
+ * @param options.config.otpExpirationInMinutes - How long the OTP is valid
167
+ * @param options.config.prefill - Whether to fetch a pre-filled phone number
168
+ * @param options.config.isInstantVerify - Use instant verification API
169
+ * @param options.config.optinEnabled - Show marketing opt-in checkbox
170
+ * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
171
+ *
172
+ * @returns Phone manager with state, API methods, and subscription
173
+ *
174
+ * @example Headless usage
175
+ * ```typescript
176
+ * const manager = createPhoneManager({
177
+ * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
178
+ * });
179
+ *
180
+ * manager.subscribe((state) => console.log(state.status));
181
+ * manager.load();
182
+ * manager.setPhoneNumber('+14155551234', true);
183
+ * manager.submit();
184
+ * // ... wait for 'awaitingOtp' state ...
185
+ * manager.submitOtp('ABC123');
186
+ * manager.stop();
187
+ * ```
188
+ *
189
+ * @example With React/Preact UI hook
190
+ * ```tsx
191
+ * const [state, manager] = useManager(() => createPhoneManager({ config }));
192
+ *
193
+ * if (state.status === 'inputting') {
194
+ * return <input onChange={(e) => manager.setPhoneNumber(e.target.value, true)} />;
195
+ * }
196
+ * ```
197
+ */
198
+ declare function createPhoneManager(options: CreatePhoneActorOptions): Manager<PhoneState> & {
199
+ /**
200
+ * Initializes the phone verification flow.
201
+ * Transitions from 'idle' to 'loadingPrefill' or 'inputting'.
202
+ * Must be called before any other method.
203
+ */
204
+ load(): void;
205
+ /**
206
+ * Sets the phone number for verification.
207
+ * Should be called when state is 'inputting'.
208
+ *
209
+ * @param phone - Full phone number with country code (e.g., '+14155551234')
210
+ * @param isValid - Whether the phone number passes validation
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * // Using libphonenumber-js for validation
215
+ * import { isValidPhoneNumber } from 'libphonenumber-js';
216
+ * const phone = '+14155551234';
217
+ * phoneManager.setPhoneNumber(phone, isValidPhoneNumber(phone));
218
+ * ```
219
+ */
220
+ setPhoneNumber(phone: string, isValid: boolean): void;
221
+ /**
222
+ * Sets the marketing opt-in preference.
223
+ * Only relevant if `config.optinEnabled` is true.
224
+ *
225
+ * @param granted - Whether the user consented to receive marketing messages
226
+ */
227
+ setOptInGranted(granted: boolean): void;
228
+ /**
229
+ * Submits the phone number for verification.
230
+ * Requires a valid phone number to be set via `setPhoneNumber()`.
231
+ * Transitions to 'submitting', then to 'sendingOtp' or 'success' (if no OTP).
232
+ */
233
+ submit(): void;
234
+ /**
235
+ * Sets the OTP code without submitting.
236
+ * Use this for controlled input components.
237
+ *
238
+ * @param code - The OTP code entered by the user
239
+ */
240
+ setOtpCode(code: string): void;
241
+ /**
242
+ * Sets and submits the OTP code in one call.
243
+ * Should be called when state is 'awaitingOtp' or 'otpError'.
244
+ *
245
+ * @param code - The complete OTP code (typically 6 alphanumeric characters)
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * // Submit OTP when user completes entry
250
+ * phoneManager.submitOtp('HH36LP');
251
+ * ```
252
+ */
253
+ submitOtp(code: string): void;
254
+ /**
255
+ * Requests a new OTP code to be sent.
256
+ * Only works when state is 'awaitingOtp' and `canResend` is true.
257
+ * Resets the resend timer.
258
+ */
259
+ resendOtp(): void;
260
+ /**
261
+ * Returns to the phone input screen from OTP entry.
262
+ * Allows the user to change their phone number.
263
+ * Transitions from 'awaitingOtp' or 'otpError' back to 'inputting'.
264
+ */
265
+ back(): void;
266
+ /**
267
+ * Resets the manager to initial state.
268
+ * Can be called from 'success' or 'error' states to start over.
269
+ * Clears all stored data including phone number and OTP.
270
+ */
271
+ reset(): void;
272
+ };
273
+ /**
274
+ * Type representing a phone manager instance.
275
+ * Includes state access, API methods, and lifecycle management.
276
+ *
277
+ * @property getState - Returns the current PhoneState
278
+ * @property subscribe - Subscribes to state changes, returns unsubscribe function
279
+ * @property stop - Stops the manager and cleans up resources
280
+ * @property load - Initializes the verification flow
281
+ * @property setPhoneNumber - Sets the phone number
282
+ * @property setOptInGranted - Sets marketing opt-in preference
283
+ * @property submit - Submits the phone number
284
+ * @property setOtpCode - Sets OTP code without submitting
285
+ * @property submitOtp - Sets and submits OTP code
286
+ * @property resendOtp - Requests new OTP code
287
+ * @property back - Returns to phone input from OTP screen
288
+ * @property reset - Resets to initial state
289
+ */
290
+ type PhoneManager = ReturnType<typeof createPhoneManager>;
291
+ //#endregion
292
+ export { type PhoneConfig, type PhoneManager, type PhoneState, createPhoneManager, phoneMachine };