Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ serde_yaml = "0.9"
evalexpr = "11"
cron = "0.16"
# Observability
log = "0.4"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
tracing-opentelemetry = { version = "0.33" }
Expand Down
3 changes: 3 additions & 0 deletions crates/buzz-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ rand = { workspace = true }
tempfile = "3"
# Minimal HTTP test server for retry/policy integration tests
axum = { workspace = true }
# Local WebSocket relay fixtures for exact-event command integration tests
futures-util = { workspace = true }
tokio-tungstenite = { workspace = true }
12 changes: 11 additions & 1 deletion crates/buzz-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ export BUZZ_PRIVATE_KEY="nsec1..."
buzz channels list
```

`events get-verified` can read from a public Nostr relay without a key. If the
relay requires NIP-42, it uses `BUZZ_PRIVATE_KEY` and the optional
`BUZZ_AUTH_TAG` for authentication only; event trust still comes from local ID
recomputation and signature verification.

## Usage

All output is JSON on stdout. Errors are JSON on stderr. Exit codes: 0=ok, 1=user error, 2=network, 3=auth, 4=other, 5=write conflict.

```bash
# Set relay URL (defaults to http://localhost:3000)
# Set relay URL (defaults to http://localhost:3000 for ordinary commands)
export BUZZ_RELAY_URL="https://relay.example.com"

# Exact raw event read (command-local relay is mandatory; no env/default fallback)
buzz events get-verified --relay wss://relay.example.com --event <64hex>

# Messages
buzz messages send --channel <uuid> --content "Hello"
buzz messages send --channel <uuid> --content "Reply" --reply-to <event-id> --broadcast
Expand Down Expand Up @@ -146,6 +154,7 @@ stored rules in `validation_error` so an owner can remove and repair them.
| | `runs` | Get workflow run history |
| | `approve` | Approve/deny a workflow step |
| `feed` | `get` | Get your activity feed |
| `events` | `get-verified` | Fetch one exact raw event and verify its NIP-01 ID and Schnorr signature locally |
| `social` | `publish` | Publish a NIP-01 note |
| | `set-contacts` | Set NIP-02 contact list |
| | `event` | Get a Nostr event |
Expand Down Expand Up @@ -174,6 +183,7 @@ buzz <group> <subcommand> [flags]
├─ main.rs ──▶ commands/*.rs ──▶ client.rs ──▶ Buzz Relay REST API
│ (clap) (handlers) (reqwest)
│ └──────────▶ buzz-ws-client (exact Nostr reads)
├─ validate.rs (UUID, hex, content size, percent-encode)
└─ error.rs (CliError → JSON stderr + exit code)
Expand Down
20 changes: 20 additions & 0 deletions crates/buzz-cli/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,25 @@ buzz notes get --name dco-check # exits non-zero: not found
buzz notes rm --name does-not-exist # exits non-zero
```

### 6.13 Exact Verified Events

This is a raw NIP-01 WebSocket read. Its `--relay` is mandatory and does not
inherit `BUZZ_RELAY_URL` or the global `--relay`. The command waits for EOSE,
requires exactly one result, recomputes the event ID, and verifies the Schnorr
signature locally before writing anything to stdout.

```bash
# EVENT_ID comes from the message created in section 6.3.
buzz events get-verified \
--relay ws://localhost:3000 \
--event "$EVENT_ID" | jq .
# Expected: {id,pubkey,created_at,kind,tags,content,sig}

# A missing command-local relay is a user error even when BUZZ_RELAY_URL is set.
buzz events get-verified --event "$EVENT_ID"
# Expected: exit 1, no stdout
```

---

## 7. Error Path Testing
Expand Down Expand Up @@ -621,3 +640,4 @@ buzz channels delete --channel "$FORUM_ID" | jq .
| 60 | `notes ls` | ☐ | Own, --author all, --tag, --limit |
| 61 | `notes rm` | ☐ | Delete→get 404, double-delete idempotent, missing slug → NotFound |
| 62 | `users set-status` | ☐ | Text+emoji, text only, emoji-only (`--text ""`), `--clear`, `--clear` + `--text` → exit 1 |
| 63 | `events get-verified` | ☐ | Exact ID, raw seven-field event, local ID/signature verification, explicit WS relay |
Loading