Update protos & create ConfigurationMessage
This commit is contained in:
parent
28e3705f7e
commit
8ae5db3141
|
@ -793,6 +793,7 @@
|
|||
C3D9E4FD256778E30040E4F3 /* NSData+Image.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDB29255A580A00E217F9 /* NSData+Image.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C3D9E50E25677A510040E4F3 /* DataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDB54255A580D00E217F9 /* DataSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C3D9E52725677DF20040E4F3 /* OWSThumbnailService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDAF1255A580500E217F9 /* OWSThumbnailService.swift */; };
|
||||
C3DA9C0725AE7396008F7C7E /* ConfigurationMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DA9C0625AE7396008F7C7E /* ConfigurationMessage.swift */; };
|
||||
C3DAB3242480CB2B00725F25 /* SRCopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */; };
|
||||
C3DFFAC623E96F0D0058DAF8 /* Sheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */; };
|
||||
C3E5C2FA251DBABB0040DFFC /* EditClosedGroupVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E5C2F9251DBABB0040DFFC /* EditClosedGroupVC.swift */; };
|
||||
|
@ -1794,6 +1795,7 @@
|
|||
C3D9E40B25676C100040E4F3 /* Storage+Conformances.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Storage+Conformances.swift"; sourceTree = "<group>"; };
|
||||
C3D9E41E25676C870040E4F3 /* OWSPrimaryStorageProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWSPrimaryStorageProtocol.swift; sourceTree = "<group>"; };
|
||||
C3D9E43025676D3D0040E4F3 /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
|
||||
C3DA9C0625AE7396008F7C7E /* ConfigurationMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationMessage.swift; sourceTree = "<group>"; };
|
||||
C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SRCopyableLabel.swift; sourceTree = "<group>"; };
|
||||
C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sheet.swift; sourceTree = "<group>"; };
|
||||
C3E5C2F9251DBABB0040DFFC /* EditClosedGroupVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditClosedGroupVC.swift; sourceTree = "<group>"; };
|
||||
|
@ -2364,6 +2366,7 @@
|
|||
C300A5D22554B05A00555489 /* TypingIndicator.swift */,
|
||||
C34A977325A3E34A00852C71 /* ClosedGroupUpdateV2.swift */,
|
||||
C300A5E62554B07300555489 /* ExpirationTimerUpdate.swift */,
|
||||
C3DA9C0625AE7396008F7C7E /* ConfigurationMessage.swift */,
|
||||
);
|
||||
path = "Control Messages";
|
||||
sourceTree = "<group>";
|
||||
|
@ -4904,6 +4907,7 @@
|
|||
B8AE760B25ABFB5A001A84D2 /* GeneralUtilities.m in Sources */,
|
||||
C32C5C4F256DCC36003C73A2 /* Storage+OpenGroups.swift in Sources */,
|
||||
B8B3207B258C22550020074B /* DisplayNameUtilities.swift in Sources */,
|
||||
C3DA9C0725AE7396008F7C7E /* ConfigurationMessage.swift in Sources */,
|
||||
B8856CEE256F1054001CE70E /* OWSAudioPlayer.m in Sources */,
|
||||
C32C5EDC256DF501003C73A2 /* YapDatabaseConnection+OWS.m in Sources */,
|
||||
C3BBE0762554CDA60050F1E3 /* Configuration.swift in Sources */,
|
||||
|
|
|
@ -168,7 +168,7 @@ public final class ClosedGroupUpdateV2 : ControlMessage {
|
|||
closedGroupUpdate = SNProtoDataMessageClosedGroupUpdateV2.builder(type: .new)
|
||||
closedGroupUpdate.setPublicKey(publicKey)
|
||||
closedGroupUpdate.setName(name)
|
||||
let encryptionKeyPairAsProto = SNProtoDataMessageClosedGroupUpdateV2KeyPair.builder(publicKey: encryptionKeyPair.publicKey, privateKey: encryptionKeyPair.privateKey)
|
||||
let encryptionKeyPairAsProto = SNProtoKeyPair.builder(publicKey: encryptionKeyPair.publicKey, privateKey: encryptionKeyPair.privateKey)
|
||||
do {
|
||||
closedGroupUpdate.setEncryptionKeyPair(try encryptionKeyPairAsProto.build())
|
||||
} catch {
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
import SessionUtilitiesKit
|
||||
|
||||
@objc(SNConfigurationMessage)
|
||||
public final class ConfigurationMessage : ControlMessage {
|
||||
public var closedGroups: Set<ClosedGroup> = []
|
||||
public var openGroups: Set<String> = []
|
||||
|
||||
// MARK: Initialization
|
||||
public override init() { super.init() }
|
||||
|
||||
internal init(closedGroups: Set<ClosedGroup>, openGroups: Set<String>) {
|
||||
super.init()
|
||||
self.closedGroups = closedGroups
|
||||
self.openGroups = openGroups
|
||||
}
|
||||
|
||||
// MARK: Coding
|
||||
public required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
if let closedGroups = coder.decodeObject(forKey: "closedGroups") as! Set<ClosedGroup>? { self.closedGroups = closedGroups }
|
||||
if let openGroups = coder.decodeObject(forKey: "openGroups") as! Set<String>? { self.openGroups = openGroups }
|
||||
}
|
||||
|
||||
public override func encode(with coder: NSCoder) {
|
||||
super.encode(with: coder)
|
||||
coder.encode(closedGroups, forKey: "closedGroups")
|
||||
coder.encode(openGroups, forKey: "openGroups")
|
||||
}
|
||||
|
||||
// MARK: Proto Conversion
|
||||
public override class func fromProto(_ proto: SNProtoContent) -> ConfigurationMessage? {
|
||||
guard let configurationProto = proto.configurationMessage else { return nil }
|
||||
let closedGroups = Set(configurationProto.closedGroups.compactMap { ClosedGroup.fromProto($0) })
|
||||
let openGroups = Set(configurationProto.openGroups)
|
||||
return ConfigurationMessage(closedGroups: closedGroups, openGroups: openGroups)
|
||||
}
|
||||
|
||||
public override func toProto(using transaction: YapDatabaseReadWriteTransaction) -> SNProtoContent? {
|
||||
let configurationProto = SNProtoConfigurationMessage.builder()
|
||||
configurationProto.setClosedGroups(closedGroups.compactMap { $0.toProto() })
|
||||
configurationProto.setOpenGroups([String](openGroups))
|
||||
let contentProto = SNProtoContent.builder()
|
||||
do {
|
||||
contentProto.setConfigurationMessage(try configurationProto.build())
|
||||
return try contentProto.build()
|
||||
} catch {
|
||||
SNLog("Couldn't construct configuration proto from: \(self).")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Description
|
||||
public override var description: String {
|
||||
"""
|
||||
ConfigurationMessage(
|
||||
closedGroups: \([ClosedGroup](closedGroups).prettifiedDescription)
|
||||
openGroups: \([String](openGroups).prettifiedDescription)
|
||||
)
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Closed Group
|
||||
extension ConfigurationMessage {
|
||||
|
||||
@objc(SNClosedGroup)
|
||||
public final class ClosedGroup : NSObject, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
||||
public let publicKey: String
|
||||
public let name: String
|
||||
public let encryptionKeyPair: ECKeyPair
|
||||
public let members: Set<String>
|
||||
public let admins: Set<String>
|
||||
|
||||
public var isValid: Bool { !members.isEmpty && !admins.isEmpty }
|
||||
|
||||
public init(publicKey: String, name: String, encryptionKeyPair: ECKeyPair, members: Set<String>, admins: Set<String>) {
|
||||
self.publicKey = publicKey
|
||||
self.name = name
|
||||
self.encryptionKeyPair = encryptionKeyPair
|
||||
self.members = members
|
||||
self.admins = admins
|
||||
}
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
guard let publicKey = coder.decodeObject(forKey: "publicKey") as! String?,
|
||||
let name = coder.decodeObject(forKey: "name") as! String?,
|
||||
let encryptionKeyPair = coder.decodeObject(forKey: "encryptionKeyPair") as! ECKeyPair?,
|
||||
let members = coder.decodeObject(forKey: "members") as! Set<String>?,
|
||||
let admins = coder.decodeObject(forKey: "admins") as! Set<String>? else { return nil }
|
||||
self.publicKey = publicKey
|
||||
self.name = name
|
||||
self.encryptionKeyPair = encryptionKeyPair
|
||||
self.members = members
|
||||
self.admins = admins
|
||||
}
|
||||
|
||||
public func encode(with coder: NSCoder) {
|
||||
coder.encode(publicKey, forKey: "publicKey")
|
||||
coder.encode(name, forKey: "name")
|
||||
coder.encode(encryptionKeyPair, forKey: "encryptionKeyPair")
|
||||
coder.encode(members, forKey: "members")
|
||||
coder.encode(admins, forKey: "admins")
|
||||
}
|
||||
|
||||
public static func fromProto(_ proto: SNProtoConfigurationMessageClosedGroup) -> ClosedGroup? {
|
||||
guard let publicKey = proto.publicKey?.toHexString(),
|
||||
let name = proto.name,
|
||||
let encryptionKeyPairAsProto = proto.encryptionKeyPair else { return nil }
|
||||
let encryptionKeyPair: ECKeyPair
|
||||
do {
|
||||
encryptionKeyPair = try ECKeyPair(publicKeyData: encryptionKeyPairAsProto.publicKey, privateKeyData: encryptionKeyPairAsProto.privateKey)
|
||||
} catch {
|
||||
SNLog("Couldn't construct closed group from proto: \(self).")
|
||||
return nil
|
||||
}
|
||||
let members = Set(proto.members.map { $0.toHexString() })
|
||||
let admins = Set(proto.admins.map { $0.toHexString() })
|
||||
return ClosedGroup(publicKey: publicKey, name: name, encryptionKeyPair: encryptionKeyPair, members: members, admins: admins)
|
||||
}
|
||||
|
||||
public func toProto() -> SNProtoConfigurationMessageClosedGroup? {
|
||||
let result = SNProtoConfigurationMessageClosedGroup.builder()
|
||||
result.setPublicKey(Data(hex: publicKey))
|
||||
result.setName(name)
|
||||
do {
|
||||
let encryptionKeyPairAsProto = try SNProtoKeyPair.builder(publicKey: encryptionKeyPair.publicKey, privateKey: encryptionKeyPair.privateKey).build()
|
||||
result.setEncryptionKeyPair(encryptionKeyPairAsProto)
|
||||
} catch {
|
||||
SNLog("Couldn't construct closed group proto from: \(self).")
|
||||
return nil
|
||||
}
|
||||
result.setMembers(members.map { Data(hex: $0) })
|
||||
result.setAdmins(admins.map { Data(hex: $0) })
|
||||
do {
|
||||
return try result.build()
|
||||
} catch {
|
||||
SNLog("Couldn't construct closed group proto from: \(self).")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public override var description: String { name }
|
||||
}
|
||||
}
|
|
@ -363,6 +363,9 @@ extension SNProtoTypingMessage.SNProtoTypingMessageBuilder {
|
|||
if let _value = typingMessage {
|
||||
builder.setTypingMessage(_value)
|
||||
}
|
||||
if let _value = configurationMessage {
|
||||
builder.setConfigurationMessage(_value)
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
|
@ -388,6 +391,10 @@ extension SNProtoTypingMessage.SNProtoTypingMessageBuilder {
|
|||
proto.typingMessage = valueParam.proto
|
||||
}
|
||||
|
||||
@objc public func setConfigurationMessage(_ valueParam: SNProtoConfigurationMessage) {
|
||||
proto.configurationMessage = valueParam.proto
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SNProtoContent {
|
||||
return try SNProtoContent.parseProto(proto)
|
||||
}
|
||||
|
@ -407,16 +414,20 @@ extension SNProtoTypingMessage.SNProtoTypingMessageBuilder {
|
|||
|
||||
@objc public let typingMessage: SNProtoTypingMessage?
|
||||
|
||||
@objc public let configurationMessage: SNProtoConfigurationMessage?
|
||||
|
||||
private init(proto: SessionProtos_Content,
|
||||
dataMessage: SNProtoDataMessage?,
|
||||
syncMessage: SNProtoSyncMessage?,
|
||||
receiptMessage: SNProtoReceiptMessage?,
|
||||
typingMessage: SNProtoTypingMessage?) {
|
||||
typingMessage: SNProtoTypingMessage?,
|
||||
configurationMessage: SNProtoConfigurationMessage?) {
|
||||
self.proto = proto
|
||||
self.dataMessage = dataMessage
|
||||
self.syncMessage = syncMessage
|
||||
self.receiptMessage = receiptMessage
|
||||
self.typingMessage = typingMessage
|
||||
self.configurationMessage = configurationMessage
|
||||
}
|
||||
|
||||
@objc
|
||||
|
@ -450,6 +461,11 @@ extension SNProtoTypingMessage.SNProtoTypingMessageBuilder {
|
|||
typingMessage = try SNProtoTypingMessage.parseProto(proto.typingMessage)
|
||||
}
|
||||
|
||||
var configurationMessage: SNProtoConfigurationMessage? = nil
|
||||
if proto.hasConfigurationMessage {
|
||||
configurationMessage = try SNProtoConfigurationMessage.parseProto(proto.configurationMessage)
|
||||
}
|
||||
|
||||
// MARK: - Begin Validation Logic for SNProtoContent -
|
||||
|
||||
// MARK: - End Validation Logic for SNProtoContent -
|
||||
|
@ -458,7 +474,8 @@ extension SNProtoTypingMessage.SNProtoTypingMessageBuilder {
|
|||
dataMessage: dataMessage,
|
||||
syncMessage: syncMessage,
|
||||
receiptMessage: receiptMessage,
|
||||
typingMessage: typingMessage)
|
||||
typingMessage: typingMessage,
|
||||
configurationMessage: configurationMessage)
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -595,6 +612,118 @@ extension SNProtoClosedGroupCiphertextMessageWrapper.SNProtoClosedGroupCiphertex
|
|||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoKeyPair
|
||||
|
||||
@objc public class SNProtoKeyPair: NSObject {
|
||||
|
||||
// MARK: - SNProtoKeyPairBuilder
|
||||
|
||||
@objc public class func builder(publicKey: Data, privateKey: Data) -> SNProtoKeyPairBuilder {
|
||||
return SNProtoKeyPairBuilder(publicKey: publicKey, privateKey: privateKey)
|
||||
}
|
||||
|
||||
// asBuilder() constructs a builder that reflects the proto's contents.
|
||||
@objc public func asBuilder() -> SNProtoKeyPairBuilder {
|
||||
let builder = SNProtoKeyPairBuilder(publicKey: publicKey, privateKey: privateKey)
|
||||
return builder
|
||||
}
|
||||
|
||||
@objc public class SNProtoKeyPairBuilder: NSObject {
|
||||
|
||||
private var proto = SessionProtos_KeyPair()
|
||||
|
||||
@objc fileprivate override init() {}
|
||||
|
||||
@objc fileprivate init(publicKey: Data, privateKey: Data) {
|
||||
super.init()
|
||||
|
||||
setPublicKey(publicKey)
|
||||
setPrivateKey(privateKey)
|
||||
}
|
||||
|
||||
@objc public func setPublicKey(_ valueParam: Data) {
|
||||
proto.publicKey = valueParam
|
||||
}
|
||||
|
||||
@objc public func setPrivateKey(_ valueParam: Data) {
|
||||
proto.privateKey = valueParam
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SNProtoKeyPair {
|
||||
return try SNProtoKeyPair.parseProto(proto)
|
||||
}
|
||||
|
||||
@objc public func buildSerializedData() throws -> Data {
|
||||
return try SNProtoKeyPair.parseProto(proto).serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: SessionProtos_KeyPair
|
||||
|
||||
@objc public let publicKey: Data
|
||||
|
||||
@objc public let privateKey: Data
|
||||
|
||||
private init(proto: SessionProtos_KeyPair,
|
||||
publicKey: Data,
|
||||
privateKey: Data) {
|
||||
self.proto = proto
|
||||
self.publicKey = publicKey
|
||||
self.privateKey = privateKey
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.serializedData()
|
||||
}
|
||||
|
||||
@objc public class func parseData(_ serializedData: Data) throws -> SNProtoKeyPair {
|
||||
let proto = try SessionProtos_KeyPair(serializedData: serializedData)
|
||||
return try parseProto(proto)
|
||||
}
|
||||
|
||||
fileprivate class func parseProto(_ proto: SessionProtos_KeyPair) throws -> SNProtoKeyPair {
|
||||
guard proto.hasPublicKey else {
|
||||
throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: publicKey")
|
||||
}
|
||||
let publicKey = proto.publicKey
|
||||
|
||||
guard proto.hasPrivateKey else {
|
||||
throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: privateKey")
|
||||
}
|
||||
let privateKey = proto.privateKey
|
||||
|
||||
// MARK: - Begin Validation Logic for SNProtoKeyPair -
|
||||
|
||||
// MARK: - End Validation Logic for SNProtoKeyPair -
|
||||
|
||||
let result = SNProtoKeyPair(proto: proto,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey)
|
||||
return result
|
||||
}
|
||||
|
||||
@objc public override var debugDescription: String {
|
||||
return "\(proto)"
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extension SNProtoKeyPair {
|
||||
@objc public func serializedDataIgnoringErrors() -> Data? {
|
||||
return try! self.serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
extension SNProtoKeyPair.SNProtoKeyPairBuilder {
|
||||
@objc public func buildIgnoringErrors() -> SNProtoKeyPair? {
|
||||
return try! self.build()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoDataMessageQuoteQuotedAttachment
|
||||
|
||||
@objc public class SNProtoDataMessageQuoteQuotedAttachment: NSObject {
|
||||
|
@ -2172,118 +2301,6 @@ extension SNProtoDataMessageLokiProfile.SNProtoDataMessageLokiProfileBuilder {
|
|||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoDataMessageClosedGroupUpdateV2KeyPair
|
||||
|
||||
@objc public class SNProtoDataMessageClosedGroupUpdateV2KeyPair: NSObject {
|
||||
|
||||
// MARK: - SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder
|
||||
|
||||
@objc public class func builder(publicKey: Data, privateKey: Data) -> SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder {
|
||||
return SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder(publicKey: publicKey, privateKey: privateKey)
|
||||
}
|
||||
|
||||
// asBuilder() constructs a builder that reflects the proto's contents.
|
||||
@objc public func asBuilder() -> SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder {
|
||||
let builder = SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder(publicKey: publicKey, privateKey: privateKey)
|
||||
return builder
|
||||
}
|
||||
|
||||
@objc public class SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder: NSObject {
|
||||
|
||||
private var proto = SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair()
|
||||
|
||||
@objc fileprivate override init() {}
|
||||
|
||||
@objc fileprivate init(publicKey: Data, privateKey: Data) {
|
||||
super.init()
|
||||
|
||||
setPublicKey(publicKey)
|
||||
setPrivateKey(privateKey)
|
||||
}
|
||||
|
||||
@objc public func setPublicKey(_ valueParam: Data) {
|
||||
proto.publicKey = valueParam
|
||||
}
|
||||
|
||||
@objc public func setPrivateKey(_ valueParam: Data) {
|
||||
proto.privateKey = valueParam
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SNProtoDataMessageClosedGroupUpdateV2KeyPair {
|
||||
return try SNProtoDataMessageClosedGroupUpdateV2KeyPair.parseProto(proto)
|
||||
}
|
||||
|
||||
@objc public func buildSerializedData() throws -> Data {
|
||||
return try SNProtoDataMessageClosedGroupUpdateV2KeyPair.parseProto(proto).serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair
|
||||
|
||||
@objc public let publicKey: Data
|
||||
|
||||
@objc public let privateKey: Data
|
||||
|
||||
private init(proto: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair,
|
||||
publicKey: Data,
|
||||
privateKey: Data) {
|
||||
self.proto = proto
|
||||
self.publicKey = publicKey
|
||||
self.privateKey = privateKey
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.serializedData()
|
||||
}
|
||||
|
||||
@objc public class func parseData(_ serializedData: Data) throws -> SNProtoDataMessageClosedGroupUpdateV2KeyPair {
|
||||
let proto = try SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair(serializedData: serializedData)
|
||||
return try parseProto(proto)
|
||||
}
|
||||
|
||||
fileprivate class func parseProto(_ proto: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair) throws -> SNProtoDataMessageClosedGroupUpdateV2KeyPair {
|
||||
guard proto.hasPublicKey else {
|
||||
throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: publicKey")
|
||||
}
|
||||
let publicKey = proto.publicKey
|
||||
|
||||
guard proto.hasPrivateKey else {
|
||||
throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: privateKey")
|
||||
}
|
||||
let privateKey = proto.privateKey
|
||||
|
||||
// MARK: - Begin Validation Logic for SNProtoDataMessageClosedGroupUpdateV2KeyPair -
|
||||
|
||||
// MARK: - End Validation Logic for SNProtoDataMessageClosedGroupUpdateV2KeyPair -
|
||||
|
||||
let result = SNProtoDataMessageClosedGroupUpdateV2KeyPair(proto: proto,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey)
|
||||
return result
|
||||
}
|
||||
|
||||
@objc public override var debugDescription: String {
|
||||
return "\(proto)"
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extension SNProtoDataMessageClosedGroupUpdateV2KeyPair {
|
||||
@objc public func serializedDataIgnoringErrors() -> Data? {
|
||||
return try! self.serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
extension SNProtoDataMessageClosedGroupUpdateV2KeyPair.SNProtoDataMessageClosedGroupUpdateV2KeyPairBuilder {
|
||||
@objc public func buildIgnoringErrors() -> SNProtoDataMessageClosedGroupUpdateV2KeyPair? {
|
||||
return try! self.build()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper
|
||||
|
||||
@objc public class SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper: NSObject {
|
||||
|
@ -2472,7 +2489,7 @@ extension SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper.SNProtoDataMessage
|
|||
proto.name = valueParam
|
||||
}
|
||||
|
||||
@objc public func setEncryptionKeyPair(_ valueParam: SNProtoDataMessageClosedGroupUpdateV2KeyPair) {
|
||||
@objc public func setEncryptionKeyPair(_ valueParam: SNProtoKeyPair) {
|
||||
proto.encryptionKeyPair = valueParam.proto
|
||||
}
|
||||
|
||||
|
@ -2519,7 +2536,7 @@ extension SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper.SNProtoDataMessage
|
|||
|
||||
@objc public let type: SNProtoDataMessageClosedGroupUpdateV2Type
|
||||
|
||||
@objc public let encryptionKeyPair: SNProtoDataMessageClosedGroupUpdateV2KeyPair?
|
||||
@objc public let encryptionKeyPair: SNProtoKeyPair?
|
||||
|
||||
@objc public let wrappers: [SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper]
|
||||
|
||||
|
@ -2553,7 +2570,7 @@ extension SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper.SNProtoDataMessage
|
|||
|
||||
private init(proto: SessionProtos_DataMessage.ClosedGroupUpdateV2,
|
||||
type: SNProtoDataMessageClosedGroupUpdateV2Type,
|
||||
encryptionKeyPair: SNProtoDataMessageClosedGroupUpdateV2KeyPair?,
|
||||
encryptionKeyPair: SNProtoKeyPair?,
|
||||
wrappers: [SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper]) {
|
||||
self.proto = proto
|
||||
self.type = type
|
||||
|
@ -2577,9 +2594,9 @@ extension SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper.SNProtoDataMessage
|
|||
}
|
||||
let type = SNProtoDataMessageClosedGroupUpdateV2TypeWrap(proto.type)
|
||||
|
||||
var encryptionKeyPair: SNProtoDataMessageClosedGroupUpdateV2KeyPair? = nil
|
||||
var encryptionKeyPair: SNProtoKeyPair? = nil
|
||||
if proto.hasEncryptionKeyPair {
|
||||
encryptionKeyPair = try SNProtoDataMessageClosedGroupUpdateV2KeyPair.parseProto(proto.encryptionKeyPair)
|
||||
encryptionKeyPair = try SNProtoKeyPair.parseProto(proto.encryptionKeyPair)
|
||||
}
|
||||
|
||||
var wrappers: [SNProtoDataMessageClosedGroupUpdateV2KeyPairWrapper] = []
|
||||
|
@ -2930,6 +2947,275 @@ extension SNProtoDataMessage.SNProtoDataMessageBuilder {
|
|||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoConfigurationMessageClosedGroup
|
||||
|
||||
@objc public class SNProtoConfigurationMessageClosedGroup: NSObject {
|
||||
|
||||
// MARK: - SNProtoConfigurationMessageClosedGroupBuilder
|
||||
|
||||
@objc public class func builder() -> SNProtoConfigurationMessageClosedGroupBuilder {
|
||||
return SNProtoConfigurationMessageClosedGroupBuilder()
|
||||
}
|
||||
|
||||
// asBuilder() constructs a builder that reflects the proto's contents.
|
||||
@objc public func asBuilder() -> SNProtoConfigurationMessageClosedGroupBuilder {
|
||||
let builder = SNProtoConfigurationMessageClosedGroupBuilder()
|
||||
if let _value = publicKey {
|
||||
builder.setPublicKey(_value)
|
||||
}
|
||||
if let _value = name {
|
||||
builder.setName(_value)
|
||||
}
|
||||
if let _value = encryptionKeyPair {
|
||||
builder.setEncryptionKeyPair(_value)
|
||||
}
|
||||
builder.setMembers(members)
|
||||
builder.setAdmins(admins)
|
||||
return builder
|
||||
}
|
||||
|
||||
@objc public class SNProtoConfigurationMessageClosedGroupBuilder: NSObject {
|
||||
|
||||
private var proto = SessionProtos_ConfigurationMessage.ClosedGroup()
|
||||
|
||||
@objc fileprivate override init() {}
|
||||
|
||||
@objc public func setPublicKey(_ valueParam: Data) {
|
||||
proto.publicKey = valueParam
|
||||
}
|
||||
|
||||
@objc public func setName(_ valueParam: String) {
|
||||
proto.name = valueParam
|
||||
}
|
||||
|
||||
@objc public func setEncryptionKeyPair(_ valueParam: SNProtoKeyPair) {
|
||||
proto.encryptionKeyPair = valueParam.proto
|
||||
}
|
||||
|
||||
@objc public func addMembers(_ valueParam: Data) {
|
||||
var items = proto.members
|
||||
items.append(valueParam)
|
||||
proto.members = items
|
||||
}
|
||||
|
||||
@objc public func setMembers(_ wrappedItems: [Data]) {
|
||||
proto.members = wrappedItems
|
||||
}
|
||||
|
||||
@objc public func addAdmins(_ valueParam: Data) {
|
||||
var items = proto.admins
|
||||
items.append(valueParam)
|
||||
proto.admins = items
|
||||
}
|
||||
|
||||
@objc public func setAdmins(_ wrappedItems: [Data]) {
|
||||
proto.admins = wrappedItems
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SNProtoConfigurationMessageClosedGroup {
|
||||
return try SNProtoConfigurationMessageClosedGroup.parseProto(proto)
|
||||
}
|
||||
|
||||
@objc public func buildSerializedData() throws -> Data {
|
||||
return try SNProtoConfigurationMessageClosedGroup.parseProto(proto).serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: SessionProtos_ConfigurationMessage.ClosedGroup
|
||||
|
||||
@objc public let encryptionKeyPair: SNProtoKeyPair?
|
||||
|
||||
@objc public var publicKey: Data? {
|
||||
guard proto.hasPublicKey else {
|
||||
return nil
|
||||
}
|
||||
return proto.publicKey
|
||||
}
|
||||
@objc public var hasPublicKey: Bool {
|
||||
return proto.hasPublicKey
|
||||
}
|
||||
|
||||
@objc public var name: String? {
|
||||
guard proto.hasName else {
|
||||
return nil
|
||||
}
|
||||
return proto.name
|
||||
}
|
||||
@objc public var hasName: Bool {
|
||||
return proto.hasName
|
||||
}
|
||||
|
||||
@objc public var members: [Data] {
|
||||
return proto.members
|
||||
}
|
||||
|
||||
@objc public var admins: [Data] {
|
||||
return proto.admins
|
||||
}
|
||||
|
||||
private init(proto: SessionProtos_ConfigurationMessage.ClosedGroup,
|
||||
encryptionKeyPair: SNProtoKeyPair?) {
|
||||
self.proto = proto
|
||||
self.encryptionKeyPair = encryptionKeyPair
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.serializedData()
|
||||
}
|
||||
|
||||
@objc public class func parseData(_ serializedData: Data) throws -> SNProtoConfigurationMessageClosedGroup {
|
||||
let proto = try SessionProtos_ConfigurationMessage.ClosedGroup(serializedData: serializedData)
|
||||
return try parseProto(proto)
|
||||
}
|
||||
|
||||
fileprivate class func parseProto(_ proto: SessionProtos_ConfigurationMessage.ClosedGroup) throws -> SNProtoConfigurationMessageClosedGroup {
|
||||
var encryptionKeyPair: SNProtoKeyPair? = nil
|
||||
if proto.hasEncryptionKeyPair {
|
||||
encryptionKeyPair = try SNProtoKeyPair.parseProto(proto.encryptionKeyPair)
|
||||
}
|
||||
|
||||
// MARK: - Begin Validation Logic for SNProtoConfigurationMessageClosedGroup -
|
||||
|
||||
// MARK: - End Validation Logic for SNProtoConfigurationMessageClosedGroup -
|
||||
|
||||
let result = SNProtoConfigurationMessageClosedGroup(proto: proto,
|
||||
encryptionKeyPair: encryptionKeyPair)
|
||||
return result
|
||||
}
|
||||
|
||||
@objc public override var debugDescription: String {
|
||||
return "\(proto)"
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extension SNProtoConfigurationMessageClosedGroup {
|
||||
@objc public func serializedDataIgnoringErrors() -> Data? {
|
||||
return try! self.serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
extension SNProtoConfigurationMessageClosedGroup.SNProtoConfigurationMessageClosedGroupBuilder {
|
||||
@objc public func buildIgnoringErrors() -> SNProtoConfigurationMessageClosedGroup? {
|
||||
return try! self.build()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoConfigurationMessage
|
||||
|
||||
@objc public class SNProtoConfigurationMessage: NSObject {
|
||||
|
||||
// MARK: - SNProtoConfigurationMessageBuilder
|
||||
|
||||
@objc public class func builder() -> SNProtoConfigurationMessageBuilder {
|
||||
return SNProtoConfigurationMessageBuilder()
|
||||
}
|
||||
|
||||
// asBuilder() constructs a builder that reflects the proto's contents.
|
||||
@objc public func asBuilder() -> SNProtoConfigurationMessageBuilder {
|
||||
let builder = SNProtoConfigurationMessageBuilder()
|
||||
builder.setClosedGroups(closedGroups)
|
||||
builder.setOpenGroups(openGroups)
|
||||
return builder
|
||||
}
|
||||
|
||||
@objc public class SNProtoConfigurationMessageBuilder: NSObject {
|
||||
|
||||
private var proto = SessionProtos_ConfigurationMessage()
|
||||
|
||||
@objc fileprivate override init() {}
|
||||
|
||||
@objc public func addClosedGroups(_ valueParam: SNProtoConfigurationMessageClosedGroup) {
|
||||
var items = proto.closedGroups
|
||||
items.append(valueParam.proto)
|
||||
proto.closedGroups = items
|
||||
}
|
||||
|
||||
@objc public func setClosedGroups(_ wrappedItems: [SNProtoConfigurationMessageClosedGroup]) {
|
||||
proto.closedGroups = wrappedItems.map { $0.proto }
|
||||
}
|
||||
|
||||
@objc public func addOpenGroups(_ valueParam: String) {
|
||||
var items = proto.openGroups
|
||||
items.append(valueParam)
|
||||
proto.openGroups = items
|
||||
}
|
||||
|
||||
@objc public func setOpenGroups(_ wrappedItems: [String]) {
|
||||
proto.openGroups = wrappedItems
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SNProtoConfigurationMessage {
|
||||
return try SNProtoConfigurationMessage.parseProto(proto)
|
||||
}
|
||||
|
||||
@objc public func buildSerializedData() throws -> Data {
|
||||
return try SNProtoConfigurationMessage.parseProto(proto).serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: SessionProtos_ConfigurationMessage
|
||||
|
||||
@objc public let closedGroups: [SNProtoConfigurationMessageClosedGroup]
|
||||
|
||||
@objc public var openGroups: [String] {
|
||||
return proto.openGroups
|
||||
}
|
||||
|
||||
private init(proto: SessionProtos_ConfigurationMessage,
|
||||
closedGroups: [SNProtoConfigurationMessageClosedGroup]) {
|
||||
self.proto = proto
|
||||
self.closedGroups = closedGroups
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.serializedData()
|
||||
}
|
||||
|
||||
@objc public class func parseData(_ serializedData: Data) throws -> SNProtoConfigurationMessage {
|
||||
let proto = try SessionProtos_ConfigurationMessage(serializedData: serializedData)
|
||||
return try parseProto(proto)
|
||||
}
|
||||
|
||||
fileprivate class func parseProto(_ proto: SessionProtos_ConfigurationMessage) throws -> SNProtoConfigurationMessage {
|
||||
var closedGroups: [SNProtoConfigurationMessageClosedGroup] = []
|
||||
closedGroups = try proto.closedGroups.map { try SNProtoConfigurationMessageClosedGroup.parseProto($0) }
|
||||
|
||||
// MARK: - Begin Validation Logic for SNProtoConfigurationMessage -
|
||||
|
||||
// MARK: - End Validation Logic for SNProtoConfigurationMessage -
|
||||
|
||||
let result = SNProtoConfigurationMessage(proto: proto,
|
||||
closedGroups: closedGroups)
|
||||
return result
|
||||
}
|
||||
|
||||
@objc public override var debugDescription: String {
|
||||
return "\(proto)"
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extension SNProtoConfigurationMessage {
|
||||
@objc public func serializedDataIgnoringErrors() -> Data? {
|
||||
return try! self.serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
extension SNProtoConfigurationMessage.SNProtoConfigurationMessageBuilder {
|
||||
@objc public func buildIgnoringErrors() -> SNProtoConfigurationMessage? {
|
||||
return try! self.build()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// MARK: - SNProtoReceiptMessage
|
||||
|
||||
@objc public class SNProtoReceiptMessage: NSObject {
|
||||
|
|
|
@ -237,6 +237,15 @@ struct SessionProtos_Content {
|
|||
/// Clears the value of `typingMessage`. Subsequent reads from it will return its default value.
|
||||
mutating func clearTypingMessage() {self._typingMessage = nil}
|
||||
|
||||
var configurationMessage: SessionProtos_ConfigurationMessage {
|
||||
get {return _configurationMessage ?? SessionProtos_ConfigurationMessage()}
|
||||
set {_configurationMessage = newValue}
|
||||
}
|
||||
/// Returns true if `configurationMessage` has been explicitly set.
|
||||
var hasConfigurationMessage: Bool {return self._configurationMessage != nil}
|
||||
/// Clears the value of `configurationMessage`. Subsequent reads from it will return its default value.
|
||||
mutating func clearConfigurationMessage() {self._configurationMessage = nil}
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
|
@ -245,6 +254,7 @@ struct SessionProtos_Content {
|
|||
fileprivate var _syncMessage: SessionProtos_SyncMessage? = nil
|
||||
fileprivate var _receiptMessage: SessionProtos_ReceiptMessage? = nil
|
||||
fileprivate var _typingMessage: SessionProtos_TypingMessage? = nil
|
||||
fileprivate var _configurationMessage: SessionProtos_ConfigurationMessage? = nil
|
||||
}
|
||||
|
||||
struct SessionProtos_ClosedGroupCiphertextMessageWrapper {
|
||||
|
@ -280,6 +290,39 @@ struct SessionProtos_ClosedGroupCiphertextMessageWrapper {
|
|||
fileprivate var _ephemeralPublicKey: Data? = nil
|
||||
}
|
||||
|
||||
struct SessionProtos_KeyPair {
|
||||
// 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.
|
||||
|
||||
/// @required
|
||||
var publicKey: Data {
|
||||
get {return _publicKey ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_publicKey = newValue}
|
||||
}
|
||||
/// Returns true if `publicKey` has been explicitly set.
|
||||
var hasPublicKey: Bool {return self._publicKey != nil}
|
||||
/// Clears the value of `publicKey`. Subsequent reads from it will return its default value.
|
||||
mutating func clearPublicKey() {self._publicKey = nil}
|
||||
|
||||
/// @required
|
||||
var privateKey: Data {
|
||||
get {return _privateKey ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_privateKey = newValue}
|
||||
}
|
||||
/// Returns true if `privateKey` has been explicitly set.
|
||||
var hasPrivateKey: Bool {return self._privateKey != nil}
|
||||
/// Clears the value of `privateKey`. Subsequent reads from it will return its default value.
|
||||
mutating func clearPrivateKey() {self._privateKey = nil}
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
|
||||
fileprivate var _publicKey: Data? = nil
|
||||
fileprivate var _privateKey: Data? = nil
|
||||
}
|
||||
|
||||
struct SessionProtos_DataMessage {
|
||||
// SwiftProtobuf.Message conformance is added in an extension below. See the
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
|
@ -1056,8 +1099,8 @@ struct SessionProtos_DataMessage {
|
|||
/// Clears the value of `name`. Subsequent reads from it will return its default value.
|
||||
mutating func clearName() {self._name = nil}
|
||||
|
||||
var encryptionKeyPair: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair {
|
||||
get {return _encryptionKeyPair ?? SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair()}
|
||||
var encryptionKeyPair: SessionProtos_KeyPair {
|
||||
get {return _encryptionKeyPair ?? SessionProtos_KeyPair()}
|
||||
set {_encryptionKeyPair = newValue}
|
||||
}
|
||||
/// Returns true if `encryptionKeyPair` has been explicitly set.
|
||||
|
@ -1108,39 +1151,6 @@ struct SessionProtos_DataMessage {
|
|||
|
||||
}
|
||||
|
||||
struct KeyPair {
|
||||
// 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.
|
||||
|
||||
/// @required
|
||||
var publicKey: Data {
|
||||
get {return _publicKey ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_publicKey = newValue}
|
||||
}
|
||||
/// Returns true if `publicKey` has been explicitly set.
|
||||
var hasPublicKey: Bool {return self._publicKey != nil}
|
||||
/// Clears the value of `publicKey`. Subsequent reads from it will return its default value.
|
||||
mutating func clearPublicKey() {self._publicKey = nil}
|
||||
|
||||
/// @required
|
||||
var privateKey: Data {
|
||||
get {return _privateKey ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_privateKey = newValue}
|
||||
}
|
||||
/// Returns true if `privateKey` has been explicitly set.
|
||||
var hasPrivateKey: Bool {return self._privateKey != nil}
|
||||
/// Clears the value of `privateKey`. Subsequent reads from it will return its default value.
|
||||
mutating func clearPrivateKey() {self._privateKey = nil}
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
|
||||
fileprivate var _publicKey: Data? = nil
|
||||
fileprivate var _privateKey: Data? = nil
|
||||
}
|
||||
|
||||
struct KeyPairWrapper {
|
||||
// SwiftProtobuf.Message conformance is added in an extension below. See the
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
|
@ -1179,7 +1189,7 @@ struct SessionProtos_DataMessage {
|
|||
fileprivate var _type: SessionProtos_DataMessage.ClosedGroupUpdateV2.TypeEnum? = nil
|
||||
fileprivate var _publicKey: Data? = nil
|
||||
fileprivate var _name: String? = nil
|
||||
fileprivate var _encryptionKeyPair: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair? = nil
|
||||
fileprivate var _encryptionKeyPair: SessionProtos_KeyPair? = nil
|
||||
}
|
||||
|
||||
init() {}
|
||||
|
@ -1224,6 +1234,65 @@ extension SessionProtos_DataMessage.ClosedGroupUpdateV2.TypeEnum: CaseIterable {
|
|||
|
||||
#endif // swift(>=4.2)
|
||||
|
||||
struct SessionProtos_ConfigurationMessage {
|
||||
// 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.
|
||||
|
||||
var closedGroups: [SessionProtos_ConfigurationMessage.ClosedGroup] = []
|
||||
|
||||
var openGroups: [String] = []
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
struct ClosedGroup {
|
||||
// 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.
|
||||
|
||||
var publicKey: Data {
|
||||
get {return _publicKey ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_publicKey = newValue}
|
||||
}
|
||||
/// Returns true if `publicKey` has been explicitly set.
|
||||
var hasPublicKey: Bool {return self._publicKey != nil}
|
||||
/// Clears the value of `publicKey`. Subsequent reads from it will return its default value.
|
||||
mutating func clearPublicKey() {self._publicKey = nil}
|
||||
|
||||
var name: String {
|
||||
get {return _name ?? String()}
|
||||
set {_name = newValue}
|
||||
}
|
||||
/// Returns true if `name` has been explicitly set.
|
||||
var hasName: Bool {return self._name != nil}
|
||||
/// Clears the value of `name`. Subsequent reads from it will return its default value.
|
||||
mutating func clearName() {self._name = nil}
|
||||
|
||||
var encryptionKeyPair: SessionProtos_KeyPair {
|
||||
get {return _encryptionKeyPair ?? SessionProtos_KeyPair()}
|
||||
set {_encryptionKeyPair = newValue}
|
||||
}
|
||||
/// Returns true if `encryptionKeyPair` has been explicitly set.
|
||||
var hasEncryptionKeyPair: Bool {return self._encryptionKeyPair != nil}
|
||||
/// Clears the value of `encryptionKeyPair`. Subsequent reads from it will return its default value.
|
||||
mutating func clearEncryptionKeyPair() {self._encryptionKeyPair = nil}
|
||||
|
||||
var members: [Data] = []
|
||||
|
||||
var admins: [Data] = []
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
|
||||
fileprivate var _publicKey: Data? = nil
|
||||
fileprivate var _name: String? = nil
|
||||
fileprivate var _encryptionKeyPair: SessionProtos_KeyPair? = nil
|
||||
}
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
||||
struct SessionProtos_ReceiptMessage {
|
||||
// SwiftProtobuf.Message conformance is added in an extension below. See the
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
|
@ -2023,11 +2092,13 @@ extension SessionProtos_Content: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
|
|||
2: .same(proto: "syncMessage"),
|
||||
5: .same(proto: "receiptMessage"),
|
||||
6: .same(proto: "typingMessage"),
|
||||
7: .same(proto: "configurationMessage"),
|
||||
]
|
||||
|
||||
public var isInitialized: Bool {
|
||||
if let v = self._dataMessage, !v.isInitialized {return false}
|
||||
if let v = self._syncMessage, !v.isInitialized {return false}
|
||||
if let v = self._configurationMessage, !v.isInitialized {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -2038,6 +2109,7 @@ extension SessionProtos_Content: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
|
|||
case 2: try decoder.decodeSingularMessageField(value: &self._syncMessage)
|
||||
case 5: try decoder.decodeSingularMessageField(value: &self._receiptMessage)
|
||||
case 6: try decoder.decodeSingularMessageField(value: &self._typingMessage)
|
||||
case 7: try decoder.decodeSingularMessageField(value: &self._configurationMessage)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
@ -2056,6 +2128,9 @@ extension SessionProtos_Content: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
|
|||
if let v = self._typingMessage {
|
||||
try visitor.visitSingularMessageField(value: v, fieldNumber: 6)
|
||||
}
|
||||
if let v = self._configurationMessage {
|
||||
try visitor.visitSingularMessageField(value: v, fieldNumber: 7)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
|
@ -2064,6 +2139,7 @@ extension SessionProtos_Content: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
|
|||
if lhs._syncMessage != rhs._syncMessage {return false}
|
||||
if lhs._receiptMessage != rhs._receiptMessage {return false}
|
||||
if lhs._typingMessage != rhs._typingMessage {return false}
|
||||
if lhs._configurationMessage != rhs._configurationMessage {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
|
@ -2104,6 +2180,47 @@ extension SessionProtos_ClosedGroupCiphertextMessageWrapper: SwiftProtobuf.Messa
|
|||
}
|
||||
}
|
||||
|
||||
extension SessionProtos_KeyPair: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = _protobuf_package + ".KeyPair"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "publicKey"),
|
||||
2: .same(proto: "privateKey"),
|
||||
]
|
||||
|
||||
public var isInitialized: Bool {
|
||||
if self._publicKey == nil {return false}
|
||||
if self._privateKey == nil {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularBytesField(value: &self._publicKey)
|
||||
case 2: try decoder.decodeSingularBytesField(value: &self._privateKey)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if let v = self._publicKey {
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 1)
|
||||
}
|
||||
if let v = self._privateKey {
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 2)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: SessionProtos_KeyPair, rhs: SessionProtos_KeyPair) -> Bool {
|
||||
if lhs._publicKey != rhs._publicKey {return false}
|
||||
if lhs._privateKey != rhs._privateKey {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SessionProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = _protobuf_package + ".DataMessage"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
|
@ -2810,47 +2927,6 @@ extension SessionProtos_DataMessage.ClosedGroupUpdateV2.TypeEnum: SwiftProtobuf.
|
|||
]
|
||||
}
|
||||
|
||||
extension SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = SessionProtos_DataMessage.ClosedGroupUpdateV2.protoMessageName + ".KeyPair"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "publicKey"),
|
||||
2: .same(proto: "privateKey"),
|
||||
]
|
||||
|
||||
public var isInitialized: Bool {
|
||||
if self._publicKey == nil {return false}
|
||||
if self._privateKey == nil {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularBytesField(value: &self._publicKey)
|
||||
case 2: try decoder.decodeSingularBytesField(value: &self._privateKey)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if let v = self._publicKey {
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 1)
|
||||
}
|
||||
if let v = self._privateKey {
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 2)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair, rhs: SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPair) -> Bool {
|
||||
if lhs._publicKey != rhs._publicKey {return false}
|
||||
if lhs._privateKey != rhs._privateKey {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPairWrapper: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = SessionProtos_DataMessage.ClosedGroupUpdateV2.protoMessageName + ".KeyPairWrapper"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
|
@ -2892,6 +2968,104 @@ extension SessionProtos_DataMessage.ClosedGroupUpdateV2.KeyPairWrapper: SwiftPro
|
|||
}
|
||||
}
|
||||
|
||||
extension SessionProtos_ConfigurationMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = _protobuf_package + ".ConfigurationMessage"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "closedGroups"),
|
||||
2: .same(proto: "openGroups"),
|
||||
]
|
||||
|
||||
public var isInitialized: Bool {
|
||||
if !SwiftProtobuf.Internal.areAllInitialized(self.closedGroups) {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeRepeatedMessageField(value: &self.closedGroups)
|
||||
case 2: try decoder.decodeRepeatedStringField(value: &self.openGroups)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if !self.closedGroups.isEmpty {
|
||||
try visitor.visitRepeatedMessageField(value: self.closedGroups, fieldNumber: 1)
|
||||
}
|
||||
if !self.openGroups.isEmpty {
|
||||
try visitor.visitRepeatedStringField(value: self.openGroups, fieldNumber: 2)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: SessionProtos_ConfigurationMessage, rhs: SessionProtos_ConfigurationMessage) -> Bool {
|
||||
if lhs.closedGroups != rhs.closedGroups {return false}
|
||||
if lhs.openGroups != rhs.openGroups {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SessionProtos_ConfigurationMessage.ClosedGroup: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = SessionProtos_ConfigurationMessage.protoMessageName + ".ClosedGroup"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "publicKey"),
|
||||
2: .same(proto: "name"),
|
||||
3: .same(proto: "encryptionKeyPair"),
|
||||
4: .same(proto: "members"),
|
||||
5: .same(proto: "admins"),
|
||||
]
|
||||
|
||||
public var isInitialized: Bool {
|
||||
if let v = self._encryptionKeyPair, !v.isInitialized {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularBytesField(value: &self._publicKey)
|
||||
case 2: try decoder.decodeSingularStringField(value: &self._name)
|
||||
case 3: try decoder.decodeSingularMessageField(value: &self._encryptionKeyPair)
|
||||
case 4: try decoder.decodeRepeatedBytesField(value: &self.members)
|
||||
case 5: try decoder.decodeRepeatedBytesField(value: &self.admins)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if let v = self._publicKey {
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 1)
|
||||
}
|
||||
if let v = self._name {
|
||||
try visitor.visitSingularStringField(value: v, fieldNumber: 2)
|
||||
}
|
||||
if let v = self._encryptionKeyPair {
|
||||
try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
|
||||
}
|
||||
if !self.members.isEmpty {
|
||||
try visitor.visitRepeatedBytesField(value: self.members, fieldNumber: 4)
|
||||
}
|
||||
if !self.admins.isEmpty {
|
||||
try visitor.visitRepeatedBytesField(value: self.admins, fieldNumber: 5)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: SessionProtos_ConfigurationMessage.ClosedGroup, rhs: SessionProtos_ConfigurationMessage.ClosedGroup) -> Bool {
|
||||
if lhs._publicKey != rhs._publicKey {return false}
|
||||
if lhs._name != rhs._name {return false}
|
||||
if lhs._encryptionKeyPair != rhs._encryptionKeyPair {return false}
|
||||
if lhs.members != rhs.members {return false}
|
||||
if lhs.admins != rhs.admins {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SessionProtos_ReceiptMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = _protobuf_package + ".ReceiptMessage"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
|
|
|
@ -35,10 +35,11 @@ message TypingMessage {
|
|||
}
|
||||
|
||||
message Content {
|
||||
optional DataMessage dataMessage = 1;
|
||||
optional SyncMessage syncMessage = 2;
|
||||
optional ReceiptMessage receiptMessage = 5;
|
||||
optional TypingMessage typingMessage = 6;
|
||||
optional DataMessage dataMessage = 1;
|
||||
optional SyncMessage syncMessage = 2;
|
||||
optional ReceiptMessage receiptMessage = 5;
|
||||
optional TypingMessage typingMessage = 6;
|
||||
optional ConfigurationMessage configurationMessage = 7;
|
||||
}
|
||||
|
||||
message ClosedGroupCiphertextMessageWrapper {
|
||||
|
@ -48,6 +49,13 @@ message ClosedGroupCiphertextMessageWrapper {
|
|||
optional bytes ephemeralPublicKey = 2;
|
||||
}
|
||||
|
||||
message KeyPair {
|
||||
// @required
|
||||
required bytes publicKey = 1;
|
||||
// @required
|
||||
required bytes privateKey = 2;
|
||||
}
|
||||
|
||||
message DataMessage {
|
||||
|
||||
enum Flags {
|
||||
|
@ -167,13 +175,6 @@ message DataMessage {
|
|||
ENCRYPTION_KEY_PAIR = 3; // wrappers
|
||||
}
|
||||
|
||||
message KeyPair {
|
||||
// @required
|
||||
required bytes publicKey = 1;
|
||||
// @required
|
||||
required bytes privateKey = 2;
|
||||
}
|
||||
|
||||
message KeyPairWrapper {
|
||||
// @required
|
||||
required bytes publicKey = 1; // The public key of the user the key pair is meant for
|
||||
|
@ -206,6 +207,20 @@ message DataMessage {
|
|||
optional PublicChatInfo publicChatInfo = 999;
|
||||
}
|
||||
|
||||
message ConfigurationMessage {
|
||||
|
||||
message ClosedGroup {
|
||||
optional bytes publicKey = 1;
|
||||
optional string name = 2;
|
||||
optional KeyPair encryptionKeyPair = 3;
|
||||
repeated bytes members = 4;
|
||||
repeated bytes admins = 5;
|
||||
}
|
||||
|
||||
repeated ClosedGroup closedGroups = 1;
|
||||
repeated string openGroups = 2;
|
||||
}
|
||||
|
||||
message ReceiptMessage {
|
||||
|
||||
enum Type {
|
||||
|
|
|
@ -338,9 +338,9 @@ extension MessageReceiver {
|
|||
return SNLog("Couldn't decrypt closed group encryption key pair.")
|
||||
}
|
||||
// Parse it
|
||||
let proto: SNProtoDataMessageClosedGroupUpdateV2KeyPair
|
||||
let proto: SNProtoKeyPair
|
||||
do {
|
||||
proto = try SNProtoDataMessageClosedGroupUpdateV2KeyPair.parseData(plaintext)
|
||||
proto = try SNProtoKeyPair.parseData(plaintext)
|
||||
} catch {
|
||||
return SNLog("Couldn't parse closed group encryption key pair.")
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ extension MessageSender {
|
|||
// Generate the new encryption key pair
|
||||
let newKeyPair = Curve25519.generateKeyPair()
|
||||
// Distribute it
|
||||
let proto = try SNProtoDataMessageClosedGroupUpdateV2KeyPair.builder(publicKey: newKeyPair.publicKey,
|
||||
let proto = try SNProtoKeyPair.builder(publicKey: newKeyPair.publicKey,
|
||||
privateKey: newKeyPair.privateKey).build()
|
||||
let plaintext = try proto.serializedData()
|
||||
let wrappers = try targetMembers.compactMap { publicKey -> ClosedGroupUpdateV2.KeyPairWrapper in
|
||||
|
|
Loading…
Reference in New Issue