Page MenuHomePhabricator

D12034.id40165.diff
No OneTemporary

D12034.id40165.diff

diff --git a/lib/types/siwe-types.js b/lib/types/siwe-types.js
--- a/lib/types/siwe-types.js
+++ b/lib/types/siwe-types.js
@@ -128,7 +128,7 @@
+address: string,
+message: string,
+signature: string,
- +nonceTimestamp: number,
+ +nonceTimestamp: ?number,
};
export type IdentityWalletRegisterInput = {
diff --git a/native/account/fullscreen-siwe-panel.react.js b/native/account/fullscreen-siwe-panel.react.js
--- a/native/account/fullscreen-siwe-panel.react.js
+++ b/native/account/fullscreen-siwe-panel.react.js
@@ -192,7 +192,7 @@
onClosed={ifBeforeSuccessGoBackToPrompt}
onClosing={ifBeforeSuccessGoBackToPrompt}
onSuccessfulWalletSignature={onSuccess}
- siweMessageType={SIWEMessageTypes.MSG_AUTH}
+ siweSignatureRequestData={{ messageType: SIWEMessageTypes.MSG_AUTH }}
setLoading={setLoading}
/>
</>
diff --git a/native/account/registration/connect-ethereum.react.js b/native/account/registration/connect-ethereum.react.js
--- a/native/account/registration/connect-ethereum.react.js
+++ b/native/account/registration/connect-ethereum.react.js
@@ -196,7 +196,7 @@
onClosed={onPanelClosed}
closing={panelState === 'closing'}
onSuccessfulWalletSignature={onSuccessfulWalletSignature}
- siweMessageType={SIWEMessageTypes.MSG_AUTH}
+ siweSignatureRequestData={{ messageType: SIWEMessageTypes.MSG_AUTH }}
setLoading={siwePanelSetLoading}
keyserverCallParamOverride={serverCallParamOverride}
/>
@@ -204,8 +204,14 @@
}
const { ethereumAccount } = cachedSelections;
+ invariant(
+ !ethereumAccount || ethereumAccount.nonceTimestamp,
+ 'nonceTimestamp must be set after connecting to ethereum account',
+ );
const nonceExpired =
- ethereumAccount && siweNonceExpired(ethereumAccount.nonceTimestamp);
+ ethereumAccount &&
+ ethereumAccount.nonceTimestamp &&
+ siweNonceExpired(ethereumAccount.nonceTimestamp);
const alreadyHasConnected = !!ethereumAccount && !nonceExpired;
React.useEffect(() => {
if (nonceExpired) {
diff --git a/native/account/registration/connect-farcaster.react.js b/native/account/registration/connect-farcaster.react.js
--- a/native/account/registration/connect-farcaster.react.js
+++ b/native/account/registration/connect-farcaster.react.js
@@ -59,9 +59,14 @@
const goToNextStep = React.useCallback(
(fid?: ?string) => {
setWebViewState('closed');
-
+ invariant(
+ !ethereumAccount || ethereumAccount.nonceTimestamp,
+ 'nonceTimestamp must be set after connecting to ethereum account',
+ );
const nonceExpired =
- ethereumAccount && siweNonceExpired(ethereumAccount.nonceTimestamp);
+ ethereumAccount &&
+ ethereumAccount.nonceTimestamp &&
+ siweNonceExpired(ethereumAccount.nonceTimestamp);
if (nonceExpired) {
setCachedSelections(oldUserSelections => ({
...oldUserSelections,
diff --git a/native/account/registration/siwe-backup-message-creation.react.js b/native/account/registration/siwe-backup-message-creation.react.js
--- a/native/account/registration/siwe-backup-message-creation.react.js
+++ b/native/account/registration/siwe-backup-message-creation.react.js
@@ -57,7 +57,9 @@
onClosed={onPanelClosed}
closing={panelState === 'closing'}
onSuccessfulWalletSignature={onSuccessfulWalletSignature}
- siweMessageType={SIWEMessageTypes.MSG_BACKUP}
+ siweSignatureRequestData={{
+ messageType: SIWEMessageTypes.MSG_BACKUP,
+ }}
setLoading={siwePanelSetLoading}
/>
);
diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js
--- a/native/account/siwe-panel.react.js
+++ b/native/account/siwe-panel.react.js
@@ -1,7 +1,6 @@
// @flow
import BottomSheet from '@gorhom/bottom-sheet';
-import invariant from 'invariant';
import * as React from 'react';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import WebView from 'react-native-webview';
@@ -21,7 +20,7 @@
import type {
SIWEWebViewMessage,
SIWEResult,
- SIWEMessageType,
+ SIWESignatureRequestData,
} from 'lib/types/siwe-types.js';
import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -56,7 +55,7 @@
+onClosed: () => mixed,
+onClosing: () => mixed,
+onSuccessfulWalletSignature: SIWEResult => mixed,
- +siweMessageType: SIWEMessageType,
+ +siweSignatureRequestData: SIWESignatureRequestData,
+closing: boolean,
+setLoading: boolean => mixed,
+keyserverCallParamOverride?: Partial<ServerCallSelectorParams>,
@@ -77,7 +76,9 @@
);
const { onClosing } = props;
- const { siweMessageType } = props;
+ const {
+ siweSignatureRequestData: { messageType, messageToSign },
+ } = props;
const legacySiweAuthCallLoading = useSelector(
state => legacySiweAuthLoadingStatusSelector(state) === 'loading',
@@ -92,6 +93,9 @@
const nonceNotNeededRef = React.useRef(false);
React.useEffect(() => {
+ if (messageToSign) {
+ return;
+ }
if (nonceNotNeededRef.current) {
return;
}
@@ -139,6 +143,7 @@
getSIWENonceCall,
identityGenerateNonce,
onClosing,
+ messageToSign,
]);
const [isLoading, setLoading] = React.useState(true);
@@ -183,7 +188,6 @@
if (address && signature) {
nonceNotNeededRef.current = true;
closeBottomSheet?.();
- invariant(nonceTimestamp, 'nonceTimestamp should be set');
await onSuccessfulWalletSignature({
address,
message,
@@ -220,17 +224,23 @@
}, [closing, closeBottomSheet]);
const nonce = nonceInfo?.nonce;
- const source = React.useMemo(
- () => ({
- uri: commSIWE,
- headers: {
+ const source = React.useMemo(() => {
+ let headers;
+ if (messageToSign) {
+ headers = {
+ 'siwe-message-type': messageType,
+ 'siwe-message-to-sign': encodeURIComponent(messageToSign),
+ };
+ } else {
+ headers = {
'siwe-nonce': nonce,
'siwe-primary-identity-public-key': primaryIdentityPublicKey,
- 'siwe-message-type': siweMessageType,
- },
- }),
- [nonce, primaryIdentityPublicKey, siweMessageType],
- );
+ 'siwe-message-type': messageType,
+ };
+ }
+
+ return { uri: commSIWE, headers };
+ }, [nonce, primaryIdentityPublicKey, messageType, messageToSign]);
const onWebViewLoaded = React.useCallback(() => {
setLoading(false);
@@ -262,7 +272,7 @@
);
let bottomSheet;
- if (nonce && primaryIdentityPublicKey) {
+ if ((nonce && primaryIdentityPublicKey) || messageToSign) {
bottomSheet = (
<BottomSheet
snapPoints={snapPoints}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 12:42 AM (19 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609497
Default Alt Text
D12034.id40165.diff (6 KB)

Event Timeline