diff --git a/packages/interface-connection-encrypter-compliance-tests/package.json b/packages/interface-connection-encrypter-compliance-tests/package.json index 48bf48359..a7e697b02 100644 --- a/packages/interface-connection-encrypter-compliance-tests/package.json +++ b/packages/interface-connection-encrypter-compliance-tests/package.json @@ -142,7 +142,7 @@ "it-all": "^3.0.1", "it-pair": "^2.0.2", "it-pipe": "^3.0.1", - "it-stream-types": "^1.0.4", + "it-stream-types": "^2.0.1", "uint8arrays": "^4.0.2" }, "typedoc": { diff --git a/packages/interface-connection-encrypter-compliance-tests/src/utils/index.ts b/packages/interface-connection-encrypter-compliance-tests/src/utils/index.ts index a3c35c350..f8fadb1bc 100644 --- a/packages/interface-connection-encrypter-compliance-tests/src/utils/index.ts +++ b/packages/interface-connection-encrypter-compliance-tests/src/utils/index.ts @@ -1,12 +1,12 @@ import { duplexPair } from 'it-pair/duplex' import { multiaddr } from '@multiformats/multiaddr' import type { MultiaddrConnection } from '@libp2p/interface-connection' -import type { Duplex } from 'it-stream-types' +import type { Duplex, Source } from 'it-stream-types' export function createMaConnPair (): [MultiaddrConnection, MultiaddrConnection] { const [local, remote] = duplexPair() - function duplexToMaConn (duplex: Duplex): MultiaddrConnection { + function duplexToMaConn (duplex: Duplex, Source, Promise>): MultiaddrConnection { const output: MultiaddrConnection = { ...duplex, close: async () => {}, diff --git a/packages/interface-connection-encrypter/package.json b/packages/interface-connection-encrypter/package.json index b00e35336..cf990e2d3 100644 --- a/packages/interface-connection-encrypter/package.json +++ b/packages/interface-connection-encrypter/package.json @@ -153,8 +153,7 @@ }, "dependencies": { "@libp2p/interface-peer-id": "^2.0.0", - "it-stream-types": "^1.0.4", - "uint8arraylist": "^2.1.2" + "it-stream-types": "^2.0.1" }, "devDependencies": { "aegir": "^38.1.0" diff --git a/packages/interface-connection-encrypter/src/index.ts b/packages/interface-connection-encrypter/src/index.ts index e64ca6942..d8bcddd2e 100644 --- a/packages/interface-connection-encrypter/src/index.ts +++ b/packages/interface-connection-encrypter/src/index.ts @@ -1,5 +1,5 @@ import type { PeerId } from '@libp2p/interface-peer-id' -import type { Duplex } from 'it-stream-types' +import type { Duplex, Source } from 'it-stream-types' /** * A libp2p connection encrypter module must be compliant to this interface @@ -13,18 +13,18 @@ export interface ConnectionEncrypter { * pass it for extra verification, otherwise it will be determined during * the handshake. */ - secureOutbound: (localPeer: PeerId, connection: Duplex, remotePeer?: PeerId) => Promise> + secureOutbound: (localPeer: PeerId, connection: Duplex, Source, Promise>, remotePeer?: PeerId) => Promise> /** * Decrypt incoming data. If the remote PeerId is known, * pass it for extra verification, otherwise it will be determined during * the handshake */ - secureInbound: (localPeer: PeerId, connection: Duplex, remotePeer?: PeerId) => Promise> + secureInbound: (localPeer: PeerId, connection: Duplex, Source, Promise>, remotePeer?: PeerId) => Promise> } export interface SecuredConnection { - conn: Duplex + conn: Duplex, Source, Promise> remoteExtensions?: Extension remotePeer: PeerId } diff --git a/packages/interface-connection-gater/package.json b/packages/interface-connection-gater/package.json index 15fbcd6cd..e644fab2f 100644 --- a/packages/interface-connection-gater/package.json +++ b/packages/interface-connection-gater/package.json @@ -134,10 +134,7 @@ "dependencies": { "@libp2p/interface-connection": "^4.0.0", "@libp2p/interface-peer-id": "^2.0.0", - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^12.0.0", - "it-stream-types": "^1.0.4", - "uint8arraylist": "^2.1.2" + "@multiformats/multiaddr": "^12.0.0" }, "devDependencies": { "aegir": "^38.1.0" diff --git a/packages/interface-connection/package.json b/packages/interface-connection/package.json index fd4165f0a..9b0ddec98 100644 --- a/packages/interface-connection/package.json +++ b/packages/interface-connection/package.json @@ -155,7 +155,7 @@ "@libp2p/interface-peer-id": "^2.0.0", "@libp2p/interfaces": "^3.0.0", "@multiformats/multiaddr": "^12.0.0", - "it-stream-types": "^1.0.4", + "it-stream-types": "^2.0.1", "uint8arraylist": "^2.1.2" }, "devDependencies": { diff --git a/packages/interface-connection/src/index.ts b/packages/interface-connection/src/index.ts index 6d2dc24cb..95f6c26c5 100644 --- a/packages/interface-connection/src/index.ts +++ b/packages/interface-connection/src/index.ts @@ -1,7 +1,7 @@ import type { Multiaddr } from '@multiformats/multiaddr' import type { PeerId } from '@libp2p/interface-peer-id' import type * as Status from './status.js' -import type { Duplex } from 'it-stream-types' +import type { Duplex, Source } from 'it-stream-types' import type { AbortOptions } from '@libp2p/interfaces' import type { Uint8ArrayList } from 'uint8arraylist' @@ -72,7 +72,7 @@ export interface StreamStat { * It may be encrypted and multiplexed depending on the * configuration of the nodes. */ -export interface Stream extends Duplex { +export interface Stream extends Duplex, Source> { /** * Closes the stream for **reading** *and* **writing**. * @@ -183,7 +183,7 @@ export interface MultiaddrConnectionTimeline { * a peer. It is a low-level primitive and is the raw connection * without encryption or stream multiplexing. */ -export interface MultiaddrConnection extends Duplex { +export interface MultiaddrConnection extends Duplex, Source, Promise> { close: (err?: Error) => Promise remoteAddr: Multiaddr timeline: MultiaddrConnectionTimeline diff --git a/packages/interface-mocks/package.json b/packages/interface-mocks/package.json index 8b1ef870c..ef0c88347 100644 --- a/packages/interface-mocks/package.json +++ b/packages/interface-mocks/package.json @@ -153,20 +153,20 @@ "@libp2p/interface-transport": "^2.0.0", "@libp2p/interfaces": "^3.0.0", "@libp2p/logger": "^2.0.0", - "@libp2p/multistream-select": "^3.0.0", + "@libp2p/multistream-select": "^3.1.6", "@libp2p/peer-collections": "^3.0.1", "@libp2p/peer-id": "^2.0.0", "@libp2p/peer-id-factory": "^2.0.0", "@multiformats/multiaddr": "^12.0.0", "abortable-iterator": "^4.0.2", "any-signal": "^4.1.1", - "it-handshake": "^4.0.0", + "it-handshake": "^4.1.3", "it-map": "^3.0.2", "it-ndjson": "^1.0.0", "it-pair": "^2.0.2", "it-pipe": "^3.0.1", - "it-pushable": "^3.0.0", - "it-stream-types": "^1.0.4", + "it-pushable": "^3.1.3", + "it-stream-types": "^2.0.1", "merge-options": "^3.0.4", "uint8arraylist": "^2.1.2", "uint8arrays": "^4.0.2" diff --git a/packages/interface-mocks/src/connection-encrypter.ts b/packages/interface-mocks/src/connection-encrypter.ts index f40f78fbc..c06816714 100644 --- a/packages/interface-mocks/src/connection-encrypter.ts +++ b/packages/interface-mocks/src/connection-encrypter.ts @@ -9,7 +9,7 @@ import type { Transform, Source } from 'it-stream-types' import map from 'it-map' // A basic transform that does nothing to the data -const transform = (): Transform => { +const transform = (): Transform, AsyncGenerator> => { return (source: Source) => (async function * () { for await (const chunk of source) { yield chunk diff --git a/packages/interface-mocks/src/connection.ts b/packages/interface-mocks/src/connection.ts index 6c2c959b2..e291d99c3 100644 --- a/packages/interface-mocks/src/connection.ts +++ b/packages/interface-mocks/src/connection.ts @@ -2,7 +2,7 @@ import { peerIdFromString } from '@libp2p/peer-id' import { pipe } from 'it-pipe' import { duplexPair } from 'it-pair/duplex' import type { MultiaddrConnection, Connection, Stream, ConnectionStat, Direction } from '@libp2p/interface-connection' -import type { Duplex } from 'it-stream-types' +import type { Duplex, Source } from 'it-stream-types' import { mockMuxer } from './muxer.js' import type { PeerId } from '@libp2p/interface-peer-id' import { mockMultiaddrConnection } from './multiaddr-connection.js' @@ -79,7 +79,7 @@ class MockConnection implements Connection { } const id = `${Math.random()}` - const stream: Stream = await this.muxer.newStream(id) + const stream = await this.muxer.newStream(id) const result = await mss.select(stream, protocols, options) const streamWithProtocol: Stream = { @@ -170,7 +170,7 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio return connection } -export function mockStream (stream: Duplex): Stream { +export function mockStream (stream: Duplex, Source>): Stream { return { ...stream, close: () => {}, diff --git a/packages/interface-mocks/src/duplex.ts b/packages/interface-mocks/src/duplex.ts index 1871cdcb8..b4de1fd00 100644 --- a/packages/interface-mocks/src/duplex.ts +++ b/packages/interface-mocks/src/duplex.ts @@ -1,6 +1,6 @@ import type { Duplex } from 'it-stream-types' -export function mockDuplex (): Duplex { +export function mockDuplex (): Duplex> { return { source: [], sink: async () => {} diff --git a/packages/interface-mocks/src/multiaddr-connection.ts b/packages/interface-mocks/src/multiaddr-connection.ts index 9a50f35b8..b15845f42 100644 --- a/packages/interface-mocks/src/multiaddr-connection.ts +++ b/packages/interface-mocks/src/multiaddr-connection.ts @@ -6,7 +6,7 @@ import type { Duplex } from 'it-stream-types' import type { PeerId } from '@libp2p/interface-peer-id' import type { Multiaddr } from '@multiformats/multiaddr' -export function mockMultiaddrConnection (source: Duplex & Partial, peerId: PeerId): MultiaddrConnection { +export function mockMultiaddrConnection (source: Duplex> & Partial, peerId: PeerId): MultiaddrConnection { const maConn: MultiaddrConnection = { async close () { diff --git a/packages/interface-mocks/src/muxer.ts b/packages/interface-mocks/src/muxer.ts index fb31ad38c..b250a8399 100644 --- a/packages/interface-mocks/src/muxer.ts +++ b/packages/interface-mocks/src/muxer.ts @@ -263,7 +263,7 @@ class MuxedStream { } class MockMuxer implements StreamMuxer { - public source: Source + public source: AsyncGenerator public input: Pushable public streamInput: Pushable public name: string @@ -298,7 +298,7 @@ class MockMuxer implements StreamMuxer { } // receive incoming messages - async sink (source: Source): Promise { + async sink (source: Source): Promise { try { await pipe( abortableSource(source, this.closeController.signal), diff --git a/packages/interface-pubsub/package.json b/packages/interface-pubsub/package.json index 2e952ceb1..b6082d221 100644 --- a/packages/interface-pubsub/package.json +++ b/packages/interface-pubsub/package.json @@ -135,7 +135,7 @@ "@libp2p/interface-connection": "^4.0.0", "@libp2p/interface-peer-id": "^2.0.0", "@libp2p/interfaces": "^3.0.0", - "it-pushable": "^3.0.0", + "it-pushable": "^3.1.3", "uint8arraylist": "^2.1.2" }, "devDependencies": { diff --git a/packages/interface-stream-muxer-compliance-tests/package.json b/packages/interface-stream-muxer-compliance-tests/package.json index 1aa8e1a08..f3d69277d 100644 --- a/packages/interface-stream-muxer-compliance-tests/package.json +++ b/packages/interface-stream-muxer-compliance-tests/package.json @@ -143,7 +143,7 @@ "it-map": "^3.0.2", "it-pair": "^2.0.2", "it-pipe": "^3.0.1", - "it-stream-types": "^1.0.4", + "it-stream-types": "^2.0.1", "p-defer": "^4.0.0", "p-limit": "^4.0.0", "uint8arraylist": "^2.1.2", diff --git a/packages/interface-stream-muxer-compliance-tests/src/close-test.ts b/packages/interface-stream-muxer-compliance-tests/src/close-test.ts index 95cbfa571..003653dec 100644 --- a/packages/interface-stream-muxer-compliance-tests/src/close-test.ts +++ b/packages/interface-stream-muxer-compliance-tests/src/close-test.ts @@ -302,7 +302,6 @@ export default (common: TestSetup): void => { // Source should be done void Promise.resolve().then(async () => { - // @ts-expect-error next is part of the iterable protocol expect(await stream.source.next()).to.have.property('done', true) await stream.sink(data) }) diff --git a/packages/interface-stream-muxer/package.json b/packages/interface-stream-muxer/package.json index f1fd3be62..130f3ab74 100644 --- a/packages/interface-stream-muxer/package.json +++ b/packages/interface-stream-muxer/package.json @@ -134,7 +134,8 @@ "dependencies": { "@libp2p/interface-connection": "^4.0.0", "@libp2p/interfaces": "^3.0.0", - "it-stream-types": "^1.0.4" + "it-stream-types": "^2.0.1", + "uint8arraylist": "^2.4.3" }, "devDependencies": { "aegir": "^38.1.0" diff --git a/packages/interface-stream-muxer/src/index.ts b/packages/interface-stream-muxer/src/index.ts index a3ff31d90..cf2aa57e9 100644 --- a/packages/interface-stream-muxer/src/index.ts +++ b/packages/interface-stream-muxer/src/index.ts @@ -1,6 +1,7 @@ -import type { Duplex } from 'it-stream-types' +import type { Duplex, Source } from 'it-stream-types' import type { Direction, Stream } from '@libp2p/interface-connection' import type { AbortOptions } from '@libp2p/interfaces' +import type { Uint8ArrayList } from 'uint8arraylist' export interface StreamMuxerFactory { /** @@ -17,7 +18,7 @@ export interface StreamMuxerFactory { /** * A libp2p stream muxer */ -export interface StreamMuxer extends Duplex { +export interface StreamMuxer extends Duplex, Source, Promise> { /** * The protocol used to select this muxer during connection opening */ diff --git a/packages/interface-transport/package.json b/packages/interface-transport/package.json index 01c2462c8..31f6be57b 100644 --- a/packages/interface-transport/package.json +++ b/packages/interface-transport/package.json @@ -136,7 +136,7 @@ "@libp2p/interface-stream-muxer": "^3.0.0", "@libp2p/interfaces": "^3.0.0", "@multiformats/multiaddr": "^12.0.0", - "it-stream-types": "^1.0.4" + "it-stream-types": "^2.0.1" }, "devDependencies": { "aegir": "^38.1.0"