import os from typing import Optional class Settings: @staticmethod def load_settings() -> dict: return { "space_public_url": os.getenv("SPACE_PUBLIC_URL", ""), "session_ttl_seconds": int(os.getenv("SESSION_TTL_SECONDS", "3600")), "job_ttl_seconds": int(os.getenv("JOB_TTL_SECONDS", "300")), "max_payload_bytes": int(os.getenv("MAX_PAYLOAD_BYTES", "10485760")), "max_workers_per_session": int(os.getenv("MAX_WORKERS_PER_SESSION", "5")), "require_device_signatures": os.getenv("REQUIRE_DEVICE_SIGNATURES", "false").lower() == "true", "receipt_storage_path": os.getenv("RECEIPT_STORAGE_PATH", "./data/receipts.jsonl"), "allow_untrusted_browser_worker": os.getenv("ALLOW_UNTRUSTED_BROWSER_WORKER", "true").lower() == "true", } @staticmethod def get_public_url() -> str: url = os.getenv("SPACE_PUBLIC_URL", "") if not url: # Try to infer from HF Space environment url = os.getenv("SPACE_HOST", "") if url: url = f"https://{url}" return url @staticmethod def get_session_ttl_seconds() -> int: return int(os.getenv("SESSION_TTL_SECONDS", "3600")) @staticmethod def get_job_ttl_seconds() -> int: return int(os.getenv("JOB_TTL_SECONDS", "300")) @staticmethod def get_max_payload_bytes() -> int: return int(os.getenv("MAX_PAYLOAD_BYTES", "10485760")) @staticmethod def is_signature_required() -> bool: return os.getenv("REQUIRE_DEVICE_SIGNATURES", "false").lower() == "true"