@@ -394,13 +394,6 @@ export async function revokeToken(endpoint: string, token: string): Promise<void
394394 }
395395}
396396
397- const PAGE_STYLE =
398- 'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0;color:#111;background:#fff'
399-
400- function callbackPage ( title : string , body : string ) : string {
401- return `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>${ title } </title></head><body style="${ PAGE_STYLE } "><main style="text-align:center;max-width:28rem;padding:2rem"><h1 style="font-weight:400;font-size:1.5rem;margin:0 0 .5rem">${ title } </h1><p style="margin:0;color:#666">${ body } </p></main></body></html>`
402- }
403-
404397interface LoopbackResult {
405398 code : string
406399}
@@ -468,22 +461,17 @@ function listenForCallback(
468461 */
469462 if ( state !== expectedState ) {
470463 response
471- . writeHead ( 400 , { 'content-type' : 'text/html ; charset=utf-8' } )
464+ . writeHead ( 400 , { 'content-type' : 'text/plain ; charset=utf-8' } )
472465 . end (
473- callbackPage (
474- 'Sign-in mismatch' ,
475- 'This response did not come from the sign-in this terminal started. Return to your terminal.'
476- )
466+ 'Sign-in mismatch. This response did not come from the sign-in this terminal started. Return to your terminal.'
477467 )
478468 return
479469 }
480470 if ( error || ! code ) {
481471 const description = url . searchParams . get ( 'error_description' ) ?? undefined
482- response
483- . writeHead ( 200 , { 'content-type' : 'text/html; charset=utf-8' } )
484- . end (
485- callbackPage ( 'Sign-in cancelled' , 'You can close this tab and return to your terminal.' )
486- )
472+ const cancelledUrl = new URL ( completionUrl )
473+ cancelledUrl . searchParams . set ( 'status' , 'cancelled' )
474+ response . writeHead ( 302 , { location : cancelledUrl . toString ( ) } ) . end ( )
487475 finish ( {
488476 ok : false ,
489477 error :
@@ -506,7 +494,7 @@ function listenForCallback(
506494
507495export interface BrowserLoginOptions {
508496 scopes : readonly string [ ]
509- /** Pin the loopback port, for a container that forwards a fixed one . */
497+ /** Pin the loopback port when an SSH tunnel forwards that same port . */
510498 callbackPort ?: number
511499 /** Called with the authorize URL once the listener is up, before waiting. */
512500 onAuthorizeUrl : ( url : string ) => void
0 commit comments