Skip to content

fix: require token name + restrict marketplace publish to admins - #18

Merged
criptogus merged 1 commit into
mainfrom
claude/marketplace-lock-and-token-name
May 23, 2026
Merged

criptogus merged 1 commit into
mainfrom
claude/marketplace-lock-and-token-name

Conversation

@criptogus

Copy link
Copy Markdown
Owner

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:

  • UI (/account/tokens): button disabled until a non-empty name is typed, helper text, Enter-to-submit, and a clear placeholder/aria-label. account.tokens.tsx
  • Server: createMcpToken validator now trims the input and rejects empty strings instead of defaulting. tokens.functions.ts

2. Marketplace publication is admin-only

Authors could self-publish to the public marketplace by typing the confirmation phrase, bypassing the /admin/review queue and its adversarial gate. Now:

  • Server (setMyPackagePublished): non-admin authors submit drafts for review (review_status='pending', is_published=false). Only admins can flip is_published=true. Authors can still unpublish their own packages anytime.
  • UI (/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.
  • Database (new migration 20260523000000_marketplace_publish_admin_only.sql): enforce_admin_only_publish trigger on packages blocks any UPDATE/INSERT that flips is_published=true unless the caller is service_role (used by the admin RPCs that already run the adversarial gate) or has the admin role in user_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.tsx
  • src/lib/account/tokens.functions.ts
  • src/routes/account.packages.tsx
  • src/lib/account/packages.functions.ts
  • supabase/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/packages as a non-admin: clicking Submit for review, typing confirmation, submitting → toast says "Submitted for review", badge shows "Pending admin review", button greyed out.
  • /admin/review as admin: approving the same package flips it to "Public · marketplace".
  • Direct SQL: UPDATE packages SET is_published = TRUE WHERE id = '…'; as a non-admin authenticated session → fails with marketplace_publish_forbidden.
  • Direct SQL: same UPDATE as service_role → succeeds (used by setReviewStatus).
  • Author can still UNpublish their own previously-public package without an admin.

https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd


Generated by Claude Code

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
criptogus marked this pull request as ready for review May 23, 2026 01:48
@criptogus
criptogus merged commit adc4514 into main May 23, 2026
1 check passed
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.

2 participants