feat: Support signing using NIP-46 bunker

Suggested-by: DanConwayDev <DanConwayDev@protonmail.com>
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-07-18 21:18:26 +00:00
parent f0c20c3677
commit 4e0ecdceaf
11 changed files with 211 additions and 23 deletions

View File

@@ -24,8 +24,11 @@ use nostr::{
nip19::{self, FromBech32, Nip19Coordinate},
},
types::RelayUrl,
util::BoxedFuture,
};
use nostr_connect::client::AuthUrlHandler;
use tokio::runtime::Handle;
use url::Url;
use super::{RepoRelaySetsExt, parsers};
use crate::{
@@ -61,6 +64,18 @@ pub struct NostrEvent {
pub relays: Vec<RelayUrl>,
}
#[derive(Debug)]
pub struct EchoAuthUrl;
impl AuthUrlHandler for EchoAuthUrl {
fn on_auth_url(&self, auth_url: Url) -> BoxedFuture<Result<(), Box<dyn std::error::Error>>> {
Box::pin(async move {
println!("The bunker requires authentication. Please open this URL: {auth_url}");
Ok(())
})
}
}
impl NaddrOrSet {
/// Returns the naddr if `Naddr` or try to get the relays from the set.
/// Returns error if the set naddrs are empty or the set not found.