Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3494075
D6826.id22908.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
D6826.id22908.diff
View Options
diff --git a/landing/siwe.react.js b/landing/siwe.react.js
--- a/landing/siwe.react.js
+++ b/landing/siwe.react.js
@@ -24,7 +24,6 @@
import type { SIWEWebViewMessage } from 'lib/types/siwe-types.js';
import {
getSIWEStatementForPublicKey,
- siweStatementWithoutPublicKey,
siweMessageSigningExplanationStatements,
createSIWEMessage,
} from 'lib/utils/siwe-utils.js';
@@ -79,9 +78,13 @@
React.useContext(SIWEContext);
const onClick = React.useCallback(() => {
invariant(siweNonce, 'nonce must be present during SIWE attempt');
- const statement = siwePrimaryIdentityPublicKey
- ? getSIWEStatementForPublicKey(siwePrimaryIdentityPublicKey)
- : siweStatementWithoutPublicKey;
+ invariant(
+ siwePrimaryIdentityPublicKey,
+ 'primaryIdentityPublicKey must be present during SIWE attempt',
+ );
+ const statement = getSIWEStatementForPublicKey(
+ siwePrimaryIdentityPublicKey,
+ );
signInWithEthereum(address, signer, siweNonce, statement);
}, [address, signer, siweNonce, siwePrimaryIdentityPublicKey]);
diff --git a/lib/utils/siwe-utils.js b/lib/utils/siwe-utils.js
--- a/lib/utils/siwe-utils.js
+++ b/lib/utils/siwe-utils.js
@@ -21,7 +21,7 @@
return primaryIdentityPublicKeyRegex.test(candidate);
}
-const siweStatementWithoutPublicKey: string =
+const siweStatementLegalAgreement: string =
'By continuing, I accept the Comm Terms of Service: https://comm.app/terms';
function createSIWEMessage(
@@ -59,10 +59,9 @@
// Verify that the SIWEMessage is a well formed Comm SIWE Auth message.
function isValidSIWEMessage(candidate: SIWEMessage): boolean {
return (
- (candidate.statement === siweStatementWithoutPublicKey ||
- (candidate.statement !== null &&
- candidate.statement !== undefined &&
- isValidSIWEStatementWithPublicKey(candidate.statement))) &&
+ candidate.statement !== null &&
+ candidate.statement !== undefined &&
+ isValidSIWEStatementWithPublicKey(candidate.statement) &&
candidate.version === '1' &&
candidate.chainId === 1 &&
isValidSIWEDomain(candidate.domain) &&
@@ -77,7 +76,7 @@
isValidPrimaryIdentityPublicKey(publicKey),
'publicKey must be well formed in getSIWEStatementForPublicKey',
);
- return `Device IdPubKey: ${publicKey} ${siweStatementWithoutPublicKey}`;
+ return `Device IdPubKey: ${publicKey} ${siweStatementLegalAgreement}`;
}
const siweStatementWithPublicKeyRegex =
@@ -110,7 +109,6 @@
`identity is represented by your new Comm identity.`;
export {
- siweStatementWithoutPublicKey,
isValidSIWENonce,
isValidEthereumAddress,
primaryIdentityPublicKeyRegex,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 4:19 AM (21 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2679355
Default Alt Text
D6826.id22908.diff (2 KB)
Attached To
Mode
D6826: [lib] Require `primaryIdentityPublicKey` in `SIWEStatement`
Attached
Detach File
Event Timeline
Log In to Comment