Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
it loads an IPFS node!
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 22, 2017
1 parent 3e82c59 commit 08b4f38
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/extensions/brave/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- TODO: Don't allow img-src *, needed for favicons -->
<!-- TODO: Refactor away all unsafe-inline content -->
<!-- TODO: Replace suggestqueries.google.com and ac.duckduckgo.com and other search engines with a single config search engine -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action http://localhost:*; script-src 'self' http://localhost:*; connect-src 'self' https://s3.amazonaws.com/adblock-data/ https://s3.amazonaws.com/safe-browsing-data/ https://s3.amazonaws.com/tracking-protection-data/ https://s3.amazonaws.com/https-everywhere-data/ http://localhost:* ws://localhost:* https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://www.startpage.com https://infogalactic.com https://api.qwant.com https://ac.ecosia.org https://searx.me https://www.findx.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://brave-download.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; style-src 'unsafe-inline'; font-src 'self' http://localhost:*; img-src 'self' * data: file: chrome-extension:; object-src 'self'; plugin-types application/browser-plugin">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action http://localhost:*; script-src 'self' 'unsafe-eval' http://localhost:*; connect-src 'self' https://s3.amazonaws.com/adblock-data/ https://s3.amazonaws.com/safe-browsing-data/ https://s3.amazonaws.com/tracking-protection-data/ https://s3.amazonaws.com/https-everywhere-data/ http://localhost:* ws://localhost:* https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://www.startpage.com https://infogalactic.com https://api.qwant.com https://ac.ecosia.org https://searx.me https://www.findx.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://brave-download.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; style-src 'unsafe-inline'; font-src 'self' http://localhost:*; img-src 'self' * data: file: chrome-extension:; object-src 'self'; plugin-types application/browser-plugin">
<meta name="referrer" content="no-referrer">
<title>Brave</title>
<script src="ext/l20n.min.js"></script>
Expand Down
22 changes: 18 additions & 4 deletions app/extensions/ipfs/js/main.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
/* global Ipfs */

// const ipc = window.chrome.ipcRenderer

chrome.protocol.registerStringProtocol('ipfs', handler)
chrome.protocol.registerStringProtocol('dweb', handler)

function handler (request, callback) {
// test to check if handling the protocol works
callback('hi there!' + test()) // eslint-disable-line
// callback('hi there!' + test()) // eslint-disable-line

/*
const node = new Ipfs()

node.on('ready', () => {
callback('hi there!' + test() + Ipfs) // eslint-disable-line
node.files.cat('QmSmuETUoXzh4Qo5upHxJWZJK8AEpXXZdTqs34ttE3qMYn', (err, stream) => {
if (err) {
return callback('failed to get the hash')
}
let buf = ''
stream.on('data', (data) => {
buf += data.toString()
})
stream.on('end', () => {
callback(buf)
})
})
// callback('I am online!') // eslint-disable-line
})
*/

// test loading Ipfs into the background process scope
// callback('hi there!' + test() + Ipfs.toString()) // eslint-disable-line
}
4 changes: 3 additions & 1 deletion app/extensions/ipfs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"background": {
"scripts": [
"js/some-other.js",
"js/ipfs.min.js",
"js/main.js"
],
"persistent": true
}
},
"content_security_policy": "script-src 'self' 'unsafe-eval'"
}

0 comments on commit 08b4f38

Please sign in to comment.