feat: add basic blog features

This commit is contained in:
2026-03-09 22:17:39 +01:00
commit c16657f996
29 changed files with 3095 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
fetch('/users/generate-auth-options/arthur')
.then(resp => resp.json())
.then((optionsJSON) => {
console.log(optionsJSON);
return SimpleWebAuthnBrowser.startAuthentication({ optionsJSON })
})
.then(authResp => {
console.log("verify");
return fetch("/users/verify-auth", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
authResp: authResp,
username: "arthur"
})
});
})
.then(res => {
console.log(res);
})
.catch(err => {
console.error(err);
});

View File

@@ -0,0 +1,45 @@
window.addEventListener("DOMContentLoaded", function() {
const registerBtn = document.querySelector("#register");
registerBtn?.addEventListener("click", async function() {
await fetch("/users/register/setup", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: "arthur"
})
})
.then((data) => {
return data.json();
})
.then((data) => {
console.log("we received:", data);
return SimpleWebAuthnBrowser.startRegistration({ optionsJSON: data });
})
.then((attResp) => {
return fetch("/users/register/verify", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
registration: attResp,
username: 'arthur'
})
});
})
.then((response) => {
return response.json();
})
.then((data) => {
console.log("Le finish");
console.log(data);
})
.catch((err) => {
console.error("Something went wrong");
console.error(err);
});
});
});