Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3389125
D12000.id40256.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12000.id40256.diff
View Options
diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js
--- a/lib/types/identity-service-types.js
+++ b/lib/types/identity-service-types.js
@@ -172,6 +172,7 @@
) => Promise<$ReadOnlyArray<FarcasterUser>>;
+linkFarcasterAccount: (farcasterID: string) => Promise<void>;
+unlinkFarcasterAccount: () => Promise<void>;
+ +findUserIdentities: (userIDs: $ReadOnlyArray<string>) => Promise<Identities>;
}
export type IdentityServiceAuthLayer = {
@@ -230,6 +231,37 @@
+[userID: string]: RawDeviceList,
};
+// User Identity types
+
+export type EthereumIdentity = {
+ walletAddress: string,
+ siweMessage: string,
+ siweSignature: string,
+};
+export type Identity = {
+ +username: string,
+ +ethIdentity: ?EthereumIdentity,
+ +farcasterID: ?string,
+};
+export type Identities = {
+ +[userID: string]: Identity,
+};
+export const ethereumIdentityValidator: TInterface<EthereumIdentity> =
+ tShape<EthereumIdentity>({
+ walletAddress: t.String,
+ siweMessage: t.String,
+ siweSignature: t.String,
+ });
+export const identityValidator: TInterface<Identity> = tShape<Identity>({
+ username: t.String,
+ ethIdentity: t.maybe(ethereumIdentityValidator),
+ farcasterID: t.maybe(t.String),
+});
+export const identitiesValidator: TDict<Identities> = t.dict(
+ t.String,
+ identityValidator,
+);
+
export type SignedDeviceList = {
// JSON-stringified RawDeviceList
+rawDeviceList: string,
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
@@ -27,6 +27,7 @@
type UserDevicesOlmOutboundKeys,
type UsersSignedDeviceLists,
usersSignedDeviceListsValidator,
+ identitiesValidator,
} from 'lib/types/identity-service-types.js';
import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -615,6 +616,21 @@
} = await getAuthMetadata();
return commRustModule.unlinkFarcasterAccount(userID, deviceID, token);
},
+ findUserIdentities: async (userIDs: $ReadOnlyArray<string>) => {
+ const {
+ deviceID,
+ userID,
+ accessToken: token,
+ } = await getAuthMetadata();
+ const result = await commRustModule.findUserIdentities(
+ userID,
+ deviceID,
+ token,
+ userIDs,
+ );
+ const identities = JSON.parse(result);
+ return assertWithValidator(identities, identitiesValidator);
+ },
}),
[getAuthMetadata],
);
diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js
--- a/web/grpc/identity-service-client-wrapper.js
+++ b/web/grpc/identity-service-client-wrapper.js
@@ -30,6 +30,8 @@
farcasterUsersValidator,
type UsersSignedDeviceLists,
usersSignedDeviceListsValidator,
+ type Identities,
+ identitiesValidator,
} from 'lib/types/identity-service-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -615,6 +617,32 @@
}
await client.unlinkFarcasterAccount(new Empty());
};
+
+ findUserIdentities: (userIDs: $ReadOnlyArray<string>) => Promise<Identities> =
+ async userIDs => {
+ const client = this.authClient;
+ if (!client) {
+ throw new Error('Identity service client is not initialized');
+ }
+ const request = new IdentityAuthStructs.UserIdentitiesRequest();
+ request.setUserIdsList([...userIDs]);
+ const response = await client.findUserIdentities(request);
+ const identityObjects = response.toObject()?.identitiesMap;
+
+ let identities: Identities = {};
+ identityObjects.forEach(([userID, identityObject]) => {
+ identities = {
+ ...identities,
+ [userID]: {
+ ethIdentity: identityObject.ethIdentity,
+ username: identityObject.username,
+ farcasterID: identityObject.farcasterId,
+ },
+ };
+ });
+
+ return assertWithValidator(identities, identitiesValidator);
+ };
}
function authNewDeviceKeyUpload(
diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js
--- a/web/grpc/identity-service-context-provider.react.js
+++ b/web/grpc/identity-service-context-provider.react.js
@@ -138,6 +138,7 @@
getFarcasterUsers: proxyMethodToWorker('getFarcasterUsers'),
linkFarcasterAccount: proxyMethodToWorker('linkFarcasterAccount'),
unlinkFarcasterAccount: proxyMethodToWorker('unlinkFarcasterAccount'),
+ findUserIdentities: proxyMethodToWorker('findUserIdentities'),
};
}, [proxyMethodToWorker]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 5:39 PM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2601529
Default Alt Text
D12000.id40256.diff (4 KB)
Attached To
Mode
D12000: [native/web] make `findUserIdentities` RPC available to native and web
Attached
Detach File
Event Timeline
Log In to Comment