@umituz/react-native-auth 4.0.1 → 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.1",
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": "^2.0.2"
106
+ "@umituz/react-native-firebase": "^2.1.0"
107
107
  }
108
108
  }
@@ -4,15 +4,15 @@
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
  /**
13
12
  * Callback invoked when reauthentication is required (for Google/Apple)
13
+ * Should return Google ID token or null if cancelled
14
14
  */
15
- onReauthRequired?: () => Promise<boolean>;
15
+ onReauthRequired?: () => Promise<string | null>;
16
16
  /**
17
17
  * Callback invoked when password reauthentication is required
18
18
  * If not provided, built-in Alert.prompt will be used
@@ -32,6 +32,7 @@ export interface UseAccountManagementReturn {
32
32
  deleteAccount: () => Promise<void>;
33
33
  isLoading: boolean;
34
34
  isDeletingAccount: boolean;
35
+ PasswordPromptComponent: React.ReactNode;
35
36
  }
36
37
 
37
38
  export const useAccountManagement = (
@@ -49,51 +50,14 @@ export const useAccountManagement = (
49
50
  passwordPromptConfirm = "Confirm",
50
51
  } = options;
51
52
 
52
- const PASSWORD_PROMPT_TIMEOUT_MS = 300000; // 5 minutes
53
+ const { showPasswordPrompt, PasswordPromptComponent } = usePasswordPrompt({
54
+ title: passwordPromptTitle,
55
+ message: passwordPromptMessage,
56
+ cancelText: passwordPromptCancel,
57
+ confirmText: passwordPromptConfirm,
58
+ });
53
59
 
54
- const defaultPasswordPrompt = useCallback((): Promise<string | null> => {
55
- return new Promise((resolve) => {
56
- let resolved = false;
57
-
58
- const timeoutId = setTimeout(() => {
59
- if (!resolved) {
60
- resolved = true;
61
- resolve(null); // Treat timeout as cancellation
62
- }
63
- }, PASSWORD_PROMPT_TIMEOUT_MS);
64
-
65
- Alert.prompt(
66
- passwordPromptTitle,
67
- passwordPromptMessage,
68
- [
69
- {
70
- text: passwordPromptCancel,
71
- style: "cancel",
72
- onPress: () => {
73
- if (!resolved) {
74
- resolved = true;
75
- clearTimeout(timeoutId);
76
- resolve(null);
77
- }
78
- }
79
- },
80
- {
81
- text: passwordPromptConfirm,
82
- onPress: (pwd?: string) => {
83
- if (!resolved) {
84
- resolved = true;
85
- clearTimeout(timeoutId);
86
- resolve(pwd || null);
87
- }
88
- }
89
- },
90
- ],
91
- "secure-text"
92
- );
93
- });
94
- }, [passwordPromptTitle, passwordPromptMessage, passwordPromptCancel, passwordPromptConfirm]);
95
-
96
- const passwordHandler = onPasswordRequired || defaultPasswordPrompt;
60
+ const passwordHandler = onPasswordRequired || showPasswordPrompt;
97
61
 
98
62
  const logout = useCallback(async () => {
99
63
  await signOut();
@@ -130,5 +94,6 @@ export const useAccountManagement = (
130
94
  deleteAccount,
131
95
  isLoading: loading,
132
96
  isDeletingAccount,
97
+ PasswordPromptComponent,
133
98
  };
134
99
  };