introduced browser privacy mode

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-11-08 15:48:11 +01:00
parent 5e2c192524
commit 88b43e7dc2
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
6 changed files with 16 additions and 17 deletions

View File

@ -1,6 +1,7 @@
if(typeof ReadOnlyProvider === "undefined"){
var callbackId = 0;
var callbacks = {};
var currentAccountAddress;
function bridgeSend(data){
WebViewBridge.send(JSON.stringify(data));
@ -54,11 +55,9 @@ WebViewBridge.onMessage = function (message) {
qrCodeResponse(data, callback);
} else if (data.isAllowed) {
if (data.permission == 'web3') {
window.currentAccountAddress = data.data;
callback.resolve();
} else {
callback.resolve(data.data);
currentAccountAddress = data.data[0];
}
callback.resolve(data.data);
} else {
callback.reject(new Error("Denied"));
}
@ -85,7 +84,6 @@ function web3Response (payload, result){
}
function getSyncResponse (payload) {
console.log("getSyncResponse " + payload.method + " !")
if (payload.method == "eth_accounts" && currentAccountAddress){
return web3Response(payload, [currentAccountAddress])
} else if (payload.method == "eth_coinbase" && currentAccountAddress){
@ -132,7 +130,6 @@ ReadOnlyProvider.prototype.send = function (payload) {
};
ReadOnlyProvider.prototype.sendAsync = function (payload, callback) {
var syncResponse = getSyncResponse(payload);
if (syncResponse && callback){
callback(null, syncResponse);

View File

@ -39,7 +39,7 @@
(defn get-permission-data [cofx allowed-permission]
(let [account (get-in cofx [:db :account/account])]
(get {constants/dapp-permission-contact-code (:public-key account)
constants/dapp-permission-web3 (ethereum/normalized-address (:address account))}
constants/dapp-permission-web3 [(ethereum/normalized-address (:address account))]}
allowed-permission)))
(fx/defn send-response-to-bridge

View File

@ -134,7 +134,7 @@
:on-bridge-message #(re-frame/dispatch [:browser/bridge-message-received %])
:on-load #(re-frame/dispatch [:browser/loading-started])
:on-error #(re-frame/dispatch [:browser/error-occured])
:injected-on-start-loading-java-script (str (not opt-in?) js-res/web3
:injected-on-start-loading-java-script (str (when-not opt-in? js-res/web3)
(if opt-in?
(js-res/web3-opt-in-init (str network-id))
(js-res/web3-init

View File

@ -98,7 +98,7 @@
:source source
:value value}]))
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]} currency]
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]} {:keys [settings]} currency]
(let [show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))]
[react/view
[profile.components/settings-title (i18n/label :t/settings)]
@ -122,6 +122,11 @@
:action-fn #(re-frame/dispatch [:navigate-to :backup-seed])
:icon-content [components.common/counter {:size 22} 1]}])
[profile.components/settings-item-separator]
[profile.components/settings-switch-item
{:label-kw :t/web3-opt-in
:value (:web3-opt-in? settings)
:action-fn #(re-frame/dispatch [:accounts.ui/web3-opt-in-mode-switched %])}]
[profile.components/settings-item-separator]
[profile.components/settings-item
{:label-kw :t/need-help
:accessibility-label :help-button
@ -183,11 +188,6 @@
{:label-kw :t/devices
:action-fn #(re-frame/dispatch [:navigate-to :installations])
:accessibility-label :pairing-settings-button}])
(when dev-mode?
[profile.components/settings-switch-item
{:label-kw :t/web3-opt-in
:value (:web3-opt-in? settings)
:action-fn #(re-frame/dispatch [:accounts.ui/web3-opt-in-mode-switched %])}])
[profile.components/settings-item-separator]
[profile.components/settings-switch-item
{:label-kw :t/dev-mode
@ -252,5 +252,5 @@
:accessibility-label :share-my-profile-button}
(i18n/label :t/share-my-profile)]]
[react/view styles/my-profile-info-container
[my-profile-settings current-account currency]]
[my-profile-settings current-account shown-account currency]]
[advanced shown-account on-show-advanced]]])))

View File

@ -1,4 +1,6 @@
;; Browser (webview) configuration
;; :inject-js is a map of {<domain> <js-code>}, JS code will be injected if the domain name matches (www. is stripped away)
{:inject-js {"cryptokitties.co" "; if (!window.chrome) { window.chrome = { webstore: true }; window.ethereum.isMetaMask = web3.currentProvider.isMetaMask = true; }"}}
{:inject-js {"cryptokitties.co" "; if (!window.chrome) { window.chrome = { webstore: true };
if (ethereum) ethereum.isMetaMask = true;
if (web3 && web3.currentProvider) web3.currentProvider.isMetaMask = true; }"}}

View File

@ -701,7 +701,7 @@
"cost-fee": "Cost/Fee",
"currency-display-name-usd": "United States Dollar",
"currency-display-name-uah": "Ukraine Hryvnia",
"web3-opt-in": "Opt-in web3 provider access",
"web3-opt-in": "Browser privacy mode",
"recover-password-invalid": "This account already exists but passwords do not match",
"members-active-none": "no members",
"members-none": "no members",