Page MenuHomePhabricator

D12586.id41940.diff
No OneTemporary

D12586.id41940.diff

diff --git a/lib/shared/device-list-utils.js b/lib/shared/device-list-utils.js
--- a/lib/shared/device-list-utils.js
+++ b/lib/shared/device-list-utils.js
@@ -124,7 +124,7 @@
return { valid: true, deviceList };
}
-async function createAndSignInitialDeviceList(
+async function createAndSignSingletonDeviceList(
primaryDeviceID: string,
): Promise<SignedDeviceList> {
const initialDeviceList = composeRawDeviceList([primaryDeviceID]);
@@ -220,7 +220,7 @@
export {
verifyAndGetDeviceList,
- createAndSignInitialDeviceList,
+ createAndSignSingletonDeviceList,
fetchLatestDeviceList,
addDeviceToDeviceList,
removeDeviceFromDeviceList,
diff --git a/lib/shared/device-list-utils.test.js b/lib/shared/device-list-utils.test.js
--- a/lib/shared/device-list-utils.test.js
+++ b/lib/shared/device-list-utils.test.js
@@ -1,7 +1,7 @@
// @flow
import {
- createAndSignInitialDeviceList,
+ createAndSignSingletonDeviceList,
verifyAndGetDeviceList,
addDeviceToDeviceList,
removeDeviceFromDeviceList,
@@ -152,14 +152,14 @@
});
});
-describe(createAndSignInitialDeviceList, () => {
+describe(createAndSignSingletonDeviceList, () => {
it('creates initial device list', async () => {
const signMessage = jest
.fn<[string], string>()
.mockResolvedValue('mock_signature');
mockOlmAPISign(signMessage);
- const payload = await createAndSignInitialDeviceList('device1');
+ const payload = await createAndSignSingletonDeviceList('device1');
expect(payload.curPrimarySignature).toStrictEqual('mock_signature');
const raw = rawDeviceListFromSignedList(payload);
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
@@ -124,6 +124,9 @@
// primary device
+deletePasswordUser?: (password: string) => Promise<void>;
+logOut: () => Promise<void>;
+ // This log out type is specific to primary device, and web cannot be a
+ // primary device
+ +logOutPrimaryDevice?: () => Promise<void>;
+logOutSecondaryDevice: () => Promise<void>;
+getKeyserverKeys: string => Promise<DeviceOlmOutboundKeys>;
// Users cannot register from web
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
@@ -3,7 +3,7 @@
import * as React from 'react';
import { getOneTimeKeyValues } from 'lib/shared/crypto-utils.js';
-import { createAndSignInitialDeviceList } from 'lib/shared/device-list-utils.js';
+import { createAndSignSingletonDeviceList } from 'lib/shared/device-list-utils.js';
import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import {
type IdentityKeysBlob,
@@ -133,6 +133,21 @@
} = await getAuthMetadata();
return commRustModule.logOut(userID, deviceID, token);
},
+ logOutPrimaryDevice: async () => {
+ const {
+ deviceID,
+ userID,
+ accessToken: token,
+ } = await getAuthMetadata();
+ const signedDeviceList =
+ await createAndSignSingletonDeviceList(deviceID);
+ return commRustModule.logOutPrimaryDevice(
+ userID,
+ deviceID,
+ token,
+ JSON.stringify(signedDeviceList),
+ );
+ },
logOutSecondaryDevice: async () => {
const {
deviceID,
@@ -339,7 +354,7 @@
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
- const initialDeviceList = await createAndSignInitialDeviceList(
+ const initialDeviceList = await createAndSignSingletonDeviceList(
primaryIdentityPublicKeys.ed25519,
);
const registrationResult = await commRustModule.registerPasswordUser(
@@ -378,7 +393,7 @@
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
- const initialDeviceList = await createAndSignInitialDeviceList(
+ const initialDeviceList = await createAndSignSingletonDeviceList(
primaryIdentityPublicKeys.ed25519,
);
const registrationResult =
@@ -442,7 +457,7 @@
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
- const initialDeviceList = await createAndSignInitialDeviceList(
+ const initialDeviceList = await createAndSignSingletonDeviceList(
primaryIdentityPublicKeys.ed25519,
);
const registrationResult = await commRustModule.registerWalletUser(

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 6, 3:26 PM (19 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250114
Default Alt Text
D12586.id41940.diff (4 KB)

Event Timeline