@incodetech/core 2.0.0-alpha.8 → 2.0.0-rc.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.
- package/dist/Actor-CI32dTbG.d.ts +2 -0
- package/dist/BaseWasmProvider-C_DLEI40.esm.js +1118 -0
- package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +55 -0
- package/dist/BrowserTimerProvider-DhNc_x02.esm.js +22 -0
- package/dist/ITimerCapability-C67ZRskg.esm.js +7 -0
- package/dist/IpifyProvider-D7jx52AL.esm.js +139 -0
- package/dist/MotionSensorProvider-4v7xkqAp.esm.js +254 -0
- package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +87 -0
- package/dist/StateMachine-BCQrZJhf.d.ts +2 -0
- package/dist/WasmUtilProvider-j98OJf-S.esm.js +114 -0
- package/dist/addressSearch-BpTbTWCa.esm.js +430 -0
- package/dist/ae-signature-DDDZmWXj.esm.js +12 -0
- package/dist/ae-signature.d.ts +25 -0
- package/dist/ae-signature.esm.js +8 -0
- package/dist/antifraud.d.ts +57 -0
- package/dist/antifraud.esm.js +45 -0
- package/dist/antifraudStateMachine-O0TMf6yc.esm.js +39 -0
- package/dist/api-CESGtpbH.esm.js +53 -0
- package/dist/authentication.d.ts +12 -0
- package/dist/authentication.esm.js +25 -0
- package/dist/authenticationManager-5M-fKzXx.esm.js +67 -0
- package/dist/authenticationManager-C83GNIhl.d.ts +66 -0
- package/dist/authenticationStateMachine-BMZqatiF.esm.js +139 -0
- package/dist/backCameraStream-DMdMeGk2.esm.js +346 -0
- package/dist/browserSimulation-gxD8cSpM.esm.js +20 -0
- package/dist/camera-DBSxa6ML.d.ts +4 -0
- package/dist/camera-PA2Ljri3.esm.js +22 -0
- package/dist/camera.d.ts +15 -0
- package/dist/camera.esm.js +5 -0
- package/dist/consent.d.ts +398 -0
- package/dist/consent.esm.js +79 -0
- package/dist/consentStateMachine-CCT-B60O.esm.js +151 -0
- package/dist/cpf-PPz2Njto.esm.js +38 -0
- package/dist/cpf-ocr.d.ts +204 -0
- package/dist/cpf-ocr.esm.js +177 -0
- package/dist/cross-document-data-match.d.ts +34 -0
- package/dist/cross-document-data-match.esm.js +71 -0
- package/dist/curp-validation.d.ts +188 -0
- package/dist/curp-validation.esm.js +110 -0
- package/dist/curpValidationStateMachine-CitWLr2c.esm.js +595 -0
- package/dist/custom-fields.d.ts +115 -0
- package/dist/custom-fields.esm.js +177 -0
- package/dist/custom-watchlist.d.ts +66 -0
- package/dist/custom-watchlist.esm.js +86 -0
- package/dist/dateUtils-UoN5xswP.esm.js +23 -0
- package/dist/deepsightLoader-Cm4JIT_z.esm.js +52 -0
- package/dist/deepsightService-CEVxzehb.d.ts +412 -0
- package/dist/deepsightService-O74l4Y__.esm.js +489 -0
- package/dist/device.d.ts +46 -0
- package/dist/device.esm.js +106 -0
- package/dist/displayErrors-DqJ_IbsG.d.ts +39 -0
- package/dist/document-capture.d.ts +906 -0
- package/dist/document-capture.esm.js +156 -0
- package/dist/document-upload.d.ts +331 -0
- package/dist/document-upload.esm.js +203 -0
- package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +394 -0
- package/dist/dynamic-forms.d.ts +178 -0
- package/dist/dynamic-forms.esm.js +323 -0
- package/dist/ekyb.d.ts +148 -0
- package/dist/ekyb.esm.js +127 -0
- package/dist/ekybStateMachine-B59rQjgj.esm.js +674 -0
- package/dist/ekyc.d.ts +164 -0
- package/dist/ekyc.esm.js +104 -0
- package/dist/ekycStateMachine-oeO0Iekd.esm.js +10626 -0
- package/dist/electronic-signature.d.ts +4 -0
- package/dist/electronic-signature.esm.js +7 -0
- package/dist/electronicSignatureManager-D9OHzTpG.esm.js +428 -0
- package/dist/email.d.ts +3 -263
- package/dist/email.esm.js +7 -477
- package/dist/emailManager-DIfnS5g1.d.ts +352 -0
- package/dist/emailManager-wAV0LE-H.esm.js +238 -0
- package/dist/emailStateMachine-DOf4j58N.esm.js +292 -0
- package/dist/endpoints-CnN3SyDa.esm.js +87 -0
- package/dist/events-D6-e4vok.esm.js +596 -0
- package/dist/events.d.ts +265 -0
- package/dist/events.esm.js +4 -0
- package/dist/extensibility.d.ts +122 -0
- package/dist/extensibility.esm.js +43 -0
- package/dist/face-match.d.ts +228 -0
- package/dist/face-match.esm.js +173 -0
- package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +290 -0
- package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +690 -0
- package/dist/faceCaptureSetup-B3faSpYA.esm.js +873 -0
- package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +127 -0
- package/dist/flow-events.d.ts +6 -0
- package/dist/flow-events.esm.js +0 -0
- package/dist/flow.d.ts +101 -321
- package/dist/flow.esm.js +370 -173
- package/dist/flowCompletionService-DhkT4SRY.d.ts +10 -0
- package/dist/flowCompletionService-P54yzGvA.esm.js +13 -0
- package/dist/flowServices-DTsm-Vf1.esm.js +188 -0
- package/dist/geolocation.d.ts +127 -0
- package/dist/geolocation.esm.js +89 -0
- package/dist/geolocationStateMachine-asasuHY2.esm.js +105 -0
- package/dist/getBrowser-BSXUTWXw.esm.js +41 -0
- package/dist/getDeviceClass-BSntT9_j.esm.js +14 -0
- package/dist/government-validation.d.ts +67 -0
- package/dist/government-validation.esm.js +81 -0
- package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +271 -0
- package/dist/home.d.ts +99 -0
- package/dist/home.esm.js +61 -0
- package/dist/http.d.ts +68 -0
- package/dist/http.esm.js +3 -0
- package/dist/id-ocr.d.ts +635 -0
- package/dist/id-ocr.esm.js +86 -0
- package/dist/id-verification.d.ts +190 -0
- package/dist/id-verification.esm.js +43 -0
- package/dist/id.d.ts +24 -0
- package/dist/id.esm.js +164 -0
- package/dist/idCaptureManager-B9TGA5dq.d.ts +956 -0
- package/dist/idCaptureManager-DMK0GIt3.esm.js +581 -0
- package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +2954 -0
- package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +388 -0
- package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +71 -0
- package/dist/identity-reuse.d.ts +530 -0
- package/dist/identity-reuse.esm.js +274 -0
- package/dist/index-BLKtMA0g.d.ts +1177 -0
- package/dist/index-BcRG8rtJ.d.ts +97 -0
- package/dist/index.d.ts +3 -226
- package/dist/index.esm.js +11 -154
- package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +30 -0
- package/dist/{lib-Bu9XGMBW.esm.js → lib-BB0B_qQX.esm.js} +801 -2
- package/dist/mandatory-consent.d.ts +412 -0
- package/dist/mandatory-consent.esm.js +78 -0
- package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +126 -0
- package/dist/openviduLazy-Cm0XFh_v.esm.js +3 -0
- package/dist/openviduLazy-Cok70ZSg.esm.js +12 -0
- package/dist/permissionServices-D_i6nzEw.esm.js +50 -0
- package/dist/phone.d.ts +3 -291
- package/dist/phone.esm.js +7 -548
- package/dist/phoneManager-B6M30hKE.d.ts +397 -0
- package/dist/phoneManager-DAJbGhlY.esm.js +256 -0
- package/dist/phoneStateMachine-CuPARRaT.esm.js +351 -0
- package/dist/platform-CfrjKhmi.esm.js +83 -0
- package/dist/qe-signature-DFo_Cc-I.esm.js +12 -0
- package/dist/qe-signature.d.ts +25 -0
- package/dist/qe-signature.esm.js +8 -0
- package/dist/recordingService-Ig2UgbLv.esm.js +1003 -0
- package/dist/redirect-to-mobile.d.ts +107 -0
- package/dist/redirect-to-mobile.esm.js +102 -0
- package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +249 -0
- package/dist/runChildModule-CqqwqAkW.esm.js +219 -0
- package/dist/selfie.d.ts +21 -754
- package/dist/selfie.esm.js +113 -962
- package/dist/selfieManager-D0lSgd-J.d.ts +68 -0
- package/dist/selfieManager-Duisl7qN.esm.js +60 -0
- package/dist/selfieStateMachine-D76whWEf.esm.js +68 -0
- package/dist/session-BS-d_vuE.esm.js +3206 -0
- package/dist/session.d.ts +217 -0
- package/dist/session.esm.js +9 -0
- package/dist/setup-Buy-hyj4.esm.js +887 -0
- package/dist/setup-C5AITV8m.d.ts +254 -0
- package/dist/signature.d.ts +94 -0
- package/dist/signature.esm.js +66 -0
- package/dist/signatureStateMachine-B5-QVUve.esm.js +132 -0
- package/dist/stats-CIfiPzb1.esm.js +16 -0
- package/dist/stats.d.ts +16 -0
- package/dist/stats.esm.js +4 -0
- package/dist/trust-graph.d.ts +54 -0
- package/dist/trust-graph.esm.js +56 -0
- package/dist/types-B06Ypu2F.d.ts +49 -0
- package/dist/types-BP1m8VRw.d.ts +340 -0
- package/dist/types-CFV9G_7j.d.ts +24 -0
- package/dist/{warmup-CEJTfxQr.d.ts → warmup-CEcppFiS.d.ts} +11 -3
- package/dist/wasm.d.ts +15 -0
- package/dist/wasm.esm.js +12 -0
- package/dist/watchlist-for-business.d.ts +79 -0
- package/dist/watchlist-for-business.esm.js +148 -0
- package/dist/watchlist.d.ts +62 -0
- package/dist/watchlist.esm.js +86 -0
- package/dist/watchlistServices-DMbUhkBX.esm.js +12 -0
- package/dist/workflow.d.ts +907 -0
- package/dist/workflow.esm.js +702 -0
- package/dist/{xstate.esm-B_rda9yU.esm.js → xstate.esm-B70JrNqo.esm.js} +144 -1
- package/package.json +203 -6
- package/dist/OpenViduLogger-BdPfiZO6.esm.js +0 -3
- package/dist/OpenViduLogger-CQyDxBvM.esm.js +0 -803
- package/dist/StateMachine-DRE1oH2B.d.ts +0 -2
- package/dist/addEvent-W0ORK0jT.esm.js +0 -16
- package/dist/endpoints-BSTFaHYo.esm.js +0 -1706
- package/dist/permissionServices-I6vX6DBy.esm.js +0 -72
- /package/dist/{Manager-BGfxEmyv.d.ts → Manager-C8PrhBOx.d.ts} +0 -0
- /package/dist/{chunk-C_Yo44FK.esm.js → chunk-CRF6K_H_.esm.js} +0 -0
- /package/dist/{types-iZi2rawo.d.ts → types-CAD4va6a.d.ts} +0 -0
|
@@ -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 };
|