@incodetech/core 2.0.0-rc.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/package.json +3 -3
  2. package/dist/Actor-CI32dTbG.d.ts +0 -2
  3. package/dist/BaseWasmProvider-C_DLEI40.esm.js +0 -1118
  4. package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +0 -55
  5. package/dist/BrowserTimerProvider-DhNc_x02.esm.js +0 -22
  6. package/dist/ITimerCapability-C67ZRskg.esm.js +0 -7
  7. package/dist/IpifyProvider-D7jx52AL.esm.js +0 -139
  8. package/dist/Manager-C8PrhBOx.d.ts +0 -19
  9. package/dist/MotionSensorProvider-4v7xkqAp.esm.js +0 -254
  10. package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +0 -87
  11. package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
  12. package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
  13. package/dist/addressSearch-BpTbTWCa.esm.js +0 -430
  14. package/dist/ae-signature-DDDZmWXj.esm.js +0 -12
  15. package/dist/ae-signature.d.ts +0 -25
  16. package/dist/ae-signature.esm.js +0 -8
  17. package/dist/antifraud.d.ts +0 -57
  18. package/dist/antifraud.esm.js +0 -45
  19. package/dist/antifraudStateMachine-O0TMf6yc.esm.js +0 -39
  20. package/dist/api-CESGtpbH.esm.js +0 -53
  21. package/dist/authentication.d.ts +0 -12
  22. package/dist/authentication.esm.js +0 -25
  23. package/dist/authenticationManager-5M-fKzXx.esm.js +0 -67
  24. package/dist/authenticationManager-C83GNIhl.d.ts +0 -66
  25. package/dist/authenticationStateMachine-BMZqatiF.esm.js +0 -139
  26. package/dist/backCameraStream-DMdMeGk2.esm.js +0 -346
  27. package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
  28. package/dist/camera-DBSxa6ML.d.ts +0 -4
  29. package/dist/camera-PA2Ljri3.esm.js +0 -22
  30. package/dist/camera.d.ts +0 -15
  31. package/dist/camera.esm.js +0 -5
  32. package/dist/chunk-CRF6K_H_.esm.js +0 -49
  33. package/dist/consent.d.ts +0 -398
  34. package/dist/consent.esm.js +0 -79
  35. package/dist/consentStateMachine-CCT-B60O.esm.js +0 -151
  36. package/dist/cpf-PPz2Njto.esm.js +0 -38
  37. package/dist/cpf-ocr.d.ts +0 -204
  38. package/dist/cpf-ocr.esm.js +0 -177
  39. package/dist/cross-document-data-match.d.ts +0 -34
  40. package/dist/cross-document-data-match.esm.js +0 -71
  41. package/dist/curp-validation.d.ts +0 -188
  42. package/dist/curp-validation.esm.js +0 -110
  43. package/dist/curpValidationStateMachine-CitWLr2c.esm.js +0 -595
  44. package/dist/custom-fields.d.ts +0 -115
  45. package/dist/custom-fields.esm.js +0 -177
  46. package/dist/custom-watchlist.d.ts +0 -66
  47. package/dist/custom-watchlist.esm.js +0 -86
  48. package/dist/dateUtils-UoN5xswP.esm.js +0 -23
  49. package/dist/deepsightLoader-Cm4JIT_z.esm.js +0 -52
  50. package/dist/deepsightService-CEVxzehb.d.ts +0 -412
  51. package/dist/deepsightService-O74l4Y__.esm.js +0 -489
  52. package/dist/device.d.ts +0 -46
  53. package/dist/device.esm.js +0 -106
  54. package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
  55. package/dist/document-capture.d.ts +0 -906
  56. package/dist/document-capture.esm.js +0 -156
  57. package/dist/document-upload.d.ts +0 -331
  58. package/dist/document-upload.esm.js +0 -203
  59. package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +0 -394
  60. package/dist/dynamic-forms.d.ts +0 -178
  61. package/dist/dynamic-forms.esm.js +0 -323
  62. package/dist/ekyb.d.ts +0 -148
  63. package/dist/ekyb.esm.js +0 -127
  64. package/dist/ekybStateMachine-B59rQjgj.esm.js +0 -674
  65. package/dist/ekyc.d.ts +0 -164
  66. package/dist/ekyc.esm.js +0 -104
  67. package/dist/ekycStateMachine-oeO0Iekd.esm.js +0 -10626
  68. package/dist/electronic-signature.d.ts +0 -4
  69. package/dist/electronic-signature.esm.js +0 -7
  70. package/dist/electronicSignatureManager-D9OHzTpG.esm.js +0 -428
  71. package/dist/email.d.ts +0 -4
  72. package/dist/email.esm.js +0 -9
  73. package/dist/emailManager-DIfnS5g1.d.ts +0 -352
  74. package/dist/emailManager-wAV0LE-H.esm.js +0 -238
  75. package/dist/emailStateMachine-DOf4j58N.esm.js +0 -292
  76. package/dist/endpoints-CnN3SyDa.esm.js +0 -87
  77. package/dist/events-D6-e4vok.esm.js +0 -596
  78. package/dist/events.d.ts +0 -265
  79. package/dist/events.esm.js +0 -4
  80. package/dist/extensibility.d.ts +0 -122
  81. package/dist/extensibility.esm.js +0 -43
  82. package/dist/face-match.d.ts +0 -228
  83. package/dist/face-match.esm.js +0 -173
  84. package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +0 -290
  85. package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +0 -690
  86. package/dist/faceCaptureSetup-B3faSpYA.esm.js +0 -873
  87. package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +0 -127
  88. package/dist/flow-events.d.ts +0 -6
  89. package/dist/flow-events.esm.js +0 -0
  90. package/dist/flow.d.ts +0 -358
  91. package/dist/flow.esm.js +0 -825
  92. package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
  93. package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
  94. package/dist/flowServices-DTsm-Vf1.esm.js +0 -188
  95. package/dist/geolocation.d.ts +0 -127
  96. package/dist/geolocation.esm.js +0 -89
  97. package/dist/geolocationStateMachine-asasuHY2.esm.js +0 -105
  98. package/dist/getBrowser-BSXUTWXw.esm.js +0 -41
  99. package/dist/getDeviceClass-BSntT9_j.esm.js +0 -14
  100. package/dist/government-validation.d.ts +0 -67
  101. package/dist/government-validation.esm.js +0 -81
  102. package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +0 -271
  103. package/dist/home.d.ts +0 -99
  104. package/dist/home.esm.js +0 -61
  105. package/dist/http.d.ts +0 -68
  106. package/dist/http.esm.js +0 -3
  107. package/dist/id-ocr.d.ts +0 -635
  108. package/dist/id-ocr.esm.js +0 -86
  109. package/dist/id-verification.d.ts +0 -190
  110. package/dist/id-verification.esm.js +0 -43
  111. package/dist/id.d.ts +0 -24
  112. package/dist/id.esm.js +0 -164
  113. package/dist/idCaptureManager-B9TGA5dq.d.ts +0 -956
  114. package/dist/idCaptureManager-DMK0GIt3.esm.js +0 -581
  115. package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +0 -2954
  116. package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +0 -388
  117. package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +0 -71
  118. package/dist/identity-reuse.d.ts +0 -530
  119. package/dist/identity-reuse.esm.js +0 -274
  120. package/dist/index-BLKtMA0g.d.ts +0 -1177
  121. package/dist/index-BcRG8rtJ.d.ts +0 -97
  122. package/dist/index.d.ts +0 -3
  123. package/dist/index.esm.js +0 -12
  124. package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +0 -30
  125. package/dist/lib-BB0B_qQX.esm.js +0 -12499
  126. package/dist/mandatory-consent.d.ts +0 -412
  127. package/dist/mandatory-consent.esm.js +0 -78
  128. package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +0 -126
  129. package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
  130. package/dist/openviduLazy-Cok70ZSg.esm.js +0 -12
  131. package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
  132. package/dist/phone.d.ts +0 -4
  133. package/dist/phone.esm.js +0 -9
  134. package/dist/phoneManager-B6M30hKE.d.ts +0 -397
  135. package/dist/phoneManager-DAJbGhlY.esm.js +0 -256
  136. package/dist/phoneStateMachine-CuPARRaT.esm.js +0 -351
  137. package/dist/platform-CfrjKhmi.esm.js +0 -83
  138. package/dist/qe-signature-DFo_Cc-I.esm.js +0 -12
  139. package/dist/qe-signature.d.ts +0 -25
  140. package/dist/qe-signature.esm.js +0 -8
  141. package/dist/recordingService-Ig2UgbLv.esm.js +0 -1003
  142. package/dist/redirect-to-mobile.d.ts +0 -107
  143. package/dist/redirect-to-mobile.esm.js +0 -102
  144. package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +0 -249
  145. package/dist/runChildModule-CqqwqAkW.esm.js +0 -219
  146. package/dist/selfie.d.ts +0 -26
  147. package/dist/selfie.esm.js +0 -146
  148. package/dist/selfieManager-D0lSgd-J.d.ts +0 -68
  149. package/dist/selfieManager-Duisl7qN.esm.js +0 -60
  150. package/dist/selfieStateMachine-D76whWEf.esm.js +0 -68
  151. package/dist/session-BS-d_vuE.esm.js +0 -3206
  152. package/dist/session.d.ts +0 -217
  153. package/dist/session.esm.js +0 -9
  154. package/dist/setup-Buy-hyj4.esm.js +0 -887
  155. package/dist/setup-C5AITV8m.d.ts +0 -254
  156. package/dist/signature.d.ts +0 -94
  157. package/dist/signature.esm.js +0 -66
  158. package/dist/signatureStateMachine-B5-QVUve.esm.js +0 -132
  159. package/dist/stats-CIfiPzb1.esm.js +0 -16
  160. package/dist/stats.d.ts +0 -16
  161. package/dist/stats.esm.js +0 -4
  162. package/dist/trust-graph.d.ts +0 -54
  163. package/dist/trust-graph.esm.js +0 -56
  164. package/dist/types-B06Ypu2F.d.ts +0 -49
  165. package/dist/types-BP1m8VRw.d.ts +0 -340
  166. package/dist/types-CAD4va6a.d.ts +0 -5
  167. package/dist/types-CFV9G_7j.d.ts +0 -24
  168. package/dist/warmup-CEcppFiS.d.ts +0 -63
  169. package/dist/wasm.d.ts +0 -15
  170. package/dist/wasm.esm.js +0 -12
  171. package/dist/watchlist-for-business.d.ts +0 -79
  172. package/dist/watchlist-for-business.esm.js +0 -148
  173. package/dist/watchlist.d.ts +0 -62
  174. package/dist/watchlist.esm.js +0 -86
  175. package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
  176. package/dist/workflow.d.ts +0 -907
  177. package/dist/workflow.esm.js +0 -702
  178. package/dist/xstate.esm-B70JrNqo.esm.js +0 -3404
@@ -1,323 +0,0 @@
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 DELETED
@@ -1,148 +0,0 @@
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 };
package/dist/ekyb.esm.js DELETED
@@ -1,127 +0,0 @@
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-BS-d_vuE.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-B59rQjgj.esm.js";
10
- import "./addressSearch-BpTbTWCa.esm.js";
11
- import "./flowServices-DTsm-Vf1.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 };