@libp2p/interface 2.11.0 → 3.0.0-049bfa0fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/index.min.js +1 -1
  2. package/dist/index.min.js.map +4 -4
  3. package/dist/src/connection-encrypter.d.ts +17 -15
  4. package/dist/src/connection-encrypter.d.ts.map +1 -1
  5. package/dist/src/connection-gater.d.ts +1 -2
  6. package/dist/src/connection-gater.d.ts.map +1 -1
  7. package/dist/src/connection-protector.d.ts +9 -0
  8. package/dist/src/connection-protector.d.ts.map +1 -0
  9. package/dist/src/connection-protector.js +2 -0
  10. package/dist/src/connection-protector.js.map +1 -0
  11. package/dist/src/connection.d.ts +36 -233
  12. package/dist/src/connection.d.ts.map +1 -1
  13. package/dist/src/connection.js.map +1 -1
  14. package/dist/src/errors.d.ts +14 -0
  15. package/dist/src/errors.d.ts.map +1 -1
  16. package/dist/src/errors.js +20 -0
  17. package/dist/src/errors.js.map +1 -1
  18. package/dist/src/events.d.ts +26 -0
  19. package/dist/src/events.d.ts.map +1 -0
  20. package/dist/src/events.js +36 -0
  21. package/dist/src/events.js.map +1 -0
  22. package/dist/src/index.d.ts +35 -5
  23. package/dist/src/index.d.ts.map +1 -1
  24. package/dist/src/index.js +7 -3
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/message-stream.d.ts +159 -0
  27. package/dist/src/message-stream.d.ts.map +1 -0
  28. package/dist/src/message-stream.js +2 -0
  29. package/dist/src/message-stream.js.map +1 -0
  30. package/dist/src/metrics.d.ts +2 -2
  31. package/dist/src/metrics.d.ts.map +1 -1
  32. package/dist/src/multiaddr-connection.d.ts +25 -0
  33. package/dist/src/multiaddr-connection.d.ts.map +1 -0
  34. package/dist/src/multiaddr-connection.js +2 -0
  35. package/dist/src/multiaddr-connection.js.map +1 -0
  36. package/dist/src/peer-store.d.ts +0 -4
  37. package/dist/src/peer-store.d.ts.map +1 -1
  38. package/dist/src/stream-handler.d.ts +12 -13
  39. package/dist/src/stream-handler.d.ts.map +1 -1
  40. package/dist/src/stream-muxer.d.ts +113 -30
  41. package/dist/src/stream-muxer.d.ts.map +1 -1
  42. package/dist/src/stream.d.ts +63 -0
  43. package/dist/src/stream.d.ts.map +1 -0
  44. package/dist/src/stream.js +2 -0
  45. package/dist/src/stream.js.map +1 -0
  46. package/dist/src/topology.d.ts +3 -3
  47. package/dist/src/topology.d.ts.map +1 -1
  48. package/dist/src/transport.d.ts +20 -13
  49. package/dist/src/transport.d.ts.map +1 -1
  50. package/dist/src/transport.js.map +1 -1
  51. package/package.json +4 -6
  52. package/src/connection-encrypter.ts +19 -16
  53. package/src/connection-gater.ts +1 -2
  54. package/src/connection-protector.ts +9 -0
  55. package/src/connection.ts +38 -270
  56. package/src/errors.ts +24 -0
  57. package/src/events.ts +44 -0
  58. package/src/index.ts +38 -5
  59. package/src/message-stream.ts +183 -0
  60. package/src/metrics.ts +2 -2
  61. package/src/multiaddr-connection.ts +27 -0
  62. package/src/peer-store.ts +0 -5
  63. package/src/stream-handler.ts +14 -15
  64. package/src/stream-muxer.ts +122 -30
  65. package/src/stream.ts +70 -0
  66. package/src/topology.ts +3 -3
  67. package/src/transport.ts +25 -14
  68. package/dist/src/pubsub.d.ts +0 -248
  69. package/dist/src/pubsub.d.ts.map +0 -1
  70. package/dist/src/pubsub.js +0 -47
  71. package/dist/src/pubsub.js.map +0 -1
  72. package/dist/typedoc-urls.json +0 -223
  73. package/src/pubsub.ts +0 -286
@@ -1,59 +1,142 @@
1
- import type { Direction, Stream } from './connection.js';
2
- import type { AbortOptions, Logger } from './index.js';
3
- import type { Duplex } from 'it-stream-types';
4
- import type { Uint8ArrayList } from 'uint8arraylist';
5
- export interface StreamMuxerFactory {
1
+ import type { Stream, TypedEventTarget, MessageStream, AbortOptions } from './index.js';
2
+ /**
3
+ * User-facing message stream muxer options
4
+ */
5
+ export interface StreamMuxerOptions<MuxedStreamOptions extends StreamOptions = StreamOptions> {
6
6
  /**
7
- * The protocol used to select this muxer during connection opening
7
+ * Configuration options for each outgoing/incoming stream
8
8
  */
9
- protocol: string;
9
+ streamOptions?: MuxedStreamOptions;
10
10
  /**
11
- * Creates a new stream muxer to be used with a new connection
11
+ * libp2p is notified of incoming streams via the muxer's 'stream' event.
12
+ *
13
+ * During connection establishment there may be a small window where a muxer
14
+ * starts to process incoming stream data before a listener has been added for
15
+ * the 'stream' event.
16
+ *
17
+ * If no handler is registered for this event incoming streams can be missed
18
+ * so when this is the case muxers queue streams internally as "early
19
+ * streams", and will defer emitting the 'stream' event until after a listener
20
+ * has been registered.
21
+ *
22
+ * Allowing an unlimited amount of early streams can cause excessive memory
23
+ * consumption so this setting controls how many early streams to store when
24
+ * no 'stream' listener has been registered.
25
+ *
26
+ * If more streams than this are opened before a listener is added the muxed
27
+ * connection will be reset.
28
+ *
29
+ * @default 10
30
+ */
31
+ maxEarlyStreams?: number;
32
+ /**
33
+ * Maximum size of a message in bytes that we'll send on a stream - this
34
+ * ensures that a single stream doesn't hog a connection
35
+ *
36
+ * @default 65_536
37
+ */
38
+ maxMessageSize?: number;
39
+ /**
40
+ * Maximum number of concurrent inbound streams that we accept - if the peer
41
+ * tries to open more streams, those will be reset immediately
42
+ *
43
+ * @default 1_000
12
44
  */
13
- createStreamMuxer(init?: StreamMuxerInit): StreamMuxer;
45
+ maxInboundStreams?: number;
46
+ /**
47
+ * Maximum number of concurrent outbound streams that we accept - if the
48
+ * application tries to open more streams, the call to `newStream` will throw
49
+ *
50
+ * @default 1_000
51
+ */
52
+ maxOutboundStreams?: number;
14
53
  }
15
54
  /**
16
- * A libp2p stream muxer
55
+ * User-facing message stream options
17
56
  */
18
- export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
57
+ export interface StreamOptions {
58
+ /**
59
+ * If no data is sent or received in this number of ms the stream will be
60
+ * reset and an 'error' event emitted.
61
+ *
62
+ * @default 120_000
63
+ */
64
+ inactivityTimeout?: number;
65
+ /**
66
+ * The maximum number of bytes to store when paused or before a 'message'
67
+ * event handler is added.
68
+ *
69
+ * If the internal buffer overflows this value the stream will be reset.
70
+ *
71
+ * @default 4_194_304
72
+ */
73
+ maxReadBufferLength?: number;
74
+ /**
75
+ * The maximum number of bytes to store when the remote end of the stream is
76
+ * applying backpressure, or when it is slow to accept new bytes.
77
+ *
78
+ * If the internal buffer overflows this value the stream will be reset.
79
+ *
80
+ * @default Infinity
81
+ */
82
+ maxWriteBufferLength?: number;
83
+ }
84
+ export interface StreamMuxerFactory<Muxer extends StreamMuxer = StreamMuxer> {
19
85
  /**
20
86
  * The protocol used to select this muxer during connection opening
21
87
  */
22
88
  protocol: string;
23
89
  /**
24
- * A list of streams that are currently open. Closed streams will not be returned.
90
+ * Creates a new stream muxer to be used with a new connection
25
91
  */
26
- readonly streams: Stream[];
92
+ createStreamMuxer(maConn: MessageStream): Muxer;
93
+ }
94
+ export interface StreamMuxerEvents<MuxedStream extends Stream = Stream> {
27
95
  /**
28
- * Initiate a new stream with the given name. If no name is
29
- * provided, the id of the stream will be used.
96
+ * An incoming stream was created
30
97
  */
31
- newStream(name?: string): Stream | Promise<Stream>;
98
+ stream: CustomEvent<MuxedStream>;
99
+ }
100
+ export interface CreateStreamOptions extends AbortOptions, StreamOptions {
32
101
  /**
33
- * Close or abort all tracked streams and stop the muxer
102
+ * If a single protocol was requested and the muxer has support for this,
103
+ * pre-negotiate the protocol using this value, otherwise multistream-select
104
+ * will be run over the stream after opening.
34
105
  */
35
- close(options?: AbortOptions): Promise<void>;
106
+ protocol?: string;
107
+ }
108
+ export type StreamMuxerStatus = 'open' | 'closing' | 'closed';
109
+ /**
110
+ * A libp2p stream muxer
111
+ */
112
+ export interface StreamMuxer<MuxedStream extends Stream = Stream> extends TypedEventTarget<StreamMuxerEvents<MuxedStream>> {
36
113
  /**
37
- * Close or abort all tracked streams and stop the muxer
114
+ * The protocol used to select this muxer during connection opening
38
115
  */
39
- abort(err: Error): void;
40
- }
41
- export interface StreamMuxerInit {
116
+ protocol: string;
42
117
  /**
43
- * A callback function invoked every time an incoming stream is opened
118
+ * A list of streams that are currently open
44
119
  */
45
- onIncomingStream?(stream: Stream): void;
120
+ streams: MuxedStream[];
46
121
  /**
47
- * A callback function invoke every time a stream ends
122
+ * The status of the muxer
48
123
  */
49
- onStreamEnd?(stream: Stream): void;
124
+ status: StreamMuxerStatus;
50
125
  /**
51
- * Outbound stream muxers are opened by the local node, inbound stream muxers are opened by the remote
126
+ * Create a new stream
52
127
  */
53
- direction?: Direction;
128
+ createStream(options?: CreateStreamOptions): Promise<MuxedStream>;
54
129
  /**
55
- * The logger used by the connection
130
+ * Immediately close the muxer, abort every open stream and discard any
131
+ * unsent/unread data.
56
132
  */
57
- log?: Logger;
133
+ abort(err: Error): void;
134
+ /**
135
+ * Gracefully close the muxer. All open streams will be gracefully closed, and
136
+ * the returned promise will either resolve when any/all unsent data has been
137
+ * sent, or it will reject if the passed abort signal fires before this
138
+ * happens.
139
+ */
140
+ close(options?: AbortOptions): Promise<void>;
58
141
  }
59
142
  //# sourceMappingURL=stream-muxer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream-muxer.d.ts","sourceRoot":"","sources":["../../src/stream-muxer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,iBAAiB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW,CAAA;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,c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"}
@@ -0,0 +1,63 @@
1
+ import type { AbortOptions } from './index.ts';
2
+ import type { MessageStream, MessageStreamReadStatus, MessageStreamWriteStatus } from './message-stream.js';
3
+ /**
4
+ * A Stream is a lightweight data channel between two peers that can be written
5
+ * to and read from at both ends.
6
+ *
7
+ * It is half-closable - that is in order for it to be closed fully and any
8
+ * associated memory reclaimed, both ends must close their writeable end of the
9
+ * stream.
10
+ *
11
+ * It's also possible to close the readable end of the stream, but this depends
12
+ * on the underlying stream muxer supporting this operation which not all do.
13
+ */
14
+ export interface Stream extends MessageStream {
15
+ /**
16
+ * Unique identifier for a stream. Identifiers are not unique across muxers.
17
+ */
18
+ id: string;
19
+ /**
20
+ * The protocol negotiated for this stream
21
+ */
22
+ protocol: string;
23
+ /**
24
+ * The status of the readable end of the stream
25
+ */
26
+ readStatus: MessageStreamReadStatus;
27
+ /**
28
+ * The status of the writable end of the stream
29
+ */
30
+ writeStatus: MessageStreamWriteStatus;
31
+ /**
32
+ * The status of the readable end of the remote end of the stream - n.b. this
33
+ * requires the underlying stream transport to support sending STOP_SENDING
34
+ * messages or similar.
35
+ */
36
+ remoteReadStatus: MessageStreamReadStatus;
37
+ /**
38
+ * The status of the writable end of the remote end of the stream
39
+ */
40
+ remoteWriteStatus: MessageStreamWriteStatus;
41
+ /**
42
+ * Close stream for writing and return a promise that resolves once any
43
+ * pending data has been passed to the underlying transport.
44
+ *
45
+ * Note that the stream itself will remain readable until the remote end also
46
+ * closes it's writable end.
47
+ *
48
+ * To close without waiting for the remote, call `.abort` instead. If you want
49
+ * to wait for data to be sent first, ensure if the `.writableStatus` property
50
+ * is not 'paused', if it is, wait for a `drain` event before aborting.
51
+ */
52
+ close(options?: AbortOptions): Promise<void>;
53
+ /**
54
+ * Send a message to the remote end of the stream informing them that any
55
+ * incoming data will be discarded so they should stop sending.
56
+ *
57
+ * This requires the underlying resource to support this operation - for
58
+ * example the QUIC, WebTransport, WebRTC transports do but anything
59
+ * multiplexed using Yamux or Mplex do not.
60
+ */
61
+ closeRead(options?: AbortOptions): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAE3G;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAO,SAAQ,aAAa;IAC3C;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,UAAU,EAAE,uBAAuB,CAAA;IAEnC;;OAEG;IACH,WAAW,EAAE,wBAAwB,CAAA;IAErC;;;;OAIG;IACH,gBAAgB,EAAE,uBAAuB,CAAA;IAEzC;;OAEG;IACH,iBAAiB,EAAE,wBAAwB,CAAA;IAE3C;;;;;;;;;;OAUG;IACH,KAAK,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7C;;;;;;;OAOG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":""}
@@ -4,7 +4,7 @@ import type { PeerId } from './peer-id.js';
4
4
  * A topology filter - this can be used by topologies to ensure they do not
5
5
  * receive duplicate notifications of individual peers
6
6
  *
7
- * @see https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerFilter-1.html
7
+ * @see https://libp2p.github.io/js-libp2p/classes/_libp2p_peer-collections.PeerFilter.html
8
8
  */
9
9
  export interface TopologyFilter {
10
10
  has(peerId: PeerId): boolean;
@@ -36,11 +36,11 @@ export interface Topology {
36
36
  * Invoked when a new connection is opened to a peer that supports the
37
37
  * registered protocol
38
38
  */
39
- onConnect?(peerId: PeerId, conn: Connection): void;
39
+ onConnect?(peerId: PeerId, conn: Connection): void | Promise<void>;
40
40
  /**
41
41
  * Invoked when the last connection to a peer that supports the registered
42
42
  * protocol closes
43
43
  */
44
- onDisconnect?(peerId: PeerId): void;
44
+ onDisconnect?(peerId: PeerId): void | Promise<void>;
45
45
  }
46
46
  //# sourceMappingURL=topology.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/topology.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IAEvB;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAElD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
1
+ {"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/topology.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IAEvB;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAElE;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpD"}
@@ -1,6 +1,4 @@
1
- import type { Connection, ConnectionLimits, MultiaddrConnection } from './connection.js';
2
- import type { AbortOptions, ClearableSignal, ConnectionEncrypter } from './index.js';
3
- import type { StreamMuxerFactory } from './stream-muxer.js';
1
+ import type { AbortOptions, ClearableSignal, ConnectionEncrypter, MultiaddrConnection, Connection, ConnectionLimits, StreamMuxerFactory, PeerId } from './index.js';
4
2
  import type { Multiaddr } from '@multiformats/multiaddr';
5
3
  import type { TypedEventTarget } from 'main-event';
6
4
  import type { ProgressOptions, ProgressEvent } from 'progress-events';
@@ -114,14 +112,6 @@ export declare enum FaultTolerance {
114
112
  * Options accepted by the upgrader during connection establishment
115
113
  */
116
114
  export interface UpgraderOptions<ConnectionUpgradeEvents extends ProgressEvent = ProgressEvent> extends ProgressOptions<ConnectionUpgradeEvents>, Required<AbortOptions> {
117
- /**
118
- * If true the invoking transport is expected to implement it's own encryption
119
- * and an encryption protocol will not attempted to be negotiated via
120
- * multi-stream select
121
- *
122
- * @default false
123
- */
124
- skipEncryption?: boolean;
125
115
  /**
126
116
  * If true no connection protection will be performed on the connection.
127
117
  */
@@ -147,18 +137,35 @@ export interface UpgraderOptions<ConnectionUpgradeEvents extends ProgressEvent =
147
137
  */
148
138
  initiator?: boolean;
149
139
  }
140
+ /**
141
+ * Options accepted by the upgrader during connection establishment
142
+ */
143
+ export interface UpgraderWithoutEncryptionOptions extends UpgraderOptions {
144
+ /**
145
+ * If true the invoking transport is expected to implement it's own encryption
146
+ * and an encryption protocol will not attempted to be negotiated via
147
+ * multi-stream select
148
+ */
149
+ skipEncryption: true;
150
+ /**
151
+ * If `skipEncryption` is true, a remote PeerId must be supplied
152
+ */
153
+ remotePeer: PeerId;
154
+ }
150
155
  export type InboundConnectionUpgradeEvents = ProgressEvent<'upgrader:encrypt-inbound-connection'> | ProgressEvent<'upgrader:multiplex-inbound-connection'>;
151
156
  export type OutboundConnectionUpgradeEvents = ProgressEvent<'upgrader:encrypt-outbound-connection'> | ProgressEvent<'upgrader:multiplex-outbound-connection'>;
152
157
  export interface Upgrader {
153
158
  /**
154
159
  * Upgrades an outbound connection created by the `dial` method of a transport
155
160
  */
156
- upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>;
161
+ upgradeOutbound(maConn: MultiaddrConnection, opts: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>;
162
+ upgradeOutbound(maConn: MultiaddrConnection, opts: UpgraderWithoutEncryptionOptions): Promise<Connection>;
157
163
  /**
158
164
  * Upgrades an inbound connection received by a transport listener and
159
165
  * notifies other libp2p components about the new connection
160
166
  */
161
- upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>;
167
+ upgradeInbound(maConn: MultiaddrConnection, opts: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>;
168
+ upgradeInbound(maConn: MultiaddrConnection, opts: UpgraderWithoutEncryptionOptions): Promise<void>;
162
169
  /**
163
170
  * Used by transports that perform part of the upgrade process themselves and
164
171
  * do some async work. This allows configuring inbound upgrade timeouts from a
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,SAAS,EAAE,WAAW,CAAA;IAEtB;;OAEG;IACH,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IAEzB;;;OAGG;IACH,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,WAAW,QAAS,SAAQ,gBAAgB,CAAC,cAAc,CAAC;IAChE;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C;;OAEG;IACH,QAAQ,IAAI,SAAS,EAAE,CAAA;IACvB;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB;;;OAGG;IACH,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;CAC9C;AAED,eAAO,MAAM,eAAe,eAAkC,CAAA;AAE9D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,UAAU,EAAE,SAAS,EAAE,GAA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CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACzH,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,gCAAgC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEzG;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,eAAe,CAAC,8BAA8B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAElG;;;;;;;OAOG;IACH,wBAAwB,CAAE,MAAM,EAAE,WAAW,GAAG,eAAe,CAAA;IAE/D;;OAEG;IACH,eAAe,IAAK,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAEnD;;OAEG;IACH,uBAAuB,IAAK,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;CAC7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AA8D9D;;GAEG;AACH,MAAM,UAAU,WAAW,CAAE,KAAW;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAA;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB;;OAEG;IACH,6DAAa,CAAA;IAEb;;OAEG;IACH,2DAAQ,CAAA;AACV,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB"}
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAiDA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AA8D9D;;GAEG;AACH,MAAM,UAAU,WAAW,CAAE,KAAW;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAA;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB;;OAEG;IACH,6DAAa,CAAA;IAEb;;OAEG;IACH,2DAAQ,CAAA;AACV,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interface",
3
- "version": "2.11.0",
3
+ "version": "3.0.0-049bfa0fa",
4
4
  "description": "The interface implemented by a libp2p node",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
@@ -42,16 +42,14 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@multiformats/dns": "^1.0.6",
45
- "@multiformats/multiaddr": "^12.4.4",
46
- "it-pushable": "^3.2.3",
47
- "it-stream-types": "^2.0.2",
45
+ "@multiformats/multiaddr": "^13.0.1",
48
46
  "main-event": "^1.0.1",
49
- "multiformats": "^13.3.6",
47
+ "multiformats": "^13.4.0",
50
48
  "progress-events": "^1.0.1",
51
49
  "uint8arraylist": "^2.4.8"
52
50
  },
53
51
  "devDependencies": {
54
- "aegir": "^47.0.14"
52
+ "aegir": "^47.0.22"
55
53
  },
56
54
  "sideEffects": false
57
55
  }
@@ -1,8 +1,4 @@
1
- import type { MultiaddrConnection } from './connection.js'
2
- import type { AbortOptions, Logger, StreamMuxerFactory } from './index.js'
3
- import type { PeerId } from './peer-id.js'
4
- import type { Duplex } from 'it-stream-types'
5
- import type { Uint8ArrayList } from 'uint8arraylist'
1
+ import type { AbortOptions, StreamMuxerFactory, PeerId, MessageStream } from './index.js'
6
2
 
7
3
  /**
8
4
  * If the remote PeerId is known and passed as an option, the securing operation
@@ -10,6 +6,9 @@ import type { Uint8ArrayList } from 'uint8arraylist'
10
6
  * corresponds to the public key the remote PeerId is derived from.
11
7
  */
12
8
  export interface SecureConnectionOptions extends AbortOptions {
9
+ /**
10
+ * This will be set if the remote peer is known in advance
11
+ */
13
12
  remotePeer?: PeerId
14
13
 
15
14
  /**
@@ -21,13 +20,6 @@ export interface SecureConnectionOptions extends AbortOptions {
21
20
  skipStreamMuxerNegotiation?: boolean
22
21
  }
23
22
 
24
- /**
25
- * A stream with an optional logger
26
- */
27
- export interface SecurableStream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
28
- log?: Logger
29
- }
30
-
31
23
  /**
32
24
  * A libp2p connection encrypter module must be compliant to this interface
33
25
  * to ensure all exchanged data between two peers is encrypted.
@@ -40,19 +32,30 @@ export interface ConnectionEncrypter<Extension = unknown> {
40
32
  * pass it for extra verification, otherwise it will be determined during
41
33
  * the handshake.
42
34
  */
43
- secureOutbound <Stream extends SecurableStream = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
35
+ secureOutbound (connection: MessageStream, options?: SecureConnectionOptions): Promise<SecuredConnection<Extension>>
44
36
 
45
37
  /**
46
38
  * Decrypt incoming data. If the remote PeerId is known,
47
39
  * pass it for extra verification, otherwise it will be determined during
48
40
  * the handshake
49
41
  */
50
- secureInbound <Stream extends SecurableStream = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
42
+ secureInbound (connection: MessageStream, options?: SecureConnectionOptions): Promise<SecuredConnection<Extension>>
51
43
  }
52
44
 
53
- export interface SecuredConnection<Stream = any, Extension = unknown> {
54
- conn: Stream
45
+ export interface SecuredConnection<Extension = unknown> {
46
+ /**
47
+ * The decrypted data stream
48
+ */
49
+ connection: MessageStream
50
+
51
+ /**
52
+ * Any extension data transferred as part of the encryption handshake
53
+ */
55
54
  remoteExtensions?: Extension
55
+
56
+ /**
57
+ * The identifier of the remote peer
58
+ */
56
59
  remotePeer: PeerId
57
60
 
58
61
  /**
@@ -1,5 +1,4 @@
1
- import type { MultiaddrConnection } from './connection.js'
2
- import type { PeerId } from './peer-id.js'
1
+ import type { MultiaddrConnection, PeerId } from './index.js'
3
2
  import type { Multiaddr } from '@multiformats/multiaddr'
4
3
 
5
4
  export interface ConnectionGater {
@@ -0,0 +1,9 @@
1
+ import type { AbortOptions, MessageStream } from './index.ts'
2
+
3
+ export interface ConnectionProtector {
4
+ /**
5
+ * Takes a MessageStream and creates a private encryption stream between
6
+ * the two peers from the shared key the Protector instance was created with.
7
+ */
8
+ protect (connection: MessageStream, options?: AbortOptions): Promise<MessageStream>
9
+ }