veryfi-lens-wasm 2.0.11 → 2.0.12
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 +3 -3
- package/veryfi-lens.js +52 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfi-lens-wasm",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Lens For Web SDK with WASM",
|
|
5
5
|
"main": "veryfi-lens.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"author": "George Veryfi",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fingerprintjs/fingerprintjs": "^4.
|
|
21
|
-
"@fingerprintjs/fingerprintjs-pro": "^3.11.
|
|
20
|
+
"@fingerprintjs/fingerprintjs": "^4.6.2",
|
|
21
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.11.13",
|
|
22
22
|
"fs-extra": "^11.1.1",
|
|
23
23
|
"inquirer": "^8.0.0",
|
|
24
24
|
"jszip": "^3.10.1",
|
package/veryfi-lens.js
CHANGED
|
@@ -175,6 +175,9 @@ const VeryfiLens = (function () {
|
|
|
175
175
|
codeStripsText: "Position code strip in rectangle",
|
|
176
176
|
|
|
177
177
|
customData: {},
|
|
178
|
+
|
|
179
|
+
enforceFingerprint: false,
|
|
180
|
+
disableFingerprint: false,
|
|
178
181
|
};
|
|
179
182
|
|
|
180
183
|
|
|
@@ -1961,17 +1964,19 @@ const VeryfiLens = (function () {
|
|
|
1961
1964
|
}
|
|
1962
1965
|
};
|
|
1963
1966
|
|
|
1964
|
-
const getDeviceData = async () => {
|
|
1965
|
-
|
|
1966
|
-
!state.uuidv4 && await generateDeviceIDifNeeded();
|
|
1967
|
+
const getDeviceData = async () => {
|
|
1968
|
+
// await generateDeviceIDifNeeded();
|
|
1967
1969
|
const browserData = await getBrowserData();
|
|
1968
1970
|
const UAData = flattenObject(parseUA());
|
|
1969
1971
|
|
|
1970
|
-
|
|
1972
|
+
const data = {
|
|
1971
1973
|
browser_fingerprint: { ...UAData, ...browserData },
|
|
1972
|
-
uuid: state.uuidv4,
|
|
1973
1974
|
source: "lens.web",
|
|
1974
1975
|
};
|
|
1976
|
+
if (state.uuidv4) {
|
|
1977
|
+
data.uuid = state.uuidv4;
|
|
1978
|
+
}
|
|
1979
|
+
return data;
|
|
1975
1980
|
}
|
|
1976
1981
|
|
|
1977
1982
|
const getLcdStatus = () => {
|
|
@@ -2031,12 +2036,12 @@ const VeryfiLens = (function () {
|
|
|
2031
2036
|
FingerprintJS.defaultScriptUrlPattern
|
|
2032
2037
|
]
|
|
2033
2038
|
});
|
|
2034
|
-
const result = await fp.get();
|
|
2039
|
+
const result = await fp.get({ timeout: 20000 }); // 10 second timeout
|
|
2035
2040
|
state.visitorId = result.visitorId;
|
|
2036
2041
|
state.debug_mode && console.log("Basic fingerprint obtained:", state.visitorId);
|
|
2037
2042
|
} catch (error) {
|
|
2038
2043
|
console.error('Failed to load FingerprintJS:', error);
|
|
2039
|
-
throw error;
|
|
2044
|
+
throw error; // Let generateDeviceIDifNeeded handle it
|
|
2040
2045
|
}
|
|
2041
2046
|
}
|
|
2042
2047
|
|
|
@@ -2055,16 +2060,21 @@ const VeryfiLens = (function () {
|
|
|
2055
2060
|
]
|
|
2056
2061
|
})
|
|
2057
2062
|
const fp = await fpPromise;
|
|
2058
|
-
const result = await fp.get();
|
|
2063
|
+
const result = await fp.get({ timeout: 20000 });
|
|
2059
2064
|
state.visitorId = result.visitorId;
|
|
2060
2065
|
state.debug_mode && console.log("Pro fingerprint obtained:", state.visitorId);
|
|
2061
2066
|
} catch (error) {
|
|
2062
2067
|
console.error('Failed to load FingerprintJS Pro:', error);
|
|
2063
|
-
throw error;
|
|
2068
|
+
throw error; // Let generateDeviceIDifNeeded handle it
|
|
2064
2069
|
}
|
|
2065
2070
|
}
|
|
2066
2071
|
|
|
2067
2072
|
const generateDeviceIDifNeeded = async () => {
|
|
2073
|
+
if (state.disableFingerprint) {
|
|
2074
|
+
state.uuidv4 = 'not_generated';
|
|
2075
|
+
localStorage.removeItem('ldidk');
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2068
2078
|
const EXPIRATION_DAYS = 7; // Set desired expiration time in days
|
|
2069
2079
|
|
|
2070
2080
|
const storedData = localStorage.getItem('ldidk');
|
|
@@ -2075,29 +2085,39 @@ const VeryfiLens = (function () {
|
|
|
2075
2085
|
new Date().getTime() < cachedData.expiry;
|
|
2076
2086
|
|
|
2077
2087
|
if (!isValid) {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2088
|
+
try {
|
|
2089
|
+
// Generate new device ID
|
|
2090
|
+
if (state.clientData?.fingerprint_js_on) {
|
|
2091
|
+
await getFingerprintPro();
|
|
2092
|
+
state.uuidv4 = await hexToUUIDv4(state.visitorId);
|
|
2093
|
+
} else {
|
|
2094
|
+
if (!state.visitorId) {
|
|
2095
|
+
await getFingerprint();
|
|
2096
|
+
}
|
|
2097
|
+
state.uuidv4 = await hexToUUIDv4(state.visitorId);
|
|
2085
2098
|
}
|
|
2086
|
-
|
|
2099
|
+
} catch (error) {
|
|
2100
|
+
console.warn('Fingerprint generation failed:', error);
|
|
2101
|
+
if (state.enforceFingerprint) {
|
|
2102
|
+
throw new Error('Failed to generate device ID');
|
|
2103
|
+
}
|
|
2104
|
+
state.uuidv4 = 'not_generated'; // Set to null on failure if not enforced
|
|
2087
2105
|
}
|
|
2088
2106
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2107
|
+
if (state.uuidv4) {
|
|
2108
|
+
// Store with expiration
|
|
2109
|
+
const expiryTime = new Date().getTime() + (EXPIRATION_DAYS * 24 * 60 * 60 * 1000);
|
|
2110
|
+
const dataToStore = {
|
|
2111
|
+
id: state.uuidv4,
|
|
2112
|
+
expiry: expiryTime
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
localStorage.setItem('ldidk', JSON.stringify(dataToStore));
|
|
2116
|
+
}
|
|
2097
2117
|
} else {
|
|
2098
2118
|
state.uuidv4 = cachedData.id;
|
|
2099
2119
|
}
|
|
2100
|
-
}
|
|
2120
|
+
};
|
|
2101
2121
|
|
|
2102
2122
|
// Add a new function to handle bottle cap capture
|
|
2103
2123
|
const captureBottleCap = async () => {
|
|
@@ -2404,6 +2424,11 @@ const VeryfiLens = (function () {
|
|
|
2404
2424
|
|
|
2405
2425
|
state.debug_mode && console.log(state);
|
|
2406
2426
|
|
|
2427
|
+
await generateDeviceIDifNeeded();
|
|
2428
|
+
|
|
2429
|
+
state.enforceFingerprint = config.enforceFingerprint ?? false;
|
|
2430
|
+
state.disableFingerprint = config.disableFingerprint ?? false;
|
|
2431
|
+
|
|
2407
2432
|
} catch (error) {
|
|
2408
2433
|
console.error("Error initializing Lens:", error);
|
|
2409
2434
|
if (state.failureHandler && typeof state.failureHandler === 'function') {
|
|
@@ -2522,7 +2547,7 @@ const VeryfiLens = (function () {
|
|
|
2522
2547
|
},
|
|
2523
2548
|
|
|
2524
2549
|
getDeviceData: async () => {
|
|
2525
|
-
|
|
2550
|
+
await generateDeviceIDifNeeded(); // Already called, but safe
|
|
2526
2551
|
const browserData = await getBrowserData();
|
|
2527
2552
|
const UAData = flattenObject(parseUA());
|
|
2528
2553
|
|