@umituz/react-native-auth 4.2.7 → 4.2.9
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.9",
|
|
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",
|
|
@@ -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";
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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';
|
|
2
|
+
import { CommonActions } from '@react-navigation/native';
|
|
8
3
|
import { AppNavigation } from '@umituz/react-native-design-system';
|
|
4
|
+
import { setPasswordPromptCallback } from '../utils/passwordPromptCallback';
|
|
9
5
|
|
|
10
6
|
declare const __DEV__: boolean;
|
|
11
7
|
|
|
@@ -24,72 +20,43 @@ export const usePasswordPromptNavigation = (
|
|
|
24
20
|
options: UsePasswordPromptNavigationOptions
|
|
25
21
|
): UsePasswordPromptNavigationReturn => {
|
|
26
22
|
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
23
|
|
|
38
24
|
const showPasswordPrompt = useCallback((): Promise<string | null> => {
|
|
39
25
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
40
26
|
console.log("[showPasswordPrompt] Called");
|
|
41
27
|
}
|
|
42
28
|
|
|
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
|
-
};
|
|
29
|
+
return new Promise<string | null>((resolve) => {
|
|
30
|
+
setPasswordPromptCallback(resolve);
|
|
68
31
|
|
|
69
32
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
33
|
+
const ref = AppNavigation.getRef();
|
|
34
|
+
if (!ref?.isReady()) {
|
|
35
|
+
throw new Error("Navigation not ready");
|
|
72
36
|
}
|
|
73
37
|
|
|
74
|
-
|
|
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
|
+
);
|
|
75
47
|
|
|
76
48
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
77
|
-
console.log("[showPasswordPrompt] Navigation
|
|
49
|
+
console.log("[showPasswordPrompt] Navigation reset to PasswordPrompt");
|
|
78
50
|
}
|
|
79
51
|
} catch (error) {
|
|
80
52
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
81
53
|
console.error("[showPasswordPrompt] Navigation failed:", error);
|
|
82
54
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
resolveRef.current = null;
|
|
86
|
-
}
|
|
87
|
-
reject(error);
|
|
55
|
+
setPasswordPromptCallback(null);
|
|
56
|
+
resolve(null);
|
|
88
57
|
}
|
|
89
58
|
});
|
|
90
59
|
}, [title, message, confirmText, cancelText]);
|
|
91
60
|
|
|
92
|
-
return {
|
|
93
|
-
showPasswordPrompt,
|
|
94
|
-
};
|
|
61
|
+
return { showPasswordPrompt };
|
|
95
62
|
};
|
|
@@ -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
|
+
};
|