Page MenuHomePhabricator

D7047.id23719.diff
No OneTemporary

D7047.id23719.diff

diff --git a/web/account/traditional-login-form.react.js b/web/account/traditional-login-form.react.js
--- a/web/account/traditional-login-form.react.js
+++ b/web/account/traditional-login-form.react.js
@@ -1,6 +1,5 @@
// @flow
-import olm from '@matrix-org/olm';
import invariant from 'invariant';
import * as React from 'react';
@@ -16,11 +15,7 @@
LogInStartingPayload,
} from 'lib/types/account-types.js';
import { logInActionSources } from 'lib/types/account-types.js';
-import type {
- OLMIdentityKeys,
- PickledOLMAccount,
- SignedIdentityKeysBlob,
-} from 'lib/types/crypto-types.js';
+import type { SignedIdentityKeysBlob } from 'lib/types/crypto-types.js';
import {
useDispatchActionPromise,
useServerCall,
@@ -34,6 +29,7 @@
import Input from '../modals/input.react.js';
import { useSelector } from '../redux/redux-utils.js';
import { webLogInExtraInfoSelector } from '../selectors/account-selectors.js';
+import { signedIdentityKeysBlobSelector } from '../selectors/socket-selectors.js';
const loadingStatusSelector = createLoadingStatusSelector(logInActionTypes);
function TraditionalLoginForm(): React.Node {
@@ -43,14 +39,8 @@
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
- const primaryIdentityPublicKeys: ?OLMIdentityKeys = useSelector(
- state => state.cryptoStore.primaryIdentityKeys,
- );
- const notificationIdentityPublicKeys: ?OLMIdentityKeys = useSelector(
- state => state.cryptoStore.notificationIdentityKeys,
- );
- const primaryAccount: ?PickledOLMAccount = useSelector(
- state => state.cryptoStore.primaryAccount,
+ const signedIdentityKeysBlob: ?SignedIdentityKeysBlob = useSelector(
+ signedIdentityKeysBlobSelector,
);
const usernameInputRef = React.useRef();
@@ -80,30 +70,10 @@
async (extraInfo: LogInExtraInfo) => {
try {
invariant(
- primaryIdentityPublicKeys,
- 'primaryIdentityPublicKeys must be set in logInAction',
- );
- invariant(
- notificationIdentityPublicKeys,
- 'notificationIdentityPublicKeys must be set in logInAction',
- );
- invariant(primaryAccount, 'primaryAccount must be set in logInAction');
-
- const primaryOLMAccount = new olm.Account();
- primaryOLMAccount.unpickle(
- primaryAccount.picklingKey,
- primaryAccount.pickledAccount,
+ signedIdentityKeysBlob,
+ 'signedIdentityKeysBlob must be set in logInAction',
);
- const payloadToBeSigned = JSON.stringify({
- primaryIdentityPublicKeys,
- notificationIdentityPublicKeys,
- });
- const signedIdentityKeysBlob: SignedIdentityKeysBlob = {
- payload: payloadToBeSigned,
- signature: primaryOLMAccount.sign(payloadToBeSigned),
- };
-
const result = await callLogIn({
...extraInfo,
username,
@@ -125,15 +95,7 @@
throw e;
}
},
- [
- callLogIn,
- modalContext,
- notificationIdentityPublicKeys,
- password,
- primaryAccount,
- primaryIdentityPublicKeys,
- username,
- ],
+ [callLogIn, modalContext, password, signedIdentityKeysBlob, username],
);
const onSubmit = React.useCallback(
@@ -214,12 +176,8 @@
variant="filled"
type="submit"
disabled={
- primaryIdentityPublicKeys === null ||
- primaryIdentityPublicKeys === undefined ||
- notificationIdentityPublicKeys === null ||
- notificationIdentityPublicKeys === undefined ||
- primaryAccount === null ||
- primaryAccount === undefined ||
+ signedIdentityKeysBlob === null ||
+ signedIdentityKeysBlob === undefined ||
inputDisabled
}
onClick={onSubmit}
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
@@ -12,6 +12,7 @@
OLMIdentityKeys,
PickledOLMAccount,
SignedIdentityKeysBlob,
+ IdentityKeysBlob,
} from 'lib/types/crypto-types.js';
import type {
ClientServerRequest,
@@ -58,11 +59,12 @@
primaryAccount.pickledAccount,
);
- const payloadToBeSigned = JSON.stringify({
- primaryIdentityKeys,
- notificationIdentityKeys,
- });
+ const identityKeysBlob: IdentityKeysBlob = {
+ primaryIdentityPublicKeys: primaryIdentityKeys,
+ notificationIdentityPublicKeys: notificationIdentityKeys,
+ };
+ const payloadToBeSigned: string = JSON.stringify(identityKeysBlob);
const signedIdentityKeysBlob: SignedIdentityKeysBlob = {
payload: payloadToBeSigned,
signature: primaryOLMAccount.sign(payloadToBeSigned),
@@ -126,6 +128,7 @@
export {
openSocketSelector,
sessionIdentificationSelector,
+ signedIdentityKeysBlobSelector,
webGetClientResponsesSelector,
webSessionStateFuncSelector,
};

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 9:26 PM (20 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580842
Default Alt Text
D7047.id23719.diff (4 KB)

Event Timeline