Files
buzz/desktop/src-tauri/tests/fixtures/nip_fi
Brad Seiler 8a113ed99e fix(desktop): show upgrade guidance (BUZZ-517) (#9033)
## Summary

Old Buzz desktop clients now check a community’s public requirement
before each connection. An explicit `requires_nip_fi: true` shows an
upgrade screen with a fixed https://buzz.xyz download action and manual
fallback. Missing or false requirements, and failed discovery, preserve
normal connection behavior.

Retry, community navigation and address editing preserve keys and saved
communities. Changing an address cancels the old onboarding transaction
and fences pending profile checks. Native discovery sends no
credentials, follows no redirects, and limits requests to five seconds
and 256 KiB. Wire fixtures are exported from main `6b8a72e835` with
reproducible provenance.

### Related issue


[BUZZ-517](https://linear.app/squareup/issue/BUZZ-517/v0-clients-show-an-upgrade-screen-for-communities-requiring-nip-fi).
Related: [#8984](https://github.com/block/buzz/pull/8984) contains
mobile parser preparation;
[#8920](https://github.com/block/buzz/pull/8920) repairs relay rejection
messages.

### Rollout

There is no client flag. The upgrade screen appears only when the relay
advertises `requires_nip_fi: true`. Public auto-update delivery requires
a desktop release containing this change and promotion to the [OSS
auto-update
feed](aa749a862e/RELEASING.md (promote-an-oss-desktop-release-to-auto-update)).

In Shadow mode, requiring a community activates the screen; making it
optional restores normal connections. Global Enforce requires every
community regardless of that setting. Rollback must restore an effective
non-required policy. The optional and required outcomes are demonstrated
by Brad’s two manual cases below.

### Testing

At `71689b4708`, Honor’s isolated browser journeys passed 3/3 with zero
retries and verified served assets, including the fixed
`https://buzz.xyz` opener and manual fallback. McKeon independently
built and passed the same three journeys at the previous head
`8caa25260b` with the repository command: `CI=1 pnpm --dir desktop
build:e2e`, then `CI=1 pnpm --dir desktop exec playwright test
relay-entry-guidance.spec.ts --project=smoke`. Native IPC was mocked.

Brad [tested the running pre-rebase app
locally](https://github.com/block/buzz/pull/9033#issuecomment-6662960875):
an optional bb-public community in Shadow connected without a message;
required bb-block staging showed the upgrade message. These results
apply to that running app, not the rebased head.

Before:

![Earlier upgrade card with synthetic community
data](https://github.com/user-attachments/assets/63fbaa66-d551-4c20-ab04-c7fd966638e0)

After:

![Public upgrade card with Download latest Buzz action at
buzz.xyz](https://github.com/user-attachments/assets/f26a5d2a-47b4-4510-a86f-667d6f7c6d3d)

Generated with Codex

---------

Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
2026-11-05 19:22:01 +00:00
..

Community authentication discovery fixtures

These complete HTTP response bodies come from the production router at main commit 6b8a72e8355125d24e4f4fab1e083dced4119f5c. The NIP-FI discovery contract defines the top-level requires_nip_fi boolean.

Fixture suffix Global mode Synthetic Host Required FI capability
required shadow required.example true true
optional off free.example false false
optional_capable shadow free.example false true

The required fixture uses Shadow mode: Off never requires federated identity, even when the stored community policy requires it. Capability alone does not make an optional host required.

The exporter calls router::build_router through tower::ServiceExt::oneshot with synthetic policy and verifier boundaries. It verifies HTTP 200, Cache-Control: no-store, and matching decoded documents from / and /info, then saves the unmodified /info body. These fixtures verify wire compatibility; they do not establish deployed-host or installed-app acceptance.

To reproduce, use a detached checkout of the pinned source commit and append this temporary exporter to crates/buzz-relay/src/nip_fi_policy/tests.rs:

#[tokio::test]
async fn export_buzz_517_discovery_fixtures() {
    let out = std::path::PathBuf::from(std::env::var("BUZZ_FIXTURE_OUT").unwrap());
    std::fs::create_dir_all(&out).unwrap();
    for (name, mode, host) in [
        ("required", NipFiMode::Shadow, "required.example"),
        ("optional", NipFiMode::Off, "free.example"),
        ("optional_capable", NipFiMode::Shadow, "free.example"),
    ] {
        let (state, _, _, _) = fixture(mode).await;
        let app = crate::router::build_router(state);
        let mut documents = Vec::new();
        for path in ["/", "/info"] {
            let response = app.clone().oneshot(
                Request::get(path)
                    .header(header::HOST, host)
                    .header(header::ACCEPT, "application/nostr+json")
                    .body(Body::empty()).unwrap()
            ).await.unwrap();
            assert_eq!(response.status(), StatusCode::OK);
            assert_eq!(response.headers()[header::CACHE_CONTROL], "no-store");
            let bytes = to_bytes(response.into_body(), 256 * 1024).await.unwrap();
            documents.push(serde_json::from_slice::<serde_json::Value>(&bytes).unwrap());
            if path == "/info" {
                std::fs::write(out.join(format!("{name}.json")), &bytes).unwrap();
            }
        }
        assert_eq!(documents[0], documents[1]);
    }
}

Run from that checkout with an absolute output directory:

BUZZ_FIXTURE_OUT=/tmp/buzz-517-discovery cargo test --locked -p buzz-relay --lib nip_fi_policy::tests::export_buzz_517_discovery_fixtures -- --exact

The files here retain those response bytes with the buzz_main_6b8a72e835_ filename prefix. Legacy relays without the field are covered by the native reader's absent-field cases.