Skip to content

fix(payments): publication gate on authenticated payment initiation - #536

Merged
catomean merged 1 commit into
mainfrom
fix/draft-entity-purchase-gate
Aug 2, 2026
Merged

fix(payments): publication gate on authenticated payment initiation#536
catomean merged 1 commit into
mainfrom
fix/draft-entity-purchase-gate

Conversation

@catomean

@catomean catomean commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Found by live simulation: initiatePayment resolves seller + wallet through the admin client, so an authenticated user could mint a real invoice + order against a DRAFT entity. The authed flow now applies the same publication gate the public-support flow already has — the buyer's own RLS read decides visibility. Regression test added.

🤖 Generated with Claude Code

Found by the same live simulation: seller and wallet resolution inside
initiatePayment run on the admin client, so an authenticated user could mint
a real invoice + order against a DRAFT entity the owner never published.
The public-support flow already gates on the anonymous RLS read; the authed
flow now applies the identical pattern — the buyer's own RLS visibility is
the publication gate. Regression test added; drafts map to a clean 400.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@catomean
catomean merged commit e654ad3 into main Aug 2, 2026
5 checks passed
@catomean
catomean deleted the fix/draft-entity-purchase-gate branch August 2, 2026 10:52
catomean added a commit that referenced this pull request Aug 2, 2026
…public pages (#568)

Browser-verifying #564 against prod found the disclosure both silent where it
mattered most and primed to overstate elsewhere. Both defects came from
counting entity_wallets rows per wallet_id and trusting them:

1. Reuse across wallet ROWS holding the SAME address was invisible. Prod holds
   orangecat@coinos.io in two wallet rows (and one xpub in eleven), so the
   platform's most visible reuse — FleetCrown Personal and FleetCrown Pro both
   showing orangecat@coinos.io — disclosed nothing. On-chain linkability is a
   property of the address, not the row: now all wallet rows sharing the
   resolved address contribute links.

2. The raw count would have claimed pages that do not exist. All nine links on
   one prod wallet point at deleted entities; the notice would have read "also
   receives funds for 8 other pages" a backer cannot open — fabricated
   confidence, which is the exact failure this disclosure exists to prevent.
   Siblings are now counted through the caller's RLS-scoped client, so the
   database's own visibility rules decide what is a public page (drafts and
   deleted rows contribute nothing), matching the #536 payment gate.

Three regression tests pin both directions: twin-address reuse counts, orphan
links count zero, drafts excluded. 9 tests green; tsc + eslint clean.

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant