Page MenuHomePhabricator

D11834.diff
No OneTemporary

D11834.diff

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
@@ -1,6 +1,6 @@
// @flow
-import t, { type TInterface, type TList } from 'tcomb';
+import t, { type TInterface, type TList, type TDict } from 'tcomb';
import {
identityKeysBlobValidator,
@@ -157,6 +157,9 @@
userID: string,
sinceTimestamp?: number,
) => Promise<$ReadOnlyArray<SignedDeviceList>>;
+ +getDeviceListsForUsers?: (
+ userIDs: $ReadOnlyArray<string>,
+ ) => Promise<UsersSignedDeviceLists>;
// updating device list is possible only on Native
// web cannot be a primary device, so there's no need to expose it to JS
+updateDeviceList?: (newDeviceList: SignedDeviceList) => Promise<void>;
@@ -229,6 +232,12 @@
export const signedDeviceListHistoryValidator: TList<Array<SignedDeviceList>> =
t.list(signedDeviceListValidator);
+export type UsersSignedDeviceLists = {
+ +[userID: string]: SignedDeviceList,
+};
+export const usersSignedDeviceListsValidator: TDict<UsersSignedDeviceLists> =
+ t.dict(t.String, signedDeviceListValidator);
+
export type SignedNonce = {
+nonce: string,
+nonceSignature: 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
@@ -10,21 +10,23 @@
type OneTimeKeysResultValues,
} from 'lib/types/crypto-types.js';
import {
- type SignedDeviceList,
- signedDeviceListHistoryValidator,
- type SignedNonce,
+ type DeviceOlmInboundKeys,
+ deviceOlmInboundKeysValidator,
type DeviceOlmOutboundKeys,
deviceOlmOutboundKeysValidator,
+ farcasterUsersValidator,
+ identityAuthResultValidator,
type IdentityServiceClient,
- type UserDevicesOlmOutboundKeys,
- type UserAuthMetadata,
ONE_TIME_KEYS_NUMBER,
- identityAuthResultValidator,
- type DeviceOlmInboundKeys,
- type UserDevicesOlmInboundKeys,
- deviceOlmInboundKeysValidator,
+ type SignedDeviceList,
+ signedDeviceListHistoryValidator,
+ type SignedNonce,
+ type UserAuthMetadata,
userDeviceOlmInboundKeysValidator,
- farcasterUsersValidator,
+ type UserDevicesOlmInboundKeys,
+ type UserDevicesOlmOutboundKeys,
+ type UsersSignedDeviceLists,
+ usersSignedDeviceListsValidator,
} from 'lib/types/identity-service-types.js';
import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -545,6 +547,33 @@
signedDeviceListHistoryValidator,
);
},
+ getDeviceListsForUsers: async (userIDs: $ReadOnlyArray<string>) => {
+ const {
+ deviceID: authDeviceID,
+ userID: authUserID,
+ accessToken: token,
+ } = await getAuthMetadata();
+ const result = await commRustModule.getDeviceListsForUsers(
+ authUserID,
+ authDeviceID,
+ token,
+ userIDs,
+ );
+ const rawPayloads: { +[userID: string]: string } = JSON.parse(result);
+
+ let usersDeviceLists: UsersSignedDeviceLists = {};
+ for (const userID in rawPayloads) {
+ usersDeviceLists = {
+ ...usersDeviceLists,
+ [userID]: JSON.parse(rawPayloads[userID]),
+ };
+ }
+
+ return assertWithValidator(
+ usersDeviceLists,
+ usersSignedDeviceListsValidator,
+ );
+ },
updateDeviceList: async (newDeviceList: SignedDeviceList) => {
const {
deviceID: authDeviceID,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 1, 5:07 PM (21 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2399456
Default Alt Text
D11834.diff (3 KB)

Event Timeline