hazo_auth 4.1.0 → 4.3.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 (157) hide show
  1. package/README.md +230 -0
  2. package/SETUP_CHECKLIST.md +202 -0
  3. package/bin/hazo_auth.mjs +35 -0
  4. package/cli-src/assets/images/forgot_password_default.jpg +0 -0
  5. package/cli-src/assets/images/login_default.jpg +0 -0
  6. package/cli-src/assets/images/register_default.jpg +0 -0
  7. package/cli-src/assets/images/reset_password_default.jpg +0 -0
  8. package/cli-src/assets/images/verify_email_default.jpg +0 -0
  9. package/cli-src/cli/generate.ts +276 -0
  10. package/cli-src/cli/index.ts +207 -0
  11. package/cli-src/cli/init.ts +254 -0
  12. package/cli-src/cli/init_users.ts +376 -0
  13. package/cli-src/cli/validate.ts +581 -0
  14. package/cli-src/lib/already_logged_in_config.server.ts +46 -0
  15. package/cli-src/lib/app_logger.ts +24 -0
  16. package/cli-src/lib/auth/auth_cache.ts +220 -0
  17. package/cli-src/lib/auth/auth_rate_limiter.ts +121 -0
  18. package/cli-src/lib/auth/auth_types.ts +110 -0
  19. package/cli-src/lib/auth/auth_utils.server.ts +196 -0
  20. package/cli-src/lib/auth/hazo_get_auth.server.ts +512 -0
  21. package/cli-src/lib/auth/index.ts +23 -0
  22. package/cli-src/lib/auth/nextauth_config.ts +227 -0
  23. package/cli-src/lib/auth/scope_cache.ts +233 -0
  24. package/cli-src/lib/auth/server_auth.ts +88 -0
  25. package/cli-src/lib/auth/session_token_validator.edge.ts +91 -0
  26. package/cli-src/lib/auth_utility_config.server.ts +136 -0
  27. package/cli-src/lib/config/config_loader.server.ts +164 -0
  28. package/cli-src/lib/config/default_config.ts +199 -0
  29. package/cli-src/lib/email_verification_config.server.ts +63 -0
  30. package/cli-src/lib/file_types_config.server.ts +25 -0
  31. package/cli-src/lib/forgot_password_config.server.ts +63 -0
  32. package/cli-src/lib/hazo_connect_instance.server.ts +101 -0
  33. package/cli-src/lib/hazo_connect_setup.server.ts +194 -0
  34. package/cli-src/lib/hazo_connect_setup.ts +54 -0
  35. package/cli-src/lib/index.ts +46 -0
  36. package/cli-src/lib/login_config.server.ts +106 -0
  37. package/cli-src/lib/messages_config.server.ts +45 -0
  38. package/cli-src/lib/migrations/apply_migration.ts +105 -0
  39. package/cli-src/lib/my_settings_config.server.ts +135 -0
  40. package/cli-src/lib/oauth_config.server.ts +87 -0
  41. package/cli-src/lib/password_requirements_config.server.ts +40 -0
  42. package/cli-src/lib/profile_pic_menu_config.server.ts +138 -0
  43. package/cli-src/lib/profile_picture_config.server.ts +56 -0
  44. package/cli-src/lib/register_config.server.ts +101 -0
  45. package/cli-src/lib/reset_password_config.server.ts +103 -0
  46. package/cli-src/lib/scope_hierarchy_config.server.ts +151 -0
  47. package/cli-src/lib/services/email_service.ts +587 -0
  48. package/cli-src/lib/services/email_verification_service.ts +270 -0
  49. package/cli-src/lib/services/index.ts +16 -0
  50. package/cli-src/lib/services/login_service.ts +150 -0
  51. package/cli-src/lib/services/oauth_service.ts +494 -0
  52. package/cli-src/lib/services/password_change_service.ts +154 -0
  53. package/cli-src/lib/services/password_reset_service.ts +418 -0
  54. package/cli-src/lib/services/profile_picture_remove_service.ts +120 -0
  55. package/cli-src/lib/services/profile_picture_service.ts +451 -0
  56. package/cli-src/lib/services/profile_picture_source_mapper.ts +62 -0
  57. package/cli-src/lib/services/registration_service.ts +185 -0
  58. package/cli-src/lib/services/scope_labels_service.ts +348 -0
  59. package/cli-src/lib/services/scope_service.ts +778 -0
  60. package/cli-src/lib/services/session_token_service.ts +177 -0
  61. package/cli-src/lib/services/token_service.ts +240 -0
  62. package/cli-src/lib/services/user_profiles_cache.ts +189 -0
  63. package/cli-src/lib/services/user_profiles_service.ts +264 -0
  64. package/cli-src/lib/services/user_scope_service.ts +554 -0
  65. package/cli-src/lib/services/user_update_service.ts +141 -0
  66. package/cli-src/lib/ui_shell_config.server.ts +73 -0
  67. package/cli-src/lib/ui_sizes_config.server.ts +37 -0
  68. package/cli-src/lib/user_fields_config.server.ts +31 -0
  69. package/cli-src/lib/user_management_config.server.ts +39 -0
  70. package/cli-src/lib/user_profiles_config.server.ts +55 -0
  71. package/cli-src/lib/utils/api_route_helpers.ts +60 -0
  72. package/cli-src/lib/utils/error_sanitizer.ts +75 -0
  73. package/cli-src/lib/utils/password_validator.ts +65 -0
  74. package/cli-src/lib/utils.ts +11 -0
  75. package/cli-src/server/logging/logger_service.ts +56 -0
  76. package/dist/app/api/hazo_auth/forgot_password/route.d.ts.map +1 -1
  77. package/dist/app/api/hazo_auth/forgot_password/route.js +15 -0
  78. package/dist/app/api/hazo_auth/logout/route.d.ts.map +1 -1
  79. package/dist/app/api/hazo_auth/logout/route.js +31 -0
  80. package/dist/app/api/hazo_auth/me/route.d.ts.map +1 -1
  81. package/dist/app/api/hazo_auth/me/route.js +10 -0
  82. package/dist/cli/index.js +18 -0
  83. package/dist/cli/init_users.d.ts +17 -0
  84. package/dist/cli/init_users.d.ts.map +1 -0
  85. package/dist/cli/init_users.js +307 -0
  86. package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts +2 -0
  87. package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
  88. package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +8 -0
  89. package/dist/components/layouts/forgot_password/index.d.ts +7 -1
  90. package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
  91. package/dist/components/layouts/forgot_password/index.js +7 -2
  92. package/dist/components/layouts/login/index.d.ts +13 -1
  93. package/dist/components/layouts/login/index.d.ts.map +1 -1
  94. package/dist/components/layouts/login/index.js +11 -2
  95. package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts +17 -0
  96. package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -0
  97. package/dist/components/layouts/my_settings/components/connected_accounts_section.js +17 -0
  98. package/dist/components/layouts/my_settings/components/set_password_section.d.ts +26 -0
  99. package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -0
  100. package/dist/components/layouts/my_settings/components/set_password_section.js +127 -0
  101. package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +3 -0
  102. package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
  103. package/dist/components/layouts/my_settings/hooks/use_my_settings.js +9 -0
  104. package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
  105. package/dist/components/layouts/my_settings/index.js +4 -2
  106. package/dist/components/layouts/shared/components/google_icon.d.ts +12 -0
  107. package/dist/components/layouts/shared/components/google_icon.d.ts.map +1 -0
  108. package/dist/components/layouts/shared/components/google_icon.js +9 -0
  109. package/dist/components/layouts/shared/components/google_sign_in_button.d.ts +21 -0
  110. package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -0
  111. package/dist/components/layouts/shared/components/google_sign_in_button.js +50 -0
  112. package/dist/components/layouts/shared/components/oauth_divider.d.ts +13 -0
  113. package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -0
  114. package/dist/components/layouts/shared/components/oauth_divider.js +13 -0
  115. package/dist/components/layouts/shared/config/layout_customization.d.ts +2 -7
  116. package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
  117. package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +3 -0
  118. package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
  119. package/dist/components/layouts/shared/hooks/use_auth_status.js +4 -0
  120. package/dist/components/layouts/shared/index.d.ts +5 -0
  121. package/dist/components/layouts/shared/index.d.ts.map +1 -1
  122. package/dist/components/layouts/shared/index.js +3 -0
  123. package/dist/components/ui/button.d.ts +1 -1
  124. package/dist/lib/auth/nextauth_config.d.ts +34 -0
  125. package/dist/lib/auth/nextauth_config.d.ts.map +1 -0
  126. package/dist/lib/auth/nextauth_config.js +171 -0
  127. package/dist/lib/config/default_config.d.ts +24 -0
  128. package/dist/lib/config/default_config.d.ts.map +1 -1
  129. package/dist/lib/config/default_config.js +14 -0
  130. package/dist/lib/index.d.ts +2 -0
  131. package/dist/lib/index.d.ts.map +1 -1
  132. package/dist/lib/index.js +1 -0
  133. package/dist/lib/login_config.server.d.ts +3 -0
  134. package/dist/lib/login_config.server.d.ts.map +1 -1
  135. package/dist/lib/login_config.server.js +4 -0
  136. package/dist/lib/oauth_config.server.d.ts +29 -0
  137. package/dist/lib/oauth_config.server.d.ts.map +1 -0
  138. package/dist/lib/oauth_config.server.js +40 -0
  139. package/dist/lib/services/login_service.d.ts.map +1 -1
  140. package/dist/lib/services/login_service.js +16 -1
  141. package/dist/lib/services/oauth_service.d.ts +88 -0
  142. package/dist/lib/services/oauth_service.d.ts.map +1 -0
  143. package/dist/lib/services/oauth_service.js +376 -0
  144. package/dist/lib/services/password_reset_service.d.ts +2 -0
  145. package/dist/lib/services/password_reset_service.d.ts.map +1 -1
  146. package/dist/lib/services/password_reset_service.js +10 -0
  147. package/dist/lib/services/registration_service.d.ts.map +1 -1
  148. package/dist/lib/services/registration_service.js +1 -0
  149. package/dist/lib/utils/password_validator.d.ts +19 -0
  150. package/dist/lib/utils/password_validator.d.ts.map +1 -0
  151. package/dist/lib/utils/password_validator.js +36 -0
  152. package/dist/server_pages/login.d.ts.map +1 -1
  153. package/dist/server_pages/login.js +6 -1
  154. package/dist/server_pages/login_client_wrapper.d.ts +5 -2
  155. package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
  156. package/dist/server_pages/login_client_wrapper.js +2 -2
  157. package/package.json +6 -2
@@ -0,0 +1,581 @@
1
+ // file_description: validation logic for hazo_auth setup verification
2
+ // This module contains all the validation checks that can be run via CLI or programmatically
3
+
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+
7
+ // section: types
8
+ type CheckStatus = "pass" | "fail" | "warn";
9
+
10
+ type CheckResult = {
11
+ name: string;
12
+ status: CheckStatus;
13
+ message: string;
14
+ };
15
+
16
+ export type ValidationSummary = {
17
+ passed: number;
18
+ failed: number;
19
+ warnings: number;
20
+ results: CheckResult[];
21
+ };
22
+
23
+ // section: constants
24
+ const REQUIRED_CONFIG_FILES = [
25
+ "hazo_auth_config.ini",
26
+ "hazo_notify_config.ini",
27
+ ];
28
+
29
+ const REQUIRED_ENV_VARS = [
30
+ { name: "JWT_SECRET", required: true, description: "JWT signing secret" },
31
+ { name: "ZEPTOMAIL_API_KEY", required: false, description: "Email API key (required for email)" },
32
+ { name: "HAZO_CONNECT_POSTGREST_API_KEY", required: false, description: "PostgREST API key (if using PostgreSQL)" },
33
+ ];
34
+
35
+ const REQUIRED_API_ROUTES = [
36
+ { path: "api/hazo_auth/login", method: "POST" },
37
+ { path: "api/hazo_auth/register", method: "POST" },
38
+ { path: "api/hazo_auth/logout", method: "POST" },
39
+ { path: "api/hazo_auth/me", method: "GET" },
40
+ { path: "api/hazo_auth/forgot_password", method: "POST" },
41
+ { path: "api/hazo_auth/reset_password", method: "POST" },
42
+ { path: "api/hazo_auth/verify_email", method: "GET" },
43
+ { path: "api/hazo_auth/resend_verification", method: "POST" },
44
+ { path: "api/hazo_auth/update_user", method: "PATCH" },
45
+ { path: "api/hazo_auth/change_password", method: "POST" },
46
+ { path: "api/hazo_auth/upload_profile_picture", method: "POST" },
47
+ { path: "api/hazo_auth/remove_profile_picture", method: "DELETE" },
48
+ { path: "api/hazo_auth/library_photos", method: "GET" },
49
+ { path: "api/hazo_auth/get_auth", method: "POST" },
50
+ { path: "api/hazo_auth/validate_reset_token", method: "POST" },
51
+ { path: "api/hazo_auth/profile_picture/[filename]", method: "GET" },
52
+ // User management routes
53
+ { path: "api/hazo_auth/user_management/users", method: "GET" },
54
+ { path: "api/hazo_auth/user_management/users", method: "PATCH" },
55
+ { path: "api/hazo_auth/user_management/users", method: "POST" },
56
+ { path: "api/hazo_auth/user_management/permissions", method: "GET" },
57
+ { path: "api/hazo_auth/user_management/permissions", method: "POST" },
58
+ { path: "api/hazo_auth/user_management/permissions", method: "PUT" },
59
+ { path: "api/hazo_auth/user_management/permissions", method: "DELETE" },
60
+ { path: "api/hazo_auth/user_management/roles", method: "GET" },
61
+ { path: "api/hazo_auth/user_management/roles", method: "POST" },
62
+ { path: "api/hazo_auth/user_management/roles", method: "PUT" },
63
+ { path: "api/hazo_auth/user_management/users/roles", method: "GET" },
64
+ { path: "api/hazo_auth/user_management/users/roles", method: "POST" },
65
+ { path: "api/hazo_auth/user_management/users/roles", method: "PUT" },
66
+ ];
67
+
68
+ // section: helpers
69
+ function get_project_root(): string {
70
+ return process.cwd();
71
+ }
72
+
73
+ function file_exists(filepath: string): boolean {
74
+ try {
75
+ return fs.existsSync(filepath);
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ function read_ini_file(filepath: string): Record<string, Record<string, string>> | null {
82
+ try {
83
+ const content = fs.readFileSync(filepath, "utf-8");
84
+ const result: Record<string, Record<string, string>> = {};
85
+ let current_section = "";
86
+
87
+ for (const line of content.split("\n")) {
88
+ const trimmed = line.trim();
89
+
90
+ if (trimmed.startsWith("#") || trimmed.startsWith(";") || !trimmed) {
91
+ continue;
92
+ }
93
+
94
+ const section_match = trimmed.match(/^\[(.+)\]$/);
95
+ if (section_match) {
96
+ current_section = section_match[1];
97
+ result[current_section] = result[current_section] || {};
98
+ continue;
99
+ }
100
+
101
+ const kv_match = trimmed.match(/^([^=]+)=(.*)$/);
102
+ if (kv_match && current_section) {
103
+ const key = kv_match[1].trim();
104
+ const value = kv_match[2].trim();
105
+ result[current_section][key] = value;
106
+ }
107
+ }
108
+
109
+ return result;
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+
115
+ function print_status(status: CheckStatus): string {
116
+ switch (status) {
117
+ case "pass":
118
+ return "\x1b[32m[PASS]\x1b[0m";
119
+ case "fail":
120
+ return "\x1b[31m[FAIL]\x1b[0m";
121
+ case "warn":
122
+ return "\x1b[33m[WARN]\x1b[0m";
123
+ }
124
+ }
125
+
126
+ function print_result(result: CheckResult): void {
127
+ console.log(`${print_status(result.status)} ${result.name}`);
128
+ if (result.message && (result.status === "fail" || result.status === "warn")) {
129
+ console.log(` → ${result.message}`);
130
+ }
131
+ }
132
+
133
+ // section: check_functions
134
+ function check_config_files(project_root: string): CheckResult[] {
135
+ const results: CheckResult[] = [];
136
+
137
+ for (const config_file of REQUIRED_CONFIG_FILES) {
138
+ const filepath = path.join(project_root, config_file);
139
+ const exists = file_exists(filepath);
140
+
141
+ results.push({
142
+ name: `Config file: ${config_file}`,
143
+ status: exists ? "pass" : "fail",
144
+ message: exists ? "" : `File not found. Run: cp node_modules/hazo_auth/${config_file.replace(".ini", ".example.ini")} ./${config_file}`,
145
+ });
146
+ }
147
+
148
+ return results;
149
+ }
150
+
151
+ function check_config_values(project_root: string): CheckResult[] {
152
+ const results: CheckResult[] = [];
153
+
154
+ const hazo_config_path = path.join(project_root, "hazo_auth_config.ini");
155
+ const hazo_config = read_ini_file(hazo_config_path);
156
+
157
+ if (hazo_config) {
158
+ const db_type = hazo_config["hazo_connect"]?.["type"];
159
+ if (db_type) {
160
+ results.push({
161
+ name: "Database type configured",
162
+ status: "pass",
163
+ message: `Using: ${db_type}`,
164
+ });
165
+
166
+ if (db_type === "sqlite") {
167
+ const sqlite_path = hazo_config["hazo_connect"]?.["sqlite_path"];
168
+ if (sqlite_path) {
169
+ results.push({
170
+ name: "SQLite path configured",
171
+ status: "pass",
172
+ message: sqlite_path,
173
+ });
174
+ } else {
175
+ results.push({
176
+ name: "SQLite path configured",
177
+ status: "fail",
178
+ message: "sqlite_path not set in [hazo_connect] section",
179
+ });
180
+ }
181
+ } else if (db_type === "postgrest") {
182
+ const postgrest_url = hazo_config["hazo_connect"]?.["postgrest_url"];
183
+ if (postgrest_url) {
184
+ results.push({
185
+ name: "PostgREST URL configured",
186
+ status: "pass",
187
+ message: postgrest_url,
188
+ });
189
+ } else {
190
+ results.push({
191
+ name: "PostgREST URL configured",
192
+ status: "fail",
193
+ message: "postgrest_url not set in [hazo_connect] section",
194
+ });
195
+ }
196
+ }
197
+ } else {
198
+ results.push({
199
+ name: "Database type configured",
200
+ status: "fail",
201
+ message: "type not set in [hazo_connect] section",
202
+ });
203
+ }
204
+
205
+ const layout_mode = hazo_config["hazo_auth__ui_shell"]?.["layout_mode"];
206
+ if (layout_mode === "standalone") {
207
+ results.push({
208
+ name: "UI shell mode",
209
+ status: "pass",
210
+ message: "standalone (recommended for consuming projects)",
211
+ });
212
+ } else if (layout_mode === "test_sidebar") {
213
+ results.push({
214
+ name: "UI shell mode",
215
+ status: "warn",
216
+ message: "test_sidebar - consider changing to 'standalone' for consuming projects",
217
+ });
218
+ } else {
219
+ results.push({
220
+ name: "UI shell mode",
221
+ status: "warn",
222
+ message: "Not set - defaults to test_sidebar. Consider setting to 'standalone'",
223
+ });
224
+ }
225
+ }
226
+
227
+ const notify_config_path = path.join(project_root, "hazo_notify_config.ini");
228
+ const notify_config = read_ini_file(notify_config_path);
229
+
230
+ if (notify_config) {
231
+ const from_email = notify_config["emailer"]?.["from_email"];
232
+ const from_name = notify_config["emailer"]?.["from_name"];
233
+
234
+ if (from_email && !from_email.includes("example.com")) {
235
+ results.push({
236
+ name: "Email from_email configured",
237
+ status: "pass",
238
+ message: from_email,
239
+ });
240
+ } else {
241
+ results.push({
242
+ name: "Email from_email configured",
243
+ status: "warn",
244
+ message: from_email ? "Using example.com - update to your domain" : "Not set",
245
+ });
246
+ }
247
+
248
+ if (from_name && from_name !== "Your App Name") {
249
+ results.push({
250
+ name: "Email from_name configured",
251
+ status: "pass",
252
+ message: from_name,
253
+ });
254
+ } else {
255
+ results.push({
256
+ name: "Email from_name configured",
257
+ status: "warn",
258
+ message: "Using default - update to your app name",
259
+ });
260
+ }
261
+ }
262
+
263
+ return results;
264
+ }
265
+
266
+ function check_env_vars(): CheckResult[] {
267
+ const results: CheckResult[] = [];
268
+
269
+ for (const env_var of REQUIRED_ENV_VARS) {
270
+ const value = process.env[env_var.name];
271
+ const has_value = value && value.length > 0;
272
+
273
+ if (env_var.required) {
274
+ results.push({
275
+ name: `Environment: ${env_var.name}`,
276
+ status: has_value ? "pass" : "fail",
277
+ message: has_value ? "Set" : `Not set - ${env_var.description}`,
278
+ });
279
+ } else {
280
+ results.push({
281
+ name: `Environment: ${env_var.name}`,
282
+ status: has_value ? "pass" : "warn",
283
+ message: has_value ? "Set" : `Not set - ${env_var.description}`,
284
+ });
285
+ }
286
+ }
287
+
288
+ return results;
289
+ }
290
+
291
+ function check_api_routes(project_root: string): CheckResult[] {
292
+ const results: CheckResult[] = [];
293
+
294
+ const possible_app_dirs = [
295
+ path.join(project_root, "app"),
296
+ path.join(project_root, "src", "app"),
297
+ ];
298
+
299
+ let app_dir: string | null = null;
300
+ for (const dir of possible_app_dirs) {
301
+ if (file_exists(dir)) {
302
+ app_dir = dir;
303
+ break;
304
+ }
305
+ }
306
+
307
+ if (!app_dir) {
308
+ results.push({
309
+ name: "App directory",
310
+ status: "fail",
311
+ message: "Could not find app/ or src/app/ directory",
312
+ });
313
+ return results;
314
+ }
315
+
316
+ results.push({
317
+ name: "App directory",
318
+ status: "pass",
319
+ message: app_dir.replace(project_root, "."),
320
+ });
321
+
322
+ let routes_found = 0;
323
+ let routes_missing = 0;
324
+
325
+ for (const route of REQUIRED_API_ROUTES) {
326
+ const route_path = path.join(app_dir, route.path, "route.ts");
327
+ const route_path_js = path.join(app_dir, route.path, "route.js");
328
+ const exists = file_exists(route_path) || file_exists(route_path_js);
329
+
330
+ if (exists) {
331
+ routes_found++;
332
+ } else {
333
+ routes_missing++;
334
+ results.push({
335
+ name: `Route: /${route.path}`,
336
+ status: "fail",
337
+ message: `Missing - create ${route.path}/route.ts with export { ${route.method} } from "hazo_auth/server/routes/..."`,
338
+ });
339
+ }
340
+ }
341
+
342
+ if (routes_missing === 0) {
343
+ results.push({
344
+ name: `API Routes (${routes_found}/${REQUIRED_API_ROUTES.length})`,
345
+ status: "pass",
346
+ message: "All routes present",
347
+ });
348
+ } else {
349
+ results.unshift({
350
+ name: `API Routes (${routes_found}/${REQUIRED_API_ROUTES.length})`,
351
+ status: "fail",
352
+ message: `${routes_missing} routes missing - run: npx hazo_auth generate-routes`,
353
+ });
354
+ }
355
+
356
+ return results;
357
+ }
358
+
359
+ function check_profile_pictures(project_root: string): CheckResult[] {
360
+ const results: CheckResult[] = [];
361
+
362
+ const library_path = path.join(project_root, "public", "profile_pictures", "library");
363
+ const uploads_path = path.join(project_root, "public", "profile_pictures", "uploads");
364
+
365
+ if (file_exists(library_path)) {
366
+ try {
367
+ const files = fs.readdirSync(library_path);
368
+ const image_files = files.filter(f => /\.(jpg|jpeg|png|gif|webp)$/i.test(f));
369
+
370
+ if (image_files.length > 0) {
371
+ results.push({
372
+ name: "Profile picture library",
373
+ status: "pass",
374
+ message: `${image_files.length} images available`,
375
+ });
376
+ } else {
377
+ results.push({
378
+ name: "Profile picture library",
379
+ status: "warn",
380
+ message: "Directory exists but no images found",
381
+ });
382
+ }
383
+ } catch {
384
+ results.push({
385
+ name: "Profile picture library",
386
+ status: "warn",
387
+ message: "Could not read directory",
388
+ });
389
+ }
390
+ } else {
391
+ results.push({
392
+ name: "Profile picture library",
393
+ status: "warn",
394
+ message: "Not found - copy from node_modules/hazo_auth/public/profile_pictures/library/",
395
+ });
396
+ }
397
+
398
+ if (file_exists(uploads_path)) {
399
+ results.push({
400
+ name: "Profile picture uploads directory",
401
+ status: "pass",
402
+ message: "Exists",
403
+ });
404
+ } else {
405
+ results.push({
406
+ name: "Profile picture uploads directory",
407
+ status: "warn",
408
+ message: "Not found - will be created on first upload",
409
+ });
410
+ }
411
+
412
+ return results;
413
+ }
414
+
415
+ function check_database(project_root: string): CheckResult[] {
416
+ const results: CheckResult[] = [];
417
+
418
+ const hazo_config_path = path.join(project_root, "hazo_auth_config.ini");
419
+ const hazo_config = read_ini_file(hazo_config_path);
420
+
421
+ if (!hazo_config) {
422
+ results.push({
423
+ name: "Database check",
424
+ status: "fail",
425
+ message: "Could not read hazo_auth_config.ini",
426
+ });
427
+ return results;
428
+ }
429
+
430
+ const db_type = hazo_config["hazo_connect"]?.["type"];
431
+
432
+ if (db_type === "sqlite") {
433
+ const sqlite_path = hazo_config["hazo_connect"]?.["sqlite_path"];
434
+ if (sqlite_path) {
435
+ const full_path = path.isAbsolute(sqlite_path)
436
+ ? sqlite_path
437
+ : path.join(project_root, sqlite_path);
438
+
439
+ if (file_exists(full_path)) {
440
+ results.push({
441
+ name: "SQLite database file",
442
+ status: "pass",
443
+ message: full_path.replace(project_root, "."),
444
+ });
445
+
446
+ try {
447
+ const stats = fs.statSync(full_path);
448
+ if (stats.size > 0) {
449
+ results.push({
450
+ name: "SQLite database readable",
451
+ status: "pass",
452
+ message: `File size: ${(stats.size / 1024).toFixed(2)} KB`,
453
+ });
454
+ } else {
455
+ results.push({
456
+ name: "SQLite database readable",
457
+ status: "warn",
458
+ message: "Database file is empty - tables may need to be created",
459
+ });
460
+ }
461
+ } catch {
462
+ results.push({
463
+ name: "SQLite database readable",
464
+ status: "fail",
465
+ message: "Could not read database file",
466
+ });
467
+ }
468
+ } else {
469
+ const parent_dir = path.dirname(full_path);
470
+ if (file_exists(parent_dir)) {
471
+ results.push({
472
+ name: "SQLite database file",
473
+ status: "warn",
474
+ message: "File not found - will be created on first use",
475
+ });
476
+ } else {
477
+ results.push({
478
+ name: "SQLite database file",
479
+ status: "fail",
480
+ message: `Parent directory not found: ${parent_dir}. Create it with: mkdir -p ${parent_dir}`,
481
+ });
482
+ }
483
+ }
484
+ }
485
+ } else if (db_type === "postgrest") {
486
+ const postgrest_url = hazo_config["hazo_connect"]?.["postgrest_url"];
487
+ if (postgrest_url) {
488
+ results.push({
489
+ name: "PostgREST connection",
490
+ status: "pass",
491
+ message: `URL configured: ${postgrest_url}`,
492
+ });
493
+ results.push({
494
+ name: "PostgREST tables",
495
+ status: "warn",
496
+ message: "Cannot verify tables remotely - ensure all hazo_* tables exist in PostgreSQL",
497
+ });
498
+ } else {
499
+ results.push({
500
+ name: "PostgREST connection",
501
+ status: "fail",
502
+ message: "postgrest_url not configured",
503
+ });
504
+ }
505
+ }
506
+
507
+ return results;
508
+ }
509
+
510
+ // section: main
511
+ export function run_validation(): ValidationSummary {
512
+ const project_root = get_project_root();
513
+ const all_results: CheckResult[] = [];
514
+
515
+ console.log("\n\x1b[1m🐸 hazo_auth Setup Validation\x1b[0m");
516
+ console.log("=".repeat(50));
517
+ console.log(`Project root: ${project_root}\n`);
518
+
519
+ console.log("\x1b[1m📁 Configuration Files\x1b[0m");
520
+ const config_results = check_config_files(project_root);
521
+ config_results.forEach(print_result);
522
+ all_results.push(...config_results);
523
+ console.log();
524
+
525
+ console.log("\x1b[1m⚙️ Configuration Values\x1b[0m");
526
+ const value_results = check_config_values(project_root);
527
+ value_results.forEach(print_result);
528
+ all_results.push(...value_results);
529
+ console.log();
530
+
531
+ console.log("\x1b[1m🔐 Environment Variables\x1b[0m");
532
+ const env_results = check_env_vars();
533
+ env_results.forEach(print_result);
534
+ all_results.push(...env_results);
535
+ console.log();
536
+
537
+ console.log("\x1b[1m🗄️ Database\x1b[0m");
538
+ const db_results = check_database(project_root);
539
+ db_results.forEach(print_result);
540
+ all_results.push(...db_results);
541
+ console.log();
542
+
543
+ console.log("\x1b[1m🛤️ API Routes\x1b[0m");
544
+ const route_results = check_api_routes(project_root);
545
+ route_results.forEach(print_result);
546
+ all_results.push(...route_results);
547
+ console.log();
548
+
549
+ console.log("\x1b[1m🖼️ Profile Pictures\x1b[0m");
550
+ const pic_results = check_profile_pictures(project_root);
551
+ pic_results.forEach(print_result);
552
+ all_results.push(...pic_results);
553
+ console.log();
554
+
555
+ const summary: ValidationSummary = {
556
+ passed: all_results.filter(r => r.status === "pass").length,
557
+ failed: all_results.filter(r => r.status === "fail").length,
558
+ warnings: all_results.filter(r => r.status === "warn").length,
559
+ results: all_results,
560
+ };
561
+
562
+ console.log("=".repeat(50));
563
+ console.log("\x1b[1mSummary:\x1b[0m");
564
+ console.log(` \x1b[32m✓ Passed: ${summary.passed}\x1b[0m`);
565
+ console.log(` \x1b[31m✗ Failed: ${summary.failed}\x1b[0m`);
566
+ console.log(` \x1b[33m⚠ Warnings: ${summary.warnings}\x1b[0m`);
567
+ console.log();
568
+
569
+ if (summary.failed === 0 && summary.warnings === 0) {
570
+ console.log("\x1b[32m🦊 All checks passed! hazo_auth is ready to use.\x1b[0m\n");
571
+ } else if (summary.failed === 0) {
572
+ console.log("\x1b[33m🦊 Setup complete with warnings. Review the warnings above.\x1b[0m\n");
573
+ } else {
574
+ console.log("\x1b[31m🦊 Setup incomplete. Please fix the failed checks above.\x1b[0m\n");
575
+ console.log("For detailed setup instructions, see:");
576
+ console.log(" https://github.com/your-repo/hazo_auth/blob/main/SETUP_CHECKLIST.md\n");
577
+ }
578
+
579
+ return summary;
580
+ }
581
+
@@ -0,0 +1,46 @@
1
+ // file_description: server-only helper to read already logged in configuration from hazo_auth_config.ini
2
+ // section: imports
3
+ import { get_config_value, get_config_boolean } from "./config/config_loader.server";
4
+
5
+ // section: types
6
+ export type AlreadyLoggedInConfig = {
7
+ message: string;
8
+ showLogoutButton: boolean;
9
+ showReturnHomeButton: boolean;
10
+ returnHomeButtonLabel: string;
11
+ returnHomePath: string;
12
+ };
13
+
14
+ // section: helpers
15
+ /**
16
+ * Reads already logged in configuration from hazo_auth_config.ini file
17
+ * Falls back to defaults if hazo_auth_config.ini is not found or section is missing
18
+ * @returns Already logged in configuration options
19
+ */
20
+ export function get_already_logged_in_config(): AlreadyLoggedInConfig {
21
+ const section = "hazo_auth__already_logged_in";
22
+
23
+ // Read message (defaults to "You're already logged in.")
24
+ const message = get_config_value(section, "message", "You're already logged in.");
25
+
26
+ // Read show logout button (defaults to true)
27
+ const showLogoutButton = get_config_boolean(section, "show_logout_button", true);
28
+
29
+ // Read show return home button (defaults to false)
30
+ const showReturnHomeButton = get_config_boolean(section, "show_return_home_button", false);
31
+
32
+ // Read return home button label (defaults to "Return home")
33
+ const returnHomeButtonLabel = get_config_value(section, "return_home_button_label", "Return home");
34
+
35
+ // Read return home path (defaults to "/")
36
+ const returnHomePath = get_config_value(section, "return_home_path", "/");
37
+
38
+ return {
39
+ message,
40
+ showLogoutButton,
41
+ showReturnHomeButton,
42
+ returnHomeButtonLabel,
43
+ returnHomePath,
44
+ };
45
+ }
46
+
@@ -0,0 +1,24 @@
1
+ // file_description: client-accessible wrapper for the main app logging service
2
+ // section: imports
3
+ import { create_logger_service } from "../server/logging/logger_service";
4
+
5
+ // section: constants
6
+ const APP_NAMESPACE = "hazo_auth_ui";
7
+
8
+ // section: logger_instance
9
+ /**
10
+ * Creates a logger service instance for use in UI components
11
+ * This uses the main app logging service and can be extended with an external logger
12
+ * when provided as part of component setup
13
+ */
14
+ export const create_app_logger = (
15
+ external_logger?: {
16
+ info?: (message: string, data?: Record<string, unknown>) => void;
17
+ error?: (message: string, data?: Record<string, unknown>) => void;
18
+ warn?: (message: string, data?: Record<string, unknown>) => void;
19
+ debug?: (message: string, data?: Record<string, unknown>) => void;
20
+ }
21
+ ) => {
22
+ return create_logger_service(APP_NAMESPACE, external_logger);
23
+ };
24
+