This commit is contained in:
maaa 2024-03-11 21:52:07 +01:00
parent 9d0dbafdba
commit 2242a377b9
4 changed files with 21 additions and 18 deletions

5
main
View File

@ -11,6 +11,9 @@ from werkzeug.security import generate_password_hash, check_password_hash
from quart import Quart, render_template, request, url_for, flash, redirect, session, make_response, send_from_directory, stream_with_context, Response, request from quart import Quart, render_template, request, url_for, flash, redirect, session, make_response, send_from_directory, stream_with_context, Response, request
# Parse configuration file, and check if anything is wrong with it # Parse configuration file, and check if anything is wrong with it
if not os.path.exists("config.ini"):
print("config.ini does not exist")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read("config.ini")
@ -19,7 +22,7 @@ PORT = config["config"]["PORT"]
SECRET_KEY = config["config"]["SECRET_KEY"] SECRET_KEY = config["config"]["SECRET_KEY"]
MAX_STORAGE = config["config"]["MAX_STORAGE"] MAX_STORAGE = config["config"]["MAX_STORAGE"]
if SECRET_KEY == "placeholder": if SECRET_KEY == "supersecretkey" or "placeholder":
print("[WARNING] Secret key not set") print("[WARNING] Secret key not set")
# Define Quart # Define Quart

View File

@ -9,7 +9,7 @@ if (localStorage.getItem("DONOTSHARE-password") !== null) {
throw new Error(); throw new Error();
} }
let remote = "" let remote = "https://notes.hectabit.org"
let usernameBox = document.getElementById("usernameBox") let usernameBox = document.getElementById("usernameBox")
let passwordBox = document.getElementById("passwordBox") let passwordBox = document.getElementById("passwordBox")
@ -111,7 +111,7 @@ signupButton.addEventListener("click", (event) => {
return key return key
}; };
fetch(remote + "https://notes.hectabit.org/api/login", { fetch(remote + "/api/login", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
username: username, username: username,
@ -135,7 +135,7 @@ signupButton.addEventListener("click", (event) => {
} }
else if (response.status == 401) { else if (response.status == 401) {
console.log("Trying oldhash") console.log("Trying oldhash")
fetch(remote + "https://notes.hectabit.org/api/login", { fetch(remote + "/api/login", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
username: username, username: username,

View File

@ -13,7 +13,7 @@ if (localStorage.getItem("CACHE-username") !== null) {
document.getElementById("usernameBox").innerText = localStorage.getItem("CACHE-username") document.getElementById("usernameBox").innerText = localStorage.getItem("CACHE-username")
} }
let remote = "" let remote = "https://notes.hectabit.org"
function formatBytes(a, b = 2) { if (!+a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1000)); return `${parseFloat((a / Math.pow(1000, d)).toFixed(c))} ${["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]}` } function formatBytes(a, b = 2) { if (!+a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1000)); return `${parseFloat((a / Math.pow(1000, d)).toFixed(c))} ${["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]}` }
@ -208,7 +208,7 @@ function truncateString(str, num) {
function updateUserInfo() { function updateUserInfo() {
fetch(remote + "https://notes.hectabit.org/api/userinfo", { fetch(remote + "/api/userinfo", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -259,7 +259,7 @@ exitThing.addEventListener("click", (event) => {
}); });
deleteMyAccountButton.addEventListener("click", (event) => { deleteMyAccountButton.addEventListener("click", (event) => {
if (confirm("Are you REALLY sure that you want to delete your account? There's no going back!") == true) { if (confirm("Are you REALLY sure that you want to delete your account? There's no going back!") == true) {
fetch(remote + "https://notes.hectabit.org/api/deleteaccount", { fetch(remote + "/api/deleteaccount", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -281,7 +281,7 @@ sessionManagerButton.addEventListener("click", (event) => {
optionsDiv.classList.add("hidden") optionsDiv.classList.add("hidden")
sessionManagerDiv.classList.remove("hidden") sessionManagerDiv.classList.remove("hidden")
fetch(remote + "https://notes.hectabit.org/api/sessions/list", { fetch(remote + "/api/sessions/list", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -320,7 +320,7 @@ sessionManagerButton.addEventListener("click", (event) => {
} }
sessionRemoveButton.addEventListener("click", (event) => { sessionRemoveButton.addEventListener("click", (event) => {
fetch(remote + "https://notes.hectabit.org/api/sessions/remove", { fetch(remote + "/api/sessions/remove", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -370,7 +370,7 @@ function selectNote(nameithink) {
let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink); let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink);
thingArray.classList.add("selected") thingArray.classList.add("selected")
fetch(remote + "https://notes.hectabit.org/api/readnote", { fetch(remote + "/api/readnote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -414,7 +414,7 @@ function selectNote(nameithink) {
let encryptedText = CryptoJS.AES.encrypt(noteBox.value, password).toString(); let encryptedText = CryptoJS.AES.encrypt(noteBox.value, password).toString();
if (selectedNote == nameithink) { if (selectedNote == nameithink) {
fetch(remote + "https://notes.hectabit.org/api/editnote", { fetch(remote + "/api/editnote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -443,7 +443,7 @@ function selectNote(nameithink) {
} }
function updateNotes() { function updateNotes() {
fetch(remote + "https://notes.hectabit.org/api/listnotes", { fetch(remote + "/api/listnotes", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -476,7 +476,7 @@ function updateNotes() {
noteButton.addEventListener("click", (event) => { noteButton.addEventListener("click", (event) => {
if (event.ctrlKey) { if (event.ctrlKey) {
fetch(remote + "https://notes.hectabit.org/api/removenote", { fetch(remote + "/api/removenote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -508,7 +508,7 @@ updateNotes()
newNote.addEventListener("click", (event) => { newNote.addEventListener("click", (event) => {
let noteName = "New note" let noteName = "New note"
let encryptedName = CryptoJS.AES.encrypt(noteName, password).toString(); let encryptedName = CryptoJS.AES.encrypt(noteName, password).toString();
fetch(remote + "https://notes.hectabit.org/api/newnote", { fetch(remote + "/api/newnote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -542,7 +542,7 @@ function downloadObjectAsJson(exportObj, exportName) {
function exportNotes() { function exportNotes() {
let noteExport = [] let noteExport = []
fetch(remote + "https://notes.hectabit.org/api/exportnotes", { fetch(remote + "/api/exportnotes", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -610,7 +610,7 @@ removeBox.addEventListener("click", (event) => {
if (selectedNote == 0) { if (selectedNote == 0) {
displayError("You need to select a note first!") displayError("You need to select a note first!")
} else { } else {
fetch(remote + "https://notes.hectabit.org/api/removenote", { fetch(remote + "/api/removenote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,

View File

@ -9,7 +9,7 @@ if (localStorage.getItem("DONOTSHARE-password") !== null) {
throw new Error(); throw new Error();
} }
let remote = "" let remote = "https://notes.hectabit.org"
let usernameBox = document.getElementById("usernameBox") let usernameBox = document.getElementById("usernameBox")
let passwordBox = document.getElementById("passwordBox") let passwordBox = document.getElementById("passwordBox")
@ -63,7 +63,7 @@ signupButton.addEventListener("click", (event) => {
}; };
fetch(remote + "https://notes.hectabit.org/api/signup", { fetch(remote + "/api/signup", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
username: username, username: username,