@umituz/react-native-auth 4.0.2 → 4.1.0
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": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
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",
|
|
@@ -103,6 +103,6 @@
|
|
|
103
103
|
"LICENSE"
|
|
104
104
|
],
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@umituz/react-native-firebase": "
|
|
106
|
+
"@umituz/react-native-firebase": "^2.1.0"
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
|
-
import { Alert } from "react-native";
|
|
8
7
|
import { useAuth } from "./useAuth";
|
|
9
|
-
import { deleteCurrentUser } from "@umituz/react-native-firebase";
|
|
8
|
+
import { deleteCurrentUser, usePasswordPrompt } from "@umituz/react-native-firebase";
|
|
10
9
|
|
|
11
10
|
export interface UseAccountManagementOptions {
|
|
12
11
|
/**
|
|
@@ -33,6 +32,7 @@ export interface UseAccountManagementReturn {
|
|
|
33
32
|
deleteAccount: () => Promise<void>;
|
|
34
33
|
isLoading: boolean;
|
|
35
34
|
isDeletingAccount: boolean;
|
|
35
|
+
PasswordPromptComponent: React.ReactNode;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export const useAccountManagement = (
|
|
@@ -50,51 +50,14 @@ export const useAccountManagement = (
|
|
|
50
50
|
passwordPromptConfirm = "Confirm",
|
|
51
51
|
} = options;
|
|
52
52
|
|
|
53
|
-
const
|
|
53
|
+
const { showPasswordPrompt, PasswordPromptComponent } = usePasswordPrompt({
|
|
54
|
+
title: passwordPromptTitle,
|
|
55
|
+
message: passwordPromptMessage,
|
|
56
|
+
cancelText: passwordPromptCancel,
|
|
57
|
+
confirmText: passwordPromptConfirm,
|
|
58
|
+
});
|
|
54
59
|
|
|
55
|
-
const
|
|
56
|
-
return new Promise((resolve) => {
|
|
57
|
-
let resolved = false;
|
|
58
|
-
|
|
59
|
-
const timeoutId = setTimeout(() => {
|
|
60
|
-
if (!resolved) {
|
|
61
|
-
resolved = true;
|
|
62
|
-
resolve(null); // Treat timeout as cancellation
|
|
63
|
-
}
|
|
64
|
-
}, PASSWORD_PROMPT_TIMEOUT_MS);
|
|
65
|
-
|
|
66
|
-
Alert.prompt(
|
|
67
|
-
passwordPromptTitle,
|
|
68
|
-
passwordPromptMessage,
|
|
69
|
-
[
|
|
70
|
-
{
|
|
71
|
-
text: passwordPromptCancel,
|
|
72
|
-
style: "cancel",
|
|
73
|
-
onPress: () => {
|
|
74
|
-
if (!resolved) {
|
|
75
|
-
resolved = true;
|
|
76
|
-
clearTimeout(timeoutId);
|
|
77
|
-
resolve(null);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
text: passwordPromptConfirm,
|
|
83
|
-
onPress: (pwd?: string) => {
|
|
84
|
-
if (!resolved) {
|
|
85
|
-
resolved = true;
|
|
86
|
-
clearTimeout(timeoutId);
|
|
87
|
-
resolve(pwd || null);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
"secure-text"
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
}, [passwordPromptTitle, passwordPromptMessage, passwordPromptCancel, passwordPromptConfirm]);
|
|
96
|
-
|
|
97
|
-
const passwordHandler = onPasswordRequired || defaultPasswordPrompt;
|
|
60
|
+
const passwordHandler = onPasswordRequired || showPasswordPrompt;
|
|
98
61
|
|
|
99
62
|
const logout = useCallback(async () => {
|
|
100
63
|
await signOut();
|
|
@@ -131,5 +94,6 @@ export const useAccountManagement = (
|
|
|
131
94
|
deleteAccount,
|
|
132
95
|
isLoading: loading,
|
|
133
96
|
isDeletingAccount,
|
|
97
|
+
PasswordPromptComponent,
|
|
134
98
|
};
|
|
135
99
|
};
|