Page MenuHomePhabricator

D11215.diff
No OneTemporary

D11215.diff

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
@@ -19,17 +19,19 @@
setConnectionIssueActionType,
updateConnectionStatusActionType,
setLateResponseActionType,
+ setActiveSessionRecoveryActionType,
} from '../keyserver-conn/keyserver-conn-types.js';
-import { resolveKeyserverSessionInvalidation } from '../keyserver-conn/recovery-utils.js';
import { unsupervisedBackgroundActionType } from '../reducers/lifecycle-state-reducer.js';
-import type { InitialNotifMessageOptions } from '../shared/crypto-utils.js';
import {
pingFrequency,
serverRequestSocketTimeout,
clientRequestVisualTimeout,
clientRequestSocketTimeout,
} from '../shared/timeouts.js';
-import { recoveryActionSources } from '../types/account-types.js';
+import {
+ recoveryActionSources,
+ type RecoveryActionSource,
+} from '../types/account-types.js';
import type { CompressedData } from '../types/compression-types.js';
import { type PlatformDetails } from '../types/device-types.js';
import type { CalendarQuery } from '../types/entry-types.js';
@@ -95,7 +97,6 @@
+sessionStateFunc: () => SessionState,
+sessionIdentification: SessionIdentification,
+cookie: ?string,
- +urlPrefix: string,
+connection: ConnectionInfo,
+currentCalendarQuery: () => CalendarQuery,
+frozen: boolean,
@@ -103,16 +104,12 @@
+noDataAfterPolicyAcknowledgment?: boolean,
+lastCommunicatedPlatformDetails: ?PlatformDetails,
+decompressSocketMessage: CompressedData => string,
+ +activeSessionRecovery: null | RecoveryActionSource,
// Redux dispatch functions
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
+socketCrashLoopRecovery?: () => Promise<void>,
- // keyserver olm sessions specific props
- +getInitialNotificationsEncryptedMessage?: (
- keyserverID: string,
- options?: ?InitialNotifMessageOptions,
- ) => Promise<string>,
};
type State = {
+inflightRequests: ?InflightRequests,
@@ -127,7 +124,6 @@
pingTimeoutID: ?TimeoutID;
messageLastReceived: ?number;
reopenConnectionAfterClosing: boolean = false;
- invalidationRecoveryInProgress: boolean = false;
initializedWithUserState: ?PreRequestUserState;
failuresAfterPolicyAcknowledgment: number = 0;
@@ -324,7 +320,7 @@
this.props.active &&
this.props.connection.status === 'disconnected' &&
prevProps.connection.status !== 'disconnected' &&
- !this.invalidationRecoveryInProgress
+ !this.props.activeSessionRecovery
) {
this.reconnect();
}
@@ -486,38 +482,14 @@
});
}
} else if (message.type === serverSocketMessageTypes.AUTH_ERROR) {
- const { sessionChange } = message;
- const cookie = sessionChange ? sessionChange.cookie : this.props.cookie;
- this.invalidationRecoveryInProgress = true;
-
- const recoverySessionChange = await resolveKeyserverSessionInvalidation(
- this.props.dispatch,
- cookie,
- this.props.urlPrefix,
- recoveryActionSources.socketAuthErrorResolutionAttempt,
- this.props.keyserverID,
- this.props.getInitialNotificationsEncryptedMessage,
- );
-
- if (!recoverySessionChange) {
- const { cookie: newerCookie, currentUserInfo } = sessionChange;
- this.props.dispatch({
- type: setNewSessionActionType,
- payload: {
- sessionChange: {
- cookieInvalidated: true,
- currentUserInfo,
- cookie: newerCookie,
- },
- preRequestUserState: this.initializedWithUserState,
- error: null,
- authActionSource:
- recoveryActionSources.socketAuthErrorResolutionAttempt,
- keyserverID: this.props.keyserverID,
- },
- });
- }
- this.invalidationRecoveryInProgress = false;
+ this.props.dispatch({
+ type: setActiveSessionRecoveryActionType,
+ payload: {
+ activeSessionRecovery:
+ recoveryActionSources.socketAuthErrorResolutionAttempt,
+ keyserverID: this.props.keyserverID,
+ },
+ });
}
};
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -140,6 +140,12 @@
keyserverID,
]);
+ const activeSessionRecovery = useSelector(
+ state =>
+ state.keyserverStore.keyserverInfos[keyserverID]?.connection
+ .activeSessionRecovery,
+ );
+
return (
<Socket
{...props}
@@ -150,7 +156,6 @@
sessionStateFunc={sessionStateFunc}
sessionIdentification={sessionIdentification}
cookie={cookie}
- urlPrefix={urlPrefix}
connection={connection}
currentCalendarQuery={currentCalendarQuery}
frozen={frozen}
@@ -159,11 +164,9 @@
dispatchActionPromise={dispatchActionPromise}
noDataAfterPolicyAcknowledgment={noDataAfterPolicyAcknowledgment}
socketCrashLoopRecovery={socketCrashLoopRecovery}
- getInitialNotificationsEncryptedMessage={
- getInitialNotificationsEncryptedMessage
- }
lastCommunicatedPlatformDetails={lastCommunicatedPlatformDetails}
decompressSocketMessage={decompressMessage}
+ activeSessionRecovery={activeSessionRecovery}
/>
);
});
diff --git a/web/socket.react.js b/web/socket.react.js
--- a/web/socket.react.js
+++ b/web/socket.react.js
@@ -6,7 +6,6 @@
import { preRequestUserStateForSingleKeyserverSelector } from 'lib/selectors/account-selectors.js';
import {
cookieSelector,
- urlPrefixSelector,
connectionSelector,
lastCommunicatedPlatformDetailsSelector,
} from 'lib/selectors/keyserver-selectors.js';
@@ -39,8 +38,6 @@
const { keyserverID } = props;
const cookie = useSelector(cookieSelector(keyserverID));
- const urlPrefix = useSelector(urlPrefixSelector(keyserverID));
- invariant(urlPrefix, 'missing urlPrefix for given keyserver id');
const connection = useSelector(connectionSelector(keyserverID));
invariant(connection, 'keyserver missing from keyserverStore');
const active = useSelector(
@@ -104,6 +101,12 @@
lastCommunicatedPlatformDetailsSelector(keyserverID),
);
+ const activeSessionRecovery = useSelector(
+ state =>
+ state.keyserverStore.keyserverInfos[keyserverID]?.connection
+ .activeSessionRecovery,
+ );
+
return (
<Socket
{...props}
@@ -114,7 +117,6 @@
sessionStateFunc={sessionStateFunc}
sessionIdentification={sessionIdentification}
cookie={cookie}
- urlPrefix={urlPrefix}
connection={connection}
currentCalendarQuery={currentCalendarQuery}
frozen={false}
@@ -123,6 +125,7 @@
dispatchActionPromise={dispatchActionPromise}
lastCommunicatedPlatformDetails={lastCommunicatedPlatformDetails}
decompressSocketMessage={decompressMessage}
+ activeSessionRecovery={activeSessionRecovery}
/>
);
});

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 29, 11:53 AM (21 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2596893
Default Alt Text
D11215.diff (7 KB)

Event Timeline