@umituz/react-native-auth 2.6.8 → 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.8",
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"
@@ -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
  };