Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32555857
D11290.1767209114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D11290.1767209114.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
@@ -1,6 +1,6 @@
// @flow
-import t, { type TInterface } from 'tcomb';
+import t, { type TInterface, type TList } from 'tcomb';
import {
identityKeysBlobValidator,
@@ -128,6 +128,13 @@
// on native, publishing prekeys to Identity is called directly from C++,
// there is no need to expose it to JS
+publishWebPrekeys?: (prekeys: SignedPrekeys) => Promise<void>;
+ +getDeviceListHistoryForUser: (
+ userID: string,
+ sinceTimestamp?: number,
+ ) => Promise<$ReadOnlyArray<SignedDeviceList>>;
+ // 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>;
}
export type IdentityServiceAuthLayer = {
@@ -159,6 +166,24 @@
+notifOneTimeKeys: $ReadOnlyArray<string>,
};
+// Device list types
+
+export type RawDeviceList = {
+ +devices: $ReadOnlyArray<string>,
+ +timestamp: number,
+};
+
+export type SignedDeviceList = {
+ // JSON-stringified RawDeviceList
+ +rawDeviceList: string,
+};
+export const signedDeviceListValidator: TInterface<SignedDeviceList> =
+ tShape<SignedDeviceList>({
+ rawDeviceList: t.String,
+ });
+export const signedDeviceListHistoryValidator: TList<Array<SignedDeviceList>> =
+ t.list(signedDeviceListValidator);
+
export const ONE_TIME_KEYS_NUMBER = 10;
export const identityDeviceTypes = Object.freeze({
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,6 +10,8 @@
type OneTimeKeysResultValues,
} from 'lib/types/crypto-types.js';
import {
+ type SignedDeviceList,
+ signedDeviceListHistoryValidator,
type DeviceOlmOutboundKeys,
deviceOlmOutboundKeysValidator,
type IdentityServiceClient,
@@ -449,6 +451,45 @@
return validatedResult;
},
generateNonce: commRustModule.generateNonce,
+ getDeviceListHistoryForUser: async (
+ userID: string,
+ sinceTimestamp?: number,
+ ) => {
+ const {
+ deviceID: authDeviceID,
+ userID: authUserID,
+ accessToken: token,
+ } = await getAuthMetadata();
+ const result = await commRustModule.getDeviceListForUser(
+ authUserID,
+ authDeviceID,
+ token,
+ userID,
+ sinceTimestamp,
+ );
+ const rawPayloads: string[] = JSON.parse(result);
+ const deviceLists: SignedDeviceList[] = rawPayloads.map(payload =>
+ JSON.parse(payload),
+ );
+ return assertWithValidator(
+ deviceLists,
+ signedDeviceListHistoryValidator,
+ );
+ },
+ updateDeviceList: async (newDeviceList: SignedDeviceList) => {
+ const {
+ deviceID: authDeviceID,
+ userID,
+ accessToken: authAccessToken,
+ } = await getAuthMetadata();
+ const payload = JSON.stringify(newDeviceList);
+ await commRustModule.updateDeviceList(
+ userID,
+ authDeviceID,
+ authAccessToken,
+ payload,
+ );
+ },
}),
[getAuthMetadata],
);
diff --git a/web/grpc/identity-service-client-proxy.js b/web/grpc/identity-service-client-proxy.js
--- a/web/grpc/identity-service-client-proxy.js
+++ b/web/grpc/identity-service-client-proxy.js
@@ -5,6 +5,7 @@
SignedPrekeys,
} from 'lib/types/crypto-types.js';
import type {
+ SignedDeviceList,
IdentityServiceClient,
IdentityServiceAuthLayer,
DeviceOlmOutboundKeys,
@@ -104,6 +105,13 @@
publishWebPrekeys: (prekeys: SignedPrekeys) => Promise<void> =
this.proxyToWorker('publishWebPrekeys');
+
+ getDeviceListHistoryForUser: (
+ userID: string,
+ sinceTimestamp?: number,
+ ) => Promise<$ReadOnlyArray<SignedDeviceList>> = this.proxyToWorker(
+ 'getDeviceListHistoryForUser',
+ );
}
export { IdentityServiceClientSharedProxy };
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
@@ -9,6 +9,8 @@
} from 'lib/types/crypto-types.js';
import type { PlatformDetails } from 'lib/types/device-types.js';
import {
+ type SignedDeviceList,
+ signedDeviceListHistoryValidator,
type IdentityServiceAuthLayer,
type IdentityServiceClient,
type DeviceOlmOutboundKeys,
@@ -447,6 +449,33 @@
request.setNewNotifPrekeys(notifPrekeyUpload);
await client.refreshUserPrekeys(request);
};
+
+ getDeviceListHistoryForUser: (
+ userID: string,
+ sinceTimestamp?: number,
+ ) => Promise<$ReadOnlyArray<SignedDeviceList>> = async (
+ userID,
+ sinceTimestamp,
+ ) => {
+ const client = this.authClient;
+ if (!client) {
+ throw new Error('Identity service client is not initialized');
+ }
+ const request = new IdentityAuthStructs.GetDeviceListRequest();
+ request.setUserId(userID);
+ if (sinceTimestamp) {
+ request.setSinceTimestamp(sinceTimestamp);
+ }
+ const response = await client.getDeviceListForUser(request);
+ const rawPayloads = response.getDeviceListUpdatesList();
+ const deviceListUpdates: SignedDeviceList[] = rawPayloads.map(payload =>
+ JSON.parse(payload),
+ );
+ return assertWithValidator(
+ deviceListUpdates,
+ signedDeviceListHistoryValidator,
+ );
+ };
}
function authDeviceKeyUpload(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 31, 7:25 PM (3 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5874323
Default Alt Text
D11290.1767209114.diff (5 KB)
Attached To
Mode
D11290: [native][web] Expose Device List RPCs to JS
Attached
Detach File
Event Timeline
Log In to Comment