@libp2p/interface 2.2.0-32ca76fcb → 2.2.0-656db81cf
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.
|
@@ -5,9 +5,19 @@ import type { StreamMuxerFactory } from '../stream-muxer/index.js';
|
|
|
5
5
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
6
6
|
import type { ProgressOptions, ProgressEvent } from 'progress-events';
|
|
7
7
|
export interface ListenerEvents {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* This event signals to the transport manager that the listening addresses
|
|
10
|
+
* have changed and may be emitted at any point and/or multiple times
|
|
11
|
+
*/
|
|
9
12
|
'listening': CustomEvent;
|
|
13
|
+
/**
|
|
14
|
+
* Emitted if listening on an address failed
|
|
15
|
+
*/
|
|
10
16
|
'error': CustomEvent<Error>;
|
|
17
|
+
/**
|
|
18
|
+
* Emitted when the listener has been shut down, has no open connections and
|
|
19
|
+
* will no longer accept new connections
|
|
20
|
+
*/
|
|
11
21
|
'close': CustomEvent;
|
|
12
22
|
}
|
|
13
23
|
export interface Listener extends TypedEventTarget<ListenerEvents> {
|
|
@@ -27,16 +37,21 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
|
|
|
27
37
|
close(): Promise<void>;
|
|
28
38
|
}
|
|
29
39
|
export declare const transportSymbol: unique symbol;
|
|
30
|
-
export interface ConnectionHandler {
|
|
31
|
-
(connection: Connection): void;
|
|
32
|
-
}
|
|
33
40
|
export interface MultiaddrFilter {
|
|
34
41
|
(multiaddrs: Multiaddr[]): Multiaddr[];
|
|
35
42
|
}
|
|
36
43
|
export interface CreateListenerOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The upgrader turns a MultiaddrConnection into a Connection and notifies
|
|
46
|
+
* other libp2p components about a new incoming connection.
|
|
47
|
+
*/
|
|
37
48
|
upgrader: Upgrader;
|
|
38
49
|
}
|
|
39
50
|
export interface DialTransportOptions<DialEvents extends ProgressEvent = ProgressEvent> extends AbortOptions, ProgressOptions<DialEvents> {
|
|
51
|
+
/**
|
|
52
|
+
* The upgrader turns a MultiaddrConnection into a Connection which should be
|
|
53
|
+
* returned by the transport's dial method
|
|
54
|
+
*/
|
|
40
55
|
upgrader: Upgrader;
|
|
41
56
|
}
|
|
42
57
|
/**
|
|
@@ -94,12 +109,13 @@ export type InboundConnectionUpgradeEvents = ProgressEvent<'upgrader:encrypt-inb
|
|
|
94
109
|
export type OutboundConnectionUpgradeEvents = ProgressEvent<'upgrader:encrypt-outbound-connection'> | ProgressEvent<'upgrader:multiplex-outbound-connection'>;
|
|
95
110
|
export interface Upgrader {
|
|
96
111
|
/**
|
|
97
|
-
* Upgrades an outbound connection
|
|
112
|
+
* Upgrades an outbound connection created by the `dial` method of a transport
|
|
98
113
|
*/
|
|
99
114
|
upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>;
|
|
100
115
|
/**
|
|
101
|
-
* Upgrades an inbound connection
|
|
116
|
+
* Upgrades an inbound connection received by a transport listener and
|
|
117
|
+
* notifies other libp2p components about the new connection
|
|
102
118
|
*/
|
|
103
|
-
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<
|
|
119
|
+
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>;
|
|
104
120
|
}
|
|
105
121
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC/F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,O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CAAC,GACpD,aAAa,CAAC,uCAAuC,CAAC,CAAA;AAEtD,MAAM,MAAM,+BAA+B,GAC3C,aAAa,CAAC,sCAAsC,CAAC,GACrD,aAAa,CAAC,wCAAwC,CAAC,CAAA;AAEvD,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAE1H;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,CAAC,8BAA8B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AA2CA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAyD9D,MAAM,UAAU,WAAW,CAAE,KAAU;IACrC,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.2.0-
|
|
3
|
+
"version": "2.2.0-656db81cf",
|
|
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",
|
package/src/transport/index.ts
CHANGED
|
@@ -6,9 +6,21 @@ import type { Multiaddr } from '@multiformats/multiaddr'
|
|
|
6
6
|
import type { ProgressOptions, ProgressEvent } from 'progress-events'
|
|
7
7
|
|
|
8
8
|
export interface ListenerEvents {
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* This event signals to the transport manager that the listening addresses
|
|
11
|
+
* have changed and may be emitted at any point and/or multiple times
|
|
12
|
+
*/
|
|
10
13
|
'listening': CustomEvent
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Emitted if listening on an address failed
|
|
17
|
+
*/
|
|
11
18
|
'error': CustomEvent<Error>
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Emitted when the listener has been shut down, has no open connections and
|
|
22
|
+
* will no longer accept new connections
|
|
23
|
+
*/
|
|
12
24
|
'close': CustomEvent
|
|
13
25
|
}
|
|
14
26
|
|
|
@@ -31,15 +43,21 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
|
|
|
31
43
|
|
|
32
44
|
export const transportSymbol = Symbol.for('@libp2p/transport')
|
|
33
45
|
|
|
34
|
-
export interface ConnectionHandler { (connection: Connection): void }
|
|
35
|
-
|
|
36
46
|
export interface MultiaddrFilter { (multiaddrs: Multiaddr[]): Multiaddr[] }
|
|
37
47
|
|
|
38
48
|
export interface CreateListenerOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The upgrader turns a MultiaddrConnection into a Connection and notifies
|
|
51
|
+
* other libp2p components about a new incoming connection.
|
|
52
|
+
*/
|
|
39
53
|
upgrader: Upgrader
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
export interface DialTransportOptions<DialEvents extends ProgressEvent = ProgressEvent> extends AbortOptions, ProgressOptions<DialEvents> {
|
|
57
|
+
/**
|
|
58
|
+
* The upgrader turns a MultiaddrConnection into a Connection which should be
|
|
59
|
+
* returned by the transport's dial method
|
|
60
|
+
*/
|
|
43
61
|
upgrader: Upgrader
|
|
44
62
|
}
|
|
45
63
|
|
|
@@ -116,12 +134,13 @@ ProgressEvent<'upgrader:multiplex-outbound-connection'>
|
|
|
116
134
|
|
|
117
135
|
export interface Upgrader {
|
|
118
136
|
/**
|
|
119
|
-
* Upgrades an outbound connection
|
|
137
|
+
* Upgrades an outbound connection created by the `dial` method of a transport
|
|
120
138
|
*/
|
|
121
139
|
upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>
|
|
122
140
|
|
|
123
141
|
/**
|
|
124
|
-
* Upgrades an inbound connection
|
|
142
|
+
* Upgrades an inbound connection received by a transport listener and
|
|
143
|
+
* notifies other libp2p components about the new connection
|
|
125
144
|
*/
|
|
126
|
-
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<
|
|
145
|
+
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>
|
|
127
146
|
}
|