@umituz/react-native-firebase 2.1.0 → 2.2.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-firebase",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -74,23 +74,47 @@ async function attemptReauth(user: User, options: AccountDeletionOptions): Promi
74
74
  if (provider === "apple.com") {
75
75
  res = await reauthenticateWithApple(user);
76
76
  } else if (provider === "google.com") {
77
- if (!options.googleIdToken) {
77
+ let googleToken = options.googleIdToken;
78
+ if (!googleToken && options.onGoogleReauthRequired) {
79
+ const token = await options.onGoogleReauthRequired();
80
+ if (!token) {
81
+ return {
82
+ success: false,
83
+ error: { code: "auth/google-reauth-cancelled", message: "Google reauth cancelled" },
84
+ requiresReauth: true
85
+ };
86
+ }
87
+ googleToken = token;
88
+ }
89
+ if (!googleToken) {
78
90
  return {
79
91
  success: false,
80
92
  error: { code: "auth/google-reauth", message: "Google reauth required" },
81
93
  requiresReauth: true
82
94
  };
83
95
  }
84
- res = await reauthenticateWithGoogle(user, options.googleIdToken);
96
+ res = await reauthenticateWithGoogle(user, googleToken);
85
97
  } else if (provider === "password") {
86
- if (!options.password) {
98
+ let password = options.password;
99
+ if (!password && options.onPasswordRequired) {
100
+ const pwd = await options.onPasswordRequired();
101
+ if (!pwd) {
102
+ return {
103
+ success: false,
104
+ error: { code: "auth/password-reauth-cancelled", message: "Password reauth cancelled" },
105
+ requiresReauth: true
106
+ };
107
+ }
108
+ password = pwd;
109
+ }
110
+ if (!password) {
87
111
  return {
88
112
  success: false,
89
113
  error: { code: "auth/password-reauth", message: "Password required" },
90
114
  requiresReauth: true
91
115
  };
92
116
  }
93
- res = await reauthenticateWithPassword(user, options.password);
117
+ res = await reauthenticateWithPassword(user, password);
94
118
  } else {
95
119
  return null;
96
120
  }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Password Prompt Screen
3
+ * Full-screen modal for password input during account deletion reauthentication
4
+ */
5
+
6
+ import React, { useState } from 'react';
7
+ import { View, StyleSheet, SafeAreaView, KeyboardAvoidingView, Platform } from 'react-native';
8
+ import {
9
+ BaseModal,
10
+ AtomicInput,
11
+ AtomicButton,
12
+ AtomicText,
13
+ useAppDesignTokens
14
+ } from '@umituz/react-native-design-system';
15
+
16
+ export interface PasswordPromptScreenProps {
17
+ visible: boolean;
18
+ onConfirm: (password: string) => void;
19
+ onCancel: () => void;
20
+ title?: string;
21
+ message?: string;
22
+ confirmText?: string;
23
+ cancelText?: string;
24
+ }
25
+
26
+ export const PasswordPromptScreen: React.FC<PasswordPromptScreenProps> = ({
27
+ visible,
28
+ onConfirm,
29
+ onCancel,
30
+ title = 'Password Required',
31
+ message = 'Enter your password to continue',
32
+ confirmText = 'Confirm',
33
+ cancelText = 'Cancel',
34
+ }) => {
35
+ const tokens = useAppDesignTokens();
36
+ const [password, setPassword] = useState('');
37
+ const [error, setError] = useState('');
38
+
39
+ const handleConfirm = () => {
40
+ if (!password.trim()) {
41
+ setError('Password is required');
42
+ return;
43
+ }
44
+ onConfirm(password);
45
+ setPassword('');
46
+ setError('');
47
+ };
48
+
49
+ const handleCancel = () => {
50
+ setPassword('');
51
+ setError('');
52
+ onCancel();
53
+ };
54
+
55
+ return (
56
+ <BaseModal
57
+ visible={visible}
58
+ onClose={handleCancel}
59
+ dismissOnBackdrop={false}
60
+ presentationStyle="fullScreen"
61
+ >
62
+ <SafeAreaView style={[styles.safeArea, { backgroundColor: tokens.colors.background }]}>
63
+ <KeyboardAvoidingView
64
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
65
+ style={styles.keyboardView}
66
+ >
67
+ <View style={[styles.container, { padding: tokens.spacing.xl }]}>
68
+ <View style={styles.header}>
69
+ <AtomicText variant="h2" weight="bold" color="textPrimary" style={styles.title}>
70
+ {title}
71
+ </AtomicText>
72
+ <AtomicText variant="body" color="textSecondary" style={styles.message}>
73
+ {message}
74
+ </AtomicText>
75
+ </View>
76
+
77
+ <View style={styles.content}>
78
+ <AtomicInput
79
+ value={password}
80
+ onChangeText={(text: string) => {
81
+ setPassword(text);
82
+ setError('');
83
+ }}
84
+ placeholder="Password"
85
+ secureTextEntry
86
+ autoFocus
87
+ state={error ? 'error' : 'default'}
88
+ helperText={error}
89
+ style={{ marginBottom: tokens.spacing.md }}
90
+ />
91
+ </View>
92
+
93
+ <View style={[styles.buttons, { gap: tokens.spacing.sm }]}>
94
+ <AtomicButton
95
+ title={cancelText}
96
+ onPress={handleCancel}
97
+ variant="secondary"
98
+ style={styles.button}
99
+ />
100
+ <AtomicButton
101
+ title={confirmText}
102
+ onPress={handleConfirm}
103
+ variant="primary"
104
+ style={styles.button}
105
+ />
106
+ </View>
107
+ </View>
108
+ </KeyboardAvoidingView>
109
+ </SafeAreaView>
110
+ </BaseModal>
111
+ );
112
+ };
113
+
114
+ const styles = StyleSheet.create({
115
+ safeArea: {
116
+ flex: 1,
117
+ },
118
+ keyboardView: {
119
+ flex: 1,
120
+ },
121
+ container: {
122
+ flex: 1,
123
+ justifyContent: 'center',
124
+ },
125
+ header: {
126
+ marginBottom: 32,
127
+ },
128
+ title: {
129
+ marginBottom: 8,
130
+ textAlign: 'center',
131
+ },
132
+ message: {
133
+ textAlign: 'center',
134
+ },
135
+ content: {
136
+ flex: 1,
137
+ justifyContent: 'center',
138
+ },
139
+ buttons: {
140
+ flexDirection: 'row',
141
+ },
142
+ button: {
143
+ flex: 1,
144
+ },
145
+ });
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import React, { useState, useCallback, useMemo } from 'react';
7
- import { PasswordPromptModal } from '../components/PasswordPromptModal';
7
+ import { PasswordPromptScreen } from '../components/PasswordPromptScreen';
8
8
 
9
9
  export interface UsePasswordPromptOptions {
10
10
  title?: string;
@@ -46,7 +46,7 @@ export const usePasswordPrompt = (options: UsePasswordPromptOptions = {}): UsePa
46
46
  }, [resolvePromise]);
47
47
 
48
48
  const PasswordPromptComponent = useMemo(() => (
49
- <PasswordPromptModal
49
+ <PasswordPromptScreen
50
50
  visible={isVisible}
51
51
  onConfirm={handleConfirm}
52
52
  onCancel={handleCancel}
@@ -55,7 +55,7 @@ export const usePasswordPrompt = (options: UsePasswordPromptOptions = {}): UsePa
55
55
  confirmText={options.confirmText}
56
56
  cancelText={options.cancelText}
57
57
  />
58
- ), [isVisible, handleConfirm, handleCancel, options]);
58
+ ), [isVisible, handleConfirm, handleCancel, options.title, options.message, options.confirmText, options.cancelText]);
59
59
 
60
60
  return {
61
61
  showPasswordPrompt,
@@ -1,106 +0,0 @@
1
- /**
2
- * Password Prompt Modal
3
- * Modal for password input during account deletion reauthentication
4
- */
5
-
6
- import React, { useState } from 'react';
7
- import { View, StyleSheet } from 'react-native';
8
- import {
9
- BaseModal,
10
- AtomicInput,
11
- AtomicButton,
12
- useAppDesignTokens
13
- } from '@umituz/react-native-design-system';
14
-
15
- export interface PasswordPromptModalProps {
16
- visible: boolean;
17
- onConfirm: (password: string) => void;
18
- onCancel: () => void;
19
- title?: string;
20
- message?: string;
21
- confirmText?: string;
22
- cancelText?: string;
23
- }
24
-
25
- export const PasswordPromptModal: React.FC<PasswordPromptModalProps> = ({
26
- visible,
27
- onConfirm,
28
- onCancel,
29
- title = 'Password Required',
30
- message = 'Enter your password to continue',
31
- confirmText = 'Confirm',
32
- cancelText = 'Cancel',
33
- }) => {
34
- const tokens = useAppDesignTokens();
35
- const [password, setPassword] = useState('');
36
- const [error, setError] = useState('');
37
-
38
- const handleConfirm = () => {
39
- if (!password.trim()) {
40
- setError('Password is required');
41
- return;
42
- }
43
- onConfirm(password);
44
- setPassword('');
45
- setError('');
46
- };
47
-
48
- const handleCancel = () => {
49
- setPassword('');
50
- setError('');
51
- onCancel();
52
- };
53
-
54
- return (
55
- <BaseModal
56
- visible={visible}
57
- onClose={handleCancel}
58
- title={title}
59
- subtitle={message}
60
- dismissOnBackdrop={false}
61
- >
62
- <View style={[styles.container, { padding: tokens.spacing.md }]}>
63
- <AtomicInput
64
- value={password}
65
- onChangeText={(text: string) => {
66
- setPassword(text);
67
- setError('');
68
- }}
69
- placeholder="Password"
70
- secureTextEntry
71
- autoFocus
72
- state={error ? 'error' : 'default'}
73
- helperText={error}
74
- style={{ marginBottom: tokens.spacing.md }}
75
- />
76
-
77
- <View style={[styles.buttons, { gap: tokens.spacing.sm }]}>
78
- <AtomicButton
79
- title={cancelText}
80
- onPress={handleCancel}
81
- variant="secondary"
82
- style={styles.button}
83
- />
84
- <AtomicButton
85
- title={confirmText}
86
- onPress={handleConfirm}
87
- variant="primary"
88
- style={styles.button}
89
- />
90
- </View>
91
- </View>
92
- </BaseModal>
93
- );
94
- };
95
-
96
- const styles = StyleSheet.create({
97
- container: {
98
- width: '100%',
99
- },
100
- buttons: {
101
- flexDirection: 'row',
102
- },
103
- button: {
104
- flex: 1,
105
- },
106
- });