Merge commit 'a8390532f7' as 'ai-context/workbench-ui'

This commit is contained in:
elpresidank 2026-04-05 21:08:02 -05:00
commit 1a72bfdec0
310 changed files with 56430 additions and 0 deletions

View file

@ -0,0 +1,41 @@
/**
* Authenticated fetch utility
*
* Provides fetch functions that automatically include Bearer token authentication
* when an API key is configured in settings.
*/
/**
* Creates an authenticated fetch function that includes Bearer token when available
* @param apiKey - Optional API key for authentication
* @returns Fetch function with automatic auth headers
*/
export const createAuthenticatedFetch = (apiKey?: string) => {
return (url: string, options: RequestInit = {}) => {
const headers: HeadersInit = {
...options.headers,
};
// Add Bearer token if API key is present
if (apiKey) {
headers["Authorization"] = `Bearer ${apiKey}`;
}
return fetch(url, {
...options,
headers,
});
};
};
/**
* Hook-based authenticated fetch that uses current settings
* This is a React hook that must be called from within a component
*/
export const useAuthenticatedFetch = () => {
// Note: This will be implemented when we need it in components
// For now, we'll use the createAuthenticatedFetch directly with settings
throw new Error(
"useAuthenticatedFetch not yet implemented - use createAuthenticatedFetch with settings",
);
};