<commit_before>$server_sessions = []

module SQRL
  module Test
    module ServerSession
      extend self

      def for_ip(ip)
        $server_sessions.find {|s| s[:ip] == ip}
      end

      def for_idk(idk)
        $server_sessions.find {|s| s[:idk] == idk}
      end

      def list
        $server_sessions.map{|s|
          x = s.dup
          x[:idk] = Base64.urlsafe_encode64(s[:idk])
          x
        }.join(',')
      end

      def assert(ip, idk, nut)
        if session = for_idk(idk)
          session[:ip] = ip
        else
          create(ip, idk, nut)
        end
      end

      def login(ip, idk)
        session = for_idk(idk)
        return unless session
        session[:ip] = ip
        session[:status] = :logged_in
      end

      def create(ip, idk, nut)
        $server_sessions << {:ip => ip, :idk => idk, :nut => nut, :status => :known}
      end
    end
  end
end<commit_msg>encode session dump without =<commit_after>$server_sessions = []

module SQRL
  module Test
    module ServerSession
      extend self

      def for_ip(ip)
        $server_sessions.find {|s| s[:ip] == ip}
      end

      def for_idk(idk)
        $server_sessions.find {|s| s[:idk] == idk}
      end

      def list
        $server_sessions.map{|s|
          x = s.dup
          x[:idk] = Base64.urlsafe_encode64(s[:idk]).sub(/=*\z/, '')
          x.map {|k,v| [k,v].join(':')}.join(', ')
        }.join(',')
      end

      def assert(ip, idk, nut)
        if session = for_idk(idk)
          session[:ip] = ip
        else
          create(ip, idk, nut)
        end
      end

      def login(ip, idk)
        session = for_idk(idk)
        return unless session
        session[:ip] = ip
        session[:status] = :logged_in
      end

      def create(ip, idk, nut)
        $server_sessions << {:ip => ip, :idk => idk, :nut => nut, :status => :known}
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13533438651922064, 'fraction_numerical': 0.00421274354923644, 'mean_word_length': 1.7142857142857142, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5372493', 'n_tokens_mistral': 690, 'n_tokens_neox': 667, 'n_words': 161}