@umituz/react-native-auth 4.3.76 → 4.3.78

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.
Files changed (52) hide show
  1. package/package.json +1 -4
  2. package/src/exports/domain.ts +32 -0
  3. package/src/exports/infrastructure.ts +80 -0
  4. package/src/exports/presentation.ts +115 -0
  5. package/src/exports/shared.ts +93 -0
  6. package/src/exports/utils.ts +10 -0
  7. package/src/index.ts +7 -132
  8. package/src/infrastructure/utils/listener/anonymousSignIn/attemptAnonymousSignIn.ts +81 -0
  9. package/src/infrastructure/utils/listener/anonymousSignIn/constants.ts +7 -0
  10. package/src/infrastructure/utils/listener/anonymousSignIn/createAnonymousSignInHandler.ts +59 -0
  11. package/src/infrastructure/utils/listener/anonymousSignIn/index.ts +16 -0
  12. package/src/infrastructure/utils/listener/anonymousSignIn/types.ts +21 -0
  13. package/src/presentation/components/RegisterForm/RegisterForm.tsx +91 -0
  14. package/src/presentation/components/RegisterForm/RegisterFormFields.tsx +117 -0
  15. package/src/presentation/components/RegisterForm/index.ts +7 -0
  16. package/src/presentation/components/RegisterForm/styles.ts +11 -0
  17. package/src/presentation/components/RegisterForm/types.ts +34 -0
  18. package/src/presentation/hooks/auth/index.ts +7 -0
  19. package/src/presentation/hooks/auth/types.ts +26 -0
  20. package/src/presentation/hooks/auth/useAuthBottomSheet.ts +110 -0
  21. package/src/presentation/hooks/auth/useSocialAuthHandlers.ts +56 -0
  22. package/src/shared/error-handling/handlers/ErrorHandler.ts +70 -0
  23. package/src/shared/error-handling/handlers/FormErrorHandler.ts +99 -0
  24. package/src/shared/error-handling/handlers/index.ts +7 -0
  25. package/src/shared/error-handling/index.ts +19 -0
  26. package/src/shared/error-handling/mappers/ErrorMapper.ts +115 -0
  27. package/src/shared/error-handling/mappers/FieldErrorMapper.ts +97 -0
  28. package/src/shared/error-handling/mappers/index.ts +6 -0
  29. package/src/shared/error-handling/types/ErrorTypes.ts +23 -0
  30. package/src/shared/error-handling/types/index.ts +10 -0
  31. package/src/shared/form/builders/FieldBuilder.ts +90 -0
  32. package/src/shared/form/builders/FormBuilder.ts +126 -0
  33. package/src/shared/form/builders/index.ts +9 -0
  34. package/src/shared/form/index.ts +51 -0
  35. package/src/shared/form/state/FormState.ts +114 -0
  36. package/src/shared/form/state/index.ts +16 -0
  37. package/src/shared/form/types/FormTypes.ts +30 -0
  38. package/src/shared/form/types/index.ts +11 -0
  39. package/src/shared/form/utils/fieldUtils.ts +115 -0
  40. package/src/shared/form/utils/formUtils.ts +113 -0
  41. package/src/shared/form/utils/index.ts +6 -0
  42. package/src/shared/validation/index.ts +23 -0
  43. package/src/shared/validation/rules/ValidationRule.ts +71 -0
  44. package/src/shared/validation/rules/index.ts +5 -0
  45. package/src/shared/validation/sanitizers/EmailSanitizer.ts +22 -0
  46. package/src/shared/validation/sanitizers/PasswordSanitizer.ts +24 -0
  47. package/src/shared/validation/sanitizers/index.ts +7 -0
  48. package/src/shared/validation/types.ts +26 -0
  49. package/src/shared/validation/validators/EmailValidator.ts +61 -0
  50. package/src/shared/validation/validators/NameValidator.ts +52 -0
  51. package/src/shared/validation/validators/PasswordValidator.ts +92 -0
  52. package/src/shared/validation/validators/index.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-auth",
3
- "version": "4.3.76",
3
+ "version": "4.3.78",
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",
@@ -65,9 +65,6 @@
65
65
  "@react-native-async-storage/async-storage": "^2.2.0",
66
66
  "@react-native-community/datetimepicker": "^8.2.0",
67
67
  "@react-native-community/slider": "^5.1.1",
68
- "@react-navigation/bottom-tabs": "^7.9.0",
69
- "@react-navigation/native": "^7.1.26",
70
- "@react-navigation/stack": "^7.6.13",
71
68
  "@tanstack/query-async-storage-persister": "^5.66.7",
72
69
  "@tanstack/react-query": "^5.0.0",
73
70
  "@tanstack/react-query-persist-client": "^5.66.7",
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Domain Layer Exports
3
+ */
4
+
5
+ export type { AuthUser, AuthProviderType } from '../domain/entities/AuthUser';
6
+ export type { UserProfile, UpdateProfileParams } from '../domain/entities/UserProfile';
7
+ export {
8
+ AuthError,
9
+ AuthInitializationError,
10
+ AuthConfigurationError,
11
+ AuthValidationError,
12
+ AuthNetworkError,
13
+ AuthUserNotFoundError,
14
+ AuthWrongPasswordError,
15
+ AuthEmailAlreadyInUseError,
16
+ AuthWeakPasswordError,
17
+ AuthInvalidEmailError,
18
+ } from '../domain/errors/AuthError';
19
+ export type {
20
+ AuthConfig,
21
+ PasswordConfig,
22
+ SocialAuthConfig,
23
+ SocialProviderConfig,
24
+ GoogleAuthConfig,
25
+ AppleAuthConfig,
26
+ SocialAuthProvider,
27
+ } from '../domain/value-objects/AuthConfig';
28
+ export {
29
+ DEFAULT_AUTH_CONFIG,
30
+ DEFAULT_PASSWORD_CONFIG,
31
+ DEFAULT_SOCIAL_CONFIG,
32
+ } from '../domain/value-objects/AuthConfig';
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Infrastructure Layer Exports
3
+ */
4
+
5
+ export type { AuthCredentials, SignUpCredentials } from '../infrastructure/repositories/AuthRepository';
6
+
7
+ // Services
8
+ export {
9
+ AuthService,
10
+ initializeAuthService,
11
+ getAuthService,
12
+ resetAuthService,
13
+ } from '../infrastructure/services/AuthService';
14
+ export {
15
+ initializeAuth,
16
+ isAuthInitialized,
17
+ resetAuthInitialization,
18
+ } from '../infrastructure/services/initializeAuth';
19
+ export type { InitializeAuthOptions } from '../infrastructure/services/initializeAuth';
20
+
21
+ // Storage
22
+ export type { IStorageProvider } from '../infrastructure/types/Storage.types';
23
+ export {
24
+ createStorageProvider,
25
+ StorageProviderAdapter,
26
+ } from '../infrastructure/adapters/StorageProviderAdapter';
27
+
28
+ // Validation
29
+ export {
30
+ validateEmail,
31
+ validatePasswordForLogin,
32
+ validatePasswordForRegister,
33
+ validatePasswordConfirmation,
34
+ validateDisplayName,
35
+ } from '../infrastructure/utils/AuthValidation';
36
+ export type {
37
+ ValidationResult,
38
+ PasswordStrengthResult,
39
+ PasswordRequirements,
40
+ } from '../infrastructure/utils/AuthValidation';
41
+ export type {
42
+ FormValidationError,
43
+ FormValidationResult,
44
+ } from '../infrastructure/utils/validation/types';
45
+ export {
46
+ SECURITY_LIMITS,
47
+ sanitizeEmail,
48
+ sanitizePassword,
49
+ sanitizeName,
50
+ } from '../infrastructure/utils/validation/sanitization';
51
+ export type { SecurityLimitKey } from '../infrastructure/utils/validation/sanitization';
52
+ export {
53
+ isEmpty,
54
+ isEmptyEmail,
55
+ isEmptyPassword,
56
+ isEmptyName,
57
+ isNotEmpty,
58
+ hasContent,
59
+ } from '../infrastructure/utils/validation/validationHelpers';
60
+ export { safeCallback, safeCallbackSync } from '../infrastructure/utils/safeCallback';
61
+
62
+ // Calculators
63
+ export {
64
+ calculateUserId,
65
+ calculateHasFirebaseUser,
66
+ calculateIsAnonymous,
67
+ calculateIsAuthenticated,
68
+ calculateUserType,
69
+ calculateIsAuthReady,
70
+ calculateDerivedAuthState,
71
+ collectFieldErrors,
72
+ extractFieldError,
73
+ hasFieldErrors,
74
+ getFirstErrorMessage,
75
+ calculateUserProfileDisplay,
76
+ calculatePasswordRequirements,
77
+ calculatePasswordsMatch,
78
+ calculatePasswordValidation,
79
+ calculatePasswordStrength,
80
+ } from '../infrastructure/utils/calculators';
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Presentation Layer Exports
3
+ */
4
+
5
+ // Hooks
6
+ export { useAuth } from '../presentation/hooks/useAuth';
7
+ export type { UseAuthResult } from '../presentation/hooks/useAuth';
8
+ export { useLoginForm } from '../presentation/hooks/useLoginForm';
9
+ export type { UseLoginFormConfig, UseLoginFormResult } from '../presentation/hooks/useLoginForm';
10
+ export { useRegisterForm } from '../presentation/hooks/useRegisterForm';
11
+ export type {
12
+ UseRegisterFormConfig,
13
+ UseRegisterFormResult,
14
+ } from '../presentation/hooks/useRegisterForm';
15
+ export { useAuthRequired } from '../presentation/hooks/useAuthRequired';
16
+ export { useRequireAuth, useUserId } from '../presentation/hooks/useRequireAuth';
17
+ export { useUserProfile } from '../presentation/hooks/useUserProfile';
18
+ export type {
19
+ UserProfileData,
20
+ UseUserProfileParams,
21
+ } from '../presentation/hooks/useUserProfile';
22
+ export { useAccountManagement } from '../presentation/hooks/useAccountManagement';
23
+ export type {
24
+ UseAccountManagementReturn,
25
+ UseAccountManagementOptions,
26
+ } from '../presentation/hooks/useAccountManagement';
27
+ export { useAppleAuth } from '../presentation/hooks/useAppleAuth';
28
+ export type { UseAppleAuthResult } from '../presentation/hooks/useAppleAuth';
29
+ export { useAuthBottomSheet } from '../presentation/hooks/useAuthBottomSheet';
30
+ export type {
31
+ SocialAuthConfiguration,
32
+ } from '../presentation/hooks/useAuthBottomSheet';
33
+ export { useAuthHandlers } from '../presentation/hooks/useAuthHandlers';
34
+ export type {
35
+ AuthHandlersAppInfo,
36
+ AuthHandlersTranslations,
37
+ } from '../presentation/hooks/useAuthHandlers';
38
+ export { usePasswordPromptNavigation } from '../presentation/hooks/usePasswordPromptNavigation';
39
+ export type {
40
+ UsePasswordPromptNavigationOptions,
41
+ UsePasswordPromptNavigationReturn,
42
+ } from '../presentation/hooks/usePasswordPromptNavigation';
43
+ export { useAuthErrorHandler } from '../presentation/hooks/useAuthErrorHandler';
44
+ export type {
45
+ UseAuthErrorHandlerConfig,
46
+ UseAuthErrorHandlerResult,
47
+ } from '../presentation/hooks/useAuthErrorHandler';
48
+ export { useLocalError } from '../presentation/hooks/useLocalError';
49
+ export type { UseLocalErrorResult } from '../presentation/hooks/useLocalError';
50
+
51
+ // Components
52
+ export { AuthProvider } from '../presentation/providers/AuthProvider';
53
+ export type { ErrorFallbackProps } from '../presentation/providers/AuthProvider';
54
+ export { LoginScreen } from '../presentation/screens/LoginScreen';
55
+ export type { LoginScreenProps } from '../presentation/screens/LoginScreen';
56
+ export { RegisterScreen } from '../presentation/screens/RegisterScreen';
57
+ export type { RegisterScreenProps } from '../presentation/screens/RegisterScreen';
58
+ export { AccountScreen } from '../presentation/screens/AccountScreen';
59
+ export type {
60
+ AccountScreenProps,
61
+ AccountScreenConfig,
62
+ } from '../presentation/screens/AccountScreen';
63
+ export { EditProfileScreen } from '../presentation/screens/EditProfileScreen';
64
+ export type {
65
+ EditProfileScreenProps,
66
+ } from '../presentation/screens/EditProfileScreen';
67
+ export { PasswordPromptScreen } from '../presentation/screens/PasswordPromptScreen';
68
+ export type {
69
+ PasswordPromptScreenProps,
70
+ } from '../presentation/screens/PasswordPromptScreen';
71
+ export { AuthNavigator } from '../presentation/navigation/AuthNavigator';
72
+ export type { AuthStackParamList } from '../presentation/navigation/AuthNavigator';
73
+ export { AuthBottomSheet } from '../presentation/components/AuthBottomSheet';
74
+ export type {
75
+ AuthBottomSheetProps,
76
+ AuthBottomSheetTranslations,
77
+ } from '../presentation/components/AuthBottomSheet';
78
+ export { ProfileSection } from '../presentation/components/ProfileSection';
79
+ export type {
80
+ ProfileSectionProps,
81
+ ProfileSectionConfig,
82
+ } from '../presentation/components/ProfileSection';
83
+
84
+ // Stores
85
+ export { useAuthStore } from '../presentation/stores/authStore';
86
+ export { useAuthModalStore } from '../presentation/stores/authModalStore';
87
+ export {
88
+ initializeAuthListener,
89
+ resetAuthListener,
90
+ isAuthListenerInitialized,
91
+ } from '../presentation/stores/initializeAuthListener';
92
+ export type {
93
+ AuthState,
94
+ AuthActions,
95
+ UserType,
96
+ AuthListenerOptions,
97
+ } from '../types/auth-store.types';
98
+ export type { AuthModalMode } from '../presentation/stores/auth.selectors';
99
+ export {
100
+ selectUser,
101
+ selectLoading,
102
+ selectError,
103
+ selectSetLoading,
104
+ selectSetError,
105
+ selectSetIsAnonymous,
106
+ selectShowAuthModal,
107
+ selectUserId,
108
+ selectIsAuthenticated,
109
+ selectHasFirebaseUser,
110
+ selectIsAnonymous,
111
+ selectUserType,
112
+ selectIsAuthReady,
113
+ selectFirebaseUserId,
114
+ selectAuthState,
115
+ } from '../presentation/stores/auth.selectors';
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Shared Layer Exports
3
+ * New modular utilities
4
+ */
5
+
6
+ // Validation
7
+ export {
8
+ EmailValidator,
9
+ PasswordValidator,
10
+ NameValidator,
11
+ } from '../shared/validation/validators';
12
+ export type { PasswordConfig } from '../shared/validation/validators';
13
+ export {
14
+ EmailSanitizer,
15
+ PasswordSanitizer,
16
+ NameSanitizer,
17
+ } from '../shared/validation/sanitizers';
18
+ export {
19
+ BaseValidationRule,
20
+ RequiredRule,
21
+ RegexRule,
22
+ MinLengthRule,
23
+ } from '../shared/validation/rules';
24
+ export type {
25
+ ValidationResult,
26
+ PasswordRequirements,
27
+ PasswordStrengthResult,
28
+ ValidationRule,
29
+ ValidatorConfig,
30
+ } from '../shared/validation/types';
31
+
32
+ // Error Handling
33
+ export {
34
+ ErrorMapper,
35
+ DEFAULT_AUTH_ERROR_MAPPINGS,
36
+ FieldErrorMapper,
37
+ } from '../shared/error-handling/mappers';
38
+ export { ErrorHandler, FormErrorHandler } from '../shared/error-handling/handlers';
39
+ export type {
40
+ FieldError,
41
+ FormFieldErrors,
42
+ ErrorMap,
43
+ ErrorMappingConfig,
44
+ FormErrorHandlerConfig,
45
+ } from '../shared/error-handling/types';
46
+
47
+ // Form
48
+ export { useField, useForm } from '../shared/form/builders';
49
+ export type {
50
+ UseFieldOptions,
51
+ UseFieldResult,
52
+ UseFormOptions,
53
+ UseFormResult,
54
+ } from '../shared/form/builders';
55
+ export {
56
+ isFormValid,
57
+ isFormDirty,
58
+ isFormTouched,
59
+ getFormErrors,
60
+ getFirstFormError,
61
+ countFormErrors,
62
+ getFieldError,
63
+ fieldHasError,
64
+ isFieldTouched,
65
+ resetFormState,
66
+ } from '../shared/form/state';
67
+ export {
68
+ sanitizeFormValues,
69
+ extractFields,
70
+ areRequiredFieldsFilled,
71
+ getEmptyRequiredFields,
72
+ createFieldOptions,
73
+ mergeFormErrors,
74
+ clearFieldErrors,
75
+ } from '../shared/form/utils/formUtils';
76
+ export {
77
+ createFieldChangeHandler,
78
+ createFieldBlurHandler,
79
+ debounceFieldChange,
80
+ isFieldValueEmpty,
81
+ sanitizeFieldValue,
82
+ formatFieldValue,
83
+ validateFieldValue,
84
+ getFieldDisplayValue,
85
+ truncateFieldValue,
86
+ } from '../shared/form/utils/fieldUtils';
87
+ export type {
88
+ FieldState,
89
+ FormState,
90
+ FieldChangeHandler,
91
+ FormFieldConfig,
92
+ FormConfig,
93
+ } from '../shared/form/types';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utilities & Init Exports
3
+ */
4
+
5
+ export {
6
+ getAuthErrorLocalizationKey,
7
+ resolveErrorMessage,
8
+ } from '../presentation/utils/getAuthErrorMessage';
9
+ export { createAuthInitModule } from '../init/createAuthInitModule';
10
+ export type { AuthInitModuleConfig } from '../init/createAuthInitModule';
package/src/index.ts CHANGED
@@ -8,149 +8,24 @@
8
8
  // =============================================================================
9
9
  // DOMAIN LAYER
10
10
  // =============================================================================
11
-
12
- export type { AuthUser, AuthProviderType } from './domain/entities/AuthUser';
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';
17
-
18
- // =============================================================================
19
- // APPLICATION LAYER
20
- // =============================================================================
21
-
22
- export type { AuthCredentials, SignUpCredentials } from './infrastructure/repositories/AuthRepository';
11
+ export * from './exports/domain';
23
12
 
24
13
  // =============================================================================
25
14
  // INFRASTRUCTURE LAYER
26
15
  // =============================================================================
27
-
28
- export { AuthService, initializeAuthService, getAuthService, resetAuthService } from './infrastructure/services/AuthService';
29
- export type { IStorageProvider } from './infrastructure/types/Storage.types';
30
- export { createStorageProvider, StorageProviderAdapter } from './infrastructure/adapters/StorageProviderAdapter';
31
- export { initializeAuth, isAuthInitialized, resetAuthInitialization } from './infrastructure/services/initializeAuth';
32
- export type { InitializeAuthOptions } from './infrastructure/services/initializeAuth';
33
- export { validateEmail, validatePasswordForLogin, validatePasswordForRegister, validatePasswordConfirmation, validateDisplayName } from './infrastructure/utils/AuthValidation';
34
- export type { ValidationResult, PasswordStrengthResult, PasswordRequirements } from './infrastructure/utils/AuthValidation';
35
- export type { FormValidationError, FormValidationResult } from './infrastructure/utils/validation/types';
36
- export { SECURITY_LIMITS, sanitizeEmail, sanitizePassword, sanitizeName } from './infrastructure/utils/validation/sanitization';
37
- export type { SecurityLimitKey } from './infrastructure/utils/validation/sanitization';
38
- export { isEmpty, isEmptyEmail, isEmptyPassword, isEmptyName, isNotEmpty, hasContent } from './infrastructure/utils/validation/validationHelpers';
39
- export { safeCallback, safeCallbackSync } from './infrastructure/utils/safeCallback';
40
-
41
-
42
- // =============================================================================
43
- // CALCULATOR UTILITIES
44
- // =============================================================================
45
-
46
- export {
47
- // Auth State Calculator
48
- calculateUserId,
49
- calculateHasFirebaseUser,
50
- calculateIsAnonymous,
51
- calculateIsAuthenticated,
52
- calculateUserType,
53
- calculateIsAuthReady,
54
- calculateDerivedAuthState,
55
- // Form Error Collection
56
- collectFieldErrors,
57
- extractFieldError,
58
- hasFieldErrors,
59
- getFirstErrorMessage,
60
- // User Profile Calculator
61
- calculateUserProfileDisplay,
62
- // Password Strength Calculator
63
- calculatePasswordRequirements,
64
- calculatePasswordsMatch,
65
- calculatePasswordValidation,
66
- calculatePasswordStrength,
67
- } from './infrastructure/utils/calculators';
68
-
69
-
70
- // =============================================================================
71
- // PRESENTATION LAYER - Hooks
72
- // =============================================================================
73
-
74
- export { useAuth } from './presentation/hooks/useAuth';
75
- export type { UseAuthResult } from './presentation/hooks/useAuth';
76
- export { useLoginForm } from './presentation/hooks/useLoginForm';
77
- export type { UseLoginFormConfig, UseLoginFormResult } from './presentation/hooks/useLoginForm';
78
- export { useRegisterForm } from './presentation/hooks/useRegisterForm';
79
- export type { UseRegisterFormConfig, UseRegisterFormResult } from './presentation/hooks/useRegisterForm';
80
- export { useAuthRequired } from './presentation/hooks/useAuthRequired';
81
- export { useRequireAuth, useUserId } from './presentation/hooks/useRequireAuth';
82
- export { useUserProfile } from './presentation/hooks/useUserProfile';
83
- export type { UserProfileData, UseUserProfileParams } from './presentation/hooks/useUserProfile';
84
- export { useAccountManagement } from './presentation/hooks/useAccountManagement';
85
- export type { UseAccountManagementReturn, UseAccountManagementOptions } from './presentation/hooks/useAccountManagement';
86
- export { useAppleAuth } from './presentation/hooks/useAppleAuth';
87
- export type { UseAppleAuthResult } from './presentation/hooks/useAppleAuth';
88
- export { useAuthBottomSheet } from './presentation/hooks/useAuthBottomSheet';
89
- export type { SocialAuthConfiguration } from './presentation/hooks/useAuthBottomSheet';
90
- export { useAuthHandlers } from './presentation/hooks/useAuthHandlers';
91
- export type { AuthHandlersAppInfo, AuthHandlersTranslations } from './presentation/hooks/useAuthHandlers';
92
- export { usePasswordPromptNavigation } from './presentation/hooks/usePasswordPromptNavigation';
93
- export type { UsePasswordPromptNavigationOptions, UsePasswordPromptNavigationReturn } from './presentation/hooks/usePasswordPromptNavigation';
94
- export { useAuthErrorHandler } from './presentation/hooks/useAuthErrorHandler';
95
- export type { UseAuthErrorHandlerConfig, UseAuthErrorHandlerResult } from './presentation/hooks/useAuthErrorHandler';
96
- export { useLocalError } from './presentation/hooks/useLocalError';
97
- export type { UseLocalErrorResult } from './presentation/hooks/useLocalError';
16
+ export * from './exports/infrastructure';
98
17
 
99
18
  // =============================================================================
100
- // PRESENTATION LAYER - Components
19
+ // PRESENTATION LAYER
101
20
  // =============================================================================
102
-
103
- export { AuthProvider } from './presentation/providers/AuthProvider';
104
- export type { ErrorFallbackProps } from './presentation/providers/AuthProvider';
105
- export { LoginScreen } from './presentation/screens/LoginScreen';
106
- export type { LoginScreenProps } from './presentation/screens/LoginScreen';
107
- export { RegisterScreen } from './presentation/screens/RegisterScreen';
108
- export type { RegisterScreenProps } from './presentation/screens/RegisterScreen';
109
- export { AccountScreen } from './presentation/screens/AccountScreen';
110
- export type { AccountScreenProps, AccountScreenConfig } from './presentation/screens/AccountScreen';
111
- export { EditProfileScreen } from './presentation/screens/EditProfileScreen';
112
- export type { EditProfileScreenProps } from './presentation/screens/EditProfileScreen';
113
- export { PasswordPromptScreen } from './presentation/screens/PasswordPromptScreen';
114
- export type { PasswordPromptScreenProps } from './presentation/screens/PasswordPromptScreen';
115
- export { AuthNavigator } from './presentation/navigation/AuthNavigator';
116
- export type { AuthStackParamList } from './presentation/navigation/AuthNavigator';
117
- export { AuthBottomSheet } from './presentation/components/AuthBottomSheet';
118
- export type { AuthBottomSheetProps, AuthBottomSheetTranslations } from './presentation/components/AuthBottomSheet';
119
- export { ProfileSection } from './presentation/components/ProfileSection';
120
- export type { ProfileSectionProps, ProfileSectionConfig } from './presentation/components/ProfileSection';
21
+ export * from './exports/presentation';
121
22
 
122
23
  // =============================================================================
123
- // STORES
24
+ // SHARED LAYER (New Modular Utilities)
124
25
  // =============================================================================
125
-
126
- export { useAuthStore } from './presentation/stores/authStore';
127
- export { useAuthModalStore } from './presentation/stores/authModalStore';
128
- export { initializeAuthListener, resetAuthListener, isAuthListenerInitialized } from './presentation/stores/initializeAuthListener';
129
- export type { AuthState, AuthActions, UserType, AuthListenerOptions } from './types/auth-store.types';
130
- export type { AuthModalMode } from './presentation/stores/auth.selectors';
131
- export {
132
- selectUser,
133
- selectLoading,
134
- selectError,
135
- selectSetLoading,
136
- selectSetError,
137
- selectSetIsAnonymous,
138
- selectShowAuthModal,
139
- selectUserId,
140
- selectIsAuthenticated,
141
- selectHasFirebaseUser,
142
- selectIsAnonymous,
143
- selectUserType,
144
- selectIsAuthReady,
145
- selectFirebaseUserId,
146
- selectAuthState,
147
- } from './presentation/stores/auth.selectors';
26
+ export * from './exports/shared';
148
27
 
149
28
  // =============================================================================
150
29
  // UTILITIES & INIT
151
30
  // =============================================================================
152
-
153
- export { getAuthErrorLocalizationKey, resolveErrorMessage } from './presentation/utils/getAuthErrorMessage';
154
- export { createAuthInitModule } from './init/createAuthInitModule';
155
- export type { AuthInitModuleConfig } from './init/createAuthInitModule';
156
-
31
+ export * from './exports/utils';
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Anonymous Sign-In Attempt Logic
3
+ */
4
+
5
+ import { anonymousAuthService } from '@umituz/react-native-firebase';
6
+ import type { Auth } from 'firebase/auth';
7
+ import type { AnonymousSignInCallbacks, AnonymousSignInOptions } from './types';
8
+ import {
9
+ MAX_ANONYMOUS_RETRIES,
10
+ ANONYMOUS_RETRY_DELAY_MS,
11
+ ANONYMOUS_SIGNIN_TIMEOUT_MS,
12
+ } from './constants';
13
+
14
+ /**
15
+ * Perform anonymous sign-in with retry logic
16
+ */
17
+ async function performAnonymousSignIn(
18
+ auth: Auth,
19
+ maxRetries: number,
20
+ retryDelay: number
21
+ ): Promise<void> {
22
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
23
+ try {
24
+ await anonymousAuthService.signInAnonymously(auth);
25
+ return;
26
+ } catch (error) {
27
+ // If not last attempt, wait and retry
28
+ if (attempt < maxRetries - 1) {
29
+ await new Promise((resolve) => setTimeout(resolve, retryDelay));
30
+ continue;
31
+ }
32
+
33
+ // All attempts failed
34
+ throw error;
35
+ }
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Attempt anonymous sign-in with retry logic and timeout protection
41
+ */
42
+ export async function attemptAnonymousSignIn(
43
+ auth: Auth,
44
+ callbacks: AnonymousSignInCallbacks,
45
+ options: AnonymousSignInOptions = {}
46
+ ): Promise<void> {
47
+ const {
48
+ maxRetries = MAX_ANONYMOUS_RETRIES,
49
+ retryDelay = ANONYMOUS_RETRY_DELAY_MS,
50
+ timeout = ANONYMOUS_SIGNIN_TIMEOUT_MS,
51
+ } = options;
52
+
53
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
54
+
55
+ try {
56
+ // Add timeout protection with proper cleanup
57
+ const timeoutPromise = new Promise<never>((_, reject) => {
58
+ timeoutId = setTimeout(
59
+ () => reject(new Error('Anonymous sign-in timeout')),
60
+ timeout
61
+ );
62
+ });
63
+
64
+ // Race between sign-in and timeout
65
+ await Promise.race([
66
+ performAnonymousSignIn(auth, maxRetries, retryDelay),
67
+ timeoutPromise,
68
+ ]);
69
+
70
+ callbacks.onSignInSuccess();
71
+ } catch (error) {
72
+ const signInError =
73
+ error instanceof Error ? error : new Error('Unknown sign-in error');
74
+ callbacks.onSignInFailure(signInError);
75
+ } finally {
76
+ // Always clear timeout to prevent timer leaks
77
+ if (timeoutId !== undefined) {
78
+ clearTimeout(timeoutId);
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Anonymous Sign-In Constants
3
+ */
4
+
5
+ export const MAX_ANONYMOUS_RETRIES = 2;
6
+ export const ANONYMOUS_RETRY_DELAY_MS = 1000;
7
+ export const ANONYMOUS_SIGNIN_TIMEOUT_MS = 10000;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Create Anonymous Sign-In Handler
3
+ * Factory function for creating anonymous sign-in handlers
4
+ */
5
+
6
+ import type { Auth } from 'firebase/auth';
7
+ import type { User } from 'firebase/auth';
8
+ import type { AnonymousStore } from './types';
9
+ import { attemptAnonymousSignIn } from './attemptAnonymousSignIn';
10
+ import {
11
+ MAX_ANONYMOUS_RETRIES,
12
+ ANONYMOUS_RETRY_DELAY_MS,
13
+ ANONYMOUS_SIGNIN_TIMEOUT_MS,
14
+ } from './constants';
15
+
16
+ /**
17
+ * Create anonymous sign-in handler for auth listener
18
+ * Returns a function that can be called when no user is detected
19
+ */
20
+ export function createAnonymousSignInHandler(
21
+ auth: Auth | null,
22
+ store: AnonymousStore
23
+ ): () => Promise<void> {
24
+ return async () => {
25
+ if (!auth) {
26
+ store.setFirebaseUser(null);
27
+ store.setLoading(false);
28
+ store.setInitialized(true);
29
+ return;
30
+ }
31
+
32
+ store.setLoading(true);
33
+
34
+ await attemptAnonymousSignIn(
35
+ auth,
36
+ {
37
+ onSignInSuccess: () => {
38
+ // Listener will be triggered again with the new user
39
+ },
40
+ onSignInFailure: (error: Error) => {
41
+ if (__DEV__) {
42
+ console.error('[AnonymousSignIn] Failed:', error.message);
43
+ }
44
+ store.setFirebaseUser(null);
45
+ store.setLoading(false);
46
+ store.setInitialized(true);
47
+ store.setError(
48
+ 'Failed to sign in anonymously. Please check your connection.'
49
+ );
50
+ },
51
+ },
52
+ {
53
+ maxRetries: MAX_ANONYMOUS_RETRIES,
54
+ retryDelay: ANONYMOUS_RETRY_DELAY_MS,
55
+ timeout: ANONYMOUS_SIGNIN_TIMEOUT_MS,
56
+ }
57
+ );
58
+ };
59
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Anonymous Sign-In Module Exports
3
+ */
4
+
5
+ export { createAnonymousSignInHandler } from './createAnonymousSignInHandler';
6
+ export { attemptAnonymousSignIn } from './attemptAnonymousSignIn';
7
+ export {
8
+ MAX_ANONYMOUS_RETRIES,
9
+ ANONYMOUS_RETRY_DELAY_MS,
10
+ ANONYMOUS_SIGNIN_TIMEOUT_MS,
11
+ } from './constants';
12
+ export type {
13
+ AnonymousSignInCallbacks,
14
+ AnonymousSignInOptions,
15
+ AnonymousStore,
16
+ } from './types';