@libp2p/interface 0.0.1-05abd49f

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 (129) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +45 -0
  3. package/dist/index.min.js +3 -0
  4. package/dist/src/connection/index.d.ts +188 -0
  5. package/dist/src/connection/index.d.ts.map +1 -0
  6. package/dist/src/connection/index.js +5 -0
  7. package/dist/src/connection/index.js.map +1 -0
  8. package/dist/src/connection/status.d.ts +4 -0
  9. package/dist/src/connection/status.d.ts.map +1 -0
  10. package/dist/src/connection/status.js +4 -0
  11. package/dist/src/connection/status.js.map +1 -0
  12. package/dist/src/connection-encrypter/index.d.ts +27 -0
  13. package/dist/src/connection-encrypter/index.d.ts.map +1 -0
  14. package/dist/src/connection-encrypter/index.js +2 -0
  15. package/dist/src/connection-encrypter/index.js.map +1 -0
  16. package/dist/src/connection-gater/index.d.ts +117 -0
  17. package/dist/src/connection-gater/index.d.ts.map +1 -0
  18. package/dist/src/connection-gater/index.js +2 -0
  19. package/dist/src/connection-gater/index.js.map +1 -0
  20. package/dist/src/content-routing/index.d.ts +79 -0
  21. package/dist/src/content-routing/index.d.ts.map +1 -0
  22. package/dist/src/content-routing/index.js +21 -0
  23. package/dist/src/content-routing/index.js.map +1 -0
  24. package/dist/src/errors.d.ts +33 -0
  25. package/dist/src/errors.d.ts.map +1 -0
  26. package/dist/src/errors.js +51 -0
  27. package/dist/src/errors.js.map +1 -0
  28. package/dist/src/events.d.ts +28 -0
  29. package/dist/src/events.d.ts.map +1 -0
  30. package/dist/src/events.js +70 -0
  31. package/dist/src/events.js.map +1 -0
  32. package/dist/src/index.d.ts +575 -0
  33. package/dist/src/index.d.ts.map +1 -0
  34. package/dist/src/index.js +17 -0
  35. package/dist/src/index.js.map +1 -0
  36. package/dist/src/keychain/index.d.ts +154 -0
  37. package/dist/src/keychain/index.d.ts.map +1 -0
  38. package/dist/src/keychain/index.js +23 -0
  39. package/dist/src/keychain/index.js.map +1 -0
  40. package/dist/src/keys/index.d.ts +35 -0
  41. package/dist/src/keys/index.d.ts.map +1 -0
  42. package/dist/src/keys/index.js +4 -0
  43. package/dist/src/keys/index.js.map +1 -0
  44. package/dist/src/metrics/index.d.ts +165 -0
  45. package/dist/src/metrics/index.d.ts.map +1 -0
  46. package/dist/src/metrics/index.js +2 -0
  47. package/dist/src/metrics/index.js.map +1 -0
  48. package/dist/src/metrics/tracked-map.d.ts +17 -0
  49. package/dist/src/metrics/tracked-map.d.ts.map +1 -0
  50. package/dist/src/metrics/tracked-map.js +38 -0
  51. package/dist/src/metrics/tracked-map.js.map +1 -0
  52. package/dist/src/peer-discovery/index.d.ts +28 -0
  53. package/dist/src/peer-discovery/index.d.ts.map +1 -0
  54. package/dist/src/peer-discovery/index.js +21 -0
  55. package/dist/src/peer-discovery/index.js.map +1 -0
  56. package/dist/src/peer-id/index.d.ts +30 -0
  57. package/dist/src/peer-id/index.d.ts.map +1 -0
  58. package/dist/src/peer-id/index.js +5 -0
  59. package/dist/src/peer-id/index.js.map +1 -0
  60. package/dist/src/peer-info/index.d.ts +8 -0
  61. package/dist/src/peer-info/index.d.ts.map +1 -0
  62. package/dist/src/peer-info/index.js +2 -0
  63. package/dist/src/peer-info/index.js.map +1 -0
  64. package/dist/src/peer-routing/index.d.ts +51 -0
  65. package/dist/src/peer-routing/index.d.ts.map +1 -0
  66. package/dist/src/peer-routing/index.js +21 -0
  67. package/dist/src/peer-routing/index.js.map +1 -0
  68. package/dist/src/peer-store/index.d.ts +247 -0
  69. package/dist/src/peer-store/index.d.ts.map +1 -0
  70. package/dist/src/peer-store/index.js +2 -0
  71. package/dist/src/peer-store/index.js.map +1 -0
  72. package/dist/src/peer-store/tags.d.ts +2 -0
  73. package/dist/src/peer-store/tags.d.ts.map +1 -0
  74. package/dist/src/peer-store/tags.js +2 -0
  75. package/dist/src/peer-store/tags.js.map +1 -0
  76. package/dist/src/record/index.d.ts +33 -0
  77. package/dist/src/record/index.d.ts.map +1 -0
  78. package/dist/src/record/index.js +2 -0
  79. package/dist/src/record/index.js.map +1 -0
  80. package/dist/src/startable.d.ts +46 -0
  81. package/dist/src/startable.d.ts.map +1 -0
  82. package/dist/src/startable.js +46 -0
  83. package/dist/src/startable.js.map +1 -0
  84. package/dist/src/stream-handler/index.d.ts +23 -0
  85. package/dist/src/stream-handler/index.d.ts.map +1 -0
  86. package/dist/src/stream-handler/index.js +2 -0
  87. package/dist/src/stream-handler/index.js.map +1 -0
  88. package/dist/src/stream-muxer/index.d.ts +51 -0
  89. package/dist/src/stream-muxer/index.d.ts.map +1 -0
  90. package/dist/src/stream-muxer/index.js +2 -0
  91. package/dist/src/stream-muxer/index.js.map +1 -0
  92. package/dist/src/stream-muxer/stream.d.ts +85 -0
  93. package/dist/src/stream-muxer/stream.d.ts.map +1 -0
  94. package/dist/src/stream-muxer/stream.js +255 -0
  95. package/dist/src/stream-muxer/stream.js.map +1 -0
  96. package/dist/src/topology/index.d.ts +9 -0
  97. package/dist/src/topology/index.d.ts.map +1 -0
  98. package/dist/src/topology/index.js +2 -0
  99. package/dist/src/topology/index.js.map +1 -0
  100. package/dist/src/transport/index.d.ts +96 -0
  101. package/dist/src/transport/index.d.ts.map +1 -0
  102. package/dist/src/transport/index.js +19 -0
  103. package/dist/src/transport/index.js.map +1 -0
  104. package/package.json +177 -0
  105. package/src/connection/index.ts +221 -0
  106. package/src/connection/status.ts +4 -0
  107. package/src/connection-encrypter/index.ts +30 -0
  108. package/src/connection-gater/index.ts +128 -0
  109. package/src/content-routing/index.ts +83 -0
  110. package/src/errors.ts +68 -0
  111. package/src/events.ts +100 -0
  112. package/src/index.ts +627 -0
  113. package/src/keychain/index.ts +167 -0
  114. package/src/keys/index.ts +38 -0
  115. package/src/metrics/index.ts +187 -0
  116. package/src/metrics/tracked-map.ts +65 -0
  117. package/src/peer-discovery/index.ts +29 -0
  118. package/src/peer-id/index.ts +39 -0
  119. package/src/peer-info/index.ts +8 -0
  120. package/src/peer-routing/index.ts +53 -0
  121. package/src/peer-store/index.ts +272 -0
  122. package/src/peer-store/tags.ts +2 -0
  123. package/src/record/index.ts +35 -0
  124. package/src/startable.ts +117 -0
  125. package/src/stream-handler/index.ts +27 -0
  126. package/src/stream-muxer/index.ts +58 -0
  127. package/src/stream-muxer/stream.ts +365 -0
  128. package/src/topology/index.ts +10 -0
  129. package/src/transport/index.ts +111 -0
package/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ This project is dual licensed under MIT and Apache-2.0.
2
+
3
+ MIT: https://www.opensource.org/licenses/mit
4
+ Apache-2.0: https://www.apache.org/licenses/license-2.0
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @libp2p/interface <!-- omit in toc -->
2
+
3
+ [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
+ [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
5
+ [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)
7
+
8
+ > The interface implemented by a libp2p node
9
+
10
+ ## Table of contents <!-- omit in toc -->
11
+
12
+ - [Install](#install)
13
+ - [Browser `<script>` tag](#browser-script-tag)
14
+ - [API Docs](#api-docs)
15
+ - [License](#license)
16
+ - [Contribution](#contribution)
17
+
18
+ ## Install
19
+
20
+ ```console
21
+ $ npm i @libp2p/interface
22
+ ```
23
+
24
+ ### Browser `<script>` tag
25
+
26
+ Loading this module through a script tag will make it's exports available as `Libp2pInterface` in the global namespace.
27
+
28
+ ```html
29
+ <script src="https://unpkg.com/@libp2p/interface/dist/index.min.js"></script>
30
+ ```
31
+
32
+ ## API Docs
33
+
34
+ - <https://libp2p.github.io/js-libp2p/modules/_libp2p_interface.html>
35
+
36
+ ## License
37
+
38
+ Licensed under either of
39
+
40
+ - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
41
+ - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
42
+
43
+ ## Contribution
44
+
45
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
@@ -0,0 +1,3 @@
1
+ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PInterface = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
+ "use strict";var Libp2PInterface=(()=>{var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(o,e,x,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of b(e))!c.call(o,p)&&p!==x&&t(o,p,{get:()=>e[p],enumerable:!(r=a(e,p))||r.enumerable});return o};var f=o=>d(t({},"__esModule",{value:!0}),o);var g={};return f(g);})();
3
+ return Libp2PInterface}));
@@ -0,0 +1,188 @@
1
+ import type * as Status from './status.js';
2
+ import type { AbortOptions } from '../index.js';
3
+ import type { PeerId } from '../peer-id/index.js';
4
+ import type { Multiaddr } from '@multiformats/multiaddr';
5
+ import type { Duplex, Source } from 'it-stream-types';
6
+ import type { Uint8ArrayList } from 'uint8arraylist';
7
+ export interface ConnectionTimeline {
8
+ open: number;
9
+ upgraded?: number;
10
+ close?: number;
11
+ }
12
+ /**
13
+ * Outbound conections are opened by the local node, inbound streams are opened by the remote
14
+ */
15
+ export type Direction = 'inbound' | 'outbound';
16
+ export interface ConnectionStat {
17
+ /**
18
+ * Outbound conections are opened by the local node, inbound streams are opened by the remote
19
+ */
20
+ direction: Direction;
21
+ /**
22
+ * Lifecycle times for the connection
23
+ */
24
+ timeline: ConnectionTimeline;
25
+ /**
26
+ * Once a multiplexer has been negotiated for this stream, it will be set on the stat object
27
+ */
28
+ multiplexer?: string;
29
+ /**
30
+ * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
31
+ */
32
+ encryption?: string;
33
+ /**
34
+ * The current status of the connection
35
+ */
36
+ status: keyof typeof Status;
37
+ }
38
+ export interface StreamTimeline {
39
+ /**
40
+ * A timestamp of when the stream was opened
41
+ */
42
+ open: number;
43
+ /**
44
+ * A timestamp of when the stream was closed for both reading and writing
45
+ */
46
+ close?: number;
47
+ /**
48
+ * A timestamp of when the stream was closed for reading
49
+ */
50
+ closeRead?: number;
51
+ /**
52
+ * A timestamp of when the stream was closed for writing
53
+ */
54
+ closeWrite?: number;
55
+ /**
56
+ * A timestamp of when the stream was reset
57
+ */
58
+ reset?: number;
59
+ }
60
+ export interface StreamStat {
61
+ /**
62
+ * Outbound streams are opened by the local node, inbound streams are opened by the remote
63
+ */
64
+ direction: Direction;
65
+ /**
66
+ * Lifecycle times for the stream
67
+ */
68
+ timeline: StreamTimeline;
69
+ /**
70
+ * Once a protocol has been negotiated for this stream, it will be set on the stat object
71
+ */
72
+ protocol?: string;
73
+ }
74
+ /**
75
+ * A Stream is a data channel between two peers that
76
+ * can be written to and read from at both ends.
77
+ *
78
+ * It may be encrypted and multiplexed depending on the
79
+ * configuration of the nodes.
80
+ */
81
+ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>, Promise<void>> {
82
+ /**
83
+ * Closes the stream for **reading** *and* **writing**.
84
+ *
85
+ * Any buffered data in the source can still be consumed and the stream will end normally.
86
+ *
87
+ * This will cause a `CLOSE` message to be sent to the remote, *unless* the sink has already ended.
88
+ *
89
+ * The sink and the source will return normally.
90
+ */
91
+ close: () => void;
92
+ /**
93
+ * Closes the stream for **reading**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
94
+ *
95
+ * This function is called automatically by the muxer when it receives a `CLOSE` message from the remote.
96
+ *
97
+ * The source will return normally, the sink will continue to consume.
98
+ */
99
+ closeRead: () => void;
100
+ /**
101
+ * Closes the stream for **writing**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
102
+ *
103
+ * The source will return normally, the sink will continue to consume.
104
+ */
105
+ closeWrite: () => void;
106
+ /**
107
+ * Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred.
108
+ *
109
+ * Note, if called without an error any buffered data in the source can still be consumed and the stream will end normally.
110
+ *
111
+ * This will cause a `RESET` message to be sent to the remote, *unless* the sink has already ended.
112
+ *
113
+ * The sink will return and the source will throw if an error is passed or return normally if not.
114
+ */
115
+ abort: (err: Error) => void;
116
+ /**
117
+ * Closes the stream *immediately* for **reading** *and* **writing**. This should be called when a *remote error* has occurred.
118
+ *
119
+ * This function is called automatically by the muxer when it receives a `RESET` message from the remote.
120
+ *
121
+ * The sink will return and the source will throw.
122
+ */
123
+ reset: () => void;
124
+ /**
125
+ * Unique identifier for a stream. Identifiers are not unique across muxers.
126
+ */
127
+ id: string;
128
+ /**
129
+ * Stats about this stream
130
+ */
131
+ stat: StreamStat;
132
+ /**
133
+ * User defined stream metadata
134
+ */
135
+ metadata: Record<string, any>;
136
+ }
137
+ export interface NewStreamOptions extends AbortOptions {
138
+ /**
139
+ * If specified, and no handler has been registered with the registrar for the
140
+ * successfully negotiated protocol, use this as the max outbound stream limit
141
+ * for the protocol
142
+ */
143
+ maxOutboundStreams?: number;
144
+ }
145
+ /**
146
+ * A Connection is a high-level representation of a connection
147
+ * to a remote peer that may have been secured by encryption and
148
+ * multiplexed, depending on the configuration of the nodes
149
+ * between which the connection is made.
150
+ */
151
+ export interface Connection {
152
+ id: string;
153
+ stat: ConnectionStat;
154
+ remoteAddr: Multiaddr;
155
+ remotePeer: PeerId;
156
+ tags: string[];
157
+ streams: Stream[];
158
+ newStream: (multicodecs: string | string[], options?: NewStreamOptions) => Promise<Stream>;
159
+ addStream: (stream: Stream) => void;
160
+ removeStream: (id: string) => void;
161
+ close: () => Promise<void>;
162
+ }
163
+ export declare const symbol: unique symbol;
164
+ export declare function isConnection(other: any): other is Connection;
165
+ export interface ConnectionProtector {
166
+ /**
167
+ * Takes a given Connection and creates a private encryption stream
168
+ * between its two peers from the PSK the Protector instance was
169
+ * created with.
170
+ */
171
+ protect: (connection: MultiaddrConnection) => Promise<MultiaddrConnection>;
172
+ }
173
+ export interface MultiaddrConnectionTimeline {
174
+ open: number;
175
+ upgraded?: number;
176
+ close?: number;
177
+ }
178
+ /**
179
+ * A MultiaddrConnection is returned by transports after dialing
180
+ * a peer. It is a low-level primitive and is the raw connection
181
+ * without encryption or stream multiplexing.
182
+ */
183
+ export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> {
184
+ close: (err?: Error) => Promise<void>;
185
+ remoteAddr: Multiaddr;
186
+ timeline: MultiaddrConnectionTimeline;
187
+ }
188
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS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AAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAChH,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,UAAU,EAAE,SAAS,CAAA;IACrB,QAAQ,EAAE,2BAA2B,CAAA;CACtC"}
@@ -0,0 +1,5 @@
1
+ export const symbol = Symbol.for('@libp2p/connection');
2
+ export function isConnection(other) {
3
+ return other != null && Boolean(other[symbol]);
4
+ }
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AA6LA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const OPEN = "OPEN";
2
+ export declare const CLOSING = "CLOSING";
3
+ export declare const CLOSED = "CLOSED";
4
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/connection/status.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,MAAM,WAAW,CAAA"}
@@ -0,0 +1,4 @@
1
+ export const OPEN = 'OPEN';
2
+ export const CLOSING = 'CLOSING';
3
+ export const CLOSED = 'CLOSED';
4
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/connection/status.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAA;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,27 @@
1
+ import type { PeerId } from '../peer-id/index.js';
2
+ import type { Duplex, Source } from 'it-stream-types';
3
+ /**
4
+ * A libp2p connection encrypter module must be compliant to this interface
5
+ * to ensure all exchanged data between two peers is encrypted.
6
+ */
7
+ export interface ConnectionEncrypter<Extension = unknown> {
8
+ protocol: string;
9
+ /**
10
+ * Encrypt outgoing data to the remote party. If the remote PeerId is known,
11
+ * pass it for extra verification, otherwise it will be determined during
12
+ * the handshake.
13
+ */
14
+ secureOutbound: (localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>;
15
+ /**
16
+ * Decrypt incoming data. If the remote PeerId is known,
17
+ * pass it for extra verification, otherwise it will be determined during
18
+ * the handshake
19
+ */
20
+ secureInbound: (localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>;
21
+ }
22
+ export interface SecuredConnection<Extension = unknown> {
23
+ conn: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>;
24
+ remoteExtensions?: Extension;
25
+ remotePeer: PeerId;
26
+ }
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-encrypter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,SAAS,GAAG,OAAO;IACtD,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAA;IAEpL;;;;OAIG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAA;CACpL;AAED,MAAM,WAAW,iBAAiB,CAAC,SAAS,GAAG,OAAO;IACpD,IAAI,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3E,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-encrypter/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ import type { MultiaddrConnection } from '../connection/index.js';
2
+ import type { PeerId } from '../peer-id/index.js';
3
+ import type { Multiaddr } from '@multiformats/multiaddr';
4
+ export interface ConnectionGater {
5
+ /**
6
+ * denyDialPeer tests whether we're permitted to Dial the
7
+ * specified peer.
8
+ *
9
+ * This is called by the dialer.connectToPeer implementation before
10
+ * dialling a peer.
11
+ *
12
+ * Return true to prevent dialing the passed peer.
13
+ */
14
+ denyDialPeer?: (peerId: PeerId) => Promise<boolean>;
15
+ /**
16
+ * denyDialMultiaddr tests whether we're permitted to dial the specified
17
+ * multiaddr.
18
+ *
19
+ * This is called by the connection manager - if the peer id of the remote
20
+ * node is known it will be present in the multiaddr.
21
+ *
22
+ * Return true to prevent dialing the passed peer on the passed multiaddr.
23
+ */
24
+ denyDialMultiaddr?: (multiaddr: Multiaddr) => Promise<boolean>;
25
+ /**
26
+ * denyInboundConnection tests whether an incipient inbound connection is allowed.
27
+ *
28
+ * This is called by the upgrader, or by the transport directly (e.g. QUIC,
29
+ * Bluetooth), straight after it has accepted a connection from its socket.
30
+ *
31
+ * Return true to deny the incoming passed connection.
32
+ */
33
+ denyInboundConnection?: (maConn: MultiaddrConnection) => Promise<boolean>;
34
+ /**
35
+ * denyOutboundConnection tests whether an incipient outbound connection is allowed.
36
+ *
37
+ * This is called by the upgrader, or by the transport directly (e.g. QUIC,
38
+ * Bluetooth), straight after it has created a connection with its socket.
39
+ *
40
+ * Return true to deny the incoming passed connection.
41
+ */
42
+ denyOutboundConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>;
43
+ /**
44
+ * denyInboundEncryptedConnection tests whether a given connection, now encrypted,
45
+ * is allowed.
46
+ *
47
+ * This is called by the upgrader, after it has performed the security
48
+ * handshake, and before it negotiates the muxer, or by the directly by the
49
+ * transport, at the exact same checkpoint.
50
+ *
51
+ * Return true to deny the passed secured connection.
52
+ */
53
+ denyInboundEncryptedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>;
54
+ /**
55
+ * denyOutboundEncryptedConnection tests whether a given connection, now encrypted,
56
+ * is allowed.
57
+ *
58
+ * This is called by the upgrader, after it has performed the security
59
+ * handshake, and before it negotiates the muxer, or by the directly by the
60
+ * transport, at the exact same checkpoint.
61
+ *
62
+ * Return true to deny the passed secured connection.
63
+ */
64
+ denyOutboundEncryptedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>;
65
+ /**
66
+ * denyInboundUpgradedConnection tests whether a fully capable connection is allowed.
67
+ *
68
+ * This is called after encryption has been negotiated and the connection has been
69
+ * multiplexed, if a multiplexer is configured.
70
+ *
71
+ * Return true to deny the passed upgraded connection.
72
+ */
73
+ denyInboundUpgradedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>;
74
+ /**
75
+ * denyOutboundUpgradedConnection tests whether a fully capable connection is allowed.
76
+ *
77
+ * This is called after encryption has been negotiated and the connection has been
78
+ * multiplexed, if a multiplexer is configured.
79
+ *
80
+ * Return true to deny the passed upgraded connection.
81
+ */
82
+ denyOutboundUpgradedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>;
83
+ /**
84
+ * denyInboundRelayReservation tests whether a remote peer is allowed make a
85
+ * relay reservation on this node.
86
+ *
87
+ * Return true to deny the relay reservation.
88
+ */
89
+ denyInboundRelayReservation?: (source: PeerId) => Promise<boolean>;
90
+ /**
91
+ * denyOutboundRelayedConnection tests whether a remote peer is allowed to open a relayed
92
+ * connection to the destination node.
93
+ *
94
+ * This is invoked on the relay server when a source client with a reservation instructs
95
+ * the server to relay a connection to a destination peer.
96
+ *
97
+ * Return true to deny the relayed connection.
98
+ */
99
+ denyOutboundRelayedConnection?: (source: PeerId, destination: PeerId) => Promise<boolean>;
100
+ /**
101
+ * denyInboundRelayedConnection tests whether a remote peer is allowed to open a relayed
102
+ * connection to this node.
103
+ *
104
+ * This is invoked on the relay client when a remote relay has received an instruction to
105
+ * relay a connection to the client.
106
+ *
107
+ * Return true to deny the relayed connection.
108
+ */
109
+ denyInboundRelayedConnection?: (relay: PeerId, remotePeer: PeerId) => Promise<boolean>;
110
+ /**
111
+ * Used by the address book to filter passed addresses.
112
+ *
113
+ * Return true to allow storing the passed multiaddr for the passed peer.
114
+ */
115
+ filterMultiaddrForPeer?: (peer: PeerId, multiaddr: Multiaddr) => Promise<boolean>;
116
+ }
117
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":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AKG;IACH,2BAA2B,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAElE;;;;;;;;OAQG;IACH,6BAA6B,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAEzF;;;;;;;;OAQG;IACH,4BAA4B,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAEtF;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAClF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-gater/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ import type { AbortOptions } from '../index.js';
2
+ import type { PeerInfo } from '../peer-info/index.js';
3
+ import type { CID } from 'multiformats/cid';
4
+ /**
5
+ * Any object that implements this Symbol as a property should return a
6
+ * ContentRouting instance as the property value, similar to how
7
+ * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.
8
+ *
9
+ * @example
10
+ *
11
+ * ```js
12
+ * import { contentRouting, ContentRouting } from '@libp2p/content-routing'
13
+ *
14
+ * class MyContentRouter implements ContentRouting {
15
+ * get [contentRouting] () {
16
+ * return this
17
+ * }
18
+ *
19
+ * // ...other methods
20
+ * }
21
+ * ```
22
+ */
23
+ export declare const contentRouting: unique symbol;
24
+ export interface ContentRouting {
25
+ /**
26
+ * The implementation of this method should ensure that network peers know the
27
+ * caller can provide content that corresponds to the passed CID.
28
+ *
29
+ * @example
30
+ *
31
+ * ```js
32
+ * // ...
33
+ * await contentRouting.provide(cid)
34
+ * ```
35
+ */
36
+ provide: (cid: CID, options?: AbortOptions) => Promise<void>;
37
+ /**
38
+ * Find the providers of the passed CID.
39
+ *
40
+ * @example
41
+ *
42
+ * ```js
43
+ * // Iterate over the providers found for the given cid
44
+ * for await (const provider of contentRouting.findProviders(cid)) {
45
+ * console.log(provider.id, provider.multiaddrs)
46
+ * }
47
+ * ```
48
+ */
49
+ findProviders: (cid: CID, options?: AbortOptions) => AsyncIterable<PeerInfo>;
50
+ /**
51
+ * Puts a value corresponding to the passed key in a way that can later be
52
+ * retrieved by another network peer using the get method.
53
+ *
54
+ * @example
55
+ *
56
+ * ```js
57
+ * // ...
58
+ * const key = '/key'
59
+ * const value = uint8ArrayFromString('oh hello there')
60
+ *
61
+ * await contentRouting.put(key, value)
62
+ * ```
63
+ */
64
+ put: (key: Uint8Array, value: Uint8Array, options?: AbortOptions) => Promise<void>;
65
+ /**
66
+ * Retrieves a value from the network corresponding to the passed key.
67
+ *
68
+ * @example
69
+ *
70
+ * ```js
71
+ * // ...
72
+ *
73
+ * const key = '/key'
74
+ * const value = await contentRouting.get(key)
75
+ * ```
76
+ */
77
+ get: (key: Uint8Array, options?: AbortOptions) => Promise<Uint8Array>;
78
+ }
79
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/content-routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,eAAwC,CAAA;AAEnE,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5D;;;;;;;;;;;OAWG;IACH,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,aAAa,CAAC,QAAQ,CAAC,CAAA;IAE5E;;;;;;;;;;;;;OAaG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAElF;;;;;;;;;;;OAWG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CACtE"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Any object that implements this Symbol as a property should return a
3
+ * ContentRouting instance as the property value, similar to how
4
+ * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.
5
+ *
6
+ * @example
7
+ *
8
+ * ```js
9
+ * import { contentRouting, ContentRouting } from '@libp2p/content-routing'
10
+ *
11
+ * class MyContentRouter implements ContentRouting {
12
+ * get [contentRouting] () {
13
+ * return this
14
+ * }
15
+ *
16
+ * // ...other methods
17
+ * }
18
+ * ```
19
+ */
20
+ export const contentRouting = Symbol.for('@libp2p/content-routing');
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-routing/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * When this error is thrown it means an operation was aborted,
3
+ * usually in response to the `abort` event being emitted by an
4
+ * AbortSignal.
5
+ */
6
+ export declare class AbortError extends Error {
7
+ readonly code: string;
8
+ readonly type: string;
9
+ constructor(message?: string);
10
+ static readonly code = "ABORT_ERR";
11
+ static readonly type = "aborted";
12
+ }
13
+ export declare class CodeError<T extends Record<string, any> = Record<string, never>> extends Error {
14
+ readonly code: string;
15
+ readonly props: T;
16
+ constructor(message: string, code: string, props?: T);
17
+ }
18
+ export declare class UnexpectedPeerError extends Error {
19
+ code: string;
20
+ constructor(message?: string);
21
+ static readonly code = "ERR_UNEXPECTED_PEER";
22
+ }
23
+ export declare class InvalidCryptoExchangeError extends Error {
24
+ code: string;
25
+ constructor(message?: string);
26
+ static readonly code = "ERR_INVALID_CRYPTO_EXCHANGE";
27
+ }
28
+ export declare class InvalidCryptoTransmissionError extends Error {
29
+ code: string;
30
+ constructor(message?: string);
31
+ static readonly code = "ERR_INVALID_CRYPTO_TRANSMISSION";
32
+ }
33
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,IAAI,EAAE,MAAM,CAAA;gBAEf,OAAO,GAAE,MAAoC;IAM1D,MAAM,CAAC,QAAQ,CAAC,IAAI,eAAc;IAElC,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAY;CACjC;AAED,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAE,SAAQ,KAAK;aAKvE,IAAI,EAAE,MAAM;IAJ9B,SAAgB,KAAK,EAAE,CAAC,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EAC5B,KAAK,CAAC,EAAE,CAAC;CAOZ;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAAoB;IAKxC,MAAM,CAAC,QAAQ,CAAC,IAAI,yBAAwB;CAC7C;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IAC5C,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAA4B;IAKhD,MAAM,CAAC,QAAQ,CAAC,IAAI,iCAAgC;CACrD;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IAChD,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAAgC;IAKpD,MAAM,CAAC,QAAQ,CAAC,IAAI,qCAAoC;CACzD"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * When this error is thrown it means an operation was aborted,
3
+ * usually in response to the `abort` event being emitted by an
4
+ * AbortSignal.
5
+ */
6
+ export class AbortError extends Error {
7
+ code;
8
+ type;
9
+ constructor(message = 'The operation was aborted') {
10
+ super(message);
11
+ this.code = AbortError.code;
12
+ this.type = AbortError.type;
13
+ }
14
+ static code = 'ABORT_ERR';
15
+ static type = 'aborted';
16
+ }
17
+ export class CodeError extends Error {
18
+ code;
19
+ props;
20
+ constructor(message, code, props) {
21
+ super(message);
22
+ this.code = code;
23
+ this.name = props?.name ?? 'CodeError';
24
+ this.props = props ?? {}; // eslint-disable-line @typescript-eslint/consistent-type-assertions
25
+ }
26
+ }
27
+ export class UnexpectedPeerError extends Error {
28
+ code;
29
+ constructor(message = 'Unexpected Peer') {
30
+ super(message);
31
+ this.code = UnexpectedPeerError.code;
32
+ }
33
+ static code = 'ERR_UNEXPECTED_PEER';
34
+ }
35
+ export class InvalidCryptoExchangeError extends Error {
36
+ code;
37
+ constructor(message = 'Invalid crypto exchange') {
38
+ super(message);
39
+ this.code = InvalidCryptoExchangeError.code;
40
+ }
41
+ static code = 'ERR_INVALID_CRYPTO_EXCHANGE';
42
+ }
43
+ export class InvalidCryptoTransmissionError extends Error {
44
+ code;
45
+ constructor(message = 'Invalid crypto transmission') {
46
+ super(message);
47
+ this.code = InvalidCryptoTransmissionError.code;
48
+ }
49
+ static code = 'ERR_INVALID_CRYPTO_TRANSMISSION';
50
+ }
51
+ //# sourceMapping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