@libp2p/interface-internal 2.3.19-a02cb0461 → 2.3.19-e8398d97e

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.
@@ -1,18 +1,4 @@
1
- import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology } from '@libp2p/interface';
2
- import type { AbortOptions } from '@multiformats/multiaddr';
3
- export type {
4
- /**
5
- * @deprecated This type should be imported from @libp2p/interface directly
6
- */
7
- StreamHandler,
8
- /**
9
- * @deprecated This type should be imported from @libp2p/interface directly
10
- */
11
- StreamHandlerOptions,
12
- /**
13
- * @deprecated This type should be imported from @libp2p/interface directly
14
- */
15
- StreamHandlerRecord };
1
+ import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology, StreamMiddleware, AbortOptions } from '@libp2p/interface';
16
2
  /**
17
3
  * The `Registrar` provides an interface for registering protocol handlers -
18
4
  * these are invoked when remote peers open streams on the local node with the
@@ -55,6 +41,27 @@ export interface Registrar {
55
41
  * @returns A `StreamHandlerRecord` containing the handler and options.
56
42
  */
57
43
  getHandler(protocol: string): StreamHandlerRecord;
44
+ /**
45
+ * Retrieve any registered middleware for a given protocol.
46
+ *
47
+ * @param protocol - The protocol to fetch middleware for
48
+ * @returns A list of `StreamMiddleware` implementations
49
+ */
50
+ use(protocol: string, middleware: StreamMiddleware[]): void;
51
+ /**
52
+ * Retrieve any registered middleware for a given protocol.
53
+ *
54
+ * @param protocol - The protocol to fetch middleware for
55
+ * @returns A list of `StreamMiddleware` implementations
56
+ */
57
+ unuse(protocol: string): void;
58
+ /**
59
+ * Retrieve any registered middleware for a given protocol.
60
+ *
61
+ * @param protocol - The protocol to fetch middleware for
62
+ * @returns A list of `StreamMiddleware` implementations
63
+ */
64
+ getMiddleware(protocol: string): StreamMiddleware[];
58
65
  /**
59
66
  * Register a topology handler for a protocol - the topology will be
60
67
  * invoked when peers are discovered on the network that support the
@@ -1 +1 @@
1
- {"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../src/registrar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,YAAY;AACV;;GAEG;AACH,aAAa;AAEb;;GAEG;AACH,oBAAoB;AAEpB;;GAEG;AACH,mBAAmB,EACpB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,YAAY,IAAI,MAAM,EAAE,CAAA;IAExB;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/F;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjE;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAA;IAEjD;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEvF;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAA;CAC5C"}
1
+ {"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../src/registrar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAE3I;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,YAAY,IAAI,MAAM,EAAE,CAAA;IAExB;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/F;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjE;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAA;IAEjD;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAA;IAE3D;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAE7B;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;IAEnD;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEvF;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAA;CAC5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interface-internal",
3
- "version": "2.3.19-a02cb0461",
3
+ "version": "2.3.19-e8398d97e",
4
4
  "description": "Interfaces implemented by internal libp2p components",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface-internal#readme",
@@ -41,13 +41,13 @@
41
41
  "build": "aegir build"
42
42
  },
43
43
  "dependencies": {
44
- "@libp2p/interface": "2.11.0-a02cb0461",
45
- "@libp2p/peer-collections": "6.0.35-a02cb0461",
46
- "@multiformats/multiaddr": "^12.5.1",
44
+ "@libp2p/interface": "2.11.0-e8398d97e",
45
+ "@libp2p/peer-collections": "6.0.35-e8398d97e",
46
+ "@multiformats/multiaddr": "^13.0.1",
47
47
  "progress-events": "^1.0.1"
48
48
  },
49
49
  "devDependencies": {
50
- "aegir": "^47.0.21"
50
+ "aegir": "^47.0.22"
51
51
  },
52
52
  "sideEffects": false
53
53
  }
package/src/registrar.ts CHANGED
@@ -1,22 +1,4 @@
1
- import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology } from '@libp2p/interface'
2
- import type { AbortOptions } from '@multiformats/multiaddr'
3
-
4
- export type {
5
- /**
6
- * @deprecated This type should be imported from @libp2p/interface directly
7
- */
8
- StreamHandler,
9
-
10
- /**
11
- * @deprecated This type should be imported from @libp2p/interface directly
12
- */
13
- StreamHandlerOptions,
14
-
15
- /**
16
- * @deprecated This type should be imported from @libp2p/interface directly
17
- */
18
- StreamHandlerRecord
19
- }
1
+ import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology, StreamMiddleware, AbortOptions } from '@libp2p/interface'
20
2
 
21
3
  /**
22
4
  * The `Registrar` provides an interface for registering protocol handlers -
@@ -64,6 +46,30 @@ export interface Registrar {
64
46
  */
65
47
  getHandler(protocol: string): StreamHandlerRecord
66
48
 
49
+ /**
50
+ * Retrieve any registered middleware for a given protocol.
51
+ *
52
+ * @param protocol - The protocol to fetch middleware for
53
+ * @returns A list of `StreamMiddleware` implementations
54
+ */
55
+ use(protocol: string, middleware: StreamMiddleware[]): void
56
+
57
+ /**
58
+ * Retrieve any registered middleware for a given protocol.
59
+ *
60
+ * @param protocol - The protocol to fetch middleware for
61
+ * @returns A list of `StreamMiddleware` implementations
62
+ */
63
+ unuse(protocol: string): void
64
+
65
+ /**
66
+ * Retrieve any registered middleware for a given protocol.
67
+ *
68
+ * @param protocol - The protocol to fetch middleware for
69
+ * @returns A list of `StreamMiddleware` implementations
70
+ */
71
+ getMiddleware(protocol: string): StreamMiddleware[]
72
+
67
73
  /**
68
74
  * Register a topology handler for a protocol - the topology will be
69
75
  * invoked when peers are discovered on the network that support the