mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Bump to libsignal v0.88.0.
This commit is contained in:
committed by
Greyson Parrelli
parent
da966753a1
commit
3af8b6050c
@@ -1,18 +1,8 @@
|
||||
package org.thoughtcrime.securesms.dependencies
|
||||
|
||||
import org.signal.libsignal.internal.mapWithCancellation
|
||||
import org.signal.libsignal.keytrans.KeyTransparencyException
|
||||
import org.signal.libsignal.keytrans.VerificationFailedException
|
||||
import org.signal.libsignal.net.AppExpiredException
|
||||
import org.signal.libsignal.net.BadRequestError
|
||||
import org.signal.libsignal.net.ChatServiceException
|
||||
import org.signal.libsignal.net.KeyTransparency
|
||||
import org.signal.libsignal.net.NetworkException
|
||||
import org.signal.libsignal.net.NetworkProtocolException
|
||||
import org.signal.libsignal.net.RequestResult
|
||||
import org.signal.libsignal.net.RetryLaterException
|
||||
import org.signal.libsignal.net.ServerSideErrorException
|
||||
import org.signal.libsignal.net.TimeoutException
|
||||
import org.signal.libsignal.net.getOrError
|
||||
import org.signal.libsignal.protocol.IdentityKey
|
||||
import org.signal.libsignal.protocol.ServiceId
|
||||
@@ -27,69 +17,18 @@ class KeyTransparencyApi(private val unauthWebSocket: SignalWebSocket.Unauthenti
|
||||
/**
|
||||
* Uses KT to verify recipient. This is an unauthenticated and should only be called the first time KT is being requested for this recipient.
|
||||
*/
|
||||
suspend fun search(aci: ServiceId.Aci, aciIdentityKey: IdentityKey, e164: String?, unidentifiedAccessKey: ByteArray?, usernameHash: ByteArray?, keyTransparencyStore: KeyTransparencyStore): RequestResult<Unit, KeyTransparencyError> {
|
||||
suspend fun search(aci: ServiceId.Aci, aciIdentityKey: IdentityKey, e164: String?, unidentifiedAccessKey: ByteArray?, usernameHash: ByteArray?, keyTransparencyStore: KeyTransparencyStore): RequestResult<Unit, KeyTransparencyException> {
|
||||
return unauthWebSocket.runCatchingWithUnauthChatConnection { chatConnection ->
|
||||
chatConnection.keyTransparencyClient().search(aci, aciIdentityKey, e164, unidentifiedAccessKey, usernameHash, keyTransparencyStore)
|
||||
.mapWithCancellation(
|
||||
onSuccess = { RequestResult.Success(Unit) },
|
||||
onError = { throwable ->
|
||||
when (throwable) {
|
||||
is VerificationFailedException,
|
||||
is KeyTransparencyException,
|
||||
is AppExpiredException,
|
||||
is IllegalArgumentException -> {
|
||||
RequestResult.NonSuccess(KeyTransparencyError(throwable))
|
||||
}
|
||||
is ChatServiceException,
|
||||
is NetworkException,
|
||||
is NetworkProtocolException -> {
|
||||
RequestResult.RetryableNetworkError(throwable, null)
|
||||
}
|
||||
is RetryLaterException -> {
|
||||
RequestResult.RetryableNetworkError(throwable, throwable.duration)
|
||||
}
|
||||
else -> {
|
||||
RequestResult.ApplicationError(throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}.getOrError()
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitors KT to verify recipient. This is an unauthenticated and should only be called following a successful [search].
|
||||
*/
|
||||
suspend fun monitor(monitorMode: KeyTransparency.MonitorMode, aci: ServiceId.Aci, aciIdentityKey: IdentityKey, e164: String?, unidentifiedAccessKey: ByteArray?, usernameHash: ByteArray?, keyTransparencyStore: KeyTransparencyStore): RequestResult<Unit, KeyTransparencyError> {
|
||||
suspend fun monitor(monitorMode: KeyTransparency.MonitorMode, aci: ServiceId.Aci, aciIdentityKey: IdentityKey, e164: String?, unidentifiedAccessKey: ByteArray?, usernameHash: ByteArray?, keyTransparencyStore: KeyTransparencyStore): RequestResult<Unit, KeyTransparencyException> {
|
||||
return unauthWebSocket.runCatchingWithUnauthChatConnection { chatConnection ->
|
||||
chatConnection.keyTransparencyClient().monitor(monitorMode, aci, aciIdentityKey, e164, unidentifiedAccessKey, usernameHash, keyTransparencyStore)
|
||||
.mapWithCancellation(
|
||||
onSuccess = { RequestResult.Success(Unit) },
|
||||
onError = { throwable ->
|
||||
when (throwable) {
|
||||
is TimeoutException,
|
||||
is ServerSideErrorException,
|
||||
is NetworkException,
|
||||
is NetworkProtocolException -> {
|
||||
RequestResult.RetryableNetworkError(throwable, null)
|
||||
}
|
||||
is RetryLaterException -> {
|
||||
RequestResult.RetryableNetworkError(throwable, throwable.duration)
|
||||
}
|
||||
is VerificationFailedException,
|
||||
is KeyTransparencyException,
|
||||
is AppExpiredException,
|
||||
is IllegalArgumentException -> {
|
||||
RequestResult.NonSuccess(KeyTransparencyError(throwable))
|
||||
}
|
||||
else -> {
|
||||
RequestResult.ApplicationError(throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}.getOrError()
|
||||
}
|
||||
}
|
||||
|
||||
data class KeyTransparencyError(val exception: Throwable) : BadRequestError
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.thoughtcrime.securesms.jobs
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.libsignal.keytrans.KeyTransparencyException
|
||||
import org.signal.libsignal.keytrans.VerificationFailedException
|
||||
import org.signal.libsignal.net.AppExpiredException
|
||||
import org.signal.libsignal.net.KeyTransparency
|
||||
import org.signal.libsignal.net.RequestResult
|
||||
import org.signal.libsignal.usernames.Username
|
||||
@@ -142,28 +139,15 @@ class CheckKeyTransparencyJob private constructor(
|
||||
}
|
||||
|
||||
is RequestResult.NonSuccess -> {
|
||||
if (result.error.exception is IllegalArgumentException) {
|
||||
Log.w(TAG, "KT store was corrupted. Restarting and then retrying.")
|
||||
SignalStore.account.distinguishedHead = null
|
||||
SignalDatabase.recipients.clearSelfKeyTransparencyData()
|
||||
Result.retry(defaultBackoff())
|
||||
} else if (result.error.exception is VerificationFailedException || result.error.exception is KeyTransparencyException) {
|
||||
if (!showFailure) {
|
||||
Log.w(TAG, "Verification failure. Enqueuing this job again to run again a day.")
|
||||
StorageSyncJob.forRemoteChange()
|
||||
enqueueFollowingFailure()
|
||||
} else {
|
||||
Log.w(TAG, "Second verification failure. Showing failure sheet.")
|
||||
markFailure()
|
||||
}
|
||||
Result.failure()
|
||||
} else if (result.error.exception is AppExpiredException) {
|
||||
Result.failure()
|
||||
if (!showFailure) {
|
||||
Log.w(TAG, "Verification failure. Enqueuing this job again to run again a day.")
|
||||
StorageSyncJob.forRemoteChange()
|
||||
enqueueFollowingFailure()
|
||||
} else {
|
||||
Log.w(TAG, "Unknown nonsuccess failure. Showing failure sheet.")
|
||||
Log.w(TAG, "Second verification failure. Showing failure sheet.")
|
||||
markFailure()
|
||||
Result.failure()
|
||||
}
|
||||
Result.failure()
|
||||
}
|
||||
is RequestResult.RetryableNetworkError -> {
|
||||
if (result.retryAfter != null) {
|
||||
@@ -173,9 +157,16 @@ class CheckKeyTransparencyJob private constructor(
|
||||
}
|
||||
}
|
||||
is RequestResult.ApplicationError -> {
|
||||
Log.w(TAG, "Unknown application failure. Showing failure sheet.")
|
||||
markFailure()
|
||||
Result.failure()
|
||||
if (result.cause is IllegalArgumentException) {
|
||||
Log.w(TAG, "KT store was corrupted. Restarting and then retrying.")
|
||||
SignalStore.account.distinguishedHead = null
|
||||
SignalDatabase.recipients.clearSelfKeyTransparencyData()
|
||||
Result.retry(defaultBackoff())
|
||||
} else {
|
||||
Log.w(TAG, "Unknown application failure. Showing failure sheet.")
|
||||
markFailure()
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,7 @@ object VerifySafetyNumberRepository {
|
||||
VerifyResult.Success
|
||||
}
|
||||
is RequestResult.NonSuccess -> {
|
||||
if (result.error.exception is IllegalArgumentException) {
|
||||
VerifyResult.CorruptedFailure
|
||||
} else {
|
||||
VerifyResult.UnretryableFailure
|
||||
}
|
||||
VerifyResult.UnretryableFailure
|
||||
}
|
||||
is RequestResult.RetryableNetworkError -> {
|
||||
if (result.retryAfter != null) {
|
||||
@@ -63,7 +59,13 @@ object VerifySafetyNumberRepository {
|
||||
VerifyResult.UnretryableFailure
|
||||
}
|
||||
}
|
||||
is RequestResult.ApplicationError -> VerifyResult.UnretryableFailure
|
||||
is RequestResult.ApplicationError -> {
|
||||
if (result.cause is IllegalArgumentException) {
|
||||
VerifyResult.CorruptedFailure
|
||||
} else {
|
||||
VerifyResult.UnretryableFailure
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user