@umituz/react-native-auth 3.7.2 → 3.8.1

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.7.2",
3
+ "version": "3.8.1",
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",
@@ -36,8 +36,6 @@
36
36
  "@react-navigation/stack": ">=6.0.0",
37
37
  "@tanstack/react-query": ">=5.0.0",
38
38
  "expo": ">=54.0.0",
39
- "expo-auth-session": ">=5.0.0",
40
- "expo-web-browser": ">=12.0.0",
41
39
  "firebase": ">=11.0.0",
42
40
  "react": ">=19.0.0",
43
41
  "react-native": "0.81.4",
package/src/index.ts CHANGED
@@ -57,8 +57,6 @@ export { useProfileEdit } from './presentation/hooks/useProfileEdit';
57
57
  export type { ProfileEditFormState, UseProfileEditReturn } from './presentation/hooks/useProfileEdit';
58
58
  export { useSocialLogin } from './presentation/hooks/useSocialLogin';
59
59
  export type { UseSocialLoginConfig, UseSocialLoginResult } from './presentation/hooks/useSocialLogin';
60
- export { useGoogleAuth } from './presentation/hooks/useGoogleAuth';
61
- export type { UseGoogleAuthResult } from './presentation/hooks/useGoogleAuth';
62
60
  export { useAppleAuth } from './presentation/hooks/useAppleAuth';
63
61
  export type { UseAppleAuthResult } from './presentation/hooks/useAppleAuth';
64
62
  export { useAuthBottomSheet } from './presentation/hooks/useAuthBottomSheet';
@@ -5,14 +5,12 @@
5
5
 
6
6
  import type { IAuthRepository } from "../../application/ports/IAuthRepository";
7
7
  import type { AuthUser } from "../../domain/entities/AuthUser";
8
- import type { User } from "firebase/auth";
9
8
  import {
10
9
  signInWithEmail,
11
10
  signUpWithEmail,
12
11
  signOut as firebaseSignOut,
13
12
  getCurrentUserFromGlobal,
14
13
  setupAuthListener,
15
- type EmailCredentials,
16
14
  } from "@umituz/react-native-firebase";
17
15
  import {
18
16
  AuthValidationError,
@@ -34,11 +34,13 @@ export function useAuthBottomSheet(params: UseAuthBottomSheetParams = {}) {
34
34
  const { isAuthenticated, isAnonymous } = useAuth();
35
35
 
36
36
  // Social Auth Hooks
37
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
37
38
  const { signInWithGoogle, googleConfigured } = useGoogleAuth(socialConfig?.google);
38
39
  const { signInWithApple, appleAvailable } = useAppleAuth();
39
40
 
40
41
  // Determine enabled providers
41
42
  const providers = useMemo<SocialAuthProvider[]>(() => {
43
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
42
44
  return determineEnabledProviders(socialConfig, appleAvailable, googleConfigured);
43
45
  }, [socialConfig, appleAvailable, googleConfigured]);
44
46
 
@@ -98,6 +100,7 @@ export function useAuthBottomSheet(params: UseAuthBottomSheetParams = {}) {
98
100
  if (onGoogleSignIn) {
99
101
  await onGoogleSignIn();
100
102
  } else if (signInWithGoogle) {
103
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
101
104
  await signInWithGoogle();
102
105
  }
103
106
  } finally {
@@ -1,125 +1,24 @@
1
1
  /**
2
2
  * useGoogleAuth Hook
3
- * Handles Google OAuth flow using expo-auth-session and Firebase auth
3
+ * Handles Google Sign-In using Firebase auth
4
+ *
5
+ * This is a re-export wrapper around useGoogleOAuth from Firebase package
6
+ * for consistency with the auth package API.
4
7
  */
5
8
 
6
- import { useState, useCallback, useEffect } from "react";
7
- import { useSocialAuth, type SocialAuthConfig, type SocialAuthResult } from "@umituz/react-native-firebase";
8
- import * as Google from "expo-auth-session/providers/google";
9
- import * as WebBrowser from "expo-web-browser";
9
+ import { useGoogleOAuth } from "@umituz/react-native-firebase";
10
10
 
11
- WebBrowser.maybeCompleteAuthSession();
11
+ // Re-export types from firebase
12
+ export type {
13
+ GoogleOAuthConfig as GoogleAuthConfig,
14
+ UseGoogleOAuthResult as UseGoogleAuthResult,
15
+ SocialAuthResult,
16
+ } from "@umituz/react-native-firebase";
12
17
 
13
- export interface GoogleAuthConfig {
14
- iosClientId?: string;
15
- webClientId?: string;
16
- androidClientId?: string;
17
- }
18
-
19
- export interface UseGoogleAuthResult {
20
- signInWithGoogle: () => Promise<SocialAuthResult>;
21
- googleLoading: boolean;
22
- googleConfigured: boolean;
23
- googleError: string | null;
24
- }
25
-
26
- const PLACEHOLDER_CLIENT_ID = "000000000000-placeholder.apps.googleusercontent.com";
27
-
28
- function validateGoogleConfig(config?: GoogleAuthConfig): boolean {
29
- if (!config) return false;
30
- return !!(
31
- (config.iosClientId && config.iosClientId !== PLACEHOLDER_CLIENT_ID) ||
32
- (config.webClientId && config.webClientId !== PLACEHOLDER_CLIENT_ID) ||
33
- (config.androidClientId && config.androidClientId !== PLACEHOLDER_CLIENT_ID)
34
- );
35
- }
36
-
37
- export function useGoogleAuth(config?: GoogleAuthConfig): UseGoogleAuthResult {
38
- const [isLoading, setIsLoading] = useState(false);
39
- const [googleError, setGoogleError] = useState<string | null>(null);
40
- const googleConfigured = validateGoogleConfig(config);
41
-
42
- const { signInWithGoogleToken, googleLoading: firebaseLoading } = useSocialAuth({
43
- google: config,
44
- apple: { enabled: false },
45
- } as SocialAuthConfig);
46
-
47
- const authRequest = Google?.useAuthRequest({
48
- iosClientId: config?.iosClientId || PLACEHOLDER_CLIENT_ID,
49
- webClientId: config?.webClientId || PLACEHOLDER_CLIENT_ID,
50
- androidClientId: config?.androidClientId || PLACEHOLDER_CLIENT_ID,
51
- });
52
-
53
- const request = authRequest?.[0] ?? null;
54
- const googleResponse = authRequest?.[1] ?? null;
55
- const promptGoogleAsync = authRequest?.[2];
56
-
57
- useEffect(() => {
58
- if (googleResponse?.type === "success") {
59
- const idToken = googleResponse.authentication?.idToken;
60
- if (idToken) {
61
- setIsLoading(true);
62
- setGoogleError(null);
63
- signInWithGoogleToken(idToken)
64
- .catch((error) => { setGoogleError(error instanceof Error ? error.message : "Firebase sign-in failed"); })
65
- .finally(() => { setIsLoading(false); });
66
- }
67
- } else if (googleResponse?.type === "error") {
68
- setGoogleError("Google authentication failed");
69
- setIsLoading(false);
70
- }
71
- }, [googleResponse, signInWithGoogleToken]);
72
-
73
- const signInWithGoogle = useCallback(async (): Promise<SocialAuthResult> => {
74
- if (!promptGoogleAsync) {
75
- const error = "expo-auth-session is not available";
76
- setGoogleError(error);
77
- return { success: false, error };
78
- }
79
-
80
- if (!googleConfigured) {
81
- const error = "Google Sign-In is not configured. Please provide valid client IDs.";
82
- setGoogleError(error);
83
- return { success: false, error };
84
- }
85
-
86
- if (!request) {
87
- const error = "Google Sign-In not ready";
88
- setGoogleError(error);
89
- return { success: false, error };
90
- }
91
-
92
- setIsLoading(true);
93
- setGoogleError(null);
94
- try {
95
- const result = await promptGoogleAsync();
96
-
97
- if (result.type === "success" && result.authentication?.idToken) {
98
- return await signInWithGoogleToken(result.authentication.idToken);
99
- }
100
-
101
- if (result.type === "cancel") {
102
- const error = "Google Sign-In was cancelled";
103
- setGoogleError(error);
104
- return { success: false, error };
105
- }
106
-
107
- const error = "Google Sign-In failed";
108
- setGoogleError(error);
109
- return { success: false, error };
110
- } catch (error) {
111
- const errorMessage = error instanceof Error ? error.message : "Google sign-in failed";
112
- setGoogleError(errorMessage);
113
- return { success: false, error: errorMessage };
114
- } finally {
115
- setIsLoading(false);
116
- }
117
- }, [googleConfigured, request, promptGoogleAsync, signInWithGoogleToken]);
18
+ /**
19
+ * Hook for Google authentication
20
+ * This is a direct re-export of useGoogleOAuth from firebase package
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
23
+ export const useGoogleAuth = useGoogleOAuth;
118
24
 
119
- return {
120
- signInWithGoogle,
121
- googleLoading: isLoading || firebaseLoading,
122
- googleConfigured,
123
- googleError,
124
- };
125
- }