macsync/@packages/shared/Sources/MacSyncShared/Transport/Shared.swift

16 lines
830 B
Swift
Raw Permalink Normal View History

import Foundation
import LilithAgentCore
/// Single shared keychain where the device auth token is stored.
/// All three sync modules (iMessage, iPhoto, iMail) look here for the Bearer token.
/// The device token belongs to one hardware device it is not per-module.
public let macSyncSharedKeychain = KeychainHelper(service: "com.lilith.mac-sync")
/// Read `serverURL` from UserDefaults, falling back to localhost for local development.
/// `ConfigFile.load()` merges `~/.config/com.lilith.mac-sync/config.json` into UserDefaults
/// at every launch, so this reflects the most recent config file value.
/// For deployed setups the install script (or config file) sets the remote server URL.
public func macSyncResolveServerURL() -> String {
UserDefaults.standard.string(forKey: "serverURL") ?? "http://localhost:3201"
}