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

feat: support window.ipfs.enable() #5

Merged
merged 1 commit into from
Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const { ipfs, provider } = await getIpfs({
// These are the defaults:
tryWebExt: true, // set false to bypass WebExtension verification
tryWindow: true, // set false to bypass window.ipfs verification
permissions: {} // set the window.ipfs options you want if tryWindow is true
tryApi: true, // set false to bypass js-ipfs-http-client verification
apiAddress: null // set this to use an api in that address if tryApi is true
tryJsIpfs: false, // set true to attempt js-ipfs initialisation
Expand Down Expand Up @@ -59,6 +60,21 @@ const { ipfs, provider } = await getIpfs({
- `getJsIpfs` should be a function that returns a promise that resolves with a `JsIpfs` constructor. This works well with [dynamic `import()`](https://developers.google.com/web/updates/2017/11/dynamic-import), so you can lazily load js-ipfs when it is needed.
- `jsIpfsOpts` should be an object which specifies [advanced configurations](https://github.com/ipfs/js-ipfs#ipfs-constructor) to the node.

### Enable window.ipfs

`window.ipfs` is an experimental feature provided by [ipfs-companion](https://github.com/ipfs/ipfs-companion) browser extension. It supports passing an optional list of permissions to [display a single ACL prompt](https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/window.ipfs.md#do-i-need-to-confirm-every-api-call) the first time it is used:

```js
const { ipfs, provider } = await getIpfs({
tryWindow: true,
permissions: { commands: ['add','cat','id', 'version'] },
tryJsIpfs: true,
...
```

**Note:** Make sure to enable at least one other provider such as js-ipfs as a fallback to ensure users without `window.ipfs` are able to use your app.


## Test

```sh
Expand Down
Loading