feat: add all namespaces to delete all messages request and signature verification data

This commit is contained in:
0x330a 2023-06-14 11:18:59 +10:00
parent db277e1d30
commit 4d14ec0564
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
2 changed files with 5 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import org.session.libsignal.utilities.HTTP
import org.session.libsignal.utilities.Hex import org.session.libsignal.utilities.Hex
import org.session.libsignal.utilities.JsonUtil import org.session.libsignal.utilities.JsonUtil
import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.Log
import org.session.libsignal.utilities.Namespace
import org.session.libsignal.utilities.Snode import org.session.libsignal.utilities.Snode
import org.session.libsignal.utilities.ThreadUtils import org.session.libsignal.utilities.ThreadUtils
import org.session.libsignal.utilities.prettifiedDescription import org.session.libsignal.utilities.prettifiedDescription
@ -740,13 +741,14 @@ object SnodeAPI {
retryIfNeeded(maxRetryCount) { retryIfNeeded(maxRetryCount) {
getNetworkTime(snode).bind { (_, timestamp) -> getNetworkTime(snode).bind { (_, timestamp) ->
val signature = ByteArray(Sign.BYTES) val signature = ByteArray(Sign.BYTES)
val verificationData = (Snode.Method.DeleteAll.rawValue + timestamp.toString()).toByteArray() val verificationData = (Snode.Method.DeleteAll.rawValue + Namespace.ALL + timestamp.toString()).toByteArray()
sodium.cryptoSignDetached(signature, verificationData, verificationData.size.toLong(), userED25519KeyPair.secretKey.asBytes) sodium.cryptoSignDetached(signature, verificationData, verificationData.size.toLong(), userED25519KeyPair.secretKey.asBytes)
val deleteMessageParams = mapOf( val deleteMessageParams = mapOf(
"pubkey" to userPublicKey, "pubkey" to userPublicKey,
"pubkey_ed25519" to userED25519KeyPair.publicKey.asHexString, "pubkey_ed25519" to userED25519KeyPair.publicKey.asHexString,
"timestamp" to timestamp, "timestamp" to timestamp,
"signature" to Base64.encodeBytes(signature) "signature" to Base64.encodeBytes(signature),
"namespace" to Namespace.ALL,
) )
invoke(Snode.Method.DeleteAll, snode, deleteMessageParams, userPublicKey).map { invoke(Snode.Method.DeleteAll, snode, deleteMessageParams, userPublicKey).map {
rawResponse -> parseDeletions(userPublicKey, timestamp, rawResponse) rawResponse -> parseDeletions(userPublicKey, timestamp, rawResponse)

View File

@ -1,6 +1,7 @@
package org.session.libsignal.utilities package org.session.libsignal.utilities
object Namespace { object Namespace {
const val ALL = "all"
const val DEFAULT = 0 const val DEFAULT = 0
const val UNAUTHENTICATED_CLOSED_GROUP = -10 const val UNAUTHENTICATED_CLOSED_GROUP = -10
} }