import 'package:shared_preferences/shared_preferences.dart';
import 'token_storage.dart';

/// Web-adapter: stores JWT in SharedPreferences (localStorage on web).
/// Replace with flutter_secure_storage adapter for Android/iOS.
class WebTokenStorage implements ITokenStorage {
  static const _key = 'auth_token';

  @override
  Future<String?> getToken() async {
    final prefs = await SharedPreferences.getInstance();
    return prefs.getString(_key);
  }

  @override
  Future<void> saveToken(String token) async {
    final prefs = await SharedPreferences.getInstance();
    await prefs.setString(_key, token);
  }

  @override
  Future<void> deleteToken() async {
    final prefs = await SharedPreferences.getInstance();
    await prefs.remove(_key);
  }
}
