@incodetech/core 0.0.0-dev-20260409-a38d5e8 → 0.0.0-dev-20260409-089e5c6

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 (137) hide show
  1. package/dist/BrowserStorageProvider-ByxoNfxC.esm.js +55 -0
  2. package/dist/{OpenViduRecordingProvider-Bn2meybK.esm.js → OpenViduRecordingProvider-JatjSE3h.esm.js} +1 -1
  3. package/dist/{WasmUtilProvider-BpZSvZbg.esm.js → WasmUtilProvider-DRh0wrlm.esm.js} +1 -1
  4. package/dist/{addressSearch-DOFI7lwy.esm.js → addressSearch-CDdN30un.esm.js} +4 -4
  5. package/dist/antifraud.d.ts +1 -1
  6. package/dist/antifraud.esm.js +4 -37
  7. package/dist/antifraudStateMachine-C1AgS0nL.esm.js +39 -0
  8. package/dist/authentication.d.ts +11 -11
  9. package/dist/authentication.esm.js +22 -19
  10. package/dist/{authenticationManager-C2mk36yK.d.ts → authenticationManager-DYFYx68i.d.ts} +2 -2
  11. package/dist/authenticationManager-UaO9UTN7.esm.js +67 -0
  12. package/dist/{authenticationManager-C7dL_avf.esm.js → authenticationStateMachine-DWI65EwK.esm.js} +7 -67
  13. package/dist/{backCameraStream-tabTmwDS.esm.js → backCameraStream-BihRmMzc.esm.js} +3 -3
  14. package/dist/camera.d.ts +1 -1
  15. package/dist/camera.esm.js +3 -3
  16. package/dist/consent.d.ts +57 -57
  17. package/dist/consent.esm.js +4 -149
  18. package/dist/consentStateMachine-CpRu2hF0.esm.js +151 -0
  19. package/dist/cross-document-data-match.d.ts +1 -1
  20. package/dist/cross-document-data-match.esm.js +4 -4
  21. package/dist/curp-validation.d.ts +5 -5
  22. package/dist/curp-validation.esm.js +4 -417
  23. package/dist/curpValidationStateMachine-Czzgv2W1.esm.js +419 -0
  24. package/dist/{deepsightLoader-Cj6SyUQ-.esm.js → deepsightLoader-jIgoauFK.esm.js} +10 -10
  25. package/dist/{deepsightService-BjgXl5hs.esm.js → deepsightService-D4mM8yJ2.esm.js} +5 -5
  26. package/dist/{deepsightService-ByD6uIs7.d.ts → deepsightService-DAeakjDd.d.ts} +2 -2
  27. package/dist/device.esm.js +3 -3
  28. package/dist/document-capture.d.ts +75 -73
  29. package/dist/document-capture.esm.js +8 -403
  30. package/dist/document-upload.d.ts +50 -50
  31. package/dist/document-upload.esm.js +7 -7
  32. package/dist/documentCaptureStateMachine-XbpsHzh5.esm.js +403 -0
  33. package/dist/ekyb.d.ts +3 -3
  34. package/dist/ekyb.esm.js +10 -655
  35. package/dist/ekybStateMachine-BDuCae6s.esm.js +653 -0
  36. package/dist/ekyc.d.ts +3 -3
  37. package/dist/ekyc.esm.js +6 -10614
  38. package/dist/ekycStateMachine-BN4KBDYY.esm.js +10615 -0
  39. package/dist/email.d.ts +3 -3
  40. package/dist/email.esm.js +6 -5
  41. package/dist/emailManager-CAeo59lD.esm.js +238 -0
  42. package/dist/{emailManager-CU_hzrsl.d.ts → emailManager-CZYfcu0n.d.ts} +4 -3
  43. package/dist/{emailManager-_9R4vm6g.esm.js → emailStateMachine-Bqwe_sQS.esm.js} +6 -239
  44. package/dist/{events-DlHrOIRc.esm.js → events-CZ2ka3pu.esm.js} +8 -1
  45. package/dist/events.d.ts +1 -0
  46. package/dist/events.esm.js +2 -2
  47. package/dist/extensibility.d.ts +15 -15
  48. package/dist/extensibility.esm.js +33 -26
  49. package/dist/face-match.d.ts +7 -6
  50. package/dist/face-match.esm.js +8 -129
  51. package/dist/faceCaptureManagerFactory-D8zlMTvd.esm.js +117 -0
  52. package/dist/{faceCaptureManagerFactory-Da_-ohdg.d.ts → faceCaptureManagerFactory-DS-6yCya.d.ts} +8 -8
  53. package/dist/{faceCaptureSetup-CaVWkjvE.esm.js → faceCaptureSetup-1M6uUEjK.esm.js} +5 -119
  54. package/dist/faceMatchStateMachine-D3DuP_ya.esm.js +127 -0
  55. package/dist/flow.d.ts +8 -13
  56. package/dist/flow.esm.js +10 -29
  57. package/dist/{flowCompletionService-B5JemmC6.esm.js → flowCompletionService-W6bj7Xd3.esm.js} +2 -2
  58. package/dist/{flowServices-p22wrYPf.esm.js → flowServices-C4tjBD8q.esm.js} +3 -3
  59. package/dist/geolocation.d.ts +7 -6
  60. package/dist/geolocation.esm.js +7 -105
  61. package/dist/geolocationStateMachine-Bj2LkGwy.esm.js +105 -0
  62. package/dist/{getDeviceClass-DEzz4cmY.esm.js → getDeviceClass-BoiWvKAc.esm.js} +1 -1
  63. package/dist/government-validation.d.ts +2 -2
  64. package/dist/government-validation.esm.js +5 -269
  65. package/dist/governmentValidationStateMachine-W1CzRjVw.esm.js +271 -0
  66. package/dist/http.esm.js +1 -1
  67. package/dist/id.d.ts +10 -10
  68. package/dist/id.esm.js +22 -20
  69. package/dist/idCaptureManager-BcS8fgW4.esm.js +335 -0
  70. package/dist/{idCaptureManager-CV08v1e3.d.ts → idCaptureManager-oR6YPYHj.d.ts} +7 -7
  71. package/dist/{idCaptureManager-dyZzKv8L.esm.js → idCaptureStateMachine-MAzfM_2O.esm.js} +17 -346
  72. package/dist/identity-reuse.d.ts +530 -0
  73. package/dist/identity-reuse.esm.js +273 -0
  74. package/dist/index.d.ts +2 -2
  75. package/dist/index.esm.js +8 -8
  76. package/dist/{lib-Bavz2qmt.esm.js → lib-CxDxnzRd.esm.js} +1 -1
  77. package/dist/mandatory-consent.d.ts +55 -55
  78. package/dist/mandatory-consent.esm.js +4 -124
  79. package/dist/mandatoryConsentStateMachine-BMKi26Re.esm.js +126 -0
  80. package/dist/{openviduLazy-vhrVZCr_.esm.js → openviduLazy-B8tinh9W.esm.js} +2 -2
  81. package/dist/openviduLazy-CItjpMfL.esm.js +3 -0
  82. package/dist/{permissionServices-Cskq32Yd.esm.js → permissionServices-Cj120WaT.esm.js} +2 -2
  83. package/dist/phone.d.ts +3 -3
  84. package/dist/phone.esm.js +6 -5
  85. package/dist/phoneManager-Bvj6Jr4o.esm.js +258 -0
  86. package/dist/{phoneManager-ulJuGvJ8.d.ts → phoneManager-CCMCkyYr.d.ts} +2 -2
  87. package/dist/{phoneManager-DerdUfd4.esm.js → phoneStateMachine-B1t1Z-Dd.esm.js} +5 -258
  88. package/dist/{recordingService-483wQ6kR.esm.js → recordingService-8I_-hhNI.esm.js} +14 -68
  89. package/dist/redirect-to-mobile.d.ts +2 -2
  90. package/dist/redirect-to-mobile.esm.js +5 -247
  91. package/dist/redirectToMobileStateMachine-BVP1KcoO.esm.js +249 -0
  92. package/dist/runChildModule-B5DEiOS7.esm.js +27 -0
  93. package/dist/selfie.d.ts +11 -11
  94. package/dist/selfie.esm.js +22 -19
  95. package/dist/selfieManager-B6x3O5Ns.esm.js +60 -0
  96. package/dist/{selfieManager-DCRP7X75.d.ts → selfieManager-gizt3Zha.d.ts} +2 -2
  97. package/dist/selfieStateMachine-DHPSBFj0.esm.js +56 -0
  98. package/dist/{session-CUh77zj3.esm.js → session-DoI-X9FK.esm.js} +4 -4
  99. package/dist/session.d.ts +1 -1
  100. package/dist/session.esm.js +6 -6
  101. package/dist/{setup-XpxfZgKn.esm.js → setup-Bh2S53NT.esm.js} +6 -5
  102. package/dist/{setup-DpHakxsC.d.ts → setup-Bz3Ffaoc.d.ts} +1 -1
  103. package/dist/signature.d.ts +4 -3
  104. package/dist/signature.esm.js +6 -189
  105. package/dist/signatureStateMachine-Cv7yPuEf.esm.js +189 -0
  106. package/dist/{stats-DHDoqSBV.esm.js → stats-wkQyDFV3.esm.js} +1 -1
  107. package/dist/stats.esm.js +2 -2
  108. package/dist/types-BdEM5Jj7.d.ts +35 -0
  109. package/dist/{types-2OPf1pyv.d.ts → types-CdlQrTiZ.d.ts} +1 -1
  110. package/dist/{types-CVJVQ7fp.d.ts → types-m43DfiSx.d.ts} +1 -1
  111. package/dist/wasm.d.ts +2 -2
  112. package/dist/wasm.esm.js +8 -8
  113. package/dist/workflow.d.ts +813 -0
  114. package/dist/workflow.esm.js +600 -0
  115. package/package.json +11 -3
  116. package/dist/openviduLazy-BIPHozOu.esm.js +0 -3
  117. package/dist/selfieManager-DeOcNel4.esm.js +0 -110
  118. /package/dist/{Actor-Ba71-_30.d.ts → Actor-BkPcZGke.d.ts} +0 -0
  119. /package/dist/{BaseWasmProvider-D-s_6M5H.esm.js → BaseWasmProvider-C73c2nV9.esm.js} +0 -0
  120. /package/dist/{BrowserEnvironmentProvider-DaHeLJQw.esm.js → BrowserEnvironmentProvider-lxn4oxXn.esm.js} +0 -0
  121. /package/dist/{BrowserTimerProvider-BhD2MlHg.esm.js → BrowserTimerProvider-CSdm7__S.esm.js} +0 -0
  122. /package/dist/{ITimerCapability-oixwa6nj.esm.js → ITimerCapability-DAIaq369.esm.js} +0 -0
  123. /package/dist/{Manager-BN2g_I8W.d.ts → Manager-Bcnemkyi.d.ts} +0 -0
  124. /package/dist/{MotionSensorProvider-CodM3e0E.esm.js → MotionSensorProvider-BLnFo6My.esm.js} +0 -0
  125. /package/dist/{StateMachine-BoJsfMvg.d.ts → StateMachine-DIeoDJ7r.d.ts} +0 -0
  126. /package/dist/{api-DzpnV6O7.esm.js → api-CqKwkjJ3.esm.js} +0 -0
  127. /package/dist/{browserSimulation-B4ubb2OL.esm.js → browserSimulation-7W5-A3RV.esm.js} +0 -0
  128. /package/dist/{camera-DmkFpf5N.esm.js → camera-B-5traWf.esm.js} +0 -0
  129. /package/dist/{camera-1eeGnAaL.d.ts → camera-CgnuDuxy.d.ts} +0 -0
  130. /package/dist/{chunk-DsxENsBR.esm.js → chunk-Qw4qVmMx.esm.js} +0 -0
  131. /package/dist/{displayErrors-BZLX7idb.d.ts → displayErrors-C9-VaqmS.d.ts} +0 -0
  132. /package/dist/{flowCompletionService-D-3YCHyO.d.ts → flowCompletionService-CPLdZxe-.d.ts} +0 -0
  133. /package/dist/{getBrowser-Dtyt9J_h.esm.js → getBrowser-DJkbzQ5t.esm.js} +0 -0
  134. /package/dist/{platform-Dv7a2fv-.esm.js → platform-BfoqeM61.esm.js} +0 -0
  135. /package/dist/{types-D_QfFKxT.d.ts → types-CxU9jTRl.d.ts} +0 -0
  136. /package/dist/{warmup-CIj_wEV_.d.ts → warmup-Cs0uqxUW.d.ts} +0 -0
  137. /package/dist/{xstate.esm-Bv55-lJ4.esm.js → xstate.esm-D7D6CGwY.esm.js} +0 -0
@@ -0,0 +1,600 @@
1
+ import "./BaseWasmProvider-C73c2nV9.esm.js";
2
+ import { t as api } from "./api-CqKwkjJ3.esm.js";
3
+ import { _ as endpoints, o as createManagerInstrumentation } from "./events-CZ2ka3pu.esm.js";
4
+ import { n as getSessionFingerprintResult, r as initializeSession } from "./session-DoI-X9FK.esm.js";
5
+ import "./BrowserEnvironmentProvider-lxn4oxXn.esm.js";
6
+ import "./browserSimulation-7W5-A3RV.esm.js";
7
+ import { a as createActor, i as fromPromise, n as assign, o as createManager, t as setup } from "./xstate.esm-D7D6CGwY.esm.js";
8
+ import { t as antifraudMachine } from "./antifraudStateMachine-C1AgS0nL.esm.js";
9
+ import "./recordingService-8I_-hhNI.esm.js";
10
+ import "./deepsightService-D4mM8yJ2.esm.js";
11
+ import "./camera-B-5traWf.esm.js";
12
+ import "./getBrowser-DJkbzQ5t.esm.js";
13
+ import "./stats-wkQyDFV3.esm.js";
14
+ import "./MotionSensorProvider-BLnFo6My.esm.js";
15
+ import "./permissionServices-Cj120WaT.esm.js";
16
+ import "./platform-BfoqeM61.esm.js";
17
+ import "./ITimerCapability-DAIaq369.esm.js";
18
+ import "./backCameraStream-BihRmMzc.esm.js";
19
+ import "./getDeviceClass-BoiWvKAc.esm.js";
20
+ import "./faceCaptureSetup-1M6uUEjK.esm.js";
21
+ import { t as authenticationMachine } from "./authenticationStateMachine-DWI65EwK.esm.js";
22
+ import { t as consentMachine } from "./consentStateMachine-CpRu2hF0.esm.js";
23
+ import { t as curpValidationMachine } from "./curpValidationStateMachine-Czzgv2W1.esm.js";
24
+ import { t as documentCaptureMachine } from "./documentCaptureStateMachine-XbpsHzh5.esm.js";
25
+ import { t as ekybMachine } from "./ekybStateMachine-BDuCae6s.esm.js";
26
+ import "./addressSearch-CDdN30un.esm.js";
27
+ import "./flowServices-C4tjBD8q.esm.js";
28
+ import "./BrowserTimerProvider-CSdm7__S.esm.js";
29
+ import { t as ekycMachine } from "./ekycStateMachine-BN4KBDYY.esm.js";
30
+ import { t as emailMachine } from "./emailStateMachine-Bqwe_sQS.esm.js";
31
+ import { t as selfieMachine } from "./selfieStateMachine-DHPSBFj0.esm.js";
32
+ import { t as idCaptureMachine } from "./idCaptureStateMachine-MAzfM_2O.esm.js";
33
+ import { t as phoneMachine } from "./phoneStateMachine-B1t1Z-Dd.esm.js";
34
+ import { t as faceMatchMachine } from "./faceMatchStateMachine-D3DuP_ya.esm.js";
35
+ import { t as getFinishStatus } from "./flowCompletionService-W6bj7Xd3.esm.js";
36
+ import { t as runChildModule } from "./runChildModule-B5DEiOS7.esm.js";
37
+ import { t as geolocationMachine } from "./geolocationStateMachine-Bj2LkGwy.esm.js";
38
+ import { t as governmentValidationMachine } from "./governmentValidationStateMachine-W1CzRjVw.esm.js";
39
+ import { t as mandatoryConsentMachine } from "./mandatoryConsentStateMachine-BMKi26Re.esm.js";
40
+ import { t as redirectToMobileMachine } from "./redirectToMobileStateMachine-BVP1KcoO.esm.js";
41
+ import { t as signatureMachine } from "./signatureStateMachine-Cv7yPuEf.esm.js";
42
+
43
+ //#region src/modules/workflow/workflowServices.ts
44
+ function assertWorkflowNode(data, endpoint) {
45
+ const obj = data;
46
+ if (!obj || typeof obj.nodeType !== "string") throw new Error(`Invalid response from ${endpoint}: missing nodeType`);
47
+ }
48
+ function assertWorkflowConfig(data, endpoint) {
49
+ const obj = data;
50
+ if (!obj || typeof obj.id !== "string") throw new Error(`Invalid response from ${endpoint}: missing id`);
51
+ }
52
+ async function getCurrentNode(signal) {
53
+ const res = await api.get(endpoints.workflowCurrentNode, { signal });
54
+ if (!res.ok) throw new Error(`GET ${endpoints.workflowCurrentNode} failed: ${res.status} ${res.statusText}`);
55
+ assertWorkflowNode(res.data, endpoints.workflowCurrentNode);
56
+ return res.data;
57
+ }
58
+ async function processNode(signal) {
59
+ const res = await api.post(endpoints.workflowProcessNode, {}, { signal });
60
+ if (!res.ok) throw new Error(`POST ${endpoints.workflowProcessNode} failed: ${res.status} ${res.statusText}`);
61
+ assertWorkflowNode(res.data, endpoints.workflowProcessNode);
62
+ return res.data;
63
+ }
64
+ async function getWorkflowConfig(signal) {
65
+ const res = await api.get(endpoints.workflowInfo, { signal });
66
+ if (!res.ok) throw new Error(`GET ${endpoints.workflowInfo} failed: ${res.status} ${res.statusText}`);
67
+ assertWorkflowConfig(res.data, endpoints.workflowInfo);
68
+ return res.data;
69
+ }
70
+ async function processCustomNode(data, signal) {
71
+ const res = await api.post(endpoints.customModuleExecution, data, { signal });
72
+ if (!res.ok) throw new Error(`POST ${endpoints.customModuleExecution} failed: ${res.status} ${res.statusText}`);
73
+ }
74
+
75
+ //#endregion
76
+ //#region src/modules/workflow/workflowActors.ts
77
+ async function loadWorkflow(input, signal) {
78
+ await initializeSession({ signal }).catch(() => void 0);
79
+ const workflowConfig = await getWorkflowConfig(signal);
80
+ const realNode = await getCurrentNode(signal);
81
+ const fingerprintResult = getSessionFingerprintResult();
82
+ let currentNode = realNode;
83
+ let firstNode;
84
+ let isInjectedNode = false;
85
+ if (fingerprintResult?.showMandatoryConsent) {
86
+ firstNode = realNode;
87
+ isInjectedNode = true;
88
+ currentNode = {
89
+ id: "injected-mandatory-consent",
90
+ nodeType: "MODULE",
91
+ moduleKey: "MANDATORY_CONSENT",
92
+ moduleConfiguration: { consentType: fingerprintResult.regulationType ?? "Other" },
93
+ status: "INJECTED",
94
+ workflowId: workflowConfig.id
95
+ };
96
+ } else if (workflowConfig.redirectDesktopToMobile && input.isDesktop) {
97
+ firstNode = realNode;
98
+ isInjectedNode = true;
99
+ currentNode = {
100
+ id: "injected-redirect-to-mobile",
101
+ nodeType: "MODULE",
102
+ moduleKey: "REDIRECT_TO_MOBILE",
103
+ moduleConfiguration: {
104
+ disableSmsOption: workflowConfig.disableSmsOption ?? false,
105
+ addContinueToDesktop: workflowConfig.addContinueToDesktop ?? false,
106
+ qrPhishingResistance: workflowConfig.qrPhishingResistance ?? false
107
+ },
108
+ status: "INJECTED",
109
+ workflowId: workflowConfig.id
110
+ };
111
+ }
112
+ return {
113
+ workflowConfig,
114
+ currentNode,
115
+ firstNode,
116
+ isInjectedNode
117
+ };
118
+ }
119
+ async function processNextNode(input, signal) {
120
+ if (input.isInjectedNode && input.firstNode) {
121
+ if (input.currentNodeModuleKey === "MANDATORY_CONSENT" && input.workflowRedirectDesktopToMobile && input.isDesktop) return {
122
+ nextNode: {
123
+ id: "injected-redirect-to-mobile",
124
+ nodeType: "MODULE",
125
+ moduleKey: "REDIRECT_TO_MOBILE",
126
+ moduleConfiguration: {
127
+ disableSmsOption: input.workflowDisableSmsOption,
128
+ addContinueToDesktop: input.workflowAddContinueToDesktop,
129
+ qrPhishingResistance: input.workflowQrPhishingResistance
130
+ },
131
+ status: "INJECTED",
132
+ workflowId: input.workflowConfigId ?? ""
133
+ },
134
+ isInjectedNode: true
135
+ };
136
+ return {
137
+ nextNode: input.firstNode,
138
+ isInjectedNode: false
139
+ };
140
+ }
141
+ return {
142
+ nextNode: await processNode(signal),
143
+ isInjectedNode: false
144
+ };
145
+ }
146
+ async function handleCustomModule(input, signal) {
147
+ const { currentNode, interviewId, customModuleCallback } = input;
148
+ const callbackName = currentNode.moduleConfiguration?.callbackName ?? "";
149
+ const customData = {
150
+ interviewId,
151
+ status: "UNKNOWN",
152
+ message: null,
153
+ callbackName,
154
+ nodeId: currentNode.id
155
+ };
156
+ if (customModuleCallback) {
157
+ const result = await new Promise((resolve, reject) => {
158
+ const onAbort = () => reject(/* @__PURE__ */ new Error("Custom module aborted"));
159
+ signal.addEventListener("abort", onAbort);
160
+ customModuleCallback({
161
+ onSuccess: (message) => {
162
+ signal.removeEventListener("abort", onAbort);
163
+ resolve({
164
+ status: "OK",
165
+ message: message ?? null
166
+ });
167
+ },
168
+ onError: (message) => {
169
+ signal.removeEventListener("abort", onAbort);
170
+ resolve({
171
+ status: "FAIL",
172
+ message: message ?? null
173
+ });
174
+ },
175
+ interviewId,
176
+ nodeId: currentNode.id,
177
+ name: callbackName
178
+ });
179
+ });
180
+ customData.status = result.status;
181
+ customData.message = result.message;
182
+ }
183
+ await processCustomNode(customData, signal);
184
+ return await processNode(signal);
185
+ }
186
+ async function resolveModule(input) {
187
+ const entry = input.registeredModules[input.moduleKey];
188
+ if (!entry) throw new Error(`Unknown module type: ${input.moduleKey}. Ensure all workflow modules are registered.`);
189
+ if (typeof entry === "function") return entry();
190
+ return entry;
191
+ }
192
+
193
+ //#endregion
194
+ //#region src/modules/workflow/workflowStateMachine.ts
195
+ function extractErrorInfo(err) {
196
+ const error = err;
197
+ return {
198
+ message: error?.message ?? String(err),
199
+ code: error?.status
200
+ };
201
+ }
202
+ function extractNodeFromOutput(output) {
203
+ const obj = output;
204
+ if ("nextNode" in obj) return obj.nextNode;
205
+ if ("currentNode" in obj) return obj.currentNode;
206
+ if ("nodeType" in obj) return obj;
207
+ throw new Error("Unexpected actor output shape: cannot extract WorkflowNode");
208
+ }
209
+ const workflowMachine = setup({
210
+ types: {
211
+ context: {},
212
+ events: {},
213
+ input: {}
214
+ },
215
+ actors: {
216
+ loadWorkflow: fromPromise(({ input, signal }) => loadWorkflow(input, signal)),
217
+ processNextNode: fromPromise(({ input, signal }) => processNextNode(input, signal)),
218
+ handleCustomModule: fromPromise(({ input, signal }) => handleCustomModule(input, signal)),
219
+ resolveModule: fromPromise(({ input }) => resolveModule(input)),
220
+ notifyBackend: fromPromise(async ({ input, signal }) => {
221
+ return input.getFinishStatus(input.workflowId, signal);
222
+ }),
223
+ runChildModule
224
+ },
225
+ actions: {
226
+ setLoadingResult: assign(({ event }) => {
227
+ const result = event.output;
228
+ return {
229
+ workflowConfig: result.workflowConfig,
230
+ currentNode: result.currentNode,
231
+ firstNode: result.firstNode,
232
+ isInjectedNode: result.isInjectedNode
233
+ };
234
+ }),
235
+ setNextNode: assign(({ event }) => {
236
+ const result = event.output;
237
+ return {
238
+ currentNode: result.nextNode,
239
+ isInjectedNode: result.isInjectedNode
240
+ };
241
+ }),
242
+ setCustomModuleResult: assign(({ event }) => {
243
+ return {
244
+ currentNode: event.output,
245
+ isInjectedNode: false
246
+ };
247
+ }),
248
+ setResolvedMachine: assign(({ event }) => ({ resolvedMachine: event.output })),
249
+ setFinishStatus: assign(({ event }) => ({ finishStatus: event.output })),
250
+ setError: assign(({ event }) => {
251
+ const { message, code } = extractErrorInfo(event.error);
252
+ return {
253
+ error: message,
254
+ errorCode: code
255
+ };
256
+ }),
257
+ setModuleError: assign(({ event }) => ({ error: String(event.error) }))
258
+ },
259
+ guards: {
260
+ isModuleNode: ({ event }) => {
261
+ const output = event.output;
262
+ return extractNodeFromOutput(output).nodeType === "MODULE";
263
+ },
264
+ isFinishNode: ({ event }) => {
265
+ const output = event.output;
266
+ return extractNodeFromOutput(output).nodeType === "FINISH";
267
+ },
268
+ isAsyncResolutionNode: ({ event }) => {
269
+ const output = event.output;
270
+ return extractNodeFromOutput(output).nodeType === "ASYNC_RESOLUTION";
271
+ },
272
+ isCustomModule: ({ context }) => {
273
+ return context.currentNode?.moduleKey === "CUSTOM_MODULE";
274
+ }
275
+ }
276
+ }).createMachine({
277
+ id: "workflow",
278
+ initial: "idle",
279
+ context: ({ input }) => ({
280
+ workflowConfig: void 0,
281
+ currentNode: void 0,
282
+ firstNode: void 0,
283
+ resolvedMachine: void 0,
284
+ error: void 0,
285
+ errorCode: void 0,
286
+ registeredModules: input.modules,
287
+ finishStatus: void 0,
288
+ customModuleCallback: input.customModuleCallback,
289
+ interviewId: input.interviewId ?? "",
290
+ isDesktop: input.isDesktop ?? true,
291
+ isInjectedNode: false,
292
+ getFinishStatus: input.getFinishStatus ?? getFinishStatus
293
+ }),
294
+ states: {
295
+ idle: { on: { LOAD: "loading" } },
296
+ loading: { invoke: {
297
+ id: "loadWorkflow",
298
+ src: "loadWorkflow",
299
+ input: ({ context }) => ({ isDesktop: context.isDesktop }),
300
+ onDone: [
301
+ {
302
+ target: "resolvingModule",
303
+ guard: "isModuleNode",
304
+ actions: "setLoadingResult"
305
+ },
306
+ {
307
+ target: "completing",
308
+ guard: "isFinishNode",
309
+ actions: "setLoadingResult"
310
+ },
311
+ {
312
+ target: "asyncResolution",
313
+ guard: "isAsyncResolutionNode",
314
+ actions: "setLoadingResult"
315
+ }
316
+ ],
317
+ onError: {
318
+ target: "error",
319
+ actions: "setError"
320
+ }
321
+ } },
322
+ resolvingModule: {
323
+ always: [{
324
+ target: "handlingCustomModule",
325
+ guard: "isCustomModule"
326
+ }],
327
+ invoke: {
328
+ id: "resolveModule",
329
+ src: "resolveModule",
330
+ input: ({ context }) => ({
331
+ moduleKey: context.currentNode.moduleKey,
332
+ registeredModules: context.registeredModules
333
+ }),
334
+ onDone: {
335
+ target: "runningModule",
336
+ actions: "setResolvedMachine"
337
+ },
338
+ onError: {
339
+ target: "error",
340
+ actions: "setError"
341
+ }
342
+ }
343
+ },
344
+ runningModule: {
345
+ invoke: {
346
+ id: "currentModule",
347
+ src: "runChildModule",
348
+ input: ({ context }) => {
349
+ const config = {
350
+ ...context.currentNode?.moduleConfiguration,
351
+ ds: context.workflowConfig?.ds
352
+ };
353
+ return {
354
+ machine: context.resolvedMachine,
355
+ config
356
+ };
357
+ }
358
+ },
359
+ on: {
360
+ MODULE_COMPLETE: "processingNode",
361
+ MODULE_ERROR: {
362
+ target: "error",
363
+ actions: "setModuleError"
364
+ },
365
+ COMPLETE_FLOW: "completing"
366
+ }
367
+ },
368
+ handlingCustomModule: { invoke: {
369
+ id: "customModule",
370
+ src: "handleCustomModule",
371
+ input: ({ context }) => ({
372
+ currentNode: context.currentNode,
373
+ interviewId: context.interviewId,
374
+ customModuleCallback: context.customModuleCallback
375
+ }),
376
+ onDone: [
377
+ {
378
+ target: "resolvingModule",
379
+ guard: "isModuleNode",
380
+ actions: "setCustomModuleResult"
381
+ },
382
+ {
383
+ target: "completing",
384
+ guard: "isFinishNode",
385
+ actions: "setCustomModuleResult"
386
+ },
387
+ {
388
+ target: "asyncResolution",
389
+ guard: "isAsyncResolutionNode",
390
+ actions: "setCustomModuleResult"
391
+ }
392
+ ],
393
+ onError: {
394
+ target: "error",
395
+ actions: "setError"
396
+ }
397
+ } },
398
+ processingNode: { invoke: {
399
+ id: "processNext",
400
+ src: "processNextNode",
401
+ input: ({ context }) => ({
402
+ isInjectedNode: context.isInjectedNode,
403
+ firstNode: context.firstNode,
404
+ currentNodeModuleKey: context.currentNode?.moduleKey,
405
+ workflowConfigId: context.workflowConfig?.id,
406
+ workflowRedirectDesktopToMobile: context.workflowConfig?.redirectDesktopToMobile ?? false,
407
+ workflowDisableSmsOption: context.workflowConfig?.disableSmsOption ?? false,
408
+ workflowAddContinueToDesktop: context.workflowConfig?.addContinueToDesktop ?? false,
409
+ workflowQrPhishingResistance: context.workflowConfig?.qrPhishingResistance ?? false,
410
+ isDesktop: context.isDesktop
411
+ }),
412
+ onDone: [
413
+ {
414
+ target: "resolvingModule",
415
+ guard: "isModuleNode",
416
+ actions: "setNextNode",
417
+ reenter: true
418
+ },
419
+ {
420
+ target: "completing",
421
+ guard: "isFinishNode",
422
+ actions: "setNextNode"
423
+ },
424
+ {
425
+ target: "asyncResolution",
426
+ guard: "isAsyncResolutionNode",
427
+ actions: "setNextNode"
428
+ }
429
+ ],
430
+ onError: {
431
+ target: "error",
432
+ actions: "setError"
433
+ }
434
+ } },
435
+ completing: { invoke: {
436
+ id: "notifyBackend",
437
+ src: "notifyBackend",
438
+ input: ({ context }) => ({
439
+ getFinishStatus: context.getFinishStatus,
440
+ workflowId: context.workflowConfig?.id
441
+ }),
442
+ onDone: {
443
+ target: "finished",
444
+ actions: "setFinishStatus"
445
+ },
446
+ onError: {
447
+ target: "error",
448
+ actions: "setError"
449
+ }
450
+ } },
451
+ finished: { type: "final" },
452
+ asyncResolution: { type: "final" },
453
+ closed: { type: "final" },
454
+ error: { type: "final" }
455
+ }
456
+ });
457
+
458
+ //#endregion
459
+ //#region src/modules/workflow/workflowActor.ts
460
+ function createWorkflowActor(options) {
461
+ return createActor(workflowMachine, { input: {
462
+ modules: options.modules,
463
+ customModuleCallback: options.customModuleCallback,
464
+ interviewId: options.interviewId,
465
+ isDesktop: options.isDesktop
466
+ } }).start();
467
+ }
468
+
469
+ //#endregion
470
+ //#region src/internal/orchestration/defaultModules.ts
471
+ /**
472
+ * Shared default module registry — single source of truth for module key → machine mappings.
473
+ * Used by Workflow (eager loading). Flow uses lazy imports instead (see flowInit.ts).
474
+ *
475
+ * When adding a new module to the SDK, add it here AND to Flow's getLazyCoreMachineLoader.
476
+ */
477
+ /**
478
+ * Base module registry with all known SDK modules.
479
+ * Module keys match what the backend sends in flow/workflow configuration.
480
+ */
481
+ const DEFAULT_MODULE_REGISTRY = {
482
+ PHONE: phoneMachine,
483
+ EMAIL: emailMachine,
484
+ SELFIE: selfieMachine,
485
+ AUTHENTICATION: authenticationMachine,
486
+ ID: idCaptureMachine,
487
+ TUTORIAL_ID: idCaptureMachine,
488
+ SECOND_ID: idCaptureMachine,
489
+ FACE_MATCH: faceMatchMachine,
490
+ CURP_VALIDATION: curpValidationMachine,
491
+ GOVT_VALIDATION_PROVISIONING: governmentValidationMachine,
492
+ GEOLOCATION: geolocationMachine,
493
+ EXTERNAL_VERIFICATION: ekycMachine,
494
+ EKYB: ekybMachine,
495
+ DOCUMENT_CAPTURE: documentCaptureMachine,
496
+ ADDRESS: documentCaptureMachine,
497
+ COMBINED_CONSENT: consentMachine,
498
+ MANDATORY_CONSENT: mandatoryConsentMachine,
499
+ SIGNATURE: signatureMachine,
500
+ ANTIFRAUD: antifraudMachine
501
+ };
502
+
503
+ //#endregion
504
+ //#region src/modules/workflow/workflowManager.ts
505
+ const DEFAULT_MODULES = {
506
+ ...DEFAULT_MODULE_REGISTRY,
507
+ ID_CAPTURE: idCaptureMachine,
508
+ REDIRECT_TO_MOBILE: redirectToMobileMachine
509
+ };
510
+ function mapState(snapshot) {
511
+ const { context } = snapshot;
512
+ if (snapshot.matches("idle")) return { status: "idle" };
513
+ if (snapshot.matches("runningModule")) {
514
+ const childSnapshot = snapshot.children.currentModule?.getSnapshot();
515
+ return {
516
+ status: "ready",
517
+ workflowConfig: context.workflowConfig,
518
+ currentNode: context.currentNode,
519
+ config: {
520
+ ...context.currentNode?.moduleConfiguration,
521
+ ds: context.workflowConfig?.ds
522
+ },
523
+ moduleState: childSnapshot ?? null
524
+ };
525
+ }
526
+ if (snapshot.matches("finished")) return {
527
+ status: "finished",
528
+ workflowConfig: context.workflowConfig,
529
+ finishStatus: context.finishStatus ?? {
530
+ redirectionUrl: "",
531
+ action: "none",
532
+ scoreStatus: "UNKNOWN"
533
+ }
534
+ };
535
+ if (snapshot.matches("asyncResolution")) return {
536
+ status: "asyncResolution",
537
+ workflowConfig: context.workflowConfig,
538
+ currentNode: context.currentNode
539
+ };
540
+ if (snapshot.matches("closed")) return { status: "closed" };
541
+ if (snapshot.matches("error")) return {
542
+ status: "error",
543
+ error: context.error ?? "Unknown error",
544
+ errorCode: context.errorCode
545
+ };
546
+ return { status: "loading" };
547
+ }
548
+ function createApi({ actor, getSnapshot, trackElementClicked }) {
549
+ return {
550
+ load() {
551
+ actor.send({ type: "LOAD" });
552
+ },
553
+ completeModule() {
554
+ trackElementClicked?.("completeModule");
555
+ actor.send({ type: "MODULE_COMPLETE" });
556
+ },
557
+ completeFlow() {
558
+ trackElementClicked?.("completeFlow");
559
+ actor.send({ type: "COMPLETE_FLOW" });
560
+ },
561
+ errorModule(error) {
562
+ actor.send({
563
+ type: "MODULE_ERROR",
564
+ error
565
+ });
566
+ },
567
+ getModuleConfig() {
568
+ const snapshot = getSnapshot();
569
+ if (snapshot.value !== "runningModule") return void 0;
570
+ return {
571
+ ...snapshot.context.currentNode?.moduleConfiguration,
572
+ ds: snapshot.context.workflowConfig?.ds
573
+ };
574
+ }
575
+ };
576
+ }
577
+ /**
578
+ * Creates a workflow manager for server-driven onboarding flows.
579
+ *
580
+ * Only one orchestrator (Flow or Workflow) should be active per session.
581
+ * Each session token maps to a single orchestrator run. To start a new
582
+ * workflow, create a new session and call `setup()` with the new token
583
+ * before creating a new manager.
584
+ */
585
+ function createWorkflowManager(options = {}) {
586
+ return createManager({
587
+ actor: createWorkflowActor({
588
+ modules: DEFAULT_MODULES,
589
+ customModuleCallback: options.customModuleCallback,
590
+ interviewId: options.interviewId,
591
+ isDesktop: options.isDesktop
592
+ }),
593
+ mapState,
594
+ createApi,
595
+ instrumentation: createManagerInstrumentation("WORKFLOW")
596
+ });
597
+ }
598
+
599
+ //#endregion
600
+ export { createWorkflowManager, workflowMachine };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/core",
3
- "version": "0.0.0-dev-20260409-a38d5e8",
3
+ "version": "0.0.0-dev-20260409-089e5c6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -61,6 +61,10 @@
61
61
  "types": "./dist/geolocation.d.ts",
62
62
  "import": "./dist/geolocation.esm.js"
63
63
  },
64
+ "./identity-reuse": {
65
+ "types": "./dist/identity-reuse.d.ts",
66
+ "import": "./dist/identity-reuse.esm.js"
67
+ },
64
68
  "./ekyc": {
65
69
  "types": "./dist/ekyc.d.ts",
66
70
  "import": "./dist/ekyc.esm.js"
@@ -113,6 +117,10 @@
113
117
  "types": "./dist/antifraud.d.ts",
114
118
  "import": "./dist/antifraud.esm.js"
115
119
  },
120
+ "./workflow": {
121
+ "types": "./dist/workflow.d.ts",
122
+ "import": "./dist/workflow.esm.js"
123
+ },
116
124
  "./cross-document-data-match": {
117
125
  "types": "./dist/cross-document-data-match.d.ts",
118
126
  "import": "./dist/cross-document-data-match.esm.js"
@@ -126,8 +134,8 @@
126
134
  "tsdown": "^0.16.6",
127
135
  "typescript": "^5.9.3",
128
136
  "vitest": "^4.0.13",
129
- "@incodetech/infra": "1.0.0",
130
- "@incodetech/config": "1.0.0"
137
+ "@incodetech/config": "1.0.0",
138
+ "@incodetech/infra": "1.0.0"
131
139
  },
132
140
  "scripts": {
133
141
  "build": "tsdown -c tsdown.config.ts",
@@ -1,3 +0,0 @@
1
- import { t as loadOpenVidu } from "./openviduLazy-vhrVZCr_.esm.js";
2
-
3
- export { loadOpenVidu };