chahinebrini 677b67902b feat(devices): protected device enrollment + mobileconfig generator
Backend:
- ProtectedDevice prisma model + migration add_protected_devices
- DB helpers: list/count/get/create/confirm/revoke
- mobileconfig.ts utility — XML-escape, unique UUIDs per request
- 5 endpoints under /api/devices/* (avoid /api/devices conflict with existing
  Capacitor UserDevice route by using /api/devices/protected for list)

Phase 1: backend ready. DoH-server token-routing comes in phase 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 04:06:49 +02:00

28 lines
649 B
TypeScript

import { getProfile } from "../../db/profile";
import { listProtectedDevices } from "../../db/protectedDevices";
/**
* GET /api/devices/protected
*
* Liste aller aktiven+pending ProtectedDevices des Users.
* Niemals dnsToken zurückgeben — Security.
*
* Auth: requireUser
*/
export default defineEventHandler(async (event) => {
const user = await requireUser(event);
const profile = await getProfile(user.id);
const devices = await listProtectedDevices(user.id);
return {
success: true,
data: {
devices,
plan: profile?.plan ?? "free",
max: 3,
isLegend: profile?.plan === "legend",
},
};
});