import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:siro_service/print.dart';

class SecurityHelper {
  static const platform = MethodChannel('com.service_siro/security');

  static Future<String?> getAppSignature() async {
    try {
      final String? signature = await platform.invokeMethod('getAppSignature');
      final mode = kDebugMode ? 'DEBUG' : 'RELEASE';
      Log.print('----------------------------------------------------');
      Log.print('🚀 APP SIGNATURE HASH ($mode): $signature');
      Log.print('----------------------------------------------------');
      return signature;

    } on PlatformException catch (e) {
      Log.print('❌ Failed to get app signature: ${e.message}');
      return null;
    }
  }

  static Future<bool> isDeviceRooted() async {
    try {
      final bool isRooted = await platform.invokeMethod('isNativeRooted');
      return isRooted;
    } on PlatformException catch (e) {
      Log.print('❌ Failed to check root: ${e.message}');
      return false;
    }
  }
}
