Page MenuHomePhabricator

D14027.diff
No OneTemporary

D14027.diff

diff --git a/keyserver/src/utils/identity-utils.js b/keyserver/src/utils/identity-utils.js
--- a/keyserver/src/utils/identity-utils.js
+++ b/keyserver/src/utils/identity-utils.js
@@ -89,10 +89,41 @@
);
}
+async function publishPrekeys(
+ deviceID: string,
+ contentPrekey: string,
+ contentPrekeySignature: string,
+ notifPrekey: string,
+ notifPrekeySignature: string,
+): Promise<void> {
+ const [rustAPI, identityInfo] = await Promise.all([
+ getRustAPI(),
+ verifyUserLoggedIn(),
+ ]);
+
+ if (!identityInfo) {
+ console.warn(
+ 'Attempted to refresh prekeys before registering with Identity service',
+ );
+ return;
+ }
+
+ await rustAPI.publishPrekeys(
+ identityInfo.userId,
+ deviceID,
+ identityInfo.accessToken,
+ contentPrekey,
+ contentPrekeySignature,
+ notifPrekey,
+ notifPrekeySignature,
+ );
+}
+
export {
findUserIdentities,
privilegedDeleteUsers,
privilegedResetUserPassword,
syncPlatformDetails,
uploadOneTimeKeys,
+ publishPrekeys,
};
diff --git a/keyserver/src/utils/olm-utils.js b/keyserver/src/utils/olm-utils.js
--- a/keyserver/src/utils/olm-utils.js
+++ b/keyserver/src/utils/olm-utils.js
@@ -7,7 +7,6 @@
Session as OlmSession,
} from '@commapp/olm';
import invariant from 'invariant';
-import { getRustAPI } from 'rust-node-addon';
import uuid from 'uuid';
import { getOneTimeKeyValuesFromBlob } from 'lib/shared/crypto-utils.js';
@@ -21,7 +20,7 @@
retrieveAccountKeysSet,
} from 'lib/utils/olm-utils.js';
-import { uploadOneTimeKeys } from './identity-utils.js';
+import { publishPrekeys, uploadOneTimeKeys } from './identity-utils.js';
import {
fetchCallUpdateOlmAccount,
fetchOlmAccount,
@@ -274,8 +273,6 @@
contentAccount: OlmAccount,
notifAccount: OlmAccount,
): Promise<void> {
- const rustAPIPromise = getRustAPI();
- const verifyUserLoggedInPromise = verifyUserLoggedIn();
const deviceID = JSON.parse(contentAccount.identity_keys()).ed25519;
const { prekey: contentPrekey, prekeySignature: contentPrekeySignature } =
@@ -288,22 +285,8 @@
return;
}
- const [rustAPI, identityInfo] = await Promise.all([
- rustAPIPromise,
- verifyUserLoggedInPromise,
- ]);
-
- if (!identityInfo) {
- console.warn(
- 'Attempted to refresh prekeys before registering with Identity service',
- );
- return;
- }
-
- await rustAPI.publishPrekeys(
- identityInfo.userId,
+ await publishPrekeys(
deviceID,
- identityInfo.accessToken,
contentPrekey,
contentPrekeySignature,
notifPrekey,

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 5:52 AM (19 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2583165
Default Alt Text
D14027.diff (2 KB)

Event Timeline