examples
examples copied to clipboard
chore: implement Internet Identity example recommendations
Here are some recommendations I have on best practices in the II example project.
Important and functional changes
- AuthClient
createshould not be invoked during theloginflow- Awaiting async behavior during the
clickevent leads browsers to treat the interaction as a popup and reject it. This is a particular footgun for Safari mobile - fix: move AuthClient.create() into the global scope, and then update the Actor globally
- Awaiting async behavior during the
- Disable
loginbutton andgreetbutton until the authClient is ready - Remove
Promisewrapping oflogin- I get that
awaitis fancy, but the actual browser API is based around callbacks and events, andonSuccessandonErrorare adequate. - Note: I would also accept the wrapping if it at least
rejected in theonErrorcallback
- I get that
Less important (semantic HTML, a11y, and style)
- Using
window.greetActorandwindow.authClientinstead of local variables so new devs can play with the objects in the console. We DO NOT have to accept this change - it's just an idea I had - The
formelements are unnecessary withoutinputelements, and don't add any semantic value. I prefer<button type="button">over an empty form, and then we don't need to handlesubmitevents