mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-10 16:15:12 +00:00
* at least registration prompt works * in memory test for login * buttons to start webauthn process * begin eventstore impl * begin eventstore impl * serialize into bytes * fix: u2f, passwordless types * fix for localhost * fix script * fix: u2f, passwordless types * fix: add u2f * fix: verify u2f * fix: session data in event store * fix: u2f credentials in eventstore * fix: webauthn pkg handles business models * feat: tests * feat: append events * fix: test * fix: check only ready webauthn creds * fix: move u2f methods to authrepo * frontend improvements * fix return * feat: add passwordless * feat: add passwordless * improve ui / error handling * separate call for login * fix login * js * feat: u2f login methods * feat: remove unused session id * feat: error handling * feat: error handling * feat: refactor user eventstore * feat: finish webauthn * feat: u2f and passwordlss in auth.proto * u2f step * passwordless step * cleanup js * EndpointPasswordLessLogin * migration * update mfaChecked test * next step test * token name * cleanup * attribute * passwordless as tokens * remove sms as otp type * add "user" to amr for webauthn * error handling * fixes * fix tests * naming * naming * fixes * session handler * i18n * error handling in login * Update internal/ui/login/static/i18n/de.yaml Co-authored-by: Fabi <[email protected]> * Update internal/ui/login/static/i18n/en.yaml Co-authored-by: Fabi <[email protected]> * improvements * merge fixes * fixes * fixes Co-authored-by: Fabiennne <[email protected]> Co-authored-by: Fabi <[email protected]>
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
document.addEventListener('DOMContentLoaded', checkWebauthnSupported('btn-register', registerCredential));
|
|
|
|
function registerCredential() {
|
|
document.getElementById('wa-error').classList.add('hidden');
|
|
|
|
let opt = JSON.parse(atob(document.getElementsByName('credentialCreationData')[0].value));
|
|
opt.publicKey.challenge = bufferDecode(opt.publicKey.challenge);
|
|
opt.publicKey.user.id = bufferDecode(opt.publicKey.user.id);
|
|
if (opt.publicKey.excludeCredentials) {
|
|
for (let i = 0; i < opt.publicKey.excludeCredentials.length; i++) {
|
|
if (opt.publicKey.excludeCredentials[i].id !== null) {
|
|
opt.publicKey.excludeCredentials[i].id = bufferDecode(opt.publicKey.excludeCredentials[i].id);
|
|
}
|
|
}
|
|
}
|
|
navigator.credentials.create({
|
|
publicKey: opt.publicKey
|
|
}).then(function (credential) {
|
|
createCredential(credential);
|
|
}).catch(function (err) {
|
|
webauthnError(err);
|
|
});
|
|
}
|
|
|
|
function createCredential(newCredential) {
|
|
let attestationObject = new Uint8Array(newCredential.response.attestationObject);
|
|
let clientDataJSON = new Uint8Array(newCredential.response.clientDataJSON);
|
|
let rawId = new Uint8Array(newCredential.rawId);
|
|
|
|
let data = JSON.stringify({
|
|
id: newCredential.id,
|
|
rawId: bufferEncode(rawId),
|
|
type: newCredential.type,
|
|
response: {
|
|
attestationObject: bufferEncode(attestationObject),
|
|
clientDataJSON: bufferEncode(clientDataJSON),
|
|
},
|
|
});
|
|
|
|
document.getElementsByName('credentialData')[0].value = btoa(data);
|
|
document.getElementsByTagName('form')[0].submit();
|
|
} |