diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index c0e73b598..ab2329cc4 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1 +1 @@
-{"packages/helia":"3.0.0","packages/interface":"3.0.0","packages/interop":"2.0.0"}
\ No newline at end of file
+{"packages/block-brokers":"0.0.0", "packages/helia":"3.0.0","packages/interface":"3.0.0","packages/interop":"2.0.0"}
diff --git a/.release-please.json b/.release-please.json
index 35bf765b9..a1c4bdd85 100644
--- a/.release-please.json
+++ b/.release-please.json
@@ -1,6 +1,8 @@
{
"plugins": ["node-workspace"],
+ "last-release-sha": "456f6841aa4f6f27cb9b8636c90a1765a3018878",
"packages": {
+ "packages/block-brokers": {},
"packages/helia": {},
"packages/interface": {},
"packages/interop": {}
diff --git a/packages/block-brokers/LICENSE b/packages/block-brokers/LICENSE
new file mode 100644
index 000000000..20ce483c8
--- /dev/null
+++ b/packages/block-brokers/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/block-brokers/LICENSE-APACHE b/packages/block-brokers/LICENSE-APACHE
new file mode 100644
index 000000000..14478a3b6
--- /dev/null
+++ b/packages/block-brokers/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/block-brokers/LICENSE-MIT b/packages/block-brokers/LICENSE-MIT
new file mode 100644
index 000000000..72dc60d84
--- /dev/null
+++ b/packages/block-brokers/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/block-brokers/README.md b/packages/block-brokers/README.md
new file mode 100644
index 000000000..fd49ee6e1
--- /dev/null
+++ b/packages/block-brokers/README.md
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+[](https://ipfs.tech)
+[](https://discuss.ipfs.tech)
+[](https://codecov.io/gh/ipfs/helia)
+[](https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain)
+
+> Block brokers for Helia
+
+## Install
+
+```console
+$ npm i @helia/block-brokers
+```
+
+
+
+## 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/helia/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://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
diff --git a/packages/block-brokers/package.json b/packages/block-brokers/package.json
new file mode 100644
index 000000000..370231d80
--- /dev/null
+++ b/packages/block-brokers/package.json
@@ -0,0 +1,95 @@
+{
+ "name": "@helia/block-brokers",
+ "version": "0.0.0",
+ "description": "Block brokers for Helia",
+ "license": "Apache-2.0 OR MIT",
+ "homepage": "https://github.com/ipfs/helia/tree/master/packages/block-brokers#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/ipfs/helia.git"
+ },
+ "bugs": {
+ "url": "https://github.com/ipfs/helia/issues"
+ },
+ "publishConfig": {
+ "access": "public",
+ "provenance": true
+ },
+ "keywords": [
+ "IPFS"
+ ],
+ "type": "module",
+ "types": "./dist/src/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "*",
+ "dist/*",
+ "dist/src/*",
+ "dist/src/*/index"
+ ],
+ "src/*": [
+ "*",
+ "dist/*",
+ "dist/src/*",
+ "dist/src/*/index"
+ ]
+ }
+ },
+ "files": [
+ "src",
+ "dist",
+ "!dist/test",
+ "!**/*.tsbuildinfo"
+ ],
+ "exports": {
+ ".": {
+ "types": "./dist/src/index.d.ts",
+ "import": "./dist/src/index.js"
+ }
+ },
+ "eslintConfig": {
+ "extends": "ipfs",
+ "parserOptions": {
+ "project": true,
+ "sourceType": "module"
+ }
+ },
+ "scripts": {
+ "clean": "aegir clean",
+ "lint": "aegir lint",
+ "dep-check": "aegir dep-check",
+ "build": "aegir build",
+ "test": "aegir test",
+ "test:chrome": "aegir test -t browser --cov",
+ "test:chrome-webworker": "aegir test -t webworker",
+ "test:firefox": "aegir test -t browser -- --browser firefox",
+ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
+ "test:node": "aegir test -t node --cov",
+ "test:electron-main": "aegir test -t electron-main"
+ },
+ "dependencies": {
+ "@helia/interface": "^3.0.0",
+ "@libp2p/interface": "^1.1.1",
+ "any-signal": "^4.1.1",
+ "interface-blockstore": "^5.2.7",
+ "interface-store": "^5.1.5",
+ "ipfs-bitswap": "^20.0.0",
+ "it-filter": "^3.0.4",
+ "it-foreach": "^2.0.6",
+ "multiformats": "^13.0.0",
+ "progress-events": "^1.0.0",
+ "uint8arrays": "^5.0.0"
+ },
+ "devDependencies": {
+ "@libp2p/logger": "^4.0.1",
+ "@types/sinon": "^17.0.2",
+ "aegir": "^42.0.0",
+ "blockstore-core": "^4.3.8",
+ "delay": "^6.0.0",
+ "it-all": "^3.0.4",
+ "it-drain": "^3.0.5",
+ "sinon": "^17.0.1",
+ "sinon-ts": "^2.0.0"
+ }
+}
diff --git a/packages/helia/src/block-brokers/bitswap.ts b/packages/block-brokers/src/bitswap.ts
similarity index 100%
rename from packages/helia/src/block-brokers/bitswap.ts
rename to packages/block-brokers/src/bitswap.ts
diff --git a/packages/helia/src/block-brokers/index.ts b/packages/block-brokers/src/index.ts
similarity index 61%
rename from packages/helia/src/block-brokers/index.ts
rename to packages/block-brokers/src/index.ts
index e7f503c97..004e98f03 100644
--- a/packages/helia/src/block-brokers/index.ts
+++ b/packages/block-brokers/src/index.ts
@@ -1,2 +1,3 @@
export { bitswap } from './bitswap.js'
export { trustlessGateway } from './trustless-gateway/index.js'
+export { NetworkedStorage } from './utils/networked-storage.js'
diff --git a/packages/helia/src/block-brokers/trustless-gateway/broker.ts b/packages/block-brokers/src/trustless-gateway/broker.ts
similarity index 100%
rename from packages/helia/src/block-brokers/trustless-gateway/broker.ts
rename to packages/block-brokers/src/trustless-gateway/broker.ts
diff --git a/packages/helia/src/block-brokers/trustless-gateway/index.ts b/packages/block-brokers/src/trustless-gateway/index.ts
similarity index 100%
rename from packages/helia/src/block-brokers/trustless-gateway/index.ts
rename to packages/block-brokers/src/trustless-gateway/index.ts
diff --git a/packages/helia/src/block-brokers/trustless-gateway/trustless-gateway.ts b/packages/block-brokers/src/trustless-gateway/trustless-gateway.ts
similarity index 100%
rename from packages/helia/src/block-brokers/trustless-gateway/trustless-gateway.ts
rename to packages/block-brokers/src/trustless-gateway/trustless-gateway.ts
diff --git a/packages/block-brokers/src/utils/default-hashers.ts b/packages/block-brokers/src/utils/default-hashers.ts
new file mode 100644
index 000000000..9352e8703
--- /dev/null
+++ b/packages/block-brokers/src/utils/default-hashers.ts
@@ -0,0 +1,12 @@
+import { identity } from 'multiformats/hashes/identity'
+import { sha256, sha512 } from 'multiformats/hashes/sha2'
+import type { MultihashHasher } from 'multiformats/hashes/interface'
+
+export function defaultHashers (hashers: MultihashHasher[] = []): MultihashHasher[] {
+ return [
+ sha256,
+ sha512,
+ identity,
+ ...hashers
+ ]
+}
diff --git a/packages/helia/src/utils/networked-storage.ts b/packages/block-brokers/src/utils/networked-storage.ts
similarity index 99%
rename from packages/helia/src/utils/networked-storage.ts
rename to packages/block-brokers/src/utils/networked-storage.ts
index f8e78b4bd..cb5395329 100644
--- a/packages/helia/src/utils/networked-storage.ts
+++ b/packages/block-brokers/src/utils/networked-storage.ts
@@ -199,7 +199,7 @@ export class NetworkedStorage implements Blocks, Startable {
return this.child.has(cid, options)
}
- async * getAll (options: AbortOptions & ProgressOptions = {}): AsyncIterable {
+ async * getAll (options: AbortOptions & ProgressOptions = {}): AwaitIterable {
options.onProgress?.(new CustomProgressEvent('blocks:get-all:blockstore:get-many'))
yield * this.child.getAll(options)
}
diff --git a/packages/helia/test/block-brokers/block-broker.spec.ts b/packages/block-brokers/test/block-broker.spec.ts
similarity index 95%
rename from packages/helia/test/block-brokers/block-broker.spec.ts
rename to packages/block-brokers/test/block-broker.spec.ts
index e10eb7fcf..605790fe2 100644
--- a/packages/helia/test/block-brokers/block-broker.spec.ts
+++ b/packages/block-brokers/test/block-broker.spec.ts
@@ -8,9 +8,9 @@ import all from 'it-all'
import * as raw from 'multiformats/codecs/raw'
import Sinon from 'sinon'
import { type StubbedInstance, stubInterface } from 'sinon-ts'
-import { defaultHashers } from '../../src/utils/default-hashers.js'
-import { NetworkedStorage } from '../../src/utils/networked-storage.js'
-import { createBlock } from '../fixtures/create-block.js'
+import { defaultHashers } from '../src/utils/default-hashers.js'
+import { NetworkedStorage } from '../src/utils/networked-storage.js'
+import { createBlock } from './fixtures/create-block.js'
import type { BlockBroker, BlockRetriever } from '@helia/interface/blocks'
import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'
diff --git a/packages/block-brokers/test/fixtures/create-block.ts b/packages/block-brokers/test/fixtures/create-block.ts
new file mode 100644
index 000000000..bec0ae374
--- /dev/null
+++ b/packages/block-brokers/test/fixtures/create-block.ts
@@ -0,0 +1,18 @@
+import { CID } from 'multiformats/cid'
+import { sha256 } from 'multiformats/hashes/sha2'
+import type { Blockstore } from 'interface-blockstore'
+
+export async function createBlock (codec: Codec, block: Uint8Array): Promise<{ cid: CID, block: Uint8Array }> {
+ const mh = await sha256.digest(block)
+ const cid = CID.createV1(codec, mh)
+
+ return { cid, block }
+}
+
+export async function createAndPutBlock (codec: Codec, block: Uint8Array, blockstore: Blockstore): Promise> {
+ const result = await createBlock(codec, block)
+
+ await blockstore.put(result.cid, block)
+
+ return result.cid
+}
diff --git a/packages/helia/test/block-brokers/trustless-gateway.spec.ts b/packages/block-brokers/test/trustless-gateway.spec.ts
similarity index 95%
rename from packages/helia/test/block-brokers/trustless-gateway.spec.ts
rename to packages/block-brokers/test/trustless-gateway.spec.ts
index 2b1af781e..481ac6df8 100644
--- a/packages/helia/test/block-brokers/trustless-gateway.spec.ts
+++ b/packages/block-brokers/test/trustless-gateway.spec.ts
@@ -5,9 +5,9 @@ import { expect } from 'aegir/chai'
import * as raw from 'multiformats/codecs/raw'
import Sinon from 'sinon'
import { type StubbedInstance, stubConstructor } from 'sinon-ts'
-import { TrustlessGatewayBlockBroker } from '../../src/block-brokers/trustless-gateway/broker.js'
-import { TrustlessGateway } from '../../src/block-brokers/trustless-gateway/trustless-gateway.js'
-import { createBlock } from '../fixtures/create-block.js'
+import { TrustlessGatewayBlockBroker } from '../src/trustless-gateway/broker.js'
+import { TrustlessGateway } from '../src/trustless-gateway/trustless-gateway.js'
+import { createBlock } from './fixtures/create-block.js'
import type { BlockRetriever } from '@helia/interface/blocks'
import type { CID } from 'multiformats/cid'
diff --git a/packages/helia/test/utils/networked-storage.spec.ts b/packages/block-brokers/test/utils/networked-storage.spec.ts
similarity index 100%
rename from packages/helia/test/utils/networked-storage.spec.ts
rename to packages/block-brokers/test/utils/networked-storage.spec.ts
diff --git a/packages/block-brokers/tsconfig.json b/packages/block-brokers/tsconfig.json
new file mode 100644
index 000000000..4c0bdf772
--- /dev/null
+++ b/packages/block-brokers/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "extends": "aegir/src/config/tsconfig.aegir.json",
+ "compilerOptions": {
+ "outDir": "dist"
+ },
+ "include": [
+ "src",
+ "test"
+ ],
+ "references": [
+ {
+ "path": "../interface"
+ }
+ ]
+}
diff --git a/packages/block-brokers/typedoc.json b/packages/block-brokers/typedoc.json
new file mode 100644
index 000000000..ab96e602b
--- /dev/null
+++ b/packages/block-brokers/typedoc.json
@@ -0,0 +1,7 @@
+{
+ "entryPoints": [
+ "./src/index.ts",
+ "./src/utils/default-hashers.ts"
+ ],
+ "includeVersion": true
+}
diff --git a/packages/helia/.aegir.js b/packages/helia/.aegir.js
index 84e4b05d0..d26a61578 100644
--- a/packages/helia/.aegir.js
+++ b/packages/helia/.aegir.js
@@ -11,7 +11,7 @@ const options = {
before: async () => {
// use dynamic import otherwise the source may not have been built yet
const { createHelia } = await import('./dist/src/index.js')
- const { bitswap } = await import('./dist/src/block-brokers/index.js')
+ const { bitswap } = await import('@helia/block-brokers')
const helia = await createHelia({
blockBrokers: [
diff --git a/packages/helia/package.json b/packages/helia/package.json
index 371609e69..928b6f130 100644
--- a/packages/helia/package.json
+++ b/packages/helia/package.json
@@ -47,10 +47,6 @@
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
},
- "./block-brokers": {
- "types": "./dist/src/block-brokers/index.d.ts",
- "import": "./dist/src/block-brokers/index.js"
- },
"./hashers": {
"types": "./dist/src/utils/default-hashers.d.ts",
"import": "./dist/src/utils/default-hashers.js"
@@ -81,6 +77,7 @@
"@chainsafe/libp2p-gossipsub": "^11.0.0",
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
+ "@helia/block-brokers": "^0.0.0",
"@helia/delegated-routing-v1-http-api-client": "^1.1.0",
"@helia/interface": "^3.0.0",
"@ipld/dag-cbor": "^9.0.0",
@@ -91,7 +88,7 @@
"@libp2p/circuit-relay-v2": "^1.0.2",
"@libp2p/dcutr": "^1.0.1",
"@libp2p/identify": "^1.0.1",
- "@libp2p/interface": "^1.0.1",
+ "@libp2p/interface": "^1.1.1",
"@libp2p/kad-dht": "^12.0.1",
"@libp2p/keychain": "^4.0.2",
"@libp2p/logger": "^4.0.1",
@@ -104,18 +101,14 @@
"@libp2p/webrtc": "^4.0.3",
"@libp2p/websockets": "^8.0.2",
"@libp2p/webtransport": "^4.0.3",
- "any-signal": "^4.1.1",
"blockstore-core": "^4.0.0",
"cborg": "^4.0.1",
"datastore-core": "^9.0.0",
"interface-blockstore": "^5.0.0",
"interface-datastore": "^8.0.0",
"interface-store": "^5.0.1",
- "ipfs-bitswap": "^20.0.0",
"ipns": "^8.0.0",
"it-drain": "^3.0.1",
- "it-filter": "^3.0.1",
- "it-foreach": "^2.0.2",
"libp2p": "^1.0.3",
"mortice": "^3.0.1",
"multiformats": "^13.0.0",
@@ -128,9 +121,7 @@
"@types/sinon": "^17.0.2",
"aegir": "^42.0.0",
"delay": "^6.0.0",
- "it-all": "^3.0.4",
- "sinon": "^17.0.0",
- "sinon-ts": "^2.0.0"
+ "it-all": "^3.0.4"
},
"browser": {
"./dist/src/utils/libp2p-defaults.js": "./dist/src/utils/libp2p-defaults.browser.js"
diff --git a/packages/helia/src/helia.ts b/packages/helia/src/helia.ts
index 6e4ba230b..010cb7e9a 100644
--- a/packages/helia/src/helia.ts
+++ b/packages/helia/src/helia.ts
@@ -1,12 +1,11 @@
+import { bitswap, trustlessGateway, NetworkedStorage } from '@helia/block-brokers'
import { start, stop } from '@libp2p/interface'
import drain from 'it-drain'
import { CustomProgressEvent } from 'progress-events'
-import { bitswap, trustlessGateway } from './block-brokers/index.js'
import { PinsImpl } from './pins.js'
import { BlockStorage } from './storage.js'
import { assertDatastoreVersionIsCurrent } from './utils/datastore-version.js'
import { defaultHashers } from './utils/default-hashers.js'
-import { NetworkedStorage } from './utils/networked-storage.js'
import type { HeliaInit } from '.'
import type { GCOptions, Helia } from '@helia/interface'
import type { Pins } from '@helia/interface/pins'
diff --git a/packages/helia/test/fixtures/create-helia.ts b/packages/helia/test/fixtures/create-helia.ts
index 1ac670e4c..bff75f87c 100644
--- a/packages/helia/test/fixtures/create-helia.ts
+++ b/packages/helia/test/fixtures/create-helia.ts
@@ -1,8 +1,8 @@
+import { bitswap } from '@helia/block-brokers'
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
import { identify } from '@libp2p/identify'
import { webSockets } from '@libp2p/websockets'
import * as Filters from '@libp2p/websockets/filters'
-import { bitswap } from '../../src/block-brokers/index.js'
import { createHelia as createNode } from '../../src/index.js'
import type { Helia } from '@helia/interface'
diff --git a/packages/interface/package.json b/packages/interface/package.json
index 6545496df..2e15bb8b8 100644
--- a/packages/interface/package.json
+++ b/packages/interface/package.json
@@ -70,7 +70,7 @@
"build": "aegir build"
},
"dependencies": {
- "@libp2p/interface": "^1.0.1",
+ "@libp2p/interface": "^1.1.1",
"interface-blockstore": "^5.0.0",
"interface-datastore": "^8.0.0",
"interface-store": "^5.0.1",
diff --git a/packages/interop/package.json b/packages/interop/package.json
index 2afce8a6e..be61bb977 100644
--- a/packages/interop/package.json
+++ b/packages/interop/package.json
@@ -55,6 +55,7 @@
"devDependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
+ "@helia/block-brokers": "^0.0.0",
"@helia/interface": "^3.0.0",
"@libp2p/identify": "^1.0.1",
"@libp2p/peer-id": "^4.0.3",
diff --git a/packages/interop/test/fixtures/create-helia.browser.ts b/packages/interop/test/fixtures/create-helia.browser.ts
index 6f42ff962..8a48541fc 100644
--- a/packages/interop/test/fixtures/create-helia.browser.ts
+++ b/packages/interop/test/fixtures/create-helia.browser.ts
@@ -1,12 +1,12 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
+import { bitswap } from '@helia/block-brokers'
import { identify } from '@libp2p/identify'
import { webSockets } from '@libp2p/websockets'
import { all } from '@libp2p/websockets/filters'
import { MemoryBlockstore } from 'blockstore-core'
import { MemoryDatastore } from 'datastore-core'
import { createHelia, type HeliaInit } from 'helia'
-import { bitswap } from 'helia/block-brokers'
import { createLibp2p } from 'libp2p'
import type { Helia } from '@helia/interface'
diff --git a/packages/interop/test/fixtures/create-helia.ts b/packages/interop/test/fixtures/create-helia.ts
index c35504d34..559a3fec3 100644
--- a/packages/interop/test/fixtures/create-helia.ts
+++ b/packages/interop/test/fixtures/create-helia.ts
@@ -1,11 +1,11 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
+import { bitswap } from '@helia/block-brokers'
import { identify } from '@libp2p/identify'
import { tcp } from '@libp2p/tcp'
import { MemoryBlockstore } from 'blockstore-core'
import { MemoryDatastore } from 'datastore-core'
import { createHelia, type HeliaInit } from 'helia'
-import { bitswap } from 'helia/block-brokers'
import { createLibp2p } from 'libp2p'
import type { Helia } from '@helia/interface'