2024-07-26 19:25:41 +01:00
|
|
|
if (localStorage.getItem("DONOTSHARE-secretkey") !== null || localStorage.getItem("DONOTSHARE-password") !== null) {
|
2024-04-26 21:12:56 +01:00
|
|
|
window.location.replace("/app" + window.location.search)
|
|
|
|
document.body.innerHTML = "Redirecting..."
|
|
|
|
throw new Error();
|
|
|
|
}
|
|
|
|
|
|
|
|
let usernameBox = document.getElementById("usernameBox")
|
|
|
|
let passwordBox = document.getElementById("passwordBox")
|
|
|
|
let statusBox = document.getElementById("statusBox")
|
|
|
|
let signupButton = document.getElementById("signupButton")
|
2024-07-26 19:25:41 +01:00
|
|
|
let loginButton = document.getElementById("loginButton")
|
|
|
|
let inputContainer = document.getElementById("inputContainer")
|
2024-04-26 21:12:56 +01:00
|
|
|
|
|
|
|
function showElements(yesorno) {
|
|
|
|
if (!yesorno) {
|
2024-07-26 19:25:41 +01:00
|
|
|
inputContainer.classList.add("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
signupButton.classList.add("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
loginButton.classList.add("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
}
|
|
|
|
else {
|
2024-07-26 19:25:41 +01:00
|
|
|
inputContainer.classList.remove("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
signupButton.classList.remove("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
loginButton.classList.remove("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
complete = new Event("completed");
|
|
|
|
window.returnCode = undefined;
|
|
|
|
window.returnVar = undefined;
|
|
|
|
|
|
|
|
// This is for the WASM code to call when it's done. Do not remove it, even if it looks like it's never called.
|
|
|
|
|
|
|
|
function WASMComplete() {
|
|
|
|
window.dispatchEvent(complete);
|
|
|
|
}
|
|
|
|
|
2024-05-09 17:27:47 +01:00
|
|
|
signupButton.addEventListener("click", () => {
|
2024-07-26 19:25:41 +01:00
|
|
|
let username = usernameBox.value
|
|
|
|
let password = passwordBox.value
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
if (username === "") {
|
|
|
|
statusBox.innerText = "A username is required!"
|
|
|
|
return
|
|
|
|
}
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
if ((username).length > 20) {
|
|
|
|
statusBox.innerText = "Username cannot be more than 20 characters!"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (password === "") {
|
|
|
|
statusBox.innerText = "A password is required!"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if ((password).length < 8) {
|
|
|
|
statusBox.innerText = "8 or more characters are required!"
|
|
|
|
return
|
|
|
|
}
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
async function hashpass(pass) {
|
|
|
|
return await hashwasm.argon2id({
|
|
|
|
password: pass,
|
|
|
|
salt: new TextEncoder().encode("I munch Burgers!!"),
|
|
|
|
parallelism: 1,
|
|
|
|
iterations: 32,
|
|
|
|
memorySize: 19264,
|
|
|
|
hashLength: 32,
|
|
|
|
outputType: "hex"
|
|
|
|
})
|
|
|
|
}
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
showElements(false)
|
|
|
|
statusBox.innerText = "Computing PoW Challenge... (this may take up to 5 minutes at worst, 3 seconds at best)"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compiled version of:
|
|
|
|
* hashcat-wasm (https://concord.hectabit.org/hectabit/hashcat-wasm)
|
|
|
|
* (c) Arzumify
|
|
|
|
* @license AGPL-3.0
|
|
|
|
* Since this is my software, if you use it with proprietary servers, I will make sure you will walk across hot coals (just kidding, probably).
|
|
|
|
* I'm not kidding about the license though.
|
|
|
|
* I should stop including comments into JS and possibly minify this code. Oh, well.
|
|
|
|
*/
|
|
|
|
|
|
|
|
window.resourceExtra = "I love Burgerauth!!"
|
|
|
|
|
|
|
|
const go = new Go();
|
|
|
|
WebAssembly.instantiateStreaming(fetch("/static/wasm/hashcat.wasm"), go.importObject).then((result) => {
|
|
|
|
go.run(result.instance);
|
|
|
|
})
|
|
|
|
|
|
|
|
window.addEventListener("completed", async () => {
|
|
|
|
if (window.returnCode === 1) {
|
|
|
|
statusBox.innerText = "Please do not expose your computer to cosmic rays (an impossible logical event has occurred)."
|
|
|
|
showElements(true)
|
|
|
|
return
|
|
|
|
} else if (window.returnCode === 2) {
|
|
|
|
statusBox.innerText = "The PoW Challenge has failed. Please try again."
|
|
|
|
showElements(true)
|
|
|
|
return
|
|
|
|
}
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
statusBox.innerText = "Hashing password..."
|
|
|
|
let hashedPass = await hashpass(password)
|
|
|
|
statusBox.innerText = "Contacting server..."
|
Added example configuration, updated README.md, updated background image to Public Domain image, updated styles to be in accordance with the New Burgerware Design, fixed pages displaying poorly on phones, fixed server panics being caused by incorrect JSON, made it clear AESKeyShare is not in working order, made the application not hard-code the URL, made the application not hard-code the app name, updated the CAPTCHA module to the newest version and URL, removed crypto-js, removed unneeded broken code left over from Burgernotes, removed unneeded CSS left over from Burgernotes, made page titles consistant, changed some formatting to be using camel instead of snake case, fixed various JS bad-practices, used a really long commit message.
2024-07-10 18:43:17 +01:00
|
|
|
fetch("/api/signup", {
|
2024-04-26 21:12:56 +01:00
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: username,
|
2024-07-26 19:25:41 +01:00
|
|
|
password: hashedPass,
|
|
|
|
stamp: window.returnVar
|
2024-04-26 21:12:56 +01:00
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json; charset=UTF-8"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then((response) => response)
|
2024-07-26 19:25:41 +01:00
|
|
|
.then(async (response) => {
|
|
|
|
let responseData = await response.json()
|
|
|
|
console.log(responseData)
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
if (response.status === 200) {
|
|
|
|
statusBox.innerText = "Setting up encryption keys..."
|
|
|
|
localStorage.setItem("DONOTSHARE-secretkey", responseData["key"])
|
|
|
|
localStorage.setItem("DONOTSHARE-password", await hashwasm.argon2id({
|
|
|
|
password: password,
|
|
|
|
salt: new TextEncoder().encode("I love Burgerauth!!"),
|
|
|
|
parallelism: 1,
|
|
|
|
iterations: 32,
|
|
|
|
memorySize: 19264,
|
|
|
|
hashLength: 32,
|
|
|
|
outputType: "hex"
|
|
|
|
}))
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
statusBox.innerText = "Welcome!"
|
|
|
|
await new Promise(r => setTimeout(r, 200))
|
|
|
|
window.location.href = "/app" + window.location.search
|
|
|
|
} else if (response.status === 409) {
|
|
|
|
statusBox.innerText = "Username already taken!"
|
|
|
|
showElements(true)
|
|
|
|
} else if (response.status === 500) {
|
|
|
|
statusBox.innerText = responseData["error"]
|
|
|
|
showElements(true)
|
|
|
|
} else {
|
|
|
|
statusBox.innerText = "Something went wrong! (error code: " + responseData["error"] + ")"
|
|
|
|
showElements(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2024-04-26 21:12:56 +01:00
|
|
|
|
|
|
|
document.getElementById("privacyButton").addEventListener("click", function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
2024-05-09 17:27:47 +01:00
|
|
|
const queryString = window.location.search;
|
|
|
|
window.location.href = "/privacy" + queryString;
|
2024-04-26 21:12:56 +01:00
|
|
|
});
|
2024-07-26 19:25:41 +01:00
|
|
|
|
|
|
|
function toLogin() {
|
|
|
|
window.location.href = "/login" + window.location.search;
|
|
|
|
}
|