managarten/packages/shared-hono/src
Till JS 76d11a84ee feat(auth): server-side tier gating via requireTier middleware
The JWT already carried a `tier` claim but nothing on the server read it
— AuthGate enforcement was client-only, so a valid JWT could hit paid
LLM/research endpoints regardless of the user's access tier.

- shared-hono authMiddleware now extracts `tier` into `c.userTier`,
  defaulting unknown/missing claims to `public` (never silently grants
  higher access).
- New `requireTier(minTier)` middleware + `hasTier`/`getTierLevel`
  helpers. Tier hierarchy (guest < public < beta < alpha < founder) is
  mirrored locally to avoid pulling the Svelte-facing shared-branding
  package into Bun services.
- Applied `requireTier('beta')` as defense-in-depth on resource-heavy
  apps/api modules (chat, context, food, guides, news-research, picture,
  plants, research, traces, who) and the MCP endpoint. Pure CRUD modules
  stay auth-only — access there is gated by ownership, not tier.
- DEV_BYPASS_AUTH now injects `userTier` (defaults to founder, override
  via DEV_USER_TIER).
- Authentication guideline documents the pattern + test suite covers
  hierarchy, passes-at-minimum, and rejection paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 17:38:06 +02:00
..
admin.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
auth.ts feat(auth): server-side tier gating via requireTier middleware 2026-04-19 17:38:06 +02:00
credits.ts refactor(credits): simplify credit system — remove productivity credits, guild pools, complex gift types 2026-04-10 19:08:42 +02:00
db.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
error.ts refactor(shared-tailwind): rewrite themes.css to single-layer shadcn convention 2026-04-09 01:13:06 +02:00
health.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
index.ts feat(auth): server-side tier gating via requireTier middleware 2026-04-19 17:38:06 +02:00
logger.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
rate-limit.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
tier.test.ts feat(auth): server-side tier gating via requireTier middleware 2026-04-19 17:38:06 +02:00
tier.ts feat(auth): server-side tier gating via requireTier middleware 2026-04-19 17:38:06 +02:00
types.ts feat(auth): server-side tier gating via requireTier middleware 2026-04-19 17:38:06 +02:00