@@ -7,7 +7,7 @@ import { URL } from 'url';
77import * as fs from 'fs' ;
88import * as path from 'path' ;
99import { randomBytes } from 'crypto' ;
10- import { env } from 'vscode' ;
10+ import { env , workspace } from 'vscode' ;
1111
1212function sendFile ( res : http . ServerResponse , filepath : string ) {
1313 const isSvg = filepath . endsWith ( '.svg' ) ;
@@ -99,13 +99,14 @@ export class LoopbackAuthServer implements ILoopbackServer {
9999 this . _resultPromise = new Promise < IOAuthResult > ( ( resolve , reject ) => deferred = { resolve, reject } ) ;
100100
101101 const appNameQueryParam = `&app_name=${ encodeURIComponent ( env . appName ) } ` ;
102+ const appIsSessionsQueryParam = workspace . isAgentSessionsWorkspace ? '&app_is_sessions=true' : '' ;
102103 this . _server = http . createServer ( ( req , res ) => {
103104 const reqUrl = new URL ( req . url ! , `http://${ req . headers . host } ` ) ;
104105 switch ( reqUrl . pathname ) {
105106 case '/signin' : {
106107 const receivedNonce = ( reqUrl . searchParams . get ( 'nonce' ) ?? '' ) . replace ( / / g, '+' ) ;
107108 if ( receivedNonce !== this . nonce ) {
108- res . writeHead ( 302 , { location : `/?error=${ encodeURIComponent ( 'Nonce does not match.' ) } ${ appNameQueryParam } ` } ) ;
109+ res . writeHead ( 302 , { location : `/?error=${ encodeURIComponent ( 'Nonce does not match.' ) } ${ appNameQueryParam } ${ appIsSessionsQueryParam } ` } ) ;
109110 res . end ( ) ;
110111 }
111112 res . writeHead ( 302 , { location : this . _startingRedirect . toString ( ) } ) ;
@@ -122,20 +123,20 @@ export class LoopbackAuthServer implements ILoopbackServer {
122123 return ;
123124 }
124125 if ( this . state !== state ) {
125- res . writeHead ( 302 , { location : `/?error=${ encodeURIComponent ( 'State does not match.' ) } ${ appNameQueryParam } ` } ) ;
126+ res . writeHead ( 302 , { location : `/?error=${ encodeURIComponent ( 'State does not match.' ) } ${ appNameQueryParam } ${ appIsSessionsQueryParam } ` } ) ;
126127 res . end ( ) ;
127128 throw new Error ( 'State does not match.' ) ;
128129 }
129130 if ( this . nonce !== nonce ) {
130- res . writeHead ( 302 , { location : `/?error=${ encodeURIComponent ( 'Nonce does not match.' ) } ${ appNameQueryParam } ` } ) ;
131+ res . writeHead ( 302 , { location : `/?error=${ encodeURIComponent ( 'Nonce does not match.' ) } ${ appNameQueryParam } ${ appIsSessionsQueryParam } ` } ) ;
131132 res . end ( ) ;
132133 throw new Error ( 'Nonce does not match.' ) ;
133134 }
134135 deferred . resolve ( { code, state } ) ;
135136 if ( isPortable ) {
136- res . writeHead ( 302 , { location : `/?app_name=${ encodeURIComponent ( env . appName ) } ` } ) ;
137+ res . writeHead ( 302 , { location : `/?app_name=${ encodeURIComponent ( env . appName ) } ${ appIsSessionsQueryParam } ` } ) ;
137138 } else {
138- res . writeHead ( 302 , { location : `/?redirect_uri=${ encodeURIComponent ( callbackUri ) } ${ appNameQueryParam } ` } ) ;
139+ res . writeHead ( 302 , { location : `/?redirect_uri=${ encodeURIComponent ( callbackUri ) } ${ appNameQueryParam } ${ appIsSessionsQueryParam } ` } ) ;
139140 }
140141 res . end ( ) ;
141142 break ;
0 commit comments