@@ -85,8 +86,17 @@ const publicKey = {
navigator.credentials
.create({ publicKey })
.then((newCredentialInfo) => {
- console.log(newCredentialInfo);
- // Send new credential info to server for verification and registration.
+ // Convert credential to base64 string
+ const credentialJSON = JSON.stringify({
+ id: newCredentialInfo.id,
+ rawId: Array.from(new Uint8Array(newCredentialInfo.rawId)),
+ response: {
+ attestationObject: Array.from(new Uint8Array(newCredentialInfo.response.attestationObject)),
+ clientDataJSON: Array.from(new Uint8Array(newCredentialInfo.response.clientDataJSON))
+ },
+ type: newCredentialInfo.type
+ });
+ document.getElementById('credential-data').value = btoa(credentialJSON);
})
.catch((err) => {
console.error(err);