diff --git a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h --- a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h +++ b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h @@ -30,6 +30,9 @@ std::string sqliteFilePath, std::string sqliteEncryptionKey) override; void closeConnection() override; + virtual void validateEncryption( + const std::string &sqliteFilePath, + const std::string &encryptionKey) override; void setLogsMonitoring(bool enabled); bool getLogsMonitoring(); diff --git a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp @@ -271,4 +271,11 @@ SQLiteConnectionManager::restoreFromBackupLog(backupLog); setLogsMonitoring(initialEnabledValue); } + +void NativeSQLiteConnectionManager::validateEncryption( + const std::string &sqliteFilePath, + const std::string &encryptionKey) { + SQLiteUtils::validateEncryption(sqliteFilePath, encryptionKey); +} + } // namespace comm diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h @@ -41,6 +41,10 @@ sqlite3 *getConnection(); virtual void closeConnection() = 0; + virtual void validateEncryption( + const std::string &sqliteFilePath, + const std::string &encryptionKey) = 0; + virtual void restoreFromBackupLog(const std::vector &backupLog); }; } // 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 @@ -42,13 +42,8 @@ #endif void SQLiteQueryExecutor::migrate() { -// We don't want to run `PRAGMA key = ...;` -// on main web database. The context is here: -// https://linear.app/comm/issue/ENG-6398/issues-with-sqlcipher-on-web -#ifndef EMSCRIPTEN - SQLiteUtils::validateEncryption( + SQLiteQueryExecutor::connectionManager.validateEncryption( SQLiteQueryExecutor::sqliteFilePath, SQLiteQueryExecutor::backupDataKey); -#endif std::stringstream db_path; db_path << "db path: " << SQLiteQueryExecutor::sqliteFilePath.c_str() diff --git a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h --- a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h +++ b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h @@ -16,5 +16,8 @@ std::string sqliteFilePath, std::string sqliteEncryptionKey) override; void closeConnection() override; + virtual void validateEncryption( + const std::string &sqliteFilePath, + const std::string &encryptionKey) override; }; } // namespace comm diff --git a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp @@ -35,4 +35,14 @@ // https://linear.app/comm/issue/ENG-6398/issues-with-sqlcipher-on-web } +void WebSQLiteConnectionManager::validateEncryption( + const std::string &sqliteFilePath, + const std::string &encryptionKey) { + // We don't want to run `PRAGMA key = ...;` + // on main web database. The context is here: + // https://linear.app/comm/issue/ENG-6398/issues-with-sqlcipher-on-web + // For more context, see NativeSQLiteConnectionManager::validateEncryption + // implementation. +} + } // namespace comm diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@