@libp2p/interface-internal 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.
- 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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Connection } from '@libp2p/interface/connection';
|
|
2
|
+
import type { Listener, Transport } from '@libp2p/interface/transport';
|
|
3
|
+
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
4
|
+
export interface TransportManager {
|
|
5
|
+
add: (transport: Transport) => void;
|
|
6
|
+
dial: (ma: Multiaddr, options?: any) => Promise<Connection>;
|
|
7
|
+
getAddrs: () => Multiaddr[];
|
|
8
|
+
getTransports: () => Transport[];
|
|
9
|
+
getListeners: () => Listener[];
|
|
10
|
+
transportForMultiaddr: (ma: Multiaddr) => Transport | undefined;
|
|
11
|
+
listen: (addrs: Multiaddr[]) => Promise<void>;
|
|
12
|
+
remove: (key: string) => Promise<void>;
|
|
13
|
+
removeAll: () => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAA;IACnC,IAAI,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAC3D,QAAQ,EAAE,MAAM,SAAS,EAAE,CAAA;IAC3B,aAAa,EAAE,MAAM,SAAS,EAAE,CAAA;IAChC,YAAY,EAAE,MAAM,QAAQ,EAAE,CAAA;IAC9B,qBAAqB,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,SAAS,GAAG,SAAS,CAAA;IAC/D,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport-manager/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Connection, MultiaddrConnection } from '@libp2p/interface/connection';
|
|
2
|
+
import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer';
|
|
3
|
+
export interface UpgraderOptions {
|
|
4
|
+
skipEncryption?: boolean;
|
|
5
|
+
skipProtection?: boolean;
|
|
6
|
+
muxerFactory?: StreamMuxerFactory;
|
|
7
|
+
}
|
|
8
|
+
export interface Upgrader {
|
|
9
|
+
/**
|
|
10
|
+
* Upgrades an outbound connection on `transport.dial`.
|
|
11
|
+
*/
|
|
12
|
+
upgradeOutbound: (maConn: MultiaddrConnection, opts?: UpgraderOptions) => Promise<Connection>;
|
|
13
|
+
/**
|
|
14
|
+
* Upgrades an inbound connection on transport listener.
|
|
15
|
+
*/
|
|
16
|
+
upgradeInbound: (maConn: MultiaddrConnection, opts?: UpgraderOptions) => Promise<Connection>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/upgrader/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAExE,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAE7F;;OAEG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CAC7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/upgrader/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@libp2p/interface-internal",
|
|
3
|
+
"version": "0.0.1-05abd49f",
|
|
4
|
+
"description": "Interfaces implemented by internal libp2p components",
|
|
5
|
+
"license": "Apache-2.0 OR MIT",
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface-internal#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/libp2p/js-libp2p/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"interface",
|
|
16
|
+
"libp2p"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"types": "./dist/src/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
"*": [
|
|
23
|
+
"*",
|
|
24
|
+
"dist/*",
|
|
25
|
+
"dist/src/*",
|
|
26
|
+
"dist/src/*/index"
|
|
27
|
+
],
|
|
28
|
+
"src/*": [
|
|
29
|
+
"*",
|
|
30
|
+
"dist/*",
|
|
31
|
+
"dist/src/*",
|
|
32
|
+
"dist/src/*/index"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"src",
|
|
38
|
+
"dist",
|
|
39
|
+
"!dist/test",
|
|
40
|
+
"!**/*.tsbuildinfo"
|
|
41
|
+
],
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/src/index.d.ts",
|
|
45
|
+
"import": "./dist/src/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./address-manager": {
|
|
48
|
+
"types": "./dist/src/address-manager/index.d.ts",
|
|
49
|
+
"import": "./dist/src/address-manager/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./connection-manager": {
|
|
52
|
+
"types": "./dist/src/connection-manager/index.d.ts",
|
|
53
|
+
"import": "./dist/src/connection-manager/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./record": {
|
|
56
|
+
"types": "./dist/src/record/index.d.ts",
|
|
57
|
+
"import": "./dist/src/record/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./registrar": {
|
|
60
|
+
"types": "./dist/src/registrar/index.d.ts",
|
|
61
|
+
"import": "./dist/src/registrar/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./transport": {
|
|
64
|
+
"types": "./dist/src/transport/index.d.ts",
|
|
65
|
+
"import": "./dist/src/transport/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./transport-manager": {
|
|
68
|
+
"types": "./dist/src/transport-manager/index.d.ts",
|
|
69
|
+
"import": "./dist/src/transport-manager/index.js"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"eslintConfig": {
|
|
73
|
+
"extends": "ipfs",
|
|
74
|
+
"parserOptions": {
|
|
75
|
+
"sourceType": "module"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"clean": "aegir clean",
|
|
80
|
+
"lint": "aegir lint",
|
|
81
|
+
"dep-check": "aegir dep-check",
|
|
82
|
+
"build": "aegir build"
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"@libp2p/interface": "0.0.1-05abd49f",
|
|
86
|
+
"@libp2p/peer-collections": "3.0.2-05abd49f",
|
|
87
|
+
"@multiformats/multiaddr": "^12.1.3",
|
|
88
|
+
"uint8arraylist": "^2.4.3"
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"aegir": "^39.0.10"
|
|
92
|
+
},
|
|
93
|
+
"typedoc": {
|
|
94
|
+
"entryPoint": "./src/index.ts"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
2
|
+
|
|
3
|
+
export interface AddressManager {
|
|
4
|
+
/**
|
|
5
|
+
* Get peer listen multiaddrs
|
|
6
|
+
*/
|
|
7
|
+
getListenAddrs: () => Multiaddr[]
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get peer announcing multiaddrs
|
|
11
|
+
*/
|
|
12
|
+
getAnnounceAddrs: () => Multiaddr[]
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get observed multiaddrs - these addresses may not have been confirmed as
|
|
16
|
+
* publicly dialable yet
|
|
17
|
+
*/
|
|
18
|
+
getObservedAddrs: () => Multiaddr[]
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Signal that we have confidence an observed multiaddr is publicly dialable -
|
|
22
|
+
* this will make it appear in the output of getAddresses()
|
|
23
|
+
*/
|
|
24
|
+
confirmObservedAddr: (addr: Multiaddr) => void
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Signal that we do not have confidence an observed multiaddr is publicly dialable -
|
|
28
|
+
* this will remove it from the output of getObservedAddrs()
|
|
29
|
+
*/
|
|
30
|
+
removeObservedAddr: (addr: Multiaddr) => void
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Add peer observed addresses. These will then appear in the output of getObservedAddrs
|
|
34
|
+
* but not getAddresses() until their dialability has been confirmed via a call to
|
|
35
|
+
* confirmObservedAddr.
|
|
36
|
+
*/
|
|
37
|
+
addObservedAddr: (addr: Multiaddr) => void
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get the current node's addresses
|
|
41
|
+
*/
|
|
42
|
+
getAddresses: () => Multiaddr[]
|
|
43
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
|
|
7
|
+
export type PendingDialStatus = 'queued' | 'active' | 'error' | 'success'
|
|
8
|
+
|
|
9
|
+
export interface PendingDial {
|
|
10
|
+
id: string
|
|
11
|
+
status: PendingDialStatus
|
|
12
|
+
peerId?: PeerId
|
|
13
|
+
multiaddrs: Multiaddr[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ConnectionManager {
|
|
17
|
+
/**
|
|
18
|
+
* Return connections, optionally filtering by a PeerId
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* ```js
|
|
23
|
+
* const connections = libp2p.connectionManager.get(peerId)
|
|
24
|
+
* // []
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
getConnections: (peerId?: PeerId) => Connection[]
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Return a map of all connections with their associated PeerIds
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
*
|
|
34
|
+
* ```js
|
|
35
|
+
* const connectionsMap = libp2p.connectionManager.getConnectionsMap()
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
getConnectionsMap: () => PeerMap<Connection[]>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Open a connection to a remote peer
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* ```js
|
|
46
|
+
* const connection = await libp2p.connectionManager.openConnection(peerId)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
openConnection: (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions) => Promise<Connection>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Close our connections to a peer
|
|
53
|
+
*/
|
|
54
|
+
closeConnections: (peer: PeerId) => Promise<void>
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Invoked after an incoming connection is opened but before PeerIds are
|
|
58
|
+
* exchanged, this lets the ConnectionManager check we have sufficient
|
|
59
|
+
* resources to accept the connection in which case it will return true,
|
|
60
|
+
* otherwise it will return false.
|
|
61
|
+
*/
|
|
62
|
+
acceptIncomingConnection: (maConn: MultiaddrConnection) => Promise<boolean>
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Invoked after upgrading a multiaddr connection has finished
|
|
66
|
+
*/
|
|
67
|
+
afterUpgradeInbound: () => void
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Return the list of in-progress or queued dials
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
*
|
|
74
|
+
* ```js
|
|
75
|
+
* const dials = libp2p.connectionManager.getDialQueue()
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
getDialQueue: () => PendingDial[]
|
|
79
|
+
}
|