v7.0.0
socket.authState
can no longer be in a 'pending'
(socket.PENDING
) state.
The 'pending'
authState
represented the ambiguous authentication state which might occur when the socket is disconnected/offline. It was removed because it was too ambiguous to be useful. Instead, socket.authState
now reports the last known authentication status (optimistic approach).
Once a socket is authenticated with a valid JWT, the socket will now report itself as being 'authenticated'
until the server explicitly indicates otherwise (e.g. the server invalidates the token).
Note that this only affects the authState
property and the events related to it. Pub/sub channels are not affected; the 'pending'
state
is still supported for SCChannel
objects (the meaning of 'pending'
is a lot clearer in that context).
Breaking changes:
- Front-end authentication logic which makes explicit comparisons between
socket.authState
and'pending'
orsocket.PENDING
may need to be reworked to deal with only two states:'unauthenticated'
(socket.UNAUTHENTICATED
) and'authenticated'
(socket.AUTHENTICATED
). - Front-end authentication logic which listens for the
'authStateChange'
event may be affected since there are now only two possible auth states instead of three.