lumehq / lume

A multi-purpose nostr client for Windows and macOS.
GNU General Public License v3.0
247 stars 24 forks source link

nsecBunker crashes / token error #126

Closed derekross closed 1 month ago

derekross commented 10 months ago

It looks like nsecBunker support still has some bugs. If Lume crashes, upon restart, I am presented with a token error. I've had this happen 3 different times. Each time, the application crashed in a different part of the UI. Each time upon restart, I get the error. To fix, I blow away the local application data and generate a new nsecBunker token. Rinse and repeat.

https://i.nostr.build/JJYM.png

reyamir commented 10 months ago

Hi @derekross, thank for your report

I've re-tested the nsecbunker feature, the current UI a bit messy, when user click connect with nsecbunker button, they need to go to nsecbunker webapp -> then click Approve

and token only can use one time, if token is redemn, app will stuck at the loading screen, this is bug I'm working to fix it

Screenshot 2023-12-05 at 09 10 07

I'll do complete revamp on the UI for nsecbunker (and other signer app) in the next update.

reyamir commented 10 months ago

Other things I will add is auto-open nsecbunker webapp when some action need user's approval

reyamir commented 10 months ago

Hi @derekross, while waiting me update the UI for nsecbunker, you can follow this guide for using nsecbunker with Lume

https://github.com/luminous-devs/lume/assets/123083837/2e13310f-c10d-41de-8073-34c564c8fa8a

derekross commented 10 months ago

This is what I've done and it works great until the application crashes. Once it crashes it will no longer use the previous token that was supplied.

reyamir commented 10 months ago

oh, seem strange, I'll dig more into it

reyamir commented 10 months ago

Yo, I've found the problem here. With nsecbunker, user have 2 options:

1 - Using main key

image

With this option, user need to go back nsecbunker webapp to approve some action need user's approval (new post, zap, reaction,...)

2 - Using token

image

With token, user can assign policy so user don't need to go back nsecbunker webapp to approve some action everytime

But the cons is token is one-time usage, so if user login then close app or reload, the token is redeemed, app will stuck forever like your issue

So I need to improve this part to make sure user is acknowledged token is one-time usage, of token is redeemed, app will be redirect back to login screen instead of stuck

reyamir commented 10 months ago

I'm working on the next version, maybe release in tomorrow, if you don't mind I will send you the pre-release version to test it

derekross commented 10 months ago

okay. thank you. i appreciate it.

reyamir commented 10 months ago

Hi @derekross , I've pushed new version for improve nsecbunker support, you can try it here https://github.com/luminous-devs/lume/releases/tag/v2.2.1

if you see something need to be improve you can feedback me here 😊

derekross commented 10 months ago

Hi @derekross , I've pushed new version for improve nsecbunker support, you can try it here https://github.com/luminous-devs/lume/releases/tag/v2.2.1

if you see something need to be improve you can feedback me here 😊

Thanks. It looks like the workflow is better, but the same issue with Luke not reusing the token still exists. Upon restarting the app I have to generate a new token. And if I decide to go the non-token route and authorize individual events, it still has issues. Sorry.

reyamir commented 10 months ago

Ah, this is default behavior of nsecbunker, token is one-time-use (https://dev.nsecbunker.com/) but I still working on better flow for it, user only need to provide new token in specific screen instead of redoing full onboarding process

derekross commented 10 months ago

okay. though i don't have this issue with other clients with nsecbunker. i generated a token and i continue to use that token with those clients.

reyamir commented 10 months ago

oh, seem strange, let me check with Pablo

pablof7z commented 10 months ago

hey guys

@reyamir you should save the private key you generated locally; the one-time use token applies policies to that pubkey, so save it as you would save any nsec; no need to ask the user to give you a new token on each restart.

Also, I noticed a few commits ago you were trying to redeem the same token upon restarting the app, which is not going to work 😅

For clarity, the flow is:

  1. user generates token on nsecbunker
  2. user opens Lume and logs in with npub#token
  3. Lume generates private key
  4. Lume sends connect with user's pubkey+token
  5. Lume stores user's pubkey and the private key generated in step 3.
  6. Upon restart, Lume just reconnects with pubkey using the same private key generated in step 3.
reyamir commented 10 months ago

hey guys

@reyamir you should save the private key you generated locally; the one-time use token applies policies to that pubkey, so save it as you would save any nsec; no need to ask the user to give you a new token on each restart.

Also, I noticed a few commits ago you were trying to redeem the same token upon restarting the app, which is not going to work 😅

For clarity, the flow is:

  1. user generates token on nsecbunker
  2. user opens Lume and logs in with npub#token
  3. Lume generates private key
  4. Lume sends connect with user's pubkey+token
  5. Lume stores user's pubkey and the private key generated in step 3.
  6. Upon restart, Lume just reconnects with pubkey using the same private key generated in step 3.

Yo, I'm very appericate your support, my mistake is in the last step 😅 @derekross I'll push new version now

reyamir commented 10 months ago

Yo @derekross , new version is released https://github.com/luminous-devs/lume/releases/tag/v2.2.3 this time it will work well 😅

MerryOscar commented 7 months ago

@reyamir it looks like the NIP-46 connection string should also work with a format like this:

bunker://<hex-pubkey>?relay=wss://...&secret=<optional-secret>

are you able to support this format?

reyamir commented 7 months ago

Yes, I will add this format too