@umituz/web-dashboard 5.0.1 → 6.0.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.
- package/package.json +2 -12
- package/src/index.ts +0 -10
- package/src/styles/dashboard.css +0 -460
- package/src/domains/auth/components/AuthLayout.tsx +0 -99
- package/src/domains/auth/components/ForgotPasswordForm.tsx +0 -167
- package/src/domains/auth/components/LoginForm.tsx +0 -222
- package/src/domains/auth/components/RegisterForm.tsx +0 -281
- package/src/domains/auth/components/ResetPasswordForm.tsx +0 -173
- package/src/domains/auth/components/index.ts +0 -11
- package/src/domains/auth/components/shared/AuthErrorBanner.tsx +0 -25
- package/src/domains/auth/components/shared/EmailInput.tsx +0 -73
- package/src/domains/auth/components/shared/PasswordInput.tsx +0 -100
- package/src/domains/auth/components/shared/PasswordStrengthIndicator.tsx +0 -63
- package/src/domains/auth/components/shared/SocialLoginButtons.tsx +0 -44
- package/src/domains/auth/components/shared/SocialProviderIcons.tsx +0 -48
- package/src/domains/auth/components/shared/index.ts +0 -20
- package/src/domains/auth/hooks/index.ts +0 -8
- package/src/domains/auth/hooks/useAuth.ts +0 -230
- package/src/domains/auth/index.ts +0 -62
- package/src/domains/auth/types/auth.ts +0 -302
- package/src/domains/auth/types/index.ts +0 -25
- package/src/domains/auth/utils/auth.test.ts +0 -188
- package/src/domains/auth/utils/auth.ts +0 -221
- package/src/domains/auth/utils/i18nKeys.ts +0 -109
- package/src/domains/auth/utils/index.ts +0 -29
- package/src/domains/auth/utils/secureToken.ts +0 -33
- package/src/domains/auth/utils/validationKeys.ts +0 -23
- package/src/domains/session/DemoLogin.tsx +0 -42
- package/src/domains/session/OrgSwitcher.tsx +0 -102
- package/src/domains/session/SessionContext.tsx +0 -150
- package/src/domains/session/inMemoryAuthAdapter.ts +0 -53
- package/src/domains/session/index.ts +0 -18
- package/src/domains/session/types.ts +0 -47
- package/src/domains/session/utils/i18nKeys.ts +0 -12
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useAuth Hook
|
|
3
|
-
*
|
|
4
|
-
* Core authentication hook for managing auth state and actions.
|
|
5
|
-
* Centralizes the try/catch+loading+error pattern via a single helper
|
|
6
|
-
* to keep individual actions focused on their unique logic.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useState, useCallback } from "react";
|
|
10
|
-
import type {
|
|
11
|
-
AuthState,
|
|
12
|
-
User,
|
|
13
|
-
AuthActions,
|
|
14
|
-
LoginCredentials,
|
|
15
|
-
RegisterData,
|
|
16
|
-
ForgotPasswordData,
|
|
17
|
-
ResetPasswordData,
|
|
18
|
-
} from "../types/auth";
|
|
19
|
-
import {
|
|
20
|
-
validateLogin,
|
|
21
|
-
validateRegister,
|
|
22
|
-
validateForgotPassword,
|
|
23
|
-
validateResetPassword,
|
|
24
|
-
} from "../utils/auth";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Auth provider contract — single source of truth for backend integration.
|
|
28
|
-
*/
|
|
29
|
-
export interface AuthProvider {
|
|
30
|
-
login: (credentials: LoginCredentials) => Promise<User>;
|
|
31
|
-
register: (data: RegisterData) => Promise<User>;
|
|
32
|
-
logout: () => Promise<void>;
|
|
33
|
-
forgotPassword: (data: ForgotPasswordData) => Promise<void>;
|
|
34
|
-
resetPassword: (data: ResetPasswordData) => Promise<void>;
|
|
35
|
-
refreshAuth: () => Promise<User | null>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface UseAuthOptions {
|
|
39
|
-
/** Auth implementation (connects to your backend) */
|
|
40
|
-
authProvider?: AuthProvider;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Wrap a side-effectful async function with the standard
|
|
45
|
-
* isLoading + error + throw contract.
|
|
46
|
-
*
|
|
47
|
-
* Important: the wrapped function is the SINGLE point of truth for
|
|
48
|
-
* setting isLoading=false, ensuring errors are surfaced (not swallowed),
|
|
49
|
-
* and re-throwing for callers that need to react.
|
|
50
|
-
*/
|
|
51
|
-
const executeAuthAction = async <T>(
|
|
52
|
-
updateState: (updates: Partial<AuthState>) => void,
|
|
53
|
-
fallbackErrorMessage: string,
|
|
54
|
-
action: () => Promise<T>,
|
|
55
|
-
): Promise<T> => {
|
|
56
|
-
updateState({ isLoading: true, error: null });
|
|
57
|
-
try {
|
|
58
|
-
return await action();
|
|
59
|
-
} catch (error) {
|
|
60
|
-
const errorMessage =
|
|
61
|
-
error instanceof Error && error.message ? error.message : fallbackErrorMessage;
|
|
62
|
-
updateState({ isLoading: false, error: errorMessage });
|
|
63
|
-
throw error instanceof Error ? error : new Error(errorMessage);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* useAuth hook
|
|
69
|
-
*
|
|
70
|
-
* Manages authentication state and provides auth actions.
|
|
71
|
-
* Each action surfaces errors to the caller AND to the auth state.
|
|
72
|
-
*/
|
|
73
|
-
export function useAuth(options: UseAuthOptions = {}) {
|
|
74
|
-
const { authProvider } = options;
|
|
75
|
-
|
|
76
|
-
const [authState, setAuthState] = useState<AuthState>({
|
|
77
|
-
isAuthenticated: false,
|
|
78
|
-
user: null,
|
|
79
|
-
isLoading: false,
|
|
80
|
-
error: null,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const updateState = useCallback((updates: Partial<AuthState>) => {
|
|
84
|
-
setAuthState((prev) => ({ ...prev, ...updates }));
|
|
85
|
-
}, []);
|
|
86
|
-
|
|
87
|
-
const requireProvider = useCallback((): AuthProvider => {
|
|
88
|
-
if (!authProvider) {
|
|
89
|
-
throw new Error("Auth provider not configured");
|
|
90
|
-
}
|
|
91
|
-
return authProvider;
|
|
92
|
-
}, [authProvider]);
|
|
93
|
-
|
|
94
|
-
const login = useCallback(
|
|
95
|
-
async (credentials: LoginCredentials): Promise<User> => {
|
|
96
|
-
const validation = validateLogin(credentials);
|
|
97
|
-
if (!validation.valid) {
|
|
98
|
-
const message = validation.error ?? "Login validation failed";
|
|
99
|
-
updateState({ error: message });
|
|
100
|
-
throw new Error(message);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return executeAuthAction(updateState, "Login failed", async () => {
|
|
104
|
-
const provider = requireProvider();
|
|
105
|
-
const user = await provider.login(credentials);
|
|
106
|
-
updateState({ isAuthenticated: true, user, isLoading: false, error: null });
|
|
107
|
-
return user;
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
[requireProvider, updateState],
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const register = useCallback(
|
|
114
|
-
async (data: RegisterData): Promise<User> => {
|
|
115
|
-
const validation = validateRegister(data, false);
|
|
116
|
-
if (!validation.valid) {
|
|
117
|
-
const message = validation.error ?? "Registration validation failed";
|
|
118
|
-
updateState({ error: message });
|
|
119
|
-
throw new Error(message);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return executeAuthAction(updateState, "Registration failed", async () => {
|
|
123
|
-
const provider = requireProvider();
|
|
124
|
-
const user = await provider.register(data);
|
|
125
|
-
updateState({ isAuthenticated: true, user, isLoading: false, error: null });
|
|
126
|
-
return user;
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
[requireProvider, updateState],
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const logout = useCallback(async (): Promise<void> => {
|
|
133
|
-
await executeAuthAction(updateState, "Logout failed", async () => {
|
|
134
|
-
const provider = requireProvider();
|
|
135
|
-
await provider.logout();
|
|
136
|
-
updateState({ isAuthenticated: false, user: null, isLoading: false, error: null });
|
|
137
|
-
});
|
|
138
|
-
}, [requireProvider, updateState]);
|
|
139
|
-
|
|
140
|
-
const forgotPassword = useCallback(
|
|
141
|
-
async (data: ForgotPasswordData): Promise<void> => {
|
|
142
|
-
const validation = validateForgotPassword(data);
|
|
143
|
-
if (!validation.valid) {
|
|
144
|
-
const message = validation.error ?? "Forgot password validation failed";
|
|
145
|
-
updateState({ error: message });
|
|
146
|
-
throw new Error(message);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
await executeAuthAction(updateState, "Failed to send reset email", async () => {
|
|
150
|
-
const provider = requireProvider();
|
|
151
|
-
await provider.forgotPassword(data);
|
|
152
|
-
updateState({ isLoading: false });
|
|
153
|
-
});
|
|
154
|
-
},
|
|
155
|
-
[requireProvider, updateState],
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
const resetPassword = useCallback(
|
|
159
|
-
async (data: ResetPasswordData): Promise<void> => {
|
|
160
|
-
const validation = validateResetPassword(data);
|
|
161
|
-
if (!validation.valid) {
|
|
162
|
-
const message = validation.error ?? "Reset password validation failed";
|
|
163
|
-
updateState({ error: message });
|
|
164
|
-
throw new Error(message);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
await executeAuthAction(updateState, "Failed to reset password", async () => {
|
|
168
|
-
const provider = requireProvider();
|
|
169
|
-
await provider.resetPassword(data);
|
|
170
|
-
updateState({ isLoading: false });
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
[requireProvider, updateState],
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
const updateProfile = useCallback(
|
|
177
|
-
async (data: Partial<User>): Promise<User> => {
|
|
178
|
-
const currentUser = authState.user;
|
|
179
|
-
if (!currentUser) {
|
|
180
|
-
const message = "No user to update";
|
|
181
|
-
updateState({ error: message });
|
|
182
|
-
throw new Error(message);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return executeAuthAction(updateState, "Failed to update profile", async () => {
|
|
186
|
-
// Pure derivation of the new user, no side effects in setState callback.
|
|
187
|
-
// Required fields come from the existing user; data overrides only the rest.
|
|
188
|
-
const { id: _ignoredId, ...rest } = data;
|
|
189
|
-
const updatedUser: User = {
|
|
190
|
-
...currentUser,
|
|
191
|
-
...rest,
|
|
192
|
-
id: currentUser.id,
|
|
193
|
-
email: data.email ?? currentUser.email,
|
|
194
|
-
};
|
|
195
|
-
updateState({ user: updatedUser, isLoading: false, error: null });
|
|
196
|
-
return updatedUser;
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
[authState.user, updateState],
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
const refresh = useCallback(async (): Promise<User | null> => {
|
|
203
|
-
return executeAuthAction(updateState, "Failed to refresh authentication", async () => {
|
|
204
|
-
const provider = requireProvider();
|
|
205
|
-
const user = await provider.refreshAuth();
|
|
206
|
-
updateState({ isAuthenticated: Boolean(user), user, isLoading: false, error: null });
|
|
207
|
-
return user;
|
|
208
|
-
});
|
|
209
|
-
}, [requireProvider, updateState]);
|
|
210
|
-
|
|
211
|
-
const clearError = useCallback(() => {
|
|
212
|
-
updateState({ error: null });
|
|
213
|
-
}, [updateState]);
|
|
214
|
-
|
|
215
|
-
const authActions: AuthActions = {
|
|
216
|
-
login,
|
|
217
|
-
register,
|
|
218
|
-
logout,
|
|
219
|
-
forgotPassword,
|
|
220
|
-
resetPassword,
|
|
221
|
-
updateProfile,
|
|
222
|
-
refresh,
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
...authState,
|
|
227
|
-
...authActions,
|
|
228
|
-
clearError,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Domain
|
|
3
|
-
*
|
|
4
|
-
* Main entry point for authentication domain
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Components
|
|
8
|
-
export {
|
|
9
|
-
AuthLayout,
|
|
10
|
-
LoginForm,
|
|
11
|
-
RegisterForm,
|
|
12
|
-
ForgotPasswordForm,
|
|
13
|
-
ResetPasswordForm,
|
|
14
|
-
} from "./components";
|
|
15
|
-
|
|
16
|
-
// Hooks
|
|
17
|
-
export { useAuth, type AuthProvider } from "./hooks";
|
|
18
|
-
|
|
19
|
-
// Utils
|
|
20
|
-
export {
|
|
21
|
-
isValidEmail,
|
|
22
|
-
isValidPassword,
|
|
23
|
-
validateLogin,
|
|
24
|
-
validateRegister,
|
|
25
|
-
validateForgotPassword,
|
|
26
|
-
validateResetPassword,
|
|
27
|
-
getUserDisplayName,
|
|
28
|
-
getUserInitials,
|
|
29
|
-
isEmailVerified,
|
|
30
|
-
formatUserCreatedAt,
|
|
31
|
-
maskEmail,
|
|
32
|
-
generateResetToken,
|
|
33
|
-
calculatePasswordStrength,
|
|
34
|
-
getPasswordStrengthBand,
|
|
35
|
-
sanitizeInput,
|
|
36
|
-
AUTH_KEYS,
|
|
37
|
-
AUTH_VALIDATION_KEYS,
|
|
38
|
-
type ValidationResult,
|
|
39
|
-
type PasswordStrengthBand,
|
|
40
|
-
type AuthValidationKey,
|
|
41
|
-
} from "./utils";
|
|
42
|
-
|
|
43
|
-
// Types
|
|
44
|
-
export type {
|
|
45
|
-
LoginCredentials,
|
|
46
|
-
RegisterData,
|
|
47
|
-
ForgotPasswordData,
|
|
48
|
-
ResetPasswordData,
|
|
49
|
-
AuthState,
|
|
50
|
-
User,
|
|
51
|
-
AuthActions,
|
|
52
|
-
AuthComponentProps,
|
|
53
|
-
AuthStep,
|
|
54
|
-
AuthConfig,
|
|
55
|
-
SocialProvider,
|
|
56
|
-
AuthLayoutProps,
|
|
57
|
-
LoginFormProps,
|
|
58
|
-
RegisterFormProps,
|
|
59
|
-
ForgotPasswordFormProps,
|
|
60
|
-
ResetPasswordFormProps,
|
|
61
|
-
Translate,
|
|
62
|
-
} from "./types";
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for authentication system
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ComponentType, ReactElement } from "react";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Translation function contract. Auth components stay i18n-agnostic;
|
|
11
|
-
* the consumer plugs in their i18n library of choice.
|
|
12
|
-
* Interpolation params follow the i18next convention (`{{placeholder}}`).
|
|
13
|
-
*/
|
|
14
|
-
export type Translate = (key: string, params?: Record<string, unknown>) => string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* User credentials for login
|
|
18
|
-
*/
|
|
19
|
-
export interface LoginCredentials {
|
|
20
|
-
/** Email address */
|
|
21
|
-
email: string;
|
|
22
|
-
/** Password */
|
|
23
|
-
password: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Registration data
|
|
28
|
-
*/
|
|
29
|
-
export interface RegisterData {
|
|
30
|
-
/** Email address */
|
|
31
|
-
email: string;
|
|
32
|
-
/** Password */
|
|
33
|
-
password: string;
|
|
34
|
-
/** Full name */
|
|
35
|
-
name?: string;
|
|
36
|
-
/** Additional user data */
|
|
37
|
-
metadata?: Record<string, unknown>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Password reset request
|
|
42
|
-
*/
|
|
43
|
-
export interface ForgotPasswordData {
|
|
44
|
-
/** Email address */
|
|
45
|
-
email: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Password reset confirmation
|
|
50
|
-
*/
|
|
51
|
-
export interface ResetPasswordData {
|
|
52
|
-
/** Reset token from email */
|
|
53
|
-
token: string;
|
|
54
|
-
/** New password */
|
|
55
|
-
password: string;
|
|
56
|
-
/** Password confirmation */
|
|
57
|
-
confirmPassword: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Auth state
|
|
62
|
-
*/
|
|
63
|
-
export interface AuthState {
|
|
64
|
-
/** Is user authenticated */
|
|
65
|
-
isAuthenticated: boolean;
|
|
66
|
-
/** Current user data */
|
|
67
|
-
user: User | null;
|
|
68
|
-
/** Is authentication loading */
|
|
69
|
-
isLoading: boolean;
|
|
70
|
-
/** Authentication error */
|
|
71
|
-
error: string | null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* User profile
|
|
76
|
-
*/
|
|
77
|
-
export interface User {
|
|
78
|
-
/** Unique user ID */
|
|
79
|
-
id: string;
|
|
80
|
-
/** Email address */
|
|
81
|
-
email: string;
|
|
82
|
-
/** Display name */
|
|
83
|
-
name?: string;
|
|
84
|
-
/** Profile avatar URL */
|
|
85
|
-
avatar?: string;
|
|
86
|
-
/** Email verification status */
|
|
87
|
-
emailVerified?: boolean;
|
|
88
|
-
/** Additional user data */
|
|
89
|
-
metadata?: Record<string, unknown>;
|
|
90
|
-
/** Account creation date */
|
|
91
|
-
createdAt?: string;
|
|
92
|
-
/** Last login date */
|
|
93
|
-
lastLoginAt?: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Auth actions
|
|
98
|
-
*/
|
|
99
|
-
export interface AuthActions {
|
|
100
|
-
/** Login with email/password */
|
|
101
|
-
login: (credentials: LoginCredentials) => Promise<User>;
|
|
102
|
-
/** Register new account */
|
|
103
|
-
register: (data: RegisterData) => Promise<User>;
|
|
104
|
-
/** Logout current user */
|
|
105
|
-
logout: () => Promise<void>;
|
|
106
|
-
/** Send password reset email */
|
|
107
|
-
forgotPassword: (data: ForgotPasswordData) => Promise<void>;
|
|
108
|
-
/** Reset password with token */
|
|
109
|
-
resetPassword: (data: ResetPasswordData) => Promise<void>;
|
|
110
|
-
/** Update user profile */
|
|
111
|
-
updateProfile: (data: Partial<User>) => Promise<User>;
|
|
112
|
-
/** Refresh authentication session */
|
|
113
|
-
refresh: () => Promise<User | null>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Auth component props
|
|
118
|
-
*/
|
|
119
|
-
export interface AuthComponentProps {
|
|
120
|
-
/** Current auth state */
|
|
121
|
-
authState: AuthState;
|
|
122
|
-
/** Auth actions */
|
|
123
|
-
authActions: AuthActions;
|
|
124
|
-
/** Update auth state */
|
|
125
|
-
setAuthState: (state: Partial<AuthState>) => void;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Auth step configuration
|
|
130
|
-
*/
|
|
131
|
-
export interface AuthStep {
|
|
132
|
-
/** Step identifier */
|
|
133
|
-
id: string;
|
|
134
|
-
/** Step title */
|
|
135
|
-
title: string;
|
|
136
|
-
/** Step description */
|
|
137
|
-
description?: string;
|
|
138
|
-
/** Custom component */
|
|
139
|
-
component?: ComponentType<AuthComponentProps> | ReactElement;
|
|
140
|
-
/** Validation function */
|
|
141
|
-
validate?: (data: Record<string, unknown>) => boolean;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Auth configuration
|
|
146
|
-
*/
|
|
147
|
-
export interface AuthConfig {
|
|
148
|
-
/** Brand/application name */
|
|
149
|
-
brandName: string;
|
|
150
|
-
/** Brand tagline */
|
|
151
|
-
brandTagline?: string;
|
|
152
|
-
/** Login route */
|
|
153
|
-
loginRoute: string;
|
|
154
|
-
/** Register route */
|
|
155
|
-
registerRoute: string;
|
|
156
|
-
/** Forgot password route */
|
|
157
|
-
forgotPasswordRoute?: string;
|
|
158
|
-
/** Route after successful login */
|
|
159
|
-
afterLoginRoute: string;
|
|
160
|
-
/** Route after logout */
|
|
161
|
-
afterLogoutRoute: string;
|
|
162
|
-
/** Show social login options */
|
|
163
|
-
showSocialLogin?: boolean;
|
|
164
|
-
/** Available social providers */
|
|
165
|
-
socialProviders?: SocialProvider[];
|
|
166
|
-
/** Public home route (header "back" link). Falls back to `afterLoginRoute`. */
|
|
167
|
-
homeRoute?: string;
|
|
168
|
-
/** Footer links (rendered only when provided — no defaults that 404) */
|
|
169
|
-
footerLinks?: Array<{ label: string; href: string }>;
|
|
170
|
-
/** Enable remember me */
|
|
171
|
-
enableRememberMe?: boolean;
|
|
172
|
-
/** Enable email verification */
|
|
173
|
-
requireEmailVerification?: boolean;
|
|
174
|
-
/** Auth steps (for multi-step onboarding) */
|
|
175
|
-
steps?: AuthStep[];
|
|
176
|
-
/** Additional configuration */
|
|
177
|
-
metadata?: Record<string, unknown>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Social login provider
|
|
182
|
-
*/
|
|
183
|
-
export interface SocialProvider {
|
|
184
|
-
/** Provider ID */
|
|
185
|
-
id: string;
|
|
186
|
-
/** Display name */
|
|
187
|
-
name: string;
|
|
188
|
-
/** Icon/emoji */
|
|
189
|
-
icon: string;
|
|
190
|
-
/** Color theme */
|
|
191
|
-
color?: string;
|
|
192
|
-
/** Scopes to request */
|
|
193
|
-
scopes?: string[];
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Auth layout props
|
|
198
|
-
*/
|
|
199
|
-
export interface AuthLayoutProps {
|
|
200
|
-
/** Auth configuration */
|
|
201
|
-
config: AuthConfig;
|
|
202
|
-
/** Current auth state */
|
|
203
|
-
authState?: AuthState;
|
|
204
|
-
/** Auth actions */
|
|
205
|
-
authActions?: AuthActions;
|
|
206
|
-
/** Optional translation function for layout strings (falls back to embedded English) */
|
|
207
|
-
translate?: Translate;
|
|
208
|
-
/** Social provider login handler (receives the provider id) */
|
|
209
|
-
onSocialLogin?: (providerId: string) => void | Promise<void>;
|
|
210
|
-
/** Children content */
|
|
211
|
-
children?: React.ReactNode;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Login form props
|
|
216
|
-
*/
|
|
217
|
-
export interface LoginFormProps {
|
|
218
|
-
/** Auth configuration */
|
|
219
|
-
config: AuthConfig;
|
|
220
|
-
/** Initial credentials */
|
|
221
|
-
defaultCredentials?: Partial<LoginCredentials>;
|
|
222
|
-
/** Show remember me checkbox */
|
|
223
|
-
showRememberMe?: boolean;
|
|
224
|
-
/** Show forgot password link */
|
|
225
|
-
showForgotPassword?: boolean;
|
|
226
|
-
/** Show register link */
|
|
227
|
-
showRegisterLink?: boolean;
|
|
228
|
-
/** Show social login buttons */
|
|
229
|
-
showSocialLogin?: boolean;
|
|
230
|
-
/**
|
|
231
|
-
* Allow the built-in mock login (accepts ANY credentials) for demos.
|
|
232
|
-
* Defaults to false — without `onLoginAttempt` the form reports a
|
|
233
|
-
* configuration error instead of silently "logging in".
|
|
234
|
-
*/
|
|
235
|
-
enableMockAuth?: boolean;
|
|
236
|
-
/** Custom login handler (receives credentials, returns user) */
|
|
237
|
-
onLoginAttempt?: (credentials: LoginCredentials) => Promise<User>;
|
|
238
|
-
/** On successful login (called after onLoginAttempt or mock auth succeeds) */
|
|
239
|
-
onLoginSuccess?: (user: User) => void | Promise<void>;
|
|
240
|
-
/** On login error */
|
|
241
|
-
onLoginError?: (error: string) => void;
|
|
242
|
-
/** Google login handler */
|
|
243
|
-
onGoogleLogin?: () => void | Promise<void>;
|
|
244
|
-
/** Apple login handler */
|
|
245
|
-
onAppleLogin?: () => void | Promise<void>;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Register form props
|
|
250
|
-
*/
|
|
251
|
-
export interface RegisterFormProps {
|
|
252
|
-
/** Auth configuration */
|
|
253
|
-
config: AuthConfig;
|
|
254
|
-
/** Initial registration data */
|
|
255
|
-
defaultData?: Partial<RegisterData>;
|
|
256
|
-
/** Show terms checkbox */
|
|
257
|
-
showTerms?: boolean;
|
|
258
|
-
/** Show login link */
|
|
259
|
-
showLoginLink?: boolean;
|
|
260
|
-
/** Require password confirmation */
|
|
261
|
-
requirePasswordConfirm?: boolean;
|
|
262
|
-
/** Show social login buttons */
|
|
263
|
-
showSocialLogin?: boolean;
|
|
264
|
-
/** Custom register handler (receives register data, returns user) - overrides mock auth */
|
|
265
|
-
onRegisterAttempt?: (data: RegisterData) => Promise<User>;
|
|
266
|
-
/** On successful registration (called after onRegisterAttempt or mock auth succeeds) */
|
|
267
|
-
onRegisterSuccess?: (user: User) => void | Promise<void>;
|
|
268
|
-
/** On registration error */
|
|
269
|
-
onRegisterError?: (error: string) => void;
|
|
270
|
-
/** Google login handler */
|
|
271
|
-
onGoogleLogin?: () => void | Promise<void>;
|
|
272
|
-
/** Apple login handler */
|
|
273
|
-
onAppleLogin?: () => void | Promise<void>;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Forgot password form props
|
|
278
|
-
*/
|
|
279
|
-
export interface ForgotPasswordFormProps {
|
|
280
|
-
/** Auth configuration */
|
|
281
|
-
config: AuthConfig;
|
|
282
|
-
/** Submit handler — receives the entered email and performs the reset request */
|
|
283
|
-
onSuccess?: (data: { email: string }) => void | Promise<void>;
|
|
284
|
-
/** On error */
|
|
285
|
-
onError?: (error: string) => void;
|
|
286
|
-
/** Show back to login link */
|
|
287
|
-
showBackLink?: boolean;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Reset password form props
|
|
292
|
-
*/
|
|
293
|
-
export interface ResetPasswordFormProps {
|
|
294
|
-
/** Auth configuration */
|
|
295
|
-
config: AuthConfig;
|
|
296
|
-
/** Reset token */
|
|
297
|
-
token: string;
|
|
298
|
-
/** Submit handler — receives the token and the new password */
|
|
299
|
-
onSuccess?: (data: { token: string; password: string }) => void | Promise<void>;
|
|
300
|
-
/** On error */
|
|
301
|
-
onError?: (error: string) => void;
|
|
302
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Types
|
|
3
|
-
*
|
|
4
|
-
* Export all auth-related types
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export type {
|
|
8
|
-
LoginCredentials,
|
|
9
|
-
RegisterData,
|
|
10
|
-
ForgotPasswordData,
|
|
11
|
-
ResetPasswordData,
|
|
12
|
-
AuthState,
|
|
13
|
-
User,
|
|
14
|
-
AuthActions,
|
|
15
|
-
AuthComponentProps,
|
|
16
|
-
AuthStep,
|
|
17
|
-
AuthConfig,
|
|
18
|
-
SocialProvider,
|
|
19
|
-
AuthLayoutProps,
|
|
20
|
-
LoginFormProps,
|
|
21
|
-
RegisterFormProps,
|
|
22
|
-
ForgotPasswordFormProps,
|
|
23
|
-
ResetPasswordFormProps,
|
|
24
|
-
Translate,
|
|
25
|
-
} from "./auth";
|