veryfi-lens-wasm 2.0.2 → 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 +45 -37
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 = {
|
|
@@ -496,26 +503,25 @@ const VeryfiLens = (function () {
|
|
|
496
503
|
let wasmOutput;
|
|
497
504
|
let imgString;
|
|
498
505
|
if (state.hasCoordinates) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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;
|
|
512
519
|
} else {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
520
|
+
checkIfDocumentOnCapture();
|
|
521
|
+
imgString = state.image;
|
|
522
|
+
stopWasm();
|
|
523
|
+
return false;
|
|
517
524
|
}
|
|
518
|
-
// setBlurStatus(blurLevel); gives 0 all the time
|
|
519
525
|
stopWasm();
|
|
520
526
|
releaseCanvas(state.boxRef);
|
|
521
527
|
state.coordinates = [];
|
|
@@ -549,6 +555,7 @@ const VeryfiLens = (function () {
|
|
|
549
555
|
state.coordinates = corners.map((corner) => [corner.x, corner.y]);
|
|
550
556
|
state.previewData = preview;
|
|
551
557
|
state.shouldUpdatePreview = stitcherResult === 0;
|
|
558
|
+
state.isDocument = corners.length > 0 && stitcherResult === 0;
|
|
552
559
|
}
|
|
553
560
|
|
|
554
561
|
const logCard = (status, name, number, date, cvv) => {
|
|
@@ -866,6 +873,7 @@ const VeryfiLens = (function () {
|
|
|
866
873
|
state.exitButton = createExitButton(state.videoOverlay.overlay, {
|
|
867
874
|
setter: state.onClose,
|
|
868
875
|
redirectUrl: state.onCloseRedirectUrl,
|
|
876
|
+
lensFlavor: state.lensFlavor,
|
|
869
877
|
}, removeOverlay);
|
|
870
878
|
}
|
|
871
879
|
|
|
@@ -893,6 +901,7 @@ const VeryfiLens = (function () {
|
|
|
893
901
|
createExitButton(state.cardOverlay.element, {
|
|
894
902
|
setter: state.onClose,
|
|
895
903
|
redirectUrl: state.onCloseRedirectUrl,
|
|
904
|
+
lensFlavor: state.lensFlavor,
|
|
896
905
|
}, removeOverlay);
|
|
897
906
|
}
|
|
898
907
|
}
|
|
@@ -939,10 +948,7 @@ const VeryfiLens = (function () {
|
|
|
939
948
|
try {
|
|
940
949
|
state.updateHandler && state.updateHandler({ status: 'validation_started' });
|
|
941
950
|
const response = await fetch(
|
|
942
|
-
|
|
943
|
-
// 'https://lens-dev.veryfi.com/rest/validate_partner',
|
|
944
|
-
'http://localhost:5050/rest/validate_partner',
|
|
945
|
-
|
|
951
|
+
'https://lens.veryfi.com/rest/validate_partner',
|
|
946
952
|
{
|
|
947
953
|
method: 'POST',
|
|
948
954
|
headers: {
|
|
@@ -1003,8 +1009,7 @@ const VeryfiLens = (function () {
|
|
|
1003
1009
|
};
|
|
1004
1010
|
|
|
1005
1011
|
const response = await fetch(
|
|
1006
|
-
|
|
1007
|
-
"http://localhost:5050/rest/send-cropped",
|
|
1012
|
+
"https://lens.veryfi.com/rest/send-cropped",
|
|
1008
1013
|
{
|
|
1009
1014
|
method: "POST",
|
|
1010
1015
|
headers: {
|
|
@@ -1039,8 +1044,7 @@ const VeryfiLens = (function () {
|
|
|
1039
1044
|
spinner.show();
|
|
1040
1045
|
state.updateHandler && state.updateHandler({ status: 'submission_started' });
|
|
1041
1046
|
|
|
1042
|
-
|
|
1043
|
-
const processDocumentUrl = "http://localhost:5050/api/document";
|
|
1047
|
+
const processDocumentUrl = "https://lens.veryfi.com/api/document";
|
|
1044
1048
|
const deviceData = await getDeviceData();
|
|
1045
1049
|
|
|
1046
1050
|
const requestBody = {
|
|
@@ -1638,6 +1642,11 @@ const VeryfiLens = (function () {
|
|
|
1638
1642
|
try {
|
|
1639
1643
|
// Wait a small amount of time to ensure DOM is ready
|
|
1640
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
|
+
}
|
|
1641
1650
|
|
|
1642
1651
|
if (state.lensFlavor !== "credit_card" && state.lensFlavor !== "upload") {
|
|
1643
1652
|
// Create cropped image
|
|
@@ -1980,13 +1989,12 @@ const VeryfiLens = (function () {
|
|
|
1980
1989
|
|
|
1981
1990
|
configureLens: (config) => {
|
|
1982
1991
|
Object.keys(config).forEach(key => {
|
|
1983
|
-
if (state.hasOwnProperty(key)
|
|
1992
|
+
if (state.hasOwnProperty(key) &&
|
|
1993
|
+
key !== 'lensFlavor' &&
|
|
1994
|
+
key !== 'container') {
|
|
1984
1995
|
state[key] = config[key];
|
|
1985
1996
|
}
|
|
1986
1997
|
});
|
|
1987
|
-
if (config.lensFlavor === 'long_document' && state.captureButton) {
|
|
1988
|
-
state.captureButton.setStitching(state.isStitching);
|
|
1989
|
-
}
|
|
1990
1998
|
},
|
|
1991
1999
|
|
|
1992
2000
|
stop: () => {
|