chore(pairing): 5-min pairing window + inbound-event wiretap logging
This commit is contained in:
parent
049219b0f1
commit
5aa122d92d
1 changed files with 8 additions and 1 deletions
|
|
@ -40,7 +40,7 @@ const REQUEST_TIMEOUT: Duration = Duration::from_secs(30);
|
||||||
const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(120);
|
const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(120);
|
||||||
/// How long a pairing QR (client-initiated `nostrconnect://`) stays live
|
/// How long a pairing QR (client-initiated `nostrconnect://`) stays live
|
||||||
/// while a human opens their signer and scans it.
|
/// while a human opens their signer and scans it.
|
||||||
const PAIRING_TIMEOUT: Duration = Duration::from_secs(120);
|
const PAIRING_TIMEOUT: Duration = Duration::from_secs(300);
|
||||||
/// App name advertised to signers during client-initiated pairing.
|
/// App name advertised to signers during client-initiated pairing.
|
||||||
const APP_NAME: &str = "Keynectr";
|
const APP_NAME: &str = "Keynectr";
|
||||||
|
|
||||||
|
|
@ -581,6 +581,11 @@ impl Nip46ClientSigner {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let event = *incoming;
|
let event = *incoming;
|
||||||
|
eprintln!(
|
||||||
|
"[nip46 pairing] inbound 24133 from {} (content len {})",
|
||||||
|
&event.pubkey.to_hex()[..16],
|
||||||
|
event.content.len()
|
||||||
|
);
|
||||||
// Never answer ourselves.
|
// Never answer ourselves.
|
||||||
if event.pubkey == our_pk {
|
if event.pubkey == our_pk {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -588,9 +593,11 @@ impl Nip46ClientSigner {
|
||||||
// Not addressed to us unless it decrypts with a conversation
|
// Not addressed to us unless it decrypts with a conversation
|
||||||
// keyed to this author.
|
// keyed to this author.
|
||||||
let Ok(conv) = ConversationKey::derive(keys.secret_key(), &event.pubkey) else {
|
let Ok(conv) = ConversationKey::derive(keys.secret_key(), &event.pubkey) else {
|
||||||
|
eprintln!("[nip46 pairing] could not derive a conversation with this author");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Ok(plain) = nip44_decrypt(&conv, &event.content) else {
|
let Ok(plain) = nip44_decrypt(&conv, &event.content) else {
|
||||||
|
eprintln!("[nip46 pairing] payload did not decrypt (wrong conversation key)");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Ok(request) = serde_json::from_str::<RawRequest>(&plain) else {
|
let Ok(request) = serde_json::from_str::<RawRequest>(&plain) else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue