Skip to content
Snippets Groups Projects
Commit cd98797a authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Rename Environment to NDFEnvironment

parent 9077cdef
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!33XXMessengerClient
...@@ -16,7 +16,7 @@ extension CMixManager { ...@@ -16,7 +16,7 @@ extension CMixManager {
.appendingPathComponent("xx.network.client") .appendingPathComponent("xx.network.client")
.path, .path,
fileManager: FileManager = .default, fileManager: FileManager = .default,
environment: Environment = .mainnet, ndfEnvironment: NDFEnvironment = .mainnet,
downloadNDF: DownloadAndVerifySignedNdf = .live, downloadNDF: DownloadAndVerifySignedNdf = .live,
generateSecret: GenerateSecret = .live, generateSecret: GenerateSecret = .live,
passwordStorage: PasswordStorage, passwordStorage: PasswordStorage,
...@@ -31,7 +31,7 @@ extension CMixManager { ...@@ -31,7 +31,7 @@ extension CMixManager {
fileManager: fileManager fileManager: fileManager
), ),
create: .live( create: .live(
environment: environment, ndfEnvironment: ndfEnvironment,
downloadNDF: downloadNDF, downloadNDF: downloadNDF,
generateSecret: generateSecret, generateSecret: generateSecret,
passwordStorage: passwordStorage, passwordStorage: passwordStorage,
...@@ -42,7 +42,7 @@ extension CMixManager { ...@@ -42,7 +42,7 @@ extension CMixManager {
loadCMix: loadCMix loadCMix: loadCMix
), ),
restore: .live( restore: .live(
environment: environment, ndfEnvironment: ndfEnvironment,
downloadNDF: downloadNDF, downloadNDF: downloadNDF,
generateSecret: generateSecret, generateSecret: generateSecret,
passwordStorage: passwordStorage, passwordStorage: passwordStorage,
......
...@@ -11,7 +11,7 @@ public struct CMixManagerCreate { ...@@ -11,7 +11,7 @@ public struct CMixManagerCreate {
extension CMixManagerCreate { extension CMixManagerCreate {
public static func live( public static func live(
environment: Environment, ndfEnvironment: NDFEnvironment,
downloadNDF: DownloadAndVerifySignedNdf, downloadNDF: DownloadAndVerifySignedNdf,
generateSecret: GenerateSecret, generateSecret: GenerateSecret,
passwordStorage: PasswordStorage, passwordStorage: PasswordStorage,
...@@ -22,7 +22,7 @@ extension CMixManagerCreate { ...@@ -22,7 +22,7 @@ extension CMixManagerCreate {
loadCMix: LoadCMix loadCMix: LoadCMix
) -> CMixManagerCreate { ) -> CMixManagerCreate {
CMixManagerCreate { CMixManagerCreate {
let ndfData = try downloadNDF(environment) let ndfData = try downloadNDF(ndfEnvironment)
let password = generateSecret() let password = generateSecret()
try passwordStorage.save(password) try passwordStorage.save(password)
try? fileManager.removeItem(atPath: directoryPath) try? fileManager.removeItem(atPath: directoryPath)
......
...@@ -14,7 +14,7 @@ public struct CMixManagerRestore { ...@@ -14,7 +14,7 @@ public struct CMixManagerRestore {
extension CMixManagerRestore { extension CMixManagerRestore {
public static func live( public static func live(
environment: Environment, ndfEnvironment: NDFEnvironment,
downloadNDF: DownloadAndVerifySignedNdf, downloadNDF: DownloadAndVerifySignedNdf,
generateSecret: GenerateSecret, generateSecret: GenerateSecret,
passwordStorage: PasswordStorage, passwordStorage: PasswordStorage,
...@@ -23,7 +23,7 @@ extension CMixManagerRestore { ...@@ -23,7 +23,7 @@ extension CMixManagerRestore {
newCMixFromBackup: NewCMixFromBackup newCMixFromBackup: NewCMixFromBackup
) -> CMixManagerRestore { ) -> CMixManagerRestore {
CMixManagerRestore { backup, passphrase in CMixManagerRestore { backup, passphrase in
let ndfData = try downloadNDF(environment) let ndfData = try downloadNDF(ndfEnvironment)
let password = generateSecret() let password = generateSecret()
try passwordStorage.save(password) try passwordStorage.save(password)
try? fileManager.removeItem(atPath: directoryPath) try? fileManager.removeItem(atPath: directoryPath)
......
...@@ -2,9 +2,9 @@ import Bindings ...@@ -2,9 +2,9 @@ import Bindings
import XCTestDynamicOverlay import XCTestDynamicOverlay
public struct DownloadAndVerifySignedNdf { public struct DownloadAndVerifySignedNdf {
public var run: (Environment) throws -> Data public var run: (NDFEnvironment) throws -> Data
public func callAsFunction(_ env: Environment) throws -> Data { public func callAsFunction(_ env: NDFEnvironment) throws -> Data {
try run(env) try run(env)
} }
} }
......
import Foundation import Foundation
public struct Environment: Equatable { public struct NDFEnvironment: Equatable {
public init(url: URL, cert: String) { public init(url: URL, cert: String) {
self.url = url self.url = url
self.cert = cert self.cert = cert
...@@ -10,8 +10,8 @@ public struct Environment: Equatable { ...@@ -10,8 +10,8 @@ public struct Environment: Equatable {
public var cert: String public var cert: String
} }
extension Environment { extension NDFEnvironment {
public static let mainnet = Environment( public static let mainnet = NDFEnvironment(
url: URL(string: "https://elixxir-bins.s3.us-west-1.amazonaws.com/ndf/mainnet.json")!, url: URL(string: "https://elixxir-bins.s3.us-west-1.amazonaws.com/ndf/mainnet.json")!,
cert: """ cert: """
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
...@@ -50,3 +50,10 @@ extension Environment { ...@@ -50,3 +50,10 @@ extension Environment {
""" """
) )
} }
extension NDFEnvironment {
public static let unimplemented = NDFEnvironment(
url: URL(fileURLWithPath: "unimplemented"),
cert: "unimplemented"
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment