Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3380016
D11494.id38604.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
D11494.id38604.diff
View Options
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -457,6 +457,7 @@
function useIdentityPasswordRegister(): (
username: string,
password: string,
+ fid: ?string,
) => Promise<IdentityAuthResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
@@ -470,6 +471,7 @@
walletAddress: string,
siweMessage: string,
siweSignature: string,
+ fid: ?string,
) => Promise<IdentityAuthResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
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
@@ -129,3 +129,10 @@
+message: string,
+signature: string,
};
+
+export type IdentityWalletRegisterInput = {
+ +address: string,
+ +message: string,
+ +signature: string,
+ +fid?: ?string,
+};
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -1,5 +1,6 @@
// @flow
+import invariant from 'invariant';
import * as React from 'react';
import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js';
@@ -9,6 +10,7 @@
useIdentityPasswordRegister,
identityRegisterActionTypes,
} from 'lib/actions/user-actions.js';
+import { FIDContext } from 'lib/components/fid-provider.react.js';
import type { LogInStartingPayload } from 'lib/types/account-types.js';
import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -73,13 +75,21 @@
const callKeyserverRegister = useLegacyAshoatKeyserverCall(keyserverRegister);
const callIdentityPasswordRegister = useIdentityPasswordRegister();
+ const fidContext = React.useContext(FIDContext);
+ invariant(fidContext, 'FIDContext is missing');
+ const { setFID } = fidContext;
+
const identityRegisterUsernameAccount = React.useCallback(
- async (accountSelection: UsernameAccountSelection) => {
+ async (
+ accountSelection: UsernameAccountSelection,
+ farcasterID: ?string,
+ ) => {
const identityRegisterPromise = (async () => {
try {
const result = await callIdentityPasswordRegister(
accountSelection.username,
accountSelection.password,
+ farcasterID,
);
await setNativeCredentials({
username: accountSelection.username,
@@ -191,7 +201,8 @@
if (currentStep.step !== 'inactive') {
return;
}
- const { accountSelection, avatarData, keyserverURL } = input;
+ const { accountSelection, avatarData, keyserverURL, farcasterID } =
+ input;
if (
accountSelection.accountType === 'username' &&
!usingCommServicesAccessToken
@@ -201,7 +212,10 @@
keyserverURL,
);
} else if (accountSelection.accountType === 'username') {
- await identityRegisterUsernameAccount(accountSelection);
+ await identityRegisterUsernameAccount(
+ accountSelection,
+ farcasterID,
+ );
} else if (!usingCommServicesAccessToken) {
try {
await legacySiweServerCall(accountSelection, {
@@ -220,6 +234,7 @@
address: accountSelection.address,
message: accountSelection.message,
signature: accountSelection.signature,
+ fid: farcasterID,
});
} catch (e) {
Alert.alert(
@@ -233,6 +248,7 @@
type: setURLPrefix,
payload: keyserverURL,
});
+ setFID(farcasterID);
setCurrentStep({
step: 'waiting_for_registration_call',
avatarData,
@@ -251,6 +267,7 @@
legacySiweServerCall,
dispatch,
identityWalletRegisterCall,
+ setFID,
],
);
diff --git a/native/account/siwe-hooks.js b/native/account/siwe-hooks.js
--- a/native/account/siwe-hooks.js
+++ b/native/account/siwe-hooks.js
@@ -14,7 +14,10 @@
LogInStartingPayload,
LogInExtraInfo,
} from 'lib/types/account-types.js';
-import type { SIWEResult } from 'lib/types/siwe-types.js';
+import type {
+ SIWEResult,
+ IdentityWalletRegisterInput,
+} from 'lib/types/siwe-types.js';
import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js';
import type { CallSingleKeyserverEndpointOptions } from 'lib/utils/call-single-keyserver-endpoint.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -113,12 +116,17 @@
);
}
-function useIdentityWalletRegisterCall(): SIWEResult => Promise<void> {
+function useIdentityWalletRegisterCall(): IdentityWalletRegisterInput => Promise<void> {
const identityWalletRegister = useIdentityWalletRegister();
const dispatchActionPromise = useDispatchActionPromise();
return React.useCallback(
- async ({ address, message, signature }) => {
- const siwePromise = identityWalletRegister(address, message, signature);
+ async ({ address, message, signature, fid }) => {
+ const siwePromise = identityWalletRegister(
+ address,
+ message,
+ signature,
+ fid,
+ );
void dispatchActionPromise(identityRegisterActionTypes, siwePromise);
await siwePromise;
diff --git a/native/identity-service/identity-service-context-provider.react.js b/native/identity-service/identity-service-context-provider.react.js
--- a/native/identity-service/identity-service-context-provider.react.js
+++ b/native/identity-service/identity-service-context-provider.react.js
@@ -296,7 +296,11 @@
oneTimeKeys.notificationsOneTimeKeys,
);
},
- registerPasswordUser: async (username: string, password: string) => {
+ registerPasswordUser: async (
+ username: string,
+ password: string,
+ fid: ?string,
+ ) => {
await commCoreModule.initializeCryptoAccount();
const [
{ blobPayload, signature, primaryIdentityPublicKeys },
@@ -318,7 +322,7 @@
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
- '',
+ fid ?? '',
);
const { userID, accessToken: token } = JSON.parse(registrationResult);
const identityAuthResult = { accessToken: token, userID, username };
@@ -373,6 +377,7 @@
walletAddress: string,
siweMessage: string,
siweSignature: string,
+ fid: ?string,
) => {
await commCoreModule.initializeCryptoAccount();
const [
@@ -395,7 +400,7 @@
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
- '',
+ fid ?? '',
);
const { userID, accessToken: token } = JSON.parse(registrationResult);
const identityAuthResult = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 8:34 PM (20 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594845
Default Alt Text
D11494.id38604.diff (7 KB)
Attached To
Mode
D11494: [lib][native] Update useRegistrationServerCall to set FID in FIDContext
Attached
Detach File
Event Timeline
Log In to Comment