Skip to content

Commit ab46685

Browse files
Merge pull request #187 from ArunKumar-SF3979/patch-1
v29.2.4
2 parents eaf6ce2 + 5782f24 commit ab46685

File tree

1 file changed

+68
-7
lines changed

1 file changed

+68
-7
lines changed

Common/wwwroot/scripts/common/index.js

+68-7
Original file line numberDiff line numberDiff line change
@@ -1347,14 +1347,75 @@ window.getUserAgent = function () {
13471347
// Session based AI tokens for users
13481348
async function fingerPrint() {
13491349
try {
1350-
// Import FingerprintJS and load the agent
1351-
const FingerprintJS = await import('https://openfpcdn.io/fingerprintjs/v4');
1352-
const fp = await FingerprintJS.load();
1350+
var canvas = document.body.appendChild(document.createElement('canvas'));
1351+
canvas.width = 600;
1352+
canvas.height = 300;
1353+
canvas.style.display = "none";
1354+
const ctx = canvas.getContext("2d");
1355+
const size = 24;
1356+
const diamondSize = 28;
1357+
const gap = 4;
1358+
const startX = 30;
1359+
const startY = 30;
1360+
const blue = "#1A3276";
1361+
const orange = "#F28C00";
1362+
const colorMap = [
1363+
["blue", "blue", "diamond"],
1364+
["blue", "orange", "blue"],
1365+
["blue", "blue", "blue"]
1366+
];
1367+
function drawSquare(x, y, color) {
1368+
ctx.fillStyle = color;
1369+
ctx.fillRect(x, y, size, size);
1370+
}
1371+
function drawDiamond(centerX, centerY, size, color) {
1372+
ctx.fillStyle = color;
1373+
ctx.beginPath();
1374+
ctx.moveTo(centerX, centerY - size / 2);
1375+
ctx.lineTo(centerX + size / 2, centerY);
1376+
ctx.lineTo(centerX, centerY + size / 2);
1377+
ctx.lineTo(centerX - size / 2, centerY);
1378+
ctx.closePath();
1379+
ctx.fill();
1380+
}
1381+
for (let row = 0; row < 3; row++) {
1382+
for (let col = 0; col < 3; col++) {
1383+
const type = colorMap[row][col];
1384+
const x = startX + col * (size + gap);
1385+
const y = startY + row * (size + gap);
1386+
if (type === "blue") drawSquare(x, y, blue);
1387+
else if (type === "orange") drawSquare(x, y, orange);
1388+
else if (type === "diamond") drawDiamond(x + size / 2, y + size / 2, diamondSize, orange);
1389+
}
1390+
}
1391+
ctx.font = "20px Arial";
1392+
ctx.fillStyle = blue;
1393+
ctx.textBaseline = "middle";
1394+
ctx.fillText("Syncfusion", startX + 3 * (size + gap) + 20, startY + size + gap);
1395+
ctx.globalCompositeOperation = "multiply";
1396+
ctx.fillStyle = "rgb(255,0,255)";
1397+
ctx.beginPath(); ctx.arc(50, 200, 50, 0, Math.PI * 2); ctx.fill();
1398+
ctx.fillStyle = "rgb(0,255,255)";
1399+
ctx.beginPath(); ctx.arc(100, 200, 50, 0, Math.PI * 2); ctx.fill();
1400+
ctx.fillStyle = "rgb(255,255,0)";
1401+
ctx.beginPath(); ctx.arc(75, 250, 50, 0, Math.PI * 2); ctx.fill();
1402+
ctx.fillStyle = "rgb(255,0,255)";
1403+
ctx.beginPath();
1404+
ctx.arc(200, 200, 75, 0, Math.PI * 2, true);
1405+
ctx.arc(200, 200, 25, 0, Math.PI * 2, true);
1406+
ctx.fill("evenodd");
1407+
const sha256 = async function (str) {
1408+
const encoder = new TextEncoder();
1409+
const data = encoder.encode(str);
1410+
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
1411+
const hashArray = Array.from(new Uint8Array(hashBuffer));
1412+
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
1413+
};
13531414

1354-
// Get the visitor identifier
1355-
const result = await fp.get();
1356-
return result.visitorId;
1357-
} catch (error) {
1415+
const visitorID = sha256(canvas.toDataURL());
1416+
return visitorID;
1417+
}
1418+
catch (error) {
13581419
console.error(error);
13591420
return null;
13601421
}

0 commit comments

Comments
 (0)