tableflip/window.ipfs-fallback

Name: window.ipfs-fallback

Owner: TABLEFLIP

Description: Get window.ipfs with fallback to CDN if unavailable

Created: 2018-04-04 14:55:13.0

Updated: 2018-05-14 07:39:05.0

Pushed: 2018-05-11 12:35:09.0

Homepage: null

Size: 118

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

window.ipfs-fallback

Build Status dependencies Status JavaScript Style Guide

Get window.ipfs with fallback to CDN if unavailable

The IPFS Companion web extension provides a window.ipfs object to web pages you visit.

This module will detects the presence of window.ipfs and automatically falls back to downloading the latest version of IPFS from https://unpkg.com/ipfs/dist/index.min.js if it's unavailable. Note: can be configured to fallback to IPFS API.

Usage
rt getIpfs from 'window.ipfs-fallback'

t ipfs = await getIpfs()

ole.log(await ipfs.id())
API
getIpfs([options])

If window.ipfs is available, the promise is resolved with that node.

If window.ipfs is unavailable, a <script src="https://unpkg.com/ipfs/dist/index.min.js" /> is inserted into the document and when the script has loaded a new IPFS node is created and the promise is resolved.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.