| 140 | } |
| 141 | |
| 142 | export function waitForCallback(mcpName: string): Promise<string> { |
| 143 | return new Promise((resolve, reject) => { |
| 144 | const timeout = setTimeout(() => { |
| 145 | if (pendingAuths.has(mcpName)) { |
| 146 | pendingAuths.delete(mcpName) |
| 147 | reject(new Error("OAuth callback timeout - authorization took too long")) |
| 148 | } |
| 149 | }, CALLBACK_TIMEOUT_MS) |
| 150 | |
| 151 | pendingAuths.set(mcpName, { resolve, reject, timeout }) |
| 152 | }) |
| 153 | } |
| 154 | |
| 155 | export function cancelPending(mcpName: string): void { |
| 156 | const pending = pendingAuths.get(mcpName) |