-
Notifications
You must be signed in to change notification settings - Fork 1
bug: token endpoint not being called after expiring #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
26cf2f3
7c6ce44
4b05096
2c38a3b
de87b82
a12051b
deb72e7
b30e72a
230edfe
8fd8c28
683621d
35a052a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ async function getConfig() { | |
| ); | ||
| return { | ||
| token: session.token || '', | ||
| refreshToken: session.refreshToken, | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Missing fallback — inconsistent with
|
||
| serverUrl: API_URL, | ||
| }; | ||
| } | ||
|
|
@@ -49,7 +50,7 @@ async function fetchMemories(query, limit = 5) { | |
| } | ||
|
|
||
| async function submitConversation(conversation, sourceModel) { | ||
| return apiFetch('/v1/memory/submit', { | ||
| return apiFetch(`/v1/memory/submit`, { | ||
|
Freedisch marked this conversation as resolved.
Outdated
|
||
| method: 'POST', | ||
| body: JSON.stringify({ conversation, source_model: sourceModel }), | ||
| }); | ||
|
|
@@ -61,8 +62,9 @@ async function rotateAccessToken() { | |
| throw new Error('Not logged in please open the extension to log in'); | ||
| } | ||
|
|
||
| const response = await fetch(`${serverUrl}${`/v1/auth/refresh`}`, { | ||
| const response = await fetch(`${serverUrl}/v1/auth/refresh`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify({ refresh_token: refreshToken }), | ||
| }); | ||
|
|
||
|
|
@@ -126,6 +128,9 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => { | |
| case 'LIST_MEMORIES': { | ||
| return apiFetch('/v1/memory'); | ||
| } | ||
| case 'GENERATE_MCP_TOKEN': { | ||
| return apiFetch('/v1/mcp/token', { method: 'POST' }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edge case: This is a general concern for the new message-passing architecture, but it's most user-visible here. If the Manifest V3 service worker is suspended between the popup sending Minor, but worth noting: |
||
| } | ||
| case 'GET_CONFIG': { | ||
| return getConfig(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,19 +85,15 @@ $('btn-cancel').addEventListener('click', () => showView('login')); | |
| async function loadConnectedState(token) { | ||
| _activeToken = token; | ||
| try { | ||
| const res = await fetch(`${API_URL}/v1/memory`, { | ||
| headers: { Authorization: `Bearer ${token}` }, | ||
| }); | ||
| const res = await chrome.runtime.sendMessage({ type: 'LIST_MEMORIES' }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleanup: After this PR, all API calls in
Both should be removed to avoid confusion about whether popup.js still makes direct API calls. |
||
|
|
||
| if (res.status === 401) { | ||
| await chrome.storage.sync.remove(['userName', 'userEmail', 'userAvatar']); | ||
| await chrome.storage.session.remove(['token']); | ||
| if (!res.ok) { | ||
| showView('login'); | ||
| setMsg('Session expired — please sign in again', 'error'); | ||
| setMsg('Could not reach server', 'error'); | ||
|
Freedisch marked this conversation as resolved.
Outdated
|
||
| return; | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| const data = await res.json(); | ||
| const data = res.data; | ||
| $('stat-memories').textContent = data.count ?? data.memories?.length ?? 0; | ||
|
|
||
| showView('connected'); | ||
|
|
@@ -114,12 +110,9 @@ $('btn-generate-mcp').addEventListener('click', async () => { | |
| btn.disabled = true; | ||
| btn.textContent = '…'; | ||
| try { | ||
| const res = await fetch(`${API_URL}/v1/mcp/token`, { | ||
| method: 'POST', | ||
| headers: { Authorization: `Bearer ${_activeToken}` }, | ||
| }); | ||
| if (!res.ok) throw new Error('server error'); | ||
| const data = await res.json(); | ||
| const res = await chrome.runtime.sendMessage({ type: 'GENERATE_MCP_TOKEN' }); | ||
| if (!res.ok) throw new Error(res.error || 'server error'); | ||
| const data = res.data; | ||
| $('mcp-token-value').textContent = data.mcp_token; | ||
| $('mcp-token-display').style.display = 'block'; | ||
| $('btn-copy-mcp').textContent = 'Copy'; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.