chore: use upstream nostr-sdk instead of fork

This commit is contained in:
reya 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"
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]]

View File

@ -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" }

View File

@ -14,6 +14,17 @@ struct Account {
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]
#[specta::specta]
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())?;
// 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())?;
// Handle auth url
nostr_connect.auth_url_handler(AuthHandler);
let bunker_uri = nostr_connect
.bunker_uri()
.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())?;
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
client.set_signer(signer).await;
// Emit to front-end