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