-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4-tunnel' into develop
- Loading branch information
Showing
35 changed files
with
2,068 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...rdVPNCommunityCoreiOS/SOLARAPI/Providers/SessionProvider/Models/StartSessionRequest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// StartSessionRequest.swift | ||
// SOLARAPI | ||
// | ||
// Created by Lika Vorobeva on 26.09.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct StartSessionRequest: Codable { | ||
public let key: String | ||
public let signature: String | ||
|
||
public init(key: String, signature: String) { | ||
self.key = key | ||
self.signature = signature | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...dVPNCommunityCoreiOS/SOLARAPI/Providers/SessionProvider/Models/StartSessionResponse.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// StartSessionResponse.swift | ||
// SOLARAPI | ||
// | ||
// Created by Lika Vorobeva on 26.09.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct StartSessionResponse: Codable { | ||
public let success: Bool | ||
public let result: String? | ||
} |
36 changes: 36 additions & 0 deletions
36
SolardVPNCommunityCoreiOS/SOLARAPI/Providers/SessionProvider/NodeSessionAPITarget.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// NodeSessionAPITarget.swift | ||
// SOLARAPI | ||
// | ||
// Created by Lika Vorobeva on 26.09.2022. | ||
// | ||
|
||
import Foundation | ||
import Alamofire | ||
|
||
enum NodeSessionAPITarget { | ||
case createClient(address: String, id: String, request: StartSessionRequest) | ||
} | ||
|
||
extension NodeSessionAPITarget: APITarget { | ||
var method: HTTPMethod { | ||
switch self { | ||
case .createClient: | ||
return .post | ||
} | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case let .createClient(address, id, _): | ||
return "accounts/\(address)/sessions/\(id)" | ||
} | ||
} | ||
|
||
var parameters: Parameters { | ||
switch self { | ||
case let .createClient(_, _, data): | ||
return .requestJSONEncodable(data) | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
SolardVPNCommunityCoreiOS/SOLARAPI/Providers/SessionProvider/NodeSessionProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// NodeSessionProvider.swift | ||
// SOLARAPI | ||
// | ||
// Created by Lika Vorobeva on 26.09.2022. | ||
// | ||
|
||
import Foundation | ||
import Alamofire | ||
|
||
public final class NodeSessionProvider: SOLARAPIProvider { | ||
public init() {} | ||
} | ||
|
||
// MARK: - StealthProviderType implementation | ||
|
||
extension NodeSessionProvider: NodeSessionProviderType { | ||
public func createClient( | ||
remoteURL: URL, | ||
address: String, | ||
id: String, | ||
request: StartSessionRequest, | ||
completion: @escaping (Result<StartSessionResponse, NetworkError>) -> Void | ||
) { | ||
let apiRequest = APIRequest( | ||
baseURL: remoteURL, | ||
target: NodeSessionAPITarget.createClient(address: address, id: id, request: request) | ||
) | ||
|
||
AF.request(apiRequest) | ||
.validate() | ||
.responseDecodable(completionHandler: getResponseHandler(mapsInnerErrors: true, completion: completion)) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
SolardVPNCommunityCoreiOS/SOLARAPI/Providers/SessionProvider/NodeSessionProviderType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NodeSessionProviderType.swift | ||
// SOLARAPI | ||
// | ||
// Created by Lika Vorobeva on 26.09.2022. | ||
// | ||
|
||
import Foundation | ||
import Alamofire | ||
|
||
public protocol NodeSessionProviderType { | ||
func createClient( | ||
remoteURL: URL, | ||
address: String, | ||
id: String, | ||
request: StartSessionRequest, | ||
completion: @escaping (Result<StartSessionResponse, NetworkError>) -> Void | ||
) | ||
} |
260 changes: 244 additions & 16 deletions
260
SolardVPNCommunityCoreiOS/SOLARdVPNCommunityCoreiOS.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.