MfaClient class final

The single entry point for apps: enrol accounts, list them and produce codes, with secrets kept in the platform vault (FR-FAC-01).

This is the authenticator side. Verifying codes belongs on your server (TotpVerifier); see ADR-0002.

Secrets never leave the vault except transiently in memory to compute a code; they are wiped after use where Dart allows. Nothing here logs secrets, codes or URIs.

Properties

capabilities → Future<VaultCapabilities>
What this device's vault can provide; use it to offer protection levels.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

accounts() → Future<List<OtpAccount>>
All enrolled accounts, oldest first. Throws VaultCorrupted if the index cannot be read (recover with wipeAll or a backup).
checkIntegrity() → Future<IntegrityReport>
Runs the device integrity check again and applies the policy (FR-FAC-03), for example when the app returns to the foreground.
codeStream(String accountId, {BiometricPrompt? prompt}) → Stream<OtpCode>
Live codes of time-based account accountId (FR-FAC-02).
copyCode(String accountId) → Future<void>
Copies the current code of accountId with copySensitive (FR-FAC-05).
copySensitive(String text) → Future<void>
Copies text (a code or a setup key) marked sensitive where the platform supports it, and clears it after MfaClientOptions.clipboardExpiry (FR-FAC-05).
currentCode(String accountId, {BiometricPrompt? prompt}) → Future<OtpCode>
The current code of account accountId (UC3).
dispose() → Future<void>
Releases resources; the client cannot be used afterwards.
enrollFromUri(String otpauthUri, {ProtectionLevel protection = ProtectionLevel.standard}) → Future<OtpAccount>
Enrols the account described by an otpauth:// URI (UC1).
enrollManual({required String secretBase32, required String accountName, String? issuer, OtpType type = OtpType.totp, TotpConfig? totp, HotpConfig? hotp, int? counter, ProtectionLevel protection = ProtectionLevel.standard}) → Future<OtpAccount>
Enrols an account from a typed-in Base32 secret (UC2).
exportEncrypted(String passphrase, {Iterable<String>? accountIds}) → Future<Uint8List>
An encrypted backup of every account, or of accountIds only (FR-BAK-01, UC6).
importEncrypted(Uint8List data, String passphrase, {DuplicateStrategy onDuplicate = DuplicateStrategy.skip}) → Future<ImportReport>
Restores the accounts of a backup made by exportEncrypted on any platform (FR-BAK-03, UC7).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String accountId) → Future<void>
Deletes account accountId and its secret (UC8). Throws VaultNotFound if absent.
rename(String accountId, {String? issuer, String? accountName}) → Future<OtpAccount>
Changes the displayed issuer and/or accountName of an account. null leaves a field unchanged.
setScreenCaptureProtection(bool enabled) → Future<void>
Hides the app from screenshots, screen recording and the recent-apps preview while enabled (FR-FAC-06): Android FLAG_SECURE on the current activity, kept across activity re-creation.
toString() → String
A string representation of this object.
inherited
watchAccounts() → Stream<List<OtpAccount>>
The current accounts, then the new list after every change.
wipeAll() → Future<void>
Deletes every account and secret. Also the recovery path for a corrupted index.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

create({MfaClientOptions options = const MfaClientOptions()}) → Future<MfaClient>
Creates a client over MfaPlatform.instance.
createEnrollment({required String issuer, required String accountName, TotpConfig config = const TotpConfig(), AttemptLimiter? limiter}) → RelyingPartyEnrollment
Starts enrolling a user in TOTP on the relying-party side (FR-FAC-07).