doc updates and test fixin

This commit is contained in:
2026-01-22 11:17:06 -08:00
parent 9f7b821760
commit fac98f4c54
56 changed files with 11967 additions and 357 deletions

View File

@@ -62,16 +62,21 @@ const _performTokenRefresh = async (): Promise<string> => {
// This endpoint relies on the HttpOnly cookie, so no body is needed.
headers: { 'Content-Type': 'application/json' },
});
const data = await response.json();
const result = await response.json();
if (!response.ok) {
throw new Error(data.message || 'Failed to refresh token.');
throw new Error(result.error?.message || result.message || 'Failed to refresh token.');
}
// The API returns {success, data: {token}}, so extract the token
const token = result.data?.token;
if (!token) {
throw new Error('No token received from refresh endpoint.');
}
// On successful refresh, store the new access token.
if (typeof window !== 'undefined') {
localStorage.setItem('authToken', data.token);
localStorage.setItem('authToken', token);
}
logger.info('Successfully refreshed access token.');
return data.token;
return token;
} catch (error) {
logger.error({ error }, 'Failed to refresh token. User session has expired.');
// Only perform browser-specific actions if in the browser environment.