diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js --- a/lib/types/endpoints.js +++ b/lib/types/endpoints.js @@ -28,6 +28,11 @@ }); type SessionChangingEndpoint = $Values; +const endpointsNotRequiringAuthentication = Object.freeze({ + VERIFY_INVITE_LINK: 'verify_invite_link', + VERSION: 'version', +}); + // We do uploads over HTTP as well. This is because Websockets use TCP, which // guarantees ordering. That means that if we start an upload, any messages we // try to send the server after the upload starts will have to wait until the @@ -136,3 +141,10 @@ export function endpointIsSocketOnly(endpoint: Endpoint): boolean { return socketOnlyEndpointSet.has(endpoint); } + +const endpointsNotRequiringAuthenticationSet = new Set( + Object.values(endpointsNotRequiringAuthentication), +); +export function endpointRequiresAuthentication(endpoint: Endpoint): boolean { + return !endpointsNotRequiringAuthenticationSet.has(endpoint); +} 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 @@ -173,6 +173,7 @@ logInActionSource: ?LogInActionSource, keyserverID: string, urlPrefix: string, + temporary?: boolean, ) { dispatch({ type: setNewSessionActionType, @@ -183,6 +184,7 @@ logInActionSource, keyserverID, urlPrefix, + temporary, }, }); } @@ -214,6 +216,7 @@ const innerBoundSetNewSession = ( sessionChange: ClientSessionChange, error: ?string, + temporary?: boolean, ) => { newSessionChange = sessionChange; setNewSession( @@ -224,6 +227,7 @@ logInActionSource, keyserverID, urlPrefix, + temporary, ); }; try { @@ -319,6 +323,7 @@ const boundSetNewSession = ( sessionChange: ClientSessionChange, error: ?string, + temporary?: boolean, ) => setNewSession( dispatch, @@ -331,6 +336,7 @@ undefined, keyserverID, urlPrefix, + temporary, ); // This function gets called before callServerEndpoint sends a request, // to make sure that we're not in the middle of trying to recover diff --git a/lib/utils/call-server-endpoint.js b/lib/utils/call-server-endpoint.js --- a/lib/utils/call-server-endpoint.js +++ b/lib/utils/call-server-endpoint.js @@ -14,6 +14,7 @@ import { updateLastCommunicatedPlatformDetailsActionType } from '../actions/device-actions.js'; import { callServerEndpointTimeout } from '../shared/timeouts.js'; import type { PlatformDetails } from '../types/device-types.js'; +import { endpointRequiresAuthentication } from '../types/endpoints.js'; import { type Endpoint, type SocketAPIHandler, @@ -75,7 +76,11 @@ async function callServerEndpoint( cookie: ?string, - setNewSession: (sessionChange: ClientSessionChange, error: ?string) => void, + setNewSession: ( + sessionChange: ClientSessionChange, + error: ?string, + temporary?: boolean, + ) => void, waitIfCookieInvalidated: () => Promise, cookieInvalidationRecovery: ( sessionChange: ClientSessionChange, @@ -204,7 +209,8 @@ return await maybeReplacement(endpoint, input, options); } } - setNewSession(clientSessionChange, error); + const temporary = !endpointRequiresAuthentication(endpoint); + setNewSession(clientSessionChange, error, temporary); } if (!error && shouldSendPlatformDetails) {