retrieveCredentials method
Retrieve credentials with biometric protection
Implementation
Future<Map<String, dynamic>?> retrieveCredentials({
bool requireBiometrics = false,
String? customKey,
}) async {
try {
OnairosDebugHelper.log('🔓 Retrieving credentials with enhanced security');
// Check if biometric authentication is required and available
if (requireBiometrics && await _isBiometricsAvailable()) {
final authenticated = await _authenticateWithBiometrics('Access your secure credentials');
if (!authenticated) {
throw Exception('Biometric authentication required to access credentials');
}
}
final key = customKey ?? 'onairos_credentials_enhanced';
final credentialsJson = await _secureStorage.read(key: key);
if (credentialsJson != null) {
final credentials = jsonDecode(credentialsJson) as Map<String, dynamic>;
OnairosDebugHelper.log('✅ Credentials retrieved successfully');
return credentials;
}
OnairosDebugHelper.log('⚠️ No credentials found');
return null;
} catch (e) {
OnairosDebugHelper.log('❌ Error retrieving credentials: $e');
return null;
}
}