@incodetech/core 2.0.0 → 2.0.1

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