From 1eab6351c5ecf119760cfd8073a4286490f37d84 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 29 Feb 2024 13:26:25 -0700 Subject: [PATCH] bump the protos to the latest --- .../Proto/message_contents/message.pb.swift | 40 ++- .../private_preferences.pb.swift | 243 ++++++++++++++---- .../xcshareddata/swiftpm/Package.resolved | 4 +- 3 files changed, 230 insertions(+), 57 deletions(-) diff --git a/Sources/XMTPiOS/Proto/message_contents/message.pb.swift b/Sources/XMTPiOS/Proto/message_contents/message.pb.swift index 8cbf8114..22e935fe 100644 --- a/Sources/XMTPiOS/Proto/message_contents/message.pb.swift +++ b/Sources/XMTPiOS/Proto/message_contents/message.pb.swift @@ -125,16 +125,32 @@ public struct Xmtp_MessageContents_MessageV2 { public mutating func clearCiphertext() {self._ciphertext = nil} /// HMAC of the message ciphertext, with the HMAC key derived from the topic key - public var senderHmac: Data = Data() + public var senderHmac: Data { + get {return _senderHmac ?? Data()} + set {_senderHmac = newValue} + } + /// Returns true if `senderHmac` has been explicitly set. + public var hasSenderHmac: Bool {return self._senderHmac != nil} + /// Clears the value of `senderHmac`. Subsequent reads from it will return its default value. + public mutating func clearSenderHmac() {self._senderHmac = nil} /// Flag indicating whether the message should be pushed from a notification server - public var shouldPush: Bool = false + public var shouldPush: Bool { + get {return _shouldPush ?? false} + set {_shouldPush = newValue} + } + /// Returns true if `shouldPush` has been explicitly set. + public var hasShouldPush: Bool {return self._shouldPush != nil} + /// Clears the value of `shouldPush`. Subsequent reads from it will return its default value. + public mutating func clearShouldPush() {self._shouldPush = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} fileprivate var _ciphertext: Xmtp_MessageContents_Ciphertext? = nil + fileprivate var _senderHmac: Data? = nil + fileprivate var _shouldPush: Bool? = nil } /// Versioned Message @@ -432,8 +448,8 @@ extension Xmtp_MessageContents_MessageV2: SwiftProtobuf.Message, SwiftProtobuf._ switch fieldNumber { case 1: try { try decoder.decodeSingularBytesField(value: &self.headerBytes) }() case 2: try { try decoder.decodeSingularMessageField(value: &self._ciphertext) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.senderHmac) }() - case 4: try { try decoder.decodeSingularBoolField(value: &self.shouldPush) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._senderHmac) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self._shouldPush) }() default: break } } @@ -450,20 +466,20 @@ extension Xmtp_MessageContents_MessageV2: SwiftProtobuf.Message, SwiftProtobuf._ try { if let v = self._ciphertext { try visitor.visitSingularMessageField(value: v, fieldNumber: 2) } }() - if !self.senderHmac.isEmpty { - try visitor.visitSingularBytesField(value: self.senderHmac, fieldNumber: 3) - } - if self.shouldPush != false { - try visitor.visitSingularBoolField(value: self.shouldPush, fieldNumber: 4) - } + try { if let v = self._senderHmac { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try { if let v = self._shouldPush { + try visitor.visitSingularBoolField(value: v, fieldNumber: 4) + } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Xmtp_MessageContents_MessageV2, rhs: Xmtp_MessageContents_MessageV2) -> Bool { if lhs.headerBytes != rhs.headerBytes {return false} if lhs._ciphertext != rhs._ciphertext {return false} - if lhs.senderHmac != rhs.senderHmac {return false} - if lhs.shouldPush != rhs.shouldPush {return false} + if lhs._senderHmac != rhs._senderHmac {return false} + if lhs._shouldPush != rhs._shouldPush {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/XMTPiOS/Proto/message_contents/private_preferences.pb.swift b/Sources/XMTPiOS/Proto/message_contents/private_preferences.pb.swift index 185242d9..575bb037 100644 --- a/Sources/XMTPiOS/Proto/message_contents/private_preferences.pb.swift +++ b/Sources/XMTPiOS/Proto/message_contents/private_preferences.pb.swift @@ -9,8 +9,8 @@ /// Private Key Storage /// -/// Following definitions are not used in the protocol, instead -/// they provide a way for encoding private keys for storage. +/// Following definitions are not used in the protocol, instead they provide a +/// way for encoding private keys for storage. import Foundation import SwiftProtobuf @@ -25,9 +25,8 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } -/// PrivatePreferencesAction is a message used to update the client's -/// preference store. The only current actions are allow and block. -/// Other actions may be added later +/// PrivatePreferencesAction is a message used to update the client's preference +/// store. public struct Xmtp_MessageContents_PrivatePreferencesAction { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -35,27 +34,45 @@ public struct Xmtp_MessageContents_PrivatePreferencesAction { public var messageType: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType? = nil - public var allow: Xmtp_MessageContents_PrivatePreferencesAction.Allow { + public var allowAddress: Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress { get { - if case .allow(let v)? = messageType {return v} - return Xmtp_MessageContents_PrivatePreferencesAction.Allow() + if case .allowAddress(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress() } - set {messageType = .allow(newValue)} + set {messageType = .allowAddress(newValue)} } - public var block: Xmtp_MessageContents_PrivatePreferencesAction.Block { + public var denyAddress: Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress { get { - if case .block(let v)? = messageType {return v} - return Xmtp_MessageContents_PrivatePreferencesAction.Block() + if case .denyAddress(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress() } - set {messageType = .block(newValue)} + set {messageType = .denyAddress(newValue)} + } + + public var allowGroup: Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup { + get { + if case .allowGroup(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup() + } + set {messageType = .allowGroup(newValue)} + } + + public var denyGroup: Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup { + get { + if case .denyGroup(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup() + } + set {messageType = .denyGroup(newValue)} } public var unknownFields = SwiftProtobuf.UnknownStorage() public enum OneOf_MessageType: Equatable { - case allow(Xmtp_MessageContents_PrivatePreferencesAction.Allow) - case block(Xmtp_MessageContents_PrivatePreferencesAction.Block) + case allowAddress(Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress) + case denyAddress(Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress) + case allowGroup(Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup) + case denyGroup(Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup) #if !swift(>=4.1) public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType, rhs: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType) -> Bool { @@ -63,12 +80,20 @@ public struct Xmtp_MessageContents_PrivatePreferencesAction { // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch (lhs, rhs) { - case (.allow, .allow): return { - guard case .allow(let l) = lhs, case .allow(let r) = rhs else { preconditionFailure() } + case (.allowAddress, .allowAddress): return { + guard case .allowAddress(let l) = lhs, case .allowAddress(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.denyAddress, .denyAddress): return { + guard case .denyAddress(let l) = lhs, case .denyAddress(let r) = rhs else { preconditionFailure() } return l == r }() - case (.block, .block): return { - guard case .block(let l) = lhs, case .block(let r) = rhs else { preconditionFailure() } + case (.allowGroup, .allowGroup): return { + guard case .allowGroup(let l) = lhs, case .allowGroup(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.denyGroup, .denyGroup): return { + guard case .denyGroup(let l) = lhs, case .denyGroup(let r) = rhs else { preconditionFailure() } return l == r }() default: return false @@ -77,12 +102,13 @@ public struct Xmtp_MessageContents_PrivatePreferencesAction { #endif } - /// Add the given wallet addresses to the allow list - public struct Allow { + /// Allow 1:1 direct message (DM) access + public struct AllowAddress { // 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. + /// Add the given wallet addresses to the allow list public var walletAddresses: [String] = [] public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -90,12 +116,13 @@ public struct Xmtp_MessageContents_PrivatePreferencesAction { public init() {} } - /// Add the given wallet addresses to the block list - public struct Block { + /// Deny (block) 1:1 direct message (DM) access + public struct DenyAddress { // 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. + /// Add the given wallet addresses to the deny list public var walletAddresses: [String] = [] public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -103,6 +130,34 @@ public struct Xmtp_MessageContents_PrivatePreferencesAction { public init() {} } + /// Allow Group access + public struct AllowGroup { + // 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. + + /// Add the given group_ids to the allow list + public var groupIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + /// Deny (deny) Group access + public struct DenyGroup { + // 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. + + /// Add the given group_ids to the deny list + public var groupIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + public init() {} } @@ -148,8 +203,10 @@ public struct Xmtp_MessageContents_PrivatePreferencesPayload { #if swift(>=5.5) && canImport(_Concurrency) extension Xmtp_MessageContents_PrivatePreferencesAction: @unchecked Sendable {} extension Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType: @unchecked Sendable {} -extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: @unchecked Sendable {} -extension Xmtp_MessageContents_PrivatePreferencesAction.Block: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup: @unchecked Sendable {} extension Xmtp_MessageContents_PrivatePreferencesPayload: @unchecked Sendable {} extension Xmtp_MessageContents_PrivatePreferencesPayload.OneOf_Version: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) @@ -161,8 +218,10 @@ fileprivate let _protobuf_package = "xmtp.message_contents" extension Xmtp_MessageContents_PrivatePreferencesAction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".PrivatePreferencesAction" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "allow"), - 2: .same(proto: "block"), + 1: .standard(proto: "allow_address"), + 2: .standard(proto: "deny_address"), + 3: .standard(proto: "allow_group"), + 4: .standard(proto: "deny_group"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -172,29 +231,55 @@ extension Xmtp_MessageContents_PrivatePreferencesAction: SwiftProtobuf.Message, // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { - var v: Xmtp_MessageContents_PrivatePreferencesAction.Allow? + var v: Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress? var hadOneofValue = false if let current = self.messageType { hadOneofValue = true - if case .allow(let m) = current {v = m} + if case .allowAddress(let m) = current {v = m} } try decoder.decodeSingularMessageField(value: &v) if let v = v { if hadOneofValue {try decoder.handleConflictingOneOf()} - self.messageType = .allow(v) + self.messageType = .allowAddress(v) } }() case 2: try { - var v: Xmtp_MessageContents_PrivatePreferencesAction.Block? + var v: Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress? + var hadOneofValue = false + if let current = self.messageType { + hadOneofValue = true + if case .denyAddress(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.messageType = .denyAddress(v) + } + }() + case 3: try { + var v: Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup? + var hadOneofValue = false + if let current = self.messageType { + hadOneofValue = true + if case .allowGroup(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.messageType = .allowGroup(v) + } + }() + case 4: try { + var v: Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup? var hadOneofValue = false if let current = self.messageType { hadOneofValue = true - if case .block(let m) = current {v = m} + if case .denyGroup(let m) = current {v = m} } try decoder.decodeSingularMessageField(value: &v) if let v = v { if hadOneofValue {try decoder.handleConflictingOneOf()} - self.messageType = .block(v) + self.messageType = .denyGroup(v) } }() default: break @@ -208,14 +293,22 @@ extension Xmtp_MessageContents_PrivatePreferencesAction: SwiftProtobuf.Message, // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 switch self.messageType { - case .allow?: try { - guard case .allow(let v)? = self.messageType else { preconditionFailure() } + case .allowAddress?: try { + guard case .allowAddress(let v)? = self.messageType else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 1) }() - case .block?: try { - guard case .block(let v)? = self.messageType else { preconditionFailure() } + case .denyAddress?: try { + guard case .denyAddress(let v)? = self.messageType else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 2) }() + case .allowGroup?: try { + guard case .allowGroup(let v)? = self.messageType else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + }() + case .denyGroup?: try { + guard case .denyGroup(let v)? = self.messageType else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + }() case nil: break } try unknownFields.traverse(visitor: &visitor) @@ -228,8 +321,8 @@ extension Xmtp_MessageContents_PrivatePreferencesAction: SwiftProtobuf.Message, } } -extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".Allow" +extension Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".AllowAddress" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "wallet_addresses"), ] @@ -253,15 +346,15 @@ extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: SwiftProtobuf.Mes try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.Allow, rhs: Xmtp_MessageContents_PrivatePreferencesAction.Allow) -> Bool { + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress, rhs: Xmtp_MessageContents_PrivatePreferencesAction.AllowAddress) -> Bool { if lhs.walletAddresses != rhs.walletAddresses {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Xmtp_MessageContents_PrivatePreferencesAction.Block: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".Block" +extension Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".DenyAddress" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "wallet_addresses"), ] @@ -285,13 +378,77 @@ extension Xmtp_MessageContents_PrivatePreferencesAction.Block: SwiftProtobuf.Mes try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.Block, rhs: Xmtp_MessageContents_PrivatePreferencesAction.Block) -> Bool { + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress, rhs: Xmtp_MessageContents_PrivatePreferencesAction.DenyAddress) -> Bool { if lhs.walletAddresses != rhs.walletAddresses {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } +extension Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".AllowGroup" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "group_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedBytesField(value: &self.groupIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.groupIds.isEmpty { + try visitor.visitRepeatedBytesField(value: self.groupIds, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup, rhs: Xmtp_MessageContents_PrivatePreferencesAction.AllowGroup) -> Bool { + if lhs.groupIds != rhs.groupIds {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".DenyGroup" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "group_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedBytesField(value: &self.groupIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.groupIds.isEmpty { + try visitor.visitRepeatedBytesField(value: self.groupIds, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup, rhs: Xmtp_MessageContents_PrivatePreferencesAction.DenyGroup) -> Bool { + if lhs.groupIds != rhs.groupIds {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Xmtp_MessageContents_PrivatePreferencesPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".PrivatePreferencesPayload" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 3612b1e6..42929c12 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift", "state" : { - "revision" : "f6571b6b771b4c0a2a9469bd407ce124a9d91fed", - "version" : "0.4.2-beta3" + "revision" : "28ee27a4ded8b996a74850e366247e9fe51d782a", + "version" : "0.4.2-beta4" } }, {