trezor / trezor-suite

Trezor Suite Monorepo
https://trezor.io/trezor-suite
Other
672 stars 242 forks source link

connect-webextension proxy - revise desing #12731

Open mroz22 opened 4 weeks ago

mroz22 commented 4 weeks ago

related to #12717

karliatto commented 3 weeks ago

Regarding the proxy: After talking about this with @martykan we came to the conclusion that the proxy is out of the scope of TrezorConnect and we should focus on making connect-webextension work nicely in service worker with popup with ES modules.

karliatto commented 3 weeks ago

I believe that init should be hadled implicitly inside call

init requires settings in functions arguments and we do not have that in call method if init has not been called before.

lib/index.js does not contain inlined content-script. so simply importing from @trezor/connect-webextension forces you to use version where you have to vendorize content script.

Should be fixed by this PR https://github.com/trezor/trezor-suite/pull/12761

add default connectSrc. it is not set and 3rd parties have to do stuff like this https://github.com/RabbyHub/Rabby/blob/59e06afc722e69c6f609654c1f5ccba1f710710f/src/background/service/keyring/eth-trezor-keyring/trezor-offscreen-bridge.ts#L30

if init was not call, and channel not set, call method throws on the first attempt to access channel, this is caught, but in the catch block later on obviously not. https://github.com/trezor/trezor-suite/blob/develop/packages/connect-webextension/src/proxy/index.ts#L95

Isn't init required in all the TrezorConnect implementation?

That part of the Rabby code is running in the service worker and using the parseConnectSettings that will add DEFAULT_DOMAIN if connectSrc is not provided, but they decided to provide it explicitly.