Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3494863
D6410.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6410.diff
View Options
diff --git a/web/account/siwe.react.js b/web/account/siwe.react.js
--- a/web/account/siwe.react.js
+++ b/web/account/siwe.react.js
@@ -2,6 +2,7 @@
import '@rainbow-me/rainbowkit/dist/index.css';
+import olm from '@matrix-org/olm';
import {
ConnectButton,
darkTheme,
@@ -28,8 +29,8 @@
} from 'lib/utils/action-utils';
import {
createSIWEMessage,
+ getSIWEStatementForPublicKey,
siweMessageSigningExplanationStatements,
- siweStatementWithoutPublicKey,
} from 'lib/utils/siwe-utils.js';
import Button from '../components/button.react';
@@ -55,6 +56,10 @@
const logInExtraInfo = useSelector(webLogInExtraInfoSelector);
const [siweNonce, setSIWENonce] = React.useState<?string>(null);
+ const [
+ primaryIdentityPublicKey,
+ setPrimaryIdentityPublicKey,
+ ] = React.useState<?string>(null);
const [
hasSIWEButtonBeenClicked,
setHasSIWEButtonBeenClicked,
@@ -78,6 +83,16 @@
);
}, [dispatchActionPromise, getSIWENonceCall, siweNonceShouldBeFetched]);
+ React.useEffect(() => {
+ (async () => {
+ await olm.init();
+ const account = new olm.Account();
+ account.create();
+ const { ed25519 } = JSON.parse(account.identity_keys());
+ setPrimaryIdentityPublicKey(ed25519);
+ })();
+ }, []);
+
const siweButtonColor = React.useMemo(
() => ({ backgroundColor: 'white', color: 'black' }),
[],
@@ -108,23 +123,21 @@
const onSignInButtonClick = React.useCallback(async () => {
invariant(siweNonce, 'nonce must be present during SIWE attempt');
- const message = createSIWEMessage(
- address,
- siweStatementWithoutPublicKey,
- siweNonce,
+ invariant(
+ primaryIdentityPublicKey,
+ 'primaryIdentityPublicKey must be present during SIWE attempt',
);
+ const statement = getSIWEStatementForPublicKey(primaryIdentityPublicKey);
+ const message = createSIWEMessage(address, statement, siweNonce);
const signature = await signer.signMessage(message);
attemptSIWEAuth(message, signature);
- }, [address, attemptSIWEAuth, signer, siweNonce]);
+ }, [address, attemptSIWEAuth, primaryIdentityPublicKey, signer, siweNonce]);
let siweLoginForm;
- if (signer && !siweNonce) {
+ if (signer && (!siweNonce || !primaryIdentityPublicKey)) {
siweLoginForm = (
<div className={css.connectButtonContainer}>
- <LoadingIndicator
- status={getSIWENonceCallLoadingStatus}
- size="medium"
- />
+ <LoadingIndicator status="loading" size="medium" />
</div>
);
} else if (signer) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 7:02 AM (21 h, 55 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2680859
Default Alt Text
D6410.diff (2 KB)
Attached To
Mode
D6410: [web] Include `primaryIdentityPublicKey` in SIWE message
Attached
Detach File
Event Timeline
Log In to Comment