@@ -129,6 +129,7 @@ export default class ServerClient extends (EventEmitter as new () => TypedEventE
129129 hasReceivedNewKeys : boolean = false
130130 hasSentNewKeys : boolean = false
131131 hasAuthenticated : boolean = false
132+ credentials : UserAuthRequest | undefined
132133
133134 localChannelIndex = 0
134135 channels = new Map < number , Channel > ( )
@@ -368,6 +369,7 @@ export default class ServerClient extends (EventEmitter as new () => TypedEventE
368369
369370 async handleAuthentication ( ) {
370371 let allowLogin = false
372+ let authRequest : Packet
371373 authentication: {
372374 const userAuthFailure = new UserAuthFailure ( {
373375 auth_methods : [
@@ -382,7 +384,7 @@ export default class ServerClient extends (EventEmitter as new () => TypedEventE
382384 // and the server should be able to handle them. This current implementation
383385 // does not respect that and waits sequencially.
384386 this . debug ( "Waiting for authentication request..." )
385- const [ authRequest ] = ( await this . waitEvent ( "packet" ) ) as [ Packet ]
387+ ; [ authRequest ] = ( await this . waitEvent ( "packet" ) ) as [ Packet ]
386388 assert ( authRequest instanceof UserAuthRequest , "Invalid packet type" )
387389
388390 this . debug ( `Received authentication request:` , authRequest )
@@ -496,6 +498,11 @@ export default class ServerClient extends (EventEmitter as new () => TypedEventE
496498 }
497499 }
498500
501+ // redo the assert for type checking, otherwise it should
502+ // never throw.
503+ assert ( authRequest instanceof UserAuthRequest , "Invalid packet type" )
504+ this . credentials = authRequest
505+
499506 if ( allowLogin ) {
500507 this . sendPacket ( new UserAuthSuccess ( { } ) )
501508 this . hasAuthenticated = true
0 commit comments