2024-04-26 21:12:56 +01:00
|
|
|
if (localStorage.getItem("DONOTSHARE-secretkey") !== null) {
|
|
|
|
window.location.replace("/app" + window.location.search)
|
|
|
|
document.body.innerHTML = "Redirecting..."
|
|
|
|
throw new Error();
|
|
|
|
}
|
|
|
|
if (localStorage.getItem("DONOTSHARE-password") !== null) {
|
|
|
|
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")
|
2024-07-26 19:25:41 +01:00
|
|
|
let nextButton = document.getElementById("nextButton")
|
2024-04-26 21:12:56 +01:00
|
|
|
let signupButton = document.getElementById("signupButton")
|
|
|
|
let inputNameBox = document.getElementById("inputNameBox")
|
|
|
|
let backButton = document.getElementById("backButton")
|
2024-07-26 19:25:41 +01:00
|
|
|
let inputContainer = document.getElementById("inputContainer")
|
2024-04-26 21:12:56 +01:00
|
|
|
|
|
|
|
usernameBox.classList.remove("hidden")
|
|
|
|
inputNameBox.innerText = "Username:"
|
|
|
|
|
|
|
|
let currentInputType = 0
|
|
|
|
|
|
|
|
function showInput(inputType) {
|
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
|
|
|
if (inputType === 0) {
|
2024-07-26 19:25:41 +01:00
|
|
|
inputContainer.classList.remove("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
usernameBox.classList.remove("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
signupButton.classList.remove("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
passwordBox.classList.add("hidden")
|
|
|
|
backButton.classList.add("hidden")
|
|
|
|
inputNameBox.innerText = "Username:"
|
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
|
|
|
let serviceName
|
|
|
|
fetch("/api/servicename")
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((response) => {
|
|
|
|
serviceName = response["name"]
|
|
|
|
statusBox.innerText = "Login to your " + serviceName + " account!"
|
|
|
|
currentInputType = 0
|
|
|
|
})
|
|
|
|
} else if (inputType === 1) {
|
2024-07-26 19:25:41 +01:00
|
|
|
inputContainer.classList.remove("hidden")
|
|
|
|
signupButton.classList.add("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
usernameBox.classList.add("hidden")
|
|
|
|
passwordBox.classList.remove("hidden")
|
|
|
|
backButton.classList.remove("hidden")
|
|
|
|
inputNameBox.innerText = "Password:"
|
|
|
|
currentInputType = 1
|
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
|
|
|
} else if (inputType === 2) {
|
2024-04-26 21:12:56 +01:00
|
|
|
signupButton.classList.add("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
nextButton.classList.add("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
backButton.classList.add("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
inputContainer.classList.add("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
inputNameBox.classList.add("hidden")
|
|
|
|
currentInputType = 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showElements(yesorno) {
|
|
|
|
if (!yesorno) {
|
|
|
|
usernameBox.classList.add("hidden")
|
|
|
|
passwordBox.classList.add("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
nextButton.classList.add("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
backButton.classList.add("hidden")
|
|
|
|
inputNameBox.classList.add("hidden")
|
|
|
|
showInput(currentInputType)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
usernameBox.classList.remove("hidden")
|
|
|
|
passwordBox.classList.remove("hidden")
|
2024-07-26 19:25:41 +01:00
|
|
|
nextButton.classList.remove("hidden")
|
2024-04-26 21:12:56 +01:00
|
|
|
backButton.classList.remove("hidden")
|
|
|
|
inputNameBox.classList.remove("hidden")
|
|
|
|
showInput(currentInputType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
nextButton.addEventListener("click", async () => {
|
2024-04-26 21:12:56 +01:00
|
|
|
if (passwordBox.classList.contains("hidden")) {
|
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
|
|
|
if (usernameBox.value === "") {
|
2024-04-26 21:12:56 +01:00
|
|
|
statusBox.innerText = "A username is required!"
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
statusBox.innerText = "Welcome back, " + usernameBox.value + "!"
|
|
|
|
}
|
|
|
|
showInput(1)
|
|
|
|
} else {
|
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 (password === "") {
|
|
|
|
statusBox.innerText = "A password is required!"
|
|
|
|
return
|
|
|
|
}
|
2024-04-26 21:12:56 +01:00
|
|
|
|
2024-07-26 19:25:41 +01:00
|
|
|
showInput(2)
|
|
|
|
showElements(true)
|
|
|
|
|
|
|
|
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
|
|
|
async function migrateLegacyPassword(secretKey, password) {
|
|
|
|
return await fetch("/api/changepassword", {
|
2024-04-26 21:12:56 +01:00
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
2024-07-26 19:25:41 +01:00
|
|
|
secretKey: secretKey,
|
|
|
|
newPassword: password,
|
|
|
|
migration: true
|
2024-04-26 21:12:56 +01:00
|
|
|
}),
|
|
|
|
headers: {
|
2024-07-26 19:25:41 +01:00
|
|
|
"Content-Type": "application/json; charset=UTF-8",
|
2024-04-26 21:12:56 +01:00
|
|
|
}
|
|
|
|
})
|
2024-07-26 19:25:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async function hashpassold(pass) {
|
|
|
|
let key = pass
|
|
|
|
for (let i = 0; i < 128; i++) {
|
|
|
|
key = await hashwasm.sha3(key)
|
|
|
|
}
|
|
|
|
return key
|
|
|
|
}
|
|
|
|
|
|
|
|
statusBox.innerText = "Hashing password..."
|
|
|
|
let hashedPassword = await hashpass(password)
|
|
|
|
|
|
|
|
let response = await fetch("/api/login", {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: username,
|
|
|
|
password: hashedPassword,
|
|
|
|
modern: true
|
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json; charset=UTF-8"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let responseData = await response.json()
|
|
|
|
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"
|
|
|
|
}))
|
|
|
|
statusBox.innerText = "Welcome back!"
|
|
|
|
await new Promise(r => setTimeout(r, 200))
|
|
|
|
window.location.href = "/app" + window.location.search
|
|
|
|
} else if (response.status === 401) {
|
|
|
|
if (responseData["migrated"] !== true) {
|
|
|
|
statusBox.innerText = "Migrating to new password algorithm..."
|
|
|
|
let loginOld = await fetch("/api/login", {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: username,
|
|
|
|
password: hashpassold(password),
|
|
|
|
modern: false
|
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json; charset=UTF-8"
|
2024-04-26 21:12:56 +01:00
|
|
|
}
|
2024-07-26 19:25:41 +01:00
|
|
|
})
|
|
|
|
let loginDataOld = await loginOld.json()
|
|
|
|
if (loginOld.status === 401) {
|
|
|
|
statusBox.innerText = "Username or password incorrect!"
|
|
|
|
showInput(1)
|
|
|
|
showElements(true)
|
|
|
|
} else if (loginOld.status === 200) {
|
|
|
|
statusBox.innerText = "Setting up encryption keys..."
|
|
|
|
localStorage.setItem("DONOTSHARE-secretkey", loginDataOld["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"
|
|
|
|
}))
|
|
|
|
|
|
|
|
statusBox.innerText = "Migrating password..."
|
|
|
|
let status = await migrateLegacyPassword(loginDataOld["key"], hashedPass)
|
|
|
|
if (status.status === 200) {
|
|
|
|
statusBox.innerText = "Welcome back!"
|
|
|
|
await new Promise(r => setTimeout(r, 200))
|
|
|
|
window.location.href = "/app" + window.location.search
|
|
|
|
} else {
|
|
|
|
statusBox.innerText = (await status.json())["error"]
|
|
|
|
showInput(1)
|
|
|
|
showElements(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
statusBox.innerText = "Wrong username or password..."
|
|
|
|
showInput(1)
|
|
|
|
showElements(true)
|
|
|
|
}
|
|
|
|
} else if (response.status === 500) {
|
|
|
|
statusBox.innerText = responseData["error"]
|
|
|
|
showInput(1)
|
|
|
|
showElements(true)
|
|
|
|
} else {
|
|
|
|
statusBox.innerText = "Something went wrong! (error code: " + responseData["error"] + ")"
|
|
|
|
showInput(1)
|
|
|
|
showElements(true)
|
2024-04-26 21:12:56 +01:00
|
|
|
}
|
|
|
|
}
|
2024-07-26 19:25:41 +01:00
|
|
|
})
|
2024-04-26 21:12:56 +01:00
|
|
|
|
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
|
|
|
backButton.addEventListener("click", () => {
|
2024-04-26 21:12:56 +01:00
|
|
|
showInput(0)
|
|
|
|
});
|
|
|
|
|
|
|
|
showInput(0)
|
|
|
|
|
|
|
|
document.getElementById("privacyButton").addEventListener("click", function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
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
|
|
|
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 toSignup() {
|
|
|
|
window.location.href = "/signup" + window.location.search;
|
|
|
|
}
|