Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to revoke installations #391

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,27 @@ public final class Client {
}
try await client.requestHistorySync()
}

public func revokeAllOtherInstallations(signingKey: SigningKey) async throws {
guard let client = v3Client else {
throw ClientError.noV3Client("Error: No V3 client initialized")
}

if let signatureRequest = try await client.revokeAllOtherInstallations() {
do {
let signedData = try await signingKey.sign(message: signatureRequest.signatureText())
try await signatureRequest.addEcdsaSignature(signatureBytes: signedData.rawData)
try await client.registerIdentity(signatureRequest: signatureRequest)
} catch {
throw ClientError.creationError("Failed to sign the message: \(error.localizedDescription)")
}
}
nplasterer marked this conversation as resolved.
Show resolved Hide resolved
}

public func inboxState(refreshFromNetwork: Bool) async throws -> InboxState {
guard let client = v3Client else {
throw ClientError.noV3Client("Error: No V3 client initialized")
}
return InboxState(ffiInboxState: client.inboxState(refreshFromNetwork: refreshFromNetwork))
}
}
34 changes: 34 additions & 0 deletions Sources/XMTPiOS/Mls/InboxState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// InboxState.swift
//
//
// Created by Naomi Plasterer on 8/21/24.
//

import Foundation
import LibXMTP

public struct InboxState {
var ffiInboxState: FfiInboxState

init(ffiInboxState: FfiInboxState) {
self.ffiInboxState = ffiInboxState
}

public var inboxId: String {
ffiInboxState.inboxId
}

public var addresses: [String] {
ffiInboxState.accountAddresses
}

public var installationIds: [String] {
ffiInboxState.installationIds.map { id in id.toHex}
}

public var recoveryAddress: String {
ffiInboxState.recoveryAddress
}

}
Loading