mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-06-06 21:58:49 -04:00
account identity
This commit is contained in:
parent
0bc9dc3ad4
commit
e1a1baf4b1
3 changed files with 95 additions and 7 deletions
29
lib/entities/account.dart
Normal file
29
lib/entities/account.dart
Normal 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(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
45
lib/entities/identity.dart
Normal file
45
lib/entities/identity.dart
Normal 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(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,33 @@
|
||||||
class Profile {
|
import 'package:flutter/widgets.dart';
|
||||||
String name;
|
import 'package:veilid/veilid.dart';
|
||||||
String publicKey;
|
|
||||||
bool invisible;
|
|
||||||
|
|
||||||
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)
|
Profile.fromJson(Map<String, dynamic> json)
|
||||||
: name = json['name'],
|
: name = json['name'],
|
||||||
publicKey = json['public_key'],
|
publicKey = TypedKey.fromJson(json['public_key']),
|
||||||
invisible = json['invisible'];
|
invisible = json['invisible'];
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'name': name,
|
'name': name,
|
||||||
'public_key': publicKey,
|
'public_key': publicKey.toJson(),
|
||||||
'invisible': invisible,
|
'invisible': invisible,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue