You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

ipfs-utils

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.1 to 2.2.2

11

CHANGELOG.md

@@ -0,1 +1,12 @@

<a name="2.2.2"></a>
## [2.2.2](https://github.com/ipfs/js-ipfs-utils/compare/v2.2.1...v2.2.2) (2020-05-05)
### Bug Fixes
* fix headers and abort signals ([#41](https://github.com/ipfs/js-ipfs-utils/issues/41)) ([ad977a9](https://github.com/ipfs/js-ipfs-utils/commit/ad977a9))
* **ci:** add empty commit to fix lint checks on master ([ad2fdc4](https://github.com/ipfs/js-ipfs-utils/commit/ad2fdc4))
<a name="2.2.1"></a>

@@ -2,0 +13,0 @@ ## [2.2.1](https://github.com/ipfs/js-ipfs-utils/compare/v2.2.0...v2.2.1) (2020-05-01)

9

package.json
{
"name": "ipfs-utils",
"version": "2.2.1",
"version": "2.2.2",
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem",

@@ -36,2 +36,3 @@ "main": "src/index.js",

"abort-controller": "^3.0.0",
"any-signal": "^1.1.0",
"buffer": "^5.4.2",

@@ -49,3 +50,3 @@ "err-code": "^2.0.0",

"devDependencies": {
"aegir": "^21.8.0",
"aegir": "^21.10.0",
"delay": "^4.3.0",

@@ -61,6 +62,6 @@ "it-all": "^1.0.1",

"Alan Shaw <alan.shaw@protocol.ai>",
"Marcin Rataj <lidel@lidel.org>",
"Hector Sanjuan <code@hector.link>",
"bluelovers <codelovers@users.sourceforge.net>",
"Hector Sanjuan <code@hector.link>"
"Marcin Rataj <lidel@lidel.org>"
]
}

@@ -5,6 +5,7 @@ /* eslint-disable no-undef */

const fetch = require('node-fetch')
const merge = require('merge-options')
const merge = require('merge-options').bind({ ignoreUndefined: true })
const { URL, URLSearchParams } = require('iso-url')
const TextDecoder = require('./text-encoder')
const AbortController = require('abort-controller')
const anySignal = require('any-signal')

@@ -36,10 +37,21 @@ const Request = fetch.Request

const timedOut = () => {
const time = Date.now() - start
return time >= ms
}
return new Promise((resolve, reject) => {
const timeoutID = setTimeout(() => {
if (timedOut()) {
reject(new TimeoutError())
abortController.abort()
}
}, ms)
const after = (next) => {
return (res) => {
clearTimeout(timeoutID)
const time = Date.now() - start
if (time >= ms) {
abortController.abort()
if (timedOut()) {
reject(new TimeoutError())

@@ -49,8 +61,5 @@ return

if (next) {
next(res)
}
next(res)
}
}
const timeoutID = setTimeout(after(), ms)

@@ -94,14 +103,2 @@ promise

this.opts = merge(defaults, options)
this.opts.headers = new Headers(options.headers)
// connect internal abort to external
this.abortController = new AbortController()
if (this.opts.signal) {
this.opts.signal.addEventListener('abort', () => {
this.abortController.abort()
})
}
this.opts.signal = this.abortController.signal
}

@@ -151,9 +148,10 @@

const abortController = new AbortController()
const signal = anySignal([abortController.signal, opts.signal])
const response = await timeout(fetch(url, {
...opts,
// node-fetch implements it's own timeout in an addition to the spec so do not
// pass the timeout value on, otherwise there are two sources of timeout errors
signal,
timeout: undefined
}), opts.timeout, this.abortController)
}), opts.timeout, abortController)

@@ -196,3 +194,6 @@ if (!response.ok && opts.throwHttpErrors) {

post (resource, options = {}) {
return this.fetch(resource, merge(this.opts, options, { method: 'POST' }))
return this.fetch(resource, {
...options,
method: 'POST'
})
}

@@ -206,3 +207,6 @@

get (resource, options = {}) {
return this.fetch(resource, merge(this.opts, options, { method: 'GET' }))
return this.fetch(resource, {
...options,
method: 'GET'
})
}

@@ -216,3 +220,6 @@

put (resource, options = {}) {
return this.fetch(resource, merge(this.opts, options, { method: 'PUT' }))
return this.fetch(resource, {
...options,
method: 'PUT'
})
}

@@ -226,3 +233,6 @@

delete (resource, options = {}) {
return this.fetch(resource, merge(this.opts, options, { method: 'DELETE' }))
return this.fetch(resource, {
...options,
method: 'DELETE'
})
}

@@ -236,3 +246,6 @@

options (resource, options = {}) {
return this.fetch(resource, merge(this.opts, options, { method: 'OPTIONS' }))
return this.fetch(resource, {
...options,
method: 'OPTIONS'
})
}

@@ -239,0 +252,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc