viktor
feat. Check if user authentication occurs when the “submit” or “improved prompt” button is clicked.
fa8d078
raw
history blame
536 Bytes
/**
* Client-side authentication utilities
*/
/**
* Get the inference token from cookies
* @returns Promise that resolves to the token string or throws an error if no token is found
*/
export async function getInferenceToken(): Promise<string> {
// Get token from cookie
const cookies = document.cookie.split('; ');
const tokenCookie = cookies.find(cookie => cookie.startsWith('hf_token='));
const token = tokenCookie?.split('=')[1];
if (!token) {
throw new Error('Authentication required');
}
return token;
}