wip
This commit is contained in:
parent
5a6b81f05f
commit
78d6583160
3 changed files with 6 additions and 9 deletions
|
|
@ -24,10 +24,8 @@
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"check": "prettier --check . && tsc"
|
"check": "prettier --check . && tsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"@modelcontextprotocol/sdk": "^1.11.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@modelcontextprotocol/sdk": "^1.11.0",
|
||||||
"@types/react": "^19.0.12",
|
"@types/react": "^19.0.12",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
|
|
|
||||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
|
|
@ -7,11 +7,10 @@ settings:
|
||||||
importers:
|
importers:
|
||||||
|
|
||||||
.:
|
.:
|
||||||
dependencies:
|
devDependencies:
|
||||||
'@modelcontextprotocol/sdk':
|
'@modelcontextprotocol/sdk':
|
||||||
specifier: ^1.11.0
|
specifier: ^1.11.0
|
||||||
version: 1.11.0
|
version: 1.11.0
|
||||||
devDependencies:
|
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^19.0.12
|
specifier: ^19.0.12
|
||||||
version: 19.0.12
|
version: 19.0.12
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,6 @@ export async function onMcpAuthorization(
|
||||||
// Retrieve the stored state using the state parameter from the query
|
// Retrieve the stored state using the state parameter from the query
|
||||||
const stateKey = `${storageKeyPrefix}:state_${state}`;
|
const stateKey = `${storageKeyPrefix}:state_${state}`;
|
||||||
const storedStateJSON = localStorage.getItem(stateKey);
|
const storedStateJSON = localStorage.getItem(stateKey);
|
||||||
// Remove the state key immediately after retrieval (it's single-use)
|
|
||||||
localStorage.removeItem(stateKey);
|
|
||||||
|
|
||||||
if (!storedStateJSON) {
|
if (!storedStateJSON) {
|
||||||
throw new Error(`Invalid or expired state parameter "${state}". No matching state found in storage.`);
|
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 clientInfoStr = localStorage.getItem(clientInfoKey);
|
||||||
const codeVerifier = localStorage.getItem(codeVerifierKey);
|
const codeVerifier = localStorage.getItem(codeVerifierKey);
|
||||||
// Remove the code verifier after retrieving it
|
|
||||||
localStorage.removeItem(codeVerifierKey);
|
|
||||||
|
|
||||||
if (!clientInfoStr) {
|
if (!clientInfoStr) {
|
||||||
throw new Error(`Client information not found in storage (key: ${clientInfoKey}).`);
|
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
|
// Clean up the persisted manual auth URL if it exists
|
||||||
localStorage.removeItem(authUrlKey);
|
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.`);
|
console.log(`${logPrefix} Tokens saved. Notifying opener window.`);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue