@incodetech/core 0.0.0-dev-20260407-2c382da → 0.0.0-dev-20260407-ebd92aa
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/{BaseWasmProvider--AzPfwOm.esm.js → BaseWasmProvider-CQgeReKV.esm.js} +1 -785
- package/dist/MotionSensorProvider-BTDLt08l.esm.js +254 -0
- package/dist/OpenViduRecordingProvider-PvkEhhDq.esm.js +87 -0
- package/dist/StateMachine-DU1S4Cik.d.ts +2 -0
- package/dist/{WasmUtilProvider-BonqBWdj.esm.js → WasmUtilProvider-C45HStLj.esm.js} +1 -1
- package/dist/{addressSearch-B8Fo4v9V.esm.js → addressSearch-C5qzDvkN.esm.js} +4 -4
- package/dist/antifraud.d.ts +1 -1
- package/dist/antifraud.esm.js +3 -3
- package/dist/authentication.d.ts +11 -9
- package/dist/authentication.esm.js +18 -13
- package/dist/{authenticationManager-Bd10YGSO.d.ts → authenticationManager-CXTPgE_2.d.ts} +2 -2
- package/dist/{authenticationManager-B4gSCgrO.esm.js → authenticationManager-D4esVx-z.esm.js} +7 -6
- package/dist/{backCameraStream-DF_d7hTz.esm.js → backCameraStream-CUo1USCT.esm.js} +2 -2
- package/dist/camera.d.ts +16 -0
- package/dist/camera.esm.js +5 -0
- package/dist/consent.d.ts +52 -52
- package/dist/consent.esm.js +3 -3
- package/dist/curp-validation.d.ts +5 -5
- package/dist/curp-validation.esm.js +3 -3
- package/dist/{deepsightLoader-DKgEdLIS.esm.js → deepsightLoader-Bs5jHgca.esm.js} +10 -7
- package/dist/deepsightService-C3gQ_9Ml.esm.js +493 -0
- package/dist/{deepsightService-Ciu0atv5.d.ts → deepsightService-CyEcAH-I.d.ts} +193 -197
- package/dist/device.d.ts +46 -0
- package/dist/device.esm.js +106 -0
- package/dist/document-capture.d.ts +3 -3
- package/dist/document-capture.esm.js +6 -6
- package/dist/document-upload.d.ts +4 -4
- package/dist/document-upload.esm.js +6 -6
- package/dist/ekyb.d.ts +3 -3
- package/dist/ekyb.esm.js +9 -9
- package/dist/ekyc.d.ts +3 -3
- package/dist/ekyc.esm.js +5 -5
- package/dist/email.d.ts +3 -3
- package/dist/email.esm.js +5 -5
- package/dist/{emailManager-CpAwvP3v.esm.js → emailManager-CZ2IGW0g.esm.js} +4 -4
- package/dist/{emailManager-BQPIJR_O.d.ts → emailManager-CtA6Tvry.d.ts} +2 -2
- package/dist/events-BlVGS-8F.esm.js +472 -0
- package/dist/events.d.ts +232 -0
- package/dist/events.esm.js +4 -0
- package/dist/extensibility.d.ts +15 -13
- package/dist/extensibility.esm.js +25 -20
- package/dist/face-match.d.ts +1 -1
- package/dist/face-match.esm.js +3 -3
- package/dist/{faceCaptureManagerFactory-CdwpYykv.d.ts → faceCaptureManagerFactory-Bp_mC9b2.d.ts} +8 -6
- package/dist/faceCaptureSetup-DzlTPjT9.esm.js +828 -0
- package/dist/flow.d.ts +17 -9
- package/dist/flow.esm.js +68 -21
- package/dist/{flowCompletionService-TnWijsSw.esm.js → flowCompletionService-N6-xypy-.esm.js} +2 -2
- package/dist/{flowServices-CO2sIR3D.esm.js → flowServices-xgqnJ64L.esm.js} +3 -3
- package/dist/geolocation.d.ts +2 -2
- package/dist/geolocation.esm.js +4 -4
- package/dist/getBrowser-B800KRAi.esm.js +41 -0
- package/dist/getDeviceClass-BKd2FOAf.esm.js +14 -0
- package/dist/government-validation.d.ts +2 -2
- package/dist/government-validation.esm.js +4 -4
- package/dist/http.d.ts +57 -0
- package/dist/http.esm.js +3 -0
- package/dist/id.d.ts +11 -10
- package/dist/id.esm.js +20 -16
- package/dist/{idCaptureManager-IdqsAASp.d.ts → idCaptureManager-Bx298yFC.d.ts} +9 -7
- package/dist/{idCaptureManager-DaLU1ug7.esm.js → idCaptureManager-bowLKHEs.esm.js} +75 -58
- package/dist/index.d.ts +3 -611
- package/dist/index.esm.js +10 -562
- package/dist/{lib-i-4qLKdG.esm.js → lib-Cq5Wc-Hd.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +55 -55
- package/dist/mandatory-consent.esm.js +3 -3
- package/dist/openviduLazy-BdsxPGgp.esm.js +12 -0
- package/dist/openviduLazy-NTgGtkeK.esm.js +3 -0
- package/dist/permissionServices-CDqkkway.esm.js +50 -0
- package/dist/phone.d.ts +3 -3
- package/dist/phone.esm.js +5 -5
- package/dist/{phoneManager-BAPHSXx8.esm.js → phoneManager-CscgaER2.esm.js} +4 -4
- package/dist/{phoneManager-DA8WUJtl.d.ts → phoneManager-DlaiZtwZ.d.ts} +2 -2
- package/dist/recordingService-BDx_6XR9.esm.js +1024 -0
- package/dist/redirect-to-mobile.d.ts +2 -2
- package/dist/redirect-to-mobile.esm.js +4 -4
- package/dist/selfie.d.ts +11 -9
- package/dist/selfie.esm.js +18 -13
- package/dist/{selfieManager-BSkzncsa.esm.js → selfieManager-DVvvlMMf.esm.js} +5 -4
- package/dist/{selfieManager-Dft5wZQ_.d.ts → selfieManager-UBgYgVnw.d.ts} +2 -2
- package/dist/{session-OglUYC9l.esm.js → session-PLjFj_T3.esm.js} +5 -19
- package/dist/session.d.ts +46 -2
- package/dist/session.esm.js +7 -4
- package/dist/setup-DfinQjIF.d.ts +120 -0
- package/dist/setup-fvDWE7f8.esm.js +450 -0
- package/dist/signature.d.ts +2 -2
- package/dist/signature.esm.js +3 -3
- package/dist/{stats-BVigf5Rn.esm.js → stats-BZ1kFW4p.esm.js} +1 -1
- package/dist/stats.esm.js +2 -2
- package/dist/{types-CiLyvJGb.d.ts → types-DcqFYowa.d.ts} +1 -1
- package/dist/{types-D8Y1faI5.d.ts → types-DufUK-_f.d.ts} +1 -1
- package/dist/types-UPqCMQKa.d.ts +5 -0
- package/dist/{StateMachine-CM_aOfNL.d.ts → warmup-yzJJKXFi.d.ts} +1 -4
- package/dist/wasm.d.ts +15 -0
- package/dist/wasm.esm.js +10 -0
- package/dist/{Manager-C6AGXEq_.esm.js → xstate.esm-BXrcOcSC.esm.js} +103 -507
- package/package.json +18 -2
- package/dist/StreamCanvasCapture-DkpkIgyL.esm.js +0 -410
- package/dist/endpoints-CI5-28jT.esm.js +0 -69
- package/dist/faceCaptureSetup-DbXgtcp7.esm.js +0 -1561
- package/dist/id-CzDAG_kM.esm.js +0 -0
- package/dist/index-BuVKc9bv.d.ts +0 -1
- /package/dist/{Actor-By8WNHi-.d.ts → Actor-Cz_KnN47.d.ts} +0 -0
- /package/dist/{BrowserEnvironmentProvider-BECjyw3_.esm.js → BrowserEnvironmentProvider--xQUs3sg.esm.js} +0 -0
- /package/dist/{BrowserTimerProvider-CIqH6hJp.esm.js → BrowserTimerProvider-CkHEwJFa.esm.js} +0 -0
- /package/dist/{Manager-CCT_-HuZ.d.ts → Manager-N01KfnVA.d.ts} +0 -0
- /package/dist/{api-C2uzxrpN.esm.js → api-CyI8qTie.esm.js} +0 -0
- /package/dist/{browserSimulation-DYAk0Ipe.esm.js → browserSimulation-yzDdWSBf.esm.js} +0 -0
- /package/dist/{camera-6XJdOeBF.d.ts → camera-BcVDCZxW.d.ts} +0 -0
- /package/dist/{camera-DAuRUvnp.esm.js → camera-CsT06Zqy.esm.js} +0 -0
- /package/dist/{chunk-D6hkk-hd.esm.js → chunk-BcQWkoAq.esm.js} +0 -0
- /package/dist/{displayErrors-CGJwvrTl.d.ts → displayErrors-C0mf2glb.d.ts} +0 -0
- /package/dist/{flowCompletionService-BOd4Rk8n.d.ts → flowCompletionService-Dloh6J8n.d.ts} +0 -0
- /package/dist/{platform-DdhkonXk.esm.js → platform-Dcuv6w60.esm.js} +0 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
import { r as getToken } from "./api-CyI8qTie.esm.js";
|
|
2
|
+
import { o as createManagerInstrumentation } from "./events-BlVGS-8F.esm.js";
|
|
3
|
+
import { i as fromPromise, n as assign, o as createManager, r as fromCallback, t as setup } from "./xstate.esm-BXrcOcSC.esm.js";
|
|
4
|
+
import { _ as StreamCanvasCapture, a as initializeDeepsightSession, c as stopStream, h as flagFaceManualReview, i as initializeCamera, n as preloadOpenViduProvider, o as sendLabelInspectionEvent, r as encryptSelfieImage, s as startDetection, t as createRecordingService, v as FACE_ERROR_CODES } from "./recordingService-BDx_6XR9.esm.js";
|
|
5
|
+
import { n as requestPermission, t as checkPermission } from "./permissionServices-CDqkkway.esm.js";
|
|
6
|
+
|
|
7
|
+
//#region src/internal/faceCapture/faceCaptureManagerFactory.ts
|
|
8
|
+
function getPermissionStatus(snapshot) {
|
|
9
|
+
if (!snapshot.matches("permissions")) return;
|
|
10
|
+
if (snapshot.matches({ permissions: "idle" })) return "idle";
|
|
11
|
+
if (snapshot.matches({ permissions: "learnMore" })) return "learnMore";
|
|
12
|
+
if (snapshot.matches({ permissions: "requesting" })) return "requesting";
|
|
13
|
+
if (snapshot.matches({ permissions: "denied" })) return "denied";
|
|
14
|
+
}
|
|
15
|
+
function getCaptureStatus(snapshot) {
|
|
16
|
+
if (snapshot.matches({ capture: "initializing" })) return "initializing";
|
|
17
|
+
if (snapshot.matches({ capture: "detecting" })) return "detecting";
|
|
18
|
+
if (snapshot.matches({ capture: "capturing" })) return "capturing";
|
|
19
|
+
if (snapshot.matches({ capture: "capturingManual" })) return "capturing";
|
|
20
|
+
if (snapshot.matches({ capture: "uploading" })) return "uploading";
|
|
21
|
+
if (snapshot.matches({ capture: "uploadError" })) return "uploadError";
|
|
22
|
+
if (snapshot.matches({ capture: "success" })) return "success";
|
|
23
|
+
}
|
|
24
|
+
function mapState(snapshot) {
|
|
25
|
+
const { context } = snapshot;
|
|
26
|
+
if (snapshot.matches("idle")) return { status: "idle" };
|
|
27
|
+
if (snapshot.matches("loading")) return { status: "loading" };
|
|
28
|
+
if (snapshot.matches("tutorial")) return { status: "tutorial" };
|
|
29
|
+
if (snapshot.matches("closed")) return { status: "closed" };
|
|
30
|
+
if (snapshot.matches("permissions")) {
|
|
31
|
+
const permissionStatus = getPermissionStatus(snapshot);
|
|
32
|
+
if (permissionStatus === void 0) return {
|
|
33
|
+
status: "permissions",
|
|
34
|
+
permissionStatus: "idle"
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
status: "permissions",
|
|
38
|
+
permissionStatus
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (snapshot.matches("capture")) return {
|
|
42
|
+
status: "capture",
|
|
43
|
+
captureStatus: getCaptureStatus(snapshot) ?? "initializing",
|
|
44
|
+
stream: context.stream,
|
|
45
|
+
detectionStatus: context.detectionStatus ?? "idle",
|
|
46
|
+
debugFrame: context.debugFrame,
|
|
47
|
+
attemptsRemaining: context.attemptsRemaining ?? 0,
|
|
48
|
+
uploadError: context.uploadError,
|
|
49
|
+
assistedOnboarding: context.config?.assistedOnboarding ?? false
|
|
50
|
+
};
|
|
51
|
+
if (snapshot.matches("processing")) return { status: "processing" };
|
|
52
|
+
if (snapshot.matches("finished")) return {
|
|
53
|
+
status: "finished",
|
|
54
|
+
processResponse: context.processResponse
|
|
55
|
+
};
|
|
56
|
+
if (snapshot.matches("error")) {
|
|
57
|
+
const errorValue = context.error;
|
|
58
|
+
return {
|
|
59
|
+
status: "error",
|
|
60
|
+
error: typeof errorValue === "string" ? errorValue : errorValue ? errorValue.message : "Unknown error"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return { status: "idle" };
|
|
64
|
+
}
|
|
65
|
+
function createApi({ actor, trackElementClicked, trackCaptureAttemptFinished }) {
|
|
66
|
+
const snapshot = actor.getSnapshot();
|
|
67
|
+
snapshot.context.dependencies.trackCaptureAttemptFinished = trackCaptureAttemptFinished;
|
|
68
|
+
return {
|
|
69
|
+
load() {
|
|
70
|
+
actor.send({ type: "LOAD" });
|
|
71
|
+
},
|
|
72
|
+
nextStep() {
|
|
73
|
+
trackElementClicked?.("nextStep");
|
|
74
|
+
actor.send({ type: "NEXT_STEP" });
|
|
75
|
+
},
|
|
76
|
+
requestPermission() {
|
|
77
|
+
trackElementClicked?.("requestPermission");
|
|
78
|
+
actor.send({ type: "REQUEST_PERMISSION" });
|
|
79
|
+
},
|
|
80
|
+
goToLearnMore() {
|
|
81
|
+
trackElementClicked?.("goToLearnMore");
|
|
82
|
+
actor.send({ type: "GO_TO_LEARN_MORE" });
|
|
83
|
+
},
|
|
84
|
+
back() {
|
|
85
|
+
trackElementClicked?.("back");
|
|
86
|
+
actor.send({ type: "BACK" });
|
|
87
|
+
},
|
|
88
|
+
close() {
|
|
89
|
+
trackElementClicked?.("close");
|
|
90
|
+
actor.send({ type: "QUIT" });
|
|
91
|
+
},
|
|
92
|
+
reset() {
|
|
93
|
+
actor.send({ type: "RESET" });
|
|
94
|
+
},
|
|
95
|
+
retryCapture() {
|
|
96
|
+
trackElementClicked?.("retryCapture");
|
|
97
|
+
actor.send({ type: "RETRY_CAPTURE" });
|
|
98
|
+
},
|
|
99
|
+
capture() {
|
|
100
|
+
trackElementClicked?.("capture");
|
|
101
|
+
actor.send({ type: "MANUAL_CAPTURE" });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function getFaceCaptureErrorPayload(snapshot) {
|
|
106
|
+
const errorCode = snapshot.context.uploadError;
|
|
107
|
+
if (typeof errorCode !== "string" || errorCode.length === 0) return;
|
|
108
|
+
return { errorCode };
|
|
109
|
+
}
|
|
110
|
+
function createFaceCaptureManagerFromActor(actor, moduleName) {
|
|
111
|
+
return createManager({
|
|
112
|
+
actor,
|
|
113
|
+
mapState,
|
|
114
|
+
createApi,
|
|
115
|
+
instrumentation: createManagerInstrumentation(moduleName, { getErrorPayload: getFaceCaptureErrorPayload })
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/internal/faceCapture/faceCaptureSetup.ts
|
|
121
|
+
const getAttemptsFromConfig = (config) => {
|
|
122
|
+
return config.captureAttempts ?? config.numberOfAttempts ?? 3;
|
|
123
|
+
};
|
|
124
|
+
const _faceCaptureMachine = setup({
|
|
125
|
+
types: {
|
|
126
|
+
context: {},
|
|
127
|
+
events: {},
|
|
128
|
+
input: {}
|
|
129
|
+
},
|
|
130
|
+
actors: {
|
|
131
|
+
checkPermission: fromPromise(async () => {
|
|
132
|
+
return checkPermission();
|
|
133
|
+
}),
|
|
134
|
+
requestPermission: fromPromise(async () => {
|
|
135
|
+
return requestPermission();
|
|
136
|
+
}),
|
|
137
|
+
initializeCamera: fromPromise(async ({ input }) => {
|
|
138
|
+
return initializeCamera({
|
|
139
|
+
config: input.config,
|
|
140
|
+
deepsightService: input.deepsightService
|
|
141
|
+
});
|
|
142
|
+
}),
|
|
143
|
+
runDetection: fromCallback(({ input, sendBack }) => {
|
|
144
|
+
if (!input.frameCapturer || !input.provider) {
|
|
145
|
+
sendBack({
|
|
146
|
+
type: "DETECTION_UPDATE",
|
|
147
|
+
status: "error"
|
|
148
|
+
});
|
|
149
|
+
return () => {};
|
|
150
|
+
}
|
|
151
|
+
if (input.manualCaptureTriggered) {
|
|
152
|
+
sendBack({
|
|
153
|
+
type: "DETECTION_UPDATE",
|
|
154
|
+
status: "manualCapture"
|
|
155
|
+
});
|
|
156
|
+
return () => {};
|
|
157
|
+
}
|
|
158
|
+
const { cleanup, reset } = startDetection({
|
|
159
|
+
config: input.config,
|
|
160
|
+
capturer: input.frameCapturer,
|
|
161
|
+
onUpdate: (status) => sendBack({
|
|
162
|
+
type: "DETECTION_UPDATE",
|
|
163
|
+
status
|
|
164
|
+
}),
|
|
165
|
+
onFrame: (frame) => sendBack({
|
|
166
|
+
type: "DETECTION_FRAME",
|
|
167
|
+
frame
|
|
168
|
+
}),
|
|
169
|
+
onSuccess: (canvas, faceCoordinates) => sendBack({
|
|
170
|
+
type: "DETECTION_SUCCESS",
|
|
171
|
+
canvas,
|
|
172
|
+
faceCoordinates
|
|
173
|
+
}),
|
|
174
|
+
provider: input.provider
|
|
175
|
+
});
|
|
176
|
+
sendBack({
|
|
177
|
+
type: "DETECTION_RESET_READY",
|
|
178
|
+
reset
|
|
179
|
+
});
|
|
180
|
+
return cleanup;
|
|
181
|
+
}),
|
|
182
|
+
initializeDeepsightSession: fromPromise(async ({ input }) => {
|
|
183
|
+
return await initializeDeepsightSession({
|
|
184
|
+
ds: input.ds,
|
|
185
|
+
storage: input.storage
|
|
186
|
+
});
|
|
187
|
+
}),
|
|
188
|
+
startRecording: fromPromise(async ({ input }) => {
|
|
189
|
+
if (!input.stream) return input.recordingService;
|
|
190
|
+
const wasmUtil = await input.dependencies.getWasmUtil();
|
|
191
|
+
const sessionToken = getToken();
|
|
192
|
+
const service = input.recordingService ?? createRecordingService({
|
|
193
|
+
config: input.config,
|
|
194
|
+
wasmUtil,
|
|
195
|
+
sessionToken
|
|
196
|
+
});
|
|
197
|
+
if (service) await service.start(input.stream);
|
|
198
|
+
return service;
|
|
199
|
+
}),
|
|
200
|
+
checkVirtualCamera: fromPromise(async ({ input }) => {
|
|
201
|
+
if (!input.deepsightService || !input.stream) return false;
|
|
202
|
+
const videoTrack = input.stream.getVideoTracks()[0];
|
|
203
|
+
if (!videoTrack) return false;
|
|
204
|
+
return input.deepsightService.checkVirtualCamera(videoTrack);
|
|
205
|
+
}),
|
|
206
|
+
prepareFaceUpload: fromPromise(async ({ input }) => {
|
|
207
|
+
const ctx = input;
|
|
208
|
+
const sessionToken = getToken();
|
|
209
|
+
const recordingId = (await ctx.recordingService?.stop())?.recordingId ?? null;
|
|
210
|
+
try {
|
|
211
|
+
if (ctx.deepsightService) await Promise.all([ctx.deepsightService.performVirtualCameraCheck(sessionToken, "SELFIE"), ctx.deepsightService.analyzeFrame(ctx.capturedImage.getImageData())]);
|
|
212
|
+
} catch (error) {}
|
|
213
|
+
const logs = ctx.deepsightService?.getPipelineState() ?? "";
|
|
214
|
+
ctx.dependencies.trackCaptureAttemptFinished?.({ logs });
|
|
215
|
+
return {
|
|
216
|
+
encryptedBase64Image: await encryptSelfieImage({
|
|
217
|
+
canvas: ctx.capturedImage,
|
|
218
|
+
dependencies: ctx.dependencies
|
|
219
|
+
}),
|
|
220
|
+
recordingId
|
|
221
|
+
};
|
|
222
|
+
}),
|
|
223
|
+
uploadFace: fromPromise(async () => {
|
|
224
|
+
throw new Error("uploadFace must be provided by variant");
|
|
225
|
+
}),
|
|
226
|
+
processFace: fromPromise(async () => {
|
|
227
|
+
throw new Error("processFace must be provided by variant");
|
|
228
|
+
})
|
|
229
|
+
},
|
|
230
|
+
actions: {
|
|
231
|
+
stopMediaStream: assign(({ context }) => {
|
|
232
|
+
context.frameCapturer?.dispose();
|
|
233
|
+
if (context.stream) stopStream(context.stream);
|
|
234
|
+
context.provider?.dispose();
|
|
235
|
+
return {
|
|
236
|
+
stream: void 0,
|
|
237
|
+
provider: void 0,
|
|
238
|
+
frameCapturer: void 0
|
|
239
|
+
};
|
|
240
|
+
}),
|
|
241
|
+
setStreamAndCapturer: assign({
|
|
242
|
+
stream: ({ event }) => {
|
|
243
|
+
if ("output" in event) return event.output.stream;
|
|
244
|
+
},
|
|
245
|
+
provider: ({ event }) => {
|
|
246
|
+
if ("output" in event) return event.output.provider;
|
|
247
|
+
},
|
|
248
|
+
frameCapturer: ({ event }) => {
|
|
249
|
+
if ("output" in event) return new StreamCanvasCapture(event.output.stream);
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
trackTutorial: () => void 0,
|
|
253
|
+
trackContinue: () => {},
|
|
254
|
+
resetContext: assign(({ context }) => ({
|
|
255
|
+
stream: void 0,
|
|
256
|
+
provider: void 0,
|
|
257
|
+
frameCapturer: void 0,
|
|
258
|
+
error: void 0,
|
|
259
|
+
detectionStatus: "idle",
|
|
260
|
+
debugFrame: void 0,
|
|
261
|
+
capturedImage: void 0,
|
|
262
|
+
faceCoordinates: void 0,
|
|
263
|
+
uploadResponse: void 0,
|
|
264
|
+
processResponse: void 0,
|
|
265
|
+
recordingService: void 0,
|
|
266
|
+
attemptsRemaining: getAttemptsFromConfig(context.config),
|
|
267
|
+
uploadError: void 0,
|
|
268
|
+
permissionResult: void 0,
|
|
269
|
+
resetDetection: void 0,
|
|
270
|
+
deepsightService: void 0,
|
|
271
|
+
manualCaptureTriggered: false
|
|
272
|
+
})),
|
|
273
|
+
resetDetection: ({ context }) => {
|
|
274
|
+
context.resetDetection?.();
|
|
275
|
+
},
|
|
276
|
+
captureImage: assign({ capturedImage: ({ context }) => {
|
|
277
|
+
if (context.capturedImage) return context.capturedImage;
|
|
278
|
+
return context.frameCapturer?.getLatestCanvas() ?? void 0;
|
|
279
|
+
} }),
|
|
280
|
+
captureLatestFrame: assign({ capturedImage: ({ context }) => {
|
|
281
|
+
return context.frameCapturer?.getLatestCanvas() ?? void 0;
|
|
282
|
+
} }),
|
|
283
|
+
clearUploadFailure: assign({
|
|
284
|
+
uploadError: () => void 0,
|
|
285
|
+
detectionStatus: () => "idle",
|
|
286
|
+
capturedImage: () => void 0
|
|
287
|
+
}),
|
|
288
|
+
clearStreamForRetry: assign(({ context }) => {
|
|
289
|
+
context.frameCapturer?.dispose();
|
|
290
|
+
if (context.stream) stopStream(context.stream);
|
|
291
|
+
context.provider?.dispose();
|
|
292
|
+
return {
|
|
293
|
+
stream: void 0,
|
|
294
|
+
provider: void 0,
|
|
295
|
+
frameCapturer: void 0
|
|
296
|
+
};
|
|
297
|
+
}),
|
|
298
|
+
decrementAttemptsRemaining: assign(({ context }) => ({ attemptsRemaining: context.attemptsRemaining - 1 })),
|
|
299
|
+
setUploadErrorFromUploadValidation: assign({ uploadError: () => FACE_ERROR_CODES.SERVER }),
|
|
300
|
+
setTerminalError: assign({ error: () => "Authentication failed" }),
|
|
301
|
+
clearRecordingService: assign({ recordingService: () => void 0 }),
|
|
302
|
+
cleanup: ({ context }) => {
|
|
303
|
+
context.deepsightService?.cleanup();
|
|
304
|
+
context.recordingService?.cleanup();
|
|
305
|
+
},
|
|
306
|
+
setPermissionResultFromEvent: assign({ permissionResult: ({ event }) => event.output }),
|
|
307
|
+
setPermissionDenied: assign({ permissionResult: () => "denied" }),
|
|
308
|
+
setPermissionRefresh: assign({ permissionResult: () => "refresh" }),
|
|
309
|
+
setDeepsightServiceFromEvent: assign({ deepsightService: ({ event }) => event.output }),
|
|
310
|
+
setErrorFromEvent: assign({ error: ({ event }) => String(event.error) }),
|
|
311
|
+
setDetectionStatusDetecting: assign({ detectionStatus: ({ context }) => context.manualCaptureTriggered ? "manualCapture" : "detecting" }),
|
|
312
|
+
setRecordingServiceFromEvent: assign({ recordingService: ({ context, event }) => {
|
|
313
|
+
return event.output ?? context.recordingService;
|
|
314
|
+
} }),
|
|
315
|
+
setDetectionStatusFromEvent: assign({ detectionStatus: ({ event }) => event.status }),
|
|
316
|
+
setManualCaptureTriggered: assign({ manualCaptureTriggered: ({ context, event }) => {
|
|
317
|
+
const status = event.status;
|
|
318
|
+
return context.manualCaptureTriggered || status === "manualCapture";
|
|
319
|
+
} }),
|
|
320
|
+
setDebugFrameFromEvent: assign({ debugFrame: ({ event }) => event.frame }),
|
|
321
|
+
setResetDetectionFromEvent: assign({ resetDetection: ({ event }) => event.reset }),
|
|
322
|
+
setCapturedImageFromEvent: assign({
|
|
323
|
+
capturedImage: ({ event }) => event.canvas,
|
|
324
|
+
faceCoordinates: ({ event }) => event.faceCoordinates
|
|
325
|
+
}),
|
|
326
|
+
setUploadPreparationFromEvent: assign({
|
|
327
|
+
encryptedBase64Image: ({ event }) => event.output.encryptedBase64Image,
|
|
328
|
+
uploadRecordingId: ({ event }) => event.output.recordingId
|
|
329
|
+
}),
|
|
330
|
+
setUploadResponseFromEvent: assign({ uploadResponse: ({ event }) => event.output }),
|
|
331
|
+
setProcessResponseFromEvent: assign({ processResponse: ({ event }) => event.output }),
|
|
332
|
+
setServerErrorAndDecrement: assign(({ context }) => ({
|
|
333
|
+
uploadError: FACE_ERROR_CODES.SERVER,
|
|
334
|
+
attemptsRemaining: context.attemptsRemaining - 1
|
|
335
|
+
})),
|
|
336
|
+
sendLabelInspection: () => {
|
|
337
|
+
sendLabelInspectionEvent();
|
|
338
|
+
},
|
|
339
|
+
flagFaceManualReview: () => {
|
|
340
|
+
flagFaceManualReview();
|
|
341
|
+
},
|
|
342
|
+
preloadRecordingProvider: ({ context }) => {
|
|
343
|
+
if (context.config.enableFaceRecording === true && context.config.deepsightLiveness !== "VIDEOLIVENESS") preloadOpenViduProvider();
|
|
344
|
+
},
|
|
345
|
+
noOp: () => void 0
|
|
346
|
+
},
|
|
347
|
+
guards: {
|
|
348
|
+
hasShowTutorial: ({ context }) => context.config.showTutorial,
|
|
349
|
+
isPermissionGranted: ({ event }) => {
|
|
350
|
+
if ("output" in event) return event.output === "granted";
|
|
351
|
+
return false;
|
|
352
|
+
},
|
|
353
|
+
isPermissionDeniedError: ({ event }) => {
|
|
354
|
+
if ("error" in event) {
|
|
355
|
+
const error = event.error;
|
|
356
|
+
return error?.name === "NotAllowedError" || error?.name === "PermissionDeniedError";
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
},
|
|
360
|
+
hasStream: ({ context }) => context.stream !== void 0,
|
|
361
|
+
isCameraAndDeepsightReady: ({ context }) => context.stream !== void 0 && context.deepsightService !== void 0,
|
|
362
|
+
hasAttemptsRemaining: ({ context }) => context.attemptsRemaining > 0,
|
|
363
|
+
hasCapturedImage: ({ context }) => context.capturedImage !== void 0,
|
|
364
|
+
hasUploadValidationError: () => false,
|
|
365
|
+
isTerminalUploadError: () => false,
|
|
366
|
+
isNoAttemptsTerminal: () => false
|
|
367
|
+
}
|
|
368
|
+
}).createMachine({
|
|
369
|
+
id: "faceCapture",
|
|
370
|
+
initial: "idle",
|
|
371
|
+
context: ({ input }) => ({
|
|
372
|
+
config: input.config,
|
|
373
|
+
dependencies: input.dependencies,
|
|
374
|
+
authHint: input.authHint,
|
|
375
|
+
stream: void 0,
|
|
376
|
+
provider: void 0,
|
|
377
|
+
frameCapturer: void 0,
|
|
378
|
+
error: void 0,
|
|
379
|
+
detectionStatus: "idle",
|
|
380
|
+
debugFrame: void 0,
|
|
381
|
+
capturedImage: void 0,
|
|
382
|
+
faceCoordinates: void 0,
|
|
383
|
+
uploadResponse: void 0,
|
|
384
|
+
processResponse: void 0,
|
|
385
|
+
recordingService: void 0,
|
|
386
|
+
attemptsRemaining: getAttemptsFromConfig(input.config),
|
|
387
|
+
uploadError: void 0,
|
|
388
|
+
permissionResult: void 0,
|
|
389
|
+
resetDetection: void 0,
|
|
390
|
+
deepsightService: void 0,
|
|
391
|
+
encryptedBase64Image: void 0,
|
|
392
|
+
uploadRecordingId: void 0,
|
|
393
|
+
manualCaptureTriggered: false
|
|
394
|
+
}),
|
|
395
|
+
on: { QUIT: { target: "#faceCapture.closed" } },
|
|
396
|
+
states: {
|
|
397
|
+
idle: { on: { LOAD: [{
|
|
398
|
+
target: "tutorial",
|
|
399
|
+
guard: "hasShowTutorial"
|
|
400
|
+
}, { target: "loading" }] } },
|
|
401
|
+
loading: {
|
|
402
|
+
entry: "preloadRecordingProvider",
|
|
403
|
+
invoke: [{
|
|
404
|
+
id: "checkPermissionLoading",
|
|
405
|
+
src: "checkPermission",
|
|
406
|
+
onDone: [{
|
|
407
|
+
target: "capture",
|
|
408
|
+
guard: "isPermissionGranted",
|
|
409
|
+
actions: "setPermissionResultFromEvent"
|
|
410
|
+
}, {
|
|
411
|
+
target: "permissions",
|
|
412
|
+
actions: "setPermissionResultFromEvent"
|
|
413
|
+
}]
|
|
414
|
+
}, {
|
|
415
|
+
id: "loadingInitDeepsight",
|
|
416
|
+
src: "initializeDeepsightSession",
|
|
417
|
+
input: ({ context }) => ({
|
|
418
|
+
ds: context.config.ds,
|
|
419
|
+
storage: context.dependencies.storage
|
|
420
|
+
}),
|
|
421
|
+
onDone: { actions: "setDeepsightServiceFromEvent" },
|
|
422
|
+
onError: { actions: "noOp" }
|
|
423
|
+
}]
|
|
424
|
+
},
|
|
425
|
+
tutorial: {
|
|
426
|
+
initial: "checkingPermission",
|
|
427
|
+
entry: ["trackTutorial", "preloadRecordingProvider"],
|
|
428
|
+
states: {
|
|
429
|
+
checkingPermission: { invoke: {
|
|
430
|
+
id: "checkPermissionTutorial",
|
|
431
|
+
src: "checkPermission",
|
|
432
|
+
onDone: [{
|
|
433
|
+
target: "initializingCamera",
|
|
434
|
+
guard: "isPermissionGranted",
|
|
435
|
+
actions: "setPermissionResultFromEvent"
|
|
436
|
+
}, {
|
|
437
|
+
target: "ready",
|
|
438
|
+
actions: "setPermissionResultFromEvent"
|
|
439
|
+
}]
|
|
440
|
+
} },
|
|
441
|
+
initializingCamera: {
|
|
442
|
+
type: "parallel",
|
|
443
|
+
states: {
|
|
444
|
+
cameraInit: {
|
|
445
|
+
initial: "initializingDeepsight",
|
|
446
|
+
states: {
|
|
447
|
+
initializingDeepsight: { invoke: {
|
|
448
|
+
id: "tutorialInitDeepsight",
|
|
449
|
+
src: "initializeDeepsightSession",
|
|
450
|
+
input: ({ context }) => ({
|
|
451
|
+
ds: context.config.ds,
|
|
452
|
+
storage: context.dependencies.storage
|
|
453
|
+
}),
|
|
454
|
+
onDone: {
|
|
455
|
+
target: "initializingStream",
|
|
456
|
+
actions: "setDeepsightServiceFromEvent"
|
|
457
|
+
},
|
|
458
|
+
onError: { target: "#faceCapture.tutorial.ready" }
|
|
459
|
+
} },
|
|
460
|
+
initializingStream: { invoke: {
|
|
461
|
+
id: "tutorialInitCamera",
|
|
462
|
+
src: "initializeCamera",
|
|
463
|
+
input: ({ context }) => ({
|
|
464
|
+
config: context.config,
|
|
465
|
+
dependencies: context.dependencies,
|
|
466
|
+
deepsightService: context.deepsightService
|
|
467
|
+
}),
|
|
468
|
+
onDone: {
|
|
469
|
+
target: "ready",
|
|
470
|
+
actions: "setStreamAndCapturer"
|
|
471
|
+
},
|
|
472
|
+
onError: [{
|
|
473
|
+
target: "#faceCapture.tutorial.ready",
|
|
474
|
+
guard: "isPermissionDeniedError",
|
|
475
|
+
actions: "setPermissionDenied"
|
|
476
|
+
}, {
|
|
477
|
+
target: "#faceCapture.tutorial.ready",
|
|
478
|
+
actions: "setErrorFromEvent"
|
|
479
|
+
}]
|
|
480
|
+
} },
|
|
481
|
+
ready: { type: "final" }
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
userIntent: {
|
|
485
|
+
initial: "waiting",
|
|
486
|
+
states: {
|
|
487
|
+
waiting: { on: { NEXT_STEP: {
|
|
488
|
+
target: "clicked",
|
|
489
|
+
actions: "trackContinue"
|
|
490
|
+
} } },
|
|
491
|
+
clicked: { type: "final" }
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
onDone: { target: "#faceCapture.capture" }
|
|
496
|
+
},
|
|
497
|
+
ready: {
|
|
498
|
+
initial: "idle",
|
|
499
|
+
states: {
|
|
500
|
+
idle: { always: [{
|
|
501
|
+
target: "initializingDeepsight",
|
|
502
|
+
guard: ({ context }) => context.deepsightService === void 0
|
|
503
|
+
}, { target: "readyForNext" }] },
|
|
504
|
+
initializingDeepsight: { invoke: {
|
|
505
|
+
id: "initializeDeepsightTutorial",
|
|
506
|
+
src: "initializeDeepsightSession",
|
|
507
|
+
input: ({ context }) => ({
|
|
508
|
+
ds: context.config.ds,
|
|
509
|
+
storage: context.dependencies.storage
|
|
510
|
+
}),
|
|
511
|
+
onDone: {
|
|
512
|
+
target: "readyForNext",
|
|
513
|
+
actions: "setDeepsightServiceFromEvent"
|
|
514
|
+
},
|
|
515
|
+
onError: { target: "readyForNext" }
|
|
516
|
+
} },
|
|
517
|
+
readyForNext: { on: { NEXT_STEP: {
|
|
518
|
+
target: "#faceCapture.tutorial.waitingForPermission",
|
|
519
|
+
actions: "trackContinue"
|
|
520
|
+
} } }
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
waitingForPermission: { invoke: {
|
|
524
|
+
id: "checkPermissionWaiting",
|
|
525
|
+
src: "checkPermission",
|
|
526
|
+
onDone: [{
|
|
527
|
+
target: "#faceCapture.capture",
|
|
528
|
+
guard: "isPermissionGranted",
|
|
529
|
+
actions: "setPermissionResultFromEvent"
|
|
530
|
+
}, {
|
|
531
|
+
target: "#faceCapture.permissions",
|
|
532
|
+
actions: "setPermissionResultFromEvent"
|
|
533
|
+
}]
|
|
534
|
+
} }
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
permissions: {
|
|
538
|
+
entry: "preloadRecordingProvider",
|
|
539
|
+
initial: "checkingDeepsight",
|
|
540
|
+
states: {
|
|
541
|
+
checkingDeepsight: { always: [{
|
|
542
|
+
target: "initializingDeepsight",
|
|
543
|
+
guard: ({ context }) => context.deepsightService === void 0
|
|
544
|
+
}, { target: "idle" }] },
|
|
545
|
+
initializingDeepsight: { invoke: {
|
|
546
|
+
id: "initializeDeepsightPerms",
|
|
547
|
+
src: "initializeDeepsightSession",
|
|
548
|
+
input: ({ context }) => ({
|
|
549
|
+
ds: context.config.ds,
|
|
550
|
+
storage: context.dependencies.storage
|
|
551
|
+
}),
|
|
552
|
+
onDone: {
|
|
553
|
+
target: "idle",
|
|
554
|
+
actions: "setDeepsightServiceFromEvent"
|
|
555
|
+
},
|
|
556
|
+
onError: { target: "idle" }
|
|
557
|
+
} },
|
|
558
|
+
idle: {
|
|
559
|
+
invoke: {
|
|
560
|
+
id: "checkPermissionIdle",
|
|
561
|
+
src: "checkPermission",
|
|
562
|
+
onDone: [{
|
|
563
|
+
target: "#faceCapture.capture",
|
|
564
|
+
guard: "isPermissionGranted",
|
|
565
|
+
actions: "setPermissionResultFromEvent"
|
|
566
|
+
}, {
|
|
567
|
+
target: "denied",
|
|
568
|
+
guard: ({ event }) => event.output === "denied",
|
|
569
|
+
actions: "setPermissionResultFromEvent"
|
|
570
|
+
}]
|
|
571
|
+
},
|
|
572
|
+
on: {
|
|
573
|
+
REQUEST_PERMISSION: "requesting",
|
|
574
|
+
GO_TO_LEARN_MORE: "learnMore"
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
learnMore: { on: {
|
|
578
|
+
BACK: "idle",
|
|
579
|
+
REQUEST_PERMISSION: "requesting"
|
|
580
|
+
} },
|
|
581
|
+
requesting: { invoke: {
|
|
582
|
+
id: "requestPermission",
|
|
583
|
+
src: "requestPermission",
|
|
584
|
+
onDone: [
|
|
585
|
+
{
|
|
586
|
+
target: "#faceCapture.capture",
|
|
587
|
+
guard: "isPermissionGranted",
|
|
588
|
+
actions: "setPermissionResultFromEvent"
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
target: "denied",
|
|
592
|
+
guard: ({ event }) => event.output === "denied",
|
|
593
|
+
actions: "setPermissionResultFromEvent"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
target: "idle",
|
|
597
|
+
actions: "setPermissionResultFromEvent"
|
|
598
|
+
}
|
|
599
|
+
],
|
|
600
|
+
onError: { target: "denied" }
|
|
601
|
+
} },
|
|
602
|
+
denied: { entry: "setPermissionRefresh" }
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
capture: {
|
|
606
|
+
entry: "preloadRecordingProvider",
|
|
607
|
+
initial: "checkingDeepsight",
|
|
608
|
+
exit: [
|
|
609
|
+
"stopMediaStream",
|
|
610
|
+
"cleanup",
|
|
611
|
+
"clearRecordingService"
|
|
612
|
+
],
|
|
613
|
+
states: {
|
|
614
|
+
checkingDeepsight: { always: [{
|
|
615
|
+
target: "initializingDeepsight",
|
|
616
|
+
guard: ({ context }) => context.deepsightService === void 0
|
|
617
|
+
}, { target: "checkingStream" }] },
|
|
618
|
+
initializingDeepsight: { invoke: {
|
|
619
|
+
id: "initializeDeepsightCapture",
|
|
620
|
+
src: "initializeDeepsightSession",
|
|
621
|
+
input: ({ context }) => ({
|
|
622
|
+
ds: context.config.ds,
|
|
623
|
+
storage: context.dependencies.storage
|
|
624
|
+
}),
|
|
625
|
+
onDone: {
|
|
626
|
+
target: "checkingStream",
|
|
627
|
+
actions: ["setDeepsightServiceFromEvent"]
|
|
628
|
+
},
|
|
629
|
+
onError: { target: "#faceCapture.permissions" }
|
|
630
|
+
} },
|
|
631
|
+
checkingStream: { always: [
|
|
632
|
+
{
|
|
633
|
+
target: "initializingDeepsight",
|
|
634
|
+
guard: ({ context }) => context.deepsightService === void 0
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
target: "detecting",
|
|
638
|
+
guard: "hasStream"
|
|
639
|
+
},
|
|
640
|
+
{ target: "initializing" }
|
|
641
|
+
] },
|
|
642
|
+
initializing: { invoke: {
|
|
643
|
+
id: "initializeCamera",
|
|
644
|
+
src: "initializeCamera",
|
|
645
|
+
input: ({ context }) => ({
|
|
646
|
+
config: context.config,
|
|
647
|
+
dependencies: context.dependencies,
|
|
648
|
+
deepsightService: context.deepsightService
|
|
649
|
+
}),
|
|
650
|
+
onDone: {
|
|
651
|
+
target: "detecting",
|
|
652
|
+
actions: ["setStreamAndCapturer"]
|
|
653
|
+
},
|
|
654
|
+
onError: [{
|
|
655
|
+
target: "#faceCapture.permissions",
|
|
656
|
+
guard: "isPermissionDeniedError",
|
|
657
|
+
actions: "setPermissionDenied"
|
|
658
|
+
}, {
|
|
659
|
+
target: "#faceCapture.error",
|
|
660
|
+
actions: "setErrorFromEvent"
|
|
661
|
+
}]
|
|
662
|
+
} },
|
|
663
|
+
detecting: {
|
|
664
|
+
entry: ["setDetectionStatusDetecting"],
|
|
665
|
+
invoke: [
|
|
666
|
+
{
|
|
667
|
+
id: "checkVirtualCamera",
|
|
668
|
+
src: "checkVirtualCamera",
|
|
669
|
+
input: ({ context }) => ({
|
|
670
|
+
stream: context.stream,
|
|
671
|
+
deepsightService: context.deepsightService
|
|
672
|
+
}),
|
|
673
|
+
onDone: [{
|
|
674
|
+
target: "#faceCapture.processing",
|
|
675
|
+
guard: ({ event }) => event.output === true,
|
|
676
|
+
actions: "sendLabelInspection"
|
|
677
|
+
}],
|
|
678
|
+
onError: { actions: "noOp" }
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
id: "startRecording",
|
|
682
|
+
src: "startRecording",
|
|
683
|
+
input: ({ context }) => ({
|
|
684
|
+
config: context.config,
|
|
685
|
+
dependencies: context.dependencies,
|
|
686
|
+
recordingService: context.recordingService,
|
|
687
|
+
stream: context.stream
|
|
688
|
+
}),
|
|
689
|
+
onDone: { actions: "setRecordingServiceFromEvent" },
|
|
690
|
+
onError: { actions: "noOp" }
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
id: "runDetection",
|
|
694
|
+
src: "runDetection",
|
|
695
|
+
input: ({ context }) => ({
|
|
696
|
+
frameCapturer: context.frameCapturer,
|
|
697
|
+
provider: context.provider,
|
|
698
|
+
config: context.config,
|
|
699
|
+
manualCaptureTriggered: context.manualCaptureTriggered
|
|
700
|
+
})
|
|
701
|
+
}
|
|
702
|
+
],
|
|
703
|
+
on: {
|
|
704
|
+
DETECTION_UPDATE: { actions: ["setDetectionStatusFromEvent", "setManualCaptureTriggered"] },
|
|
705
|
+
DETECTION_FRAME: { actions: "setDebugFrameFromEvent" },
|
|
706
|
+
DETECTION_RESET_READY: { actions: "setResetDetectionFromEvent" },
|
|
707
|
+
DETECTION_SUCCESS: {
|
|
708
|
+
target: "capturing",
|
|
709
|
+
actions: "setCapturedImageFromEvent"
|
|
710
|
+
},
|
|
711
|
+
MANUAL_CAPTURE: { target: "capturingManual" }
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
capturing: {
|
|
715
|
+
entry: ["captureImage"],
|
|
716
|
+
always: [{
|
|
717
|
+
target: "preparingUpload",
|
|
718
|
+
guard: "hasCapturedImage"
|
|
719
|
+
}, {
|
|
720
|
+
target: "uploadError",
|
|
721
|
+
actions: "setServerErrorAndDecrement"
|
|
722
|
+
}]
|
|
723
|
+
},
|
|
724
|
+
capturingManual: {
|
|
725
|
+
entry: ["captureLatestFrame"],
|
|
726
|
+
always: [{
|
|
727
|
+
target: "preparingUpload",
|
|
728
|
+
guard: "hasCapturedImage"
|
|
729
|
+
}, {
|
|
730
|
+
target: "uploadError",
|
|
731
|
+
actions: "setServerErrorAndDecrement"
|
|
732
|
+
}]
|
|
733
|
+
},
|
|
734
|
+
preparingUpload: { invoke: {
|
|
735
|
+
id: "prepareFaceUpload",
|
|
736
|
+
src: "prepareFaceUpload",
|
|
737
|
+
input: ({ context }) => context,
|
|
738
|
+
onDone: {
|
|
739
|
+
target: "uploading",
|
|
740
|
+
actions: "setUploadPreparationFromEvent"
|
|
741
|
+
},
|
|
742
|
+
onError: {
|
|
743
|
+
target: "uploadError",
|
|
744
|
+
actions: "setServerErrorAndDecrement"
|
|
745
|
+
}
|
|
746
|
+
} },
|
|
747
|
+
uploading: { invoke: {
|
|
748
|
+
id: "uploadFace",
|
|
749
|
+
src: "uploadFace",
|
|
750
|
+
input: ({ context }) => context,
|
|
751
|
+
onDone: {
|
|
752
|
+
target: "validatingUpload",
|
|
753
|
+
actions: "setUploadResponseFromEvent"
|
|
754
|
+
},
|
|
755
|
+
onError: {
|
|
756
|
+
target: "uploadError",
|
|
757
|
+
actions: "setServerErrorAndDecrement"
|
|
758
|
+
}
|
|
759
|
+
} },
|
|
760
|
+
validatingUpload: { always: [
|
|
761
|
+
{
|
|
762
|
+
target: "#faceCapture.error",
|
|
763
|
+
guard: "isTerminalUploadError",
|
|
764
|
+
actions: "setTerminalError"
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
target: "uploadError",
|
|
768
|
+
guard: "hasUploadValidationError",
|
|
769
|
+
actions: ["setUploadErrorFromUploadValidation", "decrementAttemptsRemaining"]
|
|
770
|
+
},
|
|
771
|
+
{ target: "success" }
|
|
772
|
+
] },
|
|
773
|
+
uploadError: { on: { RETRY_CAPTURE: [
|
|
774
|
+
{
|
|
775
|
+
target: "checkingStream",
|
|
776
|
+
guard: "hasAttemptsRemaining",
|
|
777
|
+
actions: [
|
|
778
|
+
"resetDetection",
|
|
779
|
+
"clearUploadFailure",
|
|
780
|
+
"clearStreamForRetry"
|
|
781
|
+
]
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
target: "#faceCapture.error",
|
|
785
|
+
guard: "isNoAttemptsTerminal",
|
|
786
|
+
actions: ["setTerminalError"]
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
target: "#faceCapture.finished",
|
|
790
|
+
actions: ["flagFaceManualReview"]
|
|
791
|
+
}
|
|
792
|
+
] } },
|
|
793
|
+
success: {
|
|
794
|
+
entry: "cleanup",
|
|
795
|
+
after: { 3e3: { target: "#faceCapture.processing" } }
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
processing: { invoke: {
|
|
800
|
+
id: "processFace",
|
|
801
|
+
src: "processFace",
|
|
802
|
+
onDone: {
|
|
803
|
+
target: "finished",
|
|
804
|
+
actions: "setProcessResponseFromEvent"
|
|
805
|
+
},
|
|
806
|
+
onError: { target: "finished" }
|
|
807
|
+
} },
|
|
808
|
+
finished: {
|
|
809
|
+
entry: "stopMediaStream",
|
|
810
|
+
type: "final"
|
|
811
|
+
},
|
|
812
|
+
closed: {
|
|
813
|
+
entry: "stopMediaStream",
|
|
814
|
+
type: "final"
|
|
815
|
+
},
|
|
816
|
+
error: {
|
|
817
|
+
entry: "stopMediaStream",
|
|
818
|
+
on: { RESET: {
|
|
819
|
+
target: "idle",
|
|
820
|
+
actions: "resetContext"
|
|
821
|
+
} }
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
const faceCaptureMachine = _faceCaptureMachine;
|
|
826
|
+
|
|
827
|
+
//#endregion
|
|
828
|
+
export { createFaceCaptureManagerFromActor as n, faceCaptureMachine as t };
|