veilidchat/lib/providers/contact_invite.dart

566 lines
22 KiB
Dart
Raw Normal View History

2023-08-05 23:59:15 -04:00
import 'dart:typed_data';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:fixnum/fixnum.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../entities/local_account.dart';
2023-09-26 18:46:02 -04:00
import '../proto/proto.dart' as proto;
import '../proto/proto.dart'
2023-08-05 23:59:15 -04:00
show
ContactInvitation,
ContactInvitationRecord,
ContactRequest,
ContactRequestPrivate,
ContactResponse,
SignedContactInvitation,
SignedContactResponse;
import '../tools/tools.dart';
import '../veilid_support/veilid_support.dart';
import 'account.dart';
import 'conversation.dart';
part 'contact_invite.g.dart';
2023-09-24 22:35:54 -04:00
class ContactInviteInvalidKeyException implements Exception {
const ContactInviteInvalidKeyException(this.type) : super();
final EncryptionKeyType type;
}
2023-08-05 23:59:15 -04:00
class AcceptedContact {
AcceptedContact({
required this.profile,
required this.remoteIdentity,
2023-08-07 11:02:29 -04:00
required this.remoteConversationRecordKey,
required this.localConversationRecordKey,
2023-08-05 23:59:15 -04:00
});
proto.Profile profile;
IdentityMaster remoteIdentity;
2023-08-07 11:02:29 -04:00
TypedKey remoteConversationRecordKey;
TypedKey localConversationRecordKey;
2023-08-05 23:59:15 -04:00
}
class AcceptedOrRejectedContact {
AcceptedOrRejectedContact({required this.acceptedContact});
AcceptedContact? acceptedContact;
}
Future<AcceptedOrRejectedContact?> checkAcceptRejectContact(
{required ActiveAccountInfo activeAccountInfo,
required ContactInvitationRecord contactInvitationRecord}) async {
// Open the contact request inbox
try {
final pool = await DHTRecordPool.instance();
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
final writerKey =
proto.CryptoKeyProto.fromProto(contactInvitationRecord.writerKey);
final writerSecret =
proto.CryptoKeyProto.fromProto(contactInvitationRecord.writerSecret);
2023-09-26 18:46:02 -04:00
final recordKey = proto.TypedKeyProto.fromProto(
contactInvitationRecord.contactRequestInbox.recordKey);
2023-08-05 23:59:15 -04:00
final writer = TypedKeyPair(
2023-09-26 18:46:02 -04:00
kind: recordKey.kind, key: writerKey, secret: writerSecret);
final acceptReject = await (await pool.openRead(recordKey,
2023-08-05 23:59:15 -04:00
crypto: await DHTRecordCryptoPrivate.fromTypedKeyPair(writer),
parent: accountRecordKey,
defaultSubkey: 1))
.scope((contactRequestInbox) async {
//
final signedContactResponse = await contactRequestInbox
.getProtobuf(SignedContactResponse.fromBuffer, forceRefresh: true);
if (signedContactResponse == null) {
return null;
}
final contactResponseBytes =
Uint8List.fromList(signedContactResponse.contactResponse);
final contactResponse = ContactResponse.fromBuffer(contactResponseBytes);
final contactIdentityMasterRecordKey = proto.TypedKeyProto.fromProto(
contactResponse.identityMasterRecordKey);
2023-09-26 18:46:02 -04:00
final cs = await pool.veilid.getCryptoSystem(recordKey.kind);
2023-08-05 23:59:15 -04:00
// Fetch the remote contact's account master
final contactIdentityMaster = await openIdentityMaster(
identityMasterRecordKey: contactIdentityMasterRecordKey);
// Verify
final signature = proto.SignatureProto.fromProto(
signedContactResponse.identitySignature);
2023-08-06 15:33:40 -04:00
await cs.verify(contactIdentityMaster.identityPublicKey,
contactResponseBytes, signature);
2023-08-05 23:59:15 -04:00
2023-09-26 18:46:02 -04:00
// Check for rejection
if (!contactResponse.accept) {
return AcceptedOrRejectedContact(acceptedContact: null);
}
2023-08-05 23:59:15 -04:00
// Pull profile from remote conversation key
2023-08-07 11:02:29 -04:00
final remoteConversationRecordKey = proto.TypedKeyProto.fromProto(
contactResponse.remoteConversationRecordKey);
2023-08-05 23:59:15 -04:00
final remoteConversation = await readRemoteConversation(
activeAccountInfo: activeAccountInfo,
2023-08-06 15:33:40 -04:00
remoteIdentityPublicKey:
contactIdentityMaster.identityPublicTypedKey(),
2023-08-07 11:02:29 -04:00
remoteConversationRecordKey: remoteConversationRecordKey);
2023-08-05 23:59:15 -04:00
if (remoteConversation == null) {
2023-08-06 15:33:40 -04:00
log.info('Remote conversation could not be read. Waiting...');
2023-08-05 23:59:15 -04:00
return null;
}
2023-08-06 15:33:40 -04:00
// Complete the local conversation now that we have the remote profile
2023-08-07 11:02:29 -04:00
final localConversationRecordKey = proto.TypedKeyProto.fromProto(
contactInvitationRecord.localConversationRecordKey);
2023-08-06 15:33:40 -04:00
return createConversation(
activeAccountInfo: activeAccountInfo,
remoteIdentityPublicKey:
contactIdentityMaster.identityPublicTypedKey(),
2023-08-07 11:02:29 -04:00
existingConversationRecordKey: localConversationRecordKey,
2023-08-06 15:33:40 -04:00
// ignore: prefer_expression_function_bodies
callback: (localConversation) async {
return AcceptedOrRejectedContact(
acceptedContact: AcceptedContact(
profile: remoteConversation.profile,
remoteIdentity: contactIdentityMaster,
2023-08-07 11:02:29 -04:00
remoteConversationRecordKey: remoteConversationRecordKey,
localConversationRecordKey: localConversationRecordKey));
2023-08-06 15:33:40 -04:00
});
2023-08-05 23:59:15 -04:00
});
if (acceptReject == null) {
return null;
}
// Delete invitation and return the accepted or rejected contact
await deleteContactInvitation(
accepted: acceptReject.acceptedContact != null,
activeAccountInfo: activeAccountInfo,
contactInvitationRecord: contactInvitationRecord);
return acceptReject;
} on Exception catch (e) {
2023-09-28 12:51:44 -04:00
log.error('Exception in checkAcceptRejectContact: $e', e);
2023-08-06 15:33:40 -04:00
// Attempt to clean up. All this needs better lifetime management
await deleteContactInvitation(
accepted: false,
activeAccountInfo: activeAccountInfo,
contactInvitationRecord: contactInvitationRecord);
2023-09-25 22:59:28 -04:00
rethrow;
2023-08-05 23:59:15 -04:00
}
}
Future<void> deleteContactInvitation(
{required bool accepted,
required ActiveAccountInfo activeAccountInfo,
required ContactInvitationRecord contactInvitationRecord}) async {
final pool = await DHTRecordPool.instance();
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
// Remove ContactInvitationRecord from account's list
await (await DHTShortArray.openOwned(
proto.OwnedDHTRecordPointerProto.fromProto(
activeAccountInfo.account.contactInvitationRecords),
parent: accountRecordKey))
.scope((cirList) async {
for (var i = 0; i < cirList.length; i++) {
final item = await cirList.getItemProtobuf(
proto.ContactInvitationRecord.fromBuffer, i);
if (item == null) {
2023-08-06 15:33:40 -04:00
throw Exception('Failed to get contact invitation record');
2023-08-05 23:59:15 -04:00
}
if (item.contactRequestInbox.recordKey ==
contactInvitationRecord.contactRequestInbox.recordKey) {
await cirList.tryRemoveItem(i);
break;
}
}
await (await pool.openOwned(
proto.OwnedDHTRecordPointerProto.fromProto(
contactInvitationRecord.contactRequestInbox),
parent: accountRecordKey))
.scope((contactRequestInbox) async {
// Wipe out old invitation so it shows up as invalid
await contactRequestInbox.tryWriteBytes(Uint8List(0));
await contactRequestInbox.delete();
});
if (!accepted) {
2023-08-07 11:02:29 -04:00
await (await pool.openRead(
proto.TypedKeyProto.fromProto(
contactInvitationRecord.localConversationRecordKey),
2023-08-05 23:59:15 -04:00
parent: accountRecordKey))
.delete();
}
});
}
Future<Uint8List> createContactInvitation(
{required ActiveAccountInfo activeAccountInfo,
required EncryptionKeyType encryptionKeyType,
required String encryptionKey,
required String message,
required Timestamp? expiration}) async {
final pool = await DHTRecordPool.instance();
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
final identityKey =
activeAccountInfo.localAccount.identityMaster.identityPublicKey;
final identitySecret = activeAccountInfo.userLogin.identitySecret.value;
// Generate writer keypair to share with new contact
final cs = await pool.veilid.bestCryptoSystem();
2023-08-07 11:02:29 -04:00
final contactRequestWriter = await cs.generateKeyPair();
final conversationWriter =
getConversationWriter(activeAccountInfo: activeAccountInfo);
2023-08-05 23:59:15 -04:00
// Encrypt the writer secret with the encryption key
final encryptedSecret = await encryptSecretToBytes(
2023-08-07 11:02:29 -04:00
secret: contactRequestWriter.secret,
2023-08-05 23:59:15 -04:00
cryptoKind: cs.kind(),
encryptionKey: encryptionKey,
encryptionKeyType: encryptionKeyType);
// Create local chat DHT record with the account record key as its parent
// Do not set the encryption of this key yet as it will not yet be written
// to and it will be eventually encrypted with the DH of the contact's
// identity key
late final Uint8List signedContactInvitationBytes;
2023-08-07 11:02:29 -04:00
await (await pool.create(
parent: accountRecordKey,
schema: DHTSchema.smpl(oCnt: 0, members: [
DHTSchemaMember(mKey: conversationWriter.key, mCnt: 1)
])))
2023-08-05 23:59:15 -04:00
.deleteScope((localConversation) async {
2023-08-07 11:02:29 -04:00
// dont bother reopening localConversation with writer
2023-08-05 23:59:15 -04:00
// Make ContactRequestPrivate and encrypt with the writer secret
final crpriv = ContactRequestPrivate()
2023-08-07 11:02:29 -04:00
..writerKey = contactRequestWriter.key.toProto()
2023-08-05 23:59:15 -04:00
..profile = activeAccountInfo.account.profile
..identityMasterRecordKey =
activeAccountInfo.userLogin.accountMasterRecordKey.toProto()
..chatRecordKey = localConversation.key.toProto()
..expiration = expiration?.toInt64() ?? Int64.ZERO;
final crprivbytes = crpriv.writeToBuffer();
2023-09-24 22:35:54 -04:00
final encryptedContactRequestPrivate =
await cs.encryptAeadWithNonce(crprivbytes, contactRequestWriter.secret);
2023-08-05 23:59:15 -04:00
// Create ContactRequest and embed contactrequestprivate
final creq = ContactRequest()
..encryptionKeyType = encryptionKeyType.toProto()
..private = encryptedContactRequestPrivate;
// Create DHT unicast inbox for ContactRequest
await (await pool.create(
parent: accountRecordKey,
2023-08-07 11:02:29 -04:00
schema: DHTSchema.smpl(oCnt: 1, members: [
DHTSchemaMember(mCnt: 1, mKey: contactRequestWriter.key)
]),
2023-08-05 23:59:15 -04:00
crypto: const DHTRecordCryptoPublic()))
.deleteScope((contactRequestInbox) async {
// Store ContactRequest in owner subkey
await contactRequestInbox.eventualWriteProtobuf(creq);
// Create ContactInvitation and SignedContactInvitation
final cinv = ContactInvitation()
..contactRequestInboxKey = contactRequestInbox.key.toProto()
..writerSecret = encryptedSecret;
final cinvbytes = cinv.writeToBuffer();
final scinv = SignedContactInvitation()
..contactInvitation = cinvbytes
..identitySignature =
(await cs.sign(identityKey, identitySecret, cinvbytes)).toProto();
signedContactInvitationBytes = scinv.writeToBuffer();
// Create ContactInvitationRecord
final cinvrec = ContactInvitationRecord()
..contactRequestInbox =
contactRequestInbox.ownedDHTRecordPointer.toProto()
2023-08-07 11:02:29 -04:00
..writerKey = contactRequestWriter.key.toProto()
..writerSecret = contactRequestWriter.secret.toProto()
..localConversationRecordKey = localConversation.key.toProto()
2023-08-05 23:59:15 -04:00
..expiration = expiration?.toInt64() ?? Int64.ZERO
..invitation = signedContactInvitationBytes
..message = message;
// Add ContactInvitationRecord to account's list
// if this fails, don't keep retrying, user can try again later
await (await DHTShortArray.openOwned(
proto.OwnedDHTRecordPointerProto.fromProto(
activeAccountInfo.account.contactInvitationRecords),
parent: accountRecordKey))
.scope((cirList) async {
if (await cirList.tryAddItem(cinvrec.writeToBuffer()) == false) {
2023-08-06 15:33:40 -04:00
throw Exception('Failed to add contact invitation record');
2023-08-05 23:59:15 -04:00
}
});
});
});
return signedContactInvitationBytes;
}
class ValidContactInvitation {
ValidContactInvitation(
{required this.signedContactInvitation,
required this.contactInvitation,
required this.contactRequestInboxKey,
required this.contactRequest,
required this.contactRequestPrivate,
required this.contactIdentityMaster,
required this.writer});
SignedContactInvitation signedContactInvitation;
ContactInvitation contactInvitation;
TypedKey contactRequestInboxKey;
ContactRequest contactRequest;
ContactRequestPrivate contactRequestPrivate;
IdentityMaster contactIdentityMaster;
KeyPair writer;
}
2023-09-24 22:35:54 -04:00
typedef GetEncryptionKeyCallback = Future<SecretKey?> Function(
VeilidCryptoSystem cs,
EncryptionKeyType encryptionKeyType,
Uint8List encryptedSecret);
Future<ValidContactInvitation?> validateContactInvitation(
{required ActiveAccountInfo activeAccountInfo,
2023-09-25 22:59:28 -04:00
required IList<ContactInvitationRecord>? contactInvitationRecords,
2023-09-24 22:35:54 -04:00
required Uint8List inviteData,
required GetEncryptionKeyCallback getEncryptionKeyCallback}) async {
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
2023-08-05 23:59:15 -04:00
final signedContactInvitation =
proto.SignedContactInvitation.fromBuffer(inviteData);
final contactInvitationBytes =
Uint8List.fromList(signedContactInvitation.contactInvitation);
final contactInvitation =
proto.ContactInvitation.fromBuffer(contactInvitationBytes);
final contactRequestInboxKey =
proto.TypedKeyProto.fromProto(contactInvitation.contactRequestInboxKey);
2023-09-26 22:32:13 -04:00
ValidContactInvitation? out;
2023-08-05 23:59:15 -04:00
final pool = await DHTRecordPool.instance();
2023-09-24 22:35:54 -04:00
final cs = await pool.veilid.getCryptoSystem(contactRequestInboxKey.kind);
// See if we're chatting to ourselves, if so, don't delete it here
2023-09-25 22:59:28 -04:00
final isSelf = contactInvitationRecords?.indexWhere((cir) =>
proto.TypedKeyProto.fromProto(cir.contactRequestInbox.recordKey) ==
contactRequestInboxKey) !=
-1;
2023-09-24 22:35:54 -04:00
await (await pool.openRead(contactRequestInboxKey, parent: accountRecordKey))
2023-09-25 22:59:28 -04:00
.maybeDeleteScope(!isSelf, (contactRequestInbox) async {
2023-08-05 23:59:15 -04:00
//
final contactRequest =
await contactRequestInbox.getProtobuf(proto.ContactRequest.fromBuffer);
2023-09-24 22:35:54 -04:00
2023-08-05 23:59:15 -04:00
// Decrypt contact request private
final encryptionKeyType =
EncryptionKeyType.fromProto(contactRequest!.encryptionKeyType);
2023-09-26 22:32:13 -04:00
late final SharedSecret? writerSecret;
try {
writerSecret = await getEncryptionKeyCallback(cs, encryptionKeyType,
Uint8List.fromList(contactInvitation.writerSecret));
} on Exception catch (_) {
throw ContactInviteInvalidKeyException(encryptionKeyType);
}
2023-09-24 22:35:54 -04:00
if (writerSecret == null) {
return null;
}
2023-08-05 23:59:15 -04:00
2023-09-24 22:35:54 -04:00
final contactRequestPrivateBytes = await cs.decryptAeadWithNonce(
2023-08-05 23:59:15 -04:00
Uint8List.fromList(contactRequest.private), writerSecret);
2023-09-26 22:32:13 -04:00
2023-08-05 23:59:15 -04:00
final contactRequestPrivate =
proto.ContactRequestPrivate.fromBuffer(contactRequestPrivateBytes);
final contactIdentityMasterRecordKey = proto.TypedKeyProto.fromProto(
contactRequestPrivate.identityMasterRecordKey);
// Fetch the account master
final contactIdentityMaster = await openIdentityMaster(
identityMasterRecordKey: contactIdentityMasterRecordKey);
// Verify
final signature = proto.SignatureProto.fromProto(
signedContactInvitation.identitySignature);
2023-09-26 22:32:13 -04:00
await cs.verify(contactIdentityMaster.identityPublicKey,
contactInvitationBytes, signature);
2023-08-05 23:59:15 -04:00
final writer = KeyPair(
key: proto.CryptoKeyProto.fromProto(contactRequestPrivate.writerKey),
secret: writerSecret);
out = ValidContactInvitation(
signedContactInvitation: signedContactInvitation,
contactInvitation: contactInvitation,
contactRequestInboxKey: contactRequestInboxKey,
contactRequest: contactRequest,
contactRequestPrivate: contactRequestPrivate,
contactIdentityMaster: contactIdentityMaster,
writer: writer);
});
return out;
}
Future<AcceptedContact?> acceptContactInvitation(
ActiveAccountInfo activeAccountInfo,
ValidContactInvitation validContactInvitation) async {
final pool = await DHTRecordPool.instance();
2023-08-06 15:33:40 -04:00
try {
2023-09-24 22:35:54 -04:00
// Ensure we don't delete this if we're trying to chat to self
2023-09-25 22:59:28 -04:00
final isSelf =
validContactInvitation.contactIdentityMaster.identityPublicKey ==
activeAccountInfo.localAccount.identityMaster.identityPublicKey;
2023-09-24 22:35:54 -04:00
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
2023-08-06 15:33:40 -04:00
return (await pool.openWrite(validContactInvitation.contactRequestInboxKey,
2023-09-24 22:35:54 -04:00
validContactInvitation.writer,
parent: accountRecordKey))
2023-08-06 15:33:40 -04:00
// ignore: prefer_expression_function_bodies
2023-09-25 22:59:28 -04:00
.maybeDeleteScope(!isSelf, (contactRequestInbox) async {
2023-08-06 15:33:40 -04:00
// Create local conversation key for this
// contact and send via contact response
return createConversation(
activeAccountInfo: activeAccountInfo,
remoteIdentityPublicKey: validContactInvitation.contactIdentityMaster
.identityPublicTypedKey(),
callback: (localConversation) async {
final contactResponse = ContactResponse()
..accept = true
2023-08-07 11:02:29 -04:00
..remoteConversationRecordKey = localConversation.key.toProto()
2023-08-06 15:33:40 -04:00
..identityMasterRecordKey = activeAccountInfo
.localAccount.identityMaster.masterRecordKey
.toProto();
final contactResponseBytes = contactResponse.writeToBuffer();
final cs = await pool.veilid.getCryptoSystem(
validContactInvitation.contactRequestInboxKey.kind);
final identitySignature = await cs.sign(
activeAccountInfo.localAccount.identityMaster.identityPublicKey,
activeAccountInfo.userLogin.identitySecret.value,
contactResponseBytes);
final signedContactResponse = SignedContactResponse()
..contactResponse = contactResponseBytes
..identitySignature = identitySignature.toProto();
// Write the acceptance to the inbox
if (await contactRequestInbox.tryWriteProtobuf(
SignedContactResponse.fromBuffer, signedContactResponse,
subkey: 1) !=
null) {
throw Exception('failed to accept contact invitation');
}
return AcceptedContact(
profile: validContactInvitation.contactRequestPrivate.profile,
remoteIdentity: validContactInvitation.contactIdentityMaster,
2023-08-07 11:02:29 -04:00
remoteConversationRecordKey: proto.TypedKeyProto.fromProto(
2023-08-06 15:33:40 -04:00
validContactInvitation.contactRequestPrivate.chatRecordKey),
2023-08-07 11:02:29 -04:00
localConversationRecordKey: localConversation.key,
2023-08-06 15:33:40 -04:00
);
});
2023-08-05 23:59:15 -04:00
});
2023-08-06 15:33:40 -04:00
} on Exception catch (e) {
2023-09-28 12:51:44 -04:00
log.debug('exception: $e', e);
2023-08-06 15:33:40 -04:00
return null;
}
2023-08-05 23:59:15 -04:00
}
Future<bool> rejectContactInvitation(ActiveAccountInfo activeAccountInfo,
ValidContactInvitation validContactInvitation) async {
final pool = await DHTRecordPool.instance();
2023-09-24 22:35:54 -04:00
// Ensure we don't delete this if we're trying to chat to self
2023-09-25 22:59:28 -04:00
final isSelf =
validContactInvitation.contactIdentityMaster.identityPublicKey ==
activeAccountInfo.localAccount.identityMaster.identityPublicKey;
2023-09-24 22:35:54 -04:00
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
2023-08-05 23:59:15 -04:00
return (await pool.openWrite(validContactInvitation.contactRequestInboxKey,
2023-09-24 22:35:54 -04:00
validContactInvitation.writer,
parent: accountRecordKey))
2023-09-25 22:59:28 -04:00
.maybeDeleteScope(!isSelf, (contactRequestInbox) async {
2023-08-05 23:59:15 -04:00
final cs = await pool.veilid
.getCryptoSystem(validContactInvitation.contactRequestInboxKey.kind);
final contactResponse = ContactResponse()
..accept = false
..identityMasterRecordKey = activeAccountInfo
.localAccount.identityMaster.masterRecordKey
.toProto();
final contactResponseBytes = contactResponse.writeToBuffer();
final identitySignature = await cs.sign(
activeAccountInfo.localAccount.identityMaster.identityPublicKey,
activeAccountInfo.userLogin.identitySecret.value,
contactResponseBytes);
final signedContactResponse = SignedContactResponse()
..contactResponse = contactResponseBytes
..identitySignature = identitySignature.toProto();
// Write the rejection to the inbox
2023-08-05 23:59:15 -04:00
if (await contactRequestInbox.tryWriteProtobuf(
SignedContactResponse.fromBuffer, signedContactResponse,
subkey: 1) !=
null) {
log.error('failed to reject contact invitation');
return false;
}
return true;
});
}
/// Get the active account contact invitation list
@riverpod
Future<IList<ContactInvitationRecord>?> fetchContactInvitationRecords(
FetchContactInvitationRecordsRef ref) async {
// See if we've logged into this account or if it is locked
final activeAccountInfo = await ref.watch(fetchActiveAccountProvider.future);
if (activeAccountInfo == null) {
return null;
}
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
// Decode the contact invitation list from the DHT
IList<ContactInvitationRecord> out = const IListConst([]);
2023-10-21 19:23:43 -04:00
try {
await (await DHTShortArray.openOwned(
proto.OwnedDHTRecordPointerProto.fromProto(
activeAccountInfo.account.contactInvitationRecords),
parent: accountRecordKey))
.scope((cirList) async {
for (var i = 0; i < cirList.length; i++) {
final cir = await cirList.getItem(i);
if (cir == null) {
throw Exception('Failed to get contact invitation record');
}
out = out.add(ContactInvitationRecord.fromBuffer(cir));
2023-08-05 23:59:15 -04:00
}
2023-10-21 19:23:43 -04:00
});
} on VeilidAPIExceptionTryAgain catch (_) {
// Try again later
ref.invalidateSelf();
return null;
} on Exception catch (_) {
// Try again later
ref.invalidateSelf();
rethrow;
}
2023-08-05 23:59:15 -04:00
return out;
}