@realeyes/verifeye-sdk 1.0.1
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +44 -0
- package/dist/faceDetectionService-D37MewxK.js +96 -0
- package/dist/index-Bfh2zolf.js +2258 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +6 -0
- package/dist/livenessCheckDialog-D7nIgy_n.js +82 -0
- package/dist/livenessCheckDialog.css +1 -0
- package/dist/videoRecorderService-eqEwhEav.js +165 -0
- package/package.json +48 -0
|
@@ -0,0 +1,2258 @@
|
|
|
1
|
+
import { jsx as o, jsxs as S, Fragment as mt } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as Z, useState as D, lazy as ft, useRef as R, Suspense as ht } from "react";
|
|
3
|
+
import { useMediaQuery as pt, Box as ye, Link as gt, CircularProgress as Se, createTheme as vt, ThemeProvider as yt, ScopedCssBaseline as St, Container as Et, Dialog as Ne, DialogTitle as Le, DialogContent as Ue, DialogContentText as Pe, DialogActions as wt, Button as bt } from "@mui/material";
|
|
4
|
+
import $ from "@mui/material/DialogContent";
|
|
5
|
+
import Ct from "@mui/material/IconButton";
|
|
6
|
+
import Rt from "@mui/material/SvgIcon";
|
|
7
|
+
import L from "@mui/material/Stack";
|
|
8
|
+
import C from "@mui/material/Typography";
|
|
9
|
+
import { useTheme as W, responsiveFontSizes as Q } from "@mui/material/styles";
|
|
10
|
+
import Dt from "@mui/material/Dialog";
|
|
11
|
+
import It from "@mui/icons-material/InfoOutlined";
|
|
12
|
+
import { KinesisClient as At, PutRecordCommand as xt } from "@aws-sdk/client-kinesis";
|
|
13
|
+
import './index.css';class Tt {
|
|
14
|
+
sessionId;
|
|
15
|
+
accessToken;
|
|
16
|
+
onCompleted;
|
|
17
|
+
headless;
|
|
18
|
+
constructor(e, t, i, r = !1) {
|
|
19
|
+
this.sessionId = e, this.accessToken = t, this.onCompleted = i, this.headless = r;
|
|
20
|
+
}
|
|
21
|
+
async initSession(e) {
|
|
22
|
+
return e.initCoreSession(this.sessionId, this.accessToken, this.headless);
|
|
23
|
+
}
|
|
24
|
+
async fetchResult(e, t, i, r) {
|
|
25
|
+
return await t.callVerify(e, i, r), { sessionId: e };
|
|
26
|
+
}
|
|
27
|
+
complete(e, t) {
|
|
28
|
+
this.onCompleted(e.sessionId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const ze = ["eu", "us"];
|
|
32
|
+
function Mt(a) {
|
|
33
|
+
return typeof a == "string" && ze.includes(a);
|
|
34
|
+
}
|
|
35
|
+
class kt {
|
|
36
|
+
region;
|
|
37
|
+
constructor(e) {
|
|
38
|
+
this.region = e;
|
|
39
|
+
}
|
|
40
|
+
getCurrentEnvironment() {
|
|
41
|
+
return "production";
|
|
42
|
+
}
|
|
43
|
+
getApiBaseUrl() {
|
|
44
|
+
switch (this.region) {
|
|
45
|
+
case "eu":
|
|
46
|
+
return "https://verifeye-service-eu.realeyes.ai";
|
|
47
|
+
case "us":
|
|
48
|
+
return "https://verifeye-service-us.realeyes.ai";
|
|
49
|
+
default:
|
|
50
|
+
throw new Error(`Invalid region: ${this.region}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const Ot = ({ size: a = 16, color: e }) => /* @__PURE__ */ o(Rt, { children: /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", style: { height: a, width: a }, viewBox: "0 0 24 24", fill: e || "currentColor", children: [
|
|
55
|
+
/* @__PURE__ */ o("path", { d: "M0 0h24v24H0V0z", fill: "none" }),
|
|
56
|
+
/* @__PURE__ */ o("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" })
|
|
57
|
+
] }) }), ee = ({ uniqueId: a, visible: e = !1 }) => e ? /* @__PURE__ */ o(mt, { children: a && /* @__PURE__ */ o(
|
|
58
|
+
C,
|
|
59
|
+
{
|
|
60
|
+
variant: "body2",
|
|
61
|
+
component: "div",
|
|
62
|
+
sx: {
|
|
63
|
+
flexGrow: 1,
|
|
64
|
+
fontSize: "0.75rem",
|
|
65
|
+
marginTop: "30px !important",
|
|
66
|
+
marginBottom: "10px !important",
|
|
67
|
+
lineHeight: 1.6
|
|
68
|
+
},
|
|
69
|
+
children: /* @__PURE__ */ S("span", { style: { color: "#b0b0b0" }, children: [
|
|
70
|
+
"Session ID: ",
|
|
71
|
+
/* @__PURE__ */ o("br", {}),
|
|
72
|
+
a
|
|
73
|
+
] })
|
|
74
|
+
}
|
|
75
|
+
) }) : null, q = ({ open: a, children: e }) => {
|
|
76
|
+
if (!a) return;
|
|
77
|
+
const t = W(), r = !pt(t.breakpoints.up("md"));
|
|
78
|
+
return /* @__PURE__ */ o(
|
|
79
|
+
Dt,
|
|
80
|
+
{
|
|
81
|
+
fullScreen: r,
|
|
82
|
+
fullWidth: !0,
|
|
83
|
+
maxWidth: !1,
|
|
84
|
+
open: a,
|
|
85
|
+
disableAutoFocus: !0,
|
|
86
|
+
"aria-labelledby": "responsive-dialog-title",
|
|
87
|
+
slotProps: {
|
|
88
|
+
paper: {
|
|
89
|
+
sx: (n) => ({
|
|
90
|
+
[n.breakpoints.up("md")]: {
|
|
91
|
+
maxWidth: 420,
|
|
92
|
+
minHeight: 520
|
|
93
|
+
},
|
|
94
|
+
borderRadius: 3
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
children: e
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}, se = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20147%20147'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.2.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20105)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20fill:%20%23263235;%20}%20.st1%20{%20fill:%20%2327eabf;%20}%20%3c/style%3e%3c/defs%3e%3ccircle%20class='st1'%20cx='73.2500001'%20cy='73.7499999'%20r='59.9414062'/%3e%3cpath%20class='st0'%20d='M73,73.5c-2.55,0-4.6875001-.8625-6.4125001-2.5875s-2.5875-3.8625001-2.5875-6.4125001c0-2.4999985.8625-4.6250016,2.5875-6.3750001s3.8625001-2.625,6.4125001-2.625c2.4999985,0,4.6250016.8750015,6.3750001,2.625s2.625,3.8750016,2.625,6.3750001c0,2.55-.8750015,4.6875001-2.625,6.4125001s-3.8750016,2.5875-6.3750001,2.5875ZM54.9999997,88.5000002v-2.7c0-1.05.2625-2.0374993.7875-2.9625s1.2375-1.6624993,2.1375-2.2125c2.2999993-1.35,4.7125008-2.3749993,7.2375001-3.075s5.1375001-1.05,7.8375001-1.05,5.3124986.3499992,7.8375001,1.05,4.9374985,1.725,7.2375001,3.075c.9.5500008,1.6125,1.2874993,2.1375,2.2125s.7875,1.9125.7875,2.9625v2.7c0,.8500008-.2874985,1.5625008-.8625,2.1375-.5750015.5750004-1.2875015.8625-2.1375.8625h-30.0000004c-.8500008,0-1.5625008-.2874996-2.1375-.8625-.5750004-.5749992-.8625-1.2874993-.8625-2.1375ZM48.9999996,103.5000004c-1.65,0-3.0625002-.5875002-4.2375001-1.7625s-1.7625-2.5875-1.7625-4.2375001v-9.0000001c0-.8500008.2875002-1.5625008.8625-2.1375s1.2874998-.8625,2.1375-.8625c.8499996,0,1.5624996.2875008,2.1375.8625s.8625,1.2874993.8625,2.1375v9.0000001h9.0000001c.8500008,0,1.5625008.2874996,2.1375.8625s.8625,1.2875004.8625,2.1375c0,.8500002-.2875008,1.5625002-.8625,2.1375s-1.2874993.8625-2.1375.8625h-9.0000001ZM42.9999996,58.4999998v-9.0000001c0-1.65.5875002-3.0624985,1.7625-4.2375001s2.5875-1.7625,4.2375001-1.7625h9.0000001c.8500008,0,1.5625008.2874985,2.1375.8625s.8625,1.2875015.8625,2.1375-.2875008,1.5624985-.8625,2.1375-1.2874993.8625-2.1375.8625h-9.0000001v9.0000001c0,.8499985-.2874996,1.5624985-.8625,2.1375s-1.2875004.8625-2.1375.8625c-.8500002,0-1.5625002-.2874985-2.1375-.8625s-.8625-1.2875015-.8625-2.1375ZM97.0000004,103.5000004h-9.0000001c-.8499985,0-1.5624985-.2875002-2.1375-.8625s-.8625-1.2874998-.8625-2.1375c0-.8499996.2874985-1.5624996.8625-2.1375s1.2875015-.8625,2.1375-.8625h9.0000001v-9.0000001c0-.8500008.2874985-1.5625008.8625-2.1375s1.2875015-.8625,2.1375-.8625,1.5624985.2875008,2.1375.8625.8625,1.2874993.8625,2.1375v9.0000001c0,1.65-.5874985,3.0625002-1.7625,4.2375001s-2.5875,1.7625-4.2375001,1.7625ZM97.0000004,58.4999998v-9.0000001h-9.0000001c-.8499985,0-1.5624985-.2874985-2.1375-.8625s-.8625-1.2875015-.8625-2.1375.2874985-1.5624985.8625-2.1375,1.2875015-.8625,2.1375-.8625h9.0000001c1.65,0,3.0624985.5874985,4.2375001,1.7625s1.7625,2.5875,1.7625,4.2375001v9.0000001c0,.8499985-.2874985,1.5624985-.8625,2.1375s-1.2875015.8625-2.1375.8625-1.5624985-.2874985-2.1375-.8625-.8625-1.2875015-.8625-2.1375Z'/%3e%3c/svg%3e", Nt = ({
|
|
102
|
+
isOpen: a,
|
|
103
|
+
onAccept: e,
|
|
104
|
+
onClose: t,
|
|
105
|
+
uniqueId: i,
|
|
106
|
+
isConsentButtonLoading: r,
|
|
107
|
+
showVerificationSessionId: n
|
|
108
|
+
}) => {
|
|
109
|
+
if (!a) return;
|
|
110
|
+
const f = W(), l = Q(f).typography;
|
|
111
|
+
return /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ S(
|
|
112
|
+
$,
|
|
113
|
+
{
|
|
114
|
+
sx: {
|
|
115
|
+
display: "flex",
|
|
116
|
+
textAlign: "center !important",
|
|
117
|
+
justifyContent: "center !important",
|
|
118
|
+
alignItems: "center !important"
|
|
119
|
+
},
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ o(
|
|
122
|
+
Ct,
|
|
123
|
+
{
|
|
124
|
+
sx: {
|
|
125
|
+
position: "absolute",
|
|
126
|
+
right: 10,
|
|
127
|
+
top: 10,
|
|
128
|
+
color: "#b0b0b0",
|
|
129
|
+
"&:hover": {
|
|
130
|
+
color: "#263235"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
onClick: t,
|
|
134
|
+
children: /* @__PURE__ */ o(Ot, { size: 30 })
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ S(
|
|
138
|
+
L,
|
|
139
|
+
{
|
|
140
|
+
direction: "column",
|
|
141
|
+
sx: {
|
|
142
|
+
textAlign: "center",
|
|
143
|
+
justifyContent: "center",
|
|
144
|
+
alignItems: "center",
|
|
145
|
+
width: "100%"
|
|
146
|
+
},
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ o(
|
|
149
|
+
"img",
|
|
150
|
+
{
|
|
151
|
+
src: se,
|
|
152
|
+
alt: "Face Verification",
|
|
153
|
+
style: { width: 90, height: 90, marginBottom: 8 }
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ o(
|
|
157
|
+
C,
|
|
158
|
+
{
|
|
159
|
+
variant: "h2",
|
|
160
|
+
component: "div",
|
|
161
|
+
sx: {
|
|
162
|
+
fontSize: l.h2.fontSize,
|
|
163
|
+
fontWeight: "700",
|
|
164
|
+
color: "#263235"
|
|
165
|
+
},
|
|
166
|
+
children: "One quick check"
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
/* @__PURE__ */ S(
|
|
170
|
+
C,
|
|
171
|
+
{
|
|
172
|
+
variant: "body2",
|
|
173
|
+
component: "div",
|
|
174
|
+
sx: {
|
|
175
|
+
fontSize: l.body2.fontSize,
|
|
176
|
+
lineHeight: 1.6,
|
|
177
|
+
color: "#263235",
|
|
178
|
+
mt: "10px"
|
|
179
|
+
},
|
|
180
|
+
children: [
|
|
181
|
+
"Use your camera to verify in seconds.",
|
|
182
|
+
/* @__PURE__ */ o("br", {}),
|
|
183
|
+
"Fast, secure and ",
|
|
184
|
+
/* @__PURE__ */ o("b", { children: "no images are stored." })
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ S(
|
|
189
|
+
ye,
|
|
190
|
+
{
|
|
191
|
+
sx: {
|
|
192
|
+
backgroundColor: "#F5F5F5",
|
|
193
|
+
borderRadius: 2,
|
|
194
|
+
p: 1.5,
|
|
195
|
+
display: "flex",
|
|
196
|
+
alignItems: "flex-start",
|
|
197
|
+
gap: 1,
|
|
198
|
+
textAlign: "left",
|
|
199
|
+
mt: 3,
|
|
200
|
+
mb: 4,
|
|
201
|
+
width: "100%"
|
|
202
|
+
},
|
|
203
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ o(It, { sx: { fontSize: 20, color: "#666666", flexShrink: 0, mt: "1px" } }),
|
|
205
|
+
/* @__PURE__ */ S(
|
|
206
|
+
C,
|
|
207
|
+
{
|
|
208
|
+
variant: "body2",
|
|
209
|
+
sx: { fontSize: "0.8rem", color: "#666666", lineHeight: 1.5 },
|
|
210
|
+
children: [
|
|
211
|
+
"By continuing, you give consent to the use of your camera and image for the verification process. Read our",
|
|
212
|
+
" ",
|
|
213
|
+
/* @__PURE__ */ o(
|
|
214
|
+
gt,
|
|
215
|
+
{
|
|
216
|
+
href: "https://realeyes.ai/privacy-policy/",
|
|
217
|
+
target: "_blank",
|
|
218
|
+
rel: "noopener noreferrer",
|
|
219
|
+
sx: { color: "#666666", textDecorationColor: "#666666" },
|
|
220
|
+
children: "Privacy Policy"
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
"."
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ S(
|
|
231
|
+
"button",
|
|
232
|
+
{
|
|
233
|
+
className: "realeyes-btn realeyes-btn--rounded",
|
|
234
|
+
onClick: e,
|
|
235
|
+
disabled: r,
|
|
236
|
+
style: { width: "100%", justifyContent: "center" },
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ o("span", { children: "Continue" }),
|
|
239
|
+
r && /* @__PURE__ */ o(
|
|
240
|
+
Se,
|
|
241
|
+
{
|
|
242
|
+
size: 20,
|
|
243
|
+
sx: { color: "white" }
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
),
|
|
249
|
+
/* @__PURE__ */ o(ee, { uniqueId: i, visible: n })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
) });
|
|
256
|
+
};
|
|
257
|
+
class ve extends Error {
|
|
258
|
+
status;
|
|
259
|
+
constructor(e, t) {
|
|
260
|
+
super(e), this.name = "PermanentSessionError", this.status = t, Object.setPrototypeOf(this, new.target.prototype);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
class H extends Error {
|
|
264
|
+
constructor(e = "Server is busy, please try again later.") {
|
|
265
|
+
super(e), this.name = "ServerBusyError", Object.setPrototypeOf(this, new.target.prototype);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
class M {
|
|
269
|
+
mediaStream;
|
|
270
|
+
videoElement;
|
|
271
|
+
canvasElement;
|
|
272
|
+
isReady;
|
|
273
|
+
adjustLoop;
|
|
274
|
+
cameraReadinessLoop;
|
|
275
|
+
// Video capture settings
|
|
276
|
+
static VIDEO_WIDTH = 1280;
|
|
277
|
+
static VIDEO_HEIGHT = 720;
|
|
278
|
+
static VIDEO_FRAME_RATE = 24;
|
|
279
|
+
constructor() {
|
|
280
|
+
this.isReady = !1;
|
|
281
|
+
}
|
|
282
|
+
async startVideo(e = void 0, t = void 0) {
|
|
283
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia)
|
|
284
|
+
try {
|
|
285
|
+
const i = {
|
|
286
|
+
video: {
|
|
287
|
+
width: {
|
|
288
|
+
min: 320,
|
|
289
|
+
ideal: M.VIDEO_WIDTH,
|
|
290
|
+
max: M.VIDEO_WIDTH
|
|
291
|
+
},
|
|
292
|
+
height: {
|
|
293
|
+
min: 240,
|
|
294
|
+
ideal: M.VIDEO_HEIGHT,
|
|
295
|
+
max: M.VIDEO_HEIGHT
|
|
296
|
+
},
|
|
297
|
+
frameRate: {
|
|
298
|
+
ideal: M.VIDEO_FRAME_RATE,
|
|
299
|
+
max: M.VIDEO_FRAME_RATE
|
|
300
|
+
},
|
|
301
|
+
facingMode: t ?? { ideal: "user" }
|
|
302
|
+
},
|
|
303
|
+
audio: !1
|
|
304
|
+
}, r = await navigator.mediaDevices.getUserMedia(
|
|
305
|
+
e ? { video: { deviceId: e } } : i
|
|
306
|
+
);
|
|
307
|
+
this.mediaStream = r, this.videoElement = document.createElement("video"), this.videoElement.id = "videoExperienceSdk", this.canvasElement = document.createElement("canvas"), this.canvasElement.width = M.VIDEO_WIDTH, this.canvasElement.height = M.VIDEO_HEIGHT, document.body.appendChild(this.videoElement), this.videoElement.pause(), this.videoElement.setAttribute("playsinline", ""), this.videoElement.playsInline = !0, this.videoElement.setAttribute("muted", ""), this.videoElement.controls = !0, this.videoElement.muted = !0, this.videoElement.autoplay = !0, this.videoElement.src = "", this.videoElement.style.width = "1px", this.videoElement.style.height = "1px";
|
|
308
|
+
try {
|
|
309
|
+
this.videoElement.srcObject = this.mediaStream;
|
|
310
|
+
} catch (f) {
|
|
311
|
+
console.error(f), this.videoElement.src = window.URL.createObjectURL(
|
|
312
|
+
this.mediaStream
|
|
313
|
+
);
|
|
314
|
+
} finally {
|
|
315
|
+
this.videoElement.play();
|
|
316
|
+
}
|
|
317
|
+
const n = this;
|
|
318
|
+
return n.videoElement.addEventListener("loadedmetadata", () => {
|
|
319
|
+
n.cameraReadinessLoop = setInterval(() => {
|
|
320
|
+
n.videoElement && !n.videoElement.paused && !n.videoElement.ended && (n.videoElement.currentTime || 0) > 0 && (n.isReady = !0, clearInterval(n.cameraReadinessLoop), n.adjustLoop = setInterval(() => {
|
|
321
|
+
if (n.mediaStream == null) return;
|
|
322
|
+
const f = n.mediaStream.getVideoTracks()[0].getSettings().width, l = n.mediaStream.getVideoTracks()[0].getSettings().height;
|
|
323
|
+
n.videoElement.width !== f && (n.videoElement.width = n.mediaStream.getVideoTracks()[0].getSettings().width, n.canvasElement.width = n.videoElement.width), n.videoElement.height !== l && (n.videoElement.height = n.mediaStream.getVideoTracks()[0].getSettings().height, n.canvasElement.height = n.videoElement.height);
|
|
324
|
+
}, 150));
|
|
325
|
+
}, 100);
|
|
326
|
+
}), { status: !0, error: null };
|
|
327
|
+
} catch (i) {
|
|
328
|
+
return console.error(i), { status: !1, error: i?.name || "UnknownError" };
|
|
329
|
+
}
|
|
330
|
+
return { status: !1, error: "NoMediaDevices" };
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Returns a promise with the image data from the camera.
|
|
334
|
+
* @async
|
|
335
|
+
* @function getImage
|
|
336
|
+
* @memberof CameraManager
|
|
337
|
+
* @instance
|
|
338
|
+
* @returns {Promise<string>} - A promise with the base64 image data.
|
|
339
|
+
* @throws {string} No media stream. Call startVideo to initialize the camera.
|
|
340
|
+
*
|
|
341
|
+
**/
|
|
342
|
+
async getImage() {
|
|
343
|
+
const e = this;
|
|
344
|
+
return e.mediaStream == null ? Promise.reject(
|
|
345
|
+
"Error: No media stream. Call startVideo to initialize the camera."
|
|
346
|
+
) : new Promise((t, i) => {
|
|
347
|
+
let r = 0;
|
|
348
|
+
const n = () => {
|
|
349
|
+
if (r > 10) {
|
|
350
|
+
i("Error: Could not get image from camera.");
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (e.isReady && e.videoElement && e.canvasElement?.width && e.canvasElement?.height) {
|
|
354
|
+
e.canvasElement.getContext("2d").drawImage(
|
|
355
|
+
e.videoElement,
|
|
356
|
+
0,
|
|
357
|
+
0,
|
|
358
|
+
e.canvasElement.width,
|
|
359
|
+
e.canvasElement.height
|
|
360
|
+
);
|
|
361
|
+
const f = e.canvasElement.toDataURL("image/png");
|
|
362
|
+
t(f);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
r++, setTimeout(n, 150);
|
|
366
|
+
};
|
|
367
|
+
n();
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Stops the video stream if it was created by the SDK.
|
|
372
|
+
* @function stopVideo
|
|
373
|
+
* @memberof CameraManager
|
|
374
|
+
* @instance
|
|
375
|
+
* @returns {void}
|
|
376
|
+
*/
|
|
377
|
+
stopVideo() {
|
|
378
|
+
if (this.mediaStream) {
|
|
379
|
+
clearInterval(this.adjustLoop), this.isReady = !1;
|
|
380
|
+
try {
|
|
381
|
+
this.mediaStream.getVideoTracks().forEach(function(e) {
|
|
382
|
+
e.stop();
|
|
383
|
+
});
|
|
384
|
+
} catch {
|
|
385
|
+
}
|
|
386
|
+
this.mediaStream = void 0, this.videoElement.srcObject = null, this.videoElement.removeAttribute("src"), document.body.removeChild(this.videoElement), this.videoElement = void 0, this.canvasElement = void 0, this.adjustLoop = void 0;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
class Lt {
|
|
391
|
+
browser;
|
|
392
|
+
version;
|
|
393
|
+
constructor() {
|
|
394
|
+
this.browser = null, this.version = null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
class N {
|
|
398
|
+
static extractVersion(e, t, i) {
|
|
399
|
+
const r = e.match(t);
|
|
400
|
+
return r && r.length >= i ? parseInt(r[i], 10) : null;
|
|
401
|
+
}
|
|
402
|
+
static detectBrowser(e) {
|
|
403
|
+
const t = e && e.navigator, i = new Lt();
|
|
404
|
+
return typeof e > "u" || !e.navigator ? (i.browser = "Not a browser", i) : (t.mozGetUserMedia && t.userAgent.match(/Firefox\/(\d+)\./) ? (i.browser = "firefox", i.version = N.extractVersion(
|
|
405
|
+
t.userAgent,
|
|
406
|
+
/Firefox\/(\d+)\./,
|
|
407
|
+
1
|
|
408
|
+
)) : t.webkitGetUserMedia && t.userAgent.match(/Chrom(e|ium)\/(\d+)\./) ? (i.browser = "chrome", i.version = N.extractVersion(
|
|
409
|
+
t.userAgent,
|
|
410
|
+
/Chrom(e|ium)\/(\d+)\./,
|
|
411
|
+
2
|
|
412
|
+
)) : t.mediaDevices && t.userAgent.match(/Edge\/(\d+).(\d+)$/) ? (i.browser = "edge", i.version = N.extractVersion(
|
|
413
|
+
t.userAgent,
|
|
414
|
+
/Edge\/(\d+).(\d+)$/,
|
|
415
|
+
2
|
|
416
|
+
)) : e.RTCPeerConnection && t.userAgent.match(/AppleWebKit\/(\d+)\./) ? (i.browser = "safari", i.version = N.extractVersion(
|
|
417
|
+
t.userAgent,
|
|
418
|
+
/AppleWebKit\/(\d+)\./,
|
|
419
|
+
1
|
|
420
|
+
)) : i.browser = "Not supported", i);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
class Ut {
|
|
424
|
+
shimCreateObjectURL(e) {
|
|
425
|
+
const t = e && e.URL;
|
|
426
|
+
if (typeof e == "object" && e.HTMLMediaElement && "srcObject" in e.HTMLMediaElement.prototype && t.createObjectURL && t.revokeObjectURL) {
|
|
427
|
+
const i = t.createObjectURL.bind(t), r = t.revokeObjectURL.bind(t), n = /* @__PURE__ */ new Map();
|
|
428
|
+
let f = 0;
|
|
429
|
+
t.createObjectURL = function(c) {
|
|
430
|
+
if ("getTracks" in c) {
|
|
431
|
+
const d = "polyblob:" + ++f;
|
|
432
|
+
return n.set(d, c), d;
|
|
433
|
+
}
|
|
434
|
+
return i(c);
|
|
435
|
+
}, t.revokeObjectURL = function(c) {
|
|
436
|
+
r(c), n.delete(c);
|
|
437
|
+
};
|
|
438
|
+
const l = Object.getOwnPropertyDescriptor(
|
|
439
|
+
e.HTMLMediaElement.prototype,
|
|
440
|
+
"src"
|
|
441
|
+
);
|
|
442
|
+
Object.defineProperty(e.HTMLMediaElement.prototype, "src", {
|
|
443
|
+
get: function() {
|
|
444
|
+
if (l && typeof l.get == "function")
|
|
445
|
+
return l.get.call(this);
|
|
446
|
+
},
|
|
447
|
+
set: function(c) {
|
|
448
|
+
if (this.srcObject = n.get(c) || null, l && typeof l.set == "function")
|
|
449
|
+
return l.set.call(this, c);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
const s = e.HTMLMediaElement.prototype.setAttribute;
|
|
453
|
+
e.HTMLMediaElement.prototype.setAttribute = function() {
|
|
454
|
+
return arguments.length === 2 && ("" + arguments[0]).toLowerCase() === "src" && (this.srcObject = n.get(arguments[1]) || null), s.apply(this, arguments);
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
class Pt {
|
|
460
|
+
init(e) {
|
|
461
|
+
const t = N.detectBrowser(e), i = e && e.navigator, r = function(s) {
|
|
462
|
+
if (typeof s != "object" || s.mandatory || s.optional) return s;
|
|
463
|
+
const c = {};
|
|
464
|
+
return Object.keys(s).forEach(function(d) {
|
|
465
|
+
if (d !== "require" && d !== "advanced" && d !== "mediaSource") {
|
|
466
|
+
const u = typeof s[d] == "object" ? s[d] : {
|
|
467
|
+
ideal: s[d]
|
|
468
|
+
};
|
|
469
|
+
u.exact !== void 0 && typeof u.exact == "number" && (u.min = u.max = u.exact);
|
|
470
|
+
const h = function(p, v) {
|
|
471
|
+
return p ? p + v.charAt(0).toUpperCase() + v.slice(1) : v === "deviceId" ? "sourceId" : v;
|
|
472
|
+
};
|
|
473
|
+
if (u.ideal !== void 0) {
|
|
474
|
+
c.optional = c.optional || [];
|
|
475
|
+
let p = {};
|
|
476
|
+
typeof u.ideal == "number" ? (p[h("min", d)] = u.ideal, c.optional.push(p), p = {}, p[h("max", d)] = u.ideal) : p[h("", d)] = u.ideal, c.optional.push(p);
|
|
477
|
+
}
|
|
478
|
+
u.exact !== void 0 && typeof u.exact != "number" ? (c.mandatory = c.mandatory || {}, c.mandatory[h("", d)] = u.exact) : ["min", "max"].forEach(function(p) {
|
|
479
|
+
u[p] !== void 0 && (c.mandatory = c.mandatory || {}, c.mandatory[h(p, d)] = u[p]);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}), s.advanced && (c.optional = (c.optional || []).concat(s.advanced)), c;
|
|
483
|
+
}, n = function(s, c) {
|
|
484
|
+
if (t.version && 61 <= t.version)
|
|
485
|
+
return c(s);
|
|
486
|
+
if ((s = JSON.parse(JSON.stringify(s))) && typeof s.audio == "object") {
|
|
487
|
+
const d = function(u, h, p) {
|
|
488
|
+
h in u && !(p in u) && (u[p] = u[h], delete u[h]);
|
|
489
|
+
};
|
|
490
|
+
s = JSON.parse(JSON.stringify(s)), d(
|
|
491
|
+
s.audio,
|
|
492
|
+
"autoGainControl",
|
|
493
|
+
"googAutoGainControl"
|
|
494
|
+
), d(
|
|
495
|
+
s.audio,
|
|
496
|
+
"noiseSuppression",
|
|
497
|
+
"googNoiseSuppression"
|
|
498
|
+
), s.audio = r(s.audio);
|
|
499
|
+
}
|
|
500
|
+
if (s && typeof s.video == "object") {
|
|
501
|
+
let d = s.video.facingMode;
|
|
502
|
+
d = d && (typeof d == "object" ? d : {
|
|
503
|
+
ideal: d
|
|
504
|
+
});
|
|
505
|
+
const u = t.version && 66 > t.version;
|
|
506
|
+
if (!(!d || d.exact !== "user" && d.exact !== "environment" && d.ideal !== "user" && d.ideal !== "environment" || i.mediaDevices.getSupportedConstraints && i.mediaDevices.getSupportedConstraints().facingMode && !u)) {
|
|
507
|
+
delete s.video.facingMode;
|
|
508
|
+
let h = null;
|
|
509
|
+
if (d.exact === "environment" || d.ideal === "environment" ? h = ["back", "rear"] : (d.exact === "user" || d.ideal === "user") && (h = ["front"]), h)
|
|
510
|
+
return i.mediaDevices.enumerateDevices().then(function(p) {
|
|
511
|
+
p = p.filter(function(U) {
|
|
512
|
+
return U.kind === "videoinput";
|
|
513
|
+
});
|
|
514
|
+
let v = p.find(
|
|
515
|
+
function(U) {
|
|
516
|
+
return h.some(function(te) {
|
|
517
|
+
return U.label.toLowerCase().indexOf(te) !== -1;
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
);
|
|
521
|
+
return !v && p.length && h.indexOf("back") !== -1 && (v = p[p.length - 1]), v && (s.video.deviceId = d.exact ? {
|
|
522
|
+
exact: v.deviceId
|
|
523
|
+
} : {
|
|
524
|
+
ideal: v.deviceId
|
|
525
|
+
}), s.video = r(s.video), c(s);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
s.video = r(s.video);
|
|
529
|
+
}
|
|
530
|
+
return c(s);
|
|
531
|
+
}, f = function(s) {
|
|
532
|
+
return {
|
|
533
|
+
name: {
|
|
534
|
+
PermissionDeniedError: "NotAllowedError",
|
|
535
|
+
PermissionDismissedError: "NotAllowedError",
|
|
536
|
+
InvalidStateError: "NotAllowedError",
|
|
537
|
+
DevicesNotFoundError: "NotFoundError",
|
|
538
|
+
ConstraintNotSatisfiedError: "OverconstrainedError",
|
|
539
|
+
TrackStartError: "NotReadableError",
|
|
540
|
+
MediaDeviceFailedDueToShutdown: "NotAllowedError",
|
|
541
|
+
MediaDeviceKillSwitchOn: "NotAllowedError",
|
|
542
|
+
TabCaptureError: "AbortError",
|
|
543
|
+
ScreenCaptureError: "AbortError",
|
|
544
|
+
DeviceCaptureError: "AbortError"
|
|
545
|
+
}[s.name] || s.name,
|
|
546
|
+
message: s.message,
|
|
547
|
+
constraint: s.constraint || s.constraintName,
|
|
548
|
+
toString: function() {
|
|
549
|
+
return this.name + (this.message && ": ") + this.message;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
i.getUserMedia = function(s, c, d) {
|
|
554
|
+
n(s, function(u) {
|
|
555
|
+
i.webkitGetUserMedia(
|
|
556
|
+
u,
|
|
557
|
+
c,
|
|
558
|
+
function(h) {
|
|
559
|
+
d && d(f(h));
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
const l = function(s) {
|
|
565
|
+
return new Promise(function(c, d) {
|
|
566
|
+
i.getUserMedia(
|
|
567
|
+
s,
|
|
568
|
+
c,
|
|
569
|
+
d
|
|
570
|
+
);
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
if (i.mediaDevices || (i.mediaDevices = {
|
|
574
|
+
getUserMedia: l,
|
|
575
|
+
enumerateDevices: function() {
|
|
576
|
+
return new Promise(function(s) {
|
|
577
|
+
const c = {
|
|
578
|
+
audio: "audioinput",
|
|
579
|
+
video: "videoinput"
|
|
580
|
+
};
|
|
581
|
+
return e.MediaStreamTrack.getSources(function(d) {
|
|
582
|
+
s(
|
|
583
|
+
d.map(function(u) {
|
|
584
|
+
return {
|
|
585
|
+
label: u.label,
|
|
586
|
+
kind: c[u.kind],
|
|
587
|
+
deviceId: u.id,
|
|
588
|
+
groupId: ""
|
|
589
|
+
};
|
|
590
|
+
})
|
|
591
|
+
);
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
},
|
|
595
|
+
getSupportedConstraints: function() {
|
|
596
|
+
return {
|
|
597
|
+
deviceId: !0,
|
|
598
|
+
echoCancellation: !0,
|
|
599
|
+
facingMode: !0,
|
|
600
|
+
frameRate: !0,
|
|
601
|
+
height: !0,
|
|
602
|
+
width: !0
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
}), i.mediaDevices.getUserMedia) {
|
|
606
|
+
const s = i.mediaDevices.getUserMedia.bind(
|
|
607
|
+
i.mediaDevices
|
|
608
|
+
);
|
|
609
|
+
i.mediaDevices.getUserMedia = function(c) {
|
|
610
|
+
return n(
|
|
611
|
+
c,
|
|
612
|
+
function(d) {
|
|
613
|
+
return s(d).then(
|
|
614
|
+
function(u) {
|
|
615
|
+
if (d.audio && !u.getAudioTracks().length || d.video && !u.getVideoTracks().length)
|
|
616
|
+
throw u.getTracks().forEach(function(h) {
|
|
617
|
+
h.stop();
|
|
618
|
+
}), new DOMException("", "NotFoundError");
|
|
619
|
+
return u;
|
|
620
|
+
},
|
|
621
|
+
function(u) {
|
|
622
|
+
return Promise.reject(f(u));
|
|
623
|
+
}
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
};
|
|
628
|
+
} else
|
|
629
|
+
i.mediaDevices.getUserMedia = function(s) {
|
|
630
|
+
return l(s);
|
|
631
|
+
};
|
|
632
|
+
typeof i.mediaDevices.addEventListener > "u" && (i.mediaDevices.addEventListener = function() {
|
|
633
|
+
}), typeof i.mediaDevices.removeEventListener > "u" && (i.mediaDevices.removeEventListener = function() {
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
class Vt {
|
|
638
|
+
shimGetUserMedia(e) {
|
|
639
|
+
return new Pt().init(e);
|
|
640
|
+
}
|
|
641
|
+
shimMediaStream(e) {
|
|
642
|
+
e.MediaStream = e.MediaStream || e.webkitMediaStream;
|
|
643
|
+
}
|
|
644
|
+
shimSourceObject(e) {
|
|
645
|
+
const t = e && e.URL;
|
|
646
|
+
typeof e == "object" && (!e.HTMLMediaElement || "srcObject" in e.HTMLMediaElement.prototype || Object.defineProperty(
|
|
647
|
+
e.HTMLMediaElement.prototype,
|
|
648
|
+
"srcObject",
|
|
649
|
+
{
|
|
650
|
+
get: function() {
|
|
651
|
+
return this._srcObject;
|
|
652
|
+
},
|
|
653
|
+
set: function(i) {
|
|
654
|
+
const r = this;
|
|
655
|
+
this._srcObject = i, this.src && t.revokeObjectURL(this.src), i ? (this.src = t.createObjectURL(i), i.addEventListener("addtrack", function() {
|
|
656
|
+
r.src && t.revokeObjectURL(r.src), r.src = t.createObjectURL(i);
|
|
657
|
+
}), i.addEventListener("removetrack", function() {
|
|
658
|
+
r.src && t.revokeObjectURL(r.src), r.src = t.createObjectURL(i);
|
|
659
|
+
})) : this.src = "";
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
));
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
class zt {
|
|
666
|
+
init(e) {
|
|
667
|
+
e = e && e.navigator;
|
|
668
|
+
const t = function(r) {
|
|
669
|
+
return {
|
|
670
|
+
name: {
|
|
671
|
+
PermissionDeniedError: "NotAllowedError"
|
|
672
|
+
}[r.name] || r.name,
|
|
673
|
+
message: r.message,
|
|
674
|
+
constraint: r.constraint,
|
|
675
|
+
toString: function() {
|
|
676
|
+
return this.name;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}, i = e.mediaDevices.getUserMedia.bind(
|
|
680
|
+
e.mediaDevices
|
|
681
|
+
);
|
|
682
|
+
e.mediaDevices.getUserMedia = function(r) {
|
|
683
|
+
return i(r).catch(function(n) {
|
|
684
|
+
return Promise.reject(t(n));
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
class Ft {
|
|
690
|
+
shimGetUserMedia(e) {
|
|
691
|
+
return new zt().init(e);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
class _t {
|
|
695
|
+
init(e) {
|
|
696
|
+
const t = N.detectBrowser(e), i = e && e.navigator;
|
|
697
|
+
e = e && e.MediaStreamTrack;
|
|
698
|
+
const r = function(l) {
|
|
699
|
+
return {
|
|
700
|
+
name: {
|
|
701
|
+
InternalError: "NotReadableError",
|
|
702
|
+
NotSupportedError: "TypeError",
|
|
703
|
+
PermissionDeniedError: "NotAllowedError",
|
|
704
|
+
SecurityError: "NotAllowedError"
|
|
705
|
+
}[l.name] || l.name,
|
|
706
|
+
message: {
|
|
707
|
+
"The operation is insecure.": "The request is not allowed by the user agent or the platform in the current context."
|
|
708
|
+
}[l.message] || l.message,
|
|
709
|
+
constraint: l.constraint,
|
|
710
|
+
toString: function() {
|
|
711
|
+
return this.name + (this.message && ": ") + this.message;
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
}, n = function(l, s, c) {
|
|
715
|
+
const d = function(u) {
|
|
716
|
+
if (typeof u != "object" || u.require) return u;
|
|
717
|
+
const h = [];
|
|
718
|
+
return Object.keys(u).forEach(function(p) {
|
|
719
|
+
if (p !== "require" && p !== "advanced" && p !== "mediaSource") {
|
|
720
|
+
const v = u[p] = typeof u[p] == "object" ? u[p] : {
|
|
721
|
+
ideal: u[p]
|
|
722
|
+
};
|
|
723
|
+
if (v.min === void 0 && v.max === void 0 && v.exact === void 0 || h.push(p), v.exact !== void 0 && (typeof v.exact == "number" ? v.min = v.max = v.exact : u[p] = v.exact, delete v.exact), v.ideal !== void 0) {
|
|
724
|
+
u.advanced = u.advanced || [];
|
|
725
|
+
const U = {};
|
|
726
|
+
U[p] = typeof v.ideal == "number" ? {
|
|
727
|
+
min: v.ideal,
|
|
728
|
+
max: v.ideal
|
|
729
|
+
} : v.ideal, u.advanced.push(U), delete v.ideal, Object.keys(v).length || delete u[p];
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}), h.length && (u.require = h), u;
|
|
733
|
+
};
|
|
734
|
+
return l = JSON.parse(JSON.stringify(l)), t.version && 38 > t.version && (l.audio && (l.audio = d(l.audio)), l.video && (l.video = d(l.video))), i.mozGetUserMedia(
|
|
735
|
+
l,
|
|
736
|
+
s,
|
|
737
|
+
function(u) {
|
|
738
|
+
c(r(u));
|
|
739
|
+
}
|
|
740
|
+
);
|
|
741
|
+
}, f = function(l) {
|
|
742
|
+
return new Promise(function(s, c) {
|
|
743
|
+
n(l, s, c);
|
|
744
|
+
});
|
|
745
|
+
};
|
|
746
|
+
if (i.mediaDevices || (i.mediaDevices = {
|
|
747
|
+
getUserMedia: f,
|
|
748
|
+
addEventListener: function() {
|
|
749
|
+
},
|
|
750
|
+
removeEventListener: function() {
|
|
751
|
+
}
|
|
752
|
+
}), i.mediaDevices.enumerateDevices = i.mediaDevices.enumerateDevices || function() {
|
|
753
|
+
return new Promise(function(l) {
|
|
754
|
+
l([
|
|
755
|
+
{
|
|
756
|
+
kind: "audioinput",
|
|
757
|
+
deviceId: "default",
|
|
758
|
+
label: "",
|
|
759
|
+
groupId: ""
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
kind: "videoinput",
|
|
763
|
+
deviceId: "default",
|
|
764
|
+
label: "",
|
|
765
|
+
groupId: ""
|
|
766
|
+
}
|
|
767
|
+
]);
|
|
768
|
+
});
|
|
769
|
+
}, t.version && 41 > t.version) {
|
|
770
|
+
const l = i.mediaDevices.enumerateDevices.bind(
|
|
771
|
+
i.mediaDevices
|
|
772
|
+
);
|
|
773
|
+
i.mediaDevices.enumerateDevices = function() {
|
|
774
|
+
return l().then(void 0, function(s) {
|
|
775
|
+
if (s.name === "NotFoundError") return [];
|
|
776
|
+
throw s;
|
|
777
|
+
});
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
if (t.version && 49 > t.version) {
|
|
781
|
+
const l = i.mediaDevices.getUserMedia.bind(
|
|
782
|
+
i.mediaDevices
|
|
783
|
+
);
|
|
784
|
+
i.mediaDevices.getUserMedia = function(s) {
|
|
785
|
+
return l(s).then(
|
|
786
|
+
function(c) {
|
|
787
|
+
if (s.audio && !c.getAudioTracks().length || s.video && !c.getVideoTracks().length)
|
|
788
|
+
throw c.getTracks().forEach(function(d) {
|
|
789
|
+
d.stop();
|
|
790
|
+
}), new DOMException(
|
|
791
|
+
"The object can not be found here.",
|
|
792
|
+
"NotFoundError"
|
|
793
|
+
);
|
|
794
|
+
return c;
|
|
795
|
+
},
|
|
796
|
+
function(c) {
|
|
797
|
+
return Promise.reject(r(c));
|
|
798
|
+
}
|
|
799
|
+
);
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
if (!(t.version && 55 < t.version && "autoGainControl" in i.mediaDevices.getSupportedConstraints())) {
|
|
803
|
+
const l = function(c, d, u) {
|
|
804
|
+
d in c && !(u in c) && (c[u] = c[d], delete c[d]);
|
|
805
|
+
}, s = i.mediaDevices.getUserMedia.bind(
|
|
806
|
+
i.mediaDevices
|
|
807
|
+
);
|
|
808
|
+
if (i.mediaDevices.getUserMedia = function(c) {
|
|
809
|
+
return typeof c == "object" && typeof c.audio == "object" && (c = JSON.parse(JSON.stringify(c)), l(c.audio, "autoGainControl", "mozAutoGainControl"), l(c.audio, "noiseSuppression", "mozNoiseSuppression")), s(c);
|
|
810
|
+
}, e && e.prototype.getSettings) {
|
|
811
|
+
const c = e.prototype.getSettings;
|
|
812
|
+
e.prototype.getSettings = function() {
|
|
813
|
+
const d = c.apply(this, arguments);
|
|
814
|
+
return l(d, "mozAutoGainControl", "autoGainControl"), l(d, "mozNoiseSuppression", "noiseSuppression"), d;
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
if (e && e.prototype.applyConstraints) {
|
|
818
|
+
const c = e.prototype.applyConstraints;
|
|
819
|
+
e.prototype.applyConstraints = function(d) {
|
|
820
|
+
return this.kind === "audio" && typeof d == "object" && (d = JSON.parse(JSON.stringify(d)), l(d, "autoGainControl", "mozAutoGainControl"), l(d, "noiseSuppression", "mozNoiseSuppression")), c.apply(this, [d]);
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
i.getUserMedia = function(l, s, c) {
|
|
825
|
+
if (t.version && 44 > t.version)
|
|
826
|
+
return n(
|
|
827
|
+
l,
|
|
828
|
+
s,
|
|
829
|
+
c
|
|
830
|
+
);
|
|
831
|
+
console.warn(
|
|
832
|
+
"navigator.getUserMedia",
|
|
833
|
+
"navigator.mediaDevices.getUserMedia"
|
|
834
|
+
), i.mediaDevices.getUserMedia(l).then(s, c);
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
class Gt {
|
|
839
|
+
shimGetUserMedia(e) {
|
|
840
|
+
return new _t().init(e);
|
|
841
|
+
}
|
|
842
|
+
shimSourceObject(e) {
|
|
843
|
+
typeof e == "object" && (!e.HTMLMediaElement || "srcObject" in e.HTMLMediaElement.prototype || Object.defineProperty(
|
|
844
|
+
e.HTMLMediaElement.prototype,
|
|
845
|
+
"srcObject",
|
|
846
|
+
{
|
|
847
|
+
get: function() {
|
|
848
|
+
return this.mozSrcObject;
|
|
849
|
+
},
|
|
850
|
+
set: function(t) {
|
|
851
|
+
this.mozSrcObject = t;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
));
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
class Bt {
|
|
858
|
+
shimGetUserMedia(e) {
|
|
859
|
+
const t = e && e.navigator;
|
|
860
|
+
t.getUserMedia || (t.webkitGetUserMedia ? t.getUserMedia = t.webkitGetUserMedia.bind(t) : t.mediaDevices && t.mediaDevices.getUserMedia && (t.getUserMedia = (function(i, r, n) {
|
|
861
|
+
t.mediaDevices.getUserMedia(i).then(r, n);
|
|
862
|
+
}).bind(t)));
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
class jt {
|
|
866
|
+
browserDetails;
|
|
867
|
+
browserAdapter;
|
|
868
|
+
commonAdapter;
|
|
869
|
+
extractVersion;
|
|
870
|
+
constructor(e, t, i, r) {
|
|
871
|
+
this.browserDetails = e, this.browserAdapter = t, this.commonAdapter = i, this.extractVersion = r;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
class Ht {
|
|
875
|
+
init() {
|
|
876
|
+
const e = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : {}, t = e && e.window, i = N.detectBrowser(t), r = new Vt(), n = new Ft(), f = new Gt(), l = new Bt(), s = new Ut(), c = new jt(
|
|
877
|
+
i,
|
|
878
|
+
null,
|
|
879
|
+
s,
|
|
880
|
+
N.extractVersion
|
|
881
|
+
);
|
|
882
|
+
switch (i.browser) {
|
|
883
|
+
case "chrome":
|
|
884
|
+
c.browserAdapter = r, s.shimCreateObjectURL(t), r.shimGetUserMedia(t), r.shimMediaStream(t), r.shimSourceObject(t);
|
|
885
|
+
break;
|
|
886
|
+
case "firefox":
|
|
887
|
+
c.browserAdapter = f, s.shimCreateObjectURL(t), f.shimGetUserMedia(t), f.shimSourceObject(t);
|
|
888
|
+
break;
|
|
889
|
+
case "edge":
|
|
890
|
+
c.browserAdapter = n, s.shimCreateObjectURL(t), n.shimGetUserMedia(t);
|
|
891
|
+
break;
|
|
892
|
+
case "safari":
|
|
893
|
+
c.browserAdapter = l, s.shimCreateObjectURL(t), l.shimGetUserMedia(t);
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
return c;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
class $t {
|
|
900
|
+
cameraManager;
|
|
901
|
+
constructor() {
|
|
902
|
+
this.cameraManager = new M();
|
|
903
|
+
}
|
|
904
|
+
async init() {
|
|
905
|
+
return new Ht().init();
|
|
906
|
+
}
|
|
907
|
+
async startVideo(e) {
|
|
908
|
+
const t = await this.cameraManager.startVideo(
|
|
909
|
+
e,
|
|
910
|
+
{ ideal: "user" }
|
|
911
|
+
);
|
|
912
|
+
return this.translateMediaError(t);
|
|
913
|
+
}
|
|
914
|
+
async getImage() {
|
|
915
|
+
return await this.cameraManager.getImage();
|
|
916
|
+
}
|
|
917
|
+
stopVideo() {
|
|
918
|
+
return this.cameraManager.stopVideo();
|
|
919
|
+
}
|
|
920
|
+
getCameraManager() {
|
|
921
|
+
return this.cameraManager;
|
|
922
|
+
}
|
|
923
|
+
getVideoElement() {
|
|
924
|
+
return this.cameraManager.videoElement;
|
|
925
|
+
}
|
|
926
|
+
translateMediaError(e) {
|
|
927
|
+
if (e.status)
|
|
928
|
+
return new F(
|
|
929
|
+
O.GRANTED,
|
|
930
|
+
z.GRANTED
|
|
931
|
+
);
|
|
932
|
+
switch (e.error) {
|
|
933
|
+
case "AbortError":
|
|
934
|
+
return new F(
|
|
935
|
+
O.CAMERA_ERROR,
|
|
936
|
+
z.ABORT_ERROR
|
|
937
|
+
);
|
|
938
|
+
case "NotAllowedError":
|
|
939
|
+
return new F(
|
|
940
|
+
O.DENIED,
|
|
941
|
+
z.NOT_ALLOWED_ERROR
|
|
942
|
+
);
|
|
943
|
+
case "NotFoundError":
|
|
944
|
+
return new F(
|
|
945
|
+
O.NO_CAMERA,
|
|
946
|
+
z.NOT_FOUND_ERROR
|
|
947
|
+
);
|
|
948
|
+
case "NotReadableError":
|
|
949
|
+
return new F(
|
|
950
|
+
O.CAMERA_ERROR,
|
|
951
|
+
z.NOT_READABLE_ERROR
|
|
952
|
+
);
|
|
953
|
+
case "OverconstrainedError":
|
|
954
|
+
return new F(
|
|
955
|
+
O.NO_CAMERA,
|
|
956
|
+
z.OVERCONSTRAINED_ERROR
|
|
957
|
+
);
|
|
958
|
+
case "SecurityError":
|
|
959
|
+
return new F(
|
|
960
|
+
O.DENIED,
|
|
961
|
+
z.SECURITY_ERROR
|
|
962
|
+
);
|
|
963
|
+
default:
|
|
964
|
+
return new F(
|
|
965
|
+
O.CAMERA_ERROR,
|
|
966
|
+
z.UNKNOWN_ERROR
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
const O = {
|
|
972
|
+
GRANTED: "granted",
|
|
973
|
+
NO_CAMERA: "no-camera",
|
|
974
|
+
CAMERA_ERROR: "camera-error",
|
|
975
|
+
DENIED: "denied"
|
|
976
|
+
}, z = {
|
|
977
|
+
GRANTED: "granted",
|
|
978
|
+
ABORT_ERROR: "abort-error",
|
|
979
|
+
NOT_ALLOWED_ERROR: "not-allowed-error",
|
|
980
|
+
NOT_FOUND_ERROR: "not-found-error",
|
|
981
|
+
NOT_READABLE_ERROR: "not-readable-error",
|
|
982
|
+
OVERCONSTRAINED_ERROR: "overconstrained-error",
|
|
983
|
+
SECURITY_ERROR: "security-error",
|
|
984
|
+
UNKNOWN_ERROR: "unknown-error"
|
|
985
|
+
};
|
|
986
|
+
class F {
|
|
987
|
+
cameraAccessResult;
|
|
988
|
+
detailedCameraAccessResult;
|
|
989
|
+
isGranted;
|
|
990
|
+
constructor(e, t) {
|
|
991
|
+
this.cameraAccessResult = e, this.isGranted = e === O.GRANTED, this.detailedCameraAccessResult = t;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
function Fe() {
|
|
995
|
+
return crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
996
|
+
}
|
|
997
|
+
function X() {
|
|
998
|
+
const a = "verify-correlation-id";
|
|
999
|
+
let e = sessionStorage.getItem(a);
|
|
1000
|
+
return e || (e = Fe(), e = e.replaceAll("-", ""), sessionStorage.setItem(a, e)), e;
|
|
1001
|
+
}
|
|
1002
|
+
function Wt(a) {
|
|
1003
|
+
sessionStorage.setItem("verify-event-info-account-hash", a.accountHash), sessionStorage.setItem("verify-event-info-verification-session-id", a.verificationSessionId);
|
|
1004
|
+
}
|
|
1005
|
+
function j() {
|
|
1006
|
+
const a = sessionStorage.getItem("verify-event-info-account-hash") || "", e = sessionStorage.getItem("verify-event-info-verification-session-id") || "";
|
|
1007
|
+
return {
|
|
1008
|
+
accountHash: a,
|
|
1009
|
+
verificationSessionId: e
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
function qt(a) {
|
|
1013
|
+
const e = a.getFullYear(), t = (a.getMonth() + 1).toString().padStart(2, "0"), i = a.getDate().toString().padStart(2, "0"), r = a.getHours().toString().padStart(2, "0"), n = a.getMinutes().toString().padStart(2, "0"), f = a.getSeconds().toString().padStart(2, "0"), l = a.getMilliseconds().toString().padStart(3, "0"), s = -a.getTimezoneOffset(), c = s >= 0 ? "+" : "-", d = Math.abs(s), u = Math.floor(d / 60).toString().padStart(2, "0"), h = (d % 60).toString().padStart(2, "0");
|
|
1014
|
+
return `${e}-${t}-${i}T${r}:${n}:${f}.${l}${c}${u}:${h}`;
|
|
1015
|
+
}
|
|
1016
|
+
class Kt {
|
|
1017
|
+
kinesisClient = null;
|
|
1018
|
+
kinesisConfig = null;
|
|
1019
|
+
sequenceNumber = 1;
|
|
1020
|
+
serverTimeOffset = 0;
|
|
1021
|
+
eventQueue = [];
|
|
1022
|
+
environment;
|
|
1023
|
+
constructor(e) {
|
|
1024
|
+
this.environment = e.getCurrentEnvironment();
|
|
1025
|
+
}
|
|
1026
|
+
initialize(e) {
|
|
1027
|
+
if (!e) {
|
|
1028
|
+
this.logMessage("warn", "Kinesis configuration not available - events will not be sent"), this.kinesisClient = null, this.kinesisConfig = null;
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
this.kinesisConfig = e;
|
|
1032
|
+
const t = Date.now(), i = new Date(e.serverTime).getTime();
|
|
1033
|
+
this.serverTimeOffset = i - t, this.logMessage("log", `Server time offset: ${this.serverTimeOffset}ms`), this.kinesisClient = new At({
|
|
1034
|
+
region: e.region,
|
|
1035
|
+
credentials: {
|
|
1036
|
+
accessKeyId: e.accessKeyId,
|
|
1037
|
+
secretAccessKey: e.secretAccessKey,
|
|
1038
|
+
sessionToken: e.sessionToken
|
|
1039
|
+
},
|
|
1040
|
+
retryMode: "standard",
|
|
1041
|
+
maxAttempts: 3
|
|
1042
|
+
}), this.logMessage("log", `Kinesis client initialized for stream: ${e.streamName}`);
|
|
1043
|
+
}
|
|
1044
|
+
async sendEvent(e, t, i, r) {
|
|
1045
|
+
const n = r ?? Date.now(), f = new Date(n + this.serverTimeOffset), l = f.toISOString(), s = qt(f), c = {
|
|
1046
|
+
type: e,
|
|
1047
|
+
absolute_utc_time: l,
|
|
1048
|
+
absolute_local_time: s,
|
|
1049
|
+
sequence_number: this.sequenceNumber++,
|
|
1050
|
+
args: i
|
|
1051
|
+
};
|
|
1052
|
+
if (this.eventQueue.push(c), !t)
|
|
1053
|
+
return !0;
|
|
1054
|
+
if (!this.kinesisClient || !this.kinesisConfig)
|
|
1055
|
+
return this.logMessage("warn", `Kinesis not configured - event '${e}' queued but not sent`), !1;
|
|
1056
|
+
const d = j();
|
|
1057
|
+
let u = !0;
|
|
1058
|
+
for (; this.eventQueue.length > 0; ) {
|
|
1059
|
+
const h = this.eventQueue.shift();
|
|
1060
|
+
h.source_id = t, h.account_hash = d.accountHash, h.region = this.kinesisConfig.logicalRegion, h.host = this.kinesisConfig.domain, h.pid = X();
|
|
1061
|
+
try {
|
|
1062
|
+
const p = new xt({
|
|
1063
|
+
StreamName: this.kinesisConfig.streamName,
|
|
1064
|
+
PartitionKey: h.source_id,
|
|
1065
|
+
Data: new TextEncoder().encode(JSON.stringify(h))
|
|
1066
|
+
}), v = await this.kinesisClient.send(p);
|
|
1067
|
+
this.logMessage("log", `Event '${h.type}' sent to Kinesis:`, {
|
|
1068
|
+
sequenceNumber: v.SequenceNumber,
|
|
1069
|
+
shardId: v.ShardId
|
|
1070
|
+
});
|
|
1071
|
+
} catch (p) {
|
|
1072
|
+
this.logMessage("warn", `Failed to send event '${h.type}' to Kinesis:`, p), u = !1;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return u;
|
|
1076
|
+
}
|
|
1077
|
+
logMessage(e, t, i) {
|
|
1078
|
+
this.environment !== "production" && console[e](`[KinesisService] ${t}`, i || "");
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
class Jt {
|
|
1082
|
+
timers = /* @__PURE__ */ new Map();
|
|
1083
|
+
stats = [];
|
|
1084
|
+
kinesisService;
|
|
1085
|
+
sessionIdRef;
|
|
1086
|
+
constructor(e, t) {
|
|
1087
|
+
this.kinesisService = e, this.sessionIdRef = t;
|
|
1088
|
+
}
|
|
1089
|
+
startTimer(e) {
|
|
1090
|
+
this.timers.set(e, performance.now());
|
|
1091
|
+
}
|
|
1092
|
+
sendStatsCheckpoint() {
|
|
1093
|
+
const e = this.getAllStatsAsObject();
|
|
1094
|
+
Object.keys(e).length > 0 && this.kinesisService.sendEvent("StatsCollected", this.sessionIdRef.current, e);
|
|
1095
|
+
}
|
|
1096
|
+
stopTimer(e, t = !0) {
|
|
1097
|
+
const i = this.timers.get(e);
|
|
1098
|
+
if (i === void 0)
|
|
1099
|
+
return this.stats.push({ type: e, duration: 0 }), t && this.sendStatsCheckpoint(), 0;
|
|
1100
|
+
const r = Math.round(performance.now() - i);
|
|
1101
|
+
return this.stats.push({ type: e, duration: r }), this.timers.delete(e), t && this.sendStatsCheckpoint(), r;
|
|
1102
|
+
}
|
|
1103
|
+
addStat(e, t, i = !0) {
|
|
1104
|
+
this.stats.push({ type: e, duration: Math.round(t) }), i && this.sendStatsCheckpoint();
|
|
1105
|
+
}
|
|
1106
|
+
addStatIfMissing(e, t, i = !0) {
|
|
1107
|
+
this.stats.some((r) => r.type === e) || this.addStat(e, t, i);
|
|
1108
|
+
}
|
|
1109
|
+
async forceSendStats() {
|
|
1110
|
+
const e = this.getAllStatsAsObject();
|
|
1111
|
+
return console.log("Force sending stats:", e), Object.keys(e).length > 0 ? await this.kinesisService.sendEvent("StatsCollected", this.sessionIdRef.current, e) : !0;
|
|
1112
|
+
}
|
|
1113
|
+
getAllStats() {
|
|
1114
|
+
return [...this.stats];
|
|
1115
|
+
}
|
|
1116
|
+
getAllStatsAsObject() {
|
|
1117
|
+
const e = {};
|
|
1118
|
+
for (const t of this.stats)
|
|
1119
|
+
e[t.type] = t.duration;
|
|
1120
|
+
return e;
|
|
1121
|
+
}
|
|
1122
|
+
reset() {
|
|
1123
|
+
this.timers.clear(), this.stats.length = 0;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
class Yt {
|
|
1127
|
+
cameraSdk;
|
|
1128
|
+
kinesisService;
|
|
1129
|
+
statsService = null;
|
|
1130
|
+
apiBaseUrl;
|
|
1131
|
+
livenessCheckType = void 0;
|
|
1132
|
+
mediaPipeInitPromise = null;
|
|
1133
|
+
faceDetectionServiceModule = null;
|
|
1134
|
+
videoRecorderServiceModule = null;
|
|
1135
|
+
// Signal piped through to every fetch issued by this service so the host component can
|
|
1136
|
+
// abort in-flight init / capture-image / capture-video calls on unmount. The Verification
|
|
1137
|
+
// page sets this from its lifecycle AbortController; if nobody sets it, signal is undefined
|
|
1138
|
+
// and fetches behave as before.
|
|
1139
|
+
abortSignal = void 0;
|
|
1140
|
+
accessToken = void 0;
|
|
1141
|
+
constructor(e, t) {
|
|
1142
|
+
this.cameraSdk = new $t(), this.apiBaseUrl = t.getApiBaseUrl(), this.kinesisService = e;
|
|
1143
|
+
}
|
|
1144
|
+
setAbortSignal(e) {
|
|
1145
|
+
this.abortSignal = e;
|
|
1146
|
+
}
|
|
1147
|
+
getAccessToken() {
|
|
1148
|
+
return this.accessToken;
|
|
1149
|
+
}
|
|
1150
|
+
preloadMediaPipe() {
|
|
1151
|
+
this.mediaPipeInitPromise || (this.mediaPipeInitPromise = this.loadAndInitMediaPipe().catch(() => {
|
|
1152
|
+
this.mediaPipeInitPromise = null;
|
|
1153
|
+
}));
|
|
1154
|
+
}
|
|
1155
|
+
async loadAndInitMediaPipe() {
|
|
1156
|
+
this.faceDetectionServiceModule = await import("./faceDetectionService-D37MewxK.js"), await this.faceDetectionServiceModule.faceDetectionService.initialize(), this.livenessCheckType === "basic" && (this.videoRecorderServiceModule = await import("./videoRecorderService-eqEwhEav.js"), await this.videoRecorderServiceModule.videoRecorderService.initialize());
|
|
1157
|
+
}
|
|
1158
|
+
async ensureMediaPipeInitialized() {
|
|
1159
|
+
this.mediaPipeInitPromise || this.preloadMediaPipe(), await this.mediaPipeInitPromise;
|
|
1160
|
+
}
|
|
1161
|
+
async initCoreSession(e, t, i = !1) {
|
|
1162
|
+
sessionStorage.clear();
|
|
1163
|
+
const r = performance.now(), n = await this.callInitCoreSession(e, t, i);
|
|
1164
|
+
return n.sessionToken = t, this.applyInitSessionResponse(n, r);
|
|
1165
|
+
}
|
|
1166
|
+
// Called by RedirectStrategy after it fetches /init-redirect-session itself,
|
|
1167
|
+
// to apply the side effects that belong to the core service (liveness type,
|
|
1168
|
+
// camera init, kinesis bootstrap).
|
|
1169
|
+
async applyInitSessionResponse(e, t) {
|
|
1170
|
+
return e.sessionToken && (this.accessToken = e.sessionToken), this.livenessCheckType = e.livenessCheckType?.toLowerCase(), console.log(`Liveness check type: ${this.livenessCheckType}`), (this.livenessCheckType === "disabled" || this.livenessCheckType === "basic") && await this.cameraSdk.init(), Wt({ accountHash: e.accountHash ?? "", verificationSessionId: e.verificationSessionId }), this.kinesisService.initialize(e.kinesisConfig), this.kinesisService.sendEvent("SessionInitialized", e.verificationSessionId, {
|
|
1171
|
+
duration: performance.now() - t
|
|
1172
|
+
}), e;
|
|
1173
|
+
}
|
|
1174
|
+
async checkCameraAccess() {
|
|
1175
|
+
try {
|
|
1176
|
+
return (await navigator.permissions.query({
|
|
1177
|
+
name: "camera"
|
|
1178
|
+
})).state;
|
|
1179
|
+
} catch {
|
|
1180
|
+
return "unknown";
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
async startCamera(e = void 0) {
|
|
1184
|
+
return await this.cameraSdk.startVideo(e);
|
|
1185
|
+
}
|
|
1186
|
+
async stopCamera() {
|
|
1187
|
+
this.cameraSdk.stopVideo();
|
|
1188
|
+
}
|
|
1189
|
+
async detectFace(e, t = void 0) {
|
|
1190
|
+
let i = 2;
|
|
1191
|
+
const r = await this.cameraSdk.startVideo(
|
|
1192
|
+
t
|
|
1193
|
+
);
|
|
1194
|
+
let n = new _(!1);
|
|
1195
|
+
if (r.isGranted) {
|
|
1196
|
+
if (await this.ensureMediaPipeInitialized(), !this.faceDetectionServiceModule)
|
|
1197
|
+
throw new Error("MediaPipe not initialized");
|
|
1198
|
+
const f = this.cameraSdk.getVideoElement();
|
|
1199
|
+
return f ? (await this.retryInCaseOfError(
|
|
1200
|
+
async () => {
|
|
1201
|
+
const l = await this.faceDetectionServiceModule.faceDetectionService.findBestFaceFrame(
|
|
1202
|
+
f,
|
|
1203
|
+
2e3,
|
|
1204
|
+
0.9
|
|
1205
|
+
);
|
|
1206
|
+
if (!l.hasFace || !l.base64Image)
|
|
1207
|
+
return n.base64Image = l.base64Image, new _(!1);
|
|
1208
|
+
if (this.livenessCheckType === "basic") {
|
|
1209
|
+
if (!this.videoRecorderServiceModule)
|
|
1210
|
+
throw new Error("Video recorder not initialized");
|
|
1211
|
+
const s = await this.videoRecorderServiceModule.videoRecorderService.recordVideo(
|
|
1212
|
+
f,
|
|
1213
|
+
500
|
|
1214
|
+
);
|
|
1215
|
+
if (!s.hasFaceDetected)
|
|
1216
|
+
return n.base64Image = l.base64Image, new _(!1);
|
|
1217
|
+
this.statsService?.startTimer("callCaptureVideoDuration"), n = await this.callCaptureVideo(
|
|
1218
|
+
new Qt(
|
|
1219
|
+
e,
|
|
1220
|
+
s.videoBlob,
|
|
1221
|
+
s.cryptoChain,
|
|
1222
|
+
s.mimeType
|
|
1223
|
+
)
|
|
1224
|
+
), this.statsService?.stopTimer("callCaptureVideoDuration");
|
|
1225
|
+
} else
|
|
1226
|
+
this.statsService?.startTimer("callCaptureImageDuration"), n = await this.callCaptureImage(
|
|
1227
|
+
new Zt(e, l.base64Image)
|
|
1228
|
+
), this.statsService?.stopTimer("callCaptureImageDuration");
|
|
1229
|
+
return n.faceDetected || (n.base64Image = l.base64Image), n;
|
|
1230
|
+
},
|
|
1231
|
+
async (l) => l && l.faceDetected ? { shouldRetry: !1 } : (i--, { shouldRetry: i >= 0 }),
|
|
1232
|
+
() => Promise.resolve({ shouldRetry: !0 })
|
|
1233
|
+
).finally(() => {
|
|
1234
|
+
this.cameraSdk.stopVideo();
|
|
1235
|
+
}), n) : (this.cameraSdk.stopVideo(), new _(!1));
|
|
1236
|
+
}
|
|
1237
|
+
return new _(!1);
|
|
1238
|
+
}
|
|
1239
|
+
async retryInCaseOfError(e, t, i) {
|
|
1240
|
+
let r = 2;
|
|
1241
|
+
do
|
|
1242
|
+
try {
|
|
1243
|
+
const n = await e();
|
|
1244
|
+
if ((await t(n)).shouldRetry)
|
|
1245
|
+
r = 2;
|
|
1246
|
+
else break;
|
|
1247
|
+
} catch (n) {
|
|
1248
|
+
if (!(await i(n)).shouldRetry)
|
|
1249
|
+
break;
|
|
1250
|
+
if (r--, r <= 0)
|
|
1251
|
+
throw n;
|
|
1252
|
+
}
|
|
1253
|
+
while (!0);
|
|
1254
|
+
}
|
|
1255
|
+
resolveTechUserId() {
|
|
1256
|
+
let t = new URL(window.location.href).searchParams.get("reTechUserId");
|
|
1257
|
+
return t != null ? localStorage.setItem("verify-tech-user-id", t) : (t = localStorage.getItem("verify-tech-user-id"), t == null && (t = Fe(), localStorage.setItem("verify-tech-user-id", t))), t;
|
|
1258
|
+
}
|
|
1259
|
+
async callInitCoreSession(e, t, i) {
|
|
1260
|
+
const r = await fetch(
|
|
1261
|
+
`${this.apiBaseUrl}/api/v1/verification/init-session`,
|
|
1262
|
+
{
|
|
1263
|
+
method: "POST",
|
|
1264
|
+
headers: {
|
|
1265
|
+
"Content-Type": "application/json",
|
|
1266
|
+
"x-verify-correlation-id": X(),
|
|
1267
|
+
"x-verify-tech-user-id": this.resolveTechUserId(),
|
|
1268
|
+
Authorization: `Bearer ${t}`
|
|
1269
|
+
},
|
|
1270
|
+
body: JSON.stringify({ verificationSessionId: e, localTime: (/* @__PURE__ */ new Date()).toISOString(), isHeadless: i }),
|
|
1271
|
+
signal: this.abortSignal
|
|
1272
|
+
}
|
|
1273
|
+
);
|
|
1274
|
+
return this.parseInitResponse(r);
|
|
1275
|
+
}
|
|
1276
|
+
async parseInitResponse(e) {
|
|
1277
|
+
if (!e.ok) {
|
|
1278
|
+
if (e.status === 429) throw new H();
|
|
1279
|
+
const i = (await e.text()).trim() || "An error occurred during initializing the session!";
|
|
1280
|
+
throw e.status >= 400 && e.status < 500 ? new ve(i, e.status) : new Error(i);
|
|
1281
|
+
}
|
|
1282
|
+
return e.json();
|
|
1283
|
+
}
|
|
1284
|
+
async callVerify(e, t, i) {
|
|
1285
|
+
let r = `${this.apiBaseUrl}/api/v1/verification/verify`;
|
|
1286
|
+
const n = await fetch(r, {
|
|
1287
|
+
method: "POST",
|
|
1288
|
+
headers: {
|
|
1289
|
+
"Content-Type": "application/json",
|
|
1290
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
1291
|
+
"x-verify-correlation-id": X(),
|
|
1292
|
+
"x-verify-account-hash": j().accountHash,
|
|
1293
|
+
"x-verify-event-source-id": j().verificationSessionId
|
|
1294
|
+
},
|
|
1295
|
+
body: JSON.stringify({ verificationSessionId: e, failedReason: t }),
|
|
1296
|
+
signal: i ?? this.abortSignal
|
|
1297
|
+
});
|
|
1298
|
+
if (!n.ok)
|
|
1299
|
+
throw n.status === 429 ? new H() : new Error(await n.text() || "Verification failed");
|
|
1300
|
+
}
|
|
1301
|
+
async callCaptureImage(e) {
|
|
1302
|
+
const t = await fetch(
|
|
1303
|
+
`${this.apiBaseUrl}/api/v1/verification/capture-image`,
|
|
1304
|
+
{
|
|
1305
|
+
method: "POST",
|
|
1306
|
+
headers: {
|
|
1307
|
+
"Content-Type": "application/json",
|
|
1308
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
1309
|
+
"x-verify-correlation-id": X(),
|
|
1310
|
+
"x-verify-account-hash": j().accountHash,
|
|
1311
|
+
"x-verify-event-source-id": j().verificationSessionId
|
|
1312
|
+
},
|
|
1313
|
+
body: JSON.stringify(e),
|
|
1314
|
+
signal: this.abortSignal
|
|
1315
|
+
}
|
|
1316
|
+
);
|
|
1317
|
+
if (!t.ok)
|
|
1318
|
+
throw t.status === 429 ? new H() : t.status === 400 ? new Error(await t.text()) : new Error("An error occurred during capturing image!");
|
|
1319
|
+
return new _(!0);
|
|
1320
|
+
}
|
|
1321
|
+
async callCaptureVideo(e) {
|
|
1322
|
+
const t = await this.blobToBase64(e.videoBlob), i = await fetch(
|
|
1323
|
+
`${this.apiBaseUrl}/api/v1/verification/capture-video`,
|
|
1324
|
+
{
|
|
1325
|
+
method: "POST",
|
|
1326
|
+
headers: {
|
|
1327
|
+
"Content-Type": "application/json",
|
|
1328
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
1329
|
+
"x-verify-correlation-id": X(),
|
|
1330
|
+
"x-verify-account-hash": j().accountHash,
|
|
1331
|
+
"x-verify-event-source-id": j().verificationSessionId
|
|
1332
|
+
},
|
|
1333
|
+
body: JSON.stringify({
|
|
1334
|
+
verificationSessionId: e.verificationSessionId,
|
|
1335
|
+
base64Video: t,
|
|
1336
|
+
cryptoChain: e.cryptoChain,
|
|
1337
|
+
mimeType: e.mimeType
|
|
1338
|
+
}),
|
|
1339
|
+
signal: this.abortSignal
|
|
1340
|
+
}
|
|
1341
|
+
);
|
|
1342
|
+
if (!i.ok)
|
|
1343
|
+
throw i.status === 429 ? new H() : i.status === 400 ? new Error(await i.text()) : new Error("An error occurred during capturing video!");
|
|
1344
|
+
return new _(!0);
|
|
1345
|
+
}
|
|
1346
|
+
async blobToBase64(e) {
|
|
1347
|
+
if (!e || e.size === 0)
|
|
1348
|
+
throw new Error("Empty or invalid video blob");
|
|
1349
|
+
return new Promise((t, i) => {
|
|
1350
|
+
const r = new FileReader();
|
|
1351
|
+
r.onloadend = () => {
|
|
1352
|
+
const n = r.result;
|
|
1353
|
+
if (!n || typeof n != "string") {
|
|
1354
|
+
i(new Error("Failed to read blob as data URL"));
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const f = n.split(",");
|
|
1358
|
+
if (f.length !== 2 || !f[1]) {
|
|
1359
|
+
i(new Error("Invalid data URL format"));
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
const l = f[1];
|
|
1363
|
+
console.log(`Video blob converted to base64: ${(l.length * 0.75 / 1024).toFixed(2)} KB`), t(l);
|
|
1364
|
+
}, r.onerror = () => {
|
|
1365
|
+
i(new Error(`FileReader error: ${r.error?.message || "Unknown error"}`));
|
|
1366
|
+
}, r.readAsDataURL(e);
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
class Zt {
|
|
1371
|
+
verificationSessionId;
|
|
1372
|
+
base64Image;
|
|
1373
|
+
constructor(e, t) {
|
|
1374
|
+
this.verificationSessionId = e, this.base64Image = t;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
class Qt {
|
|
1378
|
+
verificationSessionId;
|
|
1379
|
+
videoBlob;
|
|
1380
|
+
cryptoChain;
|
|
1381
|
+
mimeType;
|
|
1382
|
+
constructor(e, t, i, r) {
|
|
1383
|
+
this.verificationSessionId = e, this.videoBlob = t, this.cryptoChain = i, this.mimeType = r;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
class _ {
|
|
1387
|
+
faceDetected;
|
|
1388
|
+
base64Image;
|
|
1389
|
+
constructor(e, t = void 0) {
|
|
1390
|
+
this.faceDetected = e, this.base64Image = t;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
const Xt = ({
|
|
1394
|
+
isOpen: a,
|
|
1395
|
+
uniqueId: e,
|
|
1396
|
+
onPermissionGranted: t,
|
|
1397
|
+
onPermissionDenied: i,
|
|
1398
|
+
verificationService: r
|
|
1399
|
+
}) => {
|
|
1400
|
+
if (!a) return;
|
|
1401
|
+
const n = W(), f = Q(n).typography;
|
|
1402
|
+
return r.checkCameraAccess().then((l) => {
|
|
1403
|
+
if (l === "granted") {
|
|
1404
|
+
t();
|
|
1405
|
+
return;
|
|
1406
|
+
} else if (l === "denied") {
|
|
1407
|
+
i();
|
|
1408
|
+
return;
|
|
1409
|
+
} else
|
|
1410
|
+
r.startCamera().then((s) => {
|
|
1411
|
+
if (s.isGranted) {
|
|
1412
|
+
r.stopCamera(), t();
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
i();
|
|
1416
|
+
}).catch(() => {
|
|
1417
|
+
i();
|
|
1418
|
+
});
|
|
1419
|
+
}), /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ o(
|
|
1420
|
+
$,
|
|
1421
|
+
{
|
|
1422
|
+
sx: {
|
|
1423
|
+
display: "flex",
|
|
1424
|
+
textAlign: "center !important",
|
|
1425
|
+
justifyContent: "center !important",
|
|
1426
|
+
alignItems: "center !important"
|
|
1427
|
+
},
|
|
1428
|
+
children: /* @__PURE__ */ S(
|
|
1429
|
+
L,
|
|
1430
|
+
{
|
|
1431
|
+
direction: "column",
|
|
1432
|
+
spacing: 2,
|
|
1433
|
+
sx: {
|
|
1434
|
+
textAlign: "center",
|
|
1435
|
+
justifyContent: "center",
|
|
1436
|
+
alignItems: "center"
|
|
1437
|
+
},
|
|
1438
|
+
children: [
|
|
1439
|
+
/* @__PURE__ */ o(
|
|
1440
|
+
C,
|
|
1441
|
+
{
|
|
1442
|
+
variant: "h2",
|
|
1443
|
+
component: "div",
|
|
1444
|
+
sx: {
|
|
1445
|
+
fontSize: f.h2.fontSize,
|
|
1446
|
+
fontWeight: "bold",
|
|
1447
|
+
color: "#263235"
|
|
1448
|
+
},
|
|
1449
|
+
children: "Verify you are not a robot with a selfie"
|
|
1450
|
+
}
|
|
1451
|
+
),
|
|
1452
|
+
/* @__PURE__ */ S(
|
|
1453
|
+
C,
|
|
1454
|
+
{
|
|
1455
|
+
variant: "body2",
|
|
1456
|
+
component: "div",
|
|
1457
|
+
sx: {
|
|
1458
|
+
fontSize: f.body2.fontSize,
|
|
1459
|
+
color: "#263235"
|
|
1460
|
+
},
|
|
1461
|
+
children: [
|
|
1462
|
+
"Realeyes needs brief camera access ",
|
|
1463
|
+
/* @__PURE__ */ o("br", {}),
|
|
1464
|
+
"Please, click “Allow”"
|
|
1465
|
+
]
|
|
1466
|
+
}
|
|
1467
|
+
),
|
|
1468
|
+
/* @__PURE__ */ o("div", { className: "face-icon-container", children: /* @__PURE__ */ o(
|
|
1469
|
+
"img",
|
|
1470
|
+
{
|
|
1471
|
+
src: se,
|
|
1472
|
+
alt: "Face Verification",
|
|
1473
|
+
className: "face-icon"
|
|
1474
|
+
}
|
|
1475
|
+
) }),
|
|
1476
|
+
/* @__PURE__ */ S(
|
|
1477
|
+
L,
|
|
1478
|
+
{
|
|
1479
|
+
direction: "column",
|
|
1480
|
+
sx: {
|
|
1481
|
+
textAlign: "center",
|
|
1482
|
+
justifyContent: "center",
|
|
1483
|
+
alignItems: "center"
|
|
1484
|
+
},
|
|
1485
|
+
children: [
|
|
1486
|
+
/* @__PURE__ */ o(
|
|
1487
|
+
C,
|
|
1488
|
+
{
|
|
1489
|
+
variant: "body2",
|
|
1490
|
+
component: "div",
|
|
1491
|
+
sx: {
|
|
1492
|
+
flexGrow: 1,
|
|
1493
|
+
fontSize: f.body2.fontSize,
|
|
1494
|
+
fontWeight: "bold",
|
|
1495
|
+
color: "#263235"
|
|
1496
|
+
},
|
|
1497
|
+
children: "No one will ever see you"
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
/* @__PURE__ */ o(
|
|
1501
|
+
C,
|
|
1502
|
+
{
|
|
1503
|
+
variant: "body2",
|
|
1504
|
+
component: "div",
|
|
1505
|
+
sx: {
|
|
1506
|
+
flexGrow: 1,
|
|
1507
|
+
fontSize: f.body2.fontSize,
|
|
1508
|
+
fontWeight: "bold",
|
|
1509
|
+
color: "#263235"
|
|
1510
|
+
},
|
|
1511
|
+
children: "Your data is encrypted"
|
|
1512
|
+
}
|
|
1513
|
+
)
|
|
1514
|
+
]
|
|
1515
|
+
}
|
|
1516
|
+
),
|
|
1517
|
+
/* @__PURE__ */ o(ee, { uniqueId: e })
|
|
1518
|
+
]
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1521
|
+
}
|
|
1522
|
+
) });
|
|
1523
|
+
}, ge = ({ isOpen: a, text: e }) => {
|
|
1524
|
+
if (a)
|
|
1525
|
+
return e || (e = "Loading..."), /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ o(
|
|
1526
|
+
$,
|
|
1527
|
+
{
|
|
1528
|
+
sx: {
|
|
1529
|
+
display: "flex",
|
|
1530
|
+
textAlign: "center !important",
|
|
1531
|
+
justifyContent: "center !important",
|
|
1532
|
+
alignItems: "center !important"
|
|
1533
|
+
},
|
|
1534
|
+
children: /* @__PURE__ */ S(
|
|
1535
|
+
ye,
|
|
1536
|
+
{
|
|
1537
|
+
display: "flex",
|
|
1538
|
+
flexDirection: "column",
|
|
1539
|
+
alignItems: "center",
|
|
1540
|
+
justifyContent: "center",
|
|
1541
|
+
minHeight: "100px",
|
|
1542
|
+
minWidth: "300px",
|
|
1543
|
+
children: [
|
|
1544
|
+
/* @__PURE__ */ o(Se, { sx: { color: "#10b981" } }),
|
|
1545
|
+
/* @__PURE__ */ o(C, { variant: "body2", sx: { mt: 2 }, children: e })
|
|
1546
|
+
]
|
|
1547
|
+
}
|
|
1548
|
+
)
|
|
1549
|
+
}
|
|
1550
|
+
) });
|
|
1551
|
+
}, ei = ({
|
|
1552
|
+
isOpen: a,
|
|
1553
|
+
uniqueId: e,
|
|
1554
|
+
onTryAgain: t
|
|
1555
|
+
}) => {
|
|
1556
|
+
if (!a) return;
|
|
1557
|
+
const i = W(), r = Q(i).typography;
|
|
1558
|
+
return /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ o(
|
|
1559
|
+
$,
|
|
1560
|
+
{
|
|
1561
|
+
sx: {
|
|
1562
|
+
display: "flex",
|
|
1563
|
+
textAlign: "center !important",
|
|
1564
|
+
justifyContent: "center !important",
|
|
1565
|
+
alignItems: "center !important"
|
|
1566
|
+
},
|
|
1567
|
+
children: /* @__PURE__ */ S(
|
|
1568
|
+
L,
|
|
1569
|
+
{
|
|
1570
|
+
direction: "column",
|
|
1571
|
+
spacing: 2,
|
|
1572
|
+
sx: {
|
|
1573
|
+
textAlign: "center",
|
|
1574
|
+
justifyContent: "center",
|
|
1575
|
+
alignItems: "center"
|
|
1576
|
+
},
|
|
1577
|
+
children: [
|
|
1578
|
+
/* @__PURE__ */ o(
|
|
1579
|
+
C,
|
|
1580
|
+
{
|
|
1581
|
+
variant: "h2",
|
|
1582
|
+
component: "div",
|
|
1583
|
+
sx: {
|
|
1584
|
+
flexGrow: 1,
|
|
1585
|
+
fontSize: r.h2.fontSize,
|
|
1586
|
+
fontWeight: "bold",
|
|
1587
|
+
color: "#263235"
|
|
1588
|
+
},
|
|
1589
|
+
children: "Verify you are not a robot with a selfie"
|
|
1590
|
+
}
|
|
1591
|
+
),
|
|
1592
|
+
/* @__PURE__ */ S(
|
|
1593
|
+
C,
|
|
1594
|
+
{
|
|
1595
|
+
variant: "body2",
|
|
1596
|
+
component: "div",
|
|
1597
|
+
sx: {
|
|
1598
|
+
fontSize: r.body2.fontSize,
|
|
1599
|
+
color: "#263235"
|
|
1600
|
+
},
|
|
1601
|
+
children: [
|
|
1602
|
+
"Realeyes needs brief camera access ",
|
|
1603
|
+
/* @__PURE__ */ o("br", {}),
|
|
1604
|
+
'Please allow your camera and click on "Try Again".'
|
|
1605
|
+
]
|
|
1606
|
+
}
|
|
1607
|
+
),
|
|
1608
|
+
/* @__PURE__ */ o("div", { className: "face-icon-container", children: /* @__PURE__ */ o(
|
|
1609
|
+
"img",
|
|
1610
|
+
{
|
|
1611
|
+
src: se,
|
|
1612
|
+
alt: "Face Verification",
|
|
1613
|
+
className: "face-icon"
|
|
1614
|
+
}
|
|
1615
|
+
) }),
|
|
1616
|
+
/* @__PURE__ */ S(
|
|
1617
|
+
L,
|
|
1618
|
+
{
|
|
1619
|
+
direction: "column",
|
|
1620
|
+
sx: {
|
|
1621
|
+
textAlign: "center",
|
|
1622
|
+
justifyContent: "center",
|
|
1623
|
+
alignItems: "center"
|
|
1624
|
+
},
|
|
1625
|
+
children: [
|
|
1626
|
+
/* @__PURE__ */ o(
|
|
1627
|
+
C,
|
|
1628
|
+
{
|
|
1629
|
+
variant: "body2",
|
|
1630
|
+
component: "div",
|
|
1631
|
+
sx: {
|
|
1632
|
+
flexGrow: 1,
|
|
1633
|
+
fontSize: r.body2.fontSize,
|
|
1634
|
+
fontWeight: "bold",
|
|
1635
|
+
color: "#263235"
|
|
1636
|
+
},
|
|
1637
|
+
children: "No one will ever see you"
|
|
1638
|
+
}
|
|
1639
|
+
),
|
|
1640
|
+
/* @__PURE__ */ o(
|
|
1641
|
+
C,
|
|
1642
|
+
{
|
|
1643
|
+
variant: "body2",
|
|
1644
|
+
component: "div",
|
|
1645
|
+
sx: {
|
|
1646
|
+
flexGrow: 1,
|
|
1647
|
+
fontSize: r.body2.fontSize,
|
|
1648
|
+
fontWeight: "bold",
|
|
1649
|
+
color: "#263235"
|
|
1650
|
+
},
|
|
1651
|
+
children: "Your data is encrypted"
|
|
1652
|
+
}
|
|
1653
|
+
)
|
|
1654
|
+
]
|
|
1655
|
+
}
|
|
1656
|
+
),
|
|
1657
|
+
/* @__PURE__ */ o("button", { className: "realeyes-btn", onClick: t, children: "Try Again" }),
|
|
1658
|
+
/* @__PURE__ */ o(ee, { uniqueId: e })
|
|
1659
|
+
]
|
|
1660
|
+
}
|
|
1661
|
+
)
|
|
1662
|
+
}
|
|
1663
|
+
) });
|
|
1664
|
+
}, ti = ({
|
|
1665
|
+
isOpen: a,
|
|
1666
|
+
uniqueId: e,
|
|
1667
|
+
onFaceDetected: t,
|
|
1668
|
+
onNoFaceDetected: i,
|
|
1669
|
+
detectFace: r
|
|
1670
|
+
}) => {
|
|
1671
|
+
const n = W(), f = Q(n).typography;
|
|
1672
|
+
return Z(() => {
|
|
1673
|
+
a && r().then((l) => {
|
|
1674
|
+
l.faceDetected ? t() : i(l.base64Image);
|
|
1675
|
+
});
|
|
1676
|
+
}, [a]), a ? /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ o(
|
|
1677
|
+
$,
|
|
1678
|
+
{
|
|
1679
|
+
sx: {
|
|
1680
|
+
display: "flex",
|
|
1681
|
+
textAlign: "center !important",
|
|
1682
|
+
justifyContent: "center !important",
|
|
1683
|
+
alignItems: "center !important"
|
|
1684
|
+
},
|
|
1685
|
+
children: /* @__PURE__ */ S(
|
|
1686
|
+
L,
|
|
1687
|
+
{
|
|
1688
|
+
direction: "column",
|
|
1689
|
+
spacing: 2,
|
|
1690
|
+
sx: {
|
|
1691
|
+
textAlign: "center",
|
|
1692
|
+
justifyContent: "center",
|
|
1693
|
+
alignItems: "center"
|
|
1694
|
+
},
|
|
1695
|
+
children: [
|
|
1696
|
+
/* @__PURE__ */ o(
|
|
1697
|
+
C,
|
|
1698
|
+
{
|
|
1699
|
+
variant: "h2",
|
|
1700
|
+
component: "div",
|
|
1701
|
+
sx: {
|
|
1702
|
+
flexGrow: 1,
|
|
1703
|
+
fontSize: f.h2.fontSize,
|
|
1704
|
+
fontWeight: "bold",
|
|
1705
|
+
color: "#263235"
|
|
1706
|
+
},
|
|
1707
|
+
children: "Verification in progress"
|
|
1708
|
+
}
|
|
1709
|
+
),
|
|
1710
|
+
/* @__PURE__ */ o("div", { className: "face-icon-container", children: /* @__PURE__ */ o(
|
|
1711
|
+
"img",
|
|
1712
|
+
{
|
|
1713
|
+
src: se,
|
|
1714
|
+
alt: "Face Verification",
|
|
1715
|
+
className: "face-icon"
|
|
1716
|
+
}
|
|
1717
|
+
) }),
|
|
1718
|
+
/* @__PURE__ */ o(Se, { size: "4rem", sx: { color: "#10b981" } }),
|
|
1719
|
+
/* @__PURE__ */ o(ee, { uniqueId: e })
|
|
1720
|
+
]
|
|
1721
|
+
}
|
|
1722
|
+
)
|
|
1723
|
+
}
|
|
1724
|
+
) }) : null;
|
|
1725
|
+
}, ii = ({
|
|
1726
|
+
isOpen: a,
|
|
1727
|
+
uniqueId: e,
|
|
1728
|
+
onRetry: t,
|
|
1729
|
+
base64Image: i
|
|
1730
|
+
}) => {
|
|
1731
|
+
if (!a) return;
|
|
1732
|
+
const r = W(), n = Q(r).typography;
|
|
1733
|
+
return /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ o(
|
|
1734
|
+
$,
|
|
1735
|
+
{
|
|
1736
|
+
sx: {
|
|
1737
|
+
display: "flex",
|
|
1738
|
+
textAlign: "center !important",
|
|
1739
|
+
justifyContent: "center !important",
|
|
1740
|
+
alignItems: "center !important"
|
|
1741
|
+
},
|
|
1742
|
+
children: /* @__PURE__ */ S(
|
|
1743
|
+
L,
|
|
1744
|
+
{
|
|
1745
|
+
direction: "column",
|
|
1746
|
+
spacing: 2,
|
|
1747
|
+
sx: {
|
|
1748
|
+
textAlign: "center",
|
|
1749
|
+
justifyContent: "center",
|
|
1750
|
+
alignItems: "center"
|
|
1751
|
+
},
|
|
1752
|
+
children: [
|
|
1753
|
+
/* @__PURE__ */ o(
|
|
1754
|
+
C,
|
|
1755
|
+
{
|
|
1756
|
+
variant: "h2",
|
|
1757
|
+
component: "div",
|
|
1758
|
+
sx: {
|
|
1759
|
+
flexGrow: 1,
|
|
1760
|
+
fontSize: n.h2.fontSize,
|
|
1761
|
+
fontWeight: "bold",
|
|
1762
|
+
color: "#263235"
|
|
1763
|
+
},
|
|
1764
|
+
children: "We cannot see your face"
|
|
1765
|
+
}
|
|
1766
|
+
),
|
|
1767
|
+
/* @__PURE__ */ o(
|
|
1768
|
+
L,
|
|
1769
|
+
{
|
|
1770
|
+
direction: "column",
|
|
1771
|
+
spacing: 0,
|
|
1772
|
+
sx: {
|
|
1773
|
+
textAlign: "center",
|
|
1774
|
+
justifyContent: "center",
|
|
1775
|
+
alignItems: "center"
|
|
1776
|
+
},
|
|
1777
|
+
children: /* @__PURE__ */ o(
|
|
1778
|
+
"img",
|
|
1779
|
+
{
|
|
1780
|
+
src: i,
|
|
1781
|
+
alt: "No face detected",
|
|
1782
|
+
style: { maxWidth: "300px" }
|
|
1783
|
+
}
|
|
1784
|
+
)
|
|
1785
|
+
}
|
|
1786
|
+
),
|
|
1787
|
+
/* @__PURE__ */ o(
|
|
1788
|
+
C,
|
|
1789
|
+
{
|
|
1790
|
+
variant: "body2",
|
|
1791
|
+
component: "div",
|
|
1792
|
+
sx: {
|
|
1793
|
+
fontSize: n.body2.fontSize,
|
|
1794
|
+
textAlign: "left",
|
|
1795
|
+
color: "#263235"
|
|
1796
|
+
},
|
|
1797
|
+
style: { marginTop: 10 },
|
|
1798
|
+
children: /* @__PURE__ */ S("ul", { style: { paddingLeft: 0 }, children: [
|
|
1799
|
+
/* @__PURE__ */ S("li", { children: [
|
|
1800
|
+
/* @__PURE__ */ o("b", { children: "Look" }),
|
|
1801
|
+
" into the camera"
|
|
1802
|
+
] }),
|
|
1803
|
+
/* @__PURE__ */ S("li", { children: [
|
|
1804
|
+
"Check your ",
|
|
1805
|
+
/* @__PURE__ */ o("b", { children: "ligthning" })
|
|
1806
|
+
] }),
|
|
1807
|
+
/* @__PURE__ */ S("li", { children: [
|
|
1808
|
+
"Make sure only this page ",
|
|
1809
|
+
/* @__PURE__ */ o("b", { children: "uses your camera" })
|
|
1810
|
+
] })
|
|
1811
|
+
] })
|
|
1812
|
+
}
|
|
1813
|
+
),
|
|
1814
|
+
/* @__PURE__ */ o("button", { className: "realeyes-btn", onClick: t, children: "Retry" }),
|
|
1815
|
+
/* @__PURE__ */ o(ee, { uniqueId: e })
|
|
1816
|
+
]
|
|
1817
|
+
}
|
|
1818
|
+
)
|
|
1819
|
+
}
|
|
1820
|
+
) });
|
|
1821
|
+
}, ri = ({
|
|
1822
|
+
isOpen: a,
|
|
1823
|
+
onOk: e
|
|
1824
|
+
}) => {
|
|
1825
|
+
const [t, i] = D(60), r = W(), n = Q(r).typography;
|
|
1826
|
+
return Z(() => {
|
|
1827
|
+
if (!a) {
|
|
1828
|
+
i(60);
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
const f = setInterval(() => {
|
|
1832
|
+
i((l) => l <= 1 ? (clearInterval(f), e(), 0) : l - 1);
|
|
1833
|
+
}, 1e3);
|
|
1834
|
+
return () => clearInterval(f);
|
|
1835
|
+
}, [a, e]), a ? /* @__PURE__ */ o(q, { open: a, children: /* @__PURE__ */ o(
|
|
1836
|
+
$,
|
|
1837
|
+
{
|
|
1838
|
+
sx: {
|
|
1839
|
+
display: "flex",
|
|
1840
|
+
textAlign: "center !important",
|
|
1841
|
+
justifyContent: "center !important",
|
|
1842
|
+
alignItems: "center !important"
|
|
1843
|
+
},
|
|
1844
|
+
children: /* @__PURE__ */ S(
|
|
1845
|
+
L,
|
|
1846
|
+
{
|
|
1847
|
+
direction: "column",
|
|
1848
|
+
spacing: 3,
|
|
1849
|
+
sx: {
|
|
1850
|
+
textAlign: "center",
|
|
1851
|
+
justifyContent: "center",
|
|
1852
|
+
alignItems: "center"
|
|
1853
|
+
},
|
|
1854
|
+
children: [
|
|
1855
|
+
/* @__PURE__ */ o(
|
|
1856
|
+
C,
|
|
1857
|
+
{
|
|
1858
|
+
variant: "h2",
|
|
1859
|
+
component: "div",
|
|
1860
|
+
sx: {
|
|
1861
|
+
fontSize: n.h2.fontSize,
|
|
1862
|
+
fontWeight: "700",
|
|
1863
|
+
color: "#263235"
|
|
1864
|
+
},
|
|
1865
|
+
children: "Session timeout"
|
|
1866
|
+
}
|
|
1867
|
+
),
|
|
1868
|
+
/* @__PURE__ */ o(
|
|
1869
|
+
C,
|
|
1870
|
+
{
|
|
1871
|
+
variant: "body2",
|
|
1872
|
+
component: "div",
|
|
1873
|
+
sx: {
|
|
1874
|
+
fontSize: n.body2.fontSize,
|
|
1875
|
+
color: "#263235"
|
|
1876
|
+
},
|
|
1877
|
+
children: "Your session has expired. Please try again."
|
|
1878
|
+
}
|
|
1879
|
+
),
|
|
1880
|
+
/* @__PURE__ */ S(
|
|
1881
|
+
C,
|
|
1882
|
+
{
|
|
1883
|
+
variant: "body2",
|
|
1884
|
+
component: "div",
|
|
1885
|
+
sx: {
|
|
1886
|
+
fontSize: n.body2.fontSize,
|
|
1887
|
+
color: "#666666"
|
|
1888
|
+
},
|
|
1889
|
+
children: [
|
|
1890
|
+
"Redirecting in ",
|
|
1891
|
+
t,
|
|
1892
|
+
" seconds..."
|
|
1893
|
+
]
|
|
1894
|
+
}
|
|
1895
|
+
),
|
|
1896
|
+
/* @__PURE__ */ o("button", { className: "realeyes-btn", onClick: e, children: "OK" })
|
|
1897
|
+
]
|
|
1898
|
+
}
|
|
1899
|
+
)
|
|
1900
|
+
}
|
|
1901
|
+
) }) : null;
|
|
1902
|
+
}, ni = ft(() => import("./livenessCheckDialog-D7nIgy_n.js")), si = vt({
|
|
1903
|
+
palette: {
|
|
1904
|
+
mode: "light"
|
|
1905
|
+
},
|
|
1906
|
+
typography: {
|
|
1907
|
+
fontFamily: "Lexend Deca",
|
|
1908
|
+
h1: {
|
|
1909
|
+
fontSize: "3rem",
|
|
1910
|
+
lineHeight: "1.2"
|
|
1911
|
+
},
|
|
1912
|
+
h2: {
|
|
1913
|
+
fontSize: "2rem",
|
|
1914
|
+
lineHeight: "1.2"
|
|
1915
|
+
},
|
|
1916
|
+
body1: {
|
|
1917
|
+
fontSize: "1.125rem",
|
|
1918
|
+
lineHeight: "1.2"
|
|
1919
|
+
},
|
|
1920
|
+
body2: {
|
|
1921
|
+
fontSize: "0.9rem",
|
|
1922
|
+
lineHeight: "1.2"
|
|
1923
|
+
}
|
|
1924
|
+
},
|
|
1925
|
+
components: {
|
|
1926
|
+
MuiBackdrop: {
|
|
1927
|
+
styleOverrides: {
|
|
1928
|
+
root: {
|
|
1929
|
+
backgroundColor: "rgba(0,0,0,0)"
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
}), oi = 300 * 1e3, Ve = {
|
|
1935
|
+
SkipIfCameraGranted: "1",
|
|
1936
|
+
AlwaysSkip: "2"
|
|
1937
|
+
}, ai = ({ strategy: a, config: e, consentSkipMode: t, headless: i = !1, onServiceError: r, headlessCallbacks: n, showVerificationSessionId: f = !1 }) => {
|
|
1938
|
+
const [l, s] = D(!1), [c, d] = D(!1), [u, h] = D(!1), [p, v] = D(!1), [U, te] = D(!1), [oe, K] = D(!1), [_e, ae] = D(!1), [Ee, we] = D(!1), [be, Ge] = D(!0), [Be, Ce] = D(!1), [Re, ce] = D(!1), [le, A] = D(""), [je, De] = D(!0), [de, ue] = D(null), ie = R(2), me = R(3), Ie = R(0), Ae = R(0), [He, $e] = D(""), [J, We] = D("..."), Y = R(!1), G = R(null), fe = R(!1), E = R("..."), xe = R(""), Te = R(""), w = R(new Kt(e)).current, g = R(new Jt(w, E)).current, I = R(new Yt(w, e)).current;
|
|
1939
|
+
I.statsService = g;
|
|
1940
|
+
const Me = R(r);
|
|
1941
|
+
Me.current = r;
|
|
1942
|
+
const P = (m) => {
|
|
1943
|
+
console.error(`Error during ${m}`), Me.current?.(m);
|
|
1944
|
+
}, re = R(n);
|
|
1945
|
+
re.current = n;
|
|
1946
|
+
const he = R(null);
|
|
1947
|
+
Z(() => {
|
|
1948
|
+
const m = new AbortController();
|
|
1949
|
+
if (he.current = m, G.current)
|
|
1950
|
+
I.setAbortSignal(m.signal);
|
|
1951
|
+
else {
|
|
1952
|
+
const b = new AbortController();
|
|
1953
|
+
I.setAbortSignal(b.signal), w.sendEvent("PageLoaded", null, {}), i || qe(), G.current = ke(
|
|
1954
|
+
() => Je(),
|
|
1955
|
+
1e3,
|
|
1956
|
+
4,
|
|
1957
|
+
(T) => {
|
|
1958
|
+
Ie.current = T;
|
|
1959
|
+
}
|
|
1960
|
+
).finally(() => {
|
|
1961
|
+
I.setAbortSignal(he.current?.signal);
|
|
1962
|
+
}).catch(() => {
|
|
1963
|
+
P("init-session");
|
|
1964
|
+
}), i && Ke();
|
|
1965
|
+
}
|
|
1966
|
+
const y = setTimeout(async () => {
|
|
1967
|
+
if (!fe.current) {
|
|
1968
|
+
g.stopTimer("consentDuration", !1), g.stopTimer("permissionDuration", !1), g.stopTimer("livenessDuration", !1), g.stopTimer("captureImageDuration", !1), g.stopTimer("initDuration", !1);
|
|
1969
|
+
const b = window.__pageLoadStart;
|
|
1970
|
+
b !== void 0 && g.addStat("sessionDuration", performance.now() - b, !1), await g.forceSendStats(), w.sendEvent("ClientSideFailed", E.current, { reason: "session_timeout" }), we(!0), x("SESSION_TIMEOUT", { status: "timeout" });
|
|
1971
|
+
}
|
|
1972
|
+
}, oi);
|
|
1973
|
+
return () => {
|
|
1974
|
+
clearTimeout(y), m.abort();
|
|
1975
|
+
};
|
|
1976
|
+
}, []), Z(() => {
|
|
1977
|
+
if (!c) return;
|
|
1978
|
+
let m = 0;
|
|
1979
|
+
const y = requestAnimationFrame(() => {
|
|
1980
|
+
m = requestAnimationFrame(() => {
|
|
1981
|
+
g.startTimer("consentDuration");
|
|
1982
|
+
});
|
|
1983
|
+
});
|
|
1984
|
+
return () => {
|
|
1985
|
+
cancelAnimationFrame(y), m && cancelAnimationFrame(m);
|
|
1986
|
+
};
|
|
1987
|
+
}, [c]), Z(() => {
|
|
1988
|
+
if (!oe) return;
|
|
1989
|
+
let m = 0;
|
|
1990
|
+
const y = requestAnimationFrame(() => {
|
|
1991
|
+
m = requestAnimationFrame(() => {
|
|
1992
|
+
g.startTimer("permissionDuration");
|
|
1993
|
+
});
|
|
1994
|
+
});
|
|
1995
|
+
return () => {
|
|
1996
|
+
cancelAnimationFrame(y), m && cancelAnimationFrame(m);
|
|
1997
|
+
};
|
|
1998
|
+
}, [oe]), Z(() => {
|
|
1999
|
+
if (!u) return;
|
|
2000
|
+
let m = 0;
|
|
2001
|
+
const y = requestAnimationFrame(() => {
|
|
2002
|
+
m = requestAnimationFrame(() => {
|
|
2003
|
+
g.startTimer("livenessDuration");
|
|
2004
|
+
});
|
|
2005
|
+
});
|
|
2006
|
+
return () => {
|
|
2007
|
+
cancelAnimationFrame(y), m && cancelAnimationFrame(m);
|
|
2008
|
+
};
|
|
2009
|
+
}, [u]);
|
|
2010
|
+
const qe = async () => {
|
|
2011
|
+
switch (Ge(!1), t) {
|
|
2012
|
+
case Ve.SkipIfCameraGranted: {
|
|
2013
|
+
const m = await I.checkCameraAccess();
|
|
2014
|
+
m !== "granted" ? (w.sendEvent("ConsentShown", E.current, { consentMode: t, cameraAccess: m }), d(!0)) : (w.sendEvent("ConsentSkipped", E.current, { contentMode: t, cameraAccess: m }), K(!0));
|
|
2015
|
+
break;
|
|
2016
|
+
}
|
|
2017
|
+
case Ve.AlwaysSkip:
|
|
2018
|
+
w.sendEvent("ConsentSkipped", E.current, { consentMode: t }), K(!0);
|
|
2019
|
+
break;
|
|
2020
|
+
default:
|
|
2021
|
+
w.sendEvent("ConsentShown", E.current, { consentMode: t }), d(!0);
|
|
2022
|
+
}
|
|
2023
|
+
}, Ke = async () => {
|
|
2024
|
+
re.current?.onVerificationStarting?.();
|
|
2025
|
+
try {
|
|
2026
|
+
await G.current;
|
|
2027
|
+
} catch {
|
|
2028
|
+
}
|
|
2029
|
+
if (Y.current)
|
|
2030
|
+
try {
|
|
2031
|
+
re.current?.onBeforeCameraAccess?.();
|
|
2032
|
+
const m = await I.checkCameraAccess();
|
|
2033
|
+
if (m === "unknown" || m !== "granted") {
|
|
2034
|
+
const b = await I.startCamera();
|
|
2035
|
+
if (await I.stopCamera(), b === "unknown" || !b.isGranted) {
|
|
2036
|
+
w.sendEvent("CameraPermissionDenied", E.current, {}), await x("CAMERA_ACCESS_ERROR", { status: "camera_error" });
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
re.current?.onAfterCameraAccess?.(), w.sendEvent("CameraPermissionGranted", E.current, {}), g.startTimer("captureImageDuration");
|
|
2041
|
+
const y = await Oe();
|
|
2042
|
+
g.stopTimer("captureImageDuration"), y.faceDetected ? await x() : (w.sendEvent("ClientSideFailed", E.current, { reason: "no_face" }), await x());
|
|
2043
|
+
} catch {
|
|
2044
|
+
P("unknown");
|
|
2045
|
+
}
|
|
2046
|
+
}, ke = async (m, y = 1e3, b = 4, T) => {
|
|
2047
|
+
const ne = Date.now();
|
|
2048
|
+
let V = y, k = 1;
|
|
2049
|
+
for (; ; )
|
|
2050
|
+
try {
|
|
2051
|
+
return await m();
|
|
2052
|
+
} catch {
|
|
2053
|
+
const lt = Date.now() - ne;
|
|
2054
|
+
if (k > b)
|
|
2055
|
+
throw new Error(`Retry limit exceeded after ${lt / 1e3} seconds`);
|
|
2056
|
+
console.warn(`Retrying (attempt: ${k}) in ${V / 1e3} seconds...`), ue(`Retrying (attempt: ${k}) in ${V / 1e3} seconds...`), await new Promise(async (dt) => {
|
|
2057
|
+
for (let pe = 0; pe < V / 1e3; pe++)
|
|
2058
|
+
ue(
|
|
2059
|
+
`Retrying (attempt: ${k}) in ${V / 1e3} / ${V / 1e3 - pe} seconds...`
|
|
2060
|
+
), await new Promise((ut) => setTimeout(ut, 1e3));
|
|
2061
|
+
setTimeout(dt, 0);
|
|
2062
|
+
}), V *= 2, T?.(k), k++;
|
|
2063
|
+
}
|
|
2064
|
+
}, Je = async () => {
|
|
2065
|
+
A(""), g.startTimer("initDuration");
|
|
2066
|
+
const m = window.__pageLoadStart;
|
|
2067
|
+
m && g.addStat("pageLoadDuration", performance.now() - m);
|
|
2068
|
+
try {
|
|
2069
|
+
const y = await a.initSession(I);
|
|
2070
|
+
if (E.current = y.verificationSessionId, We(y.verificationSessionId), I.livenessCheckType = y.livenessCheckType?.toLowerCase(), y.livenessCheckConfig) {
|
|
2071
|
+
s(!0), Te.current = y.livenessCheckConfig.aws_project_region, xe.current = y.livenessCheckSessionId;
|
|
2072
|
+
const { Amplify: b } = await import("aws-amplify");
|
|
2073
|
+
b.configure(y.livenessCheckConfig);
|
|
2074
|
+
} else
|
|
2075
|
+
I.preloadMediaPipe();
|
|
2076
|
+
Y.current = !0, g.stopTimer("initDuration");
|
|
2077
|
+
} catch (y) {
|
|
2078
|
+
if (y instanceof H)
|
|
2079
|
+
throw y;
|
|
2080
|
+
y instanceof DOMException && y.name === "AbortError" || (y instanceof ve ? (A(y.message), De(!1), P("init-session")) : y instanceof Error ? (A(y.message), P("init-session")) : (A("An error occurred during initializing the session!"), P("init-session")));
|
|
2081
|
+
}
|
|
2082
|
+
}, Oe = async () => {
|
|
2083
|
+
A("");
|
|
2084
|
+
try {
|
|
2085
|
+
return await I.detectFace(E.current);
|
|
2086
|
+
} catch (m) {
|
|
2087
|
+
if (m instanceof H)
|
|
2088
|
+
throw m;
|
|
2089
|
+
m instanceof ve ? (A(m.message), De(!1)) : m instanceof Error ? A(m.message) : A("An error occurred during face detection!"), P("capture-image");
|
|
2090
|
+
}
|
|
2091
|
+
return new _(!1);
|
|
2092
|
+
}, x = async (m, y = { status: "completed" }) => {
|
|
2093
|
+
if (!fe.current) {
|
|
2094
|
+
g.startTimer("getResultDuration"), fe.current = !0, ce(!0);
|
|
2095
|
+
try {
|
|
2096
|
+
await ke(
|
|
2097
|
+
async () => {
|
|
2098
|
+
try {
|
|
2099
|
+
const b = await a.fetchResult(
|
|
2100
|
+
E.current,
|
|
2101
|
+
I,
|
|
2102
|
+
m,
|
|
2103
|
+
he.current?.signal
|
|
2104
|
+
);
|
|
2105
|
+
g.stopTimer("getResultDuration", !1);
|
|
2106
|
+
const T = g.getAllStatsAsObject(), ne = (T.consentDuration ?? 0) + (T.permissionDuration ?? 0) + (T.livenessDuration ?? 0), V = (T.initDuration ?? 0) + (T.pageLoadDuration ?? 0) + (T.getResultDuration ?? 0) + (T.captureImageDuration ?? 0);
|
|
2107
|
+
g.addStat("totalUserInteractionDuration", ne, !1), g.addStat("totalDuration", ne + V, !1);
|
|
2108
|
+
const k = window.__pageLoadStart;
|
|
2109
|
+
k !== void 0 && g.addStatIfMissing("sessionDuration", performance.now() - k, !1), g.addStat("throttlingInitRetryCount", Ie.current, !1), g.addStat("throttlingGetResultRetryCount", Ae.current, !1), g.addStat("cameraPermissionRetryCount", 3 - me.current, !1), g.addStat("noFaceRetryCount", 2 - ie.current, !1), await g.forceSendStats() || console.error("[StatsService] forceSendStats failed - StatsCollected event not sent to Kinesis"), await w.sendEvent(
|
|
2110
|
+
"VerificationCompleted",
|
|
2111
|
+
E.current,
|
|
2112
|
+
b.logPayload ?? {}
|
|
2113
|
+
), g.reset(), a.complete(b, y);
|
|
2114
|
+
} catch (b) {
|
|
2115
|
+
if (b instanceof H) throw b;
|
|
2116
|
+
console.error("completeVerification failed:", b), A("An error occurred during the verification!"), ce(!1), P("verify");
|
|
2117
|
+
}
|
|
2118
|
+
},
|
|
2119
|
+
1e3,
|
|
2120
|
+
4,
|
|
2121
|
+
(b) => {
|
|
2122
|
+
Ae.current = b;
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2125
|
+
} catch (b) {
|
|
2126
|
+
console.error("completeVerification throttling retry exhausted:", b), m !== "THROTTLING_LIMIT" && a.onThrottlingLimitExhausted?.(E.current, I), A("Service is currently busy. Please try again later."), ce(!1), P("verify");
|
|
2127
|
+
} finally {
|
|
2128
|
+
ue(null);
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}, Ye = async () => {
|
|
2132
|
+
Y.current || (Ce(!0), await G.current, Ce(!1)), g.stopTimer("consentDuration"), w.sendEvent("ConsentClosed", E.current, { result: "accepted" }), d(!1), K(!0);
|
|
2133
|
+
}, Ze = async () => {
|
|
2134
|
+
Y.current || await G.current, g.stopTimer("consentDuration"), w.sendEvent("ConsentClosed", E.current, { result: "declined" }), w.sendEvent("ClientSideFailed", E.current, { reason: "no_consent" }), d(!1), await x("CONSENT_DECLINED", { status: "consent_declined" });
|
|
2135
|
+
}, Qe = async () => {
|
|
2136
|
+
Y.current || await G.current, g.stopTimer("permissionDuration"), w.sendEvent("CameraPermissionGranted", E.current, {}), K(!1), l ? (w.sendEvent("LivenessCheckStarted", E.current, {}), h(!0)) : (g.startTimer("captureImageDuration"), v(!0));
|
|
2137
|
+
}, Xe = async () => {
|
|
2138
|
+
Y.current || await G.current, g.stopTimer("permissionDuration"), w.sendEvent("CameraPermissionDenied", E.current, {}), K(!1), ae(!0);
|
|
2139
|
+
}, et = async () => {
|
|
2140
|
+
if (me.current <= 0) {
|
|
2141
|
+
ae(!1), await x("CAMERA_ACCESS_ERROR", { status: "camera_error" });
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
me.current -= 1, ae(!1), K(!0);
|
|
2145
|
+
}, tt = async () => {
|
|
2146
|
+
g.stopTimer("captureImageDuration"), v(!1), await x();
|
|
2147
|
+
}, it = async (m) => {
|
|
2148
|
+
g.stopTimer("captureImageDuration"), v(!1), $e(m), ie.current <= 0 ? (w.sendEvent("ClientSideFailed", E.current, { reason: "no_face" }), await x()) : (ie.current -= 1, te(!0));
|
|
2149
|
+
}, rt = async () => {
|
|
2150
|
+
te(!1), ie.current >= 0 ? (g.startTimer("captureImageDuration"), v(!0)) : await x();
|
|
2151
|
+
}, nt = async () => {
|
|
2152
|
+
console.log("Liveness check completed"), g.stopTimer("livenessDuration"), w.sendEvent("LivenessCheckPassed", E.current, {}), h(!1), await x();
|
|
2153
|
+
}, st = async (m) => {
|
|
2154
|
+
if (console.error("Liveness check failed:", m), m.state === "CAMERA_ACCESS_ERROR") {
|
|
2155
|
+
A("Please allow the camera for the liveness test!");
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
if (m.state === "MOBILE_LANDSCAPE_ERROR") {
|
|
2159
|
+
A("Please use the mobile in portrait mode!");
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
g.stopTimer("livenessDuration"), w.sendEvent("LivenessCheckFailed", E.current, { reason: m.state }), h(!1), await x(m.state, { status: "liveness_error" });
|
|
2163
|
+
}, ot = async () => {
|
|
2164
|
+
g.stopTimer("livenessDuration"), w.sendEvent("ClientSideFailed", E.current, { reason: "liveness_cancelled" }), h(!1), await x("LIVENESS_CANCELED", { status: "liveness_canceled" });
|
|
2165
|
+
}, at = async () => {
|
|
2166
|
+
we(!1), a.onSessionTimeout?.(E.current);
|
|
2167
|
+
};
|
|
2168
|
+
if (i)
|
|
2169
|
+
return null;
|
|
2170
|
+
let B;
|
|
2171
|
+
return de ? B = /* @__PURE__ */ S(Ne, { open: !!de, maxWidth: "xs", fullWidth: !0, children: [
|
|
2172
|
+
/* @__PURE__ */ o(Le, { children: "Server is busy" }),
|
|
2173
|
+
/* @__PURE__ */ o(Ue, { children: /* @__PURE__ */ o(Pe, { children: de }) })
|
|
2174
|
+
] }) : le ? B = /* @__PURE__ */ S(Ne, { open: !!le, maxWidth: "xs", fullWidth: !0, children: [
|
|
2175
|
+
/* @__PURE__ */ o(Le, { children: "Error" }),
|
|
2176
|
+
/* @__PURE__ */ o(Ue, { children: /* @__PURE__ */ o(Pe, { children: le }) }),
|
|
2177
|
+
je && /* @__PURE__ */ o(wt, { children: /* @__PURE__ */ o(bt, { onClick: () => window.location.reload(), variant: "contained", color: "primary", children: "Retry" }) })
|
|
2178
|
+
] }) : Ee ? B = /* @__PURE__ */ o(ri, { isOpen: Ee, onOk: at }) : be ? B = /* @__PURE__ */ o(ge, { isOpen: be }) : Re ? B = /* @__PURE__ */ o(ge, { isOpen: Re, text: "Verifying..." }) : B = /* @__PURE__ */ S(ye, { children: [
|
|
2179
|
+
/* @__PURE__ */ o(
|
|
2180
|
+
Nt,
|
|
2181
|
+
{
|
|
2182
|
+
isOpen: c,
|
|
2183
|
+
onAccept: Ye,
|
|
2184
|
+
onClose: Ze,
|
|
2185
|
+
uniqueId: J,
|
|
2186
|
+
isConsentButtonLoading: Be,
|
|
2187
|
+
showVerificationSessionId: f
|
|
2188
|
+
}
|
|
2189
|
+
),
|
|
2190
|
+
/* @__PURE__ */ o(
|
|
2191
|
+
Xt,
|
|
2192
|
+
{
|
|
2193
|
+
isOpen: oe,
|
|
2194
|
+
uniqueId: J,
|
|
2195
|
+
onPermissionGranted: Qe,
|
|
2196
|
+
onPermissionDenied: Xe,
|
|
2197
|
+
verificationService: I
|
|
2198
|
+
}
|
|
2199
|
+
),
|
|
2200
|
+
/* @__PURE__ */ o(
|
|
2201
|
+
ei,
|
|
2202
|
+
{
|
|
2203
|
+
isOpen: _e,
|
|
2204
|
+
uniqueId: J,
|
|
2205
|
+
onTryAgain: et
|
|
2206
|
+
}
|
|
2207
|
+
),
|
|
2208
|
+
/* @__PURE__ */ o(
|
|
2209
|
+
ti,
|
|
2210
|
+
{
|
|
2211
|
+
isOpen: p,
|
|
2212
|
+
uniqueId: J,
|
|
2213
|
+
detectFace: Oe,
|
|
2214
|
+
onFaceDetected: tt,
|
|
2215
|
+
onNoFaceDetected: it
|
|
2216
|
+
}
|
|
2217
|
+
),
|
|
2218
|
+
/* @__PURE__ */ o(
|
|
2219
|
+
ii,
|
|
2220
|
+
{
|
|
2221
|
+
isOpen: U,
|
|
2222
|
+
uniqueId: J,
|
|
2223
|
+
onRetry: rt,
|
|
2224
|
+
base64Image: He
|
|
2225
|
+
}
|
|
2226
|
+
),
|
|
2227
|
+
l && u && /* @__PURE__ */ o(ht, { fallback: /* @__PURE__ */ o(ge, { isOpen: !0 }), children: /* @__PURE__ */ o(
|
|
2228
|
+
ni,
|
|
2229
|
+
{
|
|
2230
|
+
isOpen: u,
|
|
2231
|
+
uniqueId: J,
|
|
2232
|
+
livenessSessionId: xe.current,
|
|
2233
|
+
livenessRegion: Te.current,
|
|
2234
|
+
onLivenessComplete: nt,
|
|
2235
|
+
onLivenessError: st,
|
|
2236
|
+
onClose: ot
|
|
2237
|
+
}
|
|
2238
|
+
) })
|
|
2239
|
+
] }), /* @__PURE__ */ S(yt, { theme: si, children: [
|
|
2240
|
+
/* @__PURE__ */ o(St, {}),
|
|
2241
|
+
/* @__PURE__ */ o(Et, { children: B })
|
|
2242
|
+
] });
|
|
2243
|
+
}, Ci = ({ sessionId: a, accessToken: e, onVerificationCompleted: t, consentSkipMode: i, headless: r = !1, onServiceError: n, headlessCallbacks: f, showVerificationSessionId: l, region: s, createConfig: c }) => {
|
|
2244
|
+
if (!Mt(s))
|
|
2245
|
+
throw new Error(
|
|
2246
|
+
`VerifyVerifier: invalid "region" prop ${JSON.stringify(s)}. Expected one of: ${ze.map((h) => `"${h}"`).join(", ")}.`
|
|
2247
|
+
);
|
|
2248
|
+
const d = R(c ? c(s) : new kt(s)), u = R(new Tt(a, e, t, r));
|
|
2249
|
+
return /* @__PURE__ */ o(ai, { strategy: u.current, config: d.current, consentSkipMode: i, headless: r, onServiceError: n, headlessCallbacks: f, showVerificationSessionId: l });
|
|
2250
|
+
};
|
|
2251
|
+
export {
|
|
2252
|
+
Ot as C,
|
|
2253
|
+
ee as D,
|
|
2254
|
+
q as R,
|
|
2255
|
+
Ci as V,
|
|
2256
|
+
Ve as a,
|
|
2257
|
+
ze as b
|
|
2258
|
+
};
|