Calling startAuthentication with a pending conditional UI auth fails in iOS 16.1 simulator
See original GitHub issueHello again,
I have tested the conditional UI support in the browser library and it is working great both on Safari 16.1 on Mac and Chrome Canary. however there seems to be a problem when testing it on mobile safari on iOS 16.1 simulator (doesn’t seem to work on existing iOS 16 simulator). It does seem that when there is an outstanding startAuthentication
call with useBrowserAutofill
true, if the traditional webauth is used for signing in, it aborts the outstanding conditional UI but it starts the new request before the aborted request being fully aborted resulting in that call failing. Calling the startAuthentication
method again in exactly the same way but without outstanding request works fine then.
Here is a successful conditional UI sign in
Here is the traditional webauth sign in. Notice the first attempt fails with error at 00:05
NotAllowedError: No available authenticator recognized any of the allowed credentials
WebAuthnError — index.js:48
identifyAuthenticationError — index.js:185
(anonymous function) — index.js:237
asyncFunctionResume
(anonymous function)
promiseReactionJobWithoutPromise
promiseReactionJob
In the example code here it seems the calling for normal request happens at the error handling of aborting the conditional one. this seems convoluted and not sure if this is really needed to handle the abort correctly or not
let startConditionalRequest = async () => {
if (window.PublicKeyCredential.isConditionalMediationAvailable) {
console.log("Conditional UI is understood by the browser");
if (!await window.PublicKeyCredential.isConditionalMediationAvailable()) {
showError("Conditional UI is understood by your browser but not available");
return;
}
} else {
// Normally, this would mean Conditional Mediation is not available. However, the "current"
// development implementation on chrome exposes availability via
// navigator.credentials.conditionalMediationSupported. You won't have to add this code
// by the time the feature is released.
if (!navigator.credentials.conditionalMediationSupported) {
showError("Your browser does not implement Conditional UI (are you running the right chrome/safari version with the right flags?)");
return;
} else {
console.log("This browser understand the old version of Conditional UI feature detection");
}
}
abortController = new AbortController();
abortSignal = abortController.signal;
try {
let credential = await navigator.credentials.get({
signal: abortSignal,
publicKey: {
// Don't do this in production!
challenge: new Uint8Array([1, 2, 3, 4])
},
mediation: "conditional"
});
if (credential) {
let username = String.fromCodePoint(...new Uint8Array(credential.response.userHandle));
window.location = "site.html?username=" + username;
} else {
showError("Credential returned null");
}
} catch (error) {
if (error.name == "AbortError") {
console.log("request aborted, starting vanilla request");
startNormalRequest();
return;
}
showError(error.toString());
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
I submitted feedback and raised it with someone at Apple (as best I can via Twitter lol)
Here’s a basic HTML reproduction page I created and included in my feedback, to prove it’s not a SimpleWebAuthn issue 😃
I’m converting this into a Discussion because the issue seems to exist pretty firmly at the browser/OS level.
And if we start discussing implementation questions like, “should the modal UI get triggered from an AbortError detected when Conditional UI errors out”, that’s going to still be something handled by a project using SimpleWebAuthn as opposed to anything I could address within this library 🤔