Update dependency org.matrix.rustcomponents:sdk-android to v26.04.27 (#6666)
* Update dependency org.matrix.rustcomponents:sdk-android to v26.04.27 * Fix breaking API changes: - OIDC components are now prefixed `OAuth`. - `Room.startLiveLocationShare` now returns the event id of the beacon state event if it succeeds. - `RoomInfo` now contains an `activeServiceMembersCount` property. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín <jorgem@element.io>
This commit is contained in:
parent
90ed385745
commit
997227b020
21 changed files with 50 additions and 42 deletions
|
|
@ -178,7 +178,7 @@ test_detekt_test = { module = "io.gitlab.arturbosch.detekt:detekt-test", version
|
|||
# https://github.com/matrix-org/matrix-rust-components-kotlin/commits/main/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt
|
||||
# All new features should not be implemented in the pull request that upgrades the version, developers should
|
||||
# only fix API breaks and may add some TODOs.
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:26.04.21"
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:26.04.27"
|
||||
|
||||
# Others
|
||||
coil = { module = "io.coil-kt.coil3:coil", version.ref = "coil" }
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ interface JoinedRoom : BaseRoom {
|
|||
/**
|
||||
* Start sharing live location in this room.
|
||||
* @param durationMillis How long to share location (in milliseconds).
|
||||
* @return Result indicating success or failure.
|
||||
* @return Result containing the [EventId] of the beacon state event on success or an error on failure.
|
||||
*/
|
||||
suspend fun startLiveLocationShare(durationMillis: Long): Result<Unit>
|
||||
suspend fun startLiveLocationShare(durationMillis: Long): Result<EventId>
|
||||
|
||||
/**
|
||||
* Stop sharing live location in this room.
|
||||
|
|
|
|||
|
|
@ -214,5 +214,5 @@ fun SessionData.toSession() = Session(
|
|||
deviceId = deviceId,
|
||||
homeserverUrl = homeserverUrl,
|
||||
slidingSyncVersion = SlidingSyncVersion.NATIVE,
|
||||
oidcData = oidcData,
|
||||
oauthData = oidcData,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ package io.element.android.libraries.matrix.impl.auth
|
|||
|
||||
import io.element.android.libraries.matrix.api.auth.AuthenticationException
|
||||
import org.matrix.rustcomponents.sdk.ClientBuildException
|
||||
import org.matrix.rustcomponents.sdk.OidcException
|
||||
import org.matrix.rustcomponents.sdk.OAuthException
|
||||
|
||||
fun Throwable.mapAuthenticationException(): AuthenticationException {
|
||||
return when (this) {
|
||||
|
|
@ -29,12 +29,12 @@ fun Throwable.mapAuthenticationException(): AuthenticationException {
|
|||
is ClientBuildException.WellKnownLookupFailed -> AuthenticationException.Generic(message)
|
||||
is ClientBuildException.EventCache -> AuthenticationException.Generic(message)
|
||||
}
|
||||
is OidcException -> when (this) {
|
||||
is OidcException.Generic -> AuthenticationException.Oidc(message)
|
||||
is OidcException.CallbackUrlInvalid -> AuthenticationException.Oidc(message)
|
||||
is OidcException.Cancelled -> AuthenticationException.Oidc(message)
|
||||
is OidcException.MetadataInvalid -> AuthenticationException.Oidc(message)
|
||||
is OidcException.NotSupported -> AuthenticationException.Oidc(message)
|
||||
is OAuthException -> when (this) {
|
||||
is OAuthException.Generic -> AuthenticationException.Oidc(message)
|
||||
is OAuthException.CallbackUrlInvalid -> AuthenticationException.Oidc(message)
|
||||
is OAuthException.Cancelled -> AuthenticationException.Oidc(message)
|
||||
is OAuthException.MetadataInvalid -> AuthenticationException.Oidc(message)
|
||||
is OAuthException.NotSupported -> AuthenticationException.Oidc(message)
|
||||
}
|
||||
else -> AuthenticationException.Generic(message)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ fun HomeserverLoginDetails.map(): MatrixHomeServerDetails = use {
|
|||
MatrixHomeServerDetails(
|
||||
url = url(),
|
||||
supportsPasswordLogin = supportsPasswordLogin(),
|
||||
supportsOidcLogin = supportsOidcLogin(),
|
||||
supportsOidcLogin = supportsOauthLogin(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ import dev.zacsweers.metro.Inject
|
|||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import io.element.android.libraries.matrix.api.auth.OidcConfig
|
||||
import io.element.android.libraries.matrix.api.auth.OidcRedirectUrlProvider
|
||||
import org.matrix.rustcomponents.sdk.OidcConfiguration
|
||||
import org.matrix.rustcomponents.sdk.OAuthConfiguration
|
||||
|
||||
@Inject
|
||||
class OidcConfigurationProvider(
|
||||
private val buildMeta: BuildMeta,
|
||||
private val oidcRedirectUrlProvider: OidcRedirectUrlProvider,
|
||||
) {
|
||||
fun get(): OidcConfiguration = OidcConfiguration(
|
||||
fun get(): OAuthConfiguration = OAuthConfiguration(
|
||||
clientName = buildMeta.applicationName,
|
||||
redirectUri = oidcRedirectUrlProvider.provide(),
|
||||
clientUri = OidcConfig.CLIENT_URI,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
package io.element.android.libraries.matrix.impl.auth
|
||||
|
||||
import io.element.android.libraries.matrix.api.auth.OidcPrompt
|
||||
import org.matrix.rustcomponents.sdk.OidcPrompt as RustOidcPrompt
|
||||
import org.matrix.rustcomponents.sdk.OAuthPrompt as RustOidcPrompt
|
||||
|
||||
internal fun OidcPrompt.toRustPrompt(): RustOidcPrompt {
|
||||
return when (this) {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class RustHomeServerLoginCompatibilityChecker(
|
|||
it.homeserverLoginDetails()
|
||||
}
|
||||
.use {
|
||||
Timber.d("Homeserver $url | OIDC: ${it.supportsOidcLogin()} | Password: ${it.supportsPasswordLogin()} | SSO: ${it.supportsSsoLogin()}")
|
||||
it.supportsOidcLogin() || it.supportsPasswordLogin()
|
||||
Timber.d("Homeserver $url | OIDC: ${it.supportsOauthLogin()} | Password: ${it.supportsPasswordLogin()} | SSO: ${it.supportsSsoLogin()}")
|
||||
it.supportsOauthLogin() || it.supportsPasswordLogin()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,8 +260,8 @@ class RustMatrixAuthenticationService(
|
|||
return withContext(coroutineDispatchers.io) {
|
||||
runCatchingExceptions {
|
||||
val client = currentClient ?: error("You need to call `setHomeserver()` first")
|
||||
val oAuthAuthorizationData = client.urlForOidc(
|
||||
oidcConfiguration = oidcConfigurationProvider.get(),
|
||||
val oAuthAuthorizationData = client.urlForOauth(
|
||||
oauthConfiguration = oidcConfigurationProvider.get(),
|
||||
prompt = prompt.toRustPrompt(),
|
||||
loginHint = loginHint,
|
||||
// If we want to restore a previous session for which we have encryption keys, we can pass the deviceId here. At the moment, we don't
|
||||
|
|
@ -282,7 +282,7 @@ class RustMatrixAuthenticationService(
|
|||
return withContext(coroutineDispatchers.io) {
|
||||
runCatchingExceptions {
|
||||
pendingOAuthAuthorizationData?.use {
|
||||
currentClient?.abortOidcAuth(it)
|
||||
currentClient?.abortOauthAuth(it)
|
||||
}
|
||||
pendingOAuthAuthorizationData = null
|
||||
}.mapFailure { failure ->
|
||||
|
|
@ -304,7 +304,7 @@ class RustMatrixAuthenticationService(
|
|||
runCatchingExceptions {
|
||||
val client = currentClient ?: error("You need to call `setHomeserver()` first")
|
||||
val currentSessionPaths = sessionPaths ?: error("You need to call `setHomeserver()` first")
|
||||
client.loginWithOidcCallback(
|
||||
client.loginWithOauthCallback(
|
||||
callbackUrl = callbackUrl,
|
||||
)
|
||||
// Free the pending data since we won't use it to abort the flow anymore
|
||||
|
|
@ -368,7 +368,7 @@ class RustMatrixAuthenticationService(
|
|||
qrCodeData = sdkQrCodeLoginData,
|
||||
)
|
||||
client.newLoginWithQrCodeHandler(
|
||||
oidcConfiguration = oidcConfiguration,
|
||||
oauthConfiguration = oidcConfiguration,
|
||||
).use {
|
||||
it.scan(
|
||||
qrCodeData = qrCodeData.rustQrCodeData,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ object QrErrorMapper {
|
|||
is RustHumanQrLoginException.OtherDeviceNotSignedIn -> QrLoginException.OtherDeviceNotSignedIn
|
||||
is RustHumanQrLoginException.LinkingNotSupported -> QrLoginException.LinkingNotSupported
|
||||
is RustHumanQrLoginException.Unknown -> QrLoginException.Unknown
|
||||
is RustHumanQrLoginException.OidcMetadataInvalid -> QrLoginException.OidcMetadataInvalid
|
||||
is RustHumanQrLoginException.OAuthMetadataInvalid -> QrLoginException.OidcMetadataInvalid
|
||||
is RustHumanQrLoginException.SlidingSyncNotAvailable -> QrLoginException.SlidingSyncNotAvailable
|
||||
is RustHumanQrLoginException.CheckCodeAlreadySent -> QrLoginException.CheckCodeAlreadySent
|
||||
is RustHumanQrLoginException.CheckCodeCannotBeSent -> QrLoginException.CheckCodeCannotBeSent
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ object RustIdentityResetHandleFactory {
|
|||
return runCatchingExceptions {
|
||||
identityResetHandle?.let {
|
||||
when (val authType = identityResetHandle.authType()) {
|
||||
is CrossSigningResetAuthType.Oidc -> RustOidcIdentityResetHandle(identityResetHandle, authType.info.approvalUrl)
|
||||
is CrossSigningResetAuthType.OAuth -> RustOidcIdentityResetHandle(identityResetHandle, authType.info.approvalUrl)
|
||||
// User interactive authentication (user + password)
|
||||
CrossSigningResetAuthType.Uiaa -> RustPasswordIdentityResetHandle(userId, identityResetHandle)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ internal fun Session.toSessionData(
|
|||
accessToken = accessToken,
|
||||
refreshToken = refreshToken,
|
||||
homeserverUrl = homeserverUrl ?: this.homeserverUrl,
|
||||
oidcData = oidcData,
|
||||
oidcData = oauthData,
|
||||
loginTimestamp = Date(),
|
||||
isTokenValid = isTokenValid,
|
||||
loginType = loginType,
|
||||
|
|
|
|||
|
|
@ -516,10 +516,10 @@ class JoinedRustRoom(
|
|||
return innerRoom.liveLocationSharesFlow().timedByExpiry(systemClock::epochMillis)
|
||||
}
|
||||
|
||||
override suspend fun startLiveLocationShare(durationMillis: Long): Result<Unit> = withContext(roomDispatcher) {
|
||||
override suspend fun startLiveLocationShare(durationMillis: Long): Result<EventId> = withContext(roomDispatcher) {
|
||||
runCatchingExceptions {
|
||||
innerRoom.startLiveLocationShare(durationMillis.toULong())
|
||||
}
|
||||
}.map(::EventId)
|
||||
}
|
||||
|
||||
override suspend fun stopLiveLocationShare(): Result<Unit> = withContext(roomDispatcher) {
|
||||
|
|
@ -538,7 +538,7 @@ class JoinedRustRoom(
|
|||
|
||||
override fun destroy() {
|
||||
baseRoom.destroy()
|
||||
liveInnerTimeline.destroy()
|
||||
liveTimeline.close()
|
||||
threadsListService.destroy()
|
||||
Timber.d("Room $roomId destroyed")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import kotlinx.coroutines.channels.awaitClose
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.buffer
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import org.matrix.rustcomponents.sdk.LiveLocationShareListener
|
||||
import org.matrix.rustcomponents.sdk.LiveLocationShareUpdate
|
||||
import org.matrix.rustcomponents.sdk.LiveLocationsListener
|
||||
import org.matrix.rustcomponents.sdk.RoomInterface
|
||||
import org.matrix.rustcomponents.sdk.LiveLocationShare as RustLiveLocationShare
|
||||
|
||||
|
|
@ -41,9 +41,9 @@ fun RoomInterface.liveLocationSharesFlow(): Flow<List<LiveLocationShare>> {
|
|||
}
|
||||
}
|
||||
return callbackFlow {
|
||||
val liveLocationShares = liveLocationShares()
|
||||
val liveLocationShares = liveLocationsObserver()
|
||||
val shares: MutableList<LiveLocationShare> = ArrayList()
|
||||
val taskHandle = liveLocationShares.subscribe(object : LiveLocationShareListener {
|
||||
val taskHandle = liveLocationShares.subscribe(object : LiveLocationsListener {
|
||||
override fun onUpdate(updates: List<LiveLocationShareUpdate>) {
|
||||
for (update in updates) {
|
||||
shares.applyUpdate(update)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.google.common.truth.Truth.assertThat
|
|||
import io.element.android.libraries.matrix.api.auth.AuthenticationException
|
||||
import org.junit.Test
|
||||
import org.matrix.rustcomponents.sdk.ClientBuildException
|
||||
import org.matrix.rustcomponents.sdk.OidcException
|
||||
import org.matrix.rustcomponents.sdk.OAuthException
|
||||
|
||||
class AuthenticationExceptionMappingTest {
|
||||
@Test
|
||||
|
|
@ -65,15 +65,15 @@ class AuthenticationExceptionMappingTest {
|
|||
|
||||
@Test
|
||||
fun `mapping Oidc exceptions map to the Oidc Kotlin`() {
|
||||
assertThat(OidcException.Generic("Generic").mapAuthenticationException())
|
||||
assertThat(OAuthException.Generic("Generic").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Oidc>("Generic")
|
||||
assertThat(OidcException.CallbackUrlInvalid("CallbackUrlInvalid").mapAuthenticationException())
|
||||
assertThat(OAuthException.CallbackUrlInvalid("CallbackUrlInvalid").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Oidc>("CallbackUrlInvalid")
|
||||
assertThat(OidcException.Cancelled("Cancelled").mapAuthenticationException())
|
||||
assertThat(OAuthException.Cancelled("Cancelled").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Oidc>("Cancelled")
|
||||
assertThat(OidcException.MetadataInvalid("MetadataInvalid").mapAuthenticationException())
|
||||
assertThat(OAuthException.MetadataInvalid("MetadataInvalid").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Oidc>("MetadataInvalid")
|
||||
assertThat(OidcException.NotSupported("NotSupported").mapAuthenticationException())
|
||||
assertThat(OAuthException.NotSupported("NotSupported").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Oidc>("NotSupported")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class QrErrorMapperTest {
|
|||
assertThat(QrErrorMapper.map(RustHumanQrLoginException.OtherDeviceNotSignedIn())).isEqualTo(QrLoginException.OtherDeviceNotSignedIn)
|
||||
assertThat(QrErrorMapper.map(RustHumanQrLoginException.LinkingNotSupported())).isEqualTo(QrLoginException.LinkingNotSupported)
|
||||
assertThat(QrErrorMapper.map(RustHumanQrLoginException.Unknown())).isEqualTo(QrLoginException.Unknown)
|
||||
assertThat(QrErrorMapper.map(RustHumanQrLoginException.OidcMetadataInvalid())).isEqualTo(QrLoginException.OidcMetadataInvalid)
|
||||
assertThat(QrErrorMapper.map(RustHumanQrLoginException.OAuthMetadataInvalid())).isEqualTo(QrLoginException.OidcMetadataInvalid)
|
||||
assertThat(QrErrorMapper.map(RustHumanQrLoginException.SlidingSyncNotAvailable())).isEqualTo(QrLoginException.SlidingSyncNotAvailable)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
package io.element.android.libraries.matrix.impl.fixtures.factories
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiTimelineEvent
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_NAME
|
||||
import io.element.android.libraries.matrix.test.A_USER_NAME
|
||||
|
|
@ -68,6 +69,8 @@ internal fun aRustNotificationRoomInfo(
|
|||
isDirect: Boolean = false,
|
||||
joinRule: JoinRule? = null,
|
||||
isSpace: Boolean = false,
|
||||
serviceMembers: List<UserId> = emptyList(),
|
||||
activeServiceMemberCount: Int = 0,
|
||||
) = NotificationRoomInfo(
|
||||
displayName = displayName,
|
||||
avatarUrl = avatarUrl,
|
||||
|
|
@ -78,6 +81,8 @@ internal fun aRustNotificationRoomInfo(
|
|||
isDirect = isDirect,
|
||||
joinRule = joinRule,
|
||||
isSpace = isSpace,
|
||||
serviceMembers = serviceMembers.map { it.value },
|
||||
activeServiceMembersCount = activeServiceMemberCount.toULong(),
|
||||
)
|
||||
|
||||
internal fun aRustNotificationEventTimeline(
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ internal fun aRustRoomInfo(
|
|||
serviceMembers: List<String> = emptyList(),
|
||||
isLowPriority: Boolean = false,
|
||||
activeRoomCallConsensusIntent: RtcCallIntentConsensus = RtcCallIntentConsensus.None,
|
||||
activeServiceMembersCount: Int = 0,
|
||||
) = RoomInfo(
|
||||
id = id,
|
||||
displayName = displayName,
|
||||
|
|
@ -101,4 +102,5 @@ internal fun aRustRoomInfo(
|
|||
serviceMembers = serviceMembers,
|
||||
isLowPriority = isLowPriority,
|
||||
activeRoomCallConsensusIntent = activeRoomCallConsensusIntent,
|
||||
activeServiceMembersCount = activeServiceMembersCount.toULong(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ internal fun aRustSession(
|
|||
userId = A_USER_ID.value,
|
||||
deviceId = A_DEVICE_ID.value,
|
||||
homeserverUrl = A_HOMESERVER_URL,
|
||||
oidcData = null,
|
||||
oauthData = null,
|
||||
slidingSyncVersion = proxy,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class FakeFfiHomeserverLoginDetails(
|
|||
private val supportsSsoLogin: Boolean = false,
|
||||
) : HomeserverLoginDetails(NoHandle) {
|
||||
override fun url(): String = url
|
||||
override fun supportsOidcLogin(): Boolean = supportsOidcLogin
|
||||
override fun supportsOauthLogin(): Boolean = supportsOidcLogin
|
||||
override fun supportsPasswordLogin(): Boolean = supportsPasswordLogin
|
||||
override fun supportsSsoLogin(): Boolean = supportsSsoLogin
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import io.element.android.libraries.matrix.api.roomdirectory.RoomVisibility
|
|||
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||
import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver
|
||||
import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings
|
||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||
import io.element.android.libraries.matrix.test.notificationsettings.FakeNotificationSettingsService
|
||||
import io.element.android.libraries.matrix.test.room.threads.FakeThreadsListService
|
||||
import io.element.android.libraries.matrix.test.timeline.FakeTimeline
|
||||
|
|
@ -238,8 +239,8 @@ class FakeJoinedRoom(
|
|||
return liveLocationSharesFlow
|
||||
}
|
||||
|
||||
override suspend fun startLiveLocationShare(durationMillis: Long): Result<Unit> = simulateLongTask {
|
||||
startLiveLocationShareResult(durationMillis)
|
||||
override suspend fun startLiveLocationShare(durationMillis: Long): Result<EventId> = simulateLongTask {
|
||||
startLiveLocationShareResult(durationMillis).map { AN_EVENT_ID }
|
||||
}
|
||||
|
||||
override suspend fun stopLiveLocationShare(): Result<Unit> = simulateLongTask {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue