diff --git a/packages/interface-stream-muxer/src/index.ts b/packages/interface-stream-muxer/src/index.ts index 6ad19dd3d..a0efad257 100644 --- a/packages/interface-stream-muxer/src/index.ts +++ b/packages/interface-stream-muxer/src/index.ts @@ -18,7 +18,7 @@ export interface StreamMuxer extends Duplex { * Initiate a new stream with the given name. If no name is * provided, the id of the stream will be used. */ - newStream: (name?: string) => Stream + newStream: (name?: string) => Stream | Promise /** * Close or abort all tracked streams and stop the muxer diff --git a/packages/interface-transport/src/index.ts b/packages/interface-transport/src/index.ts index 49c8260b7..b99a13b93 100644 --- a/packages/interface-transport/src/index.ts +++ b/packages/interface-transport/src/index.ts @@ -1,6 +1,7 @@ import type { AbortOptions } from '@libp2p/interfaces' import type { EventEmitter } from '@libp2p/interfaces/events' import type { Multiaddr } from '@multiformats/multiaddr' +import type { StreamMuxerFactory } from '@libp2p/interface-stream-muxer' import type { Connection, MultiaddrConnection } from '@libp2p/interface-connection' import type { Duplex } from 'it-stream-types' @@ -78,11 +79,18 @@ export interface UpgraderEvents { 'connectionEnd': CustomEvent } +export interface UpgradeOptions { + // Enable only if your transporter natively supports encryption and you've authenticated the remote peer manually + skipEncryption?: boolean + // Use a custom muxerfactory to upgrade the connection + withStreamMuxer?: StreamMuxerFactory +} + export interface Upgrader extends EventEmitter { /** * Upgrades an outbound connection on `transport.dial`. */ - upgradeOutbound: (maConn: MultiaddrConnection) => Promise + upgradeOutbound: (maConn: MultiaddrConnection, opts?: UpgradeOptions) => Promise /** * Upgrades an inbound connection on transport listener.