@incodetech/core 2.0.0-rc.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/package.json +3 -3
  2. package/dist/Actor-CI32dTbG.d.ts +0 -2
  3. package/dist/BaseWasmProvider-C_DLEI40.esm.js +0 -1118
  4. package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +0 -55
  5. package/dist/BrowserTimerProvider-DhNc_x02.esm.js +0 -22
  6. package/dist/ITimerCapability-C67ZRskg.esm.js +0 -7
  7. package/dist/IpifyProvider-D7jx52AL.esm.js +0 -139
  8. package/dist/Manager-C8PrhBOx.d.ts +0 -19
  9. package/dist/MotionSensorProvider-4v7xkqAp.esm.js +0 -254
  10. package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +0 -87
  11. package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
  12. package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
  13. package/dist/addressSearch-BpTbTWCa.esm.js +0 -430
  14. package/dist/ae-signature-DDDZmWXj.esm.js +0 -12
  15. package/dist/ae-signature.d.ts +0 -25
  16. package/dist/ae-signature.esm.js +0 -8
  17. package/dist/antifraud.d.ts +0 -57
  18. package/dist/antifraud.esm.js +0 -45
  19. package/dist/antifraudStateMachine-O0TMf6yc.esm.js +0 -39
  20. package/dist/api-CESGtpbH.esm.js +0 -53
  21. package/dist/authentication.d.ts +0 -12
  22. package/dist/authentication.esm.js +0 -25
  23. package/dist/authenticationManager-5M-fKzXx.esm.js +0 -67
  24. package/dist/authenticationManager-C83GNIhl.d.ts +0 -66
  25. package/dist/authenticationStateMachine-BMZqatiF.esm.js +0 -139
  26. package/dist/backCameraStream-DMdMeGk2.esm.js +0 -346
  27. package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
  28. package/dist/camera-DBSxa6ML.d.ts +0 -4
  29. package/dist/camera-PA2Ljri3.esm.js +0 -22
  30. package/dist/camera.d.ts +0 -15
  31. package/dist/camera.esm.js +0 -5
  32. package/dist/chunk-CRF6K_H_.esm.js +0 -49
  33. package/dist/consent.d.ts +0 -398
  34. package/dist/consent.esm.js +0 -79
  35. package/dist/consentStateMachine-CCT-B60O.esm.js +0 -151
  36. package/dist/cpf-PPz2Njto.esm.js +0 -38
  37. package/dist/cpf-ocr.d.ts +0 -204
  38. package/dist/cpf-ocr.esm.js +0 -177
  39. package/dist/cross-document-data-match.d.ts +0 -34
  40. package/dist/cross-document-data-match.esm.js +0 -71
  41. package/dist/curp-validation.d.ts +0 -188
  42. package/dist/curp-validation.esm.js +0 -110
  43. package/dist/curpValidationStateMachine-CitWLr2c.esm.js +0 -595
  44. package/dist/custom-fields.d.ts +0 -115
  45. package/dist/custom-fields.esm.js +0 -177
  46. package/dist/custom-watchlist.d.ts +0 -66
  47. package/dist/custom-watchlist.esm.js +0 -86
  48. package/dist/dateUtils-UoN5xswP.esm.js +0 -23
  49. package/dist/deepsightLoader-Cm4JIT_z.esm.js +0 -52
  50. package/dist/deepsightService-CEVxzehb.d.ts +0 -412
  51. package/dist/deepsightService-O74l4Y__.esm.js +0 -489
  52. package/dist/device.d.ts +0 -46
  53. package/dist/device.esm.js +0 -106
  54. package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
  55. package/dist/document-capture.d.ts +0 -906
  56. package/dist/document-capture.esm.js +0 -156
  57. package/dist/document-upload.d.ts +0 -331
  58. package/dist/document-upload.esm.js +0 -203
  59. package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +0 -394
  60. package/dist/dynamic-forms.d.ts +0 -178
  61. package/dist/dynamic-forms.esm.js +0 -323
  62. package/dist/ekyb.d.ts +0 -148
  63. package/dist/ekyb.esm.js +0 -127
  64. package/dist/ekybStateMachine-B59rQjgj.esm.js +0 -674
  65. package/dist/ekyc.d.ts +0 -164
  66. package/dist/ekyc.esm.js +0 -104
  67. package/dist/ekycStateMachine-oeO0Iekd.esm.js +0 -10626
  68. package/dist/electronic-signature.d.ts +0 -4
  69. package/dist/electronic-signature.esm.js +0 -7
  70. package/dist/electronicSignatureManager-D9OHzTpG.esm.js +0 -428
  71. package/dist/email.d.ts +0 -4
  72. package/dist/email.esm.js +0 -9
  73. package/dist/emailManager-DIfnS5g1.d.ts +0 -352
  74. package/dist/emailManager-wAV0LE-H.esm.js +0 -238
  75. package/dist/emailStateMachine-DOf4j58N.esm.js +0 -292
  76. package/dist/endpoints-CnN3SyDa.esm.js +0 -87
  77. package/dist/events-D6-e4vok.esm.js +0 -596
  78. package/dist/events.d.ts +0 -265
  79. package/dist/events.esm.js +0 -4
  80. package/dist/extensibility.d.ts +0 -122
  81. package/dist/extensibility.esm.js +0 -43
  82. package/dist/face-match.d.ts +0 -228
  83. package/dist/face-match.esm.js +0 -173
  84. package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +0 -290
  85. package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +0 -690
  86. package/dist/faceCaptureSetup-B3faSpYA.esm.js +0 -873
  87. package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +0 -127
  88. package/dist/flow-events.d.ts +0 -6
  89. package/dist/flow-events.esm.js +0 -0
  90. package/dist/flow.d.ts +0 -358
  91. package/dist/flow.esm.js +0 -825
  92. package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
  93. package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
  94. package/dist/flowServices-DTsm-Vf1.esm.js +0 -188
  95. package/dist/geolocation.d.ts +0 -127
  96. package/dist/geolocation.esm.js +0 -89
  97. package/dist/geolocationStateMachine-asasuHY2.esm.js +0 -105
  98. package/dist/getBrowser-BSXUTWXw.esm.js +0 -41
  99. package/dist/getDeviceClass-BSntT9_j.esm.js +0 -14
  100. package/dist/government-validation.d.ts +0 -67
  101. package/dist/government-validation.esm.js +0 -81
  102. package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +0 -271
  103. package/dist/home.d.ts +0 -99
  104. package/dist/home.esm.js +0 -61
  105. package/dist/http.d.ts +0 -68
  106. package/dist/http.esm.js +0 -3
  107. package/dist/id-ocr.d.ts +0 -635
  108. package/dist/id-ocr.esm.js +0 -86
  109. package/dist/id-verification.d.ts +0 -190
  110. package/dist/id-verification.esm.js +0 -43
  111. package/dist/id.d.ts +0 -24
  112. package/dist/id.esm.js +0 -164
  113. package/dist/idCaptureManager-B9TGA5dq.d.ts +0 -956
  114. package/dist/idCaptureManager-DMK0GIt3.esm.js +0 -581
  115. package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +0 -2954
  116. package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +0 -388
  117. package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +0 -71
  118. package/dist/identity-reuse.d.ts +0 -530
  119. package/dist/identity-reuse.esm.js +0 -274
  120. package/dist/index-BLKtMA0g.d.ts +0 -1177
  121. package/dist/index-BcRG8rtJ.d.ts +0 -97
  122. package/dist/index.d.ts +0 -3
  123. package/dist/index.esm.js +0 -12
  124. package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +0 -30
  125. package/dist/lib-BB0B_qQX.esm.js +0 -12499
  126. package/dist/mandatory-consent.d.ts +0 -412
  127. package/dist/mandatory-consent.esm.js +0 -78
  128. package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +0 -126
  129. package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
  130. package/dist/openviduLazy-Cok70ZSg.esm.js +0 -12
  131. package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
  132. package/dist/phone.d.ts +0 -4
  133. package/dist/phone.esm.js +0 -9
  134. package/dist/phoneManager-B6M30hKE.d.ts +0 -397
  135. package/dist/phoneManager-DAJbGhlY.esm.js +0 -256
  136. package/dist/phoneStateMachine-CuPARRaT.esm.js +0 -351
  137. package/dist/platform-CfrjKhmi.esm.js +0 -83
  138. package/dist/qe-signature-DFo_Cc-I.esm.js +0 -12
  139. package/dist/qe-signature.d.ts +0 -25
  140. package/dist/qe-signature.esm.js +0 -8
  141. package/dist/recordingService-Ig2UgbLv.esm.js +0 -1003
  142. package/dist/redirect-to-mobile.d.ts +0 -107
  143. package/dist/redirect-to-mobile.esm.js +0 -102
  144. package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +0 -249
  145. package/dist/runChildModule-CqqwqAkW.esm.js +0 -219
  146. package/dist/selfie.d.ts +0 -26
  147. package/dist/selfie.esm.js +0 -146
  148. package/dist/selfieManager-D0lSgd-J.d.ts +0 -68
  149. package/dist/selfieManager-Duisl7qN.esm.js +0 -60
  150. package/dist/selfieStateMachine-D76whWEf.esm.js +0 -68
  151. package/dist/session-BS-d_vuE.esm.js +0 -3206
  152. package/dist/session.d.ts +0 -217
  153. package/dist/session.esm.js +0 -9
  154. package/dist/setup-Buy-hyj4.esm.js +0 -887
  155. package/dist/setup-C5AITV8m.d.ts +0 -254
  156. package/dist/signature.d.ts +0 -94
  157. package/dist/signature.esm.js +0 -66
  158. package/dist/signatureStateMachine-B5-QVUve.esm.js +0 -132
  159. package/dist/stats-CIfiPzb1.esm.js +0 -16
  160. package/dist/stats.d.ts +0 -16
  161. package/dist/stats.esm.js +0 -4
  162. package/dist/trust-graph.d.ts +0 -54
  163. package/dist/trust-graph.esm.js +0 -56
  164. package/dist/types-B06Ypu2F.d.ts +0 -49
  165. package/dist/types-BP1m8VRw.d.ts +0 -340
  166. package/dist/types-CAD4va6a.d.ts +0 -5
  167. package/dist/types-CFV9G_7j.d.ts +0 -24
  168. package/dist/warmup-CEcppFiS.d.ts +0 -63
  169. package/dist/wasm.d.ts +0 -15
  170. package/dist/wasm.esm.js +0 -12
  171. package/dist/watchlist-for-business.d.ts +0 -79
  172. package/dist/watchlist-for-business.esm.js +0 -148
  173. package/dist/watchlist.d.ts +0 -62
  174. package/dist/watchlist.esm.js +0 -86
  175. package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
  176. package/dist/workflow.d.ts +0 -907
  177. package/dist/workflow.esm.js +0 -702
  178. package/dist/xstate.esm-B70JrNqo.esm.js +0 -3404
@@ -1,173 +0,0 @@
1
- import "./api-CESGtpbH.esm.js";
2
- import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
3
- import "./endpoints-CnN3SyDa.esm.js";
4
- import { c as createManager, s as createActor } from "./xstate.esm-B70JrNqo.esm.js";
5
- import { t as faceMatchMachine } from "./faceMatchStateMachine-DNFrxTFS.esm.js";
6
-
7
- //#region src/modules/face-match/faceMatchActor.ts
8
- function createFaceMatchActor(options) {
9
- return createActor(faceMatchMachine, { input: { config: options.config } }).start();
10
- }
11
-
12
- //#endregion
13
- //#region src/modules/face-match/faceMatchManager.ts
14
- /**
15
- * @module @incodetech/core/face-match
16
- *
17
- * Face match module for the Incode Web SDK.
18
- * Supports both headless (programmatic) and UI-driven usage patterns.
19
- *
20
- * ## Headless Usage
21
- *
22
- * The face match manager can be used entirely without UI for backend integrations,
23
- * custom UI implementations, or automated workflows.
24
- *
25
- * @example Basic headless face match with auto-skip
26
- * ```typescript
27
- * import { createFaceMatchManager } from '@incodetech/core/face-match';
28
- * import { setup } from '@incodetech/core';
29
- *
30
- * // 1. Configure the SDK (required before using any module)
31
- * setup({ apiURL: 'https://api.example.com', token: 'your-token' });
32
- *
33
- * // 2. Create the face match manager
34
- * const faceMatchManager = createFaceMatchManager({
35
- * config: {
36
- * matchingType: 'selfieVsId',
37
- * disableFaceMatchAnimation: true,
38
- * },
39
- * });
40
- *
41
- * // 3. Subscribe to state changes (optional but recommended)
42
- * faceMatchManager.subscribe((state) => {
43
- * console.log('Face match state:', state.status);
44
- * if (state.status === 'finished') {
45
- * console.log('Face match complete!', state.matched);
46
- * }
47
- * if (state.status === 'error') {
48
- * console.error('Error:', state.error);
49
- * }
50
- * });
51
- *
52
- * // 4. Start the flow
53
- * faceMatchManager.load();
54
- *
55
- * // 5. Auto-completes when disableFaceMatchAnimation is true
56
- * // Or call faceMatchManager.continue() after animation in custom UI
57
- *
58
- * // 6. Clean up when done
59
- * faceMatchManager.stop();
60
- * ```
61
- *
62
- * @example Headless face match with custom UI
63
- * ```typescript
64
- * const faceMatchManager = createFaceMatchManager({
65
- * config: { matchingType: 'selfieVsId', disableFaceMatchAnimation: false },
66
- * });
67
- *
68
- * faceMatchManager.subscribe((state) => {
69
- * if (state.status === 'animating') {
70
- * // Render your custom animation
71
- * renderAnimation(state.images, state.result);
72
- * }
73
- * if (state.status === 'result') {
74
- * // Show result and wait for user to click continue
75
- * showResult(state.matched);
76
- * }
77
- * });
78
- *
79
- * faceMatchManager.load();
80
- * // When animation completes in your UI:
81
- * faceMatchManager.animationComplete();
82
- * // When user clicks continue:
83
- * faceMatchManager.continue();
84
- * ```
85
- */
86
- function mapState(snapshot) {
87
- const typedSnapshot = snapshot;
88
- const { context } = typedSnapshot;
89
- if (typedSnapshot.matches("idle")) return { status: "idle" };
90
- if (typedSnapshot.matches("loading")) return { status: "loading" };
91
- if (typedSnapshot.matches("animating")) return {
92
- status: "animating",
93
- images: context.images,
94
- result: context.result
95
- };
96
- if (typedSnapshot.matches("result")) return {
97
- status: "result",
98
- images: context.images,
99
- result: context.result,
100
- matched: context.result.matched
101
- };
102
- if (typedSnapshot.matches("finished")) return {
103
- status: "finished",
104
- matched: context.result?.matched ?? null
105
- };
106
- if (typedSnapshot.matches("error")) return {
107
- status: "error",
108
- error: context.error ?? "An error occurred"
109
- };
110
- return { status: "idle" };
111
- }
112
- function createApi({ actor, trackElementClicked }) {
113
- return {
114
- load() {
115
- actor.send({ type: "LOAD" });
116
- },
117
- animationComplete() {
118
- actor.send({ type: "ANIMATION_COMPLETE" });
119
- },
120
- continue() {
121
- trackElementClicked?.("continue");
122
- actor.send({ type: "CONTINUE" });
123
- },
124
- reset() {
125
- actor.send({ type: "RESET" });
126
- }
127
- };
128
- }
129
- /**
130
- * Creates a face match manager for headless or UI-driven usage.
131
- *
132
- * The manager provides a state machine-based API for face comparison
133
- * with optional animation display.
134
- *
135
- * @param options - Configuration options
136
- * @param options.config - Face match configuration
137
- * @param options.config.matchingType - Which images to compare (default: 'selfieVsId')
138
- * @param options.config.disableFaceMatchAnimation - Skip animation and auto-complete (default: false)
139
- *
140
- * @returns Face match manager with state, API methods, and subscription
141
- *
142
- * @example Headless usage
143
- * ```typescript
144
- * const manager = createFaceMatchManager({
145
- * config: { matchingType: 'selfieVsId', disableFaceMatchAnimation: true },
146
- * });
147
- *
148
- * manager.subscribe((state) => console.log(state.status));
149
- * manager.load();
150
- * // Auto-completes when disableFaceMatchAnimation is true
151
- * manager.stop();
152
- * ```
153
- *
154
- * @example With React/Preact UI hook
155
- * ```tsx
156
- * const [state, manager] = useManager(() => createFaceMatchManager({ config }));
157
- *
158
- * if (state.status === 'animating') {
159
- * return <Animation images={state.images} />;
160
- * }
161
- * ```
162
- */
163
- function createFaceMatchManager(options) {
164
- return createManager({
165
- actor: createFaceMatchActor(options),
166
- mapState,
167
- createApi,
168
- instrumentation: createManagerInstrumentation(eventModuleNames.faceMatch)
169
- });
170
- }
171
-
172
- //#endregion
173
- export { createFaceMatchManager, faceMatchMachine };
@@ -1,290 +0,0 @@
1
- import { n as eventModuleNames, o as createManagerInstrumentation, r as eventScreenNames } from "./events-D6-e4vok.esm.js";
2
- import { c as createManager } from "./xstate.esm-B70JrNqo.esm.js";
3
-
4
- //#region src/internal/faceCapture/faceCaptureManagerFactory.ts
5
- function getPermissionStatus(snapshot) {
6
- if (!snapshot.matches("permissions")) return;
7
- if (snapshot.matches({ permissions: "idle" })) return "idle";
8
- if (snapshot.matches({ permissions: "learnMore" })) return "learnMore";
9
- if (snapshot.matches({ permissions: "requesting" })) return "requesting";
10
- if (snapshot.matches({ permissions: "denied" })) return "denied";
11
- }
12
- function getCaptureStatus(snapshot) {
13
- if (snapshot.matches({ capture: "initializing" })) return "initializing";
14
- if (snapshot.matches({ capture: "detecting" })) return "detecting";
15
- if (snapshot.matches({ capture: "capturing" })) return "capturing";
16
- if (snapshot.matches({ capture: "capturingManual" })) return "capturing";
17
- if (snapshot.matches({ capture: "preparingUpload" })) return "uploading";
18
- if (snapshot.matches({ capture: "uploading" })) return "uploading";
19
- if (snapshot.matches({ capture: "validatingUpload" })) return "uploading";
20
- if (snapshot.matches({ capture: "uploadError" })) return "uploadError";
21
- if (snapshot.matches({ capture: "success" })) return "success";
22
- }
23
- function mapState(snapshot) {
24
- const { context } = snapshot;
25
- if (snapshot.matches("idle")) return { status: "idle" };
26
- if (snapshot.matches("loading")) return { status: "loading" };
27
- if (snapshot.matches("tutorial")) return {
28
- status: "tutorial",
29
- ageAssurance: context.config?.ageAssurance === true
30
- };
31
- if (snapshot.matches("closed")) return { status: "closed" };
32
- if (snapshot.matches("permissions")) {
33
- const permissionStatus = getPermissionStatus(snapshot);
34
- if (permissionStatus === void 0) return {
35
- status: "permissions",
36
- permissionStatus: "idle"
37
- };
38
- return {
39
- status: "permissions",
40
- permissionStatus
41
- };
42
- }
43
- if (snapshot.matches("capture")) return {
44
- status: "capture",
45
- captureStatus: getCaptureStatus(snapshot) ?? "initializing",
46
- stream: context.stream,
47
- detectionStatus: context.detectionStatus ?? "idle",
48
- debugFrame: context.debugFrame,
49
- attemptsRemaining: context.attemptsRemaining ?? 0,
50
- uploadError: context.uploadError,
51
- assistedOnboarding: context.config?.assistedOnboarding ?? false,
52
- ageAssurance: context.config?.ageAssurance === true
53
- };
54
- if (snapshot.matches("processing")) return { status: "processing" };
55
- if (snapshot.matches("finished")) return {
56
- status: "finished",
57
- processResponse: context.processResponse
58
- };
59
- if (snapshot.matches("error")) {
60
- const errorValue = context.error;
61
- return {
62
- status: "error",
63
- error: typeof errorValue === "string" ? errorValue : errorValue ? errorValue.message : "Unknown error"
64
- };
65
- }
66
- return { status: "idle" };
67
- }
68
- function getFaceCaptureTutorialScreen(snapshot) {
69
- if (snapshot.context?.config?.ageAssurance === true) return "faceCapture.tutorial.ageAssurance";
70
- if (typeof snapshot.value === "object" && snapshot.value !== null) {
71
- const tutorialValue = snapshot.value.tutorial;
72
- if (typeof tutorialValue === "object" && tutorialValue !== null && "initializingCamera" in tutorialValue) return "faceCapture.tutorial.loading";
73
- }
74
- return "faceCapture.tutorial.default";
75
- }
76
- function getCapturingScreen(detectionStatus) {
77
- switch (detectionStatus) {
78
- case "getReady":
79
- case "getReadyFinished": return "faceCapture.capturing.getReady";
80
- case "dark": return "faceCapture.capturing.tooDark";
81
- case "tooBright": return "faceCapture.capturing.tooBright";
82
- case "tooClose": return "faceCapture.capturing.moveAway";
83
- case "tooFar": return "faceCapture.capturing.moveCloser";
84
- case "moveLeft": return "faceCapture.capturing.moveLeft";
85
- case "moveRight": return "faceCapture.capturing.moveRight";
86
- case "blur":
87
- case "centerFace":
88
- case "noFace":
89
- case "tooManyFaces": return "faceCapture.capturing.alignFace";
90
- case "faceAngle":
91
- case "lookAtCamera": return "faceCapture.capturing.lookAtCamera";
92
- case "eyesClosed": return "faceCapture.capturing.eyesClosed";
93
- case "faceMask": return "faceCapture.capturing.maskDetected";
94
- case "lenses": return "faceCapture.capturing.glassesDetected";
95
- case "headWear": return "faceCapture.capturing.hatDetected";
96
- case "faceOcclusion": return "faceCapture.capturing.faceOcclusion";
97
- case "manualCapture": return "faceCapture.manualCapture.default";
98
- case "capturing": return "faceCapture.loading.processing";
99
- case "detecting":
100
- case "idle":
101
- case "offline": return "faceCapture.genericErrors.noConnection";
102
- case "success":
103
- case "error":
104
- default: return "faceCapture.capturing.initiatingState";
105
- }
106
- }
107
- function getResultErrorScreen(errorCode, attemptsRemaining) {
108
- const exhaustedSuffix = attemptsRemaining === 0 ? "Exhausted" : "";
109
- switch (errorCode) {
110
- case "LENSES_ERROR":
111
- case "LENSES_DETECTED": return `faceCapture.resultError.lensesDetected${exhaustedSuffix}`;
112
- case "BRIGHTNESS_ERROR": return `faceCapture.resultError.tooBright${exhaustedSuffix}`;
113
- case "MASK_ERROR":
114
- case "FACE_MASK_DETECTED": return `faceCapture.resultError.faceMaskDetected${exhaustedSuffix}`;
115
- case "FACE_TOO_DARK":
116
- case "TOO_DARK_ERROR": return `faceCapture.resultError.tooDark${exhaustedSuffix}`;
117
- case "CLOSED_EYES_ERROR":
118
- case "CLOSED_EYES_DETECTED": return `faceCapture.resultError.eyesClosed${exhaustedSuffix}`;
119
- case "HEAD_COVER_ERROR":
120
- case "HEAD_COVER_DETECTED": return `faceCapture.resultError.headCovered${exhaustedSuffix}`;
121
- case "FACE_OCCLUDED": return `faceCapture.resultError.faceOcclusion${exhaustedSuffix}`;
122
- case "TOO_BLURRY_ERROR":
123
- case "FACE_TOO_BLURRY":
124
- case "BAD_PHOTO_QUALITY":
125
- case "SELFIE_IMAGE_LOW_QUALITY": return `faceCapture.resultError.lowQuality${exhaustedSuffix}`;
126
- case "SERVER_ERROR":
127
- case "PROCESSING_ERROR":
128
- case "BAD_REQUEST": return `faceCapture.resultError.processingFailed${exhaustedSuffix}`;
129
- case "FACE_NOT_FOUND":
130
- case "MULTIPLE_FACES":
131
- case "FACE_CROPPING_FAILED":
132
- case "FACE_TOO_SMALL":
133
- case "LIVENESS_ERROR":
134
- default: return `faceCapture.resultError.faceNotAligned${exhaustedSuffix}`;
135
- }
136
- }
137
- function getCaptureSubstateScreen(snapshot) {
138
- const { value, context } = snapshot;
139
- if (typeof value !== "object" || value === null) return void 0;
140
- const captureValue = value.capture;
141
- if (captureValue === void 0) return void 0;
142
- if (typeof captureValue === "string") switch (captureValue) {
143
- case "checkingDeepsight":
144
- case "initializingDeepsight":
145
- case "checkingStream":
146
- case "initializing": return "faceCapture.capturing.initiatingState";
147
- case "detecting": return getCapturingScreen(context?.detectionStatus);
148
- case "capturing": return "faceCapture.loading.processing";
149
- case "capturingManual": return "faceCapture.manualCapture.default";
150
- case "preparingUpload":
151
- case "uploading":
152
- case "validatingUpload": return "faceCapture.loading.uploading";
153
- case "uploadError": return getResultErrorScreen(context?.uploadError, context?.attemptsRemaining);
154
- case "success": return "faceCapture.resultSuccess.default";
155
- }
156
- if (typeof captureValue === "object" && captureValue !== null) {
157
- const substates = Object.keys(captureValue);
158
- if (substates.includes("uploading")) return "faceCapture.loading.uploading";
159
- if (substates.includes("uploadError")) return getResultErrorScreen(context?.uploadError, context?.attemptsRemaining);
160
- if (substates.includes("success")) return "faceCapture.resultSuccess.default";
161
- }
162
- return "faceCapture.capturing.initiatingState";
163
- }
164
- function getAuthFaceCaptureSubstateScreen(snapshot) {
165
- const { value } = snapshot;
166
- if (typeof value !== "object" || value === null) return void 0;
167
- const captureValue = value.capture;
168
- if (captureValue === void 0) return void 0;
169
- if (typeof captureValue === "string") switch (captureValue) {
170
- case "preparingUpload":
171
- case "uploading":
172
- case "validatingUpload": return eventScreenNames.authFaceUpload;
173
- case "uploadError": return eventScreenNames.authFaceError;
174
- case "success": return eventScreenNames.authFaceUploadSuccess;
175
- case "checkingDeepsight":
176
- case "initializingDeepsight":
177
- case "checkingStream":
178
- case "initializing":
179
- case "detecting":
180
- case "capturing":
181
- case "capturingManual": return eventScreenNames.authFace;
182
- }
183
- if (typeof captureValue === "object" && captureValue !== null) {
184
- const substates = Object.keys(captureValue);
185
- if (substates.includes("uploading") || substates.includes("validatingUpload")) return eventScreenNames.authFaceUpload;
186
- if (substates.includes("uploadError")) return eventScreenNames.authFaceError;
187
- if (substates.includes("success")) return eventScreenNames.authFaceUploadSuccess;
188
- }
189
- return eventScreenNames.authFace;
190
- }
191
- function getTopLevelState(value) {
192
- if (typeof value === "string") return value;
193
- if (typeof value === "object") return Object.keys(value)[0];
194
- }
195
- function getAuthFaceScreenName(snapshot) {
196
- const { value } = snapshot;
197
- if (value === void 0 || value === null) return void 0;
198
- const topLevel = getTopLevelState(value);
199
- if (topLevel === void 0) return void 0;
200
- switch (topLevel) {
201
- case "tutorial": return eventScreenNames.authFaceTutorial;
202
- case "capture": return getAuthFaceCaptureSubstateScreen(snapshot);
203
- case "finished": return eventScreenNames.authFaceUploadSuccess;
204
- case "error": return eventScreenNames.authFaceUploadFailed;
205
- case "idle":
206
- case "loading":
207
- case "permissions":
208
- case "processing":
209
- case "closed":
210
- default: return eventScreenNames.authFace;
211
- }
212
- }
213
- function getFaceCaptureScreenName(snapshot, moduleName) {
214
- if (moduleName === eventModuleNames.authFace || moduleName === eventModuleNames.authentication) return getAuthFaceScreenName(snapshot);
215
- const { value } = snapshot;
216
- if (value === void 0 || value === null) return void 0;
217
- const topLevel = getTopLevelState(value);
218
- if (topLevel === void 0) return void 0;
219
- switch (topLevel) {
220
- case "idle": return "faceCapture.loading.processing";
221
- case "loading": return "faceCapture.loading.processing";
222
- case "tutorial": return getFaceCaptureTutorialScreen(snapshot);
223
- case "permissions": return "faceCapture.tutorial.default";
224
- case "capture": return getCaptureSubstateScreen(snapshot);
225
- case "processing": return "faceCapture.loading.processing";
226
- case "finished": return "faceCapture.resultSuccess.default";
227
- case "closed": return "faceCapture.closed";
228
- case "error": return "faceCapture.resultError.processingFailed";
229
- default: return `faceCapture.${topLevel}`;
230
- }
231
- }
232
- function createApi({ actor, trackElementClicked, trackCaptureAttemptFinished }) {
233
- const snapshot = actor.getSnapshot();
234
- snapshot.context.dependencies.trackCaptureAttemptFinished = trackCaptureAttemptFinished;
235
- return {
236
- load() {
237
- actor.send({ type: "LOAD" });
238
- },
239
- nextStep() {
240
- trackElementClicked?.("nextStep");
241
- actor.send({ type: "NEXT_STEP" });
242
- },
243
- requestPermission() {
244
- trackElementClicked?.("requestPermission");
245
- actor.send({ type: "REQUEST_PERMISSION" });
246
- },
247
- goToLearnMore() {
248
- trackElementClicked?.("goToLearnMore");
249
- actor.send({ type: "GO_TO_LEARN_MORE" });
250
- },
251
- back() {
252
- trackElementClicked?.("back");
253
- actor.send({ type: "BACK" });
254
- },
255
- close() {
256
- trackElementClicked?.("close");
257
- actor.send({ type: "QUIT" });
258
- },
259
- reset() {
260
- actor.send({ type: "RESET" });
261
- },
262
- retryCapture() {
263
- trackElementClicked?.("retryCapture");
264
- actor.send({ type: "RETRY_CAPTURE" });
265
- },
266
- capture() {
267
- trackElementClicked?.("capture");
268
- actor.send({ type: "MANUAL_CAPTURE" });
269
- }
270
- };
271
- }
272
- function getFaceCaptureErrorPayload(snapshot) {
273
- const errorCode = snapshot.context.uploadError;
274
- if (typeof errorCode !== "string" || errorCode.length === 0) return;
275
- return { errorCode };
276
- }
277
- function createFaceCaptureManagerFromActor(actor, moduleName) {
278
- return createManager({
279
- actor,
280
- mapState,
281
- createApi,
282
- instrumentation: createManagerInstrumentation(moduleName, {
283
- getEventScreenName: (snapshot) => getFaceCaptureScreenName(snapshot, moduleName),
284
- getErrorPayload: getFaceCaptureErrorPayload
285
- })
286
- });
287
- }
288
-
289
- //#endregion
290
- export { createFaceCaptureManagerFromActor as t };