Skip to content

Commit

Permalink
Merge branch 'release/0.26.6/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Apr 4, 2023
2 parents 1f426ce + eae7ef7 commit 44cfbde
Show file tree
Hide file tree
Showing 31 changed files with 330 additions and 205 deletions.
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## Changes in 0.26.6 (2023-04-04)

🙌 Improvements

- Bugfix: Ensure related event nullability ([#1746](https://github.com/matrix-org/matrix-ios-sdk/pull/1746))
- Add constants for mention room power levels and check decrypted event content for @room mentions. ([#1750](https://github.com/matrix-org/matrix-ios-sdk/pull/1750))
- Crypto: Display correct SDK version ([#7457](https://github.com/vector-im/element-ios/issues/7457))

🐛 Bugfixes

- Fix invitations count in all chats list. ([#6871](https://github.com/vector-im/element-ios/issues/6871))

⚠️ API Changes

- Crypto: Add event decryption decoration instead of untrusted property ([#1743](https://github.com/matrix-org/matrix-ios-sdk/pull/1743))

🧱 Build

- Upgrade JitsiMeetSDK to 7.0.1-lite. ([#1754](https://github.com/matrix-org/matrix-ios-sdk/pull/1754))


## Changes in 0.26.5 (2023-03-28)

🙌 Improvements
Expand Down
7 changes: 4 additions & 3 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.26.5"
s.version = "0.26.6"
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.dependency 'MatrixSDKCrypto', '0.3.0', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true
ss.dependency 'MatrixSDKCrypto', '0.3.2', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true
end

s.subspec 'JingleCallStack' do |ss|
Expand All @@ -61,7 +61,8 @@ Pod::Spec.new do |s|
#ss.ios.dependency 'GoogleWebRTC', '~>1.1.21820'

# Use WebRTC framework included in Jitsi Meet SDK
ss.ios.dependency 'JitsiMeetSDK', '5.0.2'
# Use the lite version so we don't add a dependency on Giphy.
ss.ios.dependency 'JitsiMeetSDKLite', '7.0.1-lite'
end

end
42 changes: 24 additions & 18 deletions MatrixSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion MatrixSDK/Background/Crypto/MXLegacyBackgroundCrypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ class MXLegacyBackgroundCrypto: MXBackgroundCrypto {
decryptionResult.senderCurve25519Key = olmResult.senderKey
decryptionResult.claimedEd25519Key = olmResult.keysClaimed?["ed25519"] as? String
decryptionResult.forwardingCurve25519KeyChain = olmResult.forwardingCurve25519KeyChain
decryptionResult.isUntrusted = olmResult.isUntrusted
decryptionResult.decoration = MXEventDecryptionDecoration(
color: olmResult.isUntrusted ? .grey : .none,
message: nil
)
event.setClearData(decryptionResult)
} else if decryptorClass == MXOlmDecryption.self {
guard let ciphertextDict = event.content["ciphertext"] as? [AnyHashable: Any],
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/Algorithms/MXDecryptionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ FOUNDATION_EXPORT NSString* const MXDecryptingErrorMissingPropertyReason;
@property NSArray<NSString *> *forwardingCurve25519KeyChain;

/**
Flag indicating the decrpytion was made with an untrusted session.
Flag indicating the decryption was made with an untrusted session.
*/
@property (nonatomic, getter=isUntrusted) BOOL untrusted;

Expand Down
35 changes: 35 additions & 0 deletions MatrixSDK/Crypto/Algorithms/MXEventDecryptionDecoration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright 2023 The Matrix.org Foundation C.I.C
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

/// Recommended color to represent message's authenticity properties
@objc public enum MXEventDecryptionDecorationColor: Int {
case none
case grey
case red
}

/// Recommended visual decorations for decrypted messages, representing the message's authenticity properties
@objcMembers public class MXEventDecryptionDecoration: NSObject {
public let color: MXEventDecryptionDecorationColor
public let message: String?

public init(color: MXEventDecryptionDecorationColor, message: String?) {
self.color = color
self.message = message
}
}
10 changes: 6 additions & 4 deletions MatrixSDK/Crypto/Algorithms/MXEventDecryptionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import <Foundation/Foundation.h>

@class MXEventDecryptionDecoration;

/**
The result of a (successful) call to decryptEvent.
*/
Expand Down Expand Up @@ -46,13 +48,13 @@
@property NSArray<NSString *> *forwardingCurve25519KeyChain;

/**
If any, the error that occured during decryption.
Decoration representing the authenticity of the decrypted message
*/
@property (nonatomic) NSError *error;
@property (nonatomic, strong) MXEventDecryptionDecoration *decoration;

/**
Flag indicating the decryption was made with an untrusted session.
If any, the error that occured during decryption.
*/
@property (nonatomic, getter=isUntrusted) BOOL untrusted;
@property (nonatomic) NSError *error;

@end
19 changes: 18 additions & 1 deletion MatrixSDK/Crypto/Algorithms/Megolm/MXMegolmDecryption.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ - (MXEventDecryptionResult *)decryptEvent:(MXEvent*)event inTimeline:(NSString*)
result.senderCurve25519Key = olmResult.senderKey;
result.claimedEd25519Key = olmResult.keysClaimed[@"ed25519"];
result.forwardingCurve25519KeyChain = olmResult.forwardingCurve25519KeyChain;
result.untrusted = olmResult.isUntrusted;

MXEventDecryptionDecorationColor decryptionColor = [self decryptionColorForEvent:event decryptionResult:olmResult];
result.decoration = [[MXEventDecryptionDecoration alloc] initWithColor:decryptionColor message:nil];
}
else
{
Expand Down Expand Up @@ -160,6 +162,21 @@ - (MXEventDecryptionResult *)decryptEvent:(MXEvent*)event inTimeline:(NSString*)
return result;
}

- (MXEventDecryptionDecorationColor)decryptionColorForEvent:(MXEvent *)event
decryptionResult:(MXDecryptionResult *)decryptionResult
{
if (event.sender && [crypto trustLevelForUser:event.sender].isVerified)
{
MXDeviceInfo *deviceInfo = [crypto eventDeviceInfo:event];
if (!deviceInfo.trustLevel.isVerified)
{
return MXEventDecryptionDecorationColorRed;
}
}

return decryptionResult.isUntrusted ? MXEventDecryptionDecorationColorGrey : MXEventDecryptionDecorationColorNone;
}

/**
Add an event to the list of those we couldn't decrypt the first time we
saw them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ actor MXRoomEventDecryption: MXRoomEventDecrypting {
}

if !undecrypted.isEmpty {
log.error("Unable to decrypt some event(s)", context: [
"total": events.count,
"undecrypted": undecrypted.count
])
log.warning("Unable to decrypt \(undecrypted.count) out of \(events.count) event(s)")
} else if events.count > 1 {
log.debug("Decrypted all \(events.count) events")
}
Expand Down Expand Up @@ -113,9 +110,7 @@ actor MXRoomEventDecryption: MXRoomEventDecrypting {
log.debug("Ignoring non-room event `\(eventId)`")
}

let result = MXEventDecryptionResult()
result.clearEvent = event.clear?.jsonDictionary()
return result
return event.decryptionResult
}

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,28 @@ extension MXEventDecryptionResult {
senderCurve25519Key = event.senderCurve25519Key
claimedEd25519Key = event.claimedEd25519Key
forwardingCurve25519KeyChain = event.forwardingCurve25519Chain

// `Untrusted` state from rust is currently ignored as it lacks "undecided" option,
// will be changed in a future PR into:
// isUntrusted = event.verificationState == VerificationState.untrusted
isUntrusted = false
decoration = MXEventDecryptionDecoration(state: event.shieldState)
}
}

extension MXEventDecryptionDecoration {
convenience init(state: ShieldState) {
self.init(
color: MXEventDecryptionDecorationColor(color: state.color),
message: state.message
)
}
}

extension MXEventDecryptionDecorationColor {
init(color: ShieldColor) {
switch color {
case .none:
self = .none
case .grey:
self = .grey
case .red:
self = .red
}
}
}
5 changes: 4 additions & 1 deletion MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ extension MXCryptoMachine: MXCryptoRoomEventDecrypting {
roomId: roomId,
// Handling verification events automatically during event decryption is now a deprecated behavior,
// all verification events are handled manually via `receiveVerificationEvent`
handleVerificationEvents: false
handleVerificationEvents: false,
// The app does not use strict shields by default, in the future this will become configurable
// per room.
strictShields: false
)
}

Expand Down
5 changes: 1 addition & 4 deletions MatrixSDK/Crypto/MXCryptoV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ class MXCryptoV2: NSObject, MXCrypto {
// MARK: - Public properties

var version: String {
// Will be moved into the olm machine as API
let sdkVersion = Bundle(for: OlmMachine.self).infoDictionary?["CFBundleShortVersionString"] ?? ""
return "Matrix Crypto SDK \(sdkVersion)"

return "Rust Crypto SDK \(MatrixSDKCrypto.version()) (Vodozemac \(MatrixSDKCrypto.vodozemacVersion()))"
}

var deviceCurve25519Key: String? {
Expand Down
3 changes: 0 additions & 3 deletions MatrixSDK/Crypto/MXCryptoV2Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import Foundation
/// Feature representing the availability of the external rust-based Crypto SDK
/// whilst it is not fully available to everyone and / or is an optional feature.
@objc public protocol MXCryptoV2Feature {
/// Current version of the rust-based Crypto SDK
var version: String { get }

/// Is Crypto SDK currently enabled
///
/// By default this value is `false`. Once enabled, it can only be disabled by logging out,
Expand Down
12 changes: 6 additions & 6 deletions MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class MXKeyVerificationManagerV2: NSObject, MXKeyVerificationManager {
do {
let qr = try activeRequest.startQrVerification()
log.debug("Starting new QR verification")
return addQrTransaction(for: request, qrCode: qr, isIncoming: false)
return addQrTransaction(for: request, qr: .code(qr), isIncoming: false)
} catch {
log.error("Cannot start QR verification", context: error)
return nil
Expand All @@ -228,7 +228,7 @@ class MXKeyVerificationManagerV2: NSObject, MXKeyVerificationManager {
/// Placehoder QR transaction generated in case we cannot start a QR verification flow
/// (the other device cannot scan our code) but we may be able to scan theirs
log.debug("Adding placeholder QR verification")
return addQrTransaction(for: request, qrCode: nil, isIncoming: false)
return addQrTransaction(for: request, qr: .placeholder, isIncoming: false)
}

log.debug("No support for QR verification flow")
Expand Down Expand Up @@ -287,7 +287,7 @@ class MXKeyVerificationManagerV2: NSObject, MXKeyVerificationManager {
if event.type == kMXEventTypeStringRoomMessage && event.content?[kMXMessageTypeKey] as? String == kMXMessageTypeKeyVerificationRequest {
await handleIncomingRequest(userId: event.sender, flowId: event.eventId)
newUserId = event.sender
} else if event.type == kMXEventTypeStringKeyVerificationStart, let flowId = event.relatesTo.eventId {
} else if event.type == kMXEventTypeStringKeyVerificationStart, let flowId = event.relatesTo?.eventId {
await handleIncomingVerification(userId: event.sender, flowId: flowId)
newUserId = event.sender
} else {
Expand Down Expand Up @@ -438,7 +438,7 @@ class MXKeyVerificationManagerV2: NSObject, MXKeyVerificationManager {
log.debug("Updating existing QR verification transaction")
} else {
log.debug("Tracking new QR verification transaction")
_ = addQrTransaction(for: request, qrCode: qrCode, isIncoming: true)
_ = addQrTransaction(for: request, qr: .code(qrCode), isIncoming: true)
}
}
}
Expand All @@ -451,8 +451,8 @@ class MXKeyVerificationManagerV2: NSObject, MXKeyVerificationManager {
}

@MainActor
private func addQrTransaction(for request: VerificationRequestProtocol, qrCode: QrCodeProtocol?, isIncoming: Bool) -> MXQRCodeTransactionV2 {
let transaction = MXQRCodeTransactionV2(request: request, qrCode: qrCode, isIncoming: isIncoming, handler: handler)
private func addQrTransaction(for request: VerificationRequestProtocol, qr: MXQRCodeTransactionV2.QrKind, isIncoming: Bool) -> MXQRCodeTransactionV2 {
let transaction = MXQRCodeTransactionV2(request: request, qr: qr, isIncoming: isIncoming, handler: handler)
activeTransactions[transaction.transactionId] = transaction
return transaction
}
Expand Down
Loading

0 comments on commit 44cfbde

Please sign in to comment.