discard backup message when recovering account (#16748)

* discard backup message when recovering account

* fix test failed

* update status-go-version.json
This commit is contained in:
frank 2023-07-25 15:03:57 +08:00 committed by GitHub
parent 99dc79842d
commit 02d45fa06f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 13 deletions

View File

@ -626,10 +626,10 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
} }
@ReactMethod @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"); Log.d(TAG, "loginWithKeycard");
this.migrateKeyStoreDir(accountData, password); this.migrateKeyStoreDir(accountData, password);
String result = Statusgo.loginWithKeycard(accountData, password, chatKey); String result = Statusgo.loginWithKeycard(accountData, password, chatKey, nodeConfigJSON);
if (result.startsWith("{\"error\":\"\"")) { if (result.startsWith("{\"error\":\"\"")) {
Log.d(TAG, "LoginWithKeycard result: " + result); Log.d(TAG, "LoginWithKeycard result: " + result);
} else { } else {

View File

@ -633,14 +633,15 @@ RCT_EXPORT_METHOD(loginAccount:(NSString *)request) {
RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData
password:(NSString *)password password:(NSString *)password
chatKey:(NSString *)chatKey) { chatKey:(NSString *)chatKey
nodeConfigJSON:(NSString *)nodeConfigJSON) {
#if DEBUG #if DEBUG
NSLog(@"LoginWithKeycard() method called"); NSLog(@"LoginWithKeycard() method called");
#endif #endif
[self getExportDbFilePath]; [self getExportDbFilePath];
[self migrateKeystore:accountData password:password]; [self migrateKeystore:accountData password:password];
NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey); NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey, nodeConfigJSON);
NSLog(@"%@", result); NSLog(@"%@", result);
} }

View File

@ -1041,7 +1041,7 @@ void _LoginWithKeycard(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
if (args.Length() != 3) { if (args.Length() != 4) {
// Throw an Error that is passed back to JavaScript // Throw an Error that is passed back to JavaScript
isolate->ThrowException(Exception::TypeError( isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for LoginWithKeycard"))); String::NewFromUtf8Literal(isolate, "Wrong number of arguments for LoginWithKeycard")));
@ -1065,6 +1065,11 @@ void _LoginWithKeycard(const FunctionCallbackInfo<Value>& args) {
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'keyHex'"))); String::NewFromUtf8Literal(isolate, "Wrong argument type for 'keyHex'")));
return; 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()); String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
@ -1073,9 +1078,11 @@ void _LoginWithKeycard(const FunctionCallbackInfo<Value>& args) {
char *arg1 = *arg1Obj; char *arg1 = *arg1Obj;
String::Utf8Value arg2Obj(isolate, args[2]->ToString(context).ToLocalChecked()); String::Utf8Value arg2Obj(isolate, args[2]->ToString(context).ToLocalChecked());
char *arg2 = *arg2Obj; char *arg2 = *arg2Obj;
String::Utf8Value arg3Obj(isolate, args[3]->ToString(context).ToLocalChecked());
char *arg3 = *arg3Obj;
// Call exported Go function, which returns a C string // 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(); Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret); args.GetReturnValue().Set(ret);

View File

@ -225,12 +225,12 @@
(.verifyDatabasePassword ^js (status) key-uid hashed-password callback)) (.verifyDatabasePassword ^js (status) key-uid hashed-password callback))
(defn login-with-keycard (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") (log/debug "[native-module] login-with-keycard")
(clear-web-data) (clear-web-data)
(init-keystore (init-keystore
key-uid 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 (defn set-soft-input-mode
[mode] [mode]

View File

@ -307,7 +307,7 @@
(defn login (defn login
[args] [args]
(native-module/login-with-keycard args)) (native-module/login-with-keycard (assoc args :node-config {:ProcessBackedupMessages false})))
(defn send-transaction-with-signature (defn send-transaction-with-signature
[{:keys [transaction signature on-completed]}] [{:keys [transaction signature on-completed]}]

View File

@ -253,7 +253,8 @@
encryption-pass encryption-pass
#(let [{:keys [error]} (types/json->clj %)] #(let [{:keys [error]} (types/json->clj %)]
(if (string/blank? error) (if (string/blank? error)
(native-module/login-with-keycard login-params) (native-module/login-with-keycard
(assoc login-params :node-config {:ProcessBackedupMessages true}))
(throw (throw
(js/Error. (js/Error.
"Please shake the phone to report this error and restart the app. Migration failed unexpectedly."))))))) "Please shake the phone to report this error and restart the app. Migration failed unexpectedly.")))))))

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.162.5", "version": "v0.162.9",
"commit-sha1": "cf2d72bfa83f094719a93b7b7fd5a68e3a68ab47", "commit-sha1": "6085a05f77354a26d879f476e67aa85cac1e1414",
"src-sha256": "0x79nm1n6gbgz2lzsky29laap7m0r0hggrb2fsn07bf0xw0364qn" "src-sha256": "0lb87lnfi49fk7ijppppr79rzkg8xzpwb3xxxmmq6wca2nb1pqp5"
} }