Skip to content

Commit

Permalink
Merge pull request #16 from dodobrands/fix-strict-getPublicKey
Browse files Browse the repository at this point in the history
set publicKey to null if getPublicKey returns null
  • Loading branch information
vanbukin authored Jun 4, 2024
2 parents 719e99b + cca6f86 commit fa329d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 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,8 @@ 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"),
getPublicKeyInvalid: () => alert("Invalid data from getPublicKey() method. Expected ArrayBuffer")
};

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

const transports = newCredential.response.getTransports ?
Expand Down

0 comments on commit fa329d3

Please sign in to comment.