import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, Switch, Alert, Pressable, } from 'react-native'; import { useBiometricAuth } from '../contexts/BiometricAuthContext'; import { AppColors, KurdistanColors } from '../theme/colors'; import { Card, Button, Input, BottomSheet } from '../components'; /** * Security Settings Screen * Configure biometric auth, PIN code, auto-lock * * PRIVACY GUARANTEE: * - All data stored LOCALLY on device only * - Biometric data never leaves iOS/Android secure enclave * - PIN stored in encrypted SecureStore on device * - Settings saved in AsyncStorage (local only) * - NO DATA TRANSMITTED TO SERVERS */ export default function SecurityScreen() { const { isBiometricSupported, isBiometricEnrolled, biometricType, isBiometricEnabled, autoLockTimer, enableBiometric, disableBiometric, setPinCode, setAutoLockTimer, } = useBiometricAuth(); const [pinSheetVisible, setPinSheetVisible] = useState(false); const [newPin, setNewPin] = useState(''); const [confirmPin, setConfirmPin] = useState(''); const [settingPin, setSettingPin] = useState(false); const [timerSheetVisible, setTimerSheetVisible] = useState(false); const getBiometricLabel = () => { switch (biometricType) { case 'facial': return 'Face ID'; case 'fingerprint': return 'Fingerprint'; case 'iris': return 'Iris Recognition'; default: return 'Biometric'; } }; const getBiometricIcon = () => { switch (biometricType) { case 'facial': return 'šŸ”'; case 'fingerprint': return 'šŸ‘†'; case 'iris': return 'šŸ‘ļø'; default: return 'šŸ”’'; } }; const handleToggleBiometric = async (value: boolean) => { if (value) { // Enable biometric const success = await enableBiometric(); if (!success) { Alert.alert( 'Authentication Failed', 'Could not enable biometric authentication. Please try again.' ); } else { Alert.alert( 'Success', `${getBiometricLabel()} authentication enabled successfully!` ); } } else { // Disable biometric Alert.alert( 'Disable Biometric Auth', `Are you sure you want to disable ${getBiometricLabel()}?`, [ { text: 'Cancel', style: 'cancel' }, { text: 'Disable', style: 'destructive', onPress: async () => { await disableBiometric(); Alert.alert('Disabled', `${getBiometricLabel()} authentication disabled`); }, }, ] ); } }; const handleSetPin = async () => { if (!newPin || !confirmPin) { Alert.alert('Error', 'Please enter PIN in both fields'); return; } if (newPin.length < 4) { Alert.alert('Error', 'PIN must be at least 4 digits'); return; } if (newPin !== confirmPin) { Alert.alert('Error', 'PINs do not match'); return; } try { setSettingPin(true); await setPinCode(newPin); Alert.alert( 'Success', 'PIN code set successfully!\n\nšŸ”’ Your PIN is stored encrypted on your device only.', [ { text: 'OK', onPress: () => { setPinSheetVisible(false); setNewPin(''); setConfirmPin(''); }, }, ] ); } catch (error: unknown) { Alert.alert('Error', error instanceof Error ? error.message : 'Failed to set PIN'); } finally { setSettingPin(false); } }; const autoLockOptions = [ { label: 'Immediately', value: 0 }, { label: '1 minute', value: 1 }, { label: '5 minutes', value: 5 }, { label: '15 minutes', value: 15 }, { label: '30 minutes', value: 30 }, { label: 'Never', value: 999999 }, ]; return ( {/* Header */} Security Protect your account and assets {/* Privacy Notice */} šŸ” Privacy Guarantee All security settings are stored locally on your device only. Your biometric data never leaves your device's secure enclave. PIN codes are encrypted. No data is transmitted to our servers. {/* Biometric Authentication */} Biometric Authentication {!isBiometricSupported ? ( Biometric authentication is not available on this device ) : !isBiometricEnrolled ? ( Please enroll {getBiometricLabel()} in your device settings first ) : ( {getBiometricIcon()} {getBiometricLabel()} {isBiometricEnabled ? 'Enabled' : 'Disabled'} )} {/* PIN Code */} PIN Code Set a backup PIN code for when biometric authentication fails