@incodetech/core 0.0.0-dev-20260313-8b7649e → 0.0.0-dev-20260316-0522f9e

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 (82) hide show
  1. package/dist/Actor-D3GOC38V.d.ts +2 -0
  2. package/dist/StateMachine-BFurBmbZ.d.ts +2 -0
  3. package/dist/addressSearch-B446UZn4.esm.js +423 -0
  4. package/dist/authentication.d.ts +10 -78
  5. package/dist/authentication.esm.js +11 -195
  6. package/dist/authenticationManager-BWtUIJXV.d.ts +66 -0
  7. package/dist/authenticationManager-IChdnUM9.esm.js +197 -0
  8. package/dist/{backCameraStream-B57NWDGu.esm.js → backCameraStream-DDzfvhxo.esm.js} +1 -1
  9. package/dist/curp-validation.d.ts +4 -4
  10. package/dist/curp-validation.esm.js +5 -5
  11. package/dist/{deepsightLoader-BXTRzhYx.esm.js → deepsightLoader-IPtIRYqd.esm.js} +4 -4
  12. package/dist/{deepsightService-CYCDsan2.d.ts → deepsightService-CP5OM4Fc.d.ts} +131 -3
  13. package/dist/{deepsightService-CTK55DG8.esm.js → deepsightService-Ca85OHZ-.esm.js} +3 -3
  14. package/dist/document-capture.d.ts +2 -2
  15. package/dist/document-capture.esm.js +6 -6
  16. package/dist/document-upload.d.ts +3 -3
  17. package/dist/document-upload.esm.js +5 -5
  18. package/dist/ekyb.d.ts +16 -5
  19. package/dist/ekyb.esm.js +245 -65
  20. package/dist/ekyc.d.ts +2 -12
  21. package/dist/ekyc.esm.js +34 -197
  22. package/dist/email.d.ts +3 -263
  23. package/dist/email.esm.js +6 -477
  24. package/dist/emailManager-BRFO9OW6.esm.js +486 -0
  25. package/dist/emailManager-DcYzBeT-.d.ts +335 -0
  26. package/dist/{events-b4_xvENs.esm.js → events-3HzCcoEy.esm.js} +2 -2
  27. package/dist/extensibility.d.ts +95 -0
  28. package/dist/extensibility.esm.js +17 -0
  29. package/dist/face-match.d.ts +1 -1
  30. package/dist/face-match.esm.js +5 -5
  31. package/dist/faceCaptureManagerFactory-Dm3dO_r0.d.ts +610 -0
  32. package/dist/{faceCaptureSetup-10lCb_yE.esm.js → faceCaptureSetup-I9wFuT1d.esm.js} +11 -11
  33. package/dist/flow.d.ts +7 -7
  34. package/dist/flow.esm.js +6 -84
  35. package/dist/{flowCompletionService-DHXqHOAk.esm.js → flowCompletionService-D1bhU2uN.esm.js} +2 -2
  36. package/dist/flowServices-B5YbZJ7r.esm.js +83 -0
  37. package/dist/geolocation.d.ts +1 -1
  38. package/dist/geolocation.esm.js +5 -5
  39. package/dist/government-validation.d.ts +1 -1
  40. package/dist/government-validation.esm.js +4 -4
  41. package/dist/id-A_upgNRR.esm.js +0 -0
  42. package/dist/id.d.ts +9 -9
  43. package/dist/id.esm.js +11 -10
  44. package/dist/{id-TUJyOPso.esm.js → idCaptureManager-BdlS0WrG.esm.js} +18 -11
  45. package/dist/{index-5ZEjz-8I.d.ts → idCaptureManager-dTZ7KTot.d.ts} +30 -8
  46. package/dist/index-Km_6UPBI.d.ts +1 -0
  47. package/dist/index.d.ts +21 -12
  48. package/dist/index.esm.js +33 -21
  49. package/dist/{lib-V3Lo-Jit.esm.js → lib-DJozC192.esm.js} +1 -1
  50. package/dist/phone.d.ts +3 -291
  51. package/dist/phone.esm.js +6 -551
  52. package/dist/phoneManager-BwJpxm-D.d.ts +370 -0
  53. package/dist/phoneManager-TWj65pNG.esm.js +560 -0
  54. package/dist/redirect-to-mobile.d.ts +1 -1
  55. package/dist/redirect-to-mobile.esm.js +4 -4
  56. package/dist/selfie.d.ts +10 -408
  57. package/dist/selfie.esm.js +11 -118
  58. package/dist/selfieManager-BeVNeGVa.esm.js +117 -0
  59. package/dist/selfieManager-BgSkTLJj.d.ts +68 -0
  60. package/dist/session.d.ts +1 -1
  61. package/dist/session.esm.js +3 -3
  62. package/dist/{src-D3v6I2la.esm.js → src-D0bFtylT.esm.js} +2 -2
  63. package/dist/{stats-D76Thmqp.esm.js → stats-kLtQIgsA.esm.js} +1 -1
  64. package/dist/stats.esm.js +2 -2
  65. package/dist/{streamingEvents-CQq5fJCL.esm.js → streamingEvents-BjxVqrJP.esm.js} +3 -3
  66. package/dist/{types-DnrAr9fb.d.ts → types-BHnsBsl_.d.ts} +1 -1
  67. package/dist/{types-BYYaKde4.d.ts → types-CWa0DQcn.d.ts} +12 -1
  68. package/dist/{types-Bn54lmeM.d.ts → types-seztsdvN.d.ts} +1 -1
  69. package/package.json +5 -1
  70. package/dist/Actor-B6Lr-x6S.d.ts +0 -2
  71. package/dist/StateMachine-WHeQE3lC.d.ts +0 -2
  72. package/dist/faceCaptureManagerFactory-D1NUo68Z.d.ts +0 -231
  73. package/dist/types-B4KNFqC4.d.ts +0 -130
  74. package/dist/usStates-D4SmlpeT.esm.js +0 -210
  75. /package/dist/{Manager-CG5CQ1kY.d.ts → Manager-DsNvecSe.d.ts} +0 -0
  76. /package/dist/{api-3fZO5bmj.esm.js → api-C2uzxrpN.esm.js} +0 -0
  77. /package/dist/{camera-D7zu0Mls.d.ts → camera-Bzi6CMAW.d.ts} +0 -0
  78. /package/dist/{chunk-B1Ox1Owh.esm.js → chunk-C4_ANvih.esm.js} +0 -0
  79. /package/dist/{endpoints-5sPFFmaB.esm.js → endpoints-IAlXA1zN.esm.js} +0 -0
  80. /package/dist/{flowCompletionService-DeWKduBI.d.ts → flowCompletionService-BiICW3B-.d.ts} +0 -0
  81. /package/dist/{warmup-Da5qDIWZ.d.ts → warmup-4e5k___O.d.ts} +0 -0
  82. /package/dist/{xstate.esm-07M59Cte.esm.js → xstate.esm-CcoTezCZ.esm.js} +0 -0
@@ -1,197 +1,13 @@
1
- import { d as addEvent, n as eventModuleNames } from "./events-b4_xvENs.esm.js";
2
- import "./backCameraStream-B57NWDGu.esm.js";
3
- import { _ as BrowserStorageProvider, a as WasmUtilProvider } from "./src-D3v6I2la.esm.js";
4
- import { a as createActor, i as fromPromise, n as assign } from "./xstate.esm-07M59Cte.esm.js";
5
- import { l as getDeviceClass } from "./streamingEvents-CQq5fJCL.esm.js";
6
- import "./deepsightService-CTK55DG8.esm.js";
7
- import { t as api } from "./api-3fZO5bmj.esm.js";
8
- import { t as endpoints } from "./endpoints-5sPFFmaB.esm.js";
9
- import "./stats-D76Thmqp.esm.js";
10
- import { a as FACE_ERROR_CODES, n as faceCaptureMachine, o as createFaceCaptureManager, t as FACE_CAPTURE_EVENT_CODES } from "./faceCaptureSetup-10lCb_yE.esm.js";
1
+ import "./events-3HzCcoEy.esm.js";
2
+ import "./backCameraStream-DDzfvhxo.esm.js";
3
+ import "./src-D0bFtylT.esm.js";
4
+ import "./xstate.esm-CcoTezCZ.esm.js";
5
+ import "./streamingEvents-BjxVqrJP.esm.js";
6
+ import "./deepsightService-Ca85OHZ-.esm.js";
7
+ import "./api-C2uzxrpN.esm.js";
8
+ import "./endpoints-IAlXA1zN.esm.js";
9
+ import "./stats-kLtQIgsA.esm.js";
10
+ import "./faceCaptureSetup-I9wFuT1d.esm.js";
11
+ import { i as authenticationMachine, r as createAuthenticationActor, t as createAuthenticationManager } from "./authenticationManager-IChdnUM9.esm.js";
11
12
 
12
- //#region src/modules/authentication/authenticationErrorUtils.ts
13
- const AUTH_ERROR_MAP = {
14
- SPOOF_ATTEMPT_DETECTED: FACE_ERROR_CODES.SPOOF_ATTEMPT_DETECTED,
15
- SELFIE_FACE_OCCLUDED: FACE_ERROR_CODES.FACE_OCCLUDED,
16
- FACE_OCCLUDED: FACE_ERROR_CODES.FACE_OCCLUDED,
17
- FACE_TOO_DARK: FACE_ERROR_CODES.FACE_TOO_DARK,
18
- LENSES_DETECTED: FACE_ERROR_CODES.LENSES_DETECTED,
19
- FACE_MASK_DETECTED: FACE_ERROR_CODES.FACE_MASK_DETECTED,
20
- CLOSED_EYES_DETECTED: FACE_ERROR_CODES.CLOSED_EYES_DETECTED,
21
- HEAD_COVER_DETECTED: FACE_ERROR_CODES.HEAD_COVER_DETECTED,
22
- FACE_NOT_FOUND: FACE_ERROR_CODES.FACE_NOT_FOUND,
23
- FACE_CROPPING_FAILED: FACE_ERROR_CODES.FACE_CROPPING_FAILED,
24
- FACE_TOO_SMALL: FACE_ERROR_CODES.FACE_TOO_SMALL,
25
- FACE_TOO_BLURRY: FACE_ERROR_CODES.FACE_TOO_BLURRY,
26
- BAD_PHOTO_QUALITY: FACE_ERROR_CODES.BAD_PHOTO_QUALITY,
27
- PROCESSING_ERROR: FACE_ERROR_CODES.PROCESSING_ERROR,
28
- BAD_REQUEST: FACE_ERROR_CODES.BAD_REQUEST,
29
- SERVER: FACE_ERROR_CODES.SERVER,
30
- USER_IS_NOT_RECOGNIZED: FACE_ERROR_CODES.USER_IS_NOT_RECOGNIZED,
31
- NONEXISTENT_CUSTOMER: FACE_ERROR_CODES.NONEXISTENT_CUSTOMER,
32
- HINT_NOT_PROVIDED: FACE_ERROR_CODES.HINT_NOT_PROVIDED
33
- };
34
- const TERMINAL_AUTH_ERROR_CODES = [FACE_ERROR_CODES.NONEXISTENT_CUSTOMER, FACE_ERROR_CODES.HINT_NOT_PROVIDED];
35
- const validateAuthUploadResponse = (response) => {
36
- if (!response) return FACE_ERROR_CODES.SERVER;
37
- if (response.overallStatus !== "PASS") return AUTH_ERROR_MAP[response.error?.name] ?? FACE_ERROR_CODES.SERVER;
38
- };
39
- const isTerminalAuthError = (response, attemptsRemaining) => {
40
- if (!response) return false;
41
- const mappedError = AUTH_ERROR_MAP[response.error?.name];
42
- if (mappedError && TERMINAL_AUTH_ERROR_CODES.includes(mappedError)) return true;
43
- if (attemptsRemaining <= 0) return true;
44
- return false;
45
- };
46
-
47
- //#endregion
48
- //#region src/modules/authentication/authenticationUploadService.ts
49
- async function uploadAuthFace(params) {
50
- try {
51
- const payload = {
52
- base64Image: params.encryptedBase64Image,
53
- faceCoordinates: params.faceCoordinates ?? void 0,
54
- encrypted: true,
55
- clientInfo: { deviceClass: getDeviceClass() },
56
- metadata: params.metadata ?? void 0,
57
- ...params.authHint !== void 0 && { hint: params.authHint }
58
- };
59
- const query = {};
60
- if (params.recordingId) query.recordingId = params.recordingId;
61
- const res = await api.post(endpoints.authenticate, payload, {
62
- signal: params.signal,
63
- query
64
- });
65
- if (!res.ok) throw new Error(`POST ${endpoints.authenticate} failed: ${res.status} ${res.statusText}`);
66
- return res.data;
67
- } catch (error) {
68
- const errorCode = getAuthErrorCodeFromHttpError(error);
69
- if (errorCode) throw new Error(errorCode);
70
- throw new Error(FACE_ERROR_CODES.SERVER);
71
- }
72
- }
73
- const getAuthErrorCodeFromHttpError = (error) => {
74
- const err = error;
75
- if (err.ok !== false || typeof err.status !== "number") return;
76
- if (err.status !== 400) return FACE_ERROR_CODES.SERVER;
77
- const errorName = err.data?.error?.name;
78
- if (!errorName) return FACE_ERROR_CODES.BAD_REQUEST;
79
- return AUTH_ERROR_MAP[errorName] ?? FACE_ERROR_CODES.BAD_REQUEST;
80
- };
81
-
82
- //#endregion
83
- //#region src/modules/authentication/authenticationStateMachine.ts
84
- const _authenticationMachine = faceCaptureMachine.provide({
85
- actors: {
86
- uploadFace: fromPromise(async ({ input, signal }) => {
87
- const ctx = input;
88
- return uploadAuthFace({
89
- encryptedBase64Image: ctx.encryptedBase64Image,
90
- faceCoordinates: ctx.faceCoordinates,
91
- authHint: ctx.authHint,
92
- metadata: ctx.deepsightService?.getMetadata(),
93
- recordingId: ctx.uploadRecordingId,
94
- signal
95
- });
96
- }),
97
- processFace: fromPromise(async () => ({}))
98
- },
99
- actions: {
100
- trackContinue: () => {
101
- addEvent({
102
- code: FACE_CAPTURE_EVENT_CODES.CONTINUE,
103
- module: eventModuleNames.authentication
104
- });
105
- },
106
- setUploadErrorFromUploadValidation: assign({ uploadError: ({ context }) => {
107
- const resp = context.uploadResponse;
108
- return validateAuthUploadResponse(resp) ?? FACE_ERROR_CODES.SERVER;
109
- } }),
110
- setTerminalError: assign({ error: ({ context }) => {
111
- const resp = context.uploadResponse;
112
- if (context.attemptsRemaining <= 0) return {
113
- type: "FACE_AUTH_ERROR",
114
- message: "No more attempts remaining"
115
- };
116
- if (!resp) return {
117
- type: "FACE_AUTH_ERROR",
118
- message: "Authentication failed"
119
- };
120
- return {
121
- type: "FACE_AUTH_ERROR",
122
- message: resp.error?.message ?? resp.error?.name ?? "Face authentication error"
123
- };
124
- } })
125
- },
126
- guards: {
127
- hasUploadValidationError: ({ context }) => {
128
- const resp = context.uploadResponse;
129
- return validateAuthUploadResponse(resp) !== void 0;
130
- },
131
- isTerminalUploadError: ({ context }) => {
132
- const resp = context.uploadResponse;
133
- return isTerminalAuthError(resp, context.attemptsRemaining);
134
- },
135
- isNoAttemptsTerminal: () => true
136
- }
137
- });
138
- const authenticationMachine = _authenticationMachine;
139
-
140
- //#endregion
141
- //#region src/modules/authentication/authenticationActor.ts
142
- function createAuthenticationActor(options) {
143
- const dependencies = options.dependencies ?? {
144
- storage: new BrowserStorageProvider(),
145
- getWasmUtil: () => WasmUtilProvider.getInstance()
146
- };
147
- return createActor(authenticationMachine, { input: {
148
- config: options.config,
149
- dependencies,
150
- authHint: options.authHint
151
- } }).start();
152
- }
153
-
154
- //#endregion
155
- //#region src/modules/authentication/authenticationManager.ts
156
- /**
157
- * Creates an authentication manager instance for handling face authentication flow.
158
- *
159
- * The authentication manager provides:
160
- * - State management with statuses: `idle`, `loading`, `tutorial`, `permissions`, `capture`, `finished`, `closed`, `error`
161
- * - Permission handling with nested states: `idle`, `requesting`, `denied`, `learnMore`
162
- * - Capture handling with nested states: `initializing`, `startingRecorder`, `recordingActive`, `detecting`, `capturing`, `uploading`, `uploadError`, `success`
163
- * - Camera stream access when in `capture` state
164
- * - Detection status feedback during face detection
165
- * - Attempt tracking with `attemptsRemaining`
166
- *
167
- * @param options - Configuration for the authentication actor
168
- * @param options.config - The authentication module configuration from the flow
169
- * @param options.authHint - Hint for identifying the user (e.g., phone number, email)
170
- * @returns A manager instance with state subscription, API methods, and lifecycle controls
171
- *
172
- * @example
173
- * ```ts
174
- * const authManager = createAuthenticationManager({
175
- * config: authConfig,
176
- * authHint: 'user@example.com'
177
- * });
178
- *
179
- * authManager.subscribe((state) => {
180
- * if (state.status === 'capture') {
181
- * console.log('Camera ready:', state.stream);
182
- * console.log('Detection status:', state.detectionStatus);
183
- * }
184
- * if (state.status === 'finished') {
185
- * console.log('Authentication successful!');
186
- * }
187
- * });
188
- *
189
- * authManager.load();
190
- * ```
191
- */
192
- function createAuthenticationManager(options) {
193
- return createFaceCaptureManager(createAuthenticationActor(options));
194
- }
195
-
196
- //#endregion
197
13
  export { authenticationMachine, createAuthenticationActor, createAuthenticationManager };
@@ -0,0 +1,66 @@
1
+ import { m as CreateAuthenticationActorOptions, n as FaceCaptureManagerState, p as AuthenticationActor, t as FaceCaptureManager } from "./faceCaptureManagerFactory-Dm3dO_r0.js";
2
+ import { t as Manager } from "./Manager-DsNvecSe.js";
3
+
4
+ //#region src/modules/authentication/authenticationManager.d.ts
5
+ type AuthenticationState = FaceCaptureManagerState;
6
+ declare function createAuthenticationManagerFromActor(actor: AuthenticationActor): Manager<FaceCaptureManagerState> & {
7
+ load(): void;
8
+ nextStep(): void;
9
+ requestPermission(): void;
10
+ goToLearnMore(): void;
11
+ back(): void;
12
+ close(): void;
13
+ reset(): void;
14
+ retryCapture(): void;
15
+ capture(): void;
16
+ };
17
+ /**
18
+ * Creates an authentication manager instance for handling face authentication flow.
19
+ *
20
+ * The authentication manager provides:
21
+ * - State management with statuses: `idle`, `loading`, `tutorial`, `permissions`, `capture`, `finished`, `closed`, `error`
22
+ * - Permission handling with nested states: `idle`, `requesting`, `denied`, `learnMore`
23
+ * - Capture handling with nested states: `initializing`, `startingRecorder`, `recordingActive`, `detecting`, `capturing`, `uploading`, `uploadError`, `success`
24
+ * - Camera stream access when in `capture` state
25
+ * - Detection status feedback during face detection
26
+ * - Attempt tracking with `attemptsRemaining`
27
+ *
28
+ * @param options - Configuration for the authentication actor
29
+ * @param options.config - The authentication module configuration from the flow
30
+ * @param options.authHint - Hint for identifying the user (e.g., phone number, email)
31
+ * @returns A manager instance with state subscription, API methods, and lifecycle controls
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const authManager = createAuthenticationManager({
36
+ * config: authConfig,
37
+ * authHint: 'user@example.com'
38
+ * });
39
+ *
40
+ * authManager.subscribe((state) => {
41
+ * if (state.status === 'capture') {
42
+ * console.log('Camera ready:', state.stream);
43
+ * console.log('Detection status:', state.detectionStatus);
44
+ * }
45
+ * if (state.status === 'finished') {
46
+ * console.log('Authentication successful!');
47
+ * }
48
+ * });
49
+ *
50
+ * authManager.load();
51
+ * ```
52
+ */
53
+ declare function createAuthenticationManager(options: CreateAuthenticationActorOptions): Manager<FaceCaptureManagerState> & {
54
+ load(): void;
55
+ nextStep(): void;
56
+ requestPermission(): void;
57
+ goToLearnMore(): void;
58
+ back(): void;
59
+ close(): void;
60
+ reset(): void;
61
+ retryCapture(): void;
62
+ capture(): void;
63
+ };
64
+ type AuthenticationManager = FaceCaptureManager;
65
+ //#endregion
66
+ export { createAuthenticationManagerFromActor as i, AuthenticationState as n, createAuthenticationManager as r, AuthenticationManager as t };
@@ -0,0 +1,197 @@
1
+ import { d as addEvent, n as eventModuleNames } from "./events-3HzCcoEy.esm.js";
2
+ import { _ as BrowserStorageProvider, a as WasmUtilProvider } from "./src-D0bFtylT.esm.js";
3
+ import { a as createActor, i as fromPromise, n as assign } from "./xstate.esm-CcoTezCZ.esm.js";
4
+ import { l as getDeviceClass } from "./streamingEvents-BjxVqrJP.esm.js";
5
+ import { t as api } from "./api-C2uzxrpN.esm.js";
6
+ import { t as endpoints } from "./endpoints-IAlXA1zN.esm.js";
7
+ import { a as FACE_ERROR_CODES, n as faceCaptureMachine, o as createFaceCaptureManagerFromActor, t as FACE_CAPTURE_EVENT_CODES } from "./faceCaptureSetup-I9wFuT1d.esm.js";
8
+
9
+ //#region src/modules/authentication/authenticationErrorUtils.ts
10
+ const AUTH_ERROR_MAP = {
11
+ SPOOF_ATTEMPT_DETECTED: FACE_ERROR_CODES.SPOOF_ATTEMPT_DETECTED,
12
+ SELFIE_FACE_OCCLUDED: FACE_ERROR_CODES.FACE_OCCLUDED,
13
+ FACE_OCCLUDED: FACE_ERROR_CODES.FACE_OCCLUDED,
14
+ FACE_TOO_DARK: FACE_ERROR_CODES.FACE_TOO_DARK,
15
+ LENSES_DETECTED: FACE_ERROR_CODES.LENSES_DETECTED,
16
+ FACE_MASK_DETECTED: FACE_ERROR_CODES.FACE_MASK_DETECTED,
17
+ CLOSED_EYES_DETECTED: FACE_ERROR_CODES.CLOSED_EYES_DETECTED,
18
+ HEAD_COVER_DETECTED: FACE_ERROR_CODES.HEAD_COVER_DETECTED,
19
+ FACE_NOT_FOUND: FACE_ERROR_CODES.FACE_NOT_FOUND,
20
+ FACE_CROPPING_FAILED: FACE_ERROR_CODES.FACE_CROPPING_FAILED,
21
+ FACE_TOO_SMALL: FACE_ERROR_CODES.FACE_TOO_SMALL,
22
+ FACE_TOO_BLURRY: FACE_ERROR_CODES.FACE_TOO_BLURRY,
23
+ BAD_PHOTO_QUALITY: FACE_ERROR_CODES.BAD_PHOTO_QUALITY,
24
+ PROCESSING_ERROR: FACE_ERROR_CODES.PROCESSING_ERROR,
25
+ BAD_REQUEST: FACE_ERROR_CODES.BAD_REQUEST,
26
+ SERVER: FACE_ERROR_CODES.SERVER,
27
+ USER_IS_NOT_RECOGNIZED: FACE_ERROR_CODES.USER_IS_NOT_RECOGNIZED,
28
+ NONEXISTENT_CUSTOMER: FACE_ERROR_CODES.NONEXISTENT_CUSTOMER,
29
+ HINT_NOT_PROVIDED: FACE_ERROR_CODES.HINT_NOT_PROVIDED
30
+ };
31
+ const TERMINAL_AUTH_ERROR_CODES = [FACE_ERROR_CODES.NONEXISTENT_CUSTOMER, FACE_ERROR_CODES.HINT_NOT_PROVIDED];
32
+ const validateAuthUploadResponse = (response) => {
33
+ if (!response) return FACE_ERROR_CODES.SERVER;
34
+ if (response.overallStatus !== "PASS") return AUTH_ERROR_MAP[response.error?.name] ?? FACE_ERROR_CODES.SERVER;
35
+ };
36
+ const isTerminalAuthError = (response, attemptsRemaining) => {
37
+ if (!response) return false;
38
+ const mappedError = AUTH_ERROR_MAP[response.error?.name];
39
+ if (mappedError && TERMINAL_AUTH_ERROR_CODES.includes(mappedError)) return true;
40
+ if (attemptsRemaining <= 0) return true;
41
+ return false;
42
+ };
43
+
44
+ //#endregion
45
+ //#region src/modules/authentication/authenticationUploadService.ts
46
+ async function uploadAuthFace(params) {
47
+ try {
48
+ const payload = {
49
+ base64Image: params.encryptedBase64Image,
50
+ faceCoordinates: params.faceCoordinates ?? void 0,
51
+ encrypted: true,
52
+ clientInfo: { deviceClass: getDeviceClass() },
53
+ metadata: params.metadata ?? void 0,
54
+ ...params.authHint !== void 0 && { hint: params.authHint }
55
+ };
56
+ const query = {};
57
+ if (params.recordingId) query.recordingId = params.recordingId;
58
+ const res = await api.post(endpoints.authenticate, payload, {
59
+ signal: params.signal,
60
+ query
61
+ });
62
+ if (!res.ok) throw new Error(`POST ${endpoints.authenticate} failed: ${res.status} ${res.statusText}`);
63
+ return res.data;
64
+ } catch (error) {
65
+ const errorCode = getAuthErrorCodeFromHttpError(error);
66
+ if (errorCode) throw new Error(errorCode);
67
+ throw new Error(FACE_ERROR_CODES.SERVER);
68
+ }
69
+ }
70
+ const getAuthErrorCodeFromHttpError = (error) => {
71
+ const err = error;
72
+ if (err.ok !== false || typeof err.status !== "number") return;
73
+ if (err.status !== 400) return FACE_ERROR_CODES.SERVER;
74
+ const errorName = err.data?.error?.name;
75
+ if (!errorName) return FACE_ERROR_CODES.BAD_REQUEST;
76
+ return AUTH_ERROR_MAP[errorName] ?? FACE_ERROR_CODES.BAD_REQUEST;
77
+ };
78
+
79
+ //#endregion
80
+ //#region src/modules/authentication/authenticationStateMachine.ts
81
+ const _authenticationMachine = faceCaptureMachine.provide({
82
+ actors: {
83
+ uploadFace: fromPromise(async ({ input, signal }) => {
84
+ const ctx = input;
85
+ return uploadAuthFace({
86
+ encryptedBase64Image: ctx.encryptedBase64Image,
87
+ faceCoordinates: ctx.faceCoordinates,
88
+ authHint: ctx.authHint,
89
+ metadata: ctx.deepsightService?.getMetadata(),
90
+ recordingId: ctx.uploadRecordingId,
91
+ signal
92
+ });
93
+ }),
94
+ processFace: fromPromise(async () => ({}))
95
+ },
96
+ actions: {
97
+ trackContinue: () => {
98
+ addEvent({
99
+ code: FACE_CAPTURE_EVENT_CODES.CONTINUE,
100
+ module: eventModuleNames.authentication
101
+ });
102
+ },
103
+ setUploadErrorFromUploadValidation: assign({ uploadError: ({ context }) => {
104
+ const resp = context.uploadResponse;
105
+ return validateAuthUploadResponse(resp) ?? FACE_ERROR_CODES.SERVER;
106
+ } }),
107
+ setTerminalError: assign({ error: ({ context }) => {
108
+ const resp = context.uploadResponse;
109
+ if (context.attemptsRemaining <= 0) return {
110
+ type: "FACE_AUTH_ERROR",
111
+ message: "No more attempts remaining"
112
+ };
113
+ if (!resp) return {
114
+ type: "FACE_AUTH_ERROR",
115
+ message: "Authentication failed"
116
+ };
117
+ return {
118
+ type: "FACE_AUTH_ERROR",
119
+ message: resp.error?.message ?? resp.error?.name ?? "Face authentication error"
120
+ };
121
+ } })
122
+ },
123
+ guards: {
124
+ hasUploadValidationError: ({ context }) => {
125
+ const resp = context.uploadResponse;
126
+ return validateAuthUploadResponse(resp) !== void 0;
127
+ },
128
+ isTerminalUploadError: ({ context }) => {
129
+ const resp = context.uploadResponse;
130
+ return isTerminalAuthError(resp, context.attemptsRemaining);
131
+ },
132
+ isNoAttemptsTerminal: () => true
133
+ }
134
+ });
135
+ const authenticationMachine = _authenticationMachine;
136
+
137
+ //#endregion
138
+ //#region src/modules/authentication/authenticationActor.ts
139
+ function createAuthenticationActor(options) {
140
+ const dependencies = options.dependencies ?? {
141
+ storage: new BrowserStorageProvider(),
142
+ getWasmUtil: () => WasmUtilProvider.getInstance()
143
+ };
144
+ return createActor(authenticationMachine, { input: {
145
+ config: options.config,
146
+ dependencies,
147
+ authHint: options.authHint
148
+ } }).start();
149
+ }
150
+
151
+ //#endregion
152
+ //#region src/modules/authentication/authenticationManager.ts
153
+ function createAuthenticationManagerFromActor(actor) {
154
+ return createFaceCaptureManagerFromActor(actor);
155
+ }
156
+ /**
157
+ * Creates an authentication manager instance for handling face authentication flow.
158
+ *
159
+ * The authentication manager provides:
160
+ * - State management with statuses: `idle`, `loading`, `tutorial`, `permissions`, `capture`, `finished`, `closed`, `error`
161
+ * - Permission handling with nested states: `idle`, `requesting`, `denied`, `learnMore`
162
+ * - Capture handling with nested states: `initializing`, `startingRecorder`, `recordingActive`, `detecting`, `capturing`, `uploading`, `uploadError`, `success`
163
+ * - Camera stream access when in `capture` state
164
+ * - Detection status feedback during face detection
165
+ * - Attempt tracking with `attemptsRemaining`
166
+ *
167
+ * @param options - Configuration for the authentication actor
168
+ * @param options.config - The authentication module configuration from the flow
169
+ * @param options.authHint - Hint for identifying the user (e.g., phone number, email)
170
+ * @returns A manager instance with state subscription, API methods, and lifecycle controls
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * const authManager = createAuthenticationManager({
175
+ * config: authConfig,
176
+ * authHint: 'user@example.com'
177
+ * });
178
+ *
179
+ * authManager.subscribe((state) => {
180
+ * if (state.status === 'capture') {
181
+ * console.log('Camera ready:', state.stream);
182
+ * console.log('Detection status:', state.detectionStatus);
183
+ * }
184
+ * if (state.status === 'finished') {
185
+ * console.log('Authentication successful!');
186
+ * }
187
+ * });
188
+ *
189
+ * authManager.load();
190
+ * ```
191
+ */
192
+ function createAuthenticationManager(options) {
193
+ return createFaceCaptureManagerFromActor(createAuthenticationActor(options));
194
+ }
195
+
196
+ //#endregion
197
+ export { authenticationMachine as i, createAuthenticationManagerFromActor as n, createAuthenticationActor as r, createAuthenticationManager as t };
@@ -1,4 +1,4 @@
1
- import { B as isSafari, D as enumerateVideoDevices, E as applyTrackConstraints, F as isAndroid, L as isIOS, O as requestCameraAccess, k as stopCameraStream, z as isIPhone14OrHigher } from "./src-D3v6I2la.esm.js";
1
+ import { B as isSafari, D as enumerateVideoDevices, E as applyTrackConstraints, F as isAndroid, L as isIOS, O as requestCameraAccess, k as stopCameraStream, z as isIPhone14OrHigher } from "./src-D0bFtylT.esm.js";
2
2
 
3
3
  //#region ../infra/src/capabilities/ITimerCapability.ts
4
4
  function sleep(ms) {
@@ -1,7 +1,7 @@
1
- import { t as Manager } from "./Manager-CG5CQ1kY.js";
2
- import "./camera-D7zu0Mls.js";
3
- import "./types-DnrAr9fb.js";
4
- import { r as FlowModuleConfig } from "./types-Bn54lmeM.js";
1
+ import { t as Manager } from "./Manager-DsNvecSe.js";
2
+ import "./camera-Bzi6CMAW.js";
3
+ import "./types-BHnsBsl_.js";
4
+ import { r as FlowModuleConfig } from "./types-seztsdvN.js";
5
5
 
6
6
  //#region src/modules/curp-validation/types.d.ts
7
7
  type CurpValidationConfig = FlowModuleConfig['CURP_VALIDATION'] & {
@@ -1,8 +1,8 @@
1
- import { n as eventModuleNames, r as eventScreenNames, u as screenOpened } from "./events-b4_xvENs.esm.js";
2
- import { A as createManager } from "./src-D3v6I2la.esm.js";
3
- import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-07M59Cte.esm.js";
4
- import { t as api } from "./api-3fZO5bmj.esm.js";
5
- import { t as endpoints } from "./endpoints-5sPFFmaB.esm.js";
1
+ import { n as eventModuleNames, r as eventScreenNames, u as screenOpened } from "./events-3HzCcoEy.esm.js";
2
+ import { A as createManager } from "./src-D0bFtylT.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/curp-validation/curpValidationUtils.ts
8
8
  const CURP_PATTERN = /^([A-Z][AEIOUX][A-Z]{2}\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])[HMX](?:AS|B[CS]|C[CLMSH]|D[FG]|G[TR]|HG|JC|M[CNS]|N[ETL]|OC|PL|Q[TR]|S[PLR]|T[CSL]|VZ|YN|ZS)[B-DF-HJ-NP-TV-Z]{3}[A-Z\d])(\d)$/;
@@ -1,7 +1,7 @@
1
- import { a as WasmUtilProvider, f as MotionSensorProvider, l as VisibilityProvider, y as BrowserEnvironmentProvider } from "./src-D3v6I2la.esm.js";
2
- import { t as createDeepsightService } from "./deepsightService-CTK55DG8.esm.js";
3
- import "./api-3fZO5bmj.esm.js";
4
- import "./stats-D76Thmqp.esm.js";
1
+ import { a as WasmUtilProvider, f as MotionSensorProvider, l as VisibilityProvider, y as BrowserEnvironmentProvider } from "./src-D0bFtylT.esm.js";
2
+ import { t as createDeepsightService } from "./deepsightService-Ca85OHZ-.esm.js";
3
+ import "./api-C2uzxrpN.esm.js";
4
+ import "./stats-kLtQIgsA.esm.js";
5
5
 
6
6
  //#region src/internal/deepsight/deepsightLoader.ts
7
7
  const SDK_VERSION = "2.0.0";
@@ -1,4 +1,4 @@
1
- import { t as CameraStream } from "./camera-D7zu0Mls.js";
1
+ import { t as CameraStream } from "./camera-Bzi6CMAW.js";
2
2
 
3
3
  //#region ../infra/src/media/canvas.d.ts
4
4
  /**
@@ -111,8 +111,61 @@ declare class IncodeCanvas {
111
111
  getResizedCanvas(videoElementWidth: number, videoElementHeight: number): IncodeCanvas | null;
112
112
  }
113
113
  //#endregion
114
+ //#region ../infra/src/capabilities/IMLProviderCapability.d.ts
115
+ /**
116
+ * Base configuration shared by all ML provider capabilities.
117
+ */
118
+ interface MLProviderConfig {
119
+ /** Path to the WASM binary */
120
+ wasmPath?: string;
121
+ /** Path to the SIMD-optimized WASM binary (optional) */
122
+ wasmSimdPath?: string;
123
+ /** Path to the WASM glue code */
124
+ glueCodePath?: string;
125
+ /** Whether to use SIMD optimizations (default: true) */
126
+ useSimd?: boolean;
127
+ /**
128
+ * Base path for ML model files. Models will be loaded from `${modelsBasePath}/${modelFileName}`.
129
+ * If not provided, models are expected in a 'models' subdirectory relative to the WASM binary.
130
+ */
131
+ modelsBasePath?: string;
132
+ }
133
+ /**
134
+ * Base interface for ML provider capabilities.
135
+ * Provides common lifecycle and frame processing methods shared by
136
+ * FaceDetectionCapability and IdCaptureCapability.
137
+ */
138
+ interface IMLProviderCapability<TConfig extends MLProviderConfig> {
139
+ /**
140
+ * Whether the provider has been initialized and is ready to process frames.
141
+ */
142
+ readonly initialized: boolean;
143
+ /**
144
+ * Initializes the provider with the given configuration.
145
+ * If WASM was already warmed up via `setup()` or `warmupWasm()`, this returns almost instantly.
146
+ * @param config - Provider configuration including WASM paths
147
+ */
148
+ initialize(config: TConfig): Promise<void>;
149
+ /**
150
+ * Processes a frame through the ML pipeline.
151
+ * Callbacks set via `setCallbacks()` will be invoked based on the analysis results.
152
+ * @param image - Image data to process
153
+ * @throws Error if provider is not initialized
154
+ */
155
+ processFrame(image: ImageData): Promise<void>;
156
+ /**
157
+ * Resets the pipeline to its initial state.
158
+ * Safe to call even if not initialized (no-op in that case).
159
+ */
160
+ reset(): void;
161
+ /**
162
+ * Disposes of resources and resets initialization state.
163
+ * Safe to call even if not initialized.
164
+ */
165
+ dispose(): Promise<void>;
166
+ }
167
+ //#endregion
114
168
  //#region ../infra/src/capabilities/IMotionSensorCapability.d.ts
115
-
116
169
  type MotionStatus = 'PASS' | 'FAIL' | 'UNCLEAR';
117
170
  type MotionPermissionState = 'granted' | 'denied' | 'not-required';
118
171
  type IMotionSensorCapability = {
@@ -124,6 +177,77 @@ type IMotionSensorCapability = {
124
177
  readonly hasPermission: boolean;
125
178
  };
126
179
  //#endregion
180
+ //#region ../infra/src/capabilities/IRecordingCapability.d.ts
181
+ type RecordingPublisher = {
182
+ getStreamId: () => string | undefined;
183
+ replaceVideoTrack: (track: MediaStreamTrack) => Promise<void>;
184
+ destroy: () => void;
185
+ };
186
+ type RecordingConnection = {
187
+ sessionId: string | undefined;
188
+ publisher: RecordingPublisher;
189
+ disconnect: () => Promise<void>;
190
+ };
191
+ type RecordingConnectionEvents = {
192
+ onSessionConnected?: (sessionId: string | undefined) => void;
193
+ onSessionDisconnected?: (sessionId: string | undefined) => void;
194
+ onSessionException?: (params: {
195
+ name?: string;
196
+ message?: string;
197
+ sessionId?: string;
198
+ }) => void;
199
+ onPublisherCreated?: (params: {
200
+ streamId?: string;
201
+ sessionId?: string;
202
+ }) => void;
203
+ onPublisherError?: (params: {
204
+ message?: string;
205
+ sessionId?: string;
206
+ streamId?: string;
207
+ }) => void;
208
+ };
209
+ type ConnectRecordingParams = {
210
+ sessionToken: string;
211
+ stream: MediaStream;
212
+ events?: RecordingConnectionEvents;
213
+ };
214
+ type IRecordingCapability = {
215
+ /**
216
+ * Connects to a recording session and publishes the provided media stream.
217
+ * Returns a connection handle that can be disconnected and used to manage the publisher.
218
+ */
219
+ connect: (params: ConnectRecordingParams) => Promise<RecordingConnection>;
220
+ };
221
+ //#endregion
222
+ //#region ../infra/src/capabilities/IStorageCapability.d.ts
223
+ /**
224
+ * Storage capability interface for abstracting storage operations.
225
+ * Enables swapping between browser localStorage and future WASM-based storage.
226
+ */
227
+ interface IStorageCapability {
228
+ /**
229
+ * Retrieves a value from storage.
230
+ * @param key - The storage key
231
+ * @returns The stored value or null if not found
232
+ */
233
+ get<T>(key: string): Promise<T | null>;
234
+ /**
235
+ * Stores a value in storage.
236
+ * @param key - The storage key
237
+ * @param value - The value to store (will be serialized)
238
+ */
239
+ set<T>(key: string, value: T): Promise<void>;
240
+ /**
241
+ * Removes a value from storage.
242
+ * @param key - The storage key to remove
243
+ */
244
+ remove(key: string): Promise<void>;
245
+ /**
246
+ * Clears all values from storage.
247
+ */
248
+ clear(): Promise<void>;
249
+ }
250
+ //#endregion
127
251
  //#region ../infra/src/media/StreamCanvasCapture.d.ts
128
252
  type StreamCanvasCaptureOptions = {
129
253
  fps?: number;
@@ -162,6 +286,10 @@ declare class StreamCanvasCapture {
162
286
  private tick;
163
287
  }
164
288
  //#endregion
289
+ //#region src/internal/permissions/types.d.ts
290
+ type PermissionResult = 'granted' | 'denied' | 'prompt';
291
+ type PermissionStatus = 'idle' | 'requesting' | 'denied' | 'learnMore';
292
+ //#endregion
165
293
  //#region src/internal/deepsight/metadataService.d.ts
166
294
  type MetadataService = {
167
295
  initialize(sdkVersion: string, disableIpify?: boolean): Promise<void>;
@@ -222,4 +350,4 @@ type DeepsightPrcCheckParams = {
222
350
  constraints: MediaStreamConstraints;
223
351
  };
224
352
  //#endregion
225
- export { IncodeCanvas as i, StreamCanvasCapture as n, IMotionSensorCapability as r, DeepsightService as t };
353
+ export { IStorageCapability as a, IMotionSensorCapability as c, IncodeCanvas as d, StreamCanvasCapture as i, IMLProviderCapability as l, PermissionResult as n, IRecordingCapability as o, PermissionStatus as r, RecordingConnection as s, DeepsightService as t, MLProviderConfig as u };