Repository Public
1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: App/AppEnvironment.swift3// Description: Where this build of the app connects and under which identifiers it stores things. Release = production wallet only; the development variant (Debug) = a local throwaway stack, never production.4import Foundation5import SPWalletCore67enum AppEnvironment {8 static let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "?"9 static let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "?"10 static let userAgent = "SPWallet-macOS/\(version) (\(build))"1112 #if SPW_DEV13 static let isDevelopment = true14 static let keychainService = "ai.spboucher.spwallet.dev"15 /// The local stack started by Scripts/backend-dev.sh (test mnemonic generated on the spot, SPW_BROADCAST=off).16 static var configuration: APIConfiguration {17 let port = UserDefaults.standard.integer(forKey: "spwDevPort")18 let origin = URL(string: "http://localhost:\(port == 0 ? 8760 : port)")!19 return APIConfiguration(origin: origin, rpId: "localhost", userAgent: userAgent)20 }21 #else22 static let isDevelopment = false23 static let keychainService = "ai.spboucher.spwallet"24 static var configuration: APIConfiguration { .production(userAgent: userAgent) }25 #endif2627 /// Application Support inside the sandbox container: offline snapshots, exports in progress. Nothing secret is written there.28 static var supportDirectory: URL {29 let base = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("SPWallet", isDirectory: true)30 try? FileManager.default.createDirectory(at: base, withIntermediateDirectories: true)31 return base32 }33}34