Repository Public
1// SP Wallet iOS2// File: App/AppConfiguration.swift3// Description: Static configuration of the app: the wallet's origin and relying party (Info.plist), the App Group, and — in DEBUG4// builds only — the override that points the app at a throwaway local stack with a software passkey.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import Foundation9import SPWalletCore1011struct AppConfiguration: Sendable {12 let api: APIConfiguration13 let appGroup: String14 /** DEBUG only: directory of the throwaway stack (setup token, software passkey). Always nil in release builds. */15 let devStackDirectory: URL?16 /** DEBUG only: UI tests ask for an empty, in-memory state. */17 let ephemeral: Bool1819 var isProduction: Bool { devStackDirectory == nil }2021 static func load() -> AppConfiguration {22 let info = Bundle.main.infoDictionary ?? [:]23 let version = info["CFBundleShortVersionString"] as? String ?? "0"24 let build = info["CFBundleVersion"] as? String ?? "0"25 let ua = "SPWallet-iOS/\(version) (\(build))"26 let group = info["SPWalletAppGroup"] as? String ?? "group.ai.spboucher.spwallet.ios"27 var origin = URL(string: info["SPWalletOrigin"] as? String ?? "https://wallet.spboucher.ai")!28 var rp = info["SPWalletRelyingParty"] as? String ?? "wallet.spboucher.ai"29 var dev: URL?30 var ephemeral = false31 #if DEBUG32 let env = ProcessInfo.processInfo.environment33 // only a loopback origin can replace the production one, and only in a debug build34 if let o = env["SPWALLET_ORIGIN"], let u = URL(string: o), u.host == "localhost" || u.host == "127.0.0.1" {35 origin = u; rp = "localhost"36 dev = URL(fileURLWithPath: env["SPWALLET_DEV_DIR"] ?? "/tmp/spw-native-8750/current")37 }38 ephemeral = env["SPWALLET_EPHEMERAL"] == "1"39 #endif40 return AppConfiguration(api: APIConfiguration(origin: origin, rpId: rp, userAgent: ua), appGroup: group, devStackDirectory: dev, ephemeral: ephemeral)41 }42}43