Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

deps!: bump it-stream-types from 1.0.5 to 2.0.1 #362

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Uint8Array>()

function duplexToMaConn (duplex: Duplex<Uint8Array>): MultiaddrConnection {
function duplexToMaConn (duplex: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>): MultiaddrConnection {
const output: MultiaddrConnection = {
...duplex,
close: async () => {},
Expand Down
3 changes: 1 addition & 2 deletions packages/interface-connection-encrypter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions packages/interface-connection-encrypter/src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,18 +13,18 @@ export interface ConnectionEncrypter<Extension = unknown> {
* pass it for extra verification, otherwise it will be determined during
* the handshake.
*/
secureOutbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>
secureOutbound: (localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>

/**
* 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<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>
secureInbound: (localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>
}

export interface SecuredConnection<Extension = unknown> {
conn: Duplex<Uint8Array>
conn: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>
remoteExtensions?: Extension
remotePeer: PeerId
}
5 changes: 1 addition & 4 deletions packages/interface-connection-gater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-connection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions packages/interface-connection/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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<Uint8ArrayList, Uint8ArrayList | Uint8Array> {
export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>> {
/**
* Closes the stream for **reading** *and* **writing**.
*
Expand Down Expand Up @@ -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<Uint8Array> {
export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> {
close: (err?: Error) => Promise<void>
remoteAddr: Multiaddr
timeline: MultiaddrConnectionTimeline
Expand Down
8 changes: 4 additions & 4 deletions packages/interface-mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-mocks/src/connection-encrypter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T>(): Transform<T, T> => {
const transform = <T>(): Transform<Source<T>, AsyncGenerator<T>> => {
return (source: Source<T>) => (async function * () {
for await (const chunk of source) {
yield chunk
Expand Down
6 changes: 3 additions & 3 deletions packages/interface-mocks/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -170,7 +170,7 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio
return connection
}

export function mockStream (stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>): Stream {
export function mockStream (stream: Duplex<AsyncGenerator<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>>): Stream {
return {
...stream,
close: () => {},
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-mocks/src/duplex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Duplex } from 'it-stream-types'

export function mockDuplex (): Duplex<Uint8Array> {
export function mockDuplex (): Duplex<Iterable<Uint8Array>> {
return {
source: [],
sink: async () => {}
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-mocks/src/multiaddr-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint8Array> & Partial<MultiaddrConnection>, peerId: PeerId): MultiaddrConnection {
export function mockMultiaddrConnection (source: Duplex<AsyncGenerator<Uint8Array>> & Partial<MultiaddrConnection>, peerId: PeerId): MultiaddrConnection {
const maConn: MultiaddrConnection = {
async close () {

Expand Down
4 changes: 2 additions & 2 deletions packages/interface-mocks/src/muxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class MuxedStream {
}

class MockMuxer implements StreamMuxer {
public source: Source<Uint8Array>
public source: AsyncGenerator<Uint8Array>
public input: Pushable<Uint8Array>
public streamInput: Pushable<StreamMessage>
public name: string
Expand Down Expand Up @@ -298,7 +298,7 @@ class MockMuxer implements StreamMuxer {
}

// receive incoming messages
async sink (source: Source<Uint8Array>): Promise<void> {
async sink (source: Source<Uint8ArrayList | Uint8Array>): Promise<void> {
try {
await pipe(
abortableSource(source, this.closeController.signal),
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export default (common: TestSetup<StreamMuxerFactory>): 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)
})
Expand Down
3 changes: 2 additions & 1 deletion packages/interface-stream-muxer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions packages/interface-stream-muxer/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand All @@ -17,7 +18,7 @@ export interface StreamMuxerFactory {
/**
* A libp2p stream muxer
*/
export interface StreamMuxer extends Duplex<Uint8Array> {
export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8ArrayList | Uint8Array>, Promise<void>> {
/**
* The protocol used to select this muxer during connection opening
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-transport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down