getAlby / js-sdk

JavaScript SDK for the Alby OAuth2 Wallet API and the Nostr Wallet Connect API.
https://npmjs.com/package/@getalby/sdk
63 stars 16 forks source link

Issue when use with Tauri app #90

Closed reyamir closed 4 months ago

reyamir commented 1 year ago

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?

bumi commented 1 year ago

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)

reyamir commented 1 year ago

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

rolznz commented 10 months ago

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

reyamir commented 10 months ago

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

rolznz commented 4 months ago

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