Open nostrband opened 2 months ago
I would be happy for a PR for this if you know a good solution. Would it just be deleting webln from the window object?
I guess the provider could start throwing exceptions on all access methods?
But how do we tell the provider to do that? Maybe we could propose a disable
method in webln https://www.webln.guide/building-lightning-apps/webln-reference
I was talking about Alby NWC connection, it's probably harder to do when BC just wraps the existing webln provider.
@nostrband do you use Bitcoin Connect v3? by default it will not set window.webln. If you decide to set it yourself, then you must also delete it when the user disconnects their wallet
Yeah I'm using v3 and I'm clearing window.webln after disconnect
@nostrband so is there anything we can do here? or should we update the docs so it's clear if you set window.webln you should also listen to the disconnected event and delete window.webln?
Hmm ok maybe it should be the app's job to react to disconnect properly. Especially given that if you're just forwarding the existing webln provider then it's harder to make it get "disconnected" if app saves a reference to it and doesn't react to disconnect properly.
I guess onConnected docs could state that this provider object may still be usable even after user clicks "disconnect" so app should react to onDisconnected properly.
Thanks @nostrband for the clarification.
If I save the provider in (i.e. in window.webln) and client disconnects the wallet I can still pay with saved window.webln, tested with Alby connection. This shouldn't happen, if client clicks disconnect then there should be no way for the app to access the wallet.