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

window.ipfs loading script from external CDN #570

Closed
victorb opened this issue Sep 11, 2018 · 3 comments
Closed

window.ipfs loading script from external CDN #570

victorb opened this issue Sep 11, 2018 · 3 comments
Labels
exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature status/ready Ready to be worked

Comments

@victorb
Copy link
Member

victorb commented Sep 11, 2018

Currently, if window.ipfs can't be found, we load ipfs-api from unpkg (https://github.com/ipfs-shipyard/ipfs-companion/blob/50db9c08d5bf0e5297981ff474da07585aa8a8ce/docs/examples/window.ipfs-fallback.html#L21). Rather than trusting unpkg, we could bundle ipfs-api in the extension and serve it from the extension (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/web_accessible_resources)

This will enable ipfs-companion to load ipfs-api even if internet is not accessible and faster even if internet access is present.

@lidel lidel added kind/enhancement A net-new feature or improvement to an existing feature exp/intermediate Prior experience is likely helpful and removed exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature labels Sep 11, 2018
@alanshaw
Copy link
Member

I looked at this and thought the only reason window.ipfs wouldn't be available would be if the extension isn't installed (we still have to add window.ipfs even if the user has disabled all access to it due to us being unable to inject a content script programmatically before any other scripts run on the page).

In which case, there'd be no point doing this.

Looking at the code ipfs is not added to the window object if not in a secure context, so in this case it it could work.

It's tricky though because the page would have to somehow know ipfs-companion was installed (is there even a way?) and what the web extension URL was? I guess we could add a different property to the window with that URL?

Another idea - what if we intercept the unpkg URL and serve a local resource?

@lidel
Copy link
Member

lidel commented Sep 16, 2018

(Another use case: user explicitly disabled window.ipfs in Preferences.)

I agree, intercept&redirect is the way to do this.
I am not sure if we want to bundle a single version with Companion. Instead, we could keep a list of IPFS CIDs for multiple unkpkg URLs and redirect to IPFS versions on exact match.

Also, we should move away from things like unpkg and start including URLs to IPFS versions in release notes of js-ipfs and js-ipfs-api.


Update: created "Intercept URLs for JS libs at public CDNs": #674

@lidel
Copy link
Member

lidel commented Oct 19, 2020

Closing due to #589 (comment)

@lidel lidel closed this as completed Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

3 participants