veryfi-lens-wasm 2.0.1 → 2.0.3
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/components/creditCard.js +3 -2
- package/components/exitButton.js +16 -7
- package/components/frame.js +15 -8
- package/components/greenBox.js +19 -9
- package/components/longPreview.js +2 -1
- package/components/stitchingButton.js +1 -1
- package/components/video.js +23 -9
- package/package.json +1 -1
- package/veryfi-lens.js +187 -101
package/components/creditCard.js
CHANGED
|
@@ -25,14 +25,14 @@ export const createCreditCardComponent = (container) => {
|
|
|
25
25
|
|
|
26
26
|
'--card-text-color': 'white',
|
|
27
27
|
'--card-number-font-size': '24px',
|
|
28
|
-
'--card-number-margin': '90px 0 10px
|
|
28
|
+
'--card-number-margin': '90px 0 10px 65px',
|
|
29
29
|
|
|
30
30
|
'--card-info-margin-left': '20px',
|
|
31
31
|
'--card-info-margin-right': '20px',
|
|
32
32
|
'--card-info-font-weight': 'bold',
|
|
33
33
|
|
|
34
34
|
'--flip-message-width': '300px',
|
|
35
|
-
'--flip-message-bottom': '
|
|
35
|
+
'--flip-message-bottom': '22%',
|
|
36
36
|
'--flip-message-font-size': '25px',
|
|
37
37
|
'--flip-message-z-index': '152',
|
|
38
38
|
};
|
|
@@ -118,6 +118,7 @@ export const createCreditCardComponent = (container) => {
|
|
|
118
118
|
flipMessage.style.cssText = `
|
|
119
119
|
position: absolute;
|
|
120
120
|
display: block;
|
|
121
|
+
text-transform: uppercase;
|
|
121
122
|
width: var(--flip-message-width);
|
|
122
123
|
bottom: var(--flip-message-bottom);
|
|
123
124
|
left: 50%;
|
package/components/exitButton.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const createExitButton = (container, options, removeOverlay) => {
|
|
2
|
-
const { setter, redirectUrl } = options;
|
|
2
|
+
const { setter, redirectUrl, lensFlavor } = options;
|
|
3
3
|
|
|
4
4
|
const button = document.createElement('a');
|
|
5
5
|
button.id = 'veryfi-exit-button';
|
|
@@ -43,12 +43,21 @@ export const createExitButton = (container, options, removeOverlay) => {
|
|
|
43
43
|
const isLandscape = window.innerWidth > window.innerHeight;
|
|
44
44
|
|
|
45
45
|
if (isMobile && isLandscape) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
if (lensFlavor === 'credit_card') {
|
|
47
|
+
// Special positioning for credit card in landscape
|
|
48
|
+
button.style.position = 'fixed';
|
|
49
|
+
button.style.top = '20px';
|
|
50
|
+
button.style.right = '20px';
|
|
51
|
+
button.style.left = 'unset';
|
|
52
|
+
button.style.bottom = 'unset';
|
|
53
|
+
button.style.zIndex = '9999'; // Ensure it's above the card outline
|
|
54
|
+
} else {
|
|
55
|
+
// Default landscape positioning for other flavors
|
|
56
|
+
button.style.right = '50px';
|
|
57
|
+
button.style.top = 'calc(20vh - 20px)';
|
|
58
|
+
button.style.left = 'unset';
|
|
59
|
+
button.style.bottom = 'unset';
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
button.addEventListener('mouseenter', () => {
|
package/components/frame.js
CHANGED
|
@@ -18,20 +18,27 @@ export const createFrame = (container) => {
|
|
|
18
18
|
const handleResize = () => {
|
|
19
19
|
const isMobile = window.innerWidth <= 768 || window.innerHeight <= 768;
|
|
20
20
|
|
|
21
|
-
if (isMobile) {
|
|
21
|
+
if (!isMobile) {
|
|
22
|
+
if (container.dataset.fullscreen === 'true') {
|
|
23
|
+
frameCanvas.style.position = 'fixed';
|
|
24
|
+
frameCanvas.style.width = '100vw';
|
|
25
|
+
frameCanvas.style.height = '100vh';
|
|
26
|
+
frameCanvas.style.maxWidth = 'none';
|
|
27
|
+
frameCanvas.style.top = '0';
|
|
28
|
+
frameCanvas.style.left = '0';
|
|
29
|
+
} else {
|
|
30
|
+
frameCanvas.style.width = '100%';
|
|
31
|
+
frameCanvas.style.height = 'auto';
|
|
32
|
+
frameCanvas.style.maxWidth = '500px';
|
|
33
|
+
frameCanvas.style.position = 'absolute';
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
22
36
|
frameCanvas.style.width = '100vw';
|
|
23
37
|
frameCanvas.style.height = '100vh';
|
|
24
38
|
frameCanvas.style.maxWidth = '100%';
|
|
25
39
|
frameCanvas.style.position = 'fixed';
|
|
26
40
|
frameCanvas.style.top = '0';
|
|
27
41
|
frameCanvas.style.left = '0';
|
|
28
|
-
} else {
|
|
29
|
-
frameCanvas.style.width = '100%';
|
|
30
|
-
frameCanvas.style.height = 'auto';
|
|
31
|
-
frameCanvas.style.maxWidth = '500px';
|
|
32
|
-
frameCanvas.style.position = 'absolute';
|
|
33
|
-
frameCanvas.style.top = '';
|
|
34
|
-
frameCanvas.style.left = '';
|
|
35
42
|
}
|
|
36
43
|
};
|
|
37
44
|
|
package/components/greenBox.js
CHANGED
|
@@ -16,8 +16,26 @@ export const createGreenBox = (container) => {
|
|
|
16
16
|
|
|
17
17
|
const handleResize = () => {
|
|
18
18
|
const isMobile = window.innerWidth <= 768 || window.innerHeight <= 768;
|
|
19
|
+
const isFullscreen = container.dataset.fullscreen === 'true';
|
|
19
20
|
|
|
20
|
-
if (isMobile) {
|
|
21
|
+
if (!isMobile) {
|
|
22
|
+
if (isFullscreen) {
|
|
23
|
+
boxCanvas.style.position = 'fixed';
|
|
24
|
+
boxCanvas.style.width = '100vw';
|
|
25
|
+
boxCanvas.style.height = '100vh';
|
|
26
|
+
boxCanvas.style.maxWidth = 'none';
|
|
27
|
+
boxCanvas.style.top = '0';
|
|
28
|
+
boxCanvas.style.left = '0';
|
|
29
|
+
} else {
|
|
30
|
+
boxCanvas.style.width = '100%';
|
|
31
|
+
boxCanvas.style.height = 'auto';
|
|
32
|
+
boxCanvas.style.maxWidth = '500px';
|
|
33
|
+
boxCanvas.style.position = 'absolute';
|
|
34
|
+
boxCanvas.style.objectFit = 'cover';
|
|
35
|
+
boxCanvas.style.top = '';
|
|
36
|
+
boxCanvas.style.left = '';
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
21
39
|
boxCanvas.style.width = '100vw';
|
|
22
40
|
boxCanvas.style.height = '100vh';
|
|
23
41
|
boxCanvas.style.maxWidth = '100%';
|
|
@@ -25,14 +43,6 @@ export const createGreenBox = (container) => {
|
|
|
25
43
|
boxCanvas.style.objectFit = 'cover';
|
|
26
44
|
boxCanvas.style.top = '0';
|
|
27
45
|
boxCanvas.style.left = '0';
|
|
28
|
-
} else {
|
|
29
|
-
boxCanvas.style.width = '100%';
|
|
30
|
-
boxCanvas.style.height = 'auto';
|
|
31
|
-
boxCanvas.style.maxWidth = '500px';
|
|
32
|
-
boxCanvas.style.position = 'absolute';
|
|
33
|
-
boxCanvas.style.objectFit = 'cover';
|
|
34
|
-
boxCanvas.style.top = '';
|
|
35
|
-
boxCanvas.style.left = '';
|
|
36
46
|
}
|
|
37
47
|
};
|
|
38
48
|
|
|
@@ -9,7 +9,7 @@ export const createLongPreview = (parentContainer) => {
|
|
|
9
9
|
width: '80px',
|
|
10
10
|
height: '70vh',
|
|
11
11
|
borderRadius: '4px',
|
|
12
|
-
zIndex: '
|
|
12
|
+
zIndex: '1000',
|
|
13
13
|
overflowY: 'hidden',
|
|
14
14
|
border: '1px solid #86efac',
|
|
15
15
|
};
|
|
@@ -20,6 +20,7 @@ export const createLongPreview = (parentContainer) => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
parentContainer.appendChild(container);
|
|
23
|
+
container.style.zIndex = '1000';
|
|
23
24
|
|
|
24
25
|
const updatePreview = (data, originalWidth, originalHeight) => {
|
|
25
26
|
while (container.firstChild) {
|
package/components/video.js
CHANGED
|
@@ -18,28 +18,42 @@ export const createVideo = (container) => {
|
|
|
18
18
|
|
|
19
19
|
const handleResize = () => {
|
|
20
20
|
const isMobile = window.innerWidth <= 768 || window.innerHeight <= 768;
|
|
21
|
+
const isFullscreen = container.dataset.fullscreen === 'true';
|
|
22
|
+
const isLandscape = window.innerWidth > window.innerHeight;
|
|
21
23
|
|
|
22
24
|
if (!isMobile) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (isFullscreen) {
|
|
26
|
+
video.style.position = 'fixed';
|
|
27
|
+
video.style.width = '100vw';
|
|
28
|
+
video.style.height = '100vh';
|
|
29
|
+
video.style.maxWidth = 'none';
|
|
30
|
+
video.style.top = '0';
|
|
31
|
+
video.style.left = '0';
|
|
32
|
+
video.style.transform = isLandscape ? 'none' : 'scale(1.5)';
|
|
33
|
+
video.style.objectFit = isLandscape ? 'cover' : 'cover';
|
|
34
|
+
} else {
|
|
35
|
+
video.style.position = 'absolute';
|
|
36
|
+
video.style.width = '100%';
|
|
37
|
+
video.style.height = 'auto';
|
|
38
|
+
video.style.maxWidth = '500px';
|
|
39
|
+
video.style.top = '';
|
|
40
|
+
video.style.left = '';
|
|
41
|
+
video.style.transform = 'none';
|
|
42
|
+
video.style.objectFit = 'cover';
|
|
43
|
+
}
|
|
30
44
|
} else {
|
|
31
|
-
// console.log('mobile');
|
|
32
45
|
video.style.position = 'fixed';
|
|
33
46
|
video.style.top = '0';
|
|
34
47
|
video.style.left = '0';
|
|
35
48
|
video.style.width = '100vw';
|
|
36
49
|
video.style.height = '100vh';
|
|
37
50
|
video.style.maxWidth = 'none';
|
|
51
|
+
video.style.transform = 'none';
|
|
52
|
+
video.style.objectFit = 'cover';
|
|
38
53
|
}
|
|
39
54
|
};
|
|
40
55
|
|
|
41
56
|
handleResize();
|
|
42
|
-
|
|
43
57
|
window.addEventListener('resize', handleResize);
|
|
44
58
|
|
|
45
59
|
video.playsInline = true;
|
package/package.json
CHANGED
package/veryfi-lens.js
CHANGED
|
@@ -82,6 +82,7 @@ const VeryfiLens = (function () {
|
|
|
82
82
|
fpPromise: null,
|
|
83
83
|
debug_mode: false,
|
|
84
84
|
enableSubmit: true,
|
|
85
|
+
enableFullScreen: false,
|
|
85
86
|
|
|
86
87
|
// UI Configuration
|
|
87
88
|
docValidation: true,
|
|
@@ -175,12 +176,23 @@ const VeryfiLens = (function () {
|
|
|
175
176
|
}
|
|
176
177
|
const isDesktop = window.screen.width > window.screen.height;
|
|
177
178
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
179
|
+
const isMobile = window.innerWidth <= 768 || window.innerHeight <= 768;
|
|
178
180
|
|
|
179
181
|
let videoConfig = {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
...(isMobile ? {
|
|
183
|
+
width: { ideal: 3840 },
|
|
184
|
+
height: { ideal: 2160 },
|
|
185
|
+
} : lensFlavor === 'long_document' ? {
|
|
186
|
+
width: { ideal: 3840 },
|
|
187
|
+
height: { ideal: 2160 },
|
|
188
|
+
} : {
|
|
189
|
+
width: { ideal: 1920 },
|
|
190
|
+
height: { ideal: 1080 },
|
|
191
|
+
}),
|
|
192
|
+
facingMode: "environment",
|
|
182
193
|
advanced: [{ torch: true }],
|
|
183
194
|
};
|
|
195
|
+
console.log(videoConfig);
|
|
184
196
|
|
|
185
197
|
if (isAndroid) {
|
|
186
198
|
try {
|
|
@@ -189,15 +201,10 @@ const VeryfiLens = (function () {
|
|
|
189
201
|
const mainCameraDevice = videoDevices.find(device => device.label.includes("camera2 0"));
|
|
190
202
|
if (mainCameraDevice) {
|
|
191
203
|
videoConfig.deviceId = { exact: mainCameraDevice.deviceId };
|
|
192
|
-
} else {
|
|
193
|
-
videoConfig.facingMode = "environment";
|
|
194
204
|
}
|
|
195
205
|
} catch (error) {
|
|
196
206
|
console.error("Error enumerating devices", error);
|
|
197
|
-
videoConfig.facingMode = "environment";
|
|
198
207
|
}
|
|
199
|
-
} else {
|
|
200
|
-
videoConfig.facingMode = "environment";
|
|
201
208
|
}
|
|
202
209
|
|
|
203
210
|
const constraints = {
|
|
@@ -353,6 +360,11 @@ const VeryfiLens = (function () {
|
|
|
353
360
|
};
|
|
354
361
|
|
|
355
362
|
const sendWasm = async (mode) => {
|
|
363
|
+
if (!wasmWrapper) {
|
|
364
|
+
state.debug_mode && console.log("WASM wrapper not initialized");
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
356
368
|
if (state.isDocumentProcess) {
|
|
357
369
|
mode = "Document";
|
|
358
370
|
} else if (state.isStitchingProcess) {
|
|
@@ -360,50 +372,56 @@ const VeryfiLens = (function () {
|
|
|
360
372
|
} else {
|
|
361
373
|
mode = "StitcherProcess";
|
|
362
374
|
}
|
|
363
|
-
if (state.videoRef) {
|
|
364
|
-
let rCorners;
|
|
365
|
-
const video = state.videoRef;
|
|
366
|
-
let videoHeight = video.videoHeight;
|
|
367
|
-
let videoWidth = video.videoWidth;
|
|
368
|
-
const fullSizeCanvas = document.createElement("canvas");
|
|
369
|
-
fullSizeCanvas.width = videoWidth;
|
|
370
|
-
fullSizeCanvas.height = videoHeight;
|
|
371
|
-
const fullSizeCtx = fullSizeCanvas.getContext("2d");
|
|
372
|
-
|
|
373
|
-
if (fullSizeCtx) {
|
|
374
|
-
fullSizeCtx.save();
|
|
375
|
-
fullSizeCtx.drawImage(video, 0, 0, videoWidth, videoHeight);
|
|
376
|
-
fullSizeCtx.restore();
|
|
377
|
-
const imgString = fullSizeCanvas.toDataURL("image/jpeg");
|
|
378
375
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
376
|
+
if (state.videoRef) {
|
|
377
|
+
try {
|
|
378
|
+
let rCorners;
|
|
379
|
+
const video = state.videoRef;
|
|
380
|
+
let videoHeight = video.videoHeight;
|
|
381
|
+
let videoWidth = video.videoWidth;
|
|
382
|
+
const fullSizeCanvas = document.createElement("canvas");
|
|
383
|
+
fullSizeCanvas.width = videoWidth;
|
|
384
|
+
fullSizeCanvas.height = videoHeight;
|
|
385
|
+
const fullSizeCtx = fullSizeCanvas.getContext("2d");
|
|
386
|
+
|
|
387
|
+
if (fullSizeCtx) {
|
|
388
|
+
fullSizeCtx.save();
|
|
389
|
+
fullSizeCtx.drawImage(video, 0, 0, videoWidth, videoHeight);
|
|
390
|
+
fullSizeCtx.restore();
|
|
391
|
+
const imgString = fullSizeCanvas.toDataURL("image/jpeg");
|
|
392
|
+
|
|
393
|
+
try {
|
|
394
|
+
state.fullSizeImage = await loadImage(imgString);
|
|
395
|
+
createImageBitmap(state.fullSizeImage).then((bitmap) => {
|
|
396
|
+
if (wasmWrapper && typeof wasmWrapper.processDocument === 'function') {
|
|
397
|
+
wasmWrapper.processDocument(bitmap, mode);
|
|
398
|
+
rCorners = state.coordinates.map((corner) => corner);
|
|
399
|
+
if (
|
|
400
|
+
rCorners.length &&
|
|
401
|
+
rCorners.some((subArr) => subArr.reduce((a, b) => a + b, 0) !== 0)
|
|
402
|
+
) {
|
|
403
|
+
drawContours(rCorners);
|
|
404
|
+
if (state.previewData !== null && state.shouldUpdatePreview) {
|
|
405
|
+
state.longPreview && state.longPreview.updatePreview(
|
|
406
|
+
state.previewData.data,
|
|
407
|
+
state.previewData.outputWidth,
|
|
408
|
+
state.previewData.outputHeight
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
setHasCoordinates(false);
|
|
413
|
+
state.image = imgString;
|
|
414
|
+
}
|
|
396
415
|
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
});
|
|
402
|
-
} catch (error) {
|
|
403
|
-
console.log(error);
|
|
404
|
-
}
|
|
416
|
+
});
|
|
417
|
+
} catch (error) {
|
|
418
|
+
console.log(error);
|
|
419
|
+
}
|
|
405
420
|
|
|
406
|
-
|
|
421
|
+
releaseCanvas(fullSizeCanvas);
|
|
422
|
+
}
|
|
423
|
+
} catch (error) {
|
|
424
|
+
console.error("Error in sendWasm:", error);
|
|
407
425
|
}
|
|
408
426
|
}
|
|
409
427
|
};
|
|
@@ -485,26 +503,25 @@ const VeryfiLens = (function () {
|
|
|
485
503
|
let wasmOutput;
|
|
486
504
|
let imgString;
|
|
487
505
|
if (state.hasCoordinates) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
506
|
+
wasmOutput = await wasmWrapper.getStitchedImage();
|
|
507
|
+
const { data, blurLevel, outputHeight, outputWidth } = wasmOutput;
|
|
508
|
+
const width = outputWidth;
|
|
509
|
+
const height = outputHeight;
|
|
510
|
+
const cropImgCanvas = state.cropImgRef;
|
|
511
|
+
state.cropImgRef.height = height;
|
|
512
|
+
state.cropImgRef.width = width;
|
|
513
|
+
const ctx = cropImgCanvas.getContext("2d");
|
|
514
|
+
const imageData = new ImageData(data, width, height);
|
|
515
|
+
ctx.putImageData(imageData, 0, 0);
|
|
516
|
+
imgString = cropImgCanvas.toDataURL("image/jpeg");
|
|
517
|
+
state.image = cropImgCanvas;
|
|
518
|
+
state.isDocument = true;
|
|
501
519
|
} else {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
520
|
+
checkIfDocumentOnCapture();
|
|
521
|
+
imgString = state.image;
|
|
522
|
+
stopWasm();
|
|
523
|
+
return false;
|
|
506
524
|
}
|
|
507
|
-
// setBlurStatus(blurLevel); gives 0 all the time
|
|
508
525
|
stopWasm();
|
|
509
526
|
releaseCanvas(state.boxRef);
|
|
510
527
|
state.coordinates = [];
|
|
@@ -538,6 +555,7 @@ const VeryfiLens = (function () {
|
|
|
538
555
|
state.coordinates = corners.map((corner) => [corner.x, corner.y]);
|
|
539
556
|
state.previewData = preview;
|
|
540
557
|
state.shouldUpdatePreview = stitcherResult === 0;
|
|
558
|
+
state.isDocument = corners.length > 0 && stitcherResult === 0;
|
|
541
559
|
}
|
|
542
560
|
|
|
543
561
|
const logCard = (status, name, number, date, cvv) => {
|
|
@@ -855,6 +873,7 @@ const VeryfiLens = (function () {
|
|
|
855
873
|
state.exitButton = createExitButton(state.videoOverlay.overlay, {
|
|
856
874
|
setter: state.onClose,
|
|
857
875
|
redirectUrl: state.onCloseRedirectUrl,
|
|
876
|
+
lensFlavor: state.lensFlavor,
|
|
858
877
|
}, removeOverlay);
|
|
859
878
|
}
|
|
860
879
|
|
|
@@ -882,6 +901,7 @@ const VeryfiLens = (function () {
|
|
|
882
901
|
createExitButton(state.cardOverlay.element, {
|
|
883
902
|
setter: state.onClose,
|
|
884
903
|
redirectUrl: state.onCloseRedirectUrl,
|
|
904
|
+
lensFlavor: state.lensFlavor,
|
|
885
905
|
}, removeOverlay);
|
|
886
906
|
}
|
|
887
907
|
}
|
|
@@ -929,9 +949,6 @@ const VeryfiLens = (function () {
|
|
|
929
949
|
state.updateHandler && state.updateHandler({ status: 'validation_started' });
|
|
930
950
|
const response = await fetch(
|
|
931
951
|
'https://lens.veryfi.com/rest/validate_partner',
|
|
932
|
-
// 'https://lens-dev.veryfi.com/rest/validate_partner',
|
|
933
|
-
// 'http://localhost:5050/rest/validate_partner',
|
|
934
|
-
|
|
935
952
|
{
|
|
936
953
|
method: 'POST',
|
|
937
954
|
headers: {
|
|
@@ -1087,14 +1104,38 @@ const VeryfiLens = (function () {
|
|
|
1087
1104
|
};
|
|
1088
1105
|
|
|
1089
1106
|
const removeOverlay = () => {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1107
|
+
try {
|
|
1108
|
+
// Clear any existing intervals first
|
|
1109
|
+
if (state.intervalRef) {
|
|
1110
|
+
clearInterval(state.intervalRef);
|
|
1111
|
+
state.intervalRef = null;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// Then proceed with other cleanup
|
|
1115
|
+
if (state.videoRef && state.videoRef.srcObject) {
|
|
1116
|
+
const tracks = state.videoRef.srcObject.getTracks();
|
|
1117
|
+
tracks.forEach(track => track.stop());
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// Reset WASM wrapper
|
|
1121
|
+
if (wasmWrapper) {
|
|
1122
|
+
wasmWrapper.release();
|
|
1123
|
+
wasmWrapper = null;
|
|
1124
|
+
}
|
|
1125
|
+
if (state.usingOverlayContainer) {
|
|
1126
|
+
stopLens();
|
|
1127
|
+
document.body.removeChild(state.container);
|
|
1128
|
+
state.usingOverlayContainer = false;
|
|
1129
|
+
} else {
|
|
1130
|
+
stopLens();
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
// Continue with other cleanup...
|
|
1134
|
+
resetState();
|
|
1135
|
+
|
|
1136
|
+
} catch (error) {
|
|
1137
|
+
console.error("Error in removeOverlay:", error);
|
|
1096
1138
|
}
|
|
1097
|
-
resetState();
|
|
1098
1139
|
};
|
|
1099
1140
|
|
|
1100
1141
|
const resetState = () => {
|
|
@@ -1247,6 +1288,7 @@ const VeryfiLens = (function () {
|
|
|
1247
1288
|
try {
|
|
1248
1289
|
state.debug_mode && console.log("[EVENT] capture");
|
|
1249
1290
|
state.updateHandler && state.updateHandler({ status: 'capture_started' });
|
|
1291
|
+
!state.uuidv4 && await generateDeviceIDifNeeded();
|
|
1250
1292
|
|
|
1251
1293
|
switch (state.lensFlavor) {
|
|
1252
1294
|
case "long_document":
|
|
@@ -1600,6 +1642,11 @@ const VeryfiLens = (function () {
|
|
|
1600
1642
|
try {
|
|
1601
1643
|
// Wait a small amount of time to ensure DOM is ready
|
|
1602
1644
|
await new Promise(resolve => setTimeout(resolve, 0));
|
|
1645
|
+
|
|
1646
|
+
// Set fullscreen attribute on container
|
|
1647
|
+
if (state.container) {
|
|
1648
|
+
state.container.dataset.fullscreen = state.enableFullScreen.toString();
|
|
1649
|
+
}
|
|
1603
1650
|
|
|
1604
1651
|
if (state.lensFlavor !== "credit_card" && state.lensFlavor !== "upload") {
|
|
1605
1652
|
// Create cropped image
|
|
@@ -1676,7 +1723,7 @@ const VeryfiLens = (function () {
|
|
|
1676
1723
|
|
|
1677
1724
|
const getDeviceData = async () => {
|
|
1678
1725
|
|
|
1679
|
-
state.uuidv4
|
|
1726
|
+
!state.uuidv4 && await generateDeviceIDifNeeded();
|
|
1680
1727
|
const browserData = await getBrowserData();
|
|
1681
1728
|
const UAData = flattenObject(parseUA());
|
|
1682
1729
|
|
|
@@ -1732,8 +1779,18 @@ const VeryfiLens = (function () {
|
|
|
1732
1779
|
};
|
|
1733
1780
|
|
|
1734
1781
|
const getFingerprint = async () => {
|
|
1782
|
+
state.debug_mode && console.log("Getting fingerprint");
|
|
1735
1783
|
try {
|
|
1736
|
-
const fp = await FingerprintJS.load(
|
|
1784
|
+
const fp = await FingerprintJS.load({
|
|
1785
|
+
endpoint: [
|
|
1786
|
+
"https://fp.veryfi.com",
|
|
1787
|
+
FingerprintJS.defaultEndpoint
|
|
1788
|
+
],
|
|
1789
|
+
scriptUrlPattern: [
|
|
1790
|
+
"https://fp.veryfi.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",
|
|
1791
|
+
FingerprintJS.defaultScriptUrlPattern
|
|
1792
|
+
]
|
|
1793
|
+
});
|
|
1737
1794
|
const result = await fp.get();
|
|
1738
1795
|
state.visitorId = result.visitorId;
|
|
1739
1796
|
state.debug_mode && console.log("Basic fingerprint obtained:", state.visitorId);
|
|
@@ -1744,10 +1801,20 @@ const VeryfiLens = (function () {
|
|
|
1744
1801
|
}
|
|
1745
1802
|
|
|
1746
1803
|
const getFingerprintPro = async () => {
|
|
1804
|
+
state.debug_mode && console.log("Getting fingerprint pro");
|
|
1747
1805
|
try {
|
|
1748
|
-
const
|
|
1749
|
-
apiKey:
|
|
1750
|
-
|
|
1806
|
+
const fpPromise = FingerprintJSPro.load({
|
|
1807
|
+
apiKey: state.clientData.fpjs_key,
|
|
1808
|
+
endpoint: [
|
|
1809
|
+
"https://fp.veryfi.com",
|
|
1810
|
+
FingerprintJS.defaultEndpoint
|
|
1811
|
+
],
|
|
1812
|
+
scriptUrlPattern: [
|
|
1813
|
+
"https://fp.veryfi.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",
|
|
1814
|
+
FingerprintJS.defaultScriptUrlPattern
|
|
1815
|
+
]
|
|
1816
|
+
})
|
|
1817
|
+
const fp = await fpPromise;
|
|
1751
1818
|
const result = await fp.get();
|
|
1752
1819
|
state.visitorId = result.visitorId;
|
|
1753
1820
|
state.debug_mode && console.log("Pro fingerprint obtained:", state.visitorId);
|
|
@@ -1757,6 +1824,41 @@ const VeryfiLens = (function () {
|
|
|
1757
1824
|
}
|
|
1758
1825
|
}
|
|
1759
1826
|
|
|
1827
|
+
const generateDeviceIDifNeeded = async () => {
|
|
1828
|
+
const EXPIRATION_DAYS = 7; // Set desired expiration time in days
|
|
1829
|
+
|
|
1830
|
+
const storedData = localStorage.getItem('ldidk');
|
|
1831
|
+
let cachedData = storedData ? JSON.parse(storedData) : null;
|
|
1832
|
+
|
|
1833
|
+
const isValid = cachedData &&
|
|
1834
|
+
cachedData.expiry &&
|
|
1835
|
+
new Date().getTime() < cachedData.expiry;
|
|
1836
|
+
|
|
1837
|
+
if (!isValid) {
|
|
1838
|
+
// Generate new device ID
|
|
1839
|
+
if (state.clientData?.fingerprint_js_on) {
|
|
1840
|
+
await getFingerprintPro();
|
|
1841
|
+
state.uuidv4 = await hexToUUIDv4(state.visitorId);
|
|
1842
|
+
} else {
|
|
1843
|
+
if (!state.visitorId) {
|
|
1844
|
+
await getFingerprint();
|
|
1845
|
+
}
|
|
1846
|
+
state.uuidv4 = await hexToUUIDv4(state.visitorId);
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
// Store with expiration
|
|
1850
|
+
const expiryTime = new Date().getTime() + (EXPIRATION_DAYS * 24 * 60 * 60 * 1000);
|
|
1851
|
+
const dataToStore = {
|
|
1852
|
+
id: state.uuidv4,
|
|
1853
|
+
expiry: expiryTime
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
localStorage.setItem('ldidk', JSON.stringify(dataToStore));
|
|
1857
|
+
} else {
|
|
1858
|
+
state.uuidv4 = cachedData.id;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1760
1862
|
return {
|
|
1761
1863
|
|
|
1762
1864
|
init: async (clientId, config) => {
|
|
@@ -1769,20 +1871,6 @@ const VeryfiLens = (function () {
|
|
|
1769
1871
|
state.clientData = await validatePartner(state.clientId);
|
|
1770
1872
|
config.debug_mode && console.log(state.clientData);
|
|
1771
1873
|
|
|
1772
|
-
if (typeof window !== 'undefined') {
|
|
1773
|
-
|
|
1774
|
-
try {
|
|
1775
|
-
state.debug_mode && console.log("Getting fingerprint");
|
|
1776
|
-
if (state.clientData.fingerprint_js_on) {
|
|
1777
|
-
await getFingerprintPro();
|
|
1778
|
-
} else {
|
|
1779
|
-
await getFingerprint();
|
|
1780
|
-
}
|
|
1781
|
-
} catch (error) {
|
|
1782
|
-
console.error('Failed to initialize fingerprinting:', error);
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
1874
|
await initializeWasmWrapper();
|
|
1787
1875
|
|
|
1788
1876
|
switch (config.lensFlavor) {
|
|
@@ -1877,10 +1965,9 @@ const VeryfiLens = (function () {
|
|
|
1877
1965
|
},
|
|
1878
1966
|
|
|
1879
1967
|
getDeviceData: async () => {
|
|
1880
|
-
state.
|
|
1968
|
+
!state.uuidv4 && await generateDeviceIDifNeeded();
|
|
1881
1969
|
const browserData = await getBrowserData();
|
|
1882
1970
|
const UAData = flattenObject(parseUA());
|
|
1883
|
-
|
|
1884
1971
|
return {
|
|
1885
1972
|
browser_fingerprint: { ...UAData, ...browserData },
|
|
1886
1973
|
uuid: state.uuidv4,
|
|
@@ -1902,13 +1989,12 @@ const VeryfiLens = (function () {
|
|
|
1902
1989
|
|
|
1903
1990
|
configureLens: (config) => {
|
|
1904
1991
|
Object.keys(config).forEach(key => {
|
|
1905
|
-
if (state.hasOwnProperty(key)
|
|
1992
|
+
if (state.hasOwnProperty(key) &&
|
|
1993
|
+
key !== 'lensFlavor' &&
|
|
1994
|
+
key !== 'container') {
|
|
1906
1995
|
state[key] = config[key];
|
|
1907
1996
|
}
|
|
1908
1997
|
});
|
|
1909
|
-
if (config.lensFlavor === 'long_document' && state.captureButton) {
|
|
1910
|
-
state.captureButton.setStitching(state.isStitching);
|
|
1911
|
-
}
|
|
1912
1998
|
},
|
|
1913
1999
|
|
|
1914
2000
|
stop: () => {
|