Page MenuHomePhabricator

D6306.id21059.diff
No OneTemporary

D6306.id21059.diff

diff --git a/landing/package.json b/landing/package.json
--- a/landing/package.json
+++ b/landing/package.json
@@ -59,7 +59,6 @@
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-text-loop": "^2.3.0",
- "siwe": "^1.1.6",
"wagmi": "^0.6.0"
}
}
diff --git a/landing/siwe.react.js b/landing/siwe.react.js
--- a/landing/siwe.react.js
+++ b/landing/siwe.react.js
@@ -11,7 +11,6 @@
import invariant from 'invariant';
import _merge from 'lodash/fp/merge';
import * as React from 'react';
-import { SiweMessage } from 'siwe';
import '@rainbow-me/rainbowkit/dist/index.css';
import {
useAccount,
@@ -28,6 +27,7 @@
import {
getSIWEStatementForPublicKey,
siweStatementWithoutPublicKey,
+ createSIWEMessage,
} from 'lib/utils/siwe-utils.js';
import { SIWEContext } from './siwe-context.js';
@@ -53,22 +53,6 @@
provider,
});
-function createSiweMessage(address: string, statement: string, nonce: string) {
- invariant(nonce, 'nonce must be present in createSiweMessage');
- const domain = window.location.host;
- const origin = window.location.origin;
- const message = new SiweMessage({
- domain,
- address,
- statement,
- uri: origin,
- version: '1',
- chainId: '1',
- nonce,
- });
- return message.prepareMessage();
-}
-
function postMessageToNativeWebView(message: SIWEWebViewMessage) {
window.ReactNativeWebView?.postMessage?.(JSON.stringify(message));
}
@@ -80,7 +64,7 @@
statement: string,
) {
invariant(nonce, 'nonce must be present in signInWithEthereum');
- const message = createSiweMessage(address, statement, nonce);
+ const message = createSIWEMessage(address, statement, nonce);
const signature = await signer.signMessage(message);
postMessageToNativeWebView({
type: 'siwe_success',
diff --git a/lib/package.json b/lib/package.json
--- a/lib/package.json
+++ b/lib/package.json
@@ -39,6 +39,7 @@
"simple-markdown": "^0.7.2",
"string-hash": "^1.1.3",
"tcomb": "^3.2.29",
+ "siwe": "^1.1.6",
"tinycolor2": "^1.4.1",
"tokenize-text": "^1.1.3",
"url-parse-lax": "^3.0.0",
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
@@ -1,6 +1,7 @@
// @flow
import invariant from 'invariant';
+import { SiweMessage } from 'siwe';
import type { SIWEMessage } from '../types/siwe-types.js';
import { isDev } from './dev-utils.js';
@@ -23,9 +24,28 @@
const siweStatementWithoutPublicKey: string =
'By continuing, I accept the Comm Terms of Service: https://comm.app/terms';
+function createSIWEMessage(
+ address: string,
+ statement: string,
+ nonce: string,
+): string {
+ invariant(nonce, 'nonce must be present in createSiweMessage');
+ const domain = window.location.host;
+ const origin = window.location.origin;
+ const message = new SiweMessage({
+ domain,
+ address,
+ statement,
+ uri: origin,
+ version: '1',
+ chainId: '1',
+ nonce,
+ });
+ return message.prepareMessage();
+}
+
const expectedDomain = isDev ? 'localhost:3000' : 'comm.app';
const expectedURI = isDev ? 'http://localhost:3000' : 'https://comm.app';
-
// Verify that the SIWEMessage is a well formed Comm SIWE Auth message.
function isValidSIWEMessage(candidate: SIWEMessage): boolean {
return (
@@ -76,6 +96,7 @@
isValidSIWENonce,
isValidEthereumAddress,
isValidPrimaryIdentityPublicKey,
+ createSIWEMessage,
isValidSIWEMessage,
getSIWEStatementForPublicKey,
isValidSIWEStatementWithPublicKey,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 7:34 AM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496811
Default Alt Text
D6306.id21059.diff (3 KB)

Event Timeline