@@ -16,7 +16,7 @@ import { ConsoleLogger, listen as doListen } from 'vscode-ws-jsonrpc';
16
16
17
17
import GitpodAuthSession from './sessionhandler' ;
18
18
import fetch from 'node-fetch' ;
19
- import { URLSearchParams } from 'url' ;
19
+ import { URL , URLSearchParams } from 'url' ;
20
20
21
21
export const authCompletePath = '/auth-complete' ;
22
22
const getBaseURL = ( ) => vscode . workspace . getConfiguration ( 'gitpod' ) . get ( 'authOrigin' , 'https://gitpod.io' ) ;
@@ -240,20 +240,20 @@ export async function setSettingsSync(enabled?: boolean): Promise<void> {
240
240
async function createApiWebSocket ( accessToken : string ) : Promise < { gitpodService : GitpodConnection ; pendignWebSocket : Promise < ReconnectingWebSocket > ; } > {
241
241
const factory = new JsonRpcProxyFactory < GitpodServer > ( ) ;
242
242
const gitpodService : GitpodConnection = new GitpodServiceImpl < GitpodClient , GitpodServer > ( factory . createProxy ( ) ) as any ;
243
+ console . log ( `Using token: ${ accessToken } ` ) ;
243
244
const pendignWebSocket = ( async ( ) => {
244
245
class GitpodServerWebSocket extends WebSocket {
245
246
constructor ( address : string , protocols ?: string | string [ ] ) {
246
247
super ( address , protocols , {
247
248
headers : {
248
- 'Origin' : getBaseURL ( ) ,
249
+ 'Origin' : new URL ( getBaseURL ( ) ) . origin ,
249
250
'Authorization' : `Bearer ${ accessToken } `
250
251
}
251
252
} ) ;
252
253
}
253
254
}
254
255
const webSocketMaxRetries = 3 ;
255
- console . log ( `Endpoint: ${ getBaseURL ( ) . replace ( 'https' , 'wss' ) } ` ) ;
256
- const webSocket = new ReconnectingWebSocket ( getBaseURL ( ) . replace ( 'https' , 'wss' ) , undefined , {
256
+ const webSocket = new ReconnectingWebSocket ( `${ getBaseURL ( ) . replace ( 'https' , 'wss' ) } /api/v1` , undefined , {
257
257
minReconnectionDelay : 1000 ,
258
258
connectionTimeout : 10000 ,
259
259
maxRetries : webSocketMaxRetries - 1 ,
@@ -310,11 +310,12 @@ export async function resolveAuthenticationSession(scopes: readonly string[], co
310
310
} ) ;
311
311
312
312
if ( ! exchangeTokenResponse . ok ) {
313
- vscode . window . showErrorMessage ( `Couldn't connect: ${ exchangeTokenResponse . statusText } , ${ await exchangeTokenResponse . text ( ) } ` ) ;
313
+ vscode . window . showErrorMessage ( `Couldn't connect (token exchange) : ${ exchangeTokenResponse . statusText } , ${ await exchangeTokenResponse . text ( ) } ` ) ;
314
314
return null ;
315
315
}
316
316
317
317
const exchangeTokenData : ExchangeTokenResponse = await exchangeTokenResponse . json ( ) ;
318
+ console . log ( exchangeTokenData ) ;
318
319
const access_token = exchangeTokenData . access_token ;
319
320
320
321
console . log ( access_token ) ;
0 commit comments