Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2838251
D12067.id40277.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12067.id40277.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
@@ -6,7 +6,10 @@
SignedDeviceList,
} from '../types/identity-service-types.js';
import { getConfig } from '../utils/config.js';
-import { rawDeviceListFromSignedList } from '../utils/device-list-utils.js';
+import {
+ composeRawDeviceList,
+ rawDeviceListFromSignedList,
+} from '../utils/device-list-utils.js';
export type DeviceListVerificationResult =
| { +valid: true, +deviceList: RawDeviceList }
@@ -118,4 +121,17 @@
return { valid: true, deviceList };
}
-export { verifyAndGetDeviceList };
+async function createAndSignInitialDeviceList(
+ primaryDeviceID: string,
+): Promise<SignedDeviceList> {
+ const initialDeviceList = composeRawDeviceList([primaryDeviceID]);
+ const rawDeviceList = JSON.stringify(initialDeviceList);
+ const { olmAPI } = getConfig();
+ const curPrimarySignature = await olmAPI.signMessage(rawDeviceList);
+ return {
+ rawDeviceList,
+ curPrimarySignature,
+ };
+}
+
+export { verifyAndGetDeviceList, createAndSignInitialDeviceList };
diff --git a/lib/utils/device-list-utils.js b/lib/utils/device-list-utils.js
--- a/lib/utils/device-list-utils.js
+++ b/lib/utils/device-list-utils.js
@@ -9,6 +9,13 @@
} from '../types/identity-service-types.js';
import { rawDeviceListValidator } from '../types/identity-service-types.js';
+function composeRawDeviceList(devices: $ReadOnlyArray<string>): RawDeviceList {
+ return {
+ devices,
+ timestamp: Date.now(),
+ };
+}
+
function convertSignedDeviceListsToRawDeviceLists(
signedDeviceLists: UsersSignedDeviceLists,
): UsersRawDeviceLists {
@@ -34,4 +41,5 @@
export {
convertSignedDeviceListsToRawDeviceLists,
rawDeviceListFromSignedList,
+ composeRawDeviceList,
};
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,6 +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 { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import {
type IdentityKeysBlob,
@@ -324,6 +325,9 @@
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
+ const initialDeviceList = await createAndSignInitialDeviceList(
+ primaryIdentityPublicKeys.ed25519,
+ );
const registrationResult = await commRustModule.registerPasswordUser(
username,
password,
@@ -336,7 +340,7 @@
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
fid ?? '',
- '', // initialDeviceList
+ JSON.stringify(initialDeviceList),
);
const { userID, accessToken: token } = JSON.parse(registrationResult);
const identityAuthResult = { accessToken: token, userID, username };
@@ -403,6 +407,9 @@
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
+ const initialDeviceList = await createAndSignInitialDeviceList(
+ primaryIdentityPublicKeys.ed25519,
+ );
const registrationResult = await commRustModule.registerWalletUser(
siweMessage,
siweSignature,
@@ -415,7 +422,7 @@
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
fid ?? '',
- '', // initialDeviceList
+ JSON.stringify(initialDeviceList),
);
const { userID, accessToken: token } = JSON.parse(registrationResult);
const identityAuthResult = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 29, 9:26 PM (21 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2202737
Default Alt Text
D12067.id40277.diff (3 KB)
Attached To
Mode
D12067: [native] Create initial device list during registration
Attached
Detach File
Event Timeline
Log In to Comment