<commit_before>module Userbin
  class Client

    attr_accessor :request_context

    def self.install_proxy_methods(*names)
      names.each do |name|
        class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{name}(*args)
            Userbin::User.new('$current').#{name}(*args)
          end
        RUBY
      end
    end

    install_proxy_methods :challenges, :events, :sessions, :pairings,
      :backup_codes, :generate_backup_codes, :trusted_devices,
      :enable_mfa!, :disable_mfa!

    def initialize(request, response, opts = {})
      # Save a reference in the per-request store so that the request
      # middleware in request.rb can access it
      RequestStore.store[:userbin] = self

      if response.class.name == 'ActionDispatch::Cookies::CookieJar'
        cookies = Userbin::CookieStore::Rack.new(response)
      else
        cookies = Userbin::CookieStore::Base.new(request, response)
      end

      @store = Userbin::TokenStore.new(cookies)

      @request_context = {
        ip: request.ip,
        user_agent: request.user_agent
      }<commit_msg>Add Cookie ID to request headers<commit_after>module Userbin
  class Client

    attr_accessor :request_context

    def self.install_proxy_methods(*names)
      names.each do |name|
        class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{name}(*args)
            Userbin::User.new('$current').#{name}(*args)
          end
        RUBY
      end
    end

    install_proxy_methods :challenges, :events, :sessions, :pairings,
      :backup_codes, :generate_backup_codes, :trusted_devices,
      :enable_mfa!, :disable_mfa!

    def initialize(request, response, opts = {})
      # Save a reference in the per-request store so that the request
      # middleware in request.rb can access it
      RequestStore.store[:userbin] = self

      if response.class.name == 'ActionDispatch::Cookies::CookieJar'
        cookies = Userbin::CookieStore::Rack.new(response)
      else
        cookies = Userbin::CookieStore::Base.new(request, response)
      end

      @store = Userbin::TokenStore.new(cookies)

      @request_context = {
        ip: request.ip,
        user_agent: request.user_agent,
        cookie_id: cookies['__cid']
      }
{'fraction_non_alphanumeric': 0.10663082437275985, 'fraction_numerical': 0.0008960573476702509, 'mean_word_length': 2.7847457627118644, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '1032623', 'n_tokens_mistral': 687, 'n_tokens_neox': 665, 'n_words': 153}