Autosubmit login form on adding passkey (#78)

Co-authored-by: Karl Ludwig Weise <ludwig@ludwigweise.de>
This commit is contained in:
Karl Ludwig Weise
2025-09-11 12:18:37 +02:00
committed by GitHub
co-authored by Karl Ludwig Weise
parent ff315072e3
commit dc598a5146
2 changed files with 21 additions and 7 deletions
+16 -7
View File
@@ -1,15 +1,24 @@
import logger from "$lib/logger";
export const arrayBufferToBase64 = (buffer: ArrayBuffer): string => {
const bytes = new Uint8Array(buffer);
let binary = "";
try {
const bytes = new Uint8Array(buffer);
let binary = "";
// Simple loop, no fancy operations
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
// Simple loop, no fancy operations
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
} catch (error) {
logger.error("Failed to convert ArrayBuffer to Base64", {
error,
notes:
"If you see this error locally, the best way to use passkeys is Chromium as of writing this",
});
throw error;
}
return window.btoa(binary);
};
export const base64UrlToArrayBuffer = (base64url: string) => {
@@ -120,6 +120,11 @@
// Update UI to show passkey is ready
$passkeyLoading = "success";
const isValid = await form.validateForm();
if (isValid) {
form.submit();
}
}
};