diff --git a/lib/components/keyserver-connection-handler.js b/lib/components/keyserver-connection-handler.js --- a/lib/components/keyserver-connection-handler.js +++ b/lib/components/keyserver-connection-handler.js @@ -247,6 +247,7 @@ cancelled = true; setAuthInProgress(false); }; + const hasBeenCancelled = () => cancelled; const promise = (async () => { const userStateBeforeRecovery = preRequestUserStateRef.current; @@ -259,6 +260,7 @@ recoveryActionSource, keyserverID, getInitialNotificationsEncryptedMessageForRecovery, + hasBeenCancelled, ); const sessionChange = recoverySessionChange ?? genericCookieInvalidation; diff --git a/lib/keyserver-conn/recovery-utils.js b/lib/keyserver-conn/recovery-utils.js --- a/lib/keyserver-conn/recovery-utils.js +++ b/lib/keyserver-conn/recovery-utils.js @@ -49,6 +49,7 @@ getInitialNotificationsEncryptedMessage: ( options?: ?InitialNotifMessageOptions, ) => Promise, + hasBeenCancelled: () => boolean, ): Promise { const { resolveKeyserverSessionInvalidationUsingNativeCredentials } = getConfig(); @@ -149,6 +150,7 @@ recoveryActionSource, keyserverID, getInitialNotificationsEncryptedMessage, + hasBeenCancelled, ); return newSessionChange; } diff --git a/lib/utils/config.js b/lib/utils/config.js --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -22,6 +22,7 @@ getInitialNotificationsEncryptedMessage: ( options?: ?InitialNotifMessageOptions, ) => Promise, + hasBeenCancelled: () => boolean, ) => Promise, +setSessionIDOnRequest: boolean, +calendarRangeInactivityLimit: ?number, diff --git a/native/account/legacy-recover-keyserver-session.js b/native/account/legacy-recover-keyserver-session.js --- a/native/account/legacy-recover-keyserver-session.js +++ b/native/account/legacy-recover-keyserver-session.js @@ -1,9 +1,10 @@ // @flow import { logInActionTypes, logInRawAction } from 'lib/actions/user-actions.js'; -import type { - DispatchRecoveryAttempt, - CallKeyserverEndpoint, +import { + type DispatchRecoveryAttempt, + type CallKeyserverEndpoint, + CANCELLED_ERROR, } from 'lib/keyserver-conn/keyserver-conn-types.js'; import type { InitialNotifMessageOptions } from 'lib/shared/crypto-utils.js'; import type { RecoveryActionSource } from 'lib/types/account-types.js'; @@ -22,9 +23,10 @@ getInitialNotificationsEncryptedMessage: ( ?InitialNotifMessageOptions, ) => Promise, + hasBeenCancelled: () => boolean, ) { const keychainCredentials = await fetchNativeKeychainCredentials(); - if (!keychainCredentials) { + if (!keychainCredentials || hasBeenCancelled()) { return; } @@ -35,6 +37,9 @@ callSingleKeyserverEndpoint, }), ]); + if (hasBeenCancelled()) { + throw new Error(CANCELLED_ERROR); + } const extraInfo = { ...baseExtraInfo, initialNotificationsEncryptedMessage }; const { calendarQuery } = extraInfo; 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 @@ -73,6 +73,7 @@ source, authoritativeKeyserverID, getInitialNotificationsEncryptedMessage, + () => false, ); dispatch({ type: setStoreLoadedActionType }); } catch (fetchCookieException) {