checkpoint

This commit is contained in:
Christien Rioux 2024-02-12 09:10:07 -05:00
parent a6ba08255b
commit 9dd17cb077
11 changed files with 80 additions and 85 deletions

View file

@ -74,9 +74,7 @@ class ChatComponent extends StatelessWidget {
);
final editedName = conversation.contact.editedProfile.name;
final remoteUser = types.User(
id: proto.TypedKeyProto.fromProto(
conversation.contact.identityPublicKey)
.toString(),
id: conversation.contact.identityPublicKey.toVeilid().toString(),
firstName: editedName);
// Get the messages to display

View file

@ -91,14 +91,17 @@ class ActiveConversationMessagesCubit extends BlocMapCubit<TypedKey,
required proto.Conversation localConversation,
required proto.Conversation remoteConversation}) async =>
add(() => MapEntry(
proto.TypedKeyProto.fromProto(contact.remoteConversationRecordKey),
contact.remoteConversationRecordKey.toVeilid(),
MessagesCubit(
activeAccountInfo: _activeAccountInfo,
remoteIdentityPublicKey: contact.identityPublicKey,
localConversationRecordKey: contact.localConversationRecordKey,
remoteConversationRecordKey: contact.remoteConversationRecordKey,
localMessagesRecordKey: localConversation.messages,
remoteMessagesRecordKey: remoteConversation.messages)));
remoteIdentityPublicKey: contact.identityPublicKey.toVeilid(),
localConversationRecordKey:
contact.localConversationRecordKey.toVeilid(),
remoteConversationRecordKey:
contact.remoteConversationRecordKey.toVeilid(),
localMessagesRecordKey: localConversation.messages.toVeilid(),
remoteMessagesRecordKey:
remoteConversation.messages.toVeilid())));
////

View file

@ -23,8 +23,7 @@ class ChatListCubit extends DHTShortArrayCubit<proto.Chat> {
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
final chatListRecordKey =
proto.OwnedDHTRecordPointerProto.fromProto(account.chatList);
final chatListRecordKey = account.chatList.toVeilid();
final dhtRecord = await DHTShortArray.openOwned(chatListRecordKey,
parent: accountRecordKey);

View file

@ -26,7 +26,7 @@ class ChatSingleContactItemWidget extends StatelessWidget {
final activeChatCubit = context.watch<ActiveChatCubit>();
final remoteConversationRecordKey =
proto.TypedKeyProto.fromProto(_contact.remoteConversationRecordKey);
_contact.remoteConversationRecordKey.toVeilid();
final selected = activeChatCubit.state == remoteConversationRecordKey;
return Container(

View file

@ -50,8 +50,7 @@ class ContactInvitationListCubit
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
final contactInvitationListRecordKey =
proto.OwnedDHTRecordPointerProto.fromProto(
account.contactInvitationRecords);
account.contactInvitationRecords.toVeilid();
final dhtRecord = await DHTShortArray.openOwned(
contactInvitationListRecordKey,
@ -175,8 +174,7 @@ class ContactInvitationListCubit
}
}
await (await pool.openOwned(
proto.OwnedDHTRecordPointerProto.fromProto(
contactInvitationRecord.contactRequestInbox),
contactInvitationRecord.contactRequestInbox.toVeilid(),
parent: accountRecordKey))
.scope((contactRequestInbox) async {
// Wipe out old invitation so it shows up as invalid
@ -185,8 +183,7 @@ class ContactInvitationListCubit
});
if (!accepted) {
await (await pool.openRead(
proto.TypedKeyProto.fromProto(
contactInvitationRecord.localConversationRecordKey),
contactInvitationRecord.localConversationRecordKey.toVeilid(),
parent: accountRecordKey))
.delete();
}
@ -205,7 +202,7 @@ class ContactInvitationListCubit
final contactInvitation =
proto.ContactInvitation.fromBuffer(contactInvitationBytes);
final contactRequestInboxKey =
proto.TypedKeyProto.fromProto(contactInvitation.contactRequestInboxKey);
contactInvitation.contactRequestInboxKey.toVeilid();
ValidContactInvitation? out;
@ -216,7 +213,7 @@ class ContactInvitationListCubit
// If we're chatting to ourselves,
// we are validating an invitation we have created
final isSelf = state.data!.value.indexWhere((cir) =>
proto.TypedKeyProto.fromProto(cir.contactRequestInbox.recordKey) ==
cir.contactRequestInbox.recordKey.toVeilid() ==
contactRequestInboxKey) !=
-1;
@ -246,21 +243,20 @@ class ContactInvitationListCubit
final contactRequestPrivate =
proto.ContactRequestPrivate.fromBuffer(contactRequestPrivateBytes);
final contactIdentityMasterRecordKey = proto.TypedKeyProto.fromProto(
contactRequestPrivate.identityMasterRecordKey);
final contactIdentityMasterRecordKey =
contactRequestPrivate.identityMasterRecordKey.toVeilid();
// Fetch the account master
final contactIdentityMaster = await openIdentityMaster(
identityMasterRecordKey: contactIdentityMasterRecordKey);
// Verify
final signature = proto.SignatureProto.fromProto(
signedContactInvitation.identitySignature);
final signature = signedContactInvitation.identitySignature.toVeilid();
await cs.verify(contactIdentityMaster.identityPublicKey,
contactInvitationBytes, signature);
final writer = KeyPair(
key: proto.CryptoKeyProto.fromProto(contactRequestPrivate.writerKey),
key: contactRequestPrivate.writerKey.toVeilid(),
secret: writerSecret);
out = ValidContactInvitation(
@ -282,12 +278,10 @@ class ContactInvitationListCubit
final pool = DHTRecordPool.instance;
final accountRecordKey = _activeAccountInfo
.userLogin.accountRecordInfo.accountRecord.recordKey;
final writerKey =
proto.CryptoKeyProto.fromProto(contactInvitationRecord.writerKey);
final writerSecret =
proto.CryptoKeyProto.fromProto(contactInvitationRecord.writerSecret);
final recordKey = proto.TypedKeyProto.fromProto(
contactInvitationRecord.contactRequestInbox.recordKey);
final writerKey = contactInvitationRecord.writerKey.toVeilid();
final writerSecret = contactInvitationRecord.writerSecret.toVeilid();
final recordKey =
contactInvitationRecord.contactRequestInbox.recordKey.toVeilid();
final writer = TypedKeyPair(
kind: recordKey.kind, key: writerKey, secret: writerSecret);
final acceptReject = await (await pool.openRead(recordKey,
@ -307,8 +301,8 @@ class ContactInvitationListCubit
Uint8List.fromList(signedContactResponse.contactResponse);
final contactResponse =
proto.ContactResponse.fromBuffer(contactResponseBytes);
final contactIdentityMasterRecordKey = proto.TypedKeyProto.fromProto(
contactResponse.identityMasterRecordKey);
final contactIdentityMasterRecordKey =
contactResponse.identityMasterRecordKey.toVeilid();
final cs = await pool.veilid.getCryptoSystem(recordKey.kind);
// Fetch the remote contact's account master
@ -316,8 +310,7 @@ class ContactInvitationListCubit
identityMasterRecordKey: contactIdentityMasterRecordKey);
// Verify
final signature = proto.SignatureProto.fromProto(
signedContactResponse.identitySignature);
final signature = signedContactResponse.identitySignature.toVeilid();
await cs.verify(contactIdentityMaster.identityPublicKey,
contactResponseBytes, signature);
@ -327,8 +320,8 @@ class ContactInvitationListCubit
}
// Pull profile from remote conversation key
final remoteConversationRecordKey = proto.TypedKeyProto.fromProto(
contactResponse.remoteConversationRecordKey);
final remoteConversationRecordKey =
contactResponse.remoteConversationRecordKey.toVeilid();
final conversation = ConversationCubit(
activeAccountInfo: _activeAccountInfo,
@ -345,8 +338,8 @@ class ContactInvitationListCubit
}
// Complete the local conversation now that we have the remote profile
final localConversationRecordKey = proto.TypedKeyProto.fromProto(
contactInvitationRecord.localConversationRecordKey);
final localConversationRecordKey =
contactInvitationRecord.localConversationRecordKey.toVeilid();
return conversation.initLocalConversation(
existingConversationRecordKey: localConversationRecordKey,
profile: _account.profile,

View file

@ -80,8 +80,8 @@ class ValidContactInvitation {
return AcceptedContact(
remoteProfile: _contactRequestPrivate.profile,
remoteIdentity: _contactIdentityMaster,
remoteConversationRecordKey: proto.TypedKeyProto.fromProto(
_contactRequestPrivate.chatRecordKey),
remoteConversationRecordKey:
_contactRequestPrivate.chatRecordKey.toVeilid(),
localConversationRecordKey: localConversation.key,
);
});

View file

@ -24,8 +24,7 @@ class ContactListCubit extends DHTShortArrayCubit<proto.Contact> {
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
final contactListRecordKey =
proto.OwnedDHTRecordPointerProto.fromProto(account.contactList);
final contactListRecordKey = account.contactList.toVeilid();
final dhtRecord = await DHTShortArray.openOwned(contactListRecordKey,
parent: accountRecordKey);
@ -63,10 +62,9 @@ class ContactListCubit extends DHTShortArrayCubit<proto.Contact> {
final pool = DHTRecordPool.instance;
final accountRecordKey =
_activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
final localConversationKey =
proto.TypedKeyProto.fromProto(contact.localConversationRecordKey);
final localConversationKey = contact.localConversationRecordKey.toVeilid();
final remoteConversationKey =
proto.TypedKeyProto.fromProto(contact.remoteConversationRecordKey);
contact.remoteConversationRecordKey.toVeilid();
// Remove Contact from account's list
for (var i = 0; i < shortArray.length; i++) {

View file

@ -25,7 +25,7 @@ class ContactItemWidget extends StatelessWidget {
final scale = theme.extension<ScaleScheme>()!;
final remoteConversationKey =
proto.TypedKeyProto.fromProto(contact.remoteConversationRecordKey);
contact.remoteConversationRecordKey.toVeilid();
return Container(
margin: const EdgeInsets.fromLTRB(0, 4, 0, 0),