@umituz/react-native-auth 4.2.8 → 4.2.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 +1 -1
- package/src/index.ts +1 -1
- package/src/presentation/components/AccountActions.tsx +20 -2
- package/src/presentation/hooks/useAuthHandlers.ts +2 -20
- package/src/presentation/hooks/usePasswordPromptNavigation.ts +17 -7
- package/src/presentation/screens/PasswordPromptScreen.tsx +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.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",
|
package/src/index.ts
CHANGED
|
@@ -62,7 +62,7 @@ export type { UseAppleAuthResult } from './presentation/hooks/useAppleAuth';
|
|
|
62
62
|
export { useAuthBottomSheet } from './presentation/hooks/useAuthBottomSheet';
|
|
63
63
|
export type { SocialAuthConfiguration } from './presentation/hooks/useAuthBottomSheet';
|
|
64
64
|
export { useAuthHandlers } from './presentation/hooks/useAuthHandlers';
|
|
65
|
-
export type { AuthHandlersAppInfo, AuthHandlersTranslations
|
|
65
|
+
export type { AuthHandlersAppInfo, AuthHandlersTranslations } from './presentation/hooks/useAuthHandlers';
|
|
66
66
|
export { usePasswordPromptNavigation } from './presentation/hooks/usePasswordPromptNavigation';
|
|
67
67
|
export type { UsePasswordPromptNavigationOptions, UsePasswordPromptNavigationReturn } from './presentation/hooks/usePasswordPromptNavigation';
|
|
68
68
|
|
|
@@ -3,6 +3,8 @@ import { View, TouchableOpacity, StyleSheet } from "react-native";
|
|
|
3
3
|
import { useAppDesignTokens, AtomicIcon, AtomicText, useAlert, AlertType, AlertMode } from "@umituz/react-native-design-system";
|
|
4
4
|
import { actionButtonStyle } from "../utils/commonStyles";
|
|
5
5
|
|
|
6
|
+
declare const __DEV__: boolean;
|
|
7
|
+
|
|
6
8
|
export interface AccountActionsConfig {
|
|
7
9
|
logoutText: string;
|
|
8
10
|
deleteAccountText: string;
|
|
@@ -65,17 +67,33 @@ export const AccountActions: React.FC<AccountActionsProps> = ({ config }) => {
|
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
const handleDeleteAccount = () => {
|
|
70
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
71
|
+
console.log("[AccountActions] handleDeleteAccount called, showing confirmation modal");
|
|
72
|
+
}
|
|
68
73
|
alert.show(AlertType.ERROR, AlertMode.MODAL, deleteConfirmTitle, deleteConfirmMessage, {
|
|
69
74
|
actions: [
|
|
70
|
-
{ id: "cancel", label: cancelText, style: "secondary", onPress: () => {
|
|
75
|
+
{ id: "cancel", label: cancelText, style: "secondary", onPress: () => {
|
|
76
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
77
|
+
console.log("[AccountActions] Delete account cancelled");
|
|
78
|
+
}
|
|
79
|
+
} },
|
|
71
80
|
{
|
|
72
81
|
id: "confirm",
|
|
73
82
|
label: deleteAccountText,
|
|
74
83
|
style: "destructive",
|
|
75
84
|
onPress: async () => {
|
|
85
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
86
|
+
console.log("[AccountActions] Delete account confirmed, modal should be closed now, calling onDeleteAccount");
|
|
87
|
+
}
|
|
76
88
|
try {
|
|
77
89
|
await onDeleteAccount();
|
|
78
|
-
|
|
90
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
91
|
+
console.log("[AccountActions] onDeleteAccount completed successfully");
|
|
92
|
+
}
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
95
|
+
console.error("[AccountActions] onDeleteAccount failed:", error);
|
|
96
|
+
}
|
|
79
97
|
alert.showError(deleteErrorTitle, deleteErrorMessage, { mode: AlertMode.MODAL });
|
|
80
98
|
}
|
|
81
99
|
},
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Handlers Hook
|
|
3
|
-
* Centralized authentication-related handlers
|
|
4
|
-
* Uses auth package for all auth operations - no duplication
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import { useCallback } from "react";
|
|
8
2
|
import { Linking, Alert } from "react-native";
|
|
9
3
|
import { useAuth } from "./useAuth";
|
|
@@ -31,15 +25,7 @@ export interface AuthHandlersTranslations {
|
|
|
31
25
|
deleteAccountError?: string;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
|
-
export
|
|
35
|
-
onBeforeDeleteAccount?: () => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const useAuthHandlers = (
|
|
39
|
-
appInfo: AuthHandlersAppInfo,
|
|
40
|
-
translations?: AuthHandlersTranslations,
|
|
41
|
-
options?: AuthHandlersOptions,
|
|
42
|
-
) => {
|
|
28
|
+
export const useAuthHandlers = (appInfo: AuthHandlersAppInfo, translations?: AuthHandlersTranslations) => {
|
|
43
29
|
const { signOut } = useAuth();
|
|
44
30
|
const { showAuthModal } = useAuthModalStore();
|
|
45
31
|
|
|
@@ -98,10 +84,6 @@ export const useAuthHandlers = (
|
|
|
98
84
|
console.log("[useAuthHandlers] handleDeleteAccount called");
|
|
99
85
|
}
|
|
100
86
|
try {
|
|
101
|
-
if (options?.onBeforeDeleteAccount) {
|
|
102
|
-
options.onBeforeDeleteAccount();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
87
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
106
88
|
console.log("[useAuthHandlers] Calling deleteAccountFromAuth...");
|
|
107
89
|
}
|
|
@@ -119,7 +101,7 @@ export const useAuthHandlers = (
|
|
|
119
101
|
errorMessage || translations?.deleteAccountError || "Failed to delete account"
|
|
120
102
|
);
|
|
121
103
|
}
|
|
122
|
-
}, [deleteAccountFromAuth, translations
|
|
104
|
+
}, [deleteAccountFromAuth, translations]);
|
|
123
105
|
|
|
124
106
|
const handleSignIn = useCallback(() => {
|
|
125
107
|
showAuthModal(undefined, "login");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
+
import { CommonActions } from '@react-navigation/native';
|
|
2
3
|
import { AppNavigation } from '@umituz/react-native-design-system';
|
|
3
4
|
import { setPasswordPromptCallback } from '../utils/passwordPromptCallback';
|
|
4
5
|
|
|
@@ -29,14 +30,23 @@ export const usePasswordPromptNavigation = (
|
|
|
29
30
|
setPasswordPromptCallback(resolve);
|
|
30
31
|
|
|
31
32
|
try {
|
|
32
|
-
AppNavigation.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const ref = AppNavigation.getRef();
|
|
34
|
+
if (!ref?.isReady()) {
|
|
35
|
+
throw new Error("Navigation not ready");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ref.dispatch(
|
|
39
|
+
CommonActions.reset({
|
|
40
|
+
index: 1,
|
|
41
|
+
routes: [
|
|
42
|
+
{ name: 'Home' },
|
|
43
|
+
{ name: 'PasswordPrompt', params: { title, message, confirmText, cancelText } },
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
|
|
38
48
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
39
|
-
console.log("[showPasswordPrompt] Navigation
|
|
49
|
+
console.log("[showPasswordPrompt] Navigation reset to PasswordPrompt");
|
|
40
50
|
}
|
|
41
51
|
} catch (error) {
|
|
42
52
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
} from '@umituz/react-native-design-system';
|
|
11
11
|
import { resolvePasswordPrompt } from '../utils/passwordPromptCallback';
|
|
12
12
|
|
|
13
|
+
declare const __DEV__: boolean;
|
|
14
|
+
|
|
13
15
|
export interface PasswordPromptScreenProps {
|
|
14
16
|
route: {
|
|
15
17
|
params: {
|
|
@@ -32,6 +34,10 @@ export const PasswordPromptScreen: React.FC<PasswordPromptScreenProps> = ({
|
|
|
32
34
|
const [password, setPassword] = useState('');
|
|
33
35
|
const [error, setError] = useState('');
|
|
34
36
|
|
|
37
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
38
|
+
console.log("[PasswordPromptScreen] Rendered");
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
const {
|
|
36
42
|
title = 'Password Required',
|
|
37
43
|
message = 'Enter your password to continue',
|
|
@@ -40,15 +46,24 @@ export const PasswordPromptScreen: React.FC<PasswordPromptScreenProps> = ({
|
|
|
40
46
|
} = route.params;
|
|
41
47
|
|
|
42
48
|
const handleConfirm = () => {
|
|
49
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
50
|
+
console.log("[PasswordPromptScreen] handleConfirm called, password length:", password.length);
|
|
51
|
+
}
|
|
43
52
|
if (!password.trim()) {
|
|
44
53
|
setError('Password is required');
|
|
45
54
|
return;
|
|
46
55
|
}
|
|
56
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
57
|
+
console.log("[PasswordPromptScreen] Resolving password prompt and going back");
|
|
58
|
+
}
|
|
47
59
|
resolvePasswordPrompt(password);
|
|
48
60
|
navigation.goBack();
|
|
49
61
|
};
|
|
50
62
|
|
|
51
63
|
const handleCancel = () => {
|
|
64
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
65
|
+
console.log("[PasswordPromptScreen] handleCancel called");
|
|
66
|
+
}
|
|
52
67
|
resolvePasswordPrompt(null);
|
|
53
68
|
navigation.goBack();
|
|
54
69
|
};
|