(oauthState: string, mcpName?: string)
| 131 | } |
| 132 | |
| 133 | export function waitForCallback(oauthState: string, mcpName?: string): Promise<string> { |
| 134 | if (mcpName) mcpNameToState.set(mcpName, oauthState) |
| 135 | return new Promise((resolve, reject) => { |
| 136 | const timeout = setTimeout(() => { |
| 137 | if (pendingAuths.has(oauthState)) { |
| 138 | pendingAuths.delete(oauthState) |
| 139 | if (mcpName) mcpNameToState.delete(mcpName) |
| 140 | reject(new Error("OAuth callback timeout - authorization took too long")) |
| 141 | stopIfIdle() |
| 142 | } |
| 143 | }, CALLBACK_TIMEOUT_MS) |
| 144 | |
| 145 | pendingAuths.set(oauthState, { resolve, reject, timeout }) |
| 146 | }) |
| 147 | } |
| 148 | |
| 149 | export function cancelPending(mcpName: string): void { |
| 150 | // Look up the oauthState for this mcpName via the reverse index |
nothing calls this directly
no test coverage detected