Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"rust-analyzer.cargo.features": [
"chromium-crypto/tracing",
"decrypt-cookies/Safari",
"decrypt-cookies/tracing",
"decrypt-cookies/linkme",
"binary-cookies/serde",
"binary-cookies/tokio",
"binary-cookies/csv",
Expand Down
49 changes: 22 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ panic = "abort"


[workspace.dependencies]
linkme = "0.3"
napi = "3"
napi-derive = "3"
napi-build = "2"
Expand All @@ -42,7 +43,6 @@ plist = "1"
bstr = "1"
oval = "2"
winnow = "0.7.11"
annotate-snippets = "0.11"

TinyUFO = "0.5"
cfg-if = "1"
Expand All @@ -53,7 +53,6 @@ reqwest = { version = "^0.12", default-features = false }
sea-orm = { version = "^1", default-features = false, features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"] }

dirs = { version = "^6" }
const_format = { version = "0.2" }

tracing = { version = "^0.1" }
tracing-subscriber = { version = "^0.3", default-features = true, features = ["env-filter"] }
Expand Down
2 changes: 0 additions & 2 deletions crates/binary-cookies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ categories = ["asynchronous", "authentication", "encoding"]
include = ["Cargo.toml", "README.md", "src"]

[dependencies]
# TODO: better error display?
# annotate-snippets = { workspace = true }
bstr = { workspace = true }
chrono = { workspace = true }
oval = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/decrypt-cookies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ binary-cookies = { workspace = true, features = ["tokio"], optional = true }
chromium-crypto = { workspace = true }
chrono = { workspace = true }
dirs = { workspace = true }
linkme = { workspace = true, optional = true }
pastey = { workspace = true, optional = true }
rayon = { workspace = true, optional = true }
reqwest = { workspace = true, default-features = false, features = ["cookies"], optional = true }
rust-ini = { workspace = true, optional = true }
Expand All @@ -33,9 +35,6 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }

[target.'cfg(not(windows))'.dependencies]
const_format = { workspace = true }

[target.'cfg(windows)'.dependencies]
anyhow = { workspace = true, optional = true }
rawcopy-rs-next = { workspace = true, optional = true }
Expand All @@ -46,6 +45,7 @@ chromium = ["anyhow", "rawcopy-rs-next", "rayon", "sea-orm"]
default = ["chromium", "firefox", "reqwest", "serde", "tracing"]
ffi = [] # Use for bindgen
firefox = ["rayon", "rust-ini", "sea-orm"]
linkme = ["dep:linkme", "pastey"] # Generate a browser name array
reqwest = ["dep:reqwest"]
serde = ["chrono/serde", "dep:serde"]
tracing = ["chromium-crypto/tracing", "dep:tracing"]
Expand Down
3 changes: 3 additions & 0 deletions crates/decrypt-cookies/examples/new_browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ firefox!("windows", NewBrowserBasedFirefox, base: r"AppData\Roaming\Mozilla\NewB
#[snafu::report]
#[tokio::main]
async fn main() -> Result<(), Whatever> {
assert!(BROWSERS.contains(&"NewBrowserBasedChromium"));
assert!(BROWSERS.contains(&"NewBrowserBasedFirefox"));

let chromium = ChromiumBuilder::<NewBrowserBasedChromium>::new()
.build()
.await
Expand Down
11 changes: 10 additions & 1 deletion crates/decrypt-cookies/src/browser/chromium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub trait ChromiumPath {

/// Register a Chromium based browser info
///
/// When linkme feature is enabled, the macro requires the `linkme` crate.
///
/// It accept
/// - `platform`
/// - `browser`: Generate a struct
Expand Down Expand Up @@ -128,6 +130,13 @@ macro_rules! chromium {
$(, key: $key:literal)?
$(, safe_name: $safe_name:literal)?
) => {
#[cfg(feature = "linkme")]
$crate::pastey::paste! {
#[cfg(target_os = $platform)]
#[linkme::distributed_slice($crate::browser::BROWSERS)]
static [<$browser:upper _NAME>]: &str = stringify!($browser);
}

#[cfg(target_os = $platform)]
#[derive(Clone, Copy)]
#[derive(Debug)]
Expand All @@ -145,7 +154,7 @@ macro_rules! chromium {
$(const LOGIN_DATA_FOR_ACCOUNT: &str = $login_data_fa;)?
$(const KEY: &str = $key;)?
$(
const SAFE_STORAGE: &str = const_format::concatcp!($safe_name, " Safe Storage");
const SAFE_STORAGE: &str = concat!($safe_name, " Safe Storage");
#[cfg(target_os = "macos")]
const SAFE_NAME: &str = $safe_name;
)?
Expand Down
9 changes: 9 additions & 0 deletions crates/decrypt-cookies/src/browser/firefox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub trait FirefoxPath {

/// Register a Firefox based browser info
///
/// When linkme feature is enabled, the macro requires the `linkme` crate.
///
/// It accept
/// - `platform`
/// - `browser`: Generate a struct
Expand Down Expand Up @@ -88,6 +90,13 @@ macro_rules! firefox {
$(, login_data: $login_data:literal)?
$(, key = $key:literal)?
) => {
#[cfg(feature = "linkme")]
$crate::pastey::paste! {
#[cfg(target_os = $platform)]
#[linkme::distributed_slice($crate::browser::BROWSERS)]
static [<$browser:upper _NAME>]: &str = stringify!($browser);
}

#[cfg(target_os = $platform)]
#[derive(Clone, Copy)]
#[derive(Debug)]
Expand Down
20 changes: 20 additions & 0 deletions crates/decrypt-cookies/src/browser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,23 @@ pub use firefox::*;

#[cfg(any(feature = "chromium", feature = "firefox"))]
const CACHE_PATH: &str = "decrypt-cookies";

#[cfg(feature = "linkme")]
#[linkme::distributed_slice]
/// All supported browser names
pub static BROWSERS: [&str];

#[cfg(feature = "linkme")]
#[test]
fn linkme_work() {
assert!(BROWSERS.contains(&"Firefox"));
assert!(BROWSERS.contains(&"Librewolf"));

assert!(BROWSERS.contains(&"Edge"));
assert!(BROWSERS.contains(&"Chrome"));

#[cfg(not(target_os = "linux"))]
assert!(BROWSERS.contains(&"CocCoc"));
#[cfg(not(target_os = "linux"))]
assert!(BROWSERS.contains(&"Arc"));
}
3 changes: 3 additions & 0 deletions crates/decrypt-cookies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ pub mod firefox;
pub mod safari;

pub(crate) mod utils;

#[cfg(feature = "linkme")]
pub use pastey;
Loading