Usability of error messages in FIDO2
The included JavaScript currently just does an alert with the raw exception on errors. This is far from ideal usability-wise.
There are some common cases where errors can occur:
- Users cancel the webauthn flow (NotAllowedError)
- The key is already registered (i.e. included in
excludedCredentials) (InvalidStateError)
Unfortunately, none of these Exceptions seem to be specific to those situations. So we cannot just check for them to show a meaningful error message.
In the case of cancellation, no error is probably the best option.
In the case where the key is already registered, chrome displays a useful error message on its own. So showing another one is not helpful. Firefox, on the other hand, doesn't show anything, so a custom error message is needed.
Unexpected errors should also be displayed somehow.
https://github.com/MasterKale/SimpleWebAuthn/blob/master/packages/browser/src/helpers/identifyRegistrationError.ts could be a helpful resource to interpret errors.