aepp-sdk-js icon indicating copy to clipboard operation
aepp-sdk-js copied to clipboard

Browser extension shouldn't open connections to pages that not using it

Open davidyuk opened this issue 3 years ago • 3 comments

https://github.com/aeternity/aepp-sdk-js/blob/9f2f22a97c84b00efda5f11373836eddfaa26f50/examples/browser/wallet-web-extension/src/content-script.js#L19

https://github.com/aeternity/aepp-sdk-js/blob/9f2f22a97c84b00efda5f11373836eddfaa26f50/examples/browser/wallet-web-extension/src/background.js#L67-L73

Together these parts make all opened pages be in sdk.rpcClients. Superhero wallet reloads connected pages in some cases and this makes it reload extra pages.

Try to make the fix not breaking aepp<->content-script connection.

davidyuk avatar Feb 16 '22 05:02 davidyuk

@davidyuk I have given a lot of thought to this. Tried a few implementations too. as I observe, the wallet keeps on emitting shareWalletInfo. My first thought was the content-script bridge https://github.com/aeternity/aepp-sdk-js/blob/9f2f22a97c84b00efda5f11373836eddfaa26f50/examples/browser/wallet-web-extension/src/content-script.js#L38 will not run by default. Aepps would explicitly need to send a connectionRequest via postMessage. This would break the existing aepp<-> content-script connection.

Try to make the fix not breaking aepp<->content-script connection. I am not sure how to establish a connection without either one of the parties initiating the connection or both have to be in a loop.

subhod-i avatar Mar 30 '22 12:03 subhod-i

As I know, the problem is that when the wallet connects to it's content script it considers to be connected to app even if aepp doesn't talk to content script. We need somehow to track the intermediate state when the wallet is connected to content script, but not to the aepp yet 🤔

davidyuk avatar Apr 12 '22 20:04 davidyuk

Actually, it is not necessary to remove extra rpc clients, because it can be detected is aepp connected or not by _isRpcClientConnected (but need to make it public somehow).

davidyuk avatar Jun 29 '22 20:06 davidyuk