@umituz/react-native-auth 3.6.73 → 3.6.74
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.74",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -7,9 +7,6 @@ export interface PasswordConfig {
|
|
|
7
7
|
minLength: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Social authentication provider configuration
|
|
12
|
-
*/
|
|
13
10
|
export interface SocialProviderConfig {
|
|
14
11
|
enabled: boolean;
|
|
15
12
|
}
|
|
@@ -20,21 +17,13 @@ export interface GoogleAuthConfig extends SocialProviderConfig {
|
|
|
20
17
|
androidClientId?: string;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export interface AppleAuthConfig extends SocialProviderConfig {
|
|
24
|
-
// Apple Sign In doesn't require additional config for basic usage
|
|
25
|
-
}
|
|
20
|
+
export interface AppleAuthConfig extends SocialProviderConfig {}
|
|
26
21
|
|
|
27
|
-
/**
|
|
28
|
-
* Social authentication configuration
|
|
29
|
-
*/
|
|
30
22
|
export interface SocialAuthConfig {
|
|
31
23
|
google?: GoogleAuthConfig;
|
|
32
24
|
apple?: AppleAuthConfig;
|
|
33
25
|
}
|
|
34
26
|
|
|
35
|
-
/**
|
|
36
|
-
* Supported social auth providers
|
|
37
|
-
*/
|
|
38
27
|
export type SocialAuthProvider = "google" | "apple";
|
|
39
28
|
|
|
40
29
|
export interface AuthConfig {
|
|
@@ -42,23 +31,16 @@ export interface AuthConfig {
|
|
|
42
31
|
social?: SocialAuthConfig;
|
|
43
32
|
}
|
|
44
33
|
|
|
45
|
-
export const DEFAULT_PASSWORD_CONFIG: PasswordConfig = {
|
|
46
|
-
minLength: 6,
|
|
47
|
-
};
|
|
48
|
-
|
|
34
|
+
export const DEFAULT_PASSWORD_CONFIG: PasswordConfig = { minLength: 6 };
|
|
49
35
|
export const DEFAULT_SOCIAL_CONFIG: SocialAuthConfig = {
|
|
50
36
|
google: { enabled: false },
|
|
51
37
|
apple: { enabled: false },
|
|
52
38
|
};
|
|
53
|
-
|
|
54
39
|
export const DEFAULT_AUTH_CONFIG: AuthConfig = {
|
|
55
40
|
password: DEFAULT_PASSWORD_CONFIG,
|
|
56
41
|
social: DEFAULT_SOCIAL_CONFIG,
|
|
57
42
|
};
|
|
58
43
|
|
|
59
|
-
/**
|
|
60
|
-
* Configuration validation error
|
|
61
|
-
*/
|
|
62
44
|
export class AuthConfigValidationError extends Error {
|
|
63
45
|
constructor(message: string, public readonly field: string) {
|
|
64
46
|
super(message);
|
|
@@ -66,58 +48,29 @@ export class AuthConfigValidationError extends Error {
|
|
|
66
48
|
}
|
|
67
49
|
}
|
|
68
50
|
|
|
69
|
-
/**
|
|
70
|
-
* Validate authentication configuration
|
|
71
|
-
* @throws {AuthConfigValidationError} if configuration is invalid
|
|
72
|
-
*/
|
|
73
51
|
export function validateAuthConfig(config: Partial<AuthConfig>): void {
|
|
74
|
-
// Validate password config
|
|
75
52
|
if (config.password) {
|
|
76
53
|
if (typeof config.password.minLength !== "number") {
|
|
77
|
-
throw new AuthConfigValidationError(
|
|
78
|
-
"Password minLength must be a number",
|
|
79
|
-
"password.minLength"
|
|
80
|
-
);
|
|
54
|
+
throw new AuthConfigValidationError("Password minLength must be a number", "password.minLength");
|
|
81
55
|
}
|
|
82
56
|
if (config.password.minLength < 4) {
|
|
83
|
-
throw new AuthConfigValidationError(
|
|
84
|
-
"Password minLength must be at least 4 characters",
|
|
85
|
-
"password.minLength"
|
|
86
|
-
);
|
|
57
|
+
throw new AuthConfigValidationError("Password minLength must be at least 4 characters", "password.minLength");
|
|
87
58
|
}
|
|
88
59
|
if (config.password.minLength > 128) {
|
|
89
|
-
throw new AuthConfigValidationError(
|
|
90
|
-
"Password minLength must not exceed 128 characters",
|
|
91
|
-
"password.minLength"
|
|
92
|
-
);
|
|
60
|
+
throw new AuthConfigValidationError("Password minLength must not exceed 128 characters", "password.minLength");
|
|
93
61
|
}
|
|
94
62
|
}
|
|
95
63
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
if (googleConfig.enabled) {
|
|
101
|
-
// At least one client ID should be provided if enabled
|
|
102
|
-
if (!googleConfig.webClientId && !googleConfig.iosClientId && !googleConfig.androidClientId) {
|
|
103
|
-
throw new AuthConfigValidationError(
|
|
104
|
-
"At least one Google client ID (web, iOS, or Android) must be provided when Google Sign-In is enabled",
|
|
105
|
-
"social.google"
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
64
|
+
if (config.social?.google?.enabled) {
|
|
65
|
+
const googleConfig = config.social.google;
|
|
66
|
+
if (!googleConfig.webClientId && !googleConfig.iosClientId && !googleConfig.androidClientId) {
|
|
67
|
+
throw new AuthConfigValidationError("At least one Google client ID must be provided when Google Sign-In is enabled", "social.google");
|
|
109
68
|
}
|
|
110
69
|
}
|
|
111
70
|
}
|
|
112
71
|
|
|
113
|
-
/**
|
|
114
|
-
* Sanitize and merge auth config with defaults
|
|
115
|
-
* Ensures valid configuration values
|
|
116
|
-
*/
|
|
117
72
|
export function sanitizeAuthConfig(config: Partial<AuthConfig> = {}): AuthConfig {
|
|
118
|
-
// Validate first
|
|
119
73
|
validateAuthConfig(config);
|
|
120
|
-
|
|
121
74
|
return {
|
|
122
75
|
password: {
|
|
123
76
|
minLength: config.password?.minLength ?? DEFAULT_PASSWORD_CONFIG.minLength,
|
package/src/index.ts
CHANGED
|
@@ -10,97 +10,30 @@
|
|
|
10
10
|
// =============================================================================
|
|
11
11
|
|
|
12
12
|
export type { AuthUser, AuthProviderType } from './domain/entities/AuthUser';
|
|
13
|
-
export {
|
|
14
|
-
AuthError,
|
|
15
|
-
AuthInitializationError,
|
|
16
|
-
AuthConfigurationError,
|
|
17
|
-
AuthValidationError,
|
|
18
|
-
AuthNetworkError,
|
|
19
|
-
AuthUserNotFoundError,
|
|
20
|
-
AuthWrongPasswordError,
|
|
21
|
-
AuthEmailAlreadyInUseError,
|
|
22
|
-
AuthWeakPasswordError,
|
|
23
|
-
AuthInvalidEmailError,
|
|
24
|
-
} from './domain/errors/AuthError';
|
|
25
|
-
|
|
26
|
-
export type {
|
|
27
|
-
AuthConfig,
|
|
28
|
-
PasswordConfig,
|
|
29
|
-
SocialAuthConfig,
|
|
30
|
-
SocialProviderConfig,
|
|
31
|
-
GoogleAuthConfig,
|
|
32
|
-
AppleAuthConfig,
|
|
33
|
-
SocialAuthProvider,
|
|
34
|
-
} from './domain/value-objects/AuthConfig';
|
|
35
|
-
export {
|
|
36
|
-
DEFAULT_AUTH_CONFIG,
|
|
37
|
-
DEFAULT_PASSWORD_CONFIG,
|
|
38
|
-
DEFAULT_SOCIAL_CONFIG,
|
|
39
|
-
} from './domain/value-objects/AuthConfig';
|
|
40
|
-
|
|
41
13
|
export type { UserProfile, UpdateProfileParams } from './domain/entities/UserProfile';
|
|
14
|
+
export { AuthError, AuthInitializationError, AuthConfigurationError, AuthValidationError, AuthNetworkError, AuthUserNotFoundError, AuthWrongPasswordError, AuthEmailAlreadyInUseError, AuthWeakPasswordError, AuthInvalidEmailError } from './domain/errors/AuthError';
|
|
15
|
+
export type { AuthConfig, PasswordConfig, SocialAuthConfig, SocialProviderConfig, GoogleAuthConfig, AppleAuthConfig, SocialAuthProvider } from './domain/value-objects/AuthConfig';
|
|
16
|
+
export { DEFAULT_AUTH_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_SOCIAL_CONFIG } from './domain/value-objects/AuthConfig';
|
|
42
17
|
|
|
43
18
|
// =============================================================================
|
|
44
19
|
// APPLICATION LAYER
|
|
45
20
|
// =============================================================================
|
|
46
21
|
|
|
47
|
-
export type {
|
|
48
|
-
IAuthProvider,
|
|
49
|
-
AuthCredentials,
|
|
50
|
-
SignUpCredentials,
|
|
51
|
-
SocialSignInResult,
|
|
52
|
-
} from './application/ports/IAuthProvider';
|
|
22
|
+
export type { IAuthProvider, AuthCredentials, SignUpCredentials, SocialSignInResult } from './application/ports/IAuthProvider';
|
|
53
23
|
|
|
54
24
|
// =============================================================================
|
|
55
25
|
// INFRASTRUCTURE LAYER
|
|
56
26
|
// =============================================================================
|
|
57
27
|
|
|
58
28
|
export { FirebaseAuthProvider } from './infrastructure/providers/FirebaseAuthProvider';
|
|
59
|
-
export {
|
|
60
|
-
AuthService,
|
|
61
|
-
initializeAuthService,
|
|
62
|
-
getAuthService,
|
|
63
|
-
resetAuthService,
|
|
64
|
-
} from './infrastructure/services/AuthService';
|
|
29
|
+
export { AuthService, initializeAuthService, getAuthService, resetAuthService } from './infrastructure/services/AuthService';
|
|
65
30
|
export type { IStorageProvider } from './infrastructure/types/Storage.types';
|
|
66
|
-
export {
|
|
67
|
-
|
|
68
|
-
StorageProviderAdapter,
|
|
69
|
-
} from './infrastructure/adapters/StorageProviderAdapter';
|
|
70
|
-
export {
|
|
71
|
-
initializeAuth,
|
|
72
|
-
isAuthInitialized,
|
|
73
|
-
resetAuthInitialization,
|
|
74
|
-
} from './infrastructure/services/initializeAuth';
|
|
31
|
+
export { createStorageProvider, StorageProviderAdapter } from './infrastructure/adapters/StorageProviderAdapter';
|
|
32
|
+
export { initializeAuth, isAuthInitialized, resetAuthInitialization } from './infrastructure/services/initializeAuth';
|
|
75
33
|
export type { InitializeAuthOptions } from './infrastructure/services/initializeAuth';
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// =============================================================================
|
|
80
|
-
|
|
81
|
-
export {
|
|
82
|
-
validateEmail,
|
|
83
|
-
validatePasswordForLogin,
|
|
84
|
-
validatePasswordForRegister,
|
|
85
|
-
validatePasswordConfirmation,
|
|
86
|
-
validateDisplayName,
|
|
87
|
-
} from './infrastructure/utils/AuthValidation';
|
|
88
|
-
export type {
|
|
89
|
-
ValidationResult,
|
|
90
|
-
PasswordStrengthResult,
|
|
91
|
-
PasswordRequirements,
|
|
92
|
-
} from './infrastructure/utils/AuthValidation';
|
|
93
|
-
|
|
94
|
-
export {
|
|
95
|
-
SECURITY_LIMITS,
|
|
96
|
-
sanitizeWhitespace,
|
|
97
|
-
sanitizeEmail,
|
|
98
|
-
sanitizePassword,
|
|
99
|
-
sanitizeName,
|
|
100
|
-
sanitizeText,
|
|
101
|
-
containsDangerousChars,
|
|
102
|
-
isWithinLengthLimit,
|
|
103
|
-
} from './infrastructure/utils/validation/sanitization';
|
|
34
|
+
export { validateEmail, validatePasswordForLogin, validatePasswordForRegister, validatePasswordConfirmation, validateDisplayName } from './infrastructure/utils/AuthValidation';
|
|
35
|
+
export type { ValidationResult, PasswordStrengthResult, PasswordRequirements } from './infrastructure/utils/AuthValidation';
|
|
36
|
+
export { SECURITY_LIMITS, sanitizeWhitespace, sanitizeEmail, sanitizePassword, sanitizeName, sanitizeText, containsDangerousChars, isWithinLengthLimit } from './infrastructure/utils/validation/sanitization';
|
|
104
37
|
export type { SecurityLimitKey } from './infrastructure/utils/validation/sanitization';
|
|
105
38
|
|
|
106
39
|
// =============================================================================
|
|
@@ -109,37 +42,26 @@ export type { SecurityLimitKey } from './infrastructure/utils/validation/sanitiz
|
|
|
109
42
|
|
|
110
43
|
export { useAuth } from './presentation/hooks/useAuth';
|
|
111
44
|
export type { UseAuthResult } from './presentation/hooks/useAuth';
|
|
112
|
-
|
|
113
45
|
export { useLoginForm } from './presentation/hooks/useLoginForm';
|
|
114
46
|
export type { UseLoginFormConfig, UseLoginFormResult } from './presentation/hooks/useLoginForm';
|
|
115
|
-
|
|
116
47
|
export { useRegisterForm } from './presentation/hooks/useRegisterForm';
|
|
117
48
|
export type { UseRegisterFormConfig, UseRegisterFormResult } from './presentation/hooks/useRegisterForm';
|
|
118
|
-
|
|
119
49
|
export { useAuthRequired } from './presentation/hooks/useAuthRequired';
|
|
120
50
|
export { useRequireAuth, useUserId } from './presentation/hooks/useRequireAuth';
|
|
121
|
-
|
|
122
51
|
export { useUserProfile } from './presentation/hooks/useUserProfile';
|
|
123
52
|
export type { UserProfileData, UseUserProfileParams } from './presentation/hooks/useUserProfile';
|
|
124
|
-
|
|
125
53
|
export { useAccountManagement } from './presentation/hooks/useAccountManagement';
|
|
126
54
|
export type { UseAccountManagementReturn } from './presentation/hooks/useAccountManagement';
|
|
127
|
-
|
|
128
55
|
export { useProfileUpdate } from './presentation/hooks/useProfileUpdate';
|
|
129
56
|
export type { UseProfileUpdateReturn } from './presentation/hooks/useProfileUpdate';
|
|
130
|
-
|
|
131
57
|
export { useProfileEdit } from './presentation/hooks/useProfileEdit';
|
|
132
58
|
export type { ProfileEditFormState, UseProfileEditReturn } from './presentation/hooks/useProfileEdit';
|
|
133
|
-
|
|
134
59
|
export { useSocialLogin } from './presentation/hooks/useSocialLogin';
|
|
135
60
|
export type { UseSocialLoginConfig, UseSocialLoginResult } from './presentation/hooks/useSocialLogin';
|
|
136
|
-
|
|
137
61
|
export { useGoogleAuth } from './presentation/hooks/useGoogleAuth';
|
|
138
62
|
export type { UseGoogleAuthResult } from './presentation/hooks/useGoogleAuth';
|
|
139
|
-
|
|
140
63
|
export { useAppleAuth } from './presentation/hooks/useAppleAuth';
|
|
141
64
|
export type { UseAppleAuthResult } from './presentation/hooks/useAppleAuth';
|
|
142
|
-
|
|
143
65
|
export { useAuthBottomSheet } from './presentation/hooks/useAuthBottomSheet';
|
|
144
66
|
export type { SocialAuthConfiguration } from './presentation/hooks/useAuthBottomSheet';
|
|
145
67
|
|
|
@@ -149,22 +71,16 @@ export type { SocialAuthConfiguration } from './presentation/hooks/useAuthBottom
|
|
|
149
71
|
|
|
150
72
|
export { AuthProvider } from './presentation/providers/AuthProvider';
|
|
151
73
|
export type { ErrorFallbackProps } from './presentation/providers/AuthProvider';
|
|
152
|
-
|
|
153
74
|
export { LoginScreen } from './presentation/screens/LoginScreen';
|
|
154
75
|
export type { LoginScreenProps } from './presentation/screens/LoginScreen';
|
|
155
|
-
|
|
156
76
|
export { RegisterScreen } from './presentation/screens/RegisterScreen';
|
|
157
77
|
export type { RegisterScreenProps } from './presentation/screens/RegisterScreen';
|
|
158
|
-
|
|
159
78
|
export { AccountScreen } from './presentation/screens/AccountScreen';
|
|
160
79
|
export type { AccountScreenProps, AccountScreenConfig } from './presentation/screens/AccountScreen';
|
|
161
|
-
|
|
162
80
|
export { EditProfileScreen } from './presentation/screens/EditProfileScreen';
|
|
163
81
|
export type { EditProfileScreenProps } from './presentation/screens/EditProfileScreen';
|
|
164
|
-
|
|
165
82
|
export { AuthNavigator } from './presentation/navigation/AuthNavigator';
|
|
166
83
|
export type { AuthStackParamList } from './presentation/navigation/AuthNavigator';
|
|
167
|
-
|
|
168
84
|
export { AuthBottomSheet } from './presentation/components/AuthBottomSheet';
|
|
169
85
|
export { ProfileSection } from './presentation/components/ProfileSection';
|
|
170
86
|
export type { ProfileSectionProps, ProfileSectionConfig } from './presentation/components/ProfileSection';
|
|
@@ -175,28 +91,15 @@ export type { ProfileSectionProps, ProfileSectionConfig } from './presentation/c
|
|
|
175
91
|
|
|
176
92
|
export { useAuthStore } from './presentation/stores/authStore';
|
|
177
93
|
export { useAuthModalStore } from './presentation/stores/authModalStore';
|
|
178
|
-
export {
|
|
179
|
-
|
|
180
|
-
resetAuthListener,
|
|
181
|
-
isAuthListenerInitialized,
|
|
182
|
-
} from './presentation/stores/initializeAuthListener';
|
|
183
|
-
export type { AuthState, AuthActions, UserType } from './types/auth-store.types';
|
|
184
|
-
export type { AuthListenerOptions } from './types/auth-store.types';
|
|
94
|
+
export { initializeAuthListener, resetAuthListener, isAuthListenerInitialized } from './presentation/stores/initializeAuthListener';
|
|
95
|
+
export type { AuthState, AuthActions, UserType, AuthListenerOptions } from './types/auth-store.types';
|
|
185
96
|
export * from './presentation/stores/auth.selectors';
|
|
186
97
|
|
|
187
98
|
// =============================================================================
|
|
188
|
-
// UTILITIES
|
|
189
|
-
// =============================================================================
|
|
190
|
-
|
|
191
|
-
export {
|
|
192
|
-
getAuthErrorLocalizationKey,
|
|
193
|
-
resolveErrorMessage,
|
|
194
|
-
} from './presentation/utils/getAuthErrorMessage';
|
|
195
|
-
|
|
196
|
-
// =============================================================================
|
|
197
|
-
// INIT MODULE
|
|
99
|
+
// UTILITIES & INIT
|
|
198
100
|
// =============================================================================
|
|
199
101
|
|
|
102
|
+
export { getAuthErrorLocalizationKey, resolveErrorMessage } from './presentation/utils/getAuthErrorMessage';
|
|
200
103
|
export { createAuthInitModule } from './init';
|
|
201
104
|
export type { AuthInitModuleConfig } from './init/createAuthInitModule';
|
|
202
105
|
|
|
@@ -47,12 +47,7 @@ export const AccountActions: React.FC<AccountActionsProps> = ({ config }) => {
|
|
|
47
47
|
const handleLogout = () => {
|
|
48
48
|
alert.show(AlertType.WARNING, AlertMode.MODAL, logoutConfirmTitle, logoutConfirmMessage, {
|
|
49
49
|
actions: [
|
|
50
|
-
{
|
|
51
|
-
id: "cancel",
|
|
52
|
-
label: cancelText,
|
|
53
|
-
style: "secondary",
|
|
54
|
-
onPress: () => {},
|
|
55
|
-
},
|
|
50
|
+
{ id: "cancel", label: cancelText, style: "secondary", onPress: () => {} },
|
|
56
51
|
{
|
|
57
52
|
id: "confirm",
|
|
58
53
|
label: logoutText,
|
|
@@ -72,12 +67,7 @@ export const AccountActions: React.FC<AccountActionsProps> = ({ config }) => {
|
|
|
72
67
|
const handleDeleteAccount = () => {
|
|
73
68
|
alert.show(AlertType.ERROR, AlertMode.MODAL, deleteConfirmTitle, deleteConfirmMessage, {
|
|
74
69
|
actions: [
|
|
75
|
-
{
|
|
76
|
-
id: "cancel",
|
|
77
|
-
label: cancelText,
|
|
78
|
-
style: "secondary",
|
|
79
|
-
onPress: () => {},
|
|
80
|
-
},
|
|
70
|
+
{ id: "cancel", label: cancelText, style: "secondary", onPress: () => {} },
|
|
81
71
|
{
|
|
82
72
|
id: "confirm",
|
|
83
73
|
label: deleteAccountText,
|
|
@@ -97,40 +87,22 @@ export const AccountActions: React.FC<AccountActionsProps> = ({ config }) => {
|
|
|
97
87
|
return (
|
|
98
88
|
<View style={styles.container}>
|
|
99
89
|
{showChangePassword && onChangePassword && changePasswordText && (
|
|
100
|
-
<TouchableOpacity
|
|
101
|
-
style={[actionButtonStyle.container, { borderColor: tokens.colors.border }]}
|
|
102
|
-
onPress={onChangePassword}
|
|
103
|
-
activeOpacity={0.7}
|
|
104
|
-
>
|
|
90
|
+
<TouchableOpacity style={[actionButtonStyle.container, { borderColor: tokens.colors.border }]} onPress={onChangePassword} activeOpacity={0.7}>
|
|
105
91
|
<AtomicIcon name="key-outline" size="md" color="textPrimary" />
|
|
106
|
-
<AtomicText style={actionButtonStyle.text} color="textPrimary">
|
|
107
|
-
{changePasswordText}
|
|
108
|
-
</AtomicText>
|
|
92
|
+
<AtomicText style={actionButtonStyle.text} color="textPrimary">{changePasswordText}</AtomicText>
|
|
109
93
|
<AtomicIcon name="chevron-forward" size="sm" color="textSecondary" />
|
|
110
94
|
</TouchableOpacity>
|
|
111
95
|
)}
|
|
112
96
|
|
|
113
|
-
<TouchableOpacity
|
|
114
|
-
style={[actionButtonStyle.container, { borderColor: tokens.colors.border }]}
|
|
115
|
-
onPress={handleLogout}
|
|
116
|
-
activeOpacity={0.7}
|
|
117
|
-
>
|
|
97
|
+
<TouchableOpacity style={[actionButtonStyle.container, { borderColor: tokens.colors.border }]} onPress={handleLogout} activeOpacity={0.7}>
|
|
118
98
|
<AtomicIcon name="log-out-outline" size="md" color="error" />
|
|
119
|
-
<AtomicText style={actionButtonStyle.text} color="error">
|
|
120
|
-
{logoutText}
|
|
121
|
-
</AtomicText>
|
|
99
|
+
<AtomicText style={actionButtonStyle.text} color="error">{logoutText}</AtomicText>
|
|
122
100
|
<AtomicIcon name="chevron-forward" size="sm" color="textSecondary" />
|
|
123
101
|
</TouchableOpacity>
|
|
124
102
|
|
|
125
|
-
<TouchableOpacity
|
|
126
|
-
style={[actionButtonStyle.container, { borderColor: tokens.colors.border }]}
|
|
127
|
-
onPress={handleDeleteAccount}
|
|
128
|
-
activeOpacity={0.7}
|
|
129
|
-
>
|
|
103
|
+
<TouchableOpacity style={[actionButtonStyle.container, { borderColor: tokens.colors.border }]} onPress={handleDeleteAccount} activeOpacity={0.7}>
|
|
130
104
|
<AtomicIcon name="trash-outline" size="md" color="error" />
|
|
131
|
-
<AtomicText style={actionButtonStyle.text} color="error">
|
|
132
|
-
{deleteAccountText}
|
|
133
|
-
</AtomicText>
|
|
105
|
+
<AtomicText style={actionButtonStyle.text} color="error">{deleteAccountText}</AtomicText>
|
|
134
106
|
<AtomicIcon name="chevron-forward" size="sm" color="textSecondary" />
|
|
135
107
|
</TouchableOpacity>
|
|
136
108
|
</View>
|
|
@@ -138,7 +110,5 @@ export const AccountActions: React.FC<AccountActionsProps> = ({ config }) => {
|
|
|
138
110
|
};
|
|
139
111
|
|
|
140
112
|
const styles = StyleSheet.create({
|
|
141
|
-
container: {
|
|
142
|
-
gap: 12,
|
|
143
|
-
},
|
|
113
|
+
container: { gap: 12 },
|
|
144
114
|
});
|
|
@@ -9,128 +9,98 @@ import { useAppDesignTokens, AtomicText, AtomicIcon, AtomicAvatar } from "@umitu
|
|
|
9
9
|
import { ProfileBenefitsList } from "./ProfileBenefitsList";
|
|
10
10
|
|
|
11
11
|
export interface ProfileSectionConfig {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
displayName?: string;
|
|
13
|
+
userId?: string;
|
|
14
|
+
isAnonymous: boolean;
|
|
15
|
+
avatarUrl?: string;
|
|
16
|
+
accountSettingsRoute?: string;
|
|
17
|
+
benefits?: string[];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface ProfileSectionProps {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
profile: ProfileSectionConfig;
|
|
22
|
+
onPress?: () => void;
|
|
23
|
+
onSignIn?: () => void;
|
|
24
|
+
signInText?: string;
|
|
25
|
+
anonymousText?: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const ProfileSection: React.FC<ProfileSectionProps> = ({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
profile,
|
|
30
|
+
onPress,
|
|
31
|
+
onSignIn,
|
|
32
|
+
signInText,
|
|
33
|
+
anonymousText,
|
|
34
34
|
}) => {
|
|
35
|
-
|
|
35
|
+
const tokens = useAppDesignTokens();
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const handlePress = () => {
|
|
38
|
+
if (profile.isAnonymous && onSignIn) {
|
|
39
|
+
onSignIn();
|
|
40
|
+
} else if (onPress) {
|
|
41
|
+
onPress();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
return (
|
|
46
|
+
<TouchableOpacity
|
|
47
|
+
style={[styles.container, { backgroundColor: tokens.colors.surface }]}
|
|
48
|
+
onPress={handlePress}
|
|
49
|
+
activeOpacity={0.7}
|
|
50
|
+
disabled={!onPress && !onSignIn}
|
|
51
|
+
>
|
|
52
|
+
<View style={styles.content}>
|
|
53
|
+
<View style={styles.avatarContainer}>
|
|
54
|
+
<AtomicAvatar
|
|
55
|
+
source={profile.avatarUrl ? { uri: profile.avatarUrl } : undefined}
|
|
56
|
+
name={profile.displayName || (profile.isAnonymous ? anonymousText : signInText)}
|
|
57
|
+
size="md"
|
|
58
|
+
/>
|
|
59
|
+
</View>
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<AtomicText
|
|
72
|
-
type="bodySmall"
|
|
73
|
-
color="textSecondary"
|
|
74
|
-
numberOfLines={1}
|
|
75
|
-
>
|
|
76
|
-
{profile.userId}
|
|
77
|
-
</AtomicText>
|
|
78
|
-
)}
|
|
79
|
-
</View>
|
|
61
|
+
<View style={styles.info}>
|
|
62
|
+
<AtomicText type="titleMedium" color="textPrimary" numberOfLines={1} style={styles.displayName}>
|
|
63
|
+
{profile.displayName}
|
|
64
|
+
</AtomicText>
|
|
65
|
+
{profile.userId && (
|
|
66
|
+
<AtomicText type="bodySmall" color="textSecondary" numberOfLines={1}>
|
|
67
|
+
{profile.userId}
|
|
68
|
+
</AtomicText>
|
|
69
|
+
)}
|
|
70
|
+
</View>
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
{onPress && !profile.isAnonymous && (
|
|
73
|
+
<AtomicIcon name="chevron-forward" size="sm" color="textSecondary" />
|
|
74
|
+
)}
|
|
75
|
+
</View>
|
|
85
76
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
{profile.isAnonymous && onSignIn && (
|
|
78
|
+
<View style={[styles.ctaContainer, { borderTopColor: tokens.colors.border }]}>
|
|
79
|
+
{profile.benefits && profile.benefits.length > 0 && (
|
|
80
|
+
<ProfileBenefitsList benefits={profile.benefits} />
|
|
81
|
+
)}
|
|
91
82
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
<TouchableOpacity
|
|
84
|
+
style={[styles.ctaButton, { backgroundColor: tokens.colors.primary }]}
|
|
85
|
+
onPress={onSignIn}
|
|
86
|
+
activeOpacity={0.8}
|
|
87
|
+
>
|
|
88
|
+
<AtomicText type="labelLarge" style={{ color: tokens.colors.onPrimary }}>
|
|
89
|
+
{signInText}
|
|
90
|
+
</AtomicText>
|
|
91
|
+
</TouchableOpacity>
|
|
92
|
+
</View>
|
|
93
|
+
)}
|
|
94
|
+
</TouchableOpacity>
|
|
95
|
+
);
|
|
105
96
|
};
|
|
106
97
|
|
|
107
98
|
const styles = StyleSheet.create({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
alignItems: "center",
|
|
116
|
-
},
|
|
117
|
-
avatarContainer: {
|
|
118
|
-
marginRight: 12,
|
|
119
|
-
},
|
|
120
|
-
info: {
|
|
121
|
-
flex: 1,
|
|
122
|
-
},
|
|
123
|
-
displayName: {
|
|
124
|
-
marginBottom: 2,
|
|
125
|
-
},
|
|
126
|
-
ctaContainer: {
|
|
127
|
-
marginTop: 12,
|
|
128
|
-
paddingTop: 12,
|
|
129
|
-
borderTopWidth: 1,
|
|
130
|
-
},
|
|
131
|
-
ctaButton: {
|
|
132
|
-
paddingVertical: 12,
|
|
133
|
-
borderRadius: 8,
|
|
134
|
-
alignItems: "center",
|
|
135
|
-
},
|
|
99
|
+
container: { borderRadius: 12, padding: 16, marginBottom: 16 },
|
|
100
|
+
content: { flexDirection: "row", alignItems: "center" },
|
|
101
|
+
avatarContainer: { marginRight: 12 },
|
|
102
|
+
info: { flex: 1 },
|
|
103
|
+
displayName: { marginBottom: 2 },
|
|
104
|
+
ctaContainer: { marginTop: 12, paddingTop: 12, borderTopWidth: 1 },
|
|
105
|
+
ctaButton: { paddingVertical: 12, borderRadius: 8, alignItems: "center" },
|
|
136
106
|
});
|
|
@@ -119,10 +119,7 @@ export const RegisterForm: React.FC<RegisterFormProps> = ({
|
|
|
119
119
|
style={styles.input}
|
|
120
120
|
/>
|
|
121
121
|
{password.length > 0 && (
|
|
122
|
-
<PasswordStrengthIndicator
|
|
123
|
-
translations={translations.passwordStrength}
|
|
124
|
-
requirements={passwordRequirements}
|
|
125
|
-
/>
|
|
122
|
+
<PasswordStrengthIndicator translations={translations.passwordStrength} requirements={passwordRequirements} />
|
|
126
123
|
)}
|
|
127
124
|
|
|
128
125
|
<AtomicInput
|
|
@@ -144,10 +141,7 @@ export const RegisterForm: React.FC<RegisterFormProps> = ({
|
|
|
144
141
|
style={styles.input}
|
|
145
142
|
/>
|
|
146
143
|
{confirmPassword.length > 0 && (
|
|
147
|
-
<PasswordMatchIndicator
|
|
148
|
-
translations={translations.passwordMatch}
|
|
149
|
-
isMatch={passwordsMatch}
|
|
150
|
-
/>
|
|
144
|
+
<PasswordMatchIndicator translations={translations.passwordMatch} isMatch={passwordsMatch} />
|
|
151
145
|
)}
|
|
152
146
|
|
|
153
147
|
<AuthErrorDisplay error={displayError} />
|
|
@@ -155,24 +149,14 @@ export const RegisterForm: React.FC<RegisterFormProps> = ({
|
|
|
155
149
|
<AtomicButton
|
|
156
150
|
variant="primary"
|
|
157
151
|
onPress={() => { void handleSignUp(); }}
|
|
158
|
-
disabled={
|
|
159
|
-
loading ||
|
|
160
|
-
!email.trim() ||
|
|
161
|
-
!password.trim() ||
|
|
162
|
-
!confirmPassword.trim()
|
|
163
|
-
}
|
|
152
|
+
disabled={loading || !email.trim() || !password.trim() || !confirmPassword.trim()}
|
|
164
153
|
fullWidth
|
|
165
154
|
style={styles.signUpButton}
|
|
166
155
|
>
|
|
167
156
|
{translations.signUp}
|
|
168
157
|
</AtomicButton>
|
|
169
158
|
|
|
170
|
-
<AuthLink
|
|
171
|
-
text={translations.alreadyHaveAccount}
|
|
172
|
-
linkText={translations.signIn}
|
|
173
|
-
onPress={onNavigateToLogin}
|
|
174
|
-
disabled={loading}
|
|
175
|
-
/>
|
|
159
|
+
<AuthLink text={translations.alreadyHaveAccount} linkText={translations.signIn} onPress={onNavigateToLogin} disabled={loading} />
|
|
176
160
|
|
|
177
161
|
<AuthLegalLinks
|
|
178
162
|
translations={translations.legal}
|
|
@@ -187,12 +171,6 @@ export const RegisterForm: React.FC<RegisterFormProps> = ({
|
|
|
187
171
|
};
|
|
188
172
|
|
|
189
173
|
const styles = StyleSheet.create({
|
|
190
|
-
input: {
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
signUpButton: {
|
|
194
|
-
minHeight: 52,
|
|
195
|
-
marginBottom: 16,
|
|
196
|
-
marginTop: 8,
|
|
197
|
-
},
|
|
174
|
+
input: { marginBottom: 20 },
|
|
175
|
+
signUpButton: { minHeight: 52, marginBottom: 16, marginTop: 8 },
|
|
198
176
|
});
|