don't need those
This commit is contained in:
parent
f2519d89ca
commit
77727249a5
|
@ -74,59 +74,3 @@ function save_field(field) {
|
|||
field.children[1].replaceWith(edit);
|
||||
});
|
||||
}
|
||||
|
||||
function register() {
|
||||
fetch(url_prefix + '/api/register/begin', {
|
||||
method: 'POST',
|
||||
}).then(function(response) {
|
||||
if(!response.ok) { throw new Error('Error getting registration data!'); }
|
||||
return response.arrayBuffer();
|
||||
}).then(CBOR.decode).then(function(options) {
|
||||
return navigator.credentials.create(options);
|
||||
}).then(function(attestation) {
|
||||
return fetch(url_prefix + '/api/register/complete', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/cbor'},
|
||||
body: CBOR.encode({
|
||||
"attestationObject": new Uint8Array(attestation.response.attestationObject),
|
||||
"clientDataJSON": new Uint8Array(attestation.response.clientDataJSON),
|
||||
})
|
||||
});
|
||||
}).then(function(response) {
|
||||
let stat = response.ok ? 'successful' : 'unsuccessful';
|
||||
alert('Registration ' + stat + ' More details in server log...');
|
||||
}, function(reason) {
|
||||
alert(reason);
|
||||
}).then(function() {
|
||||
window.location = url_prefix;
|
||||
});
|
||||
}
|
||||
|
||||
function login() {
|
||||
fetch(url_prefix + '/api/authenticate/begin', {
|
||||
method: 'POST',
|
||||
}).then(function(response) {
|
||||
if(!response.ok) { throw new Error('No credential available to authenticate!'); }
|
||||
return response.arrayBuffer();
|
||||
}).then(CBOR.decode).then(function(options) {
|
||||
return navigator.credentials.get(options);
|
||||
}).then(function(assertion) {
|
||||
return fetch(url_prefix + '/api/authenticate/complete', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/cbor'},
|
||||
body: CBOR.encode({
|
||||
"credentialId": new Uint8Array(assertion.rawId),
|
||||
"authenticatorData": new Uint8Array(assertion.response.authenticatorData),
|
||||
"clientDataJSON": new Uint8Array(assertion.response.clientDataJSON),
|
||||
"signature": new Uint8Array(assertion.response.signature)
|
||||
})
|
||||
})
|
||||
}).then(function(response) {
|
||||
let stat = response.ok ? 'successful' : 'unsuccessful';
|
||||
alert('Authentication ' + stat + ' More details in server log...');
|
||||
}, function(reason) {
|
||||
alert(reason);
|
||||
}).then(function() {
|
||||
window.location = url_prefix;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user