@umituz/react-native-auth 3.6.71 → 3.6.73

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 (32) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +1 -0
  3. package/src/infrastructure/adapters/StorageProviderAdapter.ts +1 -4
  4. package/src/infrastructure/providers/FirebaseAuthProvider.ts +5 -32
  5. package/src/infrastructure/repositories/AuthRepository.ts +0 -5
  6. package/src/infrastructure/services/AnonymousModeService.ts +6 -20
  7. package/src/infrastructure/services/AuthEventService.ts +2 -4
  8. package/src/infrastructure/services/initializeAuth.ts +2 -11
  9. package/src/infrastructure/utils/AuthErrorMapper.ts +0 -4
  10. package/src/infrastructure/utils/authStateHandler.ts +2 -4
  11. package/src/infrastructure/utils/listener/anonymousSignInHandler.ts +2 -22
  12. package/src/infrastructure/utils/listener/listenerLifecycle.util.ts +144 -0
  13. package/src/infrastructure/utils/listener/listenerState.util.ts +125 -0
  14. package/src/init/createAuthInitModule.ts +3 -22
  15. package/src/presentation/components/AccountActions.tsx +2 -4
  16. package/src/presentation/components/AuthBottomSheet.tsx +1 -17
  17. package/src/presentation/hooks/useAccountManagement.ts +0 -7
  18. package/src/presentation/hooks/useAuth.ts +2 -4
  19. package/src/presentation/hooks/useAuthBottomSheet.ts +23 -79
  20. package/src/presentation/hooks/useGoogleAuth.ts +0 -3
  21. package/src/presentation/hooks/useLoginForm.ts +26 -30
  22. package/src/presentation/hooks/useProfileEdit.ts +56 -64
  23. package/src/presentation/hooks/useRegisterForm.ts +41 -44
  24. package/src/presentation/providers/AuthProvider.tsx +2 -7
  25. package/src/presentation/stores/authModalStore.ts +0 -7
  26. package/src/presentation/stores/authStore.ts +1 -28
  27. package/src/presentation/stores/initializeAuthListener.ts +30 -160
  28. package/src/presentation/utils/accountDeleteHandler.util.ts +0 -51
  29. package/src/presentation/utils/authTransition.util.ts +72 -0
  30. package/src/presentation/utils/form/formFieldState.util.ts +82 -0
  31. package/src/presentation/utils/form/formValidation.util.ts +173 -0
  32. package/src/presentation/utils/socialAuthHandler.util.ts +106 -0
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Social Auth Handler Utilities
3
+ * Manages social authentication state and handlers
4
+ */
5
+
6
+ import { useState, useCallback } from "react";
7
+ import type { SocialAuthProvider } from "../../domain/value-objects/AuthConfig";
8
+ import { Platform } from "react-native";
9
+
10
+ export interface SocialAuthHandlers {
11
+ googleLoading: boolean;
12
+ appleLoading: boolean;
13
+ handleGoogleSignIn: () => Promise<void>;
14
+ handleAppleSignIn: () => Promise<void>;
15
+ }
16
+
17
+ export interface SocialAuthConfig {
18
+ google?: { iosClientId?: string; webClientId?: string; androidClientId?: string };
19
+ apple?: { enabled: boolean };
20
+ }
21
+
22
+ /**
23
+ * Hook for managing social auth loading states
24
+ */
25
+ export function useSocialAuthLoading() {
26
+ const [googleLoading, setGoogleLoading] = useState(false);
27
+ const [appleLoading, setAppleLoading] = useState(false);
28
+
29
+ const createGoogleHandler = useCallback(
30
+ (handler: () => Promise<void>) => {
31
+ return async () => {
32
+ setGoogleLoading(true);
33
+ try {
34
+ await handler();
35
+ } finally {
36
+ setGoogleLoading(false);
37
+ }
38
+ };
39
+ },
40
+ []
41
+ );
42
+
43
+ const createAppleHandler = useCallback(
44
+ (handler: () => Promise<void>) => {
45
+ return async () => {
46
+ setAppleLoading(true);
47
+ try {
48
+ await handler();
49
+ } finally {
50
+ setAppleLoading(false);
51
+ }
52
+ };
53
+ },
54
+ []
55
+ );
56
+
57
+ return {
58
+ googleLoading,
59
+ appleLoading,
60
+ setGoogleLoading,
61
+ setAppleLoading,
62
+ createGoogleHandler,
63
+ createAppleHandler,
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Determine enabled social auth providers
69
+ */
70
+ export function determineEnabledProviders(
71
+ config: SocialAuthConfig | undefined,
72
+ appleAvailable: boolean,
73
+ googleConfigured: boolean
74
+ ): SocialAuthProvider[] {
75
+ const providers: SocialAuthProvider[] = [];
76
+
77
+ if (Platform.OS === "ios" && config?.apple?.enabled && appleAvailable) {
78
+ providers.push("apple");
79
+ }
80
+
81
+ if (googleConfigured) {
82
+ providers.push("google");
83
+ }
84
+
85
+ return providers;
86
+ }
87
+
88
+ /**
89
+ * Create social auth handlers
90
+ */
91
+ export function createSocialAuthHandlers(
92
+ googleSignIn: (() => Promise<void>) | undefined,
93
+ appleSignIn: (() => Promise<void>) | undefined,
94
+ internalGoogleHandler: (() => Promise<void>) | undefined,
95
+ internalAppleHandler: (() => Promise<void>) | undefined
96
+ ): SocialAuthHandlers {
97
+ const googleHandler = googleSignIn || internalGoogleHandler;
98
+ const appleHandler = appleSignIn || internalAppleHandler;
99
+
100
+ return {
101
+ googleLoading: false,
102
+ appleLoading: false,
103
+ handleGoogleSignIn: googleHandler || (async () => {}),
104
+ handleAppleSignIn: appleHandler || (async () => {}),
105
+ };
106
+ }