account identity

This commit is contained in:
Christien Rioux 2023-07-04 22:48:34 -05:00
parent 0bc9dc3ad4
commit e1a1baf4b1
3 changed files with 95 additions and 7 deletions

29
lib/entities/account.dart Normal file
View File

@ -0,0 +1,29 @@
import 'package:flutter/widgets.dart';
import 'profile.dart';
import 'identity.dart';
@immutable
class Account {
final Profile profile;
final Identity identity;
const Account({required this.profile, required this.identity});
Account copyWith({Profile? profile, Identity? identity}) {
return Account(
profile: profile ?? this.profile,
identity: identity ?? this.identity,
);
}
Account.fromJson(Map<String, dynamic> json)
: profile = Profile.fromJson(json['profile']),
identity = Identity.fromJson(json['identity']);
Map<String, dynamic> toJson() {
return {
'profile': profile.toJson(),
'identity': identity.toJson(),
};
}
}

View File

@ -0,0 +1,45 @@
import 'package:flutter/widgets.dart';
import 'package:veilid/veilid.dart';
@immutable
class Identity {
final TypedKey identityPublicKey;
final TypedKey masterPublicKey;
final Signature identitySignature;
final Signature masterSignature;
const Identity(
{required this.identityPublicKey,
required this.masterPublicKey,
required this.identitySignature,
required this.masterSignature});
// Todo with slightly different content.
Identity copyWith(
{TypedKey? identityPublicKey,
TypedKey? masterPublicKey,
Signature? identitySignature,
Signature? masterSignature}) {
return Identity(
identityPublicKey: identityPublicKey ?? this.identityPublicKey,
masterPublicKey: masterPublicKey ?? this.masterPublicKey,
identitySignature: identitySignature ?? this.identitySignature,
masterSignature: masterSignature ?? this.masterSignature,
);
}
Identity.fromJson(Map<String, dynamic> json)
: identityPublicKey = TypedKey.fromJson(json['identity_public_key']),
masterPublicKey = TypedKey.fromJson(json['master_public_key']),
identitySignature = Signature.fromJson(json['identity_signature']),
masterSignature = Signature.fromJson(json['master_signature']);
Map<String, dynamic> toJson() {
return {
'identity_public_key': identityPublicKey.toJson(),
'master_public_key': masterPublicKey.toJson(),
'identity_signature': identitySignature.toJson(),
'master_signature': masterSignature.toJson(),
};
}
}

View File

@ -1,19 +1,33 @@
class Profile {
String name;
String publicKey;
bool invisible;
import 'package:flutter/widgets.dart';
import 'package:veilid/veilid.dart';
Profile(this.name, this.publicKey) : invisible = false;
@immutable
class Profile {
final String name;
final TypedKey publicKey;
final bool invisible;
const Profile(
{required this.name, required this.publicKey, required this.invisible});
// Todo with slightly different content.
Profile copyWith({String? name, TypedKey? publicKey, bool? invisible}) {
return Profile(
name: name ?? this.name,
publicKey: publicKey ?? this.publicKey,
invisible: invisible ?? this.invisible,
);
}
Profile.fromJson(Map<String, dynamic> json)
: name = json['name'],
publicKey = json['public_key'],
publicKey = TypedKey.fromJson(json['public_key']),
invisible = json['invisible'];
Map<String, dynamic> toJson() {
return {
'name': name,
'public_key': publicKey,
'public_key': publicKey.toJson(),
'invisible': invisible,
};
}