diff --git a/Sources/XMTPiOS/ApiClient.swift b/Sources/XMTPiOS/ApiClient.swift index 37fca6d5..eda80026 100644 --- a/Sources/XMTPiOS/ApiClient.swift +++ b/Sources/XMTPiOS/ApiClient.swift @@ -35,9 +35,10 @@ extension GenericErrorDescribing { let .GroupError(message), let .Signature(message), let .GroupMetadata(message), - let .Generic(message): - return message - case .GroupMutablePermissions(message: let message): + let .Generic(message), + let .GroupMutablePermissions(message), + let .SignatureRequestError(message), + let .Erc1271SignatureError(message): return message } } diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index d91771ca..004a0b82 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -202,7 +202,7 @@ public final class Client { signingKey: account ) - let client = try Client(address: account.address, privateKeyBundleV1: privateKeyBundleV1, apiClient: apiClient, v3Client: v3Client, dbPath: dbPath, installationID: v3Client?.installationId().toHex ?? "", v3Client?.inboxId() ?? "") + let client = try Client(address: account.address, privateKeyBundleV1: privateKeyBundleV1, apiClient: apiClient, v3Client: v3Client, dbPath: dbPath, installationID: v3Client?.installationId().toHex ?? "", inboxID: v3Client?.inboxId() ?? "") let conversations = client.conversations let contacts = client.contacts try await client.ensureUserContactPublished() diff --git a/Sources/XMTPiOS/Conversation.swift b/Sources/XMTPiOS/Conversation.swift index 4fab7c6c..ad0f88ba 100644 --- a/Sources/XMTPiOS/Conversation.swift +++ b/Sources/XMTPiOS/Conversation.swift @@ -30,12 +30,12 @@ public enum Conversation: Sendable { case v1, v2, group } - public func consentState() async -> ConsentState { + public func consentState() async throws -> ConsentState { switch self { case .v1(let conversationV1): - return await conversationV1.client.contacts.consentList.state(address: peerAddress) + return try await conversationV1.client.contacts.consentList.state(address: peerAddress) case .v2(let conversationV2): - return await conversationV2.client.contacts.consentList.state(address: peerAddress) + return try await conversationV2.client.contacts.consentList.state(address: peerAddress) case let .group(group): return await group.client.contacts.consentList.groupState(groupId: group.id) } @@ -76,24 +76,28 @@ public enum Conversation: Sendable { /// The wallet address of the other person in this conversation. public var peerAddress: String { - switch self { - case let .v1(conversationV1): - return conversationV1.peerAddress - case let .v2(conversationV2): - return conversationV2.peerAddress - case let .group(group): - return group.peerAddresses.joined(separator: ",") + get throws { + switch self { + case let .v1(conversationV1): + return conversationV1.peerAddress + case let .v2(conversationV2): + return conversationV2.peerAddress + case let .group(group): + return try group.peerInboxIds.joined(separator: ",") + } } } public var peerAddresses: [String] { - switch self { - case let .v1(conversationV1): - return [conversationV1.peerAddress] - case let .v2(conversationV2): - return [conversationV2.peerAddress] - case let .group(group): - return group.peerAddresses + get throws { + switch self { + case let .v1(conversationV1): + return [conversationV1.peerAddress] + case let .v2(conversationV2): + return [conversationV2.peerAddress] + case let .group(group): + return try group.peerInboxIds + } } } @@ -124,10 +128,10 @@ public enum Conversation: Sendable { /// Exports the serializable topic data required for later import. /// See Conversations.importTopicData() - public func toTopicData() -> Xmtp_KeystoreApi_V1_TopicMap.TopicData { - Xmtp_KeystoreApi_V1_TopicMap.TopicData.with { + public func toTopicData() throws -> Xmtp_KeystoreApi_V1_TopicMap.TopicData { + try Xmtp_KeystoreApi_V1_TopicMap.TopicData.with { $0.createdNs = UInt64(createdAt.timeIntervalSince1970 * 1000) * 1_000_000 - $0.peerAddress = peerAddress + $0.peerAddress = try peerAddress if case let .v2(cv2) = self { $0.invitation = Xmtp_MessageContents_InvitationV1.with { $0.topic = cv2.topic diff --git a/Sources/XMTPiOS/Conversations.swift b/Sources/XMTPiOS/Conversations.swift index ea599129..d69eaed1 100644 --- a/Sources/XMTPiOS/Conversations.swift +++ b/Sources/XMTPiOS/Conversations.swift @@ -427,8 +427,8 @@ public actor Conversations { return .v1(conversationV1) } - private func findExistingConversation(with peerAddress: String, conversationID: String?) -> Conversation? { - return conversationsByTopic.first(where: { $0.value.peerAddress == peerAddress && + private func findExistingConversation(with peerAddress: String, conversationID: String?) throws -> Conversation? { + return try conversationsByTopic.first(where: { try $0.value.peerAddress == peerAddress && (($0.value.conversationID ?? "") == (conversationID ?? "")) })?.value } @@ -447,7 +447,7 @@ public actor Conversations { throw ConversationError.recipientIsSender } print("\(client.address) starting conversation with \(peerAddress)") - if let existing = findExistingConversation(with: peerAddress, conversationID: context?.conversationID) { + if let existing = try findExistingConversation(with: peerAddress, conversationID: context?.conversationID) { return existing } @@ -456,7 +456,7 @@ public actor Conversations { } _ = try await list() // cache old conversations and check again - if let existing = findExistingConversation(with: peerAddress, conversationID: context?.conversationID) { + if let existing = try findExistingConversation(with: peerAddress, conversationID: context?.conversationID) { return existing } @@ -633,8 +633,8 @@ public actor Conversations { } } - newConversations - .filter { $0.peerAddress != client.address && Topic.isValidTopic(topic: $0.topic) } + try newConversations + .filter { try $0.peerAddress != client.address && Topic.isValidTopic(topic: $0.topic) } .forEach { conversationsByTopic[$0.topic] = $0 } // TODO(perf): use DB to persist + sort diff --git a/Sources/XMTPiOS/Extensions/Ffi.swift b/Sources/XMTPiOS/Extensions/Ffi.swift index 2ac6c8e4..2f3f6d0b 100644 --- a/Sources/XMTPiOS/Extensions/Ffi.swift +++ b/Sources/XMTPiOS/Extensions/Ffi.swift @@ -202,7 +202,7 @@ extension FfiGroup { } extension FfiGroupMember { - var fromFFI: Group.Member { - Group.Member(ffiGroupMember: self) + var fromFFI: Member { + Member(ffiGroupMember: self) } } diff --git a/Sources/XMTPiOS/Mls/MessageV3.swift b/Sources/XMTPiOS/Mls/MessageV3.swift index ec0792e0..37c6ff95 100644 --- a/Sources/XMTPiOS/Mls/MessageV3.swift +++ b/Sources/XMTPiOS/Mls/MessageV3.swift @@ -29,8 +29,8 @@ public struct MessageV3: Identifiable { return ffiMessage.convoId } - var senderAddress: String { - return ffiMessage.addrFrom + var senderInboxId: String { + return ffiMessage.senderInboxId } var sentAt: Date { @@ -57,12 +57,12 @@ public struct MessageV3: Identifiable { client: client, topic: Topic.groupMessage(convoId.toHex).description, encodedContent: encodedContent, - senderAddress: senderAddress, + senderAddress: senderInboxId, sent: sentAt, deliveryStatus: deliveryStatus ) - if decodedMessage.encodedContent.type == ContentTypeGroupMembershipChanged && ffiMessage.kind != .membershipChange { + if decodedMessage.encodedContent.type == ContentTypeGroupUpdated && ffiMessage.kind != .membershipChange { throw MessageV3Error.decodeError("Error decoding group membership change") } @@ -96,13 +96,13 @@ public struct MessageV3: Identifiable { let decrytedMessage = DecryptedMessage( id: id.toHex, encodedContent: encodedContent, - senderAddress: senderAddress, + senderAddress: senderInboxId, sentAt: Date(), topic: Topic.groupMessage(convoId.toHex).description, deliveryStatus: deliveryStatus ) - if decrytedMessage.encodedContent.type == ContentTypeGroupMembershipChanged && ffiMessage.kind != .membershipChange { + if decrytedMessage.encodedContent.type == ContentTypeGroupUpdated && ffiMessage.kind != .membershipChange { throw MessageV3Error.decodeError("Error decoding group membership change") } diff --git a/Sources/XMTPiOS/Proto/identity/api/v1/identity.pb.swift b/Sources/XMTPiOS/Proto/identity/api/v1/identity.pb.swift deleted file mode 100644 index cb5c3780..00000000 --- a/Sources/XMTPiOS/Proto/identity/api/v1/identity.pb.swift +++ /dev/null @@ -1,601 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: identity/api/v1/identity.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 -} - -/// Publishes an identity update to the network -public struct Xmtp_Identity_Api_V1_PublishIdentityUpdateRequest { - // 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 identityUpdate: Xmtp_Identity_Associations_IdentityUpdate { - get {return _identityUpdate ?? Xmtp_Identity_Associations_IdentityUpdate()} - set {_identityUpdate = newValue} - } - /// Returns true if `identityUpdate` has been explicitly set. - public var hasIdentityUpdate: Bool {return self._identityUpdate != nil} - /// Clears the value of `identityUpdate`. Subsequent reads from it will return its default value. - public mutating func clearIdentityUpdate() {self._identityUpdate = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _identityUpdate: Xmtp_Identity_Associations_IdentityUpdate? = nil -} - -/// The response when an identity update is published -public struct Xmtp_Identity_Api_V1_PublishIdentityUpdateResponse { - // 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() {} -} - -/// Get all updates for an identity since the specified time -public struct Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var requests: [Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest.Request] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// Points to the last entry the client has received. The sequence_id should be - /// set to 0 if the client has not received anything. - 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 inboxID: String = String() - - public var sequenceID: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Returns all log entries for the requested identities -public struct Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var responses: [Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.Response] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// A single entry in the XID log on the server. - public struct IdentityUpdateLog { - // 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 sequenceID: UInt64 = 0 - - public var serverTimestampNs: UInt64 = 0 - - public var update: Xmtp_Identity_Associations_IdentityUpdate { - get {return _update ?? Xmtp_Identity_Associations_IdentityUpdate()} - set {_update = newValue} - } - /// Returns true if `update` has been explicitly set. - public var hasUpdate: Bool {return self._update != nil} - /// Clears the value of `update`. Subsequent reads from it will return its default value. - public mutating func clearUpdate() {self._update = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _update: Xmtp_Identity_Associations_IdentityUpdate? = nil - } - - /// The update log for a single identity, starting after the last cursor - 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 inboxID: String = String() - - public var updates: [Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.IdentityUpdateLog] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Request to retrieve the XIDs for the given addresses -public struct Xmtp_Identity_Api_V1_GetInboxIdsRequest { - // 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_Identity_Api_V1_GetInboxIdsRequest.Request] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// A single request for a given address - 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 address: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Response with the XIDs for the requested addresses -public struct Xmtp_Identity_Api_V1_GetInboxIdsResponse { - // 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_Identity_Api_V1_GetInboxIdsResponse.Response] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// A single response for a given address - 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 address: String = String() - - public var inboxID: String { - get {return _inboxID ?? String()} - set {_inboxID = newValue} - } - /// Returns true if `inboxID` has been explicitly set. - public var hasInboxID: Bool {return self._inboxID != nil} - /// Clears the value of `inboxID`. Subsequent reads from it will return its default value. - public mutating func clearInboxID() {self._inboxID = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _inboxID: String? = nil - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_Identity_Api_V1_PublishIdentityUpdateRequest: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_PublishIdentityUpdateResponse: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest.Request: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.IdentityUpdateLog: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.Response: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetInboxIdsRequest: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetInboxIdsRequest.Request: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetInboxIdsResponse: @unchecked Sendable {} -extension Xmtp_Identity_Api_V1_GetInboxIdsResponse.Response: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.identity.api.v1" - -extension Xmtp_Identity_Api_V1_PublishIdentityUpdateRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PublishIdentityUpdateRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "identity_update"), - ] - - 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._identityUpdate) }() - 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._identityUpdate { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Api_V1_PublishIdentityUpdateRequest, rhs: Xmtp_Identity_Api_V1_PublishIdentityUpdateRequest) -> Bool { - if lhs._identityUpdate != rhs._identityUpdate {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_PublishIdentityUpdateResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PublishIdentityUpdateResponse" - 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_Identity_Api_V1_PublishIdentityUpdateResponse, rhs: Xmtp_Identity_Api_V1_PublishIdentityUpdateResponse) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetIdentityUpdatesRequest" - 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_Identity_Api_V1_GetIdentityUpdatesRequest, rhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest) -> Bool { - if lhs.requests != rhs.requests {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest.protoMessageName + ".Request" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "inbox_id"), - 2: .standard(proto: "sequence_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.inboxID) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.sequenceID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.inboxID.isEmpty { - try visitor.visitSingularStringField(value: self.inboxID, fieldNumber: 1) - } - if self.sequenceID != 0 { - try visitor.visitSingularUInt64Field(value: self.sequenceID, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest.Request, rhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesRequest.Request) -> Bool { - if lhs.inboxID != rhs.inboxID {return false} - if lhs.sequenceID != rhs.sequenceID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetIdentityUpdatesResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "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_Identity_Api_V1_GetIdentityUpdatesResponse, rhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse) -> Bool { - if lhs.responses != rhs.responses {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.IdentityUpdateLog: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.protoMessageName + ".IdentityUpdateLog" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "sequence_id"), - 2: .standard(proto: "server_timestamp_ns"), - 3: .same(proto: "update"), - ] - - 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.sequenceID) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.serverTimestampNs) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._update) }() - 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.sequenceID != 0 { - try visitor.visitSingularUInt64Field(value: self.sequenceID, fieldNumber: 1) - } - if self.serverTimestampNs != 0 { - try visitor.visitSingularUInt64Field(value: self.serverTimestampNs, fieldNumber: 2) - } - try { if let v = self._update { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.IdentityUpdateLog, rhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.IdentityUpdateLog) -> Bool { - if lhs.sequenceID != rhs.sequenceID {return false} - if lhs.serverTimestampNs != rhs.serverTimestampNs {return false} - if lhs._update != rhs._update {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.protoMessageName + ".Response" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "inbox_id"), - 2: .same(proto: "updates"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.inboxID) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &self.updates) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.inboxID.isEmpty { - try visitor.visitSingularStringField(value: self.inboxID, fieldNumber: 1) - } - if !self.updates.isEmpty { - try visitor.visitRepeatedMessageField(value: self.updates, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.Response, rhs: Xmtp_Identity_Api_V1_GetIdentityUpdatesResponse.Response) -> Bool { - if lhs.inboxID != rhs.inboxID {return false} - if lhs.updates != rhs.updates {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetInboxIdsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetInboxIdsRequest" - 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_Identity_Api_V1_GetInboxIdsRequest, rhs: Xmtp_Identity_Api_V1_GetInboxIdsRequest) -> Bool { - if lhs.requests != rhs.requests {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetInboxIdsRequest.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Identity_Api_V1_GetInboxIdsRequest.protoMessageName + ".Request" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Api_V1_GetInboxIdsRequest.Request, rhs: Xmtp_Identity_Api_V1_GetInboxIdsRequest.Request) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetInboxIdsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetInboxIdsResponse" - 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_Identity_Api_V1_GetInboxIdsResponse, rhs: Xmtp_Identity_Api_V1_GetInboxIdsResponse) -> Bool { - if lhs.responses != rhs.responses {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Api_V1_GetInboxIdsResponse.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Identity_Api_V1_GetInboxIdsResponse.protoMessageName + ".Response" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .standard(proto: "inbox_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._inboxID) }() - 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.address.isEmpty { - try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) - } - try { if let v = self._inboxID { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Api_V1_GetInboxIdsResponse.Response, rhs: Xmtp_Identity_Api_V1_GetInboxIdsResponse.Response) -> Bool { - if lhs.address != rhs.address {return false} - if lhs._inboxID != rhs._inboxID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTPiOS/Proto/identity/associations/association.pb.swift b/Sources/XMTPiOS/Proto/identity/associations/association.pb.swift deleted file mode 100644 index 4a743a47..00000000 --- a/Sources/XMTPiOS/Proto/identity/associations/association.pb.swift +++ /dev/null @@ -1,991 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: identity/associations/association.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Payloads to be signed for identity associations - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// The identifier for a member of an XID -public struct Xmtp_Identity_Associations_MemberIdentifier { - // 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 kind: Xmtp_Identity_Associations_MemberIdentifier.OneOf_Kind? = nil - - public var address: String { - get { - if case .address(let v)? = kind {return v} - return String() - } - set {kind = .address(newValue)} - } - - public var installationPublicKey: Data { - get { - if case .installationPublicKey(let v)? = kind {return v} - return Data() - } - set {kind = .installationPublicKey(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Kind: Equatable { - case address(String) - case installationPublicKey(Data) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Identity_Associations_MemberIdentifier.OneOf_Kind, rhs: Xmtp_Identity_Associations_MemberIdentifier.OneOf_Kind) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.address, .address): return { - guard case .address(let l) = lhs, case .address(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.installationPublicKey, .installationPublicKey): return { - guard case .installationPublicKey(let l) = lhs, case .installationPublicKey(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif - } - - public init() {} -} - -/// single member that optionally indicates the member that added them -public struct Xmtp_Identity_Associations_Member { - // 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 identifier: Xmtp_Identity_Associations_MemberIdentifier { - get {return _identifier ?? Xmtp_Identity_Associations_MemberIdentifier()} - set {_identifier = newValue} - } - /// Returns true if `identifier` has been explicitly set. - public var hasIdentifier: Bool {return self._identifier != nil} - /// Clears the value of `identifier`. Subsequent reads from it will return its default value. - public mutating func clearIdentifier() {self._identifier = nil} - - public var addedByEntity: Xmtp_Identity_Associations_MemberIdentifier { - get {return _addedByEntity ?? Xmtp_Identity_Associations_MemberIdentifier()} - set {_addedByEntity = newValue} - } - /// Returns true if `addedByEntity` has been explicitly set. - public var hasAddedByEntity: Bool {return self._addedByEntity != nil} - /// Clears the value of `addedByEntity`. Subsequent reads from it will return its default value. - public mutating func clearAddedByEntity() {self._addedByEntity = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _identifier: Xmtp_Identity_Associations_MemberIdentifier? = nil - fileprivate var _addedByEntity: Xmtp_Identity_Associations_MemberIdentifier? = nil -} - -/// The first entry of any XID log. The XID must be deterministically derivable -/// from the address and nonce. -/// The recovery address defaults to the initial associated_address unless -/// there is a subsequent ChangeRecoveryAddress in the log. -public struct Xmtp_Identity_Associations_CreateInbox { - // 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 initialAddress: String = String() - - public var nonce: UInt64 = 0 - - /// Must be an addressable member - public var initialAddressSignature: Xmtp_Identity_Associations_Signature { - get {return _initialAddressSignature ?? Xmtp_Identity_Associations_Signature()} - set {_initialAddressSignature = newValue} - } - /// Returns true if `initialAddressSignature` has been explicitly set. - public var hasInitialAddressSignature: Bool {return self._initialAddressSignature != nil} - /// Clears the value of `initialAddressSignature`. Subsequent reads from it will return its default value. - public mutating func clearInitialAddressSignature() {self._initialAddressSignature = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _initialAddressSignature: Xmtp_Identity_Associations_Signature? = nil -} - -/// Adds a new member for an XID - either an addressable member such as a -/// wallet, or an installation acting on behalf of an address. -/// A key-pair that has been associated with one role MUST not be permitted to be -/// associated with a different role. -public struct Xmtp_Identity_Associations_AddAssociation { - // 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 newMemberIdentifier: Xmtp_Identity_Associations_MemberIdentifier { - get {return _newMemberIdentifier ?? Xmtp_Identity_Associations_MemberIdentifier()} - set {_newMemberIdentifier = newValue} - } - /// Returns true if `newMemberIdentifier` has been explicitly set. - public var hasNewMemberIdentifier: Bool {return self._newMemberIdentifier != nil} - /// Clears the value of `newMemberIdentifier`. Subsequent reads from it will return its default value. - public mutating func clearNewMemberIdentifier() {self._newMemberIdentifier = nil} - - public var existingMemberSignature: Xmtp_Identity_Associations_Signature { - get {return _existingMemberSignature ?? Xmtp_Identity_Associations_Signature()} - set {_existingMemberSignature = newValue} - } - /// Returns true if `existingMemberSignature` has been explicitly set. - public var hasExistingMemberSignature: Bool {return self._existingMemberSignature != nil} - /// Clears the value of `existingMemberSignature`. Subsequent reads from it will return its default value. - public mutating func clearExistingMemberSignature() {self._existingMemberSignature = nil} - - public var newMemberSignature: Xmtp_Identity_Associations_Signature { - get {return _newMemberSignature ?? Xmtp_Identity_Associations_Signature()} - set {_newMemberSignature = newValue} - } - /// Returns true if `newMemberSignature` has been explicitly set. - public var hasNewMemberSignature: Bool {return self._newMemberSignature != nil} - /// Clears the value of `newMemberSignature`. Subsequent reads from it will return its default value. - public mutating func clearNewMemberSignature() {self._newMemberSignature = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _newMemberIdentifier: Xmtp_Identity_Associations_MemberIdentifier? = nil - fileprivate var _existingMemberSignature: Xmtp_Identity_Associations_Signature? = nil - fileprivate var _newMemberSignature: Xmtp_Identity_Associations_Signature? = nil -} - -/// Revokes a member from an XID. The recovery address must sign the revocation. -public struct Xmtp_Identity_Associations_RevokeAssociation { - // 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 memberToRevoke: Xmtp_Identity_Associations_MemberIdentifier { - get {return _memberToRevoke ?? Xmtp_Identity_Associations_MemberIdentifier()} - set {_memberToRevoke = newValue} - } - /// Returns true if `memberToRevoke` has been explicitly set. - public var hasMemberToRevoke: Bool {return self._memberToRevoke != nil} - /// Clears the value of `memberToRevoke`. Subsequent reads from it will return its default value. - public mutating func clearMemberToRevoke() {self._memberToRevoke = nil} - - public var recoveryAddressSignature: Xmtp_Identity_Associations_Signature { - get {return _recoveryAddressSignature ?? Xmtp_Identity_Associations_Signature()} - set {_recoveryAddressSignature = newValue} - } - /// Returns true if `recoveryAddressSignature` has been explicitly set. - public var hasRecoveryAddressSignature: Bool {return self._recoveryAddressSignature != nil} - /// Clears the value of `recoveryAddressSignature`. Subsequent reads from it will return its default value. - public mutating func clearRecoveryAddressSignature() {self._recoveryAddressSignature = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _memberToRevoke: Xmtp_Identity_Associations_MemberIdentifier? = nil - fileprivate var _recoveryAddressSignature: Xmtp_Identity_Associations_Signature? = nil -} - -/// Changes the recovery address for an XID. The recovery address is not required -/// to be a member of the XID. In addition to being able to add members, the -/// recovery address can also revoke members. -public struct Xmtp_Identity_Associations_ChangeRecoveryAddress { - // 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 newRecoveryAddress: String = String() - - public var existingRecoveryAddressSignature: Xmtp_Identity_Associations_Signature { - get {return _existingRecoveryAddressSignature ?? Xmtp_Identity_Associations_Signature()} - set {_existingRecoveryAddressSignature = newValue} - } - /// Returns true if `existingRecoveryAddressSignature` has been explicitly set. - public var hasExistingRecoveryAddressSignature: Bool {return self._existingRecoveryAddressSignature != nil} - /// Clears the value of `existingRecoveryAddressSignature`. Subsequent reads from it will return its default value. - public mutating func clearExistingRecoveryAddressSignature() {self._existingRecoveryAddressSignature = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _existingRecoveryAddressSignature: Xmtp_Identity_Associations_Signature? = nil -} - -/// A single identity operation -public struct Xmtp_Identity_Associations_IdentityAction { - // 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 kind: Xmtp_Identity_Associations_IdentityAction.OneOf_Kind? = nil - - public var createInbox: Xmtp_Identity_Associations_CreateInbox { - get { - if case .createInbox(let v)? = kind {return v} - return Xmtp_Identity_Associations_CreateInbox() - } - set {kind = .createInbox(newValue)} - } - - public var add: Xmtp_Identity_Associations_AddAssociation { - get { - if case .add(let v)? = kind {return v} - return Xmtp_Identity_Associations_AddAssociation() - } - set {kind = .add(newValue)} - } - - public var revoke: Xmtp_Identity_Associations_RevokeAssociation { - get { - if case .revoke(let v)? = kind {return v} - return Xmtp_Identity_Associations_RevokeAssociation() - } - set {kind = .revoke(newValue)} - } - - public var changeRecoveryAddress: Xmtp_Identity_Associations_ChangeRecoveryAddress { - get { - if case .changeRecoveryAddress(let v)? = kind {return v} - return Xmtp_Identity_Associations_ChangeRecoveryAddress() - } - set {kind = .changeRecoveryAddress(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Kind: Equatable { - case createInbox(Xmtp_Identity_Associations_CreateInbox) - case add(Xmtp_Identity_Associations_AddAssociation) - case revoke(Xmtp_Identity_Associations_RevokeAssociation) - case changeRecoveryAddress(Xmtp_Identity_Associations_ChangeRecoveryAddress) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Identity_Associations_IdentityAction.OneOf_Kind, rhs: Xmtp_Identity_Associations_IdentityAction.OneOf_Kind) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.createInbox, .createInbox): return { - guard case .createInbox(let l) = lhs, case .createInbox(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.add, .add): return { - guard case .add(let l) = lhs, case .add(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.revoke, .revoke): return { - guard case .revoke(let l) = lhs, case .revoke(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.changeRecoveryAddress, .changeRecoveryAddress): return { - guard case .changeRecoveryAddress(let l) = lhs, case .changeRecoveryAddress(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif - } - - public init() {} -} - -/// One or more identity actions that were signed together. -/// Example: [CreateXid, AddAssociation, ChangeRecoveryAddress] -/// 1. The batched signature text is created by concatenating the signature text -/// of each association together with a separator, '\n\n\n'. -/// 2. The user signs this concatenated result. -/// 3. The resulting signature is added to each association proto where relevant. -/// The same signature may be used for multiple associations in the array. -public struct Xmtp_Identity_Associations_IdentityUpdate { - // 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 actions: [Xmtp_Identity_Associations_IdentityAction] = [] - - public var clientTimestampNs: UInt64 = 0 - - public var inboxID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Map of members belonging to an inbox_id -public struct Xmtp_Identity_Associations_MemberMap { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var key: Xmtp_Identity_Associations_MemberIdentifier { - get {return _key ?? Xmtp_Identity_Associations_MemberIdentifier()} - set {_key = newValue} - } - /// Returns true if `key` has been explicitly set. - public var hasKey: Bool {return self._key != nil} - /// Clears the value of `key`. Subsequent reads from it will return its default value. - public mutating func clearKey() {self._key = nil} - - public var value: Xmtp_Identity_Associations_Member { - get {return _value ?? Xmtp_Identity_Associations_Member()} - set {_value = newValue} - } - /// Returns true if `value` has been explicitly set. - public var hasValue: Bool {return self._value != nil} - /// Clears the value of `value`. Subsequent reads from it will return its default value. - public mutating func clearValue() {self._value = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _key: Xmtp_Identity_Associations_MemberIdentifier? = nil - fileprivate var _value: Xmtp_Identity_Associations_Member? = nil -} - -/// A final association state resulting from multiple `IdentityUpdates` -public struct Xmtp_Identity_Associations_AssociationState { - // 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 inboxID: String = String() - - public var members: [Xmtp_Identity_Associations_MemberMap] = [] - - public var recoveryAddress: String = String() - - public var seenSignatures: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -//// state diff between two final AssociationStates -public struct Xmtp_Identity_Associations_AssociationStateDiff { - // 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 newMembers: [Xmtp_Identity_Associations_MemberIdentifier] = [] - - public var removedMembers: [Xmtp_Identity_Associations_MemberIdentifier] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_Identity_Associations_MemberIdentifier: @unchecked Sendable {} -extension Xmtp_Identity_Associations_MemberIdentifier.OneOf_Kind: @unchecked Sendable {} -extension Xmtp_Identity_Associations_Member: @unchecked Sendable {} -extension Xmtp_Identity_Associations_CreateInbox: @unchecked Sendable {} -extension Xmtp_Identity_Associations_AddAssociation: @unchecked Sendable {} -extension Xmtp_Identity_Associations_RevokeAssociation: @unchecked Sendable {} -extension Xmtp_Identity_Associations_ChangeRecoveryAddress: @unchecked Sendable {} -extension Xmtp_Identity_Associations_IdentityAction: @unchecked Sendable {} -extension Xmtp_Identity_Associations_IdentityAction.OneOf_Kind: @unchecked Sendable {} -extension Xmtp_Identity_Associations_IdentityUpdate: @unchecked Sendable {} -extension Xmtp_Identity_Associations_MemberMap: @unchecked Sendable {} -extension Xmtp_Identity_Associations_AssociationState: @unchecked Sendable {} -extension Xmtp_Identity_Associations_AssociationStateDiff: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.identity.associations" - -extension Xmtp_Identity_Associations_MemberIdentifier: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".MemberIdentifier" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .standard(proto: "installation_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 { - var v: String? - try decoder.decodeSingularStringField(value: &v) - if let v = v { - if self.kind != nil {try decoder.handleConflictingOneOf()} - self.kind = .address(v) - } - }() - case 2: try { - var v: Data? - try decoder.decodeSingularBytesField(value: &v) - if let v = v { - if self.kind != nil {try decoder.handleConflictingOneOf()} - self.kind = .installationPublicKey(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.kind { - case .address?: try { - guard case .address(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - }() - case .installationPublicKey?: try { - guard case .installationPublicKey(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - }() - case nil: break - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_MemberIdentifier, rhs: Xmtp_Identity_Associations_MemberIdentifier) -> Bool { - if lhs.kind != rhs.kind {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_Member: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Member" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "identifier"), - 2: .standard(proto: "added_by_entity"), - ] - - 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._identifier) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._addedByEntity) }() - 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._identifier { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._addedByEntity { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_Member, rhs: Xmtp_Identity_Associations_Member) -> Bool { - if lhs._identifier != rhs._identifier {return false} - if lhs._addedByEntity != rhs._addedByEntity {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_CreateInbox: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CreateInbox" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "initial_address"), - 2: .same(proto: "nonce"), - 3: .standard(proto: "initial_address_signature"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.initialAddress) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.nonce) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._initialAddressSignature) }() - 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.initialAddress.isEmpty { - try visitor.visitSingularStringField(value: self.initialAddress, fieldNumber: 1) - } - if self.nonce != 0 { - try visitor.visitSingularUInt64Field(value: self.nonce, fieldNumber: 2) - } - try { if let v = self._initialAddressSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_CreateInbox, rhs: Xmtp_Identity_Associations_CreateInbox) -> Bool { - if lhs.initialAddress != rhs.initialAddress {return false} - if lhs.nonce != rhs.nonce {return false} - if lhs._initialAddressSignature != rhs._initialAddressSignature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_AddAssociation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AddAssociation" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "new_member_identifier"), - 2: .standard(proto: "existing_member_signature"), - 3: .standard(proto: "new_member_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._newMemberIdentifier) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._existingMemberSignature) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._newMemberSignature) }() - 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._newMemberIdentifier { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._existingMemberSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try { if let v = self._newMemberSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_AddAssociation, rhs: Xmtp_Identity_Associations_AddAssociation) -> Bool { - if lhs._newMemberIdentifier != rhs._newMemberIdentifier {return false} - if lhs._existingMemberSignature != rhs._existingMemberSignature {return false} - if lhs._newMemberSignature != rhs._newMemberSignature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_RevokeAssociation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RevokeAssociation" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "member_to_revoke"), - 2: .standard(proto: "recovery_address_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._memberToRevoke) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._recoveryAddressSignature) }() - 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._memberToRevoke { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._recoveryAddressSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_RevokeAssociation, rhs: Xmtp_Identity_Associations_RevokeAssociation) -> Bool { - if lhs._memberToRevoke != rhs._memberToRevoke {return false} - if lhs._recoveryAddressSignature != rhs._recoveryAddressSignature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_ChangeRecoveryAddress: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ChangeRecoveryAddress" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "new_recovery_address"), - 2: .standard(proto: "existing_recovery_address_signature"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.newRecoveryAddress) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._existingRecoveryAddressSignature) }() - 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.newRecoveryAddress.isEmpty { - try visitor.visitSingularStringField(value: self.newRecoveryAddress, fieldNumber: 1) - } - try { if let v = self._existingRecoveryAddressSignature { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_ChangeRecoveryAddress, rhs: Xmtp_Identity_Associations_ChangeRecoveryAddress) -> Bool { - if lhs.newRecoveryAddress != rhs.newRecoveryAddress {return false} - if lhs._existingRecoveryAddressSignature != rhs._existingRecoveryAddressSignature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_IdentityAction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".IdentityAction" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "create_inbox"), - 2: .same(proto: "add"), - 3: .same(proto: "revoke"), - 4: .standard(proto: "change_recovery_address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Xmtp_Identity_Associations_CreateInbox? - var hadOneofValue = false - if let current = self.kind { - hadOneofValue = true - if case .createInbox(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.kind = .createInbox(v) - } - }() - case 2: try { - var v: Xmtp_Identity_Associations_AddAssociation? - var hadOneofValue = false - if let current = self.kind { - hadOneofValue = true - if case .add(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.kind = .add(v) - } - }() - case 3: try { - var v: Xmtp_Identity_Associations_RevokeAssociation? - var hadOneofValue = false - if let current = self.kind { - hadOneofValue = true - if case .revoke(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.kind = .revoke(v) - } - }() - case 4: try { - var v: Xmtp_Identity_Associations_ChangeRecoveryAddress? - var hadOneofValue = false - if let current = self.kind { - hadOneofValue = true - if case .changeRecoveryAddress(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.kind = .changeRecoveryAddress(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.kind { - case .createInbox?: try { - guard case .createInbox(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - }() - case .add?: try { - guard case .add(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - }() - case .revoke?: try { - guard case .revoke(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - }() - case .changeRecoveryAddress?: try { - guard case .changeRecoveryAddress(let v)? = self.kind else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - }() - case nil: break - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_IdentityAction, rhs: Xmtp_Identity_Associations_IdentityAction) -> Bool { - if lhs.kind != rhs.kind {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_IdentityUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".IdentityUpdate" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "actions"), - 2: .standard(proto: "client_timestamp_ns"), - 3: .standard(proto: "inbox_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.actions) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.clientTimestampNs) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.inboxID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.actions.isEmpty { - try visitor.visitRepeatedMessageField(value: self.actions, fieldNumber: 1) - } - if self.clientTimestampNs != 0 { - try visitor.visitSingularUInt64Field(value: self.clientTimestampNs, fieldNumber: 2) - } - if !self.inboxID.isEmpty { - try visitor.visitSingularStringField(value: self.inboxID, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_IdentityUpdate, rhs: Xmtp_Identity_Associations_IdentityUpdate) -> Bool { - if lhs.actions != rhs.actions {return false} - if lhs.clientTimestampNs != rhs.clientTimestampNs {return false} - if lhs.inboxID != rhs.inboxID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_MemberMap: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".MemberMap" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "key"), - 2: .same(proto: "value"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._key) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._value) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._key { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._value { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_MemberMap, rhs: Xmtp_Identity_Associations_MemberMap) -> Bool { - if lhs._key != rhs._key {return false} - if lhs._value != rhs._value {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_AssociationState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AssociationState" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "inbox_id"), - 2: .same(proto: "members"), - 3: .standard(proto: "recovery_address"), - 4: .standard(proto: "seen_signatures"), - ] - - 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.inboxID) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &self.members) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.recoveryAddress) }() - case 4: try { try decoder.decodeRepeatedBytesField(value: &self.seenSignatures) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.inboxID.isEmpty { - try visitor.visitSingularStringField(value: self.inboxID, fieldNumber: 1) - } - if !self.members.isEmpty { - try visitor.visitRepeatedMessageField(value: self.members, fieldNumber: 2) - } - if !self.recoveryAddress.isEmpty { - try visitor.visitSingularStringField(value: self.recoveryAddress, fieldNumber: 3) - } - if !self.seenSignatures.isEmpty { - try visitor.visitRepeatedBytesField(value: self.seenSignatures, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_AssociationState, rhs: Xmtp_Identity_Associations_AssociationState) -> Bool { - if lhs.inboxID != rhs.inboxID {return false} - if lhs.members != rhs.members {return false} - if lhs.recoveryAddress != rhs.recoveryAddress {return false} - if lhs.seenSignatures != rhs.seenSignatures {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_AssociationStateDiff: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AssociationStateDiff" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "new_members"), - 2: .standard(proto: "removed_members"), - ] - - 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.newMembers) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &self.removedMembers) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.newMembers.isEmpty { - try visitor.visitRepeatedMessageField(value: self.newMembers, fieldNumber: 1) - } - if !self.removedMembers.isEmpty { - try visitor.visitRepeatedMessageField(value: self.removedMembers, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_AssociationStateDiff, rhs: Xmtp_Identity_Associations_AssociationStateDiff) -> Bool { - if lhs.newMembers != rhs.newMembers {return false} - if lhs.removedMembers != rhs.removedMembers {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTPiOS/Proto/identity/associations/signature.pb.swift b/Sources/XMTPiOS/Proto/identity/associations/signature.pb.swift deleted file mode 100644 index dfe7713b..00000000 --- a/Sources/XMTPiOS/Proto/identity/associations/signature.pb.swift +++ /dev/null @@ -1,476 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: identity/associations/signature.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Signing methods for identity associations - -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 -} - -/// RecoverableEcdsaSignature for EIP-191 and V2 signatures -public struct Xmtp_Identity_Associations_RecoverableEcdsaSignature { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// 65-bytes [ R || S || V ], with recovery id as the last byte - public var bytes: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// EdDSA signature for 25519 -public struct Xmtp_Identity_Associations_RecoverableEd25519Signature { - // 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. - - /// 64 bytes [R(32 bytes) || S(32 bytes)] - public var bytes: Data = Data() - - /// 32 bytes - public var publicKey: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Smart wallet signature -public struct Xmtp_Identity_Associations_Erc1271Signature { - // 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. - - /// CAIP-10 - /// https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md - public var accountID: String = String() - - /// Specify the block number to verify the signature against - public var blockNumber: UInt64 = 0 - - /// The actual signature bytes - public var signature: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// An existing address on xmtpv2 may have already signed a legacy identity key -/// of type SignedPublicKey via the 'Create Identity' signature. -/// For migration to xmtpv3, the legacy key is permitted to sign on behalf of the -/// address to create a matching xmtpv3 installation key. -/// This signature type can ONLY be used for CreateXid and AddAssociation -/// payloads, and can only be used once in xmtpv3. -public struct Xmtp_Identity_Associations_LegacyDelegatedSignature { - // 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 delegatedKey: Xmtp_MessageContents_SignedPublicKey { - get {return _delegatedKey ?? Xmtp_MessageContents_SignedPublicKey()} - set {_delegatedKey = newValue} - } - /// Returns true if `delegatedKey` has been explicitly set. - public var hasDelegatedKey: Bool {return self._delegatedKey != nil} - /// Clears the value of `delegatedKey`. Subsequent reads from it will return its default value. - public mutating func clearDelegatedKey() {self._delegatedKey = nil} - - public var signature: Xmtp_Identity_Associations_RecoverableEcdsaSignature { - get {return _signature ?? Xmtp_Identity_Associations_RecoverableEcdsaSignature()} - set {_signature = newValue} - } - /// Returns true if `signature` has been explicitly set. - public var hasSignature: Bool {return self._signature != nil} - /// Clears the value of `signature`. Subsequent reads from it will return its default value. - public mutating func clearSignature() {self._signature = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _delegatedKey: Xmtp_MessageContents_SignedPublicKey? = nil - fileprivate var _signature: Xmtp_Identity_Associations_RecoverableEcdsaSignature? = nil -} - -/// A wrapper for all possible signature types -public struct Xmtp_Identity_Associations_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. - - /// Must have two properties: - /// 1. An identifier (address or public key) for the signer must either be - /// recoverable, or specified as a field. - /// 2. The signer certifies that the signing payload is correct. The payload - /// must be inferred from the context in which the signature is provided. - public var signature: Xmtp_Identity_Associations_Signature.OneOf_Signature? = nil - - public var erc191: Xmtp_Identity_Associations_RecoverableEcdsaSignature { - get { - if case .erc191(let v)? = signature {return v} - return Xmtp_Identity_Associations_RecoverableEcdsaSignature() - } - set {signature = .erc191(newValue)} - } - - public var erc1271: Xmtp_Identity_Associations_Erc1271Signature { - get { - if case .erc1271(let v)? = signature {return v} - return Xmtp_Identity_Associations_Erc1271Signature() - } - set {signature = .erc1271(newValue)} - } - - public var installationKey: Xmtp_Identity_Associations_RecoverableEd25519Signature { - get { - if case .installationKey(let v)? = signature {return v} - return Xmtp_Identity_Associations_RecoverableEd25519Signature() - } - set {signature = .installationKey(newValue)} - } - - public var delegatedErc191: Xmtp_Identity_Associations_LegacyDelegatedSignature { - get { - if case .delegatedErc191(let v)? = signature {return v} - return Xmtp_Identity_Associations_LegacyDelegatedSignature() - } - set {signature = .delegatedErc191(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// Must have two properties: - /// 1. An identifier (address or public key) for the signer must either be - /// recoverable, or specified as a field. - /// 2. The signer certifies that the signing payload is correct. The payload - /// must be inferred from the context in which the signature is provided. - public enum OneOf_Signature: Equatable { - case erc191(Xmtp_Identity_Associations_RecoverableEcdsaSignature) - case erc1271(Xmtp_Identity_Associations_Erc1271Signature) - case installationKey(Xmtp_Identity_Associations_RecoverableEd25519Signature) - case delegatedErc191(Xmtp_Identity_Associations_LegacyDelegatedSignature) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Identity_Associations_Signature.OneOf_Signature, rhs: Xmtp_Identity_Associations_Signature.OneOf_Signature) -> 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 (.erc191, .erc191): return { - guard case .erc191(let l) = lhs, case .erc191(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.erc1271, .erc1271): return { - guard case .erc1271(let l) = lhs, case .erc1271(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.installationKey, .installationKey): return { - guard case .installationKey(let l) = lhs, case .installationKey(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.delegatedErc191, .delegatedErc191): return { - guard case .delegatedErc191(let l) = lhs, case .delegatedErc191(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_Identity_Associations_RecoverableEcdsaSignature: @unchecked Sendable {} -extension Xmtp_Identity_Associations_RecoverableEd25519Signature: @unchecked Sendable {} -extension Xmtp_Identity_Associations_Erc1271Signature: @unchecked Sendable {} -extension Xmtp_Identity_Associations_LegacyDelegatedSignature: @unchecked Sendable {} -extension Xmtp_Identity_Associations_Signature: @unchecked Sendable {} -extension Xmtp_Identity_Associations_Signature.OneOf_Signature: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.identity.associations" - -extension Xmtp_Identity_Associations_RecoverableEcdsaSignature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RecoverableEcdsaSignature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "bytes"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.bytes) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.bytes.isEmpty { - try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_RecoverableEcdsaSignature, rhs: Xmtp_Identity_Associations_RecoverableEcdsaSignature) -> Bool { - if lhs.bytes != rhs.bytes {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_RecoverableEd25519Signature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".RecoverableEd25519Signature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "bytes"), - 2: .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.decodeSingularBytesField(value: &self.bytes) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.publicKey) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.bytes.isEmpty { - try visitor.visitSingularBytesField(value: self.bytes, fieldNumber: 1) - } - if !self.publicKey.isEmpty { - try visitor.visitSingularBytesField(value: self.publicKey, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_RecoverableEd25519Signature, rhs: Xmtp_Identity_Associations_RecoverableEd25519Signature) -> Bool { - if lhs.bytes != rhs.bytes {return false} - if lhs.publicKey != rhs.publicKey {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_Erc1271Signature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Erc1271Signature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "account_id"), - 2: .standard(proto: "block_number"), - 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.decodeSingularStringField(value: &self.accountID) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockNumber) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.signature) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.accountID.isEmpty { - try visitor.visitSingularStringField(value: self.accountID, fieldNumber: 1) - } - if self.blockNumber != 0 { - try visitor.visitSingularUInt64Field(value: self.blockNumber, fieldNumber: 2) - } - if !self.signature.isEmpty { - try visitor.visitSingularBytesField(value: self.signature, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_Erc1271Signature, rhs: Xmtp_Identity_Associations_Erc1271Signature) -> Bool { - if lhs.accountID != rhs.accountID {return false} - if lhs.blockNumber != rhs.blockNumber {return false} - if lhs.signature != rhs.signature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_LegacyDelegatedSignature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".LegacyDelegatedSignature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "delegated_key"), - 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.decodeSingularMessageField(value: &self._delegatedKey) }() - 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 - try { if let v = self._delegatedKey { - try visitor.visitSingularMessageField(value: v, 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_Identity_Associations_LegacyDelegatedSignature, rhs: Xmtp_Identity_Associations_LegacyDelegatedSignature) -> Bool { - if lhs._delegatedKey != rhs._delegatedKey {return false} - if lhs._signature != rhs._signature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Identity_Associations_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: "erc_191"), - 2: .standard(proto: "erc_1271"), - 3: .standard(proto: "installation_key"), - 4: .standard(proto: "delegated_erc_191"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Xmtp_Identity_Associations_RecoverableEcdsaSignature? - var hadOneofValue = false - if let current = self.signature { - hadOneofValue = true - if case .erc191(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.signature = .erc191(v) - } - }() - case 2: try { - var v: Xmtp_Identity_Associations_Erc1271Signature? - var hadOneofValue = false - if let current = self.signature { - hadOneofValue = true - if case .erc1271(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.signature = .erc1271(v) - } - }() - case 3: try { - var v: Xmtp_Identity_Associations_RecoverableEd25519Signature? - var hadOneofValue = false - if let current = self.signature { - hadOneofValue = true - if case .installationKey(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.signature = .installationKey(v) - } - }() - case 4: try { - var v: Xmtp_Identity_Associations_LegacyDelegatedSignature? - var hadOneofValue = false - if let current = self.signature { - hadOneofValue = true - if case .delegatedErc191(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.signature = .delegatedErc191(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.signature { - case .erc191?: try { - guard case .erc191(let v)? = self.signature else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - }() - case .erc1271?: try { - guard case .erc1271(let v)? = self.signature else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - }() - case .installationKey?: try { - guard case .installationKey(let v)? = self.signature else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - }() - case .delegatedErc191?: try { - guard case .delegatedErc191(let v)? = self.signature else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - }() - case nil: break - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_Associations_Signature, rhs: Xmtp_Identity_Associations_Signature) -> Bool { - if lhs.signature != rhs.signature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTPiOS/Proto/identity/credential.pb.swift b/Sources/XMTPiOS/Proto/identity/credential.pb.swift deleted file mode 100644 index f4df03a6..00000000 --- a/Sources/XMTPiOS/Proto/identity/credential.pb.swift +++ /dev/null @@ -1,76 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: identity/credential.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -/// Credentials - -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 credential that can be used in MLS leaf nodes -public struct Xmtp_Identity_MlsCredential { - // 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 inboxID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_Identity_MlsCredential: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.identity" - -extension Xmtp_Identity_MlsCredential: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".MlsCredential" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "inbox_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.inboxID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.inboxID.isEmpty { - try visitor.visitSingularStringField(value: self.inboxID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Identity_MlsCredential, rhs: Xmtp_Identity_MlsCredential) -> Bool { - if lhs.inboxID != rhs.inboxID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTPiOS/Proto/mls/message_contents/content.pb.swift b/Sources/XMTPiOS/Proto/mls/message_contents/content.pb.swift deleted file mode 100644 index 4ad3d227..00000000 --- a/Sources/XMTPiOS/Proto/mls/message_contents/content.pb.swift +++ /dev/null @@ -1,868 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: mls/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 -/// Copied from V2 code so that we can eventually retire all V2 message content - -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_Mls_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_Mls_MessageContents_Compression: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static let allCases: [Xmtp_Mls_MessageContents_Compression] = [ - .deflate, - .gzip, - ] -} - -#endif // swift(>=4.2) - -/// ContentTypeId is used to identify the type of content stored in a Message. -public struct Xmtp_Mls_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_Mls_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_Mls_MessageContents_ContentTypeId { - get {return _type ?? Xmtp_Mls_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_Mls_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_Mls_MessageContents_ContentTypeId? = nil - fileprivate var _fallback: String? = nil - fileprivate var _compression: Xmtp_Mls_MessageContents_Compression? = nil -} - -/// A PlaintextEnvelope is the outermost payload that gets encrypted by MLS -public struct Xmtp_Mls_MessageContents_PlaintextEnvelope { - // 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. - - /// Selector which declares which version of the EncodedContent this - /// PlaintextEnvelope is - public var content: Xmtp_Mls_MessageContents_PlaintextEnvelope.OneOf_Content? = nil - - public var v1: Xmtp_Mls_MessageContents_PlaintextEnvelope.V1 { - get { - if case .v1(let v)? = content {return v} - return Xmtp_Mls_MessageContents_PlaintextEnvelope.V1() - } - set {content = .v1(newValue)} - } - - public var v2: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2 { - get { - if case .v2(let v)? = content {return v} - return Xmtp_Mls_MessageContents_PlaintextEnvelope.V2() - } - set {content = .v2(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// Selector which declares which version of the EncodedContent this - /// PlaintextEnvelope is - public enum OneOf_Content: Equatable { - case v1(Xmtp_Mls_MessageContents_PlaintextEnvelope.V1) - case v2(Xmtp_Mls_MessageContents_PlaintextEnvelope.V2) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.OneOf_Content, rhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.OneOf_Content) -> 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 - } - - /// Version 1 of the encrypted envelope - public struct V1 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Expected to be EncodedContent - public var content: Data = Data() - - /// A unique value that can be used to ensure that the same content can - /// produce different hashes. May be the sender timestamp. - public var idempotencyKey: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - /// Version 2 of the encrypted envelope - public struct V2 { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// A unique value that can be used to ensure that the same content can - /// produce different hashes. May be the sender timestamp. - public var idempotencyKey: String = String() - - public var messageType: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2.OneOf_MessageType? = nil - - /// Expected to be EncodedContent - public var content: Data { - get { - if case .content(let v)? = messageType {return v} - return Data() - } - set {messageType = .content(newValue)} - } - - /// Initiator sends a request to receive message history - public var request: Xmtp_Mls_MessageContents_MessageHistoryRequest { - get { - if case .request(let v)? = messageType {return v} - return Xmtp_Mls_MessageContents_MessageHistoryRequest() - } - set {messageType = .request(newValue)} - } - - /// Some other authorized installation sends a reply - public var reply: Xmtp_Mls_MessageContents_MessageHistoryReply { - get { - if case .reply(let v)? = messageType {return v} - return Xmtp_Mls_MessageContents_MessageHistoryReply() - } - set {messageType = .reply(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_MessageType: Equatable { - /// Expected to be EncodedContent - case content(Data) - /// Initiator sends a request to receive message history - case request(Xmtp_Mls_MessageContents_MessageHistoryRequest) - /// Some other authorized installation sends a reply - case reply(Xmtp_Mls_MessageContents_MessageHistoryReply) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2.OneOf_MessageType, rhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2.OneOf_MessageType) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.content, .content): return { - guard case .content(let l) = lhs, case .content(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.request, .request): return { - guard case .request(let l) = lhs, case .request(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.reply, .reply): return { - guard case .reply(let l) = lhs, case .reply(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif - } - - public init() {} - } - - public init() {} -} - -/// Initiator or new installation id requesting a history will send a request -public struct Xmtp_Mls_MessageContents_MessageHistoryRequest { - // 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. - - /// Unique identifier for each request - public var requestID: String = String() - - /// Ensures a human is in the loop - public var pinCode: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Pre-existing installation id capable of supplying a history sends this reply -public struct Xmtp_Mls_MessageContents_MessageHistoryReply { - // 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 match an existing request_id from a message history request - public var requestID: String = String() - - /// Where the messages can be retrieved from - public var url: String = String() - - /// Generated input 'secret' for the AES Key used to encrypt the message-bundle - public var encryptionKey: Xmtp_Mls_MessageContents_MessageHistoryKeyType { - get {return _encryptionKey ?? Xmtp_Mls_MessageContents_MessageHistoryKeyType()} - set {_encryptionKey = newValue} - } - /// Returns true if `encryptionKey` has been explicitly set. - public var hasEncryptionKey: Bool {return self._encryptionKey != nil} - /// Clears the value of `encryptionKey`. Subsequent reads from it will return its default value. - public mutating func clearEncryptionKey() {self._encryptionKey = nil} - - /// Generated input 'secret' for the HMAC Key used to sign the bundle_hash - public var signingKey: Xmtp_Mls_MessageContents_MessageHistoryKeyType { - get {return _signingKey ?? Xmtp_Mls_MessageContents_MessageHistoryKeyType()} - set {_signingKey = newValue} - } - /// Returns true if `signingKey` has been explicitly set. - public var hasSigningKey: Bool {return self._signingKey != nil} - /// Clears the value of `signingKey`. Subsequent reads from it will return its default value. - public mutating func clearSigningKey() {self._signingKey = nil} - - /// HMAC Signature of the message-bundle - public var bundleHash: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _encryptionKey: Xmtp_Mls_MessageContents_MessageHistoryKeyType? = nil - fileprivate var _signingKey: Xmtp_Mls_MessageContents_MessageHistoryKeyType? = nil -} - -/// Key used to encrypt or sign the message-bundle -public struct Xmtp_Mls_MessageContents_MessageHistoryKeyType { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var key: Xmtp_Mls_MessageContents_MessageHistoryKeyType.OneOf_Key? = nil - - public var chacha20Poly1305: Data { - get { - if case .chacha20Poly1305(let v)? = key {return v} - return Data() - } - set {key = .chacha20Poly1305(newValue)} - } - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum OneOf_Key: Equatable { - case chacha20Poly1305(Data) - - #if !swift(>=4.1) - public static func ==(lhs: Xmtp_Mls_MessageContents_MessageHistoryKeyType.OneOf_Key, rhs: Xmtp_Mls_MessageContents_MessageHistoryKeyType.OneOf_Key) -> 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 (.chacha20Poly1305, .chacha20Poly1305): return { - guard case .chacha20Poly1305(let l) = lhs, case .chacha20Poly1305(let r) = rhs else { preconditionFailure() } - return l == r - }() - } - } - #endif - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_Mls_MessageContents_Compression: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_ContentTypeId: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_EncodedContent: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_PlaintextEnvelope: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_PlaintextEnvelope.OneOf_Content: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_PlaintextEnvelope.V1: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_PlaintextEnvelope.V2: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_PlaintextEnvelope.V2.OneOf_MessageType: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_MessageHistoryRequest: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_MessageHistoryReply: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_MessageHistoryKeyType: @unchecked Sendable {} -extension Xmtp_Mls_MessageContents_MessageHistoryKeyType.OneOf_Key: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.mls.message_contents" - -extension Xmtp_Mls_MessageContents_Compression: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "COMPRESSION_DEFLATE"), - 1: .same(proto: "COMPRESSION_GZIP"), - ] -} - -extension Xmtp_Mls_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_Mls_MessageContents_ContentTypeId, rhs: Xmtp_Mls_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_Mls_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_Mls_MessageContents_EncodedContent, rhs: Xmtp_Mls_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_Mls_MessageContents_PlaintextEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PlaintextEnvelope" - 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_Mls_MessageContents_PlaintextEnvelope.V1? - var hadOneofValue = false - if let current = self.content { - 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.content = .v1(v) - } - }() - case 2: try { - var v: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2? - var hadOneofValue = false - if let current = self.content { - 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.content = .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.content { - case .v1?: try { - guard case .v1(let v)? = self.content else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - }() - case .v2?: try { - guard case .v2(let v)? = self.content else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - }() - case nil: break - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_PlaintextEnvelope, rhs: Xmtp_Mls_MessageContents_PlaintextEnvelope) -> Bool { - if lhs.content != rhs.content {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_PlaintextEnvelope.V1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Mls_MessageContents_PlaintextEnvelope.protoMessageName + ".V1" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "content"), - 2: .standard(proto: "idempotency_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.decodeSingularBytesField(value: &self.content) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.idempotencyKey) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.content.isEmpty { - try visitor.visitSingularBytesField(value: self.content, fieldNumber: 1) - } - if !self.idempotencyKey.isEmpty { - try visitor.visitSingularStringField(value: self.idempotencyKey, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.V1, rhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.V1) -> Bool { - if lhs.content != rhs.content {return false} - if lhs.idempotencyKey != rhs.idempotencyKey {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_PlaintextEnvelope.V2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_Mls_MessageContents_PlaintextEnvelope.protoMessageName + ".V2" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "idempotency_key"), - 2: .same(proto: "content"), - 3: .same(proto: "request"), - 4: .same(proto: "reply"), - ] - - 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.idempotencyKey) }() - case 2: try { - var v: Data? - try decoder.decodeSingularBytesField(value: &v) - if let v = v { - if self.messageType != nil {try decoder.handleConflictingOneOf()} - self.messageType = .content(v) - } - }() - case 3: try { - var v: Xmtp_Mls_MessageContents_MessageHistoryRequest? - var hadOneofValue = false - if let current = self.messageType { - hadOneofValue = true - if case .request(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.messageType = .request(v) - } - }() - case 4: try { - var v: Xmtp_Mls_MessageContents_MessageHistoryReply? - var hadOneofValue = false - if let current = self.messageType { - hadOneofValue = true - if case .reply(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - self.messageType = .reply(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.idempotencyKey.isEmpty { - try visitor.visitSingularStringField(value: self.idempotencyKey, fieldNumber: 1) - } - switch self.messageType { - case .content?: try { - guard case .content(let v)? = self.messageType else { preconditionFailure() } - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - }() - case .request?: try { - guard case .request(let v)? = self.messageType else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - }() - case .reply?: try { - guard case .reply(let v)? = self.messageType else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - }() - case nil: break - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2, rhs: Xmtp_Mls_MessageContents_PlaintextEnvelope.V2) -> Bool { - if lhs.idempotencyKey != rhs.idempotencyKey {return false} - if lhs.messageType != rhs.messageType {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_MessageHistoryRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".MessageHistoryRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "request_id"), - 2: .standard(proto: "pin_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.requestID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.pinCode) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.requestID.isEmpty { - try visitor.visitSingularStringField(value: self.requestID, fieldNumber: 1) - } - if !self.pinCode.isEmpty { - try visitor.visitSingularStringField(value: self.pinCode, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_MessageHistoryRequest, rhs: Xmtp_Mls_MessageContents_MessageHistoryRequest) -> Bool { - if lhs.requestID != rhs.requestID {return false} - if lhs.pinCode != rhs.pinCode {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_MessageHistoryReply: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".MessageHistoryReply" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "request_id"), - 2: .same(proto: "url"), - 3: .standard(proto: "encryption_key"), - 4: .standard(proto: "signing_key"), - 5: .standard(proto: "bundle_hash"), - ] - - 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.requestID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.url) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._encryptionKey) }() - case 4: try { try decoder.decodeSingularMessageField(value: &self._signingKey) }() - case 5: try { try decoder.decodeSingularBytesField(value: &self.bundleHash) }() - 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.requestID.isEmpty { - try visitor.visitSingularStringField(value: self.requestID, fieldNumber: 1) - } - if !self.url.isEmpty { - try visitor.visitSingularStringField(value: self.url, fieldNumber: 2) - } - try { if let v = self._encryptionKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - try { if let v = self._signingKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - } }() - if !self.bundleHash.isEmpty { - try visitor.visitSingularBytesField(value: self.bundleHash, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_MessageHistoryReply, rhs: Xmtp_Mls_MessageContents_MessageHistoryReply) -> Bool { - if lhs.requestID != rhs.requestID {return false} - if lhs.url != rhs.url {return false} - if lhs._encryptionKey != rhs._encryptionKey {return false} - if lhs._signingKey != rhs._signingKey {return false} - if lhs.bundleHash != rhs.bundleHash {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_Mls_MessageContents_MessageHistoryKeyType: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".MessageHistoryKeyType" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "chacha20_poly1305"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { - var v: Data? - try decoder.decodeSingularBytesField(value: &v) - if let v = v { - if self.key != nil {try decoder.handleConflictingOneOf()} - self.key = .chacha20Poly1305(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 .chacha20Poly1305(let v)? = self.key { - try visitor.visitSingularBytesField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_Mls_MessageContents_MessageHistoryKeyType, rhs: Xmtp_Mls_MessageContents_MessageHistoryKeyType) -> Bool { - if lhs.key != rhs.key {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/XMTPiOS/Proto/mls_validation/v1/service.pb.swift b/Sources/XMTPiOS/Proto/mls_validation/v1/service.pb.swift deleted file mode 100644 index 3eb55b30..00000000 --- a/Sources/XMTPiOS/Proto/mls_validation/v1/service.pb.swift +++ /dev/null @@ -1,961 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: mls_validation/v1/service.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 -} - -/// Validates a Inbox-ID Key Package Type -public struct Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse { - // 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_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse.Response] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// one response corresponding to information about one key package - 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 isOk: Bool = false - - public var errorMessage: String = String() - - public var credential: Xmtp_Identity_MlsCredential { - get {return _credential ?? Xmtp_Identity_MlsCredential()} - set {_credential = newValue} - } - /// Returns true if `credential` has been explicitly set. - public var hasCredential: Bool {return self._credential != nil} - /// Clears the value of `credential`. Subsequent reads from it will return its default value. - public mutating func clearCredential() {self._credential = nil} - - public var installationPublicKey: Data = Data() - - public var expiration: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _credential: Xmtp_Identity_MlsCredential? = nil - } - - public init() {} -} - -/// Contains a batch of serialized Key Packages -public struct Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var keyPackages: [Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest.KeyPackage] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// Wrapper for each key package - public struct KeyPackage { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var keyPackageBytesTlsSerialized: Data = Data() - - public var isInboxIDCredential: Bool = false - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Response to ValidateKeyPackagesRequest -public struct Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse { - // 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_MlsValidation_V1_ValidateKeyPackagesResponse.ValidationResponse] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// An individual response to one key package - public struct ValidationResponse { - // 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 isOk: Bool = false - - public var errorMessage: String = String() - - public var installationID: Data = Data() - - public var accountAddress: String = String() - - public var credentialIdentityBytes: Data = Data() - - public var expiration: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Contains a batch of serialized Group Messages -public struct Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest { - // 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 groupMessages: [Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest.GroupMessage] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// Wrapper for each message - public struct GroupMessage { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var groupMessageBytesTlsSerialized: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Response to ValidateGroupMessagesRequest -public struct Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse { - // 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_MlsValidation_V1_ValidateGroupMessagesResponse.ValidationResponse] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// An individual response to one message - public struct ValidationResponse { - // 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 isOk: Bool = false - - public var errorMessage: String = String() - - public var groupID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -/// Request to get a final association state for identity updates -public struct Xmtp_MlsValidation_V1_GetAssociationStateRequest { - // 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. - - /// List of identity updates - public var oldUpdates: [Xmtp_Identity_Associations_IdentityUpdate] = [] - - public var newUpdates: [Xmtp_Identity_Associations_IdentityUpdate] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -/// Response to GetAssociationStateRequest, containing the final association state -/// for an InboxID -public struct Xmtp_MlsValidation_V1_GetAssociationStateResponse { - // 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 associationState: Xmtp_Identity_Associations_AssociationState { - get {return _associationState ?? Xmtp_Identity_Associations_AssociationState()} - set {_associationState = newValue} - } - /// Returns true if `associationState` has been explicitly set. - public var hasAssociationState: Bool {return self._associationState != nil} - /// Clears the value of `associationState`. Subsequent reads from it will return its default value. - public mutating func clearAssociationState() {self._associationState = nil} - - public var stateDiff: Xmtp_Identity_Associations_AssociationStateDiff { - get {return _stateDiff ?? Xmtp_Identity_Associations_AssociationStateDiff()} - set {_stateDiff = newValue} - } - /// Returns true if `stateDiff` has been explicitly set. - public var hasStateDiff: Bool {return self._stateDiff != nil} - /// Clears the value of `stateDiff`. Subsequent reads from it will return its default value. - public mutating func clearStateDiff() {self._stateDiff = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _associationState: Xmtp_Identity_Associations_AssociationState? = nil - fileprivate var _stateDiff: Xmtp_Identity_Associations_AssociationStateDiff? = nil -} - -/// Request to validate an InboxID with the backend service. Ensures an Inbox Id <> Installation key are valid. -public struct Xmtp_MlsValidation_V1_ValidateInboxIdsRequest { - // 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. - - /// list of validation requests - public var requests: [Xmtp_MlsValidation_V1_ValidateInboxIdsRequest.ValidationRequest] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// a single validation request - public struct ValidationRequest { - // 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 credential: Xmtp_Identity_MlsCredential { - get {return _credential ?? Xmtp_Identity_MlsCredential()} - set {_credential = newValue} - } - /// Returns true if `credential` has been explicitly set. - public var hasCredential: Bool {return self._credential != nil} - /// Clears the value of `credential`. Subsequent reads from it will return its default value. - public mutating func clearCredential() {self._credential = nil} - - public var installationPublicKey: Data = Data() - - public var identityUpdates: [Xmtp_Identity_Associations_IdentityUpdate] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _credential: Xmtp_Identity_MlsCredential? = nil - } - - public init() {} -} - -/// Response to ValidateInboxIdRequest -public struct Xmtp_MlsValidation_V1_ValidateInboxIdsResponse { - // 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. - - /// List of validation responses - public var responses: [Xmtp_MlsValidation_V1_ValidateInboxIdsResponse.ValidationResponse] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - /// a single validation response - public struct ValidationResponse { - // 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 isOk: Bool = false - - public var errorMessage: String = String() - - public var inboxID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse.Response: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest.KeyPackage: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse.ValidationResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest.GroupMessage: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse.ValidationResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_GetAssociationStateRequest: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_GetAssociationStateResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateInboxIdsRequest: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateInboxIdsRequest.ValidationRequest: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateInboxIdsResponse: @unchecked Sendable {} -extension Xmtp_MlsValidation_V1_ValidateInboxIdsResponse.ValidationResponse: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "xmtp.mls_validation.v1" - -extension Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateInboxIdKeyPackagesResponse" - 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_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse, rhs: Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse) -> Bool { - if lhs.responses != rhs.responses {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse.protoMessageName + ".Response" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "is_ok"), - 2: .standard(proto: "error_message"), - 3: .same(proto: "credential"), - 4: .standard(proto: "installation_public_key"), - 5: .same(proto: "expiration"), - ] - - 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.decodeSingularBoolField(value: &self.isOk) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._credential) }() - case 4: try { try decoder.decodeSingularBytesField(value: &self.installationPublicKey) }() - case 5: try { try decoder.decodeSingularUInt64Field(value: &self.expiration) }() - 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.isOk != false { - try visitor.visitSingularBoolField(value: self.isOk, fieldNumber: 1) - } - if !self.errorMessage.isEmpty { - try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) - } - try { if let v = self._credential { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - if !self.installationPublicKey.isEmpty { - try visitor.visitSingularBytesField(value: self.installationPublicKey, fieldNumber: 4) - } - if self.expiration != 0 { - try visitor.visitSingularUInt64Field(value: self.expiration, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse.Response, rhs: Xmtp_MlsValidation_V1_ValidateInboxIdKeyPackagesResponse.Response) -> Bool { - if lhs.isOk != rhs.isOk {return false} - if lhs.errorMessage != rhs.errorMessage {return false} - if lhs._credential != rhs._credential {return false} - if lhs.installationPublicKey != rhs.installationPublicKey {return false} - if lhs.expiration != rhs.expiration {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateKeyPackagesRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "key_packages"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.keyPackages) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.keyPackages.isEmpty { - try visitor.visitRepeatedMessageField(value: self.keyPackages, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest, rhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest) -> Bool { - if lhs.keyPackages != rhs.keyPackages {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest.KeyPackage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest.protoMessageName + ".KeyPackage" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "key_package_bytes_tls_serialized"), - 2: .standard(proto: "is_inbox_id_credential"), - ] - - 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.keyPackageBytesTlsSerialized) }() - case 2: try { try decoder.decodeSingularBoolField(value: &self.isInboxIDCredential) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.keyPackageBytesTlsSerialized.isEmpty { - try visitor.visitSingularBytesField(value: self.keyPackageBytesTlsSerialized, fieldNumber: 1) - } - if self.isInboxIDCredential != false { - try visitor.visitSingularBoolField(value: self.isInboxIDCredential, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest.KeyPackage, rhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesRequest.KeyPackage) -> Bool { - if lhs.keyPackageBytesTlsSerialized != rhs.keyPackageBytesTlsSerialized {return false} - if lhs.isInboxIDCredential != rhs.isInboxIDCredential {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateKeyPackagesResponse" - 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_MlsValidation_V1_ValidateKeyPackagesResponse, rhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse) -> Bool { - if lhs.responses != rhs.responses {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse.ValidationResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse.protoMessageName + ".ValidationResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "is_ok"), - 2: .standard(proto: "error_message"), - 3: .standard(proto: "installation_id"), - 4: .standard(proto: "account_address"), - 5: .standard(proto: "credential_identity_bytes"), - 6: .same(proto: "expiration"), - ] - - 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.decodeSingularBoolField(value: &self.isOk) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.installationID) }() - case 4: try { try decoder.decodeSingularStringField(value: &self.accountAddress) }() - case 5: try { try decoder.decodeSingularBytesField(value: &self.credentialIdentityBytes) }() - case 6: try { try decoder.decodeSingularUInt64Field(value: &self.expiration) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.isOk != false { - try visitor.visitSingularBoolField(value: self.isOk, fieldNumber: 1) - } - if !self.errorMessage.isEmpty { - try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) - } - if !self.installationID.isEmpty { - try visitor.visitSingularBytesField(value: self.installationID, fieldNumber: 3) - } - if !self.accountAddress.isEmpty { - try visitor.visitSingularStringField(value: self.accountAddress, fieldNumber: 4) - } - if !self.credentialIdentityBytes.isEmpty { - try visitor.visitSingularBytesField(value: self.credentialIdentityBytes, fieldNumber: 5) - } - if self.expiration != 0 { - try visitor.visitSingularUInt64Field(value: self.expiration, fieldNumber: 6) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse.ValidationResponse, rhs: Xmtp_MlsValidation_V1_ValidateKeyPackagesResponse.ValidationResponse) -> Bool { - if lhs.isOk != rhs.isOk {return false} - if lhs.errorMessage != rhs.errorMessage {return false} - if lhs.installationID != rhs.installationID {return false} - if lhs.accountAddress != rhs.accountAddress {return false} - if lhs.credentialIdentityBytes != rhs.credentialIdentityBytes {return false} - if lhs.expiration != rhs.expiration {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateGroupMessagesRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "group_messages"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.groupMessages) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.groupMessages.isEmpty { - try visitor.visitRepeatedMessageField(value: self.groupMessages, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest, rhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest) -> Bool { - if lhs.groupMessages != rhs.groupMessages {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest.GroupMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest.protoMessageName + ".GroupMessage" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "group_message_bytes_tls_serialized"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.groupMessageBytesTlsSerialized) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.groupMessageBytesTlsSerialized.isEmpty { - try visitor.visitSingularBytesField(value: self.groupMessageBytesTlsSerialized, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest.GroupMessage, rhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesRequest.GroupMessage) -> Bool { - if lhs.groupMessageBytesTlsSerialized != rhs.groupMessageBytesTlsSerialized {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateGroupMessagesResponse" - 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_MlsValidation_V1_ValidateGroupMessagesResponse, rhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse) -> Bool { - if lhs.responses != rhs.responses {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse.ValidationResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse.protoMessageName + ".ValidationResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "is_ok"), - 2: .standard(proto: "error_message"), - 3: .standard(proto: "group_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBoolField(value: &self.isOk) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.groupID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.isOk != false { - try visitor.visitSingularBoolField(value: self.isOk, fieldNumber: 1) - } - if !self.errorMessage.isEmpty { - try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) - } - if !self.groupID.isEmpty { - try visitor.visitSingularStringField(value: self.groupID, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse.ValidationResponse, rhs: Xmtp_MlsValidation_V1_ValidateGroupMessagesResponse.ValidationResponse) -> Bool { - if lhs.isOk != rhs.isOk {return false} - if lhs.errorMessage != rhs.errorMessage {return false} - if lhs.groupID != rhs.groupID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_GetAssociationStateRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAssociationStateRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "old_updates"), - 2: .standard(proto: "new_updates"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.oldUpdates) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &self.newUpdates) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.oldUpdates.isEmpty { - try visitor.visitRepeatedMessageField(value: self.oldUpdates, fieldNumber: 1) - } - if !self.newUpdates.isEmpty { - try visitor.visitRepeatedMessageField(value: self.newUpdates, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_GetAssociationStateRequest, rhs: Xmtp_MlsValidation_V1_GetAssociationStateRequest) -> Bool { - if lhs.oldUpdates != rhs.oldUpdates {return false} - if lhs.newUpdates != rhs.newUpdates {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_GetAssociationStateResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAssociationStateResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "association_state"), - 2: .standard(proto: "state_diff"), - ] - - 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._associationState) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._stateDiff) }() - 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._associationState { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._stateDiff { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_GetAssociationStateResponse, rhs: Xmtp_MlsValidation_V1_GetAssociationStateResponse) -> Bool { - if lhs._associationState != rhs._associationState {return false} - if lhs._stateDiff != rhs._stateDiff {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateInboxIdsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateInboxIdsRequest" - 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_MlsValidation_V1_ValidateInboxIdsRequest, rhs: Xmtp_MlsValidation_V1_ValidateInboxIdsRequest) -> Bool { - if lhs.requests != rhs.requests {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateInboxIdsRequest.ValidationRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateInboxIdsRequest.protoMessageName + ".ValidationRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "credential"), - 2: .standard(proto: "installation_public_key"), - 3: .standard(proto: "identity_updates"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._credential) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.installationPublicKey) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &self.identityUpdates) }() - 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._credential { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - if !self.installationPublicKey.isEmpty { - try visitor.visitSingularBytesField(value: self.installationPublicKey, fieldNumber: 2) - } - if !self.identityUpdates.isEmpty { - try visitor.visitRepeatedMessageField(value: self.identityUpdates, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateInboxIdsRequest.ValidationRequest, rhs: Xmtp_MlsValidation_V1_ValidateInboxIdsRequest.ValidationRequest) -> Bool { - if lhs._credential != rhs._credential {return false} - if lhs.installationPublicKey != rhs.installationPublicKey {return false} - if lhs.identityUpdates != rhs.identityUpdates {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateInboxIdsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ValidateInboxIdsResponse" - 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_MlsValidation_V1_ValidateInboxIdsResponse, rhs: Xmtp_MlsValidation_V1_ValidateInboxIdsResponse) -> Bool { - if lhs.responses != rhs.responses {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Xmtp_MlsValidation_V1_ValidateInboxIdsResponse.ValidationResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MlsValidation_V1_ValidateInboxIdsResponse.protoMessageName + ".ValidationResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "is_ok"), - 2: .standard(proto: "error_message"), - 3: .standard(proto: "inbox_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBoolField(value: &self.isOk) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.inboxID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.isOk != false { - try visitor.visitSingularBoolField(value: self.isOk, fieldNumber: 1) - } - if !self.errorMessage.isEmpty { - try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) - } - if !self.inboxID.isEmpty { - try visitor.visitSingularStringField(value: self.inboxID, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Xmtp_MlsValidation_V1_ValidateInboxIdsResponse.ValidationResponse, rhs: Xmtp_MlsValidation_V1_ValidateInboxIdsResponse.ValidationResponse) -> Bool { - if lhs.isOk != rhs.isOk {return false} - if lhs.errorMessage != rhs.errorMessage {return false} - if lhs.inboxID != rhs.inboxID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Tests/XMTPTests/ClientTests.swift b/Tests/XMTPTests/ClientTests.swift index e5b3b0d6..71ba11ea 100644 --- a/Tests/XMTPTests/ClientTests.swift +++ b/Tests/XMTPTests/ClientTests.swift @@ -103,16 +103,14 @@ class ClientTests: XCTestCase { appropriateFor: nil, create: false ) - - let dbPath = documentsURL.appendingPathComponent("xmtp-\(bo.walletAddress).db3").path - + let client = try await Client.create( account: bo, options: .init( api: .init(env: .local, isSecure: false), mlsAlpha: true, mlsEncryptionKey: key, - mlsDbPath: dbPath + mlsDbDirectory: "xmtp_db" ) ) @@ -123,7 +121,7 @@ class ClientTests: XCTestCase { api: .init(env: .local, isSecure: false), mlsAlpha: true, mlsEncryptionKey: key, - mlsDbPath: dbPath + mlsDbDirectory: "xmtp_db" ) ) @@ -137,7 +135,7 @@ class ClientTests: XCTestCase { api: .init(env: .local, isSecure: false), mlsAlpha: true, mlsEncryptionKey: nil, - mlsDbPath: dbPath + mlsDbDirectory: "xmtp_db" ) ) ) @@ -149,7 +147,7 @@ class ClientTests: XCTestCase { api: .init(env: .local, isSecure: false), mlsAlpha: true, mlsEncryptionKey: key, - mlsDbPath: nil + mlsDbDirectory: nil ) ) ) diff --git a/Tests/XMTPTests/ConversationTests.swift b/Tests/XMTPTests/ConversationTests.swift index 0ecce2cc..c3714c58 100644 --- a/Tests/XMTPTests/ConversationTests.swift +++ b/Tests/XMTPTests/ConversationTests.swift @@ -510,7 +510,7 @@ class ConversationTests: XCTestCase { let conversation = try aliceClient.importConversation(from: jsExportJSONData) - XCTAssertEqual(conversation?.peerAddress, "0x5DAc8E2B64b8523C11AF3e5A2E087c2EA9003f14") + XCTAssertEqual(try conversation?.peerAddress, "0x5DAc8E2B64b8523C11AF3e5A2E087c2EA9003f14") } func testImportV2ConversationFromJS() async throws { @@ -519,7 +519,7 @@ class ConversationTests: XCTestCase { """.utf8) let conversation = try aliceClient.importConversation(from: jsExportJSONData) - XCTAssertEqual(conversation?.peerAddress, "0x436D906d1339fC4E951769b1699051f020373D04") + XCTAssertEqual(try conversation?.peerAddress, "0x436D906d1339fC4E951769b1699051f020373D04") } func testImportV2ConversationWithNoContextFromJS() async throws { @@ -632,7 +632,7 @@ class ConversationTests: XCTestCase { func testCanHaveConsentState() async throws { let bobConversation = try await bobClient.conversations.newConversation(with: alice.address, context: InvitationV1.Context(conversationID: "hi")) - let isAllowed = (await bobConversation.consentState()) == .allowed + let isAllowed = (try await bobConversation.consentState()) == .allowed // Conversations you start should start as allowed XCTAssertTrue(isAllowed) @@ -640,19 +640,19 @@ class ConversationTests: XCTestCase { try await bobClient.contacts.deny(addresses: [alice.address]) try await bobClient.contacts.refreshConsentList() - let isDenied = (await bobConversation.consentState()) == .denied + let isDenied = (try await bobConversation.consentState()) == .denied XCTAssertTrue(isDenied) let aliceConversation = (try await aliceClient.conversations.list())[0] - let isUnknown = (await aliceConversation.consentState()) == .unknown + let isUnknown = (try await aliceConversation.consentState()) == .unknown // Conversations started with you should start as unknown XCTAssertTrue(isUnknown) try await aliceClient.contacts.allow(addresses: [bob.address]) - let isBobAllowed = (await aliceConversation.consentState()) == .allowed + let isBobAllowed = (try await aliceConversation.consentState()) == .allowed XCTAssertTrue(isBobAllowed) let aliceClient2 = try await Client.create(account: alice, apiClient: fakeApiClient) @@ -661,28 +661,28 @@ class ConversationTests: XCTestCase { try await aliceClient2.contacts.refreshConsentList() // Allow state should sync across clients - let isBobAllowed2 = (await aliceConversation2.consentState()) == .allowed + let isBobAllowed2 = (try await aliceConversation2.consentState()) == .allowed XCTAssertTrue(isBobAllowed2) } func testCanHaveImplicitConsentOnMessageSend() async throws { let bobConversation = try await bobClient.conversations.newConversation(with: alice.address, context: InvitationV1.Context(conversationID: "hi")) - let isAllowed = (await bobConversation.consentState()) == .allowed + let isAllowed = (try await bobConversation.consentState()) == .allowed // Conversations you start should start as allowed XCTAssertTrue(isAllowed) let aliceConversation = (try await aliceClient.conversations.list())[0] - let isUnknown = (await aliceConversation.consentState()) == .unknown + let isUnknown = (try await aliceConversation.consentState()) == .unknown // Conversations started with you should start as unknown XCTAssertTrue(isUnknown) try await aliceConversation.send(content: "hey bob") try await aliceClient.contacts.refreshConsentList() - let isNowAllowed = (await aliceConversation.consentState()) == .allowed + let isNowAllowed = (try await aliceConversation.consentState()) == .allowed // Conversations you send a message to get marked as allowed XCTAssertTrue(isNowAllowed) diff --git a/Tests/XMTPTests/ConversationsTest.swift b/Tests/XMTPTests/ConversationsTest.swift index fc64e9bf..501b895f 100644 --- a/Tests/XMTPTests/ConversationsTest.swift +++ b/Tests/XMTPTests/ConversationsTest.swift @@ -32,7 +32,7 @@ class ConversationsTests: XCTestCase { let envelope = Envelope(topic: .userIntro(client.address), timestamp: created, message: try Message(v1: message).serializedData()) let conversation = try await client.conversations.fromIntro(envelope: envelope) - XCTAssertEqual(conversation.peerAddress, newWallet.address) + XCTAssertEqual(try conversation.peerAddress, newWallet.address) XCTAssertEqual(conversation.createdAt.description, created.description) } @@ -58,7 +58,7 @@ class ConversationsTests: XCTestCase { let envelope = Envelope(topic: .userInvite(peerAddress), timestamp: created, message: try sealed.serializedData()) let conversation = try await client.conversations.fromInvite(envelope: envelope) - XCTAssertEqual(conversation.peerAddress, newWallet.address) + XCTAssertEqual(try conversation.peerAddress, newWallet.address) XCTAssertEqual(conversation.createdAt.description, created.description) } diff --git a/Tests/XMTPTests/GroupTests.swift b/Tests/XMTPTests/GroupTests.swift index 0b24b1ee..1d3344e6 100644 --- a/Tests/XMTPTests/GroupTests.swift +++ b/Tests/XMTPTests/GroupTests.swift @@ -51,7 +51,7 @@ class GroupTests: XCTestCase { account: alice, options: .init( api: .init(env: .local, isSecure: false), - codecs: [GroupMembershipChangedCodec()], + codecs: [GroupUpdatedCodec()], mlsAlpha: true, mlsEncryptionKey: key ) @@ -61,7 +61,7 @@ class GroupTests: XCTestCase { account: bob, options: .init( api: .init(env: .local, isSecure: false), - codecs: [GroupMembershipChangedCodec()], + codecs: [GroupUpdatedCodec()], mlsAlpha: true, mlsEncryptionKey: key ) @@ -71,7 +71,7 @@ class GroupTests: XCTestCase { account: fred, options: .init( api: .init(env: .local, isSecure: false), - codecs: [GroupMembershipChangedCodec()], + codecs: [GroupUpdatedCodec()], mlsAlpha: true, mlsEncryptionKey: key ) @@ -87,82 +87,82 @@ class GroupTests: XCTestCase { ) } - func testCanCreateAGroupWithDefaultPermissions() async throws { - let fixtures = try await localFixtures() - let bobGroup = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address]) - try await fixtures.aliceClient.conversations.sync() - let aliceGroup = try await fixtures.aliceClient.conversations.groups().first! - XCTAssert(!bobGroup.id.isEmpty) - XCTAssert(!aliceGroup.id.isEmpty) - - try await aliceGroup.addMembers(addresses: [fixtures.fred.address]) - try await bobGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 3) - XCTAssertEqual(bobGroup.memberAddresses.count, 3) - - try await aliceGroup.removeMembers(addresses: [fixtures.fred.address]) - try await bobGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 2) - XCTAssertEqual(bobGroup.memberAddresses.count, 2) - - try await bobGroup.addMembers(addresses: [fixtures.fred.address]) - try await aliceGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 3) - XCTAssertEqual(bobGroup.memberAddresses.count, 3) - -// XCTAssertEqual(try bobGroup.permissionLevel(), .everyoneIsAdmin) -// XCTAssertEqual(try aliceGroup.permissionLevel(), .everyoneIsAdmin) - XCTAssertEqual(try bobGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) - XCTAssertEqual(try aliceGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) - XCTAssert(try bobGroup.isAdmin()) - XCTAssert(try !aliceGroup.isAdmin()) - } - - func testCanCreateAGroupWithAdminPermissions() async throws { - let fixtures = try await localFixtures() - let bobGroup = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address], permissions: GroupPermissions.groupCreatorIsAdmin) - try await fixtures.aliceClient.conversations.sync() - let aliceGroup = try await fixtures.aliceClient.conversations.groups().first! - XCTAssert(!bobGroup.id.isEmpty) - XCTAssert(!aliceGroup.id.isEmpty) - - let bobConsentResult = await fixtures.bobClient.contacts.consentList.groupState(groupId: bobGroup.id) - XCTAssertEqual(bobConsentResult, ConsentState.allowed) - - let aliceConsentResult = await fixtures.aliceClient.contacts.consentList.groupState(groupId: aliceGroup.id) - XCTAssertEqual(aliceConsentResult, ConsentState.unknown) - - try await bobGroup.addMembers(addresses: [fixtures.fred.address]) - try await aliceGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 3) - XCTAssertEqual(bobGroup.memberAddresses.count, 3) - - await assertThrowsAsyncError( - try await aliceGroup.removeMembers(addresses: [fixtures.fred.address]) - ) - try await bobGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 3) - XCTAssertEqual(bobGroup.memberAddresses.count, 3) - - try await bobGroup.removeMembers(addresses: [fixtures.fred.address]) - try await aliceGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 2) - XCTAssertEqual(bobGroup.memberAddresses.count, 2) - - await assertThrowsAsyncError( - try await aliceGroup.addMembers(addresses: [fixtures.fred.address]) - ) - try await bobGroup.sync() - XCTAssertEqual(aliceGroup.memberAddresses.count, 2) - XCTAssertEqual(bobGroup.memberAddresses.count, 2) - -// XCTAssertEqual(try bobGroup.permissionLevel(), .groupCreatorIsAdmin) -// XCTAssertEqual(try aliceGroup.permissionLevel(), .groupCreatorIsAdmin) - XCTAssertEqual(try bobGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) - XCTAssertEqual(try aliceGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) - XCTAssert(try bobGroup.isAdmin()) - XCTAssert(try !aliceGroup.isAdmin()) - } +// func testCanCreateAGroupWithDefaultPermissions() async throws { +// let fixtures = try await localFixtures() +// let bobGroup = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address]) +// try await fixtures.aliceClient.conversations.sync() +// let aliceGroup = try await fixtures.aliceClient.conversations.groups().first! +// XCTAssert(!bobGroup.id.isEmpty) +// XCTAssert(!aliceGroup.id.isEmpty) +// +// try await aliceGroup.addMembers(addresses: [fixtures.fred.address]) +// try await bobGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 3) +// XCTAssertEqual(bobGroup.memberAddresses.count, 3) +// +// try await aliceGroup.removeMembers(addresses: [fixtures.fred.address]) +// try await bobGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 2) +// XCTAssertEqual(bobGroup.memberAddresses.count, 2) +// +// try await bobGroup.addMembers(addresses: [fixtures.fred.address]) +// try await aliceGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 3) +// XCTAssertEqual(bobGroup.memberAddresses.count, 3) +// +//// XCTAssertEqual(try bobGroup.permissionLevel(), .everyoneIsAdmin) +//// XCTAssertEqual(try aliceGroup.permissionLevel(), .everyoneIsAdmin) +// XCTAssertEqual(try bobGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) +// XCTAssertEqual(try aliceGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) +// XCTAssert(try bobGroup.isAdmin()) +// XCTAssert(try !aliceGroup.isAdmin()) +// } +// +// func testCanCreateAGroupWithAdminPermissions() async throws { +// let fixtures = try await localFixtures() +// let bobGroup = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address], permissions: GroupPermissions.groupCreatorIsAdmin) +// try await fixtures.aliceClient.conversations.sync() +// let aliceGroup = try await fixtures.aliceClient.conversations.groups().first! +// XCTAssert(!bobGroup.id.isEmpty) +// XCTAssert(!aliceGroup.id.isEmpty) +// +// let bobConsentResult = await fixtures.bobClient.contacts.consentList.groupState(groupId: bobGroup.id) +// XCTAssertEqual(bobConsentResult, ConsentState.allowed) +// +// let aliceConsentResult = await fixtures.aliceClient.contacts.consentList.groupState(groupId: aliceGroup.id) +// XCTAssertEqual(aliceConsentResult, ConsentState.unknown) +// +// try await bobGroup.addMembers(addresses: [fixtures.fred.address]) +// try await aliceGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 3) +// XCTAssertEqual(bobGroup.memberAddresses.count, 3) +// +// await assertThrowsAsyncError( +// try await aliceGroup.removeMembers(addresses: [fixtures.fred.address]) +// ) +// try await bobGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 3) +// XCTAssertEqual(bobGroup.memberAddresses.count, 3) +// +// try await bobGroup.removeMembers(addresses: [fixtures.fred.address]) +// try await aliceGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 2) +// XCTAssertEqual(bobGroup.memberAddresses.count, 2) +// +// await assertThrowsAsyncError( +// try await aliceGroup.addMembers(addresses: [fixtures.fred.address]) +// ) +// try await bobGroup.sync() +// XCTAssertEqual(aliceGroup.memberAddresses.count, 2) +// XCTAssertEqual(bobGroup.memberAddresses.count, 2) +// +//// XCTAssertEqual(try bobGroup.permissionLevel(), .groupCreatorIsAdmin) +//// XCTAssertEqual(try aliceGroup.permissionLevel(), .groupCreatorIsAdmin) +// XCTAssertEqual(try bobGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) +// XCTAssertEqual(try aliceGroup.adminAddress().lowercased(), fixtures.bobClient.address.lowercased()) +// XCTAssert(try bobGroup.isAdmin()) +// XCTAssert(try !aliceGroup.isAdmin()) +// } func testCanListGroups() async throws { let fixtures = try await localFixtures() @@ -196,11 +196,11 @@ class GroupTests: XCTestCase { let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address]) try await group.sync() - let members = group.memberAddresses.map(\.localizedLowercase).sorted() - let peerMembers = Conversation.group(group).peerAddresses.map(\.localizedLowercase).sorted() + let members = try group.members.map(\.inboxId).sorted() + let peerMembers = try Conversation.group(group).peerAddresses.sorted() - XCTAssertEqual([fixtures.bob.address.localizedLowercase, fixtures.alice.address.localizedLowercase].sorted(), members) - XCTAssertEqual([fixtures.bob.address.localizedLowercase].sorted(), peerMembers) + XCTAssertEqual([fixtures.bobClient.inboxID, fixtures.aliceClient.inboxID].sorted(), members) + XCTAssertEqual([fixtures.bobClient.inboxID].sorted(), peerMembers) } func testCanAddGroupMembers() async throws { @@ -210,16 +210,35 @@ class GroupTests: XCTestCase { try await group.addMembers(addresses: [fixtures.fred.address]) try await group.sync() - let members = group.memberAddresses.map(\.localizedLowercase).sorted() + let members = try group.members.map(\.inboxId).sorted() + + XCTAssertEqual([ + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, + fixtures.fredClient.inboxID + ].sorted(), members) + + let groupChangedMessage: GroupUpdated = try await group.messages().first!.content() + XCTAssertEqual(groupChangedMessage.addedInboxes.map(\.inboxID), [fixtures.fredClient.inboxID]) + } + + func testCanAddGroupMembersByInboxId() async throws { + let fixtures = try await localFixtures() + let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address]) + + try await group.addMembersByInboxId(inboxIds: [fixtures.fredClient.inboxID]) + + try await group.sync() + let members = try group.members.map(\.inboxId).sorted() XCTAssertEqual([ - fixtures.bob.address.localizedLowercase, - fixtures.alice.address.localizedLowercase, - fixtures.fred.address.localizedLowercase + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, + fixtures.fredClient.inboxID ].sorted(), members) - let groupChangedMessage: GroupMembershipChanges = try await group.messages().first!.content() - XCTAssertEqual(groupChangedMessage.membersAdded.map(\.accountAddress.localizedLowercase), [fixtures.fred.address.localizedLowercase]) + let groupChangedMessage: GroupUpdated = try await group.messages().first!.content() + XCTAssertEqual(groupChangedMessage.addedInboxes.map(\.inboxID), [fixtures.fredClient.inboxID]) } func testCanRemoveMembers() async throws { @@ -227,26 +246,53 @@ class GroupTests: XCTestCase { let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address, fixtures.fred.address]) try await group.sync() - let members = group.memberAddresses.map(\.localizedLowercase).sorted() + let members = try group.members.map(\.inboxId).sorted() XCTAssertEqual([ - fixtures.bob.address.localizedLowercase, - fixtures.alice.address.localizedLowercase, - fixtures.fred.address.localizedLowercase + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, + fixtures.fredClient.inboxID ].sorted(), members) try await group.removeMembers(addresses: [fixtures.fred.address]) try await group.sync() - let newMembers = group.memberAddresses.map(\.localizedLowercase).sorted() + let newMembers = try group.members.map(\.inboxId).sorted() + XCTAssertEqual([ + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, + ].sorted(), newMembers) + + let groupChangedMessage: GroupUpdated = try await group.messages().first!.content() + XCTAssertEqual(groupChangedMessage.removedInboxes.map(\.inboxID), [fixtures.fredClient.inboxID]) + } + + func testCanRemoveMembersByInboxId() async throws { + let fixtures = try await localFixtures() + let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address, fixtures.fred.address]) + + try await group.sync() + let members = try group.members.map(\.inboxId).sorted() + + XCTAssertEqual([ + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, + fixtures.fredClient.inboxID + ].sorted(), members) + + try await group.removeMembersByInboxId(inboxIds: [fixtures.fredClient.inboxID]) + + try await group.sync() + + let newMembers = try group.members.map(\.inboxId).sorted() XCTAssertEqual([ - fixtures.bob.address.localizedLowercase, - fixtures.alice.address.localizedLowercase, + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, ].sorted(), newMembers) - let groupChangedMessage: GroupMembershipChanges = try await group.messages().first!.content() - XCTAssertEqual(groupChangedMessage.membersRemoved.map(\.accountAddress.localizedLowercase), [fixtures.fred.address.localizedLowercase]) + let groupChangedMessage: GroupUpdated = try await group.messages().first!.content() + XCTAssertEqual(groupChangedMessage.removedInboxes.map(\.inboxID), [fixtures.fredClient.inboxID]) } func testCanMessage() async throws { @@ -263,12 +309,12 @@ class GroupTests: XCTestCase { let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address, fixtures.fred.address]) try await group.sync() - let members = group.memberAddresses.map(\.localizedLowercase).sorted() + let members = try group.members.map(\.inboxId).sorted() XCTAssertEqual([ - fixtures.bob.address.localizedLowercase, - fixtures.alice.address.localizedLowercase, - fixtures.fred.address.localizedLowercase + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, + fixtures.fredClient.inboxID ].sorted(), members) try await fixtures.fredClient.conversations.sync() @@ -285,10 +331,10 @@ class GroupTests: XCTestCase { try await group.sync() - let newMembers = group.memberAddresses.map(\.localizedLowercase).sorted() + let newMembers = try group.members.map(\.inboxId).sorted() XCTAssertEqual([ - fixtures.bob.address.localizedLowercase, - fixtures.alice.address.localizedLowercase, + fixtures.bobClient.inboxID, + fixtures.aliceClient.inboxID, ].sorted(), newMembers) try await fredGroup?.sync() @@ -313,8 +359,8 @@ class GroupTests: XCTestCase { // Check Bob's group for the added_by_address of the inviter let bobGroup = try await fixtures.bobClient.conversations.groups().first - let aliceAddress = fixtures.alice.address.localizedLowercase - let whoAddedBob = try bobGroup?.addedByAddress().localizedLowercase + let aliceAddress = fixtures.aliceClient.inboxID + let whoAddedBob = try bobGroup?.addedByInboxId() // Verify the welcome host_credential is equal to Amal's XCTAssertEqual(aliceAddress, whoAddedBob) @@ -370,14 +416,14 @@ class GroupTests: XCTestCase { func testCanSendMessagesToGroup() async throws { let fixtures = try await localFixtures() let aliceGroup = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address]) - let membershipChange = GroupMembershipChanges() + let membershipChange = GroupUpdated() try await fixtures.bobClient.conversations.sync() let bobGroup = try await fixtures.bobClient.conversations.groups()[0] _ = try await aliceGroup.send(content: "sup gang original") let messageId = try await aliceGroup.send(content: "sup gang") - _ = try await aliceGroup.send(content: membershipChange, options: SendOptions(contentType: ContentTypeGroupMembershipChanged)) + _ = try await aliceGroup.send(content: membershipChange, options: SendOptions(contentType: ContentTypeGroupUpdated)) try await aliceGroup.sync() let aliceGroupsCount = try await aliceGroup.messages().count @@ -457,7 +503,7 @@ class GroupTests: XCTestCase { func testCanStreamGroupMessages() async throws { let fixtures = try await localFixtures() let group = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.address]) - let membershipChange = GroupMembershipChanges() + let membershipChange = GroupUpdated() let expectation1 = expectation(description: "got a message") expectation1.expectedFulfillmentCount = 1 @@ -468,7 +514,7 @@ class GroupTests: XCTestCase { } _ = try await group.send(content: "hi") - _ = try await group.send(content: membershipChange, options: SendOptions(contentType: ContentTypeGroupMembershipChanged)) + _ = try await group.send(content: membershipChange, options: SendOptions(contentType: ContentTypeGroupUpdated)) await waitForExpectations(timeout: 3) } @@ -529,7 +575,7 @@ class GroupTests: XCTestCase { func testCanStreamAllDecryptedMessages() async throws { let fixtures = try await localFixtures() - let membershipChange = GroupMembershipChanges() + let membershipChange = GroupUpdated() let expectation1 = expectation(description: "got a conversation") expectation1.expectedFulfillmentCount = 2 @@ -543,7 +589,7 @@ class GroupTests: XCTestCase { } _ = try await group.send(content: "hi") - _ = try await group.send(content: membershipChange, options: SendOptions(contentType: ContentTypeGroupMembershipChanged)) + _ = try await group.send(content: membershipChange, options: SendOptions(contentType: ContentTypeGroupUpdated)) _ = try await convo.send(content: "hi") await waitForExpectations(timeout: 3) diff --git a/Tests/XMTPTests/IntegrationTests.swift b/Tests/XMTPTests/IntegrationTests.swift index 6bdee833..608417b6 100644 --- a/Tests/XMTPTests/IntegrationTests.swift +++ b/Tests/XMTPTests/IntegrationTests.swift @@ -195,8 +195,8 @@ final class IntegrationTests: XCTestCase { // Alice should see the same topic and keyMaterial for both conversations. XCTAssertEqual(c1.topic, c2.topic) XCTAssertEqual( - c1.toTopicData().invitation.aes256GcmHkdfSha256.keyMaterial, - c2.toTopicData().invitation.aes256GcmHkdfSha256.keyMaterial) + try c1.toTopicData().invitation.aes256GcmHkdfSha256.keyMaterial, + try c2.toTopicData().invitation.aes256GcmHkdfSha256.keyMaterial) // And Bob should only see the one conversation. let bobConvos = try await bob.conversations.list() diff --git a/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift b/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift index 94c1fcae..71105cc6 100644 --- a/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift +++ b/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift @@ -91,14 +91,14 @@ struct MessageGroupMembershipChangedView: View { var label: String { do { - let changes: GroupMembershipChanges = try message.content() + let changes: GroupUpdated = try message.content() - if !changes.membersAdded.isEmpty { - return "Added \(changes.membersAdded.map(\.accountAddress).map { Util.abbreviate(address: $0) }.joined(separator: ", "))" + if !changes.addedInboxes.isEmpty { + return "Added \(changes.addedInboxes.map(\.inboxID).map { Util.abbreviate(address: $0) }.joined(separator: ", "))" } - if !changes.membersRemoved.isEmpty { - return "Removed \(changes.membersRemoved.map(\.accountAddress).map { Util.abbreviate(address: $0) }.joined(separator: ", "))" + if !changes.removedInboxes.isEmpty { + return "Removed \(changes.removedInboxes.map(\.inboxID).map { Util.abbreviate(address: $0) }.joined(separator: ", "))" } return changes.debugDescription @@ -119,7 +119,7 @@ struct MessageCellView: View { switch message.encodedContent.type { case ContentTypeText: MessageTextView(myAddress: myAddress, message: message) - case ContentTypeGroupMembershipChanged: + case ContentTypeGroupUpdated: MessageGroupMembershipChangedView(message: message) default: Text(message.fallbackContent) diff --git a/XMTPiOSExample/XMTPiOSExample/Views/NewConversationView.swift b/XMTPiOSExample/XMTPiOSExample/Views/NewConversationView.swift index e76bb025..c54d487e 100644 --- a/XMTPiOSExample/XMTPiOSExample/Views/NewConversationView.swift +++ b/XMTPiOSExample/XMTPiOSExample/Views/NewConversationView.swift @@ -8,23 +8,26 @@ import SwiftUI import XMTPiOS -enum ConversationOrGroup: Identifiable, Hashable { +enum ConversationOrGroup: Hashable { + case conversation(Conversation), group(XMTPiOS.Group) - static func == (lhs: ConversationOrGroup, rhs: ConversationOrGroup) -> Bool { - lhs.id == rhs.id + static func == (lhs: ConversationOrGroup, rhs: ConversationOrGroup) throws -> Bool { + try lhs.id == rhs.id } - func hash(into hasher: inout Hasher) { - id.hash(into: &hasher) + func hash(into hasher: inout Hasher) throws { + try id.hash(into: &hasher) } var id: String { - switch self { - case .conversation(let conversation): - return conversation.peerAddress - case .group(let group): - return group.memberAddresses.joined(separator: ",") + get throws { + switch self { + case .conversation(let conversation): + return try conversation.peerAddress + case .group(let group): + return try group.members.map(\.inboxId).joined(separator: ",") + } } }