get_cookie/
lib.rs

1//! Fetch a cookie from a locally-installed browser store
2//!
3//! # Example
4//!
5//! ```rust,no_run
6//! extern crate get_cookie;
7//!
8//! # fn main() {
9//!   let cookie = get_cookie::get_cookie(".mydomain.com", "my-cookie-name");
10//! # }
11//! ```
12
13mod chrome;
14mod cookie;
15mod errors;
16
17pub fn get_cookie(domain: &str, cookie: &str) -> Result<String, errors::GetCookieError> {
18    // TODO: Add support for other browsers, check which browser has the latest cookie and return it.
19    let cookie = chrome::get_cookie(domain, cookie)?;
20    match cookie.value {
21        cookie::CookieValue::Text(text) => Ok(text),
22        cookie::CookieValue::Encrypted(_) => Err(errors::GetCookieError::DecryptionError),
23    }
24    //
25    // Safari support:
26    //   * Could be based on https://github.com/alexwlchan/azure-aws-credentials/blob/development/src/safari_browsercookie.rs
27    //   * Safari cookies file could not be read by default, the app needs "full disk access" permission, which
28    //     requires an App (not a stand-alone binary), signing, etc.
29}