Skip to content

Commit a1168f9

Browse files
authored
fix: specify duplex option (#239)
A recent change to the fetch spec means the `duplex` option has to be set to `half` when using a `ReadbleStream` as the request body.
1 parent 5faabb4 commit a1168f9

File tree

10 files changed

+192
-127
lines changed

10 files changed

+192
-127
lines changed

.github/dependabot.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ updates:
44
directory: "/"
55
schedule:
66
interval: daily
7-
time: "11:00"
7+
time: "10:00"
88
open-pull-requests-limit: 10
9+
commit-message:
10+
prefix: "deps"
11+
prefix-development: "deps(dev)"

.github/workflows/js-test-and-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [windows-latest, ubuntu-latest, macos-latest]
30-
node: [16]
30+
node: [lts/*]
3131
fail-fast: true
3232
steps:
3333
- uses: actions/checkout@v3

LICENSE

+3-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
1-
The MIT License (MIT)
2-
3-
Copyright (c) IPFS
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
This project is dual licensed under MIT and Apache-2.0.
222

3+
MIT: https://www.opensource.org/licenses/mit
4+
Apache-2.0: https://www.apache.org/licenses/license-2.0

LICENSE-APACHE

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

LICENSE-MIT

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+49-44
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
1-
# js-ipfs-utils <!-- omit in toc -->
1+
# ipfs-utils <!-- omit in toc -->
22

3-
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
4-
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
5-
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6-
[![Build Status](https://github.com/ipfs/js-ipfs-utils/actions/workflows/js-test-and-release.yml/badge.svg?branch=main)](https://github.com/ipfs/js-ipfs-utils/actions/workflows/js-test-and-release.yml)
7-
[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-utils/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-utils)
8-
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-utils.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-utils)
9-
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
3+
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
4+
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
5+
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-utils.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-utils)
6+
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-utils/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-ipfs-utils/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
107

11-
> This package serves as a central repository for shared logic and dependencies for all IPFS packages, using `ipfs-utils` helps to easily re-use small scoped blocks of logic across all the js core interface implementations and also as a dependency proxy (think `aegir` for domain logic dependencies).
8+
> Package to aggregate shared logic and dependencies for the IPFS ecosystem
129
13-
`ipfs-utils` aims to provide single function default export per file (with a few exceptions) scoped in 3 general categories:
14-
- General use
15-
- Data structs wrangling (arrays, objects, streams, etc)
16-
- IPFS core subsystems
17-
18-
*General use* and *Data structs wrangling* should try to be just re-exports of community packages.
19-
20-
The IPFS ecosystem has lots of repos with it comes several problems like:
21-
- Domain logic dedupe - all interface-core implementations shared a lot of logic like validation, streams handling, etc.
22-
- Dependencies management - it's really easy with so many repos for dependencies to go out of control, they become outdated, different repos use different modules to do the same thing (like merging defaults options), browser bundles ends up with multiple versions of the same package, bumping versions is cumbersome to do because we need to go through several repos, etc.
23-
24-
These problems are the motivation for this package, having shared logic in this package avoids creating cyclic dependencies, centralizes common use modules/functions (exactly like aegir does for the tooling), semantic versioning for 3rd party dependencies is handled in one single place (a good example is going from streams 2 to 3) and maintainers should only care about having `ipfs-utils` updated.
25-
26-
## Table of Contents <!-- omit in toc -->
10+
## Table of contents <!-- omit in toc -->
2711

2812
- [Install](#install)
13+
- [Browser `<script>` tag](#browser-script-tag)
2914
- [Usage](#usage)
30-
- [Functions](#functions)
31-
- [General Use](#general-use)
32-
- [TODO](#todo)
33-
- [Data Struct Wrangling](#data-struct-wrangling)
34-
- [TODO](#todo-1)
35-
- [Core API](#core-api)
36-
- [TODO](#todo-2)
37-
- [Contribute](#contribute)
15+
- [API Docs](#api-docs)
3816
- [License](#license)
17+
- [Contribute](#contribute)
3918

4019
## Install
4120

21+
```console
22+
$ npm i ipfs-utils
23+
```
24+
25+
### Browser `<script>` tag
26+
27+
Loading this module through a script tag will make it's exports available as `IpfsUtils` in the global namespace.
4228

43-
```bash
44-
$ npm install --save ipfs-utils
29+
```html
30+
<script src="https://unpkg.com/ipfs-utils/dist/index.min.js"></script>
4531
```
4632

33+
`ipfs-utils` aims to provide single function default export per file (with a few exceptions) scoped in 3 general categories:
34+
35+
- General use
36+
- Data structs wrangling (arrays, objects, streams, etc)
37+
- IPFS core subsystems
38+
39+
*General use* and *Data structs wrangling* should try to be just re-exports of community packages.
40+
41+
The IPFS ecosystem has lots of repos with it comes several problems like:
42+
43+
- Domain logic dedupe - all interface-core implementations shared a lot of logic like validation, streams handling, etc.
44+
- Dependencies management - it's really easy with so many repos for dependencies to go out of control, they become outdated, different repos use different modules to do the same thing (like merging defaults options), browser bundles ends up with multiple versions of the same package, bumping versions is cumbersome to do because we need to go through several repos, etc.
45+
46+
These problems are the motivation for this package, having shared logic in this package avoids creating cyclic dependencies, centralizes common use modules/functions (exactly like aegir does for the tooling), semantic versioning for 3rd party dependencies is handled in one single place (a good example is going from streams 2 to 3) and maintainers should only care about having `ipfs-utils` updated.
47+
4748
## Usage
49+
4850
Each function should be imported directly.
4951

5052
```js
@@ -54,22 +56,25 @@ validateAddInput(Buffer.from('test'))
5456
// true
5557
```
5658

57-
## Functions
59+
## API Docs
60+
61+
- <https://ipfs.github.io/js-ipfs-utils>
5862

59-
### General Use
60-
#### TODO
61-
### Data Struct Wrangling
62-
#### TODO
63-
### Core API
64-
#### TODO
63+
## License
64+
65+
Licensed under either of
6566

67+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
68+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
6669

6770
## Contribute
6871

69-
Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs-utils/issues).
72+
Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-utils/issues).
7073

71-
Check out our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
74+
Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
7275

73-
## License
76+
Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
77+
78+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
7479

75-
[MIT](LICENSE) © Protocol Labs Inc.
80+
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)

package.json

+59-34
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,46 @@
22
"name": "ipfs-utils",
33
"version": "9.0.9",
44
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem",
5-
"main": "src/index.js",
65
"author": "Hugo Dias <[email protected]>",
7-
"homepage": "https://github.com/ipfs/js-ipfs-utils",
8-
"bugs": "https://github.com/ipfs/js-ipfs-utils/issues",
9-
"repository": "github:ipfs/js-ipfs-utils",
10-
"files": [
11-
"src",
12-
"dist"
13-
],
14-
"browser": {
15-
"./src/http/fetch.js": "./src/http/fetch.browser.js",
16-
"./src/temp-dir.js": "./src/temp-dir.browser.js",
17-
"./src/path-join.js": "./src/path-join.browser.js",
18-
"./src/fetch.js": "./src/fetch.browser.js",
19-
"./src/files/glob-source.js": false,
20-
"./test/files/glob-source.spec.js": false,
21-
"electron-fetch": false,
22-
"fs": false
6+
"license": "Apache-2.0 OR MIT",
7+
"homepage": "https://github.com/ipfs/js-ipfs-utils#readme",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/ipfs/js-ipfs-utils.git"
2311
},
24-
"react-native": {
25-
"./src/fetch.js": "./src/fetch.rn.js",
26-
"./src/http/fetch.js": "./src/http/fetch.rn.js"
12+
"bugs": {
13+
"url": "https://github.com/ipfs/js-ipfs-utils/issues"
14+
},
15+
"engines": {
16+
"node": ">=16.0.0",
17+
"npm": ">=7.0.0"
2718
},
19+
"main": "src/index.js",
2820
"types": "dist/src/index.d.ts",
2921
"typesVersions": {
3022
"*": {
23+
"*": [
24+
"*",
25+
"dist/*",
26+
"dist/src/*"
27+
],
3128
"src/*": [
29+
"*",
30+
"dist/*",
3231
"dist/src/*"
3332
]
3433
}
3534
},
35+
"files": [
36+
"src",
37+
"dist"
38+
],
39+
"eslintConfig": {
40+
"extends": "ipfs",
41+
"env": {
42+
"worker": true
43+
}
44+
},
3645
"release": {
3746
"branches": [
3847
"master"
@@ -60,15 +69,15 @@
6069
"release": "patch"
6170
},
6271
{
63-
"type": "chore",
72+
"type": "docs",
6473
"release": "patch"
6574
},
6675
{
67-
"type": "docs",
76+
"type": "test",
6877
"release": "patch"
6978
},
7079
{
71-
"type": "test",
80+
"type": "deps",
7281
"release": "patch"
7382
},
7483
{
@@ -98,7 +107,11 @@
98107
},
99108
{
100109
"type": "docs",
101-
"section": "Trivial Changes"
110+
"section": "Documentation"
111+
},
112+
{
113+
"type": "deps",
114+
"section": "Dependencies"
102115
},
103116
{
104117
"type": "test",
@@ -115,6 +128,7 @@
115128
]
116129
},
117130
"scripts": {
131+
"clean": "aegir clean",
118132
"lint": "aegir lint",
119133
"dep-check": "aegir dep-check",
120134
"build": "aegir build",
@@ -125,11 +139,12 @@
125139
"test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
126140
"test:node": "npm run test -- -t node --cov",
127141
"test:electron-main": "npm run test -- -t electron-main",
128-
"release": "semantic-release"
142+
"release": "aegir release",
143+
"docs": "aegir docs"
129144
},
130-
"license": "MIT",
131145
"dependencies": {
132146
"any-signal": "^3.0.0",
147+
"browser-readablestream-to-it": "^1.0.0",
133148
"buffer": "^6.0.1",
134149
"electron-fetch": "^1.7.2",
135150
"err-code": "^3.0.1",
@@ -138,10 +153,10 @@
138153
"it-glob": "^1.0.1",
139154
"it-to-stream": "^1.0.0",
140155
"merge-options": "^3.0.4",
141-
"nanoid": "^3.1.20",
156+
"nanoid": "^4.0.0",
142157
"native-fetch": "^3.0.0",
143158
"node-fetch": "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz",
144-
"react-native-fetch-api": "^2.0.0",
159+
"react-native-fetch-api": "^3.0.0",
145160
"stream-to-it": "^0.2.2"
146161
},
147162
"devDependencies": {
@@ -152,15 +167,25 @@
152167
"it-all": "^1.0.4",
153168
"it-drain": "^1.0.3",
154169
"it-last": "^1.0.4",
170+
"it-to-buffer": "^2.0.0",
155171
"react-native-polyfill-globals": "^3.0.0",
156-
"readable-stream": "^3.6.0",
172+
"readable-stream": "^4.3.0",
157173
"uint8arrays": "^3.0.0",
158174
"util": "^0.12.3"
159175
},
160-
"eslintConfig": {
161-
"extends": "ipfs",
162-
"env": {
163-
"worker": true
164-
}
176+
"browser": {
177+
"./src/http/fetch.js": "./src/http/fetch.browser.js",
178+
"./src/temp-dir.js": "./src/temp-dir.browser.js",
179+
"./src/path-join.js": "./src/path-join.browser.js",
180+
"./src/fetch.js": "./src/fetch.browser.js",
181+
"./src/files/glob-source.js": false,
182+
"./test/files/glob-source.spec.js": false,
183+
"electron-fetch": false,
184+
"node-fetch": false,
185+
"fs": false
186+
},
187+
"react-native": {
188+
"./src/fetch.js": "./src/fetch.rn.js",
189+
"./src/http/fetch.js": "./src/http/fetch.rn.js"
165190
}
166191
}

0 commit comments

Comments
 (0)