Skip to content

Commit

Permalink
set publicKey to null if getPublicKey returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
Keroosha committed Jun 4, 2024
1 parent 719e99b commit 126f0b4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions demo/WebAuthn.Net.Demo.Mvc/wwwroot/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ const Alerts = {
usernameInputEmpty: () => alert("Username input is empty"),
credentialsGetApiNull: () => alert("navigator.credentials.get returned null"),
credentialsCreateApiNull: () => alert("navigator.credentials.create returned null"),
getAuthenticatorDataInvalid: () => alert("Invalid data from getAuthenticatorData() method. Expected arraybuffer"),
getPublicKeyInvalid: () => alert("Invalid data from getPublicKey() method. Expected arraybuffer")
getAuthenticatorDataInvalid: () => alert("Invalid data from getAuthenticatorData() method. Expected arraybuffer")
};

// API
Expand Down Expand Up @@ -144,11 +143,11 @@ const API = {
if (newCredential.response.getPublicKey) {
const responsePublicKey = newCredential.response.getPublicKey();
const isValid = responsePublicKey instanceof ArrayBuffer;
if (!isValid) {
Alerts.getPublicKeyInvalid();
return;
if (isValid) {
publicKey = coerceToBase64Url(responsePublicKey);
} else {
publicKey = null;
}
publicKey = coerceToBase64Url(responsePublicKey);
}

const transports = newCredential.response.getTransports ?
Expand Down

0 comments on commit 126f0b4

Please sign in to comment.