veryfi-lens-wasm 2.0.8 → 2.0.10
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 +68 -15
package/package.json
CHANGED
package/veryfi-lens.js
CHANGED
|
@@ -147,22 +147,20 @@ const VeryfiLens = (function () {
|
|
|
147
147
|
submitButtonText: 'Submit Anyway',
|
|
148
148
|
retakeButtonText: 'Retake a picture',
|
|
149
149
|
|
|
150
|
-
// File upload UI text configuration
|
|
151
150
|
cropButtonText: 'Crop',
|
|
152
151
|
resetButtonText: 'Reset',
|
|
153
152
|
dropZoneText: 'Click or drag and drop to upload an image',
|
|
154
153
|
|
|
155
|
-
// Add new property for custom submit handler
|
|
156
154
|
customSubmitHandler: null,
|
|
157
155
|
|
|
158
|
-
// Add new properties for bottle cap functionality
|
|
159
156
|
bottleCapOverlay: null,
|
|
160
157
|
|
|
161
|
-
// Add new properties for code strips functionality
|
|
162
158
|
codeStripsOverlay: null,
|
|
163
159
|
rectWidth: 0.7,
|
|
164
160
|
rectHeight: 0.08,
|
|
165
161
|
codeStripsText: "Position code strip in rectangle",
|
|
162
|
+
|
|
163
|
+
customData: {},
|
|
166
164
|
};
|
|
167
165
|
|
|
168
166
|
|
|
@@ -1121,9 +1119,10 @@ const VeryfiLens = (function () {
|
|
|
1121
1119
|
const requestBody = {
|
|
1122
1120
|
image: image,
|
|
1123
1121
|
doc_type: state.lensFlavor === 'checks' ? 'checks' : 'documents',
|
|
1124
|
-
resource: "
|
|
1122
|
+
resource: "api",
|
|
1125
1123
|
client_name: state.clientData.client_name,
|
|
1126
1124
|
device_data: deviceData,
|
|
1125
|
+
...state.customData
|
|
1127
1126
|
};
|
|
1128
1127
|
|
|
1129
1128
|
const requestOptions = {
|
|
@@ -1292,6 +1291,9 @@ const VeryfiLens = (function () {
|
|
|
1292
1291
|
state.rectHeight = 0.08; // Reset to default rectangle height
|
|
1293
1292
|
state.codeStripsText = "Position code strip in rectangle"; // Reset to default text
|
|
1294
1293
|
state.codeStripsOverlay = null;
|
|
1294
|
+
|
|
1295
|
+
// Note: customData is NOT reset here as it should persist across captures
|
|
1296
|
+
// and only be reset when explicitly changed by the user
|
|
1295
1297
|
|
|
1296
1298
|
state.debug_mode && console.log("State reset complete");
|
|
1297
1299
|
};
|
|
@@ -1401,7 +1403,7 @@ const VeryfiLens = (function () {
|
|
|
1401
1403
|
}
|
|
1402
1404
|
break;
|
|
1403
1405
|
case "checks":
|
|
1404
|
-
captureChecks();
|
|
1406
|
+
await captureChecks();
|
|
1405
1407
|
break;
|
|
1406
1408
|
default:
|
|
1407
1409
|
state.finalImage = await cropWasm();
|
|
@@ -1410,8 +1412,6 @@ const VeryfiLens = (function () {
|
|
|
1410
1412
|
if (state.lensFlavor !== 'checks' && state.resultSetter && typeof state.resultSetter === 'function') {
|
|
1411
1413
|
state.resultSetter(state.finalImage);
|
|
1412
1414
|
state.updateHandler && state.updateHandler({ status: 'capture_completed' });
|
|
1413
|
-
} else if (state.lensFlavor === 'checks' && state.resultSetter && typeof state.resultSetter === 'function') {
|
|
1414
|
-
state.resultSetter = [state.frontImage, state.backImage];
|
|
1415
1415
|
}
|
|
1416
1416
|
|
|
1417
1417
|
stopLens();
|
|
@@ -1424,11 +1424,12 @@ const VeryfiLens = (function () {
|
|
|
1424
1424
|
state.docReadyResult = await docReady();
|
|
1425
1425
|
state.updateHandler && state.updateHandler({ status: 'processing_completed' });
|
|
1426
1426
|
state.debug_mode && console.log("Document processed successfully");
|
|
1427
|
-
}
|
|
1428
1427
|
|
|
1429
1428
|
if (state.resultSetter && typeof state.resultSetter === 'function') {
|
|
1430
1429
|
state.resultSetter({ ...state.docReadyResult, image: state.finalImage });
|
|
1431
1430
|
}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1432
1433
|
|
|
1433
1434
|
const isBlurry = checkIfBlurOnCapture();
|
|
1434
1435
|
|
|
@@ -1496,6 +1497,20 @@ const VeryfiLens = (function () {
|
|
|
1496
1497
|
state.cropImgRef.showSuccessBorder();
|
|
1497
1498
|
}
|
|
1498
1499
|
|
|
1500
|
+
// Process the front image with docReady
|
|
1501
|
+
state.updateHandler && state.updateHandler({ status: 'processing_started' });
|
|
1502
|
+
state.docReadyResult = await docReady();
|
|
1503
|
+
state.updateHandler && state.updateHandler({ status: 'processing_completed' });
|
|
1504
|
+
state.debug_mode && console.log("Front check image processed successfully");
|
|
1505
|
+
|
|
1506
|
+
// Update result setter with processed result
|
|
1507
|
+
if (state.resultSetter && typeof state.resultSetter === 'function') {
|
|
1508
|
+
state.resultSetter({
|
|
1509
|
+
...state.docReadyResult,
|
|
1510
|
+
frontImage: state.frontImage
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1499
1514
|
if (state.captureBackOfCheck) {
|
|
1500
1515
|
const checkCaptureModal = createCheckCaptureModal(
|
|
1501
1516
|
state.container,
|
|
@@ -1531,11 +1546,6 @@ const VeryfiLens = (function () {
|
|
|
1531
1546
|
}, removeOverlay);
|
|
1532
1547
|
state.enableSubmit && state.submitButton.show();
|
|
1533
1548
|
}
|
|
1534
|
-
if (state.resultSetter && typeof state.resultSetter === 'function') {
|
|
1535
|
-
state.resultSetter({
|
|
1536
|
-
frontImage: state.frontImage
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1539
1549
|
}
|
|
1540
1550
|
);
|
|
1541
1551
|
checkCaptureModal.show();
|
|
@@ -1564,6 +1574,12 @@ const VeryfiLens = (function () {
|
|
|
1564
1574
|
return;
|
|
1565
1575
|
}
|
|
1566
1576
|
|
|
1577
|
+
// Process the back image with docReady
|
|
1578
|
+
state.updateHandler && state.updateHandler({ status: 'processing_started' });
|
|
1579
|
+
state.docReadyResult = await docReady();
|
|
1580
|
+
state.updateHandler && state.updateHandler({ status: 'processing_completed' });
|
|
1581
|
+
state.debug_mode && console.log("Back check image processed successfully");
|
|
1582
|
+
|
|
1567
1583
|
// Both checks passed, show success border
|
|
1568
1584
|
if (state.cropImgRef && typeof state.cropImgRef.showSuccessBorder === 'function') {
|
|
1569
1585
|
state.cropImgRef.showSuccessBorder();
|
|
@@ -1592,9 +1608,11 @@ const VeryfiLens = (function () {
|
|
|
1592
1608
|
state.enableSubmit && state.submitButton.show();
|
|
1593
1609
|
}
|
|
1594
1610
|
|
|
1595
|
-
// Call success handler with properly structured data
|
|
1611
|
+
// Call success handler with properly structured data including docReady results
|
|
1596
1612
|
if (state.resultSetter && typeof state.resultSetter === 'function') {
|
|
1613
|
+
state.debug_mode && console.log("Setting result setter");
|
|
1597
1614
|
state.resultSetter({
|
|
1615
|
+
...state.docReadyResult,
|
|
1598
1616
|
frontImage: state.frontImage,
|
|
1599
1617
|
backImage: state.backImage
|
|
1600
1618
|
});
|
|
@@ -2254,6 +2272,16 @@ const VeryfiLens = (function () {
|
|
|
2254
2272
|
}
|
|
2255
2273
|
});
|
|
2256
2274
|
|
|
2275
|
+
// Handle customData specifically with validation
|
|
2276
|
+
if (config.customData) {
|
|
2277
|
+
if (typeof config.customData === 'object' && config.customData !== null && !Array.isArray(config.customData)) {
|
|
2278
|
+
state.customData = { ...config.customData };
|
|
2279
|
+
config.debug_mode && console.log("Custom data set:", state.customData);
|
|
2280
|
+
} else {
|
|
2281
|
+
console.warn('customData must be a plain object. Ignoring invalid customData.');
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2257
2285
|
if (config.container) {
|
|
2258
2286
|
state.debug_mode && console.log("Container found", config.container);
|
|
2259
2287
|
state.container = document.getElementById(config.container);
|
|
@@ -2413,6 +2441,16 @@ const VeryfiLens = (function () {
|
|
|
2413
2441
|
state[key] = config[key];
|
|
2414
2442
|
}
|
|
2415
2443
|
});
|
|
2444
|
+
|
|
2445
|
+
// Handle customData specifically with validation
|
|
2446
|
+
if (config.customData !== undefined) {
|
|
2447
|
+
if (typeof config.customData === 'object' && config.customData !== null && !Array.isArray(config.customData)) {
|
|
2448
|
+
state.customData = { ...config.customData };
|
|
2449
|
+
state.debug_mode && console.log("Custom data updated:", state.customData);
|
|
2450
|
+
} else {
|
|
2451
|
+
console.warn('customData must be a plain object. Ignoring invalid customData.');
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2416
2454
|
},
|
|
2417
2455
|
|
|
2418
2456
|
stop: () => {
|
|
@@ -2420,6 +2458,8 @@ const VeryfiLens = (function () {
|
|
|
2420
2458
|
state.debug_mode && console.log("Stopping VeryfiLens");
|
|
2421
2459
|
stopLens();
|
|
2422
2460
|
removeOverlay();
|
|
2461
|
+
// Reset custom data when completely stopping the lens
|
|
2462
|
+
state.customData = {};
|
|
2423
2463
|
state.debug_mode && console.log("VeryfiLens stopped successfully");
|
|
2424
2464
|
} catch (error) {
|
|
2425
2465
|
console.error("Error stopping VeryfiLens:", error);
|
|
@@ -2436,6 +2476,19 @@ const VeryfiLens = (function () {
|
|
|
2436
2476
|
console.warn('Custom submit handler must be a function');
|
|
2437
2477
|
}
|
|
2438
2478
|
},
|
|
2479
|
+
|
|
2480
|
+
setCustomData: (data) => {
|
|
2481
|
+
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
2482
|
+
state.customData = { ...data };
|
|
2483
|
+
state.debug_mode && console.log("Custom data set:", state.customData);
|
|
2484
|
+
} else {
|
|
2485
|
+
console.warn('Custom data must be a plain object');
|
|
2486
|
+
}
|
|
2487
|
+
},
|
|
2488
|
+
|
|
2489
|
+
getCustomData: () => {
|
|
2490
|
+
return { ...state.customData };
|
|
2491
|
+
},
|
|
2439
2492
|
};
|
|
2440
2493
|
})();
|
|
2441
2494
|
|