@umituz/react-native-auth 2.6.8 → 2.6.10
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 +16 -2
- package/src/presentation/components/AccountActions.tsx +1 -1
- package/src/presentation/components/AuthBottomSheet.tsx +1 -1
- package/src/presentation/components/AuthDivider.tsx +1 -1
- package/src/presentation/components/AuthFormCard.tsx +1 -1
- package/src/presentation/components/AuthGradientBackground.tsx +1 -1
- package/src/presentation/components/AuthHeader.tsx +1 -1
- package/src/presentation/components/AuthLegalLinks.tsx +2 -2
- package/src/presentation/components/AuthLink.tsx +2 -2
- package/src/presentation/components/LoginForm.tsx +1 -1
- package/src/presentation/components/PasswordMatchIndicator.tsx +1 -1
- package/src/presentation/components/PasswordStrengthIndicator.tsx +1 -1
- package/src/presentation/components/ProfileSection.tsx +1 -1
- package/src/presentation/components/RegisterForm.tsx +1 -1
- package/src/presentation/components/SocialLoginButtons.tsx +1 -1
- package/src/presentation/hooks/useAccountManagement.ts +51 -6
- package/src/presentation/navigation/AuthNavigator.tsx +1 -1
- package/src/presentation/screens/AccountScreen.tsx +1 -1
- package/src/presentation/screens/EditProfileScreen.tsx +1 -1
- package/src/types/external.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.10",
|
|
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",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"@react-navigation/native": ">=6.0.0",
|
|
33
33
|
"@react-navigation/stack": ">=6.0.0",
|
|
34
34
|
"@umituz/react-native-design-system": "latest",
|
|
35
|
-
"@umituz/react-native-design-system-theme": "latest",
|
|
36
35
|
"@umituz/react-native-firebase-auth": "latest",
|
|
37
36
|
"@umituz/react-native-localization": "latest",
|
|
38
37
|
"@umituz/react-native-avatar": "latest",
|
|
@@ -50,12 +49,27 @@
|
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
52
|
+
"@react-native-async-storage/async-storage": "^1.24.0",
|
|
53
|
+
"@react-navigation/native": "^6.0.0",
|
|
54
|
+
"@react-navigation/stack": "^6.0.0",
|
|
53
55
|
"@types/node": "^20.0.0",
|
|
54
56
|
"@types/react": "~19.1.0",
|
|
57
|
+
"@umituz/react-native-avatar": "latest",
|
|
58
|
+
"@umituz/react-native-design-system": "latest",
|
|
59
|
+
"@umituz/react-native-firebase": "latest",
|
|
60
|
+
"@umituz/react-native-firebase-auth": "latest",
|
|
61
|
+
"@umituz/react-native-localization": "latest",
|
|
62
|
+
"@umituz/react-native-storage": "latest",
|
|
63
|
+
"@umituz/react-native-validation": "latest",
|
|
64
|
+
"expo-apple-authentication": "^6.0.0",
|
|
65
|
+
"expo-crypto": "^12.0.0",
|
|
66
|
+
"expo-linear-gradient": "^13.0.0",
|
|
55
67
|
"firebase": "^11.0.0",
|
|
68
|
+
"react": "~19.1.0",
|
|
56
69
|
"react-native": "~0.76.0",
|
|
57
70
|
"react-native-gesture-handler": "^2.0.0",
|
|
58
71
|
"react-native-reanimated": "^3.0.0",
|
|
72
|
+
"react-native-safe-area-context": "^4.0.0",
|
|
59
73
|
"react-native-svg": "^15.15.1",
|
|
60
74
|
"typescript": "~5.9.2",
|
|
61
75
|
"zustand": "^4.0.0"
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { View, Text, TouchableOpacity, StyleSheet, Alert } from "react-native";
|
|
9
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
9
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
|
|
11
11
|
export interface AccountActionsConfig {
|
|
12
12
|
logoutText?: string;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
BottomSheetScrollView,
|
|
12
12
|
type BottomSheetBackdropProps,
|
|
13
13
|
} from "@gorhom/bottom-sheet";
|
|
14
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
14
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
15
15
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
16
16
|
import { useAuthModalStore } from "../stores/authModalStore";
|
|
17
17
|
import { useAuth } from "../hooks/useAuth";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, Text, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
10
|
|
|
11
11
|
export const AuthDivider: React.FC = () => {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
|
|
10
10
|
interface AuthFormCardProps {
|
|
11
11
|
children: React.ReactNode;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { StyleSheet } from "react-native";
|
|
8
8
|
import { LinearGradient } from "expo-linear-gradient";
|
|
9
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
9
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
|
|
11
11
|
export const AuthGradientBackground: React.FC = () => {
|
|
12
12
|
const tokens = useAppDesignTokens();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, Text, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
10
|
|
|
11
11
|
interface AuthHeaderProps {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, StyleSheet, Linking } from "react-native";
|
|
8
|
-
import { AtomicButton, AtomicText } from "@umituz/react-native-design-system
|
|
9
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { AtomicButton, AtomicText } from "@umituz/react-native-design-system";
|
|
9
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
11
11
|
|
|
12
12
|
export interface AuthLegalLinksProps {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, Text, StyleSheet } from "react-native";
|
|
8
|
-
import { AtomicButton } from "@umituz/react-native-design-system
|
|
9
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { AtomicButton } from "@umituz/react-native-design-system";
|
|
9
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
|
|
11
11
|
interface AuthLinkProps {
|
|
12
12
|
text: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
|
-
import { AtomicInput, AtomicButton } from "@umituz/react-native-design-system
|
|
8
|
+
import { AtomicInput, AtomicButton } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
10
|
import { useLoginForm } from "../hooks/useLoginForm";
|
|
11
11
|
import { AuthErrorDisplay } from "./AuthErrorDisplay";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, Text, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
10
|
|
|
11
11
|
export interface PasswordMatchIndicatorProps {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, Text, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
import type { PasswordRequirements } from "../../infrastructure/utils/AuthValidation";
|
|
10
10
|
|
|
11
11
|
export interface PasswordStrengthIndicatorProps {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
|
|
9
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
9
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
import { Avatar } from "@umituz/react-native-avatar";
|
|
11
11
|
|
|
12
12
|
export interface ProfileSectionConfig {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
|
-
import { AtomicInput, AtomicButton } from "@umituz/react-native-design-system
|
|
8
|
+
import { AtomicInput, AtomicButton } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
10
|
import { useRegisterForm } from "../hooks/useRegisterForm";
|
|
11
11
|
import { AuthErrorDisplay } from "./AuthErrorDisplay";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Platform,
|
|
8
8
|
ActivityIndicator,
|
|
9
9
|
} from "react-native";
|
|
10
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
10
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
11
11
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
12
12
|
import type { SocialAuthProvider } from "../../domain/value-objects/AuthConfig";
|
|
13
13
|
import { AppleIconSvg, GoogleIconSvg } from "./icons";
|
|
@@ -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 = (
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
|
|
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
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useEffect, useState } from "react";
|
|
7
7
|
import { createStackNavigator } from "@react-navigation/stack";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
8
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
9
|
import { storageRepository } from "@umituz/react-native-storage";
|
|
10
10
|
import { unwrap } from "@umituz/react-native-storage";
|
|
11
11
|
import { LoginScreen } from "../screens/LoginScreen";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { View, ScrollView, StyleSheet } from "react-native";
|
|
9
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
9
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
import { ProfileSection, type ProfileSectionConfig } from "../components/ProfileSection";
|
|
11
11
|
import { AccountActions, type AccountActionsConfig } from "../components/AccountActions";
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
StyleSheet,
|
|
15
15
|
ActivityIndicator,
|
|
16
16
|
} from "react-native";
|
|
17
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system
|
|
17
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
18
18
|
import { Avatar } from "@umituz/react-native-avatar";
|
|
19
19
|
|
|
20
20
|
export interface EditProfileConfig {
|
package/src/types/external.d.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* These are optional dependencies that should be provided by the consuming application
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
declare module '@umituz/react-native-design-system
|
|
6
|
+
declare module '@umituz/react-native-design-system' {
|
|
7
7
|
export function useAppDesignTokens(): any;
|
|
8
8
|
export const defaultTheme: any;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
declare module '@umituz/react-native-design-system
|
|
11
|
+
declare module '@umituz/react-native-design-system' {
|
|
12
12
|
export const AtomicInput: any;
|
|
13
13
|
export const AtomicButton: any;
|
|
14
14
|
export const AtomicText: any;
|