Initial ChronoSeal release

This commit is contained in:
thakares committed 2026-05-07 21:57:47 +05:30
commit a66debdece
48 files changed
+2362

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
const events = [];
document.addEventListener('mousemove', (e) => {
events.push({ x: e.clientX, y: e.clientY, t: performance.now() });
if (events.length > 300) events.shift();
});
export function collectEntropy(since) {
return events.filter(e => e.t > since);
}
+72
View File
@@ -0,0 +1,72 @@
import init, { generate_keypair, sign_message, compute_next_hash, run_program } from './pkg/antibot_wasm.js';
import { collectEntropy } from './entropy.js';
import { sendRequest } from './transport.js';
let session, prevHash, currentSalt, opcodesB64, lastTime;
export async function initHeartbeat() {
await init();
const pubHex = generate_keypair();
const initResp = await sendRequest('/init', 'POST', { public_key: pubHex });
session = initResp.session_id;
prevHash = initResp.initial_hash;
currentSalt = initResp.salt;
opcodesB64 = initResp.opcodes_b64;
lastTime = performance.now();
scheduleNext();
}
function scheduleNext() {
const delay = 12000 + Math.random() * 13000;
setTimeout(sendHeartbeat, delay);
}
async function sendHeartbeat() {
try {
const now = performance.now();
const events = collectEntropy(lastTime);
lastTime = now;
const stackState = JSON.stringify(run_program(opcodesB64));
const fingerprint = {
aspectRatio: (screen.width / screen.height).toFixed(10),
devicePixelRatio: String(window.devicePixelRatio),
hardwareConcurrency: navigator.hardwareConcurrency || 1
};
const timestamp = Date.now();
const entropyData = { events: events.map(e => ({ x: e.x, y: e.y, t: e.t })) };
const entropyJson = JSON.stringify(entropyData);
const signable = {
sessionId: session,
prevHash: prevHash,
timestamp: timestamp,
entropyData: entropyData,
stackState: JSON.parse(stackState),
fingerprint: fingerprint
};
const msg = JSON.stringify(signable, Object.keys(signable).sort());
const sig = sign_message(msg);
const resp = await sendRequest('/hb', 'POST', {
session_id: session,
prev_hash: prevHash,
timestamp,
entropy_data: entropyData,
stack_state: JSON.parse(stackState),
fingerprint,
signature: sig
});
if (resp.next_salt) {
currentSalt = resp.next_salt;
prevHash = compute_next_hash(prevHash, timestamp, entropyJson, stackState, currentSalt);
} else {
console.warn('Heartbeat rejected');
}
} catch (e) {
console.error(e);
} finally {
scheduleNext();
}
}
+12
View File
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Anti-Scraper Demo</title>
</head>
<body>
<h1>Protected Page</h1>
<p>Move your mouse to generate entropy.</p>
<script type="module" src="./main.js"></script>
</body>
</html>
+5
View File
@@ -0,0 +1,5 @@
import { initHeartbeat } from './heartbeat.js';
(async () => {
await initHeartbeat();
})();
+9
View File
@@ -0,0 +1,9 @@
export async function sendRequest(url, method, body) {
const res = await fetch(url, {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
return res.json();
}