You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a recommended way to detect if the user has a WebLN provider installed? I'm wanting to use this detection to decide whether to show LN payment options to the user or to show them a message to download a WebLN provider.
The requestProvider() function seems like the best way to do this within the webln library, but it also enables the WebLN provider and causes some providers (Alby) to immediately prompt the user for authorization:
Alternatively, I could use the same window.webln check that requestProvider() uses without the enable call, but it feels wrong to go outside of the library to do this:
I think you're absolutely right that requestProvider should not necessarily automatically enable the provider, that was probably a bad move on the initial implementation.
I am however hesitant to implement a synchronous detectProvider function. One thing I wanted to keep in mind was alternative providers that aren't just browser extensions. For instance, I could see there being some kind of standard port that webln will try to reach out to and see if there's a local application listening. Or maybe an iframe-based postMessage implementation. Both of these would require you to wait for some kind of response.
If someone wants to hack around the lack of a detect method today by checking for window.webln, they can definitely do that, but it might not be future proof for some other future implementation.
Is there a recommended way to detect if the user has a WebLN provider installed? I'm wanting to use this detection to decide whether to show LN payment options to the user or to show them a message to download a WebLN provider.
The
requestProvider()
function seems like the best way to do this within the webln library, but it also enables the WebLN provider and causes some providers (Alby) to immediately prompt the user for authorization:webln/src/client.ts
Line 26 in ab22196
Alternatively, I could use the same
window.webln
check thatrequestProvider()
uses without the enable call, but it feels wrong to go outside of the library to do this:webln/src/client.ts
Line 21 in ab22196
The text was updated successfully, but these errors were encountered: