fix: require token name + restrict marketplace publish to admins - #18
Merged
Merged
Conversation
Two user-reported issues from /account:
1. Token name was silently defaulting to "Default" when the user clicked
Mint without typing — and the input cleared on submit so the user
couldn't tell why. Now the Mint button is disabled until a non-empty
name is typed, and the server-side validator trims + rejects empty
strings instead of defaulting.
2. Authors could self-publish to the public marketplace just by typing
the confirmation phrase, bypassing the admin review queue entirely.
The /admin/review flow with the adversarial gate existed but was
optional. Now:
- setMyPackagePublished submits non-admin requests for review
(review_status='pending', is_published stays false) and only
admins can flip is_published=true directly.
- The /account/packages dialog and CTAs say "Submit for review",
show a "Pending admin review" badge while queued, and gray out
the button until an admin acts.
- New DB trigger enforce_admin_only_publish blocks any UPDATE that
flips is_published true unless the caller is service_role or
has the admin role in user_roles — so even direct SQL or a new
code path that forgot the check can't expose a package
publicly without admin approval.
https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
criptogus
marked this pull request as ready for review
May 23, 2026 01:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two user-reported issues from the account area.
1. Token name required (no more silent "Default")
The Mint button used to fall back to
name || "Default", so users who hadn't typed a name (or had typed and didn't realise the input had cleared) ended up with indistinguishable tokens. Fixed by:/account/tokens): button disabled until a non-empty name is typed, helper text, Enter-to-submit, and a clear placeholder/aria-label.account.tokens.tsxcreateMcpTokenvalidator now trims the input and rejects empty strings instead of defaulting.tokens.functions.ts2. Marketplace publication is admin-only
Authors could self-publish to the public marketplace by typing the confirmation phrase, bypassing the
/admin/reviewqueue and its adversarial gate. Now:setMyPackagePublished): non-admin authors submit drafts for review (review_status='pending',is_published=false). Only admins can flipis_published=true. Authors can still unpublish their own packages anytime./account/packages): CTA changed to "Submit for review", new amber "Pending admin review" badge while queued, button greyed out while pending; copy explains the admin approval flow.20260523000000_marketplace_publish_admin_only.sql):enforce_admin_only_publishtrigger onpackagesblocks any UPDATE/INSERT that flipsis_published=trueunless the caller isservice_role(used by the admin RPCs that already run the adversarial gate) or has theadminrole inuser_roles. Belt-and-suspenders: even a future code path that forgets the application check can't expose a package publicly.Files
src/routes/account.tokens.tsxsrc/lib/account/tokens.functions.tssrc/routes/account.packages.tsxsrc/lib/account/packages.functions.tssupabase/migrations/20260523000000_marketplace_publish_admin_only.sql(new)Test plan
/account/tokens: Mint button is disabled until a name is typed; typing "ci-deploy" + Mint shows the new token in the list as "ci-deploy" (not "Default")./account/packagesas a non-admin: clicking Submit for review, typing confirmation, submitting → toast says "Submitted for review", badge shows "Pending admin review", button greyed out./admin/reviewas admin: approving the same package flips it to "Public · marketplace".UPDATE packages SET is_published = TRUE WHERE id = '…';as a non-admin authenticated session → fails withmarketplace_publish_forbidden.setReviewStatus).https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
Generated by Claude Code