(state: string)
| 140 | } |
| 141 | |
| 142 | function waitForOAuthCallback(state: string): Promise<ImplicitTokenPayload> { |
| 143 | return new Promise((resolve, reject) => { |
| 144 | const timeout = setTimeout( |
| 145 | () => { |
| 146 | if (pendingOAuth) { |
| 147 | pendingOAuth = undefined |
| 148 | reject(new Error("OAuth callback timeout - authorization took too long")) |
| 149 | } |
| 150 | }, |
| 151 | 5 * 60 * 1000, |
| 152 | ) |
| 153 | pendingOAuth = { |
| 154 | state, |
| 155 | resolve: (tokens) => { |
| 156 | clearTimeout(timeout) |
| 157 | resolve(tokens) |
| 158 | }, |
| 159 | reject: (error) => { |
| 160 | clearTimeout(timeout) |
| 161 | reject(error) |
| 162 | }, |
| 163 | } |
| 164 | }) |
| 165 | } |
| 166 | |
| 167 | async function listRouters( |
| 168 | bearer: string, |