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

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,5 +1,4 @@
1
- import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology } from '@libp2p/interface';
2
- import type { AbortOptions } from '@multiformats/multiaddr';
1
+ import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology, StreamMiddleware, AbortOptions } from '@libp2p/interface';
3
2
  export type {
4
3
  /**
5
4
  * @deprecated This type should be imported from @libp2p/interface directly
@@ -55,6 +54,27 @@ export interface Registrar {
55
54
  * @returns A `StreamHandlerRecord` containing the handler and options.
56
55
  */
57
56
  getHandler(protocol: string): StreamHandlerRecord;
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
+ use(protocol: string, middleware: StreamMiddleware[]): void;
64
+ /**
65
+ * Retrieve any registered middleware for a given protocol.
66
+ *
67
+ * @param protocol - The protocol to fetch middleware for
68
+ * @returns A list of `StreamMiddleware` implementations
69
+ */
70
+ unuse(protocol: string): void;
71
+ /**
72
+ * Retrieve any registered middleware for a given protocol.
73
+ *
74
+ * @param protocol - The protocol to fetch middleware for
75
+ * @returns A list of `StreamMiddleware` implementations
76
+ */
77
+ getMiddleware(protocol: string): StreamMiddleware[];
58
78
  /**
59
79
  * Register a topology handler for a protocol - the topology will be
60
80
  * 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,YAA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AE,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-da78fa851",
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-da78fa851",
45
+ "@libp2p/peer-collections": "6.0.35-da78fa851",
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,5 +1,4 @@
1
- import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology } from '@libp2p/interface'
2
- import type { AbortOptions } from '@multiformats/multiaddr'
1
+ import type { StreamHandler, StreamHandlerOptions, StreamHandlerRecord, Topology, StreamMiddleware, AbortOptions } from '@libp2p/interface'
3
2
 
4
3
  export type {
5
4
  /**
@@ -64,6 +63,30 @@ export interface Registrar {
64
63
  */
65
64
  getHandler(protocol: string): StreamHandlerRecord
66
65
 
66
+ /**
67
+ * Retrieve any registered middleware for a given protocol.
68
+ *
69
+ * @param protocol - The protocol to fetch middleware for
70
+ * @returns A list of `StreamMiddleware` implementations
71
+ */
72
+ use(protocol: string, middleware: StreamMiddleware[]): void
73
+
74
+ /**
75
+ * Retrieve any registered middleware for a given protocol.
76
+ *
77
+ * @param protocol - The protocol to fetch middleware for
78
+ * @returns A list of `StreamMiddleware` implementations
79
+ */
80
+ unuse(protocol: string): void
81
+
82
+ /**
83
+ * Retrieve any registered middleware for a given protocol.
84
+ *
85
+ * @param protocol - The protocol to fetch middleware for
86
+ * @returns A list of `StreamMiddleware` implementations
87
+ */
88
+ getMiddleware(protocol: string): StreamMiddleware[]
89
+
67
90
  /**
68
91
  * Register a topology handler for a protocol - the topology will be
69
92
  * invoked when peers are discovered on the network that support the