[#6587] IPFS hosted apps should not share cookies/etc

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2019-01-31 11:55:09 +01:00
parent b80e02d8cf
commit 5fe9e3d156
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
5 changed files with 21 additions and 7 deletions

View File

@ -40,7 +40,8 @@
"react-native-fetch-polyfill"
"text-encoding"
"js-sha3"
"react-navigation"]
"react-navigation"
"hi-base32"]
;; Desktop modules
:desktop-modules ["realm"

View File

@ -66,7 +66,8 @@
"text-encoding": "^0.6.4",
"url": "0.10.3",
"web3": "git+https://github.com/status-im/web3.js.git#0.20.1-status",
"web3-utils": "1.0.0-beta.36"
"web3-utils": "1.0.0-beta.36",
"hi-base32": "0.5.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.47"

View File

@ -3786,6 +3786,11 @@ hash.js@^1.0.0, hash.js@^1.0.3:
inherits "^2.0.3"
minimalistic-assert "^1.0.1"
hi-base32@0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/hi-base32/-/hi-base32-0.5.0.tgz#61329f76a31f31008533f1c36f2473e259d64571"
integrity sha512-DDRmxSyoYuvjUb9EnXdoiMChBZ7ZcUVJsK5Frd3kqMhuBxvmZdnBeynAVfj7/ECbn++CekcoprvC/rprHPAtow==
hmac-drbg@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"

View File

@ -20,7 +20,8 @@
[status-im.utils.random :as random]
[status-im.utils.types :as types]
[status-im.utils.universal-links.core :as utils.universal-links]
[taoensso.timbre :as log]))
[taoensso.timbre :as log]
[status-im.js-dependencies :as js-dependencies]))
(fx/defn initialize-browsers
[{:keys [db all-stored-browsers]}]
@ -177,14 +178,19 @@
[{:keys [db] :as cofx} proto-code hash]
(let [current-url (get-current-url (get-current-browser db))
host (http/url-host current-url)
gateways (if (= swarm-proto-code proto-code) "swarm-gateways.net/bzz:/" "ipfs.infura.io/ipfs/")]
path (subs current-url (+ (.indexOf current-url host) (count host)))
gateway (if (= ipfs-proto-code proto-code)
(let [base32hash (-> (.encode js-dependencies/hi-base32 (alphabase.base58/decode hash))
(string/replace #"=" "")
(string/lower-case))]
(str base32hash ".infura.status.im"))
(str "swarm-gateways.net/bzz:/" hash))]
(fx/merge cofx
{:db (-> (update db :browser/options
assoc
:url (str "https://" gateways hash
(subs current-url (+ (.indexOf current-url host) (count host))))
:url (str "https://" gateway path)
:resolving? false)
(assoc-in [:browser/options :resolved-ens host] (str gateways hash)))})))
(assoc-in [:browser/options :resolved-ens host] gateway))})))
(fx/defn resolve-ens-multihash-error
[{:keys [db] :as cofx}]

View File

@ -9,3 +9,4 @@
(def text-encoding (js/require "text-encoding"))
(def js-sha3 (js/require "js-sha3"))
(def web3-utils (js/require "web3-utils"))
(def hi-base32 (js/require "hi-base32"))