(account: string, pkce: PkceCodes, state: string)
| 234 | } |
| 235 | |
| 236 | function 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 | |
| 266 | export async function SnowflakeCortexAuthPlugin(_input: PluginInput): Promise<Hooks> { |
| 267 | const prompts = [ |
no test coverage detected