Skip to content

Commit 5782f24

Browse files
v29.2.4
1 parent 4a8994d commit 5782f24

File tree

1 file changed

+71
-65
lines changed

1 file changed

+71
-65
lines changed

Common/wwwroot/scripts/common/index.js

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

13471347
// Session based AI tokens for users
13481348
async function fingerPrint() {
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();
1379-
}
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);
1349+
try {
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);
13881370
}
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-
};
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+
};
14131414

1414-
const visitorID = sha256(canvas.toDataURL());
1415-
return visitorID;
1415+
const visitorID = sha256(canvas.toDataURL());
1416+
return visitorID;
1417+
}
1418+
catch (error) {
1419+
console.error(error);
1420+
return null;
1421+
}
14161422
}
14171423

14181424
async function getRemainingTokens(userId) {

0 commit comments

Comments
 (0)