@incodetech/core 0.0.0-dev-20260409-a38d5e8 → 0.0.0-dev-20260409-09dfd52

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 (134) hide show
  1. package/dist/BrowserStorageProvider-CXaS5Ooj.esm.js +55 -0
  2. package/dist/{OpenViduRecordingProvider-Bn2meybK.esm.js → OpenViduRecordingProvider-D_cVAwYQ.esm.js} +1 -1
  3. package/dist/{WasmUtilProvider-BpZSvZbg.esm.js → WasmUtilProvider-mWSXzp7b.esm.js} +1 -1
  4. package/dist/{addressSearch-DOFI7lwy.esm.js → addressSearch-C26OZIx0.esm.js} +4 -4
  5. package/dist/antifraud.d.ts +1 -1
  6. package/dist/antifraud.esm.js +4 -37
  7. package/dist/antifraudStateMachine-B74mO8vr.esm.js +39 -0
  8. package/dist/authentication.d.ts +11 -11
  9. package/dist/authentication.esm.js +22 -19
  10. package/dist/authenticationManager-BBQHippG.esm.js +67 -0
  11. package/dist/{authenticationManager-C2mk36yK.d.ts → authenticationManager-DOTo1EYF.d.ts} +2 -2
  12. package/dist/{authenticationManager-C7dL_avf.esm.js → authenticationStateMachine-DCJ0ArAt.esm.js} +7 -67
  13. package/dist/{backCameraStream-tabTmwDS.esm.js → backCameraStream-D9g2wyil.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 +55 -55
  17. package/dist/consent.esm.js +4 -149
  18. package/dist/consentStateMachine-DIdJXJW0.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-Dp5WB6__.esm.js +419 -0
  24. package/dist/{deepsightLoader-Cj6SyUQ-.esm.js → deepsightLoader-CaULV07H.esm.js} +10 -10
  25. package/dist/{deepsightService-ByD6uIs7.d.ts → deepsightService-S-tU77m-.d.ts} +2 -2
  26. package/dist/{deepsightService-BjgXl5hs.esm.js → deepsightService-rPGLH8Xp.esm.js} +5 -5
  27. package/dist/device.esm.js +3 -3
  28. package/dist/document-capture.d.ts +80 -78
  29. package/dist/document-capture.esm.js +8 -403
  30. package/dist/document-upload.d.ts +53 -53
  31. package/dist/document-upload.esm.js +7 -7
  32. package/dist/documentCaptureStateMachine-ByYOCKz5.esm.js +403 -0
  33. package/dist/ekyb.d.ts +3 -3
  34. package/dist/ekyb.esm.js +10 -655
  35. package/dist/ekybStateMachine-DRku_YmR.esm.js +653 -0
  36. package/dist/ekyc.d.ts +3 -3
  37. package/dist/ekyc.esm.js +6 -10614
  38. package/dist/ekycStateMachine-CSWaaWVl.esm.js +10615 -0
  39. package/dist/email.d.ts +3 -3
  40. package/dist/email.esm.js +6 -5
  41. package/dist/{emailManager-CU_hzrsl.d.ts → emailManager-D6CHM2QO.d.ts} +4 -3
  42. package/dist/emailManager-DByjyeY8.esm.js +238 -0
  43. package/dist/{emailManager-_9R4vm6g.esm.js → emailStateMachine-BoIkeCw5.esm.js} +6 -239
  44. package/dist/{events-DlHrOIRc.esm.js → events-W91zLpx4.esm.js} +5 -1
  45. package/dist/events.esm.js +2 -2
  46. package/dist/extensibility.d.ts +15 -15
  47. package/dist/extensibility.esm.js +33 -26
  48. package/dist/face-match.d.ts +7 -6
  49. package/dist/face-match.esm.js +8 -129
  50. package/dist/faceCaptureManagerFactory-Bspg2Tyf.esm.js +117 -0
  51. package/dist/{faceCaptureManagerFactory-Da_-ohdg.d.ts → faceCaptureManagerFactory-P2yy30KU.d.ts} +8 -8
  52. package/dist/{faceCaptureSetup-CaVWkjvE.esm.js → faceCaptureSetup-CQevz86q.esm.js} +5 -119
  53. package/dist/faceMatchStateMachine-CLterVEC.esm.js +127 -0
  54. package/dist/flow.d.ts +8 -13
  55. package/dist/flow.esm.js +10 -29
  56. package/dist/{flowCompletionService-B5JemmC6.esm.js → flowCompletionService-DZSDUXus.esm.js} +2 -2
  57. package/dist/{flowServices-p22wrYPf.esm.js → flowServices-YATk0fgY.esm.js} +3 -3
  58. package/dist/geolocation.d.ts +7 -6
  59. package/dist/geolocation.esm.js +7 -105
  60. package/dist/geolocationStateMachine-CRRUCl9K.esm.js +105 -0
  61. package/dist/{getDeviceClass-DEzz4cmY.esm.js → getDeviceClass-DBF-ExLR.esm.js} +1 -1
  62. package/dist/government-validation.d.ts +2 -2
  63. package/dist/government-validation.esm.js +5 -269
  64. package/dist/governmentValidationStateMachine-C_iPX9VE.esm.js +271 -0
  65. package/dist/http.esm.js +1 -1
  66. package/dist/id.d.ts +10 -10
  67. package/dist/id.esm.js +22 -20
  68. package/dist/idCaptureManager-CJfatzuY.esm.js +335 -0
  69. package/dist/{idCaptureManager-CV08v1e3.d.ts → idCaptureManager-CbZvdr9y.d.ts} +7 -7
  70. package/dist/{idCaptureManager-dyZzKv8L.esm.js → idCaptureStateMachine-gf-Q9piu.esm.js} +17 -346
  71. package/dist/index.d.ts +2 -2
  72. package/dist/index.esm.js +8 -8
  73. package/dist/{lib-Bavz2qmt.esm.js → lib-BzVJ-zxG.esm.js} +1 -1
  74. package/dist/mandatory-consent.d.ts +55 -55
  75. package/dist/mandatory-consent.esm.js +4 -124
  76. package/dist/mandatoryConsentStateMachine-BZNBJ1fK.esm.js +126 -0
  77. package/dist/{openviduLazy-vhrVZCr_.esm.js → openviduLazy-CLg_-u0m.esm.js} +2 -2
  78. package/dist/openviduLazy-rFXBtZVZ.esm.js +3 -0
  79. package/dist/{permissionServices-Cskq32Yd.esm.js → permissionServices-Cisv73eQ.esm.js} +2 -2
  80. package/dist/phone.d.ts +3 -3
  81. package/dist/phone.esm.js +6 -5
  82. package/dist/phoneManager-DhC4obPF.esm.js +258 -0
  83. package/dist/{phoneManager-ulJuGvJ8.d.ts → phoneManager-Zwr-qCnC.d.ts} +2 -2
  84. package/dist/{phoneManager-DerdUfd4.esm.js → phoneStateMachine-Cc_w4tC0.esm.js} +5 -258
  85. package/dist/{recordingService-483wQ6kR.esm.js → recordingService-CCfxUY7-.esm.js} +14 -68
  86. package/dist/redirect-to-mobile.d.ts +2 -2
  87. package/dist/redirect-to-mobile.esm.js +5 -247
  88. package/dist/redirectToMobileStateMachine-vOe27Ufw.esm.js +249 -0
  89. package/dist/runChildModule-DVC4JEjp.esm.js +27 -0
  90. package/dist/selfie.d.ts +11 -11
  91. package/dist/selfie.esm.js +22 -19
  92. package/dist/selfieManager-CorEST5h.esm.js +60 -0
  93. package/dist/{selfieManager-DCRP7X75.d.ts → selfieManager-DNwfxieF.d.ts} +2 -2
  94. package/dist/selfieStateMachine-3b19ON1z.esm.js +56 -0
  95. package/dist/{session-CUh77zj3.esm.js → session-B_rKSRql.esm.js} +4 -4
  96. package/dist/session.d.ts +1 -1
  97. package/dist/session.esm.js +6 -6
  98. package/dist/{setup-DpHakxsC.d.ts → setup-BYqwVLiv.d.ts} +1 -1
  99. package/dist/{setup-XpxfZgKn.esm.js → setup-DLvhsDol.esm.js} +6 -5
  100. package/dist/signature.d.ts +4 -3
  101. package/dist/signature.esm.js +6 -189
  102. package/dist/signatureStateMachine-CU92zCXU.esm.js +189 -0
  103. package/dist/{stats-DHDoqSBV.esm.js → stats-gFD2351t.esm.js} +1 -1
  104. package/dist/stats.esm.js +2 -2
  105. package/dist/{types-2OPf1pyv.d.ts → types-CYJ0Ish6.d.ts} +1 -1
  106. package/dist/types-CjsEZRcz.d.ts +35 -0
  107. package/dist/{types-CVJVQ7fp.d.ts → types-DU8HmI5U.d.ts} +1 -1
  108. package/dist/wasm.d.ts +2 -2
  109. package/dist/wasm.esm.js +8 -8
  110. package/dist/workflow.d.ts +813 -0
  111. package/dist/workflow.esm.js +600 -0
  112. package/package.json +7 -3
  113. package/dist/openviduLazy-BIPHozOu.esm.js +0 -3
  114. package/dist/selfieManager-DeOcNel4.esm.js +0 -110
  115. /package/dist/{Actor-Ba71-_30.d.ts → Actor-DbWH1K6E.d.ts} +0 -0
  116. /package/dist/{BaseWasmProvider-D-s_6M5H.esm.js → BaseWasmProvider-DoYDYH1z.esm.js} +0 -0
  117. /package/dist/{BrowserEnvironmentProvider-DaHeLJQw.esm.js → BrowserEnvironmentProvider-BtKLxTx4.esm.js} +0 -0
  118. /package/dist/{BrowserTimerProvider-BhD2MlHg.esm.js → BrowserTimerProvider-v7bpbrAk.esm.js} +0 -0
  119. /package/dist/{ITimerCapability-oixwa6nj.esm.js → ITimerCapability-BZO_FsCo.esm.js} +0 -0
  120. /package/dist/{Manager-BN2g_I8W.d.ts → Manager-DcPMRgTm.d.ts} +0 -0
  121. /package/dist/{MotionSensorProvider-CodM3e0E.esm.js → MotionSensorProvider-D90R4qwV.esm.js} +0 -0
  122. /package/dist/{StateMachine-BoJsfMvg.d.ts → StateMachine-BBuIgsHT.d.ts} +0 -0
  123. /package/dist/{api-DzpnV6O7.esm.js → api-aa9Mx20l.esm.js} +0 -0
  124. /package/dist/{browserSimulation-B4ubb2OL.esm.js → browserSimulation-DFqGKQAD.esm.js} +0 -0
  125. /package/dist/{camera-1eeGnAaL.d.ts → camera-DATT31my.d.ts} +0 -0
  126. /package/dist/{camera-DmkFpf5N.esm.js → camera-DpPQS_-5.esm.js} +0 -0
  127. /package/dist/{chunk-DsxENsBR.esm.js → chunk-YGHKo4MY.esm.js} +0 -0
  128. /package/dist/{displayErrors-BZLX7idb.d.ts → displayErrors-xrg0ejaS.d.ts} +0 -0
  129. /package/dist/{flowCompletionService-D-3YCHyO.d.ts → flowCompletionService-gxt5reFV.d.ts} +0 -0
  130. /package/dist/{getBrowser-Dtyt9J_h.esm.js → getBrowser-DCcD7H-M.esm.js} +0 -0
  131. /package/dist/{platform-Dv7a2fv-.esm.js → platform-DctkySJU.esm.js} +0 -0
  132. /package/dist/{types-D_QfFKxT.d.ts → types-CIjb0FKu.d.ts} +0 -0
  133. /package/dist/{warmup-CIj_wEV_.d.ts → warmup-Ckb1hN85.d.ts} +0 -0
  134. /package/dist/{xstate.esm-Bv55-lJ4.esm.js → xstate.esm-B7FPE6br.esm.js} +0 -0
@@ -0,0 +1,600 @@
1
+ import "./BaseWasmProvider-DoYDYH1z.esm.js";
2
+ import { t as api } from "./api-aa9Mx20l.esm.js";
3
+ import { _ as endpoints, o as createManagerInstrumentation } from "./events-W91zLpx4.esm.js";
4
+ import { n as getSessionFingerprintResult, r as initializeSession } from "./session-B_rKSRql.esm.js";
5
+ import "./BrowserEnvironmentProvider-BtKLxTx4.esm.js";
6
+ import "./browserSimulation-DFqGKQAD.esm.js";
7
+ import { a as createActor, i as fromPromise, n as assign, o as createManager, t as setup } from "./xstate.esm-B7FPE6br.esm.js";
8
+ import { t as antifraudMachine } from "./antifraudStateMachine-B74mO8vr.esm.js";
9
+ import "./recordingService-CCfxUY7-.esm.js";
10
+ import "./deepsightService-rPGLH8Xp.esm.js";
11
+ import "./camera-DpPQS_-5.esm.js";
12
+ import "./getBrowser-DCcD7H-M.esm.js";
13
+ import "./stats-gFD2351t.esm.js";
14
+ import "./MotionSensorProvider-D90R4qwV.esm.js";
15
+ import "./permissionServices-Cisv73eQ.esm.js";
16
+ import "./platform-DctkySJU.esm.js";
17
+ import "./ITimerCapability-BZO_FsCo.esm.js";
18
+ import "./backCameraStream-D9g2wyil.esm.js";
19
+ import "./getDeviceClass-DBF-ExLR.esm.js";
20
+ import "./faceCaptureSetup-CQevz86q.esm.js";
21
+ import { t as authenticationMachine } from "./authenticationStateMachine-DCJ0ArAt.esm.js";
22
+ import { t as consentMachine } from "./consentStateMachine-DIdJXJW0.esm.js";
23
+ import { t as curpValidationMachine } from "./curpValidationStateMachine-Dp5WB6__.esm.js";
24
+ import { t as documentCaptureMachine } from "./documentCaptureStateMachine-ByYOCKz5.esm.js";
25
+ import { t as ekybMachine } from "./ekybStateMachine-DRku_YmR.esm.js";
26
+ import "./addressSearch-C26OZIx0.esm.js";
27
+ import "./flowServices-YATk0fgY.esm.js";
28
+ import "./BrowserTimerProvider-v7bpbrAk.esm.js";
29
+ import { t as ekycMachine } from "./ekycStateMachine-CSWaaWVl.esm.js";
30
+ import { t as emailMachine } from "./emailStateMachine-BoIkeCw5.esm.js";
31
+ import { t as selfieMachine } from "./selfieStateMachine-3b19ON1z.esm.js";
32
+ import { t as idCaptureMachine } from "./idCaptureStateMachine-gf-Q9piu.esm.js";
33
+ import { t as phoneMachine } from "./phoneStateMachine-Cc_w4tC0.esm.js";
34
+ import { t as faceMatchMachine } from "./faceMatchStateMachine-CLterVEC.esm.js";
35
+ import { t as getFinishStatus } from "./flowCompletionService-DZSDUXus.esm.js";
36
+ import { t as runChildModule } from "./runChildModule-DVC4JEjp.esm.js";
37
+ import { t as geolocationMachine } from "./geolocationStateMachine-CRRUCl9K.esm.js";
38
+ import { t as governmentValidationMachine } from "./governmentValidationStateMachine-C_iPX9VE.esm.js";
39
+ import { t as mandatoryConsentMachine } from "./mandatoryConsentStateMachine-BZNBJ1fK.esm.js";
40
+ import { t as redirectToMobileMachine } from "./redirectToMobileStateMachine-vOe27Ufw.esm.js";
41
+ import { t as signatureMachine } from "./signatureStateMachine-CU92zCXU.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-09dfd52",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -113,6 +113,10 @@
113
113
  "types": "./dist/antifraud.d.ts",
114
114
  "import": "./dist/antifraud.esm.js"
115
115
  },
116
+ "./workflow": {
117
+ "types": "./dist/workflow.d.ts",
118
+ "import": "./dist/workflow.esm.js"
119
+ },
116
120
  "./cross-document-data-match": {
117
121
  "types": "./dist/cross-document-data-match.d.ts",
118
122
  "import": "./dist/cross-document-data-match.esm.js"
@@ -126,8 +130,8 @@
126
130
  "tsdown": "^0.16.6",
127
131
  "typescript": "^5.9.3",
128
132
  "vitest": "^4.0.13",
129
- "@incodetech/infra": "1.0.0",
130
- "@incodetech/config": "1.0.0"
133
+ "@incodetech/config": "1.0.0",
134
+ "@incodetech/infra": "1.0.0"
131
135
  },
132
136
  "scripts": {
133
137
  "build": "tsdown -c tsdown.config.ts",
@@ -1,3 +0,0 @@
1
- import { t as loadOpenVidu } from "./openviduLazy-vhrVZCr_.esm.js";
2
-
3
- export { loadOpenVidu };