# frozen_string_literal: true

module Dispatch
  module Adapter
    class Claude < Base
      module PKCE
        module_function

        def generate
          verifier = base64url(SecureRandom.bytes(32))
          challenge = base64url(Digest::SHA256.digest(verifier))
          { verifier:, challenge: }
        end

        def base64url(bytes)
          Base64.urlsafe_encode64(bytes).delete("=")
        end
      end
    end
  end
end
