Page MenuHomePhabricator

D11219.diff
No OneTemporary

D11219.diff

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
@@ -47,7 +47,6 @@
recoveryActionSource: RecoveryActionSource,
keyserverID: string,
getInitialNotificationsEncryptedMessage?: (
- keyserverID: string,
options?: ?InitialNotifMessageOptions,
) => Promise<string>,
): Promise<?ClientSessionChange> {
diff --git a/lib/selectors/socket-selectors.js b/lib/selectors/socket-selectors.js
--- a/lib/selectors/socket-selectors.js
+++ b/lib/selectors/socket-selectors.js
@@ -96,9 +96,7 @@
) => (
calendarActive: boolean,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
- getInitialNotificationsEncryptedMessage: ?(
- keyserverID: string,
- ) => Promise<string>,
+ getInitialNotificationsEncryptedMessage: () => Promise<string>,
serverRequests: $ReadOnlyArray<ClientServerRequest>,
) => Promise<$ReadOnlyArray<ClientClientResponse>> = createSelector(
boundStateSyncSpecsSelector,
@@ -112,9 +110,7 @@
return async (
calendarActive: boolean,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
- getInitialNotificationsEncryptedMessage: ?(
- keyserverID: string,
- ) => Promise<string>,
+ getInitialNotificationsEncryptedMessage: () => Promise<string>,
serverRequests: $ReadOnlyArray<ClientServerRequest>,
): Promise<$ReadOnlyArray<ClientClientResponse>> => {
const clientResponses = [];
@@ -202,11 +198,10 @@
});
} else if (
serverRequest.type ===
- serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE &&
- getInitialNotificationsEncryptedMessage
+ serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE
) {
const initialNotificationsEncryptedMessage =
- await getInitialNotificationsEncryptedMessage(keyserverID);
+ await getInitialNotificationsEncryptedMessage();
clientResponses.push({
type: serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE,
initialNotificationsEncryptedMessage,
diff --git a/lib/shared/crypto-utils.js b/lib/shared/crypto-utils.js
--- a/lib/shared/crypto-utils.js
+++ b/lib/shared/crypto-utils.js
@@ -1,17 +1,15 @@
// @flow
+import invariant from 'invariant';
import * as React from 'react';
import {
getOlmSessionInitializationData,
getOlmSessionInitializationDataActionTypes,
} from '../actions/user-actions.js';
-import type {
- OLMIdentityKeys,
- OLMOneTimeKeys,
- OLMPrekey,
-} from '../types/crypto-types';
-import type { OlmSessionInitializationInfo } from '../types/request-types';
+import { cookieSelector } from '../selectors/keyserver-selectors.js';
+import { OlmSessionCreatorContext } from '../shared/olm-session-creator-context.js';
+import type { OLMOneTimeKeys, OLMPrekey } from '../types/crypto-types.js';
import { useLegacyAshoatKeyserverCall } from '../utils/action-utils.js';
import type {
CallSingleKeyserverEndpointOptions,
@@ -19,6 +17,7 @@
} from '../utils/call-single-keyserver-endpoint.js';
import { values } from '../utils/objects.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
+import { useSelector } from '../utils/redux-utils.js';
export type InitialNotifMessageOptions = {
+callSingleKeyserverEndpoint?: ?CallSingleKeyserverEndpoint,
@@ -30,22 +29,21 @@
};
function useInitialNotificationsEncryptedMessage(
- platformSpecificSessionCreator: (
- notificationsIdentityKeys: OLMIdentityKeys,
- notificationsInitializationInfo: OlmSessionInitializationInfo,
- keyserverID: string,
- ) => Promise<string>,
-): (
keyserverID: string,
- options?: ?InitialNotifMessageOptions,
-) => Promise<string> {
+): (options?: ?InitialNotifMessageOptions) => Promise<string> {
const callGetOlmSessionInitializationData = useLegacyAshoatKeyserverCall(
getOlmSessionInitializationData,
);
const dispatchActionPromise = useDispatchActionPromise();
+ const cookie = useSelector(cookieSelector(keyserverID));
+
+ const olmSessionCreator = React.useContext(OlmSessionCreatorContext);
+ invariant(olmSessionCreator, 'Olm session creator should be set');
+ const { notificationsSessionCreator } = olmSessionCreator;
+
return React.useCallback(
- async (keyserverID, options) => {
+ async options => {
const callSingleKeyserverEndpoint = options?.callSingleKeyserverEndpoint;
const callSingleKeyserverEndpointOptions =
options?.callSingleKeyserverEndpointOptions;
@@ -69,7 +67,8 @@
signedIdentityKeysBlob.payload,
);
- return await platformSpecificSessionCreator(
+ return await notificationsSessionCreator(
+ cookie,
notificationIdentityPublicKeys,
notifInitializationInfo,
keyserverID,
@@ -78,7 +77,9 @@
[
callGetOlmSessionInitializationData,
dispatchActionPromise,
- platformSpecificSessionCreator,
+ notificationsSessionCreator,
+ cookie,
+ keyserverID,
],
);
}
diff --git a/lib/utils/config.js b/lib/utils/config.js
--- a/lib/utils/config.js
+++ b/lib/utils/config.js
@@ -20,7 +20,6 @@
recoveryActionSource: RecoveryActionSource,
keyserverID: string,
getInitialNotificationsEncryptedMessage?: (
- keyserverID: string,
options?: ?InitialNotifMessageOptions,
) => Promise<string>,
) => Promise<void>,
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
@@ -20,7 +20,6 @@
recoveryActionSource: RecoveryActionSource,
keyserverID: string,
getInitialNotificationsEncryptedMessage?: (
- keyserverID: string,
?InitialNotifMessageOptions,
) => Promise<string>,
) {
@@ -32,7 +31,7 @@
if (getInitialNotificationsEncryptedMessage) {
const initialNotificationsEncryptedMessage =
- await getInitialNotificationsEncryptedMessage(keyserverID, {
+ await getInitialNotificationsEncryptedMessage({
callSingleKeyserverEndpoint,
});
extraInfo = { ...extraInfo, initialNotificationsEncryptedMessage };
diff --git a/native/account/log-in-panel.react.js b/native/account/log-in-panel.react.js
--- a/native/account/log-in-panel.react.js
+++ b/native/account/log-in-panel.react.js
@@ -54,7 +54,6 @@
UserNotFoundAlertDetails,
} from '../utils/alert-messages.js';
import Alert from '../utils/alert.js';
-import { nativeNotificationsSessionCreator } from '../utils/crypto-utils.js';
import type { StateContainer } from '../utils/state-container.js';
export type LogInState = {
@@ -76,9 +75,7 @@
username: string,
password: string,
) => Promise<IdentityAuthResult>,
- +getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
+ +getInitialNotificationsEncryptedMessage: () => Promise<string>,
};
class LogInPanel extends React.PureComponent<Props> {
usernameInput: ?TextInput;
@@ -253,9 +250,7 @@
Keyboard.dismiss();
const extraInfo = await this.props.logInExtraInfo();
const initialNotificationsEncryptedMessage =
- await this.props.getInitialNotificationsEncryptedMessage(
- authoritativeKeyserverID,
- );
+ await this.props.getInitialNotificationsEncryptedMessage();
if (usingCommServicesAccessToken) {
void this.props.dispatchActionPromise(
@@ -444,9 +439,7 @@
const callLegacyLogIn = useLogIn();
const callIdentityPasswordLogIn = useIdentityPasswordLogIn();
const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(
- nativeNotificationsSessionCreator,
- );
+ useInitialNotificationsEncryptedMessage(authoritativeKeyserverID);
return (
<LogInPanel
diff --git a/native/account/register-panel.react.js b/native/account/register-panel.react.js
--- a/native/account/register-panel.react.js
+++ b/native/account/register-panel.react.js
@@ -54,7 +54,6 @@
UnknownErrorAlertDetails,
} from '../utils/alert-messages.js';
import Alert from '../utils/alert.js';
-import { nativeNotificationsSessionCreator } from '../utils/crypto-utils.js';
import { type StateContainer } from '../utils/state-container.js';
type WritableRegisterState = {
@@ -75,9 +74,7 @@
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
+register: (registerInfo: RegisterInfo) => Promise<RegisterResult>,
- +getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
+ +getInitialNotificationsEncryptedMessage: () => Promise<string>,
};
type State = {
+confirmPasswordFocused: boolean,
@@ -311,9 +308,7 @@
Keyboard.dismiss();
const extraInfo = await this.props.logInExtraInfo();
const initialNotificationsEncryptedMessage =
- await this.props.getInitialNotificationsEncryptedMessage(
- authoritativeKeyserverID,
- );
+ await this.props.getInitialNotificationsEncryptedMessage();
void this.props.dispatchActionPromise(
keyserverRegisterActionTypes,
this.registerAction({
@@ -492,9 +487,7 @@
const dispatchActionPromise = useDispatchActionPromise();
const callRegister = useLegacyAshoatKeyserverCall(keyserverRegister);
const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(
- nativeNotificationsSessionCreator,
- );
+ useInitialNotificationsEncryptedMessage(authoritativeKeyserverID);
return (
<RegisterPanel
diff --git a/native/account/siwe-hooks.js b/native/account/siwe-hooks.js
--- a/native/account/siwe-hooks.js
+++ b/native/account/siwe-hooks.js
@@ -22,7 +22,6 @@
import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import { useSelector } from '../redux/redux-utils.js';
import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors.js';
-import { nativeNotificationsSessionCreator } from '../utils/crypto-utils.js';
type SIWEServerCallParams = {
+message: string,
@@ -57,7 +56,7 @@
const logInExtraInfo = useSelector(nativeLogInExtraInfoSelector);
const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(nativeNotificationsSessionCreator);
+ useInitialNotificationsEncryptedMessage(authoritativeKeyserverID);
const dispatchActionPromise = useDispatchActionPromise();
return React.useCallback(
@@ -67,12 +66,9 @@
) => {
const extraInfo = await logInExtraInfo();
const initialNotificationsEncryptedMessage =
- await getInitialNotificationsEncryptedMessage(
- authoritativeKeyserverID,
- {
- callSingleKeyserverEndpointOptions,
- },
- );
+ await getInitialNotificationsEncryptedMessage({
+ callSingleKeyserverEndpointOptions,
+ });
const siwePromise = callSIWE(
message,
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
@@ -31,7 +31,6 @@
import { setStoreLoadedActionType } from '../redux/action-types.js';
import { useSelector } from '../redux/redux-utils.js';
import Alert from '../utils/alert.js';
-import { nativeNotificationsSessionCreator } from '../utils/crypto-utils.js';
import { isTaskCancelledError } from '../utils/error-handling.js';
import { useStaffCanSee } from '../utils/staff-utils.js';
@@ -62,7 +61,7 @@
);
const mediaCacheContext = React.useContext(MediaCacheContext);
const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(nativeNotificationsSessionCreator);
+ useInitialNotificationsEncryptedMessage(authoritativeKeyserverID);
const callFetchNewCookieFromNativeCredentials = React.useCallback(
async (source: RecoveryActionSource) => {
diff --git a/native/selectors/socket-selectors.js b/native/selectors/socket-selectors.js
--- a/native/selectors/socket-selectors.js
+++ b/native/selectors/socket-selectors.js
@@ -49,10 +49,8 @@
type NativeGetClientResponsesSelectorInputType = $ReadOnly<{
...NavPlusRedux,
- getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
- keyserverID: string,
+ +getInitialNotificationsEncryptedMessage: () => Promise<string>,
+ +keyserverID: string,
}>;
const nativeGetClientResponsesSelector: (
@@ -70,15 +68,11 @@
getClientResponsesFunc: (
calendarActive: boolean,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
- getInitialNotificationsEncryptedMessage: ?(
- keyserverID: string,
- ) => Promise<string>,
+ getInitialNotificationsEncryptedMessage: () => Promise<string>,
serverRequests: $ReadOnlyArray<ClientServerRequest>,
) => Promise<$ReadOnlyArray<ClientClientResponse>>,
calendarActive: boolean,
- getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
+ getInitialNotificationsEncryptedMessage: () => Promise<string>,
) =>
(serverRequests: $ReadOnlyArray<ClientServerRequest>) =>
getClientResponsesFunc(
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -32,7 +32,6 @@
nativeSessionStateFuncSelector,
} from './selectors/socket-selectors.js';
import Alert from './utils/alert.js';
-import { nativeNotificationsSessionCreator } from './utils/crypto-utils.js';
import { decompressMessage } from './utils/decompress.js';
const NativeSocket: React.ComponentType<BaseSocketProps> =
@@ -63,9 +62,7 @@
);
const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(
- nativeNotificationsSessionCreator,
- );
+ useInitialNotificationsEncryptedMessage(keyserverID);
const getClientResponses = useSelector(state =>
nativeGetClientResponsesSelector({
diff --git a/web/account/account-hooks.js b/web/account/account-hooks.js
--- a/web/account/account-hooks.js
+++ b/web/account/account-hooks.js
@@ -409,23 +409,10 @@
);
}
-function useWebNotificationsSessionCreator(): (
- cookie: ?string,
- notificationsIdentityKeys: OLMIdentityKeys,
- notificationsInitializationInfo: OlmSessionInitializationInfo,
- keyserverID: string,
-) => Promise<string> {
- const context = React.useContext(OlmSessionCreatorContext);
- invariant(context, 'WebNotificationsSessionCreator not found.');
-
- return context.notificationsSessionCreator;
-}
-
export {
useGetSignedIdentityKeysBlob,
useGetOrCreateCryptoStore,
OlmSessionCreatorProvider,
- useWebNotificationsSessionCreator,
GetOrCreateCryptoStoreProvider,
useGetDeviceKeyUpload,
};
diff --git a/web/selectors/socket-selectors.js b/web/selectors/socket-selectors.js
--- a/web/selectors/socket-selectors.js
+++ b/web/selectors/socket-selectors.js
@@ -44,9 +44,7 @@
type WebGetClientResponsesSelectorInputType = {
+state: AppState,
+getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
- +getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
+ +getInitialNotificationsEncryptedMessage: () => Promise<string>,
+keyserverID: string,
};
@@ -67,16 +65,12 @@
getClientResponsesFunc: (
calendarActive: boolean,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
- getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
+ getInitialNotificationsEncryptedMessage: () => Promise<string>,
serverRequests: $ReadOnlyArray<ClientServerRequest>,
) => Promise<$ReadOnlyArray<ClientClientResponse>>,
getSignedIdentityKeysBlob: () => Promise<SignedIdentityKeysBlob>,
calendarActive: boolean,
- getInitialNotificationsEncryptedMessage: (
- keyserverID: string,
- ) => Promise<string>,
+ getInitialNotificationsEncryptedMessage: () => Promise<string>,
) =>
(serverRequests: $ReadOnlyArray<ClientServerRequest>) =>
getClientResponsesFunc(
diff --git a/web/socket.react.js b/web/socket.react.js
--- a/web/socket.react.js
+++ b/web/socket.react.js
@@ -12,15 +12,10 @@
import { openSocketSelector } from 'lib/selectors/socket-selectors.js';
import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
import Socket, { type BaseSocketProps } from 'lib/socket/socket.react.js';
-import type { OLMIdentityKeys } from 'lib/types/crypto-types.js';
-import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
-import {
- useGetSignedIdentityKeysBlob,
- useWebNotificationsSessionCreator,
-} from './account/account-hooks.js';
+import { useGetSignedIdentityKeysBlob } from './account/account-hooks.js';
import { useSelector } from './redux/redux-utils.js';
import {
activeThreadSelector,
@@ -56,22 +51,8 @@
preRequestUserStateForSingleKeyserverSelector(keyserverID),
);
const getSignedIdentityKeysBlob = useGetSignedIdentityKeysBlob();
- const webNotificationsSessionCreator = useWebNotificationsSessionCreator();
- const webNotifsSessionCreatorForCookie = React.useCallback(
- async (
- notificationsIdentityKeys: OLMIdentityKeys,
- notificationsInitializationInfo: OlmSessionInitializationInfo,
- ) =>
- webNotificationsSessionCreator(
- cookie,
- notificationsIdentityKeys,
- notificationsInitializationInfo,
- keyserverID,
- ),
- [webNotificationsSessionCreator, cookie, keyserverID],
- );
const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(webNotifsSessionCreatorForCookie);
+ useInitialNotificationsEncryptedMessage(keyserverID);
const getClientResponses = useSelector(state =>
webGetClientResponsesSelector({
state,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 29, 11:56 AM (21 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2596899
Default Alt Text
D11219.diff (17 KB)

Event Timeline