Page MenuHomePhorge

D11571.1768850825.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D11571.1768850825.diff

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
@@ -14,7 +14,6 @@
#ifndef EMSCRIPTEN
#include "../CryptoTools/CryptoModule.h"
-#include "../Notifications/BackgroundDataStorage/NotificationsCryptoModule.h"
#include "CommSecureStore.h"
#include "PlatformSpecificTools.h"
#include "StaffUtils.h"
@@ -553,41 +552,6 @@
return create_table(db, query, "integrity_store");
}
-bool migrate_notifs_crypto_account(sqlite3 *db) {
-#ifndef EMSCRIPTEN
- std::string legacyCryptoAccountDataKey = "cryptoAccountDataKey";
- folly::Optional<std::string> secretKey =
- CommSecureStore::get(legacyCryptoAccountDataKey);
-
- if (!secretKey.hasValue()) {
- return false;
- }
-
- std::unique_ptr<crypto::CryptoModule> legacyNotifsAccount =
- NotificationsCryptoModule::migrateLegacyNotificationsCryptoModule();
-
- if (!legacyNotifsAccount) {
- return true;
- }
-
- std::string insert_notifs_account_query =
- "REPLACE INTO olm_persist_account (id, account_data) "
- "VALUES (?, ?);";
-
- crypto::Persist legacyNotifsPersist =
- legacyNotifsAccount->storeAsB64(secretKey.value());
- std::string notifsAccountData = std::string(
- legacyNotifsPersist.account.begin(), legacyNotifsPersist.account.end());
-
- replaceEntity<OlmPersistAccount>(
- db, insert_notifs_account_query, {NOTIFS_ACCOUNT_ID, notifsAccountData});
-
- return true;
-#else
- return true;
-#endif
-}
-
bool create_synced_metadata_table(sqlite3 *db) {
std::string query =
"CREATE TABLE IF NOT EXISTS synced_metadata ("
@@ -1001,7 +965,7 @@
{35, {create_communities_table, true}},
{36, {create_messages_to_device_table, true}},
{37, {create_integrity_table, true}},
- {38, {migrate_notifs_crypto_account, true}},
+ {38, {[](sqlite3 *) { return true; }, false}},
{39, {create_synced_metadata_table, true}},
{40, {create_keyservers_synced, true}},
{41, {create_aux_user_table, true}}}};
diff --git a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.h b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.h
--- a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.h
+++ b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.h
@@ -39,8 +39,6 @@
const static std::string initialEncryptedMessageContent;
const static int olmEncryptedTypeMessage;
- static std::unique_ptr<crypto::CryptoModule>
- migrateLegacyNotificationsCryptoModule();
static void clearSensitiveData();
static void persistNotificationsSession(
const std::string &keyserverID,
diff --git a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
--- a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
+++ b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
@@ -183,42 +183,6 @@
return {std::move(session), picklingKey};
}
-std::unique_ptr<crypto::CryptoModule>
-NotificationsCryptoModule::migrateLegacyNotificationsCryptoModule() {
- const std::string notificationsCryptoAccountPath =
- PlatformSpecificTools::getNotificationsCryptoAccountPath();
- std::ifstream notificationCryptoAccountCheck(notificationsCryptoAccountPath);
-
- if (!notificationCryptoAccountCheck.good()) {
- notificationCryptoAccountCheck.close();
- return nullptr;
- }
- notificationCryptoAccountCheck.close();
-
- std::string legacySecureStoreNotifsAccountKey =
- "notificationsCryptoAccountDataKey";
- folly::Optional<std::string> legacyPicklingKey =
- CommSecureStore::get(legacySecureStoreNotifsAccountKey);
- if (!legacyPicklingKey.hasValue()) {
- throw std::runtime_error(
- "Attempt to migrate legacy notifications account but pickling key "
- "missing.");
- }
-
- std::unique_ptr<crypto::CryptoModule> legacyCryptoModule =
- NotificationsCryptoModule::deserializeCryptoModule(
- notificationsCryptoAccountPath, legacyPicklingKey.value());
-
- std::string legacyNotificationsSessionID = "keyserverHostedNotificationsID";
- std::shared_ptr<crypto::Session> legacyNotificationsSession =
- legacyCryptoModule->getSessionByDeviceId(legacyNotificationsSessionID);
-
- NotificationsCryptoModule::persistNotificationsSession(
- ashoatKeyserverIDUsedOnlyForMigrationFromLegacyNotifStorage,
- legacyNotificationsSession);
- return legacyCryptoModule;
-}
-
void NotificationsCryptoModule::clearSensitiveData() {
std::string notificationsCryptoAccountPath =
PlatformSpecificTools::getNotificationsCryptoAccountPath();
@@ -332,8 +296,17 @@
}
void NotificationsCryptoModule::LegacyStatefulDecryptResult::flushState() {
+ std::shared_ptr<crypto::Session> legacyNotificationsSession =
+ this->cryptoModule->getSessionByDeviceId(keyserverHostedNotificationsID);
NotificationsCryptoModule::serializeAndFlushCryptoModule(
std::move(this->cryptoModule), this->path, this->picklingKey);
+ try {
+ NotificationsCryptoModule::persistNotificationsSession(
+ ashoatKeyserverIDUsedOnlyForMigrationFromLegacyNotifStorage,
+ legacyNotificationsSession);
+ } catch (const CommMMKV::InitFromNSEForbiddenError &e) {
+ return;
+ }
}
std::unique_ptr<NotificationsCryptoModule::BaseStatefulDecryptResult>
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$@<O00001
literal 0
Hc$@<O00001

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 19, 7:27 PM (19 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5957849
Default Alt Text
D11571.1768850825.diff (5 KB)

Event Timeline