Files
buzz/crates
Will Pfleger 24a3706060 feat(relay): log who and why for NIP-FI shadow would-deny (#8634)
In shadow mode, the relay's `nip-fi shadow would-deny` line now says
which client enforce would refuse and why, not just the coarse public
outcome.

- The line moves from `debug` to `info`. Admits still write no line.
- It gains `reason`, one value from a fixed snake_case set naming the
step's private condition: `community_unresolved` (community resolution
failed or was unavailable), `community_stale`, `session_deadline`,
`duplicate_authorization`, `missing_proof`, `invalid_proof`,
`missing_assertion`, `malformed_assertion`, `verifier_unavailable`, the
verifier's own error code without its `nip_fi_` prefix (for example
`expired`, `unknown_issuer`, `invalid_signature_or_claims`,
`token_type_rejected`), `key_mismatch`, `no_asserted_key`, `deny_set`,
`owner_banned`, `not_stored_owner`, `owner_ban_unavailable`,
`owner_link_unavailable` and `tenant_unavailable`.
- It gains `pubkey`, the hex Nostr key of the would-be-refused client,
or `absent`. On HTTP it is the verified NIP-98 proof key, for every step
including community and cardinality. On WebSocket and audio it is the
key NIP-42 AUTH proved, or for deny-set and deadline the key a verified
token asserts. A router-guard or upgrade would-deny precedes any proof,
so its line names the key the client later proves: the request's
verified NIP-98 key, or the connection's first verified NIP-42 AUTH key.
Each such line is written exactly once. On HTTP it is written when the
handler verifies its NIP-98 proof, or as `absent` when the request ends
without one. On WebSocket and audio it is written at the first verified
NIP-42 AUTH, while the connection stays open, or as `absent` when an
unproven connection's read loop ends (close or auth timeout), before any
cleanup that can block. Its counter still increments at once. An
unsigned `X-Pubkey` never counts.
- `buzz_nip_fi_shadow_total` keeps exactly its `route`, `stage`,
`outcome` and `community` labels, so cardinality stays bounded.

No token, assertion, issuer, subject or other claim reaches the line;
verifier reasons are static strings. The denial classes and response
bodies clients see are unchanged.

---------

Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
2026-10-28 00:22:45 +00:00
..