From c265e81118bd1835d8db204b44c34a25eaa149cc Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 25 May 2018 11:31:59 +0200 Subject: [PATCH] no message --- TelegramCore.xcodeproj/project.pbxproj | 6 + TelegramCore/Account.swift | 8 +- TelegramCore/Api0.swift | 73 +- TelegramCore/Api1.swift | 902 ++----------------- TelegramCore/Api2.swift | 257 +----- TelegramCore/Api3.swift | 256 +----- TelegramCore/Authorization.swift | 2 +- TelegramCore/Download.swift | 2 +- TelegramCore/GrantSecureIdAccess.swift | 9 +- TelegramCore/Network.swift | 4 +- TelegramCore/RequestSecureIdForm.swift | 20 +- TelegramCore/SaveSecureIdValue.swift | 19 +- TelegramCore/SecureFileMediaResource.swift | 3 +- TelegramCore/SecureIdDataTypes.swift | 4 +- TelegramCore/SecureIdValueContentError.swift | 4 +- TelegramCore/Serialization.swift | 2 +- TelegramCore/StoreMessage_Telegram.swift | 2 +- TelegramCore/TelegramMediaAction.swift | 8 +- TelegramCore/TermsOfService.swift | 29 + TelegramCore/TwoStepVerification.swift | 24 +- TelegramCore/VerifySecureIdValue.swift | 20 +- 21 files changed, 252 insertions(+), 1402 deletions(-) create mode 100644 TelegramCore/TermsOfService.swift diff --git a/TelegramCore.xcodeproj/project.pbxproj b/TelegramCore.xcodeproj/project.pbxproj index e205a9dd59..ef0f148910 100644 --- a/TelegramCore.xcodeproj/project.pbxproj +++ b/TelegramCore.xcodeproj/project.pbxproj @@ -350,6 +350,8 @@ D0642EFA1F3E05D700792790 /* EarliestUnseenPersonalMentionMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0642EF81F3E05D700792790 /* EarliestUnseenPersonalMentionMessage.swift */; }; D067066C1D512ADB00DED3E3 /* Postbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D06706671D512ADB00DED3E3 /* Postbox.framework */; }; D067066D1D512ADB00DED3E3 /* SwiftSignalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D06706681D512ADB00DED3E3 /* SwiftSignalKit.framework */; }; + D06ECFC220B77B8300C576C2 /* TermsOfService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06ECFC120B77B8300C576C2 /* TermsOfService.swift */; }; + D06ECFC320B77B8300C576C2 /* TermsOfService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06ECFC120B77B8300C576C2 /* TermsOfService.swift */; }; D07047B41F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07047B31F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift */; }; D07047B51F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07047B31F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift */; }; D07047B71F3DF2CD00F6A8D4 /* ManagedConsumePersonalMessagesActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07047B61F3DF2CD00F6A8D4 /* ManagedConsumePersonalMessagesActions.swift */; }; @@ -903,6 +905,7 @@ D06706671D512ADB00DED3E3 /* Postbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Postbox.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D06706681D512ADB00DED3E3 /* SwiftSignalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftSignalKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D067066E1D512AEB00DED3E3 /* MtProtoKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MtProtoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D06ECFC120B77B8300C576C2 /* TermsOfService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfService.swift; sourceTree = ""; }; D07047B31F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsumablePersonalMentionMessageAttribute.swift; sourceTree = ""; }; D07047B61F3DF2CD00F6A8D4 /* ManagedConsumePersonalMessagesActions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedConsumePersonalMessagesActions.swift; sourceTree = ""; }; D07047B91F3DF75500F6A8D4 /* ConsumePersonalMessageAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsumePersonalMessageAction.swift; sourceTree = ""; }; @@ -1468,6 +1471,7 @@ D0528E591E658B3600E2FEF5 /* ManagedLocalInputActivities.swift */, D099D7481EEF418D00A3128C /* HistoryViewChannelStateValidation.swift */, D0B1671C1F9EA2C300976B40 /* ChatHistoryPreloadManager.swift */, + D06ECFC120B77B8300C576C2 /* TermsOfService.swift */, ); name = Account; sourceTree = ""; @@ -2036,6 +2040,7 @@ D03B0CF71D62250800955575 /* TelegramMediaImage.swift in Sources */, D054648E20738626002ECC1E /* SecureIdDriversLicenseValue.swift in Sources */, C210DD621FBDB90800F673D8 /* SourceReferenceMessageAttribute.swift in Sources */, + D06ECFC220B77B8300C576C2 /* TermsOfService.swift in Sources */, D0E23DDF1E8082A400B9B6D2 /* ArchivedStickerPacks.swift in Sources */, D0546494207386D7002ECC1E /* SecureIdUtilityBillValue.swift in Sources */, D0BC386E1E3FDAB70044D6FE /* CreateGroup.swift in Sources */, @@ -2524,6 +2529,7 @@ D001F3E91E128A1C007A8C60 /* SecretChatState.swift in Sources */, D08F4A6A1E79CECB00A2AA15 /* ManagedSynchronizeInstalledStickerPacksOperations.swift in Sources */, D0B8444B1DAB91FD005F29E1 /* ManagedSynchronizePeerReadStates.swift in Sources */, + D06ECFC320B77B8300C576C2 /* TermsOfService.swift in Sources */, D0F8C39E20178B9B00236FC5 /* GroupFeedPeers.swift in Sources */, D073CE6C1DCBCF17007511FD /* TextEntitiesMessageAttribute.swift in Sources */, D03C53751DAD5CA9004C17B3 /* TelegramUserPresence.swift in Sources */, diff --git a/TelegramCore/Account.swift b/TelegramCore/Account.swift index 125aa923f5..911aa44bf5 100644 --- a/TelegramCore/Account.swift +++ b/TelegramCore/Account.swift @@ -358,10 +358,10 @@ public func twoStepAuthData(_ network: Network) -> Signal map { config -> TwoStepAuthData in switch config { - case let .noPassword(newSalt, newSecureSalt, secretRandom, emailUnconfirmedPattern): - return TwoStepAuthData(nextSalt: newSalt.makeData(), currentSalt: nil, hasRecovery: false, hasSecretValues: false, currentHint: nil, unconfirmedEmailPattern: emailUnconfirmedPattern, secretRandom: secretRandom.makeData(), nextSecureSalt: newSecureSalt.makeData()) - case let .password(flags, currentSalt, newSalt, newSecureSalt, secretRandom, hint, emailUnconfirmedPattern): - return TwoStepAuthData(nextSalt: newSalt.makeData(), currentSalt: currentSalt.makeData(), hasRecovery: (flags & (1 << 0)) != 0, hasSecretValues: (flags & (1 << 1)) != 0, currentHint: hint, unconfirmedEmailPattern: emailUnconfirmedPattern, secretRandom: secretRandom.makeData(), nextSecureSalt: newSecureSalt.makeData()) + case let .noPassword(newSalt, emailUnconfirmedPattern): + return TwoStepAuthData(nextSalt: newSalt.makeData(), currentSalt: nil, hasRecovery: false, hasSecretValues: false, currentHint: nil, unconfirmedEmailPattern: emailUnconfirmedPattern, secretRandom: Data(), nextSecureSalt: Data()) + case let .password(currentSalt, newSalt, hint, hasRecovery, emailUnconfirmedPattern): + return TwoStepAuthData(nextSalt: newSalt.makeData(), currentSalt: currentSalt.makeData(), hasRecovery: hasRecovery == .boolTrue, hasSecretValues: false, currentHint: hint, unconfirmedEmailPattern: emailUnconfirmedPattern, secretRandom: Data(), nextSecureSalt: Data()) } } } diff --git a/TelegramCore/Api0.swift b/TelegramCore/Api0.swift index b2a6617397..d8f680926a 100644 --- a/TelegramCore/Api0.swift +++ b/TelegramCore/Api0.swift @@ -75,7 +75,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-292807034] = { return Api.InputChannel.parse_inputChannelEmpty($0) } dict[-1343524562] = { return Api.InputChannel.parse_inputChannel($0) } dict[414687501] = { return Api.DcOption.parse_dcOption($0) } - dict[2077869041] = { return Api.account.PasswordSettings.parse_passwordSettings($0) } + dict[-1212732749] = { return Api.account.PasswordSettings.parse_passwordSettings($0) } dict[292985073] = { return Api.LangPackLanguage.parse_langPackLanguage($0) } dict[-1987579119] = { return Api.help.AppUpdate.parse_appUpdate($0) } dict[-1000708810] = { return Api.help.AppUpdate.parse_noAppUpdate($0) } @@ -214,8 +214,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1358175439] = { return Api.KeyboardButton.parse_keyboardButtonGame($0) } dict[-1344716869] = { return Api.KeyboardButton.parse_keyboardButtonBuy($0) } dict[-748155807] = { return Api.ContactStatus.parse_contactStatus($0) } - dict[1679398724] = { return Api.SecureFile.parse_secureFileEmpty($0) } - dict[-534283678] = { return Api.SecureFile.parse_secureFile($0) } dict[236446268] = { return Api.PhotoSize.parse_photoSizeEmpty($0) } dict[2009052699] = { return Api.PhotoSize.parse_photoSize($0) } dict[-374917894] = { return Api.PhotoSize.parse_photoCachedSize($0) } @@ -267,7 +265,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1928391342] = { return Api.InputDocument.parse_inputDocumentEmpty($0) } dict[410618194] = { return Api.InputDocument.parse_inputDocument($0) } dict[2131196633] = { return Api.contacts.ResolvedPeer.parse_resolvedPeer($0) } - dict[-1964327229] = { return Api.SecureData.parse_secureData($0) } dict[-1771768449] = { return Api.InputMedia.parse_inputMediaEmpty($0) } dict[-104578748] = { return Api.InputMedia.parse_inputMediaGeoPoint($0) } dict[-1494984313] = { return Api.InputMedia.parse_inputMediaContact($0) } @@ -325,16 +322,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-526508104] = { return Api.help.ProxyData.parse_proxyDataEmpty($0) } dict[737668643] = { return Api.help.ProxyData.parse_proxyDataPromo($0) } dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) } - dict[2103482845] = { return Api.SecurePlainData.parse_securePlainPhone($0) } - dict[569137759] = { return Api.SecurePlainData.parse_securePlainEmail($0) } dict[-1269012015] = { return Api.messages.AffectedHistory.parse_affectedHistory($0) } - dict[570402317] = { return Api.account.PasswordInputSettings.parse_passwordInputSettings($0) } + dict[-2037289493] = { return Api.account.PasswordInputSettings.parse_passwordInputSettings($0) } dict[649453030] = { return Api.messages.MessageEditData.parse_messageEditData($0) } dict[-886477832] = { return Api.LabeledPrice.parse_labeledPrice($0) } dict[-438840932] = { return Api.messages.ChatFull.parse_chatFull($0) } - dict[108557032] = { return Api.InputSecureValue.parse_inputSecureValue($0) } - dict[1722786150] = { return Api.help.DeepLinkInfo.parse_deepLinkInfoEmpty($0) } - dict[1783556146] = { return Api.help.DeepLinkInfo.parse_deepLinkInfo($0) } dict[-313079300] = { return Api.account.WebAuthorizations.parse_webAuthorizations($0) } dict[-236044656] = { return Api.help.TermsOfService.parse_termsOfService($0) } dict[1490799288] = { return Api.ReportReason.parse_inputReportReasonSpam($0) } @@ -345,15 +337,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1169445179] = { return Api.DraftMessage.parse_draftMessageEmpty($0) } dict[-40996577] = { return Api.DraftMessage.parse_draftMessage($0) } dict[1568467877] = { return Api.ChannelAdminRights.parse_channelAdminRights($0) } - dict[-2128640689] = { return Api.account.SentEmailCode.parse_sentEmailCode($0) } dict[-1038136962] = { return Api.EncryptedFile.parse_encryptedFileEmpty($0) } dict[1248893260] = { return Api.EncryptedFile.parse_encryptedFile($0) } - dict[-391902247] = { return Api.SecureValueError.parse_secureValueErrorData($0) } - dict[12467706] = { return Api.SecureValueError.parse_secureValueErrorFrontSide($0) } - dict[-2037765467] = { return Api.SecureValueError.parse_secureValueErrorReverseSide($0) } - dict[-449327402] = { return Api.SecureValueError.parse_secureValueErrorSelfie($0) } - dict[2054162547] = { return Api.SecureValueError.parse_secureValueErrorFile($0) } - dict[1717706985] = { return Api.SecureValueError.parse_secureValueErrorFiles($0) } dict[1489977929] = { return Api.ChannelBannedRights.parse_channelBannedRights($0) } dict[-1613493288] = { return Api.NotifyPeer.parse_notifyPeer($0) } dict[-1261946036] = { return Api.NotifyPeer.parse_notifyUsers($0) } @@ -369,8 +354,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1493171408] = { return Api.HighScore.parse_highScore($0) } dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) } dict[986597452] = { return Api.contacts.Link.parse_link($0) } - dict[-1263225191] = { return Api.SecureValue.parse_secureValue($0) } - dict[-316748368] = { return Api.SecureValueHash.parse_secureValueHash($0) } dict[1444661369] = { return Api.ContactBlocked.parse_contactBlocked($0) } dict[-2128698738] = { return Api.auth.CheckedPhone.parse_checkedPhone($0) } dict[-1182234929] = { return Api.InputUser.parse_inputUserEmpty($0) } @@ -378,7 +361,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-668391402] = { return Api.InputUser.parse_inputUser($0) } dict[-1908433218] = { return Api.Page.parse_pagePart($0) } dict[1433323434] = { return Api.Page.parse_pageFull($0) } - dict[871426631] = { return Api.SecureCredentialsEncrypted.parse_secureCredentialsEncrypted($0) } dict[157948117] = { return Api.upload.File.parse_file($0) } dict[-242427324] = { return Api.upload.File.parse_fileCdnRedirect($0) } dict[182649427] = { return Api.MessageRange.parse_messageRange($0) } @@ -464,7 +446,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[342061462] = { return Api.InputFileLocation.parse_inputFileLocation($0) } dict[-182231723] = { return Api.InputFileLocation.parse_inputEncryptedFileLocation($0) } dict[1125058340] = { return Api.InputFileLocation.parse_inputDocumentFileLocation($0) } - dict[-876089816] = { return Api.InputFileLocation.parse_inputSecureFileLocation($0) } dict[286776671] = { return Api.GeoPoint.parse_geoPointEmpty($0) } dict[541710092] = { return Api.GeoPoint.parse_geoPoint($0) } dict[506920429] = { return Api.InputPhoneCall.parse_inputPhoneCall($0) } @@ -476,8 +457,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[178373535] = { return Api.InputPaymentCredentials.parse_inputPaymentCredentialsApplePay($0) } dict[-905587442] = { return Api.InputPaymentCredentials.parse_inputPaymentCredentialsAndroidPay($0) } dict[-1239335713] = { return Api.ShippingOption.parse_shippingOption($0) } - dict[859091184] = { return Api.InputSecureFile.parse_inputSecureFileUploaded($0) } - dict[1399317950] = { return Api.InputSecureFile.parse_inputSecureFile($0) } dict[512535275] = { return Api.PostAddress.parse_postAddress($0) } dict[2104790276] = { return Api.DataJSON.parse_dataJSON($0) } dict[1251549527] = { return Api.InputStickeredMedia.parse_inputStickeredMediaPhoto($0) } @@ -501,6 +480,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1816636575] = { return Api.LangPackString.parse_langPackStringPluralized($0) } dict[695856818] = { return Api.LangPackString.parse_langPackStringDeleted($0) } dict[-1036396922] = { return Api.InputWebFileLocation.parse_inputWebFileLocation($0) } + dict[1713855074] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) } + dict[1430205163] = { return Api.InputWebFileLocation.parse_inputWebFileGeoMessageLocation($0) } dict[1436466797] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) } dict[398898678] = { return Api.help.Support.parse_support($0) } dict[1474492012] = { return Api.MessagesFilter.parse_inputMessagesFilterEmpty($0) } @@ -536,28 +517,14 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-209768682] = { return Api.messages.FavedStickers.parse_favedStickers($0) } dict[1776236393] = { return Api.ExportedChatInvite.parse_chatInviteEmpty($0) } dict[-64092740] = { return Api.ExportedChatInvite.parse_chatInviteExported($0) } - dict[-879268525] = { return Api.account.AuthorizationForm.parse_authorizationForm($0) } dict[2079516406] = { return Api.Authorization.parse_authorization($0) } dict[-1361650766] = { return Api.MaskCoords.parse_maskCoords($0) } dict[-395967805] = { return Api.messages.AllStickers.parse_allStickersNotModified($0) } dict[-302170017] = { return Api.messages.AllStickers.parse_allStickers($0) } dict[-1655957568] = { return Api.PhoneConnection.parse_phoneConnection($0) } dict[-1194283041] = { return Api.AccountDaysTTL.parse_accountDaysTTL($0) } - dict[-1658158621] = { return Api.SecureValueType.parse_secureValueTypePersonalDetails($0) } - dict[1034709504] = { return Api.SecureValueType.parse_secureValueTypePassport($0) } - dict[115615172] = { return Api.SecureValueType.parse_secureValueTypeDriverLicense($0) } - dict[-1596951477] = { return Api.SecureValueType.parse_secureValueTypeIdentityCard($0) } - dict[-1717268701] = { return Api.SecureValueType.parse_secureValueTypeInternalPassport($0) } - dict[-874308058] = { return Api.SecureValueType.parse_secureValueTypeAddress($0) } - dict[-63531698] = { return Api.SecureValueType.parse_secureValueTypeUtilityBill($0) } - dict[-1995211763] = { return Api.SecureValueType.parse_secureValueTypeBankStatement($0) } - dict[-1954007928] = { return Api.SecureValueType.parse_secureValueTypeRentalAgreement($0) } - dict[-1713143702] = { return Api.SecureValueType.parse_secureValueTypePassportRegistration($0) } - dict[-368907213] = { return Api.SecureValueType.parse_secureValueTypeTemporaryRegistration($0) } - dict[-1289704741] = { return Api.SecureValueType.parse_secureValueTypePhone($0) } - dict[-1908627474] = { return Api.SecureValueType.parse_secureValueTypeEmail($0) } - dict[1587643126] = { return Api.account.Password.parse_noPassword($0) } - dict[-902187961] = { return Api.account.Password.parse_password($0) } + dict[-1764049896] = { return Api.account.Password.parse_noPassword($0) } + dict[2081952796] = { return Api.account.Password.parse_password($0) } dict[-1462213465] = { return Api.InputBotInlineResult.parse_inputBotInlineResultPhoto($0) } dict[-459324] = { return Api.InputBotInlineResult.parse_inputBotInlineResultDocument($0) } dict[1336154098] = { return Api.InputBotInlineResult.parse_inputBotInlineResultGame($0) } @@ -589,8 +556,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1200788123] = { return Api.MessageAction.parse_messageActionScreenshotTaken($0) } dict[-85549226] = { return Api.MessageAction.parse_messageActionCustomAction($0) } dict[-1410748418] = { return Api.MessageAction.parse_messageActionBotAllowed($0) } - dict[455635795] = { return Api.MessageAction.parse_messageActionSecureValuesSentMe($0) } - dict[-648257196] = { return Api.MessageAction.parse_messageActionSecureValuesSent($0) } dict[1399245077] = { return Api.PhoneCall.parse_phoneCallEmpty($0) } dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) } dict[-2089411356] = { return Api.PhoneCall.parse_phoneCallRequested($0) } @@ -800,8 +765,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.ContactStatus: _1.serialize(buffer, boxed) - case let _1 as Api.SecureFile: - _1.serialize(buffer, boxed) case let _1 as Api.PhotoSize: _1.serialize(buffer, boxed) case let _1 as Api.messages.Stickers: @@ -846,8 +809,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.contacts.ResolvedPeer: _1.serialize(buffer, boxed) - case let _1 as Api.SecureData: - _1.serialize(buffer, boxed) case let _1 as Api.InputMedia: _1.serialize(buffer, boxed) case let _1 as Api.InputPeer: @@ -878,8 +839,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.auth.ExportedAuthorization: _1.serialize(buffer, boxed) - case let _1 as Api.SecurePlainData: - _1.serialize(buffer, boxed) case let _1 as Api.messages.AffectedHistory: _1.serialize(buffer, boxed) case let _1 as Api.account.PasswordInputSettings: @@ -890,10 +849,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.messages.ChatFull: _1.serialize(buffer, boxed) - case let _1 as Api.InputSecureValue: - _1.serialize(buffer, boxed) - case let _1 as Api.help.DeepLinkInfo: - _1.serialize(buffer, boxed) case let _1 as Api.account.WebAuthorizations: _1.serialize(buffer, boxed) case let _1 as Api.help.TermsOfService: @@ -906,12 +861,8 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.ChannelAdminRights: _1.serialize(buffer, boxed) - case let _1 as Api.account.SentEmailCode: - _1.serialize(buffer, boxed) case let _1 as Api.EncryptedFile: _1.serialize(buffer, boxed) - case let _1 as Api.SecureValueError: - _1.serialize(buffer, boxed) case let _1 as Api.ChannelBannedRights: _1.serialize(buffer, boxed) case let _1 as Api.NotifyPeer: @@ -928,10 +879,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.contacts.Link: _1.serialize(buffer, boxed) - case let _1 as Api.SecureValue: - _1.serialize(buffer, boxed) - case let _1 as Api.SecureValueHash: - _1.serialize(buffer, boxed) case let _1 as Api.ContactBlocked: _1.serialize(buffer, boxed) case let _1 as Api.auth.CheckedPhone: @@ -940,8 +887,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.Page: _1.serialize(buffer, boxed) - case let _1 as Api.SecureCredentialsEncrypted: - _1.serialize(buffer, boxed) case let _1 as Api.upload.File: _1.serialize(buffer, boxed) case let _1 as Api.MessageRange: @@ -1032,8 +977,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.ShippingOption: _1.serialize(buffer, boxed) - case let _1 as Api.InputSecureFile: - _1.serialize(buffer, boxed) case let _1 as Api.PostAddress: _1.serialize(buffer, boxed) case let _1 as Api.DataJSON: @@ -1082,8 +1025,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.ExportedChatInvite: _1.serialize(buffer, boxed) - case let _1 as Api.account.AuthorizationForm: - _1.serialize(buffer, boxed) case let _1 as Api.Authorization: _1.serialize(buffer, boxed) case let _1 as Api.MaskCoords: @@ -1094,8 +1035,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.AccountDaysTTL: _1.serialize(buffer, boxed) - case let _1 as Api.SecureValueType: - _1.serialize(buffer, boxed) case let _1 as Api.account.Password: _1.serialize(buffer, boxed) case let _1 as Api.InputBotInlineResult: diff --git a/TelegramCore/Api1.swift b/TelegramCore/Api1.swift index 2a42faaf3c..d7939e8f44 100644 --- a/TelegramCore/Api1.swift +++ b/TelegramCore/Api1.swift @@ -4664,67 +4664,6 @@ public extension Api { } } - } - public enum SecureFile { - case secureFileEmpty - case secureFile(id: Int64, accessHash: Int64, size: Int32, dcId: Int32, date: Int32, fileHash: Buffer, secret: Buffer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureFileEmpty: - if boxed { - buffer.appendInt32(1679398724) - } - - break - case .secureFile(let id, let accessHash, let size, let dcId, let date, let fileHash, let secret): - if boxed { - buffer.appendInt32(-534283678) - } - serializeInt64(id, buffer: buffer, boxed: false) - serializeInt64(accessHash, buffer: buffer, boxed: false) - serializeInt32(size, buffer: buffer, boxed: false) - serializeInt32(dcId, buffer: buffer, boxed: false) - serializeInt32(date, buffer: buffer, boxed: false) - serializeBytes(fileHash, buffer: buffer, boxed: false) - serializeBytes(secret, buffer: buffer, boxed: false) - break - } - } - - static func parse_secureFileEmpty(_ reader: BufferReader) -> SecureFile? { - return Api.SecureFile.secureFileEmpty - } - static func parse_secureFile(_ reader: BufferReader) -> SecureFile? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int64? - _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() - var _6: Buffer? - _6 = parseBytes(reader) - var _7: Buffer? - _7 = parseBytes(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = _7 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { - return Api.SecureFile.secureFile(id: _1!, accessHash: _2!, size: _3!, dcId: _4!, date: _5!, fileHash: _6!, secret: _7!) - } - else { - return nil - } - } - } public enum PhotoSize { case photoSizeEmpty(type: String) @@ -5797,41 +5736,6 @@ public extension Api { } } - } - public enum SecureData { - case secureData(data: Buffer, dataHash: Buffer, secret: Buffer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureData(let data, let dataHash, let secret): - if boxed { - buffer.appendInt32(-1964327229) - } - serializeBytes(data, buffer: buffer, boxed: false) - serializeBytes(dataHash, buffer: buffer, boxed: false) - serializeBytes(secret, buffer: buffer, boxed: false) - break - } - } - - static func parse_secureData(_ reader: BufferReader) -> SecureData? { - var _1: Buffer? - _1 = parseBytes(reader) - var _2: Buffer? - _2 = parseBytes(reader) - var _3: Buffer? - _3 = parseBytes(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureData.secureData(data: _1!, dataHash: _2!, secret: _3!) - } - else { - return nil - } - } - } public enum InputMedia { case inputMediaEmpty @@ -7032,51 +6936,6 @@ public extension Api { } } - } - public enum SecurePlainData { - case securePlainPhone(phone: String) - case securePlainEmail(email: String) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .securePlainPhone(let phone): - if boxed { - buffer.appendInt32(2103482845) - } - serializeString(phone, buffer: buffer, boxed: false) - break - case .securePlainEmail(let email): - if boxed { - buffer.appendInt32(569137759) - } - serializeString(email, buffer: buffer, boxed: false) - break - } - } - - static func parse_securePlainPhone(_ reader: BufferReader) -> SecurePlainData? { - var _1: String? - _1 = parseString(reader) - let _c1 = _1 != nil - if _c1 { - return Api.SecurePlainData.securePlainPhone(phone: _1!) - } - else { - return nil - } - } - static func parse_securePlainEmail(_ reader: BufferReader) -> SecurePlainData? { - var _1: String? - _1 = parseString(reader) - let _c1 = _1 != nil - if _c1 { - return Api.SecurePlainData.securePlainEmail(email: _1!) - } - else { - return nil - } - } - } public enum LabeledPrice { case labeledPrice(label: String, amount: Int64) @@ -7108,79 +6967,6 @@ public extension Api { } } - } - public enum InputSecureValue { - case inputSecureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, frontSide: Api.InputSecureFile?, reverseSide: Api.InputSecureFile?, selfie: Api.InputSecureFile?, files: [Api.InputSecureFile]?, plainData: Api.SecurePlainData?) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .inputSecureValue(let flags, let type, let data, let frontSide, let reverseSide, let selfie, let files, let plainData): - if boxed { - buffer.appendInt32(108557032) - } - serializeInt32(flags, buffer: buffer, boxed: false) - type.serialize(buffer, true) - if Int(flags) & Int(1 << 0) != 0 {data!.serialize(buffer, true)} - if Int(flags) & Int(1 << 1) != 0 {frontSide!.serialize(buffer, true)} - if Int(flags) & Int(1 << 2) != 0 {reverseSide!.serialize(buffer, true)} - if Int(flags) & Int(1 << 3) != 0 {selfie!.serialize(buffer, true)} - if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261) - buffer.appendInt32(Int32(files!.count)) - for item in files! { - item.serialize(buffer, true) - }} - if Int(flags) & Int(1 << 5) != 0 {plainData!.serialize(buffer, true)} - break - } - } - - static func parse_inputSecureValue(_ reader: BufferReader) -> InputSecureValue? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.SecureValueType? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _3: Api.SecureData? - if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.SecureData - } } - var _4: Api.InputSecureFile? - if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { - _4 = Api.parse(reader, signature: signature) as? Api.InputSecureFile - } } - var _5: Api.InputSecureFile? - if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { - _5 = Api.parse(reader, signature: signature) as? Api.InputSecureFile - } } - var _6: Api.InputSecureFile? - if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { - _6 = Api.parse(reader, signature: signature) as? Api.InputSecureFile - } } - var _7: [Api.InputSecureFile]? - if Int(_1!) & Int(1 << 4) != 0 {if let _ = reader.readInt32() { - _7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputSecureFile.self) - } } - var _8: Api.SecurePlainData? - if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() { - _8 = Api.parse(reader, signature: signature) as? Api.SecurePlainData - } } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil - let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil - let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil - let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil - let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil - let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.InputSecureValue.inputSecureValue(flags: _1!, type: _2!, data: _3, frontSide: _4, reverseSide: _5, selfie: _6, files: _7, plainData: _8) - } - else { - return nil - } - } - } public enum ReportReason { case inputReportReasonSpam @@ -7408,193 +7194,6 @@ public extension Api { } } - } - public enum SecureValueError { - case secureValueErrorData(type: Api.SecureValueType, dataHash: Buffer, field: String, text: String) - case secureValueErrorFrontSide(type: Api.SecureValueType, fileHash: Buffer, text: String) - case secureValueErrorReverseSide(type: Api.SecureValueType, fileHash: Buffer, text: String) - case secureValueErrorSelfie(type: Api.SecureValueType, fileHash: Buffer, text: String) - case secureValueErrorFile(type: Api.SecureValueType, fileHash: Buffer, text: String) - case secureValueErrorFiles(type: Api.SecureValueType, fileHash: [Buffer], text: String) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureValueErrorData(let type, let dataHash, let field, let text): - if boxed { - buffer.appendInt32(-391902247) - } - type.serialize(buffer, true) - serializeBytes(dataHash, buffer: buffer, boxed: false) - serializeString(field, buffer: buffer, boxed: false) - serializeString(text, buffer: buffer, boxed: false) - break - case .secureValueErrorFrontSide(let type, let fileHash, let text): - if boxed { - buffer.appendInt32(12467706) - } - type.serialize(buffer, true) - serializeBytes(fileHash, buffer: buffer, boxed: false) - serializeString(text, buffer: buffer, boxed: false) - break - case .secureValueErrorReverseSide(let type, let fileHash, let text): - if boxed { - buffer.appendInt32(-2037765467) - } - type.serialize(buffer, true) - serializeBytes(fileHash, buffer: buffer, boxed: false) - serializeString(text, buffer: buffer, boxed: false) - break - case .secureValueErrorSelfie(let type, let fileHash, let text): - if boxed { - buffer.appendInt32(-449327402) - } - type.serialize(buffer, true) - serializeBytes(fileHash, buffer: buffer, boxed: false) - serializeString(text, buffer: buffer, boxed: false) - break - case .secureValueErrorFile(let type, let fileHash, let text): - if boxed { - buffer.appendInt32(2054162547) - } - type.serialize(buffer, true) - serializeBytes(fileHash, buffer: buffer, boxed: false) - serializeString(text, buffer: buffer, boxed: false) - break - case .secureValueErrorFiles(let type, let fileHash, let text): - if boxed { - buffer.appendInt32(1717706985) - } - type.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(fileHash.count)) - for item in fileHash { - serializeBytes(item, buffer: buffer, boxed: false) - } - serializeString(text, buffer: buffer, boxed: false) - break - } - } - - static func parse_secureValueErrorData(_ reader: BufferReader) -> SecureValueError? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: Buffer? - _2 = parseBytes(reader) - var _3: String? - _3 = parseString(reader) - var _4: String? - _4 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.SecureValueError.secureValueErrorData(type: _1!, dataHash: _2!, field: _3!, text: _4!) - } - else { - return nil - } - } - static func parse_secureValueErrorFrontSide(_ reader: BufferReader) -> SecureValueError? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: Buffer? - _2 = parseBytes(reader) - var _3: String? - _3 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureValueError.secureValueErrorFrontSide(type: _1!, fileHash: _2!, text: _3!) - } - else { - return nil - } - } - static func parse_secureValueErrorReverseSide(_ reader: BufferReader) -> SecureValueError? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: Buffer? - _2 = parseBytes(reader) - var _3: String? - _3 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureValueError.secureValueErrorReverseSide(type: _1!, fileHash: _2!, text: _3!) - } - else { - return nil - } - } - static func parse_secureValueErrorSelfie(_ reader: BufferReader) -> SecureValueError? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: Buffer? - _2 = parseBytes(reader) - var _3: String? - _3 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureValueError.secureValueErrorSelfie(type: _1!, fileHash: _2!, text: _3!) - } - else { - return nil - } - } - static func parse_secureValueErrorFile(_ reader: BufferReader) -> SecureValueError? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: Buffer? - _2 = parseBytes(reader) - var _3: String? - _3 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureValueError.secureValueErrorFile(type: _1!, fileHash: _2!, text: _3!) - } - else { - return nil - } - } - static func parse_secureValueErrorFiles(_ reader: BufferReader) -> SecureValueError? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: [Buffer]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: -1255641564, elementType: Buffer.self) - } - var _3: String? - _3 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureValueError.secureValueErrorFiles(type: _1!, fileHash: _2!, text: _3!) - } - else { - return nil - } - } - } public enum ChannelBannedRights { case channelBannedRights(flags: Int32, untilDate: Int32) @@ -7879,116 +7478,6 @@ public extension Api { } } - } - public enum SecureValue { - case secureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, frontSide: Api.SecureFile?, reverseSide: Api.SecureFile?, selfie: Api.SecureFile?, files: [Api.SecureFile]?, plainData: Api.SecurePlainData?, hash: Buffer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureValue(let flags, let type, let data, let frontSide, let reverseSide, let selfie, let files, let plainData, let hash): - if boxed { - buffer.appendInt32(-1263225191) - } - serializeInt32(flags, buffer: buffer, boxed: false) - type.serialize(buffer, true) - if Int(flags) & Int(1 << 0) != 0 {data!.serialize(buffer, true)} - if Int(flags) & Int(1 << 1) != 0 {frontSide!.serialize(buffer, true)} - if Int(flags) & Int(1 << 2) != 0 {reverseSide!.serialize(buffer, true)} - if Int(flags) & Int(1 << 3) != 0 {selfie!.serialize(buffer, true)} - if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261) - buffer.appendInt32(Int32(files!.count)) - for item in files! { - item.serialize(buffer, true) - }} - if Int(flags) & Int(1 << 5) != 0 {plainData!.serialize(buffer, true)} - serializeBytes(hash, buffer: buffer, boxed: false) - break - } - } - - static func parse_secureValue(_ reader: BufferReader) -> SecureValue? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.SecureValueType? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _3: Api.SecureData? - if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.SecureData - } } - var _4: Api.SecureFile? - if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { - _4 = Api.parse(reader, signature: signature) as? Api.SecureFile - } } - var _5: Api.SecureFile? - if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { - _5 = Api.parse(reader, signature: signature) as? Api.SecureFile - } } - var _6: Api.SecureFile? - if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { - _6 = Api.parse(reader, signature: signature) as? Api.SecureFile - } } - var _7: [Api.SecureFile]? - if Int(_1!) & Int(1 << 4) != 0 {if let _ = reader.readInt32() { - _7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureFile.self) - } } - var _8: Api.SecurePlainData? - if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() { - _8 = Api.parse(reader, signature: signature) as? Api.SecurePlainData - } } - var _9: Buffer? - _9 = parseBytes(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil - let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil - let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil - let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil - let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil - let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil - let _c9 = _9 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 { - return Api.SecureValue.secureValue(flags: _1!, type: _2!, data: _3, frontSide: _4, reverseSide: _5, selfie: _6, files: _7, plainData: _8, hash: _9!) - } - else { - return nil - } - } - - } - public enum SecureValueHash { - case secureValueHash(type: Api.SecureValueType, hash: Buffer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureValueHash(let type, let hash): - if boxed { - buffer.appendInt32(-316748368) - } - type.serialize(buffer, true) - serializeBytes(hash, buffer: buffer, boxed: false) - break - } - } - - static func parse_secureValueHash(_ reader: BufferReader) -> SecureValueHash? { - var _1: Api.SecureValueType? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.SecureValueType - } - var _2: Buffer? - _2 = parseBytes(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.SecureValueHash.secureValueHash(type: _1!, hash: _2!) - } - else { - return nil - } - } - } public enum ContactBlocked { case contactBlocked(userId: Int32, date: Int32) @@ -8168,41 +7657,6 @@ public extension Api { } } - } - public enum SecureCredentialsEncrypted { - case secureCredentialsEncrypted(data: Buffer, hash: Buffer, secret: Buffer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureCredentialsEncrypted(let data, let hash, let secret): - if boxed { - buffer.appendInt32(871426631) - } - serializeBytes(data, buffer: buffer, boxed: false) - serializeBytes(hash, buffer: buffer, boxed: false) - serializeBytes(secret, buffer: buffer, boxed: false) - break - } - } - - static func parse_secureCredentialsEncrypted(_ reader: BufferReader) -> SecureCredentialsEncrypted? { - var _1: Buffer? - _1 = parseBytes(reader) - var _2: Buffer? - _2 = parseBytes(reader) - var _3: Buffer? - _3 = parseBytes(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.SecureCredentialsEncrypted.secureCredentialsEncrypted(data: _1!, hash: _2!, secret: _3!) - } - else { - return nil - } - } - } public enum MessageRange { case messageRange(minId: Int32, maxId: Int32) @@ -10277,7 +9731,6 @@ public extension Api { case inputFileLocation(volumeId: Int64, localId: Int32, secret: Int64) case inputEncryptedFileLocation(id: Int64, accessHash: Int64) case inputDocumentFileLocation(id: Int64, accessHash: Int64, version: Int32) - case inputSecureFileLocation(id: Int64, accessHash: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -10304,13 +9757,6 @@ public extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(version, buffer: buffer, boxed: false) break - case .inputSecureFileLocation(let id, let accessHash): - if boxed { - buffer.appendInt32(-876089816) - } - serializeInt64(id, buffer: buffer, boxed: false) - serializeInt64(accessHash, buffer: buffer, boxed: false) - break } } @@ -10362,20 +9808,6 @@ public extension Api { return nil } } - static func parse_inputSecureFileLocation(_ reader: BufferReader) -> InputFileLocation? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int64? - _2 = reader.readInt64() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.InputFileLocation.inputSecureFileLocation(id: _1!, accessHash: _2!) - } - else { - return nil - } - } } public enum GeoPoint { @@ -10689,71 +10121,6 @@ public extension Api { } } - } - public enum InputSecureFile { - case inputSecureFileUploaded(id: Int64, parts: Int32, md5Checksum: String, fileHash: Buffer, secret: Buffer) - case inputSecureFile(id: Int64, accessHash: Int64) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .inputSecureFileUploaded(let id, let parts, let md5Checksum, let fileHash, let secret): - if boxed { - buffer.appendInt32(859091184) - } - serializeInt64(id, buffer: buffer, boxed: false) - serializeInt32(parts, buffer: buffer, boxed: false) - serializeString(md5Checksum, buffer: buffer, boxed: false) - serializeBytes(fileHash, buffer: buffer, boxed: false) - serializeBytes(secret, buffer: buffer, boxed: false) - break - case .inputSecureFile(let id, let accessHash): - if boxed { - buffer.appendInt32(1399317950) - } - serializeInt64(id, buffer: buffer, boxed: false) - serializeInt64(accessHash, buffer: buffer, boxed: false) - break - } - } - - static func parse_inputSecureFileUploaded(_ reader: BufferReader) -> InputSecureFile? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() - var _3: String? - _3 = parseString(reader) - var _4: Buffer? - _4 = parseBytes(reader) - var _5: Buffer? - _5 = parseBytes(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.InputSecureFile.inputSecureFileUploaded(id: _1!, parts: _2!, md5Checksum: _3!, fileHash: _4!, secret: _5!) - } - else { - return nil - } - } - static func parse_inputSecureFile(_ reader: BufferReader) -> InputSecureFile? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int64? - _2 = reader.readInt64() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.InputSecureFile.inputSecureFile(id: _1!, accessHash: _2!) - } - else { - return nil - } - } - } public enum PostAddress { case postAddress(streetLine1: String, streetLine2: String, city: String, state: String, countryIso2: String, postCode: String) @@ -11174,6 +10541,8 @@ public extension Api { } public enum InputWebFileLocation { case inputWebFileLocation(url: String, accessHash: Int64) + case inputWebFileGeoPointLocation(geoPoint: Api.InputGeoPoint, w: Int32, h: Int32, zoom: Int32, scale: Int32) + case inputWebFileGeoMessageLocation(peer: Api.InputPeer, msgId: Int32, w: Int32, h: Int32, zoom: Int32, scale: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -11184,6 +10553,27 @@ public extension Api { serializeString(url, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) break + case .inputWebFileGeoPointLocation(let geoPoint, let w, let h, let zoom, let scale): + if boxed { + buffer.appendInt32(1713855074) + } + geoPoint.serialize(buffer, true) + serializeInt32(w, buffer: buffer, boxed: false) + serializeInt32(h, buffer: buffer, boxed: false) + serializeInt32(zoom, buffer: buffer, boxed: false) + serializeInt32(scale, buffer: buffer, boxed: false) + break + case .inputWebFileGeoMessageLocation(let peer, let msgId, let w, let h, let zoom, let scale): + if boxed { + buffer.appendInt32(1430205163) + } + peer.serialize(buffer, true) + serializeInt32(msgId, buffer: buffer, boxed: false) + serializeInt32(w, buffer: buffer, boxed: false) + serializeInt32(h, buffer: buffer, boxed: false) + serializeInt32(zoom, buffer: buffer, boxed: false) + serializeInt32(scale, buffer: buffer, boxed: false) + break } } @@ -11201,6 +10591,59 @@ public extension Api { return nil } } + static func parse_inputWebFileGeoPointLocation(_ reader: BufferReader) -> InputWebFileLocation? { + var _1: Api.InputGeoPoint? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.InputGeoPoint + } + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + _3 = reader.readInt32() + var _4: Int32? + _4 = reader.readInt32() + var _5: Int32? + _5 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.InputWebFileLocation.inputWebFileGeoPointLocation(geoPoint: _1!, w: _2!, h: _3!, zoom: _4!, scale: _5!) + } + else { + return nil + } + } + static func parse_inputWebFileGeoMessageLocation(_ reader: BufferReader) -> InputWebFileLocation? { + var _1: Api.InputPeer? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.InputPeer + } + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + _3 = reader.readInt32() + var _4: Int32? + _4 = reader.readInt32() + var _5: Int32? + _5 = reader.readInt32() + var _6: Int32? + _6 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.InputWebFileLocation.inputWebFileGeoMessageLocation(peer: _1!, msgId: _2!, w: _3!, h: _4!, zoom: _5!, scale: _6!) + } + else { + return nil + } + } } public enum MessageFwdHeader { @@ -11925,145 +11368,6 @@ public extension Api { } } - } - public enum SecureValueType { - case secureValueTypePersonalDetails - case secureValueTypePassport - case secureValueTypeDriverLicense - case secureValueTypeIdentityCard - case secureValueTypeInternalPassport - case secureValueTypeAddress - case secureValueTypeUtilityBill - case secureValueTypeBankStatement - case secureValueTypeRentalAgreement - case secureValueTypePassportRegistration - case secureValueTypeTemporaryRegistration - case secureValueTypePhone - case secureValueTypeEmail - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .secureValueTypePersonalDetails: - if boxed { - buffer.appendInt32(-1658158621) - } - - break - case .secureValueTypePassport: - if boxed { - buffer.appendInt32(1034709504) - } - - break - case .secureValueTypeDriverLicense: - if boxed { - buffer.appendInt32(115615172) - } - - break - case .secureValueTypeIdentityCard: - if boxed { - buffer.appendInt32(-1596951477) - } - - break - case .secureValueTypeInternalPassport: - if boxed { - buffer.appendInt32(-1717268701) - } - - break - case .secureValueTypeAddress: - if boxed { - buffer.appendInt32(-874308058) - } - - break - case .secureValueTypeUtilityBill: - if boxed { - buffer.appendInt32(-63531698) - } - - break - case .secureValueTypeBankStatement: - if boxed { - buffer.appendInt32(-1995211763) - } - - break - case .secureValueTypeRentalAgreement: - if boxed { - buffer.appendInt32(-1954007928) - } - - break - case .secureValueTypePassportRegistration: - if boxed { - buffer.appendInt32(-1713143702) - } - - break - case .secureValueTypeTemporaryRegistration: - if boxed { - buffer.appendInt32(-368907213) - } - - break - case .secureValueTypePhone: - if boxed { - buffer.appendInt32(-1289704741) - } - - break - case .secureValueTypeEmail: - if boxed { - buffer.appendInt32(-1908627474) - } - - break - } - } - - static func parse_secureValueTypePersonalDetails(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypePersonalDetails - } - static func parse_secureValueTypePassport(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypePassport - } - static func parse_secureValueTypeDriverLicense(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeDriverLicense - } - static func parse_secureValueTypeIdentityCard(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeIdentityCard - } - static func parse_secureValueTypeInternalPassport(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeInternalPassport - } - static func parse_secureValueTypeAddress(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeAddress - } - static func parse_secureValueTypeUtilityBill(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeUtilityBill - } - static func parse_secureValueTypeBankStatement(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeBankStatement - } - static func parse_secureValueTypeRentalAgreement(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeRentalAgreement - } - static func parse_secureValueTypePassportRegistration(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypePassportRegistration - } - static func parse_secureValueTypeTemporaryRegistration(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeTemporaryRegistration - } - static func parse_secureValueTypePhone(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypePhone - } - static func parse_secureValueTypeEmail(_ reader: BufferReader) -> SecureValueType? { - return Api.SecureValueType.secureValueTypeEmail - } - } public enum InputBotInlineResult { case inputBotInlineResultPhoto(id: String, type: String, photo: Api.InputPhoto, sendMessage: Api.InputBotInlineMessage) @@ -12356,8 +11660,6 @@ public extension Api { case messageActionScreenshotTaken case messageActionCustomAction(message: String) case messageActionBotAllowed(domain: String) - case messageActionSecureValuesSentMe(values: [Api.SecureValue], credentials: Api.SecureCredentialsEncrypted) - case messageActionSecureValuesSent(types: [Api.SecureValueType]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -12502,27 +11804,6 @@ public extension Api { } serializeString(domain, buffer: buffer, boxed: false) break - case .messageActionSecureValuesSentMe(let values, let credentials): - if boxed { - buffer.appendInt32(455635795) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(values.count)) - for item in values { - item.serialize(buffer, true) - } - credentials.serialize(buffer, true) - break - case .messageActionSecureValuesSent(let types): - if boxed { - buffer.appendInt32(-648257196) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(types.count)) - for item in types { - item.serialize(buffer, true) - } - break } } @@ -12757,37 +12038,6 @@ public extension Api { return nil } } - static func parse_messageActionSecureValuesSentMe(_ reader: BufferReader) -> MessageAction? { - var _1: [Api.SecureValue]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValue.self) - } - var _2: Api.SecureCredentialsEncrypted? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.SecureCredentialsEncrypted - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.MessageAction.messageActionSecureValuesSentMe(values: _1!, credentials: _2!) - } - else { - return nil - } - } - static func parse_messageActionSecureValuesSent(_ reader: BufferReader) -> MessageAction? { - var _1: [Api.SecureValueType]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValueType.self) - } - let _c1 = _1 != nil - if _c1 { - return Api.MessageAction.messageActionSecureValuesSent(types: _1!) - } - else { - return nil - } - } } public enum PhoneCall { diff --git a/TelegramCore/Api2.swift b/TelegramCore/Api2.swift index b5177b8f37..809ccb354c 100644 --- a/TelegramCore/Api2.swift +++ b/TelegramCore/Api2.swift @@ -1271,57 +1271,6 @@ public struct help { } } - } - public enum DeepLinkInfo { - case deepLinkInfoEmpty - case deepLinkInfo(flags: Int32, message: String, entities: [Api.MessageEntity]?) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .deepLinkInfoEmpty: - if boxed { - buffer.appendInt32(1722786150) - } - - break - case .deepLinkInfo(let flags, let message, let entities): - if boxed { - buffer.appendInt32(1783556146) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeString(message, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261) - buffer.appendInt32(Int32(entities!.count)) - for item in entities! { - item.serialize(buffer, true) - }} - break - } - } - - static func parse_deepLinkInfoEmpty(_ reader: BufferReader) -> DeepLinkInfo? { - return Api.help.DeepLinkInfo.deepLinkInfoEmpty - } - static func parse_deepLinkInfo(_ reader: BufferReader) -> DeepLinkInfo? { - var _1: Int32? - _1 = reader.readInt32() - var _2: String? - _2 = parseString(reader) - var _3: [Api.MessageEntity]? - if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self) - } } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil - if _c1 && _c2 && _c3 { - return Api.help.DeepLinkInfo.deepLinkInfo(flags: _1!, message: _2!, entities: _3) - } - else { - return nil - } - } - } public enum TermsOfService { case termsOfService(text: String) @@ -2196,18 +2145,15 @@ public struct account { } public enum PasswordSettings { - case passwordSettings(email: String, secureSalt: Buffer, secureSecret: Buffer, secureSecretId: Int64) + case passwordSettings(email: String) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .passwordSettings(let email, let secureSalt, let secureSecret, let secureSecretId): + case .passwordSettings(let email): if boxed { - buffer.appendInt32(2077869041) + buffer.appendInt32(-1212732749) } serializeString(email, buffer: buffer, boxed: false) - serializeBytes(secureSalt, buffer: buffer, boxed: false) - serializeBytes(secureSecret, buffer: buffer, boxed: false) - serializeInt64(secureSecretId, buffer: buffer, boxed: false) break } } @@ -2215,18 +2161,9 @@ public struct account { static func parse_passwordSettings(_ reader: BufferReader) -> PasswordSettings? { var _1: String? _1 = parseString(reader) - var _2: Buffer? - _2 = parseBytes(reader) - var _3: Buffer? - _3 = parseBytes(reader) - var _4: Int64? - _4 = reader.readInt64() let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.account.PasswordSettings.passwordSettings(email: _1!, secureSalt: _2!, secureSecret: _3!, secureSecretId: _4!) + if _c1 { + return Api.account.PasswordSettings.passwordSettings(email: _1!) } else { return nil @@ -2235,22 +2172,19 @@ public struct account { } public enum PasswordInputSettings { - case passwordInputSettings(flags: Int32, newSalt: Buffer?, newPasswordHash: Buffer?, hint: String?, email: String?, newSecureSalt: Buffer?, newSecureSecret: Buffer?, newSecureSecretId: Int64?) + case passwordInputSettings(flags: Int32, newSalt: Buffer?, newPasswordHash: Buffer?, hint: String?, email: String?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .passwordInputSettings(let flags, let newSalt, let newPasswordHash, let hint, let email, let newSecureSalt, let newSecureSecret, let newSecureSecretId): + case .passwordInputSettings(let flags, let newSalt, let newPasswordHash, let hint, let email): if boxed { - buffer.appendInt32(570402317) + buffer.appendInt32(-2037289493) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeBytes(newSalt!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeBytes(newPasswordHash!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeString(hint!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeString(email!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 2) != 0 {serializeBytes(newSecureSalt!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 2) != 0 {serializeBytes(newSecureSecret!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 2) != 0 {serializeInt64(newSecureSecretId!, buffer: buffer, boxed: false)} break } } @@ -2266,22 +2200,13 @@ public struct account { if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } var _5: String? if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) } - var _6: Buffer? - if Int(_1!) & Int(1 << 2) != 0 {_6 = parseBytes(reader) } - var _7: Buffer? - if Int(_1!) & Int(1 << 2) != 0 {_7 = parseBytes(reader) } - var _8: Int64? - if Int(_1!) & Int(1 << 2) != 0 {_8 = reader.readInt64() } let _c1 = _1 != nil let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil - let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil - let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil - let _c8 = (Int(_1!) & Int(1 << 2) == 0) || _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.account.PasswordInputSettings.passwordInputSettings(flags: _1!, newSalt: _2, newPasswordHash: _3, hint: _4, email: _5, newSecureSalt: _6, newSecureSecret: _7, newSecureSecretId: _8) + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.account.PasswordInputSettings.passwordInputSettings(flags: _1!, newSalt: _2, newPasswordHash: _3, hint: _4, email: _5) } else { return nil @@ -2331,37 +2256,6 @@ public struct account { } } - } - public enum SentEmailCode { - case sentEmailCode(emailPattern: String, length: Int32) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .sentEmailCode(let emailPattern, let length): - if boxed { - buffer.appendInt32(-2128640689) - } - serializeString(emailPattern, buffer: buffer, boxed: false) - serializeInt32(length, buffer: buffer, boxed: false) - break - } - } - - static func parse_sentEmailCode(_ reader: BufferReader) -> SentEmailCode? { - var _1: String? - _1 = parseString(reader) - var _2: Int32? - _2 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.account.SentEmailCode.sentEmailCode(emailPattern: _1!, length: _2!) - } - else { - return nil - } - } - } public enum Authorizations { case authorizations(authorizations: [Api.Authorization]) @@ -2395,103 +2289,28 @@ public struct account { } } - } - public enum AuthorizationForm { - case authorizationForm(flags: Int32, requiredTypes: [Api.SecureValueType], values: [Api.SecureValue], errors: [Api.SecureValueError], users: [Api.User], privacyPolicyUrl: String?) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .authorizationForm(let flags, let requiredTypes, let values, let errors, let users, let privacyPolicyUrl): - if boxed { - buffer.appendInt32(-879268525) - } - serializeInt32(flags, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(requiredTypes.count)) - for item in requiredTypes { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(values.count)) - for item in values { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(errors.count)) - for item in errors { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - if Int(flags) & Int(1 << 0) != 0 {serializeString(privacyPolicyUrl!, buffer: buffer, boxed: false)} - break - } - } - - static func parse_authorizationForm(_ reader: BufferReader) -> AuthorizationForm? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Api.SecureValueType]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValueType.self) - } - var _3: [Api.SecureValue]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValue.self) - } - var _4: [Api.SecureValueError]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValueError.self) - } - var _5: [Api.User]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - var _6: String? - if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { - return Api.account.AuthorizationForm.authorizationForm(flags: _1!, requiredTypes: _2!, values: _3!, errors: _4!, users: _5!, privacyPolicyUrl: _6) - } - else { - return nil - } - } - } public enum Password { - case noPassword(newSalt: Buffer, newSecureSalt: Buffer, secureRandom: Buffer, emailUnconfirmedPattern: String) - case password(flags: Int32, currentSalt: Buffer, newSalt: Buffer, newSecureSalt: Buffer, secureRandom: Buffer, hint: String, emailUnconfirmedPattern: String) + case noPassword(newSalt: Buffer, emailUnconfirmedPattern: String) + case password(currentSalt: Buffer, newSalt: Buffer, hint: String, hasRecovery: Api.Bool, emailUnconfirmedPattern: String) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .noPassword(let newSalt, let newSecureSalt, let secureRandom, let emailUnconfirmedPattern): + case .noPassword(let newSalt, let emailUnconfirmedPattern): if boxed { - buffer.appendInt32(1587643126) + buffer.appendInt32(-1764049896) } serializeBytes(newSalt, buffer: buffer, boxed: false) - serializeBytes(newSecureSalt, buffer: buffer, boxed: false) - serializeBytes(secureRandom, buffer: buffer, boxed: false) serializeString(emailUnconfirmedPattern, buffer: buffer, boxed: false) break - case .password(let flags, let currentSalt, let newSalt, let newSecureSalt, let secureRandom, let hint, let emailUnconfirmedPattern): + case .password(let currentSalt, let newSalt, let hint, let hasRecovery, let emailUnconfirmedPattern): if boxed { - buffer.appendInt32(-902187961) + buffer.appendInt32(2081952796) } - serializeInt32(flags, buffer: buffer, boxed: false) serializeBytes(currentSalt, buffer: buffer, boxed: false) serializeBytes(newSalt, buffer: buffer, boxed: false) - serializeBytes(newSecureSalt, buffer: buffer, boxed: false) - serializeBytes(secureRandom, buffer: buffer, boxed: false) serializeString(hint, buffer: buffer, boxed: false) + hasRecovery.serialize(buffer, true) serializeString(emailUnconfirmedPattern, buffer: buffer, boxed: false) break } @@ -2500,47 +2319,37 @@ public struct account { static func parse_noPassword(_ reader: BufferReader) -> Password? { var _1: Buffer? _1 = parseBytes(reader) - var _2: Buffer? - _2 = parseBytes(reader) - var _3: Buffer? - _3 = parseBytes(reader) - var _4: String? - _4 = parseString(reader) + var _2: String? + _2 = parseString(reader) let _c1 = _1 != nil let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.account.Password.noPassword(newSalt: _1!, newSecureSalt: _2!, secureRandom: _3!, emailUnconfirmedPattern: _4!) + if _c1 && _c2 { + return Api.account.Password.noPassword(newSalt: _1!, emailUnconfirmedPattern: _2!) } else { return nil } } static func parse_password(_ reader: BufferReader) -> Password? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Buffer? + _1 = parseBytes(reader) var _2: Buffer? _2 = parseBytes(reader) - var _3: Buffer? - _3 = parseBytes(reader) - var _4: Buffer? - _4 = parseBytes(reader) - var _5: Buffer? - _5 = parseBytes(reader) - var _6: String? - _6 = parseString(reader) - var _7: String? - _7 = parseString(reader) + var _3: String? + _3 = parseString(reader) + var _4: Api.Bool? + if let signature = reader.readInt32() { + _4 = Api.parse(reader, signature: signature) as? Api.Bool + } + var _5: String? + _5 = parseString(reader) let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil let _c4 = _4 != nil let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = _7 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { - return Api.account.Password.password(flags: _1!, currentSalt: _2!, newSalt: _3!, newSecureSalt: _4!, secureRandom: _5!, hint: _6!, emailUnconfirmedPattern: _7!) + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.account.Password.password(currentSalt: _1!, newSalt: _2!, hint: _3!, hasRecovery: _4!, emailUnconfirmedPattern: _5!) } else { return nil diff --git a/TelegramCore/Api3.swift b/TelegramCore/Api3.swift index 3a7b5cbd5b..3a46cb72d6 100644 --- a/TelegramCore/Api3.swift +++ b/TelegramCore/Api3.swift @@ -1031,28 +1031,6 @@ public extension Api { }) } - public static func editInlineBotMessage(flags: Int32, id: Api.InputBotInlineMessageID, message: String?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(319564933) - serializeInt32(flags, buffer: buffer, boxed: false) - id.serialize(buffer, true) - if Int(flags) & Int(1 << 11) != 0 {serializeString(message!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)} - if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261) - buffer.appendInt32(Int32(entities!.count)) - for item in entities! { - item.serialize(buffer, true) - }} - return (FunctionDescription({return "(messages.editInlineBotMessage flags: \(flags), id: \(id), message: \(String(describing: message)), replyMarkup: \(String(describing: replyMarkup)), entities: \(String(describing: entities)))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - public static func getBotCallbackAnswer(flags: Int32, peer: Api.InputPeer, msgId: Int32, data: Buffer?) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.BotCallbackAnswer?) { let buffer = Buffer() buffer.appendInt32(-2130010132) @@ -1801,6 +1779,30 @@ public extension Api { }) } + public static func editInlineBotMessage(flags: Int32, id: Api.InputBotInlineMessageID, message: String?, media: Api.InputMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, geoPoint: Api.InputGeoPoint?) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { + let buffer = Buffer() + buffer.appendInt32(-1379669976) + serializeInt32(flags, buffer: buffer, boxed: false) + id.serialize(buffer, true) + if Int(flags) & Int(1 << 11) != 0 {serializeString(message!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 14) != 0 {media!.serialize(buffer, true)} + if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)} + if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261) + buffer.appendInt32(Int32(entities!.count)) + for item in entities! { + item.serialize(buffer, true) + }} + if Int(flags) & Int(1 << 13) != 0 {geoPoint!.serialize(buffer, true)} + return (FunctionDescription({return "(messages.editInlineBotMessage flags: \(flags), id: \(id), message: \(String(describing: message)), media: \(String(describing: media)), replyMarkup: \(String(describing: replyMarkup)), entities: \(String(describing: entities)), geoPoint: \(String(describing: geoPoint)))"}), buffer, { (buffer: Buffer) -> Api.Bool? in + let reader = BufferReader(buffer) + var result: Api.Bool? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.Bool + } + return result + }) + } + public static func getStickers(emoticon: String, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Stickers?) { let buffer = Buffer() buffer.appendInt32(71126828) @@ -2770,25 +2772,6 @@ public extension Api { return result }) } - - public static func setSecureValueErrors(id: Api.InputUser, errors: [Api.SecureValueError]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(-1865902923) - id.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(errors.count)) - for item in errors { - item.serialize(buffer, true) - } - return (FunctionDescription({return "(users.setSecureValueErrors id: \(id), errors: \(errors))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } } public struct contacts { public static func getStatuses() -> (CustomStringConvertible, Buffer, (Buffer) -> [Api.ContactStatus]?) { @@ -3122,20 +3105,6 @@ public extension Api { }) } - public static func getTermsOfService() -> (CustomStringConvertible, Buffer, (Buffer) -> Api.help.TermsOfService?) { - let buffer = Buffer() - buffer.appendInt32(889286899) - - return (FunctionDescription({return "(help.getTermsOfService )"}), buffer, { (buffer: Buffer) -> Api.help.TermsOfService? in - let reader = BufferReader(buffer) - var result: Api.help.TermsOfService? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.help.TermsOfService - } - return result - }) - } - public static func setBotUpdatesStatus(pendingUpdatesCount: Int32, message: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { let buffer = Buffer() buffer.appendInt32(-333262899) @@ -3207,15 +3176,16 @@ public extension Api { }) } - public static func getDeepLinkInfo(path: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.help.DeepLinkInfo?) { + public static func getTermsOfService(countryIso2: String, langCode: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.help.TermsOfService?) { let buffer = Buffer() - buffer.appendInt32(1072547679) - serializeString(path, buffer: buffer, boxed: false) - return (FunctionDescription({return "(help.getDeepLinkInfo path: \(path))"}), buffer, { (buffer: Buffer) -> Api.help.DeepLinkInfo? in + buffer.appendInt32(-92706236) + serializeString(countryIso2, buffer: buffer, boxed: false) + serializeString(langCode, buffer: buffer, boxed: false) + return (FunctionDescription({return "(help.getTermsOfService countryIso2: \(countryIso2), langCode: \(langCode))"}), buffer, { (buffer: Buffer) -> Api.help.TermsOfService? in let reader = BufferReader(buffer) - var result: Api.help.DeepLinkInfo? + var result: Api.help.TermsOfService? if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.help.DeepLinkInfo + result = Api.parse(reader, signature: signature) as? Api.help.TermsOfService } return result }) @@ -3852,170 +3822,6 @@ public extension Api { return result }) } - - public static func getAllSecureValues() -> (CustomStringConvertible, Buffer, (Buffer) -> [Api.SecureValue]?) { - let buffer = Buffer() - buffer.appendInt32(-1299661699) - - return (FunctionDescription({return "(account.getAllSecureValues )"}), buffer, { (buffer: Buffer) -> [Api.SecureValue]? in - let reader = BufferReader(buffer) - var result: [Api.SecureValue]? - if let _ = reader.readInt32() { - result = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValue.self) - } - return result - }) - } - - public static func getSecureValue(types: [Api.SecureValueType]) -> (CustomStringConvertible, Buffer, (Buffer) -> [Api.SecureValue]?) { - let buffer = Buffer() - buffer.appendInt32(1936088002) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(types.count)) - for item in types { - item.serialize(buffer, true) - } - return (FunctionDescription({return "(account.getSecureValue types: \(types))"}), buffer, { (buffer: Buffer) -> [Api.SecureValue]? in - let reader = BufferReader(buffer) - var result: [Api.SecureValue]? - if let _ = reader.readInt32() { - result = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureValue.self) - } - return result - }) - } - - public static func saveSecureValue(value: Api.InputSecureValue, secureSecretId: Int64) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.SecureValue?) { - let buffer = Buffer() - buffer.appendInt32(-1986010339) - value.serialize(buffer, true) - serializeInt64(secureSecretId, buffer: buffer, boxed: false) - return (FunctionDescription({return "(account.saveSecureValue value: \(value), secureSecretId: \(secureSecretId))"}), buffer, { (buffer: Buffer) -> Api.SecureValue? in - let reader = BufferReader(buffer) - var result: Api.SecureValue? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.SecureValue - } - return result - }) - } - - public static func deleteSecureValue(types: [Api.SecureValueType]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(-1199522741) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(types.count)) - for item in types { - item.serialize(buffer, true) - } - return (FunctionDescription({return "(account.deleteSecureValue types: \(types))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func getAuthorizationForm(botId: Int32, scope: String, publicKey: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.account.AuthorizationForm?) { - let buffer = Buffer() - buffer.appendInt32(-1200903967) - serializeInt32(botId, buffer: buffer, boxed: false) - serializeString(scope, buffer: buffer, boxed: false) - serializeString(publicKey, buffer: buffer, boxed: false) - return (FunctionDescription({return "(account.getAuthorizationForm botId: \(botId), scope: \(scope), publicKey: \(publicKey))"}), buffer, { (buffer: Buffer) -> Api.account.AuthorizationForm? in - let reader = BufferReader(buffer) - var result: Api.account.AuthorizationForm? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.account.AuthorizationForm - } - return result - }) - } - - public static func acceptAuthorization(botId: Int32, scope: String, publicKey: String, valueHashes: [Api.SecureValueHash], credentials: Api.SecureCredentialsEncrypted) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(-419267436) - serializeInt32(botId, buffer: buffer, boxed: false) - serializeString(scope, buffer: buffer, boxed: false) - serializeString(publicKey, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(valueHashes.count)) - for item in valueHashes { - item.serialize(buffer, true) - } - credentials.serialize(buffer, true) - return (FunctionDescription({return "(account.acceptAuthorization botId: \(botId), scope: \(scope), publicKey: \(publicKey), valueHashes: \(valueHashes), credentials: \(credentials))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func sendVerifyPhoneCode(flags: Int32, phoneNumber: String, currentNumber: Api.Bool?) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.auth.SentCode?) { - let buffer = Buffer() - buffer.appendInt32(-2110553932) - serializeInt32(flags, buffer: buffer, boxed: false) - serializeString(phoneNumber, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {currentNumber!.serialize(buffer, true)} - return (FunctionDescription({return "(account.sendVerifyPhoneCode flags: \(flags), phoneNumber: \(phoneNumber), currentNumber: \(String(describing: currentNumber)))"}), buffer, { (buffer: Buffer) -> Api.auth.SentCode? in - let reader = BufferReader(buffer) - var result: Api.auth.SentCode? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.auth.SentCode - } - return result - }) - } - - public static func verifyPhone(phoneNumber: String, phoneCodeHash: String, phoneCode: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(1305716726) - serializeString(phoneNumber, buffer: buffer, boxed: false) - serializeString(phoneCodeHash, buffer: buffer, boxed: false) - serializeString(phoneCode, buffer: buffer, boxed: false) - return (FunctionDescription({return "(account.verifyPhone phoneNumber: \(phoneNumber), phoneCodeHash: \(phoneCodeHash), phoneCode: \(phoneCode))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func sendVerifyEmailCode(email: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.account.SentEmailCode?) { - let buffer = Buffer() - buffer.appendInt32(1880182943) - serializeString(email, buffer: buffer, boxed: false) - return (FunctionDescription({return "(account.sendVerifyEmailCode email: \(email))"}), buffer, { (buffer: Buffer) -> Api.account.SentEmailCode? in - let reader = BufferReader(buffer) - var result: Api.account.SentEmailCode? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.account.SentEmailCode - } - return result - }) - } - - public static func verifyEmail(email: String, code: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(-323339813) - serializeString(email, buffer: buffer, boxed: false) - serializeString(code, buffer: buffer, boxed: false) - return (FunctionDescription({return "(account.verifyEmail email: \(email), code: \(code))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } } public struct langpack { public static func getLangPack(langCode: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.LangPackDifference?) { diff --git a/TelegramCore/Authorization.swift b/TelegramCore/Authorization.swift index 7a01191b21..962ff6e8d4 100644 --- a/TelegramCore/Authorization.swift +++ b/TelegramCore/Authorization.swift @@ -156,7 +156,7 @@ public func authorizeWithCode(account: UnauthorizedAccount, code: String) -> Sig switch result { case .noPassword: return .fail(.generic) - case let .password(_, _, _, _, _, hint, _): + case let .password(_, _, hint, _, _): return .single(.password(hint: hint)) } } diff --git a/TelegramCore/Download.swift b/TelegramCore/Download.swift index 40b84ae8c3..7ece0376f2 100644 --- a/TelegramCore/Download.swift +++ b/TelegramCore/Download.swift @@ -44,7 +44,7 @@ class Download: NSObject, MTRequestMessageServiceDelegate { self.mtProto = MTProto(context: self.context, datacenterId: datacenterId, usageCalculationInfo: usageInfo) self.mtProto.cdn = isCdn - self.mtProto.useTempAuthKeys = !isCdn + self.mtProto.useTempAuthKeys = self.context.useTempAuthKeys && !isCdn self.mtProto.media = true; if !isCdn && datacenterId != masterDatacenterId { self.mtProto.authTokenMasterDatacenterId = masterDatacenterId diff --git a/TelegramCore/GrantSecureIdAccess.swift b/TelegramCore/GrantSecureIdAccess.swift index b7a3d0eef8..5b49d71960 100644 --- a/TelegramCore/GrantSecureIdAccess.swift +++ b/TelegramCore/GrantSecureIdAccess.swift @@ -9,7 +9,7 @@ import Foundation import SwiftSignalKit #endif -func apiSecureValueType(value: SecureIdValue) -> Api.SecureValueType { +/*func apiSecureValueType(value: SecureIdValue) -> Api.SecureValueType { let type: Api.SecureValueType switch value { case .personalDetails: @@ -173,14 +173,15 @@ private func encryptedCredentialsData(data: Data, secretData: Data) -> (data: Da return nil } return (encryptedData, hash) -} +}*/ public enum GrantSecureIdAccessError { case generic } public func grantSecureIdAccess(network: Network, peerId: PeerId, publicKey: String, scope: String, opaquePayload: Data, values: [SecureIdValueWithContext]) -> Signal { - guard peerId.namespace == Namespaces.Peer.CloudUser else { + return .never() + /*guard peerId.namespace == Namespaces.Peer.CloudUser else { return .fail(.generic) } guard let credentialsSecretData = generateSecureSecretData() else { @@ -207,5 +208,5 @@ public func grantSecureIdAccess(network: Network, peerId: PeerId, publicKey: Str } |> mapToSignal { _ -> Signal in return .complete() - } + }*/ } diff --git a/TelegramCore/Network.swift b/TelegramCore/Network.swift index 948a9223cf..4efa755549 100644 --- a/TelegramCore/Network.swift +++ b/TelegramCore/Network.swift @@ -342,7 +342,7 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary apiEnvironment = apiEnvironment.withUpdatedNetworkSettings((networkSettings ?? NetworkSettings.defaultSettings).mtNetworkSettings) - let context = MTContext(serialization: serialization, apiEnvironment: apiEnvironment, useTempAuthKeys: true)! + let context = MTContext(serialization: serialization, apiEnvironment: apiEnvironment, useTempAuthKeys: false)! let seedAddressList: [Int: [String]] @@ -373,7 +373,7 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary #endif let mtProto = MTProto(context: context, datacenterId: datacenterId, usageCalculationInfo: usageCalculationInfo(basePath: basePath, category: nil))! - mtProto.useTempAuthKeys = true + mtProto.useTempAuthKeys = context.useTempAuthKeys let connectionStatus = Promise(.waitingForNetwork) diff --git a/TelegramCore/RequestSecureIdForm.swift b/TelegramCore/RequestSecureIdForm.swift index 38b5909b8e..7b69a1a73e 100644 --- a/TelegramCore/RequestSecureIdForm.swift +++ b/TelegramCore/RequestSecureIdForm.swift @@ -14,7 +14,7 @@ public enum RequestSecureIdFormError { case serverError(String) } -private func parseSecureValueType(_ type: Api.SecureValueType, selfie: Bool) -> SecureIdRequestedFormField { +/*private func parseSecureValueType(_ type: Api.SecureValueType, selfie: Bool) -> SecureIdRequestedFormField { switch type { case .secureValueTypePersonalDetails: return .personalDetails @@ -50,13 +50,13 @@ private func parseSecureData(_ value: Api.SecureData) -> (data: Data, hash: Data case let .secureData(data, dataHash, secret): return (data.makeData(), dataHash.makeData(), secret.makeData()) } -} +}*/ struct ParsedSecureValue { let valueWithContext: SecureIdValueWithContext } -func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, errors: [Api.SecureValueError]) -> ParsedSecureValue? { +/*func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, errors: [Api.SecureValueError]) -> ParsedSecureValue? { switch value { case let .secureValue(_, type, data, frontSide, reverseSide, selfie, files, plainData, hash): let parsedFileReferences = files.flatMap { $0.compactMap(SecureIdFileReference.init) } ?? [] @@ -221,19 +221,20 @@ func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, er private func parseSecureValues(context: SecureIdAccessContext, values: [Api.SecureValue], errors: [Api.SecureValueError]) -> [SecureIdValueWithContext] { return values.map({ parseSecureValue(context: context, value: $0, errors: errors) }).compactMap({ $0?.valueWithContext }) -} +}*/ public struct EncryptedSecureIdForm { public let peerId: PeerId public let requestedFields: [SecureIdRequestedFormField] public let termsUrl: String? - let encryptedValues: [Api.SecureValue] - let errors: [Api.SecureValueError] + /*let encryptedValues: [Api.SecureValue] + let errors: [Api.SecureValueError]*/ } public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: PeerId, scope: String, publicKey: String) -> Signal { - if peerId.namespace != Namespaces.Peer.CloudUser { + return .never() + /*if peerId.namespace != Namespaces.Peer.CloudUser { return .fail(.serverError("PEER IS NOT A BOT")) } return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id, scope: scope, publicKey: publicKey)) @@ -258,9 +259,10 @@ public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: Peer }, termsUrl: termsUrl, encryptedValues: values, errors: errors) } } |> mapError { _ in return RequestSecureIdFormError.generic } - } + }*/ } public func decryptedSecureIdForm(context: SecureIdAccessContext, form: EncryptedSecureIdForm) -> SecureIdForm? { - return SecureIdForm(peerId: form.peerId, requestedFields: form.requestedFields, values: parseSecureValues(context: context, values: form.encryptedValues, errors: form.errors)) + return nil + //return SecureIdForm(peerId: form.peerId, requestedFields: form.requestedFields, values: parseSecureValues(context: context, values: form.encryptedValues, errors: form.errors)) } diff --git a/TelegramCore/SaveSecureIdValue.swift b/TelegramCore/SaveSecureIdValue.swift index dab871582f..950aeea617 100644 --- a/TelegramCore/SaveSecureIdValue.swift +++ b/TelegramCore/SaveSecureIdValue.swift @@ -87,7 +87,7 @@ func decryptedSecureValueData(context: SecureIdValueAccessContext, encryptedData return unpaddedValueData } -private func apiInputSecretFile(_ file: SecureIdVerificationDocumentReference) -> Api.InputSecureFile { +/*private func apiInputSecretFile(_ file: SecureIdVerificationDocumentReference) -> Api.InputSecureFile { switch file { case let .remote(file): return Api.InputSecureFile.inputSecureFile(id: file.id, accessHash: file.accessHash) @@ -202,10 +202,11 @@ private func makeInputSecureValue(context: SecureIdAccessContext, value: SecureI } return Api.InputSecureValue.inputSecureValue(flags: flags, type: inputData.type, data: secureData, frontSide: inputData.frontSideReference.flatMap(apiInputSecretFile), reverseSide: inputData.backSideReference.flatMap(apiInputSecretFile), selfie: inputData.selfieReference.flatMap(apiInputSecretFile), files: files, plainData: inputData.publicData) -} +}*/ public func saveSecureIdValue(postbox: Postbox, network: Network, context: SecureIdAccessContext, value: SecureIdValue, uploadedFiles: [Data: Data]) -> Signal { - let delete = deleteSecureIdValues(network: network, keys: Set([value.key])) + return .never() + /*let delete = deleteSecureIdValues(network: network, keys: Set([value.key])) |> mapError { _ -> SaveSecureIdValueError in return .generic } @@ -245,7 +246,7 @@ public func saveSecureIdValue(postbox: Postbox, network: Network, context: Secur return .single(parsedValue.valueWithContext) } - return delete |> then(save) + return delete |> then(save)*/ } public enum DeleteSecureIdValueError { @@ -253,17 +254,19 @@ public enum DeleteSecureIdValueError { } public func deleteSecureIdValues(network: Network, keys: Set) -> Signal { - return network.request(Api.functions.account.deleteSecureValue(types: keys.map(apiSecureValueType(key:)))) + return .never() + /*return network.request(Api.functions.account.deleteSecureValue(types: keys.map(apiSecureValueType(key:)))) |> mapError { _ -> DeleteSecureIdValueError in return .generic } |> mapToSignal { _ -> Signal in return .complete() - } + }*/ } public func dropSecureId(network: Network, currentPassword: String) -> Signal { - return twoStepAuthData(network) + return .never() + /*return twoStepAuthData(network) |> mapError { _ -> AuthorizationPasswordVerificationError in return .generic } @@ -292,5 +295,5 @@ public func dropSecureId(network: Network, currentPassword: String) -> Signal map {_ in} |> mapError {_ in return AuthorizationPasswordVerificationError.generic} } } - } + }*/ } diff --git a/TelegramCore/SecureFileMediaResource.swift b/TelegramCore/SecureFileMediaResource.swift index eca19cb806..f7ffa115d6 100644 --- a/TelegramCore/SecureFileMediaResource.swift +++ b/TelegramCore/SecureFileMediaResource.swift @@ -45,7 +45,8 @@ public class SecureFileMediaResource: TelegramCloudMediaResource, TelegramMultip } var apiInputLocation: Api.InputFileLocation { - return Api.InputFileLocation.inputSecureFileLocation(id: self.file.id, accessHash: self.file.accessHash) + preconditionFailure() + //return Api.InputFileLocation.inputSecureFileLocation(id: self.file.id, accessHash: self.file.accessHash) } public init(file: SecureIdFileReference) { diff --git a/TelegramCore/SecureIdDataTypes.swift b/TelegramCore/SecureIdDataTypes.swift index fbcf1e9890..d9b1251b1f 100644 --- a/TelegramCore/SecureIdDataTypes.swift +++ b/TelegramCore/SecureIdDataTypes.swift @@ -27,7 +27,7 @@ public struct SecureIdFileReference: Equatable { let encryptedSecret: Data } -extension SecureIdFileReference { +/*extension SecureIdFileReference { init?(apiFile: Api.SecureFile) { switch apiFile { case let .secureFile(id, accessHash, size, dcId, date, fileHash, secret): @@ -36,7 +36,7 @@ extension SecureIdFileReference { return nil } } -} +}*/ extension SecureIdGender { init?(serializedString: String) { diff --git a/TelegramCore/SecureIdValueContentError.swift b/TelegramCore/SecureIdValueContentError.swift index 98aa2b61ed..753d904acc 100644 --- a/TelegramCore/SecureIdValueContentError.swift +++ b/TelegramCore/SecureIdValueContentError.swift @@ -57,7 +57,7 @@ public enum SecureIdValueContentErrorAddressField: String, Hashable { public typealias SecureIdValueContentError = String -func parseSecureIdValueContentErrors(dataHash: Data?, fileHashes: Set, selfieHash: Data?, frontSideHash: Data?, backSideHash: Data?, errors: [Api.SecureValueError]) -> [SecureIdValueContentErrorKey: SecureIdValueContentError] { +/*func parseSecureIdValueContentErrors(dataHash: Data?, fileHashes: Set, selfieHash: Data?, frontSideHash: Data?, backSideHash: Data?, errors: [Api.SecureValueError]) -> [SecureIdValueContentErrorKey: SecureIdValueContentError] { var result: [SecureIdValueContentErrorKey: SecureIdValueContentError] = [:] for error in errors { switch error { @@ -122,4 +122,4 @@ func parseSecureIdValueContentErrors(dataHash: Data?, fileHashes: Set, sel } } return result -} +}*/ diff --git a/TelegramCore/Serialization.swift b/TelegramCore/Serialization.swift index 1674b37502..3dba47a07e 100644 --- a/TelegramCore/Serialization.swift +++ b/TelegramCore/Serialization.swift @@ -93,7 +93,7 @@ public class BoxedMessage: NSObject { public class Serialization: NSObject, MTSerialization { public func currentLayer() -> UInt { - return 80 + return 79 } public func parseMessage(_ data: Data!) -> Any! { diff --git a/TelegramCore/StoreMessage_Telegram.swift b/TelegramCore/StoreMessage_Telegram.swift index c159be2e08..3a4ec8cb3e 100644 --- a/TelegramCore/StoreMessage_Telegram.swift +++ b/TelegramCore/StoreMessage_Telegram.swift @@ -204,7 +204,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { } switch action { - case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe: + case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed/*, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe*/: break case let .messageActionChannelMigrateFrom(_, chatId): result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)) diff --git a/TelegramCore/TelegramMediaAction.swift b/TelegramCore/TelegramMediaAction.swift index f8d133cb89..fbdc0bb81e 100644 --- a/TelegramCore/TelegramMediaAction.swift +++ b/TelegramCore/TelegramMediaAction.swift @@ -389,10 +389,10 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe return TelegramMediaAction(action: .customText(text: message, entities: [])) case let .messageActionBotAllowed(domain): return TelegramMediaAction(action: .botDomainAccessGranted(domain: domain)) - case .messageActionSecureValuesSentMe: + /*case .messageActionSecureValuesSentMe: return nil case let .messageActionSecureValuesSent(types): - return TelegramMediaAction(action: .botSentSecureValues(types: types.map(SentSecureValueType.init))) + return TelegramMediaAction(action: .botSentSecureValues(types: types.map(SentSecureValueType.init)))*/ } } @@ -411,7 +411,7 @@ extension PhoneCallDiscardReason { } } -extension SentSecureValueType { +/*extension SentSecureValueType { init(apiType: Api.SecureValueType) { switch apiType { case .secureValueTypePersonalDetails: @@ -442,4 +442,4 @@ extension SentSecureValueType { self = .temporaryRegistration } } -} +}*/ diff --git a/TelegramCore/TermsOfService.swift b/TelegramCore/TermsOfService.swift new file mode 100644 index 0000000000..5b30140f5c --- /dev/null +++ b/TelegramCore/TermsOfService.swift @@ -0,0 +1,29 @@ +import Foundation +#if os(macOS) +import PostboxMac +import SwiftSignalKitMac +import MtProtoKitMac +#else +import Postbox +import SwiftSignalKit +import MtProtoKitDynamic +#endif + +public func requestTermsOfService(network: Network, countryCode: String) -> Signal { + let langCode: String + if let langPackCode = network.context.apiEnvironment.langPackCode, !langPackCode.isEmpty { + langCode = langPackCode + } else { + langCode = "en" + } + return network.request(Api.functions.help.getTermsOfService(countryIso2: countryCode, langCode: langCode)) + |> `catch` { _ -> Signal in + return .single(.termsOfService(text: "")) + } + |> map { result -> String in + switch result { + case let .termsOfService(text): + return text + } + } +} diff --git a/TelegramCore/TwoStepVerification.swift b/TelegramCore/TwoStepVerification.swift index 63e534eb8e..ebabd9a6a0 100644 --- a/TelegramCore/TwoStepVerification.swift +++ b/TelegramCore/TwoStepVerification.swift @@ -19,10 +19,10 @@ public func twoStepVerificationConfiguration(account: Account) -> Signal retryRequest |> map { result -> TwoStepVerificationConfiguration in switch result { - case let .noPassword(_, _, _, emailUnconfirmedPattern): + case let .noPassword(_, emailUnconfirmedPattern): return .notSet(pendingEmailPattern: emailUnconfirmedPattern) - case let .password(flags, _, _, _, _, hint, emailUnconfirmedPattern): - return .set(hint: hint, hasRecoveryEmail: (flags & (1 << 0)) != 0, pendingEmailPattern: emailUnconfirmedPattern) + case let .password(_, _, hint, hasRecovery, emailUnconfirmedPattern): + return .set(hint: hint, hasRecoveryEmail: hasRecovery == .boolTrue, pendingEmailPattern: emailUnconfirmedPattern) } } } @@ -62,14 +62,14 @@ public func requestTwoStepVerifiationSettings(network: Network, password: String } |> mapToSignal { result -> Signal in switch result { - case let .passwordSettings(email, secureSalt, secureSecret, secureSecretId): + case let .passwordSettings(email): var parsedSecureSecret: TwoStepVerificationSecureSecret? - if secureSalt.size != 0 && secureSecret.size != 0 { + /*if secureSalt.size != 0 && secureSecret.size != 0 { if secureSecret.size != 32 { return .fail(.generic) } parsedSecureSecret = TwoStepVerificationSecureSecret(data: secureSecret.makeData(), salt: secureSalt.makeData(), id: secureSecretId) - } + }*/ return .single(TwoStepVerificationSettings(email: email, secureSecret: parsedSecureSecret)) } } @@ -130,7 +130,7 @@ public func updateTwoStepVerificationPassword(network: Network, currentPassword: flags |= (1 << 0) } - return network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: .passwordInputSettings(flags: flags, newSalt: Buffer(data: Data()), newPasswordHash: Buffer(data: Data()), hint: "", email: "", newSecureSalt: nil, newSecureSecret: nil, newSecureSecretId: nil)), automaticFloodWait: true) + return network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: .passwordInputSettings(flags: flags, newSalt: Buffer(data: Data()), newPasswordHash: Buffer(data: Data()), hint: "", email: "")), automaticFloodWait: true) |> mapError { _ -> UpdateTwoStepVerificationPasswordError in return .generic } @@ -157,7 +157,7 @@ public func updateTwoStepVerificationPassword(network: Network, currentPassword: updatedData.append(nextSalt) var updatedSecureSecret: TwoStepVerificationSecureSecret? - if let encryptedSecret = secureSecret { + /*if let encryptedSecret = secureSecret { flags |= 1 << 2 if let decryptedSecret = decryptedSecureSecret(encryptedSecretData: encryptedSecret.data, password: currentPassword ?? "", salt: encryptedSecret.salt, id: encryptedSecret.id) { if let (data, salt, id) = encryptedSecureSecret(secretData: decryptedSecret, password: password, inputSalt: authData.nextSecureSalt) { @@ -168,10 +168,10 @@ public func updateTwoStepVerificationPassword(network: Network, currentPassword: } else { return .fail(.generic) } - } + }*/ let updatedPasswordHash = sha256Digest(updatedData) - return network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: Api.account.PasswordInputSettings.passwordInputSettings(flags: flags, newSalt: Buffer(data: nextSalt), newPasswordHash: Buffer(data: updatedPasswordHash), hint: hint, email: email, newSecureSalt: (updatedSecureSecret?.salt).flatMap(Buffer.init), newSecureSecret: (updatedSecureSecret?.data).flatMap(Buffer.init), newSecureSecretId: updatedSecureSecret?.id)), automaticFloodWait: false) + return network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: Api.account.PasswordInputSettings.passwordInputSettings(flags: flags, newSalt: Buffer(data: nextSalt), newPasswordHash: Buffer(data: updatedPasswordHash), hint: hint, email: email)), automaticFloodWait: false) |> map { _ -> UpdateTwoStepVerificationPasswordResult in return .password(password: password, pendingEmailPattern: nil) } @@ -229,7 +229,7 @@ func updateTwoStepVerificationSecureSecret(network: Network, password: String, s } let flags: Int32 = (1 << 2) - return network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: .passwordInputSettings(flags: flags, newSalt: nil, newPasswordHash: nil, hint: nil, email: nil, newSecureSalt: Buffer(data: secretSalt), newSecureSecret: Buffer(data: encryptedSecret), newSecureSecretId: secretId)), automaticFloodWait: false) + return network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: .passwordInputSettings(flags: flags, newSalt: nil, newPasswordHash: nil, hint: nil, email: nil)), automaticFloodWait: false) |> mapError { _ -> UpdateTwoStepVerificationSecureSecretError in return .generic } @@ -257,7 +257,7 @@ public func updateTwoStepVerificationEmail(account: Account, currentPassword: St } let flags: Int32 = 1 << 1 - return account.network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: Api.account.PasswordInputSettings.passwordInputSettings(flags: flags, newSalt: nil, newPasswordHash: nil, hint: nil, email: updatedEmail, newSecureSalt: nil, newSecureSecret: nil, newSecureSecretId: nil)), automaticFloodWait: false) + return account.network.request(Api.functions.account.updatePasswordSettings(currentPasswordHash: currentPasswordHash, newSettings: Api.account.PasswordInputSettings.passwordInputSettings(flags: flags, newSalt: nil, newPasswordHash: nil, hint: nil, email: updatedEmail)), automaticFloodWait: false) |> map { _ -> UpdateTwoStepVerificationPasswordResult in return .password(password: currentPassword, pendingEmailPattern: nil) } diff --git a/TelegramCore/VerifySecureIdValue.swift b/TelegramCore/VerifySecureIdValue.swift index 2c090c2899..2ab05e9264 100644 --- a/TelegramCore/VerifySecureIdValue.swift +++ b/TelegramCore/VerifySecureIdValue.swift @@ -24,7 +24,8 @@ public struct SecureIdPreparePhoneVerificationPayload { } public func secureIdPreparePhoneVerification(network: Network, value: SecureIdPhoneValue) -> Signal { - return network.request(Api.functions.account.sendVerifyPhoneCode(flags: 0, phoneNumber: value.phone, currentNumber: nil), automaticFloodWait: false) + return .never() + /*return network.request(Api.functions.account.sendVerifyPhoneCode(flags: 0, phoneNumber: value.phone, currentNumber: nil), automaticFloodWait: false) |> mapError { error -> SecureIdPreparePhoneVerificationError in if error.errorDescription.hasPrefix("FLOOD_WAIT") { return .flood @@ -38,7 +39,7 @@ public func secureIdPreparePhoneVerification(network: Network, value: SecureIdPh case let .sentCode(_, type, phoneCodeHash, nextType, timeout): return SecureIdPreparePhoneVerificationPayload(type: SentAuthorizationCodeType(apiType: type), nextType: nextType.flatMap(AuthorizationCodeNextType.init), timeout: timeout, phone: value.phone, phoneCodeHash: phoneCodeHash) } - } + }*/ } public enum SecureIdCommitPhoneVerificationError { @@ -48,7 +49,8 @@ public enum SecureIdCommitPhoneVerificationError { } public func secureIdCommitPhoneVerification(postbox: Postbox, network: Network, context: SecureIdAccessContext, payload: SecureIdPreparePhoneVerificationPayload, code: String) -> Signal { - return network.request(Api.functions.account.verifyPhone(phoneNumber: payload.phone, phoneCodeHash: payload.phoneCodeHash, phoneCode: code)) + return .never() + /*return network.request(Api.functions.account.verifyPhone(phoneNumber: payload.phone, phoneCodeHash: payload.phoneCodeHash, phoneCode: code)) |> mapError { error -> SecureIdCommitPhoneVerificationError in if error.errorDescription.hasPrefix("FLOOD_WAIT") { return .flood @@ -63,7 +65,7 @@ public func secureIdCommitPhoneVerification(postbox: Postbox, network: Network, |> mapError { _ -> SecureIdCommitPhoneVerificationError in return .generic } - } + }*/ } public enum SecureIdPrepareEmailVerificationError { @@ -77,7 +79,8 @@ public struct SecureIdPrepareEmailVerificationPayload { } public func secureIdPrepareEmailVerification(network: Network, value: SecureIdEmailValue) -> Signal { - return network.request(Api.functions.account.sendVerifyEmailCode(email: value.email), automaticFloodWait: false) + return .never() + /*return network.request(Api.functions.account.sendVerifyEmailCode(email: value.email), automaticFloodWait: false) |> mapError { error -> SecureIdPrepareEmailVerificationError in if error.errorDescription.hasPrefix("FLOOD_WAIT") { return .flood @@ -89,7 +92,7 @@ public func secureIdPrepareEmailVerification(network: Network, value: SecureIdEm case .sentEmailCode(_, let length): return SecureIdPrepareEmailVerificationPayload(email: value.email, length: length) } - } + }*/ } public enum SecureIdCommitEmailVerificationError { @@ -99,7 +102,8 @@ public enum SecureIdCommitEmailVerificationError { } public func secureIdCommitEmailVerification(postbox: Postbox, network: Network, context: SecureIdAccessContext, payload: SecureIdPrepareEmailVerificationPayload, code: String) -> Signal { - return network.request(Api.functions.account.verifyEmail(email: payload.email, code: code), automaticFloodWait: false) + return .never() + /*return network.request(Api.functions.account.verifyEmail(email: payload.email, code: code), automaticFloodWait: false) |> mapError { error -> SecureIdCommitEmailVerificationError in if error.errorDescription.hasPrefix("FLOOD_WAIT") { return .flood @@ -111,5 +115,5 @@ public func secureIdCommitEmailVerification(postbox: Postbox, network: Network, |> mapError { _ -> SecureIdCommitEmailVerificationError in return .generic } - } + }*/ }