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 @@ -104,6 +104,8 @@ // async functions that hit server APIs +logOut: (preRequestUserState: PreRequestUserState) => Promise, +socketCrashLoopRecovery?: () => Promise, + // keyserver olm sessions specific props + +getInitialNotificationsEncryptedMessage?: () => Promise, }; type State = { +inflightRequests: ?InflightRequests, @@ -463,6 +465,7 @@ cookie, this.props.urlPrefix, logInActionSources.socketAuthErrorResolutionAttempt, + this.props.getInitialNotificationsEncryptedMessage, ); if (!recoverySessionChange && sessionChange) { 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 @@ -179,6 +179,7 @@ cookie: ?string, urlPrefix: string, logInActionSource: LogInActionSource, + getInitialNotificationsEncryptedMessage?: () => Promise, ): Promise { const resolveInvalidatedCookie = getConfig().resolveInvalidatedCookie; if (!resolveInvalidatedCookie) { @@ -241,6 +242,7 @@ boundCallServerEndpoint, dispatchRecoveryAttempt, logInActionSource, + getInitialNotificationsEncryptedMessage, ); return newSessionChange; } diff --git a/lib/utils/config.js b/lib/utils/config.js --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -12,6 +12,7 @@ callServerEndpoint: CallServerEndpoint, dispatchRecoveryAttempt: DispatchRecoveryAttempt, logInActionSource: LogInActionSource, + getInitialNotificationsEncryptedMessage?: () => Promise, ) => Promise, +setCookieOnRequest: boolean, +setSessionIDOnRequest: boolean, 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 @@ -62,6 +62,7 @@ runTiming, ratchetAlongWithKeyboardHeight, } from '../utils/animation-utils.js'; +import { useInitialNotificationsEncryptedMessage } from '../utils/crypto-utils.js'; import { type StateContainer, type StateChange, @@ -136,6 +137,8 @@ +styles: typeof unboundStyles, // Redux dispatch functions +dispatch: Dispatch, + // Keyserver olm sessions functions + +getInitialNotificationsEncryptedMessage: () => Promise, }; type State = { +mode: LoggedOutMode, @@ -315,6 +318,7 @@ cookie, urlPrefix, actionSource, + this.props.getInitialNotificationsEncryptedMessage, ); if ( sessionChange && @@ -778,6 +782,8 @@ const styles = useStyles(unboundStyles); const dispatch = useDispatch(); + const getInitialNotificationsEncryptedMessage = + useInitialNotificationsEncryptedMessage(); return ( ); }); diff --git a/native/account/resolve-invalidated-cookie.js b/native/account/resolve-invalidated-cookie.js --- a/native/account/resolve-invalidated-cookie.js +++ b/native/account/resolve-invalidated-cookie.js @@ -14,15 +14,23 @@ callServerEndpoint: CallServerEndpoint, dispatchRecoveryAttempt: DispatchRecoveryAttempt, logInActionSource: LogInActionSource, + getInitialNotificationsEncryptedMessage?: () => Promise, ) { const keychainCredentials = await fetchNativeKeychainCredentials(); if (!keychainCredentials) { return; } - const extraInfo = await nativeLogInExtraInfoSelector({ + let extraInfo = await nativeLogInExtraInfoSelector({ redux: store.getState(), navContext: getGlobalNavContext(), })(); + + if (getInitialNotificationsEncryptedMessage) { + const initialNotificationsEncryptedMessage = + await getInitialNotificationsEncryptedMessage(); + extraInfo = { ...extraInfo, initialNotificationsEncryptedMessage }; + } + const { calendarQuery } = extraInfo; await dispatchRecoveryAttempt( logInActionTypes, 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 @@ -20,6 +20,7 @@ import { setStoreLoadedActionType } from '../redux/action-types.js'; import { useSelector } from '../redux/redux-utils.js'; import { StaffContext } from '../staff/staff-context.js'; +import { useInitialNotificationsEncryptedMessage } from '../utils/crypto-utils.js'; import { isTaskCancelledError } from '../utils/error-handling.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; @@ -39,6 +40,8 @@ state.currentUserInfo?.anonymous ? undefined : state.currentUserInfo?.id, ); const mediaCacheContext = React.useContext(MediaCacheContext); + const getInitialNotificationsEncryptedMessage = + useInitialNotificationsEncryptedMessage(); const callFetchNewCookieFromNativeCredentials = React.useCallback( async (source: LogInActionSource) => { @@ -48,6 +51,7 @@ cookie, urlPrefix, source, + getInitialNotificationsEncryptedMessage, ); dispatch({ type: setStoreLoadedActionType }); } catch (fetchCookieException) { @@ -63,7 +67,13 @@ } } }, - [cookie, dispatch, staffCanSee, urlPrefix], + [ + cookie, + dispatch, + staffCanSee, + urlPrefix, + getInitialNotificationsEncryptedMessage, + ], ); const callClearSensitiveData = React.useCallback( diff --git a/native/socket.react.js b/native/socket.react.js --- a/native/socket.react.js +++ b/native/socket.react.js @@ -30,6 +30,7 @@ nativeGetClientResponsesSelector, nativeSessionStateFuncSelector, } from './selectors/socket-selectors.js'; +import { useInitialNotificationsEncryptedMessage } from './utils/crypto-utils.js'; const NativeSocket: React.ComponentType = React.memo(function NativeSocket(props: BaseSocketProps) { @@ -88,6 +89,8 @@ const dispatch = useDispatch(); const dispatchActionPromise = useDispatchActionPromise(); const callLogOut = useServerCall(logOut); + const getInitialNotificationsEncryptedMessage = + useInitialNotificationsEncryptedMessage(); const socketCrashLoopRecovery = React.useCallback(async () => { if (!accountHasPassword(currentUserInfo)) { @@ -108,6 +111,7 @@ cookie, urlPrefix, logInActionSources.refetchUserDataAfterAcknowledgment, + getInitialNotificationsEncryptedMessage, ); }, [ callLogOut, @@ -117,6 +121,7 @@ dispatchActionPromise, preRequestUserState, urlPrefix, + getInitialNotificationsEncryptedMessage, ]); return ( @@ -140,6 +145,9 @@ logOut={callLogOut} noDataAfterPolicyAcknowledgment={noDataAfterPolicyAcknowledgment} socketCrashLoopRecovery={socketCrashLoopRecovery} + getInitialNotificationsEncryptedMessage={ + getInitialNotificationsEncryptedMessage + } /> ); });