@libp2p/interface-internal 0.0.1-6fdaa7dc

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 (39) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +36 -0
  3. package/dist/index.min.js +3 -0
  4. package/dist/src/address-manager/index.d.ts +37 -0
  5. package/dist/src/address-manager/index.d.ts.map +1 -0
  6. package/dist/src/address-manager/index.js +2 -0
  7. package/dist/src/address-manager/index.js.map +1 -0
  8. package/dist/src/connection-manager/index.d.ts +71 -0
  9. package/dist/src/connection-manager/index.d.ts.map +1 -0
  10. package/dist/src/connection-manager/index.js +2 -0
  11. package/dist/src/connection-manager/index.js.map +1 -0
  12. package/dist/src/index.d.ts +548 -0
  13. package/dist/src/index.d.ts.map +1 -0
  14. package/dist/src/index.js +17 -0
  15. package/dist/src/index.js.map +1 -0
  16. package/dist/src/record/index.d.ts +33 -0
  17. package/dist/src/record/index.d.ts.map +1 -0
  18. package/dist/src/record/index.js +2 -0
  19. package/dist/src/record/index.js.map +1 -0
  20. package/dist/src/registrar/index.d.ts +60 -0
  21. package/dist/src/registrar/index.d.ts.map +1 -0
  22. package/dist/src/registrar/index.js +2 -0
  23. package/dist/src/registrar/index.js.map +1 -0
  24. package/dist/src/transport-manager/index.d.ts +15 -0
  25. package/dist/src/transport-manager/index.d.ts.map +1 -0
  26. package/dist/src/transport-manager/index.js +2 -0
  27. package/dist/src/transport-manager/index.js.map +1 -0
  28. package/dist/src/upgrader/index.d.ts +18 -0
  29. package/dist/src/upgrader/index.d.ts.map +1 -0
  30. package/dist/src/upgrader/index.js +2 -0
  31. package/dist/src/upgrader/index.js.map +1 -0
  32. package/package.json +96 -0
  33. package/src/address-manager/index.ts +43 -0
  34. package/src/connection-manager/index.ts +79 -0
  35. package/src/index.ts +598 -0
  36. package/src/record/index.ts +35 -0
  37. package/src/registrar/index.ts +71 -0
  38. package/src/transport-manager/index.ts +15 -0
  39. package/src/upgrader/index.ts +20 -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,36 @@
1
+ # @libp2p/interface-internal <!-- 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
+ > Interfaces implemented by internal libp2p components
9
+
10
+ ## Table of contents <!-- omit in toc -->
11
+
12
+ - [Install](#install)
13
+ - [API Docs](#api-docs)
14
+ - [License](#license)
15
+ - [Contribution](#contribution)
16
+
17
+ ## Install
18
+
19
+ ```console
20
+ $ npm i @libp2p/interface-internal
21
+ ```
22
+
23
+ ## API Docs
24
+
25
+ - <https://libp2p.github.io/js-libp2p/modules/_libp2p_interface_internal.html>
26
+
27
+ ## License
28
+
29
+ Licensed under either of
30
+
31
+ - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
32
+ - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
33
+
34
+ ## Contribution
35
+
36
+ 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.Libp2PInterfaceInternal = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
+ "use strict";var Libp2PInterfaceInternal=(()=>{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 Libp2PInterfaceInternal}));
@@ -0,0 +1,37 @@
1
+ import type { Multiaddr } from '@multiformats/multiaddr';
2
+ export interface AddressManager {
3
+ /**
4
+ * Get peer listen multiaddrs
5
+ */
6
+ getListenAddrs: () => Multiaddr[];
7
+ /**
8
+ * Get peer announcing multiaddrs
9
+ */
10
+ getAnnounceAddrs: () => Multiaddr[];
11
+ /**
12
+ * Get observed multiaddrs - these addresses may not have been confirmed as
13
+ * publicly dialable yet
14
+ */
15
+ getObservedAddrs: () => Multiaddr[];
16
+ /**
17
+ * Signal that we have confidence an observed multiaddr is publicly dialable -
18
+ * this will make it appear in the output of getAddresses()
19
+ */
20
+ confirmObservedAddr: (addr: Multiaddr) => void;
21
+ /**
22
+ * Signal that we do not have confidence an observed multiaddr is publicly dialable -
23
+ * this will remove it from the output of getObservedAddrs()
24
+ */
25
+ removeObservedAddr: (addr: Multiaddr) => void;
26
+ /**
27
+ * Add peer observed addresses. These will then appear in the output of getObservedAddrs
28
+ * but not getAddresses() until their dialability has been confirmed via a call to
29
+ * confirmObservedAddr.
30
+ */
31
+ addObservedAddr: (addr: Multiaddr) => void;
32
+ /**
33
+ * Get the current node's addresses
34
+ */
35
+ getAddresses: () => Multiaddr[];
36
+ }
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,cAAc,EAAE,MAAM,SAAS,EAAE,CAAA;IAEjC;;OAEG;IACH,gBAAgB,EAAE,MAAM,SAAS,EAAE,CAAA;IAEnC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,SAAS,EAAE,CAAA;IAEnC;;;OAGG;IACH,mBAAmB,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IAE9C;;;OAGG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IAE7C;;;;OAIG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IAE1C;;OAEG;IACH,YAAY,EAAE,MAAM,SAAS,EAAE,CAAA;CAChC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/address-manager/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ import type { AbortOptions } from '@libp2p/interface';
2
+ import type { Connection, MultiaddrConnection } from '@libp2p/interface/connection';
3
+ import type { PeerId } from '@libp2p/interface/peer-id';
4
+ import type { PeerMap } from '@libp2p/peer-collections';
5
+ import type { Multiaddr } from '@multiformats/multiaddr';
6
+ export type PendingDialStatus = 'queued' | 'active' | 'error' | 'success';
7
+ export interface PendingDial {
8
+ id: string;
9
+ status: PendingDialStatus;
10
+ peerId?: PeerId;
11
+ multiaddrs: Multiaddr[];
12
+ }
13
+ export interface ConnectionManager {
14
+ /**
15
+ * Return connections, optionally filtering by a PeerId
16
+ *
17
+ * @example
18
+ *
19
+ * ```js
20
+ * const connections = libp2p.connectionManager.get(peerId)
21
+ * // []
22
+ * ```
23
+ */
24
+ getConnections: (peerId?: PeerId) => Connection[];
25
+ /**
26
+ * Return a map of all connections with their associated PeerIds
27
+ *
28
+ * @example
29
+ *
30
+ * ```js
31
+ * const connectionsMap = libp2p.connectionManager.getConnectionsMap()
32
+ * ```
33
+ */
34
+ getConnectionsMap: () => PeerMap<Connection[]>;
35
+ /**
36
+ * Open a connection to a remote peer
37
+ *
38
+ * @example
39
+ *
40
+ * ```js
41
+ * const connection = await libp2p.connectionManager.openConnection(peerId)
42
+ * ```
43
+ */
44
+ openConnection: (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions) => Promise<Connection>;
45
+ /**
46
+ * Close our connections to a peer
47
+ */
48
+ closeConnections: (peer: PeerId) => Promise<void>;
49
+ /**
50
+ * Invoked after an incoming connection is opened but before PeerIds are
51
+ * exchanged, this lets the ConnectionManager check we have sufficient
52
+ * resources to accept the connection in which case it will return true,
53
+ * otherwise it will return false.
54
+ */
55
+ acceptIncomingConnection: (maConn: MultiaddrConnection) => Promise<boolean>;
56
+ /**
57
+ * Invoked after upgrading a multiaddr connection has finished
58
+ */
59
+ afterUpgradeInbound: () => void;
60
+ /**
61
+ * Return the list of in-progress or queued dials
62
+ *
63
+ * @example
64
+ *
65
+ * ```js
66
+ * const dials = libp2p.connectionManager.getDialQueue()
67
+ * ```
68
+ */
69
+ getDialQueue: () => PendingDial[];
70
+ }
71
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAEzE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,iBAAiB,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;OASG;IACH,cAAc,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,UAAU,EAAE,CAAA;IAEjD;;;;;;;;OAQG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IAE9C;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAEvG;;OAEG;IACH,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjD;;;;;OAKG;IACH,wBAAwB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAE3E;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAA;IAE/B;;;;;;;;OAQG;IACH,YAAY,EAAE,MAAM,WAAW,EAAE,CAAA;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":""}