Make the client more secure (#3742)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
Douwe Osinga
2025-07-31 19:20:37 +02:00
committed by GitHub
parent d9313aca57
commit d1e38fba32
19 changed files with 89 additions and 104 deletions
+17
View File
@@ -1,5 +1,6 @@
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { client } from './api/client.gen';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
@@ -16,3 +17,19 @@ export function patchConsoleLogging() {
// Intercept console methods
return;
}
// This needs to be called before any API calls are made, but since we're using the client
// in multiple useEffect locations, we can't be sure who goes first.
let clientInitialized = false;
export async function ensureClientInitialized() {
if (clientInitialized) return;
client.setConfig({
baseUrl: window.appConfig.get('GOOSE_API_HOST') + ':' + window.appConfig.get('GOOSE_PORT'),
headers: {
'Content-Type': 'application/json',
'X-Secret-Key': await window.electron.getSecretKey(),
},
});
clientInitialized = true;
}