diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index 83546d966..50ff85fec 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -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 @@ -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) diff --git a/library/src/main/java/org/xmtp/android/library/libxmtp/InboxState.kt b/library/src/main/java/org/xmtp/android/library/libxmtp/InboxState.kt new file mode 100644 index 000000000..cf4325ff0 --- /dev/null +++ b/library/src/main/java/org/xmtp/android/library/libxmtp/InboxState.kt @@ -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 + get() = ffiInboxState.accountAddresses + + val installationIds: List + get() = ffiInboxState.installationIds.map { it.toHex() } + + val recoveryAddress: String + get() = ffiInboxState.recoveryAddress + +}