hazo_auth 1.6.7 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -14
- package/SETUP_CHECKLIST.md +65 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +5 -3
- package/dist/components/layouts/email_verification/index.d.ts +2 -1
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +3 -1
- package/dist/components/layouts/forgot_password/index.d.ts +2 -1
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +3 -1
- package/dist/components/layouts/login/index.d.ts +2 -1
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +3 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +4 -2
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +7 -5
- package/dist/components/layouts/my_settings/index.d.ts +2 -1
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +3 -2
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +3 -1
- package/dist/components/layouts/register/index.d.ts +2 -1
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +4 -2
- package/dist/components/layouts/reset_password/index.d.ts +2 -1
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts +2 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +3 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +8 -4
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts +2 -1
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/visual_panel.d.ts +2 -1
- package/dist/components/layouts/shared/components/visual_panel.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/visual_panel.js +2 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +4 -2
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_hazo_auth.js +4 -2
- package/dist/components/layouts/shared/index.d.ts +0 -2
- package/dist/components/layouts/shared/index.d.ts.map +1 -1
- package/dist/components/layouts/shared/index.js +2 -2
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +8 -6
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +15 -13
- package/dist/contexts/hazo_auth_config.d.ts +18 -0
- package/dist/contexts/hazo_auth_config.d.ts.map +1 -0
- package/dist/contexts/hazo_auth_config.js +10 -0
- package/dist/contexts/hazo_auth_provider.d.ts +73 -0
- package/dist/contexts/hazo_auth_provider.d.ts.map +1 -0
- package/dist/contexts/hazo_auth_provider.js +82 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/lib/config/default_config.d.ts +237 -0
- package/dist/lib/config/default_config.d.ts.map +1 -0
- package/dist/lib/config/default_config.js +159 -0
- package/dist/lib/email_verification_config.server.d.ts +4 -0
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/email_verification_config.server.js +12 -0
- package/dist/lib/forgot_password_config.server.d.ts +4 -0
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.js +12 -0
- package/dist/lib/login_config.server.d.ts +4 -0
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +10 -0
- package/dist/lib/password_requirements_config.server.d.ts +1 -1
- package/dist/lib/password_requirements_config.server.d.ts.map +1 -1
- package/dist/lib/password_requirements_config.server.js +8 -7
- package/dist/lib/register_config.server.d.ts +4 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +10 -0
- package/dist/lib/reset_password_config.server.d.ts +4 -0
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +10 -0
- package/dist/page_components/forgot_password.d.ts.map +1 -1
- package/dist/page_components/forgot_password.js +14 -0
- package/dist/page_components/login.d.ts +4 -0
- package/dist/page_components/login.d.ts.map +1 -1
- package/dist/page_components/login.js +14 -0
- package/dist/page_components/register.d.ts.map +1 -1
- package/dist/page_components/register.js +14 -0
- package/dist/page_components/reset_password.d.ts.map +1 -1
- package/dist/page_components/reset_password.js +14 -0
- package/dist/page_components/verify_email.d.ts.map +1 -1
- package/dist/page_components/verify_email.js +14 -0
- package/dist/pages/forgot_password.d.ts +52 -0
- package/dist/pages/forgot_password.d.ts.map +1 -0
- package/dist/pages/forgot_password.js +41 -0
- package/dist/pages/index.d.ts +33 -0
- package/dist/pages/index.d.ts.map +1 -0
- package/dist/pages/index.js +28 -0
- package/dist/pages/login.d.ts +43 -0
- package/dist/pages/login.d.ts.map +1 -0
- package/dist/pages/login.js +45 -0
- package/dist/pages/my_settings.d.ts +54 -0
- package/dist/pages/my_settings.d.ts.map +1 -0
- package/dist/pages/my_settings.js +57 -0
- package/dist/pages/register.d.ts +44 -0
- package/dist/pages/register.d.ts.map +1 -0
- package/dist/pages/register.js +46 -0
- package/dist/pages/reset_password.d.ts +43 -0
- package/dist/pages/reset_password.d.ts.map +1 -0
- package/dist/pages/reset_password.js +42 -0
- package/dist/pages/verify_email.d.ts +52 -0
- package/dist/pages/verify_email.d.ts.map +1 -0
- package/dist/pages/verify_email.js +41 -0
- package/dist/server_pages/forgot_password.d.ts +53 -0
- package/dist/server_pages/forgot_password.d.ts.map +1 -0
- package/dist/server_pages/forgot_password.js +40 -0
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +15 -0
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/forgot_password_client_wrapper.js +27 -0
- package/dist/server_pages/index.d.ts +13 -0
- package/dist/server_pages/index.d.ts.map +1 -0
- package/dist/server_pages/index.js +7 -0
- package/dist/server_pages/login.d.ts +43 -0
- package/dist/server_pages/login.d.ts.map +1 -0
- package/dist/server_pages/login.js +39 -0
- package/dist/server_pages/login_client_wrapper.d.ts +13 -0
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/login_client_wrapper.js +29 -0
- package/dist/server_pages/my_settings.d.ts +53 -0
- package/dist/server_pages/my_settings.d.ts.map +1 -0
- package/dist/server_pages/my_settings.js +57 -0
- package/dist/server_pages/register.d.ts +45 -0
- package/dist/server_pages/register.d.ts.map +1 -0
- package/dist/server_pages/register.js +41 -0
- package/dist/server_pages/register_client_wrapper.d.ts +13 -0
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/register_client_wrapper.js +27 -0
- package/dist/server_pages/reset_password.d.ts +44 -0
- package/dist/server_pages/reset_password.d.ts.map +1 -0
- package/dist/server_pages/reset_password.js +40 -0
- package/dist/server_pages/reset_password_client_wrapper.d.ts +13 -0
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/reset_password_client_wrapper.js +27 -0
- package/dist/server_pages/verify_email.d.ts +53 -0
- package/dist/server_pages/verify_email.d.ts.map +1 -0
- package/dist/server_pages/verify_email.js +40 -0
- package/dist/server_pages/verify_email_client_wrapper.d.ts +15 -0
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/verify_email_client_wrapper.js +27 -0
- package/package.json +34 -10
|
@@ -17,6 +17,7 @@ import { RolesMatrix } from "./components/roles_matrix";
|
|
|
17
17
|
import { UserX, KeyRound, Edit, Trash2, Loader2, CircleCheck, CircleX, Plus, UserPlus } from "lucide-react";
|
|
18
18
|
import { toast } from "sonner";
|
|
19
19
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip";
|
|
20
|
+
import { useHazoAuthConfig } from "../../../contexts/hazo_auth_provider";
|
|
20
21
|
// section: component
|
|
21
22
|
/**
|
|
22
23
|
* User Management layout component with three tabs
|
|
@@ -27,6 +28,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../
|
|
|
27
28
|
* @returns User Management layout component
|
|
28
29
|
*/
|
|
29
30
|
export function UserManagementLayout({ className }) {
|
|
31
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
30
32
|
// Permission checks
|
|
31
33
|
const authResult = use_hazo_auth();
|
|
32
34
|
const hasUserManagementPermission = authResult.authenticated &&
|
|
@@ -64,7 +66,7 @@ export function UserManagementLayout({ className }) {
|
|
|
64
66
|
const loadUsers = useCallback(async () => {
|
|
65
67
|
setUsersLoading(true);
|
|
66
68
|
try {
|
|
67
|
-
const response = await fetch(
|
|
69
|
+
const response = await fetch(`${apiBasePath}/user_management/users`);
|
|
68
70
|
const data = await response.json();
|
|
69
71
|
if (data.success) {
|
|
70
72
|
setUsers(data.users);
|
|
@@ -97,7 +99,7 @@ export function UserManagementLayout({ className }) {
|
|
|
97
99
|
const loadPermissions = async () => {
|
|
98
100
|
setPermissionsLoading(true);
|
|
99
101
|
try {
|
|
100
|
-
const response = await fetch(
|
|
102
|
+
const response = await fetch(`${apiBasePath}/user_management/permissions`);
|
|
101
103
|
const data = await response.json();
|
|
102
104
|
if (data.success) {
|
|
103
105
|
const db_perms = data.db_permissions.map((p) => ({
|
|
@@ -133,7 +135,7 @@ export function UserManagementLayout({ className }) {
|
|
|
133
135
|
return;
|
|
134
136
|
setUsersActionLoading(true);
|
|
135
137
|
try {
|
|
136
|
-
const response = await fetch(
|
|
138
|
+
const response = await fetch(`${apiBasePath}/user_management/users`, {
|
|
137
139
|
method: "PATCH",
|
|
138
140
|
headers: {
|
|
139
141
|
"Content-Type": "application/json",
|
|
@@ -149,7 +151,7 @@ export function UserManagementLayout({ className }) {
|
|
|
149
151
|
setDeactivateDialogOpen(false);
|
|
150
152
|
setSelectedUser(null);
|
|
151
153
|
// Reload users
|
|
152
|
-
const reload_response = await fetch(
|
|
154
|
+
const reload_response = await fetch(`${apiBasePath}/user_management/users`);
|
|
153
155
|
const reload_data = await reload_response.json();
|
|
154
156
|
if (reload_data.success) {
|
|
155
157
|
setUsers(reload_data.users);
|
|
@@ -172,7 +174,7 @@ export function UserManagementLayout({ className }) {
|
|
|
172
174
|
return;
|
|
173
175
|
setUsersActionLoading(true);
|
|
174
176
|
try {
|
|
175
|
-
const response = await fetch(
|
|
177
|
+
const response = await fetch(`${apiBasePath}/user_management/users`, {
|
|
176
178
|
method: "POST",
|
|
177
179
|
headers: {
|
|
178
180
|
"Content-Type": "application/json",
|
|
@@ -203,7 +205,7 @@ export function UserManagementLayout({ className }) {
|
|
|
203
205
|
var _a, _b;
|
|
204
206
|
setMigrateLoading(true);
|
|
205
207
|
try {
|
|
206
|
-
const response = await fetch(
|
|
208
|
+
const response = await fetch(`${apiBasePath}/user_management/permissions?action=migrate`, {
|
|
207
209
|
method: "POST",
|
|
208
210
|
});
|
|
209
211
|
const data = await response.json();
|
|
@@ -224,7 +226,7 @@ export function UserManagementLayout({ className }) {
|
|
|
224
226
|
toast.info(`Skipped: ${data.skipped.join(", ")}`);
|
|
225
227
|
}
|
|
226
228
|
// Reload permissions
|
|
227
|
-
const reload_response = await fetch(
|
|
229
|
+
const reload_response = await fetch(`${apiBasePath}/user_management/permissions`);
|
|
228
230
|
const reload_data = await reload_response.json();
|
|
229
231
|
if (reload_data.success) {
|
|
230
232
|
const db_perms = reload_data.db_permissions.map((p) => ({
|
|
@@ -259,7 +261,7 @@ export function UserManagementLayout({ className }) {
|
|
|
259
261
|
return;
|
|
260
262
|
setPermissionsActionLoading(true);
|
|
261
263
|
try {
|
|
262
|
-
const response = await fetch(
|
|
264
|
+
const response = await fetch(`${apiBasePath}/user_management/permissions`, {
|
|
263
265
|
method: "PUT",
|
|
264
266
|
headers: {
|
|
265
267
|
"Content-Type": "application/json",
|
|
@@ -276,7 +278,7 @@ export function UserManagementLayout({ className }) {
|
|
|
276
278
|
setEditingPermission(null);
|
|
277
279
|
setEditDescription("");
|
|
278
280
|
// Reload permissions
|
|
279
|
-
const reload_response = await fetch(
|
|
281
|
+
const reload_response = await fetch(`${apiBasePath}/user_management/permissions`);
|
|
280
282
|
const reload_data = await reload_response.json();
|
|
281
283
|
if (reload_data.success) {
|
|
282
284
|
const db_perms = reload_data.db_permissions.map((p) => ({
|
|
@@ -313,7 +315,7 @@ export function UserManagementLayout({ className }) {
|
|
|
313
315
|
}
|
|
314
316
|
setPermissionsActionLoading(true);
|
|
315
317
|
try {
|
|
316
|
-
const response = await fetch(
|
|
318
|
+
const response = await fetch(`${apiBasePath}/user_management/permissions`, {
|
|
317
319
|
method: "POST",
|
|
318
320
|
headers: {
|
|
319
321
|
"Content-Type": "application/json",
|
|
@@ -330,7 +332,7 @@ export function UserManagementLayout({ className }) {
|
|
|
330
332
|
setNewPermissionName("");
|
|
331
333
|
setNewPermissionDescription("");
|
|
332
334
|
// Reload permissions
|
|
333
|
-
const reload_response = await fetch(
|
|
335
|
+
const reload_response = await fetch(`${apiBasePath}/user_management/permissions`);
|
|
334
336
|
const reload_data = await reload_response.json();
|
|
335
337
|
if (reload_data.success) {
|
|
336
338
|
const db_perms = reload_data.db_permissions.map((p) => ({
|
|
@@ -365,14 +367,14 @@ export function UserManagementLayout({ className }) {
|
|
|
365
367
|
return;
|
|
366
368
|
setPermissionsActionLoading(true);
|
|
367
369
|
try {
|
|
368
|
-
const response = await fetch(
|
|
370
|
+
const response = await fetch(`${apiBasePath}/user_management/permissions?permission_id=${permission.id}`, {
|
|
369
371
|
method: "DELETE",
|
|
370
372
|
});
|
|
371
373
|
const data = await response.json();
|
|
372
374
|
if (data.success) {
|
|
373
375
|
toast.success("Permission deleted successfully");
|
|
374
376
|
// Reload permissions
|
|
375
|
-
const reload_response = await fetch(
|
|
377
|
+
const reload_response = await fetch(`${apiBasePath}/user_management/permissions`);
|
|
376
378
|
const reload_data = await reload_response.json();
|
|
377
379
|
if (reload_data.success) {
|
|
378
380
|
const db_perms = reload_data.db_permissions.map((p) => ({
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime configuration for hazo_auth components
|
|
3
|
+
* Controls API paths and other runtime settings
|
|
4
|
+
*/
|
|
5
|
+
export type HazoAuthConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* Base path for all hazo_auth API endpoints
|
|
8
|
+
* @default "/api/hazo_auth"
|
|
9
|
+
* @example "/api/v1/auth"
|
|
10
|
+
*/
|
|
11
|
+
apiBasePath: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Default configuration values
|
|
15
|
+
* Used when no provider is present or when values are not specified
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_HAZO_AUTH_CONFIG: HazoAuthConfig;
|
|
18
|
+
//# sourceMappingURL=hazo_auth_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_auth_config.d.ts","sourceRoot":"","sources":["../../src/contexts/hazo_auth_config.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,cAEtC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// file_description: Type definitions for HazoAuth runtime configuration
|
|
2
|
+
// This file defines the configuration structure for the HazoAuthProvider context
|
|
3
|
+
// section: types
|
|
4
|
+
/**
|
|
5
|
+
* Default configuration values
|
|
6
|
+
* Used when no provider is present or when values are not specified
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_HAZO_AUTH_CONFIG = {
|
|
9
|
+
apiBasePath: "/api/hazo_auth",
|
|
10
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type HazoAuthConfig } from "./hazo_auth_config";
|
|
3
|
+
/**
|
|
4
|
+
* Props for HazoAuthProvider component
|
|
5
|
+
*/
|
|
6
|
+
export type HazoAuthProviderProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Base path for all hazo_auth API endpoints
|
|
9
|
+
* @default "/api/hazo_auth"
|
|
10
|
+
* @example "/api/v1/auth" - Custom API path
|
|
11
|
+
*/
|
|
12
|
+
apiBasePath?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Child components that will have access to the configuration
|
|
15
|
+
*/
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Context Provider for hazo_auth runtime configuration
|
|
20
|
+
*
|
|
21
|
+
* Wrap your app (or specific parts) with this provider to customize
|
|
22
|
+
* API paths and other runtime settings for all hazo_auth components.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // In your root layout or app component
|
|
27
|
+
* import { HazoAuthProvider } from "hazo_auth/provider";
|
|
28
|
+
*
|
|
29
|
+
* export default function RootLayout({ children }) {
|
|
30
|
+
* return (
|
|
31
|
+
* <html>
|
|
32
|
+
* <body>
|
|
33
|
+
* <HazoAuthProvider apiBasePath="/api/v1/auth">
|
|
34
|
+
* {children}
|
|
35
|
+
* </HazoAuthProvider>
|
|
36
|
+
* </body>
|
|
37
|
+
* </html>
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* // Using default values (no provider needed)
|
|
45
|
+
* // All components will use "/api/hazo_auth" as the base path
|
|
46
|
+
* export default function App() {
|
|
47
|
+
* return <LoginPage />;
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function HazoAuthProvider({ apiBasePath, children }: HazoAuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
/**
|
|
53
|
+
* Hook to access hazo_auth runtime configuration
|
|
54
|
+
*
|
|
55
|
+
* Returns the current configuration from the nearest HazoAuthProvider,
|
|
56
|
+
* or default values if no provider is present.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* function MyComponent() {
|
|
61
|
+
* const { apiBasePath } = useHazoAuthConfig();
|
|
62
|
+
*
|
|
63
|
+
* const response = await fetch(`${apiBasePath}/login`, {
|
|
64
|
+
* method: "POST",
|
|
65
|
+
* body: JSON.stringify({ email, password }),
|
|
66
|
+
* });
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @returns Current HazoAuthConfig
|
|
71
|
+
*/
|
|
72
|
+
export declare function useHazoAuthConfig(): HazoAuthConfig;
|
|
73
|
+
//# sourceMappingURL=hazo_auth_provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_auth_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/hazo_auth_provider.tsx"],"names":[],"mappings":"AAMA,OAAc,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAYnF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,WAAkD,EAClD,QAAQ,EACT,EAAE,qBAAqB,2CAcvB;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// file_description: React Context Provider for hazo_auth runtime configuration
|
|
2
|
+
// Provides global configuration for API paths and other runtime settings
|
|
3
|
+
// Must be used as a wrapper in consuming apps for customizing API endpoints
|
|
4
|
+
// section: imports
|
|
5
|
+
"use client";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { createContext, useContext, useMemo } from "react";
|
|
8
|
+
import { DEFAULT_HAZO_AUTH_CONFIG } from "./hazo_auth_config";
|
|
9
|
+
// section: context_definition
|
|
10
|
+
/**
|
|
11
|
+
* React Context for hazo_auth configuration
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const HazoAuthConfigContext = createContext(DEFAULT_HAZO_AUTH_CONFIG);
|
|
15
|
+
// section: provider_component
|
|
16
|
+
/**
|
|
17
|
+
* Context Provider for hazo_auth runtime configuration
|
|
18
|
+
*
|
|
19
|
+
* Wrap your app (or specific parts) with this provider to customize
|
|
20
|
+
* API paths and other runtime settings for all hazo_auth components.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // In your root layout or app component
|
|
25
|
+
* import { HazoAuthProvider } from "hazo_auth/provider";
|
|
26
|
+
*
|
|
27
|
+
* export default function RootLayout({ children }) {
|
|
28
|
+
* return (
|
|
29
|
+
* <html>
|
|
30
|
+
* <body>
|
|
31
|
+
* <HazoAuthProvider apiBasePath="/api/v1/auth">
|
|
32
|
+
* {children}
|
|
33
|
+
* </HazoAuthProvider>
|
|
34
|
+
* </body>
|
|
35
|
+
* </html>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Using default values (no provider needed)
|
|
43
|
+
* // All components will use "/api/hazo_auth" as the base path
|
|
44
|
+
* export default function App() {
|
|
45
|
+
* return <LoginPage />;
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function HazoAuthProvider({ apiBasePath = DEFAULT_HAZO_AUTH_CONFIG.apiBasePath, children }) {
|
|
50
|
+
// Memoize config to avoid unnecessary re-renders
|
|
51
|
+
const config = useMemo(() => ({
|
|
52
|
+
apiBasePath,
|
|
53
|
+
}), [apiBasePath]);
|
|
54
|
+
return (_jsx(HazoAuthConfigContext.Provider, { value: config, children: children }));
|
|
55
|
+
}
|
|
56
|
+
// section: hook
|
|
57
|
+
/**
|
|
58
|
+
* Hook to access hazo_auth runtime configuration
|
|
59
|
+
*
|
|
60
|
+
* Returns the current configuration from the nearest HazoAuthProvider,
|
|
61
|
+
* or default values if no provider is present.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* function MyComponent() {
|
|
66
|
+
* const { apiBasePath } = useHazoAuthConfig();
|
|
67
|
+
*
|
|
68
|
+
* const response = await fetch(`${apiBasePath}/login`, {
|
|
69
|
+
* method: "POST",
|
|
70
|
+
* body: JSON.stringify({ email, password }),
|
|
71
|
+
* });
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @returns Current HazoAuthConfig
|
|
76
|
+
*/
|
|
77
|
+
export function useHazoAuthConfig() {
|
|
78
|
+
const context = useContext(HazoAuthConfigContext);
|
|
79
|
+
// Context will always have a value (either from provider or default)
|
|
80
|
+
// No need to check for undefined
|
|
81
|
+
return context;
|
|
82
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AAGnC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,oBAAoB,CAAC;AAGnC,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// file_description: main entry point for hazo_auth package - exports all public APIs
|
|
2
|
+
// section: context_exports
|
|
3
|
+
export * from "./contexts/hazo_auth_provider";
|
|
4
|
+
export * from "./contexts/hazo_auth_config";
|
|
2
5
|
// section: component_exports
|
|
3
6
|
export * from "./components/index";
|
|
4
7
|
// section: lib_exports
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
export declare const DEFAULT_PASSWORD_REQUIREMENTS: {
|
|
2
|
+
readonly minimum_length: 8;
|
|
3
|
+
readonly require_uppercase: false;
|
|
4
|
+
readonly require_lowercase: false;
|
|
5
|
+
readonly require_number: false;
|
|
6
|
+
readonly require_special: false;
|
|
7
|
+
};
|
|
8
|
+
export declare const DEFAULT_USER_FIELDS: {
|
|
9
|
+
readonly show_name_field: true;
|
|
10
|
+
readonly show_email_field: true;
|
|
11
|
+
readonly show_password_field: true;
|
|
12
|
+
};
|
|
13
|
+
export declare const DEFAULT_PROFILE_PICTURE: {
|
|
14
|
+
readonly allow_photo_upload: true;
|
|
15
|
+
readonly max_photo_size: 5242880;
|
|
16
|
+
readonly user_photo_default: true;
|
|
17
|
+
readonly user_photo_default_priority1: "gravatar";
|
|
18
|
+
readonly user_photo_default_priority2: "library";
|
|
19
|
+
readonly library_photo_path: "/profile_pictures/library";
|
|
20
|
+
};
|
|
21
|
+
export declare const DEFAULT_UI_SIZES: {
|
|
22
|
+
readonly gravatar_size: 200;
|
|
23
|
+
readonly profile_picture_size: 128;
|
|
24
|
+
readonly tooltip_icon_size_default: 16;
|
|
25
|
+
readonly tooltip_icon_size_small: 14;
|
|
26
|
+
readonly library_photo_grid_columns: 4;
|
|
27
|
+
readonly library_photo_preview_size: 80;
|
|
28
|
+
readonly image_compression_max_dimension: 800;
|
|
29
|
+
readonly upload_file_hard_limit_bytes: 10485760;
|
|
30
|
+
};
|
|
31
|
+
export declare const DEFAULT_FILE_TYPES: {
|
|
32
|
+
readonly allowed_image_extensions: readonly [".jpg", ".jpeg", ".png", ".gif", ".webp"];
|
|
33
|
+
readonly allowed_image_mime_types: readonly ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
34
|
+
};
|
|
35
|
+
export declare const DEFAULT_MESSAGES: {
|
|
36
|
+
readonly photo_upload_disabled_message: "Photo upload is currently disabled. Contact your administrator.";
|
|
37
|
+
readonly gravatar_setup_message: "To use Gravatar, create a free account at gravatar.com with the same email address you use here.";
|
|
38
|
+
readonly gravatar_no_account_message: "No Gravatar account found for your email. Using library photo instead.";
|
|
39
|
+
readonly library_tooltip_message: "Choose from our library of profile pictures";
|
|
40
|
+
};
|
|
41
|
+
export declare const DEFAULT_ALREADY_LOGGED_IN: {
|
|
42
|
+
readonly message: "You are already logged in";
|
|
43
|
+
readonly showLogoutButton: true;
|
|
44
|
+
readonly showReturnHomeButton: true;
|
|
45
|
+
readonly returnHomeButtonLabel: "Return Home";
|
|
46
|
+
readonly returnHomePath: "/";
|
|
47
|
+
};
|
|
48
|
+
export declare const DEFAULT_LOGIN: {
|
|
49
|
+
readonly redirectRoute: string | undefined;
|
|
50
|
+
readonly successMessage: "Successfully logged in";
|
|
51
|
+
readonly forgotPasswordPath: "/hazo_auth/forgot_password";
|
|
52
|
+
readonly forgotPasswordLabel: "Forgot password?";
|
|
53
|
+
readonly createAccountPath: "/hazo_auth/register";
|
|
54
|
+
readonly createAccountLabel: "Create account";
|
|
55
|
+
};
|
|
56
|
+
export declare const DEFAULT_REGISTER: {
|
|
57
|
+
readonly redirectRoute: string | undefined;
|
|
58
|
+
readonly successMessage: "Registration successful! Please check your email to verify your account.";
|
|
59
|
+
readonly loginPath: "/hazo_auth/login";
|
|
60
|
+
readonly loginLabel: "Already have an account? Sign in";
|
|
61
|
+
readonly requireEmailVerification: true;
|
|
62
|
+
};
|
|
63
|
+
export declare const DEFAULT_FORGOT_PASSWORD: {
|
|
64
|
+
readonly successMessage: "If an account with that email exists, a password reset link has been sent.";
|
|
65
|
+
readonly loginPath: "/hazo_auth/login";
|
|
66
|
+
readonly loginLabel: "Back to login";
|
|
67
|
+
};
|
|
68
|
+
export declare const DEFAULT_RESET_PASSWORD: {
|
|
69
|
+
readonly successMessage: "Password reset successfully. You can now log in with your new password.";
|
|
70
|
+
readonly loginPath: "/hazo_auth/login";
|
|
71
|
+
readonly redirectDelay: 2;
|
|
72
|
+
};
|
|
73
|
+
export declare const DEFAULT_EMAIL_VERIFICATION: {
|
|
74
|
+
readonly successMessage: "Email verified successfully! Redirecting to login...";
|
|
75
|
+
readonly errorMessage: "Email verification failed. The link may have expired.";
|
|
76
|
+
readonly loginPath: "/hazo_auth/login";
|
|
77
|
+
readonly redirectDelay: 5;
|
|
78
|
+
};
|
|
79
|
+
export declare const DEFAULT_MY_SETTINGS: {
|
|
80
|
+
readonly showNameField: true;
|
|
81
|
+
readonly showEmailField: true;
|
|
82
|
+
readonly showPasswordField: true;
|
|
83
|
+
readonly showProfilePicture: true;
|
|
84
|
+
};
|
|
85
|
+
export declare const DEFAULT_USER_MANAGEMENT: {
|
|
86
|
+
readonly enableUserManagement: true;
|
|
87
|
+
readonly enableRoleManagement: true;
|
|
88
|
+
readonly enablePermissionManagement: true;
|
|
89
|
+
};
|
|
90
|
+
export declare const DEFAULT_AUTH_UTILITY: {
|
|
91
|
+
readonly sessionCookieName: "hazo_session";
|
|
92
|
+
readonly sessionDuration: 86400;
|
|
93
|
+
readonly requireEmailVerification: true;
|
|
94
|
+
};
|
|
95
|
+
export declare const DEFAULT_UI_SHELL: {
|
|
96
|
+
readonly layout_mode: "standalone" | "test_sidebar";
|
|
97
|
+
readonly image_src: "/globe.svg";
|
|
98
|
+
readonly image_width: 400;
|
|
99
|
+
readonly image_height: 400;
|
|
100
|
+
readonly show_visual_panel: true;
|
|
101
|
+
};
|
|
102
|
+
export declare const DEFAULT_PROFILE_PIC_MENU: {
|
|
103
|
+
readonly show_single_button: false;
|
|
104
|
+
readonly sign_up_label: "Sign Up";
|
|
105
|
+
readonly sign_in_label: "Sign In";
|
|
106
|
+
readonly register_path: "/hazo_auth/register";
|
|
107
|
+
readonly login_path: "/hazo_auth/login";
|
|
108
|
+
readonly settings_path: "/hazo_auth/my_settings";
|
|
109
|
+
readonly logout_path: "/api/hazo_auth/logout";
|
|
110
|
+
};
|
|
111
|
+
export declare const DEFAULT_API_PATHS: {
|
|
112
|
+
readonly apiBasePath: "/api/hazo_auth";
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* All default configuration values combined in one object
|
|
116
|
+
* This makes it easy to see all defaults at a glance and export them as needed
|
|
117
|
+
*/
|
|
118
|
+
export declare const HAZO_AUTH_DEFAULTS: {
|
|
119
|
+
readonly passwordRequirements: {
|
|
120
|
+
readonly minimum_length: 8;
|
|
121
|
+
readonly require_uppercase: false;
|
|
122
|
+
readonly require_lowercase: false;
|
|
123
|
+
readonly require_number: false;
|
|
124
|
+
readonly require_special: false;
|
|
125
|
+
};
|
|
126
|
+
readonly userFields: {
|
|
127
|
+
readonly show_name_field: true;
|
|
128
|
+
readonly show_email_field: true;
|
|
129
|
+
readonly show_password_field: true;
|
|
130
|
+
};
|
|
131
|
+
readonly profilePicture: {
|
|
132
|
+
readonly allow_photo_upload: true;
|
|
133
|
+
readonly max_photo_size: 5242880;
|
|
134
|
+
readonly user_photo_default: true;
|
|
135
|
+
readonly user_photo_default_priority1: "gravatar";
|
|
136
|
+
readonly user_photo_default_priority2: "library";
|
|
137
|
+
readonly library_photo_path: "/profile_pictures/library";
|
|
138
|
+
};
|
|
139
|
+
readonly uiSizes: {
|
|
140
|
+
readonly gravatar_size: 200;
|
|
141
|
+
readonly profile_picture_size: 128;
|
|
142
|
+
readonly tooltip_icon_size_default: 16;
|
|
143
|
+
readonly tooltip_icon_size_small: 14;
|
|
144
|
+
readonly library_photo_grid_columns: 4;
|
|
145
|
+
readonly library_photo_preview_size: 80;
|
|
146
|
+
readonly image_compression_max_dimension: 800;
|
|
147
|
+
readonly upload_file_hard_limit_bytes: 10485760;
|
|
148
|
+
};
|
|
149
|
+
readonly fileTypes: {
|
|
150
|
+
readonly allowed_image_extensions: readonly [".jpg", ".jpeg", ".png", ".gif", ".webp"];
|
|
151
|
+
readonly allowed_image_mime_types: readonly ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
152
|
+
};
|
|
153
|
+
readonly messages: {
|
|
154
|
+
readonly photo_upload_disabled_message: "Photo upload is currently disabled. Contact your administrator.";
|
|
155
|
+
readonly gravatar_setup_message: "To use Gravatar, create a free account at gravatar.com with the same email address you use here.";
|
|
156
|
+
readonly gravatar_no_account_message: "No Gravatar account found for your email. Using library photo instead.";
|
|
157
|
+
readonly library_tooltip_message: "Choose from our library of profile pictures";
|
|
158
|
+
};
|
|
159
|
+
readonly alreadyLoggedIn: {
|
|
160
|
+
readonly message: "You are already logged in";
|
|
161
|
+
readonly showLogoutButton: true;
|
|
162
|
+
readonly showReturnHomeButton: true;
|
|
163
|
+
readonly returnHomeButtonLabel: "Return Home";
|
|
164
|
+
readonly returnHomePath: "/";
|
|
165
|
+
};
|
|
166
|
+
readonly login: {
|
|
167
|
+
readonly redirectRoute: string | undefined;
|
|
168
|
+
readonly successMessage: "Successfully logged in";
|
|
169
|
+
readonly forgotPasswordPath: "/hazo_auth/forgot_password";
|
|
170
|
+
readonly forgotPasswordLabel: "Forgot password?";
|
|
171
|
+
readonly createAccountPath: "/hazo_auth/register";
|
|
172
|
+
readonly createAccountLabel: "Create account";
|
|
173
|
+
};
|
|
174
|
+
readonly register: {
|
|
175
|
+
readonly redirectRoute: string | undefined;
|
|
176
|
+
readonly successMessage: "Registration successful! Please check your email to verify your account.";
|
|
177
|
+
readonly loginPath: "/hazo_auth/login";
|
|
178
|
+
readonly loginLabel: "Already have an account? Sign in";
|
|
179
|
+
readonly requireEmailVerification: true;
|
|
180
|
+
};
|
|
181
|
+
readonly forgotPassword: {
|
|
182
|
+
readonly successMessage: "If an account with that email exists, a password reset link has been sent.";
|
|
183
|
+
readonly loginPath: "/hazo_auth/login";
|
|
184
|
+
readonly loginLabel: "Back to login";
|
|
185
|
+
};
|
|
186
|
+
readonly resetPassword: {
|
|
187
|
+
readonly successMessage: "Password reset successfully. You can now log in with your new password.";
|
|
188
|
+
readonly loginPath: "/hazo_auth/login";
|
|
189
|
+
readonly redirectDelay: 2;
|
|
190
|
+
};
|
|
191
|
+
readonly emailVerification: {
|
|
192
|
+
readonly successMessage: "Email verified successfully! Redirecting to login...";
|
|
193
|
+
readonly errorMessage: "Email verification failed. The link may have expired.";
|
|
194
|
+
readonly loginPath: "/hazo_auth/login";
|
|
195
|
+
readonly redirectDelay: 5;
|
|
196
|
+
};
|
|
197
|
+
readonly mySettings: {
|
|
198
|
+
readonly showNameField: true;
|
|
199
|
+
readonly showEmailField: true;
|
|
200
|
+
readonly showPasswordField: true;
|
|
201
|
+
readonly showProfilePicture: true;
|
|
202
|
+
};
|
|
203
|
+
readonly userManagement: {
|
|
204
|
+
readonly enableUserManagement: true;
|
|
205
|
+
readonly enableRoleManagement: true;
|
|
206
|
+
readonly enablePermissionManagement: true;
|
|
207
|
+
};
|
|
208
|
+
readonly authUtility: {
|
|
209
|
+
readonly sessionCookieName: "hazo_session";
|
|
210
|
+
readonly sessionDuration: 86400;
|
|
211
|
+
readonly requireEmailVerification: true;
|
|
212
|
+
};
|
|
213
|
+
readonly uiShell: {
|
|
214
|
+
readonly layout_mode: "standalone" | "test_sidebar";
|
|
215
|
+
readonly image_src: "/globe.svg";
|
|
216
|
+
readonly image_width: 400;
|
|
217
|
+
readonly image_height: 400;
|
|
218
|
+
readonly show_visual_panel: true;
|
|
219
|
+
};
|
|
220
|
+
readonly profilePicMenu: {
|
|
221
|
+
readonly show_single_button: false;
|
|
222
|
+
readonly sign_up_label: "Sign Up";
|
|
223
|
+
readonly sign_in_label: "Sign In";
|
|
224
|
+
readonly register_path: "/hazo_auth/register";
|
|
225
|
+
readonly login_path: "/hazo_auth/login";
|
|
226
|
+
readonly settings_path: "/hazo_auth/my_settings";
|
|
227
|
+
readonly logout_path: "/api/hazo_auth/logout";
|
|
228
|
+
};
|
|
229
|
+
readonly apiPaths: {
|
|
230
|
+
readonly apiBasePath: "/api/hazo_auth";
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Type representing the complete default configuration structure
|
|
235
|
+
*/
|
|
236
|
+
export type HazoAuthDefaults = typeof HAZO_AUTH_DEFAULTS;
|
|
237
|
+
//# sourceMappingURL=default_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default_config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/default_config.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,6BAA6B;;;;;;CAMhC,CAAC;AAGX,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAGX,eAAO,MAAM,uBAAuB;;;;;;;CAO1B,CAAC;AAGX,eAAO,MAAM,gBAAgB;;;;;;;;;CASnB,CAAC;AAGX,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAGX,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC;AAGX,eAAO,MAAM,yBAAyB;;;;;;CAM5B,CAAC;AAGX,eAAO,MAAM,aAAa;4BACI,MAAM,GAAG,SAAS;;;;;;CAMtC,CAAC;AAGX,eAAO,MAAM,gBAAgB;4BACC,MAAM,GAAG,SAAS;;;;;CAKtC,CAAC;AAGX,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC;AAGX,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAC;AAGX,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAC;AAGX,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAGX,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC;AAGX,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAGX,eAAO,MAAM,gBAAgB;0BACE,YAAY,GAAG,cAAc;;;;;CAKlD,CAAC;AAGX,eAAO,MAAM,wBAAwB;;;;;;;;CAQ3B,CAAC;AAGX,eAAO,MAAM,iBAAiB;;CAEpB,CAAC;AAGX;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA3FD,MAAM,GAAG,SAAS;;;;;;;;gCAUlB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAqDjB,YAAY,GAAG,cAAc;;;;;;;;;;;;;;;;;;CA+ClD,CAAC;AAGX;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,kBAAkB,CAAC"}
|