mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 05:37:56 +00:00
6a86915549
🔐 SECURITY FIXES: - Fixed CRITICAL seed storage vulnerability * Changed from AsyncStorage to SecureStore for wallet seeds * Seeds now encrypted in hardware-backed secure storage * Affects: PolkadotContext.tsx (lines 166, 189) 🛡️ ERROR HANDLING: - Added global ErrorBoundary component * Catches unhandled React errors * Shows user-friendly error UI * Integrated into App.tsx provider hierarchy * Files: ErrorBoundary.tsx (new), App.tsx, components/index.ts 🧹 PRODUCTION READINESS: - Protected all 47 console statements with __DEV__ checks * console.log: 12 statements * console.error: 32 statements * console.warn: 1 statement * Files affected: 16 files across contexts, screens, i18n * Production builds will strip these out 📦 PROVIDER HIERARCHY: - Added BiometricAuthProvider to App.tsx - Updated provider order: ErrorBoundary → Polkadot → Language → BiometricAuth → Navigator Files modified: 18 New files: 1 (ErrorBoundary.tsx) This commit resolves 3 P0 critical issues from production readiness audit.
258 lines
6.6 KiB
TypeScript
258 lines
6.6 KiB
TypeScript
import React, { useState } from 'react';
|
|
import {
|
|
View,
|
|
Text,
|
|
TextInput,
|
|
TouchableOpacity,
|
|
StyleSheet,
|
|
SafeAreaView,
|
|
KeyboardAvoidingView,
|
|
Platform,
|
|
ScrollView,
|
|
StatusBar,
|
|
} from 'react-native';
|
|
import { LinearGradient } from 'expo-linear-gradient';
|
|
import { useTranslation } from 'react-i18next';
|
|
import AppColors, { KurdistanColors } from '../theme/colors';
|
|
|
|
interface SignUpScreenProps {
|
|
onSignUp: () => void;
|
|
onNavigateToSignIn: () => void;
|
|
}
|
|
|
|
const SignUpScreen: React.FC<SignUpScreenProps> = ({ onSignUp, onNavigateToSignIn }) => {
|
|
const { t } = useTranslation();
|
|
const [email, setEmail] = useState('');
|
|
const [password, setPassword] = useState('');
|
|
const [confirmPassword, setConfirmPassword] = useState('');
|
|
|
|
const handleSignUp = () => {
|
|
// TODO: Implement actual registration
|
|
if (password !== confirmPassword) {
|
|
alert('Passwords do not match!');
|
|
return;
|
|
}
|
|
if (__DEV__) console.log('Sign up:', { email, password });
|
|
onSignUp();
|
|
};
|
|
|
|
return (
|
|
<SafeAreaView style={styles.container}>
|
|
<StatusBar barStyle="light-content" />
|
|
<LinearGradient
|
|
colors={[KurdistanColors.sor, KurdistanColors.zer]}
|
|
start={{ x: 0, y: 0 }}
|
|
end={{ x: 1, y: 1 }}
|
|
style={styles.gradient}
|
|
>
|
|
<KeyboardAvoidingView
|
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
style={styles.keyboardView}
|
|
>
|
|
<ScrollView
|
|
contentContainerStyle={styles.scrollContent}
|
|
showsVerticalScrollIndicator={false}
|
|
>
|
|
{/* Header */}
|
|
<View style={styles.header}>
|
|
<View style={styles.logoContainer}>
|
|
<Text style={styles.logoText}>PZK</Text>
|
|
</View>
|
|
<Text style={styles.title}>{t('auth.getStarted')}</Text>
|
|
<Text style={styles.subtitle}>{t('auth.createAccount')}</Text>
|
|
</View>
|
|
|
|
{/* Form */}
|
|
<View style={styles.form}>
|
|
<View style={styles.inputGroup}>
|
|
<Text style={styles.label}>{t('auth.email')}</Text>
|
|
<TextInput
|
|
style={styles.input}
|
|
placeholder={t('auth.email')}
|
|
value={email}
|
|
onChangeText={setEmail}
|
|
keyboardType="email-address"
|
|
autoCapitalize="none"
|
|
placeholderTextColor="rgba(0, 0, 0, 0.4)"
|
|
/>
|
|
</View>
|
|
|
|
<View style={styles.inputGroup}>
|
|
<Text style={styles.label}>{t('auth.password')}</Text>
|
|
<TextInput
|
|
style={styles.input}
|
|
placeholder={t('auth.password')}
|
|
value={password}
|
|
onChangeText={setPassword}
|
|
secureTextEntry
|
|
placeholderTextColor="rgba(0, 0, 0, 0.4)"
|
|
/>
|
|
</View>
|
|
|
|
<View style={styles.inputGroup}>
|
|
<Text style={styles.label}>{t('auth.confirmPassword')}</Text>
|
|
<TextInput
|
|
style={styles.input}
|
|
placeholder={t('auth.confirmPassword')}
|
|
value={confirmPassword}
|
|
onChangeText={setConfirmPassword}
|
|
secureTextEntry
|
|
placeholderTextColor="rgba(0, 0, 0, 0.4)"
|
|
/>
|
|
</View>
|
|
|
|
<TouchableOpacity
|
|
style={styles.signUpButton}
|
|
onPress={handleSignUp}
|
|
activeOpacity={0.8}
|
|
>
|
|
<Text style={styles.signUpButtonText}>{t('auth.signUp')}</Text>
|
|
</TouchableOpacity>
|
|
|
|
<View style={styles.divider}>
|
|
<View style={styles.dividerLine} />
|
|
<Text style={styles.dividerText}>or</Text>
|
|
<View style={styles.dividerLine} />
|
|
</View>
|
|
|
|
<TouchableOpacity
|
|
style={styles.signInPrompt}
|
|
onPress={onNavigateToSignIn}
|
|
>
|
|
<Text style={styles.signInPromptText}>
|
|
{t('auth.haveAccount')}{' '}
|
|
<Text style={styles.signInLink}>{t('auth.signIn')}</Text>
|
|
</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
</ScrollView>
|
|
</KeyboardAvoidingView>
|
|
</LinearGradient>
|
|
</SafeAreaView>
|
|
);
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
backgroundColor: KurdistanColors.sor,
|
|
},
|
|
gradient: {
|
|
flex: 1,
|
|
},
|
|
keyboardView: {
|
|
flex: 1,
|
|
},
|
|
scrollContent: {
|
|
flexGrow: 1,
|
|
padding: 20,
|
|
paddingTop: 60,
|
|
},
|
|
header: {
|
|
alignItems: 'center',
|
|
marginBottom: 40,
|
|
},
|
|
logoContainer: {
|
|
width: 80,
|
|
height: 80,
|
|
borderRadius: 40,
|
|
backgroundColor: KurdistanColors.spi,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
marginBottom: 16,
|
|
shadowColor: '#000',
|
|
shadowOffset: { width: 0, height: 4 },
|
|
shadowOpacity: 0.3,
|
|
shadowRadius: 8,
|
|
elevation: 8,
|
|
},
|
|
logoText: {
|
|
fontSize: 28,
|
|
fontWeight: 'bold',
|
|
color: KurdistanColors.sor,
|
|
},
|
|
title: {
|
|
fontSize: 24,
|
|
fontWeight: 'bold',
|
|
color: KurdistanColors.spi,
|
|
marginBottom: 8,
|
|
},
|
|
subtitle: {
|
|
fontSize: 16,
|
|
color: KurdistanColors.spi,
|
|
opacity: 0.9,
|
|
},
|
|
form: {
|
|
backgroundColor: KurdistanColors.spi,
|
|
borderRadius: 20,
|
|
padding: 24,
|
|
shadowColor: '#000',
|
|
shadowOffset: { width: 0, height: 4 },
|
|
shadowOpacity: 0.2,
|
|
shadowRadius: 8,
|
|
elevation: 8,
|
|
},
|
|
inputGroup: {
|
|
marginBottom: 20,
|
|
},
|
|
label: {
|
|
fontSize: 14,
|
|
fontWeight: '600',
|
|
color: KurdistanColors.reş,
|
|
marginBottom: 8,
|
|
},
|
|
input: {
|
|
backgroundColor: '#F5F5F5',
|
|
borderRadius: 12,
|
|
padding: 16,
|
|
fontSize: 16,
|
|
borderWidth: 1,
|
|
borderColor: '#E0E0E0',
|
|
},
|
|
signUpButton: {
|
|
backgroundColor: KurdistanColors.sor,
|
|
borderRadius: 12,
|
|
padding: 16,
|
|
alignItems: 'center',
|
|
marginTop: 8,
|
|
shadowColor: KurdistanColors.sor,
|
|
shadowOffset: { width: 0, height: 4 },
|
|
shadowOpacity: 0.3,
|
|
shadowRadius: 6,
|
|
elevation: 6,
|
|
},
|
|
signUpButtonText: {
|
|
fontSize: 18,
|
|
fontWeight: 'bold',
|
|
color: KurdistanColors.spi,
|
|
},
|
|
divider: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
marginVertical: 24,
|
|
},
|
|
dividerLine: {
|
|
flex: 1,
|
|
height: 1,
|
|
backgroundColor: '#E0E0E0',
|
|
},
|
|
dividerText: {
|
|
marginHorizontal: 12,
|
|
fontSize: 14,
|
|
color: '#999',
|
|
},
|
|
signInPrompt: {
|
|
alignItems: 'center',
|
|
},
|
|
signInPromptText: {
|
|
fontSize: 14,
|
|
color: '#666',
|
|
},
|
|
signInLink: {
|
|
color: KurdistanColors.sor,
|
|
fontWeight: 'bold',
|
|
},
|
|
});
|
|
|
|
export default SignUpScreen;
|