Skip to content

Commit

Permalink
fix: specify duplex option (#239)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achingbrain authored Jan 11, 2023
1 parent 5faabb4 commit a1168f9
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 127 deletions.
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ updates:
directory: "/"
schedule:
interval: daily
time: "11:00"
time: "10:00"
open-pull-requests-limit: 10
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
2 changes: 1 addition & 1 deletion .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [16]
node: [lts/*]
fail-fast: true
steps:
- uses: actions/checkout@v3
Expand Down
24 changes: 3 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
The MIT License (MIT)

Copyright (c) IPFS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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

http://www.apache.org/licenses/LICENSE-2.0

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.
19 changes: 19 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
93 changes: 49 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
# js-ipfs-utils <!-- omit in toc -->
# ipfs-utils <!-- omit in toc -->

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![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)
[![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)
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-utils.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-utils)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-utils.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-utils)
[![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)

> 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).
> Package to aggregate shared logic and dependencies for the IPFS ecosystem
`ipfs-utils` aims to provide single function default export per file (with a few exceptions) scoped in 3 general categories:
- General use
- Data structs wrangling (arrays, objects, streams, etc)
- IPFS core subsystems

*General use* and *Data structs wrangling* should try to be just re-exports of community packages.

The IPFS ecosystem has lots of repos with it comes several problems like:
- Domain logic dedupe - all interface-core implementations shared a lot of logic like validation, streams handling, etc.
- 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.

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.

## Table of Contents <!-- omit in toc -->
## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [Functions](#functions)
- [General Use](#general-use)
- [TODO](#todo)
- [Data Struct Wrangling](#data-struct-wrangling)
- [TODO](#todo-1)
- [Core API](#core-api)
- [TODO](#todo-2)
- [Contribute](#contribute)
- [API Docs](#api-docs)
- [License](#license)
- [Contribute](#contribute)

## Install

```console
$ npm i ipfs-utils
```

### Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `IpfsUtils` in the global namespace.

```bash
$ npm install --save ipfs-utils
```html
<script src="https://unpkg.com/ipfs-utils/dist/index.min.js"></script>
```

`ipfs-utils` aims to provide single function default export per file (with a few exceptions) scoped in 3 general categories:

- General use
- Data structs wrangling (arrays, objects, streams, etc)
- IPFS core subsystems

*General use* and *Data structs wrangling* should try to be just re-exports of community packages.

The IPFS ecosystem has lots of repos with it comes several problems like:

- Domain logic dedupe - all interface-core implementations shared a lot of logic like validation, streams handling, etc.
- 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.

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.

## Usage

Each function should be imported directly.

```js
Expand All @@ -54,22 +56,25 @@ validateAddInput(Buffer.from('test'))
// true
```

## Functions
## API Docs

- <https://ipfs.github.io/js-ipfs-utils>

### General Use
#### TODO
### Data Struct Wrangling
#### TODO
### Core API
#### TODO
## License

Licensed under either of

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

## Contribute

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

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).
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.

## License
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).

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.

[MIT](LICENSE) © Protocol Labs Inc.
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
93 changes: 59 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,46 @@
"name": "ipfs-utils",
"version": "9.0.9",
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem",
"main": "src/index.js",
"author": "Hugo Dias <hugomrdias@gmail.com>",
"homepage": "https://github.com/ipfs/js-ipfs-utils",
"bugs": "https://github.com/ipfs/js-ipfs-utils/issues",
"repository": "github:ipfs/js-ipfs-utils",
"files": [
"src",
"dist"
],
"browser": {
"./src/http/fetch.js": "./src/http/fetch.browser.js",
"./src/temp-dir.js": "./src/temp-dir.browser.js",
"./src/path-join.js": "./src/path-join.browser.js",
"./src/fetch.js": "./src/fetch.browser.js",
"./src/files/glob-source.js": false,
"./test/files/glob-source.spec.js": false,
"electron-fetch": false,
"fs": false
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/js-ipfs-utils#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/js-ipfs-utils.git"
},
"react-native": {
"./src/fetch.js": "./src/fetch.rn.js",
"./src/http/fetch.js": "./src/http/fetch.rn.js"
"bugs": {
"url": "https://github.com/ipfs/js-ipfs-utils/issues"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*"
],
"src/*": [
"*",
"dist/*",
"dist/src/*"
]
}
},
"files": [
"src",
"dist"
],
"eslintConfig": {
"extends": "ipfs",
"env": {
"worker": true
}
},
"release": {
"branches": [
"master"
Expand Down Expand Up @@ -60,15 +69,15 @@
"release": "patch"
},
{
"type": "chore",
"type": "docs",
"release": "patch"
},
{
"type": "docs",
"type": "test",
"release": "patch"
},
{
"type": "test",
"type": "deps",
"release": "patch"
},
{
Expand Down Expand Up @@ -98,7 +107,11 @@
},
{
"type": "docs",
"section": "Trivial Changes"
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
Expand All @@ -115,6 +128,7 @@
]
},
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"build": "aegir build",
Expand All @@ -125,11 +139,12 @@
"test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
"test:node": "npm run test -- -t node --cov",
"test:electron-main": "npm run test -- -t electron-main",
"release": "semantic-release"
"release": "aegir release",
"docs": "aegir docs"
},
"license": "MIT",
"dependencies": {
"any-signal": "^3.0.0",
"browser-readablestream-to-it": "^1.0.0",
"buffer": "^6.0.1",
"electron-fetch": "^1.7.2",
"err-code": "^3.0.1",
Expand All @@ -138,10 +153,10 @@
"it-glob": "^1.0.1",
"it-to-stream": "^1.0.0",
"merge-options": "^3.0.4",
"nanoid": "^3.1.20",
"nanoid": "^4.0.0",
"native-fetch": "^3.0.0",
"node-fetch": "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz",
"react-native-fetch-api": "^2.0.0",
"react-native-fetch-api": "^3.0.0",
"stream-to-it": "^0.2.2"
},
"devDependencies": {
Expand All @@ -152,15 +167,25 @@
"it-all": "^1.0.4",
"it-drain": "^1.0.3",
"it-last": "^1.0.4",
"it-to-buffer": "^2.0.0",
"react-native-polyfill-globals": "^3.0.0",
"readable-stream": "^3.6.0",
"readable-stream": "^4.3.0",
"uint8arrays": "^3.0.0",
"util": "^0.12.3"
},
"eslintConfig": {
"extends": "ipfs",
"env": {
"worker": true
}
"browser": {
"./src/http/fetch.js": "./src/http/fetch.browser.js",
"./src/temp-dir.js": "./src/temp-dir.browser.js",
"./src/path-join.js": "./src/path-join.browser.js",
"./src/fetch.js": "./src/fetch.browser.js",
"./src/files/glob-source.js": false,
"./test/files/glob-source.spec.js": false,
"electron-fetch": false,
"node-fetch": false,
"fs": false
},
"react-native": {
"./src/fetch.js": "./src/fetch.rn.js",
"./src/http/fetch.js": "./src/http/fetch.rn.js"
}
}
Loading

0 comments on commit a1168f9

Please sign in to comment.