@umituz/react-native-auth 4.2.6 → 4.2.8
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.2.
|
|
3
|
+
"version": "4.2.8",
|
|
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,16 +32,13 @@ export interface AuthHandlersTranslations {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface AuthHandlersOptions {
|
|
35
|
-
|
|
35
|
+
onBeforeDeleteAccount?: () => void;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* Hook that provides authentication-related handlers
|
|
40
|
-
*/
|
|
41
38
|
export const useAuthHandlers = (
|
|
42
39
|
appInfo: AuthHandlersAppInfo,
|
|
43
40
|
translations?: AuthHandlersTranslations,
|
|
44
|
-
options?: AuthHandlersOptions
|
|
41
|
+
options?: AuthHandlersOptions,
|
|
45
42
|
) => {
|
|
46
43
|
const { signOut } = useAuth();
|
|
47
44
|
const { showAuthModal } = useAuthModalStore();
|
|
@@ -101,12 +98,8 @@ export const useAuthHandlers = (
|
|
|
101
98
|
console.log("[useAuthHandlers] handleDeleteAccount called");
|
|
102
99
|
}
|
|
103
100
|
try {
|
|
104
|
-
if (options?.
|
|
105
|
-
|
|
106
|
-
console.log("[useAuthHandlers] Closing modal before delete...");
|
|
107
|
-
}
|
|
108
|
-
options.onClose();
|
|
109
|
-
await new Promise(resolve => setTimeout(resolve, 300));
|
|
101
|
+
if (options?.onBeforeDeleteAccount) {
|
|
102
|
+
options.onBeforeDeleteAccount();
|
|
110
103
|
}
|
|
111
104
|
|
|
112
105
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* Password Prompt Navigation Hook
|
|
3
|
-
* Navigation-based password prompt that maintains Promise interface
|
|
4
|
-
* Uses AppNavigation for global navigation access
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useCallback, useRef, useEffect } from 'react';
|
|
1
|
+
import { useCallback } from 'react';
|
|
8
2
|
import { AppNavigation } from '@umituz/react-native-design-system';
|
|
3
|
+
import { setPasswordPromptCallback } from '../utils/passwordPromptCallback';
|
|
9
4
|
|
|
10
5
|
declare const __DEV__: boolean;
|
|
11
6
|
|
|
@@ -24,55 +19,22 @@ export const usePasswordPromptNavigation = (
|
|
|
24
19
|
options: UsePasswordPromptNavigationOptions
|
|
25
20
|
): UsePasswordPromptNavigationReturn => {
|
|
26
21
|
const { title, message, confirmText, cancelText } = options;
|
|
27
|
-
const resolveRef = useRef<((value: string | null) => void) | null>(null);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
return () => {
|
|
31
|
-
if (resolveRef.current) {
|
|
32
|
-
resolveRef.current(null);
|
|
33
|
-
resolveRef.current = null;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
22
|
|
|
38
23
|
const showPasswordPrompt = useCallback((): Promise<string | null> => {
|
|
39
24
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
40
25
|
console.log("[showPasswordPrompt] Called");
|
|
41
26
|
}
|
|
42
27
|
|
|
43
|
-
return new Promise<string | null>((resolve
|
|
44
|
-
|
|
45
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
46
|
-
console.log("[showPasswordPrompt] Resolving previous promise with null");
|
|
47
|
-
}
|
|
48
|
-
resolveRef.current(null);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
resolveRef.current = resolve;
|
|
52
|
-
|
|
53
|
-
const params = {
|
|
54
|
-
onComplete: (password: string | null) => {
|
|
55
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
56
|
-
console.log("[showPasswordPrompt] onComplete called with:", password ? "password" : "null");
|
|
57
|
-
}
|
|
58
|
-
if (resolveRef.current) {
|
|
59
|
-
resolveRef.current(password);
|
|
60
|
-
resolveRef.current = null;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
title,
|
|
64
|
-
message,
|
|
65
|
-
confirmText,
|
|
66
|
-
cancelText,
|
|
67
|
-
};
|
|
28
|
+
return new Promise<string | null>((resolve) => {
|
|
29
|
+
setPasswordPromptCallback(resolve);
|
|
68
30
|
|
|
69
31
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
32
|
+
AppNavigation.navigate('PasswordPrompt', {
|
|
33
|
+
title,
|
|
34
|
+
message,
|
|
35
|
+
confirmText,
|
|
36
|
+
cancelText,
|
|
37
|
+
});
|
|
76
38
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
77
39
|
console.log("[showPasswordPrompt] Navigation called successfully");
|
|
78
40
|
}
|
|
@@ -80,16 +42,11 @@ export const usePasswordPromptNavigation = (
|
|
|
80
42
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
81
43
|
console.error("[showPasswordPrompt] Navigation failed:", error);
|
|
82
44
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
resolveRef.current = null;
|
|
86
|
-
}
|
|
87
|
-
reject(error);
|
|
45
|
+
setPasswordPromptCallback(null);
|
|
46
|
+
resolve(null);
|
|
88
47
|
}
|
|
89
48
|
});
|
|
90
49
|
}, [title, message, confirmText, cancelText]);
|
|
91
50
|
|
|
92
|
-
return {
|
|
93
|
-
showPasswordPrompt,
|
|
94
|
-
};
|
|
51
|
+
return { showPasswordPrompt };
|
|
95
52
|
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Password Prompt Screen
|
|
3
|
-
* Navigation screen for password input during account deletion reauthentication
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
7
2
|
import { View, StyleSheet, KeyboardAvoidingView, Platform, TouchableOpacity } from 'react-native';
|
|
8
3
|
import {
|
|
9
4
|
AtomicInput,
|
|
@@ -13,11 +8,11 @@ import {
|
|
|
13
8
|
SafeAreaView,
|
|
14
9
|
useAppDesignTokens
|
|
15
10
|
} from '@umituz/react-native-design-system';
|
|
11
|
+
import { resolvePasswordPrompt } from '../utils/passwordPromptCallback';
|
|
16
12
|
|
|
17
13
|
export interface PasswordPromptScreenProps {
|
|
18
14
|
route: {
|
|
19
15
|
params: {
|
|
20
|
-
onComplete: (password: string | null) => void;
|
|
21
16
|
title?: string;
|
|
22
17
|
message?: string;
|
|
23
18
|
confirmText?: string;
|
|
@@ -38,30 +33,23 @@ export const PasswordPromptScreen: React.FC<PasswordPromptScreenProps> = ({
|
|
|
38
33
|
const [error, setError] = useState('');
|
|
39
34
|
|
|
40
35
|
const {
|
|
41
|
-
onComplete,
|
|
42
36
|
title = 'Password Required',
|
|
43
37
|
message = 'Enter your password to continue',
|
|
44
38
|
confirmText = 'Confirm',
|
|
45
39
|
cancelText = 'Cancel',
|
|
46
40
|
} = route.params;
|
|
47
41
|
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
return () => {
|
|
50
|
-
onComplete(null);
|
|
51
|
-
};
|
|
52
|
-
}, [onComplete]);
|
|
53
|
-
|
|
54
42
|
const handleConfirm = () => {
|
|
55
43
|
if (!password.trim()) {
|
|
56
44
|
setError('Password is required');
|
|
57
45
|
return;
|
|
58
46
|
}
|
|
59
|
-
|
|
47
|
+
resolvePasswordPrompt(password);
|
|
60
48
|
navigation.goBack();
|
|
61
49
|
};
|
|
62
50
|
|
|
63
51
|
const handleCancel = () => {
|
|
64
|
-
|
|
52
|
+
resolvePasswordPrompt(null);
|
|
65
53
|
navigation.goBack();
|
|
66
54
|
};
|
|
67
55
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
let callback: ((value: string | null) => void) | null = null;
|
|
2
|
+
|
|
3
|
+
export const setPasswordPromptCallback = (cb: ((value: string | null) => void) | null): void => {
|
|
4
|
+
callback = cb;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const getPasswordPromptCallback = (): ((value: string | null) => void) | null => callback;
|
|
8
|
+
|
|
9
|
+
export const resolvePasswordPrompt = (value: string | null): void => {
|
|
10
|
+
if (callback) {
|
|
11
|
+
callback(value);
|
|
12
|
+
callback = null;
|
|
13
|
+
}
|
|
14
|
+
};
|