Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3342194
D12586.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12586.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 12:42 AM (12 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2566905
Default Alt Text
D12586.diff (4 KB)
Attached To
Mode
D12586: [lib][native] Add logOutPrimaryDevice to Identity Client
Attached
Detach File
Event Timeline
Log In to Comment