veryfi-lens-wasm 1.2.8 → 1.3.0
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/README.md +3 -9
- package/package.json +3 -1
- package/veryfi-lens.js +196 -47
- package/wasm/device-uuid.js +0 -921
package/README.md
CHANGED
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
<img src="https://user-images.githubusercontent.com/30125790/212157486-bfd08c5d-9337-4b78-be6f-230dc63838ba.png#gh-light-mode-only" width="200">
|
|
4
4
|
|
|
5
|
-
# Lens for Browser socket version has been moved to a separate package
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
<https://www.npmjs.com/package/veryfi-lens-socket>
|
|
6
|
+
# Lens for Browser socket version has been moved to a separate package https://github.com/veryfi/veryfi-lens-socket
|
|
9
7
|
|
|
10
8
|
# Veryfi Lens for Browser WASM SDK
|
|
11
|
-
|
|
12
9
|
Veryfi Lens for Web SDK is a framework for your web app to give it document capture superpowers in minutes.
|
|
13
10
|
|
|
14
11
|
Lens follows a client-server architecture where the server is for validating your client and getting session key and the client side is for displaying and showing Lens components for capturing documents.
|
|
15
12
|
|
|
13
|
+
|
|
16
14
|
**_You can skip first step and copy wasm folder from package directory manually if you want to do so_.**
|
|
17
15
|
|
|
18
16
|
1. run `npm exec veryfi-lens-wasm-setup` and provide it with path to directory where
|
|
@@ -59,13 +57,11 @@ For usual receipt (Next.Js example)
|
|
|
59
57
|
|
|
60
58
|
For Long receipt (Next.Js example)
|
|
61
59
|
Add container with id="preview-container" to see stitching preview
|
|
62
|
-
|
|
63
60
|
```
|
|
64
61
|
<div id="preview-container"
|
|
65
62
|
className="absolute top-[100px] left-[10px] md:left-[40px] w-[22vw] md:w-[18vw] h-[70vh] rounded-md z-40 overflow-y-hidden border-[1px] border-solid border-green-300"
|
|
66
63
|
></div>
|
|
67
64
|
```
|
|
68
|
-
|
|
69
65
|
```
|
|
70
66
|
const [veryfiLens, setVeryfiLens] = useState<{
|
|
71
67
|
startStitching(): void;
|
|
@@ -138,10 +134,8 @@ webpack: (config) => {
|
|
|
138
134
|
```
|
|
139
135
|
|
|
140
136
|
If using Vite and Vue:
|
|
141
|
-
|
|
142
137
|
1. install serve `npm i serve`
|
|
143
138
|
2. Add following to your vite config
|
|
144
|
-
|
|
145
139
|
```
|
|
146
140
|
server: {
|
|
147
141
|
https: {
|
|
@@ -165,7 +159,7 @@ If using Vite and Vue:
|
|
|
165
159
|
}
|
|
166
160
|
```
|
|
167
161
|
|
|
168
|
-
|
|
162
|
+
3. `serve -s dist -p 3000`
|
|
169
163
|
|
|
170
164
|
If using Angular:
|
|
171
165
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfi-lens-wasm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Lens For Browser WASM SDK",
|
|
5
5
|
"main": "veryfi-lens.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"author": "George Veryfi",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@fingerprintjs/fingerprintjs": "^4.5.1",
|
|
21
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.11.5",
|
|
20
22
|
"fs-extra": "^11.1.1",
|
|
21
23
|
"inquirer": "^8.0.0",
|
|
22
24
|
"path": "^0.12.7"
|
package/veryfi-lens.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import DeviceUUID from "./wasm/device-uuid.js";
|
|
2
1
|
import { WasmWrapper } from "./wasm/wasm.js";
|
|
3
2
|
import gatherBrowserData from "./wasm/device-data.js";
|
|
4
3
|
import UAParser from "./wasm/parser-wrapper.js";
|
|
4
|
+
import FingerprintJS from "@fingerprintjs/fingerprintjs";
|
|
5
|
+
import FingerprintJSPro from "@fingerprintjs/fingerprintjs-pro";
|
|
5
6
|
|
|
6
7
|
const VeryfiLens = (function () {
|
|
7
8
|
const DEFAULT_BOX_COlOR = "rgba(84, 192, 139, 0.6)";
|
|
@@ -16,11 +17,14 @@ const VeryfiLens = (function () {
|
|
|
16
17
|
let videoRef = null;
|
|
17
18
|
let intervalRef = null;
|
|
18
19
|
let userAgent = null;
|
|
19
|
-
let device_uuid = null;
|
|
20
20
|
let torchTrack = null;
|
|
21
21
|
let fullSizeImage;
|
|
22
22
|
let finalImage;
|
|
23
23
|
|
|
24
|
+
let visitorId = null;
|
|
25
|
+
let visitorIdPro = null;
|
|
26
|
+
let uuidv4 = null;
|
|
27
|
+
let partnerData = null;
|
|
24
28
|
let previewData = null;
|
|
25
29
|
let boxColor = DEFAULT_BOX_COlOR;
|
|
26
30
|
let clientId = "";
|
|
@@ -57,6 +61,105 @@ const VeryfiLens = (function () {
|
|
|
57
61
|
}
|
|
58
62
|
};
|
|
59
63
|
|
|
64
|
+
const getFingerprint = async () => {
|
|
65
|
+
const fpPromise = FingerprintJS.load({
|
|
66
|
+
endpoint: [
|
|
67
|
+
"https://fp.veryfi.com",
|
|
68
|
+
FingerprintJS.defaultEndpoint
|
|
69
|
+
],
|
|
70
|
+
scriptUrlPattern: [
|
|
71
|
+
"https://fp.veryfi.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",
|
|
72
|
+
FingerprintJS.defaultScriptUrlPattern
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Get the visitor identifier when you need it.
|
|
77
|
+
const fp = await fpPromise;
|
|
78
|
+
const result = await fp.get();
|
|
79
|
+
visitorId = result.visitorId;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const getFingerprintPro = async () => {
|
|
83
|
+
try {
|
|
84
|
+
const fpPromise = FingerprintJSPro.load({
|
|
85
|
+
apiKey: partnerData.fpjs_key,
|
|
86
|
+
endpoint: [
|
|
87
|
+
"https://fp.veryfi.com",
|
|
88
|
+
FingerprintJS.defaultEndpoint
|
|
89
|
+
],
|
|
90
|
+
scriptUrlPattern: [
|
|
91
|
+
"https://fp.veryfi.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",
|
|
92
|
+
FingerprintJS.defaultScriptUrlPattern
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
const fp = await fpPromise;
|
|
96
|
+
const result = await fp.get();
|
|
97
|
+
visitorIdPro = result.visitorId;
|
|
98
|
+
// console.log("Pro fingerprint obtained:", visitorIdPro);
|
|
99
|
+
return visitorIdPro;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Failed to load FingerprintJS Pro:', error);
|
|
102
|
+
console.log('Falling back to basic fingerprint...');
|
|
103
|
+
await getFingerprint();
|
|
104
|
+
return visitorId;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const generateDeviceIDifNeeded = async () => {
|
|
109
|
+
const EXPIRATION_DAYS = 7; // Set desired expiration time in days
|
|
110
|
+
const storedData = localStorage.getItem('ldidk');
|
|
111
|
+
let cachedData = storedData ? JSON.parse(storedData) : null;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const isValid = cachedData &&
|
|
116
|
+
cachedData.expiry &&
|
|
117
|
+
new Date().getTime() < cachedData.expiry;
|
|
118
|
+
|
|
119
|
+
if (!isValid) {
|
|
120
|
+
// Generate new device ID
|
|
121
|
+
if (partnerData?.fingerprint_js_on) {
|
|
122
|
+
await getFingerprintPro();
|
|
123
|
+
uuidv4 = await hexToUUIDv4(visitorId);
|
|
124
|
+
} else {
|
|
125
|
+
if (!visitorId) {
|
|
126
|
+
await getFingerprint();
|
|
127
|
+
}
|
|
128
|
+
uuidv4 = await hexToUUIDv4(visitorId);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Store with expiration
|
|
132
|
+
const expiryTime = new Date().getTime() + (EXPIRATION_DAYS * 24 * 60 * 60 * 1000);
|
|
133
|
+
const dataToStore = {
|
|
134
|
+
id: uuidv4,
|
|
135
|
+
expiry: expiryTime
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
localStorage.setItem('ldidk', JSON.stringify(dataToStore));
|
|
139
|
+
} else {
|
|
140
|
+
uuidv4 = cachedData.id;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const hexToUUIDv4 = async (inputString) => {
|
|
145
|
+
const data = new TextEncoder().encode(inputString);
|
|
146
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
147
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
148
|
+
|
|
149
|
+
// Format sections to ensure correct lengths
|
|
150
|
+
const sections = [
|
|
151
|
+
hashArray.slice(0, 4).map(b => b.toString(16).padStart(2, '0')).join(''), // 8 chars
|
|
152
|
+
hashArray.slice(4, 6).map(b => b.toString(16).padStart(2, '0')).join(''), // 4 chars
|
|
153
|
+
'4' + hashArray.slice(6, 8).map(b => b.toString(16).padStart(2, '0')).join('').substring(1), // 4 chars, starts with 4
|
|
154
|
+
'8' + hashArray.slice(8, 10).map(b => b.toString(16).padStart(2, '0')).join('').substring(1), // 4 chars, starts with 8
|
|
155
|
+
hashArray.slice(10, 16).map(b => b.toString(16).padStart(2, '0')).join('') // 12 chars
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
const uuid = sections.join('-').toLowerCase();
|
|
159
|
+
|
|
160
|
+
return uuid;
|
|
161
|
+
};
|
|
162
|
+
|
|
60
163
|
const setClientId = (key) => {
|
|
61
164
|
clientId = key;
|
|
62
165
|
};
|
|
@@ -137,11 +240,11 @@ const VeryfiLens = (function () {
|
|
|
137
240
|
const video = videoRef;
|
|
138
241
|
video.srcObject = stream;
|
|
139
242
|
wasmWrapper.setStitcherCallback(logLongDocument);
|
|
243
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
140
244
|
})
|
|
141
245
|
.catch((err) => {
|
|
142
246
|
console.log(`[Event] Error: ${err}`);
|
|
143
247
|
});
|
|
144
|
-
torchTrack = stream.getVideoTracks()[0];
|
|
145
248
|
} catch (error) {
|
|
146
249
|
console.error("Error accessing the camera", error);
|
|
147
250
|
}
|
|
@@ -157,7 +260,6 @@ const VeryfiLens = (function () {
|
|
|
157
260
|
if (navigator) {
|
|
158
261
|
try {
|
|
159
262
|
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
160
|
-
console.log(devices);
|
|
161
263
|
const videoDevices = devices.filter(
|
|
162
264
|
(device) => device.kind === "videoinput"
|
|
163
265
|
);
|
|
@@ -314,6 +416,7 @@ const VeryfiLens = (function () {
|
|
|
314
416
|
const video = videoRef;
|
|
315
417
|
video.srcObject = stream;
|
|
316
418
|
wasmWrapper.setDocumentCallback(logDocument);
|
|
419
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
317
420
|
|
|
318
421
|
// Add event listener to handle orientation changes on mobile
|
|
319
422
|
if (!isDesktop) {
|
|
@@ -326,7 +429,6 @@ const VeryfiLens = (function () {
|
|
|
326
429
|
video.srcObject = newStream;
|
|
327
430
|
});
|
|
328
431
|
}
|
|
329
|
-
torchTrack = stream.getVideoTracks()[0];
|
|
330
432
|
} catch (error) {
|
|
331
433
|
console.error("Error accessing the camera", error);
|
|
332
434
|
}
|
|
@@ -482,7 +584,7 @@ const VeryfiLens = (function () {
|
|
|
482
584
|
imgString = cropImgCanvas.toDataURL("image/jpeg");
|
|
483
585
|
image = cropImgCanvas;
|
|
484
586
|
} else {
|
|
485
|
-
console.log(isDocument);
|
|
587
|
+
// console.log(isDocument);
|
|
486
588
|
imgString = image;
|
|
487
589
|
}
|
|
488
590
|
// setBlurStatus(blurLevel); gives 0 all the time
|
|
@@ -576,7 +678,7 @@ const VeryfiLens = (function () {
|
|
|
576
678
|
);
|
|
577
679
|
|
|
578
680
|
creditCardStatus = status;
|
|
579
|
-
console.log(newData);
|
|
681
|
+
// console.log(newData);
|
|
580
682
|
Object.keys(newData).forEach((key) => {
|
|
581
683
|
// Check also for empty string along with undefined and null
|
|
582
684
|
if (
|
|
@@ -860,10 +962,16 @@ const VeryfiLens = (function () {
|
|
|
860
962
|
};
|
|
861
963
|
|
|
862
964
|
const createElement = (type, id, classes, container) => {
|
|
965
|
+
if (!container) {
|
|
966
|
+
console.warn('Container element not found. Make sure "veryfi-container" exists in the DOM');
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
|
|
863
970
|
const element = document.createElement(type);
|
|
864
971
|
element.setAttribute("id", id);
|
|
865
972
|
element.className += classes;
|
|
866
973
|
container.appendChild(element);
|
|
974
|
+
return element;
|
|
867
975
|
};
|
|
868
976
|
|
|
869
977
|
const getDeviceID = (uuid) => {
|
|
@@ -1127,14 +1235,42 @@ const VeryfiLens = (function () {
|
|
|
1127
1235
|
return browserData;
|
|
1128
1236
|
};
|
|
1129
1237
|
|
|
1238
|
+
const validatePartner = async (client_id) => {
|
|
1239
|
+
try {
|
|
1240
|
+
const response = await fetch(
|
|
1241
|
+
'https://lens.veryfi.com/rest/validate_partner',
|
|
1242
|
+
{
|
|
1243
|
+
method: 'POST',
|
|
1244
|
+
headers: {
|
|
1245
|
+
'Content-Type': 'application/json',
|
|
1246
|
+
'CLIENT-ID': client_id,
|
|
1247
|
+
},
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
if (!response.ok) {
|
|
1251
|
+
if (response.status === 401) {
|
|
1252
|
+
throw new Error('Authorization failed, please contact customer support');
|
|
1253
|
+
}
|
|
1254
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1255
|
+
}
|
|
1256
|
+
if (response.status === 200) {
|
|
1257
|
+
console.log('Partner validated')
|
|
1258
|
+
return response.json()
|
|
1259
|
+
}
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
console.error('Error validating partner:', error);
|
|
1262
|
+
throw error;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1130
1266
|
return {
|
|
1131
|
-
initWasm: async (
|
|
1267
|
+
initWasm: async (client_id) => {
|
|
1132
1268
|
isDocumentProcess = true;
|
|
1133
1269
|
userAgent = navigator.userAgent;
|
|
1134
|
-
|
|
1270
|
+
partnerData = await validatePartner(client_id);
|
|
1135
1271
|
|
|
1136
|
-
if (session) {
|
|
1137
|
-
lensSessionKey = session;
|
|
1272
|
+
if (partnerData.session) {
|
|
1273
|
+
lensSessionKey = partnerData.session;
|
|
1138
1274
|
createCanvases();
|
|
1139
1275
|
videoRef = document.getElementById("veryfi-video-ref");
|
|
1140
1276
|
const video = videoRef;
|
|
@@ -1156,13 +1292,14 @@ const VeryfiLens = (function () {
|
|
|
1156
1292
|
}
|
|
1157
1293
|
},
|
|
1158
1294
|
|
|
1159
|
-
initWasmLong: async (
|
|
1295
|
+
initWasmLong: async (client_id) => {
|
|
1296
|
+
partnerData = await validatePartner(client_id);
|
|
1297
|
+
console.log(partnerData, 'partnerData');
|
|
1160
1298
|
isStitchingProcess = false;
|
|
1161
1299
|
userAgent = navigator.userAgent;
|
|
1162
|
-
device_uuid = new DeviceUUID(userAgent).get();
|
|
1163
1300
|
|
|
1164
|
-
if (session) {
|
|
1165
|
-
lensSessionKey = session;
|
|
1301
|
+
if (partnerData.session) {
|
|
1302
|
+
lensSessionKey = partnerData.session;
|
|
1166
1303
|
createCanvases();
|
|
1167
1304
|
videoRef = document.getElementById("veryfi-video-ref");
|
|
1168
1305
|
const video = videoRef;
|
|
@@ -1184,10 +1321,10 @@ const VeryfiLens = (function () {
|
|
|
1184
1321
|
}
|
|
1185
1322
|
},
|
|
1186
1323
|
|
|
1187
|
-
initUploadWasm: async (
|
|
1188
|
-
|
|
1324
|
+
initUploadWasm: async (client_id) => {
|
|
1325
|
+
partnerData = await validatePartner(client_id);
|
|
1326
|
+
if (partnerData.session) {
|
|
1189
1327
|
userAgent = navigator.userAgent;
|
|
1190
|
-
device_uuid = new DeviceUUID(userAgent).get();
|
|
1191
1328
|
if (client_id) {
|
|
1192
1329
|
await startUploadWasm(client_id);
|
|
1193
1330
|
} else {
|
|
@@ -1200,51 +1337,62 @@ const VeryfiLens = (function () {
|
|
|
1200
1337
|
}
|
|
1201
1338
|
},
|
|
1202
1339
|
|
|
1203
|
-
initCC: async (
|
|
1340
|
+
initCC: async (client_id) => {
|
|
1204
1341
|
isDocumentProcess = true;
|
|
1205
1342
|
userAgent = navigator.userAgent;
|
|
1206
|
-
|
|
1343
|
+
partnerData = await validatePartner(client_id);
|
|
1207
1344
|
ShouldProcessCC = true;
|
|
1208
1345
|
CCPhase = "ScanningFront";
|
|
1209
1346
|
cardData = { status: "", number: "", name: "", date: "", cvv: "" };
|
|
1210
1347
|
|
|
1211
|
-
if (session) {
|
|
1212
|
-
lensSessionKey = session;
|
|
1348
|
+
if (partnerData.session) {
|
|
1349
|
+
lensSessionKey = partnerData.session;
|
|
1213
1350
|
const container = document.getElementById("veryfi-container");
|
|
1351
|
+
|
|
1352
|
+
if (!container) {
|
|
1353
|
+
console.error('Container element "veryfi-container" not found in the DOM');
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1214
1357
|
const generalClasses = "absolute sm:rounded-md h-full max-w-none";
|
|
1215
|
-
createElement(
|
|
1358
|
+
const videoElement = createElement(
|
|
1216
1359
|
"video",
|
|
1217
1360
|
"veryfi-video-ref",
|
|
1218
1361
|
`${generalClasses} z-10`,
|
|
1219
1362
|
container
|
|
1220
1363
|
);
|
|
1221
1364
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1365
|
+
if (videoElement) {
|
|
1366
|
+
videoRef = videoElement;
|
|
1367
|
+
const video = videoRef;
|
|
1368
|
+
video.playsInline = true;
|
|
1369
|
+
video.preload = "metadata";
|
|
1370
|
+
video.autoplay = true;
|
|
1371
|
+
frameRef = document.getElementById("veryfi-frame-ref");
|
|
1372
|
+
boxRef = document.getElementById("veryfi-box-ref");
|
|
1373
|
+
if (client_id) {
|
|
1374
|
+
startWasmCC(client_id);
|
|
1375
|
+
} else {
|
|
1376
|
+
console.log("No client id provided");
|
|
1377
|
+
return false;
|
|
1378
|
+
}
|
|
1234
1379
|
}
|
|
1235
1380
|
} else {
|
|
1236
1381
|
console.log("No session token provided");
|
|
1237
|
-
return;
|
|
1382
|
+
return false;
|
|
1238
1383
|
}
|
|
1384
|
+
|
|
1385
|
+
return true;
|
|
1239
1386
|
},
|
|
1240
1387
|
|
|
1241
|
-
initChecks: async (
|
|
1388
|
+
initChecks: async (client_id) => {
|
|
1242
1389
|
isDocumentProcess = true;
|
|
1243
1390
|
userAgent = navigator.userAgent;
|
|
1244
|
-
|
|
1391
|
+
clientId = client_id;
|
|
1392
|
+
partnerData = await validatePartner(clientId);
|
|
1245
1393
|
|
|
1246
|
-
if (session) {
|
|
1247
|
-
lensSessionKey = session;
|
|
1394
|
+
if (partnerData.session) {
|
|
1395
|
+
lensSessionKey = partnerData.session;
|
|
1248
1396
|
createCheckCanvases();
|
|
1249
1397
|
videoRef = document.getElementById("veryfi-video-ref");
|
|
1250
1398
|
const video = videoRef;
|
|
@@ -1254,8 +1402,8 @@ const VeryfiLens = (function () {
|
|
|
1254
1402
|
frameRef = document.getElementById("veryfi-frame-ref");
|
|
1255
1403
|
boxRef = document.getElementById("veryfi-box-ref");
|
|
1256
1404
|
cropImgRef = document.getElementById("veryfi-crop-img-ref");
|
|
1257
|
-
if (
|
|
1258
|
-
startWasmChecks(
|
|
1405
|
+
if (clientId) {
|
|
1406
|
+
startWasmChecks(clientId);
|
|
1259
1407
|
} else {
|
|
1260
1408
|
console.log("No client id provided");
|
|
1261
1409
|
return;
|
|
@@ -1289,6 +1437,7 @@ const VeryfiLens = (function () {
|
|
|
1289
1437
|
setImage && setImage(finalImage);
|
|
1290
1438
|
stopWasm();
|
|
1291
1439
|
// wasmWrapper.releaseCallback();
|
|
1440
|
+
!uuidv4 && await generateDeviceIDifNeeded();
|
|
1292
1441
|
setIsEditing && setIsEditing(true);
|
|
1293
1442
|
return finalImage;
|
|
1294
1443
|
},
|
|
@@ -1300,14 +1449,17 @@ const VeryfiLens = (function () {
|
|
|
1300
1449
|
stopWasm();
|
|
1301
1450
|
if (hasCoordinates) setIsDocument(true);
|
|
1302
1451
|
wasmWrapper.releaseCallback();
|
|
1452
|
+
!uuidv4 && await generateDeviceIDifNeeded();
|
|
1303
1453
|
setIsEditing && setIsEditing(true);
|
|
1304
1454
|
return finalImage;
|
|
1305
1455
|
},
|
|
1306
1456
|
|
|
1307
1457
|
captureUploaded: async (imageData) => {
|
|
1458
|
+
!uuidv4 && await generateDeviceIDifNeeded();
|
|
1308
1459
|
return await createImageBitmap(imageData).then((bitmap) => {
|
|
1309
1460
|
const wasmOutput = wasmWrapper.cropDocument(bitmap);
|
|
1310
1461
|
const { data, blurLevel, outputHeight, outputWidth } = wasmOutput;
|
|
1462
|
+
|
|
1311
1463
|
// If a document is detected and cropped
|
|
1312
1464
|
if (outputWidth > 0 && outputHeight > 0) {
|
|
1313
1465
|
const width = outputWidth;
|
|
@@ -1424,16 +1576,13 @@ const VeryfiLens = (function () {
|
|
|
1424
1576
|
},
|
|
1425
1577
|
|
|
1426
1578
|
getDeviceData: async () => {
|
|
1427
|
-
|
|
1428
|
-
userAgent = navigator.userAgent;
|
|
1429
|
-
device_uuid = new DeviceUUID(userAgent).get();
|
|
1430
|
-
}
|
|
1579
|
+
!uuidv4 && await generateDeviceIDifNeeded();
|
|
1431
1580
|
const browserData = await getBrowserData();
|
|
1432
1581
|
const UAData = flattenObject(parseUA());
|
|
1433
1582
|
|
|
1434
1583
|
return {
|
|
1435
1584
|
browser_fingerprint: { ...UAData, ...browserData },
|
|
1436
|
-
uuid:
|
|
1585
|
+
uuid: uuidv4,
|
|
1437
1586
|
source: "lens.web",
|
|
1438
1587
|
};
|
|
1439
1588
|
},
|