diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js --- a/lib/socket/socket.react.js +++ b/lib/socket/socket.react.js @@ -67,7 +67,7 @@ import type { DispatchActionPromise } from '../utils/action-utils.js'; import { setNewSessionActionType, - fetchNewCookieFromNativeCredentials, + resolveKeyserverSessionInvalidation, } from '../utils/action-utils.js'; import { getConfig } from '../utils/config.js'; import { ServerError, SocketTimeout, SocketOffline } from '../utils/errors.js'; @@ -482,7 +482,7 @@ const cookie = sessionChange ? sessionChange.cookie : this.props.cookie; this.invalidationRecoveryInProgress = true; - const recoverySessionChange = await fetchNewCookieFromNativeCredentials( + const recoverySessionChange = await resolveKeyserverSessionInvalidation( this.props.dispatch, cookie, this.props.urlPrefix, diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js --- a/lib/utils/action-utils.js +++ b/lib/utils/action-utils.js @@ -185,12 +185,13 @@ }); } -// This function calls resolveInvalidatedCookie, which dispatchs a log in action -// using the native credentials. Note that we never actually specify a sessionID -// here, on the assumption that only native clients will call this. (Native -// clients don't specify a sessionID, indicating to the server that it should -// use the cookieID as the sessionID.) -async function fetchNewCookieFromNativeCredentials( +// This function attempts to resolve an invalid keyserver session. A session can +// become invalid when a keyserver invalidates it, or due to inconsistent client +// state. If the client is usingCommServicesAccessToken, then the invalidation +// recovery will try to go through the keyserver's Olm auth responder. +// Otherwise, it will attempt to use the user's credentials to log in with the +// legacy auth responder, which won't work on web and won't work for ETH users. +async function resolveKeyserverSessionInvalidation( dispatch: Dispatch, cookie: ?string, urlPrefix: string, @@ -351,7 +352,7 @@ sessionChange: ClientSessionChange, ) => { const newAnonymousCookie = sessionChange.cookie; - const newSessionChange = await fetchNewCookieFromNativeCredentials( + const newSessionChange = await resolveKeyserverSessionInvalidation( dispatch, newAnonymousCookie, urlPrefix, @@ -600,7 +601,7 @@ export { useDispatchActionPromise, setNewSessionActionType, - fetchNewCookieFromNativeCredentials, + resolveKeyserverSessionInvalidation, createBoundServerCallsSelector, registerActiveSocket, useServerCall, diff --git a/native/account/logged-out-modal.react.js b/native/account/logged-out-modal.react.js --- a/native/account/logged-out-modal.react.js +++ b/native/account/logged-out-modal.react.js @@ -26,7 +26,7 @@ import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js'; import { logInActionSources } from 'lib/types/account-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; -import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils.js'; +import { resolveKeyserverSessionInvalidation } from 'lib/utils/action-utils.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; @@ -432,7 +432,7 @@ const actionSource = loggedIn ? logInActionSources.appStartReduxLoggedInButInvalidCookie : logInActionSources.appStartCookieLoggedInButInvalidRedux; - const sessionChange = await fetchNewCookieFromNativeCredentials( + const sessionChange = await resolveKeyserverSessionInvalidation( dispatch, cookie, urlPrefix, diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js --- a/native/data/sqlite-data-handler.js +++ b/native/data/sqlite-data-handler.js @@ -18,7 +18,7 @@ logInActionSources, type LogInActionSource, } from 'lib/types/account-types.js'; -import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils.js'; +import { resolveKeyserverSessionInvalidation } from 'lib/utils/action-utils.js'; import { getMessageForException } from 'lib/utils/errors.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; @@ -65,7 +65,7 @@ const callFetchNewCookieFromNativeCredentials = React.useCallback( async (source: LogInActionSource) => { try { - await fetchNewCookieFromNativeCredentials( + await resolveKeyserverSessionInvalidation( dispatch, cookie, urlPrefix, diff --git a/native/socket.react.js b/native/socket.react.js --- a/native/socket.react.js +++ b/native/socket.react.js @@ -18,7 +18,7 @@ import { setConnectionIssueActionType } from 'lib/types/socket-types.js'; import { useDispatchActionPromise, - fetchNewCookieFromNativeCredentials, + resolveKeyserverSessionInvalidation, } from 'lib/utils/action-utils.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; @@ -132,7 +132,7 @@ return; } - await fetchNewCookieFromNativeCredentials( + await resolveKeyserverSessionInvalidation( dispatch, cookie, urlPrefix,