-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose IPFS Core API as window.ipfs #42
Comments
I did a quick prototype for this today: load js-ipfs packaged with the extension, start an instance. Challenges here are similar to #41.
|
So basically as far as I can tell, the js-ipfs instance in the extension can't communicate to anyone except via https. Adding files, etc. would work normally, but an IPFS node without a network is fairly limited in functionality... |
I got something working over here: https://github.com/VictorBjelkholm/js-ipfs-in-the-browser Basically it sets up two parts. One background page for the daemon and handling communication with the content script. Two is the content script that injects functions to the page script. You can download and install this: https://github.com/VictorBjelkholm/js-ipfs-in-the-browser/releases/tag/lol When installed, this page should change from "nope" -> "yeah!" and also show your daemons id: https://ipfs.io/ipfs/QmcVc8eQiWkR23wMKiQjipLRSjCxR1FEj4TL99aY89J83d |
Great work @victorbjelkholm! 🎉 |
After standup call, I'll do the following before moving on:
|
@haadcode maybe you could list the methods you're using in Orbit, and we could get Orbit to work with the extension instance of js-ipfs? I'm betting the shipping JS without js-ipfs/js-ipfs-api would be minimal and load super fast! |
@victorbjelkholm orbit is using .object.put/.get, .pubsub (pretty much all methods), .swarm.peers and .files.add/.cat. And the Electron version uses those + .util.addFromFs and .ls. |
Can I add a request that we document how to get at the other API methods? For example, if I want to use |
So, trouble in wonderland. Seemingly, you cannot pass functions or anything that can't be serialized into JSON between the background and content scripts. This makes the interface of for example Not sure how to solve this, but reached out in Mozilla IRC about confirmation and help with workarounds if possible. Reference: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/sendMessage
|
@victorbjelkholm it is intended behaviour as the background and content scripts might run in separate JS engine instances. |
Probably the next steps here are:
Edit, also:
|
FYSA we hope to deliver this feature via browser extension (it will be an opt-in experiment initially) |
This feature landed in Beta channel of our browser extension. Discussion related to |
Web Extension makes js-ipfs protocol (interface-core-api) available in the browser through window.ipfs
The text was updated successfully, but these errors were encountered: