@mano8/astro-auth-m8 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +100 -0
  3. package/dist/bin/astro-auth-m8.d.ts +3 -0
  4. package/dist/bin/astro-auth-m8.d.ts.map +1 -0
  5. package/dist/bin/astro-auth-m8.js +53 -0
  6. package/dist/bin/astro-auth-m8.js.map +1 -0
  7. package/dist/src/integration.d.ts +42 -0
  8. package/dist/src/integration.d.ts.map +1 -0
  9. package/dist/src/integration.js +54 -0
  10. package/dist/src/integration.js.map +1 -0
  11. package/dist/src/lib/csp.d.ts +19 -0
  12. package/dist/src/lib/csp.d.ts.map +1 -0
  13. package/dist/src/lib/csp.js +49 -0
  14. package/dist/src/lib/csp.js.map +1 -0
  15. package/dist/src/middleware.d.ts +4 -0
  16. package/dist/src/middleware.d.ts.map +1 -0
  17. package/dist/src/middleware.js +24 -0
  18. package/dist/src/middleware.js.map +1 -0
  19. package/dist/src/runtime/api/apiKeys.d.ts +7 -0
  20. package/dist/src/runtime/api/apiKeys.d.ts.map +1 -0
  21. package/dist/src/runtime/api/apiKeys.js +26 -0
  22. package/dist/src/runtime/api/apiKeys.js.map +1 -0
  23. package/dist/src/runtime/api/auth.d.ts +6 -0
  24. package/dist/src/runtime/api/auth.d.ts.map +1 -0
  25. package/dist/src/runtime/api/auth.js +53 -0
  26. package/dist/src/runtime/api/auth.js.map +1 -0
  27. package/dist/src/runtime/api/dashboard.d.ts +4 -0
  28. package/dist/src/runtime/api/dashboard.d.ts.map +1 -0
  29. package/dist/src/runtime/api/dashboard.js +9 -0
  30. package/dist/src/runtime/api/dashboard.js.map +1 -0
  31. package/dist/src/runtime/api/index.d.ts +9 -0
  32. package/dist/src/runtime/api/index.d.ts.map +1 -0
  33. package/dist/src/runtime/api/index.js +9 -0
  34. package/dist/src/runtime/api/index.js.map +1 -0
  35. package/dist/src/runtime/api/oauth.d.ts +17 -0
  36. package/dist/src/runtime/api/oauth.d.ts.map +1 -0
  37. package/dist/src/runtime/api/oauth.js +41 -0
  38. package/dist/src/runtime/api/oauth.js.map +1 -0
  39. package/dist/src/runtime/api/ops.d.ts +4 -0
  40. package/dist/src/runtime/api/ops.d.ts.map +1 -0
  41. package/dist/src/runtime/api/ops.js +9 -0
  42. package/dist/src/runtime/api/ops.js.map +1 -0
  43. package/dist/src/runtime/api/profile.d.ts +6 -0
  44. package/dist/src/runtime/api/profile.d.ts.map +1 -0
  45. package/dist/src/runtime/api/profile.js +15 -0
  46. package/dist/src/runtime/api/profile.js.map +1 -0
  47. package/dist/src/runtime/api/sessions.d.ts +9 -0
  48. package/dist/src/runtime/api/sessions.d.ts.map +1 -0
  49. package/dist/src/runtime/api/sessions.js +24 -0
  50. package/dist/src/runtime/api/sessions.js.map +1 -0
  51. package/dist/src/runtime/api/users.d.ts +8 -0
  52. package/dist/src/runtime/api/users.d.ts.map +1 -0
  53. package/dist/src/runtime/api/users.js +21 -0
  54. package/dist/src/runtime/api/users.js.map +1 -0
  55. package/dist/src/runtime/client.d.ts +17 -0
  56. package/dist/src/runtime/client.d.ts.map +1 -0
  57. package/dist/src/runtime/client.js +92 -0
  58. package/dist/src/runtime/client.js.map +1 -0
  59. package/dist/src/runtime/compatibility.d.ts +32 -0
  60. package/dist/src/runtime/compatibility.d.ts.map +1 -0
  61. package/dist/src/runtime/compatibility.js +97 -0
  62. package/dist/src/runtime/compatibility.js.map +1 -0
  63. package/dist/src/runtime/config.d.ts +10 -0
  64. package/dist/src/runtime/config.d.ts.map +1 -0
  65. package/dist/src/runtime/config.js +18 -0
  66. package/dist/src/runtime/config.js.map +1 -0
  67. package/dist/src/runtime/errors.d.ts +20 -0
  68. package/dist/src/runtime/errors.d.ts.map +1 -0
  69. package/dist/src/runtime/errors.js +44 -0
  70. package/dist/src/runtime/errors.js.map +1 -0
  71. package/dist/src/runtime/hooks/index.d.ts +8 -0
  72. package/dist/src/runtime/hooks/index.d.ts.map +1 -0
  73. package/dist/src/runtime/hooks/index.js +8 -0
  74. package/dist/src/runtime/hooks/index.js.map +1 -0
  75. package/dist/src/runtime/hooks/useApiKeys.d.ts +74 -0
  76. package/dist/src/runtime/hooks/useApiKeys.d.ts.map +1 -0
  77. package/dist/src/runtime/hooks/useApiKeys.js +53 -0
  78. package/dist/src/runtime/hooks/useApiKeys.js.map +1 -0
  79. package/dist/src/runtime/hooks/useDashboard.d.ts +43 -0
  80. package/dist/src/runtime/hooks/useDashboard.d.ts.map +1 -0
  81. package/dist/src/runtime/hooks/useDashboard.js +29 -0
  82. package/dist/src/runtime/hooks/useDashboard.js.map +1 -0
  83. package/dist/src/runtime/hooks/useGoogleLogin.d.ts +6 -0
  84. package/dist/src/runtime/hooks/useGoogleLogin.d.ts.map +1 -0
  85. package/dist/src/runtime/hooks/useGoogleLogin.js +24 -0
  86. package/dist/src/runtime/hooks/useGoogleLogin.js.map +1 -0
  87. package/dist/src/runtime/hooks/useProfile.d.ts +98 -0
  88. package/dist/src/runtime/hooks/useProfile.d.ts.map +1 -0
  89. package/dist/src/runtime/hooks/useProfile.js +57 -0
  90. package/dist/src/runtime/hooks/useProfile.js.map +1 -0
  91. package/dist/src/runtime/hooks/useSessions.d.ts +77 -0
  92. package/dist/src/runtime/hooks/useSessions.d.ts.map +1 -0
  93. package/dist/src/runtime/hooks/useSessions.js +56 -0
  94. package/dist/src/runtime/hooks/useSessions.js.map +1 -0
  95. package/dist/src/runtime/hooks/useUsers.d.ts +171 -0
  96. package/dist/src/runtime/hooks/useUsers.d.ts.map +1 -0
  97. package/dist/src/runtime/hooks/useUsers.js +87 -0
  98. package/dist/src/runtime/hooks/useUsers.js.map +1 -0
  99. package/dist/src/runtime/listParams.d.ts +27 -0
  100. package/dist/src/runtime/listParams.d.ts.map +1 -0
  101. package/dist/src/runtime/listParams.js +66 -0
  102. package/dist/src/runtime/listParams.js.map +1 -0
  103. package/dist/src/runtime/queryKeys.d.ts +10 -0
  104. package/dist/src/runtime/queryKeys.d.ts.map +1 -0
  105. package/dist/src/runtime/queryKeys.js +11 -0
  106. package/dist/src/runtime/queryKeys.js.map +1 -0
  107. package/dist/src/runtime/react/AuthProvider.d.ts +18 -0
  108. package/dist/src/runtime/react/AuthProvider.d.ts.map +1 -0
  109. package/dist/src/runtime/react/AuthProvider.js +121 -0
  110. package/dist/src/runtime/react/AuthProvider.js.map +1 -0
  111. package/dist/src/runtime/react/AuthQueryProvider.d.ts +8 -0
  112. package/dist/src/runtime/react/AuthQueryProvider.d.ts.map +1 -0
  113. package/dist/src/runtime/react/AuthQueryProvider.js +11 -0
  114. package/dist/src/runtime/react/AuthQueryProvider.js.map +1 -0
  115. package/dist/src/runtime/react/RequireAuth.d.ts +6 -0
  116. package/dist/src/runtime/react/RequireAuth.d.ts.map +1 -0
  117. package/dist/src/runtime/react/RequireAuth.js +8 -0
  118. package/dist/src/runtime/react/RequireAuth.js.map +1 -0
  119. package/dist/src/runtime/react/RequireRole.d.ts +9 -0
  120. package/dist/src/runtime/react/RequireRole.d.ts.map +1 -0
  121. package/dist/src/runtime/react/RequireRole.js +12 -0
  122. package/dist/src/runtime/react/RequireRole.js.map +1 -0
  123. package/dist/src/runtime/react/default-ui/AccountView.d.ts +2 -0
  124. package/dist/src/runtime/react/default-ui/AccountView.d.ts.map +1 -0
  125. package/dist/src/runtime/react/default-ui/AccountView.js +16 -0
  126. package/dist/src/runtime/react/default-ui/AccountView.js.map +1 -0
  127. package/dist/src/runtime/react/default-ui/CallbackView.d.ts +2 -0
  128. package/dist/src/runtime/react/default-ui/CallbackView.d.ts.map +1 -0
  129. package/dist/src/runtime/react/default-ui/CallbackView.js +22 -0
  130. package/dist/src/runtime/react/default-ui/CallbackView.js.map +1 -0
  131. package/dist/src/runtime/react/default-ui/LoginForm.d.ts +44 -0
  132. package/dist/src/runtime/react/default-ui/LoginForm.d.ts.map +1 -0
  133. package/dist/src/runtime/react/default-ui/LoginForm.js +58 -0
  134. package/dist/src/runtime/react/default-ui/LoginForm.js.map +1 -0
  135. package/dist/src/runtime/react/default-ui/LoginView.d.ts +6 -0
  136. package/dist/src/runtime/react/default-ui/LoginView.d.ts.map +1 -0
  137. package/dist/src/runtime/react/default-ui/LoginView.js +8 -0
  138. package/dist/src/runtime/react/default-ui/LoginView.js.map +1 -0
  139. package/dist/src/runtime/react/default-ui/SignupView.d.ts +2 -0
  140. package/dist/src/runtime/react/default-ui/SignupView.d.ts.map +1 -0
  141. package/dist/src/runtime/react/default-ui/SignupView.js +5 -0
  142. package/dist/src/runtime/react/default-ui/SignupView.js.map +1 -0
  143. package/dist/src/runtime/react/default-ui/index.d.ts +6 -0
  144. package/dist/src/runtime/react/default-ui/index.d.ts.map +1 -0
  145. package/dist/src/runtime/react/default-ui/index.js +6 -0
  146. package/dist/src/runtime/react/default-ui/index.js.map +1 -0
  147. package/dist/src/runtime/react/index.d.ts +5 -0
  148. package/dist/src/runtime/react/index.d.ts.map +1 -0
  149. package/dist/src/runtime/react/index.js +5 -0
  150. package/dist/src/runtime/react/index.js.map +1 -0
  151. package/dist/src/runtime/routes.d.ts +19 -0
  152. package/dist/src/runtime/routes.d.ts.map +1 -0
  153. package/dist/src/runtime/routes.js +33 -0
  154. package/dist/src/runtime/routes.js.map +1 -0
  155. package/dist/src/runtime/schemas.d.ts +299 -0
  156. package/dist/src/runtime/schemas.d.ts.map +1 -0
  157. package/dist/src/runtime/schemas.js +184 -0
  158. package/dist/src/runtime/schemas.js.map +1 -0
  159. package/dist/src/runtime/tokenStore.d.ts +5 -0
  160. package/dist/src/runtime/tokenStore.d.ts.map +1 -0
  161. package/dist/src/runtime/tokenStore.js +20 -0
  162. package/dist/src/runtime/tokenStore.js.map +1 -0
  163. package/package.json +82 -0
  164. package/registry/r/account-dashboard.json +21 -0
  165. package/registry/r/activity-bar-chart.json +21 -0
  166. package/registry/r/admin-users-panel.json +24 -0
  167. package/registry/r/api-keys-panel.json +21 -0
  168. package/registry/r/dashboard-overview.json +20 -0
  169. package/registry/r/data-table.json +23 -0
  170. package/registry/r/profile-panel.json +21 -0
  171. package/registry/r/registry.json +55 -0
  172. package/registry/r/sessions-panel.json +22 -0
  173. package/registry.json +132 -0
  174. package/src/routes/account.astro +8 -0
  175. package/src/routes/callback.astro +5 -0
  176. package/src/routes/login.astro +8 -0
  177. package/src/routes/logout.astro +18 -0
  178. package/src/routes/signup.astro +5 -0
  179. package/src/scaffold/styles/auth.css +49 -0
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "activity-bar-chart",
4
+ "type": "registry:component",
5
+ "title": "Activity Bar Chart",
6
+ "description": "shadcn chart preset (recharts) for fa-auth per-model added/updated activity.",
7
+ "dependencies": [
8
+ "recharts"
9
+ ],
10
+ "registryDependencies": [
11
+ "chart"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "registry/blocks/chart/activity-bar-chart.tsx",
16
+ "content": "\"use client\";\n\n// Pure-shadcn bar chart preset (recharts-backed) for fa-auth dashboard activity:\n// per-model `added` vs `updated` counts. Copied into the consumer via the\n// @fa-m8-auth registry; edit freely per app.\nimport { Bar, BarChart, CartesianGrid, XAxis, YAxis } from \"recharts\";\n\nimport {\n type ChartConfig,\n ChartContainer,\n ChartLegend,\n ChartLegendContent,\n ChartTooltip,\n ChartTooltipContent,\n} from \"@/components/ui/chart\";\n\nexport interface ActivityDatum {\n model: string;\n added: number;\n updated: number;\n}\n\nexport interface ActivityBarChartProps {\n data: ActivityDatum[];\n addedLabel?: string;\n updatedLabel?: string;\n className?: string;\n}\n\nexport function ActivityBarChart({\n data,\n addedLabel = \"Added\",\n updatedLabel = \"Updated\",\n className,\n}: ActivityBarChartProps) {\n const chartConfig = {\n added: { label: addedLabel, color: \"var(--chart-1)\" },\n updated: { label: updatedLabel, color: \"var(--chart-2)\" },\n } satisfies ChartConfig;\n\n return (\n <ChartContainer config={chartConfig} className={className}>\n <BarChart accessibilityLayer data={data}>\n <CartesianGrid vertical={false} />\n <XAxis\n dataKey=\"model\"\n tickLine={false}\n tickMargin={10}\n axisLine={false}\n />\n <YAxis tickLine={false} axisLine={false} allowDecimals={false} width={32} />\n <ChartTooltip content={<ChartTooltipContent />} />\n <ChartLegend content={<ChartLegendContent />} />\n <Bar dataKey=\"added\" fill=\"var(--color-added)\" radius={4} />\n <Bar dataKey=\"updated\" fill=\"var(--color-updated)\" radius={4} />\n </BarChart>\n </ChartContainer>\n );\n}\n",
17
+ "type": "registry:component",
18
+ "target": "components/fa-auth/activity-bar-chart.tsx"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "admin-users-panel",
4
+ "type": "registry:component",
5
+ "title": "Admin Users Panel",
6
+ "description": "fa-auth superuser-only user management (create/update/delete), gated by the package's RequireRole and driven by useUsers. Requires @fa-m8/astro-auth-m8 installed.",
7
+ "dependencies": [
8
+ "lucide-react"
9
+ ],
10
+ "registryDependencies": [
11
+ "card",
12
+ "button",
13
+ "input",
14
+ "label"
15
+ ],
16
+ "files": [
17
+ {
18
+ "path": "registry/blocks/account/admin-users-panel.tsx",
19
+ "content": "\"use client\";\n\n// fa-auth admin users panel: superuser-only user management (create / update /\n// delete). Headless logic stays a live dependency — `useUsers`\n// (@fa-m8/astro-auth-m8/hooks) owns the API calls, the package Zod schemas\n// validate the forms, and the package's `RequireRole superuser` gates the whole\n// panel. This file is only the shadcn skin, copied into the consumer via the\n// @fa-m8-auth registry — edit (and translate via `labels`) freely per app.\nimport * as React from \"react\";\nimport { RefreshCw, Trash2 } from \"lucide-react\";\nimport { RequireRole } from \"@fa-m8/astro-auth-m8/react\";\nimport { useUsers } from \"@fa-m8/astro-auth-m8/hooks\";\nimport { RoleTypeSchema, UserCreateSchema, UserUpdateSchema } from \"@fa-m8/astro-auth-m8/schemas\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\n\nexport interface AdminUsersPanelLabels {\n title: string;\n description: string;\n updateScope: string;\n invalidCreate: string;\n invalidUpdate: string;\n created: string;\n updated: string;\n createFailed: string;\n updateFailed: string;\n email: string;\n fullName: string;\n avatar: string;\n avatarPlaceholder: string;\n password: string;\n passwordPlaceholder: string;\n passwordUnsupported: string;\n create: string;\n role: string;\n emailVerified: string;\n superuser: string;\n users: string;\n refresh: string;\n loading: string;\n user: string;\n provider: string;\n providerPassword: string;\n providerGoogle: string;\n actions: string;\n active: string;\n inactive: string;\n save: string;\n delete: string;\n}\n\nconst DEFAULT_LABELS: AdminUsersPanelLabels = {\n title: \"Admin users\",\n description: \"Superuser-only user management.\",\n updateScope:\n \"User updates support email, full name, avatar, password, and role. Provider, account status, and verification flags are managed by the auth service.\",\n invalidCreate: \"Invalid user payload.\",\n invalidUpdate: \"Invalid update payload.\",\n created: \"User created.\",\n updated: \"User updated.\",\n createFailed: \"Failed to create user.\",\n updateFailed: \"Failed to update user.\",\n email: \"Email\",\n fullName: \"Full name\",\n avatar: \"Avatar URL\",\n avatarPlaceholder: \"https://example.com/avatar.png\",\n password: \"Password\",\n passwordPlaceholder: \"Leave blank to keep current password\",\n passwordUnsupported: \"Password disabled for Google users\",\n create: \"Create\",\n role: \"Role\",\n emailVerified: \"Email verified\",\n superuser: \"Superuser\",\n users: \"users\",\n refresh: \"Refresh\",\n loading: \"Loading users...\",\n user: \"User\",\n provider: \"Provider\",\n providerPassword: \"Password\",\n providerGoogle: \"Google\",\n actions: \"Actions\",\n active: \"Active\",\n inactive: \"Inactive\",\n save: \"Save\",\n delete: \"Delete\",\n};\n\nfunction formString(formData: FormData, key: string): string | undefined {\n const value = formData.get(key);\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nconst inputClassName =\n \"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40\";\n\nfunction AdminUsersPanelInner({ t }: { t: AdminUsersPanelLabels }) {\n const { users: usersData, loading, error, reload, create, update, remove } = useUsers(false);\n const users = usersData?.data ?? [];\n const count = usersData?.count ?? 0;\n const errorText = error instanceof Error ? error.message : error ? String(error) : null;\n const [message, setMessage] = React.useState<string | null>(null);\n\n React.useEffect(() => {\n reload().catch(() => {});\n }, [reload]);\n\n const handleCreate = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n setMessage(null);\n\n const form = event.currentTarget;\n const formData = new FormData(form);\n const role = formString(formData, \"role\");\n // Superadmins create password-based accounts only; OAuth credentials and the\n // email_verified flag are owned by the auth service's internal sign-in flow.\n const parsed = UserCreateSchema.safeParse({\n email: formString(formData, \"email\"),\n password: formString(formData, \"password\"),\n full_name: formString(formData, \"full_name\"),\n avatar: formString(formData, \"avatar\"),\n provider: \"password\",\n role: role ? RoleTypeSchema.parse(role) : \"user\",\n is_active: formData.get(\"is_active\") === \"on\",\n is_superuser: formData.get(\"is_superuser\") === \"on\",\n });\n\n if (!parsed.success) {\n setMessage(parsed.error.issues[0]?.message ?? t.invalidCreate);\n return;\n }\n\n try {\n await create(parsed.data);\n await reload();\n form.reset();\n setMessage(t.created);\n } catch (err) {\n setMessage(err instanceof Error ? err.message : t.createFailed);\n }\n };\n\n const handleUpdate = async (event: React.FormEvent<HTMLFormElement>, id: string) => {\n event.preventDefault();\n setMessage(null);\n\n const formData = new FormData(event.currentTarget);\n // Provider and OAuth user ID are owned by the auth service and not editable here.\n const parsed = UserUpdateSchema.safeParse({\n email: formString(formData, \"email\"),\n full_name: formString(formData, \"full_name\"),\n avatar: formString(formData, \"avatar\"),\n password: formString(formData, \"password\"),\n role: formString(formData, \"role\"),\n });\n\n if (!parsed.success) {\n setMessage(parsed.error.issues[0]?.message ?? t.invalidUpdate);\n return;\n }\n\n try {\n await update(id, parsed.data);\n await reload();\n setMessage(t.updated);\n } catch (err) {\n setMessage(err instanceof Error ? err.message : t.updateFailed);\n }\n };\n\n return (\n <Card className=\"not-content\">\n <CardHeader>\n <CardTitle>{t.title}</CardTitle>\n <CardDescription>{t.description}</CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-6\">\n <p className=\"text-sm text-muted-foreground\">\n {t.updateScope}\n </p>\n <form onSubmit={handleCreate} className=\"grid gap-3 md:grid-cols-2 xl:grid-cols-4 md:items-end\">\n <div className=\"space-y-1\">\n <Label htmlFor=\"admin-create-email\" className=\"pb-2\">{t.email}</Label>\n <Input id=\"admin-create-email\" name=\"email\" type=\"email\" required />\n </div>\n <div className=\"space-y-1\">\n <Label htmlFor=\"admin-create-name\" className=\"pb-2\">{t.fullName}</Label>\n <Input id=\"admin-create-name\" name=\"full_name\" />\n </div>\n <div className=\"space-y-1\">\n <Label htmlFor=\"admin-create-avatar\" className=\"pb-2\">{t.avatar}</Label>\n <Input id=\"admin-create-avatar\" name=\"avatar\" type=\"url\" placeholder={t.avatarPlaceholder} />\n </div>\n <div className=\"space-y-1\">\n <Label htmlFor=\"admin-create-password\" className=\"pb-2\">{t.password}</Label>\n <Input id=\"admin-create-password\" name=\"password\" type=\"password\" minLength={8} required />\n </div>\n <div className=\"space-y-1\">\n <Label htmlFor=\"admin-create-role\" className=\"pb-2\">{t.role}</Label>\n <select id=\"admin-create-role\" name=\"role\" defaultValue=\"user\" className={inputClassName}>\n {RoleTypeSchema.options.map((role) => <option key={role} value={role}>{role}</option>)}\n </select>\n </div>\n <label className=\"flex items-center gap-2 pb-2 text-sm\">\n <input name=\"is_active\" type=\"checkbox\" defaultChecked className=\"size-4\" />\n {t.active}\n </label>\n <label className=\"flex items-center gap-2 pb-2 text-sm\">\n <input name=\"is_superuser\" type=\"checkbox\" className=\"size-4\" />\n {t.superuser}\n </label>\n <Button type=\"submit\">{t.create}</Button>\n </form>\n\n <div className=\"flex items-center justify-between gap-3\">\n <p className=\"text-sm text-muted-foreground\">{count} {t.users}</p>\n <Button type=\"button\" size=\"sm\" variant=\"outline\" onClick={() => reload()}>\n <RefreshCw />\n {t.refresh}\n </Button>\n </div>\n\n {(message || errorText) && (\n <p className=\"rounded-md border p-3 text-sm\">{message ?? errorText}</p>\n )}\n\n {loading && users.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">{t.loading}</p>\n ) : (\n <div className=\"overflow-x-auto rounded-md border\">\n <table className=\"w-full min-w-[760px] text-left text-sm\">\n <thead className=\"border-b bg-muted/40 text-muted-foreground\">\n <tr>\n <th className=\"px-3 py-2 font-medium\">{t.user}</th>\n <th className=\"px-3 py-2 font-medium\">{t.role}</th>\n <th className=\"px-3 py-2 font-medium\">{t.provider}</th>\n <th className=\"px-3 py-2 font-medium\">{t.actions}</th>\n </tr>\n </thead>\n <tbody className=\"divide-y\">\n {users.map((user) => (\n <tr key={user.id}>\n <td className=\"px-3 py-3 align-top\">\n <form id={`admin-user-${user.id}`} onSubmit={(event) => handleUpdate(event, user.id)} className=\"grid gap-2\">\n <Input name=\"email\" type=\"email\" defaultValue={user.email} required />\n <Input name=\"full_name\" defaultValue={user.full_name ?? \"\"} placeholder={t.fullName} />\n <Input name=\"avatar\" type=\"url\" defaultValue={user.avatar ?? \"\"} placeholder={t.avatarPlaceholder} />\n <Input\n name=\"password\"\n type=\"password\"\n placeholder={user.provider === \"password\" ? t.passwordPlaceholder : t.passwordUnsupported}\n disabled={user.provider === \"google\"}\n />\n </form>\n </td>\n <td className=\"px-3 py-3 align-top\">\n <select name=\"role\" form={`admin-user-${user.id}`} defaultValue={user.role} className={inputClassName}>\n {RoleTypeSchema.options.map((role) => <option key={role} value={role}>{role}</option>)}\n </select>\n </td>\n <td className=\"px-3 py-3 align-top\">\n <span className=\"inline-flex h-8 items-center rounded-md border bg-muted/40 px-2 text-sm capitalize\">\n {user.provider === \"google\" ? t.providerGoogle : t.providerPassword}\n </span>\n <p className=\"mt-2 text-xs text-muted-foreground\">\n {user.is_active ? t.active : t.inactive}\n {user.email_verified ? ` - ${t.emailVerified}` : \"\"}\n {user.is_superuser ? ` - ${t.superuser}` : \"\"}\n </p>\n </td>\n <td className=\"px-3 py-3 align-top\">\n <div className=\"flex gap-2\">\n <Button type=\"submit\" form={`admin-user-${user.id}`} size=\"sm\">{t.save}</Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"destructive\"\n onClick={async () => {\n await remove(user.id);\n await reload();\n }}\n >\n <Trash2 />\n {t.delete}\n </Button>\n </div>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n\nexport function AdminUsersPanel({ labels }: { labels?: Partial<AdminUsersPanelLabels> }) {\n const t = { ...DEFAULT_LABELS, ...labels };\n // Superuser-only: gate the whole panel via the package's RequireRole so the\n // privileged API calls never mount for non-superusers, even if a consumer\n // renders it unconditionally.\n return (\n <RequireRole superuser>\n <AdminUsersPanelInner t={t} />\n </RequireRole>\n );\n}\n",
20
+ "type": "registry:component",
21
+ "target": "components/fa-auth/admin-users-panel.tsx"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "api-keys-panel",
4
+ "type": "registry:component",
5
+ "title": "Account API Keys Panel",
6
+ "description": "fa-auth API token mint/revoke panel driven by the package's useApiKeys hook. Requires @fa-m8/astro-auth-m8 installed.",
7
+ "registryDependencies": [
8
+ "card",
9
+ "button",
10
+ "input",
11
+ "label"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "registry/blocks/account/api-keys-panel.tsx",
16
+ "content": "\"use client\";\n\n// fa-auth API keys panel: mint and revoke programmatic API tokens. Headless\n// logic stays a live dependency — `useApiKeys` (@fa-m8/astro-auth-m8/hooks) owns\n// the list/create/revoke calls and the package Zod schema validates the form.\n// This file is only the shadcn skin, copied into the consumer via the\n// @fa-m8-auth registry — edit (and translate via `labels`) freely per app.\nimport * as React from \"react\";\nimport { useApiKeys } from \"@fa-m8/astro-auth-m8/hooks\";\nimport { ApiKeyCreateSchema } from \"@fa-m8/astro-auth-m8/schemas\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\n\nexport interface ApiKeysPanelLabels {\n createTitle: string;\n createDescription: string;\n name: string;\n namePlaceholder: string;\n ttl: string;\n ttlUnit: string;\n unitHours: string;\n unitDays: string;\n unitWeeks: string;\n defaultName: string;\n generating: string;\n mint: string;\n securityNotice: string;\n copied: string;\n copy: string;\n activeTitle: string;\n loading: string;\n empty: string;\n active: string;\n revoked: string;\n expires: string;\n lastUsed: string;\n notUsed: string;\n notAvailable: string;\n revoke: string;\n}\n\nconst DEFAULT_LABELS: ApiKeysPanelLabels = {\n createTitle: \"Create API token\",\n createDescription: \"Provision programmatic client identifiers for remote integrations.\",\n name: \"Token name\",\n namePlaceholder: \"e.g. CI/CD deployment server\",\n ttl: \"Validity\",\n ttlUnit: \"Unit\",\n unitHours: \"Hours\",\n unitDays: \"Days\",\n unitWeeks: \"Weeks\",\n defaultName: \"Default key\",\n generating: \"Generating...\",\n mint: \"Mint new key\",\n securityNotice: \"Security notice: copy this API key now. It will not be shown again.\",\n copied: \"Copied\",\n copy: \"Copy\",\n activeTitle: \"Active credentials\",\n loading: \"Loading API tokens...\",\n empty: \"No active API tokens found.\",\n active: \"Active\",\n revoked: \"Revoked\",\n expires: \"Expires\",\n lastUsed: \"Last used\",\n notUsed: \"Never used\",\n notAvailable: \"n/a\",\n revoke: \"Revoke token\",\n};\n\n// Backend currently accepts whole-hour TTLs only; sub-hour units need an auth-API change.\nconst TTL_UNIT_HOURS = { hours: 1, days: 24, weeks: 168 } as const;\ntype TtlUnit = keyof typeof TTL_UNIT_HOURS;\nconst inputClassName =\n \"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40\";\n\nexport function ApiKeysPanel({ labels }: { labels?: Partial<ApiKeysPanelLabels> }) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const { apiKeys: keys, loading, reload, create, createdKey: lastCreated, revoke } = useApiKeys(false);\n const [isCreating, setIsCreating] = React.useState(false);\n const [copied, setCopied] = React.useState(false);\n\n React.useEffect(() => {\n reload().catch(() => {});\n }, [reload]);\n\n const handleCreateToken = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n setCopied(false);\n const form = e.currentTarget;\n const formData = new FormData(form);\n\n const amount = Number(formData.get(\"ttl_amount\")) || 1;\n const unit = (formData.get(\"ttl_unit\")?.toString() as TtlUnit) || \"days\";\n const ttl_hours = Math.max(1, Math.round(amount * (TTL_UNIT_HOURS[unit] ?? 24)));\n\n const parsedData = ApiKeyCreateSchema.parse({\n name: formData.get(\"name\")?.toString() || t.defaultName,\n ttl_hours,\n });\n\n setIsCreating(true);\n try {\n await create(parsedData);\n form.reset();\n } finally {\n setIsCreating(false);\n }\n };\n\n const handleCopy = (text: string) => {\n navigator.clipboard.writeText(text);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n return (\n <div className=\"not-content space-y-6\">\n <Card>\n <CardHeader>\n <CardTitle>{t.createTitle}</CardTitle>\n <CardDescription>{t.createDescription}</CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={handleCreateToken} className=\"flex flex-wrap items-end gap-4\">\n <div className=\"flex-1 min-w-[200px] space-y-1\">\n <Label htmlFor=\"name\" className=\"pb-2\">{t.name}</Label>\n <Input id=\"name\" name=\"name\" placeholder={t.namePlaceholder} required />\n </div>\n <div className=\"w-24 space-y-1\">\n <Label htmlFor=\"ttl_amount\" className=\"pb-2\">{t.ttl}</Label>\n <Input id=\"ttl_amount\" name=\"ttl_amount\" type=\"number\" min={1} defaultValue=\"30\" required />\n </div>\n <div className=\"w-32 space-y-1\">\n <Label htmlFor=\"ttl_unit\" className=\"pb-2\">{t.ttlUnit}</Label>\n <select\n id=\"ttl_unit\"\n name=\"ttl_unit\"\n defaultValue=\"days\"\n className={inputClassName}\n >\n <option value=\"hours\">{t.unitHours}</option>\n <option value=\"days\">{t.unitDays}</option>\n <option value=\"weeks\">{t.unitWeeks}</option>\n </select>\n </div>\n <Button type=\"submit\" disabled={isCreating}>\n {isCreating ? t.generating : t.mint}\n </Button>\n </form>\n\n {lastCreated && (\n <div className=\"mt-4 p-4 border border-amber-200 bg-amber-50 rounded-md text-amber-900 space-y-2\">\n <p className=\"text-sm font-bold\">{t.securityNotice}</p>\n <div className=\"flex items-center gap-2 bg-white p-2 rounded border font-mono text-xs overflow-x-auto\">\n <span className=\"flex-1 select-all break-all\">{lastCreated.plaintext}</span>\n <Button size=\"sm\" variant=\"ghost\" onClick={() => handleCopy(lastCreated.plaintext)}>\n {copied ? t.copied : t.copy}\n </Button>\n </div>\n </div>\n )}\n </CardContent>\n </Card>\n\n <Card>\n <CardHeader>\n <CardTitle>{t.activeTitle}</CardTitle>\n </CardHeader>\n <CardContent>\n {loading && keys.length === 0 ? (\n <p className=\"text-sm text-muted-foreground py-2 italic\">{t.loading}</p>\n ) : keys.length === 0 ? (\n <p className=\"text-sm text-muted-foreground py-2 italic\">{t.empty}</p>\n ) : (\n <div className=\"divide-y divide-border\">\n {keys.map((key) => (\n <div key={key.id} className=\"flex items-center justify-between gap-3 py-3\">\n <div className=\"min-w-0\">\n <h4 className=\"text-sm font-semibold\">{key.name}</h4>\n <p className=\"text-xs text-muted-foreground\">\n {t.expires}: {key.expires_at ? new Date(key.expires_at).toLocaleString() : t.notAvailable}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {t.lastUsed}: {key.last_used_at ? new Date(key.last_used_at).toLocaleString() : t.notUsed}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {key.revoked ? t.revoked : t.active}\n </p>\n </div>\n <Button\n size=\"sm\"\n variant=\"destructive\"\n disabled={key.revoked}\n onClick={() => revoke(key.id)}\n >\n {t.revoke}\n </Button>\n </div>\n ))}\n </div>\n )}\n </CardContent>\n </Card>\n </div>\n );\n}\n",
17
+ "type": "registry:component",
18
+ "target": "components/fa-auth/api-keys-panel.tsx"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "dashboard-overview",
4
+ "type": "registry:component",
5
+ "title": "Account Dashboard Overview",
6
+ "description": "fa-auth activity dashboard (stat cards + chart) driven by the package's useDashboard hook. Requires @fa-m8/astro-auth-m8 installed.",
7
+ "registryDependencies": [
8
+ "card",
9
+ "skeleton",
10
+ "./node_modules/@fa-m8/astro-auth-m8/registry/r/activity-bar-chart.json"
11
+ ],
12
+ "files": [
13
+ {
14
+ "path": "registry/blocks/account/dashboard-overview.tsx",
15
+ "content": "\"use client\";\n\n// fa-auth account landing view: an activity dashboard built from the package's\n// headless `useDashboard` hook. Logic stays a live dependency\n// (@fa-m8/astro-auth-m8/hooks); this file is only the shadcn skin and is copied\n// into the consumer via the @fa-m8-auth registry — edit freely per app.\nimport * as React from \"react\";\nimport { Activity, TrendingUp, Users } from \"lucide-react\";\nimport { useDashboard } from \"@fa-m8/astro-auth-m8/hooks\";\n\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { ActivityBarChart } from \"@/components/fa-auth/activity-bar-chart\";\n\nexport interface DashboardOverviewLabels {\n title: string;\n subtitle: string;\n users: string;\n totalAdded: string;\n totalUpdated: string;\n activityTitle: string;\n added: string;\n updated: string;\n empty: string;\n error: string;\n}\n\nconst DEFAULT_LABELS: DashboardOverviewLabels = {\n title: \"Overview\",\n subtitle: \"Account activity at a glance.\",\n users: \"Users\",\n totalAdded: \"Total added\",\n totalUpdated: \"Total updated\",\n activityTitle: \"Activity by model\",\n added: \"Added\",\n updated: \"Updated\",\n empty: \"No activity recorded yet.\",\n error: \"Could not load dashboard activity.\",\n};\n\n/** Scope: \"me\" for the signed-in user, \"global\" for superuser fleet-wide stats. */\nexport interface DashboardOverviewProps {\n scope?: \"me\" | \"global\";\n labels?: Partial<DashboardOverviewLabels>;\n}\n\nfunction StatCard({\n label,\n value,\n icon: Icon,\n}: {\n label: string;\n value: React.ReactNode;\n icon: React.ComponentType<{ className?: string }>;\n}) {\n return (\n <Card className=\"h-full\">\n <CardHeader className=\"flex flex-row items-center justify-between space-y-0 pb-2\">\n <CardTitle className=\"text-sm font-medium text-muted-foreground\">\n {label}\n </CardTitle>\n <Icon className=\"size-4 text-muted-foreground\" />\n </CardHeader>\n <CardContent>\n <div className=\"text-2xl font-semibold tabular-nums\">{value}</div>\n </CardContent>\n </Card>\n );\n}\n\nexport function DashboardOverview({\n scope = \"me\",\n labels,\n}: DashboardOverviewProps) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const { activity, loading, error } = useDashboard(scope);\n\n const counters = activity?.activity.activity ?? [];\n const totals = counters.reduce(\n (acc, row) => ({\n added: acc.added + row.added,\n updated: acc.updated + row.updated,\n }),\n { added: 0, updated: 0 },\n );\n\n if (loading) {\n return (\n <div className=\"not-content space-y-4\" aria-busy=\"true\">\n <div className=\"grid auto-rows-fr gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {[0, 1, 2].map((i) => (\n <Skeleton key={i} className=\"h-28 w-full\" />\n ))}\n </div>\n <Skeleton className=\"h-64 w-full\" />\n </div>\n );\n }\n\n if (error) {\n return (\n <Card role=\"alert\" className=\"border-destructive/50\">\n <CardContent className=\"py-6 text-sm text-destructive\">\n {t.error}\n </CardContent>\n </Card>\n );\n }\n\n return (\n <div className=\"not-content space-y-6\">\n <div className=\"space-y-1\">\n <h2 className=\"text-xl font-semibold tracking-tight\">{t.title}</h2>\n <p className=\"text-sm text-muted-foreground\">{t.subtitle}</p>\n </div>\n\n <div className=\"grid auto-rows-fr gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n <StatCard\n label={t.users}\n value={(activity?.nb_users ?? 0).toLocaleString()}\n icon={Users}\n />\n <StatCard\n label={t.totalAdded}\n value={totals.added.toLocaleString()}\n icon={TrendingUp}\n />\n <StatCard\n label={t.totalUpdated}\n value={totals.updated.toLocaleString()}\n icon={Activity}\n />\n </div>\n\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base\">{t.activityTitle}</CardTitle>\n </CardHeader>\n <CardContent>\n {counters.length ? (\n <ActivityBarChart\n data={counters}\n addedLabel={t.added}\n updatedLabel={t.updated}\n className=\"aspect-auto h-64 w-full\"\n />\n ) : (\n <p className=\"py-8 text-center text-sm text-muted-foreground\">\n {t.empty}\n </p>\n )}\n </CardContent>\n </Card>\n </div>\n );\n}\n",
16
+ "type": "registry:component",
17
+ "target": "components/fa-auth/dashboard-overview.tsx"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "data-table",
4
+ "type": "registry:component",
5
+ "title": "Data Table",
6
+ "description": "Generic pure-shadcn data table (sorting, filtering, pagination) built on @tanstack/react-table.",
7
+ "dependencies": [
8
+ "@tanstack/react-table"
9
+ ],
10
+ "registryDependencies": [
11
+ "table",
12
+ "button",
13
+ "input"
14
+ ],
15
+ "files": [
16
+ {
17
+ "path": "registry/blocks/data-table/data-table.tsx",
18
+ "content": "\"use client\";\n\n// Generic, pure-shadcn data table (sorting + filtering + pagination) built on\n// @tanstack/react-table and the shadcn `table` primitive. Copied into the\n// consumer via the @fa-m8-auth registry; edit freely per app.\nimport * as React from \"react\";\nimport {\n type ColumnDef,\n type ColumnFiltersState,\n type SortingState,\n flexRender,\n getCoreRowModel,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n} from \"@tanstack/react-table\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@/components/ui/table\";\n\nexport interface DataTableProps<TData, TValue> {\n columns: ColumnDef<TData, TValue>[];\n data: TData[];\n /** Column id to wire the search box to; omit to hide the filter input. */\n filterColumn?: string;\n filterPlaceholder?: string;\n /** Page size for client-side pagination. Defaults to 10. */\n pageSize?: number;\n /** Rendered when there are no rows. */\n emptyMessage?: string;\n}\n\nexport function DataTable<TData, TValue>({\n columns,\n data,\n filterColumn,\n filterPlaceholder = \"Filter…\",\n pageSize = 10,\n emptyMessage = \"No results.\",\n}: DataTableProps<TData, TValue>) {\n const [sorting, setSorting] = React.useState<SortingState>([]);\n const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>([]);\n\n const table = useReactTable({\n data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n onSortingChange: setSorting,\n onColumnFiltersChange: setColumnFilters,\n initialState: { pagination: { pageSize } },\n state: { sorting, columnFilters },\n });\n\n const filterCol = filterColumn ? table.getColumn(filterColumn) : undefined;\n\n return (\n <div className=\"space-y-3\">\n {filterCol ? (\n <Input\n value={(filterCol.getFilterValue() as string) ?? \"\"}\n onChange={(event) => filterCol.setFilterValue(event.target.value)}\n placeholder={filterPlaceholder}\n className=\"max-w-sm\"\n aria-label={filterPlaceholder}\n />\n ) : null}\n\n <div className=\"rounded-md border\">\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <TableHead key={header.id}>\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell key={cell.id}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell colSpan={columns.length} className=\"h-24 text-center\">\n {emptyMessage}\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n\n {table.getPageCount() > 1 ? (\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n Previous\n </Button>\n <span className=\"text-sm text-muted-foreground\">\n Page {table.getState().pagination.pageIndex + 1} of{\" \"}\n {table.getPageCount()}\n </span>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n Next\n </Button>\n </div>\n ) : null}\n </div>\n );\n}\n",
19
+ "type": "registry:component",
20
+ "target": "components/fa-auth/data-table.tsx"
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "profile-panel",
4
+ "type": "registry:component",
5
+ "title": "Account Profile Panel",
6
+ "description": "fa-auth profile editor (metadata + password rotation) driven by the package's useAuth + useProfile hooks. Requires @fa-m8/astro-auth-m8 installed.",
7
+ "registryDependencies": [
8
+ "card",
9
+ "button",
10
+ "input",
11
+ "label"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "registry/blocks/account/profile-panel.tsx",
16
+ "content": "\"use client\";\n\n// fa-auth profile panel: edit public profile metadata + rotate password.\n// Headless logic stays a live dependency — `useAuth` (@fa-m8/astro-auth-m8/react)\n// supplies the signed-in user + reload, `useProfile` (@fa-m8/astro-auth-m8/hooks)\n// performs the writes, and the package Zod schemas validate the form. This file\n// is only the shadcn skin and is copied into the consumer via the @fa-m8-auth\n// registry — edit (and translate via `labels`) freely per app.\nimport * as React from \"react\";\nimport { useAuth } from \"@fa-m8/astro-auth-m8/react\";\nimport { useProfile } from \"@fa-m8/astro-auth-m8/hooks\";\nimport { UserUpdateMeSchema, UpdatePasswordSchema } from \"@fa-m8/astro-auth-m8/schemas\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\n\nexport interface ProfilePanelLabels {\n title: string;\n description: string;\n saved: string;\n failed: string;\n email: string;\n emailReadOnly: string;\n fullName: string;\n avatar: string;\n avatarPlaceholder: string;\n saving: string;\n submit: string;\n passwordTitle: string;\n passwordDescription: string;\n googlePasswordDisabled: string;\n credentialsRotated: string;\n passwordFailed: string;\n currentPassword: string;\n newPassword: string;\n changePassword: string;\n incorrectPasswordError: string;\n samePasswordError: string;\n}\n\nconst DEFAULT_LABELS: ProfilePanelLabels = {\n title: \"Profile details\",\n description: \"Update your public profile metadata.\",\n saved: \"Profile saved.\",\n failed: \"Failed to update profile.\",\n email: \"Email address\",\n emailReadOnly: \"Email is managed by the auth service and cannot be changed here.\",\n fullName: \"Full name\",\n avatar: \"Avatar URL\",\n avatarPlaceholder: \"https://example.com/avatar.png\",\n saving: \"Saving...\",\n submit: \"Update details\",\n passwordTitle: \"Password management\",\n passwordDescription: \"Rotate your authentication credentials securely.\",\n googlePasswordDisabled:\n \"Your account is integrated via Google SSO. Password changes are disabled.\",\n credentialsRotated: \"Credentials rotated.\",\n passwordFailed: \"Failed to alter security credentials.\",\n currentPassword: \"Current password\",\n newPassword: \"New password\",\n changePassword: \"Change password\",\n incorrectPasswordError: \"The current password you entered is incorrect.\",\n samePasswordError: \"The new password must be different from your current one.\",\n};\n\nfunction errorMessage(err: unknown, fallback: string): string {\n return err instanceof Error && err.message ? err.message : fallback;\n}\n\n/** Map known backend (English) auth messages to the active locale, falling back to the raw message. */\nfunction translatePasswordError(err: unknown, t: ProfilePanelLabels): string {\n const raw = errorMessage(err, t.passwordFailed);\n const known: Record<string, string> = {\n \"Incorrect password\": t.incorrectPasswordError,\n \"New password cannot be the same as the current one\": t.samePasswordError,\n };\n return known[raw] ?? raw;\n}\n\nexport function ProfilePanel({ labels }: { labels?: Partial<ProfilePanelLabels> }) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const { user, reload } = useAuth();\n const { save, changePassword } = useProfile(false);\n\n const [isUpdating, setIsUpdating] = React.useState(false);\n const [profileSuccess, setProfileSuccess] = React.useState(false);\n const [passSuccess, setPassSuccess] = React.useState(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n\n const handleUpdateProfile = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n setErrors({});\n setProfileSuccess(false);\n\n const formData = new FormData(e.currentTarget);\n // Email is not editable here; optional fields submit as null when left blank\n // so an empty avatar clears the value instead of failing URL validation.\n const result = UserUpdateMeSchema.safeParse({\n full_name: formData.get(\"full_name\")?.toString().trim() || null,\n avatar: formData.get(\"avatar\")?.toString().trim() || null,\n });\n if (!result.success) {\n result.error.issues.forEach((i) => setErrors((prev) => ({ ...prev, [i.path[0]]: i.message })));\n return;\n }\n\n setIsUpdating(true);\n try {\n await save(result.data);\n await reload();\n setProfileSuccess(true);\n } catch (err) {\n setErrors({ profileApi: errorMessage(err, t.failed) });\n } finally {\n setIsUpdating(false);\n }\n };\n\n const handleChangePassword = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n setErrors({});\n setPassSuccess(false);\n\n const form = e.currentTarget;\n const formData = new FormData(form);\n const rawData = Object.fromEntries(formData);\n\n const result = UpdatePasswordSchema.safeParse(rawData);\n if (!result.success) {\n result.error.issues.forEach((i) => setErrors((prev) => ({ ...prev, [i.path[0]]: i.message })));\n return;\n }\n\n try {\n await changePassword(result.data);\n setPassSuccess(true);\n form.reset();\n } catch (err) {\n setErrors({ passApi: translatePasswordError(err, t) });\n }\n };\n\n if (!user) return null;\n\n return (\n <div className=\"not-content grid auto-rows-fr gap-6 md:grid-cols-2\">\n {/* Profile metadata form */}\n <Card className=\"h-full\">\n <CardHeader>\n <CardTitle>{t.title}</CardTitle>\n <CardDescription>{t.description}</CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={handleUpdateProfile} className=\"space-y-4\">\n {profileSuccess && <div className=\"p-2 text-sm text-emerald-600 bg-emerald-50 rounded\">{t.saved}</div>}\n {errors.profileApi && <div className=\"p-2 text-sm text-destructive bg-destructive/10 rounded\">{errors.profileApi}</div>}\n\n <div className=\"space-y-1\">\n <Label htmlFor=\"email\" className=\"pb-2\">{t.email}</Label>\n <Input id=\"email\" value={user.email} type=\"email\" readOnly disabled aria-readonly=\"true\" />\n <p className=\"text-xs text-muted-foreground\">{t.emailReadOnly}</p>\n </div>\n\n <div className=\"space-y-1\">\n <Label htmlFor=\"full_name\" className=\"pb-2\">{t.fullName}</Label>\n <Input id=\"full_name\" name=\"full_name\" defaultValue={user.full_name || \"\"} />\n </div>\n\n <div className=\"space-y-1\">\n <Label htmlFor=\"avatar\" className=\"pb-2\">{t.avatar}</Label>\n <Input\n id=\"avatar\"\n name=\"avatar\"\n type=\"url\"\n defaultValue={user.avatar || \"\"}\n placeholder={t.avatarPlaceholder}\n />\n {errors.avatar && <p className=\"text-xs text-destructive\">{errors.avatar}</p>}\n </div>\n\n <Button type=\"submit\" disabled={isUpdating}>\n {isUpdating ? t.saving : t.submit}\n </Button>\n </form>\n </CardContent>\n </Card>\n\n {/* Password rotation (hidden for OAuth-provisioned accounts) */}\n <Card className=\"h-full\">\n <CardHeader>\n <CardTitle>{t.passwordTitle}</CardTitle>\n <CardDescription>{t.passwordDescription}</CardDescription>\n </CardHeader>\n <CardContent>\n {user.provider === \"google\" ? (\n <p className=\"text-sm text-muted-foreground italic pt-4\">\n {t.googlePasswordDisabled}\n </p>\n ) : (\n <form onSubmit={handleChangePassword} className=\"space-y-4\">\n {passSuccess && <div className=\"p-2 text-sm text-emerald-600 bg-emerald-50 rounded\">{t.credentialsRotated}</div>}\n {errors.passApi && <div className=\"p-2 text-sm text-destructive bg-destructive/10 rounded\">{errors.passApi}</div>}\n\n <div className=\"space-y-1\">\n <Label htmlFor=\"current_password\" className=\"pb-2\">{t.currentPassword}</Label>\n <Input id=\"current_password\" name=\"current_password\" type=\"password\" required />\n </div>\n\n <div className=\"space-y-1\">\n <Label htmlFor=\"new_password\" className=\"pb-2\">{t.newPassword}</Label>\n <Input id=\"new_password\" name=\"new_password\" type=\"password\" required />\n {errors.new_password && <p className=\"text-xs text-destructive\">{errors.new_password}</p>}\n </div>\n\n <Button type=\"submit\" variant=\"secondary\">{t.changePassword}</Button>\n </form>\n )}\n </CardContent>\n </Card>\n </div>\n );\n}\n",
17
+ "type": "registry:component",
18
+ "target": "components/fa-auth/profile-panel.tsx"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry.json",
3
+ "name": "fa-m8-auth",
4
+ "homepage": "https://github.com/mano8/astro-auth-m8",
5
+ "items": [
6
+ {
7
+ "name": "data-table",
8
+ "type": "registry:component",
9
+ "title": "Data Table",
10
+ "description": "Generic pure-shadcn data table (sorting, filtering, pagination) built on @tanstack/react-table."
11
+ },
12
+ {
13
+ "name": "activity-bar-chart",
14
+ "type": "registry:component",
15
+ "title": "Activity Bar Chart",
16
+ "description": "shadcn chart preset (recharts) for fa-auth per-model added/updated activity."
17
+ },
18
+ {
19
+ "name": "dashboard-overview",
20
+ "type": "registry:component",
21
+ "title": "Account Dashboard Overview",
22
+ "description": "fa-auth activity dashboard (stat cards + chart) driven by the package's useDashboard hook. Requires @fa-m8/astro-auth-m8 installed."
23
+ },
24
+ {
25
+ "name": "account-dashboard",
26
+ "type": "registry:component",
27
+ "title": "Account Dashboard",
28
+ "description": "fa-auth account view whose first/landing tab is the activity dashboard; secondary tabs are wired by the consumer. Requires @fa-m8/astro-auth-m8 installed."
29
+ },
30
+ {
31
+ "name": "profile-panel",
32
+ "type": "registry:component",
33
+ "title": "Account Profile Panel",
34
+ "description": "fa-auth profile editor (metadata + password rotation) driven by the package's useAuth + useProfile hooks. Requires @fa-m8/astro-auth-m8 installed."
35
+ },
36
+ {
37
+ "name": "sessions-panel",
38
+ "type": "registry:component",
39
+ "title": "Account Sessions Panel",
40
+ "description": "fa-auth session details + activity summaries with superuser-only session revocation, driven by the package's useSessions + useDashboard hooks. Requires @fa-m8/astro-auth-m8 installed."
41
+ },
42
+ {
43
+ "name": "api-keys-panel",
44
+ "type": "registry:component",
45
+ "title": "Account API Keys Panel",
46
+ "description": "fa-auth API token mint/revoke panel driven by the package's useApiKeys hook. Requires @fa-m8/astro-auth-m8 installed."
47
+ },
48
+ {
49
+ "name": "admin-users-panel",
50
+ "type": "registry:component",
51
+ "title": "Admin Users Panel",
52
+ "description": "fa-auth superuser-only user management (create/update/delete), gated by the package's RequireRole and driven by useUsers. Requires @fa-m8/astro-auth-m8 installed."
53
+ }
54
+ ]
55
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "sessions-panel",
4
+ "type": "registry:component",
5
+ "title": "Account Sessions Panel",
6
+ "description": "fa-auth session details + activity summaries with superuser-only session revocation, driven by the package's useSessions + useDashboard hooks. Requires @fa-m8/astro-auth-m8 installed.",
7
+ "dependencies": [
8
+ "lucide-react"
9
+ ],
10
+ "registryDependencies": [
11
+ "card",
12
+ "button"
13
+ ],
14
+ "files": [
15
+ {
16
+ "path": "registry/blocks/account/sessions-panel.tsx",
17
+ "content": "\"use client\";\n\n// fa-auth sessions panel: current session details + your/all activity summaries,\n// with superuser-only session revocation. Headless logic stays a live dependency\n// — `useAuth` (@fa-m8/astro-auth-m8/react) supplies the user, `useSessions` and\n// `useDashboard` (@fa-m8/astro-auth-m8/hooks) supply the data. This file is only\n// the shadcn skin, copied into the consumer via the @fa-m8-auth registry — edit\n// (and translate via `labels`) freely per app.\nimport * as React from \"react\";\nimport { RefreshCw, Trash2 } from \"lucide-react\";\nimport { useAuth } from \"@fa-m8/astro-auth-m8/react\";\nimport { useSessions, useDashboard } from \"@fa-m8/astro-auth-m8/hooks\";\nimport type { UsersActivity } from \"@fa-m8/astro-auth-m8/schemas\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\n\nexport interface SessionsPanelLabels {\n notAvailable: string;\n logins: string;\n registrations: string;\n users: string;\n title: string;\n description: string;\n provider: string;\n jwtExpires: string;\n refreshExpires: string;\n notLoaded: string;\n yourActivity: string;\n refresh: string;\n adminTitle: string;\n adminDescription: string;\n allActivity: string;\n loading: string;\n empty: string;\n expires: string;\n revoke: string;\n}\n\nconst DEFAULT_LABELS: SessionsPanelLabels = {\n notAvailable: \"n/a\",\n logins: \"Logins\",\n registrations: \"Registrations\",\n users: \"Users\",\n title: \"Session\",\n description: \"Current authentication session and account activity.\",\n provider: \"Provider\",\n jwtExpires: \"JWT expires\",\n refreshExpires: \"Refresh expires\",\n notLoaded: \"Session details are not loaded.\",\n yourActivity: \"Your activity\",\n refresh: \"Refresh\",\n adminTitle: \"Admin sessions\",\n adminDescription: \"Superuser-only session overview.\",\n allActivity: \"All activity\",\n loading: \"Loading sessions...\",\n empty: \"No sessions returned.\",\n expires: \"Expires\",\n revoke: \"Revoke\",\n};\n\nfunction formatDate(value: string | null | undefined, fallback: string): string {\n if (!value) return fallback;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? value : date.toLocaleString();\n}\n\nfunction ActivitySummary({\n title,\n totalLogins,\n totalRegistrations,\n totalUsers,\n t,\n}: {\n title: string;\n totalLogins?: number;\n totalRegistrations?: number;\n totalUsers?: number;\n t: SessionsPanelLabels;\n}) {\n return (\n <div className=\"rounded-md border p-3\">\n <h4 className=\"text-sm font-semibold\">{title}</h4>\n <dl className=\"mt-3 grid grid-cols-3 gap-3 text-sm\">\n <div>\n <dt className=\"text-muted-foreground\">{t.logins}</dt>\n <dd className=\"font-medium\">{totalLogins ?? \"-\"}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t.registrations}</dt>\n <dd className=\"font-medium\">{totalRegistrations ?? \"-\"}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t.users}</dt>\n <dd className=\"font-medium\">{totalUsers ?? \"-\"}</dd>\n </div>\n </dl>\n </div>\n );\n}\n\nfunction activityAdded(stats: UsersActivity | null, model: string): number | undefined {\n return stats?.activity.activity.find((entry) => entry.model === model)?.added;\n}\n\nexport function SessionsPanel({ labels }: { labels?: Partial<SessionsPanelLabels> }) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const { user } = useAuth();\n const isSuperuser = user?.is_superuser ?? false;\n\n const { current, reloadCurrent, sessions, reload: list, revoke, loading } = useSessions(false);\n const { activity: mine, reload: reloadMine } = useDashboard(\"me\", false);\n const { activity: all, reload: reloadAll } = useDashboard(\"global\", false);\n\n const rows = sessions?.data ?? [];\n\n React.useEffect(() => {\n reloadCurrent().catch(() => {});\n reloadMine().catch(() => {});\n }, [reloadCurrent, reloadMine]);\n\n React.useEffect(() => {\n if (!isSuperuser) return;\n list().catch(() => {});\n reloadAll().catch(() => {});\n }, [isSuperuser, list, reloadAll]);\n\n return (\n <div className=\"not-content grid auto-rows-fr gap-6 lg:grid-cols-2\">\n <Card className=\"h-full\">\n <CardHeader>\n <CardTitle>{t.title}</CardTitle>\n <CardDescription>{t.description}</CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {current ? (\n <dl className=\"grid gap-2 text-sm\">\n <div className=\"flex justify-between gap-3\">\n <dt className=\"text-muted-foreground\">{t.provider}</dt>\n <dd className=\"font-medium\">{current.provider}</dd>\n </div>\n <div className=\"flex justify-between gap-3\">\n <dt className=\"text-muted-foreground\">{t.jwtExpires}</dt>\n <dd className=\"font-medium text-right\">{formatDate(current.jwt_expires_at, t.notAvailable)}</dd>\n </div>\n <div className=\"flex justify-between gap-3\">\n <dt className=\"text-muted-foreground\">{t.refreshExpires}</dt>\n <dd className=\"font-medium text-right\">{formatDate(current.refresh_expires_at, t.notAvailable)}</dd>\n </div>\n </dl>\n ) : (\n <p className=\"text-sm text-muted-foreground\">{t.notLoaded}</p>\n )}\n\n <ActivitySummary\n title={t.yourActivity}\n totalLogins={activityAdded(mine, \"login\")}\n totalRegistrations={activityAdded(mine, \"registration\")}\n totalUsers={mine?.nb_users}\n t={t}\n />\n\n <Button type=\"button\" variant=\"outline\" onClick={() => { reloadCurrent(); reloadMine(); }}>\n <RefreshCw />\n {t.refresh}\n </Button>\n </CardContent>\n </Card>\n\n {isSuperuser && (\n <Card className=\"h-full\">\n <CardHeader>\n <CardTitle>{t.adminTitle}</CardTitle>\n <CardDescription>{t.adminDescription}</CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <ActivitySummary\n title={t.allActivity}\n totalLogins={activityAdded(all, \"login\")}\n totalRegistrations={activityAdded(all, \"registration\")}\n totalUsers={all?.nb_users}\n t={t}\n />\n\n {rows.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">\n {loading ? t.loading : t.empty}\n </p>\n ) : (\n <div className=\"divide-y rounded-md border\">\n {rows.map((session) => (\n <div key={session.id} className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"min-w-0 text-sm\">\n <p className=\"truncate font-medium\">{session.id}</p>\n <p className=\"text-muted-foreground\">{t.expires} {formatDate(session.refresh_expires_at, t.notAvailable)}</p>\n </div>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"destructive\"\n onClick={async () => {\n await revoke(session.id);\n await list();\n }}\n >\n <Trash2 />\n {t.revoke}\n </Button>\n </div>\n ))}\n </div>\n )}\n </CardContent>\n </Card>\n )}\n </div>\n );\n}\n",
18
+ "type": "registry:component",
19
+ "target": "components/fa-auth/sessions-panel.tsx"
20
+ }
21
+ ]
22
+ }
package/registry.json ADDED
@@ -0,0 +1,132 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry.json",
3
+ "name": "fa-m8-auth",
4
+ "homepage": "https://github.com/mano8/astro-auth-m8",
5
+ "items": [
6
+ {
7
+ "name": "data-table",
8
+ "type": "registry:component",
9
+ "title": "Data Table",
10
+ "description": "Generic pure-shadcn data table (sorting, filtering, pagination) built on @tanstack/react-table.",
11
+ "dependencies": ["@tanstack/react-table"],
12
+ "registryDependencies": ["table", "button", "input"],
13
+ "files": [
14
+ {
15
+ "path": "registry/blocks/data-table/data-table.tsx",
16
+ "type": "registry:component",
17
+ "target": "components/fa-auth/data-table.tsx"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "name": "activity-bar-chart",
23
+ "type": "registry:component",
24
+ "title": "Activity Bar Chart",
25
+ "description": "shadcn chart preset (recharts) for fa-auth per-model added/updated activity.",
26
+ "dependencies": ["recharts"],
27
+ "registryDependencies": ["chart"],
28
+ "files": [
29
+ {
30
+ "path": "registry/blocks/chart/activity-bar-chart.tsx",
31
+ "type": "registry:component",
32
+ "target": "components/fa-auth/activity-bar-chart.tsx"
33
+ }
34
+ ]
35
+ },
36
+ {
37
+ "name": "dashboard-overview",
38
+ "type": "registry:component",
39
+ "title": "Account Dashboard Overview",
40
+ "description": "fa-auth activity dashboard (stat cards + chart) driven by the package's useDashboard hook. Requires @fa-m8/astro-auth-m8 installed.",
41
+ "registryDependencies": [
42
+ "card",
43
+ "skeleton",
44
+ "./node_modules/@fa-m8/astro-auth-m8/registry/r/activity-bar-chart.json"
45
+ ],
46
+ "files": [
47
+ {
48
+ "path": "registry/blocks/account/dashboard-overview.tsx",
49
+ "type": "registry:component",
50
+ "target": "components/fa-auth/dashboard-overview.tsx"
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "name": "account-dashboard",
56
+ "type": "registry:component",
57
+ "title": "Account Dashboard",
58
+ "description": "fa-auth account view whose first/landing tab is the activity dashboard; secondary tabs are wired by the consumer. Requires @fa-m8/astro-auth-m8 installed.",
59
+ "registryDependencies": [
60
+ "button",
61
+ "skeleton",
62
+ "navigation-menu",
63
+ "./node_modules/@fa-m8/astro-auth-m8/registry/r/dashboard-overview.json"
64
+ ],
65
+ "files": [
66
+ {
67
+ "path": "registry/blocks/account/account-dashboard.tsx",
68
+ "type": "registry:component",
69
+ "target": "components/fa-auth/account-dashboard.tsx"
70
+ }
71
+ ]
72
+ },
73
+ {
74
+ "name": "profile-panel",
75
+ "type": "registry:component",
76
+ "title": "Account Profile Panel",
77
+ "description": "fa-auth profile editor (metadata + password rotation) driven by the package's useAuth + useProfile hooks. Requires @fa-m8/astro-auth-m8 installed.",
78
+ "registryDependencies": ["card", "button", "input", "label"],
79
+ "files": [
80
+ {
81
+ "path": "registry/blocks/account/profile-panel.tsx",
82
+ "type": "registry:component",
83
+ "target": "components/fa-auth/profile-panel.tsx"
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ "name": "sessions-panel",
89
+ "type": "registry:component",
90
+ "title": "Account Sessions Panel",
91
+ "description": "fa-auth session details + activity summaries with superuser-only session revocation, driven by the package's useSessions + useDashboard hooks. Requires @fa-m8/astro-auth-m8 installed.",
92
+ "dependencies": ["lucide-react"],
93
+ "registryDependencies": ["card", "button"],
94
+ "files": [
95
+ {
96
+ "path": "registry/blocks/account/sessions-panel.tsx",
97
+ "type": "registry:component",
98
+ "target": "components/fa-auth/sessions-panel.tsx"
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "name": "api-keys-panel",
104
+ "type": "registry:component",
105
+ "title": "Account API Keys Panel",
106
+ "description": "fa-auth API token mint/revoke panel driven by the package's useApiKeys hook. Requires @fa-m8/astro-auth-m8 installed.",
107
+ "registryDependencies": ["card", "button", "input", "label"],
108
+ "files": [
109
+ {
110
+ "path": "registry/blocks/account/api-keys-panel.tsx",
111
+ "type": "registry:component",
112
+ "target": "components/fa-auth/api-keys-panel.tsx"
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ "name": "admin-users-panel",
118
+ "type": "registry:component",
119
+ "title": "Admin Users Panel",
120
+ "description": "fa-auth superuser-only user management (create/update/delete), gated by the package's RequireRole and driven by useUsers. Requires @fa-m8/astro-auth-m8 installed.",
121
+ "dependencies": ["lucide-react"],
122
+ "registryDependencies": ["card", "button", "input", "label"],
123
+ "files": [
124
+ {
125
+ "path": "registry/blocks/account/admin-users-panel.tsx",
126
+ "type": "registry:component",
127
+ "target": "components/fa-auth/admin-users-panel.tsx"
128
+ }
129
+ ]
130
+ }
131
+ ]
132
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ import { AuthProvider } from "@fa-m8/astro-auth-m8/react";
3
+ import { AccountView } from "@fa-m8/astro-auth-m8/default-ui";
4
+ import "../scaffold/styles/auth.css";
5
+ ---
6
+ <AuthProvider client:load config={{ apiBase: import.meta.env.PUBLIC_FA_AUTH_API_BASE }}>
7
+ <AccountView />
8
+ </AuthProvider>
@@ -0,0 +1,5 @@
1
+ ---
2
+ import { CallbackView } from "@fa-m8/astro-auth-m8/default-ui";
3
+ import "../scaffold/styles/auth.css";
4
+ ---
5
+ <CallbackView client:load />
@@ -0,0 +1,8 @@
1
+ ---
2
+ import { AuthProvider } from "@fa-m8/astro-auth-m8/react";
3
+ import { LoginView } from "@fa-m8/astro-auth-m8/default-ui";
4
+ import "../scaffold/styles/auth.css";
5
+ ---
6
+ <AuthProvider client:load config={{ apiBase: import.meta.env.PUBLIC_FA_AUTH_API_BASE }}>
7
+ <LoginView />
8
+ </AuthProvider>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { AuthProvider } from "@fa-m8/astro-auth-m8/react";
3
+ import { logout } from "@fa-m8/astro-auth-m8/client";
4
+ import "../scaffold/styles/auth.css";
5
+ ---
6
+ <AuthProvider client:load config={{ apiBase: import.meta.env.PUBLIC_FA_AUTH_API_BASE }}>
7
+ <form class="fa-auth-panel" method="post">
8
+ <h1>Sign out</h1>
9
+ <button type="button" id="fa-auth-logout">Sign out</button>
10
+ </form>
11
+ </AuthProvider>
12
+ <script>
13
+ import { logout } from "@fa-m8/astro-auth-m8/client";
14
+ document.getElementById("fa-auth-logout")?.addEventListener("click", async () => {
15
+ await logout();
16
+ window.location.assign("../auth/login");
17
+ });
18
+ </script>
@@ -0,0 +1,5 @@
1
+ ---
2
+ import { SignupView } from "@fa-m8/astro-auth-m8/default-ui";
3
+ import "../scaffold/styles/auth.css";
4
+ ---
5
+ <SignupView client:load />
@@ -0,0 +1,49 @@
1
+ .fa-auth-panel {
2
+ width: min(100% - 32px, 420px);
3
+ margin: 64px auto;
4
+ font-family: system-ui, sans-serif;
5
+ }
6
+
7
+ .fa-auth-panel h1 {
8
+ margin: 0 0 24px;
9
+ font-size: 1.75rem;
10
+ }
11
+
12
+ .fa-auth-panel form,
13
+ .fa-auth-panel label,
14
+ .fa-auth-panel dl {
15
+ display: grid;
16
+ gap: 12px;
17
+ }
18
+
19
+ .fa-auth-panel label {
20
+ padding-bottom: 0.5rem;
21
+ }
22
+
23
+ .fa-auth-panel input,
24
+ .fa-auth-panel select,
25
+ .fa-auth-panel button {
26
+ min-height: 40px;
27
+ font: inherit;
28
+ }
29
+
30
+ .fa-auth-panel select {
31
+ color-scheme: light;
32
+ }
33
+
34
+ :root[data-theme='dark'] .fa-auth-panel select {
35
+ color-scheme: dark;
36
+ }
37
+
38
+ .fa-auth-panel select option {
39
+ background-color: var(--popover, Canvas);
40
+ color: var(--popover-foreground, CanvasText);
41
+ }
42
+
43
+ .fa-auth-panel button {
44
+ cursor: pointer;
45
+ }
46
+
47
+ .fa-auth-panel [role="alert"] {
48
+ color: #9f1239;
49
+ }