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 @@ -157,7 +157,7 @@ userID: string, sinceTimestamp?: number, ) => Promise<$ReadOnlyArray>; - +getDeviceListsForUsers?: ( + +getDeviceListsForUsers: ( userIDs: $ReadOnlyArray, ) => Promise; // updating device list is possible only on Native 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 @@ -28,6 +28,8 @@ userDeviceOlmInboundKeysValidator, type FarcasterUser, farcasterUsersValidator, + type UsersSignedDeviceLists, + usersSignedDeviceListsValidator, } from 'lib/types/identity-service-types.js'; import { getMessageForException } from 'lib/utils/errors.js'; import { assertWithValidator } from 'lib/utils/validation-utils.js'; @@ -533,6 +535,32 @@ ); }; + getDeviceListsForUsers: ( + userIDs: $ReadOnlyArray, + ) => Promise = async userIDs => { + const client = this.authClient; + if (!client) { + throw new Error('Identity service client is not initialized'); + } + const request = new IdentityAuthStructs.PeersDeviceListsRequest(); + request.setUserIdsList([...userIDs]); + const response = await client.getDeviceListsForUsers(request); + const rawPayloads = response.toObject()?.usersDeviceListsMap; + + let usersDeviceLists: UsersSignedDeviceLists = {}; + rawPayloads.forEach(([userID, rawPayload]) => { + usersDeviceLists = { + ...usersDeviceLists, + [userID]: JSON.parse(rawPayload), + }; + }); + + return assertWithValidator( + usersDeviceLists, + usersSignedDeviceListsValidator, + ); + }; + getFarcasterUsers: ( farcasterIDs: $ReadOnlyArray, ) => Promise<$ReadOnlyArray> = async farcasterIDs => { 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 @@ -134,6 +134,7 @@ getDeviceListHistoryForUser: proxyMethodToWorker( 'getDeviceListHistoryForUser', ), + getDeviceListsForUsers: proxyMethodToWorker('getDeviceListsForUsers'), getFarcasterUsers: proxyMethodToWorker('getFarcasterUsers'), linkFarcasterAccount: proxyMethodToWorker('linkFarcasterAccount'), unlinkFarcasterAccount: proxyMethodToWorker('unlinkFarcasterAccount'),