Skip to content

feat(relay): list and revoke invite links - #9680

Merged
wpfleger96 merged 4 commits into
mainfrom
duncan/invite-list-revoke
Nov 20, 2026
Merged

wpfleger96 merged 4 commits into
mainfrom
duncan/invite-list-revoke

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Stack: this PR → #9690

What this does

Adds listing and revocation for v2 invite links, and makes every reader of an invite's expiry accept a missing value.

  • GET /api/invites?limit=&before= lists the community's v2 invites, newest first: id, creator, created/expiry/revoked times, uses and a computed status (active, revoked, expired, exhausted). Owner/admin only. The NIP-98 signature covers the full URL including the query. limit defaults to 50 (max 200). next_before is an opaque cursor holding the last row's created_at (microseconds) and id, so paging doesn't depend on that row still existing.
  • POST /api/invites/revoke takes exactly one of {"id": "<uuid>"} or {"code": "v2...."}. The code is hashed and looked up only inside the request's community. v1 and malformed codes get 400 invite_not_revocable; an invite not in the community gets 404. Revoking twice returns the first revoked_at. Members who already joined stay.
  • Authorization. Mint, list and revoke share one HTTP admission helper (tenant bind → NIP-98 via NIP-FI → replay → membership/ban → NIP-OA owner link → role gate). Revoke's final decision is made in the write transaction, in the same order as mint: admission lock → actor's role row FOR SHARE → restriction check → invite row FOR UPDATE. Owners and admins can revoke any invite; any other member only one they created. A removed or restricted actor is refused. Mint now uses the same role-lock helper.
  • Mint response now includes invite_id.
  • Nullable expiry readers. Claim, list, the mint response and operator mint treat a missing expires_at as "never expires". The column is still NOT NULL here.
  • Secrets. No list/revoke response or access-log line contains a code or its hash; request errors are fixed strings that never echo input. Revoke logs only invite_id. A revoke the database refuses is logged as denied with its reason.

Deploy order

A follow-up PR adds links that never expire (expires_at nullable). It depends on this PR being deployed everywhere first, so every serving relay can read a missing expiry before one is written.

Tests

  • DB (relay_invite/manage_postgres_tests.rs): revoke by code targets exactly one of two near-identical invites, idempotent revoke, community scoping, creator demoted to member can revoke theirs, a member who didn't create it is refused, a removed creator is refused, a restricted admin is refused, a demotion holding the role row or a restriction holding the admission lock makes revoke wait and then refuse with the row unchanged, a paused claim and a revoke serialize with the member kept, revoke is refused while the community is quiescing, paging survives deleting the cursor row, and a row with no expiry is listed, claimed, kept by the reaper and revocable (on a scratch database with NOT NULL dropped).
  • Relay (invites/postgres_tests/manage_tests.rs): list/revoke by id and code end to end, no code or hash in responses, member/non-member refusals, bad selectors, other-community lookups, query-string signature binding, malformed requests not echoing a code in responses or access logs, refused revokes logged as denied, and replayed list/revoke requests refused.

wpfleger96 and others added 4 commits November 18, 2026 18:02
Add GET /api/invites (owner/admin) and POST /api/invites/revoke (by id or
v2 code; owner/admin or the invite's creator, gated in the write
transaction). Mint responses now include invite_id, and every reader of an
invite's expiry accepts a missing value so a later release can mint links
that never expire.

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Return fixed parse errors that never echo input, use a self-contained
(created_at, id) list cursor, log database revoke refusals as denials, and
cover the revoke writer's demotion, restriction, claim and quiescing races
plus replay on the new routes.

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
Signed-off-by: Will Pfleger <wpfleger@block.xyz>
…voke

* origin/main:
  feat(mobile): add saved channel section filters (#8479)
  feat(relay): support community-scoped NIP-AR artifacts (#9650)

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
@wpfleger96
wpfleger96 marked this pull request as ready for review November 19, 2026 22:41
@wpfleger96
wpfleger96 deployed to codex-review November 19, 2026 22:41 — with GitHub Actions Active
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 19, 2026
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 9bcb3e45a426bc4b232f4731f46d6015ed0781ab...a79dff50561bfbfacf02225e46ad30e6991b1123
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings identified in the authorized PR range.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds and tests were not run, as instructed.

Generated by Codex Security Review |
Requested by: @wpfleger96 |
Workflow run

@TheSentinel454 TheSentinel454 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 LGTM. Lock order matches claim and mint, list and revoke never return a code or hash, and all new tests ran in CI at this head.

@wpfleger96
wpfleger96 merged commit 792a9ce into main Nov 20, 2026
98 checks passed
@wpfleger96
wpfleger96 deleted the duncan/invite-list-revoke branch November 20, 2026 20:48
mcdickenson added a commit that referenced this pull request Nov 20, 2026
…mployee-name-sync-20261112-92c07862

* origin/main: (65 commits)
  fix(mobile): diagnostic reporting follow-ups (#9808)
  feat(relay): list and revoke invite links (#9680)
  fix(push-gateway): answer 429, not 404, when the delivery quota is exhausted (#9803)
  feat(cli): leave archived identities out of users get --name (#9752)
  fix(mobile): skip the emoji picker when its opener is gone (#9820)
  fix(push-gateway): retry, don't drop, a delivery replayed while its first attempt is in flight (#9802)
  fix(mobile): clear the Duo top edge in the Activity header (#9807)
  feat(test-client): add buzz-acceptance relay probe (#9767)
  feat(relay): add pinned messages (nip-pm) (#9729)
  Align Duo chat headers, inset Home selections, and fix received photo-stack swipes (#9795)
  fix(mobile): only dot channel-sent replies in the reader's threads (#9696)
  docs: point community invite at buzz.communities (#9797)
  Mobile: refine section filters and ordering in Messages (#9796)
  feat(push-gateway): mint FCM tokens through AWS workload identity federation (#9692)
  feat(mobile): report explicit diagnostic errors (#9673)
  fix(mobile): keep the agent poster over a failed iOS player (#9693)
  perf(push-gateway): evict the oldest signed-call window without scanning (#9799)
  Refine iOS composer and transcribe recordings into drafts (#9574)
  fix(mobile): recognize agents without NIP-OA in Huddles (#8545)
  test(relay): cover member-cache invalidation routes and refill orders (#9748)
  ...

Signed-off-by: Matt Dickenson <mdickenson@squareup.com>

# Conflicts:
#	crates/buzz-relay/src/router.rs
wpfleger96 added a commit to block/buzz-app that referenced this pull request Nov 20, 2026
Adds invite-link management to community Membership settings.

- **Links tab** for owners and admins: each invite with its status, uses
and expiry, a **Revoke** button on every row (with confirmation),
paging, and a Refresh that keeps pages already loaded. A **Revoke a
link** field takes a pasted invite link for this community and revokes
it by its code. People who already joined stay in.
- **Revoke results** come from the relay's receipt, so a revoked row
shows Revoked even when a later list read fails. A failed revoke keeps
the confirmation open with a readable error and Retry; after a timeout,
Refresh shows what the relay holds. A revoke still in flight, success or
failure, still shows when the admin goes Back to Members and Forward
again. After a row is revoked, focus moves to the list.
- **Links without an expiry** read "Never expires" in the list.
- **Both hosts** (browser broker and native `relay_http`) support a
signed `GET /api/invites`, which accepts only the relay's opaque
`before` cursor, and `POST /api/invites/revoke`. Request shapes are
normalized in `admin-protocol.ts`.

Minting is unchanged from main.

Stack: #3910 → #4120

Related: [buzz#9680](block/buzz#9680)

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Co-authored-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz>
ruvnet added a commit to ruvnet/ruflo that referenced this pull request Nov 22, 2026
…_sync cursor (#5029, #5030) (#5057)

* fix(x-gateway): single-use invites, invite revocation, ordered sync cursor (#5029, #5030)

#5029
- mintInvite and federation_invite_mint default to max_uses 1 (was 25);
  maxUses/ttlSecs must be positive integers.
- New legacy-only, admin-only federation_invite_revoke: revokes by code or id
  via buzz-relay POST /api/invites/revoke (block/buzz#9680). Admission is
  decided by the relay, so revocation lives there; a relay build without the
  route answers 404 and the tool reports "unsupported". Withheld from the
  directory profiles because it accepts an invite code.
- CLI: x_federation_invite_revoke passthrough; mint/--uses text says default 1.

#5030
- federation_sync returns next_cursor and accepts since_cursor. The relay
  exposes no receive-order sequence, so the cursor carries a window floor plus
  48-bit prefixes of the ids already delivered inside it. Each call reads the
  whole window (full NIP-01 pages are narrowed by `until` bisection, because
  `limit` keeps the newest events) and delivers unseen events oldest first by
  (created_at, id). Same-second events and late arrivals within 300 s are
  delivered exactly once. A timed-out read hands the same cursor back.
- The cursor is decoded as hostile input: length cap, strict shape, lookback
  clamped to 30 days, bound to the type filter.
- No-cursor calls keep the old window read and relay filter.
- CLI: since_cursor in the x_federation_sync schema; `federation sync --cursor`.

Gateway package 0.9.2 -> 0.10.0, plugin 0.10.6 -> 0.11.0.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(x-gateway): judge sync completeness on the raw relay page; compact cursor

buzz-relay applies `limit` in SQL before it matches #t/#k in Rust
(handlers/req.rs filter_fully_pushable), so a short #t-filtered page does not
prove a window complete. Cursor reads now send only kinds/since/until/limit,
match the swarm tag and type locally, and judge completeness on the raw count.
A no-cursor read cannot prove completeness either, so its next_cursor keeps the
whole requested window and remembers what was returned.

The cursor encodes delivered ids as delta-coded seconds, so the largest cursor
the gateway can emit (2000 ids in distinct seconds) fits the schema cap, and
any type string the tool accepts round-trips. Tests: the fake relay applies
limit before tag matching and carries non-swarm traffic; a property test pins
the cursor size bound.

Co-Authored-By: RuFlo <ruv@ruv.net>

* test(ci): list the new x-gateway node:test files in the root ratchet baseline

invite-admin and sync-cursor import nostr-tools, which only the plugin's own
`npm test` installs (157/157 pass there), like the other x-gateway suites.

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>

This branch was successfully deployed

1 active deployment
codex-review — a79dff50 Deployed Nov 19, 2026 by wpfleger96 via Run Codex Security Review #16546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants