veryfi-lens-wasm 1.2.1 → 1.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfi-lens-wasm",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Lens For Web SDK with WASM",
5
5
  "main": "veryfi-lens.js",
6
6
  "type": "module",
package/veryfi-lens.js CHANGED
@@ -448,32 +448,6 @@ const VeryfiLens = (function () {
448
448
  }
449
449
  };
450
450
 
451
- // const testCCVideo = async () => {
452
- // const video = videoRef;
453
- // video.src = './cardTest.mp4';
454
- // wasmWrapper.setCardDetectorCallback(logCard);
455
- // };
456
-
457
- const testCCVideo = async () => {
458
- console.log("TEST VIDEO");
459
- // Create a video element
460
- const video = document.createElement("video");
461
- video.src = "./cardTest.mp4";
462
- video.autoplay = true;
463
- video.muted = true; // Mute the video to avoid audio playback
464
- video.loop = true; // Loop the video
465
-
466
- // Attach the video element to the document body
467
- document.body.appendChild(video);
468
-
469
- // Set the video element as the source object of the videoRef
470
- const videoRef = document.getElementById("veryfi-video-ref"); // Assuming you have a video element with this ID
471
- videoRef.srcObject = video.captureStream();
472
-
473
- // Mock the behavior of wasmWrapper.setCardDetectorCallback
474
- wasmWrapper.setCardDetectorCallback(logCard);
475
- };
476
-
477
451
  const loadImage = (src) => {
478
452
  return new Promise((resolve, reject) => {
479
453
  const img = new Image();
@@ -1048,9 +1022,10 @@ const VeryfiLens = (function () {
1048
1022
  const startUploadWasm = async (client_id) => {
1049
1023
  await wasmWrapper.initialize(client_id);
1050
1024
  if (wasmWrapper) {
1051
- wasmWrapper.setDocumentCallback(logDocument);
1025
+ await wasmWrapper.setDocumentCallback(logDocument);
1052
1026
  }
1053
1027
  };
1028
+
1054
1029
  const startWasmCC = async (client_id) => {
1055
1030
  if (!wasmWrapper.loaded) {
1056
1031
  await wasmWrapper.initialize(client_id);
@@ -1070,24 +1045,6 @@ const VeryfiLens = (function () {
1070
1045
  }, INTERVAL);
1071
1046
  }
1072
1047
  };
1073
- const testWasmCC = async (client_id) => {
1074
- await wasmWrapper.initialize(client_id);
1075
- console.log("first");
1076
- if (wasmWrapper) {
1077
- testCCVideo();
1078
- requestAnimationFrame(displayVideo);
1079
- intervalRef = setInterval(() => {
1080
- if (
1081
- cardData.status === "AutoCaptureResultDone" &&
1082
- CCPhase === "ScanningBack"
1083
- ) {
1084
- clearInterval(intervalRef); // Stop sending frames once condition is met
1085
- } else {
1086
- sendCardWasm();
1087
- }
1088
- }, INTERVAL);
1089
- }
1090
- };
1091
1048
 
1092
1049
  const setBlurStatus = (variance) => {
1093
1050
  if (variance >= 9) {
@@ -1400,16 +1357,6 @@ const VeryfiLens = (function () {
1400
1357
  return;
1401
1358
  }
1402
1359
  },
1403
- testCC: (client_id) => {
1404
- console.log("testing");
1405
- isDocumentProcess = true;
1406
- userAgent = navigator.userAgent;
1407
- device_uuid = new DeviceUUID(userAgent).get();
1408
- ShouldProcessCC = true;
1409
- CCPhase = "ScanningFront";
1410
- cardData = { status: "", number: "", name: "", date: "", cvv: "" };
1411
- testWasmCC(client_id);
1412
- },
1413
1360
 
1414
1361
  startCamera: () => {
1415
1362
  console.log("[EVENT] startCamera");
@@ -1472,10 +1419,11 @@ const VeryfiLens = (function () {
1472
1419
  },
1473
1420
 
1474
1421
  captureUploaded: async (imageData) => {
1475
- return await createImageBitmap(imageData).then((bitmap) => {
1476
- const wasmOutput = wasmWrapper.cropDocument(bitmap);
1422
+ return await createImageBitmap(imageData).then(async (bitmap) => {
1423
+ const wasmOutput = await wasmWrapper.cropDocument(bitmap);
1477
1424
  const { data, blurLevel, outputHeight, outputWidth } = wasmOutput;
1478
- // If a document is detected and cropped
1425
+ // console.log(outputWidth, outputHeight, "output")
1426
+
1479
1427
  if (outputWidth > 0 && outputHeight > 0) {
1480
1428
  const width = outputWidth;
1481
1429
  const height = outputHeight;
@@ -1486,18 +1434,16 @@ const VeryfiLens = (function () {
1486
1434
  const imageData = new ImageData(data, width, height);
1487
1435
  ctx.putImageData(imageData, 0, 0);
1488
1436
  setBlurStatus(blurLevel);
1489
- wasmWrapper.releaseCallback();
1490
- stopWasm();
1491
-
1437
+ wasmWrapper.releaseCallback()
1492
1438
  const imgString = cropImgCanvas.toDataURL("image/jpeg");
1493
1439
  image = cropImgCanvas;
1494
- releaseCanvas(boxRef);
1495
1440
  setIsDocument(true);
1496
1441
  coordinates = [];
1497
1442
  return imgString.split("data:image/jpeg;base64,")[1];
1498
1443
  } else {
1499
1444
  // Return the original, uncropped image
1500
1445
  return new Promise((resolve, reject) => {
1446
+ setIsDocument(false);
1501
1447
  const reader = new FileReader();
1502
1448
  reader.readAsDataURL(imageData);
1503
1449
  reader.onload = function () {
@@ -1507,6 +1453,7 @@ const VeryfiLens = (function () {
1507
1453
  reader.onerror = function (error) {
1508
1454
  reject(error);
1509
1455
  };
1456
+ // stopWasm()
1510
1457
  });
1511
1458
  }
1512
1459
  });
@@ -1605,6 +1552,7 @@ const VeryfiLens = (function () {
1605
1552
  frameRef && frameRef.remove();
1606
1553
  boxRef && boxRef.remove();
1607
1554
  cropImgRef && cropImgRef.remove();
1555
+ // wasmWrapper && wasmWrapper.release();
1608
1556
  setIsDocument(false);
1609
1557
  },
1610
1558
 
@@ -1626,6 +1574,9 @@ const VeryfiLens = (function () {
1626
1574
  getCardPhase: () => {
1627
1575
  return CCPhase;
1628
1576
  },
1577
+ releaseWasm: () => {
1578
+ wasmWrapper.release();
1579
+ }
1629
1580
  };
1630
1581
  })();
1631
1582