diff --git a/lib/entities/dht.dart b/lib/entities/dht.dart new file mode 100644 index 0000000..f5609c7 --- /dev/null +++ b/lib/entities/dht.dart @@ -0,0 +1,28 @@ +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 'dht.freezed.dart'; +part 'dht.g.dart'; + +// Header in subkey 0 for Fixed DHT Data +// Subkeys 1..=stride on the first key are concatenated chunks +// Subkeys 0..stride on the 'keys' keys are concatenated chunks +@freezed +class DHTData with _$DHTData { + const factory DHTData({ + // Other keys to concatenate + required List keys, + // Total data size + required int size, + // Chunk size per subkey + required int chunk, + // Subkeys per key + required int stride, + }) = _DHTData; + factory DHTData.fromJson(Map json) => _$DHTData(json); +} diff --git a/lib/entities/entities.dart b/lib/entities/entities.dart index febd2c3..55c490a 100644 --- a/lib/entities/entities.dart +++ b/lib/entities/entities.dart @@ -27,8 +27,8 @@ class Messages with _$Messages { } // A record of a 1-1 chat that is synchronized between -// two users. Backed up on a DHT key. -// +// two users. Backed up on a DHT key. Visible and encrypted +// for the other party // // DHT Key (UnicastOutbox): conversationPublicKey // DHT Secret: conversationSecret @@ -53,11 +53,16 @@ class Conversation with _$Conversation { // Contains @freezed class Contact with _$Contact { - const factory Contact( - {required Profile remoteProfile, - required Profile localProfile, - required Identity identity, - required bool available}) = _Contact; + const factory Contact({ + // Profile as locally edited + required Profile localProfile, + // Profile from remote conversation + required Profile remoteProfile, + // Identity from remote conversation + required Identity identity, + // xxx + required bool available, + }) = _Contact; factory Contact.fromJson(Map json) => _$ContactFromJson(json); @@ -80,13 +85,15 @@ class Profile with _$Profile { required String title, // Status/away message required String status, - // Icon data (png 128x128x24bit) - required Uint8List icon, + // Icon DHTData + required TypedKey icon, }) = _Profile; factory Profile.fromJson(Map json) => _$ProfileFromJson(json); } +// A linked list of DHT subvalues + // A record of an individual account // DHT Key (Private): accountPublicKey // DHT Secret: accountSecretKey @@ -100,10 +107,7 @@ class Account with _$Account { // Auto-away sets 'away' mode after an inactivity time required autoAwayTimeoutSec, // The contacts for this account - required List, - - xxx investigate immutable FIC lists and their use with freezed/jsonserializable, switch them here - + required DHTListRef contacts, }) = _Account; factory Account.fromJson(Map json) =>