Compare commits

..

256 Commits

Author SHA1 Message Date
achingbrain
8ce2f08589 chore: release version v0.35.5 2021-12-15 09:28:05 +00:00
achingbrain
fe0d9828bb chore: update contributors 2021-12-15 09:28:04 +00:00
achingbrain
c8e1b08c19 chore: typo 2021-12-15 09:25:40 +00:00
achingbrain
faf1f89d9e chore: release version v0.35.4 2021-12-15 08:18:44 +00:00
achingbrain
76f4ea5e8a chore: update contributors 2021-12-15 08:18:44 +00:00
Alex Potsides
2f0b311df7 feat: allow per-component metrics to be collected (#1061)
Implements the idea from #1060 - allows us to get some insight into what's happening in a libp2p node out side of just bandwidth stats.

Configures a few default metrics if metrics are enabled - current connections, the state of the dial queue, etc.

Also makes the `Metrics` class not depend on the `ConnectionManager` class, otherwise we can't collect simple metrics from the connection manager class due to the circular dependency.
2021-12-15 08:03:09 +00:00
achingbrain
d172d0d952 chore: release version v0.35.3 2021-12-13 09:03:54 +00:00
achingbrain
f8e8023aed chore: update contributors 2021-12-13 09:03:54 +00:00
Alex Potsides
bdc9f16d0c fix: clean up pending dial targets (#1059)
If the `Promise.race` throws, execution of the function is terminated so the pending dial target is never removed from the map and we leak memory.

This can happen when there are invalid multiaddrs or when a peer reports more dialable addresses than the threshold.

Instead wrap the `Promise.race` in a `try/finally` which will always remove the pending dial target in the event of success or failure.
2021-12-10 12:42:09 +00:00
Alex Potsides
1b46f47fdb chore: run node tests in ci (#1057)
Looks like this project stopped running the `test:node` npm script when it was migrated to gh actions.

Re-enable it and fix all the related test failures.
2021-12-08 08:38:17 +00:00
dependabot[bot]
b539f9b655 chore(deps-dev): bump libp2p-gossipsub from 0.11.4 to 0.12.1 (#1045)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-07 21:06:06 +00:00
dependabot[bot]
103818733e chore(deps-dev): bump @chainsafe/libp2p-noise from 4.1.1 to 5.0.0 (#1053)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-07 21:05:53 +00:00
Marston Connell
1f1bbc0ee6 docs: naming error in the documentation (#1056)
Changed LevelStore to LevelDatastore
2021-12-07 21:05:33 +00:00
Robert Kiel
3b683e7156 fix: fix uncaught promise rejection when finding peers (#1044)
Do not abort all attempts to find peers when `findPeers` on one router throws synchronously

Co-authored-by: Robert Kiel <robert.kiel@hoprnet.io>
Co-authored-by: achingbrain <alex@achingbrain.net>
2021-12-07 17:51:48 +00:00
Alex Potsides
b25e0fe531 fix: make error codes consistent (#1054)
Sometimes they are `NOT_FOUND`, sometimes `ERR_NOT_FOUND`, etc.

Move all error codes into `errors.js` and reference them from there.
2021-12-07 14:42:10 +00:00
Alex Potsides
cbaa5a2ef3 chore: switch to nat api (#1052)
@motrix/nat-api is a fork, nat-api has the fix from https://github.com/alxhotel/nat-api/pull/25
2021-12-07 09:37:12 +00:00
Alan Smithee
51dabb1724 chore: pubsub example subscribe returns void (#1048)
Seems like the correct return type of `Libp2p.pubsub.subscribe` is `void`, so the `await` can be removed: ae21299ade/src/pubsub-adapter.js (L29)
2021-12-06 21:12:38 +01:00
Vasco Santos
b9339bccaa chore: release version v0.35.2 2021-12-06 21:07:39 +01:00
Vasco Santos
9b21893b64 chore: update contributors 2021-12-06 21:07:38 +01:00
Alex Potsides
b70fb43427 fix: increase maxlisteners on event target (#1050)
Sometimes you encounter peers with lots of addresses. When this happens
you can attach more than 10x event listeners to the abort signal we
use to abort all the dials - this causes node to print a warning
which is misleading.

This PR increases the default number of listeners on the signal.

Fixes #900
2021-12-06 20:54:44 +01:00
achingbrain
ae21299ade chore: release version v0.35.1 2021-12-03 16:24:14 +00:00
achingbrain
149120bebc chore: update contributors 2021-12-03 16:24:13 +00:00
Alex Potsides
91c2ec9856 fix: do not let closest peers run forever (#1047)
The DHT takes a `signal` not a timeout so if a timeout is passed,
create a `TimeoutController` that will abort the query after the
timeout.
2021-12-03 15:47:30 +00:00
achingbrain
6d0ac819f1 chore: release version v0.35.0 2021-12-02 10:44:07 +00:00
achingbrain
15a0b1dbf2 chore: update contributors 2021-12-02 10:44:07 +00:00
Alex Potsides
9cbf36fcb5 chore: update peer id and libp2p crypto (#1042)
BREAKING CHANGE: requires node 15+
2021-12-02 10:11:23 +00:00
Alex Potsides
3a9d5f64d9 fix: stop dht before connection manager (#1041)
Stop the dht before the connection manager, otherwise in-flight eviction pings fail and we move on to the next one when we should just abort them all.

Also pulls in the fix from #1039 and splits the auto-dialler out from the connection manager as during shutdown it can get into a weird state where it's simultaneously killing and creating connections so stop auto-dialling things before we cause connections to dip below the low watermark by killing existing connections.

Fixes: https://github.com/ipfs/js-ipfs/issues/3923
2021-11-30 18:07:57 +00:00
Alex Potsides
eacd7e8f76 chore: update deps (#1038) 2021-11-26 16:00:47 +00:00
dependabot[bot]
7f2cc4dc44 chore(deps-dev): bump ipfs-http-client from 52.0.5 to 54.0.2 (#1035)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-26 14:26:26 +00:00
achingbrain
5cc5a8749a chore: release version v0.34.0 2021-11-25 16:49:46 +00:00
achingbrain
ee60e18213 chore: update contributors 2021-11-25 16:49:46 +00:00
achingbrain
a4a2fac41e chore: node_modules is not required 2021-11-25 16:48:41 +00:00
Alex Potsides
2f598eba09 feat: update dht (#1009)
Changes dht creation to use factory function and updates docs

BREAKING CHANGE: libp2p-kad-dht has a new event-based API which is exposed as `_dht`
2021-11-25 16:32:19 +00:00
Alan Smithee
443a102528 docs: minor corrections to discovery-mechanisms readme (#1030) 2021-11-21 23:18:45 +01:00
Alex Potsides
3bed7b4cb2 chore: update aegir (#1027)
Updates aegir, fixes all new linting errors.
2021-11-19 08:02:24 +00:00
Alex Potsides
3fb424914f chore: fix examples (#1026)
Uses npm to install deps for examples.

We can put yarn back when we remove `node-fetch@2.x` from ipfs-utils, or when
yarn can download tarball dependencies reliably.

This either needs:

1. https://github.com/node-fetch/node-fetch/pull/1172 merging
2. Swap node-fetch for undici
3. Drop CJS support (node-fetch 3 has the above fix but is ESM-only)
2021-11-19 07:26:38 +00:00
patrickwoodhead
bb0ca28195 docs: update connection link in API docs (#1024)
Fixes #1018

The issue was caused when the repo [js-libp2p-interfaces](https://github.com/libp2p/js-libp2p-interfaces) was renamed and refactored in this [commit](946348f7f8)
2021-11-16 15:55:00 +00:00
TheStarBoys
01a8b8da9b chore: example docs for auto-relay with correct port 2021-11-12 10:50:11 +01:00
Vasco Santos
77d7cb8f08 fix: private ip ts compile has no call signatures (#1020) 2021-11-12 10:34:44 +01:00
Robert Kiel
a335fda852 docs: fix datastore link (#999) 2021-09-27 12:42:53 +02:00
Vasco Santos
43e3af0c12 chore: add migration guide to 0.33 (#997) 2021-09-24 11:33:59 +02:00
Vasco Santos
2c9c3cf6d5 chore: release version v0.33.0 2021-09-24 10:32:46 +02:00
Vasco Santos
4d6587539c chore: update contributors 2021-09-24 10:32:45 +02:00
Alex Potsides
83734ef520 chore: update datastore (#990)
`interface-datastore` now only contains the interface definition,
`datastore-core` has the various implementations.

BREAKING CHANGE: datastore implementations provided to libp2p must be compliant with interface-datastore@6.0.0
2021-09-24 10:24:29 +02:00
Vasco Santos
1c2e4d89ac chore: release version v0.32.5 2021-09-21 09:47:01 +02:00
Vasco Santos
c635b08d2f chore: update contributors 2021-09-21 09:47:01 +02:00
dependabot[bot]
3aedf55115 chore(deps): bump es6-promisify from 6.1.1 to 7.0.0 (#974)
Bumps [es6-promisify](https://github.com/mikehall314/es6-promisify) from 6.1.1 to 7.0.0.
- [Release notes](https://github.com/mikehall314/es6-promisify/releases)
- [Commits](https://github.com/mikehall314/es6-promisify/compare/v6.1.1...v7.0.0)

---
updated-dependencies:
- dependency-name: es6-promisify
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 09:40:36 +02:00
dependabot[bot]
ede653cad9 chore(deps-dev): bump into-stream from 6.0.0 to 7.0.0 (#972)
Bumps [into-stream](https://github.com/sindresorhus/into-stream) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/sindresorhus/into-stream/releases)
- [Commits](https://github.com/sindresorhus/into-stream/compare/v6.0.0...v7.0.0)

---
updated-dependencies:
- dependency-name: into-stream
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 09:39:58 +02:00
dependabot[bot]
2ab811d708 chore(deps-dev): bump libp2p-kad-dht from 0.23.4 to 0.24.2 (#991)
Bumps [libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht) from 0.23.4 to 0.24.2.
- [Release notes](https://github.com/libp2p/js-libp2p-kad-dht/releases)
- [Changelog](https://github.com/libp2p/js-libp2p-kad-dht/blob/master/CHANGELOG.md)
- [Commits](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.23.4...v0.24.2)

---
updated-dependencies:
- dependency-name: libp2p-kad-dht
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 09:39:25 +02:00
XiaoZhang
122c89dd0d fix: move abortable-iterator to dependencies (#992)
fix #986
2021-09-21 09:36:37 +02:00
Leask Wong
97107c4ef7 chore: update datastore usage in CONFIGURATION.md (#982)
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
2021-08-31 11:51:51 +02:00
dependabot[bot]
d3f78edffe chore(deps-dev): bump ipfs-http-client from 50.1.2 to 52.0.2 (#973)
Bumps [ipfs-http-client](https://github.com/ipfs/js-ipfs) from 50.1.2 to 52.0.2.
- [Release notes](https://github.com/ipfs/js-ipfs/releases)
- [Changelog](https://github.com/ipfs/js-ipfs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ipfs/js-ipfs/compare/ipfs-http-client@50.1.2...ipfs-http-client@52.0.2)

---
updated-dependencies:
- dependency-name: ipfs-http-client
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-26 12:28:44 +02:00
Vasco Santos
f8e3cf10b0 chore: add dependabot (#968) 2021-08-26 12:02:28 +02:00
Vasco Santos
f342c1ff50 docs: update package list (#969) 2021-08-26 12:02:17 +02:00
Vasco Santos
fe63990a16 chore: libp2p interop job needs exit for aegir (#971) 2021-08-26 11:19:13 +02:00
Vasco Santos
e82b6e414b chore: release version v0.32.4 2021-08-20 09:25:15 +02:00
Vasco Santos
1d62ead8e5 chore: update contributors 2021-08-20 09:25:14 +02:00
Vasco Santos
3d25ff7fd0 chore: use new libp2p-noise 2021-08-20 09:13:21 +02:00
Vasco Santos
0f389a7828 chore: update uint8arrays 2021-08-20 09:13:21 +02:00
Vasco Santos
9f0582f372 chore: remove unused dev dep (#966) 2021-08-19 09:38:39 +02:00
Vasco Santos
266f2c3c86 chore: release version v0.32.3 2021-08-16 18:20:41 +02:00
Vasco Santos
7783edb059 chore: update contributors 2021-08-16 18:20:40 +02:00
Vasco Santos
ba2b4d4b28 fix: uint8arrays is a dep (#964) 2021-08-16 17:54:24 +02:00
Vasco Santos
06c3a6d407 chore: release version v0.32.2 2021-08-13 17:02:52 +02:00
Vasco Santos
833f789714 chore: update contributors 2021-08-13 17:02:51 +02:00
greenSnot
ef24fabf02 feat: custom protocol name (#962)
Co-authored-by: mzdws <8580712+mzdws@user.noreply.gitee.com>
2021-08-13 16:21:50 +02:00
Vasco Santos
3b33fb4b73 fix: browser example ci 2021-08-12 15:15:13 +02:00
Vasco Santos
a07fb7960b chore: update action setup node 2021-08-12 15:15:13 +02:00
Vasco Santos
b11126ca89 chore: release version v0.32.1 2021-07-22 11:51:39 +02:00
Vasco Santos
df53ab4e65 chore: update contributors 2021-07-22 11:51:39 +02:00
Robert Kiel
0701de40b1 fix: turn compliance tests into devDependency (#960)
Co-authored-by: Robert Kiel <robert.kiel@hoprnet.io>
2021-07-22 11:42:04 +02:00
Vasco Santos
d6bb967243 chore: release version v0.32.0 2021-07-15 13:14:37 +02:00
Vasco Santos
d48005b8b7 chore: update contributors 2021-07-15 13:14:36 +02:00
Vasco Santos
67b97e32da chore: add migration guide to 0.32 (#957) 2021-07-15 12:34:15 +02:00
Vasco Santos
664ba2d1e7 chore: release version v0.32.0-rc.0 2021-07-09 09:01:25 +02:00
Vasco Santos
608564b033 chore: update contributors 2021-07-09 09:01:24 +02:00
Vasco Santos
af723b355e fix: do not allow dial to large number of multiaddrs (#954) 2021-07-09 08:46:24 +02:00
Alex Potsides
13cf476148 chore: update to new multiformats (#948)
BREAKING CHANGE: uses the CID class from the new multiformats module

Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
2021-07-09 08:43:34 +02:00
Vasco Santos
39b03586e8 chore: use libp2p-tcp with types (#952) 2021-06-16 09:09:26 +02:00
Vasco Santos
f7183e8afd chore: release version v0.31.7 2021-06-14 09:56:53 +02:00
Vasco Santos
b9988adce9 chore: update contributors 2021-06-14 09:56:53 +02:00
Vasco Santos
b291bc06ec fix: dialer leaking resources after stopping (#947)
* fix: dialer leaking resources after stopping

* chore: add error code to test
2021-06-14 09:19:23 +02:00
Vasco Santos
755eb909f2 chore: update gossipsub dep for example 2021-06-13 21:42:36 +02:00
Vasco Santos
afe0f854e8 chore: use node 16 2021-06-13 21:42:36 +02:00
Vasco Santos
50f7f32e53 chore: update branch 2021-06-13 21:42:36 +02:00
Vasco Santos
052aad4e06 chore: use node 15 in ci 2021-06-13 21:42:36 +02:00
Vasco Santos
2c4b567b00 chore: restructure pubsub tests 2021-06-13 21:42:36 +02:00
Alex Potsides
2a6a635f13 chore: remove ipfs-utils dep (#953)
* chore: remove ipfs-utils dep

We only use it for the env detection, so use [wherearewe](https://www.npmjs.com/package/wherearewe)
instead which is that, but pulled out into a tiny module.

The `TextDecoder` class is global everywhere we support so we don't
need to pull it in from `ipfs-utils` and it's been removed from v8
anyway.

* chore: update ipfs-http-client
2021-06-11 10:01:40 +02:00
Franck Royer
cd152f122f chore: add secure websockets example (#930)
* Add Secure WebSockets example

* Make dial accept self-signed cert
2021-06-11 09:45:47 +02:00
mcclure
2959794796 chore: add more details on DHT configuration in CONFIGURATION.md (#951) 2021-06-10 09:06:26 +02:00
Ryan Bell
2068c845cb chore: configuration format fix 2021-06-07 11:50:21 +02:00
Vasco Santos
d8ba284883 fix: chat example with new multiaddr (#946) 2021-05-28 13:46:08 +02:00
Vasco Santos
869d35d852 chore: release version v0.31.6 2021-05-27 10:48:26 +02:00
Vasco Santos
d6540bf01d chore: update contributors 2021-05-27 10:48:26 +02:00
zeim839
478963ad2d feat: keychain rotate passphrase (#944)
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
2021-05-27 10:30:19 +02:00
Vasco Santos
d22ad83890 chore: update libp2p interop (#940) 2021-05-21 10:22:11 +02:00
Vasco Santos
538f296b0a chore: release version v0.31.5 2021-05-12 19:17:23 +02:00
Vasco Santos
7bac2045cc chore: update contributors 2021-05-12 19:17:22 +02:00
Alex Potsides
818d2b2a98 fix: store remote agent and protocol version during identify (#943) 2021-05-12 19:11:17 +02:00
Vasco Santos
d163ffd224 chore: release version v0.31.4 2021-05-12 17:05:35 +02:00
Vasco Santos
b29d6c9304 chore: update contributors 2021-05-12 17:05:35 +02:00
zeim839
890dd05941 replaced libp2p with node (#942)
Co-authored-by: zeim839 <kassissahil@gmail.com>
2021-05-12 16:47:29 +02:00
zeim839
a79c6b50d7 fix: peerRouting.findPeer() trying to find self (#941)
* throw error if node attempts to find itself

Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
2021-05-12 16:46:20 +02:00
Vasco Santos
d372a68692 chore: add github issue templates (#938) 2021-05-05 15:06:56 +02:00
Vasco Santos
4e3fc19623 chore: release version v0.31.3 2021-05-04 12:23:58 +02:00
Vasco Santos
2fa82b387c chore: update contributors 2021-05-04 12:23:57 +02:00
Alex Potsides
8fc6f8af81 chore: update ipfs-utils dep (#937) 2021-05-04 12:14:11 +02:00
Vasco Santos
924585b143 chore: release version v0.31.2 2021-04-30 15:45:45 +02:00
Vasco Santos
556f0203db chore: update contributors 2021-04-30 15:45:44 +02:00
Vasco Santos
b5a9eb2087 fix: moving averages record types (#935) 2021-04-30 15:42:34 +02:00
Vasco Santos
e5187d02ba chore: release version v0.31.1 2021-04-30 13:40:29 +02:00
Vasco Santos
150e4f97c1 chore: update contributors 2021-04-30 13:40:28 +02:00
Vasco Santos
302bb90058 fix: event emitter and interfaces types for discovery and routing (#934) 2021-04-30 13:20:12 +02:00
Vasco Santos
f860ffb3e7 chore: add migration guide to 0.31 (#912) 2021-04-30 09:30:41 +02:00
Vasco Santos
2572f3e034 chore: update libp2p dht and gossipsub to releases (#933) 2021-04-29 10:10:57 +02:00
Vasco Santos
d76356e56a chore: release version v0.31.0 2021-04-28 15:39:48 +02:00
Vasco Santos
e9543eb2e1 chore: update contributors 2021-04-28 15:39:48 +02:00
Vasco Santos
5282708263 chore: release version v0.31.0-rc.7 2021-04-27 17:18:12 +02:00
Vasco Santos
ed494f03ae chore: update contributors 2021-04-27 17:18:12 +02:00
Vasco Santos
ac370fc967 fix: address book guarantees no replicated entries are added (#927) 2021-04-27 17:14:48 +02:00
Vasco Santos
ef4393649f chore: remove chai deps (#929) 2021-04-27 17:13:34 +02:00
Vasco Santos
f23fd4b7c7 chore: update noise (#926) 2021-04-27 13:24:31 +02:00
Vasco Santos
5372f7af2f chore: release version v0.31.0-rc.6 2021-04-22 10:09:18 +02:00
Vasco Santos
97da0ba740 chore: update contributors 2021-04-22 10:09:18 +02:00
Vasco Santos
88b04156bf fix: keychain optional pw and use interfaces for validators and selectors instead (#924) 2021-04-22 09:53:55 +02:00
Vasco Santos
64f3af897b chore: release version v0.31.0-rc.5 2021-04-21 15:01:31 +02:00
Vasco Santos
54e502afcb chore: update contributors 2021-04-21 15:01:31 +02:00
Alex Potsides
086b0ec0df fix: demand pubsub subclass instead of pubsub instance (#922)
Changes the `Libp2pModules.pubsub` property to be a class that maybe
extends `PubsubBaseProtocol` instead of an instance of that class.
2021-04-21 14:55:21 +02:00
Vasco Santos
cc1f4af879 fix: dht configuration selectors and validators (#919) 2021-04-21 13:28:37 +02:00
Franck Royer
6456a0fff8 chore: browser example dependencies must be installed at the root first (#921)
Fixes #920
2021-04-21 10:45:50 +02:00
Vasco Santos
44463b9145 fix: address book should not emit peer event if no addresses are known #887 2021-04-21 09:14:01 +02:00
Vasco Santos
7eb2cea570 chore: release version v0.31.0-rc.4 2021-04-20 17:14:17 +02:00
Vasco Santos
c381be3510 chore: update contributors 2021-04-20 17:14:16 +02:00
Alex Potsides
975e77991e fix: add clientMode dht arg and upgrade interface-datastore (#918) 2021-04-20 17:11:23 +02:00
Vasco Santos
b043bca607 fix: specify pbjs root (#917) 2021-04-20 16:25:48 +02:00
Vasco Santos
3ffeb4ebe6 chore: apply suggestions from code review
Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
2021-04-20 11:41:50 +02:00
Vasco Santos
06e8f3dd42 fix: do not add abort signals to useless addresses (#913) 2021-04-20 09:31:16 +02:00
Vasco Santos
3f7dde3e13 chore: release version v0.31.0-rc.3 2021-04-19 14:12:25 +02:00
Vasco Santos
6f4e7ceeac chore: update contributors 2021-04-19 14:12:25 +02:00
Alex Potsides
2af692fb4d fix: remove inline arg types from function definitions (#916)
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
2021-04-19 14:08:00 +02:00
Vasco Santos
906315ce73 chore: release version v0.31.0-rc.2 2021-04-16 17:12:57 +02:00
Vasco Santos
49f04cbe70 chore: update contributors 2021-04-16 17:12:57 +02:00
Alex Potsides
3d0a79eff3 fix: metrics stats and moving averages types (#915)
* fix: give stats initial values

Otherwise the compiler cannot derive the type and thinks `stats.snapshot` returns `{}`

* fix: add type shape to moving averages as well
2021-04-16 17:10:22 +02:00
Vasco Santos
55ee332907 chore: release version v0.31.0-rc.1 2021-04-16 15:55:22 +02:00
Vasco Santos
ffe122d47e chore: update contributors 2021-04-16 15:55:22 +02:00
Vasco Santos
21c9aeecb1 fix: dial protocol should throw if no protocol is provided (#914)
BREAKING CHANGE: dialProtocol does not return connection when no protocols are provided
2021-04-16 15:49:57 +02:00
Vasco Santos
a93cca9178 chore: update release template with examples testing (#911) 2021-04-16 09:27:44 +02:00
Vasco Santos
828a32d4f5 chore: add jsdoc 2021-04-15 14:38:25 +02:00
Vasco Santos
b4fb9b7bf2 fix: address book should not emit peer event if no addresses are known 2021-04-15 14:19:59 +02:00
Vasco Santos
0aed9fe1b3 chore: release version v0.31.0-rc.0 2021-04-15 09:52:56 +02:00
Vasco Santos
9d1b917e8a chore: update contributors 2021-04-15 09:52:55 +02:00
Vasco Santos
8506414ea1 chore: config types and dependencies update (#904)
BREAKING CHANGES:

top level types were updated, multiaddr@9.0.0 is used, dialer and keychain internal property names changed and connectionManager minPeers is not supported anymore
2021-04-15 09:40:02 +02:00
Vasco Santos
8e1743cac4 chore: release version v0.30.12 2021-03-27 13:43:36 +01:00
Vasco Santos
3ea95ce642 chore: update contributors 2021-03-27 13:43:35 +01:00
Alex Potsides
c4cae29ef3 chore: do not look up external IP during test (#906)
The NAT manager test will throw if the current computer is behind a
double NAT as at runtime it won't be possible to map external ports.

We don't care about that during the test so configure a fake external
IP so the test will still test the shut-down functionality on a computer
that is behind a double NAT.
2021-03-27 13:15:35 +01:00
Alex Potsides
a7128f07ec fix: the API of es6-promisify is not the same as promisify-es6 (#905) 2021-03-26 18:13:07 +01:00
Vasco Santos
c3e147df6b chore: delegates config md properties for client (#903) 2021-03-24 09:35:17 +01:00
Vasco Santos
b89445274d chore: release version v0.30.11 2021-03-23 09:51:32 +01:00
Vasco Santos
b9e3bcd91e chore: update contributors 2021-03-23 09:51:32 +01:00
Vasco Santos
f5c1cd1fb0 fix: interface-datastore update 2021-03-23 09:39:28 +01:00
Vasco Santos
975e4b0fe0 chore: increase bundle size 2021-03-23 09:39:28 +01:00
Vasco Santos
9504f1951a fix: connection direction should be only inbound or outbound 2021-03-23 09:39:28 +01:00
Vasco Santos
8e1fc78353 chore: release version v0.30.10 2021-03-09 18:52:37 +01:00
Vasco Santos
8895a092b6 chore: update contributors 2021-03-09 18:52:37 +01:00
TJKoury
f2f361998d chore: swap promisify to maintained package (#896)
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
2021-03-09 16:55:38 +01:00
Vasco Santos
5f702f3481 fix: conn mgr access to moving averages record object (#897)
* fix: conn mgr access to moving averages record object

* chore: remove node 12

* chore: add parcel workaround
2021-03-09 16:51:41 +01:00
Philipp Muens
03b34cac7d docs: fix link to connection encryption example (#894) 2021-03-02 13:07:52 +01:00
Aleksei
9c67364caa Add an example of webrtc-direct (#868)
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
2021-02-25 16:34:02 +01:00
Vasco Santos
a1424826e7 chore: release version v0.30.9 2021-02-25 15:31:26 +01:00
Vasco Santos
3d5bba070b chore: update contributors 2021-02-25 15:31:26 +01:00
Vasco Santos
3f314d5e90 fix: transport manager fault tolerance should include tolerance to transport listen fail (#893) 2021-02-25 15:23:07 +01:00
Miguel Mota
4ee3e1973b chore: minor grammar fixes on discovery example (#890) 2021-02-18 11:36:35 +01:00
Vasco Santos
fc6558b897 chore: release version v0.30.8 2021-02-11 14:57:43 +01:00
Vasco Santos
3e302570e5 chore: update contributors 2021-02-11 14:57:43 +01:00
Vasco Santos
a34d2bbcc3 fix: routers should only use dht if enabled (#885) 2021-02-11 14:37:34 +01:00
Vasco Santos
9941414a91 chore: update delegates config docs to use http client (#853) 2021-02-11 11:42:10 +01:00
Vasco Santos
46cb46188a chore: add discovery example with relay and pubsub discovery (#855) 2021-02-11 11:37:11 +01:00
Vasco Santos
1af8472dc6 chore: add transports example (#851) 2021-02-11 11:12:23 +01:00
Vasco Santos
f6a4cad827 chore: add pubsub example tests (#850) 2021-02-10 21:00:40 +01:00
Vasco Santos
b1079474de chore: add protocol and stream muxing example tests (#849) 2021-02-10 15:40:19 +01:00
Vasco Santos
a150ea60c5 chore: add peer and content routing example tests (#848) 2021-02-08 11:03:42 +01:00
Vasco Santos
aec8e3d3bb chore: release version v0.30.7 2021-02-01 18:40:05 +01:00
Vasco Santos
3abf4aeb35 chore: update contributors 2021-02-01 18:40:05 +01:00
Alex Potsides
a36b2112aa fix: do not add observed address received from peers (#882) 2021-02-01 18:32:57 +01:00
Vasco Santos
8d3b61710a chore: release version v0.30.6 2021-01-29 14:39:41 +01:00
Vasco Santos
5dbbeef311 chore: update contributors 2021-01-29 14:39:41 +01:00
Vasco Santos
3e7594f697 fix: peer discovery type in config (#878)
to any
2021-01-29 14:32:13 +01:00
Alex Potsides
ce2a624a09 fix: unref nat manager retries (#877)
The retry operation in the NAT Manager can prevent node from shutting
down, so unref the retries so they don't keep adding work to the
event loop.
2021-01-29 14:09:59 +01:00
Vasco Santos
a64c02838c chore: release version v0.30.5 2021-01-28 16:50:46 +01:00
Vasco Santos
74d07e5e8c chore: update contributors 2021-01-28 16:50:46 +01:00
Vasco Santos
eeda056883 fix: create has optional peer id type (#875) 2021-01-28 16:41:04 +01:00
Kevin Lacker
f06e06a006 chore: update bootstrapers example url 2021-01-28 11:06:11 +01:00
Vasco Santos
28f52bbf75 chore: release version v0.30.4 2021-01-27 15:23:56 +01:00
Vasco Santos
ed5f8f853f chore: update contributors 2021-01-27 15:23:56 +01:00
Alex Potsides
0a6bc0d101 feat: add UPnP NAT manager (#810)
* feat: add uPnP nat manager

Adds a really basic nat manager that attempts to use UPnP to punch
a hole through your router for any IPV4 tcp addresses you have
configured.

Adds any configured addresses to the node's observed addresses list
and adds observed addresses to `libp2p.multiaddrs` so we exchange
them with peers when performing `identify` and people can dial you.

Adds configuration options under `config.nat`

Hole punching is async to not affect start up time.

Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
2021-01-27 14:55:26 +01:00
Vasco Santos
b5c9e48b68 chore: release version v0.30.3 2021-01-27 14:33:33 +01:00
Vasco Santos
9942cbd50c chore: update contributors 2021-01-27 14:33:32 +01:00
Vasco Santos
037c965a67 chore: update deps (#869) 2021-01-27 09:45:31 +01:00
Vasco Santos
748b552876 chore: pnet example test (#845) 2021-01-22 10:24:15 +01:00
Vasco Santos
961b48bb8d chore: release version v0.30.2 2021-01-21 13:50:49 +01:00
Vasco Santos
000826db21 chore: update contributors 2021-01-21 13:50:48 +01:00
Alex Potsides
45c33675a7 fix: store multiaddrs during content and peer routing queries (#865)
* fix: store provider multiaddrs during find providers

Changes the behaviour of `libp2p.contentRouting.findProviders` to store
the multiaddrs reported by the routers before yielding results to
the caller, so when they try to dial the provider, the multiaddrs are
already in the peer store's address book.

Also dedupes providers reported by routers but keeps all of the addresses
reported, even for duplicates.

Also, also fixes a performance bug where the previous implementation would
wait for any router to completely finish finding providers before sending
any results to the caller.  It'll now yield results as they come in which
makes it much, much faster.
2021-01-21 13:41:27 +01:00
Samlior
a28c878f4a chore: fix close for ConnectionManager (#861) 2021-01-21 12:09:53 +01:00
Vasco Santos
67067c97d5 chore: connection encryption example test (#843) 2021-01-21 09:27:27 +01:00
Vasco Santos
f45cd1c4b5 chore: echo example test (#842) 2021-01-20 10:46:04 +01:00
Vasco Santos
0a02207116 chore: add discovery example tests (#841) 2021-01-19 11:02:56 +01:00
Vasco Santos
0b854a949f chore: add browser example test (#846) 2021-01-19 09:57:56 +01:00
Vasco Santos
9014ea657a chore: release version v0.30.1 2021-01-18 17:14:31 +01:00
Vasco Santos
f40697975e chore: update contributors 2021-01-18 17:14:30 +01:00
Vasco Santos
6c41e30456 fix: event emitter types with local types (#864) 2021-01-18 17:07:30 +01:00
Vasco Santos
77e8273a64 chore: add chat example (#840) 2021-01-18 11:15:02 +01:00
acolytec3
d60922b799 docs: Add bootstrap to custom peer discovery (#859) 2021-01-15 10:27:23 +01:00
Vasco Santos
42b51d8f01 chore: add github actions badge and fix codecov (#837) 2020-12-17 14:22:36 +01:00
Vasco Santos
d19401aa4c chore: release version v0.30.0 2020-12-16 14:03:09 +01:00
Vasco Santos
24bb8df521 chore: update contributors 2020-12-16 14:03:09 +01:00
Vasco Santos
58d4f9a915 chore: release version v0.30.0-rc.2 2020-12-16 13:56:41 +01:00
Vasco Santos
239413e331 chore: update contributors 2020-12-16 13:56:41 +01:00
Vasco Santos
01d43a7b60 chore: fix multicodec updates (#835)
* chore: fix specific multicodec version

* chore: fix multicodec issues

* chore: remove prepare script
2020-12-16 13:56:41 +01:00
Vasco Santos
37d66fd88c chore: release version v0.30.0-rc.1 2020-12-16 13:56:41 +01:00
Vasco Santos
21e8ced81a chore: update contributors 2020-12-16 13:56:41 +01:00
Vasco Santos
9ae1b758e9 fix: types from ipfs integration (#832) 2020-12-16 13:56:41 +01:00
Vasco Santos
408868655c chore: remove secio from packages table (#833) 2020-12-16 13:56:41 +01:00
Vasco Santos
c5f61ac05f chore: release version v0.30.0-rc.0 2020-12-16 13:56:41 +01:00
Vasco Santos
5d0ac529e4 chore: update contributors 2020-12-16 13:56:41 +01:00
Vasco Santos
bc05083207 docs: production guide base setup (#804) 2020-12-16 13:56:41 +01:00
Vasco Santos
169bb806a7 chore: add typedefs (#802) 2020-12-16 13:56:41 +01:00
Vasco Santos
7809e6444e chore: auto relay configuration example with noise (#828) 2020-12-16 13:56:41 +01:00
Vasco Santos
f7e1426b9e chore: update pubsub example by disabled emit self (#823) 2020-12-16 13:56:41 +01:00
Vasco Santos
7d76ba1367 docs: migration 0.29 to 0.30 (#808) 2020-12-16 13:56:41 +01:00
Vasco Santos
b538ebdc0a chore: use set-delayed-interval module on circuit (#809) 2020-12-16 13:56:41 +01:00
Vasco Santos
baedf3fe5a feat: discover and connect to closest peers (#798) 2020-12-16 13:56:41 +01:00
Vasco Santos
4ebcdb085c chore: update websockets (#806)
* chore: update websockets
2020-12-16 13:56:41 +01:00
Vasco Santos
4448de8432 docs: auto relay example (#795)
* chore: auto relay example

* chore: update examples to use process arguments

* chore: add test setup for node tests and test for auto-relay

* chore: apply suggestions from code review

* chore: do not use promise for multiaddrs event on example
2020-12-16 13:56:41 +01:00
Vasco Santos
585ad52b4c feat: custom dialer addr sorter (#792)
* feat: custom dialer addr sorter

* chore: use libp2p utils sorter via addressBook getMultiaddrsForPeer

* chore: use new libp2p utils

* chore: apply suggestions from code review

Co-authored-by: Jacob Heun <jacobheun@gmail.com>

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-12-16 13:56:41 +01:00
Vasco Santos
e50c6abcf2 chore: update pubsub (#801)
BREAKING CHANGE: 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
2020-12-16 13:56:41 +01:00
Vasco Santos
49fffda23c test: custom announce filter 2020-12-16 13:56:41 +01:00
Vasco Santos
689c35ed1c fix: remove test/dialing/utils extra file 2020-12-16 13:56:41 +01:00
Vasco Santos
1a13e2c6ca chore: update address manager readme 2020-12-16 13:56:41 +01:00
Vasco Santos
5758db8ea9 chore: remove noAnnounce from address manager 2020-12-16 13:56:41 +01:00
Vasco Santos
ef9d3ca2c6 feat: custom announce filter 2020-12-16 13:56:41 +01:00
Vasco Santos
97e3633f47 chore: store self protocols in protobook (#760) 2020-12-16 13:56:41 +01:00
Vasco Santos
e36b67a212 chore: improve logging for auto relay active listen 2020-12-16 13:56:41 +01:00
Vasco Santos
e977039c8a chore: sort relay addresses to listen for public first 2020-12-16 13:56:41 +01:00
Vasco Santos
a5337c1797 chore: lint issues fixed 2020-12-16 13:56:41 +01:00
Vasco Santos
ee23fb9508 chore: apply suggestions from code review
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-12-16 13:56:41 +01:00
Vasco Santos
11a46ea71e chore: add configuration docs for auto relay and hop service 2020-12-16 13:56:41 +01:00
Vasco Santos
5c72424e57 chore: address review 2020-12-16 13:56:41 +01:00
Vasco Santos
0bf0b7cf89 feat: auto relay network query for new relays 2020-12-16 13:56:41 +01:00
Vasco Santos
55020056ee chore: lint issue fixed 0.30 2020-12-16 13:56:41 +01:00
Vasco Santos
bb83cacb5a chore: address review 2020-12-16 13:56:41 +01:00
Vasco Santos
447d0ed0dd chore: add identify test for multiaddr change 2020-12-16 13:56:41 +01:00
Vasco Santos
43eda43f06 chore: create signed peer record on new listen addresses in transport manager 2020-12-16 13:56:41 +01:00
Vasco Santos
7b93ece7f2 chore: use listening events to create self peer record on updates 2020-12-16 13:56:41 +01:00
Vasco Santos
74bdfd1024 chore: _isStarted is false when stop starts 2020-12-16 13:56:41 +01:00
Vasco Santos
4d1fcdb3d2 chore: auto relay multiaddr update push 2020-12-16 13:56:41 +01:00
Vasco Santos
caf66ea143 feat: auto relay (#723)
* feat: auto relay

* fix: leverage protoBook events to ask relay peers if they support hop

* chore: refactor disconnect

* chore: do not listen on a relayed conn

* chore: tweaks

* chore: improve _listenOnAvailableHopRelays logic

* chore: default value of 1 to maxListeners on auto-relay
2020-12-16 13:56:41 +01:00
357 changed files with 9949 additions and 8541 deletions

View File

@@ -1,12 +1,13 @@
'use strict'
const path = require('path')
const Libp2p = require('./src')
const { MULTIADDRS_WEBSOCKETS } = require('./test/fixtures/browser')
const Peers = require('./test/fixtures/peers')
const PeerId = require('peer-id')
const WebSockets = require('libp2p-websockets')
const Muxer = require('libp2p-mplex')
const { NOISE: Crypto } = require('libp2p-noise')
const { NOISE: Crypto } = require('@chainsafe/libp2p-noise')
const pipe = require('it-pipe')
let libp2p
@@ -31,6 +32,9 @@ const before = async () => {
enabled: true,
active: false
}
},
nat: {
enabled: false
}
}
})
@@ -44,16 +48,23 @@ const after = async () => {
await libp2p.stop()
}
/** @type {import('aegir').Options["build"]["config"]} */
const esbuild = {
inject: [path.join(__dirname, './scripts/node-globals.js')]
}
/** @type {import('aegir').PartialOptions} */
module.exports = {
bundlesize: { maxSize: '225kB' },
hooks: {
pre: before,
post: after
build: {
bundlesizeMax: '253kB'
},
webpack: {
node: {
// needed by bcrypto
Buffer: true
test: {
before,
after,
browser: {
config: {
buildConfig: esbuild
}
}
}
}

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: libp2p Official Forum
url: https://discuss.libp2p.io
about: For general questions, support requests and discussions

55
.github/ISSUE_TEMPLATE/open_an_issue.md vendored Normal file
View File

@@ -0,0 +1,55 @@
---
name: Open an issue
about: For reporting bugs or errors in the JavaScript libp2p implementation
title: ''
labels: need/triage
assignees: ''
---
<!--
Thank you for reporting an issue.
This issue tracker is for bugs found within the JavaScript implementation of libp2p.
If you are asking a question about how to use libp2p, please ask on https://discuss.libp2p.io
Otherwise please fill in as much of the template below as possible.
-->
- **Version**:
<!--
Check package.json version
-->
- **Platform**:
<!--
Output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows). If using in a Browser, please share the browser version as well
-->
- **Subsystem**:
<!--
If known, please specify affected core module name (e.g Dialer, Pubsub, Relay etc)
-->
#### Severity:
<!--
One of following:
Critical - System crash, application panic.
High - The main functionality of the application does not work, API breakage, repo format breakage, etc.
Medium - A non-essential functionality does not work, performance issues, etc.
Low - An optional functionality does not work.
Very Low - Translation or documentation mistake. Something that won't give anyone a bad day.
-->
#### Description:
<!--
- What you did
- What happened
- What you expected to happen
-->
#### Steps to reproduce the error:
<!--
If possible, please provide code that demonstrates the problem, keeping it as simple and free of external dependencies as you are able
-->

View File

@@ -25,8 +25,6 @@
- [ ] [js-ipfs](https://github.com/ipfs/js-ipfs)
- 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

8
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "11:00"
open-pull-requests-limit: 10

141
.github/workflows/examples.yml vendored Normal file
View File

@@ -0,0 +1,141 @@
name: examples
on:
push:
branches:
- master
pull_request:
branches:
- '**'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npx aegir lint
- run: npx aegir ts -p check
- run: npx aegir build
test-auto-relay-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- auto-relay
test-chat-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- chat
test-connection-encryption-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- connection-encryption
test-discovery-mechanisms-example:
needs: check
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- discovery-mechanisms
test-echo-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- echo
test-libp2p-in-the-browser-example:
needs: check
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- libp2p-in-the-browser
test-peer-and-content-routing-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- peer-and-content-routing
test-pnet-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- pnet
test-protocol-and-stream-muxing-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- protocol-and-stream-muxing
test-pubsub-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- pubsub
test-transports-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: cd examples && npm i && npm run test -- transports
test-webrtc-direct-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: cd examples && npm i && npm run test -- webrtc-direct

View File

@@ -12,12 +12,14 @@ jobs:
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
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npx aegir lint
- run: npx aegir build
- run: npx aegir dep-check
- uses: ipfs/aegir/actions/bundle-size
name: size
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -27,41 +29,53 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [12, 14]
node: [16]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
- run: npm install
- run: npm run test:node -- --cov --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
- uses: actions/setup-node@v2
with:
node-version: lts/*
- run: npm install
- run: npm run test:browser -- -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
- uses: actions/setup-node@v2
with:
node-version: lts/*
- run: npm install
- run: npm run test:browser -- -t browser -t webworker --bail -- --browser firefox
test-ts:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- run: npm install
- run: npm run test:ts
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
- uses: actions/setup-node@v2
with:
node-version: lts/*
- run: npm install
- run: npm run test:interop -- --bail -- --exit

2
.gitignore vendored
View File

@@ -4,6 +4,7 @@ docs
test/repo-tests*
**/bundle.js
.cache
.parcel-cache
# Logs
logs
@@ -36,6 +37,7 @@ 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

View File

@@ -1,3 +1,472 @@
## [0.35.5](https://github.com/libp2p/js-libp2p/compare/v0.35.4...v0.35.5) (2021-12-15)
## [0.35.4](https://github.com/libp2p/js-libp2p/compare/v0.35.3...v0.35.4) (2021-12-15)
### Features
* allow per-component metrics to be collected ([#1061](https://github.com/libp2p/js-libp2p/issues/1061)) ([2f0b311](https://github.com/libp2p/js-libp2p/commit/2f0b311df7127aa44512c2008142d4ca30268986)), closes [#1060](https://github.com/libp2p/js-libp2p/issues/1060)
## [0.35.3](https://github.com/libp2p/js-libp2p/compare/v0.35.2...v0.35.3) (2021-12-13)
### Bug Fixes
* clean up pending dial targets ([#1059](https://github.com/libp2p/js-libp2p/issues/1059)) ([bdc9f16](https://github.com/libp2p/js-libp2p/commit/bdc9f16d0cbe56ccf26822f11068e7795bcef046))
* fix uncaught promise rejection when finding peers ([#1044](https://github.com/libp2p/js-libp2p/issues/1044)) ([3b683e7](https://github.com/libp2p/js-libp2p/commit/3b683e715686163e229b7b5c3a892327dfd4fc63))
* make error codes consistent ([#1054](https://github.com/libp2p/js-libp2p/issues/1054)) ([b25e0fe](https://github.com/libp2p/js-libp2p/commit/b25e0fe5312db58a06c39500ae84c50fed3a93bd))
## [0.35.2](https://github.com/libp2p/js-libp2p/compare/v0.33.0...v0.35.2) (2021-12-06)
### Bug Fixes
* do not let closest peers run forever ([#1047](https://github.com/libp2p/js-libp2p/issues/1047)) ([91c2ec9](https://github.com/libp2p/js-libp2p/commit/91c2ec9856a3e972b7b2c9c4d9a4eda1d431c7ef))
* increase maxlisteners on event target ([#1050](https://github.com/libp2p/js-libp2p/issues/1050)) ([b70fb43](https://github.com/libp2p/js-libp2p/commit/b70fb43427b47df079b55929ec8956f69cbda966)), closes [#900](https://github.com/libp2p/js-libp2p/issues/900)
* private ip ts compile has no call signatures ([#1020](https://github.com/libp2p/js-libp2p/issues/1020)) ([77d7cb8](https://github.com/libp2p/js-libp2p/commit/77d7cb8f0815f2cdd3bfdfa8b641a7a186fe9520))
* stop dht before connection manager ([#1041](https://github.com/libp2p/js-libp2p/issues/1041)) ([3a9d5f6](https://github.com/libp2p/js-libp2p/commit/3a9d5f64d96719ebb4d3b083c4f5832db4fa0816)), closes [#1039](https://github.com/libp2p/js-libp2p/issues/1039)
### chore
* update peer id and libp2p crypto ([#1042](https://github.com/libp2p/js-libp2p/issues/1042)) ([9cbf36f](https://github.com/libp2p/js-libp2p/commit/9cbf36fcb54099e6fed35ceccc4a2376f0926c1f))
### Features
* update dht ([#1009](https://github.com/libp2p/js-libp2p/issues/1009)) ([2f598eb](https://github.com/libp2p/js-libp2p/commit/2f598eba09cff4301474af08196158065e3602d8))
### BREAKING CHANGES
* requires node 15+
* libp2p-kad-dht has a new event-based API which is exposed as `_dht`
## [0.35.1](https://github.com/libp2p/js-libp2p/compare/v0.35.0...v0.35.1) (2021-12-03)
### Bug Fixes
* do not let closest peers run forever ([#1047](https://github.com/libp2p/js-libp2p/issues/1047)) ([91c2ec9](https://github.com/libp2p/js-libp2p/commit/91c2ec9856a3e972b7b2c9c4d9a4eda1d431c7ef))
# [0.35.0](https://github.com/libp2p/js-libp2p/compare/v0.34.0...v0.35.0) (2021-12-02)
### Bug Fixes
* stop dht before connection manager ([#1041](https://github.com/libp2p/js-libp2p/issues/1041)) ([3a9d5f6](https://github.com/libp2p/js-libp2p/commit/3a9d5f64d96719ebb4d3b083c4f5832db4fa0816)), closes [#1039](https://github.com/libp2p/js-libp2p/issues/1039)
### chore
* update peer id and libp2p crypto ([#1042](https://github.com/libp2p/js-libp2p/issues/1042)) ([9cbf36f](https://github.com/libp2p/js-libp2p/commit/9cbf36fcb54099e6fed35ceccc4a2376f0926c1f))
### BREAKING CHANGES
* requires node 15+
# [0.34.0](https://github.com/libp2p/js-libp2p/compare/v0.33.0...v0.34.0) (2021-11-25)
### Bug Fixes
* private ip ts compile has no call signatures ([#1020](https://github.com/libp2p/js-libp2p/issues/1020)) ([77d7cb8](https://github.com/libp2p/js-libp2p/commit/77d7cb8f0815f2cdd3bfdfa8b641a7a186fe9520))
### Features
* update dht ([#1009](https://github.com/libp2p/js-libp2p/issues/1009)) ([2f598eb](https://github.com/libp2p/js-libp2p/commit/2f598eba09cff4301474af08196158065e3602d8))
### BREAKING CHANGES
* libp2p-kad-dht has a new event-based API which is exposed as `_dht`
# [0.33.0](https://github.com/libp2p/js-libp2p/compare/v0.32.5...v0.33.0) (2021-09-24)
### chore
* update datastore ([#990](https://github.com/libp2p/js-libp2p/issues/990)) ([83734ef](https://github.com/libp2p/js-libp2p/commit/83734ef52061ad61ddb5ca49aae27e3a8b937058))
### BREAKING CHANGES
* datastore implementations provided to libp2p must be compliant with interface-datastore@6.0.0
## [0.32.5](https://github.com/libp2p/js-libp2p/compare/v0.32.4...v0.32.5) (2021-09-21)
### Bug Fixes
* move abortable-iterator to dependencies ([#992](https://github.com/libp2p/js-libp2p/issues/992)) ([122c89d](https://github.com/libp2p/js-libp2p/commit/122c89dd0df55a59edaae078e3dc7c31b5603715)), closes [#986](https://github.com/libp2p/js-libp2p/issues/986)
## [0.32.4](https://github.com/libp2p/js-libp2p/compare/v0.32.3...v0.32.4) (2021-08-20)
## [0.32.3](https://github.com/libp2p/js-libp2p/compare/v0.32.2...v0.32.3) (2021-08-16)
### Bug Fixes
* uint8arrays is a dep ([#964](https://github.com/libp2p/js-libp2p/issues/964)) ([ba2b4d4](https://github.com/libp2p/js-libp2p/commit/ba2b4d4b28f1d9940b457de344aed44537f9eabd))
## [0.32.2](https://github.com/libp2p/js-libp2p/compare/v0.32.1...v0.32.2) (2021-08-13)
### Bug Fixes
* browser example ci ([3b33fb4](https://github.com/libp2p/js-libp2p/commit/3b33fb4b73ba8065e432fb59f758fe138fd23d9e))
### Features
* custom protocol name ([#962](https://github.com/libp2p/js-libp2p/issues/962)) ([ef24fab](https://github.com/libp2p/js-libp2p/commit/ef24fabf0269fd079888e92eedb458e23ef1c733))
## [0.32.1](https://github.com/libp2p/js-libp2p/compare/v0.32.0...v0.32.1) (2021-07-22)
### Bug Fixes
* turn compliance tests into devDependency ([#960](https://github.com/libp2p/js-libp2p/issues/960)) ([0701de4](https://github.com/libp2p/js-libp2p/commit/0701de40b1ebdf319959846d8c4fdd30b3cf34a4))
# [0.32.0](https://github.com/libp2p/js-libp2p/compare/v0.32.0-rc.0...v0.32.0) (2021-07-15)
# [0.32.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.31.7...v0.32.0-rc.0) (2021-07-09)
### Bug Fixes
* do not allow dial to large number of multiaddrs ([#954](https://github.com/libp2p/js-libp2p/issues/954)) ([af723b3](https://github.com/libp2p/js-libp2p/commit/af723b355e1ddf4aecf439f81c3aa67613d45fa4))
### chore
* update to new multiformats ([#948](https://github.com/libp2p/js-libp2p/issues/948)) ([13cf476](https://github.com/libp2p/js-libp2p/commit/13cf4761489d59b22924bb8ec2ec6dbe207b280c))
### BREAKING CHANGES
* uses the CID class from the new multiformats module
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
## [0.31.7](https://github.com/libp2p/js-libp2p/compare/v0.31.6...v0.31.7) (2021-06-14)
### Bug Fixes
* chat example with new multiaddr ([#946](https://github.com/libp2p/js-libp2p/issues/946)) ([d8ba284](https://github.com/libp2p/js-libp2p/commit/d8ba2848833d9fb8a963d1b7c8d27062c6f829da))
* dialer leaking resources after stopping ([#947](https://github.com/libp2p/js-libp2p/issues/947)) ([b291bc0](https://github.com/libp2p/js-libp2p/commit/b291bc06ec13feeb6e010730edfad754a3b2dc1b))
## [0.31.6](https://github.com/libp2p/js-libp2p/compare/v0.31.5...v0.31.6) (2021-05-27)
### Features
* keychain rotate passphrase ([#944](https://github.com/libp2p/js-libp2p/issues/944)) ([478963a](https://github.com/libp2p/js-libp2p/commit/478963ad2d195444494c0acc54cb3847a29e117c))
## [0.31.5](https://github.com/libp2p/js-libp2p/compare/v0.31.4...v0.31.5) (2021-05-12)
### Bug Fixes
* store remote agent and protocol version during identify ([#943](https://github.com/libp2p/js-libp2p/issues/943)) ([818d2b2](https://github.com/libp2p/js-libp2p/commit/818d2b2a98736f4242694479089396f6070cdad5))
## [0.31.4](https://github.com/libp2p/js-libp2p/compare/v0.31.3...v0.31.4) (2021-05-12)
### Bug Fixes
* peerRouting.findPeer() trying to find self ([#941](https://github.com/libp2p/js-libp2p/issues/941)) ([a79c6b5](https://github.com/libp2p/js-libp2p/commit/a79c6b50d7fddbcdb1af53efae922cecad4c9a83))
## [0.31.3](https://github.com/libp2p/js-libp2p/compare/v0.31.2...v0.31.3) (2021-05-04)
## [0.31.2](https://github.com/libp2p/js-libp2p/compare/v0.31.1...v0.31.2) (2021-04-30)
### Bug Fixes
* moving averages record types ([#935](https://github.com/libp2p/js-libp2p/issues/935)) ([b5a9eb2](https://github.com/libp2p/js-libp2p/commit/b5a9eb208763efa027d0b4caae87c515b6f5869b))
## [0.31.1](https://github.com/libp2p/js-libp2p/compare/v0.31.0...v0.31.1) (2021-04-30)
### Bug Fixes
* event emitter and interfaces types for discovery and routing ([#934](https://github.com/libp2p/js-libp2p/issues/934)) ([302bb90](https://github.com/libp2p/js-libp2p/commit/302bb9005891aa06b70a5f354bfac6b2d5a3c3b8))
# [0.31.0](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.7...v0.31.0) (2021-04-28)
# [0.31.0-rc.7](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.6...v0.31.0-rc.7) (2021-04-27)
### Bug Fixes
* address book guarantees no replicated entries are added ([#927](https://github.com/libp2p/js-libp2p/issues/927)) ([ac370fc](https://github.com/libp2p/js-libp2p/commit/ac370fc9679b51da8cee3791b6dd268d0695d136))
# [0.31.0-rc.6](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.5...v0.31.0-rc.6) (2021-04-22)
### Bug Fixes
* keychain optional pw and use interfaces for validators and selectors instead ([#924](https://github.com/libp2p/js-libp2p/issues/924)) ([88b0415](https://github.com/libp2p/js-libp2p/commit/88b04156bf614650c2b14d49b12e969c5eecf04d))
# [0.31.0-rc.5](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.4...v0.31.0-rc.5) (2021-04-21)
### Bug Fixes
* address book should not emit peer event if no addresses are known ([b4fb9b7](https://github.com/libp2p/js-libp2p/commit/b4fb9b7bf266ba03c4462c0a41b1c2691e4e88d4))
* demand pubsub subclass instead of pubsub instance ([#922](https://github.com/libp2p/js-libp2p/issues/922)) ([086b0ec](https://github.com/libp2p/js-libp2p/commit/086b0ec0df2fac93845d0a0a6b2e2464e869afcd))
* dht configuration selectors and validators ([#919](https://github.com/libp2p/js-libp2p/issues/919)) ([cc1f4af](https://github.com/libp2p/js-libp2p/commit/cc1f4af879a58e94538591851d0085ff98cd2641))
# [0.31.0-rc.4](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.3...v0.31.0-rc.4) (2021-04-20)
### Bug Fixes
* add clientMode dht arg and upgrade interface-datastore ([#918](https://github.com/libp2p/js-libp2p/issues/918)) ([975e779](https://github.com/libp2p/js-libp2p/commit/975e77991e67dd9bff790b83df7bd6fa5ddcfc67))
* do not add abort signals to useless addresses ([#913](https://github.com/libp2p/js-libp2p/issues/913)) ([06e8f3d](https://github.com/libp2p/js-libp2p/commit/06e8f3dd42432e4b37ab7904b02abde7d1cadda3))
* specify pbjs root ([#917](https://github.com/libp2p/js-libp2p/issues/917)) ([b043bca](https://github.com/libp2p/js-libp2p/commit/b043bca607565cf534771e6cf975288a8ff3030b))
# [0.31.0-rc.3](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.2...v0.31.0-rc.3) (2021-04-19)
### Bug Fixes
* remove inline arg types from function definitions ([#916](https://github.com/libp2p/js-libp2p/issues/916)) ([2af692f](https://github.com/libp2p/js-libp2p/commit/2af692fb4de572168524ae684608fc6526de4ef7))
# [0.31.0-rc.2](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.1...v0.31.0-rc.2) (2021-04-16)
### Bug Fixes
* metrics stats and moving averages types ([#915](https://github.com/libp2p/js-libp2p/issues/915)) ([3d0a79e](https://github.com/libp2p/js-libp2p/commit/3d0a79eff3bc34a5bdc8ffa31e9b09345a02ad9d))
# [0.31.0-rc.1](https://github.com/libp2p/js-libp2p/compare/v0.31.0-rc.0...v0.31.0-rc.1) (2021-04-16)
### Bug Fixes
* dial protocol should throw if no protocol is provided ([#914](https://github.com/libp2p/js-libp2p/issues/914)) ([21c9aee](https://github.com/libp2p/js-libp2p/commit/21c9aeecb13440238aa6b0fb5a6731d2f87d4938))
### BREAKING CHANGES
* dialProtocol does not return connection when no protocols are provided
# [0.31.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.30.12...v0.31.0-rc.0) (2021-04-15)
## [0.30.12](https://github.com/libp2p/js-libp2p/compare/v0.30.11...v0.30.12) (2021-03-27)
### Bug Fixes
* the API of es6-promisify is not the same as promisify-es6 ([#905](https://github.com/libp2p/js-libp2p/issues/905)) ([a7128f0](https://github.com/libp2p/js-libp2p/commit/a7128f07ec8d4b729145ecfc6ad1d585ffddea46))
## [0.30.11](https://github.com/libp2p/js-libp2p/compare/v0.30.10...v0.30.11) (2021-03-23)
### Bug Fixes
* connection direction should be only inbound or outbound ([9504f19](https://github.com/libp2p/js-libp2p/commit/9504f1951a3cca55bb7b4e25e4934e4024034ee8))
* interface-datastore update ([f5c1cd1](https://github.com/libp2p/js-libp2p/commit/f5c1cd1fb07bc73cf9d9da3c2eb4327bed4279a4))
## [0.30.10](https://github.com/libp2p/js-libp2p/compare/v0.30.9...v0.30.10) (2021-03-09)
### Bug Fixes
* conn mgr access to moving averages record object ([#897](https://github.com/libp2p/js-libp2p/issues/897)) ([5f702f3](https://github.com/libp2p/js-libp2p/commit/5f702f3481afd4ad4fbc89f0e9b75a6d56b03520))
## [0.30.9](https://github.com/libp2p/js-libp2p/compare/v0.30.8...v0.30.9) (2021-02-25)
### Bug Fixes
* transport manager fault tolerance should include tolerance to transport listen fail ([#893](https://github.com/libp2p/js-libp2p/issues/893)) ([3f314d5](https://github.com/libp2p/js-libp2p/commit/3f314d5e90f74583b721386d0c9c5d8363cd4de7))
## [0.30.8](https://github.com/libp2p/js-libp2p/compare/v0.30.7...v0.30.8) (2021-02-11)
### Bug Fixes
* routers should only use dht if enabled ([#885](https://github.com/libp2p/js-libp2p/issues/885)) ([a34d2bb](https://github.com/libp2p/js-libp2p/commit/a34d2bbcc3d69ec3006137a909a7e8c53b9d378e))
## [0.30.7](https://github.com/libp2p/js-libp2p/compare/v0.30.6...v0.30.7) (2021-02-01)
### Bug Fixes
* do not add observed address received from peers ([#882](https://github.com/libp2p/js-libp2p/issues/882)) ([a36b211](https://github.com/libp2p/js-libp2p/commit/a36b2112aafcee309a02de0cff5440cf69cd53a7))
## [0.30.6](https://github.com/libp2p/js-libp2p/compare/v0.30.5...v0.30.6) (2021-01-29)
### Bug Fixes
* peer discovery type in config ([#878](https://github.com/libp2p/js-libp2p/issues/878)) ([3e7594f](https://github.com/libp2p/js-libp2p/commit/3e7594f69733bf374b374a6065458fa6cae81c5f))
* unref nat manager retries ([#877](https://github.com/libp2p/js-libp2p/issues/877)) ([ce2a624](https://github.com/libp2p/js-libp2p/commit/ce2a624a09b3107c0b2b4752e666804ecea54fb5))
## [0.30.5](https://github.com/libp2p/js-libp2p/compare/v0.30.4...v0.30.5) (2021-01-28)
### Bug Fixes
* create has optional peer id type ([#875](https://github.com/libp2p/js-libp2p/issues/875)) ([eeda056](https://github.com/libp2p/js-libp2p/commit/eeda05688330c17b810bf47544ef977386623317))
## [0.30.4](https://github.com/libp2p/js-libp2p/compare/v0.30.3...v0.30.4) (2021-01-27)
### Features
* add UPnP NAT manager ([#810](https://github.com/libp2p/js-libp2p/issues/810)) ([0a6bc0d](https://github.com/libp2p/js-libp2p/commit/0a6bc0d1013dfd80ab600e8f74c1544b433ece29))
## [0.30.3](https://github.com/libp2p/js-libp2p/compare/v0.30.2...v0.30.3) (2021-01-27)
## [0.30.2](https://github.com/libp2p/js-libp2p/compare/v0.30.1...v0.30.2) (2021-01-21)
### Bug Fixes
* store multiaddrs during content and peer routing queries ([#865](https://github.com/libp2p/js-libp2p/issues/865)) ([45c3367](https://github.com/libp2p/js-libp2p/commit/45c33675a7412c66d0fd4e113ef8506077b6f492))
## [0.30.1](https://github.com/libp2p/js-libp2p/compare/v0.30.0...v0.30.1) (2021-01-18)
### Bug Fixes
* event emitter types with local types ([#864](https://github.com/libp2p/js-libp2p/issues/864)) ([6c41e30](https://github.com/libp2p/js-libp2p/commit/6c41e3045608bcae8061d20501be5751dad8157a))
# [0.30.0](https://github.com/libp2p/js-libp2p/compare/v0.29.4...v0.30.0) (2020-12-16)
### Bug Fixes
* remove test/dialing/utils extra file ([689c35e](https://github.com/libp2p/js-libp2p/commit/689c35ed1c68e514293a9895d496e2e8440454e9))
* types from ipfs integration ([#832](https://github.com/libp2p/js-libp2p/issues/832)) ([9ae1b75](https://github.com/libp2p/js-libp2p/commit/9ae1b758e99e3fc9067e26b4eae4c15ccb1ba303))
### chore
* update pubsub ([#801](https://github.com/libp2p/js-libp2p/issues/801)) ([e50c6ab](https://github.com/libp2p/js-libp2p/commit/e50c6abcf2ebc80ebf2dfadd015ab21a20cffadc))
### Features
* auto relay ([#723](https://github.com/libp2p/js-libp2p/issues/723)) ([caf66ea](https://github.com/libp2p/js-libp2p/commit/caf66ea1439f6b75a0c321a16bd5c5d7d6a2bd47))
* auto relay network query for new relays ([0bf0b7c](https://github.com/libp2p/js-libp2p/commit/0bf0b7cf8968d55002ac4c559ffb59985feeb092))
* custom announce filter ([ef9d3ca](https://github.com/libp2p/js-libp2p/commit/ef9d3ca2c6f35d692d6079e74088c5146d46eebe))
* custom dialer addr sorter ([#792](https://github.com/libp2p/js-libp2p/issues/792)) ([585ad52](https://github.com/libp2p/js-libp2p/commit/585ad52b4c71dd7514e99a287e0318b2b837ec48))
* discover and connect to closest peers ([#798](https://github.com/libp2p/js-libp2p/issues/798)) ([baedf3f](https://github.com/libp2p/js-libp2p/commit/baedf3fe5ab946e938db1415d1662452cdfc0cc1))
### 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
# [0.30.0-rc.2](https://github.com/libp2p/js-libp2p/compare/v0.30.0-rc.1...v0.30.0-rc.2) (2020-12-15)
# [0.30.0-rc.1](https://github.com/libp2p/js-libp2p/compare/v0.30.0-rc.0...v0.30.0-rc.1) (2020-12-11)
### Bug Fixes
* types from ipfs integration ([#832](https://github.com/libp2p/js-libp2p/issues/832)) ([216eb97](https://github.com/libp2p/js-libp2p/commit/216eb9730ef473f73a974c3dbaf306ecdc815c8b))
# [0.30.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.29.4...v0.30.0-rc.0) (2020-12-10)

View File

@@ -16,8 +16,8 @@
</p>
<p align="center">
<a href="https://travis-ci.com/libp2p/js-libp2p"><img src="https://flat.badgen.net/travis/libp2p/js-libp2p" /></a>
<a href="https://codecov.io/gh/libp2p/js-libp2p"><img src="https://img.shields.io/codecov/c/github/ipfs/js-ipfs-multipart/master.svg?style=flat-square"></a>
<a href="https://github.com/libp2p/js-libp2p/actions?query=branch%3Amaster+workflow%3Aci+"><img src="https://img.shields.io/github/workflow/status/libp2p/js-libp2p/ci?label=ci&style=flat-square" /></a>
<a href="https://codecov.io/gh/libp2p/js-libp2p"><img src="https://img.shields.io/codecov/c/github/libp2p/js-libp2p/master.svg?style=flat-square"></a>
<a href="https://bundlephobia.com/result?p=ipfsd-ctl"><img src="https://flat.badgen.net/bundlephobia/minzip/ipfsd-ctl"></a>
<br>
<a href="https://david-dm.org/libp2p/js-libp2p"><img src="https://david-dm.org/libp2p/js-libp2p.svg?style=flat-square" /></a>
@@ -147,7 +147,6 @@ List of packages currently in existence for libp2p
| [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | [![npm](https://img.shields.io/npm/v/libp2p-websockets.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-websockets/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-websockets.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websockets) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-websockets/master)](https://travis-ci.com/libp2p/js-libp2p-websockets) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-websockets/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-websockets) | [Jacob Heun](mailto:jacobheun@gmail.com) |
| **secure channels** |
| [`libp2p-noise`](//github.com/NodeFactoryIo/js-libp2p-noise) | [![npm](https://img.shields.io/npm/v/libp2p-noise.svg?maxAge=86400&style=flat-square)](//github.com/NodeFactoryIo/js-libp2p-noise/releases) | [![Deps](https://david-dm.org/NodeFactoryIo/js-libp2p-noise.svg?style=flat-square)](https://david-dm.org/NodeFactoryIo/js-libp2p-noise) | [![Travis CI](https://flat.badgen.net/travis/NodeFactoryIo/js-libp2p-noise/master)](https://travis-ci.com/NodeFactoryIo/js-libp2p-noise) | [![codecov](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise) | N/A |
| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [![npm](https://img.shields.io/npm/v/libp2p-secio.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-secio/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-secio/master)](https://travis-ci.com/libp2p/js-libp2p-secio) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-secio/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-secio) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
| **stream multiplexers** |
| [`libp2p-mplex`](//github.com/libp2p/js-libp2p-mplex) | [![npm](https://img.shields.io/npm/v/libp2p-mplex.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-mplex/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-mplex.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-mplex) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-mplex/master)](https://travis-ci.com/libp2p/js-libp2p-mplex) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-mplex/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-mplex) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
| **peer discovery** |
@@ -164,9 +163,9 @@ List of packages currently in existence for libp2p
| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | [![npm](https://img.shields.io/npm/v/libp2p-kad-dht.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-kad-dht/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-kad-dht.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-kad-dht) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-kad-dht/master)](https://travis-ci.com/libp2p/js-libp2p-kad-dht) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-kad-dht/branch/master/graph/badge.svg?style=flat-square)](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) | [![npm](https://img.shields.io/npm/v/libp2p-crypto.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-crypto/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-crypto.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-crypto) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-crypto/master)](https://travis-ci.com/libp2p/js-libp2p-crypto) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-crypto/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-crypto) | [Jacob Heun](mailto:jacobheun@gmail.com) |
| [`libp2p-crypto-secp256k1`](//github.com/libp2p/js-libp2p-crypto-secp256k1) | [![npm](https://img.shields.io/npm/v/libp2p-crypto-secp256k1.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-crypto-secp256k1/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-crypto-secp256k1.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-crypto-secp256k1) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-crypto-secp256k1/master)](https://travis-ci.com/libp2p/js-libp2p-crypto-secp256k1) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-crypto-secp256k1/branch/master/graph/badge.svg?style=flat-square)](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) | [![npm](https://img.shields.io/npm/v/peer-id.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-peer-id/releases) | [![Deps](https://david-dm.org/libp2p/js-peer-id.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-id) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-peer-id/master)](https://travis-ci.com/libp2p/js-peer-id) | [![codecov](https://codecov.io/gh/libp2p/js-peer-id/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-peer-id) | [Vasco Santos](mailto:santos.vasco10@gmail.com) |
| [`libp2p-record`](//github.com/libp2p/js-libp2p-record) | [![npm](https://img.shields.io/npm/v/libp2p-record.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-record/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-record.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-record) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-record/master)](https://travis-ci.com/libp2p/js-libp2p-record) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-record/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-record) | [Jacob Heun](mailto:santos.vasco10@gmail.com) |
| **pubsub** |
| [`libp2p-floodsub`](//github.com/libp2p/js-libp2p-floodsub) | [![npm](https://img.shields.io/npm/v/libp2p-floodsub.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-floodsub/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-floodsub.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-floodsub) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-floodsub/master)](https://travis-ci.com/libp2p/js-libp2p-floodsub) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-floodsub/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-floodsub) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
| [`libp2p-gossipsub`](//github.com/ChainSafe/js-libp2p-gossipsub) | [![npm](https://img.shields.io/npm/v/libp2p-gossipsub.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/js-libp2p-gossipsub/releases) | [![Deps](https://david-dm.org/ChainSafe/js-libp2p-gossipsub.svg?style=flat-square)](https://david-dm.org/ChainSafe/js-libp2p-gossipsub) | [![Travis CI](https://flat.badgen.net/travis/ChainSafe/js-libp2p-gossipsub/master)](https://travis-ci.com/ChainSafe/js-libp2p-gossipsub) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub) | [Cayman Nava](mailto:caymannava@gmail.com) |

2
dist/index.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,17 +0,0 @@
/*!
* 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
*/

View File

@@ -1,50 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,106 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,70 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,18 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,56 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,10 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/circuit/circuit/utils.js"],"names":[],"mappings":";;AAuBA;;;;;GAKG;AACH,8FAsBC"}

View File

@@ -1,7 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/circuit/constants.js"],"names":[],"mappings":""}

View File

@@ -1,69 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,5 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/circuit/listener.js"],"names":[],"mappings":"AAciB,kCAHN,OAAO,KAAK,CAAC,GACX,QAAQ,CA+DpB"}

View File

@@ -1,2 +0,0 @@
export const relay: string;
//# sourceMappingURL=multicodec.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"multicodec.d.ts","sourceRoot":"","sources":["../../../src/circuit/multicodec.js"],"names":[],"mappings":""}

View File

@@ -1,5 +0,0 @@
declare const _exports: {
CircuitRelay: import('../../types').CircuitMessageProto;
};
export = _exports;
//# sourceMappingURL=index.d.ts.map

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,84 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,2 +0,0 @@
export function namespaceToCid(namespace: string): Promise<import("cids")>;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/circuit/utils.js"],"names":[],"mappings":"AAagC,0CAHrB,MAAM,GACJ,uBAAY,CAOxB"}

View File

@@ -1,2 +0,0 @@
export function validate(opts: any): any;
//# sourceMappingURL=config.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.js"],"names":[],"mappings":"AAuF0B,yCAMzB"}

View File

@@ -1,203 +0,0 @@
/// <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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,134 +0,0 @@
/// <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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,62 +0,0 @@
/// <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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,10 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.js"],"names":[],"mappings":""}

View File

@@ -1,93 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,55 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,157 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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
View File

@@ -1,35 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.js"],"names":[],"mappings":""}

View File

@@ -1,20 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,5 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/identify/consts.js"],"names":[],"mappings":""}

View File

@@ -1,98 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,3 +0,0 @@
declare const _exports: any;
export = _exports;
//# sourceMappingURL=message.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/identify/message.js"],"names":[],"mappings":""}

288
dist/src/index.d.ts vendored
View File

@@ -1,288 +0,0 @@
/// <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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,11 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"plaintext.d.ts","sourceRoot":"","sources":["../../../src/insecure/plaintext.js"],"names":[],"mappings":";AAYA,0CAAmC;AA4DlB;;;GAEd;AACe;;;GAEf"}

View File

@@ -1,3 +0,0 @@
declare const _exports: any;
export = _exports;
//# sourceMappingURL=proto.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../../src/insecure/proto.js"],"names":[],"mappings":""}

View File

@@ -1,41 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,147 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,13 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/keychain/util.js"],"names":[],"mappings":"AAmB4B,8DAFf,UAAU,CAqDtB;AAED;;;;;;;;;GASG;AACH,wFAKC"}

View File

@@ -1,154 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,3 +0,0 @@
declare function _exports(maxSize: number): any;
export = _exports;
//# sourceMappingURL=old-peers.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"old-peers.d.ts","sourceRoot":"","sources":["../../../src/metrics/old-peers.js"],"names":[],"mappings":"AAUiB,mCAHN,MAAM,GACJ,GAAG,CAOf"}

View File

@@ -1,121 +0,0 @@
/// <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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,63 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,120 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,80 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,129 +0,0 @@
/// <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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,24 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,49 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,6 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../src/peer-store/persistent/consts.js"],"names":[],"mappings":""}

View File

@@ -1,123 +0,0 @@
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

View File

@@ -1 +0,0 @@
{"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"}

View File

@@ -1,3 +0,0 @@
declare const _exports: any;
export = _exports;
//# sourceMappingURL=address-book.proto.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"address-book.proto.d.ts","sourceRoot":"","sources":["../../../../../src/peer-store/persistent/pb/address-book.proto.js"],"names":[],"mappings":""}

Some files were not shown because too many files have changed in this diff Show More