New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ipfs-grpc-client

Package Overview
Dependencies
Maintainers
2
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-grpc-client - npm Package Compare versions

Comparing version 0.0.1-rc.5958 to 0.0.1-rc.5959

10

package.json
{
"name": "ipfs-grpc-client",
"version": "0.0.1-rc.5958+fad9b740",
"version": "0.0.1-rc.5959+b90a495b",
"description": "A client library for the IPFS gRPC API",

@@ -45,7 +45,7 @@ "keywords": [

"change-case": "^4.1.1",
"cids": "^1.0.0",
"cids": "^1.1.5",
"debug": "^4.1.1",
"err-code": "^2.0.3",
"ipfs-core-utils": "^0.5.5-rc.5+fad9b740",
"ipfs-grpc-protocol": "^0.0.1-rc.5958+fad9b740",
"ipfs-core-utils": "^0.5.5-rc.6+b90a495b",
"ipfs-grpc-protocol": "^0.0.1-rc.5959+b90a495b",
"it-first": "^1.0.4",

@@ -65,3 +65,3 @@ "it-pushable": "^1.4.0",

},
"gitHead": "fad9b7402e67a459e9967a1319870da165ba722a"
"gitHead": "b90a495bd07cc81ac7a9dcad75c5625b59dc3dd9"
}

@@ -38,2 +38,3 @@ # ipfs-grpc-client

| url | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to |
| agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `undefined` | A http.Agent used to control HTTP client behaviour (node.js only) |

@@ -40,0 +41,0 @@ ### Returns

@@ -82,3 +82,4 @@ 'use strict'

debug: Boolean(process.env.DEBUG),
metadata: options
metadata: options,
agent: opts.agent
})

@@ -85,0 +86,0 @@

@@ -16,3 +16,4 @@ 'use strict'

debug: Boolean(process.env.DEBUG),
metadata: options
metadata: options,
agent: opts.agent
})) {

@@ -19,0 +20,0 @@ yield {

@@ -41,3 +41,4 @@ 'use strict'

debug: Boolean(process.env.DEBUG),
metadata: options
metadata: options,
agent: opts.agent
})

@@ -44,0 +45,0 @@ }

@@ -14,3 +14,4 @@ 'use strict'

host: opts.url,
metadata: toHeaders(options)
metadata: toHeaders(options),
agent: opts.agent
})

@@ -17,0 +18,0 @@

@@ -16,8 +16,28 @@ 'use strict'

function WebsocketTransport () {
return (opts) => {
return websocketRequest(opts)
/**
* @param {object} options
* @param {import('http').Agent} [options.agent] - http.Agent used to control HTTP client behaviour
*/
function WebsocketTransport (options) {
/**
* @param {import('@improbable-eng/grpc-web').grpc.TransportOptions} opts
*/
const websocketTransportFactory = (opts) => {
return websocketRequest({
...options,
...opts
})
}
return websocketTransportFactory
}
/**
* @typedef {object} NodeTransportOptions
* @property {import('http').Agent} [options.agent]
*
* @typedef {NodeTransportOptions & import('@improbable-eng/grpc-web').grpc.TransportOptions} WebSocketTransportOptions
*
* @param {WebSocketTransportOptions} options
*/
function websocketRequest (options) {

@@ -58,3 +78,3 @@ const webSocketAddress = constructWebSocketAddress(options.url)

start: (metadata) => {
ws = new WebSocket(webSocketAddress, ['grpc-websockets'])
ws = new WebSocket(webSocketAddress, ['grpc-websockets'], options)
ws.binaryType = 'arraybuffer'

@@ -98,3 +118,4 @@ ws.onopen = function () {

}
throw new Error('Websocket transport constructed with non-https:// or http:// host.')
throw new Error('Websocket transport url must start with ws:// or wss:// or http:// or https://')
}

@@ -101,0 +122,0 @@

'use strict'
const transport = require('./grpc/transport')
const toUrlString = require('ipfs-core-utils/src/to-url-string')
const loadServices = require('./utils/load-services')
const { grpc } = require('@improbable-eng/grpc-web')
grpc.setDefaultTransport(transport())

@@ -24,3 +22,8 @@ const service = loadServices()

module.exports = function createClient (opts = {}) {
/**
* @param {object} opts
* @param {string} opts.url - The URL to connect to as a URL or Multiaddr
* @param {import('http').Agent} [opts.agent] - http.Agent used to control HTTP client behaviour (node.js only)
*/
module.exports = function createClient (opts = { url: '' }) {
opts.url = toUrlString(opts.url)

@@ -27,0 +30,0 @@

@@ -6,2 +6,3 @@ 'use strict'

const toHeaders = require('./to-headers')
const transport = require('../grpc/transport')

@@ -27,2 +28,3 @@ async function sendMessages (service, client, source) {

* @param {object} [options.metadata] - Metadata sent as headers
* @param {import('http').Agent} [options.agent] - http.Agent used to control HTTP client behaviour (node.js only)
* @returns {{ source: AsyncIterable<object>, sink: { push: Function, end: Function } }}

@@ -37,3 +39,8 @@ **/

const client = grpc.client(service, options)
const client = grpc.client(service, {
...options,
transport: transport({
agent: options.agent
})
})
client.onMessage(message => {

@@ -40,0 +47,0 @@ sink.push(message)

@@ -18,2 +18,3 @@ 'use strict'

* @param {object} [options.metadata] - Metadata sent as headers
* @param {import('http').Agent} [options.agent] - http.Agent used to control HTTP client behaviour (node.js only)
* @returns {Promise<Object>} - A promise that resolves to a response object

@@ -20,0 +21,0 @@ **/

@@ -17,2 +17,3 @@ 'use strict'

* @param {object} [options.metadata] - Metadata sent as headers
* @param {import('http').Agent} [options.agent] - http.Agent used to control HTTP client behaviour (node.js only)
* @returns {AsyncIterable<object>}

@@ -19,0 +20,0 @@ **/

@@ -18,2 +18,3 @@ 'use strict'

* @param {object} [options.metadata] - Metadata sent as headers
* @param {import('http').Agent} [options.agent] - http.Agent used to control HTTP client behaviour (node.js only)
* @returns {Promise<Object>} - A promise that resolves to a response object

@@ -20,0 +21,0 @@ **/

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc