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

View File

@ -39,7 +39,7 @@
(defn get-permission-data [cofx allowed-permission] (defn get-permission-data [cofx allowed-permission]
(let [account (get-in cofx [:db :account/account])] (let [account (get-in cofx [:db :account/account])]
(get {constants/dapp-permission-contact-code (:public-key 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))) allowed-permission)))
(fx/defn send-response-to-bridge (fx/defn send-response-to-bridge

View File

@ -134,7 +134,7 @@
:on-bridge-message #(re-frame/dispatch [:browser/bridge-message-received %]) :on-bridge-message #(re-frame/dispatch [:browser/bridge-message-received %])
:on-load #(re-frame/dispatch [:browser/loading-started]) :on-load #(re-frame/dispatch [:browser/loading-started])
:on-error #(re-frame/dispatch [:browser/error-occured]) :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? (if opt-in?
(js-res/web3-opt-in-init (str network-id)) (js-res/web3-opt-in-init (str network-id))
(js-res/web3-init (js-res/web3-init

View File

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

View File

@ -1,4 +1,6 @@
;; Browser (webview) configuration ;; 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 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", "cost-fee": "Cost/Fee",
"currency-display-name-usd": "United States Dollar", "currency-display-name-usd": "United States Dollar",
"currency-display-name-uah": "Ukraine Hryvnia", "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", "recover-password-invalid": "This account already exists but passwords do not match",
"members-active-none": "no members", "members-active-none": "no members",
"members-none": "no members", "members-none": "no members",