@@ -107,20 +107,17 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
107107
108108 const logger = getLogger ( ) ;
109109 logger . debug (
110- { clientId : this . config . clientId , accountManagerHost : this . accountManagerHost , localPort : this . localPort } ,
111- `[Auth] ImplicitOAuthStrategy initialized for client: ${ this . config . clientId } ` ,
112- ) ;
113- logger . trace (
114- { scopes : this . config . scopes } ,
115- `[Auth] Configured scopes: ${ this . config . scopes ?. join ( ', ' ) || '(none)' } ` ,
110+ { clientId : this . config . clientId , accountManagerHost : this . accountManagerHost , port : this . localPort } ,
111+ '[Auth] ImplicitOAuthStrategy initialized' ,
116112 ) ;
113+ logger . trace ( { scopes : this . config . scopes } , '[Auth] Configured scopes' ) ;
117114 }
118115
119116 async fetch ( url : string , init : RequestInit = { } ) : Promise < Response > {
120117 const logger = getLogger ( ) ;
121118 const method = init . method || 'GET' ;
122119
123- logger . trace ( { method, url} , ` [Auth] Fetching with implicit OAuth: ${ method } ${ url } ` ) ;
120+ logger . trace ( { method, url} , ' [Auth] Fetching with implicit OAuth' ) ;
124121
125122 const token = await this . getAccessToken ( ) ;
126123
@@ -132,10 +129,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
132129 let res = await fetch ( url , { ...init , headers} ) ;
133130 const duration = Date . now ( ) - startTime ;
134131
135- logger . debug (
136- { method, url, status : res . status , duration} ,
137- `[Auth] Response: ${ method } ${ url } ${ res . status } ${ duration } ms` ,
138- ) ;
132+ logger . debug ( { method, url, status : res . status , duration} , '[Auth] Response' ) ;
139133
140134 // RESILIENCE: If the server says 401, the token might have expired or been revoked.
141135 // We retry exactly once after invalidating the cached token.
@@ -149,10 +143,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
149143 res = await fetch ( url , { ...init , headers} ) ;
150144 const retryDuration = Date . now ( ) - retryStart ;
151145
152- logger . debug (
153- { method, url, status : res . status , duration : retryDuration } ,
154- `[Auth] Retry response: ${ method } ${ url } ${ res . status } ${ retryDuration } ms` ,
155- ) ;
146+ logger . debug ( { method, url, status : res . status , duration : retryDuration } , '[Auth] Retry response' ) ;
156147 }
157148
158149 return res ;
@@ -244,10 +235,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
244235 ) ;
245236 ACCESS_TOKEN_CACHE . delete ( clientId ) ;
246237 } else {
247- logger . debug (
248- { timeUntilExpiryMs : timeUntilExpiry } ,
249- `[Auth] Reusing cached access token (expires in ${ Math . round ( timeUntilExpiry / 1000 ) } s)` ,
250- ) ;
238+ logger . debug ( { timeUntilExpiryMs : timeUntilExpiry } , '[Auth] Reusing cached access token' ) ;
251239 return cached . accessToken ;
252240 }
253241 }
@@ -314,7 +302,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
314302 logger . trace ( { authorizeUrl} , '[Auth] Authorization URL' ) ;
315303
316304 // Print URL to console (in case machine has no default browser)
317- logger . info ( `Login URL: ${ authorizeUrl } ` ) ;
305+ logger . info ( { url : authorizeUrl } , `Login URL: ${ authorizeUrl } ` ) ;
318306 logger . info ( 'If the URL does not open automatically, copy/paste it into a browser on this machine.' ) ;
319307
320308 // Attempt to open the browser
@@ -337,7 +325,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
337325 hasAccessToken : ! ! accessToken ,
338326 hasError : ! ! error ,
339327 } ,
340- ` [Auth] Received redirect request: ${ requestUrl . pathname } ` ,
328+ ' [Auth] Received redirect request' ,
341329 ) ;
342330
343331 if ( ! accessToken && ! error ) {
@@ -349,7 +337,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
349337 } else if ( accessToken ) {
350338 const authDuration = Date . now ( ) - startTime ;
351339 // Successfully received access token
352- logger . debug ( { authDurationMs : authDuration } , `[Auth] Got access token response (took ${ authDuration } ms)` ) ;
340+ logger . debug ( { duration : authDuration } , `[Auth] Got access token response (${ authDuration } ms)` ) ;
353341 logger . info ( 'Successfully authenticated' ) ;
354342
355343 try {
@@ -366,7 +354,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
366354
367355 logger . debug (
368356 { expiresIn, expiresAt : expiration . toISOString ( ) , scopes} ,
369- `[Auth] Token expires in ${ expiresIn } s, scopes: ${ scopes . join ( ', ' ) || '(none)' } ` ,
357+ `[Auth] Token expires in ${ expiresIn } s, scopes: ${ scopes . join ( ' ' ) } ` ,
370358 ) ;
371359
372360 resolve ( {
@@ -391,7 +379,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
391379 } else if ( error ) {
392380 // OAuth error response
393381 const errorMessage = errorDescription || error ;
394- logger . error ( { error, errorDescription} , `[Auth] OAuth error: ${ errorMessage } ` ) ;
382+ logger . error ( { error, errorDescription} , `[Auth] OAuth error: ${ error } ` ) ;
395383 response . writeHead ( 500 , { 'Content-Type' : 'text/plain' } ) ;
396384 response . write ( `Authentication failed: ${ errorMessage } ` ) ;
397385 response . end ( ) ;
@@ -421,7 +409,7 @@ export class ImplicitOAuthStrategy implements AuthStrategy {
421409 } ) ;
422410
423411 server . on ( 'error' , ( err ) => {
424- logger . error ( { error : err . message , port : this . localPort } , ` [Auth] Failed to start OAuth redirect server` ) ;
412+ logger . error ( { error : err . message , port : this . localPort } , ' [Auth] Failed to start OAuth redirect server' ) ;
425413 reject ( new Error ( `Failed to start OAuth redirect server: ${ err . message } ` ) ) ;
426414 } ) ;
427415 } ) ;
0 commit comments