Skip to content

Commit

Permalink
chore: use upstream nostr-sdk instead of fork
Browse files Browse the repository at this point in the history
  • Loading branch information
reyamir committed Nov 8, 2024
1 parent 4904177 commit 50bf6c0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
25 changes: 13 additions & 12 deletions src-tauri/Cargo.lock

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

6 changes: 2 additions & 4 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
20 changes: 18 additions & 2 deletions src-tauri/src/commands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 50bf6c0

Please sign in to comment.