Notes on Developing with libdweb
August 13, 2018 · View on GitHub
mozilla/libdwebhosts a community effort to implement experimental APIs for Firefox WebExtensions with a goal of enabling dweb protocols in Firefox through browser add-ons. The long term goal of this project is to integrate these APIs into the WebExtensions ecosystem.
See also:
- #343: Create WebExtensions Experiments to Prototype Missing APIs
TL;DR
-
Execute commands below to fetch Firefox Nightly, build and run Companion extension in libdweb-enabled context:
git clone -b libdweb --depth 1 https://github.com/ipfs-shipyard/ipfs-companion.git cd ipfs-companion npm run libdweb -
Optional Smoke-Test:
- Open
ipfs://bafkreickb4yq3sr3q2xqn3z3wzimilsa4wkbx25azqbvcnihq65moyjcvi - Open
ipns://docs.ipfs.io - Open
ipns://tr.wikipedia-on-ipfs.org - Confirm
ipfs://protocol remains in Location Bar (example)
- Open
Developer Notes
Install Firefox Nightly
- Get latest Nightly from http://nightly.mozilla.org/
- libdweb won't run in regular release, it has to be nightly or developer edition
How to Build and run libdweb-enabled bundle
# checkout libdweb branch into a new directory
# including submodules (namely ./libdweb)
git clone -b libdweb --depth 1 https://github.com/ipfs-shipyard/ipfs-companion.git
cd ipfs-companion
# install deps and build
npm run libdweb:build
# run in firefox-nightly
npm run libdweb:firefox
Manually run with different firefox binary
To run your extension in libdweb context:
npm run libdweb:build
export MOZ_DISABLE_CONTENT_SANDBOX=1
web-ext run --firefox=/path/to/nightly/firefox-bin --browser-console --url about:debugging
Additional notes:
- Script
libdweb:firefoxwill download latest Firefox Nightly to./firefox/firefox - After initially running
libdweb:buildit is ok to useyarn watch– it will work as expected
Known Issues
If you are using yarn it may not update github-based dependencies and produce bogus this.content is undefined errors.
Fix is to make sure you run the latest versions of libdweb and other dev deps by removing yarn cache.
Execute yarn cache clean.
Appendix: Smoke-Testing libdweb APIs
Protocol Handler API
- Open
ipfs://bafkreickb4yq3sr3q2xqn3z3wzimilsa4wkbx25azqbvcnihq65moyjcvi - Open
ipns://docs.ipfs.io - Confirm
ipfs://protocol remains in Location Bar (example)
References
- ipfs-companion/issues/#343 – Create WebExtensions Experiments to Prototype Missing APIs
- ipfs-companion/pr/533 -
ipfs://andipns://protocol handlers with libdweb API
- ipfs-companion/pr/533 -
- https://github.com/mozilla/libdweb/ – Extension context containing an experimental libdweb APIs
- https://github.com/orgs/libdweb – API adapters for seamless libdweb integration
#dweb@ irc.mozilla.org