@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,388 +0,0 @@
1
- import { t as api } from "./api-CESGtpbH.esm.js";
2
- import { x as getTimestamp } from "./events-D6-e4vok.esm.js";
3
- import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
4
- import { a as fromPromise, r as assign, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
5
- import { t as validateCPF } from "./cpf-PPz2Njto.esm.js";
6
-
7
- //#region ../infra/src/providers/browser/DateFormattingProvider.ts
8
- var DateFormattingProvider = class {
9
- utcToIsoDateString(value) {
10
- if (value === void 0 || value === null || value === "") return "";
11
- const date = new Date(value);
12
- if (Number.isNaN(date.getTime())) return "";
13
- return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, "0")}-${String(date.getUTCDate()).padStart(2, "0")}`;
14
- }
15
- parseIsoDateStringToEpochMs(value) {
16
- return Date.parse(value);
17
- }
18
- getAgeInYears(birthDate, referenceEpochMs) {
19
- const now = new Date(referenceEpochMs);
20
- const birth = typeof birthDate === "string" && /^\d{4}-\d{2}-\d{2}$/.test(birthDate) ? (() => {
21
- const [y, m, d] = birthDate.split("-").map(Number);
22
- return new Date(y, m - 1, d);
23
- })() : new Date(birthDate);
24
- let age = now.getFullYear() - birth.getFullYear();
25
- const monthDiff = now.getMonth() - birth.getMonth();
26
- if (monthDiff < 0 || monthDiff === 0 && now.getDate() < birth.getDate()) age--;
27
- return age;
28
- }
29
- };
30
-
31
- //#endregion
32
- //#region src/modules/id-ocr/idOcrUtils.ts
33
- const dateFormattingInstance$1 = new DateFormattingProvider();
34
- const resolveFullName = (data) => {
35
- if (data.name?.fullName) return data.name.fullName;
36
- const joined = [
37
- data.name?.givenName ?? data.givenName ?? data.firstName,
38
- data.name?.paternalLastName ?? data.fathersSurname,
39
- data.name?.maternalLastName ?? data.mothersSurname
40
- ].filter(Boolean).join(" ").trim();
41
- if (joined) return joined;
42
- return data.fullNameMrz ?? "";
43
- };
44
- const mapOcrResponseToFormData = (data) => ({
45
- name: resolveFullName(data),
46
- firstName: data.firstName ?? data.givenName ?? data.name?.givenName ?? "",
47
- lastName: data.fathersSurname ?? data.name?.paternalLastName ?? "",
48
- paternalLastName: data.fathersSurname ?? data.name?.paternalLastName ?? "",
49
- maternalLastName: data.mothersSurname ?? data.name?.maternalLastName ?? "",
50
- birthDate: dateFormattingInstance$1.utcToIsoDateString(data.birthDate),
51
- gender: data.gender ?? "",
52
- address: data.address ?? "",
53
- documentNumber: data.documentNumber ?? "",
54
- personalNumber: data.personalNumber ?? "",
55
- curp: data.curp ?? "",
56
- issuingCountry: data.issuingCountry ?? "",
57
- expireAt: data.expireAt,
58
- email: ""
59
- });
60
- const mapUpdateOcrDataForApi = (params) => {
61
- const working = { ...params };
62
- const nameTrimmed = working.name?.trim();
63
- if (nameTrimmed) working.name = nameTrimmed;
64
- if (nameTrimmed && !working.firstName?.trim() && !working.paternalLastName?.trim() && !working.maternalLastName?.trim()) {
65
- const tokens = nameTrimmed.split(/\s+/).filter(Boolean);
66
- if (tokens.length === 3) {
67
- working.firstName = tokens[0];
68
- working.paternalLastName = tokens[1];
69
- working.maternalLastName = tokens[2];
70
- }
71
- }
72
- const body = {};
73
- for (const key of Object.keys(working)) {
74
- const raw = working[key];
75
- if (raw === void 0) continue;
76
- if (key === "birthDate") {
77
- body[key] = dateFormattingInstance$1.parseIsoDateStringToEpochMs(raw);
78
- continue;
79
- }
80
- body[key] = typeof raw === "string" ? raw.trim() : raw;
81
- }
82
- return body;
83
- };
84
-
85
- //#endregion
86
- //#region src/modules/id-ocr/idOcrServices.ts
87
- /** Fetch ID OCR data. Throws on failure. */
88
- async function getOcrData(signal, isSecondId) {
89
- const url = isSecondId ? endpoints.ocrDataSecondId : endpoints.ocrData;
90
- const res = await api.get(url, { signal });
91
- if (!res.ok) throw new Error(`GET ${url} failed: ${res.status} ${res.statusText}`);
92
- return res.data;
93
- }
94
- /** Updates ID OCR data if OCR data is editable. Throws on failure. */
95
- async function updateOcrData(params, signal, isSecondId) {
96
- const url = isSecondId ? endpoints.updateEditableOcrDataSecondId : endpoints.updateEditableOcrData;
97
- const res = await api.put(url, mapUpdateOcrDataForApi(params), { signal });
98
- if (!res.ok) throw new Error(`PUT failed: ${url} failed: ${res.status} ${res.statusText}`);
99
- return res.data;
100
- }
101
-
102
- //#endregion
103
- //#region src/modules/id-ocr/idOcrConsts.ts
104
- const MIN_AGE = 18;
105
- const CPFFlowIds = [
106
- "65985b7ec335fa20effa547b",
107
- "657b823ddb312196b5dd30f8",
108
- "659843c207413e34c407fc1d",
109
- "657c8b7a188817b6ec04b26c",
110
- "6793bba8845d50f53f5fb910",
111
- "679826a35ec9927c65407873",
112
- "6838c03fae866c13e63fbaf4",
113
- "681a14fb37a49f2319cbf359",
114
- "68e5318406c77c2b6993ed8f",
115
- "68e531531a6892418eecd21f",
116
- "68e5314706c77c2b6993eb99"
117
- ];
118
-
119
- //#endregion
120
- //#region src/modules/id-ocr/idOcrFields.ts
121
- const CPF_ONLY_OCR_FIELDS = [{
122
- key: "documentNumber",
123
- labelKey: "userData.cpf",
124
- type: "text",
125
- validation: [{ type: "required" }, { type: "cpf" }],
126
- required: true
127
- }];
128
- const OCR_FIELDS = [
129
- {
130
- key: "name",
131
- labelKey: "userData.fullName",
132
- type: "text",
133
- validation: [{ type: "required" }],
134
- required: true
135
- },
136
- {
137
- key: "birthDate",
138
- labelKey: "userData.dateOfBirth",
139
- type: "date",
140
- validation: [{ type: "required" }, {
141
- type: "minAge",
142
- years: MIN_AGE
143
- }],
144
- required: true
145
- },
146
- {
147
- key: "gender",
148
- labelKey: "userData.sex",
149
- type: "radio",
150
- options: [{
151
- label: "common.male",
152
- value: "M"
153
- }, {
154
- label: "common.female",
155
- value: "F"
156
- }],
157
- required: false
158
- },
159
- {
160
- key: "issuingCountry",
161
- labelKey: "userData.issuingCountry",
162
- type: "text",
163
- validation: [{ type: "required" }],
164
- required: true
165
- },
166
- {
167
- key: "documentNumber",
168
- labelKey: "userData.documentNumber",
169
- type: "text",
170
- validation: [{ type: "required" }],
171
- required: true
172
- },
173
- {
174
- key: "address",
175
- labelKey: "userData.address",
176
- type: "text",
177
- validation: [{ type: "required" }],
178
- required: true
179
- }
180
- ];
181
- const getOcrFields = (config) => {
182
- const { flowId } = config;
183
- if (flowId && CPFFlowIds.includes(flowId)) return CPF_ONLY_OCR_FIELDS;
184
- return OCR_FIELDS;
185
- };
186
-
187
- //#endregion
188
- //#region src/modules/id-ocr/idOcrValidators.ts
189
- const dateFormattingInstance = new DateFormattingProvider();
190
- const createValidators = () => {
191
- return {
192
- required: (value, _) => !value.trim() ? "modifiableOCR.cantBeEmpty" : void 0,
193
- minAge: (value, rule) => {
194
- if (!value.trim() || rule.type !== "minAge") return void 0;
195
- return dateFormattingInstance.getAgeInYears(value, getTimestamp()) < rule.years ? "modifiableOCR.ageRange" : void 0;
196
- },
197
- cpf: (value, rule) => {
198
- if (rule.type !== "cpf" || !value.trim()) return void 0;
199
- return validateCPF(value) ? void 0 : "verification.errors.invalidTaxId";
200
- }
201
- };
202
- };
203
- const normalizeFieldValue = (value) => typeof value === "string" ? value.trim() : String(value ?? "");
204
- const validateFieldValue = (value, field, validators) => {
205
- if (!field.validation) return void 0;
206
- for (const rule of field.validation) {
207
- const error = validators[rule.type](value, rule);
208
- if (error) return error;
209
- }
210
- };
211
- const validateOcrForm = (data, fields) => {
212
- const validators = createValidators();
213
- return fields.reduce((errors, field) => {
214
- const error = validateFieldValue(normalizeFieldValue(data[field.key]), field, validators);
215
- if (error) errors[field.key] = error;
216
- return errors;
217
- }, {});
218
- };
219
- const validateOcrField = (data, fieldKey, fields) => {
220
- const field = fields.find((field$1) => field$1.key === fieldKey);
221
- if (!field) return void 0;
222
- const validators = createValidators();
223
- return validateFieldValue(normalizeFieldValue(data[field.key]), field, validators);
224
- };
225
-
226
- //#endregion
227
- //#region src/modules/id-ocr/idOcrStateMachine.ts
228
- const emptyOcrData = () => ({});
229
- const idOcrStateMachine = setup({
230
- types: {
231
- context: {},
232
- events: {},
233
- input: {}
234
- },
235
- actors: {
236
- getOcrData: fromPromise(async ({ input, signal }) => getOcrData(signal, input.isSecondId)),
237
- updateOcrData: fromPromise(async ({ input, signal }) => updateOcrData(input.params, signal, input.isSecondId))
238
- },
239
- actions: {
240
- setInitialData: assign(({ event }) => {
241
- const raw = event.output;
242
- return {
243
- formData: mapOcrResponseToFormData(raw),
244
- editedFields: {},
245
- validationErrors: void 0,
246
- error: void 0
247
- };
248
- }),
249
- updateField: assign(({ context, event }) => {
250
- const { field, value } = event;
251
- return {
252
- formData: {
253
- ...context.formData,
254
- [field]: value
255
- },
256
- editedFields: {
257
- ...context.editedFields,
258
- [field]: value
259
- }
260
- };
261
- }),
262
- clearFieldValidationError: assign(({ context, event }) => {
263
- if (event.type !== "DATA_CHANGED") return {};
264
- const { field } = event;
265
- const errs = context.validationErrors;
266
- if (!errs?.[field]) return {};
267
- const next = { ...errs };
268
- delete next[field];
269
- return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
270
- }),
271
- setOcrValidationErrors: assign(({ context }) => ({ validationErrors: validateOcrForm(context.formData, getOcrFields(context.config)) })),
272
- validateFormField: assign(({ context, event }) => {
273
- if (event.type !== "VALIDATE_FIELD") return {};
274
- const { field } = event;
275
- const message = validateOcrField(context.formData, field, getOcrFields(context.config));
276
- const next = { ...context.validationErrors ?? {} };
277
- if (message) next[field] = message;
278
- else delete next[field];
279
- return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
280
- }),
281
- setError: assign(({ event }) => ({ error: String(event.error) })),
282
- beginSecondIdOcrPhase: assign(() => ({
283
- activeOcrDocument: "second",
284
- editedFields: {},
285
- validationErrors: void 0
286
- })),
287
- resetForRetry: assign(() => ({
288
- activeOcrDocument: "first",
289
- formData: emptyOcrData(),
290
- editedFields: {},
291
- error: void 0,
292
- validationErrors: void 0
293
- })),
294
- computeValidationResult: assign(({ context }) => ({ validationErrors: validateOcrForm(context.formData, getOcrFields(context.config)) }))
295
- },
296
- guards: {
297
- isOcrEditable: ({ context }) => context.config.editableOcr === true,
298
- shouldLoadSecondOcrAfterFirst: ({ context }) => context.config.secondId === true && context.activeOcrDocument === "first",
299
- isOcrFormValid: ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0,
300
- shouldSubmit: ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0 && Object.keys(context.editedFields).length > 0,
301
- shouldProceedWithoutSubmitToSecondId: ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0 && Object.keys(context.editedFields).length === 0 && context.config.secondId === true && context.activeOcrDocument === "first"
302
- }
303
- }).createMachine({
304
- id: "idOcr",
305
- initial: "idle",
306
- context: ({ input }) => {
307
- const data = emptyOcrData();
308
- return {
309
- config: input.config,
310
- formData: data,
311
- editedFields: {},
312
- activeOcrDocument: "first"
313
- };
314
- },
315
- states: {
316
- idle: { on: { LOAD: [{ target: "loading" }] } },
317
- loading: { invoke: {
318
- src: "getOcrData",
319
- input: ({ context }) => ({ isSecondId: context.activeOcrDocument === "second" }),
320
- onDone: [{
321
- target: "inputting",
322
- guard: "isOcrEditable",
323
- actions: "setInitialData"
324
- }, {
325
- target: "readonly",
326
- actions: "setInitialData"
327
- }],
328
- onError: {
329
- target: "error",
330
- actions: "setError"
331
- }
332
- } },
333
- readonly: { on: { CONTINUE: [{
334
- target: "loading",
335
- guard: "shouldLoadSecondOcrAfterFirst",
336
- actions: "beginSecondIdOcrPhase"
337
- }, { target: "success" }] } },
338
- inputting: { on: {
339
- DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
340
- VALIDATE_FIELD: { actions: "validateFormField" },
341
- CONTINUE: { target: "validatingContinue" }
342
- } },
343
- validatingContinue: {
344
- entry: "computeValidationResult",
345
- always: [
346
- {
347
- guard: "shouldSubmit",
348
- target: "submitting"
349
- },
350
- {
351
- guard: "shouldProceedWithoutSubmitToSecondId",
352
- target: "loading",
353
- actions: "beginSecondIdOcrPhase"
354
- },
355
- {
356
- guard: "isOcrFormValid",
357
- target: "success"
358
- },
359
- { target: "inputting" }
360
- ]
361
- },
362
- submitting: { invoke: {
363
- src: "updateOcrData",
364
- input: ({ context }) => ({
365
- params: context.editedFields,
366
- isSecondId: context.activeOcrDocument === "second"
367
- }),
368
- onDone: [{
369
- target: "loading",
370
- guard: "shouldLoadSecondOcrAfterFirst",
371
- actions: "beginSecondIdOcrPhase"
372
- }, { target: "success" }],
373
- onError: {
374
- target: "error",
375
- actions: "setError"
376
- }
377
- } },
378
- error: { on: { RETRY: {
379
- target: "loading",
380
- actions: "resetForRetry"
381
- } } },
382
- success: { after: { 3e3: "finished" } },
383
- finished: { type: "final" }
384
- }
385
- });
386
-
387
- //#endregion
388
- export { MIN_AGE as a, CPFFlowIds as i, OCR_FIELDS as n, getOcrFields as r, idOcrStateMachine as t };
@@ -1,71 +0,0 @@
1
- import { t as api } from "./api-CESGtpbH.esm.js";
2
- import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
3
- import { a as fromPromise, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
4
-
5
- //#region src/modules/id-verification/idVerificationServices.ts
6
- /**
7
- * Submits the captured ID for backend verification. Wraps `POST /omni/process/id`
8
- * (or `/omni/process/second-id` when `isSecondId` is true).
9
- *
10
- * The `queueName` query parameter is always appended — including when empty —
11
- * to match the legacy request shape that the server returns 200 for. The
12
- * versioned `/0/omni/process/id` route 500s when the parameter is omitted.
13
- */
14
- async function processId(input = {}, signal) {
15
- const endpoint = input.isSecondId ? endpoints.processSecondId : endpoints.processId;
16
- const queueName = input.queueName ?? "";
17
- const url = `${endpoint}?queueName=${encodeURIComponent(queueName)}`;
18
- const res = await api.post(url, {}, { signal });
19
- if (!res.ok) throw new Error(`POST ${endpoint} failed: ${res.status} ${res.statusText}`);
20
- return { isDocumentExpired: res.data?.isDocumentExpired ?? false };
21
- }
22
-
23
- //#endregion
24
- //#region src/modules/id-verification/idVerificationStateMachine.ts
25
- function deriveIsSecondId(config) {
26
- if (config.isSecondId === true) return true;
27
- if (config.idRank === "SECOND_ID") return true;
28
- return false;
29
- }
30
- const idVerificationMachine = setup({
31
- types: {
32
- context: {},
33
- events: {},
34
- input: {}
35
- },
36
- actors: { processId: fromPromise(async ({ input, signal }) => {
37
- return processId({
38
- isSecondId: input.isSecondId,
39
- queueName: input.queueName
40
- }, signal);
41
- }) },
42
- guards: { isDocumentExpired: ({ event }) => event.output?.isDocumentExpired === true }
43
- }).createMachine({
44
- id: "idVerification",
45
- initial: "idle",
46
- context: ({ input }) => ({
47
- config: input.config,
48
- isSecondId: deriveIsSecondId(input.config)
49
- }),
50
- states: {
51
- idle: { on: { LOAD: "processing" } },
52
- processing: { invoke: {
53
- id: "processId",
54
- src: "processId",
55
- input: ({ context }) => ({
56
- isSecondId: context.isSecondId,
57
- queueName: context.config.queueName ?? ""
58
- }),
59
- onDone: [{
60
- target: "expired",
61
- guard: "isDocumentExpired"
62
- }, { target: "finished" }],
63
- onError: { target: "finished" }
64
- } },
65
- expired: { on: { CONTINUE: "finished" } },
66
- finished: { type: "final" }
67
- }
68
- });
69
-
70
- //#endregion
71
- export { idVerificationMachine as t };