diff --git a/lib/src/model/messages_model.dart b/lib/src/model/messages_model.dart index fb87d27..378cd27 100644 --- a/lib/src/model/messages_model.dart +++ b/lib/src/model/messages_model.dart @@ -1,5 +1,3 @@ -import 'dart:typed_data'; - import 'package:cv/cv.dart'; class DbMessages extends CvModelBase { @@ -8,6 +6,9 @@ class DbMessages extends CvModelBase { static const columnMessageId = "messageId"; final messageId = CvField(columnMessageId); + static const columnBody = "body"; + final messageBody = CvField(columnBody); + static const columnCreatedAt = "created_at"; final createdAt = CvField(columnCreatedAt); diff --git a/lib/src/model/model_constants.dart b/lib/src/model/model_constants.dart index ad5aa79..083e57c 100644 --- a/lib/src/model/model_constants.dart +++ b/lib/src/model/model_constants.dart @@ -1,4 +1,4 @@ -const String dbName = 'connect.db'; +const String dbName = 'twonly.db'; const int kVersion1 = 1; diff --git a/lib/src/proto/api/client_to_server.pb.dart b/lib/src/proto/api/client_to_server.pb.dart index 331b00e..8ed2d89 100644 --- a/lib/src/proto/api/client_to_server.pb.dart +++ b/lib/src/proto/api/client_to_server.pb.dart @@ -204,6 +204,7 @@ class Handshake_Register extends $pb.GeneratedMessage { $core.List<$core.int>? signedPrekey, $core.List<$core.int>? signedPrekeySignature, $fixnum.Int64? signedPrekeyId, + $fixnum.Int64? registrationId, }) { final $result = create(); if (username != null) { @@ -224,6 +225,9 @@ class Handshake_Register extends $pb.GeneratedMessage { if (signedPrekeyId != null) { $result.signedPrekeyId = signedPrekeyId; } + if (registrationId != null) { + $result.registrationId = registrationId; + } return $result; } Handshake_Register._() : super(); @@ -237,6 +241,7 @@ class Handshake_Register extends $pb.GeneratedMessage { ..a<$core.List<$core.int>>(4, _omitFieldNames ? '' : 'signedPrekey', $pb.PbFieldType.OY) ..a<$core.List<$core.int>>(5, _omitFieldNames ? '' : 'signedPrekeySignature', $pb.PbFieldType.OY) ..aInt64(6, _omitFieldNames ? '' : 'signedPrekeyId') + ..aInt64(7, _omitFieldNames ? '' : 'registrationId') ..hasRequiredFields = false ; @@ -314,6 +319,15 @@ class Handshake_Register extends $pb.GeneratedMessage { $core.bool hasSignedPrekeyId() => $_has(5); @$pb.TagNumber(6) void clearSignedPrekeyId() => clearField(6); + + @$pb.TagNumber(7) + $fixnum.Int64 get registrationId => $_getI64(6); + @$pb.TagNumber(7) + set registrationId($fixnum.Int64 v) { $_setInt64(6, v); } + @$pb.TagNumber(7) + $core.bool hasRegistrationId() => $_has(6); + @$pb.TagNumber(7) + void clearRegistrationId() => clearField(7); } class Handshake_GetChallenge extends $pb.GeneratedMessage { @@ -677,10 +691,140 @@ class ApplicationData_GetPrekeysByUserId extends $pb.GeneratedMessage { void clearUserId() => clearField(1); } +class ApplicationData_GetUploadToken extends $pb.GeneratedMessage { + factory ApplicationData_GetUploadToken({ + $core.int? len, + }) { + final $result = create(); + if (len != null) { + $result.len = len; + } + return $result; + } + ApplicationData_GetUploadToken._() : super(); + factory ApplicationData_GetUploadToken.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory ApplicationData_GetUploadToken.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ApplicationData.GetUploadToken', package: const $pb.PackageName(_omitMessageNames ? '' : 'client_to_server'), createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'len', $pb.PbFieldType.OU3) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + ApplicationData_GetUploadToken clone() => ApplicationData_GetUploadToken()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + ApplicationData_GetUploadToken copyWith(void Function(ApplicationData_GetUploadToken) updates) => super.copyWith((message) => updates(message as ApplicationData_GetUploadToken)) as ApplicationData_GetUploadToken; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static ApplicationData_GetUploadToken create() => ApplicationData_GetUploadToken._(); + ApplicationData_GetUploadToken createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static ApplicationData_GetUploadToken getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static ApplicationData_GetUploadToken? _defaultInstance; + + @$pb.TagNumber(1) + $core.int get len => $_getIZ(0); + @$pb.TagNumber(1) + set len($core.int v) { $_setUnsignedInt32(0, v); } + @$pb.TagNumber(1) + $core.bool hasLen() => $_has(0); + @$pb.TagNumber(1) + void clearLen() => clearField(1); +} + +class ApplicationData_UploadData extends $pb.GeneratedMessage { + factory ApplicationData_UploadData({ + $core.List<$core.int>? uploadToken, + $core.int? offset, + $core.List<$core.int>? data, + }) { + final $result = create(); + if (uploadToken != null) { + $result.uploadToken = uploadToken; + } + if (offset != null) { + $result.offset = offset; + } + if (data != null) { + $result.data = data; + } + return $result; + } + ApplicationData_UploadData._() : super(); + factory ApplicationData_UploadData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory ApplicationData_UploadData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ApplicationData.UploadData', package: const $pb.PackageName(_omitMessageNames ? '' : 'client_to_server'), createEmptyInstance: create) + ..a<$core.List<$core.int>>(1, _omitFieldNames ? '' : 'uploadToken', $pb.PbFieldType.OY) + ..a<$core.int>(2, _omitFieldNames ? '' : 'offset', $pb.PbFieldType.OU3) + ..a<$core.List<$core.int>>(3, _omitFieldNames ? '' : 'data', $pb.PbFieldType.OY) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + ApplicationData_UploadData clone() => ApplicationData_UploadData()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + ApplicationData_UploadData copyWith(void Function(ApplicationData_UploadData) updates) => super.copyWith((message) => updates(message as ApplicationData_UploadData)) as ApplicationData_UploadData; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static ApplicationData_UploadData create() => ApplicationData_UploadData._(); + ApplicationData_UploadData createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static ApplicationData_UploadData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static ApplicationData_UploadData? _defaultInstance; + + @$pb.TagNumber(1) + $core.List<$core.int> get uploadToken => $_getN(0); + @$pb.TagNumber(1) + set uploadToken($core.List<$core.int> v) { $_setBytes(0, v); } + @$pb.TagNumber(1) + $core.bool hasUploadToken() => $_has(0); + @$pb.TagNumber(1) + void clearUploadToken() => clearField(1); + + @$pb.TagNumber(2) + $core.int get offset => $_getIZ(1); + @$pb.TagNumber(2) + set offset($core.int v) { $_setUnsignedInt32(1, v); } + @$pb.TagNumber(2) + $core.bool hasOffset() => $_has(1); + @$pb.TagNumber(2) + void clearOffset() => clearField(2); + + @$pb.TagNumber(3) + $core.List<$core.int> get data => $_getN(2); + @$pb.TagNumber(3) + set data($core.List<$core.int> v) { $_setBytes(2, v); } + @$pb.TagNumber(3) + $core.bool hasData() => $_has(2); + @$pb.TagNumber(3) + void clearData() => clearField(3); +} + enum ApplicationData_ApplicationData { textmessage, getuserbyusername, getprekeysbyuserid, + getuploadtoken, + uploaddata, notSet } @@ -689,6 +833,8 @@ class ApplicationData extends $pb.GeneratedMessage { ApplicationData_TextMessage? textmessage, ApplicationData_GetUserByUsername? getuserbyusername, ApplicationData_GetPrekeysByUserId? getprekeysbyuserid, + ApplicationData_GetUploadToken? getuploadtoken, + ApplicationData_UploadData? uploaddata, }) { final $result = create(); if (textmessage != null) { @@ -700,6 +846,12 @@ class ApplicationData extends $pb.GeneratedMessage { if (getprekeysbyuserid != null) { $result.getprekeysbyuserid = getprekeysbyuserid; } + if (getuploadtoken != null) { + $result.getuploadtoken = getuploadtoken; + } + if (uploaddata != null) { + $result.uploaddata = uploaddata; + } return $result; } ApplicationData._() : super(); @@ -710,13 +862,17 @@ class ApplicationData extends $pb.GeneratedMessage { 1 : ApplicationData_ApplicationData.textmessage, 2 : ApplicationData_ApplicationData.getuserbyusername, 3 : ApplicationData_ApplicationData.getprekeysbyuserid, + 4 : ApplicationData_ApplicationData.getuploadtoken, + 5 : ApplicationData_ApplicationData.uploaddata, 0 : ApplicationData_ApplicationData.notSet }; static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ApplicationData', package: const $pb.PackageName(_omitMessageNames ? '' : 'client_to_server'), createEmptyInstance: create) - ..oo(0, [1, 2, 3]) + ..oo(0, [1, 2, 3, 4, 5]) ..aOM(1, _omitFieldNames ? '' : 'textmessage', subBuilder: ApplicationData_TextMessage.create) ..aOM(2, _omitFieldNames ? '' : 'getuserbyusername', subBuilder: ApplicationData_GetUserByUsername.create) ..aOM(3, _omitFieldNames ? '' : 'getprekeysbyuserid', subBuilder: ApplicationData_GetPrekeysByUserId.create) + ..aOM(4, _omitFieldNames ? '' : 'getuploadtoken', subBuilder: ApplicationData_GetUploadToken.create) + ..aOM(5, _omitFieldNames ? '' : 'uploaddata', subBuilder: ApplicationData_UploadData.create) ..hasRequiredFields = false ; @@ -776,11 +932,97 @@ class ApplicationData extends $pb.GeneratedMessage { void clearGetprekeysbyuserid() => clearField(3); @$pb.TagNumber(3) ApplicationData_GetPrekeysByUserId ensureGetprekeysbyuserid() => $_ensure(2); + + @$pb.TagNumber(4) + ApplicationData_GetUploadToken get getuploadtoken => $_getN(3); + @$pb.TagNumber(4) + set getuploadtoken(ApplicationData_GetUploadToken v) { setField(4, v); } + @$pb.TagNumber(4) + $core.bool hasGetuploadtoken() => $_has(3); + @$pb.TagNumber(4) + void clearGetuploadtoken() => clearField(4); + @$pb.TagNumber(4) + ApplicationData_GetUploadToken ensureGetuploadtoken() => $_ensure(3); + + @$pb.TagNumber(5) + ApplicationData_UploadData get uploaddata => $_getN(4); + @$pb.TagNumber(5) + set uploaddata(ApplicationData_UploadData v) { setField(5, v); } + @$pb.TagNumber(5) + $core.bool hasUploaddata() => $_has(4); + @$pb.TagNumber(5) + void clearUploaddata() => clearField(5); + @$pb.TagNumber(5) + ApplicationData_UploadData ensureUploaddata() => $_ensure(4); +} + +class Response_PreKey extends $pb.GeneratedMessage { + factory Response_PreKey({ + $fixnum.Int64? id, + $core.List<$core.int>? prekey, + }) { + final $result = create(); + if (id != null) { + $result.id = id; + } + if (prekey != null) { + $result.prekey = prekey; + } + return $result; + } + Response_PreKey._() : super(); + factory Response_PreKey.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory Response_PreKey.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Response.PreKey', package: const $pb.PackageName(_omitMessageNames ? '' : 'client_to_server'), createEmptyInstance: create) + ..aInt64(1, _omitFieldNames ? '' : 'id') + ..a<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'prekey', $pb.PbFieldType.OY) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Response_PreKey clone() => Response_PreKey()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Response_PreKey copyWith(void Function(Response_PreKey) updates) => super.copyWith((message) => updates(message as Response_PreKey)) as Response_PreKey; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Response_PreKey create() => Response_PreKey._(); + Response_PreKey createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Response_PreKey getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Response_PreKey? _defaultInstance; + + @$pb.TagNumber(1) + $fixnum.Int64 get id => $_getI64(0); + @$pb.TagNumber(1) + set id($fixnum.Int64 v) { $_setInt64(0, v); } + @$pb.TagNumber(1) + $core.bool hasId() => $_has(0); + @$pb.TagNumber(1) + void clearId() => clearField(1); + + @$pb.TagNumber(2) + $core.List<$core.int> get prekey => $_getN(1); + @$pb.TagNumber(2) + set prekey($core.List<$core.int> v) { $_setBytes(1, v); } + @$pb.TagNumber(2) + $core.bool hasPrekey() => $_has(1); + @$pb.TagNumber(2) + void clearPrekey() => clearField(2); } class Response_Prekeys extends $pb.GeneratedMessage { factory Response_Prekeys({ - $core.Iterable<$core.List<$core.int>>? prekeys, + $core.Iterable? prekeys, }) { final $result = create(); if (prekeys != null) { @@ -793,7 +1035,7 @@ class Response_Prekeys extends $pb.GeneratedMessage { factory Response_Prekeys.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Response.Prekeys', package: const $pb.PackageName(_omitMessageNames ? '' : 'client_to_server'), createEmptyInstance: create) - ..p<$core.List<$core.int>>(1, _omitFieldNames ? '' : 'prekeys', $pb.PbFieldType.PY) + ..pc(1, _omitFieldNames ? '' : 'prekeys', $pb.PbFieldType.PM, subBuilder: Response_PreKey.create) ..hasRequiredFields = false ; @@ -819,7 +1061,7 @@ class Response_Prekeys extends $pb.GeneratedMessage { static Response_Prekeys? _defaultInstance; @$pb.TagNumber(1) - $core.List<$core.List<$core.int>> get prekeys => $_getList(0); + $core.List get prekeys => $_getList(0); } enum Response_Ok_Ok { diff --git a/lib/src/proto/api/client_to_server.pbjson.dart b/lib/src/proto/api/client_to_server.pbjson.dart index 99b7607..ecb3c31 100644 --- a/lib/src/proto/api/client_to_server.pbjson.dart +++ b/lib/src/proto/api/client_to_server.pbjson.dart @@ -75,6 +75,7 @@ const Handshake_Register$json = { {'1': 'signed_prekey', '3': 4, '4': 1, '5': 12, '10': 'signedPrekey'}, {'1': 'signed_prekey_signature', '3': 5, '4': 1, '5': 12, '10': 'signedPrekeySignature'}, {'1': 'signed_prekey_id', '3': 6, '4': 1, '5': 3, '10': 'signedPrekeyId'}, + {'1': 'registration_id', '3': 7, '4': 1, '5': 3, '10': 'registrationId'}, ], '8': [ {'1': '_invite_code'}, @@ -101,14 +102,14 @@ final $typed_data.Uint8List handshakeDescriptor = $convert.base64Decode( 'FrZS5SZWdpc3RlckgAUghyZWdpc3RlchJOCgxnZXRjaGFsbGVuZ2UYAiABKAsyKC5jbGllbnRf' 'dG9fc2VydmVyLkhhbmRzaGFrZS5HZXRDaGFsbGVuZ2VIAFIMZ2V0Y2hhbGxlbmdlEksKC29wZW' '5zZXNzaW9uGAMgASgLMicuY2xpZW50X3RvX3NlcnZlci5IYW5kc2hha2UuT3BlblNlc3Npb25I' - 'AFILb3BlbnNlc3Npb24akwIKCFJlZ2lzdGVyEhoKCHVzZXJuYW1lGAEgASgJUgh1c2VybmFtZR' + 'AFILb3BlbnNlc3Npb24avAIKCFJlZ2lzdGVyEhoKCHVzZXJuYW1lGAEgASgJUgh1c2VybmFtZR' 'IkCgtpbnZpdGVfY29kZRgCIAEoCUgAUgppbnZpdGVDb2RliAEBEi4KE3B1YmxpY19pZGVudGl0' 'eV9rZXkYAyABKAxSEXB1YmxpY0lkZW50aXR5S2V5EiMKDXNpZ25lZF9wcmVrZXkYBCABKAxSDH' 'NpZ25lZFByZWtleRI2ChdzaWduZWRfcHJla2V5X3NpZ25hdHVyZRgFIAEoDFIVc2lnbmVkUHJl' - 'a2V5U2lnbmF0dXJlEigKEHNpZ25lZF9wcmVrZXlfaWQYBiABKANSDnNpZ25lZFByZWtleUlkQg' - '4KDF9pbnZpdGVfY29kZRoOCgxHZXRDaGFsbGVuZ2UaQgoLT3BlblNlc3Npb24SFwoHdXNlcl9p' - 'ZBgBIAEoDFIGdXNlcklkEhoKCHJlc3BvbnNlGAIgASgMUghyZXNwb25zZUILCglIYW5kc2hha2' - 'U='); + 'a2V5U2lnbmF0dXJlEigKEHNpZ25lZF9wcmVrZXlfaWQYBiABKANSDnNpZ25lZFByZWtleUlkEi' + 'cKD3JlZ2lzdHJhdGlvbl9pZBgHIAEoA1IOcmVnaXN0cmF0aW9uSWRCDgoMX2ludml0ZV9jb2Rl' + 'Gg4KDEdldENoYWxsZW5nZRpCCgtPcGVuU2Vzc2lvbhIXCgd1c2VyX2lkGAEgASgMUgZ1c2VySW' + 'QSGgoIcmVzcG9uc2UYAiABKAxSCHJlc3BvbnNlQgsKCUhhbmRzaGFrZQ=='); @$core.Deprecated('Use applicationDataDescriptor instead') const ApplicationData$json = { @@ -117,8 +118,10 @@ const ApplicationData$json = { {'1': 'textmessage', '3': 1, '4': 1, '5': 11, '6': '.client_to_server.ApplicationData.TextMessage', '9': 0, '10': 'textmessage'}, {'1': 'getuserbyusername', '3': 2, '4': 1, '5': 11, '6': '.client_to_server.ApplicationData.GetUserByUsername', '9': 0, '10': 'getuserbyusername'}, {'1': 'getprekeysbyuserid', '3': 3, '4': 1, '5': 11, '6': '.client_to_server.ApplicationData.GetPrekeysByUserId', '9': 0, '10': 'getprekeysbyuserid'}, + {'1': 'getuploadtoken', '3': 4, '4': 1, '5': 11, '6': '.client_to_server.ApplicationData.GetUploadToken', '9': 0, '10': 'getuploadtoken'}, + {'1': 'uploaddata', '3': 5, '4': 1, '5': 11, '6': '.client_to_server.ApplicationData.UploadData', '9': 0, '10': 'uploaddata'}, ], - '3': [ApplicationData_TextMessage$json, ApplicationData_GetUserByUsername$json, ApplicationData_GetPrekeysByUserId$json], + '3': [ApplicationData_TextMessage$json, ApplicationData_GetUserByUsername$json, ApplicationData_GetPrekeysByUserId$json, ApplicationData_GetUploadToken$json, ApplicationData_UploadData$json], '8': [ {'1': 'ApplicationData'}, ], @@ -149,6 +152,24 @@ const ApplicationData_GetPrekeysByUserId$json = { ], }; +@$core.Deprecated('Use applicationDataDescriptor instead') +const ApplicationData_GetUploadToken$json = { + '1': 'GetUploadToken', + '2': [ + {'1': 'len', '3': 1, '4': 1, '5': 13, '10': 'len'}, + ], +}; + +@$core.Deprecated('Use applicationDataDescriptor instead') +const ApplicationData_UploadData$json = { + '1': 'UploadData', + '2': [ + {'1': 'upload_token', '3': 1, '4': 1, '5': 12, '10': 'uploadToken'}, + {'1': 'offset', '3': 2, '4': 1, '5': 13, '10': 'offset'}, + {'1': 'data', '3': 3, '4': 1, '5': 12, '10': 'data'}, + ], +}; + /// Descriptor for `ApplicationData`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List applicationDataDescriptor = $convert.base64Decode( 'Cg9BcHBsaWNhdGlvbkRhdGESUQoLdGV4dG1lc3NhZ2UYASABKAsyLS5jbGllbnRfdG9fc2Vydm' @@ -156,10 +177,16 @@ final $typed_data.Uint8List applicationDataDescriptor = $convert.base64Decode( 'Ynl1c2VybmFtZRgCIAEoCzIzLmNsaWVudF90b19zZXJ2ZXIuQXBwbGljYXRpb25EYXRhLkdldF' 'VzZXJCeVVzZXJuYW1lSABSEWdldHVzZXJieXVzZXJuYW1lEmYKEmdldHByZWtleXNieXVzZXJp' 'ZBgDIAEoCzI0LmNsaWVudF90b19zZXJ2ZXIuQXBwbGljYXRpb25EYXRhLkdldFByZWtleXNCeV' - 'VzZXJJZEgAUhJnZXRwcmVrZXlzYnl1c2VyaWQaOgoLVGV4dE1lc3NhZ2USFwoHdXNlcl9pZBgB' - 'IAEoDFIGdXNlcklkEhIKBGJvZHkYAyABKAxSBGJvZHkaLwoRR2V0VXNlckJ5VXNlcm5hbWUSGg' - 'oIdXNlcm5hbWUYASABKAlSCHVzZXJuYW1lGi0KEkdldFByZWtleXNCeVVzZXJJZBIXCgd1c2Vy' - 'X2lkGAEgASgMUgZ1c2VySWRCEQoPQXBwbGljYXRpb25EYXRh'); + 'VzZXJJZEgAUhJnZXRwcmVrZXlzYnl1c2VyaWQSWgoOZ2V0dXBsb2FkdG9rZW4YBCABKAsyMC5j' + 'bGllbnRfdG9fc2VydmVyLkFwcGxpY2F0aW9uRGF0YS5HZXRVcGxvYWRUb2tlbkgAUg5nZXR1cG' + 'xvYWR0b2tlbhJOCgp1cGxvYWRkYXRhGAUgASgLMiwuY2xpZW50X3RvX3NlcnZlci5BcHBsaWNh' + 'dGlvbkRhdGEuVXBsb2FkRGF0YUgAUgp1cGxvYWRkYXRhGjoKC1RleHRNZXNzYWdlEhcKB3VzZX' + 'JfaWQYASABKAxSBnVzZXJJZBISCgRib2R5GAMgASgMUgRib2R5Gi8KEUdldFVzZXJCeVVzZXJu' + 'YW1lEhoKCHVzZXJuYW1lGAEgASgJUgh1c2VybmFtZRotChJHZXRQcmVrZXlzQnlVc2VySWQSFw' + 'oHdXNlcl9pZBgBIAEoDFIGdXNlcklkGiIKDkdldFVwbG9hZFRva2VuEhAKA2xlbhgBIAEoDVID' + 'bGVuGlsKClVwbG9hZERhdGESIQoMdXBsb2FkX3Rva2VuGAEgASgMUgt1cGxvYWRUb2tlbhIWCg' + 'ZvZmZzZXQYAiABKA1SBm9mZnNldBISCgRkYXRhGAMgASgMUgRkYXRhQhEKD0FwcGxpY2F0aW9u' + 'RGF0YQ=='); @$core.Deprecated('Use responseDescriptor instead') const Response$json = { @@ -168,17 +195,26 @@ const Response$json = { {'1': 'ok', '3': 1, '4': 1, '5': 11, '6': '.client_to_server.Response.Ok', '9': 0, '10': 'ok'}, {'1': 'error', '3': 2, '4': 1, '5': 14, '6': '.error.ErrorCode', '9': 0, '10': 'error'}, ], - '3': [Response_Prekeys$json, Response_Ok$json], + '3': [Response_PreKey$json, Response_Prekeys$json, Response_Ok$json], '8': [ {'1': 'Response'}, ], }; +@$core.Deprecated('Use responseDescriptor instead') +const Response_PreKey$json = { + '1': 'PreKey', + '2': [ + {'1': 'id', '3': 1, '4': 1, '5': 3, '10': 'id'}, + {'1': 'prekey', '3': 2, '4': 1, '5': 12, '10': 'prekey'}, + ], +}; + @$core.Deprecated('Use responseDescriptor instead') const Response_Prekeys$json = { '1': 'Prekeys', '2': [ - {'1': 'prekeys', '3': 1, '4': 3, '5': 12, '10': 'prekeys'}, + {'1': 'prekeys', '3': 1, '4': 3, '5': 11, '6': '.client_to_server.Response.PreKey', '10': 'prekeys'}, ], }; @@ -197,8 +233,9 @@ const Response_Ok$json = { /// Descriptor for `Response`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List responseDescriptor = $convert.base64Decode( 'CghSZXNwb25zZRIvCgJvaxgBIAEoCzIdLmNsaWVudF90b19zZXJ2ZXIuUmVzcG9uc2UuT2tIAF' - 'ICb2sSKAoFZXJyb3IYAiABKA4yEC5lcnJvci5FcnJvckNvZGVIAFIFZXJyb3IaIwoHUHJla2V5' - 'cxIYCgdwcmVrZXlzGAEgAygMUgdwcmVrZXlzGmAKAk9rEhQKBE5vbmUYASABKAhIAFIETm9uZR' - 'I+CgdwcmVrZXlzGAIgASgLMiIuY2xpZW50X3RvX3NlcnZlci5SZXNwb25zZS5QcmVrZXlzSABS' - 'B3ByZWtleXNCBAoCT2tCCgoIUmVzcG9uc2U='); + 'ICb2sSKAoFZXJyb3IYAiABKA4yEC5lcnJvci5FcnJvckNvZGVIAFIFZXJyb3IaMAoGUHJlS2V5' + 'Eg4KAmlkGAEgASgDUgJpZBIWCgZwcmVrZXkYAiABKAxSBnByZWtleRpGCgdQcmVrZXlzEjsKB3' + 'ByZWtleXMYASADKAsyIS5jbGllbnRfdG9fc2VydmVyLlJlc3BvbnNlLlByZUtleVIHcHJla2V5' + 'cxpgCgJPaxIUCgROb25lGAEgASgISABSBE5vbmUSPgoHcHJla2V5cxgCIAEoCzIiLmNsaWVudF' + '90b19zZXJ2ZXIuUmVzcG9uc2UuUHJla2V5c0gAUgdwcmVrZXlzQgQKAk9rQgoKCFJlc3BvbnNl'); diff --git a/lib/src/proto/api/error.pbenum.dart b/lib/src/proto/api/error.pbenum.dart index 8c9d9c0..b2bd916 100644 --- a/lib/src/proto/api/error.pbenum.dart +++ b/lib/src/proto/api/error.pbenum.dart @@ -27,6 +27,8 @@ class ErrorCode extends $pb.ProtobufEnum { static const ErrorCode SessionAlreadyAuthenticated = ErrorCode._(1008, _omitEnumNames ? '' : 'SessionAlreadyAuthenticated'); static const ErrorCode SessionNotAuthenticated = ErrorCode._(1009, _omitEnumNames ? '' : 'SessionNotAuthenticated'); static const ErrorCode OnlyOneSessionAllowed = ErrorCode._(1010, _omitEnumNames ? '' : 'OnlyOneSessionAllowed'); + static const ErrorCode UploadLimitReached = ErrorCode._(1011, _omitEnumNames ? '' : 'UploadLimitReached'); + static const ErrorCode InvalidUpdateToken = ErrorCode._(1012, _omitEnumNames ? '' : 'InvalidUpdateToken'); static const $core.List values = [ Unknown, @@ -42,6 +44,8 @@ class ErrorCode extends $pb.ProtobufEnum { SessionAlreadyAuthenticated, SessionNotAuthenticated, OnlyOneSessionAllowed, + UploadLimitReached, + InvalidUpdateToken, ]; static final $core.Map<$core.int, ErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values); diff --git a/lib/src/proto/api/error.pbjson.dart b/lib/src/proto/api/error.pbjson.dart index 0cc3219..5a49388 100644 --- a/lib/src/proto/api/error.pbjson.dart +++ b/lib/src/proto/api/error.pbjson.dart @@ -30,6 +30,8 @@ const ErrorCode$json = { {'1': 'SessionAlreadyAuthenticated', '2': 1008}, {'1': 'SessionNotAuthenticated', '2': 1009}, {'1': 'OnlyOneSessionAllowed', '2': 1010}, + {'1': 'UploadLimitReached', '2': 1011}, + {'1': 'InvalidUpdateToken', '2': 1012}, ], }; @@ -40,5 +42,6 @@ final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode( 'EhkKFFVzZXJuYW1lQWxyZWFkeVRha2VuEOsHEhYKEVNpZ25hdHVyZU5vdFZhbGlkEOwHEhUKEF' 'VzZXJuYW1lTm90Rm91bmQQ7QcSFQoQVXNlcm5hbWVOb3RWYWxpZBDuBxIVChBJbnZhbGlkUHVi' 'bGljS2V5EO8HEiAKG1Nlc3Npb25BbHJlYWR5QXV0aGVudGljYXRlZBDwBxIcChdTZXNzaW9uTm' - '90QXV0aGVudGljYXRlZBDxBxIaChVPbmx5T25lU2Vzc2lvbkFsbG93ZWQQ8gc='); + '90QXV0aGVudGljYXRlZBDxBxIaChVPbmx5T25lU2Vzc2lvbkFsbG93ZWQQ8gcSFwoSVXBsb2Fk' + 'TGltaXRSZWFjaGVkEPMHEhcKEkludmFsaWRVcGRhdGVUb2tlbhD0Bw=='); diff --git a/lib/src/proto/api/server_to_client.pb.dart b/lib/src/proto/api/server_to_client.pb.dart index bfd1701..2e7b161 100644 --- a/lib/src/proto/api/server_to_client.pb.dart +++ b/lib/src/proto/api/server_to_client.pb.dart @@ -244,14 +244,79 @@ class NewMessage extends $pb.GeneratedMessage { void clearBody() => clearField(1); } +class Response_PreKey extends $pb.GeneratedMessage { + factory Response_PreKey({ + $fixnum.Int64? id, + $core.List<$core.int>? prekey, + }) { + final $result = create(); + if (id != null) { + $result.id = id; + } + if (prekey != null) { + $result.prekey = prekey; + } + return $result; + } + Response_PreKey._() : super(); + factory Response_PreKey.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory Response_PreKey.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Response.PreKey', package: const $pb.PackageName(_omitMessageNames ? '' : 'server_to_client'), createEmptyInstance: create) + ..aInt64(1, _omitFieldNames ? '' : 'id') + ..a<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'prekey', $pb.PbFieldType.OY) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Response_PreKey clone() => Response_PreKey()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Response_PreKey copyWith(void Function(Response_PreKey) updates) => super.copyWith((message) => updates(message as Response_PreKey)) as Response_PreKey; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Response_PreKey create() => Response_PreKey._(); + Response_PreKey createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Response_PreKey getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Response_PreKey? _defaultInstance; + + @$pb.TagNumber(1) + $fixnum.Int64 get id => $_getI64(0); + @$pb.TagNumber(1) + set id($fixnum.Int64 v) { $_setInt64(0, v); } + @$pb.TagNumber(1) + $core.bool hasId() => $_has(0); + @$pb.TagNumber(1) + void clearId() => clearField(1); + + @$pb.TagNumber(2) + $core.List<$core.int> get prekey => $_getN(1); + @$pb.TagNumber(2) + set prekey($core.List<$core.int> v) { $_setBytes(1, v); } + @$pb.TagNumber(2) + $core.bool hasPrekey() => $_has(1); + @$pb.TagNumber(2) + void clearPrekey() => clearField(2); +} + class Response_UserData extends $pb.GeneratedMessage { factory Response_UserData({ $core.List<$core.int>? userId, - $core.Iterable<$core.List<$core.int>>? prekeys, + $core.Iterable? prekeys, $core.List<$core.int>? publicIdentityKey, $core.List<$core.int>? signedPrekey, $core.List<$core.int>? signedPrekeySignature, $fixnum.Int64? signedPrekeyId, + $fixnum.Int64? registrationId, }) { final $result = create(); if (userId != null) { @@ -272,6 +337,9 @@ class Response_UserData extends $pb.GeneratedMessage { if (signedPrekeyId != null) { $result.signedPrekeyId = signedPrekeyId; } + if (registrationId != null) { + $result.registrationId = registrationId; + } return $result; } Response_UserData._() : super(); @@ -280,11 +348,12 @@ class Response_UserData extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Response.UserData', package: const $pb.PackageName(_omitMessageNames ? '' : 'server_to_client'), createEmptyInstance: create) ..a<$core.List<$core.int>>(1, _omitFieldNames ? '' : 'userId', $pb.PbFieldType.OY) - ..p<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'prekeys', $pb.PbFieldType.PY) + ..pc(2, _omitFieldNames ? '' : 'prekeys', $pb.PbFieldType.PM, subBuilder: Response_PreKey.create) ..a<$core.List<$core.int>>(3, _omitFieldNames ? '' : 'publicIdentityKey', $pb.PbFieldType.OY) ..a<$core.List<$core.int>>(4, _omitFieldNames ? '' : 'signedPrekey', $pb.PbFieldType.OY) ..a<$core.List<$core.int>>(5, _omitFieldNames ? '' : 'signedPrekeySignature', $pb.PbFieldType.OY) ..aInt64(6, _omitFieldNames ? '' : 'signedPrekeyId') + ..aInt64(7, _omitFieldNames ? '' : 'registrationId') ..hasRequiredFields = false ; @@ -319,7 +388,7 @@ class Response_UserData extends $pb.GeneratedMessage { void clearUserId() => clearField(1); @$pb.TagNumber(2) - $core.List<$core.List<$core.int>> get prekeys => $_getList(1); + $core.List get prekeys => $_getList(1); @$pb.TagNumber(3) $core.List<$core.int> get publicIdentityKey => $_getN(2); @@ -356,12 +425,22 @@ class Response_UserData extends $pb.GeneratedMessage { $core.bool hasSignedPrekeyId() => $_has(5); @$pb.TagNumber(6) void clearSignedPrekeyId() => clearField(6); + + @$pb.TagNumber(7) + $fixnum.Int64 get registrationId => $_getI64(6); + @$pb.TagNumber(7) + set registrationId($fixnum.Int64 v) { $_setInt64(6, v); } + @$pb.TagNumber(7) + $core.bool hasRegistrationId() => $_has(6); + @$pb.TagNumber(7) + void clearRegistrationId() => clearField(7); } enum Response_Ok_Ok { none, userid, challenge, + uploadtoken, userdata, notSet } @@ -371,6 +450,7 @@ class Response_Ok extends $pb.GeneratedMessage { $core.bool? none, $core.List<$core.int>? userid, $core.List<$core.int>? challenge, + $core.List<$core.int>? uploadtoken, Response_UserData? userdata, }) { final $result = create(); @@ -383,6 +463,9 @@ class Response_Ok extends $pb.GeneratedMessage { if (challenge != null) { $result.challenge = challenge; } + if (uploadtoken != null) { + $result.uploadtoken = uploadtoken; + } if (userdata != null) { $result.userdata = userdata; } @@ -396,15 +479,17 @@ class Response_Ok extends $pb.GeneratedMessage { 1 : Response_Ok_Ok.none, 2 : Response_Ok_Ok.userid, 3 : Response_Ok_Ok.challenge, - 4 : Response_Ok_Ok.userdata, + 4 : Response_Ok_Ok.uploadtoken, + 5 : Response_Ok_Ok.userdata, 0 : Response_Ok_Ok.notSet }; static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Response.Ok', package: const $pb.PackageName(_omitMessageNames ? '' : 'server_to_client'), createEmptyInstance: create) - ..oo(0, [1, 2, 3, 4]) + ..oo(0, [1, 2, 3, 4, 5]) ..aOB(1, _omitFieldNames ? '' : 'None', protoName: 'None') ..a<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'userid', $pb.PbFieldType.OY) ..a<$core.List<$core.int>>(3, _omitFieldNames ? '' : 'challenge', $pb.PbFieldType.OY) - ..aOM(4, _omitFieldNames ? '' : 'userdata', subBuilder: Response_UserData.create) + ..a<$core.List<$core.int>>(4, _omitFieldNames ? '' : 'uploadtoken', $pb.PbFieldType.OY) + ..aOM(5, _omitFieldNames ? '' : 'userdata', subBuilder: Response_UserData.create) ..hasRequiredFields = false ; @@ -460,15 +545,24 @@ class Response_Ok extends $pb.GeneratedMessage { void clearChallenge() => clearField(3); @$pb.TagNumber(4) - Response_UserData get userdata => $_getN(3); + $core.List<$core.int> get uploadtoken => $_getN(3); @$pb.TagNumber(4) - set userdata(Response_UserData v) { setField(4, v); } + set uploadtoken($core.List<$core.int> v) { $_setBytes(3, v); } @$pb.TagNumber(4) - $core.bool hasUserdata() => $_has(3); + $core.bool hasUploadtoken() => $_has(3); @$pb.TagNumber(4) - void clearUserdata() => clearField(4); - @$pb.TagNumber(4) - Response_UserData ensureUserdata() => $_ensure(3); + void clearUploadtoken() => clearField(4); + + @$pb.TagNumber(5) + Response_UserData get userdata => $_getN(4); + @$pb.TagNumber(5) + set userdata(Response_UserData v) { setField(5, v); } + @$pb.TagNumber(5) + $core.bool hasUserdata() => $_has(4); + @$pb.TagNumber(5) + void clearUserdata() => clearField(5); + @$pb.TagNumber(5) + Response_UserData ensureUserdata() => $_ensure(4); } enum Response_Response { diff --git a/lib/src/proto/api/server_to_client.pbjson.dart b/lib/src/proto/api/server_to_client.pbjson.dart index 89e559e..095a24b 100644 --- a/lib/src/proto/api/server_to_client.pbjson.dart +++ b/lib/src/proto/api/server_to_client.pbjson.dart @@ -69,27 +69,38 @@ const Response$json = { {'1': 'ok', '3': 1, '4': 1, '5': 11, '6': '.server_to_client.Response.Ok', '9': 0, '10': 'ok'}, {'1': 'error', '3': 2, '4': 1, '5': 14, '6': '.error.ErrorCode', '9': 0, '10': 'error'}, ], - '3': [Response_UserData$json, Response_Ok$json], + '3': [Response_PreKey$json, Response_UserData$json, Response_Ok$json], '8': [ {'1': 'Response'}, ], }; +@$core.Deprecated('Use responseDescriptor instead') +const Response_PreKey$json = { + '1': 'PreKey', + '2': [ + {'1': 'id', '3': 1, '4': 1, '5': 3, '10': 'id'}, + {'1': 'prekey', '3': 2, '4': 1, '5': 12, '10': 'prekey'}, + ], +}; + @$core.Deprecated('Use responseDescriptor instead') const Response_UserData$json = { '1': 'UserData', '2': [ {'1': 'user_id', '3': 1, '4': 1, '5': 12, '10': 'userId'}, - {'1': 'prekeys', '3': 2, '4': 3, '5': 12, '10': 'prekeys'}, + {'1': 'prekeys', '3': 2, '4': 3, '5': 11, '6': '.server_to_client.Response.PreKey', '10': 'prekeys'}, {'1': 'public_identity_key', '3': 3, '4': 1, '5': 12, '9': 0, '10': 'publicIdentityKey', '17': true}, {'1': 'signed_prekey', '3': 4, '4': 1, '5': 12, '9': 1, '10': 'signedPrekey', '17': true}, {'1': 'signed_prekey_signature', '3': 5, '4': 1, '5': 12, '9': 2, '10': 'signedPrekeySignature', '17': true}, - {'1': 'signed_prekey_id', '3': 6, '4': 1, '5': 3, '9': 3, '10': 'signedPrekeyId', '17': true}, + {'1': 'registration_id', '3': 7, '4': 1, '5': 3, '9': 3, '10': 'registrationId', '17': true}, + {'1': 'signed_prekey_id', '3': 6, '4': 1, '5': 3, '9': 4, '10': 'signedPrekeyId', '17': true}, ], '8': [ {'1': '_public_identity_key'}, {'1': '_signed_prekey'}, {'1': '_signed_prekey_signature'}, + {'1': '_registration_id'}, {'1': '_signed_prekey_id'}, ], }; @@ -101,7 +112,8 @@ const Response_Ok$json = { {'1': 'None', '3': 1, '4': 1, '5': 8, '9': 0, '10': 'None'}, {'1': 'userid', '3': 2, '4': 1, '5': 12, '9': 0, '10': 'userid'}, {'1': 'challenge', '3': 3, '4': 1, '5': 12, '9': 0, '10': 'challenge'}, - {'1': 'userdata', '3': 4, '4': 1, '5': 11, '6': '.server_to_client.Response.UserData', '9': 0, '10': 'userdata'}, + {'1': 'uploadtoken', '3': 4, '4': 1, '5': 12, '9': 0, '10': 'uploadtoken'}, + {'1': 'userdata', '3': 5, '4': 1, '5': 11, '6': '.server_to_client.Response.UserData', '9': 0, '10': 'userdata'}, ], '8': [ {'1': 'Ok'}, @@ -111,15 +123,18 @@ const Response_Ok$json = { /// Descriptor for `Response`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List responseDescriptor = $convert.base64Decode( 'CghSZXNwb25zZRIvCgJvaxgBIAEoCzIdLnNlcnZlcl90b19jbGllbnQuUmVzcG9uc2UuT2tIAF' - 'ICb2sSKAoFZXJyb3IYAiABKA4yEC5lcnJvci5FcnJvckNvZGVIAFIFZXJyb3Ia4wIKCFVzZXJE' - 'YXRhEhcKB3VzZXJfaWQYASABKAxSBnVzZXJJZBIYCgdwcmVrZXlzGAIgAygMUgdwcmVrZXlzEj' - 'MKE3B1YmxpY19pZGVudGl0eV9rZXkYAyABKAxIAFIRcHVibGljSWRlbnRpdHlLZXmIAQESKAoN' - 'c2lnbmVkX3ByZWtleRgEIAEoDEgBUgxzaWduZWRQcmVrZXmIAQESOwoXc2lnbmVkX3ByZWtleV' - '9zaWduYXR1cmUYBSABKAxIAlIVc2lnbmVkUHJla2V5U2lnbmF0dXJliAEBEi0KEHNpZ25lZF9w' - 'cmVrZXlfaWQYBiABKANIA1IOc2lnbmVkUHJla2V5SWSIAQFCFgoUX3B1YmxpY19pZGVudGl0eV' - '9rZXlCEAoOX3NpZ25lZF9wcmVrZXlCGgoYX3NpZ25lZF9wcmVrZXlfc2lnbmF0dXJlQhMKEV9z' - 'aWduZWRfcHJla2V5X2lkGp0BCgJPaxIUCgROb25lGAEgASgISABSBE5vbmUSGAoGdXNlcmlkGA' - 'IgASgMSABSBnVzZXJpZBIeCgljaGFsbGVuZ2UYAyABKAxIAFIJY2hhbGxlbmdlEkEKCHVzZXJk' - 'YXRhGAQgASgLMiMuc2VydmVyX3RvX2NsaWVudC5SZXNwb25zZS5Vc2VyRGF0YUgAUgh1c2VyZG' - 'F0YUIECgJPa0IKCghSZXNwb25zZQ=='); + 'ICb2sSKAoFZXJyb3IYAiABKA4yEC5lcnJvci5FcnJvckNvZGVIAFIFZXJyb3IaMAoGUHJlS2V5' + 'Eg4KAmlkGAEgASgDUgJpZBIWCgZwcmVrZXkYAiABKAxSBnByZWtleRrIAwoIVXNlckRhdGESFw' + 'oHdXNlcl9pZBgBIAEoDFIGdXNlcklkEjsKB3ByZWtleXMYAiADKAsyIS5zZXJ2ZXJfdG9fY2xp' + 'ZW50LlJlc3BvbnNlLlByZUtleVIHcHJla2V5cxIzChNwdWJsaWNfaWRlbnRpdHlfa2V5GAMgAS' + 'gMSABSEXB1YmxpY0lkZW50aXR5S2V5iAEBEigKDXNpZ25lZF9wcmVrZXkYBCABKAxIAVIMc2ln' + 'bmVkUHJla2V5iAEBEjsKF3NpZ25lZF9wcmVrZXlfc2lnbmF0dXJlGAUgASgMSAJSFXNpZ25lZF' + 'ByZWtleVNpZ25hdHVyZYgBARIsCg9yZWdpc3RyYXRpb25faWQYByABKANIA1IOcmVnaXN0cmF0' + 'aW9uSWSIAQESLQoQc2lnbmVkX3ByZWtleV9pZBgGIAEoA0gEUg5zaWduZWRQcmVrZXlJZIgBAU' + 'IWChRfcHVibGljX2lkZW50aXR5X2tleUIQCg5fc2lnbmVkX3ByZWtleUIaChhfc2lnbmVkX3By' + 'ZWtleV9zaWduYXR1cmVCEgoQX3JlZ2lzdHJhdGlvbl9pZEITChFfc2lnbmVkX3ByZWtleV9pZB' + 'rBAQoCT2sSFAoETm9uZRgBIAEoCEgAUgROb25lEhgKBnVzZXJpZBgCIAEoDEgAUgZ1c2VyaWQS' + 'HgoJY2hhbGxlbmdlGAMgASgMSABSCWNoYWxsZW5nZRIiCgt1cGxvYWR0b2tlbhgEIAEoDEgAUg' + 't1cGxvYWR0b2tlbhJBCgh1c2VyZGF0YRgFIAEoCzIjLnNlcnZlcl90b19jbGllbnQuUmVzcG9u' + 'c2UuVXNlckRhdGFIAFIIdXNlcmRhdGFCBAoCT2tCCgoIUmVzcG9uc2U='); diff --git a/lib/src/providers/api_provider.dart b/lib/src/providers/api_provider.dart index ea0fd02..1f3ae1f 100644 --- a/lib/src/providers/api_provider.dart +++ b/lib/src/providers/api_provider.dart @@ -2,11 +2,14 @@ import 'dart:collection'; import 'dart:math'; import 'package:fixnum/fixnum.dart'; import 'package:flutter/material.dart'; +import 'package:libsignal_protocol_dart/libsignal_protocol_dart.dart'; import 'package:logging/logging.dart'; -import 'package:twonly/src/proto/api/client_to_server.pb.dart'; +import 'package:twonly/src/proto/api/client_to_server.pb.dart' as client; +import 'package:twonly/src/proto/api/client_to_server.pbserver.dart'; import 'package:twonly/src/proto/api/error.pb.dart'; import 'package:twonly/src/proto/api/server_to_client.pb.dart' as server; +import 'package:twonly/src/proto/api/server_to_client.pbserver.dart'; import 'package:twonly/src/signal/signal_helper.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:twonly/src/utils.dart'; @@ -103,9 +106,9 @@ class ApiProvider { void tryToReconnect() { Future.delayed(Duration(seconds: _reconnectionDelay)).then( (value) async { - _reconnectionDelay = _reconnectionDelay * 2; - if (_reconnectionDelay > 60 * 5) { - _reconnectionDelay = 60 * 5; + _reconnectionDelay = _reconnectionDelay + 2; + if (_reconnectionDelay > 20) { + _reconnectionDelay = 20; } await connect(); }, @@ -118,6 +121,7 @@ class ApiProvider { if (msg.v0.hasResponse()) { messagesV0[msg.v0.seq] = msg; } else { + _handleServerMessage(msg); log.shout("Got a new message from the server: $msg"); } } catch (e) { @@ -125,6 +129,34 @@ class ApiProvider { } } + Future _handleServerMessage(server.ServerToClient msg) async { + client.Response? response; + + if (msg.v0.requestNewPreKeys) { + List localPreKeys = await SignalHelper.getPreKeys(); + + List prekeysList = []; + for (int i = 0; i < localPreKeys.length; i++) { + prekeysList.add(client.Response_PreKey() + ..id = Int64(localPreKeys[i].id) + ..prekey = localPreKeys[i].getKeyPair().publicKey.serialize()); + } + var prekeys = client.Response_Prekeys(prekeys: prekeysList); + var ok = client.Response_Ok()..prekeys = prekeys; + response = client.Response()..ok = ok; + } + + if (response == null) return; + + var v0 = client.V0() + ..seq = msg.v0.seq + ..response = response; + var res = ClientToServer()..v0 = v0; + + final resBytes = res.writeToBuffer(); + _channel!.sink.add(resBytes); + } + Future _waitForResponse(Int64 seq) async { final startTime = DateTime.now(); @@ -162,7 +194,7 @@ class ApiProvider { } ClientToServer createClientToServerFromHandshake(Handshake handshake) { - var v0 = V0() + var v0 = client.V0() ..seq = Int64(0) ..handshake = handshake; return ClientToServer()..v0 = v0; @@ -170,7 +202,7 @@ class ApiProvider { ClientToServer createClientToServerFromApplicationData( ApplicationData applicationData) { - var v0 = V0() + var v0 = client.V0() ..seq = Int64(0) ..applicationdata = applicationData; return ClientToServer()..v0 = v0; @@ -218,9 +250,7 @@ class ApiProvider { } Future authenticate() async { - final reqSignal = await SignalHelper.getRegisterData(); - - if (reqSignal == null) { + if (await SignalHelper.getSignalIdentity() == null) { return; } @@ -271,19 +301,26 @@ class ApiProvider { } Future register(String username, String? inviteCode) async { - final reqSignal = await SignalHelper.getRegisterData(); - - if (reqSignal == null) { + final signalIdentity = await SignalHelper.getSignalIdentity(); + if (signalIdentity == null) { return Result.error( "There was an fatal error. Try reinstalling the app."); } + final signalStore = + await SignalHelper.getSignalStoreFromIdentity(signalIdentity); + + final signedPreKey = (await signalStore.loadSignedPreKeys())[0]; + log.shout("handle registrationId", signalIdentity.registrationId); + var register = Handshake_Register() ..username = username - ..publicIdentityKey = reqSignal["identityKey"] - ..signedPrekey = reqSignal["signedPreKey"]?["key"] - ..signedPrekeySignature = reqSignal["signedPreKey"]?["signature"] - ..signedPrekeyId = Int64(reqSignal["signedPreKey"]?["id"]); + ..publicIdentityKey = + (await signalStore.getIdentityKeyPair()).getPublicKey().serialize() + ..registrationId = Int64(signalIdentity.registrationId) + ..signedPrekey = signedPreKey.getKeyPair().publicKey.serialize() + ..signedPrekeySignature = signedPreKey.signature + ..signedPrekeyId = Int64(signedPreKey.id); if (inviteCode != null && inviteCode != "") { register.inviteCode = inviteCode; diff --git a/lib/src/providers/db_provider.dart b/lib/src/providers/db_provider.dart index f7ff2cd..12f971d 100644 --- a/lib/src/providers/db_provider.dart +++ b/lib/src/providers/db_provider.dart @@ -1,5 +1,7 @@ import 'dart:async'; +import 'dart:io'; import 'dart:math'; +import 'package:logging/logging.dart'; import 'package:twonly/src/model/identity_key_store_model.dart'; import 'package:twonly/src/model/model_constants.dart'; import 'package:twonly/src/model/pre_key_model.dart'; @@ -71,6 +73,10 @@ class DbProvider { await openPath(await fixPath(dbName)); } + Future remove() async { + await _createDb(db!); + } + Future fixPath(String path) async => path; Future close() async { diff --git a/lib/src/signal/connect_signed_pre_key_store.dart b/lib/src/signal/connect_signed_pre_key_store.dart index 7f9a8b4..7267475 100644 --- a/lib/src/signal/connect_signed_pre_key_store.dart +++ b/lib/src/signal/connect_signed_pre_key_store.dart @@ -16,6 +16,7 @@ class ConnectSignedPreKeyStore extends SignedPreKeyStore { return store; } final storeHashMap = json.decode(storeSerialized); + print(storeHashMap); for (final item in storeHashMap) { store[item[0]] = base64Decode(item[1]); } diff --git a/lib/src/signal/signal_helper.dart b/lib/src/signal/signal_helper.dart index 8788da7..7f8ccf3 100644 --- a/lib/src/signal/signal_helper.dart +++ b/lib/src/signal/signal_helper.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'dart:typed_data'; import 'package:libsignal_protocol_dart/libsignal_protocol_dart.dart'; import 'package:twonly/src/model/signal_identity_json.dart'; +import 'package:twonly/src/proto/api/server_to_client.pb.dart'; import 'package:twonly/src/utils.dart'; import 'connect_sender_key_store.dart'; @@ -39,58 +40,9 @@ class SignalDataModel { } } - // one to one implementation - Future buildSession( - String target, - Map remoteBundle, - ) async { - SignalProtocolAddress targetAddress = - SignalProtocolAddress(target, SignalHelper.defaultDeviceId); - SessionBuilder sessionBuilder = - SessionBuilder.fromSignalStore(signalStore, targetAddress); - PreKeyBundle temp = preKeyBundleFromJson(remoteBundle); - await sessionBuilder.processPreKeyBundle(temp); - } + // PreKeyBundle preKeyBundleFromJson(Map remoteBundle) { - PreKeyBundle preKeyBundleFromJson(Map remoteBundle) { - // One time pre key calculation - List tempPreKeys = remoteBundle["preKeys"]; - ECPublicKey? tempPrePublicKey; - int? tempPreKeyId; - if (tempPreKeys.isNotEmpty) { - tempPrePublicKey = Curve.decodePoint( - DjbECPublicKey(base64Decode(tempPreKeys.first['key'])).serialize(), - 1); - tempPreKeyId = remoteBundle["preKeys"].first['id']; - } - // Signed pre key calculation - int tempSignedPreKeyId = remoteBundle["signedPreKey"]['id']; - Map? tempSignedPreKey = remoteBundle["signedPreKey"]; - ECPublicKey? tempSignedPreKeyPublic; - Uint8List? tempSignedPreKeySignature; - if (tempSignedPreKey != null) { - tempSignedPreKeyPublic = Curve.decodePoint( - DjbECPublicKey(base64Decode(remoteBundle["signedPreKey"]['key'])) - .serialize(), - 1); - tempSignedPreKeySignature = - base64Decode(remoteBundle["signedPreKey"]['signature']); - } - // Identity key calculation - IdentityKey tempIdentityKey = IdentityKey(Curve.decodePoint( - DjbECPublicKey(base64Decode(remoteBundle["identityKey"])).serialize(), - 1)); - return PreKeyBundle( - remoteBundle['registrationId'], - 1, - tempPreKeyId, - tempPrePublicKey, - tempSignedPreKeyId, - tempSignedPreKeyPublic, - tempSignedPreKeySignature, - tempIdentityKey, - ); - } + // } Future getEncryptedText(String text, String target) async { try { @@ -136,62 +88,124 @@ class SignalDataModel { } } +int userIdToRegistrationId(List userId) { + int result = 0; + for (int i = 8; i < 16; i++) { + result = (result << 8) | userId[i]; + } + return result; +} + +String uint8ListToHex(List list) { + final StringBuffer hexBuffer = StringBuffer(); + for (int byte in list) { + hexBuffer.write(byte.toRadixString(16).padLeft(2, '0')); + } + return hexBuffer.toString().toUpperCase(); +} + class SignalHelper { static const int defaultDeviceId = 1; static Future getPrivateKey() async { - final storage = getSecureStorage(); - final signalIdentityJson = await storage.read(key: "signal_identity"); - if (signalIdentityJson == null) { + final signalIdentity = await getSignalIdentity(); + if (signalIdentity == null) { return null; } - final SignalIdentity signalIdentity = - SignalIdentity.fromJson(jsonDecode(signalIdentityJson)); - final IdentityKeyPair identityKeyPair = IdentityKeyPair.fromSerialized(signalIdentity.identityKeyPairU8List); return identityKeyPair.getPrivateKey(); } - static Future?> getRegisterData() async { - // final publicKey = identityKeyPair.getPublicKey().serialize(); + static Future addNewContact(Response_UserData userData) async { + final List userId = userData.userId; + + SignalProtocolAddress targetAddress = SignalProtocolAddress( + uint8ListToHex(userId), SignalHelper.defaultDeviceId); + + SignalProtocolStore? signalStore = await SignalHelper.getSignalStore(); + if (signalStore == null) { + return false; + } + + SessionBuilder sessionBuilder = + SessionBuilder.fromSignalStore(signalStore, targetAddress); + + ECPublicKey? tempPrePublicKey; + int? tempPreKeyId; + if (userData.prekeys.isNotEmpty) { + tempPrePublicKey = Curve.decodePoint( + DjbECPublicKey(Uint8List.fromList(userData.prekeys.first.prekey)) + .serialize(), + 1); + tempPreKeyId = userData.prekeys.first.id.toInt(); + } + // Signed pre key calculation + int tempSignedPreKeyId = userData.signedPrekeyId.toInt(); + // Map? tempSignedPreKey = remoteBundle["signedPreKey"]; + ECPublicKey? tempSignedPreKeyPublic; + Uint8List? tempSignedPreKeySignature; + // if (tempSignedPreKey != null) { + tempSignedPreKeyPublic = Curve.decodePoint( + DjbECPublicKey(Uint8List.fromList(userData.signedPrekey)).serialize(), + 1); + tempSignedPreKeySignature = + Uint8List.fromList(userData.signedPrekeySignature); + // } + // Identity key calculation + IdentityKey tempIdentityKey = IdentityKey(Curve.decodePoint( + DjbECPublicKey(Uint8List.fromList(userData.publicIdentityKey)) + .serialize(), + 1)); + PreKeyBundle preKeyBundle = PreKeyBundle( + userData.registrationId.toInt(), + 1, + tempPreKeyId, + tempPrePublicKey, + tempSignedPreKeyId, + tempSignedPreKeyPublic, + tempSignedPreKeySignature, + tempIdentityKey, + ); + + await sessionBuilder.processPreKeyBundle(preKeyBundle); + + return true; + } + + static Future getSignalStore() async { + return await getSignalStoreFromIdentity((await getSignalIdentity())!); + } + + static Future getSignalIdentity() async { final storage = getSecureStorage(); final signalIdentityJson = await storage.read(key: "signal_identity"); if (signalIdentityJson == null) { return null; } - final SignalIdentity signalIdentity = - SignalIdentity.fromJson(jsonDecode(signalIdentityJson)); + return SignalIdentity.fromJson(jsonDecode(signalIdentityJson)); + } + static Future getSignalStoreFromIdentity( + SignalIdentity signalIdentity) async { final IdentityKeyPair identityKeyPair = IdentityKeyPair.fromSerialized(signalIdentity.identityKeyPairU8List); - ConnectSignalProtocolStore signalStore = ConnectSignalProtocolStore( + return ConnectSignalProtocolStore( identityKeyPair, signalIdentity.registrationId); + } - final signedPreKey = (await signalStore.loadSignedPreKeys())[0]; - final Map req = {}; - req['registrationId'] = signalIdentity.registrationId; - req['identityKey'] = - (await signalStore.getIdentityKeyPair()).getPublicKey().serialize(); - - req['signedPreKey'] = { - 'id': signedPreKey.id, - 'signature': signedPreKey.signature, - 'key': signedPreKey.getKeyPair().publicKey.serialize(), - }; - // List pKeysList = []; - // for (PreKeyRecord pKey in preKeys) { - // Map pKeys = {}; - // pKeys['id'] = pKey.id; - // pKeys['key'] = base64Encode(pKey.getKeyPair().publicKey.serialize()); - // pKeysList.add(pKeys); - // } - // req['preKeys'] = pKeysList; - return req; + static Future> getPreKeys() async { + final preKeys = generatePreKeys(0, 200); + final signalStore = await getSignalStore(); + if (signalStore == null) return []; + for (final p in preKeys) { + await signalStore.preKeyStore.storePreKey(p.id, p); + } + return preKeys; } static Future createIfNotExistsSignalIdentity() async { @@ -208,14 +222,9 @@ class SignalHelper { ConnectSignalProtocolStore signalStore = ConnectSignalProtocolStore(identityKeyPair, registrationId); - final preKeys = generatePreKeys(0, 100); final signedPreKey = generateSignedPreKey(identityKeyPair, SignalHelper.defaultDeviceId); - for (final p in preKeys) { - await signalStore.preKeyStore.storePreKey(p.id, p); - } - await signalStore.signedPreKeyStore .storeSignedPreKey(signedPreKey.id, signedPreKey); diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 89b8a63..e0a4976 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -2,7 +2,9 @@ import 'dart:convert'; import 'dart:math'; import 'dart:typed_data'; import 'dart:ui'; +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; +import 'package:libsignal_protocol_dart/libsignal_protocol_dart.dart'; import 'package:logging/logging.dart'; import 'package:twonly/main.dart'; import 'package:twonly/src/signal/signal_helper.dart'; @@ -45,8 +47,10 @@ Future getUser() async { Future deleteLocalUserData() async { final storage = getSecureStorage(); - await storage.delete(key: "user_data"); - await storage.delete(key: "signal_identity"); + var password = await storage.read(key: "sqflite_database_password"); + await dbProvider.remove(); + await storage.write(key: "sqflite_database_password", value: password); + await storage.deleteAll(); return true; } @@ -61,11 +65,42 @@ Uint8List getRandomUint8List(int length) { return randomBytes; } +int userIdToRegistrationId(Uint8List userId) { + int result = 0; + for (int i = 8; i < 16; i++) { + result = (result << 8) | userId[i]; + } + return result; +} + +String uint8ListToHex(Uint8List list) { + final StringBuffer hexBuffer = StringBuffer(); + for (int byte in list) { + hexBuffer.write(byte.toRadixString(16).padLeft(2, '0')); + } + return hexBuffer.toString().toUpperCase(); +} + Future addNewUser(String username) async { final res = await apiProvider.getUserData(username); if (res.isSuccess) { - print("Found user: ${res.value}"); + print(res.value); + print(res.value.userdata.userId); + + await SignalHelper.addNewContact(res.value.userdata); + + // final Map req = {}; + // req['identityKey'] = + // (await signalStore.getIdentityKeyPair()).getPublicKey().serialize(); + + // req['signedPreKey'] = { + // 'id': signedPreKey.id, + // 'signature': signedPreKey.signature, + // 'key': signedPreKey.getKeyPair().publicKey.serialize(), + // }; + + print("Add new user: ${res}"); } return res.isSuccess; diff --git a/lib/src/views/register_view.dart b/lib/src/views/register_view.dart index 00232b3..f33bb44 100644 --- a/lib/src/views/register_view.dart +++ b/lib/src/views/register_view.dart @@ -1,3 +1,4 @@ +import 'package:twonly/main.dart'; import 'package:twonly/src/providers/api_provider.dart'; import '../utils.dart'; import 'package:flutter/material.dart'; @@ -123,6 +124,7 @@ class _RegisterViewState extends State { usernameController.text, inviteCodeController.text); setState(() { _isTryingToRegister = false; + apiProvider.authenticate(); }); if (res.isSuccess) { widget.callbackOnSuccess();