diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:20:28 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:20:28 +0000 |
| commit | 75cd323e2481502671aa1f62b28875d95f9863c3 (patch) | |
| tree | 7616f95119ad18ba07cbfcb744025f644ba9ce3e /src/lib/login | |
| parent | 83448a99aaf18c7a045a081c5de0c22bc4a83de1 (diff) | |
feat(login): contact remote signer when needed
for existing login, the remote signer should only be called when an
event needs to be signed. This might be a AUTH event so we still
need to call it during read scenarios.
a feature was added to rust-nostr to enable this.
Diffstat (limited to 'src/lib/login')
| -rw-r--r-- | src/lib/login/existing.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/lib/login/existing.rs b/src/lib/login/existing.rs index f5b93c7..45727b0 100644 --- a/src/lib/login/existing.rs +++ b/src/lib/login/existing.rs | |||
| @@ -198,24 +198,25 @@ async fn get_signer( | |||
| 198 | bunker_app_key, | 198 | bunker_app_key, |
| 199 | npub, | 199 | npub, |
| 200 | } => { | 200 | } => { |
| 201 | let term = console::Term::stderr(); | ||
| 202 | term.write_line("connecting to remote signer...")?; | ||
| 203 | let uri = NostrConnectURI::parse(bunker_uri)?; | 201 | let uri = NostrConnectURI::parse(bunker_uri)?; |
| 204 | let signer: Arc<dyn NostrSigner> = Arc::new(NostrConnect::new( | 202 | let s = NostrConnect::new( |
| 205 | uri, | 203 | uri, |
| 206 | nostr::Keys::from_str(bunker_app_key).context("invalid app key")?, | 204 | nostr::Keys::from_str(bunker_app_key).context("invalid app key")?, |
| 207 | Duration::from_secs(10 * 60), | 205 | Duration::from_secs(10 * 60), |
| 208 | None, | 206 | None, |
| 209 | )?); | 207 | )?; |
| 210 | term.clear_last_lines(1)?; | 208 | if let Some(public_key) = npub.clone().and_then(|npub| PublicKey::parse(npub).ok()) { |
| 211 | let public_key = if let Some(pubic_key) = | 209 | s.non_secure_set_user_public_key(public_key)?; |
| 212 | npub.clone().and_then(|npub| PublicKey::parse(npub).ok()) | 210 | let signer: Arc<dyn NostrSigner> = Arc::new(s); |
| 213 | { | 211 | Ok((signer, public_key)) |
| 214 | pubic_key | ||
| 215 | } else { | 212 | } else { |
| 216 | fetch_public_key(&signer).await? | 213 | let signer: Arc<dyn NostrSigner> = Arc::new(s); |
| 217 | }; | 214 | let term = console::Term::stderr(); |
| 218 | Ok((signer, public_key)) | 215 | term.write_line("connecting to remote signer...")?; |
| 216 | let public_key = fetch_public_key(&signer).await?; | ||
| 217 | term.clear_last_lines(1)?; | ||
| 218 | Ok((signer, public_key)) | ||
| 219 | } | ||
| 219 | } | 220 | } |
| 220 | } | 221 | } |
| 221 | } | 222 | } |