main
swift 36 lines 1.14 KB
Raw
1 import Foundation
2
3 /// The smbCloud environment to target.
4 ///
5 /// Mirrors `smbcloud_network::environment::Environment` in the canonical Rust
6 /// SDK: `dev` points at the local auth service over plain HTTP loopback, and
7 /// `production` at the hosted service over HTTPS.
8 public enum SmbCloudEnvironment: Sendable, Equatable {
9 case dev
10 case production
11 /// Escape hatch for self-hosted / staging deployments.
12 case custom(scheme: String, host: String)
13
14 /// `http` for `dev`, `https` for `production`.
15 public var apiProtocol: String {
16 switch self {
17 case .dev: return "http"
18 case .production: return "https"
19 case .custom(let scheme, _): return scheme
20 }
21 }
22
23 /// `localhost:8088` for `dev`, `api.smbcloud.xyz` for `production`.
24 public var apiHost: String {
25 switch self {
26 case .dev: return "localhost:8088"
27 case .production: return "api.smbcloud.xyz"
28 case .custom(_, let host): return host
29 }
30 }
31
32 /// The issuer base URL (`<scheme>://<host>/`), used by the OIDC endpoints.
33 var baseURL: URL {
34 URL(string: "\(apiProtocol)://\(apiHost)/")!
35 }
36 }