From 50bf6c04c1f3c9c4bc29287485d0dda86ec4e0c9 Mon Sep 17 00:00:00 2001 From: reya Date: Fri, 8 Nov 2024 07:51:48 +0700 Subject: [PATCH] chore: use upstream nostr-sdk instead of fork --- src-tauri/Cargo.lock | 25 +++++++++++++------------ src-tauri/Cargo.toml | 6 ++---- src-tauri/src/commands/account.rs | 20 ++++++++++++++++++-- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index fa7afb93..78e3a11d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -12,6 +12,7 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" name = "Lume" version = "24.11.0" dependencies = [ + "async-trait", "border", "futures", "keyring", @@ -47,6 +48,7 @@ dependencies = [ "tokio", "tracing-subscriber", "url", + "webbrowser", ] [[package]] @@ -3091,7 +3093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -3490,7 +3492,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" [[package]] name = "nostr" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "aes", "async-trait", @@ -3521,7 +3523,7 @@ dependencies = [ [[package]] name = "nostr-connect" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "async-trait", "async-utility", @@ -3530,13 +3532,12 @@ dependencies = [ "thiserror", "tokio", "tracing", - "webbrowser", ] [[package]] name = "nostr-database" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "async-trait", "flatbuffers", @@ -3550,7 +3551,7 @@ dependencies = [ [[package]] name = "nostr-lmdb" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "heed", "nostr", @@ -3563,7 +3564,7 @@ dependencies = [ [[package]] name = "nostr-relay-pool" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "async-utility", "async-wsocket", @@ -3581,7 +3582,7 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "async-utility", "atomic-destructor", @@ -3600,7 +3601,7 @@ dependencies = [ [[package]] name = "nostr-zapper" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "async-trait", "nostr", @@ -3736,7 +3737,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 2.0.79", @@ -3745,7 +3746,7 @@ dependencies = [ [[package]] name = "nwc" version = "0.36.0" -source = "git+https://github.com/reyamir/nostr?branch=feat/open-auth-url#596ad460a6747ccc60c27dce8141bf2dd5765df6" +source = "git+https://github.com/rust-nostr/nostr#46d96391d94316d6bf1637e10f1b980f866f1879" dependencies = [ "async-trait", "async-utility", @@ -7267,7 +7268,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 265af600..006cac52 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -49,10 +49,8 @@ regex = "1.10.4" keyring = { version = "3", features = ["apple-native", "windows-native"] } keyring-search = { git = "https://github.com/reyamir/keyring-search" } tracing-subscriber = { version = "0.3.18", features = ["fmt"] } - -[patch.'https://github.com/rust-nostr/nostr'] -nostr-sdk = { git = "https://github.com/reyamir/nostr", branch = "feat/open-auth-url", features = ["lmdb", "webln", "all-nips"] } -nostr-connect = { git = "https://github.com/reyamir/nostr", branch = "feat/open-auth-url" } +async-trait = "0.1.83" +webbrowser = "1.0.2" [target.'cfg(target_os = "macos")'.dependencies] border = { git = "https://github.com/ahkohd/tauri-toolkit", branch = "v2" } diff --git a/src-tauri/src/commands/account.rs b/src-tauri/src/commands/account.rs index b37584fc..0e406ba8 100644 --- a/src-tauri/src/commands/account.rs +++ b/src-tauri/src/commands/account.rs @@ -14,6 +14,17 @@ struct Account { nostr_connect: Option, } +#[derive(Debug, Clone)] +struct AuthHandler; + +#[async_trait::async_trait] +impl AuthUrlHandler for AuthHandler { + async fn on_auth_url(&self, auth_url: Url) -> Result<()> { + webbrowser::open(auth_url.as_str())?; + Ok(()) + } +} + #[tauri::command] #[specta::specta] pub fn get_accounts() -> Vec { @@ -94,9 +105,12 @@ pub async fn connect_account(uri: String, state: State<'_, Nostr>) -> Result { + Ok(mut signer) => { + // Handle auth url + signer.auth_url_handler(AuthHandler); // Update signer client.set_signer(signer).await; // Emit to front-end