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

Function waitForOAuthCallback

packages/opencode/src/plugin/openai/codex.ts:236–261  ·  view source on GitHub ↗
(pkce: PkceCodes, state: string)

Source from the content-addressed store, hash-verified

234}
235
236function waitForOAuthCallback(pkce: PkceCodes, state: string): Promise<TokenResponse> {
237 return new Promise((resolve, reject) => {
238 const timeout = setTimeout(
239 () => {
240 if (pendingOAuth) {
241 pendingOAuth = undefined
242 reject(new Error("OAuth callback timeout - authorization took too long"))
243 }
244 },
245 5 * 60 * 1000,
246 ) // 5 minute timeout
247
248 pendingOAuth = {
249 pkce,
250 state,
251 resolve: (tokens) => {
252 clearTimeout(timeout)
253 resolve(tokens)
254 },
255 reject: (error) => {
256 clearTimeout(timeout)
257 reject(error)
258 },
259 }
260 })
261}
262
263export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPluginOptions = {}): Promise<Hooks> {
264 const issuer = options.issuer ?? ISSUER

Callers 1

CodexAuthPluginFunction · 0.70

Calls 2

rejectFunction · 0.50
resolveFunction · 0.50

Tested by

no test coverage detected