This commit is contained in:
Glen Maddern 2025-05-06 14:37:52 +10:00
commit 78d6583160
3 changed files with 6 additions and 9 deletions

View file

@ -24,10 +24,8 @@
"build": "tsup",
"check": "prettier --check . && tsc"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.11.0"
},
"devDependencies": {
"@modelcontextprotocol/sdk": "^1.11.0",
"@types/react": "^19.0.12",
"prettier": "^3.5.3",
"react": "^19.0.0",

3
pnpm-lock.yaml generated
View file

@ -7,11 +7,10 @@ settings:
importers:
.:
dependencies:
devDependencies:
'@modelcontextprotocol/sdk':
specifier: ^1.11.0
version: 1.11.0
devDependencies:
'@types/react':
specifier: ^19.0.12
version: 19.0.12

View file

@ -46,8 +46,6 @@ export async function onMcpAuthorization(
// Retrieve the stored state using the state parameter from the query
const stateKey = `${storageKeyPrefix}:state_${state}`;
const storedStateJSON = localStorage.getItem(stateKey);
// Remove the state key immediately after retrieval (it's single-use)
localStorage.removeItem(stateKey);
if (!storedStateJSON) {
throw new Error(`Invalid or expired state parameter "${state}". No matching state found in storage.`);
@ -76,8 +74,6 @@ export async function onMcpAuthorization(
const clientInfoStr = localStorage.getItem(clientInfoKey);
const codeVerifier = localStorage.getItem(codeVerifierKey);
// Remove the code verifier after retrieving it
localStorage.removeItem(codeVerifierKey);
if (!clientInfoStr) {
throw new Error(`Client information not found in storage (key: ${clientInfoKey}).`);
@ -114,6 +110,10 @@ export async function onMcpAuthorization(
// Clean up the persisted manual auth URL if it exists
localStorage.removeItem(authUrlKey);
// Remove the state key immediately after retrieval (it's single-use)
localStorage.removeItem(stateKey);
// Remove the code verifier after retrieving it
localStorage.removeItem(codeVerifierKey);
console.log(`${logPrefix} Tokens saved. Notifying opener window.`);