Export unencrypted db on iOS

This commit is contained in:
Roman Volosovskyi 2021-11-01 14:08:54 +02:00
parent 1034d542db
commit 9035954f8b
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
4 changed files with 24 additions and 12 deletions

View File

@ -371,7 +371,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
} }
@ReactMethod @ReactMethod
public void exportUnencryptedDatabase(final String accountData, final String password) { public void exportUnencryptedDatabase(final String accountData, final String password, final Callback callback) {
Log.d(TAG, "login"); Log.d(TAG, "login");
final File newFile = getExportDBFile(); final File newFile = getExportDBFile();

View File

@ -853,11 +853,16 @@ StatusgoStartLocalNotifications();
} }
RCT_EXPORT_METHOD(exportUnencryptedDatabase:(NSString *)accountData RCT_EXPORT_METHOD(exportUnencryptedDatabase:(NSString *)accountData
password:(NSString *)password) { password:(NSString *)password
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG #if DEBUG
NSLog(@"exportUnencryptedDatabase() method called"); NSLog(@"exportUnencryptedDatabase() method called");
#endif #endif
""; NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"export.db"];
StatusgoExportUnencryptedDatabase(accountData, password, filePath);
callback(@[filePath]);
} }
RCT_EXPORT_METHOD(importUnencryptedDatabase:(NSString *)accountData RCT_EXPORT_METHOD(importUnencryptedDatabase:(NSString *)accountData

View File

@ -38,7 +38,9 @@
[status-im.navigation :as navigation] [status-im.navigation :as navigation]
[status-im.signing.eip1559 :as eip1559] [status-im.signing.eip1559 :as eip1559]
[status-im.data-store.chats :as data-store.chats] [status-im.data-store.chats :as data-store.chats]
[status-im.data-store.visibility-status-updates :as visibility-status-updates-store])) [status-im.data-store.visibility-status-updates :as visibility-status-updates-store]
[status-im.ui.components.react :as react]
[status-im.utils.platform :as platform]))
(re-frame/reg-fx (re-frame/reg-fx
::initialize-communities-enabled ::initialize-communities-enabled
@ -65,8 +67,8 @@
(re-frame/reg-fx (re-frame/reg-fx
::export-db ::export-db
(fn [[key-uid account-data hashed-password]] (fn [[key-uid account-data hashed-password callback]]
(status/export-db key-uid account-data hashed-password))) (status/export-db key-uid account-data hashed-password callback)))
(re-frame/reg-fx (re-frame/reg-fx
::import-db ::import-db
@ -146,7 +148,12 @@
(types/clj->json {:name name (types/clj->json {:name name
:key-uid key-uid :key-uid key-uid
:identicon identicon}) :identicon identicon})
(ethereum/sha3 (security/safe-unmask-data password))]})) (ethereum/sha3 (security/safe-unmask-data password))
(fn [path]
(when platform/ios?
(let [uri (str "file://" path)]
(.share ^js react/sharing (clj->js {:title "Unencrypted database"
:url uri})))))]}))
(fx/defn import-db-submitted (fx/defn import-db-submitted
{:events [:multiaccounts.login.ui/import-db-submitted]} {:events [:multiaccounts.login.ui/import-db-submitted]}

View File

@ -66,12 +66,12 @@
(defn export-db (defn export-db
"NOTE: beware, the password has to be sha3 hashed" "NOTE: beware, the password has to be sha3 hashed"
[key-uid account-data hashed-password] [key-uid account-data hashed-password callback]
(log/debug "[native-module] export-db") (log/debug "[native-module] export-db")
(clear-web-data) (clear-web-data)
(init-keystore (init-keystore
key-uid key-uid
#(.exportUnencryptedDatabase ^js (status) account-data hashed-password))) #(.exportUnencryptedDatabase ^js (status) account-data hashed-password callback)))
(defn import-db (defn import-db
"NOTE: beware, the password has to be sha3 hashed" "NOTE: beware, the password has to be sha3 hashed"