@umituz/react-native-auth 3.4.30 → 3.4.32

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.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Auth Background Component
3
+ * Standard background for auth screens
4
+ */
5
+
6
+ import React from "react";
7
+ import { StyleSheet, View } from "react-native";
8
+ import { useAppDesignTokens } from "@umituz/react-native-design-system";
9
+
10
+ export const AuthBackground: React.FC = () => {
11
+ const tokens = useAppDesignTokens();
12
+
13
+ return (
14
+ <View
15
+ style={[
16
+ StyleSheet.absoluteFill,
17
+ { backgroundColor: tokens.colors.backgroundPrimary }
18
+ ]}
19
+ />
20
+ );
21
+ };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auth Container Component
3
- * Main container for auth screens with gradient and scroll
3
+ * Main container for auth screens with background and scroll
4
4
  */
5
5
 
6
6
  import React, { useMemo } from "react";
@@ -12,7 +12,7 @@ import {
12
12
  } from "react-native";
13
13
  import { useSafeAreaInsets } from "react-native-safe-area-context";
14
14
  import { useResponsive } from "@umituz/react-native-design-system";
15
- import { AuthGradientBackground } from "./AuthGradientBackground";
15
+ import { AuthBackground } from "./AuthBackground";
16
16
 
17
17
  /** Layout constants for auth screens */
18
18
  const AUTH_LAYOUT = {
@@ -39,7 +39,7 @@ export const AuthContainer: React.FC<AuthContainerProps> = ({ children }) => {
39
39
  style={styles.container}
40
40
  behavior="padding"
41
41
  >
42
- <AuthGradientBackground />
42
+ <AuthBackground />
43
43
  <ScrollView
44
44
  contentContainerStyle={[styles.scrollContent, dynamicStyles]}
45
45
  keyboardShouldPersistTaps="handled"
@@ -0,0 +1,222 @@
1
+ # LoginForm & RegisterForm
2
+
3
+ Pre-built authentication form components for email/password login and registration.
4
+
5
+ ---
6
+
7
+ ## LoginForm
8
+
9
+ Email and password login form component with built-in validation.
10
+
11
+ ### Strategy
12
+
13
+ **Purpose**: Provides a complete login form with email/password validation, error handling, and loading states without needing to build from scratch.
14
+
15
+ **When to Use**:
16
+ - Standard email/password authentication flow
17
+ - Need quick login screen implementation
18
+ - Want built-in validation and error handling
19
+
20
+ **Import Path**:
21
+ ```typescript
22
+ import { LoginForm } from '@umituz/react-native-auth';
23
+ ```
24
+
25
+ **Component Location**: `src/presentation/components/LoginForm.tsx`
26
+
27
+ ### Rules
28
+
29
+ **MUST**:
30
+ - Provide `onNavigateToRegister` callback for navigation to registration screen
31
+ - Use within an auth container or proper layout wrapper
32
+ - Handle loading states during authentication
33
+ - Display error messages from validation
34
+
35
+ **MUST NOT**:
36
+ - Modify internal form validation logic
37
+ - Override keyboard navigation behavior
38
+ - Bypass built-in error handling
39
+
40
+ ### Constraints
41
+
42
+ **LIMITATIONS**:
43
+ - Only supports email/password authentication (use social login components separately)
44
+ - Validation rules are fixed (email format, password required)
45
+ - Error messages follow localization keys
46
+ - Form layout is predefined
47
+
48
+ **PLATFORM SUPPORT**:
49
+ - iOS: ✅ Fully supported
50
+ - Android: ✅ Fully supported
51
+ - Web: ✅ Fully supported
52
+
53
+ **REQUIREMENTS**:
54
+ - Parent component must handle navigation
55
+ - Authentication context/provider must be configured
56
+ - Localization keys must be defined
57
+
58
+ ---
59
+
60
+ ## RegisterForm
61
+
62
+ User registration form with display name, email, password, and confirm password fields.
63
+
64
+ ### Strategy
65
+
66
+ **Purpose**: Provides complete registration flow with password strength indicator, validation, and terms acceptance.
67
+
68
+ **When to Use**:
69
+ - Standard user registration flow
70
+ - Need password strength requirements
71
+ - Require terms/privacy acceptance
72
+
73
+ **Import Path**:
74
+ ```typescript
75
+ import { RegisterForm } from '@umituz/react-native-auth';
76
+ ```
77
+
78
+ **Component Location**: `src/presentation/components/RegisterForm.tsx`
79
+
80
+ ### Rules
81
+
82
+ **MUST**:
83
+ - Provide `onNavigateToLogin` callback for navigation back to login
84
+ - Provide terms/privacy URLs or handlers
85
+ - Display password strength indicator to users
86
+ - Handle terms acceptance before submission
87
+
88
+ **MUST NOT**:
89
+ - Allow registration without terms acceptance
90
+ - Disable password validation
91
+ - Bypass email verification flow (if enabled)
92
+
93
+ ### Constraints
94
+
95
+ **LIMITATIONS**:
96
+ - Password requirements are fixed (8+ chars, uppercase, lowercase, number, special char)
97
+ - Terms/privacy links must be provided
98
+ - Form fields are predefined (display name, email, password, confirm password)
99
+ - Cannot add custom validation rules
100
+
101
+ **VALIDATION REQUIREMENTS**:
102
+ - Display name: Required, cannot be empty
103
+ - Email: Required, must be valid format
104
+ - Password: Required, must meet complexity requirements
105
+ - Confirm Password: Required, must match password
106
+
107
+ **PLATFORM SUPPORT**:
108
+ - iOS: ✅ Fully supported
109
+ - Android: ✅ Fully supported
110
+ - Web: ✅ Fully supported
111
+
112
+ ---
113
+
114
+ ## Form Validation
115
+
116
+ ### Strategy
117
+
118
+ **Purpose**: Built-in validation ensures user input meets security requirements before submission.
119
+
120
+ **Validation Utility Location**: `src/infrastructure/utils/AuthValidation.ts`
121
+
122
+ ### Rules
123
+
124
+ **MUST**:
125
+ - Use `validateEmail` for email format validation
126
+ - Use `validatePasswordForRegister` for password requirements
127
+ - Display validation errors to users
128
+ - Prevent submission with invalid data
129
+
130
+ **MUST NOT**:
131
+ - Allow empty required fields
132
+ - Bypass password complexity requirements
133
+ - Submit with mismatched passwords
134
+
135
+ ### Constraints
136
+
137
+ **PASSWORD REQUIREMENTS** (Default):
138
+ - Minimum length: 8 characters
139
+ - Must contain: Uppercase letter
140
+ - Must contain: Lowercase letter
141
+ - Must contain: Number
142
+ - Must contain: Special character
143
+
144
+ **EMAIL REQUIREMENTS**:
145
+ - Valid email format (user@domain.com)
146
+ - Cannot be empty
147
+
148
+ **CONFIGURABLE SETTINGS**:
149
+ See `DEFAULT_VAL_CONFIG` in `AuthValidation.ts`
150
+
151
+ ---
152
+
153
+ ## Error Handling
154
+
155
+ ### Strategy
156
+
157
+ **Purpose**: Clear user feedback for validation and authentication errors.
158
+
159
+ ### Rules
160
+
161
+ **MUST**:
162
+ - Display field-level validation errors
163
+ - Show authentication errors (wrong password, user not found, etc.)
164
+ - Provide clear error messages in user's language
165
+ - Allow retry after error
166
+
167
+ **MUST NOT**:
168
+ - Show raw error codes to users
169
+ - Expose sensitive information in errors
170
+ - Block user indefinitely after errors
171
+
172
+ ### Constraints
173
+
174
+ **ERROR TYPES**:
175
+ - Validation errors: Red text below input field
176
+ - Network errors: Alert or banner message
177
+ - Authentication errors: Clear message with retry option
178
+
179
+ **LOCALIZATION**:
180
+ All error messages must use localization keys from i18n configuration.
181
+
182
+ ---
183
+
184
+ ## Accessibility
185
+
186
+ ### Strategy
187
+
188
+ **Purpose**: Ensure forms are accessible to all users including screen reader users.
189
+
190
+ ### Rules
191
+
192
+ **MUST**:
193
+ - Provide labels for all input fields
194
+ - Announce errors to screen readers
195
+ - Support keyboard navigation
196
+ - Maintain proper focus order
197
+
198
+ **MUST NOT**:
199
+ - Rely on color alone for error indication
200
+ - Use placeholder text as labels
201
+ - Disrupt screen reader navigation
202
+
203
+ ### Constraints
204
+
205
+ **WCAG COMPLIANCE**:
206
+ - Minimum contrast ratios for text
207
+ - Touch target size: 44x44px minimum
208
+ - Focus indicators on all interactive elements
209
+ - Screen reader announcements for state changes
210
+
211
+ ---
212
+
213
+ ## Related Components
214
+
215
+ - **`PasswordStrengthIndicator`** (`src/presentation/components/PasswordIndicators.tsx`) - Visual password requirements display
216
+ - **`PasswordMatchIndicator`** (`src/presentation/components/PasswordIndicators.tsx`) - Password confirmation feedback
217
+ - **`SocialLoginButtons`** (`src/presentation/components/SocialLoginButtons.tsx`) - Social authentication integration
218
+
219
+ ## Related Hooks
220
+
221
+ - **`useAuth`** (`src/presentation/hooks/useAuth.ts`) - Main authentication state management
222
+ - **`useSocialLogin`** (`src/presentation/hooks/useSocialLogin.ts`) - Social authentication handlers
@@ -0,0 +1,260 @@
1
+ # Password Indicators
2
+
3
+ Visual components for password validation and user feedback during registration.
4
+
5
+ ---
6
+
7
+ ## PasswordStrengthIndicator
8
+
9
+ Displays password requirements visually and shows which requirements are met as user types.
10
+
11
+ ### Strategy
12
+
13
+ **Purpose**: Provides real-time visual feedback on password strength to guide users toward creating secure passwords.
14
+
15
+ **When to Use**:
16
+ - Registration screens requiring password input
17
+ - Password change screens
18
+ - Anywhere users create/update passwords
19
+ - Need to show password security requirements
20
+
21
+ **Import Path**:
22
+ ```typescript
23
+ import { PasswordStrengthIndicator } from '@umituz/react-native-auth';
24
+ ```
25
+
26
+ **Component Location**: `src/presentation/components/PasswordIndicators.tsx`
27
+
28
+ **Validation Utility**: `src/infrastructure/utils/AuthValidation.ts`
29
+
30
+ ### Rules
31
+
32
+ **MUST**:
33
+ - Pass `requirements` object with boolean values for each requirement
34
+ - Show indicator before user starts typing for guidance
35
+ - Update in real-time as password changes
36
+ - Use clear visual distinction (color/icons) for met vs unmet requirements
37
+ - Support both labeled and compact (dots only) modes
38
+
39
+ **MUST NOT**:
40
+ - Hide requirements until after user fails validation
41
+ - Use color alone to convey requirement status (add icons/text)
42
+ - Allow password submission when requirements not met
43
+ - Modify validation logic (use provided utilities)
44
+
45
+ ### Constraints
46
+
47
+ **REQUIREMENT TYPES** (Fixed):
48
+ ```typescript
49
+ interface PasswordRequirements {
50
+ hasMinLength: boolean; // Default: 8 characters
51
+ hasUppercase: boolean; // A-Z
52
+ hasLowercase: boolean; // a-z
53
+ hasNumber: boolean; // 0-9
54
+ hasSpecialChar: boolean; // Special characters
55
+ }
56
+ ```
57
+
58
+ **DISPLAY MODES**:
59
+ - Full mode: Labels with each requirement
60
+ - Compact mode: Dots only (5 dots = 5 requirements)
61
+
62
+ **VISUAL FEEDBACK**:
63
+ - Met requirement: Green color with checkmark
64
+ - Unmet requirement: Gray color with dot
65
+ - Partially met: Yellow/orange color (optional enhancement)
66
+
67
+ **CUSTOMIZATION LIMITS**:
68
+ - Cannot add/remove requirements
69
+ - Cannot change requirement order
70
+ - Colors follow design system tokens
71
+
72
+ **PLATFORM SUPPORT**:
73
+ - iOS: ✅ Fully supported
74
+ - Android: ✅ Fully supported
75
+ - Web: ✅ Fully supported
76
+
77
+ **REQUIREMENTS**:
78
+ - Parent component must calculate requirements object
79
+ - Must recalculate on every password change
80
+ - Localization keys for requirement labels
81
+
82
+ ---
83
+
84
+ ## PasswordMatchIndicator
85
+
86
+ Shows whether two password fields match in real-time.
87
+
88
+ ### Strategy
89
+
90
+ **Purpose**: Provides immediate feedback when confirming password to prevent typos and ensure user entered intended password.
91
+
92
+ **When to Use**:
93
+ - Registration forms with password confirmation
94
+ - Password change forms
95
+ - Anywhere password needs to be re-entered for confirmation
96
+
97
+ **Import Path**:
98
+ ```typescript
99
+ import { PasswordMatchIndicator } from '@umituz/react-native-auth';
100
+ ```
101
+
102
+ **Component Location**: `src/presentation/components/PasswordIndicators.tsx`
103
+
104
+ ### Rules
105
+
106
+ **MUST**:
107
+ - Only show when confirm password field has input
108
+ - Update in real-time as user types
109
+ - Show clear visual feedback (green = match, red = no match)
110
+ - Display before form submission
111
+ - Check for exact string match (case-sensitive)
112
+
113
+ **MUST NOT**:
114
+ - Show indicator before user types in confirm field
115
+ - Allow submission if passwords don't match
116
+ - Use ambiguous colors (red/green only, no yellow)
117
+ - Hide indicator after initial display
118
+
119
+ ### Constraints
120
+
121
+ **DISPLAY TRIGGERS**:
122
+ - Show only when: `confirmPassword.length > 0`
123
+ - Hide when: Confirm field cleared
124
+ - Update on: Every keystroke in confirm field
125
+
126
+ **MATCH CRITERIA**:
127
+ - Exact string match required
128
+ - Case-sensitive
129
+ - Whitespace-sensitive
130
+ - No fuzzy matching allowed
131
+
132
+ **VISUAL STATES**:
133
+ - Match: Green color, checkmark icon, positive text
134
+ - No Match: Red color, X icon, negative text
135
+ - Empty: Hidden (no indicator)
136
+
137
+ **TIMING CONSTRAINTS**:
138
+ - No debounce (immediate feedback)
139
+ - No animation delay
140
+ - Instant update on keystroke
141
+
142
+ **PLATFORM SUPPORT**:
143
+ - iOS: ✅ Fully supported
144
+ - Android: ✅ Fully supported
145
+ - Web: ✅ Fully supported
146
+
147
+ ---
148
+
149
+ ## Combined Usage Strategy
150
+
151
+ ### Strategy
152
+
153
+ **Purpose**: Use both indicators together for complete password validation feedback during registration.
154
+
155
+ **When to Use**:
156
+ - User registration flow
157
+ - Password creation with confirmation
158
+ - Need both strength requirements and match confirmation
159
+
160
+ ### Rules
161
+
162
+ **MUST**:
163
+ - Show PasswordStrengthIndicator below password field
164
+ - Show PasswordMatchIndicator below confirm password field
165
+ - Calculate strength requirements on password field changes
166
+ - Calculate match status on confirm field changes
167
+ - Disable submit button until both: all requirements met AND passwords match
168
+
169
+ **MUST NOT**:
170
+ - Show match indicator before strength indicator
171
+ - Allow submission with unmet requirements even if passwords match
172
+ - Hide strength indicator after user moves to confirm field
173
+
174
+ ### Constraints
175
+
176
+ **FORM FLOW**:
177
+ 1. User types password → Show strength indicator
178
+ 2. User types confirm password → Show match indicator
179
+ 3. Both valid → Enable submit button
180
+ 4. Either invalid → Disable submit button
181
+
182
+ **VALIDATION DEPENDENCIES**:
183
+ - Strength validation: Password field only
184
+ - Match validation: Both password fields
185
+ - Submit enabled: Both validations pass
186
+
187
+ ---
188
+
189
+ ## Accessibility Requirements
190
+
191
+ ### Strategy
192
+
193
+ **Purpose**: Ensure password validation is accessible to all users including screen reader users.
194
+
195
+ ### Rules
196
+
197
+ **MUST**:
198
+ - Announce requirement status changes to screen readers
199
+ - Provide text alternatives to color indicators
200
+ - Use semantic HTML (if web)
201
+ - Maintain high contrast for visibility
202
+ - Support keyboard navigation
203
+
204
+ **MUST NOT**:
205
+ - Rely on color alone to convey status
206
+ - Use placeholder text for requirements
207
+ - Hide requirements from screen readers
208
+
209
+ ### Constraints
210
+
211
+ **SCREEN READER**:
212
+ - Announce "Password requirement met: 3 of 5"
213
+ - Announce match status: "Passwords match" or "Passwords don't match"
214
+ - Use ARIA live regions for dynamic updates
215
+
216
+ **VISUAL ACCESSIBILITY**:
217
+ - Minimum contrast ratio: 4.5:1 for text
218
+ - Color + icon for requirement status (not color alone)
219
+ - Touch target size: 44x44px minimum (mobile)
220
+
221
+ ---
222
+
223
+ ## Design System Integration
224
+
225
+ ### Strategy
226
+
227
+ **Purpose**: Consistent styling with application design system.
228
+
229
+ ### Rules
230
+
231
+ **MUST**:
232
+ - Use design system color tokens for valid/invalid states
233
+ - Follow design system spacing guidelines
234
+ - Use design system typography
235
+ - Match design system border radius
236
+
237
+ **MUST NOT**:
238
+ - Hardcode colors or sizes
239
+ - Use custom icons outside design system
240
+ - Override design system animations
241
+
242
+ ### Constraints
243
+
244
+ **TOKEN DEPENDENCIES**:
245
+ - `tokens.colors.success` - Met requirement
246
+ - `tokens.colors.error` - Unmet requirement
247
+ - `tokens.spacing.md` - Indicator spacing
248
+ - `tokens.radius.sm` - Icon border radius
249
+
250
+ ---
251
+
252
+ ## Related Components
253
+
254
+ - **`RegisterForm`** (`src/presentation/components/RegisterForm.tsx`) - Uses both indicators automatically
255
+ - **`LoginForm`** (`src/presentation/components/LoginForm.tsx`) - May use strength indicator for password changes
256
+
257
+ ## Related Utilities
258
+
259
+ - **`validatePasswordForRegister`** (`src/infrastructure/utils/AuthValidation.ts`) - Password validation logic
260
+ - **`DEFAULT_VAL_CONFIG`** (`src/infrastructure/utils/AuthValidation.ts`) - Configuration for requirements