Page MenuHomePhabricator

D7048.diff
No OneTemporary

D7048.diff

diff --git a/web/account/siwe-login-form.react.js b/web/account/siwe-login-form.react.js
--- a/web/account/siwe-login-form.react.js
+++ b/web/account/siwe-login-form.react.js
@@ -1,7 +1,6 @@
// @flow
import '@rainbow-me/rainbowkit/styles.css';
-import olm from '@matrix-org/olm';
import invariant from 'invariant';
import * as React from 'react';
import { useAccount, useSigner } from 'wagmi';
@@ -18,7 +17,6 @@
import type { LogInStartingPayload } from 'lib/types/account-types.js';
import type {
OLMIdentityKeys,
- PickledOLMAccount,
SignedIdentityKeysBlob,
} from 'lib/types/crypto-types.js';
import {
@@ -38,6 +36,7 @@
import LoadingIndicator from '../loading-indicator.react.js';
import { useSelector } from '../redux/redux-utils.js';
import { webLogInExtraInfoSelector } from '../selectors/account-selectors.js';
+import { signedIdentityKeysBlobSelector } from '../selectors/socket-selectors.js';
type SIWELoginFormProps = {
+cancelSIWEAuthFlow: () => void,
@@ -78,76 +77,38 @@
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 callSIWEAuthEndpoint = React.useCallback(
- (
- message: string,
- signature: string,
- extraInfo,
- signedIdentityKeysBlob: SignedIdentityKeysBlob,
- ) =>
- siweAuthCall({
+ (message: string, signature: string, extraInfo) => {
+ invariant(
+ signedIdentityKeysBlob,
+ 'signedIdentityKeysBlob must be set in attemptSIWEAuth',
+ );
+ return siweAuthCall({
message,
signature,
signedIdentityKeysBlob,
...extraInfo,
- }),
- [siweAuthCall],
+ });
+ },
+ [signedIdentityKeysBlob, siweAuthCall],
);
const attemptSIWEAuth = React.useCallback(
(message: string, signature: string) => {
- invariant(
- primaryIdentityPublicKeys,
- 'primaryIdentityPublicKeys must be set in attemptSIWEAuth',
- );
- invariant(
- notificationIdentityPublicKeys,
- 'notificationIdentityPublicKeys must be set in attemptSIWEAuth',
- );
- invariant(primaryAccount, 'primaryAccount must be set in logInAction');
-
- const primaryOLMAccount = new olm.Account();
- primaryOLMAccount.unpickle(
- primaryAccount.picklingKey,
- primaryAccount.pickledAccount,
- );
- const payloadToBeSigned = JSON.stringify({
- primaryIdentityPublicKeys,
- notificationIdentityPublicKeys,
- });
- const signedIdentityKeysBlob: SignedIdentityKeysBlob = {
- payload: payloadToBeSigned,
- signature: primaryOLMAccount.sign(payloadToBeSigned),
- };
-
const extraInfo = logInExtraInfo();
dispatchActionPromise(
siweAuthActionTypes,
- callSIWEAuthEndpoint(
- message,
- signature,
- extraInfo,
- signedIdentityKeysBlob,
- ),
+ callSIWEAuthEndpoint(message, signature, extraInfo),
undefined,
({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload),
);
},
- [
- callSIWEAuthEndpoint,
- dispatchActionPromise,
- logInExtraInfo,
- notificationIdentityPublicKeys,
- primaryAccount,
- primaryIdentityPublicKeys,
- ],
+ [callSIWEAuthEndpoint, dispatchActionPromise, logInExtraInfo],
);
const onSignInButtonClick = React.useCallback(async () => {
@@ -177,7 +138,7 @@
[],
);
- if (!siweNonce || !primaryIdentityPublicKeys) {
+ if (!siweNonce || !primaryIdentityPublicKeys || !signedIdentityKeysBlob) {
return (
<div className={css.loadingIndicator}>
<LoadingIndicator status="loading" size="large" />

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 11:38 PM (22 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581692
Default Alt Text
D7048.diff (4 KB)

Event Timeline