chore: use upstream nostr-sdk instead of fork

This commit is contained in:
2024-11-08 07:51:48 +07:00
parent 490417771c
commit 50bf6c04c1
3 changed files with 33 additions and 18 deletions

25
src-tauri/Cargo.lock generated
View File

@@ -12,6 +12,7 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
name = "Lume" name = "Lume"
version = "24.11.0" version = "24.11.0"
dependencies = [ dependencies = [
"async-trait",
"border", "border",
"futures", "futures",
"keyring", "keyring",
@@ -47,6 +48,7 @@ dependencies = [
"tokio", "tokio",
"tracing-subscriber", "tracing-subscriber",
"url", "url",
"webbrowser",
] ]
[[package]] [[package]]
@@ -3091,7 +3093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-targets 0.48.5", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -3490,7 +3492,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
[[package]] [[package]]
name = "nostr" name = "nostr"
version = "0.36.0" 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 = [ dependencies = [
"aes", "aes",
"async-trait", "async-trait",
@@ -3521,7 +3523,7 @@ dependencies = [
[[package]] [[package]]
name = "nostr-connect" name = "nostr-connect"
version = "0.36.0" 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 = [ dependencies = [
"async-trait", "async-trait",
"async-utility", "async-utility",
@@ -3530,13 +3532,12 @@ dependencies = [
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
"webbrowser",
] ]
[[package]] [[package]]
name = "nostr-database" name = "nostr-database"
version = "0.36.0" 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 = [ dependencies = [
"async-trait", "async-trait",
"flatbuffers", "flatbuffers",
@@ -3550,7 +3551,7 @@ dependencies = [
[[package]] [[package]]
name = "nostr-lmdb" name = "nostr-lmdb"
version = "0.36.0" 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 = [ dependencies = [
"heed", "heed",
"nostr", "nostr",
@@ -3563,7 +3564,7 @@ dependencies = [
[[package]] [[package]]
name = "nostr-relay-pool" name = "nostr-relay-pool"
version = "0.36.0" 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 = [ dependencies = [
"async-utility", "async-utility",
"async-wsocket", "async-wsocket",
@@ -3581,7 +3582,7 @@ dependencies = [
[[package]] [[package]]
name = "nostr-sdk" name = "nostr-sdk"
version = "0.36.0" 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 = [ dependencies = [
"async-utility", "async-utility",
"atomic-destructor", "atomic-destructor",
@@ -3600,7 +3601,7 @@ dependencies = [
[[package]] [[package]]
name = "nostr-zapper" name = "nostr-zapper"
version = "0.36.0" 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 = [ dependencies = [
"async-trait", "async-trait",
"nostr", "nostr",
@@ -3736,7 +3737,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [ dependencies = [
"proc-macro-crate 1.3.1", "proc-macro-crate 3.2.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.79", "syn 2.0.79",
@@ -3745,7 +3746,7 @@ dependencies = [
[[package]] [[package]]
name = "nwc" name = "nwc"
version = "0.36.0" 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 = [ dependencies = [
"async-trait", "async-trait",
"async-utility", "async-utility",
@@ -7267,7 +7268,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]

View File

@@ -49,10 +49,8 @@ regex = "1.10.4"
keyring = { version = "3", features = ["apple-native", "windows-native"] } keyring = { version = "3", features = ["apple-native", "windows-native"] }
keyring-search = { git = "https://github.com/reyamir/keyring-search" } keyring-search = { git = "https://github.com/reyamir/keyring-search" }
tracing-subscriber = { version = "0.3.18", features = ["fmt"] } tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
async-trait = "0.1.83"
[patch.'https://github.com/rust-nostr/nostr'] webbrowser = "1.0.2"
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" }
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]
border = { git = "https://github.com/ahkohd/tauri-toolkit", branch = "v2" } border = { git = "https://github.com/ahkohd/tauri-toolkit", branch = "v2" }

View File

@@ -14,6 +14,17 @@ struct Account {
nostr_connect: Option<String>, nostr_connect: Option<String>,
} }
#[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] #[tauri::command]
#[specta::specta] #[specta::specta]
pub fn get_accounts() -> Vec<String> { pub fn get_accounts() -> Vec<String> {
@@ -94,9 +105,12 @@ pub async fn connect_account(uri: String, state: State<'_, Nostr>) -> Result<Str
let remote_npub = remote_user.to_bech32().map_err(|err| err.to_string())?; let remote_npub = remote_user.to_bech32().map_err(|err| err.to_string())?;
// Init nostr connect // Init nostr connect
let nostr_connect = NostrConnect::new(bunker_uri, app_keys, Duration::from_secs(120), None) let mut nostr_connect = NostrConnect::new(bunker_uri, app_keys, Duration::from_secs(120), None)
.map_err(|err| err.to_string())?; .map_err(|err| err.to_string())?;
// Handle auth url
nostr_connect.auth_url_handler(AuthHandler);
let bunker_uri = nostr_connect let bunker_uri = nostr_connect
.bunker_uri() .bunker_uri()
.await .await
@@ -217,7 +231,9 @@ pub async fn set_signer(
let app_keys = Keys::from_str(&account.secret_key).map_err(|e| e.to_string())?; let app_keys = Keys::from_str(&account.secret_key).map_err(|e| e.to_string())?;
match NostrConnect::new(uri, app_keys, Duration::from_secs(120), None) { match NostrConnect::new(uri, app_keys, Duration::from_secs(120), None) {
Ok(signer) => { Ok(mut signer) => {
// Handle auth url
signer.auth_url_handler(AuthHandler);
// Update signer // Update signer
client.set_signer(signer).await; client.set_signer(signer).await;
// Emit to front-end // Emit to front-end