* Get auth token from cookies * @returns {Promise }
()
| 6 | * @returns {Promise<string|null>} |
| 7 | */ |
| 8 | async function getTokenFromCookie() { |
| 9 | try { |
| 10 | // Get configuration to determine which domain to check |
| 11 | const domain = 'inverseui.com'; |
| 12 | |
| 13 | // Get all cookies for the domain to debug |
| 14 | const allCookies = await chrome.cookies.getAll({ |
| 15 | domain: domain.startsWith('.') ? domain : `.${domain}` |
| 16 | }); |
| 17 | console.log(`All cookies for ${domain}:`, allCookies); |
| 18 | |
| 19 | // Get specific cookie from domain |
| 20 | // Using getAll with specific name since get() might have issues with domain cookies |
| 21 | const cookies = await chrome.cookies.getAll({ |
| 22 | domain: domain.startsWith('.') ? domain : `.${domain}`, |
| 23 | name: 'inverseui_auth_token' |
| 24 | }); |
| 25 | |
| 26 | if (cookies && cookies.length > 0) { |
| 27 | return cookies[0].value; |
| 28 | } |
| 29 | |
| 30 | return null; |
| 31 | } catch (error) { |
| 32 | console.error('Failed to read auth cookie:', error); |
| 33 | return null; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Check if user is authenticated |
no outgoing calls
no test coverage detected