Skip to content

Commit 2572510

Browse files
author
Hayt
committed
Merge origin/main into hayt/nip-fi-stateless-enforcement
Co-authored-by: Will Pfleger <[email protected]> Signed-off-by: Will Pfleger <[email protected]> * origin/main: fix(sidebar): converge stale-at-open state across devices (sections/sort/stars/mutes) (#7805) feat(nip-fi): harden Blossom kind-24242 verifier to NIP-FI spec (#7288) Signed-off-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz>
2 parents fc871cc + 52c4c08 commit 2572510

55 files changed

Lines changed: 7385 additions & 2683 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎RELEASING.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,45 @@ prior release's recorded squash commit; tag ancestry is deliberately irrelevant.
8989
Every push to `main` continues to publish the rolling relay `:main` and
9090
`:sha-<7>` tags, plus matching `:debug-main` and `:debug-sha-<7>` variants.
9191

92+
#### NIP-FI upload proof freshness (relay floor)
93+
94+
Desktop, CLI, and mobile clients mint Blossom upload authorization proofs with
95+
a **60-second expiry** (`expiration = now + 60`). **Older** relays (≤ `v0.2.1`)
96+
re-run the full auth verifier — including the expiry check — after receiving the
97+
full upload body, so a 60-second proof that was valid when admitted can expire
98+
during a large or slow transfer, causing a spurious rejection.
99+
100+
The repair (commit `75e9bef748d2149ce459b14da842e706a51a5f78`, landed in this
101+
PR) replaces the post-body full-verifier call with a hash-only check
102+
(`verify_upload_hash_only`): the relay verifies the freshness and all other
103+
proof fields before reading the body; the only check after transfer is that the
104+
body's SHA-256 matches what was declared in the signed proof.
105+
106+
Clients cannot lengthen proofs beyond 60 seconds (NIP-FI §Strict limits the
107+
max proof window to 60 s). This is a relay-side concern:
108+
109+
- **The relay release that includes this PR's changes** (the first relay
110+
tag > `v0.2.1`, containing commit `75e9bef748d2149ce459b14da842e706a51a5f78`)
111+
performs a hash-only post-body check, eliminating the expiry window during
112+
transfer. **Update this line with the concrete relay tag once it is cut.**
113+
- **Older self-hosted relays** (≤ `v0.2.1`) re-verify the full proof expiry
114+
after transfer and may reject large uploads over slow connections.
115+
Upgrading the relay is the fix; no client workaround exists within Strict
116+
constraints.
117+
118+
**Prerequisite before distributing desktop, CLI, or mobile builds that mint
119+
60-second upload proofs:** verify that all supported relay environments have
120+
been upgraded to a relay release containing commit
121+
`75e9bef748d2149ce459b14da842e706a51a5f78`. An unknown or unverified deployment
122+
does not satisfy this prerequisite. Deployments running ≤ `v0.2.1` must be
123+
upgraded before receiving these clients.
124+
125+
When releasing a new **relay** version that carries the post-body hash-only
126+
check, record the concrete tag here so release operators can verify the
127+
prerequisite. When releasing **desktop, CLI, or mobile** for environments where
128+
self-hosted relays may be running pre-floor versions, document the floor in
129+
release notes and require operators to upgrade before distributing these clients.
130+
92131
### Mobile
93132

94133
1. **Publish a candidate.** From a clean checkout whose `origin` is the

‎crates/buzz-cli/src/client.rs‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ fn sign_blossom_get(keys: &Keys, media_url: &str) -> Result<String, CliError> {
327327
use nostr::Timestamp;
328328

329329
let now = Timestamp::now().as_secs();
330-
let exp_str = (now + 600).to_string();
330+
let exp_str = (now + 60).to_string();
331331
let domain = relay_server_tag(media_url)
332332
.ok_or_else(|| CliError::Usage(format!("invalid media URL: {media_url}")))?;
333333
let tags = vec![
@@ -350,28 +350,23 @@ fn sign_blossom_get(keys: &Keys, media_url: &str) -> Result<String, CliError> {
350350
fn sign_blossom_upload(
351351
keys: &Keys,
352352
sha256: &str,
353-
mime: &str,
353+
_mime: &str,
354354
relay_url: &str,
355355
) -> Result<String, CliError> {
356356
use base64::engine::general_purpose::URL_SAFE_NO_PAD;
357357
use nostr::Timestamp;
358358

359359
let now = Timestamp::now().as_secs();
360-
let expiry: u64 = if mime.starts_with("video/") {
361-
3600
362-
} else {
363-
600
364-
};
365-
let exp_str = (now + expiry).to_string();
360+
let exp_str = (now + 60).to_string();
361+
let domain = relay_server_tag(relay_url)
362+
.ok_or_else(|| CliError::Usage(format!("invalid relay URL: {relay_url}")))?;
366363

367-
let mut tags = vec![
364+
let tags = vec![
368365
Tag::parse(["t", "upload"]).map_err(|e| CliError::Other(e.to_string()))?,
369366
Tag::parse(["x", sha256]).map_err(|e| CliError::Other(e.to_string()))?,
370367
Tag::parse(["expiration", &exp_str]).map_err(|e| CliError::Other(e.to_string()))?,
368+
Tag::parse(["server", &domain]).map_err(|e| CliError::Other(e.to_string()))?,
371369
];
372-
if let Some(domain) = relay_server_tag(relay_url) {
373-
tags.push(Tag::parse(["server", &domain]).map_err(|e| CliError::Other(e.to_string()))?);
374-
}
375370

376371
let auth_event = EventBuilder::new(Kind::from(24242), "Upload file")
377372
.tags(tags)

‎crates/buzz-dev-mcp/src/view_image.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub(crate) const MAX_DECODER_ALLOC: u64 = 256 * 1024 * 1024;
4949
/// Connect + read timeout for URL fetches.
5050
const FETCH_TIMEOUT: Duration = Duration::from_secs(10);
5151
/// Lifetime of a Blossom `t=get` read token for relay media fetches.
52-
/// Matches the desktop client's `MEDIA_GET_AUTH_EXPIRY_SECS`.
53-
const MEDIA_GET_AUTH_EXPIRY_SECS: u64 = 600;
52+
/// 60 seconds — matches the NIP-FI strict proof window.
53+
const MEDIA_GET_AUTH_EXPIRY_SECS: u64 = 60;
5454

5555
/// Build the decoder allocation cap. Centralised so the resize path uses the
5656
/// same value tests can reason about.

0 commit comments

Comments
 (0)