diff --git a/.github/dependabot.yml b/.github/dependabot.yml index de46e32616..0bc3b42de8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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)" diff --git a/.gitignore b/.gitignore index 12652bc725..7ebda0ab08 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ tsconfig-types.aegir.json # Coverage directory used by tools like istanbul coverage +.coverage .nyc_output tests_output cache diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/LICENSE-MIT b/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/docs/MIGRATION-TO-ASYNC-AWAIT.md b/docs/MIGRATION-TO-ASYNC-AWAIT.md index a30b3d8af3..718071a0d4 100644 --- a/docs/MIGRATION-TO-ASYNC-AWAIT.md +++ b/docs/MIGRATION-TO-ASYNC-AWAIT.md @@ -100,7 +100,7 @@ const peerId = PeerId.createFromB58String(peerIdStr) You can get hold of the `PeerId` class using npm or in a script tag: ```js -import { PeerId } from '@libp2p/interfaces/peer-id' +import { PeerId } from '@libp2p/interface-peer-id' const peerId = PeerId.createFromB58String(peerIdStr) ``` @@ -128,7 +128,7 @@ You can get hold of the `PeerInfo` class using npm or in a script tag: ```js const PeerInfo = require('peer-info') -import { PeerId } from '@libp2p/interfaces/peer-id' +import { PeerId } from '@libp2p/interface-peer-id' const peerInfo = new PeerInfo(PeerId.createFromB58String(info.id)) info.addrs.forEach(addr => peerInfo.multiaddrs.add(addr)) ``` diff --git a/docs/MODULE.md b/docs/MODULE.md index 67de596e13..23e612d708 100644 --- a/docs/MODULE.md +++ b/docs/MODULE.md @@ -102,7 +102,7 @@ Instead of a boolean, you may provide an object with custom initialization optio - `privateKey` (string/PeerId) A pre-generated private key to use. Can be either a base64 string or a [PeerId](https://github.com/libp2p/js-peer-id) instance. **NOTE: This overrides `bits`.** ```js // Generating a Peer ID: - import { PeerId } from '@libp2p/interfaces/peer-id' + import { PeerId } from '@libp2p/interface-peer-id' // Generates a new Peer ID, complete with public/private keypair // See https://github.com/libp2p/js-peer-id const peerId = await PeerId.create({ bits: 2048 }) diff --git a/lerna.json b/lerna.json index 2b32098657..86c45bda4a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,8 +1,6 @@ { "version": "independent", - "packages": [ - "packages/*" - ], + "useWorkspaces": true, "command": { "bootstrap": { "hoist": true diff --git a/package.json b/package.json index cbf0e34e92..e9d95e8489 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,20 @@ "name": "js-ipfs", "version": "1.0.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "private": true, "scripts": { "link": "lerna link", "reset": "lerna run clean && rimraf packages/*/node_modules node_modules package-lock.json packages/*/package-lock.json", @@ -44,268 +58,19 @@ "docker:rc:push-next": "docker push ipfs/js-ipfs:next", "docker:rc:push-rc": "docker push ipfs/js-ipfs:v`npm show ipfs@next version -q`" }, - "eslintConfig": { - "extends": "ipfs", - "ignorePatterns": [ - "!.aegir.js" - ] - }, "devDependencies": { - "lerna": "^4.0.0", + "lerna": "^5.0.0", "node-fetch": "npm:@achingbrain/node-fetch@^2.6.4", "npm-run-all": "^4.1.5", "rimraf": "^3.0.2" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "ignorePatterns": [ + "!.aegir.js" + ] }, - "private": true, "workspaces": [ "packages/*" - ], - "engines": { - "npm": ">=7.0.0" - }, - "contributors": [ - "David Dias ", - "achingbrain ", - "Alan Shaw ", - "Friedel Ziegelmayer ", - "Juan Batiz-Benet ", - "Vasco Santos ", - "Hugo Dias ", - "Henrique Dias ", - "Volker Mische ", - "ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ", - "Marcin Rataj ", - "Stephen Whitmore ", - "Jacob Heun ", - "Francisco Baio Dias ", - "Matt Bell ", - "Richard Schneider ", - "Pedro Teixeira ", - "Travis Person ", - "Kristoffer Ström ", - "Dmitriy Ryajov ", - "Irakli Gozalishvili ", - "Oli Evans ", - "nginnever ", - "Richard Littauer ", - "dirkmc ", - "Diogo Silva ", - "Pedro Santos ", - "Connor Keenan ", - "kumavis ", - "Harlan T Wood ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Pascal Precht ", - "Andrew Nesbitt ", - "Hector Sanjuan ", - "Maciej Krüger ", - "Michael Garvin ", - "Steven Allen ", - "Michael Muré ", - "Łukasz Magiera ", - "João Antunes ", - "Enrico Marino ", - "Teri Chadbourne ", - "Christian Couder ", - "Rob Brackett ", - "Prabhakar Poudel ", - "Mithgol ", - "Haad ", - "Jonathan ", - "Xmader ", - "Sangwon Hong ", - "Joonas Koivunen ", - "Gavin McDermott ", - "Mikeal Rogers ", - "Dzmitry Das ", - "Rod Vagg ", - "Andrew de Andrade ", - "Matt Ober ", - "Максим Ильин ", - "Ryan Bell ", - "Alex Mingoia ", - "RasmusErik Voel Jensen ", - "Marius Darila ", - "Yahya ", - "anders ", - "bluelovers ", - "Paulo Rodrigues ", - "haad ", - "Jeromy ", - "0xflotus <0xflotus@gmail.com>", - "Andrey ", - "André Cruz ", - "Antonio Tenorio-Fornés ", - "Dan Ordille ", - "Dan Shields <35669742+NukeManDan@users.noreply.github.com>", - "David Gilbertson ", - "Doug A ", - "Georgios Rassias ", - "Gorka Ludlow ", - "Jeff Downie ", - "Jim Pick ", - "Jonybang ", - "Kevin Simper ", - "Kevin Wang ", - "Ludwig <35169452+ludwigschubi@users.noreply.github.com>", - "Mark Robert Henderson ", - "Maxime Lathuilière ", - "Molly ", - "Nuno Nogueira ", - "Portia Burton ", - "Raoul Millais ", - "Sid Harder ", - "Vu Tien Khang ", - "reasv <7143787+reasv@users.noreply.github.com>", - "samuli ", - "shunkin ", - "tcme ", - "seungwon-kang ", - "Arpit Agarwal ", - "Jason Papakostas ", - "Ilya Kreymer ", - "Julien Malard ", - "phillmac ", - "Holodisc ", - "Lars Gierth ", - "priecint ", - "Lukas Drgon ", - "Heo Sangmin ", - "Manuel Spagnolo ", - "Henry Rodrick ", - "Marcus Bernales ", - "Harsh Vakharia ", - "Alen Siljak ", - "Mat Kelly ", - "Haoliang Yu ", - "Hannah Howard ", - "Matt Zumwalt ", - "robbsolter <35879806+robbsolter@users.noreply.github.com>", - "Michael Bradley ", - "Guilherme Pacheco ", - "Gregory Oakes ", - "Michelle Lee ", - "Grant Herman ", - "Mitar ", - "Gopalakrishna Palem ", - "Mohamed Abdulaziz ", - "ron litzenberger ", - "Mounish Sai ", - "My9Bot <34904312+My9Bot@users.noreply.github.com>", - "Nate Foss ", - "Adin Schmahmann ", - "Nick Poulden ", - "Nicolás Santángelo ", - "Giuseppe Bertone ", - "sarthak khandelwal ", - "Níckolas Goline ", - "Giles ", - "Olivério Sousa <47525443+oliveriosousa@users.noreply.github.com>", - "Orie Steele ", - "Oskar Nyberg ", - "Padmashree Jha ", - "George Shammas ", - "Pau Ramon Revilla ", - "Paul Cowgill ", - "Gabriel Garrido Calvo ", - "Filip Š ", - "Fil ", - "Pete Thomas ", - "Philipp Krüger ", - "Felix Yan ", - "Qmstream <51881352+Qmstream@users.noreply.github.com>", - "Adam Uhlíř ", - "Faheel Ahmad ", - "Revat Arora <70435319+CypherX7@users.noreply.github.com>", - "Donatas Stundys ", - "Dominic Della Valle ", - "Rod Keys ", - "Dmitry Nikulin ", - "Roman Khafizianov ", - "Dietrich Ayala ", - "Davide Icardi ", - "Sergey Ukustov ", - "swedneck <40505480+swedneck@users.noreply.github.com>", - "SidHarder ", - "A_A <21040751+Otto-AA@users.noreply.github.com>", - "David da Silva ", - "Steven Vandevelde ", - "Subin Siby ", - "TJKoury ", - "Tapasweni Pathak ", - "Tara Vancil ", - "Tejas Kumthekar <6154318+tk26@users.noreply.github.com>", - "Terence Pae ", - "David Braun ", - "Thiago Delgado ", - "Thorsten Zoerner ", - "Timothé ", - "David ", - "Danny ", - "thattommyhall ", - "Uroš Jurglič ", - "Daniela Borges Matos de Carvalho ", - "Daniel J. O'Quinn ", - "Victor Bjelkholm ", - "Daniel Constantin ", - "Vincent Martin ", - "Daniel Buchner ", - "Alex North ", - "Vutsal Singhal ", - "Xiao Liang ", - "Dafeng ", - "Connor White ", - "Yole ", - "Yusef Napora ", - "Zhiyuan Lin ", - "Clemo ", - "Christian Paul ", - "arjunraghurama ", - "bitspill ", - "Chirag Shinde ", - "datafatmunger ", - "Chance Hudson ", - "Caio Gondim ", - "CSDUMMI <31551856+CSDUMMI@users.noreply.github.com>", - "CHEVALAY JOSSELIN ", - "Bruno Zell ", - "dmitriy ryajov ", - "elsehow ", - "ethers ", - "Bruno Barbieri ", - "Brian Vander Schaaf ", - "Brandon ", - "Bernard Mordan ", - "hapsody ", - "imestin <34135450+imestin@users.noreply.github.com>", - "isan_rivkin ", - "javaskript <14116782+javaskript@users.noreply.github.com>", - "Ayush Mahajan ", - "jonahweissman <19804455+jonahweissman@users.noreply.github.com>", - "kevingzhang ", - "klueq <43359723+klueq@users.noreply.github.com>", - "James Halliday ", - "Jason Carver ", - "Jeeyong Um ", - "leekt216 ", - "nature hacker <30657227+z89@users.noreply.github.com>", - "Jessica Schilling ", - "Arkadiy Kukarkin ", - "Joe Turgeon ", - "Joel Gustafson ", - "Johannes Wikner ", - "John Kane ", - "Johnny <9611008+johnnymatthews@users.noreply.github.com>", - "Jon Schlinkert ", - "Jade Meskill ", - "Jonathan Commins ", - "noah the goodra ", - "Jacob Karlsson ", - "Jorropo ", - "João Santos " ] } diff --git a/packages/interface-ipfs-core/LICENSE b/packages/interface-ipfs-core/LICENSE index 7d37874703..20ce483c86 100644 --- a/packages/interface-ipfs-core/LICENSE +++ b/packages/interface-ipfs-core/LICENSE @@ -1,21 +1,4 @@ -The MIT License (MIT) +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2018 Protocol Labs, Inc. - -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. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/interface-ipfs-core/LICENSE-APACHE b/packages/interface-ipfs-core/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/interface-ipfs-core/LICENSE-APACHE @@ -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. diff --git a/packages/interface-ipfs-core/LICENSE-MIT b/packages/interface-ipfs-core/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/interface-ipfs-core/LICENSE-MIT @@ -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. diff --git a/packages/interface-ipfs-core/README.md b/packages/interface-ipfs-core/README.md index 29dea01059..4e5b8b7989 100644 --- a/packages/interface-ipfs-core/README.md +++ b/packages/interface-ipfs-core/README.md @@ -1,20 +1,20 @@ # interface-ipfs-core -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?style=flat-square&path=packages/interface-ipfs-core)](https://david-dm.org/ipfs/js-ipfs?path=packages/interface-ipfs-core) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A test suite and interface you can use to implement an IPFS core interface. +> A test suite and interface you can use to implement a IPFS core interface. -## Table of Contents +## Table of contents +- [Install](#install) - [Background](#background) - [Core API](#core-api) - [Modules that implement the interface](#modules-that-implement-the-interface) - [Badge](#badge) -- [Install](#install) - [Usage](#usage) - [Running tests](#running-tests) - [Running tests by command](#running-tests-by-command) @@ -22,9 +22,14 @@ - [Running only specific tests](#running-only-specific-tests) - [Skipping tests](#skipping-tests) - [Skipping specific tests](#skipping-specific-tests) -- [Contribute](#contribute) - - [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i interface-ipfs-core +``` ## Background @@ -54,10 +59,6 @@ Include this badge in your readme if you make a new module that implements inter [![IPFS Core API Compatible](https://cdn.rawgit.com/ipfs/interface-ipfs-core/master/img/badge.svg)](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) ``` -## Install - -In JavaScript land: - ```console $ npm install interface-ipfs-core ``` @@ -163,18 +164,23 @@ tests.repo(createCommon, { }) ``` -## Contribute +## License + +Licensed under either of -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs/issues)! +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +## Contribute -### Want to hack on IPFS? +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.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). -Copyright (c) Protocol Labs, Inc. under the **MIT License**. See [LICENSE.md](./LICENSE.md) for details. +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) [UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index 2416d78ab3..f8cc081875 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -2,9 +2,24 @@ "name": "interface-ipfs-core", "version": "0.155.2", "description": "A test suite and interface you can use to implement a IPFS core interface.", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -22,10 +37,17 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./src/index.js" + } + }, "eslintConfig": { "extends": "ipfs", "parserOptions": { @@ -35,149 +57,66 @@ "test/fixtures/*" ] }, - "exports": { - ".": { - "import": "./src/index.js" - } - }, - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "browser": { - "fs": false, - "os": false, - "path": false - }, "scripts": { "clean": "aegir clean", "build": "aegir build && copyfiles './test/fixtures/**/*' ./dist", "lint": "aegir lint", - "dep-check": "aegir dep-check -i ipfs-core-types -i copyfiles" + "dep-check": "aegir dep-check -i ipfs-core-types -i copyfiles -i @libp2p/interfaces" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, - "keywords": [ - "IPFS" - ], - "license": "MIT", "dependencies": { "@ipld/car": "^4.1.0", "@ipld/dag-cbor": "^7.0.0", "@ipld/dag-pb": "^2.1.3", - "@libp2p/crypto": "^0.22.9", - "@libp2p/interfaces": "^2.0.4", + "@libp2p/crypto": "^1.0.0", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interfaces": "^3.0.3", "@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id-factory": "^1.0.10", - "@libp2p/websockets": "^1.0.8", - "@multiformats/multiaddr": "^10.0.0", - "@types/pako": "^1.0.2", - "@types/readable-stream": "^2.3.11", + "@libp2p/websockets": "^3.0.0", + "@multiformats/multiaddr": "^10.1.8", + "@types/node": "^18.0.0", + "@types/pako": "^2.0.0", + "@types/readable-stream": "^2.3.13", "aegir": "^37.0.11", - "blockstore-core": "^1.0.2", + "blockstore-core": "^2.0.1", "copyfiles": "^2.4.1", - "dag-jose": "^1.0.0", + "dag-jose": "^2.0.1", "delay": "^5.0.0", - "did-jwt": "^5.12.1", + "did-jwt": "^6.2.0", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-unixfs": "^6.0.3", - "ipfs-unixfs-importer": "^9.0.3", + "ipfs-core-types": "^0.11.0", + "ipfs-unixfs": "^7.0.0", + "ipfs-unixfs-importer": "^10.0.1", "ipfs-utils": "^9.0.6", - "ipns": "^1.0.0", + "ipns": "^2.0.2", "is-ipfs": "^6.0.1", "iso-random-stream": "^2.0.2", "it-all": "^1.0.4", "it-buffer-stream": "^2.0.0", "it-concat": "^2.0.0", "it-drain": "^1.0.3", - "it-first": "^1.0.4", + "it-first": "^1.0.6", "it-last": "^1.0.4", - "it-map": "^1.0.4", + "it-map": "^1.0.6", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "it-tar": "^5.0.0", + "it-pushable": "^3.0.0", + "it-tar": "^6.0.0", "it-to-buffer": "^2.0.0", "merge-options": "^3.0.4", "multiformats": "^9.5.1", - "nanoid": "^3.1.23", + "nanoid": "^4.0.0", "p-defer": "^4.0.0", "p-map": "^5.3.0", "p-retry": "^5.1.0", - "p-wait-for": "^4.1.0", + "p-wait-for": "^5.0.0", "pako": "^2.0.4", - "readable-stream": "^3.4.0", + "readable-stream": "^4.0.0", "sinon": "^14.0.0", "uint8arrays": "^3.0.0" }, - "contributors": [ - "Alan Shaw ", - "Alan Shaw ", - "Alex Potsides ", - "Andrey ", - "Dan Ordille ", - "Dan Shields <35669742+NukeManDan@users.noreply.github.com>", - "David Dias ", - "Dmitriy Ryajov ", - "Enrico Marino ", - "Friedel Ziegelmayer ", - "Giles ", - "Haad ", - "Henrique Dias ", - "Hugo Dias ", - "Hugo Dias ", - "Jacob Heun ", - "Jacob Karlsson ", - "Jason Papakostas ", - "Jim Pick ", - "Joel Gustafson ", - "Jonathan ", - "Kevin Simper ", - "Maciej Krüger ", - "Marcin Rataj ", - "Marius Darila ", - "Matt Ober ", - "Matt Zumwalt ", - "Michael Garvin ", - "Michael Muré ", - "Mikeal Rogers ", - "Nicolás Santángelo ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Oli Evans ", - "Pascal Precht ", - "Pedro Santos ", - "Pedro Santos ", - "Pedro Teixeira ", - "Prabhakar Poudel ", - "Richard Littauer ", - "Richard Schneider ", - "Ryan Bell ", - "Sangwon Hong ", - "Stephen Whitmore ", - "Steven Allen ", - "Teri Chadbourne ", - "Thiago Delgado ", - "Travis Person ", - "Travis Person ", - "Vasco Santos ", - "Vasco Santos ", - "Volker Mische ", - "Vutsal Singhal ", - "dirkmc ", - "greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>", - "greenkeeper[bot] ", - "greenkeeperio-bot ", - "haad ", - "isan_rivkin ", - "klueq <43359723+klueq@users.noreply.github.com>", - "kumavis ", - "nginnever ", - "reasv <7143787+reasv@users.noreply.github.com>", - "ron litzenberger ", - "shunkin ", - "tcme ", - "victorbjelkholm ", - "Łukasz Magiera ", - "Максим Ильин " - ] + "browser": { + "fs": false, + "os": false, + "path": false + } } diff --git a/packages/interface-ipfs-core/src/add.js b/packages/interface-ipfs-core/src/add.js index 154fac2303..38cd90175b 100644 --- a/packages/interface-ipfs-core/src/add.js +++ b/packages/interface-ipfs-core/src/add.js @@ -30,7 +30,7 @@ export function testAdd (factory, options) { const it = getIt(options) describe('.add', function () { - this.timeout(540 * 1000) + this.timeout(1080 * 1000) /** @type {import('ipfs-core-types').IPFS} */ let ipfs diff --git a/packages/interface-ipfs-core/src/bitswap/utils.js b/packages/interface-ipfs-core/src/bitswap/utils.js index 68957d217c..04a942e869 100644 --- a/packages/interface-ipfs-core/src/bitswap/utils.js +++ b/packages/interface-ipfs-core/src/bitswap/utils.js @@ -1,7 +1,7 @@ import delay from 'delay' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/interface-ipfs-core/src/dag/get.js b/packages/interface-ipfs-core/src/dag/get.js index 2507baa480..607e47f6d7 100644 --- a/packages/interface-ipfs-core/src/dag/get.js +++ b/packages/interface-ipfs-core/src/dag/get.js @@ -105,7 +105,7 @@ export function testGet (factory, options) { await ipfs.dag.put(nodePb, { storeCodec: 'dag-pb', hashAlg: 'sha2-256' }) await ipfs.dag.put(nodeCbor, { storeCodec: 'dag-cbor', hashAlg: 'sha2-256' }) - const signer = ES256KSigner('278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f') + const signer = ES256KSigner(uint8ArrayFromString('278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f', 'hex')) nodeJose = await createJWS(base64url.encode(cidCbor.bytes).slice(1), signer) cidJose = CID.createV1(dagJOSE.code, await sha256.digest(dagJOSE.encode(nodeJose))) await ipfs.dag.put(nodeJose, { storeCodec: dagJOSE.name, hashAlg: 'sha2-256' }) diff --git a/packages/interface-ipfs-core/src/miscellaneous/id.js b/packages/interface-ipfs-core/src/miscellaneous/id.js index 7b141bf91e..507cf19583 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/id.js +++ b/packages/interface-ipfs-core/src/miscellaneous/id.js @@ -48,17 +48,11 @@ export function testId (factory, options) { expect(res).to.have.a.property('protocols').that.is.an('array') expect(res.protocols).to.include.members([ - '/floodsub/1.0.0', - '/ipfs/bitswap/1.0.0', - '/ipfs/bitswap/1.1.0', '/ipfs/bitswap/1.2.0', '/ipfs/id/1.0.0', '/ipfs/id/push/1.0.0', '/ipfs/lan/kad/1.0.0', - '/ipfs/ping/1.0.0', - '/libp2p/circuit/relay/0.1.0', - '/meshsub/1.0.0', - '/meshsub/1.1.0' + '/ipfs/ping/1.0.0' ]) }) diff --git a/packages/interface-ipfs-core/src/name-pubsub/pubsub.js b/packages/interface-ipfs-core/src/name-pubsub/pubsub.js index c003794030..7849334951 100644 --- a/packages/interface-ipfs-core/src/name-pubsub/pubsub.js +++ b/packages/interface-ipfs-core/src/name-pubsub/pubsub.js @@ -25,7 +25,7 @@ const daemonsOptions = { /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler} EventHandler */ @@ -126,7 +126,7 @@ export function testPubsub (factory, options) { const testAccountName = 'test-account' /** - * @type {import('@libp2p/interfaces/pubsub').Message} + * @type {import('@libp2p/interface-pubsub').Message} */ let publishedMessage @@ -162,8 +162,12 @@ export function testPubsub (factory, options) { const publishedMessageData = ipns.unmarshal(publishedMessage.data) - if (!publishedMessageData.pubKey) { - throw new Error('No public key found in message data') + if (publishedMessage.type !== 'signed') { + throw new Error('Message was not signed') + } + + if (publishedMessageData.pubKey == null) { + throw new Error('Public key was missing from published message data') } const messageKey = publishedMessage.from diff --git a/packages/interface-ipfs-core/src/name/publish.js b/packages/interface-ipfs-core/src/name/publish.js index 6bfb01b0e1..e44b806387 100644 --- a/packages/interface-ipfs-core/src/name/publish.js +++ b/packages/interface-ipfs-core/src/name/publish.js @@ -10,7 +10,7 @@ import { peerIdFromString } from '@libp2p/peer-id' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/interface-ipfs-core/src/name/resolve.js b/packages/interface-ipfs-core/src/name/resolve.js index 3c3c41c835..f1fa281733 100644 --- a/packages/interface-ipfs-core/src/name/resolve.js +++ b/packages/interface-ipfs-core/src/name/resolve.js @@ -10,7 +10,7 @@ import * as Digest from 'multiformats/hashes/digest' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/interface-ipfs-core/src/pubsub/subscribe.js b/packages/interface-ipfs-core/src/pubsub/subscribe.js index f4093ac196..bad06e4015 100644 --- a/packages/interface-ipfs-core/src/pubsub/subscribe.js +++ b/packages/interface-ipfs-core/src/pubsub/subscribe.js @@ -13,11 +13,11 @@ import { isWebWorker, isNode } from 'ipfs-utils/src/env.js' import sinon from 'sinon' import defer from 'p-defer' import pWaitFor from 'p-wait-for' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('it-pushable').Pushable} Pushable * @typedef {import('p-defer').DeferredPromise} DeferredMessagePromise */ @@ -84,6 +84,10 @@ export function testSubscribe (factory, options) { const msg = await deferred.promise + if (msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(msg.data)).to.equal('hi') expect(msg).to.have.property('sequenceNumber') expect(msg.sequenceNumber).to.be.a('BigInt') @@ -93,7 +97,7 @@ export function testSubscribe (factory, options) { }) it('should subscribe to one topic with options', async () => { - const msgStream = pushable() + const msgStream = pushable({ objectMode: true }) await ipfs1.pubsub.subscribe(topic, msg => { msgStream.push(msg) @@ -153,7 +157,7 @@ export function testSubscribe (factory, options) { }) it('should allow discover option to be passed', async () => { - const msgStream = pushable() + const msgStream = pushable({ objectMode: true }) await ipfs1.pubsub.subscribe(topic, msg => { msgStream.push(msg) @@ -248,10 +252,20 @@ export function testSubscribe (factory, options) { await ipfs2.pubsub.publish(topic, uint8ArrayFromString(expectedString)) const sub1Msg = await msgStream1.promise + + if (sub1Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub1Msg.data)).to.be.eql(expectedString) expect(sub1Msg.from.toString()).to.eql(ipfs2Id.id.toString()) const sub2Msg = await msgStream2.promise + + if (sub2Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub2Msg.data)).to.be.eql(expectedString) expect(sub2Msg.from.toString()).to.eql(ipfs2Id.id.toString()) }) @@ -283,10 +297,20 @@ export function testSubscribe (factory, options) { await ipfs2.pubsub.publish(topic, uint8ArrayFromString(expectedString)) const sub1Msg = await msgStream1.promise + + if (sub1Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub1Msg.data)).to.be.eql(expectedString) expect(sub1Msg.from.toString()).to.eql(ipfs2Id.id.toString()) const sub2Msg = await msgStream2.promise + + if (sub2Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub2Msg.data)).to.be.eql(expectedString) expect(sub2Msg.from.toString()).to.eql(ipfs2Id.id.toString()) }) @@ -319,10 +343,20 @@ export function testSubscribe (factory, options) { await ipfs2.pubsub.publish(topic, buffer) const sub1Msg = await msgStream1.promise + + if (sub1Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub1Msg.data, 'base16')).to.be.eql(expectedHex) expect(sub1Msg.from.toString()).to.eql(ipfs2Id.id.toString()) const sub2Msg = await msgStream2.promise + + if (sub2Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub2Msg.data, 'base16')).to.be.eql(expectedHex) expect(sub2Msg.from.toString()).to.eql(ipfs2Id.id.toString()) }) @@ -330,8 +364,8 @@ export function testSubscribe (factory, options) { it('should receive multiple messages', async () => { const outbox = ['hello', 'world', 'this', 'is', 'pubsub'] - const msgStream1 = pushable() - const msgStream2 = pushable() + const msgStream1 = pushable({ objectMode: true }) + const msgStream2 = pushable({ objectMode: true }) let sub1Called = 0 /** @type {import('@libp2p/interfaces/events').EventHandler} */ @@ -377,7 +411,7 @@ export function testSubscribe (factory, options) { const msgBase = 'msg - ' const count = 100 - const msgStream = pushable() + const msgStream = pushable({ objectMode: true }) let subCalled = 0 /** @type {import('@libp2p/interfaces/events').EventHandler} */ @@ -426,8 +460,8 @@ export function testSubscribe (factory, options) { const topic = `pubsub-topic-${Math.random()}` topics.push(topic) - const msgStream1 = pushable() - const msgStream2 = pushable() + const msgStream1 = pushable({ objectMode: true }) + const msgStream2 = pushable({ objectMode: true }) msgStreams.push({ msgStream1, diff --git a/packages/interface-ipfs-core/src/pubsub/unsubscribe.js b/packages/interface-ipfs-core/src/pubsub/unsubscribe.js index 7746525414..5112e00e47 100644 --- a/packages/interface-ipfs-core/src/pubsub/unsubscribe.js +++ b/packages/interface-ipfs-core/src/pubsub/unsubscribe.js @@ -7,7 +7,7 @@ import waitFor from '../utils/wait-for.js' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ /** diff --git a/packages/interface-ipfs-core/src/pubsub/utils.js b/packages/interface-ipfs-core/src/pubsub/utils.js index cdf90788d1..540f6d4d1a 100644 --- a/packages/interface-ipfs-core/src/pubsub/utils.js +++ b/packages/interface-ipfs-core/src/pubsub/utils.js @@ -2,7 +2,7 @@ import { nanoid } from 'nanoid' import delay from 'delay' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/ipfs-cli/LICENSE b/packages/ipfs-cli/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-cli/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-cli/LICENSE-MIT b/packages/ipfs-cli/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-cli/LICENSE-MIT +++ b/packages/ipfs-cli/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-cli/README.md b/packages/ipfs-cli/README.md index 08fee6dff8..1ec7e2843e 100644 --- a/packages/ipfs-cli/README.md +++ b/packages/ipfs-cli/README.md @@ -1,16 +1,24 @@ # ipfs-cli -> The implementation of the js-IPFS CLI +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-cli +``` ```console $ npm install -g ipfs @@ -18,23 +26,21 @@ $ npm install -g ipfs $ jsipfs daemon ``` -## Want to hack on IPFS? +## License -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +Licensed under either of -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +## Contribute -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -## License +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. + +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). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-cli/package.json b/packages/ipfs-cli/package.json index 79259e3a02..17a9d21cdd 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -2,15 +2,24 @@ "name": "ipfs-cli", "version": "0.13.5", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-cli#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-cli#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,27 +37,26 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./utils": { + "types": "./src/utils.d.ts", "import": "./src/utils.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "lint": "aegir lint", @@ -62,26 +70,26 @@ "@ipld/dag-cbor": "^7.0.0", "@ipld/dag-json": "^8.0.1", "@ipld/dag-pb": "^2.1.3", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^10.0.0", + "@multiformats/multiaddr": "^10.1.8", "@multiformats/multiaddr-to-uri": "^9.0.1", "byteman": "^1.3.5", "execa": "^6.1.0", - "get-folder-size": "^3.1.0", - "ipfs-core": "^0.15.4", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-daemon": "^0.13.5", - "ipfs-http-client": "^57.0.3", + "get-folder-size": "^4.0.0", + "ipfs-core": "^0.15.0", + "ipfs-core-types": "^0.11.0", + "ipfs-core-utils": "^0.15.0", + "ipfs-daemon": "^0.13.0", + "ipfs-http-client": "^57.0.0", "ipfs-utils": "^9.0.6", "it-concat": "^2.0.0", - "it-map": "^1.0.5", + "it-map": "^1.0.6", "it-merge": "^1.0.3", "it-pipe": "^2.0.3", "it-split": "^1.0.0", - "it-tar": "^5.0.0", + "it-tar": "^6.0.0", "jsondiffpatch": "^0.4.1", "multiformats": "^9.5.1", "parse-duration": "^1.0.0", @@ -92,18 +100,18 @@ "yargs": "^17.4.0" }, "devDependencies": { - "@libp2p/crypto": "^0.22.9", + "@libp2p/crypto": "^1.0.0", "@types/get-folder-size": "^3.0.1", "@types/ncp": "^2.0.5", "@types/progress": "^2.0.3", "@types/rimraf": "^3.0.1", "@types/yargs": "^17.0.10", "aegir": "^37.0.11", - "ipfs-repo": "^14.0.1", + "ipfs-repo": "^15.0.0", "it-all": "^1.0.4", "it-first": "^1.0.4", "it-to-buffer": "^2.0.0", - "nanoid": "^3.1.23", + "nanoid": "^4.0.0", "ncp": "^2.0.0", "pako": "^2.0.4", "rimraf": "^3.0.2", diff --git a/packages/ipfs-cli/src/commands/bitswap/wantlist.js b/packages/ipfs-cli/src/commands/bitswap/wantlist.js index 54132e31c1..a61bb33241 100644 --- a/packages/ipfs-cli/src/commands/bitswap/wantlist.js +++ b/packages/ipfs-cli/src/commands/bitswap/wantlist.js @@ -4,7 +4,7 @@ import { coercePeerId } from '../../utils.js' /** * @typedef {object} Argv * @property {import('../../types').Context} Argv.ctx - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peer + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peer * @property {string} Argv.cidBase * @property {number} Argv.timeout */ diff --git a/packages/ipfs-cli/src/commands/dht/find-peer.js b/packages/ipfs-cli/src/commands/dht/find-peer.js index 652f8ff568..bb9cdc06cf 100644 --- a/packages/ipfs-cli/src/commands/dht/find-peer.js +++ b/packages/ipfs-cli/src/commands/dht/find-peer.js @@ -4,7 +4,7 @@ import { coercePeerId } from '../../utils.js' /** * @typedef {object} Argv * @property {import('../../types').Context} Argv.ctx - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peerId + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peerId * @property {number} Argv.timeout */ diff --git a/packages/ipfs-cli/src/commands/dht/query.js b/packages/ipfs-cli/src/commands/dht/query.js index bbbafd1bb7..32bba2d324 100644 --- a/packages/ipfs-cli/src/commands/dht/query.js +++ b/packages/ipfs-cli/src/commands/dht/query.js @@ -4,7 +4,7 @@ import { coercePeerId } from '../../utils.js' /** * @typedef {object} Argv * @property {import('../../types').Context} Argv.ctx - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peerId + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peerId * @property {number} Argv.timeout * @property {number} Argv.count */ diff --git a/packages/ipfs-cli/src/commands/id.js b/packages/ipfs-cli/src/commands/id.js index f9609f6c12..ac177a2bcb 100644 --- a/packages/ipfs-cli/src/commands/id.js +++ b/packages/ipfs-cli/src/commands/id.js @@ -6,7 +6,7 @@ import { coercePeerId } from '../utils.js' * @property {import('../types').Context} Argv.ctx * @property {string} Argv.format * @property {number} Argv.timeout - * @property {import('@libp2p/interfaces/peer-id').PeerId} [Argv.peerId] + * @property {import('@libp2p/interface-peer-id').PeerId} [Argv.peerId] */ /** @type {import('yargs').CommandModule} */ diff --git a/packages/ipfs-cli/src/commands/ping.js b/packages/ipfs-cli/src/commands/ping.js index b55a66c5f2..619b22a31a 100644 --- a/packages/ipfs-cli/src/commands/ping.js +++ b/packages/ipfs-cli/src/commands/ping.js @@ -5,7 +5,7 @@ import { coercePeerId } from '../utils.js' * @typedef {object} Argv * @property {import('../types').Context} Argv.ctx * @property {number} Argv.count - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peerId + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peerId * @property {number} Argv.timeout */ diff --git a/packages/ipfs-cli/src/commands/pubsub/sub.js b/packages/ipfs-cli/src/commands/pubsub/sub.js index 4c310ab6ef..b08eecbcb8 100644 --- a/packages/ipfs-cli/src/commands/pubsub/sub.js +++ b/packages/ipfs-cli/src/commands/pubsub/sub.js @@ -1,7 +1,7 @@ import parseDuration from 'parse-duration' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ /** diff --git a/packages/ipfs-cli/src/commands/stats/bw.js b/packages/ipfs-cli/src/commands/stats/bw.js index cabbab6083..fb0b40adc5 100644 --- a/packages/ipfs-cli/src/commands/stats/bw.js +++ b/packages/ipfs-cli/src/commands/stats/bw.js @@ -4,7 +4,7 @@ import { coercePeerId } from '../../utils.js' /** * @typedef {object} Argv * @property {import('../../types').Context} Argv.ctx - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peer + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peer * @property {string} Argv.proto * @property {boolean} Argv.poll * @property {number} Argv.interval diff --git a/packages/ipfs-cli/test/utils/match-peer-id.js b/packages/ipfs-cli/test/utils/match-peer-id.js index 35dfa56b13..5095c2de9a 100644 --- a/packages/ipfs-cli/test/utils/match-peer-id.js +++ b/packages/ipfs-cli/test/utils/match-peer-id.js @@ -1,7 +1,7 @@ import sinon from 'sinon' /** - * @param {import('@libp2p/interfaces/peer-id').PeerId} peerId + * @param {import('@libp2p/interface-peer-id').PeerId} peerId * @returns {import('sinon').SinonMatcher} */ export function matchPeerId (peerId) { diff --git a/packages/ipfs-client/LICENSE b/packages/ipfs-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-client/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-client/LICENSE-APACHE b/packages/ipfs-client/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-client/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-client/LICENSE-MIT b/packages/ipfs-client/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-client/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-client/README.md b/packages/ipfs-client/README.md index 4d1d37ff09..468fcc47aa 100644 --- a/packages/ipfs-client/README.md +++ b/packages/ipfs-client/README.md @@ -1,15 +1,33 @@ -# ipfs-client +# ipfs-client -> A client for [ipfs][] daemons +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -This module combines the [ipfs-grpc-client][] and [ipfs-http-client][] modules to give you a client that is capable of bidirectional streaming in the browser as well as node. +> A client library to talk to local IPFS daemons + +## Table of contents + +- [Install](#install) +- [API](#api) + - [`create([options])`](#createoptions) + - [Parameters](#parameters) + - [Options](#options) + - [Returns](#returns) + - [Example](#example) +- [License](#license) +- [Contribute](#contribute) ## Install ```console -$ npm install ipfs-client +$ npm i ipfs-client ``` +This module combines the [ipfs-grpc-client][] and [ipfs-http-client][] modules to give you a client that is capable of bidirectional streaming in the browser as well as node. + ## API The client object created by the `createClient` function supports the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api), see the docs for more. @@ -24,16 +42,16 @@ None An optional object which may have the following keys: -| Name | Type | Default | Description | -| ---- | ---- | ------- | ----------- | -| grpc | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | -| http | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-http-server][] to connect to | +| Name | Type | Default | Description | +| ----- | -------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------- | +| grpc | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | +| http | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-http-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) | ### Returns -| Type | Description | -| -------- | -------- | +| Type | Description | +| -------- | ------------------------- | | `object` | An instance of the client | ### Example @@ -49,8 +67,31 @@ const client = create({ const id = await client.id() ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + [ipfs]: https://www.npmjs.com/package/ipfs + [ipfs-grpc-client]: https://www.npmjs.com/package/ipfs-grpc-client + [ipfs-http-client]: https://www.npmjs.com/package/ipfs-http-client + [ipfs-grpc-server]: https://www.npmjs.com/package/ipfs-grpc-server + [ipfs-http-server]: https://www.npmjs.com/package/ipfs-http-server diff --git a/packages/ipfs-client/package.json b/packages/ipfs-client/package.json index 457c842aad..98c76d6e0e 100644 --- a/packages/ipfs-client/package.json +++ b/packages/ipfs-client/package.json @@ -2,34 +2,57 @@ "name": "ipfs-client", "version": "0.8.3", "description": "A client library to talk to local IPFS daemons", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -38,8 +61,8 @@ "dep-check": "aegir dep-check -i aegir" }, "dependencies": { - "ipfs-grpc-client": "^0.10.2", - "ipfs-http-client": "^57.0.3", + "ipfs-grpc-client": "^0.10.0", + "ipfs-http-client": "^57.0.0", "merge-options": "^3.0.4" }, "devDependencies": { diff --git a/packages/ipfs-client/tsconfig.json b/packages/ipfs-client/tsconfig.json index e6c324da5b..a5eb86d485 100644 --- a/packages/ipfs-client/tsconfig.json +++ b/packages/ipfs-client/tsconfig.json @@ -9,10 +9,10 @@ ], "references": [ { - "path": "../ipfs-http-client" + "path": "../ipfs-grpc-client" }, { - "path": "../ipfs-grpc-client" + "path": "../ipfs-http-client" } ] } diff --git a/packages/ipfs-core-config/LICENSE b/packages/ipfs-core-config/LICENSE index 2c624782f3..20ce483c86 100644 --- a/packages/ipfs-core-config/LICENSE +++ b/packages/ipfs-core-config/LICENSE @@ -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 diff --git a/packages/ipfs-core-config/LICENSE-APACHE b/packages/ipfs-core-config/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-core-config/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-core-config/LICENSE-MIT b/packages/ipfs-core-config/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-core-config/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-core-config/README.md b/packages/ipfs-core-config/README.md index 661851a76d..14218e9c74 100644 --- a/packages/ipfs-core-config/README.md +++ b/packages/ipfs-core-config/README.md @@ -1,33 +1,40 @@ -# ipfs-core-utils +# ipfs-core-config -[![](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) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-core-config)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-core-config) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> This package serves as a repository code shared between the core `ipfs` core implementation and the `ipfs-http-client` +> Package to store node and browser specific config for ipfs-core -## Table of Contents +## Table of contents - [Install](#install) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-core-utils +```console +$ npm i ipfs-core-config ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/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) diff --git a/packages/ipfs-core-config/package.json b/packages/ipfs-core-config/package.json index 36f0474c78..a19fbdbea6 100644 --- a/packages/ipfs-core-config/package.json +++ b/packages/ipfs-core-config/package.json @@ -3,11 +3,21 @@ "version": "0.4.1", "description": "Package to store node and browser specific config for ipfs-core", "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-config#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -25,52 +35,57 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./config": { + "types": "./src/config.d.ts", "browser": "./src/config.browser.js", "import": "./src/config.js" }, "./dns": { + "types": "./src/dns.d.ts", "browser": "./src/dns.browser.js", "import": "./src/dns.js" }, "./init-assets": { + "types": "./src/init-assets.d.ts", "browser": "./src/init-assets.browser.js", "import": "./src/init-assets.js" }, "./libp2p": { + "types": "./src/libp2p.d.ts", "browser": "./src/libp2p.browser.js", "import": "./src/libp2p.js" }, "./libp2p-pubsub-routers": { + "types": "./src/libp2p-pubsub-routers.d.ts", "browser": "./src/libp2p-pubsub-routers.browser.js", "import": "./src/libp2p-pubsub-routers.js" }, "./preload": { + "types": "./src/preload.d.ts", "browser": "./src/preload.browser.js", "import": "./src/preload.js" }, "./repo": { + "types": "./src/repo.d.ts", "browser": "./src/repo.browser.js", "import": "./src/repo.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "lint": "aegir lint", @@ -78,22 +93,21 @@ "dep-check": "aegir dep-check -i aegir -i ipfs-core-utils", "build": "aegir build" }, - "license": "MIT", "dependencies": { - "@chainsafe/libp2p-gossipsub": "^1.0.0", - "@libp2p/floodsub": "^1.0.2", - "@libp2p/logger": "^1.1.4", - "@libp2p/mdns": "^1.0.3", - "@libp2p/tcp": "^1.0.6", - "@libp2p/webrtc-star": "^1.0.6", - "blockstore-datastore-adapter": "^2.0.2", - "datastore-core": "^7.0.0", - "datastore-fs": "^7.0.0", - "datastore-level": "^8.0.0", + "@chainsafe/libp2p-gossipsub": "^4.0.0", + "@libp2p/floodsub": "^3.0.0", + "@libp2p/logger": "^2.0.0", + "@libp2p/mdns": "^3.0.0", + "@libp2p/tcp": "^3.0.1", + "@libp2p/webrtc-star": "^3.0.0", + "blockstore-datastore-adapter": "^3.0.0", + "datastore-core": "^8.0.1", + "datastore-fs": "^8.0.0", + "datastore-level": "^9.0.0", "err-code": "^3.0.1", "hashlru": "^2.3.0", - "interface-datastore": "^6.1.1", - "ipfs-repo": "^14.0.1", + "interface-datastore": "^7.0.0", + "ipfs-repo": "^15.0.0", "ipfs-utils": "^9.0.6", "is-ipfs": "^6.0.1", "it-all": "^1.0.4", @@ -104,6 +118,6 @@ }, "devDependencies": { "aegir": "^37.0.11", - "ipfs-core-utils": "^0.15.1" + "ipfs-core-utils": "^0.15.0" } } diff --git a/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js b/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js index 0dff8d6e33..d2749def9a 100644 --- a/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js +++ b/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js @@ -1,12 +1,14 @@ import { GossipSub } from '@chainsafe/libp2p-gossipsub' -/** @typedef {import('@libp2p/interfaces/pubsub').PubSub} PubSub */ +/** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ /** @type {() => Record}>} */ export const routers = () => ({ gossipsub: new GossipSub({ allowPublishToZeroPeers: true, fallbackToFloodsub: true, - emitSelf: true + emitSelf: true, + maxInboundStreams: 64, + maxOutboundStreams: 128 }) }) diff --git a/packages/ipfs-core-config/src/libp2p-pubsub-routers.js b/packages/ipfs-core-config/src/libp2p-pubsub-routers.js index 0acbb0f49c..b21da2882a 100644 --- a/packages/ipfs-core-config/src/libp2p-pubsub-routers.js +++ b/packages/ipfs-core-config/src/libp2p-pubsub-routers.js @@ -1,14 +1,16 @@ import { GossipSub } from '@chainsafe/libp2p-gossipsub' import { FloodSub } from '@libp2p/floodsub' -/** @typedef {import('@libp2p/interfaces/pubsub').PubSub} PubSub */ +/** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ /** @type {() => Record}>} */ export const routers = () => ({ gossipsub: new GossipSub({ allowPublishToZeroPeers: true, fallbackToFloodsub: true, - emitSelf: true + emitSelf: true, + maxInboundStreams: 64, + maxOutboundStreams: 128 }), floodsub: new FloodSub({ emitSelf: true diff --git a/packages/ipfs-core-config/tsconfig.json b/packages/ipfs-core-config/tsconfig.json index b3e9d0eb46..b32180efc4 100644 --- a/packages/ipfs-core-config/tsconfig.json +++ b/packages/ipfs-core-config/tsconfig.json @@ -10,7 +10,7 @@ ], "references": [ { - "path": "../ipfs-core-types" + "path": "../ipfs-core-utils" } ] } diff --git a/packages/ipfs-core-types/LICENSE b/packages/ipfs-core-types/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-core-types/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-core-types/LICENSE-MIT b/packages/ipfs-core-types/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-core-types/LICENSE-MIT +++ b/packages/ipfs-core-types/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-core-types/README.md b/packages/ipfs-core-types/README.md index 37a5abce74..74084e05de 100644 --- a/packages/ipfs-core-types/README.md +++ b/packages/ipfs-core-types/README.md @@ -1,24 +1,29 @@ # ipfs-core-types -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?style=flat-square&path=packages/ipfs-core-types)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-core-types) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> IPFS interface definitions used by implementations for API compatibility +> IPFS interface definitions used by implementations for API compatibility. -## Table of Contents +## Table of contents -- [Background](#background) - [Install](#install) +- [Background](#background) - [Usage](#usage) - [In JSDoc syntax](#in-jsdoc-syntax) - [In Typescript](#in-typescript) - [Validation](#validation) -- [Contribute](#contribute) - - [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-core-types +``` ## Background @@ -26,10 +31,6 @@ The primary goal of this module is to define and ensure that IPFS core implement It offers a set of typescript interface definitions that define the IPFS core API. Once your implementation implements those APIs you can use the tests found in the [interface-ipfs-core](https://www.npmjs.com/package/interface-ipfs-core) module to validate your implementation. -## Install - -In JavaScript land: - ```console $ npm install ipfs-core-types ``` @@ -62,19 +63,21 @@ class MyImpl implements IPFS { In order to validate API compatibility you can run [typescript](https://www.typescriptlang.org/) over your implementation which will point out all the API compatibilities if there are some. +## License -## Contribute +Licensed under either of -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs/issues)! +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +## Contribute -### Want to hack on IPFS? +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.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). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +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. -[![](https://github.com/ipfs/js-ipfs/raw/master/ipfs-core-types/img/badge.png)](https://github.com/ipfs/js-ipfs/tree/master/ipfs-core-types) +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-core-types/package.json b/packages/ipfs-core-types/package.json index 91cc7ab06c..e45bb51805 100644 --- a/packages/ipfs-core-types/package.json +++ b/packages/ipfs-core-types/package.json @@ -2,60 +2,63 @@ "name": "ipfs-core-types", "version": "0.11.1", "description": "IPFS interface definitions used by implementations for API compatibility.", - "types": "dist/src/index.d.ts", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-types#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "scripts": { - "clean": "aegir clean", - "lint": "aegir lint", - "build": "aegir build" + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "keywords": [ + "API", + "IPFS", + "interface", + "types" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" }, + "type": "module", + "types": "./dist/src/index.d.ts", "files": [ - "dist", "src", + "dist/src", + "!dist/test", "!**/*.tsbuildinfo" ], - "typesVersions": { - "*": { - "*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ], - "src/*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ] + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" } }, "eslintConfig": { - "extends": "ipfs" + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "scripts": { + "clean": "aegir clean", + "lint": "aegir lint", + "build": "aegir build" }, - "keywords": [ - "IPFS", - "types", - "interface", - "API" - ], - "license": "(Apache-2.0 OR MIT)", "dependencies": { "@ipld/dag-pb": "^2.1.3", - "interface-datastore": "^6.1.1", - "ipfs-unixfs": "^6.0.9", - "@multiformats/multiaddr": "^10.0.0", + "@libp2p/interface-keychain": "^1.0.3", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-peer-info": "^1.0.2", + "@libp2p/interface-pubsub": "^2.0.0", + "@multiformats/multiaddr": "^10.1.8", + "@types/node": "^18.0.0", + "interface-datastore": "^7.0.0", + "ipfs-unixfs": "^7.0.0", "multiformats": "^9.5.1" }, "devDependencies": { "aegir": "^37.0.11" - }, - "contributors": [ - "Irakli Gozalishvili " - ] + } } diff --git a/packages/ipfs-core-types/src/bitswap/index.ts b/packages/ipfs-core-types/src/bitswap/index.ts index b239fac72e..3fa2123f58 100644 --- a/packages/ipfs-core-types/src/bitswap/index.ts +++ b/packages/ipfs-core-types/src/bitswap/index.ts @@ -1,6 +1,6 @@ import type { CID } from 'multiformats/cid' import type { AbortOptions } from '../utils' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/dht/index.ts b/packages/ipfs-core-types/src/dht/index.ts index fa25233fd2..55676c2fcf 100644 --- a/packages/ipfs-core-types/src/dht/index.ts +++ b/packages/ipfs-core-types/src/dht/index.ts @@ -1,7 +1,7 @@ import type { AbortOptions } from '../utils' import type { CID } from 'multiformats/cid' -import type { PeerId } from '@libp2p/interfaces/peer-id' -import type { PeerInfo } from '@libp2p/interfaces/peer-info' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { PeerInfo } from '@libp2p/interface-peer-info' export interface API { /** diff --git a/packages/ipfs-core-types/src/key/index.ts b/packages/ipfs-core-types/src/key/index.ts index a848196a8d..2d3f5698dd 100644 --- a/packages/ipfs-core-types/src/key/index.ts +++ b/packages/ipfs-core-types/src/key/index.ts @@ -1,5 +1,5 @@ import type { AbortOptions } from '../utils' -import type { KeyType } from '@libp2p/interfaces/keychain' +import type { KeyType } from '@libp2p/interface-keychain' export interface API { /** diff --git a/packages/ipfs-core-types/src/name/index.ts b/packages/ipfs-core-types/src/name/index.ts index 300c899f3c..de824e6cc6 100644 --- a/packages/ipfs-core-types/src/name/index.ts +++ b/packages/ipfs-core-types/src/name/index.ts @@ -1,7 +1,7 @@ import type { CID } from 'multiformats/cid' import type { AbortOptions } from '../utils' import type { API as PubsubAPI } from './pubsub' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/pubsub/index.ts b/packages/ipfs-core-types/src/pubsub/index.ts index fbac8ed74b..6768cae695 100644 --- a/packages/ipfs-core-types/src/pubsub/index.ts +++ b/packages/ipfs-core-types/src/pubsub/index.ts @@ -1,6 +1,6 @@ import type { AbortOptions } from '../utils' -import type { PeerId } from '@libp2p/interfaces/peer-id' -import type { Message } from '@libp2p/interfaces/pubsub' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { Message } from '@libp2p/interface-pubsub' import type { EventHandler } from '@libp2p/interfaces/events' export interface API { diff --git a/packages/ipfs-core-types/src/root.ts b/packages/ipfs-core-types/src/root.ts index 6ca27dcdc4..bcba95bbf6 100644 --- a/packages/ipfs-core-types/src/root.ts +++ b/packages/ipfs-core-types/src/root.ts @@ -2,7 +2,7 @@ import type { AbortOptions, PreloadOptions, IPFSPath, ImportCandidateStream, Imp import type { CID, CIDVersion } from 'multiformats/cid' import type { Mtime } from 'ipfs-unixfs' import type { Multiaddr } from '@multiformats/multiaddr' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/stats/index.ts b/packages/ipfs-core-types/src/stats/index.ts index 43f69ce1e4..fba9aba2a9 100644 --- a/packages/ipfs-core-types/src/stats/index.ts +++ b/packages/ipfs-core-types/src/stats/index.ts @@ -1,7 +1,7 @@ import type { AbortOptions } from '../utils' import type { API as BitswapAPI } from '../bitswap' import type { API as RepoAPI } from '../repo' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { bitswap: BitswapAPI['stat'] diff --git a/packages/ipfs-core-types/src/swarm/index.ts b/packages/ipfs-core-types/src/swarm/index.ts index 48849531e6..f8bbf4362f 100644 --- a/packages/ipfs-core-types/src/swarm/index.ts +++ b/packages/ipfs-core-types/src/swarm/index.ts @@ -1,6 +1,6 @@ import type { AbortOptions } from '../utils' import type { Multiaddr } from '@multiformats/multiaddr' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/utils.ts b/packages/ipfs-core-types/src/utils.ts index 1833a70b04..bc641a31c4 100644 --- a/packages/ipfs-core-types/src/utils.ts +++ b/packages/ipfs-core-types/src/utils.ts @@ -119,7 +119,7 @@ export interface PreloadOptions { export type IPFSPath = CID | string export interface BufferStore { - put: (key: Uint8Array, value: Uint8Array) => Promise - get: (key: Uint8Array) => Promise + put: (key: Uint8Array, value: Uint8Array, options?: AbortOptions) => Promise + get: (key: Uint8Array, options?: AbortOptions) => Promise stores: any[] } diff --git a/packages/ipfs-core-types/tsconfig.json b/packages/ipfs-core-types/tsconfig.json index 8988b1e0a2..5fe8ea40d7 100644 --- a/packages/ipfs-core-types/tsconfig.json +++ b/packages/ipfs-core-types/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "dist", - "emitDeclarationOnly": true + "outDir": "dist" }, "include": [ "src" diff --git a/packages/ipfs-core-utils/LICENSE b/packages/ipfs-core-utils/LICENSE index 2c624782f3..20ce483c86 100644 --- a/packages/ipfs-core-utils/LICENSE +++ b/packages/ipfs-core-utils/LICENSE @@ -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 diff --git a/packages/ipfs-core-utils/LICENSE-APACHE b/packages/ipfs-core-utils/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-core-utils/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-core-utils/LICENSE-MIT b/packages/ipfs-core-utils/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-core-utils/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-core-utils/README.md b/packages/ipfs-core-utils/README.md index 0f3319d8d8..5a3d3c05b4 100644 --- a/packages/ipfs-core-utils/README.md +++ b/packages/ipfs-core-utils/README.md @@ -1,33 +1,40 @@ # ipfs-core-utils -[![](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) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-core-utils)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-core-utils) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> This package serves as a repository code shared between the core `ipfs` core implementation and the `ipfs-http-client` +> Package to share code between ipfs and ipfs-http-client -## Table of Contents +## Table of contents - [Install](#install) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-core-utils +```console +$ npm i ipfs-core-utils ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/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) diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index 18c4759aa5..2ac533bfff 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -3,11 +3,21 @@ "version": "0.15.1", "description": "Package to share code between ipfs and ipfs-http-client", "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-utils#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -25,80 +35,96 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, - "./files/normalise-input-single": { - "import": "./src/files/normalise-input-single.js" + "./agent": { + "types": "./src/agent.d.ts", + "browser": "./src/agent.browser.js", + "import": "./src/agent.js" }, - "./files/normalise-input-single.browser": { - "import": "./src/files/normalise-input-single.browser.js" + "./errors": { + "types": "./src/errors.d.ts", + "import": "./src/errors.js" }, - "./files/normalise-input-multiple": { - "import": "./src/files/normalise-input-multiple.js" + "./files/format-mode": { + "types": "./src/files/format-mode.d.ts", + "import": "./src/files/format-mode.js" }, - "./files/normalise-input-multiple.browser": { - "import": "./src/files/normalise-input-multiple.browser.js" + "./files/format-mtime": { + "types": "./src/files/format-mtime.d.ts", + "import": "./src/files/format-mtime.js" }, "./files/normalise-content": { + "types": "./src/files/normalise-content.d.ts", "import": "./src/files/normalise-content.js" }, "./files/normalise-content.browser": { + "types": "./src/files/normalise-content.browser.d.ts", "import": "./src/files/normalise-content.browser.js" }, - "./files/format-mode": { - "import": "./src/files/format-mode.js" + "./files/normalise-input-multiple": { + "types": "./src/files/normalise-input-multiple.d.ts", + "import": "./src/files/normalise-input-multiple.js" }, - "./files/format-mtime": { - "import": "./src/files/format-mtime.js" + "./files/normalise-input-multiple.browser": { + "types": "./src/files/normalise-input-multiple.browser.d.ts", + "import": "./src/files/normalise-input-multiple.browser.js" }, - "./pins/normalise-input": { - "import": "./src/pins/normalise-input.js" + "./files/normalise-input-single": { + "types": "./src/files/normalise-input-single.d.ts", + "import": "./src/files/normalise-input-single.js" }, - "./errors": { - "import": "./src/errors.js" + "./files/normalise-input-single.browser": { + "types": "./src/files/normalise-input-single.browser.d.ts", + "import": "./src/files/normalise-input-single.browser.js" }, "./multibases": { + "types": "./src/multibases.d.ts", "import": "./src/multibases.js" }, "./multicodecs": { + "types": "./src/multicodecs.d.ts", "import": "./src/multicodecs.js" }, "./multihashes": { + "types": "./src/multihashes.d.ts", "import": "./src/multihashes.js" }, + "./multipart-request": { + "types": "./src/multipart-request.d.ts", + "browser": "./src/multipart-request.browser.js", + "import": "./src/multipart-request.js" + }, + "./pins/normalise-input": { + "types": "./src/pins/normalise-input.d.ts", + "import": "./src/pins/normalise-input.js" + }, "./to-cid-and-path": { + "types": "./src/to-cid-and-path.d.ts", "import": "./src/to-cid-and-path.js" }, "./to-url-string": { + "types": "./src/to-url-string.d.ts", "import": "./src/to-url-string.js" }, "./with-timeout-option": { + "types": "./src/with-timeout-option.d.ts", "import": "./src/with-timeout-option.js" - }, - "./agent": { - "browser": "./src/agent.browser.js", - "import": "./src/agent.js" - }, - "./multipart-request": { - "browser": "./src/multipart-request.browser.js", - "import": "./src/multipart-request.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "test": "aegir test", @@ -113,25 +139,24 @@ "dep-check": "aegir dep-check -i ipfs-core-types", "build": "aegir build" }, - "license": "MIT", "dependencies": { - "@libp2p/logger": "^1.1.4", - "@multiformats/multiaddr": "^10.0.0", + "@libp2p/logger": "^2.0.0", + "@multiformats/multiaddr": "^10.1.8", "@multiformats/multiaddr-to-uri": "^9.0.1", "any-signal": "^3.0.0", "blob-to-it": "^1.0.1", "browser-readablestream-to-it": "^1.0.1", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-unixfs": "^6.0.9", + "ipfs-core-types": "^0.11.0", + "ipfs-unixfs": "^7.0.0", "ipfs-utils": "^9.0.6", "it-all": "^1.0.4", - "it-map": "^1.0.4", + "it-map": "^1.0.6", "it-peekable": "^1.0.2", "it-to-stream": "^1.0.0", "merge-options": "^3.0.4", "multiformats": "^9.5.1", - "nanoid": "^3.1.23", + "nanoid": "^4.0.0", "parse-duration": "^1.0.0", "timeout-abort-controller": "^3.0.0", "uint8arrays": "^3.0.0" diff --git a/packages/ipfs-core/LICENSE b/packages/ipfs-core/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-core/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-core/LICENSE-MIT b/packages/ipfs-core/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-core/LICENSE-MIT +++ b/packages/ipfs-core/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-core/README.md b/packages/ipfs-core/README.md index bf5157353e..d690536b65 100644 --- a/packages/ipfs-core/README.md +++ b/packages/ipfs-core/README.md @@ -1,3 +1,31 @@ +# ipfs-core + +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> JavaScript implementation of the IPFS specification + +## Table of contents + +- - [Install](#install) +- [ipfs-core ](#ipfs-core----omit-in-toc---) + - [Getting Started](#getting-started) + - [Next Steps](#next-steps) + - [Browser CDN](#browser-cdn) + - [Browser bundle](#browser-bundle) + - [Want to hack on IPFS?](#want-to-hack-on-ipfs) + - [License](#license) + - [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-core +``` +

IPFS in JavaScript logo @@ -22,21 +50,10 @@ # ipfs-core -> The IPFS Core API - `ipfs-core` is the implementation of the IPFS Core API written in JavaScript without depending on other languages/implementations. It contains all you need to integrate IPFS into your application. If you want to run IPFS as a standalone daemon process, see the [ipfs](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs) module. -## Table of Contents - -- [Getting Started](#getting-started) -- [Next Steps](#next-steps) - - [Browser CDN](#browser-cdn) - - [Browser bundle](#browser-bundle) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) -- [License](#license) - ## Getting Started The `ipfs-core` package contains all the features of `ipfs` but in a lighter package without the CLI or HTTP servers: @@ -58,12 +75,12 @@ console.info(cid) ## Next Steps -* Look into the [js-ipfs-examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser -* Read the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node -* Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs -* Check out https://docs.ipfs.io for tips, how-tos and more -* See https://blog.ipfs.io for news and more -* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io +- Look into the [js-ipfs-examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser +- Read the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node +- Head over to to take interactive tutorials that cover core IPFS APIs +- Check out for tips, how-tos and more +- See for news and more +- Need help? Please ask 'How do I?' questions on ### Browser CDN @@ -104,15 +121,26 @@ Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of - **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge - **Perform code reviews** More eyes will help -a. speed the project along -b. ensure quality, and -c. reduce possible future bugs. + a. speed the project along + b. ensure quality, and + c. reduce possible future bugs. - **Add tests**. There can never be enough tests. -Find out about chat channels, the IPFS newsletter, the IPFS blog, and more in the [IPFS community space](https://docs.ipfs.io/community/). - ## License -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute -[![](https://github.com/ipfs/js-ipfs/raw/master/packages/interface-ipfs-core/img/badge.png)](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index be48530838..9fb745a48b 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -2,15 +2,24 @@ "name": "ipfs-core", "version": "0.15.4", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,27 +37,26 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./config/profiles": { + "types": "./src/components/config/profiles.d.ts", "import": "./src/components/config/profiles.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -63,69 +71,73 @@ "test:electron-main": "aegir test -t electron-main", "test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrappers.js", "clean": "aegir clean", - "dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types --i interface-blockstore" + "dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types --i interface-blockstore -i @libp2p/interface-dht -i @libp2p/interface-keys -i @libp2p/interface-transport -i @libp2p/interfaces" }, "dependencies": { - "@chainsafe/libp2p-noise": "^6.0.1", - "@ipld/car": "^4.0.0", + "@chainsafe/libp2p-noise": "^8.0.0", + "@ipld/car": "^4.1.0", "@ipld/dag-cbor": "^7.0.0", "@ipld/dag-json": "^8.0.1", "@ipld/dag-pb": "^2.1.3", - "@libp2p/bootstrap": "^1.0.2", - "@libp2p/crypto": "^0.22.9", - "@libp2p/delegated-content-routing": "^1.0.3", - "@libp2p/delegated-peer-routing": "^1.0.3", - "@libp2p/interfaces": "^2.0.4", - "@libp2p/kad-dht": "^1.0.3", - "@libp2p/logger": "^1.1.4", - "@libp2p/mplex": "^1.0.5", + "@libp2p/bootstrap": "^2.0.0", + "@libp2p/crypto": "^1.0.0", + "@libp2p/delegated-content-routing": "^2.0.1", + "@libp2p/delegated-peer-routing": "^2.0.1", + "@libp2p/interface-dht": "^1.0.1", + "@libp2p/interface-keys": "^1.0.3", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-transport": "^1.0.2", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/kad-dht": "^3.0.0", + "@libp2p/logger": "^2.0.0", + "@libp2p/mplex": "^5.0.0", "@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id-factory": "^1.0.10", - "@libp2p/record": "^1.0.1", - "@libp2p/websockets": "^1.0.8", + "@libp2p/record": "^2.0.0", + "@libp2p/websockets": "^3.0.0", "@multiformats/mafmt": "^11.0.2", "@multiformats/multiaddr": "^10.1.8", "@multiformats/multiaddr-to-uri": "^9.0.1", "@multiformats/murmur3": "^1.1.1", "any-signal": "^3.0.0", "array-shuffle": "^3.0.0", - "blockstore-core": "^1.0.2", - "dag-jose": "^1.0.0", - "datastore-core": "^7.0.0", - "datastore-pubsub": "^3.0.0", + "blockstore-core": "^2.0.1", + "dag-jose": "^2.0.1", + "datastore-core": "^8.0.1", + "datastore-pubsub": "^4.0.2", "dlv": "^1.1.3", "err-code": "^3.0.1", - "hamt-sharding": "^2.0.1", + "hamt-sharding": "^3.0.0", "hashlru": "^2.3.0", - "interface-blockstore": "^2.0.3", - "interface-datastore": "^6.1.1", - "ipfs-bitswap": "^11.0.0", - "ipfs-core-config": "^0.4.1", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-http-client": "^57.0.3", - "ipfs-repo": "^14.0.1", - "ipfs-unixfs": "^6.0.9", - "ipfs-unixfs-exporter": "^7.0.11", - "ipfs-unixfs-importer": "^9.0.10", + "interface-blockstore": "^3.0.0", + "interface-datastore": "^7.0.0", + "ipfs-bitswap": "^12.0.3", + "ipfs-core-config": "^0.4.0", + "ipfs-core-types": "^0.11.0", + "ipfs-core-utils": "^0.15.0", + "ipfs-http-client": "^57.0.0", + "ipfs-repo": "^15.0.0", + "ipfs-unixfs": "^7.0.0", + "ipfs-unixfs-exporter": "^8.0.4", + "ipfs-unixfs-importer": "^10.0.1", "ipfs-utils": "^9.0.6", - "ipns": "^1.0.0", + "ipns": "^2.0.2", "is-domain-name": "^1.0.1", "is-ipfs": "^6.0.1", "it-drain": "^1.0.3", "it-filter": "^1.0.2", - "it-first": "^1.0.4", + "it-first": "^1.0.6", "it-last": "^1.0.4", - "it-map": "^1.0.4", - "it-merge": "^1.0.2", + "it-map": "^1.0.6", + "it-merge": "^1.0.3", "it-parallel": "^2.0.1", "it-peekable": "^1.0.2", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "it-tar": "^5.0.0", + "it-pushable": "^3.0.0", + "it-tar": "^6.0.0", "it-to-buffer": "^2.0.0", "just-safe-set": "^4.0.2", - "libp2p": "^0.37.1", + "libp2p": "^0.38.0", "merge-options": "^3.0.4", "mortice": "^3.0.0", "multiformats": "^9.5.1", @@ -135,20 +147,20 @@ "uint8arrays": "^3.0.0" }, "devDependencies": { - "@chainsafe/libp2p-gossipsub": "^1.0.0", + "@chainsafe/libp2p-gossipsub": "^4.0.0", "@types/dlv": "^1.1.2", - "@types/pako": "^1.0.2", + "@types/pako": "^2.0.0", "@types/rimraf": "^3.0.1", "aegir": "^37.0.11", - "blockstore-datastore-adapter": "^2.0.2", + "blockstore-datastore-adapter": "^3.0.0", "delay": "^5.0.0", "go-ipfs": "^0.12.1", - "interface-blockstore-tests": "^2.0.4", - "interface-ipfs-core": "^0.155.2", - "ipfsd-ctl": "^11.0.0", + "interface-blockstore-tests": "^3.0.0", + "interface-ipfs-core": "^0.155.0", + "ipfsd-ctl": "^12.0.0", "iso-url": "^1.0.0", "it-all": "^1.0.4", - "nanoid": "^3.1.23", + "nanoid": "^4.0.0", "p-defer": "^4.0.0", "rimraf": "^3.0.2", "sinon": "^14.0.0" diff --git a/packages/ipfs-core/src/block-storage.js b/packages/ipfs-core/src/block-storage.js index 19f93999db..f1adccc2ad 100644 --- a/packages/ipfs-core/src/block-storage.js +++ b/packages/ipfs-core/src/block-storage.js @@ -102,8 +102,8 @@ export class BlockStorage extends BaseBlockstore { * @param {AbortOptions} [options] */ async * getMany (cids, options = {}) { - const getFromBitswap = pushable() - const getFromChild = pushable() + const getFromBitswap = pushable({ objectMode: true }) + const getFromChild = pushable({ objectMode: true }) Promise.resolve().then(async () => { for await (const cid of cids) { diff --git a/packages/ipfs-core/src/components/bitswap/index.js b/packages/ipfs-core/src/components/bitswap/index.js index 75e07f045e..348ec28351 100644 --- a/packages/ipfs-core/src/components/bitswap/index.js +++ b/packages/ipfs-core/src/components/bitswap/index.js @@ -5,7 +5,7 @@ import { createStat } from './stat.js' /** * @typedef {import('../../types').NetworkService} NetworkService - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId * @typedef {import('multiformats/cid').CID} CID * @typedef {import('ipfs-core-types/src/utils').AbortOptions} AbortOptions */ diff --git a/packages/ipfs-core/src/components/dht.js b/packages/ipfs-core/src/components/dht.js index 97add61092..d4954b444b 100644 --- a/packages/ipfs-core/src/components/dht.js +++ b/packages/ipfs-core/src/components/dht.js @@ -9,9 +9,9 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { peerIdFromString } from '@libp2p/peer-id' /** - * @typedef {import('@libp2p/interfaces/dht').QueryEvent} QueryEvent + * @typedef {import('@libp2p/interface-dht').QueryEvent} QueryEvent * @typedef {import('./network').Network} Network - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ const IPNS_PREFIX = '/ipns/' @@ -98,7 +98,7 @@ export function createDht ({ network, repo, peerId }) { throw errCode(new Error('dht not configured'), 'ERR_DHT_NOT_CONFIGURED') } - yield * libp2p.dht.put(dhtKey, value) + yield * libp2p.dht.put(dhtKey, value, options) }, /** diff --git a/packages/ipfs-core/src/components/id.js b/packages/ipfs-core/src/components/id.js index 2dc32c7df5..f1d89d859a 100644 --- a/packages/ipfs-core/src/components/id.js +++ b/packages/ipfs-core/src/components/id.js @@ -11,12 +11,12 @@ const log = logger('ipfs:components:id') /** * @typedef {import('libp2p').Libp2p} Libp2p * @typedef {import('ipfs-core-types/src/utils').AbortOptions} AbortOptions - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** * @param {object} config - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('../types').NetworkService} config.network */ export function createId ({ peerId, network }) { diff --git a/packages/ipfs-core/src/components/index.js b/packages/ipfs-core/src/components/index.js index 2bba834e65..e3df15d948 100644 --- a/packages/ipfs-core/src/components/index.js +++ b/packages/ipfs-core/src/components/index.js @@ -12,6 +12,7 @@ import { bases, hashes, codecs } from 'multiformats/basics' import { initAssets } from 'ipfs-core-config/init-assets' import { AlreadyInitializedError } from '../errors.js' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' +import { TimeoutController } from 'timeout-abort-controller' import { createStart } from './start.js' import { createStop } from './stop.js' @@ -52,6 +53,8 @@ import { Multibases } from 'ipfs-core-utils/multibases' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) const log = logger('ipfs') +const IPNS_INIT_KEYSPACE_TIMEOUT = 30000 + /** * @typedef {import('../types').Options} Options * @typedef {import('../types').Print} Print @@ -331,7 +334,14 @@ export async function create (options = {}) { throw errCode(new Error('Public key missing'), 'ERR_MISSING_PUBLIC_KEY') } - await ipfs.ipns.initializeKeyspace(storage.peerId, uint8ArrayFromString(`/ipfs/${cid}`)) + const timeoutController = new TimeoutController(IPNS_INIT_KEYSPACE_TIMEOUT) + try { + await ipfs.ipns.initializeKeyspace(storage.peerId, uint8ArrayFromString(`/ipfs/${cid}`), { + signal: timeoutController.signal + }) + } finally { + timeoutController.clear() + } } if (options.start !== false) { diff --git a/packages/ipfs-core/src/components/ipns.js b/packages/ipfs-core/src/components/ipns.js index 54c3b364ae..0d542fc524 100644 --- a/packages/ipfs-core/src/components/ipns.js +++ b/packages/ipfs-core/src/components/ipns.js @@ -7,7 +7,8 @@ import { logger } from '@libp2p/logger' const log = logger('ipfs:components:ipns') /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions * * @typedef {object} ExperimentalOptions * @property {boolean} [ipnsPubsub] @@ -59,8 +60,8 @@ export class IPNSAPI { * * @param {object} config * @param {import('ipfs-repo').IPFSRepo} config.repo - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ startOffline ({ repo, peerId, keychain }) { if (this.offline != null) { @@ -79,8 +80,8 @@ export class IPNSAPI { * @param {object} config * @param {import('libp2p').Libp2p} config.libp2p * @param {import('ipfs-repo').IPFSRepo} config.repo - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ async startOnline ({ libp2p, repo, peerId, keychain }) { if (this.online != null) { @@ -106,15 +107,19 @@ export class IPNSAPI { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - publish (peerId, value, lifetime) { - return this.getIPNS().publish(peerId, value, lifetime) + publish (peerId, value, lifetime, options) { + return this.getIPNS().publish(peerId, value, lifetime, options) } /** * * @param {string} name - * @param {*} [options] + * @param {object} [options] + * @param {boolean} [options.nocache] + * @param {boolean} [options.recursive] + * @param {AbortSignal} [options.signal] */ resolve (name, options) { return this.getIPNS().resolve(name, options) @@ -123,8 +128,9 @@ export class IPNSAPI { /** * @param {PeerId} peerId * @param {Uint8Array} value + * @param {AbortOptions} [options] */ - initializeKeyspace (peerId, value) { - return this.getIPNS().initializeKeyspace(peerId, value) + initializeKeyspace (peerId, value, options) { + return this.getIPNS().initializeKeyspace(peerId, value, options) } } diff --git a/packages/ipfs-core/src/components/key/export.js b/packages/ipfs-core/src/components/key/export.js index 4e58e9861d..3bbdf66d50 100644 --- a/packages/ipfs-core/src/components/key/export.js +++ b/packages/ipfs-core/src/components/key/export.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createExport ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/gen.js b/packages/ipfs-core/src/components/key/gen.js index 8640fd7247..e8525da9b4 100644 --- a/packages/ipfs-core/src/components/key/gen.js +++ b/packages/ipfs-core/src/components/key/gen.js @@ -5,7 +5,7 @@ const DEFAULT_KEY_SIZE = 2048 /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createGen ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/import.js b/packages/ipfs-core/src/components/key/import.js index 0a5711ea40..c73b84cb3c 100644 --- a/packages/ipfs-core/src/components/key/import.js +++ b/packages/ipfs-core/src/components/key/import.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createImport ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/index.js b/packages/ipfs-core/src/components/key/index.js index c34521e838..12383d3f3d 100644 --- a/packages/ipfs-core/src/components/key/index.js +++ b/packages/ipfs-core/src/components/key/index.js @@ -7,7 +7,7 @@ import { createRename } from './rename.js' import { createRm } from './rm.js' /** - * @typedef {import('@libp2p/interfaces/keychain').KeyChain} Keychain + * @typedef {import('@libp2p/interface-keychain').KeyChain} Keychain */ export class KeyAPI { diff --git a/packages/ipfs-core/src/components/key/info.js b/packages/ipfs-core/src/components/key/info.js index 0059eca793..8e4c7fd670 100644 --- a/packages/ipfs-core/src/components/key/info.js +++ b/packages/ipfs-core/src/components/key/info.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createInfo ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/list.js b/packages/ipfs-core/src/components/key/list.js index c7f6af6af0..cfee62a7a3 100644 --- a/packages/ipfs-core/src/components/key/list.js +++ b/packages/ipfs-core/src/components/key/list.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createList ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/rename.js b/packages/ipfs-core/src/components/key/rename.js index 71ebef6d8f..98ffe84c03 100644 --- a/packages/ipfs-core/src/components/key/rename.js +++ b/packages/ipfs-core/src/components/key/rename.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createRename ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/rm.js b/packages/ipfs-core/src/components/key/rm.js index 087eaaf2a8..3dd55e38c7 100644 --- a/packages/ipfs-core/src/components/key/rm.js +++ b/packages/ipfs-core/src/components/key/rm.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createRm ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index fa2d4f0d7a..ed38d78dd6 100644 --- a/packages/ipfs-core/src/components/libp2p.js +++ b/packages/ipfs-core/src/components/libp2p.js @@ -15,7 +15,7 @@ import { ipnsValidator } from 'ipns/validator' import { ipnsSelector } from 'ipns/selector' import { WebSockets } from '@libp2p/websockets' import { Mplex } from '@libp2p/mplex' -import { NOISE } from '@chainsafe/libp2p-noise' +import { Noise } from '@chainsafe/libp2p-noise' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true, concatArrays: true }) @@ -31,7 +31,7 @@ const mergeOptions = mergeOpts.bind({ ignoreUndefined: true, concatArrays: true * @property {DekOptions} [dek] * * @typedef {import('ipfs-repo').IPFSRepo} Repo - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId * @typedef {import('../types').Options} IPFSOptions * @typedef {import('libp2p').Libp2p} LibP2P * @typedef {import('libp2p').Libp2pOptions} Libp2pOptions @@ -125,12 +125,12 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, transports: [], streamMuxers: [ new Mplex({ - // temporary fix until we can limit streams on a per-protocol basis - maxStreamsPerConnection: Infinity + maxInboundStreams: 256, + maxOutboundStreams: 1024 }) ], connectionEncryption: [ - NOISE + new Noise() ], relay: { enabled: get(options, 'relay.enabled', get(config, 'relay.enabled', true)), diff --git a/packages/ipfs-core/src/components/name/index.js b/packages/ipfs-core/src/components/name/index.js index 7e998e01f8..b4fdd65a58 100644 --- a/packages/ipfs-core/src/components/name/index.js +++ b/packages/ipfs-core/src/components/name/index.js @@ -6,12 +6,12 @@ export class NameAPI { /** * @param {object} config * @param {import('../ipns').IPNSAPI} config.ipns - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('../../types').Options} config.options * @param {import('ipfs-repo').IPFSRepo} config.repo * @param {import('ipfs-core-utils/multicodecs').Multicodecs} config.codecs * @param {import('ipfs-core-types/src/root').API<{}>["isOnline"]} config.isOnline - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain * @param {import('ipfs-core-types/src/root').API<{}>["dns"]} config.dns */ constructor ({ dns, ipns, repo, codecs, peerId, isOnline, keychain, options }) { diff --git a/packages/ipfs-core/src/components/name/publish.js b/packages/ipfs-core/src/components/name/publish.js index be940978be..1a62727490 100644 --- a/packages/ipfs-core/src/components/name/publish.js +++ b/packages/ipfs-core/src/components/name/publish.js @@ -18,16 +18,16 @@ const log = logger('ipfs:name:publish') * @param {import('../ipns').IPNSAPI} config.ipns * @param {import('ipfs-repo').IPFSRepo} config.repo * @param {import('ipfs-core-utils/multicodecs').Multicodecs} config.codecs - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('ipfs-core-types/src/root').API<{}>["isOnline"]} config.isOnline - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createPublish ({ ipns, repo, codecs, peerId, isOnline, keychain }) { /** * @param {string} keyName */ const lookupKey = async keyName => { - /** @type {import('@libp2p/interfaces/keys').PrivateKey} */ + /** @type {import('@libp2p/interface-keys').PrivateKey} */ let privateKey if (keyName === 'self' && peerId.privateKey != null) { @@ -89,7 +89,7 @@ export function createPublish ({ ipns, repo, codecs, peerId, isOnline, keychain const bytes = uint8ArrayFromString(value) // Start publishing process - const result = await ipns.publish(results[0], bytes, pubLifetime) + const result = await ipns.publish(results[0], bytes, pubLifetime, options) return { name: result.name, diff --git a/packages/ipfs-core/src/components/network.js b/packages/ipfs-core/src/components/network.js index ab473caaee..b2f0f44a57 100644 --- a/packages/ipfs-core/src/components/network.js +++ b/packages/ipfs-core/src/components/network.js @@ -22,7 +22,7 @@ import { BlockStorage } from '../block-storage.js' * @typedef {import('../types').Print} Print * @typedef {import('libp2p').Libp2p} libp2p * @typedef {import('ipfs-bitswap').IPFSBitswap} Bitswap - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId * @typedef {import('ipfs-core-types/src/utils').AbortOptions} AbortOptions */ @@ -76,7 +76,9 @@ export class Network { const bitswap = createBitswap(libp2p, repo.blocks, { statsEnabled: true, - hashLoader: hashers + hashLoader: hashers, + maxInboundStreams: 1024, + maxOutboundStreams: 1024 }) await bitswap.start() diff --git a/packages/ipfs-core/src/components/pubsub.js b/packages/ipfs-core/src/components/pubsub.js index 4f584e63aa..145af80186 100644 --- a/packages/ipfs-core/src/components/pubsub.js +++ b/packages/ipfs-core/src/components/pubsub.js @@ -4,7 +4,7 @@ import { NotEnabledError } from '../errors.js' import get from 'dlv' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler>} EventHandler * @typedef {import('@libp2p/interfaces/events').EventHandler} MessageEventHandler */ diff --git a/packages/ipfs-core/src/components/start.js b/packages/ipfs-core/src/components/start.js index cab8c111cf..cdae78c1a3 100644 --- a/packages/ipfs-core/src/components/start.js +++ b/packages/ipfs-core/src/components/start.js @@ -3,13 +3,13 @@ import { Service } from '../utils/service.js' /** * @param {object} config * @param {import('../types').NetworkService} config.network - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('ipfs-repo').IPFSRepo} config.repo * @param {import('../types').Print} config.print * @param {import('../types').Preload} config.preload * @param {import('../types').MfsPreload} config.mfsPreload * @param {import('./ipns').IPNSAPI} config.ipns - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain * @param {import('ipfs-core-utils/multihashes').Multihashes} config.hashers * @param {import('../types').Options} config.options */ diff --git a/packages/ipfs-core/src/components/storage.js b/packages/ipfs-core/src/components/storage.js index d30006448f..8f7eff57b7 100644 --- a/packages/ipfs-core/src/components/storage.js +++ b/packages/ipfs-core/src/components/storage.js @@ -4,7 +4,7 @@ import getDefaultConfig from 'ipfs-core-config/config' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { peerIdFromKeys } from '@libp2p/peer-id' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import mergeOpts from 'merge-options' import { profiles as configProfiles } from './config/profiles.js' import { NotEnabledError, NotInitializedError } from '../errors.js' @@ -24,8 +24,8 @@ const log = logger('ipfs:components:peer:storage') * @typedef {import('../types').Print} Print * @typedef {import('ipfs-core-types/src/config').Config} IPFSConfig * @typedef {import('@libp2p/crypto/keys').KeyTypes} KeyType - * @typedef {import('@libp2p/interfaces/keychain').KeyChain} Keychain - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-keychain').KeyChain} Keychain + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ export class Storage { diff --git a/packages/ipfs-core/src/ipns/index.js b/packages/ipfs-core/src/ipns/index.js index c851cd0d0a..aa43a14086 100644 --- a/packages/ipfs-core/src/ipns/index.js +++ b/packages/ipfs-core/src/ipns/index.js @@ -10,8 +10,9 @@ const log = logger('ipfs:ipns') const defaultRecordTtl = 60 * 1000 /** - * @typedef {import('@libp2p/interfaces/keys').PrivateKey} PrivateKey - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-keys').PrivateKey} PrivateKey + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ export class IPNS { @@ -19,7 +20,7 @@ export class IPNS { * @param {import('ipfs-core-types/src/utils').BufferStore} routing * @param {import('interface-datastore').Datastore} datastore * @param {PeerId} peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} keychain + * @param {import('@libp2p/interface-keychain').KeyChain} keychain * @param {object} options * @param {string} options.pass * @param {number} [options.initialBroadcastInterval] @@ -39,10 +40,11 @@ export class IPNS { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - async publish (peerId, value, lifetime = IpnsPublisher.defaultRecordLifetime) { + async publish (peerId, value, lifetime = IpnsPublisher.defaultRecordLifetime, options) { try { - await this.publisher.publishWithEOL(peerId, value, lifetime) + await this.publisher.publishWithEOL(peerId, value, lifetime, options) log(`IPNS value ${uint8ArrayToString(value, 'base32')} was published correctly`) @@ -74,6 +76,7 @@ export class IPNS { * @param {object} options * @param {boolean} [options.nocache] * @param {boolean} [options.recursive] + * @param {AbortSignal} [options.signal] */ async resolve (name, options = {}) { if (typeof name !== 'string') { @@ -111,8 +114,9 @@ export class IPNS { * * @param {PeerId} peerId * @param {Uint8Array} value + * @param {AbortOptions} [options] */ - async initializeKeyspace (peerId, value) { // eslint-disable-line require-await - return this.publish(peerId, value, IpnsPublisher.defaultRecordLifetime) + async initializeKeyspace (peerId, value, options) { // eslint-disable-line require-await + return this.publish(peerId, value, IpnsPublisher.defaultRecordLifetime, options) } } diff --git a/packages/ipfs-core/src/ipns/publisher.js b/packages/ipfs-core/src/ipns/publisher.js index 64706cf92b..eb66b1e525 100644 --- a/packages/ipfs-core/src/ipns/publisher.js +++ b/packages/ipfs-core/src/ipns/publisher.js @@ -1,4 +1,4 @@ -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import { notFoundError } from 'datastore-core/errors' import errcode from 'err-code' import { logger } from '@libp2p/logger' @@ -9,10 +9,11 @@ import * as ipns from 'ipns' const log = logger('ipfs:ipns:publisher') /** - * @typedef {import('@libp2p/interfaces/keys').PrivateKey} PrivateKey - * @typedef {import('@libp2p/interfaces/keys').PublicKey} PublicKey + * @typedef {import('@libp2p/interface-keys').PrivateKey} PrivateKey + * @typedef {import('@libp2p/interface-keys').PublicKey} PublicKey * @typedef {import('ipns').IPNSEntry} IPNSEntry - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ const ERR_NOT_FOUND = notFoundError().code @@ -35,11 +36,12 @@ export class IpnsPublisher { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - async publishWithEOL (peerId, value, lifetime) { - const record = await this._updateOrCreateRecord(peerId, value, lifetime) + async publishWithEOL (peerId, value, lifetime, options) { + const record = await this._updateOrCreateRecord(peerId, value, lifetime, options) - return this._putRecordToRouting(record, peerId) + return this._putRecordToRouting(record, peerId, options) } /** @@ -47,16 +49,18 @@ export class IpnsPublisher { * * @param {PeerId} peerId * @param {Uint8Array} value + * @param {AbortOptions} options */ - publish (peerId, value) { - return this.publishWithEOL(peerId, value, defaultRecordLifetime) + publish (peerId, value, options) { + return this.publishWithEOL(peerId, value, defaultRecordLifetime, options) } /** * @param {Uint8Array} record * @param {PeerId} peerId + * @param {AbortOptions} [options] */ - async _putRecordToRouting (record, peerId) { + async _putRecordToRouting (record, peerId, options) { if (!(isPeerId(peerId))) { const errMsg = 'peerId received is not valid' log.error(errMsg) @@ -70,7 +74,7 @@ export class IpnsPublisher { const routingKey = ipns.peerIdToRoutingKey(peerId) - await this._publishEntry(routingKey, record) + await this._publishEntry(routingKey, record, options) return record } @@ -78,11 +82,12 @@ export class IpnsPublisher { /** * @param {Uint8Array} key * @param {Uint8Array} entry + * @param {AbortOptions} [options] */ - async _publishEntry (key, entry) { + async _publishEntry (key, entry, options) { // Add record to routing (buffer key) try { - const res = await this._routing.put(key, entry) + const res = await this._routing.put(key, entry, options) log(`ipns record for ${uint8ArrayToString(key, 'base32')} was stored in the routing`) return res @@ -162,8 +167,9 @@ export class IpnsPublisher { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - async _updateOrCreateRecord (peerId, value, lifetime) { + async _updateOrCreateRecord (peerId, value, lifetime, options) { if (!(isPeerId(peerId))) { const errMsg = 'peerId received is not valid' log.error(errMsg) @@ -217,7 +223,7 @@ export class IpnsPublisher { const data = ipns.marshal(entryData) // Store the new record - await this._datastore.put(ipns.getLocalKey(peerId.toBytes()), data) + await this._datastore.put(ipns.getLocalKey(peerId.toBytes()), data, options) log(`ipns record for ${uint8ArrayToString(value, 'base32')} was stored in the datastore`) diff --git a/packages/ipfs-core/src/ipns/republisher.js b/packages/ipfs-core/src/ipns/republisher.js index a64162cea6..e9a1758b81 100644 --- a/packages/ipfs-core/src/ipns/republisher.js +++ b/packages/ipfs-core/src/ipns/republisher.js @@ -1,15 +1,17 @@ import * as ipns from 'ipns' import { importKey } from '@libp2p/crypto/keys' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import errcode from 'err-code' import { logger } from '@libp2p/logger' import { peerIdFromKeys } from '@libp2p/peer-id' +import { TimeoutController } from 'timeout-abort-controller' const log = logger('ipfs:ipns:republisher') /** - * @typedef {import('@libp2p/interfaces/keys').PrivateKey} PrivateKey - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-keys').PrivateKey} PrivateKey + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ const minute = 60 * 1000 @@ -23,7 +25,7 @@ export class IpnsRepublisher { * @param {import('./publisher').IpnsPublisher} publisher * @param {import('interface-datastore').Datastore} datastore * @param {PeerId} peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} keychain + * @param {import('@libp2p/interface-keychain').KeyChain} keychain * @param {object} options * @param {string} options.pass * @param {number} [options.initialBroadcastInterval] @@ -87,7 +89,17 @@ export class IpnsRepublisher { const { pass } = this._options let firstRun = true - republishHandle._task = () => this._republishEntries(this._peerId, pass) + republishHandle._task = async () => { + const timeoutController = new TimeoutController(30000) + + try { + await this._republishEntries(this._peerId, pass, { + signal: timeoutController.signal + }) + } finally { + timeoutController.clear() + } + } republishHandle.runPeriodically(() => { if (firstRun) { @@ -116,12 +128,13 @@ export class IpnsRepublisher { /** * @param {PeerId} peerId * @param {string} pass + * @param {AbortOptions} options */ - async _republishEntries (peerId, pass) { + async _republishEntries (peerId, pass, options) { // TODO: Should use list of published entries. // We can't currently *do* that because go uses this method for now. try { - await this._republishEntry(peerId) + await this._republishEntry(peerId, options) } catch (/** @type {any} */ err) { const errMsg = 'cannot republish entry for the node\'s private key' @@ -143,7 +156,7 @@ export class IpnsRepublisher { const privKey = await importKey(pem, pass) const peerIdKey = await peerIdFromKeys(privKey.public.bytes, privKey.bytes) - await this._republishEntry(peerIdKey) + await this._republishEntry(peerIdKey, options) } } catch (/** @type {any} */ err) { log.error(err) @@ -153,11 +166,12 @@ export class IpnsRepublisher { /** * @param {PeerId} peerId + * @param {AbortOptions} options */ - async _republishEntry (peerId) { + async _republishEntry (peerId, options) { try { const value = await this._getPreviousValue(peerId) - await this._publisher.publishWithEOL(peerId, value, defaultRecordLifetime) + await this._publisher.publishWithEOL(peerId, value, defaultRecordLifetime, options) } catch (/** @type {any} */ err) { if (err.code === 'ERR_NO_ENTRY_FOUND') { return diff --git a/packages/ipfs-core/src/ipns/resolver.js b/packages/ipfs-core/src/ipns/resolver.js index b06203b3a1..a0f3a4ff95 100644 --- a/packages/ipfs-core/src/ipns/resolver.js +++ b/packages/ipfs-core/src/ipns/resolver.js @@ -9,7 +9,8 @@ import * as Errors from 'datastore-core/errors' import { ipnsValidator } from 'ipns/validator' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ const log = logger('ipfs:ipns:resolver') @@ -28,8 +29,9 @@ export class IpnsResolver { /** * @param {string} name - * @param {object} options + * @param {object} [options] * @param {boolean} [options.recursive] + * @param {AbortSignal} [options.signal] */ async resolve (name, options = {}) { if (typeof name !== 'string') { @@ -53,7 +55,7 @@ export class IpnsResolver { depth = defaultMaximumRecursiveDepth } - const res = await this.resolver(key, depth) + const res = await this.resolver(key, depth, options) log(`${name} was locally resolved correctly`) return res @@ -64,9 +66,10 @@ export class IpnsResolver { * * @param {string} name * @param {number} depth + * @param {AbortOptions} options * @returns {Promise} */ - async resolver (name, depth) { + async resolver (name, depth, options) { // Exceeded recursive maximum depth if (depth === 0) { const errMsg = `could not resolve name (recursion limit of ${defaultMaximumRecursiveDepth} exceeded)` @@ -75,7 +78,7 @@ export class IpnsResolver { throw errcode(new Error(errMsg), 'ERR_RESOLVE_RECURSION_LIMIT') } - const res = await this._resolveName(name) + const res = await this._resolveName(name, options) const nameSegments = res.split('/') // If obtained a ipfs cid or recursive option is disabled @@ -84,21 +87,22 @@ export class IpnsResolver { } // continue recursively until depth equals 0 - return this.resolver(nameSegments[2], depth - 1) + return this.resolver(nameSegments[2], depth - 1, options) } /** * Resolve ipns entries from the provided routing * * @param {string} name + * @param {AbortOptions} options */ - async _resolveName (name) { + async _resolveName (name, options) { const peerId = peerIdFromString(name) const routingKey = ipns.peerIdToRoutingKey(peerId) let record try { - record = await this._routing.get(routingKey) + record = await this._routing.get(routingKey, options) } catch (/** @type {any} */ err) { log.error('could not get record from routing', err) diff --git a/packages/ipfs-core/src/ipns/routing/config.js b/packages/ipfs-core/src/ipns/routing/config.js index aabaf9b923..be4f1afa13 100644 --- a/packages/ipfs-core/src/ipns/routing/config.js +++ b/packages/ipfs-core/src/ipns/routing/config.js @@ -12,7 +12,7 @@ import { DHTDatastore } from './dht-datastore.js' * @param {object} arg * @param {import('libp2p').Libp2p} arg.libp2p * @param {import('ipfs-repo').IPFSRepo} arg.repo - * @param {import('@libp2p/interfaces/peer-id').PeerId} arg.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} arg.peerId * @param {object} arg.options */ export function createRouting ({ libp2p, repo, peerId, options }) { diff --git a/packages/ipfs-core/src/ipns/routing/dht-datastore.js b/packages/ipfs-core/src/ipns/routing/dht-datastore.js index e137d64c96..62b08eadff 100644 --- a/packages/ipfs-core/src/ipns/routing/dht-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/dht-datastore.js @@ -4,10 +4,14 @@ import { logger } from '@libp2p/logger' const log = logger('ipfs:ipns:dht-datastore') +/** + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions + */ + export class DHTDatastore { /** * - * @param {import('@libp2p/interfaces/dht').DHT} dht + * @param {import('@libp2p/interface-dht').DHT} dht */ constructor (dht) { this._dht = dht @@ -16,10 +20,11 @@ export class DHTDatastore { /** * @param {Uint8Array} key - identifier of the value. * @param {Uint8Array} value - value to be stored. + * @param {AbortOptions} [options] */ - async put (key, value) { + async put (key, value, options) { try { - await drain(this._dht.put(key, value)) + await drain(this._dht.put(key, value, options)) } catch (/** @type {any} */ err) { log.error(err) throw err @@ -28,9 +33,10 @@ export class DHTDatastore { /** * @param {Uint8Array} key - identifier of the value to be obtained. + * @param {AbortOptions} [options] */ - async get (key) { - for await (const event of this._dht.get(key)) { + async get (key, options) { + for await (const event of this._dht.get(key, options)) { if (event.name === 'VALUE') { return event.value } diff --git a/packages/ipfs-core/src/ipns/routing/offline-datastore.js b/packages/ipfs-core/src/ipns/routing/offline-datastore.js index 5ec0289e9d..bbc590b596 100644 --- a/packages/ipfs-core/src/ipns/routing/offline-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/offline-datastore.js @@ -6,6 +6,10 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string' const log = logger('ipfs:ipns:offline-datastore') +/** + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions + */ + // Offline datastore aims to mimic the same encoding as routing when storing records // to the local datastore export class OfflineDatastore { @@ -23,8 +27,9 @@ export class OfflineDatastore { * * @param {Uint8Array} key - identifier of the value. * @param {Uint8Array} value - value to be stored. + * @param {AbortOptions} [options] */ - async put (key, value) { // eslint-disable-line require-await + async put (key, value, options) { // eslint-disable-line require-await if (!(key instanceof Uint8Array)) { throw errcode(new Error('Offline datastore key must be a Uint8Array'), 'ERR_INVALID_KEY') } @@ -45,15 +50,16 @@ export class OfflineDatastore { // Marshal to libp2p record as the DHT does const record = new Libp2pRecord(key, value, new Date()) - await this._datastore.put(routingKey, record.serialize()) + await this._datastore.put(routingKey, record.serialize(), options) } /** * Get a value from the local datastore indexed by the received key properly encoded. * * @param {Uint8Array} key - identifier of the value to be obtained. + * @param {AbortOptions} [options] */ - async get (key) { + async get (key, options) { if (!(key instanceof Uint8Array)) { throw errcode(new Error('Offline datastore key must be a Uint8Array'), 'ERR_INVALID_KEY') } @@ -67,7 +73,7 @@ export class OfflineDatastore { throw errcode(new Error('Not possible to generate the routing key'), 'ERR_GENERATING_ROUTING_KEY') } - const res = await this._datastore.get(routingKey) + const res = await this._datastore.get(routingKey, options) // Unmarshal libp2p record as the DHT does let record diff --git a/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js b/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js index 2eb4999e44..e796cd6f91 100644 --- a/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js @@ -11,12 +11,16 @@ import { peerIdFromString } from '@libp2p/peer-id' const log = logger('ipfs:ipns:pubsub') +/** + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions + */ + // Pubsub datastore aims to manage the pubsub subscriptions for IPNS export class IpnsPubsubDatastore { /** - * @param {import('@libp2p/interfaces/pubsub').PubSub} pubsub + * @param {import('@libp2p/interface-pubsub').PubSub} pubsub * @param {import('interface-datastore').Datastore} localDatastore - * @param {import('@libp2p/interfaces/peer-id').PeerId} peerId + * @param {import('@libp2p/interface-peer-id').PeerId} peerId */ constructor (pubsub, localDatastore, peerId) { /** @type {Record} */ @@ -33,10 +37,11 @@ export class IpnsPubsubDatastore { * * @param {Uint8Array} key - identifier of the value. * @param {Uint8Array} value - value to be stored. + * @param {AbortOptions} [options] */ - async put (key, value) { + async put (key, value, options) { try { - await this._pubsubDs.put(key, value) + await this._pubsubDs.put(key, value, options) } catch (/** @type {any} */ err) { log.error(err) throw err @@ -49,13 +54,14 @@ export class IpnsPubsubDatastore { * updated once new publishes occur. * * @param {Uint8Array} key - identifier of the value to be obtained. + * @param {AbortOptions} [options] */ - async get (key) { + async get (key, options) { let res let err try { - res = await this._pubsubDs.get(key) + res = await this._pubsubDs.get(key, options) } catch (/** @type {any} */ e) { err = e } diff --git a/packages/ipfs-core/src/types.ts b/packages/ipfs-core/src/types.ts index 9d09890a5e..6a02e5df69 100644 --- a/packages/ipfs-core/src/types.ts +++ b/packages/ipfs-core/src/types.ts @@ -1,14 +1,11 @@ -import type { KeyType } from '@libp2p/interfaces/keys' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { KeyType } from '@libp2p/interface-keys' +import type { PeerId } from '@libp2p/interface-peer-id' import type { Config as IPFSConfig } from 'ipfs-core-types/src/config' import type { Libp2p, Libp2pOptions } from 'libp2p' - import type { IPFSRepo } from 'ipfs-repo' import type { ProgressCallback as MigrationProgressCallback } from 'ipfs-repo-migrations' import type { Network, Options as NetworkOptions } from './components/network' - import type { Datastore } from 'interface-datastore' - import type { Service } from './utils/service' import type { CID } from 'multiformats/cid' import type { BlockCodec } from 'multiformats/codecs/interface' diff --git a/packages/ipfs-core/test/libp2p.spec.js b/packages/ipfs-core/test/libp2p.spec.js index 5bf4a6398b..2a926908d0 100644 --- a/packages/ipfs-core/test/libp2p.spec.js +++ b/packages/ipfs-core/test/libp2p.spec.js @@ -2,43 +2,14 @@ import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core/memory' -// import { createLibp2p } from 'libp2p' -// import { EventEmitter } from 'events' import { createLibp2p as libp2pComponent } from '../src/components/libp2p.js' -// import { NOISE as Crypto } from '@chainsafe/libp2p-noise' import { GossipSub } from '@chainsafe/libp2p-gossipsub' import { createEd25519PeerId } from '@libp2p/peer-id-factory' /** - * @type {import('@libp2p/interfaces/transport').Transport} + * @type {import('@libp2p/interface-transport').Transport} */ -/* -class DummyTransport { - get [Symbol.toStringTag] () { - return 'DummyTransport' - } - - filter () { - return [] - } -} - -class DummyDiscovery extends EventEmitter { - get [Symbol.toStringTag] () { - return 'DummyDiscovery' - } - - start () { - return Promise.resolve() - } - - stop () { - return Promise.resolve() - } -} -*/ - describe('libp2p customization', function () { // Provide some extra time for ci since we're starting libp2p nodes in each test this.timeout(25 * 1000) @@ -48,7 +19,7 @@ describe('libp2p customization', function () { */ let datastore /** - * @type {import('@libp2p/interfaces/peer-id').PeerId} + * @type {import('@libp2p/interface-peer-id').PeerId} */ let peerId /** @@ -88,131 +59,7 @@ describe('libp2p customization', function () { libp2p = null } }) - /* - describe('bundle', () => { - it('should allow for using a libp2p bundle', async () => { - libp2p = await libp2pComponent({ - options: { - libp2p: async (opts) => { - return createLibp2p({ - peerId: opts.peerId, - transports: [new DummyTransport()], - connectionEncryption: [Crypto], - relay: { enabled: false } - }) - } - }, - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig - }) - - await libp2p.start() - - expect(libp2p._config.peerDiscovery).to.eql({ autoDial: true }) - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports).to.have.length(1) - }) - - it('should pass libp2p options to libp2p bundle function', async () => { - libp2p = await libp2pComponent({ - options: { - libp2p: async (opts) => { - return createLibp2p({ - peerId: opts.peerId, - // @ts-expect-error DummyTransport is not complete implementation - modules: { transport: [DummyTransport], connEncryption: [Crypto] }, - config: { relay: { enabled: false } } - }) - } - }, - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig - }) - - await libp2p.start() - - expect(libp2p._config.peerDiscovery).to.eql({ autoDial: true }) - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports[0] instanceof DummyTransport).to.equal(true) - }) - }) - describe('options', () => { - it('should use options by default', async () => { - libp2p = await libp2pComponent({ - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig - }) - - await libp2p.start() - - expect(libp2p._config).to.deep.include({ - peerDiscovery: { - autoDial: true, - bootstrap: { - enabled: true, - list: [] - }, - mdns: { - enabled: false - }, - webRTCStar: { - enabled: false - } - }, - pubsub: { - enabled: true, - emitSelf: true - } - }) - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports).to.have.length(3) - }) - - it('should allow for overriding via options', async () => { - const annAddr = '/dns4/test.ipfs.io/tcp/443/wss' - - libp2p = await libp2pComponent({ - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig, - options: { - libp2p: { - transports: [new DummyTransport()], - peerDiscovery: [new DummyDiscovery()], - relay: { enabled: false }, - addresses: { - announce: [annAddr] - } - } - } - }) - - await libp2p.start() - - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports).to.have.length(1) - expect(transports[0] instanceof DummyTransport).to.be.true() - - const discoveries = Array.from(libp2p.discovery.values()) - expect(discoveries).to.have.length(1) - expect(discoveries[0] instanceof DummyDiscovery).to.be.true() - - expect(libp2p.getMultiaddrs().map(m => m.toString())).to.include(annAddr) - }) - }) -*/ describe('config', () => { it('should be able to specify Announce addresses', async () => { const annAddr = '/dns4/test.ipfs.io/tcp/443/wss' diff --git a/packages/ipfs-core/tsconfig.json b/packages/ipfs-core/tsconfig.json index cace6261fa..75c9db0632 100644 --- a/packages/ipfs-core/tsconfig.json +++ b/packages/ipfs-core/tsconfig.json @@ -10,6 +10,9 @@ "package.json" ], "references": [ + { + "path": "../interface-ipfs-core" + }, { "path": "../ipfs-core-config" }, diff --git a/packages/ipfs-daemon/LICENSE b/packages/ipfs-daemon/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-daemon/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-daemon/LICENSE-MIT b/packages/ipfs-daemon/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-daemon/LICENSE-MIT +++ b/packages/ipfs-daemon/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-daemon/README.md b/packages/ipfs-daemon/README.md index f15fbd16a4..bff80307a2 100644 --- a/packages/ipfs-daemon/README.md +++ b/packages/ipfs-daemon/README.md @@ -1,16 +1,24 @@ # ipfs-daemon -> The implementation of the js-IPFS daemon +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-daemon +``` ```console $ npm install -g ipfs @@ -18,23 +26,21 @@ $ npm install -g ipfs $ jsipfs daemon ``` -## Want to hack on IPFS? +## License -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +Licensed under either of -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +## Contribute -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -## License +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. + +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). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index 90564234ba..2c366511cb 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -2,22 +2,49 @@ "name": "ipfs-daemon", "version": "0.13.5", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-daemon#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-daemon#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,10 +54,6 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", @@ -40,16 +63,16 @@ "build": "aegir build --no-bundle" }, "dependencies": { - "@libp2p/logger": "^1.1.4", - "@libp2p/webrtc-star": "^1.0.6", + "@libp2p/logger": "^2.0.0", + "@libp2p/webrtc-star": "^3.0.0", "@mapbox/node-pre-gyp": "^1.0.5", - "ipfs-core": "^0.15.4", - "ipfs-core-types": "^0.11.1", - "ipfs-grpc-server": "^0.9.4", - "ipfs-http-gateway": "^0.10.4", - "ipfs-http-server": "^0.12.5", + "ipfs-core": "^0.15.0", + "ipfs-core-types": "^0.11.0", + "ipfs-grpc-server": "^0.9.0", + "ipfs-http-gateway": "^0.10.0", + "ipfs-http-server": "^0.12.0", "ipfs-utils": "^9.0.6", - "libp2p": "^0.37.1" + "libp2p": "^0.38.0" }, "devDependencies": { "aegir": "^37.0.11", diff --git a/packages/ipfs-grpc-client/LICENSE b/packages/ipfs-grpc-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-grpc-client/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-grpc-client/LICENSE-APACHE b/packages/ipfs-grpc-client/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-grpc-client/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-grpc-client/LICENSE-MIT b/packages/ipfs-grpc-client/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-grpc-client/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-grpc-client/README.md b/packages/ipfs-grpc-client/README.md index 6ba15bac9a..dc0af12833 100644 --- a/packages/ipfs-grpc-client/README.md +++ b/packages/ipfs-grpc-client/README.md @@ -1,6 +1,31 @@ -# ipfs-grpc-client +# ipfs-grpc-client -> A client for the [ipfs-grpc-server][] module +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> A client library for the IPFS gRPC API + +## Table of contents + +- [Install](#install) +- [Why?](#why) +- [API](#api) + - [`create([options])`](#createoptions) + - [Parameters](#parameters) + - [Options](#options) + - [Returns](#returns) + - [Example](#example) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-grpc-client +``` This module implements part of the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) using gRPC over websockets to achieve the bidirectional streaming necessary to have full duplex streams running in the browser. @@ -14,12 +39,6 @@ This limits what we can do in browsers in terms of the API, for example streamin 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 - -```console -$ npm install ipfs-grpc-client -``` - ## API ### `create([options])` @@ -32,15 +51,15 @@ None An optional object which may have the following keys: -| Name | Type | Default | Description | -| ---- | ---- | ------- | ----------- | -| url | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | +| Name | Type | Default | Description | +| ----- | -------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------- | +| 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) | ### Returns -| Type | Description | -| -------- | -------- | +| Type | Description | +| -------- | ------------------------- | | `object` | An instance of the client | ### Example @@ -55,4 +74,23 @@ const client = create({ const id = await client.id() ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + [ipfs-grpc-server]: https://www.npmjs.com/package/ipfs-grpc-server diff --git a/packages/ipfs-grpc-client/package.json b/packages/ipfs-grpc-client/package.json index d7ecd3d86d..a7e119a04e 100644 --- a/packages/ipfs-grpc-client/package.json +++ b/packages/ipfs-grpc-client/package.json @@ -2,22 +2,49 @@ "name": "ipfs-grpc-client", "version": "0.10.2", "description": "A client library for the IPFS gRPC API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,14 +54,6 @@ "sourceType": "module" } }, - "browser": { - "./src/grpc/transport.js": "./src/grpc/transport.browser.js", - "./src/grpc/transport.node.js": "./src/grpc/transport.browser.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test": "aegir test", @@ -46,31 +65,36 @@ "test:electron-main": "aegir test -t electron-main", "lint": "aegir lint", "clean": "aegir clean", - "dep-check": "aegir dep-check -i aegir -i ipfs-grpc-protocol -i ipfs-core-types" + "dep-check": "aegir dep-check -i aegir -i ipfs-grpc-protocol -i ipfs-core-types -i protobufjs-cli" }, "dependencies": { "@improbable-eng/grpc-web": "^0.15.0", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^10.1.8", "change-case": "^4.1.1", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", + "ipfs-core-types": "^0.11.0", + "ipfs-core-utils": "^0.15.0", "ipfs-grpc-protocol": "^0.6.0", - "ipfs-unixfs": "^6.0.9", - "it-first": "^1.0.4", - "it-pushable": "^2.0.1", - "@multiformats/multiaddr": "^10.0.0", + "ipfs-unixfs": "^7.0.0", + "it-first": "^1.0.6", + "it-pushable": "^3.0.0", "multiformats": "^9.5.1", "p-defer": "^4.0.0", - "protobufjs": "^6.10.2", + "protobufjs": "^7.0.0", "uint8arrays": "^3.0.0", - "wherearewe": "^1.0.0", + "wherearewe": "^2.0.1", "ws": "^8.5.0" }, "devDependencies": { "aegir": "^37.0.11", "it-all": "^1.0.4", + "protobufjs-cli": "^1.0.0", "sinon": "^14.0.0" + }, + "browser": { + "./src/grpc/transport.js": "./src/grpc/transport.browser.js", + "./src/grpc/transport.node.js": "./src/grpc/transport.browser.js" } } diff --git a/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js b/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js index 64ae7a820d..bbd3d0145f 100644 --- a/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js +++ b/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js @@ -36,12 +36,25 @@ export function grpcPubsubSubscribe (grpc, service, opts) { deferred.resolve() } else { - /** @type {import('@libp2p/interfaces/pubsub').Message} */ - const msg = { - from: peerIdFromString(result.from), - sequenceNumber: result.sequenceNumber == null ? undefined : BigInt(`0x${uint8ArrayToString(result.sequenceNumber, 'base16')}`), - data: result.data, - topic: result.topic + /** @type {import('@libp2p/interface-pubsub').Message} */ + let msg + + if (result.type === 'signed') { + msg = { + type: 'signed', + from: peerIdFromString(result.from), + sequenceNumber: BigInt(`0x${uint8ArrayToString(result.sequenceNumber, 'base16')}`), + data: result.data, + topic: result.topic, + key: result.key, + signature: result.signature + } + } else { + msg = { + type: 'unsigned', + data: result.data, + topic: result.topic + } } if (typeof handler === 'function') { diff --git a/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js b/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js index 7406f50d44..603552ac59 100644 --- a/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js +++ b/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js @@ -1,6 +1,6 @@ /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler} Subscription */ diff --git a/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js b/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js index 22e4129695..158879abd0 100644 --- a/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js +++ b/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js @@ -28,8 +28,8 @@ async function sendMessages (service, client, source) { * @returns {{ source: AsyncIterable, sink: import('it-pushable').Pushable }} **/ export function bidiToDuplex (grpc, service, options) { - const source = pushable() - const sink = pushable() + const source = pushable({ objectMode: true }) + const sink = pushable({ objectMode: true }) const client = grpc.client(service, { ...options, diff --git a/packages/ipfs-grpc-client/tsconfig.json b/packages/ipfs-grpc-client/tsconfig.json index c90cd3a743..e74bc8d2b1 100644 --- a/packages/ipfs-grpc-client/tsconfig.json +++ b/packages/ipfs-grpc-client/tsconfig.json @@ -13,6 +13,9 @@ }, { "path": "../ipfs-core-utils" + }, + { + "path": "../ipfs-grpc-protocol" } ] } diff --git a/packages/ipfs-grpc-protocol/LICENSE b/packages/ipfs-grpc-protocol/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-grpc-protocol/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-grpc-protocol/LICENSE-APACHE b/packages/ipfs-grpc-protocol/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-grpc-protocol/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-grpc-protocol/LICENSE-MIT b/packages/ipfs-grpc-protocol/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-grpc-protocol/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-grpc-protocol/README.md b/packages/ipfs-grpc-protocol/README.md index 75e7e478de..cb1a259a93 100644 --- a/packages/ipfs-grpc-protocol/README.md +++ b/packages/ipfs-grpc-protocol/README.md @@ -1,3 +1,40 @@ -# ipfs-grpc-protocol +# ipfs-grpc-protocol -Contains `.proto` files that define the IPFS gRPC interface. +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> Protobuf definitions for the IPFS gRPC API + +## Table of contents + +- [Install](#install) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-grpc-protocol +``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-grpc-protocol/package.json b/packages/ipfs-grpc-protocol/package.json index a7ee626678..ae6f522b58 100644 --- a/packages/ipfs-grpc-protocol/package.json +++ b/packages/ipfs-grpc-protocol/package.json @@ -2,34 +2,57 @@ "name": "ipfs-grpc-protocol", "version": "0.6.0", "description": "Protobuf definitions for the IPFS gRPC API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-protocol#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-protocol#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "clean": "aegir clean", @@ -39,6 +62,7 @@ "devDependencies": { "aegir": "^37.0.11", "mkdirp": "^1.0.4", - "protobufjs": "^6.10.2" + "protobufjs": "^7.0.0", + "protobufjs-cli": "^1.0.0" } } diff --git a/packages/ipfs-grpc-protocol/src/index.js b/packages/ipfs-grpc-protocol/src/index.js index 1886e5932c..5207bbfc9a 100644 --- a/packages/ipfs-grpc-protocol/src/index.js +++ b/packages/ipfs-grpc-protocol/src/index.js @@ -120,6 +120,18 @@ export default { topic: { type: 'string', id: 5 + }, + key: { + type: 'bytes', + id: 6 + }, + signature: { + type: 'bytes', + id: 7 + }, + type: { + type: 'string', + id: 8 } } }, diff --git a/packages/ipfs-grpc-protocol/src/pubsub.proto b/packages/ipfs-grpc-protocol/src/pubsub.proto index 438189ae63..5968aebdcc 100644 --- a/packages/ipfs-grpc-protocol/src/pubsub.proto +++ b/packages/ipfs-grpc-protocol/src/pubsub.proto @@ -19,6 +19,9 @@ message SubscribeResponse { bytes sequenceNumber = 3; bytes data = 4; string topic = 5; + bytes key = 6; + bytes signature = 7; + string type = 8; } message UnSubscribeRequest { diff --git a/packages/ipfs-grpc-server/LICENSE b/packages/ipfs-grpc-server/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-grpc-server/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-grpc-server/LICENSE-APACHE b/packages/ipfs-grpc-server/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-grpc-server/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-grpc-server/LICENSE-MIT b/packages/ipfs-grpc-server/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-grpc-server/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-grpc-server/README.md b/packages/ipfs-grpc-server/README.md index d2439f2f5c..8cf92e355b 100644 --- a/packages/ipfs-grpc-server/README.md +++ b/packages/ipfs-grpc-server/README.md @@ -1,6 +1,38 @@ -# ipfs-grpc-server - -> A gRPC server that runs over a websocket +# ipfs-grpc-server + +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> A server library for the IPFS gRPC API + +## Table of contents + +- [Install](#install) +- [Why?](#why) +- [Protocol](#protocol) + - [1. Metadata](#1-metadata) + - [2. Messages](#2-messages) + - [Signal](#signal) + - [Header](#header) + - [Message data](#message-data) + - [Trailer](#trailer) +- [Handlers](#handlers) + - [Metadata](#metadata) + - [Unary](#unary) + - [Server streaming](#server-streaming) + - [Client streaming](#client-streaming) + - [Bidirectional streaming](#bidirectional-streaming) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-grpc-server +``` ## Why? @@ -46,30 +78,30 @@ One ore more messages will be sent. Messages are sent as a single websocket mes Every message sent to or received from the server will have the following format: -| byte index | Notes | -|---|---| -| 0 | Signal | -| 1-5 | Header | -| n1-n2 | Message data | -| n3-n3+5 | Trailer +| byte index | Notes | +| ---------- | ------------ | +| 0 | Signal | +| 1-5 | Header | +| n1-n2 | Message data | +| n3-n3+5 | Trailer | #### Signal A one-byte field. -| Value | Meaning | -|---|---| -| 0 | START_SEND: Further messages will be sent as part of this context | -| 1 | FINISH_SEND: This is the final message, no further data will be sent | +| Value | Meaning | +| ----- | --------------------------------------------------------------------- | +| 0 | START\_SEND: Further messages will be sent as part of this context | +| 1 | FINISH\_SEND: This is the final message, no further data will be sent | #### Header A five-byte field that contains one byte signifying if it's a Header or a Trailer and four bytes that contain the length of the following data. -| byte index | Meaning | -|--------------|---| -| 0 | 0: This is a header, 128: This is a footer | -| 1-4 | An unsigned big-endian 32-bit integer that specifies the length of the message | +| byte index | Meaning | +| ---------- | ------------------------------------------------------------------------------ | +| 0 | 0: This is a header, 128: This is a footer | +| 1-4 | An unsigned big-endian 32-bit integer that specifies the length of the message | #### Message data @@ -79,10 +111,10 @@ A protocol buffer message, the length of which is defined in the header A five-byte field that contains one byte signifying if it's a Header or a Trailer and four bytes that contain the length of the following data. -| byte index | Meaning | -|--------------|---| -| 0 | 0: This is a header, 128: This is a footer | -| 1-4 | A big-endian 32-bit integer that specifies the length of the trailer | +| byte index | Meaning | +| ---------- | -------------------------------------------------------------------- | +| 0 | 0: This is a header, 128: This is a footer | +| 1-4 | A big-endian 32-bit integer that specifies the length of the trailer | The trailer contains [HTTP headers][] as a utf8 encoded string in the same way as invocation metadata. @@ -177,6 +209,27 @@ export function grpcFunction (ipfs, options = {}) { } ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + [HTTP headers]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers + [it-pushable]: https://www.npmjs.com/package/it-pushable + [AsyncIterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator diff --git a/packages/ipfs-grpc-server/package.json b/packages/ipfs-grpc-server/package.json index 5556a176f5..afba1fbfcb 100644 --- a/packages/ipfs-grpc-server/package.json +++ b/packages/ipfs-grpc-server/package.json @@ -2,22 +2,49 @@ "name": "ipfs-grpc-server", "version": "0.9.4", "description": "A server library for the IPFS gRPC API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-server#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-server#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,10 +54,6 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", @@ -41,27 +64,27 @@ }, "dependencies": { "@grpc/grpc-js": "^1.1.8", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^10.1.8", "change-case": "^4.1.1", "coercer": "^1.1.2", - "ipfs-core-types": "^0.11.1", + "ipfs-core-types": "^0.11.0", "ipfs-grpc-protocol": "^0.6.0", - "it-first": "^1.0.4", - "it-map": "^1.0.4", + "it-first": "^1.0.6", + "it-map": "^1.0.6", "it-peekable": "^1.0.2", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "@multiformats/multiaddr": "^10.0.0", - "nanoid": "^3.1.23", - "protobufjs": "^6.10.2", + "it-pushable": "^3.0.0", + "nanoid": "^4.0.0", + "protobufjs": "^7.0.0", "uint8arrays": "^3.0.0", "ws": "^8.5.0" }, "devDependencies": { "@types/ws": "^8.5.3", "aegir": "^37.0.11", - "ipfs-core": "^0.15.4", + "ipfs-core": "^0.15.0", "it-all": "^1.0.4", "it-drain": "^1.0.3", "sinon": "^14.0.0" diff --git a/packages/ipfs-grpc-server/src/endpoints/add.js b/packages/ipfs-grpc-server/src/endpoints/add.js index cfbc72e61b..fcfe9e99b6 100644 --- a/packages/ipfs-grpc-server/src/endpoints/add.js +++ b/packages/ipfs-grpc-server/src/endpoints/add.js @@ -26,7 +26,7 @@ export function grpcAdd (ipfs, options = {}) { await pipe( async function * toInput () { - const fileInputStream = pushable() + const fileInputStream = pushable({ objectMode: true }) setTimeout(async () => { const streams = [] diff --git a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js index 8ba85d0155..785dcb883f 100644 --- a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js +++ b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js @@ -3,7 +3,7 @@ import { nanoid } from 'nanoid' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ /** @@ -27,7 +27,7 @@ export function grpcPubsubSubscribe (ipfs, options = {}) { onMessage: (message) => { let sequenceNumber - if (message.sequenceNumber != null) { + if (message.type === 'signed' && message.sequenceNumber != null) { let numberString = message.sequenceNumber.toString(16) if (numberString.length % 2 !== 0) { diff --git a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js index 3b2a2a9559..4636ba4025 100644 --- a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js +++ b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js @@ -1,5 +1,5 @@ /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {object} Subscription * @property {import('@libp2p/interfaces/events').EventHandler} onMessage * @property {() => void} onUnsubscribe diff --git a/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js b/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js index d2ca764e96..fc89ac3be3 100644 --- a/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js +++ b/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js @@ -51,8 +51,8 @@ export class WebSocketMessageChannel { serialize: (message) => Buffer.from([]) } - this.source = pushable() - this.sink = pushable() + this.source = pushable({ objectMode: true }) + this.sink = pushable({ objectMode: true }) ws.on('message', (buf) => { if (!(buf instanceof Uint8Array)) { diff --git a/packages/ipfs-grpc-server/test/utils/channel.js b/packages/ipfs-grpc-server/test/utils/channel.js index 95463b2006..8ce3bf7d18 100644 --- a/packages/ipfs-grpc-server/test/utils/channel.js +++ b/packages/ipfs-grpc-server/test/utils/channel.js @@ -3,10 +3,10 @@ import { pushable } from 'it-pushable' class MessageChannel { constructor () { - this.source = pushable() - this.sink = pushable() + this.source = pushable({ objectMode: true }) + this.sink = pushable({ objectMode: true }) - this.clientSink = pushable() + this.clientSink = pushable({ objectMode: true }) } sendMetadata (metadata) { diff --git a/packages/ipfs-grpc-server/tsconfig.json b/packages/ipfs-grpc-server/tsconfig.json index 5b011ba049..1adae043f7 100644 --- a/packages/ipfs-grpc-server/tsconfig.json +++ b/packages/ipfs-grpc-server/tsconfig.json @@ -8,8 +8,14 @@ "src" ], "references": [ + { + "path": "../ipfs-core" + }, { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-grpc-protocol" } ] } diff --git a/packages/ipfs-http-client/LICENSE b/packages/ipfs-http-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-http-client/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-http-client/LICENSE-MIT b/packages/ipfs-http-client/LICENSE-MIT index 2b7661ee41..72dc60d84b 100644 --- a/packages/ipfs-http-client/LICENSE-MIT +++ b/packages/ipfs-http-client/LICENSE-MIT @@ -1,7 +1,5 @@ The MIT License (MIT) -Copyright (c) 2016 Protocol Labs, Inc. - 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 @@ -9,14 +7,13 @@ 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 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. - +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/ipfs-http-client/README.md b/packages/ipfs-http-client/README.md index 3f5a97697f..666171ca70 100644 --- a/packages/ipfs-http-client/README.md +++ b/packages/ipfs-http-client/README.md @@ -1,41 +1,20 @@ -

- IPFS http client lib logo -

+# ipfs-http-client -

The JavaScript HTTP RPC API client library for IPFS implementations.

+[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -

- - - - -

+> A client library for the IPFS HTTP API -

- - - - -
- - - - - - - -
-

- -> A client library for the IPFS HTTP RPC API (`/api/v0/*`), implemented in JavaScript. This client library implements the IPFS [Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) enabling applications to change between an embedded js-ipfs node and any remote IPFS node without having to change the code. In addition, this client library implements a set of utility functions. - -## Table of Contents +## Table of contents +- [Install](#install) - [Getting Started](#getting-started) - - [Install](#install) - [Next Steps](#next-steps) - [Usage](#usage) - - [`create([options])`](#createoptions) + - - [`create([options])`](#createoptions) - [Parameters](#parameters) - [Options](#options) - [Returns](#returns) @@ -57,17 +36,48 @@ - [Global Timeouts](#global-timeouts) - [Development](#development) - [Testing](#testing) -- [Contribute](#contribute) - [Historical context](#historical-context) - [License](#license) +- [Contribute](#contribute) -## Getting Started +## Install -We've come a long way, but this project is still in Alpha, lots of development is happening, APIs might change, beware of 🐉.. +```console +$ npm i ipfs-http-client +``` + +

+ IPFS http client lib logo +

+ +

The JavaScript HTTP RPC API client library for IPFS implementations.

-### Install +

+ + + + +

-This module uses node.js, and can be installed through npm: +

+ + + + +
+ + + + + + + +
+

+ +## Getting Started + +We've come a long way, but this project is still in Alpha, lots of development is happening, APIs might change, beware of 🐉.. ```bash npm install --save ipfs-http-client @@ -77,14 +87,14 @@ Both the Current and Active LTS versions of Node.js are supported. Please see [n ### Next Steps -* Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) -* Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser -* Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node -* Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it -* Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs -* Check out https://docs.ipfs.io for tips, how-tos and more -* See https://blog.ipfs.io for news and more -* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io +- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) +- Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser +- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node +- Visit to learn about IPFS and the concepts that underpin it +- Head over to to take interactive tutorials that cover core IPFS APIs +- Check out for tips, how-tos and more +- See for news and more +- Need help? Please ask 'How do I?' questions on ## Usage @@ -102,19 +112,19 @@ None Alternatively it can be an object which may have the following keys: -| Name | Type | Default | Description | -| ---- | ---- | ------- | ----------- | -| url | `String` or `URL` or `Multiaddr` | `'http://localhost:5001/api/v0'` | A URL that resolves to a running instance of the IPFS [HTTP RPC API](https://docs.ipfs.io/reference/http/api/) | -| protocol | `String` | `'http'` | The protocol to used (ignored if url is specified) | -| host | `String` | `'localhost'` | The host to used (ignored if url is specified) | -| port | `number` | `5001` | The port to used (ignored if url is specified) | -| path | `String` | `'api/v0'` | The path to used (ignored if url is specified) | -| agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `http.Agent({ keepAlive: true, maxSockets: 6 })` | An `http.Agent` used to control client behaviour (node.js only) | +| Name | Type | Default | Description | +| -------- | -------------------------------------------------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- | +| url | `String` or `URL` or `Multiaddr` | `'http://localhost:5001/api/v0'` | A URL that resolves to a running instance of the IPFS [HTTP RPC API](https://docs.ipfs.io/reference/http/api/) | +| protocol | `String` | `'http'` | The protocol to used (ignored if url is specified) | +| host | `String` | `'localhost'` | The host to used (ignored if url is specified) | +| port | `number` | `5001` | The port to used (ignored if url is specified) | +| path | `String` | `'api/v0'` | The path to used (ignored if url is specified) | +| agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `http.Agent({ keepAlive: true, maxSockets: 6 })` | An `http.Agent` used to control client behaviour (node.js only) | #### Returns -| Type | Description | -| ---- | ----------- | +| Type | Description | +| -------- | --------------------------------------------------------------------------------------------------------- | | `Object` | An object that conforms to the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) | #### Example @@ -143,10 +153,10 @@ const { cid } = await client.add('Hello world!') ### Additional Options -All core API methods take _additional_ `options` specific to the HTTP API: +All core API methods take *additional* `options` specific to the HTTP API: -* `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options. -* `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request. +- `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options. +- `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request. ### Instance Utils @@ -299,9 +309,9 @@ To always request the latest version, use one of the following examples: For maximum security you may also decide to: -* reference a specific version of IPFS API (to prevent unexpected breaking changes when a newer latest version is published) -* [generate a SRI hash](https://www.srihash.org/) of that version and use it to ensure integrity. Learn more also at the [jsdelivr website](https://www.jsdelivr.com/using-sri-with-dynamic-files) -* set the [CORS settings attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) to make anonymous requests to CDN +- reference a specific version of IPFS API (to prevent unexpected breaking changes when a newer latest version is published) +- [generate a SRI hash](https://www.srihash.org/) of that version and use it to ensure integrity. Learn more also at the [jsdelivr website](https://www.jsdelivr.com/using-sri-with-dynamic-files) +- set the [CORS settings attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) to make anonymous requests to CDN Example: @@ -342,7 +352,7 @@ const ipfs = create({ ### Global Timeouts -To set a global timeout for _all_ requests pass a value for the `timeout` option: +To set a global timeout for *all* requests pass a value for the `timeout` option: ```js // Timeout after 10 seconds @@ -358,24 +368,25 @@ const ipfs = create({ timeout: '2m' }) We run tests by executing `npm test` in a terminal window. This will run both Node.js and Browser tests, both in Chrome and PhantomJS. To ensure that the module conforms with the [`interface-ipfs-core`](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) spec, we run the batch of tests provided by the interface module, which can be found [here](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core/src). -## Contribute +## Historical context -The js-ipfs-http-client is a work in progress. As such, there's a few things you can do right now to help out: +This module started as a direct mapping from the go-ipfs cli to a JavaScript implementation, although this was useful and familiar to a lot of developers that were coming to IPFS for the first time, it also created some confusion on how to operate the core of IPFS and have access to the full capacity of the protocol. After much consideration, we decided to create `interface-ipfs-core` with the goal of standardizing the interface of a core implementation of IPFS, and keep the utility functions the IPFS community learned to use and love, such as reading files from disk and storing them directly to IPFS. -- **[Check out the existing issues](https://github.com/ipfs/js-ipfs-http-client/issues)**! -- **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs. -- **Add tests**. There can never be enough tests. Note that interface tests exist inside [`interface-ipfs-core`](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core/src). +## License -**Want to hack on IPFS?** +Licensed under either of -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -## Historical context +## Contribute -This module started as a direct mapping from the go-ipfs cli to a JavaScript implementation, although this was useful and familiar to a lot of developers that were coming to IPFS for the first time, it also created some confusion on how to operate the core of IPFS and have access to the full capacity of the protocol. After much consideration, we decided to create `interface-ipfs-core` with the goal of standardizing the interface of a core implementation of IPFS, and keep the utility functions the IPFS community learned to use and love, such as reading files from disk and storing them directly to IPFS. +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -## License +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. -[MIT](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). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fipfs%2Fjs-ipfs-http-client.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fipfs%2Fjs-ipfs-http-client?ref=badge_large) +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index 884466f151..f6b0e24b43 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -2,21 +2,49 @@ "name": "ipfs-http-client", "version": "57.0.3", "description": "A client library for the IPFS HTTP API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -26,17 +54,6 @@ "sourceType": "module" } }, - "browser": { - "ipfs-utils/src/files/glob-source": false, - "go-ipfs": false, - "ipfs-core-utils/src/files/normalise-input": "ipfs-core-utils/src/files/normalise-input/index.browser.js", - "http": false, - "https": false - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test": "aegir test", @@ -53,18 +70,18 @@ "@ipld/dag-cbor": "^7.0.0", "@ipld/dag-json": "^8.0.1", "@ipld/dag-pb": "^2.1.3", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^10.1.8", "any-signal": "^3.0.0", - "dag-jose": "^1.0.0", + "dag-jose": "^2.0.1", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", + "ipfs-core-types": "^0.11.0", + "ipfs-core-utils": "^0.15.0", "ipfs-utils": "^9.0.6", "it-first": "^1.0.6", "it-last": "^1.0.4", "merge-options": "^3.0.4", - "@multiformats/multiaddr": "^10.0.0", "multiformats": "^9.5.1", "parse-duration": "^1.0.0", "stream-to-it": "^0.2.2", @@ -74,117 +91,17 @@ "aegir": "^37.0.11", "delay": "^5.0.0", "go-ipfs": "^0.12.1", - "ipfsd-ctl": "^11.0.0", + "ipfsd-ctl": "^12.0.0", "it-all": "^1.0.4", "it-first": "^1.0.4", "nock": "^13.0.2", "p-defer": "^4.0.0" }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" - }, - "contributors": [ - "Alan Shaw ", - "Alan Shaw ", - "Alex Mingoia ", - "Alex Potsides ", - "Antonio Tenorio-Fornés ", - "Bruno Barbieri ", - "Clemo ", - "Connor Keenan ", - "Daniel Constantin ", - "Danny ", - "David Braun ", - "David Dias ", - "Dietrich Ayala ", - "Diogo Silva ", - "Dmitriy Ryajov ", - "Dmitry Nikulin ", - "Donatas Stundys ", - "Fil ", - "Filip Š ", - "Francisco Baio Dias ", - "Friedel Ziegelmayer ", - "Gar ", - "Gavin McDermott ", - "Gopalakrishna Palem ", - "Greenkeeper ", - "Haad ", - "Harlan T Wood ", - "Harlan T Wood ", - "Henrique Dias ", - "Holodisc ", - "Hugo Dias ", - "Hugo Dias ", - "JGAntunes ", - "Jacob Heun ", - "James Halliday ", - "Jason Carver ", - "Jason Papakostas ", - "Jeff Downie ", - "Jeromy ", - "Jeromy ", - "Jim Pick ", - "Joe Turgeon ", - "Jonathan ", - "Juan Batiz-Benet ", - "Kevin Wang ", - "Kristoffer Ström ", - "Marcin Rataj ", - "Matt Bell ", - "Matt Ober ", - "Maxime Lathuilière ", - "Michael Bradley ", - "Michael Muré ", - "Michael Muré ", - "Mikeal Rogers ", - "Mitar ", - "Mithgol ", - "Mohamed Abdulaziz ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Nuno Nogueira ", - "Níckolas Goline ", - "Oli Evans ", - "Orie Steele ", - "Paul Cowgill ", - "Pedro Santos ", - "Pedro Santos ", - "Pedro Teixeira ", - "Pete Thomas ", - "Richard Littauer ", - "Richard Schneider ", - "Roman Khafizianov ", - "SeungWon ", - "Stephen Whitmore ", - "Tara Vancil ", - "Teri Chadbourne ", - "Travis Person ", - "Travis Person ", - "Vasco Santos ", - "Vasco Santos ", - "Victor Bjelkholm ", - "Volker Mische ", - "Zhiyuan Lin ", - "dirkmc ", - "dmitriy ryajov ", - "elsehow ", - "ethers ", - "greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>", - "greenkeeper[bot] ", - "haad ", - "kumavis ", - "leekt216 ", - "nginnever ", - "noah the goodra ", - "phillmac ", - "priecint ", - "samuli ", - "sarthak khandelwal ", - "shunkin ", - "victorbjelkholm ", - "Łukasz Magiera ", - "Łukasz Magiera ", - "Xmader " - ] + "browser": { + "ipfs-utils/src/files/glob-source": false, + "go-ipfs": false, + "ipfs-core-utils/src/files/normalise-input": "ipfs-core-utils/src/files/normalise-input/index.browser.js", + "http": false, + "https": false + } } diff --git a/packages/ipfs-http-client/src/dht/map-event.js b/packages/ipfs-http-client/src/dht/map-event.js index 7a8777759a..c08cd50f33 100644 --- a/packages/ipfs-http-client/src/dht/map-event.js +++ b/packages/ipfs-http-client/src/dht/map-event.js @@ -13,7 +13,7 @@ import { Multiaddr } from '@multiformats/multiaddr' import { peerIdFromString } from '@libp2p/peer-id' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** @@ -46,7 +46,7 @@ export const mapEvent = (event) => { if (event.Type === FinalPeer) { // dht.query ends with a FinalPeer event with no Responses - /** @type {import('@libp2p/interfaces/peer-info').PeerInfo} */ + /** @type {import('@libp2p/interface-peer-info').PeerInfo} */ let peer = { // @ts-expect-error go-ipfs does not return this id: event.ID ?? peerIdFromString(event.ID), diff --git a/packages/ipfs-http-client/src/pubsub/subscribe.js b/packages/ipfs-http-client/src/pubsub/subscribe.js index 8646747a2f..38fd85dce7 100644 --- a/packages/ipfs-http-client/src/pubsub/subscribe.js +++ b/packages/ipfs-http-client/src/pubsub/subscribe.js @@ -7,7 +7,7 @@ const log = logger('ipfs-http-client:pubsub:subscribe') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {(err: Error, fatal: boolean, msg?: Message) => void} ErrorHandlerFn * @typedef {import('ipfs-core-types/src/pubsub').API} PubsubAPI * @typedef {import('../types').Options} Options @@ -107,12 +107,23 @@ async function readMessages (response, { onMessage, onEnd, onError }) { continue } - onMessage({ - from: peerIdFromString(msg.from), - data: rpcToBytes(msg.data), - sequenceNumber: rpcToBigInt(msg.seqno), - topic: rpcToText(msg.topicIDs[0]) - }) + if (msg.from != null && msg.seqno != null) { + onMessage({ + type: 'signed', + from: peerIdFromString(msg.from), + data: rpcToBytes(msg.data), + sequenceNumber: rpcToBigInt(msg.seqno), + topic: rpcToText(msg.topicIDs[0]), + key: rpcToBytes(msg.key ?? 'u'), + signature: rpcToBytes(msg.signature ?? 'u') + }) + } else { + onMessage({ + type: 'unsigned', + data: rpcToBytes(msg.data), + topic: rpcToText(msg.topicIDs[0]) + }) + } } catch (/** @type {any} */ err) { err.message = `Failed to parse pubsub message: ${err.message}` onError(err, false, msg) // Not fatal diff --git a/packages/ipfs-http-client/src/pubsub/subscription-tracker.js b/packages/ipfs-http-client/src/pubsub/subscription-tracker.js index 3cc0dd5a0c..52bb1db9bf 100644 --- a/packages/ipfs-http-client/src/pubsub/subscription-tracker.js +++ b/packages/ipfs-http-client/src/pubsub/subscription-tracker.js @@ -1,6 +1,6 @@ /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler} MessageHandlerFn * * @typedef {object} Subscription diff --git a/packages/ipfs-http-gateway/LICENSE b/packages/ipfs-http-gateway/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-http-gateway/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-http-gateway/LICENSE-MIT b/packages/ipfs-http-gateway/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-http-gateway/LICENSE-MIT +++ b/packages/ipfs-http-gateway/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-http-gateway/README.md b/packages/ipfs-http-gateway/README.md index 993805d32e..5d16ba119d 100644 --- a/packages/ipfs-http-gateway/README.md +++ b/packages/ipfs-http-gateway/README.md @@ -1,16 +1,24 @@ # ipfs-http-gateway -> A web server that bridges HTTP to IPFS +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-http-gateway +``` ```console $ npm install -g ipfs @@ -19,24 +27,21 @@ $ jsipfs daemon $ curl http://localhost:9090/ipfs/Qmfoo ``` -## Want to hack on IPFS? +## License + +Licensed under either of -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +## Contribute -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +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. +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). -## License +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. -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-gateway/package.json b/packages/ipfs-http-gateway/package.json index 88c522a469..df48d13507 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -2,15 +2,24 @@ "name": "ipfs-http-gateway", "version": "0.10.4", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-gateway#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-gateway#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,15 +37,18 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./resources/index": { + "types": "./src/resources/index.d.ts", "import": "./src/resources/index.js" } }, @@ -46,10 +58,6 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", @@ -62,10 +70,10 @@ "@hapi/ammo": "^5.0.1", "@hapi/boom": "^9.1.0", "@hapi/hapi": "^20.0.0", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "hapi-pino": "^8.5.0", - "ipfs-core-types": "^0.11.1", - "ipfs-http-response": "^3.0.4", + "ipfs-core-types": "^0.11.0", + "ipfs-http-response": "^3.0.0", "is-ipfs": "^6.0.1", "it-last": "^1.0.4", "it-to-stream": "^1.0.0", diff --git a/packages/ipfs-http-gateway/tsconfig.json b/packages/ipfs-http-gateway/tsconfig.json index 5b011ba049..2d28a2ad20 100644 --- a/packages/ipfs-http-gateway/tsconfig.json +++ b/packages/ipfs-http-gateway/tsconfig.json @@ -10,6 +10,9 @@ "references": [ { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-http-response" } ] } diff --git a/packages/ipfs-http-response/LICENSE b/packages/ipfs-http-response/LICENSE index e4224df5b7..20ce483c86 100644 --- a/packages/ipfs-http-response/LICENSE +++ b/packages/ipfs-http-response/LICENSE @@ -1,21 +1,4 @@ -MIT License +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2018 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. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/ipfs-http-response/LICENSE-APACHE b/packages/ipfs-http-response/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-http-response/LICENSE-APACHE @@ -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. diff --git a/packages/ipfs-http-response/LICENSE-MIT b/packages/ipfs-http-response/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-http-response/LICENSE-MIT @@ -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. diff --git a/packages/ipfs-http-response/README.md b/packages/ipfs-http-response/README.md index b726645fbf..640baa0551 100644 --- a/packages/ipfs-http-response/README.md +++ b/packages/ipfs-http-response/README.md @@ -1,19 +1,29 @@ -# js-ipfs-http-response +# ipfs-http-response -[![](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) -[![standard-readme](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) > Creates an HTTP response from an IPFS Hash -### Installation +## Table of contents -> npm install ipfs-http-response +- [Install](#install) +- [Usage](#usage) + - [Creating HTTP Response](#creating-http-response) + - [Using protocol-agnostic resolver](#using-protocol-agnostic-resolver) +- [License](#license) +- [Contribute](#contribute) -## Usage +## Install + +```console +$ npm i ipfs-http-response +``` +## Usage ### Creating HTTP Response @@ -39,7 +49,6 @@ console.log(result) If `ipfsPath` points at a directory, `resolver.cid` will throw Error `This dag node is a directory` with a `cid` attribute that can be passed to `resolver.directory`: - ```js import { resolver } from 'ipfs-http-response' @@ -50,3 +59,22 @@ console.log(result) `result` will be either a `string` with HTML directory listing or an array with CIDs of `index` pages present in inspected directory. ![ipfs-http-response usage](docs/ipfs-http-response.png "ipfs-http-response usage") + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-response/package.json b/packages/ipfs-http-response/package.json index fe41a04a23..1df91a8c1d 100644 --- a/packages/ipfs-http-response/package.json +++ b/packages/ipfs-http-response/package.json @@ -2,9 +2,27 @@ "name": "ipfs-http-response", "version": "3.0.4", "description": "Creates an HTTP response from an IPFS Hash", - "leadMaintainer": "Vasco Santos ", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "author": "Vasco Santos ", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-response#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "keywords": [ + "http", + "ipfs", + "response" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -21,18 +39,24 @@ ] } }, - "type": "module", + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./src/index.js" + } + }, "eslintConfig": { "extends": "ipfs", "parserOptions": { "sourceType": "module" } }, - "exports": { - ".": { - "import": "./src/index.js" - } - }, "scripts": { "lint": "aegir lint", "clean": "aegir clean", @@ -41,34 +65,15 @@ "test:node": "aegir test -t node --cov", "dep-check": "aegir dep-check -i global" }, - "browser": { - "file-type": "file-type/browser", - "fs": false - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs-http-response.git" - }, - "keywords": [ - "ipfs", - "http", - "response" - ], - "author": "Vasco Santos ", - "license": "MIT", - "bugs": { - "url": "https://github.com/ipfs/js-ipfs-http-response/issues" - }, - "homepage": "https://github.com/ipfs/js-ipfs-http-response#readme", "dependencies": { - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "ejs": "^3.1.6", "file-type": "^17.1.1", - "filesize": "^8.0.0", + "filesize": "^9.0.11", "it-buffer": "^0.1.1", "it-concat": "^2.0.0", "it-map": "^1.0.6", - "it-reader": "^5.0.1", + "it-reader": "^6.0.1", "it-to-stream": "^1.0.0", "mime-types": "^2.1.30", "p-try-each": "^1.0.1" @@ -78,19 +83,13 @@ "@types/mime-types": "^2.1.1", "aegir": "^37.0.11", "get-stream": "^6.0.0", - "ipfs-core": "^0.15.4", - "ipfsd-ctl": "^11.0.0", + "ipfs-core": "^0.15.0", + "ipfsd-ctl": "^12.0.0", "it-all": "^1.0.4", "uint8arrays": "^3.0.0" }, - "contributors": [ - "Vasco Santos ", - "Alex Potsides ", - "Hector Sanjuan ", - "Marcin Rataj ", - "André Cruz ", - "Irakli Gozalishvili ", - "Alan Shaw ", - "Pedro Santos " - ] + "browser": { + "file-type": "file-type/browser", + "fs": false + } } diff --git a/packages/ipfs-http-response/tsconfig.json b/packages/ipfs-http-response/tsconfig.json index 448e187c8c..882b188dfc 100644 --- a/packages/ipfs-http-response/tsconfig.json +++ b/packages/ipfs-http-response/tsconfig.json @@ -11,5 +11,10 @@ "exclude": [ "dist", "node_modules" + ], + "references": [ + { + "path": "../ipfs-core" + } ] } diff --git a/packages/ipfs-http-server/LICENSE b/packages/ipfs-http-server/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-http-server/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-http-server/LICENSE-MIT b/packages/ipfs-http-server/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-http-server/LICENSE-MIT +++ b/packages/ipfs-http-server/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-http-server/README.md b/packages/ipfs-http-server/README.md index e75b94ac23..51f5921326 100644 --- a/packages/ipfs-http-server/README.md +++ b/packages/ipfs-http-server/README.md @@ -1,16 +1,24 @@ # ipfs-http-server -> The implementation of the IPFS RPC-over-HTTP API +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-http-server +``` ```console $ npm install -g ipfs @@ -23,24 +31,21 @@ $ curl -X POST http://localhost:5002/api/v0/id | npx json ... ``` -## Want to hack on IPFS? +## License + +Licensed under either of -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +## Contribute -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +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. +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). -## License +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. -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index f8271ef649..1c29edb0f3 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -2,22 +2,49 @@ "name": "ipfs-http-server", "version": "0.12.5", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-server#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-server#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,16 +54,12 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", "test:node": "aegir test -t node --cov", "clean": "aegir clean", - "dep-check": "aegir dep-check -i ipfs-http-client -i ipfs-core-types -i @libp2p/interfaces -i ipfs-unixfs", + "dep-check": "aegir dep-check -i ipfs-http-client -i ipfs-core-types -i @libp2p/interfaces -i ipfs-unixfs -i @libp2p/interface-dht", "build": "aegir build --no-bundle", "prepublishOnly": "node scripts/update-version.js" }, @@ -45,29 +68,30 @@ "@hapi/content": "^5.0.2", "@hapi/hapi": "^20.0.0", "@ipld/dag-pb": "^2.1.3", - "@libp2p/interfaces": "^2.0.4", - "@libp2p/logger": "^1.1.4", + "@libp2p/interface-dht": "^1.0.1", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^10.1.8", "any-signal": "^3.0.0", "dlv": "^1.1.3", "hapi-pino": "^8.5.0", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-http-gateway": "^0.10.4", - "ipfs-unixfs": "^6.0.9", + "ipfs-core-types": "^0.11.0", + "ipfs-core-utils": "^0.15.0", + "ipfs-http-gateway": "^0.10.0", + "ipfs-unixfs": "^7.0.0", "it-all": "^1.0.4", "it-drain": "^1.0.3", "it-filter": "^1.0.2", "it-last": "^1.0.4", - "it-map": "^1.0.4", - "it-merge": "^1.0.2", + "it-map": "^1.0.6", + "it-merge": "^1.0.3", "it-multipart": "^2.0.0", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", + "it-pushable": "^3.0.0", "it-reduce": "^1.0.5", "joi": "^17.2.1", "just-safe-set": "^4.0.2", - "@multiformats/multiaddr": "^10.0.0", "multiformats": "^9.5.1", "parse-duration": "^1.0.0", "stream-to-it": "^0.2.2", @@ -78,10 +102,11 @@ "devDependencies": { "@types/hapi-pino": "^8.0.1", "@types/hapi__hapi": "^20.0.5", + "@types/node": "^18.0.0", "aegir": "^37.0.11", "err-code": "^3.0.1", "form-data": "^4.0.0", - "ipfs-http-client": "^57.0.3", + "ipfs-http-client": "^57.0.0", "iso-random-stream": "^2.0.2", "it-first": "^1.0.4", "it-to-buffer": "^2.0.0", diff --git a/packages/ipfs-http-server/src/api/resources/dht.js b/packages/ipfs-http-server/src/api/resources/dht.js index bb1a453f40..2a9df85b9d 100644 --- a/packages/ipfs-http-server/src/api/resources/dht.js +++ b/packages/ipfs-http-server/src/api/resources/dht.js @@ -9,7 +9,7 @@ import Boom from '@hapi/boom' /** * @typedef {import('ipfs-core-types/src/dht').QueryEvent} QueryEvent - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/ipfs-http-server/src/api/resources/pubsub.js b/packages/ipfs-http-server/src/api/resources/pubsub.js index 52cb8f7922..5cd38252b4 100644 --- a/packages/ipfs-http-server/src/api/resources/pubsub.js +++ b/packages/ipfs-http-server/src/api/resources/pubsub.js @@ -9,7 +9,7 @@ import { pushable } from 'it-pushable' import { base64url } from 'multiformats/bases/base64' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ const preDecodeTopicFromHttpRpc = { @@ -71,30 +71,35 @@ export const subscribeResource = { // request.raw.res.setHeader('Trailer', 'X-Stream-Error') return streamResponse(request, h, () => { - const output = pushable() + const output = pushable({ objectMode: true }) /** * @type {import('@libp2p/interfaces/events').EventHandler} */ const handler = (msg) => { - let sequenceNumber - - if (msg.sequenceNumber != null) { + if (msg.type === 'signed') { let numberString = msg.sequenceNumber.toString(16) if (numberString.length % 2 !== 0) { numberString = `0${numberString}` } - sequenceNumber = base64url.encode(uint8ArrayFromString(numberString, 'base16')) - } + const sequenceNumber = base64url.encode(uint8ArrayFromString(numberString, 'base16')) - output.push({ - from: msg.from, // TODO: switch to peerIdFromString(msg.from).toString() when go-ipfs defaults to CIDv1 - data: base64url.encode(msg.data), - seqno: sequenceNumber, - topicIDs: [base64url.encode(uint8ArrayFromString(msg.topic))] - }) + output.push({ + from: msg.from, // TODO: switch to peerIdFromString(msg.from).toString() when go-ipfs defaults to CIDv1 + data: base64url.encode(msg.data), + seqno: sequenceNumber, + topicIDs: [base64url.encode(uint8ArrayFromString(msg.topic))], + key: base64url.encode(msg.key), + signature: base64url.encode(msg.signature) + }) + } else { + output.push({ + data: base64url.encode(msg.data), + topicIDs: [base64url.encode(uint8ArrayFromString(msg.topic))] + }) + } } // js-ipfs-http-client needs a reply, and go-ipfs does the same thing diff --git a/packages/ipfs-http-server/src/api/resources/shutdown.js b/packages/ipfs-http-server/src/api/resources/shutdown.js index 0114d8a22f..9a8a6e0292 100644 --- a/packages/ipfs-http-server/src/api/resources/shutdown.js +++ b/packages/ipfs-http-server/src/api/resources/shutdown.js @@ -11,7 +11,7 @@ export const shutdownResource = { * @param {import('@hapi/hapi').ResponseToolkit} h */ handler: (_request, h) => { - setImmediate(() => process.emit('SIGTERM')) + setImmediate(() => process.emit('SIGTERM', 'SIGTERM')) return h.response() } } diff --git a/packages/ipfs-http-server/src/api/routes/debug.js b/packages/ipfs-http-server/src/api/routes/debug.js index 023dcc9dde..1ed38a0abe 100644 --- a/packages/ipfs-http-server/src/api/routes/debug.js +++ b/packages/ipfs-http-server/src/api/routes/debug.js @@ -1,3 +1,5 @@ +/* eslint-disable max-depth */ + import client from 'prom-client' import Boom from '@hapi/boom' import { disable, enable } from '@libp2p/logger' @@ -28,14 +30,36 @@ export default [{ if (metrics) { for (const [system, components] of metrics.getComponentMetrics().entries()) { for (const [component, componentMetrics] of components.entries()) { - for (const [metricName, metricValue] of componentMetrics.entries()) { + for (const [metricName, trackedMetric] of componentMetrics.entries()) { const name = `${system}-${component}-${metricName}`.replace(/-/g, '_') + const labelName = trackedMetric.label ?? metricName.replace(/-/g, '_') + const help = trackedMetric.help ?? metricName.replace(/-/g, '_') + + /** @type {client.GaugeConfiguration} */ + const gaugeOptions = { name, help } + const metricValue = await trackedMetric.calculate() - if (!gauges[name]) { // eslint-disable-line max-depth - gauges[name] = new client.Gauge({ name, help: name }) + if (typeof metricValue !== 'number') { + // metric group + gaugeOptions.labelNames = [ + labelName + ] } - gauges[name].set(metricValue) + if (!gauges[name]) { + // create metric if it's not been seen before + gauges[name] = new client.Gauge(gaugeOptions) + } + + if (typeof metricValue !== 'number') { + // metric group + Object.entries(metricValue).forEach(([key, value]) => { + gauges[name].set({ [labelName]: key }, value) + }) + } else { + // metric value + gauges[name].set(metricValue) + } } } } diff --git a/packages/ipfs-http-server/src/error-handler.js b/packages/ipfs-http-server/src/error-handler.js index 1c21274117..cca2fb48c5 100644 --- a/packages/ipfs-http-server/src/error-handler.js +++ b/packages/ipfs-http-server/src/error-handler.js @@ -34,16 +34,14 @@ export function errorHandler (server) { if (process.env.DEBUG || statusCode >= 500) { const { req } = request.raw const debug = { - method: req.method, - url: request.url, + method: req.method?.toString(), + url: request.url?.toString(), headers: req.headers, - info: request.info, payload: request.payload, response: res.output.payload } server.logger.error(debug) - server.logger.error(res) } const response = h.response({ diff --git a/packages/ipfs-http-server/test/inject/dht.js b/packages/ipfs-http-server/test/inject/dht.js index 4d182fa627..3f9ed0de40 100644 --- a/packages/ipfs-http-server/test/inject/dht.js +++ b/packages/ipfs-http-server/test/inject/dht.js @@ -11,7 +11,7 @@ import { allNdjson } from '../utils/all-ndjson.js' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import FormData from 'form-data' import streamToPromise from 'stream-to-promise' -import { EventTypes } from '@libp2p/interfaces/dht' +import { EventTypes } from '@libp2p/interface-dht' describe('/dht', () => { const peerId = 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A' diff --git a/packages/ipfs-http-server/test/inject/object.js b/packages/ipfs-http-server/test/inject/object.js index d1c77bcf6a..5bb990fcb1 100644 --- a/packages/ipfs-http-server/test/inject/object.js +++ b/packages/ipfs-http-server/test/inject/object.js @@ -292,7 +292,7 @@ describe('/object', () => { ipfs.bases.getBase.withArgs('base58btc').returns(base58btc) const pbNode = { - Data: uint8ArrayFromString('another'), + Data: Uint8Array.from(uint8ArrayFromString('another')), Links: [{ Name: 'some link', Hash: CID.parse('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V'), @@ -341,7 +341,7 @@ describe('/object', () => { ipfs.bases.getBase.withArgs('base64').returns(base64) const pbNode = { - Data: uint8ArrayFromString('another'), + Data: Uint8Array.from(uint8ArrayFromString('another')), Links: [{ Name: 'some link', Hash: CID.parse('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V').toV1(), @@ -390,7 +390,7 @@ describe('/object', () => { ipfs.bases.getBase.withArgs('base58btc').returns(base58btc) const pbNode = { - Data: uint8ArrayFromString('another'), + Data: Uint8Array.from(uint8ArrayFromString('another')), Links: [{ Name: 'some link', Hash: CID.parse('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V'), diff --git a/packages/ipfs-http-server/tsconfig.json b/packages/ipfs-http-server/tsconfig.json index e6f92ccfd4..04be5d4ba1 100644 --- a/packages/ipfs-http-server/tsconfig.json +++ b/packages/ipfs-http-server/tsconfig.json @@ -15,6 +15,9 @@ { "path": "../ipfs-core-utils" }, + { + "path": "../ipfs-http-client" + }, { "path": "../ipfs-http-gateway" } diff --git a/packages/ipfs-message-port-client/LICENSE b/packages/ipfs-message-port-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-message-port-client/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-message-port-client/LICENSE-MIT b/packages/ipfs-message-port-client/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-message-port-client/LICENSE-MIT +++ b/packages/ipfs-message-port-client/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-message-port-client/README.md b/packages/ipfs-message-port-client/README.md index 42008f7221..dc26cc5566 100644 --- a/packages/ipfs-message-port-client/README.md +++ b/packages/ipfs-message-port-client/README.md @@ -1,27 +1,25 @@ # ipfs-message-port-client -[![](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) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-message-port-client)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-message-port-client) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A client library for the IPFS API over [message channel][]. This client library provides (subset) of [IPFS API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) enabling applications to work with js-ipfs running in the different JS e.g. [SharedWorker][]. +> IPFS client library for accessing IPFS node over message port -## Table of Contentens +## Table of contents - [Install](#install) - [Usage](#usage) - [Notes on Performance](#notes-on-performance) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-message-port-client +```console +$ npm i ipfs-message-port-client ``` ## Usage @@ -42,7 +40,6 @@ goal of this library is to allow sharing a node across browsing contexts (tabs, iframes) and therefore most likely `ipfs-message-port-server` will be in a separate JS bundle and loaded in the [SharedWorker][]. - ```js import { IPFSClient } from 'ipfs-message-port-client' // URL to the script containing ipfs-message-port-server. @@ -121,21 +118,35 @@ const example = async (url) => { } ``` -[message channel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel -[SharedWorker]:https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker -[`MessagePort`]:https://developer.mozilla.org/en-US/docs/Web/API/MessagePort -[structured cloning algorithm]:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[Transferable]:https://developer.mozilla.org/en-US/docs/Web/API/Transferable -[Blob]:https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[File]:https://developer.mozilla.org/en-US/docs/Web/API/File +## License +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + +[message channel]: https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel + +[SharedWorker]: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker + +[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort + +[structured cloning algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm + +[Transferable]: https://developer.mozilla.org/en-US/docs/Web/API/Transferable + +[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[File]: https://developer.mozilla.org/en-US/docs/Web/API/File diff --git a/packages/ipfs-message-port-client/package.json b/packages/ipfs-message-port-client/package.json index d343403c7e..46b4fd0f0c 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -2,24 +2,51 @@ "name": "ipfs-message-port-client", "version": "0.12.4", "description": "IPFS client library for accessing IPFS node over message port", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs", "message-port", "worker" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -29,11 +56,6 @@ "sourceType": "module" } }, - "browser": {}, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test:interface:message-port-client": "aegir test -t browser --bail -f ./test/interface-message-port-client.js", @@ -44,20 +66,16 @@ "dependencies": { "browser-readablestream-to-it": "^1.0.1", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-message-port-protocol": "^0.12.1", - "ipfs-unixfs": "^6.0.9", + "ipfs-core-types": "^0.11.0", + "ipfs-message-port-protocol": "^0.12.0", + "ipfs-unixfs": "^7.0.0", "it-peekable": "^1.0.2", "multiformats": "^9.5.1" }, "devDependencies": { "aegir": "^37.0.11", - "interface-ipfs-core": "^0.155.2", - "ipfs-core": "^0.15.4", - "ipfs-message-port-server": "^0.12.1" - }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" + "interface-ipfs-core": "^0.155.0", + "ipfs-core": "^0.15.0", + "ipfs-message-port-server": "^0.12.0" } } diff --git a/packages/ipfs-message-port-client/tsconfig.json b/packages/ipfs-message-port-client/tsconfig.json index d95a1d29d4..38f8d21175 100644 --- a/packages/ipfs-message-port-client/tsconfig.json +++ b/packages/ipfs-message-port-client/tsconfig.json @@ -9,13 +9,19 @@ ], "references": [ { - "path": "../ipfs-message-port-protocol" + "path": "../interface-ipfs-core" }, { - "path": "../ipfs-message-port-server" + "path": "../ipfs-core" }, { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-message-port-protocol" + }, + { + "path": "../ipfs-message-port-server" } ] } diff --git a/packages/ipfs-message-port-protocol/LICENSE b/packages/ipfs-message-port-protocol/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-message-port-protocol/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-message-port-protocol/LICENSE-MIT b/packages/ipfs-message-port-protocol/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-message-port-protocol/LICENSE-MIT +++ b/packages/ipfs-message-port-protocol/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-message-port-protocol/README.md b/packages/ipfs-message-port-protocol/README.md index a0a51d1836..1163666874 100644 --- a/packages/ipfs-message-port-protocol/README.md +++ b/packages/ipfs-message-port-protocol/README.md @@ -1,16 +1,14 @@ # ipfs-message-port-protocol -[![](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) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-message-port-protocol)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-message-port-protocol) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> This package serves as a repository code shared between the core `ipfs-message-port-client` and the `ipfs-message-port-server` +> IPFS client/server protocol over message port -## Table of Contentens +## Table of contents - [Install](#install) - [Usage](#usage) @@ -19,13 +17,13 @@ - [DAGNode](#dagnode) - [AsyncIterable](#asynciterable) - [Callback](#callback) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-message-port-protocol +```console +$ npm i ipfs-message-port-protocol ``` ## Usage @@ -97,7 +95,6 @@ all the IO coordination between two. It needs to be provided `encoder` / Unlike other encoders the `transfer` argument is mandatory (because async iterable is encoded to a [MessagePort][] that can only be transferred). - ```js import { encodeIterable, decodeIterable } from 'ipfs-message-port-protocol/core') @@ -163,22 +160,33 @@ port2.onmessage = ({data}) => { } ``` +## License -[structured cloning algorithm]:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[message channel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel -[MessagePort]:https://developer.mozilla.org/en-US/docs/Web/API/MessagePort -[Transferable]:https://developer.mozilla.org/en-US/docs/Web/API/Transferable - -[CID]:https://github.com/multiformats/js-cid +Licensed under either of -[async iterables]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + +[structured cloning algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm + +[message channel]: https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel + +[MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort + +[Transferable]: https://developer.mozilla.org/en-US/docs/Web/API/Transferable + +[CID]: https://github.com/multiformats/js-cid -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[async iterables]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index 9247cad684..89731ce998 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -2,15 +2,24 @@ "name": "ipfs-message-port-protocol", "version": "0.12.1", "description": "IPFS client/server protocol over message port", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-protocol#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-protocol#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,40 +37,42 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./block": { + "types": "./src/block.d.ts", "import": "./src/block.js" }, "./cid": { + "types": "./src/cid.d.ts", "import": "./src/cid.js" }, "./core": { + "types": "./src/core.d.ts", "import": "./src/core.js" }, "./dag": { + "types": "./src/dag.d.ts", "import": "./src/dag.js" }, "./error": { + "types": "./src/error.d.ts", "import": "./src/error.js" } }, - "browser": {}, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -76,15 +87,11 @@ "dep-check": "aegir dep-check -i ipfs-core-types" }, "dependencies": { - "ipfs-core-types": "^0.11.1", + "ipfs-core-types": "^0.11.0", "multiformats": "^9.5.1" }, "devDependencies": { "aegir": "^37.0.11", "uint8arrays": "^3.0.0" - }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" } } diff --git a/packages/ipfs-message-port-server/LICENSE b/packages/ipfs-message-port-server/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-message-port-server/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs-message-port-server/LICENSE-MIT b/packages/ipfs-message-port-server/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-message-port-server/LICENSE-MIT +++ b/packages/ipfs-message-port-server/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-message-port-server/README.md b/packages/ipfs-message-port-server/README.md index 15cde10eeb..421259f484 100644 --- a/packages/ipfs-message-port-server/README.md +++ b/packages/ipfs-message-port-server/README.md @@ -1,28 +1,25 @@ # ipfs-message-port-server -[![](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) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-message-port-server)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-message-port-server) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A library for providing IPFS node over [message channel][]. This library enables -applications running in the different JS context to use [IPFS API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) (subset) via `ipfs-message-port-client`. +> IPFS server library for exposing IPFS node over message port -## Table of Contentens +## Table of contents - [Install](#install) - [Usage](#usage) - [Notes on Performance](#notes-on-performance) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-message-port-server +```console +$ npm i ipfs-message-port-server ``` ## Usage @@ -66,7 +63,6 @@ const main = async () => { main() ``` - ### Notes on Performance Since the data sent over the [message channel][] is copied via @@ -77,22 +73,35 @@ on the server side. This should not be a problem in general as IPFS node itself does not retain references to returned values, but is something to keep in mind when doing something custom. +## License -[message channel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel -[SharedWorker]:https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker -[`MessagePort`]:https://developer.mozilla.org/en-US/docs/Web/API/MessagePort -[structured cloning algorithm]:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[Transferable]:https://developer.mozilla.org/en-US/docs/Web/API/Transferable -[Blob]:https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[File]:https://developer.mozilla.org/en-US/docs/Web/API/File +Licensed under either of +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + +[message channel]: https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel + +[SharedWorker]: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker + +[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort + +[structured cloning algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm + +[Transferable]: https://developer.mozilla.org/en-US/docs/Web/API/Transferable + +[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[File]: https://developer.mozilla.org/en-US/docs/Web/API/File diff --git a/packages/ipfs-message-port-server/package.json b/packages/ipfs-message-port-server/package.json index dec1de5482..26870e3ae8 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -2,42 +2,75 @@ "name": "ipfs-message-port-server", "version": "0.12.1", "description": "IPFS server library for exposing IPFS node over message port", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-server#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs", "message-port", "worker" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-server#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./block": { + "types": "./src/block.d.ts", "import": "./src/block.js" }, "./core": { + "types": "./src/core.d.ts", "import": "./src/core.js" }, "./dag": { + "types": "./src/dag.d.ts", "import": "./src/dag.js" }, "./files": { + "types": "./src/files.d.ts", "import": "./src/files.js" }, "./server": { + "types": "./src/server.d.ts", "import": "./src/server.js" }, "./service": { + "types": "./src/service.d.ts", "import": "./src/service.js" } }, @@ -47,13 +80,6 @@ "sourceType": "module" } }, - "browser": { - "worker_threads": false - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test": "aegir test", @@ -66,16 +92,15 @@ "dep-check": "aegir dep-check -i ipfs-core-types" }, "dependencies": { - "ipfs-core-types": "^0.11.1", - "ipfs-message-port-protocol": "^0.12.1", + "ipfs-core-types": "^0.11.0", + "ipfs-message-port-protocol": "^0.12.0", "it-all": "^1.0.4" }, "devDependencies": { "aegir": "^37.0.11", "multiformats": "^9.5.1" }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" + "browser": { + "worker_threads": false } } diff --git a/packages/ipfs/LICENSE b/packages/ipfs/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs/LICENSE @@ -0,0 +1,4 @@ +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 diff --git a/packages/ipfs/LICENSE-MIT b/packages/ipfs/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs/LICENSE-MIT +++ b/packages/ipfs/LICENSE-MIT @@ -16,4 +16,4 @@ 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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs/README.md b/packages/ipfs/README.md index 8d848afb73..37f6f857b2 100644 --- a/packages/ipfs/README.md +++ b/packages/ipfs/README.md @@ -1,3 +1,28 @@ +# ipfs + +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> JavaScript implementation of the IPFS specification + +## Table of contents + +- [Install](#install) +- [Getting Started](#getting-started) + - [Next Steps](#next-steps) +- [Want to hack on IPFS?](#want-to-hack-on-ipfs) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs +``` +

IPFS in JavaScript logo @@ -24,18 +49,8 @@ If you want to integrate IPFS into your application without including a CLI or HTTP server, see the [ipfs-core](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core) module. -## Table of Contents - -- [Getting Started](#getting-started) - - [Install](#install) - - [Next Steps](#next-steps) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) -- [License](#license) - ## Getting Started -### Install - Installing `ipfs` globally will give you the `jsipfs` command which you can use to start a daemon running: ```console @@ -58,13 +73,13 @@ added QmXXY5ZxbtuYj6DnfApLiGstzPN7fvSyigrRee3hDWPCaf hello-world.txt ### Next Steps -* Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) -* Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser -* Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node -* Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs -* Check out https://docs.ipfs.io for tips, how-tos and more -* See https://blog.ipfs.io for news and more -* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io +- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) +- Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser +- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node +- Head over to to take interactive tutorials that cover core IPFS APIs +- Check out for tips, how-tos and more +- See for news and more +- Need help? Please ask 'How do I?' questions on ## Want to hack on IPFS? @@ -85,6 +100,19 @@ Find out about chat channels, the IPFS newsletter, the IPFS blog, and more in th ## License -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -[![](https://github.com/ipfs/js-ipfs/raw/master/packages/interface-ipfs-core/img/badge.png)](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +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. + +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. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index 74cc6f9b0e..cbd6cfdcda 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -2,14 +2,27 @@ "name": "ipfs", "version": "0.63.5", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "bin": { + "jsipfs": "src/cli.js" + }, "type": "module", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -27,31 +40,27 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./path": { + "types": "./src/path.d.ts", "browser": "./src/path.browser.js", "import": "./src/path.js" } }, - "bin": { - "jsipfs": "src/cli.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -67,28 +76,28 @@ "dep-check": "aegir dep-check -i ipfs-core-types -i @types/*" }, "dependencies": { - "@libp2p/logger": "^1.1.4", - "ipfs-cli": "^0.13.5", - "ipfs-core": "^0.15.4", + "@libp2p/logger": "^2.0.0", + "ipfs-cli": "^0.13.0", + "ipfs-core": "^0.15.0", "semver": "^7.3.2", - "update-notifier": "^5.0.0" + "update-notifier": "^6.0.0" }, "devDependencies": { - "@libp2p/webrtc-star-signalling-server": "^1.0.3", - "@libp2p/websockets": "^1.0.8", + "@libp2p/webrtc-star-signalling-server": "^2.0.1", + "@libp2p/websockets": "^3.0.0", "@types/semver": "^7.3.4", - "@types/update-notifier": "^5.0.0", + "@types/update-notifier": "^6.0.1", "aegir": "^37.0.11", "cross-env": "^7.0.0", "electron-webrtc": "^0.3.0", "go-ipfs": "^0.12.1", - "interface-ipfs-core": "^0.155.2", - "ipfs-client": "^0.8.3", - "ipfs-core-types": "^0.11.1", - "ipfs-http-client": "^57.0.3", + "interface-ipfs-core": "^0.155.0", + "ipfs-client": "^0.8.0", + "ipfs-core-types": "^0.11.0", + "ipfs-http-client": "^57.0.0", "ipfs-interop": "ipfs/interop#feat/upgrade-to-esm-libp2p", "ipfs-utils": "^9.0.6", - "ipfsd-ctl": "^11.0.0", + "ipfsd-ctl": "^12.0.0", "iso-url": "^1.0.0", "merge-options": "^3.0.4", "mock-ipfs-pinning-service": "^0.4.2", @@ -99,154 +108,5 @@ "./src/cli.js": false, "./src/path.js": "./src/path.browser.js", "go-ipfs": false - }, - "engines": { - "node": ">=15.0.0", - "npm": ">=6.0.0" - }, - "contributors": [ - "0xflotus <0xflotus@gmail.com>", - "A_A <21040751+Otto-AA@users.noreply.github.com>", - "Adam Uhlíř ", - "Alan Shaw ", - "Alan Shaw ", - "Alex North ", - "Alex Potsides ", - "Andrew Nesbitt ", - "Andrew de Andrade ", - "André Cruz ", - "Arkadiy Kukarkin ", - "Arpit Agarwal <93arpit@gmail.com>", - "Arpit Agarwal ", - "Ayush Mahajan ", - "Bernard Mordan ", - "Brian Vander Schaaf ", - "Bruno Zell ", - "CHEVALAY JOSSELIN ", - "Caio Gondim ", - "Chance Hudson ", - "Chirag Shinde ", - "Christian Couder ", - "Dafeng ", - "Dan Ordille ", - "Dan Shields <35669742+NukeManDan@users.noreply.github.com>", - "Daniel Buchner ", - "Daniel J. O'Quinn ", - "Daniela Borges Matos de Carvalho ", - "David Dias ", - "David Gilbertson ", - "David da Silva ", - "Diogo Silva ", - "Dmitriy Ryajov ", - "Dominic Della Valle ", - "Dzmitry Bachko ", - "Enrico Marino ", - "Faheel Ahmad ", - "Felix Yan ", - "Francisco Baio Dias ", - "Francisco Baio Dias ", - "Friedel Ziegelmayer ", - "Gabriel Garrido Calvo ", - "Gar ", - "Georgios Rassias ", - "Gorka Ludlow ", - "Grant Herman ", - "Greenkeeper ", - "Haad ", - "Haoliang Yu ", - "Harsh Vakharia ", - "Henrique Dias ", - "Henry Rodrick ", - "Heo Sangmin ", - "Hugo Dias ", - "Hugo Dias ", - "Irakli Gozalishvili ", - "Jacob Heun ", - "Jacob Heun ", - "Jade Meskill ", - "Jessica Schilling ", - "Johannes Wikner ", - "Jon Schlinkert ", - "Jonathan ", - "Jonybang ", - "Jorropo ", - "João Antunes ", - "João Santos ", - "Kevin Wang ", - "Lars Gierth ", - "Lukas Drgon ", - "Maciej Krüger ", - "Marcin Rataj ", - "Marcus Bernales ", - "Marius Darila ", - "Mark Robert Henderson ", - "Mat Kelly ", - "Michelle Lee ", - "Mikeal Rogers ", - "Mithgol ", - "Molly ", - "Mounish Sai ", - "My9Bot <34904312+My9Bot@users.noreply.github.com>", - "Nick Poulden ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Nuno Nogueira ", - "Oli Evans ", - "Oskar Nyberg ", - "Pascal Precht ", - "Pau Ramon Revilla ", - "Paulo Rodrigues ", - "Pedro Santos ", - "Pedro Santos ", - "Pedro Teixeira ", - "Portia Burton ", - "Prabhakar Poudel ", - "Qmstream <51881352+Qmstream@users.noreply.github.com>", - "Raoul Millais ", - "RasmusErik Voel Jensen ", - "Richard Littauer ", - "Richard Schneider ", - "Rob Brackett ", - "Rod Keys ", - "Sangwon Hong ", - "Sid Harder ", - "SidHarder ", - "Stephen Whitmore ", - "Stephen Whitmore ", - "Steven Allen ", - "Tapasweni Pathak ", - "Terence Pae ", - "Teri Chadbourne ", - "Travis CI ", - "Uroš Jurglič ", - "Vasco Santos ", - "Vasco Santos ", - "Vincent Martin ", - "Volker Mische ", - "Xiao Liang ", - "Yahya ", - "Yole ", - "bitspill ", - "datafatmunger ", - "dirkmc ", - "dirkmc ", - "greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>", - "greenkeeper[bot] ", - "haad ", - "hapsody ", - "jbenet ", - "jonahweissman <19804455+jonahweissman@users.noreply.github.com>", - "kevingzhang ", - "kumavis ", - "nginnever ", - "npmcdn-to-unpkg-bot ", - "reasv <7143787+reasv@users.noreply.github.com>", - "robbsolter <35879806+robbsolter@users.noreply.github.com>", - "seungwon-kang ", - "swedneck <40505480+swedneck@users.noreply.github.com>", - "tcme ", - "victorbjelkholm ", - "Łukasz Magiera ", - "Максим Ильин ", - "Xmader " - ] + } } diff --git a/packages/ipfs/tsconfig.json b/packages/ipfs/tsconfig.json index 2e5e453229..b66401b4d0 100644 --- a/packages/ipfs/tsconfig.json +++ b/packages/ipfs/tsconfig.json @@ -10,14 +10,23 @@ "package.json" ], "references": [ + { + "path": "../interface-ipfs-core" + }, { "path": "../ipfs-cli" }, + { + "path": "../ipfs-client" + }, { "path": "../ipfs-core" }, { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-http-client" } ] }