@umituz/react-native-auth 2.6.7 → 2.6.9

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": "2.6.7",
3
+ "version": "2.6.9",
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",
@@ -50,12 +50,28 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@gorhom/bottom-sheet": "^5.0.0",
53
+ "@react-native-async-storage/async-storage": "^1.24.0",
54
+ "@react-navigation/native": "^6.0.0",
55
+ "@react-navigation/stack": "^6.0.0",
53
56
  "@types/node": "^20.0.0",
54
57
  "@types/react": "~19.1.0",
58
+ "@umituz/react-native-avatar": "latest",
59
+ "@umituz/react-native-design-system": "latest",
60
+ "@umituz/react-native-design-system-theme": "latest",
61
+ "@umituz/react-native-firebase": "latest",
62
+ "@umituz/react-native-firebase-auth": "latest",
63
+ "@umituz/react-native-localization": "latest",
64
+ "@umituz/react-native-storage": "latest",
65
+ "@umituz/react-native-validation": "latest",
66
+ "expo-apple-authentication": "^6.0.0",
67
+ "expo-crypto": "^12.0.0",
68
+ "expo-linear-gradient": "^13.0.0",
55
69
  "firebase": "^11.0.0",
70
+ "react": "~19.1.0",
56
71
  "react-native": "~0.76.0",
57
72
  "react-native-gesture-handler": "^2.0.0",
58
73
  "react-native-reanimated": "^3.0.0",
74
+ "react-native-safe-area-context": "^4.0.0",
59
75
  "react-native-svg": "^15.15.1",
60
76
  "typescript": "~5.9.2",
61
77
  "zustand": "^4.0.0"
@@ -12,7 +12,7 @@ export const styles = StyleSheet.create({
12
12
  },
13
13
  scrollContent: {
14
14
  paddingHorizontal: 24,
15
- paddingBottom: 20, // Reduced from 40 to 20 to save space
15
+ paddingBottom: 40,
16
16
  },
17
17
  closeButton: {
18
18
  position: "absolute",
@@ -27,20 +27,20 @@ export const styles = StyleSheet.create({
27
27
  },
28
28
  header: {
29
29
  alignItems: "center",
30
- marginBottom: 8,
31
- marginTop: 4,
32
- paddingTop: 4,
30
+ marginBottom: 24,
31
+ marginTop: 8,
32
+ paddingTop: 16,
33
33
  },
34
34
  title: {
35
- fontSize: 22,
35
+ fontSize: 28,
36
36
  fontWeight: "700",
37
- marginBottom: 2,
37
+ marginBottom: 8,
38
38
  textAlign: "center",
39
39
  },
40
40
  subtitle: {
41
- fontSize: 13,
41
+ fontSize: 15,
42
42
  textAlign: "center",
43
- lineHeight: 18,
43
+ lineHeight: 22,
44
44
  },
45
45
  formContainer: {
46
46
  flex: 1,
@@ -114,7 +114,7 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
114
114
  [],
115
115
  );
116
116
 
117
- const snapPoints = useMemo(() => ["94%"], []);
117
+ const snapPoints = useMemo(() => ["95%"], []);
118
118
 
119
119
  return (
120
120
  <BottomSheetModal
@@ -111,7 +111,7 @@ export const AuthLegalLinks: React.FC<AuthLegalLinksProps> = ({
111
111
 
112
112
  const styles = StyleSheet.create({
113
113
  container: {
114
- marginTop: 8,
114
+ marginTop: 16,
115
115
  alignItems: "center",
116
116
  },
117
117
  prefixText: {
@@ -50,8 +50,8 @@ const styles = StyleSheet.create({
50
50
  flexDirection: "row",
51
51
  justifyContent: "center",
52
52
  alignItems: "center",
53
- marginTop: 0,
54
- paddingTop: 0,
53
+ marginTop: 8,
54
+ paddingTop: 8,
55
55
  },
56
56
  text: {
57
57
  fontSize: 15,
@@ -153,14 +153,14 @@ export const RegisterForm: React.FC<RegisterFormProps> = ({
153
153
 
154
154
  const styles = StyleSheet.create({
155
155
  inputContainer: {
156
- marginBottom: 10,
156
+ marginBottom: 20,
157
157
  },
158
158
  buttonContainer: {
159
- marginBottom: 8,
160
- marginTop: 4,
159
+ marginBottom: 16,
160
+ marginTop: 8,
161
161
  },
162
162
  signUpButton: {
163
- minHeight: 48,
163
+ minHeight: 52,
164
164
  },
165
165
  });
166
166
 
@@ -111,12 +111,12 @@ export const SocialLoginButtons: React.FC<SocialLoginButtonsProps> = ({
111
111
 
112
112
  const styles = StyleSheet.create({
113
113
  container: {
114
- marginTop: 12,
114
+ marginTop: 24,
115
115
  },
116
116
  dividerContainer: {
117
117
  flexDirection: "row",
118
118
  alignItems: "center",
119
- marginBottom: 12,
119
+ marginBottom: 20,
120
120
  },
121
121
  divider: {
122
122
  flex: 1,
@@ -135,7 +135,7 @@ const styles = StyleSheet.create({
135
135
  flexDirection: "row",
136
136
  alignItems: "center",
137
137
  justifyContent: "center",
138
- paddingVertical: 10,
138
+ paddingVertical: 14,
139
139
  borderRadius: 12,
140
140
  borderWidth: 1,
141
141
  gap: 8,
@@ -1,20 +1,35 @@
1
1
  /**
2
2
  * useAccountManagement Hook
3
3
  * Provides account management functionality (logout, delete)
4
+ * Generic hook - reauthentication is handled via callback from calling app
4
5
  */
5
6
 
6
- import { useCallback } from "react";
7
+ import { useCallback, useState } from "react";
7
8
  import { useAuth } from "./useAuth";
8
9
  import { deleteCurrentUser } from "@umituz/react-native-firebase-auth";
9
10
 
11
+ export interface UseAccountManagementOptions {
12
+ /**
13
+ * Callback invoked when reauthentication is required
14
+ * App should show appropriate UI (Google/Apple sign-in) and return success status
15
+ * If not provided, reauthentication errors will be thrown
16
+ */
17
+ onReauthRequired?: () => Promise<boolean>;
18
+ }
19
+
10
20
  export interface UseAccountManagementReturn {
11
21
  logout: () => Promise<void>;
12
22
  deleteAccount: () => Promise<void>;
13
23
  isLoading: boolean;
24
+ isDeletingAccount: boolean;
14
25
  }
15
26
 
16
- export const useAccountManagement = (): UseAccountManagementReturn => {
27
+ export const useAccountManagement = (
28
+ options: UseAccountManagementOptions = {}
29
+ ): UseAccountManagementReturn => {
17
30
  const { user, loading, signOut } = useAuth();
31
+ const [isDeletingAccount, setIsDeletingAccount] = useState(false);
32
+ const { onReauthRequired } = options;
18
33
 
19
34
  const logout = useCallback(async () => {
20
35
  await signOut();
@@ -29,16 +44,46 @@ export const useAccountManagement = (): UseAccountManagementReturn => {
29
44
  throw new Error("Cannot delete anonymous account");
30
45
  }
31
46
 
32
- const result = await deleteCurrentUser();
47
+ setIsDeletingAccount(true);
48
+
49
+ try {
50
+ const result = await deleteCurrentUser({ autoReauthenticate: true });
51
+
52
+ if (result.success) {
53
+ return;
54
+ }
55
+
56
+ // If reauthentication required and callback provided
57
+ if (result.error?.requiresReauth && onReauthRequired) {
58
+ const reauthSuccess = await onReauthRequired();
59
+
60
+ if (reauthSuccess) {
61
+ const retryResult = await deleteCurrentUser({
62
+ autoReauthenticate: false,
63
+ });
64
+
65
+ if (retryResult.success) {
66
+ return;
67
+ }
68
+
69
+ if (retryResult.error) {
70
+ throw new Error(retryResult.error.message);
71
+ }
72
+ }
73
+ }
33
74
 
34
- if (!result.success && result.error) {
35
- throw new Error(result.error.message);
75
+ if (result.error) {
76
+ throw new Error(result.error.message);
77
+ }
78
+ } finally {
79
+ setIsDeletingAccount(false);
36
80
  }
37
- }, [user]);
81
+ }, [user, onReauthRequired]);
38
82
 
39
83
  return {
40
84
  logout,
41
85
  deleteAccount,
42
86
  isLoading: loading,
87
+ isDeletingAccount,
43
88
  };
44
89
  };