aragon / aragon.js

(Aragon 1) A monorepo of JavaScript libraries for interacting with Aragon
https://aragon.org
GNU Affero General Public License v3.0
82 stars 58 forks source link

API: global IPFS cache + resolver #290

Open sohkai opened 5 years ago

sohkai commented 5 years ago

It would be interesting for @aragon/wrapper to hold an in-memory (or indexedDB) IPFS cache with a resolver API exposed to apps.

Aragon apps could fetch IPFS files through a shared bus and have results cached for faster loads afterwards (optional, but most likely enabled by default). Apps could even use this API to "preload" IPFS files that users may be interested in later, such as for rendering certain parts of UIs that users may not immediately see.

An initial API on the app side could look like:

api.ipfsResolve(path: string, { cache: bool, timeout: Number }): Promise<string>

Where path could be a direct hash or an IPLD path.

cc @stellarmagnet @osarrouy

osarrouy commented 5 years ago

That sounds great!

As discussed with Brett a couple of days ago I realized that we also rely on the js-ipld-git format which provides its own encoding and decoding routines for ipld-git objects. As stated here this package is not provided by default in js-ipfs nor js-ipfs-http-gateway.

It's actually possible to load it but I guess it's a bad idea - from a security perspective - to let apps load client wide IPLD resolvers. It would also allow to overwrite the default dag-cbor and dag-pb resolvers [and possibly inject malicious data in any other app].

So I guess the only way for pando to work would be to instantiate its own IPLD resolver which only requires to pass the client wide ipfs.objects object as a parameter ...