@libp2p/webrtc 3.2.5 → 3.2.6-051154dd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -138
- package/dist/index.min.js +10 -11
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +30 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +4 -6
- package/dist/src/private-to-private/initiate-connection.js.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts +2 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.js +3 -2
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.js +1 -1
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.d.ts +0 -1
- package/dist/src/private-to-private/util.d.ts.map +1 -1
- package/dist/src/private-to-private/util.js +0 -10
- package/dist/src/private-to-private/util.js.map +1 -1
- package/package.json +10 -10
- package/src/index.ts +31 -0
- package/src/private-to-private/initiate-connection.ts +5 -7
- package/src/private-to-private/signaling-stream-handler.ts +4 -3
- package/src/private-to-private/transport.ts +1 -1
- package/src/private-to-private/util.ts +0 -13
- package/dist/typedoc-urls.json +0 -8
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# @libp2p/webrtc <!-- omit in toc -->
|
|
2
|
-
|
|
3
1
|
[](http://libp2p.io/)
|
|
4
2
|
[](https://discuss.libp2p.io)
|
|
5
3
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
@@ -7,41 +5,11 @@
|
|
|
7
5
|
|
|
8
6
|
> A libp2p transport using WebRTC connections
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Examples](#examples)
|
|
16
|
-
- [Interfaces](#interfaces)
|
|
17
|
-
- [Transport](#transport)
|
|
18
|
-
- [Connection](#connection)
|
|
19
|
-
- [Development](#development)
|
|
20
|
-
- [Build](#build)
|
|
21
|
-
- [Protocol Buffers](#protocol-buffers)
|
|
22
|
-
- [Test](#test)
|
|
23
|
-
- [Lint](#lint)
|
|
24
|
-
- [Clean](#clean)
|
|
25
|
-
- [Check Dependencies](#check-dependencies)
|
|
26
|
-
- [API Docs](#api-docs)
|
|
27
|
-
- [License](#license)
|
|
28
|
-
- [Contribution](#contribution)
|
|
29
|
-
|
|
30
|
-
## Install
|
|
31
|
-
|
|
32
|
-
```console
|
|
33
|
-
$ npm i @libp2p/webrtc
|
|
34
|
-
```
|
|
8
|
+
# About
|
|
35
9
|
|
|
36
|
-
|
|
10
|
+
A [libp2p transport](https://docs.libp2p.io/concepts/transports/overview/) based on [WebRTC datachannels](https://webrtc.org/).
|
|
37
11
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```html
|
|
41
|
-
<script src="https://unpkg.com/@libp2p/webrtc/dist/index.min.js"></script>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Usage
|
|
12
|
+
## Example
|
|
45
13
|
|
|
46
14
|
```js
|
|
47
15
|
import { createLibp2p } from 'libp2p'
|
|
@@ -55,7 +23,7 @@ import { webRTC } from '@libp2p/webrtc'
|
|
|
55
23
|
const node = await createLibp2p({
|
|
56
24
|
transports: [webRTC()],
|
|
57
25
|
connectionEncryption: [noise()],
|
|
58
|
-
})
|
|
26
|
+
})
|
|
59
27
|
|
|
60
28
|
await node.start()
|
|
61
29
|
|
|
@@ -66,123 +34,31 @@ const response = await pipe([fromString(message)], stream, async (source) => awa
|
|
|
66
34
|
const responseDecoded = toString(response.slice(0, response.length))
|
|
67
35
|
```
|
|
68
36
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Examples can be found in the [examples folder](examples/README.md).
|
|
72
|
-
|
|
73
|
-
## Interfaces
|
|
74
|
-
|
|
75
|
-
### Transport
|
|
76
|
-
|
|
77
|
-

|
|
78
|
-
|
|
79
|
-
Browsers can usually only `dial`, but `listen` is supported in the WebRTC
|
|
80
|
-
transport when paired with another listener like CircuitV2, where you listen on
|
|
81
|
-
a relayed connection. Take a look at [index.js](examples/browser-to-browser/index.js) for
|
|
82
|
-
an example.
|
|
83
|
-
|
|
84
|
-
### Connection
|
|
85
|
-
|
|
86
|
-

|
|
87
|
-
|
|
88
|
-
```js
|
|
89
|
-
interface MultiaddrConnection extends Duplex<Uint8Array> {
|
|
90
|
-
close: (err?: Error) => Promise<void>
|
|
91
|
-
remoteAddr: Multiaddr
|
|
92
|
-
timeline: MultiaddrConnectionTimeline
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
class WebRTCMultiaddrConnection implements MultiaddrConnection { }
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Development
|
|
99
|
-
|
|
100
|
-
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:
|
|
101
|
-
|
|
102
|
-
- [Check out the existing issues](//github.com/little-bear-labs/js-libp2p-webrtc/issues).
|
|
103
|
-
- **Perform code reviews**.
|
|
104
|
-
- **Add tests**. There can never be enough tests.
|
|
105
|
-
- 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.
|
|
106
|
-
|
|
107
|
-
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).
|
|
108
|
-
|
|
109
|
-
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
|
|
110
|
-
|
|
111
|
-
This module leans heavily on (Aegir)\[<https://github.com/ipfs/aegir>] for most of the `package.json` scripts.
|
|
112
|
-
|
|
113
|
-
### Build
|
|
37
|
+
# Install
|
|
114
38
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```shell
|
|
118
|
-
npm run build
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
The build will be located in the `/dist` folder.
|
|
122
|
-
|
|
123
|
-
### Protocol Buffers
|
|
124
|
-
|
|
125
|
-
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.
|
|
126
|
-
|
|
127
|
-
### Test
|
|
128
|
-
|
|
129
|
-
To run all tests:
|
|
130
|
-
|
|
131
|
-
```shell
|
|
132
|
-
npm test
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
To run tests for Chrome only:
|
|
136
|
-
|
|
137
|
-
```shell
|
|
138
|
-
npm run test:chrome
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
To run tests for Firefox only:
|
|
142
|
-
|
|
143
|
-
```shell
|
|
144
|
-
npm run test:firefox
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Lint
|
|
148
|
-
|
|
149
|
-
Aegir is also used to lint the code, which follows the [Standard](https://github.com/standard/standard) JS linter.
|
|
150
|
-
The VS Code plugin for this standard is located at <https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard>.
|
|
151
|
-
To lint this repo:
|
|
152
|
-
|
|
153
|
-
```shell
|
|
154
|
-
npm run lint
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
You can also auto-fix when applicable:
|
|
158
|
-
|
|
159
|
-
```shell
|
|
160
|
-
npm run lint:fix
|
|
39
|
+
```console
|
|
40
|
+
$ npm i @libp2p/webrtc
|
|
161
41
|
```
|
|
162
42
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
```shell
|
|
166
|
-
npm run clean
|
|
167
|
-
```
|
|
43
|
+
## Browser `<script>` tag
|
|
168
44
|
|
|
169
|
-
|
|
45
|
+
Loading this module through a script tag will make it's exports available as `Libp2pWebrtc` in the global namespace.
|
|
170
46
|
|
|
171
|
-
```
|
|
172
|
-
|
|
47
|
+
```html
|
|
48
|
+
<script src="https://unpkg.com/@libp2p/webrtc/dist/index.min.js"></script>
|
|
173
49
|
```
|
|
174
50
|
|
|
175
|
-
|
|
51
|
+
# API Docs
|
|
176
52
|
|
|
177
53
|
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_webrtc.html>
|
|
178
54
|
|
|
179
|
-
|
|
55
|
+
# License
|
|
180
56
|
|
|
181
57
|
Licensed under either of
|
|
182
58
|
|
|
183
59
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
184
60
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
185
61
|
|
|
186
|
-
|
|
62
|
+
# Contribution
|
|
187
63
|
|
|
188
64
|
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.
|