@incodetech/core 2.0.0 → 2.0.1-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.
Files changed (178) hide show
  1. package/dist/Actor-CI32dTbG.d.ts +2 -0
  2. package/dist/BaseWasmProvider-C_DLEI40.esm.js +1118 -0
  3. package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +55 -0
  4. package/dist/BrowserTimerProvider-DhNc_x02.esm.js +22 -0
  5. package/dist/ITimerCapability-C67ZRskg.esm.js +7 -0
  6. package/dist/IpifyProvider-D7jx52AL.esm.js +139 -0
  7. package/dist/Manager-C8PrhBOx.d.ts +19 -0
  8. package/dist/MotionSensorProvider-4v7xkqAp.esm.js +254 -0
  9. package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +87 -0
  10. package/dist/StateMachine-BCQrZJhf.d.ts +2 -0
  11. package/dist/WasmUtilProvider-j98OJf-S.esm.js +114 -0
  12. package/dist/addressSearch-BpTbTWCa.esm.js +430 -0
  13. package/dist/ae-signature-DDDZmWXj.esm.js +12 -0
  14. package/dist/ae-signature.d.ts +25 -0
  15. package/dist/ae-signature.esm.js +8 -0
  16. package/dist/antifraud.d.ts +57 -0
  17. package/dist/antifraud.esm.js +45 -0
  18. package/dist/antifraudStateMachine-O0TMf6yc.esm.js +39 -0
  19. package/dist/api-CESGtpbH.esm.js +53 -0
  20. package/dist/authentication.d.ts +12 -0
  21. package/dist/authentication.esm.js +25 -0
  22. package/dist/authenticationManager-5M-fKzXx.esm.js +67 -0
  23. package/dist/authenticationManager-C83GNIhl.d.ts +66 -0
  24. package/dist/authenticationStateMachine-BMZqatiF.esm.js +139 -0
  25. package/dist/backCameraStream-DMdMeGk2.esm.js +346 -0
  26. package/dist/browserSimulation-gxD8cSpM.esm.js +20 -0
  27. package/dist/camera-DBSxa6ML.d.ts +4 -0
  28. package/dist/camera-PA2Ljri3.esm.js +22 -0
  29. package/dist/camera.d.ts +15 -0
  30. package/dist/camera.esm.js +5 -0
  31. package/dist/chunk-CRF6K_H_.esm.js +49 -0
  32. package/dist/consent.d.ts +398 -0
  33. package/dist/consent.esm.js +79 -0
  34. package/dist/consentStateMachine-CCT-B60O.esm.js +151 -0
  35. package/dist/cpf-PPz2Njto.esm.js +38 -0
  36. package/dist/cpf-ocr.d.ts +204 -0
  37. package/dist/cpf-ocr.esm.js +177 -0
  38. package/dist/cross-document-data-match.d.ts +34 -0
  39. package/dist/cross-document-data-match.esm.js +71 -0
  40. package/dist/curp-validation.d.ts +188 -0
  41. package/dist/curp-validation.esm.js +110 -0
  42. package/dist/curpValidationStateMachine-CitWLr2c.esm.js +595 -0
  43. package/dist/custom-fields.d.ts +115 -0
  44. package/dist/custom-fields.esm.js +177 -0
  45. package/dist/custom-watchlist.d.ts +66 -0
  46. package/dist/custom-watchlist.esm.js +86 -0
  47. package/dist/dateUtils-UoN5xswP.esm.js +23 -0
  48. package/dist/deepsightLoader-Cm4JIT_z.esm.js +52 -0
  49. package/dist/deepsightService-CEVxzehb.d.ts +412 -0
  50. package/dist/deepsightService-O74l4Y__.esm.js +489 -0
  51. package/dist/device.d.ts +46 -0
  52. package/dist/device.esm.js +106 -0
  53. package/dist/displayErrors-DqJ_IbsG.d.ts +39 -0
  54. package/dist/document-capture.d.ts +906 -0
  55. package/dist/document-capture.esm.js +156 -0
  56. package/dist/document-upload.d.ts +331 -0
  57. package/dist/document-upload.esm.js +203 -0
  58. package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +394 -0
  59. package/dist/dynamic-forms.d.ts +178 -0
  60. package/dist/dynamic-forms.esm.js +323 -0
  61. package/dist/ekyb.d.ts +148 -0
  62. package/dist/ekyb.esm.js +127 -0
  63. package/dist/ekybStateMachine-BR2let5f.esm.js +674 -0
  64. package/dist/ekyc.d.ts +164 -0
  65. package/dist/ekyc.esm.js +104 -0
  66. package/dist/ekycStateMachine-oeO0Iekd.esm.js +10626 -0
  67. package/dist/electronic-signature.d.ts +4 -0
  68. package/dist/electronic-signature.esm.js +7 -0
  69. package/dist/electronicSignatureManager-D9OHzTpG.esm.js +428 -0
  70. package/dist/email.d.ts +4 -0
  71. package/dist/email.esm.js +9 -0
  72. package/dist/emailManager-DIfnS5g1.d.ts +352 -0
  73. package/dist/emailManager-wAV0LE-H.esm.js +238 -0
  74. package/dist/emailStateMachine-DOf4j58N.esm.js +292 -0
  75. package/dist/endpoints-CnN3SyDa.esm.js +87 -0
  76. package/dist/events-D6-e4vok.esm.js +596 -0
  77. package/dist/events.d.ts +265 -0
  78. package/dist/events.esm.js +4 -0
  79. package/dist/extensibility.d.ts +122 -0
  80. package/dist/extensibility.esm.js +43 -0
  81. package/dist/face-match.d.ts +228 -0
  82. package/dist/face-match.esm.js +173 -0
  83. package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +290 -0
  84. package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +690 -0
  85. package/dist/faceCaptureSetup-B3faSpYA.esm.js +873 -0
  86. package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +127 -0
  87. package/dist/flow-events.d.ts +6 -0
  88. package/dist/flow-events.esm.js +0 -0
  89. package/dist/flow.d.ts +358 -0
  90. package/dist/flow.esm.js +825 -0
  91. package/dist/flowCompletionService-DhkT4SRY.d.ts +10 -0
  92. package/dist/flowCompletionService-P54yzGvA.esm.js +13 -0
  93. package/dist/flowServices-DG3IdWw6.esm.js +188 -0
  94. package/dist/geolocation.d.ts +127 -0
  95. package/dist/geolocation.esm.js +89 -0
  96. package/dist/geolocationStateMachine-asasuHY2.esm.js +105 -0
  97. package/dist/getBrowser-BSXUTWXw.esm.js +41 -0
  98. package/dist/getDeviceClass-BSntT9_j.esm.js +14 -0
  99. package/dist/government-validation.d.ts +67 -0
  100. package/dist/government-validation.esm.js +81 -0
  101. package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +271 -0
  102. package/dist/home.d.ts +99 -0
  103. package/dist/home.esm.js +61 -0
  104. package/dist/http.d.ts +68 -0
  105. package/dist/http.esm.js +3 -0
  106. package/dist/id-ocr.d.ts +635 -0
  107. package/dist/id-ocr.esm.js +86 -0
  108. package/dist/id-verification.d.ts +190 -0
  109. package/dist/id-verification.esm.js +43 -0
  110. package/dist/id.d.ts +24 -0
  111. package/dist/id.esm.js +164 -0
  112. package/dist/idCaptureManager-Fyd0eam-.d.ts +958 -0
  113. package/dist/idCaptureManager-ZPkD7Gjk.esm.js +581 -0
  114. package/dist/idCaptureStateMachine-BK0bPHoc.esm.js +2963 -0
  115. package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +388 -0
  116. package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +71 -0
  117. package/dist/identity-reuse.d.ts +530 -0
  118. package/dist/identity-reuse.esm.js +274 -0
  119. package/dist/index-BcRG8rtJ.d.ts +97 -0
  120. package/dist/index-DZoqeAo9.d.ts +1177 -0
  121. package/dist/index.d.ts +3 -0
  122. package/dist/index.esm.js +12 -0
  123. package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +30 -0
  124. package/dist/lib-BB0B_qQX.esm.js +12499 -0
  125. package/dist/mandatory-consent.d.ts +412 -0
  126. package/dist/mandatory-consent.esm.js +78 -0
  127. package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +126 -0
  128. package/dist/openviduLazy-Cm0XFh_v.esm.js +3 -0
  129. package/dist/openviduLazy-Cok70ZSg.esm.js +12 -0
  130. package/dist/permissionServices-D_i6nzEw.esm.js +50 -0
  131. package/dist/phone.d.ts +4 -0
  132. package/dist/phone.esm.js +9 -0
  133. package/dist/phoneManager-B6M30hKE.d.ts +397 -0
  134. package/dist/phoneManager-DAJbGhlY.esm.js +256 -0
  135. package/dist/phoneStateMachine-CuPARRaT.esm.js +351 -0
  136. package/dist/platform-CfrjKhmi.esm.js +83 -0
  137. package/dist/qe-signature-DFo_Cc-I.esm.js +12 -0
  138. package/dist/qe-signature.d.ts +25 -0
  139. package/dist/qe-signature.esm.js +8 -0
  140. package/dist/recordingService-Ig2UgbLv.esm.js +1003 -0
  141. package/dist/redirect-to-mobile.d.ts +107 -0
  142. package/dist/redirect-to-mobile.esm.js +102 -0
  143. package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +249 -0
  144. package/dist/runChildModule-CqqwqAkW.esm.js +219 -0
  145. package/dist/selfie.d.ts +26 -0
  146. package/dist/selfie.esm.js +146 -0
  147. package/dist/selfieManager-D0lSgd-J.d.ts +68 -0
  148. package/dist/selfieManager-Duisl7qN.esm.js +60 -0
  149. package/dist/selfieStateMachine-D76whWEf.esm.js +68 -0
  150. package/dist/session-CGtQJJzB.esm.js +3206 -0
  151. package/dist/session.d.ts +217 -0
  152. package/dist/session.esm.js +9 -0
  153. package/dist/setup-C5AITV8m.d.ts +254 -0
  154. package/dist/setup-DsM8IG7k.esm.js +887 -0
  155. package/dist/signature.d.ts +94 -0
  156. package/dist/signature.esm.js +66 -0
  157. package/dist/signatureStateMachine-B5-QVUve.esm.js +132 -0
  158. package/dist/stats-CIfiPzb1.esm.js +16 -0
  159. package/dist/stats.d.ts +16 -0
  160. package/dist/stats.esm.js +4 -0
  161. package/dist/trust-graph.d.ts +54 -0
  162. package/dist/trust-graph.esm.js +56 -0
  163. package/dist/types-B06Ypu2F.d.ts +49 -0
  164. package/dist/types-BP1m8VRw.d.ts +340 -0
  165. package/dist/types-CAD4va6a.d.ts +5 -0
  166. package/dist/types-CFV9G_7j.d.ts +24 -0
  167. package/dist/warmup-CEcppFiS.d.ts +63 -0
  168. package/dist/wasm.d.ts +15 -0
  169. package/dist/wasm.esm.js +12 -0
  170. package/dist/watchlist-for-business.d.ts +79 -0
  171. package/dist/watchlist-for-business.esm.js +148 -0
  172. package/dist/watchlist.d.ts +62 -0
  173. package/dist/watchlist.esm.js +86 -0
  174. package/dist/watchlistServices-DMbUhkBX.esm.js +12 -0
  175. package/dist/workflow.d.ts +907 -0
  176. package/dist/workflow.esm.js +702 -0
  177. package/dist/xstate.esm-B70JrNqo.esm.js +3404 -0
  178. package/package.json +1 -1
@@ -0,0 +1,323 @@
1
+ import { t as api } from "./api-CESGtpbH.esm.js";
2
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
3
+ import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
4
+ import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
5
+ import { t as validateCPF } from "./cpf-PPz2Njto.esm.js";
6
+ import { t as isoDateToMs } from "./dateUtils-UoN5xswP.esm.js";
7
+
8
+ //#region src/modules/dynamic-forms/dynamicFormsServices.ts
9
+ async function fetchForms(flowId, signal) {
10
+ const url = `${endpoints.moduleConfig}?id=${encodeURIComponent(flowId)}&moduleKey=DYNAMIC_FORMS`;
11
+ const res = await api.get(url, { signal });
12
+ if (!res.ok) throw new Error(`GET ${endpoints.moduleConfig} failed: ${res.status} ${res.statusText}`);
13
+ return res.data;
14
+ }
15
+ async function submitFormAnswer(params, signal) {
16
+ const res = await api.post(endpoints.dynamicFormsSubmitAnswer, {
17
+ questionId: params.questionId,
18
+ answerDetails: { singleAnswer: params.singleAnswer }
19
+ }, { signal });
20
+ if (!res.ok) throw new Error(`POST ${endpoints.dynamicFormsSubmitAnswer} failed: ${res.status} ${res.statusText}`);
21
+ return res.data;
22
+ }
23
+
24
+ //#endregion
25
+ //#region src/modules/dynamic-forms/dynamicFormsStateMachine.ts
26
+ /**
27
+ * Returns default answers for a screen, seeding 'NO' for every YESNO question.
28
+ * An untouched checkbox must submit a value — this is a domain rule, not a UI concern.
29
+ */
30
+ function seedDefaultAnswers(formScreen) {
31
+ if (!formScreen) return {};
32
+ const defaults = {};
33
+ for (const q of formScreen.questions) if ((q.inputType ?? q.overrides) === "YESNO") defaults[q.questionId] = "NO";
34
+ return defaults;
35
+ }
36
+ /**
37
+ * Transforms a raw answer value before submission based on question type.
38
+ * - CPF: strips formatting characters (dots and dash)
39
+ * - DATE: converts ISO date string (YYYY-MM-DD) to Unix milliseconds string
40
+ * - All others: pass through as-is
41
+ */
42
+ function transformAnswerValue(inputType, value) {
43
+ switch (inputType) {
44
+ case "CPF": return value.replace(/[-.]/g, "");
45
+ case "DATE": return isoDateToMs(value).toString();
46
+ default: return value;
47
+ }
48
+ }
49
+ const dynamicFormsMachine = setup({
50
+ types: {
51
+ context: {},
52
+ events: {},
53
+ input: {}
54
+ },
55
+ actors: {
56
+ fetchScreens: fromPromise(async ({ input, signal }) => {
57
+ return fetchForms(input.flowId, signal);
58
+ }),
59
+ submitScreenAnswers: fromPromise(async ({ input, signal }) => {
60
+ const { screen: formScreen, answers } = input;
61
+ for (const question of formScreen.questions) {
62
+ const singleAnswer = transformAnswerValue(question.inputType ?? question.overrides ?? "TEXT", answers[question.questionId] ?? "");
63
+ try {
64
+ await submitFormAnswer({
65
+ questionId: question.questionId,
66
+ singleAnswer
67
+ }, signal);
68
+ } catch {}
69
+ }
70
+ return { success: true };
71
+ })
72
+ },
73
+ actions: {
74
+ setScreens: assign(({ event }) => {
75
+ const screens = event.output.screens;
76
+ return {
77
+ screens,
78
+ answers: seedDefaultAnswers(screens[0])
79
+ };
80
+ }),
81
+ setAnswer: assign(({ context, event }) => {
82
+ const e = event;
83
+ const question = context.screens[context.currentScreenIndex]?.questions.find((q) => q.questionId === e.questionId);
84
+ const effectiveType = question?.inputType ?? question?.overrides;
85
+ const newAnswerValidity = { ...context.answerValidity };
86
+ if (effectiveType === "CPF") newAnswerValidity[e.questionId] = validateCPF(e.value);
87
+ return {
88
+ answers: {
89
+ ...context.answers,
90
+ [e.questionId]: e.value
91
+ },
92
+ answerValidity: newAnswerValidity
93
+ };
94
+ }),
95
+ setAnswerValidity: assign(({ context, event }) => {
96
+ const e = event;
97
+ return { answerValidity: {
98
+ ...context.answerValidity,
99
+ [e.questionId]: e.isValid
100
+ } };
101
+ }),
102
+ advanceScreen: assign(({ context }) => {
103
+ const nextIndex = context.currentScreenIndex + 1;
104
+ return {
105
+ currentScreenIndex: nextIndex,
106
+ answers: seedDefaultAnswers(context.screens[nextIndex]),
107
+ answerValidity: {}
108
+ };
109
+ }),
110
+ markCompleted: assign({ result: "completed" }),
111
+ markSkipped: assign({ result: "skipped" })
112
+ },
113
+ guards: {
114
+ hasPreloadedScreens: ({ context }) => (context.config.screens?.length ?? 0) > 0,
115
+ hasFlowId: ({ context }) => !!context.config.flowId,
116
+ isLastScreen: ({ context }) => context.currentScreenIndex >= context.screens.length - 1
117
+ }
118
+ }).createMachine({
119
+ id: "dynamicForms",
120
+ initial: "idle",
121
+ context: ({ input }) => {
122
+ const screens = input.config.screens ?? [];
123
+ return {
124
+ config: input.config,
125
+ screens,
126
+ currentScreenIndex: 0,
127
+ answers: seedDefaultAnswers(screens[0]),
128
+ answerValidity: {},
129
+ result: null
130
+ };
131
+ },
132
+ states: {
133
+ idle: { on: { LOAD: [
134
+ {
135
+ target: "inputting",
136
+ guard: "hasPreloadedScreens"
137
+ },
138
+ {
139
+ target: "loadingScreens",
140
+ guard: "hasFlowId"
141
+ },
142
+ { target: "misconfigured" }
143
+ ] } },
144
+ loadingScreens: { invoke: {
145
+ id: "fetchScreens",
146
+ src: "fetchScreens",
147
+ input: ({ context }) => ({ flowId: context.config.flowId ?? "" }),
148
+ onDone: {
149
+ target: "inputting",
150
+ actions: "setScreens"
151
+ },
152
+ onError: {
153
+ target: "finished",
154
+ actions: "markSkipped"
155
+ }
156
+ } },
157
+ inputting: { on: {
158
+ ANSWER_CHANGED: { actions: "setAnswer" },
159
+ ANSWER_VALIDITY_CHANGED: { actions: "setAnswerValidity" },
160
+ SUBMIT: { target: "submitting" }
161
+ } },
162
+ submitting: { invoke: {
163
+ id: "submitScreenAnswers",
164
+ src: "submitScreenAnswers",
165
+ input: ({ context }) => ({
166
+ screen: context.screens[context.currentScreenIndex],
167
+ answers: context.answers
168
+ }),
169
+ onDone: [{
170
+ target: "success",
171
+ guard: "isLastScreen"
172
+ }, {
173
+ target: "inputting",
174
+ actions: "advanceScreen"
175
+ }],
176
+ onError: [{
177
+ target: "success",
178
+ guard: "isLastScreen"
179
+ }, {
180
+ target: "inputting",
181
+ actions: "advanceScreen"
182
+ }]
183
+ } },
184
+ success: { after: { 3e3: {
185
+ target: "finished",
186
+ actions: "markCompleted"
187
+ } } },
188
+ finished: { type: "final" },
189
+ misconfigured: { on: { CLOSE: { target: "closed" } } },
190
+ closed: { type: "final" }
191
+ }
192
+ });
193
+
194
+ //#endregion
195
+ //#region src/modules/dynamic-forms/dynamicFormsActor.ts
196
+ function createDynamicFormsActor(options) {
197
+ return createActor(dynamicFormsMachine, { input: { config: options.config } }).start();
198
+ }
199
+
200
+ //#endregion
201
+ //#region src/modules/dynamic-forms/dynamicFormsManager.ts
202
+ /**
203
+ * @module @incodetech/core/dynamic-forms
204
+ *
205
+ * Dynamic Forms module for the Incode Web SDK.
206
+ * Drives multi-screen forms defined by backend configuration.
207
+ *
208
+ * @example Headless usage
209
+ * ```typescript
210
+ * import { createDynamicFormsManager } from '@incodetech/core/dynamic-forms';
211
+ * import { setup } from '@incodetech/core';
212
+ *
213
+ * setup({ apiURL: 'https://api.example.com', token: 'your-token' });
214
+ *
215
+ * const manager = createDynamicFormsManager({
216
+ * config: { flowId: 'flow-123' },
217
+ * });
218
+ *
219
+ * manager.subscribe((state) => {
220
+ * if (state.status === 'inputting') {
221
+ * console.log('Screen:', state.currentScreen.title);
222
+ * }
223
+ * if (state.status === 'finished') {
224
+ * console.log('Result:', state.result); // 'completed' | 'skipped'
225
+ * }
226
+ * });
227
+ *
228
+ * manager.load();
229
+ * manager.stop();
230
+ * ```
231
+ */
232
+ function isScreenComplete(answers, formScreen) {
233
+ return formScreen.questions.every((q) => {
234
+ if (q.isOptional) return true;
235
+ if ((q.inputType ?? q.overrides) === "YESNO") return true;
236
+ const value = answers[q.questionId];
237
+ return value !== void 0 && value !== "";
238
+ });
239
+ }
240
+ function mapState(snapshot) {
241
+ const typedSnapshot = snapshot;
242
+ const { context } = typedSnapshot;
243
+ if (typedSnapshot.matches("idle")) return { status: "idle" };
244
+ if (typedSnapshot.matches("loadingScreens")) return { status: "loadingScreens" };
245
+ if (typedSnapshot.matches("inputting")) {
246
+ const currentScreen = context.screens[context.currentScreenIndex];
247
+ const allFormatsValid = !Object.values(context.answerValidity).some((v) => v === false);
248
+ return {
249
+ status: "inputting",
250
+ currentScreen,
251
+ screenIndex: context.currentScreenIndex,
252
+ totalScreens: context.screens.length,
253
+ answers: context.answers,
254
+ answerValidity: context.answerValidity,
255
+ canSubmit: currentScreen ? isScreenComplete(context.answers, currentScreen) && allFormatsValid : false
256
+ };
257
+ }
258
+ if (typedSnapshot.matches("submitting")) {
259
+ const currentScreen = context.screens[context.currentScreenIndex];
260
+ return {
261
+ status: "submitting",
262
+ screenIndex: context.currentScreenIndex,
263
+ totalScreens: context.screens.length,
264
+ currentScreen,
265
+ answers: context.answers,
266
+ answerValidity: context.answerValidity
267
+ };
268
+ }
269
+ if (typedSnapshot.matches("success")) return { status: "success" };
270
+ if (typedSnapshot.matches("finished")) return {
271
+ status: "finished",
272
+ result: context.result
273
+ };
274
+ if (typedSnapshot.matches("misconfigured")) return { status: "misconfigured" };
275
+ if (typedSnapshot.matches("closed")) return { status: "closed" };
276
+ return { status: "idle" };
277
+ }
278
+ function createApi({ actor }) {
279
+ return {
280
+ load() {
281
+ actor.send({ type: "LOAD" });
282
+ },
283
+ setAnswer(questionId, value) {
284
+ actor.send({
285
+ type: "ANSWER_CHANGED",
286
+ questionId,
287
+ value
288
+ });
289
+ },
290
+ setAnswerValidity(questionId, isValid) {
291
+ actor.send({
292
+ type: "ANSWER_VALIDITY_CHANGED",
293
+ questionId,
294
+ isValid
295
+ });
296
+ },
297
+ submit() {
298
+ actor.send({ type: "SUBMIT" });
299
+ },
300
+ close() {
301
+ actor.send({ type: "CLOSE" });
302
+ }
303
+ };
304
+ }
305
+ /**
306
+ * Creates a dynamic forms manager for headless or UI-driven usage.
307
+ *
308
+ * @param options - Configuration options
309
+ * @param options.config - Dynamic forms configuration (flowId or pre-loaded screens)
310
+ *
311
+ * @returns Dynamic forms manager with state, API methods, and subscription
312
+ */
313
+ function createDynamicFormsManager(options) {
314
+ return createManager({
315
+ actor: createDynamicFormsActor(options),
316
+ mapState,
317
+ createApi,
318
+ instrumentation: createManagerInstrumentation(eventModuleNames.forms)
319
+ });
320
+ }
321
+
322
+ //#endregion
323
+ export { createDynamicFormsManager, dynamicFormsMachine };
package/dist/ekyb.d.ts ADDED
@@ -0,0 +1,148 @@
1
+ import { t as Manager } from "./Manager-C8PrhBOx.js";
2
+ import "./Actor-CI32dTbG.js";
3
+ import "./camera-DBSxa6ML.js";
4
+ import "./types-CFV9G_7j.js";
5
+ import { i as FlowModuleConfig } from "./types-BP1m8VRw.js";
6
+ import { n as AddressSuggestion, r as FieldDef, t as DisplayErrorsResult } from "./displayErrors-DqJ_IbsG.js";
7
+
8
+ //#region src/modules/ekyb/types.d.ts
9
+ type UboEntry = {
10
+ id: string;
11
+ name: string;
12
+ surname: string;
13
+ };
14
+ type EkybFormValues = {
15
+ country: string;
16
+ businessName?: string;
17
+ street?: string;
18
+ houseNo?: string;
19
+ addressLine2?: string;
20
+ city?: string;
21
+ state?: string;
22
+ postalCode?: string;
23
+ taxId?: string;
24
+ };
25
+ type EkybConfig = {
26
+ flowId?: string;
27
+ verificationFields?: string[];
28
+ checkBusinessName?: boolean;
29
+ checkAddress?: boolean;
30
+ checkTaxId?: boolean;
31
+ checkUniqueBeneficialOwner?: boolean;
32
+ };
33
+ type EkybFieldDef = FieldDef & {
34
+ optionalForCountries?: string[];
35
+ };
36
+ type EkybCountry = 'BR' | 'US' | 'GB' | 'ES' | 'IT' | 'FR' | 'DE' | 'IL' | 'MX' | 'CN' | 'NG' | 'CM' | 'KE';
37
+ //#endregion
38
+ //#region src/modules/ekyb/ekybStateMachine.d.ts
39
+ declare const ekybMachine: any;
40
+ //#endregion
41
+ //#region src/modules/ekyb/ekybActor.d.ts
42
+ type CreateEkybActorOptions = {
43
+ config: EkybConfig;
44
+ };
45
+ //#endregion
46
+ //#region src/modules/ekyb/ekybManager.d.ts
47
+ type EkybLoadingState = {
48
+ status: 'loading';
49
+ };
50
+ type EkybFormState = {
51
+ status: 'form';
52
+ country: string;
53
+ availableCountries: readonly string[];
54
+ fields: EkybFieldDef[];
55
+ values: EkybFormValues;
56
+ errors: Record<string, string>;
57
+ isValid: boolean;
58
+ ubos: UboEntry[];
59
+ canAddUbo: boolean;
60
+ addressSuggestions: AddressSuggestion[];
61
+ submitAttempted: boolean;
62
+ };
63
+ type EkybSubmittingState = {
64
+ status: 'submitting';
65
+ };
66
+ type EkybSuccessState = {
67
+ status: 'success';
68
+ };
69
+ type EkybErrorState = {
70
+ status: 'error';
71
+ errorMessage: string;
72
+ };
73
+ type EkybFinishedState = {
74
+ status: 'finished';
75
+ };
76
+ type EkybClosedState = {
77
+ status: 'closed';
78
+ };
79
+ /**
80
+ * Discriminated union of all possible eKYB manager states.
81
+ */
82
+ type EkybState = EkybLoadingState | EkybFormState | EkybSubmittingState | EkybSuccessState | EkybErrorState | EkybFinishedState | EkybClosedState;
83
+ /**
84
+ * Creates an eKYB manager for headless or UI-driven usage.
85
+ */
86
+ declare function createEkybManager(options: CreateEkybActorOptions): Manager<EkybState> & {
87
+ /** Initializes the eKYB flow — builds form fields from the provided config */
88
+ load(): void;
89
+ /** Sets the country and resets/revalidates fields */
90
+ setCountry(country: string): void;
91
+ /** Sets a form field value and triggers revalidation */
92
+ setField(name: string, value: string): void;
93
+ /** Adds a new UBO entry (max 8) */
94
+ addUbo(): void;
95
+ /** Removes a UBO entry by index */
96
+ removeUbo(index: number): void;
97
+ /** Sets a UBO field (name or surname) */
98
+ setUboField(index: number, field: "name" | "surname", value: string): void;
99
+ /** Searches for address suggestions (debounced) */
100
+ searchAddress(query: string): void;
101
+ /** Fills address fields from a selected suggestion */
102
+ selectAddress(suggestion: AddressSuggestion): void;
103
+ /** Submits the form (requires isValid to be true) */
104
+ submit(): void;
105
+ /** Retries from failure state, returning to the form */
106
+ retry(): void;
107
+ /** Closes/dismisses the module */
108
+ close(): void;
109
+ };
110
+ type EkybManager = ReturnType<typeof createEkybManager>;
111
+ //#endregion
112
+ //#region src/modules/ekyb/ekybActions.d.ts
113
+ declare function computeDisplayErrors(errors: Record<string, string>, touched: Record<string, boolean>, submitAttempted: boolean, country: string, fields?: EkybFieldDef[]): DisplayErrorsResult;
114
+ //#endregion
115
+ //#region src/modules/ekyb/ekybServices.d.ts
116
+ type EkybFlowConfig = FlowModuleConfig['EKYB'];
117
+ //#endregion
118
+ //#region src/modules/ekyb/ekybUtils.d.ts
119
+ /**
120
+ * Normalizes any supported eKYB config input into a manager-ready `EkybConfig`.
121
+ *
122
+ * Accepts either:
123
+ * - A manager-ready `EkybConfig` (with `flowId` or `verificationFields`) →
124
+ * returned unchanged.
125
+ * - A raw backend `EkybFlowConfig` (with `*Source` companions) → stripped to
126
+ * the four `check*` fields the manager consumes.
127
+ *
128
+ * Idempotent: `toEkybConfig(toEkybConfig(x))` equals `toEkybConfig(x)`.
129
+ */
130
+ declare function toEkybConfig(config: Partial<EkybFlowConfig> & Partial<EkybConfig>): EkybConfig;
131
+ //#endregion
132
+ //#region src/modules/ekyb/ekybConstants.d.ts
133
+ /**
134
+ * Countries available in all environments.
135
+ * Sorted alphabetically by display name.
136
+ */
137
+ declare const SUPPORTED_COUNTRIES: readonly EkybCountry[];
138
+ /**
139
+ * Additional countries available only in dev/staging environments.
140
+ */
141
+ declare const DEV_ONLY_COUNTRIES: readonly EkybCountry[];
142
+ /**
143
+ * Union of all recognized country codes (prod + dev).
144
+ */
145
+ declare const ALL_COUNTRIES: readonly EkybCountry[];
146
+ declare function isSupportedCountry(code: string): code is EkybCountry;
147
+ //#endregion
148
+ export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, type AddressSuggestion as EkybAddressSuggestion, type EkybConfig, type EkybCountry, type EkybFieldDef, type EkybFlowConfig, type EkybManager, type EkybState, SUPPORTED_COUNTRIES, type UboEntry, computeDisplayErrors as computeEkybDisplayErrors, createEkybManager, ekybMachine, isSupportedCountry, toEkybConfig };
@@ -0,0 +1,127 @@
1
+ import "./BrowserTimerProvider-DhNc_x02.esm.js";
2
+ import "./api-CESGtpbH.esm.js";
3
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
4
+ import "./endpoints-CnN3SyDa.esm.js";
5
+ import "./session-CGtQJJzB.esm.js";
6
+ import "./IpifyProvider-D7jx52AL.esm.js";
7
+ import "./browserSimulation-gxD8cSpM.esm.js";
8
+ import { c as createManager, s as createActor } from "./xstate.esm-B70JrNqo.esm.js";
9
+ import { a as DEV_ONLY_COUNTRIES, i as ALL_COUNTRIES, n as computeDisplayErrors, o as SUPPORTED_COUNTRIES, r as toEkybConfig, s as isSupportedCountry, t as ekybMachine } from "./ekybStateMachine-BR2let5f.esm.js";
10
+ import "./addressSearch-BpTbTWCa.esm.js";
11
+ import "./flowServices-DG3IdWw6.esm.js";
12
+
13
+ //#region src/modules/ekyb/ekybActor.ts
14
+ /**
15
+ * Creates and starts an eKYB actor.
16
+ * The actor begins directly in 'form' state (no loading phase).
17
+ */
18
+ function createEkybActor(options) {
19
+ return createActor(ekybMachine, { input: { config: options.config } }).start();
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/modules/ekyb/ekybManager.ts
24
+ function mapState(snapshot) {
25
+ const typedSnapshot = snapshot;
26
+ const { context } = typedSnapshot;
27
+ if (typedSnapshot.matches("idle") || typedSnapshot.matches("loading")) return { status: "loading" };
28
+ if (typedSnapshot.matches("form")) return {
29
+ status: "form",
30
+ country: context.country,
31
+ availableCountries: context.availableCountries,
32
+ fields: context.fields,
33
+ values: context.values,
34
+ errors: context.errors,
35
+ isValid: context.isValid,
36
+ ubos: context.ubos,
37
+ canAddUbo: context.canAddUbo,
38
+ addressSuggestions: context.addressSuggestions,
39
+ submitAttempted: context.submitAttempted
40
+ };
41
+ if (typedSnapshot.matches("submitting")) return { status: "submitting" };
42
+ if (typedSnapshot.matches("success")) return { status: "success" };
43
+ if (typedSnapshot.matches("error")) return {
44
+ status: "error",
45
+ errorMessage: context.errorMessage
46
+ };
47
+ if (typedSnapshot.matches("finished")) return { status: "finished" };
48
+ if (typedSnapshot.matches("closed")) return { status: "closed" };
49
+ return { status: "loading" };
50
+ }
51
+ function createApi({ actor, trackElementClicked }) {
52
+ return {
53
+ load() {
54
+ actor.send({ type: "LOAD" });
55
+ },
56
+ setCountry(country) {
57
+ actor.send({
58
+ type: "SET_COUNTRY",
59
+ country
60
+ });
61
+ },
62
+ setField(name, value) {
63
+ actor.send({
64
+ type: "SET_FIELD",
65
+ name,
66
+ value
67
+ });
68
+ },
69
+ addUbo() {
70
+ trackElementClicked?.("addUbo");
71
+ actor.send({ type: "ADD_UBO" });
72
+ },
73
+ removeUbo(index) {
74
+ trackElementClicked?.(`removeUbo.${index}`);
75
+ actor.send({
76
+ type: "REMOVE_UBO",
77
+ index
78
+ });
79
+ },
80
+ setUboField(index, field, value) {
81
+ actor.send({
82
+ type: "SET_UBO_FIELD",
83
+ index,
84
+ field,
85
+ value
86
+ });
87
+ },
88
+ searchAddress(query) {
89
+ actor.send({
90
+ type: "SEARCH_ADDRESS",
91
+ query
92
+ });
93
+ },
94
+ selectAddress(suggestion) {
95
+ actor.send({
96
+ type: "SELECT_ADDRESS",
97
+ suggestion
98
+ });
99
+ },
100
+ submit() {
101
+ trackElementClicked?.("submit");
102
+ actor.send({ type: "SUBMIT" });
103
+ },
104
+ retry() {
105
+ trackElementClicked?.("retry");
106
+ actor.send({ type: "RETRY" });
107
+ },
108
+ close() {
109
+ trackElementClicked?.("close");
110
+ actor.send({ type: "CLOSE" });
111
+ }
112
+ };
113
+ }
114
+ /**
115
+ * Creates an eKYB manager for headless or UI-driven usage.
116
+ */
117
+ function createEkybManager(options) {
118
+ return createManager({
119
+ actor: createEkybActor(options),
120
+ mapState,
121
+ createApi,
122
+ instrumentation: createManagerInstrumentation(eventModuleNames.ekyb)
123
+ });
124
+ }
125
+
126
+ //#endregion
127
+ export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, SUPPORTED_COUNTRIES, computeDisplayErrors as computeEkybDisplayErrors, createEkybManager, ekybMachine, isSupportedCountry, toEkybConfig };