EOSIO / universal-authenticator-library

A library for allowing apps to easily use different auth providers.
MIT License
127 stars 35 forks source link

Interface method request: shouldRequestChainId #53

Closed aaroncox closed 2 years ago

aaroncox commented 4 years ago

Much like the shouldRequestAccountName method on a provider, it would also be useful (for our implementation specifically) if the interface also had a shouldRequestChainId method on the provider. It would be a prompt like the account name request, except have some sort of selection (dropdown, icons, etc) which prompts the user to select a blockchain. This step would only be required if more than one chain was provided to UAL and the provider specified shouldRequestChainId = true.

The reason behind this is within the EOSIO Signing Request specification we're using - we expect the chain to be already defined at the time an identity request is made. When using UAL in conjunction with multiple blockchains and the UAL-Anchor plugin, we essentially are forced right now to inject a selection in before initializing UAL and just passing one chain at a time.

My thoughts is the interface could require something like this:

 /**
   * Returns whether or not the button should show chain ID field.
   * This is for Authenticators that require a single chain ID is specified for authentication.
   */
  public async shouldRequestChainId(): Promise<boolean> {
    return true
  }

If you are interested to see the workaround we have tossed together just to get things working now, we have one available and published here:

Demo: https://greymass.github.io/ual-anchor-demo/ Source: https://github.com/greymass/ual-anchor-demo/

We are basically reinstantiating the UALProvider with a single chain, whenever the user changes blockchains using the dropdown above the login button. Making this selection process part of the UAL modal flow I believe would be a much better user experience.

I considered submitting a PR with this change - but before I took the effort of writing/testing it, I figured I should open an issue first to discuss the idea. Thanks, and look forward to hearing your thoughts!

sanaraufx commented 3 years ago

Cleaning up old issues so we can focus on more recent open items. Please reopen this ticket if needed. Thank you.