@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.
- package/LICENSE +4 -0
- package/README.md +36 -0
- package/dist/index.min.js +3 -0
- package/dist/src/address-manager/index.d.ts +37 -0
- package/dist/src/address-manager/index.d.ts.map +1 -0
- package/dist/src/address-manager/index.js +2 -0
- package/dist/src/address-manager/index.js.map +1 -0
- package/dist/src/connection-manager/index.d.ts +71 -0
- package/dist/src/connection-manager/index.d.ts.map +1 -0
- package/dist/src/connection-manager/index.js +2 -0
- package/dist/src/connection-manager/index.js.map +1 -0
- package/dist/src/index.d.ts +548 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/record/index.d.ts +33 -0
- package/dist/src/record/index.d.ts.map +1 -0
- package/dist/src/record/index.js +2 -0
- package/dist/src/record/index.js.map +1 -0
- package/dist/src/registrar/index.d.ts +60 -0
- package/dist/src/registrar/index.d.ts.map +1 -0
- package/dist/src/registrar/index.js +2 -0
- package/dist/src/registrar/index.js.map +1 -0
- package/dist/src/transport-manager/index.d.ts +15 -0
- package/dist/src/transport-manager/index.d.ts.map +1 -0
- package/dist/src/transport-manager/index.js +2 -0
- package/dist/src/transport-manager/index.js.map +1 -0
- package/dist/src/upgrader/index.d.ts +18 -0
- package/dist/src/upgrader/index.d.ts.map +1 -0
- package/dist/src/upgrader/index.js +2 -0
- package/dist/src/upgrader/index.js.map +1 -0
- package/package.json +96 -0
- package/src/address-manager/index.ts +43 -0
- package/src/connection-manager/index.ts +79 -0
- package/src/index.ts +598 -0
- package/src/record/index.ts +35 -0
- package/src/registrar/index.ts +71 -0
- package/src/transport-manager/index.ts +15 -0
- package/src/upgrader/index.ts +20 -0
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @libp2p/interface-internal <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
[](http://libp2p.io/)
|
|
4
|
+
[](https://discuss.libp2p.io)
|
|
5
|
+
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
6
|
+
[](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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":""}
|