Page MenuHomePhabricator

D10748.id35903.diff
No OneTemporary

D10748.id35903.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
@@ -31,15 +31,15 @@
+oneTimeNotifPrekey: ?string,
};
-export type KeyserverKeys = {
+export type DeviceOlmOutboundKeys = {
+identityKeysBlob: IdentityKeysBlob,
+contentInitializationInfo: OlmSessionInitializationInfo,
+notifInitializationInfo: OlmSessionInitializationInfo,
+payloadSignature: string,
+socialProof: ?string,
};
-export const keyserverKeysValidator: TInterface<KeyserverKeys> =
- tShape<KeyserverKeys>({
+export const deviceOlmOutboundKeysValidator: TInterface<DeviceOlmOutboundKeys> =
+ tShape<DeviceOlmOutboundKeys>({
identityKeysBlob: identityKeysBlobValidator,
contentInitializationInfo: olmSessionInitializationInfoValidator,
notifInitializationInfo: olmSessionInitializationInfoValidator,
@@ -49,7 +49,7 @@
export interface IdentityServiceClient {
+deleteUser: () => Promise<void>;
- +getKeyserverKeys: string => Promise<KeyserverKeys>;
+ +getKeyserverKeys: string => Promise<DeviceOlmOutboundKeys>;
+registerUser?: (
username: string,
password: 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
@@ -7,8 +7,8 @@
import {
type IdentityServiceClient,
type UserLoginResponse,
- type KeyserverKeys,
- keyserverKeysValidator,
+ type DeviceOlmOutboundKeys,
+ deviceOlmOutboundKeysValidator,
} from 'lib/types/identity-service-types.js';
import { ONE_TIME_KEYS_NUMBER } from 'lib/types/identity-service-types.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -70,7 +70,9 @@
const { deviceID, userID, accessToken } = await getAuthMetadata();
return commRustModule.deleteUser(userID, deviceID, accessToken);
},
- getKeyserverKeys: async (keyserverID: string): Promise<KeyserverKeys> => {
+ getKeyserverKeys: async (
+ keyserverID: string,
+ ): Promise<DeviceOlmOutboundKeys> => {
const { deviceID, userID, accessToken } = await getAuthMetadata();
const result = await commRustModule.getKeyserverKeys(
userID,
@@ -104,7 +106,10 @@
throw new Error('Missing notif one time key');
}
- return assertWithValidator(keyserverKeys, keyserverKeysValidator);
+ return assertWithValidator(
+ keyserverKeys,
+ deviceOlmOutboundKeysValidator,
+ );
},
registerUser: async (username: string, password: string) => {
await commCoreModule.initializeCryptoAccount();
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
@@ -4,8 +4,8 @@
import {
type IdentityServiceAuthLayer,
type IdentityServiceClient,
- type KeyserverKeys,
- keyserverKeysValidator,
+ type DeviceOlmOutboundKeys,
+ deviceOlmOutboundKeysValidator,
} from 'lib/types/identity-service-types.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -81,49 +81,48 @@
await this.authClient.deleteUser(new Empty());
};
- getKeyserverKeys: (keyserverID: string) => Promise<KeyserverKeys> = async (
- keyserverID: string,
- ) => {
- const client = this.authClient;
- if (!client) {
- throw new Error('Identity service client is not initialized');
- }
-
- const request = new IdentityAuthStructs.OutboundKeysForUserRequest();
- request.setUserId(keyserverID);
- const response = await client.getKeyserverKeys(request);
-
- const keyserverInfo = response.getKeyserverInfo();
- const identityInfo = keyserverInfo?.getIdentityInfo();
- const contentPreKey = keyserverInfo?.getContentPrekey();
- const notifPreKey = keyserverInfo?.getNotifPrekey();
- const payload = identityInfo?.getPayload();
-
- const keyserverKeys = {
- identityKeysBlob: payload ? JSON.parse(payload) : null,
- contentInitializationInfo: {
- prekey: contentPreKey?.getPrekey(),
- prekeySignature: contentPreKey?.getPrekeySignature(),
- oneTimeKey: keyserverInfo?.getOneTimeContentPrekey(),
- },
- notifInitializationInfo: {
- prekey: notifPreKey?.getPrekey(),
- prekeySignature: notifPreKey?.getPrekeySignature(),
- oneTimeKey: keyserverInfo?.getOneTimeNotifPrekey(),
- },
- payloadSignature: identityInfo?.getPayloadSignature(),
- socialProof: identityInfo?.getSocialProof(),
+ getKeyserverKeys: (keyserverID: string) => Promise<DeviceOlmOutboundKeys> =
+ async (keyserverID: string) => {
+ const client = this.authClient;
+ if (!client) {
+ throw new Error('Identity service client is not initialized');
+ }
+
+ const request = new IdentityAuthStructs.OutboundKeysForUserRequest();
+ request.setUserId(keyserverID);
+ const response = await client.getKeyserverKeys(request);
+
+ const keyserverInfo = response.getKeyserverInfo();
+ const identityInfo = keyserverInfo?.getIdentityInfo();
+ const contentPreKey = keyserverInfo?.getContentPrekey();
+ const notifPreKey = keyserverInfo?.getNotifPrekey();
+ const payload = identityInfo?.getPayload();
+
+ const keyserverKeys = {
+ identityKeysBlob: payload ? JSON.parse(payload) : null,
+ contentInitializationInfo: {
+ prekey: contentPreKey?.getPrekey(),
+ prekeySignature: contentPreKey?.getPrekeySignature(),
+ oneTimeKey: keyserverInfo?.getOneTimeContentPrekey(),
+ },
+ notifInitializationInfo: {
+ prekey: notifPreKey?.getPrekey(),
+ prekeySignature: notifPreKey?.getPrekeySignature(),
+ oneTimeKey: keyserverInfo?.getOneTimeNotifPrekey(),
+ },
+ payloadSignature: identityInfo?.getPayloadSignature(),
+ socialProof: identityInfo?.getSocialProof(),
+ };
+
+ if (!keyserverKeys.contentInitializationInfo.oneTimeKey) {
+ throw new Error('Missing content one time key');
+ }
+ if (!keyserverKeys.notifInitializationInfo.oneTimeKey) {
+ throw new Error('Missing notif one time key');
+ }
+
+ return assertWithValidator(keyserverKeys, deviceOlmOutboundKeysValidator);
};
-
- if (!keyserverKeys.contentInitializationInfo.oneTimeKey) {
- throw new Error('Missing content one time key');
- }
- if (!keyserverKeys.notifInitializationInfo.oneTimeKey) {
- throw new Error('Missing notif one time key');
- }
-
- return assertWithValidator(keyserverKeys, keyserverKeysValidator);
- };
}
export { IdentityServiceClientWrapper };

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 5:41 PM (10 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2701582
Default Alt Text
D10748.id35903.diff (6 KB)

Event Timeline