Page MenuHomePhabricator

D11719.diff
No OneTemporary

D11719.diff

diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js
--- a/lib/types/crypto-types.js
+++ b/lib/types/crypto-types.js
@@ -147,6 +147,11 @@
+getUserPublicKey: () => Promise<ClientPublicKeys>,
+encrypt: (content: string, deviceID: string) => Promise<EncryptedData>,
+decrypt: (encryptedData: EncryptedData, deviceID: string) => Promise<string>,
+ +decryptSequential: (
+ encryptedData: EncryptedData,
+ deviceID: string,
+ messageID: string,
+ ) => Promise<string>,
+contentInboundSessionCreator: (
contentIdentityKeys: OLMIdentityKeys,
initialEncryptedData: EncryptedData,
diff --git a/lib/utils/__mocks__/config.js b/lib/utils/__mocks__/config.js
--- a/lib/utils/__mocks__/config.js
+++ b/lib/utils/__mocks__/config.js
@@ -17,6 +17,7 @@
getUserPublicKey: jest.fn(),
encrypt: jest.fn(),
decrypt: jest.fn(),
+ decryptSequential: jest.fn(),
contentInboundSessionCreator: jest.fn(),
contentOutboundSessionCreator: jest.fn(),
notificationsSessionCreator: jest.fn(),
diff --git a/native/crypto/olm-api.js b/native/crypto/olm-api.js
--- a/native/crypto/olm-api.js
+++ b/native/crypto/olm-api.js
@@ -20,6 +20,7 @@
getUserPublicKey: commCoreModule.getUserPublicKey,
encrypt: commCoreModule.encrypt,
decrypt: commCoreModule.decrypt,
+ decryptSequential: commCoreModule.decryptSequential,
async contentInboundSessionCreator(
contentIdentityKeys: OLMIdentityKeys,
initialEncryptedData: EncryptedData,
diff --git a/web/crypto/olm-api.js b/web/crypto/olm-api.js
--- a/web/crypto/olm-api.js
+++ b/web/crypto/olm-api.js
@@ -46,6 +46,7 @@
getUserPublicKey: proxyToWorker('getUserPublicKey'),
encrypt: proxyToWorker('encrypt'),
decrypt: proxyToWorker('decrypt'),
+ decryptSequential: proxyToWorker('decryptSequential'),
contentInboundSessionCreator: proxyToWorker('contentInboundSessionCreator'),
contentOutboundSessionCreator: proxyToWorker('contentOutboundSessionCreator'),
notificationsSessionCreator: proxyToWorker('notificationsSessionCreator'),
diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -452,6 +452,30 @@
return result;
},
+ async decryptSequential(
+ encryptedData: EncryptedData,
+ deviceID: string,
+ // eslint-disable-next-line no-unused-vars
+ messageID: string,
+ ): Promise<string> {
+ if (!cryptoStore) {
+ throw new Error('Crypto account not initialized');
+ }
+
+ const { session } = cryptoStore.contentSessions[deviceID];
+ if (!session) {
+ throw new Error(`No session for deviceID: ${deviceID}`);
+ }
+
+ const result = session.decrypt_sequential(
+ encryptedData.messageType,
+ encryptedData.message,
+ );
+
+ persistCryptoStore();
+
+ return result;
+ },
async contentInboundSessionCreator(
contentIdentityKeys: OLMIdentityKeys,
initialEncryptedData: EncryptedData,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 10:33 PM (18 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2566034
Default Alt Text
D11719.diff (2 KB)

Event Timeline