35 Commits

Author SHA1 Message Date
Alex Potsides
a15254fdd4
fix: update to new interfaces (#1206)
Notably removes the `Dialer` interface as the `ConnectionManager` is now in charge of managing connections.
2022-05-04 10:19:04 +01:00
Alex Potsides
c64a586a20
chore: update aegir to the latest version (#1186)
Removes boilerplate config that is no longer necessary
2022-04-09 09:26:25 +01:00
Alex Potsides
199395de4d
feat: convert to typescript (#1172)
Converts this module to typescript.

- Ecosystem modules renamed from (e.g.) `libp2p-tcp` to `@libp2p/tcp`
- Ecosystem module now have named exports
- Configuration has been updated, now pass instances of modules instead of classes:
- Some configuration keys have been renamed to make them more descriptive.  `transport` -> `transports`, `connEncryption` -> `connectionEncryption`.  In general where we pass multiple things, the key is now plural, e.g. `streamMuxer` -> `streamMuxers`, `contentRouting` -> `contentRouters`, etc.  Where we are configuring a singleton the config key is singular, e.g. `connProtector` -> `connectionProtector` etc.
- Properties of the `modules` config key have been moved to the root
- Properties of the `config` config key have been moved to the root
```js
// before
import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'

await Libp2p.create({
  modules: {
    transport: [
      TCP
    ],
  }
  config: {
    transport: {
      [TCP.tag]: {
        foo: 'bar'
      }
    },
    relay: {
      enabled: true,
      hop: {
        enabled: true,
        active: true
      }
    }
  }
})
```
```js
// after
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'

await createLibp2p({
  transports: [
    new TCP({ foo: 'bar' })
  ],
  relay: {
    enabled: true,
    hop: {
      enabled: true,
      active: true
    }
  }
})
```
- Use of `enabled` flag has been reduced - previously you could pass a module but disable it with config.  Now if you don't want a feature, just don't pass an implementation.   Eg:
```js
// before
await Libp2p.create({
  modules: {
    transport: [
      TCP
    ],
    pubsub: Gossipsub
  },
  config: {
    pubsub: {
      enabled: false
    }
  }
})
```
```js
// after
await createLibp2p({
  transports: [
    new TCP()
  ]
})
```
- `.multiaddrs` renamed to `.getMultiaddrs()` because it's not a property accessor, work is done by that method to calculate announce addresses, observed addresses, etc
- `/p2p/${peerId}` is now appended to all addresses returned by `.getMultiaddrs()` so they can be used opaquely (every consumer has to append the peer ID to the address to actually use it otherwise).  If you need low-level unadulterated addresses, call methods on the address manager.

BREAKING CHANGE: types are no longer hand crafted, this module is now ESM only
2022-03-28 14:30:27 +01:00
Vasco Santos
3d25ff7fd0 chore: use new libp2p-noise 2021-08-20 09:13:21 +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
975e4b0fe0 chore: increase bundle size 2021-03-23 09:39:28 +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
Vasco Santos
1af8472dc6
chore: add transports example (#851) 2021-02-11 11:12:23 +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
037c965a67
chore: update deps (#869) 2021-01-27 09:45:31 +01:00
Vasco Santos
55c9bfac44 feat: gossipsub 1.1 (#733)
* feat: gossipsub 1.1

BREAKING CHANGE: pubsub implementation is now directly exposed and its API was updated according to the new pubsub interface in js-libp2p-interfaces repo

* chore: use gossipsub branch with src added

* fix: add pubsub handlers adapter

* chore: fix deps

* chore: update pubsub docs and examples

* chore: apply suggestions from code review

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

* chore: use new floodsub

* chore: change validator doc set

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

* chore: add new gossipsub src

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-08-27 15:38:01 +02:00
Alex Potsides
1e869717ff fix: replace node buffers with uint8arrays (#730)
* fix: replace node buffers with uint8arrays

Upgrades all deps and replaces all use of node Buffers with Uint8Arrays

BREAKING CHANGES:

- All deps used by this module now use Uint8Arrays in place of node Buffers

* chore: browser fixes

* chore: remove .only

* chore: stringify uint8array before parsing

* chore: update interop suite

* chore: remove ts from build command

* chore: update deps

* fix: update records to use uint8array

* chore: fix lint

* chore: update deps

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-08-27 15:38:01 +02:00
Vasco Santos
dab1c8b2a5 chore: increase bundle size 2020-08-27 15:38:01 +02:00
Vasco Santos
9ccab40fc8
fix: not dial all known peers in parallel on startup (#698)
* fix: not dial all known peers on startup

* feat: connection manager should proactively connect to peers from peerStore

* chore: increase bundle size

* fix: do connMgr proactive dial on an interval

* chore: address review

* chore: use retimer reschedule

* chore: address review

* fix: use minConnections in default config

* chore: minPeers to minConnections everywhere
2020-07-14 16:05:26 +02:00
Vasco Santos
6065923356 chore: integrate libp2p-keychain into js-libp2p (#633)
Integrates the libp2p-keychain codebase into this repo
2020-05-28 12:37:48 +02:00
Vasco Santos
43630f1e0b test: use libp2p-noise (#585)
* chore: use libp2p-noise

* chore: address review
2020-05-28 12:37:48 +02:00
Vasco Santos
12e48adafa chore: remove peer-info usage
BREAKING CHANGE: all API methods with peer-info parameters or return values were changed. You can check the API.md document, in order to check the new values to use
2020-05-28 12:37:48 +02:00
Vasco Santos
3fa1fa3a0b chore: increase max bundle size to 185kB 2020-05-11 11:00:13 +02:00
Hugo Dias
9b13fe321a
fix: remove node global (#587)
* fix: use new libp2p-crypto

* fix: remove node globals and reduce size

- adds buffer require
- adds globalThis where needed
- streaming-iterables was remove and new utils created, this will be consolidated in `ipfs-utils` and backported here to normalize all these iterator helper functions
- latency-monitor was copied inside the repo
- iso-random-stream is now used instead of node crypto
- the test `should ignore self on discovery` was moved to node only

Size: 172.97KB
47.03KB below the 220KB limit.

`aegir build --node false` and `aegir test -t browser --node false` now work 🎉

* fix: fix require path

* fix: feedback

* fix: update deps and bundle size

* chore: bump interfaces

* chore: update size
2020-04-24 17:10:40 +02:00
Jacob Heun
f77ce39484 refactor: circuit relay to async (#477)
* refactor: add dialing over relay support

* chore: fix lint

* fix: dont clear listeners on close

* fix: if dial errors already have codes, just rethrow them

* fix: clear the registrar when libp2p stops

* fix: improve connection maintenance with circuit

* chore: correct feedback

* test: use chai as promised

* test(fix): reset multiaddrs on dial test
2020-01-24 14:40:40 +01:00
Jacob Heun
f28b09fc0d refactor: update secio and tests to use it (#484)
* refactor: use async secio

* test: add secio to most test suites

* chore: update secio version
2020-01-24 14:40:40 +01:00
Jacob Heun
fe2a8eddbb refactor: crypto and pnet (#469)
* feat: add initial plaintext 2 module

* refactor: initial refactor of pnet

* chore: fix lint

* fix: update plaintext api usage

* test: use plaintext for test crypto

* chore: update deps

test: update dialer suite scope

* feat: add connection protection to the upgrader

* refactor: cleanup and lint fix

* chore: remove unncessary transforms

* chore: temporarily disable bundlesize

* chore: add missing dep

* fix: use it-handshake to prevent overreading

* chore(fix): PR feedback updates

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
2020-01-24 14:40:40 +01:00
Jacob Heun
440fbf0c04 refactor(async): update transports subsystem (#461)
* test: remove all tests for a clean slate

The refactor will require a large number of updates to the tests. In order
to ensure we have done a decent deduplication, and have a cleaner suite of tests
we've removed all tests. This will also allow us to more easily see tests
for the refactored systems.

We have a record of the latest test suites in master, so we are not losing any history.

* chore: update tcp and websockets
* chore: remove other transports until they are converted
* chore: use mafmt and multiaddr async versions
* chore: add and fix dependencies
* chore: clean up travis file
* feat: add new transport manager
* docs: add constructor jsdocs
* refactor(config): check that transports exist
This also removes the other logic, it can be added when those subsystems are refactored

* chore(deps): use async peer-id and peer-info
* feat: wire up the transport manager with libp2p
* chore: remove superstruct dep
2020-01-24 14:40:40 +01:00
Jacob Heun
b3deb356f1
fix: reference files directly to avoid npm install failures (#408) 2019-08-21 10:23:06 +02:00
Jacob Heun
fd738f9d51
refactor: add js-libp2p-switch to the libp2p codebase (#388)
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Co-authored-by: Alan Shaw <alan@tableflip.io>
Co-authored-by: Arnaud <arnaud.valensi@gmail.com>
Co-authored-by: David Dias <daviddias.p@gmail.com>
Co-authored-by: David Dias <mail@daviddias.me>
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
Co-authored-by: Francisco Baio Dias <xicombd@gmail.com>
Co-authored-by: Friedel Ziegelmayer <dignifiedquire@gmail.com>
Co-authored-by: Haad <haadcode@users.noreply.github.com>
Co-authored-by: Hugo Dias <mail@hugodias.me>
Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Kevin Kwok <antimatter15@gmail.com>
Co-authored-by: Kobi Gurkan <kobigurk@gmail.com>
Co-authored-by: Maciej Krüger <mkg20001@gmail.com>
Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Michael Fakhry <fakhrimichael@live.com>
Co-authored-by: Oli Evans <oli@tableflip.io>
Co-authored-by: Pau Ramon Revilla <masylum@gmail.com>
Co-authored-by: Pedro Teixeira <i@pgte.me>
Co-authored-by: Pius Nyakoojo <piusnyakoojo@gmail.com>
Co-authored-by: Richard Littauer <richard.littauer@gmail.com>
Co-authored-by: Sid Harder <sideharder@gmail.com>
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
Co-authored-by: harrshasri <35241544+harrshasri@users.noreply.github.com>
Co-authored-by: kumavis <kumavis@users.noreply.github.com>
Co-authored-by: ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>
2019-08-08 19:01:16 +02:00
Jacob Heun
ff7a6c86a0
fix: promisified methods (#398)
* chore: update ws rendezvous dep

test(fix): fix tests with latest ws rendezvous server

* fix: promisification of libp2p methods

test: add tests to verify promisify support until async/await endeavor is complete

* chore: fix linting
2019-08-06 10:53:23 +02:00
Jacob Heun
9433c6c398
docs: add createLibp2p to readme (#368)
* chore: update deps
* test(fix): account for wrtcrendezvous now being thenable
2019-06-07 15:50:23 +02:00
Jacob Heun
01aa44724e
feat: auto dial discovered peers (#349) 2019-04-11 12:44:58 +02:00
Jacob Heun
e5f19e860b
fix: remove unneeded peerbook puts (#348) 2019-04-05 14:27:35 +02:00
Jacob Heun
9f5f07269e
test: add circuit browser test (#326) 2019-02-25 13:44:56 +01:00
Hugo Dias
d497961938 fix: bundle-size (#298)
* fix: bundle-size

* fix: feedback

* fix: lint

* chore: update deps

* fix: add bundle size check and update deps

* fix: fix badges

* fix: add once to package.json

* fix: fix config validation
2019-02-21 17:07:35 +01:00
David Dias
6905f1ba41
feat: (BREAKING CHANGE) overhaul libp2p config and constructor
* docs: update chat example and add info to its readme
* docs: update echo example
* docs: update libp2p in browser example
* docs: update pubsub example
* docs: update peer and content routing examples
* docs: update discovery mechanisms example
* docs: update encrypted comms example
* docs: update protocol and stream muxing example
* feat: add config validation
* test: update CI configs, use only node 8
2018-06-28 10:06:25 +02:00
David Dias
f602cd9f79
test: use that crypto puzzle! (#135) 2017-12-01 09:19:44 +00:00
Maciej Krüger
95f029eb7a feat: Bring libp2p-websocket-star to the Transports family! 🌟 (#122)
* test: add libp2p-websocket-star tests

* refactor: websocket-star-{signal => rendezvous}

* misc: Apply requested changes

* chore: update deps

* refactor: considerable amount of refactor, clean up test structure

* use right flag

* test: refactor transport tests
2017-11-27 09:10:36 +00:00
Dmitriy Ryajov
29cc0afc64 feat: enable and test Circuit Relay
* feat: new super simplified API

* feat: append peer id to multiaddr if not there

* [WIP] Awesome DHT (#86)

* feat: integrate dht

* better interfaces

* docs: add documentation for peerRouting, contentRouting, dht

* fix: take in passed datastore

* fix: update usage of _getPeerInfo

* fix: getPeerInfo

* docs: update docs

* moar

feat: correctly handle p2p-circuit addrs when creating a peer info object

refactor: rework config options

* feat: adding circuit relaying

* feat: rework circuit relay for protobufs

* feat: circuit loading and tests

* fix: clean up _getPeerInfo to work with /p2p-circuit

* wip: tests cleaup

* test: clean up

* wip

* fix: bringing back test reworks and new aegir

* test: group tests

* test: clean up

* test: adjust test

* fix: use getPeerId to determine if the ipfs fragment is missing

* feat: adding circuit relaying

* feat: circuit loading and tests

* test: clean up

* wip

* feat: upgrade to latest aegir

* fix: removing unused tests

* feat: cleanup tests

* fix: create node defautl options

* chore: upgrade swarm to latest version

* fix: updated aegir and adjust timeouts

* feat: more timeouts

* chore: updating deps

* fix: circle ci builds

* test: timeouts
2017-10-26 12:51:36 +01:00