Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Implement webrtc in js-libp2p #4

Merged
merged 150 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
df4dc22
skeleton structs
ckousik Jul 28, 2022
73b8365
Some changes from David's comments.
John-LittleBearLabs Aug 3, 2022
5b5b4a0
some formatting
John-LittleBearLabs Aug 3, 2022
7e90dbc
Fixing .prettierrc. Thanks Paul.
John-LittleBearLabs Aug 3, 2022
6be6364
Pulling in Chinmay's comments from his branch.
John-LittleBearLabs Aug 3, 2022
9e14b9d
intitial stream logic
ckousik Aug 5, 2022
8defcf8
change timeline
ckousik Aug 5, 2022
340e32a
Merge pull request #5 from little-bear-labs/ckousik/con-432
ckousik Aug 5, 2022
49027ab
Up next: actually shake hands.
John-LittleBearLabs Aug 3, 2022
26656dc
adding noise
John-LittleBearLabs Aug 4, 2022
90cd103
checkpoint
John-LittleBearLabs Aug 4, 2022
2e56aa6
Next step will be easier after merging in Chinmay's latest work.
John-LittleBearLabs Aug 5, 2022
8bc1da5
Making use of Chinmay's Stream.
John-LittleBearLabs Aug 5, 2022
c25b4df
checkpoint
John-LittleBearLabs Aug 5, 2022
e85e3f3
Updating to latest interface-connection
John-LittleBearLabs Aug 8, 2022
6ed4634
Use p-defer
John-LittleBearLabs Aug 8, 2022
0aa9dc4
This looks right-ish to me. Need better error type and testing.
John-LittleBearLabs Aug 9, 2022
fbce43c
Added an SDP test to get started.
John-LittleBearLabs Aug 9, 2022
0999b49
Transport implements initializable
ckousik Aug 10, 2022
a1147d2
Update libp2p-noise reference from local directory to a hash in the u…
John-LittleBearLabs Aug 10, 2022
0ce1b0a
Merge pull request #6 from little-bear-labs/jt/con-428_dial
John-LittleBearLabs Aug 10, 2022
12cf00a
Merge branch 'jt/con-428_dial' into ckousik/transport-initializable
John-LittleBearLabs Aug 10, 2022
688dc3e
Merge pull request #11 from little-bear-labs/ckousik/transport-initia…
ckousik Aug 10, 2022
2a8f5af
Testing was indeed quite useful.
John-LittleBearLabs Aug 10, 2022
42e393e
Error types
John-LittleBearLabs Aug 10, 2022
f694dbf
Merge remote-tracking branch 'origin/develop' into jt/con-427_munge
John-LittleBearLabs Aug 10, 2022
143bc44
RTCPeerConnection does not exist during a test?
John-LittleBearLabs Aug 10, 2022
d6ddfbf
initial connection implementation
ckousik Aug 11, 2022
cac0f86
tests
ckousik Aug 11, 2022
529df96
about to merge
John-LittleBearLabs Aug 11, 2022
d9cbc83
Merge remote-tracking branch 'origin/ckousik/con-431' into possiblyde…
John-LittleBearLabs Aug 11, 2022
fd56251
Every public method covered with a test case
John-LittleBearLabs Aug 11, 2022
da01296
Merge pull request #10 from little-bear-labs/jt/con-427_munge
John-LittleBearLabs Aug 11, 2022
819d243
Merge remote-tracking branch 'origin/develop' into jt/con-439_streamTest
John-LittleBearLabs Aug 11, 2022
1ab83be
Merge pull request #15 from little-bear-labs/jt/con-439_streamTest
John-LittleBearLabs Aug 12, 2022
0a7acbe
Getting more specific with the errors being thrown.
John-LittleBearLabs Aug 12, 2022
3073031
Fix noise prologue generation
ckousik Aug 15, 2022
425b830
Shifting approach.
John-LittleBearLabs Aug 15, 2022
d5f0db9
Using error codes tied to error types by way of convenience functions.
John-LittleBearLabs Aug 15, 2022
fd63ecd
fix multibase
ckousik Aug 15, 2022
2b845e0
fix duplicate function
ckousik Aug 15, 2022
ea19f45
Merge remote-tracking branch 'origin/jt/error' into ckousik/noise-pro…
ckousik Aug 15, 2022
60df448
use new errors
ckousik Aug 15, 2022
cbb9864
remove comment
ckousik Aug 15, 2022
2556b17
Merge pull request #18 from little-bear-labs/ckousik/noise-prologue
ckousik Aug 15, 2022
2859c75
Initial pass at the README
ddimaria Aug 30, 2022
17f9f5a
Add CI templates
ddimaria Aug 31, 2022
db6d1b8
Add full aegir scripts to package.json
ddimaria Aug 31, 2022
9cda6dd
Merge pull request #21 from little-bear-labs/feature/fill-in-readme
ddimaria Sep 1, 2022
4c107c0
Merge remote-tracking branch 'origin/develop' into feature/add_ci_and…
ddimaria Sep 1, 2022
d9168c9
Revive aegir linting
ddimaria Sep 1, 2022
02adfaa
Unit testing WebRTCTransport (#19)
John-LittleBearLabs Sep 2, 2022
dc2042f
Add message framing to support half-close and reset of stream
John-LittleBearLabs Sep 2, 2022
bc47d77
Fill in README to match the package.json scripts
ddimaria Sep 2, 2022
ae5b841
Add develop as a target for GH Actions CI
ddimaria Sep 6, 2022
2047b07
Merge remote-tracking branch 'origin/develop' into feature/add_ci_and…
ddimaria Sep 6, 2022
345d65c
Correction from Chinmay's PR comment. Also, updated flag names based …
John-LittleBearLabs Sep 6, 2022
2cb112f
fixes
ckousik Sep 8, 2022
d6adda2
more fixes
ckousik Sep 8, 2022
2956313
fixes
ckousik Sep 9, 2022
e74f877
npm scripts to startup the golang server and get that ma into the tes…
John-LittleBearLabs Sep 12, 2022
ea298c2
Forgot the line ending.
John-LittleBearLabs Sep 12, 2022
47dd8ed
match ufrag pwd to spec
ckousik Sep 12, 2022
e31a42f
Removed node and electron-renderer jobs in CI
ddimaria Sep 12, 2022
c54b121
Add message framing to support half-close of stream (#20)
John-LittleBearLabs Sep 13, 2022
e156adf
Merge remote-tracking branch 'origin/develop' into feature/add_ci_and…
ddimaria Sep 13, 2022
94d4701
Merge pull request #22 from little-bear-labs/feature/add_ci_and_linting
ddimaria Sep 13, 2022
e487f28
Bump uuid from 8.3.2 to 9.0.0
dependabot[bot] Sep 13, 2022
a16b1dc
Merge branch 'develop' into ckousik/interop-test
ckousik Sep 13, 2022
19db64e
fix reject
ckousik Sep 14, 2022
9d6b10b
fix rejects
ckousik Sep 14, 2022
cd47528
add .nvmrc file to autmatically select required node engine
Sep 14, 2022
0f467df
address Glen's review
ckousik Sep 15, 2022
efd09ca
fix
ckousik Sep 15, 2022
5584eba
Merge pull request #25 from little-bear-labs/patch/add-nvmrc-file
ckousik Sep 16, 2022
7b3becc
use upgrader interface
ckousik Sep 26, 2022
0c80b92
Upgradable MultiaddrConnection
ckousik Sep 28, 2022
6824cfd
Merge pull request #23 from little-bear-labs/ckousik/interop-test
ckousik Sep 30, 2022
a9c23db
Merge branch 'develop' into ckousik/upgradable
ckousik Sep 30, 2022
b8403c0
Bump @multiformats/multiaddr from 10.5.0 to 11.0.3
dependabot[bot] Sep 30, 2022
76f3cd4
Bump @chainsafe/libp2p-noise from 8.0.2 to 9.0.0
dependabot[bot] Oct 7, 2022
5888f82
update interfaces
ckousik Oct 10, 2022
f9ad5d0
Bump @libp2p/interface-mocks from 4.0.3 to 6.1.0
dependabot[bot] Oct 12, 2022
5cec3d6
Bump @libp2p/components from 2.1.1 to 3.1.1
dependabot[bot] Oct 12, 2022
cc890c0
Merge pull request #29 from little-bear-labs/ckousik/upgradable
ckousik Oct 12, 2022
657f6e7
Merge branch 'develop' into dependabot/npm_and_yarn/libp2p/interface-…
ckousik Oct 12, 2022
e38c98a
Merge pull request #41 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Oct 12, 2022
5014a85
Merge branch 'develop' into dependabot/npm_and_yarn/multiformats/mult…
ckousik Oct 12, 2022
92e80d5
Merge pull request #30 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Oct 12, 2022
e667593
Merge pull request #24 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Oct 12, 2022
d098ff4
Merge branch 'develop' into dependabot/npm_and_yarn/chainsafe/libp2p-…
ckousik Oct 12, 2022
7be66bd
Merge pull request #34 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Oct 12, 2022
0685d72
Merge branch 'develop' into dependabot/npm_and_yarn/libp2p/components…
ckousik Oct 12, 2022
510ae3c
Merge pull request #42 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Oct 12, 2022
92fe5a6
Bump multiformats from 9.9.0 to 10.0.0
dependabot[bot] Oct 12, 2022
bc96c4b
Merge pull request #43 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Oct 12, 2022
dbd0237
deps: update libp2p to release version
achingbrain Oct 17, 2022
2b41b7f
Merge pull request #48 from achingbrain/deps/update-libp2p
ckousik Oct 17, 2022
cad0263
fix handshake channel
ckousik Oct 17, 2022
764c930
Merge pull request #49 from little-bear-labs/ckousik/fix-handshake
ckousik Oct 17, 2022
2576453
fix hash algorithm to sha-256
ckousik Oct 18, 2022
d650972
Merge pull request #51 from little-bear-labs/ckousik/fix-prologue
ckousik Oct 24, 2022
ffad684
A series of changes I made so I could import this library
plauche Oct 17, 2022
1a10fb3
More changes
plauche Oct 17, 2022
11610ac
Cleaning up and minimizing changes
plauche Oct 28, 2022
ed6deda
Merge pull request #50 from little-bear-labs/changes-for-importing
plauche Oct 29, 2022
f1f46dc
Add message length
ckousik Oct 31, 2022
9d29cb0
use it-length-prefixed
ckousik Oct 31, 2022
43a8820
stream transitions
ckousik Nov 1, 2022
51aa49d
add comments
ckousik Nov 1, 2022
f80baba
fix
ckousik Nov 2, 2022
2b7b2c1
Merge pull request #54 from little-bear-labs/ckousik/add-prefix-len
ckousik Nov 2, 2022
c25a42d
Bump @chainsafe/libp2p-noise from 9.0.0 to 10.0.0
dependabot[bot] Nov 2, 2022
9172498
Merge pull request #52 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Nov 2, 2022
9854ff3
Determine hash function from multiaddr
ckousik Nov 3, 2022
2e8da7c
Merge pull request #55 from little-bear-labs/ckousik/hash-function
ckousik Nov 3, 2022
e5b12cf
Apply auto lint fixer
ddimaria Nov 3, 2022
4f2e574
Upgrade code to work with new noise API
ddimaria Nov 3, 2022
885326f
Fix all linting errors and begin to refactor code + documentation
ddimaria Nov 4, 2022
a99e5b2
Fix CI
ddimaria Nov 4, 2022
b3393c4
Add missing dependencies in package.json
ddimaria Nov 4, 2022
f3d74f0
Bump @libp2p/interface-mocks from 7.1.0 to 8.0.1
dependabot[bot] Nov 8, 2022
58bf647
Add .js extensions to src imports and reorder imports
ddimaria Nov 8, 2022
a02c541
Fix lints
ddimaria Nov 8, 2022
f15cafc
Merge pull request #56 from little-bear-labs/bugfix/fix-linting-issues
ddimaria Nov 9, 2022
a2407bd
test prepare script
ckousik Nov 17, 2022
a2c83dd
add proto files
ckousik Nov 17, 2022
c8c329e
Fill in code documentation
ddimaria Nov 18, 2022
6d7c528
Ignore coverage reports
ddimaria Nov 18, 2022
e4b0d71
Merge pull request #59 from little-bear-labs/ckousik/temp-fix-install
ckousik Nov 18, 2022
b2e4f60
Merge pull request #57 from little-bear-labs/dependabot/npm_and_yarn/…
ckousik Nov 18, 2022
37794cd
Test maconn, update existing test and code to accomodate tests
ddimaria Nov 30, 2022
232d171
Create a browser-to-server example
ddimaria Dec 1, 2022
1c7b463
Fix copy/paste documentation errors
ddimaria Dec 1, 2022
4599d33
Remove unused
ddimaria Dec 1, 2022
041a057
Test chrome and firefox
ddimaria Dec 1, 2022
d42e613
Merge remote-tracking branch 'origin/develop' into feature/refactor-a…
ddimaria Dec 1, 2022
86dd1d2
Add webworker tests
ddimaria Dec 1, 2022
3b78322
Removing webworker scripts as webrtc doesn't work in web/service workers
ddimaria Dec 1, 2022
7d83c81
Polish all the READMEs
ddimaria Dec 2, 2022
57a0635
Prefer template literals
ddimaria Dec 2, 2022
581ca72
Remove webworker and electron jobs in CI
ddimaria Dec 2, 2022
9d3afb0
Cosmetic refactors
ddimaria Dec 2, 2022
0a6ce42
Update master reference to main in CI
ddimaria Dec 2, 2022
584c6fa
Refactor stream tests
ddimaria Dec 2, 2022
a1df8c3
Complete transport tests
ddimaria Dec 2, 2022
dbf9bd4
Update src/muxer.ts
ddimaria Dec 5, 2022
f254822
Update examples/browser-to-server/README.md
ddimaria Dec 5, 2022
0ea38dc
Merge pull request #60 from little-bear-labs/feature/refactor-and-add…
ddimaria Dec 5, 2022
6760bbb
Remove prepare script
ddimaria Dec 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
build: {
config: {
platform: 'node'
},
bundlesizeMax: '31KB'
}
}
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
11 changes: 11 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

name: Automerge
on: [ pull_request ]

jobs:
automerge:
uses: protocol/.github/.github/workflows/automerge.yml@master
with:
job: 'automerge'
71 changes: 71 additions & 0 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: test & maybe release
on:
push:
branches:
- main # with #262 - ${{{ github.default_branch }}}
pull_request:
branches:
- main # with #262 - ${{{ github.default_branch }}}
- develop

jobs:

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present lint
- run: npm run --if-present dep-check

test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome

test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox

release:
needs: [test-chrome, test-firefox]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: ipfs/aegir/actions/docker-login@master
with:
docker-token: ${{ secrets.DOCKER_TOKEN }}
docker-username: ${{ secrets.DOCKER_USERNAME }}
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
*.swp

pids
logs
results
tmp

# Build
public/css/main.css

# Coverage reports
coverage
.coverage
.nyc_output

# API keys and secrets
.env

# Dependency directory
node_modules
bower_components

# Editors
.idea
*.iml
.vscode/launch.json

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
dist/
types/

# ignore yarn.lock
yarn.lock
package-lock.json


1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.17.0
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth":180,
"tabWidth":2,
"useTabs":false,
"semi":true,
"singleQuote":true,
"trailingComma":"es5",
"bracketSpacing":true,
"jsxBracketSameLine":false,
"arrowParens":"always",
"requirePragma":false,
"insertPragma":false,
"proseWrap":"preserve"
}
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
19 changes: 19 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
198 changes: 198 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# @libp2p/webrtc <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/little-bear-labs/js-libp2p-webrtc.svg?style=flat-square)](https://codecov.io/gh/little-bear-labs/js-libp2p-webrtc)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/little-bear-labs/js-libp2p-webrtc/actions/workflows/js-test-and-release.yml)

> The browser implementation of the WebRTC module for libp2p.

## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Usage](#usage)
- [Examples](#examples)
- [Interfaces](#interfaces)
- [Transport](#transport)
- [Connection](#connection)
- [Contribute](#contribute)
- [Build](#build)
- [Protocol Buffers](#protocol-buffers)
- [Test](#test)
- [Lint](#lint)
- [Clean](#clean)
- [Check Dependencies](#check-dependencies)
- [Build a Release](#build-a-release)
- [License](#license)
- [Contribution](#contribution)

## Install

```shell
npm i @libp2p/webrtc
```

## Usage

```js
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 'js-libp2p-webrtc'

const node = await createLibp2p({
transports: [webRTC()],
connectionEncryption: [() => new 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](examples/README.md).

## Interfaces

### Transport

![https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-transport](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/packages/interface-transport/img/badge.png)

Browsers can only `dial`, so `listen` is not supported.

```js
interface Transport {
[Symbol.toStringTag]: string
[symbol]: true
dial: (ma: Multiaddr, options: DialOptions) => Promise<Connection>
createListener: (options: CreateListenerOptions) => Listener
filter: MultiaddrFilter
}

class WebRTCTransport implements Transport {

async dial (ma: Multiaddr, options: WebRTCDialOptions): Promise<Connection> {
const rawConn = await this._connect(ma, options)
log(`dialing address - ${ma.toString()}`)
return rawConn
}

createListener (options: CreateListenerOptions): Listener {
throw unimplemented('WebRTCTransport.createListener')
}
}
```

### Connection

![https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-connection](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/packages/interface-connection/img/badge.png)

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

class WebRTCMultiaddrConnection implements MultiaddrConnection { }
```

## Contribute

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](//github.com/little-bear-labs/js-libp2p-webrtc/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](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/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:

```shell
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:

```shell
npm test
```

To run tests for Chome only:

```shell
npm run test:chrome
```

To run tests for Firefox only:

```shell
npm run test:firefox
```

### Lint
Aegir is also used to lint the code, which follows the [Standard](https://github.com/standard/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:

```shell
npm run lint
```

You can also auto-fix when applicable:

```shell
npm run lint:fix
```

### Clean

```shell
npm run clean
```

### Check Dependencies

```shell
npm run deps-check
```

### Build a Release

```shell
npm run release
```
## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## 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.
Loading