@incodetech/core 0.0.0-dev-20260416-e8e67a4 → 0.0.0-dev-20260416-3692bda

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 (32) hide show
  1. package/dist/ae-signature.d.ts +1 -1
  2. package/dist/authentication.d.ts +3 -3
  3. package/dist/{authenticationManager-DxWVcbnl.d.ts → authenticationManager-C75RqUmN.d.ts} +1 -1
  4. package/dist/consent.d.ts +50 -50
  5. package/dist/curp-validation.d.ts +1 -1
  6. package/dist/document-capture.d.ts +70 -70
  7. package/dist/document-upload.d.ts +46 -46
  8. package/dist/ekyb.esm.js +2 -2
  9. package/dist/{ekybStateMachine-BfBs85Uj.esm.js → ekybStateMachine-BdztAoD6.esm.js} +1 -1
  10. package/dist/electronic-signature.d.ts +1 -1
  11. package/dist/extensibility.d.ts +5 -5
  12. package/dist/extensibility.esm.js +2 -2
  13. package/dist/{faceCaptureManagerFactory-CV5lfQZg.d.ts → faceCaptureManagerFactory-XQOqroTM.d.ts} +1 -1
  14. package/dist/flow.d.ts +29 -4
  15. package/dist/flow.esm.js +234 -91
  16. package/dist/{flowServices-BjihIhLr.esm.js → flowServices-ibDApkcC.esm.js} +1 -9
  17. package/dist/home.d.ts +11 -11
  18. package/dist/id.d.ts +2 -2
  19. package/dist/id.esm.js +2 -2
  20. package/dist/{idCaptureManager-Cxuy_f9Q.esm.js → idCaptureManager-Bvv0ssj8.esm.js} +38 -27
  21. package/dist/{idCaptureManager-BF-9O4pN.d.ts → idCaptureManager-eoc0PvFh.d.ts} +1 -1
  22. package/dist/{idCaptureStateMachine-DndyW7Rc.esm.js → idCaptureStateMachine-hELTmJQc.esm.js} +3 -1
  23. package/dist/identity-reuse.d.ts +46 -46
  24. package/dist/{index-BfG6VHnt.d.ts → index-XfOqcbrI.d.ts} +119 -119
  25. package/dist/mandatory-consent.d.ts +51 -51
  26. package/dist/qe-signature.d.ts +1 -1
  27. package/dist/selfie.d.ts +3 -3
  28. package/dist/{selfieManager-J9vh9MZ6.d.ts → selfieManager-Bsag2fr3.d.ts} +1 -1
  29. package/dist/{types-Bk2AoUFA.d.ts → types-x6tue2ld.d.ts} +1 -0
  30. package/dist/workflow.d.ts +82 -82
  31. package/dist/workflow.esm.js +3 -3
  32. package/package.json +1 -1
package/dist/flow.esm.js CHANGED
@@ -4,7 +4,7 @@ import "./session-4kX3TYAC.esm.js";
4
4
  import "./BrowserEnvironmentProvider-D7IR7V-D.esm.js";
5
5
  import "./browserSimulation-UTYyQOiB.esm.js";
6
6
  import { a as createActor, i as fromPromise, n as assign, o as createManager, t as setup } from "./xstate.esm-BlgyVBVv.esm.js";
7
- import { n as getRequiredWasmPipelines, r as normalizeFlowModules, t as getFlow } from "./flowServices-BjihIhLr.esm.js";
7
+ import { n as getRequiredWasmPipelines, r as normalizeFlowModules, t as getFlow } from "./flowServices-ibDApkcC.esm.js";
8
8
  import { t as getFinishStatus } from "./flowCompletionService-BoRh9z5O.esm.js";
9
9
  import { t as runChildModule } from "./runChildModule-CPESMGyI.esm.js";
10
10
 
@@ -137,7 +137,7 @@ function createFlowActor(options) {
137
137
 
138
138
  //#endregion
139
139
  //#region src/modules/flow/flowManager.ts
140
- function mapState$1(snapshot) {
140
+ function mapState(snapshot) {
141
141
  const { value, context } = snapshot;
142
142
  switch (value) {
143
143
  case "idle": return { status: "idle" };
@@ -161,7 +161,7 @@ function mapState$1(snapshot) {
161
161
  default: return { status: "idle" };
162
162
  }
163
163
  }
164
- function createApi$1({ actor, getSnapshot, trackElementClicked }) {
164
+ function createApi({ actor, getSnapshot, trackElementClicked }) {
165
165
  function getCanNext() {
166
166
  const snapshot = getSnapshot();
167
167
  const { currentStepIndex, steps } = snapshot.context;
@@ -239,8 +239,8 @@ function createApi$1({ actor, getSnapshot, trackElementClicked }) {
239
239
  function createFlowManager(options) {
240
240
  return createManager({
241
241
  actor: createFlowActor(options),
242
- mapState: mapState$1,
243
- createApi: createApi$1,
242
+ mapState,
243
+ createApi,
244
244
  instrumentation: createManagerInstrumentation("FLOW")
245
245
  });
246
246
  }
@@ -287,6 +287,37 @@ function createModuleLoader(registry) {
287
287
 
288
288
  //#endregion
289
289
  //#region src/modules/flow/orchestratedFlowStateMachine.ts
290
+ function createBaseContext(context, isHomeContinueLoading) {
291
+ return {
292
+ flow: void 0,
293
+ error: void 0,
294
+ steps: [],
295
+ currentStepIndex: -1,
296
+ currentStep: void 0,
297
+ config: void 0,
298
+ getFlow: context.getFlow,
299
+ registeredModules: context.registeredModules,
300
+ lazyRegisteredModules: context.lazyRegisteredModules,
301
+ currentModuleMachine: void 0,
302
+ getFinishStatus: context.getFinishStatus,
303
+ enableHome: context.enableHome,
304
+ finishStatus: void 0,
305
+ isHomeContinueLoading
306
+ };
307
+ }
308
+ function createInitialContext(input) {
309
+ return createBaseContext({
310
+ getFlow: input.getFlow,
311
+ registeredModules: input.modules ?? {},
312
+ lazyRegisteredModules: input.lazyModules ?? {},
313
+ getFinishStatus: input.getFinishStatus ?? getFinishStatus,
314
+ enableHome: input.enableHome === true
315
+ }, false);
316
+ }
317
+ function shouldEnterHome(context) {
318
+ return context.enableHome === true && context.currentStepIndex === 0 && context.isHomeContinueLoading === false;
319
+ }
320
+ const homeContinueOn = { HOME_CONTINUE: { actions: "setHomeContinueLoading" } };
290
321
  const orchestratedFlowMachine = setup({
291
322
  types: {
292
323
  context: {},
@@ -313,20 +344,10 @@ const orchestratedFlowMachine = setup({
313
344
  })
314
345
  },
315
346
  actions: {
316
- resetContext: assign(({ context }) => ({
317
- flow: void 0,
318
- error: void 0,
319
- steps: [],
320
- currentStepIndex: -1,
321
- currentStep: void 0,
322
- config: void 0,
323
- getFlow: context.getFlow,
324
- registeredModules: context.registeredModules,
325
- lazyRegisteredModules: context.lazyRegisteredModules,
326
- currentModuleMachine: void 0,
327
- getFinishStatus: context.getFinishStatus,
328
- finishStatus: void 0
329
- })),
347
+ resetContext: assign(({ context }) => createBaseContext(context, false)),
348
+ resetContextForLoad: assign(({ context }) => createBaseContext(context, context.isHomeContinueLoading)),
349
+ setHomeContinueLoading: assign({ isHomeContinueLoading: true }),
350
+ clearHomeContinueLoading: assign({ isHomeContinueLoading: false }),
330
351
  setFlowData: assign(({ event }) => {
331
352
  const flow = event.output;
332
353
  const flowModules = flow.flowModules ?? [];
@@ -365,6 +386,7 @@ const orchestratedFlowMachine = setup({
365
386
  guards: {
366
387
  isLastStep: ({ context }) => context.currentStepIndex >= 0 && context.currentStepIndex === context.steps.length - 1,
367
388
  canGoNext: ({ context }) => context.currentStepIndex >= 0 && context.currentStepIndex < context.steps.length - 1,
389
+ shouldEnterHome: ({ context }) => shouldEnterHome(context),
368
390
  hasModule: ({ context, event }) => {
369
391
  if (!("output" in event)) return false;
370
392
  const firstModuleKey = event.output.flowModules?.[0]?.key;
@@ -379,25 +401,15 @@ const orchestratedFlowMachine = setup({
379
401
  }).createMachine({
380
402
  id: "orchestratedFlow",
381
403
  initial: "idle",
382
- context: ({ input }) => ({
383
- flow: void 0,
384
- error: void 0,
385
- steps: [],
386
- currentStepIndex: -1,
387
- currentStep: void 0,
388
- config: void 0,
389
- getFlow: input.getFlow,
390
- registeredModules: input.modules ?? {},
391
- lazyRegisteredModules: input.lazyModules ?? {},
392
- currentModuleMachine: void 0,
393
- getFinishStatus: input.getFinishStatus ?? getFinishStatus,
394
- finishStatus: void 0
395
- }),
404
+ context: ({ input }) => createInitialContext(input),
396
405
  states: {
397
- idle: { on: { LOAD: {
398
- target: "loading",
399
- actions: "resetContext"
400
- } } },
406
+ idle: { on: {
407
+ LOAD: {
408
+ target: "loading",
409
+ actions: "resetContextForLoad"
410
+ },
411
+ ...homeContinueOn
412
+ } },
401
413
  loading: {
402
414
  invoke: {
403
415
  id: "fetchFlow",
@@ -419,10 +431,13 @@ const orchestratedFlowMachine = setup({
419
431
  actions: "setError"
420
432
  }
421
433
  },
422
- on: { CANCEL: {
423
- target: "idle",
424
- actions: "resetContext"
425
- } }
434
+ on: {
435
+ CANCEL: {
436
+ target: "idle",
437
+ actions: "resetContext"
438
+ },
439
+ ...homeContinueOn
440
+ }
426
441
  },
427
442
  resolvingModule: {
428
443
  invoke: {
@@ -433,25 +448,47 @@ const orchestratedFlowMachine = setup({
433
448
  modules: context.registeredModules,
434
449
  lazyModules: context.lazyRegisteredModules
435
450
  }),
436
- onDone: [{
437
- target: "runningModule",
438
- guard: "hasCurrentModuleMachine",
439
- actions: "setCurrentModuleMachine"
440
- }, {
441
- target: "error",
442
- actions: assign(({ context }) => ({ error: context.currentStep ? `No registered module found for: ${context.currentStep}` : "No registered module found: flow has no modules" }))
443
- }],
451
+ onDone: [
452
+ {
453
+ target: "home",
454
+ guard: "shouldEnterHome",
455
+ actions: "setCurrentModuleMachine"
456
+ },
457
+ {
458
+ target: "runningModule",
459
+ guard: "hasCurrentModuleMachine",
460
+ actions: "setCurrentModuleMachine"
461
+ },
462
+ {
463
+ target: "error",
464
+ actions: assign(({ context }) => ({ error: context.currentStep ? `No registered module found for: ${context.currentStep}` : "No registered module found: flow has no modules" }))
465
+ }
466
+ ],
444
467
  onError: {
445
468
  target: "error",
446
469
  actions: "setError"
447
470
  }
448
471
  },
449
- on: { RESET: {
472
+ on: {
473
+ RESET: {
474
+ target: "idle",
475
+ actions: "resetContext"
476
+ },
477
+ ...homeContinueOn
478
+ }
479
+ },
480
+ home: { on: {
481
+ HOME_CONTINUE: {
482
+ target: "runningModule",
483
+ actions: "clearHomeContinueLoading"
484
+ },
485
+ RESET: {
450
486
  target: "idle",
451
487
  actions: "resetContext"
452
- } }
453
- },
488
+ }
489
+ } },
454
490
  runningModule: {
491
+ entry: "clearHomeContinueLoading",
455
492
  invoke: {
456
493
  id: "currentModule",
457
494
  src: "runChildModule",
@@ -519,49 +556,124 @@ const orchestratedFlowMachine = setup({
519
556
  target: "idle",
520
557
  actions: "resetContext"
521
558
  } } },
522
- error: { on: { RESET: {
523
- target: "idle",
524
- actions: "resetContext"
525
- } } }
559
+ error: {
560
+ entry: "clearHomeContinueLoading",
561
+ on: { RESET: {
562
+ target: "idle",
563
+ actions: "resetContext"
564
+ } }
565
+ }
526
566
  }
527
567
  });
528
568
 
529
569
  //#endregion
530
570
  //#region src/modules/flow/orchestratedFlowManager.ts
531
- function mapState(snapshot) {
571
+ function deriveUiModel(snapshot, mappedStatus, isHomePhase, options) {
572
+ const { enableHome } = options;
573
+ const isTerminal = mappedStatus === "finished" || mappedStatus === "error";
574
+ const awaitingOrchestrator = mappedStatus === "idle" || mappedStatus === "loading";
575
+ const visible = isTerminal === false && enableHome === true ? awaitingOrchestrator || isHomePhase : false;
576
+ const lazyModuleKey = mappedStatus === "ready" && visible === false ? snapshot.context.currentStep : void 0;
577
+ const shouldPrefetchHome = isTerminal === false && enableHome === true && snapshot.context.isHomeContinueLoading === false && (awaitingOrchestrator || isHomePhase);
578
+ return {
579
+ homeScreen: {
580
+ visible,
581
+ isContinueLoading: isTerminal ? false : snapshot.context.isHomeContinueLoading
582
+ },
583
+ presentation: {
584
+ isAwaitingReady: awaitingOrchestrator,
585
+ lazyModuleKey,
586
+ shouldPrefetchHome
587
+ }
588
+ };
589
+ }
590
+ function getMappedStatus(snapshot) {
591
+ const { value } = snapshot;
592
+ if (value === "idle") return "idle";
593
+ if (value === "loading" || value === "resolvingModule" || typeof value === "object") return "loading";
594
+ if (value === "finished") return "finished";
595
+ if (value === "error") return "error";
596
+ return "ready";
597
+ }
598
+ function mapOrchestratedFlowState(snapshot, uiOptions) {
532
599
  const { value, context } = snapshot;
533
- if (value === "idle") return { status: "idle" };
534
- if (value === "loading" || value === "resolvingModule" || typeof value === "object") return { status: "loading" };
535
- switch (value) {
536
- case "runningModule": {
537
- const childSnapshot = snapshot.children.currentModule?.getSnapshot();
538
- return {
539
- status: "ready",
540
- flow: context.flow ?? {},
541
- steps: context.steps,
542
- currentStepIndex: context.currentStepIndex,
543
- currentStep: context.currentStep,
544
- config: context.config,
545
- moduleState: childSnapshot ?? null
546
- };
600
+ const mappedStatus = getMappedStatus(snapshot);
601
+ const uiModel = deriveUiModel(snapshot, mappedStatus, value === "home", uiOptions);
602
+ if (mappedStatus === "idle") return {
603
+ status: "idle",
604
+ homeScreen: uiModel.homeScreen,
605
+ presentation: uiModel.presentation
606
+ };
607
+ if (mappedStatus === "loading") return {
608
+ status: "loading",
609
+ homeScreen: uiModel.homeScreen,
610
+ presentation: uiModel.presentation
611
+ };
612
+ if (mappedStatus === "finished") return {
613
+ status: "finished",
614
+ flow: context.flow ?? {},
615
+ finishStatus: context.finishStatus ?? {
616
+ redirectionUrl: "",
617
+ action: "none",
618
+ scoreStatus: "UNKNOWN"
619
+ },
620
+ homeScreen: uiModel.homeScreen,
621
+ presentation: uiModel.presentation
622
+ };
623
+ if (mappedStatus === "error") return {
624
+ status: "error",
625
+ error: context.error ?? "Unknown error",
626
+ homeScreen: uiModel.homeScreen,
627
+ presentation: uiModel.presentation
628
+ };
629
+ const childSnapshot = value === "runningModule" ? snapshot.children.currentModule?.getSnapshot() : null;
630
+ return {
631
+ status: "ready",
632
+ flow: context.flow ?? {},
633
+ steps: context.steps,
634
+ currentStepIndex: context.currentStepIndex,
635
+ currentStep: context.currentStep,
636
+ config: context.config,
637
+ moduleState: childSnapshot ?? null,
638
+ homeScreen: uiModel.homeScreen,
639
+ presentation: uiModel.presentation
640
+ };
641
+ }
642
+ function waitForOrchestratorReadyFromActor(actor, mapState$1, isResolved) {
643
+ return new Promise((resolve, reject) => {
644
+ const initial = mapState$1(actor.getSnapshot());
645
+ if (isResolved(initial)) {
646
+ resolve();
647
+ return;
547
648
  }
548
- case "finished": return {
549
- status: "finished",
550
- flow: context.flow ?? {},
551
- finishStatus: context.finishStatus ?? {
552
- redirectionUrl: "",
553
- action: "none",
554
- scoreStatus: "UNKNOWN"
649
+ if (initial.status === "error") {
650
+ reject(new Error(initial.error));
651
+ return;
652
+ }
653
+ if (initial.status === "finished") {
654
+ reject(/* @__PURE__ */ new Error("Flow finished"));
655
+ return;
656
+ }
657
+ const subscription = actor.subscribe(() => {
658
+ const next = mapState$1(actor.getSnapshot());
659
+ if (isResolved(next)) {
660
+ subscription.unsubscribe();
661
+ resolve();
662
+ } else if (next.status === "error") {
663
+ subscription.unsubscribe();
664
+ reject(new Error(next.error));
665
+ } else if (next.status === "finished") {
666
+ subscription.unsubscribe();
667
+ reject(/* @__PURE__ */ new Error("Flow finished"));
555
668
  }
556
- };
557
- case "error": return {
558
- status: "error",
559
- error: context.error ?? "Unknown error"
560
- };
561
- default: return { status: "idle" };
562
- }
669
+ });
670
+ });
563
671
  }
564
- function createApi({ actor, getSnapshot, trackElementClicked }) {
672
+ function createOrchestratedFlowApi({ actor, getSnapshot, trackElementClicked }, uiOptions) {
673
+ const { enableHome } = uiOptions;
674
+ function mapSnapshot() {
675
+ return mapOrchestratedFlowState(getSnapshot(), { enableHome });
676
+ }
565
677
  function getCanNext() {
566
678
  const snapshot = getSnapshot();
567
679
  const { currentStepIndex, steps } = snapshot.context;
@@ -609,7 +721,34 @@ function createApi({ actor, getSnapshot, trackElementClicked }) {
609
721
  return getCanNext();
610
722
  },
611
723
  getModuleConfig,
612
- isModuleEnabled
724
+ isModuleEnabled,
725
+ isAwaitingOrchestratorReady() {
726
+ return mapSnapshot().presentation.isAwaitingReady;
727
+ },
728
+ getLazyModuleKey() {
729
+ return mapSnapshot().presentation.lazyModuleKey;
730
+ },
731
+ shouldRenderHomeScreen() {
732
+ return mapSnapshot().homeScreen.visible;
733
+ },
734
+ async continueFromHome() {
735
+ const state = mapSnapshot();
736
+ if (!state.homeScreen.visible) return;
737
+ if (state.status === "ready") {
738
+ trackElementClicked?.("homeContinue");
739
+ actor.send({ type: "HOME_CONTINUE" });
740
+ return;
741
+ }
742
+ if (state.presentation.isAwaitingReady) {
743
+ trackElementClicked?.("homeContinue");
744
+ actor.send({ type: "HOME_CONTINUE" });
745
+ try {
746
+ await waitForOrchestratorReadyFromActor(actor, (snap) => mapOrchestratedFlowState(snap, { enableHome }), (next) => next.status === "ready" && next.homeScreen.visible === false);
747
+ } catch {
748
+ return;
749
+ }
750
+ }
751
+ }
613
752
  };
614
753
  }
615
754
  function createOrchestratedFlowActor(options) {
@@ -617,14 +756,18 @@ function createOrchestratedFlowActor(options) {
617
756
  getFlow: options.getFlow ?? getFlow,
618
757
  modules: options.modules,
619
758
  lazyModules: options.lazyModules,
620
- getFinishStatus: options.getFinishStatus
759
+ getFinishStatus: options.getFinishStatus,
760
+ enableHome: options.enableHome
621
761
  } }).start();
622
762
  }
623
763
  function createOrchestratedFlowManager(options) {
764
+ const actor = createOrchestratedFlowActor(options);
765
+ const enableHome = options.enableHome === true;
766
+ const uiOpts = { enableHome };
624
767
  return createManager({
625
- actor: createOrchestratedFlowActor(options),
626
- mapState,
627
- createApi,
768
+ actor,
769
+ mapState: (snapshot) => mapOrchestratedFlowState(snapshot, uiOpts),
770
+ createApi: (apiOpts) => createOrchestratedFlowApi(apiOpts, { enableHome }),
628
771
  instrumentation: createManagerInstrumentation("FLOW")
629
772
  });
630
773
  }
@@ -46,7 +46,6 @@ function getRequiredWasmPipelines(flow) {
46
46
  */
47
47
  function normalizeFlowModules(flow, options = {}) {
48
48
  let modules = normalizeIdModules(flow.flowModules);
49
- if (options.enableHome === true && !hasModule(modules, "HOME")) modules = addHome(modules);
50
49
  if (shouldInjectRedirect(flow, modules, options)) modules = addRedirect(flow, modules, options);
51
50
  return modules;
52
51
  }
@@ -72,17 +71,10 @@ function normalizeIdModules(modules) {
72
71
  return [module];
73
72
  });
74
73
  }
75
- function addHome(modules) {
76
- return [{
77
- key: "HOME",
78
- configuration: {}
79
- }, ...modules];
80
- }
81
74
  function shouldInjectRedirect(flow, modules, options) {
82
75
  return options.isDesktop === true && flow.redirectDesktopToMobile === true && !hasModule(modules, "REDIRECT_TO_MOBILE");
83
76
  }
84
77
  function addRedirect(flow, modules, options) {
85
- const modulesWithoutHome = modules.filter((module) => module.key !== "HOME");
86
78
  return [{
87
79
  key: "REDIRECT_TO_MOBILE",
88
80
  configuration: {
@@ -93,7 +85,7 @@ function addRedirect(flow, modules, options) {
93
85
  authHint: options.authHint,
94
86
  lang: options.lang
95
87
  }
96
- }, ...modulesWithoutHome];
88
+ }, ...modules];
97
89
  }
98
90
  function hasModule(modules, key) {
99
91
  return modules.some((module) => module.key === key);
package/dist/home.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as Manager } from "./Manager-C1r-74H0.js";
2
2
  import "./camera-C1Lz6NFz.js";
3
3
  import "./types-DGwsRYfm.js";
4
- import { t as EmptyConfig } from "./types-Bk2AoUFA.js";
5
- import * as xstate136 from "xstate";
4
+ import { t as EmptyConfig } from "./types-x6tue2ld.js";
5
+ import * as xstate709 from "xstate";
6
6
 
7
7
  //#region src/modules/home/types.d.ts
8
8
  type HomeConfig = EmptyConfig;
@@ -34,41 +34,41 @@ type HomeContext = {
34
34
  type HomeInput = {
35
35
  config: EmptyConfig;
36
36
  };
37
- declare const homeMachine: xstate136.StateMachine<HomeContext, {
37
+ declare const homeMachine: xstate709.StateMachine<HomeContext, {
38
38
  type: "LOAD";
39
39
  } | {
40
40
  type: "COMPLETE";
41
41
  } | {
42
42
  type: "RESET";
43
- }, {}, never, never, never, never, "idle" | "finished" | "main", string, HomeInput, xstate136.NonReducibleUnknown, xstate136.EventObject, xstate136.MetaObject, {
43
+ }, {}, never, never, never, never, "idle" | "finished" | "main", string, HomeInput, xstate709.NonReducibleUnknown, xstate709.EventObject, xstate709.MetaObject, {
44
44
  readonly id: "home";
45
45
  readonly initial: "idle";
46
46
  readonly context: ({
47
47
  input
48
48
  }: {
49
49
  spawn: {
50
- <TSrc extends never>(logic: TSrc, ...[options]: never): xstate136.ActorRefFromLogic<never>;
51
- <TLogic extends xstate136.AnyActorLogic>(src: TLogic, ...[options]: xstate136.ConditionalRequired<[options?: ({
50
+ <TSrc extends never>(logic: TSrc, ...[options]: never): xstate709.ActorRefFromLogic<never>;
51
+ <TLogic extends xstate709.AnyActorLogic>(src: TLogic, ...[options]: xstate709.ConditionalRequired<[options?: ({
52
52
  id?: never;
53
53
  systemId?: string;
54
- input?: xstate136.InputFrom<TLogic> | undefined;
54
+ input?: xstate709.InputFrom<TLogic> | undefined;
55
55
  syncSnapshot?: boolean;
56
- } & { [K in xstate136.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate136.IsNotNever<xstate136.RequiredLogicInput<TLogic>>>): xstate136.ActorRefFromLogic<TLogic>;
56
+ } & { [K in xstate709.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate709.IsNotNever<xstate709.RequiredLogicInput<TLogic>>>): xstate709.ActorRefFromLogic<TLogic>;
57
57
  };
58
58
  input: HomeInput;
59
- self: xstate136.ActorRef<xstate136.MachineSnapshot<HomeContext, {
59
+ self: xstate709.ActorRef<xstate709.MachineSnapshot<HomeContext, {
60
60
  type: "LOAD";
61
61
  } | {
62
62
  type: "COMPLETE";
63
63
  } | {
64
64
  type: "RESET";
65
- }, Record<string, xstate136.AnyActorRef | undefined>, xstate136.StateValue, string, unknown, any, any>, {
65
+ }, Record<string, xstate709.AnyActorRef | undefined>, xstate709.StateValue, string, unknown, any, any>, {
66
66
  type: "LOAD";
67
67
  } | {
68
68
  type: "COMPLETE";
69
69
  } | {
70
70
  type: "RESET";
71
- }, xstate136.AnyEventObject>;
71
+ }, xstate709.AnyEventObject>;
72
72
  }) => {
73
73
  config: EmptyConfig;
74
74
  };
package/dist/id.d.ts CHANGED
@@ -4,8 +4,8 @@ import "./Actor-Cqaw-2DF.js";
4
4
  import "./StateMachine-sxIjYRWS.js";
5
5
  import { t as CameraStream } from "./camera-C1Lz6NFz.js";
6
6
  import "./types-DGwsRYfm.js";
7
- import "./types-Bk2AoUFA.js";
7
+ import "./types-x6tue2ld.js";
8
8
  import "./deepsightService-D8Kbc-41.js";
9
9
  import { n as PermissionStatus, t as PermissionResult } from "./types-B-JXmW0H.js";
10
- import { A as IdCaptureDependencies, B as RecordingSession, C as CaptureIdResponse, D as ID_ERROR_CODES, E as DetectionStatus, F as IdCaptureThresholds, H as DetectionOrientation, I as IdDocumentType, L as IdError, M as IdCaptureGeometry, N as IdCaptureInput, O as IdCaptureConfig, P as IdCaptureMode, R as IdErrorCode, S as idCaptureMachine, T as DetectionArea, U as IdCaptureSettings, V as UploadIdResponse, _ as validateUploadResponse, a as IdCaptureInitResult, b as createIdCaptureActor, c as UploadIdImageParams, d as preloadIdRecordingProvider, f as processId, g as uploadIdImage, h as stopStream, j as IdCaptureEvent, k as IdCaptureContext, l as ValidationError, m as stopRecording, n as IdCaptureState, o as InitializeIdCaptureParams, p as startRecordingSession, r as createIdCaptureManager, s as StartRecordingParams, t as IdCaptureManager, u as initializeIdCapture, v as CreateIdCaptureActorOptions, w as CapturedImage, x as IdCaptureMachine, y as IdCaptureActor, z as IdFlowStep } from "./idCaptureManager-BF-9O4pN.js";
10
+ import { A as IdCaptureDependencies, B as RecordingSession, C as CaptureIdResponse, D as ID_ERROR_CODES, E as DetectionStatus, F as IdCaptureThresholds, H as DetectionOrientation, I as IdDocumentType, L as IdError, M as IdCaptureGeometry, N as IdCaptureInput, O as IdCaptureConfig, P as IdCaptureMode, R as IdErrorCode, S as idCaptureMachine, T as DetectionArea, U as IdCaptureSettings, V as UploadIdResponse, _ as validateUploadResponse, a as IdCaptureInitResult, b as createIdCaptureActor, c as UploadIdImageParams, d as preloadIdRecordingProvider, f as processId, g as uploadIdImage, h as stopStream, j as IdCaptureEvent, k as IdCaptureContext, l as ValidationError, m as stopRecording, n as IdCaptureState, o as InitializeIdCaptureParams, p as startRecordingSession, r as createIdCaptureManager, s as StartRecordingParams, t as IdCaptureManager, u as initializeIdCapture, v as CreateIdCaptureActorOptions, w as CapturedImage, x as IdCaptureMachine, y as IdCaptureActor, z as IdFlowStep } from "./idCaptureManager-eoc0PvFh.js";
11
11
  export { CameraStream, CaptureIdResponse, CapturedImage, type CreateIdCaptureActorOptions, DetectionArea, DetectionOrientation, DetectionStatus, ID_ERROR_CODES, type IdCaptureActor, IdCaptureConfig, type IdCaptureContext, IdCaptureDependencies, type IdCaptureEvent, IdCaptureGeometry, IdCaptureInitResult, type IdCaptureInput, type IdCaptureMachine, type IdCaptureManager, IdCaptureMode, IdCaptureSettings, type IdCaptureState, IdCaptureThresholds, IdDocumentType, IdError, IdErrorCode, IdFlowStep, InitializeIdCaptureParams, PermissionResult, PermissionStatus, RecordingSession, StartRecordingParams, UploadIdImageParams, UploadIdResponse, ValidationError, createIdCaptureActor, createIdCaptureManager, idCaptureMachine, initializeIdCapture, preloadIdRecordingProvider, processId, startRecordingSession, stopRecording, stopStream, uploadIdImage, validateUploadResponse };
package/dist/id.esm.js CHANGED
@@ -18,7 +18,7 @@ import "./ITimerCapability-6rqYcRcc.esm.js";
18
18
  import "./backCameraStream-BgZ58W73.esm.js";
19
19
  import "./getDeviceClass-DEQ0Ko8p.esm.js";
20
20
  import "./BrowserTimerProvider-DDCqhG2g.esm.js";
21
- import { a as startRecordingSession, c as uploadIdImage, i as processId, l as validateUploadResponse, n as initializeIdCapture, o as stopRecording, r as preloadIdRecordingProvider, s as stopStream, t as idCaptureMachine, u as ID_ERROR_CODES } from "./idCaptureStateMachine-DndyW7Rc.esm.js";
22
- import { r as createIdCaptureActor, t as createIdCaptureManager } from "./idCaptureManager-Cxuy_f9Q.esm.js";
21
+ import { a as startRecordingSession, c as uploadIdImage, i as processId, l as validateUploadResponse, n as initializeIdCapture, o as stopRecording, r as preloadIdRecordingProvider, s as stopStream, t as idCaptureMachine, u as ID_ERROR_CODES } from "./idCaptureStateMachine-hELTmJQc.esm.js";
22
+ import { r as createIdCaptureActor, t as createIdCaptureManager } from "./idCaptureManager-Bvv0ssj8.esm.js";
23
23
 
24
24
  export { ID_ERROR_CODES, createIdCaptureActor, createIdCaptureManager, idCaptureMachine, initializeIdCapture, preloadIdRecordingProvider, processId, startRecordingSession, stopRecording, stopStream, uploadIdImage, validateUploadResponse };
@@ -1,7 +1,7 @@
1
1
  import { n as eventModuleNames, o as createManagerInstrumentation, r as eventScreenNames } from "./events-GaZE-J-6.esm.js";
2
2
  import { a as createActor, o as createManager } from "./xstate.esm-BlgyVBVv.esm.js";
3
3
  import { t as BrowserStorageProvider } from "./BrowserStorageProvider-DOp7HlOV.esm.js";
4
- import { t as idCaptureMachine } from "./idCaptureStateMachine-DndyW7Rc.esm.js";
4
+ import { t as idCaptureMachine } from "./idCaptureStateMachine-hELTmJQc.esm.js";
5
5
 
6
6
  //#region src/modules/id/idCaptureActor.ts
7
7
  function createIdCaptureActor(options) {
@@ -80,6 +80,42 @@ function getErrorDescription(errorCode, uploadResponse) {
80
80
  SERVER_ERROR: "Please try again later"
81
81
  }[errorCode];
82
82
  }
83
+ function shouldCaptureBack(context) {
84
+ if (!(context.currentMode === "front" || context.currentMode === "passport")) return false;
85
+ if (context.config.onlyFront || context.config.onlyBack) return false;
86
+ if (context.config.usSmartCapture && context.currentMode === "front") return false;
87
+ const serverSkipped = context.uploadResponse?.skipBackIdCapture === true;
88
+ const forceBackForNonPassport = context.config.alwaysCaptureBackOfId === true && context.currentMode !== "passport";
89
+ return !serverSkipped || forceBackForNonPassport;
90
+ }
91
+ function shouldCaptureFront(context) {
92
+ return context.config.usSmartCapture === true && context.currentMode === "back" && context.uploadResponse?.forceFrontIdCapture === true;
93
+ }
94
+ function mapCaptureState(snapshot, context) {
95
+ const captureStatus = getCaptureStatus(snapshot) ?? "initializing";
96
+ const { uploadError, uploadResponse } = context;
97
+ return {
98
+ status: "capture",
99
+ captureStatus,
100
+ stream: context.stream,
101
+ detectionStatus: context.detectionStatus,
102
+ debugFrame: void 0,
103
+ attemptsRemaining: context.attemptsRemaining,
104
+ uploadError,
105
+ currentMode: context.currentMode,
106
+ counterValue: context.counterValue,
107
+ orientation: context.orientation,
108
+ idType: context.idType,
109
+ previewImageUrl: context.previewImageUrl,
110
+ uploadProgress: context.uploadProgress ?? 0,
111
+ uploadErrorMessage: uploadError ? getErrorMessage(uploadError) : void 0,
112
+ uploadErrorDescription: uploadError ? getErrorDescription(uploadError, uploadResponse) : void 0,
113
+ needsBackCapture: shouldCaptureBack(context),
114
+ needsFrontCapture: shouldCaptureFront(context),
115
+ showCaptureButtonInAuto: context.config.showCaptureButtonInAuto ?? false,
116
+ canRetry: context.attemptsRemaining > 0
117
+ };
118
+ }
83
119
  function mapState(snapshot) {
84
120
  const { context } = snapshot;
85
121
  if (snapshot.matches("idle")) return { status: "idle" };
@@ -105,32 +141,7 @@ function mapState(snapshot) {
105
141
  permissionStatus
106
142
  };
107
143
  }
108
- if (snapshot.matches("capture")) {
109
- const captureStatus = getCaptureStatus(snapshot);
110
- const needsBackCapture = (context.currentMode === "front" || context.currentMode === "passport") && !context.config.onlyFront && !context.config.onlyBack && !context.uploadResponse?.skipBackIdCapture && !(context.config.usSmartCapture && context.currentMode === "front");
111
- const needsFrontCapture = context.config.usSmartCapture === true && context.currentMode === "back" && context.uploadResponse?.forceFrontIdCapture === true;
112
- return {
113
- status: "capture",
114
- captureStatus: captureStatus ?? "initializing",
115
- stream: context.stream,
116
- detectionStatus: context.detectionStatus,
117
- debugFrame: void 0,
118
- attemptsRemaining: context.attemptsRemaining,
119
- uploadError: context.uploadError,
120
- currentMode: context.currentMode,
121
- counterValue: context.counterValue,
122
- orientation: context.orientation,
123
- idType: context.idType,
124
- previewImageUrl: context.previewImageUrl,
125
- uploadProgress: context.uploadProgress ?? 0,
126
- uploadErrorMessage: context.uploadError ? getErrorMessage(context.uploadError) : void 0,
127
- uploadErrorDescription: context.uploadError ? getErrorDescription(context.uploadError, context.uploadResponse) : void 0,
128
- needsBackCapture,
129
- needsFrontCapture,
130
- showCaptureButtonInAuto: context.config.showCaptureButtonInAuto ?? false,
131
- canRetry: context.attemptsRemaining > 0
132
- };
133
- }
144
+ if (snapshot.matches("capture")) return mapCaptureState(snapshot, context);
134
145
  if (snapshot.matches("mandatoryConsent")) return {
135
146
  status: "mandatoryConsent",
136
147
  regulationType: context.uploadResponse?.regulationType ?? "Other"
@@ -2,7 +2,7 @@ import { t as Manager } from "./Manager-C1r-74H0.js";
2
2
  import { t as ActorRefFrom } from "./Actor-Cqaw-2DF.js";
3
3
  import { n as StateMachine, t as AnyStateMachine } from "./StateMachine-sxIjYRWS.js";
4
4
  import { t as CameraStream } from "./camera-C1Lz6NFz.js";
5
- import { a as RegulationTypes, n as Flow, o as TutorialIdConfig } from "./types-Bk2AoUFA.js";
5
+ import { a as RegulationTypes, n as Flow, o as TutorialIdConfig } from "./types-x6tue2ld.js";
6
6
  import { c as IMLProviderCapability, d as IRecordingCapability, f as RecordingConnection, i as IncodeCanvas, l as MLProviderConfig, n as IMotionSensorCapability, r as StreamCanvasCapture, t as DeepsightService, u as IStorageCapability } from "./deepsightService-D8Kbc-41.js";
7
7
  import { n as PermissionStatus, t as PermissionResult } from "./types-B-JXmW0H.js";
8
8
 
@@ -1079,7 +1079,9 @@ const shouldContinueToBackGuard = ({ context }) => {
1079
1079
  if (context.config.onlyFront) return false;
1080
1080
  if (context.config.onlyBack) return false;
1081
1081
  if (context.config.usSmartCapture) return false;
1082
- if (context.uploadResponse?.skipBackIdCapture) return false;
1082
+ if (context.uploadResponse?.skipBackIdCapture) {
1083
+ if (!(context.config.alwaysCaptureBackOfId === true && context.currentMode !== "passport")) return false;
1084
+ }
1083
1085
  return true;
1084
1086
  };
1085
1087
  const shouldContinueToFrontGuard = ({ context }) => context.config.usSmartCapture === true && context.currentMode === "back" && context.uploadResponse?.forceFrontIdCapture === true;