irislib / iris-messenger

Decentralized messenger
https://iris.to
MIT License
719 stars 157 forks source link

Enable Private Relay Support [feature request][500k sats] #364

Closed alltheseas closed 1 year ago

alltheseas commented 1 year ago

As a Iris user who wants to connect with a particular group of nostriches privately, I want to be able to connect to a private relay, so that I can read and share notes only with a specific group of nostriches.

Acceptance Criteria

  1. Iris user can connect to a private relay
  2. Iris user has a method to provide authentication details to a private relay
  3. Iris user can check visually if they are successfully connected to the private relay
  4. Iris user can remove a private relay
  5. Iris user can de-authenticate from a private relay

implementation details NIP-42

Origin: https://iris.to/note1c6khgk6phxzhq7hh2v32nhzrvlyn4y2ctk6h0kgtgfrgrh7y7e5qma8ykl

Additional context Introduced feature request to Damus (iOS), and Amethyst (Android) as well.

Why is this important: private relays provide differentiation and novelty compared to incumbent twtr.

nostr-wine commented 1 year ago

We'll offer a 500k sats bounty per client for this feature.

npub1zenn0 commented 1 year ago

'ello, letting you know that I've worked on it, https://github.com/irislib/iris-messenger/pull/370 hopefully merged soon.

I'll admit that the UX isn't exactly the friendliest of all, but I think it gets the job done for now.

nostr-wine commented 1 year ago

Awesome - thank you for working on this. I will add your pubkey to filter.nostr.wine right now so you can test that you are approved. I will note that the AUTH may not necessarily come on connect (as detailed in the NIP), so I'm not sure how Iris wants to handle this.

npub1zenn0 commented 1 year ago

Cool. I haven't tested what happens if the event comes somewhere randomly down the line, but based on the code the flow should work the same and isn't broken at least.

npub1zenn0vgcy2st7dz7gexxtuuan860ucryg26kdlnap2kndwrqmy0swwp3st -- thanks!

nostr-wine commented 1 year ago

Added!

npub1zenn0 commented 1 year ago

Cool, thanks. The authentication works but I found another related issue, so that's useful

nostr-wine commented 1 year ago

Thank you! I'm trying to test this but I can't get Iris to only connect to relays on my list. My console log always has connection failures to relays that aren't on my list. Why? Is there a way I can make Iris ONLY use relays in my list so that I can test this?

I'm able to see a connection to filter.nostr.wine server side, but it is also using my old filter.nostr.wine/npub relay URL simultaneously (even though I deleted it from my relay list). I need to be able to isolate one relay at a time so I can verify events are flowing.

nostr-wine commented 1 year ago
Screenshot 2023-04-22 at 8 50 18 AM

None of the failing relays are in my list...

npub1zenn0 commented 1 year ago

Can you see if that happens in a private window?

nostr-wine commented 1 year ago

Same result. As soon as I login with my extension, it starts trying to connect to relays that aren't in my list. Interestingly, it seems to be a very old list (perhaps just based on popularity) because most of these relays are no longer functional.

relay.current.fyi brb.io relay.nostr.info relay.snort.social

Seem to be the stickiest ones.

npub1zenn0 commented 1 year ago

Yeah those are on the default relays list. Yeah I see the bug now too, will check in a bit.

npub1zenn0 commented 1 year ago

Well, looks like making iris use a single relay is gonna be a massive hurdle so I'd rather not go down that road. The connection retry errors aren't really a problem.

I think best you can do to confirm that events are flowing is to check the websocket events in the devtools network tab:

image

nostr-wine commented 1 year ago

Sorry for the delay! I was able to verify this. Thank you so much. Can I zap you as payment?

npub1zenn0 commented 1 year ago

No problem at all. Yeah, zap is good! Thanks.

nostr-wine commented 1 year ago

Paid! Thanks again.

npub1zenn0 commented 1 year ago

Got it. Big thanks!