From 0d00b17a6783ee8037e371967b4f3d2af9ff7340 Mon Sep 17 00:00:00 2001 From: Pat Nakajima Date: Wed, 11 Oct 2023 12:41:15 -0700 Subject: [PATCH 01/11] Start on v2 allow state stuff --- Package.resolved | 4 +- Sources/XMTP/Contacts.swift | 69 +++++++++ Sources/XMTP/Conversation.swift | 39 +++-- Sources/XMTP/Conversations.swift | 2 + Tests/XMTPTests/ContactsTests.swift | 28 ++++ Tests/XMTPTests/ConversationTests.swift | 180 ++++++++++++++---------- 6 files changed, 229 insertions(+), 93 deletions(-) diff --git a/Package.resolved b/Package.resolved index e5bfa207..b1574ca2 100644 --- a/Package.resolved +++ b/Package.resolved @@ -149,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/xmtp-rust-swift", "state" : { - "revision" : "4a76e5401fa780c40610e2f0d248f695261d08dd", - "version" : "0.3.1-beta0" + "revision" : "d1aaac47fc7c57645a6fe9e06972b957b3efa33c", + "version" : "0.3.5-beta0" } } ], diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index 1e750628..1887e44b 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -7,6 +7,35 @@ import Foundation +public enum AllowState: String, Codable { + case allowed, blocked, unknown +} + +struct AllowListEntry: Codable, Hashable { + enum EntryType: String, Codable { + case address + } + + static func address(_ address: String, type: AllowState) -> AllowListEntry { + AllowListEntry(value: address, entryType: .address, permissionType: type) + } + + var value: String + var entryType: EntryType + var permissionType: AllowState +} + +struct AllowList { + var allowedAddresses: Set = [] + var blockedAddresses: Set = [] + + var entries: Set = [] + + func state(address: String) -> AllowState { + entries.first(where: { $0.entryType == .address && $0.value == address })?.permissionType ?? AllowState.unknown + } +} + /// Provides access to contact bundles. public actor Contacts { var client: Client @@ -17,10 +46,50 @@ public actor Contacts { // Whether or not we have sent invite/intro to this contact var hasIntroduced: [String: Bool] = [:] + var allowList = AllowList() + init(client: Client) { self.client = client } + public func isAllowed(_ address: String) -> Bool { + for entry in allowList.entries { + switch entry.entryType { + case .address: + if address == entry.value { + return entry.permissionType == .allowed + } + } + } + + return false + } + + public func isBlocked(_ address: String) -> Bool { + for entry in allowList.entries { + switch entry.entryType { + case .address: + if address == entry.value { + return entry.permissionType == .blocked + } + } + } + + return false + } + + public func allow(addresses: [String]) { + for address in addresses { + allowList.entries.insert(.address(address, type: .allowed)) + } + } + + public func block(addresses: [String]) { + for address in addresses { + allowList.entries.insert(.address(address, type: .blocked)) + } + } + func markIntroduced(_ peerAddress: String, _ isIntroduced: Bool) { hasIntroduced[peerAddress] = isIntroduced } diff --git a/Sources/XMTP/Conversation.swift b/Sources/XMTP/Conversation.swift index 5d922af7..2b0c0c2f 100644 --- a/Sources/XMTP/Conversation.swift +++ b/Sources/XMTP/Conversation.swift @@ -29,6 +29,19 @@ public enum Conversation: Sendable { case v1, v2 } + public func allowState() async -> AllowState { + let client: Client + + switch self { + case .v1(let conversationV1): + client = conversationV1.client + case .v2(let conversationV2): + client = conversationV2.client + } + + return await client.contacts.allowList.state(address: peerAddress) + } + public var version: Version { switch self { case .v1: @@ -82,7 +95,7 @@ public enum Conversation: Sendable { /// See Conversations.importTopicData() public func toTopicData() -> Xmtp_KeystoreApi_V1_TopicMap.TopicData { Xmtp_KeystoreApi_V1_TopicMap.TopicData.with { - $0.createdNs = UInt64(createdAt.timeIntervalSince1970 * 1_000) * 1_000_000 + $0.createdNs = UInt64(createdAt.timeIntervalSince1970 * 1000) * 1_000_000 $0.peerAddress = peerAddress if case let .v2(cv2) = self { $0.invitation = Xmtp_MessageContents_InvitationV1.with { @@ -123,16 +136,16 @@ public enum Conversation: Sendable { } } - // This is a convenience for invoking the underlying `client.publish(prepared.envelopes)` - // If a caller has a `Client` handy, they may opt to do that directly instead. - @discardableResult public func send(prepared: PreparedMessage) async throws -> String { - switch self { - case let .v1(conversationV1): - return try await conversationV1.send(prepared: prepared) - case let .v2(conversationV2): - return try await conversationV2.send(prepared: prepared) - } - } + // This is a convenience for invoking the underlying `client.publish(prepared.envelopes)` + // If a caller has a `Client` handy, they may opt to do that directly instead. + @discardableResult public func send(prepared: PreparedMessage) async throws -> String { + switch self { + case let .v1(conversationV1): + return try await conversationV1.send(prepared: prepared) + case let .v2(conversationV2): + return try await conversationV2.send(prepared: prepared) + } + } @discardableResult public func send(content: T, options: SendOptions? = nil, fallback _: String? = nil) async throws -> String { switch self { @@ -199,10 +212,10 @@ public enum Conversation: Sendable { } /// List messages in the conversation - public func messages(limit: Int? = nil, before: Date? = nil, after: Date? = nil, direction: PagingInfoSortDirection? = .descending) async throws -> [DecodedMessage] { + public func messages(limit: Int? = nil, before: Date? = nil, after: Date? = nil, direction: PagingInfoSortDirection? = .descending) async throws -> [DecodedMessage] { switch self { case let .v1(conversationV1): - return try await conversationV1.messages(limit: limit, before: before, after: after, direction: direction) + return try await conversationV1.messages(limit: limit, before: before, after: after, direction: direction) case let .v2(conversationV2): return try await conversationV2.messages(limit: limit, before: before, after: after, direction: direction) } diff --git a/Sources/XMTP/Conversations.swift b/Sources/XMTP/Conversations.swift index 109e67ca..b5db19eb 100644 --- a/Sources/XMTP/Conversations.swift +++ b/Sources/XMTP/Conversations.swift @@ -155,6 +155,8 @@ public actor Conversations { let sealedInvitation = try await sendInvitation(recipient: recipient, invitation: invitation, created: Date()) let conversationV2 = try ConversationV2.create(client: client, invitation: invitation, header: sealedInvitation.v1.header) + await client.contacts.allow(addresses: [peerAddress]) + let conversation: Conversation = .v2(conversationV2) conversationsByTopic[conversation.topic] = conversation return conversation diff --git a/Tests/XMTPTests/ContactsTests.swift b/Tests/XMTPTests/ContactsTests.swift index 072bb415..d4006e87 100644 --- a/Tests/XMTPTests/ContactsTests.swift +++ b/Tests/XMTPTests/ContactsTests.swift @@ -53,4 +53,32 @@ class ContactsTests: XCTestCase { let hasContact = await fixtures.aliceClient.contacts.has(fixtures.bob.walletAddress) XCTAssert(hasContact) } + + func testAllowAddress() async throws { + let fixtures = await fixtures() + + let contacts = fixtures.bobClient.contacts + var result = await contacts.isAllowed(fixtures.alice.address) + + XCTAssertFalse(result) + + await contacts.allow(addresses: [fixtures.alice.address]) + + result = await contacts.isAllowed(fixtures.alice.address) + XCTAssertTrue(result) + } + + func testBlockAddress() async throws { + let fixtures = await fixtures() + + let contacts = fixtures.bobClient.contacts + var result = await contacts.isAllowed(fixtures.alice.address) + + XCTAssertFalse(result) + + await contacts.block(addresses: [fixtures.alice.address]) + + result = await contacts.isBlocked(fixtures.alice.address) + XCTAssertTrue(result) + } } diff --git a/Tests/XMTPTests/ConversationTests.swift b/Tests/XMTPTests/ConversationTests.swift index b6ede00a..4f213547 100644 --- a/Tests/XMTPTests/ConversationTests.swift +++ b/Tests/XMTPTests/ConversationTests.swift @@ -39,7 +39,7 @@ class ConversationTests: XCTestCase { let preparedMessage = try await conversation.prepareMessage(content: "hi") let messageID = preparedMessage.messageID - try await conversation.send(prepared: preparedMessage) + try await conversation.send(prepared: preparedMessage) let messages = try await conversation.messages() let message = messages[0] @@ -48,27 +48,27 @@ class ConversationTests: XCTestCase { XCTAssertEqual(message.id, messageID) } - func testCanSendPreparedMessagesWithoutAConversation() async throws { - let conversation = try await aliceClient.conversations.newConversation(with: bob.address) - let preparedMessage = try await conversation.prepareMessage(content: "hi") - let messageID = preparedMessage.messageID + func testCanSendPreparedMessagesWithoutAConversation() async throws { + let conversation = try await aliceClient.conversations.newConversation(with: bob.address) + let preparedMessage = try await conversation.prepareMessage(content: "hi") + let messageID = preparedMessage.messageID - // This does not need the `conversation` to `.publish` the message. - // This simulates a background task publishes all pending messages upon connection. - try await aliceClient.publish(envelopes: preparedMessage.envelopes) + // This does not need the `conversation` to `.publish` the message. + // This simulates a background task publishes all pending messages upon connection. + try await aliceClient.publish(envelopes: preparedMessage.envelopes) - let messages = try await conversation.messages() - let message = messages[0] + let messages = try await conversation.messages() + let message = messages[0] - XCTAssertEqual("hi", message.body) - XCTAssertEqual(message.id, messageID) - } + XCTAssertEqual("hi", message.body) + XCTAssertEqual(message.id, messageID) + } func testV2RejectsSpoofedContactBundles() async throws { let topic = "/xmtp/0/m-Gdb7oj5nNdfZ3MJFLAcS4WTABgr6al1hePy6JV1-QUE/proto" guard let envelopeMessage = Data(base64String: "Er0ECkcIwNruhKLgkKUXEjsveG10cC8wL20tR2RiN29qNW5OZGZaM01KRkxBY1M0V1RBQmdyNmFsMWhlUHk2SlYxLVFVRS9wcm90bxLxAwruAwognstLoG6LWgiBRsWuBOt+tYNJz+CqCj9zq6hYymLoak8SDFsVSy+cVAII0/r3sxq7A/GCOrVtKH6J+4ggfUuI5lDkFPJ8G5DHlysCfRyFMcQDIG/2SFUqSILAlpTNbeTC9eSI2hUjcnlpH9+ncFcBu8StGfmilVGfiADru2fGdThiQ+VYturqLIJQXCHO2DkvbbUOg9xI66E4Hj41R9vE8yRGeZ/eRGRLRm06HftwSQgzAYf2AukbvjNx/k+xCMqti49Qtv9AjzxVnwttLiA/9O+GDcOsiB1RQzbZZzaDjQ/nLDTF6K4vKI4rS9QwzTJqnoCdp0SbMZFf+KVZpq3VWnMGkMxLW5Fr6gMvKny1e1LAtUJSIclI/1xPXu5nsKd4IyzGb2ZQFXFQ/BVL9Z4CeOZTsjZLGTOGS75xzzGHDtKohcl79+0lgIhAuSWSLDa2+o2OYT0fAjChp+qqxXcisAyrD5FB6c9spXKfoDZsqMV/bnCg3+udIuNtk7zBk7jdTDMkofEtE3hyIm8d3ycmxKYOakDPqeo+Nk1hQ0ogxI8Z7cEoS2ovi9+rGBMwREzltUkTVR3BKvgV2EOADxxTWo7y8WRwWxQ+O6mYPACsiFNqjX5Nvah5lRjihphQldJfyVOG8Rgf4UwkFxmI"), - let keyMaterial = Data(base64String: "R0BBM5OPftNEuavH/991IKyJ1UqsgdEG4SrdxlIG2ZY=") + let keyMaterial = Data(base64String: "R0BBM5OPftNEuavH/991IKyJ1UqsgdEG4SrdxlIG2ZY=") else { XCTFail("did not have correct setup data") return @@ -88,7 +88,7 @@ class ConversationTests: XCTestCase { } func testDoesNotAllowConversationWithSelf() async throws { - try TestConfig.skipIfNotRunningLocalNodeTests() + try TestConfig.skipIfNotRunningLocalNodeTests() let expectation = expectation(description: "convo with self throws") let client = aliceClient! @@ -221,12 +221,12 @@ class ConversationTests: XCTestCase { let encodedContent = try encoder.encode(content: "hi alice", client: aliceClient) // Stream a message - fakeApiClient.send( + try fakeApiClient.send( envelope: Envelope( topic: conversation.topic, timestamp: Date(), - message: try Message( - v2: try await MessageV2.encode( + message: Message( + v2: await MessageV2.encode( client: bobClient, content: encodedContent, topic: conversation.topic, @@ -292,7 +292,7 @@ class ConversationTests: XCTestCase { ) try await aliceClient.publish(envelopes: [ - Envelope(topic: aliceConversation.topic, timestamp: Date(), message: try Message(v2: tamperedMessage).serializedData()), + Envelope(topic: aliceConversation.topic, timestamp: Date(), message: Message(v2: tamperedMessage).serializedData()), ]) guard case let .v2(bobConversation) = try await bobClient.conversations.newConversation(with: alice.address, context: InvitationV1.Context(conversationID: "hi")) else { @@ -343,7 +343,7 @@ class ConversationTests: XCTestCase { let messages = try await aliceConversation.messages(limit: 1) XCTAssertEqual(1, messages.count) XCTAssertEqual("hey alice 3", messages[0].body) - XCTAssertEqual(aliceConversation.topic.description, messages[0].topic) + XCTAssertEqual(aliceConversation.topic.description, messages[0].topic) let messages2 = try await aliceConversation.messages(limit: 1, before: messages[0].sent) XCTAssertEqual(1, messages2.count) @@ -385,7 +385,7 @@ class ConversationTests: XCTestCase { let messages = try await aliceConversation.messages(limit: 1) XCTAssertEqual(1, messages.count) XCTAssertEqual("hey alice 3", messages[0].body) - XCTAssertEqual(aliceConversation.topic, messages[0].topic) + XCTAssertEqual(aliceConversation.topic, messages[0].topic) let messages2 = try await aliceConversation.messages(limit: 1, before: messages[0].sent) XCTAssertEqual(1, messages2.count) @@ -393,7 +393,6 @@ class ConversationTests: XCTestCase { } func testCanRetrieveAllMessages() async throws { - guard case let .v2(bobConversation) = try await bobClient.conversations.newConversation(with: alice.address, context: InvitationV1.Context(conversationID: "hi")) else { XCTFail("did not get a v2 conversation for bob") return @@ -404,7 +403,7 @@ class ConversationTests: XCTestCase { return } - for i in 0..<110 { + for i in 0 ..< 110 { do { let content = "hey alice \(i)" let sentAt = Date().addingTimeInterval(-1000) @@ -423,61 +422,60 @@ class ConversationTests: XCTestCase { let messages = try await aliceConversation.messages() XCTAssertEqual(110, messages.count) } - - func testCanRetrieveBatchMessages() async throws { - - guard case let .v2(bobConversation) = try await aliceClient.conversations.newConversation(with: bob.address, context: InvitationV1.Context(conversationID: "hi")) else { - XCTFail("did not get a v2 conversation for bob") - return - } - - for i in 0..<3 { - do { - let content = "hey alice \(i)" - let sentAt = Date().addingTimeInterval(-1000) - try await bobConversation.send(content: content, sentAt: sentAt) - } catch { - print("Error sending message:", error) - } - } - - let messages = try await aliceClient.conversations.listBatchMessages( - topics: [bobConversation.topic : Pagination(limit:3)] - ) - XCTAssertEqual(3, messages.count) - XCTAssertEqual(bobConversation.topic, messages[0].topic) - XCTAssertEqual(bobConversation.topic, messages[1].topic) - XCTAssertEqual(bobConversation.topic, messages[2].topic) - } - - func testProperlyDiscardBadBatchMessages() async throws { - - guard case let .v2(bobConversation) = try await aliceClient.conversations - .newConversation(with: bob.address) else { - XCTFail("did not get a v2 conversation for bob") - return - } - - try await bobConversation.send(content: "Hello") - - // Now we send some garbage and expect it to be properly ignored. - try await bobClient.apiClient.publish(envelopes: [ - Envelope( - topic: bobConversation.topic, - timestamp: Date(), - message: Data([1, 2, 3]) // garbage, malformed message - ) - ]) - - try await bobConversation.send(content: "Goodbye") - - let messages = try await aliceClient.conversations.listBatchMessages( - topics: [bobConversation.topic : nil] - ) - XCTAssertEqual(2, messages.count) - XCTAssertEqual("Goodbye", try messages[0].content()) - XCTAssertEqual("Hello", try messages[1].content()) - } + + func testCanRetrieveBatchMessages() async throws { + guard case let .v2(bobConversation) = try await aliceClient.conversations.newConversation(with: bob.address, context: InvitationV1.Context(conversationID: "hi")) else { + XCTFail("did not get a v2 conversation for bob") + return + } + + for i in 0 ..< 3 { + do { + let content = "hey alice \(i)" + let sentAt = Date().addingTimeInterval(-1000) + try await bobConversation.send(content: content, sentAt: sentAt) + } catch { + print("Error sending message:", error) + } + } + + let messages = try await aliceClient.conversations.listBatchMessages( + topics: [bobConversation.topic: Pagination(limit: 3)] + ) + XCTAssertEqual(3, messages.count) + XCTAssertEqual(bobConversation.topic, messages[0].topic) + XCTAssertEqual(bobConversation.topic, messages[1].topic) + XCTAssertEqual(bobConversation.topic, messages[2].topic) + } + + func testProperlyDiscardBadBatchMessages() async throws { + guard case let .v2(bobConversation) = try await aliceClient.conversations + .newConversation(with: bob.address) + else { + XCTFail("did not get a v2 conversation for bob") + return + } + + try await bobConversation.send(content: "Hello") + + // Now we send some garbage and expect it to be properly ignored. + try await bobClient.apiClient.publish(envelopes: [ + Envelope( + topic: bobConversation.topic, + timestamp: Date(), + message: Data([1, 2, 3]) // garbage, malformed message + ), + ]) + + try await bobConversation.send(content: "Goodbye") + + let messages = try await aliceClient.conversations.listBatchMessages( + topics: [bobConversation.topic: nil] + ) + XCTAssertEqual(2, messages.count) + XCTAssertEqual("Goodbye", try messages[0].content()) + XCTAssertEqual("Hello", try messages[1].content()) + } func testImportV1ConversationFromJS() async throws { let jsExportJSONData = Data(""" @@ -607,4 +605,30 @@ class ConversationTests: XCTestCase { XCTAssertEqual(Array(repeating: "A", count: 1000).joined(), messages[0].body) XCTAssertEqual(bob.address, messages[0].senderAddress) } + + func testCanHaveAllowState() async throws { + let bobConversation = try await bobClient.conversations.newConversation(with: alice.address, context: InvitationV1.Context(conversationID: "hi")) + let isAllowed = (await bobConversation.allowState()) == .allowed + + // Conversations you start should start as allowed + XCTAssertTrue(isAllowed) + + let aliceConversation = (try await aliceClient.conversations.list())[0] + let isUnknown = (await aliceConversation.allowState()) == .unknown + + // Conversations started with you should start as unknown + XCTAssertTrue(isUnknown) + + await aliceClient.contacts.allow(addresses: [bob.address]) + + let isBobAllowed = (await aliceConversation.allowState()) == .allowed + XCTAssertTrue(isBobAllowed) + + let aliceClient2 = try await Client.create(account: alice, apiClient: fakeApiClient) + let aliceConversation2 = (try await aliceClient2.conversations.list())[0] + + // Allow state should sync across clients + let isBobAllowed2 = (await aliceConversation2.allowState()) == .allowed + XCTAssertTrue(isBobAllowed2) + } } From 87c1df32ee46cee812890adcaac3a88012050fd5 Mon Sep 17 00:00:00 2001 From: Pat Nakajima Date: Fri, 13 Oct 2023 10:14:18 -0700 Subject: [PATCH 02/11] encrypt --- Package.resolved | 4 +- Package.swift | 2 +- Sources/XMTP/Contacts.swift | 105 +++++++++++++++++------- Sources/XMTP/Conversations.swift | 2 +- Sources/XMTP/Messages/Topic.swift | 5 +- Tests/XMTPTests/ContactsTests.swift | 4 +- Tests/XMTPTests/ConversationTests.swift | 5 +- 7 files changed, 89 insertions(+), 38 deletions(-) diff --git a/Package.resolved b/Package.resolved index b1574ca2..875d144a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -149,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/xmtp-rust-swift", "state" : { - "revision" : "d1aaac47fc7c57645a6fe9e06972b957b3efa33c", - "version" : "0.3.5-beta0" + "branch" : "main", + "revision" : "d1aaac47fc7c57645a6fe9e06972b957b3efa33c" } } ], diff --git a/Package.swift b/Package.swift index 8ee196d6..82d8b97a 100644 --- a/Package.swift +++ b/Package.swift @@ -26,7 +26,7 @@ let package = Package( .package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"), .package(url: "https://github.com/bufbuild/connect-swift", from: "0.3.0"), .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"), - .package(url: "https://github.com/xmtp/xmtp-rust-swift", from: "0.3.5-beta0"), + .package(url: "https://github.com/xmtp/xmtp-rust-swift", branch: "main"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index 1887e44b..8761281f 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -6,6 +6,7 @@ // import Foundation +import XMTPRust public enum AllowState: String, Codable { case allowed, blocked, unknown @@ -16,23 +17,81 @@ struct AllowListEntry: Codable, Hashable { case address } - static func address(_ address: String, type: AllowState) -> AllowListEntry { + static func address(_ address: String, type: AllowState = .unknown) -> AllowListEntry { AllowListEntry(value: address, entryType: .address, permissionType: type) } var value: String var entryType: EntryType var permissionType: AllowState + + var key: String { + "\(entryType)-\(value)" + } } -struct AllowList { - var allowedAddresses: Set = [] - var blockedAddresses: Set = [] +class AllowList { + var entries: [String: AllowState] = [:] + + static func load(from client: Client) async throws -> AllowList { + let envelopes = try await client.query(topic: .allowList(client.address)) + let allowList = AllowList() + + for envelope in envelopes.envelopes { + let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes + let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes + + let payload = try XMTPRust.ecies_decrypt_k256_sha3_256( + RustVec(publicKey), + RustVec(privateKey), + RustVec(envelope.message) + ) + + let entry = try JSONDecoder().decode(AllowListEntry.self, from: Data(payload)) + + allowList.entries[entry.key] = entry.permissionType + } + + return allowList + } + + static func publish(entry: AllowListEntry, to client: Client) async throws { + let payload = try JSONEncoder().encode(entry) + + let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes + let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes + + let message = try XMTPRust.ecies_encrypt_k256_sha3_256( + RustVec(publicKey), + RustVec(privateKey), + RustVec(payload) + ) + + let envelope = Envelope( + topic: Topic.allowList(client.address), + timestamp: Date(), + message: Data(message) + ) + + try await client.publish(envelopes: [envelope]) + } + + func allow(address: String) -> AllowListEntry { + entries[AllowListEntry.address(address).key] = .allowed + + return .address(address, type: .allowed) + } - var entries: Set = [] + func block(address: String) -> AllowListEntry { + entries[AllowListEntry.address(address).key] = .blocked + + return .address(address, type: .blocked) + } func state(address: String) -> AllowState { - entries.first(where: { $0.entryType == .address && $0.value == address })?.permissionType ?? AllowState.unknown + let state = entries[AllowListEntry.address(address).key] + + return state ?? .unknown } } @@ -52,41 +111,27 @@ public actor Contacts { self.client = client } - public func isAllowed(_ address: String) -> Bool { - for entry in allowList.entries { - switch entry.entryType { - case .address: - if address == entry.value { - return entry.permissionType == .allowed - } - } - } + public func refreshAllowList() async throws { + self.allowList = try await AllowList.load(from: client) + } - return false + public func isAllowed(_ address: String) -> Bool { + return allowList.state(address: address) == .allowed } public func isBlocked(_ address: String) -> Bool { - for entry in allowList.entries { - switch entry.entryType { - case .address: - if address == entry.value { - return entry.permissionType == .blocked - } - } - } - - return false + return allowList.state(address: address) == .blocked } - public func allow(addresses: [String]) { + public func allow(addresses: [String]) async throws { for address in addresses { - allowList.entries.insert(.address(address, type: .allowed)) + try await AllowList.publish(entry: allowList.allow(address: address), to: client) } } - public func block(addresses: [String]) { + public func block(addresses: [String]) async throws { for address in addresses { - allowList.entries.insert(.address(address, type: .blocked)) + try await AllowList.publish(entry: allowList.block(address: address), to: client) } } diff --git a/Sources/XMTP/Conversations.swift b/Sources/XMTP/Conversations.swift index b5db19eb..9b9bd3ea 100644 --- a/Sources/XMTP/Conversations.swift +++ b/Sources/XMTP/Conversations.swift @@ -155,7 +155,7 @@ public actor Conversations { let sealedInvitation = try await sendInvitation(recipient: recipient, invitation: invitation, created: Date()) let conversationV2 = try ConversationV2.create(client: client, invitation: invitation, header: sealedInvitation.v1.header) - await client.contacts.allow(addresses: [peerAddress]) + try await client.contacts.allow(addresses: [peerAddress]) let conversation: Conversation = .v2(conversationV2) conversationsByTopic[conversation.topic] = conversation diff --git a/Sources/XMTP/Messages/Topic.swift b/Sources/XMTP/Messages/Topic.swift index e0b9c0b6..638434b3 100644 --- a/Sources/XMTP/Messages/Topic.swift +++ b/Sources/XMTP/Messages/Topic.swift @@ -13,7 +13,8 @@ public enum Topic { userIntro(String), userInvite(String), directMessageV1(String, String), - directMessageV2(String) + directMessageV2(String), + allowList(String) var description: String { switch self { @@ -30,6 +31,8 @@ public enum Topic { return wrap("dm-\(addresses)") case let .directMessageV2(randomString): return wrap("m-\(randomString)") + case let .allowList(identifier): + return wrap("privatestore-\(identifier)/allowlist") } } diff --git a/Tests/XMTPTests/ContactsTests.swift b/Tests/XMTPTests/ContactsTests.swift index d4006e87..d17423c8 100644 --- a/Tests/XMTPTests/ContactsTests.swift +++ b/Tests/XMTPTests/ContactsTests.swift @@ -62,7 +62,7 @@ class ContactsTests: XCTestCase { XCTAssertFalse(result) - await contacts.allow(addresses: [fixtures.alice.address]) + try await contacts.allow(addresses: [fixtures.alice.address]) result = await contacts.isAllowed(fixtures.alice.address) XCTAssertTrue(result) @@ -76,7 +76,7 @@ class ContactsTests: XCTestCase { XCTAssertFalse(result) - await contacts.block(addresses: [fixtures.alice.address]) + try await contacts.block(addresses: [fixtures.alice.address]) result = await contacts.isBlocked(fixtures.alice.address) XCTAssertTrue(result) diff --git a/Tests/XMTPTests/ConversationTests.swift b/Tests/XMTPTests/ConversationTests.swift index 4f213547..6e56e966 100644 --- a/Tests/XMTPTests/ConversationTests.swift +++ b/Tests/XMTPTests/ConversationTests.swift @@ -619,7 +619,7 @@ class ConversationTests: XCTestCase { // Conversations started with you should start as unknown XCTAssertTrue(isUnknown) - await aliceClient.contacts.allow(addresses: [bob.address]) + try await aliceClient.contacts.allow(addresses: [bob.address]) let isBobAllowed = (await aliceConversation.allowState()) == .allowed XCTAssertTrue(isBobAllowed) @@ -627,8 +627,11 @@ class ConversationTests: XCTestCase { let aliceClient2 = try await Client.create(account: alice, apiClient: fakeApiClient) let aliceConversation2 = (try await aliceClient2.conversations.list())[0] + try await aliceClient2.contacts.refreshAllowList() + // Allow state should sync across clients let isBobAllowed2 = (await aliceConversation2.allowState()) == .allowed + XCTAssertTrue(isBobAllowed2) } } From fb6166ee6a894279e24901376226c5a8ae61daf2 Mon Sep 17 00:00:00 2001 From: Pat Nakajima Date: Fri, 13 Oct 2023 12:17:52 -0700 Subject: [PATCH 03/11] Derive topic identifier instead of using wallet address --- Package.resolved | 2 +- Sources/XMTP/Contacts.swift | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Package.resolved b/Package.resolved index 875d144a..ffdbb7f1 100644 --- a/Package.resolved +++ b/Package.resolved @@ -150,7 +150,7 @@ "location" : "https://github.com/xmtp/xmtp-rust-swift", "state" : { "branch" : "main", - "revision" : "d1aaac47fc7c57645a6fe9e06972b957b3efa33c" + "revision" : "e857176b7e368c51e1dadcbbcce648bb20432f26" } } ], diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index 8761281f..725a0a16 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -34,12 +34,15 @@ class AllowList { var entries: [String: AllowState] = [:] static func load(from client: Client) async throws -> AllowList { - let envelopes = try await client.query(topic: .allowList(client.address)) + let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes + let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes + + let identifier = try XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() + let envelopes = try await client.query(topic: .allowList(identifier)) let allowList = AllowList() for envelope in envelopes.envelopes { - let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes - let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes + let payload = try XMTPRust.ecies_decrypt_k256_sha3_256( RustVec(publicKey), @@ -60,6 +63,7 @@ class AllowList { let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes + let identifier = try XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() let message = try XMTPRust.ecies_encrypt_k256_sha3_256( RustVec(publicKey), @@ -68,7 +72,7 @@ class AllowList { ) let envelope = Envelope( - topic: Topic.allowList(client.address), + topic: Topic.allowList(identifier), timestamp: Date(), message: Data(message) ) From 0618b77272315890114db333c00858e394768dc9 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 23 Oct 2023 21:45:55 -0700 Subject: [PATCH 04/11] generate the latest proto code --- .../Proto/keystore_api/v1/keystore.pb.swift | 653 +++++++++++- .../XMTP/Proto/message_api/v1/authn.pb.swift | 2 +- .../Proto/message_api/v1/message_api.pb.swift | 2 +- .../XMTP/Proto/message_api/v3/mls.pb.swift | 978 ++++++++++++++++++ .../Proto/message_contents/content.pb.swift | 2 +- .../Proto/message_contents/ecies.pb.swift | 116 +++ .../message_contents/private_key.pb.swift | 2 +- .../private_preferences.pb.swift | 252 +++++ .../message_contents/public_key.pb.swift | 2 +- .../message_contents/signed_payload.pb.swift | 97 ++ .../mls/message_contents/message.pb.swift | 300 ++++++ .../v3/message_contents/association.pb.swift | 248 +++++ .../Proto/v3/message_contents/invite.pb.swift | 241 +++++ .../v3/message_contents/message.pb.swift | 370 +++++++ .../v3/message_contents/public_key.pb.swift | 658 ++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 4 +- 16 files changed, 3919 insertions(+), 8 deletions(-) create mode 100644 Sources/XMTP/Proto/message_api/v3/mls.pb.swift create mode 100644 Sources/XMTP/Proto/message_contents/ecies.pb.swift create mode 100644 Sources/XMTP/Proto/message_contents/private_preferences.pb.swift create mode 100644 Sources/XMTP/Proto/message_contents/signed_payload.pb.swift create mode 100644 Sources/XMTP/Proto/mls/message_contents/message.pb.swift create mode 100644 Sources/XMTP/Proto/v3/message_contents/association.pb.swift create mode 100644 Sources/XMTP/Proto/v3/message_contents/invite.pb.swift create mode 100644 Sources/XMTP/Proto/v3/message_contents/message.pb.swift create mode 100644 Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift diff --git a/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift b/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift index 586462ad..865874ae 100644 --- a/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift +++ b/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift @@ -58,7 +58,7 @@ public enum Xmtp_KeystoreApi_V1_ErrorCode: SwiftProtobuf.Enum { extension Xmtp_KeystoreApi_V1_ErrorCode: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Xmtp_KeystoreApi_V1_ErrorCode] = [ + public static let allCases: [Xmtp_KeystoreApi_V1_ErrorCode] = [ .unspecified, .invalidInput, .noMatchingPrekey, @@ -67,6 +67,51 @@ extension Xmtp_KeystoreApi_V1_ErrorCode: CaseIterable { #endif // swift(>=4.2) +/// JobType is used to specify the type of job the caller would like info on +public enum Xmtp_KeystoreApi_V1_JobType: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + case refreshV1 // = 1 + case refreshV2 // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .refreshV1 + case 2: self = .refreshV2 + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .refreshV1: return 1 + case .refreshV2: return 2 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension Xmtp_KeystoreApi_V1_JobType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Xmtp_KeystoreApi_V1_JobType] = [ + .unspecified, + .refreshV1, + .refreshV2, + ] +} + +#endif // swift(>=4.2) + /// Wrapper class for errors from the Keystore API public struct Xmtp_KeystoreApi_V1_KeystoreError { // SwiftProtobuf.Message conformance is added in an extension below. See the @@ -604,6 +649,178 @@ public struct Xmtp_KeystoreApi_V1_CreateAuthTokenRequest { fileprivate var _timestampNs: UInt64? = nil } +/// SaveV1ConversationsRequest is used to save a batch of conversations to the +/// built in persistence +public struct Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var conversations: [Xmtp_MessageContents_ConversationReference] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Placeholder response type for SaveV1Conversations +public struct Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Response for GetV2Conversations +public struct Xmtp_KeystoreApi_V1_GetConversationsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var conversations: [Xmtp_MessageContents_ConversationReference] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Used to check if the Keystore implementation has been setup for the given +/// wallet address Only used for MM Snap Keystore currently +public struct Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddress: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Response to GetKeystoreStatusRequest +public struct Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var status: Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Status of the Keystore for the specified wallet address + public enum KeystoreStatus: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + case uninitialized // = 1 + case initialized // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .uninitialized + case 2: self = .initialized + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .uninitialized: return 1 + case .initialized: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus] = [ + .unspecified, + .uninitialized, + .initialized, + ] +} + +#endif // swift(>=4.2) + +/// Used to initialize the Keystore with a private key bundle retrieved from the +/// client +public struct Xmtp_KeystoreApi_V1_InitKeystoreRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var bundle: Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle? = nil + + public var v1: Xmtp_MessageContents_PrivateKeyBundleV1 { + get { + if case .v1(let v)? = bundle {return v} + return Xmtp_MessageContents_PrivateKeyBundleV1() + } + set {bundle = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Bundle: Equatable { + case v1(Xmtp_MessageContents_PrivateKeyBundleV1) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle, rhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} +} + +/// Response to the request to initialize the Keystore +public struct Xmtp_KeystoreApi_V1_InitKeystoreResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var error: Xmtp_KeystoreApi_V1_KeystoreError { + get {return _error ?? Xmtp_KeystoreApi_V1_KeystoreError()} + set {_error = newValue} + } + /// Returns true if `error` has been explicitly set. + public var hasError: Bool {return self._error != nil} + /// Clears the value of `error`. Subsequent reads from it will return its default value. + public mutating func clearError() {self._error = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _error: Xmtp_KeystoreApi_V1_KeystoreError? = nil +} + /// SignDigestRequest is used to sign a digest with either the identity key /// or a prekey public struct Xmtp_KeystoreApi_V1_SignDigestRequest { @@ -660,6 +877,58 @@ public struct Xmtp_KeystoreApi_V1_SignDigestRequest { public init() {} } +/// GetRefreshJobRequest is used to get the last run time of a refresh job +public struct Xmtp_KeystoreApi_V1_GetRefreshJobRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var jobType: Xmtp_KeystoreApi_V1_JobType = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// GetRefreshJobResponse is used to return the last run time of a refresh job +public struct Xmtp_KeystoreApi_V1_GetRefreshJobResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var lastRunNs: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// SetRefreshJobRequest is used to set the last run time of a refresh job +public struct Xmtp_KeystoreApi_V1_SetRefeshJobRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var jobType: Xmtp_KeystoreApi_V1_JobType = .unspecified + + public var lastRunNs: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// SetRefreshJobResponse is an empty response type +public struct Xmtp_KeystoreApi_V1_SetRefreshJobResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + /// A mapping of topics to their decrypted invitations public struct Xmtp_KeystoreApi_V1_TopicMap { // SwiftProtobuf.Message conformance is added in an extension below. See the @@ -701,6 +970,7 @@ public struct Xmtp_KeystoreApi_V1_TopicMap { #if swift(>=5.5) && canImport(_Concurrency) extension Xmtp_KeystoreApi_V1_ErrorCode: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_JobType: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_KeystoreError: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_DecryptV1Request: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_DecryptV1Request.Request: @unchecked Sendable {} @@ -727,8 +997,21 @@ extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response: @unchecked Sendable extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.OneOf_Response: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_CreateAuthTokenRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetConversationsResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_InitKeystoreRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_InitKeystoreResponse: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_SignDigestRequest: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_SignDigestRequest.OneOf_Signer: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetRefreshJobRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetRefreshJobResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SetRefeshJobRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SetRefreshJobResponse: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_TopicMap: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_TopicMap.TopicData: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) @@ -745,6 +1028,14 @@ extension Xmtp_KeystoreApi_V1_ErrorCode: SwiftProtobuf._ProtoNameProviding { ] } +extension Xmtp_KeystoreApi_V1_JobType: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "JOB_TYPE_UNSPECIFIED"), + 1: .same(proto: "JOB_TYPE_REFRESH_V1"), + 2: .same(proto: "JOB_TYPE_REFRESH_V2"), + ] +} + extension Xmtp_KeystoreApi_V1_KeystoreError: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".KeystoreError" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -1717,6 +2008,245 @@ extension Xmtp_KeystoreApi_V1_CreateAuthTokenRequest: SwiftProtobuf.Message, Swi } } +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SaveV1ConversationsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "conversations"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.conversations) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.conversations.isEmpty { + try visitor.visitRepeatedMessageField(value: self.conversations, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest, rhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest) -> Bool { + if lhs.conversations != rhs.conversations {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SaveV1ConversationsResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse, rhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetConversationsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetConversationsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "conversations"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.conversations) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.conversations.isEmpty { + try visitor.visitRepeatedMessageField(value: self.conversations, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetConversationsResponse, rhs: Xmtp_KeystoreApi_V1_GetConversationsResponse) -> Bool { + if lhs.conversations != rhs.conversations {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetKeystoreStatusRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.walletAddress) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddress.isEmpty { + try visitor.visitSingularStringField(value: self.walletAddress, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest, rhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest) -> Bool { + if lhs.walletAddress != rhs.walletAddress {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetKeystoreStatusResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.status != .unspecified { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse, rhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "KEYSTORE_STATUS_UNSPECIFIED"), + 1: .same(proto: "KEYSTORE_STATUS_UNINITIALIZED"), + 2: .same(proto: "KEYSTORE_STATUS_INITIALIZED"), + ] +} + +extension Xmtp_KeystoreApi_V1_InitKeystoreRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InitKeystoreRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_MessageContents_PrivateKeyBundleV1? + var hadOneofValue = false + if let current = self.bundle { + hadOneofValue = true + if case .v1(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.bundle = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.bundle { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest, rhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest) -> Bool { + if lhs.bundle != rhs.bundle {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_InitKeystoreResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InitKeystoreResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "error"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._error) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._error { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_InitKeystoreResponse, rhs: Xmtp_KeystoreApi_V1_InitKeystoreResponse) -> Bool { + if lhs._error != rhs._error {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Xmtp_KeystoreApi_V1_SignDigestRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".SignDigestRequest" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -1783,6 +2313,127 @@ extension Xmtp_KeystoreApi_V1_SignDigestRequest: SwiftProtobuf.Message, SwiftPro } } +extension Xmtp_KeystoreApi_V1_GetRefreshJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetRefreshJobRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "job_type"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.jobType) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.jobType != .unspecified { + try visitor.visitSingularEnumField(value: self.jobType, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetRefreshJobRequest, rhs: Xmtp_KeystoreApi_V1_GetRefreshJobRequest) -> Bool { + if lhs.jobType != rhs.jobType {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetRefreshJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetRefreshJobResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "last_run_ns"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt64Field(value: &self.lastRunNs) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.lastRunNs != 0 { + try visitor.visitSingularInt64Field(value: self.lastRunNs, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetRefreshJobResponse, rhs: Xmtp_KeystoreApi_V1_GetRefreshJobResponse) -> Bool { + if lhs.lastRunNs != rhs.lastRunNs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_SetRefeshJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SetRefeshJobRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "job_type"), + 2: .standard(proto: "last_run_ns"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.jobType) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self.lastRunNs) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.jobType != .unspecified { + try visitor.visitSingularEnumField(value: self.jobType, fieldNumber: 1) + } + if self.lastRunNs != 0 { + try visitor.visitSingularInt64Field(value: self.lastRunNs, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SetRefeshJobRequest, rhs: Xmtp_KeystoreApi_V1_SetRefeshJobRequest) -> Bool { + if lhs.jobType != rhs.jobType {return false} + if lhs.lastRunNs != rhs.lastRunNs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_SetRefreshJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SetRefreshJobResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SetRefreshJobResponse, rhs: Xmtp_KeystoreApi_V1_SetRefreshJobResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Xmtp_KeystoreApi_V1_TopicMap: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".TopicMap" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/Sources/XMTP/Proto/message_api/v1/authn.pb.swift b/Sources/XMTP/Proto/message_api/v1/authn.pb.swift index 22361f7c..238944c2 100644 --- a/Sources/XMTP/Proto/message_api/v1/authn.pb.swift +++ b/Sources/XMTP/Proto/message_api/v1/authn.pb.swift @@ -73,7 +73,7 @@ public struct Xmtp_MessageApi_V1_AuthData { /// address of the wallet public var walletAddr: String = String() - /// time when the token was generated/signed + /// time when the token was generated/signed public var createdNs: UInt64 = 0 public var unknownFields = SwiftProtobuf.UnknownStorage() diff --git a/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift b/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift index 03ae0a3a..c3ac86e3 100644 --- a/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift +++ b/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift @@ -58,7 +58,7 @@ public enum Xmtp_MessageApi_V1_SortDirection: SwiftProtobuf.Enum { extension Xmtp_MessageApi_V1_SortDirection: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Xmtp_MessageApi_V1_SortDirection] = [ + public static let allCases: [Xmtp_MessageApi_V1_SortDirection] = [ .unspecified, .ascending, .descending, diff --git a/Sources/XMTP/Proto/message_api/v3/mls.pb.swift b/Sources/XMTP/Proto/message_api/v3/mls.pb.swift new file mode 100644 index 00000000..5b295e2b --- /dev/null +++ b/Sources/XMTP/Proto/message_api/v3/mls.pb.swift @@ -0,0 +1,978 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_api/v3/mls.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Message API + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Publish a batch of MLS messages +public struct Xmtp_MessageApi_V3_PublishToGroupRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var messages: [Xmtp_Mls_MessageContents_GroupMessage] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Publish a batch of welcome messages +public struct Xmtp_MessageApi_V3_PublishWelcomesRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var welcomeMessages: [Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// An individual welcome message + public struct WelcomeMessageRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The topic will be derived from this + public var installationID: String = String() + + public var welcomeMessage: Xmtp_Mls_MessageContents_WelcomeMessage { + get {return _welcomeMessage ?? Xmtp_Mls_MessageContents_WelcomeMessage()} + set {_welcomeMessage = newValue} + } + /// Returns true if `welcomeMessage` has been explicitly set. + public var hasWelcomeMessage: Bool {return self._welcomeMessage != nil} + /// Clears the value of `welcomeMessage`. Subsequent reads from it will return its default value. + public mutating func clearWelcomeMessage() {self._welcomeMessage = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _welcomeMessage: Xmtp_Mls_MessageContents_WelcomeMessage? = nil + } + + public init() {} +} + +/// Register a new installation +public struct Xmtp_MessageApi_V3_RegisterInstallationRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var credentialBytes: Data = Data() + + public var signingKeyPublic: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Xmtp_MessageApi_V3_RegisterInstallationResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var installationID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Upload one or more key packages +public struct Xmtp_MessageApi_V3_UploadKeyPackagesRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var keyPackages: [Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// An individual key package upload request + public struct KeyPackageUpload { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The owner's wallet address would be extracted from the identity + /// credential in the key package, and all signatures would be validated. + public var keyPackageTlsSerialized: Data = Data() + + /// The node will always treat the most recent last-resort key package as + /// the active one, and will ignore all others. + public var isLastResort: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +/// Consume one or more key packages, removing them from further use +public struct Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The caller can provide an array of wallet addresses, and the API + /// will return one key package for each installation associated with each + /// wallet address + public var installationIds: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// The response to a ConsumeKeyPackagesRequest +public struct Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Returns one key package per installation in the original order of the + /// request. If any installations are missing key packages, + public var keyPackages: [Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// An individual key package + public struct KeyPackage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var keyPackageTlsSerialized: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +/// Revoke an installation +public struct Xmtp_MessageApi_V3_RevokeInstallationRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var installationID: String = String() + + /// All revocations must be validated with a wallet signature over the + /// installation_id being revoked (and some sort of standard prologue) + public var walletSignature: Xmtp_MessageContents_Signature { + get {return _walletSignature ?? Xmtp_MessageContents_Signature()} + set {_walletSignature = newValue} + } + /// Returns true if `walletSignature` has been explicitly set. + public var hasWalletSignature: Bool {return self._walletSignature != nil} + /// Clears the value of `walletSignature`. Subsequent reads from it will return its default value. + public mutating func clearWalletSignature() {self._walletSignature = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _walletSignature: Xmtp_MessageContents_Signature? = nil +} + +/// Get all updates for an identity since the specified time +public struct Xmtp_MessageApi_V3_GetIdentityUpdatesRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddresses: [String] = [] + + public var startTimeNs: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Used to get any new or revoked installations for a list of wallet addresses +public struct Xmtp_MessageApi_V3_GetIdentityUpdatesResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of updates (or empty objects if no changes) in the original order + /// of the request + public var updates: [Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// A new installation ID was seen for the first time by the nodes + public struct NewInstallationUpdate { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var installationID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + /// An installation was revoked + public struct RevokedInstallationUpdate { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var installationID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + /// A wrapper for any update to the wallet + public struct Update { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var timestampNs: UInt64 = 0 + + public var kind: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind? = nil + + public var newInstallation: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate { + get { + if case .newInstallation(let v)? = kind {return v} + return Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate() + } + set {kind = .newInstallation(newValue)} + } + + public var revokedInstallation: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate { + get { + if case .revokedInstallation(let v)? = kind {return v} + return Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate() + } + set {kind = .revokedInstallation(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Kind: Equatable { + case newInstallation(Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate) + case revokedInstallation(Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.newInstallation, .newInstallation): return { + guard case .newInstallation(let l) = lhs, case .newInstallation(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.revokedInstallation, .revokedInstallation): return { + guard case .revokedInstallation(let l) = lhs, case .revokedInstallation(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + public init() {} + } + + /// A wrapper for the updates for a single wallet + public struct WalletUpdates { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var updates: [Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageApi_V3_PublishToGroupRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_PublishWelcomesRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_RegisterInstallationRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_RegisterInstallationResponse: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_RevokeInstallationRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesRequest: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind: @unchecked Sendable {} +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_api.v3" + +extension Xmtp_MessageApi_V3_PublishToGroupRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PublishToGroupRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "messages"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.messages) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.messages.isEmpty { + try visitor.visitRepeatedMessageField(value: self.messages, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_PublishToGroupRequest, rhs: Xmtp_MessageApi_V3_PublishToGroupRequest) -> Bool { + if lhs.messages != rhs.messages {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_PublishWelcomesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PublishWelcomesRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "welcome_messages"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.welcomeMessages) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.welcomeMessages.isEmpty { + try visitor.visitRepeatedMessageField(value: self.welcomeMessages, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_PublishWelcomesRequest, rhs: Xmtp_MessageApi_V3_PublishWelcomesRequest) -> Bool { + if lhs.welcomeMessages != rhs.welcomeMessages {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_PublishWelcomesRequest.protoMessageName + ".WelcomeMessageRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "installation_id"), + 2: .standard(proto: "welcome_message"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._welcomeMessage) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.installationID.isEmpty { + try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) + } + try { if let v = self._welcomeMessage { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest, rhs: Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest) -> Bool { + if lhs.installationID != rhs.installationID {return false} + if lhs._welcomeMessage != rhs._welcomeMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_RegisterInstallationRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RegisterInstallationRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "credential_bytes"), + 2: .standard(proto: "signing_key_public"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.credentialBytes) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.signingKeyPublic) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.credentialBytes.isEmpty { + try visitor.visitSingularBytesField(value: self.credentialBytes, fieldNumber: 1) + } + if !self.signingKeyPublic.isEmpty { + try visitor.visitSingularBytesField(value: self.signingKeyPublic, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_RegisterInstallationRequest, rhs: Xmtp_MessageApi_V3_RegisterInstallationRequest) -> Bool { + if lhs.credentialBytes != rhs.credentialBytes {return false} + if lhs.signingKeyPublic != rhs.signingKeyPublic {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_RegisterInstallationResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RegisterInstallationResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "installation_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.installationID.isEmpty { + try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_RegisterInstallationResponse, rhs: Xmtp_MessageApi_V3_RegisterInstallationResponse) -> Bool { + if lhs.installationID != rhs.installationID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UploadKeyPackagesRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "key_packages"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.keyPackages) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.keyPackages.isEmpty { + try visitor.visitRepeatedMessageField(value: self.keyPackages, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest, rhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest) -> Bool { + if lhs.keyPackages != rhs.keyPackages {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_UploadKeyPackagesRequest.protoMessageName + ".KeyPackageUpload" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "key_package_tls_serialized"), + 2: .standard(proto: "is_last_resort"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.keyPackageTlsSerialized) }() + case 2: try { try decoder.decodeSingularBoolField(value: &self.isLastResort) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.keyPackageTlsSerialized.isEmpty { + try visitor.visitSingularBytesField(value: self.keyPackageTlsSerialized, fieldNumber: 1) + } + if self.isLastResort != false { + try visitor.visitSingularBoolField(value: self.isLastResort, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload, rhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload) -> Bool { + if lhs.keyPackageTlsSerialized != rhs.keyPackageTlsSerialized {return false} + if lhs.isLastResort != rhs.isLastResort {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ConsumeKeyPackagesRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "installation_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.installationIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.installationIds.isEmpty { + try visitor.visitRepeatedStringField(value: self.installationIds, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest, rhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest) -> Bool { + if lhs.installationIds != rhs.installationIds {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ConsumeKeyPackagesResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "key_packages"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.keyPackages) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.keyPackages.isEmpty { + try visitor.visitRepeatedMessageField(value: self.keyPackages, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse, rhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse) -> Bool { + if lhs.keyPackages != rhs.keyPackages {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.protoMessageName + ".KeyPackage" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "key_package_tls_serialized"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.keyPackageTlsSerialized) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.keyPackageTlsSerialized.isEmpty { + try visitor.visitSingularBytesField(value: self.keyPackageTlsSerialized, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage, rhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage) -> Bool { + if lhs.keyPackageTlsSerialized != rhs.keyPackageTlsSerialized {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_RevokeInstallationRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RevokeInstallationRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "installation_id"), + 2: .standard(proto: "wallet_signature"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._walletSignature) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.installationID.isEmpty { + try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) + } + try { if let v = self._walletSignature { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_RevokeInstallationRequest, rhs: Xmtp_MessageApi_V3_RevokeInstallationRequest) -> Bool { + if lhs.installationID != rhs.installationID {return false} + if lhs._walletSignature != rhs._walletSignature {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_GetIdentityUpdatesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetIdentityUpdatesRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_addresses"), + 2: .standard(proto: "start_time_ns"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.walletAddresses) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.startTimeNs) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddresses.isEmpty { + try visitor.visitRepeatedStringField(value: self.walletAddresses, fieldNumber: 1) + } + if self.startTimeNs != 0 { + try visitor.visitSingularUInt64Field(value: self.startTimeNs, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesRequest, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesRequest) -> Bool { + if lhs.walletAddresses != rhs.walletAddresses {return false} + if lhs.startTimeNs != rhs.startTimeNs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetIdentityUpdatesResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "updates"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.updates) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.updates.isEmpty { + try visitor.visitRepeatedMessageField(value: self.updates, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse) -> Bool { + if lhs.updates != rhs.updates {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".NewInstallationUpdate" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "installation_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.installationID.isEmpty { + try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate) -> Bool { + if lhs.installationID != rhs.installationID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".RevokedInstallationUpdate" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "installation_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.installationID.isEmpty { + try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate) -> Bool { + if lhs.installationID != rhs.installationID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".Update" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "timestamp_ns"), + 2: .standard(proto: "new_installation"), + 3: .standard(proto: "revoked_installation"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.timestampNs) }() + case 2: try { + var v: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate? + var hadOneofValue = false + if let current = self.kind { + hadOneofValue = true + if case .newInstallation(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.kind = .newInstallation(v) + } + }() + case 3: try { + var v: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate? + var hadOneofValue = false + if let current = self.kind { + hadOneofValue = true + if case .revokedInstallation(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.kind = .revokedInstallation(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.timestampNs != 0 { + try visitor.visitSingularUInt64Field(value: self.timestampNs, fieldNumber: 1) + } + switch self.kind { + case .newInstallation?: try { + guard case .newInstallation(let v)? = self.kind else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + }() + case .revokedInstallation?: try { + guard case .revokedInstallation(let v)? = self.kind else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update) -> Bool { + if lhs.timestampNs != rhs.timestampNs {return false} + if lhs.kind != rhs.kind {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".WalletUpdates" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "updates"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.updates) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.updates.isEmpty { + try visitor.visitRepeatedMessageField(value: self.updates, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates) -> Bool { + if lhs.updates != rhs.updates {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/message_contents/content.pb.swift b/Sources/XMTP/Proto/message_contents/content.pb.swift index cf73da0d..6f588dd0 100644 --- a/Sources/XMTP/Proto/message_contents/content.pb.swift +++ b/Sources/XMTP/Proto/message_contents/content.pb.swift @@ -56,7 +56,7 @@ public enum Xmtp_MessageContents_Compression: SwiftProtobuf.Enum { extension Xmtp_MessageContents_Compression: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Xmtp_MessageContents_Compression] = [ + public static let allCases: [Xmtp_MessageContents_Compression] = [ .deflate, .gzip, ] diff --git a/Sources/XMTP/Proto/message_contents/ecies.pb.swift b/Sources/XMTP/Proto/message_contents/ecies.pb.swift new file mode 100644 index 00000000..21f3b6f1 --- /dev/null +++ b/Sources/XMTP/Proto/message_contents/ecies.pb.swift @@ -0,0 +1,116 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_contents/ecies.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// ECIES is a wrapper for ECIES payloads + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// EciesMessage is a wrapper for ECIES encrypted payloads +public struct Xmtp_MessageContents_EciesMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var version: Xmtp_MessageContents_EciesMessage.OneOf_Version? = nil + + /// Expected to be an ECIES encrypted SignedPayload + public var v1: Data { + get { + if case .v1(let v)? = version {return v} + return Data() + } + set {version = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Version: Equatable { + /// Expected to be an ECIES encrypted SignedPayload + case v1(Data) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_MessageContents_EciesMessage.OneOf_Version, rhs: Xmtp_MessageContents_EciesMessage.OneOf_Version) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageContents_EciesMessage: @unchecked Sendable {} +extension Xmtp_MessageContents_EciesMessage.OneOf_Version: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_contents" + +extension Xmtp_MessageContents_EciesMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".EciesMessage" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Data? + try decoder.decodeSingularBytesField(value: &v) + if let v = v { + if self.version != nil {try decoder.handleConflictingOneOf()} + self.version = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.version { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_EciesMessage, rhs: Xmtp_MessageContents_EciesMessage) -> Bool { + if lhs.version != rhs.version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/message_contents/private_key.pb.swift b/Sources/XMTP/Proto/message_contents/private_key.pb.swift index 4e916b5e..2015222a 100644 --- a/Sources/XMTP/Proto/message_contents/private_key.pb.swift +++ b/Sources/XMTP/Proto/message_contents/private_key.pb.swift @@ -279,7 +279,7 @@ public struct Xmtp_MessageContents_EncryptedPrivateKeyBundleV1 { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// randomly generated pre-key + /// randomly generated pre-key public var walletPreKey: Data = Data() /// MUST contain encrypted PrivateKeyBundle diff --git a/Sources/XMTP/Proto/message_contents/private_preferences.pb.swift b/Sources/XMTP/Proto/message_contents/private_preferences.pb.swift new file mode 100644 index 00000000..0e969de9 --- /dev/null +++ b/Sources/XMTP/Proto/message_contents/private_preferences.pb.swift @@ -0,0 +1,252 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_contents/private_preferences.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Private Key Storage +/// +/// Following definitions are not used in the protocol, instead +/// they provide a way for encoding private keys for storage. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// PrivatePreferencesAction is a message used to update the client's +/// preference store. The only current actions are allow and block. +/// Other actions may be added later +public struct Xmtp_MessageContents_PrivatePreferencesAction { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var messageType: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType? = nil + + public var allow: Xmtp_MessageContents_PrivatePreferencesAction.Allow { + get { + if case .allow(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.Allow() + } + set {messageType = .allow(newValue)} + } + + public var block: Xmtp_MessageContents_PrivatePreferencesAction.Block { + get { + if case .block(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.Block() + } + set {messageType = .block(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_MessageType: Equatable { + case allow(Xmtp_MessageContents_PrivatePreferencesAction.Allow) + case block(Xmtp_MessageContents_PrivatePreferencesAction.Block) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType, rhs: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.allow, .allow): return { + guard case .allow(let l) = lhs, case .allow(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.block, .block): return { + guard case .block(let l) = lhs, case .block(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + /// Add the given wallet addresses to the allow list + public struct Allow { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddresses: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + /// Add the given wallet addresses to the block list + public struct Block { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddresses: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageContents_PrivatePreferencesAction: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.Block: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_contents" + +extension Xmtp_MessageContents_PrivatePreferencesAction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PrivatePreferencesAction" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "allow"), + 2: .same(proto: "block"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_MessageContents_PrivatePreferencesAction.Allow? + var hadOneofValue = false + if let current = self.messageType { + hadOneofValue = true + if case .allow(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.messageType = .allow(v) + } + }() + case 2: try { + var v: Xmtp_MessageContents_PrivatePreferencesAction.Block? + var hadOneofValue = false + if let current = self.messageType { + hadOneofValue = true + if case .block(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.messageType = .block(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + switch self.messageType { + case .allow?: try { + guard case .allow(let v)? = self.messageType else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + }() + case .block?: try { + guard case .block(let v)? = self.messageType else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction, rhs: Xmtp_MessageContents_PrivatePreferencesAction) -> Bool { + if lhs.messageType != rhs.messageType {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".Allow" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_addresses"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.walletAddresses) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddresses.isEmpty { + try visitor.visitRepeatedStringField(value: self.walletAddresses, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.Allow, rhs: Xmtp_MessageContents_PrivatePreferencesAction.Allow) -> Bool { + if lhs.walletAddresses != rhs.walletAddresses {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageContents_PrivatePreferencesAction.Block: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".Block" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_addresses"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.walletAddresses) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddresses.isEmpty { + try visitor.visitRepeatedStringField(value: self.walletAddresses, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.Block, rhs: Xmtp_MessageContents_PrivatePreferencesAction.Block) -> Bool { + if lhs.walletAddresses != rhs.walletAddresses {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/message_contents/public_key.pb.swift b/Sources/XMTP/Proto/message_contents/public_key.pb.swift index a1accdaf..534e9075 100644 --- a/Sources/XMTP/Proto/message_contents/public_key.pb.swift +++ b/Sources/XMTP/Proto/message_contents/public_key.pb.swift @@ -79,7 +79,7 @@ public struct Xmtp_MessageContents_UnsignedPublicKey { public init() {} } -/// SignedPublicKey +/// SignedPublicKey public struct Xmtp_MessageContents_SignedPublicKey { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for diff --git a/Sources/XMTP/Proto/message_contents/signed_payload.pb.swift b/Sources/XMTP/Proto/message_contents/signed_payload.pb.swift new file mode 100644 index 00000000..3d8550cf --- /dev/null +++ b/Sources/XMTP/Proto/message_contents/signed_payload.pb.swift @@ -0,0 +1,97 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_contents/signed_payload.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Signature is a generic structure for signed byte arrays + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// SignedPayload is a wrapper for a signature and a payload +public struct Xmtp_MessageContents_SignedPayload { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var payload: Data = Data() + + public var signature: Xmtp_MessageContents_Signature { + get {return _signature ?? Xmtp_MessageContents_Signature()} + set {_signature = newValue} + } + /// Returns true if `signature` has been explicitly set. + public var hasSignature: Bool {return self._signature != nil} + /// Clears the value of `signature`. Subsequent reads from it will return its default value. + public mutating func clearSignature() {self._signature = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _signature: Xmtp_MessageContents_Signature? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageContents_SignedPayload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_contents" + +extension Xmtp_MessageContents_SignedPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SignedPayload" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "payload"), + 2: .same(proto: "signature"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.payload) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._signature) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.payload.isEmpty { + try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 1) + } + try { if let v = self._signature { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_SignedPayload, rhs: Xmtp_MessageContents_SignedPayload) -> Bool { + if lhs.payload != rhs.payload {return false} + if lhs._signature != rhs._signature {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/mls/message_contents/message.pb.swift b/Sources/XMTP/Proto/mls/message_contents/message.pb.swift new file mode 100644 index 00000000..ed157698 --- /dev/null +++ b/Sources/XMTP/Proto/mls/message_contents/message.pb.swift @@ -0,0 +1,300 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: mls/message_contents/message.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// V3 invite message structure + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Wrapper for a MLS welcome message +public struct Xmtp_Mls_MessageContents_WelcomeMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var version: Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version? = nil + + public var v1: Xmtp_Mls_MessageContents_WelcomeMessage.V1 { + get { + if case .v1(let v)? = version {return v} + return Xmtp_Mls_MessageContents_WelcomeMessage.V1() + } + set {version = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Version: Equatable { + case v1(Xmtp_Mls_MessageContents_WelcomeMessage.V1) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version, rhs: Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + /// Version 1 of the WelcomeMessage format + public struct V1 { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var welcomeMessageTlsSerialized: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +/// GroupMessage wraps any MLS message sent to a group topic +public struct Xmtp_Mls_MessageContents_GroupMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var version: Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version? = nil + + public var v1: Xmtp_Mls_MessageContents_GroupMessage.V1 { + get { + if case .v1(let v)? = version {return v} + return Xmtp_Mls_MessageContents_GroupMessage.V1() + } + set {version = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Version: Equatable { + case v1(Xmtp_Mls_MessageContents_GroupMessage.V1) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version, rhs: Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + /// Version 1 of the GroupMessage format + public struct V1 { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var mlsMessageTlsSerialized: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_Mls_MessageContents_WelcomeMessage: @unchecked Sendable {} +extension Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version: @unchecked Sendable {} +extension Xmtp_Mls_MessageContents_WelcomeMessage.V1: @unchecked Sendable {} +extension Xmtp_Mls_MessageContents_GroupMessage: @unchecked Sendable {} +extension Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version: @unchecked Sendable {} +extension Xmtp_Mls_MessageContents_GroupMessage.V1: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.mls.message_contents" + +extension Xmtp_Mls_MessageContents_WelcomeMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WelcomeMessage" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_Mls_MessageContents_WelcomeMessage.V1? + var hadOneofValue = false + if let current = self.version { + hadOneofValue = true + if case .v1(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.version = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.version { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_Mls_MessageContents_WelcomeMessage, rhs: Xmtp_Mls_MessageContents_WelcomeMessage) -> Bool { + if lhs.version != rhs.version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_Mls_MessageContents_WelcomeMessage.V1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_Mls_MessageContents_WelcomeMessage.protoMessageName + ".V1" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "welcome_message_tls_serialized"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.welcomeMessageTlsSerialized) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.welcomeMessageTlsSerialized.isEmpty { + try visitor.visitSingularBytesField(value: self.welcomeMessageTlsSerialized, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_Mls_MessageContents_WelcomeMessage.V1, rhs: Xmtp_Mls_MessageContents_WelcomeMessage.V1) -> Bool { + if lhs.welcomeMessageTlsSerialized != rhs.welcomeMessageTlsSerialized {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_Mls_MessageContents_GroupMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GroupMessage" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_Mls_MessageContents_GroupMessage.V1? + var hadOneofValue = false + if let current = self.version { + hadOneofValue = true + if case .v1(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.version = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.version { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_Mls_MessageContents_GroupMessage, rhs: Xmtp_Mls_MessageContents_GroupMessage) -> Bool { + if lhs.version != rhs.version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_Mls_MessageContents_GroupMessage.V1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_Mls_MessageContents_GroupMessage.protoMessageName + ".V1" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "mls_message_tls_serialized"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.mlsMessageTlsSerialized) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.mlsMessageTlsSerialized.isEmpty { + try visitor.visitSingularBytesField(value: self.mlsMessageTlsSerialized, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_Mls_MessageContents_GroupMessage.V1, rhs: Xmtp_Mls_MessageContents_GroupMessage.V1) -> Bool { + if lhs.mlsMessageTlsSerialized != rhs.mlsMessageTlsSerialized {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/v3/message_contents/association.pb.swift b/Sources/XMTP/Proto/v3/message_contents/association.pb.swift new file mode 100644 index 00000000..3d2f91f5 --- /dev/null +++ b/Sources/XMTP/Proto/v3/message_contents/association.pb.swift @@ -0,0 +1,248 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: v3/message_contents/association.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Association types + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Allows for us to update the format of the association text without +/// incrementing the entire proto +public enum Xmtp_V3_MessageContents_AssociationTextVersion: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + case associationTextVersion1 // = 1 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .associationTextVersion1 + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .associationTextVersion1: return 1 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension Xmtp_V3_MessageContents_AssociationTextVersion: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Xmtp_V3_MessageContents_AssociationTextVersion] = [ + .unspecified, + .associationTextVersion1, + ] +} + +#endif // swift(>=4.2) + +/// EIP191Association is used for all EIP 191 compliant wallet signatures +public struct Xmtp_V3_MessageContents_Eip191Association { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var associationTextVersion: Xmtp_V3_MessageContents_AssociationTextVersion = .unspecified + + public var signature: Xmtp_V3_MessageContents_RecoverableEcdsaSignature { + get {return _signature ?? Xmtp_V3_MessageContents_RecoverableEcdsaSignature()} + set {_signature = newValue} + } + /// Returns true if `signature` has been explicitly set. + public var hasSignature: Bool {return self._signature != nil} + /// Clears the value of `signature`. Subsequent reads from it will return its default value. + public mutating func clearSignature() {self._signature = nil} + + public var walletAddress: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _signature: Xmtp_V3_MessageContents_RecoverableEcdsaSignature? = nil +} + +/// RecoverableEcdsaSignature +public struct Xmtp_V3_MessageContents_RecoverableEcdsaSignature { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Includes recovery id as the last byte + public var bytes: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// EdDSA signature bytes matching RFC 8032 +public struct Xmtp_V3_MessageContents_EdDsaSignature { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var bytes: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_V3_MessageContents_AssociationTextVersion: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_Eip191Association: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_RecoverableEcdsaSignature: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_EdDsaSignature: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.v3.message_contents" + +extension Xmtp_V3_MessageContents_AssociationTextVersion: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "ASSOCIATION_TEXT_VERSION_UNSPECIFIED"), + 1: .same(proto: "ASSOCIATION_TEXT_VERSION_1"), + ] +} + +extension Xmtp_V3_MessageContents_Eip191Association: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Eip191Association" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "association_text_version"), + 2: .same(proto: "signature"), + 3: .standard(proto: "wallet_address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.associationTextVersion) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._signature) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.walletAddress) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.associationTextVersion != .unspecified { + try visitor.visitSingularEnumField(value: self.associationTextVersion, fieldNumber: 1) + } + try { if let v = self._signature { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.walletAddress.isEmpty { + try visitor.visitSingularStringField(value: self.walletAddress, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_Eip191Association, rhs: Xmtp_V3_MessageContents_Eip191Association) -> Bool { + if lhs.associationTextVersion != rhs.associationTextVersion {return false} + if lhs._signature != rhs._signature {return false} + if lhs.walletAddress != rhs.walletAddress {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_RecoverableEcdsaSignature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RecoverableEcdsaSignature" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "bytes"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.bytes.isEmpty { + try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_RecoverableEcdsaSignature, rhs: Xmtp_V3_MessageContents_RecoverableEcdsaSignature) -> Bool { + if lhs.bytes != rhs.bytes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_EdDsaSignature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".EdDsaSignature" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "bytes"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.bytes.isEmpty { + try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_EdDsaSignature, rhs: Xmtp_V3_MessageContents_EdDsaSignature) -> Bool { + if lhs.bytes != rhs.bytes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/v3/message_contents/invite.pb.swift b/Sources/XMTP/Proto/v3/message_contents/invite.pb.swift new file mode 100644 index 00000000..f5aebb4b --- /dev/null +++ b/Sources/XMTP/Proto/v3/message_contents/invite.pb.swift @@ -0,0 +1,241 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: v3/message_contents/invite.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// V3 invite message structure + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// InvitationV1 is the invitation message meant to be encrypted as +/// ciphertext in InvitationEnvelopeV1 and decrypted by the recipient using the +/// provided inviter `InstallationContactBundle` +public struct Xmtp_V3_MessageContents_InvitationV1 { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// If the inviter contact bundle has the same wallet address as the current + /// user, the invitee is the other wallet address in the conversation. If the + /// inviter contact bundle has a different wallet address, the invitee wallet + /// address MUST be the wallet address of the recipient of the invite. + public var inviteeWalletAddress: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// InvitationEnvelopeV1 is the encrypted invitation message and the contact of +/// the sender +public struct Xmtp_V3_MessageContents_InvitationEnvelopeV1 { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// This contains the public key that will be used to decrypt the ciphertext + public var inviter: Xmtp_V3_MessageContents_InstallationContactBundle { + get {return _inviter ?? Xmtp_V3_MessageContents_InstallationContactBundle()} + set {_inviter = newValue} + } + /// Returns true if `inviter` has been explicitly set. + public var hasInviter: Bool {return self._inviter != nil} + /// Clears the value of `inviter`. Subsequent reads from it will return its default value. + public mutating func clearInviter() {self._inviter = nil} + + /// Corresponds to an InvitationV1 message + public var ciphertext: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _inviter: Xmtp_V3_MessageContents_InstallationContactBundle? = nil +} + +/// Wrapper message type +public struct Xmtp_V3_MessageContents_InvitationEnvelope { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var version: Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version? = nil + + public var v1: Xmtp_V3_MessageContents_InvitationEnvelopeV1 { + get { + if case .v1(let v)? = version {return v} + return Xmtp_V3_MessageContents_InvitationEnvelopeV1() + } + set {version = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Version: Equatable { + case v1(Xmtp_V3_MessageContents_InvitationEnvelopeV1) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version, rhs: Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_V3_MessageContents_InvitationV1: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_InvitationEnvelopeV1: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_InvitationEnvelope: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.v3.message_contents" + +extension Xmtp_V3_MessageContents_InvitationV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InvitationV1" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "invitee_wallet_address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.inviteeWalletAddress) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.inviteeWalletAddress.isEmpty { + try visitor.visitSingularStringField(value: self.inviteeWalletAddress, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_InvitationV1, rhs: Xmtp_V3_MessageContents_InvitationV1) -> Bool { + if lhs.inviteeWalletAddress != rhs.inviteeWalletAddress {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_InvitationEnvelopeV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InvitationEnvelopeV1" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "inviter"), + 2: .same(proto: "ciphertext"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._inviter) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.ciphertext) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._inviter { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.ciphertext.isEmpty { + try visitor.visitSingularBytesField(value: self.ciphertext, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_InvitationEnvelopeV1, rhs: Xmtp_V3_MessageContents_InvitationEnvelopeV1) -> Bool { + if lhs._inviter != rhs._inviter {return false} + if lhs.ciphertext != rhs.ciphertext {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_InvitationEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InvitationEnvelope" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_V3_MessageContents_InvitationEnvelopeV1? + var hadOneofValue = false + if let current = self.version { + hadOneofValue = true + if case .v1(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.version = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.version { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_InvitationEnvelope, rhs: Xmtp_V3_MessageContents_InvitationEnvelope) -> Bool { + if lhs.version != rhs.version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/v3/message_contents/message.pb.swift b/Sources/XMTP/Proto/v3/message_contents/message.pb.swift new file mode 100644 index 00000000..2496b1c7 --- /dev/null +++ b/Sources/XMTP/Proto/v3/message_contents/message.pb.swift @@ -0,0 +1,370 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: v3/message_contents/message.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Structure for messages in v3 + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// The version used for the decrypted padlock message payload +public enum Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + case one // = 1 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .one + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .one: return 1 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Xmtp_V3_MessageContents_PadlockMessagePayloadVersion] = [ + .unspecified, + .one, + ] +} + +#endif // swift(>=4.2) + +/// Metadata that is encrypted via SealedSender and only visible to the recipient +/// Currently we do not actually encrypt this, actual implementation of +/// SealedSender will be added shortly. +public struct Xmtp_V3_MessageContents_PadlockMessageSealedMetadata { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var senderUserAddress: String = String() + + public var senderInstallationID: String = String() + + public var recipientUserAddress: String = String() + + public var recipientInstallationID: String = String() + + public var isPrekeyMessage: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Plaintext header included with messages, visible to all +/// Recipients can verify this header has not been tampered with. +/// Servers are unable to verify if the header has been tampered with. +public struct Xmtp_V3_MessageContents_PadlockMessageHeader { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var sentNs: UInt64 = 0 + + /// PadlockMessageSealedMetadata + public var sealedMetadata: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Encrypted body included with messages, only visible to recipients +/// When receiving a message: +/// 1. Decrypt the sealed metadata in the header via SealedSender +/// 2. Verify that you match the recipient_user_address and +/// recipient_installation_id. Verify that the sender_installation_id matches +/// the sender_user_address. +/// 2. Find the relevant session using the sender_user_address and +/// sender_installation_id in the unsealed metadata +/// 3. Use the session to decrypt the payload +/// 4. Verify that the header_signature in the decrypted payload was produced by +/// signing the header_bytes with the ed25519 key matching the +/// sender_installation_id +/// 5. Verify that both the sender_user and recipient_user are partipants of the +/// conversation referenced by convo_id +public struct Xmtp_V3_MessageContents_PadlockMessagePayload { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var messageVersion: Xmtp_V3_MessageContents_PadlockMessagePayloadVersion = .unspecified + + /// Signs PadlockMessageHeader + public var headerSignature: Xmtp_V3_MessageContents_EdDsaSignature { + get {return _headerSignature ?? Xmtp_V3_MessageContents_EdDsaSignature()} + set {_headerSignature = newValue} + } + /// Returns true if `headerSignature` has been explicitly set. + public var hasHeaderSignature: Bool {return self._headerSignature != nil} + /// Clears the value of `headerSignature`. Subsequent reads from it will return its default value. + public mutating func clearHeaderSignature() {self._headerSignature = nil} + + public var convoID: String = String() + + /// EncodedContent + public var contentBytes: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _headerSignature: Xmtp_V3_MessageContents_EdDsaSignature? = nil +} + +/// Combines the plaintext header with the encrypted payload +public struct Xmtp_V3_MessageContents_PadlockMessageEnvelope { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// PadlockMessageHeader + public var headerBytes: Data = Data() + + /// Encrypted PadlockMessagePayload + public var ciphertext: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_PadlockMessageSealedMetadata: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_PadlockMessageHeader: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_PadlockMessagePayload: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_PadlockMessageEnvelope: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.v3.message_contents" + +extension Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "PADLOCK_MESSAGE_PAYLOAD_VERSION_UNSPECIFIED"), + 1: .same(proto: "PADLOCK_MESSAGE_PAYLOAD_VERSION_ONE"), + ] +} + +extension Xmtp_V3_MessageContents_PadlockMessageSealedMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PadlockMessageSealedMetadata" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "sender_user_address"), + 2: .standard(proto: "sender_installation_id"), + 3: .standard(proto: "recipient_user_address"), + 4: .standard(proto: "recipient_installation_id"), + 5: .standard(proto: "is_prekey_message"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.senderUserAddress) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.senderInstallationID) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.recipientUserAddress) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.recipientInstallationID) }() + case 5: try { try decoder.decodeSingularBoolField(value: &self.isPrekeyMessage) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.senderUserAddress.isEmpty { + try visitor.visitSingularStringField(value: self.senderUserAddress, fieldNumber: 1) + } + if !self.senderInstallationID.isEmpty { + try visitor.visitSingularStringField(value: self.senderInstallationID, fieldNumber: 2) + } + if !self.recipientUserAddress.isEmpty { + try visitor.visitSingularStringField(value: self.recipientUserAddress, fieldNumber: 3) + } + if !self.recipientInstallationID.isEmpty { + try visitor.visitSingularStringField(value: self.recipientInstallationID, fieldNumber: 4) + } + if self.isPrekeyMessage != false { + try visitor.visitSingularBoolField(value: self.isPrekeyMessage, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessageSealedMetadata, rhs: Xmtp_V3_MessageContents_PadlockMessageSealedMetadata) -> Bool { + if lhs.senderUserAddress != rhs.senderUserAddress {return false} + if lhs.senderInstallationID != rhs.senderInstallationID {return false} + if lhs.recipientUserAddress != rhs.recipientUserAddress {return false} + if lhs.recipientInstallationID != rhs.recipientInstallationID {return false} + if lhs.isPrekeyMessage != rhs.isPrekeyMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_PadlockMessageHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PadlockMessageHeader" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "sent_ns"), + 2: .standard(proto: "sealed_metadata"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.sentNs) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.sealedMetadata) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.sentNs != 0 { + try visitor.visitSingularUInt64Field(value: self.sentNs, fieldNumber: 1) + } + if !self.sealedMetadata.isEmpty { + try visitor.visitSingularBytesField(value: self.sealedMetadata, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessageHeader, rhs: Xmtp_V3_MessageContents_PadlockMessageHeader) -> Bool { + if lhs.sentNs != rhs.sentNs {return false} + if lhs.sealedMetadata != rhs.sealedMetadata {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_PadlockMessagePayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PadlockMessagePayload" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "message_version"), + 2: .standard(proto: "header_signature"), + 3: .standard(proto: "convo_id"), + 4: .standard(proto: "content_bytes"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.messageVersion) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._headerSignature) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.convoID) }() + case 4: try { try decoder.decodeSingularBytesField(value: &self.contentBytes) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.messageVersion != .unspecified { + try visitor.visitSingularEnumField(value: self.messageVersion, fieldNumber: 1) + } + try { if let v = self._headerSignature { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.convoID.isEmpty { + try visitor.visitSingularStringField(value: self.convoID, fieldNumber: 3) + } + if !self.contentBytes.isEmpty { + try visitor.visitSingularBytesField(value: self.contentBytes, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessagePayload, rhs: Xmtp_V3_MessageContents_PadlockMessagePayload) -> Bool { + if lhs.messageVersion != rhs.messageVersion {return false} + if lhs._headerSignature != rhs._headerSignature {return false} + if lhs.convoID != rhs.convoID {return false} + if lhs.contentBytes != rhs.contentBytes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_PadlockMessageEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PadlockMessageEnvelope" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "header_bytes"), + 2: .same(proto: "ciphertext"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.headerBytes) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.ciphertext) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.headerBytes.isEmpty { + try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 1) + } + if !self.ciphertext.isEmpty { + try visitor.visitSingularBytesField(value: self.ciphertext, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessageEnvelope, rhs: Xmtp_V3_MessageContents_PadlockMessageEnvelope) -> Bool { + if lhs.headerBytes != rhs.headerBytes {return false} + if lhs.ciphertext != rhs.ciphertext {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift b/Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift new file mode 100644 index 00000000..c38a7bf1 --- /dev/null +++ b/Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift @@ -0,0 +1,658 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: v3/message_contents/public_key.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Structure for representing public keys of different types, +/// including signatures used to authenticate the keys. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// An unsigned public key used by libxmtp +public struct Xmtp_V3_MessageContents_VmacUnsignedPublicKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var createdNs: UInt64 = 0 + + public var union: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union? = nil + + public var curve25519: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519 { + get { + if case .curve25519(let v)? = union {return v} + return Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519() + } + set {union = .curve25519(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Union: Equatable { + case curve25519(Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union, rhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.curve25519, .curve25519): return { + guard case .curve25519(let l) = lhs, case .curve25519(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + /// A Vodozemac curve25519 key serialized via serde + /// (https://github.com/matrix-org/vodozemac/blob/ + /// 929bbaf325686435bdd0ed0d0cc45b0cbad3430d/src/types/curve25519.rs#L100) + public struct VodozemacCurve25519 { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var bytes: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +/// A key linked to an XMTP account (e.g. signed by a wallet) +/// The purpose of the key is encoded in the signature +public struct Xmtp_V3_MessageContents_VmacAccountLinkedKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey { + get {return _key ?? Xmtp_V3_MessageContents_VmacUnsignedPublicKey()} + set {_key = newValue} + } + /// Returns true if `key` has been explicitly set. + public var hasKey: Bool {return self._key != nil} + /// Clears the value of `key`. Subsequent reads from it will return its default value. + public mutating func clearKey() {self._key = nil} + + public var association: Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association? = nil + + public var eip191: Xmtp_V3_MessageContents_Eip191Association { + get { + if case .eip191(let v)? = association {return v} + return Xmtp_V3_MessageContents_Eip191Association() + } + set {association = .eip191(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Association: Equatable { + case eip191(Xmtp_V3_MessageContents_Eip191Association) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association, rhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.eip191, .eip191): return { + guard case .eip191(let l) = lhs, case .eip191(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} + + fileprivate var _key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey? = nil +} + +/// A key linked to an installation (e.g. signed by an installation identity key) +/// The purpose of the key is encoded in the signature +public struct Xmtp_V3_MessageContents_VmacInstallationLinkedKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey { + get {return _key ?? Xmtp_V3_MessageContents_VmacUnsignedPublicKey()} + set {_key = newValue} + } + /// Returns true if `key` has been explicitly set. + public var hasKey: Bool {return self._key != nil} + /// Clears the value of `key`. Subsequent reads from it will return its default value. + public mutating func clearKey() {self._key = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey? = nil +} + +/// A bundle of one time keys uploaded by a client, to be used as +/// input to (X)3DH exchanges with it. The server is expected to serve +/// and delete one prekey to anyone who requests one. +/// In our initial prototype we will not actually use one-time prekeys, +/// defaulting to fallback keys. +public struct Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey { + get {return _identityKey ?? Xmtp_V3_MessageContents_VmacAccountLinkedKey()} + set {_identityKey = newValue} + } + /// Returns true if `identityKey` has been explicitly set. + public var hasIdentityKey: Bool {return self._identityKey != nil} + /// Clears the value of `identityKey`. Subsequent reads from it will return its default value. + public mutating func clearIdentityKey() {self._identityKey = nil} + + public var oneTimeKeys: [Xmtp_V3_MessageContents_VmacInstallationLinkedKey] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey? = nil +} + +/// A fallback key uploaded by a client, which replaces any existing +/// fallback key. The server is expected to serve this prekey when +/// all one-time prekeys have been exhausted. +/// In our initial prototype we will always use the fallback key in place +/// of any one-time prekeys. +public struct Xmtp_V3_MessageContents_VmacFallbackKeyRotation { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey { + get {return _identityKey ?? Xmtp_V3_MessageContents_VmacAccountLinkedKey()} + set {_identityKey = newValue} + } + /// Returns true if `identityKey` has been explicitly set. + public var hasIdentityKey: Bool {return self._identityKey != nil} + /// Clears the value of `identityKey`. Subsequent reads from it will return its default value. + public mutating func clearIdentityKey() {self._identityKey = nil} + + public var fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey { + get {return _fallbackKey ?? Xmtp_V3_MessageContents_VmacInstallationLinkedKey()} + set {_fallbackKey = newValue} + } + /// Returns true if `fallbackKey` has been explicitly set. + public var hasFallbackKey: Bool {return self._fallbackKey != nil} + /// Clears the value of `fallbackKey`. Subsequent reads from it will return its default value. + public mutating func clearFallbackKey() {self._fallbackKey = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey? = nil + fileprivate var _fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey? = nil +} + +/// A contact bundle served by the server to a requesting client +public struct Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1 { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey { + get {return _identityKey ?? Xmtp_V3_MessageContents_VmacAccountLinkedKey()} + set {_identityKey = newValue} + } + /// Returns true if `identityKey` has been explicitly set. + public var hasIdentityKey: Bool {return self._identityKey != nil} + /// Clears the value of `identityKey`. Subsequent reads from it will return its default value. + public mutating func clearIdentityKey() {self._identityKey = nil} + + public var fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey { + get {return _fallbackKey ?? Xmtp_V3_MessageContents_VmacInstallationLinkedKey()} + set {_fallbackKey = newValue} + } + /// Returns true if `fallbackKey` has been explicitly set. + public var hasFallbackKey: Bool {return self._fallbackKey != nil} + /// Clears the value of `fallbackKey`. Subsequent reads from it will return its default value. + public mutating func clearFallbackKey() {self._fallbackKey = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey? = nil + fileprivate var _fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey? = nil +} + +/// A wrapper for versions of the installation contact bundle to allow +/// upgradeability +public struct Xmtp_V3_MessageContents_InstallationContactBundle { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var version: Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version? = nil + + public var v1: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1 { + get { + if case .v1(let v)? = version {return v} + return Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1() + } + set {version = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Version: Equatable { + case v1(Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version, rhs: Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacAccountLinkedKey: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacInstallationLinkedKey: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacFallbackKeyRotation: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_InstallationContactBundle: @unchecked Sendable {} +extension Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.v3.message_contents" + +extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".VmacUnsignedPublicKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "created_ns"), + 2: .same(proto: "curve25519"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.createdNs) }() + case 2: try { + var v: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519? + var hadOneofValue = false + if let current = self.union { + hadOneofValue = true + if case .curve25519(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.union = .curve25519(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.createdNs != 0 { + try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 1) + } + try { if case .curve25519(let v)? = self.union { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey, rhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey) -> Bool { + if lhs.createdNs != rhs.createdNs {return false} + if lhs.union != rhs.union {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_V3_MessageContents_VmacUnsignedPublicKey.protoMessageName + ".VodozemacCurve25519" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "bytes"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.bytes.isEmpty { + try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519, rhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519) -> Bool { + if lhs.bytes != rhs.bytes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_VmacAccountLinkedKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".VmacAccountLinkedKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "key"), + 2: .standard(proto: "eip_191"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._key) }() + case 2: try { + var v: Xmtp_V3_MessageContents_Eip191Association? + var hadOneofValue = false + if let current = self.association { + hadOneofValue = true + if case .eip191(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.association = .eip191(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._key { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if case .eip191(let v)? = self.association { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey, rhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey) -> Bool { + if lhs._key != rhs._key {return false} + if lhs.association != rhs.association {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_VmacInstallationLinkedKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".VmacInstallationLinkedKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "key"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._key) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._key { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacInstallationLinkedKey, rhs: Xmtp_V3_MessageContents_VmacInstallationLinkedKey) -> Bool { + if lhs._key != rhs._key {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".VmacOneTimeKeyTopupBundle" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "identity_key"), + 2: .standard(proto: "one_time_keys"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._identityKey) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.oneTimeKeys) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._identityKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.oneTimeKeys.isEmpty { + try visitor.visitRepeatedMessageField(value: self.oneTimeKeys, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle, rhs: Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle) -> Bool { + if lhs._identityKey != rhs._identityKey {return false} + if lhs.oneTimeKeys != rhs.oneTimeKeys {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_VmacFallbackKeyRotation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".VmacFallbackKeyRotation" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "identity_key"), + 2: .standard(proto: "fallback_key"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._identityKey) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._fallbackKey) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._identityKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._fallbackKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacFallbackKeyRotation, rhs: Xmtp_V3_MessageContents_VmacFallbackKeyRotation) -> Bool { + if lhs._identityKey != rhs._identityKey {return false} + if lhs._fallbackKey != rhs._fallbackKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".VmacInstallationPublicKeyBundleV1" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "identity_key"), + 2: .standard(proto: "fallback_key"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._identityKey) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._fallbackKey) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._identityKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._fallbackKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1, rhs: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1) -> Bool { + if lhs._identityKey != rhs._identityKey {return false} + if lhs._fallbackKey != rhs._fallbackKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_V3_MessageContents_InstallationContactBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InstallationContactBundle" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1? + var hadOneofValue = false + if let current = self.version { + hadOneofValue = true + if case .v1(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.version = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.version { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_V3_MessageContents_InstallationContactBundle, rhs: Xmtp_V3_MessageContents_InstallationContactBundle) -> Bool { + if lhs.version != rhs.version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 65e196f6..38a4515b 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -176,8 +176,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/xmtp-rust-swift", "state" : { - "revision" : "d1aaac47fc7c57645a6fe9e06972b957b3efa33c", - "version" : "0.3.5-beta0" + "branch" : "main", + "revision" : "e857176b7e368c51e1dadcbbcce648bb20432f26" } } ], From dbad2c5b32936950f602960c4970c85a553a5914 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 14:54:33 -0700 Subject: [PATCH 05/11] update contacts to use proto code --- Sources/XMTP/Contacts.swift | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index 725a0a16..ac52e8a7 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -8,6 +8,9 @@ import Foundation import XMTPRust + +public typealias PrivatePreferencesAction = Xmtp_MessageContents_PrivatePreferencesAction + public enum AllowState: String, Codable { case allowed, blocked, unknown } @@ -40,6 +43,8 @@ class AllowList { let identifier = try XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() let envelopes = try await client.query(topic: .allowList(identifier)) let allowList = AllowList() + + var preferences: [PrivatePreferencesAction] = [] for envelope in envelopes.envelopes { @@ -50,16 +55,32 @@ class AllowList { RustVec(envelope.message) ) - let entry = try JSONDecoder().decode(AllowListEntry.self, from: Data(payload)) - - allowList.entries[entry.key] = entry.permissionType + preferences.append(try PrivatePreferencesAction(contiguousBytes: Data(payload).bytes)) } + + preferences.forEach { preference in + preference.allow.walletAddresses.forEach { address in + allowList.allow(address: address) + } + preference.block.walletAddresses.forEach { address in + allowList.block(address: address) + } + } return allowList } static func publish(entry: AllowListEntry, to client: Client) async throws { - let payload = try JSONEncoder().encode(entry) + + var payload = PrivatePreferencesAction() + switch entry.permissionType { + case .allowed: + payload.allow.walletAddresses = [entry.value] + case .blocked: + payload.block.walletAddresses = [entry.value] + case .unknown: + payload.unknownFields + } let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes @@ -68,7 +89,7 @@ class AllowList { let message = try XMTPRust.ecies_encrypt_k256_sha3_256( RustVec(publicKey), RustVec(privateKey), - RustVec(payload) + RustVec(payload.serializedData()) ) let envelope = Envelope( From 3e55e80ba7b633549054cf237f1ee16733a4224b Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 15:15:22 -0700 Subject: [PATCH 06/11] pull the identifier and keys out to the init --- Sources/XMTP/Contacts.swift | 55 ++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index ac52e8a7..1e64142a 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -33,16 +33,33 @@ struct AllowListEntry: Codable, Hashable { } } +public enum ContactError: Error { + case invalidIdentifier +} + class AllowList { var entries: [String: AllowState] = [:] + var publicKey: Data + var privateKey: Data + var identifier: String? + + var client: Client + + init(client: Client) { + self.client = client + self.privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes + self.publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes + self.identifier = try? XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() + } + + func load() async throws -> AllowList { + guard let identifier = identifier else { + throw ContactError.invalidIdentifier + } + + let envelopes = try await client.query(topic: .allowList(identifier)) - static func load(from client: Client) async throws -> AllowList { - let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes - let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes - - let identifier = try XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() - let envelopes = try await client.query(topic: .allowList(identifier)) - let allowList = AllowList() + let allowList = AllowList(client: client) var preferences: [PrivatePreferencesAction] = [] @@ -70,8 +87,11 @@ class AllowList { return allowList } - static func publish(entry: AllowListEntry, to client: Client) async throws { - + func publish(entry: AllowListEntry) async throws { + guard let identifier = identifier else { + throw ContactError.invalidIdentifier + } + var payload = PrivatePreferencesAction() switch entry.permissionType { case .allowed: @@ -82,10 +102,6 @@ class AllowList { payload.unknownFields } - let publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes - let privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes - let identifier = try XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() - let message = try XMTPRust.ecies_encrypt_k256_sha3_256( RustVec(publicKey), RustVec(privateKey), @@ -130,14 +146,15 @@ public actor Contacts { // Whether or not we have sent invite/intro to this contact var hasIntroduced: [String: Bool] = [:] - var allowList = AllowList() - - init(client: Client) { + var allowList: AllowList + + init(client: Client) { self.client = client + self.allowList = AllowList(client: client) } public func refreshAllowList() async throws { - self.allowList = try await AllowList.load(from: client) + self.allowList = try await AllowList(client: client).load() } public func isAllowed(_ address: String) -> Bool { @@ -150,13 +167,13 @@ public actor Contacts { public func allow(addresses: [String]) async throws { for address in addresses { - try await AllowList.publish(entry: allowList.allow(address: address), to: client) + try await AllowList(client: client).publish(entry: allowList.allow(address: address)) } } public func block(addresses: [String]) async throws { for address in addresses { - try await AllowList.publish(entry: allowList.block(address: address), to: client) + try await AllowList(client: client).publish(entry: allowList.block(address: address)) } } From 5ffb80028c5ba4d727897d4dbb961716a2d3005c Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 15:21:20 -0700 Subject: [PATCH 07/11] remove proto code that breaks the build --- .../XMTP/Proto/message_api/v3/mls.pb.swift | 978 ------------------ .../mls/message_contents/message.pb.swift | 300 ------ .../v3/message_contents/association.pb.swift | 248 ----- .../Proto/v3/message_contents/invite.pb.swift | 241 ----- .../v3/message_contents/message.pb.swift | 370 ------- .../v3/message_contents/public_key.pb.swift | 658 ------------ 6 files changed, 2795 deletions(-) delete mode 100644 Sources/XMTP/Proto/message_api/v3/mls.pb.swift delete mode 100644 Sources/XMTP/Proto/mls/message_contents/message.pb.swift delete mode 100644 Sources/XMTP/Proto/v3/message_contents/association.pb.swift delete mode 100644 Sources/XMTP/Proto/v3/message_contents/invite.pb.swift delete mode 100644 Sources/XMTP/Proto/v3/message_contents/message.pb.swift delete mode 100644 Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift diff --git a/Sources/XMTP/Proto/message_api/v3/mls.pb.swift b/Sources/XMTP/Proto/message_api/v3/mls.pb.swift deleted file mode 100644 index 5b295e2b..00000000 --- a/Sources/XMTP/Proto/message_api/v3/mls.pb.swift +++ /dev/null @@ -1,978 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: message_api/v3/mls.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Message API - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// Publish a batch of MLS messages -public struct Xmtp_MessageApi_V3_PublishToGroupRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var messages: [Xmtp_Mls_MessageContents_GroupMessage] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Publish a batch of welcome messages -public struct Xmtp_MessageApi_V3_PublishWelcomesRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var welcomeMessages: [Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// An individual welcome message - public struct WelcomeMessageRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The topic will be derived from this - public var installationID: String = String() - - public var welcomeMessage: Xmtp_Mls_MessageContents_WelcomeMessage { - get {return _welcomeMessage ?? Xmtp_Mls_MessageContents_WelcomeMessage()} - set {_welcomeMessage = newValue} - } - /// Returns true if `welcomeMessage` has been explicitly set. - public var hasWelcomeMessage: Bool {return self._welcomeMessage != nil} - /// Clears the value of `welcomeMessage`. Subsequent reads from it will return its default value. - public mutating func clearWelcomeMessage() {self._welcomeMessage = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _welcomeMessage: Xmtp_Mls_MessageContents_WelcomeMessage? = nil - } - - public init() {} -} - -/// Register a new installation -public struct Xmtp_MessageApi_V3_RegisterInstallationRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var credentialBytes: Data = Data() - - public var signingKeyPublic: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Xmtp_MessageApi_V3_RegisterInstallationResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var installationID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Upload one or more key packages -public struct Xmtp_MessageApi_V3_UploadKeyPackagesRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var keyPackages: [Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// An individual key package upload request - public struct KeyPackageUpload { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The owner's wallet address would be extracted from the identity - /// credential in the key package, and all signatures would be validated. - public var keyPackageTlsSerialized: Data = Data() - - /// The node will always treat the most recent last-resort key package as - /// the active one, and will ignore all others. - public var isLastResort: Bool = false - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Consume one or more key packages, removing them from further use -public struct Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The caller can provide an array of wallet addresses, and the API - /// will return one key package for each installation associated with each - /// wallet address - public var installationIds: [String] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// The response to a ConsumeKeyPackagesRequest -public struct Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Returns one key package per installation in the original order of the - /// request. If any installations are missing key packages, - public var keyPackages: [Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// An individual key package - public struct KeyPackage { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var keyPackageTlsSerialized: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Revoke an installation -public struct Xmtp_MessageApi_V3_RevokeInstallationRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var installationID: String = String() - - /// All revocations must be validated with a wallet signature over the - /// installation_id being revoked (and some sort of standard prologue) - public var walletSignature: Xmtp_MessageContents_Signature { - get {return _walletSignature ?? Xmtp_MessageContents_Signature()} - set {_walletSignature = newValue} - } - /// Returns true if `walletSignature` has been explicitly set. - public var hasWalletSignature: Bool {return self._walletSignature != nil} - /// Clears the value of `walletSignature`. Subsequent reads from it will return its default value. - public mutating func clearWalletSignature() {self._walletSignature = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _walletSignature: Xmtp_MessageContents_Signature? = nil -} - -/// Get all updates for an identity since the specified time -public struct Xmtp_MessageApi_V3_GetIdentityUpdatesRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var walletAddresses: [String] = [] - - public var startTimeNs: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Used to get any new or revoked installations for a list of wallet addresses -public struct Xmtp_MessageApi_V3_GetIdentityUpdatesResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// A list of updates (or empty objects if no changes) in the original order - /// of the request - public var updates: [Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// A new installation ID was seen for the first time by the nodes - public struct NewInstallationUpdate { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var installationID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - /// An installation was revoked - public struct RevokedInstallationUpdate { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var installationID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - /// A wrapper for any update to the wallet - public struct Update { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var timestampNs: UInt64 = 0 - - public var kind: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind? = nil - - public var newInstallation: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate { - get { - if case .newInstallation(let v)? = kind {return v} - return Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate() - } - set {kind = .newInstallation(newValue)} - } - - public var revokedInstallation: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate { - get { - if case .revokedInstallation(let v)? = kind {return v} - return Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate() - } - set {kind = .revokedInstallation(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Kind: Equatable { - case newInstallation(Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate) - case revokedInstallation(Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.newInstallation, .newInstallation): return { - guard case .newInstallation(let l) = lhs, case .newInstallation(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.revokedInstallation, .revokedInstallation): return { - guard case .revokedInstallation(let l) = lhs, case .revokedInstallation(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif - } - - public init() {} - } - - /// A wrapper for the updates for a single wallet - public struct WalletUpdates { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var updates: [Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_MessageApi_V3_PublishToGroupRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_PublishWelcomesRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_RegisterInstallationRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_RegisterInstallationResponse: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_RevokeInstallationRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesRequest: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update.OneOf_Kind: @unchecked Sendable {} -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.message_api.v3" - -extension Xmtp_MessageApi_V3_PublishToGroupRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PublishToGroupRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "messages"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.messages) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.messages.isEmpty { - try visitor.visitRepeatedMessageField(value: self.messages, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_PublishToGroupRequest, rhs: Xmtp_MessageApi_V3_PublishToGroupRequest) -> Bool { - if lhs.messages != rhs.messages {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_PublishWelcomesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PublishWelcomesRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "welcome_messages"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.welcomeMessages) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.welcomeMessages.isEmpty { - try visitor.visitRepeatedMessageField(value: self.welcomeMessages, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_PublishWelcomesRequest, rhs: Xmtp_MessageApi_V3_PublishWelcomesRequest) -> Bool { - if lhs.welcomeMessages != rhs.welcomeMessages {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_PublishWelcomesRequest.protoMessageName + ".WelcomeMessageRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "installation_id"), - 2: .standard(proto: "welcome_message"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._welcomeMessage) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.installationID.isEmpty { - try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) - } - try { if let v = self._welcomeMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest, rhs: Xmtp_MessageApi_V3_PublishWelcomesRequest.WelcomeMessageRequest) -> Bool { - if lhs.installationID != rhs.installationID {return false} - if lhs._welcomeMessage != rhs._welcomeMessage {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_RegisterInstallationRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RegisterInstallationRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "credential_bytes"), - 2: .standard(proto: "signing_key_public"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.credentialBytes) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.signingKeyPublic) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.credentialBytes.isEmpty { - try visitor.visitSingularBytesField(value: self.credentialBytes, fieldNumber: 1) - } - if !self.signingKeyPublic.isEmpty { - try visitor.visitSingularBytesField(value: self.signingKeyPublic, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_RegisterInstallationRequest, rhs: Xmtp_MessageApi_V3_RegisterInstallationRequest) -> Bool { - if lhs.credentialBytes != rhs.credentialBytes {return false} - if lhs.signingKeyPublic != rhs.signingKeyPublic {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_RegisterInstallationResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RegisterInstallationResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "installation_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.installationID.isEmpty { - try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_RegisterInstallationResponse, rhs: Xmtp_MessageApi_V3_RegisterInstallationResponse) -> Bool { - if lhs.installationID != rhs.installationID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".UploadKeyPackagesRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "key_packages"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.keyPackages) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.keyPackages.isEmpty { - try visitor.visitRepeatedMessageField(value: self.keyPackages, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest, rhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest) -> Bool { - if lhs.keyPackages != rhs.keyPackages {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_UploadKeyPackagesRequest.protoMessageName + ".KeyPackageUpload" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "key_package_tls_serialized"), - 2: .standard(proto: "is_last_resort"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.keyPackageTlsSerialized) }() - case 2: try { try decoder.decodeSingularBoolField(value: &self.isLastResort) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.keyPackageTlsSerialized.isEmpty { - try visitor.visitSingularBytesField(value: self.keyPackageTlsSerialized, fieldNumber: 1) - } - if self.isLastResort != false { - try visitor.visitSingularBoolField(value: self.isLastResort, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload, rhs: Xmtp_MessageApi_V3_UploadKeyPackagesRequest.KeyPackageUpload) -> Bool { - if lhs.keyPackageTlsSerialized != rhs.keyPackageTlsSerialized {return false} - if lhs.isLastResort != rhs.isLastResort {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ConsumeKeyPackagesRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "installation_ids"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedStringField(value: &self.installationIds) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.installationIds.isEmpty { - try visitor.visitRepeatedStringField(value: self.installationIds, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest, rhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesRequest) -> Bool { - if lhs.installationIds != rhs.installationIds {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ConsumeKeyPackagesResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "key_packages"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.keyPackages) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.keyPackages.isEmpty { - try visitor.visitRepeatedMessageField(value: self.keyPackages, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse, rhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse) -> Bool { - if lhs.keyPackages != rhs.keyPackages {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.protoMessageName + ".KeyPackage" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "key_package_tls_serialized"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.keyPackageTlsSerialized) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.keyPackageTlsSerialized.isEmpty { - try visitor.visitSingularBytesField(value: self.keyPackageTlsSerialized, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage, rhs: Xmtp_MessageApi_V3_ConsumeKeyPackagesResponse.KeyPackage) -> Bool { - if lhs.keyPackageTlsSerialized != rhs.keyPackageTlsSerialized {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_RevokeInstallationRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RevokeInstallationRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "installation_id"), - 2: .standard(proto: "wallet_signature"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._walletSignature) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.installationID.isEmpty { - try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) - } - try { if let v = self._walletSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_RevokeInstallationRequest, rhs: Xmtp_MessageApi_V3_RevokeInstallationRequest) -> Bool { - if lhs.installationID != rhs.installationID {return false} - if lhs._walletSignature != rhs._walletSignature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_GetIdentityUpdatesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetIdentityUpdatesRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "wallet_addresses"), - 2: .standard(proto: "start_time_ns"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedStringField(value: &self.walletAddresses) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.startTimeNs) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.walletAddresses.isEmpty { - try visitor.visitRepeatedStringField(value: self.walletAddresses, fieldNumber: 1) - } - if self.startTimeNs != 0 { - try visitor.visitSingularUInt64Field(value: self.startTimeNs, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesRequest, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesRequest) -> Bool { - if lhs.walletAddresses != rhs.walletAddresses {return false} - if lhs.startTimeNs != rhs.startTimeNs {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetIdentityUpdatesResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "updates"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.updates) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.updates.isEmpty { - try visitor.visitRepeatedMessageField(value: self.updates, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse) -> Bool { - if lhs.updates != rhs.updates {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".NewInstallationUpdate" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "installation_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.installationID.isEmpty { - try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate) -> Bool { - if lhs.installationID != rhs.installationID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".RevokedInstallationUpdate" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "installation_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.installationID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.installationID.isEmpty { - try visitor.visitSingularStringField(value: self.installationID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate) -> Bool { - if lhs.installationID != rhs.installationID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".Update" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "timestamp_ns"), - 2: .standard(proto: "new_installation"), - 3: .standard(proto: "revoked_installation"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.timestampNs) }() - case 2: try { - var v: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.NewInstallationUpdate? - var hadOneofValue = false - if let current = self.kind { - hadOneofValue = true - if case .newInstallation(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.kind = .newInstallation(v) - } - }() - case 3: try { - var v: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.RevokedInstallationUpdate? - var hadOneofValue = false - if let current = self.kind { - hadOneofValue = true - if case .revokedInstallation(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.kind = .revokedInstallation(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.timestampNs != 0 { - try visitor.visitSingularUInt64Field(value: self.timestampNs, fieldNumber: 1) - } - switch self.kind { - case .newInstallation?: try { - guard case .newInstallation(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - }() - case .revokedInstallation?: try { - guard case .revokedInstallation(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - }() - case nil: break - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.Update) -> Bool { - if lhs.timestampNs != rhs.timestampNs {return false} - if lhs.kind != rhs.kind {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.protoMessageName + ".WalletUpdates" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "updates"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.updates) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.updates.isEmpty { - try visitor.visitRepeatedMessageField(value: self.updates, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates, rhs: Xmtp_MessageApi_V3_GetIdentityUpdatesResponse.WalletUpdates) -> Bool { - if lhs.updates != rhs.updates {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTP/Proto/mls/message_contents/message.pb.swift b/Sources/XMTP/Proto/mls/message_contents/message.pb.swift deleted file mode 100644 index ed157698..00000000 --- a/Sources/XMTP/Proto/mls/message_contents/message.pb.swift +++ /dev/null @@ -1,300 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: mls/message_contents/message.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// V3 invite message structure - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// Wrapper for a MLS welcome message -public struct Xmtp_Mls_MessageContents_WelcomeMessage { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var version: Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version? = nil - - public var v1: Xmtp_Mls_MessageContents_WelcomeMessage.V1 { - get { - if case .v1(let v)? = version {return v} - return Xmtp_Mls_MessageContents_WelcomeMessage.V1() - } - set {version = .v1(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Version: Equatable { - case v1(Xmtp_Mls_MessageContents_WelcomeMessage.V1) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version, rhs: Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.v1, .v1): return { - guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - /// Version 1 of the WelcomeMessage format - public struct V1 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var welcomeMessageTlsSerialized: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// GroupMessage wraps any MLS message sent to a group topic -public struct Xmtp_Mls_MessageContents_GroupMessage { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var version: Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version? = nil - - public var v1: Xmtp_Mls_MessageContents_GroupMessage.V1 { - get { - if case .v1(let v)? = version {return v} - return Xmtp_Mls_MessageContents_GroupMessage.V1() - } - set {version = .v1(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Version: Equatable { - case v1(Xmtp_Mls_MessageContents_GroupMessage.V1) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version, rhs: Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.v1, .v1): return { - guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - /// Version 1 of the GroupMessage format - public struct V1 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var mlsMessageTlsSerialized: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_Mls_MessageContents_WelcomeMessage: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_WelcomeMessage.OneOf_Version: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_WelcomeMessage.V1: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_GroupMessage: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_GroupMessage.OneOf_Version: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_GroupMessage.V1: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.mls.message_contents" - -extension Xmtp_Mls_MessageContents_WelcomeMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".WelcomeMessage" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "v1"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Xmtp_Mls_MessageContents_WelcomeMessage.V1? - var hadOneofValue = false - if let current = self.version { - hadOneofValue = true - if case .v1(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.version = .v1(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if case .v1(let v)? = self.version { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_WelcomeMessage, rhs: Xmtp_Mls_MessageContents_WelcomeMessage) -> Bool { - if lhs.version != rhs.version {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_WelcomeMessage.V1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Mls_MessageContents_WelcomeMessage.protoMessageName + ".V1" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "welcome_message_tls_serialized"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.welcomeMessageTlsSerialized) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.welcomeMessageTlsSerialized.isEmpty { - try visitor.visitSingularBytesField(value: self.welcomeMessageTlsSerialized, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_WelcomeMessage.V1, rhs: Xmtp_Mls_MessageContents_WelcomeMessage.V1) -> Bool { - if lhs.welcomeMessageTlsSerialized != rhs.welcomeMessageTlsSerialized {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_GroupMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GroupMessage" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "v1"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Xmtp_Mls_MessageContents_GroupMessage.V1? - var hadOneofValue = false - if let current = self.version { - hadOneofValue = true - if case .v1(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.version = .v1(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if case .v1(let v)? = self.version { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_GroupMessage, rhs: Xmtp_Mls_MessageContents_GroupMessage) -> Bool { - if lhs.version != rhs.version {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_GroupMessage.V1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Mls_MessageContents_GroupMessage.protoMessageName + ".V1" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "mls_message_tls_serialized"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.mlsMessageTlsSerialized) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.mlsMessageTlsSerialized.isEmpty { - try visitor.visitSingularBytesField(value: self.mlsMessageTlsSerialized, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_GroupMessage.V1, rhs: Xmtp_Mls_MessageContents_GroupMessage.V1) -> Bool { - if lhs.mlsMessageTlsSerialized != rhs.mlsMessageTlsSerialized {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTP/Proto/v3/message_contents/association.pb.swift b/Sources/XMTP/Proto/v3/message_contents/association.pb.swift deleted file mode 100644 index 3d2f91f5..00000000 --- a/Sources/XMTP/Proto/v3/message_contents/association.pb.swift +++ /dev/null @@ -1,248 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: v3/message_contents/association.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Association types - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// Allows for us to update the format of the association text without -/// incrementing the entire proto -public enum Xmtp_V3_MessageContents_AssociationTextVersion: SwiftProtobuf.Enum { - public typealias RawValue = Int - case unspecified // = 0 - case associationTextVersion1 // = 1 - case UNRECOGNIZED(Int) - - public init() { - self = .unspecified - } - - public init?(rawValue: Int) { - switch rawValue { - case 0: self = .unspecified - case 1: self = .associationTextVersion1 - default: self = .UNRECOGNIZED(rawValue) - } - } - - public var rawValue: Int { - switch self { - case .unspecified: return 0 - case .associationTextVersion1: return 1 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Xmtp_V3_MessageContents_AssociationTextVersion: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static let allCases: [Xmtp_V3_MessageContents_AssociationTextVersion] = [ - .unspecified, - .associationTextVersion1, - ] -} - -#endif // swift(>=4.2) - -/// EIP191Association is used for all EIP 191 compliant wallet signatures -public struct Xmtp_V3_MessageContents_Eip191Association { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var associationTextVersion: Xmtp_V3_MessageContents_AssociationTextVersion = .unspecified - - public var signature: Xmtp_V3_MessageContents_RecoverableEcdsaSignature { - get {return _signature ?? Xmtp_V3_MessageContents_RecoverableEcdsaSignature()} - set {_signature = newValue} - } - /// Returns true if `signature` has been explicitly set. - public var hasSignature: Bool {return self._signature != nil} - /// Clears the value of `signature`. Subsequent reads from it will return its default value. - public mutating func clearSignature() {self._signature = nil} - - public var walletAddress: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _signature: Xmtp_V3_MessageContents_RecoverableEcdsaSignature? = nil -} - -/// RecoverableEcdsaSignature -public struct Xmtp_V3_MessageContents_RecoverableEcdsaSignature { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Includes recovery id as the last byte - public var bytes: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// EdDSA signature bytes matching RFC 8032 -public struct Xmtp_V3_MessageContents_EdDsaSignature { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var bytes: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_V3_MessageContents_AssociationTextVersion: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_Eip191Association: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_RecoverableEcdsaSignature: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_EdDsaSignature: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.v3.message_contents" - -extension Xmtp_V3_MessageContents_AssociationTextVersion: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "ASSOCIATION_TEXT_VERSION_UNSPECIFIED"), - 1: .same(proto: "ASSOCIATION_TEXT_VERSION_1"), - ] -} - -extension Xmtp_V3_MessageContents_Eip191Association: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Eip191Association" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "association_text_version"), - 2: .same(proto: "signature"), - 3: .standard(proto: "wallet_address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularEnumField(value: &self.associationTextVersion) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._signature) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.walletAddress) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.associationTextVersion != .unspecified { - try visitor.visitSingularEnumField(value: self.associationTextVersion, fieldNumber: 1) - } - try { if let v = self._signature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - if !self.walletAddress.isEmpty { - try visitor.visitSingularStringField(value: self.walletAddress, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_Eip191Association, rhs: Xmtp_V3_MessageContents_Eip191Association) -> Bool { - if lhs.associationTextVersion != rhs.associationTextVersion {return false} - if lhs._signature != rhs._signature {return false} - if lhs.walletAddress != rhs.walletAddress {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_RecoverableEcdsaSignature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RecoverableEcdsaSignature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "bytes"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.bytes.isEmpty { - try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_RecoverableEcdsaSignature, rhs: Xmtp_V3_MessageContents_RecoverableEcdsaSignature) -> Bool { - if lhs.bytes != rhs.bytes {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_EdDsaSignature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".EdDsaSignature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "bytes"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.bytes.isEmpty { - try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_EdDsaSignature, rhs: Xmtp_V3_MessageContents_EdDsaSignature) -> Bool { - if lhs.bytes != rhs.bytes {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTP/Proto/v3/message_contents/invite.pb.swift b/Sources/XMTP/Proto/v3/message_contents/invite.pb.swift deleted file mode 100644 index f5aebb4b..00000000 --- a/Sources/XMTP/Proto/v3/message_contents/invite.pb.swift +++ /dev/null @@ -1,241 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: v3/message_contents/invite.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// V3 invite message structure - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// InvitationV1 is the invitation message meant to be encrypted as -/// ciphertext in InvitationEnvelopeV1 and decrypted by the recipient using the -/// provided inviter `InstallationContactBundle` -public struct Xmtp_V3_MessageContents_InvitationV1 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// If the inviter contact bundle has the same wallet address as the current - /// user, the invitee is the other wallet address in the conversation. If the - /// inviter contact bundle has a different wallet address, the invitee wallet - /// address MUST be the wallet address of the recipient of the invite. - public var inviteeWalletAddress: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// InvitationEnvelopeV1 is the encrypted invitation message and the contact of -/// the sender -public struct Xmtp_V3_MessageContents_InvitationEnvelopeV1 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// This contains the public key that will be used to decrypt the ciphertext - public var inviter: Xmtp_V3_MessageContents_InstallationContactBundle { - get {return _inviter ?? Xmtp_V3_MessageContents_InstallationContactBundle()} - set {_inviter = newValue} - } - /// Returns true if `inviter` has been explicitly set. - public var hasInviter: Bool {return self._inviter != nil} - /// Clears the value of `inviter`. Subsequent reads from it will return its default value. - public mutating func clearInviter() {self._inviter = nil} - - /// Corresponds to an InvitationV1 message - public var ciphertext: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _inviter: Xmtp_V3_MessageContents_InstallationContactBundle? = nil -} - -/// Wrapper message type -public struct Xmtp_V3_MessageContents_InvitationEnvelope { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var version: Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version? = nil - - public var v1: Xmtp_V3_MessageContents_InvitationEnvelopeV1 { - get { - if case .v1(let v)? = version {return v} - return Xmtp_V3_MessageContents_InvitationEnvelopeV1() - } - set {version = .v1(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Version: Equatable { - case v1(Xmtp_V3_MessageContents_InvitationEnvelopeV1) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version, rhs: Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.v1, .v1): return { - guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_V3_MessageContents_InvitationV1: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_InvitationEnvelopeV1: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_InvitationEnvelope: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_InvitationEnvelope.OneOf_Version: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.v3.message_contents" - -extension Xmtp_V3_MessageContents_InvitationV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".InvitationV1" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "invitee_wallet_address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.inviteeWalletAddress) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.inviteeWalletAddress.isEmpty { - try visitor.visitSingularStringField(value: self.inviteeWalletAddress, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_InvitationV1, rhs: Xmtp_V3_MessageContents_InvitationV1) -> Bool { - if lhs.inviteeWalletAddress != rhs.inviteeWalletAddress {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_InvitationEnvelopeV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".InvitationEnvelopeV1" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "inviter"), - 2: .same(proto: "ciphertext"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._inviter) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.ciphertext) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._inviter { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - if !self.ciphertext.isEmpty { - try visitor.visitSingularBytesField(value: self.ciphertext, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_InvitationEnvelopeV1, rhs: Xmtp_V3_MessageContents_InvitationEnvelopeV1) -> Bool { - if lhs._inviter != rhs._inviter {return false} - if lhs.ciphertext != rhs.ciphertext {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_InvitationEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".InvitationEnvelope" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "v1"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Xmtp_V3_MessageContents_InvitationEnvelopeV1? - var hadOneofValue = false - if let current = self.version { - hadOneofValue = true - if case .v1(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.version = .v1(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if case .v1(let v)? = self.version { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_InvitationEnvelope, rhs: Xmtp_V3_MessageContents_InvitationEnvelope) -> Bool { - if lhs.version != rhs.version {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTP/Proto/v3/message_contents/message.pb.swift b/Sources/XMTP/Proto/v3/message_contents/message.pb.swift deleted file mode 100644 index 2496b1c7..00000000 --- a/Sources/XMTP/Proto/v3/message_contents/message.pb.swift +++ /dev/null @@ -1,370 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: v3/message_contents/message.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Structure for messages in v3 - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// The version used for the decrypted padlock message payload -public enum Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: SwiftProtobuf.Enum { - public typealias RawValue = Int - case unspecified // = 0 - case one // = 1 - case UNRECOGNIZED(Int) - - public init() { - self = .unspecified - } - - public init?(rawValue: Int) { - switch rawValue { - case 0: self = .unspecified - case 1: self = .one - default: self = .UNRECOGNIZED(rawValue) - } - } - - public var rawValue: Int { - switch self { - case .unspecified: return 0 - case .one: return 1 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static let allCases: [Xmtp_V3_MessageContents_PadlockMessagePayloadVersion] = [ - .unspecified, - .one, - ] -} - -#endif // swift(>=4.2) - -/// Metadata that is encrypted via SealedSender and only visible to the recipient -/// Currently we do not actually encrypt this, actual implementation of -/// SealedSender will be added shortly. -public struct Xmtp_V3_MessageContents_PadlockMessageSealedMetadata { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var senderUserAddress: String = String() - - public var senderInstallationID: String = String() - - public var recipientUserAddress: String = String() - - public var recipientInstallationID: String = String() - - public var isPrekeyMessage: Bool = false - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Plaintext header included with messages, visible to all -/// Recipients can verify this header has not been tampered with. -/// Servers are unable to verify if the header has been tampered with. -public struct Xmtp_V3_MessageContents_PadlockMessageHeader { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var sentNs: UInt64 = 0 - - /// PadlockMessageSealedMetadata - public var sealedMetadata: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Encrypted body included with messages, only visible to recipients -/// When receiving a message: -/// 1. Decrypt the sealed metadata in the header via SealedSender -/// 2. Verify that you match the recipient_user_address and -/// recipient_installation_id. Verify that the sender_installation_id matches -/// the sender_user_address. -/// 2. Find the relevant session using the sender_user_address and -/// sender_installation_id in the unsealed metadata -/// 3. Use the session to decrypt the payload -/// 4. Verify that the header_signature in the decrypted payload was produced by -/// signing the header_bytes with the ed25519 key matching the -/// sender_installation_id -/// 5. Verify that both the sender_user and recipient_user are partipants of the -/// conversation referenced by convo_id -public struct Xmtp_V3_MessageContents_PadlockMessagePayload { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var messageVersion: Xmtp_V3_MessageContents_PadlockMessagePayloadVersion = .unspecified - - /// Signs PadlockMessageHeader - public var headerSignature: Xmtp_V3_MessageContents_EdDsaSignature { - get {return _headerSignature ?? Xmtp_V3_MessageContents_EdDsaSignature()} - set {_headerSignature = newValue} - } - /// Returns true if `headerSignature` has been explicitly set. - public var hasHeaderSignature: Bool {return self._headerSignature != nil} - /// Clears the value of `headerSignature`. Subsequent reads from it will return its default value. - public mutating func clearHeaderSignature() {self._headerSignature = nil} - - public var convoID: String = String() - - /// EncodedContent - public var contentBytes: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _headerSignature: Xmtp_V3_MessageContents_EdDsaSignature? = nil -} - -/// Combines the plaintext header with the encrypted payload -public struct Xmtp_V3_MessageContents_PadlockMessageEnvelope { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// PadlockMessageHeader - public var headerBytes: Data = Data() - - /// Encrypted PadlockMessagePayload - public var ciphertext: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_PadlockMessageSealedMetadata: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_PadlockMessageHeader: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_PadlockMessagePayload: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_PadlockMessageEnvelope: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.v3.message_contents" - -extension Xmtp_V3_MessageContents_PadlockMessagePayloadVersion: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "PADLOCK_MESSAGE_PAYLOAD_VERSION_UNSPECIFIED"), - 1: .same(proto: "PADLOCK_MESSAGE_PAYLOAD_VERSION_ONE"), - ] -} - -extension Xmtp_V3_MessageContents_PadlockMessageSealedMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PadlockMessageSealedMetadata" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "sender_user_address"), - 2: .standard(proto: "sender_installation_id"), - 3: .standard(proto: "recipient_user_address"), - 4: .standard(proto: "recipient_installation_id"), - 5: .standard(proto: "is_prekey_message"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.senderUserAddress) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.senderInstallationID) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.recipientUserAddress) }() - case 4: try { try decoder.decodeSingularStringField(value: &self.recipientInstallationID) }() - case 5: try { try decoder.decodeSingularBoolField(value: &self.isPrekeyMessage) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.senderUserAddress.isEmpty { - try visitor.visitSingularStringField(value: self.senderUserAddress, fieldNumber: 1) - } - if !self.senderInstallationID.isEmpty { - try visitor.visitSingularStringField(value: self.senderInstallationID, fieldNumber: 2) - } - if !self.recipientUserAddress.isEmpty { - try visitor.visitSingularStringField(value: self.recipientUserAddress, fieldNumber: 3) - } - if !self.recipientInstallationID.isEmpty { - try visitor.visitSingularStringField(value: self.recipientInstallationID, fieldNumber: 4) - } - if self.isPrekeyMessage != false { - try visitor.visitSingularBoolField(value: self.isPrekeyMessage, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessageSealedMetadata, rhs: Xmtp_V3_MessageContents_PadlockMessageSealedMetadata) -> Bool { - if lhs.senderUserAddress != rhs.senderUserAddress {return false} - if lhs.senderInstallationID != rhs.senderInstallationID {return false} - if lhs.recipientUserAddress != rhs.recipientUserAddress {return false} - if lhs.recipientInstallationID != rhs.recipientInstallationID {return false} - if lhs.isPrekeyMessage != rhs.isPrekeyMessage {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_PadlockMessageHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PadlockMessageHeader" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "sent_ns"), - 2: .standard(proto: "sealed_metadata"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.sentNs) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.sealedMetadata) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.sentNs != 0 { - try visitor.visitSingularUInt64Field(value: self.sentNs, fieldNumber: 1) - } - if !self.sealedMetadata.isEmpty { - try visitor.visitSingularBytesField(value: self.sealedMetadata, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessageHeader, rhs: Xmtp_V3_MessageContents_PadlockMessageHeader) -> Bool { - if lhs.sentNs != rhs.sentNs {return false} - if lhs.sealedMetadata != rhs.sealedMetadata {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_PadlockMessagePayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PadlockMessagePayload" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "message_version"), - 2: .standard(proto: "header_signature"), - 3: .standard(proto: "convo_id"), - 4: .standard(proto: "content_bytes"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularEnumField(value: &self.messageVersion) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._headerSignature) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.convoID) }() - case 4: try { try decoder.decodeSingularBytesField(value: &self.contentBytes) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.messageVersion != .unspecified { - try visitor.visitSingularEnumField(value: self.messageVersion, fieldNumber: 1) - } - try { if let v = self._headerSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - if !self.convoID.isEmpty { - try visitor.visitSingularStringField(value: self.convoID, fieldNumber: 3) - } - if !self.contentBytes.isEmpty { - try visitor.visitSingularBytesField(value: self.contentBytes, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessagePayload, rhs: Xmtp_V3_MessageContents_PadlockMessagePayload) -> Bool { - if lhs.messageVersion != rhs.messageVersion {return false} - if lhs._headerSignature != rhs._headerSignature {return false} - if lhs.convoID != rhs.convoID {return false} - if lhs.contentBytes != rhs.contentBytes {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_PadlockMessageEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PadlockMessageEnvelope" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "header_bytes"), - 2: .same(proto: "ciphertext"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.headerBytes) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.ciphertext) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.headerBytes.isEmpty { - try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 1) - } - if !self.ciphertext.isEmpty { - try visitor.visitSingularBytesField(value: self.ciphertext, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_PadlockMessageEnvelope, rhs: Xmtp_V3_MessageContents_PadlockMessageEnvelope) -> Bool { - if lhs.headerBytes != rhs.headerBytes {return false} - if lhs.ciphertext != rhs.ciphertext {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift b/Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift deleted file mode 100644 index c38a7bf1..00000000 --- a/Sources/XMTP/Proto/v3/message_contents/public_key.pb.swift +++ /dev/null @@ -1,658 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: v3/message_contents/public_key.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Structure for representing public keys of different types, -/// including signatures used to authenticate the keys. - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// An unsigned public key used by libxmtp -public struct Xmtp_V3_MessageContents_VmacUnsignedPublicKey { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var createdNs: UInt64 = 0 - - public var union: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union? = nil - - public var curve25519: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519 { - get { - if case .curve25519(let v)? = union {return v} - return Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519() - } - set {union = .curve25519(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Union: Equatable { - case curve25519(Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union, rhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.curve25519, .curve25519): return { - guard case .curve25519(let l) = lhs, case .curve25519(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - /// A Vodozemac curve25519 key serialized via serde - /// (https://github.com/matrix-org/vodozemac/blob/ - /// 929bbaf325686435bdd0ed0d0cc45b0cbad3430d/src/types/curve25519.rs#L100) - public struct VodozemacCurve25519 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var bytes: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// A key linked to an XMTP account (e.g. signed by a wallet) -/// The purpose of the key is encoded in the signature -public struct Xmtp_V3_MessageContents_VmacAccountLinkedKey { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey { - get {return _key ?? Xmtp_V3_MessageContents_VmacUnsignedPublicKey()} - set {_key = newValue} - } - /// Returns true if `key` has been explicitly set. - public var hasKey: Bool {return self._key != nil} - /// Clears the value of `key`. Subsequent reads from it will return its default value. - public mutating func clearKey() {self._key = nil} - - public var association: Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association? = nil - - public var eip191: Xmtp_V3_MessageContents_Eip191Association { - get { - if case .eip191(let v)? = association {return v} - return Xmtp_V3_MessageContents_Eip191Association() - } - set {association = .eip191(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Association: Equatable { - case eip191(Xmtp_V3_MessageContents_Eip191Association) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association, rhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.eip191, .eip191): return { - guard case .eip191(let l) = lhs, case .eip191(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - public init() {} - - fileprivate var _key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey? = nil -} - -/// A key linked to an installation (e.g. signed by an installation identity key) -/// The purpose of the key is encoded in the signature -public struct Xmtp_V3_MessageContents_VmacInstallationLinkedKey { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey { - get {return _key ?? Xmtp_V3_MessageContents_VmacUnsignedPublicKey()} - set {_key = newValue} - } - /// Returns true if `key` has been explicitly set. - public var hasKey: Bool {return self._key != nil} - /// Clears the value of `key`. Subsequent reads from it will return its default value. - public mutating func clearKey() {self._key = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _key: Xmtp_V3_MessageContents_VmacUnsignedPublicKey? = nil -} - -/// A bundle of one time keys uploaded by a client, to be used as -/// input to (X)3DH exchanges with it. The server is expected to serve -/// and delete one prekey to anyone who requests one. -/// In our initial prototype we will not actually use one-time prekeys, -/// defaulting to fallback keys. -public struct Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey { - get {return _identityKey ?? Xmtp_V3_MessageContents_VmacAccountLinkedKey()} - set {_identityKey = newValue} - } - /// Returns true if `identityKey` has been explicitly set. - public var hasIdentityKey: Bool {return self._identityKey != nil} - /// Clears the value of `identityKey`. Subsequent reads from it will return its default value. - public mutating func clearIdentityKey() {self._identityKey = nil} - - public var oneTimeKeys: [Xmtp_V3_MessageContents_VmacInstallationLinkedKey] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey? = nil -} - -/// A fallback key uploaded by a client, which replaces any existing -/// fallback key. The server is expected to serve this prekey when -/// all one-time prekeys have been exhausted. -/// In our initial prototype we will always use the fallback key in place -/// of any one-time prekeys. -public struct Xmtp_V3_MessageContents_VmacFallbackKeyRotation { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey { - get {return _identityKey ?? Xmtp_V3_MessageContents_VmacAccountLinkedKey()} - set {_identityKey = newValue} - } - /// Returns true if `identityKey` has been explicitly set. - public var hasIdentityKey: Bool {return self._identityKey != nil} - /// Clears the value of `identityKey`. Subsequent reads from it will return its default value. - public mutating func clearIdentityKey() {self._identityKey = nil} - - public var fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey { - get {return _fallbackKey ?? Xmtp_V3_MessageContents_VmacInstallationLinkedKey()} - set {_fallbackKey = newValue} - } - /// Returns true if `fallbackKey` has been explicitly set. - public var hasFallbackKey: Bool {return self._fallbackKey != nil} - /// Clears the value of `fallbackKey`. Subsequent reads from it will return its default value. - public mutating func clearFallbackKey() {self._fallbackKey = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey? = nil - fileprivate var _fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey? = nil -} - -/// A contact bundle served by the server to a requesting client -public struct Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey { - get {return _identityKey ?? Xmtp_V3_MessageContents_VmacAccountLinkedKey()} - set {_identityKey = newValue} - } - /// Returns true if `identityKey` has been explicitly set. - public var hasIdentityKey: Bool {return self._identityKey != nil} - /// Clears the value of `identityKey`. Subsequent reads from it will return its default value. - public mutating func clearIdentityKey() {self._identityKey = nil} - - public var fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey { - get {return _fallbackKey ?? Xmtp_V3_MessageContents_VmacInstallationLinkedKey()} - set {_fallbackKey = newValue} - } - /// Returns true if `fallbackKey` has been explicitly set. - public var hasFallbackKey: Bool {return self._fallbackKey != nil} - /// Clears the value of `fallbackKey`. Subsequent reads from it will return its default value. - public mutating func clearFallbackKey() {self._fallbackKey = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _identityKey: Xmtp_V3_MessageContents_VmacAccountLinkedKey? = nil - fileprivate var _fallbackKey: Xmtp_V3_MessageContents_VmacInstallationLinkedKey? = nil -} - -/// A wrapper for versions of the installation contact bundle to allow -/// upgradeability -public struct Xmtp_V3_MessageContents_InstallationContactBundle { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var version: Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version? = nil - - public var v1: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1 { - get { - if case .v1(let v)? = version {return v} - return Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1() - } - set {version = .v1(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Version: Equatable { - case v1(Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version, rhs: Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.v1, .v1): return { - guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey.OneOf_Union: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacAccountLinkedKey: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacAccountLinkedKey.OneOf_Association: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacInstallationLinkedKey: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacFallbackKeyRotation: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_InstallationContactBundle: @unchecked Sendable {} -extension Xmtp_V3_MessageContents_InstallationContactBundle.OneOf_Version: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.v3.message_contents" - -extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".VmacUnsignedPublicKey" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "created_ns"), - 2: .same(proto: "curve25519"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.createdNs) }() - case 2: try { - var v: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519? - var hadOneofValue = false - if let current = self.union { - hadOneofValue = true - if case .curve25519(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.union = .curve25519(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.createdNs != 0 { - try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 1) - } - try { if case .curve25519(let v)? = self.union { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey, rhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey) -> Bool { - if lhs.createdNs != rhs.createdNs {return false} - if lhs.union != rhs.union {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_V3_MessageContents_VmacUnsignedPublicKey.protoMessageName + ".VodozemacCurve25519" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "bytes"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.bytes.isEmpty { - try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519, rhs: Xmtp_V3_MessageContents_VmacUnsignedPublicKey.VodozemacCurve25519) -> Bool { - if lhs.bytes != rhs.bytes {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_VmacAccountLinkedKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".VmacAccountLinkedKey" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "key"), - 2: .standard(proto: "eip_191"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._key) }() - case 2: try { - var v: Xmtp_V3_MessageContents_Eip191Association? - var hadOneofValue = false - if let current = self.association { - hadOneofValue = true - if case .eip191(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.association = .eip191(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._key { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if case .eip191(let v)? = self.association { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey, rhs: Xmtp_V3_MessageContents_VmacAccountLinkedKey) -> Bool { - if lhs._key != rhs._key {return false} - if lhs.association != rhs.association {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_VmacInstallationLinkedKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".VmacInstallationLinkedKey" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "key"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._key) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._key { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacInstallationLinkedKey, rhs: Xmtp_V3_MessageContents_VmacInstallationLinkedKey) -> Bool { - if lhs._key != rhs._key {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".VmacOneTimeKeyTopupBundle" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "identity_key"), - 2: .standard(proto: "one_time_keys"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._identityKey) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &self.oneTimeKeys) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._identityKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - if !self.oneTimeKeys.isEmpty { - try visitor.visitRepeatedMessageField(value: self.oneTimeKeys, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle, rhs: Xmtp_V3_MessageContents_VmacOneTimeKeyTopupBundle) -> Bool { - if lhs._identityKey != rhs._identityKey {return false} - if lhs.oneTimeKeys != rhs.oneTimeKeys {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_VmacFallbackKeyRotation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".VmacFallbackKeyRotation" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "identity_key"), - 2: .standard(proto: "fallback_key"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._identityKey) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._fallbackKey) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._identityKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._fallbackKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacFallbackKeyRotation, rhs: Xmtp_V3_MessageContents_VmacFallbackKeyRotation) -> Bool { - if lhs._identityKey != rhs._identityKey {return false} - if lhs._fallbackKey != rhs._fallbackKey {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".VmacInstallationPublicKeyBundleV1" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "identity_key"), - 2: .standard(proto: "fallback_key"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._identityKey) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._fallbackKey) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._identityKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._fallbackKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1, rhs: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1) -> Bool { - if lhs._identityKey != rhs._identityKey {return false} - if lhs._fallbackKey != rhs._fallbackKey {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_V3_MessageContents_InstallationContactBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".InstallationContactBundle" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "v1"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Xmtp_V3_MessageContents_VmacInstallationPublicKeyBundleV1? - var hadOneofValue = false - if let current = self.version { - hadOneofValue = true - if case .v1(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.version = .v1(v) - } - }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if case .v1(let v)? = self.version { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_V3_MessageContents_InstallationContactBundle, rhs: Xmtp_V3_MessageContents_InstallationContactBundle) -> Bool { - if lhs.version != rhs.version {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} From 1b9c9a042efbd554185c5e07b9f7e282508dc1d9 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 15:28:46 -0700 Subject: [PATCH 08/11] bump the pod specs for RN --- XMTP.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XMTP.podspec b/XMTP.podspec index 94de8558..8be822db 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "XMTP" - spec.version = "0.6.0-alpha0" + spec.version = "0.6.1-alpha0" spec.summary = "XMTP SDK Cocoapod" # This description is used to generate tags and improve search results. @@ -44,7 +44,7 @@ Pod::Spec.new do |spec| spec.dependency "web3.swift" spec.dependency "GzipSwift" spec.dependency "Connect-Swift" - spec.dependency 'XMTPRust', '= 0.3.5-beta0' + spec.dependency 'XMTPRust', '= 0.3.6-beta0' spec.xcconfig = {'VALID_ARCHS' => 'arm64' } end From ece91cf40c512d847beca8ff55cac4ea38548304 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 15:56:51 -0700 Subject: [PATCH 09/11] update the topic --- Sources/XMTP/Messages/Topic.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XMTP/Messages/Topic.swift b/Sources/XMTP/Messages/Topic.swift index 638434b3..d7c6275a 100644 --- a/Sources/XMTP/Messages/Topic.swift +++ b/Sources/XMTP/Messages/Topic.swift @@ -32,7 +32,7 @@ public enum Topic { case let .directMessageV2(randomString): return wrap("m-\(randomString)") case let .allowList(identifier): - return wrap("privatestore-\(identifier)/allowlist") + return wrap("pppp-\(identifier)") } } From 815c117e5b7c9e00c82aefa1b27dcfd32432688e Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 15:59:27 -0700 Subject: [PATCH 10/11] name it preference list and confirm tests still pass --- Sources/XMTP/Contacts.swift | 4 ++-- Sources/XMTP/Messages/Topic.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index 1e64142a..2f73d448 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -57,7 +57,7 @@ class AllowList { throw ContactError.invalidIdentifier } - let envelopes = try await client.query(topic: .allowList(identifier)) + let envelopes = try await client.query(topic: .preferenceList(identifier)) let allowList = AllowList(client: client) @@ -109,7 +109,7 @@ class AllowList { ) let envelope = Envelope( - topic: Topic.allowList(identifier), + topic: Topic.preferenceList(identifier), timestamp: Date(), message: Data(message) ) diff --git a/Sources/XMTP/Messages/Topic.swift b/Sources/XMTP/Messages/Topic.swift index d7c6275a..fde788f7 100644 --- a/Sources/XMTP/Messages/Topic.swift +++ b/Sources/XMTP/Messages/Topic.swift @@ -14,7 +14,7 @@ public enum Topic { userInvite(String), directMessageV1(String, String), directMessageV2(String), - allowList(String) + preferenceList(String) var description: String { switch self { @@ -31,7 +31,7 @@ public enum Topic { return wrap("dm-\(addresses)") case let .directMessageV2(randomString): return wrap("m-\(randomString)") - case let .allowList(identifier): + case let .preferenceList(identifier): return wrap("pppp-\(identifier)") } } From 3ecba27866e0870af21a3f5244fc60da266c21e4 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 16:03:33 -0700 Subject: [PATCH 11/11] fix the linter issue --- Sources/XMTP/Contacts.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/XMTP/Contacts.swift b/Sources/XMTP/Contacts.swift index 2f73d448..c3704471 100644 --- a/Sources/XMTP/Contacts.swift +++ b/Sources/XMTP/Contacts.swift @@ -49,7 +49,9 @@ class AllowList { self.client = client self.privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes self.publicKey = client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes + // swiftlint:disable no_optional_try self.identifier = try? XMTPRust.generate_private_preferences_topic_identifier(RustVec(privateKey)).toString() + // swiftlint:enable no_optional_try } func load() async throws -> AllowList {