mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-08 05:11:33 +00:00
Compare commits
370 Commits
refactor-a
...
fix/types-
Author | SHA1 | Date | |
---|---|---|---|
b10511eceb | |||
0f451659df | |||
eaf4fb7ac6 | |||
4bbd915a6d | |||
64124f17ed | |||
117f2b97b0 | |||
bbdaae17ae | |||
7461d2a642 | |||
f82a972ab2 | |||
b73106eba2 | |||
6b434aeaf7 | |||
44f07033fe | |||
91b15b6790 | |||
9205fce34d | |||
a4e858cbf5 | |||
3f1dc20caf | |||
8351adff2b | |||
22e41f5047 | |||
48476d504a | |||
186f9b758e | |||
20d9d98b3a | |||
87dcd2ec47 | |||
b87d42c074 | |||
df5fe0e3ab | |||
5d79a137ee | |||
8b6c738937 | |||
9faf1bfcf6 | |||
f9235e2ff6 | |||
f9786c8ab8 | |||
b45ef6aa54 | |||
d79ef8420e | |||
fba9457011 | |||
c22508c3e4 | |||
0ac8252b4c | |||
65ec267e7f | |||
48656712ea | |||
1a5ae74741 | |||
8691465a52 | |||
6350a187c7 | |||
8e3bb09279 | |||
73204958ee | |||
e9e4b731a5 | |||
d0a9fada32 | |||
824a444f56 | |||
fef54b2b2c | |||
8f29a667a1 | |||
093c0ea13f | |||
61c36f9e09 | |||
f82da56901 | |||
06f26e586f | |||
8879634363 | |||
4a80afce8f | |||
f75ae341bb | |||
f2d010a3ab | |||
e04224a1e2 | |||
4c6be91588 | |||
5f50054d94 | |||
d7d8439e71 | |||
4c7a89b710 | |||
4eabe07bde | |||
2fd3b0a0e5 | |||
ec6f7d1cfd | |||
a1053bdc54 | |||
0d48fc4f5a | |||
60d437f595 | |||
96df4b7dc4 | |||
bb59b518f1 | |||
fb4b2734d3 | |||
0087218194 | |||
58b793d700 | |||
63ba2f8fa3 | |||
bd26bde876 | |||
3c2a45a9d2 | |||
bbf8ef7065 | |||
d6d1a746ea | |||
28b79a76a8 | |||
81e70df742 | |||
e9478cee2e | |||
7be17a3ce1 | |||
93dda74085 | |||
cfbd52d7f7 | |||
6cd23ea6c9 | |||
9b75a0f184 | |||
b606ce0e91 | |||
64c8c0f097 | |||
9be582e222 | |||
55c9bfac44 | |||
1e869717ff | |||
9107efe121 | |||
cd09327eb6 | |||
ca57e65ecc | |||
f574e82a5d | |||
15613ccf19 | |||
dab1c8b2a5 | |||
d437defede | |||
74d414c21f | |||
8f2e69048f | |||
b0a36ccbc8 | |||
3158366579 | |||
1d318e12d8 | |||
8a97dded26 | |||
e50f0eeb7b | |||
ee57a643cc | |||
89658dd655 | |||
4ab125e017 | |||
71daac24b1 | |||
02a5095b9c | |||
3e5d450eca | |||
098f3d1dd3 | |||
689f90a698 | |||
0e3cc5866b | |||
4851680c4d | |||
0e18735b8c | |||
f68ff35625 | |||
8c56ec0d23 | |||
fa5ee873e3 | |||
51d7ca44c1 | |||
726a746479 | |||
a331b84f13 | |||
78d152dd68 | |||
7e14aa19b5 | |||
2440c872df | |||
6c7e5e5eef | |||
388df6b6e6 | |||
7dbfe6ab1a | |||
cea59a1fe4 | |||
7da9ad44ab | |||
3896941128 | |||
856b38de67 | |||
798d7b73c1 | |||
f2d0d8b51d | |||
999c1b7740 | |||
99ff361a55 | |||
6115f8b680 | |||
9ccab40fc8 | |||
619e5dd73c | |||
0fd23f6a5f | |||
5a84dd56d0 | |||
7b05d6922b | |||
08a4fad80b | |||
51da8874d8 | |||
5cd8c19567 | |||
db766eaca9 | |||
a1308d640d | |||
19e7254c3d | |||
f4898eb883 | |||
9bec719fce | |||
b664c0aafd | |||
b524bbf627 | |||
07bd269fb0 | |||
a8219e61a0 | |||
a1590acc8b | |||
a0cf83c640 | |||
b56cdda0ef | |||
b621fbdfdc | |||
24dd1d22c5 | |||
a1a1213bdc | |||
90a9d93968 | |||
8f680e20e9 | |||
afafd08943 | |||
c038550fad | |||
d60a3215d0 | |||
1e51295150 | |||
5299995998 | |||
64a66f08ac | |||
e2a63bab62 | |||
294b032b0b | |||
72f37acd4a | |||
52a615f922 | |||
698c1df1b4 | |||
7f4662f8d8 | |||
84b935f682 | |||
0fbb59748e | |||
56316b8c1e | |||
aaa1155633 | |||
aa5e232479 | |||
eb7adcf1ab | |||
0be74e6a61 | |||
6065923356 | |||
2b45fee0ed | |||
8bf5a70bb8 | |||
6627278a87 | |||
65e87460b0 | |||
7b8d01697d | |||
ce38033c10 | |||
3f2b06dc26 | |||
1e3d6f4b56 | |||
48a9a3eecc | |||
9ea9287bea | |||
5123a8357b | |||
43630f1e0b | |||
aaf62a40ec | |||
7fbd1556e8 | |||
51474c334a | |||
d75cc97ced | |||
2a7967c1cc | |||
9e9ec0b575 | |||
d3a4bf0a3f | |||
d33919d0b3 | |||
c215339a27 | |||
cb597b57d7 | |||
12e48adafa | |||
ed6d5bb4b4 | |||
e9d225c9dc | |||
2aac3b0f69 | |||
9862653051 | |||
b781911ac2 | |||
3fa1fa3a0b | |||
dfed982404 | |||
60b6a55906 | |||
aadeb73c94 | |||
ea6b1ecce4 | |||
d3ab238738 | |||
97455957ac | |||
5255d87d0a | |||
03ce7c3103 | |||
ea0621b2f6 | |||
9197df309b | |||
8dd361338b | |||
9b13fe321a | |||
1f85e0213a | |||
09a604b5e5 | |||
ed16b69057 | |||
c940f2d384 | |||
2620d46f01 | |||
e192eb6508 | |||
b57de4ed0c | |||
760d8b4c3a | |||
7b56f559cb | |||
0fd5188176 | |||
bd7fd0f755 | |||
da83721d6d | |||
1414e45969 | |||
9e35fbc316 | |||
30728753cf | |||
afdbe3deac | |||
ce58805e90 | |||
b5303fd788 | |||
aa78d2ef15 | |||
5a4641980d | |||
f4ec35573e | |||
524e6f8433 | |||
fad9cb22e0 | |||
e1b158fbb9 | |||
1837d6e95e | |||
4bce6aa0b9 | |||
4d11edd62c | |||
a8984c6cd3 | |||
0882dcea3b | |||
b3d8132ea6 | |||
a317a8b011 | |||
8bed8f39ff | |||
58c0c7c03e | |||
f662fdcf36 | |||
5608178247 | |||
dcd58693f5 | |||
8bf05e6db6 | |||
0589d53616 | |||
eb2528c1d6 | |||
141cf90ca0 | |||
f4ec459a7b | |||
56a7842664 | |||
be8fc9daf1 | |||
f39e8f0da9 | |||
ed0c2cb6c1 | |||
c6592c5797 | |||
33cef10721 | |||
2d6408eb30 | |||
29a96690ad | |||
8b94cd1e2e | |||
b83880765f | |||
560d7084fe | |||
d21b7ce4ff | |||
c1038bec92 | |||
bb2e56e6c7 | |||
4222c49556 | |||
2f2ba420ef | |||
e9d16ba190 | |||
afb552c063 | |||
721151b9fc | |||
efc96c2f19 | |||
ba4681b312 | |||
6b00eeab0a | |||
c339be10ee | |||
7b326cc525 | |||
835a689965 | |||
b08d81cee7 | |||
6445fda050 | |||
4ca481b869 | |||
5d7ee50e76 | |||
48fd64182b | |||
58db09a9d3 | |||
15f7c2a974 | |||
4384d139d2 | |||
bd1068e5d9 | |||
854ac49a10 | |||
f9d0047bf6 | |||
ae5ce9a66f | |||
14a1955a78 | |||
f1eb373235 | |||
dabee00127 | |||
17b6a3fd73 | |||
4f7586886c | |||
71f46bf4a6 | |||
cba035a75b | |||
2c5183bd70 | |||
a586efb5f7 | |||
1db69c5f27 | |||
9e1a9f04ae | |||
287f1b98e5 | |||
90ecc57dbc | |||
ae52d483fc | |||
2570a1ba30 | |||
633b0c291f | |||
7d505494be | |||
1df52ae205 | |||
ba02764c5f | |||
404fa69513 | |||
85988cfaab | |||
def3574ba0 | |||
6b1da8326f | |||
a12006a4fa | |||
466b4dfd70 | |||
98e82df5e1 | |||
6ad840c3f3 | |||
7ac5e42a1a | |||
b86ef64904 | |||
b6cd48b798 | |||
a5b54a7017 | |||
e1e3be8106 | |||
b7432bd02b | |||
7c2fefda46 | |||
2788982c53 | |||
76ec1ccd21 | |||
e445a17278 | |||
2329ef3ea3 | |||
ce8e60bb0d | |||
12fc069873 | |||
9a6e07d70b | |||
8da9fc97d4 | |||
a020db183a | |||
f77ce39484 | |||
18a062ed12 | |||
1999606ecc | |||
472e14f2b4 | |||
953d185c39 | |||
c563e06a60 | |||
f28b09fc0d | |||
2104578924 | |||
bcad60995e | |||
432b0997ae | |||
2afdbb71b2 | |||
c7a54f34f7 | |||
9d52b80c45 | |||
582094a834 | |||
fe2a8eddbb | |||
5e1dbc21a2 | |||
b37ccc7279 | |||
440fbf0c04 | |||
0cef51d4c2 | |||
b277b26043 | |||
bc071ce7d7 | |||
01730214d6 | |||
0826531e31 | |||
35ac02dcb5 | |||
b73348078d | |||
21cd9c67bc | |||
0fc4537a5e | |||
6a05f3e6e7 | |||
93a1e42ef3 |
27
.aegir.js
27
.aegir.js
@ -4,25 +4,34 @@ const Libp2p = require('./src')
|
||||
const { MULTIADDRS_WEBSOCKETS } = require('./test/fixtures/browser')
|
||||
const Peers = require('./test/fixtures/peers')
|
||||
const PeerId = require('peer-id')
|
||||
const PeerInfo = require('peer-info')
|
||||
const WebSockets = require('libp2p-websockets')
|
||||
const Muxer = require('libp2p-mplex')
|
||||
const Crypto = require('./src/insecure/plaintext')
|
||||
const { NOISE: Crypto } = require('libp2p-noise')
|
||||
const pipe = require('it-pipe')
|
||||
let libp2p
|
||||
|
||||
const before = async () => {
|
||||
// Use the last peer
|
||||
const peerId = await PeerId.createFromJSON(Peers[Peers.length - 1])
|
||||
const peerInfo = new PeerInfo(peerId)
|
||||
peerInfo.multiaddrs.add(MULTIADDRS_WEBSOCKETS[0])
|
||||
|
||||
libp2p = new Libp2p({
|
||||
peerInfo,
|
||||
addresses: {
|
||||
listen: [MULTIADDRS_WEBSOCKETS[0]]
|
||||
},
|
||||
peerId,
|
||||
modules: {
|
||||
transport: [WebSockets],
|
||||
streamMuxer: [Muxer],
|
||||
connEncryption: [Crypto]
|
||||
},
|
||||
config: {
|
||||
relay: {
|
||||
enabled: true,
|
||||
hop: {
|
||||
enabled: true,
|
||||
active: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// Add the echo protocol
|
||||
@ -36,9 +45,15 @@ const after = async () => {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
bundlesize: { maxSize: '220kB' },
|
||||
bundlesize: { maxSize: '225kB' },
|
||||
hooks: {
|
||||
pre: before,
|
||||
post: after
|
||||
},
|
||||
webpack: {
|
||||
node: {
|
||||
// needed by bcrypto
|
||||
Buffer: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
67
.github/workflows/main.yml
vendored
Normal file
67
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
name: ci
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: yarn lint
|
||||
- uses: gozala/typescript-error-reporter-action@v1.0.8
|
||||
- run: yarn build
|
||||
- run: yarn aegir dep-check
|
||||
- uses: ipfs/aegir/actions/bundle-size@master
|
||||
name: size
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
test-node:
|
||||
needs: check
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||
node: [12, 14]
|
||||
fail-fast: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: yarn
|
||||
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
|
||||
- uses: codecov/codecov-action@v1
|
||||
test-chrome:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: npx aegir test -t browser -t webworker --bail
|
||||
test-firefox:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
|
||||
test-interop:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: cd node_modules/interop-libp2p && yarn && LIBP2P_JS=${GITHUB_WORKSPACE}/src/index.js npx aegir test -t node --bail
|
||||
test-auto-relay-example:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: cd examples && yarn && npm run test -- auto-relay
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,6 +3,7 @@ docs
|
||||
**/*.log
|
||||
test/repo-tests*
|
||||
**/bundle.js
|
||||
.cache
|
||||
|
||||
# Logs
|
||||
logs
|
||||
@ -35,7 +36,6 @@ build
|
||||
node_modules
|
||||
|
||||
lib
|
||||
dist
|
||||
test/test-data/go-ipfs-repo/LOCK
|
||||
test/test-data/go-ipfs-repo/LOG
|
||||
test/test-data/go-ipfs-repo/LOG.old
|
||||
|
42
.travis.yml
42
.travis.yml
@ -1,42 +0,0 @@
|
||||
language: node_js
|
||||
cache: npm
|
||||
stages:
|
||||
- check
|
||||
- test
|
||||
- cov
|
||||
|
||||
node_js:
|
||||
- '10'
|
||||
- '12'
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
script: npx nyc -s npm run test:node -- --bail
|
||||
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: check
|
||||
script:
|
||||
# - npx aegir build --bundlesize
|
||||
- npx aegir dep-check -- -i wrtc -i electron-webrtc
|
||||
- npm run lint
|
||||
|
||||
- stage: test
|
||||
name: chrome
|
||||
addons:
|
||||
chrome: stable
|
||||
script:
|
||||
- npx aegir test -t browser -t webworker
|
||||
|
||||
- stage: test
|
||||
name: firefox
|
||||
addons:
|
||||
firefox: latest
|
||||
script:
|
||||
- npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
|
||||
|
||||
notifications:
|
||||
email: false
|
598
CHANGELOG.md
598
CHANGELOG.md
@ -1,3 +1,601 @@
|
||||
# [0.30.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.29.4...v0.30.0-rc.0) (2020-12-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove test/dialing/utils extra file ([3f1dc20](https://github.com/libp2p/js-libp2p/commit/3f1dc20caf1c80078f403deb9174cd06d08567ab))
|
||||
|
||||
|
||||
### chore
|
||||
|
||||
* update pubsub ([#801](https://github.com/libp2p/js-libp2p/issues/801)) ([9205fce](https://github.com/libp2p/js-libp2p/commit/9205fce34d0cd8dd5d32988be34c110fc0a5b6e2))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* auto relay ([#723](https://github.com/libp2p/js-libp2p/issues/723)) ([65ec267](https://github.com/libp2p/js-libp2p/commit/65ec267e7f4826caacd042213c3fbacce589ab5b))
|
||||
* auto relay network query for new relays ([9faf1bf](https://github.com/libp2p/js-libp2p/commit/9faf1bfcf61581acc715b9be78b71dc14501835a))
|
||||
* custom announce filter ([48476d5](https://github.com/libp2p/js-libp2p/commit/48476d504a98b7b51b3e2dc64eab93670fde0c7b))
|
||||
* custom dialer addr sorter ([#792](https://github.com/libp2p/js-libp2p/issues/792)) ([91b15b6](https://github.com/libp2p/js-libp2p/commit/91b15b6790952b4db11264961d9c6f2a96d1fe43))
|
||||
* discover and connect to closest peers ([#798](https://github.com/libp2p/js-libp2p/issues/798)) ([b73106e](https://github.com/libp2p/js-libp2p/commit/b73106eba2d559621f427f7aa788e9b0ef47d135))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* pubsub signing policy properties were changed according to libp2p-interfaces changes to a single property. The emitSelf option default value was also modified to match the routers value
|
||||
|
||||
|
||||
|
||||
<a name="0.29.4"></a>
|
||||
## [0.29.4](https://github.com/libp2p/js-libp2p/compare/v0.29.3...v0.29.4) (2020-12-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* dial self ([#826](https://github.com/libp2p/js-libp2p/issues/826)) ([6350a18](https://github.com/libp2p/js-libp2p/commit/6350a18))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* custom and store self agent version + store self protocol version ([#800](https://github.com/libp2p/js-libp2p/issues/800)) ([d0a9fad](https://github.com/libp2p/js-libp2p/commit/d0a9fad))
|
||||
* support custom listener options ([#822](https://github.com/libp2p/js-libp2p/issues/822)) ([8691465](https://github.com/libp2p/js-libp2p/commit/8691465))
|
||||
|
||||
|
||||
|
||||
<a name="0.29.3"></a>
|
||||
## [0.29.3](https://github.com/libp2p/js-libp2p/compare/v0.29.2...v0.29.3) (2020-11-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* resolve multiaddrs before dial ([#782](https://github.com/libp2p/js-libp2p/issues/782)) ([093c0ea](https://github.com/libp2p/js-libp2p/commit/093c0ea))
|
||||
|
||||
|
||||
|
||||
<a name="0.29.2"></a>
|
||||
## [0.29.2](https://github.com/libp2p/js-libp2p/compare/v0.29.1...v0.29.2) (2020-10-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* cleanup open streams on conn close ([#791](https://github.com/libp2p/js-libp2p/issues/791)) ([06f26e5](https://github.com/libp2p/js-libp2p/commit/06f26e5))
|
||||
|
||||
|
||||
|
||||
<a name="0.29.1"></a>
|
||||
## [0.29.1](https://github.com/libp2p/js-libp2p/compare/v0.29.0...v0.29.1) (2020-10-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* catch error in upgrader close call ([e04224a](https://github.com/libp2p/js-libp2p/commit/e04224a))
|
||||
* ensure streams are closed on connection close ([4c6be91](https://github.com/libp2p/js-libp2p/commit/4c6be91))
|
||||
* flakey identify test firefox ([#774](https://github.com/libp2p/js-libp2p/issues/774)) ([60d437f](https://github.com/libp2p/js-libp2p/commit/60d437f))
|
||||
|
||||
|
||||
|
||||
<a name="0.29.0"></a>
|
||||
# [0.29.0](https://github.com/libp2p/js-libp2p/compare/v0.28.10...v0.29.0) (2020-08-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not return self on peerstore.peers ([15613cc](https://github.com/libp2p/js-libp2p/commit/15613cc))
|
||||
* peer record interop with go ([#739](https://github.com/libp2p/js-libp2p/issues/739)) ([93dda74](https://github.com/libp2p/js-libp2p/commit/93dda74))
|
||||
* replace node buffers with uint8arrays ([#730](https://github.com/libp2p/js-libp2p/issues/730)) ([1e86971](https://github.com/libp2p/js-libp2p/commit/1e86971))
|
||||
* revert new identify protocol versions ([3158366](https://github.com/libp2p/js-libp2p/commit/3158366))
|
||||
* signature compliant with spec ([4ab125e](https://github.com/libp2p/js-libp2p/commit/4ab125e))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* update travis to use node lts and stable ([098f3d1](https://github.com/libp2p/js-libp2p/commit/098f3d1))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* cerified addressbook ([8f2e690](https://github.com/libp2p/js-libp2p/commit/8f2e690))
|
||||
* create self peer record in identify ([8a97dde](https://github.com/libp2p/js-libp2p/commit/8a97dde))
|
||||
* exchange signed peer records in identify ([e50f0ee](https://github.com/libp2p/js-libp2p/commit/e50f0ee))
|
||||
* gossipsub 1.1 ([#733](https://github.com/libp2p/js-libp2p/issues/733)) ([55c9bfa](https://github.com/libp2p/js-libp2p/commit/55c9bfa))
|
||||
* signed peer records record manager ([3e5d450](https://github.com/libp2p/js-libp2p/commit/3e5d450))
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* reapply "fix: throw if no conn encryption module provided ([#665](https://github.com/libp2p/js-libp2p/issues/665))" ([689f90a](https://github.com/libp2p/js-libp2p/commit/689f90a))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* pubsub implementation is now directly exposed and its API was updated according to the new pubsub interface in js-libp2p-interfaces repo
|
||||
|
||||
* chore: use gossipsub branch with src added
|
||||
|
||||
* fix: add pubsub handlers adapter
|
||||
|
||||
* chore: fix deps
|
||||
|
||||
* chore: update pubsub docs and examples
|
||||
|
||||
* chore: apply suggestions from code review
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: use new floodsub
|
||||
|
||||
* chore: change validator doc set
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: add new gossipsub src
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
* - All deps used by this module now use Uint8Arrays in place of node Buffers
|
||||
|
||||
* chore: browser fixes
|
||||
|
||||
* chore: remove .only
|
||||
|
||||
* chore: stringify uint8array before parsing
|
||||
|
||||
* chore: update interop suite
|
||||
|
||||
* chore: remove ts from build command
|
||||
|
||||
* chore: update deps
|
||||
|
||||
* fix: update records to use uint8array
|
||||
|
||||
* chore: fix lint
|
||||
|
||||
* chore: update deps
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
* this drops testing support in node 10.
|
||||
|
||||
|
||||
|
||||
<a name="0.29.0-rc.1"></a>
|
||||
# [0.29.0-rc.1](https://github.com/libp2p/js-libp2p/compare/v0.29.0-rc.0...v0.29.0-rc.1) (2020-08-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* peer record interop with go ([#739](https://github.com/libp2p/js-libp2p/issues/739)) ([c4c7ef9](https://github.com/libp2p/js-libp2p/commit/c4c7ef9))
|
||||
|
||||
|
||||
|
||||
<a name="0.29.0-rc.0"></a>
|
||||
# [0.29.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.28.10...v0.29.0-rc.0) (2020-08-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not return self on peerstore.peers ([e1b8edc](https://github.com/libp2p/js-libp2p/commit/e1b8edc))
|
||||
* replace node buffers with uint8arrays ([#730](https://github.com/libp2p/js-libp2p/issues/730)) ([507f8c4](https://github.com/libp2p/js-libp2p/commit/507f8c4))
|
||||
* revert new identify protocol versions ([a798c65](https://github.com/libp2p/js-libp2p/commit/a798c65))
|
||||
* signature compliant with spec ([97b5d2a](https://github.com/libp2p/js-libp2p/commit/97b5d2a))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* update travis to use node lts and stable ([c272288](https://github.com/libp2p/js-libp2p/commit/c272288))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* cerified addressbook ([e0ed258](https://github.com/libp2p/js-libp2p/commit/e0ed258))
|
||||
* create self peer record in identify ([83922a7](https://github.com/libp2p/js-libp2p/commit/83922a7))
|
||||
* exchange signed peer records in identify ([f835457](https://github.com/libp2p/js-libp2p/commit/f835457))
|
||||
* gossipsub 1.1 ([#733](https://github.com/libp2p/js-libp2p/issues/733)) ([e14ce40](https://github.com/libp2p/js-libp2p/commit/e14ce40))
|
||||
* signed peer records record manager ([f95edf1](https://github.com/libp2p/js-libp2p/commit/f95edf1))
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* reapply "fix: throw if no conn encryption module provided ([#665](https://github.com/libp2p/js-libp2p/issues/665))" ([ad7f02e](https://github.com/libp2p/js-libp2p/commit/ad7f02e))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* pubsub implementation is now directly exposed and its API was updated according to the new pubsub interface in js-libp2p-interfaces repo
|
||||
|
||||
* chore: use gossipsub branch with src added
|
||||
|
||||
* fix: add pubsub handlers adapter
|
||||
|
||||
* chore: fix deps
|
||||
|
||||
* chore: update pubsub docs and examples
|
||||
|
||||
* chore: apply suggestions from code review
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: use new floodsub
|
||||
|
||||
* chore: change validator doc set
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: add new gossipsub src
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
* - All deps used by this module now use Uint8Arrays in place of node Buffers
|
||||
|
||||
* chore: browser fixes
|
||||
|
||||
* chore: remove .only
|
||||
|
||||
* chore: stringify uint8array before parsing
|
||||
|
||||
* chore: update interop suite
|
||||
|
||||
* chore: remove ts from build command
|
||||
|
||||
* chore: update deps
|
||||
|
||||
* fix: update records to use uint8array
|
||||
|
||||
* chore: fix lint
|
||||
|
||||
* chore: update deps
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
* this drops testing support in node 10.
|
||||
|
||||
|
||||
|
||||
<a name="0.28.10"></a>
|
||||
## [0.28.10](https://github.com/libp2p/js-libp2p/compare/v0.28.9...v0.28.10) (2020-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow certain keychain operations without a password ([#726](https://github.com/libp2p/js-libp2p/issues/726)) ([8c56ec0](https://github.com/libp2p/js-libp2p/commit/8c56ec0))
|
||||
* **identify:** make agentversion dynamic and add it to the peerstore ([#724](https://github.com/libp2p/js-libp2p/issues/724)) ([726a746](https://github.com/libp2p/js-libp2p/commit/726a746))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **keychain:** add support for ed25519 and secp keys ([#725](https://github.com/libp2p/js-libp2p/issues/725)) ([51d7ca4](https://github.com/libp2p/js-libp2p/commit/51d7ca4))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.9"></a>
|
||||
## [0.28.9](https://github.com/libp2p/js-libp2p/compare/v0.28.8...v0.28.9) (2020-07-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ping multiaddr from peer not previously stored in peerstore ([#719](https://github.com/libp2p/js-libp2p/issues/719)) ([2440c87](https://github.com/libp2p/js-libp2p/commit/2440c87))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.8"></a>
|
||||
## [0.28.8](https://github.com/libp2p/js-libp2p/compare/v0.28.7...v0.28.8) (2020-07-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* create dial target for peer with no known addrs ([#715](https://github.com/libp2p/js-libp2p/issues/715)) ([7da9ad4](https://github.com/libp2p/js-libp2p/commit/7da9ad4))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.7"></a>
|
||||
## [0.28.7](https://github.com/libp2p/js-libp2p/compare/v0.28.6...v0.28.7) (2020-07-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* retimer reschedule does not work as interval ([#710](https://github.com/libp2p/js-libp2p/issues/710)) ([999c1b7](https://github.com/libp2p/js-libp2p/commit/999c1b7))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.6"></a>
|
||||
## [0.28.6](https://github.com/libp2p/js-libp2p/compare/v0.28.5...v0.28.6) (2020-07-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* not dial all known peers in parallel on startup ([#698](https://github.com/libp2p/js-libp2p/issues/698)) ([9ccab40](https://github.com/libp2p/js-libp2p/commit/9ccab40))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.5"></a>
|
||||
## [0.28.5](https://github.com/libp2p/js-libp2p/compare/v0.28.4...v0.28.5) (2020-07-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* pass libp2p to the dht ([#700](https://github.com/libp2p/js-libp2p/issues/700)) ([5a84dd5](https://github.com/libp2p/js-libp2p/commit/5a84dd5))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.4"></a>
|
||||
## [0.28.4](https://github.com/libp2p/js-libp2p/compare/v0.28.3...v0.28.4) (2020-07-03)
|
||||
|
||||
|
||||
|
||||
<a name="0.28.3"></a>
|
||||
## [0.28.3](https://github.com/libp2p/js-libp2p/compare/v0.28.2...v0.28.3) (2020-06-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* catch pipe errors ([#678](https://github.com/libp2p/js-libp2p/issues/678)) ([a8219e6](https://github.com/libp2p/js-libp2p/commit/a8219e6))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.2"></a>
|
||||
## [0.28.2](https://github.com/libp2p/js-libp2p/compare/v0.28.1...v0.28.2) (2020-06-15)
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* "fix: throw if no conn encryption module provided ([#665](https://github.com/libp2p/js-libp2p/issues/665))" ([b621fbd](https://github.com/libp2p/js-libp2p/commit/b621fbd))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.1"></a>
|
||||
## [0.28.1](https://github.com/libp2p/js-libp2p/compare/v0.28.0...v0.28.1) (2020-06-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* throw if no conn encryption module provided ([#665](https://github.com/libp2p/js-libp2p/issues/665)) ([c038550](https://github.com/libp2p/js-libp2p/commit/c038550))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add ConnectionManager#getAll ([8f680e2](https://github.com/libp2p/js-libp2p/commit/8f680e2))
|
||||
|
||||
|
||||
|
||||
<a name="0.28.0"></a>
|
||||
# [0.28.0](https://github.com/libp2p/js-libp2p/compare/v0.28.0-rc.0...v0.28.0) (2020-06-05)
|
||||
|
||||
|
||||
|
||||
<a name="0.28.0-rc.0"></a>
|
||||
# [0.28.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.27.8...v0.28.0-rc.0) (2020-05-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* always emit when a connection is made ([72f37ac](https://github.com/libp2p/js-libp2p/commit/72f37ac))
|
||||
* expose the muxed stream interface on inbound streams ([52a615f](https://github.com/libp2p/js-libp2p/commit/52a615f))
|
||||
* libp2p connections getter ([aaf62a4](https://github.com/libp2p/js-libp2p/commit/aaf62a4))
|
||||
* onConnect should not add addr to the addressBook ([2b45fee](https://github.com/libp2p/js-libp2p/commit/2b45fee))
|
||||
* use libp2p.multiaddrs instead of listen ([7fbd155](https://github.com/libp2p/js-libp2p/commit/7fbd155))
|
||||
* **example:** rename misleading variable ([#645](https://github.com/libp2p/js-libp2p/issues/645)) ([b781911](https://github.com/libp2p/js-libp2p/commit/b781911))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* deprecate old peer store api ([#598](https://github.com/libp2p/js-libp2p/issues/598)) ([ed6d5bb](https://github.com/libp2p/js-libp2p/commit/ed6d5bb))
|
||||
* remove peer-info usage ([12e48ad](https://github.com/libp2p/js-libp2p/commit/12e48ad))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* address and proto books ([#590](https://github.com/libp2p/js-libp2p/issues/590)) ([e9d225c](https://github.com/libp2p/js-libp2p/commit/e9d225c))
|
||||
* address manager ([2a7967c](https://github.com/libp2p/js-libp2p/commit/2a7967c))
|
||||
* keybook ([ce38033](https://github.com/libp2p/js-libp2p/commit/ce38033))
|
||||
* metadata book ([#638](https://github.com/libp2p/js-libp2p/issues/638)) ([84b935f](https://github.com/libp2p/js-libp2p/commit/84b935f))
|
||||
* peerStore persistence ([5123a83](https://github.com/libp2p/js-libp2p/commit/5123a83))
|
||||
* support dial only on transport manager to tolerate errors ([#643](https://github.com/libp2p/js-libp2p/issues/643)) ([698c1df](https://github.com/libp2p/js-libp2p/commit/698c1df))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* all API methods with peer-info parameters or return values were changed. You can check the API.md document, in order to check the new values to use
|
||||
* the peer-store api changed. Check the API docs for the new specification.
|
||||
|
||||
* chore: apply suggestions from code review
|
||||
|
||||
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: apply suggestions from code review
|
||||
|
||||
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
|
||||
|
||||
<a name="0.27.8"></a>
|
||||
## [0.27.8](https://github.com/libp2p/js-libp2p/compare/v0.27.7...v0.27.8) (2020-05-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* reset discovery services upon stop ([#618](https://github.com/libp2p/js-libp2p/issues/618)) ([ea0621b](https://github.com/libp2p/js-libp2p/commit/ea0621b))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.7"></a>
|
||||
## [0.27.7](https://github.com/libp2p/js-libp2p/compare/v0.27.6...v0.27.7) (2020-04-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove node global ([#587](https://github.com/libp2p/js-libp2p/issues/587)) ([9b13fe3](https://github.com/libp2p/js-libp2p/commit/9b13fe3))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.6"></a>
|
||||
## [0.27.6](https://github.com/libp2p/js-libp2p/compare/v0.27.5...v0.27.6) (2020-04-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add null check in libp2p.hangUp() ([c940f2d](https://github.com/libp2p/js-libp2p/commit/c940f2d))
|
||||
* make circuit relay listening addresses more forgiving ([#604](https://github.com/libp2p/js-libp2p/issues/604)) ([e192eb6](https://github.com/libp2p/js-libp2p/commit/e192eb6))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.5"></a>
|
||||
## [0.27.5](https://github.com/libp2p/js-libp2p/compare/v0.27.4...v0.27.5) (2020-04-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* await peer discovery start in libp2p start ([#600](https://github.com/libp2p/js-libp2p/issues/600)) ([bd7fd0f](https://github.com/libp2p/js-libp2p/commit/bd7fd0f))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.4"></a>
|
||||
## [0.27.4](https://github.com/libp2p/js-libp2p/compare/v0.27.3...v0.27.4) (2020-03-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* only use a single export ([#596](https://github.com/libp2p/js-libp2p/issues/596)) ([3072875](https://github.com/libp2p/js-libp2p/commit/3072875))
|
||||
* pass libp2p to discovery services ([#597](https://github.com/libp2p/js-libp2p/issues/597)) ([9e35fbc](https://github.com/libp2p/js-libp2p/commit/9e35fbc))
|
||||
* **test:** improve flakey random walk discovery test ([#574](https://github.com/libp2p/js-libp2p/issues/574)) ([f4ec355](https://github.com/libp2p/js-libp2p/commit/f4ec355))
|
||||
* remove use of assert module ([#561](https://github.com/libp2p/js-libp2p/issues/561)) ([a8984c6](https://github.com/libp2p/js-libp2p/commit/a8984c6))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.3"></a>
|
||||
## [0.27.3](https://github.com/libp2p/js-libp2p/compare/v0.27.2...v0.27.3) (2020-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* dont allow multiaddr dials without a peer id ([#558](https://github.com/libp2p/js-libp2p/issues/558)) ([a317a8b](https://github.com/libp2p/js-libp2p/commit/a317a8b))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.2"></a>
|
||||
## [0.27.2](https://github.com/libp2p/js-libp2p/compare/v0.27.1...v0.27.2) (2020-02-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure identify streams are closed ([#551](https://github.com/libp2p/js-libp2p/issues/551)) ([f662fdc](https://github.com/libp2p/js-libp2p/commit/f662fdc))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.1"></a>
|
||||
## [0.27.1](https://github.com/libp2p/js-libp2p/compare/v0.27.0...v0.27.1) (2020-02-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* stop stream after first pong received ([#545](https://github.com/libp2p/js-libp2p/issues/545)) ([be8fc9d](https://github.com/libp2p/js-libp2p/commit/be8fc9d))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.0"></a>
|
||||
# [0.27.0](https://github.com/libp2p/js-libp2p/compare/v0.26.2...v0.27.0) (2020-01-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* clean up peer discovery flow ([#494](https://github.com/libp2p/js-libp2p/issues/494)) ([12fc069](https://github.com/libp2p/js-libp2p/commit/12fc069))
|
||||
* clean up pending dials abort per feedback ([633b0c2](https://github.com/libp2p/js-libp2p/commit/633b0c2))
|
||||
* conn mngr min/max connection values ([#528](https://github.com/libp2p/js-libp2p/issues/528)) ([ba4681b](https://github.com/libp2p/js-libp2p/commit/ba4681b))
|
||||
* correct release readme ([ce8e60b](https://github.com/libp2p/js-libp2p/commit/ce8e60b))
|
||||
* examples readme typos ([#481](https://github.com/libp2p/js-libp2p/issues/481)) ([35ac02d](https://github.com/libp2p/js-libp2p/commit/35ac02d))
|
||||
* make dialer configurable ([#521](https://github.com/libp2p/js-libp2p/issues/521)) ([4ca481b](https://github.com/libp2p/js-libp2p/commit/4ca481b))
|
||||
* performance bottleneck in stat.js ([#463](https://github.com/libp2p/js-libp2p/issues/463)) ([93a1e42](https://github.com/libp2p/js-libp2p/commit/93a1e42))
|
||||
* registrar should filter the disconnected conn ([#532](https://github.com/libp2p/js-libp2p/issues/532)) ([bb2e56e](https://github.com/libp2p/js-libp2p/commit/bb2e56e))
|
||||
* release tokens as soon as they are available ([2570a1b](https://github.com/libp2p/js-libp2p/commit/2570a1b))
|
||||
* replace peerInfo addresses with listen addresses ([#485](https://github.com/libp2p/js-libp2p/issues/485)) ([1999606](https://github.com/libp2p/js-libp2p/commit/1999606))
|
||||
* stop discoveries ([#530](https://github.com/libp2p/js-libp2p/issues/530)) ([4222c49](https://github.com/libp2p/js-libp2p/commit/4222c49))
|
||||
* token release logic ([90ecc57](https://github.com/libp2p/js-libp2p/commit/90ecc57))
|
||||
* upgrader should not need muxers ([#517](https://github.com/libp2p/js-libp2p/issues/517)) ([5d7ee50](https://github.com/libp2p/js-libp2p/commit/5d7ee50))
|
||||
* use toB58String everywhere to be consistent ([#537](https://github.com/libp2p/js-libp2p/issues/537)) ([c1038be](https://github.com/libp2p/js-libp2p/commit/c1038be))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* abort all pending dials on stop ([ba02764](https://github.com/libp2p/js-libp2p/commit/ba02764))
|
||||
* add early token recycling in ([a5b54a7](https://github.com/libp2p/js-libp2p/commit/a5b54a7))
|
||||
* add libp2p.connections getter ([#522](https://github.com/libp2p/js-libp2p/issues/522)) ([6445fda](https://github.com/libp2p/js-libp2p/commit/6445fda))
|
||||
* add token based dialer ([e445a17](https://github.com/libp2p/js-libp2p/commit/e445a17))
|
||||
* allow transport options to be passed on creation ([#524](https://github.com/libp2p/js-libp2p/issues/524)) ([c339be1](https://github.com/libp2p/js-libp2p/commit/c339be1))
|
||||
* coalescing dial support ([#518](https://github.com/libp2p/js-libp2p/issues/518)) ([15f7c2a](https://github.com/libp2p/js-libp2p/commit/15f7c2a))
|
||||
* discovery modules ([#486](https://github.com/libp2p/js-libp2p/issues/486)) ([18a062e](https://github.com/libp2p/js-libp2p/commit/18a062e))
|
||||
* discovery modules from transports should be added ([#510](https://github.com/libp2p/js-libp2p/issues/510)) ([f1eb373](https://github.com/libp2p/js-libp2p/commit/f1eb373))
|
||||
* peer store ([#470](https://github.com/libp2p/js-libp2p/issues/470)) ([582094a](https://github.com/libp2p/js-libp2p/commit/582094a))
|
||||
* registrar ([#471](https://github.com/libp2p/js-libp2p/issues/471)) ([9d52b80](https://github.com/libp2p/js-libp2p/commit/9d52b80))
|
||||
* support peer-id instances in peer store operations ([#491](https://github.com/libp2p/js-libp2p/issues/491)) ([8da9fc9](https://github.com/libp2p/js-libp2p/commit/8da9fc9))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.0-rc.0"></a>
|
||||
# [0.27.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.27.0-pre.2...v0.27.0-rc.0) (2020-01-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* registrar should filter the disconnected conn ([#532](https://github.com/libp2p/js-libp2p/issues/532)) ([83409de](https://github.com/libp2p/js-libp2p/commit/83409de))
|
||||
* stop discoveries ([#530](https://github.com/libp2p/js-libp2p/issues/530)) ([c44e6e3](https://github.com/libp2p/js-libp2p/commit/c44e6e3))
|
||||
* use toB58String everywhere to be consistent ([#537](https://github.com/libp2p/js-libp2p/issues/537)) ([31d1b23](https://github.com/libp2p/js-libp2p/commit/31d1b23))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.0-pre.2"></a>
|
||||
# [0.27.0-pre.2](https://github.com/libp2p/js-libp2p/compare/v0.27.0-pre.1...v0.27.0-pre.2) (2020-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* conn mngr min/max connection values ([#528](https://github.com/libp2p/js-libp2p/issues/528)) ([a1717da](https://github.com/libp2p/js-libp2p/commit/a1717da))
|
||||
* make dialer configurable ([#521](https://github.com/libp2p/js-libp2p/issues/521)) ([24c3ce6](https://github.com/libp2p/js-libp2p/commit/24c3ce6))
|
||||
* upgrader should not need muxers ([#517](https://github.com/libp2p/js-libp2p/issues/517)) ([56a1825](https://github.com/libp2p/js-libp2p/commit/56a1825))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add libp2p.connections getter ([#522](https://github.com/libp2p/js-libp2p/issues/522)) ([6ca19c5](https://github.com/libp2p/js-libp2p/commit/6ca19c5))
|
||||
* allow transport options to be passed on creation ([#524](https://github.com/libp2p/js-libp2p/issues/524)) ([0d4b2bd](https://github.com/libp2p/js-libp2p/commit/0d4b2bd))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.0-pre.1"></a>
|
||||
# [0.27.0-pre.1](https://github.com/libp2p/js-libp2p/compare/v0.27.0-pre.0...v0.27.0-pre.1) (2019-12-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* coalescing dial support ([#518](https://github.com/libp2p/js-libp2p/issues/518)) ([4a871bb](https://github.com/libp2p/js-libp2p/commit/4a871bb))
|
||||
|
||||
|
||||
|
||||
<a name="0.27.0-pre.0"></a>
|
||||
# [0.27.0-pre.0](https://github.com/libp2p/js-libp2p/compare/v0.26.2...v0.27.0-pre.0) (2019-12-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* clean up peer discovery flow ([#494](https://github.com/libp2p/js-libp2p/issues/494)) ([f3eb1f1](https://github.com/libp2p/js-libp2p/commit/f3eb1f1))
|
||||
* clean up pending dials abort per feedback ([7c3371b](https://github.com/libp2p/js-libp2p/commit/7c3371b))
|
||||
* correct release readme ([c4bc00b](https://github.com/libp2p/js-libp2p/commit/c4bc00b))
|
||||
* examples readme typos ([#481](https://github.com/libp2p/js-libp2p/issues/481)) ([35ac02d](https://github.com/libp2p/js-libp2p/commit/35ac02d))
|
||||
* performance bottleneck in stat.js ([#463](https://github.com/libp2p/js-libp2p/issues/463)) ([93a1e42](https://github.com/libp2p/js-libp2p/commit/93a1e42))
|
||||
* release tokens as soon as they are available ([43440aa](https://github.com/libp2p/js-libp2p/commit/43440aa))
|
||||
* replace peerInfo addresses with listen addresses ([#485](https://github.com/libp2p/js-libp2p/issues/485)) ([acbbc0f](https://github.com/libp2p/js-libp2p/commit/acbbc0f))
|
||||
* token release logic ([1838a64](https://github.com/libp2p/js-libp2p/commit/1838a64))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* abort all pending dials on stop ([754fbc2](https://github.com/libp2p/js-libp2p/commit/754fbc2))
|
||||
* add early token recycling in ([24c6037](https://github.com/libp2p/js-libp2p/commit/24c6037))
|
||||
* add token based dialer ([f8540fa](https://github.com/libp2p/js-libp2p/commit/f8540fa))
|
||||
* discovery modules ([#486](https://github.com/libp2p/js-libp2p/issues/486)) ([997ee16](https://github.com/libp2p/js-libp2p/commit/997ee16))
|
||||
* discovery modules from transports should be added ([#510](https://github.com/libp2p/js-libp2p/issues/510)) ([af96dcc](https://github.com/libp2p/js-libp2p/commit/af96dcc))
|
||||
* peer store ([#470](https://github.com/libp2p/js-libp2p/issues/470)) ([f3e276e](https://github.com/libp2p/js-libp2p/commit/f3e276e))
|
||||
* registrar ([#471](https://github.com/libp2p/js-libp2p/issues/471)) ([797d8f0](https://github.com/libp2p/js-libp2p/commit/797d8f0))
|
||||
* support peer-id instances in peer store operations ([#491](https://github.com/libp2p/js-libp2p/issues/491)) ([11ed6bd](https://github.com/libp2p/js-libp2p/commit/11ed6bd))
|
||||
|
||||
|
||||
|
||||
<a name="0.26.2"></a>
|
||||
## [0.26.2](https://github.com/libp2p/js-libp2p/compare/v0.26.1...v0.26.2) (2019-09-24)
|
||||
|
||||
|
@ -37,7 +37,7 @@ One of following:
|
||||
|
||||
<!--
|
||||
This is for you! Please read, and then delete this text before posting it.
|
||||
The js-ipfs issues are only for bug reports and directly actionable features.
|
||||
The js-libp2p issues are only for bug reports and directly actionable features.
|
||||
|
||||
Read https://github.com/ipfs/community/blob/master/CONTRIBUTING.md#reporting-issues if your issue doesn't fit either of those categories.
|
||||
-->
|
||||
|
45
MIGRATION_TEMPLATE.md
Normal file
45
MIGRATION_TEMPLATE.md
Normal file
@ -0,0 +1,45 @@
|
||||
<!--Specify versions for migration below-->
|
||||
# Migrating to libp2p@__
|
||||
|
||||
A migration guide for refactoring your application code from libp2p v__ to v__.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [API](#api)
|
||||
- [Module Updates](#module-updates)
|
||||
|
||||
## API
|
||||
|
||||
<!--Describe breaking APIs with examples for Before and After
|
||||
Example:
|
||||
|
||||
### Peer Discovery
|
||||
|
||||
__Describe__
|
||||
|
||||
**Before**
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
-->
|
||||
|
||||
## Module Updates
|
||||
|
||||
With this release you should update the following libp2p modules if you are relying on them:
|
||||
|
||||
<!--Specify module versions in JSON for migration below.
|
||||
It's recommended to check package.json changes for this:
|
||||
`git diff <release> <prev> -- package.json`
|
||||
-->
|
||||
|
||||
```json
|
||||
|
||||
```
|
559
README.md
559
README.md
@ -5,12 +5,14 @@
|
||||
<h3 align="center">The JavaScript implementation of the libp2p Networking Stack.</h3>
|
||||
|
||||
<p align="center">
|
||||
<a href="http://ipn.io"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a>
|
||||
<a href="http://protocol.ai"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a>
|
||||
<a href="http://libp2p.io/"><img src="https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square" /></a>
|
||||
<a href="http://webchat.freenode.net/?channels=%23libp2p"><img src="https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square" /></a>
|
||||
<a href="https://riot.permaweb.io/#/room/#libp2p:permaweb.io"><img src="https://img.shields.io/badge/matrix-%23libp2p%3Apermaweb.io-blue.svg?style=flat-square" /> </a>
|
||||
<a href="https://riot.im/app/#/room/#libp2p:matrix.org"><img src="https://img.shields.io/badge/matrix-%23libp2p%3Apermaweb.io-blue.svg?style=flat-square" /> </a>
|
||||
<a href="https://discord.gg/66KBrm2"><img src="https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord&style=flat-square" /></a>
|
||||
<a href="https://discuss.libp2p.io"><img src="https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/libp2p"><img src="https://img.shields.io/npm/dm/libp2p.svg" /></a>
|
||||
<a href="https://www.jsdelivr.com/package/npm/libp2p"><img src="https://data.jsdelivr.com/v1/package/npm/libp2p/badge"/></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@ -21,8 +23,8 @@
|
||||
<a href="https://david-dm.org/libp2p/js-libp2p"><img src="https://david-dm.org/libp2p/js-libp2p.svg?style=flat-square" /></a>
|
||||
<a href="https://github.com/feross/standard"><img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square"></a>
|
||||
<a href="https://github.com/RichardLitt/standard-readme"><img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" /></a>
|
||||
<a href=""><img src="https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square" /></a>
|
||||
<a href=""><img src="https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square" /></a>
|
||||
<a href=""><img src="https://img.shields.io/badge/npm-%3E%3D6.0.0-orange.svg?style=flat-square" /></a>
|
||||
<a href=""><img src="https://img.shields.io/badge/Node.js-%3E%3D12.0.0-orange.svg?style=flat-square" /></a>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
@ -30,13 +32,14 @@
|
||||
|
||||
We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉..
|
||||
|
||||
**Want to get started?** Check our [examples folder](/examples).
|
||||
The documentation in the master branch may contain changes from a pre-release.
|
||||
If you are looking for the documentation of the latest release, you can view the latest release on [**npm**](https://www.npmjs.com/package/libp2p), or select the tag in github that matches the version you are looking for.
|
||||
|
||||
[**`Weekly Core Dev Calls`**](https://github.com/ipfs/pm/issues/650)
|
||||
**Want to get started?** Check our [GETTING_STARTED.md](./doc/GETTING_STARTED.md) guide and [examples folder](/examples).
|
||||
|
||||
## Tech Lead
|
||||
**Want to update libp2p in your project?** Check our [migrations folder](./doc/migrations).
|
||||
|
||||
[David Dias](https://github.com/diasdavid/)
|
||||
[**`Weekly Core Dev Calls`**](https://github.com/libp2p/team-mgmt/issues/16)
|
||||
|
||||
## Lead Maintainer
|
||||
|
||||
@ -45,12 +48,12 @@ We've come a long way, but this project is still in Alpha, lots of development i
|
||||
## Table of Contents
|
||||
|
||||
- [Background](#background)
|
||||
- [Bundles](#bundles)
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Configuration](#configuration)
|
||||
- [API](#api)
|
||||
- [Events](#events)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Tutorials and Examples](#tutorials-and-examples)
|
||||
- [Development](#development)
|
||||
- [Tests](#tests)
|
||||
- [Packages](#packages)
|
||||
@ -59,7 +62,7 @@ We've come a long way, but this project is still in Alpha, lots of development i
|
||||
|
||||
## Background
|
||||
|
||||
libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, devs have long had to made custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API.
|
||||
libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, devs have long had to make custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API.
|
||||
|
||||
We are in the process of writing better documentation, blog posts, tutorials and a formal specification. Today you can find:
|
||||
|
||||
@ -74,464 +77,37 @@ We are in the process of writing better documentation, blog posts, tutorials and
|
||||
|
||||
To sum up, libp2p is a "network stack" -- a protocol suite -- that cleanly separates concerns, and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability. libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.
|
||||
|
||||
## Bundles
|
||||
|
||||
With its modular nature, libp2p can be found being used in different projects with different sets of features, while preserving the same top level API. `js-libp2p` is only a skeleton and should not be installed directly, if you are looking for a prebundled libp2p stack, please check:
|
||||
|
||||
- [libp2p-ipfs-nodejs](https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime/libp2p-nodejs.js) - The libp2p build used by js-ipfs when run in Node.js
|
||||
- [libp2p-ipfs-browser](https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime/libp2p-browser.js) - The libp2p build used by js-ipfs when run in a Browser (that supports WebRTC)
|
||||
|
||||
If you have developed a libp2p bundle, please consider submitting it to this list so that it can be found easily by the users of libp2p.
|
||||
|
||||
## Install
|
||||
|
||||
Again, as noted above, this module is only a skeleton and should not be used directly other than libp2p bundle implementors that want to extend its code.
|
||||
|
||||
```sh
|
||||
npm install --save libp2p
|
||||
npm install libp2p
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
**IMPORTANT NOTE**: We are currently on the way of migrating all our `libp2p` modules to use `async await` and `async iterators`, instead of callbacks and `pull-streams`. As a consequence, when you start a new libp2p project, we must check which versions of the modules you should use. For now, it is required to use the modules using callbacks with `libp2p`, while we are working on getting the remaining modules ready for a full migration. For more details, you can have a look at [libp2p/js-libp2p#266](https://github.com/libp2p/js-libp2p/issues/266).
|
||||
### Configuration
|
||||
|
||||
### [Tutorials and Examples](/examples)
|
||||
|
||||
You can find multiple examples on the [examples folder](/examples) that will guide you through using libp2p for several scenarios.
|
||||
|
||||
### Creating your own libp2p bundle
|
||||
|
||||
The libp2p module acts as a glue for every libp2p module that you can use to create your own libp2p bundle. Creating your own libp2p bundle gives you a lot of freedom when it comes to customize it with features and default setup. We recommend creating your own libp2p bundle for the app you are developing that takes in account your needs (e.g. for a browser working version of libp2p that acts as the network layer of IPFS, we have a built one that leverages the Browser transports).
|
||||
|
||||
**Example:**
|
||||
|
||||
```JavaScript
|
||||
// Creating a bundle that adds:
|
||||
// transport: websockets + tcp
|
||||
// stream-muxing: spdy & mplex
|
||||
// crypto-channel: secio
|
||||
// discovery: multicast-dns
|
||||
|
||||
const Libp2p = require('libp2p')
|
||||
const TCP = require('libp2p-tcp')
|
||||
const WS = require('libp2p-websockets')
|
||||
const SPDY = require('libp2p-spdy')
|
||||
const MPLEX = require('libp2p-mplex')
|
||||
const SECIO = require('libp2p-secio')
|
||||
const MulticastDNS = require('libp2p-mdns')
|
||||
const DHT = require('libp2p-kad-dht')
|
||||
const GossipSub = require('libp2p-gossipsub')
|
||||
const defaultsDeep = require('@nodeutils/defaults-deep')
|
||||
const Protector = require('libp2p-pnet')
|
||||
const DelegatedPeerRouter = require('libp2p-delegated-peer-routing')
|
||||
const DelegatedContentRouter = require('libp2p-delegated-content-routing')
|
||||
|
||||
class Node extends Libp2p {
|
||||
constructor (_options) {
|
||||
const peerInfo = _options.peerInfo
|
||||
const defaults = {
|
||||
// The libp2p modules for this libp2p bundle
|
||||
modules: {
|
||||
transport: [
|
||||
TCP,
|
||||
new WS() // It can take instances too!
|
||||
],
|
||||
streamMuxer: [
|
||||
SPDY,
|
||||
MPLEX
|
||||
],
|
||||
connEncryption: [
|
||||
SECIO
|
||||
],
|
||||
/** Encryption for private networks. Needs additional private key to work **/
|
||||
// connProtector: new Protector(/*protector specific opts*/),
|
||||
/** Enable custom content routers, such as delegated routing **/
|
||||
// contentRouting: [
|
||||
// new DelegatedContentRouter(peerInfo.id)
|
||||
// ],
|
||||
/** Enable custom peer routers, such as delegated routing **/
|
||||
// peerRouting: [
|
||||
// new DelegatedPeerRouter()
|
||||
// ],
|
||||
peerDiscovery: [
|
||||
MulticastDNS
|
||||
],
|
||||
dht: DHT, // DHT enables PeerRouting, ContentRouting and DHT itself components
|
||||
pubsub: GossipSub
|
||||
},
|
||||
|
||||
// libp2p config options (typically found on a config.json)
|
||||
config: { // The config object is the part of the config that can go into a file, config.json.
|
||||
peerDiscovery: {
|
||||
autoDial: true, // Auto connect to discovered peers (limited by ConnectionManager minPeers)
|
||||
mdns: { // mdns options
|
||||
interval: 1000, // ms
|
||||
enabled: true
|
||||
},
|
||||
webrtcStar: { // webrtc-star options
|
||||
interval: 1000, // ms
|
||||
enabled: false
|
||||
}
|
||||
// .. other discovery module options.
|
||||
},
|
||||
relay: { // Circuit Relay options
|
||||
enabled: true,
|
||||
hop: {
|
||||
enabled: false,
|
||||
active: false
|
||||
}
|
||||
},
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
enabled: true,
|
||||
randomWalk: {
|
||||
enabled: true, // Allows to disable discovery (enabled by default)
|
||||
interval: 300e3,
|
||||
timeout: 10e3
|
||||
}
|
||||
},
|
||||
pubsub: {
|
||||
enabled: true,
|
||||
emitSelf: true, // whether the node should emit to self on publish, in the event of the topic being subscribed
|
||||
signMessages: true, // if messages should be signed
|
||||
strictSigning: true // if message signing should be required
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// overload any defaults of your bundle using https://github.com/nodeutils/defaults-deep
|
||||
super(defaultsDeep(_options, defaults))
|
||||
}
|
||||
}
|
||||
|
||||
// Now all the nodes you create, will have TCP, WebSockets, SPDY, MPLEX, SECIO and MulticastDNS support.
|
||||
```
|
||||
For all the information on how you can configure libp2p see [CONFIGURATION.md](./doc/CONFIGURATION.md).
|
||||
|
||||
### API
|
||||
|
||||
**IMPORTANT NOTE**: All the methods listed in the API section that take a callback are also now Promisified. Libp2p is migrating away from callbacks to async/await, and in a future release (that will be announced in advance), callback support will be removed entirely. You can follow progress of the async/await endeavor at https://github.com/ipfs/js-ipfs/issues/1670.
|
||||
The specification is available on [API.md](./doc/API.md).
|
||||
|
||||
#### Create a Node - `Libp2p.create(options)`
|
||||
### Getting started
|
||||
|
||||
> Behaves exactly like `new Libp2p(options)`, but doesn't require a PeerInfo. One will be generated instead
|
||||
If you are starting your journey with `js-libp2p`, read the [GETTING_STARTED.md](./doc/GETTING_STARTED.md) guide.
|
||||
|
||||
```js
|
||||
const { create } = require('libp2p')
|
||||
const libp2p = await create(options)
|
||||
### Tutorials and Examples
|
||||
|
||||
await libp2p.start()
|
||||
```
|
||||
|
||||
- `options`: Object of libp2p configuration options
|
||||
|
||||
#### Create a Node alternative - `new Libp2p(options)`
|
||||
|
||||
> Creates an instance of Libp2p with a custom `PeerInfo` provided via `options.peerInfo`.
|
||||
|
||||
Required keys in the `options` object:
|
||||
|
||||
- `peerInfo`: instance of [PeerInfo][] that contains the [PeerId][], Keys and [multiaddrs][multiaddr] of the libp2p Node.
|
||||
- `modules.transport`: An array that must include at least 1 transport, such as `libp2p-tcp`.
|
||||
|
||||
#### `libp2p.start(callback)`
|
||||
|
||||
> Start the libp2p Node.
|
||||
|
||||
`callback` following signature `function (err) {}`, where `err` is an Error in case starting the node fails.
|
||||
|
||||
#### `libp2p.stop(callback)`
|
||||
|
||||
> Stop the libp2p Node.
|
||||
|
||||
`callback` following signature `function (err) {}`, where `err` is an Error in case stopping the node fails.
|
||||
|
||||
#### `libp2p.dial(peer, callback)`
|
||||
|
||||
> Dials to another peer in the network, establishes the connection.
|
||||
|
||||
- `peer`: can be an instance of [PeerInfo][], [PeerId][], [multiaddr][], or a multiaddr string
|
||||
- `callback` following signature `function (err, conn) {}`, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
|
||||
|
||||
#### `libp2p.dialProtocol(peer, protocol, callback)`
|
||||
|
||||
> Dials to another peer in the network and selects a protocol to talk with that peer.
|
||||
|
||||
- `peer`: can be an instance of [PeerInfo][], [PeerId][], [multiaddr][], or a multiaddr string
|
||||
- `protocol`: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
|
||||
- `callback`: Function with signature `function (err, conn) {}`, where `conn` is a [Connection](https://github.com/libp2p/interface-connection) object
|
||||
|
||||
`callback` following signature `function (err, conn) {}`, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
|
||||
|
||||
#### `libp2p.dialFSM(peer, protocol, callback)`
|
||||
|
||||
> Behaves like `.dial` and `.dialProtocol` but calls back with a Connection State Machine
|
||||
|
||||
- `peer`: can be an instance of [PeerInfo][], [PeerId][], [multiaddr][], or a multiaddr string
|
||||
- `protocol`: an optional String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
|
||||
- `callback`: following signature `function (err, connFSM) {}`, where `connFSM` is a [Connection State Machine](https://github.com/libp2p/js-libp2p-switch#connection-state-machine)
|
||||
|
||||
#### `libp2p.hangUp(peer, callback)`
|
||||
|
||||
> Closes an open connection with a peer, graciously.
|
||||
|
||||
- `peer`: can be an instance of [PeerInfo][], [PeerId][] or [multiaddr][]
|
||||
|
||||
`callback` following signature `function (err) {}`, where `err` is an Error in case stopping the node fails.
|
||||
|
||||
#### `libp2p.peerRouting.findPeer(id, options, callback)`
|
||||
|
||||
> Looks up for multiaddrs of a peer in the DHT
|
||||
|
||||
- `id`: instance of [PeerId][]
|
||||
- `options`: object of options
|
||||
- `options.maxTimeout`: Number milliseconds
|
||||
|
||||
#### `libp2p.contentRouting.findProviders(key, options, callback)`
|
||||
|
||||
- `key`: Buffer
|
||||
- `options`: object of options
|
||||
- `options.maxTimeout`: Number milliseconds
|
||||
- `options.maxNumProviders` maximum number of providers to find
|
||||
|
||||
#### `libp2p.contentRouting.provide(key, callback)`
|
||||
|
||||
- `key`: Buffer
|
||||
|
||||
#### `libp2p.handle(protocol, handlerFunc [, matchFunc])`
|
||||
|
||||
> Handle new protocol
|
||||
|
||||
- `protocol`: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
|
||||
- `handlerFunc`: following signature `function (protocol, conn) {}`, where `conn` is a [Connection](https://github.com/libp2p/interface-connection) object
|
||||
- `matchFunc`: Function for matching on protocol (exact matching, semver, etc). Default to exact match.
|
||||
|
||||
#### `libp2p.unhandle(protocol)`
|
||||
|
||||
> Stop handling protocol
|
||||
|
||||
- `protocol`: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
|
||||
|
||||
#### Events
|
||||
|
||||
##### `libp2p.on('start', () => {})`
|
||||
|
||||
> Libp2p has started, along with all its services.
|
||||
|
||||
##### `libp2p.on('stop', () => {})`
|
||||
|
||||
> Libp2p has stopped, along with all its services.
|
||||
|
||||
##### `libp2p.on('error', (err) => {})`
|
||||
|
||||
> An error has occurred
|
||||
|
||||
- `err`: instance of `Error`
|
||||
|
||||
##### `libp2p.on('peer:discovery', (peer) => {})`
|
||||
|
||||
> Peer has been discovered.
|
||||
|
||||
If `autoDial` is `true`, applications should **not** attempt to connect to the peer
|
||||
unless they are performing a specific action. See [peer discovery and auto dial](./doc/PEER_DISCOVERY.md) for more information.
|
||||
|
||||
- `peer`: instance of [PeerInfo][]
|
||||
|
||||
##### `libp2p.on('peer:connect', (peer) => {})`
|
||||
|
||||
> We have a new muxed connection to a peer
|
||||
|
||||
- `peer`: instance of [PeerInfo][]
|
||||
|
||||
##### `libp2p.on('peer:disconnect', (peer) => {})`
|
||||
|
||||
> We have closed a connection to a peer
|
||||
|
||||
- `peer`: instance of [PeerInfo][]
|
||||
|
||||
##### `libp2p.on('connection:start', (peer) => {})`
|
||||
|
||||
> We created a new connection to a peer
|
||||
|
||||
- `peer`: instance of [PeerInfo][]
|
||||
|
||||
##### `libp2p.on('connection:end', (peer) => {})`
|
||||
|
||||
> We closed a connection to a peer
|
||||
|
||||
- `peer`: instance of [PeerInfo][]
|
||||
|
||||
#### `libp2p.isStarted()`
|
||||
|
||||
> Check if libp2p is started
|
||||
|
||||
#### `libp2p.ping(peer [, options], callback)`
|
||||
|
||||
> Ping a node in the network
|
||||
|
||||
#### `libp2p.peerBook`
|
||||
|
||||
> PeerBook instance of the node
|
||||
|
||||
#### `libp2p.peerInfo`
|
||||
|
||||
> PeerInfo instance of the node
|
||||
|
||||
#### `libp2p.pubsub`
|
||||
|
||||
> Same API as IPFS PubSub, defined in the [CORE API Spec](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md). Just replace `ipfs` by `libp2p` and you are golden.
|
||||
|
||||
---------------------
|
||||
|
||||
`DHT methods also exposed for the time being`
|
||||
|
||||
#### `libp2p.dht.put(key, value, callback)`
|
||||
|
||||
- `key`: Buffer
|
||||
- `value`: Buffer
|
||||
|
||||
#### `libp2p.dht.get(key, options, callback)`
|
||||
|
||||
- `key`: Buffer
|
||||
- `options`: object of options
|
||||
- `options.maxTimeout`: Number milliseconds
|
||||
|
||||
#### `libp2p.dht.getMany(key, nVals, options, callback)`
|
||||
|
||||
- `key`: Buffer
|
||||
- `nVals`: Number
|
||||
- `options`: object of options
|
||||
- `options.maxTimeout`: Number milliseconds
|
||||
|
||||
[PeerInfo]: https://github.com/libp2p/js-peer-info
|
||||
[PeerId]: https://github.com/libp2p/js-peer-id
|
||||
[PeerBook]: https://github.com/libp2p/js-peer-book
|
||||
[multiaddr]: https://github.com/multiformats/js-multiaddr
|
||||
[Connection]: https://github.com/libp2p/interface-connection
|
||||
|
||||
-------
|
||||
|
||||
### Switch Stats API
|
||||
|
||||
##### `libp2p.stats.emit('update')`
|
||||
|
||||
Every time any stat value changes, this object emits an `update` event.
|
||||
|
||||
#### Global stats
|
||||
|
||||
##### `libp2p.stats.global.snapshot`
|
||||
|
||||
Should return a stats snapshot, which is an object containing the following keys and respective values:
|
||||
|
||||
- dataSent: amount of bytes sent, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
- dataReceived: amount of bytes received, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
|
||||
##### `libp2p.stats.global.movingAverages`
|
||||
|
||||
Returns an object containing the following keys:
|
||||
|
||||
- dataSent
|
||||
- dataReceived
|
||||
|
||||
Each one of them contains an object that has a key for each interval (`60000`, `300000` and `900000` miliseconds).
|
||||
|
||||
Each one of these values is [an exponential moving-average instance](https://github.com/pgte/moving-average#readme).
|
||||
|
||||
#### Per-transport stats
|
||||
|
||||
##### `libp2p.stats.transports()`
|
||||
|
||||
Returns an array containing the tags (string) for each observed transport.
|
||||
|
||||
##### `libp2p.stats.forTransport(transportTag).snapshot`
|
||||
|
||||
Should return a stats snapshot, which is an object containing the following keys and respective values:
|
||||
|
||||
- dataSent: amount of bytes sent, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
- dataReceived: amount of bytes received, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
|
||||
##### `libp2p.stats.forTransport(transportTag).movingAverages`
|
||||
|
||||
Returns an object containing the following keys:
|
||||
|
||||
dataSent
|
||||
dataReceived
|
||||
|
||||
Each one of them contains an object that has a key for each interval (`60000`, `300000` and `900000` miliseconds).
|
||||
|
||||
Each one of these values is [an exponential moving-average instance](https://github.com/pgte/moving-average#readme).
|
||||
|
||||
#### Per-protocol stats
|
||||
|
||||
##### `libp2p.stats.protocols()`
|
||||
|
||||
Returns an array containing the tags (string) for each observed protocol.
|
||||
|
||||
##### `libp2p.stats.forProtocol(protocolTag).snapshot`
|
||||
|
||||
Should return a stats snapshot, which is an object containing the following keys and respective values:
|
||||
|
||||
- dataSent: amount of bytes sent, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
- dataReceived: amount of bytes received, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
|
||||
|
||||
##### `libp2p.stats.forProtocol(protocolTag).movingAverages`
|
||||
|
||||
Returns an object containing the following keys:
|
||||
|
||||
- dataSent
|
||||
- dataReceived
|
||||
|
||||
Each one of them contains an object that has a key for each interval (`60000`, `300000` and `900000` miliseconds).
|
||||
|
||||
Each one of these values is [an exponential moving-average instance](https://github.com/pgte/moving-average#readme).
|
||||
|
||||
#### Per-peer stats
|
||||
|
||||
##### `libp2p.stats.peers()`
|
||||
|
||||
Returns an array containing the peerIDs (B58-encoded string) for each observed peer.
|
||||
|
||||
##### `libp2p.stats.forPeer(peerId:String).snapshot`
|
||||
|
||||
Should return a stats snapshot, which is an object containing the following keys and respective values:
|
||||
|
||||
- dataSent: amount of bytes sent, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
- dataReceived: amount of bytes received, [Big](https://github.com/MikeMcl/big.js#readme) number
|
||||
|
||||
|
||||
##### `libp2p.stats.forPeer(peerId:String).movingAverages`
|
||||
|
||||
Returns an object containing the following keys:
|
||||
|
||||
- dataSent
|
||||
- dataReceived
|
||||
|
||||
Each one of them contains an object that has a key for each interval (`60000`, `300000` and `900000` miliseconds).
|
||||
|
||||
Each one of these values is [an exponential moving-average instance](https://github.com/pgte/moving-average#readme).
|
||||
|
||||
#### Stats update interval
|
||||
|
||||
Stats are not updated in real-time. Instead, measurements are buffered and stats are updated at an interval. The maximum interval can be defined through the `Switch` constructor option `stats.computeThrottleTimeout`, defined in miliseconds.
|
||||
|
||||
### Private Networks
|
||||
|
||||
#### Enforcement
|
||||
|
||||
Libp2p provides support for connection protection, such as for private networks. You can enforce network protection by setting the environment variable `LIBP2P_FORCE_PNET=1`. When this variable is on, if no protector is set via `options.connProtector`, Libp2p will throw an error upon creation.
|
||||
|
||||
#### Protectors
|
||||
|
||||
Some available network protectors:
|
||||
* [libp2p-pnet](https://github.com/libp2p/js-libp2p-pnet)
|
||||
You can find multiple examples on the [examples folder](./examples) that will guide you through using libp2p for several scenarios.
|
||||
|
||||
## Development
|
||||
|
||||
**Clone and install dependencies:**
|
||||
|
||||
```sh
|
||||
> git clone https://github.com/ipfs/js-ipfs.git
|
||||
> cd js-ipfs
|
||||
> git clone https://github.com/libp2p/js-libp2p.git
|
||||
> cd js-libp2p
|
||||
> npm install
|
||||
```
|
||||
|
||||
@ -558,50 +134,45 @@ List of packages currently in existence for libp2p
|
||||
|
||||
| Package | Version | Deps | CI | Coverage | Lead Maintainer |
|
||||
| ---------|---------|---------|---------|---------|--------- |
|
||||
| **Libp2p** |
|
||||
| [`interface-libp2p`](//github.com/libp2p/interface-libp2p) | [](//github.com/libp2p/interface-libp2p/releases) | [](https://david-dm.org/libp2p/interface-libp2p) | [](https://travis-ci.com/libp2p/interface-libp2p) | [](https://codecov.io/gh/libp2p/interface-libp2p) | N/A |
|
||||
| [`libp2p`](//github.com/libp2p/js-libp2p) | [](//github.com/libp2p/js-libp2p/releases) | [](https://david-dm.org/libp2p/js-libp2p) | [](https://travis-ci.com/libp2p/js-libp2p) | [](https://codecov.io/gh/libp2p/js-libp2p) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| **Connection** |
|
||||
| [`interface-connection`](//github.com/libp2p/interface-connection) | [](//github.com/libp2p/interface-connection/releases) | [](https://david-dm.org/libp2p/interface-connection) | [](https://travis-ci.com/libp2p/interface-connection) | [](https://codecov.io/gh/libp2p/interface-connection) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| **Transport** |
|
||||
| [`interface-transport`](//github.com/libp2p/interface-transport) | [](//github.com/libp2p/interface-transport/releases) | [](https://david-dm.org/libp2p/interface-transport) | [](https://travis-ci.com/libp2p/interface-transport) | [](https://codecov.io/gh/libp2p/interface-transport) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-tcp`](//github.com/libp2p/js-libp2p-tcp) | [](//github.com/libp2p/js-libp2p-tcp/releases) | [](https://david-dm.org/libp2p/js-libp2p-tcp) | [](https://travis-ci.com/libp2p/js-libp2p-tcp) | [](https://codecov.io/gh/libp2p/js-libp2p-tcp) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-utp`](//github.com/libp2p/js-libp2p-utp) | [](//github.com/libp2p/js-libp2p-utp/releases) | [](https://david-dm.org/libp2p/js-libp2p-utp) | [](https://travis-ci.com/libp2p/js-libp2p-utp) | [](https://codecov.io/gh/libp2p/js-libp2p-utp) | N/A |
|
||||
| [`libp2p-webrtc-direct`](//github.com/libp2p/js-libp2p-webrtc-direct) | [](//github.com/libp2p/js-libp2p-webrtc-direct/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-direct) | [](https://travis-ci.com/libp2p/js-libp2p-webrtc-direct) | [](https://codecov.io/gh/libp2p/js-libp2p-webrtc-direct) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | [](//github.com/libp2p/js-libp2p-websockets/releases) | [](https://david-dm.org/libp2p/js-libp2p-websockets) | [](https://travis-ci.com/libp2p/js-libp2p-websockets) | [](https://codecov.io/gh/libp2p/js-libp2p-websockets) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-websocket-star`](//github.com/libp2p/js-libp2p-websocket-star) | [](//github.com/libp2p/js-libp2p-websocket-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-websocket-star) | [](https://travis-ci.com/libp2p/js-libp2p-websocket-star) | [](https://codecov.io/gh/libp2p/js-libp2p-websocket-star) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| **Crypto Channels** |
|
||||
| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [](//github.com/libp2p/js-libp2p-secio/releases) | [](https://david-dm.org/libp2p/js-libp2p-secio) | [](https://travis-ci.com/libp2p/js-libp2p-secio) | [](https://codecov.io/gh/libp2p/js-libp2p-secio) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
|
||||
| **Stream Muxers** |
|
||||
| [`interface-stream-muxer`](//github.com/libp2p/interface-stream-muxer) | [](//github.com/libp2p/interface-stream-muxer/releases) | [](https://david-dm.org/libp2p/interface-stream-muxer) | [](https://travis-ci.com/libp2p/interface-stream-muxer) | [](https://codecov.io/gh/libp2p/interface-stream-muxer) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-mplex`](//github.com/libp2p/js-libp2p-mplex) | [](//github.com/libp2p/js-libp2p-mplex/releases) | [](https://david-dm.org/libp2p/js-libp2p-mplex) | [](https://travis-ci.com/libp2p/js-libp2p-mplex) | [](https://codecov.io/gh/libp2p/js-libp2p-mplex) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-spdy`](//github.com/libp2p/js-libp2p-spdy) | [](//github.com/libp2p/js-libp2p-spdy/releases) | [](https://david-dm.org/libp2p/js-libp2p-spdy) | [](https://travis-ci.com/libp2p/js-libp2p-spdy) | [](https://codecov.io/gh/libp2p/js-libp2p-spdy) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| **Discovery** |
|
||||
| [`interface-peer-discovery`](//github.com/libp2p/interface-peer-discovery) | [](//github.com/libp2p/interface-peer-discovery/releases) | [](https://david-dm.org/libp2p/interface-peer-discovery) | [](https://travis-ci.com/libp2p/interface-peer-discovery) | [](https://codecov.io/gh/libp2p/interface-peer-discovery) | N/A |
|
||||
| [`libp2p-bootstrap`](//github.com/libp2p/js-libp2p-bootstrap) | [](//github.com/libp2p/js-libp2p-bootstrap/releases) | [](https://david-dm.org/libp2p/js-libp2p-bootstrap) | [](https://travis-ci.com/libp2p/js-libp2p-bootstrap) | [](https://codecov.io/gh/libp2p/js-libp2p-bootstrap) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [](//github.com/libp2p/js-libp2p-kad-dht/releases) | [](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [](https://codecov.io/gh/libp2p/js-libp2p-kad-dht) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-mdns`](//github.com/libp2p/js-libp2p-mdns) | [](//github.com/libp2p/js-libp2p-mdns/releases) | [](https://david-dm.org/libp2p/js-libp2p-mdns) | [](https://travis-ci.com/libp2p/js-libp2p-mdns) | [](https://codecov.io/gh/libp2p/js-libp2p-mdns) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-rendezvous`](//github.com/libp2p/js-libp2p-rendezvous) | [](//github.com/libp2p/js-libp2p-rendezvous/releases) | [](https://david-dm.org/libp2p/js-libp2p-rendezvous) | [](https://travis-ci.com/libp2p/js-libp2p-rendezvous) | [](https://codecov.io/gh/libp2p/js-libp2p-rendezvous) | N/A |
|
||||
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-websocket-star`](//github.com/libp2p/js-libp2p-websocket-star) | [](//github.com/libp2p/js-libp2p-websocket-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-websocket-star) | [](https://travis-ci.com/libp2p/js-libp2p-websocket-star) | [](https://codecov.io/gh/libp2p/js-libp2p-websocket-star) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| **Content Routing** |
|
||||
| [`interface-content-routing`](//github.com/libp2p/interface-content-routing) | [](//github.com/libp2p/interface-content-routing/releases) | [](https://david-dm.org/libp2p/interface-content-routing) | [](https://travis-ci.com/libp2p/interface-content-routing) | [](https://codecov.io/gh/libp2p/interface-content-routing) | N/A |
|
||||
| [`libp2p-delegated-content-routing`](//github.com/libp2p/js-libp2p-delegated-content-routing) | [](//github.com/libp2p/js-libp2p-delegated-content-routing/releases) | [](https://david-dm.org/libp2p/js-libp2p-delegated-content-routing) | [](https://travis-ci.com/libp2p/js-libp2p-delegated-content-routing) | [](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [](//github.com/libp2p/js-libp2p-kad-dht/releases) | [](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [](https://codecov.io/gh/libp2p/js-libp2p-kad-dht) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| **Peer Routing** |
|
||||
| [`interface-peer-routing`](//github.com/libp2p/interface-peer-routing) | [](//github.com/libp2p/interface-peer-routing/releases) | [](https://david-dm.org/libp2p/interface-peer-routing) | [](https://travis-ci.com/libp2p/interface-peer-routing) | [](https://codecov.io/gh/libp2p/interface-peer-routing) | N/A |
|
||||
| [`libp2p-delegated-peer-routing`](//github.com/libp2p/js-libp2p-delegated-peer-routing) | [](//github.com/libp2p/js-libp2p-delegated-peer-routing/releases) | [](https://david-dm.org/libp2p/js-libp2p-delegated-peer-routing) | [](https://travis-ci.com/libp2p/js-libp2p-delegated-peer-routing) | [](https://codecov.io/gh/libp2p/js-libp2p-delegated-peer-routing) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [](//github.com/libp2p/js-libp2p-kad-dht/releases) | [](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [](https://codecov.io/gh/libp2p/js-libp2p-kad-dht) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| **Utilities** |
|
||||
| [`libp2p-crypto`](//github.com/libp2p/js-libp2p-crypto) | [](//github.com/libp2p/js-libp2p-crypto/releases) | [](https://david-dm.org/libp2p/js-libp2p-crypto) | [](https://travis-ci.com/libp2p/js-libp2p-crypto) | [](https://codecov.io/gh/libp2p/js-libp2p-crypto) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
|
||||
| [`libp2p-crypto-secp256k1`](//github.com/libp2p/js-libp2p-crypto-secp256k1) | [](//github.com/libp2p/js-libp2p-crypto-secp256k1/releases) | [](https://david-dm.org/libp2p/js-libp2p-crypto-secp256k1) | [](https://travis-ci.com/libp2p/js-libp2p-crypto-secp256k1) | [](https://codecov.io/gh/libp2p/js-libp2p-crypto-secp256k1) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
|
||||
| **Data Types** |
|
||||
| [`peer-book`](//github.com/libp2p/js-peer-book) | [](//github.com/libp2p/js-peer-book/releases) | [](https://david-dm.org/libp2p/js-peer-book) | [](https://travis-ci.com/libp2p/js-peer-book) | [](https://codecov.io/gh/libp2p/js-peer-book) | [Pedro Teixeira](mailto:i@pgte.me) |
|
||||
| [`peer-id`](//github.com/libp2p/js-peer-id) | [](//github.com/libp2p/js-peer-id/releases) | [](https://david-dm.org/libp2p/js-peer-id) | [](https://travis-ci.com/libp2p/js-peer-id) | [](https://codecov.io/gh/libp2p/js-peer-id) | [Pedro Teixeira](mailto:i@pgte.me) |
|
||||
| [`peer-info`](//github.com/libp2p/js-peer-info) | [](//github.com/libp2p/js-peer-info/releases) | [](https://david-dm.org/libp2p/js-peer-info) | [](https://travis-ci.com/libp2p/js-peer-info) | [](https://codecov.io/gh/libp2p/js-peer-info) | [Pedro Teixeira](mailto:i@pgte.me) |
|
||||
| **Extensions** |
|
||||
| [`libp2p-floodsub`](//github.com/libp2p/js-libp2p-floodsub) | [](//github.com/libp2p/js-libp2p-floodsub/releases) | [](https://david-dm.org/libp2p/js-libp2p-floodsub) | [](https://travis-ci.com/libp2p/js-libp2p-floodsub) | [](https://codecov.io/gh/libp2p/js-libp2p-floodsub) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| **libp2p** |
|
||||
| [`libp2p`](//github.com/libp2p/js-libp2p) | [](//github.com/libp2p/js-libp2p/releases) | [](https://david-dm.org/libp2p/js-libp2p) | [](https://travis-ci.com/libp2p/js-libp2p) | [](https://codecov.io/gh/libp2p/js-libp2p) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-daemon`](//github.com/libp2p/js-libp2p-daemon) | [](//github.com/libp2p/js-libp2p-daemon/releases) | [](https://david-dm.org/libp2p/js-libp2p-daemon) | [](https://travis-ci.com/libp2p/js-libp2p-daemon) | [](https://codecov.io/gh/libp2p/js-libp2p-daemon) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-daemon-client`](//github.com/libp2p/js-libp2p-daemon-client) | [](//github.com/libp2p/js-libp2p-daemon-client/releases) | [](https://david-dm.org/libp2p/js-libp2p-daemon-client) | [](https://travis-ci.com/libp2p/js-libp2p-daemon-client) | [](https://codecov.io/gh/libp2p/js-libp2p-daemon-client) | [Vasco Santos](mailto:santos.vasco10@gmail.com) |
|
||||
| [`libp2p-interfaces`](//github.com/libp2p/js-interfaces) | [](//github.com/libp2p/js-interfaces/releases) | [](https://david-dm.org/libp2p/js-interfaces) | [](https://travis-ci.com/libp2p/js-interfaces) | [](https://codecov.io/gh/libp2p/js-interfaces) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`interop-libp2p`](//github.com/libp2p/interop) | [](//github.com/libp2p/interop/releases) | [](https://david-dm.org/libp2p/interop) | [](https://travis-ci.com/libp2p/interop) | [](https://codecov.io/gh/libp2p/interop) | [Vasco Santos](mailto:santos.vasco10@gmail.com) |
|
||||
| **transports** |
|
||||
| [`libp2p-tcp`](//github.com/libp2p/js-libp2p-tcp) | [](//github.com/libp2p/js-libp2p-tcp/releases) | [](https://david-dm.org/libp2p/js-libp2p-tcp) | [](https://travis-ci.com/libp2p/js-libp2p-tcp) | [](https://codecov.io/gh/libp2p/js-libp2p-tcp) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-webrtc-direct`](//github.com/libp2p/js-libp2p-webrtc-direct) | [](//github.com/libp2p/js-libp2p-webrtc-direct/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-direct) | [](https://travis-ci.com/libp2p/js-libp2p-webrtc-direct) | [](https://codecov.io/gh/libp2p/js-libp2p-webrtc-direct) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | [](//github.com/libp2p/js-libp2p-websockets/releases) | [](https://david-dm.org/libp2p/js-libp2p-websockets) | [](https://travis-ci.com/libp2p/js-libp2p-websockets) | [](https://codecov.io/gh/libp2p/js-libp2p-websockets) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| **secure channels** |
|
||||
| [`libp2p-noise`](//github.com/NodeFactoryIo/js-libp2p-noise) | [](//github.com/NodeFactoryIo/js-libp2p-noise/releases) | [](https://david-dm.org/NodeFactoryIo/js-libp2p-noise) | [](https://travis-ci.com/NodeFactoryIo/js-libp2p-noise) | [](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise) | N/A |
|
||||
| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [](//github.com/libp2p/js-libp2p-secio/releases) | [](https://david-dm.org/libp2p/js-libp2p-secio) | [](https://travis-ci.com/libp2p/js-libp2p-secio) | [](https://codecov.io/gh/libp2p/js-libp2p-secio) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
|
||||
| **stream multiplexers** |
|
||||
| [`libp2p-mplex`](//github.com/libp2p/js-libp2p-mplex) | [](//github.com/libp2p/js-libp2p-mplex/releases) | [](https://david-dm.org/libp2p/js-libp2p-mplex) | [](https://travis-ci.com/libp2p/js-libp2p-mplex) | [](https://codecov.io/gh/libp2p/js-libp2p-mplex) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| **peer discovery** |
|
||||
| [`libp2p-bootstrap`](//github.com/libp2p/js-libp2p-bootstrap) | [](//github.com/libp2p/js-libp2p-bootstrap/releases) | [](https://david-dm.org/libp2p/js-libp2p-bootstrap) | [](https://travis-ci.com/libp2p/js-libp2p-bootstrap) | [](https://codecov.io/gh/libp2p/js-libp2p-bootstrap) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [](//github.com/libp2p/js-libp2p-kad-dht/releases) | [](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [](https://codecov.io/gh/libp2p/js-libp2p-kad-dht) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-mdns`](//github.com/libp2p/js-libp2p-mdns) | [](//github.com/libp2p/js-libp2p-mdns/releases) | [](https://david-dm.org/libp2p/js-libp2p-mdns) | [](https://travis-ci.com/libp2p/js-libp2p-mdns) | [](https://codecov.io/gh/libp2p/js-libp2p-mdns) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`@chainsafe/discv5`](//github.com/ChainSafe/discv5) | [](//github.com/ChainSafe/discv5/releases) | [](https://david-dm.org/ChainSafe/discv5) | [](https://travis-ci.com/ChainSafe/discv5) | [](https://codecov.io/gh/ChainSafe/discv5) | [Cayman Nava](mailto:caymannava@gmail.com) |
|
||||
| **content routing** |
|
||||
| [`libp2p-delegated-content-routing`](//github.com/libp2p/js-libp2p-delegated-content-routing) | [](//github.com/libp2p/js-libp2p-delegated-content-routing/releases) | [](https://david-dm.org/libp2p/js-libp2p-delegated-content-routing) | [](https://travis-ci.com/libp2p/js-libp2p-delegated-content-routing) | [](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [](//github.com/libp2p/js-libp2p-kad-dht/releases) | [](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [](https://codecov.io/gh/libp2p/js-libp2p-kad-dht) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| **peer routing** |
|
||||
| [`libp2p-delegated-peer-routing`](//github.com/libp2p/js-libp2p-delegated-peer-routing) | [](//github.com/libp2p/js-libp2p-delegated-peer-routing/releases) | [](https://david-dm.org/libp2p/js-libp2p-delegated-peer-routing) | [](https://travis-ci.com/libp2p/js-libp2p-delegated-peer-routing) | [](https://codecov.io/gh/libp2p/js-libp2p-delegated-peer-routing) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [](//github.com/libp2p/js-libp2p-kad-dht/releases) | [](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [](https://codecov.io/gh/libp2p/js-libp2p-kad-dht) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| **utilities** |
|
||||
| [`libp2p-crypto`](//github.com/libp2p/js-libp2p-crypto) | [](//github.com/libp2p/js-libp2p-crypto/releases) | [](https://david-dm.org/libp2p/js-libp2p-crypto) | [](https://travis-ci.com/libp2p/js-libp2p-crypto) | [](https://codecov.io/gh/libp2p/js-libp2p-crypto) | [Jacob Heun](mailto:jacobheun@gmail.com) |
|
||||
| [`libp2p-crypto-secp256k1`](//github.com/libp2p/js-libp2p-crypto-secp256k1) | [](//github.com/libp2p/js-libp2p-crypto-secp256k1/releases) | [](https://david-dm.org/libp2p/js-libp2p-crypto-secp256k1) | [](https://travis-ci.com/libp2p/js-libp2p-crypto-secp256k1) | [](https://codecov.io/gh/libp2p/js-libp2p-crypto-secp256k1) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
|
||||
| **data types** |
|
||||
| [`peer-id`](//github.com/libp2p/js-peer-id) | [](//github.com/libp2p/js-peer-id/releases) | [](https://david-dm.org/libp2p/js-peer-id) | [](https://travis-ci.com/libp2p/js-peer-id) | [](https://codecov.io/gh/libp2p/js-peer-id) | [Vasco Santos](mailto:santos.vasco10@gmail.com) |
|
||||
| **pubsub** |
|
||||
| [`libp2p-floodsub`](//github.com/libp2p/js-libp2p-floodsub) | [](//github.com/libp2p/js-libp2p-floodsub/releases) | [](https://david-dm.org/libp2p/js-libp2p-floodsub) | [](https://travis-ci.com/libp2p/js-libp2p-floodsub) | [](https://codecov.io/gh/libp2p/js-libp2p-floodsub) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
|
||||
| [`libp2p-gossipsub`](//github.com/ChainSafe/js-libp2p-gossipsub) | [](//github.com/ChainSafe/js-libp2p-gossipsub/releases) | [](https://david-dm.org/ChainSafe/js-libp2p-gossipsub) | [](https://travis-ci.com/ChainSafe/js-libp2p-gossipsub) | [](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub) | [Cayman Nava](mailto:caymannava@gmail.com) |
|
||||
| **extensions** |
|
||||
| [`libp2p-nat-mgnr`](//github.com/libp2p/js-libp2p-nat-mgnr) | [](//github.com/libp2p/js-libp2p-nat-mgnr/releases) | [](https://david-dm.org/libp2p/js-libp2p-nat-mgnr) | [](https://travis-ci.com/libp2p/js-libp2p-nat-mgnr) | [](https://codecov.io/gh/libp2p/js-libp2p-nat-mgnr) | N/A |
|
||||
| [`libp2p-utils`](//github.com/libp2p/js-libp2p-utils) | [](//github.com/libp2p/js-libp2p-utils/releases) | [](https://david-dm.org/libp2p/js-libp2p-utils) | [](https://travis-ci.com/libp2p/js-libp2p-utils) | [](https://codecov.io/gh/libp2p/js-libp2p-utils) | [Vasco Santos](mailto:santos.vasco10@gmail.com) |
|
||||
|
||||
## Contribute
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
- Documentation
|
||||
- [ ] Ensure that README.md is up to date
|
||||
- [ ] Ensure that all the examples run
|
||||
- [ ] Ensure [libp2p/js-libp2p-examples](https://github.com/libp2p/js-libp2p-examples) is updated
|
||||
- [ ] Ensure that [libp2p/docs](https://github.com/libp2p/docs) is updated
|
||||
- Communication
|
||||
- [ ] Create the release issue
|
||||
- [ ] Take a snapshot between of everyone that has contributed to this release (including its subdeps in IPFS, libp2p, IPLD and multiformats) using [`name-your-contributors`](https://www.npmjs.com/package/name-your-contributors). Generate a nice markdown list with [this script](https://gist.github.com/jacobheun/d2ff479ca991733c13cdcf688a1317e5)
|
||||
@ -50,8 +52,8 @@ Would you like to contribute to the libp2p project and don't know how? Well, the
|
||||
- Check the issues with the `help wanted` label in the [libp2p repo](https://github.com/libp2p/js-libp2p/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
|
||||
- Join an IPFS All Hands, introduce yourself and let us know where you would like to contribute - https://github.com/ipfs/team-mgmt#all-hands-call
|
||||
- Hack with IPFS and show us what you made! The All Hands call is also the perfect venue for demos, join in and show us what you built
|
||||
- Join the discussion at http://discuss.ipfs.io/ and help users finding their answers.
|
||||
- Join the [⚡️ⒿⓈ Core Dev Team Weekly Sync 🙌🏽 ](https://github.com/ipfs/team-mgmt/issues/650) and be part of the Sprint action!
|
||||
- Join the discussion at http://discuss.libp2p.io/ and help users finding their answers.
|
||||
- Join the [⚡️libp2p Weekly Sync 🙌🏽](https://github.com/libp2p/team-mgmt/issues/16) and be part of the Sprint action!
|
||||
|
||||
# ⁉️ Do you have questions?
|
||||
|
||||
|
2
dist/index.min.js
vendored
Normal file
2
dist/index.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17
dist/index.min.js.LICENSE.txt
vendored
Normal file
17
dist/index.min.js.LICENSE.txt
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <http://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||
|
||||
/**
|
||||
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
||||
*
|
||||
* @version 0.8.0
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2015-2018
|
||||
* @license MIT
|
||||
*/
|
50
dist/src/address-manager/index.d.ts
vendored
Normal file
50
dist/src/address-manager/index.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
export = AddressManager;
|
||||
/**
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} AddressManagerOptions
|
||||
* @property {string[]} [listen = []] - list of multiaddrs string representation to listen.
|
||||
* @property {string[]} [announce = []] - list of multiaddrs string representation to announce.
|
||||
*/
|
||||
declare class AddressManager {
|
||||
/**
|
||||
* Responsible for managing the peer addresses.
|
||||
* Peers can specify their listen and announce addresses.
|
||||
* The listen addresses will be used by the libp2p transports to listen for new connections,
|
||||
* while the announce addresses will be used for the peer addresses' to other peers in the network.
|
||||
*
|
||||
* @class
|
||||
* @param {AddressManagerOptions} [options]
|
||||
*/
|
||||
constructor({ listen, announce }?: AddressManagerOptions | undefined);
|
||||
listen: Set<string>;
|
||||
announce: Set<string>;
|
||||
/**
|
||||
* Get peer listen multiaddrs.
|
||||
*
|
||||
* @returns {Multiaddr[]}
|
||||
*/
|
||||
getListenAddrs(): Multiaddr[];
|
||||
/**
|
||||
* Get peer announcing multiaddrs.
|
||||
*
|
||||
* @returns {Multiaddr[]}
|
||||
*/
|
||||
getAnnounceAddrs(): Multiaddr[];
|
||||
}
|
||||
declare namespace AddressManager {
|
||||
export { Multiaddr, AddressManagerOptions };
|
||||
}
|
||||
type Multiaddr = import("multiaddr");
|
||||
type AddressManagerOptions = {
|
||||
/**
|
||||
* - list of multiaddrs string representation to listen.
|
||||
*/
|
||||
listen?: string[] | undefined;
|
||||
/**
|
||||
* - list of multiaddrs string representation to announce.
|
||||
*/
|
||||
announce?: string[] | undefined;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/address-manager/index.d.ts.map
vendored
Normal file
1
dist/src/address-manager/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address-manager/index.js"],"names":[],"mappings":";AAIA;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;;;;;;OAQG;IACH,sEAGC;IAFC,oBAA6B;IAC7B,sBAAiC;IAGnC;;;;OAIG;IACH,kBAFa,SAAS,EAAE,CAIvB;IAED;;;;OAIG;IACH,oBAFa,SAAS,EAAE,CAIvB;CACF"}
|
106
dist/src/circuit/auto-relay.d.ts
vendored
Normal file
106
dist/src/circuit/auto-relay.d.ts
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
export = AutoRelay;
|
||||
/**
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('../peer-store/address-book').Address} Address
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} AutoRelayProperties
|
||||
* @property {import('../')} libp2p
|
||||
*
|
||||
* @typedef {Object} AutoRelayOptions
|
||||
* @property {number} [maxListeners = 1] - maximum number of relays to listen.
|
||||
*/
|
||||
declare class AutoRelay {
|
||||
/**
|
||||
* Creates an instance of AutoRelay.
|
||||
*
|
||||
* @class
|
||||
* @param {AutoRelayProperties & AutoRelayOptions} props
|
||||
*/
|
||||
constructor({ libp2p, maxListeners }: AutoRelayProperties & AutoRelayOptions);
|
||||
_libp2p: import("..");
|
||||
_peerId: import("peer-id");
|
||||
_peerStore: import("../peer-store");
|
||||
_connectionManager: import("../connection-manager");
|
||||
_transportManager: import("../transport-manager");
|
||||
_addressSorter: (addresses: import("../peer-store/address-book").Address[]) => import("../peer-store/address-book").Address[];
|
||||
maxListeners: number;
|
||||
/**
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
_listenRelays: Set<string>;
|
||||
/**
|
||||
* Check if a peer supports the relay protocol.
|
||||
* If the protocol is not supported, check if it was supported before and remove it as a listen relay.
|
||||
* If the protocol is supported, check if the peer supports **HOP** and add it as a listener if
|
||||
* inside the threshold.
|
||||
*
|
||||
* @param {Object} props
|
||||
* @param {PeerId} props.peerId
|
||||
* @param {string[]} props.protocols
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_onProtocolChange({ peerId, protocols }: {
|
||||
peerId: import("peer-id");
|
||||
protocols: string[];
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* Peer disconnects.
|
||||
*
|
||||
* @param {Connection} connection - connection to the peer
|
||||
* @returns {void}
|
||||
*/
|
||||
_onPeerDisconnected(connection: Connection): void;
|
||||
/**
|
||||
* Attempt to listen on the given relay connection.
|
||||
*
|
||||
* @private
|
||||
* @param {Connection} connection - connection to the peer
|
||||
* @param {string} id - peer identifier string
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private _addListenRelay;
|
||||
/**
|
||||
* Remove listen relay.
|
||||
*
|
||||
* @private
|
||||
* @param {string} id - peer identifier string.
|
||||
* @returns {void}
|
||||
*/
|
||||
private _removeListenRelay;
|
||||
/**
|
||||
* Try to listen on available hop relay connections.
|
||||
* The following order will happen while we do not have enough relays.
|
||||
* 1. Check the metadata store for known relays, try to listen on the ones we are already connected.
|
||||
* 2. Dial and try to listen on the peers we know that support hop but are not connected.
|
||||
* 3. Search the network.
|
||||
*
|
||||
* @param {string[]} [peersToIgnore]
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_listenOnAvailableHopRelays(peersToIgnore?: string[] | undefined): Promise<void>;
|
||||
}
|
||||
declare namespace AutoRelay {
|
||||
export { Connection, Address, AutoRelayProperties, AutoRelayOptions };
|
||||
}
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type AutoRelayProperties = {
|
||||
libp2p: import('../');
|
||||
};
|
||||
type AutoRelayOptions = {
|
||||
/**
|
||||
* - maximum number of relays to listen.
|
||||
*/
|
||||
maxListeners?: number | undefined;
|
||||
};
|
||||
type Address = {
|
||||
/**
|
||||
* peer multiaddr.
|
||||
*/
|
||||
multiaddr: import("multiaddr");
|
||||
/**
|
||||
* obtained from a signed peer record.
|
||||
*/
|
||||
isCertified: boolean;
|
||||
};
|
||||
//# sourceMappingURL=auto-relay.d.ts.map
|
1
dist/src/circuit/auto-relay.d.ts.map
vendored
Normal file
1
dist/src/circuit/auto-relay.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../../src/circuit/auto-relay.js"],"names":[],"mappings":";AAsBA;;;GAGG;AAEH;;;;;;GAMG;AAEH;IACE;;;;;OAKG;IACH,sCAFW,mBAAmB,GAAG,gBAAgB,EAsBhD;IAnBC,sBAAqB;IACrB,2BAA4B;IAC5B,oCAAkC;IAClC,oDAAkD;IAClD,kDAAgD;IAChD,8HAAiD;IAEjD,qBAAgC;IAEhC;;OAEG;IACH,eAFU,IAAI,MAAM,CAAC,CAES;IAShC;;;;;;;;;;OAUG;IACH;QAJyB,MAAM;QACJ,SAAS,EAAzB,MAAM,EAAE;QACN,QAAQ,IAAI,CAAC,CAsCzB;IAED;;;;;OAKG;IACH,gCAHW,UAAU,GACR,IAAI,CAYhB;IAED;;;;;;;OAOG;IACH,wBA0BC;IAED;;;;;;OAMG;IACH,2BAKC;IAED;;;;;;;;;OASG;IACH,mEAFa,QAAQ,IAAI,CAAC,CA2EzB;CACF;;;;;;YA5Oa,OAAO,KAAK,CAAC"}
|
70
dist/src/circuit/circuit/hop.d.ts
vendored
Normal file
70
dist/src/circuit/circuit/hop.d.ts
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
export type CircuitRequest = {
|
||||
type: import("../../types").CircuitType;
|
||||
dstPeer: import("../../types").CircuitPeer;
|
||||
srcPeer: import("../../types").CircuitPeer;
|
||||
};
|
||||
export type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
export type StreamHandlerT = import("./stream-handler")<import("../../types").CircuitRequest>;
|
||||
export type Transport = import("../transport");
|
||||
export type HopRequest = {
|
||||
connection: Connection;
|
||||
request: CircuitRequest;
|
||||
streamHandler: import("./stream-handler")<import("../../types").CircuitRequest>;
|
||||
circuit: Transport;
|
||||
};
|
||||
/**
|
||||
* @typedef {import('../../types').CircuitRequest} CircuitRequest
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('./stream-handler')<CircuitRequest>} StreamHandlerT
|
||||
* @typedef {import('../transport')} Transport
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} HopRequest
|
||||
* @property {Connection} connection
|
||||
* @property {CircuitRequest} request
|
||||
* @property {StreamHandlerT} streamHandler
|
||||
* @property {Transport} circuit
|
||||
*/
|
||||
/**
|
||||
* @param {HopRequest} options
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export function handleHop({ connection, request, streamHandler, circuit }: HopRequest): Promise<void>;
|
||||
/**
|
||||
* Performs a HOP request to a relay peer, to request a connection to another
|
||||
* peer. A new, virtual, connection will be created between the two via the relay.
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {Connection} options.connection - Connection to the relay
|
||||
* @param {CircuitRequest} options.request
|
||||
* @returns {Promise<Connection>}
|
||||
*/
|
||||
export function hop({ connection, request }: {
|
||||
connection: Connection;
|
||||
request: CircuitRequest;
|
||||
}): Promise<Connection>;
|
||||
/**
|
||||
* Performs a CAN_HOP request to a relay peer, in order to understand its capabilities.
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {Connection} options.connection - Connection to the relay
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export function canHop({ connection }: {
|
||||
connection: Connection;
|
||||
}): Promise<boolean>;
|
||||
/**
|
||||
* Creates an unencoded CAN_HOP response based on the Circuits configuration
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {Connection} options.connection
|
||||
* @param {StreamHandlerT} options.streamHandler
|
||||
* @param {Transport} options.circuit
|
||||
* @private
|
||||
*/
|
||||
export function handleCanHop({ connection, streamHandler, circuit }: {
|
||||
connection: Connection;
|
||||
streamHandler: import("./stream-handler")<import("../../types").CircuitRequest>;
|
||||
circuit: Transport;
|
||||
}): void;
|
||||
//# sourceMappingURL=hop.d.ts.map
|
1
dist/src/circuit/circuit/hop.d.ts.map
vendored
Normal file
1
dist/src/circuit/circuit/hop.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"hop.d.ts","sourceRoot":"","sources":["../../../../src/circuit/circuit/hop.js"],"names":[],"mappings":";;;;;;;;;gBA4Bc,UAAU;aACV,cAAc;;aAEd,SAAS;;AAZvB;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AACH,2EAHW,UAAU,GACR,QAAQ,IAAI,CAAC,CAuEzB;AAED;;;;;;;;GAQG;AACH;IAJ+B,UAAU,EAA9B,UAAU;IACc,OAAO,EAA/B,cAAc;IACZ,QAAQ,UAAU,CAAC,CAsB/B;AAED;;;;;;GAMG;AACH;IAH+B,UAAU,EAA9B,UAAU;IACR,QAAQ,OAAO,CAAC,CAqB5B;AAED;;;;;;;;GAQG;AACH;IAL+B,UAAU,EAA9B,UAAU;IACc,aAAa;IAClB,OAAO,EAA1B,SAAS;SAcnB"}
|
18
dist/src/circuit/circuit/stop.d.ts
vendored
Normal file
18
dist/src/circuit/circuit/stop.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
export function handleStop({ connection, request, streamHandler }: {
|
||||
connection: Connection;
|
||||
request: CircuitRequest;
|
||||
streamHandler: import("./stream-handler")<import("../../types").CircuitRequest>;
|
||||
}): Promise<MuxedStream> | void;
|
||||
export function stop({ connection, request }: {
|
||||
connection: Connection;
|
||||
request: CircuitRequest;
|
||||
}): Promise<MuxedStream | void>;
|
||||
export type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
export type MuxedStream = import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
|
||||
export type CircuitRequest = {
|
||||
type: import("../../types").CircuitType;
|
||||
dstPeer: import("../../types").CircuitPeer;
|
||||
srcPeer: import("../../types").CircuitPeer;
|
||||
};
|
||||
export type StreamHandlerT = import("./stream-handler")<import("../../types").CircuitRequest>;
|
||||
//# sourceMappingURL=stop.d.ts.map
|
1
dist/src/circuit/circuit/stop.d.ts.map
vendored
Normal file
1
dist/src/circuit/circuit/stop.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../../src/circuit/circuit/stop.js"],"names":[],"mappings":"AA6B4B;IALG,UAAU,EAA9B,UAAU;IACc,OAAO,EAA/B,cAAc;IACU,aAAa;IACnC,QAAQ,WAAW,CAAC,GAAC,IAAI,CAqBrC;AAWqB;IAJS,UAAU,EAA9B,UAAU;IACc,OAAO,EAA/B,cAAc;IACZ,QAAQ,WAAW,GAAC,IAAI,CAAC,CAoBrC"}
|
56
dist/src/circuit/circuit/stream-handler.d.ts
vendored
Normal file
56
dist/src/circuit/circuit/stream-handler.d.ts
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
export = StreamHandler;
|
||||
/**
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
||||
*/
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
declare class StreamHandler<T> {
|
||||
/**
|
||||
* Create a stream handler for connection
|
||||
*
|
||||
* @class
|
||||
* @param {object} options
|
||||
* @param {MuxedStream} options.stream - A duplex iterable
|
||||
* @param {number} [options.maxLength = 4096] - max bytes length of message
|
||||
*/
|
||||
constructor({ stream, maxLength }: {
|
||||
stream: MuxedStream;
|
||||
maxLength: number | undefined;
|
||||
});
|
||||
stream: import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
|
||||
shake: any;
|
||||
decoder: AsyncGenerator<Buffer | import("bl"), import("bl"), unknown>;
|
||||
/**
|
||||
* Read and decode message
|
||||
*
|
||||
* @async
|
||||
* @returns {Promise<T|undefined>}
|
||||
*/
|
||||
read(): Promise<T | undefined>;
|
||||
/**
|
||||
* Encode and write array of buffers
|
||||
*
|
||||
* @param {CircuitPB} msg - An unencoded CircuitRelay protobuf message
|
||||
* @returns {void}
|
||||
*/
|
||||
write(msg: any): void;
|
||||
/**
|
||||
* Return the handshake rest stream and invalidate handler
|
||||
*
|
||||
* @returns {*} A duplex iterable
|
||||
*/
|
||||
rest(): any;
|
||||
end(msg: any): void;
|
||||
/**
|
||||
* Close the stream
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
close(): void;
|
||||
}
|
||||
declare namespace StreamHandler {
|
||||
export { MuxedStream };
|
||||
}
|
||||
type MuxedStream = import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
|
||||
//# sourceMappingURL=stream-handler.d.ts.map
|
1
dist/src/circuit/circuit/stream-handler.d.ts.map
vendored
Normal file
1
dist/src/circuit/circuit/stream-handler.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../../../src/circuit/circuit/stream-handler.js"],"names":[],"mappings":";AAWA;;GAEG;AAEH;;GAEG;AACH;IACE;;;;;;;OAOG;IACH;QAHgC,MAAM,EAA3B,WAAW;QACM,SAAS;OAOpC;IAJC,uEAAoB;IAEpB,WAAmC;IACnC,sEAAoF;IAGtF;;;;;OAKG;IACH,+BAWC;IAED;;;;;OAKG;IACH,iBAFa,IAAI,CAMhB;IAED;;;;OAIG;IACH,YAGC;IAED,oBAGC;IAED;;;;OAIG;IACH,SAFa,IAAI,CAKhB;CACF"}
|
10
dist/src/circuit/circuit/utils.d.ts
vendored
Normal file
10
dist/src/circuit/circuit/utils.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export type StreamHandler = import("./stream-handler")<any>;
|
||||
export type CircuitStatus = 100 | 220 | 221 | 250 | 251 | 260 | 261 | 262 | 270 | 280 | 320 | 321 | 350 | 351 | 390 | 400;
|
||||
/**
|
||||
* Validate incomming HOP/STOP message
|
||||
*
|
||||
* @param {*} msg - A CircuitRelay unencoded protobuf message
|
||||
* @param {StreamHandler} streamHandler
|
||||
*/
|
||||
export function validateAddrs(msg: any, streamHandler: import("./stream-handler")<any>): void;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
1
dist/src/circuit/circuit/utils.d.ts.map
vendored
Normal file
1
dist/src/circuit/circuit/utils.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/circuit/circuit/utils.js"],"names":[],"mappings":";;AAuBA;;;;;GAKG;AACH,8FAsBC"}
|
7
dist/src/circuit/constants.d.ts
vendored
Normal file
7
dist/src/circuit/constants.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
export const ADVERTISE_BOOT_DELAY: number;
|
||||
export const ADVERTISE_TTL: number;
|
||||
export const CIRCUIT_PROTO_CODE: number;
|
||||
export const HOP_METADATA_KEY: string;
|
||||
export const HOP_METADATA_VALUE: string;
|
||||
export const RELAY_RENDEZVOUS_NS: string;
|
||||
//# sourceMappingURL=constants.d.ts.map
|
1
dist/src/circuit/constants.d.ts.map
vendored
Normal file
1
dist/src/circuit/constants.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/circuit/constants.js"],"names":[],"mappings":""}
|
69
dist/src/circuit/index.d.ts
vendored
Normal file
69
dist/src/circuit/index.d.ts
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
export = Relay;
|
||||
/**
|
||||
* @typedef {import('../')} Libp2p
|
||||
*
|
||||
* @typedef {Object} RelayAdvertiseOptions
|
||||
* @property {number} [bootDelay = ADVERTISE_BOOT_DELAY]
|
||||
* @property {boolean} [enabled = true]
|
||||
* @property {number} [ttl = ADVERTISE_TTL]
|
||||
*
|
||||
* @typedef {Object} HopOptions
|
||||
* @property {boolean} [enabled = false]
|
||||
* @property {boolean} [active = false]
|
||||
*
|
||||
* @typedef {Object} AutoRelayOptions
|
||||
* @property {number} [maxListeners = 2] - maximum number of relays to listen.
|
||||
* @property {boolean} [enabled = false]
|
||||
*/
|
||||
declare class Relay {
|
||||
/**
|
||||
* Creates an instance of Relay.
|
||||
*
|
||||
* @class
|
||||
* @param {Libp2p} libp2p
|
||||
*/
|
||||
constructor(libp2p: Libp2p);
|
||||
_libp2p: import("..");
|
||||
_options: any;
|
||||
_autoRelay: import("./auto-relay");
|
||||
/**
|
||||
* Advertise hop relay service in the network.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_advertiseService(): Promise<void>;
|
||||
/**
|
||||
* Start Relay service.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
start(): void;
|
||||
_timeout: any;
|
||||
/**
|
||||
* Stop Relay service.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
stop(): void;
|
||||
}
|
||||
declare namespace Relay {
|
||||
export { Libp2p, RelayAdvertiseOptions, HopOptions, AutoRelayOptions };
|
||||
}
|
||||
type Libp2p = import("..");
|
||||
type RelayAdvertiseOptions = {
|
||||
bootDelay?: number | undefined;
|
||||
enabled?: boolean | undefined;
|
||||
ttl?: number | undefined;
|
||||
};
|
||||
type HopOptions = {
|
||||
enabled?: boolean | undefined;
|
||||
active?: boolean | undefined;
|
||||
};
|
||||
type AutoRelayOptions = {
|
||||
/**
|
||||
* - maximum number of relays to listen.
|
||||
*/
|
||||
maxListeners?: number | undefined;
|
||||
enabled?: boolean | undefined;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/circuit/index.d.ts.map
vendored
Normal file
1
dist/src/circuit/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/circuit/index.js"],"names":[],"mappings":";AAoBA;;;;;;;;;;;;;;;GAeG;AAEH;IACE;;;;;OAKG;IACH,oBAFW,MAAM,EAkBhB;IAfC,sBAAqB;IACrB,cAQC;IAGD,mCAA0G;IA8B5G;;;;OAIG;IACH,qBAFa,QAAQ,IAAI,CAAC,CAezB;IA3CD;;;;OAIG;IACH,SAFa,IAAI,CAWhB;IAJG,cAEC;IAIL;;;;OAIG;IACH,QAFa,IAAI,CAIhB;CAqBF"}
|
5
dist/src/circuit/listener.d.ts
vendored
Normal file
5
dist/src/circuit/listener.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare function _exports(libp2p: import('../')): Listener;
|
||||
export = _exports;
|
||||
export type Multiaddr = import("multiaddr");
|
||||
export type Listener = import("libp2p-interfaces/src/transport/types").Listener;
|
||||
//# sourceMappingURL=listener.d.ts.map
|
1
dist/src/circuit/listener.d.ts.map
vendored
Normal file
1
dist/src/circuit/listener.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/circuit/listener.js"],"names":[],"mappings":"AAciB,kCAHN,OAAO,KAAK,CAAC,GACX,QAAQ,CA+DpB"}
|
2
dist/src/circuit/multicodec.d.ts
vendored
Normal file
2
dist/src/circuit/multicodec.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export const relay: string;
|
||||
//# sourceMappingURL=multicodec.d.ts.map
|
1
dist/src/circuit/multicodec.d.ts.map
vendored
Normal file
1
dist/src/circuit/multicodec.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"multicodec.d.ts","sourceRoot":"","sources":["../../../src/circuit/multicodec.js"],"names":[],"mappings":""}
|
5
dist/src/circuit/protocol/index.d.ts
vendored
Normal file
5
dist/src/circuit/protocol/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare const _exports: {
|
||||
CircuitRelay: import('../../types').CircuitMessageProto;
|
||||
};
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/circuit/protocol/index.d.ts.map
vendored
Normal file
1
dist/src/circuit/protocol/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/circuit/protocol/index.js"],"names":[],"mappings":"wBAGW;IAAC,YAAY,EAAE,OAAO,aAAa,EAAE,mBAAmB,CAAA;CAAC"}
|
84
dist/src/circuit/transport.d.ts
vendored
Normal file
84
dist/src/circuit/transport.d.ts
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
export = Circuit;
|
||||
/**
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
||||
* @typedef {import('../types').CircuitRequest} CircuitRequest
|
||||
*/
|
||||
declare class Circuit {
|
||||
/**
|
||||
* Checks if the given value is a Transport instance.
|
||||
*
|
||||
* @param {any} other
|
||||
* @returns {other is Transport}
|
||||
*/
|
||||
static isTransport(other: any): other is Transport;
|
||||
/**
|
||||
* Creates an instance of the Circuit Transport.
|
||||
*
|
||||
* @class
|
||||
* @param {object} options
|
||||
* @param {import('../')} options.libp2p
|
||||
* @param {import('../upgrader')} options.upgrader
|
||||
*/
|
||||
constructor({ libp2p, upgrader }: {
|
||||
libp2p: import('../');
|
||||
upgrader: import('../upgrader');
|
||||
});
|
||||
_dialer: import("../dialer");
|
||||
_registrar: import("../registrar");
|
||||
_connectionManager: import("../connection-manager");
|
||||
_upgrader: import("../upgrader");
|
||||
_options: any;
|
||||
_libp2p: import("..");
|
||||
peerId: import("peer-id");
|
||||
/**
|
||||
* @param {Object} props
|
||||
* @param {Connection} props.connection
|
||||
* @param {MuxedStream} props.stream
|
||||
*/
|
||||
_onProtocol({ connection, stream }: {
|
||||
connection: Connection;
|
||||
stream: MuxedStream;
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* Dial a peer over a relay
|
||||
*
|
||||
* @param {Multiaddr} ma - the multiaddr of the peer to dial
|
||||
* @param {Object} options - dial options
|
||||
* @param {AbortSignal} [options.signal] - An optional abort signal
|
||||
* @returns {Promise<Connection>} - the connection
|
||||
*/
|
||||
dial(ma: Multiaddr, options: {
|
||||
signal: AbortSignal | undefined;
|
||||
}): Promise<Connection>;
|
||||
/**
|
||||
* Create a listener
|
||||
*
|
||||
* @param {any} options
|
||||
* @param {Function} handler
|
||||
* @returns {import('libp2p-interfaces/src/transport/types').Listener}
|
||||
*/
|
||||
createListener(options: any, handler: Function): import('libp2p-interfaces/src/transport/types').Listener;
|
||||
handler: Function | undefined;
|
||||
/**
|
||||
* Filter check for all Multiaddrs that this transport can dial on
|
||||
*
|
||||
* @param {Multiaddr[]} multiaddrs
|
||||
* @returns {Multiaddr[]}
|
||||
*/
|
||||
filter(multiaddrs: Multiaddr[]): Multiaddr[];
|
||||
get [Symbol.toStringTag](): string;
|
||||
}
|
||||
declare namespace Circuit {
|
||||
export { Multiaddr, Connection, MuxedStream, CircuitRequest };
|
||||
}
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type MuxedStream = import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
|
||||
type Multiaddr = import("multiaddr");
|
||||
type CircuitRequest = {
|
||||
type: import("../types").CircuitType;
|
||||
dstPeer: import("../types").CircuitPeer;
|
||||
srcPeer: import("../types").CircuitPeer;
|
||||
};
|
||||
//# sourceMappingURL=transport.d.ts.map
|
1
dist/src/circuit/transport.d.ts.map
vendored
Normal file
1
dist/src/circuit/transport.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/circuit/transport.js"],"names":[],"mappings":";AAsBA;;;;;GAKG;AAEH;IAiLE;;;;;OAKG;IACH,0BAHW,GAAG,sBAKb;IAxLD;;;;;;;OAOG;IACH;QAHkC,MAAM,EAA7B,OAAO,KAAK,CAAC;QACkB,QAAQ,EAAvC,OAAO,aAAa,CAAC;OAY/B;IATC,6BAA4B;IAC5B,mCAAkC;IAClC,oDAAkD;IAClD,iCAAyB;IACzB,cAAoC;IACpC,sBAAqB;IACrB,0BAA2B;IAK7B;;;;OAIG;IACH;QAH6B,UAAU,EAA5B,UAAU;QACS,MAAM,EAAzB,WAAW;sBA2DrB;IAED;;;;;;;OAOG;IACH,SALW,SAAS;QAEa,MAAM;QAC1B,QAAQ,UAAU,CAAC,CA+C/B;IAED;;;;;;OAMG;IACH,wBAJW,GAAG,sBAED,OAAO,uCAAuC,EAAE,QAAQ,CAYpE;IAHC,8BAAsB;IAKxB;;;;;OAKG;IACH,mBAHW,SAAS,EAAE,GACT,SAAS,EAAE,CAQvB;IAED,mCAEC;CAWF"}
|
2
dist/src/circuit/utils.d.ts
vendored
Normal file
2
dist/src/circuit/utils.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export function namespaceToCid(namespace: string): Promise<import("cids")>;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
1
dist/src/circuit/utils.d.ts.map
vendored
Normal file
1
dist/src/circuit/utils.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/circuit/utils.js"],"names":[],"mappings":"AAagC,0CAHrB,MAAM,GACJ,uBAAY,CAOxB"}
|
2
dist/src/config.d.ts
vendored
Normal file
2
dist/src/config.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export function validate(opts: any): any;
|
||||
//# sourceMappingURL=config.d.ts.map
|
1
dist/src/config.d.ts.map
vendored
Normal file
1
dist/src/config.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.js"],"names":[],"mappings":"AAuF0B,yCAMzB"}
|
203
dist/src/connection-manager/index.d.ts
vendored
Normal file
203
dist/src/connection-manager/index.d.ts
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
/// <reference types="node" />
|
||||
export = ConnectionManager;
|
||||
declare const ConnectionManager_base: typeof import("events").EventEmitter;
|
||||
/**
|
||||
* @typedef {import('../')} Libp2p
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} ConnectionManagerOptions
|
||||
* @property {number} [maxConnections = Infinity] - The maximum number of connections allowed.
|
||||
* @property {number} [minConnections = 0] - The minimum number of connections to avoid pruning.
|
||||
* @property {number} [maxData = Infinity] - The max data (in and out), per average interval to allow.
|
||||
* @property {number} [maxSentData = Infinity] - The max outgoing data, per average interval to allow.
|
||||
* @property {number} [maxReceivedData = Infinity] - The max incoming data, per average interval to allow.
|
||||
* @property {number} [maxEventLoopDelay = Infinity] - The upper limit the event loop can take to run.
|
||||
* @property {number} [pollInterval = 2000] - How often, in milliseconds, metrics and latency should be checked.
|
||||
* @property {number} [movingAverageInterval = 60000] - How often, in milliseconds, to compute averages.
|
||||
* @property {number} [defaultPeerValue = 1] - The value of the peer.
|
||||
* @property {boolean} [autoDial = true] - Should preemptively guarantee connections are above the low watermark.
|
||||
* @property {number} [autoDialInterval = 10000] - How often, in milliseconds, it should preemptively guarantee connections are above the low watermark.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @fires ConnectionManager#peer:connect Emitted when a new peer is connected.
|
||||
* @fires ConnectionManager#peer:disconnect Emitted when a peer is disconnected.
|
||||
*/
|
||||
declare class ConnectionManager extends ConnectionManager_base {
|
||||
/**
|
||||
* Responsible for managing known connections.
|
||||
*
|
||||
* @class
|
||||
* @param {Libp2p} libp2p
|
||||
* @param {ConnectionManagerOptions} options
|
||||
*/
|
||||
constructor(libp2p: Libp2p, options?: ConnectionManagerOptions);
|
||||
_libp2p: import("..");
|
||||
_peerId: string;
|
||||
_options: any;
|
||||
/**
|
||||
* Map of peer identifiers to their peer value for pruning connections.
|
||||
*
|
||||
* @type {Map<string, number>}
|
||||
*/
|
||||
_peerValues: Map<string, number>;
|
||||
/**
|
||||
* Map of connections per peer
|
||||
*
|
||||
* @type {Map<string, Connection[]>}
|
||||
*/
|
||||
connections: Map<string, Connection[]>;
|
||||
_started: boolean;
|
||||
_timer: any;
|
||||
_autoDialTimeout: any;
|
||||
/**
|
||||
* Checks the libp2p metrics to determine if any values have exceeded
|
||||
* the configured maximums.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _checkMetrics;
|
||||
/**
|
||||
* Proactively tries to connect to known peers stored in the PeerStore.
|
||||
* It will keep the number of connections below the upper limit and sort
|
||||
* the peers to connect based on wether we know their keys and protocols.
|
||||
*
|
||||
* @async
|
||||
* @private
|
||||
*/
|
||||
private _autoDial;
|
||||
/**
|
||||
* Get current number of open connections.
|
||||
*/
|
||||
get size(): number;
|
||||
/**
|
||||
* Starts the Connection Manager. If Metrics are not enabled on libp2p
|
||||
* only event loop and connection limits will be monitored.
|
||||
*/
|
||||
start(): void;
|
||||
_latencyMonitor: import("./latency-monitor") | undefined;
|
||||
/**
|
||||
* If the event loop is slow, maybe close a connection
|
||||
*
|
||||
* @private
|
||||
* @param {*} summary - The LatencyMonitor summary
|
||||
*/
|
||||
private _onLatencyMeasure;
|
||||
/**
|
||||
* Stops the Connection Manager
|
||||
*
|
||||
* @async
|
||||
*/
|
||||
stop(): Promise<void>;
|
||||
/**
|
||||
* Cleans up the connections
|
||||
*
|
||||
* @async
|
||||
*/
|
||||
_close(): Promise<void>;
|
||||
/**
|
||||
* Sets the value of the given peer. Peers with lower values
|
||||
* will be disconnected first.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {number} value - A number between 0 and 1
|
||||
* @returns {void}
|
||||
*/
|
||||
setPeerValue(peerId: import("peer-id"), value: number): void;
|
||||
/**
|
||||
* Tracks the incoming connection and check the connection limit
|
||||
*
|
||||
* @param {Connection} connection
|
||||
* @returns {void}
|
||||
*/
|
||||
onConnect(connection: Connection): void;
|
||||
/**
|
||||
* Removes the connection from tracking
|
||||
*
|
||||
* @param {Connection} connection
|
||||
* @returns {void}
|
||||
*/
|
||||
onDisconnect(connection: Connection): void;
|
||||
/**
|
||||
* Get a connection with a peer.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {Connection|null}
|
||||
*/
|
||||
get(peerId: import("peer-id")): Connection | null;
|
||||
/**
|
||||
* Get all open connections with a peer.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {Connection[]}
|
||||
*/
|
||||
getAll(peerId: import("peer-id")): Connection[];
|
||||
/**
|
||||
* If the `value` of `name` has exceeded its limit, maybe close a connection
|
||||
*
|
||||
* @private
|
||||
* @param {string} name - The name of the field to check limits for
|
||||
* @param {number} value - The current value of the field
|
||||
*/
|
||||
private _checkMaxLimit;
|
||||
/**
|
||||
* If we have more connections than our maximum, close a connection
|
||||
* to the lowest valued peer.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _maybeDisconnectOne;
|
||||
}
|
||||
declare namespace ConnectionManager {
|
||||
export { Libp2p, Connection, ConnectionManagerOptions };
|
||||
}
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type Libp2p = import("..");
|
||||
type ConnectionManagerOptions = {
|
||||
/**
|
||||
* - The maximum number of connections allowed.
|
||||
*/
|
||||
maxConnections?: number | undefined;
|
||||
/**
|
||||
* - The minimum number of connections to avoid pruning.
|
||||
*/
|
||||
minConnections?: number | undefined;
|
||||
/**
|
||||
* - The max data (in and out), per average interval to allow.
|
||||
*/
|
||||
maxData?: number | undefined;
|
||||
/**
|
||||
* - The max outgoing data, per average interval to allow.
|
||||
*/
|
||||
maxSentData?: number | undefined;
|
||||
/**
|
||||
* - The max incoming data, per average interval to allow.
|
||||
*/
|
||||
maxReceivedData?: number | undefined;
|
||||
/**
|
||||
* - The upper limit the event loop can take to run.
|
||||
*/
|
||||
maxEventLoopDelay?: number | undefined;
|
||||
/**
|
||||
* - How often, in milliseconds, metrics and latency should be checked.
|
||||
*/
|
||||
pollInterval?: number | undefined;
|
||||
/**
|
||||
* - How often, in milliseconds, to compute averages.
|
||||
*/
|
||||
movingAverageInterval?: number | undefined;
|
||||
/**
|
||||
* - The value of the peer.
|
||||
*/
|
||||
defaultPeerValue?: number | undefined;
|
||||
/**
|
||||
* - Should preemptively guarantee connections are above the low watermark.
|
||||
*/
|
||||
autoDial?: boolean | undefined;
|
||||
/**
|
||||
* - How often, in milliseconds, it should preemptively guarantee connections are above the low watermark.
|
||||
*/
|
||||
autoDialInterval?: number | undefined;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/connection-manager/index.d.ts.map
vendored
Normal file
1
dist/src/connection-manager/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.js"],"names":[],"mappings":";;;AAiCA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH;IACE;;;;;;OAMG;IACH,oBAHW,MAAM,YACN,wBAAwB,EAkClC;IA7BC,sBAAqB;IACrB,gBAA0C;IAE1C,cAAqF;IAOrF;;;;OAIG;IACH,aAFU,IAAI,MAAM,EAAE,MAAM,CAAC,CAED;IAE5B;;;;OAIG;IACH,aAFU,IAAI,MAAM,EAAE,UAAU,EAAE,CAAC,CAEP;IAE5B,kBAAqB;IACrB,YAAkB;IAClB,sBAA4B;IAoF9B;;;;;OAKG;IACH,sBAYC;IA8GD;;;;;;;OAOG;IACH,kBAqCC;IA5PD;;OAEG;IACH,mBAGC;IAED;;;OAGG;IACH,cAiBC;IAXC,yDAGE;IAgKJ;;;;;OAKG;IACH,0BAEC;IA9JD;;;;OAIG;IACH,sBAQC;IAED;;;;OAIG;IACH,wBAWC;IAED;;;;;;;OAOG;IACH,+CAHW,MAAM,GACJ,IAAI,CAOhB;IAsBD;;;;;OAKG;IACH,sBAHW,UAAU,GACR,IAAI,CAqBhB;IAED;;;;;OAKG;IACH,yBAHW,UAAU,GACR,IAAI,CAchB;IAED;;;;;OAKG;IACH,gCAFa,UAAU,GAAC,IAAI,CAQ3B;IAED;;;;;OAKG;IACH,mCAFa,UAAU,EAAE,CAexB;IAYD;;;;;;OAMG;IACH,uBAOC;IAiDD;;;;;OAKG;IACH,4BAiBC;CACF"}
|
134
dist/src/connection-manager/latency-monitor.d.ts
vendored
Normal file
134
dist/src/connection-manager/latency-monitor.d.ts
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
/// <reference types="node" />
|
||||
export = LatencyMonitor;
|
||||
declare const LatencyMonitor_base: typeof import("events").EventEmitter;
|
||||
/**
|
||||
* @typedef {Object} SummaryObject
|
||||
* @property {number} events How many events were called
|
||||
* @property {number} minMS What was the min time for a cb to be called
|
||||
* @property {number} maxMS What was the max time for a cb to be called
|
||||
* @property {number} avgMs What was the average time for a cb to be called
|
||||
* @property {number} lengthMs How long this interval was in ms
|
||||
*
|
||||
* @typedef {Object} LatencyMonitorOptions
|
||||
* @property {number} [latencyCheckIntervalMs=500] - How often to add a latency check event (ms)
|
||||
* @property {number} [dataEmitIntervalMs=5000] - How often to summarize latency check events. null or 0 disables event firing
|
||||
* @property {Function} [asyncTestFn] - What cb-style async function to use
|
||||
* @property {number} [latencyRandomPercentage=5] - What percent (+/-) of latencyCheckIntervalMs should we randomly use? This helps avoid alignment to other events.
|
||||
*/
|
||||
/**
|
||||
* A class to monitor latency of any async function which works in a browser or node. This works by periodically calling
|
||||
* the asyncTestFn and timing how long it takes the callback to be called. It can also periodically emit stats about this.
|
||||
* This can be disabled and stats can be pulled via setting dataEmitIntervalMs = 0.
|
||||
*
|
||||
* @extends {EventEmitter}
|
||||
*
|
||||
* The default implementation is an event loop latency monitor. This works by firing periodic events into the event loop
|
||||
* and timing how long it takes to get back.
|
||||
*
|
||||
* @example
|
||||
* const monitor = new LatencyMonitor();
|
||||
* monitor.on('data', (summary) => console.log('Event Loop Latency: %O', summary));
|
||||
*
|
||||
* @example
|
||||
* const monitor = new LatencyMonitor({latencyCheckIntervalMs: 1000, dataEmitIntervalMs: 60000, asyncTestFn:ping});
|
||||
* monitor.on('data', (summary) => console.log('Ping Pong Latency: %O', summary));
|
||||
*/
|
||||
declare class LatencyMonitor extends LatencyMonitor_base {
|
||||
/**
|
||||
* @class
|
||||
* @param {LatencyMonitorOptions} [options]
|
||||
*/
|
||||
constructor({ latencyCheckIntervalMs, dataEmitIntervalMs, asyncTestFn, latencyRandomPercentage }?: LatencyMonitorOptions | undefined);
|
||||
/**
|
||||
* Start internal timers
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _startTimers;
|
||||
_emitIntervalID: NodeJS.Timeout | undefined;
|
||||
/**
|
||||
* Stop internal timers
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _stopTimers;
|
||||
_checkLatencyID: NodeJS.Timeout | undefined;
|
||||
/**
|
||||
* Emit summary only if there were events. It might not have any events if it was forced via a page hidden/show
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _emitSummary;
|
||||
/**
|
||||
* Calling this function will end the collection period. If a timing event was already fired and somewhere in the queue,
|
||||
* it will not count for this time period
|
||||
*
|
||||
* @returns {SummaryObject}
|
||||
*/
|
||||
getSummary(): SummaryObject;
|
||||
_latencyData: {
|
||||
startTime: any;
|
||||
minMs: number;
|
||||
maxMs: number;
|
||||
events: number;
|
||||
totalMs: number;
|
||||
} | undefined;
|
||||
/**
|
||||
* Randomly calls an async fn every roughly latencyCheckIntervalMs (plus some randomness). If no async fn is found,
|
||||
* it will simply report on event loop latency.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _checkLatency;
|
||||
_initLatencyData(): {
|
||||
startTime: any;
|
||||
minMs: number;
|
||||
maxMs: number;
|
||||
events: number;
|
||||
totalMs: number;
|
||||
};
|
||||
}
|
||||
declare namespace LatencyMonitor {
|
||||
export { SummaryObject, LatencyMonitorOptions };
|
||||
}
|
||||
type SummaryObject = {
|
||||
/**
|
||||
* How many events were called
|
||||
*/
|
||||
events: number;
|
||||
/**
|
||||
* What was the min time for a cb to be called
|
||||
*/
|
||||
minMS: number;
|
||||
/**
|
||||
* What was the max time for a cb to be called
|
||||
*/
|
||||
maxMS: number;
|
||||
/**
|
||||
* What was the average time for a cb to be called
|
||||
*/
|
||||
avgMs: number;
|
||||
/**
|
||||
* How long this interval was in ms
|
||||
*/
|
||||
lengthMs: number;
|
||||
};
|
||||
type LatencyMonitorOptions = {
|
||||
/**
|
||||
* - How often to add a latency check event (ms)
|
||||
*/
|
||||
latencyCheckIntervalMs?: number | undefined;
|
||||
/**
|
||||
* - How often to summarize latency check events. null or 0 disables event firing
|
||||
*/
|
||||
dataEmitIntervalMs?: number | undefined;
|
||||
/**
|
||||
* - What cb-style async function to use
|
||||
*/
|
||||
asyncTestFn?: Function | undefined;
|
||||
/**
|
||||
* - What percent (+/-) of latencyCheckIntervalMs should we randomly use? This helps avoid alignment to other events.
|
||||
*/
|
||||
latencyRandomPercentage?: number | undefined;
|
||||
};
|
||||
//# sourceMappingURL=latency-monitor.d.ts.map
|
1
dist/src/connection-manager/latency-monitor.d.ts.map
vendored
Normal file
1
dist/src/connection-manager/latency-monitor.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"latency-monitor.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/latency-monitor.js"],"names":[],"mappings":";;;AAaA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;OAGG;IACH,sIA8DC;IAED;;;;OAIG;IACH,qBAYC;IALG,4CAAsF;IAO1F;;;;OAIG;IACH,oBASC;IANG,4CAAgC;IAQpC;;;;OAIG;IACH,qBAKC;IAED;;;;;OAKG;IACH,cAFa,aAAa,CAkBzB;IAJC;;;;;;kBAA2C;IAM7C;;;;;OAKG;IACH,sBAgDC;IAED;;;;;;MAQC;CACF;;;;;;;;YA5Oa,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;cACN,MAAM"}
|
62
dist/src/connection-manager/visibility-change-emitter.d.ts
vendored
Normal file
62
dist/src/connection-manager/visibility-change-emitter.d.ts
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/// <reference types="node" />
|
||||
export = VisibilityChangeEmitter;
|
||||
declare const VisibilityChangeEmitter_base: typeof import("events").EventEmitter;
|
||||
/**
|
||||
* Listen to page visibility change events (i.e. when the page is focused / blurred) by an event emitter.
|
||||
*
|
||||
* Warning: This does not work on all browsers, but should work on all modern browsers
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const myVisibilityEmitter = new VisibilityChangeEmitter();
|
||||
*
|
||||
* myVisibilityEmitter.on('visibilityChange', (pageInFocus) => {
|
||||
* if ( pageInFocus ){
|
||||
* // Page is in focus
|
||||
* console.log('In focus');
|
||||
* }
|
||||
* else {
|
||||
* // Page is blurred
|
||||
* console.log('Out of focus');
|
||||
* }
|
||||
* });
|
||||
* // To access the visibility state directly, call:
|
||||
* console.log('Am I focused now? ' + myVisibilityEmitter.isVisible());
|
||||
*/
|
||||
declare class VisibilityChangeEmitter extends VisibilityChangeEmitter_base {
|
||||
/**
|
||||
* document.hidden and document.visibilityChange are the two variables we need to check for;
|
||||
* Since these variables are named differently in different browsers, this function sets
|
||||
* the appropriate name based on the browser being used. Once executed, tha actual names of
|
||||
* document.hidden and document.visibilityChange are found in this._hidden and this._visibilityChange
|
||||
* respectively
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _initializeVisibilityVarNames;
|
||||
_hidden: string | undefined;
|
||||
_visibilityChange: string | undefined;
|
||||
/**
|
||||
* Adds an event listener on the document that listens to changes in document.visibilityChange
|
||||
* (or whatever name by which the visibilityChange variable is known in the browser)
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _addVisibilityChangeListener;
|
||||
/**
|
||||
* The function returns ```true``` if the page is visible or ```false``` if the page is not visible and
|
||||
* ```undefined``` if the page visibility API is not supported by the browser.
|
||||
*
|
||||
* @returns {boolean | void} whether the page is now visible or not (undefined is unknown)
|
||||
*/
|
||||
isVisible(): boolean | void;
|
||||
/**
|
||||
* The function that is called when document.visibilityChange has changed
|
||||
* It emits an event called visibilityChange and sends the value of document.hidden as a
|
||||
* parameter
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _handleVisibilityChange;
|
||||
}
|
||||
//# sourceMappingURL=visibility-change-emitter.d.ts.map
|
1
dist/src/connection-manager/visibility-change-emitter.d.ts.map
vendored
Normal file
1
dist/src/connection-manager/visibility-change-emitter.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"visibility-change-emitter.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/visibility-change-emitter.js"],"names":[],"mappings":";;;AAYA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAgBE;;;;;;;;OAQG;IACH,sCAkBC;IAFC,4BAAqB;IACrB,sCAAyC;IAG3C;;;;;OAKG;IACH,qCAQC;IAED;;;;;OAKG;IACH,aAFa,OAAO,GAAG,IAAI,CAQ1B;IAED;;;;;;OAMG;IACH,gCAKC;CACF"}
|
10
dist/src/constants.d.ts
vendored
Normal file
10
dist/src/constants.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export const DIAL_TIMEOUT: number;
|
||||
export const MAX_PARALLEL_DIALS: number;
|
||||
export const MAX_PER_PEER_DIALS: number;
|
||||
export namespace METRICS {
|
||||
const computeThrottleMaxQueueSize: number;
|
||||
const computeThrottleTimeout: number;
|
||||
const movingAverageIntervals: number[];
|
||||
const maxOldPeersRetention: number;
|
||||
}
|
||||
//# sourceMappingURL=constants.d.ts.map
|
1
dist/src/constants.d.ts.map
vendored
Normal file
1
dist/src/constants.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.js"],"names":[],"mappings":""}
|
93
dist/src/content-routing.d.ts
vendored
Normal file
93
dist/src/content-routing.d.ts
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
export = ContentRouting;
|
||||
/**
|
||||
* @typedef {import('peer-id')} PeerId
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
* @typedef {import('cids')} CID
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} GetData
|
||||
* @property {PeerId} from
|
||||
* @property {Uint8Array} val
|
||||
*/
|
||||
declare class ContentRouting {
|
||||
/**
|
||||
* @class
|
||||
* @param {import('./')} libp2p
|
||||
*/
|
||||
constructor(libp2p: import('./'));
|
||||
libp2p: import(".");
|
||||
routers: any;
|
||||
dht: any;
|
||||
/**
|
||||
* Iterates over all content routers in series to find providers of the given key.
|
||||
* Once a content router succeeds, iteration will stop.
|
||||
*
|
||||
* @param {CID} key - The CID key of the content to find
|
||||
* @param {object} [options]
|
||||
* @param {number} [options.timeout] - How long the query should run
|
||||
* @param {number} [options.maxNumProviders] - maximum number of providers to find
|
||||
* @returns {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>}
|
||||
*/
|
||||
findProviders(key: CID, options?: {
|
||||
timeout?: number | undefined;
|
||||
maxNumProviders?: number | undefined;
|
||||
} | undefined): AsyncIterable<{
|
||||
id: PeerId;
|
||||
multiaddrs: Multiaddr[];
|
||||
}>;
|
||||
/**
|
||||
* Iterates over all content routers in parallel to notify it is
|
||||
* a provider of the given key.
|
||||
*
|
||||
* @param {CID} key - The CID key of the content to find
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
provide(key: CID): Promise<void>;
|
||||
/**
|
||||
* Store the given key/value pair in the DHT.
|
||||
*
|
||||
* @param {Uint8Array} key
|
||||
* @param {Uint8Array} value
|
||||
* @param {Object} [options] - put options
|
||||
* @param {number} [options.minPeers] - minimum number of peers required to successfully put
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
put(key: Uint8Array, value: Uint8Array, options?: {
|
||||
minPeers?: number | undefined;
|
||||
} | undefined): Promise<void>;
|
||||
/**
|
||||
* Get the value to the given key.
|
||||
* Times out after 1 minute by default.
|
||||
*
|
||||
* @param {Uint8Array} key
|
||||
* @param {Object} [options] - get options
|
||||
* @param {number} [options.timeout] - optional timeout (default: 60000)
|
||||
* @returns {Promise<GetData>}
|
||||
*/
|
||||
get(key: Uint8Array, options?: {
|
||||
timeout?: number | undefined;
|
||||
} | undefined): Promise<GetData>;
|
||||
/**
|
||||
* Get the `n` values to the given key without sorting.
|
||||
*
|
||||
* @param {Uint8Array} key
|
||||
* @param {number} nVals
|
||||
* @param {Object} [options] - get options
|
||||
* @param {number} [options.timeout] - optional timeout (default: 60000)
|
||||
* @returns {Promise<GetData[]>}
|
||||
*/
|
||||
getMany(key: Uint8Array, nVals: number, options?: {
|
||||
timeout?: number | undefined;
|
||||
} | undefined): Promise<GetData[]>;
|
||||
}
|
||||
declare namespace ContentRouting {
|
||||
export { PeerId, Multiaddr, CID, GetData };
|
||||
}
|
||||
type CID = import("cids");
|
||||
type PeerId = import("peer-id");
|
||||
type Multiaddr = import("multiaddr");
|
||||
type GetData = {
|
||||
from: PeerId;
|
||||
val: Uint8Array;
|
||||
};
|
||||
//# sourceMappingURL=content-routing.d.ts.map
|
1
dist/src/content-routing.d.ts.map
vendored
Normal file
1
dist/src/content-routing.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"content-routing.d.ts","sourceRoot":"","sources":["../../src/content-routing.js"],"names":[],"mappings":";AAQA;;;;GAIG;AAEH;;;;GAIG;AAEH;IACE;;;OAGG;IACH,oBAFW,OAAO,IAAI,CAAC,EAWtB;IARC,oBAAoB;IACpB,aAAmD;IACnD,SAAsB;IAQxB;;;;;;;;;OASG;IACH,mBANW,GAAG;;;oBAID,cAAc;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAqBlE;IAED;;;;;;OAMG;IACH,aAHW,GAAG,GACD,QAAQ,IAAI,CAAC,CAQzB;IAED;;;;;;;;OAQG;IACH,SANW,UAAU,SACV,UAAU;;oBAGR,QAAQ,IAAI,CAAC,CAQzB;IAED;;;;;;;;OAQG;IACH,SALW,UAAU;;oBAGR,QAAQ,OAAO,CAAC,CAQ5B;IAED;;;;;;;;OAQG;IACH,aANW,UAAU,SACV,MAAM;;oBAGJ,QAAQ,OAAO,EAAE,CAAC,CAQ9B;CACF;;;;;;;;UApHa,MAAM;SACN,UAAU"}
|
55
dist/src/dialer/dial-request.d.ts
vendored
Normal file
55
dist/src/dialer/dial-request.d.ts
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
export = DialRequest;
|
||||
/**
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('./')} Dialer
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} DialOptions
|
||||
* @property {AbortSignal} signal
|
||||
*
|
||||
* @typedef {Object} DialRequestOptions
|
||||
* @property {Multiaddr[]} addrs
|
||||
* @property {(m: Multiaddr, options: DialOptions) => Promise<Connection>} dialAction
|
||||
* @property {Dialer} dialer
|
||||
*/
|
||||
declare class DialRequest {
|
||||
/**
|
||||
* Manages running the `dialAction` on multiple provided `addrs` in parallel
|
||||
* up to a maximum determined by the number of tokens returned
|
||||
* from `dialer.getTokens`. Once a DialRequest is created, it can be
|
||||
* started using `DialRequest.run(options)`. Once a single dial has succeeded,
|
||||
* all other dials in the request will be cancelled.
|
||||
*
|
||||
* @class
|
||||
* @param {DialRequestOptions} options
|
||||
*/
|
||||
constructor({ addrs, dialAction, dialer }: DialRequestOptions);
|
||||
addrs: import("multiaddr")[];
|
||||
dialer: import(".");
|
||||
dialAction: (m: Multiaddr, options: DialOptions) => Promise<Connection>;
|
||||
/**
|
||||
* @async
|
||||
* @param {object} [options]
|
||||
* @param {AbortSignal} [options.signal] - An AbortController signal
|
||||
* @returns {Promise<Connection>}
|
||||
*/
|
||||
run(options?: {
|
||||
signal?: AbortSignal | undefined;
|
||||
} | undefined): Promise<Connection>;
|
||||
}
|
||||
declare namespace DialRequest {
|
||||
export { Connection, Dialer, Multiaddr, DialOptions, DialRequestOptions };
|
||||
}
|
||||
type Multiaddr = import("multiaddr");
|
||||
type DialOptions = {
|
||||
signal: AbortSignal;
|
||||
};
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type DialRequestOptions = {
|
||||
addrs: Multiaddr[];
|
||||
dialAction: (m: Multiaddr, options: DialOptions) => Promise<Connection>;
|
||||
dialer: Dialer;
|
||||
};
|
||||
type Dialer = import(".");
|
||||
//# sourceMappingURL=dial-request.d.ts.map
|
1
dist/src/dialer/dial-request.d.ts.map
vendored
Normal file
1
dist/src/dialer/dial-request.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"dial-request.d.ts","sourceRoot":"","sources":["../../../src/dialer/dial-request.js"],"names":[],"mappings":";AAQA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;IACE;;;;;;;;;OASG;IACH,2CAFW,kBAAkB,EAU5B;IAHC,6BAAkB;IAClB,oBAAoB;IACpB,gBAtBc,SAAS,WAAW,WAAW,KAAK,QAAQ,UAAU,CAAC,CAsBzC;IAG9B;;;;;OAKG;IACH;;oBAFa,QAAQ,UAAU,CAAC,CAuC/B;CACF;;;;;;YAzEa,WAAW;;;;WAGX,SAAS,EAAE;oBACP,SAAS,WAAW,WAAW,KAAK,QAAQ,UAAU,CAAC;YAC3D,MAAM"}
|
157
dist/src/dialer/index.d.ts
vendored
Normal file
157
dist/src/dialer/index.d.ts
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
export = Dialer;
|
||||
/**
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
* @typedef {import('peer-id')} PeerId
|
||||
* @typedef {import('../peer-store')} PeerStore
|
||||
* @typedef {import('../peer-store/address-book').Address} Address
|
||||
* @typedef {import('../transport-manager')} TransportManager
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} DialerProperties
|
||||
* @property {PeerStore} peerStore
|
||||
* @property {TransportManager} transportManager
|
||||
*
|
||||
* @typedef {(addr:Multiaddr) => Promise<string[]>} Resolver
|
||||
*
|
||||
* @typedef {Object} DialerOptions
|
||||
* @property {(addresses: Address[]) => Address[]} [options.addressSorter = publicAddressesFirst] - Sort the known addresses of a peer before trying to dial.
|
||||
* @property {number} [concurrency = MAX_PARALLEL_DIALS] - Number of max concurrent dials.
|
||||
* @property {number} [perPeerLimit = MAX_PER_PEER_DIALS] - Number of max concurrent dials per peer.
|
||||
* @property {number} [timeout = DIAL_TIMEOUT] - How long a dial attempt is allowed to take.
|
||||
* @property {Record<string, Resolver>} [resolvers = {}] - multiaddr resolvers to use when dialing
|
||||
*
|
||||
* @typedef DialTarget
|
||||
* @property {string} id
|
||||
* @property {Multiaddr[]} addrs
|
||||
*
|
||||
* @typedef PendingDial
|
||||
* @property {DialRequest} dialRequest
|
||||
* @property {TimeoutController} controller
|
||||
* @property {Promise} promise
|
||||
* @property {function():void} destroy
|
||||
*/
|
||||
declare class Dialer {
|
||||
/**
|
||||
* @class
|
||||
* @param {DialerProperties & DialerOptions} options
|
||||
*/
|
||||
constructor({ transportManager, peerStore, addressSorter, concurrency, timeout, perPeerLimit, resolvers }: DialerProperties & DialerOptions);
|
||||
transportManager: import("../transport-manager");
|
||||
peerStore: import("../peer-store");
|
||||
addressSorter: (addresses: Address[]) => Address[];
|
||||
concurrency: number;
|
||||
timeout: number;
|
||||
perPeerLimit: number;
|
||||
tokens: number[];
|
||||
_pendingDials: Map<any, any>;
|
||||
/**
|
||||
* Clears any pending dials
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Connects to a given `peer` by dialing all of its known addresses.
|
||||
* The dial to the first address that is successfully able to upgrade a connection
|
||||
* will be used.
|
||||
*
|
||||
* @param {PeerId|Multiaddr|string} peer - The peer to dial
|
||||
* @param {object} [options]
|
||||
* @param {AbortSignal} [options.signal] - An AbortController signal
|
||||
* @returns {Promise<Connection>}
|
||||
*/
|
||||
connectToPeer(peer: PeerId | Multiaddr | string, options?: {
|
||||
signal?: AbortSignal | undefined;
|
||||
} | undefined): Promise<Connection>;
|
||||
/**
|
||||
* Creates a DialTarget. The DialTarget is used to create and track
|
||||
* the DialRequest to a given peer.
|
||||
* If a multiaddr is received it should be the first address attempted.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId|Multiaddr|string} peer - A PeerId or Multiaddr
|
||||
* @returns {Promise<DialTarget>}
|
||||
*/
|
||||
private _createDialTarget;
|
||||
/**
|
||||
* Creates a PendingDial that wraps the underlying DialRequest
|
||||
*
|
||||
* @private
|
||||
* @param {DialTarget} dialTarget
|
||||
* @param {object} [options]
|
||||
* @param {AbortSignal} [options.signal] - An AbortController signal
|
||||
* @returns {PendingDial}
|
||||
*/
|
||||
private _createPendingDial;
|
||||
getTokens(num: any): number[];
|
||||
releaseToken(token: any): void;
|
||||
/**
|
||||
* Resolve multiaddr recursively.
|
||||
*
|
||||
* @param {Multiaddr} ma
|
||||
* @returns {Promise<Multiaddr[]>}
|
||||
*/
|
||||
_resolve(ma: Multiaddr): Promise<Multiaddr[]>;
|
||||
/**
|
||||
* Resolve a given multiaddr. If this fails, an empty array will be returned
|
||||
*
|
||||
* @param {Multiaddr} ma
|
||||
* @returns {Promise<Multiaddr[]>}
|
||||
*/
|
||||
_resolveRecord(ma: Multiaddr): Promise<Multiaddr[]>;
|
||||
}
|
||||
declare namespace Dialer {
|
||||
export { Connection, Multiaddr, PeerId, PeerStore, Address, TransportManager, DialerProperties, Resolver, DialerOptions, DialTarget, PendingDial };
|
||||
}
|
||||
type Address = {
|
||||
/**
|
||||
* peer multiaddr.
|
||||
*/
|
||||
multiaddr: import("multiaddr");
|
||||
/**
|
||||
* obtained from a signed peer record.
|
||||
*/
|
||||
isCertified: boolean;
|
||||
};
|
||||
type PeerId = import("peer-id");
|
||||
type Multiaddr = import("multiaddr");
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type DialerProperties = {
|
||||
peerStore: PeerStore;
|
||||
transportManager: TransportManager;
|
||||
};
|
||||
type DialerOptions = {
|
||||
/**
|
||||
* - Sort the known addresses of a peer before trying to dial.
|
||||
*/
|
||||
addressSorter?: ((addresses: Address[]) => Address[]) | undefined;
|
||||
/**
|
||||
* - Number of max concurrent dials.
|
||||
*/
|
||||
concurrency?: number | undefined;
|
||||
/**
|
||||
* - Number of max concurrent dials per peer.
|
||||
*/
|
||||
perPeerLimit?: number | undefined;
|
||||
/**
|
||||
* - How long a dial attempt is allowed to take.
|
||||
*/
|
||||
timeout?: number | undefined;
|
||||
/**
|
||||
* - multiaddr resolvers to use when dialing
|
||||
*/
|
||||
resolvers?: Record<string, (addr: Multiaddr) => Promise<string[]>> | undefined;
|
||||
};
|
||||
type PeerStore = import("../peer-store");
|
||||
type TransportManager = import("../transport-manager");
|
||||
type Resolver = (addr: Multiaddr) => Promise<string[]>;
|
||||
type DialTarget = {
|
||||
id: string;
|
||||
addrs: Multiaddr[];
|
||||
};
|
||||
type PendingDial = {
|
||||
dialRequest: import("./dial-request");
|
||||
controller: any;
|
||||
promise: Promise<any>;
|
||||
destroy: () => void;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/dialer/index.d.ts.map
vendored
Normal file
1
dist/src/dialer/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dialer/index.js"],"names":[],"mappings":";AAsBA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;IACE;;;OAGG;IACH,2GAFW,gBAAgB,GAAG,aAAa,EAuB1C;IAZC,iDAAwC;IACxC,mCAA0B;IAC1B,2BAjCsB,OAAO,EAAE,KAAK,OAAO,EAAE,CAiCX;IAClC,oBAA8B;IAC9B,gBAAsB;IACtB,qBAAgC;IAChC,iBAAkE;IAClE,6BAA8B;IAOhC;;OAEG;IACH,gBASC;IAED;;;;;;;;;OASG;IACH,oBALW,MAAM,GAAC,SAAS,GAAC,MAAM;;oBAGrB,QAAQ,UAAU,CAAC,CAwB/B;IAED;;;;;;;;OAQG;IACH,0BA0BC;IAED;;;;;;;;OAQG;IACH,2BA6BC;IAED,8BAKC;IAED,+BAKC;IAED;;;;;OAKG;IACH,aAHW,SAAS,GACP,QAAQ,SAAS,EAAE,CAAC,CAwBhC;IAED;;;;;OAKG;IACH,mBAHW,SAAS,GACP,QAAQ,SAAS,EAAE,CAAC,CAWhC;CACF;;;;;;;;;;;;;;;;;;eA5Oa,SAAS;sBACT,gBAAgB;;;;;;iCAKJ,OAAO,EAAE,KAAK,OAAO,EAAE;;;;;;;;;;;;;;;;sCAH9B,SAAS,KAAK,QAAQ,MAAM,EAAE,CAAC;;;;uBAA/B,SAAS,KAAK,QAAQ,MAAM,EAAE,CAAC;;QAUpC,MAAM;WACN,SAAS,EAAE;;;;;;mBAMA,IAAI"}
|
35
dist/src/errors.d.ts
vendored
Normal file
35
dist/src/errors.d.ts
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
export namespace messages {
|
||||
const NOT_STARTED_YET: string;
|
||||
const DHT_DISABLED: string;
|
||||
const CONN_ENCRYPTION_REQUIRED: string;
|
||||
}
|
||||
export namespace codes {
|
||||
const DHT_DISABLED_1: string;
|
||||
export { DHT_DISABLED_1 as DHT_DISABLED };
|
||||
export const PUBSUB_NOT_STARTED: string;
|
||||
export const DHT_NOT_STARTED: string;
|
||||
const CONN_ENCRYPTION_REQUIRED_1: string;
|
||||
export { CONN_ENCRYPTION_REQUIRED_1 as CONN_ENCRYPTION_REQUIRED };
|
||||
export const ERR_CONNECTION_ENDED: string;
|
||||
export const ERR_CONNECTION_FAILED: string;
|
||||
export const ERR_NODE_NOT_STARTED: string;
|
||||
export const ERR_ALREADY_ABORTED: string;
|
||||
export const ERR_NO_VALID_ADDRESSES: string;
|
||||
export const ERR_DIALED_SELF: string;
|
||||
export const ERR_DISCOVERED_SELF: string;
|
||||
export const ERR_DUPLICATE_TRANSPORT: string;
|
||||
export const ERR_ENCRYPTION_FAILED: string;
|
||||
export const ERR_HOP_REQUEST_FAILED: string;
|
||||
export const ERR_INVALID_KEY: string;
|
||||
export const ERR_INVALID_MESSAGE: string;
|
||||
export const ERR_INVALID_PARAMETERS: string;
|
||||
export const ERR_INVALID_PEER: string;
|
||||
export const ERR_MUXER_UNAVAILABLE: string;
|
||||
export const ERR_TIMEOUT: string;
|
||||
export const ERR_TRANSPORT_UNAVAILABLE: string;
|
||||
export const ERR_TRANSPORT_DIAL_FAILED: string;
|
||||
export const ERR_UNSUPPORTED_PROTOCOL: string;
|
||||
export const ERR_INVALID_MULTIADDR: string;
|
||||
export const ERR_SIGNATURE_NOT_VALID: string;
|
||||
}
|
||||
//# sourceMappingURL=errors.d.ts.map
|
1
dist/src/errors.d.ts.map
vendored
Normal file
1
dist/src/errors.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.js"],"names":[],"mappings":""}
|
20
dist/src/get-peer.d.ts
vendored
Normal file
20
dist/src/get-peer.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
export = getPeer;
|
||||
/**
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
*/
|
||||
/**
|
||||
* Converts the given `peer` to a `Peer` object.
|
||||
* If a multiaddr is received, the addressBook is updated.
|
||||
*
|
||||
* @param {PeerId|Multiaddr|string} peer
|
||||
* @returns {{ id: PeerId, multiaddrs: Multiaddr[]|undefined }}
|
||||
*/
|
||||
declare function getPeer(peer: import("peer-id") | Multiaddr | string): {
|
||||
id: import("peer-id");
|
||||
multiaddrs: Multiaddr[] | undefined;
|
||||
};
|
||||
declare namespace getPeer {
|
||||
export { Multiaddr };
|
||||
}
|
||||
type Multiaddr = import("multiaddr");
|
||||
//# sourceMappingURL=get-peer.d.ts.map
|
1
dist/src/get-peer.d.ts.map
vendored
Normal file
1
dist/src/get-peer.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-peer.d.ts","sourceRoot":"","sources":["../../src/get-peer.js"],"names":[],"mappings":";AAQA;;GAEG;AAEH;;;;;;GAMG;AACH,+BAHW,oBAAO,SAAS,GAAC,MAAM,GACrB;IAAE,EAAE,oBAAS;IAAC,UAAU,EAAE,SAAS,EAAE,GAAC,SAAS,CAAA;CAAE,CAwB7D"}
|
5
dist/src/identify/consts.d.ts
vendored
Normal file
5
dist/src/identify/consts.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export var PROTOCOL_VERSION: string;
|
||||
export var AGENT_VERSION: string;
|
||||
export var MULTICODEC_IDENTIFY: string;
|
||||
export var MULTICODEC_IDENTIFY_PUSH: string;
|
||||
//# sourceMappingURL=consts.d.ts.map
|
1
dist/src/identify/consts.d.ts.map
vendored
Normal file
1
dist/src/identify/consts.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/identify/consts.js"],"names":[],"mappings":""}
|
98
dist/src/identify/index.d.ts
vendored
Normal file
98
dist/src/identify/index.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
export = IdentifyService;
|
||||
/**
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
||||
*/
|
||||
declare class IdentifyService {
|
||||
/**
|
||||
* Takes the `addr` and converts it to a Multiaddr if possible
|
||||
*
|
||||
* @param {Uint8Array | string} addr
|
||||
* @returns {multiaddr|null}
|
||||
*/
|
||||
static getCleanMultiaddr(addr: Uint8Array | string): import("multiaddr") | null;
|
||||
/**
|
||||
* @class
|
||||
* @param {Object} options
|
||||
* @param {import('../')} options.libp2p
|
||||
*/
|
||||
constructor({ libp2p }: {
|
||||
libp2p: import('../');
|
||||
});
|
||||
_libp2p: import("..");
|
||||
peerStore: import("../peer-store");
|
||||
connectionManager: import("../connection-manager");
|
||||
peerId: import("peer-id");
|
||||
/**
|
||||
* A handler to register with Libp2p to process identify messages.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {Connection} options.connection
|
||||
* @param {MuxedStream} options.stream
|
||||
* @param {string} options.protocol
|
||||
* @returns {Promise<void>|undefined}
|
||||
*/
|
||||
handleMessage({ connection, stream, protocol }: {
|
||||
connection: Connection;
|
||||
stream: MuxedStream;
|
||||
protocol: string;
|
||||
}): Promise<void> | undefined;
|
||||
_host: any;
|
||||
/**
|
||||
* Send an Identify Push update to the list of connections
|
||||
*
|
||||
* @param {Connection[]} connections
|
||||
* @returns {Promise<void[]>}
|
||||
*/
|
||||
push(connections: Connection[]): Promise<void[]>;
|
||||
/**
|
||||
* Calls `push` for all peers in the `peerStore` that are connected
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
pushToPeerStore(): void;
|
||||
/**
|
||||
* Requests the `Identify` message from peer associated with the given `connection`.
|
||||
* If the identified peer does not match the `PeerId` associated with the connection,
|
||||
* an error will be thrown.
|
||||
*
|
||||
* @async
|
||||
* @param {Connection} connection
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
identify(connection: Connection): Promise<void>;
|
||||
/**
|
||||
* Sends the `Identify` response with the Signed Peer Record
|
||||
* to the requesting peer over the given `connection`
|
||||
*
|
||||
* @private
|
||||
* @param {Object} options
|
||||
* @param {MuxedStream} options.stream
|
||||
* @param {Connection} options.connection
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private _handleIdentify;
|
||||
/**
|
||||
* Reads the Identify Push message from the given `connection`
|
||||
*
|
||||
* @private
|
||||
* @param {object} options
|
||||
* @param {MuxedStream} options.stream
|
||||
* @param {Connection} options.connection
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private _handlePush;
|
||||
}
|
||||
declare namespace IdentifyService {
|
||||
export { multicodecs, Message as Messsage, Connection, MuxedStream };
|
||||
}
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type MuxedStream = import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
|
||||
declare namespace multicodecs {
|
||||
export { MULTICODEC_IDENTIFY as IDENTIFY };
|
||||
export { MULTICODEC_IDENTIFY_PUSH as IDENTIFY_PUSH };
|
||||
}
|
||||
declare const Message: any;
|
||||
declare const MULTICODEC_IDENTIFY: string;
|
||||
declare const MULTICODEC_IDENTIFY_PUSH: string;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/identify/index.d.ts.map
vendored
Normal file
1
dist/src/identify/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identify/index.js"],"names":[],"mappings":";AA+BA;;;GAGG;AAEH;IAwRE;;;;;OAKG;IACH,+BAHW,UAAU,GAAG,MAAM,GACjB,sBAAU,IAAI,CAW1B;IAtSD;;;;OAIG;IACH;QAFkC,MAAM,EAA7B,OAAO,KAAK,CAAC;OAqCvB;IAlCC,sBAAqB;IACrB,mCAAiC;IACjC,mDAAiD;IACjD,0BAA2B;IAiK7B;;;;;;;;OAQG;IACH;QAL+B,UAAU,EAA9B,UAAU;QACW,MAAM,EAA3B,WAAW;QACK,QAAQ,EAAxB,MAAM;QACJ,QAAQ,IAAI,CAAC,GAAC,SAAS,CAWnC;IA9KC,WAIC;IAwBH;;;;;OAKG;IACH,kBAHW,UAAU,EAAE,GACV,QAAQ,IAAI,EAAE,CAAC,CA4B3B;IAED;;;;OAIG;IACH,mBAFa,IAAI,CAiBhB;IAED;;;;;;;;OAQG;IACH,qBAHW,UAAU,GACR,QAAQ,IAAI,CAAC,CA+DzB;IAsBD;;;;;;;;;OASG;IACH,wBA6BC;IAED;;;;;;;;OAQG;IACH,oBAqCC;CAkBF;;;;;;;;;;AA3TD,2BAAoC"}
|
3
dist/src/identify/message.d.ts
vendored
Normal file
3
dist/src/identify/message.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=message.d.ts.map
|
1
dist/src/identify/message.d.ts.map
vendored
Normal file
1
dist/src/identify/message.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/identify/message.js"],"names":[],"mappings":""}
|
288
dist/src/index.d.ts
vendored
Normal file
288
dist/src/index.d.ts
vendored
Normal file
@ -0,0 +1,288 @@
|
||||
/// <reference types="node" />
|
||||
export = Libp2p;
|
||||
declare const Libp2p_base: typeof import("events").EventEmitter;
|
||||
/**
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
||||
* @typedef {import('libp2p-interfaces/src/transport/types').TransportFactory} TransportFactory
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxerFactory} MuxerFactory
|
||||
* @typedef {import('libp2p-interfaces/src/crypto/types').Crypto} Crypto
|
||||
* @typedef {import('libp2p-interfaces/src/pubsub')} Pubsub
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} PeerStoreOptions
|
||||
* @property {boolean} persistence
|
||||
*
|
||||
* @typedef {Object} PeerDiscoveryOptions
|
||||
* @property {boolean} autoDial
|
||||
*
|
||||
* @typedef {Object} RelayOptions
|
||||
* @property {boolean} enabled
|
||||
* @property {import('./circuit').RelayAdvertiseOptions} advertise
|
||||
* @property {import('./circuit').HopOptions} hop
|
||||
* @property {import('./circuit').AutoRelayOptions} autoRelay
|
||||
*
|
||||
* @typedef {Object} Libp2pConfig
|
||||
* @property {Object} [dht] dht module options
|
||||
* @property {PeerDiscoveryOptions} [peerDiscovery]
|
||||
* @property {Pubsub} [pubsub] pubsub module options
|
||||
* @property {RelayOptions} [relay]
|
||||
* @property {Record<string, Object>} [transport] transport options indexed by transport key
|
||||
*
|
||||
* @typedef {Object} Libp2pModules
|
||||
* @property {TransportFactory[]} transport
|
||||
* @property {MuxerFactory[]} streamMuxer
|
||||
* @property {Crypto[]} connEncryption
|
||||
*
|
||||
* @typedef {Object} Libp2pOptions
|
||||
* @property {Libp2pModules} modules libp2p modules to use
|
||||
* @property {import('./address-manager').AddressManagerOptions} [addresses]
|
||||
* @property {import('./connection-manager').ConnectionManagerOptions} [connectionManager]
|
||||
* @property {import('./dialer').DialerOptions} [dialer]
|
||||
* @property {import('./metrics').MetricsOptions} [metrics]
|
||||
* @property {Object} [keychain]
|
||||
* @property {import('./transport-manager').TransportManagerOptions} [transportManager]
|
||||
* @property {PeerStoreOptions & import('./peer-store/persistent').PersistentPeerStoreOptions} [peerStore]
|
||||
* @property {Libp2pConfig} [config]
|
||||
* @property {PeerId} peerId
|
||||
*
|
||||
* @typedef {Object} CreateOptions
|
||||
* @property {PeerId} peerId
|
||||
*
|
||||
* @extends {EventEmitter}
|
||||
* @fires Libp2p#error Emitted when an error occurs
|
||||
* @fires Libp2p#peer:discovery Emitted when a peer is discovered
|
||||
*/
|
||||
declare class Libp2p extends Libp2p_base {
|
||||
/**
|
||||
* Like `new Libp2p(options)` except it will create a `PeerId`
|
||||
* instance if one is not provided in options.
|
||||
*
|
||||
* @param {Libp2pOptions & CreateOptions} options - Libp2p configuration options
|
||||
* @returns {Promise<Libp2p>}
|
||||
*/
|
||||
static create(options: Libp2pOptions & CreateOptions): Promise<Libp2p>;
|
||||
/**
|
||||
* Libp2p node.
|
||||
*
|
||||
* @class
|
||||
* @param {Libp2pOptions} _options
|
||||
*/
|
||||
constructor(_options: Libp2pOptions);
|
||||
_options: any;
|
||||
/** @type {PeerId} */
|
||||
peerId: import("peer-id");
|
||||
datastore: any;
|
||||
peerStore: import("./peer-store");
|
||||
addresses: any;
|
||||
addressManager: import("./address-manager");
|
||||
_modules: any;
|
||||
_config: any;
|
||||
_transport: any[];
|
||||
_discovery: Map<any, any>;
|
||||
connectionManager: import("./connection-manager");
|
||||
metrics: import("./metrics") | undefined;
|
||||
keychain: import("./keychain") | undefined;
|
||||
upgrader: import("./upgrader");
|
||||
transportManager: import("./transport-manager");
|
||||
registrar: import("./registrar");
|
||||
/**
|
||||
* Registers the `handler` for each protocol
|
||||
*
|
||||
* @param {string[]|string} protocols
|
||||
* @param {({ connection: Connection, stream: MuxedStream, protocol: string }) => void} handler
|
||||
*/
|
||||
handle(protocols: string[] | string, handler: ({ connection: Connection, stream: MuxedStream, protocol: string }: {
|
||||
connection: any;
|
||||
stream: any;
|
||||
protocol: any;
|
||||
}) => void): void;
|
||||
dialer: import("./dialer");
|
||||
relay: import("./circuit") | undefined;
|
||||
identifyService: import("./identify") | undefined;
|
||||
_dht: any;
|
||||
/** @type {Pubsub} */
|
||||
pubsub: import("libp2p-interfaces/src/pubsub");
|
||||
peerRouting: import("./peer-routing");
|
||||
contentRouting: import("./content-routing");
|
||||
/**
|
||||
* Called whenever peer discovery services emit `peer` events.
|
||||
* Known peers may be emitted.
|
||||
*
|
||||
* @private
|
||||
* @param {{ id: PeerId, multiaddrs: Multiaddr[], protocols: string[] }} peer
|
||||
*/
|
||||
private _onDiscoveryPeer;
|
||||
/**
|
||||
* Starts the libp2p node and all its subsystems
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
start(): Promise<void>;
|
||||
/**
|
||||
* Stop the libp2p node by closing its listeners and open connections
|
||||
*
|
||||
* @async
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
stop(): Promise<void>;
|
||||
_isStarted: boolean | undefined;
|
||||
/**
|
||||
* Load keychain keys from the datastore.
|
||||
* Imports the private key as 'self', if needed.
|
||||
*
|
||||
* @async
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
loadKeychain(): Promise<void>;
|
||||
isStarted(): boolean | undefined;
|
||||
/**
|
||||
* Gets a Map of the current connections. The keys are the stringified
|
||||
* `PeerId` of the peer. The value is an array of Connections to that peer.
|
||||
*
|
||||
* @returns {Map<string, Connection[]>}
|
||||
*/
|
||||
get connections(): Map<string, import("libp2p-interfaces/src/connection/connection")[]>;
|
||||
/**
|
||||
* Dials to the provided peer. If successful, the known metadata of the
|
||||
* peer will be added to the nodes `peerStore`
|
||||
*
|
||||
* @param {PeerId|Multiaddr|string} peer - The peer to dial
|
||||
* @param {object} [options]
|
||||
* @param {AbortSignal} [options.signal]
|
||||
* @returns {Promise<Connection>}
|
||||
*/
|
||||
dial(peer: import("peer-id") | Multiaddr | string, options?: {
|
||||
signal?: AbortSignal | undefined;
|
||||
} | undefined): Promise<Connection>;
|
||||
/**
|
||||
* Dials to the provided peer and handshakes with the given protocol.
|
||||
* If successful, the known metadata of the peer will be added to the nodes `peerStore`,
|
||||
* and the `Connection` will be returned
|
||||
*
|
||||
* @async
|
||||
* @param {PeerId|Multiaddr|string} peer - The peer to dial
|
||||
* @param {string[]|string} protocols
|
||||
* @param {object} [options]
|
||||
* @param {AbortSignal} [options.signal]
|
||||
* @returns {Promise<Connection|*>}
|
||||
*/
|
||||
dialProtocol(peer: import("peer-id") | Multiaddr | string, protocols: string[] | string, options?: {
|
||||
signal?: AbortSignal | undefined;
|
||||
} | undefined): Promise<Connection | any>;
|
||||
/**
|
||||
* Get peer advertising multiaddrs by concating the addresses used
|
||||
* by transports to listen with the announce addresses.
|
||||
* Duplicated addresses and noAnnounce addresses are filtered out.
|
||||
*
|
||||
* @returns {Multiaddr[]}
|
||||
*/
|
||||
get multiaddrs(): import("multiaddr")[];
|
||||
/**
|
||||
* Disconnects all connections to the given `peer`
|
||||
*
|
||||
* @param {PeerId|Multiaddr|string} peer - the peer to close connections to
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
hangUp(peer: import("peer-id") | Multiaddr | string): Promise<void>;
|
||||
/**
|
||||
* Pings the given peer in order to obtain the operation latency.
|
||||
*
|
||||
* @param {PeerId|Multiaddr|string} peer - The peer to ping
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
ping(peer: import("peer-id") | Multiaddr | string): Promise<number>;
|
||||
/**
|
||||
* Removes the handler for each protocol. The protocol
|
||||
* will no longer be supported on streams.
|
||||
*
|
||||
* @param {string[]|string} protocols
|
||||
*/
|
||||
unhandle(protocols: string[] | string): void;
|
||||
_onStarting(): Promise<void>;
|
||||
/**
|
||||
* Called when libp2p has started and before it returns
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
private _onDidStart;
|
||||
/**
|
||||
* Will dial to the given `peerId` if the current number of
|
||||
* connected peers is less than the configured `ConnectionManager`
|
||||
* minConnections.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
*/
|
||||
private _maybeConnect;
|
||||
/**
|
||||
* Initializes and starts peer discovery services
|
||||
*
|
||||
* @async
|
||||
* @private
|
||||
*/
|
||||
private _setupPeerDiscovery;
|
||||
}
|
||||
declare namespace Libp2p {
|
||||
export { Multiaddr, Connection, MuxedStream, TransportFactory, MuxerFactory, Crypto, Pubsub, PeerStoreOptions, PeerDiscoveryOptions, RelayOptions, Libp2pConfig, Libp2pModules, Libp2pOptions, CreateOptions };
|
||||
}
|
||||
type Multiaddr = import("multiaddr");
|
||||
type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
type Libp2pOptions = {
|
||||
/**
|
||||
* libp2p modules to use
|
||||
*/
|
||||
modules: Libp2pModules;
|
||||
addresses?: import("./address-manager").AddressManagerOptions | undefined;
|
||||
connectionManager?: import("./connection-manager").ConnectionManagerOptions | undefined;
|
||||
dialer?: import("./dialer").DialerOptions | undefined;
|
||||
metrics?: import("./metrics").MetricsOptions | undefined;
|
||||
keychain?: any;
|
||||
transportManager?: import("./transport-manager").TransportManagerOptions | undefined;
|
||||
peerStore?: (PeerStoreOptions & import("./peer-store/persistent").PersistentPeerStoreOptions) | undefined;
|
||||
config?: Libp2pConfig | undefined;
|
||||
peerId: import("peer-id");
|
||||
};
|
||||
type CreateOptions = {
|
||||
peerId: import("peer-id");
|
||||
};
|
||||
type MuxedStream = import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
|
||||
type TransportFactory = import("libp2p-interfaces/src/transport/types").TransportFactory<any, any>;
|
||||
type MuxerFactory = import("libp2p-interfaces/src/stream-muxer/types").MuxerFactory;
|
||||
type Crypto = import("libp2p-interfaces/src/crypto/types").Crypto;
|
||||
type Pubsub = import("libp2p-interfaces/src/pubsub");
|
||||
type PeerStoreOptions = {
|
||||
persistence: boolean;
|
||||
};
|
||||
type PeerDiscoveryOptions = {
|
||||
autoDial: boolean;
|
||||
};
|
||||
type RelayOptions = {
|
||||
enabled: boolean;
|
||||
advertise: import('./circuit').RelayAdvertiseOptions;
|
||||
hop: import('./circuit').HopOptions;
|
||||
autoRelay: import('./circuit').AutoRelayOptions;
|
||||
};
|
||||
type Libp2pConfig = {
|
||||
/**
|
||||
* dht module options
|
||||
*/
|
||||
dht?: any;
|
||||
peerDiscovery?: PeerDiscoveryOptions | undefined;
|
||||
/**
|
||||
* pubsub module options
|
||||
*/
|
||||
pubsub?: import("libp2p-interfaces/src/pubsub") | undefined;
|
||||
relay?: RelayOptions | undefined;
|
||||
/**
|
||||
* transport options indexed by transport key
|
||||
*/
|
||||
transport?: Record<string, any> | undefined;
|
||||
};
|
||||
type Libp2pModules = {
|
||||
transport: import("libp2p-interfaces/src/transport/types").TransportFactory<any, any>[];
|
||||
streamMuxer: MuxerFactory[];
|
||||
connEncryption: Crypto[];
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/index.d.ts.map
vendored
Normal file
1
dist/src/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";;;AAmCA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH;IACE;;;;;;OAMG;IACH,uBAHW,aAAa,GAAG,aAAa,GAC3B,QAAQ,MAAM,CAAC,CAW3B;IAED;;;;;OAKG;IACH,sBAFW,aAAa,EAsKvB;IAhKC,cAAwC;IAExC,qBAAqB;IACrB,0BAAkC;IAClC,eAAwC;IAExC,kCAM0C;IAG1C,eAAwC;IACxC,4CAAiE;IAEjE,cAAqC;IACrC,aAAmC;IACnC,kBAAoB;IACpB,0BAA2B;IAM3B,kDAGE;IAIA,yCAGE;IASF,2CAIE;IAMJ,+BAKE;IAGF,gDAIE;IAGF,iCAGE;IAuTJ;;;;;OAKG;IACH,kBAHW,MAAM,EAAE,GAAC,MAAM;;;;UACwD,IAAI,QAUrF;IAvTC,2BAQE;IAWA,uCAA4B;IAW5B,kDAA4D;IAc5D,UAQE;IAOF,qBAAqB;IACrB,+CAA8D;IAKhE,sCAAwC;IACxC,4CAA8C;IA8ThD;;;;;;OAMG;IACH,yBAQC;IAlTD;;;;OAIG;IACH,SAFa,QAAQ,IAAI,CAAC,CAezB;IAED;;;;;OAKG;IACH,QAFa,QAAQ,IAAI,CAAC,CAuCzB;IAjCG,gCAAuB;IAmC3B;;;;;;OAMG;IACH,gBAFa,QAAQ,IAAI,CAAC,CAYzB;IAED,iCAEC;IAED;;;;;OAKG;IACH,wFAEC;IAED;;;;;;;;OAQG;IACH,WALW,oBAAO,SAAS,GAAC,MAAM;;oBAGrB,QAAQ,UAAU,CAAC,CAI/B;IAED;;;;;;;;;;;OAWG;IACH,mBANW,oBAAO,SAAS,GAAC,MAAM,aACvB,MAAM,EAAE,GAAC,MAAM;;oBAGb,QAAQ,UAAU,MAAE,CAAC,CAuBjC;IAED;;;;;;OAMG;IACH,wCAUC;IAED;;;;;OAKG;IACH,aAHW,oBAAO,SAAS,GAAC,MAAM,GACrB,QAAQ,IAAI,CAAC,CAgBzB;IAED;;;;;OAKG;IACH,WAHW,oBAAO,SAAS,GAAC,MAAM,GACrB,QAAQ,MAAM,CAAC,CAW3B;IAkBD;;;;;OAKG;IACH,oBAFW,MAAM,EAAE,GAAC,MAAM,QAUzB;IAED,6BAuBC;IAED;;;;OAIG;IACH,oBAuBC;IAmBD;;;;;;;OAOG;IACH,sBAaC;IAED;;;;;OAKG;IACH,4BA6CC;CACF;;;;;;;;;;aAnmBa,aAAa;;;;;;;;;;;;;;;;;;;;iBAxBb,OAAO;;;cAGP,OAAO;;;aAGP,OAAO;eACP,OAAO,WAAW,EAAE,qBAAqB;SACzC,OAAO,WAAW,EAAE,UAAU;eAC9B,OAAO,WAAW,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;eAUpC,4EAAkB;iBAClB,YAAY,EAAE;oBACd,MAAM,EAAE"}
|
11
dist/src/insecure/plaintext.d.ts
vendored
Normal file
11
dist/src/insecure/plaintext.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export type Connection = import("libp2p-interfaces/src/connection/connection");
|
||||
export const protocol: "/plaintext/2.0.0";
|
||||
export declare function secureInbound(localId: any, conn: any, remoteId: any): Promise<{
|
||||
conn: any;
|
||||
remotePeer: import("peer-id");
|
||||
}>;
|
||||
export declare function secureOutbound(localId: any, conn: any, remoteId: any): Promise<{
|
||||
conn: any;
|
||||
remotePeer: import("peer-id");
|
||||
}>;
|
||||
//# sourceMappingURL=plaintext.d.ts.map
|
1
dist/src/insecure/plaintext.d.ts.map
vendored
Normal file
1
dist/src/insecure/plaintext.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"plaintext.d.ts","sourceRoot":"","sources":["../../../src/insecure/plaintext.js"],"names":[],"mappings":";AAYA,0CAAmC;AA4DlB;;;GAEd;AACe;;;GAEf"}
|
3
dist/src/insecure/proto.d.ts
vendored
Normal file
3
dist/src/insecure/proto.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=proto.d.ts.map
|
1
dist/src/insecure/proto.d.ts.map
vendored
Normal file
1
dist/src/insecure/proto.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../../src/insecure/proto.js"],"names":[],"mappings":""}
|
41
dist/src/keychain/cms.d.ts
vendored
Normal file
41
dist/src/keychain/cms.d.ts
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
export = CMS;
|
||||
/**
|
||||
* Cryptographic Message Syntax (aka PKCS #7)
|
||||
*
|
||||
* CMS describes an encapsulation syntax for data protection. It
|
||||
* is used to digitally sign, digest, authenticate, or encrypt
|
||||
* arbitrary message content.
|
||||
*
|
||||
* See RFC 5652 for all the details.
|
||||
*/
|
||||
declare class CMS {
|
||||
/**
|
||||
* Creates a new instance with a keychain
|
||||
*
|
||||
* @param {import('./index')} keychain - the available keys
|
||||
* @param {string} dek
|
||||
*/
|
||||
constructor(keychain: import('./index'), dek: string);
|
||||
keychain: import(".");
|
||||
/**
|
||||
* Creates some protected data.
|
||||
*
|
||||
* The output Uint8Array contains the PKCS #7 message in DER.
|
||||
*
|
||||
* @param {string} name - The local key name.
|
||||
* @param {Uint8Array} plain - The data to encrypt.
|
||||
* @returns {Promise<Uint8Array>}
|
||||
*/
|
||||
encrypt(name: string, plain: Uint8Array): Promise<Uint8Array>;
|
||||
/**
|
||||
* Reads some protected data.
|
||||
*
|
||||
* The keychain must contain one of the keys used to encrypt the data. If none of the keys
|
||||
* exists, an Error is returned with the property 'missingKeys'. It is array of key ids.
|
||||
*
|
||||
* @param {Uint8Array} cmsData - The CMS encrypted data to decrypt.
|
||||
* @returns {Promise<Uint8Array>}
|
||||
*/
|
||||
decrypt(cmsData: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
//# sourceMappingURL=cms.d.ts.map
|
1
dist/src/keychain/cms.d.ts.map
vendored
Normal file
1
dist/src/keychain/cms.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"cms.d.ts","sourceRoot":"","sources":["../../../src/keychain/cms.js"],"names":[],"mappings":";AAYA;;;;;;;;GAQG;AACH;IACE;;;;;OAKG;IACH,sBAHW,OAAO,SAAS,CAAC,OACjB,MAAM,EAShB;IAFC,sBAAwB;IAI1B;;;;;;;;OAQG;IACH,cAJW,MAAM,SACN,UAAU,GACR,QAAQ,UAAU,CAAC,CAuB/B;IAED;;;;;;;;OAQG;IACH,iBAHW,UAAU,GACR,QAAQ,UAAU,CAAC,CAwD/B;CACF"}
|
147
dist/src/keychain/index.d.ts
vendored
Normal file
147
dist/src/keychain/index.d.ts
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
export = Keychain;
|
||||
/**
|
||||
* Information about a key.
|
||||
*
|
||||
* @typedef {Object} KeyInfo
|
||||
* @property {string} id - The universally unique key id.
|
||||
* @property {string} name - The local key name.
|
||||
*/
|
||||
/**
|
||||
* Manages the lifecycle of a key. Keys are encrypted at rest using PKCS #8.
|
||||
*
|
||||
* A key in the store has two entries
|
||||
* - '/info/*key-name*', contains the KeyInfo for the key
|
||||
* - '/pkcs8/*key-name*', contains the PKCS #8 for the key
|
||||
*
|
||||
*/
|
||||
declare class Keychain {
|
||||
/**
|
||||
* Generates the options for a keychain. A random salt is produced.
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
static generateOptions(): any;
|
||||
/**
|
||||
* Gets an object that can encrypt/decrypt protected data.
|
||||
* The default options for a keychain.
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
static get options(): any;
|
||||
/**
|
||||
* Creates a new instance of a key chain.
|
||||
*
|
||||
* @param {Datastore} store - where the key are.
|
||||
* @param {object} options
|
||||
* @class
|
||||
*/
|
||||
constructor(store: any, options: object);
|
||||
store: any;
|
||||
opts: any;
|
||||
/**
|
||||
* Gets an object that can encrypt/decrypt protected data
|
||||
* using the Cryptographic Message Syntax (CMS).
|
||||
*
|
||||
* CMS describes an encapsulation syntax for data protection. It
|
||||
* is used to digitally sign, digest, authenticate, or encrypt
|
||||
* arbitrary message content.
|
||||
*
|
||||
* @returns {CMS}
|
||||
*/
|
||||
get cms(): import("./cms");
|
||||
/**
|
||||
* Create a new key.
|
||||
*
|
||||
* @param {string} name - The local key name; cannot already exist.
|
||||
* @param {string} type - One of the key types; 'rsa'.
|
||||
* @param {number} [size = 2048] - The key size in bits. Used for rsa keys only.
|
||||
* @returns {Promise<KeyInfo>}
|
||||
*/
|
||||
createKey(name: string, type: string, size?: number | undefined): Promise<KeyInfo>;
|
||||
/**
|
||||
* List all the keys.
|
||||
*
|
||||
* @returns {Promise<KeyInfo[]>}
|
||||
*/
|
||||
listKeys(): Promise<KeyInfo[]>;
|
||||
/**
|
||||
* Find a key by it's id.
|
||||
*
|
||||
* @param {string} id - The universally unique key identifier.
|
||||
* @returns {Promise<KeyInfo|undefined>}
|
||||
*/
|
||||
findKeyById(id: string): Promise<KeyInfo | undefined>;
|
||||
/**
|
||||
* Find a key by it's name.
|
||||
*
|
||||
* @param {string} name - The local key name.
|
||||
* @returns {Promise<KeyInfo>}
|
||||
*/
|
||||
findKeyByName(name: string): Promise<KeyInfo>;
|
||||
/**
|
||||
* Remove an existing key.
|
||||
*
|
||||
* @param {string} name - The local key name; must already exist.
|
||||
* @returns {Promise<KeyInfo>}
|
||||
*/
|
||||
removeKey(name: string): Promise<KeyInfo>;
|
||||
/**
|
||||
* Rename a key
|
||||
*
|
||||
* @param {string} oldName - The old local key name; must already exist.
|
||||
* @param {string} newName - The new local key name; must not already exist.
|
||||
* @returns {Promise<KeyInfo>}
|
||||
*/
|
||||
renameKey(oldName: string, newName: string): Promise<KeyInfo>;
|
||||
/**
|
||||
* Export an existing key as a PEM encrypted PKCS #8 string
|
||||
*
|
||||
* @param {string} name - The local key name; must already exist.
|
||||
* @param {string} password - The password
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
exportKey(name: string, password: string): Promise<string>;
|
||||
/**
|
||||
* Import a new key from a PEM encoded PKCS #8 string
|
||||
*
|
||||
* @param {string} name - The local key name; must not already exist.
|
||||
* @param {string} pem - The PEM encoded PKCS #8 string
|
||||
* @param {string} password - The password.
|
||||
* @returns {Promise<KeyInfo>}
|
||||
*/
|
||||
importKey(name: string, pem: string, password: string): Promise<KeyInfo>;
|
||||
/**
|
||||
* Import a peer key
|
||||
*
|
||||
* @param {string} name - The local key name; must not already exist.
|
||||
* @param {PeerId} peer - The PEM encoded PKCS #8 string
|
||||
* @returns {Promise<KeyInfo>}
|
||||
*/
|
||||
importPeer(name: string, peer: PeerId): Promise<KeyInfo>;
|
||||
/**
|
||||
* Gets the private key as PEM encoded PKCS #8 string.
|
||||
*
|
||||
* @param {string} name
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
_getPrivateKey(name: string): Promise<string>;
|
||||
}
|
||||
declare namespace Keychain {
|
||||
export { PeerId, Key, KeyInfo };
|
||||
}
|
||||
/**
|
||||
* Information about a key.
|
||||
*/
|
||||
type KeyInfo = {
|
||||
/**
|
||||
* - The universally unique key id.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* - The local key name.
|
||||
*/
|
||||
name: string;
|
||||
};
|
||||
type PeerId = import("peer-id");
|
||||
type Key = any;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/keychain/index.d.ts.map
vendored
Normal file
1
dist/src/keychain/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keychain/index.js"],"names":[],"mappings":";AAwFA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH;IAsDE;;;;OAIG;IACH,8BAKC;IAED;;;;;OAKG;IACH,0BAEC;IAzED;;;;;;OAMG;IACH,iCAHW,MAAM,EAiChB;IA1BC,WAAkB;IAElB,UAAiD;IA0BnD;;;;;;;;;OASG;IACH,2BAEC;IAwBD;;;;;;;OAOG;IACH,gBALW,MAAM,QACN,MAAM,8BAEJ,QAAQ,OAAO,CAAC,CAiD5B;IAED;;;;OAIG;IACH,YAFa,QAAQ,OAAO,EAAE,CAAC,CAc9B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,QAAQ,OAAO,GAAC,SAAS,CAAC,CAStC;IAED;;;;;OAKG;IACH,oBAHW,MAAM,GACJ,QAAQ,OAAO,CAAC,CAc5B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,QAAQ,OAAO,CAAC,CAc5B;IAED;;;;;;OAMG;IACH,mBAJW,MAAM,WACN,MAAM,GACJ,QAAQ,OAAO,CAAC,CAkC5B;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,YACN,MAAM,GACJ,QAAQ,MAAM,CAAC,CAqB3B;IAED;;;;;;;OAOG;IACH,gBALW,MAAM,OACN,MAAM,YACN,MAAM,GACJ,QAAQ,OAAO,CAAC,CAyC5B;IAED;;;;;;OAMG;IACH,iBAJW,MAAM,QACN,MAAM,GACJ,QAAQ,OAAO,CAAC,CAiC5B;IAED;;;;;OAKG;IACH,qBAHW,MAAM,GACJ,QAAQ,MAAM,CAAC,CAc3B;CACF;;;;;;;;;;;QA5Ya,MAAM;;;;UACN,MAAM"}
|
13
dist/src/keychain/util.d.ts
vendored
Normal file
13
dist/src/keychain/util.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
export function certificateForKey(key: any, privateKey: any): Uint8Array;
|
||||
/**
|
||||
* Finds the first item in a collection that is matched in the
|
||||
* `asyncCompare` function.
|
||||
*
|
||||
* `asyncCompare` is an async function that must
|
||||
* resolve to either `true` or `false`.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {function(*)} asyncCompare - An async function that returns a boolean
|
||||
*/
|
||||
export function findAsync(array: any[], asyncCompare: (arg0: any) => any): Promise<any>;
|
||||
//# sourceMappingURL=util.d.ts.map
|
1
dist/src/keychain/util.d.ts.map
vendored
Normal file
1
dist/src/keychain/util.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/keychain/util.js"],"names":[],"mappings":"AAmB4B,8DAFf,UAAU,CAqDtB;AAED;;;;;;;;;GASG;AACH,wFAKC"}
|
154
dist/src/metrics/index.d.ts
vendored
Normal file
154
dist/src/metrics/index.d.ts
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
export = Metrics;
|
||||
/**
|
||||
* @typedef {import('peer-id')} PeerId
|
||||
* @typedef {import('libp2p-interfaces/src/transport/types').MultiaddrConnection} MultiaddrConnection
|
||||
*/
|
||||
/**
|
||||
* @typedef MetricsProperties
|
||||
* @property {import('../connection-manager')} connectionManager
|
||||
*
|
||||
* @typedef MetricsOptions
|
||||
* @property {number} [computeThrottleMaxQueueSize = defaultOptions.computeThrottleMaxQueueSize]
|
||||
* @property {number} [computeThrottleTimeout = defaultOptions.computeThrottleTimeout]
|
||||
* @property {number[]} [movingAverageIntervals = defaultOptions.movingAverageIntervals]
|
||||
* @property {number} [maxOldPeersRetention = defaultOptions.maxOldPeersRetention]
|
||||
*/
|
||||
declare class Metrics {
|
||||
/**
|
||||
* Merges `other` into `target`. `target` will be modified
|
||||
* and returned.
|
||||
*
|
||||
* @param {Stats} target
|
||||
* @param {Stats} other
|
||||
* @returns {Stats}
|
||||
*/
|
||||
static mergeStats(target: import("./stats"), other: import("./stats")): import("./stats");
|
||||
/**
|
||||
* @class
|
||||
* @param {MetricsProperties & MetricsOptions} options
|
||||
*/
|
||||
constructor(options: MetricsProperties & MetricsOptions);
|
||||
_options: any;
|
||||
_globalStats: import("./stats");
|
||||
_peerStats: Map<any, any>;
|
||||
_protocolStats: Map<any, any>;
|
||||
_oldPeers: any;
|
||||
_running: boolean;
|
||||
/**
|
||||
* Takes the metadata for a message and tracks it in the
|
||||
* appropriate categories. If the protocol is present, protocol
|
||||
* stats will also be tracked.
|
||||
*
|
||||
* @private
|
||||
* @param {object} params
|
||||
* @param {PeerId} params.remotePeer - Remote peer
|
||||
* @param {string} [params.protocol] - Protocol string the stream is running
|
||||
* @param {string} params.direction - One of ['in','out']
|
||||
* @param {number} params.dataLength - Size of the message
|
||||
* @returns {void}
|
||||
*/
|
||||
private _onMessage;
|
||||
_connectionManager: import("../connection-manager");
|
||||
/**
|
||||
* Must be called for stats to saved. Any data pushed for tracking
|
||||
* will be ignored.
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Stops all averages timers and prevents new data from being tracked.
|
||||
* Once `stop` is called, `start` must be called to resume stats tracking.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Gets the global `Stats` object
|
||||
*
|
||||
* @returns {Stats}
|
||||
*/
|
||||
get global(): import("./stats");
|
||||
/**
|
||||
* Returns a list of `PeerId` strings currently being tracked
|
||||
*
|
||||
* @returns {string[]}
|
||||
*/
|
||||
get peers(): string[];
|
||||
/**
|
||||
* Returns the `Stats` object for the given `PeerId` whether it
|
||||
* is a live peer, or in the disconnected peer LRU cache.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {Stats}
|
||||
*/
|
||||
forPeer(peerId: PeerId): import("./stats");
|
||||
/**
|
||||
* Returns a list of all protocol strings currently being tracked.
|
||||
*
|
||||
* @returns {string[]}
|
||||
*/
|
||||
get protocols(): string[];
|
||||
/**
|
||||
* Returns the `Stats` object for the given `protocol`.
|
||||
*
|
||||
* @param {string} protocol
|
||||
* @returns {Stats}
|
||||
*/
|
||||
forProtocol(protocol: string): import("./stats");
|
||||
/**
|
||||
* Should be called when all connections to a given peer
|
||||
* have closed. The `Stats` collection for the peer will
|
||||
* be stopped and moved to an LRU for temporary retention.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
*/
|
||||
onPeerDisconnected(peerId: PeerId): void;
|
||||
/**
|
||||
* Replaces the `PeerId` string with the given `peerId`.
|
||||
* If stats are already being tracked for the given `peerId`, the
|
||||
* placeholder stats will be merged with the existing stats.
|
||||
*
|
||||
* @param {PeerId} placeholder - A peerId string
|
||||
* @param {PeerId} peerId
|
||||
* @returns {void}
|
||||
*/
|
||||
updatePlaceholder(placeholder: PeerId, peerId: PeerId): void;
|
||||
/**
|
||||
* Tracks data running through a given Duplex Iterable `stream`. If
|
||||
* the `peerId` is not provided, a placeholder string will be created and
|
||||
* returned. This allows lazy tracking of a peer when the peer is not yet known.
|
||||
* When the `PeerId` is known, `Metrics.updatePlaceholder` should be called
|
||||
* with the placeholder string returned from here, and the known `PeerId`.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {MultiaddrConnection} options.stream - A duplex iterable stream
|
||||
* @param {PeerId} [options.remotePeer] - The id of the remote peer that's connected
|
||||
* @param {string} [options.protocol] - The protocol the stream is running
|
||||
* @returns {MultiaddrConnection} The peerId string or placeholder string
|
||||
*/
|
||||
trackStream({ stream, remotePeer, protocol }: {
|
||||
stream: MultiaddrConnection;
|
||||
remotePeer: import("peer-id") | undefined;
|
||||
protocol: string | undefined;
|
||||
}): MultiaddrConnection;
|
||||
}
|
||||
declare namespace Metrics {
|
||||
export { PeerId, MultiaddrConnection, MetricsProperties, MetricsOptions };
|
||||
}
|
||||
type PeerId = import("peer-id");
|
||||
type MultiaddrConnection = {
|
||||
sink: import("libp2p-interfaces/src/stream-muxer/types").Sink;
|
||||
source: () => AsyncIterable<Uint8Array>;
|
||||
close: (err?: Error | undefined) => Promise<void>;
|
||||
conn: unknown;
|
||||
remoteAddr: import("multiaddr");
|
||||
localAddr?: import("multiaddr") | undefined;
|
||||
timeline: import("libp2p-interfaces/src/transport/types").MultiaddrConnectionTimeline;
|
||||
};
|
||||
type MetricsProperties = {
|
||||
connectionManager: import('../connection-manager');
|
||||
};
|
||||
type MetricsOptions = {
|
||||
computeThrottleMaxQueueSize?: number | undefined;
|
||||
computeThrottleTimeout?: number | undefined;
|
||||
movingAverageIntervals?: number[] | undefined;
|
||||
maxOldPeersRetention?: number | undefined;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/metrics/index.d.ts.map
vendored
Normal file
1
dist/src/metrics/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metrics/index.js"],"names":[],"mappings":";AAoBA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH;IAwNE;;;;;;;OAOG;IACH,0FASC;IAxOD;;;OAGG;IACH,qBAFW,iBAAiB,GAAG,cAAc,EAc5C;IAXC,cAAqD;IACrD,gCAA6D;IAC7D,0BAA2B;IAC3B,8BAA+B;IAC/B,eAA+D;IAC/D,kBAAqB;IAiGvB;;;;;;;;;;;;OAYG;IACH,mBAwBC;IApIC,oDAAmD;IAMrD;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,aASC;IAED;;;;OAIG;IACH,gCAEC;IAED;;;;OAIG;IACH,sBAEC;IAED;;;;;;OAMG;IACH,gBAHW,MAAM,qBAMhB;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;;OAKG;IACH,sBAHW,MAAM,qBAKhB;IAED;;;;;;OAMG;IACH,2BAFW,MAAM,QAUhB;IAyCD;;;;;;;;OAQG;IACH,+BAJW,MAAM,UACN,MAAM,GACJ,IAAI,CAoBhB;IAED;;;;;;;;;;;;OAYG;IACH;QALwC,MAAM,EAAnC,mBAAmB;QACF,UAAU;QACV,QAAQ;QACvB,mBAAmB,CA2B/B;CAoBF;;;;;;;;;;;;;;;uBAnPa,OAAO,uBAAuB,CAAC"}
|
3
dist/src/metrics/old-peers.d.ts
vendored
Normal file
3
dist/src/metrics/old-peers.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare function _exports(maxSize: number): any;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=old-peers.d.ts.map
|
1
dist/src/metrics/old-peers.d.ts.map
vendored
Normal file
1
dist/src/metrics/old-peers.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"old-peers.d.ts","sourceRoot":"","sources":["../../../src/metrics/old-peers.js"],"names":[],"mappings":"AAUiB,mCAHN,MAAM,GACJ,GAAG,CAOf"}
|
121
dist/src/metrics/stats.d.ts
vendored
Normal file
121
dist/src/metrics/stats.d.ts
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/// <reference types="node" />
|
||||
export = Stats;
|
||||
declare const Stats_base: typeof import("events").EventEmitter;
|
||||
declare class Stats extends Stats_base {
|
||||
/**
|
||||
* A queue based manager for stat processing
|
||||
*
|
||||
* @class
|
||||
* @param {string[]} initialCounters
|
||||
* @param {any} options
|
||||
*/
|
||||
constructor(initialCounters: string[], options: any);
|
||||
_options: any;
|
||||
_queue: any[];
|
||||
_stats: {};
|
||||
_frequencyLastTime: number;
|
||||
_frequencyAccumulators: {};
|
||||
_movingAverages: {};
|
||||
/**
|
||||
* If there are items in the queue, they will will be processed and
|
||||
* the frequency for all items will be updated based on the Timestamp
|
||||
* of the last item in the queue. The `update` event will also be emitted
|
||||
* with the latest stats.
|
||||
*
|
||||
* If there are no items in the queue, no action is taken.
|
||||
*
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
private _update;
|
||||
/**
|
||||
* Initializes the internal timer if there are items in the queue. This
|
||||
* should only need to be called if `Stats.stop` was previously called, as
|
||||
* `Stats.push` will also start the processing.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Stops processing and computing of stats by clearing the internal
|
||||
* timer.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
stop(): void;
|
||||
_timeout: any;
|
||||
/**
|
||||
* Returns a clone of the current stats.
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
get snapshot(): any;
|
||||
/**
|
||||
* Returns a clone of the internal movingAverages
|
||||
*
|
||||
* @returns {MovingAverage}
|
||||
*/
|
||||
get movingAverages(): any;
|
||||
/**
|
||||
* Returns a plain JSON object of the stats
|
||||
*
|
||||
* @returns {*}
|
||||
*/
|
||||
toJSON(): any;
|
||||
/**
|
||||
* Pushes the given operation data to the queue, along with the
|
||||
* current Timestamp, then resets the update timer.
|
||||
*
|
||||
* @param {string} counter
|
||||
* @param {number} inc
|
||||
* @returns {void}
|
||||
*/
|
||||
push(counter: string, inc: number): void;
|
||||
/**
|
||||
* Resets the timeout for triggering updates.
|
||||
*
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
private _resetComputeTimeout;
|
||||
/**
|
||||
* Calculates and returns the timeout for the next update based on
|
||||
* the urgency of the update.
|
||||
*
|
||||
* @private
|
||||
* @returns {number}
|
||||
*/
|
||||
private _nextTimeout;
|
||||
/**
|
||||
* For each key in the stats, the frequency and moving averages
|
||||
* will be updated via Stats._updateFrequencyFor based on the time
|
||||
* difference between calls to this method.
|
||||
*
|
||||
* @private
|
||||
* @param {Timestamp} latestTime
|
||||
* @returns {void}
|
||||
*/
|
||||
private _updateFrequency;
|
||||
/**
|
||||
* Updates the `movingAverages` for the given `key` and also
|
||||
* resets the `frequencyAccumulator` for the `key`.
|
||||
*
|
||||
* @private
|
||||
* @param {string} key
|
||||
* @param {number} timeDiffMS - Time in milliseconds
|
||||
* @param {Timestamp} latestTime - Time in ticks
|
||||
* @returns {void}
|
||||
*/
|
||||
private _updateFrequencyFor;
|
||||
/**
|
||||
* For the given operation, `op`, the stats and `frequencyAccumulator`
|
||||
* will be updated or initialized if they don't already exist.
|
||||
*
|
||||
* @private
|
||||
* @param {{string, number}[]} op
|
||||
* @throws {InvalidNumber}
|
||||
* @returns {void}
|
||||
*/
|
||||
private _applyOp;
|
||||
}
|
||||
//# sourceMappingURL=stats.d.ts.map
|
1
dist/src/metrics/stats.d.ts.map
vendored
Normal file
1
dist/src/metrics/stats.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/metrics/stats.js"],"names":[],"mappings":";;;AAQA;IACE;;;;;;OAMG;IACH,6BAHW,MAAM,EAAE,WACR,GAAG,EA4Bb;IAvBC,cAAuB;IACvB,cAAgB;IAChB,WAAgB;IAEhB,2BAAoC;IACpC,2BAAgC;IAEhC,oBAAyB;IA4H3B;;;;;;;;;;OAUG;IACH,gBAaC;IAlID;;;;;;OAMG;IACH,SAFa,IAAI,CAMhB;IAED;;;;;OAKG;IACH,QAFa,IAAI,CAOhB;IAFG,cAAoB;IAIxB;;;;OAIG;IACH,oBAEC;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,cAkBC;IAED;;;;;;;OAOG;IACH,cAJW,MAAM,OACN,MAAM,GACJ,IAAI,CAKhB;IAED;;;;;OAKG;IACH,6BAEC;IAED;;;;;;OAMG;IACH,qBAKC;IA4BD;;;;;;;;OAQG;IACH,yBAQC;IAED;;;;;;;;;OASG;IACH,4BAsBC;IAED;;;;;;;;OAQG;IACH,iBAqBC;CACF"}
|
63
dist/src/peer-routing.d.ts
vendored
Normal file
63
dist/src/peer-routing.d.ts
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
export = PeerRouting;
|
||||
/**
|
||||
* @typedef {import('peer-id')} PeerId
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
*/
|
||||
declare class PeerRouting {
|
||||
/**
|
||||
* @class
|
||||
* @param {import('./')} libp2p
|
||||
*/
|
||||
constructor(libp2p: import('./'));
|
||||
_peerId: import("peer-id");
|
||||
_peerStore: import("./peer-store");
|
||||
_routers: any;
|
||||
_refreshManagerOptions: any;
|
||||
/**
|
||||
* Recurrent task to find closest peers and add their addresses to the Address Book.
|
||||
*/
|
||||
_findClosestPeersTask(): Promise<void>;
|
||||
/**
|
||||
* Start peer routing service.
|
||||
*/
|
||||
start(): void;
|
||||
_timeoutId: any;
|
||||
/**
|
||||
* Stop peer routing service.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Iterates over all peer routers in series to find the given peer.
|
||||
*
|
||||
* @param {PeerId} id - The id of the peer to find
|
||||
* @param {object} [options]
|
||||
* @param {number} [options.timeout] - How long the query should run
|
||||
* @returns {Promise<{ id: PeerId, multiaddrs: Multiaddr[] }>}
|
||||
*/
|
||||
findPeer(id: PeerId, options?: {
|
||||
timeout?: number | undefined;
|
||||
} | undefined): Promise<{
|
||||
id: PeerId;
|
||||
multiaddrs: Multiaddr[];
|
||||
}>;
|
||||
/**
|
||||
* Attempt to find the closest peers on the network to the given key.
|
||||
*
|
||||
* @param {Uint8Array} key - A CID like key
|
||||
* @param {Object} [options]
|
||||
* @param {number} [options.timeout=30e3] - How long the query can take.
|
||||
* @returns {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>}
|
||||
*/
|
||||
getClosestPeers(key: Uint8Array, options?: {
|
||||
timeout?: number | undefined;
|
||||
} | undefined): AsyncIterable<{
|
||||
id: PeerId;
|
||||
multiaddrs: Multiaddr[];
|
||||
}>;
|
||||
}
|
||||
declare namespace PeerRouting {
|
||||
export { PeerId, Multiaddr };
|
||||
}
|
||||
type PeerId = import("peer-id");
|
||||
type Multiaddr = import("multiaddr");
|
||||
//# sourceMappingURL=peer-routing.d.ts.map
|
1
dist/src/peer-routing.d.ts.map
vendored
Normal file
1
dist/src/peer-routing.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"peer-routing.d.ts","sourceRoot":"","sources":["../../src/peer-routing.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;IACE;;;OAGG;IACH,oBAFW,OAAO,IAAI,CAAC,EAetB;IAZC,2BAA4B;IAC5B,mCAAkC;IAClC,cAAiD;IAOjD,4BAAwE;IAkB1E;;OAEG;IACH,uCAQC;IAxBD;;OAEG;IACH,cAQC;IAHC,gBAEC;IAgBH;;OAEG;IACH,aAEC;IAED;;;;;;;OAOG;IACH,aALW,MAAM;;oBAGJ,QAAQ;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAiB5D;IAED;;;;;;;OAOG;IACH,qBALW,UAAU;;oBAGR,cAAc;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAqBlE;CACF"}
|
120
dist/src/peer-store/address-book.d.ts
vendored
Normal file
120
dist/src/peer-store/address-book.d.ts
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
export = AddressBook;
|
||||
declare const AddressBook_base: typeof import("./book");
|
||||
/**
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
* @typedef {import('./')} PeerStore
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} Address
|
||||
* @property {Multiaddr} multiaddr peer multiaddr.
|
||||
* @property {boolean} isCertified obtained from a signed peer record.
|
||||
*
|
||||
* @typedef {Object} CertifiedRecord
|
||||
* @property {Uint8Array} raw raw envelope.
|
||||
* @property {number} seqNumber seq counter.
|
||||
*
|
||||
* @typedef {Object} Entry
|
||||
* @property {Address[]} addresses peer Addresses.
|
||||
* @property {CertifiedRecord} record certified peer record.
|
||||
*/
|
||||
/**
|
||||
* @extends {Book}
|
||||
*/
|
||||
declare class AddressBook extends AddressBook_base {
|
||||
/**
|
||||
* The AddressBook is responsible for keeping the known multiaddrs of a peer.
|
||||
*
|
||||
* @class
|
||||
* @param {PeerStore} peerStore
|
||||
*/
|
||||
constructor(peerStore: PeerStore);
|
||||
/**
|
||||
* ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.
|
||||
* This will return a boolean that indicates if the record was successfully processed and added
|
||||
* into the AddressBook.
|
||||
*
|
||||
* @param {Envelope} envelope
|
||||
* @returns {boolean}
|
||||
*/
|
||||
consumePeerRecord(envelope: import("../record/envelope")): boolean;
|
||||
/**
|
||||
* Get the raw Envelope for a peer. Returns
|
||||
* undefined if no Envelope is found.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {Uint8Array|undefined}
|
||||
*/
|
||||
getRawEnvelope(peerId: import("peer-id")): Uint8Array | undefined;
|
||||
/**
|
||||
* Get an Envelope containing a PeerRecord for the given peer.
|
||||
* Returns undefined if no record exists.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {Promise<Envelope|void>|undefined}
|
||||
*/
|
||||
getPeerRecord(peerId: import("peer-id")): Promise<import("../record/envelope") | void> | undefined;
|
||||
/**
|
||||
* Add known addresses of a provided peer.
|
||||
* If the peer is not known, it is set with the given addresses.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {Multiaddr[]} multiaddrs
|
||||
* @returns {AddressBook}
|
||||
*/
|
||||
add(peerId: import("peer-id"), multiaddrs: Multiaddr[]): AddressBook;
|
||||
/**
|
||||
* Transforms received multiaddrs into Address.
|
||||
*
|
||||
* @private
|
||||
* @param {Multiaddr[]} multiaddrs
|
||||
* @param {boolean} [isCertified]
|
||||
* @returns {Address[]}
|
||||
*/
|
||||
private _toAddresses;
|
||||
/**
|
||||
* Get the known multiaddrs for a given peer. All returned multiaddrs
|
||||
* will include the encapsulated `PeerId` of the peer.
|
||||
* Returns `undefined` if there are no known multiaddrs for the given peer.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {(addresses: Address[]) => Address[]} [addressSorter]
|
||||
* @returns {Multiaddr[]|undefined}
|
||||
*/
|
||||
getMultiaddrsForPeer(peerId: import("peer-id"), addressSorter?: ((addresses: Address[]) => Address[]) | undefined): Multiaddr[] | undefined;
|
||||
}
|
||||
declare namespace AddressBook {
|
||||
export { Multiaddr, PeerStore, Address, CertifiedRecord, Entry };
|
||||
}
|
||||
type Multiaddr = import("multiaddr");
|
||||
type Address = {
|
||||
/**
|
||||
* peer multiaddr.
|
||||
*/
|
||||
multiaddr: Multiaddr;
|
||||
/**
|
||||
* obtained from a signed peer record.
|
||||
*/
|
||||
isCertified: boolean;
|
||||
};
|
||||
type PeerStore = import(".");
|
||||
type CertifiedRecord = {
|
||||
/**
|
||||
* raw envelope.
|
||||
*/
|
||||
raw: Uint8Array;
|
||||
/**
|
||||
* seq counter.
|
||||
*/
|
||||
seqNumber: number;
|
||||
};
|
||||
type Entry = {
|
||||
/**
|
||||
* peer Addresses.
|
||||
*/
|
||||
addresses: Address[];
|
||||
/**
|
||||
* certified peer record.
|
||||
*/
|
||||
record: CertifiedRecord;
|
||||
};
|
||||
//# sourceMappingURL=address-book.d.ts.map
|
1
dist/src/peer-store/address-book.d.ts.map
vendored
Normal file
1
dist/src/peer-store/address-book.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";;AAmBA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH;IACE;;;;;OAKG;IACH,uBAFW,SAAS,EA0BnB;IAED;;;;;;;OAOG;IACH,2DAFa,OAAO,CA8CnB;IAED;;;;;;OAMG;IACH,2CAFa,UAAU,GAAC,SAAS,CAUhC;IAED;;;;;;OAMG;IACH,0CAFa,QAAQ,+BAAS,IAAI,CAAC,GAAC,SAAS,CAU5C;IAuDD;;;;;;;OAOG;IACH,2CAHW,SAAS,EAAE,GACT,WAAW,CA0CvB;IAmBD;;;;;;;OAOG;IACH,qBAqBC;IAED;;;;;;;;OAQG;IACH,6EAHuB,OAAO,EAAE,KAAK,OAAO,EAAE,gBACjC,SAAS,EAAE,GAAC,SAAS,CAsBjC;CACF;;;;;;;;;eA7Ta,SAAS;;;;iBACT,OAAO;;;;;;;SAGP,UAAU;;;;eACV,MAAM;;;;;;eAGN,OAAO,EAAE;;;;YACT,eAAe"}
|
80
dist/src/peer-store/book.d.ts
vendored
Normal file
80
dist/src/peer-store/book.d.ts
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
export = Book;
|
||||
/**
|
||||
* @typedef {import('./')} PeerStore
|
||||
*/
|
||||
declare class Book {
|
||||
/**
|
||||
* The Book is the skeleton for the PeerStore books.
|
||||
*
|
||||
* @class
|
||||
* @param {Object} properties
|
||||
* @param {PeerStore} properties.peerStore - PeerStore instance.
|
||||
* @param {string} properties.eventName - Name of the event to emit by the PeerStore.
|
||||
* @param {string} properties.eventProperty - Name of the property to emit by the PeerStore.
|
||||
* @param {(data: any) => any[]} [properties.eventTransformer] - Transformer function of the provided data for being emitted.
|
||||
*/
|
||||
constructor({ peerStore, eventName, eventProperty, eventTransformer }: {
|
||||
peerStore: PeerStore;
|
||||
eventName: string;
|
||||
eventProperty: string;
|
||||
eventTransformer: ((data: any) => any[]) | undefined;
|
||||
});
|
||||
_ps: import(".");
|
||||
eventName: string;
|
||||
eventProperty: string;
|
||||
eventTransformer: (data: any) => any[];
|
||||
/**
|
||||
* Map known peers to their data.
|
||||
*
|
||||
* @type {Map<string, any[]|any>}
|
||||
*/
|
||||
data: Map<string, any[] | any>;
|
||||
/**
|
||||
* Set known data of a provided peer.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {any[]|any} data
|
||||
*/
|
||||
set(peerId: import("peer-id"), data: any[] | any): void;
|
||||
/**
|
||||
* Set data into the datastructure, persistence and emit it using the provided transformers.
|
||||
*
|
||||
* @protected
|
||||
* @param {PeerId} peerId - peerId of the data to store
|
||||
* @param {any} data - data to store.
|
||||
* @param {Object} [options] - storing options.
|
||||
* @param {boolean} [options.emit = true] - emit the provided data.
|
||||
* @returns {void}
|
||||
*/
|
||||
protected _setData(peerId: import("peer-id"), data: any, { emit }?: {
|
||||
emit?: boolean | undefined;
|
||||
} | undefined): void;
|
||||
/**
|
||||
* Emit data.
|
||||
*
|
||||
* @protected
|
||||
* @param {PeerId} peerId
|
||||
* @param {any} [data]
|
||||
*/
|
||||
protected _emit(peerId: import("peer-id"), data?: any): void;
|
||||
/**
|
||||
* Get the known data of a provided peer.
|
||||
* Returns `undefined` if there is no available data for the given peer.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {any[]|any|undefined}
|
||||
*/
|
||||
get(peerId: import("peer-id")): any[] | any | undefined;
|
||||
/**
|
||||
* Deletes the provided peer from the book.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {boolean}
|
||||
*/
|
||||
delete(peerId: import("peer-id")): boolean;
|
||||
}
|
||||
declare namespace Book {
|
||||
export { PeerStore };
|
||||
}
|
||||
type PeerStore = import(".");
|
||||
//# sourceMappingURL=book.d.ts.map
|
1
dist/src/peer-store/book.d.ts.map
vendored
Normal file
1
dist/src/peer-store/book.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/book.js"],"names":[],"mappings":";AAWA;;GAEG;AAEH;IACE;;;;;;;;;OASG;IACH;QALiC,SAAS,EAA/B,SAAS;QACU,SAAS,EAA5B,MAAM;QACa,aAAa,EAAhC,MAAM;QAC4B,gBAAgB,UAA3C,GAAG,KAAK,GAAG,EAAE;OAc9B;IAXC,iBAAoB;IACpB,kBAA0B;IAC1B,sBAAkC;IAClC,yBANgB,GAAG,KAAK,GAAG,EAAE,CAMW;IAExC;;;;OAIG;IACH,MAFU,IAAI,MAAM,EAAE,GAAG,EAAE,GAAC,GAAG,CAAC,CAEX;IAGvB;;;;;OAKG;IACH,qCAFW,GAAG,EAAE,GAAC,GAAG,QAInB;IAED;;;;;;;;;OASG;IACH,oDALW,GAAG;;oBAGD,IAAI,CAUhB;IAED;;;;;;OAMG;IACH,kDAFW,GAAG,QAOb;IAED;;;;;;OAMG;IACH,gCAFa,GAAG,EAAE,GAAC,GAAG,GAAC,SAAS,CAW/B;IAED;;;;;OAKG;IACH,mCAFa,OAAO,CAcnB;CACF"}
|
129
dist/src/peer-store/index.d.ts
vendored
Normal file
129
dist/src/peer-store/index.d.ts
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
/// <reference types="node" />
|
||||
export = PeerStore;
|
||||
declare const PeerStore_base: typeof import("events").EventEmitter;
|
||||
/**
|
||||
* @typedef {import('./address-book').Address} Address
|
||||
*/
|
||||
/**
|
||||
* @extends {EventEmitter}
|
||||
*
|
||||
* @fires PeerStore#peer Emitted when a new peer is added.
|
||||
* @fires PeerStore#change:protocols Emitted when a known peer supports a different set of protocols.
|
||||
* @fires PeerStore#change:multiaddrs Emitted when a known peer has a different set of multiaddrs.
|
||||
* @fires PeerStore#change:pubkey Emitted emitted when a peer's public key is known.
|
||||
* @fires PeerStore#change:metadata Emitted when the known metadata of a peer change.
|
||||
*/
|
||||
declare class PeerStore extends PeerStore_base {
|
||||
/**
|
||||
* Peer object
|
||||
*
|
||||
* @typedef {Object} Peer
|
||||
* @property {PeerId} id peer's peer-id instance.
|
||||
* @property {Address[]} addresses peer's addresses containing its multiaddrs and metadata.
|
||||
* @property {string[]} protocols peer's supported protocols.
|
||||
* @property {Map<string, Uint8Array>|undefined} metadata peer's metadata map.
|
||||
*/
|
||||
/**
|
||||
* Responsible for managing known peers, as well as their addresses, protocols and metadata.
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {PeerId} options.peerId
|
||||
* @class
|
||||
*/
|
||||
constructor({ peerId }: {
|
||||
peerId: import("peer-id");
|
||||
});
|
||||
_peerId: import("peer-id");
|
||||
/**
|
||||
* AddressBook containing a map of peerIdStr to Address.
|
||||
*/
|
||||
addressBook: import("./address-book");
|
||||
/**
|
||||
* KeyBook containing a map of peerIdStr to their PeerId with public keys.
|
||||
*/
|
||||
keyBook: import("./key-book");
|
||||
/**
|
||||
* MetadataBook containing a map of peerIdStr to their metadata Map.
|
||||
*/
|
||||
metadataBook: import("./metadata-book");
|
||||
/**
|
||||
* ProtoBook containing a map of peerIdStr to supported protocols.
|
||||
*/
|
||||
protoBook: import("./proto-book");
|
||||
/**
|
||||
* Start the PeerStore.
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Stop the PeerStore.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Get all the stored information of every peer known.
|
||||
*
|
||||
* @returns {Map<string, Peer>}
|
||||
*/
|
||||
get peers(): Map<string, {
|
||||
/**
|
||||
* peer's peer-id instance.
|
||||
*/
|
||||
id: import("peer-id");
|
||||
/**
|
||||
* peer's addresses containing its multiaddrs and metadata.
|
||||
*/
|
||||
addresses: Address[];
|
||||
/**
|
||||
* peer's supported protocols.
|
||||
*/
|
||||
protocols: string[];
|
||||
/**
|
||||
* peer's metadata map.
|
||||
*/
|
||||
metadata: Map<string, Uint8Array> | undefined;
|
||||
}>;
|
||||
/**
|
||||
* Delete the information of the given peer in every book.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {boolean} true if found and removed
|
||||
*/
|
||||
delete(peerId: import("peer-id")): boolean;
|
||||
/**
|
||||
* Get the stored information of a given peer.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {Peer|undefined}
|
||||
*/
|
||||
get(peerId: import("peer-id")): {
|
||||
/**
|
||||
* peer's peer-id instance.
|
||||
*/
|
||||
id: import("peer-id");
|
||||
/**
|
||||
* peer's addresses containing its multiaddrs and metadata.
|
||||
*/
|
||||
addresses: Address[];
|
||||
/**
|
||||
* peer's supported protocols.
|
||||
*/
|
||||
protocols: string[];
|
||||
/**
|
||||
* peer's metadata map.
|
||||
*/
|
||||
metadata: Map<string, Uint8Array> | undefined;
|
||||
} | undefined;
|
||||
}
|
||||
declare namespace PeerStore {
|
||||
export { Address };
|
||||
}
|
||||
type Address = {
|
||||
/**
|
||||
* peer multiaddr.
|
||||
*/
|
||||
multiaddr: import("multiaddr");
|
||||
/**
|
||||
* obtained from a signed peer record.
|
||||
*/
|
||||
isCertified: boolean;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/peer-store/index.d.ts.map
vendored
Normal file
1
dist/src/peer-store/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";;;AAgBA;;GAEG;AAEH;;;;;;;;GAQG;AACH;IACE;;;;;;;;OAQG;IAEH;;;;;;OAMG;IACH;QAH2B,MAAM;OA2BhC;IArBC,2BAAqB;IAErB;;OAEG;IACH,sCAAwC;IAExC;;OAEG;IACH,8BAAgC;IAEhC;;OAEG;IACH,wCAA0C;IAE1C;;OAEG;IACH,kCAAoC;IAGtC;;OAEG;IACH,cAAW;IAEX;;OAEG;IACH,aAAU;IAEV;;;;OAIG;IACH;;;;;;;;mBArDc,OAAO,EAAE;;;;mBACT,MAAM,EAAE;;;;kBACR,IAAI,MAAM,EAAE,UAAU,CAAC,GAAC,SAAS;OAoE9C;IAED;;;;;OAKG;IACH,mCAFa,OAAO,CASnB;IAED;;;;;OAKG;IACH;;;;;;;;mBA7Fc,OAAO,EAAE;;;;mBACT,MAAM,EAAE;;;;kBACR,IAAI,MAAM,EAAE,UAAU,CAAC,GAAC,SAAS;kBA+G9C;CACF"}
|
24
dist/src/peer-store/key-book.d.ts
vendored
Normal file
24
dist/src/peer-store/key-book.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
export = KeyBook;
|
||||
declare const KeyBook_base: typeof import("./book");
|
||||
/**
|
||||
* @typedef {import('./')} PeerStore
|
||||
* @typedef {import('libp2p-crypto').PublicKey} PublicKey
|
||||
*/
|
||||
/**
|
||||
* @extends {Book}
|
||||
*/
|
||||
declare class KeyBook extends KeyBook_base {
|
||||
/**
|
||||
* The KeyBook is responsible for keeping the known public keys of a peer.
|
||||
*
|
||||
* @class
|
||||
* @param {PeerStore} peerStore
|
||||
*/
|
||||
constructor(peerStore: PeerStore);
|
||||
}
|
||||
declare namespace KeyBook {
|
||||
export { PeerStore, PublicKey };
|
||||
}
|
||||
type PeerStore = import(".");
|
||||
type PublicKey = import("libp2p-crypto").PublicKey;
|
||||
//# sourceMappingURL=key-book.d.ts.map
|
1
dist/src/peer-store/key-book.d.ts.map
vendored
Normal file
1
dist/src/peer-store/key-book.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"key-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/key-book.js"],"names":[],"mappings":";;AAgBA;;;GAGG;AAEH;;GAEG;AACH;IACE;;;;;OAKG;IACH,uBAFW,SAAS,EAgBnB;CAgDF"}
|
49
dist/src/peer-store/metadata-book.d.ts
vendored
Normal file
49
dist/src/peer-store/metadata-book.d.ts
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
export = MetadataBook;
|
||||
declare const MetadataBook_base: typeof import("./book");
|
||||
/**
|
||||
* @typedef {import('./')} PeerStore
|
||||
*/
|
||||
/**
|
||||
* @extends {Book}
|
||||
*
|
||||
* @fires MetadataBook#change:metadata
|
||||
*/
|
||||
declare class MetadataBook extends MetadataBook_base {
|
||||
/**
|
||||
* The MetadataBook is responsible for keeping the known supported
|
||||
* protocols of a peer.
|
||||
*
|
||||
* @class
|
||||
* @param {PeerStore} peerStore
|
||||
*/
|
||||
constructor(peerStore: PeerStore);
|
||||
/**
|
||||
* Set data into the datastructure
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
_setValue(peerId: any, key: any, value: any, { emit }?: {
|
||||
emit?: boolean | undefined;
|
||||
}): void;
|
||||
/**
|
||||
* Get specific metadata value, if it exists
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {string} key
|
||||
* @returns {Uint8Array | undefined}
|
||||
*/
|
||||
getValue(peerId: import("peer-id"), key: string): Uint8Array | undefined;
|
||||
/**
|
||||
* Deletes the provided peer metadata key from the book.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {string} key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
deleteValue(peerId: import("peer-id"), key: string): boolean;
|
||||
}
|
||||
declare namespace MetadataBook {
|
||||
export { PeerStore };
|
||||
}
|
||||
type PeerStore = import(".");
|
||||
//# sourceMappingURL=metadata-book.d.ts.map
|
1
dist/src/peer-store/metadata-book.d.ts.map
vendored
Normal file
1
dist/src/peer-store/metadata-book.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"metadata-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/metadata-book.js"],"names":[],"mappings":";;AAiBA;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;;;;OAMG;IACH,uBAFW,SAAS,EAmBnB;IA4BD;;;;OAIG;IACH;;aAeC;IAgBD;;;;;;OAMG;IACH,yCAHW,MAAM,GACJ,UAAU,GAAG,SAAS,CASlC;IAsBD;;;;;;OAMG;IACH,4CAHW,MAAM,GACJ,OAAO,CAgBnB;CACF"}
|
6
dist/src/peer-store/persistent/consts.d.ts
vendored
Normal file
6
dist/src/peer-store/persistent/consts.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export var NAMESPACE_COMMON: string;
|
||||
export var NAMESPACE_ADDRESS: string;
|
||||
export var NAMESPACE_KEYS: string;
|
||||
export var NAMESPACE_METADATA: string;
|
||||
export var NAMESPACE_PROTOCOL: string;
|
||||
//# sourceMappingURL=consts.d.ts.map
|
1
dist/src/peer-store/persistent/consts.d.ts.map
vendored
Normal file
1
dist/src/peer-store/persistent/consts.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../src/peer-store/persistent/consts.js"],"names":[],"mappings":""}
|
123
dist/src/peer-store/persistent/index.d.ts
vendored
Normal file
123
dist/src/peer-store/persistent/index.d.ts
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
export = PersistentPeerStore;
|
||||
declare const PersistentPeerStore_base: typeof import("..");
|
||||
/**
|
||||
* @typedef {Object} PersistentPeerStoreProperties
|
||||
* @property {PeerId} peerId
|
||||
* @property {any} datastore
|
||||
*
|
||||
* @typedef {Object} PersistentPeerStoreOptions
|
||||
* @property {number} [threshold = 5] - Number of dirty peers allowed before commit data.
|
||||
*/
|
||||
/**
|
||||
* Responsible for managing the persistence of data in the PeerStore.
|
||||
*/
|
||||
declare class PersistentPeerStore extends PersistentPeerStore_base {
|
||||
/**
|
||||
* @class
|
||||
* @param {PersistentPeerStoreProperties & PersistentPeerStoreOptions} properties
|
||||
*/
|
||||
constructor({ peerId, datastore, threshold }: PersistentPeerStoreProperties & PersistentPeerStoreOptions);
|
||||
/**
|
||||
* Backend datastore used to persist data.
|
||||
*/
|
||||
_datastore: any;
|
||||
/**
|
||||
* Peers modified after the latest data persisted.
|
||||
*/
|
||||
_dirtyPeers: Set<any>;
|
||||
/**
|
||||
* Peers metadata changed mapping peer identifers to metadata changed.
|
||||
*
|
||||
* @type {Map<string, Set<string>>}
|
||||
*/
|
||||
_dirtyMetadata: Map<string, Set<string>>;
|
||||
threshold: number;
|
||||
/**
|
||||
* Add modified peer to the dirty set
|
||||
*
|
||||
* @private
|
||||
* @param {Object} params
|
||||
* @param {PeerId} params.peerId
|
||||
*/
|
||||
private _addDirtyPeer;
|
||||
/**
|
||||
* Add modified peer key to the dirty set
|
||||
*
|
||||
* @private
|
||||
* @param {Object} params
|
||||
* @param {PeerId} params.peerId
|
||||
*/
|
||||
private _addDirtyPeerKey;
|
||||
/**
|
||||
* Add modified metadata peer to the set.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} params
|
||||
* @param {PeerId} params.peerId
|
||||
* @param {string} params.metadata
|
||||
*/
|
||||
private _addDirtyPeerMetadata;
|
||||
/**
|
||||
* Add all the peers current data to a datastore batch and commit it.
|
||||
*
|
||||
* @private
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private _commitData;
|
||||
/**
|
||||
* Add address book data of the peer to the batch.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
* @param {Object} batch
|
||||
*/
|
||||
private _batchAddressBook;
|
||||
/**
|
||||
* Add Key book data of the peer to the batch.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
* @param {Object} batch
|
||||
*/
|
||||
private _batchKeyBook;
|
||||
/**
|
||||
* Add metadata book data of the peer to the batch.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
* @param {Object} batch
|
||||
*/
|
||||
private _batchMetadataBook;
|
||||
/**
|
||||
* Add proto book data of the peer to the batch.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
* @param {Object} batch
|
||||
*/
|
||||
private _batchProtoBook;
|
||||
/**
|
||||
* Process datastore entry and add its data to the correct book.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} params
|
||||
* @param {Key} params.key - datastore key
|
||||
* @param {Uint8Array} params.value - datastore value stored
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private _processDatastoreEntry;
|
||||
}
|
||||
declare namespace PersistentPeerStore {
|
||||
export { PersistentPeerStoreProperties, PersistentPeerStoreOptions };
|
||||
}
|
||||
type PersistentPeerStoreProperties = {
|
||||
peerId: import("peer-id");
|
||||
datastore: any;
|
||||
};
|
||||
type PersistentPeerStoreOptions = {
|
||||
/**
|
||||
* - Number of dirty peers allowed before commit data.
|
||||
*/
|
||||
threshold?: number | undefined;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/peer-store/persistent/index.d.ts.map
vendored
Normal file
1
dist/src/peer-store/persistent/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/peer-store/persistent/index.js"],"names":[],"mappings":";;AAuBA;;;;;;;GAOG;AAEH;;GAEG;AACH;IACE;;;OAGG;IACH,8CAFW,6BAA6B,GAAG,0BAA0B,EAwBpE;IAnBC;;OAEG;IACH,gBAA2B;IAE3B;;OAEG;IACH,sBAA4B;IAE5B;;;;OAIG;IACH,gBAFU,IAAI,MAAM,EAAE,IAAI,MAAM,CAAC,CAAC,CAEH;IAE/B,kBAA0B;IAsC5B;;;;;;OAMG;IACH,sBAYC;IAED;;;;;;OAMG;IACH,yBAiBC;IAED;;;;;;;OAOG;IACH,8BAiBC;IAED;;;;;OAKG;IACH,oBA+BC;IAED;;;;;;OAMG;IACH,0BA4BC;IAED;;;;;;OAMG;IACH,sBAiBC;IAED;;;;;;OAMG;IACH,2BAkBC;IAED;;;;;;OAMG;IACH,wBAmBC;IAED;;;;;;;;OAQG;IACH,+BAwDC;CACF;;;;;;eAjXa,GAAG"}
|
3
dist/src/peer-store/persistent/pb/address-book.proto.d.ts
vendored
Normal file
3
dist/src/peer-store/persistent/pb/address-book.proto.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=address-book.proto.d.ts.map
|
1
dist/src/peer-store/persistent/pb/address-book.proto.d.ts.map
vendored
Normal file
1
dist/src/peer-store/persistent/pb/address-book.proto.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"address-book.proto.d.ts","sourceRoot":"","sources":["../../../../../src/peer-store/persistent/pb/address-book.proto.js"],"names":[],"mappings":""}
|
3
dist/src/peer-store/persistent/pb/proto-book.proto.d.ts
vendored
Normal file
3
dist/src/peer-store/persistent/pb/proto-book.proto.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=proto-book.proto.d.ts.map
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user