import 'package:flutter_secure_storage/flutter_secure_storage.dart';

class SecureStorage {
  final FlutterSecureStorage _storage = const FlutterSecureStorage();

  static const String _keyToken = 'jwt_token';
  static const String _keyDeviceSecret = 'device_secret';
  static const String _keyUserId = 'user_id';

  Future<void> saveToken(String token) async {
    await _storage.write(key: _keyToken, value: token);
  }

  Future<String?> getToken() async {
    return await _storage.read(key: _keyToken);
  }

  Future<void> saveDeviceSecret(String secret) async {
    await _storage.write(key: _keyDeviceSecret, value: secret);
  }

  Future<String?> getDeviceSecret() async {
    return await _storage.read(key: _keyDeviceSecret);
  }

  Future<void> clearAll() async {
    await _storage.deleteAll();
  }

  // Generic read/write for user profile data
  Future<void> write(String key, String value) async {
    await _storage.write(key: key, value: value);
  }

  Future<String?> read(String key) async {
    return await _storage.read(key: key);
  }
}
