SecureBankKit.initialize constructor

SecureBankKit.initialize({
  1. bool enableRootDetection = true,
  2. bool enablePinning = false,
  3. bool enableAppIntegrity = true,
  4. bool enableEmulatorDetection = true,
  5. bool enableScreenRecordingDetection = false,
  6. bool enableTamperDetection = true,
  7. bool enableRuntimeProtection = true,
  8. bool enableLogging = false,
  9. 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 enableEmulatorDetection = true,
  bool enableScreenRecordingDetection = false,
  bool enableTamperDetection = true,
  bool enableRuntimeProtection = 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);
  final emulatorDs       = EmulatorDetectionDatasource(channel);
  final recordingDs      = ScreenRecordingDatasource(channel);
  final tamperDs         = TamperDetectionDatasource(channel);
  final runtimeDs        = RuntimeProtectionDatasource(channel);

  // Repositories
  final certRepo         = CertificatePinningRepositoryImpl(certDs);
  final rootRepo         = RootDetectionRepositoryImpl(rootDs);
  final screenshotRepo   = ScreenshotProtectionRepositoryImpl(screenshotDs);
  final integrityRepo    = AppIntegrityRepositoryImpl(integrityDs);
  final storageRepo      = SecureStorageRepositoryImpl(storageDs);
  final emulatorRepo     = EmulatorDetectionRepositoryImpl(emulatorDs);
  final recordingRepo    = ScreenRecordingRepositoryImpl(recordingDs);
  final tamperRepo       = TamperDetectionRepositoryImpl(tamperDs);
  final runtimeRepo      = RuntimeProtectionRepositoryImpl(runtimeDs);

  // Use cases
  final checkRoot        = CheckRootStatusUseCase(rootRepo);
  final validateCert     = ValidateCertificateUseCase(certRepo);
  final checkIntegrity   = CheckAppIntegrityUseCase(integrityRepo);
  final toggleScreenshot = ToggleScreenshotProtectionUseCase(screenshotRepo);
  final secureStorageUc  = SecureStorageUseCase(storageRepo);
  final checkEmulator    = CheckEmulatorUseCase(emulatorRepo);
  final checkRecording   = CheckScreenRecordingUseCase(recordingRepo);
  final checkTamper      = CheckTamperUseCase(tamperRepo);
  final checkRuntime     = CheckRuntimeProtectionUseCase(runtimeRepo);

  SecurityLogger.info('SecureBankKit initialized');

  return SecureBankKit._(
    enableRootDetection: enableRootDetection,
    enablePinning: enablePinning,
    enableAppIntegrity: enableAppIntegrity,
    enableEmulatorDetection: enableEmulatorDetection,
    enableScreenRecordingDetection: enableScreenRecordingDetection,
    enableTamperDetection: enableTamperDetection,
    enableRuntimeProtection: enableRuntimeProtection,
    certificatePins: certificatePins,
    checkRoot: checkRoot,
    validateCertificate: validateCert,
    checkAppIntegrity: checkIntegrity,
    checkEmulator: checkEmulator,
    checkScreenRecording: checkRecording,
    checkTamper: checkTamper,
    checkRuntimeProtection: checkRuntime,
    toggleScreenshot: toggleScreenshot,
    secureStorageUseCase: secureStorageUc,
  );
}