@umituz/react-native-auth 3.4.21 → 3.4.22

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.21",
3
+ "version": "3.4.22",
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",
package/src/index.ts CHANGED
@@ -173,7 +173,7 @@ export { useAppleAuth } from './presentation/hooks/useAppleAuth';
173
173
  export type { UseAppleAuthResult } from './presentation/hooks/useAppleAuth';
174
174
 
175
175
  export { useAuthBottomSheet } from './presentation/hooks/useAuthBottomSheet';
176
- export { useAuthBottomSheetWrapper } from './presentation/hooks/useAuthBottomSheetWrapper';
176
+ export type { SocialAuthConfiguration } from './presentation/hooks/useAuthBottomSheet';
177
177
 
178
178
  export type { UserProfile, UpdateProfileParams } from './domain/entities/UserProfile';
179
179
 
@@ -219,9 +219,6 @@ export { PasswordMatchIndicator } from './presentation/components/PasswordMatchI
219
219
  export type { PasswordMatchIndicatorProps } from './presentation/components/PasswordMatchIndicator';
220
220
  export { AuthBottomSheet } from './presentation/components/AuthBottomSheet';
221
221
  export type { AuthBottomSheetProps } from './presentation/components/AuthBottomSheet';
222
- export { AuthBottomSheetWrapper } from './presentation/components/AuthBottomSheetWrapper';
223
- export type { AuthBottomSheetWrapperProps } from './presentation/components/AuthBottomSheetWrapper';
224
- export type { SocialAuthConfiguration } from './presentation/hooks/useAuthBottomSheetWrapper';
225
222
  export { SocialLoginButtons } from './presentation/components/SocialLoginButtons';
226
223
  export type { SocialLoginButtonsProps } from './presentation/components/SocialLoginButtons';
227
224
  export { ProfileSection } from './presentation/components/ProfileSection';
@@ -13,23 +13,22 @@ import {
13
13
  BottomSheetModal,
14
14
  } from "@umituz/react-native-design-system";
15
15
  import { useLocalization } from "@umituz/react-native-localization";
16
- import { useAuthBottomSheet } from "../hooks/useAuthBottomSheet";
16
+ import { useAuthBottomSheet, type SocialAuthConfiguration } from "../hooks/useAuthBottomSheet";
17
17
  import { LoginForm } from "./LoginForm";
18
18
  import { RegisterForm } from "./RegisterForm";
19
19
  import { SocialLoginButtons } from "./SocialLoginButtons";
20
20
  import { styles } from "./AuthBottomSheet.styles";
21
- import type { SocialAuthProvider } from "../../domain/value-objects/AuthConfig";
22
21
 
23
22
  export interface AuthBottomSheetProps {
24
23
  termsUrl?: string;
25
24
  privacyUrl?: string;
26
25
  onTermsPress?: () => void;
27
26
  onPrivacyPress?: () => void;
28
- /** Enabled social auth providers */
29
- socialProviders?: SocialAuthProvider[];
30
- /** Called when Google sign-in is requested */
27
+ /** Social auth configuration */
28
+ socialConfig?: SocialAuthConfiguration;
29
+ /** Called when Google sign-in is requested (overrides internal behavior) */
31
30
  onGoogleSignIn?: () => Promise<void>;
32
- /** Called when Apple sign-in is requested */
31
+ /** Called when Apple sign-in is requested (overrides internal behavior) */
33
32
  onAppleSignIn?: () => Promise<void>;
34
33
  }
35
34
 
@@ -38,7 +37,7 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
38
37
  privacyUrl,
39
38
  onTermsPress,
40
39
  onPrivacyPress,
41
- socialProviders = [],
40
+ socialConfig,
42
41
  onGoogleSignIn,
43
42
  onAppleSignIn,
44
43
  }) => {
@@ -50,13 +49,14 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
50
49
  googleLoading,
51
50
  appleLoading,
52
51
  mode,
52
+ providers,
53
53
  handleDismiss,
54
54
  handleClose,
55
55
  handleNavigateToRegister,
56
56
  handleNavigateToLogin,
57
57
  handleGoogleSignIn,
58
58
  handleAppleSignIn,
59
- } = useAuthBottomSheet({ onGoogleSignIn, onAppleSignIn });
59
+ } = useAuthBottomSheet({ socialConfig, onGoogleSignIn, onAppleSignIn });
60
60
 
61
61
  return (
62
62
  <BottomSheetModal
@@ -106,9 +106,9 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
106
106
  />
107
107
  )}
108
108
 
109
- {socialProviders.length > 0 && (
109
+ {providers.length > 0 && (
110
110
  <SocialLoginButtons
111
- enabledProviders={socialProviders}
111
+ enabledProviders={providers}
112
112
  onGooglePress={() => { void handleGoogleSignIn(); }}
113
113
  onApplePress={() => { void handleAppleSignIn(); }}
114
114
  googleLoading={googleLoading}
@@ -1,14 +1,28 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { Platform } from "react-native";
2
3
  import type { BottomSheetModalRef } from "@umituz/react-native-design-system";
3
4
  import { useAuthModalStore } from "../stores/authModalStore";
4
5
  import { useAuth } from "../hooks/useAuth";
6
+ import { useGoogleAuth, type GoogleAuthConfig } from "./useGoogleAuth";
7
+ import { useAppleAuth } from "./useAppleAuth";
8
+ import type { SocialAuthProvider } from "../../domain/value-objects/AuthConfig";
5
9
 
6
- interface UseAuthBottomSheetProps {
10
+ declare const __DEV__: boolean;
11
+
12
+ export interface SocialAuthConfiguration {
13
+ google?: GoogleAuthConfig;
14
+ apple?: { enabled: boolean };
15
+ }
16
+
17
+ interface UseAuthBottomSheetParams {
18
+ socialConfig?: SocialAuthConfiguration;
7
19
  onGoogleSignIn?: () => Promise<void>;
8
20
  onAppleSignIn?: () => Promise<void>;
9
21
  }
10
22
 
11
- export function useAuthBottomSheet({ onGoogleSignIn, onAppleSignIn }: UseAuthBottomSheetProps) {
23
+ export function useAuthBottomSheet(params: UseAuthBottomSheetParams = {}) {
24
+ const { socialConfig, onGoogleSignIn, onAppleSignIn } = params;
25
+
12
26
  const modalRef = useRef<BottomSheetModalRef>(null);
13
27
  const [googleLoading, setGoogleLoading] = useState(false);
14
28
  const [appleLoading, setAppleLoading] = useState(false);
@@ -17,6 +31,25 @@ export function useAuthBottomSheet({ onGoogleSignIn, onAppleSignIn }: UseAuthBot
17
31
  useAuthModalStore();
18
32
  const { isAuthenticated, isAnonymous } = useAuth();
19
33
 
34
+ // Social Auth Hooks
35
+ const { signInWithGoogle, googleConfigured } = useGoogleAuth(socialConfig?.google);
36
+ const { signInWithApple, appleAvailable } = useAppleAuth();
37
+
38
+ // Determine enabled providers
39
+ const providers = useMemo<SocialAuthProvider[]>(() => {
40
+ const result: SocialAuthProvider[] = [];
41
+
42
+ if (Platform.OS === "ios" && socialConfig?.apple?.enabled && appleAvailable) {
43
+ result.push("apple");
44
+ }
45
+
46
+ if (googleConfigured) {
47
+ result.push("google");
48
+ }
49
+
50
+ return result;
51
+ }, [socialConfig?.apple?.enabled, appleAvailable, googleConfigured]);
52
+
20
53
  // Handle visibility sync with modalRef
21
54
  useEffect(() => {
22
55
  if (isVisible) {
@@ -41,14 +74,13 @@ export function useAuthBottomSheet({ onGoogleSignIn, onAppleSignIn }: UseAuthBot
41
74
  const prevIsAnonymousRef = useRef(isAnonymous);
42
75
 
43
76
  useEffect(() => {
44
- // Determine if user just successfully authenticated (either A: were not authed at all, or B: were anonymous and now aren't)
45
77
  const justAuthenticated = !prevIsAuthenticatedRef.current && isAuthenticated;
46
78
  const justConvertedFromAnonymous = prevIsAnonymousRef.current && !isAnonymous && isAuthenticated;
47
79
 
48
80
  if ((justAuthenticated || justConvertedFromAnonymous) && isVisible && !isAnonymous) {
49
81
  if (typeof __DEV__ !== "undefined" && __DEV__) {
50
82
  // eslint-disable-next-line no-console
51
- console.log("[AuthBottomSheet] Auto-closing due to successful authentication transition", {
83
+ console.log("[useAuthBottomSheet] Auto-closing due to successful authentication transition", {
52
84
  justAuthenticated,
53
85
  justConvertedFromAnonymous,
54
86
  });
@@ -57,7 +89,6 @@ export function useAuthBottomSheet({ onGoogleSignIn, onAppleSignIn }: UseAuthBot
57
89
  executePendingCallback();
58
90
  }
59
91
 
60
- // Update refs for next render
61
92
  prevIsAuthenticatedRef.current = isAuthenticated;
62
93
  prevIsVisibleRef.current = isVisible;
63
94
  prevIsAnonymousRef.current = isAnonymous;
@@ -71,36 +102,43 @@ export function useAuthBottomSheet({ onGoogleSignIn, onAppleSignIn }: UseAuthBot
71
102
  setMode("login");
72
103
  }, [setMode]);
73
104
 
74
- const handleGoogleSignIn = useCallback(async () => {
75
- if (!onGoogleSignIn) return;
105
+ const handleGoogleSignInInternal = useCallback(async () => {
76
106
  setGoogleLoading(true);
77
107
  try {
78
- await onGoogleSignIn();
108
+ if (onGoogleSignIn) {
109
+ await onGoogleSignIn();
110
+ } else if (signInWithGoogle) {
111
+ await signInWithGoogle();
112
+ }
79
113
  } finally {
80
114
  setGoogleLoading(false);
81
115
  }
82
- }, [onGoogleSignIn]);
116
+ }, [onGoogleSignIn, signInWithGoogle]);
83
117
 
84
- const handleAppleSignIn = useCallback(async () => {
85
- if (!onAppleSignIn) return;
118
+ const handleAppleSignInInternal = useCallback(async () => {
86
119
  setAppleLoading(true);
87
120
  try {
88
- await onAppleSignIn();
121
+ if (onAppleSignIn) {
122
+ await onAppleSignIn();
123
+ } else if (signInWithApple) {
124
+ await signInWithApple();
125
+ }
89
126
  } finally {
90
127
  setAppleLoading(false);
91
128
  }
92
- }, [onAppleSignIn]);
129
+ }, [onAppleSignIn, signInWithApple]);
93
130
 
94
131
  return {
95
132
  modalRef,
96
133
  googleLoading,
97
134
  appleLoading,
98
135
  mode,
136
+ providers,
99
137
  handleDismiss,
100
138
  handleClose,
101
139
  handleNavigateToRegister,
102
140
  handleNavigateToLogin,
103
- handleGoogleSignIn,
104
- handleAppleSignIn,
141
+ handleGoogleSignIn: handleGoogleSignInInternal,
142
+ handleAppleSignIn: handleAppleSignInInternal,
105
143
  };
106
144
  }
@@ -1,63 +0,0 @@
1
- /**
2
- * AuthBottomSheetWrapper Component
3
- * Self-contained auth modal with integrated social login
4
- *
5
- * This wrapper component combines AuthBottomSheet with social auth hooks,
6
- * providing a complete authentication solution for apps.
7
- *
8
- * Usage:
9
- * ```tsx
10
- * <AuthBottomSheetWrapper
11
- * termsUrl="https://myapp.com/terms"
12
- * privacyUrl="https://myapp.com/privacy"
13
- * socialConfig={{
14
- * google: { webClientId: '...', iosClientId: '...' },
15
- * apple: { enabled: true }
16
- * }}
17
- * />
18
- * ```
19
- */
20
-
21
- import React from "react";
22
- import { AuthBottomSheet } from "./AuthBottomSheet";
23
- import { useAuthBottomSheetWrapper, type SocialAuthConfiguration } from "../hooks/useAuthBottomSheetWrapper";
24
-
25
- export interface AuthBottomSheetWrapperProps {
26
- /** Terms of Service URL */
27
- termsUrl?: string;
28
- /** Privacy Policy URL */
29
- privacyUrl?: string;
30
- /** Called when Terms link is pressed (overrides default behavior) */
31
- onTermsPress?: () => void;
32
- /** Called when Privacy link is pressed (overrides default behavior) */
33
- onPrivacyPress?: () => void;
34
- /** Social auth configuration */
35
- socialConfig?: SocialAuthConfiguration;
36
- }
37
-
38
- /**
39
- * Self-contained auth bottom sheet with integrated social login
40
- */
41
- export const AuthBottomSheetWrapper: React.FC<AuthBottomSheetWrapperProps> = ({
42
- termsUrl,
43
- privacyUrl,
44
- onTermsPress,
45
- onPrivacyPress,
46
- socialConfig,
47
- }) => {
48
- const { providers, handleGoogleSignIn, handleAppleSignIn } = useAuthBottomSheetWrapper({
49
- socialConfig,
50
- });
51
-
52
- return (
53
- <AuthBottomSheet
54
- termsUrl={termsUrl}
55
- privacyUrl={privacyUrl}
56
- onTermsPress={onTermsPress}
57
- onPrivacyPress={onPrivacyPress}
58
- socialProviders={providers}
59
- onGoogleSignIn={handleGoogleSignIn}
60
- onAppleSignIn={handleAppleSignIn}
61
- />
62
- );
63
- };
@@ -1,70 +0,0 @@
1
- import { useCallback, useMemo } from "react";
2
- import { Platform } from "react-native";
3
- import { useGoogleAuth, type GoogleAuthConfig } from "./useGoogleAuth";
4
- import { useAppleAuth } from "./useAppleAuth";
5
- import type { SocialAuthProvider } from "../../domain/value-objects/AuthConfig";
6
-
7
- declare const __DEV__: boolean;
8
-
9
- export interface SocialAuthConfiguration {
10
- google?: GoogleAuthConfig;
11
- apple?: { enabled: boolean };
12
- }
13
-
14
- interface UseAuthBottomSheetWrapperProps {
15
- socialConfig?: SocialAuthConfiguration;
16
- }
17
-
18
- export function useAuthBottomSheetWrapper({ socialConfig }: UseAuthBottomSheetWrapperProps) {
19
- const { signInWithGoogle, googleConfigured } = useGoogleAuth(socialConfig?.google);
20
- const { signInWithApple, appleAvailable } = useAppleAuth();
21
-
22
- const providers = useMemo<SocialAuthProvider[]>(() => {
23
- const result: SocialAuthProvider[] = [];
24
-
25
- if (Platform.OS === "ios" && socialConfig?.apple?.enabled && appleAvailable) {
26
- result.push("apple");
27
- }
28
-
29
- if (googleConfigured) {
30
- result.push("google");
31
- }
32
-
33
- if (__DEV__) {
34
- // eslint-disable-next-line no-console
35
- console.log("[useAuthBottomSheetWrapper] Enabled providers:", result);
36
- }
37
-
38
- return result;
39
- }, [socialConfig?.apple?.enabled, appleAvailable, googleConfigured]);
40
-
41
- const handleGoogleSignIn = useCallback(async () => {
42
- if (__DEV__) {
43
- // eslint-disable-next-line no-console
44
- console.log("[useAuthBottomSheetWrapper] Google sign-in requested");
45
- }
46
- const result = await signInWithGoogle();
47
- if (__DEV__) {
48
- // eslint-disable-next-line no-console
49
- console.log("[useAuthBottomSheetWrapper] Google result:", result);
50
- }
51
- }, [signInWithGoogle]);
52
-
53
- const handleAppleSignIn = useCallback(async () => {
54
- if (__DEV__) {
55
- // eslint-disable-next-line no-console
56
- console.log("[useAuthBottomSheetWrapper] Apple sign-in requested");
57
- }
58
- const result = await signInWithApple();
59
- if (__DEV__) {
60
- // eslint-disable-next-line no-console
61
- console.log("[useAuthBottomSheetWrapper] Apple result:", result);
62
- }
63
- }, [signInWithApple]);
64
-
65
- return {
66
- providers,
67
- handleGoogleSignIn,
68
- handleAppleSignIn,
69
- };
70
- }