feat: add passkey creation functionality

This commit is contained in:
Prad Nukala
2024-12-08 22:53:04 -05:00
parent 5c3966a9d6
commit e0ebe92361
15 changed files with 189 additions and 118 deletions
+10 -7
View File
@@ -113,17 +113,20 @@ templ CredentialsScripts() {
.replace(/\//g, '_')
.replace(/=/g, '');
}
// Function to create a passkey
function createPasskey(button) {
const passkey = window.crypto.getRandomValues(new Uint8Array(32)).join('');
// Assuming there is a hidden input field to store the passkey
const hiddenInput = button.closest('form').querySelector('input[name="passkey"]');
if (hiddenInput) {
hiddenInput.value = passkey;
}
console.log('Passkey generated:', passkey);
}
</script>
}
}
script CreatePasskey(id string) {
function createPasskey(id) {
const passkey = document.getElementById(id);
passkey.value = window.crypto.getRandomValues(new Uint8Array(32)).join('');
}
}
// Template for creating credentials
templ CreateCredential(options *RegisterOptions) {
@CredentialsScripts()