@libp2p/interface 2.11.0-6059227cb → 2.11.0-87bc8d4fb

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 (72) 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 +15 -17
  4. package/dist/src/connection-encrypter.d.ts.map +1 -1
  5. package/dist/src/connection-gater.d.ts +2 -1
  6. package/dist/src/connection-gater.d.ts.map +1 -1
  7. package/dist/src/connection.d.ts +233 -36
  8. package/dist/src/connection.d.ts.map +1 -1
  9. package/dist/src/connection.js.map +1 -1
  10. package/dist/src/errors.d.ts +0 -14
  11. package/dist/src/errors.d.ts.map +1 -1
  12. package/dist/src/errors.js +0 -20
  13. package/dist/src/errors.js.map +1 -1
  14. package/dist/src/index.d.ts +5 -35
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +3 -7
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/metrics.d.ts +2 -2
  19. package/dist/src/metrics.d.ts.map +1 -1
  20. package/dist/src/peer-store.d.ts +4 -0
  21. package/dist/src/peer-store.d.ts.map +1 -1
  22. package/dist/src/pubsub.d.ts +248 -0
  23. package/dist/src/pubsub.d.ts.map +1 -0
  24. package/dist/src/pubsub.js +47 -0
  25. package/dist/src/pubsub.js.map +1 -0
  26. package/dist/src/stream-handler.d.ts +13 -12
  27. package/dist/src/stream-handler.d.ts.map +1 -1
  28. package/dist/src/stream-muxer.d.ts +30 -113
  29. package/dist/src/stream-muxer.d.ts.map +1 -1
  30. package/dist/src/topology.d.ts +3 -3
  31. package/dist/src/topology.d.ts.map +1 -1
  32. package/dist/src/transport.d.ts +13 -20
  33. package/dist/src/transport.d.ts.map +1 -1
  34. package/dist/src/transport.js.map +1 -1
  35. package/package.json +6 -4
  36. package/src/connection-encrypter.ts +16 -19
  37. package/src/connection-gater.ts +2 -1
  38. package/src/connection.ts +270 -38
  39. package/src/errors.ts +0 -24
  40. package/src/index.ts +5 -38
  41. package/src/metrics.ts +2 -2
  42. package/src/peer-store.ts +5 -0
  43. package/src/pubsub.ts +286 -0
  44. package/src/stream-handler.ts +15 -14
  45. package/src/stream-muxer.ts +30 -122
  46. package/src/topology.ts +3 -3
  47. package/src/transport.ts +14 -25
  48. package/dist/src/connection-protector.d.ts +0 -9
  49. package/dist/src/connection-protector.d.ts.map +0 -1
  50. package/dist/src/connection-protector.js +0 -2
  51. package/dist/src/connection-protector.js.map +0 -1
  52. package/dist/src/events.d.ts +0 -26
  53. package/dist/src/events.d.ts.map +0 -1
  54. package/dist/src/events.js +0 -36
  55. package/dist/src/events.js.map +0 -1
  56. package/dist/src/message-stream.d.ts +0 -159
  57. package/dist/src/message-stream.d.ts.map +0 -1
  58. package/dist/src/message-stream.js +0 -2
  59. package/dist/src/message-stream.js.map +0 -1
  60. package/dist/src/multiaddr-connection.d.ts +0 -25
  61. package/dist/src/multiaddr-connection.d.ts.map +0 -1
  62. package/dist/src/multiaddr-connection.js +0 -2
  63. package/dist/src/multiaddr-connection.js.map +0 -1
  64. package/dist/src/stream.d.ts +0 -63
  65. package/dist/src/stream.d.ts.map +0 -1
  66. package/dist/src/stream.js +0 -2
  67. package/dist/src/stream.js.map +0 -1
  68. package/src/connection-protector.ts +0 -9
  69. package/src/events.ts +0 -44
  70. package/src/message-stream.ts +0 -183
  71. package/src/multiaddr-connection.ts +0 -27
  72. package/src/stream.ts +0 -70
package/src/transport.ts CHANGED
@@ -1,4 +1,6 @@
1
- import type { AbortOptions, ClearableSignal, ConnectionEncrypter, MultiaddrConnection, Connection, ConnectionLimits, StreamMuxerFactory, PeerId } from './index.js'
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'
2
4
  import type { Multiaddr } from '@multiformats/multiaddr'
3
5
  import type { TypedEventTarget } from 'main-event'
4
6
  import type { ProgressOptions, ProgressEvent } from 'progress-events'
@@ -27,19 +29,16 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
27
29
  * Start a listener
28
30
  */
29
31
  listen(multiaddr: Multiaddr): Promise<void>
30
-
31
32
  /**
32
33
  * Get listen addresses
33
34
  */
34
35
  getAddrs(): Multiaddr[]
35
-
36
36
  /**
37
37
  * Close listener
38
38
  *
39
39
  * @returns {Promise<void>}
40
40
  */
41
41
  close(): Promise<void>
42
-
43
42
  /**
44
43
  * Allows transports to amend announce addresses - to add certificate hashes
45
44
  * or other metadata that cannot be known before runtime
@@ -135,6 +134,15 @@ export enum FaultTolerance {
135
134
  * Options accepted by the upgrader during connection establishment
136
135
  */
137
136
  export interface UpgraderOptions<ConnectionUpgradeEvents extends ProgressEvent = ProgressEvent> extends ProgressOptions<ConnectionUpgradeEvents>, Required<AbortOptions> {
137
+ /**
138
+ * If true the invoking transport is expected to implement it's own encryption
139
+ * and an encryption protocol will not attempted to be negotiated via
140
+ * multi-stream select
141
+ *
142
+ * @default false
143
+ */
144
+ skipEncryption?: boolean
145
+
138
146
  /**
139
147
  * If true no connection protection will be performed on the connection.
140
148
  */
@@ -164,23 +172,6 @@ export interface UpgraderOptions<ConnectionUpgradeEvents extends ProgressEvent =
164
172
  initiator?: boolean
165
173
  }
166
174
 
167
- /**
168
- * Options accepted by the upgrader during connection establishment
169
- */
170
- export interface UpgraderWithoutEncryptionOptions extends UpgraderOptions {
171
- /**
172
- * If true the invoking transport is expected to implement it's own encryption
173
- * and an encryption protocol will not attempted to be negotiated via
174
- * multi-stream select
175
- */
176
- skipEncryption: true
177
-
178
- /**
179
- * If `skipEncryption` is true, a remote PeerId must be supplied
180
- */
181
- remotePeer: PeerId
182
- }
183
-
184
175
  export type InboundConnectionUpgradeEvents =
185
176
  ProgressEvent<'upgrader:encrypt-inbound-connection'> |
186
177
  ProgressEvent<'upgrader:multiplex-inbound-connection'>
@@ -193,15 +184,13 @@ export interface Upgrader {
193
184
  /**
194
185
  * Upgrades an outbound connection created by the `dial` method of a transport
195
186
  */
196
- upgradeOutbound(maConn: MultiaddrConnection, opts: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>
197
- upgradeOutbound(maConn: MultiaddrConnection, opts: UpgraderWithoutEncryptionOptions): Promise<Connection>
187
+ upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>
198
188
 
199
189
  /**
200
190
  * Upgrades an inbound connection received by a transport listener and
201
191
  * notifies other libp2p components about the new connection
202
192
  */
203
- upgradeInbound(maConn: MultiaddrConnection, opts: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>
204
- upgradeInbound(maConn: MultiaddrConnection, opts: UpgraderWithoutEncryptionOptions): Promise<void>
193
+ upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>
205
194
 
206
195
  /**
207
196
  * Used by transports that perform part of the upgrade process themselves and
@@ -1,9 +0,0 @@
1
- import type { AbortOptions, MessageStream } from './index.ts';
2
- export interface ConnectionProtector {
3
- /**
4
- * Takes a MessageStream and creates a private encryption stream between
5
- * the two peers from the shared key the Protector instance was created with.
6
- */
7
- protect(connection: MessageStream, options?: AbortOptions): Promise<MessageStream>;
8
- }
9
- //# sourceMappingURL=connection-protector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-protector.d.ts","sourceRoot":"","sources":["../../src/connection-protector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE7D,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAE,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;CACpF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=connection-protector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-protector.js","sourceRoot":"","sources":["../../src/connection-protector.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import type { Uint8ArrayList } from 'uint8arraylist';
2
- /**
3
- * A custom implementation of MessageEvent as the Undici version does too much
4
- * validation in it's constructor so is very slow.
5
- */
6
- export declare class StreamMessageEvent extends Event {
7
- data: Uint8Array | Uint8ArrayList;
8
- constructor(data: Uint8Array | Uint8ArrayList, eventInitDict?: EventInit);
9
- }
10
- /**
11
- * An event dispatched when the stream is closed. The `error` property can be
12
- * inspected to discover if the closing was graceful or not, and the `remote`
13
- * property shows which end of the stream initiated the closure
14
- */
15
- export declare class StreamCloseEvent extends Event {
16
- error?: Error;
17
- local?: boolean;
18
- constructor(local?: boolean, error?: Error, eventInitDict?: EventInit);
19
- }
20
- export declare class StreamAbortEvent extends StreamCloseEvent {
21
- constructor(error: Error, eventInitDict?: EventInit);
22
- }
23
- export declare class StreamResetEvent extends StreamCloseEvent {
24
- constructor(error: Error, eventInitDict?: EventInit);
25
- }
26
- //# sourceMappingURL=events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACpC,IAAI,EAAE,UAAU,GAAG,cAAc,CAAA;gBAE3B,IAAI,EAAE,UAAU,GAAG,cAAc,EAAE,aAAa,CAAC,EAAE,SAAS;CAK1E;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAClC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;gBAET,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,SAAS;CAMvE;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACvC,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,SAAS;CAGrD;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACvC,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,SAAS;CAGrD"}
@@ -1,36 +0,0 @@
1
- /**
2
- * A custom implementation of MessageEvent as the Undici version does too much
3
- * validation in it's constructor so is very slow.
4
- */
5
- export class StreamMessageEvent extends Event {
6
- data;
7
- constructor(data, eventInitDict) {
8
- super('message', eventInitDict);
9
- this.data = data;
10
- }
11
- }
12
- /**
13
- * An event dispatched when the stream is closed. The `error` property can be
14
- * inspected to discover if the closing was graceful or not, and the `remote`
15
- * property shows which end of the stream initiated the closure
16
- */
17
- export class StreamCloseEvent extends Event {
18
- error;
19
- local;
20
- constructor(local, error, eventInitDict) {
21
- super('close', eventInitDict);
22
- this.error = error;
23
- this.local = local;
24
- }
25
- }
26
- export class StreamAbortEvent extends StreamCloseEvent {
27
- constructor(error, eventInitDict) {
28
- super(true, error, eventInitDict);
29
- }
30
- }
31
- export class StreamResetEvent extends StreamCloseEvent {
32
- constructor(error, eventInitDict) {
33
- super(false, error, eventInitDict);
34
- }
35
- }
36
- //# sourceMappingURL=events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACpC,IAAI,CAA6B;IAExC,YAAa,IAAiC,EAAE,aAAyB;QACvE,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;QAE/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAClC,KAAK,CAAQ;IACb,KAAK,CAAU;IAEtB,YAAa,KAAe,EAAE,KAAa,EAAE,aAAyB;QACpE,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;QAE7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IACpD,YAAa,KAAY,EAAE,aAAyB;QAClD,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAA;IACnC,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IACpD,YAAa,KAAY,EAAE,aAAyB;QAClD,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,CAAA;IACpC,CAAC;CACF"}
@@ -1,159 +0,0 @@
1
- import type { Logger, StreamCloseEvent, StreamMessageEvent, TypedEventTarget, AbortOptions } from './index.js';
2
- import type { Uint8ArrayList } from 'uint8arraylist';
3
- /**
4
- * The direction of the message stream
5
- */
6
- export type MessageStreamDirection = 'inbound' | 'outbound';
7
- /**
8
- * The states a message stream can be in
9
- */
10
- export type MessageStreamStatus = 'open' | 'closing' | 'closed' | 'aborted' | 'reset';
11
- /**
12
- * The states the readable end of a message stream can be in
13
- */
14
- export type MessageStreamReadStatus = 'readable' | 'paused' | 'closing' | 'closed';
15
- /**
16
- * The states the writable end of a message stream can be in
17
- */
18
- export type MessageStreamWriteStatus = 'writable' | 'closing' | 'closed';
19
- /**
20
- * An object that records the times of various events
21
- */
22
- export interface MessageStreamTimeline {
23
- /**
24
- * A timestamp of when the message stream was opened
25
- */
26
- open: number;
27
- /**
28
- * A timestamp of when the message stream was closed for both reading and
29
- * writing by both ends of the stream
30
- */
31
- close?: number;
32
- }
33
- export interface MessageStreamEvents {
34
- /**
35
- * Data was received from the remote end of the message stream
36
- */
37
- message: StreamMessageEvent;
38
- /**
39
- * The local send buffer has emptied and the stream may be written to once
40
- * more, unless it is currently closing.
41
- */
42
- drain: Event;
43
- /**
44
- * The underlying resource is closed - no further events will be emitted and
45
- * the stream cannot be used to send or receive any more data.
46
- *
47
- * When the `.error` field is set, the `local` property of the event will be
48
- * `true` value if the `.abort` was invoked, otherwise it means a remote error
49
- * occurred and the peer sent a reset signal.
50
- */
51
- close: StreamCloseEvent;
52
- /**
53
- * Where the stream implementation supports half-closing, it may emit this
54
- * event when the remote end of the stream closes it's writable end.
55
- *
56
- * After this event is received no further 'message' events will be emitted
57
- * though the stream can still be written to, if it has not been closed at
58
- * this end.
59
- */
60
- remoteCloseWrite: Event;
61
- /**
62
- * The outgoing write queue emptied - there are no more bytes queued for
63
- * sending to the remote end of the stream.
64
- */
65
- idle: Event;
66
- }
67
- export interface MessageStream<Timeline extends MessageStreamTimeline = MessageStreamTimeline> extends TypedEventTarget<MessageStreamEvents>, AsyncIterable<Uint8Array | Uint8ArrayList> {
68
- /**
69
- * The current status of the message stream
70
- */
71
- status: MessageStreamStatus;
72
- /**
73
- * Timestamps of when stream events occurred
74
- */
75
- timeline: Timeline;
76
- /**
77
- * A logging implementation that can be used to log stream-specific messages
78
- */
79
- log: Logger;
80
- /**
81
- * Whether this stream is inbound or outbound
82
- */
83
- direction: MessageStreamDirection;
84
- /**
85
- * The maximum number of bytes to store when paused. If receipt of more bytes
86
- * from the remote end of the stream causes the buffer size to exceed this
87
- * value the stream will be reset and a 'close' event emitted.
88
- *
89
- * This value can be changed at runtime.
90
- */
91
- maxReadBufferLength: number;
92
- /**
93
- * When the `.send` method returns false it means that the underlying resource
94
- * has signalled that it's write buffer is full. If the user continues to call
95
- * `.send`, outgoing bytes are stored in an internal buffer until the
96
- * underlying resource signals that it can accept more data.
97
- *
98
- * If the size of that internal buffer exceed this value the stream will be
99
- * reset and a 'close' event emitted.
100
- *
101
- * This value can be changed at runtime.
102
- */
103
- maxWriteBufferLength?: number;
104
- /**
105
- * If no data is transmitted over the stream in this many ms, the stream will
106
- * be aborted with an InactivityTimeoutError
107
- */
108
- inactivityTimeout: number;
109
- /**
110
- * If this property is `true`, the underlying transport has signalled that its
111
- * write buffer is full and that `.send` should not be called again.
112
- *
113
- * A `drain` event will be emitted after which is its safe to call `.send`
114
- * again to resume sending.
115
- */
116
- writableNeedsDrain: boolean;
117
- /**
118
- * Write data to the stream. If the method returns false it means the
119
- * internal buffer is now full and the caller should wait for the 'drain'
120
- * event before sending more data.
121
- *
122
- * This method may throw if:
123
- * - The internal send buffer is full
124
- * - The stream has previously been closed for writing locally or remotely
125
- */
126
- send(data: Uint8Array | Uint8ArrayList): boolean;
127
- /**
128
- * Stop accepting new data to send and return a promise that resolves when any
129
- * unsent data has been written into the underlying resource.
130
- */
131
- close(options?: AbortOptions): Promise<void>;
132
- /**
133
- * Stop accepting new data to send, discard any unsent/unread data, and emit a
134
- * 'close' event with the 'error' property set to the passed error.
135
- */
136
- abort(err: Error): void;
137
- /**
138
- * Stop emitting further 'message' events. Any received data will be stored in
139
- * an internal buffer. If the buffer size reaches `maxReadBufferLength`, the
140
- * stream will be reset and a StreamAbortEvent emitted.
141
- *
142
- * If the underlying resource supports it, the remote peer will be instructed
143
- * to pause transmission of further data.
144
- */
145
- pause(): void;
146
- /**
147
- * Resume emitting 'message' events.
148
- *
149
- * If the underlying resource supports it, the remote peer will be informed
150
- * that it is ok to start sending data again.
151
- */
152
- resume(): void;
153
- /**
154
- * Queue the passed data to be emitted as a 'message' event either during the
155
- * next tick or sooner if data is received from the underlying resource.
156
- */
157
- push(buf: Uint8Array | Uint8ArrayList): void;
158
- }
159
- //# sourceMappingURL=message-stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-stream.d.ts","sourceRoot":"","sources":["../../src/message-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,UAAU,CAAA;AAE3D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AAErF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;AAElF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAA;AAExE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAA;IAE3B;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAA;IAEZ;;;;;;;OAOG;IACH,KAAK,EAAE,gBAAgB,CAAA;IAEvB;;;;;;;OAOG;IACH,gBAAgB,EAAE,KAAK,CAAA;IAEvB;;;OAGG;IACH,IAAI,EAAE,KAAK,CAAA;CACZ;AAED,MAAM,WAAW,aAAa,CAAC,QAAQ,SAAS,qBAAqB,GAAG,qBAAqB,CAAE,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,UAAU,GAAG,cAAc,CAAC;IACtL;;OAEG;IACH,MAAM,EAAE,mBAAmB,CAAA;IAE3B;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAElB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAA;IAEjC;;;;;;OAMG;IACH,mBAAmB,EAAE,MAAM,CAAA;IAE3B;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAA;IAEzB;;;;;;OAMG;IACH,kBAAkB,EAAE,OAAO,CAAA;IAE3B;;;;;;;;OAQG;IACH,IAAI,CAAE,IAAI,EAAE,UAAU,GAAG,cAAc,GAAG,OAAO,CAAA;IAEjD;;;OAGG;IACH,KAAK,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7C;;;OAGG;IACH,KAAK,CAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;IAExB;;;;;;;OAOG;IACH,KAAK,IAAK,IAAI,CAAA;IAEd;;;;;OAKG;IACH,MAAM,IAAK,IAAI,CAAA;IAEf;;;OAGG;IACH,IAAI,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,GAAG,IAAI,CAAA;CAC9C"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=message-stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-stream.js","sourceRoot":"","sources":["../../src/message-stream.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- import type { MessageStream, MessageStreamTimeline } from './message-stream.ts';
2
- import type { Multiaddr } from '@multiformats/multiaddr';
3
- export interface MultiaddrConnectionTimeline extends MessageStreamTimeline {
4
- /**
5
- * When the MultiaddrConnection was upgraded to a Connection - the type of
6
- * connection encryption and multiplexing was negotiated.
7
- */
8
- upgraded?: number;
9
- }
10
- /**
11
- * A MultiaddrConnection is returned by a transport after dialing a peer. It is
12
- * a low-level primitive and is the raw connection, typically without encryption
13
- * or stream multiplexing.
14
- */
15
- export interface MultiaddrConnection extends MessageStream<MultiaddrConnectionTimeline> {
16
- /**
17
- * The address of the remote end of the connection
18
- */
19
- remoteAddr: Multiaddr;
20
- /**
21
- * When stream life cycle events occurred
22
- */
23
- timeline: MultiaddrConnectionTimeline;
24
- }
25
- //# sourceMappingURL=multiaddr-connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiaddr-connection.d.ts","sourceRoot":"","sources":["../../src/multiaddr-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,WAAW,2BAA4B,SAAQ,qBAAqB;IACxE;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa,CAAC,2BAA2B,CAAC;IACrF;;OAEG;IACH,UAAU,EAAE,SAAS,CAAA;IAErB;;OAEG;IACH,QAAQ,EAAE,2BAA2B,CAAA;CACtC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=multiaddr-connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiaddr-connection.js","sourceRoot":"","sources":["../../src/multiaddr-connection.ts"],"names":[],"mappings":""}
@@ -1,63 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
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
- }
package/src/events.ts DELETED
@@ -1,44 +0,0 @@
1
- import type { Uint8ArrayList } from 'uint8arraylist'
2
-
3
- /**
4
- * A custom implementation of MessageEvent as the Undici version does too much
5
- * validation in it's constructor so is very slow.
6
- */
7
- export class StreamMessageEvent extends Event {
8
- public data: Uint8Array | Uint8ArrayList
9
-
10
- constructor (data: Uint8Array | Uint8ArrayList, eventInitDict?: EventInit) {
11
- super('message', eventInitDict)
12
-
13
- this.data = data
14
- }
15
- }
16
-
17
- /**
18
- * An event dispatched when the stream is closed. The `error` property can be
19
- * inspected to discover if the closing was graceful or not, and the `remote`
20
- * property shows which end of the stream initiated the closure
21
- */
22
- export class StreamCloseEvent extends Event {
23
- public error?: Error
24
- public local?: boolean
25
-
26
- constructor (local?: boolean, error?: Error, eventInitDict?: EventInit) {
27
- super('close', eventInitDict)
28
-
29
- this.error = error
30
- this.local = local
31
- }
32
- }
33
-
34
- export class StreamAbortEvent extends StreamCloseEvent {
35
- constructor (error: Error, eventInitDict?: EventInit) {
36
- super(true, error, eventInitDict)
37
- }
38
- }
39
-
40
- export class StreamResetEvent extends StreamCloseEvent {
41
- constructor (error: Error, eventInitDict?: EventInit) {
42
- super(false, error, eventInitDict)
43
- }
44
- }