veryfi-lens-wasm 2.0.9 → 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 +42 -5
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
|
};
|
|
@@ -2270,6 +2272,16 @@ const VeryfiLens = (function () {
|
|
|
2270
2272
|
}
|
|
2271
2273
|
});
|
|
2272
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
|
+
|
|
2273
2285
|
if (config.container) {
|
|
2274
2286
|
state.debug_mode && console.log("Container found", config.container);
|
|
2275
2287
|
state.container = document.getElementById(config.container);
|
|
@@ -2429,6 +2441,16 @@ const VeryfiLens = (function () {
|
|
|
2429
2441
|
state[key] = config[key];
|
|
2430
2442
|
}
|
|
2431
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
|
+
}
|
|
2432
2454
|
},
|
|
2433
2455
|
|
|
2434
2456
|
stop: () => {
|
|
@@ -2436,6 +2458,8 @@ const VeryfiLens = (function () {
|
|
|
2436
2458
|
state.debug_mode && console.log("Stopping VeryfiLens");
|
|
2437
2459
|
stopLens();
|
|
2438
2460
|
removeOverlay();
|
|
2461
|
+
// Reset custom data when completely stopping the lens
|
|
2462
|
+
state.customData = {};
|
|
2439
2463
|
state.debug_mode && console.log("VeryfiLens stopped successfully");
|
|
2440
2464
|
} catch (error) {
|
|
2441
2465
|
console.error("Error stopping VeryfiLens:", error);
|
|
@@ -2452,6 +2476,19 @@ const VeryfiLens = (function () {
|
|
|
2452
2476
|
console.warn('Custom submit handler must be a function');
|
|
2453
2477
|
}
|
|
2454
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
|
+
},
|
|
2455
2492
|
};
|
|
2456
2493
|
})();
|
|
2457
2494
|
|