Skip to content

Commit 11aa1f4

Browse files
committed
Merge branch 'release/0.27.8/master'
2 parents 26764b1 + 754e2fc commit 11aa1f4

File tree

20 files changed

+85
-43
lines changed

20 files changed

+85
-43
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Changes in 0.27.8 (2024-05-29)
2+
3+
🙌 Improvements
4+
5+
- When sorting room list alphabetically, sort it case-insensitive. ([#1851](https://github.com/matrix-org/matrix-ios-sdk/pull/1851))
6+
- Crypto: Update crypto SDK to 0.4.1 ([#1853](https://github.com/matrix-org/matrix-ios-sdk/pull/1853))
7+
8+
19
## Changes in 0.27.7 (2024-05-01)
210

311
No significant changes.

MatrixSDK.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "MatrixSDK"
4-
s.version = "0.27.7"
4+
s.version = "0.27.8"
55
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"
66

77
s.description = <<-DESC
@@ -45,7 +45,7 @@ Pod::Spec.new do |s|
4545
ss.dependency 'OLMKit', '~> 3.2.5'
4646
ss.dependency 'Realm', '10.27.0'
4747
ss.dependency 'libbase58', '~> 0.1.4'
48-
ss.dependency 'MatrixSDKCrypto', '0.3.13', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true
48+
ss.dependency 'MatrixSDKCrypto', '0.4.2', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true
4949
end
5050

5151
s.subspec 'JingleCallStack' do |ss|

MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventDecryption.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,13 @@ actor MXRoomEventDecryption: MXRoomEventDecrypting {
227227
])
228228
return trackedDecryptionResult(for: event, error: error)
229229

230-
case .MissingRoomKey(let message):
230+
case .MissingRoomKey(let message, let withheldCode):
231231
if undecryptedEvents[sessionId] == nil {
232232
log.error("Failed to decrypt event(s) due to missing room keys", context: [
233233
"session_id": sessionId,
234234
"message": message,
235235
"error": error,
236+
"withheldCode": withheldCode ?? "N/A",
236237
"details": "further errors for the same key will be supressed",
237238
])
238239
}

MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ class MXCryptoMachine {
116116
}
117117
}
118118

119+
func invalidateCache() async {
120+
await machine.clearCryptoCache()
121+
}
122+
119123
// MARK: - Private
120124

121125
private static func createMachine(userId: String, deviceId: String, log: MXNamedLog) throws -> OlmMachine {
@@ -591,9 +595,14 @@ extension MXCryptoMachine: MXCryptoCrossSigning {
591595

592596
func bootstrapCrossSigning(authParams: [AnyHashable: Any]) async throws {
593597
let result = try machine.bootstrapCrossSigning()
598+
// If this is called before the device keys have been uploaded there will be a
599+
// request to upload them, do that first.
600+
if let optionalKeyRequest = result.uploadKeysRequest {
601+
try await handleRequest(optionalKeyRequest)
602+
}
594603
let _ = try await [
595604
requests.uploadSigningKeys(request: result.uploadSigningKeysRequest, authParams: authParams),
596-
requests.uploadSignatures(request: result.signatureRequest)
605+
requests.uploadSignatures(request: result.uploadSignatureRequest)
597606
]
598607
}
599608

@@ -833,7 +842,7 @@ extension MXCryptoMachine: MXCryptoBackup {
833842
guard let message = MXCryptoTools.canonicalJSONString(forJSON: object) else {
834843
throw Error.cannotSerialize
835844
}
836-
return machine.sign(message: message)
845+
return try machine.sign(message: message)
837846
}
838847

839848
func backupRoomKeys() async throws {

MatrixSDK/Crypto/Dehydration/DehydrationService.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class DehydrationService: NSObject {
6868
// Convert it back to Data
6969
let pickleKeyData = MXBase64Tools.data(fromBase64: base64PickleKey)
7070

71-
let rehydrationResult = await rehydrateDevice(pickleKeyData: [UInt8](pickleKeyData))
71+
let rehydrationResult = await rehydrateDevice(pickleKeyData: pickleKeyData)
7272
switch rehydrationResult {
7373
case .success((let deviceId, let rehydratedDevice)):
7474
// Fetch and process the to device events available on the dehydrated device
@@ -86,14 +86,15 @@ public class DehydrationService: NSObject {
8686
}
8787

8888
// Finally, create a new dehydrated device with the same pickle key
89-
try await dehydrateDevice(pickleKeyData: [UInt8](pickleKeyData))
89+
try await dehydrateDevice(pickleKeyData: pickleKeyData)
9090
} else { // Otherwise, generate a new dehydration pickle key, store it and dehydrate a device
9191
// Generate a new dehydration pickle key
92-
var pickleKeyData = [UInt8](repeating: 0, count: 32)
93-
_ = SecRandomCopyBytes(kSecRandomDefault, 32, &pickleKeyData)
92+
var pickleKeyRaw = [UInt8](repeating: 0, count: 32)
93+
_ = SecRandomCopyBytes(kSecRandomDefault, 32, &pickleKeyRaw)
94+
let pickleKeyData = Data(bytes: pickleKeyRaw, count: 32)
9495

9596
// Convert it to unpadded base 64
96-
let base64PickleKey = MXBase64Tools.unpaddedBase64(from: Data(bytes: pickleKeyData, count: 32))
97+
let base64PickleKey = MXBase64Tools.unpaddedBase64(from: pickleKeyData)
9798

9899
// Store it on the backend
99100
try await storeSecret(base64PickleKey, secretId: secretId, secretStorageKeys: [secretStorageKeyId: privateKeyData])
@@ -131,10 +132,10 @@ public class DehydrationService: NSObject {
131132

132133
// MARK: - Device dehydration
133134

134-
private func dehydrateDevice(pickleKeyData: [UInt8]) async throws {
135-
let dehydratedDevice = dehydratedDevices.create()
135+
private func dehydrateDevice(pickleKeyData: Data) async throws {
136+
let dehydratedDevice = try dehydratedDevices.create()
136137

137-
let requestDetails = try dehydratedDevice.keysForUpload(deviceDisplayName: deviceDisplayName, pickleKey: [UInt8](pickleKeyData))
138+
let requestDetails = try dehydratedDevice.keysForUpload(deviceDisplayName: deviceDisplayName, pickleKey: pickleKeyData)
138139

139140
let parameters = MXDehydratedDeviceCreationParameters()
140141
parameters.body = requestDetails.body
@@ -150,7 +151,7 @@ public class DehydrationService: NSObject {
150151
}
151152
}
152153

153-
private func rehydrateDevice(pickleKeyData: [UInt8]) async -> Result<(deviceId: String, rehydratedDevice: RehydratedDeviceProtocol), DehydrationServiceError> {
154+
private func rehydrateDevice(pickleKeyData: Data) async -> Result<(deviceId: String, rehydratedDevice: RehydratedDeviceProtocol), DehydrationServiceError> {
154155
await withCheckedContinuation { continuation in
155156
self.restClient.retrieveDehydratedDevice { [weak self] dehydratedDevice in
156157
guard let self else { return }
@@ -163,7 +164,7 @@ public class DehydrationService: NSObject {
163164
}
164165

165166
do {
166-
let rehydratedDevice = try self.dehydratedDevices.rehydrate(pickleKey: [UInt8](pickleKeyData), deviceId: dehydratedDevice.deviceId, deviceData: deviceDataJSON)
167+
let rehydratedDevice = try self.dehydratedDevices.rehydrate(pickleKey: pickleKeyData, deviceId: dehydratedDevice.deviceId, deviceData: deviceDataJSON)
167168
continuation.resume(returning: .success((dehydratedDevice.deviceId, rehydratedDevice)))
168169
} catch {
169170
continuation.resume(returning: .failure(DehydrationServiceError.failedRehydration(error)))

MatrixSDK/Crypto/MXCrypto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ extern NSString *const MXDeviceListDidUpdateUsersDevicesNotification;
378378
*/
379379
- (void)setBlacklistUnverifiedDevicesInRoom:(NSString *)roomId blacklist:(BOOL)blacklist;
380380

381+
- (void) invalidateCache:(void (^)(void))done;
382+
381383
@end
382384

383385
NS_ASSUME_NONNULL_END

MatrixSDK/Crypto/MXCryptoV2.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import MatrixSDKCrypto
2020
/// An implementation of `MXCrypto` which uses [matrix-rust-sdk](https://github.com/matrix-org/matrix-rust-sdk/tree/main/crates/matrix-sdk-crypto)
2121
/// under the hood.
2222
class MXCryptoV2: NSObject, MXCrypto {
23+
2324
enum Error: Swift.Error {
2425
case cannotUnsetTrust
2526
case backupNotEnabled
@@ -720,4 +721,13 @@ class MXCryptoV2: NSObject, MXCrypto {
720721
return dict[info.userId] = info
721722
}
722723
}
723-
}
724+
725+
func invalidateCache(_ done: @escaping () -> Void) {
726+
Task {
727+
log.debug("Invalidating Olm Machine crypto store cache.")
728+
await machine.invalidateCache()
729+
await MainActor.run {
730+
done()
731+
}
732+
}
733+
}}

MatrixSDK/Crypto/Migration/Data/MXCryptoMigrationStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct MXCryptoMigrationStore {
5454
account: try pickledAccount(pickleKey: pickleKey),
5555
sessions: [], // Sessions are extracted in batches separately
5656
inboundGroupSessions: [], // Group sessions are extracted in batches separately
57-
pickleKey: [UInt8](pickleKey),
57+
pickleKey: pickleKey,
5858
backupVersion: legacyStore.backupVersion,
5959
backupRecoveryKey: backupRecoveryKey(),
6060
crossSigning: crossSigning(),
@@ -194,7 +194,7 @@ private extension PickledAccount {
194194
private extension PickledSession {
195195
init(session: MXOlmSession, pickleKey: Data) throws {
196196
let pickle = try session.session.serializeData(withKey: pickleKey)
197-
let time = "\(Int(session.lastReceivedMessageTs))"
197+
let time = UInt64(session.lastReceivedMessageTs)
198198

199199
self.init(
200200
pickle: pickle,

MatrixSDK/Data/RoomList/Common/MXRoomListDataSortable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension MXRoomListDataSortable {
5252
// }
5353

5454
if sortOptions.alphabetical {
55-
result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.displayName, ascending: true))
55+
result.append(NSSortDescriptor(key: "displayName", ascending: true, selector: #selector(NSString.localizedStandardCompare(_:))))
5656
}
5757

5858
if sortOptions.invitesFirst {

MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ extension MXCoreDataRoomListDataFetcher: MXRoomListDataSortable {
250250
var result: [NSSortDescriptor] = []
251251

252252
if sortOptions.alphabetical {
253-
result.append(NSSortDescriptor(keyPath: \MXRoomSummaryMO.s_displayName, ascending: true))
253+
result.append(NSSortDescriptor(key: "s_displayName", ascending: true, selector: #selector(NSString.localizedStandardCompare(_:))))
254254
}
255255

256256
if sortOptions.invitesFirst {

0 commit comments

Comments
 (0)