@incodetech/core 0.0.0-dev-20260313-bc2dab4 → 0.0.0-dev-20260317-ce5d28b

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 (70) hide show
  1. package/dist/addressSearch-B446UZn4.esm.js +423 -0
  2. package/dist/authentication.d.ts +10 -10
  3. package/dist/authentication.esm.js +6 -6
  4. package/dist/{authenticationManager-DQL9XsaI.d.ts → authenticationManager-BWtUIJXV.d.ts} +2 -2
  5. package/dist/{authenticationManager-4j4j8ac9.esm.js → authenticationManager-IChdnUM9.esm.js} +3 -3
  6. package/dist/{backCameraStream-4aLwsDOv.esm.js → backCameraStream-DDzfvhxo.esm.js} +1 -1
  7. package/dist/curp-validation.d.ts +4 -4
  8. package/dist/curp-validation.esm.js +1 -1
  9. package/dist/{deepsightLoader-C-Xil8cg.esm.js → deepsightLoader-IPtIRYqd.esm.js} +2 -2
  10. package/dist/{deepsightService-UhtHJCFb.d.ts → deepsightService-CP5OM4Fc.d.ts} +1 -1
  11. package/dist/{deepsightService-BgqD33AH.esm.js → deepsightService-Ca85OHZ-.esm.js} +1 -1
  12. package/dist/document-capture.d.ts +37 -37
  13. package/dist/document-capture.esm.js +2 -2
  14. package/dist/document-upload.d.ts +46 -46
  15. package/dist/document-upload.esm.js +2 -2
  16. package/dist/ekyb.d.ts +16 -5
  17. package/dist/ekyb.esm.js +241 -61
  18. package/dist/ekyc.d.ts +2 -12
  19. package/dist/ekyc.esm.js +31 -194
  20. package/dist/email.d.ts +3 -3
  21. package/dist/email.esm.js +2 -2
  22. package/dist/{emailManager-e7j__XBB.esm.js → emailManager-BRFO9OW6.esm.js} +1 -1
  23. package/dist/{emailManager-DZeOYBQ6.d.ts → emailManager-DcYzBeT-.d.ts} +2 -2
  24. package/dist/extensibility.d.ts +14 -14
  25. package/dist/extensibility.esm.js +10 -10
  26. package/dist/face-match.d.ts +1 -1
  27. package/dist/face-match.esm.js +1 -1
  28. package/dist/{faceCaptureManagerFactory-CiQWYHp2.d.ts → faceCaptureManagerFactory-Dm3dO_r0.d.ts} +7 -7
  29. package/dist/{faceCaptureSetup-CF9TJlsc.esm.js → faceCaptureSetup-I9wFuT1d.esm.js} +4 -4
  30. package/dist/flow.d.ts +7 -7
  31. package/dist/flow.esm.js +5 -83
  32. package/dist/flowServices-B5YbZJ7r.esm.js +83 -0
  33. package/dist/geolocation.d.ts +1 -1
  34. package/dist/geolocation.esm.js +1 -1
  35. package/dist/government-validation.d.ts +1 -1
  36. package/dist/government-validation.esm.js +1 -1
  37. package/dist/id.d.ts +9 -9
  38. package/dist/id.esm.js +5 -5
  39. package/dist/{idCaptureManager-B9BsU7-M.esm.js → idCaptureManager-BdlS0WrG.esm.js} +5 -5
  40. package/dist/{idCaptureManager-D8FwP0TW.d.ts → idCaptureManager-dTZ7KTot.d.ts} +6 -6
  41. package/dist/index.d.ts +10 -10
  42. package/dist/index.esm.js +5 -5
  43. package/dist/phone.d.ts +3 -3
  44. package/dist/phone.esm.js +2 -2
  45. package/dist/{phoneManager-BsamACjL.d.ts → phoneManager-BwJpxm-D.d.ts} +2 -2
  46. package/dist/{phoneManager-B6fNmxhw.esm.js → phoneManager-TWj65pNG.esm.js} +1 -1
  47. package/dist/redirect-to-mobile.d.ts +1 -1
  48. package/dist/redirect-to-mobile.esm.js +1 -1
  49. package/dist/selfie.d.ts +10 -10
  50. package/dist/selfie.esm.js +6 -6
  51. package/dist/{selfieManager-ByV0akn-.esm.js → selfieManager-BeVNeGVa.esm.js} +2 -2
  52. package/dist/{selfieManager-Czysy-lv.d.ts → selfieManager-BgSkTLJj.d.ts} +2 -2
  53. package/dist/session.d.ts +1 -1
  54. package/dist/session.esm.js +1 -1
  55. package/dist/{src-BmVrWkLJ.esm.js → src-D0bFtylT.esm.js} +1 -1
  56. package/dist/{streamingEvents-Cw6kqXEh.esm.js → streamingEvents-BjxVqrJP.esm.js} +1 -1
  57. package/dist/{types-BugcSDaO.d.ts → types-BHnsBsl_.d.ts} +1 -1
  58. package/dist/{types-DTieLton.d.ts → types-CWa0DQcn.d.ts} +12 -1
  59. package/dist/{types-C9Jo2XOb.d.ts → types-seztsdvN.d.ts} +1 -1
  60. package/package.json +3 -3
  61. package/dist/usStates-vWM_ZgEH.esm.js +0 -210
  62. /package/dist/{Actor-BAf9LRYf.d.ts → Actor-D3GOC38V.d.ts} +0 -0
  63. /package/dist/{Manager-CXnC-tN_.d.ts → Manager-DsNvecSe.d.ts} +0 -0
  64. /package/dist/{StateMachine-DJpZF_HP.d.ts → StateMachine-BFurBmbZ.d.ts} +0 -0
  65. /package/dist/{camera-DDn9ILon.d.ts → camera-Bzi6CMAW.d.ts} +0 -0
  66. /package/dist/{flowCompletionService-D4YDcHQR.d.ts → flowCompletionService-BiICW3B-.d.ts} +0 -0
  67. /package/dist/{flowCompletionService-CV8Ywiut.esm.js → flowCompletionService-D1bhU2uN.esm.js} +0 -0
  68. /package/dist/{index-BtQzTfU9.d.ts → index-Km_6UPBI.d.ts} +0 -0
  69. /package/dist/{lib-COh1FH9n.esm.js → lib-DJozC192.esm.js} +0 -0
  70. /package/dist/{warmup-Bp_1oXoL.d.ts → warmup-4e5k___O.d.ts} +0 -0
package/dist/ekyb.esm.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-3HzCcoEy.esm.js";
2
- import { A as createManager } from "./src-BmVrWkLJ.esm.js";
2
+ import { A as createManager } from "./src-D0bFtylT.esm.js";
3
3
  import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-CcoTezCZ.esm.js";
4
4
  import { t as api } from "./api-C2uzxrpN.esm.js";
5
5
  import { t as endpoints } from "./endpoints-IAlXA1zN.esm.js";
6
- import { t as usStateOptions } from "./usStates-vWM_ZgEH.esm.js";
6
+ import { a as POSTAL_CODE_FORMAT_ERROR_KEYS, c as getPostalCodeMaxLength, i as FIXED_DIGIT_POSTAL_CODE_LENGTH, l as validatePostalCode, n as fillFromSuggestion, o as formatPostalCode, r as DYNAMIC_REQUIRED_KEY, s as getPostalCodeErrorKey, t as debounceSearchActor, u as usStateOptions } from "./addressSearch-B446UZn4.esm.js";
7
+ import { t as getFlow } from "./flowServices-B5YbZJ7r.esm.js";
7
8
 
8
9
  //#region src/modules/ekyb/ekybConstants.ts
9
10
  const UBO_INPUT_LIMIT = 8;
@@ -189,6 +190,10 @@ function requiresAddressValidation(countryCode) {
189
190
  //#endregion
190
191
  //#region src/modules/ekyb/ekybActions.ts
191
192
  const REQUIRED_ERROR_KEYS = new Set(["ekyb.error.requiredField"]);
193
+ const UBO_FIELD_LABELS = {
194
+ name: "ekyb.uboName",
195
+ surname: "ekyb.uboSurname"
196
+ };
192
197
  function buildEkybFields(verificationFields, country, _hasUbos) {
193
198
  let modules = verificationFields.filter((f) => f !== "ubos-user_input" && !f.startsWith("socure"));
194
199
  if (country === "GB") modules = modules.filter((m) => m !== "state-user_input");
@@ -207,7 +212,11 @@ function buildEkybFields(verificationFields, country, _hasUbos) {
207
212
  label: `ekyb.${fieldName}`,
208
213
  required: !optional
209
214
  };
210
- if (fieldName === "taxId") def.required = true;
215
+ if (fieldName === "taxId") {
216
+ def.required = true;
217
+ if (country === "CN") def.label = "verification.labels.prcId";
218
+ }
219
+ if (fieldName === "postalCode") def.maxLength = getPostalCodeMaxLength(country);
211
220
  if (fieldName === "state" && country === "US") {
212
221
  def.type = "dropdown";
213
222
  def.options = usStateOptions;
@@ -233,6 +242,9 @@ function validateEkybField(name, value, required, country) {
233
242
  }
234
243
  if (COUNTRIES_WITH_SPECIAL_TAX_ID_RULES.includes(country) && !val) return;
235
244
  }
245
+ if (name === "postalCode" && val) {
246
+ if (!validatePostalCode(val, country)) return getPostalCodeErrorKey(country);
247
+ }
236
248
  }
237
249
  function computeEkybValidation(fields, values, country, ubos, hasUbos) {
238
250
  const errors = {};
@@ -250,22 +262,57 @@ function computeEkybValidation(fields, values, country, ubos, hasUbos) {
250
262
  }
251
263
  }
252
264
  if (hasUbos) for (let i = 0; i < ubos.length; i++) {
253
- if (!ubos[i].name.trim()) errors[`ubo-${i}-name`] = "ekyb.error.requiredField";
254
- if (!ubos[i].surname.trim()) errors[`ubo-${i}-surname`] = "ekyb.error.requiredField";
265
+ const isDefault = i === 0;
266
+ const hasAnyValue = ubos[i].name.trim() !== "" || ubos[i].surname.trim() !== "";
267
+ if (isDefault || hasAnyValue) {
268
+ if (!ubos[i].name.trim()) errors[`ubo-${i}-name`] = "ekyb.error.requiredField";
269
+ if (!ubos[i].surname.trim()) errors[`ubo-${i}-surname`] = "ekyb.error.requiredField";
270
+ }
255
271
  }
256
272
  return {
257
273
  errors,
258
274
  isValid: Object.keys(errors).length === 0
259
275
  };
260
276
  }
261
- function computeDisplayErrors(errors, touched, submitAttempted) {
277
+ function computeDisplayErrors(errors, touched, submitAttempted, country, fields) {
262
278
  const display = {};
279
+ const errorParams = {};
280
+ const fieldLabelMap = new Map(fields?.map((f) => [f.name, f.label]));
263
281
  for (const [field, err] of Object.entries(errors)) {
264
282
  const isRequiredErr = REQUIRED_ERROR_KEYS.has(err);
265
- if (isRequiredErr && submitAttempted) display[field] = err;
266
- else if (!isRequiredErr && touched[field]) display[field] = err;
283
+ if (isRequiredErr && (submitAttempted || touched[field])) {
284
+ display[field] = DYNAMIC_REQUIRED_KEY;
285
+ const label = fieldLabelMap.get(field);
286
+ if (label) errorParams[field] = { fieldName: label };
287
+ else {
288
+ const uboMatch = field.match(/^ubo-\d+-(name|surname)$/);
289
+ if (uboMatch) errorParams[field] = { fieldName: UBO_FIELD_LABELS[uboMatch[1]] ?? field };
290
+ }
291
+ } else if (!isRequiredErr && touched[field]) display[field] = err;
292
+ if (display[field] && field === "postalCode" && POSTAL_CODE_FORMAT_ERROR_KEYS.has(err)) {
293
+ const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
294
+ if (fixedLen !== void 0) errorParams[field] = {
295
+ ...errorParams[field] ?? {},
296
+ length: fixedLen
297
+ };
298
+ else {
299
+ let maxLen = getPostalCodeMaxLength(country);
300
+ if (country === "US" || country === "BR") maxLen = maxLen - 1;
301
+ errorParams[field] = {
302
+ ...errorParams[field] ?? {},
303
+ maxLength: maxLen
304
+ };
305
+ }
306
+ }
267
307
  }
268
- return display;
308
+ return {
309
+ displayErrors: display,
310
+ errorParams
311
+ };
312
+ }
313
+ function processEkybFieldValue(name, value, country) {
314
+ if (name === "postalCode") return formatPostalCode(value, country);
315
+ return value;
269
316
  }
270
317
  function buildEkybSubmitPayload(ctx) {
271
318
  const uboNames = ctx.ubos.filter((u) => u.name.trim() || u.surname.trim()).map((u) => `${u.name.trim()} ${u.surname.trim()}`.trim());
@@ -283,6 +330,7 @@ function buildEkybSubmitPayload(ctx) {
283
330
 
284
331
  //#endregion
285
332
  //#region src/modules/ekyb/ekybGuards.ts
333
+ const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
286
334
  const isValidGuard = ({ context }) => context.isValid;
287
335
  const canAddUboGuard = ({ context }) => context.canAddUbo;
288
336
  const isValidUboIndexGuard = ({ context, event }) => {
@@ -296,6 +344,12 @@ const isSupportedCountryGuard = ({ event }) => {
296
344
 
297
345
  //#endregion
298
346
  //#region src/modules/ekyb/ekybServices.ts
347
+ /** Fetches the onboarding flow and extracts the EKYB module configuration */
348
+ async function fetchEkybModuleConfig(signal) {
349
+ const ekybModule = (await getFlow(signal)).flowModules.find((m) => m.key === "EKYB");
350
+ if (!ekybModule) throw new Error("EKYB module not found in flow configuration");
351
+ return ekybModule.configuration;
352
+ }
299
353
  /** Submits eKYB business verification */
300
354
  async function submitEkyb(data, signal) {
301
355
  const res = await api.post(endpoints.ekybSubmit, data, { signal });
@@ -305,6 +359,7 @@ async function submitEkyb(data, signal) {
305
359
 
306
360
  //#endregion
307
361
  //#region src/modules/ekyb/ekybActors.ts
362
+ const fetchEkybModuleConfigActor = fromPromise(async ({ signal }) => fetchEkybModuleConfig(signal));
308
363
  const submitEkybActor = fromPromise(async ({ input, signal }) => submitEkyb(input, signal));
309
364
 
310
365
  //#endregion
@@ -315,8 +370,51 @@ const ekybMachine = setup({
315
370
  events: {},
316
371
  input: {}
317
372
  },
318
- actors: { submitEkyb: submitEkybActor },
373
+ actors: {
374
+ fetchEkybModuleConfig: fetchEkybModuleConfigActor,
375
+ submitEkyb: submitEkybActor,
376
+ debounceSearch: debounceSearchActor
377
+ },
319
378
  actions: {
379
+ applyFetchedConfig: assign(({ event }) => {
380
+ const fetched = event.output;
381
+ const config = {
382
+ checkBusinessName: fetched.checkBusinessName,
383
+ checkAddress: fetched.checkAddress,
384
+ checkTaxId: fetched.checkTaxId,
385
+ checkUniqueBeneficialOwner: fetched.checkUniqueBeneficialOwner
386
+ };
387
+ const country = "US";
388
+ const vFields = getDefaultVerificationFields(config);
389
+ const hasUbos = config.checkUniqueBeneficialOwner !== false && vFields.includes("ubos-user_input");
390
+ const fields = buildEkybFields(vFields, country, hasUbos);
391
+ const values = { country };
392
+ const ubos = hasUbos ? [{
393
+ id: "ubo-1",
394
+ name: "",
395
+ surname: ""
396
+ }] : [];
397
+ const { errors, isValid } = computeEkybValidation(fields, values, country, ubos, hasUbos);
398
+ return {
399
+ config,
400
+ country,
401
+ availableCountries: ALL_COUNTRIES,
402
+ fields,
403
+ values,
404
+ errors,
405
+ displayErrors: {},
406
+ errorParams: {},
407
+ isValid,
408
+ ubos,
409
+ canAddUbo: hasUbos,
410
+ hasUbos,
411
+ touched: {},
412
+ submitAttempted: false,
413
+ addressSuggestions: [],
414
+ _nextUboId: 2,
415
+ _searchQuery: ""
416
+ };
417
+ }),
320
418
  setCountry: assign(({ context, event }) => {
321
419
  const { country } = event;
322
420
  const vFields = getDefaultVerificationFields(context.config);
@@ -340,6 +438,7 @@ const ekybMachine = setup({
340
438
  state: ""
341
439
  };
342
440
  const { errors, isValid } = computeEkybValidation(fields, newValues, country, ubos, hasUbos);
441
+ const { displayErrors, errorParams } = computeDisplayErrors(errors, context.touched, context.submitAttempted, country, fields);
343
442
  return {
344
443
  country,
345
444
  fields,
@@ -349,29 +448,32 @@ const ekybMachine = setup({
349
448
  ubos,
350
449
  canAddUbo: hasUbos && ubos.length < UBO_INPUT_LIMIT,
351
450
  hasUbos,
352
- displayErrors: {},
353
- touched: {},
354
- submitAttempted: false,
451
+ displayErrors,
452
+ errorParams,
453
+ submitAttempted: context.submitAttempted,
355
454
  _nextUboId: nextId
356
455
  };
357
456
  }),
358
457
  updateField: assign(({ context, event }) => {
359
458
  const { name, value } = event;
459
+ const processed = processEkybFieldValue(name, value, context.country);
360
460
  const newValues = {
361
461
  ...context.values,
362
- [name]: value
462
+ [name]: processed
363
463
  };
364
464
  const newTouched = {
365
465
  ...context.touched,
366
466
  [name]: true
367
467
  };
368
468
  const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
469
+ const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.country, context.fields);
369
470
  return {
370
471
  values: newValues,
371
472
  errors,
372
473
  isValid,
373
474
  touched: newTouched,
374
- displayErrors: computeDisplayErrors(errors, newTouched, context.submitAttempted)
475
+ displayErrors,
476
+ errorParams
375
477
  };
376
478
  }),
377
479
  addUbo: assign(({ context }) => {
@@ -383,12 +485,14 @@ const ekybMachine = setup({
383
485
  }];
384
486
  const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
385
487
  const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
488
+ const { displayErrors, errorParams } = computeDisplayErrors(errors, context.touched, context.submitAttempted, context.country, context.fields);
386
489
  return {
387
490
  ubos,
388
491
  canAddUbo,
389
492
  errors,
390
493
  isValid,
391
- displayErrors: computeDisplayErrors(errors, context.touched, context.submitAttempted),
494
+ displayErrors,
495
+ errorParams,
392
496
  _nextUboId: newId + 1
393
497
  };
394
498
  }),
@@ -409,12 +513,14 @@ const ekybMachine = setup({
409
513
  touched[`ubo-${newIdx}-${match[2]}`] = val;
410
514
  }
411
515
  const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
516
+ const { displayErrors, errorParams } = computeDisplayErrors(errors, touched, context.submitAttempted, context.country, context.fields);
412
517
  return {
413
518
  ubos,
414
519
  canAddUbo,
415
520
  errors,
416
521
  isValid,
417
- displayErrors: computeDisplayErrors(errors, touched, context.submitAttempted),
522
+ displayErrors,
523
+ errorParams,
418
524
  touched
419
525
  };
420
526
  }),
@@ -430,20 +536,42 @@ const ekybMachine = setup({
430
536
  [uboKey]: true
431
537
  };
432
538
  const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
539
+ const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.country, context.fields);
433
540
  return {
434
541
  ubos,
435
542
  errors,
436
543
  isValid,
437
544
  touched: newTouched,
438
- displayErrors: computeDisplayErrors(errors, newTouched, context.submitAttempted)
545
+ displayErrors,
546
+ errorParams
439
547
  };
440
548
  }),
441
549
  setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
442
550
  clearErrorMessage: assign({ errorMessage: () => "" }),
443
- markSubmitAttempted: assign(({ context }) => ({
444
- submitAttempted: true,
445
- displayErrors: computeDisplayErrors(context.errors, context.touched, true)
446
- })),
551
+ markSubmitAttempted: assign(({ context }) => {
552
+ const { displayErrors, errorParams } = computeDisplayErrors(context.errors, context.touched, true, context.country, context.fields);
553
+ return {
554
+ submitAttempted: true,
555
+ displayErrors,
556
+ errorParams
557
+ };
558
+ }),
559
+ fillAddressFields: assign(({ context, event }) => {
560
+ const { suggestion } = event;
561
+ const { values: newValues, touched: newTouched } = fillFromSuggestion(context.values, context.touched, suggestion);
562
+ const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
563
+ const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.country, context.fields);
564
+ return {
565
+ values: newValues,
566
+ addressSuggestions: [],
567
+ errors,
568
+ isValid,
569
+ touched: newTouched,
570
+ displayErrors,
571
+ errorParams
572
+ };
573
+ }),
574
+ setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions })),
447
575
  trackModuleOpen: () => {
448
576
  addEvent({
449
577
  code: "open",
@@ -459,6 +587,7 @@ const ekybMachine = setup({
459
587
  }
460
588
  },
461
589
  guards: {
590
+ hasFlowId: hasFlowIdGuard,
462
591
  isValid: isValidGuard,
463
592
  canAddUbo: canAddUboGuard,
464
593
  isValidUboIndex: isValidUboIndexGuard,
@@ -466,7 +595,7 @@ const ekybMachine = setup({
466
595
  }
467
596
  }).createMachine({
468
597
  id: "ekyb",
469
- initial: "form",
598
+ initial: "idle",
470
599
  context: ({ input }) => {
471
600
  const country = "US";
472
601
  const vFields = getDefaultVerificationFields(input.config);
@@ -487,6 +616,7 @@ const ekybMachine = setup({
487
616
  values,
488
617
  errors,
489
618
  displayErrors: {},
619
+ errorParams: {},
490
620
  isValid,
491
621
  ubos,
492
622
  canAddUbo: hasUbos,
@@ -494,35 +624,79 @@ const ekybMachine = setup({
494
624
  errorMessage: "",
495
625
  touched: {},
496
626
  submitAttempted: false,
497
- _nextUboId: 2
627
+ addressSuggestions: [],
628
+ _nextUboId: 2,
629
+ _searchQuery: ""
498
630
  };
499
631
  },
500
- entry: ["trackModuleOpen", "trackFormOpen"],
632
+ entry: "trackModuleOpen",
501
633
  states: {
502
- form: { on: {
503
- SET_COUNTRY: {
504
- guard: "isSupportedCountry",
505
- actions: "setCountry"
506
- },
507
- SET_FIELD: { actions: "updateField" },
508
- ADD_UBO: {
509
- guard: "canAddUbo",
510
- actions: "addUbo"
511
- },
512
- REMOVE_UBO: {
513
- guard: "isValidUboIndex",
514
- actions: "removeUbo"
515
- },
516
- SET_UBO_FIELD: {
517
- guard: "isValidUboIndex",
518
- actions: "setUboField"
634
+ idle: { on: { LOAD: [{
635
+ target: "loading",
636
+ guard: "hasFlowId"
637
+ }, { target: "form" }] } },
638
+ loading: { invoke: {
639
+ id: "fetchEkybModuleConfig",
640
+ src: "fetchEkybModuleConfig",
641
+ onDone: {
642
+ target: "form",
643
+ actions: "applyFetchedConfig"
519
644
  },
520
- SUBMIT: [{
521
- target: "submitting",
522
- guard: "isValid"
523
- }, { actions: "markSubmitAttempted" }],
524
- CLOSE: { target: "closed" }
645
+ onError: "form"
525
646
  } },
647
+ form: {
648
+ entry: "trackFormOpen",
649
+ initial: "idle",
650
+ states: {
651
+ idle: {},
652
+ searching: {
653
+ invoke: {
654
+ id: "debounceSearch",
655
+ src: "debounceSearch",
656
+ input: ({ context }) => ({ query: context._searchQuery })
657
+ },
658
+ on: { RESULTS: {
659
+ target: "idle",
660
+ actions: "setAddressSuggestions"
661
+ } }
662
+ }
663
+ },
664
+ on: {
665
+ SET_COUNTRY: {
666
+ guard: "isSupportedCountry",
667
+ actions: "setCountry"
668
+ },
669
+ SET_FIELD: { actions: "updateField" },
670
+ SEARCH_ADDRESS: {
671
+ target: ".searching",
672
+ actions: assign(({ event }) => ({
673
+ _searchQuery: event.query,
674
+ addressSuggestions: []
675
+ }))
676
+ },
677
+ SELECT_ADDRESS: {
678
+ target: ".idle",
679
+ actions: "fillAddressFields"
680
+ },
681
+ ADD_UBO: {
682
+ guard: "canAddUbo",
683
+ actions: "addUbo"
684
+ },
685
+ REMOVE_UBO: {
686
+ guard: "isValidUboIndex",
687
+ actions: "removeUbo"
688
+ },
689
+ SET_UBO_FIELD: {
690
+ guard: "isValidUboIndex",
691
+ actions: "setUboField"
692
+ },
693
+ SUBMIT: [{
694
+ target: "submitting",
695
+ guard: "isValid"
696
+ }, { actions: "markSubmitAttempted" }],
697
+ CLOSE: { target: "closed" }
698
+ }
699
+ },
526
700
  submitting: { invoke: {
527
701
  id: "submitEkyb",
528
702
  src: "submitEkyb",
@@ -561,17 +735,19 @@ function createEkybActor(options) {
561
735
  function mapState(snapshot) {
562
736
  const typedSnapshot = snapshot;
563
737
  const { context } = typedSnapshot;
738
+ if (typedSnapshot.matches("idle") || typedSnapshot.matches("loading")) return { status: "loading" };
564
739
  if (typedSnapshot.matches("form")) return {
565
740
  status: "form",
566
741
  country: context.country,
567
742
  availableCountries: context.availableCountries,
568
743
  fields: context.fields,
569
744
  values: context.values,
570
- errors: context.errors,
571
745
  displayErrors: context.displayErrors,
746
+ errorParams: context.errorParams,
572
747
  isValid: context.isValid,
573
748
  ubos: context.ubos,
574
- canAddUbo: context.canAddUbo
749
+ canAddUbo: context.canAddUbo,
750
+ addressSuggestions: context.addressSuggestions
575
751
  };
576
752
  if (typedSnapshot.matches("submitting")) return { status: "submitting" };
577
753
  if (typedSnapshot.matches("success")) return { status: "success" };
@@ -581,21 +757,13 @@ function mapState(snapshot) {
581
757
  };
582
758
  if (typedSnapshot.matches("finished")) return { status: "finished" };
583
759
  if (typedSnapshot.matches("closed")) return { status: "closed" };
584
- return {
585
- status: "form",
586
- country: context.country,
587
- availableCountries: context.availableCountries,
588
- fields: context.fields,
589
- values: context.values,
590
- errors: context.errors,
591
- displayErrors: context.displayErrors,
592
- isValid: context.isValid,
593
- ubos: context.ubos,
594
- canAddUbo: context.canAddUbo
595
- };
760
+ return { status: "loading" };
596
761
  }
597
762
  function createApi({ actor }) {
598
763
  return {
764
+ load() {
765
+ actor.send({ type: "LOAD" });
766
+ },
599
767
  setCountry(country) {
600
768
  actor.send({
601
769
  type: "SET_COUNTRY",
@@ -626,6 +794,18 @@ function createApi({ actor }) {
626
794
  value
627
795
  });
628
796
  },
797
+ searchAddress(query) {
798
+ actor.send({
799
+ type: "SEARCH_ADDRESS",
800
+ query
801
+ });
802
+ },
803
+ selectAddress(suggestion) {
804
+ actor.send({
805
+ type: "SELECT_ADDRESS",
806
+ suggestion
807
+ });
808
+ },
629
809
  submit() {
630
810
  actor.send({ type: "SUBMIT" });
631
811
  },
package/dist/ekyc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Manager } from "./Manager-CXnC-tN_.js";
2
- import { t as FieldDef } from "./types-DTieLton.js";
1
+ import { t as Manager } from "./Manager-DsNvecSe.js";
2
+ import { n as FieldDef, t as AddressSuggestion } from "./types-CWa0DQcn.js";
3
3
 
4
4
  //#region src/modules/ekyc/types.d.ts
5
5
  type EkycFieldSource = 'user_input' | 'document_scan' | 'poa_document' | 'phone_module_input' | 'email_module_input' | false;
@@ -64,16 +64,6 @@ type EkycConfig = {
64
64
  type EkycFieldDef = FieldDef & {
65
65
  source: EkycFieldSource;
66
66
  };
67
- type AddressSuggestion = {
68
- id: string | number;
69
- label: string;
70
- street?: string;
71
- city?: string;
72
- stateCode?: string;
73
- postalCode?: string;
74
- houseNumber?: string;
75
- countryCode?: string;
76
- };
77
67
  //#endregion
78
68
  //#region src/modules/ekyc/ekycStateMachine.d.ts
79
69
  declare const ekycMachine: any;