@umituz/react-native-auth 2.5.4 → 2.5.5

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.5.4",
3
+ "version": "2.5.5",
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",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * User Profile Types
3
+ * Domain types for user profile management across all apps
4
+ */
5
+
6
+ export interface UserProfile {
7
+ uid: string;
8
+ email: string | null;
9
+ displayName: string | null;
10
+ photoURL: string | null;
11
+ isAnonymous: boolean;
12
+ createdAt: Date | null;
13
+ lastLoginAt: Date | null;
14
+ }
15
+
16
+ export interface UpdateProfileParams {
17
+ displayName?: string;
18
+ photoURL?: string;
19
+ }
package/src/index.ts CHANGED
@@ -102,12 +102,23 @@ export type { UseAuthResult } from './presentation/hooks/useAuth';
102
102
  export { useUserProfile } from './presentation/hooks/useUserProfile';
103
103
  export type { UserProfileData, UseUserProfileParams } from './presentation/hooks/useUserProfile';
104
104
 
105
+ export { useAccountManagement } from './presentation/hooks/useAccountManagement';
106
+ export type { UseAccountManagementReturn } from './presentation/hooks/useAccountManagement';
107
+
108
+ export { useProfileUpdate } from './presentation/hooks/useProfileUpdate';
109
+ export type { UseProfileUpdateReturn } from './presentation/hooks/useProfileUpdate';
110
+
111
+ export type { UserProfile, UpdateProfileParams } from './domain/entities/UserProfile';
112
+
105
113
  // =============================================================================
106
114
  // PRESENTATION LAYER - Screens & Navigation
107
115
  // =============================================================================
108
116
 
109
117
  export { LoginScreen } from './presentation/screens/LoginScreen';
110
118
  export { RegisterScreen } from './presentation/screens/RegisterScreen';
119
+ export { AccountScreen } from './presentation/screens/AccountScreen';
120
+ export type { AccountScreenConfig, AccountScreenProps } from './presentation/screens/AccountScreen';
121
+
111
122
  export { AuthNavigator } from './presentation/navigation/AuthNavigator';
112
123
  export type {
113
124
  AuthStackParamList,
@@ -133,6 +144,8 @@ export { AuthBottomSheet } from './presentation/components/AuthBottomSheet';
133
144
  export type { AuthBottomSheetProps } from './presentation/components/AuthBottomSheet';
134
145
  export { ProfileSection } from './presentation/components/ProfileSection';
135
146
  export type { ProfileSectionConfig, ProfileSectionProps } from './presentation/components/ProfileSection';
147
+ export { AccountActions } from './presentation/components/AccountActions';
148
+ export type { AccountActionsConfig, AccountActionsProps } from './presentation/components/AccountActions';
136
149
 
137
150
  // =============================================================================
138
151
  // PRESENTATION LAYER - Stores
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Account Actions Component
3
+ * Provides logout and delete account functionality
4
+ * Only shown for authenticated (non-anonymous) users
5
+ */
6
+
7
+ import React from "react";
8
+ import { View, Text, TouchableOpacity, StyleSheet, Alert } from "react-native";
9
+ import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
10
+
11
+ export interface AccountActionsConfig {
12
+ logoutText?: string;
13
+ deleteAccountText?: string;
14
+ logoutConfirmTitle?: string;
15
+ logoutConfirmMessage?: string;
16
+ deleteConfirmTitle?: string;
17
+ deleteConfirmMessage?: string;
18
+ onLogout: () => Promise<void>;
19
+ onDeleteAccount: () => Promise<void>;
20
+ }
21
+
22
+ export interface AccountActionsProps {
23
+ config: AccountActionsConfig;
24
+ }
25
+
26
+ export const AccountActions: React.FC<AccountActionsProps> = ({ config }) => {
27
+ const tokens = useAppDesignTokens();
28
+ const {
29
+ logoutText = "Log Out",
30
+ deleteAccountText = "Delete Account",
31
+ logoutConfirmTitle = "Log Out?",
32
+ logoutConfirmMessage = "Are you sure you want to log out?",
33
+ deleteConfirmTitle = "Delete Account?",
34
+ deleteConfirmMessage =
35
+ "This will permanently delete your account and all data. This action cannot be undone.",
36
+ onLogout,
37
+ onDeleteAccount,
38
+ } = config;
39
+
40
+ const handleLogout = () => {
41
+ Alert.alert(logoutConfirmTitle, logoutConfirmMessage, [
42
+ { text: "Cancel", style: "cancel" },
43
+ {
44
+ text: logoutText,
45
+ style: "destructive",
46
+ onPress: async () => {
47
+ try {
48
+ await onLogout();
49
+ } catch (error) {
50
+ console.error("Logout failed:", error);
51
+ }
52
+ },
53
+ },
54
+ ]);
55
+ };
56
+
57
+ const handleDeleteAccount = () => {
58
+ Alert.alert(deleteConfirmTitle, deleteConfirmMessage, [
59
+ { text: "Cancel", style: "cancel" },
60
+ {
61
+ text: deleteAccountText,
62
+ style: "destructive",
63
+ onPress: async () => {
64
+ try {
65
+ await onDeleteAccount();
66
+ } catch (error) {
67
+ console.error("Delete account failed:", error);
68
+ }
69
+ },
70
+ },
71
+ ]);
72
+ };
73
+
74
+ return (
75
+ <View style={styles.container}>
76
+ {/* Logout */}
77
+ <TouchableOpacity
78
+ style={[styles.actionButton, { borderColor: tokens.colors.border }]}
79
+ onPress={handleLogout}
80
+ activeOpacity={0.7}
81
+ >
82
+ <Text style={[styles.actionIcon, { color: tokens.colors.error }]}>
83
+
84
+ </Text>
85
+ <Text style={[styles.actionText, { color: tokens.colors.error }]}>
86
+ {logoutText}
87
+ </Text>
88
+ <Text style={[styles.chevron, { color: tokens.colors.textTertiary }]}>
89
+
90
+ </Text>
91
+ </TouchableOpacity>
92
+
93
+ {/* Delete Account */}
94
+ <TouchableOpacity
95
+ style={[styles.actionButton, { borderColor: tokens.colors.border }]}
96
+ onPress={handleDeleteAccount}
97
+ activeOpacity={0.7}
98
+ >
99
+ <Text style={[styles.actionIcon, { color: tokens.colors.error }]}>
100
+ 🗑
101
+ </Text>
102
+ <Text style={[styles.actionText, { color: tokens.colors.error }]}>
103
+ {deleteAccountText}
104
+ </Text>
105
+ <Text style={[styles.chevron, { color: tokens.colors.textTertiary }]}>
106
+
107
+ </Text>
108
+ </TouchableOpacity>
109
+ </View>
110
+ );
111
+ };
112
+
113
+ const styles = StyleSheet.create({
114
+ container: {
115
+ gap: 12,
116
+ },
117
+ actionButton: {
118
+ flexDirection: "row",
119
+ alignItems: "center",
120
+ paddingVertical: 16,
121
+ paddingHorizontal: 16,
122
+ borderRadius: 12,
123
+ borderWidth: 1,
124
+ gap: 12,
125
+ },
126
+ actionIcon: {
127
+ fontSize: 20,
128
+ },
129
+ actionText: {
130
+ flex: 1,
131
+ fontSize: 16,
132
+ fontWeight: "500",
133
+ },
134
+ chevron: {
135
+ fontSize: 24,
136
+ fontWeight: "400",
137
+ },
138
+ });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * useAccountManagement Hook
3
+ * Provides account management functionality (logout, delete)
4
+ */
5
+
6
+ import { useCallback } from "react";
7
+ import { useAuth } from "./useAuth";
8
+
9
+ export interface UseAccountManagementReturn {
10
+ logout: () => Promise<void>;
11
+ deleteAccount: () => Promise<void>;
12
+ isLoading: boolean;
13
+ }
14
+
15
+ export const useAccountManagement = (): UseAccountManagementReturn => {
16
+ const { user, loading, signOut } = useAuth();
17
+
18
+ const logout = useCallback(async () => {
19
+ await signOut();
20
+ }, [signOut]);
21
+
22
+ const deleteAccount = useCallback(async () => {
23
+ if (!user) {
24
+ throw new Error("No user logged in");
25
+ }
26
+
27
+ if (user.isAnonymous) {
28
+ throw new Error("Cannot delete anonymous account");
29
+ }
30
+
31
+ // Note: Add user deletion logic via Firebase Admin SDK on backend
32
+ // Frontend should call backend API to delete user account
33
+ throw new Error("Account deletion requires backend implementation");
34
+ }, [user]);
35
+
36
+ return {
37
+ logout,
38
+ deleteAccount,
39
+ isLoading: loading,
40
+ };
41
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * useProfileUpdate Hook
3
+ * Hook for profile updates - implementation should be provided by app
4
+ * Apps should use Firebase SDK directly or backend API
5
+ */
6
+
7
+ import { useState, useCallback } from "react";
8
+ import { useAuth } from "./useAuth";
9
+ import type { UpdateProfileParams } from "../../domain/entities/UserProfile";
10
+
11
+ export interface UseProfileUpdateReturn {
12
+ updateProfile: (params: UpdateProfileParams) => Promise<void>;
13
+ isUpdating: boolean;
14
+ error: string | null;
15
+ }
16
+
17
+ export const useProfileUpdate = (): UseProfileUpdateReturn => {
18
+ const { user } = useAuth();
19
+ const [isUpdating, setIsUpdating] = useState(false);
20
+ const [error, setError] = useState<string | null>(null);
21
+
22
+ const updateProfile = useCallback(
23
+ async (params: UpdateProfileParams) => {
24
+ if (!user) {
25
+ throw new Error("No user logged in");
26
+ }
27
+
28
+ if (user.isAnonymous) {
29
+ throw new Error("Anonymous users cannot update profile");
30
+ }
31
+
32
+ // Note: App should implement this via Firebase SDK
33
+ // Example: auth().currentUser?.updateProfile({ displayName, photoURL })
34
+ throw new Error("Profile update should be implemented by app");
35
+ },
36
+ [user],
37
+ );
38
+
39
+ return {
40
+ updateProfile,
41
+ isUpdating,
42
+ error,
43
+ };
44
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Account Screen
3
+ * Pure UI component for account management
4
+ * Business logic provided via props from app layer
5
+ */
6
+
7
+ import React from "react";
8
+ import { View, ScrollView, StyleSheet } from "react-native";
9
+ import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
10
+ import { ProfileSection, type ProfileSectionConfig } from "../components/ProfileSection";
11
+ import { AccountActions, type AccountActionsConfig } from "../components/AccountActions";
12
+
13
+ export interface AccountScreenConfig {
14
+ profile: ProfileSectionConfig;
15
+ accountActions: AccountActionsConfig;
16
+ }
17
+
18
+ export interface AccountScreenProps {
19
+ config: AccountScreenConfig;
20
+ }
21
+
22
+ export const AccountScreen: React.FC<AccountScreenProps> = ({ config }) => {
23
+ const tokens = useAppDesignTokens();
24
+
25
+ return (
26
+ <ScrollView
27
+ style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}
28
+ contentContainerStyle={styles.content}
29
+ >
30
+ <ProfileSection profile={config.profile} />
31
+ <View style={styles.divider} />
32
+ <AccountActions config={config.accountActions} />
33
+ </ScrollView>
34
+ );
35
+ };
36
+
37
+ const styles = StyleSheet.create({
38
+ container: {
39
+ flex: 1,
40
+ },
41
+ content: {
42
+ padding: 16,
43
+ },
44
+ divider: {
45
+ height: 24,
46
+ },
47
+ });