Skip to content
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

[PoC] libdweb experiment: protocol handler API #533

Closed
wants to merge 35 commits into from
Closed

[PoC] libdweb experiment: protocol handler API #533

wants to merge 35 commits into from

Conversation

lidel
Copy link
Member

@lidel lidel commented Jul 17, 2018

ipfs:// and ipns:// sitting on a tree

Background

This PR aims to implement ipfs:// and ipns:// using browser.protocol.registerProtocol API from mozilla/libdweb. The goal is to ensure proposed API delivers everything IPFS needs, and squash some bugs in the process.

Developer notes on working with libdweb can be found in docs/libdweb.md

ref mozilla/libdweb#2, #343, #164, ipfs/in-web-browsers#6, ipfs/in-web-browsers#14, ipfs/specs#152
cc @Gozala @kyledrake

4 min demo (August 2018)

Lab Day 2018 // Protocol Handler Demo with libdweb and Firefox Nightly

Tasks

  • create libdweb branch which runs libdweb experiments from a single command
  • Wire up the protocol to support common use cases
    • works with external IPFS node
    • works with embedded js-ipfs node
    • loads image with static mime-type
    • loads image or HTML page and let browser to do mime-sniffing
    • loads a directory and renders listing similar to HTTP gateway
    • displays error page on invalid CID/path
      • detect CIDv0 and provide conversion UI
    • supports streaming: plays a big video file
      (API supports this, I am just too sleepy to add this today, will happen soon)
  • look for edge cases, issues with browser UI being HTTP-centric etc and document/report them
    - IN PROGRESS 🚧 🏗️

Known Issues

HTML issues

Missing API / Spec Issues

IPFS-specific, UX Issues, Other

Test Resources

IPFS

  • picture:
    • ipfs://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va (CID codec: dag-pb)
    • ipfs://bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy/(CID coded: raw)
  • html page: ipfs://bafybeidvtwx54qr44kidymvhfzefzxhgkieigwth6oswk75zhlzjdmunoy/linkify-demo.html
  • directory tree: ipfs://babybeiccrv3uc3hjipdnwf4nnntbxuwvt4pn5dsgelvvyueucracbevtha
  • plain text file: ipfs://babybeiccrv3uc3hjipdnwf4nnntbxuwvt4pn5dsgelvvyueucracbevtha/go-proofs/README.md
  • video
    • small video (2MB): ipfs://bafybeigwa5rlpq42cj3arbw27aprhjezhimhqkvhbb2kztjtdxyhjalr3q/big-buck-bunny_trailer.webm
    • standalone trickle-dag webm video (22MB): ipfs://bafybeigxjv2o4jse2lajbd5c7xxl5rluhyqg5yupln42252e5tcao7hbge
    • same video but used in <video src="ipfs://cidv1b32" /> ipfs://bafkreihosso7nxtyhjtpvjmrdoflyup6ex6b2xgzezibavuonobt2l4dai
  • invalid CID (lowercased CIDv0): ipfs://qmbwqxbekc3p8tqskc98xmwnzrzdtrlmimpl8wbutgsmnr/
  • A snapshot of Eng. Wikipedia: ipfs://QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco

IPNS

  • ipns://docs.ipfs.io
  • ipns://cid-utils.ipfs.team
  • ipns://tr.wikipedia-on-ipfs.org
  • ipns://explore.ipld.io
  • ipns://explorecatena.com

Screenshots

ipfs:// demo

2018-09-14-001826_1280x800_scrot

2018-09-14-002106_1280x800_scrot

This is a first step on the road to native protocol handler and more.

mozilla/libdweb is included as a git submodule, which enables us to
develop against latest API prototypes with as little overhead as
possible.

`libdweb-build` will produce extension bundle with access to
experimental APIs

`firefox:libdweb` will start Firefox Nightly with mentioned bundle.
Make sure firefox-nightly is on your PATH
Just a basic handler that reads images and returns them to the browser.

TODO:
 - support directory listing
 - support streaming
 - support mime-sniffing
@lidel lidel added the area/cidv1b32 Moving to CIDv1/Base32 by default label Jul 17, 2018
@lidel lidel added this to the 2018-Q3 milestone Jul 17, 2018
@lidel lidel self-assigned this Jul 17, 2018
- port directory detection from streaming branch in Muon-Brave
- detect streaming responses and return them as async iterator
- trivia: switch from uglify-es to terser to support for-await
@lidel
Copy link
Member Author

lidel commented Jul 22, 2018

Added:

  • streaming
    • 👍 standalone trickle-dag webm video works fine: ipfs://bafybeigxjv2o4jse2lajbd5c7xxl5rluhyqg5yupln42252e5tcao7hbge
    • 👎 use in <video src="ipfs://cidv1b32" /> does not seem to work yet. Opening ipfs://bafkreihosso7nxtyhjtpvjmrdoflyup6ex6b2xgzezibavuonobt2l4dai produces errors, probably due to lack of content-range semantics.
  • error handling
    • basic error message on invalid CID (lowercased CIDv0): ipfs://qmbwqxbekc3p8tqskc98xmwnzrzdtrlmimpl8wbutgsmnr/

@lidel
Copy link
Member Author

lidel commented Aug 2, 2018

Small update: got IPNS working during a short workshop at Dweb Summit :-)

2018-08-02_11-27

Also, simplified docs/libdweb.md it is now 2 commands that require only firefox-nightly, git and npm on your PATH

@lidel lidel force-pushed the libdweb branch 3 times, most recently from 18e78bf to 89543d1 Compare August 3, 2018 18:54
@lidel
Copy link
Member Author

lidel commented Aug 15, 2018

Ack. We are using async handler for multiple reasons, setting arbitrary (future: ipld/legacy-unixfs-v2#11) content type being only one of them (dnslink lookup and other apis are/will be async as well).

Also, some updates:

@lidel lidel mentioned this pull request Dec 9, 2018
@djdv djdv mentioned this pull request Feb 13, 2019
@lidel lidel added status/inactive No significant work in the previous month and removed status/in-progress In progress labels May 28, 2020
@lidel lidel marked this pull request as draft September 22, 2020 12:20
@lidel lidel changed the title [WIP] libdweb experiment: protocol handler API [PoC] libdweb experiment: protocol handler API Sep 22, 2020
@lidel
Copy link
Member Author

lidel commented Sep 22, 2020

This PR was important step towards demonstrating value of IPFS in the browser context, and how future could look like, and unlocked collaborations with Brave, Opera and more to come.

Sadly Mozilla dropped the ball on libdweb in 2019 and APIs used in this PR never landed in Firefox Nightly, and after a year of no activity it is time to close it together with #553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cidv1b32 Moving to CIDv1/Base32 by default area/libdweb Work related to new APIs from Mozilla/libdweb status/inactive No significant work in the previous month
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants