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
