0.4.1 • Published 3 years ago

@chris.troutner/ipfs-grpc-client v0.4.1

Weekly downloads
-
License
(Apache-2.0 OR MI...
Repository
github
Last release
3 years ago

ipfs-grpc-client

A client for the ipfs-grpc-server module

This module implements part of the IPFS Core API using gRPC over websockets to achieve the bidirectional streaming necessary to have full duplex streams running in the browser.

It's not recommended you use this directly, instead use the ipfs-client to combine this with the ipfs-http-client in order to have HTTP fallback for the missing parts of the API.

Why?

The fetch and XHR APIs do not allow for full-duplex streaming, that is, allowing the client to receive bytes from the response while also adding more bytes to the outgoing request.

This limits what we can do in browsers in terms of the API, for example streaming arbitrarily sized payloads or exposing libp2p duplex streams.

gPRC over websockets has no such limitations so allows us to harness the full power of a remote IPFS node in the browser without the need to work around browser behaviour.

Install

$ npm install ipfs-grpc-client

API

create([options])

Parameters

None

Options

An optional object which may have the following keys:

NameTypeDefaultDescription
urlMultiaddr or string or URLundefinedThe address of a ipfs-grpc-server to connect to
agenthttp.AgentundefinedA http.Agent used to control HTTP client behaviour (node.js only)

Returns

TypeDescription
objectAn instance of the client

Example

const { create } = require('ipfs-gprc-client')

const client = create({
  url: '/ipv4/127.0.0.1/tcp/1234/ws'
})

const id = await client.id()