fabianbormann / cardano-peer-connect

This library aims to provide simple interfaces to implement CIP-0045 for dApps and wallets
Apache License 2.0
12 stars 4 forks source link

Feature proposal - Request auto-connect #17

Closed marcuspuchalla closed 1 year ago

marcuspuchalla commented 1 year ago

Currently, the implementing dApp can accept an incoming connection automatically if it does not specify a verifyConnection callback. Or if it specifies a callback, it can signal the connector the allowance was given.

To further extend these functions and allow DApps to more precisely determine which wallets are allowed to connect automatically and where the user shall be asked, I propose extending the current function in this way.

  1. Add optional property requestAutoConnect boolean property to IWalletInfo, indicating if the connecting wallet is requesting an auto-connect connection.

  2. Extend the interface DAppPeerConnectParameters.callback function to take a second parameter, allowAutoConnect. The implementing DApp can use this parameter to signal if the user has allowed connecting using auto-connect. (Of course the DApp can still not use this and fall back to asking the user for permission every time he connects.)

  3. Add optional property autoConnect to IConnectMessage, which signals the client if the user and the DApp accepted the auto-connect.

  4. Adjusting all connect rpc calls in DAppPeerConnect to forward allowAutoConnect to the autoConnect property.

This way, the DApp can decide in verifyConnection callback if a connection from a specific wallet

In the latter case, the DApp could also implement the user with an interface to show which wallets he has used to connect to it, which are still active, and let the user manage wallet permissions.

I would appreciate any comments on this idea and am open for discussions. If we agree on adding this, I can add a PR.

fabianbormann commented 1 year ago

You refer to the situation where a user has already been established a connection between a dApp and its wallet in the past and revisit the dApp again?

Currently the user would have to allow the connection on every reconnect (if verifyConnection has been implemented that way) and your idea would be to introduce a possibility to automatically connect the dApp to the wallet if the autoConnect property would be set?

I just had to write it in my words to see if I understood it correctly 😊

marcuspuchalla commented 1 year ago

Basically, yes 😄 It might have been too late yesterday, and my description was too lengthy.

So after the implementation, there are three use case scenarios that DApps can choose from.

  1. The DApp lets a user connect without any user interaction.
  2. The DApp asks the user for permission every time.
  3. The DApp allows AutoConnect and asks the user for this permission once.

This is what the DApp would have to do:

In case 1. the DApp does not have to do anything and does not implement the verifyConnection. In case 2. the DApp can provide a simple dialog in verifyConnection "Do you want to connect to Wallet X ?" In case 3. the DApp provides an extensive dialog in verifyConnection "Do you want to connect to Wallet X ? + an e.g. additional checkbox to allow the wallet to auto-connect"

I'll create a draft PR for this today.

marcuspuchalla commented 1 year ago

PR added https://github.com/fabianbormann/cardano-peer-connect/pull/19

fabianbormann commented 1 year ago

Thx @marcuspuchalla PR reviewed & merged 🎉 😊 .. The new release has been built and published to npm