Skip to content

Commit

Permalink
add version functions to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed May 6, 2024
1 parent c9d7658 commit a0e57d5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions bindings/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface CookieObject {
httpOnly: boolean
sameSite: number
}
export function version(): string
export function anyBrowser(dbPath: string, domains?: Array<string> | undefined | null, keyPath?: string | undefined | null): Array<CookieObject>
/** Common browsers */
export function firefox(domains?: Array<string> | undefined | null): Array<CookieObject>
Expand Down
3 changes: 2 additions & 1 deletion bindings/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { anyBrowser, firefox, librewolf, chrome, brave, edge, opera, operaGx, chromium, vivaldi, firefoxBased, load, safari, chromiumBased } = nativeBinding
const { version, anyBrowser, firefox, librewolf, chrome, brave, edge, opera, operaGx, chromium, vivaldi, firefoxBased, load, safari, chromiumBased } = nativeBinding

module.exports.version = version
module.exports.anyBrowser = anyBrowser
module.exports.firefox = firefox
module.exports.librewolf = librewolf
Expand Down
2 changes: 1 addition & 1 deletion bindings/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
},
"repository": "https://github.com/thewh1teagle/rookie",
"description": "Load cookies from any browser on any platform"
}
}
5 changes: 5 additions & 0 deletions bindings/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ pub struct CookieObject {
pub same_site: i64,
}

#[napi]
pub fn version() -> Result<String> {
Ok(rookie::version())
}

fn cookies_to_js(cookies: Vec<Cookie>) -> Result<Vec<CookieObject>> {
let mut js_cookies: Vec<CookieObject> = vec![];
for cookie in cookies {
Expand Down
6 changes: 6 additions & 0 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ use rookie::enums::Cookie;
mod browsers;
use browsers::*;

#[pyfunction]
fn version() -> PyResult<String> {
Ok(rookie::version())
}

#[pymodule]
fn rookiepy(_py: Python, m: &PyModule) -> PyResult<()> {
pyo3_log::init();
Expand Down Expand Up @@ -31,6 +36,7 @@ fn rookiepy(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(safari, m)?)?;
}

m.add_function(wrap_pyfunction!(version, m)?)?;
Ok(())
}

Expand Down

0 comments on commit a0e57d5

Please sign in to comment.