Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3517261
D6901.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6901.diff
View Options
diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -1,5 +1,6 @@
// @flow
+import olm from '@matrix-org/olm';
import cluster from 'cluster';
import cookieParser from 'cookie-parser';
import express from 'express';
@@ -38,6 +39,7 @@
} from './utils/urls.js';
(async () => {
+ await olm.init();
await prefetchAllURLFacts();
const squadCalBaseRoutePath = getSquadCalURLFacts()?.baseRoutePath;
diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js
--- a/keyserver/src/responders/user-responders.js
+++ b/keyserver/src/responders/user-responders.js
@@ -1,6 +1,5 @@
// @flow
-import olm from '@matrix-org/olm';
import invariant from 'invariant';
import { ErrorTypes, SiweMessage } from 'siwe';
import t from 'tcomb';
@@ -94,6 +93,8 @@
} from '../updaters/account-updaters.js';
import { userSubscriptionUpdater } from '../updaters/user-subscription-updaters.js';
import { viewerAcknowledgmentUpdater } from '../updaters/viewer-acknowledgment-updater.js';
+import { getOLMUtility } from '../utils/olm-utils.js';
+import type { OLMUtility } from '../utils/olm-utils.js';
import { validateInput } from '../utils/validation-utils.js';
const subscriptionUpdateRequestInputValidator = tShape({
@@ -342,8 +343,7 @@
signedIdentityKeysBlob.payload,
);
- await olm.init();
- const olmUtil = new olm.Utility();
+ const olmUtil: OLMUtility = getOLMUtility();
try {
olmUtil.ed25519_verify(
identityKeys.primaryIdentityPublicKeys.ed25519,
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
@@ -1,5 +1,6 @@
// @flow
+import olm from '@matrix-org/olm';
import invariant from 'invariant';
import { importJSON } from './import-json.js';
@@ -25,4 +26,13 @@
) => void,
};
-export { getOlmConfig };
+let cachedOLMUtility: OLMUtility;
+function getOLMUtility(): OLMUtility {
+ if (cachedOLMUtility) {
+ return cachedOLMUtility;
+ }
+ cachedOLMUtility = new olm.Utility();
+ return cachedOLMUtility;
+}
+
+export { getOlmConfig, getOLMUtility };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 4:48 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2695423
Default Alt Text
D6901.diff (2 KB)
Attached To
Mode
D6901: [keyserver] Introduce `getOLMUtility(...)` and initialize OLM on `keyserver` start
Attached
Detach File
Event Timeline
Log In to Comment