5️⃣ Backup
Backup data is no longer the recommended approach to perform account recovery, and the feature has been removed from Android and iOS SDKs. The recommended flow is using the temporary state. Follow the guide on account recovery.
Back up your user's data so you can restore their Keyless account when necessary.
Create a backup (not recommended)
Create backups after authentication, and push them into your backup system. Each backup is encrypted with aes-gcm using the backupKey as symmetric key. You need both backupData and backupKey to restore an account with Keyless.
import 'package:keyless_flutter_sdk/keyless.dart';
import 'package:keyless_flutter_sdk/models/configurations/authentication_configuration.dart';
// Retrieve temporary state during authentication
final configuration = BiomAuthConfig(shouldRetrieveTemporaryState: true);
try {
final result = await Keyless.instance.authenticate(configuration);
if (result.temporaryState != null) {
print("Temporary state retrieved successfully");
// Store temporaryState securely
}
} catch (error) {
print("Failed to retrieve temporary state: $error");
}Restore from a backup (not recommended)
Restore the user account by providing backupData and backupKey to the withBackup method:
import 'package:keyless_flutter_sdk/keyless.dart';
import 'package:keyless_flutter_sdk/models/configurations/enrollment_configuration.dart';
// Create enrollment configuration with backup
final configuration = BiomEnrollConfig(
backup: KeylessBackup(
data: backupData,
key: backupKey
)
);
try {
final result = await Keyless.instance.enroll(configuration);
print("Enrollment from backup successful");
} catch (error) {
print("Enrollment from backup failed: $error");
}Last updated
Was this helpful?