Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discard backup message when recovering account #16748

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,10 @@ public void migrateKeyStoreDir(final String accountData, final String password)
}

@ReactMethod
public void loginWithKeycard(final String accountData, final String password, final String chatKey) {
public void loginWithKeycard(final String accountData, final String password, final String chatKey, final String nodeConfigJSON) {
Log.d(TAG, "loginWithKeycard");
this.migrateKeyStoreDir(accountData, password);
String result = Statusgo.loginWithKeycard(accountData, password, chatKey);
String result = Statusgo.loginWithKeycard(accountData, password, chatKey, nodeConfigJSON);
if (result.startsWith("{\"error\":\"\"")) {
Log.d(TAG, "LoginWithKeycard result: " + result);
} else {
Expand Down
5 changes: 3 additions & 2 deletions modules/react-native-status/ios/RCTStatus/RCTStatus.m
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,15 @@ - (void) migrateKeystore:(NSString *)accountData

RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData
password:(NSString *)password
chatKey:(NSString *)chatKey) {
chatKey:(NSString *)chatKey
nodeConfigJSON:(NSString *)nodeConfigJSON) {
#if DEBUG
NSLog(@"LoginWithKeycard() method called");
#endif
[self getExportDbFilePath];
[self migrateKeystore:accountData password:password];

NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey);
NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey, nodeConfigJSON);

NSLog(@"%@", result);
}
Expand Down
11 changes: 9 additions & 2 deletions modules/react-native-status/nodejs/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ void _LoginWithKeycard(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();

if (args.Length() != 3) {
if (args.Length() != 4) {
// Throw an Error that is passed back to JavaScript
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for LoginWithKeycard")));
Expand All @@ -1065,6 +1065,11 @@ void _LoginWithKeycard(const FunctionCallbackInfo<Value>& args) {
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'keyHex'")));
return;
}
if (!args[3]->IsString()) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'nodeConfigJSON'")));
return;
}


String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
Expand All @@ -1073,9 +1078,11 @@ void _LoginWithKeycard(const FunctionCallbackInfo<Value>& args) {
char *arg1 = *arg1Obj;
String::Utf8Value arg2Obj(isolate, args[2]->ToString(context).ToLocalChecked());
char *arg2 = *arg2Obj;
String::Utf8Value arg3Obj(isolate, args[3]->ToString(context).ToLocalChecked());
char *arg3 = *arg3Obj;

// Call exported Go function, which returns a C string
char *c = LoginWithKeycard(arg0, arg1, arg2);
char *c = LoginWithKeycard(arg0, arg1, arg2, arg3);

Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret);
Expand Down
4 changes: 2 additions & 2 deletions src/native_module/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@
(.verifyDatabasePassword ^js (status) key-uid hashed-password callback))

(defn login-with-keycard
[{:keys [key-uid multiaccount-data password chat-key]}]
[{:keys [key-uid multiaccount-data password chat-key node-config]}]
(log/debug "[native-module] login-with-keycard")
(clear-web-data)
(init-keystore
key-uid
#(.loginWithKeycard ^js (status) multiaccount-data password chat-key)))
#(.loginWithKeycard ^js (status) multiaccount-data password chat-key (types/clj->json node-config))))

(defn set-soft-input-mode
[mode]
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/keycard/real_keycard.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@

(defn login
[args]
(native-module/login-with-keycard args))
(native-module/login-with-keycard (assoc args :node-config {:ProcessBackedupMessages false})))

(defn send-transaction-with-signature
[{:keys [transaction signature on-completed]}]
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/keycard/recovery.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@
encryption-pass
#(let [{:keys [error]} (types/json->clj %)]
(if (string/blank? error)
(native-module/login-with-keycard login-params)
(native-module/login-with-keycard
(assoc login-params :node-config {:ProcessBackedupMessages true}))
(throw
(js/Error.
"Please shake the phone to report this error and restart the app. Migration failed unexpectedly.")))))))
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.162.5",
"commit-sha1": "cf2d72bfa83f094719a93b7b7fd5a68e3a68ab47",
"src-sha256": "0x79nm1n6gbgz2lzsky29laap7m0r0hggrb2fsn07bf0xw0364qn"
"version": "v0.162.9",
"commit-sha1": "6085a05f77354a26d879f476e67aa85cac1e1414",
"src-sha256": "0lb87lnfi49fk7ijppppr79rzkg8xzpwb3xxxmmq6wca2nb1pqp5"
}