Skip to content

Commit ce6374c

Browse files
dradovicabergs
andauthored
use coerceToArrayBuffer on assertion options in Demo js (#467)
Co-authored-by: Anders Åberg <[email protected]>
1 parent 3ab071f commit ce6374c

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

Demo/wwwroot/js/custom.login.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ async function handleSignInSubmit(event) {
3737
return;
3838
}
3939

40-
// todo: switch this to coercebase64
41-
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
42-
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));
43-
44-
// fix escaping. Change this to coerce
40+
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
4541
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
46-
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
47-
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
42+
listItem.id = coerceToArrayBuffer(listItem.id);
4843
});
4944

5045
console.log("Assertion options", makeAssertionOptions);

Demo/wwwroot/js/mfa.login.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,9 @@ async function handleSignInSubmit(event) {
4242
return;
4343
}
4444

45-
// todo: switch this to coercebase64
46-
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
47-
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));
48-
49-
// fix escaping. Change this to coerce
45+
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
5046
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
51-
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
52-
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
47+
listItem.id = coerceToArrayBuffer(listItem.id);
5348
});
5449

5550
console.log("Assertion options", makeAssertionOptions);

Demo/wwwroot/js/passwordless.login.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,9 @@ async function handleSignInSubmit(event) {
3535
return;
3636
}
3737

38-
// todo: switch this to coercebase64
39-
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
40-
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));
41-
42-
// fix escaping. Change this to coerce
38+
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
4339
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
44-
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
45-
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
40+
listItem.id = coerceToArrayBuffer(listItem.id);
4641
});
4742

4843
console.log("Assertion options", makeAssertionOptions);

Demo/wwwroot/js/usernameless.login.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,9 @@ async function handleSignInSubmit(event) {
3535
return;
3636
}
3737

38-
// todo: switch this to coercebase64
39-
const challenge = makeAssertionOptions.challenge.replace(/-/g, "+").replace(/_/g, "/");
40-
makeAssertionOptions.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0));
41-
42-
// fix escaping. Change this to coerce
38+
makeAssertionOptions.challenge = coerceToArrayBuffer(makeAssertionOptions.challenge);
4339
makeAssertionOptions.allowCredentials.forEach(function (listItem) {
44-
var fixedId = listItem.id.replace(/\_/g, "/").replace(/\-/g, "+");
45-
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0));
40+
listItem.id = coerceToArrayBuffer(listItem.id);
4641
});
4742

4843
console.log("Assertion options", makeAssertionOptions);

0 commit comments

Comments
 (0)