Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3406342
D12900.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12900.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
@@ -327,13 +327,23 @@
export const identityDeviceTypeToPlatform: {
+[identityDeviceType: IdentityDeviceType]: Platform,
-} = {
+} = Object.freeze({
[identityDeviceTypes.WEB]: 'web',
[identityDeviceTypes.ANDROID]: 'android',
[identityDeviceTypes.IOS]: 'ios',
[identityDeviceTypes.WINDOWS]: 'windows',
[identityDeviceTypes.MAC_OS]: 'macos',
-};
+});
+
+export const platformToIdentityDeviceType: {
+ +[platform: Platform]: IdentityDeviceType,
+} = Object.freeze({
+ web: identityDeviceTypes.WEB,
+ android: identityDeviceTypes.ANDROID,
+ ios: identityDeviceTypes.IOS,
+ windows: identityDeviceTypes.WINDOWS,
+ macos: identityDeviceTypes.MAC_OS,
+});
export const identityDeviceTypeValidator: TEnums = t.enums.of(
values(identityDeviceTypes),
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
@@ -20,7 +20,6 @@
type IdentityAuthResult,
type IdentityNewDeviceKeyUpload,
type IdentityExistingDeviceKeyUpload,
- identityDeviceTypes,
identityAuthResultValidator,
type UserDevicesOlmInboundKeys,
type DeviceOlmInboundKeys,
@@ -34,6 +33,7 @@
type PeersDeviceLists,
peersDeviceListsValidator,
type IdentityPlatformDetails,
+ platformToIdentityDeviceType,
} from 'lib/types/identity-service-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
@@ -58,6 +58,7 @@
class IdentityServiceClientWrapper implements IdentityServiceClient {
overridedOpaqueFilepath: string;
+ platformDetails: PlatformDetails;
authClient: ?IdentityAuthClient.IdentityClientServicePromiseClient;
unauthClient: IdentityUnauthClient.IdentityClientServicePromiseClient;
getNewDeviceKeyUpload: () => Promise<IdentityNewDeviceKeyUpload>;
@@ -71,6 +72,7 @@
getExistingDeviceKeyUpload: () => Promise<IdentityExistingDeviceKeyUpload>,
) {
this.overridedOpaqueFilepath = overridedOpaqueFilepath;
+ this.platformDetails = platformDetails;
if (authLayer) {
this.authClient = IdentityServiceClientWrapper.createAuthClient(
platformDetails,
@@ -356,6 +358,7 @@
const startRequestBytes = opaqueLogin.start(password);
const deviceKeyUpload = authExistingDeviceKeyUpload(
+ this.platformDetails,
identityDeviceKeyUpload,
);
@@ -418,6 +421,7 @@
) => {
const identityDeviceKeyUpload = await this.getExistingDeviceKeyUpload();
const deviceKeyUpload = authExistingDeviceKeyUpload(
+ this.platformDetails,
identityDeviceKeyUpload,
);
@@ -453,7 +457,10 @@
nonceChallengeResponse,
) => {
const identityDeviceKeyUpload = await this.getNewDeviceKeyUpload();
- const deviceKeyUpload = authNewDeviceKeyUpload(identityDeviceKeyUpload);
+ const deviceKeyUpload = authNewDeviceKeyUpload(
+ this.platformDetails,
+ identityDeviceKeyUpload,
+ );
const { nonce, nonceSignature } = nonceChallengeResponse;
const request = new SecondaryDeviceKeysUploadRequest();
@@ -750,6 +757,7 @@
}
function authNewDeviceKeyUpload(
+ platformDetails: PlatformDetails,
uploadData: IdentityNewDeviceKeyUpload,
): DeviceKeyUpload {
const {
@@ -776,6 +784,7 @@
const notifPrekeyUpload = createPrekey(notifPrekey, notifPrekeySignature);
const deviceKeyUpload = createDeviceKeyUpload(
+ platformDetails,
identityKeyInfo,
contentPrekeyUpload,
notifPrekeyUpload,
@@ -787,6 +796,7 @@
}
function authExistingDeviceKeyUpload(
+ platformDetails: PlatformDetails,
uploadData: IdentityExistingDeviceKeyUpload,
): DeviceKeyUpload {
const {
@@ -811,6 +821,7 @@
const notifPrekeyUpload = createPrekey(notifPrekey, notifPrekeySignature);
const deviceKeyUpload = createDeviceKeyUpload(
+ platformDetails,
identityKeyInfo,
contentPrekeyUpload,
notifPrekeyUpload,
@@ -837,6 +848,7 @@
}
function createDeviceKeyUpload(
+ platformDetails: PlatformDetails,
identityKeyInfo: IdentityKeyInfo,
contentPrekeyUpload: Prekey,
notifPrekeyUpload: Prekey,
@@ -849,7 +861,9 @@
deviceKeyUpload.setNotifUpload(notifPrekeyUpload);
deviceKeyUpload.setOneTimeContentPrekeysList([...contentOneTimeKeys]);
deviceKeyUpload.setOneTimeNotifPrekeysList([...notifOneTimeKeys]);
- deviceKeyUpload.setDeviceType(identityDeviceTypes.WEB);
+ deviceKeyUpload.setDeviceType(
+ platformToIdentityDeviceType[platformDetails.platform],
+ );
return deviceKeyUpload;
}
diff --git a/web/grpc/interceptor.js b/web/grpc/interceptor.js
--- a/web/grpc/interceptor.js
+++ b/web/grpc/interceptor.js
@@ -33,7 +33,14 @@
if (majorDesktopVersion) {
metadata['major_desktop_version'] = majorDesktopVersion.toString();
}
- metadata['device_type'] = deviceType;
+
+ let identityDeviceType;
+ if (deviceType === 'macos') {
+ identityDeviceType = 'mac_os';
+ } else {
+ identityDeviceType = deviceType;
+ }
+ metadata['device_type'] = identityDeviceType;
return invoker(request);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 1:26 AM (13 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615458
Default Alt Text
D12900.diff (5 KB)
Attached To
Mode
D12900: Prevent desktop devices from presenting themselves as web to identity
Attached
Detach File
Event Timeline
Log In to Comment