4.0.31 • Published 2 days ago

@libp2p/webrtc v4.0.31

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
2 days ago

@libp2p/webrtc

libp2p.io Discuss codecov CI

A libp2p transport using WebRTC connections

Table of contents

Install

$ npm i @libp2p/webrtc

Browser <script> tag

Loading this module through a script tag will make it's exports available as Libp2pWebrtc in the global namespace.

<script src="https://unpkg.com/@libp2p/webrtc/dist/index.min.js"></script>

Usage

import { createLibp2p } from 'libp2p'
import { noise } from '@chainsafe/libp2p-noise'
import { multiaddr } from '@multiformats/multiaddr'
import first from 'it-first'
import { pipe } from 'it-pipe'
import { fromString, toString } from 'uint8arrays'
import { webRTC } from '@libp2p/webrtc'

const node = await createLibp2p({
  transports: [webRTC()],
  connectionEncryption: [noise()],
});

await node.start()

const ma =  multiaddr('/ip4/0.0.0.0/udp/56093/webrtc/certhash/uEiByaEfNSLBexWBNFZy_QB1vAKEj7JAXDizRs4_SnTflsQ')
const stream = await node.dialProtocol(ma, ['/my-protocol/1.0.0'])
const message = `Hello js-libp2p-webrtc\n`
const response = await pipe([fromString(message)], stream, async (source) => await first(source))
const responseDecoded = toString(response.slice(0, response.length))

Examples

Examples can be found in the examples folder.

Interfaces

Transport

https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-transport

Browsers can usually only dial, but listen is supported in the WebRTC transport when paired with another listener like CircuitV2, where you listen on a relayed connection. Take a look at index.js for an example.

Connection

https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-connection

interface MultiaddrConnection extends Duplex<Uint8Array> {
  close: (err?: Error) => Promise<void>
  remoteAddr: Multiaddr
  timeline: MultiaddrConnectionTimeline
}

class WebRTCMultiaddrConnection implements MultiaddrConnection { }

Development

Contributions are welcome! The libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:

  • Check out the existing issues.
  • Perform code reviews.
  • Add tests. There can never be enough tests.
  • Go through the modules and check out existing issues. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.

Please be aware that all interactions related to libp2p are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

This module leans heavily on (Aegir)[https://github.com/ipfs/aegir] for most of the package.json scripts.

Build

The build script is a wrapper to aegir build. To build this package:

npm run build

The build will be located in the /dist folder.

Protocol Buffers

There is also npm run generate:proto script that uses protoc to populate the generated code directory proto_ts based on *.proto files in src. Don't forget to run this step before build any time you make a change to any of the *.proto files.

Test

To run all tests:

npm test

To run tests for Chrome only:

npm run test:chrome

To run tests for Firefox only:

npm run test:firefox

Lint

Aegir is also used to lint the code, which follows the Standard JS linter. The VS Code plugin for this standard is located at https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard. To lint this repo:

npm run lint

You can also auto-fix when applicable:

npm run lint:fix

Clean

npm run clean

Check Dependencies

npm run deps-check

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

4.0.31

2 days ago

4.0.30

3 days ago

4.0.29

9 days ago

4.0.28-2281f802b

10 days ago

4.0.28-fd1f8343d

11 days ago

4.0.28-eaf8ac7cf

11 days ago

4.0.28-acef72613

12 days ago

4.0.28

17 days ago

4.0.27-ea4f26285

17 days ago

4.0.26-31c78f4ed

18 days ago

4.0.25-b17824a1d

21 days ago

4.0.26

21 days ago

4.0.25-2c56203f9

21 days ago

4.0.24-936dbba10

24 days ago

4.0.24-732c436d4

24 days ago

4.0.25

24 days ago

4.0.24-2b2958fe6

25 days ago

4.0.24

28 days ago

4.0.23-3e515f007

28 days ago

4.0.23-d446c6c31

29 days ago

4.0.23-a2b41f793

1 month ago

4.0.23-80278b36b

1 month ago

4.0.23-afe15f669

1 month ago

4.0.23-4fc0a7d30

1 month ago

4.0.23-1f589c822

1 month ago

4.0.23-ab5f05763

1 month ago

4.0.23-3ffecc5bf

1 month ago

4.0.22-59a97b61b

1 month ago

4.0.22-330a5ed72

1 month ago

4.0.23

1 month ago

4.0.22-82901e785

1 month ago

4.0.22-1fc929c1c

1 month ago

4.0.22-bf720c045

1 month ago

4.0.22

2 months ago

4.0.21

2 months ago

4.0.21-fad3074b8

2 months ago

4.0.21-cad9cf007

2 months ago

4.0.21-e1798aa26

2 months ago

4.0.20-f39ce5f13

2 months ago

4.0.20-83ef3717e

2 months ago

4.0.20-ab466004b

2 months ago

4.0.20-a9cc0ee49

2 months ago

4.0.20-28e51652a

2 months ago

4.0.20-2122a713d

2 months ago

4.0.20-f71bc49bd

2 months ago

4.0.20

2 months ago

4.0.19-f0d2b52d0

2 months ago

4.0.19-bedfd0aa2

2 months ago

4.0.19-8072a2e59

2 months ago

4.0.19-b1b77adb4

2 months ago

4.0.19-e1c01370b

2 months ago

4.0.19-fb7c51c3c

3 months ago

4.0.17-03ff9fd82

3 months ago

4.0.17-9891ecd73

3 months ago

4.0.19

3 months ago

4.0.17-dab5cf724

3 months ago

4.0.18

3 months ago

4.0.17-0321812e7

3 months ago

4.0.18-0c7bbbb07

3 months ago

4.0.17-2370d1c39

3 months ago

4.0.17-1cb2408ac

3 months ago

4.0.17-e1db332a4

3 months ago

4.0.17-6f323de7d

3 months ago

4.0.17-c9ed1c7d6

3 months ago

4.0.16-72f0e09f7

3 months ago

4.0.17

3 months ago

4.0.16-dbc92ab74

3 months ago

4.0.16-74fb5671d

3 months ago

4.0.16-f4dda4a3c

3 months ago

4.0.16-2e464c099

3 months ago

4.0.16-08f6f607d

4 months ago

4.0.16-f27138ca1

4 months ago

4.0.16-3e47d88fd

4 months ago

4.0.16-9376e61a1

4 months ago

4.0.16-74477f6ea

4 months ago

4.0.16-8c6654c3a

4 months ago

4.0.16

4 months ago

4.0.15-092861e23

4 months ago

4.0.15

4 months ago

4.0.14-ddaa59a60

4 months ago

4.0.14-856ccd708

4 months ago

4.0.15-8bbd43628

4 months ago

4.0.14-4691f4173

4 months ago

4.0.14-900236724

4 months ago

4.0.14-821a38e24

4 months ago

4.0.13-d011f6130

4 months ago

4.0.13-528d73781

4 months ago

4.0.14

4 months ago

4.0.13-444d83751

4 months ago

4.0.13-581574d6d

4 months ago

4.0.13-388d02b33

4 months ago

4.0.13-ba7089984

4 months ago

4.0.13

4 months ago

4.0.12-5d1f68e92

4 months ago

4.0.12-28587d24f

4 months ago

4.0.12-4e0135c7d

4 months ago

4.0.11-cd8cafcd5

5 months ago

4.0.11-178fe2671

5 months ago

4.0.12

5 months ago

4.0.11-6fd681d09

5 months ago

4.0.11-c00378909

5 months ago

4.0.11-83dfc7dc8

5 months ago

4.0.10-07f3afe2d

5 months ago

4.0.10-984f13e42

5 months ago

4.0.11

5 months ago

4.0.10-ad6f70bf3

5 months ago

4.0.10-f71f2e14e

5 months ago

4.0.10-a7c6a93c6

5 months ago

4.0.10-9eff7eff0

5 months ago

4.0.10-230afea4b

5 months ago

4.0.10-f81be145a

5 months ago

4.0.10-01e9a5fe4

5 months ago

4.0.10

5 months ago

4.0.10-742915567

5 months ago

4.0.9-341581166

5 months ago

4.0.9-6d11e8268

5 months ago

4.0.9

5 months ago

4.0.8-d10506189

5 months ago

4.0.8-64a915ae9

5 months ago

4.0.8-3bf6387ff

5 months ago

4.0.8-93890c8f9

5 months ago

4.0.7

5 months ago

4.0.8

5 months ago

4.0.6-16588d27c

5 months ago

4.0.7-887c6ffe1

5 months ago

3.2.8-78db573f9

6 months ago

3.2.11-adea7bbbf

6 months ago

3.2.1-e9099d40

7 months ago

2.0.10-b1024c6c

9 months ago

3.2.11-3dee5df4d

6 months ago

2.0.10-7debe031

9 months ago

4.0.1-561797a89

5 months ago

3.1.7-01acccef

8 months ago

3.2.2

7 months ago

3.2.1

7 months ago

4.0.5-bcfa15993

5 months ago

3.2.0

8 months ago

2.0.10-a41d25d4

9 months ago

3.2.6

6 months ago

3.2.5

6 months ago

3.2.4

6 months ago

3.2.3

7 months ago

3.2.11-0b4a2ee79

5 months ago

4.0.0-06e6d235f

5 months ago

3.2.11-e2267d437

5 months ago

3.1.8-0634e3b7

8 months ago

4.0.5

5 months ago

4.0.4

5 months ago

4.0.6

5 months ago

4.0.1

5 months ago

4.0.0

5 months ago

3.2.1-f1053159

7 months ago

4.0.3

5 months ago

4.0.2

5 months ago

3.2.11-74e84bc29

5 months ago

3.2.5-50442d7a

6 months ago

2.0.10-06f4901a

10 months ago

3.1.7-32825633

8 months ago

3.2.7-dfbe0cc0

6 months ago

3.1.3-eaac8943

9 months ago

3.2.0-f09ac4a7

7 months ago

3.1.3-5e85154b

9 months ago

2.0.10-5315f7bc

10 months ago

3.1.10-4db2f5f5

8 months ago

3.1.9-c4eff4c5

8 months ago

2.0.10-daeb43d8

10 months ago

3.2.9

6 months ago

4.0.3-e7167fe52

5 months ago

3.2.10-c960eb659

6 months ago

3.2.8

6 months ago

3.2.7

6 months ago

3.1.9-5294f14c

8 months ago

3.0.0-e66f4891

9 months ago

3.1.7-9a69e6f7

8 months ago

2.0.10-c999d6a7

9 months ago

3.1.3

9 months ago

3.2.11-05b52d69c

6 months ago

3.1.2

9 months ago

4.0.0-a32e70bac

5 months ago

3.1.1

9 months ago

3.1.7

8 months ago

3.1.6

9 months ago

3.1.5

9 months ago

3.2.5-69581367

6 months ago

3.1.4

9 months ago

3.1.3-9c0353cf

9 months ago

2.0.10-1f7e18b0

9 months ago

3.2.3-7534ae7b

6 months ago

4.0.0-bcf18265e

5 months ago

3.1.3-02b89323

9 months ago

3.2.11

6 months ago

3.2.6-f4fac961

6 months ago

3.2.2-cf3ae893

7 months ago

3.2.10

6 months ago

3.2.11-7877a50e0

5 months ago

3.1.3-e26848b0

9 months ago

4.0.1-bca8d6e68

5 months ago

3.1.6-89778624

8 months ago

3.2.4-50f912c2

6 months ago

3.2.0-6640116d

8 months ago

3.1.2-446fff87

9 months ago

3.1.4-6abcd22f

9 months ago

3.2.11-bb6ceb192

5 months ago

3.1.3-a1fbb7e2

9 months ago

2.0.10-6eab9c5e

10 months ago

3.1.10-88c47f51

8 months ago

3.2.0-91842c93

7 months ago

3.1.3-32212959

9 months ago

3.2.8-1d141331a

6 months ago

3.2.1-28794fe4

7 months ago

3.2.2-62a56b54

7 months ago

3.1.9

8 months ago

3.1.8

8 months ago

3.1.0-a4a10fd4

9 months ago

3.0.0

9 months ago

3.2.5-346ff5a2

6 months ago

3.1.1-58421e11

9 months ago

3.1.3-a31b420f

9 months ago

3.2.3-68504939

6 months ago

3.2.0-b57bca44

7 months ago

2.0.10-5eee70a4

10 months ago

3.1.3-6b839807

9 months ago

3.1.1-5ffa7a74

9 months ago

3.1.7-13f5b48e

8 months ago

2.0.10-e9cafd3d

10 months ago

3.2.1-f670307a

7 months ago

3.1.9-28d6722f

8 months ago

3.2.10-effcfaa8e

6 months ago

3.1.8-2b755a82

8 months ago

3.2.5-d5ef1c91

6 months ago

3.2.0-ae36e86b

7 months ago

3.2.5-16a87076

6 months ago

3.2.9-fb8a6f188

6 months ago

3.2.0-e3ab1929

7 months ago

3.1.8-7517082d

8 months ago

2.0.10-a1ec46b5

9 months ago

3.2.6-fdcb801e

6 months ago

3.2.11-9c67c5b3d

6 months ago

3.1.3-4c1a33b3

9 months ago

4.0.3-7861ed882

5 months ago

3.1.3-18567b7c

9 months ago

3.2.11-4a474d54d

5 months ago

3.1.4-4ef9c79c

9 months ago

4.0.1-cf963694f

5 months ago

3.1.4-d9948596

9 months ago

3.1.4-e664d14f

9 months ago

3.2.1-5a6a4379

7 months ago

4.0.5-10ea19700

5 months ago

3.1.0-c858ca7f

9 months ago

3.1.6-098ba082

8 months ago

3.1.4-d30f09f2

9 months ago

3.1.4-87165551

9 months ago

4.0.3-9197f10ba

5 months ago

3.2.0-72319fe6

7 months ago

3.2.3-f9d1c072

6 months ago

2.0.10-7f60b579

9 months ago

3.2.3-ab2c1f67

6 months ago

2.0.10-69c93ac5

9 months ago

3.2.11-68db79f6b

5 months ago

3.2.11-8bb6d5333

5 months ago

3.1.1-8f681db3

9 months ago

3.2.6-051154dd

6 months ago

3.1.9-10cbc8fa

8 months ago

3.2.11-8f921ee97

5 months ago

3.2.0-972b10a9

7 months ago

3.2.11-13a870cbe

6 months ago

3.2.11-6b6ba9ab7

5 months ago

3.2.1-c88de8e1

7 months ago

4.0.2-8c169db1b

5 months ago

3.1.6-24c1c248

8 months ago

3.1.9-0d228f9f

8 months ago

3.2.1-e8123d3f

7 months ago

2.0.10-57c32721

9 months ago

3.2.11-6625a27fc

6 months ago

4.0.0-273d8177c

5 months ago

3.2.5-025c082a

6 months ago

3.2.1-7d8b1551

7 months ago

3.1.6-f3fd7b62

9 months ago

3.2.11-0f5c305af

6 months ago

3.2.9-70d5efc2e

6 months ago

3.2.11-d729d66a5

5 months ago

4.0.0-551622a96

5 months ago

3.1.10-20d5f220

8 months ago

3.0.0-ef83dd1d

9 months ago

3.1.6-6a02d765

8 months ago

3.1.11

8 months ago

3.2.2-77e3cbc3

7 months ago

4.0.1-6c1f0ee81

5 months ago

3.1.4-87dc7e9f

9 months ago

3.2.5-b686fb5a

6 months ago

4.0.5-5a9362e21

5 months ago

3.1.10-0ee4f784

8 months ago

3.1.10

8 months ago

4.0.1-53224004f

5 months ago

3.2.8-8b82e68e8

6 months ago

3.2.1-c97dea04

7 months ago

4.0.2-f537b3731

5 months ago

2.0.10-c2232166

9 months ago

3.0.0-72e81dc1

9 months ago

3.1.9-46dc3ce9

8 months ago

4.0.4-738dd40f1

5 months ago

3.2.1-980857c3

7 months ago

3.1.0-8d49602f

9 months ago

3.1.5-725f5df1

9 months ago

3.2.3-b5a808af

6 months ago

3.2.5-7903d7a5

6 months ago

3.1.9-73b87c5a

8 months ago

3.0.0-fdd80820

9 months ago

3.1.7-24a5edae

8 months ago

3.1.7-63041afe

8 months ago

3.1.3-123ded59

9 months ago

3.2.11-97ab31c0c

6 months ago

3.1.10-0ce318ec

8 months ago

3.1.6-b599905c

9 months ago

4.0.0-7682861f9

5 months ago

3.1.8-a6be8f0f

8 months ago

3.1.10-d9159dd5

8 months ago

2.0.10-791f56f0

9 months ago

2.0.10-7b5c54dd

10 months ago

3.2.1-96166ada

7 months ago

3.1.3-3345f28b

9 months ago

4.0.0-8e4fbe13a

5 months ago

3.1.7-4559a624

8 months ago

3.2.11-d8f5bc211

6 months ago

3.1.10-122f1e67

8 months ago

3.1.4-7b2ddc17

9 months ago

4.0.5-09dd02987

5 months ago

3.1.3-364e0592

9 months ago

3.1.0-8f855a3c

9 months ago

3.1.7-a533cc39

8 months ago

3.2.7-d25d9510

6 months ago

3.1.11-6cb80f7d

8 months ago

2.0.10-879f4794

10 months ago

2.0.10-f427cfc9

10 months ago

2.0.10-42c1c097

10 months ago

2.0.10-85a317bb

10 months ago

2.0.10-7fb23cd3

10 months ago

2.0.10-2e561fe9

10 months ago

1.2.0

12 months ago

2.0.10-6fdaa7dc

11 months ago

2.0.10-05abd49f

11 months ago

2.0.10-ea8a0637

11 months ago

2.0.10-d853d124

11 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.0.5

11 months ago

2.0.4

12 months ago

2.0.11

11 months ago

2.0.7

11 months ago

2.0.6

11 months ago

2.0.9

11 months ago

2.0.10

11 months ago

2.0.8

11 months ago

1.1.11

12 months ago

1.1.10

1 year ago

2.0.10-ab0e3980

11 months ago

2.0.1

12 months ago

2.0.0

12 months ago

2.0.10-8b0e6bef

11 months ago

2.0.10-3dfc236e

11 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.0.5

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.0

1 year ago