Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32937541
D11451.1768249253.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D11451.1768249253.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -121,7 +121,7 @@
virtual jsi::Value initializeContentInboundSession(
jsi::Runtime &rt,
jsi::String identityKeys,
- jsi::String encryptedMessage,
+ jsi::Object encryptedDataJSI,
jsi::String deviceID) override;
virtual jsi::Value
encrypt(jsi::Runtime &rt, jsi::String message, jsi::String deviceID) override;
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -1122,7 +1122,7 @@
rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
taskType job = [=, &innerRt]() {
std::string error;
- crypto::EncryptedData initialEncryptedMessage;
+ crypto::EncryptedData initialEncryptedData;
try {
this->contentCryptoModule->initializeOutboundForSendingSession(
deviceIDCpp,
@@ -1135,8 +1135,9 @@
oneTimeKeyCpp.begin(), oneTimeKeyCpp.end()));
const std::string initMessage = "{\"type\": \"init\"}";
- initialEncryptedMessage =
+ initialEncryptedData =
contentCryptoModule->encrypt(deviceIDCpp, initMessage);
+
this->persistCryptoModules(true, false);
} catch (const std::exception &e) {
error = e.what();
@@ -1146,11 +1147,18 @@
promise->reject(error);
return;
}
- promise->resolve(jsi::String::createFromUtf8(
+ auto initialEncryptedDataJSI = jsi::Object(innerRt);
+ auto message = std::string{
+ initialEncryptedData.message.begin(),
+ initialEncryptedData.message.end()};
+ auto messageJSI = jsi::String::createFromUtf8(innerRt, message);
+ initialEncryptedDataJSI.setProperty(innerRt, "message", messageJSI);
+ initialEncryptedDataJSI.setProperty(
innerRt,
- std::string{
- initialEncryptedMessage.message.begin(),
- initialEncryptedMessage.message.end()}));
+ "messageType",
+ static_cast<int>(initialEncryptedData.messageType));
+
+ promise->resolve(std::move(initialEncryptedDataJSI));
});
};
this->cryptoThread->scheduleTask(job);
@@ -1160,10 +1168,13 @@
jsi::Value CommCoreModule::initializeContentInboundSession(
jsi::Runtime &rt,
jsi::String identityKeys,
- jsi::String encryptedMessage,
+ jsi::Object encryptedDataJSI,
jsi::String deviceID) {
auto identityKeysCpp{identityKeys.utf8(rt)};
- auto encryptedMessageCpp{encryptedMessage.utf8(rt)};
+ size_t messageType =
+ std::lround(encryptedDataJSI.getProperty(rt, "messageType").asNumber());
+ std::string encryptedMessageCpp =
+ encryptedDataJSI.getProperty(rt, "message").asString(rt).utf8(rt);
auto deviceIDCpp{deviceID.utf8(rt)};
return createPromiseAsJSIValue(
rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
@@ -1177,8 +1188,10 @@
encryptedMessageCpp.begin(), encryptedMessageCpp.end()),
std::vector<uint8_t>(
identityKeysCpp.begin(), identityKeysCpp.end()));
- crypto::EncryptedData encryptedData{std::vector<uint8_t>(
- encryptedMessageCpp.begin(), encryptedMessageCpp.end())};
+ crypto::EncryptedData encryptedData{
+ std::vector<uint8_t>(
+ encryptedMessageCpp.begin(), encryptedMessageCpp.end()),
+ messageType};
decryptedMessage =
this->contentCryptoModule->decrypt(deviceIDCpp, encryptedData);
this->persistCryptoModules(true, false);
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -103,7 +103,7 @@
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->initializeContentOutboundSession(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt));
}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeContentInboundSession(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
- return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->initializeContentInboundSession(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->initializeContentInboundSession(rt, args[0].asString(rt), args[1].asObject(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_encrypt(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->encrypt(rt, args[0].asString(rt), args[1].asString(rt));
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -49,7 +49,7 @@
virtual jsi::Value removeKeyserverDataFromNotifStorage(jsi::Runtime &rt, jsi::Array keyserverIDsToDelete) = 0;
virtual jsi::Value getKeyserverDataFromNotifStorage(jsi::Runtime &rt, jsi::Array keyserverIDs) = 0;
virtual jsi::Value initializeContentOutboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::String prekey, jsi::String prekeySignature, jsi::String oneTimeKey, jsi::String deviceID) = 0;
- virtual jsi::Value initializeContentInboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::String encryptedMessage, jsi::String deviceID) = 0;
+ virtual jsi::Value initializeContentInboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::Object encryptedContent, jsi::String deviceID) = 0;
virtual jsi::Value encrypt(jsi::Runtime &rt, jsi::String message, jsi::String deviceID) = 0;
virtual jsi::Value decrypt(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID) = 0;
virtual jsi::Value signMessage(jsi::Runtime &rt, jsi::String message) = 0;
@@ -327,13 +327,13 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::initializeContentOutboundSession, jsInvoker_, instance_, std::move(identityKeys), std::move(prekey), std::move(prekeySignature), std::move(oneTimeKey), std::move(deviceID));
}
- jsi::Value initializeContentInboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::String encryptedMessage, jsi::String deviceID) override {
+ jsi::Value initializeContentInboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::Object encryptedContent, jsi::String deviceID) override {
static_assert(
bridging::getParameterCount(&T::initializeContentInboundSession) == 4,
"Expected initializeContentInboundSession(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
- rt, &T::initializeContentInboundSession, jsInvoker_, instance_, std::move(identityKeys), std::move(encryptedMessage), std::move(deviceID));
+ rt, &T::initializeContentInboundSession, jsInvoker_, instance_, std::move(identityKeys), std::move(encryptedContent), std::move(deviceID));
}
jsi::Value encrypt(jsi::Runtime &rt, jsi::String message, jsi::String deviceID) override {
static_assert(
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
@@ -7,7 +7,6 @@
type OlmAPI,
type OLMIdentityKeys,
type EncryptedData,
- olmEncryptedMessageTypes,
} from 'lib/types/crypto-types.js';
import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
@@ -30,7 +29,7 @@
});
return commCoreModule.initializeContentInboundSession(
identityKeys,
- initialEncryptedData.message,
+ initialEncryptedData,
contentIdentityKeys.ed25519,
);
},
@@ -44,17 +43,13 @@
ed25519: contentIdentityKeys.ed25519,
});
- const message = await commCoreModule.initializeContentOutboundSession(
+ return commCoreModule.initializeContentOutboundSession(
identityKeys,
prekey,
prekeySignature,
oneTimeKey,
contentIdentityKeys.ed25519,
);
- return {
- message,
- messageType: olmEncryptedMessageTypes.PREKEY,
- };
},
notificationsSessionCreator(
cookie: ?string,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -102,10 +102,10 @@
prekeySignature: string,
oneTimeKey: string,
deviceID: string,
- ) => Promise<string>;
+ ) => Promise<EncryptedData>;
+initializeContentInboundSession: (
identityKeys: string,
- encryptedMessage: string,
+ encryptedContent: Object,
deviceID: string,
) => Promise<string>;
+encrypt: (message: string, deviceID: string) => Promise<EncryptedData>;
@@ -148,6 +148,11 @@
backupID: string,
) => Promise<ArrayBuffer>;
+decrypt: (encryptedData: EncryptedData, deviceID: string) => Promise<string>;
+ +initializeContentInboundSession: (
+ identityKeys: string,
+ encryptedContent: EncryptedData,
+ deviceID: string,
+ ) => Promise<string>;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 12, 8:20 PM (14 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5922382
Default Alt Text
D11451.1768249253.diff (9 KB)
Attached To
Mode
D11451: [native] update `olm` session creation code use `EncryptedData`
Attached
Detach File
Event Timeline
Log In to Comment