Page MenuHomePhabricator

D12809.diff
No OneTemporary

D12809.diff

diff --git a/keyserver/src/responders/keys-responders.js b/keyserver/src/responders/keys-responders.js
--- a/keyserver/src/responders/keys-responders.js
+++ b/keyserver/src/responders/keys-responders.js
@@ -5,7 +5,7 @@
import type {
OlmSessionInitializationInfo,
GetOlmSessionInitializationDataResponse,
-} from 'lib/types/request-types.js';
+} from 'lib/types/olm-session-types.js';
import { ServerError } from 'lib/utils/errors.js';
import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -62,7 +62,7 @@
RawMessageInfo,
MessageTruncationStatuses,
} from '../types/message-types.js';
-import type { GetOlmSessionInitializationDataResponse } from '../types/request-types.js';
+import type { GetOlmSessionInitializationDataResponse } from '../types/olm-session-types.js';
import type {
UserSearchResult,
ExactUserSearchResult,
diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js
--- a/lib/selectors/user-selectors.js
+++ b/lib/selectors/user-selectors.js
@@ -14,6 +14,10 @@
type AuxUserInfo,
} from '../types/aux-user-types.js';
import type { ClientEmojiAvatar } from '../types/avatar-types';
+import {
+ type IdentityPlatformDetails,
+ identityDeviceTypes,
+} from '../types/identity-service-types.js';
import type {
RelativeMemberInfo,
RawThreadInfo,
@@ -249,6 +253,45 @@
.flat(),
);
+export type DeviceIDAndPlatformDetails = {
+ +deviceID: string,
+ +platformDetails: ?IdentityPlatformDetails,
+};
+const getOwnPeerDevices: (
+ state: BaseAppState<>,
+) => $ReadOnlyArray<DeviceIDAndPlatformDetails> = createSelector(
+ (state: BaseAppState<>) => state.auxUserStore.auxUserInfos,
+ (state: BaseAppState<>) => state.currentUserInfo && state.currentUserInfo.id,
+ (
+ auxUserInfos: AuxUserInfos,
+ currentUserID: ?string,
+ ): $ReadOnlyArray<DeviceIDAndPlatformDetails> => {
+ if (!currentUserID) {
+ return [];
+ }
+ const devices = auxUserInfos[currentUserID]?.deviceList?.devices;
+ if (!devices) {
+ return [];
+ }
+ return devices.map(deviceID => ({
+ deviceID,
+ platformDetails:
+ auxUserInfos[currentUserID].devicesPlatformDetails?.[deviceID],
+ }));
+ },
+);
+
+function getKeyserverDeviceID(
+ devices: $ReadOnlyArray<DeviceIDAndPlatformDetails>,
+): ?string {
+ const keyserverDevice = devices.find(
+ device =>
+ device.platformDetails?.deviceType === identityDeviceTypes.KEYSERVER,
+ );
+
+ return keyserverDevice ? keyserverDevice.deviceID : null;
+}
+
const getAllPeerDevices: (state: BaseAppState<>) => $ReadOnlyArray<string> =
createSelector(
(state: BaseAppState<>) => state.auxUserStore.auxUserInfos,
@@ -297,6 +340,8 @@
getRelativeUserIDs,
usersWithMissingDeviceListSelector,
getForeignPeerDevices,
+ getOwnPeerDevices,
+ getKeyserverDeviceID,
getAllPeerDevices,
getAllPeerUserIDAndDeviceIDs,
getOwnPrimaryDeviceID,
diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js
--- a/lib/types/crypto-types.js
+++ b/lib/types/crypto-types.js
@@ -2,7 +2,7 @@
import t, { type TInterface } from 'tcomb';
-import type { OlmSessionInitializationInfo } from './request-types.js';
+import type { OlmSessionInitializationInfo } from './olm-session-types.js';
import { type AuthMetadata } from '../shared/identity-client-context.js';
import { tShape } from '../utils/validation-utils.js';
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
@@ -14,7 +14,7 @@
import {
type OlmSessionInitializationInfo,
olmSessionInitializationInfoValidator,
-} from './request-types.js';
+} from './olm-session-types.js';
import {
currentUserInfoValidator,
type CurrentUserInfo,
diff --git a/lib/types/olm-session-types.js b/lib/types/olm-session-types.js
new file mode 100644
--- /dev/null
+++ b/lib/types/olm-session-types.js
@@ -0,0 +1,33 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import {
+ signedIdentityKeysBlobValidator,
+ type SignedIdentityKeysBlob,
+} from './crypto-types.js';
+import { tShape } from '../utils/validation-utils.js';
+
+export type OlmSessionInitializationInfo = {
+ +prekey: string,
+ +prekeySignature: string,
+ +oneTimeKey: ?string,
+};
+export const olmSessionInitializationInfoValidator: TInterface<OlmSessionInitializationInfo> =
+ tShape<OlmSessionInitializationInfo>({
+ prekey: t.String,
+ prekeySignature: t.String,
+ oneTimeKey: t.maybe(t.String),
+ });
+
+export type GetOlmSessionInitializationDataResponse = {
+ +signedIdentityKeysBlob: SignedIdentityKeysBlob,
+ +contentInitializationInfo: OlmSessionInitializationInfo,
+ +notifInitializationInfo: OlmSessionInitializationInfo,
+};
+export const getOlmSessionInitializationDataResponseValidator: TInterface<GetOlmSessionInitializationDataResponse> =
+ tShape({
+ signedIdentityKeysBlob: signedIdentityKeysBlobValidator,
+ contentInitializationInfo: olmSessionInitializationInfoValidator,
+ notifInitializationInfo: olmSessionInitializationInfoValidator,
+ });
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -103,6 +103,7 @@
import type { RawReactionMessageInfo } from './messages/reaction.js';
import type { RawTextMessageInfo } from './messages/text.js';
import type { BaseNavInfo, WebNavInfo } from './nav-types.js';
+import type { GetOlmSessionInitializationDataResponse } from './olm-session-types.js';
import {
type ForcePolicyAcknowledgmentPayload,
type PolicyAcknowledgmentPayload,
@@ -115,10 +116,7 @@
QueueReportsPayload,
ReportStore,
} from './report-types.js';
-import type {
- ProcessServerRequestAction,
- GetOlmSessionInitializationDataResponse,
-} from './request-types.js';
+import type { ProcessServerRequestAction } from './request-types.js';
import type {
UserSearchResult,
ExactUserSearchResult,
diff --git a/lib/types/request-types.js b/lib/types/request-types.js
--- a/lib/types/request-types.js
+++ b/lib/types/request-types.js
@@ -325,30 +325,6 @@
+payload: ProcessServerRequestsPayload,
};
-export type OlmSessionInitializationInfo = {
- +prekey: string,
- +prekeySignature: string,
- +oneTimeKey: ?string,
-};
-export const olmSessionInitializationInfoValidator: TInterface<OlmSessionInitializationInfo> =
- tShape<OlmSessionInitializationInfo>({
- prekey: t.String,
- prekeySignature: t.String,
- oneTimeKey: t.maybe(t.String),
- });
-
-export type GetOlmSessionInitializationDataResponse = {
- +signedIdentityKeysBlob: SignedIdentityKeysBlob,
- +contentInitializationInfo: OlmSessionInitializationInfo,
- +notifInitializationInfo: OlmSessionInitializationInfo,
-};
-export const getOlmSessionInitializationDataResponseValidator: TInterface<GetOlmSessionInitializationDataResponse> =
- tShape({
- signedIdentityKeysBlob: signedIdentityKeysBlobValidator,
- contentInitializationInfo: olmSessionInitializationInfoValidator,
- notifInitializationInfo: olmSessionInitializationInfoValidator,
- });
-
export const clientResponseInputValidator: TUnion<ClientResponse> = t.union([
platformClientResponseValidator,
threadInconsistencyClientResponseValidator,
diff --git a/lib/types/validators/endpoint-validators.js b/lib/types/validators/endpoint-validators.js
--- a/lib/types/validators/endpoint-validators.js
+++ b/lib/types/validators/endpoint-validators.js
@@ -61,7 +61,7 @@
} from '../activity-types.js';
import { inviteLinkValidator } from '../link-types.js';
import { uploadMultimediaResultValidator } from '../media-types.js';
-import { getOlmSessionInitializationDataResponseValidator } from '../request-types.js';
+import { getOlmSessionInitializationDataResponseValidator } from '../olm-session-types.js';
import { serverStateSyncSocketPayloadValidator } from '../socket-types.js';
const sessionChangingEndpoints = Object.freeze({
diff --git a/native/crypto/olm-api.js b/native/crypto/olm-api.js
--- a/native/crypto/olm-api.js
+++ b/native/crypto/olm-api.js
@@ -9,7 +9,7 @@
type EncryptedData,
type OutboundSessionCreationResult,
} from 'lib/types/crypto-types.js';
-import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
+import type { OlmSessionInitializationInfo } from 'lib/types/olm-session-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { commCoreModule } from '../native-modules.js';
diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -23,7 +23,7 @@
IdentityNewDeviceKeyUpload,
IdentityExistingDeviceKeyUpload,
} from 'lib/types/identity-service-types.js';
-import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
+import type { OlmSessionInitializationInfo } from 'lib/types/olm-session-types.js';
import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { entries } from 'lib/utils/objects.js';

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 1:06 PM (17 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2561425
Default Alt Text
D12809.diff (9 KB)

Event Timeline