mirror of
https://github.com/status-im/status-react.git
synced 2025-02-18 13:58:24 +00:00
Ensure browser sessions can not correlate identities between Status account sessions (#688)
This commit is contained in:
parent
351e54129c
commit
101448b963
@ -2,12 +2,17 @@ package im.status.ethereum.module;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import android.webkit.CookieSyncManager;
|
||||||
|
import android.webkit.WebStorage;
|
||||||
|
|
||||||
import com.facebook.react.bridge.*;
|
import com.facebook.react.bridge.*;
|
||||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -330,4 +335,41 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@ReactMethod
|
||||||
|
public void clearCookies() {
|
||||||
|
Log.d(TAG, "clearCookies");
|
||||||
|
final Activity activity = getCurrentActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
CookieManager.getInstance().removeAllCookies(null);
|
||||||
|
CookieManager.getInstance().flush();
|
||||||
|
} else {
|
||||||
|
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(activity);
|
||||||
|
cookieSyncManager.startSync();
|
||||||
|
CookieManager cookieManager = CookieManager.getInstance();
|
||||||
|
cookieManager.removeAllCookie();
|
||||||
|
cookieManager.removeSessionCookie();
|
||||||
|
cookieSyncManager.stopSync();
|
||||||
|
cookieSyncManager.sync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void clearStorageAPIs() {
|
||||||
|
Log.d(TAG, "clearStorageAPIs");
|
||||||
|
final Activity activity = getCurrentActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebStorage storage = WebStorage.getInstance();
|
||||||
|
if (storage != null) {
|
||||||
|
storage.deleteAllData();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,26 @@ RCT_EXPORT_METHOD(setSoftInputMode: (NSInteger) i) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(clearCookies) {
|
||||||
|
NSHTTPCookie *cookie;
|
||||||
|
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
|
||||||
|
for (cookie in [storage cookies]) {
|
||||||
|
[storage deleteCookie:cookie];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(clearStorageAPIs) {
|
||||||
|
[[NSURLCache sharedURLCache] removeAllCachedResponses];
|
||||||
|
|
||||||
|
NSString *path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
|
||||||
|
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
||||||
|
for (NSString *string in array) {
|
||||||
|
NSLog(@"Removing %@", [path stringByAppendingPathComponent:string]);
|
||||||
|
if ([[string pathExtension] isEqualToString:@"localstorage"])
|
||||||
|
[[NSFileManager defaultManager] removeItemAtPath:[path stringByAppendingPathComponent:string] error:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)signalEvent:(const char *) signal
|
+ (void)signalEvent:(const char *) signal
|
||||||
{
|
{
|
||||||
if(!signal){
|
if(!signal){
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
:change-account
|
:change-account
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [_ [_ address new-account? callback]]
|
(fn [_ [_ address new-account? callback]]
|
||||||
|
(status/clear-web-data)
|
||||||
(data-store/change-account address new-account?
|
(data-store/change-account address new-account?
|
||||||
#(callback % address new-account?)))))
|
#(callback % address new-account?)))))
|
||||||
|
|
||||||
|
@ -151,5 +151,10 @@
|
|||||||
(when status
|
(when status
|
||||||
(call-module #(.setSoftInputMode status mode))))
|
(call-module #(.setSoftInputMode status mode))))
|
||||||
|
|
||||||
|
(defn clear-web-data []
|
||||||
|
(when status
|
||||||
|
(call-module #(.clearCookies status))
|
||||||
|
(call-module #(.clearStorageAPIs status))))
|
||||||
|
|
||||||
(def adjust-resize 16)
|
(def adjust-resize 16)
|
||||||
(def adjust-pan 32)
|
(def adjust-pan 32)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user