Refactor Nostr settings/connect

* Use NIP-42 auth event instead of short text note
* Verify event ID and signature using the nostr gem instead of custom code
This commit is contained in:
2024-04-01 18:22:32 +03:00
parent d4e67a830c
commit 22d362e1a0
9 changed files with 77 additions and 67 deletions

View File

@@ -0,0 +1,17 @@
module NostrManager
class VerifyAuth < NostrManagerService
def initialize(event:, challenge:)
@event = event
@challenge_expected = challenge
@site_expected = Setting.accounts_domain
end
def call
site_given = @event.tags.find{|t| t[0] == "site"}[1]
challenge_given = @event.tags.find{|t| t[0] == "challenge"}[1]
site_given == @site_expected &&
challenge_given == @challenge_expected
end
end
end