Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3174992
D8550.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D8550.diff
View Options
diff --git a/native/cpp/CommonCpp/CryptoTools/Tools.h b/native/cpp/CommonCpp/CryptoTools/Tools.h
--- a/native/cpp/CommonCpp/CryptoTools/Tools.h
+++ b/native/cpp/CommonCpp/CryptoTools/Tools.h
@@ -4,7 +4,9 @@
#include <string>
#include <vector>
+#ifndef EMSCRIPTEN
#include "olm/olm.h"
+#endif
// base64-encoded
#define KEYSIZE 43
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -11,14 +11,18 @@
#include "entities/Report.h"
#include "entities/Thread.h"
+#ifndef EMSCRIPTEN
#include <folly/Optional.h>
-
#include <jsi/jsi.h>
+#endif
+
#include <string>
namespace comm {
+#ifndef EMSCRIPTEN
namespace jsi = facebook::jsi;
+#endif
/**
* if any initialization/cleaning up steps are required for specific
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -11,19 +11,21 @@
class SQLiteQueryExecutor : public DatabaseQueryExecutor {
static void migrate();
- static void assign_encryption_key();
static auto &getStorage();
static std::once_flag initialized;
static int sqlcipherEncryptionKeySize;
static std::string secureStoreEncryptionKeyID;
+#ifndef EMSCRIPTEN
+ static void assign_encryption_key();
+#endif
+
public:
static std::string sqliteFilePath;
static std::string encryptionKey;
SQLiteQueryExecutor();
- static void initialize(std::string &databasePath);
std::unique_ptr<Thread> getThread(std::string threadID) const override;
std::string getDraft(std::string key) const override;
void updateDraft(std::string key, std::string text) const override;
@@ -78,7 +80,11 @@
void setMetadata(std::string entry_name, std::string data) const override;
void clearMetadata(std::string entry_name) const override;
std::string getMetadata(std::string entry_name) const override;
+
+#ifndef EMSCRIPTEN
static void clearSensitiveData();
+ static void initialize(std::string &databasePath);
+#endif
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -1,5 +1,4 @@
#include "SQLiteQueryExecutor.h"
-#include "CommSecureStore.h"
#include "Logger.h"
#include "sqlite_orm.h"
@@ -8,6 +7,10 @@
#include <iostream>
#include <thread>
+#ifndef EMSCRIPTEN
+#include "CommSecureStore.h"
+#endif
+
#define ACCOUNT_ID 1
namespace comm {
@@ -850,15 +853,6 @@
sqlite3_close(db);
}
-void SQLiteQueryExecutor::assign_encryption_key() {
- CommSecureStore commSecureStore{};
- std::string encryptionKey = comm::crypto::Tools::generateRandomHexString(
- SQLiteQueryExecutor::sqlcipherEncryptionKeySize);
- commSecureStore.set(
- SQLiteQueryExecutor::secureStoreEncryptionKeyID, encryptionKey);
- SQLiteQueryExecutor::encryptionKey = encryptionKey;
-}
-
auto &SQLiteQueryExecutor::getStorage() {
static auto storage = make_storage(
SQLiteQueryExecutor::sqliteFilePath,
@@ -941,21 +935,6 @@
return storage;
}
-void SQLiteQueryExecutor::initialize(std::string &databasePath) {
- std::call_once(SQLiteQueryExecutor::initialized, [&databasePath]() {
- SQLiteQueryExecutor::sqliteFilePath = databasePath;
- CommSecureStore commSecureStore{};
- folly::Optional<std::string> maybeEncryptionKey =
- commSecureStore.get(SQLiteQueryExecutor::secureStoreEncryptionKeyID);
-
- if (file_exists(databasePath) && maybeEncryptionKey) {
- SQLiteQueryExecutor::encryptionKey = maybeEncryptionKey.value();
- return;
- }
- SQLiteQueryExecutor::assign_encryption_key();
- });
-}
-
SQLiteQueryExecutor::SQLiteQueryExecutor() {
SQLiteQueryExecutor::migrate();
}
@@ -1286,6 +1265,7 @@
return (entry == nullptr) ? "" : entry->data;
}
+#ifndef EMSCRIPTEN
void SQLiteQueryExecutor::clearSensitiveData() {
if (file_exists(SQLiteQueryExecutor::sqliteFilePath) &&
std::remove(SQLiteQueryExecutor::sqliteFilePath.c_str())) {
@@ -1298,4 +1278,29 @@
SQLiteQueryExecutor::migrate();
}
+void SQLiteQueryExecutor::initialize(std::string &databasePath) {
+ std::call_once(SQLiteQueryExecutor::initialized, [&databasePath]() {
+ SQLiteQueryExecutor::sqliteFilePath = databasePath;
+ CommSecureStore commSecureStore{};
+ folly::Optional<std::string> maybeEncryptionKey =
+ commSecureStore.get(SQLiteQueryExecutor::secureStoreEncryptionKeyID);
+
+ if (file_exists(databasePath) && maybeEncryptionKey) {
+ SQLiteQueryExecutor::encryptionKey = maybeEncryptionKey.value();
+ return;
+ }
+ SQLiteQueryExecutor::assign_encryption_key();
+ });
+}
+
+void SQLiteQueryExecutor::assign_encryption_key() {
+ CommSecureStore commSecureStore{};
+ std::string encryptionKey = comm::crypto::Tools::generateRandomHexString(
+ SQLiteQueryExecutor::sqlcipherEncryptionKeySize);
+ commSecureStore.set(
+ SQLiteQueryExecutor::secureStoreEncryptionKeyID, encryptionKey);
+ SQLiteQueryExecutor::encryptionKey = encryptionKey;
+}
+#endif
+
} // namespace comm
diff --git a/web/database/_generated/comm_query_executor.wasm b/web/database/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/web/scripts/run_emscripten.sh b/web/scripts/run_emscripten.sh
--- a/web/scripts/run_emscripten.sh
+++ b/web/scripts/run_emscripten.sh
@@ -88,6 +88,7 @@
INPUT_FILES=(
"${INPUT_DIR}CommQueryExecutor.cpp"
+ "${INPUT_DIR}SQLiteQueryExecutor.cpp"
"${WEB_CPP_DIR}Logger.cpp"
"$SQLITE_BITCODE_FILE"
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 7:31 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2445030
Default Alt Text
D8550.diff (5 KB)
Attached To
Mode
D8550: [native] hide native-specific code
Attached
Detach File
Event Timeline
Log In to Comment