diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTKeychain.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTKeychain.h index 8bded10053..1402fb9127 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTKeychain.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTKeychain.h @@ -10,3 +10,9 @@ - (void)removeObjectForKey:(NSString *)aKey group:(NSString *)group; @end + +@interface MTDeprecated : NSObject + ++ (id)unarchiveDeprecatedWithData:(NSData *)data; + +@end diff --git a/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m b/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m index 7b339d497d..137b2ce408 100644 --- a/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m +++ b/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m @@ -82,6 +82,10 @@ [bindRequestData appendInt32:expiresAt]; [bindRequestData appendTLBytes:encryptedMessage]; + if (MTLogEnabled()) { + MTLog(@"[MTBindKeyMessageService#%p binding temp %" PRId64 " to persistent %" PRId64 "]", self, _ephemeralKey.authKeyId, _persistentKey.authKeyId); + } + MTOutgoingMessage *outgoingMessage = [[MTOutgoingMessage alloc] initWithData:bindRequestData.data metadata:[NSString stringWithFormat:@"auth.bindTempAuthKey"] additionalDebugDescription:nil shortMetadata:@"auth.bindTempAuthKey" messageId:bindingMessageId messageSeqNo:bindingSeqNo]; return [[MTMessageTransaction alloc] initWithMessagePayload:@[outgoingMessage] prepared:nil failed:nil completion:^(NSDictionary *messageInternalIdToTransactionId, NSDictionary *messageInternalIdToPreparedMessage, __unused NSDictionary *messageInternalIdToQuickAckId) { diff --git a/submodules/MtProtoKit/Sources/MTKeychain.m b/submodules/MtProtoKit/Sources/MTKeychain.m index 80660fa86b..f50257e2c7 100644 --- a/submodules/MtProtoKit/Sources/MTKeychain.m +++ b/submodules/MtProtoKit/Sources/MTKeychain.m @@ -1 +1,18 @@ #import + +@implementation MTDeprecated + ++ (id)unarchiveDeprecatedWithData:(NSData *)data { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + @try { + return [NSKeyedUnarchiver unarchiveObjectWithData:data]; + } @catch(NSException *e) { + return nil; + } +#pragma clang diagnostic pop +} + +@end + + diff --git a/submodules/MtProtoKit/Sources/MTProto.m b/submodules/MtProtoKit/Sources/MTProto.m index e83566a145..725a95e696 100644 --- a/submodules/MtProtoKit/Sources/MTProto.m +++ b/submodules/MtProtoKit/Sources/MTProto.m @@ -865,9 +865,9 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; } } -- (NSString *)outgoingMessageDescription:(MTOutgoingMessage *)message messageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo +- (NSString *)outgoingMessageDescription:(MTOutgoingMessage *)message messageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo authKeyId:(int64_t)authKeyId { - return [[NSString alloc] initWithFormat:@"%@%@ (%" PRId64 "/%" PRId32 ")", message.metadata, message.additionalDebugDescription != nil ? message.additionalDebugDescription : @"", message.messageId == 0 ? messageId : message.messageId, message.messageSeqNo == 0 ? message.messageSeqNo : messageSeqNo]; + return [[NSString alloc] initWithFormat:@"%@%@ (%" PRId64 "/%" PRId32 " %" PRId64 ")", message.metadata, message.additionalDebugDescription != nil ? message.additionalDebugDescription : @"", message.messageId == 0 ? messageId : message.messageId, message.messageSeqNo == 0 ? message.messageSeqNo : messageSeqNo, authKeyId]; } - (NSString *)outgoingShortMessageDescription:(MTOutgoingMessage *)message messageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo @@ -1100,7 +1100,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; NSData *data = messageData; if (MTLogEnabled()) { - NSString *messageDescription = [self outgoingMessageDescription:outgoingMessage messageId:messageId messageSeqNo:messageSeqNo]; + NSString *messageDescription = [self outgoingMessageDescription:outgoingMessage messageId:messageId messageSeqNo:messageSeqNo authKeyId:authKey.authKeyId]; MTLogWithPrefix(_getLogPrefix, @"[MTProto#%p@%p preparing %@]", self, _context, messageDescription); } NSString *shortMessageDescription = [self outgoingShortMessageDescription:outgoingMessage messageId:messageId messageSeqNo:messageSeqNo]; diff --git a/submodules/TelegramCore/Sources/Account/Account.swift b/submodules/TelegramCore/Sources/Account/Account.swift index 3bd1ba3507..971e24bb3b 100644 --- a/submodules/TelegramCore/Sources/Account/Account.swift +++ b/submodules/TelegramCore/Sources/Account/Account.swift @@ -838,7 +838,7 @@ public func accountBackupData(postbox: Postbox) -> Signal Any? { + return MTDeprecated.unarchiveDeprecated(with: data) +} + private struct MTProtoConnectionFlags: OptionSet { let rawValue: Int @@ -1138,12 +1142,11 @@ class Keychain: NSObject, MTKeychain { } if let data = self.get(group + ":" + aKey) { var result: NSDictionary? - MTContext.perform(objCTry: { - result = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NSDictionary.self, from: data as Data) - }) + result = MTDeprecated.unarchiveDeprecated(with: data as Data) as? NSDictionary if let result = result { return result as? [AnyHashable : Any] } + assertionFailure("Unexpected keychain entry type") } return nil } @@ -1154,10 +1157,11 @@ class Keychain: NSObject, MTKeychain { } if let data = self.get(group + ":" + aKey) { var result: NSNumber? - MTContext.perform(objCTry: { - result = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NSNumber.self, from: data as Data) - }) - return result + result = MTDeprecated.unarchiveDeprecated(with: data as Data) as? NSNumber + if let result = result { + return result + } + assertionFailure("Unexpected keychain entry type") } return nil } diff --git a/submodules/TelegramUI/Components/Resources/FetchVideoMediaResource/Sources/FetchVideoMediaResource.swift b/submodules/TelegramUI/Components/Resources/FetchVideoMediaResource/Sources/FetchVideoMediaResource.swift index 4702db6484..5acad8a76b 100644 --- a/submodules/TelegramUI/Components/Resources/FetchVideoMediaResource/Sources/FetchVideoMediaResource.swift +++ b/submodules/TelegramUI/Components/Resources/FetchVideoMediaResource/Sources/FetchVideoMediaResource.swift @@ -334,7 +334,7 @@ public func fetchVideoLibraryMediaResource(postbox: Postbox, resource: VideoLibr if let values = try? JSONDecoder().decode(MediaEditorValues.self, from: adjustmentsValue.data.makeData()) { mediaEditorValues = values } - } else if let dict = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NSDictionary.self, from: adjustmentsValue.data.makeData()) as? [AnyHashable : Any], let legacyAdjustments = TGVideoEditAdjustments(dictionary: dict) { + } else if let dict = legacy_unarchiveDeprecated(data: adjustmentsValue.data.makeData()) as? [AnyHashable : Any], let legacyAdjustments = TGVideoEditAdjustments(dictionary: dict) { if alwaysUseModernPipeline { mediaEditorValues = MediaEditorValues(legacyAdjustments: legacyAdjustments, defaultPreset: qualityPreset) } else { @@ -500,7 +500,7 @@ public func fetchLocalFileVideoMediaResource(postbox: Postbox, resource: LocalFi if let values = try? JSONDecoder().decode(MediaEditorValues.self, from: videoAdjustments.data.makeData()) { mediaEditorValues = values } - } else if let dict = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NSDictionary.self, from: videoAdjustments.data.makeData()) as? [AnyHashable : Any], let legacyAdjustments = TGVideoEditAdjustments(dictionary: dict) { + } else if let dict = legacy_unarchiveDeprecated(data: videoAdjustments.data.makeData()) as? [AnyHashable : Any], let legacyAdjustments = TGVideoEditAdjustments(dictionary: dict) { if alwaysUseModernPipeline && !isImage { mediaEditorValues = MediaEditorValues(legacyAdjustments: legacyAdjustments, defaultPreset: qualityPreset) } else { @@ -710,7 +710,7 @@ public func fetchVideoLibraryMediaResourceHash(resource: VideoLibraryMediaResour adjustments = nil case let .compress(adjustmentsValue): if let adjustmentsValue = adjustmentsValue { - if let dict = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NSDictionary.self, from: adjustmentsValue.data.makeData()) as? [AnyHashable : Any], let legacyAdjustments = TGVideoEditAdjustments(dictionary: dict) { + if let dict = legacy_unarchiveDeprecated(data: adjustmentsValue.data.makeData()) as? [AnyHashable : Any], let legacyAdjustments = TGVideoEditAdjustments(dictionary: dict) { adjustments = legacyAdjustments } }