@umituz/react-native-auth 3.4.31 → 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.
@@ -1,471 +1,260 @@
1
1
  # Password Indicators
2
2
 
3
- Şifre validasyonu ve kullanıcı feedback'i için component'ler.
4
-
5
- ## Component'ler
6
-
7
- - **[`PasswordStrengthIndicator`](#passwordstrengthindicator)** - Şifre güç göstergesi
8
- - **[`PasswordMatchIndicator`](#passwordmatchindicator)** - Şifre eşleşme göstergesi
3
+ Visual components for password validation and user feedback during registration.
9
4
 
10
5
  ---
11
6
 
12
7
  ## PasswordStrengthIndicator
13
8
 
14
- Şifre gereksinimlerini görsel olarak gösterir. Kullanıcı şifre girdikçe hangi gereksinimleri karşıladığını gösterir.
9
+ Displays password requirements visually and shows which requirements are met as user types.
10
+
11
+ ### Strategy
15
12
 
16
- ### Kullanım
13
+ **Purpose**: Provides real-time visual feedback on password strength to guide users toward creating secure passwords.
17
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**:
18
22
  ```typescript
19
23
  import { PasswordStrengthIndicator } from '@umituz/react-native-auth';
20
-
21
- function RegisterForm() {
22
- const [password, setPassword] = useState('');
23
- const requirements = validatePasswordRequirements(password);
24
-
25
- return (
26
- <View>
27
- <TextInput
28
- value={password}
29
- onChangeText={setPassword}
30
- placeholder="Şifre"
31
- secureTextEntry
32
- />
33
-
34
- <PasswordStrengthIndicator requirements={requirements} />
35
- </View>
36
- );
37
- }
38
24
  ```
39
25
 
40
- ### Props
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
41
38
 
42
- | Prop | Tip | Required | Default | Açıklama |
43
- |------|-----|----------|---------|----------|
44
- | `requirements` | `PasswordRequirements` | Yes | - | Şifre gereksinimleri objesi |
45
- | `showLabels` | `boolean` | No | `true` | Label'lar gösterilsin mi |
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)
46
44
 
47
- #### PasswordRequirements
45
+ ### Constraints
48
46
 
47
+ **REQUIREMENT TYPES** (Fixed):
49
48
  ```typescript
50
49
  interface PasswordRequirements {
51
- hasMinLength: boolean; // Minimum uzunluk (varsayılan: 8)
52
- hasUppercase: boolean; // Büyük harf içeriyor
53
- hasLowercase: boolean; // Küçük harf içeriyor
54
- hasNumber: boolean; // Rakam içeriyor
55
- hasSpecialChar: boolean; // Özel karakter içeriyor
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
56
55
  }
57
56
  ```
58
57
 
59
- ### Örnekler
58
+ **DISPLAY MODES**:
59
+ - Full mode: Labels with each requirement
60
+ - Compact mode: Dots only (5 dots = 5 requirements)
60
61
 
61
- #### Tam Kullanım (Label'larla)
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)
62
66
 
63
- ```typescript
64
- function PasswordField() {
65
- const [password, setPassword] = useState('');
66
-
67
- const requirements: PasswordRequirements = {
68
- hasMinLength: password.length >= 8,
69
- hasUppercase: /[A-Z]/.test(password),
70
- hasLowercase: /[a-z]/.test(password),
71
- hasNumber: /[0-9]/.test(password),
72
- hasSpecialChar: /[!@#$%^&*(),.?":{}|<>]/.test(password),
73
- };
74
-
75
- return (
76
- <View>
77
- <TextInput
78
- value={password}
79
- onChangeText={setPassword}
80
- placeholder="Şifre"
81
- secureTextEntry
82
- />
83
-
84
- <PasswordStrengthIndicator
85
- requirements={requirements}
86
- showLabels={true}
87
- />
88
- </View>
89
- );
90
- }
91
- ```
67
+ **CUSTOMIZATION LIMITS**:
68
+ - Cannot add/remove requirements
69
+ - Cannot change requirement order
70
+ - Colors follow design system tokens
92
71
 
93
- #### Sadece Dot'lar (Label'sız)
72
+ **PLATFORM SUPPORT**:
73
+ - iOS: ✅ Fully supported
74
+ - Android: ✅ Fully supported
75
+ - Web: ✅ Fully supported
94
76
 
95
- ```typescript
96
- function CompactPasswordField() {
97
- const [password, setPassword] = useState('');
98
-
99
- const requirements: PasswordRequirements = {
100
- hasMinLength: password.length >= 8,
101
- hasUppercase: /[A-Z]/.test(password),
102
- hasLowercase: /[a-z]/.test(password),
103
- hasNumber: /[0-9]/.test(password),
104
- hasSpecialChar: /[!@#$%^&*(),.?":{}|<>]/.test(password),
105
- };
106
-
107
- return (
108
- <View>
109
- <TextInput
110
- value={password}
111
- onChangeText={setPassword}
112
- placeholder="Şifre"
113
- secureTextEntry
114
- />
115
-
116
- <PasswordStrengthIndicator
117
- requirements={requirements}
118
- showLabels={false}
119
- />
120
- </View>
121
- );
122
- }
123
- ```
77
+ **REQUIREMENTS**:
78
+ - Parent component must calculate requirements object
79
+ - Must recalculate on every password change
80
+ - Localization keys for requirement labels
81
+
82
+ ---
124
83
 
125
- #### Custom Validasyon ile
84
+ ## PasswordMatchIndicator
126
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**:
127
98
  ```typescript
128
- function CustomPasswordField() {
129
- const [password, setPassword] = useState('');
130
-
131
- const requirements: PasswordRequirements = {
132
- hasMinLength: password.length >= 12, // Özel: 12 karakter
133
- hasUppercase: /[A-Z]/.test(password),
134
- hasLowercase: /[a-z]/.test(password),
135
- hasNumber: /[0-9]/.test(password),
136
- hasSpecialChar: /[!@#$%^&*(),.?":{}|<>]/.test(password),
137
- };
138
-
139
- return (
140
- <View>
141
- <TextInput
142
- value={password}
143
- onChangeText={setPassword}
144
- placeholder="Şifre (en az 12 karakter)"
145
- secureTextEntry
146
- />
147
-
148
- <PasswordStrengthIndicator
149
- requirements={requirements}
150
- />
151
-
152
- {password.length > 0 && password.length < 12 && (
153
- <Text style={styles.warning}>
154
- Şifre en az 12 karakter olmalıdır
155
- </Text>
156
- )}
157
- </View>
158
- );
159
- }
99
+ import { PasswordMatchIndicator } from '@umituz/react-native-auth';
160
100
  ```
161
101
 
162
- #### Custom Validation Hook ile
102
+ **Component Location**: `src/presentation/components/PasswordIndicators.tsx`
163
103
 
164
- ```typescript
165
- function usePasswordValidation(minLength = 8) {
166
- const [password, setPassword] = useState('');
167
-
168
- const requirements = useMemo(() => ({
169
- hasMinLength: password.length >= minLength,
170
- hasUppercase: /[A-Z]/.test(password),
171
- hasLowercase: /[a-z]/.test(password),
172
- hasNumber: /[0-9]/.test(password),
173
- hasSpecialChar: /[!@#$%^&*(),.?":{}|<>]/.test(password),
174
- }), [password, minLength]);
175
-
176
- const allRequirementsMet = useMemo(() =>
177
- Object.values(requirements).every(Boolean),
178
- [requirements]
179
- );
180
-
181
- return {
182
- password,
183
- setPassword,
184
- requirements,
185
- allRequirementsMet,
186
- };
187
- }
104
+ ### Rules
188
105
 
189
- function RegisterForm() {
190
- const { password, setPassword, requirements, allRequirementsMet } = usePasswordValidation();
191
-
192
- return (
193
- <View>
194
- <TextInput
195
- value={password}
196
- onChangeText={setPassword}
197
- placeholder="Şifre"
198
- secureTextEntry
199
- />
200
-
201
- <PasswordStrengthIndicator requirements={requirements} />
202
-
203
- <Button
204
- onPress={handleRegister}
205
- disabled={!allRequirementsMet}
206
- >
207
- Kayıt Ol
208
- </Button>
209
- </View>
210
- );
211
- }
212
- ```
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)
213
112
 
214
- ### Görünüm
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
215
118
 
216
- Label'lı modda:
217
- ```
218
- ● En az 8 karakter
219
- ● Büyük harf
220
- ● Küçük harf
221
- ● Rakam
222
- ● Özel karakter
223
- ```
119
+ ### Constraints
224
120
 
225
- Label'sız modda:
226
- ```
227
-
228
- ```
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
229
141
 
230
- Yeşil dot ✓ = Gereklilik karşılandı
231
- Gri dot = Gereklilik karşılanmadı
142
+ **PLATFORM SUPPORT**:
143
+ - iOS: Fully supported
144
+ - Android: ✅ Fully supported
145
+ - Web: ✅ Fully supported
232
146
 
233
147
  ---
234
148
 
235
- ## PasswordMatchIndicator
149
+ ## Combined Usage Strategy
236
150
 
237
- İki şifre alanının eşleşip eşleşmediğini gösterir.
151
+ ### Strategy
238
152
 
239
- ### Kullanım
153
+ **Purpose**: Use both indicators together for complete password validation feedback during registration.
240
154
 
241
- ```typescript
242
- import { PasswordMatchIndicator } from '@umituz/react-native-auth';
155
+ **When to Use**:
156
+ - User registration flow
157
+ - Password creation with confirmation
158
+ - Need both strength requirements and match confirmation
243
159
 
244
- function RegisterForm() {
245
- const [password, setPassword] = useState('');
246
- const [confirmPassword, setConfirmPassword] = useState('');
247
-
248
- const passwordsMatch = password === confirmPassword && password.length > 0;
249
-
250
- return (
251
- <View>
252
- <TextInput
253
- value={password}
254
- onChangeText={setPassword}
255
- placeholder="Şifre"
256
- secureTextEntry
257
- />
258
-
259
- <TextInput
260
- value={confirmPassword}
261
- onChangeText={setConfirmPassword}
262
- placeholder="Şifre Tekrar"
263
- secureTextEntry
264
- />
265
-
266
- <PasswordMatchIndicator isMatch={passwordsMatch} />
267
- </View>
268
- );
269
- }
270
- ```
160
+ ### Rules
271
161
 
272
- ### Props
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
273
168
 
274
- | Prop | Tip | Required | Açıklama |
275
- |------|-----|----------|----------|
276
- | `isMatch` | `boolean` | Yes | Şifreler eşleşiyor mu |
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
277
173
 
278
- ### Örnekler
174
+ ### Constraints
279
175
 
280
- #### Basit Kullanım
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
281
181
 
282
- ```typescript
283
- function ConfirmPasswordField() {
284
- const [password, setPassword] = useState('');
285
- const [confirmPassword, setConfirmPassword] = useState('');
286
-
287
- const passwordsMatch = password === confirmPassword && password.length > 0;
288
-
289
- return (
290
- <View>
291
- <TextInput
292
- value={confirmPassword}
293
- onChangeText={setConfirmPassword}
294
- placeholder="Şifre Tekrar"
295
- secureTextEntry
296
- />
297
-
298
- {confirmPassword.length > 0 && (
299
- <PasswordMatchIndicator isMatch={passwordsMatch} />
300
- )}
301
- </View>
302
- );
303
- }
304
- ```
182
+ **VALIDATION DEPENDENCIES**:
183
+ - Strength validation: Password field only
184
+ - Match validation: Both password fields
185
+ - Submit enabled: Both validations pass
305
186
 
306
- #### Buton Disabled State ile
187
+ ---
307
188
 
308
- ```typescript
309
- function RegisterForm() {
310
- const [password, setPassword] = useState('');
311
- const [confirmPassword, setConfirmPassword] = useState('');
312
-
313
- const passwordsMatch = password === confirmPassword && password.length > 0;
314
- const canSubmit = passwordsMatch && password.length >= 8;
315
-
316
- return (
317
- <View>
318
- <TextInput
319
- value={password}
320
- onChangeText={setPassword}
321
- placeholder="Şifre"
322
- secureTextEntry
323
- />
324
-
325
- <TextInput
326
- value={confirmPassword}
327
- onChangeText={setConfirmPassword}
328
- placeholder="Şifre Tekrar"
329
- secureTextEntry
330
- />
331
-
332
- <PasswordMatchIndicator isMatch={passwordsMatch} />
333
-
334
- <Button
335
- onPress={handleRegister}
336
- disabled={!canSubmit}
337
- >
338
- Kayıt Ol
339
- </Button>
340
- </View>
341
- );
342
- }
343
- ```
189
+ ## Accessibility Requirements
344
190
 
345
- #### Custom Validation ile
191
+ ### Strategy
346
192
 
347
- ```typescript
348
- function SecureRegisterForm() {
349
- const [password, setPassword] = useState('');
350
- const [confirmPassword, setConfirmPassword] = useState('');
351
-
352
- const passwordsMatch = password === confirmPassword && password.length > 0;
353
-
354
- // Şifre güvenliği kontrolü
355
- const isPasswordSecure = useMemo(() => {
356
- const hasMinLength = password.length >= 8;
357
- const hasUppercase = /[A-Z]/.test(password);
358
- const hasLowercase = /[a-z]/.test(password);
359
- const hasNumber = /[0-9]/.test(password);
360
-
361
- return hasMinLength && hasUppercase && hasLowercase && hasNumber;
362
- }, [password]);
363
-
364
- const canSubmit = passwordsMatch && isPasswordSecure;
365
-
366
- return (
367
- <View>
368
- <TextInput
369
- value={password}
370
- onChangeText={setPassword}
371
- placeholder="Şifre"
372
- secureTextEntry
373
- />
374
-
375
- <TextInput
376
- value={confirmPassword}
377
- onChangeText={setConfirmPassword}
378
- placeholder="Şifre Tekrar"
379
- secureTextEntry
380
- />
381
-
382
- {confirmPassword.length > 0 && (
383
- <PasswordMatchIndicator isMatch={passwordsMatch} />
384
- )}
385
-
386
- <Button
387
- onPress={handleRegister}
388
- disabled={!canSubmit}
389
- >
390
- Kayıt Ol
391
- </Button>
392
- </View>
393
- );
394
- }
395
- ```
193
+ **Purpose**: Ensure password validation is accessible to all users including screen reader users.
396
194
 
397
- ### Görünüm
195
+ ### Rules
398
196
 
399
- Eşleşiyor ✓:
400
- ```
401
- Şifreler eşleşiyor
402
- ```
403
- (Yeşil renk)
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
404
203
 
405
- Eşleşmiyor ✗:
406
- ```
407
- Şifreler eşleşmiyor
408
- ```
409
- (Kırmızı renk)
204
+ **MUST NOT**:
205
+ - Rely on color alone to convey status
206
+ - Use placeholder text for requirements
207
+ - Hide requirements from screen readers
410
208
 
411
- ## Birlikte Kullanım
209
+ ### Constraints
412
210
 
413
- ```typescript
414
- function CompleteRegisterForm() {
415
- const [password, setPassword] = useState('');
416
- const [confirmPassword, setConfirmPassword] = useState('');
417
-
418
- const requirements: PasswordRequirements = {
419
- hasMinLength: password.length >= 8,
420
- hasUppercase: /[A-Z]/.test(password),
421
- hasLowercase: /[a-z]/.test(password),
422
- hasNumber: /[0-9]/.test(password),
423
- hasSpecialChar: /[!@#$%^&*(),.?":{}|<>]/.test(password),
424
- };
425
-
426
- const allRequirementsMet = Object.values(requirements).every(Boolean);
427
- const passwordsMatch = password === confirmPassword && password.length > 0;
428
- const canSubmit = allRequirementsMet && passwordsMatch;
429
-
430
- return (
431
- <View>
432
- <TextInput
433
- value={password}
434
- onChangeText={setPassword}
435
- placeholder="Şifre"
436
- secureTextEntry
437
- />
438
-
439
- <PasswordStrengthIndicator requirements={requirements} />
440
-
441
- <TextInput
442
- value={confirmPassword}
443
- onChangeText={setConfirmPassword}
444
- placeholder="Şifre Tekrar"
445
- secureTextEntry
446
- />
447
-
448
- {confirmPassword.length > 0 && (
449
- <PasswordMatchIndicator isMatch={passwordsMatch} />
450
- )}
451
-
452
- <Button
453
- onPress={handleRegister}
454
- disabled={!canSubmit}
455
- >
456
- Kayıt Ol
457
- </Button>
458
- </View>
459
- );
460
- }
461
- ```
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
+ ---
462
251
 
463
- ## İlgili Component'ler
252
+ ## Related Components
464
253
 
465
- - [`RegisterForm`](./LoginForm.md#registerform) - Kayıt formu
466
- - [`useRegisterForm`](../hooks/useRegisterForm.md) - Register form hook'u
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
467
256
 
468
- ## İlgili Util'ler
257
+ ## Related Utilities
469
258
 
470
- - [`validatePasswordForRegister`](../../infrastructure/utils/AuthValidation.ts) - Şifre validasyonu
471
- - [`DEFAULT_VAL_CONFIG`](../../infrastructure/utils/AuthValidation.ts) - Varsayılan validasyon konfigürasyonu
259
+ - **`validatePasswordForRegister`** (`src/infrastructure/utils/AuthValidation.ts`) - Password validation logic
260
+ - **`DEFAULT_VAL_CONFIG`** (`src/infrastructure/utils/AuthValidation.ts`) - Configuration for requirements