diff options
| author | Christian Cleberg <[email protected]> | 2026-07-24 18:46:47 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-07-24 19:09:01 -0500 |
| commit | 22ad96331a4456662f740c48882cab8aadd6d0b4 (patch) | |
| tree | 118f84e07454be699204841a5385783047b84f1a | |
| parent | 5fe3aeb2cefc41b8b96d99d47d967eb7aa070c98 (diff) | |
| download | domain-dig-22ad96331a4456662f740c48882cab8aadd6d0b4.tar.gz domain-dig-22ad96331a4456662f740c48882cab8aadd6d0b4.tar.bz2 domain-dig-22ad96331a4456662f740c48882cab8aadd6d0b4.zip | |
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().
| -rw-r--r-- | DomainDig/ContentView.swift | 4 | ||||
| -rw-r--r-- | LocalAPIService.swift | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/DomainDig/ContentView.swift b/DomainDig/ContentView.swift index 103e3b5..894fc88 100644 --- a/DomainDig/ContentView.swift +++ b/DomainDig/ContentView.swift @@ -3029,6 +3029,10 @@ private struct LocalAPISettingsView: View { localAPIService.copyToken() } + Button("Copy cURL Command") { + localAPIService.copyCurlCommand() + } + Button("Rotate Token") { localAPIService.rotateToken() } diff --git a/LocalAPIService.swift b/LocalAPIService.swift index cd12fb8..0a5f8a2 100644 --- a/LocalAPIService.swift +++ b/LocalAPIService.swift @@ -142,6 +142,11 @@ final class LocalAPIService { AppClipboard.copy(config.token) } + func copyCurlCommand() { + guard !config.token.isEmpty else { return } + AppClipboard.copy("curl -H \"Authorization: Bearer \(config.token)\" \(address)/portfolio") + } + func localSecretReferences() -> [String] { [LocalAPISecretStore.reference] } |
