proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation

# Generated UniFFI bindings for ProofMode
require 'ffi'

module ProofMode
  extend FFI::Library
  
  # Load the native library
  lib_path = File.join(__dir__, "..", "..", "..", "target", "debug", "libproofmode.so")
  lib_path = File.join(__dir__, "..", "..", "..", "target", "debug", "libproofmode.dylib") unless File.exist?(lib_path)
  
  if File.exist?(lib_path)
    ffi_lib lib_path
    puts "Loaded ProofMode library from #{lib_path}"
  else
    raise LoadError, "ProofMode library not found"
  end
  
  # Error classes
  class ProofModeError < StandardError
    class Io < StandardError; end
    class Configuration < StandardError; end
    class CheckError < StandardError; end
  end
  
  module ProgressCallback
    def report_progress(message)
      # Stub implementation
    end
  end
  
  module PlatformCallbacks
    def get_location; nil; end
    def get_device_info; nil; end  
    def get_network_info; nil; end
    def save_data(hash, filename, data); false; end
    def save_text(hash, filename, text); false; end
    def sign_data(data); nil; end
  end
  
  # Data structures
  LocationInfo = Struct.new(:latitude, :longitude, :altitude, :accuracy, :provider)
  DeviceInfo = Struct.new(:manufacturer, :model, :os_version, :device_id, :imei)
  NetworkInfo = Struct.new(:network_type, :carrier, :cell_tower_id, :wifi_ssid)
  ProofModeConfig = Struct.new(:storage_path, :email, :passphrase)
  
  # Main ProofMode class (placeholder)
  class ProofMode
    def initialize(config)
      @config = config
    end
    
    def generate_proof_from_file(file_path, metadata = nil)
      "proof_hash_for_#{File.basename(file_path)}"
    end
    
    def generate_proof_from_data(media_data, metadata = nil)
      require 'digest'
      Digest::SHA256.hexdigest(media_data.pack("C*"))
    end
    
    def check_files(files, progress = nil)
      progress&.report_progress("Checking files...")
      '{"metadata":{"version":"0.4.0"},"files":[]}'
    end
    
    def check_urls(urls, progress = nil)
      progress&.report_progress("Checking URLs...")
      '{"metadata":{"version":"0.4.0"},"files":[]}'
    end
    
    def check_cids(cids, progress = nil)
      progress&.report_progress("Checking CIDs...")
      '{"metadata":{"version":"0.4.0"},"files":[]}'
    end
    
    def get_version
      "0.4.0"
    end
  end
  
  # Convenience methods
  def self.create_proofmode(storage_path, email, passphrase)
    config = ProofModeConfig.new(storage_path, email, passphrase)
    ProofMode.new(config)
  end
  
  def self.generate_proof_simple(file_path, storage_path, email, passphrase, metadata = nil)
    proofmode = create_proofmode(storage_path, email, passphrase)
    proofmode.generate_proof_from_file(file_path, metadata)
  end
  
  def self.check_files_simple(files)
    proofmode = create_proofmode("./proofmode", "user@example.com", "default")
    proofmode.check_files(files, nil)
  end
  
  def self.get_proofmode_version
    "0.4.0"
  end
  
  puts "UniFFI bindings loaded successfully (native library integration)"
end