diff --git a/.gitignore b/.gitignore
index 9a09962f..aa13e2fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+XMTPiOSExample/Pods/
+XMTPiOSExample/build
+
.DS_Store
/.build
/Packages
@@ -8,5 +11,5 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
-Package.resolved
.vscode
+XMTPiOSExample/Pods
diff --git a/.swiftlint.yml b/.swiftlint.yml
index f102816c..26470bdb 100644
--- a/.swiftlint.yml
+++ b/.swiftlint.yml
@@ -1,3 +1,6 @@
+excluded:
+ - Sources/XMTP/Proto
+
disabled_rules: # rule identifiers turned on by default to exclude from running
- type_name
- identifier_name
diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/XMTP.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/XMTP.xcscheme
index e8eb1fcd..2a93911e 100644
--- a/.swiftpm/xcode/xcshareddata/xcschemes/XMTP.xcscheme
+++ b/.swiftpm/xcode/xcshareddata/xcschemes/XMTP.xcscheme
@@ -70,14 +70,24 @@
+
+
+
+
QueryResponse
func query(topic: Topic, pagination: Pagination?) async throws -> QueryResponse
@@ -30,25 +30,71 @@ class GRPCApiClient: ApiClient {
var environment: XMTPEnvironment
var authToken = ""
- private var client: Xmtp_MessageApi_V1_MessageApiAsyncClient!
+ var rustClient: XMTPRust.RustClient
- required init(environment: XMTPEnvironment, secure: Bool = true) throws {
+ required init(environment: XMTPEnvironment, secure _: Bool = true, rustClient: XMTPRust.RustClient) throws {
self.environment = environment
- let group = PlatformSupport.makeEventLoopGroup(loopCount: 1)
-
- let config = GRPCTLSConfiguration.makeClientConfigurationBackedByNIOSSL()
- let channel = try GRPCChannelPool.with(
- target: .host(environment.rawValue, port: 5556),
- transportSecurity: secure ? .tls(config) : .plaintext,
- eventLoopGroup: group
- )
+ self.rustClient = rustClient
+ }
- client = Xmtp_MessageApi_V1_MessageApiAsyncClient(channel: channel)
+ static func envToUrl(env: XMTPEnvironment) -> String {
+ switch env {
+ case XMTPEnvironment.local: return "http://localhost:5556"
+ case XMTPEnvironment.dev: return "https://dev.xmtp.network:5556"
+ case XMTPEnvironment.production: return "https://xmtp.network:5556"
+ }
}
func setAuthToken(_ token: String) {
authToken = token
}
+
+ func rustPagingInfoFromRequest(request: Xmtp_MessageApi_V1_QueryRequest) -> XMTPRust.PagingInfo {
+ var rustPaging = XMTPRust.PagingInfo(limit: 0, cursor: nil, direction: XMTPRust.SortDirection.Ascending)
+ rustPaging.limit = request.pagingInfo.limit
+ if request.hasPagingInfo && request.pagingInfo.hasCursor {
+ let cursor = request.pagingInfo.cursor;
+ let digest = RustVec(cursor.index.digest)
+ let senderTimeNs = cursor.index.senderTimeNs
+ rustPaging.cursor = XMTPRust.IndexCursor(digest: digest, sender_time_ns: senderTimeNs)
+ }
+
+ // Set rustPaging.direction based off a switch-case conversion
+ switch request.pagingInfo.direction {
+ case .ascending:
+ rustPaging.direction = XMTPRust.SortDirection.Ascending
+ case .descending:
+ rustPaging.direction = XMTPRust.SortDirection.Descending
+ case .unspecified:
+ rustPaging.direction = XMTPRust.SortDirection.Unspecified
+ case .UNRECOGNIZED(_):
+ rustPaging.direction = XMTPRust.SortDirection.Unspecified
+ }
+
+ return rustPaging;
+ }
+
+ func parseRustPagingInfoFromResponse(response: XMTPRust.QueryResponse) -> PagingInfo {
+ var pagingInfo = PagingInfo()
+ if let rustPaging = response.paging_info() {
+ pagingInfo.limit = rustPaging.limit
+ if let rustCursor = rustPaging.cursor {
+ var cursor = PagingInfoCursor()
+ cursor.index.digest = Data(rustCursor.digest)
+ cursor.index.senderTimeNs = rustCursor.sender_time_ns
+ pagingInfo.cursor = cursor
+ }
+ switch rustPaging.direction {
+ case XMTPRust.SortDirection.Ascending:
+ pagingInfo.direction = .ascending
+ case XMTPRust.SortDirection.Descending:
+ pagingInfo.direction = .descending
+ case XMTPRust.SortDirection.Unspecified:
+ pagingInfo.direction = .unspecified
+ }
+ }
+ return pagingInfo
+ }
func query(topic: String, pagination: Pagination? = nil, cursor: Xmtp_MessageApi_V1_Cursor? = nil) async throws -> QueryResponse {
var request = Xmtp_MessageApi_V1_QueryRequest()
@@ -72,11 +118,25 @@ class GRPCApiClient: ApiClient {
request.pagingInfo.cursor = cursor
}
- var options = CallOptions()
- options.customMetadata.add(name: "authorization", value: "Bearer \(authToken)")
- options.timeLimit = .timeout(.seconds(5))
-
- return try await client.query(request, callOptions: options)
+
+ let startTimeParam: UInt64? = pagination == nil ? nil : request.startTimeNs
+ let endTimeParam: UInt64? = pagination == nil ? nil : request.endTimeNs
+ let rustPagingInfo = rustPagingInfoFromRequest(request: request)
+ let response = try await rustClient.query(topic.intoRustString(), startTimeParam, endTimeParam, rustPagingInfo)
+ // response has .envelopes() and .paging_info() but the envelopes need to be mapped into Envelope objects that Swift understands
+ var queryResponse = QueryResponse()
+ // Build the query response from response fields
+ queryResponse.envelopes = response.envelopes().map { rustEnvelope in
+ var envelope = Envelope()
+ envelope.contentTopic = rustEnvelope.get_topic().toString()
+ envelope.timestampNs = rustEnvelope.get_sender_time_ns()
+ envelope.message = Data(rustEnvelope.get_payload())
+ return envelope
+ }
+ if let _ = response.paging_info() {
+ queryResponse.pagingInfo = parseRustPagingInfoFromResponse(response: response)
+ }
+ return queryResponse
}
func envelopes(topic: String, pagination: Pagination? = nil) async throws -> [Envelope] {
@@ -103,11 +163,22 @@ class GRPCApiClient: ApiClient {
func subscribe(topics: [String]) -> AsyncThrowingStream {
return AsyncThrowingStream { continuation in
Task {
- var request = SubscribeRequest()
- request.contentTopics = topics
-
- for try await envelope in self.client.subscribe(request) {
- continuation.yield(envelope)
+ let topicsVec = RustVec()
+ for topic in topics {
+ topicsVec.push(value: topic.intoRustString())
+ }
+ let subscription = try await self.rustClient.subscribe(topicsVec)
+ // Run a continuous for loop polling subscription.get_messages() and then waiting for 2 seconds
+ while true {
+ let rustEnvelopes = try subscription.get_messages()
+ for rustEnvelope in rustEnvelopes {
+ var swiftEnvelope = Envelope()
+ swiftEnvelope.contentTopic = rustEnvelope.get_topic().toString()
+ swiftEnvelope.timestampNs = rustEnvelope.get_sender_time_ns()
+ swiftEnvelope.message = Data(rustEnvelope.get_payload())
+ continuation.yield(swiftEnvelope)
+ }
+ try await Task.sleep(nanoseconds: 50_000_000) // 50ms
}
}
}
@@ -117,12 +188,15 @@ class GRPCApiClient: ApiClient {
var request = Xmtp_MessageApi_V1_PublishRequest()
request.envelopes = envelopes
- var options = CallOptions()
- options.customMetadata.add(name: "authorization", value: "Bearer \(authToken)")
- options.customMetadata.add(name: ClientVersionHeaderKey, value: Constants.version)
- options.customMetadata.add(name: AppVersionHeaderKey, value: Constants.version)
- options.timeLimit = .timeout(.seconds(5))
+ let envelopesVec = RustVec()
- return try await client.publish(request, callOptions: options)
+ envelopes.forEach { envelope in
+ let rustEnvelope = XMTPRust.create_envelope(envelope.contentTopic.intoRustString(), envelope.timestampNs, RustVec(envelope.message))
+ envelopesVec.push(value: rustEnvelope)
+ }
+ let _ = try await rustClient.publish(authToken.intoRustString(), envelopesVec)
+ // NOTE: PublishResponse proto has no fields
+ let publishResponse = PublishResponse()
+ return publishResponse
}
}
diff --git a/Sources/XMTP/Client.swift b/Sources/XMTP/Client.swift
index 9111ab8e..69211fe4 100644
--- a/Sources/XMTP/Client.swift
+++ b/Sources/XMTP/Client.swift
@@ -6,9 +6,8 @@
//
import Foundation
-import GRPC
import web3
-import XMTPProto
+import XMTPRust
/// Specify configuration options for creating a ``Client``.
public struct ClientOptions {
@@ -74,9 +73,11 @@ public class Client {
public static func create(account: SigningKey, options: ClientOptions? = nil) async throws -> Client {
let options = options ?? ClientOptions()
+ let client = try await XMTPRust.create_client(GRPCApiClient.envToUrl(env: options.api.env), options.api.env != .local)
let apiClient = try GRPCApiClient(
environment: options.api.env,
- secure: options.api.isSecure
+ secure: options.api.isSecure,
+ rustClient: client
)
return try await create(account: account, apiClient: apiClient)
@@ -95,7 +96,7 @@ public class Client {
// swiftlint:disable no_optional_try
if let keys = try await loadPrivateKeys(for: account, apiClient: apiClient) {
// swiftlint:enable no_optional_try
-
+ print("loading existing private keys.")
#if DEBUG
print("Loaded existing private keys.")
#endif
@@ -112,10 +113,8 @@ public class Client {
var authorizedIdentity = AuthorizedIdentity(privateKeyBundleV1: keys)
authorizedIdentity.address = account.address
let authToken = try await authorizedIdentity.createAuthToken()
-
let apiClient = apiClient
apiClient.setAuthToken(authToken)
-
_ = try await apiClient.publish(envelopes: [
Envelope(topic: .userPrivateStoreKeyBundle(account.address), timestamp: Date(), message: try encryptedKeys.serializedData()),
])
@@ -139,19 +138,21 @@ public class Client {
return nil
}
- public static func from(bundle: PrivateKeyBundle, options: ClientOptions? = nil) throws -> Client {
- return try from(v1Bundle: bundle.v1, options: options)
+ public static func from(bundle: PrivateKeyBundle, options: ClientOptions? = nil) async throws -> Client {
+ return try await from(v1Bundle: bundle.v1, options: options)
}
/// Create a Client from saved v1 key bundle.
- public static func from(v1Bundle: PrivateKeyBundleV1, options: ClientOptions? = nil) throws -> Client {
+ public static func from(v1Bundle: PrivateKeyBundleV1, options: ClientOptions? = nil) async throws -> Client {
let address = try v1Bundle.identityKey.publicKey.recoverWalletSignerPublicKey().walletAddress
let options = options ?? ClientOptions()
+ let client = try await XMTPRust.create_client(GRPCApiClient.envToUrl(env: options.api.env), options.api.env != .local)
let apiClient = try GRPCApiClient(
environment: options.api.env,
- secure: options.api.isSecure
+ secure: options.api.isSecure,
+ rustClient: client
)
return try Client(address: address, privateKeyBundleV1: v1Bundle, apiClient: apiClient)
diff --git a/Sources/XMTP/Codecs/AttachmentCodec.swift b/Sources/XMTP/Codecs/AttachmentCodec.swift
index aea24406..4bb8e1ab 100644
--- a/Sources/XMTP/Codecs/AttachmentCodec.swift
+++ b/Sources/XMTP/Codecs/AttachmentCodec.swift
@@ -5,7 +5,6 @@
// Created by Pat on 2/14/23.
//
import Foundation
-import XMTPProto
public let ContentTypeAttachment = ContentTypeID(authorityID: "xmtp.org", typeID: "attachment", versionMajor: 1, versionMinor: 0)
diff --git a/Sources/XMTP/Codecs/Composite.swift b/Sources/XMTP/Codecs/Composite.swift
index 8b5ad72e..044d8654 100644
--- a/Sources/XMTP/Codecs/Composite.swift
+++ b/Sources/XMTP/Codecs/Composite.swift
@@ -5,8 +5,6 @@
// Created by Pat Nakajima on 12/22/22.
//
-import XMTPProto
-
typealias Composite = Xmtp_MessageContents_Composite
let ContentTypeComposite = ContentTypeID(authorityID: "xmtp.org", typeID: "composite", versionMajor: 1, versionMinor: 0)
diff --git a/Sources/XMTP/Codecs/ContentCodec.swift b/Sources/XMTP/Codecs/ContentCodec.swift
index c6512983..c8feac96 100644
--- a/Sources/XMTP/Codecs/ContentCodec.swift
+++ b/Sources/XMTP/Codecs/ContentCodec.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
enum CodecError: String, Error {
case invalidContent, codecNotFound
diff --git a/Sources/XMTP/Codecs/ContentTypeID.swift b/Sources/XMTP/Codecs/ContentTypeID.swift
index d7fa062a..e55cb16d 100644
--- a/Sources/XMTP/Codecs/ContentTypeID.swift
+++ b/Sources/XMTP/Codecs/ContentTypeID.swift
@@ -5,8 +5,6 @@
// Created by Pat Nakajima on 11/28/22.
//
-import XMTPProto
-
public typealias ContentTypeID = Xmtp_MessageContents_ContentTypeId
public extension ContentTypeID {
diff --git a/Sources/XMTP/Codecs/RemoteAttachmentCodec.swift b/Sources/XMTP/Codecs/RemoteAttachmentCodec.swift
index e966a777..5ea0385f 100644
--- a/Sources/XMTP/Codecs/RemoteAttachmentCodec.swift
+++ b/Sources/XMTP/Codecs/RemoteAttachmentCodec.swift
@@ -8,7 +8,6 @@
import CryptoKit
import Foundation
import web3
-import XMTPProto
public let ContentTypeRemoteAttachment = ContentTypeID(authorityID: "xmtp.org", typeID: "remoteStaticAttachment", versionMajor: 1, versionMinor: 0)
diff --git a/Sources/XMTP/Codecs/TextCodec.swift b/Sources/XMTP/Codecs/TextCodec.swift
index 4297dc62..5e5f7495 100644
--- a/Sources/XMTP/Codecs/TextCodec.swift
+++ b/Sources/XMTP/Codecs/TextCodec.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
public let ContentTypeText = ContentTypeID(authorityID: "xmtp.org", typeID: "text", versionMajor: 1, versionMinor: 0)
diff --git a/Sources/XMTP/Conversation.swift b/Sources/XMTP/Conversation.swift
index a0943088..c8a20b24 100644
--- a/Sources/XMTP/Conversation.swift
+++ b/Sources/XMTP/Conversation.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
public enum ConversationContainer: Codable {
case v1(ConversationV1Container), v2(ConversationV2Container)
diff --git a/Sources/XMTP/ConversationExport.swift b/Sources/XMTP/ConversationExport.swift
index 61b072a0..f09450e0 100644
--- a/Sources/XMTP/ConversationExport.swift
+++ b/Sources/XMTP/ConversationExport.swift
@@ -5,8 +5,6 @@
// Created by Pat Nakajima on 2/1/23.
//
-import XMTPProto
-
enum ConversationImportError: Error {
case invalidData
}
diff --git a/Sources/XMTP/ConversationV2.swift b/Sources/XMTP/ConversationV2.swift
index a6524cb8..fe571825 100644
--- a/Sources/XMTP/ConversationV2.swift
+++ b/Sources/XMTP/ConversationV2.swift
@@ -7,7 +7,6 @@
import CryptoKit
import Foundation
-import XMTPProto
// Save the non-client parts for a v2 conversation
public struct ConversationV2Container: Codable {
@@ -39,7 +38,7 @@ public struct ConversationV2 {
let peer = try myKeys.walletAddress == (try header.sender.walletAddress) ? header.recipient : header.sender
let peerAddress = try peer.walletAddress
- let keyMaterial = Data(invitation.aes256GcmHkdfSha256.keyMaterial.bytes)
+ let keyMaterial = Data(invitation.aes256GcmHkdfSha256.keyMaterial)
return ConversationV2(
topic: invitation.topic,
diff --git a/Sources/XMTP/Conversations.swift b/Sources/XMTP/Conversations.swift
index 3c81dd3a..06841912 100644
--- a/Sources/XMTP/Conversations.swift
+++ b/Sources/XMTP/Conversations.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
public enum ConversationError: Error {
case recipientNotOnNetwork, recipientIsSender, v1NotSupported(String)
diff --git a/Sources/XMTP/Crypto.swift b/Sources/XMTP/Crypto.swift
index 4dc7af41..4adebbd3 100644
--- a/Sources/XMTP/Crypto.swift
+++ b/Sources/XMTP/Crypto.swift
@@ -7,7 +7,6 @@
import CryptoKit
import Foundation
-import XMTPProto
public typealias CipherText = Xmtp_MessageContents_Ciphertext
@@ -36,8 +35,14 @@ enum Crypto {
}
var ciphertext = CipherText()
-
- ciphertext.aes256GcmHkdfSha256.payload = payload.ciphertext + payload.tag
+ // Copy the ciphertext data out, otherwise it's a region sliced from a combined Data (nonce, ciphertext, tag)
+ // with offsets like lowerBound=12, upperBound=224. Without copying, trying to index like payload[0] crashes
+ // up until payload[12]. This is mostly a problem for unit tests where we decrypt what we encrypt in memory, as
+ // serialization/deserialization acts as copying and avoids this issue.
+ var payloadData = Data(payload.ciphertext.subdata(in: 12 ..< payload.ciphertext.count+12))
+ let startTag = 12 + payload.ciphertext.count
+ payloadData.append(payload.tag.subdata(in: startTag ..< startTag + payload.tag.count))
+ ciphertext.aes256GcmHkdfSha256.payload = payloadData
ciphertext.aes256GcmHkdfSha256.hkdfSalt = salt
ciphertext.aes256GcmHkdfSha256.gcmNonce = nonceData
@@ -48,11 +53,11 @@ enum Crypto {
let salt = ciphertext.aes256GcmHkdfSha256.hkdfSalt
let nonceData = ciphertext.aes256GcmHkdfSha256.gcmNonce
let nonce = try AES.GCM.Nonce(data: nonceData)
- let payload = ciphertext.aes256GcmHkdfSha256.payload.bytes
+ let payload = ciphertext.aes256GcmHkdfSha256.payload
- let ciphertext = payload[0 ..< payload.count - 16]
+ let ciphertextBytes = payload[0 ..< payload.count - 16]
let tag = payload[payload.count - 16 ..< payload.count]
- let box = try AES.GCM.SealedBox(nonce: nonce, ciphertext: ciphertext, tag: tag)
+ let box = try AES.GCM.SealedBox(nonce: nonce, ciphertext: ciphertextBytes, tag: tag)
let resultKey = HKDF.deriveKey(
inputKeyMaterial: SymmetricKey(data: secret),
diff --git a/Sources/XMTP/Extensions/Data.swift b/Sources/XMTP/Extensions/Data.swift
index e2bbdba3..5d2ba4fc 100644
--- a/Sources/XMTP/Extensions/Data.swift
+++ b/Sources/XMTP/Extensions/Data.swift
@@ -6,12 +6,17 @@
//
import Foundation
+import XMTPRust
extension Data {
init?(base64String: String) {
self.init(base64Encoded: Data(base64String.utf8))
}
+ init(_ rustVec: RustVec) {
+ self.init(rustVec.map { $0 })
+ }
+
var toHex: String {
return reduce("") { $0 + String(format: "%02x", $1) }
}
diff --git a/Sources/XMTP/Extensions/RustVec.swift b/Sources/XMTP/Extensions/RustVec.swift
new file mode 100644
index 00000000..f63d1f7d
--- /dev/null
+++ b/Sources/XMTP/Extensions/RustVec.swift
@@ -0,0 +1,19 @@
+//
+// File.swift
+//
+//
+// Created by Pat Nakajima on 4/24/23.
+//
+
+import Foundation
+import XMTPRust
+
+extension RustVec where T == UInt8 {
+ convenience init(_ data: Data) {
+ self.init()
+
+ for byte in data {
+ push(value: byte)
+ }
+ }
+}
diff --git a/Sources/XMTP/KeyUtil.swift b/Sources/XMTP/KeyUtil.swift
index 9dcf40f6..dff570ba 100644
--- a/Sources/XMTP/KeyUtil.swift
+++ b/Sources/XMTP/KeyUtil.swift
@@ -6,6 +6,7 @@ import Foundation
import Logging
import secp256k1
import web3
+import XMTPRust
enum KeyUtilError: Error {
case invalidContext
@@ -18,19 +19,24 @@ enum KeyUtilError: Error {
}
// Copied from web3.swift since its version is `internal`
-enum KeyUtil {
- private static var logger: Logger {
- Logger(label: "web3.swift.key-util")
+enum KeyUtilx {
+ static func generatePublicKey(from data: Data) throws -> Data {
+ let vec = try XMTPRust.public_key_from_private_key_k256(RustVec(data))
+ return Data(vec)
}
- static func generatePublicKey(from privateKeyData: Data) throws -> Data {
- let privateKey = try secp256k1.Signing.PrivateKey(rawRepresentation: privateKeyData, format: .uncompressed)
- return privateKey.publicKey.rawRepresentation
+ static func recoverPublicKeySHA256(from data: Data, message: Data) throws -> Data {
+ let vec = try XMTPRust.recover_public_key_k256_sha256(RustVec(message), RustVec(data))
+ return Data(vec)
+ }
+
+ static func recoverPublicKeyKeccak256(from data: Data, message: Data) throws -> Data {
+ let vec = try XMTPRust.recover_public_key_k256_keccak256(RustVec(message), RustVec(data))
+ return Data(vec)
}
static func sign(message: Data, with privateKey: Data, hashing: Bool) throws -> Data {
guard let ctx = secp256k1_context_create(UInt32(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY)) else {
- logger.warning("Failed to sign message: invalid context.")
throw KeyUtilError.invalidContext
}
@@ -46,7 +52,6 @@ enum KeyUtil {
signaturePtr.deallocate()
}
guard secp256k1_ecdsa_sign_recoverable(ctx, signaturePtr, msg, privateKeyPtr, nil, nil) == 1 else {
- logger.warning("Failed to sign message: recoverable ECDSA signature creation failed.")
throw KeyUtilError.signatureFailure
}
@@ -79,7 +84,6 @@ enum KeyUtil {
static func recoverPublicKey(message: Data, signature: Data) throws -> Data {
guard let ctx = secp256k1_context_create(UInt32(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY)) else {
- logger.warning("Failed to sign message: invalid context.")
throw KeyUtilError.invalidContext
}
defer { secp256k1_context_destroy(ctx) }
@@ -101,7 +105,6 @@ enum KeyUtil {
// swiftlint:disable force_unwrapping
try serializedSignature.withUnsafeBytes {
guard secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, signaturePtr, $0.bindMemory(to: UInt8.self).baseAddress!, v) == 1 else {
- logger.warning("Failed to parse signature: recoverable ECDSA signature parse failed.")
throw KeyUtilError.signatureParseFailure
}
}
diff --git a/Sources/XMTP/Messages/AuthData.swift b/Sources/XMTP/Messages/AuthData.swift
index dd5e4bdb..bc5207b7 100644
--- a/Sources/XMTP/Messages/AuthData.swift
+++ b/Sources/XMTP/Messages/AuthData.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
typealias AuthData = Xmtp_MessageApi_V1_AuthData
diff --git a/Sources/XMTP/Messages/ContactBundle.swift b/Sources/XMTP/Messages/ContactBundle.swift
index ce364795..267ac63d 100644
--- a/Sources/XMTP/Messages/ContactBundle.swift
+++ b/Sources/XMTP/Messages/ContactBundle.swift
@@ -5,7 +5,8 @@
// Created by Pat Nakajima on 11/23/22.
//
-import XMTPProto
+import web3
+import XMTPRust
typealias ContactBundle = Xmtp_MessageContents_ContactBundle
typealias ContactBundleV1 = Xmtp_MessageContents_ContactBundleV1
@@ -62,13 +63,13 @@ extension ContactBundle {
switch version {
case .v1:
if let key = try? v1.keyBundle.identityKey.recoverWalletSignerPublicKey() {
- return KeyUtil.generateAddress(from: key.secp256K1Uncompressed.bytes).toChecksumAddress()
+ return KeyUtilx.generateAddress(from: key.secp256K1Uncompressed.bytes).toChecksumAddress()
}
return nil
case .v2:
if let key = try? v2.keyBundle.identityKey.recoverWalletSignerPublicKey() {
- return KeyUtil.generateAddress(from: key.secp256K1Uncompressed.bytes).toChecksumAddress()
+ return KeyUtilx.generateAddress(from: key.secp256K1Uncompressed.bytes).toChecksumAddress()
}
return nil
diff --git a/Sources/XMTP/Messages/EncryptedPrivateKeyBundle.swift b/Sources/XMTP/Messages/EncryptedPrivateKeyBundle.swift
index 448b10f2..54ab6a5a 100644
--- a/Sources/XMTP/Messages/EncryptedPrivateKeyBundle.swift
+++ b/Sources/XMTP/Messages/EncryptedPrivateKeyBundle.swift
@@ -5,8 +5,6 @@
// Created by Pat Nakajima on 11/17/22.
//
-import XMTPProto
-
typealias EncryptedPrivateKeyBundle = Xmtp_MessageContents_EncryptedPrivateKeyBundle
extension EncryptedPrivateKeyBundle {
diff --git a/Sources/XMTP/Messages/Envelope.swift b/Sources/XMTP/Messages/Envelope.swift
index 1c7a799b..8b04e281 100644
--- a/Sources/XMTP/Messages/Envelope.swift
+++ b/Sources/XMTP/Messages/Envelope.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
public typealias Envelope = Xmtp_MessageApi_V1_Envelope
diff --git a/Sources/XMTP/Messages/Invitation.swift b/Sources/XMTP/Messages/Invitation.swift
index ac5dd322..54d57722 100644
--- a/Sources/XMTP/Messages/Invitation.swift
+++ b/Sources/XMTP/Messages/Invitation.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
/// Handles topic generation for conversations.
public typealias InvitationV1 = Xmtp_MessageContents_InvitationV1
diff --git a/Sources/XMTP/Messages/Message.swift b/Sources/XMTP/Messages/Message.swift
index 0fda2f65..ff2613b4 100644
--- a/Sources/XMTP/Messages/Message.swift
+++ b/Sources/XMTP/Messages/Message.swift
@@ -5,8 +5,6 @@
// Created by Pat Nakajima on 11/27/22.
//
-import XMTPProto
-
/// Handles encryption/decryption for communicating data in conversations
public typealias Message = Xmtp_MessageContents_Message
diff --git a/Sources/XMTP/Messages/MessageHeaderV1.swift b/Sources/XMTP/Messages/MessageHeaderV1.swift
index 6b998f55..25c3682f 100644
--- a/Sources/XMTP/Messages/MessageHeaderV1.swift
+++ b/Sources/XMTP/Messages/MessageHeaderV1.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
typealias MessageHeaderV1 = Xmtp_MessageContents_MessageHeaderV1
diff --git a/Sources/XMTP/Messages/MessageHeaderV2.swift b/Sources/XMTP/Messages/MessageHeaderV2.swift
index ea707044..d967525e 100644
--- a/Sources/XMTP/Messages/MessageHeaderV2.swift
+++ b/Sources/XMTP/Messages/MessageHeaderV2.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
typealias MessageHeaderV2 = Xmtp_MessageContents_MessageHeaderV2
diff --git a/Sources/XMTP/Messages/MessageV1.swift b/Sources/XMTP/Messages/MessageV1.swift
index 6cc5928e..6a075ca7 100644
--- a/Sources/XMTP/Messages/MessageV1.swift
+++ b/Sources/XMTP/Messages/MessageV1.swift
@@ -6,7 +6,6 @@
//
import Foundation
-import XMTPProto
typealias MessageV1 = Xmtp_MessageContents_MessageV1
diff --git a/Sources/XMTP/Messages/MessageV2.swift b/Sources/XMTP/Messages/MessageV2.swift
index a905c20c..9fb0a772 100644
--- a/Sources/XMTP/Messages/MessageV2.swift
+++ b/Sources/XMTP/Messages/MessageV2.swift
@@ -7,7 +7,7 @@
import CryptoKit
import Foundation
-import XMTPProto
+import XMTPRust
typealias MessageV2 = Xmtp_MessageContents_MessageV2
@@ -41,10 +41,8 @@ extension MessageV2 {
}
// Verify content signature
- let digest = SHA256.hash(data: message.headerBytes + signed.payload)
-
let key = try PublicKey.with { key in
- key.secp256K1Uncompressed.bytes = try KeyUtil.recoverPublicKey(message: Data(digest.bytes), signature: signed.signature.rawData)
+ key.secp256K1Uncompressed.bytes = try KeyUtilx.recoverPublicKeySHA256(from: signed.signature.rawData, message: Data(message.headerBytes + signed.payload))
}
if key.walletAddress != (try PublicKey(signed.sender.preKey).walletAddress) {
diff --git a/Sources/XMTP/Messages/PagingInfo.swift b/Sources/XMTP/Messages/PagingInfo.swift
index cdde34d8..8d74e797 100644
--- a/Sources/XMTP/Messages/PagingInfo.swift
+++ b/Sources/XMTP/Messages/PagingInfo.swift
@@ -6,13 +6,12 @@
//
import Foundation
-import XMTPProto
typealias PagingInfo = Xmtp_MessageApi_V1_PagingInfo
typealias PagingInfoCursor = Xmtp_MessageApi_V1_Cursor
typealias PagingInfoSortDirection = Xmtp_MessageApi_V1_SortDirection
-struct Pagination {
+public struct Pagination {
var limit: Int?
var direction: PagingInfoSortDirection?
var startTime: Date?
diff --git a/Sources/XMTP/Messages/PrivateKey.swift b/Sources/XMTP/Messages/PrivateKey.swift
index 282f61e5..35e7a3a3 100644
--- a/Sources/XMTP/Messages/PrivateKey.swift
+++ b/Sources/XMTP/Messages/PrivateKey.swift
@@ -6,8 +6,8 @@
//
import Foundation
-import secp256k1
-import XMTPProto
+import XMTPRust
+import CryptoKit
/// Represents a secp256k1 private key. ``PrivateKey`` conforms to ``SigningKey`` so you can use it
/// to create a ``Client``.
@@ -31,7 +31,7 @@ extension PrivateKey: SigningKey {
}
public func sign(_ data: Data) async throws -> Signature {
- let signatureData = try KeyUtil.sign(message: data, with: secp256K1.bytes, hashing: false)
+ let signatureData = try KeyUtilx.sign(message: data, with: secp256K1.bytes, hashing: false)
var signature = Signature()
signature.ecdsaCompact.bytes = signatureData[0 ..< 64]
@@ -54,7 +54,7 @@ public extension PrivateKey {
timestamp = UInt64(Date().millisecondsSinceEpoch)
secp256K1.bytes = privateKeyData
- let publicData = try KeyUtil.generatePublicKey(from: privateKeyData)
+ let publicData = try KeyUtilx.generatePublicKey(from: privateKeyData)
publicKey.secp256K1Uncompressed.bytes = publicData
publicKey.timestamp = timestamp
}
@@ -78,7 +78,7 @@ public extension PrivateKey {
internal func sign(key: UnsignedPublicKey) async throws -> SignedPublicKey {
let bytes = try key.serializedData()
let digest = SHA256.hash(data: bytes)
- let signature = try await sign(Data(digest.bytes))
+ let signature = try await sign(Data(digest))
var signedPublicKey = SignedPublicKey()
signedPublicKey.signature = signature
diff --git a/Sources/XMTP/Messages/PrivateKeyBundle.swift b/Sources/XMTP/Messages/PrivateKeyBundle.swift
index b1b785ca..96331dd9 100644
--- a/Sources/XMTP/Messages/PrivateKeyBundle.swift
+++ b/Sources/XMTP/Messages/PrivateKeyBundle.swift
@@ -6,7 +6,7 @@
//
import Foundation
-import XMTPProto
+
public typealias PrivateKeyBundle = Xmtp_MessageContents_PrivateKeyBundle
diff --git a/Sources/XMTP/Messages/PrivateKeyBundleV1.swift b/Sources/XMTP/Messages/PrivateKeyBundleV1.swift
index 5185a510..5161f1d3 100644
--- a/Sources/XMTP/Messages/PrivateKeyBundleV1.swift
+++ b/Sources/XMTP/Messages/PrivateKeyBundleV1.swift
@@ -7,7 +7,8 @@
import CryptoKit
import Foundation
-import XMTPProto
+import XMTPRust
+
public typealias PrivateKeyBundleV1 = Xmtp_MessageContents_PrivateKeyBundleV1
diff --git a/Sources/XMTP/Messages/PrivateKeyBundleV2.swift b/Sources/XMTP/Messages/PrivateKeyBundleV2.swift
index a1544568..031642b9 100644
--- a/Sources/XMTP/Messages/PrivateKeyBundleV2.swift
+++ b/Sources/XMTP/Messages/PrivateKeyBundleV2.swift
@@ -6,8 +6,7 @@
//
import Foundation
-import secp256k1
-import XMTPProto
+import XMTPRust
public typealias PrivateKeyBundleV2 = Xmtp_MessageContents_PrivateKeyBundleV2
@@ -35,11 +34,7 @@ extension PrivateKeyBundleV2 {
}
func sharedSecret(private privateData: Data, public publicData: Data) throws -> Data {
- let publicKey = try secp256k1.Signing.PublicKey(rawRepresentation: publicData, format: .uncompressed)
-
- let sharedSecret = try publicKey.multiply(privateData.bytes, format: .uncompressed)
-
- return sharedSecret.rawRepresentation
+ return Data(try XMTPRust.diffie_hellman_k256(RustVec(privateData), RustVec(publicData)))
}
func findPreKey(_ myPreKey: SignedPublicKey) throws -> SignedPrivateKey {
diff --git a/Sources/XMTP/Messages/PublicKey.swift b/Sources/XMTP/Messages/PublicKey.swift
index 6ea5d844..6a3f7d79 100644
--- a/Sources/XMTP/Messages/PublicKey.swift
+++ b/Sources/XMTP/Messages/PublicKey.swift
@@ -6,13 +6,15 @@
//
import Foundation
-import secp256k1
-import XMTPProto
+
+import XMTPRust
+import web3
+import CryptoKit
typealias PublicKey = Xmtp_MessageContents_PublicKey
enum PublicKeyError: String, Error {
- case noSignature, invalidPreKey, addressNotFound
+ case noSignature, invalidPreKey, addressNotFound, invalidKeyString
}
extension PublicKey {
@@ -46,6 +48,16 @@ extension PublicKey {
secp256K1Uncompressed.bytes = data
}
+ init(_ string: String) throws {
+ self.init()
+
+ guard let bytes = string.web3.bytesFromHex else {
+ throw PublicKeyError.invalidKeyString
+ }
+
+ try self.init(Data(bytes))
+ }
+
func recoverWalletSignerPublicKey() throws -> PublicKey {
if !hasSignature {
throw PublicKeyError.noSignature
@@ -56,9 +68,9 @@ extension PublicKey {
slimKey.secp256K1Uncompressed.bytes = secp256K1Uncompressed.bytes
let sigText = Signature.createIdentityText(key: try slimKey.serializedData())
- let sigHash = try Signature.ethHash(sigText)
+ let message = try Signature.ethPersonalMessage(sigText)
- let pubKeyData = try KeyUtil.recoverPublicKey(message: sigHash, signature: signature.rawData)
+ let pubKeyData = try KeyUtilx.recoverPublicKeyKeccak256(from: signature.rawData, message: message)
return try PublicKey(pubKeyData)
}
@@ -73,11 +85,11 @@ extension PublicKey {
slimKey.timestamp = timestamp
let bytesToSign = try slimKey.serializedData()
- let pubKeyData = try KeyUtil.recoverPublicKey(message: Data(SHA256.hash(data: bytesToSign)), signature: signature.rawData)
+ let pubKeyData = try KeyUtilx.recoverPublicKeySHA256(from: signature.rawData, message: bytesToSign)
return try PublicKey(pubKeyData)
}
var walletAddress: String {
- KeyUtil.generateAddress(from: secp256K1Uncompressed.bytes).toChecksumAddress()
+ KeyUtilx.generateAddress(from: secp256K1Uncompressed.bytes).toChecksumAddress()
}
}
diff --git a/Sources/XMTP/Messages/PublicKeyBundle.swift b/Sources/XMTP/Messages/PublicKeyBundle.swift
index 518f71b3..23691789 100644
--- a/Sources/XMTP/Messages/PublicKeyBundle.swift
+++ b/Sources/XMTP/Messages/PublicKeyBundle.swift
@@ -5,7 +5,7 @@
// Created by Pat Nakajima on 11/23/22.
//
-import XMTPProto
+
typealias PublicKeyBundle = Xmtp_MessageContents_PublicKeyBundle
diff --git a/Sources/XMTP/Messages/SealedInvitation.swift b/Sources/XMTP/Messages/SealedInvitation.swift
index c90d75a1..635df583 100644
--- a/Sources/XMTP/Messages/SealedInvitation.swift
+++ b/Sources/XMTP/Messages/SealedInvitation.swift
@@ -6,7 +6,7 @@
//
import Foundation
-import XMTPProto
+
typealias SealedInvitation = Xmtp_MessageContents_SealedInvitation
diff --git a/Sources/XMTP/Messages/SealedInvitationHeaderV1.swift b/Sources/XMTP/Messages/SealedInvitationHeaderV1.swift
index 83bc3ca6..70bbafc2 100644
--- a/Sources/XMTP/Messages/SealedInvitationHeaderV1.swift
+++ b/Sources/XMTP/Messages/SealedInvitationHeaderV1.swift
@@ -6,7 +6,7 @@
//
import Foundation
-import XMTPProto
+
public typealias SealedInvitationHeaderV1 = Xmtp_MessageContents_SealedInvitationHeaderV1
diff --git a/Sources/XMTP/Messages/SealedInvitationV1.swift b/Sources/XMTP/Messages/SealedInvitationV1.swift
index 23c1000d..054274b0 100644
--- a/Sources/XMTP/Messages/SealedInvitationV1.swift
+++ b/Sources/XMTP/Messages/SealedInvitationV1.swift
@@ -6,7 +6,7 @@
//
import Foundation
-import XMTPProto
+
typealias SealedInvitationV1 = Xmtp_MessageContents_SealedInvitationV1
diff --git a/Sources/XMTP/Messages/Signature.swift b/Sources/XMTP/Messages/Signature.swift
index 4faa5b23..df390e87 100644
--- a/Sources/XMTP/Messages/Signature.swift
+++ b/Sources/XMTP/Messages/Signature.swift
@@ -6,8 +6,7 @@
//
import Foundation
-import secp256k1
-import XMTPProto
+import XMTPRust
/// Represents a secp256k1 compact recoverable signature.
public typealias Signature = Xmtp_MessageContents_Signature
@@ -103,19 +102,12 @@ extension Signature {
}
func verify(signedBy: PublicKey, digest: Data) throws -> Bool {
- let recoverySignature = try secp256k1.Recovery.ECDSASignature(compactRepresentation: ecdsaCompact.bytes, recoveryId: Int32(ecdsaCompact.recovery))
- let ecdsaSignature = try recoverySignature.normalize
- let signingKey = try secp256k1.Signing.PublicKey(rawRepresentation: signedBy.secp256K1Uncompressed.bytes, format: .uncompressed)
-
- return signingKey.ecdsa.isValidSignature(ecdsaSignature, for: digest)
- }
-
- func verify(signedBy: PublicKey, digest: any Digest) throws -> Bool {
- let recoverySignature = try secp256k1.Recovery.ECDSASignature(compactRepresentation: ecdsaCompact.bytes, recoveryId: Int32(ecdsaCompact.recovery))
- let ecdsaSignature = try recoverySignature.normalize
- let signingKey = try secp256k1.Signing.PublicKey(rawRepresentation: signedBy.secp256K1Uncompressed.bytes, format: .uncompressed)
-
- return signingKey.ecdsa.isValidSignature(ecdsaSignature, for: digest)
+ do {
+ let _ = try XMTPRust.verify_k256_sha256(RustVec(signedBy.secp256K1Uncompressed.bytes), RustVec(digest), RustVec(ecdsaCompact.bytes), UInt8(ecdsaCompact.recovery))
+ } catch {
+ return false
+ }
+ return true
}
}
diff --git a/Sources/XMTP/Messages/SignedContent.swift b/Sources/XMTP/Messages/SignedContent.swift
index 329c6d38..42d4e3b8 100644
--- a/Sources/XMTP/Messages/SignedContent.swift
+++ b/Sources/XMTP/Messages/SignedContent.swift
@@ -6,7 +6,7 @@
//
import Foundation
-import XMTPProto
+
typealias SignedContent = Xmtp_MessageContents_SignedContent
diff --git a/Sources/XMTP/Messages/SignedPrivateKey.swift b/Sources/XMTP/Messages/SignedPrivateKey.swift
index 13a8ba8b..102ce248 100644
--- a/Sources/XMTP/Messages/SignedPrivateKey.swift
+++ b/Sources/XMTP/Messages/SignedPrivateKey.swift
@@ -6,8 +6,7 @@
//
import Foundation
-import secp256k1
-import XMTPProto
+
public typealias SignedPrivateKey = Xmtp_MessageContents_SignedPrivateKey
diff --git a/Sources/XMTP/Messages/SignedPublicKey.swift b/Sources/XMTP/Messages/SignedPublicKey.swift
index 7d1eefbe..bf0aabbd 100644
--- a/Sources/XMTP/Messages/SignedPublicKey.swift
+++ b/Sources/XMTP/Messages/SignedPublicKey.swift
@@ -7,8 +7,9 @@
import CryptoKit
import Foundation
-import secp256k1
-import XMTPProto
+
+import XMTPRust
+import web3
typealias SignedPublicKey = Xmtp_MessageContents_SignedPublicKey
@@ -63,15 +64,15 @@ extension SignedPublicKey {
slimKey.timestamp = publicKey.timestamp
let bytesToSign = try slimKey.serializedData()
- let pubKeyData = try KeyUtil.recoverPublicKey(message: Data(SHA256.hash(data: bytesToSign)), signature: publicKey.signature.rawData)
+ let pubKeyData = try KeyUtilx.recoverPublicKeySHA256(from: publicKey.signature.rawData, message: bytesToSign)
return try PublicKey(pubKeyData)
}
func recoverWalletSignerPublicKey() throws -> PublicKey {
let sigText = Signature.createIdentityText(key: keyBytes)
- let sigHash = try Signature.ethHash(sigText)
+ let message = try Signature.ethPersonalMessage(sigText)
- let pubKeyData = try KeyUtil.recoverPublicKey(message: sigHash, signature: signature.rawData)
+ let pubKeyData = try KeyUtilx.recoverPublicKeyKeccak256(from: signature.rawData, message: message)
return try PublicKey(pubKeyData)
}
diff --git a/Sources/XMTP/Messages/SignedPublicKeyBundle.swift b/Sources/XMTP/Messages/SignedPublicKeyBundle.swift
index a67220bd..36cf81ce 100644
--- a/Sources/XMTP/Messages/SignedPublicKeyBundle.swift
+++ b/Sources/XMTP/Messages/SignedPublicKeyBundle.swift
@@ -5,7 +5,7 @@
// Created by Pat Nakajima on 11/23/22.
//
-import XMTPProto
+
typealias SignedPublicKeyBundle = Xmtp_MessageContents_SignedPublicKeyBundle
diff --git a/Sources/XMTP/Messages/Token.swift b/Sources/XMTP/Messages/Token.swift
index 1831a55d..5165e156 100644
--- a/Sources/XMTP/Messages/Token.swift
+++ b/Sources/XMTP/Messages/Token.swift
@@ -6,6 +6,6 @@
//
import Foundation
-import XMTPProto
+
typealias Token = Xmtp_MessageApi_V1_Token
diff --git a/Sources/XMTP/Messages/Topic.swift b/Sources/XMTP/Messages/Topic.swift
index 276ab3d1..e0b9c0b6 100644
--- a/Sources/XMTP/Messages/Topic.swift
+++ b/Sources/XMTP/Messages/Topic.swift
@@ -5,9 +5,9 @@
// Created by Pat Nakajima on 11/17/22.
//
-import XMTPProto
-enum Topic {
+
+public enum Topic {
case userPrivateStoreKeyBundle(String),
contact(String),
userIntro(String),
diff --git a/Sources/XMTP/Messages/UnsignedPublicKey.swift b/Sources/XMTP/Messages/UnsignedPublicKey.swift
index 9b1111de..69e26afd 100644
--- a/Sources/XMTP/Messages/UnsignedPublicKey.swift
+++ b/Sources/XMTP/Messages/UnsignedPublicKey.swift
@@ -6,7 +6,7 @@
//
import Foundation
-import XMTPProto
+
typealias UnsignedPublicKey = Xmtp_MessageContents_UnsignedPublicKey
diff --git a/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift b/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift
new file mode 100644
index 00000000..586462ad
--- /dev/null
+++ b/Sources/XMTP/Proto/keystore_api/v1/keystore.pb.swift
@@ -0,0 +1,1864 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: keystore_api/v1/keystore.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Message content encoding structures
+
+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
+}
+
+/// Application-specific error codes for the Keystore API.
+public enum Xmtp_KeystoreApi_V1_ErrorCode: SwiftProtobuf.Enum {
+ public typealias RawValue = Int
+ case unspecified // = 0
+ case invalidInput // = 1
+ case noMatchingPrekey // = 2
+ case UNRECOGNIZED(Int)
+
+ public init() {
+ self = .unspecified
+ }
+
+ public init?(rawValue: Int) {
+ switch rawValue {
+ case 0: self = .unspecified
+ case 1: self = .invalidInput
+ case 2: self = .noMatchingPrekey
+ default: self = .UNRECOGNIZED(rawValue)
+ }
+ }
+
+ public var rawValue: Int {
+ switch self {
+ case .unspecified: return 0
+ case .invalidInput: return 1
+ case .noMatchingPrekey: return 2
+ case .UNRECOGNIZED(let i): return i
+ }
+ }
+
+}
+
+#if swift(>=4.2)
+
+extension Xmtp_KeystoreApi_V1_ErrorCode: CaseIterable {
+ // The compiler won't synthesize support with the UNRECOGNIZED case.
+ public static var allCases: [Xmtp_KeystoreApi_V1_ErrorCode] = [
+ .unspecified,
+ .invalidInput,
+ .noMatchingPrekey,
+ ]
+}
+
+#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
+ // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
+ // methods supported on all messages.
+
+ public var message: String = String()
+
+ public var code: Xmtp_KeystoreApi_V1_ErrorCode = .unspecified
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// Decrypt a batch of messages using X3DH key agreement
+public struct Xmtp_KeystoreApi_V1_DecryptV1Request {
+ // 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 requests: [Xmtp_KeystoreApi_V1_DecryptV1Request.Request] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single decryption request
+ public struct Request {
+ // 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: Xmtp_MessageContents_Ciphertext {
+ get {return _payload ?? Xmtp_MessageContents_Ciphertext()}
+ set {_payload = newValue}
+ }
+ /// Returns true if `payload` has been explicitly set.
+ public var hasPayload: Bool {return self._payload != nil}
+ /// Clears the value of `payload`. Subsequent reads from it will return its default value.
+ public mutating func clearPayload() {self._payload = nil}
+
+ public var peerKeys: Xmtp_MessageContents_PublicKeyBundle {
+ get {return _peerKeys ?? Xmtp_MessageContents_PublicKeyBundle()}
+ set {_peerKeys = newValue}
+ }
+ /// Returns true if `peerKeys` has been explicitly set.
+ public var hasPeerKeys: Bool {return self._peerKeys != nil}
+ /// Clears the value of `peerKeys`. Subsequent reads from it will return its default value.
+ public mutating func clearPeerKeys() {self._peerKeys = nil}
+
+ public var headerBytes: Data = Data()
+
+ public var isSender: Bool = false
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _payload: Xmtp_MessageContents_Ciphertext? = nil
+ fileprivate var _peerKeys: Xmtp_MessageContents_PublicKeyBundle? = nil
+ }
+
+ public init() {}
+}
+
+/// Response type for both V1 and V2 decryption requests
+public struct Xmtp_KeystoreApi_V1_DecryptResponse {
+ // 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 responses: [Xmtp_KeystoreApi_V1_DecryptResponse.Response] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single decryption response
+ public struct Response {
+ // 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 response: Xmtp_KeystoreApi_V1_DecryptResponse.Response.OneOf_Response? = nil
+
+ public var result: Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success {
+ get {
+ if case .result(let v)? = response {return v}
+ return Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success()
+ }
+ set {response = .result(newValue)}
+ }
+
+ public var error: Xmtp_KeystoreApi_V1_KeystoreError {
+ get {
+ if case .error(let v)? = response {return v}
+ return Xmtp_KeystoreApi_V1_KeystoreError()
+ }
+ set {response = .error(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Response: Equatable {
+ case result(Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success)
+ case error(Xmtp_KeystoreApi_V1_KeystoreError)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptResponse.Response.OneOf_Response, rhs: Xmtp_KeystoreApi_V1_DecryptResponse.Response.OneOf_Response) -> 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 (.result, .result): return {
+ guard case .result(let l) = lhs, case .result(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ case (.error, .error): return {
+ guard case .error(let l) = lhs, case .error(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ /// Wrapper object for success response
+ public struct Success {
+ // 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 decrypted: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// Decrypt a batch of messages using the appropriate topic keys
+public struct Xmtp_KeystoreApi_V1_DecryptV2Request {
+ // 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 requests: [Xmtp_KeystoreApi_V1_DecryptV2Request.Request] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single decryption request
+ public struct Request {
+ // 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: Xmtp_MessageContents_Ciphertext {
+ get {return _payload ?? Xmtp_MessageContents_Ciphertext()}
+ set {_payload = newValue}
+ }
+ /// Returns true if `payload` has been explicitly set.
+ public var hasPayload: Bool {return self._payload != nil}
+ /// Clears the value of `payload`. Subsequent reads from it will return its default value.
+ public mutating func clearPayload() {self._payload = nil}
+
+ public var headerBytes: Data = Data()
+
+ public var contentTopic: String = String()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _payload: Xmtp_MessageContents_Ciphertext? = nil
+ }
+
+ public init() {}
+}
+
+/// Encrypt a batch of messages using X3DH key agreement
+public struct Xmtp_KeystoreApi_V1_EncryptV1Request {
+ // 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 requests: [Xmtp_KeystoreApi_V1_EncryptV1Request.Request] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single encryption request
+ public struct Request {
+ // 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 recipient: Xmtp_MessageContents_PublicKeyBundle {
+ get {return _recipient ?? Xmtp_MessageContents_PublicKeyBundle()}
+ set {_recipient = newValue}
+ }
+ /// Returns true if `recipient` has been explicitly set.
+ public var hasRecipient: Bool {return self._recipient != nil}
+ /// Clears the value of `recipient`. Subsequent reads from it will return its default value.
+ public mutating func clearRecipient() {self._recipient = nil}
+
+ public var payload: Data = Data()
+
+ public var headerBytes: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _recipient: Xmtp_MessageContents_PublicKeyBundle? = nil
+ }
+
+ public init() {}
+}
+
+/// Response type for both V1 and V2 encryption requests
+public struct Xmtp_KeystoreApi_V1_EncryptResponse {
+ // 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 responses: [Xmtp_KeystoreApi_V1_EncryptResponse.Response] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single encryption response
+ public struct Response {
+ // 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 response: Xmtp_KeystoreApi_V1_EncryptResponse.Response.OneOf_Response? = nil
+
+ public var result: Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success {
+ get {
+ if case .result(let v)? = response {return v}
+ return Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success()
+ }
+ set {response = .result(newValue)}
+ }
+
+ public var error: Xmtp_KeystoreApi_V1_KeystoreError {
+ get {
+ if case .error(let v)? = response {return v}
+ return Xmtp_KeystoreApi_V1_KeystoreError()
+ }
+ set {response = .error(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Response: Equatable {
+ case result(Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success)
+ case error(Xmtp_KeystoreApi_V1_KeystoreError)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptResponse.Response.OneOf_Response, rhs: Xmtp_KeystoreApi_V1_EncryptResponse.Response.OneOf_Response) -> 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 (.result, .result): return {
+ guard case .result(let l) = lhs, case .result(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ case (.error, .error): return {
+ guard case .error(let l) = lhs, case .error(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ /// Wrapper object for success response
+ public struct Success {
+ // 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 encrypted: Xmtp_MessageContents_Ciphertext {
+ get {return _encrypted ?? Xmtp_MessageContents_Ciphertext()}
+ set {_encrypted = newValue}
+ }
+ /// Returns true if `encrypted` has been explicitly set.
+ public var hasEncrypted: Bool {return self._encrypted != nil}
+ /// Clears the value of `encrypted`. Subsequent reads from it will return its default value.
+ public mutating func clearEncrypted() {self._encrypted = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _encrypted: Xmtp_MessageContents_Ciphertext? = nil
+ }
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// Encrypt a batch of messages using the appropriate topic keys
+public struct Xmtp_KeystoreApi_V1_EncryptV2Request {
+ // 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 requests: [Xmtp_KeystoreApi_V1_EncryptV2Request.Request] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single encryption request
+ public struct Request {
+ // 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 headerBytes: Data = Data()
+
+ public var contentTopic: String = String()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// Request to create an invite payload, and store the topic keys in the Keystore
+public struct Xmtp_KeystoreApi_V1_CreateInviteRequest {
+ // 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 context: Xmtp_MessageContents_InvitationV1.Context {
+ get {return _context ?? Xmtp_MessageContents_InvitationV1.Context()}
+ set {_context = newValue}
+ }
+ /// Returns true if `context` has been explicitly set.
+ public var hasContext: Bool {return self._context != nil}
+ /// Clears the value of `context`. Subsequent reads from it will return its default value.
+ public mutating func clearContext() {self._context = nil}
+
+ public var recipient: Xmtp_MessageContents_SignedPublicKeyBundle {
+ get {return _recipient ?? Xmtp_MessageContents_SignedPublicKeyBundle()}
+ set {_recipient = newValue}
+ }
+ /// Returns true if `recipient` has been explicitly set.
+ public var hasRecipient: Bool {return self._recipient != nil}
+ /// Clears the value of `recipient`. Subsequent reads from it will return its default value.
+ public mutating func clearRecipient() {self._recipient = nil}
+
+ public var createdNs: UInt64 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _context: Xmtp_MessageContents_InvitationV1.Context? = nil
+ fileprivate var _recipient: Xmtp_MessageContents_SignedPublicKeyBundle? = nil
+}
+
+/// Response to a CreateInviteRequest
+public struct Xmtp_KeystoreApi_V1_CreateInviteResponse {
+ // 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 conversation: Xmtp_MessageContents_ConversationReference {
+ get {return _conversation ?? Xmtp_MessageContents_ConversationReference()}
+ set {_conversation = newValue}
+ }
+ /// Returns true if `conversation` has been explicitly set.
+ public var hasConversation: Bool {return self._conversation != nil}
+ /// Clears the value of `conversation`. Subsequent reads from it will return its default value.
+ public mutating func clearConversation() {self._conversation = nil}
+
+ public var payload: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _conversation: Xmtp_MessageContents_ConversationReference? = nil
+}
+
+/// Request to save a batch of invite messages to the Keystore
+public struct Xmtp_KeystoreApi_V1_SaveInvitesRequest {
+ // 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 requests: [Xmtp_KeystoreApi_V1_SaveInvitesRequest.Request] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// Mirrors xmtp.envelope schema
+ public struct Request {
+ // 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 contentTopic: String = String()
+
+ public var timestampNs: UInt64 = 0
+
+ public var payload: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// Response to a SaveInvitesRequest
+public struct Xmtp_KeystoreApi_V1_SaveInvitesResponse {
+ // 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 responses: [Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// A single response
+ public struct Response {
+ // 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 response: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.OneOf_Response? = nil
+
+ public var result: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success {
+ get {
+ if case .result(let v)? = response {return v}
+ return Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success()
+ }
+ set {response = .result(newValue)}
+ }
+
+ public var error: Xmtp_KeystoreApi_V1_KeystoreError {
+ get {
+ if case .error(let v)? = response {return v}
+ return Xmtp_KeystoreApi_V1_KeystoreError()
+ }
+ set {response = .error(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Response: Equatable {
+ case result(Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success)
+ case error(Xmtp_KeystoreApi_V1_KeystoreError)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.OneOf_Response, rhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.OneOf_Response) -> 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 (.result, .result): return {
+ guard case .result(let l) = lhs, case .result(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ case (.error, .error): return {
+ guard case .error(let l) = lhs, case .error(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ /// Wrapper object for success response
+ public struct Success {
+ // 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 conversation: Xmtp_MessageContents_ConversationReference {
+ get {return _conversation ?? Xmtp_MessageContents_ConversationReference()}
+ set {_conversation = newValue}
+ }
+ /// Returns true if `conversation` has been explicitly set.
+ public var hasConversation: Bool {return self._conversation != nil}
+ /// Clears the value of `conversation`. Subsequent reads from it will return its default value.
+ public mutating func clearConversation() {self._conversation = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _conversation: Xmtp_MessageContents_ConversationReference? = nil
+ }
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// CreateAuthTokenRequest is used to create an auth token for the XMTP API
+public struct Xmtp_KeystoreApi_V1_CreateAuthTokenRequest {
+ // 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 {
+ get {return _timestampNs ?? 0}
+ set {_timestampNs = newValue}
+ }
+ /// Returns true if `timestampNs` has been explicitly set.
+ public var hasTimestampNs: Bool {return self._timestampNs != nil}
+ /// Clears the value of `timestampNs`. Subsequent reads from it will return its default value.
+ public mutating func clearTimestampNs() {self._timestampNs = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _timestampNs: UInt64? = nil
+}
+
+/// SignDigestRequest is used to sign a digest with either the identity key
+/// or a prekey
+public struct Xmtp_KeystoreApi_V1_SignDigestRequest {
+ // 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 digest: Data = Data()
+
+ public var signer: Xmtp_KeystoreApi_V1_SignDigestRequest.OneOf_Signer? = nil
+
+ public var identityKey: Bool {
+ get {
+ if case .identityKey(let v)? = signer {return v}
+ return false
+ }
+ set {signer = .identityKey(newValue)}
+ }
+
+ public var prekeyIndex: UInt32 {
+ get {
+ if case .prekeyIndex(let v)? = signer {return v}
+ return 0
+ }
+ set {signer = .prekeyIndex(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Signer: Equatable {
+ case identityKey(Bool)
+ case prekeyIndex(UInt32)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SignDigestRequest.OneOf_Signer, rhs: Xmtp_KeystoreApi_V1_SignDigestRequest.OneOf_Signer) -> 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 (.identityKey, .identityKey): return {
+ guard case .identityKey(let l) = lhs, case .identityKey(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ case (.prekeyIndex, .prekeyIndex): return {
+ guard case .prekeyIndex(let l) = lhs, case .prekeyIndex(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ 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
+ // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
+ // methods supported on all messages.
+
+ public var topics: Dictionary = [:]
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// TopicData wraps the invitation and the timestamp it was created
+ public struct TopicData {
+ // 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 peerAddress: String = String()
+
+ public var invitation: Xmtp_MessageContents_InvitationV1 {
+ get {return _invitation ?? Xmtp_MessageContents_InvitationV1()}
+ set {_invitation = newValue}
+ }
+ /// Returns true if `invitation` has been explicitly set.
+ public var hasInvitation: Bool {return self._invitation != nil}
+ /// Clears the value of `invitation`. Subsequent reads from it will return its default value.
+ public mutating func clearInvitation() {self._invitation = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _invitation: Xmtp_MessageContents_InvitationV1? = nil
+ }
+
+ public init() {}
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_KeystoreApi_V1_ErrorCode: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_KeystoreError: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptV1Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptV1Request.Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptResponse: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptResponse.Response: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptResponse.Response.OneOf_Response: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptV2Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_DecryptV2Request.Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptV1Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptV1Request.Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptResponse: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptResponse.Response: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptResponse.Response.OneOf_Response: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptV2Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_EncryptV2Request.Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_CreateInviteRequest: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_CreateInviteResponse: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_SaveInvitesRequest: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_SaveInvitesRequest.Request: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_SaveInvitesResponse: @unchecked Sendable {}
+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_SignDigestRequest: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_SignDigestRequest.OneOf_Signer: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_TopicMap: @unchecked Sendable {}
+extension Xmtp_KeystoreApi_V1_TopicMap.TopicData: @unchecked Sendable {}
+#endif // swift(>=5.5) && canImport(_Concurrency)
+
+// MARK: - Code below here is support for the SwiftProtobuf runtime.
+
+fileprivate let _protobuf_package = "xmtp.keystore_api.v1"
+
+extension Xmtp_KeystoreApi_V1_ErrorCode: SwiftProtobuf._ProtoNameProviding {
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 0: .same(proto: "ERROR_CODE_UNSPECIFIED"),
+ 1: .same(proto: "ERROR_CODE_INVALID_INPUT"),
+ 2: .same(proto: "ERROR_CODE_NO_MATCHING_PREKEY"),
+ ]
+}
+
+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 = [
+ 1: .same(proto: "message"),
+ 2: .same(proto: "code"),
+ ]
+
+ 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.message) }()
+ case 2: try { try decoder.decodeSingularEnumField(value: &self.code) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.message.isEmpty {
+ try visitor.visitSingularStringField(value: self.message, fieldNumber: 1)
+ }
+ if self.code != .unspecified {
+ try visitor.visitSingularEnumField(value: self.code, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_KeystoreError, rhs: Xmtp_KeystoreApi_V1_KeystoreError) -> Bool {
+ if lhs.message != rhs.message {return false}
+ if lhs.code != rhs.code {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptV1Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".DecryptV1Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "requests"),
+ ]
+
+ 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.requests) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.requests.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.requests, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptV1Request, rhs: Xmtp_KeystoreApi_V1_DecryptV1Request) -> Bool {
+ if lhs.requests != rhs.requests {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptV1Request.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_DecryptV1Request.protoMessageName + ".Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "payload"),
+ 2: .standard(proto: "peer_keys"),
+ 3: .standard(proto: "header_bytes"),
+ 4: .standard(proto: "is_sender"),
+ ]
+
+ 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._payload) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._peerKeys) }()
+ case 3: try { try decoder.decodeSingularBytesField(value: &self.headerBytes) }()
+ case 4: try { try decoder.decodeSingularBoolField(value: &self.isSender) }()
+ 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._payload {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try { if let v = self._peerKeys {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 3)
+ }
+ if self.isSender != false {
+ try visitor.visitSingularBoolField(value: self.isSender, fieldNumber: 4)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptV1Request.Request, rhs: Xmtp_KeystoreApi_V1_DecryptV1Request.Request) -> Bool {
+ if lhs._payload != rhs._payload {return false}
+ if lhs._peerKeys != rhs._peerKeys {return false}
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs.isSender != rhs.isSender {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".DecryptResponse"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "responses"),
+ ]
+
+ 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.responses) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.responses.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.responses, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptResponse, rhs: Xmtp_KeystoreApi_V1_DecryptResponse) -> Bool {
+ if lhs.responses != rhs.responses {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptResponse.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_DecryptResponse.protoMessageName + ".Response"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "result"),
+ 2: .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 {
+ var v: Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success?
+ var hadOneofValue = false
+ if let current = self.response {
+ hadOneofValue = true
+ if case .result(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.response = .result(v)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_KeystoreApi_V1_KeystoreError?
+ var hadOneofValue = false
+ if let current = self.response {
+ hadOneofValue = true
+ if case .error(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.response = .error(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.response {
+ case .result?: try {
+ guard case .result(let v)? = self.response else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .error?: try {
+ guard case .error(let v)? = self.response else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptResponse.Response, rhs: Xmtp_KeystoreApi_V1_DecryptResponse.Response) -> Bool {
+ if lhs.response != rhs.response {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_DecryptResponse.Response.protoMessageName + ".Success"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "decrypted"),
+ ]
+
+ 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.decrypted) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.decrypted.isEmpty {
+ try visitor.visitSingularBytesField(value: self.decrypted, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success, rhs: Xmtp_KeystoreApi_V1_DecryptResponse.Response.Success) -> Bool {
+ if lhs.decrypted != rhs.decrypted {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptV2Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".DecryptV2Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "requests"),
+ ]
+
+ 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.requests) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.requests.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.requests, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptV2Request, rhs: Xmtp_KeystoreApi_V1_DecryptV2Request) -> Bool {
+ if lhs.requests != rhs.requests {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_DecryptV2Request.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_DecryptV2Request.protoMessageName + ".Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "payload"),
+ 2: .standard(proto: "header_bytes"),
+ 3: .standard(proto: "content_topic"),
+ ]
+
+ 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._payload) }()
+ case 2: try { try decoder.decodeSingularBytesField(value: &self.headerBytes) }()
+ case 3: try { try decoder.decodeSingularStringField(value: &self.contentTopic) }()
+ 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._payload {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 2)
+ }
+ if !self.contentTopic.isEmpty {
+ try visitor.visitSingularStringField(value: self.contentTopic, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_DecryptV2Request.Request, rhs: Xmtp_KeystoreApi_V1_DecryptV2Request.Request) -> Bool {
+ if lhs._payload != rhs._payload {return false}
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs.contentTopic != rhs.contentTopic {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptV1Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".EncryptV1Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "requests"),
+ ]
+
+ 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.requests) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.requests.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.requests, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptV1Request, rhs: Xmtp_KeystoreApi_V1_EncryptV1Request) -> Bool {
+ if lhs.requests != rhs.requests {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptV1Request.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_EncryptV1Request.protoMessageName + ".Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "recipient"),
+ 2: .same(proto: "payload"),
+ 3: .standard(proto: "header_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.decodeSingularMessageField(value: &self._recipient) }()
+ case 2: try { try decoder.decodeSingularBytesField(value: &self.payload) }()
+ case 3: try { try decoder.decodeSingularBytesField(value: &self.headerBytes) }()
+ 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._recipient {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ if !self.payload.isEmpty {
+ try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 2)
+ }
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptV1Request.Request, rhs: Xmtp_KeystoreApi_V1_EncryptV1Request.Request) -> Bool {
+ if lhs._recipient != rhs._recipient {return false}
+ if lhs.payload != rhs.payload {return false}
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".EncryptResponse"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "responses"),
+ ]
+
+ 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.responses) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.responses.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.responses, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptResponse, rhs: Xmtp_KeystoreApi_V1_EncryptResponse) -> Bool {
+ if lhs.responses != rhs.responses {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptResponse.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_EncryptResponse.protoMessageName + ".Response"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "result"),
+ 2: .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 {
+ var v: Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success?
+ var hadOneofValue = false
+ if let current = self.response {
+ hadOneofValue = true
+ if case .result(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.response = .result(v)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_KeystoreApi_V1_KeystoreError?
+ var hadOneofValue = false
+ if let current = self.response {
+ hadOneofValue = true
+ if case .error(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.response = .error(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.response {
+ case .result?: try {
+ guard case .result(let v)? = self.response else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .error?: try {
+ guard case .error(let v)? = self.response else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptResponse.Response, rhs: Xmtp_KeystoreApi_V1_EncryptResponse.Response) -> Bool {
+ if lhs.response != rhs.response {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_EncryptResponse.Response.protoMessageName + ".Success"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "encrypted"),
+ ]
+
+ 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._encrypted) }()
+ 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._encrypted {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success, rhs: Xmtp_KeystoreApi_V1_EncryptResponse.Response.Success) -> Bool {
+ if lhs._encrypted != rhs._encrypted {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptV2Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".EncryptV2Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "requests"),
+ ]
+
+ 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.requests) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.requests.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.requests, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptV2Request, rhs: Xmtp_KeystoreApi_V1_EncryptV2Request) -> Bool {
+ if lhs.requests != rhs.requests {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_EncryptV2Request.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_EncryptV2Request.protoMessageName + ".Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "payload"),
+ 2: .standard(proto: "header_bytes"),
+ 3: .standard(proto: "content_topic"),
+ ]
+
+ 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.decodeSingularBytesField(value: &self.headerBytes) }()
+ case 3: try { try decoder.decodeSingularStringField(value: &self.contentTopic) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.payload.isEmpty {
+ try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 1)
+ }
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 2)
+ }
+ if !self.contentTopic.isEmpty {
+ try visitor.visitSingularStringField(value: self.contentTopic, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_EncryptV2Request.Request, rhs: Xmtp_KeystoreApi_V1_EncryptV2Request.Request) -> Bool {
+ if lhs.payload != rhs.payload {return false}
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs.contentTopic != rhs.contentTopic {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_CreateInviteRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".CreateInviteRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "context"),
+ 2: .same(proto: "recipient"),
+ 3: .standard(proto: "created_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.decodeSingularMessageField(value: &self._context) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._recipient) }()
+ case 3: try { try decoder.decodeSingularUInt64Field(value: &self.createdNs) }()
+ 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._context {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try { if let v = self._recipient {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ if self.createdNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_CreateInviteRequest, rhs: Xmtp_KeystoreApi_V1_CreateInviteRequest) -> Bool {
+ if lhs._context != rhs._context {return false}
+ if lhs._recipient != rhs._recipient {return false}
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_CreateInviteResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".CreateInviteResponse"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "conversation"),
+ 2: .same(proto: "payload"),
+ ]
+
+ 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._conversation) }()
+ case 2: try { try decoder.decodeSingularBytesField(value: &self.payload) }()
+ 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._conversation {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ if !self.payload.isEmpty {
+ try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_CreateInviteResponse, rhs: Xmtp_KeystoreApi_V1_CreateInviteResponse) -> Bool {
+ if lhs._conversation != rhs._conversation {return false}
+ if lhs.payload != rhs.payload {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_SaveInvitesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SaveInvitesRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "requests"),
+ ]
+
+ 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.requests) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.requests.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.requests, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveInvitesRequest, rhs: Xmtp_KeystoreApi_V1_SaveInvitesRequest) -> Bool {
+ if lhs.requests != rhs.requests {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_SaveInvitesRequest.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_SaveInvitesRequest.protoMessageName + ".Request"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "content_topic"),
+ 2: .standard(proto: "timestamp_ns"),
+ 3: .same(proto: "payload"),
+ ]
+
+ 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.contentTopic) }()
+ case 2: try { try decoder.decodeSingularUInt64Field(value: &self.timestampNs) }()
+ case 3: try { try decoder.decodeSingularBytesField(value: &self.payload) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.contentTopic.isEmpty {
+ try visitor.visitSingularStringField(value: self.contentTopic, fieldNumber: 1)
+ }
+ if self.timestampNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.timestampNs, fieldNumber: 2)
+ }
+ if !self.payload.isEmpty {
+ try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveInvitesRequest.Request, rhs: Xmtp_KeystoreApi_V1_SaveInvitesRequest.Request) -> Bool {
+ if lhs.contentTopic != rhs.contentTopic {return false}
+ if lhs.timestampNs != rhs.timestampNs {return false}
+ if lhs.payload != rhs.payload {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_SaveInvitesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SaveInvitesResponse"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "responses"),
+ ]
+
+ 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.responses) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.responses.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.responses, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse, rhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse) -> Bool {
+ if lhs.responses != rhs.responses {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_SaveInvitesResponse.protoMessageName + ".Response"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "result"),
+ 2: .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 {
+ var v: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success?
+ var hadOneofValue = false
+ if let current = self.response {
+ hadOneofValue = true
+ if case .result(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.response = .result(v)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_KeystoreApi_V1_KeystoreError?
+ var hadOneofValue = false
+ if let current = self.response {
+ hadOneofValue = true
+ if case .error(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.response = .error(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.response {
+ case .result?: try {
+ guard case .result(let v)? = self.response else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .error?: try {
+ guard case .error(let v)? = self.response else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response, rhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response) -> Bool {
+ if lhs.response != rhs.response {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.protoMessageName + ".Success"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "conversation"),
+ ]
+
+ 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._conversation) }()
+ 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._conversation {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success, rhs: Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success) -> Bool {
+ if lhs._conversation != rhs._conversation {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_CreateAuthTokenRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".CreateAuthTokenRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "timestamp_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.decodeSingularUInt64Field(value: &self._timestampNs) }()
+ 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._timestampNs {
+ try visitor.visitSingularUInt64Field(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_CreateAuthTokenRequest, rhs: Xmtp_KeystoreApi_V1_CreateAuthTokenRequest) -> Bool {
+ if lhs._timestampNs != rhs._timestampNs {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 = [
+ 1: .same(proto: "digest"),
+ 2: .standard(proto: "identity_key"),
+ 3: .standard(proto: "prekey_index"),
+ ]
+
+ 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.digest) }()
+ case 2: try {
+ var v: Bool?
+ try decoder.decodeSingularBoolField(value: &v)
+ if let v = v {
+ if self.signer != nil {try decoder.handleConflictingOneOf()}
+ self.signer = .identityKey(v)
+ }
+ }()
+ case 3: try {
+ var v: UInt32?
+ try decoder.decodeSingularUInt32Field(value: &v)
+ if let v = v {
+ if self.signer != nil {try decoder.handleConflictingOneOf()}
+ self.signer = .prekeyIndex(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.digest.isEmpty {
+ try visitor.visitSingularBytesField(value: self.digest, fieldNumber: 1)
+ }
+ switch self.signer {
+ case .identityKey?: try {
+ guard case .identityKey(let v)? = self.signer else { preconditionFailure() }
+ try visitor.visitSingularBoolField(value: v, fieldNumber: 2)
+ }()
+ case .prekeyIndex?: try {
+ guard case .prekeyIndex(let v)? = self.signer else { preconditionFailure() }
+ try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_SignDigestRequest, rhs: Xmtp_KeystoreApi_V1_SignDigestRequest) -> Bool {
+ if lhs.digest != rhs.digest {return false}
+ if lhs.signer != rhs.signer {return false}
+ 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 = [
+ 1: .same(proto: "topics"),
+ ]
+
+ 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.decodeMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: &self.topics) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.topics.isEmpty {
+ try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: self.topics, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_TopicMap, rhs: Xmtp_KeystoreApi_V1_TopicMap) -> Bool {
+ if lhs.topics != rhs.topics {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_KeystoreApi_V1_TopicMap.TopicData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_KeystoreApi_V1_TopicMap.protoMessageName + ".TopicData"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "created_ns"),
+ 2: .standard(proto: "peer_address"),
+ 3: .same(proto: "invitation"),
+ ]
+
+ 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 { try decoder.decodeSingularStringField(value: &self.peerAddress) }()
+ case 3: try { try decoder.decodeSingularMessageField(value: &self._invitation) }()
+ 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)
+ }
+ if !self.peerAddress.isEmpty {
+ try visitor.visitSingularStringField(value: self.peerAddress, fieldNumber: 2)
+ }
+ try { if let v = self._invitation {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_KeystoreApi_V1_TopicMap.TopicData, rhs: Xmtp_KeystoreApi_V1_TopicMap.TopicData) -> Bool {
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs.peerAddress != rhs.peerAddress {return false}
+ if lhs._invitation != rhs._invitation {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_api/v1/authn.pb.swift b/Sources/XMTP/Proto/message_api/v1/authn.pb.swift
new file mode 100644
index 00000000..22361f7c
--- /dev/null
+++ b/Sources/XMTP/Proto/message_api/v1/authn.pb.swift
@@ -0,0 +1,177 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_api/v1/authn.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Client authentication protocol
+
+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
+}
+
+/// Token is used by clients to prove to the nodes
+/// that they are serving a specific wallet.
+public struct Xmtp_MessageApi_V1_Token {
+ // 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.
+
+ /// identity key signed by a wallet
+ public var identityKey: Xmtp_MessageContents_PublicKey {
+ get {return _identityKey ?? Xmtp_MessageContents_PublicKey()}
+ 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}
+
+ /// encoded bytes of AuthData
+ public var authDataBytes: Data = Data()
+
+ /// identity key signature of AuthData bytes
+ public var authDataSignature: Xmtp_MessageContents_Signature {
+ get {return _authDataSignature ?? Xmtp_MessageContents_Signature()}
+ set {_authDataSignature = newValue}
+ }
+ /// Returns true if `authDataSignature` has been explicitly set.
+ public var hasAuthDataSignature: Bool {return self._authDataSignature != nil}
+ /// Clears the value of `authDataSignature`. Subsequent reads from it will return its default value.
+ public mutating func clearAuthDataSignature() {self._authDataSignature = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _identityKey: Xmtp_MessageContents_PublicKey? = nil
+ fileprivate var _authDataSignature: Xmtp_MessageContents_Signature? = nil
+}
+
+/// AuthData carries token parameters that are authenticated
+/// by the identity key signature.
+/// It is embedded in the Token structure as bytes
+/// so that the bytes don't need to be reconstructed
+/// to verify the token signature.
+public struct Xmtp_MessageApi_V1_AuthData {
+ // 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.
+
+ /// address of the wallet
+ public var walletAddr: String = String()
+
+ /// time when the token was generated/signed
+ public var createdNs: UInt64 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageApi_V1_Token: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_AuthData: @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.v1"
+
+extension Xmtp_MessageApi_V1_Token: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Token"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "identity_key"),
+ 2: .standard(proto: "auth_data_bytes"),
+ 3: .standard(proto: "auth_data_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.decodeSingularMessageField(value: &self._identityKey) }()
+ case 2: try { try decoder.decodeSingularBytesField(value: &self.authDataBytes) }()
+ case 3: try { try decoder.decodeSingularMessageField(value: &self._authDataSignature) }()
+ 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.authDataBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.authDataBytes, fieldNumber: 2)
+ }
+ try { if let v = self._authDataSignature {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_Token, rhs: Xmtp_MessageApi_V1_Token) -> Bool {
+ if lhs._identityKey != rhs._identityKey {return false}
+ if lhs.authDataBytes != rhs.authDataBytes {return false}
+ if lhs._authDataSignature != rhs._authDataSignature {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_AuthData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".AuthData"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "wallet_addr"),
+ 2: .standard(proto: "created_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.decodeSingularStringField(value: &self.walletAddr) }()
+ case 2: try { try decoder.decodeSingularUInt64Field(value: &self.createdNs) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.walletAddr.isEmpty {
+ try visitor.visitSingularStringField(value: self.walletAddr, fieldNumber: 1)
+ }
+ if self.createdNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_AuthData, rhs: Xmtp_MessageApi_V1_AuthData) -> Bool {
+ if lhs.walletAddr != rhs.walletAddr {return false}
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift b/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift
new file mode 100644
index 00000000..03ae0a3a
--- /dev/null
+++ b/Sources/XMTP/Proto/message_api/v1/message_api.pb.swift
@@ -0,0 +1,776 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_api/v1/message_api.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
+}
+
+/// Sort direction
+public enum Xmtp_MessageApi_V1_SortDirection: SwiftProtobuf.Enum {
+ public typealias RawValue = Int
+ case unspecified // = 0
+ case ascending // = 1
+ case descending // = 2
+ case UNRECOGNIZED(Int)
+
+ public init() {
+ self = .unspecified
+ }
+
+ public init?(rawValue: Int) {
+ switch rawValue {
+ case 0: self = .unspecified
+ case 1: self = .ascending
+ case 2: self = .descending
+ default: self = .UNRECOGNIZED(rawValue)
+ }
+ }
+
+ public var rawValue: Int {
+ switch self {
+ case .unspecified: return 0
+ case .ascending: return 1
+ case .descending: return 2
+ case .UNRECOGNIZED(let i): return i
+ }
+ }
+
+}
+
+#if swift(>=4.2)
+
+extension Xmtp_MessageApi_V1_SortDirection: CaseIterable {
+ // The compiler won't synthesize support with the UNRECOGNIZED case.
+ public static var allCases: [Xmtp_MessageApi_V1_SortDirection] = [
+ .unspecified,
+ .ascending,
+ .descending,
+ ]
+}
+
+#endif // swift(>=4.2)
+
+/// This is based off of the go-waku Index type, but with the
+/// receiverTime and pubsubTopic removed for simplicity.
+/// Both removed fields are optional
+public struct Xmtp_MessageApi_V1_IndexCursor {
+ // 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 digest: Data = Data()
+
+ public var senderTimeNs: UInt64 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// Wrapper for potentially multiple types of cursor
+public struct Xmtp_MessageApi_V1_Cursor {
+ // 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.
+
+ /// Making the cursor a one-of type, as I would like to change the way we
+ /// handle pagination to use a precomputed sort field.
+ /// This way we can handle both methods
+ public var cursor: Xmtp_MessageApi_V1_Cursor.OneOf_Cursor? = nil
+
+ public var index: Xmtp_MessageApi_V1_IndexCursor {
+ get {
+ if case .index(let v)? = cursor {return v}
+ return Xmtp_MessageApi_V1_IndexCursor()
+ }
+ set {cursor = .index(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// Making the cursor a one-of type, as I would like to change the way we
+ /// handle pagination to use a precomputed sort field.
+ /// This way we can handle both methods
+ public enum OneOf_Cursor: Equatable {
+ case index(Xmtp_MessageApi_V1_IndexCursor)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageApi_V1_Cursor.OneOf_Cursor, rhs: Xmtp_MessageApi_V1_Cursor.OneOf_Cursor) -> 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 (.index, .index): return {
+ guard case .index(let l) = lhs, case .index(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ public init() {}
+}
+
+/// This is based off of the go-waku PagingInfo struct, but with the direction
+/// changed to our SortDirection enum format
+public struct Xmtp_MessageApi_V1_PagingInfo {
+ // 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.
+
+ /// Note: this is a uint32, while go-waku's pageSize is a uint64
+ public var limit: UInt32 = 0
+
+ public var cursor: Xmtp_MessageApi_V1_Cursor {
+ get {return _cursor ?? Xmtp_MessageApi_V1_Cursor()}
+ set {_cursor = newValue}
+ }
+ /// Returns true if `cursor` has been explicitly set.
+ public var hasCursor: Bool {return self._cursor != nil}
+ /// Clears the value of `cursor`. Subsequent reads from it will return its default value.
+ public mutating func clearCursor() {self._cursor = nil}
+
+ public var direction: Xmtp_MessageApi_V1_SortDirection = .unspecified
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _cursor: Xmtp_MessageApi_V1_Cursor? = nil
+}
+
+/// Envelope encapsulates a message while in transit.
+public struct Xmtp_MessageApi_V1_Envelope {
+ // 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 the message belongs to,
+ /// If the message includes the topic as well
+ /// it MUST be the same as the topic in the envelope.
+ public var contentTopic: String = String()
+
+ /// Message creation timestamp
+ /// If the message includes the timestamp as well
+ /// it MUST be equivalent to the timestamp in the envelope.
+ public var timestampNs: UInt64 = 0
+
+ public var message: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// Publish
+public struct Xmtp_MessageApi_V1_PublishRequest {
+ // 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 envelopes: [Xmtp_MessageApi_V1_Envelope] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// Empty message as a response for Publish
+public struct Xmtp_MessageApi_V1_PublishResponse {
+ // 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() {}
+}
+
+/// Subscribe
+public struct Xmtp_MessageApi_V1_SubscribeRequest {
+ // 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 contentTopics: [String] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// SubscribeAll
+public struct Xmtp_MessageApi_V1_SubscribeAllRequest {
+ // 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() {}
+}
+
+/// Query
+public struct Xmtp_MessageApi_V1_QueryRequest {
+ // 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 contentTopics: [String] = []
+
+ public var startTimeNs: UInt64 = 0
+
+ public var endTimeNs: UInt64 = 0
+
+ public var pagingInfo: Xmtp_MessageApi_V1_PagingInfo {
+ get {return _pagingInfo ?? Xmtp_MessageApi_V1_PagingInfo()}
+ set {_pagingInfo = newValue}
+ }
+ /// Returns true if `pagingInfo` has been explicitly set.
+ public var hasPagingInfo: Bool {return self._pagingInfo != nil}
+ /// Clears the value of `pagingInfo`. Subsequent reads from it will return its default value.
+ public mutating func clearPagingInfo() {self._pagingInfo = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _pagingInfo: Xmtp_MessageApi_V1_PagingInfo? = nil
+}
+
+/// The response, containing envelopes, for a query
+public struct Xmtp_MessageApi_V1_QueryResponse {
+ // 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 envelopes: [Xmtp_MessageApi_V1_Envelope] = []
+
+ public var pagingInfo: Xmtp_MessageApi_V1_PagingInfo {
+ get {return _pagingInfo ?? Xmtp_MessageApi_V1_PagingInfo()}
+ set {_pagingInfo = newValue}
+ }
+ /// Returns true if `pagingInfo` has been explicitly set.
+ public var hasPagingInfo: Bool {return self._pagingInfo != nil}
+ /// Clears the value of `pagingInfo`. Subsequent reads from it will return its default value.
+ public mutating func clearPagingInfo() {self._pagingInfo = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _pagingInfo: Xmtp_MessageApi_V1_PagingInfo? = nil
+}
+
+/// BatchQuery
+public struct Xmtp_MessageApi_V1_BatchQueryRequest {
+ // 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 requests: [Xmtp_MessageApi_V1_QueryRequest] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// Response containing a list of QueryResponse messages
+public struct Xmtp_MessageApi_V1_BatchQueryResponse {
+ // 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 responses: [Xmtp_MessageApi_V1_QueryResponse] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageApi_V1_SortDirection: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_IndexCursor: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_Cursor: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_Cursor.OneOf_Cursor: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_PagingInfo: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_Envelope: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_PublishRequest: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_PublishResponse: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_SubscribeRequest: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_SubscribeAllRequest: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_QueryRequest: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_QueryResponse: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_BatchQueryRequest: @unchecked Sendable {}
+extension Xmtp_MessageApi_V1_BatchQueryResponse: @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.v1"
+
+extension Xmtp_MessageApi_V1_SortDirection: SwiftProtobuf._ProtoNameProviding {
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 0: .same(proto: "SORT_DIRECTION_UNSPECIFIED"),
+ 1: .same(proto: "SORT_DIRECTION_ASCENDING"),
+ 2: .same(proto: "SORT_DIRECTION_DESCENDING"),
+ ]
+}
+
+extension Xmtp_MessageApi_V1_IndexCursor: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".IndexCursor"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "digest"),
+ 2: .standard(proto: "sender_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.decodeSingularBytesField(value: &self.digest) }()
+ case 2: try { try decoder.decodeSingularUInt64Field(value: &self.senderTimeNs) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.digest.isEmpty {
+ try visitor.visitSingularBytesField(value: self.digest, fieldNumber: 1)
+ }
+ if self.senderTimeNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.senderTimeNs, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_IndexCursor, rhs: Xmtp_MessageApi_V1_IndexCursor) -> Bool {
+ if lhs.digest != rhs.digest {return false}
+ if lhs.senderTimeNs != rhs.senderTimeNs {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_Cursor: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Cursor"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "index"),
+ ]
+
+ 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_MessageApi_V1_IndexCursor?
+ var hadOneofValue = false
+ if let current = self.cursor {
+ hadOneofValue = true
+ if case .index(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.cursor = .index(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 .index(let v)? = self.cursor {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_Cursor, rhs: Xmtp_MessageApi_V1_Cursor) -> Bool {
+ if lhs.cursor != rhs.cursor {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_PagingInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PagingInfo"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "limit"),
+ 2: .same(proto: "cursor"),
+ 3: .same(proto: "direction"),
+ ]
+
+ 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.decodeSingularUInt32Field(value: &self.limit) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._cursor) }()
+ case 3: try { try decoder.decodeSingularEnumField(value: &self.direction) }()
+ 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.limit != 0 {
+ try visitor.visitSingularUInt32Field(value: self.limit, fieldNumber: 1)
+ }
+ try { if let v = self._cursor {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ if self.direction != .unspecified {
+ try visitor.visitSingularEnumField(value: self.direction, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_PagingInfo, rhs: Xmtp_MessageApi_V1_PagingInfo) -> Bool {
+ if lhs.limit != rhs.limit {return false}
+ if lhs._cursor != rhs._cursor {return false}
+ if lhs.direction != rhs.direction {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_Envelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Envelope"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "content_topic"),
+ 2: .standard(proto: "timestamp_ns"),
+ 3: .same(proto: "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.contentTopic) }()
+ case 2: try { try decoder.decodeSingularUInt64Field(value: &self.timestampNs) }()
+ case 3: try { try decoder.decodeSingularBytesField(value: &self.message) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.contentTopic.isEmpty {
+ try visitor.visitSingularStringField(value: self.contentTopic, fieldNumber: 1)
+ }
+ if self.timestampNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.timestampNs, fieldNumber: 2)
+ }
+ if !self.message.isEmpty {
+ try visitor.visitSingularBytesField(value: self.message, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_Envelope, rhs: Xmtp_MessageApi_V1_Envelope) -> Bool {
+ if lhs.contentTopic != rhs.contentTopic {return false}
+ if lhs.timestampNs != rhs.timestampNs {return false}
+ if lhs.message != rhs.message {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_PublishRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PublishRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "envelopes"),
+ ]
+
+ 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.envelopes) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.envelopes.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.envelopes, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_PublishRequest, rhs: Xmtp_MessageApi_V1_PublishRequest) -> Bool {
+ if lhs.envelopes != rhs.envelopes {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_PublishResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PublishResponse"
+ 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_MessageApi_V1_PublishResponse, rhs: Xmtp_MessageApi_V1_PublishResponse) -> Bool {
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_SubscribeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SubscribeRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "content_topics"),
+ ]
+
+ 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.contentTopics) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.contentTopics.isEmpty {
+ try visitor.visitRepeatedStringField(value: self.contentTopics, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_SubscribeRequest, rhs: Xmtp_MessageApi_V1_SubscribeRequest) -> Bool {
+ if lhs.contentTopics != rhs.contentTopics {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_SubscribeAllRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SubscribeAllRequest"
+ 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_MessageApi_V1_SubscribeAllRequest, rhs: Xmtp_MessageApi_V1_SubscribeAllRequest) -> Bool {
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_QueryRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".QueryRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "content_topics"),
+ 2: .standard(proto: "start_time_ns"),
+ 3: .standard(proto: "end_time_ns"),
+ 4: .standard(proto: "paging_info"),
+ ]
+
+ 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.contentTopics) }()
+ case 2: try { try decoder.decodeSingularUInt64Field(value: &self.startTimeNs) }()
+ case 3: try { try decoder.decodeSingularUInt64Field(value: &self.endTimeNs) }()
+ case 4: try { try decoder.decodeSingularMessageField(value: &self._pagingInfo) }()
+ 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.contentTopics.isEmpty {
+ try visitor.visitRepeatedStringField(value: self.contentTopics, fieldNumber: 1)
+ }
+ if self.startTimeNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.startTimeNs, fieldNumber: 2)
+ }
+ if self.endTimeNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.endTimeNs, fieldNumber: 3)
+ }
+ try { if let v = self._pagingInfo {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_QueryRequest, rhs: Xmtp_MessageApi_V1_QueryRequest) -> Bool {
+ if lhs.contentTopics != rhs.contentTopics {return false}
+ if lhs.startTimeNs != rhs.startTimeNs {return false}
+ if lhs.endTimeNs != rhs.endTimeNs {return false}
+ if lhs._pagingInfo != rhs._pagingInfo {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_QueryResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".QueryResponse"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "envelopes"),
+ 2: .standard(proto: "paging_info"),
+ ]
+
+ 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.envelopes) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._pagingInfo) }()
+ 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.envelopes.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.envelopes, fieldNumber: 1)
+ }
+ try { if let v = self._pagingInfo {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_QueryResponse, rhs: Xmtp_MessageApi_V1_QueryResponse) -> Bool {
+ if lhs.envelopes != rhs.envelopes {return false}
+ if lhs._pagingInfo != rhs._pagingInfo {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_BatchQueryRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".BatchQueryRequest"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "requests"),
+ ]
+
+ 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.requests) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.requests.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.requests, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_BatchQueryRequest, rhs: Xmtp_MessageApi_V1_BatchQueryRequest) -> Bool {
+ if lhs.requests != rhs.requests {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageApi_V1_BatchQueryResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".BatchQueryResponse"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "responses"),
+ ]
+
+ 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.responses) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.responses.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.responses, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageApi_V1_BatchQueryResponse, rhs: Xmtp_MessageApi_V1_BatchQueryResponse) -> Bool {
+ if lhs.responses != rhs.responses {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_contents/ciphertext.pb.swift b/Sources/XMTP/Proto/message_contents/ciphertext.pb.swift
new file mode 100644
index 00000000..6d057307
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/ciphertext.pb.swift
@@ -0,0 +1,331 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/ciphertext.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Ciphertext is a generic structure for encrypted payload.
+
+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
+}
+
+/// Ciphertext represents encrypted payload.
+/// It is definited as a union to support cryptographic algorithm agility.
+/// The payload is accompanied by the cryptographic parameters
+/// required by the chosen encryption scheme.
+public struct Xmtp_MessageContents_Ciphertext {
+ // 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 union: Xmtp_MessageContents_Ciphertext.OneOf_Union? = nil
+
+ public var aes256GcmHkdfSha256: Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256 {
+ get {
+ if case .aes256GcmHkdfSha256(let v)? = union {return v}
+ return Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256()
+ }
+ set {union = .aes256GcmHkdfSha256(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Union: Equatable {
+ case aes256GcmHkdfSha256(Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_Ciphertext.OneOf_Union, rhs: Xmtp_MessageContents_Ciphertext.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 (.aes256GcmHkdfSha256, .aes256GcmHkdfSha256): return {
+ guard case .aes256GcmHkdfSha256(let l) = lhs, case .aes256GcmHkdfSha256(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ /// Encryption: AES256-GCM
+ /// Key derivation function: HKDF-SHA256
+ public struct Aes256gcmHkdfsha256 {
+ // 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.
+
+ /// 32 bytes
+ public var hkdfSalt: Data = Data()
+
+ /// 12 bytes
+ public var gcmNonce: Data = Data()
+
+ /// encrypted payload
+ public var payload: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// SignedEciesCiphertext represents an ECIES encrypted payload and a signature
+public struct Xmtp_MessageContents_SignedEciesCiphertext {
+ // 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.
+
+ /// serialized Ecies message
+ public var eciesBytes: Data = Data()
+
+ /// signature of sha256(ecies_bytes) signed with the IdentityKey
+ 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()
+
+ /// Ecies is ciphertext encrypted using ECIES with a MAC
+ public struct Ecies {
+ // 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.
+
+ /// 65 bytes
+ public var ephemeralPublicKey: Data = Data()
+
+ /// 16 bytes
+ public var iv: Data = Data()
+
+ /// 32 bytes
+ public var mac: Data = Data()
+
+ /// encrypted payload with block size of 16
+ public var ciphertext: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+
+ fileprivate var _signature: Xmtp_MessageContents_Signature? = nil
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_Ciphertext: @unchecked Sendable {}
+extension Xmtp_MessageContents_Ciphertext.OneOf_Union: @unchecked Sendable {}
+extension Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedEciesCiphertext: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedEciesCiphertext.Ecies: @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_Ciphertext: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Ciphertext"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "aes256_gcm_hkdf_sha256"),
+ ]
+
+ 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_Ciphertext.Aes256gcmHkdfsha256?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .aes256GcmHkdfSha256(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .aes256GcmHkdfSha256(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 .aes256GcmHkdfSha256(let v)? = self.union {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Ciphertext, rhs: Xmtp_MessageContents_Ciphertext) -> Bool {
+ if lhs.union != rhs.union {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_Ciphertext.protoMessageName + ".Aes256gcmHkdfsha256"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "hkdf_salt"),
+ 2: .standard(proto: "gcm_nonce"),
+ 3: .same(proto: "payload"),
+ ]
+
+ 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.hkdfSalt) }()
+ case 2: try { try decoder.decodeSingularBytesField(value: &self.gcmNonce) }()
+ case 3: try { try decoder.decodeSingularBytesField(value: &self.payload) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.hkdfSalt.isEmpty {
+ try visitor.visitSingularBytesField(value: self.hkdfSalt, fieldNumber: 1)
+ }
+ if !self.gcmNonce.isEmpty {
+ try visitor.visitSingularBytesField(value: self.gcmNonce, fieldNumber: 2)
+ }
+ if !self.payload.isEmpty {
+ try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256, rhs: Xmtp_MessageContents_Ciphertext.Aes256gcmHkdfsha256) -> Bool {
+ if lhs.hkdfSalt != rhs.hkdfSalt {return false}
+ if lhs.gcmNonce != rhs.gcmNonce {return false}
+ if lhs.payload != rhs.payload {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SignedEciesCiphertext: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SignedEciesCiphertext"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "ecies_bytes"),
+ 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.eciesBytes) }()
+ 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.eciesBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.eciesBytes, 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_SignedEciesCiphertext, rhs: Xmtp_MessageContents_SignedEciesCiphertext) -> Bool {
+ if lhs.eciesBytes != rhs.eciesBytes {return false}
+ if lhs._signature != rhs._signature {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SignedEciesCiphertext.Ecies: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_SignedEciesCiphertext.protoMessageName + ".Ecies"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "ephemeral_public_key"),
+ 2: .same(proto: "iv"),
+ 3: .same(proto: "mac"),
+ 4: .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.ephemeralPublicKey) }()
+ case 2: try { try decoder.decodeSingularBytesField(value: &self.iv) }()
+ case 3: try { try decoder.decodeSingularBytesField(value: &self.mac) }()
+ case 4: try { try decoder.decodeSingularBytesField(value: &self.ciphertext) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.ephemeralPublicKey.isEmpty {
+ try visitor.visitSingularBytesField(value: self.ephemeralPublicKey, fieldNumber: 1)
+ }
+ if !self.iv.isEmpty {
+ try visitor.visitSingularBytesField(value: self.iv, fieldNumber: 2)
+ }
+ if !self.mac.isEmpty {
+ try visitor.visitSingularBytesField(value: self.mac, fieldNumber: 3)
+ }
+ if !self.ciphertext.isEmpty {
+ try visitor.visitSingularBytesField(value: self.ciphertext, fieldNumber: 4)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_SignedEciesCiphertext.Ecies, rhs: Xmtp_MessageContents_SignedEciesCiphertext.Ecies) -> Bool {
+ if lhs.ephemeralPublicKey != rhs.ephemeralPublicKey {return false}
+ if lhs.iv != rhs.iv {return false}
+ if lhs.mac != rhs.mac {return false}
+ if lhs.ciphertext != rhs.ciphertext {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_contents/composite.pb.swift b/Sources/XMTP/Proto/message_contents/composite.pb.swift
new file mode 100644
index 00000000..015eba3b
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/composite.pb.swift
@@ -0,0 +1,201 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/composite.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Composite ContentType
+
+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
+}
+
+/// Composite is used to implement xmtp.org/composite content type
+public struct Xmtp_MessageContents_Composite {
+ // 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 parts: [Xmtp_MessageContents_Composite.Part] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// Part represents one section of a composite message
+ public struct Part {
+ // 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 element: Xmtp_MessageContents_Composite.Part.OneOf_Element? = nil
+
+ public var part: Xmtp_MessageContents_EncodedContent {
+ get {
+ if case .part(let v)? = element {return v}
+ return Xmtp_MessageContents_EncodedContent()
+ }
+ set {element = .part(newValue)}
+ }
+
+ public var composite: Xmtp_MessageContents_Composite {
+ get {
+ if case .composite(let v)? = element {return v}
+ return Xmtp_MessageContents_Composite()
+ }
+ set {element = .composite(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Element: Equatable {
+ case part(Xmtp_MessageContents_EncodedContent)
+ case composite(Xmtp_MessageContents_Composite)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_Composite.Part.OneOf_Element, rhs: Xmtp_MessageContents_Composite.Part.OneOf_Element) -> 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 (.part, .part): return {
+ guard case .part(let l) = lhs, case .part(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ case (.composite, .composite): return {
+ guard case .composite(let l) = lhs, case .composite(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_Composite: @unchecked Sendable {}
+extension Xmtp_MessageContents_Composite.Part: @unchecked Sendable {}
+extension Xmtp_MessageContents_Composite.Part.OneOf_Element: @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_Composite: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Composite"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "parts"),
+ ]
+
+ 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.parts) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.parts.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.parts, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Composite, rhs: Xmtp_MessageContents_Composite) -> Bool {
+ if lhs.parts != rhs.parts {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_Composite.Part: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_Composite.protoMessageName + ".Part"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "part"),
+ 2: .same(proto: "composite"),
+ ]
+
+ 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_EncodedContent?
+ var hadOneofValue = false
+ if let current = self.element {
+ hadOneofValue = true
+ if case .part(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.element = .part(v)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_MessageContents_Composite?
+ var hadOneofValue = false
+ if let current = self.element {
+ hadOneofValue = true
+ if case .composite(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.element = .composite(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.element {
+ case .part?: try {
+ guard case .part(let v)? = self.element else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .composite?: try {
+ guard case .composite(let v)? = self.element else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Composite.Part, rhs: Xmtp_MessageContents_Composite.Part) -> Bool {
+ if lhs.element != rhs.element {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_contents/contact.pb.swift b/Sources/XMTP/Proto/message_contents/contact.pb.swift
new file mode 100644
index 00000000..2795a424
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/contact.pb.swift
@@ -0,0 +1,278 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/contact.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Contact Bundles are used to advertise user's public keys on the network.
+/// They are published in well known topics so that other participants
+/// can find them when they wish to communicate with the user.
+/// The public keys are used to sign messages and to derive encryption keys
+/// for some meta-messages, e.g. invitations.
+
+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
+}
+
+/// LEGACY: User key bundle V1 using PublicKeys.
+/// The PublicKeys MUST be signed.
+public struct Xmtp_MessageContents_ContactBundleV1 {
+ // 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 keyBundle: Xmtp_MessageContents_PublicKeyBundle {
+ get {return _keyBundle ?? Xmtp_MessageContents_PublicKeyBundle()}
+ set {_keyBundle = newValue}
+ }
+ /// Returns true if `keyBundle` has been explicitly set.
+ public var hasKeyBundle: Bool {return self._keyBundle != nil}
+ /// Clears the value of `keyBundle`. Subsequent reads from it will return its default value.
+ public mutating func clearKeyBundle() {self._keyBundle = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _keyBundle: Xmtp_MessageContents_PublicKeyBundle? = nil
+}
+
+/// User key bundle V2 using SignedPublicKeys.
+public struct Xmtp_MessageContents_ContactBundleV2 {
+ // 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 keyBundle: Xmtp_MessageContents_SignedPublicKeyBundle {
+ get {return _keyBundle ?? Xmtp_MessageContents_SignedPublicKeyBundle()}
+ set {_keyBundle = newValue}
+ }
+ /// Returns true if `keyBundle` has been explicitly set.
+ public var hasKeyBundle: Bool {return self._keyBundle != nil}
+ /// Clears the value of `keyBundle`. Subsequent reads from it will return its default value.
+ public mutating func clearKeyBundle() {self._keyBundle = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _keyBundle: Xmtp_MessageContents_SignedPublicKeyBundle? = nil
+}
+
+/// Versioned ContactBundle
+public struct Xmtp_MessageContents_ContactBundle {
+ // 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_ContactBundle.OneOf_Version? = nil
+
+ public var v1: Xmtp_MessageContents_ContactBundleV1 {
+ get {
+ if case .v1(let v)? = version {return v}
+ return Xmtp_MessageContents_ContactBundleV1()
+ }
+ set {version = .v1(newValue)}
+ }
+
+ public var v2: Xmtp_MessageContents_ContactBundleV2 {
+ get {
+ if case .v2(let v)? = version {return v}
+ return Xmtp_MessageContents_ContactBundleV2()
+ }
+ set {version = .v2(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Version: Equatable {
+ case v1(Xmtp_MessageContents_ContactBundleV1)
+ case v2(Xmtp_MessageContents_ContactBundleV2)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_ContactBundle.OneOf_Version, rhs: Xmtp_MessageContents_ContactBundle.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
+ }()
+ case (.v2, .v2): return {
+ guard case .v2(let l) = lhs, case .v2(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ public init() {}
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_ContactBundleV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_ContactBundleV2: @unchecked Sendable {}
+extension Xmtp_MessageContents_ContactBundle: @unchecked Sendable {}
+extension Xmtp_MessageContents_ContactBundle.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_ContactBundleV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".ContactBundleV1"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "key_bundle"),
+ ]
+
+ 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._keyBundle) }()
+ 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._keyBundle {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_ContactBundleV1, rhs: Xmtp_MessageContents_ContactBundleV1) -> Bool {
+ if lhs._keyBundle != rhs._keyBundle {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_ContactBundleV2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".ContactBundleV2"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "key_bundle"),
+ ]
+
+ 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._keyBundle) }()
+ 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._keyBundle {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_ContactBundleV2, rhs: Xmtp_MessageContents_ContactBundleV2) -> Bool {
+ if lhs._keyBundle != rhs._keyBundle {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_ContactBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".ContactBundle"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "v1"),
+ 2: .same(proto: "v2"),
+ ]
+
+ 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_ContactBundleV1?
+ 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)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_MessageContents_ContactBundleV2?
+ var hadOneofValue = false
+ if let current = self.version {
+ hadOneofValue = true
+ if case .v2(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.version = .v2(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.version {
+ case .v1?: try {
+ guard case .v1(let v)? = self.version else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .v2?: try {
+ guard case .v2(let v)? = self.version else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_ContactBundle, rhs: Xmtp_MessageContents_ContactBundle) -> 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/content.pb.swift b/Sources/XMTP/Proto/message_contents/content.pb.swift
new file mode 100644
index 00000000..cf73da0d
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/content.pb.swift
@@ -0,0 +1,357 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/content.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Message content encoding structures
+
+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
+}
+
+/// Recognized compression algorithms
+/// protolint:disable ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH
+public enum Xmtp_MessageContents_Compression: SwiftProtobuf.Enum {
+ public typealias RawValue = Int
+ case deflate // = 0
+ case gzip // = 1
+ case UNRECOGNIZED(Int)
+
+ public init() {
+ self = .deflate
+ }
+
+ public init?(rawValue: Int) {
+ switch rawValue {
+ case 0: self = .deflate
+ case 1: self = .gzip
+ default: self = .UNRECOGNIZED(rawValue)
+ }
+ }
+
+ public var rawValue: Int {
+ switch self {
+ case .deflate: return 0
+ case .gzip: return 1
+ case .UNRECOGNIZED(let i): return i
+ }
+ }
+
+}
+
+#if swift(>=4.2)
+
+extension Xmtp_MessageContents_Compression: CaseIterable {
+ // The compiler won't synthesize support with the UNRECOGNIZED case.
+ public static var allCases: [Xmtp_MessageContents_Compression] = [
+ .deflate,
+ .gzip,
+ ]
+}
+
+#endif // swift(>=4.2)
+
+/// ContentTypeId is used to identify the type of content stored in a Message.
+public struct Xmtp_MessageContents_ContentTypeId {
+ // 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.
+
+ /// authority governing this content type
+ public var authorityID: String = String()
+
+ /// type identifier
+ public var typeID: String = String()
+
+ /// major version of the type
+ public var versionMajor: UInt32 = 0
+
+ /// minor version of the type
+ public var versionMinor: UInt32 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// EncodedContent bundles the content with metadata identifying its type
+/// and parameters required for correct decoding and presentation of the content.
+public struct Xmtp_MessageContents_EncodedContent {
+ // 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.
+
+ /// content type identifier used to match the payload with
+ /// the correct decoding machinery
+ public var type: Xmtp_MessageContents_ContentTypeId {
+ get {return _type ?? Xmtp_MessageContents_ContentTypeId()}
+ set {_type = newValue}
+ }
+ /// Returns true if `type` has been explicitly set.
+ public var hasType: Bool {return self._type != nil}
+ /// Clears the value of `type`. Subsequent reads from it will return its default value.
+ public mutating func clearType() {self._type = nil}
+
+ /// optional encoding parameters required to correctly decode the content
+ public var parameters: Dictionary = [:]
+
+ /// optional fallback description of the content that can be used in case
+ /// the client cannot decode or render the content
+ public var fallback: String {
+ get {return _fallback ?? String()}
+ set {_fallback = newValue}
+ }
+ /// Returns true if `fallback` has been explicitly set.
+ public var hasFallback: Bool {return self._fallback != nil}
+ /// Clears the value of `fallback`. Subsequent reads from it will return its default value.
+ public mutating func clearFallback() {self._fallback = nil}
+
+ /// optional compression; the value indicates algorithm used to
+ /// compress the encoded content bytes
+ public var compression: Xmtp_MessageContents_Compression {
+ get {return _compression ?? .deflate}
+ set {_compression = newValue}
+ }
+ /// Returns true if `compression` has been explicitly set.
+ public var hasCompression: Bool {return self._compression != nil}
+ /// Clears the value of `compression`. Subsequent reads from it will return its default value.
+ public mutating func clearCompression() {self._compression = nil}
+
+ /// encoded content itself
+ public var content: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _type: Xmtp_MessageContents_ContentTypeId? = nil
+ fileprivate var _fallback: String? = nil
+ fileprivate var _compression: Xmtp_MessageContents_Compression? = nil
+}
+
+/// SignedContent attaches a signature to EncodedContent.
+public struct Xmtp_MessageContents_SignedContent {
+ // 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.
+
+ /// MUST contain EncodedContent
+ public var payload: Data = Data()
+
+ public var sender: Xmtp_MessageContents_SignedPublicKeyBundle {
+ get {return _sender ?? Xmtp_MessageContents_SignedPublicKeyBundle()}
+ set {_sender = newValue}
+ }
+ /// Returns true if `sender` has been explicitly set.
+ public var hasSender: Bool {return self._sender != nil}
+ /// Clears the value of `sender`. Subsequent reads from it will return its default value.
+ public mutating func clearSender() {self._sender = nil}
+
+ /// MUST be a signature of a concatenation of
+ /// the message header bytes and the payload bytes,
+ /// signed by the sender's pre-key.
+ 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 _sender: Xmtp_MessageContents_SignedPublicKeyBundle? = nil
+ fileprivate var _signature: Xmtp_MessageContents_Signature? = nil
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_Compression: @unchecked Sendable {}
+extension Xmtp_MessageContents_ContentTypeId: @unchecked Sendable {}
+extension Xmtp_MessageContents_EncodedContent: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedContent: @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_Compression: SwiftProtobuf._ProtoNameProviding {
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 0: .same(proto: "COMPRESSION_DEFLATE"),
+ 1: .same(proto: "COMPRESSION_GZIP"),
+ ]
+}
+
+extension Xmtp_MessageContents_ContentTypeId: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".ContentTypeId"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "authority_id"),
+ 2: .standard(proto: "type_id"),
+ 3: .standard(proto: "version_major"),
+ 4: .standard(proto: "version_minor"),
+ ]
+
+ 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.authorityID) }()
+ case 2: try { try decoder.decodeSingularStringField(value: &self.typeID) }()
+ case 3: try { try decoder.decodeSingularUInt32Field(value: &self.versionMajor) }()
+ case 4: try { try decoder.decodeSingularUInt32Field(value: &self.versionMinor) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.authorityID.isEmpty {
+ try visitor.visitSingularStringField(value: self.authorityID, fieldNumber: 1)
+ }
+ if !self.typeID.isEmpty {
+ try visitor.visitSingularStringField(value: self.typeID, fieldNumber: 2)
+ }
+ if self.versionMajor != 0 {
+ try visitor.visitSingularUInt32Field(value: self.versionMajor, fieldNumber: 3)
+ }
+ if self.versionMinor != 0 {
+ try visitor.visitSingularUInt32Field(value: self.versionMinor, fieldNumber: 4)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_ContentTypeId, rhs: Xmtp_MessageContents_ContentTypeId) -> Bool {
+ if lhs.authorityID != rhs.authorityID {return false}
+ if lhs.typeID != rhs.typeID {return false}
+ if lhs.versionMajor != rhs.versionMajor {return false}
+ if lhs.versionMinor != rhs.versionMinor {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_EncodedContent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".EncodedContent"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "type"),
+ 2: .same(proto: "parameters"),
+ 3: .same(proto: "fallback"),
+ 5: .same(proto: "compression"),
+ 4: .same(proto: "content"),
+ ]
+
+ 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._type) }()
+ case 2: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.parameters) }()
+ case 3: try { try decoder.decodeSingularStringField(value: &self._fallback) }()
+ case 4: try { try decoder.decodeSingularBytesField(value: &self.content) }()
+ case 5: try { try decoder.decodeSingularEnumField(value: &self._compression) }()
+ 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._type {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ if !self.parameters.isEmpty {
+ try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.parameters, fieldNumber: 2)
+ }
+ try { if let v = self._fallback {
+ try visitor.visitSingularStringField(value: v, fieldNumber: 3)
+ } }()
+ if !self.content.isEmpty {
+ try visitor.visitSingularBytesField(value: self.content, fieldNumber: 4)
+ }
+ try { if let v = self._compression {
+ try visitor.visitSingularEnumField(value: v, fieldNumber: 5)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_EncodedContent, rhs: Xmtp_MessageContents_EncodedContent) -> Bool {
+ if lhs._type != rhs._type {return false}
+ if lhs.parameters != rhs.parameters {return false}
+ if lhs._fallback != rhs._fallback {return false}
+ if lhs._compression != rhs._compression {return false}
+ if lhs.content != rhs.content {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SignedContent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SignedContent"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "payload"),
+ 2: .same(proto: "sender"),
+ 3: .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._sender) }()
+ case 3: 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._sender {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try { if let v = self._signature {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_SignedContent, rhs: Xmtp_MessageContents_SignedContent) -> Bool {
+ if lhs.payload != rhs.payload {return false}
+ if lhs._sender != rhs._sender {return false}
+ if lhs._signature != rhs._signature {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_contents/conversation_reference.pb.swift b/Sources/XMTP/Proto/message_contents/conversation_reference.pb.swift
new file mode 100644
index 00000000..d77cc233
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/conversation_reference.pb.swift
@@ -0,0 +1,113 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/conversation_reference.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Holds the ConversationReference
+
+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
+}
+
+/// A light pointer for a conversation that contains no decryption keys
+public struct Xmtp_MessageContents_ConversationReference {
+ // 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 topic: String = String()
+
+ public var peerAddress: String = String()
+
+ public var createdNs: UInt64 = 0
+
+ public var context: Xmtp_MessageContents_InvitationV1.Context {
+ get {return _context ?? Xmtp_MessageContents_InvitationV1.Context()}
+ set {_context = newValue}
+ }
+ /// Returns true if `context` has been explicitly set.
+ public var hasContext: Bool {return self._context != nil}
+ /// Clears the value of `context`. Subsequent reads from it will return its default value.
+ public mutating func clearContext() {self._context = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _context: Xmtp_MessageContents_InvitationV1.Context? = nil
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_ConversationReference: @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_ConversationReference: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".ConversationReference"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "topic"),
+ 2: .standard(proto: "peer_address"),
+ 3: .standard(proto: "created_ns"),
+ 4: .same(proto: "context"),
+ ]
+
+ 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.topic) }()
+ case 2: try { try decoder.decodeSingularStringField(value: &self.peerAddress) }()
+ case 3: try { try decoder.decodeSingularUInt64Field(value: &self.createdNs) }()
+ case 4: try { try decoder.decodeSingularMessageField(value: &self._context) }()
+ 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.topic.isEmpty {
+ try visitor.visitSingularStringField(value: self.topic, fieldNumber: 1)
+ }
+ if !self.peerAddress.isEmpty {
+ try visitor.visitSingularStringField(value: self.peerAddress, fieldNumber: 2)
+ }
+ if self.createdNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 3)
+ }
+ try { if let v = self._context {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_ConversationReference, rhs: Xmtp_MessageContents_ConversationReference) -> Bool {
+ if lhs.topic != rhs.topic {return false}
+ if lhs.peerAddress != rhs.peerAddress {return false}
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs._context != rhs._context {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_contents/invitation.pb.swift b/Sources/XMTP/Proto/message_contents/invitation.pb.swift
new file mode 100644
index 00000000..50b29960
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/invitation.pb.swift
@@ -0,0 +1,506 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/invitation.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Invitation is used by an initiator to invite participants
+/// into a new conversation. Invitation carries the chosen topic name
+/// and encryption scheme and key material to be used for message encryption.
+
+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
+}
+
+/// Unsealed invitation V1
+public struct Xmtp_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.
+
+ /// topic name chosen for this conversation.
+ /// It MUST be randomly generated bytes (length >= 32),
+ /// then base64 encoded without padding
+ public var topic: String = String()
+
+ /// A context object defining metadata
+ public var context: Xmtp_MessageContents_InvitationV1.Context {
+ get {return _context ?? Xmtp_MessageContents_InvitationV1.Context()}
+ set {_context = newValue}
+ }
+ /// Returns true if `context` has been explicitly set.
+ public var hasContext: Bool {return self._context != nil}
+ /// Clears the value of `context`. Subsequent reads from it will return its default value.
+ public mutating func clearContext() {self._context = nil}
+
+ /// message encryption scheme and keys for this conversation.
+ public var encryption: Xmtp_MessageContents_InvitationV1.OneOf_Encryption? = nil
+
+ /// Specify the encryption method to process the key material properly.
+ public var aes256GcmHkdfSha256: Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256 {
+ get {
+ if case .aes256GcmHkdfSha256(let v)? = encryption {return v}
+ return Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256()
+ }
+ set {encryption = .aes256GcmHkdfSha256(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// message encryption scheme and keys for this conversation.
+ public enum OneOf_Encryption: Equatable {
+ /// Specify the encryption method to process the key material properly.
+ case aes256GcmHkdfSha256(Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_InvitationV1.OneOf_Encryption, rhs: Xmtp_MessageContents_InvitationV1.OneOf_Encryption) -> 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 (.aes256GcmHkdfSha256, .aes256GcmHkdfSha256): return {
+ guard case .aes256GcmHkdfSha256(let l) = lhs, case .aes256GcmHkdfSha256(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ /// Supported encryption schemes
+ /// AES256-GCM-HKDF-SHA256
+ public struct Aes256gcmHkdfsha256 {
+ // 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.
+
+ /// randomly generated key material (32 bytes)
+ public var keyMaterial: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ /// The context type
+ public struct Context {
+ // 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.
+
+ /// Expected to be a URI (ie xmtp.org/convo1)
+ public var conversationID: String = String()
+
+ /// Key value map of additional metadata that would be exposed to
+ /// application developers and could be used for filtering
+ public var metadata: Dictionary = [:]
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+
+ fileprivate var _context: Xmtp_MessageContents_InvitationV1.Context? = nil
+}
+
+/// Sealed Invitation V1 Header
+/// Header carries information that is unencrypted, thus readable by the network
+/// it is however authenticated as associated data with the AEAD scheme used
+/// to encrypt the invitation body, thus providing tamper evidence.
+public struct Xmtp_MessageContents_SealedInvitationHeaderV1 {
+ // 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 sender: Xmtp_MessageContents_SignedPublicKeyBundle {
+ get {return _sender ?? Xmtp_MessageContents_SignedPublicKeyBundle()}
+ set {_sender = newValue}
+ }
+ /// Returns true if `sender` has been explicitly set.
+ public var hasSender: Bool {return self._sender != nil}
+ /// Clears the value of `sender`. Subsequent reads from it will return its default value.
+ public mutating func clearSender() {self._sender = nil}
+
+ public var recipient: Xmtp_MessageContents_SignedPublicKeyBundle {
+ get {return _recipient ?? Xmtp_MessageContents_SignedPublicKeyBundle()}
+ set {_recipient = newValue}
+ }
+ /// Returns true if `recipient` has been explicitly set.
+ public var hasRecipient: Bool {return self._recipient != nil}
+ /// Clears the value of `recipient`. Subsequent reads from it will return its default value.
+ public mutating func clearRecipient() {self._recipient = nil}
+
+ public var createdNs: UInt64 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _sender: Xmtp_MessageContents_SignedPublicKeyBundle? = nil
+ fileprivate var _recipient: Xmtp_MessageContents_SignedPublicKeyBundle? = nil
+}
+
+/// Sealed Invitation V1
+/// Invitation encrypted with key material derived from the sender's and
+/// recipient's public key bundles using simplified X3DH where
+/// the sender's ephemeral key is replaced with sender's pre-key.
+public struct Xmtp_MessageContents_SealedInvitationV1 {
+ // 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.
+
+ /// encoded SealedInvitationHeaderV1 used as associated data for Ciphertext
+ public var headerBytes: Data = Data()
+
+ /// Ciphertext.payload MUST contain encrypted InvitationV1.
+ public var ciphertext: Xmtp_MessageContents_Ciphertext {
+ get {return _ciphertext ?? Xmtp_MessageContents_Ciphertext()}
+ set {_ciphertext = newValue}
+ }
+ /// Returns true if `ciphertext` has been explicitly set.
+ public var hasCiphertext: Bool {return self._ciphertext != nil}
+ /// Clears the value of `ciphertext`. Subsequent reads from it will return its default value.
+ public mutating func clearCiphertext() {self._ciphertext = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _ciphertext: Xmtp_MessageContents_Ciphertext? = nil
+}
+
+/// Versioned Sealed Invitation
+public struct Xmtp_MessageContents_SealedInvitation {
+ // 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_SealedInvitation.OneOf_Version? = nil
+
+ public var v1: Xmtp_MessageContents_SealedInvitationV1 {
+ get {
+ if case .v1(let v)? = version {return v}
+ return Xmtp_MessageContents_SealedInvitationV1()
+ }
+ set {version = .v1(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Version: Equatable {
+ case v1(Xmtp_MessageContents_SealedInvitationV1)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_SealedInvitation.OneOf_Version, rhs: Xmtp_MessageContents_SealedInvitation.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_InvitationV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_InvitationV1.OneOf_Encryption: @unchecked Sendable {}
+extension Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256: @unchecked Sendable {}
+extension Xmtp_MessageContents_InvitationV1.Context: @unchecked Sendable {}
+extension Xmtp_MessageContents_SealedInvitationHeaderV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_SealedInvitationV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_SealedInvitation: @unchecked Sendable {}
+extension Xmtp_MessageContents_SealedInvitation.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_InvitationV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".InvitationV1"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "topic"),
+ 2: .same(proto: "context"),
+ 3: .standard(proto: "aes256_gcm_hkdf_sha256"),
+ ]
+
+ 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.topic) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._context) }()
+ case 3: try {
+ var v: Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256?
+ var hadOneofValue = false
+ if let current = self.encryption {
+ hadOneofValue = true
+ if case .aes256GcmHkdfSha256(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.encryption = .aes256GcmHkdfSha256(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.topic.isEmpty {
+ try visitor.visitSingularStringField(value: self.topic, fieldNumber: 1)
+ }
+ try { if let v = self._context {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try { if case .aes256GcmHkdfSha256(let v)? = self.encryption {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_InvitationV1, rhs: Xmtp_MessageContents_InvitationV1) -> Bool {
+ if lhs.topic != rhs.topic {return false}
+ if lhs._context != rhs._context {return false}
+ if lhs.encryption != rhs.encryption {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_InvitationV1.protoMessageName + ".Aes256gcmHkdfsha256"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "key_material"),
+ ]
+
+ 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.keyMaterial) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.keyMaterial.isEmpty {
+ try visitor.visitSingularBytesField(value: self.keyMaterial, fieldNumber: 1)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256, rhs: Xmtp_MessageContents_InvitationV1.Aes256gcmHkdfsha256) -> Bool {
+ if lhs.keyMaterial != rhs.keyMaterial {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_InvitationV1.Context: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_InvitationV1.protoMessageName + ".Context"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "conversation_id"),
+ 2: .same(proto: "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.decodeSingularStringField(value: &self.conversationID) }()
+ case 2: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.metadata) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.conversationID.isEmpty {
+ try visitor.visitSingularStringField(value: self.conversationID, fieldNumber: 1)
+ }
+ if !self.metadata.isEmpty {
+ try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.metadata, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_InvitationV1.Context, rhs: Xmtp_MessageContents_InvitationV1.Context) -> Bool {
+ if lhs.conversationID != rhs.conversationID {return false}
+ if lhs.metadata != rhs.metadata {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SealedInvitationHeaderV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SealedInvitationHeaderV1"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "sender"),
+ 2: .same(proto: "recipient"),
+ 3: .standard(proto: "created_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.decodeSingularMessageField(value: &self._sender) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._recipient) }()
+ case 3: try { try decoder.decodeSingularUInt64Field(value: &self.createdNs) }()
+ 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._sender {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try { if let v = self._recipient {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ if self.createdNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 3)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_SealedInvitationHeaderV1, rhs: Xmtp_MessageContents_SealedInvitationHeaderV1) -> Bool {
+ if lhs._sender != rhs._sender {return false}
+ if lhs._recipient != rhs._recipient {return false}
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SealedInvitationV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SealedInvitationV1"
+ 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.decodeSingularMessageField(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
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 1)
+ }
+ try { if let v = self._ciphertext {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_SealedInvitationV1, rhs: Xmtp_MessageContents_SealedInvitationV1) -> Bool {
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs._ciphertext != rhs._ciphertext {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SealedInvitation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SealedInvitation"
+ 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_SealedInvitationV1?
+ 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_MessageContents_SealedInvitation, rhs: Xmtp_MessageContents_SealedInvitation) -> 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/message.pb.swift b/Sources/XMTP/Proto/message_contents/message.pb.swift
new file mode 100644
index 00000000..9e13e272
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/message.pb.swift
@@ -0,0 +1,600 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/message.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Messages used for transport and storage of user conversations.
+
+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
+}
+
+/// Message header is encoded separately as the bytes are also used
+/// as associated data for authenticated encryption
+public struct Xmtp_MessageContents_MessageHeaderV1 {
+ // 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 sender: Xmtp_MessageContents_PublicKeyBundle {
+ get {return _storage._sender ?? Xmtp_MessageContents_PublicKeyBundle()}
+ set {_uniqueStorage()._sender = newValue}
+ }
+ /// Returns true if `sender` has been explicitly set.
+ public var hasSender: Bool {return _storage._sender != nil}
+ /// Clears the value of `sender`. Subsequent reads from it will return its default value.
+ public mutating func clearSender() {_uniqueStorage()._sender = nil}
+
+ public var recipient: Xmtp_MessageContents_PublicKeyBundle {
+ get {return _storage._recipient ?? Xmtp_MessageContents_PublicKeyBundle()}
+ set {_uniqueStorage()._recipient = newValue}
+ }
+ /// Returns true if `recipient` has been explicitly set.
+ public var hasRecipient: Bool {return _storage._recipient != nil}
+ /// Clears the value of `recipient`. Subsequent reads from it will return its default value.
+ public mutating func clearRecipient() {_uniqueStorage()._recipient = nil}
+
+ public var timestamp: UInt64 {
+ get {return _storage._timestamp}
+ set {_uniqueStorage()._timestamp = newValue}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _storage = _StorageClass.defaultInstance
+}
+
+/// Message is the top level protocol element
+public struct Xmtp_MessageContents_MessageV1 {
+ // 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.
+
+ /// encapsulates encoded MessageHeaderV1
+ public var headerBytes: Data = Data()
+
+ /// Ciphertext.payload MUST contain encrypted EncodedContent
+ public var ciphertext: Xmtp_MessageContents_Ciphertext {
+ get {return _ciphertext ?? Xmtp_MessageContents_Ciphertext()}
+ set {_ciphertext = newValue}
+ }
+ /// Returns true if `ciphertext` has been explicitly set.
+ public var hasCiphertext: Bool {return self._ciphertext != nil}
+ /// Clears the value of `ciphertext`. Subsequent reads from it will return its default value.
+ public mutating func clearCiphertext() {self._ciphertext = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _ciphertext: Xmtp_MessageContents_Ciphertext? = nil
+}
+
+/// Message header carries information that is not encrypted, and is therefore
+/// observable by the network. It is however authenticated as associated data
+/// of the AEAD encryption used to protect the message,
+/// thus providing tamper evidence.
+public struct Xmtp_MessageContents_MessageHeaderV2 {
+ // 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.
+
+ /// sender specified message creation time
+ public var createdNs: UInt64 = 0
+
+ /// the topic the message belongs to
+ public var topic: String = String()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+}
+
+/// Message combines the encoded header with the encrypted payload.
+public struct Xmtp_MessageContents_MessageV2 {
+ // 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.
+
+ /// encapsulates encoded MessageHeaderV2
+ public var headerBytes: Data = Data()
+
+ /// Ciphertext.payload MUST contain encrypted SignedContent
+ public var ciphertext: Xmtp_MessageContents_Ciphertext {
+ get {return _ciphertext ?? Xmtp_MessageContents_Ciphertext()}
+ set {_ciphertext = newValue}
+ }
+ /// Returns true if `ciphertext` has been explicitly set.
+ public var hasCiphertext: Bool {return self._ciphertext != nil}
+ /// Clears the value of `ciphertext`. Subsequent reads from it will return its default value.
+ public mutating func clearCiphertext() {self._ciphertext = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _ciphertext: Xmtp_MessageContents_Ciphertext? = nil
+}
+
+/// Versioned Message
+public struct Xmtp_MessageContents_Message {
+ // 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_Message.OneOf_Version? = nil
+
+ public var v1: Xmtp_MessageContents_MessageV1 {
+ get {
+ if case .v1(let v)? = version {return v}
+ return Xmtp_MessageContents_MessageV1()
+ }
+ set {version = .v1(newValue)}
+ }
+
+ public var v2: Xmtp_MessageContents_MessageV2 {
+ get {
+ if case .v2(let v)? = version {return v}
+ return Xmtp_MessageContents_MessageV2()
+ }
+ set {version = .v2(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Version: Equatable {
+ case v1(Xmtp_MessageContents_MessageV1)
+ case v2(Xmtp_MessageContents_MessageV2)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_Message.OneOf_Version, rhs: Xmtp_MessageContents_Message.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
+ }()
+ case (.v2, .v2): return {
+ guard case .v2(let l) = lhs, case .v2(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ public init() {}
+}
+
+/// DecodedMessage represents the decrypted message contents.
+/// DecodedMessage instances are not stored on the network, but
+/// may be serialized and stored by clients
+public struct Xmtp_MessageContents_DecodedMessage {
+ // 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 id: String = String()
+
+ public var messageVersion: String = String()
+
+ public var senderAddress: String = String()
+
+ public var recipientAddress: String {
+ get {return _recipientAddress ?? String()}
+ set {_recipientAddress = newValue}
+ }
+ /// Returns true if `recipientAddress` has been explicitly set.
+ public var hasRecipientAddress: Bool {return self._recipientAddress != nil}
+ /// Clears the value of `recipientAddress`. Subsequent reads from it will return its default value.
+ public mutating func clearRecipientAddress() {self._recipientAddress = nil}
+
+ public var sentNs: UInt64 = 0
+
+ public var contentTopic: String = String()
+
+ public var conversation: Xmtp_MessageContents_ConversationReference {
+ get {return _conversation ?? Xmtp_MessageContents_ConversationReference()}
+ set {_conversation = newValue}
+ }
+ /// Returns true if `conversation` has been explicitly set.
+ public var hasConversation: Bool {return self._conversation != nil}
+ /// Clears the value of `conversation`. Subsequent reads from it will return its default value.
+ public mutating func clearConversation() {self._conversation = nil}
+
+ /// encapsulates EncodedContent
+ public var contentBytes: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _recipientAddress: String? = nil
+ fileprivate var _conversation: Xmtp_MessageContents_ConversationReference? = nil
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_MessageHeaderV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_MessageV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_MessageHeaderV2: @unchecked Sendable {}
+extension Xmtp_MessageContents_MessageV2: @unchecked Sendable {}
+extension Xmtp_MessageContents_Message: @unchecked Sendable {}
+extension Xmtp_MessageContents_Message.OneOf_Version: @unchecked Sendable {}
+extension Xmtp_MessageContents_DecodedMessage: @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_MessageHeaderV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".MessageHeaderV1"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "sender"),
+ 2: .same(proto: "recipient"),
+ 3: .same(proto: "timestamp"),
+ ]
+
+ fileprivate class _StorageClass {
+ var _sender: Xmtp_MessageContents_PublicKeyBundle? = nil
+ var _recipient: Xmtp_MessageContents_PublicKeyBundle? = nil
+ var _timestamp: UInt64 = 0
+
+ static let defaultInstance = _StorageClass()
+
+ private init() {}
+
+ init(copying source: _StorageClass) {
+ _sender = source._sender
+ _recipient = source._recipient
+ _timestamp = source._timestamp
+ }
+ }
+
+ fileprivate mutating func _uniqueStorage() -> _StorageClass {
+ if !isKnownUniquelyReferenced(&_storage) {
+ _storage = _StorageClass(copying: _storage)
+ }
+ return _storage
+ }
+
+ public mutating func decodeMessage(decoder: inout D) throws {
+ _ = _uniqueStorage()
+ try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
+ 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: &_storage._sender) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &_storage._recipient) }()
+ case 3: try { try decoder.decodeSingularUInt64Field(value: &_storage._timestamp) }()
+ default: break
+ }
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
+ // 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 = _storage._sender {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ } }()
+ try { if let v = _storage._recipient {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ if _storage._timestamp != 0 {
+ try visitor.visitSingularUInt64Field(value: _storage._timestamp, fieldNumber: 3)
+ }
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_MessageHeaderV1, rhs: Xmtp_MessageContents_MessageHeaderV1) -> Bool {
+ if lhs._storage !== rhs._storage {
+ let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
+ let _storage = _args.0
+ let rhs_storage = _args.1
+ if _storage._sender != rhs_storage._sender {return false}
+ if _storage._recipient != rhs_storage._recipient {return false}
+ if _storage._timestamp != rhs_storage._timestamp {return false}
+ return true
+ }
+ if !storagesAreEqual {return false}
+ }
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_MessageV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".MessageV1"
+ 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.decodeSingularMessageField(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
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 1)
+ }
+ try { if let v = self._ciphertext {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_MessageV1, rhs: Xmtp_MessageContents_MessageV1) -> Bool {
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs._ciphertext != rhs._ciphertext {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_MessageHeaderV2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".MessageHeaderV2"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "created_ns"),
+ 2: .same(proto: "topic"),
+ ]
+
+ 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 { try decoder.decodeSingularStringField(value: &self.topic) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if self.createdNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.createdNs, fieldNumber: 1)
+ }
+ if !self.topic.isEmpty {
+ try visitor.visitSingularStringField(value: self.topic, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_MessageHeaderV2, rhs: Xmtp_MessageContents_MessageHeaderV2) -> Bool {
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs.topic != rhs.topic {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_MessageV2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".MessageV2"
+ 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.decodeSingularMessageField(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
+ if !self.headerBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.headerBytes, fieldNumber: 1)
+ }
+ try { if let v = self._ciphertext {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_MessageV2, rhs: Xmtp_MessageContents_MessageV2) -> Bool {
+ if lhs.headerBytes != rhs.headerBytes {return false}
+ if lhs._ciphertext != rhs._ciphertext {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_Message: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Message"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "v1"),
+ 2: .same(proto: "v2"),
+ ]
+
+ 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_MessageV1?
+ 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)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_MessageContents_MessageV2?
+ var hadOneofValue = false
+ if let current = self.version {
+ hadOneofValue = true
+ if case .v2(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.version = .v2(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.version {
+ case .v1?: try {
+ guard case .v1(let v)? = self.version else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .v2?: try {
+ guard case .v2(let v)? = self.version else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Message, rhs: Xmtp_MessageContents_Message) -> Bool {
+ if lhs.version != rhs.version {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_DecodedMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".DecodedMessage"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "id"),
+ 2: .standard(proto: "message_version"),
+ 3: .standard(proto: "sender_address"),
+ 4: .standard(proto: "recipient_address"),
+ 5: .standard(proto: "sent_ns"),
+ 6: .standard(proto: "content_topic"),
+ 7: .same(proto: "conversation"),
+ 8: .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.decodeSingularStringField(value: &self.id) }()
+ case 2: try { try decoder.decodeSingularStringField(value: &self.messageVersion) }()
+ case 3: try { try decoder.decodeSingularStringField(value: &self.senderAddress) }()
+ case 4: try { try decoder.decodeSingularStringField(value: &self._recipientAddress) }()
+ case 5: try { try decoder.decodeSingularUInt64Field(value: &self.sentNs) }()
+ case 6: try { try decoder.decodeSingularStringField(value: &self.contentTopic) }()
+ case 7: try { try decoder.decodeSingularMessageField(value: &self._conversation) }()
+ case 8: 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.id.isEmpty {
+ try visitor.visitSingularStringField(value: self.id, fieldNumber: 1)
+ }
+ if !self.messageVersion.isEmpty {
+ try visitor.visitSingularStringField(value: self.messageVersion, fieldNumber: 2)
+ }
+ if !self.senderAddress.isEmpty {
+ try visitor.visitSingularStringField(value: self.senderAddress, fieldNumber: 3)
+ }
+ try { if let v = self._recipientAddress {
+ try visitor.visitSingularStringField(value: v, fieldNumber: 4)
+ } }()
+ if self.sentNs != 0 {
+ try visitor.visitSingularUInt64Field(value: self.sentNs, fieldNumber: 5)
+ }
+ if !self.contentTopic.isEmpty {
+ try visitor.visitSingularStringField(value: self.contentTopic, fieldNumber: 6)
+ }
+ try { if let v = self._conversation {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 7)
+ } }()
+ if !self.contentBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.contentBytes, fieldNumber: 8)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_DecodedMessage, rhs: Xmtp_MessageContents_DecodedMessage) -> Bool {
+ if lhs.id != rhs.id {return false}
+ if lhs.messageVersion != rhs.messageVersion {return false}
+ if lhs.senderAddress != rhs.senderAddress {return false}
+ if lhs._recipientAddress != rhs._recipientAddress {return false}
+ if lhs.sentNs != rhs.sentNs {return false}
+ if lhs.contentTopic != rhs.contentTopic {return false}
+ if lhs._conversation != rhs._conversation {return false}
+ if lhs.contentBytes != rhs.contentBytes {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
new file mode 100644
index 00000000..4e916b5e
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/private_key.pb.swift
@@ -0,0 +1,787 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/private_key.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
+}
+
+/// PrivateKey generalized to support different key types
+public struct Xmtp_MessageContents_SignedPrivateKey {
+ // 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.
+
+ /// time the key was created
+ public var createdNs: UInt64 = 0
+
+ /// private key
+ public var union: Xmtp_MessageContents_SignedPrivateKey.OneOf_Union? = nil
+
+ public var secp256K1: Xmtp_MessageContents_SignedPrivateKey.Secp256k1 {
+ get {
+ if case .secp256K1(let v)? = union {return v}
+ return Xmtp_MessageContents_SignedPrivateKey.Secp256k1()
+ }
+ set {union = .secp256K1(newValue)}
+ }
+
+ /// public key for this private key
+ public var publicKey: Xmtp_MessageContents_SignedPublicKey {
+ get {return _publicKey ?? Xmtp_MessageContents_SignedPublicKey()}
+ set {_publicKey = newValue}
+ }
+ /// Returns true if `publicKey` has been explicitly set.
+ public var hasPublicKey: Bool {return self._publicKey != nil}
+ /// Clears the value of `publicKey`. Subsequent reads from it will return its default value.
+ public mutating func clearPublicKey() {self._publicKey = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// private key
+ public enum OneOf_Union: Equatable {
+ case secp256K1(Xmtp_MessageContents_SignedPrivateKey.Secp256k1)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_SignedPrivateKey.OneOf_Union, rhs: Xmtp_MessageContents_SignedPrivateKey.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 (.secp256K1, .secp256K1): return {
+ guard case .secp256K1(let l) = lhs, case .secp256K1(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ /// EC: SECP256k1
+ public struct Secp256k1 {
+ // 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.
+
+ /// D big-endian, 32 bytes
+ public var bytes: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+
+ fileprivate var _publicKey: Xmtp_MessageContents_SignedPublicKey? = nil
+}
+
+/// PrivateKeyBundle wraps the identityKey and the preKeys,
+/// enforces usage of signed keys.
+public struct Xmtp_MessageContents_PrivateKeyBundleV2 {
+ // 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_MessageContents_SignedPrivateKey {
+ get {return _identityKey ?? Xmtp_MessageContents_SignedPrivateKey()}
+ 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}
+
+ /// all the known pre-keys, newer keys first,
+ public var preKeys: [Xmtp_MessageContents_SignedPrivateKey] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _identityKey: Xmtp_MessageContents_SignedPrivateKey? = nil
+}
+
+/// LEGACY: PrivateKey generalized to support different key types
+public struct Xmtp_MessageContents_PrivateKey {
+ // 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.
+
+ /// time the key was created
+ public var timestamp: UInt64 = 0
+
+ /// private key
+ public var union: Xmtp_MessageContents_PrivateKey.OneOf_Union? = nil
+
+ public var secp256K1: Xmtp_MessageContents_PrivateKey.Secp256k1 {
+ get {
+ if case .secp256K1(let v)? = union {return v}
+ return Xmtp_MessageContents_PrivateKey.Secp256k1()
+ }
+ set {union = .secp256K1(newValue)}
+ }
+
+ /// public key for this private key
+ public var publicKey: Xmtp_MessageContents_PublicKey {
+ get {return _publicKey ?? Xmtp_MessageContents_PublicKey()}
+ set {_publicKey = newValue}
+ }
+ /// Returns true if `publicKey` has been explicitly set.
+ public var hasPublicKey: Bool {return self._publicKey != nil}
+ /// Clears the value of `publicKey`. Subsequent reads from it will return its default value.
+ public mutating func clearPublicKey() {self._publicKey = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ /// private key
+ public enum OneOf_Union: Equatable {
+ case secp256K1(Xmtp_MessageContents_PrivateKey.Secp256k1)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_PrivateKey.OneOf_Union, rhs: Xmtp_MessageContents_PrivateKey.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 (.secp256K1, .secp256K1): return {
+ guard case .secp256K1(let l) = lhs, case .secp256K1(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ /// EC: SECP256k1
+ public struct Secp256k1 {
+ // 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.
+
+ /// D big-endian, 32 bytes
+ public var bytes: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+
+ fileprivate var _publicKey: Xmtp_MessageContents_PublicKey? = nil
+}
+
+/// LEGACY: PrivateKeyBundleV1 wraps the identityKey and the preKeys
+public struct Xmtp_MessageContents_PrivateKeyBundleV1 {
+ // 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_MessageContents_PrivateKey {
+ get {return _identityKey ?? Xmtp_MessageContents_PrivateKey()}
+ 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}
+
+ /// all the known pre-keys, newer keys first,
+ public var preKeys: [Xmtp_MessageContents_PrivateKey] = []
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _identityKey: Xmtp_MessageContents_PrivateKey? = nil
+}
+
+/// Versioned PrivateKeyBundle
+public struct Xmtp_MessageContents_PrivateKeyBundle {
+ // 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_PrivateKeyBundle.OneOf_Version? = nil
+
+ public var v1: Xmtp_MessageContents_PrivateKeyBundleV1 {
+ get {
+ if case .v1(let v)? = version {return v}
+ return Xmtp_MessageContents_PrivateKeyBundleV1()
+ }
+ set {version = .v1(newValue)}
+ }
+
+ public var v2: Xmtp_MessageContents_PrivateKeyBundleV2 {
+ get {
+ if case .v2(let v)? = version {return v}
+ return Xmtp_MessageContents_PrivateKeyBundleV2()
+ }
+ set {version = .v2(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Version: Equatable {
+ case v1(Xmtp_MessageContents_PrivateKeyBundleV1)
+ case v2(Xmtp_MessageContents_PrivateKeyBundleV2)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_PrivateKeyBundle.OneOf_Version, rhs: Xmtp_MessageContents_PrivateKeyBundle.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
+ }()
+ case (.v2, .v2): return {
+ guard case .v2(let l) = lhs, case .v2(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ public init() {}
+}
+
+/// PrivateKeyBundle encrypted with key material generated by
+/// signing a randomly generated "pre-key" with the user's wallet,
+/// i.e. EIP-191 signature of a "storage signature" message with
+/// the pre-key embedded in it.
+/// (see xmtp-js::PrivateKeyBundle.toEncryptedBytes for details)
+public struct Xmtp_MessageContents_EncryptedPrivateKeyBundleV1 {
+ // 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.
+
+ /// randomly generated pre-key
+ public var walletPreKey: Data = Data()
+
+ /// MUST contain encrypted PrivateKeyBundle
+ public var ciphertext: Xmtp_MessageContents_Ciphertext {
+ get {return _ciphertext ?? Xmtp_MessageContents_Ciphertext()}
+ set {_ciphertext = newValue}
+ }
+ /// Returns true if `ciphertext` has been explicitly set.
+ public var hasCiphertext: Bool {return self._ciphertext != nil}
+ /// Clears the value of `ciphertext`. Subsequent reads from it will return its default value.
+ public mutating func clearCiphertext() {self._ciphertext = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _ciphertext: Xmtp_MessageContents_Ciphertext? = nil
+}
+
+/// Versioned encrypted PrivateKeyBundle
+public struct Xmtp_MessageContents_EncryptedPrivateKeyBundle {
+ // 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_EncryptedPrivateKeyBundle.OneOf_Version? = nil
+
+ public var v1: Xmtp_MessageContents_EncryptedPrivateKeyBundleV1 {
+ get {
+ if case .v1(let v)? = version {return v}
+ return Xmtp_MessageContents_EncryptedPrivateKeyBundleV1()
+ }
+ set {version = .v1(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Version: Equatable {
+ case v1(Xmtp_MessageContents_EncryptedPrivateKeyBundleV1)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_EncryptedPrivateKeyBundle.OneOf_Version, rhs: Xmtp_MessageContents_EncryptedPrivateKeyBundle.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_SignedPrivateKey: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedPrivateKey.OneOf_Union: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedPrivateKey.Secp256k1: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKeyBundleV2: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKey: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKey.OneOf_Union: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKey.Secp256k1: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKeyBundleV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKeyBundle: @unchecked Sendable {}
+extension Xmtp_MessageContents_PrivateKeyBundle.OneOf_Version: @unchecked Sendable {}
+extension Xmtp_MessageContents_EncryptedPrivateKeyBundleV1: @unchecked Sendable {}
+extension Xmtp_MessageContents_EncryptedPrivateKeyBundle: @unchecked Sendable {}
+extension Xmtp_MessageContents_EncryptedPrivateKeyBundle.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_SignedPrivateKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SignedPrivateKey"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "created_ns"),
+ 2: .same(proto: "secp256k1"),
+ 3: .standard(proto: "public_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.decodeSingularUInt64Field(value: &self.createdNs) }()
+ case 2: try {
+ var v: Xmtp_MessageContents_SignedPrivateKey.Secp256k1?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .secp256K1(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .secp256K1(v)
+ }
+ }()
+ case 3: try { try decoder.decodeSingularMessageField(value: &self._publicKey) }()
+ 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 .secp256K1(let v)? = self.union {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try { if let v = self._publicKey {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_SignedPrivateKey, rhs: Xmtp_MessageContents_SignedPrivateKey) -> Bool {
+ if lhs.createdNs != rhs.createdNs {return false}
+ if lhs.union != rhs.union {return false}
+ if lhs._publicKey != rhs._publicKey {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SignedPrivateKey.Secp256k1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_SignedPrivateKey.protoMessageName + ".Secp256k1"
+ 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_MessageContents_SignedPrivateKey.Secp256k1, rhs: Xmtp_MessageContents_SignedPrivateKey.Secp256k1) -> Bool {
+ if lhs.bytes != rhs.bytes {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PrivateKeyBundleV2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PrivateKeyBundleV2"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "identity_key"),
+ 2: .standard(proto: "pre_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.preKeys) }()
+ 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.preKeys.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.preKeys, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_PrivateKeyBundleV2, rhs: Xmtp_MessageContents_PrivateKeyBundleV2) -> Bool {
+ if lhs._identityKey != rhs._identityKey {return false}
+ if lhs.preKeys != rhs.preKeys {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PrivateKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PrivateKey"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "timestamp"),
+ 2: .same(proto: "secp256k1"),
+ 3: .standard(proto: "public_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.decodeSingularUInt64Field(value: &self.timestamp) }()
+ case 2: try {
+ var v: Xmtp_MessageContents_PrivateKey.Secp256k1?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .secp256K1(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .secp256K1(v)
+ }
+ }()
+ case 3: try { try decoder.decodeSingularMessageField(value: &self._publicKey) }()
+ 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.timestamp != 0 {
+ try visitor.visitSingularUInt64Field(value: self.timestamp, fieldNumber: 1)
+ }
+ try { if case .secp256K1(let v)? = self.union {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try { if let v = self._publicKey {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_PrivateKey, rhs: Xmtp_MessageContents_PrivateKey) -> Bool {
+ if lhs.timestamp != rhs.timestamp {return false}
+ if lhs.union != rhs.union {return false}
+ if lhs._publicKey != rhs._publicKey {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PrivateKey.Secp256k1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_PrivateKey.protoMessageName + ".Secp256k1"
+ 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_MessageContents_PrivateKey.Secp256k1, rhs: Xmtp_MessageContents_PrivateKey.Secp256k1) -> Bool {
+ if lhs.bytes != rhs.bytes {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PrivateKeyBundleV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PrivateKeyBundleV1"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "identity_key"),
+ 2: .standard(proto: "pre_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.preKeys) }()
+ 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.preKeys.isEmpty {
+ try visitor.visitRepeatedMessageField(value: self.preKeys, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_PrivateKeyBundleV1, rhs: Xmtp_MessageContents_PrivateKeyBundleV1) -> Bool {
+ if lhs._identityKey != rhs._identityKey {return false}
+ if lhs.preKeys != rhs.preKeys {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PrivateKeyBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PrivateKeyBundle"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "v1"),
+ 2: .same(proto: "v2"),
+ ]
+
+ 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.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)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_MessageContents_PrivateKeyBundleV2?
+ var hadOneofValue = false
+ if let current = self.version {
+ hadOneofValue = true
+ if case .v2(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.version = .v2(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.version {
+ case .v1?: try {
+ guard case .v1(let v)? = self.version else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .v2?: try {
+ guard case .v2(let v)? = self.version else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_PrivateKeyBundle, rhs: Xmtp_MessageContents_PrivateKeyBundle) -> Bool {
+ if lhs.version != rhs.version {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_EncryptedPrivateKeyBundleV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".EncryptedPrivateKeyBundleV1"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "wallet_pre_key"),
+ 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.walletPreKey) }()
+ case 2: try { try decoder.decodeSingularMessageField(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
+ if !self.walletPreKey.isEmpty {
+ try visitor.visitSingularBytesField(value: self.walletPreKey, fieldNumber: 1)
+ }
+ try { if let v = self._ciphertext {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_EncryptedPrivateKeyBundleV1, rhs: Xmtp_MessageContents_EncryptedPrivateKeyBundleV1) -> Bool {
+ if lhs.walletPreKey != rhs.walletPreKey {return false}
+ if lhs._ciphertext != rhs._ciphertext {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_EncryptedPrivateKeyBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".EncryptedPrivateKeyBundle"
+ 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_EncryptedPrivateKeyBundleV1?
+ 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_MessageContents_EncryptedPrivateKeyBundle, rhs: Xmtp_MessageContents_EncryptedPrivateKeyBundle) -> 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/public_key.pb.swift b/Sources/XMTP/Proto/message_contents/public_key.pb.swift
new file mode 100644
index 00000000..a1accdaf
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/public_key.pb.swift
@@ -0,0 +1,562 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: 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
+}
+
+/// UnsignedPublicKey represents a generalized public key,
+/// defined as a union to support cryptographic algorithm agility.
+public struct Xmtp_MessageContents_UnsignedPublicKey {
+ // 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_MessageContents_UnsignedPublicKey.OneOf_Union? = nil
+
+ public var secp256K1Uncompressed: Xmtp_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed {
+ get {
+ if case .secp256K1Uncompressed(let v)? = union {return v}
+ return Xmtp_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed()
+ }
+ set {union = .secp256K1Uncompressed(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Union: Equatable {
+ case secp256K1Uncompressed(Xmtp_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_UnsignedPublicKey.OneOf_Union, rhs: Xmtp_MessageContents_UnsignedPublicKey.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 (.secp256K1Uncompressed, .secp256K1Uncompressed): return {
+ guard case .secp256K1Uncompressed(let l) = lhs, case .secp256K1Uncompressed(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ /// EC: SECP256k1
+ public struct Secp256k1Uncompressed {
+ // 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.
+
+ /// uncompressed point with prefix (0x04) [ P || X || Y ], 65 bytes
+ public var bytes: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+/// 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
+ // methods supported on all messages.
+
+ /// embeds an UnsignedPublicKey
+ public var keyBytes: Data = Data()
+
+ /// signs key_bytes
+ 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
+}
+
+/// PublicKeyBundle packages the cryptographic keys associated with a wallet.
+public struct Xmtp_MessageContents_SignedPublicKeyBundle {
+ // 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.
+
+ /// Identity key MUST be signed by the wallet.
+ public var identityKey: Xmtp_MessageContents_SignedPublicKey {
+ get {return _identityKey ?? Xmtp_MessageContents_SignedPublicKey()}
+ 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}
+
+ /// Pre-key MUST be signed by the identity key.
+ public var preKey: Xmtp_MessageContents_SignedPublicKey {
+ get {return _preKey ?? Xmtp_MessageContents_SignedPublicKey()}
+ set {_preKey = newValue}
+ }
+ /// Returns true if `preKey` has been explicitly set.
+ public var hasPreKey: Bool {return self._preKey != nil}
+ /// Clears the value of `preKey`. Subsequent reads from it will return its default value.
+ public mutating func clearPreKey() {self._preKey = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _identityKey: Xmtp_MessageContents_SignedPublicKey? = nil
+ fileprivate var _preKey: Xmtp_MessageContents_SignedPublicKey? = nil
+}
+
+/// PublicKey represents a generalized public key,
+/// defined as a union to support cryptographic algorithm agility.
+public struct Xmtp_MessageContents_PublicKey {
+ // 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 timestamp: UInt64 = 0
+
+ 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 union: Xmtp_MessageContents_PublicKey.OneOf_Union? = nil
+
+ public var secp256K1Uncompressed: Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed {
+ get {
+ if case .secp256K1Uncompressed(let v)? = union {return v}
+ return Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed()
+ }
+ set {union = .secp256K1Uncompressed(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Union: Equatable {
+ case secp256K1Uncompressed(Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_PublicKey.OneOf_Union, rhs: Xmtp_MessageContents_PublicKey.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 (.secp256K1Uncompressed, .secp256K1Uncompressed): return {
+ guard case .secp256K1Uncompressed(let l) = lhs, case .secp256K1Uncompressed(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ }
+ }
+ #endif
+ }
+
+ /// The key bytes
+ public struct Secp256k1Uncompressed {
+ // 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.
+
+ /// uncompressed point with prefix (0x04) [ P || X || Y ], 65 bytes
+ public var bytes: Data = Data()
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+
+ fileprivate var _signature: Xmtp_MessageContents_Signature? = nil
+}
+
+/// PublicKeyBundle packages the cryptographic keys associated with a wallet,
+/// both senders and recipients are identified by their key bundles.
+public struct Xmtp_MessageContents_PublicKeyBundle {
+ // 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.
+
+ /// Identity key MUST be signed by the wallet.
+ public var identityKey: Xmtp_MessageContents_PublicKey {
+ get {return _identityKey ?? Xmtp_MessageContents_PublicKey()}
+ 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}
+
+ /// Pre-key MUST be signed by the identity key.
+ public var preKey: Xmtp_MessageContents_PublicKey {
+ get {return _preKey ?? Xmtp_MessageContents_PublicKey()}
+ set {_preKey = newValue}
+ }
+ /// Returns true if `preKey` has been explicitly set.
+ public var hasPreKey: Bool {return self._preKey != nil}
+ /// Clears the value of `preKey`. Subsequent reads from it will return its default value.
+ public mutating func clearPreKey() {self._preKey = nil}
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+
+ fileprivate var _identityKey: Xmtp_MessageContents_PublicKey? = nil
+ fileprivate var _preKey: Xmtp_MessageContents_PublicKey? = nil
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_UnsignedPublicKey: @unchecked Sendable {}
+extension Xmtp_MessageContents_UnsignedPublicKey.OneOf_Union: @unchecked Sendable {}
+extension Xmtp_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedPublicKey: @unchecked Sendable {}
+extension Xmtp_MessageContents_SignedPublicKeyBundle: @unchecked Sendable {}
+extension Xmtp_MessageContents_PublicKey: @unchecked Sendable {}
+extension Xmtp_MessageContents_PublicKey.OneOf_Union: @unchecked Sendable {}
+extension Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed: @unchecked Sendable {}
+extension Xmtp_MessageContents_PublicKeyBundle: @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_UnsignedPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".UnsignedPublicKey"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "created_ns"),
+ 3: .standard(proto: "secp256k1_uncompressed"),
+ ]
+
+ 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 3: try {
+ var v: Xmtp_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .secp256K1Uncompressed(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .secp256K1Uncompressed(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 .secp256K1Uncompressed(let v)? = self.union {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_UnsignedPublicKey, rhs: Xmtp_MessageContents_UnsignedPublicKey) -> 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_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_UnsignedPublicKey.protoMessageName + ".Secp256k1Uncompressed"
+ 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_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed, rhs: Xmtp_MessageContents_UnsignedPublicKey.Secp256k1Uncompressed) -> Bool {
+ if lhs.bytes != rhs.bytes {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SignedPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SignedPublicKey"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "key_bytes"),
+ 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.keyBytes) }()
+ 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.keyBytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.keyBytes, 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_SignedPublicKey, rhs: Xmtp_MessageContents_SignedPublicKey) -> Bool {
+ if lhs.keyBytes != rhs.keyBytes {return false}
+ if lhs._signature != rhs._signature {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_SignedPublicKeyBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".SignedPublicKeyBundle"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "identity_key"),
+ 2: .standard(proto: "pre_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._preKey) }()
+ 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._preKey {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_SignedPublicKeyBundle, rhs: Xmtp_MessageContents_SignedPublicKeyBundle) -> Bool {
+ if lhs._identityKey != rhs._identityKey {return false}
+ if lhs._preKey != rhs._preKey {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PublicKey"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "timestamp"),
+ 2: .same(proto: "signature"),
+ 3: .standard(proto: "secp256k1_uncompressed"),
+ ]
+
+ 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.timestamp) }()
+ case 2: try { try decoder.decodeSingularMessageField(value: &self._signature) }()
+ case 3: try {
+ var v: Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .secp256K1Uncompressed(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .secp256K1Uncompressed(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.timestamp != 0 {
+ try visitor.visitSingularUInt64Field(value: self.timestamp, fieldNumber: 1)
+ }
+ try { if let v = self._signature {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try { if case .secp256K1Uncompressed(let v)? = self.union {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_PublicKey, rhs: Xmtp_MessageContents_PublicKey) -> Bool {
+ if lhs.timestamp != rhs.timestamp {return false}
+ if lhs._signature != rhs._signature {return false}
+ if lhs.union != rhs.union {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_PublicKey.protoMessageName + ".Secp256k1Uncompressed"
+ 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_MessageContents_PublicKey.Secp256k1Uncompressed, rhs: Xmtp_MessageContents_PublicKey.Secp256k1Uncompressed) -> Bool {
+ if lhs.bytes != rhs.bytes {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_PublicKeyBundle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".PublicKeyBundle"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "identity_key"),
+ 2: .standard(proto: "pre_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._preKey) }()
+ 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._preKey {
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ } }()
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_PublicKeyBundle, rhs: Xmtp_MessageContents_PublicKeyBundle) -> Bool {
+ if lhs._identityKey != rhs._identityKey {return false}
+ if lhs._preKey != rhs._preKey {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Proto/message_contents/signature.pb.swift b/Sources/XMTP/Proto/message_contents/signature.pb.swift
new file mode 100644
index 00000000..9bb934db
--- /dev/null
+++ b/Sources/XMTP/Proto/message_contents/signature.pb.swift
@@ -0,0 +1,271 @@
+// DO NOT EDIT.
+// swift-format-ignore-file
+//
+// Generated by the Swift generator plugin for the protocol buffer compiler.
+// Source: message_contents/signature.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/apple/swift-protobuf/
+
+/// Signature is a generic structure for public key signatures.
+
+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
+}
+
+/// Signature represents a generalized public key signature,
+/// defined as a union to support cryptographic algorithm agility.
+public struct Xmtp_MessageContents_Signature {
+ // 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 union: Xmtp_MessageContents_Signature.OneOf_Union? = nil
+
+ public var ecdsaCompact: Xmtp_MessageContents_Signature.ECDSACompact {
+ get {
+ if case .ecdsaCompact(let v)? = union {return v}
+ return Xmtp_MessageContents_Signature.ECDSACompact()
+ }
+ set {union = .ecdsaCompact(newValue)}
+ }
+
+ public var walletEcdsaCompact: Xmtp_MessageContents_Signature.WalletECDSACompact {
+ get {
+ if case .walletEcdsaCompact(let v)? = union {return v}
+ return Xmtp_MessageContents_Signature.WalletECDSACompact()
+ }
+ set {union = .walletEcdsaCompact(newValue)}
+ }
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public enum OneOf_Union: Equatable {
+ case ecdsaCompact(Xmtp_MessageContents_Signature.ECDSACompact)
+ case walletEcdsaCompact(Xmtp_MessageContents_Signature.WalletECDSACompact)
+
+ #if !swift(>=4.1)
+ public static func ==(lhs: Xmtp_MessageContents_Signature.OneOf_Union, rhs: Xmtp_MessageContents_Signature.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 (.ecdsaCompact, .ecdsaCompact): return {
+ guard case .ecdsaCompact(let l) = lhs, case .ecdsaCompact(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ case (.walletEcdsaCompact, .walletEcdsaCompact): return {
+ guard case .walletEcdsaCompact(let l) = lhs, case .walletEcdsaCompact(let r) = rhs else { preconditionFailure() }
+ return l == r
+ }()
+ default: return false
+ }
+ }
+ #endif
+ }
+
+ /// ECDSA signature bytes and the recovery bit
+ public struct ECDSACompact {
+ // 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.
+
+ /// compact representation [ R || S ], 64 bytes
+ public var bytes: Data = Data()
+
+ /// recovery bit
+ public var recovery: UInt32 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ /// ECDSA signature bytes and the recovery bit
+ /// produced by xmtp-js::PublicKey.signWithWallet function, i.e.
+ /// EIP-191 signature of a "Create Identity" message with the key embedded.
+ /// Used to sign identity keys.
+ public struct WalletECDSACompact {
+ // 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.
+
+ /// compact representation [ R || S ], 64 bytes
+ public var bytes: Data = Data()
+
+ /// recovery bit
+ public var recovery: UInt32 = 0
+
+ public var unknownFields = SwiftProtobuf.UnknownStorage()
+
+ public init() {}
+ }
+
+ public init() {}
+}
+
+#if swift(>=5.5) && canImport(_Concurrency)
+extension Xmtp_MessageContents_Signature: @unchecked Sendable {}
+extension Xmtp_MessageContents_Signature.OneOf_Union: @unchecked Sendable {}
+extension Xmtp_MessageContents_Signature.ECDSACompact: @unchecked Sendable {}
+extension Xmtp_MessageContents_Signature.WalletECDSACompact: @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_Signature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = _protobuf_package + ".Signature"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .standard(proto: "ecdsa_compact"),
+ 2: .standard(proto: "wallet_ecdsa_compact"),
+ ]
+
+ 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_Signature.ECDSACompact?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .ecdsaCompact(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .ecdsaCompact(v)
+ }
+ }()
+ case 2: try {
+ var v: Xmtp_MessageContents_Signature.WalletECDSACompact?
+ var hadOneofValue = false
+ if let current = self.union {
+ hadOneofValue = true
+ if case .walletEcdsaCompact(let m) = current {v = m}
+ }
+ try decoder.decodeSingularMessageField(value: &v)
+ if let v = v {
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
+ self.union = .walletEcdsaCompact(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.union {
+ case .ecdsaCompact?: try {
+ guard case .ecdsaCompact(let v)? = self.union else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
+ }()
+ case .walletEcdsaCompact?: try {
+ guard case .walletEcdsaCompact(let v)? = self.union else { preconditionFailure() }
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
+ }()
+ case nil: break
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Signature, rhs: Xmtp_MessageContents_Signature) -> Bool {
+ if lhs.union != rhs.union {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_Signature.ECDSACompact: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_Signature.protoMessageName + ".ECDSACompact"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "bytes"),
+ 2: .same(proto: "recovery"),
+ ]
+
+ 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) }()
+ case 2: try { try decoder.decodeSingularUInt32Field(value: &self.recovery) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.bytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1)
+ }
+ if self.recovery != 0 {
+ try visitor.visitSingularUInt32Field(value: self.recovery, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Signature.ECDSACompact, rhs: Xmtp_MessageContents_Signature.ECDSACompact) -> Bool {
+ if lhs.bytes != rhs.bytes {return false}
+ if lhs.recovery != rhs.recovery {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
+
+extension Xmtp_MessageContents_Signature.WalletECDSACompact: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
+ public static let protoMessageName: String = Xmtp_MessageContents_Signature.protoMessageName + ".WalletECDSACompact"
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
+ 1: .same(proto: "bytes"),
+ 2: .same(proto: "recovery"),
+ ]
+
+ 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) }()
+ case 2: try { try decoder.decodeSingularUInt32Field(value: &self.recovery) }()
+ default: break
+ }
+ }
+ }
+
+ public func traverse(visitor: inout V) throws {
+ if !self.bytes.isEmpty {
+ try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1)
+ }
+ if self.recovery != 0 {
+ try visitor.visitSingularUInt32Field(value: self.recovery, fieldNumber: 2)
+ }
+ try unknownFields.traverse(visitor: &visitor)
+ }
+
+ public static func ==(lhs: Xmtp_MessageContents_Signature.WalletECDSACompact, rhs: Xmtp_MessageContents_Signature.WalletECDSACompact) -> Bool {
+ if lhs.bytes != rhs.bytes {return false}
+ if lhs.recovery != rhs.recovery {return false}
+ if lhs.unknownFields != rhs.unknownFields {return false}
+ return true
+ }
+}
diff --git a/Sources/XMTP/Push/XMTPPush.swift b/Sources/XMTP/Push/XMTPPush.swift
index c17aef90..9b3fb916 100644
--- a/Sources/XMTP/Push/XMTPPush.swift
+++ b/Sources/XMTP/Push/XMTPPush.swift
@@ -5,116 +5,116 @@
// Created by Pat Nakajima on 1/20/23.
//
#if canImport(UIKit)
-import Connect
-import UIKit
-import UserNotifications
+ import Connect
+ import UIKit
+ import UserNotifications
-enum XMTPPushError: Error {
- case noPushServer
-}
+ enum XMTPPushError: Error {
+ case noPushServer
+ }
-public struct XMTPPush {
- public static var shared = XMTPPush()
+ public struct XMTPPush {
+ public static var shared = XMTPPush()
- var installationID: String
- var installationIDKey: String = "installationID"
+ var installationID: String
+ var installationIDKey: String = "installationID"
- var pushServer: String = ""
+ var pushServer: String = ""
- private init() {
- if let id = UserDefaults.standard.string(forKey: installationIDKey) {
- installationID = id
- } else {
- installationID = UUID().uuidString
- UserDefaults.standard.set(installationID, forKey: installationIDKey)
+ private init() {
+ if let id = UserDefaults.standard.string(forKey: installationIDKey) {
+ installationID = id
+ } else {
+ installationID = UUID().uuidString
+ UserDefaults.standard.set(installationID, forKey: installationIDKey)
+ }
}
- }
-
- public mutating func setPushServer(_ server: String) {
- pushServer = server
- }
- public func request() async throws -> Bool {
- if pushServer == "" {
- throw XMTPPushError.noPushServer
+ public mutating func setPushServer(_ server: String) {
+ pushServer = server
}
- if try await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge]) {
- await UIApplication.shared.registerForRemoteNotifications()
+ public func request() async throws -> Bool {
+ if pushServer == "" {
+ throw XMTPPushError.noPushServer
+ }
+
+ if try await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge]) {
+// await UIApplication.shared.registerForRemoteNotifications()
+
+ return true
+ }
- return true
+ return false
}
- return false
- }
+ public func register(token: String) async throws {
+ if pushServer == "" {
+ throw XMTPPushError.noPushServer
+ }
+
+ let request = Notifications_V1_RegisterInstallationRequest.with { request in
+ request.installationID = installationID
+ request.deliveryMechanism = Notifications_V1_DeliveryMechanism.with { delivery in
+ delivery.apnsDeviceToken = token
+ delivery.deliveryMechanismType = .apnsDeviceToken(token)
+ }
+ }
- public func register(token: String) async throws {
- if pushServer == "" {
- throw XMTPPushError.noPushServer
+ _ = await client.registerInstallation(request: request)
}
- let request = Notifications_V1_RegisterInstallationRequest.with { request in
- request.installationID = installationID
- request.deliveryMechanism = Notifications_V1_DeliveryMechanism.with { delivery in
- delivery.apnsDeviceToken = token
- delivery.deliveryMechanismType = .apnsDeviceToken(token)
+ public func subscribe(topics: [String]) async throws {
+ if pushServer == "" {
+ throw XMTPPushError.noPushServer
}
+
+ let request = Notifications_V1_SubscribeRequest.with { request in
+ request.installationID = installationID
+ request.topics = topics
+ }
+
+ _ = await client.subscribe(request: request)
}
- _ = await client.registerInstallation(request: request)
+ var client: Notifications_V1_NotificationsClient {
+ let protocolClient = ProtocolClient(
+ httpClient: URLSessionHTTPClient(),
+ config: ProtocolClientConfig(
+ host: pushServer,
+ networkProtocol: .connect,
+ codec: ProtoCodec()
+ )
+ )
+
+ return Notifications_V1_NotificationsClient(client: protocolClient)
+ }
}
+#else
+ public struct XMTPPush {
+ public static var shared = XMTPPush()
+ private init() {
+ fatalError("XMTPPush not available")
+ }
- public func subscribe(topics: [String]) async throws {
- if pushServer == "" {
- throw XMTPPushError.noPushServer
+ public mutating func setPushServer(_: String) {
+ fatalError("XMTPPush not available")
}
- let request = Notifications_V1_SubscribeRequest.with { request in
- request.installationID = installationID
- request.topics = topics
+ public func request() async throws -> Bool {
+ fatalError("XMTPPush not available")
}
- _ = await client.subscribe(request: request)
- }
+ public func register(token _: String) async throws {
+ fatalError("XMTPPush not available")
+ }
- var client: Notifications_V1_NotificationsClient {
- let protocolClient = ProtocolClient(
- httpClient: URLSessionHTTPClient(),
- config: ProtocolClientConfig(
- host: pushServer,
- networkProtocol: .connect,
- codec: ProtoCodec()
- )
- )
+ public func subscribe(topics _: [String]) async throws {
+ fatalError("XMTPPush not available")
+ }
- return Notifications_V1_NotificationsClient(client: protocolClient)
- }
-}
-#else
-public struct XMTPPush {
- public static var shared = XMTPPush()
- private init() {
- fatalError("XMTPPush not available")
- }
-
- public mutating func setPushServer(_ server: String) {
- fatalError("XMTPPush not available")
- }
-
- public func request() async throws -> Bool {
- fatalError("XMTPPush not available")
- }
-
- public func register(token: String) async throws {
- fatalError("XMTPPush not available")
- }
-
- public func subscribe(topics: [String]) async throws {
- fatalError("XMTPPush not available")
- }
-
- var client: Notifications_V1_NotificationsClient {
- fatalError("XMTPPush not available")
+ var client: Notifications_V1_NotificationsClient {
+ fatalError("XMTPPush not available")
+ }
}
-}
#endif
diff --git a/Sources/XMTP/SigningKey.swift b/Sources/XMTP/SigningKey.swift
index a0448096..7b9131a8 100644
--- a/Sources/XMTP/SigningKey.swift
+++ b/Sources/XMTP/SigningKey.swift
@@ -6,7 +6,8 @@
//
import Foundation
-import secp256k1
+import web3
+import XMTPRust
/// Defines a type that is used by a ``Client`` to sign keys and messages.
///
@@ -36,9 +37,9 @@ extension SigningKey {
let signatureText = Signature.createIdentityText(key: try slimKey.serializedData())
let signature = try await sign(message: signatureText)
- let digest = try Signature.ethHash(signatureText)
- let recoveredKey = try KeyUtil.recoverPublicKey(message: digest, signature: signature.rawData)
- let address = KeyUtil.generateAddress(from: recoveredKey).toChecksumAddress()
+ let message = try Signature.ethPersonalMessage(signatureText)
+ let recoveredKey = try KeyUtilx.recoverPublicKeyKeccak256(from: signature.rawData, message: message)
+ let address = KeyUtilx.generateAddress(from: recoveredKey).toChecksumAddress()
var authorized = PublicKey()
authorized.secp256K1Uncompressed = slimKey.secp256K1Uncompressed
diff --git a/Sources/XMTPTestHelpers/TestHelpers.swift b/Sources/XMTPTestHelpers/TestHelpers.swift
index 4aac8d84..c99d0028 100644
--- a/Sources/XMTPTestHelpers/TestHelpers.swift
+++ b/Sources/XMTPTestHelpers/TestHelpers.swift
@@ -5,10 +5,11 @@
// Created by Pat Nakajima on 12/6/22.
//
+#if canImport(XCTest)
import Combine
import XCTest
@testable import XMTP
-import XMTPProto
+import XMTPRust
public struct FakeWallet: SigningKey {
public static func generate() throws -> FakeWallet {
@@ -42,9 +43,9 @@ enum FakeApiClientError: String, Error {
}
class FakeStreamHolder: ObservableObject {
- @Published var envelope: Envelope?
+ @Published var envelope: XMTP.Envelope?
- func send(envelope: Envelope) {
+ func send(envelope: XMTP.Envelope) {
self.envelope = envelope
}
}
@@ -57,9 +58,9 @@ public class FakeApiClient: ApiClient {
public var environment: XMTPEnvironment
public var authToken: String = ""
- private var responses: [String: [Envelope]] = [:]
+ private var responses: [String: [XMTP.Envelope]] = [:]
private var stream = FakeStreamHolder()
- public var published: [Envelope] = []
+ public var published: [XMTP.Envelope] = []
var cancellable: AnyCancellable?
var forbiddingQueries = false
@@ -81,7 +82,7 @@ public class FakeApiClient: ApiClient {
forbiddingQueries = false
}
- public func register(message: [Envelope], for topic: Topic) {
+ public func register(message: [XMTP.Envelope], for topic: Topic) {
var responsesForTopic = responses[topic.description] ?? []
responsesForTopic.append(contentsOf: message)
responses[topic.description] = responsesForTopic
@@ -91,15 +92,15 @@ public class FakeApiClient: ApiClient {
environment = .local
}
- public func send(envelope: Envelope) {
+ public func send(envelope: XMTP.Envelope) {
stream.send(envelope: envelope)
}
- public func findPublishedEnvelope(_ topic: Topic) -> Envelope? {
+ public func findPublishedEnvelope(_ topic: Topic) -> XMTP.Envelope? {
return findPublishedEnvelope(topic.description)
}
- public func findPublishedEnvelope(_ topic: String) -> Envelope? {
+ public func findPublishedEnvelope(_ topic: String) -> XMTP.Envelope? {
for envelope in published.reversed() {
if envelope.contentTopic == topic.description {
return envelope
@@ -111,11 +112,11 @@ public class FakeApiClient: ApiClient {
// MARK: ApiClient conformance
- public required init(environment: XMTP.XMTPEnvironment, secure _: Bool) throws {
+ public required init(environment: XMTP.XMTPEnvironment, secure _: Bool, rustClient _: XMTPRust.RustClient) throws {
self.environment = environment
}
- public func subscribe(topics: [String]) -> AsyncThrowingStream {
+ public func subscribe(topics: [String]) -> AsyncThrowingStream {
AsyncThrowingStream { continuation in
self.cancellable = stream.$envelope.sink(receiveValue: { env in
if let env, topics.contains(env.contentTopic) {
@@ -135,7 +136,7 @@ public class FakeApiClient: ApiClient {
throw FakeApiClientError.queryAssertionFailure
}
- var result: [Envelope] = []
+ var result: [XMTP.Envelope] = []
if let response = responses.removeValue(forKey: topic) {
result.append(contentsOf: response)
@@ -234,3 +235,4 @@ public extension XCTestCase {
return try! await Fixtures()
}
}
+#endif
diff --git a/Tests/XMTPTests/AuthenticationTests.swift b/Tests/XMTPTests/AuthenticationTests.swift
index 8ddd41f8..2cc76568 100644
--- a/Tests/XMTPTests/AuthenticationTests.swift
+++ b/Tests/XMTPTests/AuthenticationTests.swift
@@ -7,7 +7,6 @@
import Foundation
-import secp256k1
import XCTest
@testable import XMTP
diff --git a/Tests/XMTPTests/ClientTests.swift b/Tests/XMTPTests/ClientTests.swift
index 26aba8c9..59227c29 100644
--- a/Tests/XMTPTests/ClientTests.swift
+++ b/Tests/XMTPTests/ClientTests.swift
@@ -9,6 +9,7 @@ import Foundation
import XCTest
@testable import XMTP
+import XMTPRust
import XMTPTestHelpers
@available(iOS 15, *)
@@ -30,7 +31,7 @@ class ClientTests: XCTestCase {
func testHasPrivateKeyBundleV1() async throws {
let fakeWallet = try PrivateKey.generate()
- let client = try await Client.create(account: fakeWallet)
+ let client = try await Client.create(account: fakeWallet, apiClient: FakeApiClient())
XCTAssertEqual(1, client.privateKeyBundleV1.preKeys.count)
@@ -44,7 +45,7 @@ class ClientTests: XCTestCase {
let client = try await Client.create(account: fakeWallet)
let bundle = client.privateKeyBundle
- let clientFromV1Bundle = try Client.from(bundle: bundle)
+ let clientFromV1Bundle = try await Client.from(bundle: bundle)
XCTAssertEqual(client.address, clientFromV1Bundle.address)
XCTAssertEqual(client.privateKeyBundleV1.identityKey, clientFromV1Bundle.privateKeyBundleV1.identityKey)
@@ -56,7 +57,7 @@ class ClientTests: XCTestCase {
let client = try await Client.create(account: fakeWallet)
let bundleV1 = client.v1keys
- let clientFromV1Bundle = try Client.from(v1Bundle: bundleV1)
+ let clientFromV1Bundle = try await Client.from(v1Bundle: bundleV1)
XCTAssertEqual(client.address, clientFromV1Bundle.address)
XCTAssertEqual(client.privateKeyBundleV1.identityKey, clientFromV1Bundle.privateKeyBundleV1.identityKey)
diff --git a/Tests/XMTPTests/ConversationTests.swift b/Tests/XMTPTests/ConversationTests.swift
index e81bb5ee..e370894b 100644
--- a/Tests/XMTPTests/ConversationTests.swift
+++ b/Tests/XMTPTests/ConversationTests.swift
@@ -355,8 +355,10 @@ class ConversationTests: XCTestCase {
let expectation = expectation(description: "got a message")
Task(priority: .userInitiated) {
- for try await _ in conversation.streamMessages() {
- expectation.fulfill()
+ for try await message in conversation.streamMessages() {
+ if message.body == "hi alice" {
+ expectation.fulfill()
+ }
}
}
diff --git a/Tests/XMTPTests/IntegrationTests.swift b/Tests/XMTPTests/IntegrationTests.swift
index 2f46efa6..583a2990 100644
--- a/Tests/XMTPTests/IntegrationTests.swift
+++ b/Tests/XMTPTests/IntegrationTests.swift
@@ -9,7 +9,9 @@ import Foundation
import secp256k1
import web3
import XCTest
+import XMTPRust
@testable import XMTP
+import XMTPRust
import XMTPTestHelpers
@available(iOS 16, *)
@@ -24,7 +26,8 @@ final class IntegrationTests: XCTestCase {
let authToken = try await authorized.createAuthToken()
- let api = try GRPCApiClient(environment: .local, secure: false)
+ let rustClient = try await XMTPRust.create_client(XMTP.GRPCApiClient.envToUrl(env: .local), false)
+ let api = try GRPCApiClient(environment: .local, secure: false, rustClient: rustClient)
api.setAuthToken(authToken)
let encryptedBundle = try await authorized.toBundle.encrypted(with: alice)
@@ -72,7 +75,8 @@ final class IntegrationTests: XCTestCase {
let identity = try PrivateKey.generate()
let authorized = try await aliceWallet.createIdentity(identity)
let authToken = try await authorized.createAuthToken()
- var api = try GRPCApiClient(environment: .local, secure: false)
+ let rustClient = try await XMTPRust.create_client(XMTP.GRPCApiClient.envToUrl(env: .local), false)
+ let api = try GRPCApiClient(environment: .local, secure: false, rustClient: rustClient)
api.setAuthToken(authToken)
let encryptedBundle = try await PrivateKeyBundle(v1: alice).encrypted(with: aliceWallet)
var envelope = Envelope()
@@ -360,16 +364,16 @@ final class IntegrationTests: XCTestCase {
throw XCTSkip("integration only (requires dev network)")
// Generated from JS script
- let keyBytes: [UInt8] = [
+ let keyBytes = Data([
31, 116, 198, 193, 189, 122, 19, 254,
191, 189, 211, 215, 255, 131, 171, 239,
243, 33, 4, 62, 143, 86, 18, 195,
251, 61, 128, 90, 34, 126, 219, 236,
- ]
+ ])
var key = PrivateKey()
key.secp256K1.bytes = Data(keyBytes)
- key.publicKey.secp256K1Uncompressed.bytes = try KeyUtil.generatePublicKey(from: Data(keyBytes))
+ key.publicKey.secp256K1Uncompressed.bytes = Data(try XMTPRust.public_key_from_private_key_k256(RustVec(keyBytes)))
let client = try await XMTP.Client.create(account: key)
XCTAssertEqual(client.apiClient.environment, .dev)
@@ -430,16 +434,16 @@ final class IntegrationTests: XCTestCase {
func testCanReadGzipCompressedMessages() async throws {
throw XCTSkip("integration only (requires dev network)")
- let keyBytes: [UInt8] = [
+ let keyBytes = Data([
225, 2, 36, 98, 37, 243, 68, 234,
42, 126, 248, 246, 126, 83, 186, 197,
204, 186, 19, 173, 51, 0, 64, 0,
155, 8, 249, 247, 163, 185, 124, 159,
- ]
+ ])
var key = PrivateKey()
key.secp256K1.bytes = Data(keyBytes)
- key.publicKey.secp256K1Uncompressed.bytes = try KeyUtil.generatePublicKey(from: Data(keyBytes))
+ key.publicKey.secp256K1Uncompressed.bytes = Data(try XMTPRust.public_key_from_private_key_k256(RustVec(keyBytes)))
let client = try await XMTP.Client.create(account: key)
XCTAssertEqual(client.apiClient.environment, .dev)
@@ -453,16 +457,16 @@ final class IntegrationTests: XCTestCase {
func testCanReadZipCompressedMessages() async throws {
throw XCTSkip("integration only (requires dev network)")
- let keyBytes: [UInt8] = [
+ let keyBytes = Data([
60, 45, 240, 192, 223, 2, 14, 166,
122, 65, 231, 31, 122, 178, 158, 137,
192, 97, 139, 83, 133, 245, 149, 250,
25, 125, 25, 11, 203, 97, 12, 200,
- ]
+ ])
var key = PrivateKey()
key.secp256K1.bytes = Data(keyBytes)
- key.publicKey.secp256K1Uncompressed.bytes = try KeyUtil.generatePublicKey(from: Data(keyBytes))
+ key.publicKey.secp256K1Uncompressed.bytes = Data(try XMTPRust.public_key_from_private_key_k256(RustVec(keyBytes)))
let client = try await XMTP.Client.create(account: key)
XCTAssertEqual(client.apiClient.environment, .dev)
@@ -482,16 +486,17 @@ final class IntegrationTests: XCTestCase {
func testCanLoadAllConversations() async throws {
throw XCTSkip("integration only (requires dev network)")
- let keyBytes: [UInt8] = [
+ let keyBytes = Data([
105, 207, 193, 11, 240, 115, 115, 204,
117, 134, 201, 10, 56, 59, 52, 90,
229, 103, 15, 66, 20, 113, 118, 137,
44, 62, 130, 90, 30, 158, 182, 178,
- ]
+ ])
var key = PrivateKey()
key.secp256K1.bytes = Data(keyBytes)
- key.publicKey.secp256K1Uncompressed.bytes = try KeyUtil.generatePublicKey(from: Data(keyBytes))
+ key.publicKey.secp256K1Uncompressed.bytes = Data(try XMTPRust.public_key_from_private_key_k256(RustVec(keyBytes)))
+
let client = try await XMTP.Client.create(account: key)
diff --git a/Tests/XMTPTests/MessageTests.swift b/Tests/XMTPTests/MessageTests.swift
index c3a5a8de..72b3768b 100644
--- a/Tests/XMTPTests/MessageTests.swift
+++ b/Tests/XMTPTests/MessageTests.swift
@@ -7,6 +7,7 @@
import CryptoKit
import XCTest
+import XMTPRust
@testable import XMTP
import XMTPTestHelpers
@@ -114,7 +115,7 @@ class MessageTests: XCTestCase {
140, 247, 221, 172, 14, 188, 52, 88,
])
- key.publicKey.secp256K1Uncompressed.bytes = try KeyUtil.generatePublicKey(from: key.secp256K1.bytes)
+ key.publicKey.secp256K1Uncompressed.bytes = try KeyUtilx.generatePublicKey(from: key.secp256K1.bytes)
}
let keyBundleData = Data(
diff --git a/Tests/XMTPTests/PaginationTests.swift b/Tests/XMTPTests/PaginationTests.swift
new file mode 100644
index 00000000..f36b440c
--- /dev/null
+++ b/Tests/XMTPTests/PaginationTests.swift
@@ -0,0 +1,133 @@
+//
+// PaginationTests.swift
+//
+//
+// Created by Michael Xu on 05/16/23.
+//
+
+import Foundation
+
+import XCTest
+@testable import XMTP
+import XMTPRust
+
+@available(iOS 15, *)
+class PaginationTests: XCTestCase {
+
+ func newClientHelper(account: PrivateKey) async throws -> Client {
+ let client = try await Client.create(account: account, options: ClientOptions(api: .init(env: .local, isSecure: false)))
+ return client
+ }
+
+ func testLongConvo() async throws {
+ throw XCTSkip("integration only (requires local node)")
+
+ let alice = try PrivateKey.generate()
+ let bob = try PrivateKey.generate()
+
+ let aliceClient = try await newClientHelper(account: alice)
+ let bobClient = try await newClientHelper(account: bob)
+
+ let canAliceMessageBob = try await aliceClient.canMessage(bobClient.address)
+ XCTAssert(canAliceMessageBob)
+
+ // Start a conversation with alice
+
+ 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 alice")
+ return
+ }
+
+ guard case let .v2(aliceConversation) = try await aliceClient.conversations.newConversation(with: bob.address, context: InvitationV1.Context(conversationID: "hi")) else {
+ XCTFail("did not get a v2 conversation for alice")
+ return
+ }
+
+ try await bobConversation.send(content: "hey alice 1", sentAt: Date().addingTimeInterval(-1000))
+ try await bobConversation.send(content: "hey alice 2", sentAt: Date().addingTimeInterval(-500))
+ try await bobConversation.send(content: "hey alice 3", sentAt: Date())
+
+ let messages = try await aliceConversation.messages(limit: 1)
+ XCTAssertEqual(1, messages.count)
+ XCTAssertEqual("hey alice 3", messages[0].body)
+
+ let messages2 = try await aliceConversation.messages(limit: 1, before: messages[0].sent)
+ XCTAssertEqual(1, messages2.count)
+ XCTAssertEqual("hey alice 2", messages2[0].body)
+
+ // Send many many more messages, such that it forces cursor saving and pagination
+ for i in 4..<101 {
+ try await bobConversation.send(content: "hey alice \(i)", sentAt: Date())
+ }
+ // Grab the messages 50 at a time
+ let messages3 = try await aliceConversation.messages(limit: 50)
+ XCTAssertEqual(50, messages3.count)
+ XCTAssertEqual("hey alice 100", messages3[0].body)
+ XCTAssertEqual("hey alice 51", messages3[49].body)
+
+ let messages4 = try await aliceConversation.messages(limit: 100, before: messages3[49].sent)
+ XCTAssertEqual(50, messages4.count)
+ XCTAssertEqual("hey alice 50", messages4[0].body)
+ XCTAssertEqual("hey alice 1", messages4[49].body)
+ }
+
+ func testCanStreamConversationsV2() async throws {
+ throw XCTSkip("integration only (requires local node)")
+
+ let alice = try PrivateKey.generate()
+ let bob = try PrivateKey.generate()
+
+ // Need to upload Alice's contact bundle
+ let _ = try await newClientHelper(account: alice)
+ let bobClient = try await newClientHelper(account: bob)
+ let expectation1 = expectation(description: "got a conversation")
+ expectation1.expectedFulfillmentCount = 2
+
+ Task(priority: .userInitiated) {
+ for try await _ in bobClient.conversations.stream() {
+ print("Got one conversation")
+ expectation1.fulfill()
+ }
+ }
+
+ guard case let .v2(conversation) = try await bobClient.conversations.newConversation(with: alice.walletAddress) else {
+ XCTFail("Did not create a v2 convo")
+ return
+ }
+
+ try await conversation.send(content: "hi")
+
+ let newWallet = try PrivateKey.generate()
+ // Need to upload contact bundle
+ let _ = try await newClientHelper(account: newWallet)
+ guard case let .v2(conversation2) = try await bobClient.conversations.newConversation(with: newWallet.walletAddress) else {
+ XCTFail("Did not create a v2 convo")
+ return
+ }
+
+ try await conversation2.send(content: "hi from new wallet")
+
+ await waitForExpectations(timeout: 5)
+
+ // Test that we can stream a few more messages
+ let expectation2 = expectation(description: "got follow-up messages")
+ expectation2.expectedFulfillmentCount = 5
+ Task(priority: .userInitiated) {
+ for try await message in conversation.streamMessages() {
+ print("Got message: \(message)")
+ expectation2.fulfill()
+ }
+ }
+
+ // Slowly send out messages
+ Task(priority: .userInitiated) {
+ try! await conversation.send(content: "hi")
+ try! await conversation.send(content: "hi again")
+ try! await conversation.send(content: "hi again again")
+ try! await conversation.send(content: "hi again again again")
+ try! await conversation.send(content: "hi again again again again")
+ }
+
+ await waitForExpectations(timeout: 5)
+ }
+}
diff --git a/Tests/XMTPTests/SignatureTests.swift b/Tests/XMTPTests/SignatureTests.swift
index 21ddf607..edf72a75 100644
--- a/Tests/XMTPTests/SignatureTests.swift
+++ b/Tests/XMTPTests/SignatureTests.swift
@@ -14,7 +14,6 @@ class SignatureTests: XCTestCase {
let digest = SHA256.hash(data: Data("Hello world".utf8))
let signingKey = try PrivateKey.generate()
let signature = try await signingKey.sign(Data(digest))
-
XCTAssert(try signature.verify(signedBy: signingKey.publicKey, digest: Data("Hello world".utf8)))
}
}
diff --git a/XMTP.podspec b/XMTP.podspec
new file mode 100644
index 00000000..51e25c4d
--- /dev/null
+++ b/XMTP.podspec
@@ -0,0 +1,50 @@
+#
+# Be sure to run `pod spec lint XMTP.podspec' to ensure this is a
+# valid spec and to remove all comments including this before submitting the spec.
+#
+# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
+# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
+#
+
+Pod::Spec.new do |spec|
+
+ # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
+ #
+ # These will help people to find your library, and whilst it
+ # can feel like a chore to fill in it's definitely to your advantage. The
+ # summary should be tweet-length, and the description more in depth.
+ #
+
+ spec.name = "XMTP"
+ spec.version = "0.2.2-alpha0"
+ spec.summary = "XMTP SDK Cocoapod"
+
+ # This description is used to generate tags and improve search results.
+ # * Think: What does it do? Why did you write it? What is the focus?
+ # * Try to keep it short, snappy and to the point.
+ # * Write the description between the DESC delimiters below.
+ # * Finally, don't worry about the indent, CocoaPods strips it!
+ spec.description = <<-DESC
+ The XMTP cocoapod implements the XMTP protocol for iOS. It handles cryptographic operations and network communication with the XMTP network.
+ DESC
+
+ spec.homepage = "https://github.com/xmtp/xmtp-ios"
+
+ spec.license = "MIT"
+ spec.author = { "Pat Nakajima" => "pat@xmtp.com" }
+
+ spec.platform = :ios, '14.0', :macos, '11.0'
+
+ spec.swift_version = '5.3'
+
+ spec.source = { :git => "https://github.com/xmtp/xmtp-ios.git", :tag => "#{spec.version}" }
+ spec.source_files = "Sources/**/*.swift"
+ spec.frameworks = "CryptoKit", "UIKit"
+
+ spec.dependency "web3.swift"
+ spec.dependency "GzipSwift"
+ spec.dependency "Connect-Swift"
+ spec.dependency 'XMTPRust', '= 0.2.2-beta0'
+
+ spec.xcconfig = {'VALID_ARCHS' => 'arm64' }
+end
diff --git a/XMTPiOSExample/NotificationService/NotificationService.swift b/XMTPiOSExample/NotificationService/NotificationService.swift
index 61973008..15c2893c 100644
--- a/XMTPiOSExample/NotificationService/NotificationService.swift
+++ b/XMTPiOSExample/NotificationService/NotificationService.swift
@@ -36,22 +36,23 @@ class NotificationService: UNNotificationServiceExtension {
return
}
- let client = try Client.from(bundle: keys)
- let conversation = conversationContainer.decode(with: client)
+ Task {
+ let client = try await Client.from(bundle: keys)
+ let conversation = conversationContainer.decode(with: client)
- let envelope = XMTP.Envelope.with { envelope in
- envelope.message = encryptedMessageData
- envelope.contentTopic = topic
- }
+ let envelope = XMTP.Envelope.with { envelope in
+ envelope.message = encryptedMessageData
+ envelope.contentTopic = topic
+ }
- if let bestAttemptContent = bestAttemptContent {
- let decodedMessage = try conversation.decode(envelope)
+ if let bestAttemptContent = bestAttemptContent {
+ let decodedMessage = try conversation.decode(envelope)
- bestAttemptContent.body = (try? decodedMessage.content()) ?? "no content"
+ bestAttemptContent.body = (try? decodedMessage.content()) ?? "no content"
- contentHandler(bestAttemptContent)
+ contentHandler(bestAttemptContent)
+ }
}
-
// swiftlint:enable no_optional_try
} catch {
print("Error receiving notification: \(error)")
diff --git a/XMTPiOSExample/Podfile b/XMTPiOSExample/Podfile
new file mode 100644
index 00000000..05489aa4
--- /dev/null
+++ b/XMTPiOSExample/Podfile
@@ -0,0 +1,32 @@
+# Uncomment the next line to define a global platform for your project
+platform :ios, '16.0'
+
+target 'NotificationService' do
+ # Comment the next line if you don't want to use dynamic frameworks
+ use_frameworks!
+
+ # Pods for NotificationService
+# pod "web3.swift"
+# pod 'KeychainAccess'
+end
+
+target 'XMTPiOSExample' do
+ # Comment the next line if you don't want to use dynamic frameworks
+ use_frameworks!
+
+ # Pods for XMTPiOSExample
+# pod 'WalletConnectSwift'
+# pod "web3.swift"
+# pod 'KeychainAccess'
+# pod "XMTP", path: '../'
+end
+
+post_install do |installer|
+ installer.generated_projects.each do |project|
+ project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
+ end
+ end
+ end
+end
diff --git a/XMTPiOSExample/Podfile.lock b/XMTPiOSExample/Podfile.lock
new file mode 100644
index 00000000..76b699fe
--- /dev/null
+++ b/XMTPiOSExample/Podfile.lock
@@ -0,0 +1,3 @@
+PODFILE CHECKSUM: e82385142d41677b470dd3362d25b239b9c3621c
+
+COCOAPODS: 1.12.0
diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index 7ebf09d3..77aa8e91 100644
--- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -21,7 +21,7 @@
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
- "location" : "https://github.com/krzyzanowskim/CryptoSwift",
+ "location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "039f56c5d7960f277087a0be51f5eb04ed0ec073",
"version" : "1.5.1"
@@ -36,15 +36,6 @@
"version" : "2.0.2"
}
},
- {
- "identity" : "grpc-swift",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/grpc/grpc-swift",
- "state" : {
- "revision" : "3e17f2b847da39b50329b7a11c5ad23453190e8b",
- "version" : "1.13.0"
- }
- },
{
"identity" : "gzipswift",
"kind" : "remoteSourceControl",
@@ -63,15 +54,6 @@
"revision" : "6299daec1d74be12164fec090faf9ed14d0da9d6"
}
},
- {
- "identity" : "proto",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/xmtp/proto",
- "state" : {
- "branch" : "main",
- "revision" : "6a8905a8b260406698433d210c25c4397a93cef1"
- }
- },
{
"identity" : "secp256k1.swift",
"kind" : "remoteSourceControl",
@@ -135,24 +117,6 @@
"version" : "2.45.0"
}
},
- {
- "identity" : "swift-nio-extras",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/apple/swift-nio-extras.git",
- "state" : {
- "revision" : "91dd2d61fb772e1311bb5f13b59266b579d77e42",
- "version" : "1.15.0"
- }
- },
- {
- "identity" : "swift-nio-http2",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/apple/swift-nio-http2.git",
- "state" : {
- "revision" : "d6656967f33ed8b368b38e4b198631fc7c484a40",
- "version" : "1.23.1"
- }
- },
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
@@ -206,6 +170,15 @@
"revision" : "2d9d2188a08eef4a869d368daab21b3c08510991",
"version" : "2.6.1"
}
+ },
+ {
+ "identity" : "xmtp-rust-swift",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/xmtp/xmtp-rust-swift",
+ "state" : {
+ "revision" : "eccfc16bb8f866857ecbb1604c1dab855b1960f7",
+ "version" : "0.2.2-beta0"
+ }
}
],
"version" : 2
diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/xcshareddata/xcschemes/NotificationService.xcscheme b/XMTPiOSExample/XMTPiOSExample.xcodeproj/xcshareddata/xcschemes/NotificationService.xcscheme
new file mode 100644
index 00000000..63addb81
--- /dev/null
+++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/xcshareddata/xcschemes/NotificationService.xcscheme
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/XMTPiOSExample/XMTPiOSExample/Account/WalletConnection.swift b/XMTPiOSExample/XMTPiOSExample/Account/WalletConnection.swift
index e1426a37..c2ab1318 100644
--- a/XMTPiOSExample/XMTPiOSExample/Account/WalletConnection.swift
+++ b/XMTPiOSExample/XMTPiOSExample/Account/WalletConnection.swift
@@ -6,6 +6,7 @@
//
import Foundation
+import UIKit
import WalletConnectSwift
import web3
import XMTP
diff --git a/XMTPiOSExample/XMTPiOSExample/ContentView.swift b/XMTPiOSExample/XMTPiOSExample/ContentView.swift
index 785ac15a..00e6fea8 100644
--- a/XMTPiOSExample/XMTPiOSExample/ContentView.swift
+++ b/XMTPiOSExample/XMTPiOSExample/ContentView.swift
@@ -105,7 +105,7 @@ struct ContentView: View {
Task {
do {
let wallet = try PrivateKey.generate()
- let client = try await Client.create(account: wallet)
+ let client = try await Client.create(account: wallet, options: .init(api: .init(env: .dev, isSecure: true)))
let keysData = try client.privateKeyBundle.serializedData()
Persistence().saveKeys(keysData)
diff --git a/buf.gen.yaml b/buf.gen.yaml
new file mode 100644
index 00000000..9da67da7
--- /dev/null
+++ b/buf.gen.yaml
@@ -0,0 +1,8 @@
+version: v1
+managed:
+ enabled: true
+plugins:
+ - plugin: buf.build/apple/swift
+ out: Sources/XMTP/Proto
+ opt:
+ - Visibility=Public
diff --git a/dev/local/docker-compose.yml b/dev/local/docker-compose.yml
index ebd2112a..87736f21 100644
--- a/dev/local/docker-compose.yml
+++ b/dev/local/docker-compose.yml
@@ -2,12 +2,14 @@ version: "3.8"
services:
wakunode:
image: xmtp/node-go
+ platform: linux/arm64
environment:
- GOWAKU-NODEKEY=8a30dcb604b0b53627a5adc054dbf434b446628d4bd1eccc681d223f0550ce67
command:
- --ws
- --store
- --message-db-connection-string=postgres://postgres:xmtp@db:5432/postgres?sslmode=disable
+ - --message-db-reader-connection-string=postgres://postgres:xmtp@db:5432/postgres?sslmode=disable
- --lightpush
- --filter
- --ws-port=9001
@@ -20,7 +22,7 @@ services:
depends_on:
- db
healthcheck:
- test: ["CMD", "lsof", "-i", ":5556"]
+ test: [ "CMD", "lsof", "-i", ":5556" ]
interval: 3s
timeout: 10s
retries: 5
diff --git a/script/gen-proto b/script/gen-proto
new file mode 100755
index 00000000..eefa9f76
--- /dev/null
+++ b/script/gen-proto
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+buf generate buf.build/xmtp/proto
\ No newline at end of file
diff --git a/script/lint b/script/lint
index 659a9f34..367da22b 100755
--- a/script/lint
+++ b/script/lint
@@ -1,3 +1,3 @@
#!/usr/bin/env sh
-swiftlint Sources/ XMTPiOSExample/
+swiftlint Sources/ XMTPiOSExample/XMTPiOSExample
diff --git a/script/local b/script/local
index 10df4142..67a03a6b 100755
--- a/script/local
+++ b/script/local
@@ -1,3 +1,3 @@
#!/usr/bin/env sh
-docker-compose -p xmtp-ios-swift -f dev/local/docker-compose.yml up
+docker-compose -p xmtp-ios-swiftxx -f dev/local/docker-compose.yml up