Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3398504
D7654.id27172.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7654.id27172.diff
View Options
diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js
--- a/keyserver/src/responders/user-responders.js
+++ b/keyserver/src/responders/user-responders.js
@@ -100,6 +100,7 @@
createAccount,
processSIWEAccountCreation,
} from '../creators/account-creator.js';
+import { createOlmSession } from '../creators/olm-session-creator.js';
import { dbQuery, SQL } from '../database/database.js';
import { deleteAccount } from '../deleters/account-deleters.js';
import { deleteCookie } from '../deleters/cookie-deleters.js';
@@ -339,6 +340,7 @@
+calendarQuery: ?CalendarQuery,
+socialProof?: ?SIWESocialProof,
+signedIdentityKeysBlob?: ?SignedIdentityKeysBlob,
+ +initialNotificationsEncryptedMessage?: string,
};
async function processSuccessfulLogin(
@@ -351,6 +353,7 @@
calendarQuery,
socialProof,
signedIdentityKeysBlob,
+ initialNotificationsEncryptedMessage,
} = params;
const request: LogInRequest = input;
@@ -393,6 +396,19 @@
if (calendarQuery) {
await setNewSession(viewer, calendarQuery, newServerTime);
}
+ const olmSessionPromise = (async () => {
+ if (
+ userViewerData.cookieID &&
+ initialNotificationsEncryptedMessage &&
+ signedIdentityKeysBlob
+ ) {
+ await createOlmSession(
+ initialNotificationsEncryptedMessage,
+ 'notifications',
+ userViewerData.cookieID,
+ );
+ }
+ })();
const threadCursors = {};
for (const watchedThreadID of request.watchedIDs) {
@@ -412,6 +428,7 @@
calendarQuery ? fetchEntryInfos(viewer, [calendarQuery]) : undefined,
fetchKnownUserInfos(viewer),
fetchLoggedInUserInfo(viewer),
+ olmSessionPromise,
]);
const rawEntryInfos = entriesResult ? entriesResult.rawEntryInfos : null;
@@ -448,6 +465,7 @@
// old clients, but we no longer do anything with it.
primaryIdentityPublicKey: t.maybe(tRegex(primaryIdentityPublicKeyRegex)),
signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator),
+ initialNotificationsEncryptedMessage: t.maybe(t.String),
});
export const logInResponseValidator: TInterface<LogInResponse> =
@@ -479,7 +497,8 @@
);
let identityKeys: ?IdentityKeysBlob;
- const { signedIdentityKeysBlob } = request;
+ const { signedIdentityKeysBlob, initialNotificationsEncryptedMessage } =
+ request;
if (signedIdentityKeysBlob) {
identityKeys = JSON.parse(signedIdentityKeysBlob.payload);
@@ -543,6 +562,7 @@
userID: id,
calendarQuery,
signedIdentityKeysBlob,
+ initialNotificationsEncryptedMessage,
});
return validateOutput(
viewer.platformDetails,
diff --git a/lib/types/account-types.js b/lib/types/account-types.js
--- a/lib/types/account-types.js
+++ b/lib/types/account-types.js
@@ -109,6 +109,7 @@
+calendarQuery: CalendarQuery,
+deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,
+signedIdentityKeysBlob?: SignedIdentityKeysBlob,
+ +initialNotificationsEncryptedMessage?: string,
};
export type LogInInfo = {
@@ -129,6 +130,7 @@
+source?: LogInActionSource,
+primaryIdentityPublicKey?: empty,
+signedIdentityKeysBlob?: SignedIdentityKeysBlob,
+ +initialNotificationsEncryptedMessage?: string,
};
export type LogInResponse = {
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
@@ -37,6 +37,7 @@
import { useSelector } from '../redux/redux-utils.js';
import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors.js';
import type { KeyPressEvent } from '../types/react-native.js';
+import { useInitialNotificationsEncryptedMessage } from '../utils/crypto-utils.js';
import type { StateContainer } from '../utils/state-container.js';
export type LogInState = {
@@ -54,6 +55,7 @@
+logInExtraInfo: () => Promise<LogInExtraInfo>,
+dispatchActionPromise: DispatchActionPromise,
+logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,
+ +getInitialNotificationsEncryptedMessage: () => Promise<string>,
};
class LogInPanel extends React.PureComponent<Props> {
usernameInput: ?TextInput;
@@ -227,9 +229,12 @@
Keyboard.dismiss();
const extraInfo = await this.props.logInExtraInfo();
+ const initialNotificationsEncryptedMessage =
+ await this.props.getInitialNotificationsEncryptedMessage();
+
this.props.dispatchActionPromise(
logInActionTypes,
- this.logInAction(extraInfo),
+ this.logInAction({ ...extraInfo, initialNotificationsEncryptedMessage }),
undefined,
({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload),
);
@@ -364,6 +369,8 @@
const dispatchActionPromise = useDispatchActionPromise();
const callLogIn = useServerCall(logIn);
+ const getInitialNotificationsEncryptedMessage =
+ useInitialNotificationsEncryptedMessage();
return (
<LogInPanel
@@ -372,6 +379,9 @@
logInExtraInfo={logInExtraInfo}
dispatchActionPromise={dispatchActionPromise}
logIn={callLogIn}
+ getInitialNotificationsEncryptedMessage={
+ getInitialNotificationsEncryptedMessage
+ }
/>
);
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 11:13 PM (19 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608960
Default Alt Text
D7654.id27172.diff (5 KB)
Attached To
Mode
D7654: Establish olm sessions for notifs on both sides during log-in
Attached
Detach File
Event Timeline
Log In to Comment