Skip to content

Commit

Permalink
Merge branch 'release/0.24.1/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gulekismail committed Oct 18, 2022
2 parents cc89463 + 92e9fca commit f4e268f
Show file tree
Hide file tree
Showing 110 changed files with 2,381 additions and 522 deletions.
25 changes: 25 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## Changes in 0.24.1 (2022-10-18)

🙌 Improvements

- Support additional content in voice message. ([#1595](https://github.com/matrix-org/matrix-ios-sdk/pull/1595))
- Key verification: Refactor verification manager, requests, transactions ([#1599](https://github.com/matrix-org/matrix-ios-sdk/pull/1599))
- Crypto: Refactor QR transactions ([#1602](https://github.com/matrix-org/matrix-ios-sdk/pull/1602))
- CryptoV2: Integrate Mac-compatible MatrixSDKCrypto ([#1603](https://github.com/matrix-org/matrix-ios-sdk/pull/1603))
- CryptoV2: Unencrypted verification events ([#1605](https://github.com/matrix-org/matrix-ios-sdk/pull/1605))
- Crypto: Remove megolm decrypt cache build flag ([#1606](https://github.com/matrix-org/matrix-ios-sdk/pull/1606))
- Device Manager: Exposed method to update client information. ([#1609](https://github.com/vector-im/element-ios/issues/1609))
- CryptoV2: Manual device verification ([#6781](https://github.com/vector-im/element-ios/issues/6781))
- Add support for m.local_notification_settings.<device-id> in account_data ([#6797](https://github.com/vector-im/element-ios/issues/6797))
- CryptoV2: Incoming verification requests ([#6809](https://github.com/vector-im/element-ios/issues/6809))
- CryptoV2: QR code verification ([#6859](https://github.com/vector-im/element-ios/issues/6859))

🐛 Bugfixes

- Fix users' display name in messages. ([#6850](https://github.com/vector-im/element-ios/issues/6850))

Others

- Expose rest client method for generating login tokens through MSC3882 ([#1601](https://github.com/matrix-org/matrix-ios-sdk/pull/1601))


## Changes in 0.24.0 (2022-10-04)

🙌 Improvements
Expand Down
9 changes: 4 additions & 5 deletions MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.24.0"
s.version = "0.24.1"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down Expand Up @@ -45,7 +45,7 @@ Pod::Spec.new do |s|
ss.dependency 'OLMKit', '~> 3.2.5'
ss.dependency 'Realm', '10.27.0'
ss.dependency 'libbase58', '~> 0.1.4'
ss.ios.dependency 'MatrixSDK/CryptoSDK'
ss.dependency 'MatrixSDK/CryptoSDK'
end

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

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

end
64 changes: 58 additions & 6 deletions MatrixSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion MatrixSDK/Aggregations/MXAggregations.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#import "MXAggregatedEditsUpdater.h"
#import "MXAggregatedReferencesUpdater.h"
#import "MXEventEditsListener.h"
#import "MXAggregationPaginatedResponse_Private.h"

#import "MatrixSDKSwiftHeader.h"

Expand Down
5 changes: 3 additions & 2 deletions MatrixSDK/Contrib/Swift/Data/MXRoom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ public extension MXRoom {
- parameters:
- localURL: the local filesystem path of the file to send.
- additionalContentParams: (optional) the additional parameters to the content.
- mimeType: (optional) the mime type of the file. Defaults to `audio/ogg`.
- duration: the length of the voice message in milliseconds
- samples: an array of floating point values normalized to [0, 1]
Expand All @@ -368,9 +369,9 @@ public extension MXRoom {
- returns: a `MXHTTPOperation` instance.
*/

@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 {
@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 {
let boxedSamples = samples?.compactMap { NSNumber(value: $0) }
return __sendVoiceMessage(localURL, mimeType: mimeType, duration: duration, samples: boxedSamples, threadId: threadId, localEcho: &localEcho, success: currySuccess(completion), failure: curryFailure(completion), keepActualFilename: false)
return __sendVoiceMessage(localURL, additionalContentParams: additionalContentParams, mimeType: mimeType, duration: duration, samples: boxedSamples, threadId: threadId, localEcho: &localEcho, success: currySuccess(completion), failure: curryFailure(completion), keepActualFilename: false)
}

/**
Expand Down
14 changes: 13 additions & 1 deletion MatrixSDK/Contrib/Swift/MXRestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ public extension MXRestClient {
return URL(string: fallbackString)!
}

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

/**
Reset the account password.
Expand Down Expand Up @@ -1972,5 +1975,14 @@ public extension MXRestClient {
}
return __relations(forEvent: eventId, inRoom: roomId, relationType: relationType, eventType: eventType, from: from, direction: direction, limit: _limit, success: currySuccess(completion), failure: curryFailure(completion))
}


// MARK: - Versions

/// Get the supported versions of the homeserver
/// - Parameters:
/// - completion: A closure called when the operation completes.
/// - Returns: a `MXHTTPOperation` instance.
@nonobjc @discardableResult func supportedMatrixVersions(completion: @escaping (_ response: MXResponse<MXMatrixVersions>) -> Void) -> MXHTTPOperation {
return __supportedMatrixVersions(currySuccess(completion), failure: curryFailure(completion))
}
}
23 changes: 20 additions & 3 deletions MatrixSDK/Contrib/Swift/MXSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import Foundation


public extension MXSession {
enum Error: Swift.Error {
case missingRoom
}

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




/**
Return the first joined direct chat listed in account data for this user,
or it will create one if no room exists yet.
*/
func getOrCreateDirectJoinedRoom(with userId: String) async throws -> MXRoom {
try await withCheckedThrowingContinuation { continuation in
_ = getOrCreateDirectJoinedRoom(withUserId: userId) { room in
if let room = room {
continuation.resume(returning: room)
} else {
continuation.resume(throwing: Error.missingRoom)
}
} failure: { error in
continuation.resume(throwing: error ?? Error.missingRoom)
}
}
}

/**
Join a room, optionally where the user has been invited by a 3PID invitation.
Expand Down
13 changes: 13 additions & 0 deletions MatrixSDK/Crypto/Algorithms/Olm/MXOlmDecryption.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ - (void)onRoomKeyInfo:(MXRoomKeyInfo *)keyInfo
// No impact for olm
}

- (void)onRoomKey:(MXRoomKeyResult *)key
{
// No impact for olm
}

- (void)didImportRoomKey:(MXOlmInboundGroupSession *)session
{
// No impact for olm
Expand Down Expand Up @@ -261,6 +266,14 @@ - (NSString*)decryptMessage:(NSDictionary*)message andTheirDeviceIdentityKey:(NS
NSArray<NSString *> *sessionIds = [olmDevice sessionIdsForDevice:theirDeviceIdentityKey];

NSString *messageBody = message[kMXMessageBodyKey];
if (![message[@"type"] isKindOfClass:NSNumber.class])
{
MXLogFailureDetails(@"[MXOlmDecryption] decryptMessage: Invalid type of message", @{
@"type": message[@"type"] ?: @"unknown"
})
return nil;
}

NSUInteger messageType = [((NSNumber*)message[@"type"]) unsignedIntegerValue];

// Try each session in turn
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/CrossSigning/Data/MXCrossSigningInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern NSString *const MXCrossSigningInfoTrustLevelDidChangeNotification;
*/
@interface MXCrossSigningInfo : NSObject <NSCoding>

#if DEBUG && TARGET_OS_IPHONE
#if DEBUG
/**
Initialize cross signing with MatrixSDKCrypto user identity
*/
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/CrossSigning/Data/MXCrossSigningInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@implementation MXCrossSigningInfo

#if DEBUG && TARGET_OS_IPHONE
#if DEBUG
- (instancetype)initWithUserIdentity:(MXCryptoUserIdentityWrapper *)userIdentity
{
self = [self init];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Foundation

#if DEBUG && os(iOS)
#if DEBUG

import MatrixSDKCrypto

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Foundation

#if DEBUG && os(iOS)
#if DEBUG

/// Convenience struct which transforms `MatrixSDKCrypto` cross signing info formats
/// into `MatrixSDK` `MXCrossSigningInfo` formats.
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Foundation

#if DEBUG && os(iOS)
#if DEBUG

/// A work-in-progress subclass of `MXCrossSigning` instantiated and used by `MXCryptoV2`.
///
Expand Down
77 changes: 74 additions & 3 deletions MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Foundation

#if DEBUG && os(iOS)
#if DEBUG

import MatrixSDKCrypto

Expand Down Expand Up @@ -49,6 +49,7 @@ class MXCryptoMachine {
case missingVerificationRequest
case missingVerification
case missingEmojis
case missingDecimals
case cannotCancelVerification
}

Expand Down Expand Up @@ -313,6 +314,16 @@ extension MXCryptoMachine: MXCryptoUserIdentitySource {
.keysQuery(requestId: UUID().uuidString, users: users)
)
}

func manuallyVerifyUser(userId: String) async throws {
let request = try machine.verifyIdentity(userId: userId)
try await requests.uploadSignatures(request: request)
}

func manuallyVerifyDevice(userId: String, deviceId: String) async throws {
let request = try machine.verifyDevice(userId: userId, deviceId: deviceId)
try await requests.uploadSignatures(request: request)
}
}

extension MXCryptoMachine: MXCryptoRoomEventEncrypting {
Expand Down Expand Up @@ -355,7 +366,7 @@ extension MXCryptoMachine: MXCryptoRoomEventEncrypting {
do {
let decryptedEvent = try machine.decryptRoomEvent(event: eventString, roomId: roomId)
let result = try MXEventDecryptionResult(event: decryptedEvent)
log.debug("Successfully decrypted event")
log.debug("Successfully decrypted event `\(result.clearEvent["type"] ?? "unknown")`")
return result

// `Megolm` error does not currently expose the type of "missing keys" error, so have to match against
Expand Down Expand Up @@ -464,9 +475,25 @@ extension MXCryptoMachine: MXCryptoCrossSigning {
requests.uploadSignatures(request: result.signatureRequest)
]
}

func exportCrossSigningKeys() -> CrossSigningKeyExport? {
machine.exportCrossSigningKeys()
}
}

extension MXCryptoMachine: MXCryptoVerificationRequesting {
func receiveUnencryptedVerificationEvent(event: MXEvent, roomId: String) {
guard let string = event.jsonString() else {
log.failure("Invalid event")
return
}
do {
try machine.receiveUnencryptedVerificationEvent(event: string, roomId: roomId)
} catch {
log.error("Error receiving unencrypted event", context: error)
}
}

func requestSelfVerification(methods: [String]) async throws -> VerificationRequest {
guard let result = try machine.requestSelfVerification(methods: methods) else {
throw Error.missingVerification
Expand Down Expand Up @@ -502,6 +529,10 @@ extension MXCryptoMachine: MXCryptoVerificationRequesting {
return request
}

func verificationRequests(userId: String) -> [VerificationRequest] {
return machine.getVerificationRequests(userId: userId)
}

func verificationRequest(userId: String, flowId: String) -> VerificationRequest? {
return machine.getVerificationRequest(userId: userId, flowId: flowId)
}
Expand Down Expand Up @@ -577,6 +608,14 @@ extension MXCryptoMachine: MXCryptoSASVerifying {
return result.sas
}

func startSasVerification(userId: String, deviceId: String) async throws -> Sas {
guard let result = try machine.startSasWithDevice(userId: userId, deviceId: deviceId) else {
throw Error.missingVerification
}
try await handleOutgoingVerificationRequest(result.request)
return result.sas
}

func acceptSasVerification(userId: String, flowId: String) async throws {
guard let request = machine.acceptSasVerification(userId: userId, flowId: flowId) else {
throw Error.missingVerification
Expand All @@ -590,6 +629,38 @@ extension MXCryptoMachine: MXCryptoSASVerifying {
}
return indexes.map(Int.init)
}

func sasDecimals(sas: Sas) throws -> [Int] {
guard let decimals = machine.getDecimals(userId: sas.otherUserId, flowId: sas.flowId) else {
throw Error.missingDecimals
}
return decimals.map(Int.init)
}
}

extension MXCryptoMachine: MXCryptoQRCodeVerifying {
func startQrVerification(userId: String, flowId: String) throws -> QrCode {
guard let result = try machine.startQrVerification(userId: userId, flowId: flowId) else {
throw Error.missingVerification
}
return result
}

func scanQrCode(userId: String, flowId: String, data: Data) async throws -> QrCode {
let string = MXBase64Tools.base64(from: data)
guard let result = machine.scanQrCode(userId: userId, flowId: flowId, data: string) else {
throw Error.missingVerification
}
try await handleOutgoingVerificationRequest(result.request)
return result.qr
}

func generateQrCode(userId: String, flowId: String) throws -> Data {
guard let string = machine.generateQrCode(userId: userId, flowId: flowId) else {
throw Error.missingVerification
}
return MXBase64Tools.data(fromBase64: string)
}
}

extension MXCryptoMachine: MXCryptoBackup {
Expand Down Expand Up @@ -667,7 +738,7 @@ extension MXCryptoMachine: MXCryptoBackup {
guard let json = MXTools.serialiseJSONObject(jsonKeys) else {
throw Error.cannotSerialize
}
return try machine.importDecryptedKeys(keys: json, progressListener: progressListener)
return try machine.importDecryptedRoomKeys(keys: json, progressListener: progressListener)
}
}

Expand Down
Loading

0 comments on commit f4e268f

Please sign in to comment.