// SPDX-FileCopyrightText: 2026 FocusFlow contributors // SPDX-License-Identifier: AGPL-3.0-only /// Implements Encrypted Backup behavior for the Scheduler Backup package. library; import 'dart:convert'; import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; import 'package:cryptography/cryptography.dart'; part 'encrypted_backup/errors/backup_decryption_exception.dart'; part 'encrypted_backup/codec/backup_encryption_codec.dart'; part 'encrypted_backup/errors/backup_exception.dart'; part 'encrypted_backup/paths/backup_file_names.dart'; part 'encrypted_backup/paths/backup_paths.dart'; part 'encrypted_backup/operations/encrypted_backup_operations.dart'; /// Default scheduler data directory name under the user's home directory. const defaultSchedulerDirectoryName = 'ADHD_Scheduler'; /// Default SQLite database file name used by local scheduler persistence. const defaultSchedulerDatabaseFileName = 'scheduler.sqlite'; /// Default encrypted backup directory name under the scheduler data directory. const defaultSchedulerBackupDirectoryName = 'backups'; /// Private file-level value for `_formatMagic`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. const _formatMagic = 'ADHD_SCHEDULER_BACKUP_V1'; /// Private file-level value for `_fileExtension`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. const _fileExtension = '.db.enc'; /// Private file-level value for `_kdfIterations`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. const _kdfIterations = 200000; /// Private file-level value for `_saltLength`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. const _saltLength = 16; /// Private file-level value for `_nonceLength`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. const _nonceLength = 12; /// Private file-level value for `_keyLength`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. const _keyLength = 32; /// Private file-level value for `_utf8`. /// Keeping this value near the helpers that use it avoids hidden global configuration while still preventing duplicate literals. final _utf8 = utf8.encoder;