API Reference
API Reference
Section titled “API Reference”This section provides detailed documentation for Lumo’s core classes, methods, and utilities.
Core Classes
Section titled “Core Classes”OtpEntry
Section titled “OtpEntry”The main entity representing a single OTP account.
class OtpEntry { final String id; final String issuer; final String account; final String secret; final OtpAlgorithm algorithm; final int digits; final int interval; final OtpType type; final int? counter; final DateTime created; final DateTime? lastUsed;
// Generate OTP code for current time String generateOtp();
// Get remaining time in seconds (TOTP only) int getRemainingTime();
// Create a copy with modified fields OtpEntry copyWith({...});}OtpRepository
Section titled “OtpRepository”Interface for OTP data operations.
abstract class OtpRepository { Future<Either<Failure, List<OtpEntry>>> getAllOtpEntries(); Future<Either<Failure, void>> addOtpEntry(OtpEntry entry); Future<Either<Failure, void>> updateOtpEntry(OtpEntry entry); Future<Either<Failure, void>> deleteOtpEntry(String id); Future<Either<Failure, void>> clearAllOtpEntries();}Utility Classes
Section titled “Utility Classes”OtpUtils
Section titled “OtpUtils”Static methods for OTP generation and validation.
class OtpUtils { // Generate TOTP code static String generateTotp({ required String secret, required OtpAlgorithm algorithm, required int digits, required int interval, });
// Generate HOTP code static String generateHotp({ required String secret, required int counter, required OtpAlgorithm algorithm, required int digits, });
// Validate Base32 secret static bool isValidSecret(String secret);}OtpUriParser
Section titled “OtpUriParser”Parse and validate OTP URIs.
class OtpUriParser { // Check if URI is valid OTP format static bool isValidUri(String uri);
// Parse URI to OtpEntry static OtpEntry parseUri(String uri);
// Parse label component static Map<String, String> parseLabel(String label);}State Management
Section titled “State Management”Riverpod Providers
Section titled “Riverpod Providers”Key providers for state management.
// OTP list providerfinal otpListProvider = StateNotifierProvider<OtpListNotifier, AsyncValue<List<OtpEntry>>>();
// Settings providerfinal appSettingsProvider = StateNotifierProvider<AppSettingsNotifier, AsyncValue<SettingsEntity>>();
// Authentication providerfinal authStateProvider = StateNotifierProvider<AuthStateNotifier, AsyncValue<AuthStatus>>();Enums and Constants
Section titled “Enums and Constants”OtpType
Section titled “OtpType”enum OtpType { totp, // Time-based OTP hotp, // HMAC-based OTP}OtpAlgorithm
Section titled “OtpAlgorithm”enum OtpAlgorithm { sha1, sha256, sha512,}App Constants
Section titled “App Constants”class AppConstants { static const String appName = 'Lumo'; static const int defaultDigits = 6; static const int defaultInterval = 30; static const String defaultAlgorithm = 'SHA1';}For detailed implementation examples, see the Architecture Overview and Development Guide.