mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 22:41:09 +02:00
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>
35 lines
871 B
JSON
35 lines
871 B
JSON
{
|
|
"name": "@mana/shared-hono",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"description": "Shared Hono infrastructure: auth, health, admin, error handling for lightweight compute servers",
|
|
"type": "module",
|
|
"main": "./src/index.ts",
|
|
"types": "./src/index.ts",
|
|
"exports": {
|
|
".": "./src/index.ts",
|
|
"./auth": "./src/auth.ts",
|
|
"./db": "./src/db.ts",
|
|
"./health": "./src/health.ts",
|
|
"./admin": "./src/admin.ts",
|
|
"./error": "./src/error.ts",
|
|
"./credits": "./src/credits.ts",
|
|
"./rate-limit": "./src/rate-limit.ts",
|
|
"./logger": "./src/logger.ts"
|
|
},
|
|
"scripts": {
|
|
"type-check": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@mana/shared-logger": "workspace:*",
|
|
"hono": "^4.7.0",
|
|
"jose": "^6.0.11",
|
|
"drizzle-orm": "^0.45.1",
|
|
"postgres": "^3.4.5"
|
|
},
|
|
"devDependencies": {
|
|
"@types/bun": "latest",
|
|
"@types/node": "^24.10.1",
|
|
"typescript": "^5.9.3"
|
|
}
|
|
}
|