Page MenuHomePhabricator

D13577.diff
No OneTemporary

D13577.diff

diff --git a/keyserver/addons/rust-node-addon/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js
--- a/keyserver/addons/rust-node-addon/rust-binding-types.js
+++ b/keyserver/addons/rust-node-addon/rust-binding-types.js
@@ -18,6 +18,8 @@
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
+ contentOneTimeKeys: $ReadOnlyArray<string>,
+ notifOneTimeKeys: $ReadOnlyArray<string>,
force: ?boolean,
) => Promise<IdentityInfo>,
+registerUser: (
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/login.rs b/keyserver/addons/rust-node-addon/src/identity_client/login.rs
--- a/keyserver/addons/rust-node-addon/src/identity_client/login.rs
+++ b/keyserver/addons/rust-node-addon/src/identity_client/login.rs
@@ -18,6 +18,8 @@
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
force: Option<bool>,
) -> Result<UserLoginInfo> {
debug!("Attempting to log in user: {}", username);
@@ -47,8 +49,8 @@
prekey: notif_prekey,
prekey_signature: notif_prekey_signature,
}),
- one_time_content_prekeys: Vec::new(),
- one_time_notif_prekeys: Vec::new(),
+ one_time_content_prekeys: content_one_time_keys,
+ one_time_notif_prekeys: notif_one_time_keys,
device_type: DeviceType::Keyserver.into(),
}),
force,
diff --git a/keyserver/src/user/login.js b/keyserver/src/user/login.js
--- a/keyserver/src/user/login.js
+++ b/keyserver/src/user/login.js
@@ -3,13 +3,9 @@
import type { Account as OlmAccount } from '@commapp/olm';
import { getRustAPI } from 'rust-node-addon';
-import { ONE_TIME_KEYS_NUMBER } from 'lib/types/identity-service-types.js';
import { getCommConfig } from 'lib/utils/comm-config.js';
import { ServerError } from 'lib/utils/errors.js';
-import {
- retrieveIdentityKeysAndPrekeys,
- getAccountOneTimeKeys,
-} from 'lib/utils/olm-utils.js';
+import { retrieveAccountKeysSet } from 'lib/utils/olm-utils.js';
import type { UserCredentials } from './checks.js';
import {
@@ -156,14 +152,16 @@
identityKeys: notificationsIdentityKeys,
prekey: notificationsPrekey,
prekeySignature: notificationsPrekeySignature,
- } = await getUpdateNotificationsAccount(retrieveIdentityKeysAndPrekeys);
+ oneTimeKeys: notificationsOneTimeKeys,
+ } = await fetchCallUpdateOlmAccount('notifications', retrieveAccountKeysSet);
- const contentAccountCallback = (account: OlmAccount) => {
+ const contentAccountCallback = async (account: OlmAccount) => {
const {
identityKeys: contentIdentityKeys,
+ oneTimeKeys,
prekey,
prekeySignature,
- } = retrieveIdentityKeysAndPrekeys(account);
+ } = await retrieveAccountKeysSet(account);
const identityKeysBlob = {
primaryIdentityPublicKeys: JSON.parse(contentIdentityKeys),
@@ -177,6 +175,7 @@
return {
signedIdentityKeysBlob,
+ oneTimeKeys,
prekey,
prekeySignature,
};
@@ -188,6 +187,7 @@
signedIdentityKeysBlob,
prekey: contentPrekey,
prekeySignature: contentPrekeySignature,
+ oneTimeKeys: contentOneTimeKeys,
},
] = await Promise.all([
rustAPIPromise,
@@ -203,6 +203,8 @@
contentPrekeySignature,
notificationsPrekey,
notificationsPrekeySignature,
+ contentOneTimeKeys,
+ notificationsOneTimeKeys,
userInfo.forceLogin,
);
await Promise.all([
@@ -212,14 +214,6 @@
return identity_info;
} catch (e) {
console.warn('Failed to login user: ' + getMessageForException(e));
- const [contentOneTimeKeys, notificationsOneTimeKeys] = await Promise.all([
- getUpdateContentAccount((account: OlmAccount) =>
- getAccountOneTimeKeys(account, ONE_TIME_KEYS_NUMBER),
- ),
- getUpdateNotificationsAccount((account: OlmAccount) =>
- getAccountOneTimeKeys(account, ONE_TIME_KEYS_NUMBER),
- ),
- ]);
try {
await Promise.all([
getUpdateContentAccount(markOneTimeKeysAsPublished),
diff --git a/lib/utils/olm-utils.js b/lib/utils/olm-utils.js
--- a/lib/utils/olm-utils.js
+++ b/lib/utils/olm-utils.js
@@ -18,12 +18,6 @@
+oneTimeKeys: $ReadOnlyArray<string>,
};
-type IdentityKeysAndPrekeys = {
- +identityKeys: string,
- +prekey: string,
- +prekeySignature: string,
-};
-
function validateAccountPrekey(account: OlmAccount) {
if (shouldRotatePrekey(account)) {
account.generate_prekey();
@@ -95,15 +89,6 @@
}
function retrieveAccountKeysSet(account: OlmAccount): AccountKeysSet {
- const { identityKeys, prekey, prekeySignature } =
- retrieveIdentityKeysAndPrekeys(account);
- const oneTimeKeys = getAccountOneTimeKeys(account, ONE_TIME_KEYS_NUMBER);
- return { identityKeys, oneTimeKeys, prekey, prekeySignature };
-}
-
-function retrieveIdentityKeysAndPrekeys(
- account: OlmAccount,
-): IdentityKeysAndPrekeys {
const identityKeys = account.identity_keys();
validateAccountPrekey(account);
@@ -113,7 +98,9 @@
throw new Error('invalid_prekey');
}
- return { identityKeys, prekey, prekeySignature };
+ const oneTimeKeys = getAccountOneTimeKeys(account, ONE_TIME_KEYS_NUMBER);
+
+ return { identityKeys, oneTimeKeys, prekey, prekeySignature };
}
export const OLM_SESSION_ERROR_PREFIX = 'OLM_';
@@ -155,7 +142,6 @@
shouldForgetPrekey,
shouldRotatePrekey,
getAccountOneTimeKeys,
- retrieveIdentityKeysAndPrekeys,
hasHigherDeviceID,
olmSessionErrors,
};

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 3, 5:59 PM (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2223441
Default Alt Text
D13577.diff (5 KB)

Event Timeline