hazo_auth 10.9.0 → 10.11.0

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 (45) hide show
  1. package/README.md +40 -0
  2. package/cli-src/cli/generate.ts +1 -0
  3. package/cli-src/lib/cookies_config.server.ts +50 -0
  4. package/cli-src/lib/my_settings_config.server.ts +5 -1
  5. package/cli-src/lib/services/account_deletion_service.ts +67 -0
  6. package/cli-src/lib/services/index.ts +1 -0
  7. package/config/hazo_auth_config.example.ini +25 -19
  8. package/dist/cli/generate.d.ts.map +1 -1
  9. package/dist/cli/generate.js +1 -0
  10. package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts +34 -0
  11. package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -0
  12. package/dist/components/layouts/my_settings/components/danger_zone_section.js +93 -0
  13. package/dist/components/layouts/my_settings/index.d.ts +6 -1
  14. package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
  15. package/dist/components/layouts/my_settings/index.js +3 -2
  16. package/dist/components/ui/button.d.ts +1 -1
  17. package/dist/hooks.d.ts +5 -0
  18. package/dist/hooks.d.ts.map +1 -0
  19. package/dist/hooks.js +29 -0
  20. package/dist/lib/cookies_config.server.d.ts +20 -0
  21. package/dist/lib/cookies_config.server.d.ts.map +1 -1
  22. package/dist/lib/cookies_config.server.js +43 -0
  23. package/dist/lib/my_settings_config.server.d.ts +2 -0
  24. package/dist/lib/my_settings_config.server.d.ts.map +1 -1
  25. package/dist/lib/my_settings_config.server.js +3 -1
  26. package/dist/lib/services/account_deletion_service.d.ts +22 -0
  27. package/dist/lib/services/account_deletion_service.d.ts.map +1 -0
  28. package/dist/lib/services/account_deletion_service.js +55 -0
  29. package/dist/lib/services/index.d.ts +1 -0
  30. package/dist/lib/services/index.d.ts.map +1 -1
  31. package/dist/lib/services/index.js +1 -0
  32. package/dist/page_components/my_settings.d.ts +6 -1
  33. package/dist/page_components/my_settings.d.ts.map +1 -1
  34. package/dist/page_components/my_settings.js +2 -2
  35. package/dist/server/routes/delete_account.d.ts +17 -0
  36. package/dist/server/routes/delete_account.d.ts.map +1 -0
  37. package/dist/server/routes/delete_account.js +107 -0
  38. package/dist/server/routes/index.d.ts +1 -0
  39. package/dist/server/routes/index.d.ts.map +1 -1
  40. package/dist/server/routes/index.js +1 -0
  41. package/dist/server/routes/logout.d.ts.map +1 -1
  42. package/dist/server/routes/logout.js +4 -40
  43. package/dist/server_pages/my_settings.d.ts.map +1 -1
  44. package/dist/server_pages/my_settings.js +1 -1
  45. package/package.json +11 -7
package/README.md CHANGED
@@ -3097,6 +3097,46 @@ When `enabled = false` (default), all relationship routes return 404, email rema
3097
3097
 
3098
3098
  ---
3099
3099
 
3100
+ ## Self-Service Account Deletion
3101
+
3102
+ hazo_auth supports letting an authenticated user permanently (hard) delete their own account — the deletion cascades to all related rows (scopes, invitations, tokens, etc.) via `delete_own_account`. A "Danger Zone" section is available in the My Settings layout to trigger this from the UI.
3103
+
3104
+ ### Enabling
3105
+
3106
+ The feature is opt-in and **off by default**. Add to your `hazo_auth_config.ini`:
3107
+
3108
+ ```ini
3109
+ [hazo_auth__my_settings_layout]
3110
+ enable_account_deletion = true
3111
+ ```
3112
+
3113
+ ### API
3114
+
3115
+ | Method | Endpoint | Description |
3116
+ |--------|----------|-------------|
3117
+ | DELETE | `/api/hazo_auth/delete_account` | Hard-delete the caller's own account (body: `{ confirm_email }`) |
3118
+
3119
+ The caller must re-type their own email address as confirmation. `confirm_email` is matched against the authenticated user's email **case-insensitively**.
3120
+
3121
+ **Responses:**
3122
+
3123
+ | Status | Body | When |
3124
+ |--------|------|------|
3125
+ | 200 | `{ success: true, message: "Account deleted successfully" }` | Account deleted; session cookies (hazo_auth + NextAuth/OAuth) are cleared |
3126
+ | 401 | `{ error: "Authentication required" }` | No authenticated session |
3127
+ | 403 | `{ error: "Account deletion is not enabled" }` | `enable_account_deletion` is `false` (the default) |
3128
+ | 400 | `{ error: "Confirmation email does not match your account email" }` (or missing `confirm_email`) | Confirmation check failed |
3129
+ | 400 | `{ error: <service error> }` | `delete_own_account` reported failure |
3130
+ | 500 | `{ error: "Failed to delete account. Please try again." }` | Unexpected error |
3131
+
3132
+ On success, the route clears the three core hazo_auth session cookies as well as the NextAuth/Google-OAuth cookie set, so a deleted Google-OAuth user isn't left holding a live `next-auth.session-token`.
3133
+
3134
+ ### Feature Gating
3135
+
3136
+ When `enable_account_deletion = false` (default), `DELETE /api/hazo_auth/delete_account` always returns 403 and existing behavior is completely unchanged.
3137
+
3138
+ ---
3139
+
3100
3140
  ## User Profile Service
3101
3141
 
3102
3142
  The `hazo_auth` package provides a batch user profile retrieval service for applications that need basic user information, such as chat applications or user lists.
@@ -39,6 +39,7 @@ const ROUTES: RouteDefinition[] = [
39
39
  { name: "change_password", path: "api/hazo_auth/change_password", method: "POST", export_name: "changePasswordPOST" },
40
40
  { name: "upload_profile_picture", path: "api/hazo_auth/upload_profile_picture", method: "POST", export_name: "uploadProfilePicturePOST" },
41
41
  { name: "remove_profile_picture", path: "api/hazo_auth/remove_profile_picture", method: "DELETE", export_name: "removeProfilePictureDELETE" },
42
+ { name: "delete_account", path: "api/hazo_auth/delete_account", method: "DELETE", export_name: "deleteAccountDELETE" },
42
43
  { name: "library_photos", path: "api/hazo_auth/library_photos", method: "GET", export_name: "libraryPhotosGET" },
43
44
  { name: "library_photo", path: "api/hazo_auth/library_photo/[category]/[filename]", method: "GET", export_name: "libraryPhotoGET" },
44
45
  { name: "get_auth", path: "api/hazo_auth/get_auth", method: "POST", export_name: "getAuthPOST" },
@@ -2,6 +2,7 @@
2
2
  // section: server-only-guard
3
3
  import "server-only";
4
4
 
5
+ import type { NextResponse } from "next/server";
5
6
  import { HazoConfigError } from "hazo_core";
6
7
  import { read_config_section } from "./config/config_loader.server.js";
7
8
 
@@ -109,3 +110,52 @@ export function get_cached_cookies_config(): CookiesConfig {
109
110
  export function clear_cookies_config_cache(): void {
110
111
  cached_config = null;
111
112
  }
113
+
114
+ /**
115
+ * Clears the three core hazo_auth session cookies (USER_EMAIL, USER_ID, SESSION)
116
+ * from a response, honoring the configured cookie prefix/domain. This is the same
117
+ * clearing logic used by the logout route; reuse it anywhere a session needs to be
118
+ * torn down (e.g. self-service account deletion) instead of re-implementing it.
119
+ * @param response - NextResponse object to clear cookies from
120
+ * @returns The same response, with cleared cookies (for chaining)
121
+ */
122
+ export function clear_session_cookies<T extends NextResponse>(response: T): T {
123
+ const clear_cookie_options = get_cookie_options({
124
+ expires: new Date(0),
125
+ path: "/",
126
+ });
127
+
128
+ response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_EMAIL), "", clear_cookie_options);
129
+ response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_ID), "", clear_cookie_options);
130
+ response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.SESSION), "", clear_cookie_options);
131
+
132
+ return response;
133
+ }
134
+
135
+ /**
136
+ * Clears the NextAuth.js cookies used by the Google OAuth flow (session token,
137
+ * CSRF token, callback URL — plus their `__Secure-`/`__Host-` production variants)
138
+ * from a response. This is the same clearing logic used by the logout route; reuse
139
+ * it anywhere a NextAuth-backed session needs to be torn down (e.g. self-service
140
+ * account deletion) instead of re-implementing it.
141
+ * @param response - NextResponse object to clear cookies from
142
+ * @returns The same response, with cleared cookies (for chaining)
143
+ */
144
+ export function clear_nextauth_cookies<T extends NextResponse>(response: T): T {
145
+ const clear_cookie_options = {
146
+ expires: new Date(0),
147
+ path: "/",
148
+ };
149
+
150
+ response.cookies.set("next-auth.session-token", "", clear_cookie_options);
151
+ response.cookies.set("next-auth.csrf-token", "", clear_cookie_options);
152
+ response.cookies.set("next-auth.callback-url", "", clear_cookie_options);
153
+ // Also clear secure cookie variants (used in production with HTTPS)
154
+ response.cookies.set("__Secure-next-auth.session-token", "", clear_cookie_options);
155
+ response.cookies.set("__Secure-next-auth.csrf-token", "", clear_cookie_options);
156
+ response.cookies.set("__Secure-next-auth.callback-url", "", clear_cookie_options);
157
+ // Host-prefixed variants (for some NextAuth configurations)
158
+ response.cookies.set("__Host-next-auth.csrf-token", "", clear_cookie_options);
159
+
160
+ return response;
161
+ }
@@ -3,7 +3,7 @@
3
3
  import "server-only";
4
4
 
5
5
  // section: imports
6
- import { get_config_value } from "./config/config_loader.server.js";
6
+ import { get_config_value, get_config_boolean } from "./config/config_loader.server.js";
7
7
  import { get_user_fields_config } from "./user_fields_config.server.js";
8
8
  import { get_password_requirements_config } from "./password_requirements_config.server.js";
9
9
  import { get_profile_picture_config } from "./profile_picture_config.server.js";
@@ -49,6 +49,8 @@ export type MySettingsConfig = {
49
49
  unauthorizedMessage?: string;
50
50
  loginButtonLabel?: string;
51
51
  loginPath?: string;
52
+ /** Opt-in self-service account deletion (Danger Zone). Default: false. */
53
+ enableAccountDeletion: boolean;
52
54
  messages: {
53
55
  photo_upload_disabled_message: string;
54
56
  gravatar_setup_message: string;
@@ -110,6 +112,7 @@ export function get_my_settings_config(): MySettingsConfig {
110
112
  const unauthorizedMessage = get_config_value(section, "unauthorized_message", "You must be logged in to access this page.");
111
113
  const loginButtonLabel = get_config_value(section, "login_button_label", "Go to login");
112
114
  const loginPath = get_config_value(section, "login_path", "/hazo_auth/login");
115
+ const enableAccountDeletion = get_config_boolean(section, "enable_account_deletion", false);
113
116
 
114
117
  return {
115
118
  userFields,
@@ -130,6 +133,7 @@ export function get_my_settings_config(): MySettingsConfig {
130
133
  unauthorizedMessage,
131
134
  loginButtonLabel,
132
135
  loginPath,
136
+ enableAccountDeletion,
133
137
  messages,
134
138
  uiSizes,
135
139
  fileTypes,
@@ -0,0 +1,67 @@
1
+ // file_description: service for self-service (hard) deletion of the caller's own hazo_users row
2
+ // section: imports
3
+ import { createCrudService } from "hazo_connect/server";
4
+ import { get_hazo_connect_instance } from "../hazo_connect_instance.server.js";
5
+ import { create_app_logger } from "../app_logger.js";
6
+ import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
7
+ import { get_line_number } from "../utils/api_route_helpers.js";
8
+
9
+ // section: types
10
+ export type AccountDeletionResult = {
11
+ success: boolean;
12
+ error?: string;
13
+ };
14
+
15
+ // section: main_function
16
+ /**
17
+ * Hard-deletes the caller's own `hazo_users` row.
18
+ *
19
+ * Child rows cascade automatically via `ON DELETE CASCADE` foreign keys
20
+ * (hazo_refresh_tokens, hazo_user_scopes, hazo_user_relationships,
21
+ * hazo_email_otps, hazo_legal_acceptances, hazo_google_oauth_tokens,
22
+ * hazo_user_roles) — no manual cleanup needed. A few "created by" /
23
+ * "managed by" references (hazo_users.managed_by_user_id,
24
+ * hazo_invitations.invited_by, hazo_legal_doc_versions.published_by_user_id)
25
+ * intentionally use `ON DELETE SET NULL` instead of CASCADE, by design —
26
+ * they preserve audit/history/relationship rows rather than deleting them,
27
+ * so they likewise require no manual cleanup here.
28
+ *
29
+ * @param user_id - The authenticated caller's own user ID (never another user's)
30
+ * @returns AccountDeletionResult with success status or error
31
+ */
32
+ export async function delete_own_account(
33
+ user_id: string,
34
+ ): Promise<AccountDeletionResult> {
35
+ try {
36
+ const adapter = get_hazo_connect_instance();
37
+ const users_service = createCrudService(adapter, "hazo_users");
38
+
39
+ // Verify the user still exists before deleting
40
+ const users = await users_service.findBy({ id: user_id });
41
+ if (!Array.isArray(users) || users.length === 0) {
42
+ return { success: false, error: "User not found" };
43
+ }
44
+
45
+ await users_service.deleteById(user_id);
46
+
47
+ return { success: true };
48
+ } catch (error) {
49
+ const logger = create_app_logger();
50
+ const user_friendly_error = sanitize_error_for_user(error, {
51
+ logToConsole: true,
52
+ logToLogger: true,
53
+ logger,
54
+ context: {
55
+ filename: "account_deletion_service.ts",
56
+ line_number: get_line_number(),
57
+ user_id,
58
+ operation: "delete_own_account",
59
+ },
60
+ });
61
+
62
+ return {
63
+ success: false,
64
+ error: user_friendly_error,
65
+ };
66
+ }
67
+ }
@@ -22,4 +22,5 @@ export * from "./oauth_service.js";
22
22
  export * from "./branding_service.js";
23
23
  export * from "./google_token_service.js";
24
24
  export * from "./demo_account_service.js";
25
+ export * from "./account_deletion_service.js";
25
26
 
@@ -23,6 +23,25 @@ cookie_prefix = myapp_
23
23
  # Database type: sqlite, postgrest, supabase, or file
24
24
  type = sqlite
25
25
 
26
+ # SQLite database configuration
27
+ # Path to SQLite database file (relative to process.cwd() or absolute)
28
+ sqlite_path = ./data/hazo_auth.sqlite
29
+
30
+ # Enable SQLite admin UI (true/false)
31
+ enable_admin_ui = true
32
+
33
+ # SQLite read-only mode (true/false)
34
+ # read_only = false
35
+
36
+ # PostgREST configuration (uncomment if using postgrest type)
37
+ # postgrest_url =
38
+
39
+ # PostgREST API Key (REQUIRED if PostgREST uses authentication)
40
+ # IMPORTANT: API keys should ONLY be set in environment variables for security
41
+ # Set HAZO_CONNECT_POSTGREST_API_KEY or POSTGREST_API_KEY in your .env file
42
+ # DO NOT put API keys in this config file
43
+ # postgrest_api_key =
44
+
26
45
  # UI shell controls whether pages render inside the developer sidebar or a minimal wrapper.
27
46
  [hazo_auth__ui_shell]
28
47
  # layout_mode = test_sidebar
@@ -48,25 +67,6 @@ type = sqlite
48
67
  # Show/hide description in standalone mode (true/false, default: true)
49
68
  # standalone_show_description = true
50
69
 
51
- # SQLite database configuration
52
- # Path to SQLite database file (relative to process.cwd() or absolute)
53
- sqlite_path = ./data/hazo_auth.sqlite
54
-
55
- # Enable SQLite admin UI (true/false)
56
- enable_admin_ui = true
57
-
58
- # SQLite read-only mode (true/false)
59
- # read_only = false
60
-
61
- # PostgREST configuration (uncomment if using postgrest type)
62
- # postgrest_url =
63
-
64
- # PostgREST API Key (REQUIRED if PostgREST uses authentication)
65
- # IMPORTANT: API keys should ONLY be set in environment variables for security
66
- # Set HAZO_CONNECT_POSTGREST_API_KEY or POSTGREST_API_KEY in your .env file
67
- # DO NOT put API keys in this config file
68
- # postgrest_api_key =
69
-
70
70
  [hazo_auth__register_layout]
71
71
  # Image configuration
72
72
  # Default: /hazo_auth/images/register_default.jpg (copy from node_modules/hazo_auth/public/hazo_auth)
@@ -308,6 +308,12 @@ enable_admin_ui = true
308
308
  # Login path (redirect target in unauthorized message)
309
309
  # login_path = /login
310
310
 
311
+ # Self-service account deletion (Danger Zone). Opt-in — off by default.
312
+ # When true, an authenticated user may hard-delete their own account via
313
+ # DELETE /api/hazo_auth/delete_account (re-typing their own email as confirmation).
314
+ # The hazo_users row and all cascading child rows (sessions, scopes, etc.) are removed.
315
+ # enable_account_deletion = false
316
+
311
317
  [hazo_auth__user_management]
312
318
  # User Management configuration
313
319
  # Application permission list defaults (comma-separated)
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/cli/generate.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAuMF,wBAAgB,eAAe,CAAC,OAAO,GAAE,eAAoB,GAAG,IAAI,CA8DnE"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/cli/generate.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAwMF,wBAAgB,eAAe,CAAC,OAAO,GAAE,eAAoB,GAAG,IAAI,CA8DnE"}
@@ -16,6 +16,7 @@ const ROUTES = [
16
16
  { name: "change_password", path: "api/hazo_auth/change_password", method: "POST", export_name: "changePasswordPOST" },
17
17
  { name: "upload_profile_picture", path: "api/hazo_auth/upload_profile_picture", method: "POST", export_name: "uploadProfilePicturePOST" },
18
18
  { name: "remove_profile_picture", path: "api/hazo_auth/remove_profile_picture", method: "DELETE", export_name: "removeProfilePictureDELETE" },
19
+ { name: "delete_account", path: "api/hazo_auth/delete_account", method: "DELETE", export_name: "deleteAccountDELETE" },
19
20
  { name: "library_photos", path: "api/hazo_auth/library_photos", method: "GET", export_name: "libraryPhotosGET" },
20
21
  { name: "library_photo", path: "api/hazo_auth/library_photo/[category]/[filename]", method: "GET", export_name: "libraryPhotoGET" },
21
22
  { name: "get_auth", path: "api/hazo_auth/get_auth", method: "POST", export_name: "getAuthPOST" },
@@ -0,0 +1,34 @@
1
+ export type DangerZoneSectionProps = {
2
+ /** Current user's email address — must be re-typed (case-insensitively) to confirm deletion */
3
+ email: string;
4
+ /** Whether the section renders at all. Mirrors the `enable_account_deletion` config flag; defaults to off (opt-in). */
5
+ enabled?: boolean;
6
+ /** Section heading */
7
+ heading?: string;
8
+ /** Section description */
9
+ description?: string;
10
+ /** Label for the button that opens the confirmation dialog */
11
+ deleteButtonLabel?: string;
12
+ /** Confirmation dialog title */
13
+ dialogTitle?: string;
14
+ /** Confirmation dialog description */
15
+ dialogDescription?: string;
16
+ /** Label for the retype-email confirmation input */
17
+ confirmInputLabel?: string;
18
+ /** Label for the destructive confirm button inside the dialog */
19
+ confirmButtonLabel?: string;
20
+ /** Label for the cancel button inside the dialog */
21
+ cancelButtonLabel?: string;
22
+ /** Path to navigate to once the account has been deleted */
23
+ redirectPath?: string;
24
+ };
25
+ /**
26
+ * Danger Zone Section for My Settings
27
+ * Renders a visually distinct destructive section with a "Delete my account" action.
28
+ * Clicking it opens a confirmation dialog that requires the user to re-type their own
29
+ * email address before the destructive button enables. On confirm, calls the
30
+ * account-deletion API route and signs the user out on success.
31
+ * Renders nothing when `enabled` is false (config-gated, default off).
32
+ */
33
+ export declare function DangerZoneSection({ email, enabled, heading, description, deleteButtonLabel, dialogTitle, dialogDescription, confirmInputLabel, confirmButtonLabel, cancelButtonLabel, redirectPath, }: DangerZoneSectionProps): import("react").JSX.Element | null;
34
+ //# sourceMappingURL=danger_zone_section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"danger_zone_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/danger_zone_section.tsx"],"names":[],"mappings":"AA2BA,MAAM,MAAM,sBAAsB,GAAG;IACnC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAC;IACd,uHAAuH;IACvH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,OAAe,EACf,OAAuB,EACvB,WAAsG,EACtG,iBAAuC,EACvC,WAAoC,EACpC,iBAAiK,EACjK,iBAAwD,EACxD,kBAAoD,EACpD,iBAA4B,EAC5B,YAAiC,GAClC,EAAE,sBAAsB,sCA8JxB"}
@@ -0,0 +1,93 @@
1
+ // file_description: Danger Zone section for My Settings — destructive account deletion gated
2
+ // behind typed-email re-confirmation. Visibility is controlled entirely by the `enabled` prop
3
+ // (threaded down from the `enable_account_deletion` config flag), so this component renders
4
+ // nothing unless explicitly turned on.
5
+ // section: client_directive
6
+ "use client";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ // section: imports
9
+ import { useCallback, useMemo, useState } from "react";
10
+ import { useRouter } from "next/navigation";
11
+ import { toast } from "sonner";
12
+ import { AlertTriangle } from "lucide-react";
13
+ import { Button } from "../../../ui/button.js";
14
+ import { Input } from "../../../ui/input.js";
15
+ import { AlertDialog, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "../../../ui/alert-dialog.js";
16
+ import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
17
+ import { trigger_auth_status_refresh } from "../../shared/hooks/use_auth_status.js";
18
+ import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
19
+ // section: component
20
+ /**
21
+ * Danger Zone Section for My Settings
22
+ * Renders a visually distinct destructive section with a "Delete my account" action.
23
+ * Clicking it opens a confirmation dialog that requires the user to re-type their own
24
+ * email address before the destructive button enables. On confirm, calls the
25
+ * account-deletion API route and signs the user out on success.
26
+ * Renders nothing when `enabled` is false (config-gated, default off).
27
+ */
28
+ export function DangerZoneSection({ email, enabled = false, heading = "Danger Zone", description = "Permanently delete your account and all associated data. This action cannot be undone.", deleteButtonLabel = "Delete my account", dialogTitle = "Delete your account?", dialogDescription = "This will permanently delete your account and all associated data. This action cannot be undone. To confirm, type your email address below.", confirmInputLabel = "Type your email address to confirm", confirmButtonLabel = "Permanently delete my account", cancelButtonLabel = "Cancel", redirectPath = "/hazo_auth/login", }) {
29
+ const { apiBasePath } = useHazoAuthConfig();
30
+ const router = useRouter();
31
+ const [dialogOpen, setDialogOpen] = useState(false);
32
+ const [confirmEmail, setConfirmEmail] = useState("");
33
+ const [loading, setLoading] = useState(false);
34
+ /**
35
+ * Compares the typed email against the account email, case-insensitively
36
+ */
37
+ const emailMatches = useMemo(() => {
38
+ const typed = confirmEmail.trim().toLowerCase();
39
+ const actual = (email || "").trim().toLowerCase();
40
+ return typed.length > 0 && typed === actual;
41
+ }, [confirmEmail, email]);
42
+ const resetDialogState = useCallback(() => {
43
+ setConfirmEmail("");
44
+ setLoading(false);
45
+ }, []);
46
+ const handleOpenChange = useCallback((open) => {
47
+ setDialogOpen(open);
48
+ if (!open) {
49
+ resetDialogState();
50
+ }
51
+ }, [resetDialogState]);
52
+ /**
53
+ * Sends the delete request, then signs the user out and redirects on success
54
+ */
55
+ const handleDeleteAccount = useCallback(async () => {
56
+ if (!emailMatches || loading) {
57
+ return;
58
+ }
59
+ setLoading(true);
60
+ try {
61
+ const response = await fetch(`${apiBasePath}/delete_account`, {
62
+ method: "DELETE",
63
+ headers: {
64
+ "Content-Type": "application/json",
65
+ },
66
+ credentials: "include",
67
+ body: JSON.stringify({ confirm_email: confirmEmail }),
68
+ });
69
+ const data = await response.json();
70
+ if (!response.ok || !data.success) {
71
+ const errorMessage = data.error || "Failed to delete account";
72
+ toast.error(errorMessage);
73
+ setLoading(false);
74
+ return;
75
+ }
76
+ toast.success("Your account has been deleted.");
77
+ setDialogOpen(false);
78
+ resetDialogState();
79
+ // Sign the user out client-side and send them away from the now-deleted account
80
+ trigger_auth_status_refresh();
81
+ router.push(redirectPath);
82
+ }
83
+ catch (error) {
84
+ const errorMessage = error instanceof Error ? error.message : "Failed to delete account";
85
+ toast.error(errorMessage);
86
+ setLoading(false);
87
+ }
88
+ }, [emailMatches, loading, apiBasePath, confirmEmail, resetDialogState, router, redirectPath]);
89
+ if (!enabled) {
90
+ return null;
91
+ }
92
+ return (_jsxs("div", { className: "cls_my_settings_danger_zone_section bg-white rounded-lg border border-red-200 p-6", children: [_jsxs("div", { className: "cls_danger_zone_header flex items-center gap-2 mb-2", children: [_jsx(AlertTriangle, { className: "h-5 w-5 text-red-600", "aria-hidden": "true" }), _jsx("h2", { className: "cls_danger_zone_heading text-lg font-semibold text-red-700", children: heading })] }), _jsx("p", { className: "cls_danger_zone_description text-sm text-[var(--hazo-text-muted)] mb-4", children: description }), _jsx("div", { className: "cls_danger_zone_actions flex justify-end", children: _jsx(Button, { type: "button", onClick: () => setDialogOpen(true), variant: "destructive", className: "cls_danger_zone_delete_button", "aria-label": deleteButtonLabel, children: deleteButtonLabel }) }), _jsx(AlertDialog, { open: dialogOpen, onOpenChange: handleOpenChange, children: _jsxs(AlertDialogContent, { className: "cls_delete_account_dialog", children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { className: "cls_delete_account_dialog_title", children: dialogTitle }), _jsx(AlertDialogDescription, { className: "cls_delete_account_dialog_description", children: dialogDescription })] }), _jsx("div", { className: "cls_delete_account_dialog_content py-2", children: _jsx(FormFieldWrapper, { fieldId: "delete-account-confirm-email", label: confirmInputLabel, input: _jsx(Input, { id: "delete-account-confirm-email", type: "email", value: confirmEmail, onChange: (event) => setConfirmEmail(event.target.value), placeholder: email, autoComplete: "off", disabled: loading, "aria-label": confirmInputLabel, className: "cls_delete_account_confirm_input" }) }) }), _jsxs(AlertDialogFooter, { children: [_jsx(Button, { type: "button", onClick: handleDeleteAccount, disabled: !emailMatches || loading, variant: "destructive", className: "cls_delete_account_confirm_button", "aria-label": confirmButtonLabel, children: loading ? "Deleting..." : confirmButtonLabel }), _jsx(Button, { type: "button", onClick: () => handleOpenChange(false), disabled: loading, variant: "outline", className: "cls_delete_account_cancel_button", "aria-label": cancelButtonLabel, children: cancelButtonLabel })] })] }) })] }));
93
+ }
@@ -22,6 +22,11 @@ export type MySettingsLayoutProps = {
22
22
  unauthorizedMessage?: string;
23
23
  loginButtonLabel?: string;
24
24
  loginPath?: string;
25
+ /**
26
+ * Whether the Danger Zone (account deletion) section is shown.
27
+ * Mirrors the `enable_account_deletion` config flag; defaults to off (opt-in).
28
+ */
29
+ enableAccountDeletion?: boolean;
25
30
  heading?: string;
26
31
  subHeading?: string;
27
32
  profilePhotoLabel?: string;
@@ -61,5 +66,5 @@ export type MySettingsLayoutProps = {
61
66
  * @param props - Component props including labels, button colors, password requirements, etc.
62
67
  * @returns My settings layout component
63
68
  */
64
- export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react").JSX.Element;
69
+ export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, enableAccountDeletion, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react").JSX.Element;
65
70
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,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,UAAoE,EACpE,iBAAmC,EACnC,0BAAqE,EACrE,sBAA2C,EAC3C,sBAAiC,EACjC,uBAA+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BAqOvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAcA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC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+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BA2OvB"}
@@ -9,6 +9,7 @@ import { ProfilePictureDisplay } from "./components/profile_picture_display.js";
9
9
  import { ProfilePictureDialog } from "./components/profile_picture_dialog.js";
10
10
  import { ConnectedAccountsSection } from "./components/connected_accounts_section.js";
11
11
  import { SetPasswordSection } from "./components/set_password_section.js";
12
+ import { DangerZoneSection } from "./components/danger_zone_section.js";
12
13
  import { UnauthorizedGuard } from "../shared/components/unauthorized_guard.js";
13
14
  import { use_my_settings } from "./hooks/use_my_settings.js";
14
15
  import { resolveMySettingsLabels, resolveMySettingsButtonPalette, } from "./config/my_settings_field_config.js";
@@ -24,7 +25,7 @@ import { cn } from "../../../lib/utils.js";
24
25
  * @param props - Component props including labels, button colors, password requirements, etc.
25
26
  * @returns My settings layout component
26
27
  */
27
- export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
28
+ export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", enableAccountDeletion = false, heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
28
29
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
29
30
  const resolvedLabels = resolveMySettingsLabels(labels);
30
31
  const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
@@ -34,7 +35,7 @@ export default function my_settings_layout({ className, labels, button_colors, p
34
35
  return (_jsx(UnauthorizedGuard, { message: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: cn("cls_my_settings_layout flex flex-col gap-6 p-6 w-full", className), children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-[var(--hazo-text-primary)]", children: heading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: subHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: profilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": uploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": removePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: profileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: "Full Name", value: settings.name, type: "text", placeholder: "Enter your full name", onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: "Full name input field" })), userFields.show_email_field && (_jsx(EditableField, { label: "Email Address", value: settings.email, type: "email", placeholder: "Enter your email address", onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: "Email address input field" }))] })] }), userFields.show_password_field && settings.hasPassword && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: passwordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: currentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: currentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: "Enter your current password", autoComplete: "current-password", isVisible: ((_b = settings.passwordFields) === null || _b === void 0 ? void 0 : _b.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_d = (_c = settings.passwordFields) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.currentPassword }) }), _jsxs("div", { className: "cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "new-password", label: newPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: newPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: "Enter your new password", autoComplete: "new-password", isVisible: ((_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_h = (_g = settings.passwordFields) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: confirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: "Confirm your new password", autoComplete: "new-password", isVisible: ((_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_m = (_l = settings.passwordFields) === null || _l === void 0 ? void 0 : _l.errors) === null || _m === void 0 ? void 0 : _m.confirmPassword }) })] })] }), _jsx("div", { className: "cls_my_settings_layout_password_actions flex justify-end mt-4", children: _jsx(Button, { type: "button", onClick: settings.handlePasswordSave, disabled: settings.loading || settings.isPasswordSaveDisabled, className: "cls_my_settings_layout_save_password_button", style: {
35
36
  backgroundColor: resolvedButtonPalette.submitBackground,
36
37
  color: resolvedButtonPalette.submitText,
37
- }, "aria-label": "Save password", children: "Save Password" }) })] })), !settings.hasPassword && settings.googleConnected && (_jsx(SetPasswordSection, { passwordRequirements: password_requirements, onPasswordSet: settings.refreshUserData, parentLoading: settings.loading })), _jsx(ConnectedAccountsSection, { googleConnected: settings.googleConnected || false, email: settings.email, loading: settings.loading }), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
38
+ }, "aria-label": "Save password", children: "Save Password" }) })] })), !settings.hasPassword && settings.googleConnected && (_jsx(SetPasswordSection, { passwordRequirements: password_requirements, onPasswordSet: settings.refreshUserData, parentLoading: settings.loading })), _jsx(ConnectedAccountsSection, { googleConnected: settings.googleConnected || false, email: settings.email, loading: settings.loading }), _jsx(DangerZoneSection, { enabled: enableAccountDeletion, email: settings.email }), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
38
39
  if (open) {
39
40
  settings.handleProfilePictureEdit();
40
41
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
4
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
5
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -0,0 +1,5 @@
1
+ export { use_auth_status, trigger_auth_status_refresh } from "./components/layouts/shared/hooks/use_auth_status.js";
2
+ export { use_hazo_auth, trigger_hazo_auth_refresh } from "./components/layouts/shared/hooks/use_hazo_auth.js";
3
+ export type { UseHazoAuthOptions, UseHazoAuthResult } from "./components/layouts/shared/hooks/use_hazo_auth";
4
+ export * from "./lib/auth/auth_types.js";
5
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC3G,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAI7G,cAAc,uBAAuB,CAAC"}
package/dist/hooks.js ADDED
@@ -0,0 +1,29 @@
1
+ // file_description: hooks-only client entry point — auth state without any component code
2
+ //
3
+ // USAGE:
4
+ // import { use_hazo_auth } from "hazo_auth/hooks";
5
+ //
6
+ // WHY THIS EXISTS (separate from "hazo_auth/client"):
7
+ // `hazo_auth/client` re-exports the package's entire component surface via
8
+ // `export * from "./components/index.js"` — which transitively pulls in
9
+ // ProfilePicMenu -> RolesMatrix (the whole user-management surface), the
10
+ // shadcn-derived UI kit, hazo_ui, and peer packages like sonner and the
11
+ // @radix-ui/* set. Bundlers cannot tree-shake most of that away, because these
12
+ // are "use client" modules with side effects.
13
+ //
14
+ // That is fine for a page that renders an auth layout. It is very expensive for
15
+ // a consuming app that only wants to know "is someone signed in?" in, say, a
16
+ // site header or a save button that renders on every page — a consumer doing
17
+ // exactly that measured its landing-page JS grow by more than an order of
18
+ // magnitude purely from reaching for `use_hazo_auth`.
19
+ //
20
+ // This entry point exposes the auth-state hooks and nothing else, so
21
+ // "read the session" costs a fetch wrapper rather than the whole UI kit.
22
+ // Components still come from "hazo_auth/client" (or a narrower subpath), and
23
+ // are best loaded lazily when they are actually needed.
24
+ // section: auth_state_hook_exports
25
+ export { use_auth_status, trigger_auth_status_refresh } from "./components/layouts/shared/hooks/use_auth_status.js";
26
+ export { use_hazo_auth, trigger_hazo_auth_refresh } from "./components/layouts/shared/hooks/use_hazo_auth.js";
27
+ // section: type_exports
28
+ // Type definitions are erased at runtime, so they cost nothing to re-export.
29
+ export * from "./lib/auth/auth_types.js";
@@ -1,4 +1,5 @@
1
1
  import "server-only";
2
+ import type { NextResponse } from "next/server";
2
3
  export type CookiesConfig = {
3
4
  /** Prefix for all hazo_auth cookies (e.g., "myapp_" results in "myapp_hazo_auth_session") */
4
5
  cookie_prefix: string;
@@ -43,4 +44,23 @@ export declare function get_cached_cookies_config(): CookiesConfig;
43
44
  * Clears the cached config (useful for testing)
44
45
  */
45
46
  export declare function clear_cookies_config_cache(): void;
47
+ /**
48
+ * Clears the three core hazo_auth session cookies (USER_EMAIL, USER_ID, SESSION)
49
+ * from a response, honoring the configured cookie prefix/domain. This is the same
50
+ * clearing logic used by the logout route; reuse it anywhere a session needs to be
51
+ * torn down (e.g. self-service account deletion) instead of re-implementing it.
52
+ * @param response - NextResponse object to clear cookies from
53
+ * @returns The same response, with cleared cookies (for chaining)
54
+ */
55
+ export declare function clear_session_cookies<T extends NextResponse>(response: T): T;
56
+ /**
57
+ * Clears the NextAuth.js cookies used by the Google OAuth flow (session token,
58
+ * CSRF token, callback URL — plus their `__Secure-`/`__Host-` production variants)
59
+ * from a response. This is the same clearing logic used by the logout route; reuse
60
+ * it anywhere a NextAuth-backed session needs to be torn down (e.g. self-service
61
+ * account deletion) instead of re-implementing it.
62
+ * @param response - NextResponse object to clear cookies from
63
+ * @returns The same response, with cleared cookies (for chaining)
64
+ */
65
+ export declare function clear_nextauth_cookies<T extends NextResponse>(response: T): T;
46
66
  //# sourceMappingURL=cookies_config.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookies_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/cookies_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAMrB,MAAM,MAAM,aAAa,GAAG;IAC1B,6FAA6F;IAC7F,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAYF,eAAO,MAAM,iBAAiB;;;;;;;;CAQpB,CAAC;AAGX;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,aAAa,C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AAC,GAAG,CAAC,CAW5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAiB7E"}
@@ -86,3 +86,46 @@ export function get_cached_cookies_config() {
86
86
  export function clear_cookies_config_cache() {
87
87
  cached_config = null;
88
88
  }
89
+ /**
90
+ * Clears the three core hazo_auth session cookies (USER_EMAIL, USER_ID, SESSION)
91
+ * from a response, honoring the configured cookie prefix/domain. This is the same
92
+ * clearing logic used by the logout route; reuse it anywhere a session needs to be
93
+ * torn down (e.g. self-service account deletion) instead of re-implementing it.
94
+ * @param response - NextResponse object to clear cookies from
95
+ * @returns The same response, with cleared cookies (for chaining)
96
+ */
97
+ export function clear_session_cookies(response) {
98
+ const clear_cookie_options = get_cookie_options({
99
+ expires: new Date(0),
100
+ path: "/",
101
+ });
102
+ response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_EMAIL), "", clear_cookie_options);
103
+ response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_ID), "", clear_cookie_options);
104
+ response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.SESSION), "", clear_cookie_options);
105
+ return response;
106
+ }
107
+ /**
108
+ * Clears the NextAuth.js cookies used by the Google OAuth flow (session token,
109
+ * CSRF token, callback URL — plus their `__Secure-`/`__Host-` production variants)
110
+ * from a response. This is the same clearing logic used by the logout route; reuse
111
+ * it anywhere a NextAuth-backed session needs to be torn down (e.g. self-service
112
+ * account deletion) instead of re-implementing it.
113
+ * @param response - NextResponse object to clear cookies from
114
+ * @returns The same response, with cleared cookies (for chaining)
115
+ */
116
+ export function clear_nextauth_cookies(response) {
117
+ const clear_cookie_options = {
118
+ expires: new Date(0),
119
+ path: "/",
120
+ };
121
+ response.cookies.set("next-auth.session-token", "", clear_cookie_options);
122
+ response.cookies.set("next-auth.csrf-token", "", clear_cookie_options);
123
+ response.cookies.set("next-auth.callback-url", "", clear_cookie_options);
124
+ // Also clear secure cookie variants (used in production with HTTPS)
125
+ response.cookies.set("__Secure-next-auth.session-token", "", clear_cookie_options);
126
+ response.cookies.set("__Secure-next-auth.csrf-token", "", clear_cookie_options);
127
+ response.cookies.set("__Secure-next-auth.callback-url", "", clear_cookie_options);
128
+ // Host-prefixed variants (for some NextAuth configurations)
129
+ response.cookies.set("__Host-next-auth.csrf-token", "", clear_cookie_options);
130
+ return response;
131
+ }
@@ -36,6 +36,8 @@ export type MySettingsConfig = {
36
36
  unauthorizedMessage?: string;
37
37
  loginButtonLabel?: string;
38
38
  loginPath?: string;
39
+ /** Opt-in self-service account deletion (Danger Zone). Default: false. */
40
+ enableAccountDeletion: boolean;
39
41
  messages: {
40
42
  photo_upload_disabled_message: string;
41
43
  gravatar_setup_message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"my_settings_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/my_settings_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAYrB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,oBAAoB,EAAE;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,OAAO,CAAC;QAC3B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,cAAc,EAAE,OAAO,CAAC;QACxB,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MA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AAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CA2DzD"}
@@ -2,7 +2,7 @@
2
2
  // section: server-only-guard
3
3
  import "server-only";
4
4
  // section: imports
5
- import { get_config_value } from "./config/config_loader.server.js";
5
+ import { get_config_value, get_config_boolean } from "./config/config_loader.server.js";
6
6
  import { get_user_fields_config } from "./user_fields_config.server.js";
7
7
  import { get_password_requirements_config } from "./password_requirements_config.server.js";
8
8
  import { get_profile_picture_config } from "./profile_picture_config.server.js";
@@ -43,6 +43,7 @@ export function get_my_settings_config() {
43
43
  const unauthorizedMessage = get_config_value(section, "unauthorized_message", "You must be logged in to access this page.");
44
44
  const loginButtonLabel = get_config_value(section, "login_button_label", "Go to login");
45
45
  const loginPath = get_config_value(section, "login_path", "/hazo_auth/login");
46
+ const enableAccountDeletion = get_config_boolean(section, "enable_account_deletion", false);
46
47
  return {
47
48
  userFields,
48
49
  passwordRequirements,
@@ -62,6 +63,7 @@ export function get_my_settings_config() {
62
63
  unauthorizedMessage,
63
64
  loginButtonLabel,
64
65
  loginPath,
66
+ enableAccountDeletion,
65
67
  messages,
66
68
  uiSizes,
67
69
  fileTypes,
@@ -0,0 +1,22 @@
1
+ export type AccountDeletionResult = {
2
+ success: boolean;
3
+ error?: string;
4
+ };
5
+ /**
6
+ * Hard-deletes the caller's own `hazo_users` row.
7
+ *
8
+ * Child rows cascade automatically via `ON DELETE CASCADE` foreign keys
9
+ * (hazo_refresh_tokens, hazo_user_scopes, hazo_user_relationships,
10
+ * hazo_email_otps, hazo_legal_acceptances, hazo_google_oauth_tokens,
11
+ * hazo_user_roles) — no manual cleanup needed. A few "created by" /
12
+ * "managed by" references (hazo_users.managed_by_user_id,
13
+ * hazo_invitations.invited_by, hazo_legal_doc_versions.published_by_user_id)
14
+ * intentionally use `ON DELETE SET NULL` instead of CASCADE, by design —
15
+ * they preserve audit/history/relationship rows rather than deleting them,
16
+ * so they likewise require no manual cleanup here.
17
+ *
18
+ * @param user_id - The authenticated caller's own user ID (never another user's)
19
+ * @returns AccountDeletionResult with success status or error
20
+ */
21
+ export declare function delete_own_account(user_id: string): Promise<AccountDeletionResult>;
22
+ //# sourceMappingURL=account_deletion_service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account_deletion_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/account_deletion_service.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC,CAiChC"}
@@ -0,0 +1,55 @@
1
+ // file_description: service for self-service (hard) deletion of the caller's own hazo_users row
2
+ // section: imports
3
+ import { createCrudService } from "hazo_connect/server";
4
+ import { get_hazo_connect_instance } from "../hazo_connect_instance.server.js";
5
+ import { create_app_logger } from "../app_logger.js";
6
+ import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
7
+ import { get_line_number } from "../utils/api_route_helpers.js";
8
+ // section: main_function
9
+ /**
10
+ * Hard-deletes the caller's own `hazo_users` row.
11
+ *
12
+ * Child rows cascade automatically via `ON DELETE CASCADE` foreign keys
13
+ * (hazo_refresh_tokens, hazo_user_scopes, hazo_user_relationships,
14
+ * hazo_email_otps, hazo_legal_acceptances, hazo_google_oauth_tokens,
15
+ * hazo_user_roles) — no manual cleanup needed. A few "created by" /
16
+ * "managed by" references (hazo_users.managed_by_user_id,
17
+ * hazo_invitations.invited_by, hazo_legal_doc_versions.published_by_user_id)
18
+ * intentionally use `ON DELETE SET NULL` instead of CASCADE, by design —
19
+ * they preserve audit/history/relationship rows rather than deleting them,
20
+ * so they likewise require no manual cleanup here.
21
+ *
22
+ * @param user_id - The authenticated caller's own user ID (never another user's)
23
+ * @returns AccountDeletionResult with success status or error
24
+ */
25
+ export async function delete_own_account(user_id) {
26
+ try {
27
+ const adapter = get_hazo_connect_instance();
28
+ const users_service = createCrudService(adapter, "hazo_users");
29
+ // Verify the user still exists before deleting
30
+ const users = await users_service.findBy({ id: user_id });
31
+ if (!Array.isArray(users) || users.length === 0) {
32
+ return { success: false, error: "User not found" };
33
+ }
34
+ await users_service.deleteById(user_id);
35
+ return { success: true };
36
+ }
37
+ catch (error) {
38
+ const logger = create_app_logger();
39
+ const user_friendly_error = sanitize_error_for_user(error, {
40
+ logToConsole: true,
41
+ logToLogger: true,
42
+ logger,
43
+ context: {
44
+ filename: "account_deletion_service.ts",
45
+ line_number: get_line_number(),
46
+ user_id,
47
+ operation: "delete_own_account",
48
+ },
49
+ });
50
+ return {
51
+ success: false,
52
+ error: user_friendly_error,
53
+ };
54
+ }
55
+ }
@@ -20,4 +20,5 @@ export * from "./oauth_service.js";
20
20
  export * from "./branding_service.js";
21
21
  export * from "./google_token_service.js";
22
22
  export * from "./demo_account_service.js";
23
+ export * from "./account_deletion_service.js";
23
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/services/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/services/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC"}
@@ -22,3 +22,4 @@ export * from "./oauth_service.js";
22
22
  export * from "./branding_service.js";
23
23
  export * from "./google_token_service.js";
24
24
  export * from "./demo_account_service.js";
25
+ export * from "./account_deletion_service.js";
@@ -46,6 +46,11 @@ export type MySettingsPageProps = {
46
46
  unauthorizedMessage?: string;
47
47
  loginButtonLabel?: string;
48
48
  loginPath?: string;
49
+ /**
50
+ * Whether the Danger Zone (account deletion) section is shown.
51
+ * Mirrors the `enable_account_deletion` config flag; defaults to off (opt-in).
52
+ */
53
+ enableAccountDeletion?: boolean;
49
54
  messages?: Partial<typeof DEFAULT_MESSAGES>;
50
55
  uiSizes?: Partial<typeof DEFAULT_UI_SIZES>;
51
56
  fileTypes?: {
@@ -59,6 +64,6 @@ export type MySettingsPageProps = {
59
64
  * @param props - Optional configuration overrides
60
65
  * @returns My settings page component
61
66
  */
62
- export declare function MySettingsPage({ userFields, passwordRequirements, profilePicture, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, savePasswordButtonLabel, unauthorizedMessage, loginButtonLabel, loginPath, messages, uiSizes, fileTypes, }?: MySettingsPageProps): import("react").JSX.Element;
67
+ export declare function MySettingsPage({ userFields, passwordRequirements, profilePicture, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, savePasswordButtonLabel, unauthorizedMessage, loginButtonLabel, loginPath, enableAccountDeletion, messages, uiSizes, fileTypes, }?: MySettingsPageProps): import("react").JSX.Element;
63
68
  export default MySettingsPage;
64
69
  //# sourceMappingURL=my_settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"my_settings.d.ts","sourceRoot":"","sources":["../../src/page_components/my_settings.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AA2B3G,QAAA,MAAM,gBAAgB;;;;;CAKrB,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;;;;;;CASrB,CAAC;AAQF,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,CAAC,EAAE;QACX,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;IACF,oBAAoB,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC3D,cAAc,CAAC,EAAE;QACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,4BAA4B,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;QACtD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,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AAO,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE;QACV,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;KACrC,CAAC;CACH,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,OAA4B,EAC5B,UAAoE,EACpE,iBAAmC,EACnC,0BAAiF,EACjF,sBAAuC,EACvC,sBAAiC,EACjC,uBAA+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,uBAA2C,EAC3C,mBAAkE,EAClE,gBAAgC,EAChC,SAA8B,EAC9B,qBAA6B,EAC7B,QAAQ,EACR,OAAO,EACP,SAAS,GACV,GAAE,mBAAwB,+BA2D1B;AAED,eAAe,cAAc,CAAC"}
@@ -53,7 +53,7 @@ const DEFAULT_FILE_TYPES = {
53
53
  * @param props - Optional configuration overrides
54
54
  * @returns My settings page component
55
55
  */
56
- export function MySettingsPage({ userFields, passwordRequirements, profilePicture, heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended: Square image, at least 200x200 pixels", uploadPhotoButtonLabel = "Upload Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", savePasswordButtonLabel = "Update Password", unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", messages, uiSizes, fileTypes, } = {}) {
56
+ export function MySettingsPage({ userFields, passwordRequirements, profilePicture, heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended: Square image, at least 200x200 pixels", uploadPhotoButtonLabel = "Upload Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", savePasswordButtonLabel = "Update Password", unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", enableAccountDeletion = false, messages, uiSizes, fileTypes, } = {}) {
57
57
  // Merge provided props with defaults
58
58
  const mergedUserFields = Object.assign(Object.assign({}, DEFAULT_USER_FIELDS), userFields);
59
59
  const mergedPasswordRequirements = Object.assign(Object.assign({}, DEFAULT_PASSWORD_REQUIREMENTS), passwordRequirements);
@@ -62,6 +62,6 @@ export function MySettingsPage({ userFields, passwordRequirements, profilePictur
62
62
  const mergedUiSizes = Object.assign(Object.assign({}, DEFAULT_UI_SIZES), uiSizes);
63
63
  const mergedFileTypes = Object.assign(Object.assign({}, DEFAULT_FILE_TYPES), fileTypes);
64
64
  const MySettingsLayout = my_settings_layout;
65
- return (_jsx(MySettingsLayout, { userFields: mergedUserFields, password_requirements: mergedPasswordRequirements, profilePicture: mergedProfilePicture, heading: heading, subHeading: subHeading, profilePhotoLabel: profilePhotoLabel, profilePhotoRecommendation: profilePhotoRecommendation, uploadPhotoButtonLabel: uploadPhotoButtonLabel, removePhotoButtonLabel: removePhotoButtonLabel, profileInformationLabel: profileInformationLabel, passwordLabel: passwordLabel, currentPasswordLabel: currentPasswordLabel, newPasswordLabel: newPasswordLabel, confirmPasswordLabel: confirmPasswordLabel, unauthorizedMessage: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, messages: mergedMessages, uiSizes: mergedUiSizes, fileTypes: mergedFileTypes }));
65
+ return (_jsx(MySettingsLayout, { userFields: mergedUserFields, password_requirements: mergedPasswordRequirements, profilePicture: mergedProfilePicture, heading: heading, subHeading: subHeading, profilePhotoLabel: profilePhotoLabel, profilePhotoRecommendation: profilePhotoRecommendation, uploadPhotoButtonLabel: uploadPhotoButtonLabel, removePhotoButtonLabel: removePhotoButtonLabel, profileInformationLabel: profileInformationLabel, passwordLabel: passwordLabel, currentPasswordLabel: currentPasswordLabel, newPasswordLabel: newPasswordLabel, confirmPasswordLabel: confirmPasswordLabel, unauthorizedMessage: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, enableAccountDeletion: enableAccountDeletion, messages: mergedMessages, uiSizes: mergedUiSizes, fileTypes: mergedFileTypes }));
66
66
  }
67
67
  export default MySettingsPage;
@@ -0,0 +1,17 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+ export declare const dynamic = "force-dynamic";
3
+ /**
4
+ * DELETE - Self-service hard-delete of the caller's own account.
5
+ * Body: { confirm_email: string } — must match the authenticated user's email
6
+ * address (case-insensitive) to confirm intent.
7
+ *
8
+ * Gated by `enable_account_deletion` (default: false) in the
9
+ * `[hazo_auth__my_settings_layout]` config section — opt-in, off by default.
10
+ */
11
+ export declare function DELETE(request: NextRequest): Promise<NextResponse<{
12
+ error: string;
13
+ }> | NextResponse<{
14
+ success: boolean;
15
+ message: string;
16
+ }>>;
17
+ //# sourceMappingURL=delete_account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete_account.d.ts","sourceRoot":"","sources":["../../../src/server/routes/delete_account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAcxD,eAAO,MAAM,OAAO,kBAAkB,CAAC;AAGvC;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,WAAW;;;;;IAsHhD"}
@@ -0,0 +1,107 @@
1
+ // file_description: API route handler for self-service (hard) account deletion
2
+ // section: imports
3
+ import { NextResponse } from "next/server";
4
+ import { hazo_get_auth } from "../../lib/auth/hazo_get_auth.server.js";
5
+ import { delete_own_account } from "../../lib/services/account_deletion_service.js";
6
+ import { create_app_logger } from "../../lib/app_logger.js";
7
+ import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
8
+ import { get_auth_cache } from "../../lib/auth/auth_cache.js";
9
+ import { get_auth_utility_config } from "../../lib/auth_utility_config.server.js";
10
+ import { get_config_boolean } from "../../lib/config/config_loader.server.js";
11
+ import { clear_session_cookies, clear_nextauth_cookies } from "../../lib/cookies_config.server.js";
12
+ // section: constants
13
+ const MY_SETTINGS_SECTION = "hazo_auth__my_settings_layout";
14
+ // section: route_config
15
+ export const dynamic = "force-dynamic";
16
+ // section: api_handler
17
+ /**
18
+ * DELETE - Self-service hard-delete of the caller's own account.
19
+ * Body: { confirm_email: string } — must match the authenticated user's email
20
+ * address (case-insensitive) to confirm intent.
21
+ *
22
+ * Gated by `enable_account_deletion` (default: false) in the
23
+ * `[hazo_auth__my_settings_layout]` config section — opt-in, off by default.
24
+ */
25
+ export async function DELETE(request) {
26
+ const logger = create_app_logger();
27
+ try {
28
+ // Resolve the caller
29
+ const auth = await hazo_get_auth(request);
30
+ if (!auth.user) {
31
+ return NextResponse.json({ error: "Authentication required" }, { status: 401 });
32
+ }
33
+ const user_id = auth.user.id;
34
+ // Feature is opt-in — refuse before doing any further work if disabled
35
+ const enabled = get_config_boolean(MY_SETTINGS_SECTION, "enable_account_deletion", false);
36
+ if (!enabled) {
37
+ logger.warn("account_deletion_disabled", {
38
+ filename: get_filename(),
39
+ line_number: get_line_number(),
40
+ user_id,
41
+ });
42
+ return NextResponse.json({ error: "Account deletion is not enabled" }, { status: 403 });
43
+ }
44
+ // Require the caller to re-type their own email address as confirmation
45
+ let body;
46
+ try {
47
+ body = await request.json();
48
+ }
49
+ catch (_a) {
50
+ body = {};
51
+ }
52
+ const confirm_email = typeof body.confirm_email === "string" ? body.confirm_email.trim() : "";
53
+ if (!confirm_email || confirm_email.toLowerCase() !== auth.user.email_address.toLowerCase()) {
54
+ logger.warn("account_deletion_confirmation_mismatch", {
55
+ filename: get_filename(),
56
+ line_number: get_line_number(),
57
+ user_id,
58
+ });
59
+ return NextResponse.json({ error: "Confirmation email does not match your account email" }, { status: 400 });
60
+ }
61
+ // Hard-delete the account (cascades to all related rows)
62
+ const result = await delete_own_account(user_id);
63
+ if (!result.success) {
64
+ logger.warn("account_deletion_failed", {
65
+ filename: get_filename(),
66
+ line_number: get_line_number(),
67
+ user_id,
68
+ error: result.error,
69
+ });
70
+ return NextResponse.json({ error: result.error || "Failed to delete account" }, { status: 400 });
71
+ }
72
+ // Invalidate auth cache now that the user is gone
73
+ try {
74
+ const auth_config = get_auth_utility_config();
75
+ const auth_cache = get_auth_cache(auth_config.cache_max_users, auth_config.cache_ttl_minutes, auth_config.cache_max_age_minutes);
76
+ auth_cache.invalidate_user(user_id);
77
+ }
78
+ catch (_b) {
79
+ // Non-fatal
80
+ }
81
+ logger.info("account_deletion_successful", {
82
+ filename: get_filename(),
83
+ line_number: get_line_number(),
84
+ user_id,
85
+ });
86
+ const response = NextResponse.json({
87
+ success: true,
88
+ message: "Account deleted successfully",
89
+ }, { status: 200 });
90
+ // Clear the three core hazo_auth session cookies — the account (and its session) no longer exists
91
+ clear_session_cookies(response);
92
+ // Also clear NextAuth cookies — a Google-OAuth user must not be left holding a live session-token
93
+ clear_nextauth_cookies(response);
94
+ return response;
95
+ }
96
+ catch (error) {
97
+ const error_message = error instanceof Error ? error.message : "Unknown error";
98
+ const error_stack = error instanceof Error ? error.stack : undefined;
99
+ logger.error("account_deletion_error", {
100
+ filename: get_filename(),
101
+ line_number: get_line_number(),
102
+ error_message,
103
+ error_stack,
104
+ });
105
+ return NextResponse.json({ error: "Failed to delete account. Please try again." }, { status: 500 });
106
+ }
107
+ }
@@ -11,6 +11,7 @@ export { POST as resendVerificationPOST } from "./resend_verification.js";
11
11
  export { PATCH as updateUserPATCH } from "./update_user.js";
12
12
  export { POST as uploadProfilePicturePOST } from "./upload_profile_picture.js";
13
13
  export { DELETE as removeProfilePictureDELETE } from "./remove_profile_picture.js";
14
+ export { DELETE as deleteAccountDELETE } from "./delete_account.js";
14
15
  export { GET as libraryPhotosGET } from "./library_photos.js";
15
16
  export { GET as libraryPhotoGET } from "./library_photo.js";
16
17
  export { GET as profilePictureFilenameGET } from "./profile_picture_filename.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/routes/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,IAAI,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,GAAG,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,IAAI,IAAI,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,IAAI,IAAI,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,MAAM,IAAI,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,GAAG,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,GAAG,IAAI,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACjD,OA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AAM,aAAa,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC"}
@@ -17,6 +17,7 @@ export { POST as resendVerificationPOST } from "./resend_verification.js";
17
17
  export { PATCH as updateUserPATCH } from "./update_user.js";
18
18
  export { POST as uploadProfilePicturePOST } from "./upload_profile_picture.js";
19
19
  export { DELETE as removeProfilePictureDELETE } from "./remove_profile_picture.js";
20
+ export { DELETE as deleteAccountDELETE } from "./delete_account.js";
20
21
  export { GET as libraryPhotosGET } from "./library_photos.js";
21
22
  export { GET as libraryPhotoGET } from "./library_photo.js";
22
23
  export { GET as profilePictureFilenameGET } from "./profile_picture_filename.js";
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/server/routes/logout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQxD,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW;;;;;IA8G9C"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/server/routes/logout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQxD,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW;;;;;IA0E9C"}
@@ -5,7 +5,7 @@ import { create_app_logger } from "../../lib/app_logger.js";
5
5
  import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
6
6
  import { get_auth_cache } from "../../lib/auth/auth_cache.js";
7
7
  import { get_auth_utility_config } from "../../lib/auth_utility_config.server.js";
8
- import { get_cookie_name, get_cookie_options, BASE_COOKIE_NAMES } from "../../lib/cookies_config.server.js";
8
+ import { get_cookie_name, BASE_COOKIE_NAMES, clear_session_cookies, clear_nextauth_cookies } from "../../lib/cookies_config.server.js";
9
9
  // section: api_handler
10
10
  export async function POST(request) {
11
11
  var _a, _b;
@@ -19,46 +19,10 @@ export async function POST(request) {
19
19
  success: true,
20
20
  message: "Logout successful",
21
21
  }, { status: 200 });
22
- // Clear cookies by setting them to expire in the past (with configurable domain)
23
- const clear_cookie_options = get_cookie_options({
24
- expires: new Date(0),
25
- path: "/",
26
- });
27
- response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_EMAIL), "", clear_cookie_options);
28
- response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_ID), "", clear_cookie_options);
29
- // Clear JWT session token cookie
30
- response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.SESSION), "", clear_cookie_options);
22
+ // Clear the three core hazo_auth session cookies (USER_EMAIL, USER_ID, SESSION)
23
+ clear_session_cookies(response);
31
24
  // Clear NextAuth session cookies (for OAuth users)
32
- response.cookies.set("next-auth.session-token", "", {
33
- expires: new Date(0),
34
- path: "/",
35
- });
36
- response.cookies.set("next-auth.csrf-token", "", {
37
- expires: new Date(0),
38
- path: "/",
39
- });
40
- response.cookies.set("next-auth.callback-url", "", {
41
- expires: new Date(0),
42
- path: "/",
43
- });
44
- // Also clear secure cookie variants (used in production with HTTPS)
45
- response.cookies.set("__Secure-next-auth.session-token", "", {
46
- expires: new Date(0),
47
- path: "/",
48
- });
49
- response.cookies.set("__Secure-next-auth.csrf-token", "", {
50
- expires: new Date(0),
51
- path: "/",
52
- });
53
- response.cookies.set("__Secure-next-auth.callback-url", "", {
54
- expires: new Date(0),
55
- path: "/",
56
- });
57
- // Host-prefixed variants (for some NextAuth configurations)
58
- response.cookies.set("__Host-next-auth.csrf-token", "", {
59
- expires: new Date(0),
60
- path: "/",
61
- });
25
+ clear_nextauth_cookies(response);
62
26
  // Invalidate user cache
63
27
  if (user_id) {
64
28
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"my_settings.d.ts","sourceRoot":"","sources":["../../src/server_pages/my_settings.tsx"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAQrB,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,SAAS,GACV,GAAE,mBAAwB,+BAgC1B;AAGD,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"my_settings.d.ts","sourceRoot":"","sources":["../../src/server_pages/my_settings.tsx"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAQrB,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,SAAS,GACV,GAAE,mBAAwB,+BAiC1B;AAGD,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -56,7 +56,7 @@ export default function MySettingsPage({ className, } = {}) {
56
56
  // Load configuration from INI file (with defaults)
57
57
  const config = get_my_settings_config();
58
58
  // Render layout with all server-initialized configuration, wrapped in AuthPageShell for navbar support
59
- return (_jsx(AuthPageShell, { children: _jsx(MySettingsLayout, { className: className, password_requirements: config.passwordRequirements, profilePicture: config.profilePicture, userFields: config.userFields, unauthorizedMessage: config.unauthorizedMessage, loginButtonLabel: config.loginButtonLabel, loginPath: config.loginPath, heading: config.heading, subHeading: config.subHeading, profilePhotoLabel: config.profilePhotoLabel, profilePhotoRecommendation: config.profilePhotoRecommendation, uploadPhotoButtonLabel: config.uploadPhotoButtonLabel, removePhotoButtonLabel: config.removePhotoButtonLabel, profileInformationLabel: config.profileInformationLabel, passwordLabel: config.passwordLabel, currentPasswordLabel: config.currentPasswordLabel, newPasswordLabel: config.newPasswordLabel, confirmPasswordLabel: config.confirmPasswordLabel, messages: config.messages, uiSizes: config.uiSizes, fileTypes: config.fileTypes }) }));
59
+ return (_jsx(AuthPageShell, { children: _jsx(MySettingsLayout, { className: className, password_requirements: config.passwordRequirements, profilePicture: config.profilePicture, userFields: config.userFields, unauthorizedMessage: config.unauthorizedMessage, loginButtonLabel: config.loginButtonLabel, loginPath: config.loginPath, enableAccountDeletion: config.enableAccountDeletion, heading: config.heading, subHeading: config.subHeading, profilePhotoLabel: config.profilePhotoLabel, profilePhotoRecommendation: config.profilePhotoRecommendation, uploadPhotoButtonLabel: config.uploadPhotoButtonLabel, removePhotoButtonLabel: config.removePhotoButtonLabel, profileInformationLabel: config.profileInformationLabel, passwordLabel: config.passwordLabel, currentPasswordLabel: config.currentPasswordLabel, newPasswordLabel: config.newPasswordLabel, confirmPasswordLabel: config.confirmPasswordLabel, messages: config.messages, uiSizes: config.uiSizes, fileTypes: config.fileTypes }) }));
60
60
  }
61
61
  // Named export for direct imports
62
62
  export { MySettingsPage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "10.9.0",
3
+ "version": "10.11.0",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",
@@ -41,6 +41,10 @@
41
41
  "types": "./dist/client.d.ts",
42
42
  "import": "./dist/client.js"
43
43
  },
44
+ "./hooks": {
45
+ "types": "./dist/hooks.d.ts",
46
+ "import": "./dist/hooks.js"
47
+ },
44
48
  "./server-lib": {
45
49
  "types": "./dist/server-lib.d.ts",
46
50
  "import": "./dist/server-lib.js"
@@ -265,15 +269,15 @@
265
269
  "hazo_api": "^2.6.0",
266
270
  "hazo_config": "^2.4.1",
267
271
  "hazo_connect": "^3.9.2",
268
- "hazo_core": "^1.2.1",
272
+ "hazo_core": "^1.3.0",
269
273
  "hazo_logs": "^2.1.1",
270
274
  "hazo_notify": "^6.1.4",
271
- "hazo_secure": "^1.4.0",
275
+ "hazo_secure": "^1.7.0",
272
276
  "hazo_theme": "^1.0.1",
273
- "hazo_ui": "^6.1.0",
277
+ "hazo_ui": "^6.3.1",
274
278
  "input-otp": "^1.4.0",
275
279
  "lucide-react": "^0.553.0",
276
- "next": "^14.0.0",
280
+ "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
277
281
  "next-auth": "^4.24.0",
278
282
  "next-themes": "^0.4.0",
279
283
  "react": "^18.0.0 || ^19.0.0",
@@ -409,11 +413,11 @@
409
413
  "hazo_api": "^2.6.0",
410
414
  "hazo_config": "^2.4.1",
411
415
  "hazo_connect": "^3.9.2",
412
- "hazo_core": "^1.2.1",
416
+ "hazo_core": "^1.3.0",
413
417
  "hazo_logs": "^2.1.1",
414
418
  "hazo_notify": "^6.1.4",
415
419
  "hazo_theme": "^1.0.1",
416
- "hazo_ui": "^6.1.0",
420
+ "hazo_ui": "^6.3.1",
417
421
  "input-otp": "^1.4.0",
418
422
  "jest": "^30.2.0",
419
423
  "jest-environment-jsdom": "^30.0.0",