add plain url support in all qr scanners, add scanner to browser options
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
a1d091ac19
commit
dd5864ff25
|
@ -140,6 +140,13 @@
|
||||||
{:type :browser
|
{:type :browser
|
||||||
:error :unsafe-link})))
|
:error :unsafe-link})))
|
||||||
|
|
||||||
|
(defn match-browser-string [domain]
|
||||||
|
(if (security/safe-link? domain)
|
||||||
|
{:type :browser
|
||||||
|
:url domain}
|
||||||
|
{:type :browser
|
||||||
|
:error :unsafe-link}))
|
||||||
|
|
||||||
;; NOTE(Ferossgp): Better to handle eip681 also with router instead of regexp.
|
;; NOTE(Ferossgp): Better to handle eip681 also with router instead of regexp.
|
||||||
(defn match-eip681 [uri]
|
(defn match-eip681 [uri]
|
||||||
(if-let [message (eip681/parse-uri uri)]
|
(if-let [message (eip681/parse-uri uri)]
|
||||||
|
@ -218,6 +225,9 @@
|
||||||
(ethereum/address? uri)
|
(ethereum/address? uri)
|
||||||
(cb (address->eip681 uri))
|
(cb (address->eip681 uri))
|
||||||
|
|
||||||
|
(http/url? uri)
|
||||||
|
(cb (match-browser-string uri))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(cb {:type :undefined
|
(cb {:type :undefined
|
||||||
:data uri}))))
|
:data uri}))))
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
[status-im.utils.http :as http]
|
[status-im.utils.http :as http]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
[status-im.ui.components.icons.icons :as icons]
|
[status-im.ui.components.icons.icons :as icons]
|
||||||
[status-im.constants :as constants]))
|
[status-im.constants :as constants]
|
||||||
|
[status-im.qr-scanner.core :as qr-scanner]))
|
||||||
|
|
||||||
(defn hide-sheet-and-dispatch [event]
|
(defn hide-sheet-and-dispatch [event]
|
||||||
(re-frame/dispatch [:bottom-sheet/hide])
|
(re-frame/dispatch [:bottom-sheet/hide])
|
||||||
|
@ -43,6 +44,15 @@
|
||||||
fav? (get bookmarks url)
|
fav? (get bookmarks url)
|
||||||
connected? (some #{constants/dapp-permission-web3} (get-in permissions [(http/url-host url) :permissions]))]
|
connected? (some #{constants/dapp-permission-web3} (get-in permissions [(http/url-host url) :permissions]))]
|
||||||
[react/view {:flex 1}
|
[react/view {:flex 1}
|
||||||
|
[quo/button {:style {:align-self :flex-end
|
||||||
|
:margin-right 15}
|
||||||
|
:type :icon
|
||||||
|
:theme :icon
|
||||||
|
:accessibility-label :universal-qr-scanner
|
||||||
|
:on-press #(hide-sheet-and-dispatch
|
||||||
|
[::qr-scanner/scan-code
|
||||||
|
{:handler ::qr-scanner/on-scan-success}])}
|
||||||
|
:main-icons/qr]
|
||||||
(when-not empty-tab
|
(when-not empty-tab
|
||||||
[:<>
|
[:<>
|
||||||
[quo/list-item
|
[quo/list-item
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
[status-im.ui.components.permissions :as components.permissions]
|
[status-im.ui.components.permissions :as components.permissions]
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[status-im.ui.screens.wallet.components.views :as components]
|
[status-im.ui.screens.wallet.components.views :as components]
|
||||||
[status-im.ui.screens.browser.options.views :as options])
|
[status-im.ui.screens.browser.options.views :as options]
|
||||||
|
[status-im.qr-scanner.core :as qr-scanner])
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
(defn toolbar-content [url url-original secure? url-editing? unsafe?]
|
(defn toolbar-content [url url-original secure? url-editing? unsafe?]
|
||||||
|
@ -93,18 +94,23 @@
|
||||||
:accessibility-label :browser-open-tabs}
|
:accessibility-label :browser-open-tabs}
|
||||||
[icons/icon :main-icons/tabs]]
|
[icons/icon :main-icons/tabs]]
|
||||||
|
|
||||||
|
(if empty-tab
|
||||||
[react/touchable-highlight
|
[react/touchable-highlight
|
||||||
{:on-press #(when-not empty-tab
|
{:accessibility-label :universal-qr-scanner
|
||||||
(re-frame/dispatch
|
:on-press #(re-frame/dispatch
|
||||||
|
[::qr-scanner/scan-code
|
||||||
|
{:handler ::qr-scanner/on-scan-success}])}
|
||||||
|
[icons/icon :main-icons/qr]]
|
||||||
|
[react/touchable-highlight
|
||||||
|
{:on-press #(re-frame/dispatch
|
||||||
[:bottom-sheet/show-sheet
|
[:bottom-sheet/show-sheet
|
||||||
{:content (options/browser-options
|
{:content (options/browser-options
|
||||||
url
|
url
|
||||||
dapps-account
|
dapps-account
|
||||||
empty-tab
|
empty-tab
|
||||||
name)}]))
|
name)}])
|
||||||
:style (when empty-tab styles/disabled-button)
|
|
||||||
:accessibility-label :browser-options}
|
:accessibility-label :browser-options}
|
||||||
[icons/icon :main-icons/more]]]))
|
[icons/icon :main-icons/more]])]))
|
||||||
|
|
||||||
(def resources-to-permissions-map {"android.webkit.resource.VIDEO_CAPTURE" :camera
|
(def resources-to-permissions-map {"android.webkit.resource.VIDEO_CAPTURE" :camera
|
||||||
"android.webkit.resource.AUDIO_CAPTURE" :record-audio})
|
"android.webkit.resource.AUDIO_CAPTURE" :record-audio})
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
[{:icon :qr
|
[{:icon :qr
|
||||||
:accessibility-label :scan-contact-code-button
|
:accessibility-label :scan-contact-code-button
|
||||||
:on-press #(re-frame/dispatch [:wallet.send/qr-scanner
|
:on-press #(re-frame/dispatch [:wallet.send/qr-scanner
|
||||||
{:handler :wallet.send/qr-scanner-result}])}]}])
|
{:ignore-url true
|
||||||
|
:handler :wallet.send/qr-scanner-result}])}]}])
|
||||||
|
|
||||||
(defonce search-active? (reagent/atom false))
|
(defonce search-active? (reagent/atom false))
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,12 @@
|
||||||
(string/replace host #"www." "")))
|
(string/replace host #"www." "")))
|
||||||
(catch :default _ nil)))
|
(catch :default _ nil)))
|
||||||
|
|
||||||
|
(defn url? [str]
|
||||||
|
(try
|
||||||
|
(when-let [host (.getDomain ^js (goog.Uri. str))]
|
||||||
|
(not (string/blank? host)))
|
||||||
|
(catch :default _ nil)))
|
||||||
|
|
||||||
(defn parse-payload [o]
|
(defn parse-payload [o]
|
||||||
(when o
|
(when o
|
||||||
(try
|
(try
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
(fx/defn handle-eip681 [cofx data]
|
(fx/defn handle-eip681 [cofx data]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(choose-recipient/parse-eip681-uri-and-resolve-ens data)
|
(choose-recipient/parse-eip681-uri-and-resolve-ens data true)
|
||||||
(navigation/navigate-to-cofx :wallet nil)))
|
(navigation/navigate-to-cofx :wallet nil)))
|
||||||
|
|
||||||
(fx/defn handle-referrer-url [_ {:keys [referrer]}]
|
(fx/defn handle-referrer-url [_ {:keys [referrer]}]
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
[status-im.router.core :as router]
|
[status-im.router.core :as router]
|
||||||
[status-im.qr-scanner.core :as qr-scaner]
|
[status-im.qr-scanner.core :as qr-scaner]
|
||||||
[status-im.bottom-sheet.core :as bottom-sheet]
|
[status-im.bottom-sheet.core :as bottom-sheet]
|
||||||
[status-im.navigation :as navigation]))
|
[status-im.navigation :as navigation]
|
||||||
|
[status-im.utils.http :as http]
|
||||||
|
[status-im.utils.universal-links.utils :as links]))
|
||||||
|
|
||||||
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
|
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
|
||||||
(fx/defn toggle-flashlight
|
(fx/defn toggle-flashlight
|
||||||
|
@ -102,7 +104,7 @@
|
||||||
|
|
||||||
(fx/defn parse-eip681-uri-and-resolve-ens
|
(fx/defn parse-eip681-uri-and-resolve-ens
|
||||||
{:events [:wallet/parse-eip681-uri-and-resolve-ens]}
|
{:events [:wallet/parse-eip681-uri-and-resolve-ens]}
|
||||||
[{db :db :as cofx} {:keys [message uri paths ens-names error]}]
|
[{db :db :as cofx} {:keys [message uri paths ens-names error]} ignore-url]
|
||||||
(if-not error
|
(if-not error
|
||||||
;; first we get a vector of ens-names to resolve and a vector of paths of
|
;; first we get a vector of ens-names to resolve and a vector of paths of
|
||||||
;; these names
|
;; these names
|
||||||
|
@ -122,11 +124,15 @@
|
||||||
(assoc-in message path address))
|
(assoc-in message path address))
|
||||||
message
|
message
|
||||||
(map vector paths addresses)) uri]))}})
|
(map vector paths addresses)) uri]))}})
|
||||||
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})}))
|
(if (and (http/url? uri) (not ignore-url))
|
||||||
|
(if (links/universal-link? uri)
|
||||||
|
{:dispatch [:universal-links/handle-url uri]}
|
||||||
|
{:browser/show-browser-selection uri})
|
||||||
|
{:ui/show-error (i18n/label :t/wallet-invalid-address {:data uri})})))
|
||||||
|
|
||||||
(fx/defn qr-scanner-result
|
(fx/defn qr-scanner-result
|
||||||
{:events [:wallet.send/qr-scanner-result]}
|
{:events [:wallet.send/qr-scanner-result]}
|
||||||
[cofx data _]
|
[cofx data {:keys [ignore-url]}]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(navigation/navigate-back)
|
(navigation/navigate-back)
|
||||||
(parse-eip681-uri-and-resolve-ens (router/match-eip681 data))))
|
(parse-eip681-uri-and-resolve-ens (router/match-eip681 data) ignore-url)))
|
||||||
|
|
Loading…
Reference in New Issue