@incodetech/core 2.0.0 → 2.0.1-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/Manager-C8PrhBOx.d.ts +19 -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/chunk-CRF6K_H_.esm.js +49 -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-BR2let5f.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 +4 -0
- package/dist/email.esm.js +9 -0
- 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 +358 -0
- package/dist/flow.esm.js +825 -0
- package/dist/flowCompletionService-DhkT4SRY.d.ts +10 -0
- package/dist/flowCompletionService-P54yzGvA.esm.js +13 -0
- package/dist/flowServices-DG3IdWw6.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-Fyd0eam-.d.ts +958 -0
- package/dist/idCaptureManager-ZPkD7Gjk.esm.js +581 -0
- package/dist/idCaptureStateMachine-BK0bPHoc.esm.js +2963 -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-BcRG8rtJ.d.ts +97 -0
- package/dist/index-DZoqeAo9.d.ts +1177 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +12 -0
- package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +30 -0
- package/dist/lib-BB0B_qQX.esm.js +12499 -0
- 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 +4 -0
- package/dist/phone.esm.js +9 -0
- 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 +26 -0
- package/dist/selfie.esm.js +146 -0
- 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-CGtQJJzB.esm.js +3206 -0
- package/dist/session.d.ts +217 -0
- package/dist/session.esm.js +9 -0
- package/dist/setup-C5AITV8m.d.ts +254 -0
- package/dist/setup-DsM8IG7k.esm.js +887 -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-CAD4va6a.d.ts +5 -0
- package/dist/types-CFV9G_7j.d.ts +24 -0
- package/dist/warmup-CEcppFiS.d.ts +63 -0
- 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-B70JrNqo.esm.js +3404 -0
- package/package.json +1 -1
|
@@ -0,0 +1,394 @@
|
|
|
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, r as assign, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
|
|
4
|
+
import { i as stopCameraStream } from "./camera-PA2Ljri3.esm.js";
|
|
5
|
+
import { t as getBackCameraStream } from "./backCameraStream-DMdMeGk2.esm.js";
|
|
6
|
+
|
|
7
|
+
//#region src/modules/document-capture/types.ts
|
|
8
|
+
const PROCESSING_TYPE_MAP = {
|
|
9
|
+
processV5CLogbook: "v5cMultiPageLogbook",
|
|
10
|
+
processCirculationCard: "circulationCard",
|
|
11
|
+
processFinanceSettlement: "financeSettlement",
|
|
12
|
+
processCarInvoice: "carInvoice",
|
|
13
|
+
asyncProcessCarInvoice: "carInvoice",
|
|
14
|
+
asyncProcessCirculationCard: "circulationCard",
|
|
15
|
+
capture: "addressStatement"
|
|
16
|
+
};
|
|
17
|
+
const MULTI_PAGE_TYPES = [
|
|
18
|
+
"v5cMultiPageLogbook",
|
|
19
|
+
"circulationCard",
|
|
20
|
+
"financeSettlement"
|
|
21
|
+
];
|
|
22
|
+
const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
23
|
+
const DEFAULT_CAPTURE_ATTEMPTS = 3;
|
|
24
|
+
const OTHER_DOCUMENT_TYPES = new Set([
|
|
25
|
+
"otherDocument1",
|
|
26
|
+
"otherDocument2",
|
|
27
|
+
"otherDocument3"
|
|
28
|
+
]);
|
|
29
|
+
const DOCUMENT_CAPTURE_ERROR_CODES = {
|
|
30
|
+
FILE_TOO_LARGE: "FILE_TOO_LARGE",
|
|
31
|
+
UPLOAD_FAILED: "UPLOAD_FAILED"
|
|
32
|
+
};
|
|
33
|
+
const DOCUMENT_CAPTURE_FINALIZE_ERROR_CODES = { UNEXPECTED_ERROR: "UNEXPECTED_ERROR" };
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/modules/document-capture/documentCaptureUploadService.ts
|
|
37
|
+
function isMultiPageDocumentType(processingType) {
|
|
38
|
+
return MULTI_PAGE_TYPES.includes(processingType);
|
|
39
|
+
}
|
|
40
|
+
function normalizeProcessingType(processingType) {
|
|
41
|
+
return PROCESSING_TYPE_MAP[processingType] ?? processingType;
|
|
42
|
+
}
|
|
43
|
+
function buildUrl(baseUrl, type, format) {
|
|
44
|
+
return `${baseUrl}?type=${encodeURIComponent(type)}&format=${format}`;
|
|
45
|
+
}
|
|
46
|
+
function resolveUploadUrl(processingType, fileFormat) {
|
|
47
|
+
const format = fileFormat === "application/pdf" ? "pdf" : "image";
|
|
48
|
+
const resolvedType = normalizeProcessingType(processingType);
|
|
49
|
+
if (isMultiPageDocumentType(resolvedType)) return buildUrl(endpoints.documentV3, resolvedType, format);
|
|
50
|
+
if (resolvedType === "carInvoice") return buildUrl(endpoints.cfdi, resolvedType, format);
|
|
51
|
+
if (OTHER_DOCUMENT_TYPES.has(resolvedType)) return buildUrl(endpoints.addDocument, resolvedType, format);
|
|
52
|
+
if (resolvedType === "addressStatement" || !resolvedType) return buildUrl(endpoints.addressStatement, resolvedType || "addressStatement", format);
|
|
53
|
+
return buildUrl(endpoints.addressStatement, processingType, format);
|
|
54
|
+
}
|
|
55
|
+
async function uploadDocumentCapture({ base64Image, processingType, fileFormat, onProgress, signal }) {
|
|
56
|
+
const url = resolveUploadUrl(processingType, fileFormat);
|
|
57
|
+
const rawBase64 = base64Image.includes(",") ? base64Image.split(",")[1] : base64Image;
|
|
58
|
+
const response = await api.post(url, { base64Image: rawBase64 }, {
|
|
59
|
+
signal,
|
|
60
|
+
onUploadProgress: onProgress
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) throw new Error(`Document upload failed: ${response.status}`);
|
|
63
|
+
if (!(response.data.success || response.data.status === "SUCCESS" || response.data.status === "ADD_NEXT_PAGE" || response.data.status === "OPTIONAL_PAGE_CAPTURE")) throw new Error("Document upload rejected by server");
|
|
64
|
+
return response.data;
|
|
65
|
+
}
|
|
66
|
+
function resolveMultiPageDocumentType(processingType) {
|
|
67
|
+
const resolvedType = normalizeProcessingType(processingType);
|
|
68
|
+
return isMultiPageDocumentType(resolvedType) ? resolvedType : null;
|
|
69
|
+
}
|
|
70
|
+
async function finalizeDocument({ processingType, signal }) {
|
|
71
|
+
const type = resolveMultiPageDocumentType(processingType);
|
|
72
|
+
if (!type) throw new Error(`finalizeDocument only supports multi-page types (${MULTI_PAGE_TYPES.join(", ")})`);
|
|
73
|
+
const response = await api.post(endpoints.finalizeDocument, { type }, { signal });
|
|
74
|
+
if (!response.ok) throw new Error(`Document finalize failed: ${response.status}`);
|
|
75
|
+
const data = response.data;
|
|
76
|
+
if (!data) throw new Error("Document finalize rejected by server");
|
|
77
|
+
if (!(data.success || data.status === "SUCCESS")) {
|
|
78
|
+
const serverStatus = typeof data.status === "string" ? data.status : "unknown";
|
|
79
|
+
throw new Error(`Document finalize rejected by server (status: ${serverStatus})`);
|
|
80
|
+
}
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/modules/document-capture/documentCaptureStateMachine.ts
|
|
86
|
+
const documentCaptureMachine = setup({
|
|
87
|
+
types: {
|
|
88
|
+
context: {},
|
|
89
|
+
events: {},
|
|
90
|
+
input: {}
|
|
91
|
+
},
|
|
92
|
+
actors: {
|
|
93
|
+
initCamera: fromPromise(async () => {
|
|
94
|
+
const { stream } = await getBackCameraStream(void 0);
|
|
95
|
+
return stream;
|
|
96
|
+
}),
|
|
97
|
+
uploadDocument: fromPromise(async ({ input, signal }) => {
|
|
98
|
+
return uploadDocumentCapture({
|
|
99
|
+
base64Image: input.capturedDocument.imageBase64,
|
|
100
|
+
processingType: input.processingType,
|
|
101
|
+
fileFormat: input.capturedDocument.fileType,
|
|
102
|
+
onProgress: input.onProgress,
|
|
103
|
+
signal
|
|
104
|
+
});
|
|
105
|
+
}),
|
|
106
|
+
finalizeDocumentRequest: fromPromise(async ({ input, signal }) => {
|
|
107
|
+
return finalizeDocument({
|
|
108
|
+
processingType: input.processingType,
|
|
109
|
+
signal
|
|
110
|
+
});
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
actions: {
|
|
114
|
+
setStream: assign(({ event }) => ({ stream: event.output })),
|
|
115
|
+
setCapturedDocument: assign(({ event }) => {
|
|
116
|
+
const e = event;
|
|
117
|
+
return {
|
|
118
|
+
capturedDocument: {
|
|
119
|
+
imageBase64: e.imageBase64,
|
|
120
|
+
file: e.file,
|
|
121
|
+
fileType: e.fileType
|
|
122
|
+
},
|
|
123
|
+
error: void 0
|
|
124
|
+
};
|
|
125
|
+
}),
|
|
126
|
+
setFileTooLargeError: assign({ error: () => DOCUMENT_CAPTURE_ERROR_CODES.FILE_TOO_LARGE }),
|
|
127
|
+
setProgress: assign(({ event }) => ({ progress: event.progress })),
|
|
128
|
+
setUploadError: assign({ error: () => DOCUMENT_CAPTURE_ERROR_CODES.UPLOAD_FAILED }),
|
|
129
|
+
setFinalizeError: assign({ error: () => DOCUMENT_CAPTURE_FINALIZE_ERROR_CODES.UNEXPECTED_ERROR }),
|
|
130
|
+
decrementAttemptsRemaining: assign(({ context }) => ({ attemptsRemaining: context.attemptsRemaining - 1 })),
|
|
131
|
+
setCaptureMethodFile: assign({ captureMethod: () => "file" }),
|
|
132
|
+
setCaptureMethodCamera: assign({ captureMethod: () => "camera" }),
|
|
133
|
+
setCaptureMethodGallery: assign({ captureMethod: () => "gallery" }),
|
|
134
|
+
clearCapturedDocument: assign({
|
|
135
|
+
capturedDocument: () => void 0,
|
|
136
|
+
captureMethod: () => void 0,
|
|
137
|
+
progress: () => 0,
|
|
138
|
+
error: () => void 0
|
|
139
|
+
}),
|
|
140
|
+
resetPageNumber: assign({ pageNumber: () => 1 }),
|
|
141
|
+
clearCapturedDocumentGalleryRetake: assign({
|
|
142
|
+
capturedDocument: () => void 0,
|
|
143
|
+
progress: () => 0,
|
|
144
|
+
error: () => void 0
|
|
145
|
+
}),
|
|
146
|
+
setNextPageType: assign(({ context, event }) => {
|
|
147
|
+
const { status } = event.output;
|
|
148
|
+
if (context.captureMethod === "file" && context.capturedDocument?.fileType === "application/pdf") return { nextPageType: "none" };
|
|
149
|
+
return { nextPageType: status === "ADD_NEXT_PAGE" ? "required" : status === "OPTIONAL_PAGE_CAPTURE" ? "optional" : "none" };
|
|
150
|
+
}),
|
|
151
|
+
clearForNextPage: assign(({ context }) => ({
|
|
152
|
+
capturedDocument: void 0,
|
|
153
|
+
progress: 0,
|
|
154
|
+
error: void 0,
|
|
155
|
+
pageNumber: context.pageNumber + 1,
|
|
156
|
+
nextPageType: "none",
|
|
157
|
+
captureMethod: void 0
|
|
158
|
+
})),
|
|
159
|
+
clearError: assign({ error: () => void 0 }),
|
|
160
|
+
resetProgress: assign({ progress: () => 0 }),
|
|
161
|
+
stopStream: assign(({ context }) => {
|
|
162
|
+
if (context.stream) stopCameraStream(context.stream);
|
|
163
|
+
return { stream: void 0 };
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
guards: {
|
|
167
|
+
allowSkip: ({ context }) => context.config.allowSkipDocumentCapture && context.pageNumber === 1,
|
|
168
|
+
fileSizeOk: ({ context, event }) => {
|
|
169
|
+
return event.file.size <= context.config.maxFileSize;
|
|
170
|
+
},
|
|
171
|
+
canRetry: ({ context }) => context.attemptsRemaining > 0,
|
|
172
|
+
attemptsExhausted: ({ context }) => context.attemptsRemaining <= 0,
|
|
173
|
+
isCameraMode: ({ context }) => context.config.captureMode === "camera",
|
|
174
|
+
isCaptureMethodCamera: ({ context }) => context.captureMethod === "camera",
|
|
175
|
+
isCaptureMethodGallery: ({ context }) => context.captureMethod === "gallery",
|
|
176
|
+
isCaptureMethodFile: ({ context }) => context.captureMethod === "file",
|
|
177
|
+
isNextPageOptional: ({ context }) => context.nextPageType === "optional",
|
|
178
|
+
isNextPageRequired: ({ context }) => context.nextPageType === "required",
|
|
179
|
+
canFinalizeOptionalPages: ({ context }) => context.nextPageType === "optional" && resolveMultiPageDocumentType(context.config.processingType) !== null,
|
|
180
|
+
fileSizeOkForGallery: ({ context, event }) => {
|
|
181
|
+
return event.file.size <= context.config.maxFileSize && context.captureMethod === "gallery";
|
|
182
|
+
},
|
|
183
|
+
fileSizeOkForNonGallery: ({ context, event }) => {
|
|
184
|
+
return event.file.size <= context.config.maxFileSize && context.captureMethod !== "gallery";
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}).createMachine({
|
|
188
|
+
id: "documentCapture",
|
|
189
|
+
initial: "tutorial",
|
|
190
|
+
context: ({ input }) => {
|
|
191
|
+
const { processingType = "addressStatement", captureMode = "camera", allowSkipDocumentCapture, disableSkipPoa, captureAttempts = DEFAULT_CAPTURE_ATTEMPTS, sendBase64 = false, maxFileSize = DEFAULT_MAX_FILE_SIZE, title, text, step2Title, step2Text } = input.config;
|
|
192
|
+
return {
|
|
193
|
+
config: {
|
|
194
|
+
processingType,
|
|
195
|
+
captureMode,
|
|
196
|
+
allowSkipDocumentCapture: allowSkipDocumentCapture ?? (disableSkipPoa != null ? !disableSkipPoa : false),
|
|
197
|
+
captureAttempts,
|
|
198
|
+
sendBase64,
|
|
199
|
+
maxFileSize,
|
|
200
|
+
title,
|
|
201
|
+
text,
|
|
202
|
+
step2Title,
|
|
203
|
+
step2Text
|
|
204
|
+
},
|
|
205
|
+
stream: void 0,
|
|
206
|
+
capturedDocument: void 0,
|
|
207
|
+
captureMethod: void 0,
|
|
208
|
+
progress: 0,
|
|
209
|
+
error: void 0,
|
|
210
|
+
attemptsRemaining: captureAttempts,
|
|
211
|
+
pageNumber: 1,
|
|
212
|
+
nextPageType: "none"
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
states: {
|
|
216
|
+
tutorial: { on: {
|
|
217
|
+
CAPTURE: [{
|
|
218
|
+
target: "initCamera",
|
|
219
|
+
guard: "isCameraMode"
|
|
220
|
+
}, { target: "capturing" }],
|
|
221
|
+
FILE_SELECTED: [{
|
|
222
|
+
target: "preview",
|
|
223
|
+
guard: "fileSizeOk",
|
|
224
|
+
actions: ["setCapturedDocument", "setCaptureMethodFile"]
|
|
225
|
+
}, {
|
|
226
|
+
target: "tutorial",
|
|
227
|
+
actions: "setFileTooLargeError"
|
|
228
|
+
}],
|
|
229
|
+
SKIP: {
|
|
230
|
+
target: "finished",
|
|
231
|
+
guard: "allowSkip"
|
|
232
|
+
},
|
|
233
|
+
CLOSE: { target: "closed" }
|
|
234
|
+
} },
|
|
235
|
+
initCamera: {
|
|
236
|
+
invoke: {
|
|
237
|
+
id: "initCamera",
|
|
238
|
+
src: "initCamera",
|
|
239
|
+
input: void 0,
|
|
240
|
+
onDone: {
|
|
241
|
+
target: "capturing",
|
|
242
|
+
actions: "setStream"
|
|
243
|
+
},
|
|
244
|
+
onError: {
|
|
245
|
+
target: "failure",
|
|
246
|
+
actions: "setUploadError"
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
on: { CLOSE: { target: "closed" } }
|
|
250
|
+
},
|
|
251
|
+
capturing: { on: {
|
|
252
|
+
FILE_SELECTED: [
|
|
253
|
+
{
|
|
254
|
+
target: "preview",
|
|
255
|
+
guard: "fileSizeOkForGallery",
|
|
256
|
+
actions: "setCapturedDocument"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
target: "preview",
|
|
260
|
+
guard: "fileSizeOkForNonGallery",
|
|
261
|
+
actions: ["setCapturedDocument", "setCaptureMethodCamera"]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
target: "capturing",
|
|
265
|
+
actions: "setFileTooLargeError"
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
CLOSE: {
|
|
269
|
+
target: "closed",
|
|
270
|
+
actions: "stopStream"
|
|
271
|
+
}
|
|
272
|
+
} },
|
|
273
|
+
preview: { on: {
|
|
274
|
+
ACCEPT: {
|
|
275
|
+
target: "uploading",
|
|
276
|
+
actions: "resetProgress"
|
|
277
|
+
},
|
|
278
|
+
RETAKE: [
|
|
279
|
+
{
|
|
280
|
+
target: "tutorial",
|
|
281
|
+
guard: "isCaptureMethodFile",
|
|
282
|
+
actions: "clearCapturedDocument"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
target: "capturing",
|
|
286
|
+
guard: "isCaptureMethodGallery",
|
|
287
|
+
actions: "clearCapturedDocumentGalleryRetake"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
target: "capturing",
|
|
291
|
+
actions: "clearCapturedDocument"
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
CLOSE: {
|
|
295
|
+
target: "closed",
|
|
296
|
+
actions: "stopStream"
|
|
297
|
+
}
|
|
298
|
+
} },
|
|
299
|
+
uploading: {
|
|
300
|
+
invoke: {
|
|
301
|
+
id: "uploadDocument",
|
|
302
|
+
src: "uploadDocument",
|
|
303
|
+
input: ({ context, self }) => {
|
|
304
|
+
if (!context.capturedDocument) throw new Error("No captured document to upload");
|
|
305
|
+
return {
|
|
306
|
+
capturedDocument: context.capturedDocument,
|
|
307
|
+
processingType: context.config.processingType,
|
|
308
|
+
onProgress: (progress) => {
|
|
309
|
+
self.send({
|
|
310
|
+
type: "UPLOAD_PROGRESS",
|
|
311
|
+
progress
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
},
|
|
316
|
+
onDone: {
|
|
317
|
+
target: "success",
|
|
318
|
+
actions: ["setNextPageType", "stopStream"]
|
|
319
|
+
},
|
|
320
|
+
onError: {
|
|
321
|
+
target: "failure",
|
|
322
|
+
actions: [
|
|
323
|
+
"setUploadError",
|
|
324
|
+
"decrementAttemptsRemaining",
|
|
325
|
+
"stopStream"
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
on: { UPLOAD_PROGRESS: { actions: "setProgress" } }
|
|
330
|
+
},
|
|
331
|
+
success: { on: {
|
|
332
|
+
CONTINUE: [
|
|
333
|
+
{
|
|
334
|
+
target: "nextPage",
|
|
335
|
+
guard: "isNextPageOptional"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
target: "nextPage",
|
|
339
|
+
guard: "isNextPageRequired"
|
|
340
|
+
},
|
|
341
|
+
{ target: "finished" }
|
|
342
|
+
],
|
|
343
|
+
CLOSE: { target: "closed" }
|
|
344
|
+
} },
|
|
345
|
+
nextPage: { on: {
|
|
346
|
+
NEXT_PAGE_CAMERA: {
|
|
347
|
+
target: "initCamera",
|
|
348
|
+
actions: ["clearForNextPage", "setCaptureMethodCamera"]
|
|
349
|
+
},
|
|
350
|
+
NEXT_PAGE_PHOTO_LIBRARY: {
|
|
351
|
+
target: "capturing",
|
|
352
|
+
actions: ["clearForNextPage", "setCaptureMethodGallery"]
|
|
353
|
+
},
|
|
354
|
+
ALL_PAGES_CAPTURED: [{
|
|
355
|
+
target: "finalizing",
|
|
356
|
+
guard: "canFinalizeOptionalPages"
|
|
357
|
+
}, { target: "finished" }],
|
|
358
|
+
CLOSE: { target: "closed" }
|
|
359
|
+
} },
|
|
360
|
+
finalizing: { invoke: {
|
|
361
|
+
id: "finalizeDocument",
|
|
362
|
+
src: "finalizeDocumentRequest",
|
|
363
|
+
input: ({ context }) => ({ processingType: context.config.processingType }),
|
|
364
|
+
onDone: { target: "finished" },
|
|
365
|
+
onError: {
|
|
366
|
+
target: "failure",
|
|
367
|
+
actions: ["setFinalizeError", "decrementAttemptsRemaining"]
|
|
368
|
+
}
|
|
369
|
+
} },
|
|
370
|
+
failure: {
|
|
371
|
+
on: {
|
|
372
|
+
RETRY: {
|
|
373
|
+
target: "tutorial",
|
|
374
|
+
guard: "canRetry",
|
|
375
|
+
actions: [
|
|
376
|
+
"clearError",
|
|
377
|
+
"clearCapturedDocument",
|
|
378
|
+
"resetPageNumber"
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
CLOSE: { target: "closed" }
|
|
382
|
+
},
|
|
383
|
+
after: { 3e3: {
|
|
384
|
+
target: "finished",
|
|
385
|
+
guard: "attemptsExhausted"
|
|
386
|
+
} }
|
|
387
|
+
},
|
|
388
|
+
finished: { type: "final" },
|
|
389
|
+
closed: { type: "final" }
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
//#endregion
|
|
394
|
+
export { DOCUMENT_CAPTURE_ERROR_CODES as n, documentCaptureMachine as t };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { t as Manager } from "./Manager-C8PrhBOx.js";
|
|
2
|
+
import "./Actor-CI32dTbG.js";
|
|
3
|
+
|
|
4
|
+
//#region src/modules/dynamic-forms/types.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Input types supported by dynamic form questions.
|
|
8
|
+
* `inputType` on `Question` is optional so unknown future API values degrade
|
|
9
|
+
* gracefully to the text fallback rather than requiring this union to be widened.
|
|
10
|
+
*/
|
|
11
|
+
type InputType = 'TEXT' | 'DATE' | 'COUNTRY' | 'NATIONALITY' | 'NUMBER' | 'EMAIL' | 'PHONE' | 'CPF' | 'NAME' | 'YESNO' | 'SELECT' | 'MULTISELECT';
|
|
12
|
+
/**
|
|
13
|
+
* A single question within a dynamic form screen.
|
|
14
|
+
*/
|
|
15
|
+
type Question = {
|
|
16
|
+
questionId: string;
|
|
17
|
+
/** Display label shown to the user */
|
|
18
|
+
question: string;
|
|
19
|
+
inputType?: InputType;
|
|
20
|
+
/** Fallback type used when `inputType` is absent */
|
|
21
|
+
overrides?: InputType;
|
|
22
|
+
isPredefined?: boolean;
|
|
23
|
+
isOptional?: boolean;
|
|
24
|
+
options?: string[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A single screen within the dynamic form flow.
|
|
28
|
+
*/
|
|
29
|
+
type Screen = {
|
|
30
|
+
title?: string;
|
|
31
|
+
hideTitle?: boolean;
|
|
32
|
+
questions: Question[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for the dynamic forms module.
|
|
36
|
+
* Provide either `screens` (pre-loaded) or `flowId` (fetched from API).
|
|
37
|
+
*/
|
|
38
|
+
type DynamicFormsConfig = {
|
|
39
|
+
/** Flow ID used to fetch screens from the API when `screens` is not provided */
|
|
40
|
+
flowId?: string;
|
|
41
|
+
/** Pre-loaded screens — skips the API fetch when provided */
|
|
42
|
+
screens?: Screen[];
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/modules/dynamic-forms/dynamicFormsStateMachine.d.ts
|
|
46
|
+
/** Whether the form completed normally or was skipped due to a screen-loading failure. */
|
|
47
|
+
type DynamicFormsResult = 'completed' | 'skipped';
|
|
48
|
+
declare const dynamicFormsMachine: any;
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/modules/dynamic-forms/dynamicFormsActor.d.ts
|
|
51
|
+
type CreateDynamicFormsActorOptions = {
|
|
52
|
+
config: DynamicFormsConfig;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/modules/dynamic-forms/dynamicFormsManager.d.ts
|
|
56
|
+
/** Dynamic forms manager is in initial state, waiting for `load()` */
|
|
57
|
+
type DynamicFormsIdleState = {
|
|
58
|
+
status: 'idle';
|
|
59
|
+
};
|
|
60
|
+
/** Fetching screen configuration from the backend */
|
|
61
|
+
type DynamicFormsLoadingState = {
|
|
62
|
+
status: 'loadingScreens';
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Ready for user input on the current screen.
|
|
66
|
+
* @property currentScreen - The screen definition to render
|
|
67
|
+
* @property screenIndex - 0-based index of the current screen
|
|
68
|
+
* @property totalScreens - Total number of screens in the form
|
|
69
|
+
* @property answers - Current answer values keyed by questionId
|
|
70
|
+
* @property answerValidity - Per-question format validity reported via `setAnswerValidity` (phone, email, CPF, etc.)
|
|
71
|
+
* @property canSubmit - True when all required questions have non-empty answers AND no validity flag is false
|
|
72
|
+
*/
|
|
73
|
+
type DynamicFormsInputtingState = {
|
|
74
|
+
status: 'inputting';
|
|
75
|
+
currentScreen: Screen;
|
|
76
|
+
screenIndex: number;
|
|
77
|
+
totalScreens: number;
|
|
78
|
+
answers: Record<string, string>;
|
|
79
|
+
answerValidity: Record<string, boolean>;
|
|
80
|
+
canSubmit: boolean;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Submitting the current screen's answers to the backend.
|
|
84
|
+
* The screen data is preserved so the UI can keep the form visible (with
|
|
85
|
+
* disabled fields and a button spinner) while the request is in-flight.
|
|
86
|
+
* @property screenIndex - Index of the screen being submitted
|
|
87
|
+
* @property totalScreens - Total number of screens in the form
|
|
88
|
+
* @property currentScreen - The screen whose answers are being submitted
|
|
89
|
+
* @property answers - Frozen answer values at submission time
|
|
90
|
+
* @property answerValidity - Frozen validity flags at submission time
|
|
91
|
+
*/
|
|
92
|
+
type DynamicFormsSubmittingState = {
|
|
93
|
+
status: 'submitting';
|
|
94
|
+
screenIndex: number;
|
|
95
|
+
totalScreens: number;
|
|
96
|
+
currentScreen: Screen;
|
|
97
|
+
answers: Record<string, string>;
|
|
98
|
+
answerValidity: Record<string, boolean>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* All screens submitted — success screen visible for ~3 s before
|
|
102
|
+
* transitioning to `finished`.
|
|
103
|
+
*/
|
|
104
|
+
type DynamicFormsSuccessState = {
|
|
105
|
+
status: 'success';
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* All screens completed or skipped.
|
|
109
|
+
* @property result - `'completed'` when all screens were submitted successfully;
|
|
110
|
+
* `'skipped'` when screen configuration could not be loaded (fire-and-forget).
|
|
111
|
+
*/
|
|
112
|
+
type DynamicFormsFinishedState = {
|
|
113
|
+
status: 'finished';
|
|
114
|
+
result: DynamicFormsResult;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Neither `screens` nor `flowId` was provided — misconfiguration, not a runtime error.
|
|
118
|
+
* Call `close()` to dismiss. Fix the config (provide `screens` or `flowId`) instead.
|
|
119
|
+
*/
|
|
120
|
+
type DynamicFormsMisconfiguredState = {
|
|
121
|
+
status: 'misconfigured';
|
|
122
|
+
};
|
|
123
|
+
/** User dismissed the module */
|
|
124
|
+
type DynamicFormsClosedState = {
|
|
125
|
+
status: 'closed';
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Union of all possible dynamic forms manager states.
|
|
129
|
+
*/
|
|
130
|
+
type DynamicFormsState = DynamicFormsIdleState | DynamicFormsLoadingState | DynamicFormsInputtingState | DynamicFormsSubmittingState | DynamicFormsSuccessState | DynamicFormsFinishedState | DynamicFormsMisconfiguredState | DynamicFormsClosedState;
|
|
131
|
+
/**
|
|
132
|
+
* Creates a dynamic forms manager for headless or UI-driven usage.
|
|
133
|
+
*
|
|
134
|
+
* @param options - Configuration options
|
|
135
|
+
* @param options.config - Dynamic forms configuration (flowId or pre-loaded screens)
|
|
136
|
+
*
|
|
137
|
+
* @returns Dynamic forms manager with state, API methods, and subscription
|
|
138
|
+
*/
|
|
139
|
+
declare function createDynamicFormsManager(options: CreateDynamicFormsActorOptions): Manager<DynamicFormsState> & {
|
|
140
|
+
/**
|
|
141
|
+
* Initializes the dynamic forms flow.
|
|
142
|
+
* Transitions from 'idle' to 'loadingScreens' or 'inputting'.
|
|
143
|
+
* Must be called before any other method.
|
|
144
|
+
*/
|
|
145
|
+
load(): void;
|
|
146
|
+
/**
|
|
147
|
+
* Updates the answer value for a single question.
|
|
148
|
+
* Should be called when state is 'inputting'.
|
|
149
|
+
*
|
|
150
|
+
* @param questionId - The question ID from the screen definition
|
|
151
|
+
* @param value - The raw user input value (formatting is stripped in Core before submission)
|
|
152
|
+
*/
|
|
153
|
+
setAnswer(questionId: string, value: string): void;
|
|
154
|
+
/**
|
|
155
|
+
* Reports the format validity of a question's current value.
|
|
156
|
+
* Used for fields with format constraints (PHONE, EMAIL, CPF).
|
|
157
|
+
* Core factors this into `canSubmit` — a false entry blocks submission.
|
|
158
|
+
*
|
|
159
|
+
* @param questionId - The question ID from the screen definition
|
|
160
|
+
* @param isValid - Whether the current value passes format validation
|
|
161
|
+
*/
|
|
162
|
+
setAnswerValidity(questionId: string, isValid: boolean): void;
|
|
163
|
+
/**
|
|
164
|
+
* Submits the current screen's answers.
|
|
165
|
+
* Transitions to 'submitting', then advances to the next screen or 'finished'.
|
|
166
|
+
* Answer submission failures are fire-and-forget and do not block progression.
|
|
167
|
+
*/
|
|
168
|
+
submit(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Dismisses the module from 'misconfigured' state.
|
|
171
|
+
* Fix the config (provide `screens` or `flowId`) rather than calling `reset()`.
|
|
172
|
+
*/
|
|
173
|
+
close(): void;
|
|
174
|
+
};
|
|
175
|
+
/** Type representing a dynamic forms manager instance. */
|
|
176
|
+
type DynamicFormsManager = ReturnType<typeof createDynamicFormsManager>;
|
|
177
|
+
//#endregion
|
|
178
|
+
export { type DynamicFormsConfig, type DynamicFormsManager, type DynamicFormsResult, type DynamicFormsState, type InputType, type Question, type Screen, createDynamicFormsManager, dynamicFormsMachine };
|