Tyler
2026-06-25 11:03:05 -04:00
committed by GitHub
parent 996a3f89d5
commit 73cc31cc52
212 changed files with 0 additions and 2902 deletions

View File

@@ -30,8 +30,6 @@ use tokio::time::timeout;
use tokio_tungstenite::{connect_async, tungstenite::Message};
use zeroize::Zeroizing;
// ── CLI definition ────────────────────────────────────────────────────────────
#[derive(Parser)]
#[command(
name = "buzz-pair",
@@ -72,8 +70,6 @@ enum Cmd {
TestVectors,
}
// ── Error type ────────────────────────────────────────────────────────────────
#[derive(Debug, thiserror::Error)]
enum CliError {
#[error("pairing error: {0}")]
@@ -98,8 +94,6 @@ enum CliError {
Other(String),
}
// ── Entry point ───────────────────────────────────────────────────────────────
#[tokio::main]
async fn main() {
let cli = Cli::parse();
@@ -117,8 +111,6 @@ async fn run(cmd: Cmd) -> Result<(), CliError> {
}
}
// ── source subcommand ─────────────────────────────────────────────────────────
async fn cmd_source(relay_url: String, nsec: Option<String>) -> Result<(), CliError> {
// Resolve the payload to transfer.
let (payload_str, payload_type) = resolve_payload(nsec)?;
@@ -208,8 +200,6 @@ async fn cmd_source(relay_url: String, nsec: Option<String>) -> Result<(), CliEr
Ok(())
}
// ── target subcommand ─────────────────────────────────────────────────────────
async fn cmd_target(relay_override: Option<String>, show_secret: bool) -> Result<(), CliError> {
// Read QR URI from stdin.
print!("Paste the QR URI: ");
@@ -342,8 +332,6 @@ async fn cmd_target(relay_override: Option<String>, show_secret: bool) -> Result
Ok(())
}
// ── test-vectors subcommand ───────────────────────────────────────────────────
fn cmd_test_vectors() -> Result<(), CliError> {
// Fixed test keys from the NIP-AB spec.
let session_secret: [u8; 32] =
@@ -409,8 +397,6 @@ fn cmd_test_vectors() -> Result<(), CliError> {
Ok(())
}
// ── Abort-aware event helpers ─────────────────────────────────────────────────
/// Check whether `event` is an abort from the peer. If so, transition the
/// session and return an error the caller can propagate. Otherwise return
/// `Ok(())` so the caller can proceed with its own handler.
@@ -423,8 +409,6 @@ fn check_for_abort(session: &mut PairingSession, event: &Event) -> Result<(), Cl
}
}
// ── NIP-42 auth helper ────────────────────────────────────────────────────────
/// Handle NIP-42 authentication if the relay requires it.
///
/// Uses the pairing session's ephemeral keys to authenticate, ensuring the
@@ -502,8 +486,6 @@ fn parse_auth_challenge(text: &str) -> Option<String> {
None
}
// ── WebSocket helpers ─────────────────────────────────────────────────────────
/// Publish a Nostr event to the relay.
async fn publish_event<S>(write: &mut S, event: &Event) -> Result<(), CliError>
where
@@ -592,8 +574,6 @@ fn parse_relay_event(text: &str, sub_id: &str) -> Option<Event> {
serde_json::from_value(arr[2].clone()).ok()
}
// ── Payload helpers ───────────────────────────────────────────────────────────
/// Resolve the payload to send.
///
/// If `nsec` is provided, parse it as bech32 and return the raw nsec string.
@@ -617,8 +597,6 @@ fn resolve_payload(nsec: Option<String>) -> Result<(Zeroizing<String>, PayloadTy
}
}
// ── I/O helpers ───────────────────────────────────────────────────────────────
/// Read a single line from stdin (trims trailing newline).
fn read_line() -> Result<String, CliError> {
let stdin = io::stdin();
@@ -636,8 +614,6 @@ fn read_yes_no() -> Result<bool, CliError> {
Ok(matches!(line.trim(), "y" | "Y" | "yes" | "Yes" | "YES"))
}
// ── Crypto helpers ────────────────────────────────────────────────────────────
/// Decode a 64-char hex string into a `[u8; 32]`.
fn hex_to_32(s: &str) -> Result<[u8; 32], CliError> {
let bytes = hex::decode(s).map_err(|e| CliError::Other(format!("invalid hex '{s}': {e}")))?;