Skip to content

Commit

Permalink
fix: forwards all postmsg-rpc messages between content script and bac…
Browse files Browse the repository at this point in the history
…kground, and upgrade ipfs-postmsg-proxy with fix for pull-postmsg-stream
  • Loading branch information
alanshaw committed Apr 19, 2018
1 parent 15ce18d commit 69eb3a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
8 changes: 6 additions & 2 deletions add-on/src/contentScripts/ipfs-proxy/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ function init () {
const port = browser.runtime.connect({ name: 'ipfs-proxy' })

// Forward on messages from background to the page and vice versa
port.onMessage.addListener((data) => window.postMessage(data, '*'))
port.onMessage.addListener((data) => {
if (data && data.sender && data.sender.startsWith('postmsg-rpc/')) {
window.postMessage(data, '*')
}
})

window.addEventListener('message', (msg) => {
if (msg.data && msg.data.sender === 'postmsg-rpc/client') {
if (msg.data && msg.data.sender && msg.data.sender.startsWith('postmsg-rpc/')) {
port.postMessage(msg.data)
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"ipfs": "0.28.2",
"ipfs-api": "18.2.0",
"ipfs-css": "0.3.0",
"ipfs-postmsg-proxy": "2.15.0",
"ipfs-postmsg-proxy": "2.16.0",
"is-ipfs": "0.3.2",
"is-svg": "3.0.0",
"lru_map": "0.3.3",
Expand Down
28 changes: 9 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4259,9 +4259,9 @@ ipfs-multipart@~0.1.0:
content "^3.0.0"
dicer "^0.2.5"

ipfs-postmsg-proxy@2.15.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/ipfs-postmsg-proxy/-/ipfs-postmsg-proxy-2.15.0.tgz#689d0bcd90e88d792bac50dfc4f8df85b6ba5f26"
ipfs-postmsg-proxy@2.16.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/ipfs-postmsg-proxy/-/ipfs-postmsg-proxy-2.16.0.tgz#ce5506bcb5876f383f746dfd3165eba5b598f23c"
dependencies:
big.js "^5.0.3"
callbackify "^1.1.0"
Expand All @@ -4277,7 +4277,7 @@ ipfs-postmsg-proxy@2.15.0:
prepost "^1.1.0"
pull-abortable "^4.1.1"
pull-defer "^0.2.2"
pull-postmsg-stream "^1.1.3"
pull-postmsg-stream "^1.2.0"
pull-stream "^3.6.7"
pull-stream-to-stream "^1.3.4"
shortid "^2.2.8"
Expand Down Expand Up @@ -7429,12 +7429,6 @@ postcss@6.0.19:
source-map "^0.6.1"
supports-color "^5.2.0"

postmsg-rpc@^2.1.1:
version "2.3.0"
resolved "https://registry.yarnpkg.com/postmsg-rpc/-/postmsg-rpc-2.3.0.tgz#b355afabff1371457af831fe439dd84804229392"
dependencies:
shortid "^2.2.8"

postmsg-rpc@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/postmsg-rpc/-/postmsg-rpc-2.4.0.tgz#4e2daf6851852364696debd5d6bf6936d1424cdf"
Expand Down Expand Up @@ -7469,10 +7463,6 @@ prepend-http@^1.0.0, prepend-http@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"

prepost@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/prepost/-/prepost-1.0.1.tgz#62c55d1ced516127e40ce2e3d8fc1a390cd86c7b"

prepost@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/prepost/-/prepost-1.1.0.tgz#6131567ab6fe3007b50762679f4b500e93e8ccbf"
Expand Down Expand Up @@ -7683,12 +7673,12 @@ pull-pause@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/pull-pause/-/pull-pause-0.0.2.tgz#19d45be8faa615fa556f14a96fd733462c37fba3"

pull-postmsg-stream@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/pull-postmsg-stream/-/pull-postmsg-stream-1.1.3.tgz#1318f4a7a64d7378e5c44db0627f19d29b9f41f1"
pull-postmsg-stream@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/pull-postmsg-stream/-/pull-postmsg-stream-1.2.0.tgz#3898c05abc7c68d972bbd91a69dd30649c33fb00"
dependencies:
postmsg-rpc "^2.1.1"
prepost "^1.0.1"
postmsg-rpc "^2.4.0"
prepost "^1.1.0"

pull-pushable@^2.0.0, pull-pushable@^2.0.1, pull-pushable@^2.1.2, pull-pushable@^2.2.0:
version "2.2.0"
Expand Down

0 comments on commit 69eb3a1

Please sign in to comment.