@libp2p/interface 2.10.5-58abe8702 → 2.10.5-7ce083dca
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.
- package/dist/src/connection-encrypter.d.ts +9 -3
- package/dist/src/connection-encrypter.d.ts.map +1 -1
- package/dist/src/stream-handler.d.ts +1 -1
- package/dist/src/stream-handler.d.ts.map +1 -1
- package/dist/src/stream-muxer.d.ts +5 -1
- package/dist/src/stream-muxer.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connection-encrypter.ts +10 -3
- package/src/stream-handler.ts +1 -1
- package/src/stream-muxer.ts +6 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MultiaddrConnection } from './connection.js';
|
|
2
|
-
import type { AbortOptions, StreamMuxerFactory } from './index.js';
|
|
2
|
+
import type { AbortOptions, Logger, StreamMuxerFactory } from './index.js';
|
|
3
3
|
import type { PeerId } from './peer-id.js';
|
|
4
4
|
import type { Duplex } from 'it-stream-types';
|
|
5
5
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
@@ -18,6 +18,12 @@ export interface SecureConnectionOptions extends AbortOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
skipStreamMuxerNegotiation?: boolean;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A stream with an optional logger
|
|
23
|
+
*/
|
|
24
|
+
export interface SecurableStream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
|
|
25
|
+
log?: Logger;
|
|
26
|
+
}
|
|
21
27
|
/**
|
|
22
28
|
* A libp2p connection encrypter module must be compliant to this interface
|
|
23
29
|
* to ensure all exchanged data between two peers is encrypted.
|
|
@@ -29,13 +35,13 @@ export interface ConnectionEncrypter<Extension = unknown> {
|
|
|
29
35
|
* pass it for extra verification, otherwise it will be determined during
|
|
30
36
|
* the handshake.
|
|
31
37
|
*/
|
|
32
|
-
secureOutbound<Stream extends
|
|
38
|
+
secureOutbound<Stream extends SecurableStream = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
|
|
33
39
|
/**
|
|
34
40
|
* Decrypt incoming data. If the remote PeerId is known,
|
|
35
41
|
* pass it for extra verification, otherwise it will be determined during
|
|
36
42
|
* the handshake
|
|
37
43
|
*/
|
|
38
|
-
secureInbound<Stream extends
|
|
44
|
+
secureInbound<Stream extends SecurableStream = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
|
|
39
45
|
}
|
|
40
46
|
export interface SecuredConnection<Stream = any, Extension = unknown> {
|
|
41
47
|
conn: Stream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-encrypter.d.ts","sourceRoot":"","sources":["../../src/connection-encrypter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"connection-encrypter.d.ts","sourceRoot":"","sources":["../../src/connection-encrypter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC;IAC1F,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,SAAS,GAAG,OAAO;IACtD,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAE,MAAM,SAAS,eAAe,GAAG,mBAAmB,EAAG,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;IAE5K;;;;OAIG;IACH,aAAa,CAAE,MAAM,SAAS,eAAe,GAAG,mBAAmB,EAAG,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;CAC5K;AAED,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,GAAG,EAAE,SAAS,GAAG,OAAO;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC"}
|
|
@@ -14,7 +14,7 @@ export interface StreamHandler {
|
|
|
14
14
|
/**
|
|
15
15
|
* A callback function that accepts the incoming stream data
|
|
16
16
|
*/
|
|
17
|
-
(data: IncomingStreamData): void
|
|
17
|
+
(data: IncomingStreamData): void | Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
export interface StreamHandlerOptions extends AbortOptions {
|
|
20
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACjD;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAEhC;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,CAAA;CACb;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,EAAE,aAAa,CAAA;IAEtB;;OAEG;IACH,OAAO,EAAE,oBAAoB,CAAA;CAC9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Direction, Stream } from './connection.js';
|
|
2
|
-
import type { AbortOptions } from './index.js';
|
|
2
|
+
import type { AbortOptions, Logger } from './index.js';
|
|
3
3
|
import type { Duplex } from 'it-stream-types';
|
|
4
4
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
5
5
|
export interface StreamMuxerFactory {
|
|
@@ -51,5 +51,9 @@ export interface StreamMuxerInit {
|
|
|
51
51
|
* Outbound stream muxers are opened by the local node, inbound stream muxers are opened by the remote
|
|
52
52
|
*/
|
|
53
53
|
direction?: Direction;
|
|
54
|
+
/**
|
|
55
|
+
* The logger used by the connection
|
|
56
|
+
*/
|
|
57
|
+
log?: Logger;
|
|
54
58
|
}
|
|
55
59
|
//# 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,YAAY,CAAA;
|
|
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,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC;IACtF;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAElD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5C;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAEvC;;OAEG;IACH,WAAW,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAElC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;IAErB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface",
|
|
3
|
-
"version": "2.10.5-
|
|
3
|
+
"version": "2.10.5-7ce083dca",
|
|
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",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MultiaddrConnection } from './connection.js'
|
|
2
|
-
import type { AbortOptions, StreamMuxerFactory } from './index.js'
|
|
2
|
+
import type { AbortOptions, Logger, StreamMuxerFactory } from './index.js'
|
|
3
3
|
import type { PeerId } from './peer-id.js'
|
|
4
4
|
import type { Duplex } from 'it-stream-types'
|
|
5
5
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
@@ -21,6 +21,13 @@ export interface SecureConnectionOptions extends AbortOptions {
|
|
|
21
21
|
skipStreamMuxerNegotiation?: boolean
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* A stream with an optional logger
|
|
26
|
+
*/
|
|
27
|
+
export interface SecurableStream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
|
|
28
|
+
log?: Logger
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
/**
|
|
25
32
|
* A libp2p connection encrypter module must be compliant to this interface
|
|
26
33
|
* to ensure all exchanged data between two peers is encrypted.
|
|
@@ -33,14 +40,14 @@ export interface ConnectionEncrypter<Extension = unknown> {
|
|
|
33
40
|
* pass it for extra verification, otherwise it will be determined during
|
|
34
41
|
* the handshake.
|
|
35
42
|
*/
|
|
36
|
-
secureOutbound <Stream extends
|
|
43
|
+
secureOutbound <Stream extends SecurableStream = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
46
|
* Decrypt incoming data. If the remote PeerId is known,
|
|
40
47
|
* pass it for extra verification, otherwise it will be determined during
|
|
41
48
|
* the handshake
|
|
42
49
|
*/
|
|
43
|
-
secureInbound <Stream extends
|
|
50
|
+
secureInbound <Stream extends SecurableStream = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
export interface SecuredConnection<Stream = any, Extension = unknown> {
|
package/src/stream-handler.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface StreamHandler {
|
|
|
17
17
|
/**
|
|
18
18
|
* A callback function that accepts the incoming stream data
|
|
19
19
|
*/
|
|
20
|
-
(data: IncomingStreamData): void
|
|
20
|
+
(data: IncomingStreamData): void | Promise<void>
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface StreamHandlerOptions extends AbortOptions {
|
package/src/stream-muxer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Direction, Stream } from './connection.js'
|
|
2
|
-
import type { AbortOptions } from './index.js'
|
|
2
|
+
import type { AbortOptions, Logger } from './index.js'
|
|
3
3
|
import type { Duplex } from 'it-stream-types'
|
|
4
4
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
5
5
|
|
|
@@ -60,4 +60,9 @@ export interface StreamMuxerInit {
|
|
|
60
60
|
* Outbound stream muxers are opened by the local node, inbound stream muxers are opened by the remote
|
|
61
61
|
*/
|
|
62
62
|
direction?: Direction
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The logger used by the connection
|
|
66
|
+
*/
|
|
67
|
+
log?: Logger
|
|
63
68
|
}
|