veilidchat/lib/account_manager/models/local_account/local_account.dart

46 lines
1.6 KiB
Dart
Raw Normal View History

2023-12-26 20:26:54 -05:00
import 'dart:typed_data';
import 'package:freezed_annotation/freezed_annotation.dart';
2023-12-27 22:56:24 -05:00
import 'package:veilid_support/veilid_support.dart';
2023-12-26 20:26:54 -05:00
2024-01-04 22:29:43 -05:00
import '../../models/encryption_key_type.dart';
2023-12-26 20:26:54 -05:00
part 'local_account.g.dart';
part 'local_account.freezed.dart';
// Local Accounts are stored in a table locally and not backed by a DHT key
// and represents the accounts that have been added/imported
// on the current device.
2024-06-07 14:42:04 -04:00
// Stores a copy of the most recent SuperIdentity associated with the account
2023-12-26 20:26:54 -05:00
// and the identitySecretKey optionally encrypted by an unlock code
// This is the root of the account information tree for VeilidChat
//
@freezed
class LocalAccount with _$LocalAccount {
const factory LocalAccount({
2024-06-07 14:42:04 -04:00
// The super identity key record for the account,
// containing the publicKey in the currentIdentity
required SuperIdentity superIdentity,
// The encrypted currentIdentity secret that goes with
2023-12-26 20:26:54 -05:00
// the identityPublicKey with appended salt
@Uint8ListJsonConverter() required Uint8List identitySecretBytes,
2024-06-07 14:42:04 -04:00
2023-12-26 20:26:54 -05:00
// The kind of encryption input used on the account
required EncryptionKeyType encryptionKeyType,
2024-06-07 14:42:04 -04:00
2023-12-26 20:26:54 -05:00
// If account is not hidden, password can be retrieved via
required bool biometricsEnabled,
2024-06-07 14:42:04 -04:00
2023-12-26 20:26:54 -05:00
// Keep account hidden unless account password is entered
// (tries all hidden accounts with auth method (no biometrics))
required bool hiddenAccount,
2024-06-07 14:42:04 -04:00
2023-12-26 20:26:54 -05:00
// Display name for account until it is unlocked
required String name,
}) = _LocalAccount;
factory LocalAccount.fromJson(dynamic json) =>
_$LocalAccountFromJson(json as Map<String, dynamic>);
}