(pkce: PkceCodes, state: string)
| 234 | } |
| 235 | |
| 236 | function 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 | |
| 263 | export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPluginOptions = {}): Promise<Hooks> { |
| 264 | const issuer = options.issuer ?? ISSUER |
no test coverage detected