I'm currently in the process of evaluating the implementation of WebAuthn/Passkeys on a website, and one thing that I'm having trouble finding information on is what exceptions from the WebAuthn API the user should be notified about.
There are many conditions in both the create
and get
functions on PublicKeyCredential
that throw exceptions, and I find that these fit in three broad categories:
For many exceptions (arguably the most common ones), the user is already well aware of the condition and any notification about it would just be weird. These common cases include the user simply cancelling the transaction. Handling these should just be silent.
There are other conditions that the user should probably be made aware of. For example, if my
options
object is malformed, the browser encounters an internal error, or some other actual erroneous condition occurs, I'd like to at least notify the user that an error has occurred. The "silent treatment" is very weird in these cases.Confusingly enough, there are also some conditions that seem to differ from browser to browser. For example, if the key the user decides to use isn't in the
allowCredentials
list, Chrome will notify the user of this in its WebAuthn UI and allow the user to retry or cancel, whereas Firefox will close the UI and report that condition to my script as an exception instead.
So my question is: Is there any way of distinguishing these conditions, either formally specified or otherwise? I haven't found anything in the specification, but it's rather long and I wouldn't be surprised if I've simply missed it. If there isn't, I'm not sure what the alternative is. The same exception type is reused for many different conditions, and the user-readable messages aren't standardized across browsers.
If there isn't a way to do this, I'm kind of on the edge if supporting WebAuthn/Passkeys is even a good idea.