Files
minibin/static/js/report.js
T
whoswhip 5c2427b096 reports!!!! and PoW!!!!!!!
this has taken quite a while (8 ish hours) but reports and proof of work challenges are completely implemented

the proof of work challenges are bit iffy and could be gpu accelerated which is bad, so i plan to eventually switch to something memory hard like argon2id

references used for pow:
https://dev.to/ratmd/simple-proof-of-work-in-javascript-3kgm
https://anubis.techaro.lol/docs/design/how-anubis-works
https://anubis.techaro.lol/docs/design/why-proof-of-work

as well as some other posts or repos found when searching
2026-11-20 21:31:37 -05:00

17 lines
704 B
JavaScript

const worker = new Worker("/js/pow-worker.js");
const reportForm = document.getElementById("report-form");
const submitBtn = document.getElementById("submit-btn");
const powLabel = document.getElementById("pow-label");
const challenge = reportForm.dataset;
submitBtn.disabled = true;
worker.onmessage = ({ data }) => {
submitBtn.disabled = false;
powLabel.style.display = "none";
submitBtn.classList.remove("loading");
document.getElementById("pow-result").value = data.hash;
document.getElementById("pow-nonce").value = data.nonce;
}
worker.postMessage({
challenge: reportForm.dataset.challengeData,
difficulty: Number.parseInt(reportForm.dataset.challengeDifficulty, 10),
})