| 340 | // runs out, at which point it must emit `false` to signal "no more |
| 341 | // auth methods" (but we stop as soon as we see the password entry). |
| 342 | const pump = (): void => { |
| 343 | handler([], false, (auth: string | AnyAuthMethod | false) => { |
| 344 | if (auth === false) { |
| 345 | client.emit('error', new Error('unexpected end of auth queue')); |
| 346 | return; |
| 347 | } |
| 348 | if (typeof auth !== 'object') { |
| 349 | client.emit('error', new Error(`unexpected auth: ${auth}`)); |
| 350 | return; |
| 351 | } |
| 352 | yielded.push(auth.type); |
| 353 | if (auth.type === 'password') { |
| 354 | queueMicrotask(() => { |
| 355 | client.emit('ready'); |
| 356 | }); |
| 357 | return; |
| 358 | } |
| 359 | pump(); |
| 360 | }); |
| 361 | }; |
| 362 | pump(); |
| 363 | }, |
| 364 | }); |