Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/pycookiecheat/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,28 @@ def get_macos_config(browser: BrowserType) -> dict:
raise ValueError(errmsg) from e
cookie_file = "~" / app_support / cookies_suffix

# Slack cookies can be in two places on MacOS depending on whether it was
# installed from the App Store or direct download.
if browser is BrowserType.SLACK and not cookie_file.exists():
# And this location if Slack is installed from App Store
# Cookie location and keyring username in MacOS depends on whether the
# application was installed from the App Store or direct download. To find
# out, we simply assume it's direct download and fall back to App Store if
# it's not there. Currently this distinction is only known for Slack, so
# that is the only case handled here.
isAppStore = False
if browser is BrowserType.SLACK and not cookie_file.expanduser().exists():
isAppStore = True
cookie_file = (
"~/Library/Containers/com.tinyspeck.slackmacgap/Data"
/ app_support
/ cookies_suffix
/ app_support / cookies_suffix
)

browser_name = browser.title()
keyring_service_name = f"{browser_name} Safe Storage"

keyring_username = browser_name
if browser is BrowserType.SLACK:
keyring_username = "Slack App Store Key"
if browser is BrowserType.SLACK and isAppStore:
keyring_username = f"{browser_name} App Store Key"
elif browser is BrowserType.SLACK:
keyring_username = f"{browser_name} Key"
else:
keyring_username = f"{browser_name}"

key_material = keyring.get_password(keyring_service_name, keyring_username)
if key_material is None:
Expand Down