first pass at nip42 authentication #93

Merged
LiranCohen merged 6 commits from feature/Nip42-Support into nip42 2023-01-25 14:45:00 +00:00
LiranCohen commented 2023-01-19 18:23:35 +00:00 (Migrated from github.com)

This is a first pass at implementing Nip42 Authentication.

I wasn't really sure where to put the auth function so I put it into the publisher since it has all of that type of logic there.
But I didn't really know how to get the publisher (or the event signing) into where the connection and AUTH message is handled.

There is probably a much cleaner way, maybe creating an event listener?

I figured I'd put down some code and test things out against my NIP42 relay and get some feedback on how you'd best want to accomplish this.

This is a first pass at implementing Nip42 Authentication. I wasn't really sure where to put the auth function so I put it into the publisher since it has all of that type of logic there. But I didn't really know how to get the publisher (or the event signing) into where the connection and AUTH message is handled. There is probably a much cleaner way, maybe creating an event listener? I figured I'd put down some code and test things out against my NIP42 relay and get some feedback on how you'd best want to accomplish this.
v0l commented 2023-01-19 19:23:54 +00:00 (Migrated from github.com)

What relays support auth?

What relays support auth?
LiranCohen commented 2023-01-19 19:57:42 +00:00 (Migrated from github.com)

I don't see any of the current public relays I chat on support it, but I've been coding on:
https://github.com/fiatjaf/relayer

It currently uses NIP42 as a guard around querying for Kind 4.

Can put this off 'til later if you don't see a need for it.

Will be happy to re-implement when that time comes.

I don't see any of the current public relays I chat on support it, but I've been coding on: https://github.com/fiatjaf/relayer It currently uses NIP42 as a guard around querying for Kind 4. Can put this off 'til later if you don't see a need for it. Will be happy to re-implement when that time comes.
verbiricha commented 2023-01-20 09:44:37 +00:00 (Migrated from github.com)

@LiranCohen what is your npub? want to follow you on Nostr.

@LiranCohen what is your npub? want to follow you on Nostr.
v0l commented 2023-01-20 10:16:43 +00:00 (Migrated from github.com)

I think we can implement this into the snort relay i like the idea, as well as the search nip

I think we can implement this into the snort relay i like the idea, as well as the search nip
LiranCohen commented 2023-01-20 14:30:15 +00:00 (Migrated from github.com)

@verbiricha I'm npub148jmlutaa49y5wl5mcll003ftj59v79vf7wuv3apcwpf75hx22vs7kk9ay

I'll have some time this weekend to try and re-do this in a cleaner way.

@verbiricha I'm `npub148jmlutaa49y5wl5mcll003ftj59v79vf7wuv3apcwpf75hx22vs7kk9ay` I'll have some time this weekend to try and re-do this in a cleaner way.
LiranCohen commented 2023-01-23 18:08:52 +00:00 (Migrated from github.com)

@v0l @verbiricha I made some changes here to use events instead of passing in the auth function to the relay on connect.

Not sure I love this solution, but am open to any suggestions. It shouldn't be hard to re-implement in a different way as the primitives are there are should be the same.

@v0l @verbiricha I made some changes here to use events instead of passing in the auth function to the relay on connect. Not sure I love this solution, but am open to any suggestions. It shouldn't be hard to re-implement in a different way as the primitives are there are should be the same.
LiranCohen (Migrated from github.com) reviewed 2023-01-23 18:49:53 +00:00
LiranCohen (Migrated from github.com) commented 2023-01-23 18:49:15 +00:00

I did some tests and it REALLY doesn't like this timeout.

That's fine the subscriptions will just be re-requested on auth, which happens. I'll do some further testing.

I did some tests and it REALLY doesn't like this timeout. That's fine the subscriptions will just be re-requested on auth, which happens. I'll do some further testing.
v0l (Migrated from github.com) reviewed 2023-01-25 10:38:16 +00:00
v0l (Migrated from github.com) left a comment

nostr-rs-relay recently added support for this so it should be coming soon

`nostr-rs-relay` recently added support for this so it should be coming soon
@ -77,6 +77,16 @@ export default function useEventPublisher() {
}
v0l (Migrated from github.com) commented 2023-01-25 10:32:34 +00:00

You can simply just not return anything here instead, undefined is fine

You can simply just not return anything here instead, undefined is fine
@ -24,8 +25,13 @@ export default function Layout() {
const readNotifications = useSelector<RootState, number>(s => s.login.readNotifications);
v0l (Migrated from github.com) commented 2023-01-25 10:37:44 +00:00

I think it would be simpler to just attach a function to System at startup which can handle these auth methods, instead of using the window event listener

I think it would be simpler to just attach a function to `System` at startup which can handle these auth methods, instead of using the window event listener
LiranCohen (Migrated from github.com) reviewed 2023-01-25 13:41:22 +00:00
@ -24,8 +25,13 @@ export default function Layout() {
const readNotifications = useSelector<RootState, number>(s => s.login.readNotifications);
LiranCohen (Migrated from github.com) commented 2023-01-25 13:41:21 +00:00

Yeah, that does seem cleaner.

I just made some changes and pushed.

Yeah, that does seem cleaner. I just made some changes and pushed.
LiranCohen commented 2023-01-25 13:45:37 +00:00 (Migrated from github.com)

@v0l made the suggested changes, definitely is cleaner than passing events to the window.

@v0l made the suggested changes, definitely is cleaner than passing events to the window.
v0l (Migrated from github.com) approved these changes 2023-01-25 13:58:15 +00:00
Sign in to join this conversation.
No description provided.