Page MenuHomePhabricator

D11447.id38475.diff
No OneTemporary

D11447.id38475.diff

diff --git a/lib/handlers/peer-to-peer-message-handler.js b/lib/handlers/peer-to-peer-message-handler.js
--- a/lib/handlers/peer-to-peer-message-handler.js
+++ b/lib/handlers/peer-to-peer-message-handler.js
@@ -1,5 +1,6 @@
// @flow
+import { olmEncryptedMessageTypes } from '../types/crypto-types.js';
import type {
IdentityServiceClient,
DeviceOlmInboundKeys,
@@ -49,7 +50,10 @@
try {
await olmAPI.initializeCryptoAccount();
const decrypted = await olmAPI.decrypt(
- message.encryptedContent,
+ {
+ messageType: olmEncryptedMessageTypes.TEXT,
+ message: message.encryptedContent,
+ },
message.senderInfo.deviceID,
);
console.log(
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
@@ -136,7 +136,7 @@
+initializeCryptoAccount: () => Promise<void>,
+getUserPublicKey: () => Promise<ClientPublicKeys>,
+encrypt: (content: string, deviceID: string) => Promise<EncryptedData>,
- +decrypt: (encryptedContent: string, deviceID: string) => Promise<string>,
+ +decrypt: (encryptedData: EncryptedData, deviceID: string) => Promise<string>,
+contentInboundSessionCreator: (
contentIdentityKeys: OLMIdentityKeys,
initialEncryptedContent: string,
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
@@ -6,6 +6,7 @@
type OneTimeKeysResultValues,
type OlmAPI,
type OLMIdentityKeys,
+ type EncryptedData,
} from 'lib/types/crypto-types.js';
import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
@@ -17,7 +18,12 @@
},
getUserPublicKey: commCoreModule.getUserPublicKey,
encrypt: commCoreModule.encrypt,
- decrypt: commCoreModule.decrypt,
+ async decrypt(
+ encryptedData: EncryptedData,
+ deviceID: string,
+ ): Promise<string> {
+ return commCoreModule.decrypt(encryptedData.message, deviceID);
+ },
async contentInboundSessionCreator(
contentIdentityKeys: OLMIdentityKeys,
initialEncryptedContent: string,
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
@@ -386,7 +386,10 @@
messageType: encryptedContent.type,
};
},
- async decrypt(encryptedContent: string, deviceID: string): Promise<string> {
+ async decrypt(
+ encryptedData: EncryptedData,
+ deviceID: string,
+ ): Promise<string> {
if (!cryptoStore) {
throw new Error('Crypto account not initialized');
}
@@ -397,8 +400,8 @@
}
const result = session.decrypt(
- olmEncryptedMessageTypes.TEXT,
- encryptedContent,
+ encryptedData.messageType,
+ encryptedData.message,
);
persistCryptoStore();

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 10:38 AM (19 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579367
Default Alt Text
D11447.id38475.diff (2 KB)

Event Timeline