From cc69cbd7e589ec4b065ce74d8c5e7714a040cfc5 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 26 Apr 2026 00:22:01 -0500 Subject: DomainDig v4.2.0: Add a local-only HTTP API layer for DomainDig Expose DomainDig as a programmable local domain intelligence engine over localhost with explicit user opt-in and token-based authentication. Highlights: - add a localhost-only API server with safe start/stop lifecycle - require a local token for every request and store it in Keychain - add read endpoints for portfolio, domains, history, events, and monitoring - add inspection endpoints that reuse the existing inspection engine - add monitoring enable/disable control endpoints - add structured JSON response envelopes with API versioning - add lightweight capped request logging with clear/reset support - add a Settings UI for Local API enablement, token management, status, and logs - start the server on launch only when enabled - include Local API secrets in local data reset cleanup This is the first programmability release for DomainDig and establishes the foundation for Shortcuts, scripts, and other local automation workflows. --- LocalAPIModels.swift | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 LocalAPIModels.swift (limited to 'LocalAPIModels.swift') diff --git a/LocalAPIModels.swift b/LocalAPIModels.swift new file mode 100644 index 0000000..5a18f11 --- /dev/null +++ b/LocalAPIModels.swift @@ -0,0 +1,45 @@ +import Foundation + +struct LocalAPIConfig: Codable, Equatable, Sendable { + var isEnabled: Bool + var port: Int + var token: String + var requestLoggingEnabled: Bool + + init( + isEnabled: Bool = false, + port: Int = 47821, + token: String = "", + requestLoggingEnabled: Bool = true + ) { + self.isEnabled = isEnabled + self.port = port + self.token = token + self.requestLoggingEnabled = requestLoggingEnabled + } +} + +struct APIRequestLog: Codable, Identifiable, Equatable, Sendable { + let id: UUID + let timestamp: Date + let method: String + let path: String + let statusCode: Int + let duration: TimeInterval + + init( + id: UUID = UUID(), + timestamp: Date, + method: String, + path: String, + statusCode: Int, + duration: TimeInterval + ) { + self.id = id + self.timestamp = timestamp + self.method = method + self.path = path + self.statusCode = statusCode + self.duration = duration + } +} -- cgit v1.2.3