@incodetech/core 0.0.0-dev-20260311-787552e → 0.0.0-dev-20260312-398a57f

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.
@@ -1,10 +1,10 @@
1
1
  import { t as Manager } from "./Manager-CVog-etk.js";
2
2
  import "./camera-HI2fNiV5.js";
3
3
  import { n as DocumentUploadContext, r as DocumentUploadInput, t as DocumentUploadConfig } from "./types-B_l5fu_D.js";
4
- import * as xstate271 from "xstate";
4
+ import * as xstate58 from "xstate";
5
5
 
6
6
  //#region src/modules/document-upload/documentUploadStateMachine.d.ts
7
- declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContext, {
7
+ declare const documentUploadMachine: xstate58.StateMachine<DocumentUploadContext, {
8
8
  type: "START";
9
9
  } | {
10
10
  type: "CAPTURE";
@@ -17,52 +17,52 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
17
17
  } | {
18
18
  type: "CLOSE";
19
19
  }, {
20
- [x: string]: xstate271.ActorRefFromLogic<xstate271.PromiseActorLogic<MediaStream, void, xstate271.EventObject>> | xstate271.ActorRefFromLogic<xstate271.PromiseActorLogic<void, {
20
+ [x: string]: xstate58.ActorRefFromLogic<xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>> | xstate58.ActorRefFromLogic<xstate58.PromiseActorLogic<void, {
21
21
  imageBase64: string;
22
22
  documentType: string;
23
23
  onProgress: (progress: number) => void;
24
- }, xstate271.EventObject>> | undefined;
25
- }, xstate271.Values<{
24
+ }, xstate58.EventObject>> | undefined;
25
+ }, xstate58.Values<{
26
26
  initCamera: {
27
27
  src: "initCamera";
28
- logic: xstate271.PromiseActorLogic<MediaStream, void, xstate271.EventObject>;
28
+ logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
29
29
  id: string | undefined;
30
30
  };
31
31
  uploadDocument: {
32
32
  src: "uploadDocument";
33
- logic: xstate271.PromiseActorLogic<void, {
33
+ logic: xstate58.PromiseActorLogic<void, {
34
34
  imageBase64: string;
35
35
  documentType: string;
36
36
  onProgress: (progress: number) => void;
37
- }, xstate271.EventObject>;
37
+ }, xstate58.EventObject>;
38
38
  id: string | undefined;
39
39
  };
40
- }>, xstate271.Values<{
40
+ }>, xstate58.Values<{
41
41
  setStream: {
42
42
  type: "setStream";
43
- params: xstate271.NonReducibleUnknown;
43
+ params: xstate58.NonReducibleUnknown;
44
44
  };
45
45
  setProgress: {
46
46
  type: "setProgress";
47
- params: xstate271.NonReducibleUnknown;
47
+ params: xstate58.NonReducibleUnknown;
48
48
  };
49
49
  clearError: {
50
50
  type: "clearError";
51
- params: xstate271.NonReducibleUnknown;
51
+ params: xstate58.NonReducibleUnknown;
52
52
  };
53
53
  stopStream: {
54
54
  type: "stopStream";
55
- params: xstate271.NonReducibleUnknown;
56
- };
57
- setError: {
58
- type: "setError";
59
- params: xstate271.NonReducibleUnknown;
55
+ params: xstate58.NonReducibleUnknown;
60
56
  };
61
57
  setImageAndClearError: {
62
58
  type: "setImageAndClearError";
63
- params: xstate271.NonReducibleUnknown;
59
+ params: xstate58.NonReducibleUnknown;
60
+ };
61
+ setError: {
62
+ type: "setError";
63
+ params: xstate58.NonReducibleUnknown;
64
64
  };
65
- }>, never, never, "error" | "initCamera" | "capturing" | "finished" | "closed" | "uploading" | "idle", string, DocumentUploadInput, xstate271.NonReducibleUnknown, xstate271.EventObject, xstate271.MetaObject, {
65
+ }>, never, never, "initCamera" | "error" | "capturing" | "finished" | "closed" | "uploading" | "idle", string, DocumentUploadInput, xstate58.NonReducibleUnknown, xstate58.EventObject, xstate58.MetaObject, {
66
66
  readonly id: "documentUpload";
67
67
  readonly initial: "idle";
68
68
  readonly context: ({
@@ -71,67 +71,67 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
71
71
  spawn: {
72
72
  <TSrc extends "initCamera" | "uploadDocument">(logic: TSrc, ...[options]: ({
73
73
  src: "initCamera";
74
- logic: xstate271.PromiseActorLogic<MediaStream, void, xstate271.EventObject>;
74
+ logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
75
75
  id: string | undefined;
76
76
  } extends infer T ? T extends {
77
77
  src: "initCamera";
78
- logic: xstate271.PromiseActorLogic<MediaStream, void, xstate271.EventObject>;
78
+ logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
79
79
  id: string | undefined;
80
80
  } ? T extends {
81
81
  src: TSrc;
82
- } ? xstate271.ConditionalRequired<[options?: ({
82
+ } ? xstate58.ConditionalRequired<[options?: ({
83
83
  id?: T["id"] | undefined;
84
84
  systemId?: string;
85
- input?: xstate271.InputFrom<T["logic"]> | undefined;
85
+ input?: xstate58.InputFrom<T["logic"]> | undefined;
86
86
  syncSnapshot?: boolean;
87
- } & { [K in xstate271.RequiredActorOptions<T>]: unknown }) | undefined], xstate271.IsNotNever<xstate271.RequiredActorOptions<T>>> : never : never : never) | ({
87
+ } & { [K in xstate58.RequiredActorOptions<T>]: unknown }) | undefined], xstate58.IsNotNever<xstate58.RequiredActorOptions<T>>> : never : never : never) | ({
88
88
  src: "uploadDocument";
89
- logic: xstate271.PromiseActorLogic<void, {
89
+ logic: xstate58.PromiseActorLogic<void, {
90
90
  imageBase64: string;
91
91
  documentType: string;
92
92
  onProgress: (progress: number) => void;
93
- }, xstate271.EventObject>;
93
+ }, xstate58.EventObject>;
94
94
  id: string | undefined;
95
95
  } extends infer T_1 ? T_1 extends {
96
96
  src: "uploadDocument";
97
- logic: xstate271.PromiseActorLogic<void, {
97
+ logic: xstate58.PromiseActorLogic<void, {
98
98
  imageBase64: string;
99
99
  documentType: string;
100
100
  onProgress: (progress: number) => void;
101
- }, xstate271.EventObject>;
101
+ }, xstate58.EventObject>;
102
102
  id: string | undefined;
103
103
  } ? T_1 extends {
104
104
  src: TSrc;
105
- } ? xstate271.ConditionalRequired<[options?: ({
105
+ } ? xstate58.ConditionalRequired<[options?: ({
106
106
  id?: T_1["id"] | undefined;
107
107
  systemId?: string;
108
- input?: xstate271.InputFrom<T_1["logic"]> | undefined;
108
+ input?: xstate58.InputFrom<T_1["logic"]> | undefined;
109
109
  syncSnapshot?: boolean;
110
- } & { [K_1 in xstate271.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate271.IsNotNever<xstate271.RequiredActorOptions<T_1>>> : never : never : never)): xstate271.ActorRefFromLogic<xstate271.GetConcreteByKey<xstate271.Values<{
110
+ } & { [K_1 in xstate58.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate58.IsNotNever<xstate58.RequiredActorOptions<T_1>>> : never : never : never)): xstate58.ActorRefFromLogic<xstate58.GetConcreteByKey<xstate58.Values<{
111
111
  initCamera: {
112
112
  src: "initCamera";
113
- logic: xstate271.PromiseActorLogic<MediaStream, void, xstate271.EventObject>;
113
+ logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
114
114
  id: string | undefined;
115
115
  };
116
116
  uploadDocument: {
117
117
  src: "uploadDocument";
118
- logic: xstate271.PromiseActorLogic<void, {
118
+ logic: xstate58.PromiseActorLogic<void, {
119
119
  imageBase64: string;
120
120
  documentType: string;
121
121
  onProgress: (progress: number) => void;
122
- }, xstate271.EventObject>;
122
+ }, xstate58.EventObject>;
123
123
  id: string | undefined;
124
124
  };
125
125
  }>, "src", TSrc>["logic"]>;
126
- <TLogic extends xstate271.AnyActorLogic>(src: TLogic, ...[options]: xstate271.ConditionalRequired<[options?: ({
126
+ <TLogic extends xstate58.AnyActorLogic>(src: TLogic, ...[options]: xstate58.ConditionalRequired<[options?: ({
127
127
  id?: never;
128
128
  systemId?: string;
129
- input?: xstate271.InputFrom<TLogic> | undefined;
129
+ input?: xstate58.InputFrom<TLogic> | undefined;
130
130
  syncSnapshot?: boolean;
131
- } & { [K in xstate271.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate271.IsNotNever<xstate271.RequiredLogicInput<TLogic>>>): xstate271.ActorRefFromLogic<TLogic>;
131
+ } & { [K in xstate58.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate58.IsNotNever<xstate58.RequiredLogicInput<TLogic>>>): xstate58.ActorRefFromLogic<TLogic>;
132
132
  };
133
133
  input: DocumentUploadInput;
134
- self: xstate271.ActorRef<xstate271.MachineSnapshot<DocumentUploadContext, {
134
+ self: xstate58.ActorRef<xstate58.MachineSnapshot<DocumentUploadContext, {
135
135
  type: "START";
136
136
  } | {
137
137
  type: "CAPTURE";
@@ -143,7 +143,7 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
143
143
  type: "RETRY";
144
144
  } | {
145
145
  type: "CLOSE";
146
- }, Record<string, xstate271.AnyActorRef | undefined>, xstate271.StateValue, string, unknown, any, any>, {
146
+ }, Record<string, xstate58.AnyActorRef | undefined>, xstate58.StateValue, string, unknown, any, any>, {
147
147
  type: "START";
148
148
  } | {
149
149
  type: "CAPTURE";
@@ -155,7 +155,7 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
155
155
  type: "RETRY";
156
156
  } | {
157
157
  type: "CLOSE";
158
- }, xstate271.AnyEventObject>;
158
+ }, xstate58.AnyEventObject>;
159
159
  }) => {
160
160
  config: DocumentUploadConfig;
161
161
  stream: undefined;
@@ -225,7 +225,7 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
225
225
  } | {
226
226
  type: "CLOSE";
227
227
  };
228
- self: xstate271.ActorRef<xstate271.MachineSnapshot<DocumentUploadContext, {
228
+ self: xstate58.ActorRef<xstate58.MachineSnapshot<DocumentUploadContext, {
229
229
  type: "START";
230
230
  } | {
231
231
  type: "CAPTURE";
@@ -237,7 +237,7 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
237
237
  type: "RETRY";
238
238
  } | {
239
239
  type: "CLOSE";
240
- }, Record<string, xstate271.AnyActorRef>, xstate271.StateValue, string, unknown, any, any>, {
240
+ }, Record<string, xstate58.AnyActorRef>, xstate58.StateValue, string, unknown, any, any>, {
241
241
  type: "START";
242
242
  } | {
243
243
  type: "CAPTURE";
@@ -249,7 +249,7 @@ declare const documentUploadMachine: xstate271.StateMachine<DocumentUploadContex
249
249
  type: "RETRY";
250
250
  } | {
251
251
  type: "CLOSE";
252
- }, xstate271.AnyEventObject>;
252
+ }, xstate58.AnyEventObject>;
253
253
  }) => {
254
254
  imageBase64: string;
255
255
  documentType: string;
package/dist/ekyc.d.ts CHANGED
@@ -99,6 +99,7 @@ type EkycFormState = {
99
99
  prefilled: Record<string, boolean>;
100
100
  hideEmail: boolean;
101
101
  fieldsCountry: string;
102
+ submitError: string;
102
103
  };
103
104
  type EkycSubmittingState = {
104
105
  status: 'submitting';
package/dist/ekyc.esm.js CHANGED
@@ -10369,12 +10369,6 @@ function fillFromSuggestion(values, touched, suggestion) {
10369
10369
  };
10370
10370
  }
10371
10371
 
10372
- //#endregion
10373
- //#region src/modules/ekyc/ekycGuards.ts
10374
- const isValidGuard = ({ context }) => context.isValid;
10375
- const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
10376
- const hasVerificationFieldsGuard = ({ context }) => !!context.config.verificationFields;
10377
-
10378
10372
  //#endregion
10379
10373
  //#region src/modules/ekyc/ekycServices.ts
10380
10374
  /** Fetches module configuration for EXTERNAL_VERIFICATION */
@@ -10414,13 +10408,40 @@ async function searchAddress(query, signal) {
10414
10408
  };
10415
10409
  }) } };
10416
10410
  }
10411
+ var EkycSubmitError = class extends Error {
10412
+ constructor(status, apiError) {
10413
+ super(`POST ${endpoints.ekycSubmit} failed: ${status} – ${apiError}`);
10414
+ this.name = "EkycSubmitError";
10415
+ this.status = status;
10416
+ this.apiError = apiError;
10417
+ }
10418
+ };
10417
10419
  /** Submits eKYC verification */
10418
10420
  async function submitEkyc(data, signal) {
10419
- const res = await api.post(endpoints.ekycSubmit, data, { signal });
10420
- if (!res.ok) throw new Error(`POST ${endpoints.ekycSubmit} failed: ${res.status} ${res.statusText}`);
10421
- return res.data;
10421
+ try {
10422
+ return (await api.post(endpoints.ekycSubmit, data, { signal })).data;
10423
+ } catch (err) {
10424
+ const httpErr = err;
10425
+ if (typeof httpErr.status === "number") {
10426
+ const body = httpErr.data;
10427
+ const apiError = body?.error ?? body?.message ?? String(err);
10428
+ throw new EkycSubmitError(httpErr.status, apiError);
10429
+ }
10430
+ throw err;
10431
+ }
10422
10432
  }
10423
10433
 
10434
+ //#endregion
10435
+ //#region src/modules/ekyc/ekycGuards.ts
10436
+ const isValidGuard = ({ context }) => context.isValid;
10437
+ const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
10438
+ const hasVerificationFieldsGuard = ({ context }) => !!context.config.verificationFields;
10439
+ const COUNTRY_NOT_SUPPORTED_MSG = "Request unsuccessful. Country not supported for EKYC.";
10440
+ const isCountryNotSupportedGuard = ({ event }) => {
10441
+ const err = event.error;
10442
+ return err instanceof EkycSubmitError && err.status === 400 && err.apiError === COUNTRY_NOT_SUPPORTED_MSG;
10443
+ };
10444
+
10424
10445
  //#endregion
10425
10446
  //#region src/modules/ekyc/ekycActors.ts
10426
10447
  const fetchModuleConfigActor = fromPromise(async ({ input, signal }) => fetchModuleConfig(input.flowId, signal));
@@ -10516,7 +10537,8 @@ const ekycMachine = setup({
10516
10537
  isValid,
10517
10538
  touched: newTouched,
10518
10539
  displayErrors,
10519
- errorParams
10540
+ errorParams,
10541
+ submitError: ""
10520
10542
  };
10521
10543
  }),
10522
10544
  fillAddressFields: assign(({ context, event }) => {
@@ -10531,12 +10553,15 @@ const ekycMachine = setup({
10531
10553
  isValid,
10532
10554
  touched: newTouched,
10533
10555
  displayErrors,
10534
- errorParams
10556
+ errorParams,
10557
+ submitError: ""
10535
10558
  };
10536
10559
  }),
10537
10560
  setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions })),
10538
10561
  setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
10539
10562
  clearErrorMessage: assign({ errorMessage: () => "" }),
10563
+ setSubmitError: assign(() => ({ submitError: "verification.errors.countryNotSupported" })),
10564
+ clearSubmitError: assign({ submitError: () => "" }),
10540
10565
  markSubmitAttempted: assign(({ context }) => {
10541
10566
  const { displayErrors, errorParams } = computeDisplayErrors(context.errors, context.touched, true, context.fieldsCountry);
10542
10567
  return {
@@ -10583,7 +10608,8 @@ const ekycMachine = setup({
10583
10608
  guards: {
10584
10609
  isValid: isValidGuard,
10585
10610
  hasFlowId: hasFlowIdGuard,
10586
- hasVerificationFields: hasVerificationFieldsGuard
10611
+ hasVerificationFields: hasVerificationFieldsGuard,
10612
+ isCountryNotSupported: isCountryNotSupportedGuard
10587
10613
  }
10588
10614
  }).createMachine({
10589
10615
  id: "ekyc",
@@ -10604,6 +10630,7 @@ const ekycMachine = setup({
10604
10630
  prefilled: {},
10605
10631
  hideEmail: false,
10606
10632
  errorMessage: "",
10633
+ submitError: "",
10607
10634
  touched: {},
10608
10635
  submitAttempted: false,
10609
10636
  _searchQuery: ""
@@ -10704,10 +10731,14 @@ const ekycMachine = setup({
10704
10731
  src: "submitEkyc",
10705
10732
  input: ({ context }) => buildSubmitPayload(context),
10706
10733
  onDone: { target: "success" },
10707
- onError: {
10734
+ onError: [{
10735
+ target: "form",
10736
+ guard: "isCountryNotSupported",
10737
+ actions: "setSubmitError"
10738
+ }, {
10708
10739
  target: "error",
10709
10740
  actions: "setErrorMessage"
10710
- }
10741
+ }]
10711
10742
  }
10712
10743
  },
10713
10744
  success: {
@@ -10758,7 +10789,8 @@ function mapState(snapshot) {
10758
10789
  addressSuggestions: context.addressSuggestions,
10759
10790
  prefilled: context.prefilled,
10760
10791
  hideEmail: context.hideEmail,
10761
- fieldsCountry: context.fieldsCountry
10792
+ fieldsCountry: context.fieldsCountry,
10793
+ submitError: context.submitError
10762
10794
  };
10763
10795
  if (typedSnapshot.matches("submitting")) return { status: "submitting" };
10764
10796
  if (typedSnapshot.matches("success")) return { status: "success" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/core",
3
- "version": "0.0.0-dev-20260311-787552e",
3
+ "version": "0.0.0-dev-20260312-398a57f",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",