@incodetech/core 0.0.0-dev-20260304-fb1914c → 0.0.0-dev-20260306-aac8dd3
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/authentication.d.ts +9 -8
- package/dist/authentication.esm.js +10 -10
- package/dist/{backCameraStream-CvzBcQqz.esm.js → backCameraStream-DXS4n4yS.esm.js} +1 -1
- package/dist/camera-HI2fNiV5.d.ts +4 -0
- package/dist/curp-validation.d.ts +4 -3
- package/dist/curp-validation.esm.js +5 -5
- package/dist/{deepsightLoader-BYoe0Nsv.esm.js → deepsightLoader-CCuD-pzB.esm.js} +4 -4
- package/dist/{deepsightService-nqR8Q7AS.esm.js → deepsightService-D2rnPj53.esm.js} +3 -3
- package/dist/{deepsightService-BpVsx9qI.d.ts → deepsightService-Dv1ILk27.d.ts} +1 -1
- package/dist/document-capture.d.ts +660 -0
- package/dist/document-capture.esm.js +428 -0
- package/dist/document-upload.d.ts +49 -48
- package/dist/document-upload.esm.js +5 -5
- package/dist/ekyb.d.ts +2 -2
- package/dist/ekyb.esm.js +6 -6
- package/dist/ekyc.d.ts +2 -2
- package/dist/ekyc.esm.js +6 -6
- package/dist/email.d.ts +1 -1
- package/dist/email.esm.js +5 -5
- package/dist/{endpoints-DZ8tQH8V.esm.js → endpoints-PMCuQkqs.esm.js} +4 -0
- package/dist/{events-B4Z68p21.esm.js → events-Bf73PAdv.esm.js} +2 -2
- package/dist/face-match.d.ts +1 -1
- package/dist/face-match.esm.js +5 -5
- package/dist/{faceCaptureManagerFactory-tyJQU0bQ.d.ts → faceCaptureManagerFactory-CftLkmnH.d.ts} +5 -5
- package/dist/{faceCaptureSetup-C6JFWLvG.esm.js → faceCaptureSetup-D3cIjwWO.esm.js} +9 -9
- package/dist/flow.d.ts +7 -6
- package/dist/flow.esm.js +5 -5
- package/dist/{flowCompletionService-BxrOI23Q.esm.js → flowCompletionService-C2Cjw8WY.esm.js} +2 -2
- package/dist/geolocation.d.ts +1 -1
- package/dist/geolocation.esm.js +5 -5
- package/dist/government-validation.d.ts +1 -1
- package/dist/government-validation.esm.js +4 -4
- package/dist/{id-B_LxGdTF.esm.js → id-CbVfoXco.esm.js} +10 -10
- package/dist/id.d.ts +9 -8
- package/dist/id.esm.js +10 -10
- package/dist/{index-BRPR-rem.d.ts → index-_guGVj8K.d.ts} +7 -7
- package/dist/index.d.ts +47 -10
- package/dist/index.esm.js +11 -11
- package/dist/{lib-DhQ9gAaS.esm.js → lib-DVaeY7hq.esm.js} +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/phone.esm.js +5 -5
- package/dist/selfie.d.ts +9 -8
- package/dist/selfie.esm.js +10 -10
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +3 -3
- package/dist/{src-jvUXRQjK.esm.js → src-BJhTmsja.esm.js} +77 -3
- package/dist/{stats-CIdlLJwO.esm.js → stats-De--Z9N5.esm.js} +1 -1
- package/dist/stats.esm.js +2 -2
- package/dist/{streamingEvents-evH8YUFP.esm.js → streamingEvents-BAYT4t4N.esm.js} +21 -4
- package/dist/{types-Cd8ODk69.d.ts → types-B_l5fu_D.d.ts} +4 -4
- package/dist/{types-CCmurMLG.d.ts → types-BcGRS3lW.d.ts} +1 -1
- package/package.json +5 -1
- /package/dist/{Actor-BWuqxR_a.d.ts → Actor-SKZvDOCc.d.ts} +0 -0
- /package/dist/{Manager-WfeWDo3j.d.ts → Manager-CVog-etk.d.ts} +0 -0
- /package/dist/{StateMachine-DQeBZwAJ.d.ts → StateMachine-Coiuk0UD.d.ts} +0 -0
- /package/dist/{api-utDuOVDZ.esm.js → api-CdJjfxTX.esm.js} +0 -0
- /package/dist/{chunk-B6vU4TSh.esm.js → chunk-3Wl3T5mL.esm.js} +0 -0
- /package/dist/{flowCompletionService-CSeT3Po7.d.ts → flowCompletionService-DtL1jOz4.d.ts} +0 -0
- /package/dist/{types-M1Q7M45h.d.ts → types-dSdX5z-n.d.ts} +0 -0
- /package/dist/{types-CnKs94Sr.d.ts → types-vXjqO0B-.d.ts} +0 -0
- /package/dist/{usStates-BAjX-Al7.esm.js → usStates-IoVg25OV.esm.js} +0 -0
- /package/dist/{warmup-G1qbIG0g.d.ts → warmup-CO10kO5G.d.ts} +0 -0
- /package/dist/{xstate.esm-Be4HOnoi.esm.js → xstate.esm-yA5caGbx.esm.js} +0 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { n as eventModuleNames, r as eventScreenNames, u as screenOpened } from "./events-Bf73PAdv.esm.js";
|
|
2
|
+
import { t as getBackCameraStream } from "./backCameraStream-DXS4n4yS.esm.js";
|
|
3
|
+
import { D as stopCameraStream, O as createManager } from "./src-BJhTmsja.esm.js";
|
|
4
|
+
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-yA5caGbx.esm.js";
|
|
5
|
+
import { t as api } from "./api-CdJjfxTX.esm.js";
|
|
6
|
+
import { t as endpoints } from "./endpoints-PMCuQkqs.esm.js";
|
|
7
|
+
|
|
8
|
+
//#region src/modules/document-capture/types.ts
|
|
9
|
+
const PROCESSING_TYPE_MAP = {
|
|
10
|
+
processV5CLogbook: "v5cMultiPageLogbook",
|
|
11
|
+
processCirculationCard: "circulationCard",
|
|
12
|
+
processFinanceSettlement: "financeSettlement",
|
|
13
|
+
processCarInvoice: "carInvoice",
|
|
14
|
+
asyncProcessCarInvoice: "carInvoice",
|
|
15
|
+
asyncProcessCirculationCard: "circulationCard",
|
|
16
|
+
capture: "addressStatement"
|
|
17
|
+
};
|
|
18
|
+
const MULTI_PAGE_TYPES = [
|
|
19
|
+
"v5cMultiPageLogbook",
|
|
20
|
+
"circulationCard",
|
|
21
|
+
"financeSettlement"
|
|
22
|
+
];
|
|
23
|
+
const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
24
|
+
const DEFAULT_CAPTURE_ATTEMPTS = 3;
|
|
25
|
+
const DOCUMENT_CAPTURE_ERROR_CODES = {
|
|
26
|
+
FILE_TOO_LARGE: "FILE_TOO_LARGE",
|
|
27
|
+
UPLOAD_FAILED: "UPLOAD_FAILED"
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/modules/document-capture/documentCaptureUploadService.ts
|
|
32
|
+
function resolveUploadUrl(processingType, fileFormat) {
|
|
33
|
+
const format = fileFormat === "application/pdf" ? "pdf" : "image";
|
|
34
|
+
const resolvedType = PROCESSING_TYPE_MAP[processingType] ?? processingType;
|
|
35
|
+
if (MULTI_PAGE_TYPES.includes(resolvedType)) return `${endpoints.documentV3}?type=${encodeURIComponent(resolvedType)}&format=${format}`;
|
|
36
|
+
if (resolvedType === "carInvoice") return `${endpoints.cfdi}?type=${encodeURIComponent(resolvedType)}&format=${format}`;
|
|
37
|
+
if ([
|
|
38
|
+
"otherDocument1",
|
|
39
|
+
"otherDocument2",
|
|
40
|
+
"otherDocument3"
|
|
41
|
+
].includes(resolvedType)) return `${endpoints.addDocument}?type=${encodeURIComponent(resolvedType)}&format=${format}`;
|
|
42
|
+
if (resolvedType === "addressStatement" || !resolvedType) return `${endpoints.addressStatement}?type=${encodeURIComponent(resolvedType || "addressStatement")}&format=${format}`;
|
|
43
|
+
return `${endpoints.addressStatement}?type=${encodeURIComponent(processingType)}&format=${format}`;
|
|
44
|
+
}
|
|
45
|
+
async function uploadDocumentCapture({ base64Image, processingType, fileFormat, onProgress, signal }) {
|
|
46
|
+
const url = resolveUploadUrl(processingType, fileFormat);
|
|
47
|
+
const rawBase64 = base64Image.includes(",") ? base64Image.split(",")[1] : base64Image;
|
|
48
|
+
const response = await api.post(url, { base64Image: rawBase64 }, {
|
|
49
|
+
signal,
|
|
50
|
+
onUploadProgress: onProgress
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) throw new Error(`Document upload failed: ${response.status}`);
|
|
53
|
+
if (!(response.data.success || response.data.status === "ADD_NEXT_PAGE")) throw new Error("Document upload rejected by server");
|
|
54
|
+
return response.data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/modules/document-capture/documentCaptureStateMachine.ts
|
|
59
|
+
const documentCaptureMachine = setup({
|
|
60
|
+
types: {
|
|
61
|
+
context: {},
|
|
62
|
+
events: {},
|
|
63
|
+
input: {}
|
|
64
|
+
},
|
|
65
|
+
actors: {
|
|
66
|
+
initCamera: fromPromise(async () => {
|
|
67
|
+
return getBackCameraStream(void 0);
|
|
68
|
+
}),
|
|
69
|
+
uploadDocument: fromPromise(async ({ input, signal }) => {
|
|
70
|
+
return uploadDocumentCapture({
|
|
71
|
+
base64Image: input.capturedDocument.imageBase64,
|
|
72
|
+
processingType: input.processingType,
|
|
73
|
+
fileFormat: input.capturedDocument.fileType,
|
|
74
|
+
onProgress: input.onProgress,
|
|
75
|
+
signal
|
|
76
|
+
});
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
actions: {
|
|
80
|
+
setStream: assign(({ event }) => ({ stream: event.output })),
|
|
81
|
+
setCapturedDocument: assign(({ event }) => {
|
|
82
|
+
const e = event;
|
|
83
|
+
return {
|
|
84
|
+
capturedDocument: {
|
|
85
|
+
imageBase64: e.imageBase64,
|
|
86
|
+
file: e.file,
|
|
87
|
+
fileType: e.fileType
|
|
88
|
+
},
|
|
89
|
+
error: void 0
|
|
90
|
+
};
|
|
91
|
+
}),
|
|
92
|
+
setFileTooLargeError: assign({ error: () => DOCUMENT_CAPTURE_ERROR_CODES.FILE_TOO_LARGE }),
|
|
93
|
+
setProgress: assign(({ event }) => ({ progress: event.progress })),
|
|
94
|
+
setUploadError: assign({ error: () => DOCUMENT_CAPTURE_ERROR_CODES.UPLOAD_FAILED }),
|
|
95
|
+
decrementAttemptsRemaining: assign(({ context }) => ({ attemptsRemaining: context.attemptsRemaining - 1 })),
|
|
96
|
+
setCaptureMethodFile: assign({ captureMethod: () => "file" }),
|
|
97
|
+
setCaptureMethodCamera: assign({ captureMethod: () => "camera" }),
|
|
98
|
+
clearCapturedDocument: assign({
|
|
99
|
+
capturedDocument: () => void 0,
|
|
100
|
+
captureMethod: () => void 0,
|
|
101
|
+
progress: () => 0,
|
|
102
|
+
error: () => void 0
|
|
103
|
+
}),
|
|
104
|
+
setPendingNextPage: assign(({ event }) => {
|
|
105
|
+
return { pendingNextPage: event.output.status === "ADD_NEXT_PAGE" };
|
|
106
|
+
}),
|
|
107
|
+
clearForNextPage: assign(({ context }) => ({
|
|
108
|
+
capturedDocument: void 0,
|
|
109
|
+
captureMethod: void 0,
|
|
110
|
+
progress: 0,
|
|
111
|
+
error: void 0,
|
|
112
|
+
pendingNextPage: false,
|
|
113
|
+
pageNumber: context.pageNumber + 1
|
|
114
|
+
})),
|
|
115
|
+
clearError: assign({ error: () => void 0 }),
|
|
116
|
+
resetProgress: assign({ progress: () => 0 }),
|
|
117
|
+
stopStream: assign(({ context }) => {
|
|
118
|
+
if (context.stream) stopCameraStream(context.stream);
|
|
119
|
+
return { stream: void 0 };
|
|
120
|
+
}),
|
|
121
|
+
trackTutorial: () => {
|
|
122
|
+
screenOpened(eventModuleNames.document, eventScreenNames.documentTutorial);
|
|
123
|
+
},
|
|
124
|
+
trackCapture: () => {
|
|
125
|
+
screenOpened(eventModuleNames.document, eventScreenNames.documentCameraCapture);
|
|
126
|
+
},
|
|
127
|
+
trackPreview: () => {
|
|
128
|
+
screenOpened(eventModuleNames.document, eventScreenNames.documentReviewPhoto);
|
|
129
|
+
},
|
|
130
|
+
trackUploading: () => {
|
|
131
|
+
screenOpened(eventModuleNames.document, eventScreenNames.documentUploadProgress);
|
|
132
|
+
},
|
|
133
|
+
trackSuccess: () => {
|
|
134
|
+
screenOpened(eventModuleNames.document, eventScreenNames.documentUploadSuccess);
|
|
135
|
+
},
|
|
136
|
+
trackFailure: () => {
|
|
137
|
+
screenOpened(eventModuleNames.document, eventScreenNames.documentAttemptFailed);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
guards: {
|
|
141
|
+
allowSkip: ({ context }) => context.config.allowSkipDocumentCapture && context.pageNumber === 1,
|
|
142
|
+
fileSizeOk: ({ context, event }) => {
|
|
143
|
+
return event.file.size <= context.config.maxFileSize;
|
|
144
|
+
},
|
|
145
|
+
hasAttemptsRemaining: ({ context }) => context.attemptsRemaining > 0,
|
|
146
|
+
canRetryCamera: ({ context }) => context.attemptsRemaining > 0 && context.captureMethod === "camera",
|
|
147
|
+
canRetryFile: ({ context }) => context.attemptsRemaining > 0 && context.captureMethod !== "camera",
|
|
148
|
+
attemptsExhausted: ({ context }) => context.attemptsRemaining <= 0,
|
|
149
|
+
isCameraMode: ({ context }) => context.config.captureMode === "camera",
|
|
150
|
+
isPendingNextPage: ({ context }) => context.pendingNextPage
|
|
151
|
+
}
|
|
152
|
+
}).createMachine({
|
|
153
|
+
id: "documentCapture",
|
|
154
|
+
initial: "tutorial",
|
|
155
|
+
context: ({ input }) => {
|
|
156
|
+
const { processingType = "addressStatement", captureMode = "camera", allowSkipDocumentCapture = false, captureAttempts = DEFAULT_CAPTURE_ATTEMPTS, sendBase64 = false, maxFileSize = DEFAULT_MAX_FILE_SIZE, title, text, step2Title, step2Text } = input.config;
|
|
157
|
+
return {
|
|
158
|
+
config: {
|
|
159
|
+
processingType,
|
|
160
|
+
captureMode,
|
|
161
|
+
allowSkipDocumentCapture,
|
|
162
|
+
captureAttempts,
|
|
163
|
+
sendBase64,
|
|
164
|
+
maxFileSize,
|
|
165
|
+
title,
|
|
166
|
+
text,
|
|
167
|
+
step2Title,
|
|
168
|
+
step2Text
|
|
169
|
+
},
|
|
170
|
+
stream: void 0,
|
|
171
|
+
capturedDocument: void 0,
|
|
172
|
+
captureMethod: void 0,
|
|
173
|
+
progress: 0,
|
|
174
|
+
error: void 0,
|
|
175
|
+
attemptsRemaining: captureAttempts,
|
|
176
|
+
pageNumber: 1,
|
|
177
|
+
pendingNextPage: false
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
states: {
|
|
181
|
+
tutorial: {
|
|
182
|
+
entry: "trackTutorial",
|
|
183
|
+
on: {
|
|
184
|
+
CAPTURE: [{
|
|
185
|
+
target: "initCamera",
|
|
186
|
+
guard: "isCameraMode"
|
|
187
|
+
}, { target: "capturing" }],
|
|
188
|
+
FILE_SELECTED: [{
|
|
189
|
+
target: "preview",
|
|
190
|
+
guard: "fileSizeOk",
|
|
191
|
+
actions: ["setCapturedDocument", "setCaptureMethodFile"]
|
|
192
|
+
}, {
|
|
193
|
+
target: "tutorial",
|
|
194
|
+
actions: "setFileTooLargeError"
|
|
195
|
+
}],
|
|
196
|
+
SKIP: {
|
|
197
|
+
target: "finished",
|
|
198
|
+
guard: "allowSkip"
|
|
199
|
+
},
|
|
200
|
+
CLOSE: { target: "closed" }
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
initCamera: {
|
|
204
|
+
invoke: {
|
|
205
|
+
id: "initCamera",
|
|
206
|
+
src: "initCamera",
|
|
207
|
+
input: void 0,
|
|
208
|
+
onDone: {
|
|
209
|
+
target: "capturing",
|
|
210
|
+
actions: "setStream"
|
|
211
|
+
},
|
|
212
|
+
onError: {
|
|
213
|
+
target: "failure",
|
|
214
|
+
actions: "setUploadError"
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
on: { CLOSE: { target: "closed" } }
|
|
218
|
+
},
|
|
219
|
+
capturing: {
|
|
220
|
+
entry: "trackCapture",
|
|
221
|
+
on: {
|
|
222
|
+
FILE_SELECTED: [{
|
|
223
|
+
target: "preview",
|
|
224
|
+
guard: "fileSizeOk",
|
|
225
|
+
actions: ["setCapturedDocument", "setCaptureMethodCamera"]
|
|
226
|
+
}, {
|
|
227
|
+
target: "capturing",
|
|
228
|
+
actions: "setFileTooLargeError"
|
|
229
|
+
}],
|
|
230
|
+
CLOSE: {
|
|
231
|
+
target: "closed",
|
|
232
|
+
actions: "stopStream"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
preview: {
|
|
237
|
+
entry: "trackPreview",
|
|
238
|
+
on: {
|
|
239
|
+
ACCEPT: {
|
|
240
|
+
target: "uploading",
|
|
241
|
+
actions: "resetProgress"
|
|
242
|
+
},
|
|
243
|
+
RETAKE: {
|
|
244
|
+
target: "capturing",
|
|
245
|
+
actions: "clearCapturedDocument"
|
|
246
|
+
},
|
|
247
|
+
CLOSE: {
|
|
248
|
+
target: "closed",
|
|
249
|
+
actions: "stopStream"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
uploading: {
|
|
254
|
+
entry: "trackUploading",
|
|
255
|
+
invoke: {
|
|
256
|
+
id: "uploadDocument",
|
|
257
|
+
src: "uploadDocument",
|
|
258
|
+
input: ({ context, self }) => {
|
|
259
|
+
if (!context.capturedDocument) throw new Error("No captured document to upload");
|
|
260
|
+
return {
|
|
261
|
+
capturedDocument: context.capturedDocument,
|
|
262
|
+
processingType: context.config.processingType,
|
|
263
|
+
onProgress: (progress) => {
|
|
264
|
+
self.send({
|
|
265
|
+
type: "UPLOAD_PROGRESS",
|
|
266
|
+
progress
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
onDone: {
|
|
272
|
+
target: "success",
|
|
273
|
+
actions: ["setPendingNextPage", "stopStream"]
|
|
274
|
+
},
|
|
275
|
+
onError: {
|
|
276
|
+
target: "failure",
|
|
277
|
+
actions: [
|
|
278
|
+
"setUploadError",
|
|
279
|
+
"decrementAttemptsRemaining",
|
|
280
|
+
"stopStream"
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
on: { UPLOAD_PROGRESS: { actions: "setProgress" } }
|
|
285
|
+
},
|
|
286
|
+
success: {
|
|
287
|
+
entry: "trackSuccess",
|
|
288
|
+
on: { CONTINUE: [{
|
|
289
|
+
target: "tutorial",
|
|
290
|
+
guard: "isPendingNextPage",
|
|
291
|
+
actions: "clearForNextPage"
|
|
292
|
+
}, { target: "finished" }] }
|
|
293
|
+
},
|
|
294
|
+
failure: {
|
|
295
|
+
entry: "trackFailure",
|
|
296
|
+
on: {
|
|
297
|
+
RETRY: [{
|
|
298
|
+
target: "initCamera",
|
|
299
|
+
guard: "canRetryCamera",
|
|
300
|
+
actions: ["clearError", "clearCapturedDocument"]
|
|
301
|
+
}, {
|
|
302
|
+
target: "tutorial",
|
|
303
|
+
guard: "canRetryFile",
|
|
304
|
+
actions: ["clearError", "clearCapturedDocument"]
|
|
305
|
+
}],
|
|
306
|
+
CLOSE: { target: "closed" }
|
|
307
|
+
},
|
|
308
|
+
after: { 3e3: {
|
|
309
|
+
target: "finished",
|
|
310
|
+
guard: "attemptsExhausted"
|
|
311
|
+
} }
|
|
312
|
+
},
|
|
313
|
+
finished: { type: "final" },
|
|
314
|
+
closed: { type: "final" }
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/modules/document-capture/documentCaptureActor.ts
|
|
320
|
+
function createDocumentCaptureActor(options) {
|
|
321
|
+
return createActor(documentCaptureMachine, { input: { config: options.config } }).start();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/modules/document-capture/documentCaptureManager.ts
|
|
326
|
+
function mapState(snapshot) {
|
|
327
|
+
const typedSnapshot = snapshot;
|
|
328
|
+
const { context } = typedSnapshot;
|
|
329
|
+
if (typedSnapshot.matches("tutorial")) {
|
|
330
|
+
const isSecondPage = context.pageNumber > 1;
|
|
331
|
+
return {
|
|
332
|
+
status: "tutorial",
|
|
333
|
+
title: isSecondPage ? context.config.step2Title ?? context.config.title : context.config.title,
|
|
334
|
+
text: isSecondPage ? context.config.step2Text ?? context.config.text : context.config.text,
|
|
335
|
+
allowSkipDocumentCapture: context.config.allowSkipDocumentCapture && context.pageNumber === 1,
|
|
336
|
+
captureMode: context.config.captureMode,
|
|
337
|
+
error: context.error,
|
|
338
|
+
pageNumber: context.pageNumber
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
if (typedSnapshot.matches("initCamera")) return { status: "initializingCamera" };
|
|
342
|
+
if (typedSnapshot.matches("capturing")) return {
|
|
343
|
+
status: "capturing",
|
|
344
|
+
stream: context.stream,
|
|
345
|
+
captureMode: context.config.captureMode,
|
|
346
|
+
error: context.error,
|
|
347
|
+
pageNumber: context.pageNumber
|
|
348
|
+
};
|
|
349
|
+
if (typedSnapshot.matches("preview")) return {
|
|
350
|
+
status: "preview",
|
|
351
|
+
imageBase64: context.capturedDocument?.imageBase64 ?? "",
|
|
352
|
+
fileType: context.capturedDocument?.fileType ?? "",
|
|
353
|
+
fileName: context.capturedDocument?.file.name ?? ""
|
|
354
|
+
};
|
|
355
|
+
if (typedSnapshot.matches("uploading")) return {
|
|
356
|
+
status: "uploading",
|
|
357
|
+
progress: context.progress,
|
|
358
|
+
imageBase64: context.capturedDocument?.imageBase64 ?? "",
|
|
359
|
+
fileType: context.capturedDocument?.fileType ?? "",
|
|
360
|
+
fileName: context.capturedDocument?.file.name ?? ""
|
|
361
|
+
};
|
|
362
|
+
if (typedSnapshot.matches("success")) return {
|
|
363
|
+
status: "success",
|
|
364
|
+
imageBase64: context.capturedDocument?.imageBase64 ?? "",
|
|
365
|
+
fileType: context.capturedDocument?.fileType ?? "",
|
|
366
|
+
fileName: context.capturedDocument?.file.name ?? "",
|
|
367
|
+
pendingNextPage: context.pendingNextPage
|
|
368
|
+
};
|
|
369
|
+
if (typedSnapshot.matches("failure")) return {
|
|
370
|
+
status: "failure",
|
|
371
|
+
error: context.error ?? DOCUMENT_CAPTURE_ERROR_CODES.UPLOAD_FAILED,
|
|
372
|
+
attemptsRemaining: context.attemptsRemaining
|
|
373
|
+
};
|
|
374
|
+
if (typedSnapshot.matches("finished")) return { status: "finished" };
|
|
375
|
+
if (typedSnapshot.matches("closed")) return { status: "closed" };
|
|
376
|
+
return {
|
|
377
|
+
status: "tutorial",
|
|
378
|
+
title: void 0,
|
|
379
|
+
text: void 0,
|
|
380
|
+
allowSkipDocumentCapture: false,
|
|
381
|
+
captureMode: "file",
|
|
382
|
+
error: void 0,
|
|
383
|
+
pageNumber: 1
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function createApi({ actor }) {
|
|
387
|
+
return {
|
|
388
|
+
capture() {
|
|
389
|
+
actor.send({ type: "CAPTURE" });
|
|
390
|
+
},
|
|
391
|
+
setFile(file, imageBase64) {
|
|
392
|
+
actor.send({
|
|
393
|
+
type: "FILE_SELECTED",
|
|
394
|
+
file,
|
|
395
|
+
imageBase64,
|
|
396
|
+
fileType: file.type
|
|
397
|
+
});
|
|
398
|
+
},
|
|
399
|
+
accept() {
|
|
400
|
+
actor.send({ type: "ACCEPT" });
|
|
401
|
+
},
|
|
402
|
+
retake() {
|
|
403
|
+
actor.send({ type: "RETAKE" });
|
|
404
|
+
},
|
|
405
|
+
retry() {
|
|
406
|
+
actor.send({ type: "RETRY" });
|
|
407
|
+
},
|
|
408
|
+
continue() {
|
|
409
|
+
actor.send({ type: "CONTINUE" });
|
|
410
|
+
},
|
|
411
|
+
skip() {
|
|
412
|
+
actor.send({ type: "SKIP" });
|
|
413
|
+
},
|
|
414
|
+
close() {
|
|
415
|
+
actor.send({ type: "CLOSE" });
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function createDocumentCaptureManager(options) {
|
|
420
|
+
return createManager({
|
|
421
|
+
actor: createDocumentCaptureActor(options),
|
|
422
|
+
mapState,
|
|
423
|
+
createApi
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
//#endregion
|
|
428
|
+
export { DOCUMENT_CAPTURE_ERROR_CODES, createDocumentCaptureManager, documentCaptureMachine };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { t as Manager } from "./Manager-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { t as Manager } from "./Manager-CVog-etk.js";
|
|
2
|
+
import "./camera-HI2fNiV5.js";
|
|
3
|
+
import { n as DocumentUploadContext, r as DocumentUploadInput, t as DocumentUploadConfig } from "./types-B_l5fu_D.js";
|
|
4
|
+
import * as xstate58 from "xstate";
|
|
4
5
|
|
|
5
6
|
//#region src/modules/document-upload/documentUploadStateMachine.d.ts
|
|
6
|
-
declare const documentUploadMachine:
|
|
7
|
+
declare const documentUploadMachine: xstate58.StateMachine<DocumentUploadContext, {
|
|
7
8
|
type: "START";
|
|
8
9
|
} | {
|
|
9
10
|
type: "CAPTURE";
|
|
@@ -16,52 +17,52 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
16
17
|
} | {
|
|
17
18
|
type: "CLOSE";
|
|
18
19
|
}, {
|
|
19
|
-
[x: string]:
|
|
20
|
+
[x: string]: xstate58.ActorRefFromLogic<xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>> | xstate58.ActorRefFromLogic<xstate58.PromiseActorLogic<void, {
|
|
20
21
|
imageBase64: string;
|
|
21
22
|
documentType: string;
|
|
22
23
|
onProgress: (progress: number) => void;
|
|
23
|
-
},
|
|
24
|
-
},
|
|
24
|
+
}, xstate58.EventObject>> | undefined;
|
|
25
|
+
}, xstate58.Values<{
|
|
25
26
|
initCamera: {
|
|
26
27
|
src: "initCamera";
|
|
27
|
-
logic:
|
|
28
|
+
logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
|
|
28
29
|
id: string | undefined;
|
|
29
30
|
};
|
|
30
31
|
uploadDocument: {
|
|
31
32
|
src: "uploadDocument";
|
|
32
|
-
logic:
|
|
33
|
+
logic: xstate58.PromiseActorLogic<void, {
|
|
33
34
|
imageBase64: string;
|
|
34
35
|
documentType: string;
|
|
35
36
|
onProgress: (progress: number) => void;
|
|
36
|
-
},
|
|
37
|
+
}, xstate58.EventObject>;
|
|
37
38
|
id: string | undefined;
|
|
38
39
|
};
|
|
39
|
-
}>,
|
|
40
|
+
}>, xstate58.Values<{
|
|
40
41
|
setStream: {
|
|
41
42
|
type: "setStream";
|
|
42
|
-
params:
|
|
43
|
-
};
|
|
44
|
-
setImageAndClearError: {
|
|
45
|
-
type: "setImageAndClearError";
|
|
46
|
-
params: xstate0.NonReducibleUnknown;
|
|
43
|
+
params: xstate58.NonReducibleUnknown;
|
|
47
44
|
};
|
|
48
45
|
setProgress: {
|
|
49
46
|
type: "setProgress";
|
|
50
|
-
params:
|
|
51
|
-
};
|
|
52
|
-
setError: {
|
|
53
|
-
type: "setError";
|
|
54
|
-
params: xstate0.NonReducibleUnknown;
|
|
47
|
+
params: xstate58.NonReducibleUnknown;
|
|
55
48
|
};
|
|
56
49
|
clearError: {
|
|
57
50
|
type: "clearError";
|
|
58
|
-
params:
|
|
51
|
+
params: xstate58.NonReducibleUnknown;
|
|
59
52
|
};
|
|
60
53
|
stopStream: {
|
|
61
54
|
type: "stopStream";
|
|
62
|
-
params:
|
|
55
|
+
params: xstate58.NonReducibleUnknown;
|
|
56
|
+
};
|
|
57
|
+
setImageAndClearError: {
|
|
58
|
+
type: "setImageAndClearError";
|
|
59
|
+
params: xstate58.NonReducibleUnknown;
|
|
60
|
+
};
|
|
61
|
+
setError: {
|
|
62
|
+
type: "setError";
|
|
63
|
+
params: xstate58.NonReducibleUnknown;
|
|
63
64
|
};
|
|
64
|
-
}>, never, never, "error" | "initCamera" | "
|
|
65
|
+
}>, never, never, "error" | "initCamera" | "capturing" | "finished" | "closed" | "uploading" | "idle", string, DocumentUploadInput, xstate58.NonReducibleUnknown, xstate58.EventObject, xstate58.MetaObject, {
|
|
65
66
|
readonly id: "documentUpload";
|
|
66
67
|
readonly initial: "idle";
|
|
67
68
|
readonly context: ({
|
|
@@ -70,67 +71,67 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
70
71
|
spawn: {
|
|
71
72
|
<TSrc extends "initCamera" | "uploadDocument">(logic: TSrc, ...[options]: ({
|
|
72
73
|
src: "initCamera";
|
|
73
|
-
logic:
|
|
74
|
+
logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
|
|
74
75
|
id: string | undefined;
|
|
75
76
|
} extends infer T ? T extends {
|
|
76
77
|
src: "initCamera";
|
|
77
|
-
logic:
|
|
78
|
+
logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
|
|
78
79
|
id: string | undefined;
|
|
79
80
|
} ? T extends {
|
|
80
81
|
src: TSrc;
|
|
81
|
-
} ?
|
|
82
|
+
} ? xstate58.ConditionalRequired<[options?: ({
|
|
82
83
|
id?: T["id"] | undefined;
|
|
83
84
|
systemId?: string;
|
|
84
|
-
input?:
|
|
85
|
+
input?: xstate58.InputFrom<T["logic"]> | undefined;
|
|
85
86
|
syncSnapshot?: boolean;
|
|
86
|
-
} & { [K in
|
|
87
|
+
} & { [K in xstate58.RequiredActorOptions<T>]: unknown }) | undefined], xstate58.IsNotNever<xstate58.RequiredActorOptions<T>>> : never : never : never) | ({
|
|
87
88
|
src: "uploadDocument";
|
|
88
|
-
logic:
|
|
89
|
+
logic: xstate58.PromiseActorLogic<void, {
|
|
89
90
|
imageBase64: string;
|
|
90
91
|
documentType: string;
|
|
91
92
|
onProgress: (progress: number) => void;
|
|
92
|
-
},
|
|
93
|
+
}, xstate58.EventObject>;
|
|
93
94
|
id: string | undefined;
|
|
94
95
|
} extends infer T_1 ? T_1 extends {
|
|
95
96
|
src: "uploadDocument";
|
|
96
|
-
logic:
|
|
97
|
+
logic: xstate58.PromiseActorLogic<void, {
|
|
97
98
|
imageBase64: string;
|
|
98
99
|
documentType: string;
|
|
99
100
|
onProgress: (progress: number) => void;
|
|
100
|
-
},
|
|
101
|
+
}, xstate58.EventObject>;
|
|
101
102
|
id: string | undefined;
|
|
102
103
|
} ? T_1 extends {
|
|
103
104
|
src: TSrc;
|
|
104
|
-
} ?
|
|
105
|
+
} ? xstate58.ConditionalRequired<[options?: ({
|
|
105
106
|
id?: T_1["id"] | undefined;
|
|
106
107
|
systemId?: string;
|
|
107
|
-
input?:
|
|
108
|
+
input?: xstate58.InputFrom<T_1["logic"]> | undefined;
|
|
108
109
|
syncSnapshot?: boolean;
|
|
109
|
-
} & { [K_1 in
|
|
110
|
+
} & { [K_1 in xstate58.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate58.IsNotNever<xstate58.RequiredActorOptions<T_1>>> : never : never : never)): xstate58.ActorRefFromLogic<xstate58.GetConcreteByKey<xstate58.Values<{
|
|
110
111
|
initCamera: {
|
|
111
112
|
src: "initCamera";
|
|
112
|
-
logic:
|
|
113
|
+
logic: xstate58.PromiseActorLogic<MediaStream, void, xstate58.EventObject>;
|
|
113
114
|
id: string | undefined;
|
|
114
115
|
};
|
|
115
116
|
uploadDocument: {
|
|
116
117
|
src: "uploadDocument";
|
|
117
|
-
logic:
|
|
118
|
+
logic: xstate58.PromiseActorLogic<void, {
|
|
118
119
|
imageBase64: string;
|
|
119
120
|
documentType: string;
|
|
120
121
|
onProgress: (progress: number) => void;
|
|
121
|
-
},
|
|
122
|
+
}, xstate58.EventObject>;
|
|
122
123
|
id: string | undefined;
|
|
123
124
|
};
|
|
124
125
|
}>, "src", TSrc>["logic"]>;
|
|
125
|
-
<TLogic extends
|
|
126
|
+
<TLogic extends xstate58.AnyActorLogic>(src: TLogic, ...[options]: xstate58.ConditionalRequired<[options?: ({
|
|
126
127
|
id?: never;
|
|
127
128
|
systemId?: string;
|
|
128
|
-
input?:
|
|
129
|
+
input?: xstate58.InputFrom<TLogic> | undefined;
|
|
129
130
|
syncSnapshot?: boolean;
|
|
130
|
-
} & { [K in
|
|
131
|
+
} & { [K in xstate58.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate58.IsNotNever<xstate58.RequiredLogicInput<TLogic>>>): xstate58.ActorRefFromLogic<TLogic>;
|
|
131
132
|
};
|
|
132
133
|
input: DocumentUploadInput;
|
|
133
|
-
self:
|
|
134
|
+
self: xstate58.ActorRef<xstate58.MachineSnapshot<DocumentUploadContext, {
|
|
134
135
|
type: "START";
|
|
135
136
|
} | {
|
|
136
137
|
type: "CAPTURE";
|
|
@@ -142,7 +143,7 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
142
143
|
type: "RETRY";
|
|
143
144
|
} | {
|
|
144
145
|
type: "CLOSE";
|
|
145
|
-
}, Record<string,
|
|
146
|
+
}, Record<string, xstate58.AnyActorRef | undefined>, xstate58.StateValue, string, unknown, any, any>, {
|
|
146
147
|
type: "START";
|
|
147
148
|
} | {
|
|
148
149
|
type: "CAPTURE";
|
|
@@ -154,7 +155,7 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
154
155
|
type: "RETRY";
|
|
155
156
|
} | {
|
|
156
157
|
type: "CLOSE";
|
|
157
|
-
},
|
|
158
|
+
}, xstate58.AnyEventObject>;
|
|
158
159
|
}) => {
|
|
159
160
|
config: DocumentUploadConfig;
|
|
160
161
|
stream: undefined;
|
|
@@ -224,7 +225,7 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
224
225
|
} | {
|
|
225
226
|
type: "CLOSE";
|
|
226
227
|
};
|
|
227
|
-
self:
|
|
228
|
+
self: xstate58.ActorRef<xstate58.MachineSnapshot<DocumentUploadContext, {
|
|
228
229
|
type: "START";
|
|
229
230
|
} | {
|
|
230
231
|
type: "CAPTURE";
|
|
@@ -236,7 +237,7 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
236
237
|
type: "RETRY";
|
|
237
238
|
} | {
|
|
238
239
|
type: "CLOSE";
|
|
239
|
-
}, Record<string,
|
|
240
|
+
}, Record<string, xstate58.AnyActorRef>, xstate58.StateValue, string, unknown, any, any>, {
|
|
240
241
|
type: "START";
|
|
241
242
|
} | {
|
|
242
243
|
type: "CAPTURE";
|
|
@@ -248,7 +249,7 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
248
249
|
type: "RETRY";
|
|
249
250
|
} | {
|
|
250
251
|
type: "CLOSE";
|
|
251
|
-
},
|
|
252
|
+
}, xstate58.AnyEventObject>;
|
|
252
253
|
}) => {
|
|
253
254
|
imageBase64: string;
|
|
254
255
|
documentType: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as getBackCameraStream } from "./backCameraStream-
|
|
2
|
-
import { D as
|
|
3
|
-
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-
|
|
4
|
-
import { t as api } from "./api-
|
|
5
|
-
import { t as endpoints } from "./endpoints-
|
|
1
|
+
import { t as getBackCameraStream } from "./backCameraStream-DXS4n4yS.esm.js";
|
|
2
|
+
import { D as stopCameraStream, O as createManager } from "./src-BJhTmsja.esm.js";
|
|
3
|
+
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-yA5caGbx.esm.js";
|
|
4
|
+
import { t as api } from "./api-CdJjfxTX.esm.js";
|
|
5
|
+
import { t as endpoints } from "./endpoints-PMCuQkqs.esm.js";
|
|
6
6
|
|
|
7
7
|
//#region src/modules/document-upload/documentUploadServices.ts
|
|
8
8
|
async function uploadDocument({ imageBase64, documentType, onProgress, signal }) {
|
package/dist/ekyb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Manager } from "./Manager-
|
|
2
|
-
import { t as FieldDef } from "./types-
|
|
1
|
+
import { t as Manager } from "./Manager-CVog-etk.js";
|
|
2
|
+
import { t as FieldDef } from "./types-vXjqO0B-.js";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/ekyb/types.d.ts
|
|
5
5
|
type UboEntry = {
|
package/dist/ekyb.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-
|
|
2
|
-
import {
|
|
3
|
-
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-
|
|
4
|
-
import { t as api } from "./api-
|
|
5
|
-
import { t as endpoints } from "./endpoints-
|
|
6
|
-
import { t as usStateOptions } from "./usStates-
|
|
1
|
+
import { d as addEvent, n as eventModuleNames, r as eventScreenNames } from "./events-Bf73PAdv.esm.js";
|
|
2
|
+
import { O as createManager } from "./src-BJhTmsja.esm.js";
|
|
3
|
+
import { a as createActor, i as fromPromise, n as assign, t as setup } from "./xstate.esm-yA5caGbx.esm.js";
|
|
4
|
+
import { t as api } from "./api-CdJjfxTX.esm.js";
|
|
5
|
+
import { t as endpoints } from "./endpoints-PMCuQkqs.esm.js";
|
|
6
|
+
import { t as usStateOptions } from "./usStates-IoVg25OV.esm.js";
|
|
7
7
|
|
|
8
8
|
//#region src/modules/ekyb/ekybConstants.ts
|
|
9
9
|
const UBO_INPUT_LIMIT = 8;
|