Commit 22ad96331a

22ad96331a4456662f740c48882cab8aadd6d0b4

parent: 5fe3aeb2ce

Unsigned

cmc <hello@cleberg.net> · 2026-07-24 23:46 UTC

feat: add Copy cURL Command button to the Local API page (#30)

Adds a one-tap way to get a working, authenticated request from the Local
API settings page. copyCurlCommand() copies a curl invocation using the
current bound address and token via the Authorization header:

  curl -H "Authorization: Bearer <token>" http://127.0.0.1:<port>/portfolio

Keeps the token in a header rather than a query string, so it stays out of
URLs, browser history, and the request-log view (which masks the token).
Guards on an empty token, matching copyToken().

Layout: unified · split

DomainDig/ContentView.swift +4
@@ -3029,6 +3029,10 @@ private struct LocalAPISettingsView: View {
3029 localAPIService.copyToken() 3029 localAPIService.copyToken()
3030 } 3030 }
3031 3031
3032 Button("Copy cURL Command") {
3033 localAPIService.copyCurlCommand()
3034 }
3035
3032 Button("Rotate Token") { 3036 Button("Rotate Token") {
3033 localAPIService.rotateToken() 3037 localAPIService.rotateToken()
3034 } 3038 }
LocalAPIService.swift +5
@@ -142,6 +142,11 @@ final class LocalAPIService {
142 AppClipboard.copy(config.token) 142 AppClipboard.copy(config.token)
143 } 143 }
144 144
145 func copyCurlCommand() {
146 guard !config.token.isEmpty else { return }
147 AppClipboard.copy("curl -H \"Authorization: Bearer \(config.token)\" \(address)/portfolio")
148 }
149
145 func localSecretReferences() -> [String] { 150 func localSecretReferences() -> [String] {
146 [LocalAPISecretStore.reference] 151 [LocalAPISecretStore.reference]
147 } 152 }