@xouteiro/auth_npm 1.0.13 → 1.0.17
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 +32 -27
- package/src/components/LoginOnly.jsx +129 -75
- package/src/components/LoginRegisterFlow.jsx +130 -256
- package/src/components/LogoutButton.jsx +72 -58
- package/dist/index.js +0 -2885
- package/dist/index.mjs +0 -2862
package/package.json
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
"name": "@xouteiro/auth_npm",
|
|
3
|
+
"version": "1.0.17",
|
|
4
|
+
"description": "Authentication package for Supabase",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"supabase",
|
|
12
|
+
"auth",
|
|
13
|
+
"authentication"
|
|
14
|
+
],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react-native": ">=0.72.0",
|
|
19
|
+
"react": ">=18.0.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@supabase/auth-ui-react": "^0.4.7",
|
|
23
|
+
"@supabase/auth-ui-shared": "^0.1.8",
|
|
24
|
+
"@supabase/supabase-js": "^2.52.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "^19.1.9",
|
|
28
|
+
"@types/react-dom": "^19.1.7",
|
|
29
|
+
"react-native": "^0.81.4",
|
|
30
|
+
"esbuild": "^0.25.8",
|
|
31
|
+
"tsup": "^8.5.0",
|
|
32
|
+
"typescript": "^5.9.2"
|
|
33
|
+
}
|
|
29
34
|
}
|
|
@@ -1,96 +1,150 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TextInput,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
Platform,
|
|
10
|
+
ScrollView,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { registerWithEmail } from '../register';
|
|
3
13
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
margin: '40px auto',
|
|
7
|
-
padding: 28,
|
|
8
|
-
borderRadius: 12,
|
|
9
|
-
boxShadow: '0 2px 12px rgba(0,0,0,0.08)',
|
|
10
|
-
background: '#fff',
|
|
11
|
-
fontFamily: 'sans-serif',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const inputStyle = {
|
|
15
|
-
width: '100%',
|
|
16
|
-
padding: 10,
|
|
17
|
-
margin: '10px 0',
|
|
18
|
-
borderRadius: 6,
|
|
19
|
-
border: '1px solid #ddd',
|
|
20
|
-
fontSize: 16,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const buttonStyle = {
|
|
24
|
-
width: '100%',
|
|
25
|
-
padding: 12,
|
|
26
|
-
borderRadius: 6,
|
|
27
|
-
border: 'none',
|
|
28
|
-
background: '#0070f3',
|
|
29
|
-
color: '#fff',
|
|
30
|
-
fontWeight: 600,
|
|
31
|
-
fontSize: 16,
|
|
32
|
-
marginTop: 10,
|
|
33
|
-
cursor: 'pointer',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const messageStyle = (success) => ({
|
|
37
|
-
margin: '12px 0',
|
|
38
|
-
color: success ? '#0a0' : '#d32f2f',
|
|
39
|
-
background: success ? '#eafbe7' : '#fdeaea',
|
|
40
|
-
padding: 8,
|
|
41
|
-
borderRadius: 6,
|
|
42
|
-
textAlign: 'center',
|
|
43
|
-
fontSize: 15,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export default function LoginOnly() {
|
|
47
|
-
const [identifier, setIdentifier] = useState('');
|
|
14
|
+
export default function RegisterOnly() {
|
|
15
|
+
const [email, setEmail] = useState('');
|
|
48
16
|
const [password, setPassword] = useState('');
|
|
17
|
+
const [username, setUsername] = useState('');
|
|
18
|
+
const [phone, setPhone] = useState('');
|
|
49
19
|
const [message, setMessage] = useState(null);
|
|
50
20
|
const [success, setSuccess] = useState(false);
|
|
51
21
|
|
|
52
|
-
const
|
|
53
|
-
e.preventDefault();
|
|
22
|
+
const handleRegister = async () => {
|
|
54
23
|
setMessage(null);
|
|
55
24
|
setSuccess(false);
|
|
56
|
-
const { error } = await
|
|
25
|
+
const { error } = await registerWithEmail(email, password, username, phone);
|
|
57
26
|
if (error) {
|
|
58
|
-
setMessage(error.message || '
|
|
27
|
+
setMessage(error.message || 'Registration failed');
|
|
59
28
|
setSuccess(false);
|
|
60
29
|
} else {
|
|
61
|
-
setMessage('
|
|
30
|
+
setMessage('Registration successful! Please check your email to confirm.');
|
|
62
31
|
setSuccess(true);
|
|
63
32
|
setTimeout(() => {
|
|
64
|
-
|
|
33
|
+
setEmail('');
|
|
65
34
|
setPassword('');
|
|
35
|
+
setUsername('');
|
|
36
|
+
setPhone('');
|
|
66
37
|
setMessage(null);
|
|
67
38
|
setSuccess(false);
|
|
68
|
-
},
|
|
39
|
+
}, 2000);
|
|
69
40
|
}
|
|
70
41
|
};
|
|
71
42
|
|
|
72
43
|
return (
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
44
|
+
<KeyboardAvoidingView
|
|
45
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
46
|
+
style={styles.container}
|
|
47
|
+
>
|
|
48
|
+
<ScrollView contentContainerStyle={styles.scroll}>
|
|
49
|
+
<View style={styles.box}>
|
|
50
|
+
<TextInput
|
|
51
|
+
style={styles.input}
|
|
52
|
+
placeholder="Email"
|
|
53
|
+
value={email}
|
|
54
|
+
onChangeText={setEmail}
|
|
55
|
+
autoCapitalize="none"
|
|
56
|
+
keyboardType="email-address"
|
|
57
|
+
/>
|
|
58
|
+
<TextInput
|
|
59
|
+
style={styles.input}
|
|
60
|
+
placeholder="Password"
|
|
61
|
+
value={password}
|
|
62
|
+
onChangeText={setPassword}
|
|
63
|
+
secureTextEntry
|
|
64
|
+
/>
|
|
65
|
+
<TextInput
|
|
66
|
+
style={styles.input}
|
|
67
|
+
placeholder="Username (optional)"
|
|
68
|
+
value={username}
|
|
69
|
+
onChangeText={setUsername}
|
|
70
|
+
/>
|
|
71
|
+
<TextInput
|
|
72
|
+
style={styles.input}
|
|
73
|
+
placeholder="Phone (optional)"
|
|
74
|
+
value={phone}
|
|
75
|
+
onChangeText={setPhone}
|
|
76
|
+
keyboardType="phone-pad"
|
|
77
|
+
/>
|
|
78
|
+
<TouchableOpacity style={styles.button} onPress={handleRegister}>
|
|
79
|
+
<Text style={styles.buttonText}>Register</Text>
|
|
80
|
+
</TouchableOpacity>
|
|
81
|
+
{message && (
|
|
82
|
+
<View style={[styles.message, success ? styles.success : styles.error]}>
|
|
83
|
+
<Text style={styles.messageText}>{message}</Text>
|
|
84
|
+
</View>
|
|
85
|
+
)}
|
|
86
|
+
</View>
|
|
87
|
+
</ScrollView>
|
|
88
|
+
</KeyboardAvoidingView>
|
|
95
89
|
);
|
|
96
|
-
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
container: {
|
|
94
|
+
flex: 1,
|
|
95
|
+
backgroundColor: '#f5f5f5',
|
|
96
|
+
},
|
|
97
|
+
scroll: {
|
|
98
|
+
flexGrow: 1,
|
|
99
|
+
justifyContent: 'center',
|
|
100
|
+
paddingHorizontal: 24,
|
|
101
|
+
},
|
|
102
|
+
box: {
|
|
103
|
+
padding: 28,
|
|
104
|
+
borderRadius: 12,
|
|
105
|
+
backgroundColor: '#fff',
|
|
106
|
+
shadowColor: '#000',
|
|
107
|
+
shadowOpacity: 0.08,
|
|
108
|
+
shadowRadius: 12,
|
|
109
|
+
elevation: 4,
|
|
110
|
+
},
|
|
111
|
+
input: {
|
|
112
|
+
width: '100%',
|
|
113
|
+
padding: 10,
|
|
114
|
+
marginVertical: 10,
|
|
115
|
+
borderRadius: 6,
|
|
116
|
+
borderWidth: 1,
|
|
117
|
+
borderColor: '#ddd',
|
|
118
|
+
fontSize: 16,
|
|
119
|
+
},
|
|
120
|
+
button: {
|
|
121
|
+
width: '100%',
|
|
122
|
+
padding: 12,
|
|
123
|
+
borderRadius: 6,
|
|
124
|
+
backgroundColor: '#0070f3',
|
|
125
|
+
marginTop: 10,
|
|
126
|
+
alignItems: 'center',
|
|
127
|
+
},
|
|
128
|
+
buttonText: {
|
|
129
|
+
color: '#fff',
|
|
130
|
+
fontWeight: '600',
|
|
131
|
+
fontSize: 16,
|
|
132
|
+
},
|
|
133
|
+
message: {
|
|
134
|
+
marginTop: 12,
|
|
135
|
+
padding: 8,
|
|
136
|
+
borderRadius: 6,
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
},
|
|
139
|
+
success: {
|
|
140
|
+
backgroundColor: '#eafbe7',
|
|
141
|
+
},
|
|
142
|
+
error: {
|
|
143
|
+
backgroundColor: '#fdeaea',
|
|
144
|
+
},
|
|
145
|
+
messageText: {
|
|
146
|
+
fontSize: 15,
|
|
147
|
+
color: '#333',
|
|
148
|
+
textAlign: 'center',
|
|
149
|
+
},
|
|
150
|
+
});
|