@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.
Files changed (80) hide show
  1. package/dist/Actor-BAf9LRYf.d.ts +2 -0
  2. package/dist/StateMachine-DJpZF_HP.d.ts +2 -0
  3. package/dist/authentication.d.ts +10 -78
  4. package/dist/authentication.esm.js +11 -195
  5. package/dist/authenticationManager-4j4j8ac9.esm.js +197 -0
  6. package/dist/authenticationManager-DQL9XsaI.d.ts +66 -0
  7. package/dist/{backCameraStream-B57NWDGu.esm.js → backCameraStream-4aLwsDOv.esm.js} +1 -1
  8. package/dist/curp-validation.d.ts +4 -4
  9. package/dist/curp-validation.esm.js +5 -5
  10. package/dist/{deepsightLoader-BXTRzhYx.esm.js → deepsightLoader-C-Xil8cg.esm.js} +4 -4
  11. package/dist/{deepsightService-CTK55DG8.esm.js → deepsightService-BgqD33AH.esm.js} +3 -3
  12. package/dist/{deepsightService-CYCDsan2.d.ts → deepsightService-UhtHJCFb.d.ts} +131 -3
  13. package/dist/document-capture.d.ts +49 -49
  14. package/dist/document-capture.esm.js +6 -6
  15. package/dist/document-upload.d.ts +49 -49
  16. package/dist/document-upload.esm.js +5 -5
  17. package/dist/ekyb.d.ts +2 -2
  18. package/dist/ekyb.esm.js +6 -6
  19. package/dist/ekyc.d.ts +2 -2
  20. package/dist/ekyc.esm.js +6 -6
  21. package/dist/email.d.ts +3 -263
  22. package/dist/email.esm.js +6 -477
  23. package/dist/emailManager-DZeOYBQ6.d.ts +335 -0
  24. package/dist/emailManager-e7j__XBB.esm.js +486 -0
  25. package/dist/{events-b4_xvENs.esm.js → events-3HzCcoEy.esm.js} +2 -2
  26. package/dist/extensibility.d.ts +95 -0
  27. package/dist/extensibility.esm.js +17 -0
  28. package/dist/face-match.d.ts +1 -1
  29. package/dist/face-match.esm.js +5 -5
  30. package/dist/faceCaptureManagerFactory-CiQWYHp2.d.ts +610 -0
  31. package/dist/{faceCaptureSetup-10lCb_yE.esm.js → faceCaptureSetup-CF9TJlsc.esm.js} +11 -11
  32. package/dist/flow.d.ts +7 -7
  33. package/dist/flow.esm.js +5 -5
  34. package/dist/{flowCompletionService-DHXqHOAk.esm.js → flowCompletionService-CV8Ywiut.esm.js} +2 -2
  35. package/dist/geolocation.d.ts +1 -1
  36. package/dist/geolocation.esm.js +5 -5
  37. package/dist/government-validation.d.ts +1 -1
  38. package/dist/government-validation.esm.js +4 -4
  39. package/dist/id-A_upgNRR.esm.js +0 -0
  40. package/dist/id.d.ts +9 -9
  41. package/dist/id.esm.js +11 -10
  42. package/dist/{id-TUJyOPso.esm.js → idCaptureManager-B9BsU7-M.esm.js} +18 -11
  43. package/dist/{index-5ZEjz-8I.d.ts → idCaptureManager-D8FwP0TW.d.ts} +30 -8
  44. package/dist/index-BtQzTfU9.d.ts +1 -0
  45. package/dist/index.d.ts +21 -12
  46. package/dist/index.esm.js +33 -21
  47. package/dist/{lib-V3Lo-Jit.esm.js → lib-COh1FH9n.esm.js} +1 -1
  48. package/dist/phone.d.ts +3 -291
  49. package/dist/phone.esm.js +6 -551
  50. package/dist/phoneManager-B6fNmxhw.esm.js +560 -0
  51. package/dist/phoneManager-BsamACjL.d.ts +370 -0
  52. package/dist/redirect-to-mobile.d.ts +1 -1
  53. package/dist/redirect-to-mobile.esm.js +4 -4
  54. package/dist/selfie.d.ts +10 -408
  55. package/dist/selfie.esm.js +11 -118
  56. package/dist/selfieManager-ByV0akn-.esm.js +117 -0
  57. package/dist/selfieManager-Czysy-lv.d.ts +68 -0
  58. package/dist/session.d.ts +1 -1
  59. package/dist/session.esm.js +3 -3
  60. package/dist/{src-D3v6I2la.esm.js → src-BmVrWkLJ.esm.js} +2 -2
  61. package/dist/{stats-D76Thmqp.esm.js → stats-kLtQIgsA.esm.js} +1 -1
  62. package/dist/stats.esm.js +2 -2
  63. package/dist/{streamingEvents-CQq5fJCL.esm.js → streamingEvents-Cw6kqXEh.esm.js} +3 -3
  64. package/dist/{types-DnrAr9fb.d.ts → types-BugcSDaO.d.ts} +1 -1
  65. package/dist/{types-Bn54lmeM.d.ts → types-C9Jo2XOb.d.ts} +1 -1
  66. package/package.json +5 -1
  67. package/dist/Actor-B6Lr-x6S.d.ts +0 -2
  68. package/dist/StateMachine-WHeQE3lC.d.ts +0 -2
  69. package/dist/faceCaptureManagerFactory-D1NUo68Z.d.ts +0 -231
  70. package/dist/types-B4KNFqC4.d.ts +0 -130
  71. /package/dist/{Manager-CG5CQ1kY.d.ts → Manager-CXnC-tN_.d.ts} +0 -0
  72. /package/dist/{api-3fZO5bmj.esm.js → api-C2uzxrpN.esm.js} +0 -0
  73. /package/dist/{camera-D7zu0Mls.d.ts → camera-DDn9ILon.d.ts} +0 -0
  74. /package/dist/{chunk-B1Ox1Owh.esm.js → chunk-C4_ANvih.esm.js} +0 -0
  75. /package/dist/{endpoints-5sPFFmaB.esm.js → endpoints-IAlXA1zN.esm.js} +0 -0
  76. /package/dist/{flowCompletionService-DeWKduBI.d.ts → flowCompletionService-D4YDcHQR.d.ts} +0 -0
  77. /package/dist/{types-BYYaKde4.d.ts → types-DTieLton.d.ts} +0 -0
  78. /package/dist/{usStates-D4SmlpeT.esm.js → usStates-vWM_ZgEH.esm.js} +0 -0
  79. /package/dist/{warmup-Da5qDIWZ.d.ts → warmup-Bp_1oXoL.d.ts} +0 -0
  80. /package/dist/{xstate.esm-07M59Cte.esm.js → xstate.esm-CcoTezCZ.esm.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import { ActorRefFrom, createActor } from "xstate";
2
+ export { createActor as n, ActorRefFrom as t };
@@ -0,0 +1,2 @@
1
+ import { AnyStateMachine, StateMachine, fromPromise } from "xstate";
2
+ export { StateMachine as n, fromPromise as r, AnyStateMachine as t };
@@ -1,79 +1,11 @@
1
- import "./types-B4KNFqC4.js";
2
- import "./warmup-Da5qDIWZ.js";
3
- import { a as FaceCaptureDependencies, n as FaceCaptureManagerState, r as BaseFaceCaptureConfig, t as FaceCaptureManager } from "./faceCaptureManagerFactory-D1NUo68Z.js";
4
- import { t as Manager } from "./Manager-CG5CQ1kY.js";
5
- import "./camera-D7zu0Mls.js";
6
- import { t as ActorRefFrom } from "./Actor-B6Lr-x6S.js";
7
- import { t as AnyStateMachine } from "./StateMachine-WHeQE3lC.js";
8
- import "./types-DnrAr9fb.js";
9
- import { r as FlowModuleConfig } from "./types-Bn54lmeM.js";
10
-
11
- //#region src/modules/authentication/authenticationStateMachine.d.ts
12
- declare const _authenticationMachine: AnyStateMachine;
13
- type AuthenticationMachine = typeof _authenticationMachine;
14
- declare const authenticationMachine: AnyStateMachine;
15
- //#endregion
16
- //#region src/modules/authentication/types.d.ts
17
- type AuthenticationConfig = FlowModuleConfig['AUTHENTICATION'] & BaseFaceCaptureConfig;
18
- //#endregion
19
- //#region src/modules/authentication/authenticationActor.d.ts
20
- type CreateAuthenticationActorOptions = {
21
- config: AuthenticationConfig;
22
- dependencies?: FaceCaptureDependencies;
23
- authHint?: string;
24
- };
25
- type AuthenticationActor = ActorRefFrom<AuthenticationMachine>;
26
- declare function createAuthenticationActor(options: CreateAuthenticationActorOptions): AuthenticationActor;
27
- //#endregion
28
- //#region src/modules/authentication/authenticationManager.d.ts
29
- type AuthenticationState = FaceCaptureManagerState;
30
- /**
31
- * Creates an authentication manager instance for handling face authentication flow.
32
- *
33
- * The authentication manager provides:
34
- * - State management with statuses: `idle`, `loading`, `tutorial`, `permissions`, `capture`, `finished`, `closed`, `error`
35
- * - Permission handling with nested states: `idle`, `requesting`, `denied`, `learnMore`
36
- * - Capture handling with nested states: `initializing`, `startingRecorder`, `recordingActive`, `detecting`, `capturing`, `uploading`, `uploadError`, `success`
37
- * - Camera stream access when in `capture` state
38
- * - Detection status feedback during face detection
39
- * - Attempt tracking with `attemptsRemaining`
40
- *
41
- * @param options - Configuration for the authentication actor
42
- * @param options.config - The authentication module configuration from the flow
43
- * @param options.authHint - Hint for identifying the user (e.g., phone number, email)
44
- * @returns A manager instance with state subscription, API methods, and lifecycle controls
45
- *
46
- * @example
47
- * ```ts
48
- * const authManager = createAuthenticationManager({
49
- * config: authConfig,
50
- * authHint: 'user@example.com'
51
- * });
52
- *
53
- * authManager.subscribe((state) => {
54
- * if (state.status === 'capture') {
55
- * console.log('Camera ready:', state.stream);
56
- * console.log('Detection status:', state.detectionStatus);
57
- * }
58
- * if (state.status === 'finished') {
59
- * console.log('Authentication successful!');
60
- * }
61
- * });
62
- *
63
- * authManager.load();
64
- * ```
65
- */
66
- declare function createAuthenticationManager(options: CreateAuthenticationActorOptions): Manager<FaceCaptureManagerState> & {
67
- load(): void;
68
- nextStep(): void;
69
- requestPermission(): void;
70
- goToLearnMore(): void;
71
- back(): void;
72
- close(): void;
73
- reset(): void;
74
- retryCapture(): void;
75
- capture(): void;
76
- };
77
- type AuthenticationManager = FaceCaptureManager;
78
- //#endregion
1
+ import "./deepsightService-UhtHJCFb.js";
2
+ import { g as AuthenticationConfig, h as createAuthenticationActor, m as CreateAuthenticationActorOptions, p as AuthenticationActor, y as authenticationMachine } from "./faceCaptureManagerFactory-CiQWYHp2.js";
3
+ import "./warmup-Bp_1oXoL.js";
4
+ import "./Manager-CXnC-tN_.js";
5
+ import "./camera-DDn9ILon.js";
6
+ import "./Actor-BAf9LRYf.js";
7
+ import "./StateMachine-DJpZF_HP.js";
8
+ import "./types-BugcSDaO.js";
9
+ import "./types-C9Jo2XOb.js";
10
+ import { n as AuthenticationState, r as createAuthenticationManager, t as AuthenticationManager } from "./authenticationManager-DQL9XsaI.js";
79
11
  export { type AuthenticationActor, type AuthenticationConfig, type AuthenticationManager, type AuthenticationState, type CreateAuthenticationActorOptions, authenticationMachine, createAuthenticationActor, createAuthenticationManager };
@@ -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-4aLwsDOv.esm.js";
3
+ import "./src-BmVrWkLJ.esm.js";
4
+ import "./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 "./stats-kLtQIgsA.esm.js";
10
+ import "./faceCaptureSetup-CF9TJlsc.esm.js";
11
+ import { i as authenticationMachine, r as createAuthenticationActor, t as createAuthenticationManager } from "./authenticationManager-4j4j8ac9.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,197 @@
1
+ import { d as addEvent, n as eventModuleNames } from "./events-3HzCcoEy.esm.js";
2
+ import { _ as BrowserStorageProvider, a as WasmUtilProvider } from "./src-BmVrWkLJ.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-Cw6kqXEh.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-CF9TJlsc.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 };
@@ -0,0 +1,66 @@
1
+ import { m as CreateAuthenticationActorOptions, n as FaceCaptureManagerState, p as AuthenticationActor, t as FaceCaptureManager } from "./faceCaptureManagerFactory-CiQWYHp2.js";
2
+ import { t as Manager } from "./Manager-CXnC-tN_.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 };
@@ -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-BmVrWkLJ.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-CXnC-tN_.js";
2
+ import "./camera-DDn9ILon.js";
3
+ import "./types-BugcSDaO.js";
4
+ import { r as FlowModuleConfig } from "./types-C9Jo2XOb.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-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/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-BmVrWkLJ.esm.js";
2
+ import { t as createDeepsightService } from "./deepsightService-BgqD33AH.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,6 +1,6 @@
1
- import { M as getDeviceInfo, O as requestCameraAccess, P as getUserAgent, T as IncodeCanvas, k as stopCameraStream, w as createHiddenVideoElement } from "./src-D3v6I2la.esm.js";
2
- import { t as api } from "./api-3fZO5bmj.esm.js";
3
- import { t as addDeviceStats } from "./stats-D76Thmqp.esm.js";
1
+ import { M as getDeviceInfo, O as requestCameraAccess, P as getUserAgent, T as IncodeCanvas, k as stopCameraStream, w as createHiddenVideoElement } from "./src-BmVrWkLJ.esm.js";
2
+ import { t as api } from "./api-C2uzxrpN.esm.js";
3
+ import { t as addDeviceStats } from "./stats-kLtQIgsA.esm.js";
4
4
 
5
5
  //#region src/internal/device/browserSimulation.ts
6
6
  const AUTOMATION_MARKERS = {