updated the SDK to 25.03.24

This commit is contained in:
Mauro Romito
2025-03-19 12:38:21 +01:00
committed by Mauro
parent 92a033c2c4
commit 0ee2199645
17 changed files with 99 additions and 68 deletions

View File

@@ -8565,7 +8565,7 @@
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 25.03.21;
version = 25.03.24;
};
};
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {

View File

@@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "93b8303fa004060c8ba6a856e0b66a1d47514490",
"version" : "25.3.21"
"revision" : "0da89f2a2ddaf2306144f42aed642af3f3228a1c",
"version" : "25.3.24"
}
},
{

View File

@@ -267,7 +267,12 @@ final class AppSettings {
// MARK: - Element Call
let elementCallBaseURL: URL = "https://call.element.io"
let elementCallBaseURL: URL = "https://call.element.io/room"
// These are publicly availble on https://call.element.io so we don't neeed to treat them as secrets
let elementCallPosthogAPIHost = "https://posthog-element-call.element.io"
let elementCallPosthogAPIKey = "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU"
let elementCallPosthogSentryDSN = "https://3bd2f95ba5554d4497da7153b552ffb5@sentry.tools.element.io/41"
@UserPreference(key: UserDefaultsKeys.elementCallBaseURLOverride, defaultValue: nil, storageType: .userDefaults(store))
var elementCallBaseURLOverride: URL?

View File

@@ -5989,15 +5989,15 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol, @unchecked S
//MARK: - start
var startBaseURLClientIDColorSchemeUnderlyingCallsCount = 0
var startBaseURLClientIDColorSchemeCallsCount: Int {
var startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingCallsCount = 0
var startBaseURLClientIDColorSchemeAnalyticsConfigurationCallsCount: Int {
get {
if Thread.isMainThread {
return startBaseURLClientIDColorSchemeUnderlyingCallsCount
return startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = startBaseURLClientIDColorSchemeUnderlyingCallsCount
returnValue = startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingCallsCount
}
return returnValue!
@@ -6005,29 +6005,29 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol, @unchecked S
}
set {
if Thread.isMainThread {
startBaseURLClientIDColorSchemeUnderlyingCallsCount = newValue
startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
startBaseURLClientIDColorSchemeUnderlyingCallsCount = newValue
startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingCallsCount = newValue
}
}
}
}
var startBaseURLClientIDColorSchemeCalled: Bool {
return startBaseURLClientIDColorSchemeCallsCount > 0
var startBaseURLClientIDColorSchemeAnalyticsConfigurationCalled: Bool {
return startBaseURLClientIDColorSchemeAnalyticsConfigurationCallsCount > 0
}
var startBaseURLClientIDColorSchemeReceivedArguments: (baseURL: URL, clientID: String, colorScheme: ColorScheme)?
var startBaseURLClientIDColorSchemeReceivedInvocations: [(baseURL: URL, clientID: String, colorScheme: ColorScheme)] = []
var startBaseURLClientIDColorSchemeAnalyticsConfigurationReceivedArguments: (baseURL: URL, clientID: String, colorScheme: ColorScheme, analyticsConfiguration: ElementCallAnalyticsConfiguration?)?
var startBaseURLClientIDColorSchemeAnalyticsConfigurationReceivedInvocations: [(baseURL: URL, clientID: String, colorScheme: ColorScheme, analyticsConfiguration: ElementCallAnalyticsConfiguration?)] = []
var startBaseURLClientIDColorSchemeUnderlyingReturnValue: Result<URL, ElementCallWidgetDriverError>!
var startBaseURLClientIDColorSchemeReturnValue: Result<URL, ElementCallWidgetDriverError>! {
var startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingReturnValue: Result<URL, ElementCallWidgetDriverError>!
var startBaseURLClientIDColorSchemeAnalyticsConfigurationReturnValue: Result<URL, ElementCallWidgetDriverError>! {
get {
if Thread.isMainThread {
return startBaseURLClientIDColorSchemeUnderlyingReturnValue
return startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingReturnValue
} else {
var returnValue: Result<URL, ElementCallWidgetDriverError>? = nil
DispatchQueue.main.sync {
returnValue = startBaseURLClientIDColorSchemeUnderlyingReturnValue
returnValue = startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingReturnValue
}
return returnValue!
@@ -6035,26 +6035,26 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol, @unchecked S
}
set {
if Thread.isMainThread {
startBaseURLClientIDColorSchemeUnderlyingReturnValue = newValue
startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
startBaseURLClientIDColorSchemeUnderlyingReturnValue = newValue
startBaseURLClientIDColorSchemeAnalyticsConfigurationUnderlyingReturnValue = newValue
}
}
}
}
var startBaseURLClientIDColorSchemeClosure: ((URL, String, ColorScheme) async -> Result<URL, ElementCallWidgetDriverError>)?
var startBaseURLClientIDColorSchemeAnalyticsConfigurationClosure: ((URL, String, ColorScheme, ElementCallAnalyticsConfiguration?) async -> Result<URL, ElementCallWidgetDriverError>)?
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme) async -> Result<URL, ElementCallWidgetDriverError> {
startBaseURLClientIDColorSchemeCallsCount += 1
startBaseURLClientIDColorSchemeReceivedArguments = (baseURL: baseURL, clientID: clientID, colorScheme: colorScheme)
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme, analyticsConfiguration: ElementCallAnalyticsConfiguration?) async -> Result<URL, ElementCallWidgetDriverError> {
startBaseURLClientIDColorSchemeAnalyticsConfigurationCallsCount += 1
startBaseURLClientIDColorSchemeAnalyticsConfigurationReceivedArguments = (baseURL: baseURL, clientID: clientID, colorScheme: colorScheme, analyticsConfiguration: analyticsConfiguration)
DispatchQueue.main.async {
self.startBaseURLClientIDColorSchemeReceivedInvocations.append((baseURL: baseURL, clientID: clientID, colorScheme: colorScheme))
self.startBaseURLClientIDColorSchemeAnalyticsConfigurationReceivedInvocations.append((baseURL: baseURL, clientID: clientID, colorScheme: colorScheme, analyticsConfiguration: analyticsConfiguration))
}
if let startBaseURLClientIDColorSchemeClosure = startBaseURLClientIDColorSchemeClosure {
return await startBaseURLClientIDColorSchemeClosure(baseURL, clientID, colorScheme)
if let startBaseURLClientIDColorSchemeAnalyticsConfigurationClosure = startBaseURLClientIDColorSchemeAnalyticsConfigurationClosure {
return await startBaseURLClientIDColorSchemeAnalyticsConfigurationClosure(baseURL, clientID, colorScheme, analyticsConfiguration)
} else {
return startBaseURLClientIDColorSchemeReturnValue
return startBaseURLClientIDColorSchemeAnalyticsConfigurationReturnValue
}
}
//MARK: - handleMessage

View File

@@ -2567,16 +2567,16 @@ open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable {
//MARK: - loginWithOidcCallback
open var loginWithOidcCallbackAuthorizationDataCallbackUrlThrowableError: Error?
var loginWithOidcCallbackAuthorizationDataCallbackUrlUnderlyingCallsCount = 0
open var loginWithOidcCallbackAuthorizationDataCallbackUrlCallsCount: Int {
open var loginWithOidcCallbackCallbackUrlThrowableError: Error?
var loginWithOidcCallbackCallbackUrlUnderlyingCallsCount = 0
open var loginWithOidcCallbackCallbackUrlCallsCount: Int {
get {
if Thread.isMainThread {
return loginWithOidcCallbackAuthorizationDataCallbackUrlUnderlyingCallsCount
return loginWithOidcCallbackCallbackUrlUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = loginWithOidcCallbackAuthorizationDataCallbackUrlUnderlyingCallsCount
returnValue = loginWithOidcCallbackCallbackUrlUnderlyingCallsCount
}
return returnValue!
@@ -2584,31 +2584,31 @@ open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable {
}
set {
if Thread.isMainThread {
loginWithOidcCallbackAuthorizationDataCallbackUrlUnderlyingCallsCount = newValue
loginWithOidcCallbackCallbackUrlUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
loginWithOidcCallbackAuthorizationDataCallbackUrlUnderlyingCallsCount = newValue
loginWithOidcCallbackCallbackUrlUnderlyingCallsCount = newValue
}
}
}
}
open var loginWithOidcCallbackAuthorizationDataCallbackUrlCalled: Bool {
return loginWithOidcCallbackAuthorizationDataCallbackUrlCallsCount > 0
open var loginWithOidcCallbackCallbackUrlCalled: Bool {
return loginWithOidcCallbackCallbackUrlCallsCount > 0
}
open var loginWithOidcCallbackAuthorizationDataCallbackUrlReceivedArguments: (authorizationData: OAuthAuthorizationData, callbackUrl: String)?
open var loginWithOidcCallbackAuthorizationDataCallbackUrlReceivedInvocations: [(authorizationData: OAuthAuthorizationData, callbackUrl: String)] = []
open var loginWithOidcCallbackAuthorizationDataCallbackUrlClosure: ((OAuthAuthorizationData, String) async throws -> Void)?
open var loginWithOidcCallbackCallbackUrlReceivedCallbackUrl: String?
open var loginWithOidcCallbackCallbackUrlReceivedInvocations: [String] = []
open var loginWithOidcCallbackCallbackUrlClosure: ((String) async throws -> Void)?
open override func loginWithOidcCallback(authorizationData: OAuthAuthorizationData, callbackUrl: String) async throws {
if let error = loginWithOidcCallbackAuthorizationDataCallbackUrlThrowableError {
open override func loginWithOidcCallback(callbackUrl: String) async throws {
if let error = loginWithOidcCallbackCallbackUrlThrowableError {
throw error
}
loginWithOidcCallbackAuthorizationDataCallbackUrlCallsCount += 1
loginWithOidcCallbackAuthorizationDataCallbackUrlReceivedArguments = (authorizationData: authorizationData, callbackUrl: callbackUrl)
loginWithOidcCallbackCallbackUrlCallsCount += 1
loginWithOidcCallbackCallbackUrlReceivedCallbackUrl = callbackUrl
DispatchQueue.main.async {
self.loginWithOidcCallbackAuthorizationDataCallbackUrlReceivedInvocations.append((authorizationData: authorizationData, callbackUrl: callbackUrl))
self.loginWithOidcCallbackCallbackUrlReceivedInvocations.append(callbackUrl)
}
try await loginWithOidcCallbackAuthorizationDataCallbackUrlClosure?(authorizationData, callbackUrl)
try await loginWithOidcCallbackCallbackUrlClosure?(callbackUrl)
}
//MARK: - logout

View File

@@ -119,7 +119,7 @@ extension JoinedRoomProxyMock {
fatalError()
}
widgetDriver.startBaseURLClientIDColorSchemeReturnValue = .success(url)
widgetDriver.startBaseURLClientIDColorSchemeAnalyticsConfigurationReturnValue = .success(url)
elementCallWidgetDriverDeviceIDReturnValue = widgetDriver
sendCallNotificationIfNeededReturnValue = .success(())

View File

@@ -47,7 +47,7 @@ class OIDCAuthenticationPresenter: NSObject {
return .failure(.oidcError(.unknown))
}
switch await authenticationService.loginWithOIDCCallback(url, data: oidcData) {
switch await authenticationService.loginWithOIDCCallback(url) {
case .success(let userSession):
return .success(userSession)
case .failure(let error):

View File

@@ -43,7 +43,9 @@ final class CallScreenCoordinator: CoordinatorProtocol {
viewModel = CallScreenViewModel(elementCallService: parameters.elementCallService,
configuration: parameters.configuration,
allowPictureInPicture: parameters.allowPictureInPicture,
appHooks: parameters.appHooks)
appHooks: parameters.appHooks,
appSettings: ServiceLocator.shared.settings,
analyticsService: ServiceLocator.shared.analytics)
}
func start() {

View File

@@ -16,6 +16,8 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
private let elementCallService: ElementCallServiceProtocol
private let configuration: ElementCallConfiguration
private let isPictureInPictureAllowed: Bool
private let appSettings: AppSettings
private let analyticsService: AnalyticsService
private let widgetDriver: ElementCallWidgetDriverProtocol
@@ -33,9 +35,13 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
init(elementCallService: ElementCallServiceProtocol,
configuration: ElementCallConfiguration,
allowPictureInPicture: Bool,
appHooks: AppHooks) {
appHooks: AppHooks,
appSettings: AppSettings,
analyticsService: AnalyticsService) {
self.elementCallService = elementCallService
self.configuration = configuration
self.appSettings = appSettings
self.analyticsService = analyticsService
isPictureInPictureAllowed = allowPictureInPicture
switch configuration.kind {
@@ -148,7 +154,15 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
elementCallBaseURL
}
switch await widgetDriver.start(baseURL: baseURL, clientID: clientID, colorScheme: colorScheme) {
// We only set the analytics configuration if analytics are enabled
let analyticsConfiguration = analyticsService.isEnabled ? ElementCallAnalyticsConfiguration(posthogAPIHost: appSettings.elementCallPosthogAPIHost,
posthogAPIKey: appSettings.elementCallPosthogAPIKey,
rageshakeSubmitURL: Secrets.rageshakeServerURL,
sentryDSN: appSettings.elementCallPosthogSentryDSN) : nil
switch await widgetDriver.start(baseURL: baseURL,
clientID: clientID,
colorScheme: colorScheme,
analyticsConfiguration: analyticsConfiguration) {
case .success(let url):
state.url = url
case .failure(let error):

View File

@@ -286,7 +286,7 @@ struct CallScreen_Previews: PreviewProvider {
let widgetDriver = ElementCallWidgetDriverMock()
widgetDriver.underlyingMessagePublisher = .init()
widgetDriver.underlyingActions = PassthroughSubject<ElementCallWidgetDriverAction, Never>().eraseToAnyPublisher()
widgetDriver.startBaseURLClientIDColorSchemeReturnValue = .success(URL.userDirectory)
widgetDriver.startBaseURLClientIDColorSchemeAnalyticsConfigurationReturnValue = .success(URL.userDirectory)
roomProxy.elementCallWidgetDriverDeviceIDReturnValue = widgetDriver
@@ -299,7 +299,9 @@ struct CallScreen_Previews: PreviewProvider {
colorScheme: .light,
notifyOtherParticipants: false),
allowPictureInPicture: false,
appHooks: AppHooks())
appHooks: AppHooks(),
appSettings: ServiceLocator.shared.settings,
analyticsService: ServiceLocator.shared.analytics)
}()
static var previews: some View {

View File

@@ -106,10 +106,10 @@ class AuthenticationService: AuthenticationServiceProtocol {
await client.abortOidcAuth(authorizationData: data.underlyingData)
}
func loginWithOIDCCallback(_ callbackURL: URL, data: OIDCAuthorizationDataProxy) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
func loginWithOIDCCallback(_ callbackURL: URL) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
guard let client else { return .failure(.failedLoggingIn) }
do {
try await client.loginWithOidcCallback(authorizationData: data.underlyingData, callbackUrl: callbackURL.absoluteString)
try await client.loginWithOidcCallback(callbackUrl: callbackURL.absoluteString)
return await userSession(for: client)
} catch OidcError.Cancelled {
return .failure(.oidcError(.userCancellation))

View File

@@ -45,7 +45,7 @@ protocol AuthenticationServiceProtocol {
/// Asks the SDK to abort an ongoing OIDC login if we didn't get a callback to complete the request with.
func abortOIDCLogin(data: OIDCAuthorizationDataProxy) async
/// Completes an OIDC login that was started using ``urlForOIDCLogin``.
func loginWithOIDCCallback(_ callbackURL: URL, data: OIDCAuthorizationDataProxy) async -> Result<UserSessionProtocol, AuthenticationServiceError>
func loginWithOIDCCallback(_ callbackURL: URL) async -> Result<UserSessionProtocol, AuthenticationServiceError>
/// Performs a password login using the current homeserver.
func login(username: String, password: String, initialDeviceName: String?, deviceID: String?) async -> Result<UserSessionProtocol, AuthenticationServiceError>
/// Completes registration using the credentials obtained via the helper URL.

View File

@@ -50,6 +50,7 @@ struct ElementCallWidgetMessage: Codable {
class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriverProtocol {
private let room: RoomProtocol
private let deviceID: String
private var widgetDriver: WidgetDriverAndHandle?
let widgetID = UUID().uuidString
@@ -65,14 +66,14 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
self.deviceID = deviceID
}
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme) async -> Result<URL, ElementCallWidgetDriverError> {
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme, analyticsConfiguration: ElementCallAnalyticsConfiguration?) async -> Result<URL, ElementCallWidgetDriverError> {
guard let room = room as? Room else {
return .failure(.roomInvalid)
}
let useEncryption = await (try? room.latestEncryptionState() == .encrypted) ?? false
let widgetSettings: WidgetSettings
do {
widgetSettings = try newVirtualElementCallWidget(props: .init(elementCallUrl: baseURL.absoluteString,
widgetId: widgetID,
@@ -84,13 +85,13 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
confineToRoom: true,
font: nil,
encryption: useEncryption ? .perParticipantKeys : .unencrypted,
intent: .startCall,
hideScreensharing: false, // The web view will hide it automatically
intent: nil,
hideScreensharing: false,
posthogUserId: nil,
posthogApiHost: nil,
posthogApiKey: nil,
rageshakeSubmitUrl: nil,
sentryDsn: nil,
posthogApiHost: analyticsConfiguration?.posthogAPIHost,
posthogApiKey: analyticsConfiguration?.posthogAPIKey,
rageshakeSubmitUrl: analyticsConfiguration?.rageshakeSubmitURL,
sentryDsn: analyticsConfiguration?.sentryDSN,
sentryEnvironment: nil))
} catch {
MXLog.error("Failed to build widget settings: \(error)")

View File

@@ -29,8 +29,15 @@ protocol ElementCallWidgetDriverProtocol {
var messagePublisher: PassthroughSubject<String, Never> { get }
var actions: AnyPublisher<ElementCallWidgetDriverAction, Never> { get }
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme) async -> Result<URL, ElementCallWidgetDriverError>
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme, analyticsConfiguration: ElementCallAnalyticsConfiguration?) async -> Result<URL, ElementCallWidgetDriverError>
/// Passes a message from the Widget to the SDK to handle, returning a Bool that represents whether or not the widget driver is still running.
func handleMessage(_ message: String) async -> Result<Bool, ElementCallWidgetDriverError>
}
struct ElementCallAnalyticsConfiguration {
let posthogAPIHost: String
let posthogAPIKey: String
let rageshakeSubmitURL: String
let sentryDSN: String
}

View File

@@ -23,7 +23,7 @@ class GenericCallLinkWidgetDriver: ElementCallWidgetDriverProtocol {
self.url = url
}
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme) async -> Result<URL, ElementCallWidgetDriverError> {
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme, analyticsConfiguration: ElementCallAnalyticsConfiguration?) async -> Result<URL, ElementCallWidgetDriverError> {
MXLog.error("Nothing to start, use the configuration's URL directly instead.")
return .success(url)
}

View File

@@ -68,7 +68,7 @@ struct BuildSDK: ParsableCommand {
/// but only when the ``target`` option hasn't been supplied.
func checkRustupTargets() throws {
guard target.isEmpty, device == 0, simulator == 0 else { return }
guard let output = try Zsh.run(command: "rustup show") else { throw Error.rustupOutputFailure }
guard let output = try Zsh.run(command: "rustup target list --toolchain stable --installed") else { throw Error.rustupOutputFailure }
var requiredTargets = Target.allCases.reduce(into: [String: Bool]()) { partialResult, target in
partialResult[target.rawValue] = false

View File

@@ -59,7 +59,7 @@ packages:
# Element/Matrix dependencies
MatrixRustSDK:
url: https://github.com/element-hq/matrix-rust-components-swift
exactVersion: 25.03.21
exactVersion: 25.03.24
# path: ../matrix-rust-sdk
Compound:
url: https://github.com/element-hq/compound-ios