/// SDK API
/// 端對端加密的統一入口
library;

import 'package:cipher_guard_sdk/src/domain/entities/rsa_key_pair.dart';
import 'package:cipher_guard_sdk/src/domain/entities/session_key.dart';
import 'package:cipher_guard_sdk/src/domain/entities/encrypted_message.dart';
import 'package:cipher_guard_sdk/src/presentation/wiring/cipher_guard_sdk_wiring.dart';

abstract class CipherGuardSdkApi
{
  factory CipherGuardSdkApi() => CipherGuardSdkWiring.build();

  // ==================== 平台版本 ====================
  
  /// 獲取平台版本
  Future<String?> platformVersion();

  // ==================== RSA 金鑰管理 ====================
  
  /// 生成 RSA 金鑰對
  Future<RsaKeyPair> generateRsaKeyPair({int keySize = 1024});

  /// 用密碼加密私鑰
  Future<String> encryptPrivateKey({required String privateKey, required String password,});

  /// 解密私鑰
  Future<String> decryptPrivateKey({required String encryptedPrivateKey, required String password,});

  // ==================== 會話金鑰管理 ====================
  
  /// 生成 AES 會話金鑰
  Future<SessionKey> generateSessionKey({int initialRound = 1});

  /// 用 RSA 公鑰加密會話金鑰
  Future<String> encryptSessionKey({required String sessionKey, required String publicKey,});

  /// 用 RSA 私鑰解密會話金鑰
  Future<String> decryptSessionKey({required String encryptedSessionKey, required String privateKey,});

  // ==================== 訊息加解密 ====================
  
  /// 加密訊息
  Future<EncryptedMessage> encryptMessage({required String plaintext, required String sessionKey, required int round,});

  /// 解密訊息
  Future<String> decryptMessage({required String encryptedData, required String sessionKey, required int round,});

  // ==================== 原生平台同步 ====================
  
  /// 同步加密金鑰到原生平台 (iOS App Group)
  Future<void> syncEncryptionKey({required String chatId, required int activeRound, required int round, required String activeKey, required bool isSingle,});

  /// 批量同步所有加密聊天室的金鑰
  Future<void> syncAllEncryptionKeys({required Map<String, Map<String, dynamic>> chatMap,});

  // ==================== 推送通知解密 ====================
  
  /// 設置 AES_SECRET (用於推送解密)
  Future<void> setAesSecret({required String aesSecret});

  /// 解密 APNS 推送通知內容
  Future<String?> decryptPushNotification({required String encryptedData,});
}

