refactor: remove the billing tier model (P0.1)

The community edition has no monetization (ADR-0001). Remove the tier
model (packages/shared/src/tiers.ts), the requireTier middleware and every
tier gate, GET/PATCH /api/tier and the trial start, and the Stripe
integration, which depends on the tier model.

Personal features a tier used to limit are open to everyone: unlimited
workspaces and connectors, every embedding provider including LiteLLM,
per-workspace costs, Approvals. The workspace session cap is one constant
(100). Team and enterprise surfaces are hidden instead of unlocked (team
dock zone, Settings Team/Enterprise/Plan tabs, workspace Team tab);
cloud sync reports unavailable, as it did for free users.

The sidecar ignores the tier keys in config.json but does not delete them:
both editions may still share ~/.waggle.

Web billing UI is deleted: plan cards, upgrade and trial modals, payment
success route, the KVARK sales block, tier 403 handling.
This commit is contained in:
shumeiko.it
2026-10-15 19:31:50 +02:00
parent 369d8269c1
commit fe2eb0f648
117 changed files with 342 additions and 6424 deletions

View File

@@ -237,25 +237,12 @@ export class SessionTimeoutTracker {
/**
* Routes exempt from bearer token authentication.
*
* `/api/stripe/webhook` is a tokenless POST from Stripe's servers — it can never
* carry our per-process session bearer, so in a hosted (0.0.0.0) deploy it would
* 401 before the handler and subscription-lifecycle events
* (customer.subscription.deleted/updated) would never process — cancelled subs
* would never downgrade to FREE. It is independently authenticated by Stripe
* *signature verification* inside the handler (stripe.webhooks.constructEvent
* rejects any body not signed with STRIPE_WEBHOOK_SECRET before the handler
* trusts it), so exempting it from the bearer gate does not widen the trust
* boundary. Desktop (loopback) mode is unaffected — Stripe can't reach a
* loopback bind. The path string matches the route registered in
* stripe/webhook.ts (`POST /api/stripe/webhook`, no prefix).
*/
const AUTH_EXEMPT_PATHS = [
'/health',
'/api/auth/session-token',
'/api/browser-ext/session-token',
'/api/browser-ext/pair',
'/api/stripe/webhook',
];
/**
@@ -738,8 +725,8 @@ async function securityMiddlewarePlugin(
// ── Bearer token authentication (SEC-011 + D1) ──
// D1: localhost is NO LONGER trusted by default. Waggle is a desktop app that
// coexists with browsers/extensions/other local apps, so "any loopback caller is
// trusted" let any of them drive the authenticated API (e.g. the PATCH /api/tier
// free upgrade). The Tauri webview obtains the token from the auth-exempt,
// trusted" let any of them drive the authenticated API (e.g. change settings or
// provider keys). The Tauri webview obtains the token from the auth-exempt,
// same-origin-gated /api/auth/session-token bootstrap and sends it as a Bearer.
// Set WAGGLE_TRUST_LOCALHOST=1 to restore legacy loopback trust (emergency escape).
if (sessionToken) {