diff --git a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 5b49d0153fba0965cde423d729297a5b5894bae8..0000000000000000000000000000000000000000 --- a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,95 +0,0 @@ -{ - "pins" : [ - { - "identity" : "combine-schedulers", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/combine-schedulers", - "state" : { - "revision" : "4cf088c29a20f52be0f2ca54992b492c54e0076b", - "version" : "0.5.3" - } - }, - { - "identity" : "keychainaccess", - "kind" : "remoteSourceControl", - "location" : "https://github.com/kishikawakatsumi/KeychainAccess.git", - "state" : { - "revision" : "84e546727d66f1adc5439debad16270d0fdd04e7", - "version" : "4.2.2" - } - }, - { - "identity" : "swift-case-paths", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-case-paths", - "state" : { - "revision" : "ce9c0d897db8a840c39de64caaa9b60119cf4be8", - "version" : "0.8.1" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections", - "state" : { - "revision" : "48254824bb4248676bf7ce56014ff57b142b77eb", - "version" : "1.0.2" - } - }, - { - "identity" : "swift-composable-architecture", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-composable-architecture.git", - "state" : { - "revision" : "c307541328a636b9e8e25ac868d89be54a8f8dbf", - "version" : "0.35.0" - } - }, - { - "identity" : "swift-composable-presentation", - "kind" : "remoteSourceControl", - "location" : "https://github.com/darrarski/swift-composable-presentation.git", - "state" : { - "revision" : "1f4d17fae1f7ed41cbed17929083190fd9a78ee6", - "version" : "0.5.2" - } - }, - { - "identity" : "swift-custom-dump", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-custom-dump", - "state" : { - "revision" : "c4f78db9b90ca57b7b6abc2223e235242739ea3c", - "version" : "0.4.0" - } - }, - { - "identity" : "swift-identified-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-identified-collections", - "state" : { - "revision" : "2d6b7ffcc67afd9077fac5e5a29bcd6d39b71076", - "version" : "0.4.0" - } - }, - { - "identity" : "swiftui-app-icon-creator", - "kind" : "remoteSourceControl", - "location" : "https://github.com/darrarski/swiftui-app-icon-creator.git", - "state" : { - "revision" : "f0c7ba4e66d3dc8135ccf9146afc05f9dff3c4ff", - "version" : "1.2.0" - } - }, - { - "identity" : "xctest-dynamic-overlay", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", - "state" : { - "revision" : "50a70a9d3583fe228ce672e8923010c8df2deddd", - "version" : "0.2.1" - } - } - ], - "version" : 2 -} diff --git a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift index aa492cc6c84e73846c2caf30a8677b8bbf429dd7..4baa7618e129896d093d22a0b40b0dfb7fbf620a 100644 --- a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift +++ b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift @@ -15,17 +15,17 @@ public struct ConnectionMaker { extension ConnectionMaker { public static func live(bindingsClient: BindingsClient) -> ConnectionMaker { ConnectionMaker { withAuthentication, recipientContact, myIdentity in - if !withAuthentication { + if withAuthentication { return Connection.live( - bindingsConnection: try bindingsClient.connect( - recipientContact, + bindingsAuthenticatedConnection: try bindingsClient.connect( + withAuthentication: recipientContact, myIdentity: myIdentity ) ) } else { return Connection.live( - bindingsAuthenticatedConnection: try bindingsClient.connect( - withAuthentication: recipientContact, + bindingsConnection: try bindingsClient.connect( + recipientContact, myIdentity: myIdentity ) ) diff --git a/Sources/ElixxirDAppsSDK/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/MessageSendReport.swift index d5b48cdd480b103d528b09e2db3cfd14be6b224c..60af863f971a1664b01e7f7849e7de6bb36c6a4a 100644 --- a/Sources/ElixxirDAppsSDK/MessageSendReport.swift +++ b/Sources/ElixxirDAppsSDK/MessageSendReport.swift @@ -1,39 +1,25 @@ import Foundation public struct MessageSendReport: Equatable { - public init( - roundList: [Int], - messageId: Data, - timestamp: Int - ) { - self.roundList = roundList - self.messageId = messageId - self.timestamp = timestamp - } - - public var roundList: [Int]? - public var messageId: Data? - public var timestamp: Int? + public init( + roundList: [Int]?, + messageId: Data?, + timestamp: Int? + ) { + self.roundList = roundList + self.messageId = messageId + self.timestamp = timestamp + } + + public var roundList: [Int]? + public var messageId: Data? + public var timestamp: Int? } extension MessageSendReport: Codable { - enum CodingKeys: String, CodingKey { - case roundList = "Rounds" - case messageId = "MessageID" - case timestamp = "Timestamp" - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - messageId = try container.decodeIfPresent(Data.self, forKey: .messageId) - timestamp = try container.decodeIfPresent(Int.self, forKey: .timestamp) - roundList = try container.decodeIfPresent([Int].self, forKey: .roundList) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(messageId, forKey: .messageId) - try container.encode(timestamp, forKey: .timestamp) - try container.encode(roundList, forKey: .roundList) - } + enum CodingKeys: String, CodingKey { + case roundList = "Rounds" + case messageId = "MessageID" + case timestamp = "Timestamp" + } } diff --git a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift index 75e3d421869b31e0ae841a752806490942ee443d..884afde1848f98dacab224047a0333b1788ea4d5 100644 --- a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift +++ b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift @@ -1,47 +1,37 @@ import Foundation public struct RestlikeMessage: Equatable { - public init( - version: Int, - headers: Data, - content: Data, - method: Int, - uri: String, - error: String - ) { - self.version = version - self.headers = headers - self.content = content - self.method = method - self.uri = uri - self.error = error - } - - public var version: Int? - public var headers: Data? - public var content: Data? - public var method: Int? - public var uri: String? - public var error: String? + public init( + version: Int, + headers: Data, + content: Data, + method: Int, + uri: String, + error: String + ) { + self.version = version + self.headers = headers + self.content = content + self.method = method + self.uri = uri + self.error = error + } + + public var version: Int? + public var headers: Data? + public var content: Data? + public var method: Int? + public var uri: String? + public var error: String? } extension RestlikeMessage: Codable { - enum CodingKeys: String, CodingKey { - case version = "Version" - case headers = "Headers" - case content = "Content" - case method = "Method" - case uri = "URI" - case error = "Error" - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - version = try container.decodeIfPresent(Int.self, forKey: .version) - headers = try container.decodeIfPresent(Data.self, forKey: .headers) - content = try container.decodeIfPresent(Data.self, forKey: .content) - method = try container.decodeIfPresent(Int.self, forKey: .method) - uri = try container.decodeIfPresent(String.self, forKey: .uri) - error = try container.decodeIfPresent(String.self, forKey: .error) - } + enum CodingKeys: String, CodingKey { + case version = "Version" + case headers = "Headers" + case content = "Content" + case method = "Method" + case uri = "URI" + case error = "Error" + } } diff --git a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift index d78a7eea7b4bef565128dc9c350bd4361469daef..52f3364049620ead64fb1c146677c02a66ed8dcb 100644 --- a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift +++ b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift @@ -6,9 +6,7 @@ final class MessageSendReportTests: XCTestCase { func testCoding() throws { let jsonString = """ { - "RoundList": { - "Rounds": [1,5,9] - }, + "Rounds": [1,5,9], "MessageID": "51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", "Timestamp": 1653582683183384000 } @@ -31,4 +29,18 @@ final class MessageSendReportTests: XCTestCase { XCTAssertNoDifference(decodedReport, report) } + + func testDecodeEmpty() throws { + let jsonString = "{}" + let jsonData = jsonString.data(using: .utf8)! + let decoder = JSONDecoder() + decoder.dataDecodingStrategy = .base64 + let report = try decoder.decode(MessageSendReport.self, from: jsonData) + + XCTAssertNoDifference(report, MessageSendReport( + roundList: nil, + messageId: nil, + timestamp: nil + )) + } }