@incodetech/core 0.0.0-dev-20260313-486e658 → 0.0.0-dev-20260313-bc2dab4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actor-BAf9LRYf.d.ts +2 -0
- package/dist/StateMachine-DJpZF_HP.d.ts +2 -0
- package/dist/authentication.d.ts +10 -78
- package/dist/authentication.esm.js +11 -195
- package/dist/authenticationManager-4j4j8ac9.esm.js +197 -0
- package/dist/authenticationManager-DQL9XsaI.d.ts +66 -0
- package/dist/{backCameraStream-B57NWDGu.esm.js → backCameraStream-4aLwsDOv.esm.js} +1 -1
- package/dist/curp-validation.d.ts +4 -4
- package/dist/curp-validation.esm.js +5 -5
- package/dist/{deepsightLoader-BXTRzhYx.esm.js → deepsightLoader-C-Xil8cg.esm.js} +4 -4
- package/dist/{deepsightService-CTK55DG8.esm.js → deepsightService-BgqD33AH.esm.js} +3 -3
- package/dist/{deepsightService-CYCDsan2.d.ts → deepsightService-UhtHJCFb.d.ts} +131 -3
- package/dist/document-capture.d.ts +49 -49
- package/dist/document-capture.esm.js +6 -6
- package/dist/document-upload.d.ts +49 -49
- package/dist/document-upload.esm.js +5 -5
- package/dist/ekyb.d.ts +2 -2
- package/dist/ekyb.esm.js +6 -6
- package/dist/ekyc.d.ts +2 -2
- package/dist/ekyc.esm.js +6 -6
- package/dist/email.d.ts +3 -263
- package/dist/email.esm.js +6 -477
- package/dist/emailManager-DZeOYBQ6.d.ts +335 -0
- package/dist/emailManager-e7j__XBB.esm.js +486 -0
- package/dist/{events-b4_xvENs.esm.js → events-3HzCcoEy.esm.js} +2 -2
- package/dist/extensibility.d.ts +95 -0
- package/dist/extensibility.esm.js +17 -0
- package/dist/face-match.d.ts +1 -1
- package/dist/face-match.esm.js +5 -5
- package/dist/faceCaptureManagerFactory-CiQWYHp2.d.ts +610 -0
- package/dist/{faceCaptureSetup-10lCb_yE.esm.js → faceCaptureSetup-CF9TJlsc.esm.js} +11 -11
- package/dist/flow.d.ts +7 -7
- package/dist/flow.esm.js +5 -5
- package/dist/{flowCompletionService-DHXqHOAk.esm.js → flowCompletionService-CV8Ywiut.esm.js} +2 -2
- package/dist/geolocation.d.ts +1 -1
- package/dist/geolocation.esm.js +5 -5
- package/dist/government-validation.d.ts +1 -1
- package/dist/government-validation.esm.js +4 -4
- package/dist/id-A_upgNRR.esm.js +0 -0
- package/dist/id.d.ts +9 -9
- package/dist/id.esm.js +11 -10
- package/dist/{id-TUJyOPso.esm.js → idCaptureManager-B9BsU7-M.esm.js} +18 -11
- package/dist/{index-5ZEjz-8I.d.ts → idCaptureManager-D8FwP0TW.d.ts} +30 -8
- package/dist/index-BtQzTfU9.d.ts +1 -0
- package/dist/index.d.ts +21 -12
- package/dist/index.esm.js +33 -21
- package/dist/{lib-V3Lo-Jit.esm.js → lib-COh1FH9n.esm.js} +1 -1
- package/dist/phone.d.ts +3 -291
- package/dist/phone.esm.js +6 -551
- package/dist/phoneManager-B6fNmxhw.esm.js +560 -0
- package/dist/phoneManager-BsamACjL.d.ts +370 -0
- package/dist/redirect-to-mobile.d.ts +1 -1
- package/dist/redirect-to-mobile.esm.js +4 -4
- package/dist/selfie.d.ts +10 -408
- package/dist/selfie.esm.js +11 -118
- package/dist/selfieManager-ByV0akn-.esm.js +117 -0
- package/dist/selfieManager-Czysy-lv.d.ts +68 -0
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +3 -3
- package/dist/{src-D3v6I2la.esm.js → src-BmVrWkLJ.esm.js} +2 -2
- package/dist/{stats-D76Thmqp.esm.js → stats-kLtQIgsA.esm.js} +1 -1
- package/dist/stats.esm.js +2 -2
- package/dist/{streamingEvents-CQq5fJCL.esm.js → streamingEvents-Cw6kqXEh.esm.js} +3 -3
- package/dist/{types-DnrAr9fb.d.ts → types-BugcSDaO.d.ts} +1 -1
- package/dist/{types-Bn54lmeM.d.ts → types-C9Jo2XOb.d.ts} +1 -1
- package/package.json +5 -1
- package/dist/Actor-B6Lr-x6S.d.ts +0 -2
- package/dist/StateMachine-WHeQE3lC.d.ts +0 -2
- package/dist/faceCaptureManagerFactory-D1NUo68Z.d.ts +0 -231
- package/dist/types-B4KNFqC4.d.ts +0 -130
- /package/dist/{Manager-CG5CQ1kY.d.ts → Manager-CXnC-tN_.d.ts} +0 -0
- /package/dist/{api-3fZO5bmj.esm.js → api-C2uzxrpN.esm.js} +0 -0
- /package/dist/{camera-D7zu0Mls.d.ts → camera-DDn9ILon.d.ts} +0 -0
- /package/dist/{chunk-B1Ox1Owh.esm.js → chunk-C4_ANvih.esm.js} +0 -0
- /package/dist/{endpoints-5sPFFmaB.esm.js → endpoints-IAlXA1zN.esm.js} +0 -0
- /package/dist/{flowCompletionService-DeWKduBI.d.ts → flowCompletionService-D4YDcHQR.d.ts} +0 -0
- /package/dist/{types-BYYaKde4.d.ts → types-DTieLton.d.ts} +0 -0
- /package/dist/{usStates-D4SmlpeT.esm.js → usStates-vWM_ZgEH.esm.js} +0 -0
- /package/dist/{warmup-Da5qDIWZ.d.ts → warmup-Bp_1oXoL.d.ts} +0 -0
- /package/dist/{xstate.esm-07M59Cte.esm.js → xstate.esm-CcoTezCZ.esm.js} +0 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-3HzCcoEy.esm.js";
|
|
2
|
+
import { A as createManager, g as BrowserTimerProvider } from "./src-BmVrWkLJ.esm.js";
|
|
3
|
+
import { a as createActor, i as fromPromise, n as assign, r as fromCallback, t as setup } from "./xstate.esm-CcoTezCZ.esm.js";
|
|
4
|
+
import { t as api } from "./api-C2uzxrpN.esm.js";
|
|
5
|
+
import { t as endpoints } from "./endpoints-IAlXA1zN.esm.js";
|
|
6
|
+
|
|
7
|
+
//#region src/modules/email/emailServices.ts
|
|
8
|
+
async function fetchEmail(signal) {
|
|
9
|
+
const res = await api.get(endpoints.getEmail, { signal });
|
|
10
|
+
if (!res.ok) throw new Error(`GET ${endpoints.getEmail} failed: ${res.status} ${res.statusText}`);
|
|
11
|
+
return res.data;
|
|
12
|
+
}
|
|
13
|
+
async function addEmail(params, signal) {
|
|
14
|
+
const res = await api.post(endpoints.email, { email: params.email }, { signal });
|
|
15
|
+
if (!res.ok) throw new Error(`POST ${endpoints.email} failed: ${res.status} ${res.statusText}`);
|
|
16
|
+
return res.data;
|
|
17
|
+
}
|
|
18
|
+
async function sendEmailOtp(signal) {
|
|
19
|
+
const res = await api.get(`${endpoints.sendSmsOtp}?communicationchannel=EMAIL`, { signal });
|
|
20
|
+
if (!res.ok) throw new Error(`GET ${endpoints.sendSmsOtp} failed: ${res.status} ${res.statusText}`);
|
|
21
|
+
}
|
|
22
|
+
async function verifyEmailOtp(code, signal) {
|
|
23
|
+
const res = await api.get(`${endpoints.compareOtp}?code=${code}&channel=EMAIL`, { signal });
|
|
24
|
+
if (!res.ok) throw new Error(`GET ${endpoints.compareOtp} failed: ${res.status} ${res.statusText}`);
|
|
25
|
+
return res.data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/modules/email/emailStateMachine.ts
|
|
30
|
+
const RESEND_TIMER_SECONDS = 30;
|
|
31
|
+
const emailMachine = setup({
|
|
32
|
+
types: {
|
|
33
|
+
context: {},
|
|
34
|
+
events: {},
|
|
35
|
+
input: {}
|
|
36
|
+
},
|
|
37
|
+
actors: {
|
|
38
|
+
fetchEmail: fromPromise(async ({ signal }) => {
|
|
39
|
+
return fetchEmail(signal);
|
|
40
|
+
}),
|
|
41
|
+
submitEmail: fromPromise(async ({ input, signal }) => {
|
|
42
|
+
return addEmail({ email: input.email }, signal);
|
|
43
|
+
}),
|
|
44
|
+
sendOtp: fromPromise(async ({ signal }) => {
|
|
45
|
+
return sendEmailOtp(signal);
|
|
46
|
+
}),
|
|
47
|
+
verifyOtp: fromPromise(async ({ input, signal }) => {
|
|
48
|
+
return verifyEmailOtp(input.code, signal);
|
|
49
|
+
}),
|
|
50
|
+
resendTimer: fromCallback(({ sendBack }) => {
|
|
51
|
+
const timer = BrowserTimerProvider.getInstance();
|
|
52
|
+
let seconds = RESEND_TIMER_SECONDS;
|
|
53
|
+
const interval = timer.setInterval(() => {
|
|
54
|
+
seconds -= 1;
|
|
55
|
+
sendBack({ type: "TICK" });
|
|
56
|
+
if (seconds <= 0) timer.clearInterval(interval);
|
|
57
|
+
}, 1e3);
|
|
58
|
+
return () => timer.clearInterval(interval);
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
actions: {
|
|
62
|
+
setPrefilledEmail: assign(({ event }) => {
|
|
63
|
+
const email = event.output.email;
|
|
64
|
+
return {
|
|
65
|
+
prefilledEmail: email,
|
|
66
|
+
email
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
setEmail: assign(({ event }) => {
|
|
70
|
+
const e = event;
|
|
71
|
+
return {
|
|
72
|
+
email: e.email,
|
|
73
|
+
isValid: e.isValid,
|
|
74
|
+
emailError: e.isValid ? void 0 : "Invalid email address"
|
|
75
|
+
};
|
|
76
|
+
}),
|
|
77
|
+
setEmailError: assign(({ event }) => ({ emailError: String(event.error) })),
|
|
78
|
+
setError: assign(({ event }) => ({ error: String(event.error) })),
|
|
79
|
+
clearError: assign({ error: () => void 0 }),
|
|
80
|
+
clearEmailError: assign({ emailError: () => void 0 }),
|
|
81
|
+
setOtpCode: assign(({ event }) => ({
|
|
82
|
+
otpCode: event.code,
|
|
83
|
+
otpError: void 0
|
|
84
|
+
})),
|
|
85
|
+
setOtpError: assign(({ context, event }) => ({
|
|
86
|
+
otpError: String(event.error),
|
|
87
|
+
attemptsRemaining: context.attemptsRemaining - 1
|
|
88
|
+
})),
|
|
89
|
+
clearOtpError: assign({
|
|
90
|
+
otpError: () => void 0,
|
|
91
|
+
otpCode: () => ""
|
|
92
|
+
}),
|
|
93
|
+
startResendTimer: assign({
|
|
94
|
+
resendTimer: () => RESEND_TIMER_SECONDS,
|
|
95
|
+
resendTimerActive: () => true
|
|
96
|
+
}),
|
|
97
|
+
tickResendTimer: assign(({ context }) => {
|
|
98
|
+
const newTimer = Math.max(0, context.resendTimer - 1);
|
|
99
|
+
return {
|
|
100
|
+
resendTimer: newTimer,
|
|
101
|
+
resendTimerActive: newTimer > 0
|
|
102
|
+
};
|
|
103
|
+
}),
|
|
104
|
+
stopResendTimer: assign({ resendTimerActive: () => false }),
|
|
105
|
+
resetContext: assign(({ context }) => ({
|
|
106
|
+
config: context.config,
|
|
107
|
+
email: "",
|
|
108
|
+
isValid: false,
|
|
109
|
+
emailError: void 0,
|
|
110
|
+
prefilledEmail: void 0,
|
|
111
|
+
error: void 0,
|
|
112
|
+
otpCode: "",
|
|
113
|
+
otpError: void 0,
|
|
114
|
+
attemptsRemaining: context.config.maxOtpAttempts ?? 3,
|
|
115
|
+
resendTimer: 0,
|
|
116
|
+
resendTimerActive: false
|
|
117
|
+
})),
|
|
118
|
+
sendEmailSubmitEvent: () => {
|
|
119
|
+
addEvent({
|
|
120
|
+
code: "continue",
|
|
121
|
+
module: eventModuleNames.email,
|
|
122
|
+
screen: eventScreenNames.emailInput
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
guards: {
|
|
127
|
+
hasPrefill: ({ context }) => context.config.prefill,
|
|
128
|
+
hasOtpVerification: ({ context }) => context.config.otpVerification,
|
|
129
|
+
isValidEmail: ({ context }) => context.isValid,
|
|
130
|
+
hasAttemptsRemaining: ({ context }) => context.attemptsRemaining > 0,
|
|
131
|
+
canResend: ({ context }) => !context.resendTimerActive
|
|
132
|
+
}
|
|
133
|
+
}).createMachine({
|
|
134
|
+
id: "email",
|
|
135
|
+
initial: "idle",
|
|
136
|
+
context: ({ input }) => ({
|
|
137
|
+
config: input.config,
|
|
138
|
+
email: "",
|
|
139
|
+
isValid: false,
|
|
140
|
+
emailError: void 0,
|
|
141
|
+
prefilledEmail: void 0,
|
|
142
|
+
error: void 0,
|
|
143
|
+
otpCode: "",
|
|
144
|
+
otpError: void 0,
|
|
145
|
+
attemptsRemaining: input.config.maxOtpAttempts ?? 3,
|
|
146
|
+
resendTimer: 0,
|
|
147
|
+
resendTimerActive: false
|
|
148
|
+
}),
|
|
149
|
+
states: {
|
|
150
|
+
idle: { on: { LOAD: [{
|
|
151
|
+
target: "loadingPrefill",
|
|
152
|
+
guard: "hasPrefill"
|
|
153
|
+
}, { target: "inputting" }] } },
|
|
154
|
+
loadingPrefill: { invoke: {
|
|
155
|
+
id: "fetchEmail",
|
|
156
|
+
src: "fetchEmail",
|
|
157
|
+
onDone: {
|
|
158
|
+
target: "inputting",
|
|
159
|
+
actions: "setPrefilledEmail"
|
|
160
|
+
},
|
|
161
|
+
onError: { target: "inputting" }
|
|
162
|
+
} },
|
|
163
|
+
inputting: {
|
|
164
|
+
entry: "clearEmailError",
|
|
165
|
+
on: {
|
|
166
|
+
EMAIL_CHANGED: { actions: "setEmail" },
|
|
167
|
+
SUBMIT: {
|
|
168
|
+
target: "submitting",
|
|
169
|
+
guard: "isValidEmail"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
submitting: { invoke: {
|
|
174
|
+
id: "submitEmail",
|
|
175
|
+
src: "submitEmail",
|
|
176
|
+
input: ({ context }) => ({ email: context.email }),
|
|
177
|
+
onDone: [{
|
|
178
|
+
target: "sendingOtp",
|
|
179
|
+
guard: "hasOtpVerification",
|
|
180
|
+
actions: "sendEmailSubmitEvent"
|
|
181
|
+
}, {
|
|
182
|
+
target: "finished",
|
|
183
|
+
actions: "sendEmailSubmitEvent"
|
|
184
|
+
}],
|
|
185
|
+
onError: {
|
|
186
|
+
target: "inputting",
|
|
187
|
+
actions: "setEmailError"
|
|
188
|
+
}
|
|
189
|
+
} },
|
|
190
|
+
sendingOtp: { invoke: {
|
|
191
|
+
id: "sendOtp",
|
|
192
|
+
src: "sendOtp",
|
|
193
|
+
onDone: { target: "awaitingOtp" },
|
|
194
|
+
onError: {
|
|
195
|
+
target: "awaitingOtp",
|
|
196
|
+
actions: "setError"
|
|
197
|
+
}
|
|
198
|
+
} },
|
|
199
|
+
awaitingOtp: {
|
|
200
|
+
entry: "startResendTimer",
|
|
201
|
+
invoke: {
|
|
202
|
+
id: "resendTimer",
|
|
203
|
+
src: "resendTimer"
|
|
204
|
+
},
|
|
205
|
+
on: {
|
|
206
|
+
TICK: { actions: "tickResendTimer" },
|
|
207
|
+
OTP_CHANGED: { actions: "setOtpCode" },
|
|
208
|
+
VERIFY_OTP: { target: "verifyingOtp" },
|
|
209
|
+
RESEND_OTP: {
|
|
210
|
+
target: "sendingOtp",
|
|
211
|
+
guard: "canResend"
|
|
212
|
+
},
|
|
213
|
+
BACK: { target: "inputting" }
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
verifyingOtp: { invoke: {
|
|
217
|
+
id: "verifyOtp",
|
|
218
|
+
src: "verifyOtp",
|
|
219
|
+
input: ({ context }) => ({ code: context.otpCode }),
|
|
220
|
+
onDone: [
|
|
221
|
+
{
|
|
222
|
+
target: "finished",
|
|
223
|
+
guard: ({ event }) => event.output.success === true
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
target: "otpError",
|
|
227
|
+
guard: "hasAttemptsRemaining",
|
|
228
|
+
actions: assign(({ context }) => ({
|
|
229
|
+
otpError: "Invalid OTP code",
|
|
230
|
+
attemptsRemaining: context.attemptsRemaining - 1
|
|
231
|
+
}))
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
target: "error",
|
|
235
|
+
actions: assign({ error: () => "Maximum OTP attempts exceeded" })
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
onError: [{
|
|
239
|
+
target: "otpError",
|
|
240
|
+
guard: "hasAttemptsRemaining",
|
|
241
|
+
actions: "setOtpError"
|
|
242
|
+
}, {
|
|
243
|
+
target: "error",
|
|
244
|
+
actions: "setError"
|
|
245
|
+
}]
|
|
246
|
+
} },
|
|
247
|
+
otpError: { on: {
|
|
248
|
+
OTP_CHANGED: {
|
|
249
|
+
target: "awaitingOtp",
|
|
250
|
+
actions: "setOtpCode"
|
|
251
|
+
},
|
|
252
|
+
RESEND_OTP: {
|
|
253
|
+
target: "sendingOtp",
|
|
254
|
+
guard: "canResend"
|
|
255
|
+
},
|
|
256
|
+
BACK: { target: "inputting" }
|
|
257
|
+
} },
|
|
258
|
+
finished: { type: "final" },
|
|
259
|
+
error: { on: { RESET: {
|
|
260
|
+
target: "idle",
|
|
261
|
+
actions: "resetContext"
|
|
262
|
+
} } }
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/modules/email/emailActor.ts
|
|
268
|
+
function createEmailActor(options) {
|
|
269
|
+
return createActor(emailMachine, { input: { config: options.config } }).start();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/modules/email/emailManager.ts
|
|
274
|
+
/**
|
|
275
|
+
* @module @incodetech/core/email
|
|
276
|
+
*
|
|
277
|
+
* Email verification module for the Incode Web SDK.
|
|
278
|
+
* Supports both headless (programmatic) and UI-driven usage patterns.
|
|
279
|
+
*
|
|
280
|
+
* ## Headless Usage
|
|
281
|
+
*
|
|
282
|
+
* The email manager can be used entirely without UI for backend integrations,
|
|
283
|
+
* custom UI implementations, or automated workflows.
|
|
284
|
+
*
|
|
285
|
+
* @example Basic headless email verification with OTP
|
|
286
|
+
* ```typescript
|
|
287
|
+
* import { createEmailManager } from '@incodetech/core/email';
|
|
288
|
+
* import { setup } from '@incodetech/core';
|
|
289
|
+
*
|
|
290
|
+
* // 1. Configure the SDK (required before using any module)
|
|
291
|
+
* setup({ apiURL: 'https://api.example.com', token: 'your-token' });
|
|
292
|
+
*
|
|
293
|
+
* // 2. Create the email manager
|
|
294
|
+
* const emailManager = createEmailManager({
|
|
295
|
+
* config: {
|
|
296
|
+
* otpVerification: true,
|
|
297
|
+
* otpExpirationInMinutes: 5,
|
|
298
|
+
* prefill: false,
|
|
299
|
+
* },
|
|
300
|
+
* });
|
|
301
|
+
*
|
|
302
|
+
* // 3. Subscribe to state changes (optional but recommended)
|
|
303
|
+
* emailManager.subscribe((state) => {
|
|
304
|
+
* console.log('Email state:', state.status);
|
|
305
|
+
* if (state.status === 'finished') {
|
|
306
|
+
* console.log('Email verified successfully!');
|
|
307
|
+
* }
|
|
308
|
+
* if (state.status === 'error') {
|
|
309
|
+
* console.error('Error:', state.error);
|
|
310
|
+
* }
|
|
311
|
+
* });
|
|
312
|
+
*
|
|
313
|
+
* // 4. Start the flow
|
|
314
|
+
* emailManager.load();
|
|
315
|
+
*
|
|
316
|
+
* // 5. When state is 'inputting', set the email address
|
|
317
|
+
* emailManager.setEmail('user@example.com', true);
|
|
318
|
+
*
|
|
319
|
+
* // 6. Submit the email address
|
|
320
|
+
* emailManager.submit();
|
|
321
|
+
*
|
|
322
|
+
* // 7. When state is 'awaitingOtp', submit the OTP code
|
|
323
|
+
* emailManager.submitOtp('ABC123');
|
|
324
|
+
*
|
|
325
|
+
* // 8. Clean up when done
|
|
326
|
+
* emailManager.stop();
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @example Polling-based headless usage
|
|
330
|
+
* ```typescript
|
|
331
|
+
* const emailManager = createEmailManager({ config });
|
|
332
|
+
*
|
|
333
|
+
* emailManager.load();
|
|
334
|
+
*
|
|
335
|
+
* // Poll for state changes
|
|
336
|
+
* const interval = setInterval(() => {
|
|
337
|
+
* const state = emailManager.getState();
|
|
338
|
+
*
|
|
339
|
+
* switch (state.status) {
|
|
340
|
+
* case 'inputting':
|
|
341
|
+
* emailManager.setEmail('user@example.com', true);
|
|
342
|
+
* emailManager.submit();
|
|
343
|
+
* break;
|
|
344
|
+
* case 'awaitingOtp':
|
|
345
|
+
* // Get OTP from user or external source
|
|
346
|
+
* emailManager.submitOtp(otpCode);
|
|
347
|
+
* break;
|
|
348
|
+
* case 'finished':
|
|
349
|
+
* clearInterval(interval);
|
|
350
|
+
* emailManager.stop();
|
|
351
|
+
* break;
|
|
352
|
+
* case 'error':
|
|
353
|
+
* clearInterval(interval);
|
|
354
|
+
* console.error(state.error);
|
|
355
|
+
* emailManager.stop();
|
|
356
|
+
* break;
|
|
357
|
+
* }
|
|
358
|
+
* }, 100);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
function mapState(snapshot) {
|
|
362
|
+
const typedSnapshot = snapshot;
|
|
363
|
+
const { context } = typedSnapshot;
|
|
364
|
+
if (typedSnapshot.matches("idle")) return { status: "idle" };
|
|
365
|
+
if (typedSnapshot.matches("loadingPrefill")) return { status: "loadingPrefill" };
|
|
366
|
+
if (typedSnapshot.matches("inputting")) return {
|
|
367
|
+
status: "inputting",
|
|
368
|
+
prefilledEmail: context.prefilledEmail,
|
|
369
|
+
emailError: context.emailError
|
|
370
|
+
};
|
|
371
|
+
if (typedSnapshot.matches("submitting")) return { status: "submitting" };
|
|
372
|
+
if (typedSnapshot.matches("sendingOtp")) return { status: "sendingOtp" };
|
|
373
|
+
if (typedSnapshot.matches("awaitingOtp")) return {
|
|
374
|
+
status: "awaitingOtp",
|
|
375
|
+
resendTimer: context.resendTimer,
|
|
376
|
+
canResend: !context.resendTimerActive,
|
|
377
|
+
attemptsRemaining: context.attemptsRemaining
|
|
378
|
+
};
|
|
379
|
+
if (typedSnapshot.matches("verifyingOtp")) return { status: "verifyingOtp" };
|
|
380
|
+
if (typedSnapshot.matches("otpError")) return {
|
|
381
|
+
status: "otpError",
|
|
382
|
+
error: context.otpError ?? "Invalid OTP code",
|
|
383
|
+
attemptsRemaining: context.attemptsRemaining
|
|
384
|
+
};
|
|
385
|
+
if (typedSnapshot.matches("finished")) return { status: "finished" };
|
|
386
|
+
if (typedSnapshot.matches("error")) return {
|
|
387
|
+
status: "error",
|
|
388
|
+
error: context.error ?? "An error occurred"
|
|
389
|
+
};
|
|
390
|
+
return { status: "idle" };
|
|
391
|
+
}
|
|
392
|
+
function createApi({ actor }) {
|
|
393
|
+
return {
|
|
394
|
+
load() {
|
|
395
|
+
actor.send({ type: "LOAD" });
|
|
396
|
+
},
|
|
397
|
+
setEmail(email, isValid) {
|
|
398
|
+
actor.send({
|
|
399
|
+
type: "EMAIL_CHANGED",
|
|
400
|
+
email,
|
|
401
|
+
isValid
|
|
402
|
+
});
|
|
403
|
+
},
|
|
404
|
+
submit() {
|
|
405
|
+
actor.send({ type: "SUBMIT" });
|
|
406
|
+
},
|
|
407
|
+
setOtpCode(code) {
|
|
408
|
+
actor.send({
|
|
409
|
+
type: "OTP_CHANGED",
|
|
410
|
+
code
|
|
411
|
+
});
|
|
412
|
+
},
|
|
413
|
+
submitOtp(code) {
|
|
414
|
+
actor.send({
|
|
415
|
+
type: "OTP_CHANGED",
|
|
416
|
+
code
|
|
417
|
+
});
|
|
418
|
+
actor.send({ type: "VERIFY_OTP" });
|
|
419
|
+
},
|
|
420
|
+
resendOtp() {
|
|
421
|
+
actor.send({ type: "RESEND_OTP" });
|
|
422
|
+
},
|
|
423
|
+
back() {
|
|
424
|
+
actor.send({ type: "BACK" });
|
|
425
|
+
},
|
|
426
|
+
reset() {
|
|
427
|
+
actor.send({ type: "RESET" });
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Creates an email verification manager for headless or UI-driven usage.
|
|
433
|
+
*
|
|
434
|
+
* The manager provides a state machine-based API for email address verification
|
|
435
|
+
* with optional OTP (one-time password) verification.
|
|
436
|
+
*
|
|
437
|
+
* @param options - Configuration options
|
|
438
|
+
* @param options.config - Email verification configuration
|
|
439
|
+
* @param options.config.otpVerification - Whether to require OTP verification
|
|
440
|
+
* @param options.config.otpExpirationInMinutes - How long the OTP is valid
|
|
441
|
+
* @param options.config.prefill - Whether to fetch a pre-filled email address
|
|
442
|
+
* @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
|
|
443
|
+
*
|
|
444
|
+
* @returns Email manager with state, API methods, and subscription
|
|
445
|
+
*
|
|
446
|
+
* @example Headless usage
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const manager = createEmailManager({
|
|
449
|
+
* config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
|
|
450
|
+
* });
|
|
451
|
+
*
|
|
452
|
+
* manager.subscribe((state) => console.log(state.status));
|
|
453
|
+
* manager.load();
|
|
454
|
+
* manager.setEmail('user@example.com', true);
|
|
455
|
+
* manager.submit();
|
|
456
|
+
* // ... wait for 'awaitingOtp' state ...
|
|
457
|
+
* manager.submitOtp('ABC123');
|
|
458
|
+
* manager.stop();
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* @example With React/Preact UI hook
|
|
462
|
+
* ```tsx
|
|
463
|
+
* const [state, manager] = useManager(() => createEmailManager({ config }));
|
|
464
|
+
*
|
|
465
|
+
* if (state.status === 'inputting') {
|
|
466
|
+
* return <input onChange={(e) => manager.setEmail(e.target.value, true)} />;
|
|
467
|
+
* }
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
function createEmailManager(options) {
|
|
471
|
+
return createManager({
|
|
472
|
+
actor: createEmailActor(options),
|
|
473
|
+
mapState,
|
|
474
|
+
createApi
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function createEmailManagerFromActor(actor) {
|
|
478
|
+
return createManager({
|
|
479
|
+
actor,
|
|
480
|
+
mapState,
|
|
481
|
+
createApi
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
export { createEmailManagerFromActor as n, emailMachine as r, createEmailManager as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as isApiConfigured, r as getToken, t as api } from "./api-
|
|
2
|
-
import { t as endpoints } from "./endpoints-
|
|
1
|
+
import { i as isApiConfigured, r as getToken, t as api } from "./api-C2uzxrpN.esm.js";
|
|
2
|
+
import { t as endpoints } from "./endpoints-IAlXA1zN.esm.js";
|
|
3
3
|
|
|
4
4
|
//#region ../infra/src/capabilities/IBrowserEnvironmentCapability.ts
|
|
5
5
|
function getTimestamp() {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { S as CaptureIdResponse, i as createIdCaptureManagerFromActor, n as IdCaptureState, t as IdCaptureManager } from "./idCaptureManager-D8FwP0TW.js";
|
|
2
|
+
import { a as IStorageCapability } from "./deepsightService-UhtHJCFb.js";
|
|
3
|
+
import { C as WasmUtilConfig, S as VirtualCameraCheckOutput, b as BaseWasmProvider, c as FaceCaptureEvent, f as SendFaceImageResponse, l as FaceCaptureInput, n as FaceCaptureManagerState, s as FaceCaptureContext, t as FaceCaptureManager, u as faceCaptureMachine, x as IWasmUtilCapability } from "./faceCaptureManagerFactory-CiQWYHp2.js";
|
|
4
|
+
import "./warmup-Bp_1oXoL.js";
|
|
5
|
+
import "./Manager-CXnC-tN_.js";
|
|
6
|
+
import "./camera-DDn9ILon.js";
|
|
7
|
+
import { n as createActor } from "./Actor-BAf9LRYf.js";
|
|
8
|
+
import { r as fromPromise } from "./StateMachine-DJpZF_HP.js";
|
|
9
|
+
import "./types-BugcSDaO.js";
|
|
10
|
+
import "./types-C9Jo2XOb.js";
|
|
11
|
+
import { a as ProcessFaceResponse, i as createSelfieManagerFromActor, n as SelfieState, t as SelfieManager } from "./selfieManager-Czysy-lv.js";
|
|
12
|
+
import { i as createAuthenticationManagerFromActor, n as AuthenticationState, t as AuthenticationManager } from "./authenticationManager-DQL9XsaI.js";
|
|
13
|
+
import { i as createEmailManagerFromActor, n as EmailState, t as EmailManager } from "./emailManager-DZeOYBQ6.js";
|
|
14
|
+
import { i as createPhoneManagerFromActor, n as PhoneState, t as PhoneManager } from "./phoneManager-BsamACjL.js";
|
|
15
|
+
|
|
16
|
+
//#region ../infra/src/providers/browser/BrowserStorageProvider.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Browser-based storage provider wrapping localStorage.
|
|
19
|
+
* Handles JSON serialization/deserialization automatically.
|
|
20
|
+
*/
|
|
21
|
+
declare class BrowserStorageProvider implements IStorageCapability {
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves a value from localStorage.
|
|
24
|
+
* @param key - The storage key
|
|
25
|
+
* @returns The stored value or null if not found
|
|
26
|
+
* @throws Error if stored value is invalid JSON
|
|
27
|
+
*/
|
|
28
|
+
get<T>(key: string): Promise<T | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Stores a value in localStorage.
|
|
31
|
+
* @param key - The storage key
|
|
32
|
+
* @param value - The value to store (will be serialized as JSON)
|
|
33
|
+
* @throws Error if value cannot be serialized or quota is exceeded
|
|
34
|
+
*/
|
|
35
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Removes a value from localStorage.
|
|
38
|
+
* @param key - The storage key to remove
|
|
39
|
+
*/
|
|
40
|
+
remove(key: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Clears all values from localStorage.
|
|
43
|
+
*/
|
|
44
|
+
clear(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region ../infra/src/providers/wasm/WasmUtilProvider.d.ts
|
|
48
|
+
declare class WasmUtilProvider extends BaseWasmProvider implements IWasmUtilCapability {
|
|
49
|
+
private static instance;
|
|
50
|
+
private static initPromise;
|
|
51
|
+
static getInstance(): Promise<WasmUtilProvider>;
|
|
52
|
+
static resetInstance(): void;
|
|
53
|
+
constructor();
|
|
54
|
+
initialize(config: WasmUtilConfig): Promise<void>;
|
|
55
|
+
processFrame(_image: ImageData): Promise<void>;
|
|
56
|
+
encryptImage(image: string): string;
|
|
57
|
+
setSdkVersion(version: string): void;
|
|
58
|
+
setSdkPlatform(platform: string): void;
|
|
59
|
+
setDeviceInfo(deviceInfo: object, overrideExisting?: boolean): void;
|
|
60
|
+
setBrowserInfo(browserInfo: object, overrideExisting?: boolean): void;
|
|
61
|
+
setCameraInfo(cameraInfo: object, overrideExisting?: boolean): void;
|
|
62
|
+
setMotionStatus(status: string): void;
|
|
63
|
+
setBackgroundMode(backgroundMode: boolean): void;
|
|
64
|
+
setZc(zc: string): void;
|
|
65
|
+
setInspectorOpened(opened: boolean): void;
|
|
66
|
+
getMetadata(): string;
|
|
67
|
+
analyzeFrame(image: ImageData): Promise<void>;
|
|
68
|
+
getCheck(): string;
|
|
69
|
+
getPipelineState(): string;
|
|
70
|
+
estimatePerformance(): string;
|
|
71
|
+
isVirtualCamera(label: string | null): boolean;
|
|
72
|
+
prc(): Promise<void>;
|
|
73
|
+
poc(output: VirtualCameraCheckOutput): Promise<void>;
|
|
74
|
+
ckvcks(data: ArrayBuffer): void;
|
|
75
|
+
getVersions(): Promise<unknown>;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/modules/authentication/authenticationUploadService.d.ts
|
|
79
|
+
type AuthenticationUploadResponse = {
|
|
80
|
+
overallStatus: 'PASS' | 'FAIL';
|
|
81
|
+
captureAttemptsLimit: {
|
|
82
|
+
max: number;
|
|
83
|
+
remaining: number;
|
|
84
|
+
};
|
|
85
|
+
candidate: string;
|
|
86
|
+
error: {
|
|
87
|
+
name: string;
|
|
88
|
+
message: string;
|
|
89
|
+
};
|
|
90
|
+
imageBase64?: string;
|
|
91
|
+
selfieEncryptedBase64?: string;
|
|
92
|
+
metadata?: string;
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { type AuthenticationManager, type AuthenticationState, type AuthenticationUploadResponse, BrowserStorageProvider, type CaptureIdResponse, type EmailManager, type EmailState, type FaceCaptureContext, type FaceCaptureEvent, type FaceCaptureInput, type FaceCaptureManager, type FaceCaptureManagerState, type IdCaptureManager, type IdCaptureState, type PhoneManager, type PhoneState, type ProcessFaceResponse, type SelfieManager, type SelfieState, type SendFaceImageResponse, WasmUtilProvider, createActor, createAuthenticationManagerFromActor, createEmailManagerFromActor, createIdCaptureManagerFromActor, createPhoneManagerFromActor, createSelfieManagerFromActor, faceCaptureMachine, fromPromise };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "./events-3HzCcoEy.esm.js";
|
|
2
|
+
import "./backCameraStream-4aLwsDOv.esm.js";
|
|
3
|
+
import { _ as BrowserStorageProvider, a as WasmUtilProvider } from "./src-BmVrWkLJ.esm.js";
|
|
4
|
+
import { a as createActor, i as fromPromise } from "./xstate.esm-CcoTezCZ.esm.js";
|
|
5
|
+
import "./streamingEvents-Cw6kqXEh.esm.js";
|
|
6
|
+
import "./deepsightService-BgqD33AH.esm.js";
|
|
7
|
+
import "./api-C2uzxrpN.esm.js";
|
|
8
|
+
import "./endpoints-IAlXA1zN.esm.js";
|
|
9
|
+
import { n as createIdCaptureManagerFromActor } from "./idCaptureManager-B9BsU7-M.esm.js";
|
|
10
|
+
import "./stats-kLtQIgsA.esm.js";
|
|
11
|
+
import { n as faceCaptureMachine } from "./faceCaptureSetup-CF9TJlsc.esm.js";
|
|
12
|
+
import { n as createAuthenticationManagerFromActor } from "./authenticationManager-4j4j8ac9.esm.js";
|
|
13
|
+
import { n as createEmailManagerFromActor } from "./emailManager-e7j__XBB.esm.js";
|
|
14
|
+
import { n as createSelfieManagerFromActor } from "./selfieManager-ByV0akn-.esm.js";
|
|
15
|
+
import { n as createPhoneManagerFromActor } from "./phoneManager-B6fNmxhw.esm.js";
|
|
16
|
+
|
|
17
|
+
export { BrowserStorageProvider, WasmUtilProvider, createActor, createAuthenticationManagerFromActor, createEmailManagerFromActor, createIdCaptureManagerFromActor, createPhoneManagerFromActor, createSelfieManagerFromActor, faceCaptureMachine, fromPromise };
|
package/dist/face-match.d.ts
CHANGED
package/dist/face-match.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-
|
|
2
|
-
import { A as createManager } from "./src-
|
|
3
|
-
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-
|
|
4
|
-
import { t as api } from "./api-
|
|
5
|
-
import { t as endpoints } from "./endpoints-
|
|
1
|
+
import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-3HzCcoEy.esm.js";
|
|
2
|
+
import { A as createManager } from "./src-BmVrWkLJ.esm.js";
|
|
3
|
+
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-CcoTezCZ.esm.js";
|
|
4
|
+
import { t as api } from "./api-C2uzxrpN.esm.js";
|
|
5
|
+
import { t as endpoints } from "./endpoints-IAlXA1zN.esm.js";
|
|
6
6
|
|
|
7
7
|
//#region src/modules/face-match/faceMatchServices.ts
|
|
8
8
|
/**
|