From c03cc5f8fccf248ad6870127f0abf890166090a0 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Fri, 10 Jan 2020 17:17:31 -0800 Subject: [PATCH 01/22] Feature flags for production. --- SignalServiceKit/src/Util/FeatureFlags.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Util/FeatureFlags.swift b/SignalServiceKit/src/Util/FeatureFlags.swift index dc5d1bf1ef..2b51af21c5 100644 --- a/SignalServiceKit/src/Util/FeatureFlags.swift +++ b/SignalServiceKit/src/Util/FeatureFlags.swift @@ -18,7 +18,7 @@ extension FeatureBuild { } } -let build: FeatureBuild = OWSIsDebugBuild() ? .dev : .beta +let build: FeatureBuild = .production // MARK: - From 9d516083582e6e9d2a44b1a9e9e69e6cb5141d36 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Fri, 10 Jan 2020 17:18:02 -0800 Subject: [PATCH 02/22] Feature flags for production. --- SignalServiceKit/src/Util/FeatureFlags.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Util/FeatureFlags.swift b/SignalServiceKit/src/Util/FeatureFlags.swift index 2b51af21c5..f3c412d6d4 100644 --- a/SignalServiceKit/src/Util/FeatureFlags.swift +++ b/SignalServiceKit/src/Util/FeatureFlags.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. +// Copyright (c) 2020 Open Whisper Systems. All rights reserved. // import Foundation From 0adba618f6e7363119303a447a029a0998f48386 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Fri, 10 Jan 2020 17:18:04 -0800 Subject: [PATCH 03/22] "Bump build to 3.2.0.10." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index c42e968f4b..72bff7aa82 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -45,7 +45,7 @@ CFBundleVersion - 3.2.0.9 + 3.2.0.10 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index 0ce9483d98..b611fba4c7 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 3.2.0 CFBundleVersion - 3.2.0.9 + 3.2.0.10 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 7c682e185859f289608023246d7177ec1efa39a5 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 23 Jan 2020 08:56:05 -0800 Subject: [PATCH 04/22] Additional KBS vectors and normalization fix --- .../src/Util/KeyBackupService.swift | 2 +- .../tests/Util/kbs_pin_sanitation_vectors.json | 10 ++++++++++ SignalServiceKit/tests/Util/kbs_vectors.json | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Util/KeyBackupService.swift b/SignalServiceKit/src/Util/KeyBackupService.swift index 351aea6899..4ed6155c58 100644 --- a/SignalServiceKit/src/Util/KeyBackupService.swift +++ b/SignalServiceKit/src/Util/KeyBackupService.swift @@ -376,7 +376,7 @@ public class KeyBackupService: NSObject { var normalizedPin = pin.ows_stripped() // If this pin contains only numerals, ensure they are arabic numerals. - if pin.digitsOnly() == pin { normalizedPin = pin.ensureArabicNumerals } + if pin.digitsOnly() == normalizedPin { normalizedPin = normalizedPin.ensureArabicNumerals } // NFKD unicode normalization. return normalizedPin.decomposedStringWithCompatibilityMapping diff --git a/SignalServiceKit/tests/Util/kbs_pin_sanitation_vectors.json b/SignalServiceKit/tests/Util/kbs_pin_sanitation_vectors.json index fb7d9cd8dd..88a58427ee 100644 --- a/SignalServiceKit/tests/Util/kbs_pin_sanitation_vectors.json +++ b/SignalServiceKit/tests/Util/kbs_pin_sanitation_vectors.json @@ -63,5 +63,15 @@ "name": "NFKD Test, Single Char", "pin": "Ä", "bytes": "41cc88" + }, + { + "name": "Leading and trailing spaces around non-arabic digits", + "pin": " ١٢٣٤٥ ", + "bytes": "3132333435" + }, + { + "name": "Space in non-arabic digits", + "pin": "١٢٣ ٤٥٦", + "bytes": "d9a1d9a2d9a320d9a4d9a5d9a6" } ] diff --git a/SignalServiceKit/tests/Util/kbs_vectors.json b/SignalServiceKit/tests/Util/kbs_vectors.json index 37865a346b..996512347e 100644 --- a/SignalServiceKit/tests/Util/kbs_vectors.json +++ b/SignalServiceKit/tests/Util/kbs_vectors.json @@ -17,4 +17,22 @@ "iv_and_cipher":"9d9b05402ea39c17ff1c9298c8a0e86784a352aa02a74943bf8bcf07ec0f4b574a5b786ad0182c8d308d9eb06538b8c9", "registration_lock":"4a458afa1b07493b23ee9b3f287b70416b2388ca39b5b8c27b4b7585bf73f413" }, + { + "pin": " Pass६örd ", + "backup_id": "cba811749042b303a6a7efa5ccd160aea5e3ea243c8d2692bd13d515732f51a8", + "argon2_hash": "54853336a666eb66fbe8eb7a224b3ad3f457991ed74895b22ea9c6a4a46eda40ab645acdccc1652a48a34b2ac6926340ff35c03034013f68760f20013f028dd8", + "master_key": "9571f3fde1e58588ba49bcf82be1b301ca3859a6f59076f79a8f47181ef952bf", + "kbs_access_key": "ab645acdccc1652a48a34b2ac6926340ff35c03034013f68760f20013f028dd8", + "iv_and_cipher": "11c0ba1834db15e47c172f6c987c64bd4cfc69c6047dd67a022afeec0165a10943f204d5b8f37b3cb7bab21c6dfc39c8", + "registration_lock": "577939bccb2b6638c39222d5a97998a867c5e154e30b82cc120f2dd07a3de987" + }, + { + "pin": " ६१८ ", + "backup_id": "717dc111a98423a57196512606822fca646c653facd037c10728f14ba0be2ab3", + "argon2_hash": "8e9082faa57488f9ef98a6423c416a9974fb4d7c6bfc5b4f24de8e93afea199cd2fedabd0d4c17a371491c9722578843a26be3b4923e28d452ab2fc5491e794b", + "master_key": "0432d735b32f66d0e3a70d4f9cc821a8529521a4937d26b987715d8eff4e4c54", + "kbs_access_key": "d2fedabd0d4c17a371491c9722578843a26be3b4923e28d452ab2fc5491e794b", + "iv_and_cipher": "877ef871ef1fc668401c717ef21aa12e8523579fb1ff4474b76f28c2293537c80cc7569996c9e0229bea7f378e3a824e", + "registration_lock": "23a75cb1df1a87df45cc2ed167c2bdc85ab1220b847c88761b0005cac907fce5" + } ] From 34bfd8266f4aab3328b6689591afccb667c82b01 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 23 Jan 2020 08:56:34 -0800 Subject: [PATCH 05/22] Only enforce the old minimum length during registration, we might have migrated a 4 digit pin --- .../Registration/Onboarding2FAViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/Registration/Onboarding2FAViewController.swift b/Signal/src/ViewControllers/Registration/Onboarding2FAViewController.swift index 448faf3dee..a7ef88b5b6 100644 --- a/Signal/src/ViewControllers/Registration/Onboarding2FAViewController.swift +++ b/Signal/src/ViewControllers/Registration/Onboarding2FAViewController.swift @@ -199,7 +199,7 @@ public class Onboarding2FAViewController: OnboardingBaseViewController { pinToUse = pinToUse?.substring(to: Int(kLegacyTruncated2FAv1PinLength)) } - guard let pin = pinToUse?.ows_stripped(), pin.count >= (isUsingKBS ? kMin2FAv2PinLength : kMin2FAPinLength) else { + guard let pin = pinToUse?.ows_stripped(), pin.count >= kMin2FAPinLength else { // Check if we're already in an invalid state, if so we can do nothing guard !attemptState.isInvalid else { return } attemptState = .invalid(remainingAttempts: nil) From 4676a59c2a276dc9137ff0bfa054eddfec98b4b1 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 23 Jan 2020 08:56:48 -0800 Subject: [PATCH 06/22] Enable registrationLockV2 --- SignalServiceKit/src/Util/FeatureFlags.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Util/FeatureFlags.swift b/SignalServiceKit/src/Util/FeatureFlags.swift index b273d2016f..d1f3a448fa 100644 --- a/SignalServiceKit/src/Util/FeatureFlags.swift +++ b/SignalServiceKit/src/Util/FeatureFlags.swift @@ -176,7 +176,7 @@ public class FeatureFlags: NSObject { public static let onlyModernNotificationClearance = build.includes(.beta) @objc - public static let registrationLockV2 = false + public static let registrationLockV2 = true @objc public static var allowUUIDOnlyContacts: Bool { From e0328437da3e8f720d98a0caed8b9029b89daad7 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 23 Jan 2020 13:28:59 -0800 Subject: [PATCH 07/22] Production encalve info --- SignalServiceKit/src/TSConstants.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SignalServiceKit/src/TSConstants.swift b/SignalServiceKit/src/TSConstants.swift index 9221d6d5a4..14b63b73e6 100644 --- a/SignalServiceKit/src/TSConstants.swift +++ b/SignalServiceKit/src/TSConstants.swift @@ -163,8 +163,8 @@ private class TSConstantsProduction: TSConstantsProtocol { return contactDiscoveryEnclaveName } - public let keyBackupEnclaveName = "f2e2a5004794a6c1bac5c4949eadbc243dd02e02d1a93f10fe24584fb70815d8" - public let keyBackupMrEnclave = "f51f435802ada769e67aaf5744372bb7e7d519eecf996d335eb5b46b872b5789" + public let keyBackupEnclaveName = "fe7c1bfae98f9b073d220366ea31163ee82f6d04bead774f71ca8e5c40847bfe" + public let keyBackupMrEnclave = "a3baab19ef6ce6f34ab9ebb25ba722725ae44a8872dc0ff08ad6d83a9489de87" public var keyBackupServiceId: String { return keyBackupEnclaveName } From 2ef66eed289781edec22b37846812d9ce7c55089 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 23 Jan 2020 16:20:01 -0800 Subject: [PATCH 08/22] Add request type to KBS enclave requests. --- .../src/Network/API/Requests/OWSRequestFactory.h | 3 ++- .../src/Network/API/Requests/OWSRequestFactory.m | 2 ++ SignalServiceKit/src/Util/KeyBackupService.swift | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.h b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.h index d3023cc16f..652ca710dc 100644 --- a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.h +++ b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.h @@ -151,7 +151,8 @@ typedef NS_ENUM(NSUInteger, TSVerificationTransport) { TSVerificationTransportVo enclaveName:(NSString *)enclaveName authUsername:(NSString *)authUsername authPassword:(NSString *)authPassword - cookies:(NSArray *)cookies; + cookies:(NSArray *)cookies + requestType:(NSString *)requestType; #pragma mark - UD diff --git a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m index 601ef5b6be..012adc0889 100644 --- a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m +++ b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m @@ -723,6 +723,7 @@ NSString *const OWSRequestKey_AuthKey = @"AuthKey"; authUsername:(NSString *)authUsername authPassword:(NSString *)authPassword cookies:(NSArray *)cookies + requestType:(NSString *)requestType { NSString *path = [NSString stringWithFormat:@"v1/backup/%@", enclaveName]; @@ -733,6 +734,7 @@ NSString *const OWSRequestKey_AuthKey = @"AuthKey"; @"data" : data.base64EncodedString, @"iv" : cryptIv.base64EncodedString, @"mac" : cryptMac.base64EncodedString, + @"type" : requestType }]; request.authUsername = authUsername; diff --git a/SignalServiceKit/src/Util/KeyBackupService.swift b/SignalServiceKit/src/Util/KeyBackupService.swift index 4ed6155c58..562aa31ba2 100644 --- a/SignalServiceKit/src/Util/KeyBackupService.swift +++ b/SignalServiceKit/src/Util/KeyBackupService.swift @@ -562,7 +562,8 @@ public class KeyBackupService: NSObject { enclaveName: remoteAttestation.enclaveName, authUsername: remoteAttestation.auth.username, authPassword: remoteAttestation.auth.password, - cookies: remoteAttestation.cookies + cookies: remoteAttestation.cookies, + requestType: RequestType.stringRepresentation ) return (request, remoteAttestation) @@ -850,6 +851,8 @@ private protocol KBSRequestOption { associatedtype ResponseOptionType static func responseOption(from response: KeyBackupProtoResponse) -> ResponseOptionType? func set(on builder: KeyBackupProtoRequest.KeyBackupProtoRequestBuilder) + + static var stringRepresentation: String { get } } extension KeyBackupProtoBackupRequest: KBSRequestOption { @@ -860,6 +863,7 @@ extension KeyBackupProtoBackupRequest: KBSRequestOption { func set(on builder: KeyBackupProtoRequest.KeyBackupProtoRequestBuilder) { builder.setBackup(self) } + static var stringRepresentation: String { "backup" } } extension KeyBackupProtoRestoreRequest: KBSRequestOption { typealias ResponseOptionType = KeyBackupProtoRestoreResponse @@ -869,6 +873,7 @@ extension KeyBackupProtoRestoreRequest: KBSRequestOption { func set(on builder: KeyBackupProtoRequest.KeyBackupProtoRequestBuilder) { builder.setRestore(self) } + static var stringRepresentation: String { "restore" } } extension KeyBackupProtoDeleteRequest: KBSRequestOption { typealias ResponseOptionType = KeyBackupProtoDeleteResponse @@ -878,4 +883,5 @@ extension KeyBackupProtoDeleteRequest: KBSRequestOption { func set(on builder: KeyBackupProtoRequest.KeyBackupProtoRequestBuilder) { builder.setDelete(self) } + static var stringRepresentation: String { "delete" } } From deb7ce60196115a66a4109d75b0a446cd53cb05a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 24 Jan 2020 00:09:43 -0300 Subject: [PATCH 09/22] Set feature flags for internal build. --- SignalServiceKit/src/Util/FeatureFlags.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SignalServiceKit/src/Util/FeatureFlags.swift b/SignalServiceKit/src/Util/FeatureFlags.swift index d1f3a448fa..b33c5f261d 100644 --- a/SignalServiceKit/src/Util/FeatureFlags.swift +++ b/SignalServiceKit/src/Util/FeatureFlags.swift @@ -18,7 +18,7 @@ extension FeatureBuild { } } -let build: FeatureBuild = OWSIsDebugBuild() ? .dev : .beta +let build: FeatureBuild = OWSIsDebugBuild() ? .dev : .internalPreview // MARK: - @@ -247,7 +247,7 @@ public class FeatureFlags: NSObject { public static let reactionReceive = true @objc - public static let reactionSend = build.includes(.qa) + public static let reactionSend = true @objc public static let isUsingProductionService = true From 7bdabc5c42c704fb29395a1ce031e158929ab7f7 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 24 Jan 2020 00:10:05 -0300 Subject: [PATCH 10/22] "Bump build to 3.3.0.3." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index e4c5afab2b..4b72d1bb51 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -45,7 +45,7 @@ CFBundleVersion - 3.3.0.2 + 3.3.0.3 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index ca9c38d3e1..f8e6b3dd33 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 3.3.0 CFBundleVersion - 3.3.0.2 + 3.3.0.3 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From a174c1fa8eb8f2e4ad5f47751aeb4ec42a2f620a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 24 Jan 2020 00:11:27 -0300 Subject: [PATCH 11/22] Set feature flags for beta build. --- SignalServiceKit/src/Util/FeatureFlags.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SignalServiceKit/src/Util/FeatureFlags.swift b/SignalServiceKit/src/Util/FeatureFlags.swift index b33c5f261d..b273d2016f 100644 --- a/SignalServiceKit/src/Util/FeatureFlags.swift +++ b/SignalServiceKit/src/Util/FeatureFlags.swift @@ -18,7 +18,7 @@ extension FeatureBuild { } } -let build: FeatureBuild = OWSIsDebugBuild() ? .dev : .internalPreview +let build: FeatureBuild = OWSIsDebugBuild() ? .dev : .beta // MARK: - @@ -176,7 +176,7 @@ public class FeatureFlags: NSObject { public static let onlyModernNotificationClearance = build.includes(.beta) @objc - public static let registrationLockV2 = true + public static let registrationLockV2 = false @objc public static var allowUUIDOnlyContacts: Bool { @@ -247,7 +247,7 @@ public class FeatureFlags: NSObject { public static let reactionReceive = true @objc - public static let reactionSend = true + public static let reactionSend = build.includes(.qa) @objc public static let isUsingProductionService = true From 784a595013aaf15ed74837e8ee215fb7a473f03a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 24 Jan 2020 00:11:37 -0300 Subject: [PATCH 12/22] "Bump build to 3.3.0.4." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 4b72d1bb51..d5902dc00e 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -45,7 +45,7 @@ CFBundleVersion - 3.3.0.3 + 3.3.0.4 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index f8e6b3dd33..102b138bb1 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 3.3.0 CFBundleVersion - 3.3.0.3 + 3.3.0.4 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 568b28f5650a1816075f987ee50ee38656a5af18 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 24 Jan 2020 11:37:11 -0300 Subject: [PATCH 13/22] Honor incoming groups v2 envelopes feature flag. --- .../src/Network/Receiving/GroupsV2MessageProcessor.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SignalServiceKit/src/Network/Receiving/GroupsV2MessageProcessor.m b/SignalServiceKit/src/Network/Receiving/GroupsV2MessageProcessor.m index 4bded9c033..af29836e56 100644 --- a/SignalServiceKit/src/Network/Receiving/GroupsV2MessageProcessor.m +++ b/SignalServiceKit/src/Network/Receiving/GroupsV2MessageProcessor.m @@ -267,6 +267,11 @@ typedef void (^BatchCompletionBlock)(NSArray *, SD OWSAssertDebug(envelopeData); OWSAssertDebug(transaction); + if (!SSKFeatureFlags.incomingGroupsV2) { + // Discard envelope. + return; + } + // We need to persist the decrypted envelope data ASAP to prevent data loss. [self.finder addJobWithEnvelopeData:envelopeData plaintextData:plaintextData From a392d49cc0cdd07dd3a1952d2ae646dee81f2f93 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 24 Jan 2020 19:08:01 -0300 Subject: [PATCH 14/22] Avoid String.prefix() crash. --- Podfile.lock | 2 +- Pods | 2 +- .../AttachmentApproval/AttachmentCaptionViewController.swift | 2 +- SignalMessaging/utils/DisplayableText.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 7a49ea715e..1a5dafca8f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -332,7 +332,7 @@ CHECKOUT OPTIONS: :commit: b72c2d1e6132501db906de2cffa8ded7803c54f4 :git: https://github.com/signalapp/Mantle SignalCoreKit: - :commit: 85d0a90da6aac105c59bc56068a4d456ba80748d + :commit: be8b50315a5cd18bc5474e8c63b5cb56c1140b6b :git: https://github.com/signalapp/SignalCoreKit.git SignalMetadataKit: :commit: 33dc101ee66b25ba6f4310dce04d48276a934781 diff --git a/Pods b/Pods index 742ff90c6e..392b29244b 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 742ff90c6e402446e5d3abd48c508475bb8302a4 +Subproject commit 392b29244b3c570789ac11485cb533693ca8c3f5 diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentCaptionViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentCaptionViewController.swift index 39299346be..e665cbe9d8 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentCaptionViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentCaptionViewController.swift @@ -294,7 +294,7 @@ extension AttachmentCaptionViewController: UITextViewDelegate { // Accept as much of the input as we can let charBudget: Int = Int(kMaxCaptionCharacterCount) - charsAfterDelete if charBudget >= 0 { - let acceptableNewText = String(text.prefix(charBudget)) + let acceptableNewText = text.safePrefix(charBudget) textView.text = (existingText as NSString).replacingCharacters(in: range, with: acceptableNewText) } diff --git a/SignalMessaging/utils/DisplayableText.swift b/SignalMessaging/utils/DisplayableText.swift index cc5915c98c..37253ef147 100644 --- a/SignalMessaging/utils/DisplayableText.swift +++ b/SignalMessaging/utils/DisplayableText.swift @@ -157,7 +157,7 @@ import Foundation let truncatedContent: Content? if fullText.count > kMaxTextDisplayLength { // Trim whitespace before _AND_ after slicing the snipper from the string. - let snippet = String(fullText.prefix(kMaxTextDisplayLength)).ows_stripped() + let snippet = fullText.safePrefix(kMaxTextDisplayLength).ows_stripped() let truncatedText = String(format: NSLocalizedString("OVERSIZE_TEXT_DISPLAY_FORMAT", comment: "A display format for oversize text messages."), snippet) From 1895eb1c80e3a19d365840396370f5848cc0325f Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Fri, 24 Jan 2020 19:54:33 -0800 Subject: [PATCH 15/22] RingRTC v0.3.3 --- Podfile.lock | 8 ++++---- Pods | 2 +- Signal/Signal-Info.plist | 2 +- ThirdParty/RingRTC | 2 +- ThirdParty/SignalRingRTC.podspec | 2 +- ThirdParty/WebRTC | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 1a5dafca8f..76ae94768f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -106,10 +106,10 @@ PODS: - HKDFKit - SignalCoreKit - SwiftProtobuf - - SignalRingRTC (0.3.2): + - SignalRingRTC (0.3.3): - SignalCoreKit - - SignalRingRTC/WebRTC (= 0.3.2) - - SignalRingRTC/WebRTC (0.3.2): + - SignalRingRTC/WebRTC (= 0.3.3) + - SignalRingRTC/WebRTC (0.3.3): - SignalCoreKit - SignalServiceKit (0.9.0): - AFNetworking @@ -366,7 +366,7 @@ SPEC CHECKSUMS: SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c SignalCoreKit: 4562b2bbd9830077439ca003f952a798457d4ea5 SignalMetadataKit: a7aacedf262d947c22e2c619f0fd217163d2a637 - SignalRingRTC: a6ebe5dd4e33a747a9ee63c9a99105e074e6344a + SignalRingRTC: 02c1229fa80b5168bbfb9a8541905dbfe1594046 SignalServiceKit: 71856e789067b45672443a9fdc5152409db2cd19 SQLCipher: 4636a257060f6f1b4e143a143028b61a2b462d0d SSZipArchive: 41455d4b8d2b6ab93990820b50dc697c2554a322 diff --git a/Pods b/Pods index 392b29244b..dad5e9fe6a 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 392b29244b3c570789ac11485cb533693ca8c3f5 +Subproject commit dad5e9fe6a87d858a54b597981363d084ec25b95 diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 72bff7aa82..4301fb931e 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -7,7 +7,7 @@ OSXVersion 10.15.1 WebRTCCommit - 7115a09728e023ca6132e14bd9d5f8bc5e1f0b92 Production build of v0.3.1 (Xcode 10.3) + 340f483e44db600c8055f2eaac44ff6c5e478297 Production build of v0.3.3 CFBundleDevelopmentRegion en diff --git a/ThirdParty/RingRTC b/ThirdParty/RingRTC index 939fff4cca..adbcd0196a 160000 --- a/ThirdParty/RingRTC +++ b/ThirdParty/RingRTC @@ -1 +1 @@ -Subproject commit 939fff4cca0d3b9703a4147226932a784e622d72 +Subproject commit adbcd0196a3afa589dd2e1e3ac50624ac6491752 diff --git a/ThirdParty/SignalRingRTC.podspec b/ThirdParty/SignalRingRTC.podspec index 2baef65c4b..2e2d791243 100644 --- a/ThirdParty/SignalRingRTC.podspec +++ b/ThirdParty/SignalRingRTC.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "SignalRingRTC" - s.version = "0.3.2" + s.version = "0.3.3" s.summary = "A Swift & Objective-C library used by the Signal iOS app for WebRTC interactions." s.description = <<-DESC diff --git a/ThirdParty/WebRTC b/ThirdParty/WebRTC index 7115a09728..340f483e44 160000 --- a/ThirdParty/WebRTC +++ b/ThirdParty/WebRTC @@ -1 +1 @@ -Subproject commit 7115a09728e023ca6132e14bd9d5f8bc5e1f0b92 +Subproject commit 340f483e44db600c8055f2eaac44ff6c5e478297 From 1995034a7de2ddbbf0b601ee6b654ac2f2df6684 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Fri, 24 Jan 2020 19:54:58 -0800 Subject: [PATCH 16/22] "Bump build to 3.2.1.0." --- Signal/Signal-Info.plist | 4 ++-- SignalShareExtension/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 4301fb931e..614fc64844 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -28,7 +28,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.2.0 + 3.2.1 CFBundleSignature ???? CFBundleURLTypes @@ -45,7 +45,7 @@ CFBundleVersion - 3.2.0.10 + 3.2.1.0 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index b611fba4c7..9f21494ace 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 3.2.0 + 3.2.1 CFBundleVersion - 3.2.0.10 + 3.2.1.0 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 91e2a88cb58d46d3eac75aab7ce6151a09c55225 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Sat, 25 Jan 2020 11:59:18 -0800 Subject: [PATCH 17/22] Fix duplicate 2FA reminders --- Signal/src/AppDelegate.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index fa5bffde8e..9a6587f2a7 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -749,7 +749,8 @@ NSString *NSStringForLaunchFailure(LaunchFailure launchFailure) reminderVC.modalPresentationStyle = UIModalPresentationFullScreen; } - if ([frontmostViewController isKindOfClass:[reminderVC class]]) { + if ([frontmostViewController isKindOfClass:[OWSPinReminderViewController class]] || + [frontmostViewController isKindOfClass:[OWS2FAReminderViewController class]]) { // We're already presenting this return; } From 8a9531f0fa62d533ce55bb8d58b1493b857d851b Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Sat, 25 Jan 2020 13:42:57 -0800 Subject: [PATCH 18/22] Preserve ordering of albums saved from share sheet --- .../attachments/AttachmentSharing.m | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/SignalMessaging/attachments/AttachmentSharing.m b/SignalMessaging/attachments/AttachmentSharing.m index 4f4c698755..be53d528cb 100644 --- a/SignalMessaging/attachments/AttachmentSharing.m +++ b/SignalMessaging/attachments/AttachmentSharing.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. +// Copyright (c) 2020 Open Whisper Systems. All rights reserved. // #import "AttachmentSharing.h" @@ -17,16 +17,14 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssertDebug(stream); - [self showShareUIForURL:stream.originalMediaURL sender:sender]; + [self showShareUIForAttachments:@[stream] sender:sender]; } + (void)showShareUIForAttachments:(NSArray *)attachments sender:(nullable id)sender { OWSAssertDebug(attachments.count > 0); - [self showShareUIForURLs:[attachments map:^(TSAttachmentStream *attachment){ - return attachment.originalMediaURL; - }] sender:sender completion:nil]; + [self showShareUIForActivityItems:attachments sender:sender completion:nil]; } + (void)showShareUIForURL:(NSURL *)url sender:(nullable id)sender @@ -148,4 +146,31 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface TSAttachmentStream (AttachmentSharing) + +@end + +@implementation TSAttachmentStream (AttachmentSharing) + +// called to determine data type. only the class of the return type is consulted. it should match what -itemForActivityType: returns later +- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController { + // HACK: If this is an image we want to provide the image object to + // the share sheet rather than the file path. This ensures that when + // the user saves multiple images to their camera roll the OS doesn't + // asynchronously read the files and save them to them in a random + // order. Note: when sharing a mixture of image and non-image data + // (e.g. an album with photos and videos) the OS will still incorrectly + // order the video items. I haven't found any way to work around this + // since videos may only be shared as URLs. + return self.isImage ? [UIImage new] : self.originalMediaURL; +} + +// called to fetch data after an activity is selected. you can return nil. +- (nullable id)activityViewController:(UIActivityViewController *)activityViewController + itemForActivityType:(nullable UIActivityType)activityType { + return self.isImage ? self.originalImage : self.originalMediaURL; +} + +@end + NS_ASSUME_NONNULL_END From f5223131988f0d7fabf3c5b8ebb8ee4f73db1b9f Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Sat, 25 Jan 2020 14:13:19 -0800 Subject: [PATCH 19/22] Fix sharing of URLs. --- SignalShareExtension/ShareViewController.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index c604f96aab..69b8a8bd1b 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -679,6 +679,14 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed return UnloadedItem(itemProvider: itemProvider, itemType: .other) } + // Prefer a URL if available. If there's an image item and a URL item, + // the URL is generally more useful. e.g. when sharing an app from the + // App Store the image would be the app icon and the URL is the link + // to the application. + if let urlItem = itemsToLoad.first(where: { $0.itemType == .webUrl }) { + return [urlItem] + } + let visualMediaItems = itemsToLoad.filter { ShareViewController.isVisualMediaItem(itemProvider: $0.itemProvider) } // We only allow sharing 1 item, unless they are visual media items. And if they are From 1d42c4c86b578066c9539503fc0ab0a05e7b0c93 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Sat, 25 Jan 2020 14:27:01 -0800 Subject: [PATCH 20/22] Preserve message text when pasting an attachment. --- .../ConversationView/ConversationViewController.m | 4 +++- .../AttachmentApprovalViewController.swift | 2 ++ .../ViewControllers/SharingThreadPickerViewController.m | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 35a20e12cf..c18288cfe7 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3851,7 +3851,9 @@ typedef enum : NSUInteger { - (void)showApprovalDialogForAttachments:(NSArray *)attachments { OWSNavigationController *modal = - [AttachmentApprovalViewController wrappedInNavControllerWithAttachments:attachments approvalDelegate:self]; + [AttachmentApprovalViewController wrappedInNavControllerWithAttachments:attachments + initialMessageText:self.inputToolbar.messageText + approvalDelegate:self]; [self presentFullScreenViewController:modal animated:YES completion:nil]; } diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift index 17b03ab82f..c25baf5947 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift @@ -130,6 +130,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC @objc public class func wrappedInNavController(attachments: [SignalAttachment], + initialMessageText: String?, approvalDelegate: AttachmentApprovalViewControllerDelegate) -> OWSNavigationController { @@ -137,6 +138,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC let vc = AttachmentApprovalViewController(options: [.hasCancel], sendButtonImageName: "send-solid-24", attachmentApprovalItems: attachmentApprovalItems) + vc.messageText = initialMessageText vc.approvalDelegate = approvalDelegate let navController = OWSNavigationController(rootViewController: vc) navController.ows_prefersStatusBarHidden = true diff --git a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m index 2f52b0fb2f..0e226b9fd5 100644 --- a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m +++ b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. +// Copyright (c) 2020 Open Whisper Systems. All rights reserved. // #import "SharingThreadPickerViewController.h" @@ -151,7 +151,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion); } OWSNavigationController *approvalModal = - [AttachmentApprovalViewController wrappedInNavControllerWithAttachments:self.attachments approvalDelegate:self]; + [AttachmentApprovalViewController wrappedInNavControllerWithAttachments:self.attachments + initialMessageText:nil + approvalDelegate:self]; [self presentViewController:approvalModal animated:YES completion:nil]; } From 93663765a7012a948b238fc5049a432044bb2c2a Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Sat, 25 Jan 2020 14:43:46 -0800 Subject: [PATCH 21/22] Fix vertical alignment of conversation + attachment approval textView --- .../ViewControllers/ConversationView/ConversationInputToolbar.m | 2 +- .../AttachmentApproval/AttachmentTextToolbar.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index b3fe595324..e731bdfde5 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -30,7 +30,7 @@ typedef NS_CLOSED_ENUM(NSUInteger, KeyboardType) { KeyboardType_System, Keyboard static void *kConversationInputTextViewObservingContext = &kConversationInputTextViewObservingContext; -const CGFloat kMinTextViewHeight = 38; +const CGFloat kMinTextViewHeight = 36; const CGFloat kMinToolbarItemHeight = 44; const CGFloat kMaxTextViewHeight = 98; const CGFloat kMaxIPadTextViewHeight = 142; diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift index b91ef0cc39..c7ed57c3f2 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift @@ -62,7 +62,7 @@ class AttachmentTextToolbar: UIView, UITextViewDelegate { // Layout Constants let kMinToolbarItemHeight: CGFloat = 40 - let kMinTextViewHeight: CGFloat = 38 + let kMinTextViewHeight: CGFloat = 36 var maxTextViewHeight: CGFloat { // About ~4 lines in portrait and ~3 lines in landscape. // Otherwise we risk obscuring too much of the content. From 33a730a3aaa68e47bba806e0e7ade993ec1e1a4a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 27 Jan 2020 09:28:50 -0300 Subject: [PATCH 22/22] "Bump build to 3.3.0.5." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 4f383602a7..fed1129bbd 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -45,7 +45,7 @@ CFBundleVersion - 3.3.0.4 + 3.3.0.5 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index 102b138bb1..760c903202 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 3.3.0 CFBundleVersion - 3.3.0.4 + 3.3.0.5 ITSAppUsesNonExemptEncryption NSAppTransportSecurity