SecureBankKit.initialize constructor

SecureBankKit.initialize({
  1. bool enableRootDetection = true,
  2. bool enablePinning = false,
  3. bool enableAppIntegrity = true,
  4. bool enableLogging = false,
  5. Map<String, List<String>> certificatePins = const {},
})

Creates and returns a fully-wired SecureBankKit instance.

Implementation

factory SecureBankKit.initialize({
  bool enableRootDetection = true,
  bool enablePinning = false,
  bool enableAppIntegrity = true,
  bool enableLogging = false,
  Map<String, List<String>> certificatePins = const {},
}) {
  if (enableLogging) {
    SecurityLogger.enable();
  }

  final channel = MethodChannelSecurity();

  // Datasources
  final certDs = CertificatePinningDatasource();
  final rootDs = RootDetectionDatasource(channel);
  final screenshotDs = ScreenshotProtectionDatasource(channel);
  final integrityDs = AppIntegrityDatasource(channel);
  final storageDs = SecureStorageDatasource(channel);

  // Repositories
  final certRepo = CertificatePinningRepositoryImpl(certDs);
  final rootRepo = RootDetectionRepositoryImpl(rootDs);
  final screenshotRepo = ScreenshotProtectionRepositoryImpl(screenshotDs);
  final integrityRepo = AppIntegrityRepositoryImpl(integrityDs);
  final storageRepo = SecureStorageRepositoryImpl(storageDs);

  // Use cases
  final checkRoot = CheckRootStatusUseCase(rootRepo);
  final validateCert = ValidateCertificateUseCase(certRepo);
  final checkIntegrity = CheckAppIntegrityUseCase(integrityRepo);
  final toggleScreenshot = ToggleScreenshotProtectionUseCase(screenshotRepo);
  final secureStorageUc = SecureStorageUseCase(storageRepo);

  SecurityLogger.info('SecureBankKit initialized');

  return SecureBankKit._(
    enableRootDetection: enableRootDetection,
    enablePinning: enablePinning,
    enableAppIntegrity: enableAppIntegrity,
    certificatePins: certificatePins,
    checkRoot: checkRoot,
    validateCertificate: validateCert,
    checkAppIntegrity: checkIntegrity,
    toggleScreenshot: toggleScreenshot,
    secureStorageUseCase: secureStorageUc,
  );
}