Skip to content

Commit f4e268f

Browse files
author
gulekismail
committed
Merge branch 'release/0.24.1/master'
2 parents cc89463 + 92e9fca commit f4e268f

File tree

110 files changed

+2381
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2381
-522
lines changed

CHANGES.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
## Changes in 0.24.1 (2022-10-18)
2+
3+
🙌 Improvements
4+
5+
- Support additional content in voice message. ([#1595](https://github.com/matrix-org/matrix-ios-sdk/pull/1595))
6+
- Key verification: Refactor verification manager, requests, transactions ([#1599](https://github.com/matrix-org/matrix-ios-sdk/pull/1599))
7+
- Crypto: Refactor QR transactions ([#1602](https://github.com/matrix-org/matrix-ios-sdk/pull/1602))
8+
- CryptoV2: Integrate Mac-compatible MatrixSDKCrypto ([#1603](https://github.com/matrix-org/matrix-ios-sdk/pull/1603))
9+
- CryptoV2: Unencrypted verification events ([#1605](https://github.com/matrix-org/matrix-ios-sdk/pull/1605))
10+
- Crypto: Remove megolm decrypt cache build flag ([#1606](https://github.com/matrix-org/matrix-ios-sdk/pull/1606))
11+
- Device Manager: Exposed method to update client information. ([#1609](https://github.com/vector-im/element-ios/issues/1609))
12+
- CryptoV2: Manual device verification ([#6781](https://github.com/vector-im/element-ios/issues/6781))
13+
- Add support for m.local_notification_settings.<device-id> in account_data ([#6797](https://github.com/vector-im/element-ios/issues/6797))
14+
- CryptoV2: Incoming verification requests ([#6809](https://github.com/vector-im/element-ios/issues/6809))
15+
- CryptoV2: QR code verification ([#6859](https://github.com/vector-im/element-ios/issues/6859))
16+
17+
🐛 Bugfixes
18+
19+
- Fix users' display name in messages. ([#6850](https://github.com/vector-im/element-ios/issues/6850))
20+
21+
Others
22+
23+
- Expose rest client method for generating login tokens through MSC3882 ([#1601](https://github.com/matrix-org/matrix-ios-sdk/pull/1601))
24+
25+
126
## Changes in 0.24.0 (2022-10-04)
227

328
🙌 Improvements

MatrixSDK.podspec

+4-5
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.24.0"
4+
s.version = "0.24.1"
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.ios.dependency 'MatrixSDK/CryptoSDK'
48+
ss.dependency 'MatrixSDK/CryptoSDK'
4949
end
5050

5151
s.subspec 'JingleCallStack' do |ss|
@@ -64,10 +64,9 @@ Pod::Spec.new do |s|
6464
ss.ios.dependency 'JitsiMeetSDK', '5.0.2'
6565
end
6666

67-
# Experimental / NOT production-ready Rust-based crypto library, iOS-only
67+
# Experimental / NOT production-ready Rust-based crypto library
6868
s.subspec 'CryptoSDK' do |ss|
69-
ss.platform = :ios
70-
ss.dependency 'MatrixSDKCrypto', '0.1.0', :configurations => ["DEBUG"]
69+
ss.dependency 'MatrixSDKCrypto', '0.1.2', :configurations => ["DEBUG"]
7170
end
7271

7372
end

MatrixSDK.xcodeproj/project.pbxproj

+58-6
Large diffs are not rendered by default.

MatrixSDK/Aggregations/MXAggregations.m

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#import "MXAggregatedEditsUpdater.h"
2929
#import "MXAggregatedReferencesUpdater.h"
3030
#import "MXEventEditsListener.h"
31-
#import "MXAggregationPaginatedResponse_Private.h"
3231

3332
#import "MatrixSDKSwiftHeader.h"
3433

MatrixSDK/Contrib/Swift/Data/MXRoom.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ public extension MXRoom {
346346

347347
- parameters:
348348
- localURL: the local filesystem path of the file to send.
349+
- additionalContentParams: (optional) the additional parameters to the content.
349350
- mimeType: (optional) the mime type of the file. Defaults to `audio/ogg`.
350351
- duration: the length of the voice message in milliseconds
351352
- samples: an array of floating point values normalized to [0, 1]
@@ -368,9 +369,9 @@ public extension MXRoom {
368369
- returns: a `MXHTTPOperation` instance.
369370
*/
370371

371-
@nonobjc @discardableResult func sendVoiceMessage(localURL: URL, mimeType: String?, duration: UInt, samples: [Float]?, threadId: String? = nil, localEcho: inout MXEvent?, completion: @escaping (_ response: MXResponse<String?>) -> Void) -> MXHTTPOperation {
372+
@nonobjc @discardableResult func sendVoiceMessage(localURL: URL, additionalContentParams: [String : Any]?, mimeType: String?, duration: UInt, samples: [Float]?, threadId: String? = nil, localEcho: inout MXEvent?, completion: @escaping (_ response: MXResponse<String?>) -> Void) -> MXHTTPOperation {
372373
let boxedSamples = samples?.compactMap { NSNumber(value: $0) }
373-
return __sendVoiceMessage(localURL, mimeType: mimeType, duration: duration, samples: boxedSamples, threadId: threadId, localEcho: &localEcho, success: currySuccess(completion), failure: curryFailure(completion), keepActualFilename: false)
374+
return __sendVoiceMessage(localURL, additionalContentParams: additionalContentParams, mimeType: mimeType, duration: duration, samples: boxedSamples, threadId: threadId, localEcho: &localEcho, success: currySuccess(completion), failure: curryFailure(completion), keepActualFilename: false)
374375
}
375376

376377
/**

MatrixSDK/Contrib/Swift/MXRestClient.swift

+13-1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ public extension MXRestClient {
266266
return URL(string: fallbackString)!
267267
}
268268

269+
@nonobjc func generateLoginToken(withCompletion completion: @escaping (_ response: MXResponse<MXLoginToken>) -> Void) -> MXHTTPOperation {
270+
return __generateLoginToken(success: currySuccess(completion), failure: curryFailure(completion))
271+
}
269272

270273
/**
271274
Reset the account password.
@@ -1972,5 +1975,14 @@ public extension MXRestClient {
19721975
}
19731976
return __relations(forEvent: eventId, inRoom: roomId, relationType: relationType, eventType: eventType, from: from, direction: direction, limit: _limit, success: currySuccess(completion), failure: curryFailure(completion))
19741977
}
1975-
1978+
1979+
// MARK: - Versions
1980+
1981+
/// Get the supported versions of the homeserver
1982+
/// - Parameters:
1983+
/// - completion: A closure called when the operation completes.
1984+
/// - Returns: a `MXHTTPOperation` instance.
1985+
@nonobjc @discardableResult func supportedMatrixVersions(completion: @escaping (_ response: MXResponse<MXMatrixVersions>) -> Void) -> MXHTTPOperation {
1986+
return __supportedMatrixVersions(currySuccess(completion), failure: curryFailure(completion))
1987+
}
19761988
}

MatrixSDK/Contrib/Swift/MXSession.swift

+20-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import Foundation
1111

1212

1313
public extension MXSession {
14+
enum Error: Swift.Error {
15+
case missingRoom
16+
}
1417

1518
/// Module that manages threads
1619
var threadingService: MXThreadingService {
@@ -249,9 +252,23 @@ public extension MXSession {
249252
return __createRoom(parameters, success: currySuccess(completion), failure: curryFailure(completion))
250253
}
251254

252-
253-
254-
255+
/**
256+
Return the first joined direct chat listed in account data for this user,
257+
or it will create one if no room exists yet.
258+
*/
259+
func getOrCreateDirectJoinedRoom(with userId: String) async throws -> MXRoom {
260+
try await withCheckedThrowingContinuation { continuation in
261+
_ = getOrCreateDirectJoinedRoom(withUserId: userId) { room in
262+
if let room = room {
263+
continuation.resume(returning: room)
264+
} else {
265+
continuation.resume(throwing: Error.missingRoom)
266+
}
267+
} failure: { error in
268+
continuation.resume(throwing: error ?? Error.missingRoom)
269+
}
270+
}
271+
}
255272

256273
/**
257274
Join a room, optionally where the user has been invited by a 3PID invitation.

MatrixSDK/Crypto/Algorithms/Olm/MXOlmDecryption.m

+13
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ - (void)onRoomKeyInfo:(MXRoomKeyInfo *)keyInfo
228228
// No impact for olm
229229
}
230230

231+
- (void)onRoomKey:(MXRoomKeyResult *)key
232+
{
233+
// No impact for olm
234+
}
235+
231236
- (void)didImportRoomKey:(MXOlmInboundGroupSession *)session
232237
{
233238
// No impact for olm
@@ -261,6 +266,14 @@ - (NSString*)decryptMessage:(NSDictionary*)message andTheirDeviceIdentityKey:(NS
261266
NSArray<NSString *> *sessionIds = [olmDevice sessionIdsForDevice:theirDeviceIdentityKey];
262267

263268
NSString *messageBody = message[kMXMessageBodyKey];
269+
if (![message[@"type"] isKindOfClass:NSNumber.class])
270+
{
271+
MXLogFailureDetails(@"[MXOlmDecryption] decryptMessage: Invalid type of message", @{
272+
@"type": message[@"type"] ?: @"unknown"
273+
})
274+
return nil;
275+
}
276+
264277
NSUInteger messageType = [((NSNumber*)message[@"type"]) unsignedIntegerValue];
265278

266279
// Try each session in turn

MatrixSDK/Crypto/CrossSigning/Data/MXCrossSigningInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern NSString *const MXCrossSigningInfoTrustLevelDidChangeNotification;
3333
*/
3434
@interface MXCrossSigningInfo : NSObject <NSCoding>
3535

36-
#if DEBUG && TARGET_OS_IPHONE
36+
#if DEBUG
3737
/**
3838
Initialize cross signing with MatrixSDKCrypto user identity
3939
*/

MatrixSDK/Crypto/CrossSigning/Data/MXCrossSigningInfo.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
@implementation MXCrossSigningInfo
2525

26-
#if DEBUG && TARGET_OS_IPHONE
26+
#if DEBUG
2727
- (instancetype)initWithUserIdentity:(MXCryptoUserIdentityWrapper *)userIdentity
2828
{
2929
self = [self init];

MatrixSDK/Crypto/CrossSigning/Data/MXCryptoUserIdentityWrapper.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
#if DEBUG && os(iOS)
19+
#if DEBUG
2020

2121
import MatrixSDKCrypto
2222

MatrixSDK/Crypto/CrossSigning/MXCrossSigningInfoSource.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
#if DEBUG && os(iOS)
19+
#if DEBUG
2020

2121
/// Convenience struct which transforms `MatrixSDKCrypto` cross signing info formats
2222
/// into `MatrixSDK` `MXCrossSigningInfo` formats.

MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
#if DEBUG && os(iOS)
19+
#if DEBUG
2020

2121
/// A work-in-progress subclass of `MXCrossSigning` instantiated and used by `MXCryptoV2`.
2222
///

MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift

+74-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
#if DEBUG && os(iOS)
19+
#if DEBUG
2020

2121
import MatrixSDKCrypto
2222

@@ -49,6 +49,7 @@ class MXCryptoMachine {
4949
case missingVerificationRequest
5050
case missingVerification
5151
case missingEmojis
52+
case missingDecimals
5253
case cannotCancelVerification
5354
}
5455

@@ -313,6 +314,16 @@ extension MXCryptoMachine: MXCryptoUserIdentitySource {
313314
.keysQuery(requestId: UUID().uuidString, users: users)
314315
)
315316
}
317+
318+
func manuallyVerifyUser(userId: String) async throws {
319+
let request = try machine.verifyIdentity(userId: userId)
320+
try await requests.uploadSignatures(request: request)
321+
}
322+
323+
func manuallyVerifyDevice(userId: String, deviceId: String) async throws {
324+
let request = try machine.verifyDevice(userId: userId, deviceId: deviceId)
325+
try await requests.uploadSignatures(request: request)
326+
}
316327
}
317328

318329
extension MXCryptoMachine: MXCryptoRoomEventEncrypting {
@@ -355,7 +366,7 @@ extension MXCryptoMachine: MXCryptoRoomEventEncrypting {
355366
do {
356367
let decryptedEvent = try machine.decryptRoomEvent(event: eventString, roomId: roomId)
357368
let result = try MXEventDecryptionResult(event: decryptedEvent)
358-
log.debug("Successfully decrypted event")
369+
log.debug("Successfully decrypted event `\(result.clearEvent["type"] ?? "unknown")`")
359370
return result
360371

361372
// `Megolm` error does not currently expose the type of "missing keys" error, so have to match against
@@ -464,9 +475,25 @@ extension MXCryptoMachine: MXCryptoCrossSigning {
464475
requests.uploadSignatures(request: result.signatureRequest)
465476
]
466477
}
478+
479+
func exportCrossSigningKeys() -> CrossSigningKeyExport? {
480+
machine.exportCrossSigningKeys()
481+
}
467482
}
468483

469484
extension MXCryptoMachine: MXCryptoVerificationRequesting {
485+
func receiveUnencryptedVerificationEvent(event: MXEvent, roomId: String) {
486+
guard let string = event.jsonString() else {
487+
log.failure("Invalid event")
488+
return
489+
}
490+
do {
491+
try machine.receiveUnencryptedVerificationEvent(event: string, roomId: roomId)
492+
} catch {
493+
log.error("Error receiving unencrypted event", context: error)
494+
}
495+
}
496+
470497
func requestSelfVerification(methods: [String]) async throws -> VerificationRequest {
471498
guard let result = try machine.requestSelfVerification(methods: methods) else {
472499
throw Error.missingVerification
@@ -502,6 +529,10 @@ extension MXCryptoMachine: MXCryptoVerificationRequesting {
502529
return request
503530
}
504531

532+
func verificationRequests(userId: String) -> [VerificationRequest] {
533+
return machine.getVerificationRequests(userId: userId)
534+
}
535+
505536
func verificationRequest(userId: String, flowId: String) -> VerificationRequest? {
506537
return machine.getVerificationRequest(userId: userId, flowId: flowId)
507538
}
@@ -577,6 +608,14 @@ extension MXCryptoMachine: MXCryptoSASVerifying {
577608
return result.sas
578609
}
579610

611+
func startSasVerification(userId: String, deviceId: String) async throws -> Sas {
612+
guard let result = try machine.startSasWithDevice(userId: userId, deviceId: deviceId) else {
613+
throw Error.missingVerification
614+
}
615+
try await handleOutgoingVerificationRequest(result.request)
616+
return result.sas
617+
}
618+
580619
func acceptSasVerification(userId: String, flowId: String) async throws {
581620
guard let request = machine.acceptSasVerification(userId: userId, flowId: flowId) else {
582621
throw Error.missingVerification
@@ -590,6 +629,38 @@ extension MXCryptoMachine: MXCryptoSASVerifying {
590629
}
591630
return indexes.map(Int.init)
592631
}
632+
633+
func sasDecimals(sas: Sas) throws -> [Int] {
634+
guard let decimals = machine.getDecimals(userId: sas.otherUserId, flowId: sas.flowId) else {
635+
throw Error.missingDecimals
636+
}
637+
return decimals.map(Int.init)
638+
}
639+
}
640+
641+
extension MXCryptoMachine: MXCryptoQRCodeVerifying {
642+
func startQrVerification(userId: String, flowId: String) throws -> QrCode {
643+
guard let result = try machine.startQrVerification(userId: userId, flowId: flowId) else {
644+
throw Error.missingVerification
645+
}
646+
return result
647+
}
648+
649+
func scanQrCode(userId: String, flowId: String, data: Data) async throws -> QrCode {
650+
let string = MXBase64Tools.base64(from: data)
651+
guard let result = machine.scanQrCode(userId: userId, flowId: flowId, data: string) else {
652+
throw Error.missingVerification
653+
}
654+
try await handleOutgoingVerificationRequest(result.request)
655+
return result.qr
656+
}
657+
658+
func generateQrCode(userId: String, flowId: String) throws -> Data {
659+
guard let string = machine.generateQrCode(userId: userId, flowId: flowId) else {
660+
throw Error.missingVerification
661+
}
662+
return MXBase64Tools.data(fromBase64: string)
663+
}
593664
}
594665

595666
extension MXCryptoMachine: MXCryptoBackup {
@@ -667,7 +738,7 @@ extension MXCryptoMachine: MXCryptoBackup {
667738
guard let json = MXTools.serialiseJSONObject(jsonKeys) else {
668739
throw Error.cannotSerialize
669740
}
670-
return try machine.importDecryptedKeys(keys: json, progressListener: progressListener)
741+
return try machine.importDecryptedRoomKeys(keys: json, progressListener: progressListener)
671742
}
672743
}
673744

0 commit comments

Comments
 (0)