veryfi-lens-wasm 2.0.0-beta.3 → 2.0.0-beta.4
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/cardDataButton.js +44 -0
- package/components/creditCard.js +10 -0
- package/package.json +1 -1
- package/veryfi-lens.js +60 -28
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const createCardDataButton = (container, onGetData, removeOverlay) => {
|
|
2
|
+
const button = document.createElement('button');
|
|
3
|
+
button.id = 'veryfi-card-data-button';
|
|
4
|
+
button.textContent = 'Get Card Data';
|
|
5
|
+
|
|
6
|
+
const defaultStyles = {
|
|
7
|
+
position: 'absolute',
|
|
8
|
+
bottom: '50px',
|
|
9
|
+
right: 'calc(50% - 50px)', // Position on the right side
|
|
10
|
+
padding: '10px 20px',
|
|
11
|
+
backgroundColor: '#4CAF50',
|
|
12
|
+
color: 'white',
|
|
13
|
+
border: 'none',
|
|
14
|
+
borderRadius: '5px',
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
fontSize: '16px',
|
|
17
|
+
zIndex: '1000',
|
|
18
|
+
display: 'none',
|
|
19
|
+
pointerEvents: 'auto'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
23
|
+
button.style[key] = value;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
button.addEventListener('click', () => {
|
|
27
|
+
onGetData();
|
|
28
|
+
if (removeOverlay) {
|
|
29
|
+
removeOverlay();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
container.appendChild(button);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
show: () => {
|
|
37
|
+
button.style.display = 'block';
|
|
38
|
+
},
|
|
39
|
+
hide: () => {
|
|
40
|
+
button.style.display = 'none';
|
|
41
|
+
},
|
|
42
|
+
button: button
|
|
43
|
+
};
|
|
44
|
+
};
|
package/components/creditCard.js
CHANGED
|
@@ -114,8 +114,10 @@ export const createCreditCardComponent = (container) => {
|
|
|
114
114
|
const showFlipMessage = () => {
|
|
115
115
|
const flipMessage = document.createElement('p');
|
|
116
116
|
flipMessage.textContent = 'Please flip your card';
|
|
117
|
+
flipMessage.id = 'flip-message';
|
|
117
118
|
flipMessage.style.cssText = `
|
|
118
119
|
position: absolute;
|
|
120
|
+
display: block;
|
|
119
121
|
width: var(--flip-message-width);
|
|
120
122
|
bottom: var(--flip-message-bottom);
|
|
121
123
|
left: 50%;
|
|
@@ -129,6 +131,13 @@ export const createCreditCardComponent = (container) => {
|
|
|
129
131
|
return flipMessage;
|
|
130
132
|
};
|
|
131
133
|
|
|
134
|
+
const hideFlipMessage = () => {
|
|
135
|
+
const flipMessage = cardOverlay.querySelector('#flip-message');
|
|
136
|
+
if (flipMessage) {
|
|
137
|
+
flipMessage.style.display = 'none';
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
132
141
|
// Method to update CSS variables
|
|
133
142
|
const updateStyles = (styles) => {
|
|
134
143
|
Object.entries(styles).forEach(([key, value]) => {
|
|
@@ -140,6 +149,7 @@ export const createCreditCardComponent = (container) => {
|
|
|
140
149
|
element: cardOverlay,
|
|
141
150
|
updateCardData,
|
|
142
151
|
showFlipMessage,
|
|
152
|
+
hideFlipMessage,
|
|
143
153
|
updateStyles,
|
|
144
154
|
};
|
|
145
155
|
};
|
package/package.json
CHANGED
package/veryfi-lens.js
CHANGED
|
@@ -23,6 +23,7 @@ import { createCreditCardComponent } from './components/creditCard.js';
|
|
|
23
23
|
import { createStitchingButton } from './components/stitchingButton.js';
|
|
24
24
|
import { createCheckImages } from './components/checkImages.js';
|
|
25
25
|
import { createSpinner } from './components/spinner.js';
|
|
26
|
+
import { createCardDataButton } from './components/cardDataButton.js';
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
@@ -105,6 +106,7 @@ const VeryfiLens = (function () {
|
|
|
105
106
|
usingOverlayContainer: false,
|
|
106
107
|
frontImageSetter: null,
|
|
107
108
|
backImageSetter: null,
|
|
109
|
+
cardDataButton: null,
|
|
108
110
|
|
|
109
111
|
// Handlers
|
|
110
112
|
successHandler: null,
|
|
@@ -434,16 +436,28 @@ const VeryfiLens = (function () {
|
|
|
434
436
|
return;
|
|
435
437
|
}
|
|
436
438
|
|
|
437
|
-
// Check if we're
|
|
438
|
-
if (state.CCPhase === "ScanningBack"
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
439
|
+
// Check if we're in back scanning phase
|
|
440
|
+
if (state.CCPhase === "ScanningBack") {
|
|
441
|
+
// Initialize back scanning start time if not set
|
|
442
|
+
if (!state.backScanningStartTime) {
|
|
443
|
+
state.backScanningStartTime = Date.now();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Check if 5 seconds have passed during back scanning
|
|
447
|
+
if (Date.now() - state.backScanningStartTime > 5000) {
|
|
448
|
+
if (!state.submitButtonShown) {
|
|
449
|
+
state.debug_mode && console.log("5 seconds elapsed during back scanning, showing card data button");
|
|
450
|
+
showCardDataButton();
|
|
451
|
+
state.shouldProcessCC = false; // Stop further processing
|
|
452
|
+
if (state.cardOverlay) {
|
|
453
|
+
// state.cardOverlay.element.style.display = 'none'; // Hide card overlay
|
|
454
|
+
}
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
445
458
|
}
|
|
446
459
|
|
|
460
|
+
// Rest of the existing sendCardWasm logic...
|
|
447
461
|
if (state.cardData.status === "AutoCaptureResultDone" &&
|
|
448
462
|
state.CCPhase === "ScanningBack") return;
|
|
449
463
|
|
|
@@ -551,7 +565,7 @@ const VeryfiLens = (function () {
|
|
|
551
565
|
if (newData[key] !== undefined &&
|
|
552
566
|
newData[key] !== null &&
|
|
553
567
|
newData[key] !== "" &&
|
|
554
|
-
state.cardData[key] !== newData[key]) {
|
|
568
|
+
state.cardData[key] !== newData[key]) {
|
|
555
569
|
|
|
556
570
|
state.cardData[key] = newData[key];
|
|
557
571
|
hasDataChanged = true;
|
|
@@ -579,19 +593,24 @@ const VeryfiLens = (function () {
|
|
|
579
593
|
|
|
580
594
|
case "ScanningBack":
|
|
581
595
|
state.debug_mode && console.log("Back scan processing");
|
|
582
|
-
|
|
583
|
-
const scanForNumber = !state.cardData.number;
|
|
584
|
-
const scanForName = !state.cardData.name;
|
|
585
|
-
const scanForDate = !state.cardData.date;
|
|
586
|
-
const scanForCvv = !state.cardData.cvv;
|
|
587
|
-
|
|
596
|
+
|
|
588
597
|
// If we have CVV, show submit button immediately
|
|
589
598
|
if (state.cardData.cvv) {
|
|
590
|
-
state.debug_mode && console.log("CVV captured");
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
599
|
+
state.debug_mode && console.log("CVV captured, showing card data button");
|
|
600
|
+
showCardDataButton();
|
|
601
|
+
state.cardOverlay.hideFlipMessage();
|
|
602
|
+
state.shouldProcessCC = false; // Stop further processing
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// If no CVV after 5 seconds, show button anyway
|
|
607
|
+
if (state.backScanningStartTime &&
|
|
608
|
+
Date.now() - state.backScanningStartTime > 5000 &&
|
|
609
|
+
!state.submitButtonShown) {
|
|
610
|
+
state.debug_mode && console.log("5 seconds elapsed during back scanning, showing card data button");
|
|
611
|
+
showCardDataButton();
|
|
612
|
+
state.cardOverlay.hideFlipMessage();
|
|
613
|
+
state.shouldProcessCC = false;
|
|
595
614
|
}
|
|
596
615
|
break;
|
|
597
616
|
}
|
|
@@ -1684,22 +1703,35 @@ const VeryfiLens = (function () {
|
|
|
1684
1703
|
return wasmWrapper.lcdStatus();
|
|
1685
1704
|
}
|
|
1686
1705
|
|
|
1687
|
-
const
|
|
1706
|
+
const showCardDataButton = () => {
|
|
1688
1707
|
if (!state.submitButtonShown) {
|
|
1689
1708
|
state.debug_mode && console.log("Showing submit button");
|
|
1690
1709
|
state.submitButtonShown = true;
|
|
1691
1710
|
hideVideoOverlay();
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
state.
|
|
1695
|
-
state.
|
|
1711
|
+
|
|
1712
|
+
if (state.lensFlavor === "credit_card") {
|
|
1713
|
+
state.cardDataButton = createCardDataButton(
|
|
1714
|
+
state.container,
|
|
1696
1715
|
() => {
|
|
1697
|
-
|
|
1698
|
-
|
|
1716
|
+
// Hide card overlay when button is pressed
|
|
1717
|
+
if (state.cardOverlay) {
|
|
1718
|
+
state.cardOverlay.element.style.display = 'none';
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// Handle card data
|
|
1722
|
+
if (state.resultSetter) {
|
|
1723
|
+
state.resultSetter(state.cardData);
|
|
1724
|
+
}
|
|
1725
|
+
if (state.successHandler) {
|
|
1726
|
+
state.successHandler(state.cardData);
|
|
1727
|
+
}
|
|
1699
1728
|
},
|
|
1700
1729
|
removeOverlay
|
|
1701
1730
|
);
|
|
1702
|
-
|
|
1731
|
+
|
|
1732
|
+
if (state.cardDataButton) {
|
|
1733
|
+
state.cardDataButton.show();
|
|
1734
|
+
}
|
|
1703
1735
|
}
|
|
1704
1736
|
}
|
|
1705
1737
|
};
|