veryfi-lens-wasm 1.2.5 → 1.2.7
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/package.json +1 -1
- package/veryfi-lens.js +53 -10
- package/wasm/nonsimd/veryfi-wasm.js +1 -1
- package/wasm/nonsimd/veryfi-wasm.wasm +0 -0
- package/wasm/simd/veryfi-wasm.js +1 -1
- package/wasm/simd/veryfi-wasm.wasm +0 -0
- package/wasm/tfsimd/veryfi-wasm.js +1 -1
- package/wasm/tfsimd/veryfi-wasm.wasm +0 -0
- package/wasm/wasm.js +58 -24
package/package.json
CHANGED
package/veryfi-lens.js
CHANGED
|
@@ -46,6 +46,7 @@ const VeryfiLens = (function () {
|
|
|
46
46
|
let userAgent = null;
|
|
47
47
|
let device_uuid = null;
|
|
48
48
|
let fullSizeImage;
|
|
49
|
+
let torchTrack = null
|
|
49
50
|
// let wasmWrapper = null;
|
|
50
51
|
let finalImage;
|
|
51
52
|
|
|
@@ -237,6 +238,7 @@ const VeryfiLens = (function () {
|
|
|
237
238
|
aspectRatio: isDesktop ? 9 / 16 : 16 / 9,
|
|
238
239
|
width: { ideal: 3840 },
|
|
239
240
|
height: { ideal: 2160 },
|
|
241
|
+
advanced: [{ torch: true }]
|
|
240
242
|
};
|
|
241
243
|
|
|
242
244
|
if (isAndroid) {
|
|
@@ -269,10 +271,12 @@ const VeryfiLens = (function () {
|
|
|
269
271
|
);
|
|
270
272
|
const video = videoRef;
|
|
271
273
|
video.srcObject = stream;
|
|
274
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
272
275
|
})
|
|
273
276
|
.catch((err) => {
|
|
274
277
|
console.log(`[Event] Error: ${err}`);
|
|
275
278
|
});
|
|
279
|
+
|
|
276
280
|
} catch (error) {
|
|
277
281
|
console.error("Error accessing the camera", error);
|
|
278
282
|
}
|
|
@@ -296,6 +300,7 @@ const VeryfiLens = (function () {
|
|
|
296
300
|
aspectRatio: isDesktop ? 9 / 16 : 16 / 9,
|
|
297
301
|
width: { ideal: 2560 },
|
|
298
302
|
height: { ideal: 1440 },
|
|
303
|
+
advanced: [{ torch: true }]
|
|
299
304
|
};
|
|
300
305
|
|
|
301
306
|
if (isAndroid) {
|
|
@@ -329,10 +334,12 @@ const VeryfiLens = (function () {
|
|
|
329
334
|
const video = videoRef;
|
|
330
335
|
video.srcObject = stream;
|
|
331
336
|
wasmWrapper.setStitcherCallback(logLongDocument);
|
|
337
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
332
338
|
})
|
|
333
339
|
.catch((err) => {
|
|
334
340
|
console.log(`[Event] Error: ${err}`);
|
|
335
341
|
});
|
|
342
|
+
|
|
336
343
|
} catch (error) {
|
|
337
344
|
console.error("Error accessing the camera", error);
|
|
338
345
|
}
|
|
@@ -369,6 +376,7 @@ const VeryfiLens = (function () {
|
|
|
369
376
|
aspectRatio: isDesktop ? 9 / 16 : 16 / 9,
|
|
370
377
|
width: { ideal: 3840 },
|
|
371
378
|
height: { ideal: 2160 },
|
|
379
|
+
advanced: [{ torch: true }]
|
|
372
380
|
};
|
|
373
381
|
|
|
374
382
|
if (useMainCamera) {
|
|
@@ -377,16 +385,13 @@ const VeryfiLens = (function () {
|
|
|
377
385
|
videoConfig.facingMode = "environment";
|
|
378
386
|
}
|
|
379
387
|
|
|
380
|
-
await navigator.mediaDevices
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
.catch((err) => {
|
|
388
|
-
console.log(`[Event] Error: ${err}`);
|
|
389
|
-
});
|
|
388
|
+
const stream = await navigator.mediaDevices.getUserMedia({ video: videoConfig });
|
|
389
|
+
const video = videoRef;
|
|
390
|
+
video.srcObject = stream;
|
|
391
|
+
wasmWrapper.setDocumentCallback(logDocument);
|
|
392
|
+
|
|
393
|
+
// Store the video track for torch control
|
|
394
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
390
395
|
} catch (error) {
|
|
391
396
|
console.error("Error accessing the camera", error);
|
|
392
397
|
}
|
|
@@ -423,6 +428,7 @@ const VeryfiLens = (function () {
|
|
|
423
428
|
aspectRatio: isDesktop ? 9 / 16 : 16 / 9,
|
|
424
429
|
width: { ideal: 3840 },
|
|
425
430
|
height: { ideal: 2160 },
|
|
431
|
+
advanced: [{ torch: true }]
|
|
426
432
|
};
|
|
427
433
|
|
|
428
434
|
if (useMainCamera) {
|
|
@@ -436,6 +442,7 @@ const VeryfiLens = (function () {
|
|
|
436
442
|
const video = videoRef;
|
|
437
443
|
video.srcObject = stream;
|
|
438
444
|
wasmWrapper.setCardDetectorCallback(logCard);
|
|
445
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
439
446
|
})
|
|
440
447
|
.catch((err) => {
|
|
441
448
|
console.log(`[Event] Error: ${err}`);
|
|
@@ -480,6 +487,7 @@ const VeryfiLens = (function () {
|
|
|
480
487
|
let videoConfig = {
|
|
481
488
|
width: { ideal: 3840 },
|
|
482
489
|
height: { ideal: 2160 },
|
|
490
|
+
advanced: [{ torch: true }]
|
|
483
491
|
};
|
|
484
492
|
|
|
485
493
|
if (isDesktop) {
|
|
@@ -514,6 +522,7 @@ const VeryfiLens = (function () {
|
|
|
514
522
|
video.srcObject = newStream;
|
|
515
523
|
});
|
|
516
524
|
}
|
|
525
|
+
torchTrack = stream.getVideoTracks()[0];
|
|
517
526
|
} catch (error) {
|
|
518
527
|
console.error("Error accessing the camera", error);
|
|
519
528
|
}
|
|
@@ -522,6 +531,25 @@ const VeryfiLens = (function () {
|
|
|
522
531
|
}
|
|
523
532
|
};
|
|
524
533
|
|
|
534
|
+
const toggleTorchLight = async () => {
|
|
535
|
+
if (torchTrack) {
|
|
536
|
+
const capabilities = torchTrack.getCapabilities();
|
|
537
|
+
if (capabilities.torch) {
|
|
538
|
+
try {
|
|
539
|
+
await torchTrack.applyConstraints({
|
|
540
|
+
advanced: [{ torch: !torchTrack.getConstraints().advanced?.[0]?.torch }]
|
|
541
|
+
});
|
|
542
|
+
} catch (err) {
|
|
543
|
+
console.error("Error toggling torch:", err);
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
console.log("Torch not supported on this device");
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
console.log("Camera not initialized");
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
|
|
525
553
|
const loadImage = (src) => {
|
|
526
554
|
return new Promise((resolve, reject) => {
|
|
527
555
|
const img = new Image();
|
|
@@ -1851,6 +1879,21 @@ const VeryfiLens = (function () {
|
|
|
1851
1879
|
releaseWasm: () => {
|
|
1852
1880
|
wasmWrapper.release();
|
|
1853
1881
|
},
|
|
1882
|
+
|
|
1883
|
+
toggleTorch: () => {
|
|
1884
|
+
toggleTorchLight()
|
|
1885
|
+
},
|
|
1886
|
+
|
|
1887
|
+
getLcdStatus: () => {
|
|
1888
|
+
if (wasmWrapper.lcdStatus.LCDProb > 0.5) {
|
|
1889
|
+
cardData.cvv = ""
|
|
1890
|
+
cardData.date = ""
|
|
1891
|
+
cardData.name = ""
|
|
1892
|
+
cardData.number = ""
|
|
1893
|
+
cardData.status = ""
|
|
1894
|
+
}
|
|
1895
|
+
return wasmWrapper.lcdStatus();
|
|
1896
|
+
},
|
|
1854
1897
|
};
|
|
1855
1898
|
})();
|
|
1856
1899
|
|