MCPcopy Create free account
hub / github.com/anomalyco/opencode / waitForCallback

Function waitForCallback

packages/opencode/src/mcp/oauth-callback.ts:133–147  ·  view source on GitHub ↗
(oauthState: string, mcpName?: string)

Source from the content-addressed store, hash-verified

131}
132
133export 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
149export function cancelPending(mcpName: string): void {
150 // Look up the oauthState for this mcpName via the reverse index

Callers

nothing calls this directly

Calls 4

stopIfIdleFunction · 0.85
rejectFunction · 0.50
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected