MCPcopy Index your code
hub / github.com/anomalyco/opencode / waitForOAuthCallback

Function waitForOAuthCallback

packages/opencode/src/plugin/snowflake-cortex.ts:236–264  ·  view source on GitHub ↗
(account: string, pkce: PkceCodes, state: string)

Source from the content-addressed store, hash-verified

234}
235
236function waitForOAuthCallback(account: string, pkce: PkceCodes, state: string): Promise<TokenResponse> {
237 if (pendingOAuth) {
238 pendingOAuth.reject(new Error("Superseded by a newer Snowflake authorize request"))
239 pendingOAuth = undefined
240 }
241
242 return new Promise((resolve, reject) => {
243 const timeout = setTimeout(() => {
244 if (!pendingOAuth) return
245 pendingOAuth = undefined
246 stopOAuthServer()
247 reject(new Error("Snowflake OAuth callback timeout - authorization took too long"))
248 }, OAUTH_TIMEOUT_MS)
249
250 pendingOAuth = {
251 account,
252 state,
253 pkce,
254 resolve: (tokens) => {
255 clearTimeout(timeout)
256 resolve(tokens)
257 },
258 reject: (error) => {
259 clearTimeout(timeout)
260 reject(error)
261 },
262 }
263 })
264}
265
266export async function SnowflakeCortexAuthPlugin(_input: PluginInput): Promise<Hooks> {
267 const prompts = [

Callers 1

authorizeFunction · 0.70

Calls 4

stopOAuthServerFunction · 0.70
resolveFunction · 0.70
rejectFunction · 0.50
rejectMethod · 0.45

Tested by

no test coverage detected