@incodetech/core 2.0.0-alpha.8 → 2.0.0-rc.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.
- package/dist/Actor-CI32dTbG.d.ts +2 -0
- package/dist/BaseWasmProvider-C_DLEI40.esm.js +1118 -0
- package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +55 -0
- package/dist/BrowserTimerProvider-DhNc_x02.esm.js +22 -0
- package/dist/ITimerCapability-C67ZRskg.esm.js +7 -0
- package/dist/IpifyProvider-D7jx52AL.esm.js +139 -0
- package/dist/MotionSensorProvider-4v7xkqAp.esm.js +254 -0
- package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +87 -0
- package/dist/StateMachine-BCQrZJhf.d.ts +2 -0
- package/dist/WasmUtilProvider-j98OJf-S.esm.js +114 -0
- package/dist/addressSearch-BpTbTWCa.esm.js +430 -0
- package/dist/ae-signature-DDDZmWXj.esm.js +12 -0
- package/dist/ae-signature.d.ts +25 -0
- package/dist/ae-signature.esm.js +8 -0
- package/dist/antifraud.d.ts +57 -0
- package/dist/antifraud.esm.js +45 -0
- package/dist/antifraudStateMachine-O0TMf6yc.esm.js +39 -0
- package/dist/api-CESGtpbH.esm.js +53 -0
- package/dist/authentication.d.ts +12 -0
- package/dist/authentication.esm.js +25 -0
- package/dist/authenticationManager-5M-fKzXx.esm.js +67 -0
- package/dist/authenticationManager-C83GNIhl.d.ts +66 -0
- package/dist/authenticationStateMachine-BMZqatiF.esm.js +139 -0
- package/dist/backCameraStream-DMdMeGk2.esm.js +346 -0
- package/dist/browserSimulation-gxD8cSpM.esm.js +20 -0
- package/dist/camera-DBSxa6ML.d.ts +4 -0
- package/dist/camera-PA2Ljri3.esm.js +22 -0
- package/dist/camera.d.ts +15 -0
- package/dist/camera.esm.js +5 -0
- package/dist/consent.d.ts +398 -0
- package/dist/consent.esm.js +79 -0
- package/dist/consentStateMachine-CCT-B60O.esm.js +151 -0
- package/dist/cpf-PPz2Njto.esm.js +38 -0
- package/dist/cpf-ocr.d.ts +204 -0
- package/dist/cpf-ocr.esm.js +177 -0
- package/dist/cross-document-data-match.d.ts +34 -0
- package/dist/cross-document-data-match.esm.js +71 -0
- package/dist/curp-validation.d.ts +188 -0
- package/dist/curp-validation.esm.js +110 -0
- package/dist/curpValidationStateMachine-CitWLr2c.esm.js +595 -0
- package/dist/custom-fields.d.ts +115 -0
- package/dist/custom-fields.esm.js +177 -0
- package/dist/custom-watchlist.d.ts +66 -0
- package/dist/custom-watchlist.esm.js +86 -0
- package/dist/dateUtils-UoN5xswP.esm.js +23 -0
- package/dist/deepsightLoader-Cm4JIT_z.esm.js +52 -0
- package/dist/deepsightService-CEVxzehb.d.ts +412 -0
- package/dist/deepsightService-O74l4Y__.esm.js +489 -0
- package/dist/device.d.ts +46 -0
- package/dist/device.esm.js +106 -0
- package/dist/displayErrors-DqJ_IbsG.d.ts +39 -0
- package/dist/document-capture.d.ts +906 -0
- package/dist/document-capture.esm.js +156 -0
- package/dist/document-upload.d.ts +331 -0
- package/dist/document-upload.esm.js +203 -0
- package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +394 -0
- package/dist/dynamic-forms.d.ts +178 -0
- package/dist/dynamic-forms.esm.js +323 -0
- package/dist/ekyb.d.ts +148 -0
- package/dist/ekyb.esm.js +127 -0
- package/dist/ekybStateMachine-B59rQjgj.esm.js +674 -0
- package/dist/ekyc.d.ts +164 -0
- package/dist/ekyc.esm.js +104 -0
- package/dist/ekycStateMachine-oeO0Iekd.esm.js +10626 -0
- package/dist/electronic-signature.d.ts +4 -0
- package/dist/electronic-signature.esm.js +7 -0
- package/dist/electronicSignatureManager-D9OHzTpG.esm.js +428 -0
- package/dist/email.d.ts +3 -263
- package/dist/email.esm.js +7 -477
- package/dist/emailManager-DIfnS5g1.d.ts +352 -0
- package/dist/emailManager-wAV0LE-H.esm.js +238 -0
- package/dist/emailStateMachine-DOf4j58N.esm.js +292 -0
- package/dist/endpoints-CnN3SyDa.esm.js +87 -0
- package/dist/events-D6-e4vok.esm.js +596 -0
- package/dist/events.d.ts +265 -0
- package/dist/events.esm.js +4 -0
- package/dist/extensibility.d.ts +122 -0
- package/dist/extensibility.esm.js +43 -0
- package/dist/face-match.d.ts +228 -0
- package/dist/face-match.esm.js +173 -0
- package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +290 -0
- package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +690 -0
- package/dist/faceCaptureSetup-B3faSpYA.esm.js +873 -0
- package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +127 -0
- package/dist/flow-events.d.ts +6 -0
- package/dist/flow-events.esm.js +0 -0
- package/dist/flow.d.ts +101 -321
- package/dist/flow.esm.js +370 -173
- package/dist/flowCompletionService-DhkT4SRY.d.ts +10 -0
- package/dist/flowCompletionService-P54yzGvA.esm.js +13 -0
- package/dist/flowServices-DTsm-Vf1.esm.js +188 -0
- package/dist/geolocation.d.ts +127 -0
- package/dist/geolocation.esm.js +89 -0
- package/dist/geolocationStateMachine-asasuHY2.esm.js +105 -0
- package/dist/getBrowser-BSXUTWXw.esm.js +41 -0
- package/dist/getDeviceClass-BSntT9_j.esm.js +14 -0
- package/dist/government-validation.d.ts +67 -0
- package/dist/government-validation.esm.js +81 -0
- package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +271 -0
- package/dist/home.d.ts +99 -0
- package/dist/home.esm.js +61 -0
- package/dist/http.d.ts +68 -0
- package/dist/http.esm.js +3 -0
- package/dist/id-ocr.d.ts +635 -0
- package/dist/id-ocr.esm.js +86 -0
- package/dist/id-verification.d.ts +190 -0
- package/dist/id-verification.esm.js +43 -0
- package/dist/id.d.ts +24 -0
- package/dist/id.esm.js +164 -0
- package/dist/idCaptureManager-B9TGA5dq.d.ts +956 -0
- package/dist/idCaptureManager-DMK0GIt3.esm.js +581 -0
- package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +2954 -0
- package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +388 -0
- package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +71 -0
- package/dist/identity-reuse.d.ts +530 -0
- package/dist/identity-reuse.esm.js +274 -0
- package/dist/index-BLKtMA0g.d.ts +1177 -0
- package/dist/index-BcRG8rtJ.d.ts +97 -0
- package/dist/index.d.ts +3 -226
- package/dist/index.esm.js +11 -154
- package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +30 -0
- package/dist/{lib-Bu9XGMBW.esm.js → lib-BB0B_qQX.esm.js} +801 -2
- package/dist/mandatory-consent.d.ts +412 -0
- package/dist/mandatory-consent.esm.js +78 -0
- package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +126 -0
- package/dist/openviduLazy-Cm0XFh_v.esm.js +3 -0
- package/dist/openviduLazy-Cok70ZSg.esm.js +12 -0
- package/dist/permissionServices-D_i6nzEw.esm.js +50 -0
- package/dist/phone.d.ts +3 -291
- package/dist/phone.esm.js +7 -548
- package/dist/phoneManager-B6M30hKE.d.ts +397 -0
- package/dist/phoneManager-DAJbGhlY.esm.js +256 -0
- package/dist/phoneStateMachine-CuPARRaT.esm.js +351 -0
- package/dist/platform-CfrjKhmi.esm.js +83 -0
- package/dist/qe-signature-DFo_Cc-I.esm.js +12 -0
- package/dist/qe-signature.d.ts +25 -0
- package/dist/qe-signature.esm.js +8 -0
- package/dist/recordingService-Ig2UgbLv.esm.js +1003 -0
- package/dist/redirect-to-mobile.d.ts +107 -0
- package/dist/redirect-to-mobile.esm.js +102 -0
- package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +249 -0
- package/dist/runChildModule-CqqwqAkW.esm.js +219 -0
- package/dist/selfie.d.ts +21 -754
- package/dist/selfie.esm.js +113 -962
- package/dist/selfieManager-D0lSgd-J.d.ts +68 -0
- package/dist/selfieManager-Duisl7qN.esm.js +60 -0
- package/dist/selfieStateMachine-D76whWEf.esm.js +68 -0
- package/dist/session-BS-d_vuE.esm.js +3206 -0
- package/dist/session.d.ts +217 -0
- package/dist/session.esm.js +9 -0
- package/dist/setup-Buy-hyj4.esm.js +887 -0
- package/dist/setup-C5AITV8m.d.ts +254 -0
- package/dist/signature.d.ts +94 -0
- package/dist/signature.esm.js +66 -0
- package/dist/signatureStateMachine-B5-QVUve.esm.js +132 -0
- package/dist/stats-CIfiPzb1.esm.js +16 -0
- package/dist/stats.d.ts +16 -0
- package/dist/stats.esm.js +4 -0
- package/dist/trust-graph.d.ts +54 -0
- package/dist/trust-graph.esm.js +56 -0
- package/dist/types-B06Ypu2F.d.ts +49 -0
- package/dist/types-BP1m8VRw.d.ts +340 -0
- package/dist/types-CFV9G_7j.d.ts +24 -0
- package/dist/{warmup-CEJTfxQr.d.ts → warmup-CEcppFiS.d.ts} +11 -3
- package/dist/wasm.d.ts +15 -0
- package/dist/wasm.esm.js +12 -0
- package/dist/watchlist-for-business.d.ts +79 -0
- package/dist/watchlist-for-business.esm.js +148 -0
- package/dist/watchlist.d.ts +62 -0
- package/dist/watchlist.esm.js +86 -0
- package/dist/watchlistServices-DMbUhkBX.esm.js +12 -0
- package/dist/workflow.d.ts +907 -0
- package/dist/workflow.esm.js +702 -0
- package/dist/{xstate.esm-B_rda9yU.esm.js → xstate.esm-B70JrNqo.esm.js} +144 -1
- package/package.json +203 -6
- package/dist/OpenViduLogger-BdPfiZO6.esm.js +0 -3
- package/dist/OpenViduLogger-CQyDxBvM.esm.js +0 -803
- package/dist/StateMachine-DRE1oH2B.d.ts +0 -2
- package/dist/addEvent-W0ORK0jT.esm.js +0 -16
- package/dist/endpoints-BSTFaHYo.esm.js +0 -1706
- package/dist/permissionServices-I6vX6DBy.esm.js +0 -72
- /package/dist/{Manager-BGfxEmyv.d.ts → Manager-C8PrhBOx.d.ts} +0 -0
- /package/dist/{chunk-C_Yo44FK.esm.js → chunk-CRF6K_H_.esm.js} +0 -0
- /package/dist/{types-iZi2rawo.d.ts → types-CAD4va6a.d.ts} +0 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import "./BaseWasmProvider-C_DLEI40.esm.js";
|
|
2
|
+
import "./BrowserTimerProvider-DhNc_x02.esm.js";
|
|
3
|
+
import { t as api } from "./api-CESGtpbH.esm.js";
|
|
4
|
+
import { o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
|
|
5
|
+
import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
|
|
6
|
+
import { n as getSessionFingerprintResult, r as initializeSession } from "./session-BS-d_vuE.esm.js";
|
|
7
|
+
import "./IpifyProvider-D7jx52AL.esm.js";
|
|
8
|
+
import "./browserSimulation-gxD8cSpM.esm.js";
|
|
9
|
+
import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
|
|
10
|
+
import { n as electronicSignatureMachine } from "./electronicSignatureManager-D9OHzTpG.esm.js";
|
|
11
|
+
import "./ae-signature-DDDZmWXj.esm.js";
|
|
12
|
+
import { t as antifraudMachine } from "./antifraudStateMachine-O0TMf6yc.esm.js";
|
|
13
|
+
import "./faceCaptureSetup-B3faSpYA.esm.js";
|
|
14
|
+
import "./ITimerCapability-C67ZRskg.esm.js";
|
|
15
|
+
import "./camera-PA2Ljri3.esm.js";
|
|
16
|
+
import "./deepsightService-O74l4Y__.esm.js";
|
|
17
|
+
import "./recordingService-Ig2UgbLv.esm.js";
|
|
18
|
+
import "./platform-CfrjKhmi.esm.js";
|
|
19
|
+
import "./backCameraStream-DMdMeGk2.esm.js";
|
|
20
|
+
import "./getBrowser-BSXUTWXw.esm.js";
|
|
21
|
+
import "./stats-CIfiPzb1.esm.js";
|
|
22
|
+
import "./getDeviceClass-BSntT9_j.esm.js";
|
|
23
|
+
import "./MotionSensorProvider-4v7xkqAp.esm.js";
|
|
24
|
+
import "./permissionServices-D_i6nzEw.esm.js";
|
|
25
|
+
import { t as authenticationMachine } from "./authenticationStateMachine-BMZqatiF.esm.js";
|
|
26
|
+
import { t as consentMachine } from "./consentStateMachine-CCT-B60O.esm.js";
|
|
27
|
+
import "./cpf-PPz2Njto.esm.js";
|
|
28
|
+
import { t as curpValidationMachine } from "./curpValidationStateMachine-CitWLr2c.esm.js";
|
|
29
|
+
import { t as documentCaptureMachine } from "./documentCaptureStateMachine-BqzTDy9k.esm.js";
|
|
30
|
+
import { r as toEkybConfig, t as ekybMachine } from "./ekybStateMachine-B59rQjgj.esm.js";
|
|
31
|
+
import "./addressSearch-BpTbTWCa.esm.js";
|
|
32
|
+
import "./flowServices-DTsm-Vf1.esm.js";
|
|
33
|
+
import { r as toEkycConfig, t as ekycMachine } from "./ekycStateMachine-oeO0Iekd.esm.js";
|
|
34
|
+
import { t as emailMachine } from "./emailStateMachine-DOf4j58N.esm.js";
|
|
35
|
+
import { t as selfieMachine } from "./selfieStateMachine-D76whWEf.esm.js";
|
|
36
|
+
import { t as idCaptureMachine } from "./idCaptureStateMachine-Bq0fVZXl.esm.js";
|
|
37
|
+
import { t as phoneMachine } from "./phoneStateMachine-CuPARRaT.esm.js";
|
|
38
|
+
import { t as faceMatchMachine } from "./faceMatchStateMachine-DNFrxTFS.esm.js";
|
|
39
|
+
import { n as attachFlowEventEmitter, t as runChildModule } from "./runChildModule-CqqwqAkW.esm.js";
|
|
40
|
+
import { t as getFinishStatus } from "./flowCompletionService-P54yzGvA.esm.js";
|
|
41
|
+
import { t as geolocationMachine } from "./geolocationStateMachine-asasuHY2.esm.js";
|
|
42
|
+
import { t as governmentValidationMachine } from "./governmentValidationStateMachine-BDDYrJTo.esm.js";
|
|
43
|
+
import { t as idOcrStateMachine } from "./idOcrStateMachine-YbjjC_Gg.esm.js";
|
|
44
|
+
import { t as idVerificationMachine } from "./idVerificationStateMachine-xbw9HP1Z.esm.js";
|
|
45
|
+
import { t as mandatoryConsentMachine } from "./mandatoryConsentStateMachine-Cnco1jvn.esm.js";
|
|
46
|
+
import "./qe-signature-DFo_Cc-I.esm.js";
|
|
47
|
+
import { t as redirectToMobileMachine } from "./redirectToMobileStateMachine-BOEqe46A.esm.js";
|
|
48
|
+
import { t as signatureMachine } from "./signatureStateMachine-B5-QVUve.esm.js";
|
|
49
|
+
|
|
50
|
+
//#region src/internal/orchestration/defaultModules.ts
|
|
51
|
+
/**
|
|
52
|
+
* Shared default module registry — single source of truth for module key → machine mappings.
|
|
53
|
+
* Used by Workflow (eager loading). Flow uses lazy imports instead (see flowInit.ts).
|
|
54
|
+
*
|
|
55
|
+
* When adding a new module to the SDK, add it here AND to Flow's getLazyCoreMachineLoader.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Base module registry with all known SDK modules.
|
|
59
|
+
* Module keys match what the backend sends in flow/workflow configuration.
|
|
60
|
+
*/
|
|
61
|
+
const DEFAULT_MODULE_REGISTRY = {
|
|
62
|
+
PHONE: phoneMachine,
|
|
63
|
+
EMAIL: emailMachine,
|
|
64
|
+
SELFIE: selfieMachine,
|
|
65
|
+
AUTHENTICATION: authenticationMachine,
|
|
66
|
+
ID: idCaptureMachine,
|
|
67
|
+
TUTORIAL_ID: idCaptureMachine,
|
|
68
|
+
SECOND_ID: idCaptureMachine,
|
|
69
|
+
FACE_MATCH: faceMatchMachine,
|
|
70
|
+
CURP_VALIDATION: curpValidationMachine,
|
|
71
|
+
GOVT_VALIDATION_PROVISIONING: governmentValidationMachine,
|
|
72
|
+
GEOLOCATION: geolocationMachine,
|
|
73
|
+
EXTERNAL_VERIFICATION: ekycMachine,
|
|
74
|
+
EKYB: ekybMachine,
|
|
75
|
+
DOCUMENT_CAPTURE: documentCaptureMachine,
|
|
76
|
+
ADDRESS: documentCaptureMachine,
|
|
77
|
+
COMBINED_CONSENT: consentMachine,
|
|
78
|
+
MANDATORY_CONSENT: mandatoryConsentMachine,
|
|
79
|
+
SIGNATURE: signatureMachine,
|
|
80
|
+
ANTIFRAUD: antifraudMachine,
|
|
81
|
+
ID_OCR: idOcrStateMachine,
|
|
82
|
+
AE_SIGNATURE: electronicSignatureMachine,
|
|
83
|
+
QE_SIGNATURE: electronicSignatureMachine
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Per-module config mappers for orchestrators (workflow / flow).
|
|
87
|
+
*
|
|
88
|
+
* The backend's workflow-node `moduleConfiguration` shape is not always the
|
|
89
|
+
* same as the module's `Config` type. Modules that need remapping register a
|
|
90
|
+
* mapper here; everything else falls through with identity.
|
|
91
|
+
*
|
|
92
|
+
* Owned by core so that core-only orchestrator consumers (no `@incodetech/web`)
|
|
93
|
+
* receive correctly shaped configs.
|
|
94
|
+
*
|
|
95
|
+
* When adding a new module whose workflow-node config differs from its
|
|
96
|
+
* manager's `Config` type, add a mapper entry below.
|
|
97
|
+
*/
|
|
98
|
+
const DEFAULT_MODULE_CONFIG_MAPPERS = {
|
|
99
|
+
EXTERNAL_VERIFICATION: (raw) => toEkycConfig(raw),
|
|
100
|
+
EKYB: (raw) => toEkybConfig(raw)
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Applies the module-specific config mapper (if registered) to the raw node
|
|
104
|
+
* config. Used by the workflow manager (`mapState`, `getModuleConfig`) and
|
|
105
|
+
* the workflow state machine (`runningModule.invoke.input`) so all surfaces
|
|
106
|
+
* agree on the shape consumers see.
|
|
107
|
+
*
|
|
108
|
+
* Mappers always return an object shape; the cast back to
|
|
109
|
+
* `Record<string, unknown>` preserves the surrounding API contract.
|
|
110
|
+
*/
|
|
111
|
+
function applyConfigMapper(moduleKey, raw, mappers) {
|
|
112
|
+
const mapper = moduleKey ? mappers[moduleKey] : void 0;
|
|
113
|
+
return mapper ? mapper(raw) : raw;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/modules/workflow/workflowServices.ts
|
|
118
|
+
function assertWorkflowNode(data, endpoint) {
|
|
119
|
+
const obj = data;
|
|
120
|
+
if (!obj || typeof obj.nodeType !== "string") throw new Error(`Invalid response from ${endpoint}: missing nodeType`);
|
|
121
|
+
}
|
|
122
|
+
function assertWorkflowConfig(data, endpoint) {
|
|
123
|
+
const obj = data;
|
|
124
|
+
if (!obj || typeof obj.id !== "string") throw new Error(`Invalid response from ${endpoint}: missing id`);
|
|
125
|
+
}
|
|
126
|
+
async function getCurrentNode(signal) {
|
|
127
|
+
const res = await api.get(endpoints.workflowCurrentNode, { signal });
|
|
128
|
+
if (!res.ok) throw new Error(`GET ${endpoints.workflowCurrentNode} failed: ${res.status} ${res.statusText}`);
|
|
129
|
+
assertWorkflowNode(res.data, endpoints.workflowCurrentNode);
|
|
130
|
+
return res.data;
|
|
131
|
+
}
|
|
132
|
+
async function processNode(signal) {
|
|
133
|
+
const res = await api.post(endpoints.workflowProcessNode, {}, { signal });
|
|
134
|
+
if (!res.ok) throw new Error(`POST ${endpoints.workflowProcessNode} failed: ${res.status} ${res.statusText}`);
|
|
135
|
+
assertWorkflowNode(res.data, endpoints.workflowProcessNode);
|
|
136
|
+
return res.data;
|
|
137
|
+
}
|
|
138
|
+
async function getWorkflowConfig(signal) {
|
|
139
|
+
const res = await api.get(endpoints.workflowInfo, { signal });
|
|
140
|
+
if (!res.ok) throw new Error(`GET ${endpoints.workflowInfo} failed: ${res.status} ${res.statusText}`);
|
|
141
|
+
assertWorkflowConfig(res.data, endpoints.workflowInfo);
|
|
142
|
+
return res.data;
|
|
143
|
+
}
|
|
144
|
+
async function processCustomNode(data, signal) {
|
|
145
|
+
const res = await api.post(endpoints.customModuleExecution, data, { signal });
|
|
146
|
+
if (!res.ok) throw new Error(`POST ${endpoints.customModuleExecution} failed: ${res.status} ${res.statusText}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/modules/workflow/workflowActors.ts
|
|
151
|
+
async function loadWorkflow(input, signal) {
|
|
152
|
+
await initializeSession({ signal }).catch(() => void 0);
|
|
153
|
+
const workflowConfig = await getWorkflowConfig(signal);
|
|
154
|
+
const realNode = await getCurrentNode(signal);
|
|
155
|
+
const fingerprintResult = getSessionFingerprintResult();
|
|
156
|
+
let currentNode = realNode;
|
|
157
|
+
let firstNode;
|
|
158
|
+
let isInjectedNode = false;
|
|
159
|
+
if (fingerprintResult?.showMandatoryConsent) {
|
|
160
|
+
firstNode = realNode;
|
|
161
|
+
isInjectedNode = true;
|
|
162
|
+
currentNode = {
|
|
163
|
+
id: "injected-mandatory-consent",
|
|
164
|
+
nodeType: "MODULE",
|
|
165
|
+
moduleKey: "MANDATORY_CONSENT",
|
|
166
|
+
moduleConfiguration: { consentType: fingerprintResult.regulationType ?? "Other" },
|
|
167
|
+
status: "INJECTED",
|
|
168
|
+
workflowId: workflowConfig.id
|
|
169
|
+
};
|
|
170
|
+
} else if (workflowConfig.redirectDesktopToMobile && input.isDesktop) {
|
|
171
|
+
firstNode = realNode;
|
|
172
|
+
isInjectedNode = true;
|
|
173
|
+
currentNode = {
|
|
174
|
+
id: "injected-redirect-to-mobile",
|
|
175
|
+
nodeType: "MODULE",
|
|
176
|
+
moduleKey: "REDIRECT_TO_MOBILE",
|
|
177
|
+
moduleConfiguration: {
|
|
178
|
+
disableSmsOption: workflowConfig.disableSmsOption ?? false,
|
|
179
|
+
addContinueToDesktop: workflowConfig.addContinueToDesktop ?? false,
|
|
180
|
+
qrPhishingResistance: workflowConfig.qrPhishingResistance ?? false
|
|
181
|
+
},
|
|
182
|
+
status: "INJECTED",
|
|
183
|
+
workflowId: workflowConfig.id
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
workflowConfig,
|
|
188
|
+
currentNode,
|
|
189
|
+
firstNode,
|
|
190
|
+
isInjectedNode
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
async function processNextNode(input, signal) {
|
|
194
|
+
if (input.isInjectedNode && input.firstNode) {
|
|
195
|
+
if (input.currentNodeModuleKey === "MANDATORY_CONSENT" && input.workflowRedirectDesktopToMobile && input.isDesktop) return {
|
|
196
|
+
nextNode: {
|
|
197
|
+
id: "injected-redirect-to-mobile",
|
|
198
|
+
nodeType: "MODULE",
|
|
199
|
+
moduleKey: "REDIRECT_TO_MOBILE",
|
|
200
|
+
moduleConfiguration: {
|
|
201
|
+
disableSmsOption: input.workflowDisableSmsOption,
|
|
202
|
+
addContinueToDesktop: input.workflowAddContinueToDesktop,
|
|
203
|
+
qrPhishingResistance: input.workflowQrPhishingResistance
|
|
204
|
+
},
|
|
205
|
+
status: "INJECTED",
|
|
206
|
+
workflowId: input.workflowConfigId ?? ""
|
|
207
|
+
},
|
|
208
|
+
isInjectedNode: true
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
nextNode: input.firstNode,
|
|
212
|
+
isInjectedNode: false
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
nextNode: await processNode(signal),
|
|
217
|
+
isInjectedNode: false
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async function handleCustomModule(input, signal) {
|
|
221
|
+
const { currentNode, interviewId, customModuleCallback } = input;
|
|
222
|
+
const callbackName = currentNode.moduleConfiguration?.callbackName ?? "";
|
|
223
|
+
const customData = {
|
|
224
|
+
interviewId,
|
|
225
|
+
status: "UNKNOWN",
|
|
226
|
+
message: null,
|
|
227
|
+
callbackName,
|
|
228
|
+
nodeId: currentNode.id
|
|
229
|
+
};
|
|
230
|
+
if (customModuleCallback) {
|
|
231
|
+
const result = await new Promise((resolve, reject) => {
|
|
232
|
+
const onAbort = () => reject(/* @__PURE__ */ new Error("Custom module aborted"));
|
|
233
|
+
signal.addEventListener("abort", onAbort);
|
|
234
|
+
customModuleCallback({
|
|
235
|
+
onSuccess: (message) => {
|
|
236
|
+
signal.removeEventListener("abort", onAbort);
|
|
237
|
+
resolve({
|
|
238
|
+
status: "OK",
|
|
239
|
+
message: message ?? null
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
onError: (message) => {
|
|
243
|
+
signal.removeEventListener("abort", onAbort);
|
|
244
|
+
resolve({
|
|
245
|
+
status: "FAIL",
|
|
246
|
+
message: message ?? null
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
interviewId,
|
|
250
|
+
nodeId: currentNode.id,
|
|
251
|
+
name: callbackName
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
customData.status = result.status;
|
|
255
|
+
customData.message = result.message;
|
|
256
|
+
}
|
|
257
|
+
await processCustomNode(customData, signal);
|
|
258
|
+
return await processNode(signal);
|
|
259
|
+
}
|
|
260
|
+
async function resolveModule(input) {
|
|
261
|
+
const entry = input.registeredModules[input.moduleKey];
|
|
262
|
+
if (!entry) throw new Error(`Unknown module type: ${input.moduleKey}. Ensure all workflow modules are registered.`);
|
|
263
|
+
if (typeof entry === "function") return entry();
|
|
264
|
+
return entry;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/modules/workflow/workflowStateMachine.ts
|
|
269
|
+
function extractErrorInfo(err) {
|
|
270
|
+
const error = err;
|
|
271
|
+
return {
|
|
272
|
+
message: error?.message ?? String(err),
|
|
273
|
+
code: error?.status
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function extractNodeFromOutput(output) {
|
|
277
|
+
const obj = output;
|
|
278
|
+
if ("nextNode" in obj) return obj.nextNode;
|
|
279
|
+
if ("currentNode" in obj) return obj.currentNode;
|
|
280
|
+
if ("nodeType" in obj) return obj;
|
|
281
|
+
throw new Error("Unexpected actor output shape: cannot extract WorkflowNode");
|
|
282
|
+
}
|
|
283
|
+
const workflowMachine = setup({
|
|
284
|
+
types: {
|
|
285
|
+
context: {},
|
|
286
|
+
events: {},
|
|
287
|
+
input: {}
|
|
288
|
+
},
|
|
289
|
+
actors: {
|
|
290
|
+
loadWorkflow: fromPromise(({ input, signal }) => loadWorkflow(input, signal)),
|
|
291
|
+
processNextNode: fromPromise(({ input, signal }) => processNextNode(input, signal)),
|
|
292
|
+
handleCustomModule: fromPromise(({ input, signal }) => handleCustomModule(input, signal)),
|
|
293
|
+
resolveModule: fromPromise(({ input }) => resolveModule(input)),
|
|
294
|
+
notifyBackend: fromPromise(async ({ input, signal }) => {
|
|
295
|
+
return input.getFinishStatus(input.workflowId, signal);
|
|
296
|
+
}),
|
|
297
|
+
runChildModule
|
|
298
|
+
},
|
|
299
|
+
actions: {
|
|
300
|
+
setLoadingResult: assign(({ event }) => {
|
|
301
|
+
const result = event.output;
|
|
302
|
+
return {
|
|
303
|
+
workflowConfig: result.workflowConfig,
|
|
304
|
+
currentNode: result.currentNode,
|
|
305
|
+
firstNode: result.firstNode,
|
|
306
|
+
isInjectedNode: result.isInjectedNode
|
|
307
|
+
};
|
|
308
|
+
}),
|
|
309
|
+
setNextNode: assign(({ event }) => {
|
|
310
|
+
const result = event.output;
|
|
311
|
+
return {
|
|
312
|
+
currentNode: result.nextNode,
|
|
313
|
+
isInjectedNode: result.isInjectedNode
|
|
314
|
+
};
|
|
315
|
+
}),
|
|
316
|
+
setCustomModuleResult: assign(({ event }) => {
|
|
317
|
+
return {
|
|
318
|
+
currentNode: event.output,
|
|
319
|
+
isInjectedNode: false
|
|
320
|
+
};
|
|
321
|
+
}),
|
|
322
|
+
setResolvedMachine: assign(({ event }) => ({ resolvedMachine: event.output })),
|
|
323
|
+
setFinishStatus: assign(({ event }) => ({ finishStatus: event.output })),
|
|
324
|
+
setError: assign(({ event }) => {
|
|
325
|
+
const { message, code } = extractErrorInfo(event.error);
|
|
326
|
+
return {
|
|
327
|
+
error: message,
|
|
328
|
+
errorCode: code
|
|
329
|
+
};
|
|
330
|
+
}),
|
|
331
|
+
setModuleError: assign(({ event }) => ({ error: String(event.error) })),
|
|
332
|
+
setHomeContinueLoading: assign({ isHomeContinueLoading: true }),
|
|
333
|
+
clearHomeContinueLoading: assign({ isHomeContinueLoading: false })
|
|
334
|
+
},
|
|
335
|
+
guards: {
|
|
336
|
+
isModuleNode: ({ event }) => {
|
|
337
|
+
const output = event.output;
|
|
338
|
+
return extractNodeFromOutput(output).nodeType === "MODULE";
|
|
339
|
+
},
|
|
340
|
+
isFinishNode: ({ event }) => {
|
|
341
|
+
const output = event.output;
|
|
342
|
+
return extractNodeFromOutput(output).nodeType === "FINISH";
|
|
343
|
+
},
|
|
344
|
+
isAsyncResolutionNode: ({ event }) => {
|
|
345
|
+
const output = event.output;
|
|
346
|
+
return extractNodeFromOutput(output).nodeType === "ASYNC_RESOLUTION";
|
|
347
|
+
},
|
|
348
|
+
isCustomModule: ({ context }) => {
|
|
349
|
+
return context.currentNode?.moduleKey === "CUSTOM_MODULE";
|
|
350
|
+
},
|
|
351
|
+
shouldEnterHome: ({ event }) => {
|
|
352
|
+
const result = event.output;
|
|
353
|
+
if (!result || result.currentNode.nodeType !== "MODULE") return false;
|
|
354
|
+
if (result.workflowConfig.disableLaunchScreen === true) return false;
|
|
355
|
+
if (result.currentNode.moduleKey === "REDIRECT_TO_MOBILE") return false;
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}).createMachine({
|
|
360
|
+
id: "workflow",
|
|
361
|
+
initial: "idle",
|
|
362
|
+
context: ({ input }) => ({
|
|
363
|
+
workflowConfig: void 0,
|
|
364
|
+
currentNode: void 0,
|
|
365
|
+
firstNode: void 0,
|
|
366
|
+
resolvedMachine: void 0,
|
|
367
|
+
error: void 0,
|
|
368
|
+
errorCode: void 0,
|
|
369
|
+
registeredModules: input.modules,
|
|
370
|
+
configMappers: input.configMappers ?? {},
|
|
371
|
+
finishStatus: void 0,
|
|
372
|
+
customModuleCallback: input.customModuleCallback,
|
|
373
|
+
interviewId: input.interviewId ?? "",
|
|
374
|
+
isDesktop: input.isDesktop ?? true,
|
|
375
|
+
isInjectedNode: false,
|
|
376
|
+
isHomeContinueLoading: false,
|
|
377
|
+
getFinishStatus: input.getFinishStatus ?? getFinishStatus
|
|
378
|
+
}),
|
|
379
|
+
states: {
|
|
380
|
+
idle: { on: { LOAD: "loading" } },
|
|
381
|
+
loading: { invoke: {
|
|
382
|
+
id: "loadWorkflow",
|
|
383
|
+
src: "loadWorkflow",
|
|
384
|
+
input: ({ context }) => ({ isDesktop: context.isDesktop }),
|
|
385
|
+
onDone: [
|
|
386
|
+
{
|
|
387
|
+
target: "home",
|
|
388
|
+
guard: "shouldEnterHome",
|
|
389
|
+
actions: "setLoadingResult"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
target: "resolvingModule",
|
|
393
|
+
guard: "isModuleNode",
|
|
394
|
+
actions: "setLoadingResult"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
target: "completing",
|
|
398
|
+
guard: "isFinishNode",
|
|
399
|
+
actions: "setLoadingResult"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
target: "asyncResolution",
|
|
403
|
+
guard: "isAsyncResolutionNode",
|
|
404
|
+
actions: "setLoadingResult"
|
|
405
|
+
}
|
|
406
|
+
],
|
|
407
|
+
onError: {
|
|
408
|
+
target: "error",
|
|
409
|
+
actions: "setError"
|
|
410
|
+
}
|
|
411
|
+
} },
|
|
412
|
+
home: { on: { HOME_CONTINUE: {
|
|
413
|
+
target: "resolvingModule",
|
|
414
|
+
actions: "setHomeContinueLoading"
|
|
415
|
+
} } },
|
|
416
|
+
resolvingModule: {
|
|
417
|
+
always: [{
|
|
418
|
+
target: "handlingCustomModule",
|
|
419
|
+
guard: "isCustomModule"
|
|
420
|
+
}],
|
|
421
|
+
invoke: {
|
|
422
|
+
id: "resolveModule",
|
|
423
|
+
src: "resolveModule",
|
|
424
|
+
input: ({ context }) => ({
|
|
425
|
+
moduleKey: context.currentNode.moduleKey,
|
|
426
|
+
registeredModules: context.registeredModules
|
|
427
|
+
}),
|
|
428
|
+
onDone: {
|
|
429
|
+
target: "runningModule",
|
|
430
|
+
actions: "setResolvedMachine"
|
|
431
|
+
},
|
|
432
|
+
onError: {
|
|
433
|
+
target: "error",
|
|
434
|
+
actions: "setError"
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
runningModule: {
|
|
439
|
+
entry: "clearHomeContinueLoading",
|
|
440
|
+
invoke: {
|
|
441
|
+
id: "currentModule",
|
|
442
|
+
src: "runChildModule",
|
|
443
|
+
input: ({ context }) => {
|
|
444
|
+
const config = applyConfigMapper(context.currentNode?.moduleKey, {
|
|
445
|
+
...context.currentNode?.moduleConfiguration,
|
|
446
|
+
ds: context.workflowConfig?.ds
|
|
447
|
+
}, context.configMappers);
|
|
448
|
+
return {
|
|
449
|
+
machine: context.resolvedMachine,
|
|
450
|
+
config
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
on: {
|
|
455
|
+
MODULE_COMPLETE: "processingNode",
|
|
456
|
+
MODULE_ERROR: {
|
|
457
|
+
target: "error",
|
|
458
|
+
actions: "setModuleError"
|
|
459
|
+
},
|
|
460
|
+
COMPLETE_FLOW: "completing"
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
handlingCustomModule: { invoke: {
|
|
464
|
+
id: "customModule",
|
|
465
|
+
src: "handleCustomModule",
|
|
466
|
+
input: ({ context }) => ({
|
|
467
|
+
currentNode: context.currentNode,
|
|
468
|
+
interviewId: context.interviewId,
|
|
469
|
+
customModuleCallback: context.customModuleCallback
|
|
470
|
+
}),
|
|
471
|
+
onDone: [
|
|
472
|
+
{
|
|
473
|
+
target: "resolvingModule",
|
|
474
|
+
guard: "isModuleNode",
|
|
475
|
+
actions: "setCustomModuleResult"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
target: "completing",
|
|
479
|
+
guard: "isFinishNode",
|
|
480
|
+
actions: "setCustomModuleResult"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
target: "asyncResolution",
|
|
484
|
+
guard: "isAsyncResolutionNode",
|
|
485
|
+
actions: "setCustomModuleResult"
|
|
486
|
+
}
|
|
487
|
+
],
|
|
488
|
+
onError: {
|
|
489
|
+
target: "error",
|
|
490
|
+
actions: "setError"
|
|
491
|
+
}
|
|
492
|
+
} },
|
|
493
|
+
processingNode: { invoke: {
|
|
494
|
+
id: "processNext",
|
|
495
|
+
src: "processNextNode",
|
|
496
|
+
input: ({ context }) => ({
|
|
497
|
+
isInjectedNode: context.isInjectedNode,
|
|
498
|
+
firstNode: context.firstNode,
|
|
499
|
+
currentNodeModuleKey: context.currentNode?.moduleKey,
|
|
500
|
+
workflowConfigId: context.workflowConfig?.id,
|
|
501
|
+
workflowRedirectDesktopToMobile: context.workflowConfig?.redirectDesktopToMobile ?? false,
|
|
502
|
+
workflowDisableSmsOption: context.workflowConfig?.disableSmsOption ?? false,
|
|
503
|
+
workflowAddContinueToDesktop: context.workflowConfig?.addContinueToDesktop ?? false,
|
|
504
|
+
workflowQrPhishingResistance: context.workflowConfig?.qrPhishingResistance ?? false,
|
|
505
|
+
isDesktop: context.isDesktop
|
|
506
|
+
}),
|
|
507
|
+
onDone: [
|
|
508
|
+
{
|
|
509
|
+
target: "resolvingModule",
|
|
510
|
+
guard: "isModuleNode",
|
|
511
|
+
actions: "setNextNode",
|
|
512
|
+
reenter: true
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
target: "completing",
|
|
516
|
+
guard: "isFinishNode",
|
|
517
|
+
actions: "setNextNode"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
target: "asyncResolution",
|
|
521
|
+
guard: "isAsyncResolutionNode",
|
|
522
|
+
actions: "setNextNode"
|
|
523
|
+
}
|
|
524
|
+
],
|
|
525
|
+
onError: {
|
|
526
|
+
target: "error",
|
|
527
|
+
actions: "setError"
|
|
528
|
+
}
|
|
529
|
+
} },
|
|
530
|
+
completing: { invoke: {
|
|
531
|
+
id: "notifyBackend",
|
|
532
|
+
src: "notifyBackend",
|
|
533
|
+
input: ({ context }) => ({
|
|
534
|
+
getFinishStatus: context.getFinishStatus,
|
|
535
|
+
workflowId: context.workflowConfig?.id
|
|
536
|
+
}),
|
|
537
|
+
onDone: {
|
|
538
|
+
target: "finished",
|
|
539
|
+
actions: "setFinishStatus"
|
|
540
|
+
},
|
|
541
|
+
onError: {
|
|
542
|
+
target: "error",
|
|
543
|
+
actions: "setError"
|
|
544
|
+
}
|
|
545
|
+
} },
|
|
546
|
+
finished: { type: "final" },
|
|
547
|
+
asyncResolution: { type: "final" },
|
|
548
|
+
closed: { type: "final" },
|
|
549
|
+
error: { type: "final" }
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/modules/workflow/workflowActor.ts
|
|
555
|
+
function createWorkflowActor(options) {
|
|
556
|
+
return createActor(workflowMachine, { input: {
|
|
557
|
+
modules: options.modules,
|
|
558
|
+
configMappers: options.configMappers,
|
|
559
|
+
customModuleCallback: options.customModuleCallback,
|
|
560
|
+
interviewId: options.interviewId,
|
|
561
|
+
isDesktop: options.isDesktop
|
|
562
|
+
} }).start();
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/internal/orchestration/identity-search/identitySearchStateMachine.ts
|
|
567
|
+
const identitySearchMachine = setup({ types: {
|
|
568
|
+
context: {},
|
|
569
|
+
input: {}
|
|
570
|
+
} }).createMachine({
|
|
571
|
+
id: "identitySearch",
|
|
572
|
+
initial: "done",
|
|
573
|
+
context: {},
|
|
574
|
+
states: { done: { type: "final" } }
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/modules/workflow/workflowManager.ts
|
|
579
|
+
const WORKFLOW_DEFAULT_MODULES = {
|
|
580
|
+
...DEFAULT_MODULE_REGISTRY,
|
|
581
|
+
IDENTITY_SEARCH: identitySearchMachine,
|
|
582
|
+
ID_CAPTURE: idCaptureMachine,
|
|
583
|
+
ID: idVerificationMachine,
|
|
584
|
+
REDIRECT_TO_MOBILE: redirectToMobileMachine
|
|
585
|
+
};
|
|
586
|
+
function deriveHomeScreen(snapshot) {
|
|
587
|
+
return {
|
|
588
|
+
visible: snapshot.matches("home"),
|
|
589
|
+
isContinueLoading: snapshot.context.isHomeContinueLoading
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Builds the current node's config and applies the module-specific config
|
|
594
|
+
* mapper (if any). Single source of truth for the shape consumers see —
|
|
595
|
+
* used by both `mapState` and `getModuleConfig`. The same `applyConfigMapper`
|
|
596
|
+
* is invoked at the child-actor boundary in `workflowStateMachine` so all
|
|
597
|
+
* surfaces agree.
|
|
598
|
+
*/
|
|
599
|
+
function resolveCurrentModuleConfig(moduleKey, moduleConfiguration, ds, mappers) {
|
|
600
|
+
return applyConfigMapper(moduleKey, {
|
|
601
|
+
...moduleConfiguration ?? {},
|
|
602
|
+
ds
|
|
603
|
+
}, mappers);
|
|
604
|
+
}
|
|
605
|
+
function mapState(snapshot) {
|
|
606
|
+
const { context } = snapshot;
|
|
607
|
+
const homeScreen = deriveHomeScreen(snapshot);
|
|
608
|
+
if (snapshot.matches("idle")) return {
|
|
609
|
+
status: "idle",
|
|
610
|
+
homeScreen
|
|
611
|
+
};
|
|
612
|
+
if (snapshot.matches("runningModule")) {
|
|
613
|
+
const childSnapshot = snapshot.children.currentModule?.getSnapshot();
|
|
614
|
+
return {
|
|
615
|
+
status: "ready",
|
|
616
|
+
workflowConfig: context.workflowConfig,
|
|
617
|
+
currentNode: context.currentNode,
|
|
618
|
+
config: resolveCurrentModuleConfig(context.currentNode?.moduleKey, context.currentNode?.moduleConfiguration, context.workflowConfig?.ds, context.configMappers),
|
|
619
|
+
moduleState: childSnapshot ?? null,
|
|
620
|
+
homeScreen
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
if (snapshot.matches("finished")) return {
|
|
624
|
+
status: "finished",
|
|
625
|
+
workflowConfig: context.workflowConfig,
|
|
626
|
+
finishStatus: context.finishStatus ?? {
|
|
627
|
+
redirectionUrl: "",
|
|
628
|
+
action: "none",
|
|
629
|
+
scoreStatus: "UNKNOWN"
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
if (snapshot.matches("asyncResolution")) return {
|
|
633
|
+
status: "asyncResolution",
|
|
634
|
+
workflowConfig: context.workflowConfig,
|
|
635
|
+
currentNode: context.currentNode
|
|
636
|
+
};
|
|
637
|
+
if (snapshot.matches("closed")) return { status: "closed" };
|
|
638
|
+
if (snapshot.matches("error")) return {
|
|
639
|
+
status: "error",
|
|
640
|
+
error: context.error ?? "Unknown error",
|
|
641
|
+
errorCode: context.errorCode
|
|
642
|
+
};
|
|
643
|
+
return {
|
|
644
|
+
status: "loading",
|
|
645
|
+
homeScreen
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function createApi({ actor, getSnapshot, trackElementClicked }) {
|
|
649
|
+
return {
|
|
650
|
+
load() {
|
|
651
|
+
actor.send({ type: "LOAD" });
|
|
652
|
+
},
|
|
653
|
+
completeModule() {
|
|
654
|
+
trackElementClicked?.("completeModule");
|
|
655
|
+
actor.send({ type: "MODULE_COMPLETE" });
|
|
656
|
+
},
|
|
657
|
+
completeFlow() {
|
|
658
|
+
trackElementClicked?.("completeFlow");
|
|
659
|
+
actor.send({ type: "COMPLETE_FLOW" });
|
|
660
|
+
},
|
|
661
|
+
errorModule(error) {
|
|
662
|
+
actor.send({
|
|
663
|
+
type: "MODULE_ERROR",
|
|
664
|
+
error
|
|
665
|
+
});
|
|
666
|
+
},
|
|
667
|
+
continueFromHome() {
|
|
668
|
+
trackElementClicked?.("homeContinue");
|
|
669
|
+
actor.send({ type: "HOME_CONTINUE" });
|
|
670
|
+
},
|
|
671
|
+
getModuleConfig() {
|
|
672
|
+
const snapshot = getSnapshot();
|
|
673
|
+
if (snapshot.value !== "runningModule") return void 0;
|
|
674
|
+
return resolveCurrentModuleConfig(snapshot.context.currentNode?.moduleKey, snapshot.context.currentNode?.moduleConfiguration, snapshot.context.workflowConfig?.ds, snapshot.context.configMappers);
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Creates a workflow manager for server-driven onboarding flows.
|
|
680
|
+
*
|
|
681
|
+
* Only one orchestrator (Flow or Workflow) should be active per session.
|
|
682
|
+
* Each session token maps to a single orchestrator run. To start a new
|
|
683
|
+
* workflow, create a new session and call `setup()` with the new token
|
|
684
|
+
* before creating a new manager.
|
|
685
|
+
*/
|
|
686
|
+
function createWorkflowManager(options = {}) {
|
|
687
|
+
return attachFlowEventEmitter(createManager({
|
|
688
|
+
actor: createWorkflowActor({
|
|
689
|
+
modules: WORKFLOW_DEFAULT_MODULES,
|
|
690
|
+
configMappers: DEFAULT_MODULE_CONFIG_MAPPERS,
|
|
691
|
+
customModuleCallback: options.customModuleCallback,
|
|
692
|
+
interviewId: options.interviewId,
|
|
693
|
+
isDesktop: options.isDesktop
|
|
694
|
+
}),
|
|
695
|
+
mapState,
|
|
696
|
+
createApi,
|
|
697
|
+
instrumentation: createManagerInstrumentation("WORKFLOW")
|
|
698
|
+
}), { interviewId: options.interviewId });
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
//#endregion
|
|
702
|
+
export { createWorkflowManager, workflowMachine };
|