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

Issue when use with Tauri app

Open reyamir opened this issue 2 years ago • 4 comments

Hi, I'm from Lume (https://github.com/luminous-devs/lume)

I've added support NWC via Alby on Lume, but I've use a tricky way, because window.open is not work in Tauri. I've fixed it by using Tauri new Webview https://tauri.app/v1/api/js/window/#webviewwindow to create a new webview window which open authorization url

but it come up with other issue, I can't listen user event, so I don't know user is confirm authorized or not. In Lume, I temporary make it work by assume user alway click confirm button https://github.com/luminous-devs/lume/blob/main/src/app/nwc/components/alby.tsx

I wonder is there other way to make Alby work well with Tauri?

reyamir avatar Sep 19 '23 11:09 reyamir

Hey, thanks for the issue! that's a good and important one. NWC should be easily usable from any environment and not depend on the browser. You use the getAuthorizationUrl exactly as intended. Sadly there is no standardized way for NWC apps to report back the status except a link to a "nostr+walletconnect" URL which requires custom protocol handlers and has problems in various cases like for example mobile apps where multiple apps could register that protocol handler.

Anyway, we have on open PR that actually fires an event: https://github.com/getAlby/nostr-wallet-connect/pull/107 And if I understand the tauri webview correctly then you should be able to listen to that event. No you think this would work?

Currently it only fires a nwc:success event which does not contain any information (you have all information anyway already) but theoretically the event could also contain nwc connection information (this needs some security review though)

bumi avatar Sep 19 '23 18:09 bumi

Yes, I can listen event with tauri webview: https://tauri.app/v1/guides/features/events/ I will try https://github.com/getAlby/nostr-wallet-connect/pull/107 when it merged

reyamir avatar Sep 20 '23 00:09 reyamir

@reyamir the change should be in NWC now. Could you try listening to the nwc:success event?

rolznz avatar Dec 14 '23 08:12 rolznz

yo, that great, I'll check it when working on lume v3

reyamir avatar Dec 14 '23 10:12 reyamir

@reyamir I'll close this for now, please re-open if you still have any issues.

rolznz avatar Jun 03 '24 05:06 rolznz