@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,38 @@
|
|
|
1
|
+
//#region src/shared/validators/cpf.ts
|
|
2
|
+
const INVALID_CPF_PATTERNS = [
|
|
3
|
+
"00000000000",
|
|
4
|
+
"11111111111",
|
|
5
|
+
"22222222222",
|
|
6
|
+
"33333333333",
|
|
7
|
+
"44444444444",
|
|
8
|
+
"55555555555",
|
|
9
|
+
"66666666666",
|
|
10
|
+
"77777777777",
|
|
11
|
+
"88888888888",
|
|
12
|
+
"99999999999"
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Validates a Brazilian CPF number (11-digit checksum).
|
|
16
|
+
* Accepts formatted (000.000.000-00) or unformatted input.
|
|
17
|
+
*/
|
|
18
|
+
function validateCPF(cpfString) {
|
|
19
|
+
let cpf = cpfString;
|
|
20
|
+
if (cpf.length === 14) cpf = cpf.replace(/\./g, "").replace(/-/g, "");
|
|
21
|
+
if (cpf.length !== 11) return false;
|
|
22
|
+
if (!/^\d+$/.test(cpf)) return false;
|
|
23
|
+
if (INVALID_CPF_PATTERNS.includes(cpf)) return false;
|
|
24
|
+
let sum = 0;
|
|
25
|
+
for (let i = 0; i < 9; i++) sum += Number.parseInt(cpf.charAt(i), 10) * (10 - i);
|
|
26
|
+
let firstDigit = 11 - sum % 11;
|
|
27
|
+
if (firstDigit >= 10) firstDigit = 0;
|
|
28
|
+
if (cpf.charAt(9) !== firstDigit.toString()) return false;
|
|
29
|
+
sum = 0;
|
|
30
|
+
for (let i = 0; i < 10; i++) sum += Number.parseInt(cpf.charAt(i), 10) * (11 - i);
|
|
31
|
+
let secondDigit = 11 - sum % 11;
|
|
32
|
+
if (secondDigit >= 10) secondDigit = 0;
|
|
33
|
+
if (cpf.charAt(10) !== secondDigit.toString()) return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { validateCPF as t };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { t as Manager } from "./Manager-C8PrhBOx.js";
|
|
2
|
+
import * as xstate953 from "xstate";
|
|
3
|
+
|
|
4
|
+
//#region src/modules/cpf-ocr/cpfOcrManager.d.ts
|
|
5
|
+
type CpfOcrIdleState = {
|
|
6
|
+
status: 'idle';
|
|
7
|
+
};
|
|
8
|
+
type CpfOcrLoadingState = {
|
|
9
|
+
status: 'loading';
|
|
10
|
+
};
|
|
11
|
+
type CpfOcrInputtingState = {
|
|
12
|
+
status: 'inputting';
|
|
13
|
+
cpf: string;
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
};
|
|
16
|
+
type CpfOcrSubmittingState = {
|
|
17
|
+
status: 'submitting';
|
|
18
|
+
};
|
|
19
|
+
type CpfOcrErrorState = {
|
|
20
|
+
status: 'error';
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
type CpfOcrFinishedState = {
|
|
24
|
+
status: 'finished';
|
|
25
|
+
};
|
|
26
|
+
type CpfOcrState = CpfOcrIdleState | CpfOcrLoadingState | CpfOcrInputtingState | CpfOcrSubmittingState | CpfOcrErrorState | CpfOcrFinishedState;
|
|
27
|
+
declare function createCpfOcrManager(): Manager<CpfOcrState> & {
|
|
28
|
+
load(): void;
|
|
29
|
+
setCpf(cpf: string): void;
|
|
30
|
+
submit(): void;
|
|
31
|
+
retry(): void;
|
|
32
|
+
};
|
|
33
|
+
type CpfOcrManager = ReturnType<typeof createCpfOcrManager>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/modules/cpf-ocr/types.d.ts
|
|
36
|
+
type CpfOcrDataResponse = {
|
|
37
|
+
documentNumber?: string;
|
|
38
|
+
};
|
|
39
|
+
type CpfOcrUpdateResponse = {
|
|
40
|
+
success?: boolean;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/modules/cpf-ocr/cpfOcrStateMachine.d.ts
|
|
44
|
+
type CpfOcrContext = {
|
|
45
|
+
cpf: string;
|
|
46
|
+
isValid: boolean;
|
|
47
|
+
error: string | undefined;
|
|
48
|
+
};
|
|
49
|
+
type CpfOcrInput = Record<string, never>;
|
|
50
|
+
declare const cpfOcrMachine: xstate953.StateMachine<CpfOcrContext, {
|
|
51
|
+
type: "LOAD";
|
|
52
|
+
} | {
|
|
53
|
+
type: "SET_CPF";
|
|
54
|
+
cpf: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: "SUBMIT";
|
|
57
|
+
} | {
|
|
58
|
+
type: "RETRY";
|
|
59
|
+
}, {
|
|
60
|
+
[x: string]: xstate953.ActorRefFromLogic<xstate953.PromiseActorLogic<CpfOcrDataResponse, void, xstate953.EventObject>> | xstate953.ActorRefFromLogic<xstate953.PromiseActorLogic<CpfOcrUpdateResponse, {
|
|
61
|
+
cpf: string;
|
|
62
|
+
}, xstate953.EventObject>> | undefined;
|
|
63
|
+
}, xstate953.Values<{
|
|
64
|
+
fetchCpfOcrData: {
|
|
65
|
+
src: "fetchCpfOcrData";
|
|
66
|
+
logic: xstate953.PromiseActorLogic<CpfOcrDataResponse, void, xstate953.EventObject>;
|
|
67
|
+
id: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
submitCpfOcr: {
|
|
70
|
+
src: "submitCpfOcr";
|
|
71
|
+
logic: xstate953.PromiseActorLogic<CpfOcrUpdateResponse, {
|
|
72
|
+
cpf: string;
|
|
73
|
+
}, xstate953.EventObject>;
|
|
74
|
+
id: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
}>, xstate953.Values<{
|
|
77
|
+
setError: {
|
|
78
|
+
type: "setError";
|
|
79
|
+
params: xstate953.NonReducibleUnknown;
|
|
80
|
+
};
|
|
81
|
+
clearError: {
|
|
82
|
+
type: "clearError";
|
|
83
|
+
params: xstate953.NonReducibleUnknown;
|
|
84
|
+
};
|
|
85
|
+
setPrefill: {
|
|
86
|
+
type: "setPrefill";
|
|
87
|
+
params: xstate953.NonReducibleUnknown;
|
|
88
|
+
};
|
|
89
|
+
setCpf: {
|
|
90
|
+
type: "setCpf";
|
|
91
|
+
params: xstate953.NonReducibleUnknown;
|
|
92
|
+
};
|
|
93
|
+
}>, {
|
|
94
|
+
type: "isValid";
|
|
95
|
+
params: unknown;
|
|
96
|
+
}, never, "error" | "idle" | "finished" | "loading" | "submitting" | "inputting", string, CpfOcrInput, xstate953.NonReducibleUnknown, xstate953.EventObject, xstate953.MetaObject, {
|
|
97
|
+
readonly id: "cpfOcr";
|
|
98
|
+
readonly initial: "idle";
|
|
99
|
+
readonly context: {
|
|
100
|
+
readonly cpf: "";
|
|
101
|
+
readonly isValid: false;
|
|
102
|
+
readonly error: undefined;
|
|
103
|
+
};
|
|
104
|
+
readonly states: {
|
|
105
|
+
readonly idle: {
|
|
106
|
+
readonly on: {
|
|
107
|
+
readonly LOAD: "loading";
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
readonly loading: {
|
|
111
|
+
readonly invoke: {
|
|
112
|
+
readonly src: "fetchCpfOcrData";
|
|
113
|
+
readonly onDone: {
|
|
114
|
+
readonly target: "inputting";
|
|
115
|
+
readonly actions: "setPrefill";
|
|
116
|
+
};
|
|
117
|
+
readonly onError: {
|
|
118
|
+
readonly target: "error";
|
|
119
|
+
readonly actions: "setError";
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
readonly inputting: {
|
|
124
|
+
readonly on: {
|
|
125
|
+
readonly SET_CPF: {
|
|
126
|
+
readonly actions: "setCpf";
|
|
127
|
+
};
|
|
128
|
+
readonly SUBMIT: {
|
|
129
|
+
readonly guard: "isValid";
|
|
130
|
+
readonly target: "submitting";
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
readonly submitting: {
|
|
135
|
+
readonly invoke: {
|
|
136
|
+
readonly src: "submitCpfOcr";
|
|
137
|
+
readonly input: ({
|
|
138
|
+
context
|
|
139
|
+
}: {
|
|
140
|
+
context: CpfOcrContext;
|
|
141
|
+
event: {
|
|
142
|
+
type: "LOAD";
|
|
143
|
+
} | {
|
|
144
|
+
type: "SET_CPF";
|
|
145
|
+
cpf: string;
|
|
146
|
+
} | {
|
|
147
|
+
type: "SUBMIT";
|
|
148
|
+
} | {
|
|
149
|
+
type: "RETRY";
|
|
150
|
+
};
|
|
151
|
+
self: xstate953.ActorRef<xstate953.MachineSnapshot<CpfOcrContext, {
|
|
152
|
+
type: "LOAD";
|
|
153
|
+
} | {
|
|
154
|
+
type: "SET_CPF";
|
|
155
|
+
cpf: string;
|
|
156
|
+
} | {
|
|
157
|
+
type: "SUBMIT";
|
|
158
|
+
} | {
|
|
159
|
+
type: "RETRY";
|
|
160
|
+
}, Record<string, xstate953.AnyActorRef>, xstate953.StateValue, string, unknown, any, any>, {
|
|
161
|
+
type: "LOAD";
|
|
162
|
+
} | {
|
|
163
|
+
type: "SET_CPF";
|
|
164
|
+
cpf: string;
|
|
165
|
+
} | {
|
|
166
|
+
type: "SUBMIT";
|
|
167
|
+
} | {
|
|
168
|
+
type: "RETRY";
|
|
169
|
+
}, xstate953.AnyEventObject>;
|
|
170
|
+
}) => {
|
|
171
|
+
cpf: string;
|
|
172
|
+
};
|
|
173
|
+
readonly onDone: {
|
|
174
|
+
readonly target: "finished";
|
|
175
|
+
};
|
|
176
|
+
readonly onError: {
|
|
177
|
+
readonly target: "error";
|
|
178
|
+
readonly actions: "setError";
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
readonly error: {
|
|
183
|
+
readonly on: {
|
|
184
|
+
readonly RETRY: {
|
|
185
|
+
readonly target: "loading";
|
|
186
|
+
readonly actions: "clearError";
|
|
187
|
+
};
|
|
188
|
+
readonly SET_CPF: {
|
|
189
|
+
readonly target: "inputting";
|
|
190
|
+
readonly actions: "setCpf";
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
readonly finished: {
|
|
195
|
+
readonly type: "final";
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
}>;
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/modules/cpf-ocr/cpfOcrUtils.d.ts
|
|
201
|
+
declare function formatCPF(value: string): string;
|
|
202
|
+
declare function isValidCPF(value: string): boolean;
|
|
203
|
+
//#endregion
|
|
204
|
+
export { type CpfOcrManager, type CpfOcrState, cpfOcrMachine, createCpfOcrManager, formatCPF, isValidCPF };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { t as api } from "./api-CESGtpbH.esm.js";
|
|
2
|
+
import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
|
|
3
|
+
import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
|
|
4
|
+
import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
|
|
5
|
+
import { t as validateCPF } from "./cpf-PPz2Njto.esm.js";
|
|
6
|
+
|
|
7
|
+
//#region src/modules/cpf-ocr/cpfOcrServices.ts
|
|
8
|
+
async function fetchCpfOcrData(signal) {
|
|
9
|
+
const res = await api.get(endpoints.ocrData, { signal });
|
|
10
|
+
if (!res.ok) throw new Error(`GET ${endpoints.ocrData} failed: ${res.status} ${res.statusText}`);
|
|
11
|
+
return res.data;
|
|
12
|
+
}
|
|
13
|
+
async function submitCpfOcr(documentNumber, signal) {
|
|
14
|
+
const res = await api.put(endpoints.updateSession, { documentNumber }, { signal });
|
|
15
|
+
if (!res.ok) throw new Error(`PUT ${endpoints.updateSession} failed: ${res.status} ${res.statusText}`);
|
|
16
|
+
return res.data;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/modules/cpf-ocr/cpfOcrUtils.ts
|
|
21
|
+
function formatCPF(value) {
|
|
22
|
+
const digits = value.replace(/\D/g, "").slice(0, 11);
|
|
23
|
+
const first = digits.slice(0, 3);
|
|
24
|
+
const second = digits.slice(3, 6);
|
|
25
|
+
const third = digits.slice(6, 9);
|
|
26
|
+
const verifier = digits.slice(9, 11);
|
|
27
|
+
if (digits.length > 9) return `${first}.${second}.${third}-${verifier}`;
|
|
28
|
+
if (digits.length > 6) return `${first}.${second}.${third}`;
|
|
29
|
+
if (digits.length > 3) return `${first}.${second}`;
|
|
30
|
+
return first;
|
|
31
|
+
}
|
|
32
|
+
function isValidCPF(value) {
|
|
33
|
+
return validateCPF(value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/modules/cpf-ocr/cpfOcrStateMachine.ts
|
|
38
|
+
const cpfOcrMachine = setup({
|
|
39
|
+
types: {
|
|
40
|
+
context: {},
|
|
41
|
+
events: {},
|
|
42
|
+
input: {}
|
|
43
|
+
},
|
|
44
|
+
actors: {
|
|
45
|
+
fetchCpfOcrData: fromPromise(async ({ signal }) => fetchCpfOcrData(signal)),
|
|
46
|
+
submitCpfOcr: fromPromise(async ({ input, signal }) => submitCpfOcr(input.cpf, signal))
|
|
47
|
+
},
|
|
48
|
+
actions: {
|
|
49
|
+
setPrefill: assign(({ event }) => {
|
|
50
|
+
const output = event.output;
|
|
51
|
+
const cpf = formatCPF(output.documentNumber ?? "");
|
|
52
|
+
return {
|
|
53
|
+
cpf,
|
|
54
|
+
isValid: isValidCPF(cpf),
|
|
55
|
+
error: void 0
|
|
56
|
+
};
|
|
57
|
+
}),
|
|
58
|
+
setCpf: assign(({ event }) => {
|
|
59
|
+
const cpf = formatCPF(event.cpf);
|
|
60
|
+
return {
|
|
61
|
+
cpf,
|
|
62
|
+
isValid: isValidCPF(cpf),
|
|
63
|
+
error: void 0
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
setError: assign(({ event }) => ({ error: String(event.error) })),
|
|
67
|
+
clearError: assign({ error: () => void 0 })
|
|
68
|
+
},
|
|
69
|
+
guards: { isValid: ({ context }) => context.isValid }
|
|
70
|
+
}).createMachine({
|
|
71
|
+
id: "cpfOcr",
|
|
72
|
+
initial: "idle",
|
|
73
|
+
context: {
|
|
74
|
+
cpf: "",
|
|
75
|
+
isValid: false,
|
|
76
|
+
error: void 0
|
|
77
|
+
},
|
|
78
|
+
states: {
|
|
79
|
+
idle: { on: { LOAD: "loading" } },
|
|
80
|
+
loading: { invoke: {
|
|
81
|
+
src: "fetchCpfOcrData",
|
|
82
|
+
onDone: {
|
|
83
|
+
target: "inputting",
|
|
84
|
+
actions: "setPrefill"
|
|
85
|
+
},
|
|
86
|
+
onError: {
|
|
87
|
+
target: "error",
|
|
88
|
+
actions: "setError"
|
|
89
|
+
}
|
|
90
|
+
} },
|
|
91
|
+
inputting: { on: {
|
|
92
|
+
SET_CPF: { actions: "setCpf" },
|
|
93
|
+
SUBMIT: {
|
|
94
|
+
guard: "isValid",
|
|
95
|
+
target: "submitting"
|
|
96
|
+
}
|
|
97
|
+
} },
|
|
98
|
+
submitting: { invoke: {
|
|
99
|
+
src: "submitCpfOcr",
|
|
100
|
+
input: ({ context }) => ({ cpf: context.cpf }),
|
|
101
|
+
onDone: { target: "finished" },
|
|
102
|
+
onError: {
|
|
103
|
+
target: "error",
|
|
104
|
+
actions: "setError"
|
|
105
|
+
}
|
|
106
|
+
} },
|
|
107
|
+
error: { on: {
|
|
108
|
+
RETRY: {
|
|
109
|
+
target: "loading",
|
|
110
|
+
actions: "clearError"
|
|
111
|
+
},
|
|
112
|
+
SET_CPF: {
|
|
113
|
+
target: "inputting",
|
|
114
|
+
actions: "setCpf"
|
|
115
|
+
}
|
|
116
|
+
} },
|
|
117
|
+
finished: { type: "final" }
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/modules/cpf-ocr/cpfOcrActor.ts
|
|
123
|
+
function createCpfOcrActor() {
|
|
124
|
+
return createActor(cpfOcrMachine, { input: {} }).start();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/modules/cpf-ocr/cpfOcrManager.ts
|
|
129
|
+
function mapState(snapshot) {
|
|
130
|
+
const { context } = snapshot;
|
|
131
|
+
if (snapshot.matches("idle")) return { status: "idle" };
|
|
132
|
+
if (snapshot.matches("loading")) return { status: "loading" };
|
|
133
|
+
if (snapshot.matches("inputting")) return {
|
|
134
|
+
status: "inputting",
|
|
135
|
+
cpf: context.cpf,
|
|
136
|
+
isValid: context.isValid
|
|
137
|
+
};
|
|
138
|
+
if (snapshot.matches("submitting")) return { status: "submitting" };
|
|
139
|
+
if (snapshot.matches("error")) return {
|
|
140
|
+
status: "error",
|
|
141
|
+
error: context.error ?? "Unknown error"
|
|
142
|
+
};
|
|
143
|
+
if (snapshot.matches("finished")) return { status: "finished" };
|
|
144
|
+
return { status: "idle" };
|
|
145
|
+
}
|
|
146
|
+
function createApi({ actor, trackElementClicked }) {
|
|
147
|
+
return {
|
|
148
|
+
load() {
|
|
149
|
+
actor.send({ type: "LOAD" });
|
|
150
|
+
},
|
|
151
|
+
setCpf(cpf) {
|
|
152
|
+
actor.send({
|
|
153
|
+
type: "SET_CPF",
|
|
154
|
+
cpf
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
submit() {
|
|
158
|
+
trackElementClicked?.("continue");
|
|
159
|
+
actor.send({ type: "SUBMIT" });
|
|
160
|
+
},
|
|
161
|
+
retry() {
|
|
162
|
+
trackElementClicked?.("retry");
|
|
163
|
+
actor.send({ type: "RETRY" });
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function createCpfOcrManager() {
|
|
168
|
+
return createManager({
|
|
169
|
+
actor: createCpfOcrActor(),
|
|
170
|
+
mapState,
|
|
171
|
+
createApi,
|
|
172
|
+
instrumentation: createManagerInstrumentation(eventModuleNames.idOcr)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
export { cpfOcrMachine, createCpfOcrManager, formatCPF, isValidCPF };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { t as Manager } from "./Manager-C8PrhBOx.js";
|
|
2
|
+
|
|
3
|
+
//#region src/modules/cross-document-data-match/crossDocumentDataMatchManager.d.ts
|
|
4
|
+
type CrossDocumentDataMatchIdleState = {
|
|
5
|
+
status: 'idle';
|
|
6
|
+
};
|
|
7
|
+
type CrossDocumentDataMatchProcessingState = {
|
|
8
|
+
status: 'processing';
|
|
9
|
+
};
|
|
10
|
+
type CrossDocumentDataMatchFinishedState = {
|
|
11
|
+
status: 'finished';
|
|
12
|
+
};
|
|
13
|
+
type CrossDocumentDataMatchState = CrossDocumentDataMatchIdleState | CrossDocumentDataMatchProcessingState | CrossDocumentDataMatchFinishedState;
|
|
14
|
+
declare function createCrossDocumentDataMatchManager(): Manager<CrossDocumentDataMatchState> & {
|
|
15
|
+
/**
|
|
16
|
+
* Starts cross-document comparison (spinner + backend processing).
|
|
17
|
+
*/
|
|
18
|
+
load(): void;
|
|
19
|
+
};
|
|
20
|
+
type CrossDocumentDataMatchManager = ReturnType<typeof createCrossDocumentDataMatchManager>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/modules/cross-document-data-match/crossDocumentDataMatchStateMachine.d.ts
|
|
23
|
+
declare const crossDocumentDataMatchMachine: any;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/modules/cross-document-data-match/types.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for the cross-document data match module.
|
|
28
|
+
*
|
|
29
|
+
* The module runs a backend comparison of OCR data across captured documents
|
|
30
|
+
* and completes after a minimum display duration (spinner), matching legacy behavior.
|
|
31
|
+
*/
|
|
32
|
+
type CrossDocumentDataMatchConfig = Record<string, never>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { type CrossDocumentDataMatchConfig, type CrossDocumentDataMatchManager, type CrossDocumentDataMatchState, createCrossDocumentDataMatchManager, crossDocumentDataMatchMachine };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { t as api } from "./api-CESGtpbH.esm.js";
|
|
2
|
+
import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
|
|
3
|
+
import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
|
|
4
|
+
import { a as fromPromise, c as createManager, s as createActor, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
|
|
5
|
+
import { t as sleep } from "./ITimerCapability-C67ZRskg.esm.js";
|
|
6
|
+
|
|
7
|
+
//#region src/modules/cross-document-data-match/crossDocumentDataMatchServices.ts
|
|
8
|
+
/** Minimum spinner duration (ms), aligned with SDK v1 `ProcessCrossDocumentData`. */
|
|
9
|
+
const MIN_DISPLAY_MS = 3e3;
|
|
10
|
+
async function processCrossDocumentDataMatch(signal) {
|
|
11
|
+
const [res] = await Promise.all([api.post(endpoints.processCrossDocumentDataMatch, {}, { signal }), sleep(MIN_DISPLAY_MS)]);
|
|
12
|
+
if (!res.ok) throw new Error(`POST ${endpoints.processCrossDocumentDataMatch} failed: ${res.status} ${res.statusText}`);
|
|
13
|
+
return res.data;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/modules/cross-document-data-match/crossDocumentDataMatchStateMachine.ts
|
|
18
|
+
const crossDocumentDataMatchMachine = setup({
|
|
19
|
+
types: {
|
|
20
|
+
context: {},
|
|
21
|
+
events: {}
|
|
22
|
+
},
|
|
23
|
+
actors: { processCrossDocumentDataMatch: fromPromise(async ({ signal }) => {
|
|
24
|
+
return processCrossDocumentDataMatch(signal);
|
|
25
|
+
}) }
|
|
26
|
+
}).createMachine({
|
|
27
|
+
id: "crossDocumentDataMatch",
|
|
28
|
+
initial: "idle",
|
|
29
|
+
context: {},
|
|
30
|
+
states: {
|
|
31
|
+
idle: { on: { LOAD: { target: "processing" } } },
|
|
32
|
+
processing: { invoke: {
|
|
33
|
+
id: "processCrossDocumentDataMatch",
|
|
34
|
+
src: "processCrossDocumentDataMatch",
|
|
35
|
+
onDone: { target: "finished" },
|
|
36
|
+
onError: { target: "finished" }
|
|
37
|
+
} },
|
|
38
|
+
finished: { type: "final" }
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/modules/cross-document-data-match/crossDocumentDataMatchActor.ts
|
|
44
|
+
function createCrossDocumentDataMatchActor() {
|
|
45
|
+
return createActor(crossDocumentDataMatchMachine).start();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/modules/cross-document-data-match/crossDocumentDataMatchManager.ts
|
|
50
|
+
function mapState(snapshot) {
|
|
51
|
+
const typedSnapshot = snapshot;
|
|
52
|
+
if (typedSnapshot.matches("processing")) return { status: "processing" };
|
|
53
|
+
if (typedSnapshot.matches("finished")) return { status: "finished" };
|
|
54
|
+
return { status: "idle" };
|
|
55
|
+
}
|
|
56
|
+
function createApi({ actor }) {
|
|
57
|
+
return { load() {
|
|
58
|
+
actor.send({ type: "LOAD" });
|
|
59
|
+
} };
|
|
60
|
+
}
|
|
61
|
+
function createCrossDocumentDataMatchManager() {
|
|
62
|
+
return createManager({
|
|
63
|
+
actor: createCrossDocumentDataMatchActor(),
|
|
64
|
+
mapState,
|
|
65
|
+
createApi,
|
|
66
|
+
instrumentation: createManagerInstrumentation(eventModuleNames.crossDocumentDataMatch)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { createCrossDocumentDataMatchManager, crossDocumentDataMatchMachine };
|