MCPcopy Index your code
hub / github.com/InverseUI/InverseUI-Recorder / checkAuth

Function checkAuth

api/auth.js:41–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39 * @returns {Promise<{isAuthenticated: boolean, token: string|null}>}
40 */
41export async function checkAuth() {
42 try {
43 console.log('Checking auth');
44
45 // Get token from cookie
46 let token = await getTokenFromCookie();
47 console.log('Token from cookie:', token ? `${token.substring(0, 10)}...` : 'null');
48
49 if (!token) {
50 console.log('No token found in cookies');
51 return { isAuthenticated: false, token: null };
52 }
53
54 // Verify token with backend
55 console.log('Verifying token with backend:', API_CONFIG.AUTH.authCheckUrl);
56 const response = await fetch(API_CONFIG.AUTH.authCheckUrl, {
57 method: 'GET',
58 headers: {
59 'Authorization': `Bearer ${token}`,
60 'X-Extension-ID': chrome.runtime.id
61 }
62 });
63
64 console.log('Auth verification response:', response.status);
65
66 if (response.ok) {
67 console.log('Authentication successful');
68 return { isAuthenticated: true, token };
69 } else {
70 // Token invalid - cookies are managed by frontend
71 console.log('Token verification failed:', response.status, response.statusText);
72 const errorText = await response.text().catch(() => 'No error details');
73 console.log('Error details:', errorText);
74 return { isAuthenticated: false, token: null };
75 }
76 } catch (error) {
77 console.error('Auth check failed:', error);
78 return { isAuthenticated: false, token: null };
79 }
80}
81
82/**
83 * Get current auth token

Callers 2

startFreshRecordingFunction · 0.90
sendTrackToBackendFunction · 0.90

Calls 1

getTokenFromCookieFunction · 0.85

Tested by

no test coverage detected