feat: platform AI names behind Sign in with OTM (v0.3.0)
- OTM SSO: /api/auth/otm-sso verifies the control-plane ticket (vendored verifier), in-memory jti claim, mints an HMAC cookie (src/lib/session.ts); /api/auth/session + /api/auth/signout. No accounts, no DB. - /api/ai-names: server-side call to the platform's metered gateway (ANTHROPIC_BASE_URL + per-app gateway token), 401 without a session, ~20 req/h per OTM account. Prompt/parser shared with the BYO-key path via src/lib/ai-prompt.ts. - Finder: 'Sign in with OTM for AI names' link → 'AI names' toggle when signed in; own key still overrides. Pairs with platform 0.116.0 (needsAnthropic + needsAuthSecret on names). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XStQKxPfEjrTvWo83KFCxG
This commit is contained in:
19
src/app/api/auth/session/route.ts
Normal file
19
src/app/api/auth/session/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// Who's signed in (if anyone) and whether platform AI is even wired up on this
|
||||
// deployment. The UI decides from this what to show next to the AI toggle.
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { readSession, platformAiEnabled } from "@/lib/session";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const s = readSession(req);
|
||||
return NextResponse.json(
|
||||
{
|
||||
platformAi: platformAiEnabled(),
|
||||
user: s ? { email: s.email, name: s.name ?? null } : null,
|
||||
},
|
||||
{ headers: { "cache-control": "no-store" } },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user