Skip to content

Commit

Permalink
add revokation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Aug 21, 2024
1 parent 4056694 commit 9ca2d9f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions library/src/main/java/org/xmtp/android/library/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import uniffi.xmtpv3.createV2Client
import uniffi.xmtpv3.generateInboxId
import uniffi.xmtpv3.getInboxIdForAddress
import uniffi.xmtpv3.getVersionInfo
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.InboxState
import java.io.File
import java.nio.charset.StandardCharsets
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -649,6 +650,24 @@ class Client() {
v3Client?.requestHistorySync() ?: throw XMTPException("Error no V3 client initialized")
}

suspend fun revokeAllOtherInstallations(signingKey: SigningKey) {
if (v3Client == null) throw XMTPException("Error no V3 client initialized")
v3Client?.let { client ->
val signatureRequest = client.revokeAllOtherInstallations()
signingKey.sign(signatureRequest.signatureText())?.let {
signatureRequest.addEcdsaSignature(it.rawData)
client.applySignatureRequest(signatureRequest)
}
}
}

suspend fun inboxState(refreshFromNetwork: Boolean): InboxState {
v3Client?.let {
return InboxState(it.inboxState(refreshFromNetwork))
}
throw XMTPException("Error no V3 client initialized")
}

val privateKeyBundle: PrivateKeyBundle
get() = PrivateKeyBundleBuilder.buildFromV1Key(privateKeyBundleV1)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package uniffi.xmtpv3.org.xmtp.android.library.libxmtp

import org.xmtp.android.library.toHex
import uniffi.xmtpv3.FfiInboxState

class InboxState(private val ffiInboxState: FfiInboxState) {
val inboxId: String
get() = ffiInboxState.inboxId
val addresses: List<String>
get() = ffiInboxState.accountAddresses

val installationIds: List<String>
get() = ffiInboxState.installationIds.map { it.toHex() }

val recoveryAddress: String
get() = ffiInboxState.recoveryAddress

}

0 comments on commit 9ca2d9f

Please sign in to comment.