diff --git a/swift/keystore_api/v1/keystore.pb.swift b/swift/keystore_api/v1/keystore.pb.swift index 586462ad..865874ae 100644 --- a/swift/keystore_api/v1/keystore.pb.swift +++ b/swift/keystore_api/v1/keystore.pb.swift @@ -58,7 +58,7 @@ public enum Xmtp_KeystoreApi_V1_ErrorCode: SwiftProtobuf.Enum { extension Xmtp_KeystoreApi_V1_ErrorCode: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Xmtp_KeystoreApi_V1_ErrorCode] = [ + public static let allCases: [Xmtp_KeystoreApi_V1_ErrorCode] = [ .unspecified, .invalidInput, .noMatchingPrekey, @@ -67,6 +67,51 @@ extension Xmtp_KeystoreApi_V1_ErrorCode: CaseIterable { #endif // swift(>=4.2) +/// JobType is used to specify the type of job the caller would like info on +public enum Xmtp_KeystoreApi_V1_JobType: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + case refreshV1 // = 1 + case refreshV2 // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .refreshV1 + case 2: self = .refreshV2 + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .refreshV1: return 1 + case .refreshV2: return 2 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension Xmtp_KeystoreApi_V1_JobType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Xmtp_KeystoreApi_V1_JobType] = [ + .unspecified, + .refreshV1, + .refreshV2, + ] +} + +#endif // swift(>=4.2) + /// Wrapper class for errors from the Keystore API public struct Xmtp_KeystoreApi_V1_KeystoreError { // SwiftProtobuf.Message conformance is added in an extension below. See the @@ -604,6 +649,178 @@ public struct Xmtp_KeystoreApi_V1_CreateAuthTokenRequest { fileprivate var _timestampNs: UInt64? = nil } +/// SaveV1ConversationsRequest is used to save a batch of conversations to the +/// built in persistence +public struct Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var conversations: [Xmtp_MessageContents_ConversationReference] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Placeholder response type for SaveV1Conversations +public struct Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Response for GetV2Conversations +public struct Xmtp_KeystoreApi_V1_GetConversationsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var conversations: [Xmtp_MessageContents_ConversationReference] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Used to check if the Keystore implementation has been setup for the given +/// wallet address Only used for MM Snap Keystore currently +public struct Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddress: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Response to GetKeystoreStatusRequest +public struct Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var status: Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Status of the Keystore for the specified wallet address + public enum KeystoreStatus: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + case uninitialized // = 1 + case initialized // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .uninitialized + case 2: self = .initialized + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .uninitialized: return 1 + case .initialized: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus] = [ + .unspecified, + .uninitialized, + .initialized, + ] +} + +#endif // swift(>=4.2) + +/// Used to initialize the Keystore with a private key bundle retrieved from the +/// client +public struct Xmtp_KeystoreApi_V1_InitKeystoreRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var bundle: Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle? = nil + + public var v1: Xmtp_MessageContents_PrivateKeyBundleV1 { + get { + if case .v1(let v)? = bundle {return v} + return Xmtp_MessageContents_PrivateKeyBundleV1() + } + set {bundle = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Bundle: Equatable { + case v1(Xmtp_MessageContents_PrivateKeyBundleV1) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle, rhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} +} + +/// Response to the request to initialize the Keystore +public struct Xmtp_KeystoreApi_V1_InitKeystoreResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var error: Xmtp_KeystoreApi_V1_KeystoreError { + get {return _error ?? Xmtp_KeystoreApi_V1_KeystoreError()} + set {_error = newValue} + } + /// Returns true if `error` has been explicitly set. + public var hasError: Bool {return self._error != nil} + /// Clears the value of `error`. Subsequent reads from it will return its default value. + public mutating func clearError() {self._error = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _error: Xmtp_KeystoreApi_V1_KeystoreError? = nil +} + /// SignDigestRequest is used to sign a digest with either the identity key /// or a prekey public struct Xmtp_KeystoreApi_V1_SignDigestRequest { @@ -660,6 +877,58 @@ public struct Xmtp_KeystoreApi_V1_SignDigestRequest { public init() {} } +/// GetRefreshJobRequest is used to get the last run time of a refresh job +public struct Xmtp_KeystoreApi_V1_GetRefreshJobRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var jobType: Xmtp_KeystoreApi_V1_JobType = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// GetRefreshJobResponse is used to return the last run time of a refresh job +public struct Xmtp_KeystoreApi_V1_GetRefreshJobResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var lastRunNs: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// SetRefreshJobRequest is used to set the last run time of a refresh job +public struct Xmtp_KeystoreApi_V1_SetRefeshJobRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var jobType: Xmtp_KeystoreApi_V1_JobType = .unspecified + + public var lastRunNs: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// SetRefreshJobResponse is an empty response type +public struct Xmtp_KeystoreApi_V1_SetRefreshJobResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + /// A mapping of topics to their decrypted invitations public struct Xmtp_KeystoreApi_V1_TopicMap { // SwiftProtobuf.Message conformance is added in an extension below. See the @@ -701,6 +970,7 @@ public struct Xmtp_KeystoreApi_V1_TopicMap { #if swift(>=5.5) && canImport(_Concurrency) extension Xmtp_KeystoreApi_V1_ErrorCode: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_JobType: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_KeystoreError: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_DecryptV1Request: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_DecryptV1Request.Request: @unchecked Sendable {} @@ -727,8 +997,21 @@ extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response: @unchecked Sendable extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.OneOf_Response: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_SaveInvitesResponse.Response.Success: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_CreateAuthTokenRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetConversationsResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_InitKeystoreRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_InitKeystoreRequest.OneOf_Bundle: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_InitKeystoreResponse: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_SignDigestRequest: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_SignDigestRequest.OneOf_Signer: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetRefreshJobRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_GetRefreshJobResponse: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SetRefeshJobRequest: @unchecked Sendable {} +extension Xmtp_KeystoreApi_V1_SetRefreshJobResponse: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_TopicMap: @unchecked Sendable {} extension Xmtp_KeystoreApi_V1_TopicMap.TopicData: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) @@ -745,6 +1028,14 @@ extension Xmtp_KeystoreApi_V1_ErrorCode: SwiftProtobuf._ProtoNameProviding { ] } +extension Xmtp_KeystoreApi_V1_JobType: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "JOB_TYPE_UNSPECIFIED"), + 1: .same(proto: "JOB_TYPE_REFRESH_V1"), + 2: .same(proto: "JOB_TYPE_REFRESH_V2"), + ] +} + extension Xmtp_KeystoreApi_V1_KeystoreError: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".KeystoreError" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -1717,6 +2008,245 @@ extension Xmtp_KeystoreApi_V1_CreateAuthTokenRequest: SwiftProtobuf.Message, Swi } } +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SaveV1ConversationsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "conversations"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.conversations) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.conversations.isEmpty { + try visitor.visitRepeatedMessageField(value: self.conversations, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest, rhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsRequest) -> Bool { + if lhs.conversations != rhs.conversations {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SaveV1ConversationsResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse, rhs: Xmtp_KeystoreApi_V1_SaveV1ConversationsResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetConversationsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetConversationsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "conversations"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.conversations) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.conversations.isEmpty { + try visitor.visitRepeatedMessageField(value: self.conversations, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetConversationsResponse, rhs: Xmtp_KeystoreApi_V1_GetConversationsResponse) -> Bool { + if lhs.conversations != rhs.conversations {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetKeystoreStatusRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.walletAddress) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddress.isEmpty { + try visitor.visitSingularStringField(value: self.walletAddress, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest, rhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusRequest) -> Bool { + if lhs.walletAddress != rhs.walletAddress {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetKeystoreStatusResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.status != .unspecified { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse, rhs: Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetKeystoreStatusResponse.KeystoreStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "KEYSTORE_STATUS_UNSPECIFIED"), + 1: .same(proto: "KEYSTORE_STATUS_UNINITIALIZED"), + 2: .same(proto: "KEYSTORE_STATUS_INITIALIZED"), + ] +} + +extension Xmtp_KeystoreApi_V1_InitKeystoreRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InitKeystoreRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_MessageContents_PrivateKeyBundleV1? + var hadOneofValue = false + if let current = self.bundle { + hadOneofValue = true + if case .v1(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.bundle = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.bundle { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest, rhs: Xmtp_KeystoreApi_V1_InitKeystoreRequest) -> Bool { + if lhs.bundle != rhs.bundle {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_InitKeystoreResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InitKeystoreResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "error"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._error) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._error { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_InitKeystoreResponse, rhs: Xmtp_KeystoreApi_V1_InitKeystoreResponse) -> Bool { + if lhs._error != rhs._error {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Xmtp_KeystoreApi_V1_SignDigestRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".SignDigestRequest" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -1783,6 +2313,127 @@ extension Xmtp_KeystoreApi_V1_SignDigestRequest: SwiftProtobuf.Message, SwiftPro } } +extension Xmtp_KeystoreApi_V1_GetRefreshJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetRefreshJobRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "job_type"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.jobType) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.jobType != .unspecified { + try visitor.visitSingularEnumField(value: self.jobType, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetRefreshJobRequest, rhs: Xmtp_KeystoreApi_V1_GetRefreshJobRequest) -> Bool { + if lhs.jobType != rhs.jobType {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_GetRefreshJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetRefreshJobResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "last_run_ns"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt64Field(value: &self.lastRunNs) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.lastRunNs != 0 { + try visitor.visitSingularInt64Field(value: self.lastRunNs, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_GetRefreshJobResponse, rhs: Xmtp_KeystoreApi_V1_GetRefreshJobResponse) -> Bool { + if lhs.lastRunNs != rhs.lastRunNs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_SetRefeshJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SetRefeshJobRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "job_type"), + 2: .standard(proto: "last_run_ns"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.jobType) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self.lastRunNs) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.jobType != .unspecified { + try visitor.visitSingularEnumField(value: self.jobType, fieldNumber: 1) + } + if self.lastRunNs != 0 { + try visitor.visitSingularInt64Field(value: self.lastRunNs, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SetRefeshJobRequest, rhs: Xmtp_KeystoreApi_V1_SetRefeshJobRequest) -> Bool { + if lhs.jobType != rhs.jobType {return false} + if lhs.lastRunNs != rhs.lastRunNs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_KeystoreApi_V1_SetRefreshJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SetRefreshJobResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_KeystoreApi_V1_SetRefreshJobResponse, rhs: Xmtp_KeystoreApi_V1_SetRefreshJobResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Xmtp_KeystoreApi_V1_TopicMap: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".TopicMap" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/swift/message_api/v1/authn.pb.swift b/swift/message_api/v1/authn.pb.swift index 22361f7c..238944c2 100644 --- a/swift/message_api/v1/authn.pb.swift +++ b/swift/message_api/v1/authn.pb.swift @@ -73,7 +73,7 @@ public struct Xmtp_MessageApi_V1_AuthData { /// address of the wallet public var walletAddr: String = String() - /// time when the token was generated/signed + /// time when the token was generated/signed public var createdNs: UInt64 = 0 public var unknownFields = SwiftProtobuf.UnknownStorage() diff --git a/swift/message_api/v1/message_api.grpc.swift b/swift/message_api/v1/message_api.grpc.swift index 9dd0fa0b..3d2f5e1b 100644 --- a/swift/message_api/v1/message_api.grpc.swift +++ b/swift/message_api/v1/message_api.grpc.swift @@ -44,6 +44,11 @@ public protocol Xmtp_MessageApi_V1_MessageApiClientProtocol: GRPCClient { handler: @escaping (Xmtp_MessageApi_V1_Envelope) -> Void ) -> ServerStreamingCall + func subscribe2( + callOptions: CallOptions?, + handler: @escaping (Xmtp_MessageApi_V1_Envelope) -> Void + ) -> BidirectionalStreamingCall + func subscribeAll( _ request: Xmtp_MessageApi_V1_SubscribeAllRequest, callOptions: CallOptions?, @@ -105,6 +110,29 @@ extension Xmtp_MessageApi_V1_MessageApiClientProtocol { ) } + /// Subscribe to a stream of new envelopes and your subscription using + /// bidirectional streaming + /// protolint:disable:next RPC_REQUEST_STANDARD_NAME + /// + /// Callers should use the `send` method on the returned object to send messages + /// to the server. The caller should send an `.end` after the final message has been sent. + /// + /// - Parameters: + /// - callOptions: Call options. + /// - handler: A closure called when each response is received from the server. + /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. + public func subscribe2( + callOptions: CallOptions? = nil, + handler: @escaping (Xmtp_MessageApi_V1_Envelope) -> Void + ) -> BidirectionalStreamingCall { + return self.makeBidirectionalStreamingCall( + path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [], + handler: handler + ) + } + /// Subscribe to a stream of all messages /// /// - Parameters: @@ -239,6 +267,10 @@ public protocol Xmtp_MessageApi_V1_MessageApiAsyncClientProtocol: GRPCClient { callOptions: CallOptions? ) -> GRPCAsyncServerStreamingCall + func makeSubscribe2Call( + callOptions: CallOptions? + ) -> GRPCAsyncBidirectionalStreamingCall + func makeSubscribeAllCall( _ request: Xmtp_MessageApi_V1_SubscribeAllRequest, callOptions: CallOptions? @@ -289,6 +321,16 @@ extension Xmtp_MessageApi_V1_MessageApiAsyncClientProtocol { ) } + public func makeSubscribe2Call( + callOptions: CallOptions? = nil + ) -> GRPCAsyncBidirectionalStreamingCall { + return self.makeAsyncBidirectionalStreamingCall( + path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [] + ) + } + public func makeSubscribeAllCall( _ request: Xmtp_MessageApi_V1_SubscribeAllRequest, callOptions: CallOptions? = nil @@ -352,6 +394,30 @@ extension Xmtp_MessageApi_V1_MessageApiAsyncClientProtocol { ) } + public func subscribe2( + _ requests: RequestStream, + callOptions: CallOptions? = nil + ) -> GRPCAsyncResponseStream where RequestStream: Sequence, RequestStream.Element == Xmtp_MessageApi_V1_SubscribeRequest { + return self.performAsyncBidirectionalStreamingCall( + path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path, + requests: requests, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [] + ) + } + + public func subscribe2( + _ requests: RequestStream, + callOptions: CallOptions? = nil + ) -> GRPCAsyncResponseStream where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Xmtp_MessageApi_V1_SubscribeRequest { + return self.performAsyncBidirectionalStreamingCall( + path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path, + requests: requests, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [] + ) + } + public func subscribeAll( _ request: Xmtp_MessageApi_V1_SubscribeAllRequest, callOptions: CallOptions? = nil @@ -416,6 +482,9 @@ public protocol Xmtp_MessageApi_V1_MessageApiClientInterceptorFactoryProtocol: G /// - Returns: Interceptors to use when invoking 'subscribe'. func makeSubscribeInterceptors() -> [ClientInterceptor] + /// - Returns: Interceptors to use when invoking 'subscribe2'. + func makeSubscribe2Interceptors() -> [ClientInterceptor] + /// - Returns: Interceptors to use when invoking 'subscribeAll'. func makeSubscribeAllInterceptors() -> [ClientInterceptor] @@ -433,6 +502,7 @@ public enum Xmtp_MessageApi_V1_MessageApiClientMetadata { methods: [ Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.publish, Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe, + Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2, Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribeAll, Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.query, Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.batchQuery, @@ -452,6 +522,12 @@ public enum Xmtp_MessageApi_V1_MessageApiClientMetadata { type: GRPCCallType.serverStreaming ) + public static let subscribe2 = GRPCMethodDescriptor( + name: "Subscribe2", + path: "/xmtp.message_api.v1.MessageApi/Subscribe2", + type: GRPCCallType.bidirectionalStreaming + ) + public static let subscribeAll = GRPCMethodDescriptor( name: "SubscribeAll", path: "/xmtp.message_api.v1.MessageApi/SubscribeAll", @@ -484,6 +560,11 @@ public protocol Xmtp_MessageApi_V1_MessageApiProvider: CallHandlerProvider { /// Subscribe to a stream of new envelopes matching a predicate func subscribe(request: Xmtp_MessageApi_V1_SubscribeRequest, context: StreamingResponseCallContext) -> EventLoopFuture + /// Subscribe to a stream of new envelopes and your subscription using + /// bidirectional streaming + /// protolint:disable:next RPC_REQUEST_STANDARD_NAME + func subscribe2(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> + /// Subscribe to a stream of all messages func subscribeAll(request: Xmtp_MessageApi_V1_SubscribeAllRequest, context: StreamingResponseCallContext) -> EventLoopFuture @@ -524,6 +605,15 @@ extension Xmtp_MessageApi_V1_MessageApiProvider { userFunction: self.subscribe(request:context:) ) + case "Subscribe2": + return BidirectionalStreamingServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [], + observerFactory: self.subscribe2(context:) + ) + case "SubscribeAll": return ServerStreamingServerHandler( context: context, @@ -580,6 +670,15 @@ public protocol Xmtp_MessageApi_V1_MessageApiAsyncProvider: CallHandlerProvider context: GRPCAsyncServerCallContext ) async throws + /// Subscribe to a stream of new envelopes and your subscription using + /// bidirectional streaming + /// protolint:disable:next RPC_REQUEST_STANDARD_NAME + @Sendable func subscribe2( + requestStream: GRPCAsyncRequestStream, + responseStream: GRPCAsyncResponseStreamWriter, + context: GRPCAsyncServerCallContext + ) async throws + /// Subscribe to a stream of all messages @Sendable func subscribeAll( request: Xmtp_MessageApi_V1_SubscribeAllRequest, @@ -637,6 +736,15 @@ extension Xmtp_MessageApi_V1_MessageApiAsyncProvider { wrapping: self.subscribe(request:responseStream:context:) ) + case "Subscribe2": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [], + wrapping: self.subscribe2(requestStream:responseStream:context:) + ) + case "SubscribeAll": return GRPCAsyncServerHandler( context: context, @@ -682,6 +790,10 @@ public protocol Xmtp_MessageApi_V1_MessageApiServerInterceptorFactoryProtocol { /// Defaults to calling `self.makeInterceptors()`. func makeSubscribeInterceptors() -> [ServerInterceptor] + /// - Returns: Interceptors to use when handling 'subscribe2'. + /// Defaults to calling `self.makeInterceptors()`. + func makeSubscribe2Interceptors() -> [ServerInterceptor] + /// - Returns: Interceptors to use when handling 'subscribeAll'. /// Defaults to calling `self.makeInterceptors()`. func makeSubscribeAllInterceptors() -> [ServerInterceptor] @@ -702,6 +814,7 @@ public enum Xmtp_MessageApi_V1_MessageApiServerMetadata { methods: [ Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.publish, Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.subscribe, + Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.subscribe2, Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.subscribeAll, Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.query, Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.batchQuery, @@ -721,6 +834,12 @@ public enum Xmtp_MessageApi_V1_MessageApiServerMetadata { type: GRPCCallType.serverStreaming ) + public static let subscribe2 = GRPCMethodDescriptor( + name: "Subscribe2", + path: "/xmtp.message_api.v1.MessageApi/Subscribe2", + type: GRPCCallType.bidirectionalStreaming + ) + public static let subscribeAll = GRPCMethodDescriptor( name: "SubscribeAll", path: "/xmtp.message_api.v1.MessageApi/SubscribeAll", diff --git a/swift/message_api/v1/message_api.pb.swift b/swift/message_api/v1/message_api.pb.swift index 03ae0a3a..c3ac86e3 100644 --- a/swift/message_api/v1/message_api.pb.swift +++ b/swift/message_api/v1/message_api.pb.swift @@ -58,7 +58,7 @@ public enum Xmtp_MessageApi_V1_SortDirection: SwiftProtobuf.Enum { extension Xmtp_MessageApi_V1_SortDirection: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Xmtp_MessageApi_V1_SortDirection] = [ + public static let allCases: [Xmtp_MessageApi_V1_SortDirection] = [ .unspecified, .ascending, .descending, diff --git a/swift/message_contents/content.pb.swift b/swift/message_contents/content.pb.swift index cf73da0d..6f588dd0 100644 --- a/swift/message_contents/content.pb.swift +++ b/swift/message_contents/content.pb.swift @@ -56,7 +56,7 @@ public enum Xmtp_MessageContents_Compression: SwiftProtobuf.Enum { extension Xmtp_MessageContents_Compression: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Xmtp_MessageContents_Compression] = [ + public static let allCases: [Xmtp_MessageContents_Compression] = [ .deflate, .gzip, ] diff --git a/swift/message_contents/ecies.pb.swift b/swift/message_contents/ecies.pb.swift new file mode 100644 index 00000000..21f3b6f1 --- /dev/null +++ b/swift/message_contents/ecies.pb.swift @@ -0,0 +1,116 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_contents/ecies.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// ECIES is a wrapper for ECIES payloads + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// EciesMessage is a wrapper for ECIES encrypted payloads +public struct Xmtp_MessageContents_EciesMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var version: Xmtp_MessageContents_EciesMessage.OneOf_Version? = nil + + /// Expected to be an ECIES encrypted SignedPayload + public var v1: Data { + get { + if case .v1(let v)? = version {return v} + return Data() + } + set {version = .v1(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_Version: Equatable { + /// Expected to be an ECIES encrypted SignedPayload + case v1(Data) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_MessageContents_EciesMessage.OneOf_Version, rhs: Xmtp_MessageContents_EciesMessage.OneOf_Version) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.v1, .v1): return { + guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() } + return l == r + }() + } + } + #endif + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageContents_EciesMessage: @unchecked Sendable {} +extension Xmtp_MessageContents_EciesMessage.OneOf_Version: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_contents" + +extension Xmtp_MessageContents_EciesMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".EciesMessage" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "v1"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Data? + try decoder.decodeSingularBytesField(value: &v) + if let v = v { + if self.version != nil {try decoder.handleConflictingOneOf()} + self.version = .v1(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if case .v1(let v)? = self.version { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_EciesMessage, rhs: Xmtp_MessageContents_EciesMessage) -> Bool { + if lhs.version != rhs.version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/swift/message_contents/private_key.pb.swift b/swift/message_contents/private_key.pb.swift index 4e916b5e..2015222a 100644 --- a/swift/message_contents/private_key.pb.swift +++ b/swift/message_contents/private_key.pb.swift @@ -279,7 +279,7 @@ public struct Xmtp_MessageContents_EncryptedPrivateKeyBundleV1 { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// randomly generated pre-key + /// randomly generated pre-key public var walletPreKey: Data = Data() /// MUST contain encrypted PrivateKeyBundle diff --git a/swift/message_contents/private_preferences.pb.swift b/swift/message_contents/private_preferences.pb.swift new file mode 100644 index 00000000..0e969de9 --- /dev/null +++ b/swift/message_contents/private_preferences.pb.swift @@ -0,0 +1,252 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_contents/private_preferences.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Private Key Storage +/// +/// Following definitions are not used in the protocol, instead +/// they provide a way for encoding private keys for storage. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// PrivatePreferencesAction is a message used to update the client's +/// preference store. The only current actions are allow and block. +/// Other actions may be added later +public struct Xmtp_MessageContents_PrivatePreferencesAction { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var messageType: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType? = nil + + public var allow: Xmtp_MessageContents_PrivatePreferencesAction.Allow { + get { + if case .allow(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.Allow() + } + set {messageType = .allow(newValue)} + } + + public var block: Xmtp_MessageContents_PrivatePreferencesAction.Block { + get { + if case .block(let v)? = messageType {return v} + return Xmtp_MessageContents_PrivatePreferencesAction.Block() + } + set {messageType = .block(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_MessageType: Equatable { + case allow(Xmtp_MessageContents_PrivatePreferencesAction.Allow) + case block(Xmtp_MessageContents_PrivatePreferencesAction.Block) + + #if !swift(>=4.1) + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType, rhs: Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.allow, .allow): return { + guard case .allow(let l) = lhs, case .allow(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.block, .block): return { + guard case .block(let l) = lhs, case .block(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + /// Add the given wallet addresses to the allow list + public struct Allow { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddresses: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + /// Add the given wallet addresses to the block list + public struct Block { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var walletAddresses: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageContents_PrivatePreferencesAction: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.OneOf_MessageType: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: @unchecked Sendable {} +extension Xmtp_MessageContents_PrivatePreferencesAction.Block: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_contents" + +extension Xmtp_MessageContents_PrivatePreferencesAction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PrivatePreferencesAction" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "allow"), + 2: .same(proto: "block"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Xmtp_MessageContents_PrivatePreferencesAction.Allow? + var hadOneofValue = false + if let current = self.messageType { + hadOneofValue = true + if case .allow(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.messageType = .allow(v) + } + }() + case 2: try { + var v: Xmtp_MessageContents_PrivatePreferencesAction.Block? + var hadOneofValue = false + if let current = self.messageType { + hadOneofValue = true + if case .block(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.messageType = .block(v) + } + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + switch self.messageType { + case .allow?: try { + guard case .allow(let v)? = self.messageType else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + }() + case .block?: try { + guard case .block(let v)? = self.messageType else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction, rhs: Xmtp_MessageContents_PrivatePreferencesAction) -> Bool { + if lhs.messageType != rhs.messageType {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageContents_PrivatePreferencesAction.Allow: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".Allow" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_addresses"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.walletAddresses) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddresses.isEmpty { + try visitor.visitRepeatedStringField(value: self.walletAddresses, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.Allow, rhs: Xmtp_MessageContents_PrivatePreferencesAction.Allow) -> Bool { + if lhs.walletAddresses != rhs.walletAddresses {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Xmtp_MessageContents_PrivatePreferencesAction.Block: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Xmtp_MessageContents_PrivatePreferencesAction.protoMessageName + ".Block" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "wallet_addresses"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.walletAddresses) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.walletAddresses.isEmpty { + try visitor.visitRepeatedStringField(value: self.walletAddresses, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_PrivatePreferencesAction.Block, rhs: Xmtp_MessageContents_PrivatePreferencesAction.Block) -> Bool { + if lhs.walletAddresses != rhs.walletAddresses {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/swift/message_contents/public_key.pb.swift b/swift/message_contents/public_key.pb.swift index a1accdaf..534e9075 100644 --- a/swift/message_contents/public_key.pb.swift +++ b/swift/message_contents/public_key.pb.swift @@ -79,7 +79,7 @@ public struct Xmtp_MessageContents_UnsignedPublicKey { public init() {} } -/// SignedPublicKey +/// SignedPublicKey public struct Xmtp_MessageContents_SignedPublicKey { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for diff --git a/swift/message_contents/signed_payload.pb.swift b/swift/message_contents/signed_payload.pb.swift new file mode 100644 index 00000000..3d8550cf --- /dev/null +++ b/swift/message_contents/signed_payload.pb.swift @@ -0,0 +1,97 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: message_contents/signed_payload.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +/// Signature is a generic structure for signed byte arrays + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// SignedPayload is a wrapper for a signature and a payload +public struct Xmtp_MessageContents_SignedPayload { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var payload: Data = Data() + + public var signature: Xmtp_MessageContents_Signature { + get {return _signature ?? Xmtp_MessageContents_Signature()} + set {_signature = newValue} + } + /// Returns true if `signature` has been explicitly set. + public var hasSignature: Bool {return self._signature != nil} + /// Clears the value of `signature`. Subsequent reads from it will return its default value. + public mutating func clearSignature() {self._signature = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _signature: Xmtp_MessageContents_Signature? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Xmtp_MessageContents_SignedPayload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "xmtp.message_contents" + +extension Xmtp_MessageContents_SignedPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SignedPayload" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "payload"), + 2: .same(proto: "signature"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.payload) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._signature) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.payload.isEmpty { + try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 1) + } + try { if let v = self._signature { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Xmtp_MessageContents_SignedPayload, rhs: Xmtp_MessageContents_SignedPayload) -> Bool { + if lhs.payload != rhs.payload {return false} + if lhs._signature != rhs._signature {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +}