feat: add automatic Firefox cookie and localstorage extraction (#112)

* feat: add automatic Firefox cookie and localstorage extraction

* address security and consistency findings from PR review
This commit is contained in:
sk8ordi3
2026-06-21 12:26:17 -06:00
committed by GitHub
parent a2f670b140
commit 5b724b48f8
3 changed files with 177 additions and 1 deletions
+15 -1
View File
@@ -4157,8 +4157,20 @@ class dl:
return default_cookie_file
@staticmethod
def get_cookie_jar(service: str, profile: Optional[str]) -> Optional[MozillaCookieJar]:
def get_cookie_jar(service: str, profile: Optional[str]) -> Optional[CookieJar]:
"""Get Service Cookies for Profile."""
# Check if automatic Firefox cookie extraction is configured for this service
ff_settings = getattr(config, "firefox_cookies", {}).get(service)
if ff_settings:
try:
from unshackle.core.utils.firefox_cookie_extractor import get_firefox_cookies
extracted_jar = get_firefox_cookies(ff_settings)
if extracted_jar:
return extracted_jar
except Exception:
# Fallback to file-based if Firefox extraction fails
pass
cookie_file = dl.get_cookie_path(service, profile)
if cookie_file:
cookie_jar = MozillaCookieJar(cookie_file)
@@ -4175,6 +4187,8 @@ class dl:
cookie_file.write_text(cookie_data, "utf8")
cookie_jar.load(ignore_discard=True, ignore_expires=True)
return cookie_jar
return None
@staticmethod
def save_cookies(path: Path, cookies: CookieJar):