FIX: Handle old Firefox versions that do not support isConditionalMediationAvailable (#25549)

Some versions of Firefox will throw a TypeError when calling
PublicKeyCredential.isConditionalMediationAvailable() because the
method does not exist. That would previously lead to a "Sorry, an error
has occurred." modal when trying to login.

This commit fixes the issue by properly checking if the method exists.
Since it only affects older Firefox versions, no tests are added.
This commit is contained in:
Penar Musaraj
2024-02-02 16:39:37 -05:00
committed by GitHub
parent 5f06d6490d
commit ac53e5a962

View File

@@ -133,7 +133,8 @@ export async function getPasskeyCredential(
// We cannot do a general check because iOS Safari and Chrome in Selenium quietly support the feature
// but they do not support the PublicKeyCredential.isConditionalMediationAvailable() method
if (mediation === "conditional" && isFirefox) {
const isCMA = await PublicKeyCredential.isConditionalMediationAvailable();
const isCMA =
(await PublicKeyCredential.isConditionalMediationAvailable?.()) ?? false;
if (!isCMA) {
return;
}