@umituz/react-native-auth 3.4.19 → 3.4.20
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.4.
|
|
3
|
+
"version": "3.4.20",
|
|
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",
|
|
@@ -63,13 +63,6 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
|
|
|
63
63
|
}
|
|
64
64
|
}, [isVisible]);
|
|
65
65
|
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (isAuthenticated && !isAnonymous && isVisible) {
|
|
68
|
-
hideAuthModal();
|
|
69
|
-
executePendingCallback();
|
|
70
|
-
}
|
|
71
|
-
}, [isAuthenticated, isAnonymous, isVisible, hideAuthModal, executePendingCallback]);
|
|
72
|
-
|
|
73
66
|
const handleDismiss = useCallback(() => {
|
|
74
67
|
hideAuthModal();
|
|
75
68
|
clearPendingCallback();
|
|
@@ -80,6 +73,26 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
|
|
|
80
73
|
handleDismiss();
|
|
81
74
|
}, [handleDismiss]);
|
|
82
75
|
|
|
76
|
+
const prevIsAuthenticatedRef = useRef(isAuthenticated);
|
|
77
|
+
const prevIsVisibleRef = useRef(isVisible);
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
// Only close the modal if the user was NOT authenticated and then BECOMES authenticated
|
|
81
|
+
// while the modal is visible.
|
|
82
|
+
if (!prevIsAuthenticatedRef.current && isAuthenticated && isVisible && !isAnonymous) {
|
|
83
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
84
|
+
// eslint-disable-next-line no-console
|
|
85
|
+
console.log("[AuthBottomSheet] Auto-closing due to successful authentication transition");
|
|
86
|
+
}
|
|
87
|
+
handleClose();
|
|
88
|
+
executePendingCallback();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Update ref for next render
|
|
92
|
+
prevIsAuthenticatedRef.current = isAuthenticated;
|
|
93
|
+
prevIsVisibleRef.current = isVisible;
|
|
94
|
+
}, [isAuthenticated, isVisible, isAnonymous, executePendingCallback, handleClose]);
|
|
95
|
+
|
|
83
96
|
const handleNavigateToRegister = useCallback(() => {
|
|
84
97
|
setMode("register");
|
|
85
98
|
}, [setMode]);
|
|
@@ -14,51 +14,10 @@ import {
|
|
|
14
14
|
type SocialAuthResult,
|
|
15
15
|
} from "@umituz/react-native-firebase";
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
iosClientId: string;
|
|
20
|
-
webClientId: string;
|
|
21
|
-
androidClientId: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface AuthSessionAuthentication {
|
|
25
|
-
idToken?: string;
|
|
26
|
-
accessToken?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface AuthSessionResult {
|
|
30
|
-
type: "success" | "cancel" | "dismiss" | "error" | "locked";
|
|
31
|
-
authentication?: AuthSessionAuthentication;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface AuthRequest {
|
|
35
|
-
promptAsync: () => Promise<AuthSessionResult>;
|
|
36
|
-
}
|
|
17
|
+
import * as Google from "expo-auth-session/providers/google";
|
|
18
|
+
import * as WebBrowser from "expo-web-browser";
|
|
37
19
|
|
|
38
|
-
|
|
39
|
-
AuthRequest | null,
|
|
40
|
-
AuthSessionResult | null,
|
|
41
|
-
() => Promise<AuthSessionResult>,
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
// Dynamic imports to handle optional dependencies
|
|
45
|
-
type GoogleModule = { useAuthRequest: (config: GoogleAuthRequestConfig) => UseAuthRequestReturn };
|
|
46
|
-
type WebBrowserModule = { maybeCompleteAuthSession: () => void };
|
|
47
|
-
|
|
48
|
-
let Google: GoogleModule | null = null;
|
|
49
|
-
let WebBrowser: WebBrowserModule | null = null;
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
53
|
-
Google = require("expo-auth-session/providers/google") as GoogleModule;
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
55
|
-
WebBrowser = require("expo-web-browser") as WebBrowserModule;
|
|
56
|
-
if (WebBrowser) {
|
|
57
|
-
WebBrowser.maybeCompleteAuthSession();
|
|
58
|
-
}
|
|
59
|
-
} catch {
|
|
60
|
-
// expo-auth-session not available - silent fallback
|
|
61
|
-
}
|
|
20
|
+
WebBrowser.maybeCompleteAuthSession();
|
|
62
21
|
|
|
63
22
|
export interface GoogleAuthConfig {
|
|
64
23
|
iosClientId?: string;
|
|
@@ -123,7 +82,7 @@ export function useGoogleAuth(config?: GoogleAuthConfig): UseGoogleAuthResult {
|
|
|
123
82
|
}, [googleResponse, signInWithGoogleToken]);
|
|
124
83
|
|
|
125
84
|
const signInWithGoogle = useCallback(async (): Promise<SocialAuthResult> => {
|
|
126
|
-
if (!
|
|
85
|
+
if (!promptGoogleAsync) {
|
|
127
86
|
return { success: false, error: "expo-auth-session is not available" };
|
|
128
87
|
}
|
|
129
88
|
|