Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3398925
D12034.id40317.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D12034.id40317.diff
View Options
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
@@ -183,6 +183,11 @@
}
}, [goBackToPrompt]);
+ const siweSignatureRequestData = React.useMemo(
+ () => ({ messageType: SIWEMessageTypes.MSG_AUTH }),
+ [],
+ );
+
const { closing } = props;
return (
<>
@@ -192,7 +197,7 @@
onClosed={ifBeforeSuccessGoBackToPrompt}
onClosing={ifBeforeSuccessGoBackToPrompt}
onSuccessfulWalletSignature={onSuccess}
- siweMessageType={SIWEMessageTypes.MSG_AUTH}
+ siweSignatureRequestData={siweSignatureRequestData}
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
@@ -188,6 +188,13 @@
openPanel,
} = useSIWEPanelState();
+ const siweSignatureRequestData = React.useMemo(
+ () => ({
+ messageType: SIWEMessageTypes.MSG_AUTH,
+ }),
+ [],
+ );
+
let siwePanel;
if (panelState !== 'closed') {
siwePanel = (
@@ -196,7 +203,7 @@
onClosed={onPanelClosed}
closing={panelState === 'closing'}
onSuccessfulWalletSignature={onSuccessfulWalletSignature}
- siweMessageType={SIWEMessageTypes.MSG_AUTH}
+ siweSignatureRequestData={siweSignatureRequestData}
setLoading={siwePanelSetLoading}
keyserverCallParamOverride={serverCallParamOverride}
/>
@@ -204,8 +211,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
@@ -63,9 +63,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
@@ -49,6 +49,13 @@
siwePanelSetLoading,
} = useSIWEPanelState();
+ const siweSignatureRequestData = React.useMemo(
+ () => ({
+ messageType: SIWEMessageTypes.MSG_BACKUP,
+ }),
+ [],
+ );
+
let siwePanel;
if (panelState !== 'closed') {
siwePanel = (
@@ -57,7 +64,7 @@
onClosed={onPanelClosed}
closing={panelState === 'closing'}
onSuccessfulWalletSignature={onSuccessfulWalletSignature}
- siweMessageType={SIWEMessageTypes.MSG_BACKUP}
+ siweSignatureRequestData={siweSignatureRequestData}
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,11 +20,12 @@
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';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
+import { getPublicKeyFromSIWEStatement } from 'lib/utils/siwe-utils.js';
import { useKeyboardHeight } from '../keyboard/keyboard-hooks.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -49,14 +49,15 @@
type NonceInfo = {
+nonce: string,
- +nonceTimestamp: number,
+ +nonceTimestamp?: number,
+ +issuedAt?: string,
};
type Props = {
+onClosed: () => mixed,
+onClosing: () => mixed,
+onSuccessfulWalletSignature: SIWEResult => mixed,
- +siweMessageType: SIWEMessageType,
+ +siweSignatureRequestData: SIWESignatureRequestData,
+closing: boolean,
+setLoading: boolean => mixed,
+keyserverCallParamOverride?: Partial<ServerCallSelectorParams>,
@@ -77,7 +78,14 @@
);
const { onClosing } = props;
- const { siweMessageType } = props;
+ const {
+ siweSignatureRequestData: {
+ messageType,
+ siweNonce,
+ siweStatement,
+ siweIssuedAt,
+ },
+ } = props;
const legacySiweAuthCallLoading = useSelector(
state => legacySiweAuthLoadingStatusSelector(state) === 'loading',
@@ -92,6 +100,14 @@
const nonceNotNeededRef = React.useRef(false);
React.useEffect(() => {
+ if (siweNonce && siweStatement) {
+ setNonceInfo({ nonce: siweNonce, issuedAt: siweIssuedAt });
+ const siwePrimaryIdentityPublicKey =
+ getPublicKeyFromSIWEStatement(siweStatement);
+ setPrimaryIdentityPublicKey(siwePrimaryIdentityPublicKey);
+ nonceNotNeededRef.current = true;
+ return;
+ }
if (nonceNotNeededRef.current) {
return;
}
@@ -139,6 +155,9 @@
getSIWENonceCall,
identityGenerateNonce,
onClosing,
+ siweNonce,
+ siweStatement,
+ siweIssuedAt,
]);
const [isLoading, setLoading] = React.useState(true);
@@ -183,7 +202,6 @@
if (address && signature) {
nonceNotNeededRef.current = true;
closeBottomSheet?.();
- invariant(nonceTimestamp, 'nonceTimestamp should be set');
await onSuccessfulWalletSignature({
address,
message,
@@ -220,16 +238,18 @@
}, [closing, closeBottomSheet]);
const nonce = nonceInfo?.nonce;
+ const issuedAt = nonceInfo?.issuedAt;
const source = React.useMemo(
() => ({
uri: commSIWE,
headers: {
'siwe-nonce': nonce,
'siwe-primary-identity-public-key': primaryIdentityPublicKey,
- 'siwe-message-type': siweMessageType,
+ 'siwe-message-type': messageType,
+ 'siwe-message-issued-at': issuedAt,
},
}),
- [nonce, primaryIdentityPublicKey, siweMessageType],
+ [nonce, primaryIdentityPublicKey, messageType, issuedAt],
);
const onWebViewLoaded = React.useCallback(() => {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 1:02 AM (20 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609574
Default Alt Text
D12034.id40317.diff (7 KB)
Attached To
Mode
D12034: Change SIWE panel props to enable passing complete SIWE message
Attached
Detach File
Event Timeline
Log In to Comment