Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3391273
D9334.id31558.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D9334.id31558.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
@@ -24,6 +24,8 @@
CommSecureStore secureStore;
const std::string secureStoreAccountDataKey = "cryptoAccountDataKey";
const std::string publicCryptoAccountID = "publicCryptoAccountID";
+ const std::string keyserverHostedContentID = "keyserverHostedContentID";
+ const std::string initialEncryptedMessageContent = "{\"type\": \"init\"}";
std::unique_ptr<crypto::CryptoModule> cryptoModule;
DraftStore draftStore;
ThreadStore threadStore;
@@ -73,6 +75,12 @@
jsi::String prekey,
jsi::String prekeySignature,
jsi::String oneTimeKeys) override;
+ virtual jsi::Value initializeContentSession(
+ jsi::Runtime &rt,
+ jsi::String identityKeys,
+ jsi::String prekey,
+ jsi::String prekeySignature,
+ jsi::String oneTimeKeys) override;
virtual jsi::Value
isNotificationsSessionInitialized(jsi::Runtime &rt) 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
@@ -650,6 +650,51 @@
});
}
+jsi::Value CommCoreModule::initializeContentSession(
+ jsi::Runtime &rt,
+ jsi::String identityKeys,
+ jsi::String prekey,
+ jsi::String prekeySignature,
+ jsi::String oneTimeKeys) {
+ auto identityKeysCpp{identityKeys.utf8(rt)};
+ auto prekeyCpp{prekey.utf8(rt)};
+ auto prekeySignatureCpp{prekeySignature.utf8(rt)};
+ auto oneTimeKeysCpp{oneTimeKeys.utf8(rt)};
+ return createPromiseAsJSIValue(
+ rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ taskType job = [=, &innerRt]() {
+ std::string error;
+ crypto::EncryptedData result;
+ try {
+ this->cryptoModule->initializeOutboundForSendingSession(
+ this->keyserverHostedContentID,
+ std::vector<uint8_t>(
+ identityKeysCpp.begin(), identityKeysCpp.end()),
+ std::vector<uint8_t>(prekeyCpp.begin(), prekeyCpp.end()),
+ std::vector<uint8_t>(
+ prekeySignatureCpp.begin(), prekeySignatureCpp.end()),
+ std::vector<uint8_t>(
+ oneTimeKeysCpp.begin(), oneTimeKeysCpp.end()));
+ result = this->cryptoModule->encrypt(
+ this->keyserverHostedContentID,
+ this->initialEncryptedMessageContent);
+ } 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,
+ std::string{result.message.begin(), result.message.end()}));
+ });
+ };
+ this->cryptoThread->scheduleTask(job);
+ });
+}
+
jsi::Value CommCoreModule::isNotificationsSessionInitialized(jsi::Runtime &rt) {
return createPromiseAsJSIValue(
rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
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
@@ -75,6 +75,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeNotificationsSession(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->initializeNotificationsSession(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeContentSession(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->initializeContentSession(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
+}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_isNotificationsSessionInitialized(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->isNotificationsSessionInitialized(rt);
}
@@ -142,6 +145,7 @@
methodMap_["getNotificationsOneTimeKeys"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getNotificationsOneTimeKeys};
methodMap_["generateAndGetPrekeys"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_generateAndGetPrekeys};
methodMap_["initializeNotificationsSession"] = MethodMetadata {4, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeNotificationsSession};
+ methodMap_["initializeContentSession"] = MethodMetadata {4, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeContentSession};
methodMap_["isNotificationsSessionInitialized"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_isNotificationsSessionInitialized};
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
@@ -40,6 +40,7 @@
virtual jsi::Value getNotificationsOneTimeKeys(jsi::Runtime &rt, double oneTimeKeysAmount) = 0;
virtual jsi::Value generateAndGetPrekeys(jsi::Runtime &rt) = 0;
virtual jsi::Value initializeNotificationsSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::String prekey, jsi::String prekeySignature, jsi::String oneTimeKeys) = 0;
+ virtual jsi::Value initializeContentSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::String prekey, jsi::String prekeySignature, jsi::String oneTimeKeys) = 0;
virtual jsi::Value isNotificationsSessionInitialized(jsi::Runtime &rt) = 0;
virtual double getCodeVersion(jsi::Runtime &rt) = 0;
virtual void terminate(jsi::Runtime &rt) = 0;
@@ -235,6 +236,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::initializeNotificationsSession, jsInvoker_, instance_, std::move(identityKeys), std::move(prekey), std::move(prekeySignature), std::move(oneTimeKeys));
}
+ jsi::Value initializeContentSession(jsi::Runtime &rt, jsi::String identityKeys, jsi::String prekey, jsi::String prekeySignature, jsi::String oneTimeKeys) override {
+ static_assert(
+ bridging::getParameterCount(&T::initializeContentSession) == 5,
+ "Expected initializeContentSession(...) to have 5 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::initializeContentSession, jsInvoker_, instance_, std::move(identityKeys), std::move(prekey), std::move(prekeySignature), std::move(oneTimeKeys));
+ }
jsi::Value isNotificationsSessionInitialized(jsi::Runtime &rt) override {
static_assert(
bridging::getParameterCount(&T::isNotificationsSessionInitialized) == 1,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -78,6 +78,12 @@
prekeySignature: string,
oneTimeKeys: string,
) => Promise<string>;
+ +initializeContentSession: (
+ identityKeys: string,
+ prekey: string,
+ prekeySignature: string,
+ oneTimeKeys: string,
+ ) => Promise<string>;
+isNotificationsSessionInitialized: () => Promise<boolean>;
+getCodeVersion: () => number;
+terminate: () => void;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 3:07 AM (17 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2603457
Default Alt Text
D9334.id31558.diff (7 KB)
Attached To
Mode
D9334: [native] new method to initialize content olm session
Attached
Detach File
Event Timeline
Log In to Comment