Skip to content

Commit 4a8994d

Browse files
v29.2.4
1 parent eaf6ce2 commit 4a8994d

File tree

1 file changed

+66
-11
lines changed

1 file changed

+66
-11
lines changed

Common/wwwroot/scripts/common/index.js

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,18 +1346,73 @@ window.getUserAgent = function () {
13461346

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

13631418
async function getRemainingTokens(userId) {

0 commit comments

Comments
 (0)