webauthn-local-client
webauthn-local-client copied to clipboard
Remove top-level awaits
Is there any chance the top-level awaits could be moved into functions? That way the consumer of the library can choose when to run the code (if at all), also it makes the library compatible with older bundlers.
my problem with this is, there's a reduced DX when:
-
it's a footgun that these functions will return promises (because the underlying checks have to be asynchronous), which are truthy... so people might accidentally see the truthy promise value and not realize they need to
awaitit before knowing if the library is supported. -
what's exposed are functions that only ever need to be called once, instead of just exposing the result of these calls (booleans)... sure you can cache the result internally, but it still sucks that you continue to be presented with a function call (that's promise returning!) even when on the second call it knows the answer already.
-
the main reason for checking for support of WebAuthn capability is critical path stuff like loading alternate/fallback functionality, including rendering different controls to users, etc -- you can't do anything useful until you know the result, so why force you to wait for that result.
these concerns are why I went with top-level await. but I acknowledge that it definitely has its tradeoffs when it comes to bundlers.
Not planned at the moment.