data model

This commit is contained in:
Christien Rioux 2023-07-06 22:52:02 -04:00
parent 4e91502f9e
commit 44a2761f87
13 changed files with 1103 additions and 139 deletions

3
build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
set -e
dart run build_runner build

View File

@ -1,29 +0,0 @@
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

@ -1,20 +0,0 @@
class Contact {
String name;
String publicKey;
bool available;
Contact(this.name, this.publicKey) : available = false;
Contact.fromJson(Map<String, dynamic> json)
: name = json['name'],
publicKey = json['public_key'],
available = json['available'];
Map<String, dynamic> toJson() {
return {
'name': name,
'public_key': publicKey,
'available': available,
};
}
}

245
lib/entities/entities.dart Normal file
View File

@ -0,0 +1,245 @@
import 'dart:typed_data';
import 'package:change_case/change_case.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:uuid/uuid.dart';
import 'package:veilid/veilid.dart';
part 'entities.freezed.dart';
part 'entities.g.dart';
// A record of a chunk of messages as reconciled from a conversation
//
// DHT Key (Private): messagesKey
// DHT Secret: messagesSecret
// Encryption: Symmetric(messagesSecret)
@freezed
class Messages with _$Messages {
const factory Messages(
{required Profile profile,
required Identity identity,
required bool available}) = _Messages;
factory Messages.fromJson(Map<String, dynamic> json) =>
_$MessagesFromJson(json);
}
// A record of a 1-1 chat that is synchronized between
// two users. Backed up on a DHT key.
//
//
// DHT Key (UnicastOutbox): conversationPublicKey
// DHT Secret: conversationSecret
// Encryption: DH(IdentityA, IdentityB)
@freezed
class Conversation with _$Conversation {
const factory Conversation(
{required Profile profile,
required Identity identity,
required bool available}) = _Contact;
factory Conversation.fromJson(Map<String, dynamic> json) =>
_$ConversationFromJson(json);
}
// A record of a contact that has accepted a contact invitation
// Contains a copy of the most recent remote profile as well as
// a locally edited profile.
// Contains a copy of the most recent identity from the contact's
// Master identity dht key
// Contains
@freezed
class Contact with _$Contact {
const factory Contact(
{required Profile remoteProfile,
required Profile localProfile,
required Identity identity,
required bool available}) = _Contact;
factory Contact.fromJson(Map<String, dynamic> json) =>
_$ContactFromJson(json);
}
// Publicly shared profile information for both contacts and accounts
// Contains:
// Name - Friendly name
// Title - Title of user
// Icon - Little picture to represent user in contact list
//
// DHT Key: None
// Encryption: None
@freezed
class Profile with _$Profile {
const factory Profile({
// Friendy name
required String name,
// Title of user
required String title,
// Status/away message
required String status,
// Icon data (png 128x128x24bit)
required Uint8List icon,
}) = _Profile;
factory Profile.fromJson(Map<String, dynamic> json) =>
_$ProfileFromJson(json);
}
// A record of an individual account
// DHT Key (Private): accountPublicKey
// DHT Secret: accountSecretKey
@freezed
class Account with _$Account {
const factory Account({
// The user's profile that gets shared with contacts
required Profile profile,
// Invisibility makes you always look 'Offline'
required bool invisible,
// Auto-away sets 'away' mode after an inactivity time
required autoAwayTimeoutSec,
// The contacts for this account
required List<Contact>,
xxx investigate immutable FIC lists and their use with freezed/jsonserializable, switch them here
}) = _Account;
factory Account.fromJson(Map<String, dynamic> json) =>
_$AccountFromJson(json);
}
// Identity Key points to accounts associated with this identity
// accounts field has a map of service name or uuid to account key pairs
// DHT Key (Private): identityPublicKey
// DHT Secret: identitySecretKey (stored encrypted with unlock code in local table store)
@freezed
class Identity with _$Identity {
const factory Identity({
// Top level account data key
required TypedKey accountPublicKey,
// Top level account data secret
required SecretKey accountSecretKey,
}) = _Identity;
factory Identity.fromJson(Map<String, dynamic> json) =>
_$IdentityFromJson(json);
}
// Identity Master key structure for created account
// Master key allows for regeneration of identity DHT record
// Bidirectional Master<->Identity signature allows for
// chain of identity ownership for account recovery process
//
// Backed by a DHT key at masterPublicKey, the secret is kept
// completely offline and only written to upon account recovery
//
// DHT Key (Public): masterPublicKey
// DHT Secret: masterSecretKey (kept offline)
// Encryption: None
@freezed
class IdentityMaster with _$IdentityMaster {
const factory IdentityMaster(
{required TypedKey identityPublicKey,
required TypedKey masterPublicKey,
required Signature identitySignature,
required Signature masterSignature}) = _IdentityMaster;
factory IdentityMaster.fromJson(Map<String, dynamic> json) =>
_$IdentityMasterFromJson(json);
}
// Local account identitySecretKey is potentially encrypted with a key
// using the following mechanisms
// * None : no key, bytes are unencrypted
// * Pin : Code is a numeric pin (4-256 numeric digits) hashed with Argon2
// * Password: Code is a UTF-8 string that is hashed with Argon2
enum EncryptionKeyType {
none,
pin,
password;
String toJson() => name.toPascalCase();
factory EncryptionKeyType.fromJson(String j) =>
EncryptionKeyType.values.byName(j.toCamelCase());
}
// 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.
// Stores a copy of the IdentityMaster associated with the account
// 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({
// The master key record for the account, containing the identityPublicKey
required IdentityMaster identityMaster,
// The encrypted identity secret that goes with the identityPublicKey
required Uint8List identitySecretKeyBytes,
// The kind of encryption input used on the account
required EncryptionKeyType encryptionKeyType,
// If account is not hidden, password can be retrieved via
required bool biometricsEnabled,
// Keep account hidden unless account password is entered
// (tries all hidden accounts with auth method (no biometrics))
required bool hiddenAccount,
}) = _LocalAccount;
factory LocalAccount.fromJson(Map<String, dynamic> json) =>
_$LocalAccountFromJson(json);
}
// Each theme supports light and dark mode, optionally selected by the
// operating system
enum DarkModePreference {
system,
light,
dark;
String toJson() => name.toPascalCase();
factory DarkModePreference.fromJson(String j) =>
DarkModePreference.values.byName(j.toCamelCase());
}
// Lock preference changes how frequently the messenger locks its
// interface and requires the identitySecretKey to be entered (pin/password/etc)
@freezed
class LockPreference with _$LockPreference {
const factory LockPreference({
required int inactivityLockSecs,
required bool lockWhenSwitching,
required bool lockWithSystemLock,
}) = _LockPreference;
factory LockPreference.fromJson(Map<String, dynamic> json) =>
_$LockPreferenceFromJson(json);
}
// Preferences are stored in a table locally and globally affect all
// accounts imported/added and the app in general
@freezed
class Preferences with _$Preferences {
const factory Preferences({
required DarkModePreference darkMode,
required Uuid activeTheme,
required LockPreference locking,
}) = _Preferences;
factory Preferences.fromJson(Map<String, dynamic> json) =>
_$PreferencesFromJson(json);
}
// Themes are stored in a table locally and referenced by their UUID
@freezed
class Theme with _$Theme {
const factory Theme({
required Uuid uuid,
required String name,
required Map<DarkModePreference, ThemeData> modeData,
}) = _Theme;
factory Theme.fromJson(Map<String, dynamic> json) => _$ThemeFromJson(json);
}

View File

@ -0,0 +1,739 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'entities.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
Account _$AccountFromJson(Map<String, dynamic> json) {
return _Account.fromJson(json);
}
/// @nodoc
mixin _$Account {
Profile get profile => throw _privateConstructorUsedError;
Identity get identity => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$AccountCopyWith<Account> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AccountCopyWith<$Res> {
factory $AccountCopyWith(Account value, $Res Function(Account) then) =
_$AccountCopyWithImpl<$Res, Account>;
@useResult
$Res call({Profile profile, Identity identity});
$ProfileCopyWith<$Res> get profile;
$IdentityCopyWith<$Res> get identity;
}
/// @nodoc
class _$AccountCopyWithImpl<$Res, $Val extends Account>
implements $AccountCopyWith<$Res> {
_$AccountCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profile = null,
Object? identity = null,
}) {
return _then(_value.copyWith(
profile: null == profile
? _value.profile
: profile // ignore: cast_nullable_to_non_nullable
as Profile,
identity: null == identity
? _value.identity
: identity // ignore: cast_nullable_to_non_nullable
as Identity,
) as $Val);
}
@override
@pragma('vm:prefer-inline')
$ProfileCopyWith<$Res> get profile {
return $ProfileCopyWith<$Res>(_value.profile, (value) {
return _then(_value.copyWith(profile: value) as $Val);
});
}
@override
@pragma('vm:prefer-inline')
$IdentityCopyWith<$Res> get identity {
return $IdentityCopyWith<$Res>(_value.identity, (value) {
return _then(_value.copyWith(identity: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$_AccountCopyWith<$Res> implements $AccountCopyWith<$Res> {
factory _$$_AccountCopyWith(
_$_Account value, $Res Function(_$_Account) then) =
__$$_AccountCopyWithImpl<$Res>;
@override
@useResult
$Res call({Profile profile, Identity identity});
@override
$ProfileCopyWith<$Res> get profile;
@override
$IdentityCopyWith<$Res> get identity;
}
/// @nodoc
class __$$_AccountCopyWithImpl<$Res>
extends _$AccountCopyWithImpl<$Res, _$_Account>
implements _$$_AccountCopyWith<$Res> {
__$$_AccountCopyWithImpl(_$_Account _value, $Res Function(_$_Account) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profile = null,
Object? identity = null,
}) {
return _then(_$_Account(
profile: null == profile
? _value.profile
: profile // ignore: cast_nullable_to_non_nullable
as Profile,
identity: null == identity
? _value.identity
: identity // ignore: cast_nullable_to_non_nullable
as Identity,
));
}
}
/// @nodoc
@JsonSerializable()
class _$_Account implements _Account {
const _$_Account({required this.profile, required this.identity});
factory _$_Account.fromJson(Map<String, dynamic> json) =>
_$$_AccountFromJson(json);
@override
final Profile profile;
@override
final Identity identity;
@override
String toString() {
return 'Account(profile: $profile, identity: $identity)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Account &&
(identical(other.profile, profile) || other.profile == profile) &&
(identical(other.identity, identity) ||
other.identity == identity));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, profile, identity);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_AccountCopyWith<_$_Account> get copyWith =>
__$$_AccountCopyWithImpl<_$_Account>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$_AccountToJson(
this,
);
}
}
abstract class _Account implements Account {
const factory _Account(
{required final Profile profile,
required final Identity identity}) = _$_Account;
factory _Account.fromJson(Map<String, dynamic> json) = _$_Account.fromJson;
@override
Profile get profile;
@override
Identity get identity;
@override
@JsonKey(ignore: true)
_$$_AccountCopyWith<_$_Account> get copyWith =>
throw _privateConstructorUsedError;
}
Contact _$ContactFromJson(Map<String, dynamic> json) {
return _Contact.fromJson(json);
}
/// @nodoc
mixin _$Contact {
String get name => throw _privateConstructorUsedError;
Typed<FixedEncodedString43> get publicKey =>
throw _privateConstructorUsedError;
bool get available => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ContactCopyWith<Contact> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ContactCopyWith<$Res> {
factory $ContactCopyWith(Contact value, $Res Function(Contact) then) =
_$ContactCopyWithImpl<$Res, Contact>;
@useResult
$Res call(
{String name, Typed<FixedEncodedString43> publicKey, bool available});
}
/// @nodoc
class _$ContactCopyWithImpl<$Res, $Val extends Contact>
implements $ContactCopyWith<$Res> {
_$ContactCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? publicKey = null,
Object? available = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
publicKey: null == publicKey
? _value.publicKey
: publicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
available: null == available
? _value.available
: available // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$_ContactCopyWith<$Res> implements $ContactCopyWith<$Res> {
factory _$$_ContactCopyWith(
_$_Contact value, $Res Function(_$_Contact) then) =
__$$_ContactCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name, Typed<FixedEncodedString43> publicKey, bool available});
}
/// @nodoc
class __$$_ContactCopyWithImpl<$Res>
extends _$ContactCopyWithImpl<$Res, _$_Contact>
implements _$$_ContactCopyWith<$Res> {
__$$_ContactCopyWithImpl(_$_Contact _value, $Res Function(_$_Contact) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? publicKey = null,
Object? available = null,
}) {
return _then(_$_Contact(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
publicKey: null == publicKey
? _value.publicKey
: publicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
available: null == available
? _value.available
: available // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
@JsonSerializable()
class _$_Contact implements _Contact {
const _$_Contact(
{required this.name, required this.publicKey, required this.available});
factory _$_Contact.fromJson(Map<String, dynamic> json) =>
_$$_ContactFromJson(json);
@override
final String name;
@override
final Typed<FixedEncodedString43> publicKey;
@override
final bool available;
@override
String toString() {
return 'Contact(name: $name, publicKey: $publicKey, available: $available)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Contact &&
(identical(other.name, name) || other.name == name) &&
(identical(other.publicKey, publicKey) ||
other.publicKey == publicKey) &&
(identical(other.available, available) ||
other.available == available));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, name, publicKey, available);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ContactCopyWith<_$_Contact> get copyWith =>
__$$_ContactCopyWithImpl<_$_Contact>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$_ContactToJson(
this,
);
}
}
abstract class _Contact implements Contact {
const factory _Contact(
{required final String name,
required final Typed<FixedEncodedString43> publicKey,
required final bool available}) = _$_Contact;
factory _Contact.fromJson(Map<String, dynamic> json) = _$_Contact.fromJson;
@override
String get name;
@override
Typed<FixedEncodedString43> get publicKey;
@override
bool get available;
@override
@JsonKey(ignore: true)
_$$_ContactCopyWith<_$_Contact> get copyWith =>
throw _privateConstructorUsedError;
}
Identity _$IdentityFromJson(Map<String, dynamic> json) {
return _Identity.fromJson(json);
}
/// @nodoc
mixin _$Identity {
Typed<FixedEncodedString43> get identityPublicKey =>
throw _privateConstructorUsedError;
Typed<FixedEncodedString43> get masterPublicKey =>
throw _privateConstructorUsedError;
FixedEncodedString86 get identitySignature =>
throw _privateConstructorUsedError;
FixedEncodedString86 get masterSignature =>
throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$IdentityCopyWith<Identity> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $IdentityCopyWith<$Res> {
factory $IdentityCopyWith(Identity value, $Res Function(Identity) then) =
_$IdentityCopyWithImpl<$Res, Identity>;
@useResult
$Res call(
{Typed<FixedEncodedString43> identityPublicKey,
Typed<FixedEncodedString43> masterPublicKey,
FixedEncodedString86 identitySignature,
FixedEncodedString86 masterSignature});
}
/// @nodoc
class _$IdentityCopyWithImpl<$Res, $Val extends Identity>
implements $IdentityCopyWith<$Res> {
_$IdentityCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? identityPublicKey = null,
Object? masterPublicKey = null,
Object? identitySignature = null,
Object? masterSignature = null,
}) {
return _then(_value.copyWith(
identityPublicKey: null == identityPublicKey
? _value.identityPublicKey
: identityPublicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
masterPublicKey: null == masterPublicKey
? _value.masterPublicKey
: masterPublicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
identitySignature: null == identitySignature
? _value.identitySignature
: identitySignature // ignore: cast_nullable_to_non_nullable
as FixedEncodedString86,
masterSignature: null == masterSignature
? _value.masterSignature
: masterSignature // ignore: cast_nullable_to_non_nullable
as FixedEncodedString86,
) as $Val);
}
}
/// @nodoc
abstract class _$$_IdentityCopyWith<$Res> implements $IdentityCopyWith<$Res> {
factory _$$_IdentityCopyWith(
_$_Identity value, $Res Function(_$_Identity) then) =
__$$_IdentityCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{Typed<FixedEncodedString43> identityPublicKey,
Typed<FixedEncodedString43> masterPublicKey,
FixedEncodedString86 identitySignature,
FixedEncodedString86 masterSignature});
}
/// @nodoc
class __$$_IdentityCopyWithImpl<$Res>
extends _$IdentityCopyWithImpl<$Res, _$_Identity>
implements _$$_IdentityCopyWith<$Res> {
__$$_IdentityCopyWithImpl(
_$_Identity _value, $Res Function(_$_Identity) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? identityPublicKey = null,
Object? masterPublicKey = null,
Object? identitySignature = null,
Object? masterSignature = null,
}) {
return _then(_$_Identity(
identityPublicKey: null == identityPublicKey
? _value.identityPublicKey
: identityPublicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
masterPublicKey: null == masterPublicKey
? _value.masterPublicKey
: masterPublicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
identitySignature: null == identitySignature
? _value.identitySignature
: identitySignature // ignore: cast_nullable_to_non_nullable
as FixedEncodedString86,
masterSignature: null == masterSignature
? _value.masterSignature
: masterSignature // ignore: cast_nullable_to_non_nullable
as FixedEncodedString86,
));
}
}
/// @nodoc
@JsonSerializable()
class _$_Identity implements _Identity {
const _$_Identity(
{required this.identityPublicKey,
required this.masterPublicKey,
required this.identitySignature,
required this.masterSignature});
factory _$_Identity.fromJson(Map<String, dynamic> json) =>
_$$_IdentityFromJson(json);
@override
final Typed<FixedEncodedString43> identityPublicKey;
@override
final Typed<FixedEncodedString43> masterPublicKey;
@override
final FixedEncodedString86 identitySignature;
@override
final FixedEncodedString86 masterSignature;
@override
String toString() {
return 'Identity(identityPublicKey: $identityPublicKey, masterPublicKey: $masterPublicKey, identitySignature: $identitySignature, masterSignature: $masterSignature)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Identity &&
(identical(other.identityPublicKey, identityPublicKey) ||
other.identityPublicKey == identityPublicKey) &&
(identical(other.masterPublicKey, masterPublicKey) ||
other.masterPublicKey == masterPublicKey) &&
(identical(other.identitySignature, identitySignature) ||
other.identitySignature == identitySignature) &&
(identical(other.masterSignature, masterSignature) ||
other.masterSignature == masterSignature));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, identityPublicKey,
masterPublicKey, identitySignature, masterSignature);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_IdentityCopyWith<_$_Identity> get copyWith =>
__$$_IdentityCopyWithImpl<_$_Identity>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$_IdentityToJson(
this,
);
}
}
abstract class _Identity implements Identity {
const factory _Identity(
{required final Typed<FixedEncodedString43> identityPublicKey,
required final Typed<FixedEncodedString43> masterPublicKey,
required final FixedEncodedString86 identitySignature,
required final FixedEncodedString86 masterSignature}) = _$_Identity;
factory _Identity.fromJson(Map<String, dynamic> json) = _$_Identity.fromJson;
@override
Typed<FixedEncodedString43> get identityPublicKey;
@override
Typed<FixedEncodedString43> get masterPublicKey;
@override
FixedEncodedString86 get identitySignature;
@override
FixedEncodedString86 get masterSignature;
@override
@JsonKey(ignore: true)
_$$_IdentityCopyWith<_$_Identity> get copyWith =>
throw _privateConstructorUsedError;
}
Profile _$ProfileFromJson(Map<String, dynamic> json) {
return _Profile.fromJson(json);
}
/// @nodoc
mixin _$Profile {
String get name => throw _privateConstructorUsedError;
Typed<FixedEncodedString43> get publicKey =>
throw _privateConstructorUsedError;
bool get invisible => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ProfileCopyWith<Profile> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProfileCopyWith<$Res> {
factory $ProfileCopyWith(Profile value, $Res Function(Profile) then) =
_$ProfileCopyWithImpl<$Res, Profile>;
@useResult
$Res call(
{String name, Typed<FixedEncodedString43> publicKey, bool invisible});
}
/// @nodoc
class _$ProfileCopyWithImpl<$Res, $Val extends Profile>
implements $ProfileCopyWith<$Res> {
_$ProfileCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? publicKey = null,
Object? invisible = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
publicKey: null == publicKey
? _value.publicKey
: publicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
invisible: null == invisible
? _value.invisible
: invisible // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$_ProfileCopyWith<$Res> implements $ProfileCopyWith<$Res> {
factory _$$_ProfileCopyWith(
_$_Profile value, $Res Function(_$_Profile) then) =
__$$_ProfileCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name, Typed<FixedEncodedString43> publicKey, bool invisible});
}
/// @nodoc
class __$$_ProfileCopyWithImpl<$Res>
extends _$ProfileCopyWithImpl<$Res, _$_Profile>
implements _$$_ProfileCopyWith<$Res> {
__$$_ProfileCopyWithImpl(_$_Profile _value, $Res Function(_$_Profile) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? publicKey = null,
Object? invisible = null,
}) {
return _then(_$_Profile(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
publicKey: null == publicKey
? _value.publicKey
: publicKey // ignore: cast_nullable_to_non_nullable
as Typed<FixedEncodedString43>,
invisible: null == invisible
? _value.invisible
: invisible // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
@JsonSerializable()
class _$_Profile implements _Profile {
const _$_Profile(
{required this.name, required this.publicKey, required this.invisible});
factory _$_Profile.fromJson(Map<String, dynamic> json) =>
_$$_ProfileFromJson(json);
@override
final String name;
@override
final Typed<FixedEncodedString43> publicKey;
@override
final bool invisible;
@override
String toString() {
return 'Profile(name: $name, publicKey: $publicKey, invisible: $invisible)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Profile &&
(identical(other.name, name) || other.name == name) &&
(identical(other.publicKey, publicKey) ||
other.publicKey == publicKey) &&
(identical(other.invisible, invisible) ||
other.invisible == invisible));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, name, publicKey, invisible);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ProfileCopyWith<_$_Profile> get copyWith =>
__$$_ProfileCopyWithImpl<_$_Profile>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$_ProfileToJson(
this,
);
}
}
abstract class _Profile implements Profile {
const factory _Profile(
{required final String name,
required final Typed<FixedEncodedString43> publicKey,
required final bool invisible}) = _$_Profile;
factory _Profile.fromJson(Map<String, dynamic> json) = _$_Profile.fromJson;
@override
String get name;
@override
Typed<FixedEncodedString43> get publicKey;
@override
bool get invisible;
@override
@JsonKey(ignore: true)
_$$_ProfileCopyWith<_$_Profile> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -0,0 +1,62 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'entities.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_Account _$$_AccountFromJson(Map<String, dynamic> json) => _$_Account(
profile: Profile.fromJson(json['profile'] as Map<String, dynamic>),
identity: Identity.fromJson(json['identity'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_AccountToJson(_$_Account instance) =>
<String, dynamic>{
'profile': instance.profile.toJson(),
'identity': instance.identity.toJson(),
};
_$_Contact _$$_ContactFromJson(Map<String, dynamic> json) => _$_Contact(
name: json['name'] as String,
publicKey: Typed<FixedEncodedString43>.fromJson(json['public_key']),
available: json['available'] as bool,
);
Map<String, dynamic> _$$_ContactToJson(_$_Contact instance) =>
<String, dynamic>{
'name': instance.name,
'public_key': instance.publicKey.toJson(),
'available': instance.available,
};
_$_Identity _$$_IdentityFromJson(Map<String, dynamic> json) => _$_Identity(
identityPublicKey:
Typed<FixedEncodedString43>.fromJson(json['identity_public_key']),
masterPublicKey:
Typed<FixedEncodedString43>.fromJson(json['master_public_key']),
identitySignature:
FixedEncodedString86.fromJson(json['identity_signature']),
masterSignature: FixedEncodedString86.fromJson(json['master_signature']),
);
Map<String, dynamic> _$$_IdentityToJson(_$_Identity instance) =>
<String, dynamic>{
'identity_public_key': instance.identityPublicKey.toJson(),
'master_public_key': instance.masterPublicKey.toJson(),
'identity_signature': instance.identitySignature.toJson(),
'master_signature': instance.masterSignature.toJson(),
};
_$_Profile _$$_ProfileFromJson(Map<String, dynamic> json) => _$_Profile(
name: json['name'] as String,
publicKey: Typed<FixedEncodedString43>.fromJson(json['public_key']),
invisible: json['invisible'] as bool,
);
Map<String, dynamic> _$$_ProfileToJson(_$_Profile instance) =>
<String, dynamic>{
'name': instance.name,
'public_key': instance.publicKey.toJson(),
'invisible': instance.invisible,
};

View File

@ -1,45 +0,0 @@
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,34 +0,0 @@
import 'package:flutter/widgets.dart';
import 'package:veilid/veilid.dart';
@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 = TypedKey.fromJson(json['public_key']),
invisible = json['invisible'];
Map<String, dynamic> toJson() {
return {
'name': name,
'public_key': publicKey.toJson(),
'invisible': invisible,
};
}
}

View File

@ -17,7 +17,7 @@ Future<String> getVeilidVersion() async {
// Call only once.
void _initVeilid() {
if (kIsWeb) {
var platformConfig = VeilidWASMConfig(
var platformConfig = const VeilidWASMConfig(
logging: VeilidWASMConfigLogging(
performance: VeilidWASMConfigLoggingPerformance(
enabled: true,
@ -28,7 +28,7 @@ void _initVeilid() {
enabled: true, level: VeilidConfigLogLevel.info)));
Veilid.instance.initializeVeilidCore(platformConfig.toJson());
} else {
var platformConfig = VeilidFFIConfig(
var platformConfig = const VeilidFFIConfig(
logging: VeilidFFIConfigLogging(
terminal: VeilidFFIConfigLoggingTerminal(
enabled: false,

View File

@ -60,7 +60,7 @@ class Processor {
// Set connection meter and ui state for connection state
var cs = ConnectionState.detached;
var checkPublicInternet = false;
switch (updateAttachment.state.state) {
switch (updateAttachment.state) {
case AttachmentState.detached:
cs = ConnectionState.detached;
break;
@ -92,7 +92,7 @@ class Processor {
break;
}
if (checkPublicInternet) {
if (!updateAttachment.state.publicInternetReady) {
if (!updateAttachment.publicInternetReady) {
cs = ConnectionState.attaching;
}
}

View File

@ -130,7 +130,7 @@ packages:
source: hosted
version: "8.6.1"
change_case:
dependency: transitive
dependency: "direct main"
description:
name: change_case
sha256: f4e08feaa845e75e4f5ad2b0e15f24813d7ea6c27e7b78252f0c17f752cf1157
@ -249,6 +249,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.2"
equatable:
dependency: "direct main"
description:
name: equatable
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
url: "https://pub.dev"
source: hosted
version: "2.0.5"
fake_async:
dependency: transitive
description:
@ -336,8 +344,16 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
freezed:
dependency: "direct dev"
description:
name: freezed
sha256: a9520490532087cf38bf3f7de478ab6ebeb5f68bb1eb2641546d92719b224445
url: "https://pub.dev"
source: hosted
version: "2.3.5"
freezed_annotation:
dependency: transitive
dependency: "direct main"
description:
name: freezed_annotation
sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338
@ -372,10 +388,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "1531542666c2d052c44bbf6e2b48011bf3771da0404b94c60eabec1228a62906"
sha256: df5bc28ec7d2e2a82ece59fb33b3a0f3b3eaaae386bf32040f92339820d954b6
url: "https://pub.dev"
source: hosted
version: "9.0.0"
version: "9.0.1"
graphs:
dependency: transitive
description:
@ -425,13 +441,21 @@ packages:
source: hosted
version: "0.6.7"
json_annotation:
dependency: transitive
dependency: "direct main"
description:
name: json_annotation
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
url: "https://pub.dev"
source: hosted
version: "4.8.1"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969
url: "https://pub.dev"
source: hosted
version: "6.7.1"
lints:
dependency: transitive
description:
@ -725,6 +749,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd"
url: "https://pub.dev"
source: hosted
version: "1.3.4"
source_span:
dependency: transitive
description:

View File

@ -27,13 +27,19 @@ dependencies:
shared_preferences: ^2.0.15
go_router: ^9.0.0
fast_immutable_collections: ^9.1.5
freezed_annotation: ^2.2.0
json_annotation: ^4.8.1
equatable: ^2.0.5
change_case: ^1.1.0
dev_dependencies:
flutter_test:
sdk: flutter
build_runner:
flutter_lints: ^2.0.1
build_runner: ^2.4.6
freezed: ^2.3.5
json_serializable: ^6.7.1
riverpod_generator: ^2.2.3
flutter_lints: ^2.0.0
flutter:

5
run.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
./build.sh
flutter run $@