Page MenuHomePhabricator

D11718.diff
No OneTemporary

D11718.diff

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
@@ -146,6 +146,11 @@
jsi::Runtime &rt,
jsi::Object encryptedDataJSI,
jsi::String deviceID) override;
+ virtual jsi::Value decryptSequential(
+ jsi::Runtime &rt,
+ jsi::Object encryptedDataJSI,
+ jsi::String deviceID,
+ jsi::String messageID) override;
virtual jsi::Value
signMessage(jsi::Runtime &rt, jsi::String message) override;
virtual void terminate(jsi::Runtime &rt) 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
@@ -1361,6 +1361,45 @@
});
}
+jsi::Value CommCoreModule::decryptSequential(
+ jsi::Runtime &rt,
+ jsi::Object encryptedDataJSI,
+ jsi::String deviceID,
+ jsi::String messageID) {
+ size_t messageType =
+ std::lround(encryptedDataJSI.getProperty(rt, "messageType").asNumber());
+ std::string message =
+ encryptedDataJSI.getProperty(rt, "message").asString(rt).utf8(rt);
+ auto deviceIDCpp{deviceID.utf8(rt)};
+ auto messageIDCpp{messageID.utf8(rt)};
+ return createPromiseAsJSIValue(
+ rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ taskType job = [=, &innerRt]() {
+ std::string error;
+ std::string decryptedMessage;
+ try {
+ crypto::EncryptedData encryptedData{
+ std::vector<uint8_t>(message.begin(), message.end()),
+ messageType};
+ decryptedMessage = this->contentCryptoModule->decryptSequential(
+ deviceIDCpp, encryptedData);
+ this->persistCryptoModules(true, false);
+ } catch (const std::exception &e) {
+ error = e.what();
+ }
+ this->jsInvoker_->invokeAsync([=, &innerRt]() {
+ if (error.size()) {
+ promise->reject(error);
+ return;
+ }
+ promise->resolve(
+ jsi::String::createFromUtf8(innerRt, decryptedMessage));
+ });
+ };
+ this->cryptoThread->scheduleTask(job);
+ });
+}
+
jsi::Value CommCoreModule::signMessage(jsi::Runtime &rt, jsi::String message) {
std::string messageStr = message.utf8(rt);
return createPromiseAsJSIValue(
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
@@ -120,6 +120,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decrypt(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->decrypt(rt, args[0].asObject(rt), args[1].asString(rt));
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decryptSequential(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->decryptSequential(rt, args[0].asObject(rt), args[1].asString(rt), args[2].asString(rt));
+}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_signMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->signMessage(rt, args[0].asString(rt));
}
@@ -237,6 +240,7 @@
methodMap_["initializeContentInboundSession"] = MethodMetadata {5, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeContentInboundSession};
methodMap_["encrypt"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_encrypt};
methodMap_["decrypt"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decrypt};
+ methodMap_["decryptSequential"] = MethodMetadata {3, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_decryptSequential};
methodMap_["signMessage"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_signMessage};
methodMap_["getCodeVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion};
methodMap_["terminate"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_terminate};
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
@@ -55,6 +55,7 @@
virtual jsi::Value initializeContentInboundSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::Object encryptedContent, jsi::String deviceID, double sessionVersion, bool overwrite) = 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 decryptSequential(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID, jsi::String messageID) = 0;
virtual jsi::Value signMessage(jsi::Runtime &rt, jsi::String message) = 0;
virtual double getCodeVersion(jsi::Runtime &rt) = 0;
virtual void terminate(jsi::Runtime &rt) = 0;
@@ -381,6 +382,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::decrypt, jsInvoker_, instance_, std::move(encryptedData), std::move(deviceID));
}
+ jsi::Value decryptSequential(jsi::Runtime &rt, jsi::Object encryptedData, jsi::String deviceID, jsi::String messageID) override {
+ static_assert(
+ bridging::getParameterCount(&T::decryptSequential) == 4,
+ "Expected decryptSequential(...) to have 4 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::decryptSequential, jsInvoker_, instance_, std::move(encryptedData), std::move(deviceID), std::move(messageID));
+ }
jsi::Value signMessage(jsi::Runtime &rt, jsi::String message) override {
static_assert(
bridging::getParameterCount(&T::signMessage) == 2,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -126,6 +126,11 @@
) => Promise<string>;
+encrypt: (message: string, deviceID: string) => Promise<EncryptedData>;
+decrypt: (encryptedData: Object, deviceID: string) => Promise<string>;
+ +decryptSequential: (
+ encryptedData: Object,
+ deviceID: string,
+ messageID: string,
+ ) => Promise<string>;
+signMessage: (message: string) => Promise<string>;
+getCodeVersion: () => number;
+terminate: () => void;
@@ -167,6 +172,11 @@
backupID: string,
) => Promise<ArrayBuffer>;
+decrypt: (encryptedData: EncryptedData, deviceID: string) => Promise<string>;
+ +decryptSequential: (
+ encryptedData: EncryptedData,
+ deviceID: string,
+ messageID: string,
+ ) => Promise<string>;
+initializeContentInboundSession: (
identityKeys: string,
encryptedContent: EncryptedData,
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -64,7 +64,9 @@
.field("auxUserInfo", &AuxUserInfo::aux_user_info);
value_object<ThreadActivityEntry>("ThreadActivityEntry")
.field("id", &ThreadActivityEntry::id)
- .field("threadActivityStoreEntry", &ThreadActivityEntry::thread_activity_store_entry);
+ .field(
+ "threadActivityStoreEntry",
+ &ThreadActivityEntry::thread_activity_store_entry);
value_object<WebThread>("WebThread")
.field("id", &WebThread::id)

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 10:56 PM (12 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2566333
Default Alt Text
D11718.diff (7 KB)

Event Timeline