Skip to content

Commit

Permalink
use coerceToArrayBuffer on assertion options in Demo js (#467)
Browse files Browse the repository at this point in the history
Co-authored-by: Anders Åberg <[email protected]>
  • Loading branch information
dradovic and abergs authored Nov 5, 2024
1 parent 3ab071f commit ce6374c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
9 changes: 2 additions & 7 deletions Demo/wwwroot/js/custom.login.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ async function handleSignInSubmit(event) {
return;
}

// todo: switch this to coercebase64
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));

// fix escaping. Change this to coerce
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
listItem.id = coerceToArrayBuffer(listItem.id);
});

console.log("Assertion options", makeAssertionOptions);
Expand Down
9 changes: 2 additions & 7 deletions Demo/wwwroot/js/mfa.login.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@ async function handleSignInSubmit(event) {
return;
}

// todo: switch this to coercebase64
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));

// fix escaping. Change this to coerce
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
listItem.id = coerceToArrayBuffer(listItem.id);
});

console.log("Assertion options", makeAssertionOptions);
Expand Down
9 changes: 2 additions & 7 deletions Demo/wwwroot/js/passwordless.login.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ async function handleSignInSubmit(event) {
return;
}

// todo: switch this to coercebase64
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));

// fix escaping. Change this to coerce
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
listItem.id = coerceToArrayBuffer(listItem.id);
});

console.log("Assertion options", makeAssertionOptions);
Expand Down
9 changes: 2 additions & 7 deletions Demo/wwwroot/js/usernameless.login.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ async function handleSignInSubmit(event) {
return;
}

// todo: switch this to coercebase64
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));

// fix escaping. Change this to coerce
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
listItem.id = coerceToArrayBuffer(listItem.id);
});

console.log("Assertion options", makeAssertionOptions);
Expand Down

0 comments on commit ce6374c

Please sign in to comment.